@liberfi.io/ui-predict 0.1.58 → 0.1.59
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var react=require('react'),reactQuery=require('@tanstack/react-query'),i18n=require('@liberfi.io/i18n'),ui$1=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),utils=require('@liberfi.io/utils'),walletConnector=require('@liberfi.io/wallet-connector'),lr=require('canvas-confetti'),types=require('@liberfi.io/types'),react$1=require('@liberfi.io/react'),recharts=require('recharts'),uiScaffold=require('@liberfi.io/ui-scaffold'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var lr__default=/*#__PURE__*/_interopDefault(lr);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.58");var Fo="0.1.58";var pt=react.createContext(null);function Ur(){let e=react.useContext(pt);if(!e)throw new Error("usePredictV2Context must be used within a PredictV2Provider");return e}function be(){let{client:e}=Ur();return e}function Ko(e){return ["predict-v2","events",e??{}]}async function $o(e,t){return e.listEvents(t)}function Mm(e,t={}){let r=be();return reactQuery.useQuery({queryKey:Ko(e),queryFn:()=>$o(r,e),...t})}function Go(e){return ["predict-v2","event",e]}async function Yo(e,t){return e.getEvent(t)}function Im(e,t={}){let r=be();return reactQuery.useQuery({queryKey:Go(e.slug),queryFn:()=>Yo(r,e.slug),enabled:!!e.slug,...t})}function Zo(e){return ["predict-v2","search",e]}function _r(e,t){let r=be(),n=react.useMemo(()=>({search:e.keyword,limit:e.limit??20,status:e.status??"open",source:e.source,with_markets:e.with_markets??false}),[e.keyword,e.limit,e.status,e.source,e.with_markets]);return reactQuery.useInfiniteQuery({queryKey:Zo(n),queryFn:({pageParam:s})=>r.listEvents({...n,...s!==void 0?{cursor:s}:{}}),initialPageParam:void 0,getNextPageParam:s=>s.has_more&&s.next_cursor?s.next_cursor:void 0,enabled:t?.enabled??!!e.keyword})}var Ve=react.createContext({});var ke=react.createContext(null);function Vr(){let e=react.useContext(Ve);if(!e)throw new Error("usePredictContext must be used within a PredictProvider");return e}function b(){let{client:e}=Vr();return e}function ni(e){return ["predict","events",e??{}]}async function At(e,t){return await e.getEvents(t)}function of(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ni(e),queryFn:async()=>At(r,e),...t})}function oi(e){return ["predict","events","infinite",e??{}]}function Ar(e={},t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:oi(e),queryFn:async({pageParam:n})=>At(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:n=>n.cursor??void 0,...t})}function ai(e){return ["predict","event","byId",e.id,e.withNestedMarkets]}async function li(e,t){return await e.getEventById(t.id,t.withNestedMarkets)}function mt(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ai(e),queryFn:async()=>li(r,e),...t})}function ui(e){return ["predict","markets",e??{}]}async function di(e,t){return await e.getMarkets(t)}function vf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ui(e),queryFn:async()=>di(r,e),...t})}function mi(e){return ["predict","market","byId",e.id]}async function fi(e,t){return await e.getMarketById(t.id)}function kf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:mi(e),queryFn:async()=>fi(r,e),...t})}function gi(e){return ["predict","market","byMint",e]}async function vi(e,t){return await e.getMarketByMint(t)}function Ef(e,t={}){let r=b();return reactQuery.useQuery({queryKey:gi(e),queryFn:async()=>vi(r,e),...t})}function hi(e){return ["predict","markets","batch",e]}async function bi(e,t){return await e.getMarketsBatch(t)}function Nf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:hi(e),queryFn:async()=>bi(r,e),enabled:!!(e.tickers?.length||e.mints?.length),...t})}function ki(e){return ["predict","orderBook",e]}async function Pi(e,t){return await e.getOrderbook(t)}function Ae(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ki(e),queryFn:async()=>Pi(r,e),...t})}function Si(e){return ["predict","orderBook","byMint",e]}async function Ci(e,t){return await e.getOrderbookByMint(t)}function Lf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Si(e),queryFn:async()=>Ci(r,e),...t})}function Ei(e){return ["predict","trades",e??{}]}async function wi(e,t){return await e.getTrades(t)}function Wr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ei(e),queryFn:async()=>wi(r,e),...t})}function Ti(e){return ["predict","trades","byMint",e]}async function Mi(e,t){return await e.getTradesByMint(t)}function _f(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ti(e),queryFn:async()=>Mi(r,e),...t})}function Ni(e){return ["predict","onchainTrades","byWallet",e]}async function Ft(e,t){return await e.getOnchainTradesByWallet(t)}function qr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ni(e),queryFn:async()=>Ft(r,e),...t})}function Ri(e){return ["predict","onchainTrades","byEvent",e]}async function Wt(e,t){return await e.getOnchainTradesByEvent(t)}function Ff(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ri(e),queryFn:async()=>Wt(r,e),...t})}function Oi(e){return ["predict","onchainTrades","byMarket",e]}async function qt(e,t){return await e.getOnchainTradesByMarket(t)}function Wf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Oi(e),queryFn:async()=>qt(r,e),...t})}function Kt(e){return e.cursor??void 0}function Ii(e){return ["predict","onchainTrades","byWallet","infinite",e]}function zf(e,t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:Ii(e),queryFn:async({pageParam:n})=>Ft(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kt,...t})}function Li(e){return ["predict","onchainTrades","byEvent","infinite",e]}function Gf(e,t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:Li(e),queryFn:async({pageParam:n})=>Wt(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kt,...t})}function Bi(e){return ["predict","onchainTrades","byMarket","infinite",e]}function Yf(e,t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:Bi(e),queryFn:async({pageParam:n})=>qt(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kt,...t})}function Qi(e){return ["predict","candlesticks","event",e]}async function Ui(e,t){let{ticker:r,...n}=t;return await e.getEventCandlesticks(r,n)}function Jf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Qi(e),queryFn:async()=>Ui(r,e),...t})}function zt(e){return ["predict","candlesticks","market",e]}async function Gt(e,t){let{ticker:r,...n}=t;return await e.getMarketCandlesticks(r,n)}function Yt(e,t={}){let r=b();return reactQuery.useQuery({queryKey:zt(e),queryFn:async()=>Gt(r,e),...t})}function _i(e){return ["predict","candlesticks","market","byMint",e]}async function Vi(e,t){let{mintAddress:r,...n}=t;return await e.getMarketCandlesticksByMint(r,n)}function ey(e,t={}){let r=b();return reactQuery.useQuery({queryKey:_i(e),queryFn:async()=>Vi(r,e),...t})}var ty=Yt;function Ai(e){return ["predict","forecast","percentileHistory",e]}async function Di(e,t){return await e.getEventForecastPercentileHistory(t)}function oy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ai(e),queryFn:async()=>Di(r,e),...t})}function Fi(e){return ["predict","forecast","percentileHistory","byMint",e]}async function Wi(e,t){return await e.getEventForecastPercentileHistoryByMint(t)}function iy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Fi(e),queryFn:async()=>Wi(r,e),...t})}function qi(e){return ["predict","liveData",e]}async function Hi(e,t){return await e.getLiveData(t)}function uy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:qi(e),queryFn:async()=>Hi(r,e),enabled:e.milestoneIds.length>0,...t})}function Ki(e){return ["predict","liveData","byEvent",e]}async function $i(e,t){return await e.getLiveDataByEvent(t)}function dy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ki(e),queryFn:async()=>$i(r,e),enabled:!!e.eventTicker,...t})}function zi(e){return ["predict","liveData","byMint",e]}async function Gi(e,t){return await e.getLiveDataByMint(t)}function py(e,t={}){let r=b();return reactQuery.useQuery({queryKey:zi(e),queryFn:async()=>Gi(r,e),enabled:!!e.mintAddress,...t})}function Yi(e){return ["predict","series",e??{}]}async function Xi(e,t){return await e.getSeries(t)}function $r(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Yi(e),queryFn:async()=>Xi(r,e),...t})}function ji(e){return ["predict","series","byTicker",e]}async function Zi(e,t){return await e.getSeriesByTicker(t)}function zr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ji(e),queryFn:async()=>Zi(r,e),...t})}function Ji(){return ["predict","tags","byCategories"]}async function ea(e){return await e.getTagsByCategories()}function jt(e={}){let t=b();return reactQuery.useQuery({queryKey:Ji(),queryFn:async()=>ea(t),...e})}function ta(){return ["predict","filters","bySports"]}async function ra(e){return await e.getFiltersBySports()}function hy(e={}){let t=b();return reactQuery.useQuery({queryKey:ta(),queryFn:async()=>ra(t),...e})}var by=jt;function sa(e){return ["predict","search",e]}async function oa(e,t){return await e.search(t)}function Cy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:sa(e),queryFn:async()=>oa(r,e),...t})}function aa(e){return ["predict","positions","byWallet",e]}async function la(e,t){return await e.getPositionsByWallet(t)}function Yr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:aa(e),queryFn:async()=>la(r,e),...t})}function Oy(){let e=react.useContext(ke);if(!e)throw new Error("useUserPredictContext must be used within a UserPredictProvider");return e}function Xr(e){let t=react.useContext(ke);return react.useMemo(()=>t?{positions:t.positions.filter(n=>n.market?.ticker===e.ticker),isLoading:t.isLoading,isAvailable:true}:{positions:[],isLoading:false,isAvailable:false},[t,e.ticker])}function fa(e){return ["predict","outcomeMints",e??{}]}async function ya(e,t){return await e.getOutcomeMints(t)}function Vy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:fa(e),queryFn:async()=>ya(r,e),...t})}async function ga(e,t){return await e.filterOutcomeMints(t)}function Ay(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>ga(t,r),...e})}function xa(e){return ["predict","quote",e]}async function ha(e,t){return await e.getQuote(t)}function qy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:xa(e),queryFn:async()=>ha(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}async function ba(e,t){return await e.createSwap(t)}function zy(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>ba(t,r),...e})}async function ka(e,t){return await e.createSwapInstructions(t)}function Gy(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>ka(t,r),...e})}function Pa(e){return ["predict","order",e]}async function Sa(e,t){return await e.getOrder(t)}function Jr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Pa(e),queryFn:async()=>Sa(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}function Ca(e){return ["predict","order","status",e.signature]}async function Ea(e,t){return await e.getOrderStatus(t)}function en(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ca(e),queryFn:async()=>Ea(r,e),enabled:!!e.signature,refetchInterval:t.refetchInterval??3e3,retry:false,...t})}function Ma(e){return ["predict","intent","quote",e]}async function Na(e,t){return await e.getIntentQuote(t)}function tg(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ma(e),queryFn:async()=>Na(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}async function Ra(e,t){return await e.submitIntentSwap(t)}function rg(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>Ra(t,r),...e})}async function Ia(e,t){return await e.initPredictionMarket(t)}function ig(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>Ia(t,r),...e})}function La(){return ["predict","tokens"]}async function Ba(e){return await e.getTokens()}function ug(e={}){let t=b();return reactQuery.useQuery({queryKey:La(),queryFn:async()=>Ba(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}function Qa(){return ["predict","tokens","decimals"]}async function Ua(e){return await e.getTokensWithDecimals()}function dg(e={}){let t=b();return reactQuery.useQuery({queryKey:Qa(),queryFn:async()=>Ua(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}function Va(){return ["predict","venues"]}async function Aa(e){return await e.getVenues()}function yg(e={}){let t=b();return reactQuery.useQuery({queryKey:Va(),queryFn:async()=>Aa(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}var Ge=class{ws=null;wsUrl;autoReconnect;reconnectIntervalBase;reconnectMaxInterval;pingInterval;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;pingIntervalId=null;shouldReconnect=true;listeners={connect:[],disconnect:[],reconnecting:[],error:[],price:[],trade:[],orderbook:[],status:[],subscribed:[],unsubscribed:[]};subscriptions={prices:{all:false,tickers:new Set},trades:{all:false,tickers:new Set},orderbook:{all:false,tickers:new Set}};constructor(t){this.wsUrl=t.wsUrl,this.autoReconnect=t.autoReconnect??true,this.reconnectIntervalBase=t.reconnectIntervalBase??1e3,this.reconnectMaxInterval=t.reconnectMaxInterval??3e4,this.pingInterval=t.pingInterval??3e4,t.autoConnect!==false&&this.connect();}connect(){if(!(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))){this.shouldReconnect=true,this.setStatus("connecting");try{this.ws=new WebSocket(this.wsUrl),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus("connected"),this.emit("connect",void 0),this.restoreSubscriptions(),this.startPingInterval();},this.ws.onmessage=t=>{this.handleMessage(t.data);},this.ws.onerror=t=>{let r=new Error("WebSocket error");this.emit("error",r);},this.ws.onclose=t=>{this.stopPingInterval(),this.setStatus("disconnected"),this.emit("disconnect",{code:t.code,reason:t.reason}),this.shouldReconnect&&this.autoReconnect&&this.scheduleReconnect();};}catch(t){this.emit("error",t instanceof Error?t:new Error(String(t))),this.shouldReconnect&&this.autoReconnect&&this.scheduleReconnect();}}}disconnect(){this.shouldReconnect=false,this.stopPingInterval(),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus("disconnected");}isConnected(){return this.ws!==null&&this.ws.readyState===WebSocket.OPEN}getStatus(){return this.status}subscribePrices(t,r){this.subscribeChannel("prices",t);let n=this.on("price",r);return ()=>{n(),this.unsubscribeChannel("prices",t);}}subscribeTrades(t,r){this.subscribeChannel("trades",t);let n=this.on("trade",r);return ()=>{n(),this.unsubscribeChannel("trades",t);}}subscribeOrderbook(t,r){this.subscribeChannel("orderbook",t);let n=this.on("orderbook",r);return ()=>{n(),this.unsubscribeChannel("orderbook",t);}}onStatusChange(t){return this.on("status",t)}on(t,r){return this.listeners[t].push(r),()=>{this.off(t,r);}}off(t,r){let n=this.listeners[t],s=n.indexOf(r);s!==-1&&n.splice(s,1);}removeAllListeners(t){if(t)this.listeners[t].length=0;else for(let r of Object.keys(this.listeners))this.listeners[r].length=0;}subscribeChannel(t,r){let n=this.subscriptions[t];if(r.all)n.all=true,n.tickers.clear();else if(r.tickers&&r.tickers.length>0){n.all=false;for(let s of r.tickers)n.tickers.add(s);}this.sendSubscription("subscribe",t,r);}unsubscribeChannel(t,r){let n=this.subscriptions[t];if(r.all)n.all=false,n.tickers.clear();else if(r.tickers&&r.tickers.length>0)for(let s of r.tickers)n.tickers.delete(s);this.sendSubscription("unsubscribe",t,r);}setStatus(t){this.status!==t&&(this.status=t,this.emit("status",t));}emit(t,r){let n=this.listeners[t];for(let s of n)try{s(r);}catch{}}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return false;try{return this.ws.send(JSON.stringify(t)),!0}catch{return false}}sendSubscription(t,r,n){this.send({type:t,channel:r,all:n.all,tickers:n.tickers});}handleMessage(t){try{let r=JSON.parse(t);switch(r.type){case "ticker":this.emit("price",r);break;case "trade":this.emit("trade",r);break;case "orderbook":this.emit("orderbook",r);break;case "status":break;case "subscribed":this.emit("subscribed",{channel:r.channel,all:r.all,tickers:r.tickers});break;case "unsubscribed":this.emit("unsubscribed",{channel:r.channel,all:r.all,tickers:r.tickers});break;case "pong":break;case "error":this.emit("error",new Error(r.message));break;default:if("channel"in r){let n=r;switch(n.channel){case "prices":this.emit("price",n);break;case "trades":this.emit("trade",n);break;case "orderbook":this.emit("orderbook",n);break}}}}catch{}}scheduleReconnect(){if(this.reconnectTimeout)return;let t=Math.min(this.reconnectIntervalBase*Math.pow(2,this.reconnectAttempts),this.reconnectMaxInterval);this.setStatus("reconnecting"),this.emit("reconnecting",{attempt:this.reconnectAttempts+1,delay:t}),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.reconnectAttempts++,this.connect();},t);}restoreSubscriptions(){for(let t of ["prices","trades","orderbook"]){let r=this.subscriptions[t];r.all?this.sendSubscription("subscribe",t,{all:true}):r.tickers.size>0&&this.sendSubscription("subscribe",t,{tickers:Array.from(r.tickers)});}}startPingInterval(){this.stopPingInterval(),this.pingIntervalId=setInterval(()=>{this.send({type:"ping"});},this.pingInterval);}stopPingInterval(){this.pingIntervalId&&(clearInterval(this.pingIntervalId),this.pingIntervalId=null);}};function ft(e){return new Ge(e)}function kg({wsEndpoint:e,autoConnect:t=true,autoReconnect:r=true,enabled:n=true}){let[s,i]=react.useState("disconnected"),[o,l]=react.useState(null),a=react.useRef(null);react.useEffect(()=>{if(!n){a.current&&(a.current.disconnect(),a.current=null),i("disconnected");return}let p=ft({wsUrl:e,autoConnect:t,autoReconnect:r});a.current=p;let m=p.on("status",x=>{i(x);}),f=p.on("error",x=>{l(x);}),y=p.on("connect",()=>{l(null);});return ()=>{m(),f(),y(),p.disconnect(),a.current=null;}},[e,t,r,n]);let d=react.useCallback(()=>{a.current?.connect();},[]),u=react.useCallback(()=>{a.current?.disconnect();},[]);return {client:a.current,status:s,isConnected:s==="connected",connect:d,disconnect:u,error:o}}function Eg(){let e=react.useContext(Ve);if(!e)throw new Error("useWsClient must be used within a PredictProvider");let{wsClient:t}=e,[r,n]=react.useState(t?.getStatus()??"disconnected");return react.useEffect(()=>{if(!t){n("disconnected");return}return n(t.getStatus()),t.onStatusChange(n)},[t]),{wsClient:t,wsStatus:r,isWsConnected:r==="connected"}}function Mg({client:e,all:t=false,tickers:r=[],enabled:n=true,onUpdate:s}){let[i,o]=react.useState(new Map),[l,a]=react.useState(false),d=react.useRef(s);return react.useEffect(()=>{d.current=s;},[s]),react.useEffect(()=>{if(!e||!n){a(false);return}if(!t&&r.length===0)return;let u=t?{all:true}:{tickers:r},c=e.subscribePrices(u,p=>{o(m=>{let f=new Map(m);return f.set(p.market_ticker,{yesBid:p.yes_bid,yesAsk:p.yes_ask,noBid:p.no_bid,noAsk:p.no_ask,updatedAt:Date.now()}),f}),d.current?.(p);});return a(true),()=>{c(),a(false);}},[e,t,r.join(","),n]),{prices:i,isSubscribed:l}}function Og({client:e,all:t=false,tickers:r=[],enabled:n=true,maxHistory:s=100,onUpdate:i}){let[o,l]=react.useState([]),[a,d]=react.useState(false),u=react.useRef(i);react.useEffect(()=>{u.current=i;},[i]),react.useEffect(()=>{if(!e||!n){d(false);return}if(!t&&r.length===0)return;let p=t?{all:true}:{tickers:r},m=e.subscribeTrades(p,f=>{let y={tradeId:f.trade_id,marketTicker:f.market_ticker,price:f.price,count:f.count,yesPrice:f.yes_price,noPrice:f.no_price,takerSide:f.taker_side,createdTime:f.created_time};l(x=>{let g=[y,...x];return g.length>s?g.slice(0,s):g}),u.current?.(f);});return d(true),()=>{m(),d(false);}},[e,t,r.join(","),n,s]);let c=react.useCallback(()=>{l([]);},[]);return {trades:o,isSubscribed:a,clearHistory:c}}function Bg({client:e,all:t=false,tickers:r=[],enabled:n=true,onUpdate:s}){let[i,o]=react.useState(new Map),[l,a]=react.useState(false),d=react.useRef(s);react.useEffect(()=>{d.current=s;},[s]),react.useEffect(()=>{if(!e||!n){a(false);return}if(!t&&r.length===0)return;let c=t?{all:true}:{tickers:r},p=e.subscribeOrderbook(c,m=>{o(f=>{let y=new Map(f);return y.set(m.market_ticker,{yesBids:m.yes_bids,yesAsks:m.yes_asks,noBids:m.no_bids,noAsks:m.no_asks,updatedAt:Date.now()}),y}),d.current?.(m);});return a(true),()=>{p(),a(false);}},[e,t,r.join(","),n]);let u=react.useCallback(c=>i.get(c),[i]);return {orderbooks:i,isSubscribed:l,getOrderbook:u}}var dn=["Politics","Sports","Culture","Crypto","Climate","Economics","Mentions","Companies","Financials","Tech & Science"];function pn(){let{data:e,isLoading:t,isError:r,error:n}=jt();return {data:react.useMemo(()=>{if(!e?.tagsByCategories)return [];let i=o=>{let l=dn.indexOf(o);return l===-1?dn.length:l};return Object.entries(e.tagsByCategories).map(([o,l])=>({category:o,tags:l})).sort((o,l)=>i(o.category)-i(l.category))},[e]),isLoading:t,isError:r,error:n??null}}function vt({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:s,onTagSelect:i,trailing:o,className:l}){let{t:a}=i18n.useTranslation(),d=react.useCallback(()=>{s(null);},[s]);return jsxRuntime.jsxs("div",{className:ui$1.cn("flex w-full flex-col gap-2",l),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsx(ui$1.HorizontalScrollContainer,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-0.5 py-1",children:[jsxRuntime.jsx(yt,{label:a("predict.categories.trending"),isSelected:t===null,onPress:d}),e.map(u=>jsxRuntime.jsx(yt,{label:u.category,isSelected:t===u.category,onPress:()=>s(u.category)},u.category))]})})}),o&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:o})]}),t&&n.length>0&&jsxRuntime.jsx(ui$1.HorizontalScrollContainer,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-0.5 py-1",children:[jsxRuntime.jsx(yt,{label:a("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null),variant:"secondary"}),n.map(u=>jsxRuntime.jsx(yt,{label:u,isSelected:r===u,onPress:()=>i(u),variant:"secondary"},u))]})})]})}function yt({label:e,isSelected:t,onPress:r,variant:n="primary"}){return jsxRuntime.jsx("button",{type:"button",onClick:r,className:ui$1.cn("shrink-0 rounded-full px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer","border whitespace-nowrap",n==="primary"?t?"bg-foreground text-background border-foreground":"bg-content1 text-foreground/70 border-default-200 hover:bg-default-100 hover:text-foreground":t?"bg-primary/15 text-primary border-primary/40":"bg-content1 text-foreground/50 border-default-100 hover:bg-default-50 hover:text-foreground/70"),children:e})}function yn({count:e=6}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-0.5 py-1",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 shrink-0 rounded-full",style:{width:`${60+Math.random()*40}px`}},r))})}function hn({onSelect:e,className:t}){let{data:r,isLoading:n}=pn(),[s,i]=react.useState(null),[o,l]=react.useState(null),a=react.useCallback(c=>{if(i(c),l(null),!c)e?.({category:null,tags:null});else {let p=r.find(m=>m.category===c);e?.({category:c,tags:p?.tags??null});}},[r,e]),d=react.useCallback(c=>{if(l(c),c)e?.({category:s,tags:[c]});else {let p=r.find(m=>m.category===s);e?.({category:s,tags:p?.tags??null});}},[r,s,e]);if(n)return jsxRuntime.jsx(yn,{});let u=r.find(c=>c.category===s)?.tags??[];return jsxRuntime.jsx(vt,{categories:r,selectedCategory:s,selectedTag:o,activeTags:u,onCategorySelect:a,onTagSelect:d,className:t})}var se=48,Pe=4,xt={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},w={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Se=w.ALL,ht={[w.ONE_DAY]:xt.ONE_MINUTE,[w.ONE_WEEK]:xt.ONE_HOUR,[w.ONE_MONTH]:xt.ONE_HOUR,[w.ALL]:xt.ONE_DAY},bt={[w.ONE_DAY]:300,[w.ONE_WEEK]:3600,[w.ONE_MONTH]:10800,[w.ALL]:1440*60},kt={[w.ONE_DAY]:1440*60,[w.ONE_WEEK]:10080*60,[w.ONE_MONTH]:720*60*60,[w.ALL]:null},Zt=1,Iv=1,Lv=1,Bv=99,De={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Qv=De.ONE_WEEK,Uv={[De.ONE_HOUR]:60,[De.SIX_HOURS]:60,[De.ONE_DAY]:300,[De.ONE_WEEK]:1800,[De.MAX]:1800};function bn(e={}){let{category:t,tags:r,...n}=e,s=!!t||!!r&&r.length>0,{data:i,isFetching:o,isError:l,error:a}=$r({...t?{category:t}:{},...r&&r.length>0?{tags:r.join(",")}:{},isInitialized:true,status:"active"},{enabled:s}),d=react.useMemo(()=>{if(!s||!i?.series)return;let R=i.series.map(S=>S.ticker).slice(0,25);return R.length>0?R.join(","):void 0},[s,i]),u=react.useMemo(()=>({status:"active",withNestedMarkets:true,sort:"volume24h",order:"desc",limit:48,...n,...d!==void 0?{seriesTickers:d}:{}}),[n,d]),{data:c,isLoading:p,isFetching:m,isFetchingNextPage:f,isError:y,error:x,hasNextPage:g,fetchNextPage:h,refetch:k}=Ar(u),v=react.useMemo(()=>c?.pages.flatMap(R=>R.events)??[],[c]),P=s&&!i&&!l;return {data:v,isLoading:P||p,isFetching:o||P||m&&!f,isFetchingMore:f,isError:l||y,error:a??x,hasMore:g,fetchMore:h,refetch:k}}function el({className:e}){return jsxRuntime.jsxs("div",{className:`flex h-full w-full flex-col justify-between gap-y-1.5 rounded-xl border border-border bg-content1 p-3 @5xl:gap-y-3 @5xl:p-4 ${e??""}`,children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-1 flex-col gap-y-1.5 @5xl:gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-8 flex-shrink-0 rounded-lg @5xl:h-12 @5xl:w-12"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 flex-1 rounded-md @5xl:h-12"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-12 flex-shrink-0 rounded-lg @5xl:h-10 @5xl:w-14"})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-0.5 @5xl:gap-y-1",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 w-full items-center justify-between gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-2/3 rounded-md"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-8 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 rounded-lg"})]})]}),jsxRuntime.jsxs("div",{className:"flex min-h-8 w-full items-center justify-between gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-1/2 rounded-md"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-8 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 rounded-lg"})]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-16 rounded-md @5xl:h-4"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-20 rounded-md @5xl:h-4"})]})]})}function Pt({count:e=8}){return jsxRuntime.jsx("div",{className:"@container w-full h-full",children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-4 @[640px]:grid-cols-2 @[1024px]:grid-cols-3 @[1280px]:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(el,{className:"min-h-44 @5xl:min-h-56"},r))})})}function kn({value:e,showLabel:t=true}){let r=e/100;return jsxRuntime.jsx("div",{className:"flex-shrink-0 flex flex-col items-center",children:jsxRuntime.jsxs("div",{className:"relative w-16 h-12 lg:w-20 lg:h-14",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 70",children:[jsxRuntime.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",className:"stroke-default-200",strokeWidth:"6",strokeLinecap:"round"}),jsxRuntime.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",className:"stroke-primary",strokeWidth:"6",strokeLinecap:"round",strokeDasharray:`${r*125.6} 125.6`,style:{transition:"stroke-dasharray 0.5s ease-in-out"}})]}),t&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center pt-3 lg:pt-4",children:jsxRuntime.jsxs("span",{className:"text-sm font-bold text-foreground lg:text-base leading-none",children:[e.toFixed(0),"%"]})})]})})}function Cn({event:e,onSelect:t,onSelectOutcome:r}){let{t:n}=i18n.useTranslation(),[s,i]=react.useState(null),o=e.markets||[],l=o.length>2?[...o].sort((S,L)=>Number(L.yesAsk??0)-Number(S.yesAsk??0)):o,a=l.filter(S=>S.status==="active"),d=l.length===1,u=d?l[0]:s,c=react.useMemo(()=>utils.formatAmountUSDCompact((e.volume??0)/100),[e.volume]),p=S=>S.yesAsk?parseFloat(S.yesAsk)*100:null,m=S=>S.noAsk?parseFloat(S.noAsk)*100:null,f=S=>{let L=p(S),V=m(S);return L!=null?V==null&&L<=1?"< 1%":x(L):V!=null?V<=1?"> 99%":x(100-V):"0%"},y=S=>{let L=p(S),V=m(S);return V!=null?L==null&&V<=1?"< 1%":x(V):L!=null?L<=1?"> 99%":x(100-L):"0%"},x=S=>S!=null?`${S.toFixed(0)}%`:"--",g=react.useMemo(()=>{let S=l.some(V=>V.status==="active");return l.every(V=>V.status==="closed"||V.status==="determined")?{label:n("predict.event.status.closed"),color:"bg-danger-100/50 text-danger"}:S?{label:n("predict.event.status.live"),color:"bg-primary-100/50 text-primary"}:{label:n("predict.event.status.pending"),color:"bg-warning-100/50 text-warning"}},[l,n]),h=S=>{i(S);},k=()=>{i(null);},v=()=>{u&&r&&r(e,u,"yes");},P=()=>{u&&r&&r(e,u,"no");},C=()=>{t&&t(e);},N=a.slice(0,2),R=a.length>2;return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col justify-between gap-y-1.5 rounded-xl border border-border bg-content1 p-3 transition-all duration-300 cursor-pointer hover:border-primary hover:ring-2 hover:ring-primary/20 focus-within:border-primary focus-within:bg-content2 focus-within:ring-2 focus-within:ring-primary/20 @5xl:gap-y-3 @5xl:p-4",onClick:C,children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-1 flex-col gap-y-1.5 @5xl:gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.imageUrl||void 0,name:e.title||"Event",radius:"md",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover:scale-110 @5xl:h-12 @5xl:w-12"}),jsxRuntime.jsx(ui$1.StyledTooltip,{content:e.title,placement:"bottom",children:jsxRuntime.jsx("p",{className:"flex-1 min-w-0 h-10 @5xl:h-12 text-sm font-semibold @5xl:text-base line-clamp-2",children:e.title})}),d?jsxRuntime.jsx(kn,{value:p(l[0])??50}):g.label!==n("predict.event.status.live")&&jsxRuntime.jsx("div",{className:`flex-shrink-0 flex items-center gap-x-2 rounded-lg px-2 py-1 text-sm @5xl:px-4 @5xl:py-2 ${g.color}`,children:jsxRuntime.jsx("span",{children:g.label})})]}),u&&!d&&jsxRuntime.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:S=>{S.stopPropagation(),k();},children:[jsxRuntime.jsx("span",{className:"text-left text-xs text-foreground @5xl:text-sm line-clamp-1",children:u.yesSubTitle}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground @5xl:text-lg",children:f(u)}),jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"w-3 h-3 text-default-500 @5xl:w-4 @5xl:h-4"})]})]}),!u&&!d&&N.length>0&&jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-0.5 text-xs @5xl:gap-y-1 @5xl:text-sm",children:[N.map(S=>jsxRuntime.jsxs("button",{type:"button",className:"flex min-h-8 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:L=>{L.stopPropagation(),h(S);},children:[jsxRuntime.jsx("span",{className:"text-left text-xs text-foreground @5xl:text-sm line-clamp-1",children:S.yesSubTitle}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-foreground @5xl:text-base",children:f(S)}),jsxRuntime.jsxs("div",{className:"flex h-full items-center gap-x-3 rounded-lg p-1 @5xl:p-1.5 bg-gradient-to-r from-primary-50/20 via-primary-50/20 to-secondary-50/20",children:[jsxRuntime.jsx("span",{className:"text-primary",children:n("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-default-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:n("predict.market.no")})]})]})]},S.ticker)),R&&jsxRuntime.jsx("span",{className:"text-xxs text-default-500 @5xl:text-xs",children:n("predict.event.moreMarkets",{count:a.length-2})})]}),u&&jsxRuntime.jsxs("div",{className:`flex items-center gap-x-2 text-sm @5xl:text-base ${d?"mt-3":""}`,children:[jsxRuntime.jsxs(ui$1.Button,{color:"primary",fullWidth:true,className:"group/yes bg-primary-100 text-primary @3xl:!h-12 @3xl:!text-base",size:"sm",onPress:v,children:[jsxRuntime.jsx("span",{className:"group-hover/yes:hidden",children:n("predict.market.yes")}),jsxRuntime.jsx("span",{className:"hidden group-hover/yes:inline",children:f(u)})]}),jsxRuntime.jsxs(ui$1.Button,{color:"secondary",fullWidth:true,className:"group/no bg-secondary-100 text-secondary @3xl:!h-12 @3xl:!text-base",size:"sm",onPress:P,children:[jsxRuntime.jsx("span",{className:"group-hover/no:hidden",children:n("predict.market.no")}),jsxRuntime.jsx("span",{className:"hidden group-hover/no:inline",children:y(u)})]})]})]}),!u||d?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-xxs text-default-600 hover:text-foreground @5xl:text-xs",onClick:S=>{S.stopPropagation(),C();},children:[jsxRuntime.jsx("span",{children:n("predict.event.showMore")}),jsxRuntime.jsx(ui$1.ChevronRightIcon,{className:"h-3 w-3 @5xl:h-4 @5xl:w-4"})]}),jsxRuntime.jsxs("span",{className:"text-xxs text-default-600 @5xl:text-xs",children:[c," ",n("predict.event.volume")]})]}):jsxRuntime.jsxs("button",{type:"button",className:"flex items-center cursor-pointer gap-x-1 text-xxs text-default-600 hover:text-foreground @5xl:text-xs",onClick:S=>{S.stopPropagation(),k();},children:[jsxRuntime.jsx(ui$1.ChevronLeftIcon,{className:"h-3 w-3 @5xl:h-4 @5xl:w-4"}),jsxRuntime.jsx("span",{children:n("predict.event.back")})]})]})}var fl=640,yl=768,wn=1024,gl=1280,vl=16,xl=192,hl=228,bl=244;function kl(e){return e>=gl?4:e>=wn?3:e>=fl?2:1}function Pl(e){return e>=wn?bl:e>=yl?hl:xl}function Tn({events:e,hasMore:t=false,onFetchMore:r,onSelect:n,onSelectOutcome:s}){let i=react.useRef(null),{width:o=0,height:l=0}=hooks.useResizeObserver({ref:i}),a=kl(o),d=Pl(o),u=Math.ceil(e.length/a)||0,c=t?u+1:u,p=react.useCallback(y=>y<u,[u]),m=react.useCallback(async()=>{r?.();},[r]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:m,rowCount:c,threshold:3});return jsxRuntime.jsx("div",{ref:i,className:"@container w-full h-full",children:l>0&&jsxRuntime.jsx(reactWindow.List,{style:{height:l},onRowsRendered:f,rowComponent:Sl,rowCount:c,rowHeight:d,rowProps:{events:e,columnCount:a,dataRowCount:u,gap:vl,onSelect:n,onSelectOutcome:s}})})}function Sl({index:e,style:t,events:r,columnCount:n,dataRowCount:s,gap:i,onSelect:o,onSelectOutcome:l}){if(e>=s)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let a=e*n,d=r.slice(a,a+n),u=n-d.length,c={display:"flex",gap:i,height:`calc(100% - ${i}px)`};return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{style:c,children:[d.map(p=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0},children:jsxRuntime.jsx(Cn,{event:p,onSelect:o,onSelectOutcome:l})},p.ticker)),u>0&&Array.from({length:u}).map((p,m)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${m}`))]})})}function Nn({onSelect:e,onSelectOutcome:t,...r}){let{data:n,hasMore:s,fetchMore:i,isFetching:o}=bn({limit:48,...r});return o?jsxRuntime.jsx(Pt,{count:48}):jsxRuntime.jsx(Tn,{events:n,hasMore:s,onFetchMore:i,onSelect:e,onSelectOutcome:t})}function vx({onSelect:e,onSelectOutcome:t}){let[r,n]=react.useState({category:null,tags:null}),s=react.useCallback(i=>{n(i);},[]);return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col gap-y-3",children:[jsxRuntime.jsx(hn,{onSelect:s}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Nn,{category:r.category,tags:r.tags,onSelect:e,onSelectOutcome:t})})]})}var Ml={"Climate and 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 and Technology":["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},Rn=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],rr=(()=>{let e=t=>{let r=Rn.indexOf(t);return r===-1?Rn.length:r};return Object.entries(Ml).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 Nl(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Ln({onSelect:e,trailing:t,className:r}){let[n,s]=react.useState(null),[i,o]=react.useState(null),l=react.useCallback(c=>{s(c),o(null),e?.({categorySlug:c,tagSlug:null});},[e]),a=react.useCallback(c=>{o(c),e?.({categorySlug:n,tagSlug:c});},[n,e]),d=Nl(rr),u=rr.find(c=>c.slug===n)?.tags.map(c=>c.label)??[];return jsxRuntime.jsx(vt,{categories:d,selectedCategory:n,selectedTag:i,activeTags:u,onCategorySelect:l,onTagSelect:a,trailing:t,className:r})}var nr={sortPreset:"trending",source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function sr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Bn({isOpen:e,onClose:t,value:r,onChange:n}){let{t:s}=i18n.useTranslation(),[i,o]=react.useState(r),l=react.useCallback(g=>{g?o(r):t();},[r,t]),a=react.useCallback(()=>{o(nr);},[]),d=react.useCallback(()=>{n(i),t();},[i,n,t]),u=react.useCallback((g,h)=>{o(k=>({...k,[g]:h}));},[]),c=react.useMemo(()=>sr(i),[i]),p=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"polymarket",label:s("predict.platform.polymarket")},{value:"dflow",label:s("predict.platform.dflow")}],[s]),m=react.useMemo(()=>[{value:"trending",label:s("predict.sort.trending")},{value:"volume",label:s("predict.sort.volume")},{value:"newest",label:s("predict.sort.newest")},{value:"ending_soon",label:s("predict.sort.endingSoon")},{value:"liquidity",label:s("predict.sort.liquidity")}],[s]),f=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1d",label:s("predict.filter.lessThanDay")},{value:"7d",label:s("predict.filter.lessThanWeek")},{value:"30d",label:s("predict.filter.lessThanMonth")}],[s]),y=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[s]),x=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[s]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:e,onOpenChange:l,size:"md",classNames:{base:"bg-content1 border border-default-200",header:"border-b border-default-100",body:"py-4",footer:"border-t border-default-100"},children:jsxRuntime.jsxs(ui$1.ModalContent,{children:[jsxRuntime.jsxs(ui$1.ModalHeader,{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui$1.FilterIcon,{className:"h-5 w-5 text-default-500"}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:s("predict.filter.title")}),jsxRuntime.jsx("span",{className:"text-xxs text-default-400 font-normal",children:s("predict.filter.subtitle")})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"rounded-full p-1 hover:bg-default-100 transition-colors cursor-pointer",children:jsxRuntime.jsx(ui$1.XCloseIcon,{className:"h-4 w-4 text-default-400"})})]}),jsxRuntime.jsxs(ui$1.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(Ye,{label:s("predict.filter.platform"),children:jsxRuntime.jsx(Xe,{options:p,selected:i.source,onSelect:g=>u("source",g)})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.sortBy"),children:jsxRuntime.jsx(Xe,{options:m,selected:i.sortPreset,onSelect:g=>u("sortPreset",g??"trending"),allowDeselect:false})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.timeRemaining"),children:jsxRuntime.jsx(Xe,{options:f,selected:i.timeRemaining,onSelect:g=>u("timeRemaining",g)})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.minVolume"),children:jsxRuntime.jsx(Xe,{options:y,selected:i.minVolume,onSelect:g=>u("minVolume",g)})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.minLiquidity"),children:jsxRuntime.jsx(Xe,{options:x,selected:i.minLiquidity,onSelect:g=>u("minLiquidity",g)})})]}),jsxRuntime.jsxs(ui$1.ModalFooter,{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("button",{type:"button",onClick:a,className:"flex items-center gap-1.5 text-sm text-default-500 hover:text-foreground transition-colors cursor-pointer",children:[jsxRuntime.jsx(Wl,{className:"h-3.5 w-3.5"}),jsxRuntime.jsx("span",{children:s("predict.filter.reset")})]}),jsxRuntime.jsxs(ui$1.Button,{color:"secondary",size:"md",className:"min-w-[140px] font-medium",onPress:d,children:[s("predict.filter.showResults"),c>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",c,")"]})]})]})]})})}function Ye({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function Xe({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(s=>{let i=t===s.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:s.value);},className:ui$1.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-warning/15 text-warning border-warning/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:s.label},s.value??"__all")})})}function Wl({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M13.65 2.35A7.958 7.958 0 0 0 8 0C3.58 0 .01 3.58.01 8S3.58 16 8 16c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 8 14 6 6 0 1 1 8 2c1.66 0 3.14.69 4.22 1.78L9 7h7V0l-2.35 2.35Z",fill:"currentColor"})})}var _n={trending:{sort_by:"volume_24h",sort_asc:false},volume:{sort_by:"volume",sort_asc:false},newest:{sort_by:"created_at",sort_asc:false},ending_soon:{sort_by:"end_at",sort_asc:true},liquidity:{sort_by:"liquidity",sort_asc:false}},or={trending:"predict.sort.trending",volume:"predict.sort.volume",newest:"predict.sort.newest",ending_soon:"predict.sort.endingSoon",liquidity:"predict.sort.liquidity"},Zl={trending:"predict.sort.trending.desc",volume:"predict.sort.volume.desc",newest:"predict.sort.newest.desc",ending_soon:"predict.sort.endingSoon.desc",liquidity:"predict.sort.liquidity.desc"},Jl=["trending","volume","newest","ending_soon","liquidity"];function Vn({source:e,onSourceChange:t,sortPreset:r,onSortChange:n,onFilterPress:s,filterCount:i=0,className:o}){let{t:l}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center gap-2",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(Qn,{label:l("predict.platform.dflow"),isActive:e==="dflow",onPress:()=>t("dflow")}),jsxRuntime.jsx(Qn,{label:l("predict.platform.polymarket"),isActive:e==="polymarket",onPress:()=>t("polymarket")})]}),jsxRuntime.jsxs(ui$1.Dropdown,{children:[jsxRuntime.jsx(ui$1.DropdownTrigger,{children:jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-lg border border-default-200 bg-content1 px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(ec,{className:"h-3.5 w-3.5 text-warning"}),jsxRuntime.jsx("span",{children:l(or[r])}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-3 w-3 text-default-400"})]})}),jsxRuntime.jsx(ui$1.DropdownMenu,{"aria-label":"Sort events",selectionMode:"single",selectedKeys:new Set([r]),onSelectionChange:a=>{let d=Array.from(a)[0];d&&n(d);},classNames:{base:"min-w-[200px]"},children:Jl.map(a=>jsxRuntime.jsx(ui$1.DropdownItem,{textValue:l(or[a]),classNames:{base:"data-[selected=true]:text-warning"},children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:l(or[a])}),jsxRuntime.jsx("span",{className:"text-xxs text-default-400",children:l(Zl[a])})]})},a))})]}),jsxRuntime.jsx(ui$1.StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxRuntime.jsxs(ui$1.Button,{variant:"bordered",size:"sm",className:"min-w-0 gap-1.5 border-default-200 bg-content1 text-foreground hover:bg-content2",onPress:s,children:[jsxRuntime.jsx(ui$1.FilterIcon,{className:"h-3.5 w-3.5"}),jsxRuntime.jsx("span",{className:"text-xs font-medium",children:l("predict.filter.title")})]})})]})}function Qn({label:e,isActive:t,onPress:r}){return jsxRuntime.jsx("button",{type:"button",onClick:r,className:ui$1.cn("shrink-0 rounded-full px-2.5 py-1 text-xs font-medium transition-colors duration-150 cursor-pointer border whitespace-nowrap",t?"bg-foreground text-background border-foreground":"bg-content1 text-foreground/70 border-default-200 hover:bg-default-100 hover:text-foreground"),children:e})}function ec({className:e}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:[jsxRuntime.jsx("path",{d:"M8 1.333c-.667 2-2.667 3.334-2.667 5.334a2.667 2.667 0 0 0 5.334 0C10.667 4.667 8.667 3.333 8 1.333Z",fill:"currentColor",opacity:".6"}),jsxRuntime.jsx("path",{d:"M8 4c-.5 1.5-1.5 2.5-1.5 4a1.5 1.5 0 0 0 3 0c0-1.5-1-2.5-1.5-4Z",fill:"currentColor"})]})}function rc(e){if(e)return e.tagSlug??e.categorySlug??void 0}function nc(e){return ["predict-v2","events-infinite",e]}function Fn(e={}){let{tagSlugSelection:t,limit:r=48,status:n="open",sort_by:s,sort_asc:i,source:o,with_markets:l=true}=e,a=be(),d=react.useMemo(()=>{let C=rc(t);return {limit:r,status:n,with_markets:l,...o?{source:o}:{},...C?{tag_slug:C}:{},...s?{sort_by:s}:{},...i!==void 0?{sort_asc:i}:{}}},[t,r,n,s,i,o,l]),{data:u,isLoading:c,isFetching:p,isFetchingNextPage:m,isError:f,error:y,hasNextPage:x,fetchNextPage:g,refetch:h}=reactQuery.useInfiniteQuery({queryKey:nc(d),queryFn:({pageParam:C})=>a.listEvents({...d,...C!==void 0?{cursor:C}:{}}),initialPageParam:void 0,getNextPageParam:C=>C.has_more&&C.next_cursor?C.next_cursor:void 0}),k=react.useMemo(()=>u?.pages.flatMap(C=>C.items).filter(C=>C!=null)??[],[u]),v=react.useCallback(()=>{g();},[g]),P=react.useCallback(()=>{h();},[h]);return {data:k,isLoading:c,isFetching:p&&!m,isFetchingMore:m,isError:f,error:y??null,hasMore:x??false,fetchMore:v,refetch:P}}var Wn=3,qn=["bg-primary","bg-secondary","bg-blue-500","bg-purple-500"];function ar(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function cc(e){return e!=null?e*100:null}function uc(e){let t=cc(ar(e));return t!=null?Math.round(t):0}function dc(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function pc(e){if(!e)return null;try{let t=new Date(e);return isNaN(t.getTime())?null:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return null}}function mc(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function Hn({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:s,onHover:i}){let{t:o}=i18n.useTranslation(),l=e.markets??[],a=react.useMemo(()=>l.length>2?[...l].sort((h,k)=>(ar(k)??0)-(ar(h)??0)):l,[l]),d=a.filter(h=>h.status==="open"),u=d.slice(0,Wn),c=d.length-Wn,p=react.useMemo(()=>utils.formatAmountUSDCompact(e.volume??0),[e.volume]),m=pc(e.end_at),f=react.useMemo(()=>{let h=a.some(v=>v.status==="open");return a.every(v=>v.status==="closed"||v.status==="voided")?"closed":h?"live":"pending"},[a]),y=()=>n?.(e),x=()=>i?.(e),g=(h,k)=>{h.stopPropagation(),h.preventDefault(),s?s(e,k,"yes"):n?.(e);};return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:r,className:ui$1.cn("group flex h-full w-full flex-col justify-between rounded-xl","border border-default-200/60 bg-content1 p-3 @5xl:p-4","transition-all duration-200 cursor-pointer","hover:bg-content2/40 hover:border-default-300"),onClick:t?void 0:y,onMouseEnter:x,children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-1 flex-col gap-y-2.5 @5xl:gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0 transition-transform duration-200 group-hover:scale-105 @5xl:h-12 @5xl:w-12"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(fc,{source:e.source}),f==="pending"&&jsxRuntime.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium bg-warning-100/50 text-warning leading-none",children:o("predict.event.status.pending")})]}),jsxRuntime.jsx(ui$1.StyledTooltip,{content:e.title,placement:"bottom",children:jsxRuntime.jsx("p",{className:"text-sm font-semibold leading-snug line-clamp-2 @5xl:text-base",children:e.title})})]})]}),u.length>0&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[u.map((h,k)=>{let v=uc(h);return jsxRuntime.jsxs("button",{type:"button",className:"flex w-full flex-col gap-y-1 rounded-lg bg-content2/50 px-2.5 py-1.5 transition-colors hover:bg-content2 cursor-pointer",onClick:P=>g(P,h),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-between gap-x-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 min-w-0",children:[jsxRuntime.jsx("span",{className:ui$1.cn("h-2 w-2 flex-shrink-0 rounded-full",qn[k%qn.length])}),jsxRuntime.jsx("span",{className:"text-xs text-foreground/80 line-clamp-1 @5xl:text-sm",children:h.question})]}),jsxRuntime.jsx("span",{className:"flex-shrink-0 text-sm font-semibold text-foreground @5xl:text-base",children:dc(v)})]}),jsxRuntime.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-default-200/40",children:jsxRuntime.jsx("div",{className:ui$1.cn("h-full rounded-full transition-all duration-500",k===0?"bg-primary":k===1?"bg-secondary":"bg-blue-500"),style:{width:`${Math.max(v,1)}%`}})})]},h.slug)}),c>0&&jsxRuntime.jsx("span",{className:"px-2.5 text-xxs text-default-500 @5xl:text-xs",children:o("predict.event.moreOptions",{count:c})})]})]}),jsxRuntime.jsxs("div",{className:"mt-2 flex items-center justify-between gap-x-2 pt-1.5 border-t border-default-100/50",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 text-xxs text-default-500 @5xl:text-xs",children:[jsxRuntime.jsx(yc,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{children:p})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 text-xxs text-default-500 @5xl:text-xs",children:f==="closed"?jsxRuntime.jsx("span",{className:"text-danger",children:o("predict.event.status.closed")}):m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(gc,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{children:m})]}):f==="pending"?jsxRuntime.jsx("span",{className:"text-warning",children:o("predict.event.status.pending")}):null})]})]})}function fc({source:e}){return jsxRuntime.jsxs("span",{className:ui$1.cn("inline-flex items-center gap-x-1 rounded px-1.5 py-0.5","text-[10px] font-medium leading-none",e==="polymarket"?"bg-blue-500/15 text-blue-400":"bg-primary-500/15 text-primary"),children:[jsxRuntime.jsx("span",{className:ui$1.cn("h-1.5 w-1.5 rounded-sm",e==="polymarket"?"bg-blue-400":"bg-primary")}),mc(e)]})}function yc({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M1 8.5V3.5h2l2-2v9l-2-2H1ZM7 4.5v3M9 3.5v5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})})}function gc({className:e}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:[jsxRuntime.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1"}),jsxRuntime.jsx("path",{d:"M6 3.5V6l1.5 1.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Sc=640,Cc=768,$n=1024,Ec=1280,wc=16,Tc=296,Mc=312,Nc=328;function Rc(e){return e>=Ec?4:e>=$n?3:e>=Sc?2:1}function Oc(e){return e>=$n?Nc:e>=Cc?Mc:Tc}function zn({events:e,hasMore:t=false,onFetchMore:r,onSelect:n,onSelectOutcome:s,getEventHref:i,LinkComponent:o,onHover:l}){let a=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:a}),c=Rc(d),p=Oc(d),m=Math.ceil(e.length/c)||0,f=t?m+1:m,y=react.useCallback(h=>h<m,[m]),x=react.useCallback(async()=>{r?.();},[r]),g=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:y,loadMoreRows:x,rowCount:f,threshold:3});return jsxRuntime.jsx("div",{ref:a,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{style:{height:u},onRowsRendered:g,rowComponent:Ic,rowCount:f,rowHeight:p,rowProps:{events:e,columnCount:c,dataRowCount:m,gap:wc,onSelect:n,onSelectOutcome:s,getEventHref:i,LinkComponent:o,onHover:l}})})}function Ic({index:e,style:t,events:r,columnCount:n,dataRowCount:s,gap:i,onSelect:o,onSelectOutcome:l,getEventHref:a,LinkComponent:d,onHover:u}){if(e>=s)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let c=e*n,p=r.slice(c,c+n),m=n-p.length,f={display:"flex",gap:i,height:`calc(100% - ${i}px)`};return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{style:f,children:[p.map(y=>y==null?null:jsxRuntime.jsx("div",{style:{flex:1,minWidth:0},children:jsxRuntime.jsx(Hn,{event:y,href:a?.(y),LinkComponent:d,onSelect:o,onSelectOutcome:l,onHover:u})},y.slug)),m>0&&Array.from({length:m}).map((y,x)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${x}`))]})})}function Yn({tagSlugSelection:e,limit:t=48,status:r,sort_by:n,sort_asc:s,source:i,with_markets:o,onSelect:l,onSelectOutcome:a,getEventHref:d,LinkComponent:u,onHover:c}){let{data:p,hasMore:m,fetchMore:f,isFetching:y}=Fn({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:s,source:i,with_markets:o});return y?jsxRuntime.jsx(Pt,{count:48}):jsxRuntime.jsx(zn,{events:p,hasMore:m,onFetchMore:f,onSelect:l,onSelectOutcome:a,getEventHref:d,LinkComponent:u,onHover:c})}function ph({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:s}){let[i,o]=react.useState({categorySlug:null,tagSlug:null}),[l,a]=react.useState(nr),{isOpen:d,onOpen:u,onClose:c}=ui$1.useDisclosure(),p=react.useCallback(k=>{o(k);},[]),m=react.useCallback(k=>{a(v=>({...v,source:k}));},[]),f=react.useCallback(k=>{a(v=>({...v,sortPreset:k}));},[]),y=react.useCallback(k=>{a(k);},[]),x=react.useMemo(()=>_n[l.sortPreset],[l.sortPreset]),g=react.useMemo(()=>sr(l),[l]),h=jsxRuntime.jsx(Vn,{source:l.source,onSourceChange:m,sortPreset:l.sortPreset,onSortChange:f,onFilterPress:u,filterCount:g});return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col gap-y-3",children:[jsxRuntime.jsx(Ln,{onSelect:p,trailing:h}),jsxRuntime.jsx(Bn,{isOpen:d,onClose:c,value:l,onChange:y}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Yn,{tagSlugSelection:i,sort_by:x.sort_by,sort_asc:x.sort_asc,source:l.source,onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:s})})]})}function ur(e,t,r){let n=e[t];return n?r==="yes"?n.yesMint:n.noMint:null}var Je=utils.SOLANA_TOKENS.stablecoins.USDC.address;function Wc(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};lr__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{lr__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{lr__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Jn({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:n="buy"}){let{t:s}=i18n.useTranslation(),i=react.useContext(ke),{status:o}=walletConnector.useAuth(),a=walletConnector.useWallets().find(E=>E.chainNamespace===types.ChainNamespace.SOLANA&&E.isConnected),d=o==="authenticated",u=a?.address,[c,p]=react.useState(r),[m,f]=react.useState(n),[y,x]=react.useState(NaN),g=react.useMemo(()=>ur(e.accounts,Je,c),[e.accounts,c]),{inputMint:h,outputMint:k}=react.useMemo(()=>m==="buy"?{inputMint:Je,outputMint:g}:{inputMint:g,outputMint:Je},[m,g]),v=!!h&&!!k&&y>0,P=react.useMemo(()=>Number(c==="yes"?e.yesAsk??.5:e.noAsk??.5),[c,e.yesAsk,e.noAsk]),C=react.useMemo(()=>isNaN(y)||y<=0?0:m==="buy"?P>0?y/P:0:y,[m,y,P]),N=react.useMemo(()=>isNaN(y)||y<=0?0:Math.round(y*1e6),[y]),{data:R,isLoading:S,error:L,refetch:V}=Jr({userPublicKey:u??void 0,inputMint:h??"",outputMint:k??"",amount:N,slippageBps:100},{enabled:v}),Oe=i?.usdcBalance??null,he=i?.isLoading??false,Lr=i?.refetch,me=i?.positions,at=react.useMemo(()=>{if(!me||!g)return null;let E=me.find(le=>le.mint===g);return E?E.balance:0},[me,g]),Qt=react.useMemo(()=>ur(e.accounts,Je,"yes"),[e.accounts]),Ut=react.useMemo(()=>ur(e.accounts,Je,"no"),[e.accounts]),No=react.useMemo(()=>{if(!me||!Qt)return null;let E=me.find(le=>le.mint===Qt);return E?E.balance:0},[me,Qt]),Ro=react.useMemo(()=>{if(!me||!Ut)return null;let E=me.find(le=>le.mint===Ut);return E?E.balance:0},[me,Ut]),{data:Ue}=Ae(e.ticker,{refetchInterval:5e3}),Oo=react.useMemo(()=>(c==="yes"?Ue?.yesBids:Ue?.noBids)?.[0]?.price??null,[Ue,c]),Io=react.useMemo(()=>(c==="yes"?Ue?.yesAsks:Ue?.noAsks)?.[0]?.price??null,[Ue,c]),Lo=react.useMemo(()=>R?.priceImpactPct?parseFloat(R.priceImpactPct):null,[R]),lt=react.useMemo(()=>{if(isNaN(y)||y<=0)return 0;if(R)return parseInt(R.inAmount)/1e6;if(m==="buy")return y;let E=Number(c==="yes"?e.yesBid??0:e.noBid??0);return y*E},[R,m,c,y,e.yesBid,e.noBid]),Br=react.useMemo(()=>isNaN(y)||y<=0?0:m==="buy"?C*1:lt,[m,C,lt,y]),Bo=Br-lt,Qo=react.useCallback(E=>{f(E),x(NaN);},[]),Uo=react.useCallback(E=>{if(isNaN(E)){x(NaN);return}let le=Math.max(0,E),dt=m==="buy"?Math.round(le*100)/100:Math.round(le);x(dt);},[m]);react.useEffect(()=>{v&&V();},[y,c,m,v,V]);let _t=react.useMemo(()=>{let E=[];return (isNaN(y)||y<Zt)&&E.push(`Minimum quantity is ${Zt}`),e.status!=="active"&&E.push("Market is not active"),m==="buy"&&Oe!=null&&!isNaN(y)&&y>0&&y>Oe&&E.push("Insufficient USDC balance"),m==="sell"&&at!=null&&!isNaN(y)&&y>0&&y>at&&E.push("Insufficient shares"),{isValid:E.length===0,errors:E}},[y,e.status,m,Oe,at]),[_o,Vt]=react.useState(null),[Vo,_e]=react.useState(false),[ct,ze]=react.useState(null),{data:ut}=en({signature:ct??""},{enabled:!!ct});react.useEffect(()=>{if(!ut||!ct)return;let{status:E}=ut;E==="closed"?(_e(false),ze(null),ui$1.toast.success(s("predict.trade.submitSuccess")),Wc(),x(NaN),Lr?.()):(E==="failed"||E==="expired")&&(_e(false),ze(null),ui$1.toast.error(s("predict.trade.submitError")));},[ut,ct,Lr,s]);let Ao=react.useCallback(async()=>{if(!(!_t.isValid||!d||!u||!a||he)){Vt(null),ze(null),_e(true);try{let E=R;if(E?.transaction||(E=(await V()).data),!E?.transaction){_e(!1);return}let le=Uint8Array.from(atob(E.transaction),Qr=>Qr.charCodeAt(0)),dt=await a.sendTransaction(le);Vt(dt),ze(dt);}catch{ui$1.toast.error(s("predict.trade.submitError")),_e(false);}}},[_t.isValid,d,u,a,R,he,V,s]),Do=react.useCallback(()=>{p(r),f(n),x(NaN),Vt(null),ze(null),_e(false);},[r,n]);return {outcome:c,side:m,quantity:y,shares:C,estimatedCost:lt,potentialPayout:Br,potentialProfit:Bo,isAuthenticated:d,bestBid:Oo,bestAsk:Io,order:R??null,priceImpact:Lo,usdcBalance:Oe,outcomeTokenBalance:at,yesTokenBalance:No,noTokenBalance:Ro,isBalanceLoading:he,isQuoteLoading:S,isSubmitting:Vo,quoteError:L??null,txHash:_o,orderStatus:ut??null,validation:_t,setOutcome:p,setSide:Qo,setQuantity:Uo,submit:Ao,reset:Do}}var Gc=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function ns({event:e,market:t,outcome:r,side:n,quantity:s,potentialProfit:i,estimatedCost:o,usdcBalance:l,yesTokenBalance:a,noTokenBalance:d,isBalanceLoading:u,isSubmitting:c,isValid:p,onOutcomeChange:m,onSideChange:f,onQuantityChange:y,onSubmit:x}){let{t:g}=i18n.useTranslation(),h=react.useMemo(()=>{if(c)return g("predict.trade.submitting");let v=g(n==="buy"?"predict.trade.buy":"predict.trade.sell"),P=g(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${v} ${P}`},[c,n,r,g]),k=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]);return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:r==="yes"?"text-bullish":"text-bearish",children:[g(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",g(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:v=>f(v),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:g("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui$1.Tab,{title:g("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(v=>{let P=v==="yes"?a:d;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(v),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===v?v==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:g(v==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let C=n==="buy"?v==="yes"?t.yesAsk:t.noAsk:v==="yes"?t.yesBid:t.noBid;return C!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(C)*100),"\xA2"]}):null})()]}),n==="sell"&&r===v&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:u?"\u2013":`${P??0} shares`})]},v)})}),n==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1 text-xs text-default-500",children:[jsxRuntime.jsx("img",{src:Gc,alt:"USDC",className:"h-4 w-4 rounded-full object-cover"}),jsxRuntime.jsxs("span",{children:[g("predict.trade.balance"),":"]}),jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:l!=null?`$${l.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:g(n==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui$1.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(s)?void 0:s,onValueChange:v=>{y(v);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},n),jsxRuntime.jsx("div",{className:"flex gap-x-2 justify-end",children:n==="buy"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[[1,5,10,100].map(v=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>y(Math.round(((isNaN(s)?0:s)+v)*100)/100),className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:["+",v,"$"]},v)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:g("common.all")})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[[25,50].map(v=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[v,"%"]},v)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:g("common.all")})]})})]}),!isNaN(s)&&s>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:g(n==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(n==="buy"?i:o).toFixed(2)]})]}),jsxRuntime.jsx(ui$1.Button,{color:k,fullWidth:true,radius:"lg",size:"lg",isDisabled:!p||c,isLoading:c,onPress:x,children:h})]})}function dr({event:e,market:t,initialSide:r,initialOutcome:n,chain:s}){let{outcome:i,side:o,quantity:l,estimatedCost:a,potentialPayout:d,potentialProfit:u,usdcBalance:c,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:f,isSubmitting:y,validation:x,setOutcome:g,setSide:h,setQuantity:k,submit:v}=Jn({market:t,initialSide:r,initialOutcome:n,chain:s}),P=walletConnector.useAuthCallback(v);return jsxRuntime.jsx(ns,{event:e,market:t,outcome:i,side:o,quantity:l,estimatedCost:a,potentialPayout:d,potentialProfit:u,usdcBalance:c,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:f,isSubmitting:y,isValid:x.isValid,validationErrors:x.errors,onOutcomeChange:g,onSideChange:h,onQuantityChange:k,onSubmit:P})}function jc(){return jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 px-2 py-3 lg:gap-x-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 flex-1 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-5 w-10 shrink-0 rounded-md"}),jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-16 rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-16 rounded-lg"})]})]})}function et({marketCount:e=4}){return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-4 lg:gap-y-6 px-1 lg:px-4 lg:max-w-3xl animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 lg:gap-x-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-14 w-14 shrink-0 rounded-lg lg:h-18 lg:w-18"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 min-w-0 flex-1",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-24 rounded-md lg:w-32"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-5 w-48 rounded-md lg:h-6 lg:w-72"})]})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-[200px] w-full rounded-xl lg:h-[280px]"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-32 rounded-md"}),jsxRuntime.jsx("div",{className:"flex gap-x-1",children:Array.from({length:4}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-10 rounded-md"},r))})]}),jsxRuntime.jsx("div",{className:"flex flex-col divide-y divide-default-200",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(jc,{},r))})]})}function ss(){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 w-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1 flex-1",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-28 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-40 rounded-md"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-x-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-12 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-12 rounded-md"})]}),jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 flex-1 rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 flex-1 rounded-lg"})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-14 w-full rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-12 w-full rounded-lg"})]})}var os=e=>{let{candlestickMarketTickers:t,chartRange:r=Se}=e,n=ht[r],s=kt[r],i=react.useMemo(()=>Math.floor(Date.now()/1e3),[r]),o=b(),{data:l,isLoading:a,error:d}=mt({id:e.eventId,withNestedMarkets:true}),u=react.useMemo(()=>{if(s!=null)return i-s;let k=l?.markets;return k?.length?Math.min(...k.map(v=>v.openTime)):i},[i,s,l?.markets]),{data:c,isLoading:p,error:m}=zr(l?.seriesTicker??"",{enabled:!!l?.seriesTicker}),f=react.useMemo(()=>l?.markets?(t&&t.length>0?t.slice(0,4).map(v=>l.markets.find(P=>P.ticker===v)).filter(v=>v!==void 0):[...l.markets].sort((v,P)=>Number(P.yesAsk??0)-Number(v.yesAsk??0)).slice(0,4)).map(v=>v.ticker):[],[t,l?.markets]),y=reactQuery.useQueries({queries:f.map(k=>({queryKey:zt({ticker:k,startTs:u,endTs:i,periodInterval:n}),queryFn:()=>Gt(o,{ticker:k,startTs:u,endTs:i,periodInterval:n}),enabled:f.length>0}))}),x=y.some(k=>k.isLoading),g=react.useMemo(()=>{let k=new Map;return f.forEach((v,P)=>{let C=y[P]?.error;C&&k.set(v,C);}),k},[f,y]),h=react.useMemo(()=>{let k=new Map;return f.forEach((v,P)=>{let C=y[P]?.data;C&&k.set(v,C);}),k},[f,y]);return {event:l,isEventLoading:a,eventError:d,series:c,isSeriesLoading:p,seriesError:m,periodInterval:n,candlesticks:h,isCandlesticksLoading:x,candlestickErrors:g}};var iu=utils.SOLANA_TOKENS.stablecoins.USDC.address;function is(e){let{status:t}=walletConnector.useAuth(),n=walletConnector.useWallets().find(d=>d.chainNamespace===types.ChainNamespace.SOLANA&&d.isConnected),s=t==="authenticated",i=n?.address,{data:o,isLoading:l}=react$1.useWalletPortfoliosQuery({chain:types.Chain.SOLANA,address:i??""},{enabled:s&&!!i,refetchInterval:1e4});return {holdings:react.useMemo(()=>{let d=new Map;if(!o?.portfolios||e.length===0)return d;let u=new Map;for(let c of o.portfolios)u.set(c.address,parseFloat(c.amount));for(let c of e){let p=c.accounts[iu];if(!p)continue;let m=u.get(p.yesMint)??0,f=u.get(p.noMint)??0;(m>0||f>0)&&d.set(c.ticker,{yesShares:m,noShares:f});}return d},[o,e]),isLoading:l}}function gu(e){let{cx:t,cy:r,index:n,dataLength:s,stroke:i}=e;return n!==s-1||t==null||r==null?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:i,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;8;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.1;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3,fill:i})]})}var Tt=[{stroke:"hsl(var(--heroui-primary))",id:"colorMarket0"},{stroke:"hsl(var(--heroui-secondary))",id:"colorMarket1"},{stroke:"hsl(var(--heroui-success))",id:"colorMarket2"},{stroke:"hsl(var(--heroui-warning))",id:"colorMarket3"}];function as(e,t){let r=new Date(e*1e3);switch(t){case w.ONE_DAY:return r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});case w.ONE_WEEK:case w.ONE_MONTH:return r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false});case w.ALL:default:return r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function vu(e,t,r){let n=bt[r],s=new Map;e.forEach((a,d)=>{let u=new Map;(a.candlesticks??[]).forEach(p=>{let m=p.end_period_ts-p.end_period_ts%n;u.set(m,p.yes_ask.close);}),s.set(d,u);});let i=new Set;for(let a of s.values())for(let d of a.keys())i.add(d);let o=Array.from(i).sort((a,d)=>a-d),l=new Map;return o.map(a=>{let u={date:new Date(a*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"}),timestamp:a};return t.forEach(c=>{let p=s.get(c)?.get(a);if(p!==void 0)u[c]=Math.round(p*100)/100,l.set(c,u[c]);else {let m=l.get(c);m!==void 0&&(u[c]=m);}}),u})}function ls({candlesticks:e,markets:t=[],isLoading:r,chartRange:n=w.ALL,onDataChange:s}){let[i,o]=react.useState(null),l=react.useRef(s);react.useEffect(()=>{l.current=s;});let a=react.useMemo(()=>e?Array.from(e.keys()).slice(0,4):[],[e]),d=react.useMemo(()=>!e||e.size===0?[]:vu(e,a,n),[e,a,n]),u=react.useMemo(()=>{if(d.length===0||a.length===0)return [0,100];let f=1/0,y=-1/0;if(d.forEach(v=>{a.forEach(P=>{let C=v[P];C!==void 0&&(f=Math.min(f,C),y=Math.max(y,C));});}),f===1/0||y===-1/0)return [0,100];let x=y-f,g=Math.max(x*.2,5),h=Math.max(0,Math.floor(f-g)),k=Math.min(100,Math.ceil(y+g));return [h,k]},[d,a]),c=react.useCallback(f=>{if(d.length===0)return null;let y=f!==null?d[f]:d[d.length-1];return y?{timestamp:y.timestamp,date:y.date,markets:a.map((x,g)=>{let h=t.find(k=>k.ticker===x);return {id:x,label:h?.yesSubTitle||`Market ${g+1}`,value:y[x]??0,color:Tt[g%Tt.length].stroke}})}:null},[d,a,t]);react.useEffect(()=>{l.current&&d.length>0&&l.current(c(null));},[d,c]),react.useEffect(()=>{l.current&&l.current(c(i));},[i,c]);let p=react.useCallback(f=>{typeof f?.activeTooltipIndex=="number"&&o(f.activeTooltipIndex);},[]),m=react.useCallback(()=>{o(null);},[]);return r?jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px] flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-default-400 text-sm",children:"Loading chart..."})}):d.length===0?jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px] flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-default-400 text-sm",children:"No price history data"})}):jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px]",children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:d,margin:{top:10,right:16,left:16,bottom:0},onMouseMove:p,onMouseLeave:m,children:[jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",tick:f=>{let{x:y,y:x,payload:g,index:h}=f,k=d.length,P=Math.max(1,Math.ceil(k/6)),C=h===0,N=h===k-1,R=h%P===0;return !C&&!N&&!R?null:jsxRuntime.jsx("text",{x:y,y:x+10,textAnchor:"middle",fill:"hsl(var(--heroui-default-500))",fontSize:10,children:as(g.value,n)})},tickLine:false,axisLine:false,interval:0}),jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"hsl(var(--heroui-default-200))"}),jsxRuntime.jsx(recharts.YAxis,{domain:u,tickLine:false,axisLine:false,tick:{fontSize:10,fill:"hsl(var(--heroui-default-500))"},tickFormatter:f=>`${f}%`,width:40}),jsxRuntime.jsx(recharts.Tooltip,{contentStyle:{backgroundColor:"hsl(var(--heroui-content1))",border:"1px solid hsl(var(--heroui-default-200))",borderRadius:"8px",fontSize:"12px"},labelFormatter:f=>as(f,n),formatter:(f,y)=>{let g=t.find(h=>h.ticker===y)?.yesSubTitle||y;return [`${f.toFixed(2)}%`,g]}}),a.map((f,y)=>jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:f,stroke:Tt[y%Tt.length].stroke,strokeWidth:2,isAnimationActive:false,dot:x=>jsxRuntime.jsx(gu,{...x,dataLength:d.length},`dot-${f}-${x.index}`),activeDot:false},f))]})})})}function cs(){return {timestamp:Date.now()/1e3,date:new Date().toLocaleDateString("en-US",{month:"short",day:"numeric"}),markets:[]}}function ds({marketTicker:e,openTime:t,chartRange:r=Se}){let n=ht[r],s=kt[r],i=react.useMemo(()=>Math.floor(Date.now()/1e3),[r]),o=react.useMemo(()=>s!=null?i-s:t??i,[i,s,t]),{data:l,isLoading:a,isFetching:d,error:u}=Yt({ticker:e,startTs:o,endTs:i,periodInterval:n},{enabled:!!e});return {candlesticks:l,isLoading:a,isFetching:d,error:u,periodInterval:n}}var Eu="hsl(var(--heroui-primary))",wu=[{value:w.ONE_DAY,label:"1D"},{value:w.ONE_WEEK,label:"1W"},{value:w.ONE_MONTH,label:"1M"},{value:w.ALL,label:"ALL"}];function Tu(e){let{cx:t,cy:r,index:n,dataLength:s,stroke:i}=e;return n!==s-1||t==null||r==null?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:i,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;8;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.1;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3,fill:i})]})}function ms(e,t){let r=new Date(e*1e3);switch(t){case w.ONE_DAY:return r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});case w.ONE_WEEK:case w.ONE_MONTH:return r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false});case w.ALL:default:return r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function Mu(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0)}function Nu(e,t){let r=bt[t],n=e.candlesticks??[],s=new Map;for(let o of n){let l=o.end_period_ts-o.end_period_ts%r,a=s.get(l);s.set(l,{close:o.yes_ask.close,volume:(a?.volume??0)+(o.volume??0)});}return Array.from(s.entries()).sort((o,l)=>o[0]-l[0]).map(([o,{close:l,volume:a}])=>({timestamp:o,date:new Date(o*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"}),value:Math.round(l*100)/100,volume:a}))}function fs({candlesticks:e,isLoading:t,chartRange:r,onRangeChange:n}){let s=react.useMemo(()=>e?Nu(e,r):[],[e,r]),i=react.useMemo(()=>{if(s.length===0)return [0,100];let o=1/0,l=-1/0;for(let p of s)p.value<o&&(o=p.value),p.value>l&&(l=p.value);if(o===1/0||l===-1/0)return [0,100];let a=l-o,d=Math.max(a*.2,5),u=Math.max(0,Math.floor(o-d)),c=Math.min(100,Math.ceil(l+d));return [u,c]},[s]);return t?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-neutral text-sm",children:"Loading chart..."})}),jsxRuntime.jsx(gr,{chartRange:r,onRangeChange:n})]}):s.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-neutral text-sm",children:"No price history data"})}),jsxRuntime.jsx(gr,{chartRange:r,onRangeChange:n})]}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full",children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:s,margin:{top:10,right:16,left:16,bottom:0},children:[jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",tick:o=>{let{x:l,y:a,payload:d,index:u}=o,c=s.length,m=Math.max(1,Math.ceil(c/6)),f=u===0,y=u===c-1,x=u%m===0;return !f&&!y&&!x?null:jsxRuntime.jsx("text",{x:l,y:a+10,textAnchor:"middle",fill:"hsl(var(--heroui-default-500))",fontSize:10,children:ms(d.value,r)})},tickLine:false,axisLine:false,interval:0}),jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"hsl(var(--heroui-default-200))"}),jsxRuntime.jsx(recharts.YAxis,{domain:i,tickLine:false,axisLine:false,tick:{fontSize:10,fill:"hsl(var(--heroui-default-500))"},tickFormatter:o=>`${o}%`,width:40}),jsxRuntime.jsx(recharts.Tooltip,{cursor:{stroke:"hsl(var(--heroui-default-300))"},content:({active:o,payload:l})=>{if(!o||!l?.length)return null;let a=l[0].payload,d=Math.round(a.value);return jsxRuntime.jsxs("div",{className:"rounded-lg border border-default-200 bg-content1 px-3 py-2 shadow-md",children:[jsxRuntime.jsxs("div",{className:"text-lg font-semibold text-primary",children:["Yes ",d,"\xA2"]}),jsxRuntime.jsxs("div",{className:"text-sm text-neutral",children:["Vol ",Mu(a.volume)," \xB7"," ",ms(a.timestamp,r)]})]})}}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"value",stroke:Eu,strokeWidth:2,isAnimationActive:false,dot:o=>jsxRuntime.jsx(Tu,{...o,dataLength:s.length},`dot-${o.index}`),activeDot:false})]})})}),jsxRuntime.jsx(gr,{chartRange:r,onRangeChange:n})]})}function gr({chartRange:e,onRangeChange:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-1",children:wu.map(r=>{let n=e===r.value;return jsxRuntime.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-md transition-colors cursor-pointer ${n?"bg-primary text-primary-foreground":"bg-default-100 text-default-600 hover:bg-default-200"}`,onClick:()=>t?.(r.value),children:r.label},r.value)})})}function ys({marketTicker:e}){let{data:t,isLoading:r,error:n}=Ae(e,{enabled:!!e});return {orderbook:react.useMemo(()=>{if(!t)return null;let{yesBids:i,yesAsks:o,noBids:l,noAsks:a}=t;return {yesBids:i,yesAsks:o,noBids:l,noAsks:a,bestYesBid:i.length>0?i[0].price:null,bestYesAsk:o.length>0?o[0].price:null,bestNoBid:l.length>0?l[0].price:null,bestNoAsk:a.length>0?a[0].price:null,sequence:t.sequence??null}},[t]),isOrderbookLoading:r,orderbookError:n}}function gs(e,t){let r=e.slice(0,t),n=0;return r.map(s=>(n+=s.quantity,{...s,cumulative:n,depth:0,total:s.price*s.quantity}))}function vs(e,t){for(let r of e)r.depth=t>0?r.cumulative/t:0;}function ks(e){return `${Math.round(e*100)}\xA2`}function Iu(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Lu(e){return e>=1e6?`$${(e/1e6).toFixed(2)}M`:e>=1e3?`$${(e/1e3).toFixed(2)}K`:e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function xs({row:e,side:t,showType:r=false,onClick:n}){let{t:s}=i18n.useTranslation(),i=t==="ask",o=i?"bg-bullish/10":"bg-bearish/10",l=i?"text-bullish":"text-bearish";return jsxRuntime.jsxs("button",{type:"button",className:"relative grid w-full grid-cols-4 px-2 py-2.5 text-xs cursor-pointer hover:bg-default-100 transition-colors",onClick:()=>n?.(e.price,t),children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${o} transition-[width] duration-200`,style:{width:`${e.depth*100}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 font-mono font-medium ${l} text-left`,children:r?s(i?"predict.trade.bestAsk":"predict.trade.bestBid"):""}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:ks(e.price)}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:Iu(e.quantity)}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:Lu(e.total)})]})}function hs({index:e}){let t=["60%","45%","75%","55%","65%","50%","70%","40%"];return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100",style:{width:t[e%t.length]}}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"})]})}function Bu(){return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"})]}),Array.from({length:vr}).map((e,t)=>jsxRuntime.jsx(hs,{index:t},`ask-${t}`)),jsxRuntime.jsx("div",{className:"flex justify-center border-y border-default-200 px-2 py-2.5",children:jsxRuntime.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-default-100"})}),Array.from({length:vr}).map((e,t)=>jsxRuntime.jsx(hs,{index:t+3},`bid-${t}`))]})}var vr=8;function xr({bids:e,asks:t,isLoading:r=false,maxLevels:n=vr,onPriceClick:s}){let{t:i}=i18n.useTranslation(),{bidRows:o,askRows:l,spread:a,spreadPercent:d}=react.useMemo(()=>{let c=gs(e,n),p=gs(t,n),m=Math.max(c[c.length-1]?.cumulative??0,p[p.length-1]?.cumulative??0);vs(c,m),vs(p,m);let f=c[0]?.price??null,y=p[0]?.price??null,x=null,g=null;if(f!=null&&y!=null){x=y-f;let h=(f+y)/2;h>0&&(g=Math.round(x/h*1e4)/100);}return {bidRows:c,askRows:p,spread:x,spreadPercent:g}},[e,t,n]);return r?jsxRuntime.jsx(Bu,{}):o.length===0&&l.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:i("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.total")})]}),jsxRuntime.jsx("div",{className:"flex flex-col-reverse",children:l.map((c,p)=>jsxRuntime.jsx(xs,{row:c,side:"ask",showType:p===0,onClick:s},c.price))}),a!=null&&jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 border-y border-default-200 px-2 py-2.5 text-xs text-default-500",children:[jsxRuntime.jsxs("span",{children:[i("predict.orderBook.spread"),": ",ks(a)]}),d!=null&&jsxRuntime.jsxs("span",{className:"text-default-400",children:["(",d,"%)"]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:o.map((c,p)=>jsxRuntime.jsx(xs,{row:c,side:"bid",showType:p===0,onClick:s},c.price))})]})}function _u(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(2)}K`:e.toLocaleString(void 0,{maximumFractionDigits:2})}function Vu(e){let t=Math.abs(e),r=e>=0?"+":"-";return t>=1e3?`${r}$${(t/1e3).toFixed(1)}K`:t>=1?`${r}$${t.toFixed(2)}`:`${r}$${t.toFixed(4)}`}function Ps({positions:e,isLoading:t=false}){let{t:r}=i18n.useTranslation();return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})}):e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:r("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-5 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{children:r("predict.positions.outcome")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.qty")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.avgCost")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.currentPrice")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.pnl")})]}),e.map(n=>{let s=n.position==="YES",i=s?"text-bullish":"text-bearish",o=r(s?"predict.market.yes":"predict.market.no"),l=n.avgCost!=null?`${Math.round(n.avgCost*100)}\xA2`:"\u2014",a=n.currentPrice!=null?`${Math.round(n.currentPrice*100)}\xA2`:"\u2014",d=n.pnl!=null&&n.pnlPercent!=null,u=d&&n.pnl>0?"text-bullish":d&&n.pnl<0?"text-bearish":"text-foreground";return jsxRuntime.jsxs("div",{className:"grid grid-cols-5 px-2 py-2.5 text-xs hover:bg-default-100 transition-colors",children:[jsxRuntime.jsx("span",{className:`font-medium ${i}`,children:o}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:_u(n.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:l}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:a}),jsxRuntime.jsx("span",{className:`text-right font-mono ${u}`,children:d?jsxRuntime.jsxs("span",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{children:Vu(n.pnl)}),jsxRuntime.jsxs("span",{className:"text-[10px] opacity-70",children:[n.pnlPercent>=0?"+":"",n.pnlPercent.toFixed(1),"%"]})]}):"\u2014"})]},n.mint)})]})}function Du(e){let t=e/1e6;return t>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(2)}K`:t.toLocaleString(void 0,{maximumFractionDigits:2})}function Fu(e){return e==null?"\u2014":`${Math.round(e*100)}\xA2`}function Wu(e){let t=new Date(e*1e3),r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${n} ${s}:${i}`}function qu({index:e}){let t=["60%","45%","75%","55%","65%"];return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100",style:{width:t[e%t.length]}}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"})]})}function Ss({trades:e,isLoading:t=false}){let{t:r}=i18n.useTranslation();return t?jsxRuntime.jsx("div",{className:"flex flex-col",children:Array.from({length:6}).map((n,s)=>jsxRuntime.jsx(qu,{index:s},s))}):e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.time")})]}),e.map(n=>{let s=n.side==="yes",i=s?"text-bullish":"text-bearish",o=n.side?r(s?"predict.trade.yes":"predict.trade.no"):"\u2014";return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs hover:bg-default-100 transition-colors",children:[jsxRuntime.jsx("span",{className:`font-medium ${i}`,children:o}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:Fu(n.usdPricePerContract)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:Du(n.outputAmount)}),jsxRuntime.jsx("span",{className:"text-right text-default-500",children:Wu(n.createdAt)})]},n.id)})]})}function Ts({market:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[n,s]=react.useState("trade-yes"),[i,o]=react.useState(Se),{orderbook:l,isOrderbookLoading:a}=ys({marketTicker:e.ticker}),{candlesticks:d,isFetching:u}=ds({marketTicker:e.ticker,openTime:e.openTime,chartRange:i}),{positions:c,isLoading:p}=Xr(e),{status:m}=walletConnector.useAuth(),x=walletConnector.useWallets().find(N=>N.chainNamespace===types.ChainNamespace.SOLANA&&N.isConnected)?.address,{data:g,isLoading:h}=qr({walletAddress:x??""},{enabled:(n==="trade-history"||n==="positions")&&m==="authenticated"&&!!x}),k=(g?.trades??[]).filter(N=>N.marketTicker===e.ticker),v=react.useMemo(()=>c.map(N=>{let R=k.filter(he=>he.outputMint===N.mint&&he.usdPricePerContract!=null&&he.contracts!=null&&he.contracts>0),S=Xu(R),L=N.position==="YES"?ws(N.market?.yesAsk):ws(N.market?.noAsk),V=null,Oe=null;return S!=null&&L!=null&&(V=(L-S)*N.balance,Oe=S>0?(L-S)/S*100:null),{...N,avgCost:S,currentPrice:L,pnl:V,pnlPercent:Oe}}),[c,k]),P=react.useCallback((N,R)=>{t?.(e,"yes",R==="ask"?"buy":"sell");},[e,t]),C=react.useCallback((N,R)=>{t?.(e,"no",R==="ask"?"buy":"sell");},[e,t]);return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:N=>s(N),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:r("predict.market.tradeYes")},"trade-yes"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.market.tradeNo")},"trade-no"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.market.graph")},"graph"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.positions.title")},"positions"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.tradeHistory.title")},"trade-history")]}),jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[n==="trade-yes"&&jsxRuntime.jsx(xr,{bids:l?.yesBids??[],asks:l?.yesAsks??[],isLoading:a,onPriceClick:P}),n==="trade-no"&&jsxRuntime.jsx(xr,{bids:l?.noBids??[],asks:l?.noAsks??[],isLoading:a,onPriceClick:C}),n==="graph"&&jsxRuntime.jsx(fs,{candlesticks:d,isLoading:u,chartRange:i,onRangeChange:o}),n==="positions"&&jsxRuntime.jsx(Ps,{positions:v,isLoading:p}),n==="trade-history"&&jsxRuntime.jsx(Ss,{trades:k,isLoading:h})]})]})}function Xu(e){if(e.length===0)return null;let t=0,r=0;for(let n of e)t+=n.contracts,r+=n.usdPricePerContract*n.contracts;return t>0?r/t:null}function ws(e){if(e==null)return null;let t=Number(e);return Number.isFinite(t)?t:null}var br=4;function Zu(e){let t=e.yesAsk?Math.round(parseFloat(e.yesAsk)*100):null,r=e.noAsk?Math.round(parseFloat(e.noAsk)*100):null;return {yesCents:t,noCents:r}}function Bs({markets:e,renderMarketDetail:t,onTradeAction:r,marketHoldings:n}){let{t:s}=i18n.useTranslation(),[i,o]=react.useState(false),[l,a]=react.useState(null);if(e.length===0)return null;let d=e.length>br,u=i?e:e.slice(0,br),c=p=>{a(m=>m===p?null:p);};return jsxRuntime.jsxs("div",{className:"flex flex-col divide-y divide-default-200",children:[u.map(p=>{let{yesCents:m,noCents:f}=Zu(p),y=l===p.ticker;return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 px-2 py-3 transition-colors hover:bg-content2 lg:gap-x-4 cursor-pointer",onClick:()=>c(p.ticker),role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(p.ticker));},children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1 min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium truncate lg:text-base",children:p.yesSubTitle}),(()=>{let x=n?.get(p.ticker);if(!x)return null;let{yesShares:g,noShares:h}=x;return g<=0&&h<=0?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1.5",children:[g>0&&jsxRuntime.jsx(ui$1.Chip,{size:"sm",variant:"flat",color:"primary",classNames:{base:"h-5",content:"text-[10px] font-medium px-1"},children:s("predict.market.sharesYes",{shares:g%1===0?g:g.toFixed(2)})}),h>0&&jsxRuntime.jsx(ui$1.Chip,{size:"sm",variant:"flat",color:"secondary",classNames:{base:"h-5",content:"text-[10px] font-medium px-1"},children:s("predict.market.sharesNo",{shares:h%1===0?h:h.toFixed(2)})})]})})()]}),(()=>{let x=m!=null,g=f!=null;return x&&!g&&m<=1?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"< 1%"}):g&&!x&&f<=1?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"> 99%"}):!x&&!g?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"0%"}):jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center lg:text-xl",children:`${m}%`})})(),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 flex-1 justify-end",children:[jsxRuntime.jsx(ui$1.Button,{size:"sm",color:"primary",className:"w-20 bg-primary-100 text-primary",onPress:()=>r?.(p,"yes","buy"),children:m!=null?s("predict.market.action.yes",{price:m}):s("predict.market.yes")}),jsxRuntime.jsx(ui$1.Button,{size:"sm",color:"secondary",className:"w-20 bg-secondary-100 text-secondary",onPress:()=>r?.(p,"no","buy"),children:f!=null?s("predict.market.action.no",{price:f}):s("predict.market.no")})]}),y?jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"h-4 w-4 shrink-0 text-default-400"}):jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-4 w-4 shrink-0 text-default-400"})]}),y&&t&&jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto px-2 pb-3",children:t(p)})]},p.ticker)}),d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>o(p=>!p),className:"flex items-center justify-center gap-x-1.5 px-2 py-2.5 text-sm text-default-500 transition-colors cursor-pointer hover:text-primary",children:i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:s("predict.event.rules.collapse")}),jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"h-4 w-4"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:s("predict.event.moreMarkets",{count:e.length-br})}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-4 w-4"})]})})]})}var nd=new Set(["closed","determined","finalized"]);function Nt(e){let t=new Date(e*1e3),r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${s} ${i}:${o}`}function sd({market:e}){let t=nd.has(e.status),r=react.useMemo(()=>{let s={label:"Market Open",value:Nt(e.openTime),isActive:true},i={label:"Market Closes",value:t?Nt(e.closeTime):"After the outcome occurs",isActive:t},o={label:"Projected Payout",value:"30 minutes after closing",isActive:e.status==="finalized"};return [s,i,o]},[e.openTime,e.closeTime,e.status,t]),n=react.useMemo(()=>t?null:e.canCloseEarly&&e.earlyCloseCondition?`${e.earlyCloseCondition} Otherwise, it closes by ${Nt(e.expirationTime)}.`:`This market closes by ${Nt(e.expirationTime)}.`,[t,e.canCloseEarly,e.earlyCloseCondition,e.expirationTime]);return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[r.map((s,i)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${s.isActive?"border-primary bg-primary":"border-default-300 bg-transparent"}`}),i<r.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-default-200"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${i<r.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:s.label}),jsxRuntime.jsx("span",{className:"text-xs text-default-500 lg:text-sm",children:s.value})]})]},s.label)),n&&jsxRuntime.jsx("p",{className:"text-xs text-default-500 mt-3 lg:text-sm",children:n})]})}function Us({markets:e,event:t,series:r}){let{t:n}=i18n.useTranslation(),[s,i]=react.useState(null),o=e.filter(a=>a.rulesPrimary);if(o.length===0)return null;let l=o.find(a=>a.ticker===s)??o[0];return l?.rulesPrimary?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium lg:text-base",children:n("predict.event.rules")}),o.length>1&&jsxRuntime.jsx(ui$1.Select,{size:"sm","aria-label":"Select market rules",className:"max-w-48",classNames:{trigger:"min-h-8 h-8",value:"text-xs"},selectedKeys:new Set([l.ticker]),onSelectionChange:a=>{if(a==="all")return;let d=Array.from(a);d.length>0&&i(d[0]);},children:o.map(a=>jsxRuntime.jsx(ui$1.SelectItem,{textValue:a.yesSubTitle,children:jsxRuntime.jsx("span",{className:"text-xs truncate",children:a.yesSubTitle})},a.ticker))}),jsxRuntime.jsx("div",{className:"text-xs text-foreground lg:text-sm",children:l.rulesPrimary}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-default-500 mt-2 lg:text-sm",children:"Timeline and payout"}),jsxRuntime.jsx(sd,{market:l}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-default-400 mt-2 lg:text-xs",children:[r?.ticker&&jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Series:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:r.ticker})]}),t.ticker&&jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Event:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.ticker})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Market:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:l.ticker})]})]})]}):null}var md=[{value:w.ONE_DAY,label:"1D"},{value:w.ONE_WEEK,label:"1W"},{value:w.ONE_MONTH,label:"1M"},{value:w.ALL,label:"ALL"}];function Vs({event:e,series:t,candlesticks:r,chartRange:n=w.ONE_DAY,periodInterval:s,isCandlesticksLoading:i,onRangeChange:o,selectedMarketTickers:l,onMarketSelectionChange:a,onTradeAction:d}){let{t:u}=i18n.useTranslation(),[c,p]=react.useState(cs()),[m,f]=react.useState(false),y=react.useRef(null);react.useEffect(()=>{let v=y.current;if(!v)return;let P=false,C=0,N=()=>{let{bottom:S}=v.getBoundingClientRect(),L=P?S<0:S<-20;L!==P&&(P=L,f(L));},R=()=>{cancelAnimationFrame(C),C=requestAnimationFrame(N);};return window.addEventListener("scroll",R,{passive:true,capture:true}),N(),()=>{cancelAnimationFrame(C),window.removeEventListener("scroll",R,{capture:true});}},[]);let x=react.useMemo(()=>[...e.markets||[]].sort((v,P)=>Number(P.yesAsk??0)-Number(v.yesAsk??0)),[e.markets]),{holdings:g}=is(x),h=react.useMemo(()=>utils.formatAmountUSDCompact((e.volume??0)/100),[e.volume]),k=react.useMemo(()=>{if(!e.strikeDate)return null;let v=new Date(e.strikeDate*1e3),P=v.toLocaleString("default",{month:"short"}),C=v.getDate(),N=v.getFullYear();return `${P} ${C}, ${N}`},[e.strikeDate]);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-4 lg:gap-y-6 px-1 pb-8 lg:px-4 lg:pb-12 lg:max-w-3xl",children:[jsxRuntime.jsx("div",{ref:y,className:"h-0 w-0"}),jsxRuntime.jsxs("div",{className:`sticky top-0 z-30 flex items-center bg-background/80 backdrop-blur-md transition-all duration-300 ${m?"gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.imageUrl||void 0,name:e.title||"Event",radius:"lg",className:`flex-shrink-0 transition-all duration-300 ${m?"!h-8 !w-8 lg:!h-10 lg:!w-10":"!h-14 !w-14 lg:!h-18 lg:!w-18"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[!m&&(t?.category||t?.tags&&t.tags.length>0)&&jsxRuntime.jsxs("span",{className:"text-xs text-default-500 lg:text-sm truncate",children:[t.category,t.category&&t.tags?.length>0&&" \xB7 ",t.tags?.join(", ")]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${m?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-4",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[c&&c.markets.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-xs lg:text-sm",children:c.markets.map(v=>jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:v.color}}),jsxRuntime.jsx("span",{className:"text-default-600",children:v.label})]},v.id))}),jsxRuntime.jsx(ls,{candlesticks:r,chartRange:n,markets:x,isLoading:i,onDataChange:v=>p(v)}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 mt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 text-xs text-default-500 lg:text-sm",children:[jsxRuntime.jsxs("span",{children:[h," ",u("predict.event.volume")]}),k&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-default-300",children:"\xB7"}),jsxRuntime.jsx("span",{children:u("predict.event.endDate",{date:k})})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-x-1",children:md.map(v=>jsxRuntime.jsx("button",{type:"button",onClick:()=>o?.(v.value),className:`px-2 lg:px-3 py-1 text-xs rounded-md transition-colors cursor-pointer ${n===v.value?"bg-primary text-primary-foreground":"bg-default-100 text-default-600 hover:bg-default-200"}`,children:v.label},v.value))}),x.length>1&&jsxRuntime.jsx(ui$1.Select,{size:"sm",selectionMode:"multiple",placeholder:"Markets","aria-label":"Select markets",className:"min-w-28 max-w-48",classNames:{trigger:"min-h-8 h-8",value:"text-xs"},selectedKeys:l?new Set(l):void 0,onSelectionChange:v=>{if(v==="all")return;let P=Array.from(v);P.length<=4&&a?.(P);},children:jsxRuntime.jsx(ui$1.SelectSection,{title:`Pick up to ${4} markets`,classNames:{heading:"text-xs text-default-400 px-2 py-1"},children:x.map(v=>jsxRuntime.jsx(ui$1.SelectItem,{textValue:v.yesSubTitle,children:jsxRuntime.jsx("span",{className:"text-xs truncate",children:v.yesSubTitle})},v.ticker))})})]})]})}),jsxRuntime.jsx(Bs,{markets:x,onTradeAction:d,marketHoldings:g,renderMarketDetail:v=>jsxRuntime.jsx(Ts,{market:v,onTradeAction:d})}),jsxRuntime.jsx(Us,{markets:x,event:e,series:t})]})}function Sr({eventId:e,initialMarketTickers:t,initialChartRange:r=Se,onTradeAction:n}){let[s,i]=react.useState(r),[o,l]=react.useState(t),{event:a,isEventLoading:d,eventError:u,series:c,isSeriesLoading:p,periodInterval:m,candlesticks:f,isCandlesticksLoading:y,candlestickErrors:x}=os({eventId:e,candlestickMarketTickers:o,chartRange:s}),g=react.useRef(!!t);react.useEffect(()=>{if(a?.markets&&!g.current){g.current=true;let v=[...a.markets].sort((P,C)=>Number(C.yesAsk??0)-Number(P.yesAsk??0)).slice(0,4).map(P=>P.ticker);l(v);}},[a?.markets]);let h=react.useMemo(()=>v=>{i(v);},[]),k=react.useMemo(()=>v=>{l(v);},[]);return d||p?jsxRuntime.jsx(et,{}):u||!a?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:u?.message||"Event not found"}):jsxRuntime.jsx(Vs,{event:a,series:c,candlesticks:f,chartRange:s,periodInterval:m,isCandlesticksLoading:y,candlestickErrors:x,onRangeChange:h,selectedMarketTickers:o,onMarketSelectionChange:k,onTradeAction:n})}function Fk({eventId:e,chain:t,...r}){let{t:n}=i18n.useTranslation(),{isMobile:s}=ui$1.useScreen(),{isOpen:i,onOpen:o,onClose:l}=ui$1.useDisclosure(),{data:a,isLoading:d}=mt({id:e,withNestedMarkets:true}),u=react.useMemo(()=>[...a?.markets||[]].sort((x,g)=>Number(g.yesAsk??0)-Number(x.yesAsk??0)),[a?.markets]),[c,p]=react.useState(null),m=react.useCallback((x,g,h)=>{p(k=>({market:x,outcome:g,side:h,version:(k?.version??0)+1})),s&&o();},[s,o]),f=c?.market??u[0];if(d)return s?jsxRuntime.jsx(et,{}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(et,{})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4",children:jsxRuntime.jsx(ss,{})})})]});let y=c?`${c.market.ticker}-${c.version}`:f?.ticker??"default";return s?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-full pb-20",children:jsxRuntime.jsx(Sr,{eventId:e,onTradeAction:m,...r})}),f&&jsxRuntime.jsx("div",{className:"fixed inset-x-0 bottom-0 z-40 flex justify-center p-3 bg-gradient-to-t from-background via-background/90 to-transparent",children:jsxRuntime.jsx(ui$1.Button,{color:"primary",size:"lg",className:"w-full max-w-md font-semibold",onPress:o,children:n("predict.trade.action")})}),jsxRuntime.jsx(ui$1.Drawer,{isOpen:i,onClose:l,placement:"bottom",size:"lg",hideCloseButton:true,classNames:{base:"max-h-[85dvh] rounded-t-2xl",body:"p-0"},children:jsxRuntime.jsx(ui$1.DrawerContent,{children:jsxRuntime.jsx(ui$1.DrawerBody,{children:f&&jsxRuntime.jsx(dr,{event:a,market:f,initialSide:c?.side,initialOutcome:c?.outcome,chain:t},y)})})})]}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Sr,{eventId:e,onTradeAction:m,...r})}),f&&jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 flex flex-col gap-y-4",children:jsxRuntime.jsx(dr,{event:a,market:f,initialSide:c?.side,initialOutcome:c?.outcome,chain:t},y)})})]})}function Fs(e,t){if(!e)return [];let r=e.slice(0,t),n=0,s=r.map(o=>(n+=o.quantity,{...o,cumulative:n,depth:0})),i=s[s.length-1]?.cumulative??1;for(let o of s)o.depth=o.cumulative/i;return s}function Ws({marketTicker:e,maxLevels:t=10,refetchInterval:r=5e3,outcome:n="yes"}){let{data:s,isLoading:i,isFetching:o}=Ae(e,{refetchInterval:r||void 0}),l=react.useMemo(()=>n==="yes"?s?.yesBids:s?.noBids,[s,n]),a=react.useMemo(()=>n==="yes"?s?.yesAsks:s?.noAsks,[s,n]),d=react.useMemo(()=>Fs(l,t),[l,t]),u=react.useMemo(()=>Fs(a,t),[a,t]),c=react.useMemo(()=>d.length===0||u.length===0?null:u[0].price-d[0].price,[d,u]),p=react.useMemo(()=>d.length===0||u.length===0?null:(d[0].price+u[0].price)/2,[d,u]),m=react.useMemo(()=>c===null||p===null||p===0?null:Math.round(c/p*1e4)/100,[c,p]);return {bids:d,asks:u,spread:c,spreadPercent:m,midpoint:p,isLoading:i,isFetching:o}}function qs({row:e,side:t,onClick:r}){let n=t==="bid",s=n?"bg-primary/10":"bg-danger/10",i=n?"text-primary":"text-danger";return jsxRuntime.jsxs("button",{type:"button",className:"relative flex w-full items-center justify-between px-3 py-1 text-xs hover:bg-default-100 cursor-pointer",onClick:()=>r?.(e.price),children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 ${n?"right-0":"left-0"} ${s}`,style:{width:`${e.depth*100}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 font-medium ${i}`,children:[e.price,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-default-600",children:e.quantity}),jsxRuntime.jsx("span",{className:"relative z-10 text-default-400",children:e.cumulative})]})}function Hs(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-1 py-2",children:Array.from({length:5}).map((e,t)=>jsxRuntime.jsx("div",{className:"mx-3 h-4 animate-pulse rounded bg-default-100"},t))})}function Ks({bids:e,asks:t,spread:r,spreadPercent:n,isLoading:s,onPriceClick:i}){let{t:o}=i18n.useTranslation();if(s)return jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:o("predict.orderBook.title")}),jsxRuntime.jsx(Hs,{}),jsxRuntime.jsx(Hs,{})]});let l=e.length===0&&t.length===0;return jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-default-200 px-3 py-2",children:jsxRuntime.jsx("span",{className:"text-sm font-medium",children:o("predict.orderBook.title")})}),l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-3 py-1 text-xxs text-default-400",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{children:o("predict.orderBook.qty")}),jsxRuntime.jsx("span",{children:o("predict.orderBook.total")})]}),jsxRuntime.jsx("div",{className:"flex flex-col-reverse",children:t.map(a=>jsxRuntime.jsx(qs,{row:a,side:"ask",onClick:i},a.price))}),r!==null&&jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 border-y border-default-200 py-1.5 text-xs text-default-500",children:[jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),": ",r,"\xA2"]}),n!==null&&jsxRuntime.jsxs("span",{className:"text-default-400",children:["(",n,"%)"]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(a=>jsxRuntime.jsx(qs,{row:a,side:"bid",onClick:i},a.price))})]})]})}function c0({marketTicker:e,maxLevels:t,refetchInterval:r,onPriceClick:n,outcome:s}){let{bids:i,asks:o,spread:l,spreadPercent:a,isLoading:d}=Ws({marketTicker:e,maxLevels:t,refetchInterval:r,outcome:s});return jsxRuntime.jsx(Ks,{bids:i,asks:o,spread:l,spreadPercent:a,isLoading:d,onPriceClick:n})}function zs(e={}){let[t,r]=react.useState(null),[n]=react.useState(null),s=react.useCallback(i=>{r(null);},[]);return {orders:[],isLoading:false,isFetching:false,cancellingOrderId:t,cancelOrder:s,cancelError:n}}function Ad(e){return new Date(e).toLocaleString("default",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Gs({orders:e,isLoading:t,cancellingOrderId:r,onCancel:n}){let{t:s}=i18n.useTranslation(),i=react.useMemo(()=>e.map(o=>({key:o.id,side:o.side,outcome:o.outcome,type:o.type,price:o.price,filled:`${o.filledQuantity}/${o.quantity}`,status:o.status,createdAt:Ad(o.createdAt),isCancelling:o.id===r,id:o.id})),[e,r]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:s("predict.openOrders.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((o,l)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},l))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsxs("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:[s("predict.openOrders.title"),e.length>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-default-400",children:["(",e.length,")"]})]}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:s("predict.openOrders.empty")}):jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(ui$1.StyledTable,{radius:"none","aria-label":"Open orders",className:"min-w-[600px]",children:[jsxRuntime.jsxs(ui$1.TableHeader,{children:[jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Side",width:60,children:s("predict.openOrders.side")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Outcome",width:60,children:s("predict.openOrders.outcome")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Type",width:60,children:s("predict.openOrders.type")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Price",width:60,children:s("predict.openOrders.price")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Filled",width:80,children:s("predict.openOrders.filled")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Status",width:70,children:s("predict.openOrders.status")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Time",width:120,children:s("predict.openOrders.time")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Action",width:80,align:"end",children:" "})]}),jsxRuntime.jsx(ui$1.TableBody,{children:i.map(o=>jsxRuntime.jsxs(ui$1.TableRow,{children:[jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${o.side==="buy"?"text-primary":"text-danger"}`,children:o.side==="buy"?s("predict.trade.buy"):s("predict.trade.sell")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs ${o.outcome==="yes"?"text-primary":"text-secondary"}`,children:o.outcome==="yes"?s("predict.trade.yes"):s("predict.trade.no")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs capitalize",children:o.type})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.price,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:o.filled})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs capitalize",children:o.status})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:o.createdAt})}),jsxRuntime.jsx(ui$1.TableCell,{className:"text-right",children:jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"flat",color:"danger",isLoading:o.isCancelling,onPress:()=>n(o.id),children:s("predict.openOrders.cancel")})})]},o.key))})]})})]})}function E0({refetchInterval:e}={}){let{orders:t,isLoading:r,cancellingOrderId:n,cancelOrder:s}=zs({});return jsxRuntime.jsx(Gs,{orders:t,isLoading:r,cancellingOrderId:n,onCancel:s})}function Xs({ticker:e,pageSize:t=48}={}){let[r,n]=react.useState(1),[s,i]=react.useState([void 0]),o=s[r-1],l=react.useMemo(()=>({...e?{ticker:e}:{},limit:t,...o?{cursor:o}:{}}),[e,t,o]),{data:a,isLoading:d,isFetching:u}=Wr(l),c=a,p=c?.trades??[],m=!!c?.cursor,f=r>1,y=react.useCallback(h=>{h>=1&&h<=s.length&&n(h);},[s.length]),x=react.useCallback(()=>{m&&c?.cursor&&(i(h=>{let k=[...h];return k.length===r&&k.push(c.cursor),k}),n(h=>h+1));},[m,c?.cursor,r]),g=react.useCallback(()=>{f&&n(h=>h-1);},[f]);return {trades:p,isLoading:d,isFetching:u,page:r,pageSize:t,hasNextPage:m,hasPrevPage:f,goToPage:y,nextPage:x,prevPage:g}}function Xd(e){return new Date(e*1e3).toLocaleString("default",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Zs({trades:e,isLoading:t,isFetching:r,page:n,hasNextPage:s,hasPrevPage:i,onNextPage:o,onPrevPage:l}){let{t:a}=i18n.useTranslation(),d=react.useMemo(()=>e.map(u=>({key:u.tradeId,ticker:u.ticker,takerSide:u.takerSide,price:u.price,yesPrice:u.yesPrice,noPrice:u.noPrice,count:u.count,createdAt:Xd(u.createdTime)})),[e]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:a("predict.tradeHistory.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((u,c)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},c))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:a("predict.tradeHistory.title")}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:a("predict.tradeHistory.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:`w-full overflow-x-auto ${r?"opacity-60":""}`,children:jsxRuntime.jsxs(ui$1.StyledTable,{radius:"none","aria-label":"Trade history",className:"min-w-[480px]",children:[jsxRuntime.jsxs(ui$1.TableHeader,{children:[jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Side",width:60,children:a("predict.tradeHistory.side")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Price",width:80,children:a("predict.tradeHistory.price")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Yes",width:60,children:a("predict.trade.yes")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"No",width:60,children:a("predict.trade.no")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Qty",width:60,children:a("predict.tradeHistory.qty")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Time",width:120,children:a("predict.tradeHistory.time")})]}),jsxRuntime.jsx(ui$1.TableBody,{children:d.map(u=>jsxRuntime.jsxs(ui$1.TableRow,{children:[jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${u.takerSide==="yes"?"text-primary":"text-secondary"}`,children:u.takerSide==="yes"?a("predict.trade.yes"):a("predict.trade.no")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[u.price,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs text-primary",children:[u.yesPrice,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs text-secondary",children:[u.noPrice,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:u.count})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:u.createdAt})})]},u.key))})]})}),(i||s)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-default-200 px-3 py-2",children:[jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"flat",isDisabled:!i,onPress:l,startContent:jsxRuntime.jsx(ui$1.ChevronLeftIcon,{className:"h-3 w-3"}),children:a("predict.pagination.prev")}),jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:a("predict.pagination.page",{page:n})}),jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"flat",isDisabled:!s,onPress:o,endContent:jsxRuntime.jsx(ui$1.ChevronRightIcon,{className:"h-3 w-3"}),children:a("predict.pagination.next")})]})]})]})}function q0({ticker:e,pageSize:t}={}){let{trades:r,isLoading:n,isFetching:s,page:i,hasNextPage:o,hasPrevPage:l,nextPage:a,prevPage:d}=Xs({ticker:e,pageSize:t});return jsxRuntime.jsx(Zs,{trades:r,isLoading:n,isFetching:s,page:i,hasNextPage:o,hasPrevPage:l,onNextPage:a,onPrevPage:d})}function Js(e={}){let t=react.useMemo(()=>({totalValue:0,totalUnrealizedPnl:0,totalRealizedPnl:0,count:0}),[]);return {positions:[],isLoading:false,isFetching:false,summary:t}}var Rt=e=>utils.formatAmountUSDCompact(e/100);function wr({value:e}){if(e===0)return jsxRuntime.jsx("span",{className:"text-default-500",children:Rt(0)});let t=e>0;return jsxRuntime.jsxs("span",{className:t?"text-success":"text-danger",children:[t?"+":"",Rt(e)]})}function eo({positions:e,isLoading:t,summary:r,onSell:n}){let{t:s}=i18n.useTranslation(),i=react.useMemo(()=>e.map(o=>({key:`${o.marketId}-${o.outcome}`,marketTitle:o.marketTitle,outcome:o.outcome,quantity:o.quantity,avgCost:o.avgCostBasis,currentPrice:o.currentPrice,value:o.currentPrice*o.quantity,unrealizedPnl:o.unrealizedPnl,position:o})),[e]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:s("predict.positions.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((o,l)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},l))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-default-200 px-3 py-2",children:jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[s("predict.positions.title"),e.length>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-default-400",children:["(",e.length,")"]})]})}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:s("predict.positions.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(ui$1.StyledTable,{radius:"none","aria-label":"Positions",className:"min-w-[640px]",children:[jsxRuntime.jsxs(ui$1.TableHeader,{children:[jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Market",width:200,children:s("predict.positions.market")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Outcome",width:60,children:s("predict.positions.outcome")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Qty",width:50,children:s("predict.positions.qty")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Avg Cost",width:70,children:s("predict.positions.avgCost")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Price",width:60,children:s("predict.positions.currentPrice")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Value",width:80,children:s("predict.positions.value")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"PnL",width:80,children:s("predict.positions.pnl")})]}),jsxRuntime.jsx(ui$1.TableBody,{children:i.map(o=>jsxRuntime.jsxs(ui$1.TableRow,{className:n?"cursor-pointer hover:bg-default-50":"",onClick:()=>n?.(o.position),children:[jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs font-medium line-clamp-1",children:o.marketTitle})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${o.outcome==="yes"?"text-primary":"text-secondary"}`,children:o.outcome==="yes"?s("predict.trade.yes"):s("predict.trade.no")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:o.quantity})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.avgCost,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.currentPrice,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:Rt(o.value)})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:jsxRuntime.jsx(wr,{value:o.unrealizedPnl})})})]},o.key))})]})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-default-200 px-3 py-2 text-xs",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-4",children:jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.totalValue"),":"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:Rt(r.totalValue)})]})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-4",children:[jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.unrealizedPnl"),":"," ",jsxRuntime.jsx(wr,{value:r.totalUnrealizedPnl})]}),jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.realizedPnl"),":"," ",jsxRuntime.jsx(wr,{value:r.totalRealizedPnl})]})]})]})]})]})}function iP({refetchInterval:e,onSell:t}={}){let{positions:r,isLoading:n,summary:s}=Js({});return jsxRuntime.jsx(eo,{positions:r,isLoading:n,summary:s,onSell:t})}var dp=10,pp=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Ot(){let[e,t]=jotai.useAtom(pp),r=react.useCallback(s=>{let i=s.trim();i&&t(o=>{let l=o.filter(a=>a!==i);return [i,...l].slice(0,dp)});},[t]),n=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function so({histories:e,onSelect:t,onClear:r,className:n}){let{t:s}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui$1.cn("px-4 pb-4",n),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:s("predict.search.history")}),jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui$1.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsxRuntime.jsx(ui$1.Chip,{size:"sm",variant:"bordered",className:ui$1.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function oo({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Ot();return jsxRuntime.jsx(so,{className:ui$1.cn(t),histories:r,onSelect:e,onClear:n})}function io({value:e,onValueChange:t,onClear:r,onEscape:n,className:s}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:s,children:jsxRuntime.jsx(ui$1.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui$1.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui$1.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:o=>{o.preventDefault(),n?.();},children:"Esc"})})})}function co({event:e,href:t,LinkComponent:r,onSelect:n,onHover:s,className:i}){let o=e.tags?.[0];return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:r,className:ui$1.cn("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:t?void 0:()=>n?.(e),onMouseEnter:()=>s?.(e),children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),o&&jsxRuntime.jsx("span",{className:ui$1.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:o.label})]})]})}function uo({keyword:e,limit:t,source:r}){let{data:n,isLoading:s,isFetchingNextPage:i,hasNextPage:o,fetchNextPage:l}=_r({keyword:e,limit:t,source:r},{enabled:!!e});return {events:react.useMemo(()=>n?.pages.flatMap(d=>d.items).filter(d=>d!=null)??[],[n]),isLoading:s,isFetchingNextPage:i,hasNextPage:o??false,fetchNextPage:l}}var Bp=56;function yo({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:s,...i}){let{events:o,isLoading:l,isFetchingNextPage:a,hasNextPage:d,fetchNextPage:u}=uo(i),c=react.useRef(null),{height:p}=hooks.useResizeObserver({ref:c}),m=react.useCallback(g=>g<o.length,[o]),f=react.useCallback(async()=>{d&&!a&&await u();},[d,a,u]),y=react.useMemo(()=>d?o.length+1:o.length,[o,d]),x=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:f,rowCount:y,threshold:5});return l?jsxRuntime.jsx(Up,{className:s}):o.length===0?jsxRuntime.jsx(_p,{className:s}):jsxRuntime.jsx("div",{className:ui$1.cn("w-full h-full flex flex-col",s),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:c,children:jsxRuntime.jsx(reactWindow.List,{style:{height:p},onRowsRendered:x,rowComponent:Qp,rowCount:y,rowHeight:Bp,rowProps:{events:o,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function Qp({index:e,style:t,events:r,onSelect:n,getEventHref:s,LinkComponent:i,onHover:o}){let l=r[e];return l?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(co,{event:l,href:s?.(l),LinkComponent:i,onSelect:n,onHover:o})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})})}function Up({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui$1.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function _p({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui$1.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function ho({onKeywordChange:e}){let[t,r]=react.useState(""),[n,s]=react.useState(""),{addHistory:i}=Ot(),o=hooks.useCallbackRef(e),l=hooks.useCallbackRef(i),a=react.useMemo(()=>utils.debounce(p=>{s(p),o(p),p&&l(p);},500),[o,l]),d=react.useCallback(p=>{r(p),a(p);},[a]),u=react.useCallback(p=>{a.cancel(),r(p),s(p),o(p),p&&l(p);},[a,o,l]),c=react.useCallback(()=>u(""),[u]);return {text:t,keyword:n,setText:d,setKeyword:u,clearKeyword:c}}function bo({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:s,onEscape:i,source:o}){let{text:l,keyword:a,setText:d,setKeyword:u,clearKeyword:c}=ho({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(io,{value:l,onValueChange:d,onClear:c,onEscape:i}),a?jsxRuntime.jsx(yo,{className:"flex-auto min-h-0",keyword:a,onSelect:t,getEventHref:r,LinkComponent:n,onHover:s,source:o}):jsxRuntime.jsxs("div",{className:"flex-auto min-h-0 flex flex-col",children:[jsxRuntime.jsx(oo,{onSelect:u}),jsxRuntime.jsx(Wp,{})]})]})}function Wp(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex-auto min-h-0 flex flex-col items-center justify-start text-neutral pt-20",children:[jsxRuntime.jsx(ui$1.SearchIcon,{width:32,height:32,className:"opacity-40"}),jsxRuntime.jsx("p",{className:"mt-3 text-sm",children:e("predict.search.hint")})]})}var Or="predict-search";function vS({id:e=Or}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Zp,{...t})})}function Zp({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:s}=i18n.useTranslation(),{isMobile:i}=ui$1.useScreen(),o=react.useCallback(a=>{n(a);},[n]),l=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui$1.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui$1.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:s("predict.search.title")}),jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui$1.ModalBody,{className:"p-4",children:jsxRuntime.jsx(bo,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:o,onEscape:l})})]})})}function wS({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=i18n.useTranslation(),{isDesktop:s,isMobile:i}=ui$1.useScreen(),{onOpen:o,onClose:l}=uiScaffold.useAsyncModal(Or),a=hooks.useCallbackRef(e),d=hooks.useCallbackRef(async()=>{let c=await o({params:t});c&&a(c);}),u=hooks.useCallbackRef(()=>{l();});return react.useEffect(()=>{let c=p=>{let m=document.activeElement,f=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!f&&(p.preventDefault(),d()),p.key==="Escape"&&(p.preventDefault(),u());};return window.addEventListener("keydown",c),()=>{window.removeEventListener("keydown",c);}},[d,u]),jsxRuntime.jsx(ui$1.Button,{size:"sm",radius:"full",isIconOnly:!s,onPress:d,variant:i?"flat":"bordered",startContent:s?jsxRuntime.jsx(ui$1.SearchIcon,{className:"text-neutral"}):void 0,endContent:s?jsxRuntime.jsx(ui$1.Kbd,{className:"min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui$1.cn(s&&"pl-3 pr-1.5 text-neutral",r),children:s?n("predict.search.placeholder"):jsxRuntime.jsx(ui$1.SearchIcon,{className:"text-neutral"})})}function JS({client:e,wsClient:t=null,children:r}){let n=react.useMemo(()=>({client:e,wsClient:t}),[e,t]);return jsxRuntime.jsx(Ve.Provider,{value:n,children:r})}var cm=3e4;function oC({walletAddress:e,pollingInterval:t=cm,enabled:r=true,children:n}){let{data:s,isLoading:i,error:o,refetch:l}=Yr({walletAddress:e},{enabled:r&&!!e,refetchInterval:t}),a=react.useMemo(()=>({positions:s?.positions??[],usdcBalance:s?.usdcBalance??0,isLoading:i,error:o??null,refetch:l}),[s?.positions,s?.usdcBalance,i,o,l]);return jsxRuntime.jsx(ke.Provider,{value:a,children:n})}function uC({client:e,children:t}){let r=react.useMemo(()=>({client:e}),[e]);return jsxRuntime.jsx(pt.Provider,{value:r,children:t})}function Co(e,t){let r=new URLSearchParams;t&&r.set("provider",t);for(let[s,i]of Object.entries(e))i!=null&&(typeof i=="object"?r.set(s,JSON.stringify(i)):r.set(s,String(i)));let n=r.toString();return n?`?${n}`:""}function Eo(e){return e}var ot=class{constructor(t,r){this.endpoint=t;this.provider=r;}buildUrl(t,r){let n=Co(r??{},this.provider);return `${this.endpoint}${t}${n}`}async fetch(t,r){let n=this.buildUrl(t,r);return await utils.httpGet(n)}async postRequest(t,r,n){let s=this.buildUrl(t,n);return await utils.httpPost(s,r)}};function Lt(e,t){if(!e)return [];let r=Object.entries(e).map(([n,s])=>({price:parseFloat(n),quantity:s}));return r.sort((n,s)=>t==="desc"?s.price-n.price:n.price-s.price),r}function wo(e){return {yesBids:Lt(e.yes_bids,"desc"),yesAsks:Lt(e.yes_asks,"asc"),noBids:Lt(e.no_bids,"desc"),noAsks:Lt(e.no_asks,"asc"),sequence:e.sequence}}var Bt=class extends ot{constructor(t){super(t,"dflow");}async getEvents(t){return await this.fetch("/v2/event",t??{})}async getEventById(t,r){return await this.fetch(`/v2/event/${t}`,{withNestedMarkets:r})}async getEventCandlesticks(t,r){return await this.fetch(`/v2/event/${t}/candlesticks`,r)}async getEventForecastPercentileHistory(t){let{seriesTicker:r,eventId:n,...s}=t;return await this.fetch(`/v2/event/${r}/${n}/forecast_percentile_history`,s)}async getEventForecastPercentileHistoryByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/event/by-mint/${r}/forecast_percentile_history`,n)}async getMarkets(t){return await this.fetch("/v2/market",t??{})}async getMarketById(t){return await this.fetch(`/v2/market/${t}`)}async getMarketByMint(t){return await this.fetch(`/v2/market/by-mint/${t}`)}async getMarketsBatch(t){return await this.postRequest("/v2/market/batch",t)}async getMarketCandlesticks(t,r){return await this.fetch(`/v2/market/${t}/candlesticks`,r)}async getMarketCandlesticksByMint(t,r){return await this.fetch(`/v2/market/by-mint/${t}/candlesticks`,r)}async getOrderbook(t){let r=await this.fetch(`/v2/orderbook/${t}`);return wo(r)}async getOrderbookByMint(t){let r=await this.fetch(`/v2/orderbook/by-mint/${t}`);return wo(r)}async getTrades(t){return await this.fetch("/v2/trades",t??{})}async getTradesByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/trades/by-mint/${r}`,n)}async getOnchainTradesByWallet(t){let{walletAddress:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-wallet/${r}`,n)}async getOnchainTradesByEvent(t){let{eventTicker:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-event/${r}`,n)}async getOnchainTradesByMarket(t){let{marketTicker:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-market/${r}`,n)}async getLiveData(t){return await this.fetch("/v2/live",{milestoneIds:t.milestoneIds.join(",")})}async getLiveDataByEvent(t){let{eventTicker:r,...n}=t;return await this.fetch(`/v2/live/event/${r}`,n)}async getLiveDataByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/live/by-mint/${r}`,n)}async getSeries(t){return await this.fetch("/v2/series",t??{})}async getSeriesByTicker(t){return await this.fetch(`/v2/series/${t}`)}async getTagsByCategories(){return await this.fetch("/v2/tags/by_categories")}async getFiltersBySports(){return await this.fetch("/v2/sports/filters")}async search(t){return await this.fetch("/v2/search",t)}async getPositionsByWallet(t){let{walletAddress:r}=t;return await this.fetch(`/v2/positions/by-wallet/${r}`)}async getOutcomeMints(t){return await this.fetch("/v2/outcome_mints",t??{})}async filterOutcomeMints(t){return await this.postRequest("/v2/filter_outcome_mints",t)}async getQuote(t){return await this.fetch("/v2/swap/quote",t)}async createSwap(t){return await this.postRequest("/v2/swap",t)}async createSwapInstructions(t){return await this.postRequest("/v2/swap/instructions",t)}async getOrder(t){return await this.fetch("/v2/order",t)}async getOrderStatus(t){try{return await this.fetch("/v2/order/status",t)}catch(r){if(r instanceof Error&&/\b404\b/.test(r.message))return {status:"pending",inAmount:"0",outAmount:"0"};throw r}}async getIntentQuote(t){return await this.fetch("/v2/intent/quote",t)}async submitIntentSwap(t){return await this.postRequest("/v2/intent/swap",t)}async initPredictionMarket(t){return await this.fetch("/v2/prediction-market/init",t)}async getTokens(){return await this.fetch("/v2/tokens")}async getTokensWithDecimals(){return await this.fetch("/v2/tokens/decimals")}async getVenues(){return await this.fetch("/v2/venues")}};function ym(e){let t=new URLSearchParams;for(let[n,s]of Object.entries(e))s!=null&&t.set(n,String(s));let r=t.toString();return r?`?${r}`:""}var it=class{constructor(t){this.endpoint=t;}async listEvents(t){let r=ym(t??{}),n=`${this.endpoint}/api/v1/events${r}`;return await utils.httpGet(n)}async getEvent(t){let r=`${this.endpoint}/api/v1/events/${encodeURIComponent(t)}`;return await utils.httpGet(r)}};function Mo(e){return new it(e)}
|
|
1
|
+
'use strict';var react=require('react'),reactQuery=require('@tanstack/react-query'),i18n=require('@liberfi.io/i18n'),ui$1=require('@liberfi.io/ui'),jsxRuntime=require('react/jsx-runtime'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),utils=require('@liberfi.io/utils'),walletConnector=require('@liberfi.io/wallet-connector'),lr=require('canvas-confetti'),types=require('@liberfi.io/types'),react$1=require('@liberfi.io/react'),recharts=require('recharts'),uiScaffold=require('@liberfi.io/ui-scaffold'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var lr__default=/*#__PURE__*/_interopDefault(lr);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.59");var Fo="0.1.59";var pt=react.createContext(null);function Ur(){let e=react.useContext(pt);if(!e)throw new Error("usePredictV2Context must be used within a PredictV2Provider");return e}function be(){let{client:e}=Ur();return e}function Ko(e){return ["predict-v2","events",e??{}]}async function $o(e,t){return e.listEvents(t)}function Mm(e,t={}){let r=be();return reactQuery.useQuery({queryKey:Ko(e),queryFn:()=>$o(r,e),...t})}function Go(e){return ["predict-v2","event",e]}async function Yo(e,t){return e.getEvent(t)}function Im(e,t={}){let r=be();return reactQuery.useQuery({queryKey:Go(e.slug),queryFn:()=>Yo(r,e.slug),enabled:!!e.slug,...t})}function Zo(e){return ["predict-v2","search",e]}function _r(e,t){let r=be(),n=react.useMemo(()=>({search:e.keyword,limit:e.limit??20,status:e.status??"open",source:e.source,with_markets:e.with_markets??false}),[e.keyword,e.limit,e.status,e.source,e.with_markets]);return reactQuery.useInfiniteQuery({queryKey:Zo(n),queryFn:({pageParam:s})=>r.listEvents({...n,...s!==void 0?{cursor:s}:{}}),initialPageParam:void 0,getNextPageParam:s=>s.has_more&&s.next_cursor?s.next_cursor:void 0,enabled:t?.enabled??!!e.keyword})}var Ve=react.createContext({});var ke=react.createContext(null);function Vr(){let e=react.useContext(Ve);if(!e)throw new Error("usePredictContext must be used within a PredictProvider");return e}function b(){let{client:e}=Vr();return e}function ni(e){return ["predict","events",e??{}]}async function At(e,t){return await e.getEvents(t)}function of(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ni(e),queryFn:async()=>At(r,e),...t})}function oi(e){return ["predict","events","infinite",e??{}]}function Ar(e={},t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:oi(e),queryFn:async({pageParam:n})=>At(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:n=>n.cursor??void 0,...t})}function ai(e){return ["predict","event","byId",e.id,e.withNestedMarkets]}async function li(e,t){return await e.getEventById(t.id,t.withNestedMarkets)}function mt(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ai(e),queryFn:async()=>li(r,e),...t})}function ui(e){return ["predict","markets",e??{}]}async function di(e,t){return await e.getMarkets(t)}function vf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ui(e),queryFn:async()=>di(r,e),...t})}function mi(e){return ["predict","market","byId",e.id]}async function fi(e,t){return await e.getMarketById(t.id)}function kf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:mi(e),queryFn:async()=>fi(r,e),...t})}function gi(e){return ["predict","market","byMint",e]}async function vi(e,t){return await e.getMarketByMint(t)}function Ef(e,t={}){let r=b();return reactQuery.useQuery({queryKey:gi(e),queryFn:async()=>vi(r,e),...t})}function hi(e){return ["predict","markets","batch",e]}async function bi(e,t){return await e.getMarketsBatch(t)}function Nf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:hi(e),queryFn:async()=>bi(r,e),enabled:!!(e.tickers?.length||e.mints?.length),...t})}function ki(e){return ["predict","orderBook",e]}async function Pi(e,t){return await e.getOrderbook(t)}function Ae(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ki(e),queryFn:async()=>Pi(r,e),...t})}function Si(e){return ["predict","orderBook","byMint",e]}async function Ci(e,t){return await e.getOrderbookByMint(t)}function Lf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Si(e),queryFn:async()=>Ci(r,e),...t})}function Ei(e){return ["predict","trades",e??{}]}async function wi(e,t){return await e.getTrades(t)}function Wr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ei(e),queryFn:async()=>wi(r,e),...t})}function Ti(e){return ["predict","trades","byMint",e]}async function Mi(e,t){return await e.getTradesByMint(t)}function _f(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ti(e),queryFn:async()=>Mi(r,e),...t})}function Ni(e){return ["predict","onchainTrades","byWallet",e]}async function Ft(e,t){return await e.getOnchainTradesByWallet(t)}function qr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ni(e),queryFn:async()=>Ft(r,e),...t})}function Ri(e){return ["predict","onchainTrades","byEvent",e]}async function Wt(e,t){return await e.getOnchainTradesByEvent(t)}function Ff(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ri(e),queryFn:async()=>Wt(r,e),...t})}function Oi(e){return ["predict","onchainTrades","byMarket",e]}async function qt(e,t){return await e.getOnchainTradesByMarket(t)}function Wf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Oi(e),queryFn:async()=>qt(r,e),...t})}function Kt(e){return e.cursor??void 0}function Ii(e){return ["predict","onchainTrades","byWallet","infinite",e]}function zf(e,t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:Ii(e),queryFn:async({pageParam:n})=>Ft(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kt,...t})}function Li(e){return ["predict","onchainTrades","byEvent","infinite",e]}function Gf(e,t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:Li(e),queryFn:async({pageParam:n})=>Wt(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kt,...t})}function Bi(e){return ["predict","onchainTrades","byMarket","infinite",e]}function Yf(e,t={}){let r=b();return reactQuery.useInfiniteQuery({queryKey:Bi(e),queryFn:async({pageParam:n})=>qt(r,{...e,...n!==void 0?{cursor:n}:{}}),initialPageParam:void 0,getNextPageParam:Kt,...t})}function Qi(e){return ["predict","candlesticks","event",e]}async function Ui(e,t){let{ticker:r,...n}=t;return await e.getEventCandlesticks(r,n)}function Jf(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Qi(e),queryFn:async()=>Ui(r,e),...t})}function zt(e){return ["predict","candlesticks","market",e]}async function Gt(e,t){let{ticker:r,...n}=t;return await e.getMarketCandlesticks(r,n)}function Yt(e,t={}){let r=b();return reactQuery.useQuery({queryKey:zt(e),queryFn:async()=>Gt(r,e),...t})}function _i(e){return ["predict","candlesticks","market","byMint",e]}async function Vi(e,t){let{mintAddress:r,...n}=t;return await e.getMarketCandlesticksByMint(r,n)}function ey(e,t={}){let r=b();return reactQuery.useQuery({queryKey:_i(e),queryFn:async()=>Vi(r,e),...t})}var ty=Yt;function Ai(e){return ["predict","forecast","percentileHistory",e]}async function Di(e,t){return await e.getEventForecastPercentileHistory(t)}function oy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ai(e),queryFn:async()=>Di(r,e),...t})}function Fi(e){return ["predict","forecast","percentileHistory","byMint",e]}async function Wi(e,t){return await e.getEventForecastPercentileHistoryByMint(t)}function iy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Fi(e),queryFn:async()=>Wi(r,e),...t})}function qi(e){return ["predict","liveData",e]}async function Hi(e,t){return await e.getLiveData(t)}function uy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:qi(e),queryFn:async()=>Hi(r,e),enabled:e.milestoneIds.length>0,...t})}function Ki(e){return ["predict","liveData","byEvent",e]}async function $i(e,t){return await e.getLiveDataByEvent(t)}function dy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ki(e),queryFn:async()=>$i(r,e),enabled:!!e.eventTicker,...t})}function zi(e){return ["predict","liveData","byMint",e]}async function Gi(e,t){return await e.getLiveDataByMint(t)}function py(e,t={}){let r=b();return reactQuery.useQuery({queryKey:zi(e),queryFn:async()=>Gi(r,e),enabled:!!e.mintAddress,...t})}function Yi(e){return ["predict","series",e??{}]}async function Xi(e,t){return await e.getSeries(t)}function $r(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Yi(e),queryFn:async()=>Xi(r,e),...t})}function ji(e){return ["predict","series","byTicker",e]}async function Zi(e,t){return await e.getSeriesByTicker(t)}function zr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:ji(e),queryFn:async()=>Zi(r,e),...t})}function Ji(){return ["predict","tags","byCategories"]}async function ea(e){return await e.getTagsByCategories()}function jt(e={}){let t=b();return reactQuery.useQuery({queryKey:Ji(),queryFn:async()=>ea(t),...e})}function ta(){return ["predict","filters","bySports"]}async function ra(e){return await e.getFiltersBySports()}function hy(e={}){let t=b();return reactQuery.useQuery({queryKey:ta(),queryFn:async()=>ra(t),...e})}var by=jt;function sa(e){return ["predict","search",e]}async function oa(e,t){return await e.search(t)}function Cy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:sa(e),queryFn:async()=>oa(r,e),...t})}function aa(e){return ["predict","positions","byWallet",e]}async function la(e,t){return await e.getPositionsByWallet(t)}function Yr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:aa(e),queryFn:async()=>la(r,e),...t})}function Oy(){let e=react.useContext(ke);if(!e)throw new Error("useUserPredictContext must be used within a UserPredictProvider");return e}function Xr(e){let t=react.useContext(ke);return react.useMemo(()=>t?{positions:t.positions.filter(n=>n.market?.ticker===e.ticker),isLoading:t.isLoading,isAvailable:true}:{positions:[],isLoading:false,isAvailable:false},[t,e.ticker])}function fa(e){return ["predict","outcomeMints",e??{}]}async function ya(e,t){return await e.getOutcomeMints(t)}function Vy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:fa(e),queryFn:async()=>ya(r,e),...t})}async function ga(e,t){return await e.filterOutcomeMints(t)}function Ay(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>ga(t,r),...e})}function xa(e){return ["predict","quote",e]}async function ha(e,t){return await e.getQuote(t)}function qy(e,t={}){let r=b();return reactQuery.useQuery({queryKey:xa(e),queryFn:async()=>ha(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}async function ba(e,t){return await e.createSwap(t)}function zy(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>ba(t,r),...e})}async function ka(e,t){return await e.createSwapInstructions(t)}function Gy(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>ka(t,r),...e})}function Pa(e){return ["predict","order",e]}async function Sa(e,t){return await e.getOrder(t)}function Jr(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Pa(e),queryFn:async()=>Sa(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}function Ca(e){return ["predict","order","status",e.signature]}async function Ea(e,t){return await e.getOrderStatus(t)}function en(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ca(e),queryFn:async()=>Ea(r,e),enabled:!!e.signature,refetchInterval:t.refetchInterval??3e3,retry:false,...t})}function Ma(e){return ["predict","intent","quote",e]}async function Na(e,t){return await e.getIntentQuote(t)}function tg(e,t={}){let r=b();return reactQuery.useQuery({queryKey:Ma(e),queryFn:async()=>Na(r,e),enabled:!!(e.inputMint&&e.outputMint&&e.amount>0),staleTime:1e4,gcTime:3e4,...t})}async function Ra(e,t){return await e.submitIntentSwap(t)}function rg(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>Ra(t,r),...e})}async function Ia(e,t){return await e.initPredictionMarket(t)}function ig(e={}){let t=b();return reactQuery.useMutation({mutationFn:async r=>Ia(t,r),...e})}function La(){return ["predict","tokens"]}async function Ba(e){return await e.getTokens()}function ug(e={}){let t=b();return reactQuery.useQuery({queryKey:La(),queryFn:async()=>Ba(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}function Qa(){return ["predict","tokens","decimals"]}async function Ua(e){return await e.getTokensWithDecimals()}function dg(e={}){let t=b();return reactQuery.useQuery({queryKey:Qa(),queryFn:async()=>Ua(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}function Va(){return ["predict","venues"]}async function Aa(e){return await e.getVenues()}function yg(e={}){let t=b();return reactQuery.useQuery({queryKey:Va(),queryFn:async()=>Aa(t),staleTime:300*1e3,gcTime:1800*1e3,...e})}var Ge=class{ws=null;wsUrl;autoReconnect;reconnectIntervalBase;reconnectMaxInterval;pingInterval;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;pingIntervalId=null;shouldReconnect=true;listeners={connect:[],disconnect:[],reconnecting:[],error:[],price:[],trade:[],orderbook:[],status:[],subscribed:[],unsubscribed:[]};subscriptions={prices:{all:false,tickers:new Set},trades:{all:false,tickers:new Set},orderbook:{all:false,tickers:new Set}};constructor(t){this.wsUrl=t.wsUrl,this.autoReconnect=t.autoReconnect??true,this.reconnectIntervalBase=t.reconnectIntervalBase??1e3,this.reconnectMaxInterval=t.reconnectMaxInterval??3e4,this.pingInterval=t.pingInterval??3e4,t.autoConnect!==false&&this.connect();}connect(){if(!(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))){this.shouldReconnect=true,this.setStatus("connecting");try{this.ws=new WebSocket(this.wsUrl),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus("connected"),this.emit("connect",void 0),this.restoreSubscriptions(),this.startPingInterval();},this.ws.onmessage=t=>{this.handleMessage(t.data);},this.ws.onerror=t=>{let r=new Error("WebSocket error");this.emit("error",r);},this.ws.onclose=t=>{this.stopPingInterval(),this.setStatus("disconnected"),this.emit("disconnect",{code:t.code,reason:t.reason}),this.shouldReconnect&&this.autoReconnect&&this.scheduleReconnect();};}catch(t){this.emit("error",t instanceof Error?t:new Error(String(t))),this.shouldReconnect&&this.autoReconnect&&this.scheduleReconnect();}}}disconnect(){this.shouldReconnect=false,this.stopPingInterval(),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus("disconnected");}isConnected(){return this.ws!==null&&this.ws.readyState===WebSocket.OPEN}getStatus(){return this.status}subscribePrices(t,r){this.subscribeChannel("prices",t);let n=this.on("price",r);return ()=>{n(),this.unsubscribeChannel("prices",t);}}subscribeTrades(t,r){this.subscribeChannel("trades",t);let n=this.on("trade",r);return ()=>{n(),this.unsubscribeChannel("trades",t);}}subscribeOrderbook(t,r){this.subscribeChannel("orderbook",t);let n=this.on("orderbook",r);return ()=>{n(),this.unsubscribeChannel("orderbook",t);}}onStatusChange(t){return this.on("status",t)}on(t,r){return this.listeners[t].push(r),()=>{this.off(t,r);}}off(t,r){let n=this.listeners[t],s=n.indexOf(r);s!==-1&&n.splice(s,1);}removeAllListeners(t){if(t)this.listeners[t].length=0;else for(let r of Object.keys(this.listeners))this.listeners[r].length=0;}subscribeChannel(t,r){let n=this.subscriptions[t];if(r.all)n.all=true,n.tickers.clear();else if(r.tickers&&r.tickers.length>0){n.all=false;for(let s of r.tickers)n.tickers.add(s);}this.sendSubscription("subscribe",t,r);}unsubscribeChannel(t,r){let n=this.subscriptions[t];if(r.all)n.all=false,n.tickers.clear();else if(r.tickers&&r.tickers.length>0)for(let s of r.tickers)n.tickers.delete(s);this.sendSubscription("unsubscribe",t,r);}setStatus(t){this.status!==t&&(this.status=t,this.emit("status",t));}emit(t,r){let n=this.listeners[t];for(let s of n)try{s(r);}catch{}}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return false;try{return this.ws.send(JSON.stringify(t)),!0}catch{return false}}sendSubscription(t,r,n){this.send({type:t,channel:r,all:n.all,tickers:n.tickers});}handleMessage(t){try{let r=JSON.parse(t);switch(r.type){case "ticker":this.emit("price",r);break;case "trade":this.emit("trade",r);break;case "orderbook":this.emit("orderbook",r);break;case "status":break;case "subscribed":this.emit("subscribed",{channel:r.channel,all:r.all,tickers:r.tickers});break;case "unsubscribed":this.emit("unsubscribed",{channel:r.channel,all:r.all,tickers:r.tickers});break;case "pong":break;case "error":this.emit("error",new Error(r.message));break;default:if("channel"in r){let n=r;switch(n.channel){case "prices":this.emit("price",n);break;case "trades":this.emit("trade",n);break;case "orderbook":this.emit("orderbook",n);break}}}}catch{}}scheduleReconnect(){if(this.reconnectTimeout)return;let t=Math.min(this.reconnectIntervalBase*Math.pow(2,this.reconnectAttempts),this.reconnectMaxInterval);this.setStatus("reconnecting"),this.emit("reconnecting",{attempt:this.reconnectAttempts+1,delay:t}),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.reconnectAttempts++,this.connect();},t);}restoreSubscriptions(){for(let t of ["prices","trades","orderbook"]){let r=this.subscriptions[t];r.all?this.sendSubscription("subscribe",t,{all:true}):r.tickers.size>0&&this.sendSubscription("subscribe",t,{tickers:Array.from(r.tickers)});}}startPingInterval(){this.stopPingInterval(),this.pingIntervalId=setInterval(()=>{this.send({type:"ping"});},this.pingInterval);}stopPingInterval(){this.pingIntervalId&&(clearInterval(this.pingIntervalId),this.pingIntervalId=null);}};function ft(e){return new Ge(e)}function kg({wsEndpoint:e,autoConnect:t=true,autoReconnect:r=true,enabled:n=true}){let[s,i]=react.useState("disconnected"),[o,l]=react.useState(null),a=react.useRef(null);react.useEffect(()=>{if(!n){a.current&&(a.current.disconnect(),a.current=null),i("disconnected");return}let p=ft({wsUrl:e,autoConnect:t,autoReconnect:r});a.current=p;let m=p.on("status",x=>{i(x);}),f=p.on("error",x=>{l(x);}),y=p.on("connect",()=>{l(null);});return ()=>{m(),f(),y(),p.disconnect(),a.current=null;}},[e,t,r,n]);let d=react.useCallback(()=>{a.current?.connect();},[]),u=react.useCallback(()=>{a.current?.disconnect();},[]);return {client:a.current,status:s,isConnected:s==="connected",connect:d,disconnect:u,error:o}}function Eg(){let e=react.useContext(Ve);if(!e)throw new Error("useWsClient must be used within a PredictProvider");let{wsClient:t}=e,[r,n]=react.useState(t?.getStatus()??"disconnected");return react.useEffect(()=>{if(!t){n("disconnected");return}return n(t.getStatus()),t.onStatusChange(n)},[t]),{wsClient:t,wsStatus:r,isWsConnected:r==="connected"}}function Mg({client:e,all:t=false,tickers:r=[],enabled:n=true,onUpdate:s}){let[i,o]=react.useState(new Map),[l,a]=react.useState(false),d=react.useRef(s);return react.useEffect(()=>{d.current=s;},[s]),react.useEffect(()=>{if(!e||!n){a(false);return}if(!t&&r.length===0)return;let u=t?{all:true}:{tickers:r},c=e.subscribePrices(u,p=>{o(m=>{let f=new Map(m);return f.set(p.market_ticker,{yesBid:p.yes_bid,yesAsk:p.yes_ask,noBid:p.no_bid,noAsk:p.no_ask,updatedAt:Date.now()}),f}),d.current?.(p);});return a(true),()=>{c(),a(false);}},[e,t,r.join(","),n]),{prices:i,isSubscribed:l}}function Og({client:e,all:t=false,tickers:r=[],enabled:n=true,maxHistory:s=100,onUpdate:i}){let[o,l]=react.useState([]),[a,d]=react.useState(false),u=react.useRef(i);react.useEffect(()=>{u.current=i;},[i]),react.useEffect(()=>{if(!e||!n){d(false);return}if(!t&&r.length===0)return;let p=t?{all:true}:{tickers:r},m=e.subscribeTrades(p,f=>{let y={tradeId:f.trade_id,marketTicker:f.market_ticker,price:f.price,count:f.count,yesPrice:f.yes_price,noPrice:f.no_price,takerSide:f.taker_side,createdTime:f.created_time};l(x=>{let g=[y,...x];return g.length>s?g.slice(0,s):g}),u.current?.(f);});return d(true),()=>{m(),d(false);}},[e,t,r.join(","),n,s]);let c=react.useCallback(()=>{l([]);},[]);return {trades:o,isSubscribed:a,clearHistory:c}}function Bg({client:e,all:t=false,tickers:r=[],enabled:n=true,onUpdate:s}){let[i,o]=react.useState(new Map),[l,a]=react.useState(false),d=react.useRef(s);react.useEffect(()=>{d.current=s;},[s]),react.useEffect(()=>{if(!e||!n){a(false);return}if(!t&&r.length===0)return;let c=t?{all:true}:{tickers:r},p=e.subscribeOrderbook(c,m=>{o(f=>{let y=new Map(f);return y.set(m.market_ticker,{yesBids:m.yes_bids,yesAsks:m.yes_asks,noBids:m.no_bids,noAsks:m.no_asks,updatedAt:Date.now()}),y}),d.current?.(m);});return a(true),()=>{p(),a(false);}},[e,t,r.join(","),n]);let u=react.useCallback(c=>i.get(c),[i]);return {orderbooks:i,isSubscribed:l,getOrderbook:u}}var dn=["Politics","Sports","Culture","Crypto","Climate","Economics","Mentions","Companies","Financials","Tech & Science"];function pn(){let{data:e,isLoading:t,isError:r,error:n}=jt();return {data:react.useMemo(()=>{if(!e?.tagsByCategories)return [];let i=o=>{let l=dn.indexOf(o);return l===-1?dn.length:l};return Object.entries(e.tagsByCategories).map(([o,l])=>({category:o,tags:l})).sort((o,l)=>i(o.category)-i(l.category))},[e]),isLoading:t,isError:r,error:n??null}}function vt({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:s,onTagSelect:i,trailing:o,className:l}){let{t:a}=i18n.useTranslation(),d=react.useCallback(()=>{s(null);},[s]);return jsxRuntime.jsxs("div",{className:ui$1.cn("flex w-full flex-col gap-2",l),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsx(ui$1.HorizontalScrollContainer,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-0.5 py-1",children:[jsxRuntime.jsx(yt,{label:a("predict.categories.trending"),isSelected:t===null,onPress:d}),e.map(u=>jsxRuntime.jsx(yt,{label:u.category,isSelected:t===u.category,onPress:()=>s(u.category)},u.category))]})})}),o&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:o})]}),t&&n.length>0&&jsxRuntime.jsx(ui$1.HorizontalScrollContainer,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-0.5 py-1",children:[jsxRuntime.jsx(yt,{label:a("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null),variant:"secondary"}),n.map(u=>jsxRuntime.jsx(yt,{label:u,isSelected:r===u,onPress:()=>i(u),variant:"secondary"},u))]})})]})}function yt({label:e,isSelected:t,onPress:r,variant:n="primary"}){return jsxRuntime.jsx("button",{type:"button",onClick:r,className:ui$1.cn("shrink-0 rounded-full px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer","border whitespace-nowrap",n==="primary"?t?"bg-foreground text-background border-foreground":"bg-content1 text-foreground/70 border-default-200 hover:bg-default-100 hover:text-foreground":t?"bg-primary/15 text-primary border-primary/40":"bg-content1 text-foreground/50 border-default-100 hover:bg-default-50 hover:text-foreground/70"),children:e})}function yn({count:e=6}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-0.5 py-1",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 shrink-0 rounded-full",style:{width:`${60+Math.random()*40}px`}},r))})}function hn({onSelect:e,className:t}){let{data:r,isLoading:n}=pn(),[s,i]=react.useState(null),[o,l]=react.useState(null),a=react.useCallback(c=>{if(i(c),l(null),!c)e?.({category:null,tags:null});else {let p=r.find(m=>m.category===c);e?.({category:c,tags:p?.tags??null});}},[r,e]),d=react.useCallback(c=>{if(l(c),c)e?.({category:s,tags:[c]});else {let p=r.find(m=>m.category===s);e?.({category:s,tags:p?.tags??null});}},[r,s,e]);if(n)return jsxRuntime.jsx(yn,{});let u=r.find(c=>c.category===s)?.tags??[];return jsxRuntime.jsx(vt,{categories:r,selectedCategory:s,selectedTag:o,activeTags:u,onCategorySelect:a,onTagSelect:d,className:t})}var se=48,Pe=4,xt={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},w={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Se=w.ALL,ht={[w.ONE_DAY]:xt.ONE_MINUTE,[w.ONE_WEEK]:xt.ONE_HOUR,[w.ONE_MONTH]:xt.ONE_HOUR,[w.ALL]:xt.ONE_DAY},bt={[w.ONE_DAY]:300,[w.ONE_WEEK]:3600,[w.ONE_MONTH]:10800,[w.ALL]:1440*60},kt={[w.ONE_DAY]:1440*60,[w.ONE_WEEK]:10080*60,[w.ONE_MONTH]:720*60*60,[w.ALL]:null},Zt=1,Iv=1,Lv=1,Bv=99,De={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Qv=De.ONE_WEEK,Uv={[De.ONE_HOUR]:60,[De.SIX_HOURS]:60,[De.ONE_DAY]:300,[De.ONE_WEEK]:1800,[De.MAX]:1800};function bn(e={}){let{category:t,tags:r,...n}=e,s=!!t||!!r&&r.length>0,{data:i,isFetching:o,isError:l,error:a}=$r({...t?{category:t}:{},...r&&r.length>0?{tags:r.join(",")}:{},isInitialized:true,status:"active"},{enabled:s}),d=react.useMemo(()=>{if(!s||!i?.series)return;let R=i.series.map(S=>S.ticker).slice(0,25);return R.length>0?R.join(","):void 0},[s,i]),u=react.useMemo(()=>({status:"active",withNestedMarkets:true,sort:"volume24h",order:"desc",limit:48,...n,...d!==void 0?{seriesTickers:d}:{}}),[n,d]),{data:c,isLoading:p,isFetching:m,isFetchingNextPage:f,isError:y,error:x,hasNextPage:g,fetchNextPage:h,refetch:k}=Ar(u),v=react.useMemo(()=>c?.pages.flatMap(R=>R.events)??[],[c]),P=s&&!i&&!l;return {data:v,isLoading:P||p,isFetching:o||P||m&&!f,isFetchingMore:f,isError:l||y,error:a??x,hasMore:g,fetchMore:h,refetch:k}}function el({className:e}){return jsxRuntime.jsxs("div",{className:`flex h-full w-full flex-col justify-between gap-y-1.5 rounded-xl border border-border bg-content1 p-3 @5xl:gap-y-3 @5xl:p-4 ${e??""}`,children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-1 flex-col gap-y-1.5 @5xl:gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-8 flex-shrink-0 rounded-lg @5xl:h-12 @5xl:w-12"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 flex-1 rounded-md @5xl:h-12"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-12 flex-shrink-0 rounded-lg @5xl:h-10 @5xl:w-14"})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-0.5 @5xl:gap-y-1",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 w-full items-center justify-between gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-2/3 rounded-md"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-8 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 rounded-lg"})]})]}),jsxRuntime.jsxs("div",{className:"flex min-h-8 w-full items-center justify-between gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-1/2 rounded-md"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-8 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 rounded-lg"})]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-16 rounded-md @5xl:h-4"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-20 rounded-md @5xl:h-4"})]})]})}function Pt({count:e=8}){return jsxRuntime.jsx("div",{className:"@container w-full h-full",children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-4 @[640px]:grid-cols-2 @[1024px]:grid-cols-3 @[1280px]:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(el,{className:"min-h-44 @5xl:min-h-56"},r))})})}function kn({value:e,showLabel:t=true}){let r=e/100;return jsxRuntime.jsx("div",{className:"flex-shrink-0 flex flex-col items-center",children:jsxRuntime.jsxs("div",{className:"relative w-16 h-12 lg:w-20 lg:h-14",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 70",children:[jsxRuntime.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",className:"stroke-default-200",strokeWidth:"6",strokeLinecap:"round"}),jsxRuntime.jsx("path",{d:"M 10 55 A 40 40 0 0 1 90 55",fill:"none",className:"stroke-primary",strokeWidth:"6",strokeLinecap:"round",strokeDasharray:`${r*125.6} 125.6`,style:{transition:"stroke-dasharray 0.5s ease-in-out"}})]}),t&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center pt-3 lg:pt-4",children:jsxRuntime.jsxs("span",{className:"text-sm font-bold text-foreground lg:text-base leading-none",children:[e.toFixed(0),"%"]})})]})})}function Cn({event:e,onSelect:t,onSelectOutcome:r}){let{t:n}=i18n.useTranslation(),[s,i]=react.useState(null),o=e.markets||[],l=o.length>2?[...o].sort((S,L)=>Number(L.yesAsk??0)-Number(S.yesAsk??0)):o,a=l.filter(S=>S.status==="active"),d=l.length===1,u=d?l[0]:s,c=react.useMemo(()=>utils.formatAmountUSDCompact((e.volume??0)/100),[e.volume]),p=S=>S.yesAsk?parseFloat(S.yesAsk)*100:null,m=S=>S.noAsk?parseFloat(S.noAsk)*100:null,f=S=>{let L=p(S),V=m(S);return L!=null?V==null&&L<=1?"< 1%":x(L):V!=null?V<=1?"> 99%":x(100-V):"0%"},y=S=>{let L=p(S),V=m(S);return V!=null?L==null&&V<=1?"< 1%":x(V):L!=null?L<=1?"> 99%":x(100-L):"0%"},x=S=>S!=null?`${S.toFixed(0)}%`:"--",g=react.useMemo(()=>{let S=l.some(V=>V.status==="active");return l.every(V=>V.status==="closed"||V.status==="determined")?{label:n("predict.event.status.closed"),color:"bg-danger-100/50 text-danger"}:S?{label:n("predict.event.status.live"),color:"bg-primary-100/50 text-primary"}:{label:n("predict.event.status.pending"),color:"bg-warning-100/50 text-warning"}},[l,n]),h=S=>{i(S);},k=()=>{i(null);},v=()=>{u&&r&&r(e,u,"yes");},P=()=>{u&&r&&r(e,u,"no");},C=()=>{t&&t(e);},N=a.slice(0,2),R=a.length>2;return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col justify-between gap-y-1.5 rounded-xl border border-border bg-content1 p-3 transition-all duration-300 cursor-pointer hover:border-primary hover:ring-2 hover:ring-primary/20 focus-within:border-primary focus-within:bg-content2 focus-within:ring-2 focus-within:ring-primary/20 @5xl:gap-y-3 @5xl:p-4",onClick:C,children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-1 flex-col gap-y-1.5 @5xl:gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.imageUrl||void 0,name:e.title||"Event",radius:"md",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover:scale-110 @5xl:h-12 @5xl:w-12"}),jsxRuntime.jsx(ui$1.StyledTooltip,{content:e.title,placement:"bottom",children:jsxRuntime.jsx("p",{className:"flex-1 min-w-0 h-10 @5xl:h-12 text-sm font-semibold @5xl:text-base line-clamp-2",children:e.title})}),d?jsxRuntime.jsx(kn,{value:p(l[0])??50}):g.label!==n("predict.event.status.live")&&jsxRuntime.jsx("div",{className:`flex-shrink-0 flex items-center gap-x-2 rounded-lg px-2 py-1 text-sm @5xl:px-4 @5xl:py-2 ${g.color}`,children:jsxRuntime.jsx("span",{children:g.label})})]}),u&&!d&&jsxRuntime.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:S=>{S.stopPropagation(),k();},children:[jsxRuntime.jsx("span",{className:"text-left text-xs text-foreground @5xl:text-sm line-clamp-1",children:u.yesSubTitle}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground @5xl:text-lg",children:f(u)}),jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"w-3 h-3 text-default-500 @5xl:w-4 @5xl:h-4"})]})]}),!u&&!d&&N.length>0&&jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-0.5 text-xs @5xl:gap-y-1 @5xl:text-sm",children:[N.map(S=>jsxRuntime.jsxs("button",{type:"button",className:"flex min-h-8 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:L=>{L.stopPropagation(),h(S);},children:[jsxRuntime.jsx("span",{className:"text-left text-xs text-foreground @5xl:text-sm line-clamp-1",children:S.yesSubTitle}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-foreground @5xl:text-base",children:f(S)}),jsxRuntime.jsxs("div",{className:"flex h-full items-center gap-x-3 rounded-lg p-1 @5xl:p-1.5 bg-gradient-to-r from-primary-50/20 via-primary-50/20 to-secondary-50/20",children:[jsxRuntime.jsx("span",{className:"text-primary",children:n("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-default-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:n("predict.market.no")})]})]})]},S.ticker)),R&&jsxRuntime.jsx("span",{className:"text-xxs text-default-500 @5xl:text-xs",children:n("predict.event.moreMarkets",{count:a.length-2})})]}),u&&jsxRuntime.jsxs("div",{className:`flex items-center gap-x-2 text-sm @5xl:text-base ${d?"mt-3":""}`,children:[jsxRuntime.jsxs(ui$1.Button,{color:"primary",fullWidth:true,className:"group/yes bg-primary-100 text-primary @3xl:!h-12 @3xl:!text-base",size:"sm",onPress:v,children:[jsxRuntime.jsx("span",{className:"group-hover/yes:hidden",children:n("predict.market.yes")}),jsxRuntime.jsx("span",{className:"hidden group-hover/yes:inline",children:f(u)})]}),jsxRuntime.jsxs(ui$1.Button,{color:"secondary",fullWidth:true,className:"group/no bg-secondary-100 text-secondary @3xl:!h-12 @3xl:!text-base",size:"sm",onPress:P,children:[jsxRuntime.jsx("span",{className:"group-hover/no:hidden",children:n("predict.market.no")}),jsxRuntime.jsx("span",{className:"hidden group-hover/no:inline",children:y(u)})]})]})]}),!u||d?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-xxs text-default-600 hover:text-foreground @5xl:text-xs",onClick:S=>{S.stopPropagation(),C();},children:[jsxRuntime.jsx("span",{children:n("predict.event.showMore")}),jsxRuntime.jsx(ui$1.ChevronRightIcon,{className:"h-3 w-3 @5xl:h-4 @5xl:w-4"})]}),jsxRuntime.jsxs("span",{className:"text-xxs text-default-600 @5xl:text-xs",children:[c," ",n("predict.event.volume")]})]}):jsxRuntime.jsxs("button",{type:"button",className:"flex items-center cursor-pointer gap-x-1 text-xxs text-default-600 hover:text-foreground @5xl:text-xs",onClick:S=>{S.stopPropagation(),k();},children:[jsxRuntime.jsx(ui$1.ChevronLeftIcon,{className:"h-3 w-3 @5xl:h-4 @5xl:w-4"}),jsxRuntime.jsx("span",{children:n("predict.event.back")})]})]})}var fl=640,yl=768,wn=1024,gl=1280,vl=16,xl=192,hl=228,bl=244;function kl(e){return e>=gl?4:e>=wn?3:e>=fl?2:1}function Pl(e){return e>=wn?bl:e>=yl?hl:xl}function Tn({events:e,hasMore:t=false,onFetchMore:r,onSelect:n,onSelectOutcome:s}){let i=react.useRef(null),{width:o=0,height:l=0}=hooks.useResizeObserver({ref:i}),a=kl(o),d=Pl(o),u=Math.ceil(e.length/a)||0,c=t?u+1:u,p=react.useCallback(y=>y<u,[u]),m=react.useCallback(async()=>{r?.();},[r]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:m,rowCount:c,threshold:3});return jsxRuntime.jsx("div",{ref:i,className:"@container w-full h-full",children:l>0&&jsxRuntime.jsx(reactWindow.List,{style:{height:l},onRowsRendered:f,rowComponent:Sl,rowCount:c,rowHeight:d,rowProps:{events:e,columnCount:a,dataRowCount:u,gap:vl,onSelect:n,onSelectOutcome:s}})})}function Sl({index:e,style:t,events:r,columnCount:n,dataRowCount:s,gap:i,onSelect:o,onSelectOutcome:l}){if(e>=s)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let a=e*n,d=r.slice(a,a+n),u=n-d.length,c={display:"flex",gap:i,height:`calc(100% - ${i}px)`};return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{style:c,children:[d.map(p=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0},children:jsxRuntime.jsx(Cn,{event:p,onSelect:o,onSelectOutcome:l})},p.ticker)),u>0&&Array.from({length:u}).map((p,m)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${m}`))]})})}function Nn({onSelect:e,onSelectOutcome:t,...r}){let{data:n,hasMore:s,fetchMore:i,isFetching:o}=bn({limit:48,...r});return o?jsxRuntime.jsx(Pt,{count:48}):jsxRuntime.jsx(Tn,{events:n,hasMore:s,onFetchMore:i,onSelect:e,onSelectOutcome:t})}function vx({onSelect:e,onSelectOutcome:t}){let[r,n]=react.useState({category:null,tags:null}),s=react.useCallback(i=>{n(i);},[]);return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col gap-y-3",children:[jsxRuntime.jsx(hn,{onSelect:s}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Nn,{category:r.category,tags:r.tags,onSelect:e,onSelectOutcome:t})})]})}var Ml={"Climate and 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 and Technology":["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},Rn=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],rr=(()=>{let e=t=>{let r=Rn.indexOf(t);return r===-1?Rn.length:r};return Object.entries(Ml).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 Nl(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Ln({onSelect:e,trailing:t,className:r}){let[n,s]=react.useState(null),[i,o]=react.useState(null),l=react.useCallback(c=>{s(c),o(null),e?.({categorySlug:c,tagSlug:null});},[e]),a=react.useCallback(c=>{o(c),e?.({categorySlug:n,tagSlug:c});},[n,e]),d=Nl(rr),u=rr.find(c=>c.slug===n)?.tags.map(c=>c.label)??[];return jsxRuntime.jsx(vt,{categories:d,selectedCategory:n,selectedTag:i,activeTags:u,onCategorySelect:l,onTagSelect:a,trailing:t,className:r})}var nr={sortPreset:"trending",source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function sr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Bn({isOpen:e,onClose:t,value:r,onChange:n}){let{t:s}=i18n.useTranslation(),[i,o]=react.useState(r),l=react.useCallback(g=>{g?o(r):t();},[r,t]),a=react.useCallback(()=>{o(nr);},[]),d=react.useCallback(()=>{n(i),t();},[i,n,t]),u=react.useCallback((g,h)=>{o(k=>({...k,[g]:h}));},[]),c=react.useMemo(()=>sr(i),[i]),p=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"polymarket",label:s("predict.platform.polymarket")},{value:"dflow",label:s("predict.platform.dflow")}],[s]),m=react.useMemo(()=>[{value:"trending",label:s("predict.sort.trending")},{value:"volume",label:s("predict.sort.volume")},{value:"newest",label:s("predict.sort.newest")},{value:"ending_soon",label:s("predict.sort.endingSoon")},{value:"liquidity",label:s("predict.sort.liquidity")}],[s]),f=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1d",label:s("predict.filter.lessThanDay")},{value:"7d",label:s("predict.filter.lessThanWeek")},{value:"30d",label:s("predict.filter.lessThanMonth")}],[s]),y=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[s]),x=react.useMemo(()=>[{value:void 0,label:s("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[s]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:e,onOpenChange:l,size:"md",classNames:{base:"bg-content1 border border-default-200",header:"border-b border-default-100",body:"py-4",footer:"border-t border-default-100"},children:jsxRuntime.jsxs(ui$1.ModalContent,{children:[jsxRuntime.jsxs(ui$1.ModalHeader,{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui$1.FilterIcon,{className:"h-5 w-5 text-default-500"}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:s("predict.filter.title")}),jsxRuntime.jsx("span",{className:"text-xxs text-default-400 font-normal",children:s("predict.filter.subtitle")})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"rounded-full p-1 hover:bg-default-100 transition-colors cursor-pointer",children:jsxRuntime.jsx(ui$1.XCloseIcon,{className:"h-4 w-4 text-default-400"})})]}),jsxRuntime.jsxs(ui$1.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(Ye,{label:s("predict.filter.platform"),children:jsxRuntime.jsx(Xe,{options:p,selected:i.source,onSelect:g=>u("source",g)})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.sortBy"),children:jsxRuntime.jsx(Xe,{options:m,selected:i.sortPreset,onSelect:g=>u("sortPreset",g??"trending"),allowDeselect:false})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.timeRemaining"),children:jsxRuntime.jsx(Xe,{options:f,selected:i.timeRemaining,onSelect:g=>u("timeRemaining",g)})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.minVolume"),children:jsxRuntime.jsx(Xe,{options:y,selected:i.minVolume,onSelect:g=>u("minVolume",g)})}),jsxRuntime.jsx(Ye,{label:s("predict.filter.minLiquidity"),children:jsxRuntime.jsx(Xe,{options:x,selected:i.minLiquidity,onSelect:g=>u("minLiquidity",g)})})]}),jsxRuntime.jsxs(ui$1.ModalFooter,{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("button",{type:"button",onClick:a,className:"flex items-center gap-1.5 text-sm text-default-500 hover:text-foreground transition-colors cursor-pointer",children:[jsxRuntime.jsx(Wl,{className:"h-3.5 w-3.5"}),jsxRuntime.jsx("span",{children:s("predict.filter.reset")})]}),jsxRuntime.jsxs(ui$1.Button,{color:"secondary",size:"md",className:"min-w-[140px] font-medium",onPress:d,children:[s("predict.filter.showResults"),c>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",c,")"]})]})]})]})})}function Ye({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function Xe({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(s=>{let i=t===s.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:s.value);},className:ui$1.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-warning/15 text-warning border-warning/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:s.label},s.value??"__all")})})}function Wl({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M13.65 2.35A7.958 7.958 0 0 0 8 0C3.58 0 .01 3.58.01 8S3.58 16 8 16c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 8 14 6 6 0 1 1 8 2c1.66 0 3.14.69 4.22 1.78L9 7h7V0l-2.35 2.35Z",fill:"currentColor"})})}var _n={trending:{sort_by:"volume_24h",sort_asc:false},volume:{sort_by:"volume",sort_asc:false},newest:{sort_by:"created_at",sort_asc:false},ending_soon:{sort_by:"end_at",sort_asc:true},liquidity:{sort_by:"liquidity",sort_asc:false}},or={trending:"predict.sort.trending",volume:"predict.sort.volume",newest:"predict.sort.newest",ending_soon:"predict.sort.endingSoon",liquidity:"predict.sort.liquidity"},Zl={trending:"predict.sort.trending.desc",volume:"predict.sort.volume.desc",newest:"predict.sort.newest.desc",ending_soon:"predict.sort.endingSoon.desc",liquidity:"predict.sort.liquidity.desc"},Jl=["trending","volume","newest","ending_soon","liquidity"];function Vn({source:e,onSourceChange:t,sortPreset:r,onSortChange:n,onFilterPress:s,filterCount:i=0,className:o}){let{t:l}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center gap-2",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(Qn,{label:l("predict.platform.dflow"),isActive:e==="dflow",onPress:()=>t("dflow")}),jsxRuntime.jsx(Qn,{label:l("predict.platform.polymarket"),isActive:e==="polymarket",onPress:()=>t("polymarket")})]}),jsxRuntime.jsxs(ui$1.Dropdown,{children:[jsxRuntime.jsx(ui$1.DropdownTrigger,{children:jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-lg border border-default-200 bg-content1 px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(ec,{className:"h-3.5 w-3.5 text-warning"}),jsxRuntime.jsx("span",{children:l(or[r])}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-3 w-3 text-default-400"})]})}),jsxRuntime.jsx(ui$1.DropdownMenu,{"aria-label":"Sort events",selectionMode:"single",selectedKeys:new Set([r]),onSelectionChange:a=>{let d=Array.from(a)[0];d&&n(d);},classNames:{base:"min-w-[200px]"},children:Jl.map(a=>jsxRuntime.jsx(ui$1.DropdownItem,{textValue:l(or[a]),classNames:{base:"data-[selected=true]:text-warning"},children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:l(or[a])}),jsxRuntime.jsx("span",{className:"text-xxs text-default-400",children:l(Zl[a])})]})},a))})]}),jsxRuntime.jsx(ui$1.StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxRuntime.jsxs(ui$1.Button,{variant:"bordered",size:"sm",className:"min-w-0 gap-1.5 border-default-200 bg-content1 text-foreground hover:bg-content2",onPress:s,children:[jsxRuntime.jsx(ui$1.FilterIcon,{className:"h-3.5 w-3.5"}),jsxRuntime.jsx("span",{className:"text-xs font-medium",children:l("predict.filter.title")})]})})]})}function Qn({label:e,isActive:t,onPress:r}){return jsxRuntime.jsx("button",{type:"button",onClick:r,className:ui$1.cn("shrink-0 rounded-full px-2.5 py-1 text-xs font-medium transition-colors duration-150 cursor-pointer border whitespace-nowrap",t?"bg-foreground text-background border-foreground":"bg-content1 text-foreground/70 border-default-200 hover:bg-default-100 hover:text-foreground"),children:e})}function ec({className:e}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:[jsxRuntime.jsx("path",{d:"M8 1.333c-.667 2-2.667 3.334-2.667 5.334a2.667 2.667 0 0 0 5.334 0C10.667 4.667 8.667 3.333 8 1.333Z",fill:"currentColor",opacity:".6"}),jsxRuntime.jsx("path",{d:"M8 4c-.5 1.5-1.5 2.5-1.5 4a1.5 1.5 0 0 0 3 0c0-1.5-1-2.5-1.5-4Z",fill:"currentColor"})]})}function rc(e){if(e)return e.tagSlug??e.categorySlug??void 0}function nc(e){return ["predict-v2","events-infinite",e]}function Fn(e={}){let{tagSlugSelection:t,limit:r=48,status:n="open",sort_by:s,sort_asc:i,source:o,with_markets:l=true}=e,a=be(),d=react.useMemo(()=>{let C=rc(t);return {limit:r,status:n,with_markets:l,...o?{source:o}:{},...C?{tag_slug:C}:{},...s?{sort_by:s}:{},...i!==void 0?{sort_asc:i}:{}}},[t,r,n,s,i,o,l]),{data:u,isLoading:c,isFetching:p,isFetchingNextPage:m,isError:f,error:y,hasNextPage:x,fetchNextPage:g,refetch:h}=reactQuery.useInfiniteQuery({queryKey:nc(d),queryFn:({pageParam:C})=>a.listEvents({...d,...C!==void 0?{cursor:C}:{}}),initialPageParam:void 0,getNextPageParam:C=>C.has_more&&C.next_cursor?C.next_cursor:void 0}),k=react.useMemo(()=>u?.pages.flatMap(C=>C.items).filter(C=>C!=null)??[],[u]),v=react.useCallback(()=>{g();},[g]),P=react.useCallback(()=>{h();},[h]);return {data:k,isLoading:c,isFetching:p&&!m,isFetchingMore:m,isError:f,error:y??null,hasMore:x??false,fetchMore:v,refetch:P}}var Wn=3,qn=["bg-primary","bg-secondary","bg-blue-500","bg-purple-500"];function ar(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function cc(e){return e!=null?e*100:null}function uc(e){let t=cc(ar(e));return t!=null?Math.round(t):0}function dc(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function pc(e){if(!e)return null;try{let t=new Date(e);return isNaN(t.getTime())?null:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return null}}function mc(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function Hn({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:s,onHover:i}){let{t:o}=i18n.useTranslation(),l=e.markets??[],a=react.useMemo(()=>l.length>2?[...l].sort((h,k)=>(ar(k)??0)-(ar(h)??0)):l,[l]),d=a.filter(h=>h.status==="open"),u=d.slice(0,Wn),c=d.length-Wn,p=react.useMemo(()=>utils.formatAmountUSDCompact(e.volume??0),[e.volume]),m=pc(e.end_at),f=react.useMemo(()=>{let h=a.some(v=>v.status==="open");return a.every(v=>v.status==="closed"||v.status==="voided")?"closed":h?"live":"pending"},[a]),y=()=>n?.(e),x=()=>i?.(e),g=(h,k)=>{h.stopPropagation(),h.preventDefault(),s?s(e,k,"yes"):n?.(e);};return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:r,className:ui$1.cn("group flex h-full w-full flex-col justify-between rounded-xl","border border-default-200/60 bg-content1 p-3 @5xl:p-4","transition-all duration-200 cursor-pointer","hover:bg-content2/40 hover:border-default-300"),onClick:t?void 0:y,onMouseEnter:x,children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-1 flex-col gap-y-2.5 @5xl:gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0 transition-transform duration-200 group-hover:scale-105 @5xl:h-12 @5xl:w-12"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(fc,{source:e.source}),f==="pending"&&jsxRuntime.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium bg-warning-100/50 text-warning leading-none",children:o("predict.event.status.pending")})]}),jsxRuntime.jsx(ui$1.StyledTooltip,{content:e.title,placement:"bottom",children:jsxRuntime.jsx("p",{className:"text-sm font-semibold leading-snug line-clamp-2 @5xl:text-base",children:e.title})})]})]}),u.length>0&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[u.map((h,k)=>{let v=uc(h);return jsxRuntime.jsxs("button",{type:"button",className:"flex w-full flex-col gap-y-1 rounded-lg bg-content2/50 px-2.5 py-1.5 transition-colors hover:bg-content2 cursor-pointer",onClick:P=>g(P,h),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-between gap-x-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 min-w-0",children:[jsxRuntime.jsx("span",{className:ui$1.cn("h-2 w-2 flex-shrink-0 rounded-full",qn[k%qn.length])}),jsxRuntime.jsx("span",{className:"text-xs text-foreground/80 line-clamp-1 @5xl:text-sm",children:h.question})]}),jsxRuntime.jsx("span",{className:"flex-shrink-0 text-sm font-semibold text-foreground @5xl:text-base",children:dc(v)})]}),jsxRuntime.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-default-200/40",children:jsxRuntime.jsx("div",{className:ui$1.cn("h-full rounded-full transition-all duration-500",k===0?"bg-primary":k===1?"bg-secondary":"bg-blue-500"),style:{width:`${Math.max(v,1)}%`}})})]},h.slug)}),c>0&&jsxRuntime.jsx("span",{className:"px-2.5 text-xxs text-default-500 @5xl:text-xs",children:o("predict.event.moreOptions",{count:c})})]})]}),jsxRuntime.jsxs("div",{className:"mt-2 flex items-center justify-between gap-x-2 pt-1.5 border-t border-default-100/50",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 text-xxs text-default-500 @5xl:text-xs",children:[jsxRuntime.jsx(yc,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{children:p})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 text-xxs text-default-500 @5xl:text-xs",children:f==="closed"?jsxRuntime.jsx("span",{className:"text-danger",children:o("predict.event.status.closed")}):m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(gc,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{children:m})]}):f==="pending"?jsxRuntime.jsx("span",{className:"text-warning",children:o("predict.event.status.pending")}):null})]})]})}function fc({source:e}){return jsxRuntime.jsxs("span",{className:ui$1.cn("inline-flex items-center gap-x-1 rounded px-1.5 py-0.5","text-[10px] font-medium leading-none",e==="polymarket"?"bg-blue-500/15 text-blue-400":"bg-primary-500/15 text-primary"),children:[jsxRuntime.jsx("span",{className:ui$1.cn("h-1.5 w-1.5 rounded-sm",e==="polymarket"?"bg-blue-400":"bg-primary")}),mc(e)]})}function yc({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M1 8.5V3.5h2l2-2v9l-2-2H1ZM7 4.5v3M9 3.5v5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})})}function gc({className:e}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:[jsxRuntime.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1"}),jsxRuntime.jsx("path",{d:"M6 3.5V6l1.5 1.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Sc=640,Cc=768,$n=1024,Ec=1280,wc=16,Tc=296,Mc=312,Nc=328;function Rc(e){return e>=Ec?4:e>=$n?3:e>=Sc?2:1}function Oc(e){return e>=$n?Nc:e>=Cc?Mc:Tc}function zn({events:e,hasMore:t=false,onFetchMore:r,onSelect:n,onSelectOutcome:s,getEventHref:i,LinkComponent:o,onHover:l}){let a=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:a}),c=Rc(d),p=Oc(d),m=Math.ceil(e.length/c)||0,f=t?m+1:m,y=react.useCallback(h=>h<m,[m]),x=react.useCallback(async()=>{r?.();},[r]),g=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:y,loadMoreRows:x,rowCount:f,threshold:3});return jsxRuntime.jsx("div",{ref:a,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{style:{height:u},onRowsRendered:g,rowComponent:Ic,rowCount:f,rowHeight:p,rowProps:{events:e,columnCount:c,dataRowCount:m,gap:wc,onSelect:n,onSelectOutcome:s,getEventHref:i,LinkComponent:o,onHover:l}})})}function Ic({index:e,style:t,events:r,columnCount:n,dataRowCount:s,gap:i,onSelect:o,onSelectOutcome:l,getEventHref:a,LinkComponent:d,onHover:u}){if(e>=s)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let c=e*n,p=r.slice(c,c+n),m=n-p.length,f={display:"flex",gap:i,height:`calc(100% - ${i}px)`};return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{style:f,children:[p.map(y=>y==null?null:jsxRuntime.jsx("div",{style:{flex:1,minWidth:0},children:jsxRuntime.jsx(Hn,{event:y,href:a?.(y),LinkComponent:d,onSelect:o,onSelectOutcome:l,onHover:u})},y.slug)),m>0&&Array.from({length:m}).map((y,x)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${x}`))]})})}function Yn({tagSlugSelection:e,limit:t=48,status:r,sort_by:n,sort_asc:s,source:i,with_markets:o,onSelect:l,onSelectOutcome:a,getEventHref:d,LinkComponent:u,onHover:c}){let{data:p,hasMore:m,fetchMore:f,isFetching:y}=Fn({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:s,source:i,with_markets:o});return y?jsxRuntime.jsx(Pt,{count:48}):jsxRuntime.jsx(zn,{events:p,hasMore:m,onFetchMore:f,onSelect:l,onSelectOutcome:a,getEventHref:d,LinkComponent:u,onHover:c})}function ph({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:s}){let[i,o]=react.useState({categorySlug:null,tagSlug:null}),[l,a]=react.useState(nr),{isOpen:d,onOpen:u,onClose:c}=ui$1.useDisclosure(),p=react.useCallback(k=>{o(k);},[]),m=react.useCallback(k=>{a(v=>({...v,source:k}));},[]),f=react.useCallback(k=>{a(v=>({...v,sortPreset:k}));},[]),y=react.useCallback(k=>{a(k);},[]),x=react.useMemo(()=>_n[l.sortPreset],[l.sortPreset]),g=react.useMemo(()=>sr(l),[l]),h=jsxRuntime.jsx(Vn,{source:l.source,onSourceChange:m,sortPreset:l.sortPreset,onSortChange:f,onFilterPress:u,filterCount:g});return jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col gap-y-3",children:[jsxRuntime.jsx(Ln,{onSelect:p,trailing:h}),jsxRuntime.jsx(Bn,{isOpen:d,onClose:c,value:l,onChange:y}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Yn,{tagSlugSelection:i,sort_by:x.sort_by,sort_asc:x.sort_asc,source:l.source,onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:s})})]})}function ur(e,t,r){let n=e[t];return n?r==="yes"?n.yesMint:n.noMint:null}var Je=utils.SOLANA_TOKENS.stablecoins.USDC.address;function Wc(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};lr__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{lr__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{lr__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Jn({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:n="buy"}){let{t:s}=i18n.useTranslation(),i=react.useContext(ke),{status:o}=walletConnector.useAuth(),a=walletConnector.useWallets().find(E=>E.chainNamespace===types.ChainNamespace.SOLANA&&E.isConnected),d=o==="authenticated",u=a?.address,[c,p]=react.useState(r),[m,f]=react.useState(n),[y,x]=react.useState(NaN),g=react.useMemo(()=>ur(e.accounts,Je,c),[e.accounts,c]),{inputMint:h,outputMint:k}=react.useMemo(()=>m==="buy"?{inputMint:Je,outputMint:g}:{inputMint:g,outputMint:Je},[m,g]),v=!!h&&!!k&&y>0,P=react.useMemo(()=>Number(c==="yes"?e.yesAsk??.5:e.noAsk??.5),[c,e.yesAsk,e.noAsk]),C=react.useMemo(()=>isNaN(y)||y<=0?0:m==="buy"?P>0?y/P:0:y,[m,y,P]),N=react.useMemo(()=>isNaN(y)||y<=0?0:Math.round(y*1e6),[y]),{data:R,isLoading:S,error:L,refetch:V}=Jr({userPublicKey:u??void 0,inputMint:h??"",outputMint:k??"",amount:N,slippageBps:100},{enabled:v}),Oe=i?.usdcBalance??null,he=i?.isLoading??false,Lr=i?.refetch,me=i?.positions,at=react.useMemo(()=>{if(!me||!g)return null;let E=me.find(le=>le.mint===g);return E?E.balance:0},[me,g]),Qt=react.useMemo(()=>ur(e.accounts,Je,"yes"),[e.accounts]),Ut=react.useMemo(()=>ur(e.accounts,Je,"no"),[e.accounts]),No=react.useMemo(()=>{if(!me||!Qt)return null;let E=me.find(le=>le.mint===Qt);return E?E.balance:0},[me,Qt]),Ro=react.useMemo(()=>{if(!me||!Ut)return null;let E=me.find(le=>le.mint===Ut);return E?E.balance:0},[me,Ut]),{data:Ue}=Ae(e.ticker,{refetchInterval:5e3}),Oo=react.useMemo(()=>(c==="yes"?Ue?.yesBids:Ue?.noBids)?.[0]?.price??null,[Ue,c]),Io=react.useMemo(()=>(c==="yes"?Ue?.yesAsks:Ue?.noAsks)?.[0]?.price??null,[Ue,c]),Lo=react.useMemo(()=>R?.priceImpactPct?parseFloat(R.priceImpactPct):null,[R]),lt=react.useMemo(()=>{if(isNaN(y)||y<=0)return 0;if(R)return parseInt(R.inAmount)/1e6;if(m==="buy")return y;let E=Number(c==="yes"?e.yesBid??0:e.noBid??0);return y*E},[R,m,c,y,e.yesBid,e.noBid]),Br=react.useMemo(()=>isNaN(y)||y<=0?0:m==="buy"?C*1:lt,[m,C,lt,y]),Bo=Br-lt,Qo=react.useCallback(E=>{f(E),x(NaN);},[]),Uo=react.useCallback(E=>{if(isNaN(E)){x(NaN);return}let le=Math.max(0,E),dt=m==="buy"?Math.round(le*100)/100:Math.round(le);x(dt);},[m]);react.useEffect(()=>{v&&V();},[y,c,m,v,V]);let _t=react.useMemo(()=>{let E=[];return (isNaN(y)||y<Zt)&&E.push(`Minimum quantity is ${Zt}`),e.status!=="active"&&E.push("Market is not active"),m==="buy"&&Oe!=null&&!isNaN(y)&&y>0&&y>Oe&&E.push("Insufficient USDC balance"),m==="sell"&&at!=null&&!isNaN(y)&&y>0&&y>at&&E.push("Insufficient shares"),{isValid:E.length===0,errors:E}},[y,e.status,m,Oe,at]),[_o,Vt]=react.useState(null),[Vo,_e]=react.useState(false),[ct,ze]=react.useState(null),{data:ut}=en({signature:ct??""},{enabled:!!ct});react.useEffect(()=>{if(!ut||!ct)return;let{status:E}=ut;E==="closed"?(_e(false),ze(null),ui$1.toast.success(s("predict.trade.submitSuccess")),Wc(),x(NaN),Lr?.()):(E==="failed"||E==="expired")&&(_e(false),ze(null),ui$1.toast.error(s("predict.trade.submitError")));},[ut,ct,Lr,s]);let Ao=react.useCallback(async()=>{if(!(!_t.isValid||!d||!u||!a||he)){Vt(null),ze(null),_e(true);try{let E=R;if(E?.transaction||(E=(await V()).data),!E?.transaction){_e(!1);return}let le=Uint8Array.from(atob(E.transaction),Qr=>Qr.charCodeAt(0)),dt=await a.sendTransaction(le);Vt(dt),ze(dt);}catch{ui$1.toast.error(s("predict.trade.submitError")),_e(false);}}},[_t.isValid,d,u,a,R,he,V,s]),Do=react.useCallback(()=>{p(r),f(n),x(NaN),Vt(null),ze(null),_e(false);},[r,n]);return {outcome:c,side:m,quantity:y,shares:C,estimatedCost:lt,potentialPayout:Br,potentialProfit:Bo,isAuthenticated:d,bestBid:Oo,bestAsk:Io,order:R??null,priceImpact:Lo,usdcBalance:Oe,outcomeTokenBalance:at,yesTokenBalance:No,noTokenBalance:Ro,isBalanceLoading:he,isQuoteLoading:S,isSubmitting:Vo,quoteError:L??null,txHash:_o,orderStatus:ut??null,validation:_t,setOutcome:p,setSide:Qo,setQuantity:Uo,submit:Ao,reset:Do}}var Gc=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function ns({event:e,market:t,outcome:r,side:n,quantity:s,potentialProfit:i,estimatedCost:o,usdcBalance:l,yesTokenBalance:a,noTokenBalance:d,isBalanceLoading:u,isSubmitting:c,isValid:p,onOutcomeChange:m,onSideChange:f,onQuantityChange:y,onSubmit:x}){let{t:g}=i18n.useTranslation(),h=react.useMemo(()=>{if(c)return g("predict.trade.submitting");let v=g(n==="buy"?"predict.trade.buy":"predict.trade.sell"),P=g(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${v} ${P}`},[c,n,r,g]),k=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]);return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:r==="yes"?"text-bullish":"text-bearish",children:[g(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",g(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:v=>f(v),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:g("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui$1.Tab,{title:g("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(v=>{let P=v==="yes"?a:d;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(v),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===v?v==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:g(v==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let C=n==="buy"?v==="yes"?t.yesAsk:t.noAsk:v==="yes"?t.yesBid:t.noBid;return C!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(C)*100),"\xA2"]}):null})()]}),n==="sell"&&r===v&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:u?"\u2013":`${P??0} shares`})]},v)})}),n==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1 text-xs text-default-500",children:[jsxRuntime.jsx("img",{src:Gc,alt:"USDC",className:"h-4 w-4 rounded-full object-cover"}),jsxRuntime.jsxs("span",{children:[g("predict.trade.balance"),":"]}),jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:l!=null?`$${l.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:g(n==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui$1.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(s)?void 0:s,onValueChange:v=>{y(v);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},n),jsxRuntime.jsx("div",{className:"flex gap-x-2 justify-end",children:n==="buy"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[[1,5,10,100].map(v=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>y(Math.round(((isNaN(s)?0:s)+v)*100)/100),className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:["+",v,"$"]},v)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:g("common.all")})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[[25,50].map(v=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[v,"%"]},v)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:g("common.all")})]})})]}),!isNaN(s)&&s>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:g(n==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(n==="buy"?i:o).toFixed(2)]})]}),jsxRuntime.jsx(ui$1.Button,{color:k,fullWidth:true,radius:"lg",size:"lg",isDisabled:!p||c,isLoading:c,onPress:x,children:h})]})}function dr({event:e,market:t,initialSide:r,initialOutcome:n,chain:s}){let{outcome:i,side:o,quantity:l,estimatedCost:a,potentialPayout:d,potentialProfit:u,usdcBalance:c,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:f,isSubmitting:y,validation:x,setOutcome:g,setSide:h,setQuantity:k,submit:v}=Jn({market:t,initialSide:r,initialOutcome:n,chain:s}),P=walletConnector.useAuthCallback(v);return jsxRuntime.jsx(ns,{event:e,market:t,outcome:i,side:o,quantity:l,estimatedCost:a,potentialPayout:d,potentialProfit:u,usdcBalance:c,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:f,isSubmitting:y,isValid:x.isValid,validationErrors:x.errors,onOutcomeChange:g,onSideChange:h,onQuantityChange:k,onSubmit:P})}function jc(){return jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 px-2 py-3 lg:gap-x-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 flex-1 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-5 w-10 shrink-0 rounded-md"}),jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-16 rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-16 rounded-lg"})]})]})}function et({marketCount:e=4}){return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-4 lg:gap-y-6 px-1 lg:px-4 lg:max-w-3xl animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 lg:gap-x-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-14 w-14 shrink-0 rounded-lg lg:h-18 lg:w-18"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 min-w-0 flex-1",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-24 rounded-md lg:w-32"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-5 w-48 rounded-md lg:h-6 lg:w-72"})]})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-[200px] w-full rounded-xl lg:h-[280px]"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-32 rounded-md"}),jsxRuntime.jsx("div",{className:"flex gap-x-1",children:Array.from({length:4}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-10 rounded-md"},r))})]}),jsxRuntime.jsx("div",{className:"flex flex-col divide-y divide-default-200",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(jc,{},r))})]})}function ss(){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 w-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1 flex-1",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-28 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-40 rounded-md"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-x-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-12 rounded-md"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-12 rounded-md"})]}),jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 flex-1 rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 flex-1 rounded-lg"})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-14 w-full rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-12 w-full rounded-lg"})]})}var os=e=>{let{candlestickMarketTickers:t,chartRange:r=Se}=e,n=ht[r],s=kt[r],i=react.useMemo(()=>Math.floor(Date.now()/1e3),[r]),o=b(),{data:l,isLoading:a,error:d}=mt({id:e.eventId,withNestedMarkets:true}),u=react.useMemo(()=>{if(s!=null)return i-s;let k=l?.markets;return k?.length?Math.min(...k.map(v=>v.openTime)):i},[i,s,l?.markets]),{data:c,isLoading:p,error:m}=zr(l?.seriesTicker??"",{enabled:!!l?.seriesTicker}),f=react.useMemo(()=>l?.markets?(t&&t.length>0?t.slice(0,4).map(v=>l.markets.find(P=>P.ticker===v)).filter(v=>v!==void 0):[...l.markets].sort((v,P)=>Number(P.yesAsk??0)-Number(v.yesAsk??0)).slice(0,4)).map(v=>v.ticker):[],[t,l?.markets]),y=reactQuery.useQueries({queries:f.map(k=>({queryKey:zt({ticker:k,startTs:u,endTs:i,periodInterval:n}),queryFn:()=>Gt(o,{ticker:k,startTs:u,endTs:i,periodInterval:n}),enabled:f.length>0}))}),x=y.some(k=>k.isLoading),g=react.useMemo(()=>{let k=new Map;return f.forEach((v,P)=>{let C=y[P]?.error;C&&k.set(v,C);}),k},[f,y]),h=react.useMemo(()=>{let k=new Map;return f.forEach((v,P)=>{let C=y[P]?.data;C&&k.set(v,C);}),k},[f,y]);return {event:l,isEventLoading:a,eventError:d,series:c,isSeriesLoading:p,seriesError:m,periodInterval:n,candlesticks:h,isCandlesticksLoading:x,candlestickErrors:g}};var iu=utils.SOLANA_TOKENS.stablecoins.USDC.address;function is(e){let{status:t}=walletConnector.useAuth(),n=walletConnector.useWallets().find(d=>d.chainNamespace===types.ChainNamespace.SOLANA&&d.isConnected),s=t==="authenticated",i=n?.address,{data:o,isLoading:l}=react$1.useWalletPortfoliosQuery({chain:types.Chain.SOLANA,address:i??""},{enabled:s&&!!i,refetchInterval:1e4});return {holdings:react.useMemo(()=>{let d=new Map;if(!o?.portfolios||e.length===0)return d;let u=new Map;for(let c of o.portfolios)u.set(c.address,parseFloat(c.amount));for(let c of e){let p=c.accounts[iu];if(!p)continue;let m=u.get(p.yesMint)??0,f=u.get(p.noMint)??0;(m>0||f>0)&&d.set(c.ticker,{yesShares:m,noShares:f});}return d},[o,e]),isLoading:l}}function gu(e){let{cx:t,cy:r,index:n,dataLength:s,stroke:i}=e;return n!==s-1||t==null||r==null?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:i,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;8;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.1;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3,fill:i})]})}var Tt=[{stroke:"hsl(var(--heroui-primary))",id:"colorMarket0"},{stroke:"hsl(var(--heroui-secondary))",id:"colorMarket1"},{stroke:"hsl(var(--heroui-success))",id:"colorMarket2"},{stroke:"hsl(var(--heroui-warning))",id:"colorMarket3"}];function as(e,t){let r=new Date(e*1e3);switch(t){case w.ONE_DAY:return r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});case w.ONE_WEEK:case w.ONE_MONTH:return r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false});case w.ALL:default:return r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function vu(e,t,r){let n=bt[r],s=new Map;e.forEach((a,d)=>{let u=new Map;(a.candlesticks??[]).forEach(p=>{let m=p.end_period_ts-p.end_period_ts%n;u.set(m,p.yes_ask.close);}),s.set(d,u);});let i=new Set;for(let a of s.values())for(let d of a.keys())i.add(d);let o=Array.from(i).sort((a,d)=>a-d),l=new Map;return o.map(a=>{let u={date:new Date(a*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"}),timestamp:a};return t.forEach(c=>{let p=s.get(c)?.get(a);if(p!==void 0)u[c]=Math.round(p*100)/100,l.set(c,u[c]);else {let m=l.get(c);m!==void 0&&(u[c]=m);}}),u})}function ls({candlesticks:e,markets:t=[],isLoading:r,chartRange:n=w.ALL,onDataChange:s}){let[i,o]=react.useState(null),l=react.useRef(s);react.useEffect(()=>{l.current=s;});let a=react.useMemo(()=>e?Array.from(e.keys()).slice(0,4):[],[e]),d=react.useMemo(()=>!e||e.size===0?[]:vu(e,a,n),[e,a,n]),u=react.useMemo(()=>{if(d.length===0||a.length===0)return [0,100];let f=1/0,y=-1/0;if(d.forEach(v=>{a.forEach(P=>{let C=v[P];C!==void 0&&(f=Math.min(f,C),y=Math.max(y,C));});}),f===1/0||y===-1/0)return [0,100];let x=y-f,g=Math.max(x*.2,5),h=Math.max(0,Math.floor(f-g)),k=Math.min(100,Math.ceil(y+g));return [h,k]},[d,a]),c=react.useCallback(f=>{if(d.length===0)return null;let y=f!==null?d[f]:d[d.length-1];return y?{timestamp:y.timestamp,date:y.date,markets:a.map((x,g)=>{let h=t.find(k=>k.ticker===x);return {id:x,label:h?.yesSubTitle||`Market ${g+1}`,value:y[x]??0,color:Tt[g%Tt.length].stroke}})}:null},[d,a,t]);react.useEffect(()=>{l.current&&d.length>0&&l.current(c(null));},[d,c]),react.useEffect(()=>{l.current&&l.current(c(i));},[i,c]);let p=react.useCallback(f=>{typeof f?.activeTooltipIndex=="number"&&o(f.activeTooltipIndex);},[]),m=react.useCallback(()=>{o(null);},[]);return r?jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px] flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-default-400 text-sm",children:"Loading chart..."})}):d.length===0?jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px] flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-default-400 text-sm",children:"No price history data"})}):jsxRuntime.jsx("div",{className:"h-[200px] w-full lg:h-[300px]",children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:d,margin:{top:10,right:16,left:16,bottom:0},onMouseMove:p,onMouseLeave:m,children:[jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",tick:f=>{let{x:y,y:x,payload:g,index:h}=f,k=d.length,P=Math.max(1,Math.ceil(k/6)),C=h===0,N=h===k-1,R=h%P===0;return !C&&!N&&!R?null:jsxRuntime.jsx("text",{x:y,y:x+10,textAnchor:"middle",fill:"hsl(var(--heroui-default-500))",fontSize:10,children:as(g.value,n)})},tickLine:false,axisLine:false,interval:0}),jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"hsl(var(--heroui-default-200))"}),jsxRuntime.jsx(recharts.YAxis,{domain:u,tickLine:false,axisLine:false,tick:{fontSize:10,fill:"hsl(var(--heroui-default-500))"},tickFormatter:f=>`${f}%`,width:40}),jsxRuntime.jsx(recharts.Tooltip,{contentStyle:{backgroundColor:"hsl(var(--heroui-content1))",border:"1px solid hsl(var(--heroui-default-200))",borderRadius:"8px",fontSize:"12px"},labelFormatter:f=>as(f,n),formatter:(f,y)=>{let g=t.find(h=>h.ticker===y)?.yesSubTitle||y;return [`${f.toFixed(2)}%`,g]}}),a.map((f,y)=>jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:f,stroke:Tt[y%Tt.length].stroke,strokeWidth:2,isAnimationActive:false,dot:x=>jsxRuntime.jsx(gu,{...x,dataLength:d.length},`dot-${f}-${x.index}`),activeDot:false},f))]})})})}function cs(){return {timestamp:Date.now()/1e3,date:new Date().toLocaleDateString("en-US",{month:"short",day:"numeric"}),markets:[]}}function ds({marketTicker:e,openTime:t,chartRange:r=Se}){let n=ht[r],s=kt[r],i=react.useMemo(()=>Math.floor(Date.now()/1e3),[r]),o=react.useMemo(()=>s!=null?i-s:t??i,[i,s,t]),{data:l,isLoading:a,isFetching:d,error:u}=Yt({ticker:e,startTs:o,endTs:i,periodInterval:n},{enabled:!!e});return {candlesticks:l,isLoading:a,isFetching:d,error:u,periodInterval:n}}var Eu="hsl(var(--heroui-primary))",wu=[{value:w.ONE_DAY,label:"1D"},{value:w.ONE_WEEK,label:"1W"},{value:w.ONE_MONTH,label:"1M"},{value:w.ALL,label:"ALL"}];function Tu(e){let{cx:t,cy:r,index:n,dataLength:s,stroke:i}=e;return n!==s-1||t==null||r==null?null:jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:i,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;8;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.1;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3,fill:i})]})}function ms(e,t){let r=new Date(e*1e3);switch(t){case w.ONE_DAY:return r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false});case w.ONE_WEEK:case w.ONE_MONTH:return r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false});case w.ALL:default:return r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}}function Mu(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0)}function Nu(e,t){let r=bt[t],n=e.candlesticks??[],s=new Map;for(let o of n){let l=o.end_period_ts-o.end_period_ts%r,a=s.get(l);s.set(l,{close:o.yes_ask.close,volume:(a?.volume??0)+(o.volume??0)});}return Array.from(s.entries()).sort((o,l)=>o[0]-l[0]).map(([o,{close:l,volume:a}])=>({timestamp:o,date:new Date(o*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"}),value:Math.round(l*100)/100,volume:a}))}function fs({candlesticks:e,isLoading:t,chartRange:r,onRangeChange:n}){let s=react.useMemo(()=>e?Nu(e,r):[],[e,r]),i=react.useMemo(()=>{if(s.length===0)return [0,100];let o=1/0,l=-1/0;for(let p of s)p.value<o&&(o=p.value),p.value>l&&(l=p.value);if(o===1/0||l===-1/0)return [0,100];let a=l-o,d=Math.max(a*.2,5),u=Math.max(0,Math.floor(o-d)),c=Math.min(100,Math.ceil(l+d));return [u,c]},[s]);return t?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-neutral text-sm",children:"Loading chart..."})}),jsxRuntime.jsx(gr,{chartRange:r,onRangeChange:n})]}):s.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"text-neutral text-sm",children:"No price history data"})}),jsxRuntime.jsx(gr,{chartRange:r,onRangeChange:n})]}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("div",{className:"h-[200px] w-full",children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:s,margin:{top:10,right:16,left:16,bottom:0},children:[jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",tick:o=>{let{x:l,y:a,payload:d,index:u}=o,c=s.length,m=Math.max(1,Math.ceil(c/6)),f=u===0,y=u===c-1,x=u%m===0;return !f&&!y&&!x?null:jsxRuntime.jsx("text",{x:l,y:a+10,textAnchor:"middle",fill:"hsl(var(--heroui-default-500))",fontSize:10,children:ms(d.value,r)})},tickLine:false,axisLine:false,interval:0}),jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"hsl(var(--heroui-default-200))"}),jsxRuntime.jsx(recharts.YAxis,{domain:i,tickLine:false,axisLine:false,tick:{fontSize:10,fill:"hsl(var(--heroui-default-500))"},tickFormatter:o=>`${o}%`,width:40}),jsxRuntime.jsx(recharts.Tooltip,{cursor:{stroke:"hsl(var(--heroui-default-300))"},content:({active:o,payload:l})=>{if(!o||!l?.length)return null;let a=l[0].payload,d=Math.round(a.value);return jsxRuntime.jsxs("div",{className:"rounded-lg border border-default-200 bg-content1 px-3 py-2 shadow-md",children:[jsxRuntime.jsxs("div",{className:"text-lg font-semibold text-primary",children:["Yes ",d,"\xA2"]}),jsxRuntime.jsxs("div",{className:"text-sm text-neutral",children:["Vol ",Mu(a.volume)," \xB7"," ",ms(a.timestamp,r)]})]})}}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"value",stroke:Eu,strokeWidth:2,isAnimationActive:false,dot:o=>jsxRuntime.jsx(Tu,{...o,dataLength:s.length},`dot-${o.index}`),activeDot:false})]})})}),jsxRuntime.jsx(gr,{chartRange:r,onRangeChange:n})]})}function gr({chartRange:e,onRangeChange:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-1",children:wu.map(r=>{let n=e===r.value;return jsxRuntime.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-md transition-colors cursor-pointer ${n?"bg-primary text-primary-foreground":"bg-default-100 text-default-600 hover:bg-default-200"}`,onClick:()=>t?.(r.value),children:r.label},r.value)})})}function ys({marketTicker:e}){let{data:t,isLoading:r,error:n}=Ae(e,{enabled:!!e});return {orderbook:react.useMemo(()=>{if(!t)return null;let{yesBids:i,yesAsks:o,noBids:l,noAsks:a}=t;return {yesBids:i,yesAsks:o,noBids:l,noAsks:a,bestYesBid:i.length>0?i[0].price:null,bestYesAsk:o.length>0?o[0].price:null,bestNoBid:l.length>0?l[0].price:null,bestNoAsk:a.length>0?a[0].price:null,sequence:t.sequence??null}},[t]),isOrderbookLoading:r,orderbookError:n}}function gs(e,t){let r=e.slice(0,t),n=0;return r.map(s=>(n+=s.quantity,{...s,cumulative:n,depth:0,total:s.price*s.quantity}))}function vs(e,t){for(let r of e)r.depth=t>0?r.cumulative/t:0;}function ks(e){return `${Math.round(e*100)}\xA2`}function Iu(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Lu(e){return e>=1e6?`$${(e/1e6).toFixed(2)}M`:e>=1e3?`$${(e/1e3).toFixed(2)}K`:e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function xs({row:e,side:t,showType:r=false,onClick:n}){let{t:s}=i18n.useTranslation(),i=t==="ask",o=i?"bg-bullish/10":"bg-bearish/10",l=i?"text-bullish":"text-bearish";return jsxRuntime.jsxs("button",{type:"button",className:"relative grid w-full grid-cols-4 px-2 py-2.5 text-xs cursor-pointer hover:bg-default-100 transition-colors",onClick:()=>n?.(e.price,t),children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${o} transition-[width] duration-200`,style:{width:`${e.depth*100}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 font-mono font-medium ${l} text-left`,children:r?s(i?"predict.trade.bestAsk":"predict.trade.bestBid"):""}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:ks(e.price)}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:Iu(e.quantity)}),jsxRuntime.jsx("span",{className:"relative z-10 font-mono text-foreground text-right",children:Lu(e.total)})]})}function hs({index:e}){let t=["60%","45%","75%","55%","65%","50%","70%","40%"];return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100",style:{width:t[e%t.length]}}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"})]})}function Bu(){return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-1/2"})]}),Array.from({length:vr}).map((e,t)=>jsxRuntime.jsx(hs,{index:t},`ask-${t}`)),jsxRuntime.jsx("div",{className:"flex justify-center border-y border-default-200 px-2 py-2.5",children:jsxRuntime.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-default-100"})}),Array.from({length:vr}).map((e,t)=>jsxRuntime.jsx(hs,{index:t+3},`bid-${t}`))]})}var vr=8;function xr({bids:e,asks:t,isLoading:r=false,maxLevels:n=vr,onPriceClick:s}){let{t:i}=i18n.useTranslation(),{bidRows:o,askRows:l,spread:a,spreadPercent:d}=react.useMemo(()=>{let c=gs(e,n),p=gs(t,n),m=Math.max(c[c.length-1]?.cumulative??0,p[p.length-1]?.cumulative??0);vs(c,m),vs(p,m);let f=c[0]?.price??null,y=p[0]?.price??null,x=null,g=null;if(f!=null&&y!=null){x=y-f;let h=(f+y)/2;h>0&&(g=Math.round(x/h*1e4)/100);}return {bidRows:c,askRows:p,spread:x,spreadPercent:g}},[e,t,n]);return r?jsxRuntime.jsx(Bu,{}):o.length===0&&l.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:i("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:i("predict.orderBook.total")})]}),jsxRuntime.jsx("div",{className:"flex flex-col-reverse",children:l.map((c,p)=>jsxRuntime.jsx(xs,{row:c,side:"ask",showType:p===0,onClick:s},c.price))}),a!=null&&jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 border-y border-default-200 px-2 py-2.5 text-xs text-default-500",children:[jsxRuntime.jsxs("span",{children:[i("predict.orderBook.spread"),": ",ks(a)]}),d!=null&&jsxRuntime.jsxs("span",{className:"text-default-400",children:["(",d,"%)"]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:o.map((c,p)=>jsxRuntime.jsx(xs,{row:c,side:"bid",showType:p===0,onClick:s},c.price))})]})}function _u(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(2)}K`:e.toLocaleString(void 0,{maximumFractionDigits:2})}function Vu(e){let t=Math.abs(e),r=e>=0?"+":"-";return t>=1e3?`${r}$${(t/1e3).toFixed(1)}K`:t>=1?`${r}$${t.toFixed(2)}`:`${r}$${t.toFixed(4)}`}function Ps({positions:e,isLoading:t=false}){let{t:r}=i18n.useTranslation();return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})}):e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:r("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-5 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{children:r("predict.positions.outcome")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.qty")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.avgCost")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.currentPrice")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.positions.pnl")})]}),e.map(n=>{let s=n.position==="YES",i=s?"text-bullish":"text-bearish",o=r(s?"predict.market.yes":"predict.market.no"),l=n.avgCost!=null?`${Math.round(n.avgCost*100)}\xA2`:"\u2014",a=n.currentPrice!=null?`${Math.round(n.currentPrice*100)}\xA2`:"\u2014",d=n.pnl!=null&&n.pnlPercent!=null,u=d&&n.pnl>0?"text-bullish":d&&n.pnl<0?"text-bearish":"text-foreground";return jsxRuntime.jsxs("div",{className:"grid grid-cols-5 px-2 py-2.5 text-xs hover:bg-default-100 transition-colors",children:[jsxRuntime.jsx("span",{className:`font-medium ${i}`,children:o}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:_u(n.balance)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:l}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:a}),jsxRuntime.jsx("span",{className:`text-right font-mono ${u}`,children:d?jsxRuntime.jsxs("span",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{children:Vu(n.pnl)}),jsxRuntime.jsxs("span",{className:"text-[10px] opacity-70",children:[n.pnlPercent>=0?"+":"",n.pnlPercent.toFixed(1),"%"]})]}):"\u2014"})]},n.mint)})]})}function Du(e){let t=e/1e6;return t>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(2)}K`:t.toLocaleString(void 0,{maximumFractionDigits:2})}function Fu(e){return e==null?"\u2014":`${Math.round(e*100)}\xA2`}function Wu(e){let t=new Date(e*1e3),r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${n} ${s}:${i}`}function qu({index:e}){let t=["60%","45%","75%","55%","65%"];return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 gap-x-2 px-2 py-2.5",children:[jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100",style:{width:t[e%t.length]}}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"}),jsxRuntime.jsx("div",{className:"h-4 animate-pulse rounded bg-default-100 ml-auto w-3/4"})]})}function Ss({trades:e,isLoading:t=false}){let{t:r}=i18n.useTranslation();return t?jsxRuntime.jsx("div",{className:"flex flex-col",children:Array.from({length:6}).map((n,s)=>jsxRuntime.jsx(qu,{index:s},s))}):e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-6 text-sm text-neutral",children:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs text-neutral",children:[jsxRuntime.jsx("span",{children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("span",{className:"text-right",children:r("predict.tradeHistory.time")})]}),e.map(n=>{let s=n.side==="yes",i=s?"text-bullish":"text-bearish",o=n.side?r(s?"predict.trade.yes":"predict.trade.no"):"\u2014";return jsxRuntime.jsxs("div",{className:"grid grid-cols-4 px-2 py-2.5 text-xs hover:bg-default-100 transition-colors",children:[jsxRuntime.jsx("span",{className:`font-medium ${i}`,children:o}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:Fu(n.usdPricePerContract)}),jsxRuntime.jsx("span",{className:"text-right font-mono text-foreground",children:Du(n.outputAmount)}),jsxRuntime.jsx("span",{className:"text-right text-default-500",children:Wu(n.createdAt)})]},n.id)})]})}function Ts({market:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[n,s]=react.useState("trade-yes"),[i,o]=react.useState(Se),{orderbook:l,isOrderbookLoading:a}=ys({marketTicker:e.ticker}),{candlesticks:d,isFetching:u}=ds({marketTicker:e.ticker,openTime:e.openTime,chartRange:i}),{positions:c,isLoading:p}=Xr(e),{status:m}=walletConnector.useAuth(),x=walletConnector.useWallets().find(N=>N.chainNamespace===types.ChainNamespace.SOLANA&&N.isConnected)?.address,{data:g,isLoading:h}=qr({walletAddress:x??""},{enabled:(n==="trade-history"||n==="positions")&&m==="authenticated"&&!!x}),k=(g?.trades??[]).filter(N=>N.marketTicker===e.ticker),v=react.useMemo(()=>c.map(N=>{let R=k.filter(he=>he.outputMint===N.mint&&he.usdPricePerContract!=null&&he.contracts!=null&&he.contracts>0),S=Xu(R),L=N.position==="YES"?ws(N.market?.yesAsk):ws(N.market?.noAsk),V=null,Oe=null;return S!=null&&L!=null&&(V=(L-S)*N.balance,Oe=S>0?(L-S)/S*100:null),{...N,avgCost:S,currentPrice:L,pnl:V,pnlPercent:Oe}}),[c,k]),P=react.useCallback((N,R)=>{t?.(e,"yes",R==="ask"?"buy":"sell");},[e,t]),C=react.useCallback((N,R)=>{t?.(e,"no",R==="ask"?"buy":"sell");},[e,t]);return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:N=>s(N),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:r("predict.market.tradeYes")},"trade-yes"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.market.tradeNo")},"trade-no"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.market.graph")},"graph"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.positions.title")},"positions"),jsxRuntime.jsx(ui$1.Tab,{title:r("predict.tradeHistory.title")},"trade-history")]}),jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[n==="trade-yes"&&jsxRuntime.jsx(xr,{bids:l?.yesBids??[],asks:l?.yesAsks??[],isLoading:a,onPriceClick:P}),n==="trade-no"&&jsxRuntime.jsx(xr,{bids:l?.noBids??[],asks:l?.noAsks??[],isLoading:a,onPriceClick:C}),n==="graph"&&jsxRuntime.jsx(fs,{candlesticks:d,isLoading:u,chartRange:i,onRangeChange:o}),n==="positions"&&jsxRuntime.jsx(Ps,{positions:v,isLoading:p}),n==="trade-history"&&jsxRuntime.jsx(Ss,{trades:k,isLoading:h})]})]})}function Xu(e){if(e.length===0)return null;let t=0,r=0;for(let n of e)t+=n.contracts,r+=n.usdPricePerContract*n.contracts;return t>0?r/t:null}function ws(e){if(e==null)return null;let t=Number(e);return Number.isFinite(t)?t:null}var br=4;function Zu(e){let t=e.yesAsk?Math.round(parseFloat(e.yesAsk)*100):null,r=e.noAsk?Math.round(parseFloat(e.noAsk)*100):null;return {yesCents:t,noCents:r}}function Bs({markets:e,renderMarketDetail:t,onTradeAction:r,marketHoldings:n}){let{t:s}=i18n.useTranslation(),[i,o]=react.useState(false),[l,a]=react.useState(null);if(e.length===0)return null;let d=e.length>br,u=i?e:e.slice(0,br),c=p=>{a(m=>m===p?null:p);};return jsxRuntime.jsxs("div",{className:"flex flex-col divide-y divide-default-200",children:[u.map(p=>{let{yesCents:m,noCents:f}=Zu(p),y=l===p.ticker;return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 px-2 py-3 transition-colors hover:bg-content2 lg:gap-x-4 cursor-pointer",onClick:()=>c(p.ticker),role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(p.ticker));},children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1 min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium truncate lg:text-base",children:p.yesSubTitle}),(()=>{let x=n?.get(p.ticker);if(!x)return null;let{yesShares:g,noShares:h}=x;return g<=0&&h<=0?null:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1.5",children:[g>0&&jsxRuntime.jsx(ui$1.Chip,{size:"sm",variant:"flat",color:"primary",classNames:{base:"h-5",content:"text-[10px] font-medium px-1"},children:s("predict.market.sharesYes",{shares:g%1===0?g:g.toFixed(2)})}),h>0&&jsxRuntime.jsx(ui$1.Chip,{size:"sm",variant:"flat",color:"secondary",classNames:{base:"h-5",content:"text-[10px] font-medium px-1"},children:s("predict.market.sharesNo",{shares:h%1===0?h:h.toFixed(2)})})]})})()]}),(()=>{let x=m!=null,g=f!=null;return x&&!g&&m<=1?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"< 1%"}):g&&!x&&f<=1?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"> 99%"}):!x&&!g?jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center text-default-400 lg:text-xl",children:"0%"}):jsxRuntime.jsx("span",{className:"text-lg font-bold shrink-0 text-center lg:text-xl",children:`${m}%`})})(),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 flex-1 justify-end",children:[jsxRuntime.jsx(ui$1.Button,{size:"sm",color:"primary",className:"w-20 bg-primary-100 text-primary",onPress:()=>r?.(p,"yes","buy"),children:m!=null?s("predict.market.action.yes",{price:m}):s("predict.market.yes")}),jsxRuntime.jsx(ui$1.Button,{size:"sm",color:"secondary",className:"w-20 bg-secondary-100 text-secondary",onPress:()=>r?.(p,"no","buy"),children:f!=null?s("predict.market.action.no",{price:f}):s("predict.market.no")})]}),y?jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"h-4 w-4 shrink-0 text-default-400"}):jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-4 w-4 shrink-0 text-default-400"})]}),y&&t&&jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto px-2 pb-3",children:t(p)})]},p.ticker)}),d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>o(p=>!p),className:"flex items-center justify-center gap-x-1.5 px-2 py-2.5 text-sm text-default-500 transition-colors cursor-pointer hover:text-primary",children:i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:s("predict.event.rules.collapse")}),jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"h-4 w-4"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:s("predict.event.moreMarkets",{count:e.length-br})}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-4 w-4"})]})})]})}var nd=new Set(["closed","determined","finalized"]);function Nt(e){let t=new Date(e*1e3),r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),s=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${s} ${i}:${o}`}function sd({market:e}){let t=nd.has(e.status),r=react.useMemo(()=>{let s={label:"Market Open",value:Nt(e.openTime),isActive:true},i={label:"Market Closes",value:t?Nt(e.closeTime):"After the outcome occurs",isActive:t},o={label:"Projected Payout",value:"30 minutes after closing",isActive:e.status==="finalized"};return [s,i,o]},[e.openTime,e.closeTime,e.status,t]),n=react.useMemo(()=>t?null:e.canCloseEarly&&e.earlyCloseCondition?`${e.earlyCloseCondition} Otherwise, it closes by ${Nt(e.expirationTime)}.`:`This market closes by ${Nt(e.expirationTime)}.`,[t,e.canCloseEarly,e.earlyCloseCondition,e.expirationTime]);return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[r.map((s,i)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${s.isActive?"border-primary bg-primary":"border-default-300 bg-transparent"}`}),i<r.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-default-200"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${i<r.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:s.label}),jsxRuntime.jsx("span",{className:"text-xs text-default-500 lg:text-sm",children:s.value})]})]},s.label)),n&&jsxRuntime.jsx("p",{className:"text-xs text-default-500 mt-3 lg:text-sm",children:n})]})}function Us({markets:e,event:t,series:r}){let{t:n}=i18n.useTranslation(),[s,i]=react.useState(null),o=e.filter(a=>a.rulesPrimary);if(o.length===0)return null;let l=o.find(a=>a.ticker===s)??o[0];return l?.rulesPrimary?jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium lg:text-base",children:n("predict.event.rules")}),o.length>1&&jsxRuntime.jsx(ui$1.Select,{size:"sm","aria-label":"Select market rules",className:"max-w-48",classNames:{trigger:"min-h-8 h-8",value:"text-xs"},selectedKeys:new Set([l.ticker]),onSelectionChange:a=>{if(a==="all")return;let d=Array.from(a);d.length>0&&i(d[0]);},children:o.map(a=>jsxRuntime.jsx(ui$1.SelectItem,{textValue:a.yesSubTitle,children:jsxRuntime.jsx("span",{className:"text-xs truncate",children:a.yesSubTitle})},a.ticker))}),jsxRuntime.jsx("div",{className:"text-xs text-foreground lg:text-sm",children:l.rulesPrimary}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-default-500 mt-2 lg:text-sm",children:"Timeline and payout"}),jsxRuntime.jsx(sd,{market:l}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-default-400 mt-2 lg:text-xs",children:[r?.ticker&&jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Series:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:r.ticker})]}),t.ticker&&jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Event:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.ticker})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("span",{className:"text-default-500",children:"Market:"})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:l.ticker})]})]})]}):null}var md=[{value:w.ONE_DAY,label:"1D"},{value:w.ONE_WEEK,label:"1W"},{value:w.ONE_MONTH,label:"1M"},{value:w.ALL,label:"ALL"}];function Vs({event:e,series:t,candlesticks:r,chartRange:n=w.ONE_DAY,periodInterval:s,isCandlesticksLoading:i,onRangeChange:o,selectedMarketTickers:l,onMarketSelectionChange:a,onTradeAction:d}){let{t:u}=i18n.useTranslation(),[c,p]=react.useState(cs()),[m,f]=react.useState(false),y=react.useRef(null);react.useEffect(()=>{let v=y.current;if(!v)return;let P=false,C=0,N=()=>{let{bottom:S}=v.getBoundingClientRect(),L=P?S<0:S<-20;L!==P&&(P=L,f(L));},R=()=>{cancelAnimationFrame(C),C=requestAnimationFrame(N);};return window.addEventListener("scroll",R,{passive:true,capture:true}),N(),()=>{cancelAnimationFrame(C),window.removeEventListener("scroll",R,{capture:true});}},[]);let x=react.useMemo(()=>[...e.markets||[]].sort((v,P)=>Number(P.yesAsk??0)-Number(v.yesAsk??0)),[e.markets]),{holdings:g}=is(x),h=react.useMemo(()=>utils.formatAmountUSDCompact((e.volume??0)/100),[e.volume]),k=react.useMemo(()=>{if(!e.strikeDate)return null;let v=new Date(e.strikeDate*1e3),P=v.toLocaleString("default",{month:"short"}),C=v.getDate(),N=v.getFullYear();return `${P} ${C}, ${N}`},[e.strikeDate]);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-4 lg:gap-y-6 px-1 pb-8 lg:px-4 lg:pb-12 lg:max-w-3xl",children:[jsxRuntime.jsx("div",{ref:y,className:"h-0 w-0"}),jsxRuntime.jsxs("div",{className:`sticky top-0 z-30 flex items-center bg-background/80 backdrop-blur-md transition-all duration-300 ${m?"gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.imageUrl||void 0,name:e.title||"Event",radius:"lg",className:`flex-shrink-0 transition-all duration-300 ${m?"!h-8 !w-8 lg:!h-10 lg:!w-10":"!h-14 !w-14 lg:!h-18 lg:!w-18"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[!m&&(t?.category||t?.tags&&t.tags.length>0)&&jsxRuntime.jsxs("span",{className:"text-xs text-default-500 lg:text-sm truncate",children:[t.category,t.category&&t.tags?.length>0&&" \xB7 ",t.tags?.join(", ")]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${m?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-4",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[c&&c.markets.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-xs lg:text-sm",children:c.markets.map(v=>jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:v.color}}),jsxRuntime.jsx("span",{className:"text-default-600",children:v.label})]},v.id))}),jsxRuntime.jsx(ls,{candlesticks:r,chartRange:n,markets:x,isLoading:i,onDataChange:v=>p(v)}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 mt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3 text-xs text-default-500 lg:text-sm",children:[jsxRuntime.jsxs("span",{children:[h," ",u("predict.event.volume")]}),k&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-default-300",children:"\xB7"}),jsxRuntime.jsx("span",{children:u("predict.event.endDate",{date:k})})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-x-1",children:md.map(v=>jsxRuntime.jsx("button",{type:"button",onClick:()=>o?.(v.value),className:`px-2 lg:px-3 py-1 text-xs rounded-md transition-colors cursor-pointer ${n===v.value?"bg-primary text-primary-foreground":"bg-default-100 text-default-600 hover:bg-default-200"}`,children:v.label},v.value))}),x.length>1&&jsxRuntime.jsx(ui$1.Select,{size:"sm",selectionMode:"multiple",placeholder:"Markets","aria-label":"Select markets",className:"min-w-28 max-w-48",classNames:{trigger:"min-h-8 h-8",value:"text-xs"},selectedKeys:l?new Set(l):void 0,onSelectionChange:v=>{if(v==="all")return;let P=Array.from(v);P.length<=4&&a?.(P);},children:jsxRuntime.jsx(ui$1.SelectSection,{title:`Pick up to ${4} markets`,classNames:{heading:"text-xs text-default-400 px-2 py-1"},children:x.map(v=>jsxRuntime.jsx(ui$1.SelectItem,{textValue:v.yesSubTitle,children:jsxRuntime.jsx("span",{className:"text-xs truncate",children:v.yesSubTitle})},v.ticker))})})]})]})}),jsxRuntime.jsx(Bs,{markets:x,onTradeAction:d,marketHoldings:g,renderMarketDetail:v=>jsxRuntime.jsx(Ts,{market:v,onTradeAction:d})}),jsxRuntime.jsx(Us,{markets:x,event:e,series:t})]})}function Sr({eventId:e,initialMarketTickers:t,initialChartRange:r=Se,onTradeAction:n}){let[s,i]=react.useState(r),[o,l]=react.useState(t),{event:a,isEventLoading:d,eventError:u,series:c,isSeriesLoading:p,periodInterval:m,candlesticks:f,isCandlesticksLoading:y,candlestickErrors:x}=os({eventId:e,candlestickMarketTickers:o,chartRange:s}),g=react.useRef(!!t);react.useEffect(()=>{if(a?.markets&&!g.current){g.current=true;let v=[...a.markets].sort((P,C)=>Number(C.yesAsk??0)-Number(P.yesAsk??0)).slice(0,4).map(P=>P.ticker);l(v);}},[a?.markets]);let h=react.useMemo(()=>v=>{i(v);},[]),k=react.useMemo(()=>v=>{l(v);},[]);return d||p?jsxRuntime.jsx(et,{}):u||!a?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:u?.message||"Event not found"}):jsxRuntime.jsx(Vs,{event:a,series:c,candlesticks:f,chartRange:s,periodInterval:m,isCandlesticksLoading:y,candlestickErrors:x,onRangeChange:h,selectedMarketTickers:o,onMarketSelectionChange:k,onTradeAction:n})}function Fk({eventId:e,chain:t,...r}){let{t:n}=i18n.useTranslation(),{isMobile:s}=ui$1.useScreen(),{isOpen:i,onOpen:o,onClose:l}=ui$1.useDisclosure(),{data:a,isLoading:d}=mt({id:e,withNestedMarkets:true}),u=react.useMemo(()=>[...a?.markets||[]].sort((x,g)=>Number(g.yesAsk??0)-Number(x.yesAsk??0)),[a?.markets]),[c,p]=react.useState(null),m=react.useCallback((x,g,h)=>{p(k=>({market:x,outcome:g,side:h,version:(k?.version??0)+1})),s&&o();},[s,o]),f=c?.market??u[0];if(d)return s?jsxRuntime.jsx(et,{}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(et,{})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4",children:jsxRuntime.jsx(ss,{})})})]});let y=c?`${c.market.ticker}-${c.version}`:f?.ticker??"default";return s?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-full pb-20",children:jsxRuntime.jsx(Sr,{eventId:e,onTradeAction:m,...r})}),f&&jsxRuntime.jsx("div",{className:"fixed inset-x-0 bottom-0 z-40 flex justify-center p-3 bg-gradient-to-t from-background via-background/90 to-transparent",children:jsxRuntime.jsx(ui$1.Button,{color:"primary",size:"lg",className:"w-full max-w-md font-semibold",onPress:o,children:n("predict.trade.action")})}),jsxRuntime.jsx(ui$1.Drawer,{isOpen:i,onClose:l,placement:"bottom",size:"lg",hideCloseButton:true,classNames:{base:"max-h-[85dvh] rounded-t-2xl",body:"p-0"},children:jsxRuntime.jsx(ui$1.DrawerContent,{children:jsxRuntime.jsx(ui$1.DrawerBody,{children:f&&jsxRuntime.jsx(dr,{event:a,market:f,initialSide:c?.side,initialOutcome:c?.outcome,chain:t},y)})})})]}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Sr,{eventId:e,onTradeAction:m,...r})}),f&&jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 flex flex-col gap-y-4",children:jsxRuntime.jsx(dr,{event:a,market:f,initialSide:c?.side,initialOutcome:c?.outcome,chain:t},y)})})]})}function Fs(e,t){if(!e)return [];let r=e.slice(0,t),n=0,s=r.map(o=>(n+=o.quantity,{...o,cumulative:n,depth:0})),i=s[s.length-1]?.cumulative??1;for(let o of s)o.depth=o.cumulative/i;return s}function Ws({marketTicker:e,maxLevels:t=10,refetchInterval:r=5e3,outcome:n="yes"}){let{data:s,isLoading:i,isFetching:o}=Ae(e,{refetchInterval:r||void 0}),l=react.useMemo(()=>n==="yes"?s?.yesBids:s?.noBids,[s,n]),a=react.useMemo(()=>n==="yes"?s?.yesAsks:s?.noAsks,[s,n]),d=react.useMemo(()=>Fs(l,t),[l,t]),u=react.useMemo(()=>Fs(a,t),[a,t]),c=react.useMemo(()=>d.length===0||u.length===0?null:u[0].price-d[0].price,[d,u]),p=react.useMemo(()=>d.length===0||u.length===0?null:(d[0].price+u[0].price)/2,[d,u]),m=react.useMemo(()=>c===null||p===null||p===0?null:Math.round(c/p*1e4)/100,[c,p]);return {bids:d,asks:u,spread:c,spreadPercent:m,midpoint:p,isLoading:i,isFetching:o}}function qs({row:e,side:t,onClick:r}){let n=t==="bid",s=n?"bg-primary/10":"bg-danger/10",i=n?"text-primary":"text-danger";return jsxRuntime.jsxs("button",{type:"button",className:"relative flex w-full items-center justify-between px-3 py-1 text-xs hover:bg-default-100 cursor-pointer",onClick:()=>r?.(e.price),children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 ${n?"right-0":"left-0"} ${s}`,style:{width:`${e.depth*100}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 font-medium ${i}`,children:[e.price,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-default-600",children:e.quantity}),jsxRuntime.jsx("span",{className:"relative z-10 text-default-400",children:e.cumulative})]})}function Hs(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-1 py-2",children:Array.from({length:5}).map((e,t)=>jsxRuntime.jsx("div",{className:"mx-3 h-4 animate-pulse rounded bg-default-100"},t))})}function Ks({bids:e,asks:t,spread:r,spreadPercent:n,isLoading:s,onPriceClick:i}){let{t:o}=i18n.useTranslation();if(s)return jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:o("predict.orderBook.title")}),jsxRuntime.jsx(Hs,{}),jsxRuntime.jsx(Hs,{})]});let l=e.length===0&&t.length===0;return jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-default-200 px-3 py-2",children:jsxRuntime.jsx("span",{className:"text-sm font-medium",children:o("predict.orderBook.title")})}),l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-3 py-1 text-xxs text-default-400",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{children:o("predict.orderBook.qty")}),jsxRuntime.jsx("span",{children:o("predict.orderBook.total")})]}),jsxRuntime.jsx("div",{className:"flex flex-col-reverse",children:t.map(a=>jsxRuntime.jsx(qs,{row:a,side:"ask",onClick:i},a.price))}),r!==null&&jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 border-y border-default-200 py-1.5 text-xs text-default-500",children:[jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),": ",r,"\xA2"]}),n!==null&&jsxRuntime.jsxs("span",{className:"text-default-400",children:["(",n,"%)"]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map(a=>jsxRuntime.jsx(qs,{row:a,side:"bid",onClick:i},a.price))})]})]})}function c0({marketTicker:e,maxLevels:t,refetchInterval:r,onPriceClick:n,outcome:s}){let{bids:i,asks:o,spread:l,spreadPercent:a,isLoading:d}=Ws({marketTicker:e,maxLevels:t,refetchInterval:r,outcome:s});return jsxRuntime.jsx(Ks,{bids:i,asks:o,spread:l,spreadPercent:a,isLoading:d,onPriceClick:n})}function zs(e={}){let[t,r]=react.useState(null),[n]=react.useState(null),s=react.useCallback(i=>{r(null);},[]);return {orders:[],isLoading:false,isFetching:false,cancellingOrderId:t,cancelOrder:s,cancelError:n}}function Ad(e){return new Date(e).toLocaleString("default",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Gs({orders:e,isLoading:t,cancellingOrderId:r,onCancel:n}){let{t:s}=i18n.useTranslation(),i=react.useMemo(()=>e.map(o=>({key:o.id,side:o.side,outcome:o.outcome,type:o.type,price:o.price,filled:`${o.filledQuantity}/${o.quantity}`,status:o.status,createdAt:Ad(o.createdAt),isCancelling:o.id===r,id:o.id})),[e,r]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:s("predict.openOrders.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((o,l)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},l))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsxs("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:[s("predict.openOrders.title"),e.length>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-default-400",children:["(",e.length,")"]})]}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:s("predict.openOrders.empty")}):jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(ui$1.StyledTable,{radius:"none","aria-label":"Open orders",className:"min-w-[600px]",children:[jsxRuntime.jsxs(ui$1.TableHeader,{children:[jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Side",width:60,children:s("predict.openOrders.side")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Outcome",width:60,children:s("predict.openOrders.outcome")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Type",width:60,children:s("predict.openOrders.type")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Price",width:60,children:s("predict.openOrders.price")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Filled",width:80,children:s("predict.openOrders.filled")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Status",width:70,children:s("predict.openOrders.status")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Time",width:120,children:s("predict.openOrders.time")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Action",width:80,align:"end",children:" "})]}),jsxRuntime.jsx(ui$1.TableBody,{children:i.map(o=>jsxRuntime.jsxs(ui$1.TableRow,{children:[jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${o.side==="buy"?"text-primary":"text-danger"}`,children:o.side==="buy"?s("predict.trade.buy"):s("predict.trade.sell")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs ${o.outcome==="yes"?"text-primary":"text-secondary"}`,children:o.outcome==="yes"?s("predict.trade.yes"):s("predict.trade.no")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs capitalize",children:o.type})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.price,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:o.filled})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs capitalize",children:o.status})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:o.createdAt})}),jsxRuntime.jsx(ui$1.TableCell,{className:"text-right",children:jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"flat",color:"danger",isLoading:o.isCancelling,onPress:()=>n(o.id),children:s("predict.openOrders.cancel")})})]},o.key))})]})})]})}function E0({refetchInterval:e}={}){let{orders:t,isLoading:r,cancellingOrderId:n,cancelOrder:s}=zs({});return jsxRuntime.jsx(Gs,{orders:t,isLoading:r,cancellingOrderId:n,onCancel:s})}function Xs({ticker:e,pageSize:t=48}={}){let[r,n]=react.useState(1),[s,i]=react.useState([void 0]),o=s[r-1],l=react.useMemo(()=>({...e?{ticker:e}:{},limit:t,...o?{cursor:o}:{}}),[e,t,o]),{data:a,isLoading:d,isFetching:u}=Wr(l),c=a,p=c?.trades??[],m=!!c?.cursor,f=r>1,y=react.useCallback(h=>{h>=1&&h<=s.length&&n(h);},[s.length]),x=react.useCallback(()=>{m&&c?.cursor&&(i(h=>{let k=[...h];return k.length===r&&k.push(c.cursor),k}),n(h=>h+1));},[m,c?.cursor,r]),g=react.useCallback(()=>{f&&n(h=>h-1);},[f]);return {trades:p,isLoading:d,isFetching:u,page:r,pageSize:t,hasNextPage:m,hasPrevPage:f,goToPage:y,nextPage:x,prevPage:g}}function Xd(e){return new Date(e*1e3).toLocaleString("default",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Zs({trades:e,isLoading:t,isFetching:r,page:n,hasNextPage:s,hasPrevPage:i,onNextPage:o,onPrevPage:l}){let{t:a}=i18n.useTranslation(),d=react.useMemo(()=>e.map(u=>({key:u.tradeId,ticker:u.ticker,takerSide:u.takerSide,price:u.price,yesPrice:u.yesPrice,noPrice:u.noPrice,count:u.count,createdAt:Xd(u.createdTime)})),[e]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:a("predict.tradeHistory.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((u,c)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},c))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:a("predict.tradeHistory.title")}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:a("predict.tradeHistory.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:`w-full overflow-x-auto ${r?"opacity-60":""}`,children:jsxRuntime.jsxs(ui$1.StyledTable,{radius:"none","aria-label":"Trade history",className:"min-w-[480px]",children:[jsxRuntime.jsxs(ui$1.TableHeader,{children:[jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Side",width:60,children:a("predict.tradeHistory.side")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Price",width:80,children:a("predict.tradeHistory.price")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Yes",width:60,children:a("predict.trade.yes")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"No",width:60,children:a("predict.trade.no")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Qty",width:60,children:a("predict.tradeHistory.qty")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Time",width:120,children:a("predict.tradeHistory.time")})]}),jsxRuntime.jsx(ui$1.TableBody,{children:d.map(u=>jsxRuntime.jsxs(ui$1.TableRow,{children:[jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${u.takerSide==="yes"?"text-primary":"text-secondary"}`,children:u.takerSide==="yes"?a("predict.trade.yes"):a("predict.trade.no")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[u.price,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs text-primary",children:[u.yesPrice,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs text-secondary",children:[u.noPrice,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:u.count})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:u.createdAt})})]},u.key))})]})}),(i||s)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-default-200 px-3 py-2",children:[jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"flat",isDisabled:!i,onPress:l,startContent:jsxRuntime.jsx(ui$1.ChevronLeftIcon,{className:"h-3 w-3"}),children:a("predict.pagination.prev")}),jsxRuntime.jsx("span",{className:"text-xs text-default-500",children:a("predict.pagination.page",{page:n})}),jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"flat",isDisabled:!s,onPress:o,endContent:jsxRuntime.jsx(ui$1.ChevronRightIcon,{className:"h-3 w-3"}),children:a("predict.pagination.next")})]})]})]})}function q0({ticker:e,pageSize:t}={}){let{trades:r,isLoading:n,isFetching:s,page:i,hasNextPage:o,hasPrevPage:l,nextPage:a,prevPage:d}=Xs({ticker:e,pageSize:t});return jsxRuntime.jsx(Zs,{trades:r,isLoading:n,isFetching:s,page:i,hasNextPage:o,hasPrevPage:l,onNextPage:a,onPrevPage:d})}function Js(e={}){let t=react.useMemo(()=>({totalValue:0,totalUnrealizedPnl:0,totalRealizedPnl:0,count:0}),[]);return {positions:[],isLoading:false,isFetching:false,summary:t}}var Rt=e=>utils.formatAmountUSDCompact(e/100);function wr({value:e}){if(e===0)return jsxRuntime.jsx("span",{className:"text-default-500",children:Rt(0)});let t=e>0;return jsxRuntime.jsxs("span",{className:t?"text-success":"text-danger",children:[t?"+":"",Rt(e)]})}function eo({positions:e,isLoading:t,summary:r,onSell:n}){let{t:s}=i18n.useTranslation(),i=react.useMemo(()=>e.map(o=>({key:`${o.marketId}-${o.outcome}`,marketTitle:o.marketTitle,outcome:o.outcome,quantity:o.quantity,avgCost:o.avgCostBasis,currentPrice:o.currentPrice,value:o.currentPrice*o.quantity,unrealizedPnl:o.unrealizedPnl,position:o})),[e]);return t?jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"border-b border-default-200 px-3 py-2 text-sm font-medium",children:s("predict.positions.title")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 p-3",children:Array.from({length:3}).map((o,l)=>jsxRuntime.jsx("div",{className:"h-8 animate-pulse rounded bg-default-100"},l))})]}):jsxRuntime.jsxs("div",{className:"flex w-full flex-col rounded-xl border border-default-200 bg-content1",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between border-b border-default-200 px-3 py-2",children:jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[s("predict.positions.title"),e.length>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-default-400",children:["(",e.length,")"]})]})}),e.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-xs text-default-400",children:s("predict.positions.empty")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-full overflow-x-auto",children:jsxRuntime.jsxs(ui$1.StyledTable,{radius:"none","aria-label":"Positions",className:"min-w-[640px]",children:[jsxRuntime.jsxs(ui$1.TableHeader,{children:[jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Market",width:200,children:s("predict.positions.market")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Outcome",width:60,children:s("predict.positions.outcome")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Qty",width:50,children:s("predict.positions.qty")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Avg Cost",width:70,children:s("predict.positions.avgCost")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Price",width:60,children:s("predict.positions.currentPrice")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"Value",width:80,children:s("predict.positions.value")}),jsxRuntime.jsx(ui$1.TableColumn,{textValue:"PnL",width:80,children:s("predict.positions.pnl")})]}),jsxRuntime.jsx(ui$1.TableBody,{children:i.map(o=>jsxRuntime.jsxs(ui$1.TableRow,{className:n?"cursor-pointer hover:bg-default-50":"",onClick:()=>n?.(o.position),children:[jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs font-medium line-clamp-1",children:o.marketTitle})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:`text-xs font-medium ${o.outcome==="yes"?"text-primary":"text-secondary"}`,children:o.outcome==="yes"?s("predict.trade.yes"):s("predict.trade.no")})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:o.quantity})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.avgCost,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsxs("span",{className:"text-xs",children:[o.currentPrice,"\xA2"]})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:Rt(o.value)})}),jsxRuntime.jsx(ui$1.TableCell,{children:jsxRuntime.jsx("span",{className:"text-xs",children:jsxRuntime.jsx(wr,{value:o.unrealizedPnl})})})]},o.key))})]})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-default-200 px-3 py-2 text-xs",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-4",children:jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.totalValue"),":"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:Rt(r.totalValue)})]})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-4",children:[jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.unrealizedPnl"),":"," ",jsxRuntime.jsx(wr,{value:r.totalUnrealizedPnl})]}),jsxRuntime.jsxs("span",{className:"text-default-500",children:[s("predict.positions.realizedPnl"),":"," ",jsxRuntime.jsx(wr,{value:r.totalRealizedPnl})]})]})]})]})]})}function iP({refetchInterval:e,onSell:t}={}){let{positions:r,isLoading:n,summary:s}=Js({});return jsxRuntime.jsx(eo,{positions:r,isLoading:n,summary:s,onSell:t})}var dp=10,pp=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Ot(){let[e,t]=jotai.useAtom(pp),r=react.useCallback(s=>{let i=s.trim();i&&t(o=>{let l=o.filter(a=>a!==i);return [i,...l].slice(0,dp)});},[t]),n=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function so({histories:e,onSelect:t,onClear:r,className:n}){let{t:s}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui$1.cn("px-4 pb-4",n),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:s("predict.search.history")}),jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui$1.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsxRuntime.jsx(ui$1.Chip,{size:"sm",variant:"bordered",className:ui$1.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function oo({onSelect:e,className:t}){let{histories:r,clearHistories:n}=Ot();return jsxRuntime.jsx(so,{className:ui$1.cn(t),histories:r,onSelect:e,onClear:n})}function io({value:e,onValueChange:t,onClear:r,onEscape:n,className:s}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:s,children:jsxRuntime.jsx(ui$1.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui$1.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui$1.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:o=>{o.preventDefault(),n?.();},children:"Esc"})})})}function co({event:e,href:t,LinkComponent:r,onSelect:n,onHover:s,className:i}){let o=e.tags?.[0];return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:r,className:ui$1.cn("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:l=>{t&&n&&l.preventDefault(),n?.(e);},onMouseEnter:()=>s?.(e),children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),o&&jsxRuntime.jsx("span",{className:ui$1.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:o.label})]})]})}function uo({keyword:e,limit:t,source:r}){let{data:n,isLoading:s,isFetchingNextPage:i,hasNextPage:o,fetchNextPage:l}=_r({keyword:e,limit:t,source:r},{enabled:!!e});return {events:react.useMemo(()=>n?.pages.flatMap(d=>d.items).filter(d=>d!=null)??[],[n]),isLoading:s,isFetchingNextPage:i,hasNextPage:o??false,fetchNextPage:l}}var Bp=56;function yo({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:s,...i}){let{events:o,isLoading:l,isFetchingNextPage:a,hasNextPage:d,fetchNextPage:u}=uo(i),c=react.useRef(null),{height:p}=hooks.useResizeObserver({ref:c}),m=react.useCallback(g=>g<o.length,[o]),f=react.useCallback(async()=>{d&&!a&&await u();},[d,a,u]),y=react.useMemo(()=>d?o.length+1:o.length,[o,d]),x=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:f,rowCount:y,threshold:5});return l?jsxRuntime.jsx(Up,{className:s}):o.length===0?jsxRuntime.jsx(_p,{className:s}):jsxRuntime.jsx("div",{className:ui$1.cn("w-full h-full flex flex-col",s),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:c,children:jsxRuntime.jsx(reactWindow.List,{style:{height:p},onRowsRendered:x,rowComponent:Qp,rowCount:y,rowHeight:Bp,rowProps:{events:o,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function Qp({index:e,style:t,events:r,onSelect:n,getEventHref:s,LinkComponent:i,onHover:o}){let l=r[e];return l?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(co,{event:l,href:s?.(l),LinkComponent:i,onSelect:n,onHover:o})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})})}function Up({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui$1.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function _p({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui$1.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function ho({onKeywordChange:e}){let[t,r]=react.useState(""),[n,s]=react.useState(""),{addHistory:i}=Ot(),o=hooks.useCallbackRef(e),l=hooks.useCallbackRef(i),a=react.useMemo(()=>utils.debounce(p=>{s(p),o(p),p&&l(p);},500),[o,l]),d=react.useCallback(p=>{r(p),a(p);},[a]),u=react.useCallback(p=>{a.cancel(),r(p),s(p),o(p),p&&l(p);},[a,o,l]),c=react.useCallback(()=>u(""),[u]);return {text:t,keyword:n,setText:d,setKeyword:u,clearKeyword:c}}function bo({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:s,onEscape:i,source:o}){let{text:l,keyword:a,setText:d,setKeyword:u,clearKeyword:c}=ho({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(io,{value:l,onValueChange:d,onClear:c,onEscape:i}),a?jsxRuntime.jsx(yo,{className:"flex-auto min-h-0",keyword:a,onSelect:t,getEventHref:r,LinkComponent:n,onHover:s,source:o}):jsxRuntime.jsxs("div",{className:"flex-auto min-h-0 flex flex-col",children:[jsxRuntime.jsx(oo,{onSelect:u}),jsxRuntime.jsx(Wp,{})]})]})}function Wp(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex-auto min-h-0 flex flex-col items-center justify-start text-neutral pt-20",children:[jsxRuntime.jsx(ui$1.SearchIcon,{width:32,height:32,className:"opacity-40"}),jsxRuntime.jsx("p",{className:"mt-3 text-sm",children:e("predict.search.hint")})]})}var Or="predict-search";function vS({id:e=Or}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Zp,{...t})})}function Zp({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:s}=i18n.useTranslation(),{isMobile:i}=ui$1.useScreen(),o=react.useCallback(a=>{n(a);},[n]),l=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui$1.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui$1.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:s("predict.search.title")}),jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui$1.ModalBody,{className:"p-4",children:jsxRuntime.jsx(bo,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:o,onEscape:l})})]})})}function wS({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=i18n.useTranslation(),{isDesktop:s,isMobile:i}=ui$1.useScreen(),{onOpen:o,onClose:l}=uiScaffold.useAsyncModal(Or),a=hooks.useCallbackRef(e),d=hooks.useCallbackRef(async()=>{let c=await o({params:t});c&&a(c);}),u=hooks.useCallbackRef(()=>{l();});return react.useEffect(()=>{let c=p=>{let m=document.activeElement,f=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!f&&(p.preventDefault(),d()),p.key==="Escape"&&(p.preventDefault(),u());};return window.addEventListener("keydown",c),()=>{window.removeEventListener("keydown",c);}},[d,u]),jsxRuntime.jsx(ui$1.Button,{size:"sm",radius:"full",isIconOnly:!s,onPress:d,variant:i?"flat":"bordered",startContent:s?jsxRuntime.jsx(ui$1.SearchIcon,{className:"text-neutral"}):void 0,endContent:s?jsxRuntime.jsx(ui$1.Kbd,{className:"min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui$1.cn(s&&"pl-3 pr-1.5 text-neutral",r),children:s?n("predict.search.placeholder"):jsxRuntime.jsx(ui$1.SearchIcon,{className:"text-neutral"})})}function JS({client:e,wsClient:t=null,children:r}){let n=react.useMemo(()=>({client:e,wsClient:t}),[e,t]);return jsxRuntime.jsx(Ve.Provider,{value:n,children:r})}var cm=3e4;function oC({walletAddress:e,pollingInterval:t=cm,enabled:r=true,children:n}){let{data:s,isLoading:i,error:o,refetch:l}=Yr({walletAddress:e},{enabled:r&&!!e,refetchInterval:t}),a=react.useMemo(()=>({positions:s?.positions??[],usdcBalance:s?.usdcBalance??0,isLoading:i,error:o??null,refetch:l}),[s?.positions,s?.usdcBalance,i,o,l]);return jsxRuntime.jsx(ke.Provider,{value:a,children:n})}function uC({client:e,children:t}){let r=react.useMemo(()=>({client:e}),[e]);return jsxRuntime.jsx(pt.Provider,{value:r,children:t})}function Co(e,t){let r=new URLSearchParams;t&&r.set("provider",t);for(let[s,i]of Object.entries(e))i!=null&&(typeof i=="object"?r.set(s,JSON.stringify(i)):r.set(s,String(i)));let n=r.toString();return n?`?${n}`:""}function Eo(e){return e}var ot=class{constructor(t,r){this.endpoint=t;this.provider=r;}buildUrl(t,r){let n=Co(r??{},this.provider);return `${this.endpoint}${t}${n}`}async fetch(t,r){let n=this.buildUrl(t,r);return await utils.httpGet(n)}async postRequest(t,r,n){let s=this.buildUrl(t,n);return await utils.httpPost(s,r)}};function Lt(e,t){if(!e)return [];let r=Object.entries(e).map(([n,s])=>({price:parseFloat(n),quantity:s}));return r.sort((n,s)=>t==="desc"?s.price-n.price:n.price-s.price),r}function wo(e){return {yesBids:Lt(e.yes_bids,"desc"),yesAsks:Lt(e.yes_asks,"asc"),noBids:Lt(e.no_bids,"desc"),noAsks:Lt(e.no_asks,"asc"),sequence:e.sequence}}var Bt=class extends ot{constructor(t){super(t,"dflow");}async getEvents(t){return await this.fetch("/v2/event",t??{})}async getEventById(t,r){return await this.fetch(`/v2/event/${t}`,{withNestedMarkets:r})}async getEventCandlesticks(t,r){return await this.fetch(`/v2/event/${t}/candlesticks`,r)}async getEventForecastPercentileHistory(t){let{seriesTicker:r,eventId:n,...s}=t;return await this.fetch(`/v2/event/${r}/${n}/forecast_percentile_history`,s)}async getEventForecastPercentileHistoryByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/event/by-mint/${r}/forecast_percentile_history`,n)}async getMarkets(t){return await this.fetch("/v2/market",t??{})}async getMarketById(t){return await this.fetch(`/v2/market/${t}`)}async getMarketByMint(t){return await this.fetch(`/v2/market/by-mint/${t}`)}async getMarketsBatch(t){return await this.postRequest("/v2/market/batch",t)}async getMarketCandlesticks(t,r){return await this.fetch(`/v2/market/${t}/candlesticks`,r)}async getMarketCandlesticksByMint(t,r){return await this.fetch(`/v2/market/by-mint/${t}/candlesticks`,r)}async getOrderbook(t){let r=await this.fetch(`/v2/orderbook/${t}`);return wo(r)}async getOrderbookByMint(t){let r=await this.fetch(`/v2/orderbook/by-mint/${t}`);return wo(r)}async getTrades(t){return await this.fetch("/v2/trades",t??{})}async getTradesByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/trades/by-mint/${r}`,n)}async getOnchainTradesByWallet(t){let{walletAddress:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-wallet/${r}`,n)}async getOnchainTradesByEvent(t){let{eventTicker:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-event/${r}`,n)}async getOnchainTradesByMarket(t){let{marketTicker:r,...n}=t;return await this.fetch(`/v2/trades/onchain/by-market/${r}`,n)}async getLiveData(t){return await this.fetch("/v2/live",{milestoneIds:t.milestoneIds.join(",")})}async getLiveDataByEvent(t){let{eventTicker:r,...n}=t;return await this.fetch(`/v2/live/event/${r}`,n)}async getLiveDataByMint(t){let{mintAddress:r,...n}=t;return await this.fetch(`/v2/live/by-mint/${r}`,n)}async getSeries(t){return await this.fetch("/v2/series",t??{})}async getSeriesByTicker(t){return await this.fetch(`/v2/series/${t}`)}async getTagsByCategories(){return await this.fetch("/v2/tags/by_categories")}async getFiltersBySports(){return await this.fetch("/v2/sports/filters")}async search(t){return await this.fetch("/v2/search",t)}async getPositionsByWallet(t){let{walletAddress:r}=t;return await this.fetch(`/v2/positions/by-wallet/${r}`)}async getOutcomeMints(t){return await this.fetch("/v2/outcome_mints",t??{})}async filterOutcomeMints(t){return await this.postRequest("/v2/filter_outcome_mints",t)}async getQuote(t){return await this.fetch("/v2/swap/quote",t)}async createSwap(t){return await this.postRequest("/v2/swap",t)}async createSwapInstructions(t){return await this.postRequest("/v2/swap/instructions",t)}async getOrder(t){return await this.fetch("/v2/order",t)}async getOrderStatus(t){try{return await this.fetch("/v2/order/status",t)}catch(r){if(r instanceof Error&&/\b404\b/.test(r.message))return {status:"pending",inAmount:"0",outAmount:"0"};throw r}}async getIntentQuote(t){return await this.fetch("/v2/intent/quote",t)}async submitIntentSwap(t){return await this.postRequest("/v2/intent/swap",t)}async initPredictionMarket(t){return await this.fetch("/v2/prediction-market/init",t)}async getTokens(){return await this.fetch("/v2/tokens")}async getTokensWithDecimals(){return await this.fetch("/v2/tokens/decimals")}async getVenues(){return await this.fetch("/v2/venues")}};function ym(e){let t=new URLSearchParams;for(let[n,s]of Object.entries(e))s!=null&&t.set(n,String(s));let r=t.toString();return r?`?${r}`:""}var it=class{constructor(t){this.endpoint=t;}async listEvents(t){let r=ym(t??{}),n=`${this.endpoint}/api/v1/events${r}`;return await utils.httpGet(n)}async getEvent(t){let r=`${this.endpoint}/api/v1/events/${encodeURIComponent(t)}`;return await utils.httpGet(r)}};function Mo(e){return new it(e)}
|
|
2
2
|
exports.BasePredictClient=ot;exports.CATEGORIES_V2=rr;exports.CHART_RANGE_DURATION=kt;exports.CHART_RANGE_PERIOD=ht;exports.CHART_RANGE_SAMPLE_INTERVAL=bt;exports.CandlestickPeriod=xt;exports.CategoriesSkeleton=yn;exports.CategoriesUI=vt;exports.CategoriesWidget=hn;exports.CategoriesWidgetV2=Ln;exports.ChartRange=w;exports.DEFAULT_CHART_RANGE=Se;exports.DEFAULT_FILTER_STATE=nr;exports.DEFAULT_PAGE_SIZE=se;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Qv;exports.DflowPredictClient=Bt;exports.DflowPredictWsClient=Ge;exports.EventDetailPage=Fk;exports.EventDetailSkeleton=et;exports.EventDetailUI=Vs;exports.EventDetailWidget=Sr;exports.EventItemSkeleton=el;exports.EventItemUI=Cn;exports.EventItemV2UI=Hn;exports.EventMarketDetailWidget=Ts;exports.EventsFilterV2UI=Bn;exports.EventsPage=vx;exports.EventsPageV2=ph;exports.EventsSkeleton=Pt;exports.EventsToolbarV2UI=Vn;exports.EventsUI=Tn;exports.EventsV2UI=zn;exports.EventsWidget=Nn;exports.EventsWidgetV2=Yn;exports.MAX_PRICE_HISTORY_MARKETS=Pe;exports.ORDER_MAX_PRICE=Bv;exports.ORDER_MIN_PRICE=Lv;exports.ORDER_MIN_QUANTITY=Zt;exports.ORDER_PRICE_STEP=Iv;exports.OpenOrdersUI=Gs;exports.OpenOrdersWidget=E0;exports.OrderBookUI=Ks;exports.OrderBookWidget=c0;exports.PREDICT_SEARCH_MODAL_ID=Or;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Uv;exports.PositionsUI=eo;exports.PositionsWidget=iP;exports.PredictClient=Bt;exports.PredictClientV2=it;exports.PredictContext=Ve;exports.PredictProvider=JS;exports.PredictSearchModal=vS;exports.PredictV2Context=pt;exports.PredictV2Provider=uC;exports.PredictWsClient=Ge;exports.PriceHistoryInterval=De;exports.SORT_PRESETS=_n;exports.SearchEventsButton=wS;exports.SearchHistoryUI=so;exports.SearchHistoryWidget=oo;exports.SearchInputUI=io;exports.SearchResultItemUI=co;exports.SearchResultListWidget=yo;exports.SearchWidget=bo;exports.TradeFormSkeleton=ss;exports.TradeFormUI=ns;exports.TradeFormWidget=dr;exports.TradeHistoryUI=Zs;exports.TradeHistoryWidget=q0;exports.UserPredictContext=ke;exports.UserPredictProvider=oC;exports.buildQuery=Co;exports.countActiveFilters=sr;exports.createDflowPredictWsClient=ft;exports.createPredictClientV2=Mo;exports.createPredictWsClient=ft;exports.createSwap=ba;exports.createSwapInstructions=ka;exports.eventByIdQueryKey=ai;exports.eventCandlesticksQueryKey=Qi;exports.eventV2QueryKey=Go;exports.eventsInfiniteQueryKey=oi;exports.eventsQueryKey=ni;exports.eventsV2QueryKey=Ko;exports.fetchEventById=li;exports.fetchEventCandlesticks=Ui;exports.fetchEventV2=Yo;exports.fetchEvents=At;exports.fetchEventsV2=$o;exports.fetchFiltersBySports=ra;exports.fetchForecastPercentileHistory=Di;exports.fetchForecastPercentileHistoryByMint=Wi;exports.fetchIntentQuote=Na;exports.fetchLiveData=Hi;exports.fetchLiveDataByEvent=$i;exports.fetchLiveDataByMint=Gi;exports.fetchMarketById=fi;exports.fetchMarketByMint=vi;exports.fetchMarketCandlesticks=Gt;exports.fetchMarketCandlesticksByMint=Vi;exports.fetchMarkets=di;exports.fetchMarketsBatch=bi;exports.fetchOnchainTradesByEvent=Wt;exports.fetchOnchainTradesByMarket=qt;exports.fetchOnchainTradesByWallet=Ft;exports.fetchOrder=Sa;exports.fetchOrderBook=Pi;exports.fetchOrderBookByMint=Ci;exports.fetchOrderStatus=Ea;exports.fetchOutcomeMints=ya;exports.fetchPositionsByWallet=la;exports.fetchQuote=ha;exports.fetchSearch=oa;exports.fetchSeries=Xi;exports.fetchSeriesByTicker=Zi;exports.fetchTagsByCategories=ea;exports.fetchTokens=Ba;exports.fetchTokensWithDecimals=Ua;exports.fetchTrades=wi;exports.fetchTradesByMint=Mi;exports.fetchVenues=Aa;exports.filterOutcomeMints=ga;exports.filtersBySportsQueryKey=ta;exports.forecastPercentileHistoryByMintQueryKey=Fi;exports.forecastPercentileHistoryQueryKey=Ai;exports.initPredictionMarket=Ia;exports.intentQuoteQueryKey=Ma;exports.liveDataByEventQueryKey=Ki;exports.liveDataByMintQueryKey=zi;exports.liveDataQueryKey=qi;exports.marketByIdQueryKey=mi;exports.marketByMintQueryKey=gi;exports.marketCandlesticksByMintQueryKey=_i;exports.marketCandlesticksQueryKey=zt;exports.marketsBatchQueryKey=hi;exports.marketsQueryKey=ui;exports.onchainTradesByEventInfiniteQueryKey=Li;exports.onchainTradesByEventQueryKey=Ri;exports.onchainTradesByMarketInfiniteQueryKey=Bi;exports.onchainTradesByMarketQueryKey=Oi;exports.onchainTradesByWalletInfiniteQueryKey=Ii;exports.onchainTradesByWalletQueryKey=Ni;exports.orderBookByMintQueryKey=Si;exports.orderBookQueryKey=ki;exports.orderQueryKey=Pa;exports.orderStatusQueryKey=Ca;exports.outcomeMintsQueryKey=fa;exports.positionsByWalletQueryKey=aa;exports.quoteQueryKey=xa;exports.searchQueryKey=sa;exports.seriesByTickerQueryKey=ji;exports.seriesQueryKey=Yi;exports.submitIntentSwap=Ra;exports.tagsByCategoriesQueryKey=Ji;exports.toRecord=Eo;exports.tokensQueryKey=La;exports.tokensWithDecimalsQueryKey=Qa;exports.tradesByMintQueryKey=Ti;exports.tradesQueryKey=Ei;exports.useCategoriesQuery=by;exports.useCreateSwapInstructionsMutation=Gy;exports.useCreateSwapMutation=zy;exports.useEventByIdQuery=mt;exports.useEventCandlesticksQuery=Jf;exports.useEventDetail=os;exports.useEventV2Query=Im;exports.useEvents=bn;exports.useEventsCategories=pn;exports.useEventsInfiniteQuery=Ar;exports.useEventsQuery=of;exports.useEventsV2=Fn;exports.useEventsV2Query=Mm;exports.useFilterOutcomeMintsMutation=Ay;exports.useFiltersBySportsQuery=hy;exports.useForecastPercentileHistoryByMintQuery=iy;exports.useForecastPercentileHistoryQuery=oy;exports.useInitPredictionMarketMutation=ig;exports.useIntentQuoteQuery=tg;exports.useLiveDataByEventQuery=dy;exports.useLiveDataByMintQuery=py;exports.useLiveDataQuery=uy;exports.useMarketByIdQuery=kf;exports.useMarketByMintQuery=Ef;exports.useMarketCandlesticksByMintQuery=ey;exports.useMarketCandlesticksQuery=Yt;exports.useMarketPositions=Xr;exports.useMarketsBatchQuery=Nf;exports.useMarketsQuery=vf;exports.useOnchainTradesByEventInfiniteQuery=Gf;exports.useOnchainTradesByEventQuery=Ff;exports.useOnchainTradesByMarketInfiniteQuery=Yf;exports.useOnchainTradesByMarketQuery=Wf;exports.useOnchainTradesByWalletInfiniteQuery=zf;exports.useOnchainTradesByWalletQuery=qr;exports.useOpenOrders=zs;exports.useOrderBook=Ws;exports.useOrderBookByMintQuery=Lf;exports.useOrderBookQuery=Ae;exports.useOrderQuery=Jr;exports.useOrderStatusQuery=en;exports.useOrderbookSubscription=Bg;exports.useOutcomeMintsQuery=Vy;exports.usePositions=Js;exports.usePositionsByWalletQuery=Yr;exports.usePredictClient=b;exports.usePredictContext=Vr;exports.usePredictSearchHistory=Ot;exports.usePredictV2Client=be;exports.usePredictV2Context=Ur;exports.usePriceHistoryQuery=ty;exports.usePricesSubscription=Mg;exports.useQuoteQuery=qy;exports.useSearchEventsInfiniteQuery=_r;exports.useSearchQuery=Cy;exports.useSearchResultListScript=uo;exports.useSearchScript=ho;exports.useSeriesByTickerQuery=zr;exports.useSeriesQuery=$r;exports.useSubmitIntentSwapMutation=rg;exports.useTagsByCategoriesQuery=jt;exports.useTokensQuery=ug;exports.useTokensWithDecimalsQuery=dg;exports.useTradeForm=Jn;exports.useTradeHistory=Xs;exports.useTradesByMintQuery=_f;exports.useTradesQuery=Wr;exports.useTradesSubscription=Og;exports.useUserPredictContext=Oy;exports.useVenuesQuery=yg;exports.useWsClient=Eg;exports.useWsConnection=kg;exports.venuesQueryKey=Va;exports.version=Fo;//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|