@liberfi.io/ui-predict 4.0.59 → 4.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- 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,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTradeResultConfirmation,useTickSize,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,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents,usePositions}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount,debounce}from'@liberfi.io/utils';import Fo 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 {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var Pc={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Bi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Io=(()=>{let e=t=>{let r=Bi.indexOf(t);return r===-1?Bi.length:r};return Object.entries(Pc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Wi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:s="Trending",className:l}){let{t:u}=useTranslation(),m=useCallback(()=>{o(null);},[o]),c=u("predict.categories.trending");return jsxs("div",{className:cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxs("div",{className:"cat-primary-row",children:[jsx("div",{className:"cat-tabs hideScrollbar",children:jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsx(Hi,{label:c,isSelected:t===null,onPress:m,showPulse:c===s}),jsx(Tc,{}),e.map(f=>{let d=f.slug??f.category,p=f.label??f.category;return jsx(Hi,{label:p,isSelected:t===d,onPress:()=>o(d),badge:f.badge,showPulse:d===s||p===s},d)})]})}),a&&jsx("div",{className:"flex-shrink-0",children:a})]}),t&&n.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(zi,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(f=>{let d=f.slug??f.label;return jsx(zi,{label:f.label,icon:f.icon,isSelected:r===d,onPress:()=>i(d)},d)})]})})]})}function Hi({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,n&&jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:n})]})}function Tc(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function zi({label:e,icon:t,isSelected:r,onPress:n}){return jsxs("button",{type:"button",onClick:n,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function Fv({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 $i(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Lc(e){return `predict.categories.category.${$i(e)}`}function Ki(e){return `predict.categories.tag.${$i(e)}`}function Rc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Lc(r.slug),r.label),tags:r.tags.map(n=>({slug:n.slug,label:t(Ki(n.slug),n.label),icon:n.icon}))}))}function _c(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Ki(r.slug),r.label),icon:r.icon})):[]}function Vi({onSelect:e,trailing:t,className:r}){let{t:n}=useTranslation(),o=useCallback((p,g)=>{let h=n(p);return typeof h=="string"&&h!==p?h:g},[n]),[i,a]=useState(null),[s,l]=useState(null),u=useCallback(p=>{a(p),l(null),e?.({categorySlug:p,tagSlug:null});},[e]),m=useCallback(p=>{l(p),e?.({categorySlug:i,tagSlug:p});},[i,e]),c=Rc(Io,o),f=Io.find(p=>p.slug===i),d=_c(f,o);return jsx(Wi,{categories:c,selectedCategory:i,selectedTag:s,activeTags:d,onCategorySelect:u,onTagSelect:m,trailing:t,className:r})}function Dn(e){return {title:e.title,imageUrl:e.image_url}}function Fn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var rn=24,Ao=4,Bn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ce={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Hn=ce.ALL,Gv={[ce.ONE_DAY]:Bn.ONE_MINUTE,[ce.ONE_WEEK]:Bn.ONE_HOUR,[ce.ONE_MONTH]:Bn.ONE_HOUR,[ce.ALL]:Bn.ONE_DAY},qv={[ce.ONE_DAY]:300,[ce.ONE_WEEK]:3600,[ce.ONE_MONTH]:10800,[ce.ALL]:1440*60},Yv={[ce.ONE_DAY]:1440*60,[ce.ONE_WEEK]:10080*60,[ce.ONE_MONTH]:720*60*60,[ce.ALL]:null},zn=1,Wn=1,Qv=1,Xv=1,Jv=99,Br={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Zv=Br.ONE_WEEK,eb={[Br.ONE_HOUR]:60,[Br.SIX_HOURS]:60,[Br.ONE_DAY]:300,[Br.ONE_WEEK]:1800,[Br.MAX]:1800};var qi=createContext(null);function xr(){let e=useContext(qi);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Hc=1e4;function zc({pollingInterval:e=Hc,enabled:t=true,enableKalshi:r=true,children:n}){let o=useWallets(),i=useMemo(()=>o.find(R=>R.chainNamespace===ChainNamespace.SOLANA&&R.isConnected)?.address,[o]),a=useMemo(()=>o.find(R=>R.chainNamespace===ChainNamespace.EVM&&R.isConnected)?.address,[o]),{data:s,isLoading:l,isFetching:u,error:m}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:c,isLoading:f}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:d,isLoading:p}=usePolymarketSetup(a,{enabled:t&&!!a,refetchInterval:3e4}),g=d?.safe_address,v=d?.verified??false,h=d?.wallet_kind??"deposit",x=d?.deposit_wallet_address,S=h==="safe"?d?.safe_address:x,k=h==="safe"?d?.safe_deployed??false:d?.deposit_wallet_deployed??false,{data:b,isLoading:y,isFetching:N,error:E}=useBalance({source:"polymarket",user:a??""},{enabled:t&&v&&!!a,refetchInterval:e}),P=useMemo(()=>({solanaAddress:i,evmAddress:a,polymarketWalletKind:h,polymarketWalletAddress:S,polymarketDepositWalletAddress:x,polymarketWalletDeployed:k,polymarketSafeAddress:g,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:v&&b?Number(b.balance):null,kalshiKycVerified:c?.verified??false,kalshiKycUrl:c?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:v,polymarketSafeDeployed:d?.safe_deployed??false,polymarketTokenApproved:d?.token_approved??false,polymarketSetupLoading:p,isLoading:l||y,isFetching:u||N,error:m??E??null}),[i,a,h,S,x,k,g,s,b,v,c,f,d,p,l,y,u,N,m,E]);return jsx(qi.Provider,{value:P,children:n})}var Uc={minutes:60,hours:3600,days:86400};function Un(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*Uc[r]}}function $n(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function xe(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function $c(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Kc=100,Vc=300;function Bo(e,t){return Kc/1e4+Math.max(0,e)/1e4*$c(t)}function jc(e,t){let r=e?.[t],n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:void 0}function Gc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Yi(e){let t=jc(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],n=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(n)&&n>=0?n*1e4:Gc(e,"polymarket.sportsMarketType")?Vc:0}function Qi({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:n=0,pricePerShare:o}){if(t==null||!Number.isFinite(t))return 0;let i=xe(Math.max(0,t),2);if(e!=="polymarket")return i;let a=Bo(n,o??NaN),s=i/(1+a)-r;return xe(Math.max(0,s),2)}function Xi({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Ji({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Kn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let a=parseInt(o[1],10)/1e6,s=parseInt(o[2],10)/1e6,l=Math.max(0,a-s);return t("predict.trade.polymarket.insufficientBalance",{total:xe(a,2).toFixed(2),active:xe(s,2).toFixed(2),available:xe(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function yr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function Zi(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Fo({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Fo({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Fo({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var es={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function qc(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function Ho(e,t,r){let n=e(t);return n&&n!==t?n:r}function Hr(e,t){let r=qc(t)?es.zh:es.en;return {submitted:Ho(e,"predict.trade.resultSubmitted",r.submitted),completed:Ho(e,"predict.trade.resultCompleted",r.completed),delayed:Ho(e,"predict.trade.resultDelayed",r.delayed)}}function Jc({deadlineAt:e}){let[t,r]=useState(()=>Math.max(0,e-Date.now()));return useEffect(()=>{let n=setInterval(()=>{r(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(n)},[e]),`${Math.max(0,Math.ceil(t/1e3))}s`}function zr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:n}){return {id:e,submitted:()=>{let o=Date.now()+t;toast.progress({id:e,message:n.submitted,duration:t,progress:true,action:createElement(Jc,{deadlineAt:o})});},completed:()=>{toast.update(e,{type:"success",message:n.completed,duration:5e3}),r&&Zi();},delayed:()=>{toast.update(e,{type:"blank",message:n.delayed,duration:8e3});},failed:o=>{toast.update(e,{type:"error",message:o,duration:8e3});}}}function ns({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o,i18n:i}=useTranslation(),{status:a}=useAuth(),s=useWallets(),l=usePredictClient(),u=useContext(PolymarketContext),{start:m}=useTradeResultConfirmation(),c=e.source,f=c==="polymarket",d=s.find(_=>_.chainNamespace===ChainNamespace.SOLANA&&_.isConnected),p=s.find(_=>_.chainNamespace===ChainNamespace.EVM&&_.isConnected&&"switchChain"in _),g=a==="authenticated",v=d?.address,h=p?.address,[x,S]=useState(t),[k,b]=useState("market"),[y,N]=useState(NaN),[E,P]=useState(NaN),[R,D]=useState(false),[U,Q]=useState(null),[H,Y]=useState(false),[q,te]=useState(false),[C,T]=useState("1h"),[B,J]=useState(30),[ue,se]=useState("minutes"),Ge=useMemo(()=>Hr(o,i),[i,o]),We=useCallback(async(_,Fe)=>{let Ke=zr({celebrateOnCompleted:true,messages:Ge});Ke.submitted(),await m({source:c,user:c==="kalshi"?v:h,kalshiUser:v,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:_,getOrdersHeaders:Fe})==="confirmed"?Ke.completed():Ke.delayed();},[m,h,e.event_slug,e.slug,c,Ge,v]),st=useMemo(()=>{if(c!=="polymarket")return;let _=e.provider_meta?.["polymarket.clobTokenIds"];return _?(typeof _=="string"?JSON.parse(_):_)[x==="yes"?0:1]:void 0},[c,e.provider_meta,x]),{data:w,isLoading:gt}=useTickSize(st),Ae=w?.minimum_tick_size?String(w.minimum_tick_size):"0.01",{data:Ue,isLoading:Nt}=useFeeRate(st),Pe=Ue?.base_fee??0,at=String(Pe),qe=useMemo(()=>Yi(e.provider_meta),[e.provider_meta]),{data:De}=useRebateConfig(),Re=De?.builder_enabled&&De.builder_code?De.builder_code:void 0,_e=null,Ct=false,Mt=null,At=false,ut,et,Tt;try{let _=xr();_e={kalshiUsdcBalance:_.kalshiUsdcBalance,polymarketUsdcBalance:_.polymarketUsdcBalance,isLoading:_.isLoading},Ct=_.kalshiKycVerified,Mt=_.kalshiKycUrl,At=_.polymarketSetupVerified,ut=_.polymarketSafeAddress,et=_.polymarketWalletKind,Tt=_.polymarketWalletAddress;}catch{}let lt=c==="kalshi"&&!Ct,ht=c==="polymarket"&&!At,{data:Ne}=useRealtimeOrderbook({slug:e.slug,source:c,outcome:x},{enabled:e.status==="open"}),ye=useMemo(()=>{let _=pickBestAsk(Ne,x);if(_!=null&&_>0)return _;let Fe=x==="yes"?0:1,Ke=e.outcomes[Fe];return Ke?.best_ask??Ke?.price??.5},[Ne,e.outcomes,x]),Et=useCallback(_=>{b(_);},[]),Ye=useCallback(_=>{S(_),P(NaN);},[]);useEffect(()=>{Ye(t);},[t,Ye]),useEffect(()=>{k==="limit"&&isNaN(E)&&P(Math.round(ye*1e4)/1e4);},[k,E,ye]);let ve=useMemo(()=>k==="limit"&&f&&!isNaN(E)?E:ye,[k,f,E,ye]),$e=useMemo(()=>isNaN(y)||y<=0?0:ve>0?y/ve:0,[y,ve]),be=useMemo(()=>walkOrderbook({orderbook:Ne,outcome:x,side:"buy",sharesNeeded:$e,slippageBps:r}),[Ne,x,$e,r]),Lt=useMemo(()=>be.status==="ok"&&be.worstPrice!=null&&be.worstPrice>0?be.worstPrice:ye,[be,ye]),Rt=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),I=e.provider_meta?.["dflow.yesMint"]??"",Me=e.provider_meta?.["dflow.noMint"]??"",Ce=SOLANA_TOKENS.stablecoins.USDC.address,Xr=x==="yes"?I:Me,O=Ce,Te=Xr,tt=c==="kalshi"?v??"":h??"",{data:Jr,isLoading:Co}=usePositionsMulti({kalshi_user:c==="kalshi"?tt:void 0,polymarket_user:c==="polymarket"?tt:void 0},{enabled:!!tt}),Cn=c==="kalshi"&&!!O&&!!Te&&!!v&&Rt!=="0",{refetch:Lr}=useDFlowQuote({inputMint:O,outputMint:Te,amount:Rt,userPublicKey:v??"",slippageBps:100},{enabled:Cn}),Qe=useMemo(()=>_e?c==="kalshi"?_e.kalshiUsdcBalance:_e.polymarketUsdcBalance:Jr&&Jr.positions.reduce((Fe,Ke)=>Ke.side==="USDC"||Ke.side==="collateral"?Fe+(Ke.current_value??0):Fe,0)||null,[_e,Jr,c]),Rr=_e?_e.isLoading:Co,_r=useMemo(()=>Qi({source:c,usdcBalance:Qe,feeRateBps:qe,pricePerShare:ve}),[c,Qe,qe,ve]),Ht=Qe==null?null:_r,Ir=useMemo(()=>isNaN(y)||y<=0?0:y,[y]),Yt=useMemo(()=>isNaN(y)||y<=0?0:ve>0?y/ve*1:0,[y,ve]),Mn=useMemo(()=>c!=="polymarket"||isNaN(y)||y<=0?0:Xi({usdcAmount:y,pricePerShare:ve,feeRateBps:qe}),[c,y,ve,qe]),Tn=Yt-Ir-Mn,Mo=useCallback(_=>{if(isNaN(_)){N(NaN);return}N(Math.round(Math.max(0,_)*100)/100);},[]),pr=useCallback(_=>{if(isNaN(_)){P(NaN);return}P(Math.round(_*1e4)/1e4);},[]),zt=useCallback(()=>{N(NaN),P(NaN),b("market"),te(false),T("1h"),J(30),se("minutes");},[]),Qt=useMemo(()=>{let _=[];return isNaN(y)||y<=0?_.push(o("predict.trade.minAmountUsd",{amount:Wn})):y<Wn&&_.push(o("predict.trade.minAmountUsd",{amount:Wn})),e.status!=="open"&&_.push(o("predict.trade.marketNotActive")),Ht!=null&&!isNaN(y)&&y>0&&y>Ht&&_.push(o("predict.trade.insufficientBalance")),k==="limit"&&f&&(isNaN(E)||E<.01||E>.99)&&_.push(o("predict.trade.limitPriceRange")),k==="limit"&&f&&q&&C==="custom"&&(isNaN(B)||B<=0)&&_.push(o("predict.trade.expiration.invalidDate")),c==="polymarket"&&k==="market"&&!isNaN(y)&&y>0&&$e>0&&(be.status==="insufficient_liquidity"?_.push(o("predict.trade.insufficientLiquidity",{available:xe(be.totalAvailable,2)})):be.status==="exceeds_slippage"&&_.push(o("predict.trade.priceImpactTooHigh",{impact:(be.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:_.length===0,errors:_}},[y,e.status,Ht,k,f,E,q,C,B,c,$e,be,r,o]),Or=useMemo(()=>Ht==null||isNaN(y)||y<=0?false:y>Ht,[Ht,y]),To=useCallback(()=>{n?.(c);},[n,c]),{mutateAsync:Zr}=useDFlowSubmit(),{data:mr}=useOrder({id:U??"",source:c},{enabled:!!U});useEffect(()=>{if(!mr||!U)return;let{status:_}=mr;_==="closed"?(Q(null),D(false),We("buy-market"),zt()):(_==="failed"||_==="expired")&&(D(false),Q(null),toast.error(o("predict.trade.submitError")));},[We,mr,U,zt,o]);let vt=useCallback(async()=>{if(!v||!d)return;if(!O||!Te){toast.error("Missing token mint addresses"),D(false);return}if(!Ct){Y(true),D(false);return}let _t=(await Lr()).data?.transaction;if(!_t){toast.error(o("predict.trade.submitError")),D(false);return}let en=Uint8Array.from(atob(_t),ct=>ct.charCodeAt(0)),hr=await d.signTransaction(en),Xt=await Zr({signedTransaction:btoa(String.fromCharCode(...hr)),orderContext:{user_public_key:v,input_mint:O,output_mint:Te,amount:Rt,price:String(ye),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(Xt.signature);},[v,d,Lr,Zr,O,Te,Rt,ye,x,e.slug,o,Ct]),fr=useCallback(async()=>{if(!p||!u)return;let _=p.chain,Fe=_!==Chain.POLYGON;Fe&&await p.switchChain(Chain.POLYGON);try{let Ke=await p.getEip1193Provider();if(!Ke){toast.error(o("predict.trade.submitError")),D(!1);return}let _t=et==="deposit"&&!!Tt,en=!_t&&!!ut,hr=_t?Tt:ut,Xt={address:p.address,signatureType:_t?3:en?2:0,signTypedData:async(le,ke,Xe,rt)=>{let nt=[];"name"in le&&nt.push({name:"name",type:"string"}),"version"in le&&nt.push({name:"version",type:"string"}),"chainId"in le&&nt.push({name:"chainId",type:"uint256"}),"verifyingContract"in le&&nt.push({name:"verifyingContract",type:"address"}),"salt"in le&&nt.push({name:"salt",type:"bytes32"});let It={EIP712Domain:nt,...ke};return await Ke.request({method:"eth_signTypedData_v4",params:[p.address,JSON.stringify({domain:le,types:It,primaryType:Xe,message:rt})]})}},ct=u.credentials??await u.authenticate(Xt),vr=x==="yes"?0:1,Ar="",Jt=e.provider_meta?.["polymarket.clobTokenIds"];Jt&&(Ar=(typeof Jt=="string"?JSON.parse(Jt):Jt)[vr]??"");let Dr=e.provider_meta?.["polymarket.negRisk"]??!1,En=k==="limit"&&!isNaN(E)?E:Lt,Zt=$n(En,Ae),Ln=k==="limit"?q?"GTD":"GTC":"FOK",Rn=k==="market"?y:Zt>0?y/Zt:0,tn={tokenId:Ar,price:Zt,size:Rn,side:"BUY",orderType:Ln,tickSize:Ae,negRisk:Dr,...hr&&{funderAddress:hr},...Re&&{builderCode:Re},...k==="limit"&&q&&{expiration:Un(C,B,ue)}},M;if(_t)M=await buildSignedV2OrderPayload({signer:Xt,depositWalletAddress:hr,input:tn,owner:ct.apiKey});else {let le=buildCtfExchangeDomain(Dr),ke=buildOrderMessage({...tn,signerAddress:Xt.address,signatureType:Xt.signatureType,feeRateBps:at}),Xe=await Xt.signTypedData(le,CTF_ORDER_TYPES,"Order",ke),rt=buildSignedOrder(ke,Xe,tn.orderType);M=buildClobPayload(rt,ct.apiKey);}await l.executePolymarketOrder({payload:M,l2_api_key:ct.apiKey,l2_secret:ct.secret,l2_passphrase:ct.passphrase,signer_address:ct.address,owner:ct.apiKey}),We(k==="limit"?"buy-limit":"buy-market",async()=>await buildPolymarketL2Headers(ct.address,{apiKey:ct.apiKey,secret:ct.secret,passphrase:ct.passphrase,method:"GET",requestPath:"/data/orders"})),zt(),D(!1);}finally{Fe&&_&&p.switchChain(_).catch(()=>{});}},[p,u,x,e.provider_meta,k,We,E,Lt,y,l,q,C,B,ue,zt,o,Ae,at,ut,et,Tt,Re]),gr=useCallback(async()=>{if(!(!Qt.isValid||!g)){D(true),Q(null),Y(false);try{c==="kalshi"?await vt():await fr();}catch(_){let Fe=_ instanceof Error?_.message:"",Ke=c==="polymarket"&&Fe?Kn(Fe,o,"buy"):Fe||void 0;toast.error(Ke||o("predict.trade.submitError")),D(false);}}},[Qt.isValid,g,c,vt,fr,o]);return {outcome:x,orderType:k,quantity:y,limitPrice:E,shares:$e,effectivePrice:ve,estimatedCost:Ir,estimatedFee:Mn,potentialPayout:Yt,potentialProfit:Tn,pricePerShare:ye,usdcBalance:Qe,maxBuyAmount:_r,spendableUsdcBalance:Ht,isBalanceLoading:Rr,isMarketDataLoading:c==="polymarket"&&(Nt||gt),isSubmitting:R,authStatus:a,validation:Qt,isInsufficientBalance:Or,source:c,supportsLimitOrder:f,kycRequired:H,needsKyc:lt,needsSetup:ht,kycUrl:Mt,expirationEnabled:q,expirationPreset:C,customDuration:B,customDurationUnit:ue,setOutcome:Ye,setOrderType:Et,setQuantity:Mo,setLimitPrice:pr,setExpirationEnabled:te,setExpirationPreset:T,setCustomDuration:J,setCustomDurationUnit:se,submit:gr,notifyInsufficientBalance:To}}function jn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:n(o)})]},o))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Dd=["5m","1h","12h","24h","eod","custom"],Fd={"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"},Bd=["minutes","hours","days"],Hd={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},zd={maximumFractionDigits:0},ar="-";function us({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:s,effectivePrice:l,potentialProfit:u,potentialPayout:m,estimatedCost:c,estimatedFee:f=0,usdcBalance:d,isBalanceLoading:p,isMarketDataLoading:g,isSubmitting:v,authStatus:h,isValid:x,validationErrors:S,isInsufficientBalance:k,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:N,kycRequired:E,needsKyc:P,needsSetup:R,kycUrl:D,expirationEnabled:U,expirationPreset:Q,customDuration:H,customDurationUnit:Y,oddsFormatter:q,outcomeLabels:te,onOutcomeChange:C,onOrderTypeChange:T,onQuantityChange:B,onLimitPriceChange:J,onExpirationEnabledChange:ue,onExpirationPresetChange:se,onCustomDurationChange:Ge,onCustomDurationUnitChange:We,onSubmit:st}){let{t:w}=useTranslation(),[gt,Ae]=useState(true),Ue=useDisclosure(),[Nt,Pe]=useState(""),at=useRef(false);useEffect(()=>{at.current||Pe(isNaN(i)?"":String(i));},[i]);let[qe,De]=useState(""),Re=useRef(false);useEffect(()=>{Re.current||(isNaN(a)?De(""):De(String(parseFloat((a*100).toFixed(2)))));},[a]);let _e=useCallback(O=>{if(O!==""&&!/^\d*\.?\d{0,2}$/.test(O))return;if(De(O),O===""||O==="."){J(NaN);return}let tt=parseFloat(O);isNaN(tt)||J(tt/100);},[J]),Ct=useCallback(O=>{if(O!==""&&!/^\d*\.?\d{0,2}$/.test(O))return;if(Pe(O),Ce(false),O===""||O==="."){B(NaN);return}let tt=parseFloat(O);isNaN(tt)||B(tt);},[B]);useEffect(()=>{E&&!Ue.isOpen&&Ue.onOpen();},[E]);let Mt=useMemo(()=>{let O=n==="yes"?t.yesAsk:t.noAsk;return O!=null?parseFloat((Number(O)*100).toFixed(2)):null},[n,t]),At=n==="yes"?t.yesAsk:t.noAsk,ut=At!=null&&q?q(Number(At)):Mt!=null?`${Mt} \xA2`:ar,et=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,Tt=Number.isFinite(l)&&q?q(l):et!=null?`${et} \xA2`:ar,lt=!isNaN(i)&&i>0,ht=lt?c+f:0,Ne=lt&&s>0?ht/s:0,ye=Ne>0&&q?q(Ne):Ne>0?`${parseFloat((Ne*100).toFixed(2))}\xA2`:ar,Et=h==="authenticated",Ye=h==="authenticating"||h==="deauthenticating",ve=Et&&(P||R),$e=useCallback(O=>te?.[O]??w(O==="yes"?"predict.trade.yes":"predict.trade.no"),[te,w]),be=useMemo(()=>{if(Ye)return w("predict.trade.checkingLogin");if(!Et)return w("predict.trade.loginToTrade");if(P)return w("predict.trade.kycRequired");if(R)return w("predict.trade.setupRequired");if(p)return w("predict.trade.loadingBalance");if(g)return w("predict.trade.loadingMarketData");if(v)return w("predict.trade.submitting");if(E)return w("predict.trade.kycRequired");if(!lt)return w("predict.trade.enterAmount");let O=$e(n),Te=u>0?` \u2192 Win $${u.toFixed(2)}`:"";return `${w("predict.trade.buy")} ${O}${Te}`},[Ye,Et,P,R,p,g,v,E,lt,n,$e,u,w]),Lt="primary",Rt=()=>{let O=N??xe(d??0,2);B(xe(O/2,2));},I=()=>{B(N??xe(d??0,2));},[Me,Ce]=useState(false),Xr=()=>{if(!Et){Ce(false),st();return}if(P){Ue.onOpen();return}if(R&&b){Ce(false),b();return}if(E){Ue.onOpen();return}if(k&&b){Ce(false),b();return}if(!x){Ce(true);return}Ce(false),st();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:O=>{r==="bordered"&&(O.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:O=>{r==="bordered"&&(O.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bullish",children:[w("predict.trade.buy")," ",$e(n)]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[y?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:O=>T(O),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:w("predict.trade.market")},"market"),jsx(Tab,{title:w("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&y?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:qe,onChange:O=>_e(O.target.value),onFocus:()=>{Re.current=true;},onBlur:()=>{Re.current=false,isNaN(a)?De(""):De(String(parseFloat((a*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"}}):ut!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:ut})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(O=>{let Te=O==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>C(O),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===O?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:$e(O)}),Te!=null&&jsx("span",{className:"ml-1 opacity-70",children:q?q(Number(Te)):`${parseFloat((Number(Te)*100).toFixed(2))}\xA2`})]})},O)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:Rt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("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-neutral-500 hover:text-foreground font-medium",children:w("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Nt,onChange:O=>Ct(O.target.value),onFocus:()=>{at.current=true;},onBlur:()=>{at.current=false,Pe(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Me&&S.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:S.map(O=>jsx("span",{className:"text-xs text-danger",children:O},O))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-neutral-500",children:w("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`$${xe(d,2).toFixed(2)}`:"$0"})]}),o==="limit"&&y&&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:w("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:U,onValueChange:ue,"aria-label":w("predict.trade.setExpiration")})]}),U&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[Q],onSelectionChange:O=>{let Te=Array.from(O)[0];Te&&se(Te);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Dd.map(O=>jsx(SelectItem,{children:w(Fd[O])},O))}),Q==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(H)?void 0:H,onValueChange:Ge,minValue:1,step:1,formatOptions:zd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[Y],onSelectionChange:O=>{let Te=Array.from(O)[0];Te&&We(Te);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Bd.map(O=>jsx(SelectItem,{children:w(Hd[O])},O))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>Ae(O=>!O),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:w("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",gt&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:q&&Number.isFinite(l)?Tt:et!=null?w("predict.trade.chance",{percent:et}):ar})]}),gt&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:ar})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?yr(s):ar})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${f.toFixed(2)}`})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalPayment")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${ht.toFixed(2)}`})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:ye})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${m.toFixed(2)}`:ar})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&u>0?`+$${u.toFixed(2)}`:ar})]})]})]}),jsx(Button,{color:Lt,fullWidth:true,radius:"lg",size:"lg",isDisabled:Ye||Et&&!ve&&(p||g||!lt||v),isLoading:Ye||Et&&!ve&&(v||p||g),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Xr,children:be})]}),jsx(jn,{isOpen:Ue.isOpen,onClose:Ue.onClose,kycUrl:D})]})}function qn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:a,onOutcomeChange:s,oddsFormatter:l,outcomeLabels:u}){let{outcome:m,orderType:c,quantity:f,limitPrice:d,shares:p,effectivePrice:g,estimatedCost:v,estimatedFee:h,potentialPayout:x,potentialProfit:S,pricePerShare:k,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:N,isMarketDataLoading:E,isSubmitting:P,authStatus:R,validation:D,isInsufficientBalance:U,supportsLimitOrder:Q,kycRequired:H,needsKyc:Y,needsSetup:q,kycUrl:te,expirationEnabled:C,expirationPreset:T,customDuration:B,customDurationUnit:J,setOutcome:ue,setOrderType:se,setQuantity:Ge,setLimitPrice:We,setExpirationEnabled:st,setExpirationPreset:w,setCustomDuration:gt,setCustomDurationUnit:Ae,submit:Ue,notifyInsufficientBalance:Nt}=ns({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:a}),Pe=useAuthCallback(Ue),at=useCallback(Re=>{ue(Re),s?.(Re);},[ue,s]),qe=useMemo(()=>e?Dn(e):void 0,[e]),De=useMemo(()=>Fn(t,{yesAsk:m==="yes"?k:void 0,noAsk:m==="no"?k:void 0}),[t,m,k]);return jsx(us,{event:qe,market:De,variant:r,outcome:m,orderType:c,quantity:f,limitPrice:d,shares:p,effectivePrice:g,estimatedCost:v,estimatedFee:h,potentialPayout:x,potentialProfit:S,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:N,isMarketDataLoading:E,isSubmitting:P,authStatus:R,isValid:D.isValid,validationErrors:D.errors,isInsufficientBalance:U,onInsufficientBalance:a?Nt:void 0,supportsLimitOrder:Q,kycRequired:H,needsKyc:Y,needsSetup:q,kycUrl:te,expirationEnabled:C,expirationPreset:T,customDuration:B,customDurationUnit:J,oddsFormatter:l,outcomeLabels:u,onOutcomeChange:at,onOrderTypeChange:se,onQuantityChange:Ge,onLimitPriceChange:We,onExpirationEnabledChange:st,onExpirationPresetChange:w,onCustomDurationChange:gt,onCustomDurationUnitChange:Ae,onSubmit:Pe})}var on="predict-trade";function Yn({id:e=on}){return jsx(AsyncModal,{id:e,children:t=>jsx(Yd,{...t})})}function Yd({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(qn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var sn={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function $o(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function ms({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=useTranslation(),[a,s]=useState(r),l=useMemo(()=>o?sn:{...sn,source:"polymarket"},[o]),u=useCallback(x=>{x?s(r):t();},[r,t]),m=useCallback(()=>{s(l);},[l]),c=useCallback(()=>{n(a),t();},[a,n,t]),f=useCallback((x,S)=>{s(k=>({...k,[x]:S}));},[]),d=useMemo(()=>$o(a,o),[a,o]),p=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),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:u,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.filter.title")}),jsx(tu,{onClick:()=>u(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsx(Xn,{label:i("predict.filter.platform"),children:jsx(Jn,{options:p,selected:a.source,onSelect:x=>f("source",x)})}),jsx(Xn,{label:i("predict.filter.timeRemaining"),children:jsx(Jn,{options:g,selected:a.timeRemaining,onSelect:x=>f("timeRemaining",x)})}),jsx(Xn,{label:i("predict.filter.minVolume"),children:jsx(Jn,{options:v,selected:a.minVolume,onSelect:x=>f("minVolume",x)})}),jsx(Xn,{label:i("predict.filter.minLiquidity"),children:jsx(Jn,{options:h,selected:a.minLiquidity,onSelect:x=>f("minLiquidity",x)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:m,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick: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:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function tu({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Jn({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var bs={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},gs={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},du=["start_time","volume","liquidity","ending_soon"],hs={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},uu={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function xs({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:a}){let{t:s}=useTranslation(),[l,u]=useState(false),m=useRef(null),c=useCallback(d=>{m.current&&!m.current.contains(d.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),useEffect(()=>{if(!l)return;let d=p=>{p.key==="Escape"&&u(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let f=vs[e];return jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:m,style:{position:"relative"},children:[jsxs("button",{type:"button",style:hs,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(d=>!d),children:[jsx(pu,{}),jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(gs[e])}),jsx(fu,{open:l})]}),l&&jsx("div",{style:{...uu,width:224,padding:4},children:du.map(d=>{let p=vs[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?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:v=>{g||(v.currentTarget.style.background="rgba(39,39,42,0.5)",v.currentTarget.style.color="#fff");},onMouseLeave:v=>{g||(v.currentTarget.style.background="transparent",v.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?n(!r):t(d),u(false);},children:[jsx(p,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:s(gs[d])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:hs,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(mu,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var vs={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function pu(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function mu(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function fu({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Ss(e={}){let{i18n:t}=useTranslation(),r=e.lang??t.resolvedLanguage??t.language,n=useMemo(()=>resolveEventsParams({...e,lang:r}),[r,e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit,e.lang]),{data:o,isLoading:i,isFetching:a,isFetchingNextPage:s,isError:l,error:u,hasNextPage:m,fetchNextPage:c,refetch:f}=useInfiniteEvents(n),d=useMemo(()=>o?.pages.flatMap(v=>v.items).filter(v=>v!=null)??[],[o]),p=useCallback(()=>{c();},[c]),g=useCallback(()=>{f();},[f]);return {data:d,isLoading:i,isFetching:a&&!s,isFetchingMore:s,isError:l,error:u??null,hasMore:m??false,fetchMore:p,refetch:g}}var ws=`
|
|
1
|
+
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,createElement,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTradeResultConfirmation,useTickSize,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,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents,usePositions}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount,debounce}from'@liberfi.io/utils';import zo 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 {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var Lc={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},$i=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Do=(()=>{let e=t=>{let r=$i.indexOf(t);return r===-1?$i.length:r};return Object.entries(Lc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function ji({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:s="Trending",className:l}){let{t:u}=useTranslation(),m=useCallback(()=>{o(null);},[o]),c=u("predict.categories.trending");return jsxs("div",{className:cn$1("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxs("div",{className:"cat-primary-row",children:[jsx("div",{className:"cat-tabs hideScrollbar",children:jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsx(Ki,{label:c,isSelected:t===null,onPress:m,showPulse:c===s}),jsx(Oc,{}),e.map(f=>{let d=f.slug??f.category,p=f.label??f.category;return jsx(Ki,{label:p,isSelected:t===d,onPress:()=>o(d),badge:f.badge,showPulse:d===s||p===s},d)})]})}),a&&jsx("div",{className:"flex-shrink-0",children:a})]}),t&&n.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(Vi,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(f=>{let d=f.slug??f.label;return jsx(Vi,{label:f.label,icon:f.icon,isSelected:r===d,onPress:()=>i(d)},d)})]})})]})}function Ki({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxs("button",{type:"button",onClick:r,className:cn$1("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,n&&jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:n})]})}function Oc(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Vi({label:e,icon:t,isSelected:r,onPress:n}){return jsxs("button",{type:"button",onClick:n,className:cn$1("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function Kv({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 qi(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Dc(e){return `predict.categories.category.${qi(e)}`}function Yi(e){return `predict.categories.tag.${qi(e)}`}function Fc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Dc(r.slug),r.label),tags:r.tags.map(n=>({slug:n.slug,label:t(Yi(n.slug),n.label),icon:n.icon}))}))}function Bc(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Yi(r.slug),r.label),icon:r.icon})):[]}function Qi({onSelect:e,trailing:t,className:r}){let{t:n}=useTranslation(),o=useCallback((p,g)=>{let h=n(p);return typeof h=="string"&&h!==p?h:g},[n]),[i,a]=useState(null),[s,l]=useState(null),u=useCallback(p=>{a(p),l(null),e?.({categorySlug:p,tagSlug:null});},[e]),m=useCallback(p=>{l(p),e?.({categorySlug:i,tagSlug:p});},[i,e]),c=Fc(Do,o),f=Do.find(p=>p.slug===i),d=Bc(f,o);return jsx(ji,{categories:c,selectedCategory:i,selectedTag:s,activeTags:d,onCategorySelect:u,onTagSelect:m,trailing:t,className:r})}function Fn(e){return {title:e.title,imageUrl:e.image_url}}function Bn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var an=24,Bo=4,Hn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},le={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},zn=le.ALL,eb={[le.ONE_DAY]:Hn.ONE_MINUTE,[le.ONE_WEEK]:Hn.ONE_HOUR,[le.ONE_MONTH]:Hn.ONE_HOUR,[le.ALL]:Hn.ONE_DAY},tb={[le.ONE_DAY]:300,[le.ONE_WEEK]:3600,[le.ONE_MONTH]:10800,[le.ALL]:1440*60},rb={[le.ONE_DAY]:1440*60,[le.ONE_WEEK]:10080*60,[le.ONE_MONTH]:720*60*60,[le.ALL]:null},Wn=1,Un=1,nb=1,ob=1,ib=99,Wr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},sb=Wr.ONE_WEEK,ab={[Wr.ONE_HOUR]:60,[Wr.SIX_HOURS]:60,[Wr.ONE_DAY]:300,[Wr.ONE_WEEK]:1800,[Wr.MAX]:1800};var Zi=createContext(null);function yr(){let e=useContext(Zi);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Vc=1e4;function jc({pollingInterval:e=Vc,enabled:t=true,enableKalshi:r=true,children:n}){let o=useWallets(),i=useMemo(()=>o.find(R=>R.chainNamespace===ChainNamespace.SOLANA&&R.isConnected)?.address,[o]),a=useMemo(()=>o.find(R=>R.chainNamespace===ChainNamespace.EVM&&R.isConnected)?.address,[o]),{data:s,isLoading:l,isFetching:u,error:m}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:c,isLoading:f}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:d,isLoading:p}=usePolymarketSetup(a,{enabled:t&&!!a,refetchInterval:3e4}),g=d?.safe_address,v=d?.verified??false,h=d?.wallet_kind??"deposit",x=d?.deposit_wallet_address,S=h==="safe"?d?.safe_address:x,k=h==="safe"?d?.safe_deployed??false:d?.deposit_wallet_deployed??false,{data:b,isLoading:y,isFetching:N,error:E}=useBalance({source:"polymarket",user:a??""},{enabled:t&&v&&!!a,refetchInterval:e}),w=useMemo(()=>({enableKalshi:r,solanaAddress:i,evmAddress:a,polymarketWalletKind:h,polymarketWalletAddress:S,polymarketDepositWalletAddress:x,polymarketWalletDeployed:k,polymarketSafeAddress:g,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:v&&b?Number(b.balance):null,kalshiKycVerified:c?.verified??false,kalshiKycUrl:c?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:v,polymarketSafeDeployed:d?.safe_deployed??false,polymarketTokenApproved:d?.token_approved??false,polymarketSetupLoading:p,isLoading:l||y,isFetching:u||N,error:m??E??null}),[r,i,a,h,S,x,k,g,s,b,v,c,f,d,p,l,y,u,N,m,E]);return jsx(Zi.Provider,{value:w,children:n})}var qc={minutes:60,hours:3600,days:86400};function $n(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*qc[r]}}function Kn(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 Yc(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Qc=100,Xc=300;function Wo(e,t){return Qc/1e4+Math.max(0,e)/1e4*Yc(t)}function Jc(e,t){let r=e?.[t],n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:void 0}function Zc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function es(e){let t=Jc(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],n=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(n)&&n>=0?n*1e4:Zc(e,"polymarket.sportsMarketType")?Xc:0}function ts({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:n=0,pricePerShare:o}){if(t==null||!Number.isFinite(t))return 0;let i=be(Math.max(0,t),2);if(e!=="polymarket")return i;let a=Wo(n,o??NaN),s=i/(1+a)-r;return be(Math.max(0,s),2)}function rs({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Wo(r,t);return e*n}function ns({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Wo(r,t);return e*n}function Vn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let a=parseInt(o[1],10)/1e6,s=parseInt(o[2],10)/1e6,l=Math.max(0,a-s);return t("predict.trade.polymarket.insufficientBalance",{total:be(a,2).toFixed(2),active:be(s,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 kr(e,t=2){return parseFloat(be(e,t).toFixed(t)).toString()}function os(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};zo({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{zo({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{zo({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var is={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function ed(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function Uo(e,t,r){let n=e(t);return n&&n!==t?n:r}function Ur(e,t){let r=ed(t)?is.zh:is.en;return {submitted:Uo(e,"predict.trade.resultSubmitted",r.submitted),completed:Uo(e,"predict.trade.resultCompleted",r.completed),delayed:Uo(e,"predict.trade.resultDelayed",r.delayed)}}function od({deadlineAt:e}){let[t,r]=useState(()=>Math.max(0,e-Date.now()));return useEffect(()=>{let n=setInterval(()=>{r(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(n)},[e]),`${Math.max(0,Math.ceil(t/1e3))}s`}function $r({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:n}){return {id:e,submitted:()=>{let o=Date.now()+t;toast.progress({id:e,message:n.submitted,duration:t,progress:true,action:createElement(od,{deadlineAt:o})});},completed:()=>{toast.update(e,{type:"success",message:n.completed,duration:5e3}),r&&os();},delayed:()=>{toast.update(e,{type:"blank",message:n.delayed,duration:8e3});},failed:o=>{toast.update(e,{type:"error",message:o,duration:8e3});}}}function ls({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o,i18n:i}=useTranslation(),{status:a}=useAuth(),s=useWallets(),l=usePredictClient(),u=useContext(PolymarketContext),{start:m}=useTradeResultConfirmation(),c=e.source,f=c==="polymarket",d=s.find(I=>I.chainNamespace===ChainNamespace.SOLANA&&I.isConnected),p=s.find(I=>I.chainNamespace===ChainNamespace.EVM&&I.isConnected&&"switchChain"in I),g=a==="authenticated",v=d?.address,h=p?.address,[x,S]=useState(t),[k,b]=useState("market"),[y,N]=useState(NaN),[E,w]=useState(NaN),[R,O]=useState(false),[U,Q]=useState(null),[H,Y]=useState(false),[q,te]=useState(false),[C,T]=useState("1h"),[B,J]=useState(30),[de,se]=useState("minutes"),Ve=useMemo(()=>Ur(o,i),[i,o]),je=true,Ge=useCallback(async(I,Te)=>{let ke=$r({celebrateOnCompleted:true,messages:Ve});ke.submitted(),await m({source:c,user:c==="kalshi"?v:h,kalshiUser:je?v:void 0,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:I,getOrdersHeaders:Te})==="confirmed"?ke.completed():ke.delayed();},[m,je,h,e.event_slug,e.slug,c,Ve,v]),P=useMemo(()=>{if(c!=="polymarket")return;let I=e.provider_meta?.["polymarket.clobTokenIds"];return I?(typeof I=="string"?JSON.parse(I):I)[x==="yes"?0:1]:void 0},[c,e.provider_meta,x]),{data:dt,isLoading:qe}=useTickSize(P),Re=dt?.minimum_tick_size?String(dt.minimum_tick_size):"0.01",{data:Nt,isLoading:_e}=useFeeRate(P),Ye=Nt?.base_fee??0,ot=String(Ye),we=useMemo(()=>es(e.provider_meta),[e.provider_meta]),{data:et}=useRebateConfig(),Ie=et?.builder_enabled&&et.builder_code?et.builder_code:void 0,it=null,Ot=false,Ct=null,Mt=false,tt,gt,We;try{let I=yr();je=I.enableKalshi,it={kalshiUsdcBalance:I.kalshiUsdcBalance,polymarketUsdcBalance:I.polymarketUsdcBalance,isLoading:I.isLoading},Ot=I.kalshiKycVerified,Ct=I.kalshiKycUrl,Mt=I.polymarketSetupVerified,tt=I.polymarketSafeAddress,gt=I.polymarketWalletKind,We=I.polymarketWalletAddress;}catch{}let Yt=c==="kalshi"&&!Ot,Oe=c==="polymarket"&&!Mt,{data:Qe}=useRealtimeOrderbook({slug:e.slug,source:c,outcome:x},{enabled:e.status==="open"}),me=useMemo(()=>{let I=pickBestAsk(Qe,x);if(I!=null&&I>0)return I;let Te=x==="yes"?0:1,ke=e.outcomes[Te];return ke?.best_ask??ke?.price??.5},[Qe,e.outcomes,x]),st=useCallback(I=>{b(I);},[]),ht=useCallback(I=>{S(I),w(NaN);},[]);useEffect(()=>{ht(t);},[t,ht]),useEffect(()=>{k==="limit"&&isNaN(E)&&w(Math.round(me*1e4)/1e4);},[k,E,me]);let ve=useMemo(()=>k==="limit"&&f&&!isNaN(E)?E:me,[k,f,E,me]),Xe=useMemo(()=>isNaN(y)||y<=0?0:ve>0?y/ve:0,[y,ve]),Ne=useMemo(()=>walkOrderbook({orderbook:Qe,outcome:x,side:"buy",sharesNeeded:Xe,slippageBps:r}),[Qe,x,Xe,r]),Tt=useMemo(()=>Ne.status==="ok"&&Ne.worstPrice!=null&&Ne.worstPrice>0?Ne.worstPrice:me,[Ne,me]),_=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),Ce=e.provider_meta?.["dflow.yesMint"]??"",Ue=e.provider_meta?.["dflow.noMint"]??"",en=SOLANA_TOKENS.stablecoins.USDC.address,D=x==="yes"?Ce:Ue,Me=en,vt=D,At=c==="kalshi"?v??"":h??"",{data:tn,isLoading:Mo}=usePositionsMulti({kalshi_user:c==="kalshi"?At:void 0,polymarket_user:c==="polymarket"?At:void 0},{enabled:!!At}),To=c==="kalshi"&&!!Me&&!!vt&&!!v&&_!=="0",{refetch:Qt}=useDFlowQuote({inputMint:Me,outputMint:vt,amount:_,userPublicKey:v??"",slippageBps:100},{enabled:To}),Rr=useMemo(()=>it?c==="kalshi"?it.kalshiUsdcBalance:it.polymarketUsdcBalance:tn&&tn.positions.reduce((Te,ke)=>ke.side==="USDC"||ke.side==="collateral"?Te+(ke.current_value??0):Te,0)||null,[it,tn,c]),Eo=it?it.isLoading:Mo,at=useMemo(()=>ts({source:c,usdcBalance:Rr,feeRateBps:we,pricePerShare:ve}),[c,Rr,we,ve]),Et=Rr==null?null:at,_r=useMemo(()=>isNaN(y)||y<=0?0:y,[y]),rn=useMemo(()=>isNaN(y)||y<=0?0:ve>0?y/ve*1:0,[y,ve]),Ir=useMemo(()=>c!=="polymarket"||isNaN(y)||y<=0?0:rs({usdcAmount:y,pricePerShare:ve,feeRateBps:we}),[c,y,ve,we]),ar=rn-_r-Ir,Lo=useCallback(I=>{if(isNaN(I)){N(NaN);return}N(Math.round(Math.max(0,I)*100)/100);},[]),Ln=useCallback(I=>{if(isNaN(I)){w(NaN);return}w(Math.round(I*1e4)/1e4);},[]),Or=useCallback(()=>{N(NaN),w(NaN),b("market"),te(false),T("1h"),J(30),se("minutes");},[]),Xt=useMemo(()=>{let I=[];return isNaN(y)||y<=0?I.push(o("predict.trade.minAmountUsd",{amount:Un})):y<Un&&I.push(o("predict.trade.minAmountUsd",{amount:Un})),e.status!=="open"&&I.push(o("predict.trade.marketNotActive")),Et!=null&&!isNaN(y)&&y>0&&y>Et&&I.push(o("predict.trade.insufficientBalance")),k==="limit"&&f&&(isNaN(E)||E<.01||E>.99)&&I.push(o("predict.trade.limitPriceRange")),k==="limit"&&f&&q&&C==="custom"&&(isNaN(B)||B<=0)&&I.push(o("predict.trade.expiration.invalidDate")),c==="polymarket"&&k==="market"&&!isNaN(y)&&y>0&&Xe>0&&(Ne.status==="insufficient_liquidity"?I.push(o("predict.trade.insufficientLiquidity",{available:be(Ne.totalAvailable,2)})):Ne.status==="exceeds_slippage"&&I.push(o("predict.trade.priceImpactTooHigh",{impact:(Ne.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:I.length===0,errors:I}},[y,e.status,Et,k,f,E,q,C,B,c,Xe,Ne,r,o]),fr=useMemo(()=>Et==null||isNaN(y)||y<=0?false:y>Et,[Et,y]),gr=useCallback(()=>{n?.(c);},[n,c]),{mutateAsync:hr}=useDFlowSubmit(),{data:nn}=useOrder({id:U??"",source:c},{enabled:!!U});useEffect(()=>{if(!nn||!U)return;let{status:I}=nn;I==="closed"?(Q(null),O(false),Ge("buy-market"),Or()):(I==="failed"||I==="expired")&&(O(false),Q(null),toast.error(o("predict.trade.submitError")));},[Ge,nn,U,Or,o]);let on=useCallback(async()=>{if(!v||!d)return;if(!Me||!vt){toast.error("Missing token mint addresses"),O(false);return}if(!Ot){Y(true),O(false);return}let Rt=(await Qt()).data?.transaction;if(!Rt){toast.error(o("predict.trade.submitError")),O(false);return}let sn=Uint8Array.from(atob(Rt),lt=>lt.charCodeAt(0)),Jt=await d.signTransaction(sn),Zt=await hr({signedTransaction:btoa(String.fromCharCode(...Jt)),orderContext:{user_public_key:v,input_mint:Me,output_mint:vt,amount:_,price:String(me),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(Zt.signature);},[v,d,Qt,hr,Me,vt,_,me,x,e.slug,o,Ot]),Ar=useCallback(async()=>{if(!p||!u)return;let I=p.chain,Te=I!==Chain.POLYGON;Te&&await p.switchChain(Chain.POLYGON);try{let ke=await p.getEip1193Provider();if(!ke){toast.error(o("predict.trade.submitError")),O(!1);return}let Rt=gt==="deposit"&&!!We,sn=!Rt&&!!tt,Jt=Rt?We:tt,Zt={address:p.address,signatureType:Rt?3:sn?2:0,signTypedData:async(_t,M,Se,Pe)=>{let Ae=[];"name"in _t&&Ae.push({name:"name",type:"string"}),"version"in _t&&Ae.push({name:"version",type:"string"}),"chainId"in _t&&Ae.push({name:"chainId",type:"uint256"}),"verifyingContract"in _t&&Ae.push({name:"verifyingContract",type:"address"}),"salt"in _t&&Ae.push({name:"salt",type:"bytes32"});let ut={EIP712Domain:Ae,...M};return await ke.request({method:"eth_signTypedData_v4",params:[p.address,JSON.stringify({domain:_t,types:ut,primaryType:Se,message:Pe})]})}},lt=u.credentials??await u.authenticate(Zt),Ro=x==="yes"?0:1,Rn="",Ht=e.provider_meta?.["polymarket.clobTokenIds"];Ht&&(Rn=(typeof Ht=="string"?JSON.parse(Ht):Ht)[Ro]??"");let Dr=e.provider_meta?.["polymarket.negRisk"]??!1,Fr=k==="limit"&&!isNaN(E)?E:Tt,vr=Kn(Fr,Re),_n=k==="limit"?q?"GTD":"GTC":"FOK",br=k==="market"?y:vr>0?y/vr:0,Br={tokenId:Rn,price:vr,size:br,side:"BUY",orderType:_n,tickSize:Re,negRisk:Dr,...Jt&&{funderAddress:Jt},...Ie&&{builderCode:Ie},...k==="limit"&&q&&{expiration:$n(C,B,de)}},Hr;if(Rt)Hr=await buildSignedV2OrderPayload({signer:Zt,depositWalletAddress:Jt,input:Br,owner:lt.apiKey});else {let _t=buildCtfExchangeDomain(Dr),M=buildOrderMessage({...Br,signerAddress:Zt.address,signatureType:Zt.signatureType,feeRateBps:ot}),Se=await Zt.signTypedData(_t,CTF_ORDER_TYPES,"Order",M),Pe=buildSignedOrder(M,Se,Br.orderType);Hr=buildClobPayload(Pe,lt.apiKey);}await l.executePolymarketOrder({payload:Hr,l2_api_key:lt.apiKey,l2_secret:lt.secret,l2_passphrase:lt.passphrase,signer_address:lt.address,owner:lt.apiKey}),Ge(k==="limit"?"buy-limit":"buy-market",async()=>await buildPolymarketL2Headers(lt.address,{apiKey:lt.apiKey,secret:lt.secret,passphrase:lt.passphrase,method:"GET",requestPath:"/data/orders"})),Or(),O(!1);}finally{Te&&I&&p.switchChain(I).catch(()=>{});}},[p,u,x,e.provider_meta,k,Ge,E,Tt,y,l,q,C,B,de,Or,o,Re,ot,tt,gt,We,Ie]),Lt=useCallback(async()=>{if(!(!Xt.isValid||!g)){O(true),Q(null),Y(false);try{c==="kalshi"?await on():await Ar();}catch(I){let Te=I instanceof Error?I.message:"",ke=c==="polymarket"&&Te?Vn(Te,o,"buy"):Te||void 0;toast.error(ke||o("predict.trade.submitError")),O(false);}}},[Xt.isValid,g,c,on,Ar,o]);return {outcome:x,orderType:k,quantity:y,limitPrice:E,shares:Xe,effectivePrice:ve,estimatedCost:_r,estimatedFee:Ir,potentialPayout:rn,potentialProfit:ar,pricePerShare:me,usdcBalance:Rr,maxBuyAmount:at,spendableUsdcBalance:Et,isBalanceLoading:Eo,isMarketDataLoading:c==="polymarket"&&(_e||qe),isSubmitting:R,authStatus:a,validation:Xt,isInsufficientBalance:fr,source:c,supportsLimitOrder:f,kycRequired:H,needsKyc:Yt,needsSetup:Oe,kycUrl:Ct,expirationEnabled:q,expirationPreset:C,customDuration:B,customDurationUnit:de,setOutcome:ht,setOrderType:st,setQuantity:Lo,setLimitPrice:Ln,setExpirationEnabled:te,setExpirationPreset:T,setCustomDuration:J,setCustomDurationUnit:se,submit:Lt,notifyInsufficientBalance:gr}}function Gn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:n(o)})]},o))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Ud=["5m","1h","12h","24h","eod","custom"],$d={"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"},Kd=["minutes","hours","days"],Vd={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},jd={maximumFractionDigits:0},cr="-";function hs({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:s,effectivePrice:l,potentialProfit:u,potentialPayout:m,estimatedCost:c,estimatedFee:f=0,usdcBalance:d,isBalanceLoading:p,isMarketDataLoading:g,isSubmitting:v,authStatus:h,isValid:x,validationErrors:S,isInsufficientBalance:k,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:N,kycRequired:E,needsKyc:w,needsSetup:R,kycUrl:O,expirationEnabled:U,expirationPreset:Q,customDuration:H,customDurationUnit:Y,oddsFormatter:q,outcomeLabels:te,onOutcomeChange:C,onOrderTypeChange:T,onQuantityChange:B,onLimitPriceChange:J,onExpirationEnabledChange:de,onExpirationPresetChange:se,onCustomDurationChange:Ve,onCustomDurationUnitChange:je,onSubmit:Ge}){let{t:P}=useTranslation(),[dt,qe]=useState(true),Re=useDisclosure(),[Nt,_e]=useState(""),Ye=useRef(false);useEffect(()=>{Ye.current||_e(isNaN(i)?"":String(i));},[i]);let[ot,we]=useState(""),et=useRef(false);useEffect(()=>{et.current||(isNaN(a)?we(""):we(String(parseFloat((a*100).toFixed(2)))));},[a]);let Ie=useCallback(D=>{if(D!==""&&!/^\d*\.?\d{0,2}$/.test(D))return;if(we(D),D===""||D==="."){J(NaN);return}let vt=parseFloat(D);isNaN(vt)||J(vt/100);},[J]),it=useCallback(D=>{if(D!==""&&!/^\d*\.?\d{0,2}$/.test(D))return;if(_e(D),Ue(false),D===""||D==="."){B(NaN);return}let vt=parseFloat(D);isNaN(vt)||B(vt);},[B]);useEffect(()=>{E&&!Re.isOpen&&Re.onOpen();},[E]);let Ot=useMemo(()=>{let D=n==="yes"?t.yesAsk:t.noAsk;return D!=null?parseFloat((Number(D)*100).toFixed(2)):null},[n,t]),Ct=n==="yes"?t.yesAsk:t.noAsk,Mt=Ct!=null&&q?q(Number(Ct)):Ot!=null?`${Ot} \xA2`:cr,tt=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,gt=Number.isFinite(l)&&q?q(l):tt!=null?`${tt} \xA2`:cr,We=!isNaN(i)&&i>0,Yt=We?c+f:0,Oe=We&&s>0?Yt/s:0,Qe=Oe>0&&q?q(Oe):Oe>0?`${parseFloat((Oe*100).toFixed(2))}\xA2`:cr,me=h==="authenticated",st=h==="authenticating"||h==="deauthenticating",ht=me&&(w||R),ve=useCallback(D=>te?.[D]??P(D==="yes"?"predict.trade.yes":"predict.trade.no"),[te,P]),Xe=useMemo(()=>{if(st)return P("predict.trade.checkingLogin");if(!me)return P("predict.trade.loginToTrade");if(w)return P("predict.trade.kycRequired");if(R)return P("predict.trade.setupRequired");if(p)return P("predict.trade.loadingBalance");if(g)return P("predict.trade.loadingMarketData");if(v)return P("predict.trade.submitting");if(E)return P("predict.trade.kycRequired");if(!We)return P("predict.trade.enterAmount");let D=ve(n),Me=u>0?` \u2192 Win $${u.toFixed(2)}`:"";return `${P("predict.trade.buy")} ${D}${Me}`},[st,me,w,R,p,g,v,E,We,n,ve,u,P]),Ne="primary",Tt=()=>{let D=N??be(d??0,2);B(be(D/2,2));},_=()=>{B(N??be(d??0,2));},[Ce,Ue]=useState(false),en=()=>{if(!me){Ue(false),Ge();return}if(w){Re.onOpen();return}if(R&&b){Ue(false),b();return}if(E){Re.onOpen();return}if(k&&b){Ue(false),b();return}if(!x){Ue(true);return}Ue(false),Ge();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:D=>{r==="bordered"&&(D.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:D=>{r==="bordered"&&(D.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bullish",children:[P("predict.trade.buy")," ",ve(n)]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[y?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:D=>T(D),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:P("predict.trade.market")},"market"),jsx(Tab,{title:P("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:P("predict.trade.market")}),o==="limit"&&y?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:ot,onChange:D=>Ie(D.target.value),onFocus:()=>{et.current=true;},onBlur:()=>{et.current=false,isNaN(a)?we(""):we(String(parseFloat((a*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"}}):Mt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:Mt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(D=>{let Me=D==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>C(D),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===D?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:ve(D)}),Me!=null&&jsx("span",{className:"ml-1 opacity-70",children:q?q(Number(Me)):`${parseFloat((Number(Me)*100).toFixed(2))}\xA2`})]})},D)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:P("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:Tt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:P("predict.trade.half")}),jsx("button",{type:"button",onClick:_,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:P("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Nt,onChange:D=>it(D.target.value),onFocus:()=>{Ye.current=true;},onBlur:()=>{Ye.current=false,_e(isNaN(i)?"":String(i));},startContent:jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Ce&&S.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:S.map(D=>jsx("span",{className:"text-xs text-danger",children:D},D))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-neutral-500",children:P("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`$${be(d,2).toFixed(2)}`:"$0"})]}),o==="limit"&&y&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:P("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:U,onValueChange:de,"aria-label":P("predict.trade.setExpiration")})]}),U&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":P("predict.trade.setExpiration"),selectedKeys:[Q],onSelectionChange:D=>{let Me=Array.from(D)[0];Me&&se(Me);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Ud.map(D=>jsx(SelectItem,{children:P($d[D])},D))}),Q==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(H)?void 0:H,onValueChange:Ve,minValue:1,step:1,formatOptions:jd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[Y],onSelectionChange:D=>{let Me=Array.from(D)[0];Me&&je(Me);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Kd.map(D=>jsx(SelectItem,{children:P(Vd[D])},D))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>qe(D=>!D),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:P("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",dt&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:q&&Number.isFinite(l)?gt:tt!=null?P("predict.trade.chance",{percent:tt}):cr})]}),dt&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:cr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?kr(s):cr})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${f.toFixed(2)}`})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.totalPayment")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${Yt.toFixed(2)}`})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:Qe})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${m.toFixed(2)}`:cr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&u>0?`+$${u.toFixed(2)}`:cr})]})]})]}),jsx(Button,{color:Ne,fullWidth:true,radius:"lg",size:"lg",isDisabled:st||me&&!ht&&(p||g||!We||v),isLoading:st||me&&!ht&&(v||p||g),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:en,children:Xe})]}),jsx(Gn,{isOpen:Re.isOpen,onClose:Re.onClose,kycUrl:O})]})}function Yn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:a,onOutcomeChange:s,oddsFormatter:l,outcomeLabels:u}){let{outcome:m,orderType:c,quantity:f,limitPrice:d,shares:p,effectivePrice:g,estimatedCost:v,estimatedFee:h,potentialPayout:x,potentialProfit:S,pricePerShare:k,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:N,isMarketDataLoading:E,isSubmitting:w,authStatus:R,validation:O,isInsufficientBalance:U,supportsLimitOrder:Q,kycRequired:H,needsKyc:Y,needsSetup:q,kycUrl:te,expirationEnabled:C,expirationPreset:T,customDuration:B,customDurationUnit:J,setOutcome:de,setOrderType:se,setQuantity:Ve,setLimitPrice:je,setExpirationEnabled:Ge,setExpirationPreset:P,setCustomDuration:dt,setCustomDurationUnit:qe,submit:Re,notifyInsufficientBalance:Nt}=ls({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:a}),_e=useAuthCallback(Re),Ye=useCallback(et=>{de(et),s?.(et);},[de,s]),ot=useMemo(()=>e?Fn(e):void 0,[e]),we=useMemo(()=>Bn(t,{yesAsk:m==="yes"?k:void 0,noAsk:m==="no"?k:void 0}),[t,m,k]);return jsx(hs,{event:ot,market:we,variant:r,outcome:m,orderType:c,quantity:f,limitPrice:d,shares:p,effectivePrice:g,estimatedCost:v,estimatedFee:h,potentialPayout:x,potentialProfit:S,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:N,isMarketDataLoading:E,isSubmitting:w,authStatus:R,isValid:O.isValid,validationErrors:O.errors,isInsufficientBalance:U,onInsufficientBalance:a?Nt:void 0,supportsLimitOrder:Q,kycRequired:H,needsKyc:Y,needsSetup:q,kycUrl:te,expirationEnabled:C,expirationPreset:T,customDuration:B,customDurationUnit:J,oddsFormatter:l,outcomeLabels:u,onOutcomeChange:Ye,onOrderTypeChange:se,onQuantityChange:Ve,onLimitPriceChange:je,onExpirationEnabledChange:Ge,onExpirationPresetChange:P,onCustomDurationChange:dt,onCustomDurationUnitChange:qe,onSubmit:_e})}var cn="predict-trade";function Qn({id:e=cn}){return jsx(AsyncModal,{id:e,children:t=>jsx(tu,{...t})})}function tu({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(Yn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var dn={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function jo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function bs({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=useTranslation(),[a,s]=useState(r),l=useMemo(()=>o?dn:{...dn,source:"polymarket"},[o]),u=useCallback(x=>{x?s(r):t();},[r,t]),m=useCallback(()=>{s(l);},[l]),c=useCallback(()=>{n(a),t();},[a,n,t]),f=useCallback((x,S)=>{s(k=>({...k,[x]:S}));},[]),d=useMemo(()=>jo(a,o),[a,o]),p=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),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:u,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.filter.title")}),jsx(au,{onClick:()=>u(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsx(Jn,{label:i("predict.filter.platform"),children:jsx(Zn,{options:p,selected:a.source,onSelect:x=>f("source",x)})}),jsx(Jn,{label:i("predict.filter.timeRemaining"),children:jsx(Zn,{options:g,selected:a.timeRemaining,onSelect:x=>f("timeRemaining",x)})}),jsx(Jn,{label:i("predict.filter.minVolume"),children:jsx(Zn,{options:v,selected:a.minVolume,onSelect:x=>f("minVolume",x)})}),jsx(Jn,{label:i("predict.filter.minLiquidity"),children:jsx(Zn,{options:h,selected:a.minLiquidity,onSelect:x=>f("minLiquidity",x)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:m,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[i("predict.filter.showResults"),d>0&&jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function Jn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function au({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Zn({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var Ps={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},ys={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},hu=["start_time","volume","liquidity","ending_soon"],ks={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},vu={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function ws({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:a}){let{t:s}=useTranslation(),[l,u]=useState(false),m=useRef(null),c=useCallback(d=>{m.current&&!m.current.contains(d.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),useEffect(()=>{if(!l)return;let d=p=>{p.key==="Escape"&&u(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let f=Ss[e];return jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:m,style:{position:"relative"},children:[jsxs("button",{type:"button",style:ks,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(d=>!d),children:[jsx(bu,{}),jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(ys[e])}),jsx(yu,{open:l})]}),l&&jsx("div",{style:{...vu,width:224,padding:4},children:hu.map(d=>{let p=Ss[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?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:v=>{g||(v.currentTarget.style.background="rgba(39,39,42,0.5)",v.currentTarget.style.color="#fff");},onMouseLeave:v=>{g||(v.currentTarget.style.background="transparent",v.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?n(!r):t(d),u(false);},children:[jsx(p,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:s(ys[d])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:ks,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(xu,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Ss={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function bu(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function xu(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function yu({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Ms(e={}){let{i18n:t}=useTranslation(),r=e.lang??t.resolvedLanguage??t.language,n=useMemo(()=>resolveEventsParams({...e,lang:r}),[r,e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit,e.lang]),{data:o,isLoading:i,isFetching:a,isFetchingNextPage:s,isError:l,error:u,hasNextPage:m,fetchNextPage:c,refetch:f}=useInfiniteEvents(n),d=useMemo(()=>o?.pages.flatMap(v=>v.items).filter(v=>v!=null)??[],[o]),p=useCallback(()=>{c();},[c]),g=useCallback(()=>{f();},[f]);return {data:d,isLoading:i,isFetching:a&&!s,isFetchingMore:s,isError:l,error:u??null,hasMore:m??false,fetchMore:p,refetch:g}}var Ts=`
|
|
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
|
+
`,Es={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 eo(e){return {...Es,animationDelay:`${e}ms`}}function Go({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Ts}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(wu,{index:r},r))})]})}function wu({index:e}){let t=e*120,r={...Es,animationDelay:`${t}ms`},n=e%3===0?"85%":e%3===1?"70%":"60%";return jsx("div",{style:{padding:8},children:jsxs("div",{className:"evt-skel-card",style:{display:"flex",flexDirection:"column",minHeight:248,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsx("div",{style:{...r,height:12,width:n}}),jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(o=>jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsx("div",{style:{...r,height:11,width:o===0?"55%":o===1?"45%":"35%"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...r,height:11,width:32}}),jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},o))}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsx("div",{style:{...r,height:10,width:56}}),jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Nu(){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:{...eo(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...eo(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...eo(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...eo(100),height:36,width:80,borderRadius:10}})]})]})}function Sx({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:Ts}),jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(Nu,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(Go,{count:e})})]})}var Ls=3,Au={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)"}},Du={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Yo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ds={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Fu={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},un=[{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 Rs(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 Bu(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [Yo,Fu];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [Yo,Ds];let r=t[0]??"",n=t[1]??"",o=Rs(r)%un.length,i=Rs(n)%un.length;return i===o&&(i=(i+1)%un.length),[un[o],un[i]]}function _s(e){return e.title_trans||e.title}function Hu(e){return e.question_trans||e.question}function Qo(e,t){return e?.label_trans||e?.label||t}function Fs(e){return Qo(e.outcomes?.[0],Hu(e))}function zu(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Bs(e){let t=zu(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Hs(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Is(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Os(e){let t=e.outcomes?.[1];if(t){let o=t.best_ask??t.price??0;return parseFloat((o*100).toFixed(2)).toString()}let r=e.outcomes?.[0],n=r?.best_ask??r?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function Wu(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),o=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),n>0&&i.push(`${n}h`),i.push(`${o}m`),i.join(" ")}var Uu=`
|
|
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 As({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[a,s]=useState(null),l=e.markets??[],m=useMemo(()=>l.length>2?[...l].sort((b,y)=>(y.outcomes?.[0]?.price??0)-(b.outcomes?.[0]?.price??0)):l,[l]).filter(b=>b.status==="open"),c=m.length===1,f=m.slice(0,Ns),d=m.length-Ns,p=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),g=a?m.find(b=>b.slug===a)??null:null,v=!!g||c,h=()=>{v||n?.(e);},x=b=>{b.stopPropagation(),g&&(b.preventDefault(),s(null));},S=b=>{b.stopPropagation(),t||(b.preventDefault(),n?.(e));},k=c?jsx(qu,{event:e,formattedVolume:p,href:t,LinkComponent:r,onSelect:n}):g?jsx(Qu,{onCollapse:()=>s(null)}):jsx(Ku,{moreCount:d,formattedVolume:p,source:e.source,href:t,LinkComponent:r,onShowMore:S});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:b=>{let y=b.currentTarget,N=Eu[e.source]??Lu;y.style.borderColor=N.border,y.style.boxShadow=N.shadow,i?.(e);},onMouseLeave:b=>{let y=b.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:h,children:[jsx("style",{children:Du}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Fu,{event:e,href:t,LinkComponent:r,onClick:x,isExpanded:v}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:c?jsx(Gu,{market:m[0],event:e,onSelectOutcome:o}):g?jsx(Yu,{market:g,event:e,onCollapse:()=>s(null),onSelectOutcome:o}):jsx($u,{displayedMarkets:f,onMarketClick:b=>s(b.slug)})})]}),jsx(Vu,{children:k})]})}function Fu({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?Au(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:n,children:[jsx(Avatar,{src:e.image_url||void 0,name:Ms(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",o&&"group-hover/header:text-neutral-400"),children:Ms(e)}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(Hu,{event:e})]})}function Bu(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,a=900*1e3;if(o>0&&o<=a){let s=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:s});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Hu({event:e}){let t=useMemo(()=>Bu(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,n)=>{switch(r.kind){case "live":return jsx(zu,{},n);case "crypto-short":return jsx(Wu,{label:r.label,color:r.color},n);case "closed":return jsx(Uu,{},n)}})})}function zu(){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 Wu({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 Uu(){let{t:e}=useTranslation();return jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function $u({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let n=Is(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:o=>{o.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:_s(r)}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Os(n)}),jsx(ju,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function Ku({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:a}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[a("predict.event.showMore"),jsx(Fs,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",a("predict.event.volume"),jsx(Bs,{source:r})]})]})}function Vu({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Ls({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function Ds({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[a,s]=n?_u(e):[jo,Rs],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",m=o==="label"&&l===u?"action":o,c=m==="label"?`${Go(e.outcomes?.[0],"Yes")} ${Ts(e)}\xA2`:i("predict.market.action.yes",{price:Ts(e)}),f=m==="label"?`${Go(e.outcomes?.[1],"No")} ${Es(e)}\xA2`:i("predict.market.action.no",{price:Es(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Ls,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"yes");},children:c}),jsx(Ls,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"no");},children:f})]})}function ju(){let{t:e}=useTranslation();return jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsx("span",{className:"text-neutral-400",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Gu({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Ds,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function qu({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s=>{s.stopPropagation(),r||(s.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsx(Fs,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsx(Bs,{source:e.source})]})]})}function Yu({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Is(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:_s(e)}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Os(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Ds,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function Qu({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(Xu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Fs({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 Xu({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 Bs({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var tp=8;function zs({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:a,LinkComponent:s,onHover:l}){let{t:u}=useTranslation(),m=useRef(null);useEffect(()=>{let d=m.current;if(!d)return;let p=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return p.observe(d),()=>p.disconnect()},[t,r,n]);let c=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 zs({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[a,s]=useState(null),l=e.markets??[],m=useMemo(()=>l.length>2?[...l].sort((b,y)=>(y.outcomes?.[0]?.price??0)-(b.outcomes?.[0]?.price??0)):l,[l]).filter(b=>b.status==="open"),c=m.length===1,f=m.slice(0,Ls),d=m.length-Ls,p=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),g=a?m.find(b=>b.slug===a)??null:null,v=!!g||c,h=()=>{v||n?.(e);},x=b=>{b.stopPropagation(),g&&(b.preventDefault(),s(null));},S=b=>{b.stopPropagation(),t||(b.preventDefault(),n?.(e));},k=c?jsx(ep,{event:e,formattedVolume:p,href:t,LinkComponent:r,onSelect:n}):g?jsx(rp,{onCollapse:()=>s(null)}):jsx(Qu,{moreCount:d,formattedVolume:p,source:e.source,href:t,LinkComponent:r,onShowMore:S});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:b=>{let y=b.currentTarget,N=Au[e.source]??Du;y.style.borderColor=N.border,y.style.boxShadow=N.shadow,i?.(e);},onMouseLeave:b=>{let y=b.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:h,children:[jsx("style",{children:Uu}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx($u,{event:e,href:t,LinkComponent:r,onClick:x,isExpanded:v}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:c?jsx(Zu,{market:m[0],event:e,onSelectOutcome:o}):g?jsx(tp,{market:g,event:e,onCollapse:()=>s(null),onSelectOutcome:o}):jsx(Yu,{displayedMarkets:f,onMarketClick:b=>s(b.slug)})})]}),jsx(Xu,{children:k})]})}function $u({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?Wu(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:n,children:[jsx(Avatar,{src:e.image_url||void 0,name:_s(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn$1("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",o&&"group-hover/header:text-neutral-400"),children:_s(e)}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(Vu,{event:e})]})}function Ku(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,a=900*1e3;if(o>0&&o<=a){let s=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:s});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Vu({event:e}){let t=useMemo(()=>Ku(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,n)=>{switch(r.kind){case "live":return jsx(ju,{},n);case "crypto-short":return jsx(Gu,{label:r.label,color:r.color},n);case "closed":return jsx(qu,{},n)}})})}function ju(){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 Gu({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 qu(){let{t:e}=useTranslation();return jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Yu({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let n=Bs(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:o=>{o.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:Fs(r)}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Hs(n)}),jsx(Ju,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function Qu({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:a}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[a("predict.event.showMore"),jsx(Us,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",a("predict.event.volume"),jsx($s,{source:r})]})]})}function Xu({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function As({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function Ws({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[a,s]=n?Bu(e):[Yo,Ds],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",m=o==="label"&&l===u?"action":o,c=m==="label"?`${Qo(e.outcomes?.[0],"Yes")} ${Is(e)}\xA2`:i("predict.market.action.yes",{price:Is(e)}),f=m==="label"?`${Qo(e.outcomes?.[1],"No")} ${Os(e)}\xA2`:i("predict.market.action.no",{price:Os(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(As,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"yes");},children:c}),jsx(As,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"no");},children:f})]})}function Ju(){let{t:e}=useTranslation();return jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsx("span",{className:"text-neutral-400",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Zu({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Ws,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function ep({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s=>{s.stopPropagation(),r||(s.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsx(Us,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsx($s,{source:e.source})]})]})}function tp({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Bs(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:Fs(e)}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Hs(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Ws,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function rp({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(np,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Us({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 np({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 $s({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var ap=8;function Vs({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:a,LinkComponent:s,onHover:l}){let{t:u}=useTranslation(),m=useRef(null);useEffect(()=>{let d=m.current;if(!d)return;let p=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return p.observe(d),()=>p.disconnect()},[t,r,n]);let c=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((d,p)=>d==null?null:jsx("div",{style:{padding:
|
|
36
|
+
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((d,p)=>d==null?null:jsx("div",{style:{padding:ap,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${p%4*35}ms both`},children:jsx(zs,{event:d,href:a?.(d),LinkComponent:s,onSelect:o,onSelectOutcome:i,onHover:l})},`${d.source}-${d.slug}`))}),jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),u("predict.events.loadMore")]})}),f&&jsx(lp,{onScrollToTop:c})]})}function lp({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsx("span",{children:t("predict.event.backToTop")})]})]})}function Gs({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:m,lang:c,onSelect:f,onSelectOutcome:d,getEventHref:p,LinkComponent:g,onHover:v}){let{data:h,hasMore:x,fetchMore:S,isFetching:k,isFetchingMore:b}=Ms({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:m,lang:c});return k?jsx(Go,{count:24}):jsx(Vs,{events:h,hasMore:x,isFetchingMore:b,onFetchMore:S,onSelect:f,onSelectOutcome:d,getEventHref:p,LinkComponent:g,onHover:v})}function Qx({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:a,enableKalshi:s=true,lang:l}){let[u,m]=useState({categorySlug:null,tagSlug:null}),[c,f]=useState(()=>s?dn:{...dn,source:"polymarket"}),{isOpen:d,onOpen:p,onClose:g}=useDisclosure(),{onOpen:v}=useAsyncModal(cn),h=useCallback((w,R,O)=>{t?.(w,R,O),v({params:{event:w,market:R,initialOutcome:O,onInsufficientBalance:a}});},[t,v,a]),x=useCallback(w=>{m(w);},[]),S=useCallback(w=>{f(R=>({...R,sortPreset:w}));},[]),k=useCallback(w=>{f(R=>({...R,sortAsc:w}));},[]),b=useCallback(w=>{f(w);},[]),y=useMemo(()=>Ps[c.sortPreset].sort_by,[c.sortPreset]),N=useMemo(()=>jo(c,s),[c,s]),E=useMemo(()=>jsx(ws,{sortPreset:c.sortPreset,onSortChange:S,sortAsc:c.sortAsc,onSortAscChange:k,onFilterPress:p,filterCount:N}),[c.sortPreset,c.sortAsc,N,S,k,p]);return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(Qi,{onSelect:x,trailing:E})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(bs,{isOpen:d,onClose:g,value:c,onChange:b,enableKalshi:s}),jsx(Gs,{tagSlugSelection:u,lang:l,sort_by:y,sort_asc:c.sortAsc,source:c.source,timeRemaining:c.timeRemaining,minVolume:c.minVolume,minLiquidity:c.minLiquidity,onSelect:e,onSelectOutcome:h,getEventHref:r,LinkComponent:n,onHover:o})]}),jsx(Qn,{})]})}function Xs(e){return formatAmountInUsd(e)}var mp=[{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:Xs,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:Xs,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 ty({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
37
37
|
@keyframes evt-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
38
38
|
@keyframes evt-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
39
39
|
@keyframes evtHeroTitleEnter{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -71,15 +71,15 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
71
71
|
.evt-stat-label{font-size:11px;line-height:16px;min-height:16px;white-space:nowrap}
|
|
72
72
|
@media(min-width:640px){.evt-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
73
73
|
`}),jsxs("div",{className:"evt-hero-outer",children:[jsxs("div",{className:"evt-hero-left",style:{minWidth:0,flex:1,animation:"evtHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"evt-hero-live",style:{marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"evt-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"evt-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.events.liveBadge")})]})}),jsxs("h1",{className:"evt-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.events.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.events.titleHighlight")})]}),jsx("p",{className:"evt-hero-subtitle evt-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.events.heroSubtitle")).split(`
|
|
74
|
-
`).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:ap.map((r,n)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function Qs({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i,i18n:a}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{start:l}=useTradeResultConfirmation(),{evmAddress:u}=xr(),m=useWallets(),[c,f]=useState("idle"),[d,p]=useState(null),g=t.provider_meta?.["polymarket.conditionId"],v=t.provider_meta?.["polymarket.negRisk"]??false,h=u??"",x=useMemo(()=>Hr(i,a),[a,i]),S=useMemo(()=>m.find(Y=>Y.chainNamespace===ChainNamespace.EVM&&Y.isConnected),[m]),k=Ys(r.side,t.outcomes),y=t.outcomes?.[k]?.label??r.side,N=t.result!=null?Ys(t.result,t.outcomes):-1,P=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",R=t.result!=null?k===N:true,D=useMemo(()=>R?r.size:0,[R,r.size]),U=useCallback(async()=>{if(!(!g||!h||!S)){f("pending"),p(null);try{let Y=await S.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:g,neg_risk:v,signMessage:async C=>await Y.request({method:"personal_sign",params:[C,h]}),signTypedData:async C=>await Y.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(C)]})}),f("confirming");let q=zr({messages:x});q.submitted(),await l({source:r.source,user:h,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem"})==="confirmed"?(f("success"),q.completed()):(f("delayed"),q.delayed()),n?.();}catch(Y){f("error"),p(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,h,v,S,s,x,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,n,i]),Q=useAuthCallback(U),H=c==="idle"&&!!g&&!!h&&!!S&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(eo,{label:i("predict.positions.side"),value:y,valueClassName:R?"text-green-400":"text-red-400"}),t.result!=null&&jsx(eo,{label:i("predict.redeem.result"),value:P,valueClassName:"text-green-400"}),jsx(eo,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(eo,{label:i("predict.redeem.expectedPayout"),value:`$${D.toFixed(2)}`,valueClassName:D>0?"text-green-400":"text-zinc-400"})]}),!R&&D===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),c==="error"&&d&&jsx("p",{className:"text-sm text-red-400",children:d}),c==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),c==="delayed"&&jsx("p",{className:"text-sm text-zinc-400",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:!H,isLoading:c==="pending"||c==="confirming",onPress:Q,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&c!=="success"&&c!=="delayed"&&jsx("button",{type:"button",onClick:o,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),(c==="success"||c==="delayed")&&o&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:i("common.ok")})]})]})}function eo({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function Ys(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var Sp="predict-redeem";function Js({id:e=Sp}){return jsx(AsyncModal,{id:e,children:t=>jsx(wp,{...t})})}function wp({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:n("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:n("predict.redeem.description")})]}),jsx(Qs,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function ra({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:n=100,onSuccess:o}){let{t:i,i18n:a}=useTranslation(),s=useRef(o);s.current=o;let{status:l}=useAuth(),u=useWallets(),m=usePredictClient(),c=useContext(PolymarketContext),f=useQueryClient(),{start:d}=useTradeResultConfirmation(),p=e.source,g=p==="polymarket",v=u.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected),h=u.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),x=l==="authenticated",S=v?.address,k=h?.address,[b,y]=useState(t),[N,E]=useState("market"),[P,R]=useState(NaN),[D,U]=useState(NaN),[Q,H]=useState(false),[Y,q]=useState(false),[te,C]=useState(null),[T,B]=useState(null),[J,ue]=useState(false),[se,Ge]=useState(false),[We,st]=useState("1h"),[w,gt]=useState(30),[Ae,Ue]=useState("minutes"),Nt=useMemo(()=>Hr(i,a),[a,i]),Pe=useCallback(async(M,le)=>{let ke=zr({messages:Nt});ke.submitted(),await d({source:p,user:p==="kalshi"?S:k,kalshiUser:S,polymarketUser:k,marketSlug:e.slug,eventSlug:e.event_slug,expectation:M,getOrdersHeaders:le})==="confirmed"?ke.completed():ke.delayed();},[d,k,e.event_slug,e.slug,p,Nt,S]),at=useMemo(()=>{if(p!=="polymarket")return;let M=e.provider_meta?.["polymarket.clobTokenIds"];return M?(typeof M=="string"?JSON.parse(M):M)[b==="yes"?0:1]:void 0},[p,e.provider_meta,b]),{data:qe,isLoading:De}=useTickSize(at),Re=qe?.minimum_tick_size?String(qe.minimum_tick_size):"0.01",{data:_e,isLoading:Ct}=useFeeRate(at),Mt=String(_e?.base_fee??0),{data:At}=useRebateConfig(),ut=At?.builder_enabled&&At.builder_code?At.builder_code:void 0,et=false,Tt=null,lt=false,ht,Ne,ye;try{let M=xr();et=M.kalshiKycVerified,Tt=M.kalshiKycUrl,lt=M.polymarketSetupVerified,ht=M.polymarketSafeAddress,Ne=M.polymarketWalletKind,ye=M.polymarketWalletAddress;}catch{}let Et=p==="kalshi"&&!et,Ye=p==="polymarket"&&!lt,ve=useCallback(async()=>{if(!h||!c)return null;let M=await h.getEip1193Provider();if(!M)return null;let le=Ne==="deposit"&&!!ye,ke=!le&&!!ht,Xe={address:h.address,signatureType:le?3:ke?2:0,signTypedData:async(rt,nt,It,Ie)=>{let sr=[];"name"in rt&&sr.push({name:"name",type:"string"}),"version"in rt&&sr.push({name:"version",type:"string"}),"chainId"in rt&&sr.push({name:"chainId",type:"uint256"}),"verifyingContract"in rt&&sr.push({name:"verifyingContract",type:"address"}),"salt"in rt&&sr.push({name:"salt",type:"bytes32"});let _n={EIP712Domain:sr,...nt};return await M.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:rt,types:_n,primaryType:It,message:Ie})]})}};return c.credentials??await c.authenticate(Xe)},[ht,Ne,ye,h,c]),{data:$e}=useRealtimeOrderbook({slug:e.slug,source:p,outcome:b},{enabled:e.status==="open"}),be=useMemo(()=>{let M=pickBestBid($e,b);if(M!=null&&M>0)return M;let le=b==="yes"?0:1,ke=e.outcomes[le];return ke?.best_bid??ke?.price??.5},[$e,e.outcomes,b]),Lt=p==="kalshi"?S??"":k??"",{data:Rt,isLoading:I}=usePositionsMulti({kalshi_user:p==="kalshi"?Lt:void 0,polymarket_user:p==="polymarket"?Lt:void 0},{enabled:!!Lt,refetchInterval:3e4}),Me=useCallback(async()=>{let M=await ve();return M?await buildPolymarketL2Headers(M.address,{apiKey:M.apiKey,secret:M.secret,passphrase:M.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[ve]),{data:Ce,isLoading:Xr}=useAvailableShares({source:p,user:Lt,market:e.slug,side:b},p==="polymarket"?{getHeaders:Me}:void 0,{enabled:!!Lt&&!!e.slug,refetchOnMount:"always"}),O=e.provider_meta?.["dflow.yesMint"]??"",Te=e.provider_meta?.["dflow.noMint"]??"",tt=SOLANA_TOKENS.stablecoins.USDC.address,Jr=e.provider_meta?.["dflow.collateralMint"]||"",Co=b==="yes"?O:Te,Cn=(r||b).trim().toLowerCase(),Lr=useMemo(()=>Rt?Rt.positions.find(M=>M.side?.trim().toLowerCase()===Cn&&M.market?.slug===e.slug)??null:null,[Rt,e.slug,Cn]),Qe=useMemo(()=>p==="polymarket"?getPolymarketSharesPrecision(Re):Ce?.precision??0,[p,Re,Ce?.precision]),Rr=Ce?.active_order_shares??0,_r=p==="polymarket"&&!!r&&!!Lr?.size&&(Ce?.total_shares??0)<=0&&(Ce?.available_shares??0)<=0,Ht=_r?Lr?.size??0:0,Ir=_r?Ht:Ce?.total_shares??0,Yt=_r?Math.max(0,Ht-Rr):Ce?.available_shares??0,Mn=Xr||I,Tn=Lr?.market?.provider_meta,Mo=Tn?.["dflow.outcomeMint"]||Co,pr=Tn?.["dflow.collateralMint"]||Jr,zt=Mo,Qt=pr||tt,Or=useMemo(()=>isNaN(P)||P<=0?"0":String(Math.round(P*1e6)),[P]),To=p==="kalshi"&&!!zt&&!!Qt&&!!S&&Or!=="0",{refetch:Zr}=useDFlowQuote({inputMint:zt,outputMint:Qt,amount:Or,userPublicKey:S??"",slippageBps:100},{enabled:To}),mr=useMemo(()=>isNaN(P)||P<=0?0:P,[P]),vt=useMemo(()=>walkOrderbook({orderbook:$e,outcome:b,side:"sell",sharesNeeded:mr,slippageBps:n}),[$e,b,mr,n]),fr=useMemo(()=>vt.status==="ok"&&vt.worstPrice!=null&&vt.worstPrice>0?vt.worstPrice:be,[vt,be]),gr=useMemo(()=>N==="limit"&&g&&!isNaN(D)?D:fr,[N,g,D,fr]),_=useMemo(()=>isNaN(P)||P<=0?0:P*gr,[P,gr]),Fe=useMemo(()=>p!=="polymarket"?0:Ji({grossReturn:_,pricePerShare:gr,feeRateBps:Number(Mt)}),[p,_,gr,Mt]),Ke=useMemo(()=>Math.max(0,_-Fe),[_,Fe]),_t=useCallback(M=>{y(M),U(NaN),R(NaN),q(false);},[]);useEffect(()=>{_t(t);},[t,_t]);let en=useCallback(M=>{E(M);},[]);useEffect(()=>{N==="limit"&&U(Math.round(be*1e4)/1e4);},[N,b]);let hr=useCallback(M=>{if(q(false),isNaN(M)){R(NaN);return}R(xe(Math.max(0,M),Qe));},[Qe]),Xt=useCallback(()=>{q(true),R(xe(Yt,Qe));},[Yt,Qe]),ct=useCallback(M=>{if(isNaN(M)){U(NaN);return}U(Math.round(M*1e4)/1e4);},[]),vr=useCallback(()=>{R(NaN),U(NaN),E("market"),q(false),Ge(false),st("1h"),gt(30),Ue("minutes");},[]),Ar=useMemo(()=>{let M=[];return isNaN(P)||P<=0?M.push(i("predict.trade.minQuantity",{amount:zn})):P<zn&&M.push(i("predict.trade.minQuantity",{amount:zn})),e.status!=="open"&&M.push(i("predict.trade.marketNotActive")),!isNaN(P)&&P>0&&!Y&&P>Yt&&M.push(i("predict.trade.insufficientSharesDetail",{total:xe(Ir,Qe).toFixed(Qe),active:xe(Rr,Qe).toFixed(Qe),available:xe(Yt,Qe).toFixed(Qe)})),N==="limit"&&g&&(isNaN(D)||D<.01||D>.99)&&M.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&se&&We==="custom"&&(isNaN(w)||w<=0)&&M.push(i("predict.trade.expiration.invalidDate")),p==="polymarket"&&N==="market"&&!isNaN(P)&&P>0&&(vt.status==="insufficient_liquidity"?M.push(i("predict.trade.insufficientLiquidity",{available:xe(vt.totalAvailable,2)})):vt.status==="exceeds_slippage"&&M.push(i("predict.trade.priceImpactTooHigh",{impact:(vt.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:M.length===0,errors:M}},[P,e.status,Yt,Ir,Rr,Y,N,g,D,se,We,w,Qe,p,vt,n,i]),{mutateAsync:Jt}=useDFlowSubmit(),{data:Dr}=useOrder({id:te??"",source:p},{enabled:!!te}),En=useCallback(async()=>{if(!T||!S||!v)return;let{cashAmount:M,collateral:le}=T;B(null);try{let Xe=(await m.createDFlowQuote({inputMint:le,outputMint:tt,amount:M,userPublicKey:S,slippageBps:100}))?.transaction;if(!Xe)return;let rt=Uint8Array.from(atob(Xe),It=>It.charCodeAt(0)),nt=await v.signTransaction(rt);await Jt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:S,input_mint:le,output_mint:tt,amount:M,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[T,S,v,m,Jt,tt]),Zt=useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);useEffect(()=>{if(!Dr||!te)return;let{status:M}=Dr;M==="closed"?(C(null),T?En().finally(()=>{H(false),Pe("sell-market"),Zt(),vr(),s.current?.();}):(H(false),Pe("sell-market"),Zt(),vr(),s.current?.())):(M==="failed"||M==="expired")&&(H(false),C(null),B(null),toast.error(i("predict.trade.submitError")));},[Dr,te,T,En,Pe,Zt,vr,i]);let Ln=useCallback(async()=>{if(!S||!v)return;if(!zt||!Qt){toast.error("Missing token mint addresses"),H(false);return}if(!et){ue(true),H(false);return}let ke=(await Zr()).data,Xe=ke?.transaction;if(!Xe){toast.error(i("predict.trade.submitError")),H(false);return}if(pr&&pr!==tt){let Ie=String(ke?.outAmount??"");Ie&&Ie!=="0"&&B({cashAmount:Ie,collateral:pr});}let rt=Uint8Array.from(atob(Xe),Ie=>Ie.charCodeAt(0)),nt=await v.signTransaction(rt),It=await Jt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:S,input_mint:zt,output_mint:Qt,amount:Or,price:String(be),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});C(It.signature);},[S,v,Zr,Jt,zt,Qt,Or,be,b,e.slug,pr,tt,i,et]),Rn=useCallback(async()=>{if(!h||!c)return;let M=h.chain,le=M!==Chain.POLYGON;le&&await h.switchChain(Chain.POLYGON);try{let ke=await h.getEip1193Provider();if(!ke){toast.error(i("predict.trade.submitError")),H(!1);return}let Xe=Ne==="deposit"&&!!ye,rt=!Xe&&!!ht,nt=Xe?ye:ht,It={address:h.address,signatureType:Xe?3:rt?2:0,signTypedData:async(Wt,On,Ro,_o)=>{let Fr=[];"name"in Wt&&Fr.push({name:"name",type:"string"}),"version"in Wt&&Fr.push({name:"version",type:"string"}),"chainId"in Wt&&Fr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Wt&&Fr.push({name:"verifyingContract",type:"address"}),"salt"in Wt&&Fr.push({name:"salt",type:"bytes32"});let wc={EIP712Domain:Fr,...On};return await ke.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Wt,types:wc,primaryType:Ro,message:_o})]})}},Ie=await ve();if(!Ie){toast.error(i("predict.trade.submitError")),H(!1);return}let sr=b==="yes"?0:1,_n="",In=e.provider_meta?.["polymarket.clobTokenIds"];In&&(_n=(typeof In=="string"?JSON.parse(In):In)[sr]??"");let Fi=e.provider_meta?.["polymarket.negRisk"]??!1,kc=N==="limit"&&!isNaN(D)?D:fr,Sc=$n(kc,Re),Eo={tokenId:_n,price:Sc,size:P,side:"SELL",orderType:N==="limit"?se?"GTD":"GTC":"FOK",tickSize:Re,negRisk:Fi,...nt&&{funderAddress:nt},...ut&&{builderCode:ut},...N==="limit"&&se&&{expiration:Un(We,w,Ae)}},Lo;if(Xe)Lo=await buildSignedV2OrderPayload({signer:It,depositWalletAddress:nt,input:Eo,owner:Ie.apiKey});else {let Wt=buildCtfExchangeDomain(Fi),On=buildOrderMessage({...Eo,signerAddress:It.address,signatureType:It.signatureType,feeRateBps:Mt}),Ro=await It.signTypedData(Wt,CTF_ORDER_TYPES,"Order",On),_o=buildSignedOrder(On,Ro,Eo.orderType);Lo=buildClobPayload(_o,Ie.apiKey);}await m.executePolymarketOrder({payload:Lo,l2_api_key:Ie.apiKey,l2_secret:Ie.secret,l2_passphrase:Ie.passphrase,signer_address:Ie.address,owner:Ie.apiKey}),Zt(),Pe(N==="limit"?"sell-limit":"sell-market",async()=>await buildPolymarketL2Headers(Ie.address,{apiKey:Ie.apiKey,secret:Ie.secret,passphrase:Ie.passphrase,method:"GET",requestPath:"/data/orders"})),vr(),H(!1),s.current?.();}finally{le&&M&&h.switchChain(M).catch(()=>{});}},[h,c,ve,b,e.provider_meta,N,Pe,D,fr,P,m,Zt,se,We,w,Ae,vr,i,Re,Mt,e.slug,ht,Ne,ye,ut]),tn=useCallback(async()=>{if(!(!Ar.isValid||!x)){H(true),C(null),ue(false);try{p==="kalshi"?await Ln():await Rn();}catch(M){let le=M instanceof Error?M.message:"",ke=p==="polymarket"&&le?Kn(le,i,"sell"):le||void 0;toast.error(ke||i("predict.trade.submitError")),H(false);}}},[Ar.isValid,x,p,Ln,Rn,i]);return {outcome:b,orderType:N,quantity:P,limitPrice:D,shares:mr,effectivePrice:gr,grossReturn:_,estimatedFee:Fe,estimatedReturn:Ke,pricePerShare:be,isMarketDataLoading:p==="polymarket"&&(Ct||De),isSubmitting:Q,authStatus:l,validation:Ar,supportsLimitOrder:g,kycRequired:J,needsKyc:Et,needsSetup:Ye,kycUrl:Tt,totalShares:Ir,activeOrderShares:Rr,availableShares:Yt,isAvailableLoading:Mn,isSellAll:Y,precision:Qe,expirationEnabled:se,expirationPreset:We,customDuration:w,customDurationUnit:Ae,setOutcome:_t,setOrderType:en,setQuantity:hr,setLimitPrice:ct,setSellAll:Xt,setExpirationEnabled:Ge,setExpirationPreset:st,setCustomDuration:gt,setCustomDurationUnit:Ue,submit:tn}}var am=["5m","1h","12h","24h","eod","custom"],lm={"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"},cm=["minutes","hours","days"],dm={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},um={maximumFractionDigits:0},dn="-";function da({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,effectivePrice:s,grossReturn:l,estimatedFee:u,estimatedReturn:m,isMarketDataLoading:c,isSubmitting:f,authStatus:d,isValid:p,validationErrors:g,supportsLimitOrder:v,kycRequired:h,needsKyc:x,needsSetup:S,onSetupRequired:k,kycUrl:b,totalShares:y,activeOrderShares:N,availableShares:E,isAvailableLoading:P,precision:R,expirationEnabled:D,expirationPreset:U,customDuration:Q,customDurationUnit:H,oddsFormatter:Y,outcomeLabels:q,onOutcomeChange:te,onOrderTypeChange:C,onQuantityChange:T,onLimitPriceChange:B,onSellAll:J,onExpirationEnabledChange:ue,onExpirationPresetChange:se,onCustomDurationChange:Ge,onCustomDurationUnitChange:We,onSubmit:st}){let{t:w}=useTranslation(),[gt,Ae]=useState(false),[Ue,Nt]=useState(true),Pe=useDisclosure(),[at,qe]=useState(""),De=useRef(false);useEffect(()=>{De.current||qe(isNaN(i)?"":String(i));},[i]);let[Re,_e]=useState(""),Ct=useRef(false);useEffect(()=>{Ct.current||(isNaN(a)?_e(""):_e(String(parseFloat((a*100).toFixed(2)))));},[a]);let Mt=useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(_e(I),I===""||I==="."){B(NaN);return}let Ce=parseFloat(I);isNaN(Ce)||B(Ce/100);},[B]),At=useCallback(I=>{let Me=new RegExp(`^\\d*\\.?\\d{0,${R}}$`);if(I!==""&&!Me.test(I))return;if(qe(I),Ae(false),I===""||I==="."){T(NaN);return}let Ce=parseFloat(I);isNaN(Ce)||T(Ce);},[T,R]);useEffect(()=>{h&&!Pe.isOpen&&Pe.onOpen();},[h]);let ut=useMemo(()=>{let I=n==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[n,t]),et=n==="yes"?t.yesBid:t.noBid,Tt=et!=null&&Y?Y(Number(et)):ut!=null?`${ut} \xA2`:null,lt=Number.isFinite(s)?parseFloat((s*100).toFixed(2)):null,ht=Number.isFinite(s)&&Y?Y(s):lt!=null?`${lt} \xA2`:null,Ne=!isNaN(i)&&i>0,ye=Ne&&i>0?m/i:0,Et=ye>0&&Y?Y(ye):ye>0?`${parseFloat((ye*100).toFixed(2))} \xA2`:dn,Ye=d==="authenticated",ve=d==="authenticating"||d==="deauthenticating",$e=Ye&&(x||S),be=useCallback(I=>q?.[I]??w(I==="yes"?"predict.trade.yes":"predict.trade.no"),[q,w]),Lt=useMemo(()=>{if(ve)return w("predict.trade.checkingLogin");if(!Ye)return w("predict.trade.loginToTrade");if(x)return w("predict.trade.kycRequired");if(S)return w("predict.trade.setupRequired");if(P)return w("predict.trade.loadingBalance");if(c)return w("predict.trade.loadingMarketData");if(f)return w("predict.trade.submitting");if(h)return w("predict.trade.kycRequired");if(!Ne)return w("predict.trade.enterAmount");let I=be(n);return `${w("predict.trade.sell")} ${I}`},[ve,Ye,x,S,P,c,f,h,Ne,n,be,w]),Rt=()=>{if(!Ye){Ae(false),st();return}if(x){Pe.onOpen();return}if(S&&k){Ae(false),k();return}if(h){Pe.onOpen();return}if(!p){Ae(true);return}Ae(false),st();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[w("predict.trade.sell")," ",be(n)]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[v?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:I=>C(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:w("predict.trade.market")},"market"),jsx(Tab,{title:w("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&v?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Re,onChange:I=>Mt(I.target.value),onFocus:()=>{Ct.current=true;},onBlur:()=>{Ct.current=false,isNaN(a)?_e(""):_e(String(parseFloat((a*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Tt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:Tt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let Me=I==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>te(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===I?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:be(I)}),Me!=null&&jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(Me)):`${parseFloat((Number(Me)*100).toFixed(2))}\xA2`})]})},I)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let Me=Math.pow(10,R);return jsxs("button",{type:"button",onClick:()=>{T(Math.floor(E*I/100*Me)/Me);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[I,"%"]},I)}),jsx("button",{type:"button",onClick:J,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:at,onChange:I=>At(I.target.value),onFocus:()=>{De.current=true;},onBlur:()=>{De.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"}}),gt&&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-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:P?"\u2013":`${xe(y,R).toFixed(R)}${w("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:P?"\u2013":N>0?`-${xe(N,R).toFixed(R)}${w("predict.trade.sharesUnit")}`:`0${w("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:P?"\u2013":`${xe(E,R).toFixed(R)}${w("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${m.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:()=>Nt(I=>!I),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:w("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",Ue&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Number.isFinite(s)?ht:lt!=null?w("predict.trade.chance",{percent:lt}):dn})]}),Ue&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?yr(i):dn})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:Ne?`$${l.toFixed(2)}`:dn})]}),(u??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${(u??0).toFixed(2)}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estReturnAfterFees")}),jsx("span",{className:"tabular-nums text-foreground",children:Ne?`$${m.toFixed(2)}`:dn})]}),(u??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:Et})]})]})]}),o==="limit"&&v&&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:w("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:D,onValueChange:ue,"aria-label":w("predict.trade.setExpiration")})]}),D&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[U],onSelectionChange:I=>{let Me=Array.from(I)[0];Me&&se(Me);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:am.map(I=>jsx(SelectItem,{children:w(lm[I])},I))}),U==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(Q)?void 0:Q,onValueChange:Ge,minValue:1,step:1,formatOptions:um,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[H],onSelectionChange:I=>{let Me=Array.from(I)[0];Me&&We(Me);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:cm.map(I=>jsx(SelectItem,{children:w(dm[I])},I))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:ve||Ye&&!$e&&(P||c||!Ne||f),isLoading:ve||Ye&&!$e&&(f||P||c),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Rt,children:Lt})]}),jsx(jn,{isOpen:Pe.isOpen,onClose:Pe.onClose,kycUrl:b})]})}function no({event:e,market:t,variant:r,initialOutcome:n,initialPositionSide:o,chain:i,slippageBps:a,onOutcomeChange:s,onSetupRequired:l,onSuccess:u,oddsFormatter:m,outcomeLabels:c}){let{outcome:f,orderType:d,quantity:p,limitPrice:g,effectivePrice:v,grossReturn:h,estimatedFee:x,estimatedReturn:S,pricePerShare:k,isMarketDataLoading:b,isSubmitting:y,authStatus:N,validation:E,supportsLimitOrder:P,kycRequired:R,needsKyc:D,needsSetup:U,kycUrl:Q,totalShares:H,activeOrderShares:Y,availableShares:q,isAvailableLoading:te,precision:C,expirationEnabled:T,expirationPreset:B,customDuration:J,customDurationUnit:ue,setOutcome:se,setOrderType:Ge,setQuantity:We,setLimitPrice:st,setSellAll:w,setExpirationEnabled:gt,setExpirationPreset:Ae,setCustomDuration:Ue,setCustomDurationUnit:Nt,submit:Pe}=ra({market:t,initialOutcome:n,initialPositionSide:o,slippageBps:a,onSuccess:u}),at=useAuthCallback(Pe),qe=useCallback(_e=>{se(_e),s?.(_e);},[se,s]),De=useMemo(()=>e?Dn(e):void 0,[e]),Re=useMemo(()=>Fn(t,{yesBid:f==="yes"?k:void 0,noBid:f==="no"?k:void 0}),[t,f,k]);return jsx(da,{event:De,market:Re,variant:r,outcome:f,orderType:d,quantity:p,limitPrice:g,effectivePrice:v,grossReturn:h,estimatedFee:x,estimatedReturn:S,isMarketDataLoading:b,isSubmitting:y,authStatus:N,isValid:E.isValid,validationErrors:E.errors,supportsLimitOrder:P,kycRequired:R,needsKyc:D,needsSetup:U,onSetupRequired:l,kycUrl:Q,totalShares:H,activeOrderShares:Y,availableShares:q,isAvailableLoading:te,precision:C,expirationEnabled:T,expirationPreset:B,customDuration:J,customDurationUnit:ue,oddsFormatter:m,outcomeLabels:c,onOutcomeChange:qe,onOrderTypeChange:Ge,onQuantityChange:We,onLimitPriceChange:st,onSellAll:w,onExpirationEnabledChange:gt,onExpirationPresetChange:Ae,onCustomDurationChange:Ue,onCustomDurationUnitChange:Nt,onSubmit:at})}var ti="predict-sell";function pa({id:e=ti}){return jsx(AsyncModal,{id:e,children:t=>jsx(ym,{...t})})}function ym({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(no,{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-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var oi=40,so=36,mn=480,ii=mn-so;function ga({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),a=useMemo(()=>e.markets?.map(c=>c.slug)??[],[e.markets]),{data:s}=usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=useMemo(()=>!s?.positions||!t?0:a.length===0?s.positions.length:s.positions.filter(c=>c.market&&a.includes(c.market.slug)).length,[s?.positions,a,t]),m=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:m.map(c=>jsx("button",{type:"button",onClick:()=>i(c.key),className:cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===c.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:c.label},c.key))}),t?jsxs("div",{style:{height:mn},children:[o==="positions"&&jsx(Mm,{source:e.source,walletAddress:t,marketSlugs:a}),o==="orders"&&jsx(Em,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),o==="trades"&&jsx(_m,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:n("predict.trade.connectWallet")})]})}function Mm({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=useTranslation(),{data:o,isLoading:i}=usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),a=useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[o?.positions,r]);return i?jsx(ai,{}):a.length===0?jsx(si,{message:n("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:so},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:ii},rowComponent:Tm,rowCount:a.length,rowHeight:oi,rowProps:{positions:a,closeLabel:n("predict.positions.close")}})]})}function Tm({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,a=o.pnl_percent??0,s=o.avg_price??0,l=o.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",m=i>0?"+":"",c=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,d=o.size,p=o.size*l,g=o.market?.end_at?Am(o.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsx("span",{className:cn("text-[10px] font-medium",f.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:f})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:oo(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:oo(l)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[m,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",m,a.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:n})})]})}function Em({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=useTranslation(),{data:i,isLoading:a,fetchNextPage:s,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),u=useCancelOrder(),m=useMemo(()=>{let h=i?.pages?.flatMap(k=>k.items)??[],x=new Set(["live","open","submitted","pending"]),S=h.filter(k=>x.has(k.status));return r.length>0&&(S=S.filter(k=>k.market_id&&r.includes(k.market_id))),S},[i?.pages,r]),c=useCallback(h=>{n?n(h.id):u.mutate({source:h.source,id:h.id});},[n,u]),f=m.length,d=f+(l?1:0),p=useCallback(h=>h<f,[f]),g=useCallback(async()=>{await s();},[s]),v=useInfiniteLoader({isRowLoaded:p,loadMoreRows:g,rowCount:d,threshold:5});return a?jsx(ai,{}):m.length===0&&!l?jsx(si,{message:o("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:so},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:ii},onRowsRendered:v,rowComponent:Lm,rowCount:d,rowHeight:oi,rowProps:{orders:m,itemCount:f,onCancel:c,isCancelling:u.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Lm({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:a}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:s.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?oo(parseFloat(s.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Rm,{status:s.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>o(s),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):a})})]})}function Rm({status:e}){return jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function _m({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:a}=useInfiniteTrades({source:e,wallet:t,limit:50}),s=useMemo(()=>n?.pages?.flatMap(d=>d.items)??[],[n?.pages]),l=s.length,u=l+(a?1:0),m=useCallback(d=>d<l,[l]),c=useCallback(async()=>{await i();},[i]),f=useInfiniteLoader({isRowLoaded:m,loadMoreRows:c,rowCount:u,threshold:5});return o?jsx(ai,{}):s.length===0&&!a?jsx(si,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:so},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:ii},onRowsRendered:f,rowComponent:Im,rowCount:u,rowHeight:oi,rowProps:{trades:s,itemCount:l}})]})}function Im({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",a=Om(o.timestamp),s=o.price??0,l=o.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:o.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:o.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:oo(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:a})]})}function si({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:e})}function ai(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:mn},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function oo(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Om(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${i}`}function Am(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var ha=`
|
|
74
|
+
`).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:mp.map((r,n)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function ta({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i,i18n:a}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{start:l}=useTradeResultConfirmation(),{evmAddress:u}=yr(),m=useWallets(),[c,f]=useState("idle"),[d,p]=useState(null),g=t.provider_meta?.["polymarket.conditionId"],v=t.provider_meta?.["polymarket.negRisk"]??false,h=u??"",x=useMemo(()=>Ur(i,a),[a,i]),S=useMemo(()=>m.find(Y=>Y.chainNamespace===ChainNamespace.EVM&&Y.isConnected),[m]),k=ea(r.side,t.outcomes),y=t.outcomes?.[k]?.label??r.side,N=t.result!=null?ea(t.result,t.outcomes):-1,w=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",R=t.result!=null?k===N:true,O=useMemo(()=>R?r.size:0,[R,r.size]),U=useCallback(async()=>{if(!(!g||!h||!S)){f("pending"),p(null);try{let Y=await S.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:g,neg_risk:v,signMessage:async C=>await Y.request({method:"personal_sign",params:[C,h]}),signTypedData:async C=>await Y.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(C)]})}),f("confirming");let q=$r({messages:x});q.submitted(),await l({source:r.source,user:h,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem",expectedPayout:O})==="confirmed"?(f("success"),q.completed()):(f("delayed"),q.delayed()),n?.();}catch(Y){f("error"),p(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,h,v,S,s,x,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,O,n,i]),Q=useAuthCallback(U),H=c==="idle"&&!!g&&!!h&&!!S&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(to,{label:i("predict.positions.side"),value:y,valueClassName:R?"text-green-400":"text-red-400"}),t.result!=null&&jsx(to,{label:i("predict.redeem.result"),value:w,valueClassName:"text-green-400"}),jsx(to,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(to,{label:i("predict.redeem.expectedPayout"),value:`$${O.toFixed(2)}`,valueClassName:O>0?"text-green-400":"text-zinc-400"})]}),!R&&O===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),c==="error"&&d&&jsx("p",{className:"text-sm text-red-400",children:d}),c==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),c==="delayed"&&jsx("p",{className:"text-sm text-zinc-400",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:!H,isLoading:c==="pending"||c==="confirming",onPress:Q,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&c!=="success"&&c!=="delayed"&&jsx("button",{type:"button",onClick:o,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),(c==="success"||c==="delayed")&&o&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:i("common.ok")})]})]})}function to({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function ea(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var Tp="predict-redeem";function na({id:e=Tp}){return jsx(AsyncModal,{id:e,children:t=>jsx(Ep,{...t})})}function Ep({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:n("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:n("predict.redeem.description")})]}),jsx(ta,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function ni(e){return e?.trim().toLowerCase()??""}function ri(e,t){let r=e.provider_meta?.[t];return typeof r=="string"?r:""}function aa(e,t){return !!(e&&t&&e.trim().toLowerCase().includes(t))}function om(e,t){let r=ni(e.side);if(r==="yes"||r==="no")return r;if(r==="over"||r==="odd")return "yes";if(r==="under"||r==="even")return "no";let n=[t.outcomes?.[0]?.label,ri(t,"polymarket.groupItemTitle"),ri(t,"polymarket.groupItemTitleTrans"),ri(t,"polymarket.group_item_title_trans")],o=[t.outcomes?.[1]?.label];return n.some(i=>aa(i,r))?"yes":o.some(i=>aa(i,r))?"no":null}function la({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:n=100,onSuccess:o}){let{t:i,i18n:a}=useTranslation(),s=useRef(o);s.current=o;let{status:l}=useAuth(),u=useWallets(),m=usePredictClient(),c=useContext(PolymarketContext),f=useQueryClient(),{start:d}=useTradeResultConfirmation(),p=e.source,g=p==="polymarket",v=u.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected),h=u.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),x=l==="authenticated",S=v?.address,k=h?.address,[b,y]=useState(t),[N,E]=useState("market"),[w,R]=useState(NaN),[O,U]=useState(NaN),[Q,H]=useState(false),[Y,q]=useState(false),[te,C]=useState(null),[T,B]=useState(null),[J,de]=useState(false),[se,Ve]=useState(false),[je,Ge]=useState("1h"),[P,dt]=useState(30),[qe,Re]=useState("minutes"),Nt=useMemo(()=>Ur(i,a),[a,i]),_e=true,Ye=useCallback(async(M,Se)=>{let Pe=$r({messages:Nt});Pe.submitted(),await d({source:p,user:p==="kalshi"?S:k,kalshiUser:_e?S:void 0,polymarketUser:k,marketSlug:e.slug,eventSlug:e.event_slug,expectation:M,getOrdersHeaders:Se})==="confirmed"?Pe.completed():Pe.delayed();},[d,_e,k,e.event_slug,e.slug,p,Nt,S]),ot=useMemo(()=>{if(p!=="polymarket")return;let M=e.provider_meta?.["polymarket.clobTokenIds"];return M?(typeof M=="string"?JSON.parse(M):M)[b==="yes"?0:1]:void 0},[p,e.provider_meta,b]),{data:we,isLoading:et}=useTickSize(ot),Ie=we?.minimum_tick_size?String(we.minimum_tick_size):"0.01",{data:it,isLoading:Ot}=useFeeRate(ot),Ct=String(it?.base_fee??0),{data:Mt}=useRebateConfig(),tt=Mt?.builder_enabled&&Mt.builder_code?Mt.builder_code:void 0,gt=false,We=null,Yt=false,Oe,Qe,me;try{let M=yr();_e=M.enableKalshi,gt=M.kalshiKycVerified,We=M.kalshiKycUrl,Yt=M.polymarketSetupVerified,Oe=M.polymarketSafeAddress,Qe=M.polymarketWalletKind,me=M.polymarketWalletAddress;}catch{}let st=p==="kalshi"&&!gt,ht=p==="polymarket"&&!Yt,ve=useCallback(async()=>{if(!h||!c)return null;let M=await h.getEip1193Provider();if(!M)return null;let Se=Qe==="deposit"&&!!me,Pe=!Se&&!!Oe,Ae={address:h.address,signatureType:Se?3:Pe?2:0,signTypedData:async(ut,er,zt,De)=>{let lr=[];"name"in ut&&lr.push({name:"name",type:"string"}),"version"in ut&&lr.push({name:"version",type:"string"}),"chainId"in ut&&lr.push({name:"chainId",type:"uint256"}),"verifyingContract"in ut&&lr.push({name:"verifyingContract",type:"address"}),"salt"in ut&&lr.push({name:"salt",type:"bytes32"});let In={EIP712Domain:lr,...er};return await M.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:ut,types:In,primaryType:zt,message:De})]})}};return c.credentials??await c.authenticate(Ae)},[Oe,Qe,me,h,c]),{data:Xe}=useRealtimeOrderbook({slug:e.slug,source:p,outcome:b},{enabled:e.status==="open"}),Ne=useMemo(()=>{let M=pickBestBid(Xe,b);if(M!=null&&M>0)return M;let Se=b==="yes"?0:1,Pe=e.outcomes[Se];return Pe?.best_bid??Pe?.price??.5},[Xe,e.outcomes,b]),Tt=p==="kalshi"?S??"":k??"",{data:_,isLoading:Ce}=usePositionsMulti({kalshi_user:p==="kalshi"?Tt:void 0,polymarket_user:p==="polymarket"?Tt:void 0},{enabled:!!Tt,refetchInterval:3e4}),Ue=ni(r),en=r?.trim(),D=useMemo(()=>_?_.positions.find(M=>M.market?.slug!==e.slug?false:Ue?ni(M.side)===Ue:om(M,e)===b)??null:null,[_,e,e.slug,b,Ue]),Me=en||D?.side||b,vt=useCallback(async()=>{let M=await ve();return M?await buildPolymarketL2Headers(M.address,{apiKey:M.apiKey,secret:M.secret,passphrase:M.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[ve]),{data:At,isLoading:tn}=useAvailableShares({source:p,user:Tt,market:e.slug,side:Me},p==="polymarket"?{getHeaders:vt}:void 0,{enabled:!!Tt&&!!e.slug,refetchOnMount:"always"}),Mo=e.provider_meta?.["dflow.yesMint"]??"",To=e.provider_meta?.["dflow.noMint"]??"",Qt=SOLANA_TOKENS.stablecoins.USDC.address,Rr=e.provider_meta?.["dflow.collateralMint"]||"",Eo=b==="yes"?Mo:To,at=useMemo(()=>p==="polymarket"?getPolymarketSharesPrecision(Ie):At?.precision??0,[p,Ie,At?.precision]),Et=At?.active_order_shares??0,_r=p==="polymarket"&&!!D?.size&&(At?.total_shares??0)<=0&&(At?.available_shares??0)<=0,rn=_r?D?.size??0:0,Ir=_r?rn:At?.total_shares??0,ar=_r?Math.max(0,rn-Et):At?.available_shares??0,Lo=tn||Ce,Ln=D?.market?.provider_meta,Or=Ln?.["dflow.outcomeMint"]||Eo,Xt=Ln?.["dflow.collateralMint"]||Rr,fr=Or,gr=Xt||Qt,hr=useMemo(()=>isNaN(w)||w<=0?"0":String(Math.round(w*1e6)),[w]),nn=p==="kalshi"&&!!fr&&!!gr&&!!S&&hr!=="0",{refetch:on}=useDFlowQuote({inputMint:fr,outputMint:gr,amount:hr,userPublicKey:S??"",slippageBps:100},{enabled:nn}),Ar=useMemo(()=>isNaN(w)||w<=0?0:w,[w]),Lt=useMemo(()=>walkOrderbook({orderbook:Xe,outcome:b,side:"sell",sharesNeeded:Ar,slippageBps:n}),[Xe,b,Ar,n]),I=useMemo(()=>Lt.status==="ok"&&Lt.worstPrice!=null&&Lt.worstPrice>0?Lt.worstPrice:Ne,[Lt,Ne]),Te=useMemo(()=>N==="limit"&&g&&!isNaN(O)?O:I,[N,g,O,I]),ke=useMemo(()=>isNaN(w)||w<=0?0:w*Te,[w,Te]),Rt=useMemo(()=>p!=="polymarket"?0:ns({grossReturn:ke,pricePerShare:Te,feeRateBps:Number(Ct)}),[p,ke,Te,Ct]),sn=useMemo(()=>Math.max(0,ke-Rt),[ke,Rt]),Jt=useCallback(M=>{y(M),U(NaN),R(NaN),q(false);},[]);useEffect(()=>{Jt(t);},[t,Jt]);let Zt=useCallback(M=>{E(M);},[]);useEffect(()=>{N==="limit"&&U(Math.round(Ne*1e4)/1e4);},[N,b]);let lt=useCallback(M=>{if(q(false),isNaN(M)){R(NaN);return}R(be(Math.max(0,M),at));},[at]),Ro=useCallback(()=>{q(true),R(be(ar,at));},[ar,at]),Rn=useCallback(M=>{if(isNaN(M)){U(NaN);return}U(Math.round(M*1e4)/1e4);},[]),Ht=useCallback(()=>{R(NaN),U(NaN),E("market"),q(false),Ve(false),Ge("1h"),dt(30),Re("minutes");},[]),Dr=useMemo(()=>{let M=[];return isNaN(w)||w<=0?M.push(i("predict.trade.minQuantity",{amount:Wn})):w<Wn&&M.push(i("predict.trade.minQuantity",{amount:Wn})),e.status!=="open"&&M.push(i("predict.trade.marketNotActive")),!isNaN(w)&&w>0&&!Y&&w>ar&&M.push(i("predict.trade.insufficientSharesDetail",{total:be(Ir,at).toFixed(at),active:be(Et,at).toFixed(at),available:be(ar,at).toFixed(at)})),N==="limit"&&g&&(isNaN(O)||O<.01||O>.99)&&M.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&se&&je==="custom"&&(isNaN(P)||P<=0)&&M.push(i("predict.trade.expiration.invalidDate")),p==="polymarket"&&N==="market"&&!isNaN(w)&&w>0&&(Lt.status==="insufficient_liquidity"?M.push(i("predict.trade.insufficientLiquidity",{available:be(Lt.totalAvailable,2)})):Lt.status==="exceeds_slippage"&&M.push(i("predict.trade.priceImpactTooHigh",{impact:(Lt.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:M.length===0,errors:M}},[w,e.status,ar,Ir,Et,Y,N,g,O,se,je,P,at,p,Lt,n,i]),{mutateAsync:Fr}=useDFlowSubmit(),{data:vr}=useOrder({id:te??"",source:p},{enabled:!!te}),_n=useCallback(async()=>{if(!T||!S||!v)return;let{cashAmount:M,collateral:Se}=T;B(null);try{let Ae=(await m.createDFlowQuote({inputMint:Se,outputMint:Qt,amount:M,userPublicKey:S,slippageBps:100}))?.transaction;if(!Ae)return;let ut=Uint8Array.from(atob(Ae),zt=>zt.charCodeAt(0)),er=await v.signTransaction(ut);await Fr({signedTransaction:btoa(String.fromCharCode(...er)),orderContext:{user_public_key:S,input_mint:Se,output_mint:Qt,amount:M,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[T,S,v,m,Fr,Qt]),br=useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);useEffect(()=>{if(!vr||!te)return;let{status:M}=vr;M==="closed"?(C(null),T?_n().finally(()=>{H(false),Ye("sell-market"),br(),Ht(),s.current?.();}):(H(false),Ye("sell-market"),br(),Ht(),s.current?.())):(M==="failed"||M==="expired")&&(H(false),C(null),B(null),toast.error(i("predict.trade.submitError")));},[vr,te,T,_n,Ye,br,Ht,i]);let Br=useCallback(async()=>{if(!S||!v)return;if(!fr||!gr){toast.error("Missing token mint addresses"),H(false);return}if(!gt){de(true),H(false);return}let Pe=(await on()).data,Ae=Pe?.transaction;if(!Ae){toast.error(i("predict.trade.submitError")),H(false);return}if(Xt&&Xt!==Qt){let De=String(Pe?.outAmount??"");De&&De!=="0"&&B({cashAmount:De,collateral:Xt});}let ut=Uint8Array.from(atob(Ae),De=>De.charCodeAt(0)),er=await v.signTransaction(ut),zt=await Fr({signedTransaction:btoa(String.fromCharCode(...er)),orderContext:{user_public_key:S,input_mint:fr,output_mint:gr,amount:hr,price:String(Ne),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});C(zt.signature);},[S,v,on,Fr,fr,gr,hr,Ne,b,e.slug,Xt,Qt,i,gt]),Hr=useCallback(async()=>{if(!h||!c)return;let M=h.chain,Se=M!==Chain.POLYGON;Se&&await h.switchChain(Chain.POLYGON);try{let Pe=await h.getEip1193Provider();if(!Pe){toast.error(i("predict.trade.submitError")),H(!1);return}let Ae=Qe==="deposit"&&!!me,ut=!Ae&&!!Oe,er=Ae?me:Oe,zt={address:h.address,signatureType:Ae?3:ut?2:0,signTypedData:async(Wt,An,Oo,Ao)=>{let zr=[];"name"in Wt&&zr.push({name:"name",type:"string"}),"version"in Wt&&zr.push({name:"version",type:"string"}),"chainId"in Wt&&zr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Wt&&zr.push({name:"verifyingContract",type:"address"}),"salt"in Wt&&zr.push({name:"salt",type:"bytes32"});let Ec={EIP712Domain:zr,...An};return await Pe.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Wt,types:Ec,primaryType:Oo,message:Ao})]})}},De=await ve();if(!De){toast.error(i("predict.trade.submitError")),H(!1);return}let lr=b==="yes"?0:1,In="",On=e.provider_meta?.["polymarket.clobTokenIds"];On&&(In=(typeof On=="string"?JSON.parse(On):On)[lr]??"");let Ui=e.provider_meta?.["polymarket.negRisk"]??!1,Mc=N==="limit"&&!isNaN(O)?O:I,Tc=Kn(Mc,Ie),_o={tokenId:In,price:Tc,size:w,side:"SELL",orderType:N==="limit"?se?"GTD":"GTC":"FOK",tickSize:Ie,negRisk:Ui,...er&&{funderAddress:er},...tt&&{builderCode:tt},...N==="limit"&&se&&{expiration:$n(je,P,qe)}},Io;if(Ae)Io=await buildSignedV2OrderPayload({signer:zt,depositWalletAddress:er,input:_o,owner:De.apiKey});else {let Wt=buildCtfExchangeDomain(Ui),An=buildOrderMessage({..._o,signerAddress:zt.address,signatureType:zt.signatureType,feeRateBps:Ct}),Oo=await zt.signTypedData(Wt,CTF_ORDER_TYPES,"Order",An),Ao=buildSignedOrder(An,Oo,_o.orderType);Io=buildClobPayload(Ao,De.apiKey);}await m.executePolymarketOrder({payload:Io,l2_api_key:De.apiKey,l2_secret:De.secret,l2_passphrase:De.passphrase,signer_address:De.address,owner:De.apiKey}),br(),Ye(N==="limit"?"sell-limit":"sell-market",async()=>await buildPolymarketL2Headers(De.address,{apiKey:De.apiKey,secret:De.secret,passphrase:De.passphrase,method:"GET",requestPath:"/data/orders"})),Ht(),H(!1),s.current?.();}finally{Se&&M&&h.switchChain(M).catch(()=>{});}},[h,c,ve,b,e.provider_meta,N,Ye,O,I,w,m,br,se,je,P,qe,Ht,i,Ie,Ct,e.slug,Oe,Qe,me,tt]),_t=useCallback(async()=>{if(!(!Dr.isValid||!x)){H(true),C(null),de(false);try{p==="kalshi"?await Br():await Hr();}catch(M){let Se=M instanceof Error?M.message:"",Pe=p==="polymarket"&&Se?Vn(Se,i,"sell"):Se||void 0;toast.error(Pe||i("predict.trade.submitError")),H(false);}}},[Dr.isValid,x,p,Br,Hr,i]);return {outcome:b,orderType:N,quantity:w,limitPrice:O,shares:Ar,effectivePrice:Te,grossReturn:ke,estimatedFee:Rt,estimatedReturn:sn,pricePerShare:Ne,isMarketDataLoading:p==="polymarket"&&(Ot||et),isSubmitting:Q,authStatus:l,validation:Dr,supportsLimitOrder:g,kycRequired:J,needsKyc:st,needsSetup:ht,kycUrl:We,totalShares:Ir,activeOrderShares:Et,availableShares:ar,isAvailableLoading:Lo,isSellAll:Y,precision:at,expirationEnabled:se,expirationPreset:je,customDuration:P,customDurationUnit:qe,setOutcome:Jt,setOrderType:Zt,setQuantity:lt,setLimitPrice:Rn,setSellAll:Ro,setExpirationEnabled:Ve,setExpirationPreset:Ge,setCustomDuration:dt,setCustomDurationUnit:Re,submit:_t}}var fm=["5m","1h","12h","24h","eod","custom"],gm={"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"},hm=["minutes","hours","days"],vm={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},bm={maximumFractionDigits:0},fn="-";function ha({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,effectivePrice:s,grossReturn:l,estimatedFee:u,estimatedReturn:m,isMarketDataLoading:c,isSubmitting:f,authStatus:d,isValid:p,validationErrors:g,supportsLimitOrder:v,kycRequired:h,needsKyc:x,needsSetup:S,onSetupRequired:k,kycUrl:b,totalShares:y,activeOrderShares:N,availableShares:E,isAvailableLoading:w,precision:R,expirationEnabled:O,expirationPreset:U,customDuration:Q,customDurationUnit:H,oddsFormatter:Y,outcomeLabels:q,onOutcomeChange:te,onOrderTypeChange:C,onQuantityChange:T,onLimitPriceChange:B,onSellAll:J,onExpirationEnabledChange:de,onExpirationPresetChange:se,onCustomDurationChange:Ve,onCustomDurationUnitChange:je,onSubmit:Ge}){let{t:P}=useTranslation(),[dt,qe]=useState(false),[Re,Nt]=useState(true),_e=useDisclosure(),[Ye,ot]=useState(""),we=useRef(false);useEffect(()=>{we.current||ot(isNaN(i)?"":String(i));},[i]);let[et,Ie]=useState(""),it=useRef(false);useEffect(()=>{it.current||(isNaN(a)?Ie(""):Ie(String(parseFloat((a*100).toFixed(2)))));},[a]);let Ot=useCallback(_=>{if(_!==""&&!/^\d*\.?\d{0,2}$/.test(_))return;if(Ie(_),_===""||_==="."){B(NaN);return}let Ue=parseFloat(_);isNaN(Ue)||B(Ue/100);},[B]),Ct=useCallback(_=>{let Ce=new RegExp(`^\\d*\\.?\\d{0,${R}}$`);if(_!==""&&!Ce.test(_))return;if(ot(_),qe(false),_===""||_==="."){T(NaN);return}let Ue=parseFloat(_);isNaN(Ue)||T(Ue);},[T,R]);useEffect(()=>{h&&!_e.isOpen&&_e.onOpen();},[h]);let Mt=useMemo(()=>{let _=n==="yes"?t.yesBid:t.noBid;return _!=null?parseFloat((Number(_)*100).toFixed(2)):null},[n,t]),tt=n==="yes"?t.yesBid:t.noBid,gt=tt!=null&&Y?Y(Number(tt)):Mt!=null?`${Mt} \xA2`:null,We=Number.isFinite(s)?parseFloat((s*100).toFixed(2)):null,Yt=Number.isFinite(s)&&Y?Y(s):We!=null?`${We} \xA2`:null,Oe=!isNaN(i)&&i>0,Qe=Oe&&i>0?m/i:0,me=Qe>0&&Y?Y(Qe):Qe>0?`${parseFloat((Qe*100).toFixed(2))} \xA2`:fn,st=d==="authenticated",ht=d==="authenticating"||d==="deauthenticating",ve=st&&(x||S),Xe=useCallback(_=>q?.[_]??P(_==="yes"?"predict.trade.yes":"predict.trade.no"),[q,P]),Ne=useMemo(()=>{if(ht)return P("predict.trade.checkingLogin");if(!st)return P("predict.trade.loginToTrade");if(x)return P("predict.trade.kycRequired");if(S)return P("predict.trade.setupRequired");if(w)return P("predict.trade.loadingBalance");if(c)return P("predict.trade.loadingMarketData");if(f)return P("predict.trade.submitting");if(h)return P("predict.trade.kycRequired");if(!Oe)return P("predict.trade.enterAmount");let _=Xe(n);return `${P("predict.trade.sell")} ${_}`},[ht,st,x,S,w,c,f,h,Oe,n,Xe,P]),Tt=()=>{if(!st){qe(false),Ge();return}if(x){_e.onOpen();return}if(S&&k){qe(false),k();return}if(h){_e.onOpen();return}if(!p){qe(true);return}qe(false),Ge();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:_=>{r==="bordered"&&(_.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:_=>{r==="bordered"&&(_.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[P("predict.trade.sell")," ",Xe(n)]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[v?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:_=>C(_),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:P("predict.trade.market")},"market"),jsx(Tab,{title:P("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:P("predict.trade.market")}),o==="limit"&&v?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:et,onChange:_=>Ot(_.target.value),onFocus:()=>{it.current=true;},onBlur:()=>{it.current=false,isNaN(a)?Ie(""):Ie(String(parseFloat((a*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"}}):gt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:gt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(_=>{let Ce=_==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>te(_),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===_?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:Xe(_)}),Ce!=null&&jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(Ce)):`${parseFloat((Number(Ce)*100).toFixed(2))}\xA2`})]})},_)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:P("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(_=>{let Ce=Math.pow(10,R);return jsxs("button",{type:"button",onClick:()=>{T(Math.floor(E*_/100*Ce)/Ce);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[_,"%"]},_)}),jsx("button",{type:"button",onClick:J,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:P("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ye,onChange:_=>Ct(_.target.value),onFocus:()=>{we.current=true;},onBlur:()=>{we.current=false,ot(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"}}),dt&&g.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(_=>jsx("span",{className:"text-xs text-danger",children:_},_))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:w?"\u2013":`${be(y,R).toFixed(R)}${P("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:w?"\u2013":N>0?`-${be(N,R).toFixed(R)}${P("predict.trade.sharesUnit")}`:`0${P("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:w?"\u2013":`${be(E,R).toFixed(R)}${P("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${m.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:()=>Nt(_=>!_),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:P("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",Re&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Number.isFinite(s)?Yt:We!=null?P("predict.trade.chance",{percent:We}):fn})]}),Re&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?kr(i):fn})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:Oe?`$${l.toFixed(2)}`:fn})]}),(u??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${(u??0).toFixed(2)}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.estReturnAfterFees")}),jsx("span",{className:"tabular-nums text-foreground",children:Oe?`$${m.toFixed(2)}`:fn})]}),(u??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:P("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:me})]})]})]}),o==="limit"&&v&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:P("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:O,onValueChange:de,"aria-label":P("predict.trade.setExpiration")})]}),O&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":P("predict.trade.setExpiration"),selectedKeys:[U],onSelectionChange:_=>{let Ce=Array.from(_)[0];Ce&&se(Ce);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:fm.map(_=>jsx(SelectItem,{children:P(gm[_])},_))}),U==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(Q)?void 0:Q,onValueChange:Ve,minValue:1,step:1,formatOptions:bm,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[H],onSelectionChange:_=>{let Ce=Array.from(_)[0];Ce&&je(Ce);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:hm.map(_=>jsx(SelectItem,{children:P(vm[_])},_))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:ht||st&&!ve&&(w||c||!Oe||f),isLoading:ht||st&&!ve&&(f||w||c),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Tt,children:Ne})]}),jsx(Gn,{isOpen:_e.isOpen,onClose:_e.onClose,kycUrl:b})]})}function oo({event:e,market:t,variant:r,initialOutcome:n,initialPositionSide:o,chain:i,slippageBps:a,onOutcomeChange:s,onSetupRequired:l,onSuccess:u,oddsFormatter:m,outcomeLabels:c}){let{outcome:f,orderType:d,quantity:p,limitPrice:g,effectivePrice:v,grossReturn:h,estimatedFee:x,estimatedReturn:S,pricePerShare:k,isMarketDataLoading:b,isSubmitting:y,authStatus:N,validation:E,supportsLimitOrder:w,kycRequired:R,needsKyc:O,needsSetup:U,kycUrl:Q,totalShares:H,activeOrderShares:Y,availableShares:q,isAvailableLoading:te,precision:C,expirationEnabled:T,expirationPreset:B,customDuration:J,customDurationUnit:de,setOutcome:se,setOrderType:Ve,setQuantity:je,setLimitPrice:Ge,setSellAll:P,setExpirationEnabled:dt,setExpirationPreset:qe,setCustomDuration:Re,setCustomDurationUnit:Nt,submit:_e}=la({market:t,initialOutcome:n,initialPositionSide:o,slippageBps:a,onSuccess:u}),Ye=useAuthCallback(_e),ot=useCallback(Ie=>{se(Ie),s?.(Ie);},[se,s]),we=useMemo(()=>e?Fn(e):void 0,[e]),et=useMemo(()=>Bn(t,{yesBid:f==="yes"?k:void 0,noBid:f==="no"?k:void 0}),[t,f,k]);return jsx(ha,{event:we,market:et,variant:r,outcome:f,orderType:d,quantity:p,limitPrice:g,effectivePrice:v,grossReturn:h,estimatedFee:x,estimatedReturn:S,isMarketDataLoading:b,isSubmitting:y,authStatus:N,isValid:E.isValid,validationErrors:E.errors,supportsLimitOrder:w,kycRequired:R,needsKyc:O,needsSetup:U,onSetupRequired:l,kycUrl:Q,totalShares:H,activeOrderShares:Y,availableShares:q,isAvailableLoading:te,precision:C,expirationEnabled:T,expirationPreset:B,customDuration:J,customDurationUnit:de,oddsFormatter:m,outcomeLabels:c,onOutcomeChange:ot,onOrderTypeChange:Ve,onQuantityChange:je,onLimitPriceChange:Ge,onSellAll:P,onExpirationEnabledChange:dt,onExpirationPresetChange:qe,onCustomDurationChange:Re,onCustomDurationUnitChange:Nt,onSubmit:Ye})}var si="predict-sell";function ba({id:e=si}){return jsx(AsyncModal,{id:e,children:t=>jsx(Mm,{...t})})}function Mm({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(oo,{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-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var ci=40,ao=36,vn=480,di=vn-ao;function ka({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),a=useMemo(()=>e.markets?.map(c=>c.slug)??[],[e.markets]),{data:s}=usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=useMemo(()=>!s?.positions||!t?0:a.length===0?s.positions.length:s.positions.filter(c=>c.market&&a.includes(c.market.slug)).length,[s?.positions,a,t]),m=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:m.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",o===c.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:c.label},c.key))}),t?jsxs("div",{style:{height:vn},children:[o==="positions"&&jsx(Om,{source:e.source,walletAddress:t,marketSlugs:a}),o==="orders"&&jsx(Dm,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),o==="trades"&&jsx(Hm,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:vn},children:n("predict.trade.connectWallet")})]})}function Om({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=useTranslation(),{data:o,isLoading:i}=usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),a=useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[o?.positions,r]);return i?jsx(pi,{}):a.length===0?jsx(ui,{message:n("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:ao},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:di},rowComponent:Am,rowCount:a.length,rowHeight:ci,rowProps:{positions:a,closeLabel:n("predict.positions.close")}})]})}function Am({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,a=o.pnl_percent??0,s=o.avg_price??0,l=o.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",m=i>0?"+":"",c=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,d=o.size,p=o.size*l,g=o.market?.end_at?Um(o.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsx("span",{className:cn$1("text-[10px] font-medium",f.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:f})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:io(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:io(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[m,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",m,a.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:n})})]})}function Dm({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=useTranslation(),{data:i,isLoading:a,fetchNextPage:s,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),u=useCancelOrder(),m=useMemo(()=>{let h=i?.pages?.flatMap(k=>k.items)??[],x=new Set(["live","open","submitted","pending"]),S=h.filter(k=>x.has(k.status));return r.length>0&&(S=S.filter(k=>k.market_id&&r.includes(k.market_id))),S},[i?.pages,r]),c=useCallback(h=>{n?n(h.id):u.mutate({source:h.source,id:h.id});},[n,u]),f=m.length,d=f+(l?1:0),p=useCallback(h=>h<f,[f]),g=useCallback(async()=>{await s();},[s]),v=useInfiniteLoader({isRowLoaded:p,loadMoreRows:g,rowCount:d,threshold:5});return a?jsx(pi,{}):m.length===0&&!l?jsx(ui,{message:o("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:ao},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:di},onRowsRendered:v,rowComponent:Fm,rowCount:d,rowHeight:ci,rowProps:{orders:m,itemCount:f,onCancel:c,isCancelling:u.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Fm({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:a}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:s.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?io(parseFloat(s.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Bm,{status:s.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>o(s),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):a})})]})}function Bm({status:e}){return jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function Hm({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:a}=useInfiniteTrades({source:e,wallet:t,limit:50}),s=useMemo(()=>n?.pages?.flatMap(d=>d.items)??[],[n?.pages]),l=s.length,u=l+(a?1:0),m=useCallback(d=>d<l,[l]),c=useCallback(async()=>{await i();},[i]),f=useInfiniteLoader({isRowLoaded:m,loadMoreRows:c,rowCount:u,threshold:5});return o?jsx(pi,{}):s.length===0&&!a?jsx(ui,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:ao},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:di},onRowsRendered:f,rowComponent:zm,rowCount:u,rowHeight:ci,rowProps:{trades:s,itemCount:l}})]})}function zm({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",a=Wm(o.timestamp),s=o.price??0,l=o.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:o.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:o.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:io(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:a})]})}function ui({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:vn},children:e})}function pi(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:vn},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function io(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Wm(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${i}`}function Um(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var Sa=`
|
|
75
75
|
@keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
76
|
-
`,va={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function fe(e){return {...va,animationDelay:`${e}ms`}}function fn({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:ha}),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:{...va,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...fe(0),height:14,width:48}}),jsx("div",{style:{...fe(30),height:14,width:40}}),jsx("div",{style:{...fe(60),height:14,width:40}})]}),jsx("div",{style:{...fe(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...fe(100),height:16,width:192}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsx("div",{style:{...fe(120),height:16,width:96}}),jsx("div",{style:{...fe(140),height:16,width:80}})]}),jsx("div",{style:{...fe(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...fe(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...fe(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...fe(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsx("div",{style:{...fe(240),height:14,width:56}})}),Array.from({length:e}).map((r,n)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...fe(260+n*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...fe(280+n*40),height:14,width:n%2===0?192:160}}),jsx("div",{style:{...fe(300+n*40),height:10,width:64}})]}),jsx("div",{style:{...fe(320+n*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...fe(340+n*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...fe(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...fe(400),height:16,width:64}}),jsx("div",{style:{...fe(420),height:14,width:"100%"}}),jsx("div",{style:{...fe(440),height:14,width:"80%"}}),jsx("div",{style:{...fe(460),height:14,width:"60%"}})]})]})]})}function ba(){return jsxs(Fragment,{children:[jsx("style",{children:ha}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsx("div",{style:{...fe(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...fe(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...fe(120),height:40,width:"100%",borderRadius:8}})]})]})}var wa="var(--color-bullish)",Pa="var(--color-bearish)";function gn(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 Bm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Hm(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let d of e){let p=Math.round(d.price*100);p>=0&&p<=100&&(r[p]+=d.quantity);}for(let d of t){let p=Math.round(d.price*100);p>=0&&p<=100&&(n[p]+=d.quantity);}let o=0,i=0,a=new Float64Array(101),s=new Float64Array(101);for(let d=100;d>=0;d--)o+=r[d],i+=r[d]*d/100,a[d]=o,s[d]=i;let l=0,u=0,m=new Float64Array(101),c=new Float64Array(101);for(let d=0;d<=100;d++)l+=n[d],u+=n[d]*d/100,m[d]=l,c[d]=u;let f=Math.max(a[0]??0,m[100]??0);return Array.from({length:101},(d,p)=>{let g=a[p]>0,v=m[p]>0,h=a[p]||m[p],x=r[p]>0||n[p]>0;return {priceCents:p,displayHeight:Bm(h,f),opacity:h>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[p],askCumTotal:m[p],bidCumCost:s[p],askCumCost:c[p]}})}function zm({info:e}){let{t}=useTranslation(),r=e.isBid?wa:Pa,n=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:n,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:gn(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",gn(Math.round(e.cumCost))]})]})}var Wm=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,a=t.isBid?wa:t.isAsk?Pa:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:i&&jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),Um=[0,10,20,30,40,50,60,70,80,90,100];function $m(){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:Um.map(e=>jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Na({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>Hm(e,t),[e,t]),o=useMemo(()=>{let c=e.length>0?Math.max(...e.map(d=>d.price)):0,f=t.length>0?Math.min(...t.map(d=>d.price)):1;return Math.round((c+f)/2*100)},[e,t]),i=useMemo(()=>n.some(c=>c.isBid||c.isAsk),[n]),[a,s]=useState(null),l=useRef(null),u=useCallback((c,f)=>{l.current&&(l.current.style.filter=""),f?(f.style.filter="brightness(1.5)",l.current=f):l.current=null,c.isBid||c.isAsk?s({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.priceCents}):s(null);},[]),m=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),s(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),a&&jsx(zm,{info:a}),n.map(c=>jsx(Wm,{slot:c,onEnter:u,onLeave:m},c.priceCents))]}),jsx($m,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Ra(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ma(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function _a({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o,oddsFormatter:i}){let{t:a}=useTranslation(),[s,l]=useState(n),u=i??Ra,m=e.source,{data:c,isLoading:f,isFetching:d,refetch:p}=useRealtimeOrderbook({slug:e.slug,source:m,outcome:t}),g=useMemo(()=>(c?.bids??[]).map(k=>({price:k.price,quantity:k.size})),[c?.bids]),v=useMemo(()=>(c?.asks??[]).map(k=>({price:k.price,quantity:k.size})),[c?.asks]),h=useMemo(()=>g.length>0?Math.max(...g.map(k=>k.price)):null,[g]),x=useMemo(()=>v.length>0?Math.min(...v.map(k=>k.price)):null,[v]),S=useMemo(()=>{if(h==null||x==null)return null;let k=(x-h)*100;return Math.round(k*10)/10},[h,x]);return jsxs("div",{className:cn("flex flex-col",o??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:S!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(S)?`${S}\xA2`:`${S.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[h!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",u(h)]}),h!=null&&x!=null&&jsx("span",{className:"text-neutral",children:"|"}),x!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("predict.trade.bestAsk"),": ",u(x)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:s==="depth"?"Orderbook":"Depth chart",onClick:()=>l(k=>k==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:s==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>p(),disabled:d,className:cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",d&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[s==="depth"&&jsx(Fragment,{children:f?jsx(Ma,{}):jsx(Na,{bids:g,asks:v})}),s==="table"&&jsx(Fragment,{children:f?jsx(Ma,{}):jsx(Ym,{bids:g,asks:v,bestBid:h??void 0,bestAsk:x??void 0,spread:S??void 0,oddsFormatter:i})})]})]})}var ci=4,qm=8;function Ym({bids:e,asks:t,spread:r,oddsFormatter:n}){let{t:o}=useTranslation(),[i,a]=useState(false),s=i?qm:ci,l=t.length>ci||e.length>ci,u=useMemo(()=>[...t].sort((d,p)=>d.price-p.price).slice(0,s).reverse(),[t,s]),m=useMemo(()=>[...e].sort((d,p)=>p.price-d.price).slice(0,s),[e,s]),c=useMemo(()=>{let d=[...u,...m].map(p=>p.quantity);return Math.max(...d,1)},[u,m]);return u.length===0&&m.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(d=>jsx(Ta,{price:d.price,quantity:d.quantity,side:"ask",maxQty:c,oddsFormatter:n},`ask-${d.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsx("button",{type:"button",onClick:()=>a(d=>!d),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:o(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),m.map(d=>jsx(Ta,{price:d.price,quantity:d.quantity,side:"bid",maxQty:c,oddsFormatter:n},`bid-${d.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Ta({price:e,quantity:t,side:r,maxQty:n,oddsFormatter:o}){let i=r==="ask",a=Math.min(t/n*100,100),s=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=gn(Math.round(t)),m=Math.round(t*e),c=`$${gn(m)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${a}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:o?o(e):Ra(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsx("span",{className:"relative z-10 text-foreground text-right",children:c})]})}var pi=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},hn=4,Ia=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function lf(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function cf(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ce.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Aa(e){return `${(e*100).toFixed(2)}%`}var df=[{range:ce.ONE_DAY,label:"1D"},{range:ce.ONE_WEEK,label:"1W"},{range:ce.ONE_MONTH,label:"1M"},{range:ce.ALL,label:"ALL"}];function uf({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:df.map(({range:r,label:n})=>{let o=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:o?"#f9fafb":"#6b7280",fontWeight:o?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:n},r)})})}function pf(){let e=useRef(null),t=useRef(null),r=useCallback(o=>{let i=e.current,a=t.current;if(!i||!a)return;let s=i.getBoundingClientRect(),l=(o.clientX-s.left)/s.width*100;a.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,a.style.opacity="1";},[]),n=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function mf({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let a=new Map;t?.forEach(l=>a.set(l.dataKey,l));let s=o.map(l=>a.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?cf(r,i):r}),s.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Aa(l.value):"--"})]},l.dataKey))]})}function ff({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),a=useRef(null);useEffect(()=>{if(!o)return;function u(m){a.current&&!a.current.contains(m.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let s=t.length>=hn,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(m=>m.slug===t[0]);return u?.outcomes?.[0]?.label??u?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>i(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),o&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",hn," markets"]}),e.map((u,m)=>{let c=t.includes(u.slug),f=!c&&s,d=c&&t.length===1,p=r.get(u.slug)??"#6b7280",g=u.outcomes.find(h=>h.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{d||f||n(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:c?"rgba(255,255,255,0.05)":"transparent",cursor:f||d?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!f&&!d&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=c?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:c?`2px solid ${p}`:"2px solid rgba(255,255,255,0.2)",background:c?`${p}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:c&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:p,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p,flexShrink:0}}),jsx("span",{style:{color:c?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),v&&jsx("span",{style:{color:p,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${m}-${u.slug}`)})]})]})}function gf({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(n=>{let o=t.get(n.marketSlug)??"#6b7280",i=r.get(n.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:o,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:n.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Aa(i):"--"})]})]},n.marketSlug)})})}function hf(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function vf(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),a=Math.min(Math.floor((o+1)*n),e.length),s=e.slice(i,a),l=s.map(u=>u.price).sort((u,m)=>u-m);r.push({timestamp:s[s.length-1].timestamp,price:hf(l)});}return r}function bf(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:vf(s.data,t)})),n=new Set;r.forEach(s=>s.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((s,l)=>s-l),i=r.map(s=>{let l=new Map;return s.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:s.marketSlug,map:l}}),a=new Map;return o.map(s=>{let l={timestamp:s};return i.forEach(({slug:u,map:m})=>{let c=m.get(s);if(c!==void 0)a.set(u,c),l[u]=c;else {let f=a.get(u);f!==void 0&&(l[u]=f);}}),l})}function Da(e){return jsx(pi,{children:jsx(xf,{...e})})}function xf({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=useMemo(()=>{let C=new Set;return (e.markets??[]).filter(T=>C.has(T.slug)?false:(C.add(T.slug),true))},[e.markets]),a=useMemo(()=>[...i].sort((C,T)=>{let B=J=>(J.outcomes.find(ue=>ue.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return B(T)-B(C)}),[i]),[s,l]=useState(()=>a.slice(0,hn).map(C=>C.slug));useEffect(()=>{let C=new Set(i.map(T=>T.slug));l(T=>{let B=T.filter(J=>C.has(J));return B.length===T.length?T:B.length>0?B:a.slice(0,hn).map(J=>J.slug)});},[i,a]);let[u,m]=useState(Hn),c=useMemo(()=>{let C=new Map;return s.forEach((T,B)=>{C.set(T,Ia[B%Ia.length]);}),C},[s]),f=useMemo(()=>i.filter(C=>s.includes(C.slug)),[i,s]),{series:d,isLoading:p}=useMarketHistory(f,u),g=t||p,v=useMemo(()=>{if(d.length>0&&d.some(B=>B.data.length>0))return d;let C=Date.now(),T=864e5;return f.map(B=>{let ue=(B.outcomes?.find(se=>se.label.toLowerCase()==="yes")??B.outcomes?.[0])?.price??.5;return {marketSlug:B.slug,label:B.outcomes?.[0]?.label??B.question,data:[{timestamp:C-7*T,price:ue},{timestamp:C,price:ue}]}})},[d,f]),h=useMemo(()=>u===ce.ONE_DAY?96:u===ce.ONE_WEEK?168:u===ce.ONE_MONTH?180:300,[u]),x=useMemo(()=>bf(v,h),[v,h]),S=useMemo(()=>{if(x.length===0)return [0,1];let C=1/0,T=-1/0;if(s.forEach(J=>{x.forEach(ue=>{let se=ue[J];se!=null&&(se<C&&(C=se),se>T&&(T=se));});}),!isFinite(C))return [0,1];let B=Math.max((T-C)*.15,.05);return [Math.max(0,C-B),Math.min(1,T+B)]},[x,s]),k=useMemo(()=>{let C=new Map;return v.forEach(T=>{T.data.length>0&&C.set(T.marketSlug,T.data[T.data.length-1].price);}),C},[v]),b=useMemo(()=>{let C=new Map;return v.forEach(T=>C.set(T.marketSlug,T.label)),C},[v]),y=useMemo(()=>v.map(C=>({slug:C.marketSlug,color:c.get(C.marketSlug)??"#6b7280"})),[v,c]),{wrapperRef:N,overlayRef:E,onMouseMove:P,onMouseLeave:R}=pf(),D=useCallback(C=>{l(T=>T.includes(C)?T.length<=1?T:T.filter(B=>B!==C):T.length>=hn?T:[...T,C]);},[]),[U,Q]=useState(null),H=useRef(null),Y=useRef(""),q=useRef(0),te=!g&&x.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsx(gf,{series:v,colorMap:c,displayValues:U??k}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:N,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?C=>{P(C),cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{Q(H.current);});}:void 0,onMouseLeave:te?()=>{R(),cancelAnimationFrame(q.current),Y.current="",H.current=null,Q(null);}:void 0,children:g?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):x.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:E,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:x,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:C=>lf(C,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:S,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>{let T=C;if(T.active&&T.payload?.length){let B=T.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if(B!==Y.current){Y.current=B;let J=new Map;T.payload.forEach(ue=>{ue.value!=null&&J.set(ue.dataKey,ue.value);}),H.current=J;}}return jsx(mf,{...T,labelMap:b,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(C=>{let T=c.get(C.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:C.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},C.marketSlug)}),U==null&&x.length>0&&v.map(C=>{let T=x[x.length-1],B=T[C.marketSlug];if(B==null)return null;let J=c.get(C.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:T.timestamp,y:B,ifOverflow:"extendDomain",shape:ue=>{let{cx:se,cy:Ge}=ue;return se==null||Ge==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:se,cy:Ge,r:6,fill:J,opacity:.3,children:[jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsx("circle",{cx:se,cy:Ge,r:3.5,fill:J})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(n)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(uf,{value:u,onChange:m}),a.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(ff,{markets:a,selectedSlugs:s,colorMap:c,onToggle:D})})]})]})]})}function co(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ba(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Af(e){return `${parseFloat((e*100).toFixed(2))}%`}function Ha(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function uo(e){return e.outcomes?.[0]?.label??e.question}function Df(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function vn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${a}`}function za(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let m=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(m)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let i=Math.floor(o/864e5),a=Math.floor(o%864e5/36e5),s=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(a).padStart(2,"0")}h`),u.push(`${String(s).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function Wa(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}function Va({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let c=[...e.markets||[]],f=c.filter(p=>p.status==="open").sort((p,g)=>co(g)-co(p)),d=c.filter(p=>p.status!=="open").sort((p,g)=>co(g)-co(p));return [...f,...d]},[e.markets]),a=e.status==="closed"||e.status==="voided",s=za(a?void 0:e.start_at),l=za(a?void 0:e.end_at),u=Wa(e.start_at),m=Wa(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:n,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${o?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${o?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!o&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((c,f)=>jsxs(Fragment$1,{children:[f>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:c.label})]},c.slug)),jsx(zf,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${o?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(s||l||a)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?m&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:m})}):s?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:s})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),m&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:m})]})]}):null}),jsx(Da,{event:e,volume:e.volume??void 0}),jsx(Ff,{markets:i,onTradeAction:t}),jsx(Hf,{markets:i,event:e})]})}var Ua=5;function Ff({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:n}=useScreen(),[o,i]=useState(false),[a,s]=useState(null),l=useMemo(()=>{let v=new Set;return e.filter(h=>v.has(h.slug)?false:(v.add(h.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[m,c]=useState(u?`${u}:yes`:null);if(l.length===0)return null;let f=l.length>Ua,d=o?l:l.slice(0,Ua),p=v=>{s(h=>h===v?null:v);},g=(v,h,x)=>{c(`${v.slug}:${h}`),n&&s(v.slug),t?.(v,h,x);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:d.map((v,h)=>{let x=a===v.slug;return jsx(Bf,{market:v,activeYes:m===`${v.slug}:yes`,activeNo:m===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>p(v.slug),onTradeAction:g},v.id??`${h}-${v.slug}`)})})]}),f&&jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function Bf({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:a}=useTranslation(),s=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:s}),{data:m}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),c=pickBestAsk(u,"yes")??Ba(e,"yes")??0,f=pickBestAsk(m,"no")??Ba(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:o,role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:uo(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:uo(e)}),l&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Af(c)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:s?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:d=>{d.stopPropagation(),i?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:Ha(c)})}),jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:d=>{d.stopPropagation(),i?.(e,"no","buy");},children:f!=null?a("predict.market.action.no",{price:Ha(f)}):a("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),n&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(_a,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Hf({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,a]=useState(false),[s,l]=useState(0),u=e.filter(d=>d.rules&&d.rules.length>0||d.description);if(u.length===0)return null;let m=u[s]??u[0],c=m.rules&&m.rules.length>0?m.rules.join(`
|
|
76
|
+
`,Pa={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function fe(e){return {...Pa,animationDelay:`${e}ms`}}function bn({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:Sa}),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:{...Pa,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...fe(0),height:14,width:48}}),jsx("div",{style:{...fe(30),height:14,width:40}}),jsx("div",{style:{...fe(60),height:14,width:40}})]}),jsx("div",{style:{...fe(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...fe(100),height:16,width:192}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsx("div",{style:{...fe(120),height:16,width:96}}),jsx("div",{style:{...fe(140),height:16,width:80}})]}),jsx("div",{style:{...fe(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...fe(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...fe(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...fe(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsx("div",{style:{...fe(240),height:14,width:56}})}),Array.from({length:e}).map((r,n)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...fe(260+n*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...fe(280+n*40),height:14,width:n%2===0?192:160}}),jsx("div",{style:{...fe(300+n*40),height:10,width:64}})]}),jsx("div",{style:{...fe(320+n*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...fe(340+n*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...fe(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...fe(400),height:16,width:64}}),jsx("div",{style:{...fe(420),height:14,width:"100%"}}),jsx("div",{style:{...fe(440),height:14,width:"80%"}}),jsx("div",{style:{...fe(460),height:14,width:"60%"}})]})]})]})}function wa(){return jsxs(Fragment,{children:[jsx("style",{children:Sa}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsx("div",{style:{...fe(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...fe(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...fe(120),height:40,width:"100%",borderRadius:8}})]})]})}var Ea="var(--color-bullish)",La="var(--color-bearish)";function xn(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 Vm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function jm(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let d of e){let p=Math.round(d.price*100);p>=0&&p<=100&&(r[p]+=d.quantity);}for(let d of t){let p=Math.round(d.price*100);p>=0&&p<=100&&(n[p]+=d.quantity);}let o=0,i=0,a=new Float64Array(101),s=new Float64Array(101);for(let d=100;d>=0;d--)o+=r[d],i+=r[d]*d/100,a[d]=o,s[d]=i;let l=0,u=0,m=new Float64Array(101),c=new Float64Array(101);for(let d=0;d<=100;d++)l+=n[d],u+=n[d]*d/100,m[d]=l,c[d]=u;let f=Math.max(a[0]??0,m[100]??0);return Array.from({length:101},(d,p)=>{let g=a[p]>0,v=m[p]>0,h=a[p]||m[p],x=r[p]>0||n[p]>0;return {priceCents:p,displayHeight:Vm(h,f),opacity:h>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[p],askCumTotal:m[p],bidCumCost:s[p],askCumCost:c[p]}})}function Gm({info:e}){let{t}=useTranslation(),r=e.isBid?Ea:La,n=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:n,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:xn(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",xn(Math.round(e.cumCost))]})]})}var qm=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,a=t.isBid?Ea:t.isAsk?La:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:i&&jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),Ym=[0,10,20,30,40,50,60,70,80,90,100];function Qm(){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:Ym.map(e=>jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Ra({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>jm(e,t),[e,t]),o=useMemo(()=>{let c=e.length>0?Math.max(...e.map(d=>d.price)):0,f=t.length>0?Math.min(...t.map(d=>d.price)):1;return Math.round((c+f)/2*100)},[e,t]),i=useMemo(()=>n.some(c=>c.isBid||c.isAsk),[n]),[a,s]=useState(null),l=useRef(null),u=useCallback((c,f)=>{l.current&&(l.current.style.filter=""),f?(f.style.filter="brightness(1.5)",l.current=f):l.current=null,c.isBid||c.isAsk?s({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.priceCents}):s(null);},[]),m=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),s(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),a&&jsx(Gm,{info:a}),n.map(c=>jsx(qm,{slot:c,onEnter:u,onLeave:m},c.priceCents))]}),jsx(Qm,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Fa(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ia(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function Ba({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o,oddsFormatter:i}){let{t:a}=useTranslation(),[s,l]=useState(n),u=i??Fa,m=e.source,{data:c,isLoading:f,isFetching:d,refetch:p}=useRealtimeOrderbook({slug:e.slug,source:m,outcome:t}),g=useMemo(()=>(c?.bids??[]).map(k=>({price:k.price,quantity:k.size})),[c?.bids]),v=useMemo(()=>(c?.asks??[]).map(k=>({price:k.price,quantity:k.size})),[c?.asks]),h=useMemo(()=>g.length>0?Math.max(...g.map(k=>k.price)):null,[g]),x=useMemo(()=>v.length>0?Math.min(...v.map(k=>k.price)):null,[v]),S=useMemo(()=>{if(h==null||x==null)return null;let k=(x-h)*100;return Math.round(k*10)/10},[h,x]);return jsxs("div",{className:cn$1("flex flex-col",o??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:S!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(S)?`${S}\xA2`:`${S.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[h!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",u(h)]}),h!=null&&x!=null&&jsx("span",{className:"text-neutral",children:"|"}),x!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("predict.trade.bestAsk"),": ",u(x)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:s==="depth"?"Orderbook":"Depth chart",onClick:()=>l(k=>k==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:s==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>p(),disabled:d,className:cn$1("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",d&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[s==="depth"&&jsx(Fragment,{children:f?jsx(Ia,{}):jsx(Ra,{bids:g,asks:v})}),s==="table"&&jsx(Fragment,{children:f?jsx(Ia,{}):jsx(rf,{bids:g,asks:v,bestBid:h??void 0,bestAsk:x??void 0,spread:S??void 0,oddsFormatter:i})})]})]})}var fi=4,tf=8;function rf({bids:e,asks:t,spread:r,oddsFormatter:n}){let{t:o}=useTranslation(),[i,a]=useState(false),s=i?tf:fi,l=t.length>fi||e.length>fi,u=useMemo(()=>[...t].sort((d,p)=>d.price-p.price).slice(0,s).reverse(),[t,s]),m=useMemo(()=>[...e].sort((d,p)=>p.price-d.price).slice(0,s),[e,s]),c=useMemo(()=>{let d=[...u,...m].map(p=>p.quantity);return Math.max(...d,1)},[u,m]);return u.length===0&&m.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(d=>jsx(Oa,{price:d.price,quantity:d.quantity,side:"ask",maxQty:c,oddsFormatter:n},`ask-${d.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsx("button",{type:"button",onClick:()=>a(d=>!d),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:o(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),m.map(d=>jsx(Oa,{price:d.price,quantity:d.quantity,side:"bid",maxQty:c,oddsFormatter:n},`bid-${d.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Oa({price:e,quantity:t,side:r,maxQty:n,oddsFormatter:o}){let i=r==="ask",a=Math.min(t/n*100,100),s=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=xn(Math.round(t)),m=Math.round(t*e),c=`$${xn(m)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${a}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:o?o(e):Fa(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsx("span",{className:"relative z-10 text-foreground text-right",children:c})]})}var vi=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},yn=4,Ha=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function gf(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function hf(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===le.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Wa(e){return `${(e*100).toFixed(2)}%`}var vf=[{range:le.ONE_DAY,label:"1D"},{range:le.ONE_WEEK,label:"1W"},{range:le.ONE_MONTH,label:"1M"},{range:le.ALL,label:"ALL"}];function bf({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:vf.map(({range:r,label:n})=>{let o=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:o?"#f9fafb":"#6b7280",fontWeight:o?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:n},r)})})}function xf(){let e=useRef(null),t=useRef(null),r=useCallback(o=>{let i=e.current,a=t.current;if(!i||!a)return;let s=i.getBoundingClientRect(),l=(o.clientX-s.left)/s.width*100;a.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,a.style.opacity="1";},[]),n=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function yf({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let a=new Map;t?.forEach(l=>a.set(l.dataKey,l));let s=o.map(l=>a.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?hf(r,i):r}),s.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Wa(l.value):"--"})]},l.dataKey))]})}function kf({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),a=useRef(null);useEffect(()=>{if(!o)return;function u(m){a.current&&!a.current.contains(m.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let s=t.length>=yn,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(m=>m.slug===t[0]);return u?.outcomes?.[0]?.label??u?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>i(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),o&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",yn," markets"]}),e.map((u,m)=>{let c=t.includes(u.slug),f=!c&&s,d=c&&t.length===1,p=r.get(u.slug)??"#6b7280",g=u.outcomes.find(h=>h.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{d||f||n(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:c?"rgba(255,255,255,0.05)":"transparent",cursor:f||d?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!f&&!d&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=c?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:c?`2px solid ${p}`:"2px solid rgba(255,255,255,0.2)",background:c?`${p}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:c&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:p,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p,flexShrink:0}}),jsx("span",{style:{color:c?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),v&&jsx("span",{style:{color:p,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${m}-${u.slug}`)})]})]})}function Sf({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(n=>{let o=t.get(n.marketSlug)??"#6b7280",i=r.get(n.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:o,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:n.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Wa(i):"--"})]})]},n.marketSlug)})})}function Pf(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function wf(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),a=Math.min(Math.floor((o+1)*n),e.length),s=e.slice(i,a),l=s.map(u=>u.price).sort((u,m)=>u-m);r.push({timestamp:s[s.length-1].timestamp,price:Pf(l)});}return r}function Nf(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:wf(s.data,t)})),n=new Set;r.forEach(s=>s.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((s,l)=>s-l),i=r.map(s=>{let l=new Map;return s.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:s.marketSlug,map:l}}),a=new Map;return o.map(s=>{let l={timestamp:s};return i.forEach(({slug:u,map:m})=>{let c=m.get(s);if(c!==void 0)a.set(u,c),l[u]=c;else {let f=a.get(u);f!==void 0&&(l[u]=f);}}),l})}function Ua(e){return jsx(vi,{children:jsx(Cf,{...e})})}function Cf({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=useMemo(()=>{let C=new Set;return (e.markets??[]).filter(T=>C.has(T.slug)?false:(C.add(T.slug),true))},[e.markets]),a=useMemo(()=>[...i].sort((C,T)=>{let B=J=>(J.outcomes.find(de=>de.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return B(T)-B(C)}),[i]),[s,l]=useState(()=>a.slice(0,yn).map(C=>C.slug));useEffect(()=>{let C=new Set(i.map(T=>T.slug));l(T=>{let B=T.filter(J=>C.has(J));return B.length===T.length?T:B.length>0?B:a.slice(0,yn).map(J=>J.slug)});},[i,a]);let[u,m]=useState(zn),c=useMemo(()=>{let C=new Map;return s.forEach((T,B)=>{C.set(T,Ha[B%Ha.length]);}),C},[s]),f=useMemo(()=>i.filter(C=>s.includes(C.slug)),[i,s]),{series:d,isLoading:p}=useMarketHistory(f,u),g=t||p,v=useMemo(()=>{if(d.length>0&&d.some(B=>B.data.length>0))return d;let C=Date.now(),T=864e5;return f.map(B=>{let de=(B.outcomes?.find(se=>se.label.toLowerCase()==="yes")??B.outcomes?.[0])?.price??.5;return {marketSlug:B.slug,label:B.outcomes?.[0]?.label??B.question,data:[{timestamp:C-7*T,price:de},{timestamp:C,price:de}]}})},[d,f]),h=useMemo(()=>u===le.ONE_DAY?96:u===le.ONE_WEEK?168:u===le.ONE_MONTH?180:300,[u]),x=useMemo(()=>Nf(v,h),[v,h]),S=useMemo(()=>{if(x.length===0)return [0,1];let C=1/0,T=-1/0;if(s.forEach(J=>{x.forEach(de=>{let se=de[J];se!=null&&(se<C&&(C=se),se>T&&(T=se));});}),!isFinite(C))return [0,1];let B=Math.max((T-C)*.15,.05);return [Math.max(0,C-B),Math.min(1,T+B)]},[x,s]),k=useMemo(()=>{let C=new Map;return v.forEach(T=>{T.data.length>0&&C.set(T.marketSlug,T.data[T.data.length-1].price);}),C},[v]),b=useMemo(()=>{let C=new Map;return v.forEach(T=>C.set(T.marketSlug,T.label)),C},[v]),y=useMemo(()=>v.map(C=>({slug:C.marketSlug,color:c.get(C.marketSlug)??"#6b7280"})),[v,c]),{wrapperRef:N,overlayRef:E,onMouseMove:w,onMouseLeave:R}=xf(),O=useCallback(C=>{l(T=>T.includes(C)?T.length<=1?T:T.filter(B=>B!==C):T.length>=yn?T:[...T,C]);},[]),[U,Q]=useState(null),H=useRef(null),Y=useRef(""),q=useRef(0),te=!g&&x.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsx(Sf,{series:v,colorMap:c,displayValues:U??k}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:N,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?C=>{w(C),cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{Q(H.current);});}:void 0,onMouseLeave:te?()=>{R(),cancelAnimationFrame(q.current),Y.current="",H.current=null,Q(null);}:void 0,children:g?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):x.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:E,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:x,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:C=>gf(C,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:S,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>{let T=C;if(T.active&&T.payload?.length){let B=T.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if(B!==Y.current){Y.current=B;let J=new Map;T.payload.forEach(de=>{de.value!=null&&J.set(de.dataKey,de.value);}),H.current=J;}}return jsx(yf,{...T,labelMap:b,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(C=>{let T=c.get(C.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:C.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},C.marketSlug)}),U==null&&x.length>0&&v.map(C=>{let T=x[x.length-1],B=T[C.marketSlug];if(B==null)return null;let J=c.get(C.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:T.timestamp,y:B,ifOverflow:"extendDomain",shape:de=>{let{cx:se,cy:Ve}=de;return se==null||Ve==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:se,cy:Ve,r:6,fill:J,opacity:.3,children:[jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsx("circle",{cx:se,cy:Ve,r:3.5,fill:J})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(n)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(bf,{value:u,onChange:m}),a.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(kf,{markets:a,selectedSlugs:s,colorMap:c,onToggle:O})})]})]})]})}function uo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ka(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Uf(e){return `${parseFloat((e*100).toFixed(2))}%`}function Va(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function po(e){return e.outcomes?.[0]?.label??e.question}function $f(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function kn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${a}`}function ja(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let m=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(m)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let i=Math.floor(o/864e5),a=Math.floor(o%864e5/36e5),s=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(a).padStart(2,"0")}h`),u.push(`${String(s).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function Ga(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}function Xa({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let c=[...e.markets||[]],f=c.filter(p=>p.status==="open").sort((p,g)=>uo(g)-uo(p)),d=c.filter(p=>p.status!=="open").sort((p,g)=>uo(g)-uo(p));return [...f,...d]},[e.markets]),a=e.status==="closed"||e.status==="voided",s=ja(a?void 0:e.start_at),l=ja(a?void 0:e.end_at),u=Ga(e.start_at),m=Ga(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:n,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${o?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${o?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!o&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((c,f)=>jsxs(Fragment$1,{children:[f>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:c.label})]},c.slug)),jsx(Gf,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${o?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(s||l||a)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?m&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:m})}):s?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:s})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),m&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:m})]})]}):null}),jsx(Ua,{event:e,volume:e.volume??void 0}),jsx(Kf,{markets:i,onTradeAction:t}),jsx(jf,{markets:i,event:e})]})}var qa=5;function Kf({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:n}=useScreen(),[o,i]=useState(false),[a,s]=useState(null),l=useMemo(()=>{let v=new Set;return e.filter(h=>v.has(h.slug)?false:(v.add(h.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[m,c]=useState(u?`${u}:yes`:null);if(l.length===0)return null;let f=l.length>qa,d=o?l:l.slice(0,qa),p=v=>{s(h=>h===v?null:v);},g=(v,h,x)=>{c(`${v.slug}:${h}`),n&&s(v.slug),t?.(v,h,x);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:d.map((v,h)=>{let x=a===v.slug;return jsx(Vf,{market:v,activeYes:m===`${v.slug}:yes`,activeNo:m===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>p(v.slug),onTradeAction:g},v.id??`${h}-${v.slug}`)})})]}),f&&jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function Vf({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:a}=useTranslation(),s=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:s}),{data:m}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),c=pickBestAsk(u,"yes")??Ka(e,"yes")??0,f=pickBestAsk(m,"no")??Ka(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:o,role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:po(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:po(e)}),l&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Uf(c)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:s?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:d=>{d.stopPropagation(),i?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:Va(c)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:d=>{d.stopPropagation(),i?.(e,"no","buy");},children:f!=null?a("predict.market.action.no",{price:Va(f)}):a("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),n&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(Ba,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function jf({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,a]=useState(false),[s,l]=useState(0),u=e.filter(d=>d.rules&&d.rules.length>0||d.description);if(u.length===0)return null;let m=u[s]??u[0],c=m.rules&&m.rules.length>0?m.rules.join(`
|
|
77
77
|
|
|
78
|
-
`):m.description??"";if(!c)return null;let f=c.length>200&&!n?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")}),u.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:uo(m)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:d=>{l(Number(d)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((d,p)=>jsx(DropdownItem,{className:cn(p===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:uo(d)},String(p)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),c.length>200&&jsx("button",{type:"button",onClick:()=>o(d=>!d),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>a(d=>!d),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let d=m.status,p=[];return m.created_at&&p.push({label:r("predict.event.timeline.created"),value:vn(m.created_at),isActive:true}),p.push({label:r("predict.event.timeline.open"),value:vn(m.start_at),isActive:d!=="pending"}),d==="voided"?p.push({label:r("predict.event.timeline.voided"),value:vn(m.closed_at??m.end_at),isActive:true}):d==="closed"?p.push({label:r("predict.event.timeline.closed"),value:vn(m.closed_at??m.end_at),isActive:true}):p.push({label:r("predict.event.timeline.close"),value:vn(m.end_at),isActive:false}),p})().map((d,p,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"}`}),p<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${p<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-neutral lg:text-sm",children:d.value})]})]},d.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:m.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Df(m.source)})]})]})]})]})}function zf({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function ja({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx(fn,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Va,{event:n,onTradeAction:r})}var Vf={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}},jf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Kt(e){return Vf[e]??jf}function Y1({source:e,className:t}){let r=Kt(e);return jsxs("span",{className:cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var qa="rgba(39,39,42,0.6)",Zf="rgba(63,63,70,0.8)";function eg(e){return e==null?"-":formatAmountInUsd(e)}function Qa({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=useTranslation(),{data:a,isLoading:s}=useSimilarEvents({slug:e,source:t,limit:r});return s||!a||a.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(l=>jsx(tg,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function tg({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=Kt(e.source),i=useMemo(()=>eg(e.volume),[e.volume]),a=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=Zf,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=qa;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${qa}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function mo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function y2({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:a,renderActivitySection:s,onInsufficientBalance:l,onSetupRequired:u,slippageBps:m}){let{t:c}=useTranslation(),{isDesktop:f}=useScreen(),{onOpen:d}=useAsyncModal(on),{onOpen:p}=useAsyncModal(ti),{data:g,isLoading:v}=useEvent({slug:e,source:t}),h=useMemo(()=>{let E=[...g?.markets||[]],P=E.filter(D=>D.status==="open").sort((D,U)=>mo(U)-mo(D)),R=E.filter(D=>D.status!=="open").sort((D,U)=>mo(U)-mo(D));return [...P,...R]},[g?.markets]),[x,S]=useState(null),k=useCallback((E,P,R)=>{S(D=>({market:E,outcome:P,side:R,version:(D?.version??0)+1})),!f&&g&&(R==="sell"?p({params:{event:g,market:E,initialOutcome:P,chain:r,slippageBps:m,onSetupRequired:u}}):d({params:{event:g,market:E,initialOutcome:P,chain:r,slippageBps:m,onInsufficientBalance:l}}));},[f,g,r,m,d,p,l,u]),b=x?.market??h[0];if(v){let E=!!a;return f?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(fn,{showBack:E})}),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(ba,{})})})]}):jsx(fn,{showBack:E})}let y=x?`${x.market.slug}-${x.version}`:b?.slug??"default",N=x?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[a&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:a,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:c("common.back")})}),jsx(ja,{eventSlug:e,source:t,onTradeAction:k})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[b&&(N?jsx(no,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,onSetupRequired:u},y):jsx(qn,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,onInsufficientBalance:l},y)),g&&jsx(Qa,{eventSlug:e,source:g.source,onEventClick:o,onEventHover:i})]})]}),g&&jsx("div",{className:"flex w-full flex-col",children:s?s({event:g,walletAddress:n}):jsx(ga,{event:g,walletAddress:n})}),jsx(Yn,{}),jsx(pa,{}),jsx(Js,{})]})}function Ja(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function gg(e){switch(e){case ce.ONE_DAY:return {interval:"15m",limit:96};case ce.ONE_WEEK:return {interval:"1h",limit:168};case ce.ONE_MONTH:return {interval:"4h",limit:180};case ce.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var M2=e=>{let{candlestickMarketSlugs:t,chartRange:r=Hn,source:n}=e,o=usePredictClient(),i=useMemo(()=>gg(r),[r]),{data:a,isLoading:s,error:l}=useEvent({slug:e.eventSlug,source:n}),u=useMemo(()=>{if(!a?.markets)return [];let p=new Set,g=a.markets.filter(h=>p.has(h.slug)?false:(p.add(h.slug),true));return (t&&t.length>0?t.slice(0,4).map(h=>g.find(x=>x.slug===h)).filter(h=>h!==void 0):[...g].sort((h,x)=>Ja(x)-Ja(h)).slice(0,4)).map(h=>h.slug)},[t,a?.markets]),m=useQueries({queries:u.map(p=>({queryKey:candlesticksQueryKey(p,i),queryFn:()=>o.listCandlesticks(p,i),enabled:u.length>0}))}),c=m.some(p=>p.isLoading),f=useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.error;h&&p.set(g,h);}),p},[u,m]),d=useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.data;h&&p.set(g,h);}),p},[u,m]);return {event:a,isEventLoading:s,eventError:l,candlestickParams:i,candlesticks:d,isCandlesticksLoading:c,candlestickErrors:f}};function gi({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=useMemo(()=>xg(e.created_at),[e.created_at]);return jsxs("div",{className:cn("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(hg,{src:n.profile_image,name:o,className:cn("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsx("span",{className:"truncate text-sm font-medium text-foreground",children:o}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(vg,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function hg({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=useMemo(()=>bg(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn("rounded-full object-cover",r)}):jsx("span",{className:cn("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:o},"aria-hidden":true,children:n})}function vg({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 bg(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function xg(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let i=Math.floor(o/24);if(i<7)return `${i}d`;let a=Math.floor(i/7);return a<5?`${a}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Eg={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},tl={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Lg=["latest","oldest","mostLiked"],Rg=600,_g=112;function Ig({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=useTranslation(),[a,s]=useState("latest"),[l,u]=useState(false),m=Eg[a],{data:c,isLoading:f,isFetchingNextPage:d,hasNextPage:p,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:m.order,ascending:m.ascending,holders_only:l}),v=useMemo(()=>c?.pages?.flatMap(R=>R.items)??[],[c?.pages]),h=useRef(null),{height:x}=useResizeObserver({ref:h}),S=n??(x||Rg),k=useDynamicRowHeight({defaultRowHeight:_g,key:`${e}:${t}:${a}:${l}`}),b=v.length,y=b+(p?1:0),N=useCallback(R=>R<b,[b]),E=useCallback(async()=>{p&&!d&&await g();},[p,d,g]),P=useInfiniteLoader({isRowLoaded:N,loadMoreRows:E,rowCount:y,threshold:5});return jsxs("div",{className:cn("flex h-full w-full flex-col",o),children:[jsx(Ag,{sort:a,onSortChange:s,holdersOnly:l,onHoldersOnlyChange:u}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:h,children:f?jsx(Dg,{}):v.length===0?jsx(Fg,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:S},onRowsRendered:P,rowComponent:Og,rowCount:y,rowHeight:k,rowProps:{comments:v,itemCount:b,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Og({index:e,style:t,comments:r,itemCount:n,anonymousLabel:o}){if(e>=n)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(gi,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function Ag({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=useTranslation(),[i,a]=useState(false),s=useRef(null);return useEffect(()=>{if(!i)return;let l=m=>{s.current&&!s.current.contains(m.target)&&a(false);},u=m=>{m.key==="Escape"&&a(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[i]),jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxs("div",{ref:s,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>a(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(Bg,{className:"size-3.5 text-neutral"}),jsx("span",{children:o(tl[e])}),jsx(Hg,{className:cn("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:Lg.map(l=>{let u=l===e;return jsxs("button",{type:"button",onClick:()=>{t(l),a(false);},className:cn("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:o(tl[l])}),u&&jsx(rl,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>n(!r),className:cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(rl,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function Dg(){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 Fg({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function Bg({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 Hg({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 rl({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 Ug=10,$g=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function bo(){let[e,t]=useAtom($g),r=useCallback(o=>{let i=o.trim();i&&t(a=>{let s=a.filter(l=>l!==i);return [i,...s].slice(0,Ug)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function ll({histories:e,onSelect:t,onClear:r,className:n}){let{t:o}=useTranslation();return e.length===0?null:jsxs("div",{className:cn("px-4 pb-4",n),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:o("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function cl({onSelect:e,className:t}){let{histories:r,clearHistories:n}=bo();return jsx(ll,{className:cn(t),histories:r,onSelect:e,onClear:n})}function dl({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=useTranslation();return jsx("div",{className:o,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),n?.();},children:"Esc"})})})}function c0(e){return e==null?"-":formatAmountInUsd(e)}function ul({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:a}=useTranslation(),s=e.tags?.[0],l=Kt(e.source),u=useMemo(()=>c0(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:m=>{t&&n&&m.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[u," ",a("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function pl({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:a,fetchNextPage:s}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>n?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:a??false,fetchNextPage:s}}var x0=64;function hl({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:a,isLoading:s,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:m}=pl(i),c=useRef(null),{height:f}=useResizeObserver({ref:c}),d=useCallback(h=>h<a.length,[a]),p=useCallback(async()=>{u&&!l&&await m();},[u,l,m]),g=useMemo(()=>u?a.length+1:a.length,[a,u]),v=useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:g,threshold:5});return s?jsx(k0,{className:o}):a.length===0?jsx(S0,{className:o}):jsx("div",{className:cn("w-full h-full flex flex-col",o),children:jsx("div",{className:"flex-auto min-h-0",ref:c,children:jsx(List,{className:"no-scrollbar",style:{height:f},onRowsRendered:v,rowComponent:y0,rowCount:g,rowHeight:x0,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function y0({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:a}){let s=r[e];return s?jsx("div",{style:t,children:jsx(ul,{event:s,href:o?.(s),LinkComponent:i,onSelect:n,onHover:a})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function k0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function S0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function yl({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=bo(),a=useCallbackRef(e),s=useCallbackRef(i),l=useMemo(()=>debounce(f=>{o(f),a(f),f&&s(f);},500),[a,s]),u=useCallback(f=>{r(f),l(f);},[l]),m=useCallback(f=>{l.cancel(),r(f),o(f),a(f),f&&s(f);},[l,a,s]),c=useCallback(()=>m(""),[m]);return {text:t,keyword:n,setText:u,setKeyword:m,clearKeyword:c}}function kl({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:a}){let{text:s,keyword:l,setText:u,setKeyword:m,clearKeyword:c}=yl({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(dl,{value:s,onValueChange:u,onClear:c,onEscape:i}),!l&&jsx(cl,{onSelect:m}),jsx(hl,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:a})]})}var yi="predict-search";function yS({id:e=yi}){return jsx(AsyncModal,{id:e,children:t=>jsx(A0,{...t})})}function A0({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=useTranslation(),{isMobile:i}=useScreen(),a=useCallback(l=>{n(l);},[n]),s=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:o("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(kl,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:s})})]})})}function ES({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=useTranslation(),{isDesktop:o}=useScreen(),{onOpen:i,onClose:a}=useAsyncModal(yi),s=useCallbackRef(e),l=useCallbackRef(async()=>{let m=await i({params:t});m&&s(m);}),u=useCallbackRef(()=>{a();});return useEffect(()=>{let m=c=>{let f=document.activeElement,d=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");c.key==="/"&&!d&&(c.preventDefault(),l()),c.key==="Escape"&&(c.preventDefault(),u());};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m);}},[l,u]),o?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:n("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var Si=[{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"}],_l=[{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}],El={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Ll={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function $0(e,t){if(!e)return "$5K+";let r=_l.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Il({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:a}){let{t:s}=useTranslation(),[l,u]=useState(false),[m,c]=useState(false),[f,d]=useState(false),[p,g]=useState(false),v=useRef(null),h=useRef(null),x=Si.find(b=>b.value===e)??Si[0],S=useCallback(b=>{v.current&&!v.current.contains(b.target)&&u(false),h.current&&!h.current.contains(b.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)),[S]);let k=useCallback(()=>{a?.(),g(true),setTimeout(()=>g(false),700);},[a]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
78
|
+
`):m.description??"";if(!c)return null;let f=c.length>200&&!n?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")}),u.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:po(m)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:d=>{l(Number(d)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((d,p)=>jsx(DropdownItem,{className:cn$1(p===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:po(d)},String(p)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),c.length>200&&jsx("button",{type:"button",onClick:()=>o(d=>!d),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>a(d=>!d),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let d=m.status,p=[];return m.created_at&&p.push({label:r("predict.event.timeline.created"),value:kn(m.created_at),isActive:true}),p.push({label:r("predict.event.timeline.open"),value:kn(m.start_at),isActive:d!=="pending"}),d==="voided"?p.push({label:r("predict.event.timeline.voided"),value:kn(m.closed_at??m.end_at),isActive:true}):d==="closed"?p.push({label:r("predict.event.timeline.closed"),value:kn(m.closed_at??m.end_at),isActive:true}):p.push({label:r("predict.event.timeline.close"),value:kn(m.end_at),isActive:false}),p})().map((d,p,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"}`}),p<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${p<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-neutral lg:text-sm",children:d.value})]})]},d.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:m.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:$f(m.source)})]})]})]})]})}function Gf({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function Ja({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx(bn,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Xa,{event:n,onTradeAction:r})}var Jf={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}},Zf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Kt(e){return Jf[e]??Zf}function r2({source:e,className:t}){let r=Kt(e);return jsxs("span",{className:cn$1("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var el="rgba(39,39,42,0.6)",sg="rgba(63,63,70,0.8)";function ag(e){return e==null?"-":formatAmountInUsd(e)}function rl({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=useTranslation(),{data:a,isLoading:s}=useSimilarEvents({slug:e,source:t,limit:r});return s||!a||a.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(l=>jsx(lg,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function lg({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=Kt(e.source),i=useMemo(()=>ag(e.volume),[e.volume]),a=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=sg,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=el;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${el}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function fo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function M2({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:a,renderActivitySection:s,onInsufficientBalance:l,onSetupRequired:u,slippageBps:m}){let{t:c}=useTranslation(),{isDesktop:f}=useScreen(),{onOpen:d}=useAsyncModal(cn),{onOpen:p}=useAsyncModal(si),{data:g,isLoading:v}=useEvent({slug:e,source:t}),h=useMemo(()=>{let E=[...g?.markets||[]],w=E.filter(O=>O.status==="open").sort((O,U)=>fo(U)-fo(O)),R=E.filter(O=>O.status!=="open").sort((O,U)=>fo(U)-fo(O));return [...w,...R]},[g?.markets]),[x,S]=useState(null),k=useCallback((E,w,R)=>{S(O=>({market:E,outcome:w,side:R,version:(O?.version??0)+1})),!f&&g&&(R==="sell"?p({params:{event:g,market:E,initialOutcome:w,chain:r,slippageBps:m,onSetupRequired:u}}):d({params:{event:g,market:E,initialOutcome:w,chain:r,slippageBps:m,onInsufficientBalance:l}}));},[f,g,r,m,d,p,l,u]),b=x?.market??h[0];if(v){let E=!!a;return f?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(bn,{showBack:E})}),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(wa,{})})})]}):jsx(bn,{showBack:E})}let y=x?`${x.market.slug}-${x.version}`:b?.slug??"default",N=x?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[a&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:a,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:c("common.back")})}),jsx(Ja,{eventSlug:e,source:t,onTradeAction:k})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[b&&(N?jsx(oo,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,onSetupRequired:u},y):jsx(Yn,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,onInsufficientBalance:l},y)),g&&jsx(rl,{eventSlug:e,source:g.source,onEventClick:o,onEventHover:i})]})]}),g&&jsx("div",{className:"flex w-full flex-col",children:s?s({event:g,walletAddress:n}):jsx(ka,{event:g,walletAddress:n})}),jsx(Qn,{}),jsx(ba,{}),jsx(na,{})]})}function ol(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Sg(e){switch(e){case le.ONE_DAY:return {interval:"15m",limit:96};case le.ONE_WEEK:return {interval:"1h",limit:168};case le.ONE_MONTH:return {interval:"4h",limit:180};case le.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var O2=e=>{let{candlestickMarketSlugs:t,chartRange:r=zn,source:n}=e,o=usePredictClient(),i=useMemo(()=>Sg(r),[r]),{data:a,isLoading:s,error:l}=useEvent({slug:e.eventSlug,source:n}),u=useMemo(()=>{if(!a?.markets)return [];let p=new Set,g=a.markets.filter(h=>p.has(h.slug)?false:(p.add(h.slug),true));return (t&&t.length>0?t.slice(0,4).map(h=>g.find(x=>x.slug===h)).filter(h=>h!==void 0):[...g].sort((h,x)=>ol(x)-ol(h)).slice(0,4)).map(h=>h.slug)},[t,a?.markets]),m=useQueries({queries:u.map(p=>({queryKey:candlesticksQueryKey(p,i),queryFn:()=>o.listCandlesticks(p,i),enabled:u.length>0}))}),c=m.some(p=>p.isLoading),f=useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.error;h&&p.set(g,h);}),p},[u,m]),d=useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.data;h&&p.set(g,h);}),p},[u,m]);return {event:a,isEventLoading:s,eventError:l,candlestickParams:i,candlesticks:d,isCandlesticksLoading:c,candlestickErrors:f}};function yi({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=useMemo(()=>Cg(e.created_at),[e.created_at]);return jsxs("div",{className:cn$1("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(Pg,{src:n.profile_image,name:o,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:o}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(wg,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function Pg({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=useMemo(()=>Ng(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn$1("rounded-full object-cover",r)}):jsx("span",{className:cn$1("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:o},"aria-hidden":true,children:n})}function wg({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 Ng(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function Cg(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let i=Math.floor(o/24);if(i<7)return `${i}d`;let a=Math.floor(i/7);return a<5?`${a}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Dg={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},al={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Fg=["latest","oldest","mostLiked"],Bg=600,Hg=112;function zg({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=useTranslation(),[a,s]=useState("latest"),[l,u]=useState(false),m=Dg[a],{data:c,isLoading:f,isFetchingNextPage:d,hasNextPage:p,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:m.order,ascending:m.ascending,holders_only:l}),v=useMemo(()=>c?.pages?.flatMap(R=>R.items)??[],[c?.pages]),h=useRef(null),{height:x}=useResizeObserver({ref:h}),S=n??(x||Bg),k=useDynamicRowHeight({defaultRowHeight:Hg,key:`${e}:${t}:${a}:${l}`}),b=v.length,y=b+(p?1:0),N=useCallback(R=>R<b,[b]),E=useCallback(async()=>{p&&!d&&await g();},[p,d,g]),w=useInfiniteLoader({isRowLoaded:N,loadMoreRows:E,rowCount:y,threshold:5});return jsxs("div",{className:cn$1("flex h-full w-full flex-col",o),children:[jsx(Ug,{sort:a,onSortChange:s,holdersOnly:l,onHoldersOnlyChange:u}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:h,children:f?jsx($g,{}):v.length===0?jsx(Kg,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:S},onRowsRendered:w,rowComponent:Wg,rowCount:y,rowHeight:k,rowProps:{comments:v,itemCount:b,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Wg({index:e,style:t,comments:r,itemCount:n,anonymousLabel:o}){if(e>=n)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(yi,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function Ug({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=useTranslation(),[i,a]=useState(false),s=useRef(null);return useEffect(()=>{if(!i)return;let l=m=>{s.current&&!s.current.contains(m.target)&&a(false);},u=m=>{m.key==="Escape"&&a(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[i]),jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxs("div",{ref:s,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>a(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(Vg,{className:"size-3.5 text-neutral"}),jsx("span",{children:o(al[e])}),jsx(jg,{className:cn$1("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:Fg.map(l=>{let u=l===e;return jsxs("button",{type:"button",onClick:()=>{t(l),a(false);},className:cn$1("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:o(al[l])}),u&&jsx(ll,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>n(!r),className:cn$1("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn$1("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(ll,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function $g(){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 Kg({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function Vg({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 jg({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 ll({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 Yg=10,Qg=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function xo(){let[e,t]=useAtom(Qg),r=useCallback(o=>{let i=o.trim();i&&t(a=>{let s=a.filter(l=>l!==i);return [i,...s].slice(0,Yg)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function fl({histories:e,onSelect:t,onClear:r,className:n}){let{t:o}=useTranslation();return e.length===0?null:jsxs("div",{className:cn$1("px-4 pb-4",n),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:o("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn$1("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function gl({onSelect:e,className:t}){let{histories:r,clearHistories:n}=xo();return jsx(fl,{className:cn$1(t),histories:r,onSelect:e,onClear:n})}function hl({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=useTranslation();return jsx("div",{className:o,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),n?.();},children:"Esc"})})})}function h0(e){return e==null?"-":formatAmountInUsd(e)}function vl({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:a}=useTranslation(),s=e.tags?.[0],l=Kt(e.source),u=useMemo(()=>h0(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:m=>{t&&n&&m.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[u," ",a("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function bl({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:a,fetchNextPage:s}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>n?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:a??false,fetchNextPage:s}}var C0=64;function Sl({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:a,isLoading:s,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:m}=bl(i),c=useRef(null),{height:f}=useResizeObserver({ref:c}),d=useCallback(h=>h<a.length,[a]),p=useCallback(async()=>{u&&!l&&await m();},[u,l,m]),g=useMemo(()=>u?a.length+1:a.length,[a,u]),v=useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:g,threshold:5});return s?jsx(T0,{className:o}):a.length===0?jsx(E0,{className:o}):jsx("div",{className:cn$1("w-full h-full flex flex-col",o),children:jsx("div",{className:"flex-auto min-h-0",ref:c,children:jsx(List,{className:"no-scrollbar",style:{height:f},onRowsRendered:v,rowComponent:M0,rowCount:g,rowHeight:C0,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function M0({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:a}){let s=r[e];return s?jsx("div",{style:t,children:jsx(vl,{event:s,href:o?.(s),LinkComponent:i,onSelect:n,onHover:a})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function T0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function E0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Cl({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=xo(),a=useCallbackRef(e),s=useCallbackRef(i),l=useMemo(()=>debounce(f=>{o(f),a(f),f&&s(f);},500),[a,s]),u=useCallback(f=>{r(f),l(f);},[l]),m=useCallback(f=>{l.cancel(),r(f),o(f),a(f),f&&s(f);},[l,a,s]),c=useCallback(()=>m(""),[m]);return {text:t,keyword:n,setText:u,setKeyword:m,clearKeyword:c}}function Ml({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:a}){let{text:s,keyword:l,setText:u,setKeyword:m,clearKeyword:c}=Cl({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(hl,{value:s,onValueChange:u,onClear:c,onEscape:i}),!l&&jsx(gl,{onSelect:m}),jsx(Sl,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:a})]})}var Ni="predict-search";function MS({id:e=Ni}){return jsx(AsyncModal,{id:e,children:t=>jsx(U0,{...t})})}function U0({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=useTranslation(),{isMobile:i}=useScreen(),a=useCallback(l=>{n(l);},[n]),s=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:o("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(Ml,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:s})})]})})}function DS({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=useTranslation(),{isDesktop:o}=useScreen(),{onOpen:i,onClose:a}=useAsyncModal(Ni),s=useCallbackRef(e),l=useCallbackRef(async()=>{let m=await i({params:t});m&&s(m);}),u=useCallbackRef(()=>{a();});return useEffect(()=>{let m=c=>{let f=document.activeElement,d=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");c.key==="/"&&!d&&(c.preventDefault(),l()),c.key==="Escape"&&(c.preventDefault(),u());};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m);}},[l,u]),o?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn$1("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:n("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn$1("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var Mi=[{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"}],Bl=[{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}],Al={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Dl={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Q0(e,t){if(!e)return "$5K+";let r=Bl.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Hl({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:a}){let{t:s}=useTranslation(),[l,u]=useState(false),[m,c]=useState(false),[f,d]=useState(false),[p,g]=useState(false),v=useRef(null),h=useRef(null),x=Mi.find(b=>b.value===e)??Mi[0],S=useCallback(b=>{v.current&&!v.current.contains(b.target)&&u(false),h.current&&!h.current.contains(b.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)),[S]);let k=useCallback(()=>{a?.(),g(true),setTimeout(()=>g(false),700);},[a]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
79
79
|
@keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
80
80
|
.match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
|
|
81
81
|
.match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
|
|
82
|
-
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:
|
|
82
|
+
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:Al,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(b=>!b),c(false);},children:[jsx(X0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(x.labelKey)}),jsx(Fl,{open:l})]}),l&&jsx("div",{style:{...Dl,width:224,padding:4},children:Mi.map(b=>{let y=e===b.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===b.value?n(!r):t(b.value),u(false);},children:[jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsx(J0,{type:b.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:s(b.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:s(b.descKey)})]}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]}),i&&jsxs("div",{ref:h,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:Al,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(b=>!b),u(false);},children:[jsx(Z0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:Q0(o,s)}),jsx(eh,{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false)}),jsx(Fl,{open:m})]}),f&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),s("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:s("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:s("predict.matches.filter.tooltipNote")})]})]})]}),m&&jsxs("div",{style:{...Dl,right:0,width:176},children:[jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:s("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:Bl.map(b=>{let y=b.value===0?!o:o===b.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(b.value===0?void 0:b.value),c(false);},children:[jsx("span",{children:b.labelKey?s(b.labelKey):b.label}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]})]}),a&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)",b.currentTarget.style.color="#fff";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)",b.currentTarget.style.color="#a1a1aa";},onClick:k,children:jsxs("svg",{className:p?"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 X0(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function J0({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 Z0(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function eh({onMouseEnter:e,onMouseLeave:t}){return jsxs("svg",{viewBox:"0 0 24 24",className:"hidden sm:block",style:{width:12,height:12,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",onMouseEnter:e,onMouseLeave:t,children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 16v-4"}),jsx("path",{d:"M12 8h.01"})]})}function Fl({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function oh(e){return formatAmountInUsd(e)}var ih=[{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:oh,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Wl({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
83
83
|
@keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
84
84
|
@keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
85
85
|
@keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -117,21 +117,21 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
117
117
|
.matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
|
|
118
118
|
@media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
119
119
|
`}),jsxs("div",{className:"matches-hero-outer",style:{display:"flex",marginBottom:0},children:[jsxs("div",{className:"matches-hero-left",style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,animation:"matchHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"matches-hero-live",style:{display:"flex",marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"match-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"match-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.matches.liveBadge")}),jsx("span",{style:{borderRadius:4,background:"rgba(199,255,46,0.12)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c7ff2e",textTransform:"uppercase",border:"1px solid rgba(199,255,46,0.22)"},children:t("predict.matches.betaTag")})]})}),jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:46,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsx("p",{className:"matches-hero-subtitle matches-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
|
|
120
|
-
`).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:
|
|
120
|
+
`).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:ih.map((r,n)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function Ti(e){return e==null?"-":formatAmountInUsd(e)}function lh(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Vl={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},ch={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)"}},Ul={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function dh(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var uh={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},ph={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},mh={text:"#9ca3af",icon:"#9ca3af"};function fh(e){return ph[e]??mh}var gh=`
|
|
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 ch({tier:e}){let t=Hl[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(n,o)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:o<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},o))})}function dh(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function zl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:a,LinkComponent:s}){let{t:l}=useTranslation(),u=dh(e);if(!u)return null;let[m,c]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=th(f),p=Hl[d],g=m.best_price!=null&&c.best_price!=null?m.best_price<=c.best_price?m.source:c.source:null,v=m.event_title||c.event_title,h=e.signal_tag??"stale_data",x=Dl[h]??Dl.stale_data,S=r?.(e),k=jsxs(Fragment,{children:[jsx("style",{children:lh}),f!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${p.bandFrom}, ${p.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p.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:p.color},children:[f.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(ch,{tier:d})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(Fl,{leg:m,isCheaper:g===m.source,externalUrlFallback:a?.(e,m.source),internalHref:o?.(e,m),onSelect:n?()=>n(e,m):void 0,LinkComponent:s}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(Fl,{leg:c,isCheaper:g===c.source,externalUrlFallback:a?.(e,c.source),internalHref:o?.(e,c),onSelect:n?()=>n(e,c):void 0,LinkComponent:s})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),wi(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"})}),wi(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"})]}),uh(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:x.dot,flexShrink:0}}),l(x.label)]})]})]}),b={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:S||t?"pointer":void 0},y=E=>{let P=E.currentTarget,R=rh[d];P.style.borderColor=R.border,P.style.boxShadow=R.shadow,i?.(e);},N=E=>{let P=E.currentTarget;P.style.borderColor="rgba(39,39,42,0.6)",P.style.boxShadow="none";};return S&&s?jsx(s,{href:S,className:"group match-card",children:jsx("div",{style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),children:k})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),onKeyDown:E=>{t&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),t(e));},children:k})}function uh(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Fl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:a}=useTranslation(),s=Kt(e.source),l=ah(e.source),u=e.best_price,m=e.outcomes?.[0]?.label??null,c=e.external_url??r,f=nh(e.age_seconds),d=h=>{h.stopPropagation();},p=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:p?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:s.label}),f&&jsx("span",{title:e.age_seconds!=null?a("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:oh[f],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[m&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[wi(e.vol_24h_usd)," ",a("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:a("predict.matches.centsYes")})]}),c?jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":a("predict.matches.viewOn",{platform:s.label}),title:a("predict.matches.viewOn",{platform:s.label}),onClick:h=>h.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:h=>{h.currentTarget.style.color="#d4d4d8",h.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:h=>{h.currentTarget.style.color="#71717a",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 n&&i?jsx(i,{href:n,className:"match-card-leg-link",onClick:h=>{d(h),o?.();},children:jsx("div",{style:g,children:v})}):p?jsx("div",{role:"link",tabIndex:0,style:g,onClick:h=>{d(h),o?.();},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),d(h),o?.());},children:v}):jsx("div",{style:g,children:v})}var Vl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onSelect:u,onHover:m,getMarketHref:c,LinkComponent:f,onStatsChange:d},p){let{t:g}=useTranslation(),{data:v,hasNextPage:h,fetchNextPage:x,isFetchingNextPage:S,isLoading:k,isPlaceholderData:b,refetch:y}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[N,E]=useState(0),[P,R]=useState(false);P&&!b?(R(false),E(te=>te+1)):b&&!P&&R(true),useImperativeHandle(p,()=>({refetch:()=>{y();}}),[y]);let D=useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),U=v?.pages[0]?.total,Q=useMemo(()=>{let te=0,C=0,T=0;for(let B of D){let J=B.spread??0;J>te&&(te=J),J>=.03&&T++,B.combined_volume!=null&&(C+=B.combined_volume);}return {activePairs:U??D.length,maxSpread:te,highSpreadCount:T,totalVolume:C}},[D,U]);useEffect(()=>{Q.activePairs>0&&d?.(Q);},[Q,d]);let H=useRef(null),Y=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let te=H.current;if(!te)return;let C=new IntersectionObserver(T=>{T[0]?.isIntersecting&&h&&!S&&x();},{rootMargin:"200px"});return C.observe(te),()=>C.disconnect()},[h,S,x]),useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),k)return jsx(xh,{});if(D.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 q=!h&&D.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
127
|
+
`;function hh({tier:e}){let t=Vl[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(n,o)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:o<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},o))})}function vh(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function jl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:a,LinkComponent:s}){let{t:l}=useTranslation(),u=vh(e);if(!u)return null;let[m,c]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=lh(f),p=Vl[d],g=m.best_price!=null&&c.best_price!=null?m.best_price<=c.best_price?m.source:c.source:null,v=m.event_title||c.event_title,h=e.signal_tag??"stale_data",x=Ul[h]??Ul.stale_data,S=r?.(e),k=jsxs(Fragment,{children:[jsx("style",{children:gh}),f!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${p.bandFrom}, ${p.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p.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:p.color},children:[f.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(hh,{tier:d})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx($l,{leg:m,isCheaper:g===m.source,externalUrlFallback:a?.(e,m.source),internalHref:o?.(e,m),onSelect:n?()=>n(e,m):void 0,LinkComponent:s}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx($l,{leg:c,isCheaper:g===c.source,externalUrlFallback:a?.(e,c.source),internalHref:o?.(e,c),onSelect:n?()=>n(e,c):void 0,LinkComponent:s})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),Ti(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width: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"})}),Ti(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"})]}),bh(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:x.dot,flexShrink:0}}),l(x.label)]})]})]}),b={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:S||t?"pointer":void 0},y=E=>{let w=E.currentTarget,R=ch[d];w.style.borderColor=R.border,w.style.boxShadow=R.shadow,i?.(e);},N=E=>{let w=E.currentTarget;w.style.borderColor="rgba(39,39,42,0.6)",w.style.boxShadow="none";};return S&&s?jsx(s,{href:S,className:"group match-card",children:jsx("div",{style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),children:k})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),onKeyDown:E=>{t&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),t(e));},children:k})}function bh(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function $l({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:a}=useTranslation(),s=Kt(e.source),l=fh(e.source),u=e.best_price,m=e.outcomes?.[0]?.label??null,c=e.external_url??r,f=dh(e.age_seconds),d=h=>{h.stopPropagation();},p=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:p?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:s.label}),f&&jsx("span",{title:e.age_seconds!=null?a("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:uh[f],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[m&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Ti(e.vol_24h_usd)," ",a("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:a("predict.matches.centsYes")})]}),c?jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":a("predict.matches.viewOn",{platform:s.label}),title:a("predict.matches.viewOn",{platform:s.label}),onClick:h=>h.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:h=>{h.currentTarget.style.color="#d4d4d8",h.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:h=>{h.currentTarget.style.color="#71717a",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 n&&i?jsx(i,{href:n,className:"match-card-leg-link",onClick:h=>{d(h),o?.();},children:jsx("div",{style:g,children:v})}):p?jsx("div",{role:"link",tabIndex:0,style:g,onClick:h=>{d(h),o?.();},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),d(h),o?.());},children:v}):jsx("div",{style:g,children:v})}var Xl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onSelect:u,onHover:m,getMarketHref:c,LinkComponent:f,onStatsChange:d},p){let{t:g}=useTranslation(),{data:v,hasNextPage:h,fetchNextPage:x,isFetchingNextPage:S,isLoading:k,isPlaceholderData:b,refetch:y}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[N,E]=useState(0),[w,R]=useState(false);w&&!b?(R(false),E(te=>te+1)):b&&!w&&R(true),useImperativeHandle(p,()=>({refetch:()=>{y();}}),[y]);let O=useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),U=v?.pages[0]?.total,Q=useMemo(()=>{let te=0,C=0,T=0;for(let B of O){let J=B.spread??0;J>te&&(te=J),J>=.03&&T++,B.combined_volume!=null&&(C+=B.combined_volume);}return {activePairs:U??O.length,maxSpread:te,highSpreadCount:T,totalVolume:C}},[O,U]);useEffect(()=>{Q.activePairs>0&&d?.(Q);},[Q,d]);let H=useRef(null),Y=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let te=H.current;if(!te)return;let C=new IntersectionObserver(T=>{T[0]?.isIntersecting&&h&&!S&&x();},{rootMargin:"200px"});return C.observe(te),()=>C.disconnect()},[h,S,x]),useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),k)return jsx(Ch,{});if(O.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 q=!h&&O.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
128
128
|
@media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
|
|
129
129
|
@keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
130
|
-
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:v?.pages.map(te=>te.items?.map((C,T)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${T*35}ms both`},children:jsx(zl,{match:C,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onHover:m,onSelect:u,getMarketHref:c,LinkComponent:f})},`${N}-${C.match_id}-${C.source_a}-${C.market_a?.slug??T}`)))}),jsxs("div",{ref:H,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)}}"}),S&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),q&&jsx(bh,{onScrollToTop:Y})]})});function bh({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#71717a"},children:t("predict.matches.endOfList")}),jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"#a1a1aa",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 19V5"}),jsx("path",{d:"m5 12 7-7 7 7"})]}),jsx("span",{children:t("predict.matches.backToTop")})]})]})}function xh(){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(yh,{index:t},t))})]})}function yh({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(n=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},n))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var Ch={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Mh(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let o=new Date;return `${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`};t(r());let n=setInterval(()=>t(r()),1e4);return ()=>clearInterval(n)},[]),jsx("span",{children:e})}function Th({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(Mh,{})]})]})]})]})}function hw({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,bgImageSrc:l}){let{t:u}=useTranslation(),[m,c]=useState("spread"),[f,d]=useState(false),[p,g]=useState(void 0),[v,h]=useState(),x=useRef(null),S=useCallback(N=>{c(N);},[]),k=useCallback(N=>{d(N);},[]),b=useCallback(N=>{startTransition(()=>{h(N);});},[]),y=useCallback(()=>{x.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
130
|
+
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:v?.pages.map(te=>te.items?.map((C,T)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${T*35}ms both`},children:jsx(jl,{match:C,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onHover:m,onSelect:u,getMarketHref:c,LinkComponent:f})},`${N}-${C.match_id}-${C.source_a}-${C.market_a?.slug??T}`)))}),jsxs("div",{ref:H,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)}}"}),S&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),q&&jsx(Nh,{onScrollToTop:Y})]})});function Nh({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#71717a"},children:t("predict.matches.endOfList")}),jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"#a1a1aa",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 19V5"}),jsx("path",{d:"m5 12 7-7 7 7"})]}),jsx("span",{children:t("predict.matches.backToTop")})]})]})}function Ch(){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(Mh,{index:t},t))})]})}function Mh({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(n=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},n))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var Ih={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Oh(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let o=new Date;return `${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`};t(r());let n=setInterval(()=>t(r()),1e4);return ()=>clearInterval(n)},[]),jsx("span",{children:e})}function Ah({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(Oh,{})]})]})]})]})}function PP({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,bgImageSrc:l}){let{t:u}=useTranslation(),[m,c]=useState("spread"),[f,d]=useState(false),[p,g]=useState(void 0),[v,h]=useState(),x=useRef(null),S=useCallback(N=>{c(N);},[]),k=useCallback(N=>{d(N);},[]),b=useCallback(N=>{startTransition(()=>{h(N);});},[]),y=useCallback(()=>{x.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
131
131
|
@keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
|
|
132
132
|
.match-fade-in{animation:matchFadeIn .5s ease-out both}
|
|
133
133
|
.match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
|
|
134
134
|
.match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
|
|
135
|
-
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(Al,{stats:v})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(Ch[m])}),v&&v.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:v.activePairs})})]})]}),jsx(Il,{sortBy:m,onSortChange:S,sortAsc:f,onSortAscChange:k,minVolume:p,onMinVolumeChange:g,onRefresh:y})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:u("predict.matches.experimentalFeature")})," \u2014 ",u("predict.matches.disclaimer")]})]}),jsx(Vl,{ref:x,sortBy:m,sortAsc:f,minVolume:p,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,onStatsChange:b})]}),jsx(Th,{stats:v})]})}function Ni(e){return e==null?"-":formatAmountInUsd(e)}var Rh={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"}},_h={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function Ih(e){return Rh[e]??_h}function Oh(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let n of e.matched_markets){let o=n.spread??0;o>r&&(r=o,t=n);}return t}function Ah(e,t){let r=e.entries.find(s=>s.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(s=>s.source===(t?.source_b??e.entries[1]?.source)),o=s=>{if(!s?.outcomes?.[0])return {name:null,price:null};let l=s.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=o(t?.market_a),a=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:n?.event?.volume??null,event:n?.event}]}function ww({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>Oh(e),[e]),a=e.max_spread!=null?e.max_spread*100:null,[s,l]=useMemo(()=>Ah(e,i),[e,i]),u=a!=null&&a>=3;s.yesPrice!=null&&l.yesPrice!=null?s.source==="kalshi"?s.yesPrice>l.yesPrice:l.yesPrice>s.yesPrice:false;let c=s.yesPrice!=null&&l.yesPrice!=null?s.yesPrice<=l.yesPrice?s:l:null,f=c?Kt(c.source):null,d=u?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:p=>{let g=p.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:p=>{let g=p.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[a!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${u?"rgba(255,185,0,0.3)":a>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":a>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":a>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),a.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(ql,{data:s,isCheaper:c===s,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(ql,{data:l,isCheaper:c===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),c&&f&&a!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${d==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:d==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>c.event&&t?.(c.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:d==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:d==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:c.source.charAt(0).toUpperCase()+c.source.slice(1),spread:a.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:d==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),Ni(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width: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"})}),Ni(e.combined_volume_24h)," ",o("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",o("predict.matches.match")]})]})]})}function ql({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),a=Kt(e.source),s=Ih(e.source),l=e.event?n?.(e.event):void 0,u=jsxs("div",{style:{borderRadius:14,border:`1px solid ${s.border}`,background:s.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:m=>{m.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:m=>{m.currentTarget.style.borderColor=s.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:s.text,textTransform:"uppercase"},children:a.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?s.priceActiveColor:s.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[Ni(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsx(o,{href:l,className:"block",children:u}):u}function Hh(e){return formatAmountInUsd(e)}function Ew({matches:e,total:t}){let{t:r}=useTranslation(),n=useMemo(()=>{let o=0,i=0,a=new Set;for(let s of e){s.max_spread!=null&&s.max_spread>o&&(o=s.max_spread),s.combined_volume!=null&&(i+=s.combined_volume);for(let l of s.entries)a.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:a.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(ko,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(Ci,{}),jsx(ko,{label:r("predict.matches.stats.totalVolume"),value:Hh(n.totalVolume)}),jsx(Ci,{}),jsx(ko,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Ci,{}),jsx(ko,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function ko({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function Ci(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Xl(e){return `${(e*100).toFixed(1)}\xA2`}function zh(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function Iw({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=t!=null&&t>0;return jsxs("div",{className:cn("flex items-center gap-x-2",r),children:[jsx("span",{className:cn("text-sm font-semibold",zh(e)),children:Xl(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",Xl(t)]})]})}var wn=10,jh=64,tc=40,So=48;function rc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:a,isLoading:s,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:m}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:f,fetchNextPage:d,hasNextPage:p,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=s||f,h=m||g,x=u||p,S=useMemo(()=>{let U=[];return a?.pages&&U.push(...a.pages.flatMap(Q=>Q.items)),c?.pages&&U.push(...c.pages.flatMap(Q=>Q.items)),U.sort((Q,H)=>(H.timestamp??0)-(Q.timestamp??0)),U},[a,c]),k=Math.max(1,Math.ceil(S.length/wn)+(x?1:0)),b=(o-1)*wn,y=S.slice(b,b+wn),N=useCallback(()=>{i(U=>Math.max(1,U-1));},[]),E=useCallback(async()=>{o*wn>=S.length&&x&&(u&&await l(),p&&await d()),i(Q=>Q+1);},[o,S.length,x,u,p,l,d]),P=o>1,R=o*wn<S.length||x;if(v)return jsx(Jh,{height:r});if(S.length===0&&!x)return jsx(Xh,{message:n("predict.profile.noHistory"),height:r});let D=r-tc-So;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:tc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:D},children:[y.map((U,Q)=>jsx(Gh,{trade:U},U.id??`${b+Q}`)),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:So},children:[jsxs("button",{type:"button",disabled:!P,onClick:N,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",P?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(k,5)},(U,Q)=>{let H=Q+1;return jsx("button",{type:"button",onClick:()=>i(H),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",H===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:H},H)}),jsxs("button",{type:"button",disabled:!R,onClick:E,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-So},children:y.map((U,Q)=>jsx(qh,{trade:U},U.id??`m-${b+Q}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:So},children:[jsx("button",{type:"button",disabled:!P,onClick:N,className:cn("text-sm cursor-pointer",P?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:o}),jsx("button",{type:"button",disabled:!R,onClick:E,className:cn("text-sm cursor-pointer",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Gh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=r||n,l=s?"+":"-",u=s?"text-success":"text-foreground",m=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.outcome??"",d=ac(e.timestamp),p=oc(e),g=Yh(e),v=Qh(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:jh},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:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[f&&jsx("span",{className:"mr-1",children:f}),jsx("span",{children:d})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:a}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:sc(o)}),jsx("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",u),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:p&&jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(ic,{})})})]})}function qh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=e.event?.title??e.market?.question??"\u2014",l=ac(e.timestamp),u=oc(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:s})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn("font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:a})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:sc(o)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),u&&jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(ic,{})})]})]})}function nc(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 oc(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Yh(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function Qh(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function ic(){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 Xh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Jh({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 sc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ac(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}var Pn=10,iv=64,cc=40,wo=48;function uc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,a]=useState(1),{data:s,isLoading:l,fetchNextPage:u,hasNextPage:m,isFetchingNextPage:c}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:d,fetchNextPage:p,hasNextPage:g,isFetchingNextPage:v}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||d,x=c||v,S=m||g,k=useMemo(()=>{let H=[],Y=new Set(["live","open","submitted","pending"]);return s?.pages&&H.push(...s.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),f?.pages&&H.push(...f.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),H},[s,f]),b=useCallback(H=>{o.mutate({source:H.source,id:H.id});},[o]),y=Math.max(1,Math.ceil(k.length/Pn)+(S?1:0)),N=(i-1)*Pn,E=k.slice(N,N+Pn),P=useCallback(()=>{a(H=>Math.max(1,H-1));},[]),R=useCallback(async()=>{i*Pn>=k.length&&S&&(m&&await u(),g&&await p()),a(Y=>Y+1);},[i,k.length,S,m,g,u,p]),D=i>1,U=i*Pn<k.length||S;if(h)return jsx(cv,{height:r});if(k.length===0&&!S)return jsx(lv,{message:n("predict.profile.noOrders"),height:r});let Q=r-cc-wo;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:cc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:Q},children:[E.map(H=>jsx(sv,{order:H,onCancel:b},H.id)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(dc,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:D,canGoNext:U,onPrev:P,onNext:R,onPage:a,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-wo},children:E.map(H=>jsx(av,{order:H,onCancel:b},H.id))}),jsx(dc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:D,canGoNext:U,onPrev:P,onNext:R,onPage:a,t:n,compact:true})]})}function sv({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):o*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:iv},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",n?"text-success":"text-danger"),children:r(n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o>0?pc(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function av({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn("text-xs font-medium px-1.5 py-0.5 rounded",n?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:o>0?pc(o):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function dc({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:a,onPage:s,t:l,compact:u}){return u?jsxs("div",{className:cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:wo},children:[jsx("button",{type:"button",disabled:!n,onClick:i,className:cn("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!o,onClick:a,className:cn("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:wo},children:[jsxs("button",{type:"button",disabled:!n,onClick:i,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(m,c)=>{let f=c+1;return jsx("button",{type:"button",onClick:()=>s(f),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",f===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:f},f)}),jsxs("button",{type:"button",disabled:!o,onClick:a,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function lv({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function cv({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 pc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Ri=10,mv=64,mc=40,Po=48;function fc({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=useTranslation(),[a,s]=useState(1),l=useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsx(vv,{height:r});if(e.length===0)return jsx(hv,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/Ri)),m=(a-1)*Ri,c=e.slice(m,m+Ri),f=a>1,d=a<u,p=r-mc-Po;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:mc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:n&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:p},children:c.map((g,v)=>jsx(fv,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??m+v}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Po},children:[jsxs("button",{type:"button",disabled:!f,onClick:()=>s(g=>Math.max(1,g-1)),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,v)=>{let h=v+1;return jsx("button",{type:"button",onClick:()=>s(h),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",h===a?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:h},h)}),jsxs("button",{type:"button",disabled:!d,onClick:()=>s(g=>g+1),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Po},children:c.map((g,v)=>jsx(gv,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${m+v}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Po},children:[jsx("button",{type:"button",disabled:!f,onClick:()=>s(g=>Math.max(1,g-1)),className:cn("text-sm cursor-pointer",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:a}),jsx("button",{type:"button",disabled:!d,onClick:()=>s(g=>g+1),className:cn("text-sm cursor-pointer",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function fv({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.avg_price??0,s=e.current_price??0,l=e.current_value??e.size*s,u=e.size,m=o>0?"text-success":o<0?"text-danger":"text-foreground",c=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,p=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?bv(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:mv},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:f}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn("font-medium",p.toLowerCase()==="yes"?"text-success":"text-danger"),children:p}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count:yr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*a).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:_i(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:_i(s)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",m),children:[jsxs("span",{children:[c,"$",Math.abs(o).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:["$",u.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:v}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),n("predict.profile.close")]})})]})}function gv({position:e,onClose:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.current_price??0,s=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsx("span",{className:cn("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(No,{label:n("predict.profile.totalSize"),value:yr(e.size)}),jsx(No,{label:n("predict.profile.markPrice"),value:_i(a)}),jsx(No,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:s}),jsx(No,{label:n("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:n("predict.profile.close")})})]})}function No({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn("font-mono text-foreground",r),children:t})]})}function hv({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function vv({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 _i(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function bv(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}catch{return "\u2014"}}function hc({positions:e,trades:t,isLoading:r}){let{t:n}=useTranslation(),o=useMemo(()=>{let s=0,l=0;for(let d of e)s+=d.realized_pnl??0,l+=d.current_value??d.size*(d.current_price??0);let u=0,m=0,c=0;for(let d of t)u+=d.usd_size??0,d.type==="REDEEM"&&(c++,(d.usd_size??0)>0&&m++);let f=c>0?`${m} / ${c}`:"0 / 0";return {realizedPnl:s,positionsValue:l,volume:u,winRateStr:f}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",a=o.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:n("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn("text-5xl font-bold tabular-nums",i),children:[a,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Oi,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(Oi,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Oi,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function Oi({label:e,value:t,isLoading:r}){return jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsx("span",{className:"text-sm text-neutral whitespace-nowrap",children:e}),r?jsx(Skeleton,{className:"h-6 w-14 rounded-md"}):jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var Ai=600;function Cv({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=useTranslation(),[i,a]=useState("positions"),s=!!(e||t),{data:l,isLoading:u}=usePositions({source:"kalshi",user:e??""}),{data:m,isLoading:c}=usePositions({source:"polymarket",user:t??""}),f=useMemo(()=>{let N=[];return l?.positions&&N.push(...l.positions),m?.positions&&N.push(...m.positions),N},[l,m]),d=u||c,{data:p,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:h}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),x=useMemo(()=>[...p?.pages?.flatMap(E=>E.items)??[],...v?.pages?.flatMap(E=>E.items)??[]],[p,v]),S=d||g||h,k=f.length,y=[{key:"positions",label:k>0?`${o("predict.profile.positionsTab")} (${k})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return s?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(hc,{positions:f,trades:x,isLoading:S}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(N=>jsx("button",{type:"button",onClick:()=>a(N.key),className:cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===N.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:N.label},N.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(fc,{positions:f,isLoading:d,listHeight:Ai,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(uc,{solanaAddress:e,evmAddress:t,listHeight:Ai}),i==="history"&&jsx(rc,{solanaAddress:e,evmAddress:t,listHeight:Ai})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function LP({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[a,s]=useState(false),[l,u]=useState(null),[m,c]=useState(false),f=r||m,d=n||m,p=f?"done":a?"running":"pending",g=d?"done":f&&a?"running":"pending",v=f&&d,h=useCallback(async()=>{u(null),c(false),s(true);try{await o(),c(!0);}catch(b){u(b instanceof Error?b.message:String(b));}finally{s(false);}},[o]),x=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:p},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],S=()=>{v?t():h();},k=i(v?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:b=>{b||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:x.map((b,y)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Rv,{index:y+1,status:b.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:b.label}),jsx("span",{className:`text-[11px] leading-none ${b.status==="done"?"text-[#c7ff2e]":b.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:b.status==="done"?i("predict.setup.stepComplete"):b.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:b.desc})]})]},b.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:S,disabled:a,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a?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")]}):k}),!v&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function Rv({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
136
|
-
export{
|
|
135
|
+
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(Wl,{stats:v})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(Ih[m])}),v&&v.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:v.activePairs})})]})]}),jsx(Hl,{sortBy:m,onSortChange:S,sortAsc:f,onSortAscChange:k,minVolume:p,onMinVolumeChange:g,onRefresh:y})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:u("predict.matches.experimentalFeature")})," \u2014 ",u("predict.matches.disclaimer")]})]}),jsx(Xl,{ref:x,sortBy:m,sortAsc:f,minVolume:p,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,onStatsChange:b})]}),jsx(Ah,{stats:v})]})}function Li(e){return e==null?"-":formatAmountInUsd(e)}var Bh={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"}},Hh={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function zh(e){return Bh[e]??Hh}function Wh(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let n of e.matched_markets){let o=n.spread??0;o>r&&(r=o,t=n);}return t}function Uh(e,t){let r=e.entries.find(s=>s.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(s=>s.source===(t?.source_b??e.entries[1]?.source)),o=s=>{if(!s?.outcomes?.[0])return {name:null,price:null};let l=s.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=o(t?.market_a),a=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:n?.event?.volume??null,event:n?.event}]}function LP({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>Wh(e),[e]),a=e.max_spread!=null?e.max_spread*100:null,[s,l]=useMemo(()=>Uh(e,i),[e,i]),u=a!=null&&a>=3;s.yesPrice!=null&&l.yesPrice!=null?s.source==="kalshi"?s.yesPrice>l.yesPrice:l.yesPrice>s.yesPrice:false;let c=s.yesPrice!=null&&l.yesPrice!=null?s.yesPrice<=l.yesPrice?s:l:null,f=c?Kt(c.source):null,d=u?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:p=>{let g=p.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:p=>{let g=p.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[a!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${u?"rgba(255,185,0,0.3)":a>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":a>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":a>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),a.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(ec,{data:s,isCheaper:c===s,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(ec,{data:l,isCheaper:c===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),c&&f&&a!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${d==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:d==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>c.event&&t?.(c.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:d==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:d==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:c.source.charAt(0).toUpperCase()+c.source.slice(1),spread:a.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:d==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),Li(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"})}),Li(e.combined_volume_24h)," ",o("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",o("predict.matches.match")]})]})]})}function ec({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),a=Kt(e.source),s=zh(e.source),l=e.event?n?.(e.event):void 0,u=jsxs("div",{style:{borderRadius:14,border:`1px solid ${s.border}`,background:s.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:m=>{m.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:m=>{m.currentTarget.style.borderColor=s.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:s.text,textTransform:"uppercase"},children:a.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?s.priceActiveColor:s.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[Li(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsx(o,{href:l,className:"block",children:u}):u}function jh(e){return formatAmountInUsd(e)}function DP({matches:e,total:t}){let{t:r}=useTranslation(),n=useMemo(()=>{let o=0,i=0,a=new Set;for(let s of e){s.max_spread!=null&&s.max_spread>o&&(o=s.max_spread),s.combined_volume!=null&&(i+=s.combined_volume);for(let l of s.entries)a.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:a.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(So,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(Ri,{}),jsx(So,{label:r("predict.matches.stats.totalVolume"),value:jh(n.totalVolume)}),jsx(Ri,{}),jsx(So,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Ri,{}),jsx(So,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function So({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function Ri(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function nc(e){return `${(e*100).toFixed(1)}\xA2`}function Gh(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function zP({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=t!=null&&t>0;return jsxs("div",{className:cn$1("flex items-center gap-x-2",r),children:[jsx("span",{className:cn$1("text-sm font-semibold",Gh(e)),children:nc(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",nc(t)]})]})}var Mn=10,Zh=64,ac=40,Po=48;function lc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:a,isLoading:s,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:m}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:f,fetchNextPage:d,hasNextPage:p,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=s||f,h=m||g,x=u||p,S=useMemo(()=>{let U=[];return a?.pages&&U.push(...a.pages.flatMap(Q=>Q.items)),c?.pages&&U.push(...c.pages.flatMap(Q=>Q.items)),U.sort((Q,H)=>(H.timestamp??0)-(Q.timestamp??0)),U},[a,c]),k=Math.max(1,Math.ceil(S.length/Mn)+(x?1:0)),b=(o-1)*Mn,y=S.slice(b,b+Mn),N=useCallback(()=>{i(U=>Math.max(1,U-1));},[]),E=useCallback(async()=>{o*Mn>=S.length&&x&&(u&&await l(),p&&await d()),i(Q=>Q+1);},[o,S.length,x,u,p,l,d]),w=o>1,R=o*Mn<S.length||x;if(v)return jsx(iv,{height:r});if(S.length===0&&!x)return jsx(ov,{message:n("predict.profile.noHistory"),height:r});let O=r-ac-Po;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:ac},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:O},children:[y.map((U,Q)=>jsx(ev,{trade:U},U.id??`${b+Q}`)),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:Po},children:[jsxs("button",{type:"button",disabled:!w,onClick:N,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",w?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(k,5)},(U,Q)=>{let H=Q+1;return jsx("button",{type:"button",onClick:()=>i(H),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",H===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:H},H)}),jsxs("button",{type:"button",disabled:!R,onClick:E,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Po},children:y.map((U,Q)=>jsx(tv,{trade:U},U.id??`m-${b+Q}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Po},children:[jsx("button",{type:"button",disabled:!w,onClick:N,className:cn$1("text-sm cursor-pointer",w?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:o}),jsx("button",{type:"button",disabled:!R,onClick:E,className:cn$1("text-sm cursor-pointer",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function ev({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=cc(e.type,t),s=r||n,l=s?"+":"-",u=s?"text-success":"text-foreground",m=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.outcome??"",d=mc(e.timestamp),p=dc(e),g=rv(e),v=nv(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Zh},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:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[f&&jsx("span",{className:"mr-1",children:f}),jsx("span",{children:d})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:a}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:pc(o)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",u),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:p&&jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(uc,{})})})]})}function tv({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=cc(e.type,t),s=e.event?.title??e.market?.question??"\u2014",l=mc(e.timestamp),u=dc(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:s})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn$1("font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:a})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:pc(o)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),u&&jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(uc,{})})]})]})}function cc(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 dc(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function rv(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function nv(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function uc(){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 ov({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function iv({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 pc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function mc(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}var Tn=10,pv=64,gc=40,wo=48;function vc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,a]=useState(1),{data:s,isLoading:l,fetchNextPage:u,hasNextPage:m,isFetchingNextPage:c}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:d,fetchNextPage:p,hasNextPage:g,isFetchingNextPage:v}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||d,x=c||v,S=m||g,k=useMemo(()=>{let H=[],Y=new Set(["live","open","submitted","pending"]);return s?.pages&&H.push(...s.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),f?.pages&&H.push(...f.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),H},[s,f]),b=useCallback(H=>{o.mutate({source:H.source,id:H.id});},[o]),y=Math.max(1,Math.ceil(k.length/Tn)+(S?1:0)),N=(i-1)*Tn,E=k.slice(N,N+Tn),w=useCallback(()=>{a(H=>Math.max(1,H-1));},[]),R=useCallback(async()=>{i*Tn>=k.length&&S&&(m&&await u(),g&&await p()),a(Y=>Y+1);},[i,k.length,S,m,g,u,p]),O=i>1,U=i*Tn<k.length||S;if(h)return jsx(hv,{height:r});if(k.length===0&&!S)return jsx(gv,{message:n("predict.profile.noOrders"),height:r});let Q=r-gc-wo;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:gc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:Q},children:[E.map(H=>jsx(mv,{order:H,onCancel:b},H.id)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(hc,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:O,canGoNext:U,onPrev:w,onNext:R,onPage:a,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-wo},children:E.map(H=>jsx(fv,{order:H,onCancel:b},H.id))}),jsx(hc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:O,canGoNext:U,onPrev:w,onNext:R,onPage:a,t:n,compact:true})]})}function mv({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):o*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:pv},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",n?"text-success":"text-danger"),children:r(n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o>0?bc(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function fv({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn$1("text-xs font-medium px-1.5 py-0.5 rounded",n?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:o>0?bc(o):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function hc({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:a,onPage:s,t:l,compact:u}){return u?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:wo},children:[jsx("button",{type:"button",disabled:!n,onClick:i,className:cn$1("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!o,onClick:a,className:cn$1("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:wo},children:[jsxs("button",{type:"button",disabled:!n,onClick:i,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(m,c)=>{let f=c+1;return jsx("button",{type:"button",onClick:()=>s(f),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",f===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:f},f)}),jsxs("button",{type:"button",disabled:!o,onClick:a,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function gv({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function hv({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 bc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Di=10,yv=64,xc=40,No=48;function yc({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=useTranslation(),[a,s]=useState(1),l=useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsx(wv,{height:r});if(e.length===0)return jsx(Pv,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/Di)),m=(a-1)*Di,c=e.slice(m,m+Di),f=a>1,d=a<u,p=r-xc-No;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:xc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:n&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:p},children:c.map((g,v)=>jsx(kv,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??m+v}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:No},children:[jsxs("button",{type:"button",disabled:!f,onClick:()=>s(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,v)=>{let h=v+1;return jsx("button",{type:"button",onClick:()=>s(h),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",h===a?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:h},h)}),jsxs("button",{type:"button",disabled:!d,onClick:()=>s(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-No},children:c.map((g,v)=>jsx(Sv,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${m+v}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:No},children:[jsx("button",{type:"button",disabled:!f,onClick:()=>s(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:a}),jsx("button",{type:"button",disabled:!d,onClick:()=>s(g=>g+1),className:cn$1("text-sm cursor-pointer",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function kv({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.avg_price??0,s=e.current_price??0,l=e.current_value??e.size*s,u=e.size,m=o>0?"text-success":o<0?"text-danger":"text-foreground",c=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,p=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?Nv(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:yv},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:f}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",p.toLowerCase()==="yes"?"text-success":"text-danger"),children:p}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count:kr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*a).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Fi(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Fi(s)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",m),children:[jsxs("span",{children:[c,"$",Math.abs(o).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:["$",u.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:v}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),n("predict.profile.close")]})})]})}function Sv({position:e,onClose:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.current_price??0,s=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsx("span",{className:cn$1("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(Co,{label:n("predict.profile.totalSize"),value:kr(e.size)}),jsx(Co,{label:n("predict.profile.markPrice"),value:Fi(a)}),jsx(Co,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:s}),jsx(Co,{label:n("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:n("predict.profile.close")})})]})}function Co({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn$1("font-mono text-foreground",r),children:t})]})}function Pv({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function wv({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Fi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Nv(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}catch{return "\u2014"}}function Sc({positions:e,trades:t,isLoading:r}){let{t:n}=useTranslation(),o=useMemo(()=>{let s=0,l=0;for(let d of e)s+=d.realized_pnl??0,l+=d.current_value??d.size*(d.current_price??0);let u=0,m=0,c=0;for(let d of t)u+=d.usd_size??0,d.type==="REDEEM"&&(c++,(d.usd_size??0)>0&&m++);let f=c>0?`${m} / ${c}`:"0 / 0";return {realizedPnl:s,positionsValue:l,volume:u,winRateStr:f}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",a=o.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:n("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",i),children:[a,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Hi,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(Hi,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Hi,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function Hi({label:e,value:t,isLoading:r}){return jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsx("span",{className:"text-sm text-neutral whitespace-nowrap",children:e}),r?jsx(Skeleton,{className:"h-6 w-14 rounded-md"}):jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var zi=600;function Iv({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=useTranslation(),[i,a]=useState("positions"),s=!!(e||t),{data:l,isLoading:u}=usePositions({source:"kalshi",user:e??""}),{data:m,isLoading:c}=usePositions({source:"polymarket",user:t??""}),f=useMemo(()=>{let N=[];return l?.positions&&N.push(...l.positions),m?.positions&&N.push(...m.positions),N},[l,m]),d=u||c,{data:p,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:h}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),x=useMemo(()=>[...p?.pages?.flatMap(E=>E.items)??[],...v?.pages?.flatMap(E=>E.items)??[]],[p,v]),S=d||g||h,k=f.length,y=[{key:"positions",label:k>0?`${o("predict.profile.positionsTab")} (${k})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return s?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(Sc,{positions:f,trades:x,isLoading:S}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(N=>jsx("button",{type:"button",onClick:()=>a(N.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===N.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:N.label},N.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(yc,{positions:f,isLoading:d,listHeight:zi,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(vc,{solanaAddress:e,evmAddress:t,listHeight:zi}),i==="history"&&jsx(lc,{solanaAddress:e,evmAddress:t,listHeight:zi})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function Fw({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[a,s]=useState(false),[l,u]=useState(null),[m,c]=useState(false),f=r||m,d=n||m,p=f?"done":a?"running":"pending",g=d?"done":f&&a?"running":"pending",v=f&&d,h=useCallback(async()=>{u(null),c(false),s(true);try{await o(),c(!0);}catch(b){u(b instanceof Error?b.message:String(b));}finally{s(false);}},[o]),x=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:p},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],S=()=>{v?t():h();},k=i(v?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:b=>{b||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:x.map((b,y)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Bv,{index:y+1,status:b.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:b.label}),jsx("span",{className:`text-[11px] leading-none ${b.status==="done"?"text-[#c7ff2e]":b.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:b.status==="done"?i("predict.setup.stepComplete"):b.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:b.desc})]})]},b.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:S,disabled:a,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a?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")]}):k}),!v&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function Bv({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
136
|
+
export{rb as CHART_RANGE_DURATION,eb as CHART_RANGE_PERIOD,tb as CHART_RANGE_SAMPLE_INTERVAL,Hn as CandlestickPeriod,Kv as CategoriesSkeleton,ji as CategoriesUI,Qi as CategoriesWidget,le as ChartRange,yi as CommentItemUI,zn as DEFAULT_CHART_RANGE,dn as DEFAULT_FILTER_STATE,an as DEFAULT_PAGE_SIZE,sb as DEFAULT_PRICE_HISTORY_INTERVAL,zg as EventCommentsWidget,M2 as EventDetailPage,bn as EventDetailSkeleton,Xa as EventDetailUI,Ja as EventDetailWidget,zs as EventItem,Ra as EventMarketDepthChartUI,Ba as EventMarketDetailWidget,Ua as EventPriceChart,bs as EventsFilterUI,ty as EventsHero,Qx as EventsPage,Sx as EventsPageSkeleton,Go as EventsSkeleton,ws as EventsToolbarUI,Vs as EventsUI,Gs as EventsWidget,Gn as KycModal,Bo as MAX_PRICE_HISTORY_MARKETS,LP as MatchGroupCard,jl as MatchMarketCard,Hl as MatchesFilterBar,Wl as MatchesHero,PP as MatchesPage,DP as MatchesStatsBar,Xl as MatchesWidget,ib as ORDER_MAX_PRICE,ob as ORDER_MIN_PRICE,Wn as ORDER_MIN_QUANTITY,Un as ORDER_MIN_USDC,nb as ORDER_PRICE_STEP,Qc as POLYMARKET_BUILDER_TAKER_FEE_BPS,Xc as POLYMARKET_SPORTS_TAKER_FEE_BPS,Tp as PREDICT_REDEEM_MODAL_ID,Ni as PREDICT_SEARCH_MODAL_ID,si as PREDICT_SELL_MODAL_ID,cn as PREDICT_TRADE_MODAL_ID,ab as PRICE_HISTORY_SAMPLE_INTERVAL,na as PredictRedeemModal,MS as PredictSearchModal,ba as PredictSellModal,Qn as PredictTradeModal,jc as PredictWalletProvider,Wr as PriceHistoryInterval,Iv as ProfilePage,ta as RedeemFormWidget,Ps as SORT_PRESETS,Do as STATIC_CATEGORIES,DS as SearchEventsButton,fl as SearchHistoryUI,gl as SearchHistoryWidget,hl as SearchInputUI,vl as SearchResultItemUI,Sl as SearchResultListWidget,Ml as SearchWidget,ha as SellFormUI,oo as SellFormWidget,Fw as SetupModal,lg as SimilarEventCard,rl as SimilarEventsSection,r2 as SourceBadge,zP as SpreadIndicator,wa as TradeFormSkeleton,hs as TradeFormUI,Yn as TradeFormWidget,ka as UserActivitySection,ts as computeMaxBuyAmount,jo as countActiveFilters,$r as createTradeResultToast,rs as estimatePolymarketBuyFee,ns as estimatePolymarketSellFee,os as fireCelebration,be as floorToDecimals,xn as formatKMB,kr as formatShares,Kt as getSourceMeta,Vn as parsePolymarketError,Yc as polymarketFeeFactor,$n as resolveExpiration,es as resolvePolymarketDisplayFeeRateBps,Kn as roundToTickSize,O2 as useEventDetail,Ms as useEventsInfinite,xo as usePredictSearchHistory,yr as usePredictWallet,bl as useSearchResultListScript,Cl as useSearchScript,la as useSellForm,ls as useTradeForm};//# sourceMappingURL=index.mjs.map
|
|
137
137
|
//# sourceMappingURL=index.mjs.map
|