@liberfi.io/ui-predict 4.0.54 → 4.0.56
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 +46 -5
- package/dist/index.d.ts +46 -5
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,createElement,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTradeResultConfirmation,useTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositionsMulti,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents,usePositions}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount,debounce}from'@liberfi.io/utils';import Ro from'canvas-confetti';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {List,useDynamicRowHeight}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var gc={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},Ei=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Mo=(()=>{let e=t=>{let r=Ei.indexOf(t);return r===-1?Ei.length:r};return Object.entries(gc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function _i({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:c}){let{t:u}=useTranslation(),p=useCallback(()=>{n(null);},[n]),d=u("predict.categories.trending");return jsxs("div",{className:cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",c),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(Li,{label:d,isSelected:t===null,onPress:p,showPulse:d===a}),jsx(xc,{}),e.map(f=>{let l=f.slug??f.category,m=f.label??f.category;return jsx(Li,{label:m,isSelected:t===l,onPress:()=>n(l),badge:f.badge,showPulse:l===a||m===a},l)})]})}),s&&jsx("div",{className:"flex-shrink-0",children:s})]}),t&&o.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(Ri,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(f=>{let l=f.slug??f.label;return jsx(Ri,{label:f.label,icon:f.icon,isSelected:r===l,onPress:()=>i(l)},l)})]})})]})}function Li({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,o&&jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function xc(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Ri({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function Nv({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 Oi(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function kc(e){return `predict.categories.category.${Oi(e)}`}function Di(e){return `predict.categories.tag.${Oi(e)}`}function Sc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(kc(r.slug),r.label),tags:r.tags.map(o=>({slug:o.slug,label:t(Di(o.slug),o.label),icon:o.icon}))}))}function wc(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Di(r.slug),r.label),icon:r.icon})):[]}function Ai({onSelect:e,trailing:t,className:r}){let{t:o}=useTranslation(),n=useCallback((m,g)=>{let v=o(m);return typeof v=="string"&&v!==m?v:g},[o]),[i,s]=useState(null),[a,c]=useState(null),u=useCallback(m=>{s(m),c(null),e?.({categorySlug:m,tagSlug:null});},[e]),p=useCallback(m=>{c(m),e?.({categorySlug:i,tagSlug:m});},[i,e]),d=Sc(Mo,n),f=Mo.find(m=>m.slug===i),l=wc(f,n);return jsx(_i,{categories:d,selectedCategory:i,selectedTag:a,activeTags:l,onCategorySelect:u,onTagSelect:p,trailing:t,className:r})}function Cn(e){return {title:e.title,imageUrl:e.image_url}}function Mn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??o?.best_ask??o?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??o?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:o?.label??"No"}}var jr=24,Eo=4,Tn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},le={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},En=le.ALL,Dv={[le.ONE_DAY]:Tn.ONE_MINUTE,[le.ONE_WEEK]:Tn.ONE_HOUR,[le.ONE_MONTH]:Tn.ONE_HOUR,[le.ALL]:Tn.ONE_DAY},Av={[le.ONE_DAY]:300,[le.ONE_WEEK]:3600,[le.ONE_MONTH]:10800,[le.ALL]:1440*60},Fv={[le.ONE_DAY]:1440*60,[le.ONE_WEEK]:10080*60,[le.ONE_MONTH]:720*60*60,[le.ALL]:null},Ln=1,Rn=1,Bv=1,Hv=1,zv=99,_r={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Wv=_r.ONE_WEEK,Uv={[_r.ONE_HOUR]:60,[_r.SIX_HOURS]:60,[_r.ONE_DAY]:300,[_r.ONE_WEEK]:1800,[_r.MAX]:1800};var Hi=createContext(null);function br(){let e=useContext(Hi);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Lc=1e4;function Rc({pollingInterval:e=Lc,enabled:t=true,enableKalshi:r=true,children:o}){let n=useWallets(),i=useMemo(()=>n.find(I=>I.chainNamespace===ChainNamespace.SOLANA&&I.isConnected)?.address,[n]),s=useMemo(()=>n.find(I=>I.chainNamespace===ChainNamespace.EVM&&I.isConnected)?.address,[n]),{data:a,isLoading:c,isFetching:u,error:p}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:d,isLoading:f}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:l,isLoading:m}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=l?.safe_address,h=l?.verified??false,v=l?.wallet_kind??"deposit",b=l?.deposit_wallet_address,N=v==="safe"?l?.safe_address:b,k=v==="safe"?l?.safe_deployed??false:l?.deposit_wallet_deployed??false,{data:x,isLoading:y,isFetching:P,error:S}=useBalance({source:"polymarket",user:s??""},{enabled:t&&h&&!!s,refetchInterval:e}),R=useMemo(()=>({solanaAddress:i,evmAddress:s,polymarketWalletKind:v,polymarketWalletAddress:N,polymarketDepositWalletAddress:b,polymarketWalletDeployed:k,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:h&&x?Number(x.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:h,polymarketSafeDeployed:l?.safe_deployed??false,polymarketTokenApproved:l?.token_approved??false,polymarketSetupLoading:m,isLoading:c||y,isFetching:u||P,error:p??S??null}),[i,s,v,N,b,k,g,a,x,h,d,f,l,m,c,y,u,P,p,S]);return jsx(Hi.Provider,{value:R,children:o})}var Ic={minutes:60,hours:3600,days:86400};function _n(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*Ic[r]}}function In(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function ve(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function Oc(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Dc=100,Ac=300;function zi(e,t){return Dc/1e4+Math.max(0,e)/1e4*Oc(t)}function Fc(e,t){let r=e?.[t],o=typeof r=="number"?r:Number(r);return Number.isFinite(o)?o:void 0}function Bc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Wi(e){let t=Fc(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],o=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(o)&&o>=0?o*1e4:Bc(e,"polymarket.sportsMarketType")?Ac:0}function Ui({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:o=0,pricePerShare:n}){if(t==null||!Number.isFinite(t))return 0;let i=ve(Math.max(0,t),2);if(e!=="polymarket")return i;let s=zi(o,n??NaN),a=i/(1+s)-r;return ve(Math.max(0,a),2)}function $i({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let o=zi(r,t);return e*o}function On(e,t,r){let o=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(o)return t("predict.trade.polymarket.minOrderSize",{current:o[1],min:o[2]});let n=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(n){let s=parseInt(n[1],10)/1e6,a=parseInt(n[2],10)/1e6,c=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:ve(s,2).toFixed(2),active:ve(a,2).toFixed(2),available:ve(c,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 qr(e,t=2){return parseFloat(ve(e,t).toFixed(t)).toString()}function Ki(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Ro({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Ro({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Ro({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var Vi={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function Hc(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function _o(e,t,r){let o=e(t);return o&&o!==t?o:r}function Ir(e,t){let r=Hc(t)?Vi.zh:Vi.en;return {submitted:_o(e,"predict.trade.resultSubmitted",r.submitted),completed:_o(e,"predict.trade.resultCompleted",r.completed),delayed:_o(e,"predict.trade.resultDelayed",r.delayed)}}function $c({deadlineAt:e}){let[t,r]=useState(()=>Math.max(0,e-Date.now()));return useEffect(()=>{let o=setInterval(()=>{r(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(o)},[e]),`${Math.max(0,Math.ceil(t/1e3))}s`}function Or({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:o}){return {id:e,submitted:()=>{let n=Date.now()+t;toast.progress({id:e,message:o.submitted,duration:t,progress:true,action:createElement($c,{deadlineAt:n})});},completed:()=>{toast.update(e,{type:"success",message:o.completed,duration:5e3}),r&&Ki();},delayed:()=>{toast.update(e,{type:"blank",message:o.delayed,duration:8e3});},failed:n=>{toast.update(e,{type:"error",message:n,duration:8e3});}}}function Gi({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n,i18n:i}=useTranslation(),{status:s}=useAuth(),a=useWallets(),c=usePredictClient(),u=useContext(PolymarketContext),{start:p}=useTradeResultConfirmation(),d=e.source,f=d==="polymarket",l=a.find(L=>L.chainNamespace===ChainNamespace.SOLANA&&L.isConnected),m=a.find(L=>L.chainNamespace===ChainNamespace.EVM&&L.isConnected&&"switchChain"in L),g=s==="authenticated",h=l?.address,v=m?.address,[b,N]=useState(t),[k,x]=useState("market"),[y,P]=useState(NaN),[S,R]=useState(NaN),[I,z]=useState(false),[K,W]=useState(null),[G,Y]=useState(false),[Q,re]=useState(false),[w,M]=useState("1h"),[$,J]=useState(30),[ne,O]=useState("minutes"),Se=useMemo(()=>Ir(n,i),[i,n]),A=useCallback(async(L,Ne)=>{let Re=Or({celebrateOnCompleted:true,messages:Se});Re.submitted(),await p({source:d,user:d==="kalshi"?h:v,kalshiUser:h,polymarketUser:v,marketSlug:e.slug,eventSlug:e.event_slug,expectation:L,getOrdersHeaders:Ne})==="confirmed"?Re.completed():Re.delayed();},[p,v,e.event_slug,e.slug,d,Se,h]),be=useMemo(()=>{if(d!=="polymarket")return;let L=e.provider_meta?.["polymarket.clobTokenIds"];return L?(typeof L=="string"?JSON.parse(L):L)[b==="yes"?0:1]:void 0},[d,e.provider_meta,b]),{data:pt,isLoading:Ee}=useTickSize(be),qe=pt?.minimum_tick_size?String(pt.minimum_tick_size):"0.01",{data:st,isLoading:we}=useFeeRate(be),Ze=st?.base_fee??0,et=String(Ze),tt=useMemo(()=>Wi(e.provider_meta),[e.provider_meta]),{data:at}=useRebateConfig(),Ot=at?.builder_enabled&&at.builder_code?at.builder_code:void 0,ze=null,rt=false,We=null,Ue=false,nt,mt,Mt;try{let L=br();ze={kalshiUsdcBalance:L.kalshiUsdcBalance,polymarketUsdcBalance:L.polymarketUsdcBalance,isLoading:L.isLoading},rt=L.kalshiKycVerified,We=L.kalshiKycUrl,Ue=L.polymarketSetupVerified,nt=L.polymarketSafeAddress,mt=L.polymarketWalletKind,Mt=L.polymarketWalletAddress;}catch{}let E=d==="kalshi"&&!rt,de=d==="polymarket"&&!Ue,{data:Le}=useRealtimeOrderbook({slug:e.slug,source:d,outcome:b},{enabled:e.status==="open"}),Ge=useMemo(()=>{let L=pickBestAsk(Le,b);if(L!=null&&L>0)return L;let Ne=b==="yes"?0:1,Re=e.outcomes[Ne];return Re?.best_ask??Re?.price??.5},[Le,e.outcomes,b]),Vr=useCallback(L=>{x(L);},[]),Dt=useCallback(L=>{N(L),R(NaN);},[]);useEffect(()=>{Dt(t);},[t,Dt]),useEffect(()=>{k==="limit"&&isNaN(S)&&R(Math.round(Ge*1e4)/1e4);},[k,S,Ge]);let Pt=useMemo(()=>isNaN(y)||y<=0?0:Ge>0?y/Ge:0,[y,Ge]),Pe=useMemo(()=>walkOrderbook({orderbook:Le,outcome:b,side:"buy",sharesNeeded:Pt,slippageBps:r}),[Le,b,Pt,r]),ot=useMemo(()=>Pe.status==="ok"&&Pe.worstPrice!=null&&Pe.worstPrice>0?Pe.worstPrice:Ge,[Pe,Ge]),At=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),F=e.provider_meta?.["dflow.yesMint"]??"",$e=e.provider_meta?.["dflow.noMint"]??"",ft=SOLANA_TOKENS.stablecoins.USDC.address,go=b==="yes"?F:$e,qt=ft,Gt=go,Ft=d==="kalshi"?h??"":v??"",{data:Ye,isLoading:ho}=usePositionsMulti({kalshi_user:d==="kalshi"?Ft:void 0,polymarket_user:d==="polymarket"?Ft:void 0},{enabled:!!Ft}),vo=d==="kalshi"&&!!qt&&!!Gt&&!!h&&At!=="0",{refetch:hn}=useDFlowQuote({inputMint:qt,outputMint:Gt,amount:At,userPublicKey:h??"",slippageBps:100},{enabled:vo}),Tt=useMemo(()=>ze?d==="kalshi"?ze.kalshiUsdcBalance:ze.polymarketUsdcBalance:Ye&&Ye.positions.reduce((Ne,Re)=>Re.side==="USDC"||Re.side==="collateral"?Ne+(Re.current_value??0):Ne,0)||null,[ze,Ye,d]),bo=ze?ze.isLoading:ho,Yt=useMemo(()=>k==="limit"&&f&&!isNaN(S)?S:Ge,[k,f,S,Ge]),xo=useMemo(()=>Ui({source:d,usdcBalance:Tt,feeRateBps:tt,pricePerShare:Yt}),[d,Tt,tt,Yt]),Bt=Tt==null?null:xo,vn=useMemo(()=>isNaN(y)||y<=0?0:y,[y]),nr=useMemo(()=>isNaN(y)||y<=0?0:Yt>0?y/Yt*1:0,[y,Yt]),or=useMemo(()=>d!=="polymarket"||isNaN(y)||y<=0?0:$i({usdcAmount:y,pricePerShare:Yt,feeRateBps:tt}),[d,y,Yt,tt]),pr=nr-vn-or,Er=useCallback(L=>{if(isNaN(L)){P(NaN);return}P(Math.round(Math.max(0,L)*100)/100);},[]),yo=useCallback(L=>{if(isNaN(L)){R(NaN);return}R(Math.round(L*1e4)/1e4);},[]),mr=useCallback(()=>{P(NaN),R(NaN),x("market"),re(false),M("1h"),J(30),O("minutes");},[]),fr=useMemo(()=>{let L=[];return isNaN(y)||y<=0?L.push(n("predict.trade.minAmountUsd",{amount:Rn})):y<Rn&&L.push(n("predict.trade.minAmountUsd",{amount:Rn})),e.status!=="open"&&L.push(n("predict.trade.marketNotActive")),Bt!=null&&!isNaN(y)&&y>0&&y>Bt&&L.push(n("predict.trade.insufficientBalance")),k==="limit"&&f&&(isNaN(S)||S<.01||S>.99)&&L.push(n("predict.trade.limitPriceRange")),k==="limit"&&f&&Q&&w==="custom"&&(isNaN($)||$<=0)&&L.push(n("predict.trade.expiration.invalidDate")),d==="polymarket"&&k==="market"&&!isNaN(y)&&y>0&&Pt>0&&(Pe.status==="insufficient_liquidity"?L.push(n("predict.trade.insufficientLiquidity",{available:ve(Pe.totalAvailable,2)})):Pe.status==="exceeds_slippage"&&L.push(n("predict.trade.priceImpactTooHigh",{impact:(Pe.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:L.length===0,errors:L}},[y,e.status,Bt,k,f,S,Q,w,$,d,Pt,Pe,r,n]),Nt=useMemo(()=>Bt==null||isNaN(y)||y<=0?false:y>Bt,[Bt,y]),bn=useCallback(()=>{o?.(d);},[o,d]),{mutateAsync:xn}=useDFlowSubmit(),{data:gr}=useOrder({id:K??"",source:d},{enabled:!!K});useEffect(()=>{if(!gr||!K)return;let{status:L}=gr;L==="closed"?(W(null),z(false),A("buy-market"),mr()):(L==="failed"||L==="expired")&&(z(false),W(null),toast.error(n("predict.trade.submitError")));},[A,gr,K,mr,n]);let yn=useCallback(async()=>{if(!h||!l)return;if(!qt||!Gt){toast.error("Missing token mint addresses"),z(false);return}if(!rt){Y(true),z(false);return}let gt=(await hn()).data?.transaction;if(!gt){toast.error(n("predict.trade.submitError")),z(false);return}let hr=Uint8Array.from(atob(gt),Qe=>Qe.charCodeAt(0)),ir=await l.signTransaction(hr),ht=await xn({signedTransaction:btoa(String.fromCharCode(...ir)),orderContext:{user_public_key:h,input_mint:qt,output_mint:Gt,amount:At,price:String(Ge),side:"BUY",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});W(ht.signature);},[h,l,hn,xn,qt,Gt,At,Ge,b,e.slug,n,rt]),kn=useCallback(async()=>{if(!m||!u)return;let L=m.chain,Ne=L!==Chain.POLYGON;Ne&&await m.switchChain(Chain.POLYGON);try{let Re=await m.getEip1193Provider();if(!Re){toast.error(n("predict.trade.submitError")),z(!1);return}let gt=mt==="deposit"&&!!Mt,hr=!gt&&!!nt,ir=gt?Mt:nt,ht={address:m.address,signatureType:gt?3:hr?2:0,signTypedData:async(Oe,Qt,sr,Lr)=>{let ar=[];"name"in Oe&&ar.push({name:"name",type:"string"}),"version"in Oe&&ar.push({name:"version",type:"string"}),"chainId"in Oe&&ar.push({name:"chainId",type:"uint256"}),"verifyingContract"in Oe&&ar.push({name:"verifyingContract",type:"address"}),"salt"in Oe&&ar.push({name:"salt",type:"bytes32"});let So={EIP712Domain:ar,...Qt};return await Re.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Oe,types:So,primaryType:sr,message:Lr})]})}},Qe=u.credentials??await u.authenticate(ht),Sn=b==="yes"?0:1,wn="",C=e.provider_meta?.["polymarket.clobTokenIds"];C&&(wn=(typeof C=="string"?JSON.parse(C):C)[Sn]??"");let Ce=e.provider_meta?.["polymarket.negRisk"]??!1,_e=k==="limit"&&!isNaN(S)?S:ot,Ke=In(_e,qe),lt=k==="limit"?Q?"GTD":"GTC":"FOK",Et=k==="market"?y:Ke>0?y/Ke:0,ct={tokenId:wn,price:Ke,size:Et,side:"BUY",orderType:lt,tickSize:qe,negRisk:Ce,...ir&&{funderAddress:ir},...Ot&&{builderCode:Ot},...k==="limit"&&Q&&{expiration:_n(w,$,ne)}},he;if(gt)he=await buildSignedV2OrderPayload({signer:ht,depositWalletAddress:ir,input:ct,owner:Qe.apiKey});else {let Oe=buildCtfExchangeDomain(Ce),Qt=buildOrderMessage({...ct,signerAddress:ht.address,signatureType:ht.signatureType,feeRateBps:et}),sr=await ht.signTypedData(Oe,CTF_ORDER_TYPES,"Order",Qt),Lr=buildSignedOrder(Qt,sr,ct.orderType);he=buildClobPayload(Lr,Qe.apiKey);}await c.executePolymarketOrder({payload:he,l2_api_key:Qe.apiKey,l2_secret:Qe.secret,l2_passphrase:Qe.passphrase,signer_address:Qe.address,owner:Qe.apiKey}),A(k==="limit"?"buy-limit":"buy-market",async()=>await buildPolymarketL2Headers(Qe.address,{apiKey:Qe.apiKey,secret:Qe.secret,passphrase:Qe.passphrase,method:"GET",requestPath:"/data/orders"})),mr(),z(!1);}finally{Ne&&L&&m.switchChain(L).catch(()=>{});}},[m,u,b,e.provider_meta,k,A,S,ot,y,c,Q,w,$,ne,mr,n,qe,et,nt,mt,Mt,Ot]),ko=useCallback(async()=>{if(!(!fr.isValid||!g)){z(true),W(null),Y(false);try{d==="kalshi"?await yn():await kn();}catch(L){let Ne=L instanceof Error?L.message:"",Re=d==="polymarket"&&Ne?On(Ne,n,"buy"):Ne||void 0;toast.error(Re||n("predict.trade.submitError")),z(false);}}},[fr.isValid,g,d,yn,kn,n]);return {outcome:b,orderType:k,quantity:y,limitPrice:S,shares:Pt,estimatedCost:vn,estimatedFee:or,potentialPayout:nr,potentialProfit:pr,pricePerShare:Ge,usdcBalance:Tt,maxBuyAmount:xo,spendableUsdcBalance:Bt,isBalanceLoading:bo,isMarketDataLoading:d==="polymarket"&&(we||Ee),isSubmitting:I,authStatus:s,validation:fr,isInsufficientBalance:Nt,source:d,supportsLimitOrder:f,kycRequired:G,needsKyc:E,needsSetup:de,kycUrl:We,expirationEnabled:Q,expirationPreset:w,customDuration:$,customDurationUnit:ne,setOutcome:Dt,setOrderType:Vr,setQuantity:Er,setLimitPrice:yo,setExpirationEnabled:re,setExpirationPreset:M,setCustomDuration:J,setCustomDurationUnit:O,submit:ko,notifyInsufficientBalance:bn}}function An({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:o(n)})]},n))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var Md=["5m","1h","12h","24h","eod","custom"],Td={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},Ed=["minutes","hours","days"],Ld={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Rd={maximumFractionDigits:0},xr="-";function ns({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,potentialProfit:c,potentialPayout:u,estimatedCost:p,estimatedFee:d=0,usdcBalance:f,isBalanceLoading:l,isMarketDataLoading:m,isSubmitting:g,authStatus:h,isValid:v,validationErrors:b,isInsufficientBalance:N,onInsufficientBalance:k,supportsLimitOrder:x,maxBuyAmount:y,kycRequired:P,needsKyc:S,needsSetup:R,kycUrl:I,expirationEnabled:z,expirationPreset:K,customDuration:W,customDurationUnit:G,oddsFormatter:Y,onOutcomeChange:Q,onOrderTypeChange:re,onQuantityChange:w,onLimitPriceChange:M,onExpirationEnabledChange:$,onExpirationPresetChange:J,onCustomDurationChange:ne,onCustomDurationUnitChange:O,onSubmit:Se}){let{t:A}=useTranslation(),[be,pt]=useState(true),Ee=useDisclosure(),[qe,st]=useState(""),we=useRef(false);useEffect(()=>{we.current||st(isNaN(i)?"":String(i));},[i]);let[Ze,et]=useState(""),tt=useRef(false);useEffect(()=>{tt.current||(isNaN(s)?et(""):et(String(parseFloat((s*100).toFixed(2)))));},[s]);let at=useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(et(F),F===""||F==="."){M(NaN);return}let ft=parseFloat(F);isNaN(ft)||M(ft/100);},[M]),Ot=useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(st(F),ot(false),F===""||F==="."){w(NaN);return}let ft=parseFloat(F);isNaN(ft)||w(ft);},[w]);useEffect(()=>{P&&!Ee.isOpen&&Ee.onOpen();},[P]);let ze=useMemo(()=>{let F=o==="yes"?t.yesAsk:t.noAsk;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[o,t]),rt=o==="yes"?t.yesAsk:t.noAsk,We=rt!=null&&Y?Y(Number(rt)):ze!=null?`${ze} \xA2`:xr,Ue=!isNaN(i)&&i>0,nt=Ue?p+d:0,mt=Ue&&a>0?nt/a:0,Mt=mt>0&&Y?Y(mt):mt>0?`${parseFloat((mt*100).toFixed(2))}\xA2`:xr,E=h==="authenticated",de=h==="authenticating"||h==="deauthenticating",Le=E&&(S||R),Ge=useMemo(()=>{if(de)return A("predict.trade.checkingLogin");if(!E)return A("predict.trade.loginToTrade");if(S)return A("predict.trade.kycRequired");if(R)return A("predict.trade.setupRequired");if(l)return A("predict.trade.loadingBalance");if(m)return A("predict.trade.loadingMarketData");if(g)return A("predict.trade.submitting");if(P)return A("predict.trade.kycRequired");if(!Ue)return A("predict.trade.enterAmount");let F=A(o==="yes"?"predict.trade.yes":"predict.trade.no"),$e=c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${A("predict.trade.buy")} ${F}${$e}`},[de,E,S,R,l,m,g,P,Ue,o,c,A]),Vr="primary",Dt=()=>{let F=y??ve(f??0,2);w(ve(F/2,2));},Pt=()=>{w(y??ve(f??0,2));},[Pe,ot]=useState(false),At=()=>{if(!E){ot(false),Se();return}if(S){Ee.onOpen();return}if(R&&k){ot(false),k();return}if(P){Ee.onOpen();return}if(N&&k){ot(false),k();return}if(!v){ot(true);return}ot(false),Se();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bullish",children:[A("predict.trade.buy")," ",A(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[x?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:F=>re(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:A("predict.trade.market")},"market"),jsx(Tab,{title:A("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:A("predict.trade.market")}),n==="limit"&&x?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ze,onChange:F=>at(F.target.value),onFocus:()=>{tt.current=true;},onBlur:()=>{tt.current=false,isNaN(s)?et(""):et(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"}}):We!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:We})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let $e=F==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>Q(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===F?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:A(F==="yes"?"predict.trade.yes":"predict.trade.no")}),$e!=null&&jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number($e)):`${parseFloat((Number($e)*100).toFixed(2))}\xA2`})]})},F)})}),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:A("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:Dt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:A("predict.trade.half")}),jsx("button",{type:"button",onClick:Pt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:A("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:qe,onChange:F=>Ot(F.target.value),onFocus:()=>{we.current=true;},onBlur:()=>{we.current=false,st(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"}}),Pe&&b.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:b.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-neutral-500",children:A("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:f!=null?`$${ve(f,2).toFixed(2)}`:"$0"})]}),n==="limit"&&x&&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:A("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:z,onValueChange:$,"aria-label":A("predict.trade.setExpiration")})]}),z&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":A("predict.trade.setExpiration"),selectedKeys:[K],onSelectionChange:F=>{let $e=Array.from(F)[0];$e&&J($e);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Md.map(F=>jsx(SelectItem,{children:A(Td[F])},F))}),K==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(W)?void 0:W,onValueChange:ne,minValue:1,step:1,formatOptions:Rd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[G],onSelectionChange:F=>{let $e=Array.from(F)[0];$e&&O($e);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Ed.map(F=>jsx(SelectItem,{children:A(Ld[F])},F))})]})]})]}),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:()=>pt(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:A("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",be&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&rt!=null?We:ze!=null?A("predict.trade.chance",{percent:ze}):xr})]}),be&&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:A("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:xr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:A("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?qr(a):xr})]}),d>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:A("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${d.toFixed(2)}`})]}),d>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:A("predict.trade.totalPayment")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${nt.toFixed(2)}`})]}),d>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:A("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:Mt})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:A("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:xr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:A("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&c>0?`+$${c.toFixed(2)}`:xr})]})]})]}),jsx(Button,{color:Vr,fullWidth:true,radius:"lg",size:"lg",isDisabled:de||E&&!Le&&(l||m||!Ue||g),isLoading:de||E&&!Le&&(g||l||m),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:At,children:Ge})]}),jsx(An,{isOpen:Ee.isOpen,onClose:Ee.onClose,kycUrl:I})]})}function Bn({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:c}){let{outcome:u,orderType:p,quantity:d,limitPrice:f,shares:l,estimatedCost:m,estimatedFee:g,potentialPayout:h,potentialProfit:v,pricePerShare:b,usdcBalance:N,maxBuyAmount:k,isBalanceLoading:x,isMarketDataLoading:y,isSubmitting:P,authStatus:S,validation:R,isInsufficientBalance:I,supportsLimitOrder:z,kycRequired:K,needsKyc:W,needsSetup:G,kycUrl:Y,expirationEnabled:Q,expirationPreset:re,customDuration:w,customDurationUnit:M,setOutcome:$,setOrderType:J,setQuantity:ne,setLimitPrice:O,setExpirationEnabled:Se,setExpirationPreset:A,setCustomDuration:be,setCustomDurationUnit:pt,submit:Ee,notifyInsufficientBalance:qe}=Gi({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),st=useAuthCallback(Ee),we=useCallback(tt=>{$(tt),a?.(tt);},[$,a]),Ze=useMemo(()=>e?Cn(e):void 0,[e]),et=useMemo(()=>Mn(t,{yesAsk:u==="yes"?b:void 0,noAsk:u==="no"?b:void 0}),[t,u,b]);return jsx(ns,{event:Ze,market:et,variant:r,outcome:u,orderType:p,quantity:d,limitPrice:f,shares:l,estimatedCost:m,estimatedFee:g,potentialPayout:h,potentialProfit:v,usdcBalance:N,maxBuyAmount:k,isBalanceLoading:x,isMarketDataLoading:y,isSubmitting:P,authStatus:S,isValid:R.isValid,validationErrors:R.errors,isInsufficientBalance:I,onInsufficientBalance:s?qe:void 0,supportsLimitOrder:z,kycRequired:K,needsKyc:W,needsSetup:G,kycUrl:Y,expirationEnabled:Q,expirationPreset:re,customDuration:w,customDurationUnit:M,oddsFormatter:c,onOutcomeChange:we,onOrderTypeChange:J,onQuantityChange:ne,onLimitPriceChange:O,onExpirationEnabledChange:Se,onExpirationPresetChange:A,onCustomDurationChange:be,onCustomDurationUnitChange:pt,onSubmit:st})}var Yr="predict-trade";function Hn({id:e=Yr}){return jsx(AsyncModal,{id:e,children:t=>jsx(zd,{...t})})}function zd({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(Bn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var Qr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Do(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function is({isOpen:e,onClose:t,value:r,onChange:o,enableKalshi:n=true}){let{t:i}=useTranslation(),[s,a]=useState(r),c=useMemo(()=>n?Qr:{...Qr,source:"polymarket"},[n]),u=useCallback(b=>{b?a(r):t();},[r,t]),p=useCallback(()=>{a(c);},[c]),d=useCallback(()=>{o(s),t();},[s,o,t]),f=useCallback((b,N)=>{a(k=>({...k,[b]:N}));},[]),l=useMemo(()=>Do(s,n),[s,n]),m=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),h=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsx(StyledModal,{isOpen:e,onOpenChange:u,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.filter.title")}),jsx(jd,{onClick:()=>u(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsx(Wn,{label:i("predict.filter.platform"),children:jsx(Un,{options:m,selected:s.source,onSelect:b=>f("source",b)})}),jsx(Wn,{label:i("predict.filter.timeRemaining"),children:jsx(Un,{options:g,selected:s.timeRemaining,onSelect:b=>f("timeRemaining",b)})}),jsx(Wn,{label:i("predict.filter.minVolume"),children:jsx(Un,{options:h,selected:s.minVolume,onSelect:b=>f("minVolume",b)})}),jsx(Wn,{label:i("predict.filter.minLiquidity"),children:jsx(Un,{options:v,selected:s.minLiquidity,onSelect:b=>f("minLiquidity",b)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:p,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:d,children:[i("predict.filter.showResults"),l>0&&jsxs("span",{style:{opacity:.7},children:["(",l,")"]})]})]})]})})})}function Wn({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 jd({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 Un({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let i=t===n.value;return jsx("button",{type:"button",onClick:()=>{r(i&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var ds={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},as={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},tu=["start_time","volume","liquidity","ending_soon"],ls={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"},ru={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 us({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=useTranslation(),[c,u]=useState(false),p=useRef(null),d=useCallback(l=>{p.current&&!p.current.contains(l.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)),[d]),useEffect(()=>{if(!c)return;let l=m=>{m.key==="Escape"&&u(false);};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[c]);let f=cs[e];return jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:p,style:{position:"relative"},children:[jsxs("button",{type:"button",style:ls,onMouseEnter:l=>{l.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(l=>!l),children:[jsx(nu,{}),jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(as[e])}),jsx(iu,{open:c})]}),c&&jsx("div",{style:{...ru,width:224,padding:4},children:tu.map(l=>{let m=cs[l],g=e===l;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===l?o(!r):t(l),u(false);},children:[jsx(m,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(as[l])}),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"})})]},l)})})]}),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:l=>{l.currentTarget.style.background="rgba(39,39,42,1)",l.currentTarget.style.color="#fff";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(39,39,42,0.6)",l.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:ls,onMouseEnter:l=>{l.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsx(ou,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var cs={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function nu(){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 ou(){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 iu({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 fs(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:i,isError:s,error:a,hasNextPage:c,fetchNextPage:u,refetch:p}=useInfiniteEvents(t),d=useMemo(()=>r?.pages.flatMap(m=>m.items).filter(m=>m!=null)??[],[r]),f=useCallback(()=>{u();},[u]),l=useCallback(()=>{p();},[p]);return {data:d,isLoading:o,isFetching:n&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:c??false,fetchMore:f,refetch:l}}var gs=`
|
|
1
|
+
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,createElement,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledInput,StyledSwitch,Select,SelectItem,StyledNumberInput,ChevronDownIcon,Button,Spinner,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,OrderbookTableIcon,OrderbookDepthIcon,RefreshIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,EmptyIcon,TrashIcon,Chip,XCloseIcon,Kbd,SearchIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useAuthCallback}from'@liberfi.io/wallet-connector';import {useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTradeResultConfirmation,useTickSize,useFeeRate,useRebateConfig,useRealtimeOrderbook,pickBestAsk,walkOrderbook,usePositionsMulti,useDFlowQuote,useDFlowSubmit,useOrder,buildSignedV2OrderPayload,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useRedeemPosition,pickBestBid,useAvailableShares,getPolymarketSharesPrecision,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useMarketHistory,useOrderbook,useEvent,useSimilarEvents,candlesticksQueryKey,useInfiniteComments,useSearchEvents,usePositions}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,eventStatsQueryKey,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEventStats,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useRedeemPosition,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {formatAmountInUsd,SOLANA_TOKENS,formatAmount,debounce}from'@liberfi.io/utils';import Fo from'canvas-confetti';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import {List,useDynamicRowHeight}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useScrollCollapse,useResizeObserver,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';var Pc={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Di=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Io=(()=>{let e=t=>{let r=Di.indexOf(t);return r===-1?Di.length:r};return Object.entries(Pc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Hi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:s="Trending",className:l}){let{t:u}=useTranslation(),p=useCallback(()=>{o(null);},[o]),d=u("predict.categories.trending");return jsxs("div",{className:cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxs("div",{className:"cat-primary-row",children:[jsx("div",{className:"cat-tabs hideScrollbar",children:jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsx(Fi,{label:d,isSelected:t===null,onPress:p,showPulse:d===s}),jsx(Tc,{}),e.map(f=>{let c=f.slug??f.category,m=f.label??f.category;return jsx(Fi,{label:m,isSelected:t===c,onPress:()=>o(c),badge:f.badge,showPulse:c===s||m===s},c)})]})}),a&&jsx("div",{className:"flex-shrink-0",children:a})]}),t&&n.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsx(Bi,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(f=>{let c=f.slug??f.label;return jsx(Bi,{label:f.label,icon:f.icon,isSelected:r===c,onPress:()=>i(c)},c)})]})})]})}function Fi({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,n&&jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:n})]})}function Tc(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Bi({label:e,icon:t,isSelected:r,onPress:n}){return jsxs("button",{type:"button",onClick:n,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function Dv({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 Wi(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Lc(e){return `predict.categories.category.${Wi(e)}`}function Ui(e){return `predict.categories.tag.${Wi(e)}`}function Rc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Lc(r.slug),r.label),tags:r.tags.map(n=>({slug:n.slug,label:t(Ui(n.slug),n.label),icon:n.icon}))}))}function _c(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Ui(r.slug),r.label),icon:r.icon})):[]}function $i({onSelect:e,trailing:t,className:r}){let{t:n}=useTranslation(),o=useCallback((m,g)=>{let h=n(m);return typeof h=="string"&&h!==m?h:g},[n]),[i,a]=useState(null),[s,l]=useState(null),u=useCallback(m=>{a(m),l(null),e?.({categorySlug:m,tagSlug:null});},[e]),p=useCallback(m=>{l(m),e?.({categorySlug:i,tagSlug:m});},[i,e]),d=Rc(Io,o),f=Io.find(m=>m.slug===i),c=_c(f,o);return jsx(Hi,{categories:d,selectedCategory:i,selectedTag:s,activeTags:c,onCategorySelect:u,onTagSelect:p,trailing:t,className:r})}function Dn(e){return {title:e.title,imageUrl:e.image_url}}function Fn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var rn=24,Ao=4,Bn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ce={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Hn=ce.ALL,jv={[ce.ONE_DAY]:Bn.ONE_MINUTE,[ce.ONE_WEEK]:Bn.ONE_HOUR,[ce.ONE_MONTH]:Bn.ONE_HOUR,[ce.ALL]:Bn.ONE_DAY},Gv={[ce.ONE_DAY]:300,[ce.ONE_WEEK]:3600,[ce.ONE_MONTH]:10800,[ce.ALL]:1440*60},qv={[ce.ONE_DAY]:1440*60,[ce.ONE_WEEK]:10080*60,[ce.ONE_MONTH]:720*60*60,[ce.ALL]:null},zn=1,Wn=1,Yv=1,Qv=1,Xv=99,Br={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Jv=Br.ONE_WEEK,Zv={[Br.ONE_HOUR]:60,[Br.SIX_HOURS]:60,[Br.ONE_DAY]:300,[Br.ONE_WEEK]:1800,[Br.MAX]:1800};var ji=createContext(null);function xr(){let e=useContext(ji);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Hc=1e4;function zc({pollingInterval:e=Hc,enabled:t=true,enableKalshi:r=true,children:n}){let o=useWallets(),i=useMemo(()=>o.find(_=>_.chainNamespace===ChainNamespace.SOLANA&&_.isConnected)?.address,[o]),a=useMemo(()=>o.find(_=>_.chainNamespace===ChainNamespace.EVM&&_.isConnected)?.address,[o]),{data:s,isLoading:l,isFetching:u,error:p}=useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:d,isLoading:f}=useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:c,isLoading:m}=usePolymarketSetup(a,{enabled:t&&!!a,refetchInterval:3e4}),g=c?.safe_address,v=c?.verified??false,h=c?.wallet_kind??"deposit",x=c?.deposit_wallet_address,k=h==="safe"?c?.safe_address:x,S=h==="safe"?c?.safe_deployed??false:c?.deposit_wallet_deployed??false,{data:b,isLoading:y,isFetching:N,error:M}=useBalance({source:"polymarket",user:a??""},{enabled:t&&v&&!!a,refetchInterval:e}),C=useMemo(()=>({solanaAddress:i,evmAddress:a,polymarketWalletKind:h,polymarketWalletAddress:k,polymarketDepositWalletAddress:x,polymarketWalletDeployed:S,polymarketSafeAddress:g,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:v&&b?Number(b.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:v,polymarketSafeDeployed:c?.safe_deployed??false,polymarketTokenApproved:c?.token_approved??false,polymarketSetupLoading:m,isLoading:l||y,isFetching:u||N,error:p??M??null}),[i,a,h,k,x,S,g,s,b,v,d,f,c,m,l,y,u,N,p,M]);return jsx(ji.Provider,{value:C,children:n})}var Uc={minutes:60,hours:3600,days:86400};function Un(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*Uc[r]}}function $n(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function xe(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function $c(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Kc=100,Vc=300;function Bo(e,t){return Kc/1e4+Math.max(0,e)/1e4*$c(t)}function jc(e,t){let r=e?.[t],n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:void 0}function Gc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Gi(e){let t=jc(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],n=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(n)&&n>=0?n*1e4:Gc(e,"polymarket.sportsMarketType")?Vc:0}function qi({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:n=0,pricePerShare:o}){if(t==null||!Number.isFinite(t))return 0;let i=xe(Math.max(0,t),2);if(e!=="polymarket")return i;let a=Bo(n,o??NaN),s=i/(1+a)-r;return xe(Math.max(0,s),2)}function Yi({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Qi({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Kn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let a=parseInt(o[1],10)/1e6,s=parseInt(o[2],10)/1e6,l=Math.max(0,a-s);return t("predict.trade.polymarket.insufficientBalance",{total:xe(a,2).toFixed(2),active:xe(s,2).toFixed(2),available:xe(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function yr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function Xi(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Fo({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Fo({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Fo({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var Ji={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function qc(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function Ho(e,t,r){let n=e(t);return n&&n!==t?n:r}function Hr(e,t){let r=qc(t)?Ji.zh:Ji.en;return {submitted:Ho(e,"predict.trade.resultSubmitted",r.submitted),completed:Ho(e,"predict.trade.resultCompleted",r.completed),delayed:Ho(e,"predict.trade.resultDelayed",r.delayed)}}function Jc({deadlineAt:e}){let[t,r]=useState(()=>Math.max(0,e-Date.now()));return useEffect(()=>{let n=setInterval(()=>{r(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(n)},[e]),`${Math.max(0,Math.ceil(t/1e3))}s`}function zr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:n}){return {id:e,submitted:()=>{let o=Date.now()+t;toast.progress({id:e,message:n.submitted,duration:t,progress:true,action:createElement(Jc,{deadlineAt:o})});},completed:()=>{toast.update(e,{type:"success",message:n.completed,duration:5e3}),r&&Xi();},delayed:()=>{toast.update(e,{type:"blank",message:n.delayed,duration:8e3});},failed:o=>{toast.update(e,{type:"error",message:o,duration:8e3});}}}function ts({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o,i18n:i}=useTranslation(),{status:a}=useAuth(),s=useWallets(),l=usePredictClient(),u=useContext(PolymarketContext),{start:p}=useTradeResultConfirmation(),d=e.source,f=d==="polymarket",c=s.find(R=>R.chainNamespace===ChainNamespace.SOLANA&&R.isConnected),m=s.find(R=>R.chainNamespace===ChainNamespace.EVM&&R.isConnected&&"switchChain"in R),g=a==="authenticated",v=c?.address,h=m?.address,[x,k]=useState(t),[S,b]=useState("market"),[y,N]=useState(NaN),[M,C]=useState(NaN),[_,F]=useState(false),[U,Q]=useState(null),[B,Y]=useState(false),[q,te]=useState(false),[P,T]=useState("1h"),[z,J]=useState(30),[ue,ae]=useState("minutes"),Ke=useMemo(()=>Hr(o,i),[i,o]),Ee=useCallback(async(R,Ae)=>{let We=zr({celebrateOnCompleted:true,messages:Ke});We.submitted(),await p({source:d,user:d==="kalshi"?v:h,kalshiUser:v,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:R,getOrdersHeaders:Ae})==="confirmed"?We.completed():We.delayed();},[p,h,e.event_slug,e.slug,d,Ke,v]),w=useMemo(()=>{if(d!=="polymarket")return;let R=e.provider_meta?.["polymarket.clobTokenIds"];return R?(typeof R=="string"?JSON.parse(R):R)[x==="yes"?0:1]:void 0},[d,e.provider_meta,x]),{data:He,isLoading:Je}=useTickSize(w),we=He?.minimum_tick_size?String(He.minimum_tick_size):"0.01",{data:Ct,isLoading:Oe}=useFeeRate(w),Ve=Ct?.base_fee??0,st=String(Ve),Pe=useMemo(()=>Gi(e.provider_meta),[e.provider_meta]),{data:Ze}=useRebateConfig(),Le=Ze?.builder_enabled&&Ze.builder_code?Ze.builder_code:void 0,at=null,_t=false,Mt=null,Tt=false,et,gt,ze;try{let R=xr();at={kalshiUsdcBalance:R.kalshiUsdcBalance,polymarketUsdcBalance:R.polymarketUsdcBalance,isLoading:R.isLoading},_t=R.kalshiKycVerified,Mt=R.kalshiKycUrl,Tt=R.polymarketSetupVerified,et=R.polymarketSafeAddress,gt=R.polymarketWalletKind,ze=R.polymarketWalletAddress;}catch{}let Gt=d==="kalshi"&&!_t,Re=d==="polymarket"&&!Tt,{data:je}=useRealtimeOrderbook({slug:e.slug,source:d,outcome:x},{enabled:e.status==="open"}),ge=useMemo(()=>{let R=pickBestAsk(je,x);if(R!=null&&R>0)return R;let Ae=x==="yes"?0:1,We=e.outcomes[Ae];return We?.best_ask??We?.price??.5},[je,e.outcomes,x]),lt=useCallback(R=>{b(R);},[]),ht=useCallback(R=>{k(R),C(NaN);},[]);useEffect(()=>{ht(t);},[t,ht]),useEffect(()=>{S==="limit"&&isNaN(M)&&C(Math.round(ge*1e4)/1e4);},[S,M,ge]);let Ne=useMemo(()=>S==="limit"&&f&&!isNaN(M)?M:ge,[S,f,M,ge]),ut=useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne:0,[y,Ne]),Ce=useMemo(()=>walkOrderbook({orderbook:je,outcome:x,side:"buy",sharesNeeded:ut,slippageBps:r}),[je,x,ut,r]),I=useMemo(()=>Ce.status==="ok"&&Ce.worstPrice!=null&&Ce.worstPrice>0?Ce.worstPrice:ge,[Ce,ge]),pe=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),tt=e.provider_meta?.["dflow.yesMint"]??"",Xr=e.provider_meta?.["dflow.noMint"]??"",A=SOLANA_TOKENS.stablecoins.USDC.address,Ge=x==="yes"?tt:Xr,vt=A,ur=Ge,Dt=d==="kalshi"?v??"":h??"",{data:Jr,isLoading:Co}=usePositionsMulti({kalshi_user:d==="kalshi"?Dt:void 0,polymarket_user:d==="polymarket"?Dt:void 0},{enabled:!!Dt}),Cn=d==="kalshi"&&!!vt&&!!ur&&!!v&&pe!=="0",{refetch:Lr}=useDFlowQuote({inputMint:vt,outputMint:ur,amount:pe,userPublicKey:v??"",slippageBps:100},{enabled:Cn}),qe=useMemo(()=>at?d==="kalshi"?at.kalshiUsdcBalance:at.polymarketUsdcBalance:Jr&&Jr.positions.reduce((Ae,We)=>We.side==="USDC"||We.side==="collateral"?Ae+(We.current_value??0):Ae,0)||null,[at,Jr,d]),Rr=at?at.isLoading:Co,_r=useMemo(()=>qi({source:d,usdcBalance:qe,feeRateBps:Pe,pricePerShare:Ne}),[d,qe,Pe,Ne]),Ft=qe==null?null:_r,Ir=useMemo(()=>isNaN(y)||y<=0?0:y,[y]),qt=useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne*1:0,[y,Ne]),Mn=useMemo(()=>d!=="polymarket"||isNaN(y)||y<=0?0:Yi({usdcAmount:y,pricePerShare:Ne,feeRateBps:Pe}),[d,y,Ne,Pe]),Tn=qt-Ir-Mn,Mo=useCallback(R=>{if(isNaN(R)){N(NaN);return}N(Math.round(Math.max(0,R)*100)/100);},[]),pr=useCallback(R=>{if(isNaN(R)){C(NaN);return}C(Math.round(R*1e4)/1e4);},[]),Bt=useCallback(()=>{N(NaN),C(NaN),b("market"),te(false),T("1h"),J(30),ae("minutes");},[]),Yt=useMemo(()=>{let R=[];return isNaN(y)||y<=0?R.push(o("predict.trade.minAmountUsd",{amount:Wn})):y<Wn&&R.push(o("predict.trade.minAmountUsd",{amount:Wn})),e.status!=="open"&&R.push(o("predict.trade.marketNotActive")),Ft!=null&&!isNaN(y)&&y>0&&y>Ft&&R.push(o("predict.trade.insufficientBalance")),S==="limit"&&f&&(isNaN(M)||M<.01||M>.99)&&R.push(o("predict.trade.limitPriceRange")),S==="limit"&&f&&q&&P==="custom"&&(isNaN(z)||z<=0)&&R.push(o("predict.trade.expiration.invalidDate")),d==="polymarket"&&S==="market"&&!isNaN(y)&&y>0&&ut>0&&(Ce.status==="insufficient_liquidity"?R.push(o("predict.trade.insufficientLiquidity",{available:xe(Ce.totalAvailable,2)})):Ce.status==="exceeds_slippage"&&R.push(o("predict.trade.priceImpactTooHigh",{impact:(Ce.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:R.length===0,errors:R}},[y,e.status,Ft,S,f,M,q,P,z,d,ut,Ce,r,o]),Or=useMemo(()=>Ft==null||isNaN(y)||y<=0?false:y>Ft,[Ft,y]),To=useCallback(()=>{n?.(d);},[n,d]),{mutateAsync:Zr}=useDFlowSubmit(),{data:mr}=useOrder({id:U??"",source:d},{enabled:!!U});useEffect(()=>{if(!mr||!U)return;let{status:R}=mr;R==="closed"?(Q(null),F(false),Ee("buy-market"),Bt()):(R==="failed"||R==="expired")&&(F(false),Q(null),toast.error(o("predict.trade.submitError")));},[Ee,mr,U,Bt,o]);let bt=useCallback(async()=>{if(!v||!c)return;if(!vt||!ur){toast.error("Missing token mint addresses"),F(false);return}if(!_t){Y(true),F(false);return}let Et=(await Lr()).data?.transaction;if(!Et){toast.error(o("predict.trade.submitError")),F(false);return}let en=Uint8Array.from(atob(Et),ct=>ct.charCodeAt(0)),hr=await c.signTransaction(en),Qt=await Zr({signedTransaction:btoa(String.fromCharCode(...hr)),orderContext:{user_public_key:v,input_mint:vt,output_mint:ur,amount:pe,price:String(ge),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(Qt.signature);},[v,c,Lr,Zr,vt,ur,pe,ge,x,e.slug,o,_t]),fr=useCallback(async()=>{if(!m||!u)return;let R=m.chain,Ae=R!==Chain.POLYGON;Ae&&await m.switchChain(Chain.POLYGON);try{let We=await m.getEip1193Provider();if(!We){toast.error(o("predict.trade.submitError")),F(!1);return}let Et=gt==="deposit"&&!!ze,en=!Et&&!!et,hr=Et?ze:et,Qt={address:m.address,signatureType:Et?3:en?2:0,signTypedData:async(le,ye,Ye,rt)=>{let nt=[];"name"in le&&nt.push({name:"name",type:"string"}),"version"in le&&nt.push({name:"version",type:"string"}),"chainId"in le&&nt.push({name:"chainId",type:"uint256"}),"verifyingContract"in le&&nt.push({name:"verifyingContract",type:"address"}),"salt"in le&&nt.push({name:"salt",type:"bytes32"});let Lt={EIP712Domain:nt,...ye};return await We.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:le,types:Lt,primaryType:Ye,message:rt})]})}},ct=u.credentials??await u.authenticate(Qt),vr=x==="yes"?0:1,Ar="",Xt=e.provider_meta?.["polymarket.clobTokenIds"];Xt&&(Ar=(typeof Xt=="string"?JSON.parse(Xt):Xt)[vr]??"");let Dr=e.provider_meta?.["polymarket.negRisk"]??!1,En=S==="limit"&&!isNaN(M)?M:I,Jt=$n(En,we),Ln=S==="limit"?q?"GTD":"GTC":"FOK",Rn=S==="market"?y:Jt>0?y/Jt:0,tn={tokenId:Ar,price:Jt,size:Rn,side:"BUY",orderType:Ln,tickSize:we,negRisk:Dr,...hr&&{funderAddress:hr},...Le&&{builderCode:Le},...S==="limit"&&q&&{expiration:Un(P,z,ue)}},E;if(Et)E=await buildSignedV2OrderPayload({signer:Qt,depositWalletAddress:hr,input:tn,owner:ct.apiKey});else {let le=buildCtfExchangeDomain(Dr),ye=buildOrderMessage({...tn,signerAddress:Qt.address,signatureType:Qt.signatureType,feeRateBps:st}),Ye=await Qt.signTypedData(le,CTF_ORDER_TYPES,"Order",ye),rt=buildSignedOrder(ye,Ye,tn.orderType);E=buildClobPayload(rt,ct.apiKey);}await l.executePolymarketOrder({payload:E,l2_api_key:ct.apiKey,l2_secret:ct.secret,l2_passphrase:ct.passphrase,signer_address:ct.address,owner:ct.apiKey}),Ee(S==="limit"?"buy-limit":"buy-market",async()=>await buildPolymarketL2Headers(ct.address,{apiKey:ct.apiKey,secret:ct.secret,passphrase:ct.passphrase,method:"GET",requestPath:"/data/orders"})),Bt(),F(!1);}finally{Ae&&R&&m.switchChain(R).catch(()=>{});}},[m,u,x,e.provider_meta,S,Ee,M,I,y,l,q,P,z,ue,Bt,o,we,st,et,gt,ze,Le]),gr=useCallback(async()=>{if(!(!Yt.isValid||!g)){F(true),Q(null),Y(false);try{d==="kalshi"?await bt():await fr();}catch(R){let Ae=R instanceof Error?R.message:"",We=d==="polymarket"&&Ae?Kn(Ae,o,"buy"):Ae||void 0;toast.error(We||o("predict.trade.submitError")),F(false);}}},[Yt.isValid,g,d,bt,fr,o]);return {outcome:x,orderType:S,quantity:y,limitPrice:M,shares:ut,effectivePrice:Ne,estimatedCost:Ir,estimatedFee:Mn,potentialPayout:qt,potentialProfit:Tn,pricePerShare:ge,usdcBalance:qe,maxBuyAmount:_r,spendableUsdcBalance:Ft,isBalanceLoading:Rr,isMarketDataLoading:d==="polymarket"&&(Oe||Je),isSubmitting:_,authStatus:a,validation:Yt,isInsufficientBalance:Or,source:d,supportsLimitOrder:f,kycRequired:B,needsKyc:Gt,needsSetup:Re,kycUrl:Mt,expirationEnabled:q,expirationPreset:P,customDuration:z,customDurationUnit:ue,setOutcome:ht,setOrderType:lt,setQuantity:Mo,setLimitPrice:pr,setExpirationEnabled:te,setExpirationPreset:T,setCustomDuration:J,setCustomDurationUnit:ae,submit:gr,notifyInsufficientBalance:To}}function jn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:n(o)})]},o))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Dd=["5m","1h","12h","24h","eod","custom"],Fd={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},Bd=["minutes","hours","days"],Hd={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},zd={maximumFractionDigits:0},sr="-";function ds({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:s,effectivePrice:l,potentialProfit:u,potentialPayout:p,estimatedCost:d,estimatedFee:f=0,usdcBalance:c,isBalanceLoading:m,isMarketDataLoading:g,isSubmitting:v,authStatus:h,isValid:x,validationErrors:k,isInsufficientBalance:S,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:N,kycRequired:M,needsKyc:C,needsSetup:_,kycUrl:F,expirationEnabled:U,expirationPreset:Q,customDuration:B,customDurationUnit:Y,oddsFormatter:q,onOutcomeChange:te,onOrderTypeChange:P,onQuantityChange:T,onLimitPriceChange:z,onExpirationEnabledChange:J,onExpirationPresetChange:ue,onCustomDurationChange:ae,onCustomDurationUnitChange:Ke,onSubmit:Ee}){let{t:w}=useTranslation(),[He,Je]=useState(true),we=useDisclosure(),[Ct,Oe]=useState(""),Ve=useRef(false);useEffect(()=>{Ve.current||Oe(isNaN(i)?"":String(i));},[i]);let[st,Pe]=useState(""),Ze=useRef(false);useEffect(()=>{Ze.current||(isNaN(a)?Pe(""):Pe(String(parseFloat((a*100).toFixed(2)))));},[a]);let Le=useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Pe(A),A===""||A==="."){z(NaN);return}let vt=parseFloat(A);isNaN(vt)||z(vt/100);},[z]),at=useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Oe(A),tt(false),A===""||A==="."){T(NaN);return}let vt=parseFloat(A);isNaN(vt)||T(vt);},[T]);useEffect(()=>{M&&!we.isOpen&&we.onOpen();},[M]);let _t=useMemo(()=>{let A=n==="yes"?t.yesAsk:t.noAsk;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),Mt=n==="yes"?t.yesAsk:t.noAsk,Tt=Mt!=null&&q?q(Number(Mt)):_t!=null?`${_t} \xA2`:sr,et=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,gt=Number.isFinite(l)&&q?q(l):et!=null?`${et} \xA2`:sr,ze=!isNaN(i)&&i>0,Gt=ze?d+f:0,Re=ze&&s>0?Gt/s:0,je=Re>0&&q?q(Re):Re>0?`${parseFloat((Re*100).toFixed(2))}\xA2`:sr,ge=h==="authenticated",lt=h==="authenticating"||h==="deauthenticating",ht=ge&&(C||_),Ne=useMemo(()=>{if(lt)return w("predict.trade.checkingLogin");if(!ge)return w("predict.trade.loginToTrade");if(C)return w("predict.trade.kycRequired");if(_)return w("predict.trade.setupRequired");if(m)return w("predict.trade.loadingBalance");if(g)return w("predict.trade.loadingMarketData");if(v)return w("predict.trade.submitting");if(M)return w("predict.trade.kycRequired");if(!ze)return w("predict.trade.enterAmount");let A=w(n==="yes"?"predict.trade.yes":"predict.trade.no"),Ge=u>0?` \u2192 Win $${u.toFixed(2)}`:"";return `${w("predict.trade.buy")} ${A}${Ge}`},[lt,ge,C,_,m,g,v,M,ze,n,u,w]),ut="primary",Ce=()=>{let A=N??xe(c??0,2);T(xe(A/2,2));},I=()=>{T(N??xe(c??0,2));},[pe,tt]=useState(false),Xr=()=>{if(!ge){tt(false),Ee();return}if(C){we.onOpen();return}if(_&&b){tt(false),b();return}if(M){we.onOpen();return}if(S&&b){tt(false),b();return}if(!x){tt(true);return}tt(false),Ee();};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-bullish",children:[w("predict.trade.buy")," ",w(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:[y?jsxs(Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>P(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:w("predict.trade.market")},"market"),jsx(Tab,{title:w("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&y?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:st,onChange:A=>Le(A.target.value),onFocus:()=>{Ze.current=true;},onBlur:()=>{Ze.current=false,isNaN(a)?Pe(""):Pe(String(parseFloat((a*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Tt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:Tt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(A=>{let Ge=A==="yes"?t.yesAsk:t.noAsk;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>te(A),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===A?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:w(A==="yes"?"predict.trade.yes":"predict.trade.no")}),Ge!=null&&jsx("span",{className:"ml-1 opacity-70",children:q?q(Number(Ge)):`${parseFloat((Number(Ge)*100).toFixed(2))}\xA2`})]})},A)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.youArePaying")}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("button",{type:"button",onClick:Ce,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("predict.trade.half")}),jsx("button",{type:"button",onClick:I,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("predict.trade.max")})]})]}),jsx(StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ct,onChange:A=>at(A.target.value),onFocus:()=>{Ve.current=true;},onBlur:()=>{Ve.current=false,Oe(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"}}),pe&&k.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:k.map(A=>jsx("span",{className:"text-xs text-danger",children:A},A))})]}),jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsx("span",{className:"text-neutral-500",children:w("predict.trade.balance")}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:c!=null?`$${xe(c,2).toFixed(2)}`:"$0"})]}),o==="limit"&&y&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:w("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:U,onValueChange:J,"aria-label":w("predict.trade.setExpiration")})]}),U&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[Q],onSelectionChange:A=>{let Ge=Array.from(A)[0];Ge&&ue(Ge);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Dd.map(A=>jsx(SelectItem,{children:w(Fd[A])},A))}),Q==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(B)?void 0:B,onValueChange:ae,minValue:1,step:1,formatOptions:zd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[Y],onSelectionChange:A=>{let Ge=Array.from(A)[0];Ge&&Ke(Ge);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Bd.map(A=>jsx(SelectItem,{children:w(Hd[A])},A))})]})]})]}),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:()=>Je(A=>!A),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:w("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",He&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:q&&Number.isFinite(l)?gt:et!=null?w("predict.trade.chance",{percent:et}):sr})]}),He&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:sr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?yr(s):sr})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${f.toFixed(2)}`})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalPayment")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${Gt.toFixed(2)}`})]}),f>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:je})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.payout")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:sr})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estProfit")}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&u>0?`+$${u.toFixed(2)}`:sr})]})]})]}),jsx(Button,{color:ut,fullWidth:true,radius:"lg",size:"lg",isDisabled:lt||ge&&!ht&&(m||g||!ze||v),isLoading:lt||ge&&!ht&&(v||m||g),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Xr,children:Ne})]}),jsx(jn,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:F})]})}function qn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:a,onOutcomeChange:s,oddsFormatter:l}){let{outcome:u,orderType:p,quantity:d,limitPrice:f,shares:c,effectivePrice:m,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,pricePerShare:k,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:N,isSubmitting:M,authStatus:C,validation:_,isInsufficientBalance:F,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:P,customDuration:T,customDurationUnit:z,setOutcome:J,setOrderType:ue,setQuantity:ae,setLimitPrice:Ke,setExpirationEnabled:Ee,setExpirationPreset:w,setCustomDuration:He,setCustomDurationUnit:Je,submit:we,notifyInsufficientBalance:Ct}=ts({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:a}),Oe=useAuthCallback(we),Ve=useCallback(Ze=>{J(Ze),s?.(Ze);},[J,s]),st=useMemo(()=>e?Dn(e):void 0,[e]),Pe=useMemo(()=>Fn(t,{yesAsk:u==="yes"?k:void 0,noAsk:u==="no"?k:void 0}),[t,u,k]);return jsx(ds,{event:st,market:Pe,variant:r,outcome:u,orderType:p,quantity:d,limitPrice:f,shares:c,effectivePrice:m,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:N,isSubmitting:M,authStatus:C,isValid:_.isValid,validationErrors:_.errors,isInsufficientBalance:F,onInsufficientBalance:a?Ct:void 0,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:P,customDuration:T,customDurationUnit:z,oddsFormatter:l,onOutcomeChange:Ve,onOrderTypeChange:ue,onQuantityChange:ae,onLimitPriceChange:Ke,onExpirationEnabledChange:Ee,onExpirationPresetChange:w,onCustomDurationChange:He,onCustomDurationUnitChange:Je,onSubmit:Oe})}var on="predict-trade";function Yn({id:e=on}){return jsx(AsyncModal,{id:e,children:t=>jsx(Yd,{...t})})}function Yd({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(qn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var sn={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Uo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function ps({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=useTranslation(),[a,s]=useState(r),l=useMemo(()=>o?sn:{...sn,source:"polymarket"},[o]),u=useCallback(x=>{x?s(r):t();},[r,t]),p=useCallback(()=>{s(l);},[l]),d=useCallback(()=>{n(a),t();},[a,n,t]),f=useCallback((x,k)=>{s(S=>({...S,[x]:k}));},[]),c=useMemo(()=>Uo(a,o),[a,o]),m=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),v=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),h=useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsx(StyledModal,{isOpen:e,onOpenChange:u,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.filter.title")}),jsx(tu,{onClick:()=>u(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsx(Xn,{label:i("predict.filter.platform"),children:jsx(Jn,{options:m,selected:a.source,onSelect:x=>f("source",x)})}),jsx(Xn,{label:i("predict.filter.timeRemaining"),children:jsx(Jn,{options:g,selected:a.timeRemaining,onSelect:x=>f("timeRemaining",x)})}),jsx(Xn,{label:i("predict.filter.minVolume"),children:jsx(Jn,{options:v,selected:a.minVolume,onSelect:x=>f("minVolume",x)})}),jsx(Xn,{label:i("predict.filter.minLiquidity"),children:jsx(Jn,{options:h,selected:a.minLiquidity,onSelect:x=>f("minLiquidity",x)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:p,children:i("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:d,children:[i("predict.filter.showResults"),c>0&&jsxs("span",{style:{opacity:.7},children:["(",c,")"]})]})]})]})})})}function Xn({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function tu({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function Jn({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var vs={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},fs={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},du=["start_time","volume","liquidity","ending_soon"],gs={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},uu={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function bs({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:a}){let{t:s}=useTranslation(),[l,u]=useState(false),p=useRef(null),d=useCallback(c=>{p.current&&!p.current.contains(c.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)),[d]),useEffect(()=>{if(!l)return;let c=m=>{m.key==="Escape"&&u(false);};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l]);let f=hs[e];return jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:p,style:{position:"relative"},children:[jsxs("button",{type:"button",style:gs,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(c=>!c),children:[jsx(pu,{}),jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(fs[e])}),jsx(fu,{open:l})]}),l&&jsx("div",{style:{...uu,width:224,padding:4},children:du.map(c=>{let m=hs[c],g=e===c;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:v=>{g||(v.currentTarget.style.background="rgba(39,39,42,0.5)",v.currentTarget.style.color="#fff");},onMouseLeave:v=>{g||(v.currentTarget.style.background="transparent",v.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===c?n(!r):t(c),u(false);},children:[jsx(m,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:s(fs[c])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},c)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)",c.currentTarget.style.color="#fff";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)",c.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:gs,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsx(mu,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s("predict.filter.title")})]}),i>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var hs={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function pu(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function mu(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function fu({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function ks(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:a,error:s,hasNextPage:l,fetchNextPage:u,refetch:p}=useInfiniteEvents(t),d=useMemo(()=>r?.pages.flatMap(m=>m.items).filter(m=>m!=null)??[],[r]),f=useCallback(()=>{u();},[u]),c=useCallback(()=>{p();},[p]);return {data:d,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:a,error:s??null,hasMore:l??false,fetchMore:f,refetch:c}}var Ss=`
|
|
2
2
|
@keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
3
3
|
@media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
|
|
4
4
|
@media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}
|
|
5
5
|
@media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}
|
|
6
|
-
`,
|
|
6
|
+
`,ws={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function Zn(e){return {...ws,animationDelay:`${e}ms`}}function $o({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Ss}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(vu,{index:r},r))})]})}function vu({index:e}){let t=e*120,r={...ws,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 bu(){return jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px"},children:[jsx("div",{style:{display:"flex",alignItems:"center",gap:10,minHeight:40,flex:1},children:[48,64,48,56,72,56].map((e,t)=>jsx("div",{style:{...Zn(t*50),height:28,width:e,borderRadius:6}},t))}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsx("div",{style:{...Zn(0),height:36,width:120,borderRadius:10}}),jsx("div",{style:{...Zn(50),height:36,width:36,borderRadius:10}}),jsx("div",{style:{...Zn(100),height:36,width:80,borderRadius:10}})]})]})}function mx({count:e=24}){return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("style",{children:Ss}),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(bu,{})}),jsx("div",{style:{padding:"12px 8px 80px"},children:jsx($o,{count:e})})]})}var Ps=3,Tu={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)"}},Eu={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Vo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ls={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Lu={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},an=[{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 Ns(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 Ru(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [Vo,Lu];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [Vo,Ls];let r=t[0]??"",n=t[1]??"",o=Ns(r)%an.length,i=Ns(n)%an.length;return i===o&&(i=(i+1)%an.length),[an[o],an[i]]}function Cs(e){return e.title_trans||e.title}function _u(e){return e.question_trans||e.question}function jo(e,t){return e?.label_trans||e?.label||t}function Rs(e){return jo(e.outcomes?.[0],_u(e))}function Iu(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function _s(e){let t=Iu(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Is(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Ms(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Ts(e){let t=e.outcomes?.[1];if(t){let 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 Ou(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 Au=`
|
|
7
7
|
.badge-shine { position: relative; overflow: hidden; }
|
|
8
8
|
.badge-shine::after {
|
|
9
9
|
content: "";
|
|
@@ -27,13 +27,13 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
27
27
|
outline: 2px solid hsl(var(--heroui-primary) / 0.4);
|
|
28
28
|
outline-offset: 2px;
|
|
29
29
|
}
|
|
30
|
-
`;function Ms({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i}){let[s,a]=useState(null),c=e.markets??[],p=useMemo(()=>c.length>2?[...c].sort((x,y)=>(y.outcomes?.[0]?.price??0)-(x.outcomes?.[0]?.price??0)):c,[c]).filter(x=>x.status==="open"),d=p.length===1,f=p.slice(0,vs),l=p.length-vs,m=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),g=s?p.find(x=>x.slug===s)??null:null,h=!!g||d,v=()=>{h||o?.(e);},b=x=>{x.stopPropagation(),g&&(x.preventDefault(),a(null));},N=x=>{x.stopPropagation(),t||(x.preventDefault(),o?.(e));},k=d?jsx(Bu,{event:e,formattedVolume:m,href:t,LinkComponent:r,onSelect:o}):g?jsx(zu,{onCollapse:()=>a(null)}):jsx(Ou,{moreCount:l,formattedVolume:m,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 y=x.currentTarget,P=xu[e.source]??yu;y.style.borderColor=P.border,y.style.boxShadow=P.shadow,i?.(e);},onMouseLeave:x=>{let y=x.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:v,children:[jsx("style",{children:Cu}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Mu,{event:e,href:t,LinkComponent:r,onClick:b,isExpanded:h}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:d?jsx(Fu,{market:p[0],event:e,onSelectOutcome:n}):g?jsx(Hu,{market:g,event:e,onCollapse:()=>a(null),onSelectOutcome:n}):jsx(Iu,{displayedMarkets:f,onMarketClick:x=>a(x.slug)})})]}),jsx(Du,{children:k})]})}function Mu({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let i=e.start_at?Nu(e.start_at):null;return jsxs(Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsx(Avatar,{src:e.image_url||void 0,name:xs(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:xs(e)}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(Eu,{event:e})]})}function Tu(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(n>0&&n<=s){let a=n<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=i?"5m":"15m",color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Eu({event:e}){let t=useMemo(()=>Tu(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsx(Lu,{},o);case "crypto-short":return jsx(Ru,{label:r.label,color:r.color},o);case "closed":return jsx(_u,{},o)}})})}function Lu(){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 Ru({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 _u(){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 Iu({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let o=Ns(r);return jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:n=>{n.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:Ps(r)}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Cs(o)}),jsx(Au,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function Ou({moreCount:e,formattedVolume:t,source:r,href:o,LinkComponent:n,onShowMore:i}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsx(Es,{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(Ls,{source:r})]})]})}function Du({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 Ss({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let c=a.currentTarget;c.style.setProperty("--shadow-offset","2px"),c.style.transform="translateY(2px)";},onMouseLeave:a=>{let c=a.currentTarget;c.style.setProperty("--shadow-offset","4px"),c.style.transform="translateY(0px)";},onClick:o,children:n})}function Ts({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:i}=useTranslation(),[s,a]=o?Su(e):[Bo,ws],c=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",p=n==="label"&&c===u?"action":n,d=p==="label"?`${Ho(e.outcomes?.[0],"Yes")} ${ys(e)}\xA2`:i("predict.market.action.yes",{price:ys(e)}),f=p==="label"?`${Ho(e.outcomes?.[1],"No")} ${ks(e)}\xA2`:i("predict.market.action.no",{price:ks(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Ss,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:l=>{l.stopPropagation(),r?.(t,e,"yes");},children:d}),jsx(Ss,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:l=>{l.stopPropagation(),r?.(t,e,"no");},children:f})]})}function Au(){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 Fu({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Ts,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function Bu({event:e,formattedVolume:t,href:r,LinkComponent:o,onSelect:n}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsx(Es,{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(Ls,{source:e.source})]})]})}function Hu({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let n=Ns(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:Ps(e)}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Cs(n)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Ts,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]})}function zu({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(Wu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Es({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 Wu({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 Ls({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 Vu=8;function _s({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:c}){let{t:u}=useTranslation(),p=useRef(null);useEffect(()=>{let l=p.current;if(!l)return;let m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return m.observe(l),()=>m.disconnect()},[t,r,o]);let d=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),f=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
|
|
30
|
+
`;function Os({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[a,s]=useState(null),l=e.markets??[],p=useMemo(()=>l.length>2?[...l].sort((b,y)=>(y.outcomes?.[0]?.price??0)-(b.outcomes?.[0]?.price??0)):l,[l]).filter(b=>b.status==="open"),d=p.length===1,f=p.slice(0,Ps),c=p.length-Ps,m=useMemo(()=>formatAmountInUsd(e.volume??0),[e.volume]),g=a?p.find(b=>b.slug===a)??null:null,v=!!g||d,h=()=>{v||n?.(e);},x=b=>{b.stopPropagation(),g&&(b.preventDefault(),s(null));},k=b=>{b.stopPropagation(),t||(b.preventDefault(),n?.(e));},S=d?jsx(Gu,{event:e,formattedVolume:m,href:t,LinkComponent:r,onSelect:n}):g?jsx(Yu,{onCollapse:()=>s(null)}):jsx($u,{moreCount:c,formattedVolume:m,source:e.source,href:t,LinkComponent:r,onShowMore:k});return jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:b=>{let y=b.currentTarget,N=Tu[e.source]??Eu;y.style.borderColor=N.border,y.style.boxShadow=N.shadow,i?.(e);},onMouseLeave:b=>{let y=b.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:h,children:[jsx("style",{children:Au}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Du,{event:e,href:t,LinkComponent:r,onClick:x,isExpanded:v}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:d?jsx(ju,{market:p[0],event:e,onSelectOutcome:o}):g?jsx(qu,{market:g,event:e,onCollapse:()=>s(null),onSelectOutcome:o}):jsx(Uu,{displayedMarkets:f,onMarketClick:b=>s(b.slug)})})]}),jsx(Ku,{children:S})]})}function Du({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?Ou(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:Cs(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",o&&"group-hover/header:text-neutral-400"),children:Cs(e)}),i&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsx(Bu,{event:e})]})}function Fu(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,a=900*1e3;if(o>0&&o<=a){let s=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:s});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Bu({event:e}){let t=useMemo(()=>Fu(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(Hu,{},n);case "crypto-short":return jsx(zu,{label:r.label,color:r.color},n);case "closed":return jsx(Wu,{},n)}})})}function Hu(){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 zu({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 Wu(){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 Uu({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=_s(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:Rs(r)}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Is(n)}),jsx(Vu,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function $u({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:a}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[a("predict.event.showMore"),jsx(Ds,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",a("predict.event.volume"),jsx(Fs,{source:r})]})]})}function Ku({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 Es({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function As({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=useTranslation(),[a,s]=n?Ru(e):[Vo,Ls],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",p=o==="label"&&l===u?"action":o,d=p==="label"?`${jo(e.outcomes?.[0],"Yes")} ${Ms(e)}\xA2`:i("predict.market.action.yes",{price:Ms(e)}),f=p==="label"?`${jo(e.outcomes?.[1],"No")} ${Ts(e)}\xA2`:i("predict.market.action.no",{price:Ts(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Es,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"yes");},children:d}),jsx(Es,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"no");},children:f})]})}function Vu(){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 ju({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(As,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function Gu({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s=>{s.stopPropagation(),r||(s.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsx(Ds,{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(Fs,{source:e.source})]})]})}function qu({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=_s(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:Rs(e)}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Is(o)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(As,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function Yu({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(Qu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Ds({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 Qu({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 Fs({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 ep=8;function Hs({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:a,LinkComponent:s,onHover:l}){let{t:u}=useTranslation(),p=useRef(null);useEffect(()=>{let c=p.current;if(!c)return;let m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return m.observe(c),()=>m.disconnect()},[t,r,n]);let d=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),f=!t&&e.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsx("style",{children:`
|
|
31
31
|
@keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
32
32
|
@keyframes evt-load-spin{to{transform:rotate(360deg)}}
|
|
33
33
|
@media(max-width:767px){.evt-card-grid{grid-template-columns:1fr!important}}
|
|
34
34
|
@media(min-width:768px) and (max-width:1023px){.evt-card-grid{grid-template-columns:repeat(2,1fr)!important}}
|
|
35
35
|
@media(min-width:1024px) and (max-width:1279px){.evt-card-grid{grid-template-columns:repeat(3,1fr)!important}}
|
|
36
|
-
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((
|
|
36
|
+
`}),jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((c,m)=>c==null?null:jsx("div",{style:{padding:ep,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${m%4*35}ms both`},children:jsx(Os,{event:c,href:a?.(c),LinkComponent:s,onSelect:o,onSelectOutcome:i,onHover:l})},`${c.source}-${c.slug}`))}),jsx("div",{ref:p,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),u("predict.events.loadMore")]})}),f&&jsx(tp,{onScrollToTop:d})]})}function tp({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 Ws({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p,onSelect:d,onSelectOutcome:f,getEventHref:c,LinkComponent:m,onHover:g}){let{data:v,hasMore:h,fetchMore:x,isFetching:k,isFetchingMore:S}=ks({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p});return k?jsx($o,{count:24}):jsx(Hs,{events:v,hasMore:h,isFetchingMore:S,onFetchMore:x,onSelect:d,onSelectOutcome:f,getEventHref:c,LinkComponent:m,onHover:g})}function Wx({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:a,enableKalshi:s=true}){let[l,u]=useState({categorySlug:null,tagSlug:null}),[p,d]=useState(()=>s?sn:{...sn,source:"polymarket"}),{isOpen:f,onOpen:c,onClose:m}=useDisclosure(),{onOpen:g}=useAsyncModal(on),v=useCallback((M,C,_)=>{t?.(M,C,_),g({params:{event:M,market:C,initialOutcome:_,onInsufficientBalance:a}});},[t,g,a]),h=useCallback(M=>{u(M);},[]),x=useCallback(M=>{d(C=>({...C,sortPreset:M}));},[]),k=useCallback(M=>{d(C=>({...C,sortAsc:M}));},[]),S=useCallback(M=>{d(M);},[]),b=useMemo(()=>vs[p.sortPreset].sort_by,[p.sortPreset]),y=useMemo(()=>Uo(p,s),[p,s]),N=useMemo(()=>jsx(bs,{sortPreset:p.sortPreset,onSortChange:x,sortAsc:p.sortAsc,onSortAscChange:k,onFilterPress:c,filterCount:y}),[p.sortPreset,p.sortAsc,y,x,k,c]);return jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx($i,{onSelect:h,trailing:N})}),jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsx(ps,{isOpen:f,onClose:m,value:p,onChange:S,enableKalshi:s}),jsx(Ws,{tagSlugSelection:l,sort_by:b,sort_asc:p.sortAsc,source:p.source,timeRemaining:p.timeRemaining,minVolume:p.minVolume,minLiquidity:p.minLiquidity,onSelect:e,onSelectOutcome:v,getEventHref:r,LinkComponent:n,onHover:o})]}),jsx(Yn,{})]})}function Vs(e){return formatAmountInUsd(e)}var sp=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)"},{key:"total_volume_24h",labelKey:"predict.events.stats.volume24h",format:Vs,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:Vs,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function jx({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
37
37
|
@keyframes evt-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
38
38
|
@keyframes evt-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
39
39
|
@keyframes evtHeroTitleEnter{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -71,15 +71,15 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
71
71
|
.evt-stat-label{font-size:11px;line-height:16px;min-height:16px;white-space:nowrap}
|
|
72
72
|
@media(min-width:640px){.evt-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
73
73
|
`}),jsxs("div",{className:"evt-hero-outer",children:[jsxs("div",{className:"evt-hero-left",style:{minWidth:0,flex:1,animation:"evtHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"evt-hero-live",style:{marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"evt-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"evt-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.events.liveBadge")})]})}),jsxs("h1",{className:"evt-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.events.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.events.titleHighlight")})]}),jsx("p",{className:"evt-hero-subtitle evt-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.events.heroSubtitle")).split(`
|
|
74
|
-
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:Xu.map((r,o)=>jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function Us({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i,i18n:s}=useTranslation(),{mutateAsync:a}=useRedeemPosition(),{start:c}=useTradeResultConfirmation(),{evmAddress:u}=br(),p=useWallets(),[d,f]=useState("idle"),[l,m]=useState(null),g=t.provider_meta?.["polymarket.conditionId"],h=t.provider_meta?.["polymarket.negRisk"]??false,v=u??"",b=useMemo(()=>Ir(i,s),[s,i]),N=useMemo(()=>p.find(Y=>Y.chainNamespace===ChainNamespace.EVM&&Y.isConnected),[p]),k=Ws(r.side,t.outcomes),y=t.outcomes?.[k]?.label??r.side,P=t.result!=null?Ws(t.result,t.outcomes):-1,R=(P>=0?t.outcomes?.[P]:void 0)?.label??t.result??"",I=t.result!=null?k===P:true,z=useMemo(()=>I?r.size:0,[I,r.size]),K=useCallback(async()=>{if(!(!g||!v||!N)){f("pending"),m(null);try{let Y=await N.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await a({wallet_address:v,condition_id:g,neg_risk:h,signMessage:async w=>await Y.request({method:"personal_sign",params:[w,v]}),signTypedData:async w=>await Y.request({method:"eth_signTypedData_v4",params:[v,JSON.stringify(w)]})}),f("confirming");let Q=Or({messages:b});Q.submitted(),await c({source:r.source,user:v,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem"})==="confirmed"?(f("success"),Q.completed()):(f("delayed"),Q.delayed()),o?.();}catch(Y){f("error"),m(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,v,h,N,a,b,c,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,o,i]),W=useAuthCallback(K),G=d==="idle"&&!!g&&!!v&&!!N&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(Kn,{label:i("predict.positions.side"),value:y,valueClassName:I?"text-green-400":"text-red-400"}),t.result!=null&&jsx(Kn,{label:i("predict.redeem.result"),value:R,valueClassName:"text-green-400"}),jsx(Kn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(Kn,{label:i("predict.redeem.expectedPayout"),value:`$${z.toFixed(2)}`,valueClassName:z>0?"text-green-400":"text-zinc-400"})]}),!I&&z===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),d==="error"&&l&&jsx("p",{className:"text-sm text-red-400",children:l}),d==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),d==="delayed"&&jsx("p",{className:"text-sm text-zinc-400",children:i("predict.trade.resultDelayed",{defaultValue:"Your trade was submitted successfully. Confirmation is taking a little longer."})}),jsxs("div",{className:"flex flex-col gap-2",children:[d!=="success"&&d!=="delayed"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!G,isLoading:d==="pending"||d==="confirming",onPress:W,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&d!=="success"&&d!=="delayed"&&jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),(d==="success"||d==="delayed")&&n&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Kn({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function Ws(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let o=t.findIndex(n=>n.label.toLowerCase()===r);return o>=0?o:1}var pp="predict-redeem";function Ks({id:e=pp}){return jsx(AsyncModal,{id:e,children:t=>jsx(mp,{...t})})}function mp({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:o("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:o("predict.redeem.description")})]}),jsx(Us,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Gs({market:e,initialOutcome:t="yes",slippageBps:r=100,onSuccess:o}){let{t:n,i18n:i}=useTranslation(),s=useRef(o);s.current=o;let{status:a}=useAuth(),c=useWallets(),u=usePredictClient(),p=useContext(PolymarketContext),d=useQueryClient(),{start:f}=useTradeResultConfirmation(),l=e.source,m=l==="polymarket",g=c.find(C=>C.chainNamespace===ChainNamespace.SOLANA&&C.isConnected),h=c.find(C=>C.chainNamespace===ChainNamespace.EVM&&C.isConnected&&"switchChain"in C),v=a==="authenticated",b=g?.address,N=h?.address,[k,x]=useState(t),[y,P]=useState("market"),[S,R]=useState(NaN),[I,z]=useState(NaN),[K,W]=useState(false),[G,Y]=useState(false),[Q,re]=useState(null),[w,M]=useState(null),[$,J]=useState(false),[ne,O]=useState(false),[Se,A]=useState("1h"),[be,pt]=useState(30),[Ee,qe]=useState("minutes"),st=useMemo(()=>Ir(n,i),[i,n]),we=useCallback(async(C,Ce)=>{let _e=Or({messages:st});_e.submitted(),await f({source:l,user:l==="kalshi"?b:N,kalshiUser:b,polymarketUser:N,marketSlug:e.slug,eventSlug:e.event_slug,expectation:C,getOrdersHeaders:Ce})==="confirmed"?_e.completed():_e.delayed();},[f,N,e.event_slug,e.slug,l,st,b]),Ze=useMemo(()=>{if(l!=="polymarket")return;let C=e.provider_meta?.["polymarket.clobTokenIds"];return C?(typeof C=="string"?JSON.parse(C):C)[k==="yes"?0:1]:void 0},[l,e.provider_meta,k]),{data:et,isLoading:tt}=useTickSize(Ze),at=et?.minimum_tick_size?String(et.minimum_tick_size):"0.01",{data:Ot,isLoading:ze}=useFeeRate(Ze),rt=String(Ot?.base_fee??0),{data:We}=useRebateConfig(),Ue=We?.builder_enabled&&We.builder_code?We.builder_code:void 0,nt=false,mt=null,Mt=false,E,de,Le;try{let C=br();nt=C.kalshiKycVerified,mt=C.kalshiKycUrl,Mt=C.polymarketSetupVerified,E=C.polymarketSafeAddress,de=C.polymarketWalletKind,Le=C.polymarketWalletAddress;}catch{}let Ge=l==="kalshi"&&!nt,Vr=l==="polymarket"&&!Mt,Dt=useCallback(async()=>{if(!h||!p)return null;let C=await h.getEip1193Provider();if(!C)return null;let Ce=de==="deposit"&&!!Le,_e=!Ce&&!!E,Ke={address:h.address,signatureType:Ce?3:_e?2:0,signTypedData:async(lt,Et,ct,he)=>{let Oe=[];"name"in lt&&Oe.push({name:"name",type:"string"}),"version"in lt&&Oe.push({name:"version",type:"string"}),"chainId"in lt&&Oe.push({name:"chainId",type:"uint256"}),"verifyingContract"in lt&&Oe.push({name:"verifyingContract",type:"address"}),"salt"in lt&&Oe.push({name:"salt",type:"bytes32"});let Qt={EIP712Domain:Oe,...Et};return await C.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:lt,types:Qt,primaryType:ct,message:he})]})}};return p.credentials??await p.authenticate(Ke)},[E,de,Le,h,p]),{data:Pt}=useRealtimeOrderbook({slug:e.slug,source:l,outcome:k},{enabled:e.status==="open"}),Pe=useMemo(()=>{let C=pickBestBid(Pt,k);if(C!=null&&C>0)return C;let Ce=k==="yes"?0:1,_e=e.outcomes[Ce];return _e?.best_bid??_e?.price??.5},[Pt,e.outcomes,k]),ot=l==="kalshi"?b??"":N??"",{data:At,isLoading:F}=usePositionsMulti({kalshi_user:l==="kalshi"?ot:void 0,polymarket_user:l==="polymarket"?ot:void 0},{enabled:!!ot,refetchInterval:3e4}),$e=useCallback(async()=>{let C=await Dt();return C?await buildPolymarketL2Headers(C.address,{apiKey:C.apiKey,secret:C.secret,passphrase:C.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Dt]),{data:ft,isLoading:go}=useAvailableShares({source:l,user:ot,market:e.slug,side:k},l==="polymarket"?{getHeaders:$e}:void 0,{enabled:!!ot&&!!e.slug,refetchOnMount:"always"}),qt=ft?.total_shares??0,Gt=ft?.active_order_shares??0,Ft=ft?.available_shares??0,Ye=useMemo(()=>l==="polymarket"?getPolymarketSharesPrecision(at):ft?.precision??0,[l,at,ft?.precision]),ho=go||F,vo=e.provider_meta?.["dflow.yesMint"]??"",hn=e.provider_meta?.["dflow.noMint"]??"",Tt=SOLANA_TOKENS.stablecoins.USDC.address,bo=e.provider_meta?.["dflow.collateralMint"]||"",Yt=k==="yes"?vo:hn,Bt=useMemo(()=>At?At.positions.find(C=>C.side?.toLowerCase()===k&&C.market?.slug===e.slug)??null:null,[At,e.slug,k])?.market?.provider_meta,vn=Bt?.["dflow.outcomeMint"]||Yt,nr=Bt?.["dflow.collateralMint"]||bo,or=vn,pr=nr||Tt,Er=useMemo(()=>isNaN(S)||S<=0?"0":String(Math.round(S*1e6)),[S]),yo=l==="kalshi"&&!!or&&!!pr&&!!b&&Er!=="0",{refetch:mr}=useDFlowQuote({inputMint:or,outputMint:pr,amount:Er,userPublicKey:b??"",slippageBps:100},{enabled:yo}),fr=useMemo(()=>isNaN(S)||S<=0?0:S,[S]),Nt=useMemo(()=>walkOrderbook({orderbook:Pt,outcome:k,side:"sell",sharesNeeded:fr,slippageBps:r}),[Pt,k,fr,r]),bn=useMemo(()=>Nt.status==="ok"&&Nt.worstPrice!=null&&Nt.worstPrice>0?Nt.worstPrice:Pe,[Nt,Pe]),xn=useMemo(()=>{if(isNaN(S)||S<=0)return 0;let C=y==="limit"&&m&&!isNaN(I)?I:Pe;return S*C},[S,y,m,I,Pe]),gr=useCallback(C=>{x(C),z(NaN),R(NaN),Y(false);},[]);useEffect(()=>{gr(t);},[t,gr]);let yn=useCallback(C=>{P(C);},[]);useEffect(()=>{y==="limit"&&z(Math.round(Pe*1e4)/1e4);},[y,k]);let kn=useCallback(C=>{if(Y(false),isNaN(C)){R(NaN);return}R(ve(Math.max(0,C),Ye));},[Ye]),ko=useCallback(()=>{Y(true),R(ve(Ft,Ye));},[Ft,Ye]),L=useCallback(C=>{if(isNaN(C)){z(NaN);return}z(Math.round(C*1e4)/1e4);},[]),Ne=useCallback(()=>{R(NaN),z(NaN),P("market"),Y(false),O(false),A("1h"),pt(30),qe("minutes");},[]),Re=useMemo(()=>{let C=[];return isNaN(S)||S<=0?C.push(n("predict.trade.minQuantity",{amount:Ln})):S<Ln&&C.push(n("predict.trade.minQuantity",{amount:Ln})),e.status!=="open"&&C.push(n("predict.trade.marketNotActive")),!isNaN(S)&&S>0&&!G&&S>Ft&&C.push(n("predict.trade.insufficientSharesDetail",{total:ve(qt,Ye).toFixed(Ye),active:ve(Gt,Ye).toFixed(Ye),available:ve(Ft,Ye).toFixed(Ye)})),y==="limit"&&m&&(isNaN(I)||I<.01||I>.99)&&C.push(n("predict.trade.limitPriceRange")),y==="limit"&&m&&ne&&Se==="custom"&&(isNaN(be)||be<=0)&&C.push(n("predict.trade.expiration.invalidDate")),l==="polymarket"&&y==="market"&&!isNaN(S)&&S>0&&(Nt.status==="insufficient_liquidity"?C.push(n("predict.trade.insufficientLiquidity",{available:ve(Nt.totalAvailable,2)})):Nt.status==="exceeds_slippage"&&C.push(n("predict.trade.priceImpactTooHigh",{impact:(Nt.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:C.length===0,errors:C}},[S,e.status,Ft,qt,Gt,G,y,m,I,ne,Se,be,Ye,l,Nt,r,n]),{mutateAsync:gt}=useDFlowSubmit(),{data:hr}=useOrder({id:Q??"",source:l},{enabled:!!Q}),ir=useCallback(async()=>{if(!w||!b||!g)return;let{cashAmount:C,collateral:Ce}=w;M(null);try{let Ke=(await u.createDFlowQuote({inputMint:Ce,outputMint:Tt,amount:C,userPublicKey:b,slippageBps:100}))?.transaction;if(!Ke)return;let lt=Uint8Array.from(atob(Ke),ct=>ct.charCodeAt(0)),Et=await g.signTransaction(lt);await gt({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:b,input_mint:Ce,output_mint:Tt,amount:C,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[w,b,g,u,gt,Tt]),ht=useCallback(()=>{d.invalidateQueries({queryKey:["predict","available-shares"]});},[d]);useEffect(()=>{if(!hr||!Q)return;let{status:C}=hr;C==="closed"?(re(null),w?ir().finally(()=>{W(false),we("sell-market"),ht(),Ne(),s.current?.();}):(W(false),we("sell-market"),ht(),Ne(),s.current?.())):(C==="failed"||C==="expired")&&(W(false),re(null),M(null),toast.error(n("predict.trade.submitError")));},[hr,Q,w,ir,we,ht,Ne,n]);let Qe=useCallback(async()=>{if(!b||!g)return;if(!or||!pr){toast.error("Missing token mint addresses"),W(false);return}if(!nt){J(true),W(false);return}let _e=(await mr()).data,Ke=_e?.transaction;if(!Ke){toast.error(n("predict.trade.submitError")),W(false);return}if(nr&&nr!==Tt){let he=String(_e?.outAmount??"");he&&he!=="0"&&M({cashAmount:he,collateral:nr});}let lt=Uint8Array.from(atob(Ke),he=>he.charCodeAt(0)),Et=await g.signTransaction(lt),ct=await gt({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:b,input_mint:or,output_mint:pr,amount:Er,price:String(Pe),side:"SELL",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});re(ct.signature);},[b,g,mr,gt,or,pr,Er,Pe,k,e.slug,nr,Tt,n,nt]),Sn=useCallback(async()=>{if(!h||!p)return;let C=h.chain,Ce=C!==Chain.POLYGON;Ce&&await h.switchChain(Chain.POLYGON);try{let _e=await h.getEip1193Provider();if(!_e){toast.error(n("predict.trade.submitError")),W(!1);return}let Ke=de==="deposit"&&!!Le,lt=!Ke&&!!E,Et=Ke?Le:E,ct={address:h.address,signatureType:Ke?3:lt?2:0,signTypedData:async(Ht,Pn,No,Co)=>{let Rr=[];"name"in Ht&&Rr.push({name:"name",type:"string"}),"version"in Ht&&Rr.push({name:"version",type:"string"}),"chainId"in Ht&&Rr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ht&&Rr.push({name:"verifyingContract",type:"address"}),"salt"in Ht&&Rr.push({name:"salt",type:"bytes32"});let fc={EIP712Domain:Rr,...Pn};return await _e.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Ht,types:fc,primaryType:No,message:Co})]})}},he=await Dt();if(!he){toast.error(n("predict.trade.submitError")),W(!1);return}let Oe=k==="yes"?0:1,Qt="",sr=e.provider_meta?.["polymarket.clobTokenIds"];sr&&(Qt=(typeof sr=="string"?JSON.parse(sr):sr)[Oe]??"");let Lr=e.provider_meta?.["polymarket.negRisk"]??!1,ar=y==="limit"&&!isNaN(I)?I:bn,So=In(ar,at),wo={tokenId:Qt,price:So,size:S,side:"SELL",orderType:y==="limit"?ne?"GTD":"GTC":"FOK",tickSize:at,negRisk:Lr,...Et&&{funderAddress:Et},...Ue&&{builderCode:Ue},...y==="limit"&&ne&&{expiration:_n(Se,be,Ee)}},Po;if(Ke)Po=await buildSignedV2OrderPayload({signer:ct,depositWalletAddress:Et,input:wo,owner:he.apiKey});else {let Ht=buildCtfExchangeDomain(Lr),Pn=buildOrderMessage({...wo,signerAddress:ct.address,signatureType:ct.signatureType,feeRateBps:rt}),No=await ct.signTypedData(Ht,CTF_ORDER_TYPES,"Order",Pn),Co=buildSignedOrder(Pn,No,wo.orderType);Po=buildClobPayload(Co,he.apiKey);}await u.executePolymarketOrder({payload:Po,l2_api_key:he.apiKey,l2_secret:he.secret,l2_passphrase:he.passphrase,signer_address:he.address,owner:he.apiKey}),ht(),we(y==="limit"?"sell-limit":"sell-market",async()=>await buildPolymarketL2Headers(he.address,{apiKey:he.apiKey,secret:he.secret,passphrase:he.passphrase,method:"GET",requestPath:"/data/orders"})),Ne(),W(!1),s.current?.();}finally{Ce&&C&&h.switchChain(C).catch(()=>{});}},[h,p,Dt,k,e.provider_meta,y,we,I,bn,S,u,ht,ne,Se,be,Ee,Ne,n,at,rt,e.slug,E,de,Le,Ue]),wn=useCallback(async()=>{if(!(!Re.isValid||!v)){W(true),re(null),J(false);try{l==="kalshi"?await Qe():await Sn();}catch(C){let Ce=C instanceof Error?C.message:"",_e=l==="polymarket"&&Ce?On(Ce,n,"sell"):Ce||void 0;toast.error(_e||n("predict.trade.submitError")),W(false);}}},[Re.isValid,v,l,Qe,Sn,n]);return {outcome:k,orderType:y,quantity:S,limitPrice:I,shares:fr,estimatedReturn:xn,pricePerShare:Pe,isMarketDataLoading:l==="polymarket"&&(ze||tt),isSubmitting:K,authStatus:a,validation:Re,supportsLimitOrder:m,kycRequired:$,needsKyc:Ge,needsSetup:Vr,kycUrl:mt,totalShares:qt,activeOrderShares:Gt,availableShares:Ft,isAvailableLoading:ho,isSellAll:G,precision:Ye,expirationEnabled:ne,expirationPreset:Se,customDuration:be,customDurationUnit:Ee,setOutcome:gr,setOrderType:yn,setQuantity:kn,setLimitPrice:L,setSellAll:ko,setExpirationEnabled:O,setExpirationPreset:A,setCustomDuration:pt,setCustomDurationUnit:qe,submit:wn}}var Yp=["5m","1h","12h","24h","eod","custom"],Qp={"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"},Xp=["minutes","hours","days"],Jp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Zp={maximumFractionDigits:0};function na({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:c,isSubmitting:u,authStatus:p,isValid:d,validationErrors:f,supportsLimitOrder:l,kycRequired:m,needsKyc:g,needsSetup:h,onSetupRequired:v,kycUrl:b,totalShares:N,activeOrderShares:k,availableShares:x,isAvailableLoading:y,precision:P,expirationEnabled:S,expirationPreset:R,customDuration:I,customDurationUnit:z,oddsFormatter:K,onOutcomeChange:W,onOrderTypeChange:G,onQuantityChange:Y,onLimitPriceChange:Q,onSellAll:re,onExpirationEnabledChange:w,onExpirationPresetChange:M,onCustomDurationChange:$,onCustomDurationUnitChange:J,onSubmit:ne}){let{t:O}=useTranslation(),[Se,A]=useState(false),be=useDisclosure(),[pt,Ee]=useState(""),qe=useRef(false);useEffect(()=>{qe.current||Ee(isNaN(i)?"":String(i));},[i]);let[st,we]=useState(""),Ze=useRef(false);useEffect(()=>{Ze.current||(isNaN(s)?we(""):we(String(parseFloat((s*100).toFixed(2)))));},[s]);let et=useCallback(E=>{if(E!==""&&!/^\d*\.?\d{0,2}$/.test(E))return;if(we(E),E===""||E==="."){Q(NaN);return}let Le=parseFloat(E);isNaN(Le)||Q(Le/100);},[Q]),tt=useCallback(E=>{let de=new RegExp(`^\\d*\\.?\\d{0,${P}}$`);if(E!==""&&!de.test(E))return;if(Ee(E),A(false),E===""||E==="."){Y(NaN);return}let Le=parseFloat(E);isNaN(Le)||Y(Le);},[Y,P]);useEffect(()=>{m&&!be.isOpen&&be.onOpen();},[m]);let at=useMemo(()=>{let E=o==="yes"?t.yesBid:t.noBid;return E!=null?parseFloat((Number(E)*100).toFixed(2)):null},[o,t]),Ot=o==="yes"?t.yesBid:t.noBid,ze=Ot!=null&&K?K(Number(Ot)):at!=null?`${at} \xA2`:null,rt=!isNaN(i)&&i>0,We=p==="authenticated",Ue=p==="authenticating"||p==="deauthenticating",nt=We&&(g||h),mt=useMemo(()=>{if(Ue)return O("predict.trade.checkingLogin");if(!We)return O("predict.trade.loginToTrade");if(g)return O("predict.trade.kycRequired");if(h)return O("predict.trade.setupRequired");if(y)return O("predict.trade.loadingBalance");if(c)return O("predict.trade.loadingMarketData");if(u)return O("predict.trade.submitting");if(m)return O("predict.trade.kycRequired");if(!rt)return O("predict.trade.enterAmount");let E=O(o==="yes"?"predict.trade.yes":"predict.trade.no");return `${O("predict.trade.sell")} ${E}`},[Ue,We,g,h,y,c,u,m,rt,o,O]),Mt=()=>{if(!We){A(false),ne();return}if(g){be.onOpen();return}if(h&&v){A(false),v();return}if(m){be.onOpen();return}if(!d){A(true);return}A(false),ne();};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:E=>{r==="bordered"&&(E.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:E=>{r==="bordered"&&(E.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:[O("predict.trade.sell")," ",O(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[l?jsxs(Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:E=>G(E),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:O("predict.trade.market")},"market"),jsx(Tab,{title:O("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:O("predict.trade.market")}),n==="limit"&&l?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:st,onChange:E=>et(E.target.value),onFocus:()=>{Ze.current=true;},onBlur:()=>{Ze.current=false,isNaN(s)?we(""):we(String(parseFloat((s*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):ze!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:ze})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(E=>{let de=E==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>W(E),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===E?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:O(E==="yes"?"predict.trade.yes":"predict.trade.no")}),de!=null&&jsx("span",{className:"ml-1 opacity-70",children:K?K(Number(de)):`${parseFloat((Number(de)*100).toFixed(2))}\xA2`})]})},E)})}),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:O("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(E=>{let de=Math.pow(10,P);return jsxs("button",{type:"button",onClick:()=>{Y(Math.floor(x*E/100*de)/de);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[E,"%"]},E)}),jsx("button",{type:"button",onClick:re,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:O("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:pt,onChange:E=>tt(E.target.value),onFocus:()=>{qe.current=true;},onBlur:()=>{qe.current=false,Ee(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"}}),Se&&f.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:f.map(E=>jsx("span",{className:"text-xs text-danger",children:E},E))})]}),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:O("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:y?"\u2013":`${ve(N,P).toFixed(P)}${O("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:O("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:y?"\u2013":k>0?`-${ve(k,P).toFixed(P)}${O("predict.trade.sharesUnit")}`:`0${O("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:O("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:y?"\u2013":`${ve(x,P).toFixed(P)}${O("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:O("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),n==="limit"&&l&&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:O("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:S,onValueChange:w,"aria-label":O("predict.trade.setExpiration")})]}),S&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":O("predict.trade.setExpiration"),selectedKeys:[R],onSelectionChange:E=>{let de=Array.from(E)[0];de&&M(de);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Yp.map(E=>jsx(SelectItem,{children:O(Qp[E])},E))}),R==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(I)?void 0:I,onValueChange:$,minValue:1,step:1,formatOptions:Zp,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[z],onSelectionChange:E=>{let de=Array.from(E)[0];de&&J(de);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Xp.map(E=>jsx(SelectItem,{children:O(Jp[E])},E))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:Ue||We&&!nt&&(y||c||!rt||u),isLoading:Ue||We&&!nt&&(u||y||c),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Mt,children:mt})]}),jsx(An,{isOpen:be.isOpen,onClose:be.onClose,kycUrl:b})]})}function jn({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onOutcomeChange:s,onSetupRequired:a,onSuccess:c,oddsFormatter:u}){let{outcome:p,orderType:d,quantity:f,limitPrice:l,estimatedReturn:m,pricePerShare:g,isMarketDataLoading:h,isSubmitting:v,authStatus:b,validation:N,supportsLimitOrder:k,kycRequired:x,needsKyc:y,needsSetup:P,kycUrl:S,totalShares:R,activeOrderShares:I,availableShares:z,isAvailableLoading:K,precision:W,expirationEnabled:G,expirationPreset:Y,customDuration:Q,customDurationUnit:re,setOutcome:w,setOrderType:M,setQuantity:$,setLimitPrice:J,setSellAll:ne,setExpirationEnabled:O,setExpirationPreset:Se,setCustomDuration:A,setCustomDurationUnit:be,submit:pt}=Gs({market:t,initialOutcome:o,slippageBps:i,onSuccess:c}),Ee=useAuthCallback(pt),qe=useCallback(Ze=>{w(Ze),s?.(Ze);},[w,s]),st=useMemo(()=>e?Cn(e):void 0,[e]),we=useMemo(()=>Mn(t,{yesBid:p==="yes"?g:void 0,noBid:p==="no"?g:void 0}),[t,p,g]);return jsx(na,{event:st,market:we,variant:r,outcome:p,orderType:d,quantity:f,limitPrice:l,estimatedReturn:m,isMarketDataLoading:h,isSubmitting:v,authStatus:b,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:k,kycRequired:x,needsKyc:y,needsSetup:P,onSetupRequired:a,kycUrl:S,totalShares:R,activeOrderShares:I,availableShares:z,isAvailableLoading:K,precision:W,expirationEnabled:G,expirationPreset:Y,customDuration:Q,customDurationUnit:re,oddsFormatter:u,onOutcomeChange:qe,onOrderTypeChange:M,onQuantityChange:$,onLimitPriceChange:J,onSellAll:ne,onExpirationEnabledChange:O,onExpirationPresetChange:Se,onCustomDurationChange:A,onCustomDurationUnitChange:be,onSubmit:Ee})}var qo="predict-sell";function ia({id:e=qo}){return jsx(AsyncModal,{id:e,children:t=>jsx(lm,{...t})})}function lm({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:n?"":"p-2",children:[jsx(jn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var Qo=40,Yn=36,rn=480,Xo=rn-Yn;function la({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,i]=useState("positions"),s=useMemo(()=>e.markets?.map(d=>d.slug)??[],[e.markets]),{data:a}=usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),c=useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(d=>d.market&&s.includes(d.market.slug)).length,[a?.positions,s,t]),p=[{key:"positions",label:c>0?`${o("predict.positions.title")} (${c})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:p.map(d=>jsx("button",{type:"button",onClick:()=>i(d.key),className:cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===d.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:d.label},d.key))}),t?jsxs("div",{style:{height:rn},children:[n==="positions"&&jsx(gm,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsx(vm,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsx(ym,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:o("predict.trade.connectWallet")})]})}function gm({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:i}=usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),s=useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[n?.positions,r]);return i?jsx(Zo,{}):s.length===0?jsx(Jo,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Yn},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Xo},rowComponent:hm,rowCount:s.length,rowHeight:Qo,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function hm({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let i=n.pnl??0,s=n.pnl_percent??0,a=n.avg_price??0,c=n.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",p=i>0?"+":"",d=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",f=n.side,l=n.size,m=n.size*c,g=n.market?.end_at?wm(n.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:d}),jsx("span",{className:cn("text-[10px] font-medium",f.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:f})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",m.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:qn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:qn(c)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[p,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,s.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function vm({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:c}=useInfiniteOrders({source:e,wallet_address:t}),u=useCancelOrder(),p=useMemo(()=>{let v=i?.pages?.flatMap(k=>k.items)??[],b=new Set(["live","open","submitted","pending"]),N=v.filter(k=>b.has(k.status));return r.length>0&&(N=N.filter(k=>k.market_id&&r.includes(k.market_id))),N},[i?.pages,r]),d=useCallback(v=>{o?o(v.id):u.mutate({source:v.source,id:v.id});},[o,u]),f=p.length,l=f+(c?1:0),m=useCallback(v=>v<f,[f]),g=useCallback(async()=>{await a();},[a]),h=useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:l,threshold:5});return s?jsx(Zo,{}):p.length===0&&!c?jsx(Jo,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Yn},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:Xo},onRowsRendered:h,rowComponent:bm,rowCount:l,rowHeight:Qo,rowProps:{orders:p,itemCount:f,onCancel:d,isCancelling:u.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function bm({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let c=a.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",c?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?qn(parseFloat(a.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(xm,{status:a.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(a),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):s})})]})}function xm({status:e}){return jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function ym({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:o,isLoading:n,fetchNextPage:i,hasNextPage:s}=useInfiniteTrades({source:e,wallet:t,limit:50}),a=useMemo(()=>o?.pages?.flatMap(l=>l.items)??[],[o?.pages]),c=a.length,u=c+(s?1:0),p=useCallback(l=>l<c,[c]),d=useCallback(async()=>{await i();},[i]),f=useInfiniteLoader({isRowLoaded:p,loadMoreRows:d,rowCount:u,threshold:5});return n?jsx(Zo,{}):a.length===0&&!s?jsx(Jo,{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:Xo},onRowsRendered:f,rowComponent:km,rowCount:u,rowHeight:Qo,rowProps:{trades:a,itemCount:c}})]})}function km({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let i=n.side?.toUpperCase()==="BUY",s=Sm(n.timestamp),a=n.price??0,c=n.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:qn(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function Jo({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:e})}function Zo(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:rn},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function qn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Sm(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${i}`}function wm(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var ca=`
|
|
74
|
+
`).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:sp.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 Ys({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i,i18n:a}=useTranslation(),{mutateAsync:s}=useRedeemPosition(),{start:l}=useTradeResultConfirmation(),{evmAddress:u}=xr(),p=useWallets(),[d,f]=useState("idle"),[c,m]=useState(null),g=t.provider_meta?.["polymarket.conditionId"],v=t.provider_meta?.["polymarket.negRisk"]??false,h=u??"",x=useMemo(()=>Hr(i,a),[a,i]),k=useMemo(()=>p.find(Y=>Y.chainNamespace===ChainNamespace.EVM&&Y.isConnected),[p]),S=qs(r.side,t.outcomes),y=t.outcomes?.[S]?.label??r.side,N=t.result!=null?qs(t.result,t.outcomes):-1,C=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",_=t.result!=null?S===N:true,F=useMemo(()=>_?r.size:0,[_,r.size]),U=useCallback(async()=>{if(!(!g||!h||!k)){f("pending"),m(null);try{let Y=await k.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:g,neg_risk:v,signMessage:async P=>await Y.request({method:"personal_sign",params:[P,h]}),signTypedData:async P=>await Y.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(P)]})}),f("confirming");let q=zr({messages:x});q.submitted(),await l({source:r.source,user:h,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem"})==="confirmed"?(f("success"),q.completed()):(f("delayed"),q.delayed()),n?.();}catch(Y){f("error"),m(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,h,v,k,s,x,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,n,i]),Q=useAuthCallback(U),B=d==="idle"&&!!g&&!!h&&!!k&&r.redeemable;return jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsx(eo,{label:i("predict.positions.side"),value:y,valueClassName:_?"text-green-400":"text-red-400"}),t.result!=null&&jsx(eo,{label:i("predict.redeem.result"),value:C,valueClassName:"text-green-400"}),jsx(eo,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsx(eo,{label:i("predict.redeem.expectedPayout"),value:`$${F.toFixed(2)}`,valueClassName:F>0?"text-green-400":"text-zinc-400"})]}),!_&&F===0&&jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),d==="error"&&c&&jsx("p",{className:"text-sm text-red-400",children:c}),d==="success"&&jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),d==="delayed"&&jsx("p",{className:"text-sm text-zinc-400",children:i("predict.trade.resultDelayed",{defaultValue:"Your trade was submitted successfully. Confirmation is taking a little longer."})}),jsxs("div",{className:"flex flex-col gap-2",children:[d!=="success"&&d!=="delayed"&&jsx(Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!B,isLoading:d==="pending"||d==="confirming",onPress:Q,spinner:jsx(Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&d!=="success"&&d!=="delayed"&&jsx("button",{type:"button",onClick:o,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),(d==="success"||d==="delayed")&&o&&jsx(Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:i("common.ok")})]})]})}function eo({label:e,value:t,valueClassName:r="text-white"}){return jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm text-zinc-400",children:e}),jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function qs(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var kp="predict-redeem";function Xs({id:e=kp}){return jsx(AsyncModal,{id:e,children:t=>jsx(Sp,{...t})})}function Sp({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsx("h3",{className:"text-lg font-semibold text-white",children:n("predict.redeem.title")}),jsx("p",{className:"text-sm text-zinc-400 mt-1",children:n("predict.redeem.description")})]}),jsx(Ys,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function ta({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:n=100,onSuccess:o}){let{t:i,i18n:a}=useTranslation(),s=useRef(o);s.current=o;let{status:l}=useAuth(),u=useWallets(),p=usePredictClient(),d=useContext(PolymarketContext),f=useQueryClient(),{start:c}=useTradeResultConfirmation(),m=e.source,g=m==="polymarket",v=u.find(E=>E.chainNamespace===ChainNamespace.SOLANA&&E.isConnected),h=u.find(E=>E.chainNamespace===ChainNamespace.EVM&&E.isConnected&&"switchChain"in E),x=l==="authenticated",k=v?.address,S=h?.address,[b,y]=useState(t),[N,M]=useState("market"),[C,_]=useState(NaN),[F,U]=useState(NaN),[Q,B]=useState(false),[Y,q]=useState(false),[te,P]=useState(null),[T,z]=useState(null),[J,ue]=useState(false),[ae,Ke]=useState(false),[Ee,w]=useState("1h"),[He,Je]=useState(30),[we,Ct]=useState("minutes"),Oe=useMemo(()=>Hr(i,a),[a,i]),Ve=useCallback(async(E,le)=>{let ye=zr({messages:Oe});ye.submitted(),await c({source:m,user:m==="kalshi"?k:S,kalshiUser:k,polymarketUser:S,marketSlug:e.slug,eventSlug:e.event_slug,expectation:E,getOrdersHeaders:le})==="confirmed"?ye.completed():ye.delayed();},[c,S,e.event_slug,e.slug,m,Oe,k]),st=useMemo(()=>{if(m!=="polymarket")return;let E=e.provider_meta?.["polymarket.clobTokenIds"];return E?(typeof E=="string"?JSON.parse(E):E)[b==="yes"?0:1]:void 0},[m,e.provider_meta,b]),{data:Pe,isLoading:Ze}=useTickSize(st),Le=Pe?.minimum_tick_size?String(Pe.minimum_tick_size):"0.01",{data:at,isLoading:_t}=useFeeRate(st),Mt=String(at?.base_fee??0),{data:Tt}=useRebateConfig(),et=Tt?.builder_enabled&&Tt.builder_code?Tt.builder_code:void 0,gt=false,ze=null,Gt=false,Re,je,ge;try{let E=xr();gt=E.kalshiKycVerified,ze=E.kalshiKycUrl,Gt=E.polymarketSetupVerified,Re=E.polymarketSafeAddress,je=E.polymarketWalletKind,ge=E.polymarketWalletAddress;}catch{}let lt=m==="kalshi"&&!gt,ht=m==="polymarket"&&!Gt,Ne=useCallback(async()=>{if(!h||!d)return null;let E=await h.getEip1193Provider();if(!E)return null;let le=je==="deposit"&&!!ge,ye=!le&&!!Re,Ye={address:h.address,signatureType:le?3:ye?2:0,signTypedData:async(rt,nt,Lt,_e)=>{let ir=[];"name"in rt&&ir.push({name:"name",type:"string"}),"version"in rt&&ir.push({name:"version",type:"string"}),"chainId"in rt&&ir.push({name:"chainId",type:"uint256"}),"verifyingContract"in rt&&ir.push({name:"verifyingContract",type:"address"}),"salt"in rt&&ir.push({name:"salt",type:"bytes32"});let _n={EIP712Domain:ir,...nt};return await E.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:rt,types:_n,primaryType:Lt,message:_e})]})}};return d.credentials??await d.authenticate(Ye)},[Re,je,ge,h,d]),{data:ut}=useRealtimeOrderbook({slug:e.slug,source:m,outcome:b},{enabled:e.status==="open"}),Ce=useMemo(()=>{let E=pickBestBid(ut,b);if(E!=null&&E>0)return E;let le=b==="yes"?0:1,ye=e.outcomes[le];return ye?.best_bid??ye?.price??.5},[ut,e.outcomes,b]),I=m==="kalshi"?k??"":S??"",{data:pe,isLoading:tt}=usePositionsMulti({kalshi_user:m==="kalshi"?I:void 0,polymarket_user:m==="polymarket"?I:void 0},{enabled:!!I,refetchInterval:3e4}),Xr=useCallback(async()=>{let E=await Ne();return E?await buildPolymarketL2Headers(E.address,{apiKey:E.apiKey,secret:E.secret,passphrase:E.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Ne]),{data:A,isLoading:Ge}=useAvailableShares({source:m,user:I,market:e.slug,side:b},m==="polymarket"?{getHeaders:Xr}:void 0,{enabled:!!I&&!!e.slug,refetchOnMount:"always"}),vt=e.provider_meta?.["dflow.yesMint"]??"",ur=e.provider_meta?.["dflow.noMint"]??"",Dt=SOLANA_TOKENS.stablecoins.USDC.address,Jr=e.provider_meta?.["dflow.collateralMint"]||"",Co=b==="yes"?vt:ur,Cn=(r||b).trim().toLowerCase(),Lr=useMemo(()=>pe?pe.positions.find(E=>E.side?.trim().toLowerCase()===Cn&&E.market?.slug===e.slug)??null:null,[pe,e.slug,Cn]),qe=useMemo(()=>m==="polymarket"?getPolymarketSharesPrecision(Le):A?.precision??0,[m,Le,A?.precision]),Rr=A?.active_order_shares??0,_r=m==="polymarket"&&!!r&&!!Lr?.size&&(A?.total_shares??0)<=0&&(A?.available_shares??0)<=0,Ft=_r?Lr?.size??0:0,Ir=_r?Ft:A?.total_shares??0,qt=_r?Math.max(0,Ft-Rr):A?.available_shares??0,Mn=Ge||tt,Tn=Lr?.market?.provider_meta,Mo=Tn?.["dflow.outcomeMint"]||Co,pr=Tn?.["dflow.collateralMint"]||Jr,Bt=Mo,Yt=pr||Dt,Or=useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),To=m==="kalshi"&&!!Bt&&!!Yt&&!!k&&Or!=="0",{refetch:Zr}=useDFlowQuote({inputMint:Bt,outputMint:Yt,amount:Or,userPublicKey:k??"",slippageBps:100},{enabled:To}),mr=useMemo(()=>isNaN(C)||C<=0?0:C,[C]),bt=useMemo(()=>walkOrderbook({orderbook:ut,outcome:b,side:"sell",sharesNeeded:mr,slippageBps:n}),[ut,b,mr,n]),fr=useMemo(()=>bt.status==="ok"&&bt.worstPrice!=null&&bt.worstPrice>0?bt.worstPrice:Ce,[bt,Ce]),gr=useMemo(()=>N==="limit"&&g&&!isNaN(F)?F:fr,[N,g,F,fr]),R=useMemo(()=>isNaN(C)||C<=0?0:C*gr,[C,gr]),Ae=useMemo(()=>m!=="polymarket"?0:Qi({grossReturn:R,pricePerShare:gr,feeRateBps:Number(Mt)}),[m,R,gr,Mt]),We=useMemo(()=>Math.max(0,R-Ae),[R,Ae]),Et=useCallback(E=>{y(E),U(NaN),_(NaN),q(false);},[]);useEffect(()=>{Et(t);},[t,Et]);let en=useCallback(E=>{M(E);},[]);useEffect(()=>{N==="limit"&&U(Math.round(Ce*1e4)/1e4);},[N,b]);let hr=useCallback(E=>{if(q(false),isNaN(E)){_(NaN);return}_(xe(Math.max(0,E),qe));},[qe]),Qt=useCallback(()=>{q(true),_(xe(qt,qe));},[qt,qe]),ct=useCallback(E=>{if(isNaN(E)){U(NaN);return}U(Math.round(E*1e4)/1e4);},[]),vr=useCallback(()=>{_(NaN),U(NaN),M("market"),q(false),Ke(false),w("1h"),Je(30),Ct("minutes");},[]),Ar=useMemo(()=>{let E=[];return isNaN(C)||C<=0?E.push(i("predict.trade.minQuantity",{amount:zn})):C<zn&&E.push(i("predict.trade.minQuantity",{amount:zn})),e.status!=="open"&&E.push(i("predict.trade.marketNotActive")),!isNaN(C)&&C>0&&!Y&&C>qt&&E.push(i("predict.trade.insufficientSharesDetail",{total:xe(Ir,qe).toFixed(qe),active:xe(Rr,qe).toFixed(qe),available:xe(qt,qe).toFixed(qe)})),N==="limit"&&g&&(isNaN(F)||F<.01||F>.99)&&E.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&ae&&Ee==="custom"&&(isNaN(He)||He<=0)&&E.push(i("predict.trade.expiration.invalidDate")),m==="polymarket"&&N==="market"&&!isNaN(C)&&C>0&&(bt.status==="insufficient_liquidity"?E.push(i("predict.trade.insufficientLiquidity",{available:xe(bt.totalAvailable,2)})):bt.status==="exceeds_slippage"&&E.push(i("predict.trade.priceImpactTooHigh",{impact:(bt.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:E.length===0,errors:E}},[C,e.status,qt,Ir,Rr,Y,N,g,F,ae,Ee,He,qe,m,bt,n,i]),{mutateAsync:Xt}=useDFlowSubmit(),{data:Dr}=useOrder({id:te??"",source:m},{enabled:!!te}),En=useCallback(async()=>{if(!T||!k||!v)return;let{cashAmount:E,collateral:le}=T;z(null);try{let Ye=(await p.createDFlowQuote({inputMint:le,outputMint:Dt,amount:E,userPublicKey:k,slippageBps:100}))?.transaction;if(!Ye)return;let rt=Uint8Array.from(atob(Ye),Lt=>Lt.charCodeAt(0)),nt=await v.signTransaction(rt);await Xt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:k,input_mint:le,output_mint:Dt,amount:E,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[T,k,v,p,Xt,Dt]),Jt=useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);useEffect(()=>{if(!Dr||!te)return;let{status:E}=Dr;E==="closed"?(P(null),T?En().finally(()=>{B(false),Ve("sell-market"),Jt(),vr(),s.current?.();}):(B(false),Ve("sell-market"),Jt(),vr(),s.current?.())):(E==="failed"||E==="expired")&&(B(false),P(null),z(null),toast.error(i("predict.trade.submitError")));},[Dr,te,T,En,Ve,Jt,vr,i]);let Ln=useCallback(async()=>{if(!k||!v)return;if(!Bt||!Yt){toast.error("Missing token mint addresses"),B(false);return}if(!gt){ue(true),B(false);return}let ye=(await Zr()).data,Ye=ye?.transaction;if(!Ye){toast.error(i("predict.trade.submitError")),B(false);return}if(pr&&pr!==Dt){let _e=String(ye?.outAmount??"");_e&&_e!=="0"&&z({cashAmount:_e,collateral:pr});}let rt=Uint8Array.from(atob(Ye),_e=>_e.charCodeAt(0)),nt=await v.signTransaction(rt),Lt=await Xt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:k,input_mint:Bt,output_mint:Yt,amount:Or,price:String(Ce),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});P(Lt.signature);},[k,v,Zr,Xt,Bt,Yt,Or,Ce,b,e.slug,pr,Dt,i,gt]),Rn=useCallback(async()=>{if(!h||!d)return;let E=h.chain,le=E!==Chain.POLYGON;le&&await h.switchChain(Chain.POLYGON);try{let ye=await h.getEip1193Provider();if(!ye){toast.error(i("predict.trade.submitError")),B(!1);return}let Ye=je==="deposit"&&!!ge,rt=!Ye&&!!Re,nt=Ye?ge:Re,Lt={address:h.address,signatureType:Ye?3:rt?2:0,signTypedData:async(Ht,On,Ro,_o)=>{let Fr=[];"name"in Ht&&Fr.push({name:"name",type:"string"}),"version"in Ht&&Fr.push({name:"version",type:"string"}),"chainId"in Ht&&Fr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ht&&Fr.push({name:"verifyingContract",type:"address"}),"salt"in Ht&&Fr.push({name:"salt",type:"bytes32"});let wc={EIP712Domain:Fr,...On};return await ye.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Ht,types:wc,primaryType:Ro,message:_o})]})}},_e=await Ne();if(!_e){toast.error(i("predict.trade.submitError")),B(!1);return}let ir=b==="yes"?0:1,_n="",In=e.provider_meta?.["polymarket.clobTokenIds"];In&&(_n=(typeof In=="string"?JSON.parse(In):In)[ir]??"");let Ai=e.provider_meta?.["polymarket.negRisk"]??!1,kc=N==="limit"&&!isNaN(F)?F:fr,Sc=$n(kc,Le),Eo={tokenId:_n,price:Sc,size:C,side:"SELL",orderType:N==="limit"?ae?"GTD":"GTC":"FOK",tickSize:Le,negRisk:Ai,...nt&&{funderAddress:nt},...et&&{builderCode:et},...N==="limit"&&ae&&{expiration:Un(Ee,He,we)}},Lo;if(Ye)Lo=await buildSignedV2OrderPayload({signer:Lt,depositWalletAddress:nt,input:Eo,owner:_e.apiKey});else {let Ht=buildCtfExchangeDomain(Ai),On=buildOrderMessage({...Eo,signerAddress:Lt.address,signatureType:Lt.signatureType,feeRateBps:Mt}),Ro=await Lt.signTypedData(Ht,CTF_ORDER_TYPES,"Order",On),_o=buildSignedOrder(On,Ro,Eo.orderType);Lo=buildClobPayload(_o,_e.apiKey);}await p.executePolymarketOrder({payload:Lo,l2_api_key:_e.apiKey,l2_secret:_e.secret,l2_passphrase:_e.passphrase,signer_address:_e.address,owner:_e.apiKey}),Jt(),Ve(N==="limit"?"sell-limit":"sell-market",async()=>await buildPolymarketL2Headers(_e.address,{apiKey:_e.apiKey,secret:_e.secret,passphrase:_e.passphrase,method:"GET",requestPath:"/data/orders"})),vr(),B(!1),s.current?.();}finally{le&&E&&h.switchChain(E).catch(()=>{});}},[h,d,Ne,b,e.provider_meta,N,Ve,F,fr,C,p,Jt,ae,Ee,He,we,vr,i,Le,Mt,e.slug,Re,je,ge,et]),tn=useCallback(async()=>{if(!(!Ar.isValid||!x)){B(true),P(null),ue(false);try{m==="kalshi"?await Ln():await Rn();}catch(E){let le=E instanceof Error?E.message:"",ye=m==="polymarket"&&le?Kn(le,i,"sell"):le||void 0;toast.error(ye||i("predict.trade.submitError")),B(false);}}},[Ar.isValid,x,m,Ln,Rn,i]);return {outcome:b,orderType:N,quantity:C,limitPrice:F,shares:mr,effectivePrice:gr,grossReturn:R,estimatedFee:Ae,estimatedReturn:We,pricePerShare:Ce,isMarketDataLoading:m==="polymarket"&&(_t||Ze),isSubmitting:Q,authStatus:l,validation:Ar,supportsLimitOrder:g,kycRequired:J,needsKyc:lt,needsSetup:ht,kycUrl:ze,totalShares:Ir,activeOrderShares:Rr,availableShares:qt,isAvailableLoading:Mn,isSellAll:Y,precision:qe,expirationEnabled:ae,expirationPreset:Ee,customDuration:He,customDurationUnit:we,setOutcome:Et,setOrderType:en,setQuantity:hr,setLimitPrice:ct,setSellAll:Qt,setExpirationEnabled:Ke,setExpirationPreset:w,setCustomDuration:Je,setCustomDurationUnit:Ct,submit:tn}}var sm=["5m","1h","12h","24h","eod","custom"],am={"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"},lm=["minutes","hours","days"],cm={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},dm={maximumFractionDigits:0},dn="-";function da({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,effectivePrice:s,grossReturn:l,estimatedFee:u,estimatedReturn:p,isMarketDataLoading:d,isSubmitting:f,authStatus:c,isValid:m,validationErrors:g,supportsLimitOrder:v,kycRequired:h,needsKyc:x,needsSetup:k,onSetupRequired:S,kycUrl:b,totalShares:y,activeOrderShares:N,availableShares:M,isAvailableLoading:C,precision:_,expirationEnabled:F,expirationPreset:U,customDuration:Q,customDurationUnit:B,oddsFormatter:Y,onOutcomeChange:q,onOrderTypeChange:te,onQuantityChange:P,onLimitPriceChange:T,onSellAll:z,onExpirationEnabledChange:J,onExpirationPresetChange:ue,onCustomDurationChange:ae,onCustomDurationUnitChange:Ke,onSubmit:Ee}){let{t:w}=useTranslation(),[He,Je]=useState(false),[we,Ct]=useState(true),Oe=useDisclosure(),[Ve,st]=useState(""),Pe=useRef(false);useEffect(()=>{Pe.current||st(isNaN(i)?"":String(i));},[i]);let[Ze,Le]=useState(""),at=useRef(false);useEffect(()=>{at.current||(isNaN(a)?Le(""):Le(String(parseFloat((a*100).toFixed(2)))));},[a]);let _t=useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(Le(I),I===""||I==="."){T(NaN);return}let tt=parseFloat(I);isNaN(tt)||T(tt/100);},[T]),Mt=useCallback(I=>{let pe=new RegExp(`^\\d*\\.?\\d{0,${_}}$`);if(I!==""&&!pe.test(I))return;if(st(I),Je(false),I===""||I==="."){P(NaN);return}let tt=parseFloat(I);isNaN(tt)||P(tt);},[P,_]);useEffect(()=>{h&&!Oe.isOpen&&Oe.onOpen();},[h]);let Tt=useMemo(()=>{let I=n==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[n,t]),et=n==="yes"?t.yesBid:t.noBid,gt=et!=null&&Y?Y(Number(et)):Tt!=null?`${Tt} \xA2`:null,ze=Number.isFinite(s)?parseFloat((s*100).toFixed(2)):null,Gt=Number.isFinite(s)&&Y?Y(s):ze!=null?`${ze} \xA2`:null,Re=!isNaN(i)&&i>0,je=Re&&i>0?p/i:0,ge=je>0&&Y?Y(je):je>0?`${parseFloat((je*100).toFixed(2))} \xA2`:dn,lt=c==="authenticated",ht=c==="authenticating"||c==="deauthenticating",Ne=lt&&(x||k),ut=useMemo(()=>{if(ht)return w("predict.trade.checkingLogin");if(!lt)return w("predict.trade.loginToTrade");if(x)return w("predict.trade.kycRequired");if(k)return w("predict.trade.setupRequired");if(C)return w("predict.trade.loadingBalance");if(d)return w("predict.trade.loadingMarketData");if(f)return w("predict.trade.submitting");if(h)return w("predict.trade.kycRequired");if(!Re)return w("predict.trade.enterAmount");let I=w(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${w("predict.trade.sell")} ${I}`},[ht,lt,x,k,C,d,f,h,Re,n,w]),Ce=()=>{if(!lt){Je(false),Ee();return}if(x){Oe.onOpen();return}if(k&&S){Je(false),S();return}if(h){Oe.onOpen();return}if(!m){Je(true);return}Je(false),Ee();};return jsxs(Fragment,{children:[jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:"text-bearish",children:[w("predict.trade.sell")," ",w(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:I=>te(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:w("predict.trade.market")},"market"),jsx(Tab,{title:w("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&v?jsx(StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ze,onChange:I=>_t(I.target.value),onFocus:()=>{at.current=true;},onBlur:()=>{at.current=false,isNaN(a)?Le(""):Le(String(parseFloat((a*100).toFixed(2))));},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):gt!=null&&jsx("span",{className:"text-xl font-bold tabular-nums",children:gt})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let pe=I==="yes"?t.yesBid:t.noBid;return jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxs("button",{type:"button",onClick:()=>q(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===I?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsx("span",{children:w(I==="yes"?"predict.trade.yes":"predict.trade.no")}),pe!=null&&jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(pe)):`${parseFloat((Number(pe)*100).toFixed(2))}\xA2`})]})},I)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.sellContracts")}),jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let pe=Math.pow(10,_);return jsxs("button",{type:"button",onClick:()=>{P(Math.floor(M*I/100*pe)/pe);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[I,"%"]},I)}),jsx("button",{type:"button",onClick:z,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("common.all")})]})]}),jsx(StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ve,onChange:I=>Mt(I.target.value),onFocus:()=>{Pe.current=true;},onBlur:()=>{Pe.current=false,st(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"}}),He&&g.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(I=>jsx("span",{className:"text-xs text-danger",children:I},I))})]}),jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalShares")}),jsx("span",{className:"tabular-nums text-foreground",children:C?"\u2013":`${xe(y,_).toFixed(_)}${w("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.activeOrders")}),jsx("span",{className:"tabular-nums text-warning",children:C?"\u2013":N>0?`-${xe(N,_).toFixed(_)}${w("predict.trade.sharesUnit")}`:`0${w("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.availableShares")}),jsx("span",{className:"tabular-nums text-success font-medium",children:C?"\u2013":`${xe(M,_).toFixed(_)}${w("predict.trade.sharesUnit")}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estReturn")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:"\u2013"})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>Ct(I=>!I),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:w("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn("h-3.5 w-3.5 transition-transform",we&&"rotate-180")})]}),jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Number.isFinite(s)?Gt:ze!=null?w("predict.trade.chance",{percent:ze}):dn})]}),we&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.numContracts")}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?yr(i):dn})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.totalSize")}),jsx("span",{className:"tabular-nums text-foreground",children:Re?`$${l.toFixed(2)}`:dn})]}),(u??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estFee")}),jsx("span",{className:"tabular-nums text-foreground",children:`$${(u??0).toFixed(2)}`})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.estReturnAfterFees")}),jsx("span",{className:"tabular-nums text-foreground",children:Re?`$${p.toFixed(2)}`:dn})]}),(u??0)>0&&jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:w("predict.trade.effectiveOdds")}),jsx("span",{className:"tabular-nums text-foreground",children:ge})]})]})]}),o==="limit"&&v&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:w("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:F,onValueChange:J,"aria-label":w("predict.trade.setExpiration")})]}),F&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[U],onSelectionChange:I=>{let pe=Array.from(I)[0];pe&&ue(pe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:sm.map(I=>jsx(SelectItem,{children:w(am[I])},I))}),U==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(Q)?void 0:Q,onValueChange:ae,minValue:1,step:1,formatOptions:dm,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[B],onSelectionChange:I=>{let pe=Array.from(I)[0];pe&&Ke(pe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:lm.map(I=>jsx(SelectItem,{children:w(cm[I])},I))})]})]})]}),jsx(Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:ht||lt&&!Ne&&(C||d||!Re||f),isLoading:ht||lt&&!Ne&&(f||C||d),spinner:jsx(Spinner,{size:"sm",color:"current"}),onPress:Ce,children:ut})]}),jsx(jn,{isOpen:Oe.isOpen,onClose:Oe.onClose,kycUrl:b})]})}function no({event:e,market:t,variant:r,initialOutcome:n,initialPositionSide:o,chain:i,slippageBps:a,onOutcomeChange:s,onSetupRequired:l,onSuccess:u,oddsFormatter:p}){let{outcome:d,orderType:f,quantity:c,limitPrice:m,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,pricePerShare:k,isMarketDataLoading:S,isSubmitting:b,authStatus:y,validation:N,supportsLimitOrder:M,kycRequired:C,needsKyc:_,needsSetup:F,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:P,expirationPreset:T,customDuration:z,customDurationUnit:J,setOutcome:ue,setOrderType:ae,setQuantity:Ke,setLimitPrice:Ee,setSellAll:w,setExpirationEnabled:He,setExpirationPreset:Je,setCustomDuration:we,setCustomDurationUnit:Ct,submit:Oe}=ta({market:t,initialOutcome:n,initialPositionSide:o,slippageBps:a,onSuccess:u}),Ve=useAuthCallback(Oe),st=useCallback(Le=>{ue(Le),s?.(Le);},[ue,s]),Pe=useMemo(()=>e?Dn(e):void 0,[e]),Ze=useMemo(()=>Fn(t,{yesBid:d==="yes"?k:void 0,noBid:d==="no"?k:void 0}),[t,d,k]);return jsx(da,{event:Pe,market:Ze,variant:r,outcome:d,orderType:f,quantity:c,limitPrice:m,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,isMarketDataLoading:S,isSubmitting:b,authStatus:y,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:M,kycRequired:C,needsKyc:_,needsSetup:F,onSetupRequired:l,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:P,expirationPreset:T,customDuration:z,customDurationUnit:J,oddsFormatter:p,onOutcomeChange:st,onOrderTypeChange:ae,onQuantityChange:Ke,onLimitPriceChange:Ee,onSellAll:w,onExpirationEnabledChange:He,onExpirationPresetChange:Je,onCustomDurationChange:we,onCustomDurationUnitChange:Ct,onSubmit:Ve})}var Zo="predict-sell";function pa({id:e=Zo}){return jsx(AsyncModal,{id:e,children:t=>jsx(xm,{...t})})}function xm({params:e,isOpen:t,onOpenChange:r}){let{t:n}=useTranslation(),{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{className:o?"":"p-2",children:[jsx(no,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialPositionSide:e.initialPositionSide,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),jsx("div",{className:"px-4 pb-4",children:jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var ri=40,so=36,mn=480,ni=mn-so;function ga({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=useTranslation(),[o,i]=useState("positions"),a=useMemo(()=>e.markets?.map(d=>d.slug)??[],[e.markets]),{data:s}=usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=useMemo(()=>!s?.positions||!t?0:a.length===0?s.positions.length:s.positions.filter(d=>d.market&&a.includes(d.market.slug)).length,[s?.positions,a,t]),p=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:p.map(d=>jsx("button",{type:"button",onClick:()=>i(d.key),className:cn("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:mn},children:[o==="positions"&&jsx(Cm,{source:e.source,walletAddress:t,marketSlugs:a}),o==="orders"&&jsx(Tm,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),o==="trades"&&jsx(Rm,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:n("predict.trade.connectWallet")})]})}function Cm({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=useTranslation(),{data:o,isLoading:i}=usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),a=useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[o?.positions,r]);return i?jsx(ii,{}):a.length===0?jsx(oi,{message:n("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:so},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:ni},rowComponent:Mm,rowCount:a.length,rowHeight:ri,rowProps:{positions:a,closeLabel:n("predict.positions.close")}})]})}function Mm({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,a=o.pnl_percent??0,s=o.avg_price??0,l=o.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",p=i>0?"+":"",d=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,c=o.size,m=o.size*l,g=o.market?.end_at?Om(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("text-[10px] font-medium",f.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:f})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",m.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:oo(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:oo(l)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[p,"$",Math.abs(i).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,a.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:n})})]})}function Tm({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=useTranslation(),{data:i,isLoading:a,fetchNextPage:s,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),u=useCancelOrder(),p=useMemo(()=>{let h=i?.pages?.flatMap(S=>S.items)??[],x=new Set(["live","open","submitted","pending"]),k=h.filter(S=>x.has(S.status));return r.length>0&&(k=k.filter(S=>S.market_id&&r.includes(S.market_id))),k},[i?.pages,r]),d=useCallback(h=>{n?n(h.id):u.mutate({source:h.source,id:h.id});},[n,u]),f=p.length,c=f+(l?1:0),m=useCallback(h=>h<f,[f]),g=useCallback(async()=>{await s();},[s]),v=useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:c,threshold:5});return a?jsx(ii,{}):p.length===0&&!l?jsx(oi,{message:o("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:so},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:ni},onRowsRendered:v,rowComponent:Em,rowCount:c,rowHeight:ri,rowProps:{orders:p,itemCount:f,onCancel:d,isCancelling:u.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Em({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:a}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:s.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?oo(parseFloat(s.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Lm,{status:s.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>o(s),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsx(Spinner,{size:"sm"}):a})})]})}function Lm({status:e}){return jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function Rm({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:a}=useInfiniteTrades({source:e,wallet:t,limit:50}),s=useMemo(()=>n?.pages?.flatMap(c=>c.items)??[],[n?.pages]),l=s.length,u=l+(a?1:0),p=useCallback(c=>c<l,[l]),d=useCallback(async()=>{await i();},[i]),f=useInfiniteLoader({isRowLoaded:p,loadMoreRows:d,rowCount:u,threshold:5});return o?jsx(ii,{}):s.length===0&&!a?jsx(oi,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:so},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:ni},onRowsRendered:f,rowComponent:_m,rowCount:u,rowHeight:ri,rowProps:{trades:s,itemCount:l}})]})}function _m({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",a=Im(o.timestamp),s=o.price??0,l=o.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:o.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:o.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:oo(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:a})]})}function oi({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:e})}function ii(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:mn},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function oo(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Im(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 Om(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var ha=`
|
|
75
75
|
@keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
76
|
-
`,da={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 me(e){return {...da,animationDelay:`${e}ms`}}function nn({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:ca}),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:{...da,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:{...me(0),height:14,width:48}}),jsx("div",{style:{...me(30),height:14,width:40}}),jsx("div",{style:{...me(60),height:14,width:40}})]}),jsx("div",{style:{...me(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...me(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:{...me(120),height:16,width:96}}),jsx("div",{style:{...me(140),height:16,width:80}})]}),jsx("div",{style:{...me(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...me(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...me(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...me(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:{...me(240),height:14,width:56}})}),Array.from({length:e}).map((r,o)=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("div",{style:{...me(260+o*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsx("div",{style:{...me(280+o*40),height:14,width:o%2===0?192:160}}),jsx("div",{style:{...me(300+o*40),height:10,width:64}})]}),jsx("div",{style:{...me(320+o*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...me(340+o*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...me(360+o*40),height:32,width:80,borderRadius:8}})]})]},o))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...me(400),height:16,width:64}}),jsx("div",{style:{...me(420),height:14,width:"100%"}}),jsx("div",{style:{...me(440),height:14,width:"80%"}}),jsx("div",{style:{...me(460),height:14,width:"60%"}})]})]})]})}function ua(){return jsxs(Fragment,{children:[jsx("style",{children:ca}),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:{...me(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...me(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...me(120),height:40,width:"100%",borderRadius:8}})]})]})}var ha="var(--color-bullish)",va="var(--color-bearish)";function on(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 Cm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Mm(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let l of e){let m=Math.round(l.price*100);m>=0&&m<=100&&(r[m]+=l.quantity);}for(let l of t){let m=Math.round(l.price*100);m>=0&&m<=100&&(o[m]+=l.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let l=100;l>=0;l--)n+=r[l],i+=r[l]*l/100,s[l]=n,a[l]=i;let c=0,u=0,p=new Float64Array(101),d=new Float64Array(101);for(let l=0;l<=100;l++)c+=o[l],u+=o[l]*l/100,p[l]=c,d[l]=u;let f=Math.max(s[0]??0,p[100]??0);return Array.from({length:101},(l,m)=>{let g=s[m]>0,h=p[m]>0,v=s[m]||p[m],b=r[m]>0||o[m]>0;return {priceCents:m,displayHeight:Cm(v,f),opacity:v>0?b?1:.5:0,isBid:g,isAsk:h,bidCumTotal:s[m],askCumTotal:p[m],bidCumCost:a[m],askCumCost:d[m]}})}function Tm({info:e}){let{t}=useTranslation(),r=e.isBid?ha:va,o=e.leftPct>65?void 0:`${e.leftPct}%`,n=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:o,right:n,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:on(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",on(Math.round(e.cumCost))]})]})}var Em=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),i=t.isBid||t.isAsk,s=t.isBid?ha:t.isAsk?va:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:i&&jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),Lm=[0,10,20,30,40,50,60,70,80,90,100];function Rm(){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:Lm.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 ba({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>Mm(e,t),[e,t]),n=useMemo(()=>{let d=e.length>0?Math.max(...e.map(l=>l.price)):0,f=t.length>0?Math.min(...t.map(l=>l.price)):1;return Math.round((d+f)/2*100)},[e,t]),i=useMemo(()=>o.some(d=>d.isBid||d.isAsk),[o]),[s,a]=useState(null),c=useRef(null),u=useCallback((d,f)=>{c.current&&(c.current.style.filter=""),f?(f.style.filter="brightness(1.5)",c.current=f):c.current=null,d.isBid||d.isAsk?a({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):a(null);},[]),p=useCallback(()=>{c.current&&(c.current.style.filter="",c.current=null),a(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[n>0&&jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsx(Tm,{info:s}),o.map(d=>jsx(Em,{slot:d,onEnter:u,onLeave:p},d.priceCents))]}),jsx(Rm,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Pa(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function ya(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function Na({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:o="depth",className:n,oddsFormatter:i}){let{t:s}=useTranslation(),[a,c]=useState(o),u=i??Pa,p=e.source,{data:d,isLoading:f,isFetching:l,refetch:m}=useRealtimeOrderbook({slug:e.slug,source:p,outcome:t}),g=useMemo(()=>(d?.bids??[]).map(k=>({price:k.price,quantity:k.size})),[d?.bids]),h=useMemo(()=>(d?.asks??[]).map(k=>({price:k.price,quantity:k.size})),[d?.asks]),v=useMemo(()=>g.length>0?Math.max(...g.map(k=>k.price)):null,[g]),b=useMemo(()=>h.length>0?Math.min(...h.map(k=>k.price)):null,[h]),N=useMemo(()=>{if(v==null||b==null)return null;let k=(b-v)*100;return Math.round(k*10)/10},[v,b]);return jsxs("div",{className:cn("flex flex-col",n??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:N!=null?`${s("predict.orderBook.spread")}: ${Number.isInteger(N)?`${N}\xA2`:`${N.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[v!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[s("predict.trade.bestBid"),": ",u(v)]}),v!=null&&b!=null&&jsx("span",{className:"text-neutral",children:"|"}),b!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[s("predict.trade.bestAsk"),": ",u(b)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:a==="depth"?"Orderbook":"Depth chart",onClick:()=>c(k=>k==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:a==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>m(),disabled:l,className:cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",l&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[a==="depth"&&jsx(Fragment,{children:f?jsx(ya,{}):jsx(ba,{bids:g,asks:h})}),a==="table"&&jsx(Fragment,{children:f?jsx(ya,{}):jsx(Fm,{bids:g,asks:h,bestBid:v??void 0,bestAsk:b??void 0,spread:N??void 0,oddsFormatter:i})})]})]})}var ti=4,Am=8;function Fm({bids:e,asks:t,spread:r,oddsFormatter:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=i?Am:ti,c=t.length>ti||e.length>ti,u=useMemo(()=>[...t].sort((l,m)=>l.price-m.price).slice(0,a).reverse(),[t,a]),p=useMemo(()=>[...e].sort((l,m)=>m.price-l.price).slice(0,a),[e,a]),d=useMemo(()=>{let l=[...u,...p].map(m=>m.quantity);return Math.max(...l,1)},[u,p]);return u.length===0&&p.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:[u.map(l=>jsx(ka,{price:l.price,quantity:l.quantity,side:"ask",maxQty:d,oddsFormatter:o},`ask-${l.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),c&&jsx("button",{type:"button",onClick:()=>s(l=>!l),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:n(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),p.map(l=>jsx(ka,{price:l.price,quantity:l.quantity,side:"bid",maxQty:d,oddsFormatter:o},`bid-${l.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:n("predict.orderBook.price")}),jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function ka({price:e,quantity:t,side:r,maxQty:o,oddsFormatter:n}){let i=r==="ask",s=Math.min(t/o*100,100),a=i?"bg-bearish/10":"bg-bullish/10",c=i?"text-bearish":"text-bullish",u=on(Math.round(t)),p=Math.round(t*e),d=`$${on(p)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsx("span",{className:`relative z-10 ${c}`,children:n?n(e):Pa(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsx("span",{className:"relative z-10 text-foreground text-right",children:d})]})}var oi=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}},sn=4,Ca=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Ym(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Qm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===le.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ta(e){return `${(e*100).toFixed(2)}%`}var Xm=[{range:le.ONE_DAY,label:"1D"},{range:le.ONE_WEEK,label:"1W"},{range:le.ONE_MONTH,label:"1M"},{range:le.ALL,label:"ALL"}];function Jm({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Xm.map(({range:r,label:o})=>{let n=r===e;return jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function Zm(){let e=useRef(null),t=useRef(null),r=useCallback(n=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),c=(n.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${c}%, rgba(0,0,0,0.55) ${c}%)`,s.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function ef({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:i}){if(!e||!n?.length)return null;let s=new Map;t?.forEach(c=>s.set(c.dataKey,c));let a=n.map(c=>s.get(c.slug)??{dataKey:c.slug,value:void 0,stroke:c.color,color:c.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"?Qm(r,i):r}),a.map(c=>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:c.stroke??c.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(c.dataKey)??c.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:c.value!=null?Ta(c.value):"--"})]},c.dataKey))]})}function tf({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,i]=useState(false),s=useRef(null);useEffect(()=>{if(!n)return;function u(p){s.current&&!s.current.contains(p.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n]);let a=t.length>=sn,c=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(p=>p.slug===t[0]);return u?.outcomes?.[0]?.label??u?.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(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[c,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",sn," markets"]}),e.map((u,p)=>{let d=t.includes(u.slug),f=!d&&a,l=d&&t.length===1,m=r.get(u.slug)??"#6b7280",g=u.outcomes.find(v=>v.label.toLowerCase()==="yes")??u.outcomes[0],h=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{l||f||o(u.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:f||l?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!f&&!l&&(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 ${m}`:"2px solid rgba(255,255,255,0.2)",background:d?`${m}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:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),h&&jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},u.id??`${p}-${u.slug}`)})]})]})}function rf({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",i=r.get(o.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Ta(i):"--"})]})]},o.marketSlug)})})}function nf(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function of(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let i=Math.floor(n*o),s=Math.min(Math.floor((n+1)*o),e.length),a=e.slice(i,s),c=a.map(u=>u.price).sort((u,p)=>u-p);r.push({timestamp:a[a.length-1].timestamp,price:nf(c)});}return r}function sf(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:of(a.data,t)})),o=new Set;r.forEach(a=>a.data.forEach(c=>o.add(c.timestamp)));let n=Array.from(o).sort((a,c)=>a-c),i=r.map(a=>{let c=new Map;return a.data.forEach(u=>c.set(u.timestamp,u.price)),{slug:a.marketSlug,map:c}}),s=new Map;return n.map(a=>{let c={timestamp:a};return i.forEach(({slug:u,map:p})=>{let d=p.get(a);if(d!==void 0)s.set(u,d),c[u]=d;else {let f=s.get(u);f!==void 0&&(c[u]=f);}}),c})}function Ea(e){return jsx(oi,{children:jsx(af,{...e})})}function af({event:e,isLoading:t,className:r,volume:o,fillHeight:n=false}){let i=useMemo(()=>{let w=new Set;return (e.markets??[]).filter(M=>w.has(M.slug)?false:(w.add(M.slug),true))},[e.markets]),s=useMemo(()=>[...i].sort((w,M)=>{let $=J=>(J.outcomes.find(ne=>ne.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return $(M)-$(w)}),[i]),[a,c]=useState(()=>s.slice(0,sn).map(w=>w.slug));useEffect(()=>{let w=new Set(i.map(M=>M.slug));c(M=>{let $=M.filter(J=>w.has(J));return $.length===M.length?M:$.length>0?$:s.slice(0,sn).map(J=>J.slug)});},[i,s]);let[u,p]=useState(En),d=useMemo(()=>{let w=new Map;return a.forEach((M,$)=>{w.set(M,Ca[$%Ca.length]);}),w},[a]),f=useMemo(()=>i.filter(w=>a.includes(w.slug)),[i,a]),{series:l,isLoading:m}=useMarketHistory(f,u),g=t||m,h=useMemo(()=>{if(l.length>0&&l.some($=>$.data.length>0))return l;let w=Date.now(),M=864e5;return f.map($=>{let ne=($.outcomes?.find(O=>O.label.toLowerCase()==="yes")??$.outcomes?.[0])?.price??.5;return {marketSlug:$.slug,label:$.outcomes?.[0]?.label??$.question,data:[{timestamp:w-7*M,price:ne},{timestamp:w,price:ne}]}})},[l,f]),v=useMemo(()=>u===le.ONE_DAY?96:u===le.ONE_WEEK?168:u===le.ONE_MONTH?180:300,[u]),b=useMemo(()=>sf(h,v),[h,v]),N=useMemo(()=>{if(b.length===0)return [0,1];let w=1/0,M=-1/0;if(a.forEach(J=>{b.forEach(ne=>{let O=ne[J];O!=null&&(O<w&&(w=O),O>M&&(M=O));});}),!isFinite(w))return [0,1];let $=Math.max((M-w)*.15,.05);return [Math.max(0,w-$),Math.min(1,M+$)]},[b,a]),k=useMemo(()=>{let w=new Map;return h.forEach(M=>{M.data.length>0&&w.set(M.marketSlug,M.data[M.data.length-1].price);}),w},[h]),x=useMemo(()=>{let w=new Map;return h.forEach(M=>w.set(M.marketSlug,M.label)),w},[h]),y=useMemo(()=>h.map(w=>({slug:w.marketSlug,color:d.get(w.marketSlug)??"#6b7280"})),[h,d]),{wrapperRef:P,overlayRef:S,onMouseMove:R,onMouseLeave:I}=Zm(),z=useCallback(w=>{c(M=>M.includes(w)?M.length<=1?M:M.filter($=>$!==w):M.length>=sn?M:[...M,w]);},[]),[K,W]=useState(null),G=useRef(null),Y=useRef(""),Q=useRef(0),re=!g&&b.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...n?{height:"100%",minHeight:0}:null},children:[jsx(rf,{series:h,colorMap:d,displayValues:K??k}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...n?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:P,style:{width:"100%",userSelect:"none",position:"relative",...n?{flex:1,minHeight:240}:{height:300}},onMouseMove:re?w=>{R(w),cancelAnimationFrame(Q.current),Q.current=requestAnimationFrame(()=>{W(G.current);});}:void 0,onMouseLeave:re?()=>{I(),cancelAnimationFrame(Q.current),Y.current="",G.current=null,W(null);}:void 0,children:g?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):b.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:S,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:b,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:w=>Ym(w,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:N,tickFormatter:w=>`${Math.round(w*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:w=>{let M=w;if(M.active&&M.payload?.length){let $=M.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if($!==Y.current){Y.current=$;let J=new Map;M.payload.forEach(ne=>{ne.value!=null&&J.set(ne.dataKey,ne.value);}),G.current=J;}}return jsx(ef,{...M,labelMap:x,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),h.map(w=>{let M=d.get(w.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:w.marketSlug,stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:M},connectNulls:true,isAnimationActive:false},w.marketSlug)}),K==null&&b.length>0&&h.map(w=>{let M=b[b.length-1],$=M[w.marketSlug];if($==null)return null;let J=d.get(w.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:M.timestamp,y:$,ifOverflow:"extendDomain",shape:ne=>{let{cx:O,cy:Se}=ne;return O==null||Se==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:O,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:O,cy:Se,r:3.5,fill:J})]})}},`pulse-${w.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[o!=null&&o>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(o)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(Jm,{value:u,onChange:p}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(tf,{markets:s,selectedSlugs:a,colorMap:d,onToggle:z})})]})]})]})}function Jn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ra(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function wf(e){return `${parseFloat((e*100).toFixed(2))}%`}function _a(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Zn(e){return e.outcomes?.[0]?.label??e.question}function Pf(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function an(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${i}:${s}`}function Ia(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let p=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(p)},[e]),!e||t===0)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let i=Math.floor(n/864e5),s=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4),c=Math.floor(n%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(s).padStart(2,"0")}h`),u.push(`${String(a).padStart(2,"0")}m`),u.push(`${String(c).padStart(2,"0")}s`),u.join(" ")}function Oa(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),c=a>=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${c}${u})`}function Ba({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:o,isCollapsed:n}=useScrollCollapse(),i=useMemo(()=>{let d=[...e.markets||[]],f=d.filter(m=>m.status==="open").sort((m,g)=>Jn(g)-Jn(m)),l=d.filter(m=>m.status!=="open").sort((m,g)=>Jn(g)-Jn(m));return [...f,...l]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=Ia(s?void 0:e.start_at),c=Ia(s?void 0:e.end_at),u=Oa(e.start_at),p=Oa(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((d,f)=>jsxs(Fragment$1,{children:[f>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:d.label})]},d.slug)),jsx(Tf,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||c||s)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?p&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:p})}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):c?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:c})}),p&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:p})]})]}):null}),jsx(Ea,{event:e,volume:e.volume??void 0}),jsx(Nf,{markets:i,onTradeAction:t}),jsx(Mf,{markets:i,event:e})]})}var Da=5;function Nf({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:o}=useScreen(),[n,i]=useState(false),[s,a]=useState(null),c=useMemo(()=>{let h=new Set;return e.filter(v=>h.has(v.slug)?false:(h.add(v.slug),true))},[e]),u=c.find(h=>h.status==="open")?.slug,[p,d]=useState(u?`${u}:yes`:null);if(c.length===0)return null;let f=c.length>Da,l=n?c:c.slice(0,Da),m=h=>{a(v=>v===h?null:h);},g=(h,v,b)=>{d(`${h.slug}:${v}`),o&&a(h.slug),t?.(h,v,b);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:l.map((h,v)=>{let b=s===h.slug;return jsx(Cf,{market:h,activeYes:p===`${h.slug}:yes`,activeNo:p===`${h.slug}:no`,isExpanded:b,onToggleExpand:()=>m(h.slug),onTradeAction:g},h.id??`${v}-${h.slug}`)})})]}),f&&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(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",n&&"rotate-180")})]})]})}function Cf({market:e,activeYes:t,activeNo:r,isExpanded:o,onToggleExpand:n,onTradeAction:i}){let{t:s}=useTranslation(),a=e.status==="open",c=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:a}),{data:p}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),d=pickBestAsk(u,"yes")??Ra(e,"yes")??0,f=pickBestAsk(p,"no")??Ra(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:n,role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),n());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:Zn(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:Zn(e)}),c&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:c})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:wf(d)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:l=>{l.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:_a(d)})}),jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:l=>{l.stopPropagation(),i?.(e,"no","buy");},children:f!=null?s("predict.market.action.no",{price:_a(f)}):s("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),o&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(Na,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Mf({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[i,s]=useState(false),[a,c]=useState(0),u=e.filter(l=>l.rules&&l.rules.length>0||l.description);if(u.length===0)return null;let p=u[a]??u[0],d=p.rules&&p.rules.length>0?p.rules.join(`
|
|
76
|
+
`,va={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function he(e){return {...va,animationDelay:`${e}ms`}}function fn({marketCount:e=4,showBack:t}){return jsxs(Fragment,{children:[jsx("style",{children:ha}),jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:20},children:[t&&jsx("div",{style:{height:20}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsx("div",{style:{...va,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...he(0),height:14,width:48}}),jsx("div",{style:{...he(30),height:14,width:40}}),jsx("div",{style:{...he(60),height:14,width:40}})]}),jsx("div",{style:{...he(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsx("div",{style:{...he(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:{...he(120),height:16,width:96}}),jsx("div",{style:{...he(140),height:16,width:80}})]}),jsx("div",{style:{...he(160),height:300,width:"100%",borderRadius:12}}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("div",{style:{...he(180),height:16,width:80}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...he(200),height:28,width:200,borderRadius:8}}),jsx("div",{style:{...he(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:{...he(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:{...he(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:{...he(280+n*40),height:14,width:n%2===0?192:160}}),jsx("div",{style:{...he(300+n*40),height:10,width:64}})]}),jsx("div",{style:{...he(320+n*40),height:16,width:40}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsx("div",{style:{...he(340+n*40),height:32,width:80,borderRadius:8}}),jsx("div",{style:{...he(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...he(400),height:16,width:64}}),jsx("div",{style:{...he(420),height:14,width:"100%"}}),jsx("div",{style:{...he(440),height:14,width:"80%"}}),jsx("div",{style:{...he(460),height:14,width:"60%"}})]})]})]})}function ba(){return jsxs(Fragment,{children:[jsx("style",{children:ha}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsx("div",{style:{...he(0),height:40,width:"100%",borderRadius:8}}),jsx("div",{style:{...he(60),height:96,width:"100%",borderRadius:8}}),jsx("div",{style:{...he(120),height:40,width:"100%",borderRadius:8}})]})]})}var wa="var(--color-bullish)",Pa="var(--color-bearish)";function gn(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Fm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Bm(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let c of e){let m=Math.round(c.price*100);m>=0&&m<=100&&(r[m]+=c.quantity);}for(let c of t){let m=Math.round(c.price*100);m>=0&&m<=100&&(n[m]+=c.quantity);}let o=0,i=0,a=new Float64Array(101),s=new Float64Array(101);for(let c=100;c>=0;c--)o+=r[c],i+=r[c]*c/100,a[c]=o,s[c]=i;let l=0,u=0,p=new Float64Array(101),d=new Float64Array(101);for(let c=0;c<=100;c++)l+=n[c],u+=n[c]*c/100,p[c]=l,d[c]=u;let f=Math.max(a[0]??0,p[100]??0);return Array.from({length:101},(c,m)=>{let g=a[m]>0,v=p[m]>0,h=a[m]||p[m],x=r[m]>0||n[m]>0;return {priceCents:m,displayHeight:Fm(h,f),opacity:h>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[m],askCumTotal:p[m],bidCumCost:s[m],askCumCost:d[m]}})}function Hm({info:e}){let{t}=useTranslation(),r=e.isBid?wa:Pa,n=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:n,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:gn(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",gn(Math.round(e.cumCost))]})]})}var zm=memo(function({slot:t,onEnter:r,onLeave:n}){let o=useRef(null),i=t.isBid||t.isAsk,a=t.isBid?wa:t.isAsk?Pa:void 0;return jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:i&&jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),Wm=[0,10,20,30,40,50,60,70,80,90,100];function Um(){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:Wm.map(e=>jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Na({bids:e,asks:t}){let{t:r}=useTranslation(),n=useMemo(()=>Bm(e,t),[e,t]),o=useMemo(()=>{let d=e.length>0?Math.max(...e.map(c=>c.price)):0,f=t.length>0?Math.min(...t.map(c=>c.price)):1;return Math.round((d+f)/2*100)},[e,t]),i=useMemo(()=>n.some(d=>d.isBid||d.isAsk),[n]),[a,s]=useState(null),l=useRef(null),u=useCallback((d,f)=>{l.current&&(l.current.style.filter=""),f?(f.style.filter="brightness(1.5)",l.current=f):l.current=null,d.isBid||d.isAsk?s({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):s(null);},[]),p=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),s(null);},[]);return i?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),a&&jsx(Hm,{info:a}),n.map(d=>jsx(zm,{slot:d,onEnter:u,onLeave:p},d.priceCents))]}),jsx(Um,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Ra(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ma(){let{t:e}=useTranslation();return jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsx("span",{children:e("predict.orderBook.loading")})})}function _a({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o,oddsFormatter:i}){let{t:a}=useTranslation(),[s,l]=useState(n),u=i??Ra,p=e.source,{data:d,isLoading:f,isFetching:c,refetch:m}=useRealtimeOrderbook({slug:e.slug,source:p,outcome:t}),g=useMemo(()=>(d?.bids??[]).map(S=>({price:S.price,quantity:S.size})),[d?.bids]),v=useMemo(()=>(d?.asks??[]).map(S=>({price:S.price,quantity:S.size})),[d?.asks]),h=useMemo(()=>g.length>0?Math.max(...g.map(S=>S.price)):null,[g]),x=useMemo(()=>v.length>0?Math.min(...v.map(S=>S.price)):null,[v]),k=useMemo(()=>{if(h==null||x==null)return null;let S=(x-h)*100;return Math.round(S*10)/10},[h,x]);return jsxs("div",{className:cn("flex flex-col",o??"h-[262px]"),children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:k!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(k)?`${k}\xA2`:`${k.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[h!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",u(h)]}),h!=null&&x!=null&&jsx("span",{className:"text-neutral",children:"|"}),x!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("predict.trade.bestAsk"),": ",u(x)]})]}),jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsx("button",{type:"button",title:s==="depth"?"Orderbook":"Depth chart",onClick:()=>l(S=>S==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:s==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})}),jsx("button",{type:"button",title:"Refresh",onClick:()=>m(),disabled:c,className:cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",c&&"animate-spin"),children:jsx(RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[s==="depth"&&jsx(Fragment,{children:f?jsx(Ma,{}):jsx(Na,{bids:g,asks:v})}),s==="table"&&jsx(Fragment,{children:f?jsx(Ma,{}):jsx(qm,{bids:g,asks:v,bestBid:h??void 0,bestAsk:x??void 0,spread:k??void 0,oddsFormatter:i})})]})]})}var ai=4,Gm=8;function qm({bids:e,asks:t,spread:r,oddsFormatter:n}){let{t:o}=useTranslation(),[i,a]=useState(false),s=i?Gm:ai,l=t.length>ai||e.length>ai,u=useMemo(()=>[...t].sort((c,m)=>c.price-m.price).slice(0,s).reverse(),[t,s]),p=useMemo(()=>[...e].sort((c,m)=>m.price-c.price).slice(0,s),[e,s]),d=useMemo(()=>{let c=[...u,...p].map(m=>m.quantity);return Math.max(...c,1)},[u,p]);return u.length===0&&p.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(c=>jsx(Ta,{price:c.price,quantity:c.quantity,side:"ask",maxQty:d,oddsFormatter:n},`ask-${c.price}`)),jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsx("button",{type:"button",onClick:()=>a(c=>!c),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:o(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),p.map(c=>jsx(Ta,{price:c.price,quantity:c.quantity,side:"bid",maxQty:d,oddsFormatter:n},`bid-${c.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Ta({price:e,quantity:t,side:r,maxQty:n,oddsFormatter:o}){let i=r==="ask",a=Math.min(t/n*100,100),s=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=gn(Math.round(t)),p=Math.round(t*e),d=`$${gn(p)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${a}%`}}),jsx("span",{className:`relative z-10 ${l}`,children:o?o(e):Ra(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsx("span",{className:"relative z-10 text-foreground text-right",children:d})]})}var di=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},hn=4,Ia=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function af(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function lf(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ce.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Aa(e){return `${(e*100).toFixed(2)}%`}var cf=[{range:ce.ONE_DAY,label:"1D"},{range:ce.ONE_WEEK,label:"1W"},{range:ce.ONE_MONTH,label:"1M"},{range:ce.ALL,label:"ALL"}];function df({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:cf.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 uf(){let e=useRef(null),t=useRef(null),r=useCallback(o=>{let i=e.current,a=t.current;if(!i||!a)return;let s=i.getBoundingClientRect(),l=(o.clientX-s.left)/s.width*100;a.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,a.style.opacity="1";},[]),n=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function pf({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let a=new Map;t?.forEach(l=>a.set(l.dataKey,l));let s=o.map(l=>a.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?lf(r,i):r}),s.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Aa(l.value):"--"})]},l.dataKey))]})}function mf({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=useState(false),a=useRef(null);useEffect(()=>{if(!o)return;function u(p){a.current&&!a.current.contains(p.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let s=t.length>=hn,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(p=>p.slug===t[0]);return u?.outcomes?.[0]?.label??u?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>i(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),o&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",hn," markets"]}),e.map((u,p)=>{let d=t.includes(u.slug),f=!d&&s,c=d&&t.length===1,m=r.get(u.slug)??"#6b7280",g=u.outcomes.find(h=>h.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{c||f||n(u.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:f||c?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!f&&!c&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.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 ${m}`:"2px solid rgba(255,255,255,0.2)",background:d?`${m}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:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),v&&jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${p}-${u.slug}`)})]})]})}function ff({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(n=>{let o=t.get(n.marketSlug)??"#6b7280",i=r.get(n.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:o,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:n.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Aa(i):"--"})]})]},n.marketSlug)})})}function gf(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function hf(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),a=Math.min(Math.floor((o+1)*n),e.length),s=e.slice(i,a),l=s.map(u=>u.price).sort((u,p)=>u-p);r.push({timestamp:s[s.length-1].timestamp,price:gf(l)});}return r}function vf(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:hf(s.data,t)})),n=new Set;r.forEach(s=>s.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((s,l)=>s-l),i=r.map(s=>{let l=new Map;return s.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:s.marketSlug,map:l}}),a=new Map;return o.map(s=>{let l={timestamp:s};return i.forEach(({slug:u,map:p})=>{let d=p.get(s);if(d!==void 0)a.set(u,d),l[u]=d;else {let f=a.get(u);f!==void 0&&(l[u]=f);}}),l})}function Da(e){return jsx(di,{children:jsx(bf,{...e})})}function bf({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=useMemo(()=>{let P=new Set;return (e.markets??[]).filter(T=>P.has(T.slug)?false:(P.add(T.slug),true))},[e.markets]),a=useMemo(()=>[...i].sort((P,T)=>{let z=J=>(J.outcomes.find(ue=>ue.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return z(T)-z(P)}),[i]),[s,l]=useState(()=>a.slice(0,hn).map(P=>P.slug));useEffect(()=>{let P=new Set(i.map(T=>T.slug));l(T=>{let z=T.filter(J=>P.has(J));return z.length===T.length?T:z.length>0?z:a.slice(0,hn).map(J=>J.slug)});},[i,a]);let[u,p]=useState(Hn),d=useMemo(()=>{let P=new Map;return s.forEach((T,z)=>{P.set(T,Ia[z%Ia.length]);}),P},[s]),f=useMemo(()=>i.filter(P=>s.includes(P.slug)),[i,s]),{series:c,isLoading:m}=useMarketHistory(f,u),g=t||m,v=useMemo(()=>{if(c.length>0&&c.some(z=>z.data.length>0))return c;let P=Date.now(),T=864e5;return f.map(z=>{let ue=(z.outcomes?.find(ae=>ae.label.toLowerCase()==="yes")??z.outcomes?.[0])?.price??.5;return {marketSlug:z.slug,label:z.outcomes?.[0]?.label??z.question,data:[{timestamp:P-7*T,price:ue},{timestamp:P,price:ue}]}})},[c,f]),h=useMemo(()=>u===ce.ONE_DAY?96:u===ce.ONE_WEEK?168:u===ce.ONE_MONTH?180:300,[u]),x=useMemo(()=>vf(v,h),[v,h]),k=useMemo(()=>{if(x.length===0)return [0,1];let P=1/0,T=-1/0;if(s.forEach(J=>{x.forEach(ue=>{let ae=ue[J];ae!=null&&(ae<P&&(P=ae),ae>T&&(T=ae));});}),!isFinite(P))return [0,1];let z=Math.max((T-P)*.15,.05);return [Math.max(0,P-z),Math.min(1,T+z)]},[x,s]),S=useMemo(()=>{let P=new Map;return v.forEach(T=>{T.data.length>0&&P.set(T.marketSlug,T.data[T.data.length-1].price);}),P},[v]),b=useMemo(()=>{let P=new Map;return v.forEach(T=>P.set(T.marketSlug,T.label)),P},[v]),y=useMemo(()=>v.map(P=>({slug:P.marketSlug,color:d.get(P.marketSlug)??"#6b7280"})),[v,d]),{wrapperRef:N,overlayRef:M,onMouseMove:C,onMouseLeave:_}=uf(),F=useCallback(P=>{l(T=>T.includes(P)?T.length<=1?T:T.filter(z=>z!==P):T.length>=hn?T:[...T,P]);},[]),[U,Q]=useState(null),B=useRef(null),Y=useRef(""),q=useRef(0),te=!g&&x.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsx(ff,{series:v,colorMap:d,displayValues:U??S}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsx("div",{ref:N,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?P=>{C(P),cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{Q(B.current);});}:void 0,onMouseLeave:te?()=>{_(),cancelAnimationFrame(q.current),Y.current="",B.current=null,Q(null);}:void 0,children:g?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):x.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:M,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:x,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:P=>af(P,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:k,tickFormatter:P=>`${Math.round(P*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:P=>{let T=P;if(T.active&&T.payload?.length){let z=T.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if(z!==Y.current){Y.current=z;let J=new Map;T.payload.forEach(ue=>{ue.value!=null&&J.set(ue.dataKey,ue.value);}),B.current=J;}}return jsx(pf,{...T,labelMap:b,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(P=>{let T=d.get(P.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:P.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},P.marketSlug)}),U==null&&x.length>0&&v.map(P=>{let T=x[x.length-1],z=T[P.marketSlug];if(z==null)return null;let J=d.get(P.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:T.timestamp,y:z,ifOverflow:"extendDomain",shape:ue=>{let{cx:ae,cy:Ke}=ue;return ae==null||Ke==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:ae,cy:Ke,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:ae,cy:Ke,r:3.5,fill:J})]})}},`pulse-${P.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[formatAmountInUsd(n)," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(df,{value:u,onChange:p}),a.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(mf,{markets:a,selectedSlugs:s,colorMap:d,onToggle:F})})]})]})]})}function co(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ba(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Of(e){return `${parseFloat((e*100).toFixed(2))}%`}function Ha(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function uo(e){return e.outcomes?.[0]?.label??e.question}function Af(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function vn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${a}`}function za(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let p=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(p)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let i=Math.floor(o/864e5),a=Math.floor(o%864e5/36e5),s=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(a).padStart(2,"0")}h`),u.push(`${String(s).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function Wa(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}function Va({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:n,isCollapsed:o}=useScrollCollapse(),i=useMemo(()=>{let d=[...e.markets||[]],f=d.filter(m=>m.status==="open").sort((m,g)=>co(g)-co(m)),c=d.filter(m=>m.status!=="open").sort((m,g)=>co(g)-co(m));return [...f,...c]},[e.markets]),a=e.status==="closed"||e.status==="voided",s=za(a?void 0:e.start_at),l=za(a?void 0:e.end_at),u=Wa(e.start_at),p=Wa(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:n,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${o?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${o?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!o&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((d,f)=>jsxs(Fragment$1,{children:[f>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:d.label})]},d.slug)),jsx(Hf,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${o?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(s||l||a)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?p&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:p})}):s?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:s})}),u&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:u})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),p&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:p})]})]}):null}),jsx(Da,{event:e,volume:e.volume??void 0}),jsx(Df,{markets:i,onTradeAction:t}),jsx(Bf,{markets:i,event:e})]})}var Ua=5;function Df({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isDesktop:n}=useScreen(),[o,i]=useState(false),[a,s]=useState(null),l=useMemo(()=>{let v=new Set;return e.filter(h=>v.has(h.slug)?false:(v.add(h.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[p,d]=useState(u?`${u}:yes`:null);if(l.length===0)return null;let f=l.length>Ua,c=o?l:l.slice(0,Ua),m=v=>{s(h=>h===v?null:v);},g=(v,h,x)=>{d(`${v.slug}:${h}`),n&&s(v.slug),t?.(v,h,x);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsx("th",{})]})}),jsx("tbody",{children:c.map((v,h)=>{let x=a===v.slug;return jsx(Ff,{market:v,activeYes:p===`${v.slug}:yes`,activeNo:p===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>m(v.slug),onTradeAction:g},v.id??`${h}-${v.slug}`)})})]}),f&&jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function Ff({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:a}=useTranslation(),s=e.status==="open",l=e.volume?`${formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:s}),{data:p}=useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),d=pickBestAsk(u,"yes")??Ba(e,"yes")??0,f=pickBestAsk(p,"no")??Ba(e,"no");return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:o,role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:uo(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:uo(e)}),l&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Of(d)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:s?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:c=>{c.stopPropagation(),i?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:Ha(d)})}),jsx("button",{type:"button",className:cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:c=>{c.stopPropagation(),i?.(e,"no","buy");},children:f!=null?a("predict.market.action.no",{price:Ha(f)}):a("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),n&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(_a,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Bf({markets:e,event:t}){let{t:r}=useTranslation(),[n,o]=useState(false),[i,a]=useState(false),[s,l]=useState(0),u=e.filter(c=>c.rules&&c.rules.length>0||c.description);if(u.length===0)return null;let p=u[s]??u[0],d=p.rules&&p.rules.length>0?p.rules.join(`
|
|
77
77
|
|
|
78
|
-
`):p.description??"";if(!d)return null;let f=d.length>200&&!o?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")}),u.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:Zn(p)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:l=>{c(Number(l)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((l,m)=>jsx(DropdownItem,{className:cn(m===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Zn(l)},String(m)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),d.length>200&&jsx("button",{type:"button",onClick:()=>n(l=>!l),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>s(l=>!l),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let l=p.status,m=[];return p.created_at&&m.push({label:r("predict.event.timeline.created"),value:an(p.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:an(p.start_at),isActive:l!=="pending"}),l==="voided"?m.push({label:r("predict.event.timeline.voided"),value:an(p.closed_at??p.end_at),isActive:true}):l==="closed"?m.push({label:r("predict.event.timeline.closed"),value:an(p.closed_at??p.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:an(p.end_at),isActive:false}),m})().map((l,m,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 ${l.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),m<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${m<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:l.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:l.value})]})]},l.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:p.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Pf(p.source)})]})]})]})]})}function Tf({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 Ha({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:i}=useEvent({slug:e,source:t});return n?jsx(nn,{}):i||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Ba,{event:o,onTradeAction:r})}var If={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}},Of={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Ut(e){return If[e]??Of}function F1({source:e,className:t}){let r=Ut(e);return jsxs("span",{className:cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var Wa="rgba(39,39,42,0.6)",Wf="rgba(63,63,70,0.8)";function Uf(e){return e==null?"-":formatAmountInUsd(e)}function $a({eventSlug:e,source:t,limit:r=4,onEventClick:o,onEventHover:n}){let{t:i}=useTranslation(),{data:s,isLoading:a}=useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(c=>jsx($f,{event:c,onClick:o,onHover:n},`${c.source}-${c.slug}`))})]})}function $f({event:e,onClick:t,onHover:r}){let{t:o}=useTranslation(),n=Ut(e.source),i=useMemo(()=>Uf(e.volume),[e.volume]),s=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=Wf,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=Wa;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Wa}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:n.color,flexShrink:0},children:[n.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:n.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",o("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function to(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function l2({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:c,onSetupRequired:u,slippageBps:p}){let{t:d}=useTranslation(),{isDesktop:f}=useScreen(),{onOpen:l}=useAsyncModal(Yr),{onOpen:m}=useAsyncModal(qo),{data:g,isLoading:h}=useEvent({slug:e,source:t}),v=useMemo(()=>{let S=[...g?.markets||[]],R=S.filter(z=>z.status==="open").sort((z,K)=>to(K)-to(z)),I=S.filter(z=>z.status!=="open").sort((z,K)=>to(K)-to(z));return [...R,...I]},[g?.markets]),[b,N]=useState(null),k=useCallback((S,R,I)=>{N(z=>({market:S,outcome:R,side:I,version:(z?.version??0)+1})),!f&&g&&(I==="sell"?m({params:{event:g,market:S,initialOutcome:R,chain:r,slippageBps:p,onSetupRequired:u}}):l({params:{event:g,market:S,initialOutcome:R,chain:r,slippageBps:p,onInsufficientBalance:c}}));},[f,g,r,p,l,m,c,u]),x=b?.market??v[0];if(h){let S=!!s;return f?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(nn,{showBack:S})}),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(ua,{})})})]}):jsx(nn,{showBack:S})}let y=b?`${b.market.slug}-${b.version}`:x?.slug??"default",P=b?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:d("common.back")})}),jsx(Ha,{eventSlug:e,source:t,onTradeAction:k})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[x&&(P?jsx(jn,{event:g,market:x,initialOutcome:b?.outcome,chain:r,slippageBps:p,onSetupRequired:u},y):jsx(Bn,{event:g,market:x,initialOutcome:b?.outcome,chain:r,slippageBps:p,onInsufficientBalance:c},y)),g&&jsx($a,{eventSlug:e,source:g.source,onEventClick:n,onEventHover:i})]})]}),g&&jsx("div",{className:"flex w-full flex-col",children:a?a({event:g,walletAddress:o}):jsx(la,{event:g,walletAddress:o})}),jsx(Hn,{}),jsx(ia,{}),jsx(Ks,{})]})}function Va(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function ng(e){switch(e){case le.ONE_DAY:return {interval:"15m",limit:96};case le.ONE_WEEK:return {interval:"1h",limit:168};case le.ONE_MONTH:return {interval:"4h",limit:180};case le.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var g2=e=>{let{candlestickMarketSlugs:t,chartRange:r=En,source:o}=e,n=usePredictClient(),i=useMemo(()=>ng(r),[r]),{data:s,isLoading:a,error:c}=useEvent({slug:e.eventSlug,source:o}),u=useMemo(()=>{if(!s?.markets)return [];let m=new Set,g=s.markets.filter(v=>m.has(v.slug)?false:(m.add(v.slug),true));return (t&&t.length>0?t.slice(0,4).map(v=>g.find(b=>b.slug===v)).filter(v=>v!==void 0):[...g].sort((v,b)=>Va(b)-Va(v)).slice(0,4)).map(v=>v.slug)},[t,s?.markets]),p=useQueries({queries:u.map(m=>({queryKey:candlesticksQueryKey(m,i),queryFn:()=>n.listCandlesticks(m,i),enabled:u.length>0}))}),d=p.some(m=>m.isLoading),f=useMemo(()=>{let m=new Map;return u.forEach((g,h)=>{let v=p[h]?.error;v&&m.set(g,v);}),m},[u,p]),l=useMemo(()=>{let m=new Map;return u.forEach((g,h)=>{let v=p[h]?.data;v&&m.set(g,v);}),m},[u,p]);return {event:s,isEventLoading:a,eventError:c,candlestickParams:i,candlesticks:l,isCandlesticksLoading:d,candlestickErrors:f}};function ai({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:o}=e,n=o.name||o.pseudonym||t,i=useMemo(()=>ag(e.created_at),[e.created_at]);return jsxs("div",{className:cn("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(og,{src:o.profile_image,name:n,className:cn("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(ig,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function og({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=useMemo(()=>sg(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn("rounded-full object-cover",r)}):jsx("span",{className:cn("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function ig({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})})}function sg(e){let t=0;for(let o=0;o<e.length;o++)t=e.charCodeAt(o)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function ag(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let o=Math.floor(r/60);if(o<60)return `${o}m`;let n=Math.floor(o/60);if(n<24)return `${n}h`;let i=Math.floor(n/24);if(i<7)return `${i}d`;let s=Math.floor(i/7);return s<5?`${s}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var vg={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},Ga={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},bg=["latest","oldest","mostLiked"],xg=600,yg=112;function kg({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=useTranslation(),[s,a]=useState("latest"),[c,u]=useState(false),p=vg[s],{data:d,isLoading:f,isFetchingNextPage:l,hasNextPage:m,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:p.order,ascending:p.ascending,holders_only:c}),h=useMemo(()=>d?.pages?.flatMap(I=>I.items)??[],[d?.pages]),v=useRef(null),{height:b}=useResizeObserver({ref:v}),N=o??(b||xg),k=useDynamicRowHeight({defaultRowHeight:yg,key:`${e}:${t}:${s}:${c}`}),x=h.length,y=x+(m?1:0),P=useCallback(I=>I<x,[x]),S=useCallback(async()=>{m&&!l&&await g();},[m,l,g]),R=useInfiniteLoader({isRowLoaded:P,loadMoreRows:S,rowCount:y,threshold:5});return jsxs("div",{className:cn("flex h-full w-full flex-col",n),children:[jsx(wg,{sort:s,onSortChange:a,holdersOnly:c,onHoldersOnlyChange:u}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:v,children:f?jsx(Pg,{}):h.length===0?jsx(Ng,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:N},onRowsRendered:R,rowComponent:Sg,rowCount:y,rowHeight:k,rowProps:{comments:h,itemCount:x,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Sg({index:e,style:t,comments:r,itemCount:o,anonymousLabel:n}){if(e>=o)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(ai,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function wg({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:o}){let{t:n}=useTranslation(),[i,s]=useState(false),a=useRef(null);return useEffect(()=>{if(!i)return;let c=p=>{a.current&&!a.current.contains(p.target)&&s(false);},u=p=>{p.key==="Escape"&&s(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u);}},[i]),jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxs("div",{ref:a,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>s(c=>!c),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsx(Cg,{className:"size-3.5 text-neutral"}),jsx("span",{children:n(Ga[e])}),jsx(Mg,{className:cn("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:bg.map(c=>{let u=c===e;return jsxs("button",{type:"button",onClick:()=>{t(c),s(false);},className:cn("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:n(Ga[c])}),u&&jsx(Ya,{className:"size-4 text-primary"})]},c)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>o(!r),className:cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(Ya,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function Pg(){return jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxs("div",{className:"flex gap-x-2.5",children:[jsx(Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxs("div",{className:"flex-1 space-y-2",children:[jsx(Skeleton,{className:"h-3 w-24 rounded"}),jsx(Skeleton,{className:"h-3 w-full rounded"}),jsx(Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function Ng({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function Cg({className:e}){return jsxs("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Mg({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Ya({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M20 6 9 17l-5-5"})})}var Lg=10,Rg=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function so(){let[e,t]=useAtom(Rg),r=useCallback(n=>{let i=n.trim();i&&t(s=>{let a=s.filter(c=>c!==i);return [i,...a].slice(0,Lg)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function tl({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=useTranslation();return e.length===0?null:jsxs("div",{className:cn("px-4 pb-4",o),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function rl({onSelect:e,className:t}){let{histories:r,clearHistories:o}=so();return jsx(tl,{className:cn(t),histories:r,onSelect:e,onClear:o})}function nl({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:i}=useTranslation();return jsx("div",{className:n,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function Xg(e){return e==null?"-":formatAmountInUsd(e)}function ol({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:i}){let{t:s}=useTranslation(),a=e.tags?.[0],c=Ut(e.source),u=useMemo(()=>Xg(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:p=>{t&&o&&p.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:c.color},children:[c.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:c.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[u," ",s("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function il({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[o]),isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var a0=64;function cl({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...i}){let{events:s,isLoading:a,isFetchingNextPage:c,hasNextPage:u,fetchNextPage:p}=il(i),d=useRef(null),{height:f}=useResizeObserver({ref:d}),l=useCallback(v=>v<s.length,[s]),m=useCallback(async()=>{u&&!c&&await p();},[u,c,p]),g=useMemo(()=>u?s.length+1:s.length,[s,u]),h=useInfiniteLoader({isRowLoaded:l,loadMoreRows:m,rowCount:g,threshold:5});return a?jsx(c0,{className:n}):s.length===0?jsx(d0,{className:n}):jsx("div",{className:cn("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:d,children:jsx(List,{className:"no-scrollbar",style:{height:f},onRowsRendered:h,rowComponent:l0,rowCount:g,rowHeight:a0,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function l0({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s}){let a=r[e];return a?jsx("div",{style:t,children:jsx(ol,{event:a,href:n?.(a),LinkComponent:i,onSelect:o,onHover:s})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function c0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function d0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function ml({onKeywordChange:e}){let[t,r]=useState(""),[o,n]=useState(""),{addHistory:i}=so(),s=useCallbackRef(e),a=useCallbackRef(i),c=useMemo(()=>debounce(f=>{n(f),s(f),f&&a(f);},500),[s,a]),u=useCallback(f=>{r(f),c(f);},[c]),p=useCallback(f=>{c.cancel(),r(f),n(f),s(f),f&&a(f);},[c,s,a]),d=useCallback(()=>p(""),[p]);return {text:t,keyword:o,setText:u,setKeyword:p,clearKeyword:d}}function fl({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let{text:a,keyword:c,setText:u,setKeyword:p,clearKeyword:d}=ml({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(nl,{value:a,onValueChange:u,onClear:d,onEscape:i}),!c&&jsx(rl,{onSelect:p}),jsx(cl,{className:"flex-auto min-h-0",keyword:c,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s})]})}var pi="predict-search";function lS({id:e=pi}){return jsx(AsyncModal,{id:e,children:t=>jsx(w0,{...t})})}function w0({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:i}=useScreen(),s=useCallback(c=>{o(c);},[o]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(fl,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function vS({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n}=useScreen(),{onOpen:i,onClose:s}=useAsyncModal(pi),a=useCallbackRef(e),c=useCallbackRef(async()=>{let p=await i({params:t});p&&a(p);}),u=useCallbackRef(()=>{s();});return useEffect(()=>{let p=d=>{let f=document.activeElement,l=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");d.key==="/"&&!l&&(d.preventDefault(),c()),d.key==="Escape"&&(d.preventDefault(),u());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[c,u]),n?jsx(Button,{size:"sm",radius:"full",onPress:c,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:o("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:c,variant:"bordered",className:cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var fi=[{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"}],Nl=[{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}],Sl={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"},wl={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 R0(e,t){if(!e)return "$5K+";let r=Nl.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Cl({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=useTranslation(),[c,u]=useState(false),[p,d]=useState(false),[f,l]=useState(false),[m,g]=useState(false),h=useRef(null),v=useRef(null),b=fi.find(x=>x.value===e)??fi[0],N=useCallback(x=>{h.current&&!h.current.contains(x.target)&&u(false),v.current&&!v.current.contains(x.target)&&d(false);},[]);useEffect(()=>(document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)),[N]);let k=useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
78
|
+
`):p.description??"";if(!d)return null;let f=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")}),u.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:uo(p)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:c=>{l(Number(c)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((c,m)=>jsx(DropdownItem,{className:cn(m===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:uo(c)},String(m)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),d.length>200&&jsx("button",{type:"button",onClick:()=>o(c=>!c),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>a(c=>!c),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let c=p.status,m=[];return p.created_at&&m.push({label:r("predict.event.timeline.created"),value:vn(p.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:vn(p.start_at),isActive:c!=="pending"}),c==="voided"?m.push({label:r("predict.event.timeline.voided"),value:vn(p.closed_at??p.end_at),isActive:true}):c==="closed"?m.push({label:r("predict.event.timeline.closed"),value:vn(p.closed_at??p.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:vn(p.end_at),isActive:false}),m})().map((c,m,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${c.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),m<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${m<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:c.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:c.value})]})]},c.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:p.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Af(p.source)})]})]})]})]})}function Hf({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function ja({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=useEvent({slug:e,source:t});return o?jsx(fn,{}):i||!n?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsx(Va,{event:n,onTradeAction:r})}var Kf={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}},Vf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Ut(e){return Kf[e]??Vf}function G1({source:e,className:t}){let r=Ut(e);return jsxs("span",{className:cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}var qa="rgba(39,39,42,0.6)",Jf="rgba(63,63,70,0.8)";function Zf(e){return e==null?"-":formatAmountInUsd(e)}function Qa({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=useTranslation(),{data:a,isLoading:s}=useSimilarEvents({slug:e,source:t,limit:r});return s||!a||a.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(l=>jsx(eg,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function eg({event:e,onClick:t,onHover:r}){let{t:n}=useTranslation(),o=Ut(e.source),i=useMemo(()=>Zf(e.volume),[e.volume]),a=e.tags?.[0];return jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=Jf,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=qa;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${qa}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsx("span",{style:{color:"#71717a"},children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function mo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function b2({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:a,renderActivitySection:s,onInsufficientBalance:l,onSetupRequired:u,slippageBps:p}){let{t:d}=useTranslation(),{isDesktop:f}=useScreen(),{onOpen:c}=useAsyncModal(on),{onOpen:m}=useAsyncModal(Zo),{data:g,isLoading:v}=useEvent({slug:e,source:t}),h=useMemo(()=>{let M=[...g?.markets||[]],C=M.filter(F=>F.status==="open").sort((F,U)=>mo(U)-mo(F)),_=M.filter(F=>F.status!=="open").sort((F,U)=>mo(U)-mo(F));return [...C,..._]},[g?.markets]),[x,k]=useState(null),S=useCallback((M,C,_)=>{k(F=>({market:M,outcome:C,side:_,version:(F?.version??0)+1})),!f&&g&&(_==="sell"?m({params:{event:g,market:M,initialOutcome:C,chain:r,slippageBps:p,onSetupRequired:u}}):c({params:{event:g,market:M,initialOutcome:C,chain:r,slippageBps:p,onInsufficientBalance:l}}));},[f,g,r,p,c,m,l,u]),b=x?.market??h[0];if(v){let M=!!a;return f?jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(fn,{showBack:M})}),jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsx(ba,{})})})]}):jsx(fn,{showBack:M})}let y=x?`${x.market.slug}-${x.version}`:b?.slug??"default",N=x?.side==="sell";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[a&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:a,startContent:jsx(ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:d("common.back")})}),jsx(ja,{eventSlug:e,source:t,onTradeAction:S})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[b&&(N?jsx(no,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:p,onSetupRequired:u},y):jsx(qn,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:p,onInsufficientBalance:l},y)),g&&jsx(Qa,{eventSlug:e,source:g.source,onEventClick:o,onEventHover:i})]})]}),g&&jsx("div",{className:"flex w-full flex-col",children:s?s({event:g,walletAddress:n}):jsx(ga,{event:g,walletAddress:n})}),jsx(Yn,{}),jsx(pa,{}),jsx(Xs,{})]})}function Ja(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function fg(e){switch(e){case ce.ONE_DAY:return {interval:"15m",limit:96};case ce.ONE_WEEK:return {interval:"1h",limit:168};case ce.ONE_MONTH:return {interval:"4h",limit:180};case ce.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var N2=e=>{let{candlestickMarketSlugs:t,chartRange:r=Hn,source:n}=e,o=usePredictClient(),i=useMemo(()=>fg(r),[r]),{data:a,isLoading:s,error:l}=useEvent({slug:e.eventSlug,source:n}),u=useMemo(()=>{if(!a?.markets)return [];let m=new Set,g=a.markets.filter(h=>m.has(h.slug)?false:(m.add(h.slug),true));return (t&&t.length>0?t.slice(0,4).map(h=>g.find(x=>x.slug===h)).filter(h=>h!==void 0):[...g].sort((h,x)=>Ja(x)-Ja(h)).slice(0,4)).map(h=>h.slug)},[t,a?.markets]),p=useQueries({queries:u.map(m=>({queryKey:candlesticksQueryKey(m,i),queryFn:()=>o.listCandlesticks(m,i),enabled:u.length>0}))}),d=p.some(m=>m.isLoading),f=useMemo(()=>{let m=new Map;return u.forEach((g,v)=>{let h=p[v]?.error;h&&m.set(g,h);}),m},[u,p]),c=useMemo(()=>{let m=new Map;return u.forEach((g,v)=>{let h=p[v]?.data;h&&m.set(g,h);}),m},[u,p]);return {event:a,isEventLoading:s,eventError:l,candlestickParams:i,candlesticks:c,isCandlesticksLoading:d,candlestickErrors:f}};function mi({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=useMemo(()=>bg(e.created_at),[e.created_at]);return jsxs("div",{className:cn("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsx(gg,{src:n.profile_image,name:o,className:cn("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsx("span",{className:"truncate text-sm font-medium text-foreground",children:o}),jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:i})]}),jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsx(hg,{className:"size-3.5"}),jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function gg({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=useMemo(()=>vg(t),[t]);return e?jsx("img",{src:e,alt:t,loading:"lazy",className:cn("rounded-full object-cover",r)}):jsx("span",{className:cn("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:o},"aria-hidden":true,children:n})}function hg({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})})}function vg(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function bg(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let i=Math.floor(o/24);if(i<7)return `${i}d`;let a=Math.floor(i/7);return a<5?`${a}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Tg={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},tl={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Eg=["latest","oldest","mostLiked"],Lg=600,Rg=112;function _g({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=useTranslation(),[a,s]=useState("latest"),[l,u]=useState(false),p=Tg[a],{data:d,isLoading:f,isFetchingNextPage:c,hasNextPage:m,fetchNextPage:g}=useInfiniteComments({slug:e,source:t,limit:r,order:p.order,ascending:p.ascending,holders_only:l}),v=useMemo(()=>d?.pages?.flatMap(_=>_.items)??[],[d?.pages]),h=useRef(null),{height:x}=useResizeObserver({ref:h}),k=n??(x||Lg),S=useDynamicRowHeight({defaultRowHeight:Rg,key:`${e}:${t}:${a}:${l}`}),b=v.length,y=b+(m?1:0),N=useCallback(_=>_<b,[b]),M=useCallback(async()=>{m&&!c&&await g();},[m,c,g]),C=useInfiniteLoader({isRowLoaded:N,loadMoreRows:M,rowCount:y,threshold:5});return jsxs("div",{className:cn("flex h-full w-full flex-col",o),children:[jsx(Og,{sort:a,onSortChange:s,holdersOnly:l,onHoldersOnlyChange:u}),jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:h,children:f?jsx(Ag,{}):v.length===0?jsx(Dg,{message:i("predict.comments.empty")}):jsx(List,{className:"no-scrollbar",style:{height:k},onRowsRendered:C,rowComponent:Ig,rowCount:y,rowHeight:S,rowProps:{comments:v,itemCount:b,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Ig({index:e,style:t,comments:r,itemCount:n,anonymousLabel:o}){if(e>=n)return jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsx(Spinner,{size:"sm"})});let i=r[e];return i?jsx("div",{style:t,children:jsx(mi,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function Og({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=useTranslation(),[i,a]=useState(false),s=useRef(null);return useEffect(()=>{if(!i)return;let l=p=>{s.current&&!s.current.contains(p.target)&&a(false);},u=p=>{p.key==="Escape"&&a(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[i]),jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxs("div",{ref:s,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>a(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsx(Fg,{className:"size-3.5 text-neutral"}),jsx("span",{children:o(tl[e])}),jsx(Bg,{className:cn("size-3.5 text-neutral transition-transform",i&&"rotate-180")})]}),i&&jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:Eg.map(l=>{let u=l===e;return jsxs("button",{type:"button",onClick:()=>{t(l),a(false);},className:cn("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsx("span",{className:"flex-1 font-medium",children:o(tl[l])}),u&&jsx(rl,{className:"size-4 text-primary"})]},l)})})]}),jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>n(!r),className:cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsx("span",{className:cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsx(rl,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function Ag(){return jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxs("div",{className:"flex gap-x-2.5",children:[jsx(Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxs("div",{className:"flex-1 space-y-2",children:[jsx(Skeleton,{className:"h-3 w-24 rounded"}),jsx(Skeleton,{className:"h-3 w-full rounded"}),jsx(Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function Dg({message:e}){return jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function Fg({className:e}){return jsxs("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Bg({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"m6 9 6 6 6-6"})})}function rl({className:e}){return jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsx("path",{d:"M20 6 9 17l-5-5"})})}var Wg=10,Ug=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function bo(){let[e,t]=useAtom(Ug),r=useCallback(o=>{let i=o.trim();i&&t(a=>{let s=a.filter(l=>l!==i);return [i,...s].slice(0,Wg)});},[t]),n=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function ll({histories:e,onSelect:t,onClear:r,className:n}){let{t:o}=useTranslation();return e.length===0?null:jsxs("div",{className:cn("px-4 pb-4",n),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:o("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsx(Chip,{size:"sm",variant:"bordered",className:cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function cl({onSelect:e,className:t}){let{histories:r,clearHistories:n}=bo();return jsx(ll,{className:cn(t),histories:r,onSelect:e,onClear:n})}function dl({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=useTranslation();return jsx("div",{className:o,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),n?.();},children:"Esc"})})})}function l0(e){return e==null?"-":formatAmountInUsd(e)}function ul({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:a}=useTranslation(),s=e.tags?.[0],l=Ut(e.source),u=useMemo(()=>l0(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:p=>{t&&n&&p.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[u," ",a("predict.event.volume")]}),s&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:s.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function pl({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:a,fetchNextPage:s}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>n?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:a??false,fetchNextPage:s}}var b0=64;function hl({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:a,isLoading:s,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:p}=pl(i),d=useRef(null),{height:f}=useResizeObserver({ref:d}),c=useCallback(h=>h<a.length,[a]),m=useCallback(async()=>{u&&!l&&await p();},[u,l,p]),g=useMemo(()=>u?a.length+1:a.length,[a,u]),v=useInfiniteLoader({isRowLoaded:c,loadMoreRows:m,rowCount:g,threshold:5});return s?jsx(y0,{className:o}):a.length===0?jsx(k0,{className:o}):jsx("div",{className:cn("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:f},onRowsRendered:v,rowComponent:x0,rowCount:g,rowHeight:b0,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function x0({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:a}){let s=r[e];return s?jsx("div",{style:t,children:jsx(ul,{event:s,href:o?.(s),LinkComponent:i,onSelect:n,onHover:a})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function y0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function k0({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function yl({onKeywordChange:e}){let[t,r]=useState(""),[n,o]=useState(""),{addHistory:i}=bo(),a=useCallbackRef(e),s=useCallbackRef(i),l=useMemo(()=>debounce(f=>{o(f),a(f),f&&s(f);},500),[a,s]),u=useCallback(f=>{r(f),l(f);},[l]),p=useCallback(f=>{l.cancel(),r(f),o(f),a(f),f&&s(f);},[l,a,s]),d=useCallback(()=>p(""),[p]);return {text:t,keyword:n,setText:u,setKeyword:p,clearKeyword:d}}function kl({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:a}){let{text:s,keyword:l,setText:u,setKeyword:p,clearKeyword:d}=yl({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(dl,{value:s,onValueChange:u,onClear:d,onEscape:i}),!l&&jsx(cl,{onSelect:p}),jsx(hl,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:a})]})}var bi="predict-search";function bS({id:e=bi}){return jsx(AsyncModal,{id:e,children:t=>jsx(O0,{...t})})}function O0({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=useTranslation(),{isMobile:i}=useScreen(),a=useCallback(l=>{n(l);},[n]),s=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:o("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(kl,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:s})})]})})}function MS({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=useTranslation(),{isDesktop:o}=useScreen(),{onOpen:i,onClose:a}=useAsyncModal(bi),s=useCallbackRef(e),l=useCallbackRef(async()=>{let p=await i({params:t});p&&s(p);}),u=useCallbackRef(()=>{a();});return useEffect(()=>{let p=d=>{let f=document.activeElement,c=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");d.key==="/"&&!c&&(d.preventDefault(),l()),d.key==="Escape"&&(d.preventDefault(),u());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[l,u]),o?jsx(Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsx(Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:n("predict.search.placeholder")}):jsx(Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsx(SearchIcon,{width:16,height:16,className:"text-foreground"})})}var yi=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],_l=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],El={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Ll={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function U0(e,t){if(!e)return "$5K+";let r=_l.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Il({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:a}){let{t:s}=useTranslation(),[l,u]=useState(false),[p,d]=useState(false),[f,c]=useState(false),[m,g]=useState(false),v=useRef(null),h=useRef(null),x=yi.find(b=>b.value===e)??yi[0],k=useCallback(b=>{v.current&&!v.current.contains(b.target)&&u(false),h.current&&!h.current.contains(b.target)&&d(false);},[]);useEffect(()=>(document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)),[k]);let S=useCallback(()=>{a?.(),g(true),setTimeout(()=>g(false),700);},[a]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
79
79
|
@keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
80
80
|
.match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
|
|
81
81
|
.match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
|
|
82
|
-
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:
|
|
82
|
+
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:v,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:El,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(b=>!b),d(false);},children:[jsx($0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(x.labelKey)}),jsx(Rl,{open:l})]}),l&&jsx("div",{style:{...Ll,width:224,padding:4},children:yi.map(b=>{let y=e===b.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===b.value?n(!r):t(b.value),u(false);},children:[jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsx(K0,{type:b.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:s(b.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:s(b.descKey)})]}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]}),i&&jsxs("div",{ref:h,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:El,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{d(b=>!b),u(false);},children:[jsx(V0,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:U0(o,s)}),jsx(j0,{onMouseEnter:()=>c(true),onMouseLeave:()=>c(false)}),jsx(Rl,{open:p})]}),f&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),s("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:s("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:s("predict.matches.filter.tooltipNote")})]})]})]}),p&&jsxs("div",{style:{...Ll,right:0,width:176},children:[jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:s("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:_l.map(b=>{let y=b.value===0?!o:o===b.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(b.value===0?void 0:b.value),d(false);},children:[jsx("span",{children:b.labelKey?s(b.labelKey):b.label}),y&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]})]}),a&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)",b.currentTarget.style.color="#fff";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)",b.currentTarget.style.color="#a1a1aa";},onClick:S,children:jsxs("svg",{className:m?"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 $0(){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 K0({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 V0(){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 j0({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 Rl({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 Q0(e){return formatAmountInUsd(e)}var X0=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)",borderColor:"rgba(199,255,46,0.18)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)",borderColor:"rgba(247,104,22,0.18)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>formatAmount(e),valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)",borderColor:"rgba(23,201,100,0.18)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:Q0,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Al({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
83
83
|
@keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
84
84
|
@keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
85
85
|
@keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -117,21 +117,21 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
117
117
|
.matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
|
|
118
118
|
@media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
119
119
|
`}),jsxs("div",{className:"matches-hero-outer",style:{display:"flex",marginBottom:0},children:[jsxs("div",{className:"matches-hero-left",style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,animation:"matchHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"matches-hero-live",style:{display:"flex",marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"match-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"match-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.matches.liveBadge")}),jsx("span",{style:{borderRadius:4,background:"rgba(199,255,46,0.12)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c7ff2e",textTransform:"uppercase",border:"1px solid rgba(199,255,46,0.22)"},children:t("predict.matches.betaTag")})]})}),jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:46,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsx("p",{className:"matches-hero-subtitle matches-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
|
|
120
|
-
`).map((r,
|
|
120
|
+
`).map((r,n)=>jsxs("span",{children:[n>0&&jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:X0.map((r,n)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function ki(e){return e==null?"-":formatAmountInUsd(e)}function eh(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Hl={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},th={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},Dl={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function rh(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var nh={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},oh={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},ih={text:"#9ca3af",icon:"#9ca3af"};function sh(e){return oh[e]??ih}var ah=`
|
|
121
121
|
.match-card button:focus-visible,
|
|
122
122
|
.match-card a:focus-visible,
|
|
123
123
|
.match-card [role="button"]:focus-visible {
|
|
124
124
|
outline: 2px solid hsl(var(--heroui-primary) / 0.4);
|
|
125
125
|
outline-offset: 2px;
|
|
126
126
|
}
|
|
127
|
-
`;function X0({tier:e}){let t=_l[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}function J0(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,o,n)=>({source:r,event_title:o,event_slug:n?.event_slug??"",market_id:n?.id??0,market_slug:n?.slug??"",question:n?.question??"",status:n?.status??"open",outcomes:n?.outcomes,best_price:n?.outcomes?.[0]?.best_ask??n?.outcomes?.[0]?.price??void 0,vol_24h_usd:n?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function Il({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:c}=useTranslation(),u=J0(e);if(!u)return null;let[p,d]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,l=$0(f),m=_l[l],g=p.best_price!=null&&d.best_price!=null?p.best_price<=d.best_price?p.source:d.source:null,h=p.event_title||d.event_title,v=e.signal_tag??"stale_data",b=El[v]??El.stale_data,N=r?.(e),k=jsxs(Fragment,{children:[jsx("style",{children:Q0}),f!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${m.bandFrom}, ${m.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:m.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:m.color},children:[f.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:c("predict.matches.gap")})]}),jsx(X0,{tier:l})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:h}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(Ll,{leg:p,isCheaper:g===p.source,externalUrlFallback:s?.(e,p.source),internalHref:n?.(e,p),onSelect:o?()=>o(e,p):void 0,LinkComponent:a}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(Ll,{leg:d,isCheaper:g===d.source,externalUrlFallback:s?.(e,d.source),internalHref:n?.(e,d),onSelect:o?()=>o(e,d):void 0,LinkComponent:a})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),gi(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"})}),gi(e.combined_volume_24h)," ",c("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxs("span",{title:c("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),Z0(c,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:b.dot,flexShrink:0}}),c(b.label)]})]})]}),x={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:N||t?"pointer":void 0},y=S=>{let R=S.currentTarget,I=K0[l];R.style.borderColor=I.border,R.style.boxShadow=I.shadow,i?.(e);},P=S=>{let R=S.currentTarget;R.style.borderColor="rgba(39,39,42,0.6)",R.style.boxShadow="none";};return N&&a?jsx(a,{href:N,className:"group match-card",children:jsx("div",{style:x,onMouseEnter:y,onMouseLeave:P,onClick:()=>t?.(e),children:k})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:x,onMouseEnter:y,onMouseLeave:P,onClick:()=>t?.(e),onKeyDown:S=>{t&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),t(e));},children:k})}function Z0(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let o=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:o})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Ll({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=useTranslation(),a=Ut(e.source),c=Y0(e.source),u=e.best_price,p=e.outcomes?.[0]?.label??null,d=e.external_url??r,f=V0(e.age_seconds),l=v=>{v.stopPropagation();},m=!!(o||n),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:m?"pointer":void 0,color:"inherit",textDecoration:"none"},h=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:c.text,textTransform:"uppercase"},children:a.label}),f&&jsx("span",{title:e.age_seconds!=null?s("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:j0[f],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[p&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[gi(e.vol_24h_usd)," ",s("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),d?jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:v=>v.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.color="#d4d4d8",v.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:v=>{v.currentTarget.style.color="#71717a",v.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return o&&i?jsx(i,{href:o,className:"match-card-leg-link",onClick:v=>{l(v),n?.();},children:jsx("div",{style:g,children:h})}):m?jsx("div",{role:"link",tabIndex:0,style:g,onClick:v=>{l(v),n?.();},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),l(v),n?.());},children:h}):jsx("div",{style:g,children:h})}var Bl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:c,onSelect:u,onHover:p,getMarketHref:d,LinkComponent:f,onStatsChange:l},m){let{t:g}=useTranslation(),{data:h,hasNextPage:v,fetchNextPage:b,isFetchingNextPage:N,isLoading:k,isPlaceholderData:x,refetch:y}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:keepPreviousData}),[P,S]=useState(0),[R,I]=useState(false);R&&!x?(I(false),S(re=>re+1)):x&&!R&&I(true),useImperativeHandle(m,()=>({refetch:()=>{y();}}),[y]);let z=useMemo(()=>h?.pages.flatMap(re=>re.items??[])??[],[h]),K=h?.pages[0]?.total,W=useMemo(()=>{let re=0,w=0,M=0;for(let $ of z){let J=$.spread??0;J>re&&(re=J),J>=.03&&M++,$.combined_volume!=null&&(w+=$.combined_volume);}return {activePairs:K??z.length,maxSpread:re,highSpreadCount:M,totalVolume:w}},[z,K]);useEffect(()=>{W.activePairs>0&&l?.(W);},[W,l]);let G=useRef(null),Y=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let re=G.current;if(!re)return;let w=new IntersectionObserver(M=>{M[0]?.isIntersecting&&v&&!N&&b();},{rootMargin:"200px"});return w.observe(re),()=>w.disconnect()},[v,N,b]),useEffect(()=>{if(v)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[v]),k)return jsx(ah,{});if(z.length===0)return jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let Q=!v&&z.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
127
|
+
`;function lh({tier:e}){let t=Hl[e],r=e==="wide"?5:e==="moderate"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(n,o)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:o<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},o))})}function ch(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function zl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:a,LinkComponent:s}){let{t:l}=useTranslation(),u=ch(e);if(!u)return null;let[p,d]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=eh(f),m=Hl[c],g=p.best_price!=null&&d.best_price!=null?p.best_price<=d.best_price?p.source:d.source:null,v=p.event_title||d.event_title,h=e.signal_tag??"stale_data",x=Dl[h]??Dl.stale_data,k=r?.(e),S=jsxs(Fragment,{children:[jsx("style",{children:ah}),f!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${m.bandFrom}, ${m.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:m.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:m.color},children:[f.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:l("predict.matches.gap")})]}),jsx(lh,{tier:c})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(Fl,{leg:p,isCheaper:g===p.source,externalUrlFallback:a?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:s}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(Fl,{leg:d,isCheaper:g===d.source,externalUrlFallback:a?.(e,d.source),internalHref:o?.(e,d),onSelect:n?()=>n(e,d):void 0,LinkComponent:s})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),ki(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"})}),ki(e.combined_volume_24h)," ",l("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxs("span",{title:l("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),dh(l,e.age_seconds)]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:x.dot,flexShrink:0}}),l(x.label)]})]})]}),b={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:k||t?"pointer":void 0},y=M=>{let C=M.currentTarget,_=th[c];C.style.borderColor=_.border,C.style.boxShadow=_.shadow,i?.(e);},N=M=>{let C=M.currentTarget;C.style.borderColor="rgba(39,39,42,0.6)",C.style.boxShadow="none";};return k&&s?jsx(s,{href:k,className:"group match-card",children:jsx("div",{style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),children:S})}):jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),onKeyDown:M=>{t&&(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),t(e));},children:S})}function dh(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Fl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:a}=useTranslation(),s=Ut(e.source),l=sh(e.source),u=e.best_price,p=e.outcomes?.[0]?.label??null,d=e.external_url??r,f=rh(e.age_seconds),c=h=>{h.stopPropagation();},m=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:m?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxs(Fragment,{children:[t?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:s.label}),f&&jsx("span",{title:e.age_seconds!=null?a("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:nh[f],flexShrink:0}})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[p&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[ki(e.vol_24h_usd)," ",a("predict.matches.vol24h")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:a("predict.matches.centsYes")})]}),d?jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer","aria-label":a("predict.matches.viewOn",{platform:s.label}),title:a("predict.matches.viewOn",{platform:s.label}),onClick:h=>h.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:h=>{h.currentTarget.style.color="#d4d4d8",h.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:h=>{h.currentTarget.style.color="#71717a",h.currentTarget.style.background="transparent";},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})}):jsx("span",{style:{width:18,flexShrink:0}})]});return n&&i?jsx(i,{href:n,className:"match-card-leg-link",onClick:h=>{c(h),o?.();},children:jsx("div",{style:g,children:v})}):m?jsx("div",{role:"link",tabIndex:0,style:g,onClick:h=>{c(h),o?.();},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),c(h),o?.());},children:v}):jsx("div",{style:g,children:v})}var Vl=forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onSelect:u,onHover:p,getMarketHref:d,LinkComponent:f,onStatsChange:c},m){let{t:g}=useTranslation(),{data:v,hasNextPage:h,fetchNextPage:x,isFetchingNextPage:k,isLoading:S,isPlaceholderData:b,refetch:y}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[N,M]=useState(0),[C,_]=useState(false);C&&!b?(_(false),M(te=>te+1)):b&&!C&&_(true),useImperativeHandle(m,()=>({refetch:()=>{y();}}),[y]);let F=useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),U=v?.pages[0]?.total,Q=useMemo(()=>{let te=0,P=0,T=0;for(let z of F){let J=z.spread??0;J>te&&(te=J),J>=.03&&T++,z.combined_volume!=null&&(P+=z.combined_volume);}return {activePairs:U??F.length,maxSpread:te,highSpreadCount:T,totalVolume:P}},[F,U]);useEffect(()=>{Q.activePairs>0&&c?.(Q);},[Q,c]);let B=useRef(null),Y=useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(useEffect(()=>{let te=B.current;if(!te)return;let P=new IntersectionObserver(T=>{T[0]?.isIntersecting&&h&&!k&&x();},{rootMargin:"200px"});return P.observe(te),()=>P.disconnect()},[h,k,x]),useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),S)return jsx(bh,{});if(F.length===0)return jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let q=!h&&F.length>0;return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
128
128
|
@media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
|
|
129
129
|
@keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
130
|
-
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:h?.pages.map(re=>re.items?.map((w,M)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${M*35}ms both`},children:jsx(Il,{match:w,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:c,onHover:p,onSelect:u,getMarketHref:d,LinkComponent:f})},`${P}-${w.match_id}-${w.source_a}-${w.market_a?.slug??M}`)))}),jsxs("div",{ref:G,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)}}"}),N&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),Q&&jsx(sh,{onScrollToTop:Y})]})});function sh({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 ah(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(lh,{index:t},t))})]})}function lh({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var fh={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function gh(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsx("span",{children:e})}function hh({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(gh,{})]})]})]})]})}function ow({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:c}){let{t:u}=useTranslation(),[p,d]=useState("spread"),[f,l]=useState(false),[m,g]=useState(void 0),[h,v]=useState(),b=useRef(null),N=useCallback(P=>{d(P);},[]),k=useCallback(P=>{l(P);},[]),x=useCallback(P=>{startTransition(()=>{v(P);});},[]),y=useCallback(()=>{b.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
130
|
+
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:v?.pages.map(te=>te.items?.map((P,T)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${T*35}ms both`},children:jsx(zl,{match:P,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onHover:p,onSelect:u,getMarketHref:d,LinkComponent:f})},`${N}-${P.match_id}-${P.source_a}-${P.market_a?.slug??T}`)))}),jsxs("div",{ref:B,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)}}"}),k&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),q&&jsx(vh,{onScrollToTop:Y})]})});function vh({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 bh(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(xh,{index:t},t))})]})}function xh({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 Nh={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Ch(){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 Mh({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:formatAmount(e.activePairs)})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(Ch,{})]})]})]})]})}function fw({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,bgImageSrc:l}){let{t:u}=useTranslation(),[p,d]=useState("spread"),[f,c]=useState(false),[m,g]=useState(void 0),[v,h]=useState(),x=useRef(null),k=useCallback(N=>{d(N);},[]),S=useCallback(N=>{c(N);},[]),b=useCallback(N=>{startTransition(()=>{h(N);});},[]),y=useCallback(()=>{x.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
131
131
|
@keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
|
|
132
132
|
.match-fade-in{animation:matchFadeIn .5s ease-out both}
|
|
133
133
|
.match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
|
|
134
134
|
.match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
|
|
135
|
-
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[c&&jsx("img",{src:c,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(Tl,{stats:h})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(fh[p])}),h&&h.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:h.activePairs})})]})]}),jsx(Cl,{sortBy:p,onSortChange:N,sortAsc:f,onSortAscChange:k,minVolume:m,onMinVolumeChange:g,onRefresh:y})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:u("predict.matches.experimentalFeature")})," \u2014 ",u("predict.matches.disclaimer")]})]}),jsx(Bl,{ref:b,sortBy:p,sortAsc:f,minVolume:m,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:x})]}),jsx(hh,{stats:h})]})}function vi(e){return e==null?"-":formatAmountInUsd(e)}var xh={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"}},yh={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 kh(e){return xh[e]??yh}function Sh(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let o of e.matched_markets){let n=o.spread??0;n>r&&(r=n,t=o);}return t}function wh(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),n=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let c=a.outcomes[0];return {name:c.label||null,price:c.best_ask??c.price??null}},i=n(t?.market_a),s=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:o?.event?.volume??null,event:o?.event}]}function uw({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=useTranslation(),i=useMemo(()=>Sh(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,c]=useMemo(()=>wh(e,i),[e,i]),u=s!=null&&s>=3;a.yesPrice!=null&&c.yesPrice!=null?a.source==="kalshi"?a.yesPrice>c.yesPrice:c.yesPrice>a.yesPrice:false;let d=a.yesPrice!=null&&c.yesPrice!=null?a.yesPrice<=c.yesPrice?a:c:null,f=d?Ut(d.source):null,l=u?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:m=>{let g=m.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:m=>{let g=m.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 ${u?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#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(Wl,{data:a,isCheaper:d===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(Wl,{data:c,isCheaper:d===c,onSelect:t,getEventHref:r,LinkComponent:o})]}),d&&f&&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 ${l==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:l==="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:l==="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:l==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("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:l==="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"})]}),vi(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"})}),vi(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",n("predict.matches.match")]})]})]})}function Wl({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=useTranslation(),s=Ut(e.source),a=kh(e.source),c=e.event?o?.(e.event):void 0,u=jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:c||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:a.text,textTransform:"uppercase"},children:s.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[vi(e.volume)," ",i("predict.matches.volume")]})]});return c&&n?jsx(n,{href:c,className:"block",children:u}):u}function Mh(e){return formatAmountInUsd(e)}function vw({matches:e,total:t}){let{t:r}=useTranslation(),o=useMemo(()=>{let n=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>n&&(n=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let c of a.entries)s.add(typeof c.source=="string"?c.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:i,platformCount:s.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(co,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(bi,{}),jsx(co,{label:r("predict.matches.stats.totalVolume"),value:Mh(o.totalVolume)}),jsx(bi,{}),jsx(co,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(bi,{}),jsx(co,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function co({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 bi(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Kl(e){return `${(e*100).toFixed(1)}\xA2`}function Th(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function kw({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxs("div",{className:cn("flex items-center gap-x-2",r),children:[jsx("span",{className:cn("text-sm font-semibold",Th(e)),children:Kl(e)}),o&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",Kl(t)]})]})}var mn=10,Oh=64,Gl=40,uo=48;function Yl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,i]=useState(1),{data:s,isLoading:a,fetchNextPage:c,hasNextPage:u,isFetchingNextPage:p}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:d,isLoading:f,fetchNextPage:l,hasNextPage:m,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),h=a||f,v=p||g,b=u||m,N=useMemo(()=>{let K=[];return s?.pages&&K.push(...s.pages.flatMap(W=>W.items)),d?.pages&&K.push(...d.pages.flatMap(W=>W.items)),K.sort((W,G)=>(G.timestamp??0)-(W.timestamp??0)),K},[s,d]),k=Math.max(1,Math.ceil(N.length/mn)+(b?1:0)),x=(n-1)*mn,y=N.slice(x,x+mn),P=useCallback(()=>{i(K=>Math.max(1,K-1));},[]),S=useCallback(async()=>{n*mn>=N.length&&b&&(u&&await c(),m&&await l()),i(W=>W+1);},[n,N.length,b,u,m,c,l]),R=n>1,I=n*mn<N.length||b;if(h)return jsx(zh,{height:r});if(N.length===0&&!b)return jsx(Hh,{message:o("predict.profile.noHistory"),height:r});let z=r-Gl-uo;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:Gl},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:o("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:z},children:[y.map((K,W)=>jsx(Dh,{trade:K},K.id??`${x+W}`)),v&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:uo},children:[jsxs("button",{type:"button",disabled:!R,onClick:P,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(k,5)},(K,W)=>{let G=W+1;return jsx("button",{type:"button",onClick:()=>i(G),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",G===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:G},G)}),jsxs("button",{type:"button",disabled:!I,onClick:S,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",I?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[o("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-uo},children:y.map((K,W)=>jsx(Ah,{trade:K},K.id??`m-${x+W}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:uo},children:[jsx("button",{type:"button",disabled:!R,onClick:P,className:cn("text-sm cursor-pointer",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!I,onClick:S,className:cn("text-sm cursor-pointer",I?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Dh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Ql(e.type,t),a=r||o,c=a?"+":"-",u=a?"text-success":"text-foreground",p=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.outcome??"",l=ec(e.timestamp),m=Xl(e),g=Fh(e),h=Bh(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Oh},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:[d&&jsx("img",{src:d,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:p}),jsxs("span",{className:"text-[11px] text-neutral",children:[f&&jsx("span",{className:"mr-1",children:f}),jsx("span",{children:l})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Zl(n)}),jsx("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",u),children:i>0?jsxs(Fragment,{children:[c,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:h!==null?`$${h.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:m&&jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Jl,{})})})]})}function Ah({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Ql(e.type,t),a=e.event?.title??e.market?.question??"\u2014",c=ec(e.timestamp),u=Xl(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:c})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn("font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:Zl(n)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),u&&jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Jl,{})})]})]})}function Ql(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 Xl(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Fh(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function Bh(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function Jl(){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 Hh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function zh({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 Zl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ec(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),c=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${c}${u})`}var fn=10,qh=64,rc=40,po=48;function oc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[i,s]=useState(1),{data:a,isLoading:c,fetchNextPage:u,hasNextPage:p,isFetchingNextPage:d}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:l,fetchNextPage:m,hasNextPage:g,isFetchingNextPage:h}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),v=c||l,b=d||h,N=p||g,k=useMemo(()=>{let G=[],Y=new Set(["live","open","submitted","pending"]);return a?.pages&&G.push(...a.pages.flatMap(Q=>Q.items).filter(Q=>Y.has(Q.status))),f?.pages&&G.push(...f.pages.flatMap(Q=>Q.items).filter(Q=>Y.has(Q.status))),G},[a,f]),x=useCallback(G=>{n.mutate({source:G.source,id:G.id});},[n]),y=Math.max(1,Math.ceil(k.length/fn)+(N?1:0)),P=(i-1)*fn,S=k.slice(P,P+fn),R=useCallback(()=>{s(G=>Math.max(1,G-1));},[]),I=useCallback(async()=>{i*fn>=k.length&&N&&(p&&await u(),g&&await m()),s(Y=>Y+1);},[i,k.length,N,p,g,u,m]),z=i>1,K=i*fn<k.length||N;if(v)return jsx(Xh,{height:r});if(k.length===0&&!N)return jsx(Qh,{message:o("predict.profile.noOrders"),height:r});let W=r-rc-po;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:rc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:W},children:[S.map(G=>jsx(Gh,{order:G,onCancel:x},G.id)),b&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(nc,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:z,canGoNext:K,onPrev:R,onNext:I,onPage:s,t:o}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-po},children:S.map(G=>jsx(Yh,{order:G,onCancel:x},G.id))}),jsx(nc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:z,canGoNext:K,onPrev:R,onNext:I,onPage:s,t:o,compact:true})]})}function Gh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:qh},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",o?"text-success":"text-danger"),children:r(o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?ic(n):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function Yh({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?ic(n):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function nc({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,t:c,compact:u}){return u?jsxs("div",{className:cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:po},children:[jsx("button",{type:"button",disabled:!o,onClick:i,className:cn("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!n,onClick:s,className:cn("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:po},children:[jsxs("button",{type:"button",disabled:!o,onClick:i,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",c("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,d)=>{let f=d+1;return jsx("button",{type:"button",onClick:()=>a(f),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",f===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:f},f)}),jsxs("button",{type:"button",disabled:!n,onClick:s,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[c("predict.profile.next")," \u2192"]})]})}function Qh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Xh({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 ic(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var wi=10,tv=64,sc=40,mo=48;function ac({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:i}=useTranslation(),[s,a]=useState(1),c=useCallback(()=>{for(let g of e)o?.(g);},[e,o]);if(t)return jsx(iv,{height:r});if(e.length===0)return jsx(ov,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/wi)),p=(s-1)*wi,d=e.slice(p,p+wi),f=s>1,l=s<u,m=r-sc-mo;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:sc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:o&&e.length>0&&jsx("button",{type:"button",onClick:c,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:m},children:d.map((g,h)=>jsx(rv,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??p+h}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:mo},children:[jsxs("button",{type:"button",disabled:!f,onClick:()=>a(g=>Math.max(1,g-1)),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,h)=>{let v=h+1;return jsx("button",{type:"button",onClick:()=>a(v),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",v===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:v},v)}),jsxs("button",{type:"button",disabled:!l,onClick:()=>a(g=>g+1),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",l?"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-mo},children:d.map((g,h)=>jsx(nv,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${p+h}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:mo},children:[jsx("button",{type:"button",disabled:!f,onClick:()=>a(g=>Math.max(1,g-1)),className:cn("text-sm cursor-pointer",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsx("button",{type:"button",disabled:!l,onClick:()=>a(g=>g+1),className:cn("text-sm cursor-pointer",l?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function rv({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,c=e.current_value??e.size*a,u=e.size,p=n>0?"text-success":n<0?"text-danger":"text-foreground",d=n>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",l=e.event?.image_url,m=e.side,g=e.market?.outcomes?.[0]?.label??"",h=e.market?.end_at?sv(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:tv},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:[l&&jsx("img",{src:l,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:f}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn("font-medium",m.toLowerCase()==="yes"?"text-success":"text-danger"),children:m}),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:["$",c.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:o("predict.profile.contracts",{count:qr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Pi(s)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Pi(a)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",p),children:[jsxs("span",{children:[d,"$",Math.abs(n).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:["$",u.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"}),o("predict.profile.close")]})})]})}function nv({position:e,onClose:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=n>0?"text-success":n<0?"text-danger":"text-foreground",c=n>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsx("span",{className:cn("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(fo,{label:o("predict.profile.totalSize"),value:qr(e.size)}),jsx(fo,{label:o("predict.profile.markPrice"),value:Pi(s)}),jsx(fo,{label:o("predict.profile.pnl"),value:`${c}$${Math.abs(n).toFixed(2)} (${c}${i.toFixed(1)}%)`,className:a}),jsx(fo,{label:o("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:o("predict.profile.close")})})]})}function fo({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn("font-mono text-foreground",r),children:t})]})}function ov({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function iv({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Pi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function sv(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),c=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${c}${u})`}catch{return "\u2014"}}function cc({positions:e,trades:t,isLoading:r}){let{t:o}=useTranslation(),n=useMemo(()=>{let a=0,c=0;for(let l of e)a+=l.realized_pnl??0,c+=l.current_value??l.size*(l.current_price??0);let u=0,p=0,d=0;for(let l of t)u+=l.usd_size??0,l.type==="REDEEM"&&(d++,(l.usd_size??0)>0&&p++);let f=d>0?`${p} / ${d}`:"0 / 0";return {realizedPnl:a,positionsValue:c,volume:u,winRateStr:f}},[e,t]),i=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",s=n.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:o("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn("text-5xl font-bold tabular-nums",i),children:[s,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Ci,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsx(Ci,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Ci,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function Ci({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 Mi=600;function fv({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[i,s]=useState("positions"),a=!!(e||t),{data:c,isLoading:u}=usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:d}=usePositions({source:"polymarket",user:t??""}),f=useMemo(()=>{let P=[];return c?.positions&&P.push(...c.positions),p?.positions&&P.push(...p.positions),P},[c,p]),l=u||d,{data:m,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:v}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),b=useMemo(()=>[...m?.pages?.flatMap(S=>S.items)??[],...h?.pages?.flatMap(S=>S.items)??[]],[m,h]),N=l||g||v,k=f.length,y=[{key:"positions",label:k>0?`${n("predict.profile.positionsTab")} (${k})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return a?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(cc,{positions:f,trades:b,isLoading:N}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(P=>jsx("button",{type:"button",onClick:()=>s(P.key),className:cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===P.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:P.label},P.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(ac,{positions:f,isLoading:l,listHeight:Mi,onClosePosition:r,onEventClick:o}),i==="orders"&&jsx(oc,{solanaAddress:e,evmAddress:t,listHeight:Mi}),i==="history"&&jsx(Yl,{solanaAddress:e,evmAddress:t,listHeight:Mi})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}function bP({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=useTranslation(),[s,a]=useState(false),[c,u]=useState(null),[p,d]=useState(false),f=r||p,l=o||p,m=f?"done":s?"running":"pending",g=l?"done":f&&s?"running":"pending",h=f&&l,v=useCallback(async()=>{u(null),d(false),a(true);try{await n(),d(!0);}catch(x){u(x instanceof Error?x.message:String(x));}finally{a(false);}},[n]),b=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:m},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],N=()=>{h?t():v();},k=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:b.map((x,y)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(xv,{index:y+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))}),c&&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:c})}),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")]}):k}),!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 xv({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
136
|
-
export{
|
|
135
|
+
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(Al,{stats:v})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(Nh[p])}),v&&v.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:v.activePairs})})]})]}),jsx(Il,{sortBy:p,onSortChange:k,sortAsc:f,onSortAscChange:S,minVolume:m,onMinVolumeChange:g,onRefresh:y})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:u("predict.matches.experimentalFeature")})," \u2014 ",u("predict.matches.disclaimer")]})]}),jsx(Vl,{ref:x,sortBy:p,sortAsc:f,minVolume:m,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,onStatsChange:b})]}),jsx(Mh,{stats:v})]})}function wi(e){return e==null?"-":formatAmountInUsd(e)}var Lh={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"}},Rh={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 _h(e){return Lh[e]??Rh}function Ih(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 Oh(e,t){let r=e.entries.find(s=>s.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(s=>s.source===(t?.source_b??e.entries[1]?.source)),o=s=>{if(!s?.outcomes?.[0])return {name:null,price:null};let l=s.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=o(t?.market_a),a=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:n?.event?.volume??null,event:n?.event}]}function kw({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=useTranslation(),i=useMemo(()=>Ih(e),[e]),a=e.max_spread!=null?e.max_spread*100:null,[s,l]=useMemo(()=>Oh(e,i),[e,i]),u=a!=null&&a>=3;s.yesPrice!=null&&l.yesPrice!=null?s.source==="kalshi"?s.yesPrice>l.yesPrice:l.yesPrice>s.yesPrice:false;let d=s.yesPrice!=null&&l.yesPrice!=null?s.yesPrice<=l.yesPrice?s:l:null,f=d?Ut(d.source):null,c=u?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:m=>{let g=m.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:m=>{let g=m.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[a!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${u?"rgba(255,185,0,0.3)":a>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":a>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":a>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),a.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(ql,{data:s,isCheaper:d===s,onSelect:t,getEventHref:r,LinkComponent:n}),jsx(ql,{data:l,isCheaper:d===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),d&&f&&a!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${c==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:c==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>d.event&&t?.(d.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:c==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:c==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:d.source.charAt(0).toUpperCase()+d.source.slice(1),spread:a.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:c==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),wi(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width: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"})}),wi(e.combined_volume_24h)," ",o("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",o("predict.matches.match")]})]})]})}function ql({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=useTranslation(),a=Ut(e.source),s=_h(e.source),l=e.event?n?.(e.event):void 0,u=jsxs("div",{style:{borderRadius:14,border:`1px solid ${s.border}`,background:s.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=s.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:s.text,textTransform:"uppercase"},children:a.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?s.priceActiveColor:s.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[wi(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsx(o,{href:l,className:"block",children:u}):u}function Bh(e){return formatAmountInUsd(e)}function Mw({matches:e,total:t}){let{t:r}=useTranslation(),n=useMemo(()=>{let o=0,i=0,a=new Set;for(let s of e){s.max_spread!=null&&s.max_spread>o&&(o=s.max_spread),s.combined_volume!=null&&(i+=s.combined_volume);for(let l of s.entries)a.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:a.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(ko,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsx(Pi,{}),jsx(ko,{label:r("predict.matches.stats.totalVolume"),value:Bh(n.totalVolume)}),jsx(Pi,{}),jsx(ko,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Pi,{}),jsx(ko,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function ko({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function Pi(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Xl(e){return `${(e*100).toFixed(1)}\xA2`}function Hh(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function Rw({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=t!=null&&t>0;return jsxs("div",{className:cn("flex items-center gap-x-2",r),children:[jsx("span",{className:cn("text-sm font-semibold",Hh(e)),children:Xl(e)}),n&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",Xl(t)]})]})}var wn=10,Vh=64,tc=40,So=48;function rc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),[o,i]=useState(1),{data:a,isLoading:s,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:p}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:d,isLoading:f,fetchNextPage:c,hasNextPage:m,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=s||f,h=p||g,x=u||m,k=useMemo(()=>{let U=[];return a?.pages&&U.push(...a.pages.flatMap(Q=>Q.items)),d?.pages&&U.push(...d.pages.flatMap(Q=>Q.items)),U.sort((Q,B)=>(B.timestamp??0)-(Q.timestamp??0)),U},[a,d]),S=Math.max(1,Math.ceil(k.length/wn)+(x?1:0)),b=(o-1)*wn,y=k.slice(b,b+wn),N=useCallback(()=>{i(U=>Math.max(1,U-1));},[]),M=useCallback(async()=>{o*wn>=k.length&&x&&(u&&await l(),m&&await c()),i(Q=>Q+1);},[o,k.length,x,u,m,l,c]),C=o>1,_=o*wn<k.length||x;if(v)return jsx(Xh,{height:r});if(k.length===0&&!x)return jsx(Qh,{message:n("predict.profile.noHistory"),height:r});let F=r-tc-So;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:tc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:F},children:[y.map((U,Q)=>jsx(jh,{trade:U},U.id??`${b+Q}`)),h&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:So},children:[jsxs("button",{type:"button",disabled:!C,onClick:N,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",C?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(S,5)},(U,Q)=>{let B=Q+1;return jsx("button",{type:"button",onClick:()=>i(B),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",B===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:B},B)}),jsxs("button",{type:"button",disabled:!_,onClick:M,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",_?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-So},children:y.map((U,Q)=>jsx(Gh,{trade:U},U.id??`m-${b+Q}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:So},children:[jsx("button",{type:"button",disabled:!C,onClick:N,className:cn("text-sm cursor-pointer",C?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:o}),jsx("button",{type:"button",disabled:!_,onClick:M,className:cn("text-sm cursor-pointer",_?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function jh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=r||n,l=s?"+":"-",u=s?"text-success":"text-foreground",p=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.outcome??"",c=ac(e.timestamp),m=oc(e),g=qh(e),v=Yh(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Vh},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:[d&&jsx("img",{src:d,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:p}),jsxs("span",{className:"text-[11px] text-neutral",children:[f&&jsx("span",{className:"mr-1",children:f}),jsx("span",{children:c})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:a}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:sc(o)}),jsx("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",u),children:i>0?jsxs(Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:m&&jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(ic,{})})})]})}function Gh({trade:e}){let{t}=useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=e.event?.title??e.market?.question??"\u2014",l=ac(e.timestamp),u=oc(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:s})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn("font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:a})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:sc(o)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),u&&jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(ic,{})})]})]})}function nc(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function oc(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function qh(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 Yh(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function ic(){return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsx("polyline",{points:"15 3 21 3 21 9"}),jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function Qh({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Xh({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function sc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ac(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}var Pn=10,ov=64,cc=40,wo=48;function uc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=useTranslation(),o=useCancelOrder(),[i,a]=useState(1),{data:s,isLoading:l,fetchNextPage:u,hasNextPage:p,isFetchingNextPage:d}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:c,fetchNextPage:m,hasNextPage:g,isFetchingNextPage:v}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||c,x=d||v,k=p||g,S=useMemo(()=>{let B=[],Y=new Set(["live","open","submitted","pending"]);return s?.pages&&B.push(...s.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),f?.pages&&B.push(...f.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),B},[s,f]),b=useCallback(B=>{o.mutate({source:B.source,id:B.id});},[o]),y=Math.max(1,Math.ceil(S.length/Pn)+(k?1:0)),N=(i-1)*Pn,M=S.slice(N,N+Pn),C=useCallback(()=>{a(B=>Math.max(1,B-1));},[]),_=useCallback(async()=>{i*Pn>=S.length&&k&&(p&&await u(),g&&await m()),a(Y=>Y+1);},[i,S.length,k,p,g,u,m]),F=i>1,U=i*Pn<S.length||k;if(h)return jsx(lv,{height:r});if(S.length===0&&!k)return jsx(av,{message:n("predict.profile.noOrders"),height:r});let Q=r-cc-wo;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:cc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:Q},children:[M.map(B=>jsx(iv,{order:B,onCancel:b},B.id)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(dc,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:F,canGoNext:U,onPrev:C,onNext:_,onPage:a,t:n}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-wo},children:M.map(B=>jsx(sv,{order:B,onCancel:b},B.id))}),jsx(dc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:F,canGoNext:U,onPrev:C,onNext:_,onPage:a,t:n,compact:true})]})}function iv({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:ov},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn("text-sm font-medium",n?"text-success":"text-danger"),children:r(n?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o>0?pc(o):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function sv({order:e,onCancel:t}){let{t:r}=useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn("text-xs font-medium px-1.5 py-0.5 rounded",n?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:o>0?pc(o):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function dc({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:a,onPage:s,t:l,compact:u}){return u?jsxs("div",{className:cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:wo},children:[jsx("button",{type:"button",disabled:!n,onClick:i,className:cn("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!o,onClick:a,className:cn("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:wo},children:[jsxs("button",{type:"button",disabled:!n,onClick:i,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,d)=>{let f=d+1;return jsx("button",{type:"button",onClick:()=>s(f),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",f===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:f},f)}),jsxs("button",{type:"button",disabled:!o,onClick:a,className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function av({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function lv({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function pc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Ei=10,pv=64,mc=40,Po=48;function fc({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=useTranslation(),[a,s]=useState(1),l=useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsx(hv,{height:r});if(e.length===0)return jsx(gv,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/Ei)),p=(a-1)*Ei,d=e.slice(p,p+Ei),f=a>1,c=a<u,m=r-mc-Po;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:mc},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:i("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:n&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:m},children:d.map((g,v)=>jsx(mv,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??p+v}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Po},children:[jsxs("button",{type:"button",disabled:!f,onClick:()=>s(g=>Math.max(1,g-1)),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,v)=>{let h=v+1;return jsx("button",{type:"button",onClick:()=>s(h),className:cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",h===a?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:h},h)}),jsxs("button",{type:"button",disabled:!c,onClick:()=>s(g=>g+1),className:cn("text-sm transition-colors cursor-pointer flex items-center gap-1",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Po},children:d.map((g,v)=>jsx(fv,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${p+v}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Po},children:[jsx("button",{type:"button",disabled:!f,onClick:()=>s(g=>Math.max(1,g-1)),className:cn("text-sm cursor-pointer",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:a}),jsx("button",{type:"button",disabled:!c,onClick:()=>s(g=>g+1),className:cn("text-sm cursor-pointer",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function mv({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.avg_price??0,s=e.current_price??0,l=e.current_value??e.size*s,u=e.size,p=o>0?"text-success":o<0?"text-danger":"text-foreground",d=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,m=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?vv(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:pv},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[c&&jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:f}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn("font-medium",m.toLowerCase()==="yes"?"text-success":"text-danger"),children:m}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count:yr(e.size)})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*a).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Li(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Li(s)}),jsxs("div",{className:cn("flex-[1.5] pr-2 text-right font-mono",p),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:["$",u.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:v}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),n("predict.profile.close")]})})]})}function fv({position:e,onClose:t,onEventClick:r}){let{t:n}=useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.current_price??0,s=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsx("span",{className:cn("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(No,{label:n("predict.profile.totalSize"),value:yr(e.size)}),jsx(No,{label:n("predict.profile.markPrice"),value:Li(a)}),jsx(No,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:s}),jsx(No,{label:n("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:n("predict.profile.close")})})]})}function No({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn("font-mono text-foreground",r),children:t})]})}function gv({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function hv({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Li(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function vv(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}catch{return "\u2014"}}function hc({positions:e,trades:t,isLoading:r}){let{t:n}=useTranslation(),o=useMemo(()=>{let s=0,l=0;for(let c of e)s+=c.realized_pnl??0,l+=c.current_value??c.size*(c.current_price??0);let u=0,p=0,d=0;for(let c of t)u+=c.usd_size??0,c.type==="REDEEM"&&(d++,(c.usd_size??0)>0&&p++);let f=d>0?`${p} / ${d}`:"0 / 0";return {realizedPnl:s,positionsValue:l,volume:u,winRateStr:f}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",a=o.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:n("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn("text-5xl font-bold tabular-nums",i),children:[a,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(_i,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsx(_i,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsx(_i,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function _i({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 Ii=600;function Nv({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=useTranslation(),[i,a]=useState("positions"),s=!!(e||t),{data:l,isLoading:u}=usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:d}=usePositions({source:"polymarket",user:t??""}),f=useMemo(()=>{let N=[];return l?.positions&&N.push(...l.positions),p?.positions&&N.push(...p.positions),N},[l,p]),c=u||d,{data:m,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:h}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),x=useMemo(()=>[...m?.pages?.flatMap(M=>M.items)??[],...v?.pages?.flatMap(M=>M.items)??[]],[m,v]),k=c||g||h,S=f.length,y=[{key:"positions",label:S>0?`${o("predict.profile.positionsTab")} (${S})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return s?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(hc,{positions:f,trades:x,isLoading:k}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(N=>jsx("button",{type:"button",onClick:()=>a(N.key),className:cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===N.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:N.label},N.key))}),jsxs("div",{className:"py-2",children:[i==="positions"&&jsx(fc,{positions:f,isLoading:c,listHeight:Ii,onClosePosition:r,onEventClick:n}),i==="orders"&&jsx(uc,{solanaAddress:e,evmAddress:t,listHeight:Ii}),i==="history"&&jsx(rc,{solanaAddress:e,evmAddress:t,listHeight:Ii})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function TP({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=useTranslation(),[a,s]=useState(false),[l,u]=useState(null),[p,d]=useState(false),f=r||p,c=n||p,m=f?"done":a?"running":"pending",g=c?"done":f&&a?"running":"pending",v=f&&c,h=useCallback(async()=>{u(null),d(false),s(true);try{await o(),d(!0);}catch(b){u(b instanceof Error?b.message:String(b));}finally{s(false);}},[o]),x=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:m},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],k=()=>{v?t():h();},S=i(v?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:b=>{b||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:i("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:i("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:x.map((b,y)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Lv,{index:y+1,status:b.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:b.label}),jsx("span",{className:`text-[11px] leading-none ${b.status==="done"?"text-[#c7ff2e]":b.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:b.status==="done"?i("predict.setup.stepComplete"):b.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:b.desc})]})]},b.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:k,disabled:a,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):S}),!v&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function Lv({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
136
|
+
export{qv as CHART_RANGE_DURATION,jv as CHART_RANGE_PERIOD,Gv as CHART_RANGE_SAMPLE_INTERVAL,Bn as CandlestickPeriod,Dv as CategoriesSkeleton,Hi as CategoriesUI,$i as CategoriesWidget,ce as ChartRange,mi as CommentItemUI,Hn as DEFAULT_CHART_RANGE,sn as DEFAULT_FILTER_STATE,rn as DEFAULT_PAGE_SIZE,Jv as DEFAULT_PRICE_HISTORY_INTERVAL,_g as EventCommentsWidget,b2 as EventDetailPage,fn as EventDetailSkeleton,Va as EventDetailUI,ja as EventDetailWidget,Os as EventItem,Na as EventMarketDepthChartUI,_a as EventMarketDetailWidget,Da as EventPriceChart,ps as EventsFilterUI,jx as EventsHero,Wx as EventsPage,mx as EventsPageSkeleton,$o as EventsSkeleton,bs as EventsToolbarUI,Hs as EventsUI,Ws as EventsWidget,jn as KycModal,Ao as MAX_PRICE_HISTORY_MARKETS,kw as MatchGroupCard,zl as MatchMarketCard,Il as MatchesFilterBar,Al as MatchesHero,fw as MatchesPage,Mw as MatchesStatsBar,Vl as MatchesWidget,Xv as ORDER_MAX_PRICE,Qv as ORDER_MIN_PRICE,zn as ORDER_MIN_QUANTITY,Wn as ORDER_MIN_USDC,Yv as ORDER_PRICE_STEP,Kc as POLYMARKET_BUILDER_TAKER_FEE_BPS,Vc as POLYMARKET_SPORTS_TAKER_FEE_BPS,kp as PREDICT_REDEEM_MODAL_ID,bi as PREDICT_SEARCH_MODAL_ID,Zo as PREDICT_SELL_MODAL_ID,on as PREDICT_TRADE_MODAL_ID,Zv as PRICE_HISTORY_SAMPLE_INTERVAL,Xs as PredictRedeemModal,bS as PredictSearchModal,pa as PredictSellModal,Yn as PredictTradeModal,zc as PredictWalletProvider,Br as PriceHistoryInterval,Nv as ProfilePage,Ys as RedeemFormWidget,vs as SORT_PRESETS,Io as STATIC_CATEGORIES,MS as SearchEventsButton,ll as SearchHistoryUI,cl as SearchHistoryWidget,dl as SearchInputUI,ul as SearchResultItemUI,hl as SearchResultListWidget,kl as SearchWidget,da as SellFormUI,no as SellFormWidget,TP as SetupModal,eg as SimilarEventCard,Qa as SimilarEventsSection,G1 as SourceBadge,Rw as SpreadIndicator,ba as TradeFormSkeleton,ds as TradeFormUI,qn as TradeFormWidget,ga as UserActivitySection,qi as computeMaxBuyAmount,Uo as countActiveFilters,zr as createTradeResultToast,Yi as estimatePolymarketBuyFee,Qi as estimatePolymarketSellFee,Xi as fireCelebration,xe as floorToDecimals,gn as formatKMB,yr as formatShares,Ut as getSourceMeta,Kn as parsePolymarketError,$c as polymarketFeeFactor,Un as resolveExpiration,Gi as resolvePolymarketDisplayFeeRateBps,$n as roundToTickSize,N2 as useEventDetail,ks as useEventsInfinite,bo as usePredictSearchHistory,xr as usePredictWallet,pl as useSearchResultListScript,yl as useSearchScript,ta as useSellForm,ts as useTradeForm};//# sourceMappingURL=index.mjs.map
|
|
137
137
|
//# sourceMappingURL=index.mjs.map
|