@liberfi.io/ui-predict 0.1.139 → 0.1.140
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 +8 -2
- package/dist/index.d.ts +8 -2
- 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,4 +1,4 @@
|
|
|
1
|
-
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,EmptyIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useSwitchChain,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {ChartRange,useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useAvailableShares,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,debounce}from'@liberfi.io/utils';import jn from'canvas-confetti';import {List}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.139");var dl="0.1.139";var pl={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},jo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Un=(()=>{let e=t=>{let r=jo.indexOf(t);return r===-1?jo.length:r};return Object.entries(pl).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 qo({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:l="Trending",className:a}){let{t:c}=useTranslation(),u=useCallback(()=>{o(null);},[o]),d=c("predict.categories.trending");return jsxs("div",{className:cn$1("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",a),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(Yo,{label:d,isSelected:t===null,onPress:u,showPulse:d===l}),jsx(gl,{}),e.map(m=>jsx(Yo,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===l},m.category))]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&n.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(Go,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsx(Go,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function Yo({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 gl(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Go({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 n0({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 hl(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function vl(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Jo({onSelect:e,trailing:t,className:r}){let[n,o]=useState(null),[i,s]=useState(null),l=useCallback(m=>{o(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),a=useCallback(m=>{s(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=hl(Un),u=Un.find(m=>m.slug===n),d=vl(u);return jsx(qo,{categories:c,selectedCategory:n,selectedTag:i,activeTags:d,onCategorySelect:l,onTagSelect:a,trailing:t,className:r})}function en(e){return {title:e.title,imageUrl:e.image_url}}function tn(e){let t=e.outcomes[0],r=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}var Sr=24,Kn=4,rn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},je={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},nn=je.ALL,u0={[je.ONE_DAY]:rn.ONE_MINUTE,[je.ONE_WEEK]:rn.ONE_HOUR,[je.ONE_MONTH]:rn.ONE_HOUR,[je.ALL]:rn.ONE_DAY},m0={[je.ONE_DAY]:300,[je.ONE_WEEK]:3600,[je.ONE_MONTH]:10800,[je.ALL]:1440*60},f0={[je.ONE_DAY]:1440*60,[je.ONE_WEEK]:10080*60,[je.ONE_MONTH]:720*60*60,[je.ALL]:null},on=1,an=1,g0=1,h0=1,v0=99,ur={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},x0=ur.ONE_WEEK,b0={[ur.ONE_HOUR]:60,[ur.SIX_HOURS]:60,[ur.ONE_DAY]:300,[ur.ONE_WEEK]:1800,[ur.MAX]:1800};var ti=createContext(null);function wr(){let e=useContext(ti);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Nl=1e4;function Pl({pollingInterval:e=Nl,enabled:t=true,children:r}){let n=useWallets(),o=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.SOLANA&&x.isConnected)?.address,[n]),i=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.EVM&&x.isConnected)?.address,[n]),{data:s,isLoading:l,isFetching:a,error:c}=useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:u,isLoading:d}=useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:p}=usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:v,isFetching:S,error:N}=useBalance({source:"polymarket",user:i??""},{enabled:t&&g&&!!i,refetchInterval:e}),T=useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:u?.verified??false,kalshiKycUrl:u?.kyc_url??null,kalshiKycLoading:d,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:p,isLoading:l||v,isFetching:a||S,error:c??N??null}),[o,i,f,s,h,g,u,d,m,p,l,v,a,S,c,N]);return jsx(ti.Provider,{value:T,children:r})}var Ml={minutes:60,hours:3600,days:86400};function sn(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*Ml[r]}}function ln(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function Ne(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function cn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let s=parseInt(o[1],10)/1e6,l=parseInt(o[2],10)/1e6,a=Math.max(0,s-l);return t("predict.trade.polymarket.insufficientBalance",{total:Ne(s,2).toFixed(2),active:Ne(l,2).toFixed(2),available:Ne(a,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Nr(e,t=4){return parseFloat(Ne(e,t).toFixed(t)).toString()}function Qt(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};jn({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{jn({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{jn({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function ii({market:e,initialOutcome:t="yes"}){let{t:r}=useTranslation(),{status:n}=useAuth(),o=useWallets(),i=useSwitchChain(),s=usePredictClient(),l=useContext(PolymarketContext),a=useQueryClient(),c=e.source,u=c==="polymarket",d=o.find(O=>O.chainNamespace===ChainNamespace.SOLANA&&O.isConnected),m=o.find(O=>O.chainNamespace===ChainNamespace.EVM&&O.isConnected&&"switchChain"in O),p=n==="authenticated",f=d?.address,g=m?.address,h=useMemo(()=>{if(c!=="polymarket")return;let O=e.provider_meta?.["polymarket.clobTokenIds"];return O?(typeof O=="string"?JSON.parse(O):O)[0]:void 0},[c,e.provider_meta]),{data:v,isLoading:S}=useTickSize(h),N=v?.minimum_tick_size?String(v.minimum_tick_size):"0.01",{data:T,isLoading:x}=useFeeRate(h),P=String(T?.base_fee??0),[k,Q]=useState(t),[z,J]=useState("market"),[w,B]=useState(NaN),[E,I]=useState(NaN),[de,U]=useState(false),[b,y]=useState(null),[V,j]=useState(false),[G,pe]=useState(false),[Se,it]=useState("1h"),[he,Be]=useState(30),[He,xt]=useState("minutes"),ve=null,Ke=false,tt=null,rt;try{let O=wr();ve={kalshiUsdcBalance:O.kalshiUsdcBalance,polymarketUsdcBalance:O.polymarketUsdcBalance,isLoading:O.isLoading},Ke=O.kalshiKycVerified,tt=O.kalshiKycUrl,rt=O.polymarketSafeAddress;}catch{}let we=useMemo(()=>{let O=k==="yes"?0:1,Te=e.outcomes[O];return Te?.best_ask??Te?.price??.5},[e.outcomes,k]),A=useCallback(O=>{J(O);},[]),ge=useCallback(O=>{Q(O),I(NaN);},[]);useEffect(()=>{z==="limit"&&isNaN(E)&&I(Math.round(we*100)/100);},[z,E,we]);let Oe=useMemo(()=>isNaN(w)||w<=0?0:we>0?w/we:0,[w,we]),ze=useMemo(()=>isNaN(w)||w<=0?"0":String(Math.round(w*1e6)),[w]),R=e.provider_meta?.["dflow.yesMint"]??"",Ee=e.provider_meta?.["dflow.noMint"]??"",bt=SOLANA_TOKENS.stablecoins.USDC.address,Bn=k==="yes"?R:Ee,pt=bt,jt=Bn,sr=c==="kalshi"?f??"":g??"",{data:Yt,isLoading:Ot}=usePositions({source:c,user:sr},{enabled:!!sr}),$e=c==="kalshi"&&!!pt&&!!jt&&!!f&&ze!=="0",{refetch:Ur}=useDFlowQuote({inputMint:pt,outputMint:jt,amount:ze,userPublicKey:f??"",slippageBps:100},{enabled:$e}),lr=useMemo(()=>ve?c==="kalshi"?ve.kalshiUsdcBalance:ve.polymarketUsdcBalance:Yt&&Yt.positions.reduce((Te,at)=>at.side==="USDC"||at.side==="collateral"?Te+(at.current_value??0):Te,0)||null,[ve,Yt,c]),Hn=ve?ve.isLoading:Ot,ut=useMemo(()=>z==="limit"&&u&&!isNaN(E)?E:we,[z,u,E,we]),Kr=useMemo(()=>isNaN(w)||w<=0?0:w,[w]),Vr=useMemo(()=>isNaN(w)||w<=0?0:ut>0?w/ut*1:0,[w,ut]),$o=Vr-Kr,jr=useCallback(O=>{if(isNaN(O)){B(NaN);return}B(Math.round(Math.max(0,O)*100)/100);},[]),zn=useCallback(O=>{if(isNaN(O)){I(NaN);return}let Te=Math.max(.01,Math.min(.99,O));I(Math.round(Te*100)/100);},[]),mt=useCallback(()=>{B(NaN),I(NaN),J("market"),pe(false),it("1h"),Be(30),xt("minutes");},[]),yt=useMemo(()=>{let O=[];return isNaN(w)||w<=0?O.push(r("predict.trade.minAmountUsd",{amount:an})):w<an&&O.push(r("predict.trade.minAmountUsd",{amount:an})),e.status!=="open"&&O.push(r("predict.trade.marketNotActive")),lr!=null&&!isNaN(w)&&w>0&&w>Ne(lr,2)&&O.push(r("predict.trade.insufficientBalance")),z==="limit"&&u&&(isNaN(E)||E<.01||E>.99)&&O.push(r("predict.trade.limitPriceRange")),z==="limit"&&u&&G&&Se==="custom"&&(isNaN(he)||he<=0)&&O.push(r("predict.trade.expiration.invalidDate")),{isValid:O.length===0,errors:O}},[w,e.status,lr,z,u,E,G,Se,he,r]),{mutateAsync:Dt}=useDFlowSubmit(),{data:At}=useOrder({id:b??"",source:c},{enabled:!!b});useEffect(()=>{if(!At||!b)return;let{status:O}=At;O==="closed"?(y(null),U(false),toast.success(r("predict.trade.submitSuccess")),Qt(),mt(),a.invalidateQueries({queryKey:["predict","positions"]})):(O==="failed"||O==="expired")&&(U(false),y(null),toast.error(r("predict.trade.submitError")));},[At,b,a,mt,r]);let Yr=useCallback(async()=>{if(!f||!d)return;if(!pt||!jt){toast.error("Missing token mint addresses"),U(false);return}if(!Ke){j(true),U(false);return}let cr=(await Ur()).data?.transaction;if(!cr){toast.error(r("predict.trade.submitError")),U(false);return}let Ft=Uint8Array.from(atob(cr),Bt=>Bt.charCodeAt(0)),kt=await d.signTransaction(Ft),St=await Dt({signedTransaction:btoa(String.fromCharCode(...kt)),orderContext:{user_public_key:f,input_mint:pt,output_mint:jt,amount:ze,price:String(we),side:"BUY",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});y(St.signature);},[f,d,Ur,Dt,pt,jt,ze,we,k,e.slug,r,Ke]),kr=useCallback(async()=>{if(!m||!l)return;let O=m.chain,Te=O!==Chain.POLYGON;Te&&await i(Chain.POLYGON);try{let at=await m.getEip1193Provider();if(!at){toast.error(r("predict.trade.submitError")),U(!1);return}let cr=!!rt,Ft={address:m.address,signatureType:cr?2:0,signTypedData:async(ue,Ht,Jr,Wn)=>{let zt=[];"name"in ue&&zt.push({name:"name",type:"string"}),"version"in ue&&zt.push({name:"version",type:"string"}),"chainId"in ue&&zt.push({name:"chainId",type:"uint256"}),"verifyingContract"in ue&&zt.push({name:"verifyingContract",type:"address"}),"salt"in ue&&zt.push({name:"salt",type:"bytes32"});let Wo={EIP712Domain:zt,...Ht};return await at.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:ue,types:Wo,primaryType:Jr,message:Wn})]})}},kt=l.credentials??await l.authenticate(Ft),St=k==="yes"?0:1,Bt="",wt=e.provider_meta?.["polymarket.clobTokenIds"];wt&&(Bt=(typeof wt=="string"?JSON.parse(wt):wt)[St]??"");let dr=e.provider_meta?.["polymarket.negRisk"]??!1,Gr=z==="limit"&&!isNaN(E)?E:we,Nt=ln(Gr,N),qr=z==="limit"?G?"GTD":"GTC":"FOK",Qr=z==="market"?w:Nt>0?w/Nt:0,Xr={tokenId:Bt,price:Nt,size:Qr,side:"BUY",orderType:qr,tickSize:N,negRisk:dr,...rt&&{funderAddress:rt},...z==="limit"&&G&&{expiration:sn(Se,he,He)}},M=buildCtfExchangeDomain(dr),xe=buildOrderMessage({...Xr,signerAddress:Ft.address,signatureType:Ft.signatureType,feeRateBps:P}),Ve=await Ft.signTypedData(M,CTF_ORDER_TYPES,"Order",xe),De=buildSignedOrder(xe,Ve,Xr.orderType),nt=buildClobPayload(De,kt.apiKey),We=JSON.stringify(nt),Pt=await buildPolymarketL2Headers(kt.address,{apiKey:kt.apiKey,secret:kt.secret,passphrase:kt.passphrase,method:"POST",requestPath:"/order",body:We});await s.createPolymarketOrder(nt,Pt),a.invalidateQueries({queryKey:["predict","orders"]}),a.invalidateQueries({queryKey:["predict","positions"]}),toast.success(r("predict.trade.submitSuccess")),Qt(),mt(),U(!1);}finally{Te&&O&&i(O).catch(()=>{});}},[m,l,i,k,e.provider_meta,z,E,we,w,s,a,G,Se,he,He,mt,r,N,P,rt]),$n=useCallback(async()=>{if(!(!yt.isValid||!p)){U(true),y(null),j(false);try{c==="kalshi"?await Yr():await kr();}catch(O){let Te=O instanceof Error?O.message:"",at=c==="polymarket"&&Te?cn(Te,r,"buy"):Te||void 0;toast.error(at||r("predict.trade.submitError")),U(false);}}},[yt.isValid,p,c,Yr,kr,r]);return {outcome:k,orderType:z,quantity:w,limitPrice:E,shares:Oe,estimatedCost:Kr,potentialPayout:Vr,potentialProfit:$o,usdcBalance:lr,isBalanceLoading:Hn,isMarketDataLoading:c==="polymarket"&&(x||S),isSubmitting:de,validation:yt,supportsLimitOrder:u,kycRequired:V,kycUrl:tt,expirationEnabled:G,expirationPreset:Se,customDuration:he,customDurationUnit:He,setOutcome:ge,setOrderType:A,setQuantity:jr,setLimitPrice:zn,setExpirationEnabled:pe,setExpirationPreset:it,setCustomDuration:Be,setCustomDurationUnit:xt,submit:$n}}function dn({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 lc=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,cc=["5m","1h","12h","24h","eod","custom"],dc={"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"},pc=["minutes","hours","days"],uc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},mc={maximumFractionDigits:0};function mi({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:l,potentialProfit:a,potentialPayout:c,estimatedCost:u,usdcBalance:d,isBalanceLoading:m,isMarketDataLoading:p,isSubmitting:f,isValid:g,validationErrors:h,supportsLimitOrder:v,kycRequired:S,kycUrl:N,expirationEnabled:T,expirationPreset:x,customDuration:P,customDurationUnit:k,onOutcomeChange:Q,onOrderTypeChange:z,onQuantityChange:J,onLimitPriceChange:w,onExpirationEnabledChange:B,onExpirationPresetChange:E,onCustomDurationChange:I,onCustomDurationUnitChange:de,onSubmit:U}){let{t:b}=useTranslation(),[y,V]=useState(false),j=useDisclosure(),[G,pe]=useState(""),Se=useRef(false);useEffect(()=>{Se.current||pe(isNaN(i)?"":String(i));},[i]);let[it,he]=useState(""),Be=useRef(false);useEffect(()=>{Be.current||(isNaN(s)?he(""):he(String(parseFloat((s*100).toFixed(2)))));},[s]);let He=useCallback(R=>{if(R!==""&&!/^\d*\.?\d{0,2}$/.test(R))return;if(he(R),R===""||R==="."){w(NaN);return}let bt=parseFloat(R);isNaN(bt)||w(bt/100);},[w]),xt=useCallback(R=>{if(R!==""&&!/^\d*\.?\d{0,2}$/.test(R))return;if(pe(R),Oe(false),R===""||R==="."){J(NaN);return}let bt=parseFloat(R);isNaN(bt)||J(bt);},[J]);useEffect(()=>{S&&!j.isOpen&&j.onOpen();},[S]);let ve=useMemo(()=>{let R=n==="yes"?t.yesAsk:t.noAsk;return R!=null?parseFloat((Number(R)*100).toFixed(2)):null},[n,t]),Ke=!isNaN(i)&&i>0,tt=useMemo(()=>{if(m)return b("predict.trade.loadingBalance");if(p)return b("predict.trade.loadingMarketData");if(f)return b("predict.trade.submitting");if(S)return b("predict.trade.kycRequired");if(!Ke)return b("predict.trade.enterAmount");let R=b(n==="yes"?"predict.trade.yes":"predict.trade.no"),Ee=a>0?` \u2192 Win $${a.toFixed(2)}`:"";return `${b("predict.trade.buy")} ${R}${Ee}`},[m,p,f,S,Ke,n,a,b]),rt=useMemo(()=>n==="yes"?"primary":"secondary",[n]),we=()=>{J(Math.floor((d??0)/2*100)/100);},A=()=>{J(Ne(d??0,2));},[ge,Oe]=useState(false),ze=()=>{if(S){j.onOpen();return}if(!g){Oe(true);return}Oe(false),U();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:R=>{r==="bordered"&&(R.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:R=>{r==="bordered"&&(R.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:n==="yes"?"text-bullish":"text-bearish",children:[b("predict.trade.buy")," ",b(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[v?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:R=>z(R),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:b("predict.trade.market")},"market"),jsx(Tab,{title:b("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.market")}),o==="limit"&&v?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:it,onChange:R=>He(R.target.value),onFocus:()=>{Be.current=true;},onBlur:()=>{Be.current=false,isNaN(s)?he(""):he(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):ve!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[ve," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(R=>{let Ee=R==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>Q(R),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===R?R==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:b(R==="yes"?"predict.trade.yes":"predict.trade.no")}),Ee!=null&&jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Ee)*100).toFixed(2)),"\xA2"]})]})},R)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:lc,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`${Ne(d,2).toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:we,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:b("predict.trade.half")}),jsx("button",{type:"button",onClick:A,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:b("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:G,onChange:R=>xt(R.target.value),onFocus:()=>{Se.current=true;},onBlur:()=>{Se.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"}}),ge&&h.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:h.map(R=>jsx("span",{className:"text-xs text-danger",children:R},R))})]}),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:b("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:T,onValueChange:B,"aria-label":b("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":b("predict.trade.setExpiration"),selectedKeys:[x],onSelectionChange:R=>{let Ee=Array.from(R)[0];Ee&&E(Ee);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:cc.map(R=>jsx(SelectItem,{children:b(dc[R])},R))}),x==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(P)?void 0:P,onValueChange:I,minValue:1,step:1,formatOptions:mc,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[k],onSelectionChange:R=>{let Ee=Array.from(R)[0];Ee&&de(Ee);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pc.map(R=>jsx(SelectItem,{children:b(uc[R])},R))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>V(R=>!R),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:b("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",y&&"rotate-180")})]}),ve!=null&&jsx("span",{className:"text-foreground font-medium tabular-nums",children:b("predict.trade.chance",{percent:ve})})]}),y&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?Nr(l):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&a>0?`+$${a.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:rt,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||p||!Ke||f,isLoading:f||m||p,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:ze,children:tt})]}),jsx(dn,{isOpen:j.isOpen,onClose:j.onClose,kycUrl:N})]})}function un({event:e,market:t,variant:r,initialOutcome:n,chain:o}){let{outcome:i,orderType:s,quantity:l,limitPrice:a,shares:c,estimatedCost:u,potentialPayout:d,potentialProfit:m,usdcBalance:p,isBalanceLoading:f,isMarketDataLoading:g,isSubmitting:h,validation:v,supportsLimitOrder:S,kycRequired:N,kycUrl:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,setOutcome:z,setOrderType:J,setQuantity:w,setLimitPrice:B,setExpirationEnabled:E,setExpirationPreset:I,setCustomDuration:de,setCustomDurationUnit:U,submit:b}=ii({market:t,initialOutcome:n}),y=useAuthCallback(b),V=useMemo(()=>e?en(e):void 0,[e]),j=useMemo(()=>tn(t),[t]);return jsx(mi,{event:V,market:j,variant:r,outcome:i,orderType:s,quantity:l,limitPrice:a,shares:c,estimatedCost:u,potentialPayout:d,potentialProfit:m,usdcBalance:p,isBalanceLoading:f,isMarketDataLoading:g,isSubmitting:h,isValid:v.isValid,validationErrors:v.errors,supportsLimitOrder:S,kycRequired:N,kycUrl:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,onOutcomeChange:z,onOrderTypeChange:J,onQuantityChange:w,onLimitPriceChange:B,onExpirationEnabledChange:E,onExpirationPresetChange:I,onCustomDurationChange:de,onCustomDurationUnitChange:U,onSubmit:y})}var Pr="predict-trade";function mn({id:e=Pr}){return jsx(AsyncModal,{id:e,children:t=>jsx(kc,{...t})})}function kc({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(un,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,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 qn={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Qn(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function gi({isOpen:e,onClose:t,value:r,onChange:n}){let{t:o}=useTranslation(),[i,s]=useState(r),l=useCallback(h=>{h?s(r):t();},[r,t]),a=useCallback(()=>{s(qn);},[]),c=useCallback(()=>{n(i),t();},[i,n,t]),u=useCallback((h,v)=>{s(S=>({...S,[h]:v}));},[]),d=useMemo(()=>Qn(i),[i]),m=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"polymarket",label:o("predict.platform.polymarket")},{value:"kalshi",label:o("predict.platform.kalshi")}],[o]),p=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1d",label:o("predict.filter.lessThanDay")},{value:"7d",label:o("predict.filter.lessThanWeek")},{value:"30d",label:o("predict.filter.lessThanMonth")}],[o]),f=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]),g=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]);return jsx(StyledModal,{isOpen:e,onOpenChange:l,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.filter.title")}),jsx(Mc,{onClick:()=>l(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(gn,{label:o("predict.filter.platform"),children:jsx(hn,{options:m,selected:i.source,onSelect:h=>u("source",h)})}),jsx(gn,{label:o("predict.filter.timeRemaining"),children:jsx(hn,{options:p,selected:i.timeRemaining,onSelect:h=>u("timeRemaining",h)})}),jsx(gn,{label:o("predict.filter.minVolume"),children:jsx(hn,{options:f,selected:i.minVolume,onSelect:h=>u("minVolume",h)})}),jsx(gn,{label:o("predict.filter.minLiquidity"),children:jsx(hn,{options:g,selected:i.minLiquidity,onSelect:h=>u("minLiquidity",h)})})]}),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:a,children:o("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[o("predict.filter.showResults"),d>0&&jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function gn({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 Mc({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 hn({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var yi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},vi={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Ac=["start_time","volume","liquidity","ending_soon"],xi={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"},Fc={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 ki({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:l}=useTranslation(),[a,c]=useState(false),u=useRef(null),d=useCallback(p=>{u.current&&!u.current.contains(p.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)),[d]),useEffect(()=>{if(!a)return;let p=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[a]);let m=bi[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:u,style:{position:"relative"},children:[jsxs("button",{type:"button",style:xi,onMouseEnter:p=>{p.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:p=>{p.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(p=>!p),children:[jsx(Bc,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l(vi[e])}),jsx(zc,{open:a})]}),a&&jsx("div",{style:{...Fc,width:224,padding:4},children:Ac.map(p=>{let f=bi[p],g=e===p;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:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===p?n(!r):t(p),c(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:l(vi[p])}),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"})})]},p)})})]}),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:p=>{p.currentTarget.style.background="rgba(39,39,42,1)",p.currentTarget.style.color="#fff";},onMouseLeave:p=>{p.currentTarget.style.background="rgba(39,39,42,0.6)",p.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:xi,onMouseEnter:p=>{p.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:p=>{p.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(Hc,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l("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 bi={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Bc(){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 Hc(){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 zc({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 Ni(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:s,error:l,hasNextPage:a,fetchNextPage:c,refetch:u}=useInfiniteEvents(t),d=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{c();},[c]),p=useCallback(()=>{u();},[u]);return {data:d,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:l??null,hasMore:a??false,fetchMore:m,refetch:p}}var Pi=`
|
|
1
|
+
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,EmptyIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useSwitchChain,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {ChartRange,useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,useFeeRate,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,debounce}from'@liberfi.io/utils';import jn from'canvas-confetti';import {List}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.140");var dl="0.1.140";var pl={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},jo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Un=(()=>{let e=t=>{let r=jo.indexOf(t);return r===-1?jo.length:r};return Object.entries(pl).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 qo({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:l="Trending",className:a}){let{t:c}=useTranslation(),u=useCallback(()=>{o(null);},[o]),d=c("predict.categories.trending");return jsxs("div",{className:cn$1("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",a),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(Yo,{label:d,isSelected:t===null,onPress:u,showPulse:d===l}),jsx(gl,{}),e.map(m=>jsx(Yo,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===l},m.category))]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&n.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(Go,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsx(Go,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function Yo({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 gl(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Go({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 o0({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 hl(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function vl(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Jo({onSelect:e,trailing:t,className:r}){let[n,o]=useState(null),[i,s]=useState(null),l=useCallback(m=>{o(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),a=useCallback(m=>{s(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=hl(Un),u=Un.find(m=>m.slug===n),d=vl(u);return jsx(qo,{categories:c,selectedCategory:n,selectedTag:i,activeTags:d,onCategorySelect:l,onTagSelect:a,trailing:t,className:r})}function en(e){return {title:e.title,imageUrl:e.image_url}}function tn(e){let t=e.outcomes[0],r=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}var Sr=24,Kn=4,rn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},je={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},nn=je.ALL,m0={[je.ONE_DAY]:rn.ONE_MINUTE,[je.ONE_WEEK]:rn.ONE_HOUR,[je.ONE_MONTH]:rn.ONE_HOUR,[je.ALL]:rn.ONE_DAY},f0={[je.ONE_DAY]:300,[je.ONE_WEEK]:3600,[je.ONE_MONTH]:10800,[je.ALL]:1440*60},g0={[je.ONE_DAY]:1440*60,[je.ONE_WEEK]:10080*60,[je.ONE_MONTH]:720*60*60,[je.ALL]:null},on=1,an=1,h0=1,v0=1,x0=99,ur={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},b0=ur.ONE_WEEK,y0={[ur.ONE_HOUR]:60,[ur.SIX_HOURS]:60,[ur.ONE_DAY]:300,[ur.ONE_WEEK]:1800,[ur.MAX]:1800};var ti=createContext(null);function wr(){let e=useContext(ti);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Nl=1e4;function Pl({pollingInterval:e=Nl,enabled:t=true,children:r}){let n=useWallets(),o=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.SOLANA&&x.isConnected)?.address,[n]),i=useMemo(()=>n.find(x=>x.chainNamespace===ChainNamespace.EVM&&x.isConnected)?.address,[n]),{data:s,isLoading:l,isFetching:a,error:c}=useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:u,isLoading:d}=useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:p}=usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:v,isFetching:S,error:w}=useBalance({source:"polymarket",user:i??""},{enabled:t&&g&&!!i,refetchInterval:e}),T=useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:u?.verified??false,kalshiKycUrl:u?.kyc_url??null,kalshiKycLoading:d,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:p,isLoading:l||v,isFetching:a||S,error:c??w??null}),[o,i,f,s,h,g,u,d,m,p,l,v,a,S,c,w]);return jsx(ti.Provider,{value:T,children:r})}var Ml={minutes:60,hours:3600,days:86400};function sn(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*Ml[r]}}function ln(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function Ne(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function cn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let s=parseInt(o[1],10)/1e6,l=parseInt(o[2],10)/1e6,a=Math.max(0,s-l);return t("predict.trade.polymarket.insufficientBalance",{total:Ne(s,2).toFixed(2),active:Ne(l,2).toFixed(2),available:Ne(a,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Nr(e,t=2){return parseFloat(Ne(e,t).toFixed(t)).toString()}function Xt(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};jn({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{jn({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{jn({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function ii({market:e,initialOutcome:t="yes"}){let{t:r}=useTranslation(),{status:n}=useAuth(),o=useWallets(),i=useSwitchChain(),s=usePredictClient(),l=useContext(PolymarketContext),a=useQueryClient(),c=e.source,u=c==="polymarket",d=o.find(O=>O.chainNamespace===ChainNamespace.SOLANA&&O.isConnected),m=o.find(O=>O.chainNamespace===ChainNamespace.EVM&&O.isConnected&&"switchChain"in O),p=n==="authenticated",f=d?.address,g=m?.address,h=useMemo(()=>{if(c!=="polymarket")return;let O=e.provider_meta?.["polymarket.clobTokenIds"];return O?(typeof O=="string"?JSON.parse(O):O)[0]:void 0},[c,e.provider_meta]),{data:v,isLoading:S}=useTickSize(h),w=v?.minimum_tick_size?String(v.minimum_tick_size):"0.01",{data:T,isLoading:x}=useFeeRate(h),P=String(T?.base_fee??0),[k,Q]=useState(t),[z,J]=useState("market"),[N,B]=useState(NaN),[E,I]=useState(NaN),[de,U]=useState(false),[b,y]=useState(null),[V,j]=useState(false),[G,pe]=useState(false),[Se,it]=useState("1h"),[he,Be]=useState(30),[He,xt]=useState("minutes"),ve=null,Ke=false,tt=null,rt;try{let O=wr();ve={kalshiUsdcBalance:O.kalshiUsdcBalance,polymarketUsdcBalance:O.polymarketUsdcBalance,isLoading:O.isLoading},Ke=O.kalshiKycVerified,tt=O.kalshiKycUrl,rt=O.polymarketSafeAddress;}catch{}let we=useMemo(()=>{let O=k==="yes"?0:1,Te=e.outcomes[O];return Te?.best_ask??Te?.price??.5},[e.outcomes,k]),A=useCallback(O=>{J(O);},[]),ge=useCallback(O=>{Q(O),I(NaN);},[]);useEffect(()=>{z==="limit"&&isNaN(E)&&I(Math.round(we*100)/100);},[z,E,we]);let Oe=useMemo(()=>isNaN(N)||N<=0?0:we>0?N/we:0,[N,we]),ze=useMemo(()=>isNaN(N)||N<=0?"0":String(Math.round(N*1e6)),[N]),R=e.provider_meta?.["dflow.yesMint"]??"",Ee=e.provider_meta?.["dflow.noMint"]??"",bt=SOLANA_TOKENS.stablecoins.USDC.address,Bn=k==="yes"?R:Ee,at=bt,Yt=Bn,sr=c==="kalshi"?f??"":g??"",{data:Gt,isLoading:Ot}=usePositions({source:c,user:sr},{enabled:!!sr}),$e=c==="kalshi"&&!!at&&!!Yt&&!!f&&ze!=="0",{refetch:Ur}=useDFlowQuote({inputMint:at,outputMint:Yt,amount:ze,userPublicKey:f??"",slippageBps:100},{enabled:$e}),lr=useMemo(()=>ve?c==="kalshi"?ve.kalshiUsdcBalance:ve.polymarketUsdcBalance:Gt&&Gt.positions.reduce((Te,st)=>st.side==="USDC"||st.side==="collateral"?Te+(st.current_value??0):Te,0)||null,[ve,Gt,c]),Hn=ve?ve.isLoading:Ot,ut=useMemo(()=>z==="limit"&&u&&!isNaN(E)?E:we,[z,u,E,we]),Kr=useMemo(()=>isNaN(N)||N<=0?0:N,[N]),Vr=useMemo(()=>isNaN(N)||N<=0?0:ut>0?N/ut*1:0,[N,ut]),$o=Vr-Kr,jr=useCallback(O=>{if(isNaN(O)){B(NaN);return}B(Math.round(Math.max(0,O)*100)/100);},[]),zn=useCallback(O=>{if(isNaN(O)){I(NaN);return}let Te=Math.max(.01,Math.min(.99,O));I(Math.round(Te*100)/100);},[]),mt=useCallback(()=>{B(NaN),I(NaN),J("market"),pe(false),it("1h"),Be(30),xt("minutes");},[]),yt=useMemo(()=>{let O=[];return isNaN(N)||N<=0?O.push(r("predict.trade.minAmountUsd",{amount:an})):N<an&&O.push(r("predict.trade.minAmountUsd",{amount:an})),e.status!=="open"&&O.push(r("predict.trade.marketNotActive")),lr!=null&&!isNaN(N)&&N>0&&N>Ne(lr,2)&&O.push(r("predict.trade.insufficientBalance")),z==="limit"&&u&&(isNaN(E)||E<.01||E>.99)&&O.push(r("predict.trade.limitPriceRange")),z==="limit"&&u&&G&&Se==="custom"&&(isNaN(he)||he<=0)&&O.push(r("predict.trade.expiration.invalidDate")),{isValid:O.length===0,errors:O}},[N,e.status,lr,z,u,E,G,Se,he,r]),{mutateAsync:Dt}=useDFlowSubmit(),{data:At}=useOrder({id:b??"",source:c},{enabled:!!b});useEffect(()=>{if(!At||!b)return;let{status:O}=At;O==="closed"?(y(null),U(false),toast.success(r("predict.trade.submitSuccess")),Xt(),mt(),a.invalidateQueries({queryKey:["predict","positions"]})):(O==="failed"||O==="expired")&&(U(false),y(null),toast.error(r("predict.trade.submitError")));},[At,b,a,mt,r]);let Yr=useCallback(async()=>{if(!f||!d)return;if(!at||!Yt){toast.error("Missing token mint addresses"),U(false);return}if(!Ke){j(true),U(false);return}let cr=(await Ur()).data?.transaction;if(!cr){toast.error(r("predict.trade.submitError")),U(false);return}let Ft=Uint8Array.from(atob(cr),Bt=>Bt.charCodeAt(0)),kt=await d.signTransaction(Ft),St=await Dt({signedTransaction:btoa(String.fromCharCode(...kt)),orderContext:{user_public_key:f,input_mint:at,output_mint:Yt,amount:ze,price:String(we),side:"BUY",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});y(St.signature);},[f,d,Ur,Dt,at,Yt,ze,we,k,e.slug,r,Ke]),kr=useCallback(async()=>{if(!m||!l)return;let O=m.chain,Te=O!==Chain.POLYGON;Te&&await i(Chain.POLYGON);try{let st=await m.getEip1193Provider();if(!st){toast.error(r("predict.trade.submitError")),U(!1);return}let cr=!!rt,Ft={address:m.address,signatureType:cr?2:0,signTypedData:async(ue,Ht,Jr,Wn)=>{let zt=[];"name"in ue&&zt.push({name:"name",type:"string"}),"version"in ue&&zt.push({name:"version",type:"string"}),"chainId"in ue&&zt.push({name:"chainId",type:"uint256"}),"verifyingContract"in ue&&zt.push({name:"verifyingContract",type:"address"}),"salt"in ue&&zt.push({name:"salt",type:"bytes32"});let Wo={EIP712Domain:zt,...Ht};return await st.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:ue,types:Wo,primaryType:Jr,message:Wn})]})}},kt=l.credentials??await l.authenticate(Ft),St=k==="yes"?0:1,Bt="",wt=e.provider_meta?.["polymarket.clobTokenIds"];wt&&(Bt=(typeof wt=="string"?JSON.parse(wt):wt)[St]??"");let dr=e.provider_meta?.["polymarket.negRisk"]??!1,Gr=z==="limit"&&!isNaN(E)?E:we,Nt=ln(Gr,w),qr=z==="limit"?G?"GTD":"GTC":"FOK",Qr=z==="market"?N:Nt>0?N/Nt:0,Xr={tokenId:Bt,price:Nt,size:Qr,side:"BUY",orderType:qr,tickSize:w,negRisk:dr,...rt&&{funderAddress:rt},...z==="limit"&&G&&{expiration:sn(Se,he,He)}},M=buildCtfExchangeDomain(dr),xe=buildOrderMessage({...Xr,signerAddress:Ft.address,signatureType:Ft.signatureType,feeRateBps:P}),Ve=await Ft.signTypedData(M,CTF_ORDER_TYPES,"Order",xe),De=buildSignedOrder(xe,Ve,Xr.orderType),nt=buildClobPayload(De,kt.apiKey),We=JSON.stringify(nt),Pt=await buildPolymarketL2Headers(kt.address,{apiKey:kt.apiKey,secret:kt.secret,passphrase:kt.passphrase,method:"POST",requestPath:"/order",body:We});await s.createPolymarketOrder(nt,Pt),a.invalidateQueries({queryKey:["predict","orders"]}),a.invalidateQueries({queryKey:["predict","positions"]}),toast.success(r("predict.trade.submitSuccess")),Xt(),mt(),U(!1);}finally{Te&&O&&i(O).catch(()=>{});}},[m,l,i,k,e.provider_meta,z,E,we,N,s,a,G,Se,he,He,mt,r,w,P,rt]),$n=useCallback(async()=>{if(!(!yt.isValid||!p)){U(true),y(null),j(false);try{c==="kalshi"?await Yr():await kr();}catch(O){let Te=O instanceof Error?O.message:"",st=c==="polymarket"&&Te?cn(Te,r,"buy"):Te||void 0;toast.error(st||r("predict.trade.submitError")),U(false);}}},[yt.isValid,p,c,Yr,kr,r]);return {outcome:k,orderType:z,quantity:N,limitPrice:E,shares:Oe,estimatedCost:Kr,potentialPayout:Vr,potentialProfit:$o,usdcBalance:lr,isBalanceLoading:Hn,isMarketDataLoading:c==="polymarket"&&(x||S),isSubmitting:de,validation:yt,supportsLimitOrder:u,kycRequired:V,kycUrl:tt,expirationEnabled:G,expirationPreset:Se,customDuration:he,customDurationUnit:He,setOutcome:ge,setOrderType:A,setQuantity:jr,setLimitPrice:zn,setExpirationEnabled:pe,setExpirationPreset:it,setCustomDuration:Be,setCustomDurationUnit:xt,submit:$n}}function dn({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 lc=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,cc=["5m","1h","12h","24h","eod","custom"],dc={"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"},pc=["minutes","hours","days"],uc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},mc={maximumFractionDigits:0};function mi({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:l,potentialProfit:a,potentialPayout:c,estimatedCost:u,usdcBalance:d,isBalanceLoading:m,isMarketDataLoading:p,isSubmitting:f,isValid:g,validationErrors:h,supportsLimitOrder:v,kycRequired:S,kycUrl:w,expirationEnabled:T,expirationPreset:x,customDuration:P,customDurationUnit:k,onOutcomeChange:Q,onOrderTypeChange:z,onQuantityChange:J,onLimitPriceChange:N,onExpirationEnabledChange:B,onExpirationPresetChange:E,onCustomDurationChange:I,onCustomDurationUnitChange:de,onSubmit:U}){let{t:b}=useTranslation(),[y,V]=useState(false),j=useDisclosure(),[G,pe]=useState(""),Se=useRef(false);useEffect(()=>{Se.current||pe(isNaN(i)?"":String(i));},[i]);let[it,he]=useState(""),Be=useRef(false);useEffect(()=>{Be.current||(isNaN(s)?he(""):he(String(parseFloat((s*100).toFixed(2)))));},[s]);let He=useCallback(R=>{if(R!==""&&!/^\d*\.?\d{0,2}$/.test(R))return;if(he(R),R===""||R==="."){N(NaN);return}let bt=parseFloat(R);isNaN(bt)||N(bt/100);},[N]),xt=useCallback(R=>{if(R!==""&&!/^\d*\.?\d{0,2}$/.test(R))return;if(pe(R),Oe(false),R===""||R==="."){J(NaN);return}let bt=parseFloat(R);isNaN(bt)||J(bt);},[J]);useEffect(()=>{S&&!j.isOpen&&j.onOpen();},[S]);let ve=useMemo(()=>{let R=n==="yes"?t.yesAsk:t.noAsk;return R!=null?parseFloat((Number(R)*100).toFixed(2)):null},[n,t]),Ke=!isNaN(i)&&i>0,tt=useMemo(()=>{if(m)return b("predict.trade.loadingBalance");if(p)return b("predict.trade.loadingMarketData");if(f)return b("predict.trade.submitting");if(S)return b("predict.trade.kycRequired");if(!Ke)return b("predict.trade.enterAmount");let R=b(n==="yes"?"predict.trade.yes":"predict.trade.no"),Ee=a>0?` \u2192 Win $${a.toFixed(2)}`:"";return `${b("predict.trade.buy")} ${R}${Ee}`},[m,p,f,S,Ke,n,a,b]),rt=useMemo(()=>n==="yes"?"primary":"secondary",[n]),we=()=>{J(Math.floor((d??0)/2*100)/100);},A=()=>{J(Ne(d??0,2));},[ge,Oe]=useState(false),ze=()=>{if(S){j.onOpen();return}if(!g){Oe(true);return}Oe(false),U();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:R=>{r==="bordered"&&(R.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:R=>{r==="bordered"&&(R.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:n==="yes"?"text-bullish":"text-bearish",children:[b("predict.trade.buy")," ",b(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[v?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:R=>z(R),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:b("predict.trade.market")},"market"),jsx(Tab,{title:b("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.market")}),o==="limit"&&v?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:it,onChange:R=>He(R.target.value),onFocus:()=>{Be.current=true;},onBlur:()=>{Be.current=false,isNaN(s)?he(""):he(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):ve!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[ve," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(R=>{let Ee=R==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>Q(R),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===R?R==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:b(R==="yes"?"predict.trade.yes":"predict.trade.no")}),Ee!=null&&jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Ee)*100).toFixed(2)),"\xA2"]})]})},R)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:b("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:lc,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`${Ne(d,2).toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:we,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:b("predict.trade.half")}),jsx("button",{type:"button",onClick:A,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:b("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:G,onChange:R=>xt(R.target.value),onFocus:()=>{Se.current=true;},onBlur:()=>{Se.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"}}),ge&&h.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:h.map(R=>jsx("span",{className:"text-xs text-danger",children:R},R))})]}),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:b("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:T,onValueChange:B,"aria-label":b("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":b("predict.trade.setExpiration"),selectedKeys:[x],onSelectionChange:R=>{let Ee=Array.from(R)[0];Ee&&E(Ee);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:cc.map(R=>jsx(SelectItem,{children:b(dc[R])},R))}),x==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(P)?void 0:P,onValueChange:I,minValue:1,step:1,formatOptions:mc,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[k],onSelectionChange:R=>{let Ee=Array.from(R)[0];Ee&&de(Ee);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pc.map(R=>jsx(SelectItem,{children:b(uc[R])},R))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>V(R=>!R),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:b("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",y&&"rotate-180")})]}),ve!=null&&jsx("span",{className:"text-foreground font-medium tabular-nums",children:b("predict.trade.chance",{percent:ve})})]}),y&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?Nr(l):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:b("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&a>0?`+$${a.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:rt,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||p||!Ke||f,isLoading:f||m||p,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:ze,children:tt})]}),jsx(dn,{isOpen:j.isOpen,onClose:j.onClose,kycUrl:w})]})}function un({event:e,market:t,variant:r,initialOutcome:n,chain:o}){let{outcome:i,orderType:s,quantity:l,limitPrice:a,shares:c,estimatedCost:u,potentialPayout:d,potentialProfit:m,usdcBalance:p,isBalanceLoading:f,isMarketDataLoading:g,isSubmitting:h,validation:v,supportsLimitOrder:S,kycRequired:w,kycUrl:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,setOutcome:z,setOrderType:J,setQuantity:N,setLimitPrice:B,setExpirationEnabled:E,setExpirationPreset:I,setCustomDuration:de,setCustomDurationUnit:U,submit:b}=ii({market:t,initialOutcome:n}),y=useAuthCallback(b),V=useMemo(()=>e?en(e):void 0,[e]),j=useMemo(()=>tn(t),[t]);return jsx(mi,{event:V,market:j,variant:r,outcome:i,orderType:s,quantity:l,limitPrice:a,shares:c,estimatedCost:u,potentialPayout:d,potentialProfit:m,usdcBalance:p,isBalanceLoading:f,isMarketDataLoading:g,isSubmitting:h,isValid:v.isValid,validationErrors:v.errors,supportsLimitOrder:S,kycRequired:w,kycUrl:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,onOutcomeChange:z,onOrderTypeChange:J,onQuantityChange:N,onLimitPriceChange:B,onExpirationEnabledChange:E,onExpirationPresetChange:I,onCustomDurationChange:de,onCustomDurationUnitChange:U,onSubmit:y})}var Pr="predict-trade";function mn({id:e=Pr}){return jsx(AsyncModal,{id:e,children:t=>jsx(kc,{...t})})}function kc({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(un,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,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 qn={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Qn(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function gi({isOpen:e,onClose:t,value:r,onChange:n}){let{t:o}=useTranslation(),[i,s]=useState(r),l=useCallback(h=>{h?s(r):t();},[r,t]),a=useCallback(()=>{s(qn);},[]),c=useCallback(()=>{n(i),t();},[i,n,t]),u=useCallback((h,v)=>{s(S=>({...S,[h]:v}));},[]),d=useMemo(()=>Qn(i),[i]),m=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"polymarket",label:o("predict.platform.polymarket")},{value:"kalshi",label:o("predict.platform.kalshi")}],[o]),p=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1d",label:o("predict.filter.lessThanDay")},{value:"7d",label:o("predict.filter.lessThanWeek")},{value:"30d",label:o("predict.filter.lessThanMonth")}],[o]),f=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]),g=useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]);return jsx(StyledModal,{isOpen:e,onOpenChange:l,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.filter.title")}),jsx(Mc,{onClick:()=>l(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(gn,{label:o("predict.filter.platform"),children:jsx(hn,{options:m,selected:i.source,onSelect:h=>u("source",h)})}),jsx(gn,{label:o("predict.filter.timeRemaining"),children:jsx(hn,{options:p,selected:i.timeRemaining,onSelect:h=>u("timeRemaining",h)})}),jsx(gn,{label:o("predict.filter.minVolume"),children:jsx(hn,{options:f,selected:i.minVolume,onSelect:h=>u("minVolume",h)})}),jsx(gn,{label:o("predict.filter.minLiquidity"),children:jsx(hn,{options:g,selected:i.minLiquidity,onSelect:h=>u("minLiquidity",h)})})]}),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:a,children:o("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[o("predict.filter.showResults"),d>0&&jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function gn({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 Mc({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 hn({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var yi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},vi={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Ac=["start_time","volume","liquidity","ending_soon"],xi={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"},Fc={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 ki({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:l}=useTranslation(),[a,c]=useState(false),u=useRef(null),d=useCallback(p=>{u.current&&!u.current.contains(p.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)),[d]),useEffect(()=>{if(!a)return;let p=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[a]);let m=bi[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:u,style:{position:"relative"},children:[jsxs("button",{type:"button",style:xi,onMouseEnter:p=>{p.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:p=>{p.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(p=>!p),children:[jsx(Bc,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l(vi[e])}),jsx(zc,{open:a})]}),a&&jsx("div",{style:{...Fc,width:224,padding:4},children:Ac.map(p=>{let f=bi[p],g=e===p;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:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===p?n(!r):t(p),c(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:l(vi[p])}),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"})})]},p)})})]}),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:p=>{p.currentTarget.style.background="rgba(39,39,42,1)",p.currentTarget.style.color="#fff";},onMouseLeave:p=>{p.currentTarget.style.background="rgba(39,39,42,0.6)",p.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:xi,onMouseEnter:p=>{p.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:p=>{p.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(Hc,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l("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 bi={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Bc(){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 Hc(){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 zc({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 Ni(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:s,error:l,hasNextPage:a,fetchNextPage:c,refetch:u}=useInfiniteEvents(t),d=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{c();},[c]),p=useCallback(()=>{u();},[u]);return {data:d,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:l??null,hasMore:a??false,fetchMore:m,refetch:p}}var Pi=`
|
|
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}}
|
|
@@ -14,7 +14,7 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
14
14
|
.evt-skel-hero-wrap{padding:40px 16px 32px}
|
|
15
15
|
@media(min-width:640px){.evt-skel-hero-wrap{padding:48px 24px 40px}}
|
|
16
16
|
@media(min-width:1024px){.evt-skel-hero-wrap{padding:52px 32px 44px}}
|
|
17
|
-
`,Ci={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
|
|
17
|
+
`,Ci={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 ct(e){return {...Ci,animationDelay:`${e}ms`}}function Xn({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Pi}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Uc,{index:r},r))})]})}function Uc({index:e}){let t=e*120,r={...Ci,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 Kc(){return jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)",width:"100vw",marginLeft:"calc(-50vw + 50%)"},children:[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",pointerEvents:"none"}}),jsx("div",{className:"evt-skel-hero-wrap",style:{position:"relative",zIndex:1,maxWidth:1152,margin:"0 auto"},children:jsxs("div",{className:"evt-skel-hero-outer",children:[jsxs("div",{className:"evt-skel-hero-left",style:{minWidth:0,flex:1,gap:16},children:[jsx("div",{style:{...ct(0),width:120,height:28,borderRadius:9999}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...ct(50),width:280,height:28,borderRadius:8}}),jsx("div",{style:{...ct(80),width:200,height:28,borderRadius:8}})]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[jsx("div",{style:{...ct(120),height:14,width:360,maxWidth:"100%"}}),jsx("div",{style:{...ct(150),height:14,width:300,maxWidth:"100%"}})]})]}),jsx("div",{className:"evt-skel-stat-grid",children:[0,1,2,3].map(e=>jsxs("div",{style:{padding:"14px 16px",background:"rgba(255,255,255,0.02)",borderRight:e%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:e<2?"1px solid rgba(39,39,42,0.4)":"none"},children:[jsx("div",{style:{...ct(200+e*60),height:22,width:56,borderRadius:4}}),jsx("div",{style:{...ct(230+e*60),height:14,width:64,borderRadius:4,marginTop:4}})]},e))})]})})]})}function Vc(){return jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid rgba(39,39,42,0.3)",background:"rgba(10,10,11,0.8)"},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:{...ct(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...ct(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...ct(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...ct(100),height:36,width:80,borderRadius:10}})]})]})}function Th({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:Pi}),jsx(Kc,{}),jsx(Vc,{}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx(Xn,{count:e})})]})}var Mi=3,ed={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)"}},td={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Zn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ri={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},rd={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Mr=[{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 Ei(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 nd(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Zn,rd];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Zn,Ri];let r=t[0]??"",n=t[1]??"",o=Ei(r)%Mr.length,i=Ei(n)%Mr.length;return i===o&&(i=(i+1)%Mr.length),[Mr[o],Mr[i]]}function od(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Ii(e){let t=od(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Oi(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Ti(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Li(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 id(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 ad=`
|
|
18
18
|
.badge-shine { position: relative; overflow: hidden; }
|
|
19
19
|
.badge-shine::after {
|
|
20
20
|
content: "";
|
|
@@ -38,13 +38,13 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
38
38
|
outline: 2px solid hsl(var(--heroui-primary) / 0.4);
|
|
39
39
|
outline-offset: 2px;
|
|
40
40
|
}
|
|
41
|
-
`;function Di({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[s,l]=useState(null),a=e.markets??[],u=useMemo(()=>a.length>2?[...a].sort((x,P)=>(P.outcomes?.[0]?.price??0)-(x.outcomes?.[0]?.price??0)):a,[a]).filter(x=>x.status==="open"),d=u.length===1,m=u.slice(0,Mi),p=u.length-Mi,f=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=s?u.find(x=>x.slug===s)??null:null,h=!!g||d,v=()=>{h||n?.(e);},S=x=>{x.stopPropagation(),g&&(x.preventDefault(),l(null));},N=x=>{x.stopPropagation(),t||(x.preventDefault(),n?.(e));},T=d?jsx(xd,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:n}):g?jsx(yd,{onCollapse:()=>l(null)}):jsx(fd,{moreCount:p,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:N});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:h?void 0:"pointer"},onMouseEnter:x=>{let P=x.currentTarget,k=ed[e.source]??td;P.style.borderColor=k.border,P.style.boxShadow=k.shadow,i?.(e);},onMouseLeave:x=>{let P=x.currentTarget;P.style.borderColor="rgba(39,39,42,0.6)",P.style.boxShadow="none";},onClick:v,children:[jsx("style",{children:ad}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(sd,{event:e,href:t,LinkComponent:r,onClick:S,isExpanded:h}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:d?jsx(vd,{market:u[0],event:e,onSelectOutcome:o}):g?jsx(bd,{market:g,event:e,onCollapse:()=>l(null),onSelectOutcome:o}):jsx(md,{displayedMarkets:m,onMarketClick:x=>l(x.slug)})})]}),jsx(gd,{children:T})]})}function sd({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?id(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:n,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn$1("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",o&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(cd,{event:e})]})}function ld(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(o>0&&o<=s){let l=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:l});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function cd({event:e}){let t=useMemo(()=>ld(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(dd,{},n);case "crypto-short":return jsx(pd,{label:r.label,color:r.color},n);case "closed":return jsx(ud,{},n)}})})}function dd(){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 pd({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 ud(){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 md({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=Ii(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:o=>{o.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Oi(n)}),jsx(hd,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function fd({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(Fi,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx(Bi,{source:r})]})]})}function gd({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 _i({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:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","2px"),a.style.transform="translateY(2px)";},onMouseLeave:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","4px"),a.style.transform="translateY(0px)";},onClick:n,children:o})}function Ai({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[s,l]=n?nd(e):[Zn,Ri],a=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",u=o==="label"&&a===c?"action":o,d=u==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${Ti(e)}\xA2`:i("predict.market.action.yes",{price:Ti(e)}),m=u==="label"?`${e.outcomes?.[1]?.label??"No"} ${Li(e)}\xA2`:i("predict.market.action.no",{price:Li(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(_i,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:p=>{p.stopPropagation(),r?.(t,e,"yes");},children:d}),jsx(_i,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:p=>{p.stopPropagation(),r?.(t,e,"no");},children:m})]})}function hd(){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 vd({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Ai,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function xd({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:l=>{l.stopPropagation(),r||(l.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsx(Fi,{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(Bi,{source:e.source})]})]})}function bd({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Ii(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Oi(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Ai,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function yd({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(kd,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Fi({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 kd({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 Bi({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 Pd=8;function zi({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:s,LinkComponent:l,onHover:a}){let{t:c}=useTranslation(),u=useRef(null);useEffect(()=>{let p=u.current;if(!p)return;let f=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return f.observe(p),()=>f.disconnect()},[t,r,n]);let d=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
|
|
41
|
+
`;function Di({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[s,l]=useState(null),a=e.markets??[],u=useMemo(()=>a.length>2?[...a].sort((x,P)=>(P.outcomes?.[0]?.price??0)-(x.outcomes?.[0]?.price??0)):a,[a]).filter(x=>x.status==="open"),d=u.length===1,m=u.slice(0,Mi),p=u.length-Mi,f=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=s?u.find(x=>x.slug===s)??null:null,h=!!g||d,v=()=>{h||n?.(e);},S=x=>{x.stopPropagation(),g&&(x.preventDefault(),l(null));},w=x=>{x.stopPropagation(),t||(x.preventDefault(),n?.(e));},T=d?jsx(xd,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:n}):g?jsx(yd,{onCollapse:()=>l(null)}):jsx(fd,{moreCount:p,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:w});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:h?void 0:"pointer"},onMouseEnter:x=>{let P=x.currentTarget,k=ed[e.source]??td;P.style.borderColor=k.border,P.style.boxShadow=k.shadow,i?.(e);},onMouseLeave:x=>{let P=x.currentTarget;P.style.borderColor="rgba(39,39,42,0.6)",P.style.boxShadow="none";},onClick:v,children:[jsx("style",{children:ad}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(sd,{event:e,href:t,LinkComponent:r,onClick:S,isExpanded:h}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:d?jsx(vd,{market:u[0],event:e,onSelectOutcome:o}):g?jsx(bd,{market:g,event:e,onCollapse:()=>l(null),onSelectOutcome:o}):jsx(md,{displayedMarkets:m,onMarketClick:x=>l(x.slug)})})]}),jsx(gd,{children:T})]})}function sd({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?id(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:n,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn$1("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",o&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(cd,{event:e})]})}function ld(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(o>0&&o<=s){let l=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:l});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function cd({event:e}){let t=useMemo(()=>ld(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(dd,{},n);case "crypto-short":return jsx(pd,{label:r.label,color:r.color},n);case "closed":return jsx(ud,{},n)}})})}function dd(){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 pd({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 ud(){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 md({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=Ii(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:o=>{o.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Oi(n)}),jsx(hd,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function fd({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(Fi,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx(Bi,{source:r})]})]})}function gd({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 _i({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:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","2px"),a.style.transform="translateY(2px)";},onMouseLeave:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","4px"),a.style.transform="translateY(0px)";},onClick:n,children:o})}function Ai({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[s,l]=n?nd(e):[Zn,Ri],a=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",u=o==="label"&&a===c?"action":o,d=u==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${Ti(e)}\xA2`:i("predict.market.action.yes",{price:Ti(e)}),m=u==="label"?`${e.outcomes?.[1]?.label??"No"} ${Li(e)}\xA2`:i("predict.market.action.no",{price:Li(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(_i,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:p=>{p.stopPropagation(),r?.(t,e,"yes");},children:d}),jsx(_i,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:p=>{p.stopPropagation(),r?.(t,e,"no");},children:m})]})}function hd(){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 vd({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Ai,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function xd({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:l=>{l.stopPropagation(),r||(l.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsx(Fi,{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(Bi,{source:e.source})]})]})}function bd({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Ii(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Oi(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Ai,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function yd({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(kd,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Fi({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 kd({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 Bi({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 Pd=8;function zi({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:s,LinkComponent:l,onHover:a}){let{t:c}=useTranslation(),u=useRef(null);useEffect(()=>{let p=u.current;if(!p)return;let f=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return f.observe(p),()=>f.disconnect()},[t,r,n]);let d=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
|
|
42
42
|
@keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
43
43
|
@keyframes evt-load-spin{to{transform:rotate(360deg)}}
|
|
44
44
|
@media(max-width:767px){.evt-card-grid{grid-template-columns:1fr!important}}
|
|
45
45
|
@media(min-width:768px) and (max-width:1023px){.evt-card-grid{grid-template-columns:repeat(2,1fr)!important}}
|
|
46
46
|
@media(min-width:1024px) and (max-width:1279px){.evt-card-grid{grid-template-columns:repeat(3,1fr)!important}}
|
|
47
|
-
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((p,f)=>p==null?null:jsx("div",{style:{padding:Pd,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${f%4*35}ms both`},children:jsx(Di,{event:p,href:s?.(p),LinkComponent:l,onSelect:o,onSelectOutcome:i,onHover:a})},`${p.source}-${p.slug}`))}),jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),c("predict.events.loadMore")]})}),m&&jsx(Cd,{onScrollToTop:d})]})}function Cd({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 Wi({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c,markets_limit:u,onSelect:d,onSelectOutcome:m,getEventHref:p,LinkComponent:f,onHover:g}){let{data:h,hasMore:v,fetchMore:S,isFetching:
|
|
47
|
+
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((p,f)=>p==null?null:jsx("div",{style:{padding:Pd,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${f%4*35}ms both`},children:jsx(Di,{event:p,href:s?.(p),LinkComponent:l,onSelect:o,onSelectOutcome:i,onHover:a})},`${p.source}-${p.slug}`))}),jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),c("predict.events.loadMore")]})}),m&&jsx(Cd,{onScrollToTop:d})]})}function Cd({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 Wi({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c,markets_limit:u,onSelect:d,onSelectOutcome:m,getEventHref:p,LinkComponent:f,onHover:g}){let{data:h,hasMore:v,fetchMore:S,isFetching:w,isFetchingMore:T}=Ni({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c,markets_limit:u});return w?jsx(Xn,{count:24}):jsx(zi,{events:h,hasMore:v,isFetchingMore:T,onFetchMore:S,onSelect:d,onSelectOutcome:m,getEventHref:p,LinkComponent:f,onHover:g})}function rv({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i}){let[s,l]=useState({categorySlug:null,tagSlug:null}),[a,c]=useState(qn),{isOpen:u,onOpen:d,onClose:m}=useDisclosure(),{onOpen:p}=useAsyncModal(Pr),f=useCallback((P,k,Q)=>{t?.(P,k,Q),p({params:{event:P,market:k,initialOutcome:Q}});},[t,p]),g=useCallback(P=>{l(P);},[]),h=useCallback(P=>{c(k=>({...k,sortPreset:P}));},[]),v=useCallback(P=>{c(k=>({...k,sortAsc:P}));},[]),S=useCallback(P=>{c(P);},[]),w=useMemo(()=>yi[a.sortPreset].sort_by,[a.sortPreset]),T=useMemo(()=>Qn(a),[a]),x=useMemo(()=>jsx(ki,{sortPreset:a.sortPreset,onSortChange:h,sortAsc:a.sortAsc,onSortAscChange:v,onFilterPress:d,filterCount:T}),[a.sortPreset,a.sortAsc,T,h,v,d]);return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx(Jo,{onSelect:g,trailing:x})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(gi,{isOpen:u,onClose:m,value:a,onChange:S}),jsx(Wi,{tagSlugSelection:s,sort_by:w,sort_asc:a.sortAsc,source:a.source,timeRemaining:a.timeRemaining,minVolume:a.minVolume,minLiquidity:a.minLiquidity,onSelect:e,onSelectOutcome:f,getEventHref:r,LinkComponent:n,onHover:o})]}),jsx(mn,{})]})}function Vi(e){return e>=1e9?`$${(e/1e9).toFixed(1)}B`:e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}var Ld=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>e.toLocaleString(),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:Vi,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:Vi,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=>e.toLocaleString(),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function av({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
48
48
|
@keyframes evt-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
49
49
|
@keyframes evt-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
50
50
|
@keyframes evtHeroTitleEnter{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -82,15 +82,15 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
82
82
|
.evt-stat-label{font-size:11px;line-height:16px;min-height:16px;white-space:nowrap}
|
|
83
83
|
@media(min-width:640px){.evt-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
84
84
|
`}),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(`
|
|
85
|
-
`).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:Ld.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 Qi({market:e,initialOutcome:t="yes"}){let{t:r}=useTranslation(),{status:n}=useAuth(),o=useWallets(),i=useSwitchChain(),s=usePredictClient(),l=useContext(PolymarketContext),a=useQueryClient(),c=e.source,u=c==="polymarket",d=o.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected),m=o.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),p=n==="authenticated",f=d?.address,g=m?.address,h=useMemo(()=>{if(c!=="polymarket")return;let M=e.provider_meta?.["polymarket.clobTokenIds"];return M?(typeof M=="string"?JSON.parse(M):M)[0]:void 0},[c,e.provider_meta]),{data:v,isLoading:S}=useTickSize(h),N=v?.minimum_tick_size?String(v.minimum_tick_size):"0.01",{data:T,isLoading:x}=useFeeRate(h),P=String(T?.base_fee??0),[k,Q]=useState(t),[z,J]=useState("market"),[w,B]=useState(NaN),[E,I]=useState(NaN),[de,U]=useState(false),[b,y]=useState(false),[V,j]=useState(null),[G,pe]=useState(null),[Se,it]=useState(false),[he,Be]=useState(false),[He,xt]=useState("1h"),[ve,Ke]=useState(30),[tt,rt]=useState("minutes"),we=false,A=null,ge;try{let M=wr();we=M.kalshiKycVerified,A=M.kalshiKycUrl,ge=M.polymarketSafeAddress;}catch{}let Oe=useCallback(async()=>{if(!m||!l)return null;let M=await m.getEip1193Provider();if(!M)return null;let xe=!!ge,Ve={address:m.address,signatureType:xe?2:0,signTypedData:async(De,nt,We,Pt)=>{let ue=[];"name"in De&&ue.push({name:"name",type:"string"}),"version"in De&&ue.push({name:"version",type:"string"}),"chainId"in De&&ue.push({name:"chainId",type:"uint256"}),"verifyingContract"in De&&ue.push({name:"verifyingContract",type:"address"}),"salt"in De&&ue.push({name:"salt",type:"bytes32"});let Ht={EIP712Domain:ue,...nt};return await M.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:De,types:Ht,primaryType:We,message:Pt})]})}};return l.credentials??await l.authenticate(Ve)},[ge,m,l]),ze=useMemo(()=>{let M=k==="yes"?0:1,xe=e.outcomes[M];return xe?.best_bid??xe?.price??.5},[e.outcomes,k]),R=c==="kalshi"?f??"":g??"",{data:Ee,isLoading:bt}=usePositions({source:c,user:R},{enabled:!!R,refetchInterval:3e4}),Bn=useCallback(async()=>{let M=await Oe();return M?await buildPolymarketL2Headers(M.address,{apiKey:M.apiKey,secret:M.secret,passphrase:M.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Oe]),{data:pt,isLoading:jt}=useAvailableShares({source:c,user:R,market:e.slug,side:k},c==="polymarket"?{getHeaders:Bn}:void 0,{enabled:!!R&&!!e.slug,refetchOnMount:"always"}),sr=pt?.total_shares??0,Yt=pt?.active_order_shares??0,Ot=pt?.available_shares??0,$e=pt?.precision??(c==="polymarket"?4:0),Ur=jt||bt,lr=e.provider_meta?.["dflow.yesMint"]??"",Hn=e.provider_meta?.["dflow.noMint"]??"",ut=SOLANA_TOKENS.stablecoins.USDC.address,Kr=e.provider_meta?.["dflow.collateralMint"]||"",Vr=k==="yes"?lr:Hn,jr=useMemo(()=>Ee?Ee.positions.find(M=>M.side?.toLowerCase()===k&&M.market?.slug===e.slug)??null:null,[Ee,e.slug,k])?.market?.provider_meta,zn=jr?.["dflow.outcomeMint"]||Vr,mt=jr?.["dflow.collateralMint"]||Kr,yt=zn,Dt=mt||ut,At=useMemo(()=>isNaN(w)||w<=0?"0":String(Math.round(w*1e6)),[w]),Yr=c==="kalshi"&&!!yt&&!!Dt&&!!f&&At!=="0",{refetch:kr}=useDFlowQuote({inputMint:yt,outputMint:Dt,amount:At,userPublicKey:f??"",slippageBps:100},{enabled:Yr}),$n=useMemo(()=>isNaN(w)||w<=0?0:w,[w]),O=useMemo(()=>{if(isNaN(w)||w<=0)return 0;let M=z==="limit"&&u&&!isNaN(E)?E:ze;return w*M},[w,z,u,E,ze]),Te=useCallback(M=>{Q(M),I(NaN),B(NaN),y(false);},[]),at=useCallback(M=>{J(M);},[]);useEffect(()=>{z==="limit"&&I(Math.round(ze*100)/100);},[z,k]);let cr=useCallback(M=>{if(y(false),isNaN(M)){B(NaN);return}B(Ne(Math.max(0,M),$e));},[$e]),Ft=useCallback(()=>{y(true),B(Ne(Ot,$e));},[Ot,$e]),kt=useCallback(M=>{if(isNaN(M)){I(NaN);return}let xe=Math.max(.01,Math.min(.99,M));I(Math.round(xe*100)/100);},[]),St=useCallback(()=>{B(NaN),I(NaN),J("market"),y(false),Be(false),xt("1h"),Ke(30),rt("minutes");},[]),Bt=useMemo(()=>{let M=[];return isNaN(w)||w<=0?M.push(r("predict.trade.minQuantity",{amount:on})):w<on&&M.push(r("predict.trade.minQuantity",{amount:on})),e.status!=="open"&&M.push(r("predict.trade.marketNotActive")),!isNaN(w)&&w>0&&!b&&w>Ot&&M.push(r("predict.trade.insufficientSharesDetail",{total:Ne(sr,$e).toFixed($e),active:Ne(Yt,$e).toFixed($e),available:Ne(Ot,$e).toFixed($e)})),z==="limit"&&u&&(isNaN(E)||E<.01||E>.99)&&M.push(r("predict.trade.limitPriceRange")),z==="limit"&&u&&he&&He==="custom"&&(isNaN(ve)||ve<=0)&&M.push(r("predict.trade.expiration.invalidDate")),{isValid:M.length===0,errors:M}},[w,e.status,Ot,sr,Yt,b,z,u,E,he,He,ve,$e,r]),{mutateAsync:wt}=useDFlowSubmit(),{data:dr}=useOrder({id:V??"",source:c},{enabled:!!V}),Gr=useCallback(async()=>{if(!G||!f||!d)return;let{cashAmount:M,collateral:xe}=G;pe(null);try{let De=(await s.createDFlowQuote({inputMint:xe,outputMint:ut,amount:M,userPublicKey:f,slippageBps:100}))?.transaction;if(!De)return;let nt=Uint8Array.from(atob(De),Pt=>Pt.charCodeAt(0)),We=await d.signTransaction(nt);await wt({signedTransaction:btoa(String.fromCharCode(...We)),orderContext:{user_public_key:f,input_mint:xe,output_mint:ut,amount:M,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[G,f,d,s,wt,ut]),Nt=useCallback(()=>{a.invalidateQueries({queryKey:["predict","positions"]}),a.invalidateQueries({queryKey:["predict","orders"]}),a.invalidateQueries({queryKey:["predict","available-shares"]});},[a]);useEffect(()=>{if(!dr||!V)return;let{status:M}=dr;M==="closed"?(j(null),G?Gr().finally(()=>{U(false),toast.success(r("predict.trade.submitSuccess")),Qt(),Nt(),St();}):(U(false),toast.success(r("predict.trade.submitSuccess")),Qt(),Nt(),St())):(M==="failed"||M==="expired")&&(U(false),j(null),pe(null),toast.error(r("predict.trade.submitError")));},[dr,V,G,Gr,Nt,St,r]);let qr=useCallback(async()=>{if(!f||!d)return;if(!yt||!Dt){toast.error("Missing token mint addresses"),U(false);return}if(!we){it(true),U(false);return}let Ve=(await kr()).data,De=Ve?.transaction;if(!De){toast.error(r("predict.trade.submitError")),U(false);return}if(mt&&mt!==ut){let ue=String(Ve?.outAmount??"");ue&&ue!=="0"&&pe({cashAmount:ue,collateral:mt});}let nt=Uint8Array.from(atob(De),ue=>ue.charCodeAt(0)),We=await d.signTransaction(nt),Pt=await wt({signedTransaction:btoa(String.fromCharCode(...We)),orderContext:{user_public_key:f,input_mint:yt,output_mint:Dt,amount:At,price:String(ze),side:"SELL",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});j(Pt.signature);},[f,d,kr,wt,yt,Dt,At,ze,k,e.slug,mt,ut,r,we]),Qr=useCallback(async()=>{if(!m||!l)return;let M=m.chain,xe=M!==Chain.POLYGON;xe&&await i(Chain.POLYGON);try{let Ve=await m.getEip1193Provider();if(!Ve){toast.error(r("predict.trade.submitError")),U(!1);return}let De=!!ge,nt={address:m.address,signatureType:De?2:0,signTypedData:async(Gt,al,sl,ll)=>{let pr=[];"name"in Gt&&pr.push({name:"name",type:"string"}),"version"in Gt&&pr.push({name:"version",type:"string"}),"chainId"in Gt&&pr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Gt&&pr.push({name:"verifyingContract",type:"address"}),"salt"in Gt&&pr.push({name:"salt",type:"bytes32"});let cl={EIP712Domain:pr,...al};return await Ve.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Gt,types:cl,primaryType:sl,message:ll})]})}},We=await Oe();if(!We){toast.error(r("predict.trade.submitError")),U(!1);return}let Pt=k==="yes"?0:1,ue="",Ht=e.provider_meta?.["polymarket.clobTokenIds"];Ht&&(ue=(typeof Ht=="string"?JSON.parse(Ht):Ht)[Pt]??"");let Jr=e.provider_meta?.["polymarket.negRisk"]??!1,Wn=z==="limit"&&!isNaN(E)?E:ze,zt=ln(Wn,N),Uo={tokenId:ue,price:zt,size:w,side:"SELL",orderType:z==="limit"?he?"GTD":"GTC":"FOK",tickSize:N,negRisk:Jr,...ge&&{funderAddress:ge},...z==="limit"&&he&&{expiration:sn(He,ve,tt)}},tl=buildCtfExchangeDomain(Jr),Ko=buildOrderMessage({...Uo,signerAddress:nt.address,signatureType:nt.signatureType,feeRateBps:P}),rl=await nt.signTypedData(tl,CTF_ORDER_TYPES,"Order",Ko),nl=buildSignedOrder(Ko,rl,Uo.orderType),Vo=buildClobPayload(nl,We.apiKey),ol=JSON.stringify(Vo),il=await buildPolymarketL2Headers(We.address,{apiKey:We.apiKey,secret:We.secret,passphrase:We.passphrase,method:"POST",requestPath:"/order",body:ol});await s.createPolymarketOrder(Vo,il),Nt(),toast.success(r("predict.trade.submitSuccess")),Qt(),St(),U(!1);}finally{xe&&M&&i(M).catch(()=>{});}},[m,l,Oe,i,k,e.provider_meta,z,E,ze,w,s,Nt,he,He,ve,tt,St,r,N,P,e.slug]),Xr=useCallback(async()=>{if(!(!Bt.isValid||!p)){U(true),j(null),it(false);try{c==="kalshi"?await qr():await Qr();}catch(M){let xe=M instanceof Error?M.message:"",Ve=c==="polymarket"&&xe?cn(xe,r,"sell"):xe||void 0;toast.error(Ve||r("predict.trade.submitError")),U(false);}}},[Bt.isValid,p,c,qr,Qr,r]);return {outcome:k,orderType:z,quantity:w,limitPrice:E,shares:$n,estimatedReturn:O,isMarketDataLoading:c==="polymarket"&&(x||S),isSubmitting:de,validation:Bt,supportsLimitOrder:u,kycRequired:Se,kycUrl:A,totalShares:sr,activeOrderShares:Yt,availableShares:Ot,isAvailableLoading:Ur,isSellAll:b,precision:$e,expirationEnabled:he,expirationPreset:He,customDuration:ve,customDurationUnit:tt,setOutcome:Te,setOrderType:at,setQuantity:cr,setLimitPrice:kt,setSellAll:Ft,setExpirationEnabled:Be,setExpirationPreset:xt,setCustomDuration:Ke,setCustomDurationUnit:rt,submit:Xr}}var ap=["5m","1h","12h","24h","eod","custom"],sp={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},lp=["minutes","hours","days"],cp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},dp={maximumFractionDigits:0};function ia({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,estimatedReturn:l,isMarketDataLoading:a,isSubmitting:c,isValid:u,validationErrors:d,supportsLimitOrder:m,kycRequired:p,kycUrl:f,totalShares:g,activeOrderShares:h,availableShares:v,isAvailableLoading:S,precision:N,expirationEnabled:T,expirationPreset:x,customDuration:P,customDurationUnit:k,onOutcomeChange:Q,onOrderTypeChange:z,onQuantityChange:J,onLimitPriceChange:w,onSellAll:B,onExpirationEnabledChange:E,onExpirationPresetChange:I,onCustomDurationChange:de,onCustomDurationUnitChange:U,onSubmit:b}){let{t:y}=useTranslation(),[V,j]=useState(false),G=useDisclosure(),[pe,Se]=useState(""),it=useRef(false);useEffect(()=>{it.current||Se(isNaN(i)?"":String(i));},[i]);let[he,Be]=useState(""),He=useRef(false);useEffect(()=>{He.current||(isNaN(s)?Be(""):Be(String(parseFloat((s*100).toFixed(2)))));},[s]);let xt=useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Be(A),A===""||A==="."){w(NaN);return}let Oe=parseFloat(A);isNaN(Oe)||w(Oe/100);},[w]),ve=useCallback(A=>{let ge=new RegExp(`^\\d*\\.?\\d{0,${N}}$`);if(A!==""&&!ge.test(A))return;if(Se(A),j(false),A===""||A==="."){J(NaN);return}let Oe=parseFloat(A);isNaN(Oe)||J(Oe);},[J,N]);useEffect(()=>{p&&!G.isOpen&&G.onOpen();},[p]);let Ke=useMemo(()=>{let A=n==="yes"?t.yesBid:t.noBid;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),tt=!isNaN(i)&&i>0,rt=useMemo(()=>{if(S)return y("predict.trade.loadingBalance");if(a)return y("predict.trade.loadingMarketData");if(c)return y("predict.trade.submitting");if(p)return y("predict.trade.kycRequired");if(!tt)return y("predict.trade.enterAmount");let A=y(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${y("predict.trade.sell")} ${A}`},[S,a,c,p,tt,n,y]),we=()=>{if(p){G.onOpen();return}if(!u){j(true);return}j(false),b();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[y("predict.trade.sell")," ",y(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[m?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>z(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:y("predict.trade.market")},"market"),jsx(Tab,{title:y("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.market")}),o==="limit"&&m?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:he,onChange:A=>xt(A.target.value),onFocus:()=>{He.current=true;},onBlur:()=>{He.current=false,isNaN(s)?Be(""):Be(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ke!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ke," \xA2"]})]}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(A=>{let ge=Math.pow(10,N);return jsxs("button",{type:"button",onClick:()=>{J(Math.floor(v*A/100*ge)/ge);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:[A,"%"]},A)}),jsx("button",{type:"button",onClick:B,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:pe,onChange:A=>ve(A.target.value),onFocus:()=>{it.current=true;},onBlur:()=>{it.current=false,Se(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),V&&d.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:d.map(A=>jsx("span",{className:"text-xs text-danger",children:A},A))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:S?"\u2013":`${Ne(g,N).toFixed(N)}${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:S?"\u2013":h>0?`-${Ne(h,N).toFixed(N)}${y("predict.trade.sharesUnit")}`:`0${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:S?"\u2013":`${Ne(v,N).toFixed(N)}${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${l.toFixed(2)}`:"\u2013"})]})]}),o==="limit"&&m&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:y("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:T,onValueChange:E,"aria-label":y("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[x],onSelectionChange:A=>{let ge=Array.from(A)[0];ge&&I(ge);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:ap.map(A=>jsx(SelectItem,{children:y(sp[A])},A))}),x==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(P)?void 0:P,onValueChange:de,minValue:1,step:1,formatOptions:dp,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[k],onSelectionChange:A=>{let ge=Array.from(A)[0];ge&&U(ge);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:lp.map(A=>jsx(SelectItem,{children:y(cp[A])},A))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:S||a||!tt||c,isLoading:c||S||a,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:we,children:rt})]}),jsx(dn,{isOpen:G.isOpen,onClose:G.onClose,kycUrl:f})]})}function vn({event:e,market:t,variant:r,initialOutcome:n,chain:o}){let{outcome:i,orderType:s,quantity:l,limitPrice:a,estimatedReturn:c,isMarketDataLoading:u,isSubmitting:d,validation:m,supportsLimitOrder:p,kycRequired:f,kycUrl:g,totalShares:h,activeOrderShares:v,availableShares:S,isAvailableLoading:N,precision:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,setOutcome:z,setOrderType:J,setQuantity:w,setLimitPrice:B,setSellAll:E,setExpirationEnabled:I,setExpirationPreset:de,setCustomDuration:U,setCustomDurationUnit:b,submit:y}=Qi({market:t,initialOutcome:n}),V=useAuthCallback(y),j=useMemo(()=>e?en(e):void 0,[e]),G=useMemo(()=>tn(t),[t]);return jsx(ia,{event:j,market:G,variant:r,outcome:i,orderType:s,quantity:l,limitPrice:a,estimatedReturn:c,isMarketDataLoading:u,isSubmitting:d,isValid:m.isValid,validationErrors:m.errors,supportsLimitOrder:p,kycRequired:f,kycUrl:g,totalShares:h,activeOrderShares:v,availableShares:S,isAvailableLoading:N,precision:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,onOutcomeChange:z,onOrderTypeChange:J,onQuantityChange:w,onLimitPriceChange:B,onSellAll:E,onExpirationEnabledChange:I,onExpirationPresetChange:de,onCustomDurationChange:U,onCustomDurationUnitChange:b,onSubmit:V})}var io="predict-sell";function sa({id:e=io}){return jsx(AsyncModal,{id:e,children:t=>jsx(xp,{...t})})}function xp({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(vn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,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 lo=40,yn=36,Rr=480,co=Rr-yn;function da({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),s=useMemo(()=>e.markets?.map(d=>d.slug)??[],[e.markets]),{data:l}=usePositions({source:e.source,user:t??""}),a=useMemo(()=>!l?.positions||!t?0:s.length===0?l.positions.length:l.positions.filter(d=>d.market&&s.includes(d.market.slug)).length,[l?.positions,s,t]),u=[{key:"positions",label:a>0?`${n("predict.positions.title")} (${a})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:u.map(d=>jsx("button",{type:"button",onClick:()=>i(d.key),className:cn$1("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===d.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:d.label},d.key))}),t?jsxs("div",{style:{height:Rr},children:[o==="positions"&&jsx(Pp,{source:e.source,walletAddress:t,marketSlugs:s}),o==="orders"&&jsx(Mp,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),o==="trades"&&jsx(Lp,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Rr},children:n("predict.trade.connectWallet")})]})}function Pp({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=useTranslation(),{data:o,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(l=>l.market&&r.includes(l.market.slug)):[],[o?.positions,r]);return i?jsx(uo,{}):s.length===0?jsx(po,{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:yn},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:co},rowComponent:Cp,rowCount:s.length,rowHeight:lo,rowProps:{positions:s,closeLabel:n("predict.positions.close")}})]})}function Cp({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,s=o.pnl_percent??0,l=o.avg_price??0,a=o.current_price??0,c=i>0?"text-success":i<0?"text-danger":"text-foreground",u=i>0?"+":"",d=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",m=o.side,p=o.size,f=o.size*a,g=o.market?.end_at?Ip(o.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:d}),jsx("span",{className:cn$1("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:xn(l)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:xn(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[u,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",u,s.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.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 Mp({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=useTranslation(),{data:i,isLoading:s,fetchNextPage:l,hasNextPage:a}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),u=useMemo(()=>{let v=i?.pages?.flatMap(T=>T.items)??[],S=new Set(["live","open","submitted","pending"]),N=v.filter(T=>S.has(T.status));return r.length>0&&(N=N.filter(T=>T.market_id&&r.includes(T.market_id))),N},[i?.pages,r]),d=useCallback(v=>{n?n(v.id):c.mutate({source:v.source,id:v.id});},[n,c]),m=u.length,p=m+(a?1:0),f=useCallback(v=>v<m,[m]),g=useCallback(async()=>{await l();},[l]),h=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:p,threshold:5});return s?jsx(uo,{}):u.length===0&&!a?jsx(po,{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:yn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:co},onRowsRendered:h,rowComponent:Ep,rowCount:p,rowHeight:lo,rowProps:{orders:u,itemCount:m,onCancel:d,isCancelling:c.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Ep({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:s}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let l=r[e];if(!l)return null;let a=l.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",a?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:l.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?xn(parseFloat(l.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Tp,{status:l.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>o(l),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function Tp({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 Lp({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),l=useMemo(()=>n?.pages?.flatMap(p=>p.items)??[],[n?.pages]),a=l.length,c=a+(s?1:0),u=useCallback(p=>p<a,[a]),d=useCallback(async()=>{await i();},[i]),m=useInfiniteLoader({isRowLoaded:u,loadMoreRows:d,rowCount:c,threshold:5});return o?jsx(uo,{}):l.length===0&&!s?jsx(po,{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:yn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:co},onRowsRendered:m,rowComponent:_p,rowCount:c,rowHeight:lo,rowProps:{trades:l,itemCount:a}})]})}function _p({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",s=Rp(o.timestamp),l=o.price??0,a=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:xn(l)}),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:["$",a.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function po({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Rr},children:e})}function uo(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Rr},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function xn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Rp(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${i}`}function Ip(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var pa=`
|
|
85
|
+
`).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:Ld.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 Qi({market:e,initialOutcome:t="yes"}){let{t:r}=useTranslation(),{status:n}=useAuth(),o=useWallets(),i=useSwitchChain(),s=usePredictClient(),l=useContext(PolymarketContext),a=useQueryClient(),c=e.source,u=c==="polymarket",d=o.find(M=>M.chainNamespace===ChainNamespace.SOLANA&&M.isConnected),m=o.find(M=>M.chainNamespace===ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),p=n==="authenticated",f=d?.address,g=m?.address,h=useMemo(()=>{if(c!=="polymarket")return;let M=e.provider_meta?.["polymarket.clobTokenIds"];return M?(typeof M=="string"?JSON.parse(M):M)[0]:void 0},[c,e.provider_meta]),{data:v,isLoading:S}=useTickSize(h),w=v?.minimum_tick_size?String(v.minimum_tick_size):"0.01",{data:T,isLoading:x}=useFeeRate(h),P=String(T?.base_fee??0),[k,Q]=useState(t),[z,J]=useState("market"),[N,B]=useState(NaN),[E,I]=useState(NaN),[de,U]=useState(false),[b,y]=useState(false),[V,j]=useState(null),[G,pe]=useState(null),[Se,it]=useState(false),[he,Be]=useState(false),[He,xt]=useState("1h"),[ve,Ke]=useState(30),[tt,rt]=useState("minutes"),we=false,A=null,ge;try{let M=wr();we=M.kalshiKycVerified,A=M.kalshiKycUrl,ge=M.polymarketSafeAddress;}catch{}let Oe=useCallback(async()=>{if(!m||!l)return null;let M=await m.getEip1193Provider();if(!M)return null;let xe=!!ge,Ve={address:m.address,signatureType:xe?2:0,signTypedData:async(De,nt,We,Pt)=>{let ue=[];"name"in De&&ue.push({name:"name",type:"string"}),"version"in De&&ue.push({name:"version",type:"string"}),"chainId"in De&&ue.push({name:"chainId",type:"uint256"}),"verifyingContract"in De&&ue.push({name:"verifyingContract",type:"address"}),"salt"in De&&ue.push({name:"salt",type:"bytes32"});let Ht={EIP712Domain:ue,...nt};return await M.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:De,types:Ht,primaryType:We,message:Pt})]})}};return l.credentials??await l.authenticate(Ve)},[ge,m,l]),ze=useMemo(()=>{let M=k==="yes"?0:1,xe=e.outcomes[M];return xe?.best_bid??xe?.price??.5},[e.outcomes,k]),R=c==="kalshi"?f??"":g??"",{data:Ee,isLoading:bt}=usePositions({source:c,user:R},{enabled:!!R,refetchInterval:3e4}),Bn=useCallback(async()=>{let M=await Oe();return M?await buildPolymarketL2Headers(M.address,{apiKey:M.apiKey,secret:M.secret,passphrase:M.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Oe]),{data:at,isLoading:Yt}=useAvailableShares({source:c,user:R,market:e.slug,side:k},c==="polymarket"?{getHeaders:Bn}:void 0,{enabled:!!R&&!!e.slug,refetchOnMount:"always"}),sr=at?.total_shares??0,Gt=at?.active_order_shares??0,Ot=at?.available_shares??0,$e=useMemo(()=>c==="polymarket"?getPolymarketSharesPrecision(w):at?.precision??0,[c,w,at?.precision]),Ur=Yt||bt,lr=e.provider_meta?.["dflow.yesMint"]??"",Hn=e.provider_meta?.["dflow.noMint"]??"",ut=SOLANA_TOKENS.stablecoins.USDC.address,Kr=e.provider_meta?.["dflow.collateralMint"]||"",Vr=k==="yes"?lr:Hn,jr=useMemo(()=>Ee?Ee.positions.find(M=>M.side?.toLowerCase()===k&&M.market?.slug===e.slug)??null:null,[Ee,e.slug,k])?.market?.provider_meta,zn=jr?.["dflow.outcomeMint"]||Vr,mt=jr?.["dflow.collateralMint"]||Kr,yt=zn,Dt=mt||ut,At=useMemo(()=>isNaN(N)||N<=0?"0":String(Math.round(N*1e6)),[N]),Yr=c==="kalshi"&&!!yt&&!!Dt&&!!f&&At!=="0",{refetch:kr}=useDFlowQuote({inputMint:yt,outputMint:Dt,amount:At,userPublicKey:f??"",slippageBps:100},{enabled:Yr}),$n=useMemo(()=>isNaN(N)||N<=0?0:N,[N]),O=useMemo(()=>{if(isNaN(N)||N<=0)return 0;let M=z==="limit"&&u&&!isNaN(E)?E:ze;return N*M},[N,z,u,E,ze]),Te=useCallback(M=>{Q(M),I(NaN),B(NaN),y(false);},[]),st=useCallback(M=>{J(M);},[]);useEffect(()=>{z==="limit"&&I(Math.round(ze*100)/100);},[z,k]);let cr=useCallback(M=>{if(y(false),isNaN(M)){B(NaN);return}B(Ne(Math.max(0,M),$e));},[$e]),Ft=useCallback(()=>{y(true),B(Ne(Ot,$e));},[Ot,$e]),kt=useCallback(M=>{if(isNaN(M)){I(NaN);return}let xe=Math.max(.01,Math.min(.99,M));I(Math.round(xe*100)/100);},[]),St=useCallback(()=>{B(NaN),I(NaN),J("market"),y(false),Be(false),xt("1h"),Ke(30),rt("minutes");},[]),Bt=useMemo(()=>{let M=[];return isNaN(N)||N<=0?M.push(r("predict.trade.minQuantity",{amount:on})):N<on&&M.push(r("predict.trade.minQuantity",{amount:on})),e.status!=="open"&&M.push(r("predict.trade.marketNotActive")),!isNaN(N)&&N>0&&!b&&N>Ot&&M.push(r("predict.trade.insufficientSharesDetail",{total:Ne(sr,$e).toFixed($e),active:Ne(Gt,$e).toFixed($e),available:Ne(Ot,$e).toFixed($e)})),z==="limit"&&u&&(isNaN(E)||E<.01||E>.99)&&M.push(r("predict.trade.limitPriceRange")),z==="limit"&&u&&he&&He==="custom"&&(isNaN(ve)||ve<=0)&&M.push(r("predict.trade.expiration.invalidDate")),{isValid:M.length===0,errors:M}},[N,e.status,Ot,sr,Gt,b,z,u,E,he,He,ve,$e,r]),{mutateAsync:wt}=useDFlowSubmit(),{data:dr}=useOrder({id:V??"",source:c},{enabled:!!V}),Gr=useCallback(async()=>{if(!G||!f||!d)return;let{cashAmount:M,collateral:xe}=G;pe(null);try{let De=(await s.createDFlowQuote({inputMint:xe,outputMint:ut,amount:M,userPublicKey:f,slippageBps:100}))?.transaction;if(!De)return;let nt=Uint8Array.from(atob(De),Pt=>Pt.charCodeAt(0)),We=await d.signTransaction(nt);await wt({signedTransaction:btoa(String.fromCharCode(...We)),orderContext:{user_public_key:f,input_mint:xe,output_mint:ut,amount:M,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[G,f,d,s,wt,ut]),Nt=useCallback(()=>{a.invalidateQueries({queryKey:["predict","positions"]}),a.invalidateQueries({queryKey:["predict","orders"]}),a.invalidateQueries({queryKey:["predict","available-shares"]});},[a]);useEffect(()=>{if(!dr||!V)return;let{status:M}=dr;M==="closed"?(j(null),G?Gr().finally(()=>{U(false),toast.success(r("predict.trade.submitSuccess")),Xt(),Nt(),St();}):(U(false),toast.success(r("predict.trade.submitSuccess")),Xt(),Nt(),St())):(M==="failed"||M==="expired")&&(U(false),j(null),pe(null),toast.error(r("predict.trade.submitError")));},[dr,V,G,Gr,Nt,St,r]);let qr=useCallback(async()=>{if(!f||!d)return;if(!yt||!Dt){toast.error("Missing token mint addresses"),U(false);return}if(!we){it(true),U(false);return}let Ve=(await kr()).data,De=Ve?.transaction;if(!De){toast.error(r("predict.trade.submitError")),U(false);return}if(mt&&mt!==ut){let ue=String(Ve?.outAmount??"");ue&&ue!=="0"&&pe({cashAmount:ue,collateral:mt});}let nt=Uint8Array.from(atob(De),ue=>ue.charCodeAt(0)),We=await d.signTransaction(nt),Pt=await wt({signedTransaction:btoa(String.fromCharCode(...We)),orderContext:{user_public_key:f,input_mint:yt,output_mint:Dt,amount:At,price:String(ze),side:"SELL",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});j(Pt.signature);},[f,d,kr,wt,yt,Dt,At,ze,k,e.slug,mt,ut,r,we]),Qr=useCallback(async()=>{if(!m||!l)return;let M=m.chain,xe=M!==Chain.POLYGON;xe&&await i(Chain.POLYGON);try{let Ve=await m.getEip1193Provider();if(!Ve){toast.error(r("predict.trade.submitError")),U(!1);return}let De=!!ge,nt={address:m.address,signatureType:De?2:0,signTypedData:async(qt,al,sl,ll)=>{let pr=[];"name"in qt&&pr.push({name:"name",type:"string"}),"version"in qt&&pr.push({name:"version",type:"string"}),"chainId"in qt&&pr.push({name:"chainId",type:"uint256"}),"verifyingContract"in qt&&pr.push({name:"verifyingContract",type:"address"}),"salt"in qt&&pr.push({name:"salt",type:"bytes32"});let cl={EIP712Domain:pr,...al};return await Ve.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:qt,types:cl,primaryType:sl,message:ll})]})}},We=await Oe();if(!We){toast.error(r("predict.trade.submitError")),U(!1);return}let Pt=k==="yes"?0:1,ue="",Ht=e.provider_meta?.["polymarket.clobTokenIds"];Ht&&(ue=(typeof Ht=="string"?JSON.parse(Ht):Ht)[Pt]??"");let Jr=e.provider_meta?.["polymarket.negRisk"]??!1,Wn=z==="limit"&&!isNaN(E)?E:ze,zt=ln(Wn,w),Uo={tokenId:ue,price:zt,size:N,side:"SELL",orderType:z==="limit"?he?"GTD":"GTC":"FOK",tickSize:w,negRisk:Jr,...ge&&{funderAddress:ge},...z==="limit"&&he&&{expiration:sn(He,ve,tt)}},tl=buildCtfExchangeDomain(Jr),Ko=buildOrderMessage({...Uo,signerAddress:nt.address,signatureType:nt.signatureType,feeRateBps:P}),rl=await nt.signTypedData(tl,CTF_ORDER_TYPES,"Order",Ko),nl=buildSignedOrder(Ko,rl,Uo.orderType),Vo=buildClobPayload(nl,We.apiKey),ol=JSON.stringify(Vo),il=await buildPolymarketL2Headers(We.address,{apiKey:We.apiKey,secret:We.secret,passphrase:We.passphrase,method:"POST",requestPath:"/order",body:ol});await s.createPolymarketOrder(Vo,il),Nt(),toast.success(r("predict.trade.submitSuccess")),Xt(),St(),U(!1);}finally{xe&&M&&i(M).catch(()=>{});}},[m,l,Oe,i,k,e.provider_meta,z,E,ze,N,s,Nt,he,He,ve,tt,St,r,w,P,e.slug]),Xr=useCallback(async()=>{if(!(!Bt.isValid||!p)){U(true),j(null),it(false);try{c==="kalshi"?await qr():await Qr();}catch(M){let xe=M instanceof Error?M.message:"",Ve=c==="polymarket"&&xe?cn(xe,r,"sell"):xe||void 0;toast.error(Ve||r("predict.trade.submitError")),U(false);}}},[Bt.isValid,p,c,qr,Qr,r]);return {outcome:k,orderType:z,quantity:N,limitPrice:E,shares:$n,estimatedReturn:O,isMarketDataLoading:c==="polymarket"&&(x||S),isSubmitting:de,validation:Bt,supportsLimitOrder:u,kycRequired:Se,kycUrl:A,totalShares:sr,activeOrderShares:Gt,availableShares:Ot,isAvailableLoading:Ur,isSellAll:b,precision:$e,expirationEnabled:he,expirationPreset:He,customDuration:ve,customDurationUnit:tt,setOutcome:Te,setOrderType:st,setQuantity:cr,setLimitPrice:kt,setSellAll:Ft,setExpirationEnabled:Be,setExpirationPreset:xt,setCustomDuration:Ke,setCustomDurationUnit:rt,submit:Xr}}var sp=["5m","1h","12h","24h","eod","custom"],lp={"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"},cp=["minutes","hours","days"],dp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},pp={maximumFractionDigits:0};function ia({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,estimatedReturn:l,isMarketDataLoading:a,isSubmitting:c,isValid:u,validationErrors:d,supportsLimitOrder:m,kycRequired:p,kycUrl:f,totalShares:g,activeOrderShares:h,availableShares:v,isAvailableLoading:S,precision:w,expirationEnabled:T,expirationPreset:x,customDuration:P,customDurationUnit:k,onOutcomeChange:Q,onOrderTypeChange:z,onQuantityChange:J,onLimitPriceChange:N,onSellAll:B,onExpirationEnabledChange:E,onExpirationPresetChange:I,onCustomDurationChange:de,onCustomDurationUnitChange:U,onSubmit:b}){let{t:y}=useTranslation(),[V,j]=useState(false),G=useDisclosure(),[pe,Se]=useState(""),it=useRef(false);useEffect(()=>{it.current||Se(isNaN(i)?"":String(i));},[i]);let[he,Be]=useState(""),He=useRef(false);useEffect(()=>{He.current||(isNaN(s)?Be(""):Be(String(parseFloat((s*100).toFixed(2)))));},[s]);let xt=useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Be(A),A===""||A==="."){N(NaN);return}let Oe=parseFloat(A);isNaN(Oe)||N(Oe/100);},[N]),ve=useCallback(A=>{let ge=new RegExp(`^\\d*\\.?\\d{0,${w}}$`);if(A!==""&&!ge.test(A))return;if(Se(A),j(false),A===""||A==="."){J(NaN);return}let Oe=parseFloat(A);isNaN(Oe)||J(Oe);},[J,w]);useEffect(()=>{p&&!G.isOpen&&G.onOpen();},[p]);let Ke=useMemo(()=>{let A=n==="yes"?t.yesBid:t.noBid;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),tt=!isNaN(i)&&i>0,rt=useMemo(()=>{if(S)return y("predict.trade.loadingBalance");if(a)return y("predict.trade.loadingMarketData");if(c)return y("predict.trade.submitting");if(p)return y("predict.trade.kycRequired");if(!tt)return y("predict.trade.enterAmount");let A=y(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${y("predict.trade.sell")} ${A}`},[S,a,c,p,tt,n,y]),we=()=>{if(p){G.onOpen();return}if(!u){j(true);return}j(false),b();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[y("predict.trade.sell")," ",y(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[m?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>z(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:y("predict.trade.market")},"market"),jsx(Tab,{title:y("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.market")}),o==="limit"&&m?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:he,onChange:A=>xt(A.target.value),onFocus:()=>{He.current=true;},onBlur:()=>{He.current=false,isNaN(s)?Be(""):Be(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ke!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ke," \xA2"]})]}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(A=>{let ge=Math.pow(10,w);return jsxs("button",{type:"button",onClick:()=>{J(Math.floor(v*A/100*ge)/ge);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:[A,"%"]},A)}),jsx("button",{type:"button",onClick:B,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:pe,onChange:A=>ve(A.target.value),onFocus:()=>{it.current=true;},onBlur:()=>{it.current=false,Se(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),V&&d.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:d.map(A=>jsx("span",{className:"text-xs text-danger",children:A},A))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:S?"\u2013":`${Ne(g,w).toFixed(w)}${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:S?"\u2013":h>0?`-${Ne(h,w).toFixed(w)}${y("predict.trade.sharesUnit")}`:`0${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:S?"\u2013":`${Ne(v,w).toFixed(w)}${y("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:y("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${l.toFixed(2)}`:"\u2013"})]})]}),o==="limit"&&m&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:y("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:T,onValueChange:E,"aria-label":y("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[x],onSelectionChange:A=>{let ge=Array.from(A)[0];ge&&I(ge);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:sp.map(A=>jsx(SelectItem,{children:y(lp[A])},A))}),x==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(P)?void 0:P,onValueChange:de,minValue:1,step:1,formatOptions:pp,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[k],onSelectionChange:A=>{let ge=Array.from(A)[0];ge&&U(ge);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:cp.map(A=>jsx(SelectItem,{children:y(dp[A])},A))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:S||a||!tt||c,isLoading:c||S||a,spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:we,children:rt})]}),jsx(dn,{isOpen:G.isOpen,onClose:G.onClose,kycUrl:f})]})}function vn({event:e,market:t,variant:r,initialOutcome:n,chain:o}){let{outcome:i,orderType:s,quantity:l,limitPrice:a,estimatedReturn:c,isMarketDataLoading:u,isSubmitting:d,validation:m,supportsLimitOrder:p,kycRequired:f,kycUrl:g,totalShares:h,activeOrderShares:v,availableShares:S,isAvailableLoading:w,precision:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,setOutcome:z,setOrderType:J,setQuantity:N,setLimitPrice:B,setSellAll:E,setExpirationEnabled:I,setExpirationPreset:de,setCustomDuration:U,setCustomDurationUnit:b,submit:y}=Qi({market:t,initialOutcome:n}),V=useAuthCallback(y),j=useMemo(()=>e?en(e):void 0,[e]),G=useMemo(()=>tn(t),[t]);return jsx(ia,{event:j,market:G,variant:r,outcome:i,orderType:s,quantity:l,limitPrice:a,estimatedReturn:c,isMarketDataLoading:u,isSubmitting:d,isValid:m.isValid,validationErrors:m.errors,supportsLimitOrder:p,kycRequired:f,kycUrl:g,totalShares:h,activeOrderShares:v,availableShares:S,isAvailableLoading:w,precision:T,expirationEnabled:x,expirationPreset:P,customDuration:k,customDurationUnit:Q,onOutcomeChange:z,onOrderTypeChange:J,onQuantityChange:N,onLimitPriceChange:B,onSellAll:E,onExpirationEnabledChange:I,onExpirationPresetChange:de,onCustomDurationChange:U,onCustomDurationUnitChange:b,onSubmit:V})}var io="predict-sell";function sa({id:e=io}){return jsx(AsyncModal,{id:e,children:t=>jsx(bp,{...t})})}function bp({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(vn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,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 lo=40,yn=36,Rr=480,co=Rr-yn;function da({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),s=useMemo(()=>e.markets?.map(d=>d.slug)??[],[e.markets]),{data:l}=usePositions({source:e.source,user:t??""}),a=useMemo(()=>!l?.positions||!t?0:s.length===0?l.positions.length:l.positions.filter(d=>d.market&&s.includes(d.market.slug)).length,[l?.positions,s,t]),u=[{key:"positions",label:a>0?`${n("predict.positions.title")} (${a})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:u.map(d=>jsx("button",{type:"button",onClick:()=>i(d.key),className:cn$1("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===d.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:d.label},d.key))}),t?jsxs("div",{style:{height:Rr},children:[o==="positions"&&jsx(Cp,{source:e.source,walletAddress:t,marketSlugs:s}),o==="orders"&&jsx(Ep,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),o==="trades"&&jsx(_p,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Rr},children:n("predict.trade.connectWallet")})]})}function Cp({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=useTranslation(),{data:o,isLoading:i}=usePositions({source:e,user:t}),s=useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(l=>l.market&&r.includes(l.market.slug)):[],[o?.positions,r]);return i?jsx(uo,{}):s.length===0?jsx(po,{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:yn},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:co},rowComponent:Mp,rowCount:s.length,rowHeight:lo,rowProps:{positions:s,closeLabel:n("predict.positions.close")}})]})}function Mp({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,s=o.pnl_percent??0,l=o.avg_price??0,a=o.current_price??0,c=i>0?"text-success":i<0?"text-danger":"text-foreground",u=i>0?"+":"",d=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",m=o.side,p=o.size,f=o.size*a,g=o.market?.end_at?Op(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:d}),jsx("span",{className:cn$1("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:xn(l)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:xn(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[u,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",u,s.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.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 Ep({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=useTranslation(),{data:i,isLoading:s,fetchNextPage:l,hasNextPage:a}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),u=useMemo(()=>{let v=i?.pages?.flatMap(T=>T.items)??[],S=new Set(["live","open","submitted","pending"]),w=v.filter(T=>S.has(T.status));return r.length>0&&(w=w.filter(T=>T.market_id&&r.includes(T.market_id))),w},[i?.pages,r]),d=useCallback(v=>{n?n(v.id):c.mutate({source:v.source,id:v.id});},[n,c]),m=u.length,p=m+(a?1:0),f=useCallback(v=>v<m,[m]),g=useCallback(async()=>{await l();},[l]),h=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:p,threshold:5});return s?jsx(uo,{}):u.length===0&&!a?jsx(po,{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:yn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:co},onRowsRendered:h,rowComponent:Tp,rowCount:p,rowHeight:lo,rowProps:{orders:u,itemCount:m,onCancel:d,isCancelling:c.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Tp({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:s}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let l=r[e];if(!l)return null;let a=l.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",a?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:l.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?xn(parseFloat(l.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Lp,{status:l.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>o(l),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function Lp({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 _p({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),l=useMemo(()=>n?.pages?.flatMap(p=>p.items)??[],[n?.pages]),a=l.length,c=a+(s?1:0),u=useCallback(p=>p<a,[a]),d=useCallback(async()=>{await i();},[i]),m=useInfiniteLoader({isRowLoaded:u,loadMoreRows:d,rowCount:c,threshold:5});return o?jsx(uo,{}):l.length===0&&!s?jsx(po,{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:yn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:co},onRowsRendered:m,rowComponent:Rp,rowCount:c,rowHeight:lo,rowProps:{trades:l,itemCount:a}})]})}function Rp({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",s=Ip(o.timestamp),l=o.price??0,a=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:xn(l)}),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:["$",a.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function po({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Rr},children:e})}function uo(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Rr},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function xn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Ip(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 Op(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var pa=`
|
|
86
86
|
@keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
87
|
-
`,ua={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 se(e){return {...ua,animationDelay:`${e}ms`}}function Ir({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:pa}),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:{...ua,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:{...se(0),height:14,width:48}}),jsx("div",{style:{...se(30),height:14,width:40}}),jsx("div",{style:{...se(60),height:14,width:40}})]}),jsx("div",{style:{...se(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...se(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:{...se(120),height:16,width:96}}),jsx("div",{style:{...se(140),height:16,width:80}})]}),jsx("div",{style:{...se(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...se(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...se(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...se(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:{...se(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:{...se(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:{...se(280+n*40),height:14,width:n%2===0?192:160}}),jsx("div",{style:{...se(300+n*40),height:10,width:64}})]}),jsx("div",{style:{...se(320+n*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...se(340+n*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...se(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...se(400),height:16,width:64}}),jsx("div",{style:{...se(420),height:14,width:"100%"}}),jsx("div",{style:{...se(440),height:14,width:"80%"}}),jsx("div",{style:{...se(460),height:14,width:"60%"}})]})]})]})}function ma(){return jsxs(Fragment,{children:[jsx("style",{children:pa}),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:{...se(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...se(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...se(120),height:40,width:"100%",borderRadius:8}})]})]})}var xa="var(--color-bullish)",ba="var(--color-bearish)";function Or(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Ap(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Fp(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let p of e){let f=Math.round(p.price*100);f>=0&&f<=100&&(r[f]+=p.quantity);}for(let p of t){let f=Math.round(p.price*100);f>=0&&f<=100&&(n[f]+=p.quantity);}let o=0,i=0,s=new Float64Array(101),l=new Float64Array(101);for(let p=100;p>=0;p--)o+=r[p],i+=r[p]*p/100,s[p]=o,l[p]=i;let a=0,c=0,u=new Float64Array(101),d=new Float64Array(101);for(let p=0;p<=100;p++)a+=n[p],c+=n[p]*p/100,u[p]=a,d[p]=c;let m=Math.max(s[0]??0,u[100]??0);return Array.from({length:101},(p,f)=>{let g=s[f]>0,h=u[f]>0,v=s[f]||u[f],S=r[f]>0||n[f]>0;return {priceCents:f,displayHeight:Ap(v,m),opacity:v>0?S?1:.5:0,isBid:g,isAsk:h,bidCumTotal:s[f],askCumTotal:u[f],bidCumCost:l[f],askCumCost:d[f]}})}function Bp({info:e}){let{t}=useTranslation(),r=e.isBid?xa:ba,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:Or(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Or(Math.round(e.cumCost))]})]})}var Hp=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?xa:t.isAsk?ba:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:i&&jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),zp=[0,10,20,30,40,50,60,70,80,90,100];function $p(){return jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:zp.map(e=>jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function ya({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>Fp(e,t),[e,t]),o=useMemo(()=>{let d=e.length>0?Math.max(...e.map(p=>p.price)):0,m=t.length>0?Math.min(...t.map(p=>p.price)):1;return Math.round((d+m)/2*100)},[e,t]),i=useMemo(()=>n.some(d=>d.isBid||d.isAsk),[n]),[s,l]=useState(null),a=useRef(null),c=useCallback((d,m)=>{a.current&&(a.current.style.filter=""),m?(m.style.filter="brightness(1.5)",a.current=m):a.current=null,d.isBid||d.isAsk?l({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):l(null);},[]),u=useCallback(()=>{a.current&&(a.current.style.filter="",a.current=null),l(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsx(Bp,{info:s}),n.map(d=>jsx(Hp,{slot:d,onEnter:c,onLeave:u},d.priceCents))]}),jsx($p,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function fo(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function ka(){let{t:e}=useTranslation();return jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsx(Spinner,{size:"sm"}),jsx("span",{children:e("predict.orderBook.loading")})]})}function Pa({market:e,outcome:t="yes",onTradeAction:r}){let{t:n}=useTranslation(),[o,i]=useState("depth"),s=t==="no",l=e.source,{data:a,isLoading:c,isFetching:u,refetch:d}=useOrderbook({slug:e.slug,source:l}),m=useMemo(()=>((s?a?.asks:a?.bids)??[]).map(S=>({price:s?1-S.price:S.price,quantity:S.size})),[a?.bids,a?.asks,s]),p=useMemo(()=>((s?a?.bids:a?.asks)??[]).map(S=>({price:s?1-S.price:S.price,quantity:S.size})),[a?.bids,a?.asks,s]),f=useMemo(()=>m.length>0?Math.max(...m.map(v=>v.price)):null,[m]),g=useMemo(()=>p.length>0?Math.min(...p.map(v=>v.price)):null,[p]),h=useMemo(()=>{if(f==null||g==null)return null;let v=(g-f)*100;return Math.round(v*10)/10},[f,g]);return jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:h!=null?`${n("predict.orderBook.spread")}: ${Number.isInteger(h)?`${h}\xA2`:`${h.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[f!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[n("predict.trade.bestBid"),": ",fo(f)]}),f!=null&&g!=null&&jsx("span",{className:"text-neutral",children:"|"}),g!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[n("predict.trade.bestAsk"),": ",fo(g)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:o==="depth"?"Orderbook":"Depth chart",onClick:()=>i(v=>v==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:o==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>d(),disabled:u,className:cn$1("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",u&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[o==="depth"&&jsx(Fragment,{children:c?jsx(ka,{}):jsx(ya,{bids:m,asks:p})}),o==="table"&&jsx(Fragment,{children:c?jsx(ka,{}):jsx(qp,{bids:m,asks:p,bestBid:f??void 0,bestAsk:g??void 0,spread:h??void 0})})]})]})}var Sa=8;function qp({bids:e,asks:t,spread:r}){let{t:n}=useTranslation(),o=useMemo(()=>[...t].sort((a,c)=>a.price-c.price).slice(0,Sa).reverse(),[t]),i=useMemo(()=>[...e].sort((a,c)=>c.price-a.price).slice(0,Sa),[e]),s=useMemo(()=>{let a=[...o,...i].map(c=>c.quantity);return Math.max(...a,1)},[o,i]);return o.length===0&&i.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[o.map(a=>jsx(wa,{price:a.price,quantity:a.quantity,side:"ask",maxQty:s},`ask-${a.price}`)),jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),i.map(a=>jsx(wa,{price:a.price,quantity:a.quantity,side:"bid",maxQty:s},`bid-${a.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:n("predict.orderBook.price")}),jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function wa({price:e,quantity:t,side:r,maxQty:n}){let o=r==="ask",i=Math.min(t/n*100,100),s=o?"bg-bearish/10":"bg-bullish/10",l=o?"text-bearish":"text-bullish",a=Or(Math.round(t)),c=Math.round(t*e),u=`$${Or(c)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${i}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:fo(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:a}),jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var vo=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}},wn=4,Ca=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function su(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function lu(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ChartRange.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ma(e){return `${(e*100).toFixed(2)}%`}var cu=[{range:ChartRange.ONE_DAY,label:"1D"},{range:ChartRange.ONE_WEEK,label:"1W"},{range:ChartRange.ONE_MONTH,label:"1M"},{range:ChartRange.ALL,label:"ALL"}];function du({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:cu.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 pu(){let e=useRef(null),t=useRef(null),r=useCallback(o=>{let i=e.current,s=t.current;if(!i||!s)return;let l=i.getBoundingClientRect(),a=(o.clientX-l.left)/l.width*100;s.style.background=`linear-gradient(to right, transparent ${a}%, rgba(0,0,0,0.55) ${a}%)`,s.style.opacity="1";},[]),n=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function uu({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let s=new Map;t?.forEach(a=>s.set(a.dataKey,a));let l=o.map(a=>s.get(a.slug)??{dataKey:a.slug,value:void 0,stroke:a.color,color:a.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?lu(r,i):r}),l.map(a=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:a.stroke??a.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(a.dataKey)??a.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:a.value!=null?Ma(a.value):"--"})]},a.dataKey))]})}function mu({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),s=useRef(null);useEffect(()=>{if(!o)return;function c(u){s.current&&!s.current.contains(u.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]);let l=t.length>=wn,a=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(u=>u.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>i(c=>!c),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[a,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 ",wn," markets"]}),e.map((c,u)=>{let d=t.includes(c.slug),m=!d&&l,p=d&&t.length===1,f=r.get(c.slug)??"#6b7280",g=c.outcomes.find(v=>v.label.toLowerCase()==="yes")??c.outcomes[0],h=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{p||m||n(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:m||p?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!m&&!p&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:d?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),h&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},c.id??`${u}-${c.slug}`)})]})]})}function fu({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?Ma(i):"--"})]})]},n.marketSlug)})})}function gu(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function hu(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),s=Math.min(Math.floor((o+1)*n),e.length),l=e.slice(i,s),a=l.map(c=>c.price).sort((c,u)=>c-u);r.push({timestamp:l[l.length-1].timestamp,price:gu(a)});}return r}function vu(e,t=200){if(e.length===0)return [];let r=e.map(l=>({...l,data:hu(l.data,t)})),n=new Set;r.forEach(l=>l.data.forEach(a=>n.add(a.timestamp)));let o=Array.from(n).sort((l,a)=>l-a),i=r.map(l=>{let a=new Map;return l.data.forEach(c=>a.set(c.timestamp,c.price)),{slug:l.marketSlug,map:a}}),s=new Map;return o.map(l=>{let a={timestamp:l};return i.forEach(({slug:c,map:u})=>{let d=u.get(l);if(d!==void 0)s.set(c,d),a[c]=d;else {let m=s.get(c);m!==void 0&&(a[c]=m);}}),a})}function Ea(e){return jsx(vo,{children:jsx(xu,{...e})})}function xu({event:e,isLoading:t,className:r,volume:n}){let o=useMemo(()=>{let b=new Set;return (e.markets??[]).filter(y=>y.status!=="open"||b.has(y.slug)?false:(b.add(y.slug),true))},[e.markets]),i=useMemo(()=>[...o].sort((b,y)=>{let V=j=>(j.outcomes.find(G=>G.label.toLowerCase()==="yes")??j.outcomes[0])?.price??0;return V(y)-V(b)}),[o]),[s,l]=useState(()=>i.slice(0,wn).map(b=>b.slug)),[a,c]=useState(nn),u=useMemo(()=>{let b=new Map;return s.forEach((y,V)=>{b.set(y,Ca[V%Ca.length]);}),b},[s]),d=useMemo(()=>o.filter(b=>s.includes(b.slug)),[o,s]),{series:m,isLoading:p}=useMarketHistory(d,a),f=t||p,g=useMemo(()=>{if(m.length>0&&m.some(V=>V.data.length>0))return m;let b=Date.now(),y=864e5;return d.map(V=>{let G=(V.outcomes?.find(pe=>pe.label.toLowerCase()==="yes")??V.outcomes?.[0])?.price??.5;return {marketSlug:V.slug,label:V.outcomes?.[0]?.label??V.question,data:[{timestamp:b-7*y,price:G},{timestamp:b,price:G}]}})},[m,d]),h=useMemo(()=>a===ChartRange.ONE_DAY?96:a===ChartRange.ONE_WEEK?168:a===ChartRange.ONE_MONTH?180:300,[a]),v=useMemo(()=>vu(g,h),[g,h]),S=useMemo(()=>{if(v.length===0)return [0,1];let b=1/0,y=-1/0;if(s.forEach(j=>{v.forEach(G=>{let pe=G[j];pe!=null&&(pe<b&&(b=pe),pe>y&&(y=pe));});}),!isFinite(b))return [0,1];let V=Math.max((y-b)*.15,.05);return [Math.max(0,b-V),Math.min(1,y+V)]},[v,s]),N=useMemo(()=>{let b=new Map;return g.forEach(y=>{y.data.length>0&&b.set(y.marketSlug,y.data[y.data.length-1].price);}),b},[g]),T=useMemo(()=>{let b=new Map;return g.forEach(y=>b.set(y.marketSlug,y.label)),b},[g]),x=useMemo(()=>g.map(b=>({slug:b.marketSlug,color:u.get(b.marketSlug)??"#6b7280"})),[g,u]),{wrapperRef:P,overlayRef:k,onMouseMove:Q,onMouseLeave:z}=pu(),J=useCallback(b=>{l(y=>y.includes(b)?y.length<=1?y:y.filter(V=>V!==b):y.length>=wn?y:[...y,b]);},[]),[w,B]=useState(null),E=useRef(null),I=useRef(""),de=useRef(0),U=!f&&v.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsx(fu,{series:g,colorMap:u,displayValues:w??N}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsx("div",{ref:P,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:U?b=>{Q(b),cancelAnimationFrame(de.current),de.current=requestAnimationFrame(()=>{B(E.current);});}:void 0,onMouseLeave:U?()=>{z(),cancelAnimationFrame(de.current),I.current="",E.current=null,B(null);}:void 0,children:f?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):v.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:k,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:v,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:b=>su(b,a),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:S,tickFormatter:b=>`${Math.round(b*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:b=>{let y=b;if(y.active&&y.payload?.length){let V=y.payload.map(j=>`${j.dataKey}:${j.value}`).join(",");if(V!==I.current){I.current=V;let j=new Map;y.payload.forEach(G=>{G.value!=null&&j.set(G.dataKey,G.value);}),E.current=j;}}return jsx(uu,{...y,labelMap:T,allSeries:x,range:a})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(b=>{let y=u.get(b.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:b.marketSlug,stroke:y,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:y},connectNulls:true,isAnimationActive:false},b.marketSlug)}),w==null&&v.length>0&&g.map(b=>{let y=v[v.length-1],V=y[b.marketSlug];if(V==null)return null;let j=u.get(b.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:y.timestamp,y:V,ifOverflow:"extendDomain",shape:G=>{let{cx:pe,cy:Se}=G;return pe==null||Se==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:pe,cy:Se,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:pe,cy:Se,r:3.5,fill:j})]})}},`pulse-${b.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(n).toLocaleString()," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(du,{value:a,onChange:c}),i.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(mu,{markets:i,selectedSlugs:s,colorMap:u,onToggle:J})})]})]})]})}function Ar(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function _u(e){return `${parseFloat((e*100).toFixed(2))}%`}function Ta(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Nn(e){return e.outcomes?.[0]?.label??e.question}function Ru(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Dr(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${s}`}function La(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let u=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(u)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let i=Math.floor(o/864e5),s=Math.floor(o%864e5/36e5),l=Math.floor(o%36e5/6e4),a=Math.floor(o%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(s).padStart(2,"0")}h`),c.push(`${String(l).padStart(2,"0")}m`),c.push(`${String(a).padStart(2,"0")}s`),c.join(" ")}function _a(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),l=-t.getTimezoneOffset(),a=l>=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${a}${c})`}function Da({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let d=[...e.markets||[]],m=d.filter(f=>f.status==="open").sort((f,g)=>Ar(g)-Ar(f)),p=d.filter(f=>f.status!=="open").sort((f,g)=>Ar(g)-Ar(f));return [...m,...p]},[e.markets]),s=e.status==="closed"||e.status==="voided",l=La(s?void 0:e.start_at),a=La(s?void 0:e.end_at),c=_a(e.start_at),u=_a(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((d,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:d.label})]},d.slug)),jsx(Au,{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})]})]}),(l||a||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?u&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:u})}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:l})}),c&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:c})]})]}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:a})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):null}),jsx(Ea,{event:e,volume:e.volume??void 0}),jsx(Iu,{markets:i,onTradeAction:t}),jsx(Du,{markets:i,event:e})]})}var Ra=5;function Iu({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:n}=useScreen(),[o,i]=useState(false),[s,l]=useState(null),a=useMemo(()=>{let h=new Set;return e.filter(v=>h.has(v.slug)?false:(h.add(v.slug),true))},[e]),c=a.find(h=>h.status==="open")?.slug,[u,d]=useState(c?`${c}:yes`:null);if(a.length===0)return null;let m=a.length>Ra,p=o?a:a.slice(0,Ra),f=h=>{l(v=>v===h?null:h);},g=(h,v,S)=>{d(`${h.slug}:${v}`),n&&l(h.slug),t?.(h,v,S);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:p.map((h,v)=>{let S=Ar(h),N=h.outcomes[1]?.best_ask??h.outcomes[1]?.price,T=s===h.slug;return jsx(Ou,{market:h,yesPrice:S,noPrice:N??void 0,activeYes:u===`${h.slug}:yes`,activeNo:u===`${h.slug}:no`,isExpanded:T,onToggleExpand:()=>f(h.slug),onTradeAction:g},h.id??`${v}-${h.slug}`)})})]}),m&&jsxs("button",{type:"button",onClick:()=>i(h=>!h),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 Ou({market:e,yesPrice:t,noPrice:r,activeYes:n,activeNo:o,isExpanded:i,onToggleExpand:s,onTradeAction:l}){let{t:a}=useTranslation(),c=e.status==="open",u=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:Nn(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:Nn(e)}),u&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:u})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:_u(t)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",n?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:d=>{d.stopPropagation(),l?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:Ta(t)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",o?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:d=>{d.stopPropagation(),l?.(e,"no","buy");},children:r!=null?a("predict.market.action.no",{price:Ta(r)}):a("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),i&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(Pa,{market:e,outcome:o?"no":"yes",onTradeAction:l})})})})]})}function Du({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,s]=useState(false),[l,a]=useState(0),c=e.filter(p=>p.rules&&p.rules.length>0||p.description);if(c.length===0)return null;let u=c[l]??c[0],d=u.rules&&u.rules.length>0?u.rules.join(`
|
|
87
|
+
`,ua={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 se(e){return {...ua,animationDelay:`${e}ms`}}function Ir({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:pa}),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:{...ua,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:{...se(0),height:14,width:48}}),jsx("div",{style:{...se(30),height:14,width:40}}),jsx("div",{style:{...se(60),height:14,width:40}})]}),jsx("div",{style:{...se(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...se(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:{...se(120),height:16,width:96}}),jsx("div",{style:{...se(140),height:16,width:80}})]}),jsx("div",{style:{...se(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...se(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...se(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...se(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:{...se(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:{...se(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:{...se(280+n*40),height:14,width:n%2===0?192:160}}),jsx("div",{style:{...se(300+n*40),height:10,width:64}})]}),jsx("div",{style:{...se(320+n*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...se(340+n*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...se(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...se(400),height:16,width:64}}),jsx("div",{style:{...se(420),height:14,width:"100%"}}),jsx("div",{style:{...se(440),height:14,width:"80%"}}),jsx("div",{style:{...se(460),height:14,width:"60%"}})]})]})]})}function ma(){return jsxs(Fragment,{children:[jsx("style",{children:pa}),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:{...se(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...se(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...se(120),height:40,width:"100%",borderRadius:8}})]})]})}var xa="var(--color-bullish)",ba="var(--color-bearish)";function Or(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 Fp(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Bp(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let p of e){let f=Math.round(p.price*100);f>=0&&f<=100&&(r[f]+=p.quantity);}for(let p of t){let f=Math.round(p.price*100);f>=0&&f<=100&&(n[f]+=p.quantity);}let o=0,i=0,s=new Float64Array(101),l=new Float64Array(101);for(let p=100;p>=0;p--)o+=r[p],i+=r[p]*p/100,s[p]=o,l[p]=i;let a=0,c=0,u=new Float64Array(101),d=new Float64Array(101);for(let p=0;p<=100;p++)a+=n[p],c+=n[p]*p/100,u[p]=a,d[p]=c;let m=Math.max(s[0]??0,u[100]??0);return Array.from({length:101},(p,f)=>{let g=s[f]>0,h=u[f]>0,v=s[f]||u[f],S=r[f]>0||n[f]>0;return {priceCents:f,displayHeight:Fp(v,m),opacity:v>0?S?1:.5:0,isBid:g,isAsk:h,bidCumTotal:s[f],askCumTotal:u[f],bidCumCost:l[f],askCumCost:d[f]}})}function Hp({info:e}){let{t}=useTranslation(),r=e.isBid?xa:ba,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:Or(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Or(Math.round(e.cumCost))]})]})}var zp=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?xa:t.isAsk?ba:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:i&&jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),$p=[0,10,20,30,40,50,60,70,80,90,100];function Wp(){return jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:$p.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 ya({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>Bp(e,t),[e,t]),o=useMemo(()=>{let d=e.length>0?Math.max(...e.map(p=>p.price)):0,m=t.length>0?Math.min(...t.map(p=>p.price)):1;return Math.round((d+m)/2*100)},[e,t]),i=useMemo(()=>n.some(d=>d.isBid||d.isAsk),[n]),[s,l]=useState(null),a=useRef(null),c=useCallback((d,m)=>{a.current&&(a.current.style.filter=""),m?(m.style.filter="brightness(1.5)",a.current=m):a.current=null,d.isBid||d.isAsk?l({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):l(null);},[]),u=useCallback(()=>{a.current&&(a.current.style.filter="",a.current=null),l(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsx(Hp,{info:s}),n.map(d=>jsx(zp,{slot:d,onEnter:c,onLeave:u},d.priceCents))]}),jsx(Wp,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function fo(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function ka(){let{t:e}=useTranslation();return jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsx(Spinner,{size:"sm"}),jsx("span",{children:e("predict.orderBook.loading")})]})}function Pa({market:e,outcome:t="yes",onTradeAction:r}){let{t:n}=useTranslation(),[o,i]=useState("depth"),s=t==="no",l=e.source,{data:a,isLoading:c,isFetching:u,refetch:d}=useOrderbook({slug:e.slug,source:l}),m=useMemo(()=>((s?a?.asks:a?.bids)??[]).map(S=>({price:s?1-S.price:S.price,quantity:S.size})),[a?.bids,a?.asks,s]),p=useMemo(()=>((s?a?.bids:a?.asks)??[]).map(S=>({price:s?1-S.price:S.price,quantity:S.size})),[a?.bids,a?.asks,s]),f=useMemo(()=>m.length>0?Math.max(...m.map(v=>v.price)):null,[m]),g=useMemo(()=>p.length>0?Math.min(...p.map(v=>v.price)):null,[p]),h=useMemo(()=>{if(f==null||g==null)return null;let v=(g-f)*100;return Math.round(v*10)/10},[f,g]);return jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:h!=null?`${n("predict.orderBook.spread")}: ${Number.isInteger(h)?`${h}\xA2`:`${h.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[f!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[n("predict.trade.bestBid"),": ",fo(f)]}),f!=null&&g!=null&&jsx("span",{className:"text-neutral",children:"|"}),g!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[n("predict.trade.bestAsk"),": ",fo(g)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:o==="depth"?"Orderbook":"Depth chart",onClick:()=>i(v=>v==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:o==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>d(),disabled:u,className:cn$1("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",u&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[o==="depth"&&jsx(Fragment,{children:c?jsx(ka,{}):jsx(ya,{bids:m,asks:p})}),o==="table"&&jsx(Fragment,{children:c?jsx(ka,{}):jsx(Qp,{bids:m,asks:p,bestBid:f??void 0,bestAsk:g??void 0,spread:h??void 0})})]})]})}var Sa=8;function Qp({bids:e,asks:t,spread:r}){let{t:n}=useTranslation(),o=useMemo(()=>[...t].sort((a,c)=>a.price-c.price).slice(0,Sa).reverse(),[t]),i=useMemo(()=>[...e].sort((a,c)=>c.price-a.price).slice(0,Sa),[e]),s=useMemo(()=>{let a=[...o,...i].map(c=>c.quantity);return Math.max(...a,1)},[o,i]);return o.length===0&&i.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:n("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[o.map(a=>jsx(wa,{price:a.price,quantity:a.quantity,side:"ask",maxQty:s},`ask-${a.price}`)),jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),i.map(a=>jsx(wa,{price:a.price,quantity:a.quantity,side:"bid",maxQty:s},`bid-${a.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:n("predict.orderBook.price")}),jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function wa({price:e,quantity:t,side:r,maxQty:n}){let o=r==="ask",i=Math.min(t/n*100,100),s=o?"bg-bearish/10":"bg-bullish/10",l=o?"text-bearish":"text-bullish",a=Or(Math.round(t)),c=Math.round(t*e),u=`$${Or(c)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${i}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:fo(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:a}),jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var vo=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}},wn=4,Ca=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function lu(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function cu(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ChartRange.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ma(e){return `${(e*100).toFixed(2)}%`}var du=[{range:ChartRange.ONE_DAY,label:"1D"},{range:ChartRange.ONE_WEEK,label:"1W"},{range:ChartRange.ONE_MONTH,label:"1M"},{range:ChartRange.ALL,label:"ALL"}];function pu({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:du.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 uu(){let e=useRef(null),t=useRef(null),r=useCallback(o=>{let i=e.current,s=t.current;if(!i||!s)return;let l=i.getBoundingClientRect(),a=(o.clientX-l.left)/l.width*100;s.style.background=`linear-gradient(to right, transparent ${a}%, rgba(0,0,0,0.55) ${a}%)`,s.style.opacity="1";},[]),n=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function mu({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let s=new Map;t?.forEach(a=>s.set(a.dataKey,a));let l=o.map(a=>s.get(a.slug)??{dataKey:a.slug,value:void 0,stroke:a.color,color:a.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?cu(r,i):r}),l.map(a=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:a.stroke??a.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(a.dataKey)??a.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:a.value!=null?Ma(a.value):"--"})]},a.dataKey))]})}function fu({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),s=useRef(null);useEffect(()=>{if(!o)return;function c(u){s.current&&!s.current.contains(u.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]);let l=t.length>=wn,a=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(u=>u.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>i(c=>!c),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[a,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 ",wn," markets"]}),e.map((c,u)=>{let d=t.includes(c.slug),m=!d&&l,p=d&&t.length===1,f=r.get(c.slug)??"#6b7280",g=c.outcomes.find(v=>v.label.toLowerCase()==="yes")??c.outcomes[0],h=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{p||m||n(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:m||p?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!m&&!p&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:d?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),h&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},c.id??`${u}-${c.slug}`)})]})]})}function gu({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?Ma(i):"--"})]})]},n.marketSlug)})})}function hu(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function vu(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),s=Math.min(Math.floor((o+1)*n),e.length),l=e.slice(i,s),a=l.map(c=>c.price).sort((c,u)=>c-u);r.push({timestamp:l[l.length-1].timestamp,price:hu(a)});}return r}function xu(e,t=200){if(e.length===0)return [];let r=e.map(l=>({...l,data:vu(l.data,t)})),n=new Set;r.forEach(l=>l.data.forEach(a=>n.add(a.timestamp)));let o=Array.from(n).sort((l,a)=>l-a),i=r.map(l=>{let a=new Map;return l.data.forEach(c=>a.set(c.timestamp,c.price)),{slug:l.marketSlug,map:a}}),s=new Map;return o.map(l=>{let a={timestamp:l};return i.forEach(({slug:c,map:u})=>{let d=u.get(l);if(d!==void 0)s.set(c,d),a[c]=d;else {let m=s.get(c);m!==void 0&&(a[c]=m);}}),a})}function Ea(e){return jsx(vo,{children:jsx(bu,{...e})})}function bu({event:e,isLoading:t,className:r,volume:n}){let o=useMemo(()=>{let b=new Set;return (e.markets??[]).filter(y=>y.status!=="open"||b.has(y.slug)?false:(b.add(y.slug),true))},[e.markets]),i=useMemo(()=>[...o].sort((b,y)=>{let V=j=>(j.outcomes.find(G=>G.label.toLowerCase()==="yes")??j.outcomes[0])?.price??0;return V(y)-V(b)}),[o]),[s,l]=useState(()=>i.slice(0,wn).map(b=>b.slug)),[a,c]=useState(nn),u=useMemo(()=>{let b=new Map;return s.forEach((y,V)=>{b.set(y,Ca[V%Ca.length]);}),b},[s]),d=useMemo(()=>o.filter(b=>s.includes(b.slug)),[o,s]),{series:m,isLoading:p}=useMarketHistory(d,a),f=t||p,g=useMemo(()=>{if(m.length>0&&m.some(V=>V.data.length>0))return m;let b=Date.now(),y=864e5;return d.map(V=>{let G=(V.outcomes?.find(pe=>pe.label.toLowerCase()==="yes")??V.outcomes?.[0])?.price??.5;return {marketSlug:V.slug,label:V.outcomes?.[0]?.label??V.question,data:[{timestamp:b-7*y,price:G},{timestamp:b,price:G}]}})},[m,d]),h=useMemo(()=>a===ChartRange.ONE_DAY?96:a===ChartRange.ONE_WEEK?168:a===ChartRange.ONE_MONTH?180:300,[a]),v=useMemo(()=>xu(g,h),[g,h]),S=useMemo(()=>{if(v.length===0)return [0,1];let b=1/0,y=-1/0;if(s.forEach(j=>{v.forEach(G=>{let pe=G[j];pe!=null&&(pe<b&&(b=pe),pe>y&&(y=pe));});}),!isFinite(b))return [0,1];let V=Math.max((y-b)*.15,.05);return [Math.max(0,b-V),Math.min(1,y+V)]},[v,s]),w=useMemo(()=>{let b=new Map;return g.forEach(y=>{y.data.length>0&&b.set(y.marketSlug,y.data[y.data.length-1].price);}),b},[g]),T=useMemo(()=>{let b=new Map;return g.forEach(y=>b.set(y.marketSlug,y.label)),b},[g]),x=useMemo(()=>g.map(b=>({slug:b.marketSlug,color:u.get(b.marketSlug)??"#6b7280"})),[g,u]),{wrapperRef:P,overlayRef:k,onMouseMove:Q,onMouseLeave:z}=uu(),J=useCallback(b=>{l(y=>y.includes(b)?y.length<=1?y:y.filter(V=>V!==b):y.length>=wn?y:[...y,b]);},[]),[N,B]=useState(null),E=useRef(null),I=useRef(""),de=useRef(0),U=!f&&v.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsx(gu,{series:g,colorMap:u,displayValues:N??w}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsx("div",{ref:P,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:U?b=>{Q(b),cancelAnimationFrame(de.current),de.current=requestAnimationFrame(()=>{B(E.current);});}:void 0,onMouseLeave:U?()=>{z(),cancelAnimationFrame(de.current),I.current="",E.current=null,B(null);}:void 0,children:f?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):v.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:k,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:v,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:b=>lu(b,a),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:S,tickFormatter:b=>`${Math.round(b*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:b=>{let y=b;if(y.active&&y.payload?.length){let V=y.payload.map(j=>`${j.dataKey}:${j.value}`).join(",");if(V!==I.current){I.current=V;let j=new Map;y.payload.forEach(G=>{G.value!=null&&j.set(G.dataKey,G.value);}),E.current=j;}}return jsx(mu,{...y,labelMap:T,allSeries:x,range:a})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(b=>{let y=u.get(b.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:b.marketSlug,stroke:y,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:y},connectNulls:true,isAnimationActive:false},b.marketSlug)}),N==null&&v.length>0&&g.map(b=>{let y=v[v.length-1],V=y[b.marketSlug];if(V==null)return null;let j=u.get(b.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:y.timestamp,y:V,ifOverflow:"extendDomain",shape:G=>{let{cx:pe,cy:Se}=G;return pe==null||Se==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:pe,cy:Se,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:pe,cy:Se,r:3.5,fill:j})]})}},`pulse-${b.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(n).toLocaleString()," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(pu,{value:a,onChange:c}),i.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(fu,{markets:i,selectedSlugs:s,colorMap:u,onToggle:J})})]})]})]})}function Ar(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ru(e){return `${parseFloat((e*100).toFixed(2))}%`}function Ta(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Nn(e){return e.outcomes?.[0]?.label??e.question}function Iu(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Dr(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${s}`}function La(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let u=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(u)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let i=Math.floor(o/864e5),s=Math.floor(o%864e5/36e5),l=Math.floor(o%36e5/6e4),a=Math.floor(o%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(s).padStart(2,"0")}h`),c.push(`${String(l).padStart(2,"0")}m`),c.push(`${String(a).padStart(2,"0")}s`),c.join(" ")}function _a(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),l=-t.getTimezoneOffset(),a=l>=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${a}${c})`}function Da({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let d=[...e.markets||[]],m=d.filter(f=>f.status==="open").sort((f,g)=>Ar(g)-Ar(f)),p=d.filter(f=>f.status!=="open").sort((f,g)=>Ar(g)-Ar(f));return [...m,...p]},[e.markets]),s=e.status==="closed"||e.status==="voided",l=La(s?void 0:e.start_at),a=La(s?void 0:e.end_at),c=_a(e.start_at),u=_a(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((d,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:d.label})]},d.slug)),jsx(Fu,{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})]})]}),(l||a||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?u&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:u})}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:l})}),c&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:c})]})]}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:a})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):null}),jsx(Ea,{event:e,volume:e.volume??void 0}),jsx(Ou,{markets:i,onTradeAction:t}),jsx(Au,{markets:i,event:e})]})}var Ra=5;function Ou({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:n}=useScreen(),[o,i]=useState(false),[s,l]=useState(null),a=useMemo(()=>{let h=new Set;return e.filter(v=>h.has(v.slug)?false:(h.add(v.slug),true))},[e]),c=a.find(h=>h.status==="open")?.slug,[u,d]=useState(c?`${c}:yes`:null);if(a.length===0)return null;let m=a.length>Ra,p=o?a:a.slice(0,Ra),f=h=>{l(v=>v===h?null:h);},g=(h,v,S)=>{d(`${h.slug}:${v}`),n&&l(h.slug),t?.(h,v,S);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:p.map((h,v)=>{let S=Ar(h),w=h.outcomes[1]?.best_ask??h.outcomes[1]?.price,T=s===h.slug;return jsx(Du,{market:h,yesPrice:S,noPrice:w??void 0,activeYes:u===`${h.slug}:yes`,activeNo:u===`${h.slug}:no`,isExpanded:T,onToggleExpand:()=>f(h.slug),onTradeAction:g},h.id??`${v}-${h.slug}`)})})]}),m&&jsxs("button",{type:"button",onClick:()=>i(h=>!h),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 Du({market:e,yesPrice:t,noPrice:r,activeYes:n,activeNo:o,isExpanded:i,onToggleExpand:s,onTradeAction:l}){let{t:a}=useTranslation(),c=e.status==="open",u=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:Nn(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:Nn(e)}),u&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:u})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Ru(t)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",n?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:d=>{d.stopPropagation(),l?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:Ta(t)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",o?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:d=>{d.stopPropagation(),l?.(e,"no","buy");},children:r!=null?a("predict.market.action.no",{price:Ta(r)}):a("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),i&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(Pa,{market:e,outcome:o?"no":"yes",onTradeAction:l})})})})]})}function Au({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,s]=useState(false),[l,a]=useState(0),c=e.filter(p=>p.rules&&p.rules.length>0||p.description);if(c.length===0)return null;let u=c[l]??c[0],d=u.rules&&u.rules.length>0?u.rules.join(`
|
|
88
88
|
|
|
89
|
-
`):u.description??"";if(!d)return null;let m=d.length>200&&!n?d.slice(0,200)+"...":d;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),c.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:Nn(u)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(l)],onAction:p=>{a(Number(p)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((p,f)=>jsx(DropdownItem,{className:cn$1(f===l?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Nn(p)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),d.length>200&&jsx("button",{type:"button",onClick:()=>o(p=>!p),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(p=>!p),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 p=u.status,f=[];return u.created_at&&f.push({label:r("predict.event.timeline.created"),value:Dr(u.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Dr(u.start_at),isActive:p!=="pending"}),p==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Dr(u.closed_at??u.end_at),isActive:true}):p==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Dr(u.closed_at??u.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Dr(u.end_at),isActive:false}),f})().map((p,f,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${p.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:p.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:p.value})]})]},p.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:u.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Ru(u.source)})]})]})]})]})}function Au({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 Aa({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx(Ir,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Da,{event:n,onTradeAction:r})}var $u={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}},Wu={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function gt(e){return $u[e]??Wu}function Bx({source:e,className:t}){let r=gt(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 Ba="rgba(39,39,42,0.6)",Gu="rgba(63,63,70,0.8)";function qu(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function za({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=useTranslation(),{data:s,isLoading:l}=useSimilarEvents({slug:e,source:t,limit:r});return l||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(a=>jsx(Qu,{event:a,onClick:n,onHover:o},`${a.source}-${a.slug}`))})]})}function Qu({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=gt(e.source),i=useMemo(()=>qu(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:l=>{l.currentTarget.style.borderColor=Gu,r?.(e);},onMouseLeave:l=>{l.currentTarget.style.borderColor=Ba;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Ba}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function Cn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function sb({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:s}){let{t:l}=useTranslation(),{isDesktop:a}=useScreen(),{onOpen:c}=useAsyncModal(Pr),{onOpen:u}=useAsyncModal(io),{data:d,isLoading:m}=useEvent({slug:e,source:t}),p=useMemo(()=>{let T=[...d?.markets||[]],x=T.filter(k=>k.status==="open").sort((k,Q)=>Cn(Q)-Cn(k)),P=T.filter(k=>k.status!=="open").sort((k,Q)=>Cn(Q)-Cn(k));return [...x,...P]},[d?.markets]),[f,g]=useState(null),h=useCallback((T,x,P)=>{g(k=>({market:T,outcome:x,side:P,version:(k?.version??0)+1})),!a&&d&&(P==="sell"?u({params:{event:d,market:T,initialOutcome:x,chain:r}}):c({params:{event:d,market:T,initialOutcome:x,chain:r}}));},[a,d,r,c,u]),v=f?.market??p[0];if(m){let T=!!s;return a?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(Ir,{showBack:T})}),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(ma,{})})})]}):jsx(Ir,{showBack:T})}let S=f?`${f.market.slug}-${f.version}`:v?.slug??"default",N=f?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:l("common.back")})}),jsx(Aa,{eventSlug:e,source:t,onTradeAction:h})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[v&&(N?jsx(vn,{event:d,market:v,initialOutcome:f?.outcome,chain:r},S):jsx(un,{event:d,market:v,initialOutcome:f?.outcome,chain:r},S)),d&&jsx(za,{eventSlug:e,source:d.source,onEventClick:o,onEventHover:i})]})]}),d&&jsx("div",{className:"flex w-full flex-col",children:jsx(da,{event:d,walletAddress:n})}),jsx(mn,{}),jsx(sa,{})]})}function Wa(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function dm(e){switch(e){case ChartRange.ONE_DAY:return {interval:"15m",limit:96};case ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var fb=e=>{let{candlestickMarketSlugs:t,chartRange:r=nn,source:n}=e,o=usePredictClient(),i=useMemo(()=>dm(r),[r]),{data:s,isLoading:l,error:a}=useEvent({slug:e.eventSlug,source:n}),c=useMemo(()=>{if(!s?.markets)return [];let f=new Set,g=s.markets.filter(v=>f.has(v.slug)?false:(f.add(v.slug),true));return (t&&t.length>0?t.slice(0,4).map(v=>g.find(S=>S.slug===v)).filter(v=>v!==void 0):[...g].sort((v,S)=>Wa(S)-Wa(v)).slice(0,4)).map(v=>v.slug)},[t,s?.markets]),u=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>o.listCandlesticks(f,i),enabled:c.length>0}))}),d=u.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let v=u[h]?.error;v&&f.set(g,v);}),f},[c,u]),p=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let v=u[h]?.data;v&&f.set(g,v);}),f},[c,u]);return {event:s,isEventLoading:l,eventError:a,candlestickParams:i,candlesticks:p,isCandlesticksLoading:d,candlestickErrors:m}};var mm=10,fm=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Tn(){let[e,t]=useAtom(fm),r=useCallback(o=>{let i=o.trim();i&&t(s=>{let l=s.filter(a=>a!==i);return [i,...l].slice(0,mm)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function ja({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 Ya({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Tn();return jsx(ja,{className:cn$1(t),histories:r,onSelect:e,onClear:n})}function Ga({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=useTranslation();return jsx("div",{className:o,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),n?.();},children:"Esc"})})})}function Im(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function qa({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:s}=useTranslation(),l=e.tags?.[0],a=gt(e.source),c=useMemo(()=>Im(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:u=>{t&&n&&u.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:a.color},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:a.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[c," ",s("predict.event.volume")]}),l&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:l.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Qa({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:l}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>n?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:l}}var Um=64;function es({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:s,isLoading:l,isFetchingNextPage:a,hasNextPage:c,fetchNextPage:u}=Qa(i),d=useRef(null),{height:m}=useResizeObserver({ref:d}),p=useCallback(v=>v<s.length,[s]),f=useCallback(async()=>{c&&!a&&await u();},[c,a,u]),g=useMemo(()=>c?s.length+1:s.length,[s,c]),h=useInfiniteLoader({isRowLoaded:p,loadMoreRows:f,rowCount:g,threshold:5});return l?jsx(Vm,{className:o}):s.length===0?jsx(jm,{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:d,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:h,rowComponent:Km,rowCount:g,rowHeight:Um,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function Km({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:s}){let l=r[e];return l?jsx("div",{style:t,children:jsx(qa,{event:l,href:o?.(l),LinkComponent:i,onSelect:n,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function Vm({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 jm({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 os({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=Tn(),s=useCallbackRef(e),l=useCallbackRef(i),a=useMemo(()=>debounce(m=>{o(m),s(m),m&&l(m);},500),[s,l]),c=useCallback(m=>{r(m),a(m);},[a]),u=useCallback(m=>{a.cancel(),r(m),o(m),s(m),m&&l(m);},[a,s,l]),d=useCallback(()=>u(""),[u]);return {text:t,keyword:n,setText:c,setKeyword:u,clearKeyword:d}}function is({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:s}){let{text:l,keyword:a,setText:c,setKeyword:u,clearKeyword:d}=os({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Ga,{value:l,onValueChange:c,onClear:d,onEscape:i}),!a&&jsx(Ya,{onSelect:u}),jsx(es,{className:"flex-auto min-h-0",keyword:a,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:s})]})}var wo="predict-search";function zy({id:e=wo}){return jsx(AsyncModal,{id:e,children:t=>jsx(af,{...t})})}function af({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(a=>{n(a);},[n]),l=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:o("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(is,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:l})})]})})}function qy({onSelectEvent:e,modalParams:t,className:r,displayMode:n="auto"}){let{t:o}=useTranslation(),i=useScreen(),s=n==="auto"?i.isDesktop:n==="desktop",l=n==="auto"?i.isMobile:n==="compact",{onOpen:a,onClose:c}=useAsyncModal(wo),u=useCallbackRef(e),d=useCallbackRef(async()=>{let p=await a({params:t});p&&u(p);}),m=useCallbackRef(()=>{c();});return useEffect(()=>{let p=f=>{let g=document.activeElement,h=!!g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.getAttribute("contenteditable")==="true");f.key==="/"&&!h&&(f.preventDefault(),d()),f.key==="Escape"&&(f.preventDefault(),m());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[d,m]),jsx(Button,{size:"sm",radius:"full",isIconOnly:!s,onPress:d,variant:l?"flat":"bordered",startContent:s?jsx(SearchIcon,{className:"text-neutral"}):void 0,endContent:s?jsx(Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:cn$1(s&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:s?o("predict.search.placeholder"):jsx(SearchIcon,{className:"text-neutral"})})}var Po=[{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"}],fs=[{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}],ps={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"},us={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 hf(e,t){if(!e)return "$5K+";let r=fs.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function gs({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:s}){let{t:l}=useTranslation(),[a,c]=useState(false),[u,d]=useState(false),[m,p]=useState(false),[f,g]=useState(false),h=useRef(null),v=useRef(null),S=Po.find(x=>x.value===e)??Po[0],N=useCallback(x=>{h.current&&!h.current.contains(x.target)&&c(false),v.current&&!v.current.contains(x.target)&&d(false);},[]);useEffect(()=>(document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)),[N]);let T=useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
89
|
+
`):u.description??"";if(!d)return null;let m=d.length>200&&!n?d.slice(0,200)+"...":d;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),c.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:Nn(u)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(l)],onAction:p=>{a(Number(p)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((p,f)=>jsx(DropdownItem,{className:cn$1(f===l?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Nn(p)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),d.length>200&&jsx("button",{type:"button",onClick:()=>o(p=>!p),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(p=>!p),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 p=u.status,f=[];return u.created_at&&f.push({label:r("predict.event.timeline.created"),value:Dr(u.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Dr(u.start_at),isActive:p!=="pending"}),p==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Dr(u.closed_at??u.end_at),isActive:true}):p==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Dr(u.closed_at??u.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Dr(u.end_at),isActive:false}),f})().map((p,f,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${p.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:p.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:p.value})]})]},p.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:u.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Iu(u.source)})]})]})]})]})}function Fu({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 Aa({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx(Ir,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Da,{event:n,onTradeAction:r})}var Wu={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}},Uu={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function gt(e){return Wu[e]??Uu}function Hx({source:e,className:t}){let r=gt(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 Ba="rgba(39,39,42,0.6)",qu="rgba(63,63,70,0.8)";function Qu(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function za({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=useTranslation(),{data:s,isLoading:l}=useSimilarEvents({slug:e,source:t,limit:r});return l||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(a=>jsx(Xu,{event:a,onClick:n,onHover:o},`${a.source}-${a.slug}`))})]})}function Xu({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=gt(e.source),i=useMemo(()=>Qu(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:l=>{l.currentTarget.style.borderColor=qu,r?.(e);},onMouseLeave:l=>{l.currentTarget.style.borderColor=Ba;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Ba}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function Cn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function lb({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:s}){let{t:l}=useTranslation(),{isDesktop:a}=useScreen(),{onOpen:c}=useAsyncModal(Pr),{onOpen:u}=useAsyncModal(io),{data:d,isLoading:m}=useEvent({slug:e,source:t}),p=useMemo(()=>{let T=[...d?.markets||[]],x=T.filter(k=>k.status==="open").sort((k,Q)=>Cn(Q)-Cn(k)),P=T.filter(k=>k.status!=="open").sort((k,Q)=>Cn(Q)-Cn(k));return [...x,...P]},[d?.markets]),[f,g]=useState(null),h=useCallback((T,x,P)=>{g(k=>({market:T,outcome:x,side:P,version:(k?.version??0)+1})),!a&&d&&(P==="sell"?u({params:{event:d,market:T,initialOutcome:x,chain:r}}):c({params:{event:d,market:T,initialOutcome:x,chain:r}}));},[a,d,r,c,u]),v=f?.market??p[0];if(m){let T=!!s;return a?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(Ir,{showBack:T})}),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(ma,{})})})]}):jsx(Ir,{showBack:T})}let S=f?`${f.market.slug}-${f.version}`:v?.slug??"default",w=f?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:l("common.back")})}),jsx(Aa,{eventSlug:e,source:t,onTradeAction:h})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[v&&(w?jsx(vn,{event:d,market:v,initialOutcome:f?.outcome,chain:r},S):jsx(un,{event:d,market:v,initialOutcome:f?.outcome,chain:r},S)),d&&jsx(za,{eventSlug:e,source:d.source,onEventClick:o,onEventHover:i})]})]}),d&&jsx("div",{className:"flex w-full flex-col",children:jsx(da,{event:d,walletAddress:n})}),jsx(mn,{}),jsx(sa,{})]})}function Wa(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function pm(e){switch(e){case ChartRange.ONE_DAY:return {interval:"15m",limit:96};case ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var gb=e=>{let{candlestickMarketSlugs:t,chartRange:r=nn,source:n}=e,o=usePredictClient(),i=useMemo(()=>pm(r),[r]),{data:s,isLoading:l,error:a}=useEvent({slug:e.eventSlug,source:n}),c=useMemo(()=>{if(!s?.markets)return [];let f=new Set,g=s.markets.filter(v=>f.has(v.slug)?false:(f.add(v.slug),true));return (t&&t.length>0?t.slice(0,4).map(v=>g.find(S=>S.slug===v)).filter(v=>v!==void 0):[...g].sort((v,S)=>Wa(S)-Wa(v)).slice(0,4)).map(v=>v.slug)},[t,s?.markets]),u=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,i),queryFn:()=>o.listCandlesticks(f,i),enabled:c.length>0}))}),d=u.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let v=u[h]?.error;v&&f.set(g,v);}),f},[c,u]),p=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let v=u[h]?.data;v&&f.set(g,v);}),f},[c,u]);return {event:s,isEventLoading:l,eventError:a,candlestickParams:i,candlesticks:p,isCandlesticksLoading:d,candlestickErrors:m}};var fm=10,gm=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Tn(){let[e,t]=useAtom(gm),r=useCallback(o=>{let i=o.trim();i&&t(s=>{let l=s.filter(a=>a!==i);return [i,...l].slice(0,fm)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function ja({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 Ya({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Tn();return jsx(ja,{className:cn$1(t),histories:r,onSelect:e,onClear:n})}function Ga({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=useTranslation();return jsx("div",{className:o,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),n?.();},children:"Esc"})})})}function Om(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function qa({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:s}=useTranslation(),l=e.tags?.[0],a=gt(e.source),c=useMemo(()=>Om(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:u=>{t&&n&&u.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:a.color},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:a.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[c," ",s("predict.event.volume")]}),l&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:l.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Qa({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:l}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>n?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:l}}var Km=64;function es({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:s,isLoading:l,isFetchingNextPage:a,hasNextPage:c,fetchNextPage:u}=Qa(i),d=useRef(null),{height:m}=useResizeObserver({ref:d}),p=useCallback(v=>v<s.length,[s]),f=useCallback(async()=>{c&&!a&&await u();},[c,a,u]),g=useMemo(()=>c?s.length+1:s.length,[s,c]),h=useInfiniteLoader({isRowLoaded:p,loadMoreRows:f,rowCount:g,threshold:5});return l?jsx(jm,{className:o}):s.length===0?jsx(Ym,{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:d,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:h,rowComponent:Vm,rowCount:g,rowHeight:Km,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function Vm({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:s}){let l=r[e];return l?jsx("div",{style:t,children:jsx(qa,{event:l,href:o?.(l),LinkComponent:i,onSelect:n,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function jm({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 Ym({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 os({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=Tn(),s=useCallbackRef(e),l=useCallbackRef(i),a=useMemo(()=>debounce(m=>{o(m),s(m),m&&l(m);},500),[s,l]),c=useCallback(m=>{r(m),a(m);},[a]),u=useCallback(m=>{a.cancel(),r(m),o(m),s(m),m&&l(m);},[a,s,l]),d=useCallback(()=>u(""),[u]);return {text:t,keyword:n,setText:c,setKeyword:u,clearKeyword:d}}function is({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:s}){let{text:l,keyword:a,setText:c,setKeyword:u,clearKeyword:d}=os({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Ga,{value:l,onValueChange:c,onClear:d,onEscape:i}),!a&&jsx(Ya,{onSelect:u}),jsx(es,{className:"flex-auto min-h-0",keyword:a,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:s})]})}var wo="predict-search";function $y({id:e=wo}){return jsx(AsyncModal,{id:e,children:t=>jsx(sf,{...t})})}function sf({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(a=>{n(a);},[n]),l=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:o("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(is,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:l})})]})})}function Qy({onSelectEvent:e,modalParams:t,className:r,displayMode:n="auto"}){let{t:o}=useTranslation(),i=useScreen(),s=n==="auto"?i.isDesktop:n==="desktop",l=n==="auto"?i.isMobile:n==="compact",{onOpen:a,onClose:c}=useAsyncModal(wo),u=useCallbackRef(e),d=useCallbackRef(async()=>{let p=await a({params:t});p&&u(p);}),m=useCallbackRef(()=>{c();});return useEffect(()=>{let p=f=>{let g=document.activeElement,h=!!g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.getAttribute("contenteditable")==="true");f.key==="/"&&!h&&(f.preventDefault(),d()),f.key==="Escape"&&(f.preventDefault(),m());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[d,m]),jsx(Button,{size:"sm",radius:"full",isIconOnly:!s,onPress:d,variant:l?"flat":"bordered",startContent:s?jsx(SearchIcon,{className:"text-neutral"}):void 0,endContent:s?jsx(Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:cn$1(s&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:s?o("predict.search.placeholder"):jsx(SearchIcon,{className:"text-neutral"})})}var Po=[{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"}],fs=[{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}],ps={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"},us={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 vf(e,t){if(!e)return "$5K+";let r=fs.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function gs({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:s}){let{t:l}=useTranslation(),[a,c]=useState(false),[u,d]=useState(false),[m,p]=useState(false),[f,g]=useState(false),h=useRef(null),v=useRef(null),S=Po.find(x=>x.value===e)??Po[0],w=useCallback(x=>{h.current&&!h.current.contains(x.target)&&c(false),v.current&&!v.current.contains(x.target)&&d(false);},[]);useEffect(()=>(document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)),[w]);let T=useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
90
90
|
@keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
91
91
|
.match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
|
|
92
92
|
.match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
|
|
93
|
-
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:h,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:ps,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(x=>!x),d(false);},children:[jsx(
|
|
93
|
+
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:h,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:ps,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(x=>!x),d(false);},children:[jsx(xf,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l(S.labelKey)}),jsx(ms,{open:a})]}),a&&jsx("div",{style:{...us,width:224,padding:4},children:Po.map(x=>{let P=e===x.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:P?"rgba(199,255,46,0.08)":"transparent",color:P?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:k=>{P||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{P||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===x.value?n(!r):t(x.value),c(false);},children:[jsx("div",{style:{color:P?"#c7ff2e":"#71717a"},children:jsx(bf,{type:x.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:l(x.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:l(x.descKey)})]}),P&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},x.value)})})]}),i&&jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:ps,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{d(x=>!x),c(false);},children:[jsx(yf,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:vf(o,l)}),jsx(kf,{onMouseEnter:()=>p(true),onMouseLeave:()=>p(false)}),jsx(ms,{open:u})]}),m&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),l("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:l("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:l("predict.matches.filter.tooltipNote")})]})]})]}),u&&jsxs("div",{style:{...us,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:l("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:fs.map(x=>{let P=x.value===0?!o:o===x.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:P?"rgba(199,255,46,0.08)":"transparent",color:P?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:k=>{P||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{P||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(x.value===0?void 0:x.value),d(false);},children:[jsx("span",{children:x.labelKey?l(x.labelKey):x.label}),P&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},x.value)})})]})]}),s&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)",x.currentTarget.style.color="#fff";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)",x.currentTarget.style.color="#a1a1aa";},onClick:T,children:jsxs("svg",{className:f?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})})]})]})}function xf(){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 bf({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 yf(){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 kf({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 ms({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 Nf(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(0)}K`:`$${e.toFixed(0)}`}var Pf=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>e.toLocaleString(),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=>e.toLocaleString(),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:Nf,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function hs({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
94
94
|
@keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
95
95
|
@keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
96
96
|
@keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -128,21 +128,21 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
128
128
|
.matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
|
|
129
129
|
@media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
130
130
|
`}),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(`
|
|
131
|
-
`).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:
|
|
131
|
+
`).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:Pf.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]):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 Co(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function Mo(e){let t=e.outcomes?.[0];return t?.best_ask??t?.price??null}function Mf(e){return e.outcomes?.[0]?.label||null}function Ef(e){return e==null?"low":e>=3?"high":e>=2?"medium":"low"}var ys={high:{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)"},medium:{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)"},low:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},Tf={high:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},medium:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},low:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},vs={high:{dot:"#17c964",label:"predict.matches.confidenceHigh"},medium:{dot:"#f5a524",label:"predict.matches.confidenceMed"},low:{dot:"#71717a",label:"predict.matches.confidenceLow"}};function Lf(e,t){return e||(t==null?"low":t>=.9?"high":t>=.7?"medium":"low")}function _f({tier:e}){let t=ys[e],r=e==="high"?5:e==="medium"?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))})}var Rf={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},If={text:"#9ca3af",icon:"#9ca3af"};function Of(e){return Rf[e]??If}var Df=`
|
|
132
132
|
.match-card button:focus-visible,
|
|
133
133
|
.match-card a:focus-visible,
|
|
134
134
|
.match-card [role="button"]:focus-visible {
|
|
135
135
|
outline: 2px solid hsl(var(--heroui-primary) / 0.4);
|
|
136
136
|
outline-offset: 2px;
|
|
137
137
|
}
|
|
138
|
-
`;function ks({match:e,onSelect:t,onHover:r,getMarketHref:n,LinkComponent:o}){let{t:i}=useTranslation(),s=Mo(e.market_a),l=Mo(e.market_b),a=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=
|
|
138
|
+
`;function ks({match:e,onSelect:t,onHover:r,getMarketHref:n,LinkComponent:o}){let{t:i}=useTranslation(),s=Mo(e.market_a),l=Mo(e.market_b),a=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=Ef(a),u=ys[c],d=s!=null&&l!=null?s<=l?e.source_a:e.source_b:null,m=e.event_a_title||e.event_b_title,p=Lf(e.confidence_tier,e.similarity_score),f=vs[p]??vs.low,g=c==="high"?"orange":"lime";return jsxs("div",{className:"group match-card",style:{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s"},onMouseEnter:h=>{let v=h.currentTarget,S=Tf[c];v.style.borderColor=S.border,v.style.boxShadow=S.shadow,r?.(e);},onMouseLeave:h=>{let v=h.currentTarget;v.style.borderColor="rgba(39,39,42,0.6)",v.style.boxShadow="none";},children:[jsx("style",{children:Df}),a!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${u.bandFrom}, ${u.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:u.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:u.color},children:[a.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"SPREAD"})]}),jsx(_f,{tier:c})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",margin:"0 0 12px"},children:m}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(xs,{source:e.source_a,market:e.market_a,isCheaper:d===e.source_a,onClick:()=>t?.(e,e.source_a),href:n?.(e,e.source_a),LinkComponent:o}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(xs,{source:e.source_b,market:e.market_b,isCheaper:d===e.source_b,onClick:()=>t?.(e,e.source_b),href:n?.(e,e.source_b),LinkComponent:o})]}),d&&a!=null&&jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 12px",borderRadius:8,border:`1px solid ${g==="orange"?"rgba(247,104,22,0.2)":"rgba(199,255,46,0.15)"}`,background:g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)",cursor:"pointer",transition:"all 0.15s",fontSize:11,fontWeight:500,color:g==="orange"?"rgba(247,104,22,0.9)":"rgba(199,255,46,0.85)"},onMouseEnter:h=>{let v=h.currentTarget;v.style.background=g==="orange"?"rgba(247,104,22,0.14)":"rgba(199,255,46,0.10)";},onMouseLeave:h=>{let v=h.currentTarget;v.style.background=g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)";},onClick:()=>t?.(e,d),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,flexShrink:0,color:g==="orange"?"#f76816":"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),i("predict.matches.buyEdge",{platform:d.charAt(0).toUpperCase()+d.slice(1),spread:a.toFixed(1)}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:10,height:10,color:g==="orange"?"rgba(247,104,22,0.5)":"rgba(199,255,46,0.4)"},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.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"})]}),Co(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"})}),Co(e.combined_volume_24h)," ",i("predict.matches.vol24h")]})]}),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:f.dot,flexShrink:0}}),i(f.label)]})]})]})}function xs({source:e,market:t,isCheaper:r,onClick:n,href:o,LinkComponent:i}){let{t:s}=useTranslation(),l=gt(e),a=Of(e),c=Mo(t),u=Mf(t),d=t.volume,m=jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",cursor:o||n?"pointer":void 0,transition:"background 0.15s",background:r?"rgba(199,255,46,0.03)":"transparent"},onMouseEnter:p=>{p.currentTarget.style.background=r?"rgba(199,255,46,0.06)":"rgba(255,255,255,0.02)";},onMouseLeave:p=>{p.currentTarget.style.background=r?"rgba(199,255,46,0.03)":"transparent";},onClick:n,children:[r?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:90,flexShrink:0},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:a.text,textTransform:"uppercase"},children:l.label})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[u&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Co(d)," ",s("predict.matches.volume")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:r?"#c7ff2e":"#f4f4f5"},children:c!=null?(c*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]});return o&&i?jsx(i,{href:o,className:"block",children:m}):m}var Ps=forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,onSelect:o,onHover:i,getMarketHref:s,LinkComponent:l,onStatsChange:a},c){let{t:u}=useTranslation(),{data:d,hasNextPage:m,fetchNextPage:p,isFetchingNextPage:f,isLoading:g,isPlaceholderData:h,refetch:v}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,status:"active",limit:20},{placeholderData:keepPreviousData}),[S,w]=useState(0),[T,x]=useState(false);T&&!h?(x(false),w(B=>B+1)):h&&!T&&x(true),useImperativeHandle(c,()=>({refetch:()=>{v();}}),[v]);let P=useMemo(()=>d?.pages.flatMap(B=>B.items??[])??[],[d]),k=d?.pages[0]?.total,Q=useMemo(()=>{let B=0,E=0,I=0;for(let de of P){let U=de.spread??0;U>B&&(B=U),U>=.03&&I++,de.combined_volume!=null&&(E+=de.combined_volume);}return {activePairs:k??P.length,maxSpread:B,highSpreadCount:I,totalVolume:E}},[P,k]);useEffect(()=>{Q.activePairs>0&&a?.(Q);},[Q,a]);let z=useRef(null),J=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let B=z.current;if(!B)return;let E=new IntersectionObserver(I=>{I[0]?.isIntersecting&&m&&!f&&p();},{rootMargin:"200px"});return E.observe(B),()=>E.disconnect()},[m,f,p]),useEffect(()=>{if(m)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[m]),g)return jsx(Uf,{});if(P.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:u("predict.matches.empty")})});let N=!m&&P.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
139
139
|
@media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
|
|
140
140
|
@keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
141
|
-
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:d?.pages.map(B=>B.items?.map((E,I)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${I*35}ms both`},children:jsx(ks,{match:E,onSelect:o,onHover:i,getMarketHref:s,LinkComponent:l})},`${S}-${E.match_id}-${E.source_a}-${E.market_a?.slug??I}`)))}),jsxs("div",{ref:z,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)}}"}),f&&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"})}),u("predict.matches.loadMore")]})]}),w&&jsx($f,{onScrollToTop:J})]})});function $f({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 Wf(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(Uf,{index:t},t))})]})}function Uf({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 Gf={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function qf(){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 Qf({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.activePairs.toLocaleString()})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(qf,{})]})]})]})]})}function I1({onSelect:e,onHover:t,getMarketHref:r,LinkComponent:n,bgImageSrc:o}){let{t:i}=useTranslation(),[s,l]=useState("spread"),[a,c]=useState(false),[u,d]=useState(5e3),[m,p]=useState(),f=useRef(null),g=useCallback(N=>{l(N);},[]),h=useCallback(N=>{c(N);},[]),v=useCallback(N=>{startTransition(()=>{p(N);});},[]),S=useCallback(()=>{f.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
141
|
+
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:d?.pages.map(B=>B.items?.map((E,I)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${I*35}ms both`},children:jsx(ks,{match:E,onSelect:o,onHover:i,getMarketHref:s,LinkComponent:l})},`${S}-${E.match_id}-${E.source_a}-${E.market_a?.slug??I}`)))}),jsxs("div",{ref:z,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)}}"}),f&&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"})}),u("predict.matches.loadMore")]})]}),N&&jsx(Wf,{onScrollToTop:J})]})});function Wf({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 Uf(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(Kf,{index:t},t))})]})}function Kf({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 qf={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Qf(){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 Xf({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.activePairs.toLocaleString()})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(Qf,{})]})]})]})]})}function O1({onSelect:e,onHover:t,getMarketHref:r,LinkComponent:n,bgImageSrc:o}){let{t:i}=useTranslation(),[s,l]=useState("spread"),[a,c]=useState(false),[u,d]=useState(5e3),[m,p]=useState(),f=useRef(null),g=useCallback(w=>{l(w);},[]),h=useCallback(w=>{c(w);},[]),v=useCallback(w=>{startTransition(()=>{p(w);});},[]),S=useCallback(()=>{f.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
142
142
|
@keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
|
|
143
143
|
.match-fade-in{animation:matchFadeIn .5s ease-out both}
|
|
144
144
|
.match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
|
|
145
145
|
.match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
|
|
146
|
-
`}),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:[o&&jsx("img",{src:o,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(hs,{stats:m})})]}),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:i(Gf[s])}),m&&m.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:i("predict.matches.pairsFound",{count:m.activePairs})})]})]}),jsx(gs,{sortBy:s,onSortChange:g,sortAsc:a,onSortAscChange:h,minVolume:u,onMinVolumeChange:d,onRefresh:S})]})]}),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:i("predict.matches.experimentalFeature")})," \u2014 ",i("predict.matches.disclaimer")]})]}),jsx(Ps,{ref:f,sortBy:s,sortAsc:a,minVolume:u,onSelect:e,onHover:t,getMarketHref:r,LinkComponent:n,onStatsChange:v})]}),jsx(Qf,{stats:m})]})}function To(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}var Jf={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"}},Zf={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 eg(e){return Jf[e]??Zf}function tg(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 rg(e,t){let r=e.entries.find(l=>l.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(l=>l.source===(t?.source_b??e.entries[1]?.source)),o=l=>{if(!l?.outcomes?.[0])return {name:null,price:null};let a=l.outcomes[0];return {name:a.label||null,price:a.best_ask??a.price??null}},i=o(t?.market_a),s=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:n?.event?.volume??null,event:n?.event}]}function H1({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>tg(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[l,a]=useMemo(()=>rg(e,i),[e,i]),c=s!=null&&s>=3;l.yesPrice!=null&&a.yesPrice!=null?l.source==="kalshi"?l.yesPrice>a.yesPrice:a.yesPrice>l.yesPrice:false;let d=l.yesPrice!=null&&a.yesPrice!=null?l.yesPrice<=a.yesPrice?l:a:null,m=d?gt(d.source):null,p=c?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:f=>{let g=f.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let g=f.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[s!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${c?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:c?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:c?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(Es,{data:l,isCheaper:d===l,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(Es,{data:a,isCheaper:d===a,onSelect:t,getEventHref:r,LinkComponent:n})]}),d&&m&&s!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${p==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:p==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>d.event&&t?.(d.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:p==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:d.source.charAt(0).toUpperCase()+d.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:p==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid 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"})]}),To(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"})}),To(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 Es({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),s=gt(e.source),l=eg(e.source),a=e.event?n?.(e.event):void 0,c=jsxs("div",{style:{borderRadius:14,border:`1px solid ${l.border}`,background:l.bg,padding:12,cursor:a||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:u=>{u.currentTarget.style.borderColor=l.hoverBorder;},onMouseLeave:u=>{u.currentTarget.style.borderColor=l.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:l.text,textTransform:"uppercase"},children:s.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?l.priceActiveColor:l.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:[To(e.volume)," ",i("predict.matches.volume")]})]});return a&&o?jsx(o,{href:a,className:"block",children:c}):c}function ig(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}function K1({matches:e,total:t}){let{t:r}=useTranslation(),n=useMemo(()=>{let o=0,i=0,s=new Set;for(let l of e){l.max_spread!=null&&l.max_spread>o&&(o=l.max_spread),l.combined_volume!=null&&(i+=l.combined_volume);for(let a of l.entries)s.add(typeof a.source=="string"?a.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(In,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(Lo,{}),jsx(In,{label:r("predict.matches.stats.totalVolume"),value:ig(n.totalVolume)}),jsx(Lo,{}),jsx(In,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Lo,{}),jsx(In,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function In({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 Lo(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function _s(e){return `${(e*100).toFixed(1)}\xA2`}function ag(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function G1({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",ag(e)),children:_s(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",_s(t)]})]})}var zr=10,ug=64,Ds=40,On=48;function As({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:s,isLoading:l,fetchNextPage:a,hasNextPage:c,isFetchingNextPage:u}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:d,isLoading:m,fetchNextPage:p,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),h=l||m,v=u||g,S=c||f,N=useMemo(()=>{let B=[];return s?.pages&&B.push(...s.pages.flatMap(E=>E.items)),d?.pages&&B.push(...d.pages.flatMap(E=>E.items)),B.sort((E,I)=>(I.timestamp??0)-(E.timestamp??0)),B},[s,d]),T=Math.max(1,Math.ceil(N.length/zr)+(S?1:0)),x=(o-1)*zr,P=N.slice(x,x+zr),k=useCallback(()=>{i(B=>Math.max(1,B-1));},[]),Q=useCallback(async()=>{o*zr>=N.length&&S&&(c&&await a(),f&&await p()),i(E=>E+1);},[o,N.length,S,c,f,a,p]),z=o>1,J=o*zr<N.length||S;if(h)return jsx(xg,{height:r});if(N.length===0&&!S)return jsx(vg,{message:n("predict.profile.noHistory"),height:r});let w=r-Ds-On;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:Ds},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:w},children:[P.map((B,E)=>jsx(mg,{trade:B},B.id??`${x+E}`)),v&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:On},children:[jsxs("button",{type:"button",disabled:!z,onClick:k,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",z?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(T,5)},(B,E)=>{let I=E+1;return jsx("button",{type:"button",onClick:()=>i(I),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",I===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:I},I)}),jsxs("button",{type:"button",disabled:!J,onClick:Q,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",J?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-On},children:P.map((B,E)=>jsx(fg,{trade:B},B.id??`m-${x+E}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:On},children:[jsx("button",{type:"button",disabled:!z,onClick:k,className:cn$1("text-sm cursor-pointer",z?"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:!J,onClick:Q,className:cn$1("text-sm cursor-pointer",J?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function mg({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",n=e.price??0,o=e.usd_size??0,i=Fs(e.type,t),s=r,l=s?"+":"-",a=s?"text-success":"text-foreground",c=e.event?.title??e.market?.question??"\u2014",u=e.event?.image_url,d=e.outcome??"",m=$s(e.timestamp),p=Bs(e),f=gg(e),g=hg(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:ug},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[u&&jsx("img",{src:u,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:c}),jsxs("span",{className:"text-[11px] text-neutral",children:[d&&jsx("span",{className:"mr-1",children:d}),jsx("span",{children:m})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:i}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:zs(n)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",a),children:o>0?jsxs(Fragment,{children:[l,"$",o.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",f!==null?f>=0?"text-success":"text-danger":"text-neutral"),children:f!==null?`${f>=0?"+":"-"}$${Math.abs(f).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:g!==null?`$${g.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:p&&jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Hs,{})})})]})}function fg({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",n=e.price??0,o=e.usd_size??0,i=Fs(e.type,t),s=e.event?.title??e.market?.question??"\u2014",l=$s(e.timestamp),a=Bs(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-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:i})]}),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:zs(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:o>0?`$${o.toFixed(2)}`:"\u2014"})]}),a&&jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Hs,{})})]})]})}function Fs(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 Bs(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function gg(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 hg(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 Hs(){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 vg({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function xg({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 zs(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function $s(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),l=t.getTimezoneOffset(),a=l<=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${a}${c})`}var $r=10,Pg=64,Us=40,Dn=48;function Vs({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,s]=useState(1),{data:l,isLoading:a,fetchNextPage:c,hasNextPage:u,isFetchingNextPage:d}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:p,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:h}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),v=a||p,S=d||h,N=u||g,T=useMemo(()=>{let I=[],de=new Set(["live","open","submitted","pending"]);return l?.pages&&I.push(...l.pages.flatMap(U=>U.items).filter(U=>de.has(U.status))),m?.pages&&I.push(...m.pages.flatMap(U=>U.items).filter(U=>de.has(U.status))),I},[l,m]),x=useCallback(I=>{o.mutate({source:I.source,id:I.id});},[o]),P=Math.max(1,Math.ceil(T.length/$r)+(N?1:0)),k=(i-1)*$r,Q=T.slice(k,k+$r),z=useCallback(()=>{s(I=>Math.max(1,I-1));},[]),J=useCallback(async()=>{i*$r>=T.length&&N&&(u&&await c(),g&&await f()),s(de=>de+1);},[i,T.length,N,u,g,c,f]),w=i>1,B=i*$r<T.length||N;if(v)return jsx(Tg,{height:r});if(T.length===0&&!N)return jsx(Eg,{message:n("predict.profile.noOrders"),height:r});let E=r-Us-Dn;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:Us},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:E},children:[Q.map(I=>jsx(Cg,{order:I,onCancel:x},I.id)),S&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Ks,{className:"hidden lg:flex",currentPage:i,totalPages:P,canGoPrev:w,canGoNext:B,onPrev:z,onNext:J,onPage:s,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Dn},children:Q.map(I=>jsx(Mg,{order:I,onCancel:x},I.id))}),jsx(Ks,{className:"lg:hidden",currentPage:i,totalPages:P,canGoPrev:w,canGoNext:B,onPrev:z,onNext:J,onPage:s,t:n,compact:true})]})}function Cg({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:Pg},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?js(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function Mg({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?js(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 Ks({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:s,onPage:l,t:a,compact:c}){return c?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:Dn},children:[jsx("button",{type:"button",disabled:!n,onClick:i,className:cn$1("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:Dn},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 ",a("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(u,d)=>{let m=d+1;return jsx("button",{type:"button",onClick:()=>l(m),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[a("predict.profile.next")," \u2192"]})]})}function Eg({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Tg({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 js(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Do=10,Ig=64,Ys=40,An=48;function Gs({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=useTranslation(),[s,l]=useState(1),a=useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsx(Fg,{height:r});if(e.length===0)return jsx(Ag,{message:i("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/Do)),u=(s-1)*Do,d=e.slice(u,u+Do),m=s>1,p=s<c,f=r-Ys-An;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:Ys},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:a,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:d.map((g,h)=>jsx(Og,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??u+h}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:An},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>l(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(g,h)=>{let v=h+1;return jsx("button",{type:"button",onClick:()=>l(v),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",v===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:v},v)}),jsxs("button",{type:"button",disabled:!p,onClick:()=>l(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-An},children:d.map((g,h)=>jsx(Dg,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${u+h}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:An},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>l(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!p,onClick:()=>l(g=>g+1),className:cn$1("text-sm cursor-pointer",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Og({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,l=e.current_price??0,a=e.current_value??e.size*l,c=e.size,u=o>0?"text-success":o<0?"text-danger":"text-foreground",d=o>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",h=e.market?.end_at?Bg(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:Ig},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:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",a.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count:Nr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ao(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ao(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",u),children:[jsxs("span",{children:[d,"$",Math.abs(o).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:h}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),n("predict.profile.close")]})})]})}function Dg({position:e,onClose:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,l=o>0?"text-success":o<0?"text-danger":"text-foreground",a=o>0?"+":"",c=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:c})]}),jsx("span",{className:cn$1("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(Fn,{label:n("predict.profile.totalSize"),value:Nr(e.size)}),jsx(Fn,{label:n("predict.profile.markPrice"),value:Ao(s)}),jsx(Fn,{label:n("predict.profile.pnl"),value:`${a}$${Math.abs(o).toFixed(2)} (${a}${i.toFixed(1)}%)`,className:l}),jsx(Fn,{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 Fn({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 Ag({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Fg({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 Ao(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Bg(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),l=t.getTimezoneOffset(),a=l<=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${a}${c})`}catch{return "\u2014"}}function Qs({positions:e,trades:t,isLoading:r}){let{t:n}=useTranslation(),o=useMemo(()=>{let l=0,a=0;for(let p of e)l+=p.realized_pnl??0,a+=p.current_value??p.size*(p.current_price??0);let c=0,u=0,d=0;for(let p of t)c+=p.usd_size??0,p.type==="REDEEM"&&(d++,(p.usd_size??0)>0&&u++);let m=d>0?`${u} / ${d}`:"0 / 0";return {realizedPnl:l,positionsValue:a,volume:c,winRateStr:m}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",s=o.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:n("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Bo,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(Bo,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Bo,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function Bo({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 Ho=600;function jg({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=useTranslation(),[i,s]=useState("positions"),l=!!(e||t),{data:a,isLoading:c}=usePositions({source:"kalshi",user:e??""}),{data:u,isLoading:d}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let k=[];return a?.positions&&k.push(...a.positions),u?.positions&&k.push(...u.positions),k},[a,u]),p=c||d,{data:f,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:v}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),S=useMemo(()=>[...f?.pages?.flatMap(Q=>Q.items)??[],...h?.pages?.flatMap(Q=>Q.items)??[]],[f,h]),N=p||g||v,T=m.length,P=[{key:"positions",label:T>0?`${o("predict.profile.positionsTab")} (${T})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return l?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(Qs,{positions:m,trades:S,isLoading:N}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:P.map(k=>jsx("button",{type:"button",onClick:()=>s(k.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===k.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:k.label},k.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(Gs,{positions:m,isLoading:p,listHeight:Ho,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(Vs,{solanaAddress:e,evmAddress:t,listHeight:Ho}),i==="history"&&jsx(As,{solanaAddress:e,evmAddress:t,listHeight:Ho})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function V2({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[s,l]=useState(false),[a,c]=useState(null),[u,d]=useState(false),m=r||u,p=n||u,f=m?"done":s?"running":"pending",g=p?"done":m&&s?"running":"pending",h=m&&p,v=useCallback(async()=>{c(null),d(false),l(true);try{await o(),d(!0);}catch(x){c(x instanceof Error?x.message:String(x));}finally{l(false);}},[o]),S=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],N=()=>{h?t():v();},T=i(h?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:x=>{x||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:S.map((x,P)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Xg,{index:P+1,status:x.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:x.label}),jsx("span",{className:`text-[11px] leading-none ${x.status==="done"?"text-[#c7ff2e]":x.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:x.status==="done"?i("predict.setup.stepComplete"):x.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:x.desc})]})]},x.key))}),a&&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:a})}),jsx("button",{type:"button",onClick:N,disabled:s,className:h?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):T}),!h&&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 Xg({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})}
|
|
147
|
-
export{
|
|
146
|
+
`}),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:[o&&jsx("img",{src:o,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(hs,{stats:m})})]}),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:i(qf[s])}),m&&m.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:i("predict.matches.pairsFound",{count:m.activePairs})})]})]}),jsx(gs,{sortBy:s,onSortChange:g,sortAsc:a,onSortAscChange:h,minVolume:u,onMinVolumeChange:d,onRefresh:S})]})]}),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:i("predict.matches.experimentalFeature")})," \u2014 ",i("predict.matches.disclaimer")]})]}),jsx(Ps,{ref:f,sortBy:s,sortAsc:a,minVolume:u,onSelect:e,onHover:t,getMarketHref:r,LinkComponent:n,onStatsChange:v})]}),jsx(Xf,{stats:m})]})}function To(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}var Zf={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"}},eg={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 tg(e){return Zf[e]??eg}function rg(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 ng(e,t){let r=e.entries.find(l=>l.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(l=>l.source===(t?.source_b??e.entries[1]?.source)),o=l=>{if(!l?.outcomes?.[0])return {name:null,price:null};let a=l.outcomes[0];return {name:a.label||null,price:a.best_ask??a.price??null}},i=o(t?.market_a),s=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:n?.event?.volume??null,event:n?.event}]}function z1({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>rg(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[l,a]=useMemo(()=>ng(e,i),[e,i]),c=s!=null&&s>=3;l.yesPrice!=null&&a.yesPrice!=null?l.source==="kalshi"?l.yesPrice>a.yesPrice:a.yesPrice>l.yesPrice:false;let d=l.yesPrice!=null&&a.yesPrice!=null?l.yesPrice<=a.yesPrice?l:a:null,m=d?gt(d.source):null,p=c?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:f=>{let g=f.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let g=f.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[s!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${c?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:c?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:c?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(Es,{data:l,isCheaper:d===l,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(Es,{data:a,isCheaper:d===a,onSelect:t,getEventHref:r,LinkComponent:n})]}),d&&m&&s!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${p==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:p==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>d.event&&t?.(d.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:p==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:d.source.charAt(0).toUpperCase()+d.source.slice(1),spread:s.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:p==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid 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"})]}),To(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"})}),To(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 Es({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),s=gt(e.source),l=tg(e.source),a=e.event?n?.(e.event):void 0,c=jsxs("div",{style:{borderRadius:14,border:`1px solid ${l.border}`,background:l.bg,padding:12,cursor:a||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:u=>{u.currentTarget.style.borderColor=l.hoverBorder;},onMouseLeave:u=>{u.currentTarget.style.borderColor=l.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:l.text,textTransform:"uppercase"},children:s.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?l.priceActiveColor:l.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:[To(e.volume)," ",i("predict.matches.volume")]})]});return a&&o?jsx(o,{href:a,className:"block",children:c}):c}function ag(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}function V1({matches:e,total:t}){let{t:r}=useTranslation(),n=useMemo(()=>{let o=0,i=0,s=new Set;for(let l of e){l.max_spread!=null&&l.max_spread>o&&(o=l.max_spread),l.combined_volume!=null&&(i+=l.combined_volume);for(let a of l.entries)s.add(typeof a.source=="string"?a.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(In,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(Lo,{}),jsx(In,{label:r("predict.matches.stats.totalVolume"),value:ag(n.totalVolume)}),jsx(Lo,{}),jsx(In,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Lo,{}),jsx(In,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function In({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 Lo(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function _s(e){return `${(e*100).toFixed(1)}\xA2`}function sg(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function q1({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",sg(e)),children:_s(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",_s(t)]})]})}var zr=10,mg=64,Ds=40,On=48;function As({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:s,isLoading:l,fetchNextPage:a,hasNextPage:c,isFetchingNextPage:u}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:d,isLoading:m,fetchNextPage:p,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),h=l||m,v=u||g,S=c||f,w=useMemo(()=>{let B=[];return s?.pages&&B.push(...s.pages.flatMap(E=>E.items)),d?.pages&&B.push(...d.pages.flatMap(E=>E.items)),B.sort((E,I)=>(I.timestamp??0)-(E.timestamp??0)),B},[s,d]),T=Math.max(1,Math.ceil(w.length/zr)+(S?1:0)),x=(o-1)*zr,P=w.slice(x,x+zr),k=useCallback(()=>{i(B=>Math.max(1,B-1));},[]),Q=useCallback(async()=>{o*zr>=w.length&&S&&(c&&await a(),f&&await p()),i(E=>E+1);},[o,w.length,S,c,f,a,p]),z=o>1,J=o*zr<w.length||S;if(h)return jsx(bg,{height:r});if(w.length===0&&!S)return jsx(xg,{message:n("predict.profile.noHistory"),height:r});let N=r-Ds-On;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:Ds},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:N},children:[P.map((B,E)=>jsx(fg,{trade:B},B.id??`${x+E}`)),v&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:On},children:[jsxs("button",{type:"button",disabled:!z,onClick:k,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",z?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(T,5)},(B,E)=>{let I=E+1;return jsx("button",{type:"button",onClick:()=>i(I),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",I===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:I},I)}),jsxs("button",{type:"button",disabled:!J,onClick:Q,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",J?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-On},children:P.map((B,E)=>jsx(gg,{trade:B},B.id??`m-${x+E}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:On},children:[jsx("button",{type:"button",disabled:!z,onClick:k,className:cn$1("text-sm cursor-pointer",z?"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:!J,onClick:Q,className:cn$1("text-sm cursor-pointer",J?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function fg({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",n=e.price??0,o=e.usd_size??0,i=Fs(e.type,t),s=r,l=s?"+":"-",a=s?"text-success":"text-foreground",c=e.event?.title??e.market?.question??"\u2014",u=e.event?.image_url,d=e.outcome??"",m=$s(e.timestamp),p=Bs(e),f=hg(e),g=vg(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:mg},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[u&&jsx("img",{src:u,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:c}),jsxs("span",{className:"text-[11px] text-neutral",children:[d&&jsx("span",{className:"mr-1",children:d}),jsx("span",{children:m})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:i}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:zs(n)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",a),children:o>0?jsxs(Fragment,{children:[l,"$",o.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",f!==null?f>=0?"text-success":"text-danger":"text-neutral"),children:f!==null?`${f>=0?"+":"-"}$${Math.abs(f).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:g!==null?`$${g.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:p&&jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Hs,{})})})]})}function gg({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",n=e.price??0,o=e.usd_size??0,i=Fs(e.type,t),s=e.event?.title??e.market?.question??"\u2014",l=$s(e.timestamp),a=Bs(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-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:i})]}),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:zs(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:o>0?`$${o.toFixed(2)}`:"\u2014"})]}),a&&jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Hs,{})})]})]})}function Fs(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 Bs(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function hg(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 vg(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 Hs(){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 xg({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function bg({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 zs(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function $s(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),l=t.getTimezoneOffset(),a=l<=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${a}${c})`}var $r=10,Cg=64,Us=40,Dn=48;function Vs({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,s]=useState(1),{data:l,isLoading:a,fetchNextPage:c,hasNextPage:u,isFetchingNextPage:d}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:p,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:h}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),v=a||p,S=d||h,w=u||g,T=useMemo(()=>{let I=[],de=new Set(["live","open","submitted","pending"]);return l?.pages&&I.push(...l.pages.flatMap(U=>U.items).filter(U=>de.has(U.status))),m?.pages&&I.push(...m.pages.flatMap(U=>U.items).filter(U=>de.has(U.status))),I},[l,m]),x=useCallback(I=>{o.mutate({source:I.source,id:I.id});},[o]),P=Math.max(1,Math.ceil(T.length/$r)+(w?1:0)),k=(i-1)*$r,Q=T.slice(k,k+$r),z=useCallback(()=>{s(I=>Math.max(1,I-1));},[]),J=useCallback(async()=>{i*$r>=T.length&&w&&(u&&await c(),g&&await f()),s(de=>de+1);},[i,T.length,w,u,g,c,f]),N=i>1,B=i*$r<T.length||w;if(v)return jsx(Lg,{height:r});if(T.length===0&&!w)return jsx(Tg,{message:n("predict.profile.noOrders"),height:r});let E=r-Us-Dn;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:Us},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:E},children:[Q.map(I=>jsx(Mg,{order:I,onCancel:x},I.id)),S&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Ks,{className:"hidden lg:flex",currentPage:i,totalPages:P,canGoPrev:N,canGoNext:B,onPrev:z,onNext:J,onPage:s,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Dn},children:Q.map(I=>jsx(Eg,{order:I,onCancel:x},I.id))}),jsx(Ks,{className:"lg:hidden",currentPage:i,totalPages:P,canGoPrev:N,canGoNext:B,onPrev:z,onNext:J,onPage:s,t:n,compact:true})]})}function Mg({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:Cg},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?js(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function Eg({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?js(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 Ks({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:s,onPage:l,t:a,compact:c}){return c?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:Dn},children:[jsx("button",{type:"button",disabled:!n,onClick:i,className:cn$1("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:Dn},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 ",a("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(u,d)=>{let m=d+1;return jsx("button",{type:"button",onClick:()=>l(m),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[a("predict.profile.next")," \u2192"]})]})}function Tg({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Lg({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 js(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Do=10,Og=64,Ys=40,An=48;function Gs({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=useTranslation(),[s,l]=useState(1),a=useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsx(Bg,{height:r});if(e.length===0)return jsx(Fg,{message:i("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/Do)),u=(s-1)*Do,d=e.slice(u,u+Do),m=s>1,p=s<c,f=r-Ys-An;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:Ys},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:a,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:d.map((g,h)=>jsx(Dg,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??u+h}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:An},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>l(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(g,h)=>{let v=h+1;return jsx("button",{type:"button",onClick:()=>l(v),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",v===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:v},v)}),jsxs("button",{type:"button",disabled:!p,onClick:()=>l(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-An},children:d.map((g,h)=>jsx(Ag,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${u+h}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:An},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>l(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!p,onClick:()=>l(g=>g+1),className:cn$1("text-sm cursor-pointer",p?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Dg({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,l=e.current_price??0,a=e.current_value??e.size*l,c=e.size,u=o>0?"text-success":o<0?"text-danger":"text-foreground",d=o>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",h=e.market?.end_at?Hg(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:Og},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:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",a.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count:Nr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ao(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ao(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",u),children:[jsxs("span",{children:[d,"$",Math.abs(o).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,i.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:h}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),n("predict.profile.close")]})})]})}function Ag({position:e,onClose:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,l=o>0?"text-success":o<0?"text-danger":"text-foreground",a=o>0?"+":"",c=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:c})]}),jsx("span",{className:cn$1("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(Fn,{label:n("predict.profile.totalSize"),value:Nr(e.size)}),jsx(Fn,{label:n("predict.profile.markPrice"),value:Ao(s)}),jsx(Fn,{label:n("predict.profile.pnl"),value:`${a}$${Math.abs(o).toFixed(2)} (${a}${i.toFixed(1)}%)`,className:l}),jsx(Fn,{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 Fn({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 Fg({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Bg({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 Ao(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Hg(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),l=t.getTimezoneOffset(),a=l<=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${a}${c})`}catch{return "\u2014"}}function Qs({positions:e,trades:t,isLoading:r}){let{t:n}=useTranslation(),o=useMemo(()=>{let l=0,a=0;for(let p of e)l+=p.realized_pnl??0,a+=p.current_value??p.size*(p.current_price??0);let c=0,u=0,d=0;for(let p of t)c+=p.usd_size??0,p.type==="REDEEM"&&(d++,(p.usd_size??0)>0&&u++);let m=d>0?`${u} / ${d}`:"0 / 0";return {realizedPnl:l,positionsValue:a,volume:c,winRateStr:m}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",s=o.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:n("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Bo,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(Bo,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Bo,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function Bo({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 Ho=600;function Yg({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=useTranslation(),[i,s]=useState("positions"),l=!!(e||t),{data:a,isLoading:c}=usePositions({source:"kalshi",user:e??""}),{data:u,isLoading:d}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let k=[];return a?.positions&&k.push(...a.positions),u?.positions&&k.push(...u.positions),k},[a,u]),p=c||d,{data:f,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:v}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),S=useMemo(()=>[...f?.pages?.flatMap(Q=>Q.items)??[],...h?.pages?.flatMap(Q=>Q.items)??[]],[f,h]),w=p||g||v,T=m.length,P=[{key:"positions",label:T>0?`${o("predict.profile.positionsTab")} (${T})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return l?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(Qs,{positions:m,trades:S,isLoading:w}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:P.map(k=>jsx("button",{type:"button",onClick:()=>s(k.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===k.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:k.label},k.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(Gs,{positions:m,isLoading:p,listHeight:Ho,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(Vs,{solanaAddress:e,evmAddress:t,listHeight:Ho}),i==="history"&&jsx(As,{solanaAddress:e,evmAddress:t,listHeight:Ho})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function j2({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[s,l]=useState(false),[a,c]=useState(null),[u,d]=useState(false),m=r||u,p=n||u,f=m?"done":s?"running":"pending",g=p?"done":m&&s?"running":"pending",h=m&&p,v=useCallback(async()=>{c(null),d(false),l(true);try{await o(),d(!0);}catch(x){c(x instanceof Error?x.message:String(x));}finally{l(false);}},[o]),S=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],w=()=>{h?t():v();},T=i(h?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:x=>{x||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:S.map((x,P)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Jg,{index:P+1,status:x.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:x.label}),jsx("span",{className:`text-[11px] leading-none ${x.status==="done"?"text-[#c7ff2e]":x.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:x.status==="done"?i("predict.setup.stepComplete"):x.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:x.desc})]})]},x.key))}),a&&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:a})}),jsx("button",{type:"button",onClick:w,disabled:s,className:h?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):T}),!h&&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 Jg({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})}
|
|
147
|
+
export{g0 as CHART_RANGE_DURATION,m0 as CHART_RANGE_PERIOD,f0 as CHART_RANGE_SAMPLE_INTERVAL,rn as CandlestickPeriod,o0 as CategoriesSkeleton,qo as CategoriesUI,Jo as CategoriesWidget,je as ChartRange,nn as DEFAULT_CHART_RANGE,qn as DEFAULT_FILTER_STATE,Sr as DEFAULT_PAGE_SIZE,b0 as DEFAULT_PRICE_HISTORY_INTERVAL,lb as EventDetailPage,Ir as EventDetailSkeleton,Da as EventDetailUI,Aa as EventDetailWidget,Di as EventItem,ya as EventMarketDepthChartUI,Pa as EventMarketDetailWidget,Ea as EventPriceChart,gi as EventsFilterUI,av as EventsHero,rv as EventsPage,Th as EventsPageSkeleton,Xn as EventsSkeleton,ki as EventsToolbarUI,zi as EventsUI,Wi as EventsWidget,dn as KycModal,Kn as MAX_PRICE_HISTORY_MARKETS,z1 as MatchGroupCard,ks as MatchMarketCard,gs as MatchesFilterBar,hs as MatchesHero,O1 as MatchesPage,V1 as MatchesStatsBar,Ps as MatchesWidget,x0 as ORDER_MAX_PRICE,v0 as ORDER_MIN_PRICE,on as ORDER_MIN_QUANTITY,an as ORDER_MIN_USDC,h0 as ORDER_PRICE_STEP,wo as PREDICT_SEARCH_MODAL_ID,io as PREDICT_SELL_MODAL_ID,Pr as PREDICT_TRADE_MODAL_ID,y0 as PRICE_HISTORY_SAMPLE_INTERVAL,$y as PredictSearchModal,sa as PredictSellModal,mn as PredictTradeModal,Pl as PredictWalletProvider,ur as PriceHistoryInterval,Yg as ProfilePage,yi as SORT_PRESETS,Un as STATIC_CATEGORIES,Qy as SearchEventsButton,ja as SearchHistoryUI,Ya as SearchHistoryWidget,Ga as SearchInputUI,qa as SearchResultItemUI,es as SearchResultListWidget,is as SearchWidget,ia as SellFormUI,vn as SellFormWidget,j2 as SetupModal,Xu as SimilarEventCard,za as SimilarEventsSection,Hx as SourceBadge,q1 as SpreadIndicator,ma as TradeFormSkeleton,mi as TradeFormUI,un as TradeFormWidget,da as UserActivitySection,Qn as countActiveFilters,Xt as fireCelebration,Ne as floorToDecimals,Or as formatKMB,Nr as formatShares,gt as getSourceMeta,cn as parsePolymarketError,sn as resolveExpiration,ln as roundToTickSize,gb as useEventDetail,Ni as useEventsInfinite,Tn as usePredictSearchHistory,wr as usePredictWallet,Qa as useSearchResultListScript,os as useSearchScript,Qi as useSellForm,ii as useTradeForm,dl as version};//# sourceMappingURL=index.mjs.map
|
|
148
148
|
//# sourceMappingURL=index.mjs.map
|