@liberfi.io/ui-predict 4.0.73 → 4.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- 'use strict';var react=require('react'),ui$1=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),xa=require('canvas-confetti'),reactQuery=require('@tanstack/react-query'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),search=require('@liberfi.io/ui/search');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var xa__default=/*#__PURE__*/_interopDefault(xa);var vd={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},ts=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],oo=(()=>{let e=t=>{let r=ts.indexOf(t);return r===-1?ts.length:r};return Object.entries(vd).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 pa({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:a,trailing:i,pulsingTab:s="Trending",className:l}){let{t:u}=i18n.useTranslation(),p=react.useCallback(()=>{o(null);},[o]),c=u("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui$1.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsxRuntime.jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxRuntime.jsxs("div",{className:"cat-primary-row",children:[jsxRuntime.jsx("div",{className:"cat-tabs hideScrollbar",children:jsxRuntime.jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsxRuntime.jsx(rs,{label:c,isSelected:t===null,onPress:p,showPulse:c===s}),jsxRuntime.jsx(Sd,{}),e.map(f=>{let d=f.slug??f.category,m=f.label??f.category;return jsxRuntime.jsx(rs,{label:m,isSelected:t===d,onPress:()=>o(d),badge:f.badge,showPulse:d===s||m===s},d)})]})}),i&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:i})]}),t&&n.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(ns,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>a(null)}),n.map(f=>{let d=f.slug??f.label;return jsxRuntime.jsx(ns,{label:f.label,icon:f.icon,isSelected:r===d,onPress:()=>a(d)},d)})]})})]})}function rs({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui$1.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,n&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:n})]})}function Sd(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function ns({label:e,icon:t,isSelected:r,onPress:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:n,className:ui$1.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui$1.cn("iconify size-4",t)}),e]})}function Pd({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsxRuntime.jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function as(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Nd(e){return `predict.categories.category.${as(e)}`}function is(e){return `predict.categories.tag.${as(e)}`}function Md(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Nd(r.slug),r.label),tags:r.tags.map(n=>({slug:n.slug,label:t(is(n.slug),n.label),icon:n.icon}))}))}function Ed(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(is(r.slug),r.label),icon:r.icon})):[]}function fa({onSelect:e,trailing:t,className:r}){let{t:n}=i18n.useTranslation(),o=react.useCallback((m,v)=>{let g=n(m);return typeof g=="string"&&g!==m?g:v},[n]),[a,i]=react.useState(null),[s,l]=react.useState(null),u=react.useCallback(m=>{i(m),l(null),e?.({categorySlug:m,tagSlug:null});},[e]),p=react.useCallback(m=>{l(m),e?.({categorySlug:a,tagSlug:m});},[a,e]),c=Md(oo,o),f=oo.find(m=>m.slug===a),d=Ed(f,o);return jsxRuntime.jsx(pa,{categories:c,selectedCategory:a,selectedTag:s,activeTags:d,onCategorySelect:u,onTagSelect:p,trailing:t,className:r})}function io(e,t){return e?.trim()||t}function Kr(e){return io(e.title_trans,e.title)??e.title}function ga(e){return io(e.question_trans,e.question)??e.question}function ha(e){return io(e.description_trans,e.description)}function so(e){return io(e.label_trans,e.label)??e.label}function lr(e){let t=e.outcomes?.[0];return t?so(t):ga(e)}function lo(e){return {title:Kr(e),imageUrl:e.image_url}}function co(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:ga(e),yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?so(r):lr(e),noSubTitle:n?so(n):"No"}}var jr=24,uo=4,Vr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},W={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_MONTH:"1m",ALL:"all"},vn=W.ALL,Td={[W.ONE_HOUR]:Vr.ONE_MINUTE,[W.SIX_HOURS]:Vr.ONE_MINUTE,[W.ONE_DAY]:Vr.ONE_MINUTE,[W.ONE_MONTH]:Vr.ONE_MINUTE,[W.ALL]:Vr.ONE_MINUTE},Rd={[W.ONE_HOUR]:60,[W.SIX_HOURS]:60,[W.ONE_DAY]:300,[W.ONE_MONTH]:900,[W.ALL]:900},ba={[W.ONE_HOUR]:3600,[W.SIX_HOURS]:360*60,[W.ONE_DAY]:1440*60,[W.ONE_MONTH]:720*60*60,[W.ALL]:null},Ld={[W.ONE_HOUR]:1,[W.SIX_HOURS]:1,[W.ONE_DAY]:5,[W.ONE_MONTH]:15,[W.ALL]:15},xn=1,yn=1,_d=1,Od=1,Id=99,Sr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Dd=Sr.ONE_WEEK,Ad={[Sr.ONE_HOUR]:60,[Sr.SIX_HOURS]:60,[Sr.ONE_DAY]:300,[Sr.ONE_WEEK]:1800,[Sr.MAX]:1800};var cs=react.createContext(null);function cr(){let e=react.useContext(cs);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var zd=1e4;function ds({pollingInterval:e=zd,enabled:t=true,enableKalshi:r=true,children:n}){let o=walletConnector.useWallets(),a=react.useMemo(()=>o.find(M=>M.chainNamespace===types.ChainNamespace.SOLANA&&M.isConnected)?.address,[o]),i=react.useMemo(()=>o.find(M=>M.chainNamespace===types.ChainNamespace.EVM&&M.isConnected)?.address,[o]),{data:s,isLoading:l,isFetching:u,error:p}=reactPredict.useBalance({source:"kalshi",user:a??""},{enabled:t&&r&&!!a,refetchInterval:e}),{data:c,isLoading:f}=reactPredict.useDFlowKYC(a,{enabled:t&&r&&!!a,refetchInterval:3e4}),{data:d,isLoading:m}=reactPredict.usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),v=d?.safe_address,k=d?.verified??false,g=d?.wallet_kind??"deposit",S=d?.deposit_wallet_address,h=g==="safe"?d?.safe_address:S,x=g==="safe"?d?.safe_deployed??false:d?.deposit_wallet_deployed??false,{data:b,isLoading:y,isFetching:P,error:N}=reactPredict.useBalance({source:"polymarket",user:i??""},{enabled:t&&k&&!!i,refetchInterval:e}),w=react.useMemo(()=>({enableKalshi:r,solanaAddress:a,evmAddress:i,polymarketWalletKind:g,polymarketWalletAddress:h,polymarketDepositWalletAddress:S,polymarketWalletDeployed:x,polymarketSafeAddress:v,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:k&&b?Number(b.balance):null,kalshiKycVerified:c?.verified??false,kalshiKycUrl:c?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:k,polymarketSafeDeployed:d?.safe_deployed??false,polymarketTokenApproved:d?.token_approved??false,polymarketSetupLoading:m,isLoading:l||y,isFetching:u||P,error:p??N??null}),[r,a,i,g,h,S,x,v,s,b,k,c,f,d,m,l,y,u,P,p,N]);return jsxRuntime.jsx(cs.Provider,{value:w,children:n})}var Kd={minutes:60,hours:3600,days:86400};function kn(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*Kd[r]}}function Sn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function xe(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function us(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var ps=100,ms=300;function ya(e,t){return ps/1e4+Math.max(0,e)/1e4*us(t)}function Vd(e,t){let r=e?.[t],n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:void 0}function jd(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function ka(e){let t=Vd(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],n=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(n)&&n>=0?n*1e4:jd(e,"polymarket.sportsMarketType")?ms:0}function Sa({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:n=0,pricePerShare:o}){if(t==null||!Number.isFinite(t))return 0;let a=xe(Math.max(0,t),2);if(e!=="polymarket")return a;let i=ya(n,o??NaN),s=a/(1+i)-r;return xe(Math.max(0,s),2)}function Pa({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=ya(r,t);return e*n}function wa({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=ya(r,t);return e*n}function Pn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let i=parseInt(o[1],10)/1e6,s=parseInt(o[2],10)/1e6,l=Math.max(0,i-s);return t("predict.trade.polymarket.insufficientBalance",{total:xe(i,2).toFixed(2),active:xe(s,2).toFixed(2),available:xe(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Pr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function Na(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};xa__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{xa__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{xa__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var fs={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function Gd(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function Ma(e,t,r){let n=e(t);return n&&n!==t?n:r}function Gr(e,t){let r=Gd(t)?fs.zh:fs.en;return {submitted:Ma(e,"predict.trade.resultSubmitted",r.submitted),completed:Ma(e,"predict.trade.resultCompleted",r.completed),delayed:Ma(e,"predict.trade.resultDelayed",r.delayed)}}function Xd({deadlineAt:e}){let[t,r]=react.useState(()=>Math.max(0,e-Date.now()));return react.useEffect(()=>{let n=setInterval(()=>{r(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(n)},[e]),`${Math.max(0,Math.ceil(t/1e3))}s`}function wr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:n}){return {id:e,submitted:()=>{let o=Date.now()+t;ui$1.toast.progress({id:e,message:n.submitted,duration:t,progress:true,action:react.createElement(Xd,{deadlineAt:o})});},completed:()=>{ui$1.toast.update(e,{type:"success",message:n.completed,duration:5e3}),r&&Na();},delayed:()=>{ui$1.toast.update(e,{type:"blank",message:n.delayed,duration:8e3});},failed:o=>{ui$1.toast.update(e,{type:"error",message:o,duration:8e3});}}}function Ca({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o,i18n:a}=i18n.useTranslation(),{status:i}=walletConnector.useAuth(),s=walletConnector.useWallets(),l=reactPredict.usePredictClient(),u=react.useContext(reactPredict.PolymarketContext),{start:p}=reactPredict.useTradeResultConfirmation(),c=e.source,f=c==="polymarket",d=s.find(D=>D.chainNamespace===types.ChainNamespace.SOLANA&&D.isConnected),m=s.find(D=>D.chainNamespace===types.ChainNamespace.EVM&&D.isConnected&&"switchChain"in D),v=i==="authenticated",k=d?.address,g=m?.address,[S,h]=react.useState(t),[x,b]=react.useState("market"),[y,P]=react.useState(NaN),[N,w]=react.useState(NaN),[M,L]=react.useState(false),[A,X]=react.useState(null),[_,U]=react.useState(false),[q,ee]=react.useState(false),[Y,re]=react.useState("1h"),[oe,ie]=react.useState(30),[he,Pe]=react.useState("minutes"),dt=react.useMemo(()=>Gr(o,a),[a,o]),He=true,Ve=react.useCallback(async(D,Ae)=>{let Re=wr({celebrateOnCompleted:true,messages:dt});Re.submitted(),await p({source:c,user:c==="kalshi"?k:g,kalshiUser:He?k:void 0,polymarketUser:g,marketSlug:e.slug,eventSlug:e.event_slug,expectation:D,getOrdersHeaders:Ae})==="confirmed"?Re.completed():Re.delayed();},[p,He,g,e.event_slug,e.slug,c,dt,k]),E=react.useMemo(()=>{if(c!=="polymarket")return;let D=e.provider_meta?.["polymarket.clobTokenIds"];return D?(typeof D=="string"?JSON.parse(D):D)[S==="yes"?0:1]:void 0},[c,e.provider_meta,S]),{data:at,isLoading:Oe}=reactPredict.useTickSize(E),be=reactPredict.normalizePolymarketTickSize(at?.minimum_tick_size),{data:gt,isLoading:we}=reactPredict.useFeeRate(E),Ue=gt?.base_fee??0,C=String(Ue),T=react.useMemo(()=>ka(e.provider_meta),[e.provider_meta]),{data:$}=reactPredict.useRebateConfig(),Z=$?.builder_enabled&&$.builder_code?$.builder_code:void 0,ue=null,Me=false,it=null,Rt=false,st,yt,Qe;try{let D=cr();He=D.enableKalshi,ue={kalshiUsdcBalance:D.kalshiUsdcBalance,polymarketUsdcBalance:D.polymarketUsdcBalance,isLoading:D.isLoading},Me=D.kalshiKycVerified,it=D.kalshiKycUrl,Rt=D.polymarketSetupVerified,st=D.polymarketSafeAddress,yt=D.polymarketWalletKind,Qe=D.polymarketWalletAddress;}catch{}let Yt=c==="kalshi"&&!Me,We=c==="polymarket"&&!Rt,{data:et}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:c,outcome:S},{enabled:e.status==="open"}),ve=react.useMemo(()=>{let D=reactPredict.pickBestAsk(et,S);if(D!=null&&D>0)return D;let Ae=S==="yes"?0:1,Re=e.outcomes[Ae];return Re?.best_ask??Re?.price??.5},[et,e.outcomes,S]),ut=react.useCallback(D=>{b(D);},[]),kt=react.useCallback(D=>{h(D),w(NaN);},[]);react.useEffect(()=>{kt(t);},[t,kt]),react.useEffect(()=>{x==="limit"&&isNaN(N)&&w(Math.round(ve*1e4)/1e4);},[x,N,ve]);let Ne=react.useMemo(()=>x==="limit"&&f&&!isNaN(N)?N:ve,[x,f,N,ve]),tt=react.useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne:0,[y,Ne]),Te=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:et,outcome:S,side:"buy",sharesNeeded:tt,slippageBps:r}),[et,S,tt,r]),Lt=react.useMemo(()=>Te.status==="ok"&&Te.worstPrice!=null&&Te.worstPrice>0?Te.worstPrice:ve,[Te,ve]),I=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),Ie=e.provider_meta?.["dflow.yesMint"]??"",Xe=e.provider_meta?.["dflow.noMint"]??"",pn=utils.SOLANA_TOKENS.stablecoins.USDC.address,B=S==="yes"?Ie:Xe,De=pn,St=B,Ft=c==="kalshi"?k??"":g??"",{data:mn,isLoading:na}=reactPredict.usePositionsMulti({kalshi_user:c==="kalshi"?Ft:void 0,polymarket_user:c==="polymarket"?Ft:void 0},{enabled:!!Ft}),oa=c==="kalshi"&&!!De&&!!St&&!!k&&I!=="0",{refetch:qt}=reactPredict.useDFlowQuote({inputMint:De,outputMint:St,amount:I,userPublicKey:k??"",slippageBps:100},{enabled:oa}),Ir=react.useMemo(()=>ue?c==="kalshi"?ue.kalshiUsdcBalance:ue.polymarketUsdcBalance:mn&&mn.positions.reduce((Ae,Re)=>Re.side==="USDC"||Re.side==="collateral"?Ae+(Re.current_value??0):Ae,0)||null,[ue,mn,c]),aa=ue?ue.isLoading:na,pt=react.useMemo(()=>Sa({source:c,usdcBalance:Ir,feeRateBps:T,pricePerShare:Ne}),[c,Ir,T,Ne]),_t=Ir==null?null:pt,Dr=react.useMemo(()=>isNaN(y)||y<=0?0:y,[y]),fn=react.useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne*1:0,[y,Ne]),Ar=react.useMemo(()=>c!=="polymarket"||isNaN(y)||y<=0?0:Pa({usdcAmount:y,pricePerShare:Ne,feeRateBps:T}),[c,y,Ne,T]),ir=fn-Dr-Ar,ia=react.useCallback(D=>{if(isNaN(D)){P(NaN);return}P(Math.round(Math.max(0,D)*100)/100);},[]),Jn=react.useCallback(D=>{if(isNaN(D)){w(NaN);return}w(Math.round(D*1e4)/1e4);},[]),Fr=react.useCallback(()=>{P(NaN),w(NaN),b("market"),ee(false),re("1h"),ie(30),Pe("minutes");},[]),Qt=react.useMemo(()=>{let D=[];return isNaN(y)||y<=0?D.push(o("predict.trade.minAmountUsd",{amount:yn})):y<yn&&D.push(o("predict.trade.minAmountUsd",{amount:yn})),e.status!=="open"&&D.push(o("predict.trade.marketNotActive")),_t!=null&&!isNaN(y)&&y>0&&y>_t&&D.push(o("predict.trade.insufficientBalance")),x==="limit"&&f&&(isNaN(N)||N<.01||N>.99)&&D.push(o("predict.trade.limitPriceRange")),x==="limit"&&f&&q&&Y==="custom"&&(isNaN(oe)||oe<=0)&&D.push(o("predict.trade.expiration.invalidDate")),c==="polymarket"&&x==="market"&&!isNaN(y)&&y>0&&tt>0&&(Te.status==="insufficient_liquidity"?D.push(o("predict.trade.insufficientLiquidity",{available:xe(Te.totalAvailable,2)})):Te.status==="exceeds_slippage"&&D.push(o("predict.trade.priceImpactTooHigh",{impact:(Te.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:D.length===0,errors:D}},[y,e.status,_t,x,f,N,q,Y,oe,c,tt,Te,r,o]),hr=react.useMemo(()=>_t==null||isNaN(y)||y<=0?false:y>_t,[_t,y]),br=react.useCallback(()=>{n?.(c);},[n,c]),{mutateAsync:vr}=reactPredict.useDFlowSubmit(),{data:gn}=reactPredict.useOrder({id:A??"",source:c},{enabled:!!A});react.useEffect(()=>{if(!gn||!A)return;let{status:D}=gn;D==="closed"?(X(null),L(false),Ve("buy-market"),Fr()):(D==="failed"||D==="expired")&&(L(false),X(null),ui$1.toast.error(o("predict.trade.submitError")));},[Ve,gn,A,Fr,o]);let hn=react.useCallback(async()=>{if(!k||!d)return;if(!De||!St){ui$1.toast.error("Missing token mint addresses"),L(false);return}if(!Me){U(true),L(false);return}let It=(await qt()).data?.transaction;if(!It){ui$1.toast.error(o("predict.trade.submitError")),L(false);return}let bn=Uint8Array.from(atob(It),mt=>mt.charCodeAt(0)),Xt=await d.signTransaction(bn),Jt=await vr({signedTransaction:btoa(String.fromCharCode(...Xt)),orderContext:{user_public_key:k,input_mint:De,output_mint:St,amount:I,price:String(ve),side:"BUY",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});X(Jt.signature);},[k,d,qt,vr,De,St,I,ve,S,e.slug,o,Me]),Br=react.useCallback(async()=>{if(!m||!u)return;let D=m.chain,Ae=D!==types.Chain.POLYGON;Ae&&await m.switchChain(types.Chain.POLYGON);try{let Re=await m.getEip1193Provider();if(!Re){ui$1.toast.error(o("predict.trade.submitError")),L(!1);return}let It=yt==="deposit"&&!!Qe,bn=!It&&!!st,Xt=It?Qe:st,Jt={address:m.address,signatureType:It?3:bn?2:0,signTypedData:async(Dt,R,Le,_e)=>{let ze=[];"name"in Dt&&ze.push({name:"name",type:"string"}),"version"in Dt&&ze.push({name:"version",type:"string"}),"chainId"in Dt&&ze.push({name:"chainId",type:"uint256"}),"verifyingContract"in Dt&&ze.push({name:"verifyingContract",type:"address"}),"salt"in Dt&&ze.push({name:"salt",type:"bytes32"});let ht={EIP712Domain:ze,...R};return await Re.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Dt,types:ht,primaryType:Le,message:_e})]})}},mt=u.credentials??await u.authenticate(Jt),sa=S==="yes"?0:1,Zn="",Ut=e.provider_meta?.["polymarket.clobTokenIds"];Ut&&(Zn=(typeof Ut=="string"?JSON.parse(Ut):Ut)[sa]??"");let Hr=e.provider_meta?.["polymarket.negRisk"]??!1,Ur=x==="limit"&&!isNaN(N)?N:Lt,xr=Sn(Ur,be),eo=x==="limit"?q?"GTD":"GTC":"FOK",yr=x==="market"?y:xr>0?y/xr:0,Wr={tokenId:Zn,price:xr,size:yr,side:"BUY",orderType:eo,tickSize:be,negRisk:Hr,...Xt&&{funderAddress:Xt},...Z&&{builderCode:Z},...x==="limit"&&q&&{expiration:kn(Y,oe,he)}},zr;if(It)zr=await reactPredict.buildSignedV2OrderPayload({signer:Jt,depositWalletAddress:Xt,input:Wr,owner:mt.apiKey});else {let Dt=reactPredict.buildCtfExchangeDomain(Hr),R=reactPredict.buildOrderMessage({...Wr,signerAddress:Jt.address,signatureType:Jt.signatureType,feeRateBps:C}),Le=await Jt.signTypedData(Dt,reactPredict.CTF_ORDER_TYPES,"Order",R),_e=reactPredict.buildSignedOrder(R,Le,Wr.orderType);zr=reactPredict.buildClobPayload(_e,mt.apiKey);}await l.executePolymarketOrder({payload:zr,l2_api_key:mt.apiKey,l2_secret:mt.secret,l2_passphrase:mt.passphrase,signer_address:mt.address,owner:mt.apiKey}),Ve(x==="limit"?"buy-limit":"buy-market",async()=>await reactPredict.buildPolymarketL2Headers(mt.address,{apiKey:mt.apiKey,secret:mt.secret,passphrase:mt.passphrase,method:"GET",requestPath:"/data/orders"})),Fr(),L(!1);}finally{Ae&&D&&m.switchChain(D).catch(()=>{});}},[m,u,S,e.provider_meta,x,Ve,N,Lt,y,l,q,Y,oe,he,Fr,o,be,C,st,yt,Qe,Z]),Ot=react.useCallback(async()=>{if(!(!Qt.isValid||!v)){L(true),X(null),U(false);try{c==="kalshi"?await hn():await Br();}catch(D){let Ae=D instanceof Error?D.message:"",Re=c==="polymarket"&&Ae?Pn(Ae,o,"buy"):Ae||void 0;ui$1.toast.error(Re||o("predict.trade.submitError")),L(false);}}},[Qt.isValid,v,c,hn,Br,o]);return {outcome:S,orderType:x,quantity:y,limitPrice:N,shares:tt,effectivePrice:Ne,estimatedCost:Dr,estimatedFee:Ar,potentialPayout:fn,potentialProfit:ir,pricePerShare:ve,usdcBalance:Ir,maxBuyAmount:pt,spendableUsdcBalance:_t,isBalanceLoading:aa,isMarketDataLoading:c==="polymarket"&&(we||Oe),isSubmitting:M,authStatus:i,validation:Qt,isInsufficientBalance:hr,source:c,supportsLimitOrder:f,kycRequired:_,needsKyc:Yt,needsSetup:We,kycUrl:it,expirationEnabled:q,expirationPreset:Y,customDuration:oe,customDurationUnit:he,setOutcome:kt,setOrderType:ut,setQuantity:ia,setLimitPrice:Jn,setExpirationEnabled:ee,setExpirationPreset:re,setCustomDuration:ie,setCustomDurationUnit:Pe,submit:Ot,notifyInsufficientBalance:br}}function Nn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=i18n.useTranslation();return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui$1.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),jsxRuntime.jsx("span",{children:n(o)})]},o))}),r&&jsxRuntime.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsxRuntime.jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Au=["5m","1h","12h","24h","eod","custom"],Fu={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},Bu=["minutes","hours","days"],Hu={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Uu={maximumFractionDigits:0},dr="-";function La({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:a,limitPrice:i,shares:s,effectivePrice:l,potentialProfit:u,potentialPayout:p,estimatedCost:c,estimatedFee:f=0,usdcBalance:d,isBalanceLoading:m,isMarketDataLoading:v,isSubmitting:k,authStatus:g,isValid:S,validationErrors:h,isInsufficientBalance:x,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:P,kycRequired:N,needsKyc:w,needsSetup:M,kycUrl:L,expirationEnabled:A,expirationPreset:X,customDuration:_,customDurationUnit:U,oddsFormatter:q,outcomeLabels:ee,onOutcomeChange:Y,onOrderTypeChange:re,onQuantityChange:oe,onLimitPriceChange:ie,onExpirationEnabledChange:he,onExpirationPresetChange:Pe,onCustomDurationChange:dt,onCustomDurationUnitChange:He,onSubmit:Ve}){let{t:E}=i18n.useTranslation(),[at,Oe]=react.useState(true),be=ui$1.useDisclosure(),[gt,we]=react.useState(""),Ue=react.useRef(false);react.useEffect(()=>{Ue.current||we(isNaN(a)?"":String(a));},[a]);let[C,T]=react.useState(""),$=react.useRef(false);react.useEffect(()=>{$.current||(isNaN(i)?T(""):T(String(parseFloat((i*100).toFixed(2)))));},[i]);let Z=react.useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(T(B),B===""||B==="."){ie(NaN);return}let St=parseFloat(B);isNaN(St)||ie(St/100);},[ie]),ue=react.useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(we(B),Xe(false),B===""||B==="."){oe(NaN);return}let St=parseFloat(B);isNaN(St)||oe(St);},[oe]);react.useEffect(()=>{N&&!be.isOpen&&be.onOpen();},[N,be]);let Me=react.useMemo(()=>{let B=n==="yes"?t.yesAsk:t.noAsk;return B!=null?parseFloat((Number(B)*100).toFixed(2)):null},[n,t]),it=n==="yes"?t.yesAsk:t.noAsk,Rt=it!=null&&q?q(Number(it)):Me!=null?`${Me} \xA2`:dr,st=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,yt=Number.isFinite(l)&&q?q(l):st!=null?`${st} \xA2`:dr,Qe=!isNaN(a)&&a>0,Yt=Qe?c+f:0,We=Qe&&s>0?Yt/s:0,et=We>0&&q?q(We):We>0?`${parseFloat((We*100).toFixed(2))}\xA2`:dr,ve=g==="authenticated",ut=g==="authenticating"||g==="deauthenticating",kt=ve&&(w||M),Ne=react.useCallback(B=>ee?.[B]??E(B==="yes"?"predict.trade.yes":"predict.trade.no"),[ee,E]),tt=react.useMemo(()=>{if(ut)return E("predict.trade.checkingLogin");if(!ve)return E("predict.trade.loginToTrade");if(w)return E("predict.trade.kycRequired");if(M)return E("predict.trade.setupRequired");if(m)return E("predict.trade.loadingBalance");if(v)return E("predict.trade.loadingMarketData");if(k)return E("predict.trade.submitting");if(N)return E("predict.trade.kycRequired");if(!Qe)return E("predict.trade.enterAmount");let B=Ne(n),De=u>0?` \u2192 Win $${u.toFixed(2)}`:"";return `${E("predict.trade.buy")} ${B}${De}`},[ut,ve,w,M,m,v,k,N,Qe,n,Ne,u,E]),Te="primary",Lt=()=>{let B=P??xe(d??0,2);oe(xe(B/2,2));},I=()=>{oe(P??xe(d??0,2));},[Ie,Xe]=react.useState(false),pn=()=>{if(!ve){Xe(false),Ve();return}if(w){be.onOpen();return}if(M&&b){Xe(false),b();return}if(N){be.onOpen();return}if(x&&b){Xe(false),b();return}if(!S){Xe(true);return}Xe(false),Ve();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},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.jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsxRuntime.jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxRuntime.jsxs("span",{className:"text-bullish",children:[E("predict.trade.buy")," ",Ne(n)]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[y?jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:B=>re(B),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:E("predict.trade.market")},"market"),jsxRuntime.jsx(ui$1.Tab,{title:E("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),o==="limit"&&y?jsxRuntime.jsx(ui$1.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:C,onChange:B=>Z(B.target.value),onFocus:()=>{$.current=true;},onBlur:()=>{$.current=false,isNaN(i)?T(""):T(String(parseFloat((i*100).toFixed(2))));},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Rt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:Rt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(B=>{let De=B==="yes"?t.yesAsk:t.noAsk;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>Y(B),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===B?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:Ne(B)}),De!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:q?q(Number(De)):`${parseFloat((Number(De)*100).toFixed(2))}\xA2`})]})},B)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:Lt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:E("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:I,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:E("predict.trade.max")})]})]}),jsxRuntime.jsx(ui$1.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:gt,onChange:B=>ue(B.target.value),onFocus:()=>{Ue.current=true;},onBlur:()=>{Ue.current=false,we(isNaN(a)?"":String(a));},startContent:jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Ie&&h.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:h.map(B=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:B},B))})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"text-neutral-500",children:E("predict.trade.balance")}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`$${xe(d,2).toFixed(2)}`:"$0"})]}),o==="limit"&&y&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:E("predict.trade.setExpiration")}),jsxRuntime.jsx(ui$1.StyledSwitch,{size:"sm",color:"primary",isSelected:A,onValueChange:he,"aria-label":E("predict.trade.setExpiration")})]}),A&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui$1.Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[X],onSelectionChange:B=>{let De=Array.from(B)[0];De&&Pe(De);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Au.map(B=>jsxRuntime.jsx(ui$1.SelectItem,{children:E(Fu[B])},B))}),X==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui$1.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(_)?void 0:_,onValueChange:dt,minValue:1,step:1,formatOptions:Uu,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsxRuntime.jsx(ui$1.Select,{"aria-label":"Duration unit",selectedKeys:[U],onSelectionChange:B=>{let De=Array.from(B)[0];De&&He(De);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Bu.map(B=>jsxRuntime.jsx(ui$1.SelectItem,{children:E(Hu[B])},B))})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Oe(B=>!B),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:E("predict.trade.odds")}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:ui$1.cn("h-3.5 w-3.5 transition-transform",at&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:q&&Number.isFinite(l)?yt:st!=null?E("predict.trade.chance",{percent:st}):dr})]}),at&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?`$${c.toFixed(2)}`:dr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?Pr(s):dr})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${f.toFixed(2)}`})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalPayment")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${Yt.toFixed(2)}`})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:et})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?`$${p.toFixed(2)}`:dr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(a)&&a>0&&u>0?`+$${u.toFixed(2)}`:dr})]})]})]}),jsxRuntime.jsx(ui$1.Button,{color:Te,fullWidth:true,radius:"lg",size:"lg",isDisabled:ut||ve&&!kt&&(m||v||!Qe||k),isLoading:ut||ve&&!kt&&(k||m||v),spinner:jsxRuntime.jsx(ui$1.Spinner,{size:"sm",color:"current"}),onPress:pn,children:tt})]}),jsxRuntime.jsx(Nn,{isOpen:be.isOpen,onClose:be.onClose,kycUrl:L})]})}function Mn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:a,onInsufficientBalance:i,onOutcomeChange:s,oddsFormatter:l,outcomeLabels:u}){let{outcome:p,orderType:c,quantity:f,limitPrice:d,shares:m,effectivePrice:v,estimatedCost:k,estimatedFee:g,potentialPayout:S,potentialProfit:h,pricePerShare:x,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:P,isMarketDataLoading:N,isSubmitting:w,authStatus:M,validation:L,isInsufficientBalance:A,supportsLimitOrder:X,kycRequired:_,needsKyc:U,needsSetup:q,kycUrl:ee,expirationEnabled:Y,expirationPreset:re,customDuration:oe,customDurationUnit:ie,setOutcome:he,setOrderType:Pe,setQuantity:dt,setLimitPrice:He,setExpirationEnabled:Ve,setExpirationPreset:E,setCustomDuration:at,setCustomDurationUnit:Oe,submit:be,notifyInsufficientBalance:gt}=Ca({market:t,initialOutcome:n,slippageBps:a,onInsufficientBalance:i}),we=walletConnector.useAuthCallback(be),Ue=react.useCallback($=>{he($),s?.($);},[he,s]),C=react.useMemo(()=>e?lo(e):void 0,[e]),T=react.useMemo(()=>co(t,{yesAsk:p==="yes"?x:void 0,noAsk:p==="no"?x:void 0}),[t,p,x]);return jsxRuntime.jsx(La,{event:C,market:T,variant:r,outcome:p,orderType:c,quantity:f,limitPrice:d,shares:m,effectivePrice:v,estimatedCost:k,estimatedFee:g,potentialPayout:S,potentialProfit:h,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:P,isMarketDataLoading:N,isSubmitting:w,authStatus:M,isValid:L.isValid,validationErrors:L.errors,isInsufficientBalance:A,onInsufficientBalance:i?gt:void 0,supportsLimitOrder:X,kycRequired:_,needsKyc:U,needsSetup:q,kycUrl:ee,expirationEnabled:Y,expirationPreset:re,customDuration:oe,customDurationUnit:ie,oddsFormatter:l,outcomeLabels:u,onOutcomeChange:Ue,onOrderTypeChange:Pe,onQuantityChange:dt,onLimitPriceChange:He,onExpirationEnabledChange:Ve,onExpirationPresetChange:E,onCustomDurationChange:at,onCustomDurationUnitChange:Oe,onSubmit:we})}var qr="predict-trade";function En({id:e=qr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(qu,{...t})})}function qu({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui$1.useScreen();return e?jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui$1.ModalContent,{children:jsxRuntime.jsxs("div",{className:o?"":"p-2",children:[jsxRuntime.jsx(Mn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsxRuntime.jsx("div",{className:"px-4 pb-4",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var Xr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function bo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function _a({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:a}=i18n.useTranslation(),[i,s]=react.useState(r),l=react.useMemo(()=>o?Xr:{...Xr,source:"polymarket"},[o]),u=react.useCallback(S=>{S?s(r):t();},[r,t]),p=react.useCallback(()=>{s(l);},[l]),c=react.useCallback(()=>{n(i),t();},[i,n,t]),f=react.useCallback((S,h)=>{s(x=>({...x,[S]:h}));},[]),d=react.useMemo(()=>bo(i,o),[i,o]),m=react.useMemo(()=>[{value:void 0,label:a("predict.filter.all")},{value:"polymarket",label:a("predict.platform.polymarket")},{value:"kalshi",label:a("predict.platform.kalshi")}],[a]),v=react.useMemo(()=>[{value:void 0,label:a("predict.filter.all")},{value:"1d",label:a("predict.filter.lessThanDay")},{value:"7d",label:a("predict.filter.lessThanWeek")},{value:"30d",label:a("predict.filter.lessThanMonth")}],[a]),k=react.useMemo(()=>[{value:void 0,label:a("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[a]),g=react.useMemo(()=>[{value:void 0,label:a("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[a]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:e,onOpenChange:u,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui$1.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:a("predict.filter.title")}),jsxRuntime.jsx(tp,{onClick:()=>u(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsxRuntime.jsx(go,{label:a("predict.filter.platform"),children:jsxRuntime.jsx(ho,{options:m,selected:i.source,onSelect:S=>f("source",S)})}),jsxRuntime.jsx(go,{label:a("predict.filter.timeRemaining"),children:jsxRuntime.jsx(ho,{options:v,selected:i.timeRemaining,onSelect:S=>f("timeRemaining",S)})}),jsxRuntime.jsx(go,{label:a("predict.filter.minVolume"),children:jsxRuntime.jsx(ho,{options:k,selected:i.minVolume,onSelect:S=>f("minVolume",S)})}),jsxRuntime.jsx(go,{label:a("predict.filter.minLiquidity"),children:jsxRuntime.jsx(ho,{options:g,selected:i.minLiquidity,onSelect:S=>f("minLiquidity",S)})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsxRuntime.jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:p,children:a("predict.filter.reset")}),jsxRuntime.jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[a("predict.filter.showResults"),d>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function go({label:e,children:t}){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function tp({onClick:e}){return jsxRuntime.jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function ho({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let a=t===o.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(a&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:a?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:a?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:a?"#c7ff2e":"#a1a1aa"},onMouseEnter:i=>{a||(i.currentTarget.style.background="rgba(39,39,42,0.8)",i.currentTarget.style.color="#fff");},onMouseLeave:i=>{a||(i.currentTarget.style.background="rgba(39,39,42,0.4)",i.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var Oa={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Ms={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},dp=["start_time","volume","liquidity","ending_soon"],Es={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},up={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Ia({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:a=0,className:i}){let{t:s}=i18n.useTranslation(),[l,u]=react.useState(false),p=react.useRef(null),c=react.useCallback(d=>{p.current&&!p.current.contains(d.target)&&u(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),react.useEffect(()=>{if(!l)return;let d=m=>{m.key==="Escape"&&u(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let f=Cs[e];return jsxRuntime.jsxs("div",{className:i,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:p,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:Es,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(d=>!d),children:[jsxRuntime.jsx(pp,{}),jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(Ms[e])}),jsxRuntime.jsx(fp,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...up,width:224,padding:4},children:dp.map(d=>{let m=Cs[d],v=e===d;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:v?"rgba(199,255,46,0.08)":"transparent",color:v?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:k=>{v||(k.currentTarget.style.background="rgba(39,39,42,0.5)",k.currentTarget.style.color="#fff");},onMouseLeave:k=>{v||(k.currentTarget.style.background="transparent",k.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?n(!r):t(d),u(false);},children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:v?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:s(Ms[d])}),v&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})]}),jsxRuntime.jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:Es,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsxRuntime.jsx(mp,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s("predict.filter.title")})]}),a>0&&jsxRuntime.jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:a})]})]})}var Cs={start_time:ui$1.CalendarIcon,volume:ui$1.ChartLineIcon,liquidity:ui$1.DropletIcon,ending_soon:ui$1.TimerIcon};function pp(){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function mp(){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function fp({open:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function Da(e={}){let{i18n:t}=i18n.useTranslation(),{tagSlugSelection:r,limit:n,status:o,sort_by:a,sort_asc:i,source:s,with_markets:l,minVolume:u,minLiquidity:p,timeRemaining:c,markets_limit:f,lang:d}=e,m=d??t.resolvedLanguage??t.language,v=react.useMemo(()=>reactPredict.resolveEventsParams({tagSlugSelection:r,limit:n,status:o,sort_by:a,sort_asc:i,source:s,with_markets:l,minVolume:u,minLiquidity:p,timeRemaining:c,markets_limit:f,lang:m}),[m,n,f,p,u,i,a,s,o,r,c,l]),{data:k,isLoading:g,isFetching:S,isFetchingNextPage:h,isError:x,error:b,hasNextPage:y,fetchNextPage:P,refetch:N}=reactPredict.useInfiniteEvents(v),w=react.useMemo(()=>k?.pages.flatMap(A=>A.items).filter(A=>A!=null)??[],[k]),M=react.useCallback(()=>{P();},[P]),L=react.useCallback(()=>{N();},[N]);return {data:w,isLoading:g,isFetching:S&&!h,isFetchingMore:h,isError:x,error:b??null,hasMore:y??false,fetchMore:M,refetch:L}}var Ls=`
1
+ 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),yi=require('canvas-confetti'),reactQuery=require('@tanstack/react-query'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),search=require('@liberfi.io/ui/search');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var yi__default=/*#__PURE__*/_interopDefault(yi);var bd={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},ta=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],an=(()=>{let e=t=>{let r=ta.indexOf(t);return r===-1?ta.length:r};return Object.entries(bd).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function mi({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:p}=i18n.useTranslation(),d=react.useCallback(()=>{n(null);},[n]),c=p("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsxRuntime.jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxRuntime.jsxs("div",{className:"cat-primary-row",children:[jsxRuntime.jsx("div",{className:"cat-tabs hideScrollbar",children:jsxRuntime.jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsxRuntime.jsx(ra,{label:c,isSelected:t===null,onPress:d,showPulse:c===a}),jsxRuntime.jsx(Pd,{}),e.map(m=>{let u=m.slug??m.category,f=m.label??m.category;return jsxRuntime.jsx(ra,{label:f,isSelected:t===u,onPress:()=>n(u),badge:m.badge,showPulse:u===a||f===a},u)})]})}),s&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:s})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(oa,{label:p("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(m=>{let u=m.slug??m.label;return jsxRuntime.jsx(oa,{label:m.label,icon:m.icon,isSelected:r===u,onPress:()=>i(u)},u)})]})})]})}function ra({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-text-muted hover:text-text-secondary"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-text-inverse",children:o})]})}function Pd(){return jsxRuntime.jsx("span",{className:"flex items-center text-text-muted","aria-hidden":"true",children:"|"})}function oa({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-text-muted hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function Nd({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsxRuntime.jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function ia(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function wd(e){return `predict.categories.category.${ia(e)}`}function sa(e){return `predict.categories.tag.${ia(e)}`}function Ed(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(wd(r.slug),r.label),tags:r.tags.map(o=>({slug:o.slug,label:t(sa(o.slug),o.label),icon:o.icon}))}))}function Cd(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(sa(r.slug),r.label),icon:r.icon})):[]}function gi({onSelect:e,trailing:t,className:r}){let{t:o}=i18n.useTranslation(),n=react.useCallback((f,g)=>{let h=o(f);return typeof h=="string"&&h!==f?h:g},[o]),[i,s]=react.useState(null),[a,l]=react.useState(null),p=react.useCallback(f=>{s(f),l(null),e?.({categorySlug:f,tagSlug:null});},[e]),d=react.useCallback(f=>{l(f),e?.({categorySlug:i,tagSlug:f});},[i,e]),c=Ed(an,n),m=an.find(f=>f.slug===i),u=Cd(m,n);return jsxRuntime.jsx(mi,{categories:c,selectedCategory:i,selectedTag:a,activeTags:u,onCategorySelect:p,onTagSelect:d,trailing:t,className:r})}function cn(e,t){return e?.trim()||t}function Kr(e){return cn(e.title_trans,e.title)??e.title}function hi(e){return cn(e.question_trans,e.question)??e.question}function vi(e){return cn(e.description_trans,e.description)}function dn(e){return cn(e.label_trans,e.label)??e.label}function lr(e){let t=e.outcomes?.[0];return t?dn(t):hi(e)}function un(e){return {title:Kr(e),imageUrl:e.image_url}}function pn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:hi(e),yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??o?.best_ask??o?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??o?.best_bid,yesSubTitle:r?dn(r):lr(e),noSubTitle:o?dn(o):"No"}}var jr=24,mn=4,Vr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},$={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_MONTH:"1m",ALL:"all"},bo=$.ALL,Rd={[$.ONE_HOUR]:Vr.ONE_MINUTE,[$.SIX_HOURS]:Vr.ONE_MINUTE,[$.ONE_DAY]:Vr.ONE_MINUTE,[$.ONE_MONTH]:Vr.ONE_MINUTE,[$.ALL]:Vr.ONE_MINUTE},Ld={[$.ONE_HOUR]:60,[$.SIX_HOURS]:60,[$.ONE_DAY]:300,[$.ONE_MONTH]:900,[$.ALL]:900},xi={[$.ONE_HOUR]:3600,[$.SIX_HOURS]:360*60,[$.ONE_DAY]:1440*60,[$.ONE_MONTH]:720*60*60,[$.ALL]:null},Od={[$.ONE_HOUR]:1,[$.SIX_HOURS]:1,[$.ONE_DAY]:5,[$.ONE_MONTH]:15,[$.ALL]:15},yo=1,ko=1,_d=1,Id=1,Dd=99,Pr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Ad=Pr.ONE_WEEK,Fd={[Pr.ONE_HOUR]:60,[Pr.SIX_HOURS]:60,[Pr.ONE_DAY]:300,[Pr.ONE_WEEK]:1800,[Pr.MAX]:1800};var ca=react.createContext(null);function cr(){let e=react.useContext(ca);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var $d=1e4;function da({pollingInterval:e=$d,enabled:t=true,enableKalshi:r=true,children:o}){let n=walletConnector.useWallets(),i=react.useMemo(()=>n.find(w=>w.chainNamespace===types.ChainNamespace.SOLANA&&w.isConnected)?.address,[n]),s=react.useMemo(()=>n.find(w=>w.chainNamespace===types.ChainNamespace.EVM&&w.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:p,error:d}=reactPredict.useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:c,isLoading:m}=reactPredict.useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:u,isLoading:f}=reactPredict.usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=u?.safe_address,b=u?.verified??false,h=u?.wallet_kind??"deposit",S=u?.deposit_wallet_address,x=h==="safe"?u?.safe_address:S,y=h==="safe"?u?.safe_deployed??false:u?.deposit_wallet_deployed??false,{data:v,isLoading:k,isFetching:P,error:M}=reactPredict.useBalance({source:"polymarket",user:s??""},{enabled:t&&b&&!!s,refetchInterval:e}),N=react.useMemo(()=>({enableKalshi:r,solanaAddress:i,evmAddress:s,polymarketWalletKind:h,polymarketWalletAddress:x,polymarketDepositWalletAddress:S,polymarketWalletDeployed:y,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:b&&v?Number(v.balance):null,kalshiKycVerified:c?.verified??false,kalshiKycUrl:c?.kyc_url??null,kalshiKycLoading:m,polymarketSetupVerified:b,polymarketSafeDeployed:u?.safe_deployed??false,polymarketTokenApproved:u?.token_approved??false,polymarketSetupLoading:f,isLoading:l||k,isFetching:p||P,error:d??M??null}),[r,i,s,h,x,S,y,g,a,v,b,c,m,u,f,l,k,p,P,d,M]);return jsxRuntime.jsx(ca.Provider,{value:N,children:o})}var Vd={minutes:60,hours:3600,days:86400};function So(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*Vd[r]}}function Po(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function be(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function ua(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var pa=100,ma=300;function ki(e,t){return pa/1e4+Math.max(0,e)/1e4*ua(t)}function jd(e,t){let r=e?.[t],o=typeof r=="number"?r:Number(r);return Number.isFinite(o)?o:void 0}function Gd(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Si(e){let t=jd(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],o=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(o)&&o>=0?o*1e4:Gd(e,"polymarket.sportsMarketType")?ma:0}function Pi({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:o=0,pricePerShare:n}){if(t==null||!Number.isFinite(t))return 0;let i=be(Math.max(0,t),2);if(e!=="polymarket")return i;let s=ki(o,n??NaN),a=i/(1+s)-r;return be(Math.max(0,a),2)}function Ni({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let o=ki(r,t);return e*o}function Mi({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let o=ki(r,t);return e*o}function No(e,t,r){let o=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(o)return t("predict.trade.polymarket.minOrderSize",{current:o[1],min:o[2]});let n=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(n){let s=parseInt(n[1],10)/1e6,a=parseInt(n[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:be(s,2).toFixed(2),active:be(a,2).toFixed(2),available:be(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function Nr(e,t=2){return parseFloat(be(e,t).toFixed(t)).toString()}function wi(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};yi__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{yi__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{yi__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Gr(e,t){return {submitted:e("predict.trade.resultSubmitted"),completed:e("predict.trade.resultCompleted"),delayed:e("predict.trade.resultDelayed")}}function Xd({deadlineAt:e}){let[t,r]=react.useState(()=>Math.max(0,e-Date.now()));return react.useEffect(()=>{let o=setInterval(()=>{r(Math.max(0,e-Date.now()));},1e3);return ()=>clearInterval(o)},[e]),`${Math.max(0,Math.ceil(t/1e3))}s`}function Mr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:o}){return {id:e,submitted:()=>{let n=Date.now()+t;ui.toast.progress({id:e,message:o.submitted,duration:t,progress:true,action:react.createElement(Xd,{deadlineAt:n})});},completed:()=>{ui.toast.update(e,{type:"success",message:o.completed,duration:5e3}),r&&wi();},delayed:()=>{ui.toast.update(e,{type:"blank",message:o.delayed,duration:8e3});},failed:n=>{ui.toast.update(e,{type:"error",message:n,duration:8e3});}}}function Ci({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n,i18n:i}=i18n.useTranslation(),{status:s}=walletConnector.useAuth(),a=walletConnector.useWallets(),l=reactPredict.usePredictClient(),p=react.useContext(reactPredict.PolymarketContext),{start:d}=reactPredict.useTradeResultConfirmation(),c=e.source,m=c==="polymarket",u=a.find(D=>D.chainNamespace===types.ChainNamespace.SOLANA&&D.isConnected),f=a.find(D=>D.chainNamespace===types.ChainNamespace.EVM&&D.isConnected&&"switchChain"in D),g=s==="authenticated",b=u?.address,h=f?.address,[S,x]=react.useState(t),[y,v]=react.useState("market"),[k,P]=react.useState(NaN),[M,N]=react.useState(NaN),[w,R]=react.useState(false),[A,X]=react.useState(null),[L,G]=react.useState(false),[U,oe]=react.useState(false),[W,te]=react.useState("1h"),[ne,se]=react.useState(30),[he,Pe]=react.useState("minutes"),pt=react.useMemo(()=>Gr(n),[i,n]),Ve=true,Be=react.useCallback(async(D,De)=>{let Te=Mr({celebrateOnCompleted:true,messages:pt});Te.submitted(),await d({source:c,user:c==="kalshi"?b:h,kalshiUser:Ve?b:void 0,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:D,getOrdersHeaders:De})==="confirmed"?Te.completed():Te.delayed();},[d,Ve,h,e.event_slug,e.slug,c,pt,b]),E=react.useMemo(()=>{if(c!=="polymarket")return;let D=e.provider_meta?.["polymarket.clobTokenIds"];return D?(typeof D=="string"?JSON.parse(D):D)[S==="yes"?0:1]:void 0},[c,e.provider_meta,S]),{data:st,isLoading:He}=reactPredict.useTickSize(E),ve=reactPredict.normalizePolymarketTickSize(st?.minimum_tick_size),{data:at,isLoading:we}=reactPredict.useFeeRate(E),Ue=at?.base_fee??0,qe=String(Ue),C=react.useMemo(()=>Si(e.provider_meta),[e.provider_meta]),{data:O}=reactPredict.useRebateConfig(),z=O?.builder_enabled&&O.builder_code?O.builder_code:void 0,Z=null,me=false,Ne=null,lt=false,ct,kt,Qe;try{let D=cr();Ve=D.enableKalshi,Z={kalshiUsdcBalance:D.kalshiUsdcBalance,polymarketUsdcBalance:D.polymarketUsdcBalance,isLoading:D.isLoading},me=D.kalshiKycVerified,Ne=D.kalshiKycUrl,lt=D.polymarketSetupVerified,ct=D.polymarketSafeAddress,kt=D.polymarketWalletKind,Qe=D.polymarketWalletAddress;}catch{}let Yt=c==="kalshi"&&!me,We=c==="polymarket"&&!lt,{data:et}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:c,outcome:S},{enabled:e.status==="open"}),xe=react.useMemo(()=>{let D=reactPredict.pickBestAsk(et,S);if(D!=null&&D>0)return D;let De=S==="yes"?0:1,Te=e.outcomes[De];return Te?.best_ask??Te?.price??.5},[et,e.outcomes,S]),mt=react.useCallback(D=>{v(D);},[]),St=react.useCallback(D=>{x(D),N(NaN);},[]);react.useEffect(()=>{St(t);},[t,St]),react.useEffect(()=>{y==="limit"&&isNaN(M)&&N(Math.round(xe*1e4)/1e4);},[y,M,xe]);let Me=react.useMemo(()=>y==="limit"&&m&&!isNaN(M)?M:xe,[y,m,M,xe]),tt=react.useMemo(()=>isNaN(k)||k<=0?0:Me>0?k/Me:0,[k,Me]),Ce=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:et,outcome:S,side:"buy",sharesNeeded:tt,slippageBps:r}),[et,S,tt,r]),Lt=react.useMemo(()=>Ce.status==="ok"&&Ce.worstPrice!=null&&Ce.worstPrice>0?Ce.worstPrice:xe,[Ce,xe]),I=react.useMemo(()=>isNaN(k)||k<=0?"0":String(Math.round(k*1e6)),[k]),_e=e.provider_meta?.["dflow.yesMint"]??"",Xe=e.provider_meta?.["dflow.noMint"]??"",mo=utils.SOLANA_TOKENS.stablecoins.USDC.address,B=S==="yes"?_e:Xe,Ie=mo,Pt=B,Ft=c==="kalshi"?b??"":h??"",{data:fo,isLoading:ni}=reactPredict.usePositionsMulti({kalshi_user:c==="kalshi"?Ft:void 0,polymarket_user:c==="polymarket"?Ft:void 0},{enabled:!!Ft}),ii=c==="kalshi"&&!!Ie&&!!Pt&&!!b&&I!=="0",{refetch:qt}=reactPredict.useDFlowQuote({inputMint:Ie,outputMint:Pt,amount:I,userPublicKey:b??"",slippageBps:100},{enabled:ii}),Ir=react.useMemo(()=>Z?c==="kalshi"?Z.kalshiUsdcBalance:Z.polymarketUsdcBalance:fo&&fo.positions.reduce((De,Te)=>Te.side==="USDC"||Te.side==="collateral"?De+(Te.current_value??0):De,0)||null,[Z,fo,c]),si=Z?Z.isLoading:ni,ft=react.useMemo(()=>Pi({source:c,usdcBalance:Ir,feeRateBps:C,pricePerShare:Me}),[c,Ir,C,Me]),Ot=Ir==null?null:ft,Dr=react.useMemo(()=>isNaN(k)||k<=0?0:k,[k]),go=react.useMemo(()=>isNaN(k)||k<=0?0:Me>0?k/Me*1:0,[k,Me]),Ar=react.useMemo(()=>c!=="polymarket"||isNaN(k)||k<=0?0:Ni({usdcAmount:k,pricePerShare:Me,feeRateBps:C}),[c,k,Me,C]),sr=go-Dr-Ar,ai=react.useCallback(D=>{if(isNaN(D)){P(NaN);return}P(Math.round(Math.max(0,D)*100)/100);},[]),en=react.useCallback(D=>{if(isNaN(D)){N(NaN);return}N(Math.round(D*1e4)/1e4);},[]),Fr=react.useCallback(()=>{P(NaN),N(NaN),v("market"),oe(false),te("1h"),se(30),Pe("minutes");},[]),Qt=react.useMemo(()=>{let D=[];return isNaN(k)||k<=0?D.push(n("predict.trade.minAmountUsd",{amount:ko})):k<ko&&D.push(n("predict.trade.minAmountUsd",{amount:ko})),e.status!=="open"&&D.push(n("predict.trade.marketNotActive")),Ot!=null&&!isNaN(k)&&k>0&&k>Ot&&D.push(n("predict.trade.insufficientBalance")),y==="limit"&&m&&(isNaN(M)||M<.01||M>.99)&&D.push(n("predict.trade.limitPriceRange")),y==="limit"&&m&&U&&W==="custom"&&(isNaN(ne)||ne<=0)&&D.push(n("predict.trade.expiration.invalidDate")),c==="polymarket"&&y==="market"&&!isNaN(k)&&k>0&&tt>0&&(Ce.status==="insufficient_liquidity"?D.push(n("predict.trade.insufficientLiquidity",{available:be(Ce.totalAvailable,2)})):Ce.status==="exceeds_slippage"&&D.push(n("predict.trade.priceImpactTooHigh",{impact:(Ce.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:D.length===0,errors:D}},[k,e.status,Ot,y,m,M,U,W,ne,c,tt,Ce,r,n]),vr=react.useMemo(()=>Ot==null||isNaN(k)||k<=0?false:k>Ot,[Ot,k]),xr=react.useCallback(()=>{o?.(c);},[o,c]),{mutateAsync:br}=reactPredict.useDFlowSubmit(),{data:ho}=reactPredict.useOrder({id:A??"",source:c},{enabled:!!A});react.useEffect(()=>{if(!ho||!A)return;let{status:D}=ho;D==="closed"?(X(null),R(false),Be("buy-market"),Fr()):(D==="failed"||D==="expired")&&(R(false),X(null),ui.toast.error(n("predict.trade.submitError")));},[Be,ho,A,Fr,n]);let vo=react.useCallback(async()=>{if(!b||!u)return;if(!Ie||!Pt){ui.toast.error("Missing token mint addresses"),R(false);return}if(!me){G(true),R(false);return}let It=(await qt()).data?.transaction;if(!It){ui.toast.error(n("predict.trade.submitError")),R(false);return}let xo=Uint8Array.from(atob(It),gt=>gt.charCodeAt(0)),Xt=await u.signTransaction(xo),Jt=await br({signedTransaction:btoa(String.fromCharCode(...Xt)),orderContext:{user_public_key:b,input_mint:Ie,output_mint:Pt,amount:I,price:String(xe),side:"BUY",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});X(Jt.signature);},[b,u,qt,br,Ie,Pt,I,xe,S,e.slug,n,me]),Br=react.useCallback(async()=>{if(!f||!p)return;let D=f.chain,De=D!==types.Chain.POLYGON;De&&await f.switchChain(types.Chain.POLYGON);try{let Te=await f.getEip1193Provider();if(!Te){ui.toast.error(n("predict.trade.submitError")),R(!1);return}let It=kt==="deposit"&&!!Qe,xo=!It&&!!ct,Xt=It?Qe:ct,Jt={address:f.address,signatureType:It?3:xo?2:0,signTypedData:async(Dt,T,Re,Le)=>{let ze=[];"name"in Dt&&ze.push({name:"name",type:"string"}),"version"in Dt&&ze.push({name:"version",type:"string"}),"chainId"in Dt&&ze.push({name:"chainId",type:"uint256"}),"verifyingContract"in Dt&&ze.push({name:"verifyingContract",type:"address"}),"salt"in Dt&&ze.push({name:"salt",type:"bytes32"});let vt={EIP712Domain:ze,...T};return await Te.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Dt,types:vt,primaryType:Re,message:Le})]})}},gt=p.credentials??await p.authenticate(Jt),li=S==="yes"?0:1,tn="",Ut=e.provider_meta?.["polymarket.clobTokenIds"];Ut&&(tn=(typeof Ut=="string"?JSON.parse(Ut):Ut)[li]??"");let Hr=e.provider_meta?.["polymarket.negRisk"]??!1,Ur=y==="limit"&&!isNaN(M)?M:Lt,yr=Po(Ur,ve),rn=y==="limit"?U?"GTD":"GTC":"FOK",kr=y==="market"?k:yr>0?k/yr:0,Wr={tokenId:tn,price:yr,size:kr,side:"BUY",orderType:rn,tickSize:ve,negRisk:Hr,...Xt&&{funderAddress:Xt},...z&&{builderCode:z},...y==="limit"&&U&&{expiration:So(W,ne,he)}},zr;if(It)zr=await reactPredict.buildSignedV2OrderPayload({signer:Jt,depositWalletAddress:Xt,input:Wr,owner:gt.apiKey});else {let Dt=reactPredict.buildCtfExchangeDomain(Hr),T=reactPredict.buildOrderMessage({...Wr,signerAddress:Jt.address,signatureType:Jt.signatureType,feeRateBps:qe}),Re=await Jt.signTypedData(Dt,reactPredict.CTF_ORDER_TYPES,"Order",T),Le=reactPredict.buildSignedOrder(T,Re,Wr.orderType);zr=reactPredict.buildClobPayload(Le,gt.apiKey);}await l.executePolymarketOrder({payload:zr,l2_api_key:gt.apiKey,l2_secret:gt.secret,l2_passphrase:gt.passphrase,signer_address:gt.address,owner:gt.apiKey}),Be(y==="limit"?"buy-limit":"buy-market",async()=>await reactPredict.buildPolymarketL2Headers(gt.address,{apiKey:gt.apiKey,secret:gt.secret,passphrase:gt.passphrase,method:"GET",requestPath:"/data/orders"})),Fr(),R(!1);}finally{De&&D&&f.switchChain(D).catch(()=>{});}},[f,p,S,e.provider_meta,y,Be,M,Lt,k,l,U,W,ne,he,Fr,n,ve,qe,ct,kt,Qe,z]),_t=react.useCallback(async()=>{if(!(!Qt.isValid||!g)){R(true),X(null),G(false);try{c==="kalshi"?await vo():await Br();}catch(D){let De=D instanceof Error?D.message:"",Te=c==="polymarket"&&De?No(De,n,"buy"):De||void 0;ui.toast.error(Te||n("predict.trade.submitError")),R(false);}}},[Qt.isValid,g,c,vo,Br,n]);return {outcome:S,orderType:y,quantity:k,limitPrice:M,shares:tt,effectivePrice:Me,estimatedCost:Dr,estimatedFee:Ar,potentialPayout:go,potentialProfit:sr,pricePerShare:xe,usdcBalance:Ir,maxBuyAmount:ft,spendableUsdcBalance:Ot,isBalanceLoading:si,isMarketDataLoading:c==="polymarket"&&(we||He),isSubmitting:w,authStatus:s,validation:Qt,isInsufficientBalance:vr,source:c,supportsLimitOrder:m,kycRequired:L,needsKyc:Yt,needsSetup:We,kycUrl:Ne,expirationEnabled:U,expirationPreset:W,customDuration:ne,customDurationUnit:he,setOutcome:St,setOrderType:mt,setQuantity:ai,setLimitPrice:en,setExpirationEnabled:oe,setExpirationPreset:te,setCustomDuration:se,setCustomDurationUnit:Pe,submit:_t,notifyInsufficientBalance:xr}}function wo({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:ui.THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-text-primary",children:o("predict.trade.kycModalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-text-secondary mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-text-secondary",children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-brand-primary shrink-0",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),jsxRuntime.jsx("span",{children:o(n)})]},n))}),r&&jsxRuntime.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-brand-primary/70 hover:text-brand-primary transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsxRuntime.jsx("p",{className:"text-[11px] text-text-muted mb-5",children:o("predict.trade.kycModalNote")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var Fu=["5m","1h","12h","24h","eod","custom"],Bu={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},Hu=["minutes","hours","days"],Uu={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Wu={maximumFractionDigits:0},dr="-";function Li({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,effectivePrice:l,potentialProfit:p,potentialPayout:d,estimatedCost:c,estimatedFee:m=0,usdcBalance:u,isBalanceLoading:f,isMarketDataLoading:g,isSubmitting:b,authStatus:h,isValid:S,validationErrors:x,isInsufficientBalance:y,onInsufficientBalance:v,supportsLimitOrder:k,maxBuyAmount:P,kycRequired:M,needsKyc:N,needsSetup:w,kycUrl:R,expirationEnabled:A,expirationPreset:X,customDuration:L,customDurationUnit:G,oddsFormatter:U,outcomeLabels:oe,onOutcomeChange:W,onOrderTypeChange:te,onQuantityChange:ne,onLimitPriceChange:se,onExpirationEnabledChange:he,onExpirationPresetChange:Pe,onCustomDurationChange:pt,onCustomDurationUnitChange:Ve,onSubmit:Be}){let{t:E}=i18n.useTranslation(),[st,He]=react.useState(true),ve=ui.useDisclosure(),[at,we]=react.useState(""),Ue=react.useRef(false);react.useEffect(()=>{Ue.current||we(isNaN(i)?"":String(i));},[i]);let[qe,C]=react.useState(""),O=react.useRef(false);react.useEffect(()=>{O.current||(isNaN(s)?C(""):C(String(parseFloat((s*100).toFixed(2)))));},[s]);let z=react.useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(C(B),B===""||B==="."){se(NaN);return}let Pt=parseFloat(B);isNaN(Pt)||se(Pt/100);},[se]),Z=react.useCallback(B=>{if(B!==""&&!/^\d*\.?\d{0,2}$/.test(B))return;if(we(B),Xe(false),B===""||B==="."){ne(NaN);return}let Pt=parseFloat(B);isNaN(Pt)||ne(Pt);},[ne]);react.useEffect(()=>{M&&!ve.isOpen&&ve.onOpen();},[M,ve]);let me=react.useMemo(()=>{let B=o==="yes"?t.yesAsk:t.noAsk;return B!=null?parseFloat((Number(B)*100).toFixed(2)):null},[o,t]),Ne=o==="yes"?t.yesAsk:t.noAsk,lt=Ne!=null&&U?U(Number(Ne)):me!=null?`${me} \xA2`:dr,ct=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,kt=Number.isFinite(l)&&U?U(l):ct!=null?`${ct} \xA2`:dr,Qe=!isNaN(i)&&i>0,Yt=Qe?c+m:0,We=Qe&&a>0?Yt/a:0,et=We>0&&U?U(We):We>0?`${parseFloat((We*100).toFixed(2))}\xA2`:dr,xe=h==="authenticated",mt=h==="authenticating"||h==="deauthenticating",St=xe&&(N||w),Me=react.useCallback(B=>oe?.[B]??E(B==="yes"?"predict.trade.yes":"predict.trade.no"),[oe,E]),tt=react.useMemo(()=>{if(mt)return E("predict.trade.checkingLogin");if(!xe)return E("predict.trade.loginToTrade");if(N)return E("predict.trade.kycRequired");if(w)return E("predict.trade.setupRequired");if(f)return E("predict.trade.loadingBalance");if(g)return E("predict.trade.loadingMarketData");if(b)return E("predict.trade.submitting");if(M)return E("predict.trade.kycRequired");if(!Qe)return E("predict.trade.enterAmount");let B=Me(o),Ie=p>0?` \u2192 Win $${p.toFixed(2)}`:"";return `${E("predict.trade.buy")} ${B}${Ie}`},[mt,xe,N,w,f,g,b,M,Qe,o,Me,p,E]),Ce="primary",Lt=()=>{let B=P??be(u??0,2);ne(be(B/2,2));},I=()=>{ne(P??be(u??0,2));},[_e,Xe]=react.useState(false),mo=()=>{if(!xe){Xe(false),Be();return}if(N){ve.onOpen();return}if(w&&v){Xe(false),v();return}if(M){ve.onOpen();return}if(y&&v){Xe(false),v();return}if(!S){Xe(true);return}Xe(false),Be();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="hsl(var(--heroui-content4) / 0.8)");},onMouseLeave:B=>{r==="bordered"&&(B.currentTarget.style.borderColor="hsl(var(--heroui-content3) / 0.6)");},children:[e&&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-text-muted leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsxRuntime.jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxRuntime.jsxs("span",{className:"text-positive",children:[E("predict.trade.buy")," ",Me(o)]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[k?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:B=>te(B),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:E("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:E("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),n==="limit"&&k?jsxRuntime.jsx(ui.StyledInput,{"aria-label":E("predict.trade.limitPrice"),placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:qe,onChange:B=>z(B.target.value),onFocus:()=>{O.current=true;},onBlur:()=>{O.current=false,isNaN(s)?C(""):C(String(parseFloat((s*100).toFixed(2))));},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):lt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:lt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(B=>{let Ie=B==="yes"?t.yesAsk:t.noAsk;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>W(B),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===B?"border-positive bg-positive/10 text-positive":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:Me(B)}),Ie!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:U?U(Number(Ie)):`${parseFloat((Number(Ie)*100).toFixed(2))}\xA2`})]})},B)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-text-muted",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:Lt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:I,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":E("predict.trade.tradeAmount"),fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:at,onChange:B=>Z(B.target.value),onFocus:()=>{Ue.current=true;},onBlur:()=>{Ue.current=false,we(isNaN(i)?"":String(i));},startContent:jsxRuntime.jsx("span",{className:"text-text-muted text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),_e&&x.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:x.map(B=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:B},B))})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:E("predict.trade.balance")}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:u!=null?`$${be(u,2).toFixed(2)}`:"$0"})]}),n==="limit"&&k&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:E("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:A,onValueChange:he,"aria-label":E("predict.trade.setExpiration")})]}),A&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[X],onSelectionChange:B=>{let Ie=Array.from(B)[0];Ie&&Pe(Ie);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Fu.map(B=>jsxRuntime.jsx(ui.SelectItem,{children:E(Bu[B])},B))}),X==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":E("predict.trade.durationAmount"),size:"sm",radius:"lg",value:isNaN(L)?void 0:L,onValueChange:pt,minValue:1,step:1,formatOptions:Wu,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsxRuntime.jsx(ui.Select,{"aria-label":E("predict.trade.durationUnit"),selectedKeys:[G],onSelectionChange:B=>{let Ie=Array.from(B)[0];Ie&&Ve(Ie);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Hu.map(B=>jsxRuntime.jsx(ui.SelectItem,{children:E(Uu[B])},B))})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>He(B=>!B),className:"flex items-center gap-x-1 text-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:E("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",st&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:U&&Number.isFinite(l)?kt:ct!=null?E("predict.trade.chance",{percent:ct}):dr})]}),st&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:dr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Nr(a):dr})]}),m>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${m.toFixed(2)}`})]}),m>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalPayment")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${Yt.toFixed(2)}`})]}),m>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:et})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:dr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-positive",children:!isNaN(i)&&i>0&&p>0?`+$${p.toFixed(2)}`:dr})]})]})]}),jsxRuntime.jsx(ui.Button,{color:Ce,fullWidth:true,radius:"lg",size:"lg",isDisabled:mt||xe&&!St&&(f||g||!Qe||b),isLoading:mt||xe&&!St&&(b||f||g),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:mo,children:tt})]}),jsxRuntime.jsx(wo,{isOpen:ve.isOpen,onClose:ve.onClose,kycUrl:R})]})}function Eo({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:l,outcomeLabels:p}){let{outcome:d,orderType:c,quantity:m,limitPrice:u,shares:f,effectivePrice:g,estimatedCost:b,estimatedFee:h,potentialPayout:S,potentialProfit:x,pricePerShare:y,usdcBalance:v,maxBuyAmount:k,isBalanceLoading:P,isMarketDataLoading:M,isSubmitting:N,authStatus:w,validation:R,isInsufficientBalance:A,supportsLimitOrder:X,kycRequired:L,needsKyc:G,needsSetup:U,kycUrl:oe,expirationEnabled:W,expirationPreset:te,customDuration:ne,customDurationUnit:se,setOutcome:he,setOrderType:Pe,setQuantity:pt,setLimitPrice:Ve,setExpirationEnabled:Be,setExpirationPreset:E,setCustomDuration:st,setCustomDurationUnit:He,submit:ve,notifyInsufficientBalance:at}=Ci({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),we=walletConnector.useAuthCallback(ve),Ue=react.useCallback(O=>{he(O),a?.(O);},[he,a]),qe=react.useMemo(()=>e?un(e):void 0,[e]),C=react.useMemo(()=>pn(t,{yesAsk:d==="yes"?y:void 0,noAsk:d==="no"?y:void 0}),[t,d,y]);return jsxRuntime.jsx(Li,{event:qe,market:C,variant:r,outcome:d,orderType:c,quantity:m,limitPrice:u,shares:f,effectivePrice:g,estimatedCost:b,estimatedFee:h,potentialPayout:S,potentialProfit:x,usdcBalance:v,maxBuyAmount:k,isBalanceLoading:P,isMarketDataLoading:M,isSubmitting:N,authStatus:w,isValid:R.isValid,validationErrors:R.errors,isInsufficientBalance:A,onInsufficientBalance:s?at:void 0,supportsLimitOrder:X,kycRequired:L,needsKyc:G,needsSetup:U,kycUrl:oe,expirationEnabled:W,expirationPreset:te,customDuration:ne,customDurationUnit:se,oddsFormatter:l,outcomeLabels:p,onOutcomeChange:Ue,onOrderTypeChange:Pe,onQuantityChange:pt,onLimitPriceChange:Ve,onExpirationEnabledChange:Be,onExpirationPresetChange:E,onCustomDurationChange:st,onCustomDurationUnitChange:He,onSubmit:we})}var qr="predict-trade";function Co({id:e=qr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Xu,{...t})})}function Xu({params:e,isOpen:t,onOpenChange:r}){let{t:o}=i18n.useTranslation(),{isMobile:n}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:ui.THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{className:n?"":"p-2",children:[jsxRuntime.jsx(Eo,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsxRuntime.jsx("div",{className:"px-4 pb-4",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var Xr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function bn(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function Oi({isOpen:e,onClose:t,value:r,onChange:o,enableKalshi:n=true}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(r),l=react.useMemo(()=>n?Xr:{...Xr,source:"polymarket"},[n]),p=react.useCallback(S=>{S?a(r):t();},[r,t]),d=react.useCallback(()=>{a(l);},[l]),c=react.useCallback(()=>{o(s),t();},[s,o,t]),m=react.useCallback((S,x)=>{a(y=>({...y,[S]:x}));},[]),u=react.useMemo(()=>bn(s,n),[s,n]),f=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),b=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),h=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:p,size:"md",backdrop:"opaque",scrollBehavior:"inside",classNames:{base:ui.THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-text-primary",children:i("predict.filter.title")}),jsxRuntime.jsx(np,{onClick:()=>p(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsxRuntime.jsx(vn,{label:i("predict.filter.platform"),children:jsxRuntime.jsx(xn,{options:f,selected:s.source,onSelect:S=>m("source",S)})}),jsxRuntime.jsx(vn,{label:i("predict.filter.timeRemaining"),children:jsxRuntime.jsx(xn,{options:g,selected:s.timeRemaining,onSelect:S=>m("timeRemaining",S)})}),jsxRuntime.jsx(vn,{label:i("predict.filter.minVolume"),children:jsxRuntime.jsx(xn,{options:b,selected:s.minVolume,onSelect:S=>m("minVolume",S)})}),jsxRuntime.jsx(vn,{label:i("predict.filter.minLiquidity"),children:jsxRuntime.jsx(xn,{options:h,selected:s.minLiquidity,onSelect:S=>m("minLiquidity",S)})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid var(--color-border-subtle)"},children:[jsxRuntime.jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-text-secondary text-sm font-medium hover:text-text-primary transition-colors cursor-pointer",onClick:d,children:i("predict.filter.reset")}),jsxRuntime.jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover transition-colors cursor-pointer",onClick:c,children:[i("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",u,")"]})]})]})]})})})}function vn({label:e,children:t}){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"var(--color-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function np({onClick:e}){return jsxRuntime.jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function xn({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let i=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid color-mix(in srgb, var(--color-action-primary) 30%, transparent)":"1px solid var(--color-border-subtle)",background:i?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"hsl(var(--heroui-content3) / 0.4)",color:i?"var(--color-action-primary)":"var(--color-text-secondary)"},onMouseEnter:s=>{i||(s.currentTarget.style.background="hsl(var(--heroui-content3) / 0.8)",s.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:s=>{i||(s.currentTarget.style.background="hsl(var(--heroui-content3) / 0.4)",s.currentTarget.style.color="var(--color-text-secondary)");},children:n.label},n.value??"__all")})})}var _i={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Ma={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},mp=["start_time","volume","liquidity","ending_soon"],wa={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"8px 12px",fontSize:14,color:"var(--color-text-primary)",cursor:"pointer",transition:"all 0.15s"},fp={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Ii({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=i18n.useTranslation(),[l,p]=react.useState(false),d=react.useRef(null),c=react.useCallback(u=>{d.current&&!d.current.contains(u.target)&&p(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),react.useEffect(()=>{if(!l)return;let u=f=>{f.key==="Escape"&&p(false);};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[l]);let m=Ea[e];return jsxRuntime.jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:d,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:wa,onMouseEnter:u=>{u.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:u=>{u.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:()=>p(u=>!u),children:[jsxRuntime.jsx(gp,{}),jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:"var(--color-text-secondary)"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:a(Ma[e])}),jsxRuntime.jsx(vp,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...fp,width:224,padding:4},children:mp.map(u=>{let f=Ea[u],g=e===u;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"transparent",color:g?"var(--color-action-primary)":"var(--color-text-secondary)",borderRadius:10},onMouseEnter:b=>{g||(b.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)",b.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:b=>{g||(b.currentTarget.style.background="transparent",b.currentTarget.style.color="var(--color-text-secondary)");},onClick:()=>{e===u?o(!r):t(u),p(false);},children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:g?"var(--color-action-primary)":"var(--color-text-muted)"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:a(Ma[u])}),g&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"var(--color-action-primary)",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},u)})})]}),jsxRuntime.jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",width:36,height:36,color:"var(--color-text-secondary)",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:u=>{u.currentTarget.style.background="var(--color-surface-strong)",u.currentTarget.style.color="var(--color-text-primary)";},onMouseLeave:u=>{u.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)",u.currentTarget.style.color="var(--color-text-secondary)";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:wa,onMouseEnter:u=>{u.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:u=>{u.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:n,children:[jsxRuntime.jsx(hp,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:a("predict.filter.title")})]}),i>0&&jsxRuntime.jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"var(--color-action-primary)",color:"var(--color-text-inverse)",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Ea={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function gp(){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function hp(){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function vp({open:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-muted)",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function Di(e={}){let{i18n:t}=i18n.useTranslation(),{tagSlugSelection:r,limit:o,status:n,sort_by:i,sort_asc:s,source:a,with_markets:l,minVolume:p,minLiquidity:d,timeRemaining:c,markets_limit:m,lang:u}=e,f=u??t.resolvedLanguage??t.language,g=react.useMemo(()=>reactPredict.resolveEventsParams({tagSlugSelection:r,limit:o,status:n,sort_by:i,sort_asc:s,source:a,with_markets:l,minVolume:p,minLiquidity:d,timeRemaining:c,markets_limit:m,lang:f}),[f,o,m,d,p,s,i,a,n,r,c,l]),{data:b,isLoading:h,isFetching:S,isFetchingNextPage:x,isError:y,error:v,hasNextPage:k,fetchNextPage:P,refetch:M}=reactPredict.useInfiniteEvents(g),N=react.useMemo(()=>b?.pages.flatMap(A=>A.items).filter(A=>A!=null)??[],[b]),w=react.useCallback(()=>{P();},[P]),R=react.useCallback(()=>{M();},[M]);return {data:N,isLoading:h,isFetching:S&&!x,isFetchingMore:x,isError:y,error:v??null,hasMore:k??false,fetchMore:w,refetch:R}}var Ra=`
2
2
  @keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
3
3
  @media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
4
4
  @media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}
5
5
  @media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}
6
- `,_s={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function vo(e){return {..._s,animationDelay:`${e}ms`}}function xo({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:Ls}),jsxRuntime.jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(vp,{index:r},r))})]})}function vp({index:e}){let t=e*120,r={..._s,animationDelay:`${t}ms`},n=e%3===0?"85%":e%3===1?"70%":"60%";return jsxRuntime.jsx("div",{style:{padding:8},children:jsxRuntime.jsxs("div",{className:"evt-skel-card",style:{display:"flex",flexDirection:"column",minHeight:248,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsxRuntime.jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:12,width:n}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(o=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:o===0?"55%":o===1?"45%":"35%"}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:32}}),jsxRuntime.jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},o))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:72}})]})]})})}function xp(){return jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px"},children:[jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:10,minHeight:40,flex:1},children:[48,64,48,56,72,56].map((e,t)=>jsxRuntime.jsx("div",{style:{...vo(t*50),height:28,width:e,borderRadius:6}},t))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsxRuntime.jsx("div",{style:{...vo(0),height:36,width:120,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...vo(50),height:36,width:36,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...vo(100),height:36,width:80,borderRadius:10}})]})]})}function yp({count:e=24}){return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsxRuntime.jsx("style",{children:Ls}),jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsxRuntime.jsx(xp,{})}),jsxRuntime.jsx("div",{style:{padding:"12px 8px 80px"},children:jsxRuntime.jsx(xo,{count:e})})]})}function Sp(e,t){let r={...e};return delete r.price,t||(delete r.best_bid,delete r.best_ask),r}function yo(e){if(!e.capability?.enabled)return e.legacyEvent;let t=e.marketDataEvent??e.legacyEvent;return {...t,markets:t.markets?.map(r=>({...r,outcomes:r.outcomes.map(n=>Sp(n,!!e.marketDataEvent))}))}}function Jr(e,t){if(e)return t?e.best_ask:e.best_ask??e.price}var Os=3,Lp={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},_p={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Aa={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Hs={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Op={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Cn=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function Is(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function Ip(e){let t=e.outcomes?.map(i=>i.label?.toLowerCase().trim()??"")??[];if(t.some(i=>i==="up")&&t.some(i=>i==="down"))return [Aa,Op];if(t.some(i=>i==="yes")&&t.some(i=>i==="no"))return [Aa,Hs];let r=t[0]??"",n=t[1]??"",o=Is(r)%Cn.length,a=Is(n)%Cn.length;return a===o&&(a=(a+1)%Cn.length),[Cn[o],Cn[a]]}function Ds(e){return e.title_trans||e.title}function Dp(e){return e.question_trans||e.question}function Fa(e,t){return e?.label_trans||e?.label||t}function Us(e){return Fa(e.outcomes?.[0],Dp(e))}function Ba(e,t){let r=e.outcomes?.[0];return r?Jr(r,t)??null:null}function Ws(e,t){let r=Ba(e,t);return r!=null?parseFloat((r*100).toFixed(2)):null}function zs(e){return e===null?"\u2014":e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function As(e,t){let r=e.outcomes?.[0],n=Jr(r,t);return n===void 0?"\u2014":parseFloat((n*100).toFixed(2)).toString()}function Fs(e,t){let r=e.outcomes?.[1];if(r){let a=Jr(r,t);return a===void 0?"\u2014":parseFloat((a*100).toFixed(2)).toString()}if(t)return "\u2014";let n=e.outcomes?.[0],o=n?.best_ask??n?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function Ap(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),o=Math.floor(t%36e5/6e4),a=[];return r>0&&a.push(`${r}d`),n>0&&a.push(`${n}h`),a.push(`${o}m`),a.join(" ")}var Fp=`
6
+ `,La={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function yn(e){return {...La,animationDelay:`${e}ms`}}function kn({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:Ra}),jsxRuntime.jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(kp,{index:r},r))})]})}function kp({index:e}){let t=e*120,r={...La,animationDelay:`${t}ms`},o=e%3===0?"85%":e%3===1?"70%":"60%";return jsxRuntime.jsx("div",{style:{padding:8},children:jsxRuntime.jsxs("div",{className:"evt-skel-card",style:{display:"flex",flexDirection:"column",minHeight:248,borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsxRuntime.jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:12,width:o}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(n=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:n===0?"55%":n===1?"45%":"35%"}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:32}}),jsxRuntime.jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},n))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px"},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Sp(){return jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px"},children:[jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:10,minHeight:40,flex:1},children:[48,64,48,56,72,56].map((e,t)=>jsxRuntime.jsx("div",{style:{...yn(t*50),height:28,width:e,borderRadius:6}},t))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[jsxRuntime.jsx("div",{style:{...yn(0),height:36,width:120,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...yn(50),height:36,width:36,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...yn(100),height:36,width:80,borderRadius:10}})]})]})}function Pp({count:e=24}){return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsxRuntime.jsx("style",{children:Ra}),jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid var(--color-border-subtle)"},children:jsxRuntime.jsx(Sp,{})}),jsxRuntime.jsx("div",{style:{padding:"12px 8px 80px"},children:jsxRuntime.jsx(kn,{count:e})})]})}function Mp(e,t){let r={...e};return delete r.price,t||(delete r.best_bid,delete r.best_ask),r}function Sn(e){if(!e.capability?.enabled)return e.legacyEvent;let t=e.marketDataEvent??e.legacyEvent;return {...t,markets:t.markets?.map(r=>({...r,outcomes:r.outcomes.map(o=>Mp(o,!!e.marketDataEvent))}))}}function Jr(e,t){if(e)return t?e.best_ask:e.best_ask??e.price}var Oa=3,Ip={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},Dp={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Ai={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ba={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Ap={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},To=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function _a(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function Fp(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Ai,Ap];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Ai,Ba];let r=t[0]??"",o=t[1]??"",n=_a(r)%To.length,i=_a(o)%To.length;return i===n&&(i=(i+1)%To.length),[To[n],To[i]]}function Ia(e){return e.title_trans||e.title}function Bp(e){return e.question_trans||e.question}function Fi(e,t){return e?.label_trans||e?.label||t}function Ha(e){return Fi(e.outcomes?.[0],Bp(e))}function Bi(e,t){let r=e.outcomes?.[0];return r?Jr(r,t)??null:null}function Ua(e,t){let r=Bi(e,t);return r!=null?parseFloat((r*100).toFixed(2)):null}function Wa(e){return e===null?"\u2014":e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Da(e,t){let r=e.outcomes?.[0],o=Jr(r,t);return o===void 0?"\u2014":parseFloat((o*100).toFixed(2)).toString()}function Aa(e,t){let r=e.outcomes?.[1];if(r){let i=Jr(r,t);return i===void 0?"\u2014":parseFloat((i*100).toFixed(2)).toString()}if(t)return "\u2014";let o=e.outcomes?.[0],n=o?.best_ask??o?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function Hp(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),o>0&&i.push(`${o}h`),i.push(`${n}m`),i.join(" ")}var Up=`
7
7
  .badge-shine { position: relative; overflow: hidden; }
8
8
  .badge-shine::after {
9
9
  content: "";
@@ -27,13 +27,13 @@
27
27
  outline: 2px solid hsl(var(--heroui-primary) / 0.4);
28
28
  outline-offset: 2px;
29
29
  }
30
- `;function Ua({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:a,marketDataCapability:i,marketDataEvent:s}){let[l,u]=react.useState(null),p=i?.enabled??false,c=react.useMemo(()=>yo({capability:i,legacyEvent:e,marketDataEvent:s}),[e,i,s]),d=react.useMemo(()=>{let N=c.markets??[];return N.length>2?[...N].sort((w,M)=>(Ba(M,p)??-1)-(Ba(w,p)??-1)):N},[c.markets,p]).filter(N=>N.status==="open"),m=d.length===1,v=d.slice(0,Os),k=d.length-Os,g=react.useMemo(()=>utils.formatAmountInUsd(e.volume??0),[e.volume]),S=l?d.find(N=>N.slug===l)??null:null,h=!!S||m,x=()=>{h||n?.(c);},b=N=>{N.stopPropagation(),S&&(N.preventDefault(),u(null));},y=N=>{N.stopPropagation(),t||(N.preventDefault(),n?.(c));},P=m?jsxRuntime.jsx(qp,{event:c,formattedVolume:g,href:t,LinkComponent:r,onSelect:n}):S?jsxRuntime.jsx(Xp,{onCollapse:()=>u(null)}):jsxRuntime.jsx(Vp,{moreCount:k,formattedVolume:g,source:c.source,href:t,LinkComponent:r,onShowMore:y});return jsxRuntime.jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:h?void 0:"pointer"},onMouseEnter:N=>{let w=N.currentTarget,M=Lp[e.source]??_p;w.style.borderColor=M.border,w.style.boxShadow=M.shadow,a?.(e);},onMouseLeave:N=>{let w=N.currentTarget;w.style.borderColor="rgba(39,39,42,0.6)",w.style.boxShadow="none";},onClick:x,children:[jsxRuntime.jsx("style",{children:Fp}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsxRuntime.jsx(Bp,{event:c,href:t,LinkComponent:r,onClick:b,isExpanded:h}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:m?jsxRuntime.jsx(Yp,{market:d[0],event:c,onSelectOutcome:o,marketDataEnabled:p}):S?jsxRuntime.jsx(Qp,{market:S,event:c,onCollapse:()=>u(null),onSelectOutcome:o,marketDataEnabled:p}):jsxRuntime.jsx(Kp,{displayedMarkets:v,marketDataEnabled:p,onMarketClick:N=>u(N.slug)})})]}),jsxRuntime.jsx(jp,{children:P})]})}function Bp({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let a=e.start_at?Ap(e.start_at):null;return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:n,children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:Ds(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui$1.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",o&&"group-hover/header:text-neutral-400"),children:Ds(e)}),a&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",a]})]}),jsxRuntime.jsx(Up,{event:e})]})}function Hp(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),a=300*1e3,i=900*1e3;if(o>0&&o<=i){let s=o<=a?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=a?"5m":"15m",color:s});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Up({event:e}){let t=react.useMemo(()=>Hp(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,n)=>{switch(r.kind){case "live":return jsxRuntime.jsx(Wp,{},n);case "crypto-short":return jsxRuntime.jsx(zp,{label:r.label,color:r.color},n);case "closed":return jsxRuntime.jsx($p,{},n)}})})}function Wp(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function zp({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui$1.TimerIcon,{className:"size-3 shrink-0"}),e]})}function $p(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Kp({displayedMarkets:e,onMarketClick:t,marketDataEnabled:r}){return e.length>0?jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(n=>{let o=Ws(n,r);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:a=>{a.stopPropagation(),t(n);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:Us(n)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:zs(o)}),jsxRuntime.jsx(Gp,{})]})]},n.id??`${n.source}-${n.slug}`)})}):null}function Vp({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:a}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e>0?jsxRuntime.jsxs(ui$1.Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a,children:[i("predict.event.showMore"),jsxRuntime.jsx(Ks,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsxRuntime.jsx(Vs,{source:r})]})]})}function jp({children:e}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Bs({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function $s({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action",marketDataEnabled:a}){let{t:i}=i18n.useTranslation(),[s,l]=n?Ip(e):[Aa,Hs],u=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",p=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",c=o==="label"&&u===p?"action":o,f=c==="label"?`${Fa(e.outcomes?.[0],"Yes")} ${As(e,a)}\xA2`:i("predict.market.action.yes",{price:As(e,a)}),d=c==="label"?`${Fa(e.outcomes?.[1],"No")} ${Fs(e,a)}\xA2`:i("predict.market.action.no",{price:Fs(e,a)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Bs,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"yes");},children:f}),jsxRuntime.jsx(Bs,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"no");},children:d})]})}function Gp(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Yp({market:e,event:t,onSelectOutcome:r,marketDataEnabled:n}){return jsxRuntime.jsx("div",{style:{flex:1},children:jsxRuntime.jsx($s,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label",marketDataEnabled:n})})}function qp({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:a}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ui$1.Linkable,{href:r,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s=>{s.stopPropagation(),r||(s.preventDefault(),o?.(e));},children:[a("predict.event.viewEvent"),jsxRuntime.jsx(Ks,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",a("predict.event.volume"),jsxRuntime.jsx(Vs,{source:e.source})]})]})}function Qp({market:e,event:t,onCollapse:r,onSelectOutcome:n,marketDataEnabled:o}){let a=Ws(e,o);return jsxRuntime.jsxs("div",{style:{flex:1},children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:Us(e)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:zs(a)}),jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{style:{marginTop:12},children:jsxRuntime.jsx($s,{market:e,event:t,onSelectOutcome:n,labelFormat:"action",marketDataEnabled:o})})]})}function Xp({onCollapse:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsxRuntime.jsx(Jp,{className:"h-3 w-3"}),t("predict.event.back")]}),jsxRuntime.jsx("div",{})]})}function Ks({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:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Jp({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:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Vs({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui$1.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui$1.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var rm=8;function za({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:a,getEventHref:i,LinkComponent:s,onHover:l,marketDataCapability:u,getMarketDataEvent:p}){let{t:c}=i18n.useTranslation(),f=react.useRef(null);react.useEffect(()=>{let v=f.current;if(!v)return;let k=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return k.observe(v),()=>k.disconnect()},[t,r,n]);let d=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),m=!t&&e.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("style",{children:`
30
+ `;function Ui({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i,marketDataCapability:s,marketDataEvent:a}){let[l,p]=react.useState(null),d=s?.enabled??false,c=react.useMemo(()=>Sn({capability:s,legacyEvent:e,marketDataEvent:a}),[e,s,a]),u=react.useMemo(()=>{let M=c.markets??[];return M.length>2?[...M].sort((N,w)=>(Bi(w,d)??-1)-(Bi(N,d)??-1)):M},[c.markets,d]).filter(M=>M.status==="open"),f=u.length===1,g=u.slice(0,Oa),b=u.length-Oa,h=react.useMemo(()=>utils.formatAmountInUsd(e.volume??0),[e.volume]),S=l?u.find(M=>M.slug===l)??null:null,x=!!S||f,y=()=>{x||o?.(c);},v=M=>{M.stopPropagation(),S&&(M.preventDefault(),p(null));},k=M=>{M.stopPropagation(),t||(M.preventDefault(),o?.(c));},P=f?jsxRuntime.jsx(Jp,{event:c,formattedVolume:h,href:t,LinkComponent:r,onSelect:o}):S?jsxRuntime.jsx(em,{onCollapse:()=>p(null)}):jsxRuntime.jsx(Yp,{moreCount:b,formattedVolume:h,source:c.source,href:t,LinkComponent:r,onShowMore:k});return jsxRuntime.jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",cursor:x?void 0:"pointer"},onMouseEnter:M=>{let N=M.currentTarget,w=Ip[e.source]??Dp;N.style.borderColor=w.border,N.style.boxShadow=w.shadow,i?.(e);},onMouseLeave:M=>{let N=M.currentTarget;N.style.borderColor="hsl(var(--heroui-content3) / 0.6)",N.style.boxShadow="none";},onClick:y,children:[jsxRuntime.jsx("style",{children:Up}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsxRuntime.jsx(Wp,{event:c,href:t,LinkComponent:r,onClick:v,isExpanded:x}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:f?jsxRuntime.jsx(Xp,{market:u[0],event:c,onSelectOutcome:n,marketDataEnabled:d}):S?jsxRuntime.jsx(Zp,{market:S,event:c,onCollapse:()=>p(null),onSelectOutcome:n,marketDataEnabled:d}):jsxRuntime.jsx(Gp,{displayedMarkets:g,marketDataEnabled:d,onMarketClick:M=>p(M.slug)})})]}),jsxRuntime.jsx(qp,{children:P})]})}function Wp({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let{t:i}=i18n.useTranslation(),s=e.start_at?Hp(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:Ia(e)||i("predict.event.fallbackName"),radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-text-primary line-clamp-2 lg:text-base",n&&"group-hover/header:text-text-secondary"),children:Ia(e)}),s&&jsxRuntime.jsx("span",{className:"text-[10px] leading-4 text-text-muted",children:i("predict.event.liveIn",{countdown:s})})]}),jsxRuntime.jsx($p,{event:e})]})}function zp(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(n>0&&n<=s){let a=n<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=i?"5m":"15m",color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function $p({event:e}){let t=react.useMemo(()=>zp(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsxRuntime.jsx(Kp,{},o);case "crypto-short":return jsxRuntime.jsx(Vp,{label:r.label,color:r.color},o);case "closed":return jsxRuntime.jsx(jp,{},o)}})})}function Kp(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function Vp({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function jp(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-surface-interactive/80 px-1.5 py-0.5 text-xs font-semibold text-text-secondary",children:e("predict.event.status.closed")})}function Gp({displayedMarkets:e,onMarketClick:t,marketDataEnabled:r}){return e.length>0?jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(o=>{let n=Ua(o,r);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:i=>{i.stopPropagation(),t(o);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-text-primary line-clamp-1 lg:text-sm",children:Ha(o)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-text-primary lg:text-lg",children:Wa(n)}),jsxRuntime.jsx(Qp,{})]})]},o.id??`${o.source}-${o.slug}`)})}):null}function Yp({moreCount:e,formattedVolume:t,source:r,href:o,LinkComponent:n,onShowMore:i}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e>0?jsxRuntime.jsxs(ui.Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-text-muted transition-colors hover:text-text-primary cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsxRuntime.jsx($a,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"var(--color-text-muted)"},children:[t," ",s("predict.event.volume"),jsxRuntime.jsx(Ka,{source:r})]})]})}function qp({children:e}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Fa({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:a=>{let l=a.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function za({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action",marketDataEnabled:i}){let{t:s}=i18n.useTranslation(),[a,l]=o?Fp(e):[Ai,Ba],p=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",d=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",c=n==="label"&&p===d?"action":n,m=c==="label"?`${Fi(e.outcomes?.[0],"Yes")} ${Da(e,i)}\xA2`:s("predict.market.action.yes",{price:Da(e,i)}),u=c==="label"?`${Fi(e.outcomes?.[1],"No")} ${Aa(e,i)}\xA2`:s("predict.market.action.no",{price:Aa(e,i)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Fa,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"yes");},children:m}),jsxRuntime.jsx(Fa,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"no");},children:u})]})}function Qp(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-text-secondary",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Xp({market:e,event:t,onSelectOutcome:r,marketDataEnabled:o}){return jsxRuntime.jsx("div",{style:{flex:1},children:jsxRuntime.jsx(za,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label",marketDataEnabled:o})})}function Jp({event:e,formattedVolume:t,href:r,LinkComponent:o,onSelect:n}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ui.Linkable,{href:r,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-text-muted transition-colors hover:text-text-primary cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx($a,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"var(--color-text-muted)"},children:[t," ",i("predict.event.volume"),jsxRuntime.jsx(Ka,{source:e.source})]})]})}function Zp({market:e,event:t,onCollapse:r,onSelectOutcome:o,marketDataEnabled:n}){let i=Ua(e,n);return jsxRuntime.jsxs("div",{style:{flex:1},children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-text-primary lg:text-sm",children:Ha(e)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-text-primary lg:text-lg",children:Wa(i)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-text-secondary"})]})]}),jsxRuntime.jsx("div",{style:{marginTop:12},children:jsxRuntime.jsx(za,{market:e,event:t,onSelectOutcome:o,labelFormat:"action",marketDataEnabled:n})})]})}function em({onCollapse:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-text-primary cursor-pointer lg:text-xs",style:{color:"var(--color-text-muted)"},onClick:r=>{r.stopPropagation(),e();},children:[jsxRuntime.jsx(tm,{className:"h-3 w-3"}),t("predict.event.back")]}),jsxRuntime.jsx("div",{})]})}function $a({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:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function tm({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:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ka({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-text-secondary",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var im=8;function zi({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l,marketDataCapability:p,getMarketDataEvent:d}){let{t:c}=i18n.useTranslation(),m=react.useRef(null);react.useEffect(()=>{let g=m.current;if(!g)return;let b=new IntersectionObserver(h=>{h[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return b.observe(g),()=>b.disconnect()},[t,r,o]);let u=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]),f=!t&&e.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("style",{children:`
31
31
  @keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
32
32
  @keyframes evt-load-spin{to{transform:rotate(360deg)}}
33
33
  @media(max-width:767px){.evt-card-grid{grid-template-columns:1fr!important}}
34
34
  @media(min-width:768px) and (max-width:1023px){.evt-card-grid{grid-template-columns:repeat(2,1fr)!important}}
35
35
  @media(min-width:1024px) and (max-width:1279px){.evt-card-grid{grid-template-columns:repeat(3,1fr)!important}}
36
- `}),jsxRuntime.jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((v,k)=>v==null?null:jsxRuntime.jsx("div",{style:{padding:rm,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${k%4*35}ms both`},children:jsxRuntime.jsx(Ua,{event:v,href:i?.(v),LinkComponent:s,onSelect:o,onSelectOutcome:a,onHover:l,marketDataCapability:u,marketDataEvent:p?.(v)})},`${v.source}-${v.slug}`))}),jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),c("predict.events.loadMore")]})}),m&&jsxRuntime.jsx(nm,{onScrollToTop:d})]})}function nm({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function $a({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:a,with_markets:i,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p,lang:c,onSelect:f,onSelectOutcome:d,getEventHref:m,LinkComponent:v,onHover:k,marketDataCapability:g,getMarketDataEvent:S}){let{data:h,hasMore:x,fetchMore:b,isFetching:y,isFetchingMore:P}=Da({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:a,with_markets:i,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p,lang:c});return y?jsxRuntime.jsx(xo,{count:24}):jsxRuntime.jsx(za,{events:h,hasMore:x,isFetchingMore:P,onFetchMore:b,onSelect:f,onSelectOutcome:d,getEventHref:m,LinkComponent:v,onHover:k,marketDataCapability:g,getMarketDataEvent:S})}function im({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,onInsufficientBalance:a,enableKalshi:i=true,lang:s,marketDataCapability:l,getMarketDataEvent:u}){let[p,c]=react.useState({categorySlug:null,tagSlug:null}),[f,d]=react.useState(()=>i?Xr:{...Xr,source:"polymarket"}),{isOpen:m,onOpen:v,onClose:k}=ui$1.useDisclosure(),{onOpen:g}=uiScaffold.useAsyncModal(qr),S=react.useCallback((M,L,A)=>{t?.(M,L,A),g({params:{event:M,market:L,initialOutcome:A,onInsufficientBalance:a}});},[t,g,a]),h=react.useCallback(M=>{c(M);},[]),x=react.useCallback(M=>{d(L=>({...L,sortPreset:M}));},[]),b=react.useCallback(M=>{d(L=>({...L,sortAsc:M}));},[]),y=react.useCallback(M=>{d(M);},[]),P=react.useMemo(()=>Oa[f.sortPreset].sort_by,[f.sortPreset]),N=react.useMemo(()=>bo(f,i),[f,i]),w=react.useMemo(()=>jsxRuntime.jsx(Ia,{sortPreset:f.sortPreset,onSortChange:x,sortAsc:f.sortAsc,onSortAscChange:b,onFilterPress:v,filterCount:N}),[f.sortPreset,f.sortAsc,N,x,b,v]);return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsxRuntime.jsx(fa,{onSelect:h,trailing:w})}),jsxRuntime.jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsxRuntime.jsx(_a,{isOpen:m,onClose:k,value:f,onChange:y,enableKalshi:i}),jsxRuntime.jsx($a,{tagSlugSelection:p,lang:s,sort_by:P,sort_asc:f.sortAsc,source:f.source,timeRemaining:f.timeRemaining,minVolume:f.minVolume,minLiquidity:f.minLiquidity,onSelect:e,onSelectOutcome:S,getEventHref:r,LinkComponent:n,onHover:o,marketDataCapability:l,getMarketDataEvent:u})]}),jsxRuntime.jsx(En,{})]})}function Xs(e){return utils.formatAmountInUsd(e)}var cm=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>utils.formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)"},{key:"total_volume_24h",labelKey:"predict.events.stats.volume24h",format:Xs,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:Xs,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>utils.formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function dm({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
36
+ `}),jsxRuntime.jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((g,b)=>g==null?null:jsxRuntime.jsx("div",{style:{padding:im,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${b%4*35}ms both`},children:jsxRuntime.jsx(Ui,{event:g,href:s?.(g),LinkComponent:a,onSelect:n,onSelectOutcome:i,onHover:l,marketDataCapability:p,marketDataEvent:d?.(g)})},`${g.source}-${g.slug}`))}),jsxRuntime.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--color-text-muted)",fontSize:13},children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"evt-load-spin 1s linear infinite"},children:jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),c("predict.events.loadMore")]})}),f&&jsxRuntime.jsx(sm,{onScrollToTop:u})]})}function sm({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-surface-strong"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-text-muted",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-surface-strong"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-text-secondary",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function $i({tagSlugSelection:e,limit:t=24,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:p,markets_limit:d,lang:c,onSelect:m,onSelectOutcome:u,getEventHref:f,LinkComponent:g,onHover:b,marketDataCapability:h,getMarketDataEvent:S}){let{data:x,hasMore:y,fetchMore:v,isFetching:k,isFetchingMore:P}=Di({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:i,with_markets:s,timeRemaining:a,minVolume:l,minLiquidity:p,markets_limit:d,lang:c});return k?jsxRuntime.jsx(kn,{count:24}):jsxRuntime.jsx(zi,{events:x,hasMore:y,isFetchingMore:P,onFetchMore:v,onSelect:m,onSelectOutcome:u,getEventHref:f,LinkComponent:g,onHover:b,marketDataCapability:h,getMarketDataEvent:S})}function cm({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n,onInsufficientBalance:i,enableKalshi:s=true,lang:a,marketDataCapability:l,getMarketDataEvent:p}){let[d,c]=react.useState({categorySlug:null,tagSlug:null}),[m,u]=react.useState(()=>s?Xr:{...Xr,source:"polymarket"}),{isOpen:f,onOpen:g,onClose:b}=ui.useDisclosure(),{onOpen:h}=uiScaffold.useAsyncModal(qr),S=react.useCallback((w,R,A)=>{t?.(w,R,A),h({params:{event:w,market:R,initialOutcome:A,onInsufficientBalance:i}});},[t,h,i]),x=react.useCallback(w=>{c(w);},[]),y=react.useCallback(w=>{u(R=>({...R,sortPreset:w}));},[]),v=react.useCallback(w=>{u(R=>({...R,sortAsc:w}));},[]),k=react.useCallback(w=>{u(w);},[]),P=react.useMemo(()=>_i[m.sortPreset].sort_by,[m.sortPreset]),M=react.useMemo(()=>bn(m,s),[m,s]),N=react.useMemo(()=>jsxRuntime.jsx(Ii,{sortPreset:m.sortPreset,onSortChange:y,sortAsc:m.sortAsc,onSortAscChange:v,onFilterPress:g,filterCount:M}),[m.sortPreset,m.sortAsc,M,y,v,g]);return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid var(--color-border-subtle)"},children:jsxRuntime.jsx(gi,{onSelect:x,trailing:N})}),jsxRuntime.jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsxRuntime.jsx(Oi,{isOpen:f,onClose:b,value:m,onChange:k,enableKalshi:s}),jsxRuntime.jsx($i,{tagSlugSelection:d,lang:a,sort_by:P,sort_asc:m.sortAsc,source:m.source,timeRemaining:m.timeRemaining,minVolume:m.minVolume,minLiquidity:m.minLiquidity,onSelect:e,onSelectOutcome:S,getEventHref:r,LinkComponent:o,onHover:n,marketDataCapability:l,getMarketDataEvent:p})]}),jsxRuntime.jsx(Co,{})]})}function Qa(e){return utils.formatAmountInUsd(e)}var pm=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>utils.formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)"},{key:"total_volume_24h",labelKey:"predict.events.stats.volume24h",format:Qa,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:Qa,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>utils.formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function mm({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
37
37
  @keyframes evt-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
38
38
  @keyframes evt-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
39
39
  @keyframes evtHeroTitleEnter{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
@@ -60,7 +60,7 @@
60
60
  .evt-hero-subtitle{font-size:14px}
61
61
  @media(min-width:640px){.evt-hero-subtitle{font-size:15px}}
62
62
 
63
- .evt-stat-grid{display:grid;grid-template-columns:repeat(2,1fr);width:100%;max-width:360px;border-radius:16px;border:1px solid rgba(39,39,42,0.5);overflow:hidden;flex-shrink:0;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
63
+ .evt-stat-grid{display:grid;grid-template-columns:repeat(2,1fr);width:100%;max-width:360px;border-radius:16px;border:1px solid var(--color-border-subtle);overflow:hidden;flex-shrink:0;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
64
64
  @media(min-width:640px){.evt-stat-grid{width:340px;max-width:none}}
65
65
  @media(min-width:1024px){.evt-stat-grid{width:380px}}
66
66
 
@@ -70,16 +70,16 @@
70
70
 
71
71
  .evt-stat-label{font-size:11px;line-height:16px;min-height:16px;white-space:nowrap}
72
72
  @media(min-width:640px){.evt-stat-label{font-size:12px;line-height:18px;min-height:18px}}
73
- `}),jsxRuntime.jsxs("div",{className:"evt-hero-outer",children:[jsxRuntime.jsxs("div",{className:"evt-hero-left",style:{minWidth:0,flex:1,animation:"evtHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsxRuntime.jsx("div",{className:"evt-hero-live",style:{marginBottom:16},children:jsxRuntime.jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsxRuntime.jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"evt-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsxRuntime.jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"evt-live-breathe 2.4s ease-in-out infinite"}})]}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.events.liveBadge")})]})}),jsxRuntime.jsxs("h1",{className:"evt-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxRuntime.jsxs("span",{style:{color:"#fff"},children:[t("predict.events.titlePrefix")," "]}),jsxRuntime.jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.events.titleHighlight")})]}),jsxRuntime.jsx("p",{className:"evt-hero-subtitle evt-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.events.heroSubtitle")).split(`
74
- `).map((r,n)=>jsxRuntime.jsxs("span",{children:[n>0&&jsxRuntime.jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsxRuntime.jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:cm.map((r,n)=>jsxRuntime.jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsxRuntime.jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsxRuntime.jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsxRuntime.jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsxRuntime.jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}function ja({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:a,i18n:i}=i18n.useTranslation(),{mutateAsync:s}=reactPredict.useRedeemPosition(),{start:l}=reactPredict.useTradeResultConfirmation(),{evmAddress:u}=cr(),p=walletConnector.useWallets(),[c,f]=react.useState("idle"),[d,m]=react.useState(null),v=t.provider_meta?.["polymarket.conditionId"],k=t.provider_meta?.["polymarket.negRisk"]??false,g=u??"",S=react.useMemo(()=>Gr(a,i),[i,a]),h=react.useMemo(()=>p.find(U=>U.chainNamespace===types.ChainNamespace.EVM&&U.isConnected),[p]),x=el(r.side,t.outcomes),y=t.outcomes?.[x]?.label??r.side,P=t.result!=null?el(t.result,t.outcomes):-1,w=(P>=0?t.outcomes?.[P]:void 0)?.label??t.result??"",M=t.result!=null?x===P:true,L=react.useMemo(()=>M?r.size:0,[M,r.size]),A=react.useCallback(async()=>{if(!(!v||!g||!h)){f("pending"),m(null);try{let U=await h.getEip1193Provider();if(!U)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:g,condition_id:v,neg_risk:k,signMessage:async Y=>await U.request({method:"personal_sign",params:[Y,g]}),signTypedData:async Y=>await U.request({method:"eth_signTypedData_v4",params:[g,JSON.stringify(Y)]})}),f("confirming");let q=wr({messages:S});q.submitted(),await l({source:r.source,user:g,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem",expectedPayout:L})==="confirmed"?(f("success"),q.completed()):(f("delayed"),q.delayed()),n?.();}catch(U){f("error"),m(U instanceof Error?U.message:a("predict.redeem.error"));}}},[v,g,k,h,s,S,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,L,n,a]),X=walletConnector.useAuthCallback(A),_=c==="idle"&&!!v&&!!g&&!!h&&r.redeemable;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsxRuntime.jsx("div",{className:"text-base font-medium text-white",children:e?.title??t.question}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-[rgba(39,39,42,0.4)] p-3",children:[jsxRuntime.jsx(So,{label:a("predict.positions.side"),value:y,valueClassName:M?"text-green-400":"text-red-400"}),t.result!=null&&jsxRuntime.jsx(So,{label:a("predict.redeem.result"),value:w,valueClassName:"text-green-400"}),jsxRuntime.jsx(So,{label:a("predict.positions.size"),value:r.size.toFixed(2)}),jsxRuntime.jsx(So,{label:a("predict.redeem.expectedPayout"),value:`$${L.toFixed(2)}`,valueClassName:L>0?"text-green-400":"text-zinc-400"})]}),!M&&L===0&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-500",children:a("predict.redeem.noWinnings")}),c==="error"&&d&&jsxRuntime.jsx("p",{className:"text-sm text-red-400",children:d}),c==="success"&&jsxRuntime.jsx("p",{className:"text-sm text-green-400",children:a("predict.redeem.success")}),c==="delayed"&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-400",children:a("predict.trade.resultDelayed",{defaultValue:"Your trade was submitted successfully. Confirmation is taking a little longer."})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[c!=="success"&&c!=="delayed"&&jsxRuntime.jsx(ui$1.Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!_,isLoading:c==="pending"||c==="confirming",onPress:X,spinner:jsxRuntime.jsx(ui$1.Spinner,{size:"sm",color:"current"}),children:a("predict.redeem.confirm")}),o&&c!=="success"&&c!=="delayed"&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a("common.cancel")}),(c==="success"||c==="delayed")&&o&&jsxRuntime.jsx(ui$1.Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:a("common.ok")})]})]})}function So({label:e,value:t,valueClassName:r="text-white"}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm text-zinc-400",children:e}),jsxRuntime.jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function el(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var rl="predict-redeem";function Ga({id:e=rl}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Nm,{...t})})}function Nm({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui$1.useScreen();return e?jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui$1.ModalContent,{children:jsxRuntime.jsxs("div",{className:o?"":"p-2",children:[jsxRuntime.jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsxRuntime.jsx("h3",{className:"text-lg font-semibold text-white",children:n("predict.redeem.title")}),jsxRuntime.jsx("p",{className:"text-sm text-zinc-400 mt-1",children:n("predict.redeem.description")})]}),jsxRuntime.jsx(ja,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Qa(e){return e?.trim().toLowerCase()??""}function qa(e,t){let r=e.provider_meta?.[t];return typeof r=="string"?r:""}function il(e,t){return !!(e&&t&&e.trim().toLowerCase().includes(t))}function tf(e,t){let r=Qa(e.side);if(r==="yes"||r==="no")return r;if(r==="over"||r==="odd")return "yes";if(r==="under"||r==="even")return "no";let n=[t.outcomes?.[0]?.label,qa(t,"polymarket.groupItemTitle"),qa(t,"polymarket.groupItemTitleTrans"),qa(t,"polymarket.group_item_title_trans")],o=[t.outcomes?.[1]?.label];return n.some(a=>il(a,r))?"yes":o.some(a=>il(a,r))?"no":null}function Xa({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:n=100,onSuccess:o}){let{t:a,i18n:i}=i18n.useTranslation(),s=react.useRef(o);s.current=o;let{status:l}=walletConnector.useAuth(),u=walletConnector.useWallets(),p=reactPredict.usePredictClient(),c=react.useContext(reactPredict.PolymarketContext),f=reactQuery.useQueryClient(),{start:d}=reactPredict.useTradeResultConfirmation(),m=e.source,v=m==="polymarket",k=u.find(R=>R.chainNamespace===types.ChainNamespace.SOLANA&&R.isConnected),g=u.find(R=>R.chainNamespace===types.ChainNamespace.EVM&&R.isConnected&&"switchChain"in R),S=l==="authenticated",h=k?.address,x=g?.address,[b,y]=react.useState(t),[P,N]=react.useState("market"),[w,M]=react.useState(NaN),[L,A]=react.useState(NaN),[X,_]=react.useState(false),[U,q]=react.useState(false),[ee,Y]=react.useState(null),[re,oe]=react.useState(null),[ie,he]=react.useState(false),[Pe,dt]=react.useState(false),[He,Ve]=react.useState("1h"),[E,at]=react.useState(30),[Oe,be]=react.useState("minutes"),gt=react.useMemo(()=>Gr(a,i),[i,a]),we=true,Ue=react.useCallback(async(R,Le)=>{let _e=wr({messages:gt});_e.submitted(),await d({source:m,user:m==="kalshi"?h:x,kalshiUser:we?h:void 0,polymarketUser:x,marketSlug:e.slug,eventSlug:e.event_slug,expectation:R,getOrdersHeaders:Le})==="confirmed"?_e.completed():_e.delayed();},[d,we,x,e.event_slug,e.slug,m,gt,h]),C=react.useMemo(()=>{if(m!=="polymarket")return;let R=e.provider_meta?.["polymarket.clobTokenIds"];return R?(typeof R=="string"?JSON.parse(R):R)[b==="yes"?0:1]:void 0},[m,e.provider_meta,b]),{data:T,isLoading:$}=reactPredict.useTickSize(C),Z=reactPredict.normalizePolymarketTickSize(T?.minimum_tick_size),{data:ue,isLoading:Me}=reactPredict.useFeeRate(C),it=String(ue?.base_fee??0),{data:Rt}=reactPredict.useRebateConfig(),st=Rt?.builder_enabled&&Rt.builder_code?Rt.builder_code:void 0,yt=false,Qe=null,Yt=false,We,et,ve;try{let R=cr();we=R.enableKalshi,yt=R.kalshiKycVerified,Qe=R.kalshiKycUrl,Yt=R.polymarketSetupVerified,We=R.polymarketSafeAddress,et=R.polymarketWalletKind,ve=R.polymarketWalletAddress;}catch{}let ut=m==="kalshi"&&!yt,kt=m==="polymarket"&&!Yt,Ne=react.useCallback(async()=>{if(!g||!c)return null;let R=await g.getEip1193Provider();if(!R)return null;let Le=et==="deposit"&&!!ve,_e=!Le&&!!We,ze={address:g.address,signatureType:Le?3:_e?2:0,signTypedData:async(ht,Zt,Wt,$e)=>{let sr=[];"name"in ht&&sr.push({name:"name",type:"string"}),"version"in ht&&sr.push({name:"version",type:"string"}),"chainId"in ht&&sr.push({name:"chainId",type:"uint256"}),"verifyingContract"in ht&&sr.push({name:"verifyingContract",type:"address"}),"salt"in ht&&sr.push({name:"salt",type:"bytes32"});let to={EIP712Domain:sr,...Zt};return await R.request({method:"eth_signTypedData_v4",params:[g.address,JSON.stringify({domain:ht,types:to,primaryType:Wt,message:$e})]})}};return c.credentials??await c.authenticate(ze)},[We,et,ve,g,c]),{data:tt}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:m,outcome:b},{enabled:e.status==="open"}),Te=react.useMemo(()=>{let R=reactPredict.pickBestBid(tt,b);if(R!=null&&R>0)return R;let Le=b==="yes"?0:1,_e=e.outcomes[Le];return _e?.best_bid??_e?.price??.5},[tt,e.outcomes,b]),Lt=m==="kalshi"?h??"":x??"",{data:I,isLoading:Ie}=reactPredict.usePositionsMulti({kalshi_user:m==="kalshi"?Lt:void 0,polymarket_user:m==="polymarket"?Lt:void 0},{enabled:!!Lt,refetchInterval:3e4}),Xe=Qa(r),pn=r?.trim(),B=react.useMemo(()=>I?I.positions.find(R=>R.market?.slug!==e.slug?false:Xe?Qa(R.side)===Xe:tf(R,e)===b)??null:null,[I,e,b,Xe]),De=pn||B?.side||b,St=react.useCallback(async()=>{let R=await Ne();return R?await reactPredict.buildPolymarketL2Headers(R.address,{apiKey:R.apiKey,secret:R.secret,passphrase:R.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Ne]),{data:Ft,isLoading:mn}=reactPredict.useAvailableShares({source:m,user:Lt,market:e.slug,side:De},m==="polymarket"?{getHeaders:St}:void 0,{enabled:!!Lt&&!!e.slug,refetchOnMount:"always"}),na=e.provider_meta?.["dflow.yesMint"]??"",oa=e.provider_meta?.["dflow.noMint"]??"",qt=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ir=e.provider_meta?.["dflow.collateralMint"]||"",aa=b==="yes"?na:oa,pt=react.useMemo(()=>m==="polymarket"?reactPredict.getPolymarketSharesPrecision(Z):Ft?.precision??0,[m,Z,Ft?.precision]),_t=Ft?.active_order_shares??0,Dr=m==="polymarket"&&!!B?.size&&(Ft?.total_shares??0)<=0&&(Ft?.available_shares??0)<=0,fn=Dr?B?.size??0:0,Ar=Dr?fn:Ft?.total_shares??0,ir=Dr?Math.max(0,fn-_t):Ft?.available_shares??0,ia=mn||Ie,Jn=B?.market?.provider_meta,Fr=Jn?.["dflow.outcomeMint"]||aa,Qt=Jn?.["dflow.collateralMint"]||Ir,hr=Fr,br=Qt||qt,vr=react.useMemo(()=>isNaN(w)||w<=0?"0":String(Math.round(w*1e6)),[w]),gn=m==="kalshi"&&!!hr&&!!br&&!!h&&vr!=="0",{refetch:hn}=reactPredict.useDFlowQuote({inputMint:hr,outputMint:br,amount:vr,userPublicKey:h??"",slippageBps:100},{enabled:gn}),Br=react.useMemo(()=>isNaN(w)||w<=0?0:w,[w]),Ot=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:tt,outcome:b,side:"sell",sharesNeeded:Br,slippageBps:n}),[tt,b,Br,n]),D=react.useMemo(()=>Ot.status==="ok"&&Ot.worstPrice!=null&&Ot.worstPrice>0?Ot.worstPrice:Te,[Ot,Te]),Ae=react.useMemo(()=>P==="limit"&&v&&!isNaN(L)?L:D,[P,v,L,D]),Re=react.useMemo(()=>isNaN(w)||w<=0?0:w*Ae,[w,Ae]),It=react.useMemo(()=>m!=="polymarket"?0:wa({grossReturn:Re,pricePerShare:Ae,feeRateBps:Number(it)}),[m,Re,Ae,it]),bn=react.useMemo(()=>Math.max(0,Re-It),[Re,It]),Xt=react.useCallback(R=>{y(R),A(NaN),M(NaN),q(false);},[]);react.useEffect(()=>{Xt(t);},[t,Xt]);let Jt=react.useCallback(R=>{N(R);},[]);react.useEffect(()=>{P==="limit"&&A(Math.round(Te*1e4)/1e4);},[P,b,Te]);let mt=react.useCallback(R=>{if(q(false),isNaN(R)){M(NaN);return}M(xe(Math.max(0,R),pt));},[pt]),sa=react.useCallback(()=>{q(true),M(xe(ir,pt));},[ir,pt]),Zn=react.useCallback(R=>{if(isNaN(R)){A(NaN);return}A(Math.round(R*1e4)/1e4);},[]),Ut=react.useCallback(()=>{M(NaN),A(NaN),N("market"),q(false),dt(false),Ve("1h"),at(30),be("minutes");},[]),Hr=react.useMemo(()=>{let R=[];return isNaN(w)||w<=0?R.push(a("predict.trade.minQuantity",{amount:xn})):w<xn&&R.push(a("predict.trade.minQuantity",{amount:xn})),e.status!=="open"&&R.push(a("predict.trade.marketNotActive")),!isNaN(w)&&w>0&&!U&&w>ir&&R.push(a("predict.trade.insufficientSharesDetail",{total:xe(Ar,pt).toFixed(pt),active:xe(_t,pt).toFixed(pt),available:xe(ir,pt).toFixed(pt)})),P==="limit"&&v&&(isNaN(L)||L<.01||L>.99)&&R.push(a("predict.trade.limitPriceRange")),P==="limit"&&v&&Pe&&He==="custom"&&(isNaN(E)||E<=0)&&R.push(a("predict.trade.expiration.invalidDate")),m==="polymarket"&&P==="market"&&!isNaN(w)&&w>0&&(Ot.status==="insufficient_liquidity"?R.push(a("predict.trade.insufficientLiquidity",{available:xe(Ot.totalAvailable,2)})):Ot.status==="exceeds_slippage"&&R.push(a("predict.trade.priceImpactTooHigh",{impact:(Ot.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:R.length===0,errors:R}},[w,e.status,ir,Ar,_t,U,P,v,L,Pe,He,E,pt,m,Ot,n,a]),{mutateAsync:Ur}=reactPredict.useDFlowSubmit(),{data:xr}=reactPredict.useOrder({id:ee??"",source:m},{enabled:!!ee}),eo=react.useCallback(async()=>{if(!re||!h||!k)return;let{cashAmount:R,collateral:Le}=re;oe(null);try{let ze=(await p.createDFlowQuote({inputMint:Le,outputMint:qt,amount:R,userPublicKey:h,slippageBps:100}))?.transaction;if(!ze)return;let ht=Uint8Array.from(atob(ze),Wt=>Wt.charCodeAt(0)),Zt=await k.signTransaction(ht);await Ur({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:h,input_mint:Le,output_mint:qt,amount:R,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[re,h,k,p,Ur,qt]),yr=react.useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);react.useEffect(()=>{if(!xr||!ee)return;let{status:R}=xr;R==="closed"?(Y(null),re?eo().finally(()=>{_(false),Ue("sell-market"),yr(),Ut(),s.current?.();}):(_(false),Ue("sell-market"),yr(),Ut(),s.current?.())):(R==="failed"||R==="expired")&&(_(false),Y(null),oe(null),ui$1.toast.error(a("predict.trade.submitError")));},[xr,ee,re,eo,Ue,yr,Ut,a]);let Wr=react.useCallback(async()=>{if(!h||!k)return;if(!hr||!br){ui$1.toast.error("Missing token mint addresses"),_(false);return}if(!yt){he(true),_(false);return}let _e=(await hn()).data,ze=_e?.transaction;if(!ze){ui$1.toast.error(a("predict.trade.submitError")),_(false);return}if(Qt&&Qt!==qt){let $e=String(_e?.outAmount??"");$e&&$e!=="0"&&oe({cashAmount:$e,collateral:Qt});}let ht=Uint8Array.from(atob(ze),$e=>$e.charCodeAt(0)),Zt=await k.signTransaction(ht),Wt=await Ur({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:h,input_mint:hr,output_mint:br,amount:vr,price:String(Te),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Y(Wt.signature);},[h,k,hn,Ur,hr,br,vr,Te,b,e.slug,Qt,qt,a,yt]),zr=react.useCallback(async()=>{if(!g||!c)return;let R=g.chain,Le=R!==types.Chain.POLYGON;Le&&await g.switchChain(types.Chain.POLYGON);try{let _e=await g.getEip1193Provider();if(!_e){ui$1.toast.error(a("predict.trade.submitError")),_(!1);return}let ze=et==="deposit"&&!!ve,ht=!ze&&!!We,Zt=ze?ve:We,Wt={address:g.address,signatureType:ze?3:ht?2:0,signTypedData:async(zt,no,da,ua)=>{let $r=[];"name"in zt&&$r.push({name:"name",type:"string"}),"version"in zt&&$r.push({name:"version",type:"string"}),"chainId"in zt&&$r.push({name:"chainId",type:"uint256"}),"verifyingContract"in zt&&$r.push({name:"verifyingContract",type:"address"}),"salt"in zt&&$r.push({name:"salt",type:"bytes32"});let bd={EIP712Domain:$r,...no};return await _e.request({method:"eth_signTypedData_v4",params:[g.address,JSON.stringify({domain:zt,types:bd,primaryType:da,message:ua})]})}},$e=await Ne();if(!$e){ui$1.toast.error(a("predict.trade.submitError")),_(!1);return}let sr=b==="yes"?0:1,to="",ro=e.provider_meta?.["polymarket.clobTokenIds"];ro&&(to=(typeof ro=="string"?JSON.parse(ro):ro)[sr]??"");let es=e.provider_meta?.["polymarket.negRisk"]??!1,gd=P==="limit"&&!isNaN(L)?L:D,hd=Sn(gd,Z),la={tokenId:to,price:hd,size:w,side:"SELL",orderType:P==="limit"?Pe?"GTD":"GTC":"FOK",tickSize:Z,negRisk:es,...Zt&&{funderAddress:Zt},...st&&{builderCode:st},...P==="limit"&&Pe&&{expiration:kn(He,E,Oe)}},ca;if(ze)ca=await reactPredict.buildSignedV2OrderPayload({signer:Wt,depositWalletAddress:Zt,input:la,owner:$e.apiKey});else {let zt=reactPredict.buildCtfExchangeDomain(es),no=reactPredict.buildOrderMessage({...la,signerAddress:Wt.address,signatureType:Wt.signatureType,feeRateBps:it}),da=await Wt.signTypedData(zt,reactPredict.CTF_ORDER_TYPES,"Order",no),ua=reactPredict.buildSignedOrder(no,da,la.orderType);ca=reactPredict.buildClobPayload(ua,$e.apiKey);}await p.executePolymarketOrder({payload:ca,l2_api_key:$e.apiKey,l2_secret:$e.secret,l2_passphrase:$e.passphrase,signer_address:$e.address,owner:$e.apiKey}),yr(),Ue(P==="limit"?"sell-limit":"sell-market",async()=>await reactPredict.buildPolymarketL2Headers($e.address,{apiKey:$e.apiKey,secret:$e.secret,passphrase:$e.passphrase,method:"GET",requestPath:"/data/orders"})),Ut(),_(!1),s.current?.();}finally{Le&&R&&g.switchChain(R).catch(()=>{});}},[g,c,Ne,b,e,P,Ue,L,D,w,p,yr,Pe,He,E,Oe,Ut,a,Z,it,We,et,ve,st]),Dt=react.useCallback(async()=>{if(!(!Hr.isValid||!S)){_(true),Y(null),he(false);try{m==="kalshi"?await Wr():await zr();}catch(R){let Le=R instanceof Error?R.message:"",_e=m==="polymarket"&&Le?Pn(Le,a,"sell"):Le||void 0;ui$1.toast.error(_e||a("predict.trade.submitError")),_(false);}}},[Hr.isValid,S,m,Wr,zr,a]);return {outcome:b,orderType:P,quantity:w,limitPrice:L,shares:Br,effectivePrice:Ae,grossReturn:Re,estimatedFee:It,estimatedReturn:bn,pricePerShare:Te,isMarketDataLoading:m==="polymarket"&&(Me||$),isSubmitting:X,authStatus:l,validation:Hr,supportsLimitOrder:v,kycRequired:ie,needsKyc:ut,needsSetup:kt,kycUrl:Qe,totalShares:Ar,activeOrderShares:_t,availableShares:ir,isAvailableLoading:ia,isSellAll:U,precision:pt,expirationEnabled:Pe,expirationPreset:He,customDuration:E,customDurationUnit:Oe,setOutcome:Xt,setOrderType:Jt,setQuantity:mt,setLimitPrice:Zn,setSellAll:sa,setExpirationEnabled:dt,setExpirationPreset:Ve,setCustomDuration:at,setCustomDurationUnit:be,submit:Dt}}var pf=["5m","1h","12h","24h","eod","custom"],mf={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},ff=["minutes","hours","days"],gf={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},hf={maximumFractionDigits:0},Ln="-";function ei({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:a,limitPrice:i,effectivePrice:s,grossReturn:l,estimatedFee:u,estimatedReturn:p,isMarketDataLoading:c,isSubmitting:f,authStatus:d,isValid:m,validationErrors:v,supportsLimitOrder:k,kycRequired:g,needsKyc:S,needsSetup:h,onSetupRequired:x,kycUrl:b,totalShares:y,activeOrderShares:P,availableShares:N,isAvailableLoading:w,precision:M,expirationEnabled:L,expirationPreset:A,customDuration:X,customDurationUnit:_,oddsFormatter:U,outcomeLabels:q,onOutcomeChange:ee,onOrderTypeChange:Y,onQuantityChange:re,onLimitPriceChange:oe,onSellAll:ie,onExpirationEnabledChange:he,onExpirationPresetChange:Pe,onCustomDurationChange:dt,onCustomDurationUnitChange:He,onSubmit:Ve}){let{t:E}=i18n.useTranslation(),[at,Oe]=react.useState(false),[be,gt]=react.useState(true),we=ui$1.useDisclosure(),[Ue,C]=react.useState(""),T=react.useRef(false);react.useEffect(()=>{T.current||C(isNaN(a)?"":String(a));},[a]);let[$,Z]=react.useState(""),ue=react.useRef(false);react.useEffect(()=>{ue.current||(isNaN(i)?Z(""):Z(String(parseFloat((i*100).toFixed(2)))));},[i]);let Me=react.useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(Z(I),I===""||I==="."){oe(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||oe(Xe/100);},[oe]),it=react.useCallback(I=>{let Ie=new RegExp(`^\\d*\\.?\\d{0,${M}}$`);if(I!==""&&!Ie.test(I))return;if(C(I),Oe(false),I===""||I==="."){re(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||re(Xe);},[re,M]);react.useEffect(()=>{g&&!we.isOpen&&we.onOpen();},[g,we]);let Rt=react.useMemo(()=>{let I=n==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[n,t]),st=n==="yes"?t.yesBid:t.noBid,yt=st!=null&&U?U(Number(st)):Rt!=null?`${Rt} \xA2`:null,Qe=Number.isFinite(s)?parseFloat((s*100).toFixed(2)):null,Yt=Number.isFinite(s)&&U?U(s):Qe!=null?`${Qe} \xA2`:null,We=!isNaN(a)&&a>0,et=We&&a>0?p/a:0,ve=et>0&&U?U(et):et>0?`${parseFloat((et*100).toFixed(2))} \xA2`:Ln,ut=d==="authenticated",kt=d==="authenticating"||d==="deauthenticating",Ne=ut&&(S||h),tt=react.useCallback(I=>q?.[I]??E(I==="yes"?"predict.trade.yes":"predict.trade.no"),[q,E]),Te=react.useMemo(()=>{if(kt)return E("predict.trade.checkingLogin");if(!ut)return E("predict.trade.loginToTrade");if(S)return E("predict.trade.kycRequired");if(h)return E("predict.trade.setupRequired");if(w)return E("predict.trade.loadingBalance");if(c)return E("predict.trade.loadingMarketData");if(f)return E("predict.trade.submitting");if(g)return E("predict.trade.kycRequired");if(!We)return E("predict.trade.enterAmount");let I=tt(n);return `${E("predict.trade.sell")} ${I}`},[kt,ut,S,h,w,c,f,g,We,n,tt,E]),Lt=()=>{if(!ut){Oe(false),Ve();return}if(S){we.onOpen();return}if(h&&x){Oe(false),x();return}if(g){we.onOpen();return}if(!m){Oe(true);return}Oe(false),Ve();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&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.jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsxRuntime.jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxRuntime.jsxs("span",{className:"text-bearish",children:[E("predict.trade.sell")," ",tt(n)]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[k?jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:I=>Y(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:E("predict.trade.market")},"market"),jsxRuntime.jsx(ui$1.Tab,{title:E("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),o==="limit"&&k?jsxRuntime.jsx(ui$1.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:$,onChange:I=>Me(I.target.value),onFocus:()=>{ue.current=true;},onBlur:()=>{ue.current=false,isNaN(i)?Z(""):Z(String(parseFloat((i*100).toFixed(2))));},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):yt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:yt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let Ie=I==="yes"?t.yesBid:t.noBid;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>ee(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===I?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:tt(I)}),Ie!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:U?U(Number(Ie)):`${parseFloat((Number(Ie)*100).toFixed(2))}\xA2`})]})},I)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.sellContracts")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let Ie=Math.pow(10,M);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{re(Math.floor(N*I/100*Ie)/Ie);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[I,"%"]},I)}),jsxRuntime.jsx("button",{type:"button",onClick:ie,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:E("common.all")})]})]}),jsxRuntime.jsx(ui$1.StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ue,onChange:I=>it(I.target.value),onFocus:()=>{T.current=true;},onBlur:()=>{T.current=false,C(isNaN(a)?"":String(a));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),at&&v.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:v.map(I=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:I},I))})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:w?"\u2013":`${xe(y,M).toFixed(M)}${E("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.activeOrders")}),jsxRuntime.jsx("span",{className:"tabular-nums text-warning",children:w?"\u2013":P>0?`-${xe(P,M).toFixed(M)}${E("predict.trade.sharesUnit")}`:`0${E("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.availableShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-success font-medium",children:w?"\u2013":`${xe(N,M).toFixed(M)}${E("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estReturn")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?`$${p.toFixed(2)}`:"\u2013"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>gt(I=>!I),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:E("predict.trade.odds")}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:ui$1.cn("h-3.5 w-3.5 transition-transform",be&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:U&&Number.isFinite(s)?Yt:Qe!=null?E("predict.trade.chance",{percent:Qe}):Ln})]}),be&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Pr(a):Ln})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:We?`$${l.toFixed(2)}`:Ln})]}),(u??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${(u??0).toFixed(2)}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estReturnAfterFees")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:We?`$${p.toFixed(2)}`:Ln})]}),(u??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:ve})]})]})]}),o==="limit"&&k&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:E("predict.trade.setExpiration")}),jsxRuntime.jsx(ui$1.StyledSwitch,{size:"sm",color:"primary",isSelected:L,onValueChange:he,"aria-label":E("predict.trade.setExpiration")})]}),L&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui$1.Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[A],onSelectionChange:I=>{let Ie=Array.from(I)[0];Ie&&Pe(Ie);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pf.map(I=>jsxRuntime.jsx(ui$1.SelectItem,{children:E(mf[I])},I))}),A==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui$1.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(X)?void 0:X,onValueChange:dt,minValue:1,step:1,formatOptions:hf,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsxRuntime.jsx(ui$1.Select,{"aria-label":"Duration unit",selectedKeys:[_],onSelectionChange:I=>{let Ie=Array.from(I)[0];Ie&&He(Ie);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:ff.map(I=>jsxRuntime.jsx(ui$1.SelectItem,{children:E(gf[I])},I))})]})]})]}),jsxRuntime.jsx(ui$1.Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:kt||ut&&!Ne&&(w||c||!We||f),isLoading:kt||ut&&!Ne&&(f||w||c),spinner:jsxRuntime.jsx(ui$1.Spinner,{size:"sm",color:"current"}),onPress:Lt,children:Te})]}),jsxRuntime.jsx(Nn,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:b})]})}function _n({event:e,market:t,variant:r,initialOutcome:n,initialPositionSide:o,chain:a,slippageBps:i,onOutcomeChange:s,onSetupRequired:l,onSuccess:u,oddsFormatter:p,outcomeLabels:c}){let{outcome:f,orderType:d,quantity:m,limitPrice:v,effectivePrice:k,grossReturn:g,estimatedFee:S,estimatedReturn:h,pricePerShare:x,isMarketDataLoading:b,isSubmitting:y,authStatus:P,validation:N,supportsLimitOrder:w,kycRequired:M,needsKyc:L,needsSetup:A,kycUrl:X,totalShares:_,activeOrderShares:U,availableShares:q,isAvailableLoading:ee,precision:Y,expirationEnabled:re,expirationPreset:oe,customDuration:ie,customDurationUnit:he,setOutcome:Pe,setOrderType:dt,setQuantity:He,setLimitPrice:Ve,setSellAll:E,setExpirationEnabled:at,setExpirationPreset:Oe,setCustomDuration:be,setCustomDurationUnit:gt,submit:we}=Xa({market:t,initialOutcome:n,initialPositionSide:o,slippageBps:i,onSuccess:u}),Ue=walletConnector.useAuthCallback(we),C=react.useCallback(Z=>{Pe(Z),s?.(Z);},[Pe,s]),T=react.useMemo(()=>e?lo(e):void 0,[e]),$=react.useMemo(()=>co(t,{yesBid:f==="yes"?x:void 0,noBid:f==="no"?x:void 0}),[t,f,x]);return jsxRuntime.jsx(ei,{event:T,market:$,variant:r,outcome:f,orderType:d,quantity:m,limitPrice:v,effectivePrice:k,grossReturn:g,estimatedFee:S,estimatedReturn:h,isMarketDataLoading:b,isSubmitting:y,authStatus:P,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:w,kycRequired:M,needsKyc:L,needsSetup:A,onSetupRequired:l,kycUrl:X,totalShares:_,activeOrderShares:U,availableShares:q,isAvailableLoading:ee,precision:Y,expirationEnabled:re,expirationPreset:oe,customDuration:ie,customDurationUnit:he,oddsFormatter:p,outcomeLabels:c,onOutcomeChange:C,onOrderTypeChange:dt,onQuantityChange:He,onLimitPriceChange:Ve,onSellAll:E,onExpirationEnabledChange:at,onExpirationPresetChange:Oe,onCustomDurationChange:be,onCustomDurationUnitChange:gt,onSubmit:Ue})}var No="predict-sell";function ti({id:e=No}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Nf,{...t})})}function Nf({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui$1.useScreen();return e?jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui$1.ModalContent,{children:jsxRuntime.jsxs("div",{className:o?"":"p-2",children:[jsxRuntime.jsx(_n,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialPositionSide:e.initialPositionSide,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),jsxRuntime.jsx("div",{className:"px-4 pb-4",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var oi=40,Co=36,Dn=480,ai=Dn-Co;function ii({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=i18n.useTranslation(),[o,a]=react.useState("positions"),i=react.useMemo(()=>e.markets?.map(c=>c.slug)??[],[e.markets]),{data:s}=reactPredict.usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=react.useMemo(()=>!s?.positions||!t?0:i.length===0?s.positions.length:s.positions.filter(c=>c.market&&i.includes(c.market.slug)).length,[s?.positions,i,t]),p=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:p.map(c=>jsxRuntime.jsx("button",{type:"button",onClick:()=>a(c.key),className:ui$1.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===c.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:c.label},c.key))}),t?jsxRuntime.jsxs("div",{style:{height:Dn},children:[o==="positions"&&jsxRuntime.jsx(_f,{source:e.source,walletAddress:t,marketSlugs:i}),o==="orders"&&jsxRuntime.jsx(If,{source:e.source,walletAddress:t,marketSlugs:i,onCancelOrder:r}),o==="trades"&&jsxRuntime.jsx(Ff,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Dn},children:n("predict.trade.connectWallet")})]})}function _f({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=i18n.useTranslation(),{data:o,isLoading:a}=reactPredict.usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),i=react.useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[o?.positions,r]);return a?jsxRuntime.jsx(li,{}):i.length===0?jsxRuntime.jsx(si,{message:n("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Co},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:n("predict.positions.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.markPrice")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:n("predict.positions.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:n("predict.positions.estSettlement")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:ai},rowComponent:Of,rowCount:i.length,rowHeight:oi,rowProps:{positions:i,closeLabel:n("predict.positions.close")}})]})}function Of({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let a=o.pnl??0,i=o.pnl_percent??0,s=o.avg_price??0,l=o.current_price??0,u=a>0?"text-success":a<0?"text-danger":"text-foreground",p=a>0?"+":"",c=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,d=o.size,m=o.size*l,v=o.market?.end_at?Uf(o.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsxRuntime.jsx("span",{className:ui$1.cn("text-[10px] font-medium",f.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:f})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:o.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",m.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Mo(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Mo(l)}),jsxRuntime.jsxs("div",{className:ui$1.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[p,"$",Math.abs(a).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:v}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:n})})]})}function If({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=i18n.useTranslation(),{data:a,isLoading:i,fetchNextPage:s,hasNextPage:l}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),u=reactPredict.useCancelOrder(),p=react.useMemo(()=>{let g=a?.pages?.flatMap(x=>x.items)??[],S=new Set(["live","open","submitted","pending"]),h=g.filter(x=>S.has(x.status));return r.length>0&&(h=h.filter(x=>x.market_id&&r.includes(x.market_id))),h},[a?.pages,r]),c=react.useCallback(g=>{n?n(g.id):u.mutate({source:g.source,id:g.id});},[n,u]),f=p.length,d=f+(l?1:0),m=react.useCallback(g=>g<f,[f]),v=react.useCallback(async()=>{await s();},[s]),k=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:v,rowCount:d,threshold:5});return i?jsxRuntime.jsx(li,{}):p.length===0&&!l?jsxRuntime.jsx(si,{message:o("predict.openOrders.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Co},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:o("predict.openOrders.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:o("predict.openOrders.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.openOrders.filled")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:o("predict.openOrders.status")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:ai},onRowsRendered:k,rowComponent:Df,rowCount:d,rowHeight:oi,rowProps:{orders:p,itemCount:f,onCancel:c,isCancelling:u.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Df({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:a,cancelLabel:i}){if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui$1.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:s.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?Mo(parseFloat(s.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(Af,{status:s.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>o(s),disabled:a,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:a?jsxRuntime.jsx(ui$1.Spinner,{size:"sm"}):i})})]})}function Af({status:e}){return jsxRuntime.jsx("span",{className:ui$1.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function Ff({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:n,isLoading:o,fetchNextPage:a,hasNextPage:i}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),s=react.useMemo(()=>n?.pages?.flatMap(d=>d.items)??[],[n?.pages]),l=s.length,u=l+(i?1:0),p=react.useCallback(d=>d<l,[l]),c=react.useCallback(async()=>{await a();},[a]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:c,rowCount:u,threshold:5});return o?jsxRuntime.jsx(li,{}):s.length===0&&!i?jsxRuntime.jsx(si,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Co},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:ai},onRowsRendered:f,rowComponent:Bf,rowCount:u,rowHeight:oi,rowProps:{trades:s,itemCount:l}})]})}function Bf({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let a=o.side?.toUpperCase()==="BUY",i=Hf(o.timestamp),s=o.price??0,l=o.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui$1.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",a?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:o.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:o.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Mo(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:i})]})}function si({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Dn},children:e})}function li(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Dn},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Mo(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Hf(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${a}`}function Uf(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var bl=`
73
+ `}),jsxRuntime.jsxs("div",{className:"evt-hero-outer",children:[jsxRuntime.jsxs("div",{className:"evt-hero-left",style:{minWidth:0,flex:1,animation:"evtHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsxRuntime.jsx("div",{className:"evt-hero-live",style:{marginBottom:16},children:jsxRuntime.jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsxRuntime.jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"evt-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsxRuntime.jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"evt-live-breathe 2.4s ease-in-out infinite"}})]}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)",letterSpacing:"0.025em"},children:t("predict.events.liveBadge")})]})}),jsxRuntime.jsxs("h1",{className:"evt-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxRuntime.jsxs("span",{style:{color:"#fff"},children:[t("predict.events.titlePrefix")," "]}),jsxRuntime.jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.events.titleHighlight")})]}),jsxRuntime.jsx("p",{className:"evt-hero-subtitle evt-hero-subtitle-text",style:{lineHeight:1.6,color:"var(--color-text-muted)",maxWidth:460},children:String(t("predict.events.heroSubtitle")).split(`
74
+ `).map((r,o)=>jsxRuntime.jsxs("span",{children:[o>0&&jsxRuntime.jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsxRuntime.jsx("div",{className:"evt-stat-grid",style:e?{animation:"evtStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{},children:pm.map((r,o)=>jsxRuntime.jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"hsl(var(--heroui-foreground) / 0.02)",borderRight:o%2===0?"1px solid var(--color-border-subtle)":"none",borderBottom:o<2?"1px solid var(--color-border-subtle)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsxRuntime.jsx("div",{className:"evt-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsxRuntime.jsx("div",{style:{height:16,width:56,borderRadius:4,background:"hsl(var(--heroui-foreground) / 0.06)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsxRuntime.jsx("div",{className:"evt-stat-label",style:{fontWeight:500,color:e?"var(--color-text-muted)":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsxRuntime.jsx("div",{style:{height:10,width:64,borderRadius:4,background:"hsl(var(--heroui-foreground) / 0.04)",animation:"evtStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function ji({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i,i18n:s}=i18n.useTranslation(),{mutateAsync:a}=reactPredict.useRedeemPosition(),{start:l}=reactPredict.useTradeResultConfirmation(),{evmAddress:p}=cr(),d=walletConnector.useWallets(),[c,m]=react.useState("idle"),[u,f]=react.useState(null),g=t.provider_meta?.["polymarket.conditionId"],b=t.provider_meta?.["polymarket.negRisk"]??false,h=p??"",S=react.useMemo(()=>Gr(i),[s,i]),x=react.useMemo(()=>d.find(G=>G.chainNamespace===types.ChainNamespace.EVM&&G.isConnected),[d]),y=Za(r.side,t.outcomes),k=t.outcomes?.[y]?.label??r.side,P=t.result!=null?Za(t.result,t.outcomes):-1,N=(P>=0?t.outcomes?.[P]:void 0)?.label??t.result??"",w=t.result!=null?y===P:true,R=react.useMemo(()=>w?r.size:0,[w,r.size]),A=react.useCallback(async()=>{if(!(!g||!h||!x)){m("pending"),f(null);try{let G=await x.getEip1193Provider();if(!G)throw new Error("EIP-1193 provider unavailable");await a({wallet_address:h,condition_id:g,neg_risk:b,signMessage:async W=>await G.request({method:"personal_sign",params:[W,h]}),signTypedData:async W=>await G.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(W)]})}),m("confirming");let U=Mr({messages:S});U.submitted(),await l({source:r.source,user:h,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem",expectedPayout:R})==="confirmed"?(m("success"),U.completed()):(m("delayed"),U.delayed()),o?.();}catch(G){m("error"),f(G instanceof Error?G.message:i("predict.redeem.error"));}}},[g,h,b,x,a,S,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,R,o,i]),X=walletConnector.useAuthCallback(A),L=c==="idle"&&!!g&&!!h&&!!x&&r.redeemable;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[jsxRuntime.jsx("div",{className:"text-base font-medium text-text-primary",children:e?.title??t.question}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 rounded-xl bg-surface-strong/40 p-3",children:[jsxRuntime.jsx(Nn,{label:i("predict.positions.side"),value:k,valueClassName:w?"text-success":"text-danger"}),t.result!=null&&jsxRuntime.jsx(Nn,{label:i("predict.redeem.result"),value:N,valueClassName:"text-success"}),jsxRuntime.jsx(Nn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsxRuntime.jsx(Nn,{label:i("predict.redeem.expectedPayout"),value:`$${R.toFixed(2)}`,valueClassName:R>0?"text-success":"text-text-secondary"})]}),!w&&R===0&&jsxRuntime.jsx("p",{className:"text-sm text-text-muted",children:i("predict.redeem.noWinnings")}),c==="error"&&u&&jsxRuntime.jsx("p",{className:"text-sm text-danger",children:u}),c==="success"&&jsxRuntime.jsx("p",{className:"text-sm text-success",children:i("predict.redeem.success")}),c==="delayed"&&jsxRuntime.jsx("p",{className:"text-sm text-text-secondary",children:i("predict.trade.resultDelayed",{defaultValue:"Your trade was submitted successfully. Confirmation is taking a little longer."})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[c!=="success"&&c!=="delayed"&&jsxRuntime.jsx(ui.Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!L,isLoading:c==="pending"||c==="confirming",onPress:X,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&c!=="success"&&c!=="delayed"&&jsxRuntime.jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),(c==="success"||c==="delayed")&&n&&jsxRuntime.jsx(ui.Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Nn({label:e,value:t,valueClassName:r="text-text-primary"}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:e}),jsxRuntime.jsx("span",{className:`text-sm font-medium ${r}`,children:t})]})}function Za(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let o=t.findIndex(n=>n.label.toLowerCase()===r);return o>=0?o:1}var tl="predict-redeem";function Gi({id:e=tl}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Tm,{...t})})}function Tm({params:e,isOpen:t,onOpenChange:r}){let{t:o}=i18n.useTranslation(),{isMobile:n}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:ui.THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{className:n?"":"p-2",children:[jsxRuntime.jsxs("div",{className:"px-4 pt-4 pb-1",children:[jsxRuntime.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:o("predict.redeem.title")}),jsxRuntime.jsx("p",{className:"text-sm text-text-secondary mt-1",children:o("predict.redeem.description")})]}),jsxRuntime.jsx(ji,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Qi(e){return e?.trim().toLowerCase()??""}function qi(e,t){let r=e.provider_meta?.[t];return typeof r=="string"?r:""}function il(e,t){return !!(e&&t&&e.trim().toLowerCase().includes(t))}function sf(e,t){let r=Qi(e.side);if(r==="yes"||r==="no")return r;if(r==="over"||r==="odd")return "yes";if(r==="under"||r==="even")return "no";let o=[t.outcomes?.[0]?.label,qi(t,"polymarket.groupItemTitle"),qi(t,"polymarket.groupItemTitleTrans"),qi(t,"polymarket.group_item_title_trans")],n=[t.outcomes?.[1]?.label];return o.some(i=>il(i,r))?"yes":n.some(i=>il(i,r))?"no":null}function Xi({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:o=100,onSuccess:n}){let{t:i,i18n:s}=i18n.useTranslation(),a=react.useRef(n);a.current=n;let{status:l}=walletConnector.useAuth(),p=walletConnector.useWallets(),d=reactPredict.usePredictClient(),c=react.useContext(reactPredict.PolymarketContext),m=reactQuery.useQueryClient(),{start:u}=reactPredict.useTradeResultConfirmation(),f=e.source,g=f==="polymarket",b=p.find(T=>T.chainNamespace===types.ChainNamespace.SOLANA&&T.isConnected),h=p.find(T=>T.chainNamespace===types.ChainNamespace.EVM&&T.isConnected&&"switchChain"in T),S=l==="authenticated",x=b?.address,y=h?.address,[v,k]=react.useState(t),[P,M]=react.useState("market"),[N,w]=react.useState(NaN),[R,A]=react.useState(NaN),[X,L]=react.useState(false),[G,U]=react.useState(false),[oe,W]=react.useState(null),[te,ne]=react.useState(null),[se,he]=react.useState(false),[Pe,pt]=react.useState(false),[Ve,Be]=react.useState("1h"),[E,st]=react.useState(30),[He,ve]=react.useState("minutes"),at=react.useMemo(()=>Gr(i),[s,i]),we=true,Ue=react.useCallback(async(T,Re)=>{let Le=Mr({messages:at});Le.submitted(),await u({source:f,user:f==="kalshi"?x:y,kalshiUser:we?x:void 0,polymarketUser:y,marketSlug:e.slug,eventSlug:e.event_slug,expectation:T,getOrdersHeaders:Re})==="confirmed"?Le.completed():Le.delayed();},[u,we,y,e.event_slug,e.slug,f,at,x]),qe=react.useMemo(()=>{if(f!=="polymarket")return;let T=e.provider_meta?.["polymarket.clobTokenIds"];return T?(typeof T=="string"?JSON.parse(T):T)[v==="yes"?0:1]:void 0},[f,e.provider_meta,v]),{data:C,isLoading:O}=reactPredict.useTickSize(qe),z=reactPredict.normalizePolymarketTickSize(C?.minimum_tick_size),{data:Z,isLoading:me}=reactPredict.useFeeRate(qe),Ne=String(Z?.base_fee??0),{data:lt}=reactPredict.useRebateConfig(),ct=lt?.builder_enabled&&lt.builder_code?lt.builder_code:void 0,kt=false,Qe=null,Yt=false,We,et,xe;try{let T=cr();we=T.enableKalshi,kt=T.kalshiKycVerified,Qe=T.kalshiKycUrl,Yt=T.polymarketSetupVerified,We=T.polymarketSafeAddress,et=T.polymarketWalletKind,xe=T.polymarketWalletAddress;}catch{}let mt=f==="kalshi"&&!kt,St=f==="polymarket"&&!Yt,Me=react.useCallback(async()=>{if(!h||!c)return null;let T=await h.getEip1193Provider();if(!T)return null;let Re=et==="deposit"&&!!xe,Le=!Re&&!!We,ze={address:h.address,signatureType:Re?3:Le?2:0,signTypedData:async(vt,Zt,Wt,$e)=>{let ar=[];"name"in vt&&ar.push({name:"name",type:"string"}),"version"in vt&&ar.push({name:"version",type:"string"}),"chainId"in vt&&ar.push({name:"chainId",type:"uint256"}),"verifyingContract"in vt&&ar.push({name:"verifyingContract",type:"address"}),"salt"in vt&&ar.push({name:"salt",type:"bytes32"});let on={EIP712Domain:ar,...Zt};return await T.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:vt,types:on,primaryType:Wt,message:$e})]})}};return c.credentials??await c.authenticate(ze)},[We,et,xe,h,c]),{data:tt}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:f,outcome:v},{enabled:e.status==="open"}),Ce=react.useMemo(()=>{let T=reactPredict.pickBestBid(tt,v);if(T!=null&&T>0)return T;let Re=v==="yes"?0:1,Le=e.outcomes[Re];return Le?.best_bid??Le?.price??.5},[tt,e.outcomes,v]),Lt=f==="kalshi"?x??"":y??"",{data:I,isLoading:_e}=reactPredict.usePositionsMulti({kalshi_user:f==="kalshi"?Lt:void 0,polymarket_user:f==="polymarket"?Lt:void 0},{enabled:!!Lt,refetchInterval:3e4}),Xe=Qi(r),mo=r?.trim(),B=react.useMemo(()=>I?I.positions.find(T=>T.market?.slug!==e.slug?false:Xe?Qi(T.side)===Xe:sf(T,e)===v)??null:null,[I,e,v,Xe]),Ie=mo||B?.side||v,Pt=react.useCallback(async()=>{let T=await Me();return T?await reactPredict.buildPolymarketL2Headers(T.address,{apiKey:T.apiKey,secret:T.secret,passphrase:T.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Me]),{data:Ft,isLoading:fo}=reactPredict.useAvailableShares({source:f,user:Lt,market:e.slug,side:Ie},f==="polymarket"?{getHeaders:Pt}:void 0,{enabled:!!Lt&&!!e.slug,refetchOnMount:"always"}),ni=e.provider_meta?.["dflow.yesMint"]??"",ii=e.provider_meta?.["dflow.noMint"]??"",qt=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ir=e.provider_meta?.["dflow.collateralMint"]||"",si=v==="yes"?ni:ii,ft=react.useMemo(()=>f==="polymarket"?reactPredict.getPolymarketSharesPrecision(z):Ft?.precision??0,[f,z,Ft?.precision]),Ot=Ft?.active_order_shares??0,Dr=f==="polymarket"&&!!B?.size&&(Ft?.total_shares??0)<=0&&(Ft?.available_shares??0)<=0,go=Dr?B?.size??0:0,Ar=Dr?go:Ft?.total_shares??0,sr=Dr?Math.max(0,go-Ot):Ft?.available_shares??0,ai=fo||_e,en=B?.market?.provider_meta,Fr=en?.["dflow.outcomeMint"]||si,Qt=en?.["dflow.collateralMint"]||Ir,vr=Fr,xr=Qt||qt,br=react.useMemo(()=>isNaN(N)||N<=0?"0":String(Math.round(N*1e6)),[N]),ho=f==="kalshi"&&!!vr&&!!xr&&!!x&&br!=="0",{refetch:vo}=reactPredict.useDFlowQuote({inputMint:vr,outputMint:xr,amount:br,userPublicKey:x??"",slippageBps:100},{enabled:ho}),Br=react.useMemo(()=>isNaN(N)||N<=0?0:N,[N]),_t=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:tt,outcome:v,side:"sell",sharesNeeded:Br,slippageBps:o}),[tt,v,Br,o]),D=react.useMemo(()=>_t.status==="ok"&&_t.worstPrice!=null&&_t.worstPrice>0?_t.worstPrice:Ce,[_t,Ce]),De=react.useMemo(()=>P==="limit"&&g&&!isNaN(R)?R:D,[P,g,R,D]),Te=react.useMemo(()=>isNaN(N)||N<=0?0:N*De,[N,De]),It=react.useMemo(()=>f!=="polymarket"?0:Mi({grossReturn:Te,pricePerShare:De,feeRateBps:Number(Ne)}),[f,Te,De,Ne]),xo=react.useMemo(()=>Math.max(0,Te-It),[Te,It]),Xt=react.useCallback(T=>{k(T),A(NaN),w(NaN),U(false);},[]);react.useEffect(()=>{Xt(t);},[t,Xt]);let Jt=react.useCallback(T=>{M(T);},[]);react.useEffect(()=>{P==="limit"&&A(Math.round(Ce*1e4)/1e4);},[P,v,Ce]);let gt=react.useCallback(T=>{if(U(false),isNaN(T)){w(NaN);return}w(be(Math.max(0,T),ft));},[ft]),li=react.useCallback(()=>{U(true),w(be(sr,ft));},[sr,ft]),tn=react.useCallback(T=>{if(isNaN(T)){A(NaN);return}A(Math.round(T*1e4)/1e4);},[]),Ut=react.useCallback(()=>{w(NaN),A(NaN),M("market"),U(false),pt(false),Be("1h"),st(30),ve("minutes");},[]),Hr=react.useMemo(()=>{let T=[];return isNaN(N)||N<=0?T.push(i("predict.trade.minQuantity",{amount:yo})):N<yo&&T.push(i("predict.trade.minQuantity",{amount:yo})),e.status!=="open"&&T.push(i("predict.trade.marketNotActive")),!isNaN(N)&&N>0&&!G&&N>sr&&T.push(i("predict.trade.insufficientSharesDetail",{total:be(Ar,ft).toFixed(ft),active:be(Ot,ft).toFixed(ft),available:be(sr,ft).toFixed(ft)})),P==="limit"&&g&&(isNaN(R)||R<.01||R>.99)&&T.push(i("predict.trade.limitPriceRange")),P==="limit"&&g&&Pe&&Ve==="custom"&&(isNaN(E)||E<=0)&&T.push(i("predict.trade.expiration.invalidDate")),f==="polymarket"&&P==="market"&&!isNaN(N)&&N>0&&(_t.status==="insufficient_liquidity"?T.push(i("predict.trade.insufficientLiquidity",{available:be(_t.totalAvailable,2)})):_t.status==="exceeds_slippage"&&T.push(i("predict.trade.priceImpactTooHigh",{impact:(_t.priceImpactBps/100).toFixed(2),slippage:(o/100).toFixed(2)}))),{isValid:T.length===0,errors:T}},[N,e.status,sr,Ar,Ot,G,P,g,R,Pe,Ve,E,ft,f,_t,o,i]),{mutateAsync:Ur}=reactPredict.useDFlowSubmit(),{data:yr}=reactPredict.useOrder({id:oe??"",source:f},{enabled:!!oe}),rn=react.useCallback(async()=>{if(!te||!x||!b)return;let{cashAmount:T,collateral:Re}=te;ne(null);try{let ze=(await d.createDFlowQuote({inputMint:Re,outputMint:qt,amount:T,userPublicKey:x,slippageBps:100}))?.transaction;if(!ze)return;let vt=Uint8Array.from(atob(ze),Wt=>Wt.charCodeAt(0)),Zt=await b.signTransaction(vt);await Ur({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:x,input_mint:Re,output_mint:qt,amount:T,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[te,x,b,d,Ur,qt]),kr=react.useCallback(()=>{m.invalidateQueries({queryKey:["predict","available-shares"]});},[m]);react.useEffect(()=>{if(!yr||!oe)return;let{status:T}=yr;T==="closed"?(W(null),te?rn().finally(()=>{L(false),Ue("sell-market"),kr(),Ut(),a.current?.();}):(L(false),Ue("sell-market"),kr(),Ut(),a.current?.())):(T==="failed"||T==="expired")&&(L(false),W(null),ne(null),ui.toast.error(i("predict.trade.submitError")));},[yr,oe,te,rn,Ue,kr,Ut,i]);let Wr=react.useCallback(async()=>{if(!x||!b)return;if(!vr||!xr){ui.toast.error("Missing token mint addresses"),L(false);return}if(!kt){he(true),L(false);return}let Le=(await vo()).data,ze=Le?.transaction;if(!ze){ui.toast.error(i("predict.trade.submitError")),L(false);return}if(Qt&&Qt!==qt){let $e=String(Le?.outAmount??"");$e&&$e!=="0"&&ne({cashAmount:$e,collateral:Qt});}let vt=Uint8Array.from(atob(ze),$e=>$e.charCodeAt(0)),Zt=await b.signTransaction(vt),Wt=await Ur({signedTransaction:btoa(String.fromCharCode(...Zt)),orderContext:{user_public_key:x,input_mint:vr,output_mint:xr,amount:br,price:String(Ce),side:"SELL",outcome:v==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});W(Wt.signature);},[x,b,vo,Ur,vr,xr,br,Ce,v,e.slug,Qt,qt,i,kt]),zr=react.useCallback(async()=>{if(!h||!c)return;let T=h.chain,Re=T!==types.Chain.POLYGON;Re&&await h.switchChain(types.Chain.POLYGON);try{let Le=await h.getEip1193Provider();if(!Le){ui.toast.error(i("predict.trade.submitError")),L(!1);return}let ze=et==="deposit"&&!!xe,vt=!ze&&!!We,Zt=ze?xe:We,Wt={address:h.address,signatureType:ze?3:vt?2:0,signTypedData:async(zt,sn,ui,pi)=>{let $r=[];"name"in zt&&$r.push({name:"name",type:"string"}),"version"in zt&&$r.push({name:"version",type:"string"}),"chainId"in zt&&$r.push({name:"chainId",type:"uint256"}),"verifyingContract"in zt&&$r.push({name:"verifyingContract",type:"address"}),"salt"in zt&&$r.push({name:"salt",type:"bytes32"});let xd={EIP712Domain:$r,...sn};return await Le.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:zt,types:xd,primaryType:ui,message:pi})]})}},$e=await Me();if(!$e){ui.toast.error(i("predict.trade.submitError")),L(!1);return}let ar=v==="yes"?0:1,on="",nn=e.provider_meta?.["polymarket.clobTokenIds"];nn&&(on=(typeof nn=="string"?JSON.parse(nn):nn)[ar]??"");let ea=e.provider_meta?.["polymarket.negRisk"]??!1,hd=P==="limit"&&!isNaN(R)?R:D,vd=Po(hd,z),ci={tokenId:on,price:vd,size:N,side:"SELL",orderType:P==="limit"?Pe?"GTD":"GTC":"FOK",tickSize:z,negRisk:ea,...Zt&&{funderAddress:Zt},...ct&&{builderCode:ct},...P==="limit"&&Pe&&{expiration:So(Ve,E,He)}},di;if(ze)di=await reactPredict.buildSignedV2OrderPayload({signer:Wt,depositWalletAddress:Zt,input:ci,owner:$e.apiKey});else {let zt=reactPredict.buildCtfExchangeDomain(ea),sn=reactPredict.buildOrderMessage({...ci,signerAddress:Wt.address,signatureType:Wt.signatureType,feeRateBps:Ne}),ui=await Wt.signTypedData(zt,reactPredict.CTF_ORDER_TYPES,"Order",sn),pi=reactPredict.buildSignedOrder(sn,ui,ci.orderType);di=reactPredict.buildClobPayload(pi,$e.apiKey);}await d.executePolymarketOrder({payload:di,l2_api_key:$e.apiKey,l2_secret:$e.secret,l2_passphrase:$e.passphrase,signer_address:$e.address,owner:$e.apiKey}),kr(),Ue(P==="limit"?"sell-limit":"sell-market",async()=>await reactPredict.buildPolymarketL2Headers($e.address,{apiKey:$e.apiKey,secret:$e.secret,passphrase:$e.passphrase,method:"GET",requestPath:"/data/orders"})),Ut(),L(!1),a.current?.();}finally{Re&&T&&h.switchChain(T).catch(()=>{});}},[h,c,Me,v,e,P,Ue,R,D,N,d,kr,Pe,Ve,E,He,Ut,i,z,Ne,We,et,xe,ct]),Dt=react.useCallback(async()=>{if(!(!Hr.isValid||!S)){L(true),W(null),he(false);try{f==="kalshi"?await Wr():await zr();}catch(T){let Re=T instanceof Error?T.message:"",Le=f==="polymarket"&&Re?No(Re,i,"sell"):Re||void 0;ui.toast.error(Le||i("predict.trade.submitError")),L(false);}}},[Hr.isValid,S,f,Wr,zr,i]);return {outcome:v,orderType:P,quantity:N,limitPrice:R,shares:Br,effectivePrice:De,grossReturn:Te,estimatedFee:It,estimatedReturn:xo,pricePerShare:Ce,isMarketDataLoading:f==="polymarket"&&(me||O),isSubmitting:X,authStatus:l,validation:Hr,supportsLimitOrder:g,kycRequired:se,needsKyc:mt,needsSetup:St,kycUrl:Qe,totalShares:Ar,activeOrderShares:Ot,availableShares:sr,isAvailableLoading:ai,isSellAll:G,precision:ft,expirationEnabled:Pe,expirationPreset:Ve,customDuration:E,customDurationUnit:He,setOutcome:Xt,setOrderType:Jt,setQuantity:gt,setLimitPrice:tn,setSellAll:li,setExpirationEnabled:pt,setExpirationPreset:Be,setCustomDuration:st,setCustomDurationUnit:ve,submit:Dt}}var hf=["5m","1h","12h","24h","eod","custom"],vf={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},xf=["minutes","hours","days"],bf={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},yf={maximumFractionDigits:0},Oo="-";function es({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,effectivePrice:a,grossReturn:l,estimatedFee:p,estimatedReturn:d,isMarketDataLoading:c,isSubmitting:m,authStatus:u,isValid:f,validationErrors:g,supportsLimitOrder:b,kycRequired:h,needsKyc:S,needsSetup:x,onSetupRequired:y,kycUrl:v,totalShares:k,activeOrderShares:P,availableShares:M,isAvailableLoading:N,precision:w,expirationEnabled:R,expirationPreset:A,customDuration:X,customDurationUnit:L,oddsFormatter:G,outcomeLabels:U,onOutcomeChange:oe,onOrderTypeChange:W,onQuantityChange:te,onLimitPriceChange:ne,onSellAll:se,onExpirationEnabledChange:he,onExpirationPresetChange:Pe,onCustomDurationChange:pt,onCustomDurationUnitChange:Ve,onSubmit:Be}){let{t:E}=i18n.useTranslation(),[st,He]=react.useState(false),[ve,at]=react.useState(true),we=ui.useDisclosure(),[Ue,qe]=react.useState(""),C=react.useRef(false);react.useEffect(()=>{C.current||qe(isNaN(i)?"":String(i));},[i]);let[O,z]=react.useState(""),Z=react.useRef(false);react.useEffect(()=>{Z.current||(isNaN(s)?z(""):z(String(parseFloat((s*100).toFixed(2)))));},[s]);let me=react.useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(z(I),I===""||I==="."){ne(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||ne(Xe/100);},[ne]),Ne=react.useCallback(I=>{let _e=new RegExp(`^\\d*\\.?\\d{0,${w}}$`);if(I!==""&&!_e.test(I))return;if(qe(I),He(false),I===""||I==="."){te(NaN);return}let Xe=parseFloat(I);isNaN(Xe)||te(Xe);},[te,w]);react.useEffect(()=>{h&&!we.isOpen&&we.onOpen();},[h,we]);let lt=react.useMemo(()=>{let I=o==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[o,t]),ct=o==="yes"?t.yesBid:t.noBid,kt=ct!=null&&G?G(Number(ct)):lt!=null?`${lt} \xA2`:null,Qe=Number.isFinite(a)?parseFloat((a*100).toFixed(2)):null,Yt=Number.isFinite(a)&&G?G(a):Qe!=null?`${Qe} \xA2`:null,We=!isNaN(i)&&i>0,et=We&&i>0?d/i:0,xe=et>0&&G?G(et):et>0?`${parseFloat((et*100).toFixed(2))} \xA2`:Oo,mt=u==="authenticated",St=u==="authenticating"||u==="deauthenticating",Me=mt&&(S||x),tt=react.useCallback(I=>U?.[I]??E(I==="yes"?"predict.trade.yes":"predict.trade.no"),[U,E]),Ce=react.useMemo(()=>{if(St)return E("predict.trade.checkingLogin");if(!mt)return E("predict.trade.loginToTrade");if(S)return E("predict.trade.kycRequired");if(x)return E("predict.trade.setupRequired");if(N)return E("predict.trade.loadingBalance");if(c)return E("predict.trade.loadingMarketData");if(m)return E("predict.trade.submitting");if(h)return E("predict.trade.kycRequired");if(!We)return E("predict.trade.enterAmount");let I=tt(o);return `${E("predict.trade.sell")} ${I}`},[St,mt,S,x,N,c,m,h,We,o,tt,E]),Lt=()=>{if(!mt){He(false),Be();return}if(S){we.onOpen();return}if(x&&y){He(false),y();return}if(h){we.onOpen();return}if(!f){He(true);return}He(false),Be();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="hsl(var(--heroui-content4) / 0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="hsl(var(--heroui-content3) / 0.6)");},children:[e&&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-text-muted leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsx("span",{className:"text-foreground",children:t.yesSubTitle}),jsxRuntime.jsx("span",{className:"text-foreground",children:" \xB7 "}),jsxRuntime.jsxs("span",{className:"text-negative",children:[E("predict.trade.sell")," ",tt(o)]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[b?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:I=>W(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:E("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:E("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.market")}),n==="limit"&&b?jsxRuntime.jsx(ui.StyledInput,{"aria-label":E("predict.trade.limitPrice"),placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:O,onChange:I=>me(I.target.value),onFocus:()=>{Z.current=true;},onBlur:()=>{Z.current=false,isNaN(s)?z(""):z(String(parseFloat((s*100).toFixed(2))));},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):kt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:kt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let _e=I==="yes"?t.yesBid:t.noBid;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>oe(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===I?"border-negative bg-negative/10 text-negative":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:tt(I)}),_e!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:G?G(Number(_e)):`${parseFloat((Number(_e)*100).toFixed(2))}\xA2`})]})},I)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-text-muted",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:E("predict.trade.sellContracts")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let _e=Math.pow(10,w);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{te(Math.floor(M*I/100*_e)/_e);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:[I,"%"]},I)}),jsxRuntime.jsx("button",{type:"button",onClick:se,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-text-muted hover:text-foreground font-medium",children:E("common.all")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":E("predict.trade.sellQuantity"),fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ue,onChange:I=>Ne(I.target.value),onFocus:()=>{C.current=true;},onBlur:()=>{C.current=false,qe(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),st&&g.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(I=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:I},I))})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:N?"\u2013":`${be(k,w).toFixed(w)}${E("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.activeOrders")}),jsxRuntime.jsx("span",{className:"tabular-nums text-warning",children:N?"\u2013":P>0?`-${be(P,w).toFixed(w)}${E("predict.trade.sharesUnit")}`:`0${E("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.availableShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-success font-medium",children:N?"\u2013":`${be(M,w).toFixed(w)}${E("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estReturn")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:"\u2013"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>at(I=>!I),className:"flex items-center gap-x-1 text-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:E("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",ve&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:G&&Number.isFinite(a)?Yt:Qe!=null?E("predict.trade.chance",{percent:Qe}):Oo})]}),ve&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-text-muted",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?Nr(i):Oo})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:We?`$${l.toFixed(2)}`:Oo})]}),(p??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${(p??0).toFixed(2)}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.estReturnAfterFees")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:We?`$${d.toFixed(2)}`:Oo})]}),(p??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:E("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:xe})]})]})]}),n==="limit"&&b&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:E("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:R,onValueChange:he,"aria-label":E("predict.trade.setExpiration")})]}),R&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":E("predict.trade.setExpiration"),selectedKeys:[A],onSelectionChange:I=>{let _e=Array.from(I)[0];_e&&Pe(_e);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:hf.map(I=>jsxRuntime.jsx(ui.SelectItem,{children:E(vf[I])},I))}),A==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":E("predict.trade.durationAmount"),size:"sm",radius:"lg",value:isNaN(X)?void 0:X,onValueChange:pt,minValue:1,step:1,formatOptions:yf,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsxRuntime.jsx(ui.Select,{"aria-label":E("predict.trade.durationUnit"),selectedKeys:[L],onSelectionChange:I=>{let _e=Array.from(I)[0];_e&&Ve(_e);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:xf.map(I=>jsxRuntime.jsx(ui.SelectItem,{children:E(bf[I])},I))})]})]})]}),jsxRuntime.jsx(ui.Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:St||mt&&!Me&&(N||c||!We||m),isLoading:St||mt&&!Me&&(m||N||c),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Lt,children:Ce})]}),jsxRuntime.jsx(wo,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:v})]})}function _o({event:e,market:t,variant:r,initialOutcome:o,initialPositionSide:n,chain:i,slippageBps:s,onOutcomeChange:a,onSetupRequired:l,onSuccess:p,oddsFormatter:d,outcomeLabels:c}){let{outcome:m,orderType:u,quantity:f,limitPrice:g,effectivePrice:b,grossReturn:h,estimatedFee:S,estimatedReturn:x,pricePerShare:y,isMarketDataLoading:v,isSubmitting:k,authStatus:P,validation:M,supportsLimitOrder:N,kycRequired:w,needsKyc:R,needsSetup:A,kycUrl:X,totalShares:L,activeOrderShares:G,availableShares:U,isAvailableLoading:oe,precision:W,expirationEnabled:te,expirationPreset:ne,customDuration:se,customDurationUnit:he,setOutcome:Pe,setOrderType:pt,setQuantity:Ve,setLimitPrice:Be,setSellAll:E,setExpirationEnabled:st,setExpirationPreset:He,setCustomDuration:ve,setCustomDurationUnit:at,submit:we}=Xi({market:t,initialOutcome:o,initialPositionSide:n,slippageBps:s,onSuccess:p}),Ue=walletConnector.useAuthCallback(we),qe=react.useCallback(z=>{Pe(z),a?.(z);},[Pe,a]),C=react.useMemo(()=>e?un(e):void 0,[e]),O=react.useMemo(()=>pn(t,{yesBid:m==="yes"?y:void 0,noBid:m==="no"?y:void 0}),[t,m,y]);return jsxRuntime.jsx(es,{event:C,market:O,variant:r,outcome:m,orderType:u,quantity:f,limitPrice:g,effectivePrice:b,grossReturn:h,estimatedFee:S,estimatedReturn:x,isMarketDataLoading:v,isSubmitting:k,authStatus:P,isValid:M.isValid,validationErrors:M.errors,supportsLimitOrder:N,kycRequired:w,needsKyc:R,needsSetup:A,onSetupRequired:l,kycUrl:X,totalShares:L,activeOrderShares:G,availableShares:U,isAvailableLoading:oe,precision:W,expirationEnabled:te,expirationPreset:ne,customDuration:se,customDurationUnit:he,oddsFormatter:d,outcomeLabels:c,onOutcomeChange:qe,onOrderTypeChange:pt,onQuantityChange:Ve,onLimitPriceChange:Be,onSellAll:E,onExpirationEnabledChange:st,onExpirationPresetChange:He,onCustomDurationChange:ve,onCustomDurationUnitChange:at,onSubmit:Ue})}var En="predict-sell";function ts({id:e=En}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Rf,{...t})})}function Rf({params:e,isOpen:t,onOpenChange:r}){let{t:o}=i18n.useTranslation(),{isMobile:n}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"opaque",hideCloseButton:true,classNames:{base:ui.THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{className:n?"":"p-2",children:[jsxRuntime.jsx(_o,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialPositionSide:e.initialPositionSide,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),jsxRuntime.jsx("div",{className:"px-4 pb-4",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.cancel")})})]})})}):null}var ns=40,Tn=36,Ao=480,is=Ao-Tn;function ss({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=i18n.useTranslation(),[n,i]=react.useState("positions"),s=react.useMemo(()=>e.markets?.map(c=>c.slug)??[],[e.markets]),{data:a}=reactPredict.usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=react.useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(c=>c.market&&s.includes(c.market.slug)).length,[a?.positions,s,t]),d=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(c=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(c.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===c.key?"text-foreground border-b-2 border-primary":"text-text-muted hover:text-foreground"),children:c.label},c.key))}),t?jsxRuntime.jsxs("div",{style:{height:Ao},children:[n==="positions"&&jsxRuntime.jsx(Ff,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsxRuntime.jsx(Hf,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsxRuntime.jsx(zf,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:Ao},children:o("predict.trade.connectWallet")})]})}function Ff({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=i18n.useTranslation(),{data:n,isLoading:i}=reactPredict.usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),s=react.useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[n?.positions,r]);return i?jsxRuntime.jsx(ls,{}):s.length===0?jsxRuntime.jsx(as,{message:o("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Tn},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:is},rowComponent:Bf,rowCount:s.length,rowHeight:ns,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function Bf({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let i=n.pnl??0,s=n.pnl_percent??0,a=n.avg_price??0,l=n.current_price??0,p=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",c=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",m=n.side,u=n.size,f=n.size*l,g=n.market?.end_at?Vf(n.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsxRuntime.jsx("span",{className:ui.cn("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Cn(a)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Cn(l)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",p),children:[d,"$",Math.abs(i).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,s.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",u.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-text-muted whitespace-nowrap",children:g}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-text-muted hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Hf({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=i18n.useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:l}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),p=reactPredict.useCancelOrder(),d=react.useMemo(()=>{let h=i?.pages?.flatMap(y=>y.items)??[],S=new Set(["live","open","submitted","pending"]),x=h.filter(y=>S.has(y.status));return r.length>0&&(x=x.filter(y=>y.market_id&&r.includes(y.market_id))),x},[i?.pages,r]),c=react.useCallback(h=>{o?o(h.id):p.mutate({source:h.source,id:h.id});},[o,p]),m=d.length,u=m+(l?1:0),f=react.useCallback(h=>h<m,[m]),g=react.useCallback(async()=>{await a();},[a]),b=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:u,threshold:5});return s?jsxRuntime.jsx(ls,{}):d.length===0&&!l?jsxRuntime.jsx(as,{message:n("predict.openOrders.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Tn},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:is},onRowsRendered:b,rowComponent:Uf,rowCount:u,rowHeight:ns,rowProps:{orders:d,itemCount:m,onCancel:c,isCancelling:p.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function Uf({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){let{t:a}=i18n.useTranslation();if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let l=r[e];if(!l)return null;let p=l.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",p?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-text-muted capitalize",children:l.order_type?.toLowerCase()==="market"?a("predict.trade.market"):a("predict.trade.limit")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?Cn(parseFloat(l.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(Wf,{status:l.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>n(l),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):s})})]})}function Wf({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-text-muted/10 text-text-muted",failed:"bg-danger/10 text-danger",expired:"bg-text-muted/10 text-text-muted"}[e]??"bg-text-muted/10 text-text-muted"),children:e})}function zf({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:o,isLoading:n,fetchNextPage:i,hasNextPage:s}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),a=react.useMemo(()=>o?.pages?.flatMap(u=>u.items)??[],[o?.pages]),l=a.length,p=l+(s?1:0),d=react.useCallback(u=>u<l,[l]),c=react.useCallback(async()=>{await i();},[i]),m=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:c,rowCount:p,threshold:5});return n?jsxRuntime.jsx(ls,{}):a.length===0&&!s?jsxRuntime.jsx(as,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-text-muted text-xs lg:text-sm font-normal shrink-0",style:{height:Tn},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:is},onRowsRendered:m,rowComponent:$f,rowCount:p,rowHeight:ns,rowProps:{trades:a,itemCount:l}})]})}function $f({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let i=n.side?.toUpperCase()==="BUY",s=Kf(n.timestamp),a=n.price??0,l=n.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Cn(a)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-text-muted whitespace-nowrap",children:s})]})}function as({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:Ao},children:e})}function ls(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Ao},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Cn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Kf(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${i}`}function Vf(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var hl=`
75
75
  @keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
76
- `,vl={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function ye(e){return {...vl,animationDelay:`${e}ms`}}function rn({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:bl}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:20},children:[t&&jsxRuntime.jsx("div",{style:{height:20}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxRuntime.jsx("div",{style:{...vl,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("div",{style:{...ye(0),height:14,width:48}}),jsxRuntime.jsx("div",{style:{...ye(30),height:14,width:40}}),jsxRuntime.jsx("div",{style:{...ye(60),height:14,width:40}})]}),jsxRuntime.jsx("div",{style:{...ye(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsxRuntime.jsx("div",{style:{...ye(100),height:16,width:192}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsxRuntime.jsx("div",{style:{...ye(120),height:16,width:96}}),jsxRuntime.jsx("div",{style:{...ye(140),height:16,width:80}})]}),jsxRuntime.jsx("div",{style:{...ye(160),height:300,width:"100%",borderRadius:12}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("div",{style:{...ye(180),height:16,width:80}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...ye(200),height:28,width:200,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsxRuntime.jsx("div",{style:{...ye(240),height:14,width:56}})}),Array.from({length:e}).map((r,n)=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxRuntime.jsx("div",{style:{...ye(260+n*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsxRuntime.jsx("div",{style:{...ye(280+n*40),height:14,width:n%2===0?192:160}}),jsxRuntime.jsx("div",{style:{...ye(300+n*40),height:10,width:64}})]}),jsxRuntime.jsx("div",{style:{...ye(320+n*40),height:16,width:40}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...ye(340+n*40),height:32,width:80,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(360+n*40),height:32,width:80,borderRadius:8}})]})]},n))]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsx("div",{style:{...ye(400),height:16,width:64}}),jsxRuntime.jsx("div",{style:{...ye(420),height:14,width:"100%"}}),jsxRuntime.jsx("div",{style:{...ye(440),height:14,width:"80%"}}),jsxRuntime.jsx("div",{style:{...ye(460),height:14,width:"60%"}})]})]})]})}function ci(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:bl}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",padding:16},children:[jsxRuntime.jsx("div",{style:{...ye(0),height:40,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(60),height:96,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(120),height:40,width:"100%",borderRadius:8}})]})]})}function yl(e,t,r){return e===t||!r?null:{marketSlug:t,outcomeKey:r}}function kl(e,t){return {marketSlug:e,outcomeKey:t}}function Sl(e){return e.slice(0,2).map((t,r)=>({catalogOutcome:t,tradeOutcome:r===0?"yes":"no"}))}function Ze(e,t){return `${e}:${t}`}function Pl({marketDataEnabled:e,marketSlug:t,outcomeKey:r,books:n}){return e?{legacyEnabled:false,orderbook:n?.get(Ze(t,r))??null}:{legacyEnabled:true,orderbook:void 0}}var El="var(--color-bullish)",Cl="var(--color-bearish)";function nn(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function $f(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Kf(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let d of e){let m=Math.round(d.price*100);m>=0&&m<=100&&(r[m]+=d.quantity);}for(let d of t){let m=Math.round(d.price*100);m>=0&&m<=100&&(n[m]+=d.quantity);}let o=0,a=0,i=new Float64Array(101),s=new Float64Array(101);for(let d=100;d>=0;d--)o+=r[d],a+=r[d]*d/100,i[d]=o,s[d]=a;let l=0,u=0,p=new Float64Array(101),c=new Float64Array(101);for(let d=0;d<=100;d++)l+=n[d],u+=n[d]*d/100,p[d]=l,c[d]=u;let f=Math.max(i[0]??0,p[100]??0);return Array.from({length:101},(d,m)=>{let v=i[m]>0,k=p[m]>0,g=i[m]||p[m],S=r[m]>0||n[m]>0;return {priceCents:m,displayHeight:$f(g,f),opacity:g>0?S?1:.5:0,isBid:v,isAsk:k,bidCumTotal:i[m],askCumTotal:p[m],bidCumCost:s[m],askCumCost:c[m]}})}function Vf({info:e}){let{t}=i18n.useTranslation(),r=e.isBid?El:Cl,n=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:n,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsxRuntime.jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:nn(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:r},children:["$",nn(Math.round(e.cumCost))]})]})}var jf=react.memo(function({slot:t,onEnter:r,onLeave:n}){let o=react.useRef(null),a=t.isBid||t.isAsk,i=t.isBid?El:t.isAsk?Cl:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:a?"crosshair":"default"},onMouseEnter:()=>r(t,o.current),onMouseLeave:n,children:a&&jsxRuntime.jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:i,opacity:t.opacity}})})}),Gf=[0,10,20,30,40,50,60,70,80,90,100];function Yf(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:Gf.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function ui({bids:e,asks:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>Kf(e,t),[e,t]),o=react.useMemo(()=>{let c=e.length>0?Math.max(...e.map(d=>d.price)):0,f=t.length>0?Math.min(...t.map(d=>d.price)):1;return Math.round((c+f)/2*100)},[e,t]),a=react.useMemo(()=>n.some(c=>c.isBid||c.isAsk),[n]),[i,s]=react.useState(null),l=react.useRef(null),u=react.useCallback((c,f)=>{l.current&&(l.current.style.filter=""),f?(f.style.filter="brightness(1.5)",l.current=f):l.current=null,c.isBid||c.isAsk?s({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.priceCents}):s(null);},[]),p=react.useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),s(null);},[]);return a?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),i&&jsxRuntime.jsx(Vf,{info:i}),n.map(c=>jsxRuntime.jsx(jf,{slot:c,onEnter:u,onLeave:p},c.priceCents))]}),jsxRuntime.jsx(Yf,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Il(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Rl(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral text-xs",children:jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})})}function fi({market:e,outcome:t="yes",initialViewMode:r="depth",className:n,oddsFormatter:o,enabled:a=true,orderbook:i}){let{t:s}=i18n.useTranslation(),[l,u]=react.useState(r),p=o??Il,c=e.source,{data:f,isLoading:d,isFetching:m,refetch:v}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:c,outcome:t},{enabled:a}),k=i!==void 0,g=k?i:f,S=!k&&d,h=!k&&m,x=react.useMemo(()=>(g?.bids??[]).map(w=>({price:w.price,quantity:w.size})),[g?.bids]),b=react.useMemo(()=>(g?.asks??[]).map(w=>({price:w.price,quantity:w.size})),[g?.asks]),y=react.useMemo(()=>x.length>0?Math.max(...x.map(w=>w.price)):null,[x]),P=react.useMemo(()=>b.length>0?Math.min(...b.map(w=>w.price)):null,[b]),N=react.useMemo(()=>{if(y==null||P==null)return null;let w=(P-y)*100;return Math.round(w*10)/10},[y,P]);return jsxRuntime.jsxs("div",{className:ui$1.cn("flex flex-col",n??"h-[262px]"),children:[jsxRuntime.jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:N!=null?`${s("predict.orderBook.spread")}: ${Number.isInteger(N)?`${N}\xA2`:`${N.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[y!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[s("predict.trade.bestBid"),": ",p(y)]}),y!=null&&P!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),P!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[s("predict.trade.bestAsk"),": ",p(P)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",title:l==="depth"?"Orderbook":"Depth chart",onClick:()=>u(w=>w==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:l==="depth"?jsxRuntime.jsx(ui$1.OrderbookTableIcon,{className:"h-4 w-4"}):jsxRuntime.jsx(ui$1.OrderbookDepthIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Refresh",onClick:()=>{k||v();},disabled:k||h,className:ui$1.cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",h&&"animate-spin"),children:jsxRuntime.jsx(ui$1.RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxRuntime.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[l==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:S?jsxRuntime.jsx(Rl,{}):jsxRuntime.jsx(ui,{bids:x,asks:b})}),l==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:S?jsxRuntime.jsx(Rl,{}):jsxRuntime.jsx(eg,{bids:x,asks:b,bestBid:y??void 0,bestAsk:P??void 0,spread:N??void 0,oddsFormatter:o})})]})]})}var pi=4,Zf=8;function eg({bids:e,asks:t,spread:r,oddsFormatter:n}){let{t:o}=i18n.useTranslation(),[a,i]=react.useState(false),s=a?Zf:pi,l=t.length>pi||e.length>pi,u=react.useMemo(()=>[...t].sort((d,m)=>d.price-m.price).slice(0,s).reverse(),[t,s]),p=react.useMemo(()=>[...e].sort((d,m)=>m.price-d.price).slice(0,s),[e,s]),c=react.useMemo(()=>{let d=[...u,...p].map(m=>m.quantity);return Math.max(...d,1)},[u,p]);return u.length===0&&p.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(d=>jsxRuntime.jsx(Ll,{price:d.price,quantity:d.quantity,side:"ask",maxQty:c,oddsFormatter:n},`ask-${d.price}`)),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsxRuntime.jsx("button",{type:"button",onClick:()=>i(d=>!d),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:o(a?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),p.map(d=>jsxRuntime.jsx(Ll,{price:d.price,quantity:d.quantity,side:"bid",maxQty:c,oddsFormatter:n},`bid-${d.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Ll({price:e,quantity:t,side:r,maxQty:n,oddsFormatter:o}){let a=r==="ask",i=Math.min(t/n*100,100),s=a?"bg-bearish/10":"bg-bullish/10",l=a?"text-bearish":"text-bullish",u=nn(Math.round(t)),p=Math.round(t*e),c=`$${nn(p)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${i}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 ${l}`,children:o?o(e):Il(e)}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:c})]})}var Ro=new Map,gi=new Set,Al=0;function Fl(){Al+=1,gi.forEach(e=>e());}function ag(e){return gi.add(e),()=>gi.delete(e)}function Dl(){return Al}function ig(e,t){return e?.bestAsk===t.bestAsk&&e?.bestBid===t.bestBid}function Lo(e){return e!=null&&e>0&&Number.isFinite(e)?e:void 0}function sg(e,t,r){if(!e||!t)return;let n={bestAsk:Lo(r.bestAsk),bestBid:Lo(r.bestBid)};if(n.bestAsk===void 0&&n.bestBid===void 0){_o(e,t);return}let o=Ze(e,t);ig(Ro.get(o),n)||(Ro.set(o,n),Fl());}function Bl(e,t,r){!e||!t||!r||sg(e,t,{bestAsk:Lo(reactPredict.pickBestAsk(r,t)),bestBid:Lo(reactPredict.pickBestBid(r,t))});}function _o(e,t){if(!e||!t)return;let r=Ze(e,t);Ro.delete(r)&&Fl();}function Hl(e){let t=react.useSyncExternalStore(ag,Dl,Dl);return react.useMemo(()=>{let r=new Map;for(let n of e){let o=Ze(n.slug,n.outcome),a=Ro.get(o);a!==void 0&&r.set(o,a);}return r},[e,t])}function Oo(e){return e.status==="closed"||e.status==="voided"?e.markets??[]:(e.markets??[]).filter(t=>t.status==="open")}var hi=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},Bn=4,Ul=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function xg(e,t){let r=new Date(e);return t===W.ONE_HOUR||t===W.SIX_HOURS||t===W.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===W.ALL?r.toLocaleDateString("en-US",{month:"numeric",day:"numeric"}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function yg(e,t){let r=new Date(e);return t===W.ONE_HOUR||t===W.SIX_HOURS||t===W.ONE_DAY?r.toLocaleTimeString("en-US",{month:t===W.ONE_DAY?"short":void 0,day:t===W.ONE_DAY?"numeric":void 0,hour:"2-digit",minute:"2-digit",hour12:false}):t===W.ONE_MONTH||t===W.ALL?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Wl(e){return `${(e*100).toFixed(2)}%`}function kg(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Sg(e,t,r){let n=r*1e3,o=t.map(s=>kg(s.created_at)).filter(s=>s!=null),a=o.length>0?Math.min(...o):void 0,i=ba[e];if(i!=null){let s=n-i*1e3;return [a!=null?Math.max(a,s):s,n]}return [a??n-7*864e5,n]}function Pg([e,t]){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)return [];let r=5,n=(t-e)/(r-1);return Array.from({length:r},(o,a)=>Math.round(e+n*a))}function wg(e){switch(e){case W.ONE_HOUR:case W.SIX_HOURS:return 3e4;case W.ONE_DAY:return 6e4;case W.ONE_MONTH:case W.ALL:return 5*6e4;default:return 6e4}}function Ng(e){return e.status==="open"||e.status==="pending"}var Mg=[{range:W.ONE_HOUR,label:"1h"},{range:W.SIX_HOURS,label:"6h"},{range:W.ONE_DAY,label:"1D"},{range:W.ONE_MONTH,label:"1M"},{range:W.ALL,label:"ALL"}];function Eg({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Mg.map(({range:r,label:n})=>{let o=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:o?"#f9fafb":"#6b7280",fontWeight:o?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:n},r)})})}function Cg(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(o=>{let a=e.current,i=t.current;if(!a||!i)return;let s=a.getBoundingClientRect(),l=(o.clientX-s.left)/s.width*100;i.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,i.style.opacity="1";},[]),n=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function Tg({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:a}){if(!e||!o?.length)return null;let i=new Map;t?.forEach(l=>i.set(l.dataKey,l));let s=o.map(l=>i.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?yg(r,a):r}),s.map(l=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Wl(l.value):"--"})]},l.dataKey))]})}function Rg({onPayload:e,...t}){let{active:r,label:n,payload:o}=t;return react.useEffect(()=>{r&&e(n,o);},[r,n,e,o]),jsxRuntime.jsx(Tg,{...t})}function Lg({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,a]=react.useState(false),i=react.useRef(null);react.useEffect(()=>{if(!o)return;function u(p){i.current&&!i.current.contains(p.target)&&a(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let s=t.length>=Bn,l=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(p=>p.slug===t[0]);return u?lr(u):"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:i,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>a(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),o&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",Bn," markets"]}),e.map((u,p)=>{let c=t.includes(u.slug),f=!c&&s,d=c&&t.length===1,m=r.get(u.slug)??"#6b7280",v=u.outcomes.find(g=>g.label.toLowerCase()==="yes")??u.outcomes[0],k=v?.price!=null?`${Math.round(v.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{d||f||n(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:c?"rgba(255,255,255,0.05)":"transparent",cursor:f||d?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:g=>{!f&&!d&&(g.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:g=>{g.currentTarget.style.background=c?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:c?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:c?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:c&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:c?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:lr(u)}),k&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:k})]},u.id??`${p}-${u.slug}`)})]})]})}function _g({series:e,colorMap:t,displayValues:r}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(n=>{let o=t.get(n.marketSlug)??"#6b7280",a=r.get(n.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:o,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:n.label}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:a!=null?Wl(a):"--"})]})]},n.marketSlug)})})}function Og(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let a=Math.floor(o*n),i=Math.min(Math.floor((o+1)*n),e.length),s=e.slice(a,i),l=s[s.length-1];l&&r.push(l);}return r}function Ig(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:Og(s.data,t)})),n=new Set;r.forEach(s=>s.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((s,l)=>s-l),a=r.map(s=>{let l=new Map;return s.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:s.marketSlug,map:l}}),i=new Map;return o.map(s=>{let l={timestamp:s};return a.forEach(({slug:u,map:p})=>{let c=p.get(s);if(c!==void 0)i.set(u,c),l[u]=c;else {let f=i.get(u);f!==void 0&&(l[u]=f);}}),l})}function bi(e){return jsxRuntime.jsx(hi,{children:jsxRuntime.jsx(Dg,{...e})})}function Dg({event:e,marketDataEnabled:t=false,isLoading:r,className:n,volume:o,fillHeight:a=false,orderbookQuotes:i}){let s=react.useMemo(()=>{let C=new Set;return Oo(e).filter(T=>C.has(T.slug)?false:(C.add(T.slug),true))},[e]),l=react.useMemo(()=>[...s].sort((C,T)=>{let $=Z=>(Z.outcomes.find(ue=>ue.label.toLowerCase()==="yes")??Z.outcomes[0])?.price??0;return $(T)-$(C)}),[s]),[u,p]=react.useState(()=>l.slice(0,Bn).map(C=>C.slug));react.useEffect(()=>{let C=new Set(s.map(T=>T.slug));p(T=>{let $=T.filter(Z=>C.has(Z));return $.length===T.length?T:$.length>0?$:l.slice(0,Bn).map(Z=>Z.slug)});},[s,l]);let[c,f]=react.useState(vn),d=react.useMemo(()=>{let C=new Map;return u.forEach((T,$)=>{C.set(T,Ul[$%Ul.length]);}),C},[u]),m=react.useMemo(()=>s.filter(C=>u.includes(C.slug)),[s,u]),v=react.useMemo(()=>m.map(C=>C.slug).join("|"),[m]),[k,g]=react.useState(()=>Math.floor(Date.now()/1e3)),S=react.useMemo(()=>wg(c),[c]),h=react.useMemo(()=>m.some(Ng),[m]);react.useEffect(()=>{g(Math.floor(Date.now()/1e3));},[c,v]),react.useEffect(()=>{if(!h)return;let C=()=>{let $=Math.floor(Date.now()/1e3);g(Z=>Z===$?Z:$);},T=window.setInterval(C,S);return ()=>window.clearInterval(T)},[S,h]);let x=react.useMemo(()=>Sg(c,m,k),[c,m,k]),b=react.useMemo(()=>Pg(x),[x]),{series:y,isLoading:P}=reactPredict.useMarketHistory(m,c,{endTs:k}),N=`${c}:${v}`,w=react.useRef(new Map),M=w.current.get(N),L=P&&M!=null&&M.length>0,A=L?M:y;react.useEffect(()=>{!P&&y.length>0&&w.current.set(N,y);},[N,P,y]);let X=!!(r||P&&!L),_=react.useMemo(()=>{let C=new Map;return i&&m.forEach(T=>{let $=i.get(Ze(T.slug,"yes"))?.bestAsk;$!=null&&$>0&&Number.isFinite($)&&C.set(T.slug,$);}),C},[i,m]),U=react.useMemo(()=>A.length>0&&A.some(C=>C.data.length>0)?A.map(C=>{let T=_.get(C.marketSlug);if(T==null||C.data.length===0)return C;let $=C.data[C.data.length-1];if(Math.abs($.price-T)<1e-6)return C;let Z=Math.min(Date.now(),x[1]),ue={timestamp:Z,price:T},Me=Z-$.timestamp<5e3?[...C.data.slice(0,-1),{...$,price:T}]:[...C.data,ue];return {...C,data:Me}}):X?[]:m.flatMap(C=>{let T=C.outcomes?.find(Z=>Z.label.toLowerCase()==="yes")??C.outcomes?.[0],$=_.get(C.slug)??T?.best_ask??T?.best_bid??T?.price??(t?void 0:.5);return $===void 0?[]:[{marketSlug:C.slug,label:lr(C),data:[{timestamp:x[0],price:$},{timestamp:x[1],price:$}]}]}),[A,X,_,t,m,x]),q=react.useMemo(()=>c===W.ONE_HOUR?80:c===W.SIX_HOURS?400:c===W.ONE_DAY?320:c===W.ONE_MONTH?3e3:2e3,[c]),ee=react.useMemo(()=>Ig(U,q),[U,q]),Y=react.useMemo(()=>{if(ee.length===0)return [0,1];let C=1/0,T=-1/0;if(u.forEach(Z=>{ee.forEach(ue=>{let Me=ue[Z];Me!=null&&(Me<C&&(C=Me),Me>T&&(T=Me));});}),!isFinite(C))return [0,1];let $=Math.max((T-C)*.15,.05);return [Math.max(0,C-$),Math.min(1,T+$)]},[ee,u]),re=react.useMemo(()=>{let C=new Map;return U.forEach(T=>{T.data.length>0&&C.set(T.marketSlug,T.data[T.data.length-1].price);}),C},[U]),oe=react.useMemo(()=>{let C=new Map;return U.forEach(T=>C.set(T.marketSlug,T.label)),C},[U]),ie=react.useMemo(()=>U.map(C=>({slug:C.marketSlug,color:d.get(C.marketSlug)??"#6b7280"})),[U,d]),{wrapperRef:he,overlayRef:Pe,onMouseMove:dt,onMouseLeave:He}=Cg(),Ve=react.useCallback(C=>{p(T=>T.includes(C)?T.length<=1?T:T.filter($=>$!==C):T.length>=Bn?T:[...T,C]);},[]),[E,at]=react.useState(null),Oe=react.useRef(""),be=react.useRef(0),gt=react.useCallback((C,T)=>{if(!T?.length)return;let $=`${C}:${T.map(ue=>`${ue.dataKey}:${ue.value}`).join(",")}`;if($===Oe.current)return;Oe.current=$;let Z=new Map;T.forEach(ue=>{ue.value!=null&&Z.set(ue.dataKey,ue.value);}),cancelAnimationFrame(be.current),be.current=requestAnimationFrame(()=>{at(Z);});},[]),we=react.useCallback(()=>{He(),cancelAnimationFrame(be.current),Oe.current="",at(null);},[He]),Ue=!X&&ee.length>0;return jsxRuntime.jsxs("div",{className:n,style:{display:"flex",flexDirection:"column",gap:12,...a?{height:"100%",minHeight:0}:null},children:[jsxRuntime.jsx(_g,{series:U,colorMap:d,displayValues:E??re}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...a?{flex:1,minHeight:0}:null},children:[jsxRuntime.jsx("div",{ref:he,style:{width:"100%",userSelect:"none",position:"relative",...a?{flex:1,minHeight:240}:{height:300}},onMouseMove:Ue?C=>{dt(C);}:void 0,onMouseLeave:Ue?we:void 0,children:X?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):ee.length===0?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:Pe,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:ee,margin:{top:8,right:16,left:0,bottom:0},onMouseLeave:we,children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:x,ticks:b,interval:0,tickFormatter:C=>xg(C,c),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:Y,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:C=>jsxRuntime.jsx(Rg,{...C,labelMap:oe,allSeries:ie,range:c,onPayload:gt}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),U.map(C=>{let T=d.get(C.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:C.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},C.marketSlug)}),E==null&&ee.length>0&&U.map(C=>{let T=ee[ee.length-1],$=T[C.marketSlug];if($==null)return null;let Z=d.get(C.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:T.timestamp,y:$,ifOverflow:"extendDomain",shape:ue=>{let{cx:Me,cy:it}=ue;return Me==null||it==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:Me,cy:it,r:6,fill:Z,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:Me,cy:it,r:3.5,fill:Z})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[utils.formatAmountInUsd(o)," vol"]}),jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}}),jsxRuntime.jsx(Eg,{value:c,onChange:f}),l.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(Lg,{markets:l,selectedSlugs:u,colorMap:d,onToggle:Ve})})]})]})]})}function Io(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function zl(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function qg(e){return e===void 0?"\u2014":`${parseFloat((e*100).toFixed(2))}%`}function Qg(e){if(e===void 0)return "\u2014";let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Do(e){return lr(e)}function Xg(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Hn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),a=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${a}:${i}`}function $l(e){let[t,r]=react.useState(0);if(react.useEffect(()=>{if(!e)return;r(Date.now());let p=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(p)},[e]),!e||t===0)return null;let n=new Date(e).getTime();if(isNaN(n))return null;let o=n-t;if(o<=0)return null;let a=Math.floor(o/864e5),i=Math.floor(o%864e5/36e5),s=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),u=[];return a>0&&u.push(`${a}d`),u.push(`${String(i).padStart(2,"0")}h`),u.push(`${String(s).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function Kl(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0"),i=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${a}/${i} (${l}${u})`}function Wn({event:e,marketDataEnabled:t=false,marketDataOrderbooks:r,onMarketDataBookSelectionChange:n,orderbookQuotes:o,onTradeAction:a}){let{t:i}=i18n.useTranslation(),{ref:s,isCollapsed:l}=hooks.useScrollCollapse(),u=Kr(e),p=react.useMemo(()=>{let k=[...e.markets||[]],g=k.filter(h=>h.status==="open").sort((h,x)=>Io(x)-Io(h)),S=k.filter(h=>h.status!=="open").sort((h,x)=>Io(x)-Io(h));return [...g,...S]},[e.markets]),c=e.status==="closed"||e.status==="voided",f=$l(c?void 0:e.start_at),d=$l(c?void 0:e.end_at),m=Kl(e.start_at),v=Kl(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:s,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${l?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:u||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${l?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!l&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((k,g)=>jsxRuntime.jsxs(react.Fragment,{children:[g>0&&jsxRuntime.jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral truncate",children:k.label})]},k.slug)),jsxRuntime.jsx(th,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${l?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:u})]})]}),(f||d||c)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:c?v&&jsxRuntime.jsx("span",{className:"text-neutral",children:i("predict.event.endedAt",{time:v})}):f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:i("predict.event.beginsIn",{time:f})}),m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:m})]})]}):d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:i("predict.event.endsIn",{time:d})}),v&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:v})]})]}):null}),jsxRuntime.jsx(bi,{event:e,marketDataEnabled:t,volume:e.volume??void 0,orderbookQuotes:o}),jsxRuntime.jsx(Jg,{markets:p,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:n,orderbookQuotes:o,onTradeAction:a}),jsxRuntime.jsx(eh,{markets:p,event:e})]})}var Vl=5;function Jg({markets:e,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:n,orderbookQuotes:o,onTradeAction:a}){let{t:i}=i18n.useTranslation(),{isDesktop:s}=ui$1.useScreen(),[l,u]=react.useState(false),[p,c]=react.useState(null),f=react.useMemo(()=>{let h=new Set;return e.filter(x=>h.has(x.slug)?false:(h.add(x.slug),true))},[e]),[d,m]=react.useState(null);if(f.length===0)return null;let v=f.length>Vl,k=l?f:f.slice(0,Vl),g=h=>{t&&n?.(yl(p,h.slug,d?.marketSlug===h.slug?d.outcomeKey:void 0)),c(x=>x===h.slug?null:h.slug);},S=(h,x,b,y)=>{m({marketSlug:h.slug,tradeOutcome:x,outcomeKey:y}),t&&n?.(kl(h.slug,y)),s&&c(h.slug),a?.(h,x,b);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:i("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:k.map((h,x)=>{let b=p===h.slug;return jsxRuntime.jsx(Zg,{market:h,activeSelection:d?.marketSlug===h.slug?d:void 0,isExpanded:b,orderbookQuotes:o,marketDataEnabled:t,marketDataOrderbooks:r,onToggleExpand:()=>g(h),onTradeAction:S,onUnselectedTradeAction:a},h.id??`${x}-${h.slug}`)})})]}),v&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>u(h=>!h),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:i(l?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:ui$1.cn("h-4 w-4 transition-transform",l&&"rotate-180")})]})]})}function Zg({market:e,activeSelection:t,isExpanded:r,orderbookQuotes:n,marketDataEnabled:o,marketDataOrderbooks:a,onToggleExpand:i,onTradeAction:s,onUnselectedTradeAction:l}){let{t:u}=i18n.useTranslation(),p=e.status==="open",c=e.volume?`${utils.formatAmountInUsd(e.volume)} vol`:void 0,f=n?.get(Ze(e.slug,"yes"))?.bestAsk??zl(e,"yes"),d=n?.get(Ze(e.slug,"no"))?.bestAsk??zl(e,"no"),m=t?.tradeOutcome??"yes",v=t?.outcomeKey,k=Sl(e.outcomes).map(S=>({...S,price:S.tradeOutcome==="yes"?f:d})),g=Pl({marketDataEnabled:o,marketSlug:e.slug,outcomeKey:v??"",books:a});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:i,role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),i());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url,name:Do(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:Do(e)}),c&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:c})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:qg(f)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:p?jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-2",children:k.map(({catalogOutcome:S,tradeOutcome:h,price:x})=>jsxRuntime.jsx("button",{type:"button",className:ui$1.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",h==="yes"?t?.outcomeKey===S.key?"bg-primary text-primary-foreground":"bg-primary/10 text-primary":t?.outcomeKey===S.key?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:b=>{b.stopPropagation(),s?.(e,h,"buy",S.key);},children:x!=null?u(h==="yes"?"predict.market.action.yes":"predict.market.action.no",{price:Qg(x)}):h==="yes"&&o?`${u("predict.market.yes")} \u2014`:u(h==="yes"?"predict.market.yes":"predict.market.no")},S.key))}):jsxRuntime.jsx("div",{className:"flex items-center justify-end",children:jsxRuntime.jsx("span",{className:ui$1.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?u("predict.event.status.closed"):e.status==="voided"?u("predict.event.status.voided"):u("predict.event.status.pending")})})})]}),r&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(fi,{market:e,outcome:m,onTradeAction:(S,h,x)=>{if(!v){l?.(S,h,x);return}s?.(S,h,x,v);},enabled:g.legacyEnabled,orderbook:g.orderbook})})})})]})}function eh({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[n,o]=react.useState(false),[a,i]=react.useState(false),[s,l]=react.useState(0),u=e.filter(d=>d.rules&&d.rules.length>0||ha(d));if(u.length===0)return null;let p=u[s]??u[0],c=p.rules&&p.rules.length>0?p.rules.join(`
76
+ `,vl={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function ye(e){return {...vl,animationDelay:`${e}ms`}}function ro({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:hl}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",gap:20},children:[t&&jsxRuntime.jsx("div",{style:{height:20}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxRuntime.jsx("div",{style:{...vl,width:64,height:64,borderRadius:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("div",{style:{...ye(0),height:14,width:48}}),jsxRuntime.jsx("div",{style:{...ye(30),height:14,width:40}}),jsxRuntime.jsx("div",{style:{...ye(60),height:14,width:40}})]}),jsxRuntime.jsx("div",{style:{...ye(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsxRuntime.jsx("div",{style:{...ye(100),height:16,width:192}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[jsxRuntime.jsx("div",{style:{...ye(120),height:16,width:96}}),jsxRuntime.jsx("div",{style:{...ye(140),height:16,width:80}})]}),jsxRuntime.jsx("div",{style:{...ye(160),height:300,width:"100%",borderRadius:12}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("div",{style:{...ye(180),height:16,width:80}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...ye(200),height:28,width:200,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(220),height:28,width:112,borderRadius:8}})]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0"},children:jsxRuntime.jsx("div",{style:{...ye(240),height:14,width:56}})}),Array.from({length:e}).map((r,o)=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid var(--color-border-subtle)"},children:[jsxRuntime.jsx("div",{style:{...ye(260+o*40),width:28,height:28,borderRadius:8,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[jsxRuntime.jsx("div",{style:{...ye(280+o*40),height:14,width:o%2===0?192:160}}),jsxRuntime.jsx("div",{style:{...ye(300+o*40),height:10,width:64}})]}),jsxRuntime.jsx("div",{style:{...ye(320+o*40),height:16,width:40}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...ye(340+o*40),height:32,width:80,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(360+o*40),height:32,width:80,borderRadius:8}})]})]},o))]}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsx("div",{style:{...ye(400),height:16,width:64}}),jsxRuntime.jsx("div",{style:{...ye(420),height:14,width:"100%"}}),jsxRuntime.jsx("div",{style:{...ye(440),height:14,width:"80%"}}),jsxRuntime.jsx("div",{style:{...ye(460),height:14,width:"60%"}})]})]})]})}function cs(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:hl}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",padding:16},children:[jsxRuntime.jsx("div",{style:{...ye(0),height:40,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(60),height:96,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...ye(120),height:40,width:"100%",borderRadius:8}})]})]})}function bl(e,t,r){return e===t||!r?null:{marketSlug:t,outcomeKey:r}}function yl(e,t){return {marketSlug:e,outcomeKey:t}}function kl(e){return e.slice(0,2).map((t,r)=>({catalogOutcome:t,tradeOutcome:r===0?"yes":"no"}))}function Ze(e,t){return `${e}:${t}`}function Sl({marketDataEnabled:e,marketSlug:t,outcomeKey:r,books:o}){return e?{legacyEnabled:false,orderbook:o?.get(Ze(t,r))??null}:{legacyEnabled:true,orderbook:void 0}}var wl="var(--color-bullish)",El="var(--color-bearish)";function oo(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Yf(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function qf(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let u of e){let f=Math.round(u.price*100);f>=0&&f<=100&&(r[f]+=u.quantity);}for(let u of t){let f=Math.round(u.price*100);f>=0&&f<=100&&(o[f]+=u.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let u=100;u>=0;u--)n+=r[u],i+=r[u]*u/100,s[u]=n,a[u]=i;let l=0,p=0,d=new Float64Array(101),c=new Float64Array(101);for(let u=0;u<=100;u++)l+=o[u],p+=o[u]*u/100,d[u]=l,c[u]=p;let m=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(u,f)=>{let g=s[f]>0,b=d[f]>0,h=s[f]||d[f],S=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:Yf(h,m),opacity:h>0?S?1:.5:0,isBid:g,isAsk:b,bidCumTotal:s[f],askCumTotal:d[f],bidCumCost:a[f],askCumCost:c[f]}})}function Qf({info:e}){let{t}=i18n.useTranslation(),r=e.isBid?wl:El,o=e.leftPct>65?void 0:`${e.leftPct}%`,n=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:o,right:n,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"var(--color-text-primary)",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsxRuntime.jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:oo(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:r},children:["$",oo(Math.round(e.cumCost))]})]})}var Xf=react.memo(function({slot:t,onEnter:r,onLeave:o}){let n=react.useRef(null),i=t.isBid||t.isAsk,s=t.isBid?wl:t.isAsk?El:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:i&&jsxRuntime.jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),Jf=[0,10,20,30,40,50,60,70,80,90,100];function Zf(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:Jf.map(e=>jsxRuntime.jsx("span",{className:"absolute text-text-muted font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function us({bids:e,asks:t}){let{t:r}=i18n.useTranslation(),o=react.useMemo(()=>qf(e,t),[e,t]),n=react.useMemo(()=>{let c=e.length>0?Math.max(...e.map(u=>u.price)):0,m=t.length>0?Math.min(...t.map(u=>u.price)):1;return Math.round((c+m)/2*100)},[e,t]),i=react.useMemo(()=>o.some(c=>c.isBid||c.isAsk),[o]),[s,a]=react.useState(null),l=react.useRef(null),p=react.useCallback((c,m)=>{l.current&&(l.current.style.filter=""),m?(m.style.filter="brightness(1.5)",l.current=m):l.current=null,c.isBid||c.isAsk?a({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.priceCents}):a(null);},[]),d=react.useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),a(null);},[]);return i?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[n>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsxRuntime.jsx(Qf,{info:s}),o.map(c=>jsxRuntime.jsx(Xf,{slot:c,onEnter:p,onLeave:d},c.priceCents))]}),jsxRuntime.jsx(Zf,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-muted)",fontSize:13},children:r("predict.orderBook.noData")})}function _l(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Tl(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-text-muted text-xs",children:jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})})}function fs({market:e,outcome:t="yes",initialViewMode:r="depth",className:o,oddsFormatter:n,enabled:i=true,orderbook:s}){let{t:a}=i18n.useTranslation(),[l,p]=react.useState(r),d=n??_l,c=e.source,{data:m,isLoading:u,isFetching:f,refetch:g}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:c,outcome:t},{enabled:i}),b=s!==void 0,h=b?s:m,S=!b&&u,x=!b&&f,y=react.useMemo(()=>(h?.bids??[]).map(N=>({price:N.price,quantity:N.size})),[h?.bids]),v=react.useMemo(()=>(h?.asks??[]).map(N=>({price:N.price,quantity:N.size})),[h?.asks]),k=react.useMemo(()=>y.length>0?Math.max(...y.map(N=>N.price)):null,[y]),P=react.useMemo(()=>v.length>0?Math.min(...v.map(N=>N.price)):null,[v]),M=react.useMemo(()=>{if(k==null||P==null)return null;let N=(P-k)*100;return Math.round(N*10)/10},[k,P]);return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col",o??"h-[262px]"),children:[jsxRuntime.jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-text-muted",children:M!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(M)?`${M}\xA2`:`${M.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[k!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",d(k)]}),k!=null&&P!=null&&jsxRuntime.jsx("span",{className:"text-text-muted",children:"|"}),P!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("predict.trade.bestAsk"),": ",d(P)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",title:a(l==="depth"?"predict.orderBook.tableView":"predict.orderBook.depthView"),onClick:()=>p(N=>N==="depth"?"table":"depth"),className:"flex items-center text-text-muted transition-colors cursor-pointer hover:text-foreground",children:l==="depth"?jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"}):jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:a("predict.orderBook.refresh"),onClick:()=>{b||g();},disabled:b||x,className:ui.cn("flex items-center text-text-muted transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",x&&"animate-spin"),children:jsxRuntime.jsx(ui.RefreshIcon,{className:"h-4 w-4"})})]})]}),jsxRuntime.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[l==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:S?jsxRuntime.jsx(Tl,{}):jsxRuntime.jsx(us,{bids:y,asks:v})}),l==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:S?jsxRuntime.jsx(Tl,{}):jsxRuntime.jsx(ig,{bids:y,asks:v,bestBid:k??void 0,bestAsk:P??void 0,spread:M??void 0,oddsFormatter:n})})]})]})}var ps=4,ng=8;function ig({bids:e,asks:t,spread:r,oddsFormatter:o}){let{t:n}=i18n.useTranslation(),[i,s]=react.useState(false),a=i?ng:ps,l=t.length>ps||e.length>ps,p=react.useMemo(()=>[...t].sort((u,f)=>u.price-f.price).slice(0,a).reverse(),[t,a]),d=react.useMemo(()=>[...e].sort((u,f)=>f.price-u.price).slice(0,a),[e,a]),c=react.useMemo(()=>{let u=[...p,...d].map(f=>f.quantity);return Math.max(...u,1)},[p,d]);return p.length===0&&d.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-text-muted",children:n("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[p.map(u=>jsxRuntime.jsx(Rl,{price:u.price,quantity:u.quantity,side:"ask",maxQty:c,oddsFormatter:o},`ask-${u.price}`)),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-text-muted text-[10px]",children:[r!=null&&jsxRuntime.jsxs("span",{children:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u=>!u),className:"absolute right-2 text-[10px] text-text-muted transition-colors cursor-pointer hover:text-foreground",children:n(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),d.map(u=>jsxRuntime.jsx(Rl,{price:u.price,quantity:u.quantity,side:"bid",maxQty:c,oddsFormatter:o},`bid-${u.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-text-muted border-t border-border",children:[jsxRuntime.jsx("span",{children:n("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-center",children:n("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:n("predict.orderBook.total")})]})]})}function Rl({price:e,quantity:t,side:r,maxQty:o,oddsFormatter:n}){let i=r==="ask",s=Math.min(t/o*100,100),a=i?"bg-negative/10":"bg-positive/10",l=i?"text-negative":"text-positive",p=oo(Math.round(t)),d=Math.round(t*e),c=`$${oo(d)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 ${l}`,children:n?n(e):_l(e)}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-center",children:p}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:c})]})}var Ln=new Map,gs=new Set,Dl=0;function Al(){Dl+=1,gs.forEach(e=>e());}function dg(e){return gs.add(e),()=>gs.delete(e)}function Il(){return Dl}function ug(e,t){return e?.bestAsk===t.bestAsk&&e?.bestBid===t.bestBid}function On(e){return e!=null&&e>0&&Number.isFinite(e)?e:void 0}function pg(e,t,r){if(!e||!t)return;let o={bestAsk:On(r.bestAsk),bestBid:On(r.bestBid)};if(o.bestAsk===void 0&&o.bestBid===void 0){_n(e,t);return}let n=Ze(e,t);ug(Ln.get(n),o)||(Ln.set(n,o),Al());}function Fl(e,t,r){!e||!t||!r||pg(e,t,{bestAsk:On(reactPredict.pickBestAsk(r,t)),bestBid:On(reactPredict.pickBestBid(r,t))});}function _n(e,t){if(!e||!t)return;let r=Ze(e,t);Ln.delete(r)&&Al();}function Bl(e){let t=react.useSyncExternalStore(dg,Il,Il);return react.useMemo(()=>{let r=new Map;for(let o of e){let n=Ze(o.slug,o.outcome),i=Ln.get(n);i!==void 0&&r.set(n,i);}return r},[e,t])}function In(e){return e.status==="closed"||e.status==="voided"?e.markets??[]:(e.markets??[]).filter(t=>t.status==="open")}var so=ui.themeSemanticColors.text.muted,hs=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"var(--color-text-muted)",fontSize:13},children:[jsxRuntime.jsx(i18n.Translation,{children:t=>jsxRuntime.jsx("span",{children:t("predict.chart.unavailable")})}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},Uo=4,Hl=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function wg(e,t){let r=new Date(e);return t===$.ONE_HOUR||t===$.SIX_HOURS||t===$.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===$.ALL?r.toLocaleDateString("en-US",{month:"numeric",day:"numeric"}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Eg(e,t){let r=new Date(e);return t===$.ONE_HOUR||t===$.SIX_HOURS||t===$.ONE_DAY?r.toLocaleTimeString("en-US",{month:t===$.ONE_DAY?"short":void 0,day:t===$.ONE_DAY?"numeric":void 0,hour:"2-digit",minute:"2-digit",hour12:false}):t===$.ONE_MONTH||t===$.ALL?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Wl(e){return `${(e*100).toFixed(2)}%`}function Cg(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Tg(e,t,r){let o=r*1e3,n=t.map(a=>Cg(a.created_at)).filter(a=>a!=null),i=n.length>0?Math.min(...n):void 0,s=xi[e];if(s!=null){let a=o-s*1e3;return [i!=null?Math.max(i,a):a,o]}return [i??o-7*864e5,o]}function Rg([e,t]){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)return [];let r=5,o=(t-e)/(r-1);return Array.from({length:r},(n,i)=>Math.round(e+o*i))}function Lg(e){switch(e){case $.ONE_HOUR:case $.SIX_HOURS:return 3e4;case $.ONE_DAY:return 6e4;case $.ONE_MONTH:case $.ALL:return 5*6e4;default:return 6e4}}function Og(e){return e.status==="open"||e.status==="pending"}var _g=[{range:$.ONE_HOUR,label:"1h"},{range:$.SIX_HOURS,label:"6h"},{range:$.ONE_DAY,label:"1D"},{range:$.ONE_MONTH,label:"1M"},{range:$.ALL,label:"ALL"}];function Ig({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:_g.map(({range:r,label:o})=>{let n=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"var(--color-text-primary)":"var(--color-text-muted)",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function Dg(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(n=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),l=(n.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,s.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function Ag({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:i}){if(!e||!n?.length)return null;let s=new Map;t?.forEach(l=>s.set(l.dataKey,l));let a=n.map(l=>s.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"var(--color-text-secondary)",marginBottom:6,fontWeight:500},children:typeof r=="number"?Eg(r,i):r}),a.map(l=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"var(--color-text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsxRuntime.jsx("span",{style:{color:"var(--color-text-primary)",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Wl(l.value):"--"})]},l.dataKey))]})}function Fg({onPayload:e,...t}){let{active:r,label:o,payload:n}=t;return react.useEffect(()=>{r&&e(o,n);},[r,o,e,n]),jsxRuntime.jsx(Ag,{...t})}function Bg({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let{t:n}=i18n.useTranslation(),[i,s]=react.useState(false),a=react.useRef(null);react.useEffect(()=>{if(!i)return;function d(c){a.current&&!a.current.contains(c.target)&&s(false);}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[i]);let l=t.length>=Uo,p=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(d=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(d)??so,display:"inline-block"}},d))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let d=e.find(c=>c.slug===t[0]);return d?lr(d):n("predict.chart.singleMarket")})():n("predict.chart.marketCount",{selected:t.length,total:e.length})})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>s(d=>!d),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"hsl(var(--heroui-foreground) / 0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[p,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"var(--color-text-muted)"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),i&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsx("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"var(--color-text-muted)",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:n("predict.chart.selectMarkets",{count:Uo})}),e.map((d,c)=>{let m=t.includes(d.slug),u=!m&&l,f=m&&t.length===1,g=r.get(d.slug)??so,b=d.outcomes.find(S=>S.label.toLowerCase()==="yes")??d.outcomes[0],h=b?.price!=null?`${Math.round(b.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{f||u||o(d.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:m?"hsl(var(--heroui-foreground) / 0.05)":"transparent",cursor:u||f?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:S=>{!u&&!f&&(S.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:S=>{S.currentTarget.style.background=m?"hsl(var(--heroui-foreground) / 0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:m?`2px solid ${g}`:"2px solid rgba(255,255,255,0.2)",background:m?`${g}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:m&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:g,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:m?"var(--color-text-primary)":"var(--color-text-secondary)",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:lr(d)}),h&&jsxRuntime.jsx("span",{style:{color:g,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},d.id??`${c}-${d.slug}`)})]})]})}function Hg({series:e,colorMap:t,displayValues:r}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??so,i=r.get(o.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"var(--color-text-secondary)",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsxRuntime.jsx("span",{style:{color:"var(--color-text-primary)",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Wl(i):"--"})]})]},o.marketSlug)})})}function Ug(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let i=Math.floor(n*o),s=Math.min(Math.floor((n+1)*o),e.length),a=e.slice(i,s),l=a[a.length-1];l&&r.push(l);}return r}function Wg(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:Ug(a.data,t)})),o=new Set;r.forEach(a=>a.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((a,l)=>a-l),i=r.map(a=>{let l=new Map;return a.data.forEach(p=>l.set(p.timestamp,p.price)),{slug:a.marketSlug,map:l}}),s=new Map;return n.map(a=>{let l={timestamp:a};return i.forEach(({slug:p,map:d})=>{let c=d.get(a);if(c!==void 0)s.set(p,c),l[p]=c;else {let m=s.get(p);m!==void 0&&(l[p]=m);}}),l})}function vs(e){return jsxRuntime.jsx(hs,{children:jsxRuntime.jsx(zg,{...e})})}function zg({event:e,marketDataEnabled:t=false,isLoading:r,className:o,volume:n,fillHeight:i=false,orderbookQuotes:s}){let{t:a}=i18n.useTranslation(),l=react.useMemo(()=>{let C=new Set;return In(e).filter(O=>C.has(O.slug)?false:(C.add(O.slug),true))},[e]),p=react.useMemo(()=>[...l].sort((C,O)=>{let z=Z=>(Z.outcomes.find(me=>me.label.toLowerCase()==="yes")??Z.outcomes[0])?.price??0;return z(O)-z(C)}),[l]),[d,c]=react.useState(()=>p.slice(0,Uo).map(C=>C.slug));react.useEffect(()=>{let C=new Set(l.map(O=>O.slug));c(O=>{let z=O.filter(Z=>C.has(Z));return z.length===O.length?O:z.length>0?z:p.slice(0,Uo).map(Z=>Z.slug)});},[l,p]);let[m,u]=react.useState(bo),f=react.useMemo(()=>{let C=new Map;return d.forEach((O,z)=>{C.set(O,Hl[z%Hl.length]);}),C},[d]),g=react.useMemo(()=>l.filter(C=>d.includes(C.slug)),[l,d]),b=react.useMemo(()=>g.map(C=>C.slug).join("|"),[g]),[h,S]=react.useState(()=>Math.floor(Date.now()/1e3)),x=react.useMemo(()=>Lg(m),[m]),y=react.useMemo(()=>g.some(Og),[g]);react.useEffect(()=>{S(Math.floor(Date.now()/1e3));},[m,b]),react.useEffect(()=>{if(!y)return;let C=()=>{let z=Math.floor(Date.now()/1e3);S(Z=>Z===z?Z:z);},O=window.setInterval(C,x);return ()=>window.clearInterval(O)},[x,y]);let v=react.useMemo(()=>Tg(m,g,h),[m,g,h]),k=react.useMemo(()=>Rg(v),[v]),{series:P,isLoading:M}=reactPredict.useMarketHistory(g,m,{endTs:h}),N=`${m}:${b}`,w=react.useRef(new Map),R=w.current.get(N),A=M&&R!=null&&R.length>0,X=A?R:P;react.useEffect(()=>{!M&&P.length>0&&w.current.set(N,P);},[N,M,P]);let L=!!(r||M&&!A),G=react.useMemo(()=>{let C=new Map;return s&&g.forEach(O=>{let z=s.get(Ze(O.slug,"yes"))?.bestAsk;z!=null&&z>0&&Number.isFinite(z)&&C.set(O.slug,z);}),C},[s,g]),U=react.useMemo(()=>X.length>0&&X.some(C=>C.data.length>0)?X.map(C=>{let O=G.get(C.marketSlug);if(O==null||C.data.length===0)return C;let z=C.data[C.data.length-1];if(Math.abs(z.price-O)<1e-6)return C;let Z=Math.min(Date.now(),v[1]),me={timestamp:Z,price:O},Ne=Z-z.timestamp<5e3?[...C.data.slice(0,-1),{...z,price:O}]:[...C.data,me];return {...C,data:Ne}}):L?[]:g.flatMap(C=>{let O=C.outcomes?.find(Z=>Z.label.toLowerCase()==="yes")??C.outcomes?.[0],z=G.get(C.slug)??O?.best_ask??O?.best_bid??O?.price??(t?void 0:.5);return z===void 0?[]:[{marketSlug:C.slug,label:lr(C),data:[{timestamp:v[0],price:z},{timestamp:v[1],price:z}]}]}),[X,L,G,t,g,v]),oe=react.useMemo(()=>m===$.ONE_HOUR?80:m===$.SIX_HOURS?400:m===$.ONE_DAY?320:m===$.ONE_MONTH?3e3:2e3,[m]),W=react.useMemo(()=>Wg(U,oe),[U,oe]),te=react.useMemo(()=>{if(W.length===0)return [0,1];let C=1/0,O=-1/0;if(d.forEach(Z=>{W.forEach(me=>{let Ne=me[Z];Ne!=null&&(Ne<C&&(C=Ne),Ne>O&&(O=Ne));});}),!isFinite(C))return [0,1];let z=Math.max((O-C)*.15,.05);return [Math.max(0,C-z),Math.min(1,O+z)]},[W,d]),ne=react.useMemo(()=>{let C=new Map;return U.forEach(O=>{O.data.length>0&&C.set(O.marketSlug,O.data[O.data.length-1].price);}),C},[U]),se=react.useMemo(()=>{let C=new Map;return U.forEach(O=>C.set(O.marketSlug,O.label)),C},[U]),he=react.useMemo(()=>U.map(C=>({slug:C.marketSlug,color:f.get(C.marketSlug)??so})),[U,f]),{wrapperRef:Pe,overlayRef:pt,onMouseMove:Ve,onMouseLeave:Be}=Dg(),E=react.useCallback(C=>{c(O=>O.includes(C)?O.length<=1?O:O.filter(z=>z!==C):O.length>=Uo?O:[...O,C]);},[]),[st,He]=react.useState(null),ve=react.useRef(""),at=react.useRef(0),we=react.useCallback((C,O)=>{if(!O?.length)return;let z=`${C}:${O.map(me=>`${me.dataKey}:${me.value}`).join(",")}`;if(z===ve.current)return;ve.current=z;let Z=new Map;O.forEach(me=>{me.value!=null&&Z.set(me.dataKey,me.value);}),cancelAnimationFrame(at.current),at.current=requestAnimationFrame(()=>{He(Z);});},[]),Ue=react.useCallback(()=>{Be(),cancelAnimationFrame(at.current),ve.current="",He(null);},[Be]),qe=!L&&W.length>0;return jsxRuntime.jsxs("div",{className:o,style:{display:"flex",flexDirection:"column",gap:12,...i?{height:"100%",minHeight:0}:null},children:[jsxRuntime.jsx(Hg,{series:U,colorMap:f,displayValues:st??ne}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...i?{flex:1,minHeight:0}:null},children:[jsxRuntime.jsx("div",{ref:Pe,style:{width:"100%",userSelect:"none",position:"relative",...i?{flex:1,minHeight:240}:{height:300}},onMouseMove:qe?C=>{Ve(C);}:void 0,onMouseLeave:qe?Ue:void 0,children:L?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):W.length===0?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-muted)",fontSize:13},children:a("predict.chart.noPriceHistory")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:pt,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:W,margin:{top:8,right:16,left:0,bottom:0},onMouseLeave:Ue,children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:v,ticks:k,interval:0,tickFormatter:C=>wg(C,m),axisLine:false,tickLine:false,tick:{fill:"var(--color-text-muted)",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:te,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"var(--color-text-muted)",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:C=>jsxRuntime.jsx(Fg,{...C,labelMap:se,allSeries:he,range:m,onPayload:we}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),U.map(C=>{let O=f.get(C.marketSlug)??so;return jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:C.marketSlug,stroke:O,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:O},connectNulls:true,isAnimationActive:false},C.marketSlug)}),st==null&&W.length>0&&U.map(C=>{let O=W[W.length-1],z=O[C.marketSlug];if(z==null)return null;let Z=f.get(C.marketSlug)??so;return jsxRuntime.jsx(recharts.ReferenceDot,{x:O.timestamp,y:z,ifOverflow:"extendDomain",shape:me=>{let{cx:Ne,cy:lt}=me;return Ne==null||lt==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:Ne,cy:lt,r:6,fill:Z,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:Ne,cy:lt,r:3.5,fill:Z})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxRuntime.jsx("span",{style:{color:"var(--color-text-muted)",fontSize:12},children:a("predict.chart.volume",{value:utils.formatAmountInUsd(n)})}),jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}}),jsxRuntime.jsx(Ig,{value:m,onChange:u}),p.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(Bg,{markets:p,selectedSlugs:d,colorMap:f,onToggle:E})})]})]})]})}function Dn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function zl(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function rh(e){return e===void 0?"\u2014":`${parseFloat((e*100).toFixed(2))}%`}function oh(e){if(e===void 0)return "\u2014";let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function An(e){return lr(e)}function nh(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Wo(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${i}:${s}`}function $l(e){let[t,r]=react.useState(0);if(react.useEffect(()=>{if(!e)return;r(Date.now());let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e||t===0)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let i=Math.floor(n/864e5),s=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),p=[];return i>0&&p.push(`${i}d`),p.push(`${String(s).padStart(2,"0")}h`),p.push(`${String(a).padStart(2,"0")}m`),p.push(`${String(l).padStart(2,"0")}s`),p.join(" ")}function Kl(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",p=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${p})`}function $o({event:e,marketDataEnabled:t=false,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}){let{t:s}=i18n.useTranslation(),{ref:a,isCollapsed:l}=hooks.useScrollCollapse(),p=Kr(e),d=react.useMemo(()=>{let b=[...e.markets||[]],h=b.filter(x=>x.status==="open").sort((x,y)=>Dn(y)-Dn(x)),S=b.filter(x=>x.status!=="open").sort((x,y)=>Dn(y)-Dn(x));return [...h,...S]},[e.markets]),c=e.status==="closed"||e.status==="voided",m=$l(c?void 0:e.start_at),u=$l(c?void 0:e.end_at),f=Kl(e.start_at),g=Kl(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:a,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${l?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:p||s("predict.event.fallbackName"),radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${l?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!l&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((b,h)=>jsxRuntime.jsxs(react.Fragment,{children:[h>0&&jsxRuntime.jsx("span",{className:"text-sm text-text-muted/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-text-muted truncate",children:b.label})]},b.slug)),jsxRuntime.jsx(lh,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${l?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:p})]})]}),(m||u||c)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:c?g&&jsxRuntime.jsx("span",{className:"text-text-muted",children:s("predict.event.endedAt",{time:g})}):m?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:s("predict.event.beginsIn",{time:m})}),f&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-text-muted/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-text-muted",children:f})]})]}):u?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:s("predict.event.endsIn",{time:u})}),g&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-text-muted/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-text-muted",children:g})]})]}):null}),jsxRuntime.jsx(vs,{event:e,marketDataEnabled:t,volume:e.volume??void 0,orderbookQuotes:n}),jsxRuntime.jsx(ih,{markets:d,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}),jsxRuntime.jsx(ah,{markets:d,event:e})]})}var Vl=5;function ih({markets:e,marketDataEnabled:t,marketDataOrderbooks:r,onMarketDataBookSelectionChange:o,orderbookQuotes:n,onTradeAction:i}){let{t:s}=i18n.useTranslation(),{isDesktop:a}=ui.useScreen(),[l,p]=react.useState(false),[d,c]=react.useState(null),m=react.useMemo(()=>{let x=new Set;return e.filter(y=>x.has(y.slug)?false:(x.add(y.slug),true))},[e]),[u,f]=react.useState(null);if(m.length===0)return null;let g=m.length>Vl,b=l?m:m.slice(0,Vl),h=x=>{t&&o?.(bl(d,x.slug,u?.marketSlug===x.slug?u.outcomeKey:void 0)),c(y=>y===x.slug?null:x.slug);},S=(x,y,v,k)=>{f({marketSlug:x.slug,tradeOutcome:y,outcomeKey:k}),t&&o?.(yl(x.slug,k)),a&&c(x.slug),i?.(x,y,v);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-text-muted font-normal lg:text-center lg:text-sm",children:s("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:b.map((x,y)=>{let v=d===x.slug;return jsxRuntime.jsx(sh,{market:x,activeSelection:u?.marketSlug===x.slug?u:void 0,isExpanded:v,orderbookQuotes:n,marketDataEnabled:t,marketDataOrderbooks:r,onToggleExpand:()=>h(x),onTradeAction:S,onUnselectedTradeAction:i},x.id??`${y}-${x.slug}`)})})]}),g&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>p(x=>!x),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-text-muted lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:s(l?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",l&&"rotate-180")})]})]})}function sh({market:e,activeSelection:t,isExpanded:r,orderbookQuotes:o,marketDataEnabled:n,marketDataOrderbooks:i,onToggleExpand:s,onTradeAction:a,onUnselectedTradeAction:l}){let{t:p}=i18n.useTranslation(),d=e.status==="open",c=e.volume?`${utils.formatAmountInUsd(e.volume)} vol`:void 0,m=o?.get(Ze(e.slug,"yes"))?.bestAsk??zl(e,"yes"),u=o?.get(Ze(e.slug,"no"))?.bestAsk??zl(e,"no"),f=t?.tradeOutcome??"yes",g=t?.outcomeKey,b=kl(e.outcomes).map(S=>({...S,price:S.tradeOutcome==="yes"?m:u})),h=Sl({marketDataEnabled:n,marketSlug:e.slug,outcomeKey:g??"",books:i});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),s());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsxRuntime.jsx(ui.Avatar,{src:e.image_url,name:An(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:An(e)}),c&&jsxRuntime.jsx("span",{className:"text-[8px] text-text-muted lg:text-xxs",children:c})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:rh(m)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:d?jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-2",children:b.map(({catalogOutcome:S,tradeOutcome:x,price:y})=>jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all focus-visible:outline-2 focus-visible:outline-primary/40 focus-visible:outline-offset-2",x==="yes"?t?.outcomeKey===S.key?"bg-primary text-primary-foreground":"bg-primary/10 text-primary":t?.outcomeKey===S.key?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:v=>{v.stopPropagation(),a?.(e,x,"buy",S.key);},children:y!=null?p(x==="yes"?"predict.market.action.yes":"predict.market.action.no",{price:oh(y)}):x==="yes"&&n?`${p("predict.market.yes")} \u2014`:p(x==="yes"?"predict.market.yes":"predict.market.no")},S.key))}):jsxRuntime.jsx("div",{className:"flex items-center justify-end",children:jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-text-muted/10 text-text-muted":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?p("predict.event.status.closed"):e.status==="voided"?p("predict.event.status.voided"):p("predict.event.status.pending")})})})]}),r&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(fs,{market:e,outcome:f,onTradeAction:(S,x,y)=>{if(!g){l?.(S,x,y);return}a?.(S,x,y,g);},enabled:h.legacyEnabled,orderbook:h.orderbook})})})})]})}function ah({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[i,s]=react.useState(false),[a,l]=react.useState(0),p=e.filter(u=>u.rules&&u.rules.length>0||vi(u));if(p.length===0)return null;let d=p[a]??p[0],c=d.rules&&d.rules.length>0?d.rules.join(`
77
77
 
78
- `):ha(p)??"";if(!c)return null;let f=c.length>200&&!n?c.slice(0,200)+"...":c;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),u.length>1&&jsxRuntime.jsxs(ui$1.Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsxRuntime.jsx(ui$1.DropdownTrigger,{children:jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:Do(p)})}),jsxRuntime.jsx(ui$1.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:d=>{l(Number(d)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((d,m)=>jsxRuntime.jsx(ui$1.DropdownItem,{className:ui$1.cn(m===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Do(d)},String(m)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),c.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>o(d=>!d),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>i(d=>!d),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:ui$1.cn("h-4 w-4 transition-transform",a&&"rotate-180")})]}),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:(()=>{let d=p.status,m=[];return p.created_at&&m.push({label:r("predict.event.timeline.created"),value:Hn(p.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:Hn(p.start_at),isActive:d!=="pending"}),d==="voided"?m.push({label:r("predict.event.timeline.voided"),value:Hn(p.closed_at??p.end_at),isActive:true}):d==="closed"?m.push({label:r("predict.event.timeline.closed"),value:Hn(p.closed_at??p.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:Hn(p.end_at),isActive:false}),m})().map((d,m,v)=>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 ${d.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),m<v.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${m<v.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:d.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:d.value})]})]},d.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:p.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:Xg(p.source)})]})]})]})]})}function th({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui$1.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui$1.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Yl="rgba(39,39,42,0.6)",sh="rgba(63,63,70,0.8)";function lh(e){return e==null?"-":utils.formatAmountInUsd(e)}function xi({eventSlug:e,source:t,lang:r,limit:n=4,onEventClick:o,onEventHover:a}){let{t:i}=i18n.useTranslation(),{data:s,isLoading:l}=reactPredict.useSimilarEvents({slug:e,source:t,lang:r,limit:n});return l||!s||s.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("div",{className:"-mx-1 px-1 py-1.5 lg:sticky lg:top-0 lg:z-10 lg:bg-[#0a0a0b]",children:jsxRuntime.jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-2",children:s.map(u=>jsxRuntime.jsx(Ql,{event:u,onClick:o,onHover:a},`${u.source}-${u.slug}`))})]})}function Ql({event:e,onClick:t,onHover:r}){let{t:n}=i18n.useTranslation(),o=Kr(e),a=react.useMemo(()=>lh(e.volume),[e.volume]);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:i=>{i.currentTarget.style.borderColor=sh,r?.(e);},onMouseLeave:i=>{i.currentTarget.style.borderColor=Yl;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Yl}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:o[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsxRuntime.jsx("span",{style:{fontSize:13,fontWeight:500,color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o}),jsxRuntime.jsxs("span",{style:{fontSize:10,color:"#a1a1aa"},children:[a," ",n("predict.event.volume")]})]}),jsxRuntime.jsx(ui$1.ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}var Ho=100,mh=15e3,Uo=["yes","no"];function fh(e){return e.source??"polymarket"}function gh(e){return {market_id:e.market_slug,outcome:e.outcome,bids:e.bids,asks:e.asks,spread:e.spread}}function hh(e){let t=e.filter(r=>r.status==="open").map(r=>({slug:r.slug,source:fh(r)})).sort((r,n)=>r.slug.localeCompare(n.slug));return JSON.stringify(t)}function bh(e){let t=e.filter(r=>r.status==="open").flatMap(r=>Uo.map(n=>({slug:r.slug,outcome:n}))).sort((r,n)=>{let o=r.slug.localeCompare(n.slug);return o!==0?o:r.outcome.localeCompare(n.outcome)});return JSON.stringify(t)}function Jl(e,t={}){let r=t.enabled??true,n=reactPredict.usePredictClient(),{wsClient:o}=reactPredict.usePredictWsClient(),a=reactQuery.useQueryClient(),i=react.useRef(new Set),s=react.useMemo(()=>r?hh(e):"[]",[r,e]),l=react.useMemo(()=>JSON.parse(s),[s]),u=react.useMemo(()=>new Map(l.map(h=>[h.slug,h])),[l]),p=react.useMemo(()=>new Set(l.map(h=>h.slug)),[l]),c=react.useRef(p);c.current=p;let f=react.useRef(u);f.current=u;let d=react.useMemo(()=>r?bh(e):"[]",[r,e]),m=react.useMemo(()=>JSON.parse(d),[d]),v=Hl(m),k=react.useCallback((h,x,b,y)=>{if(!y){_o(h,b);return}let P={...y,market_id:y.market_id||h,outcome:b};a.setQueryData(reactPredict.orderbookQueryKey(h,x,b),P),Bl(h,b,P);},[a]),g=react.useCallback(async(h,x)=>{try{let b=h.flatMap(P=>Uo.map(N=>({slug:P.slug,source:P.source,outcome:N}))),y=await n.getOrderbooks(b);if(x?.cancelled?.())return;for(let P of y){let N=P.outcome,w=Ze(P.slug,N);x?.markSeeded&&i.current.add(w),k(P.slug,P.source,N,P.orderbook);}}catch{if(!x?.markSeeded||x?.cancelled?.())return;for(let b of h)for(let y of Uo)i.current.add(Ze(b.slug,y));}},[k,n]);react.useEffect(()=>{if(!r){i.current.clear();return}let h=l.filter(b=>Uo.some(y=>!i.current.has(Ze(b.slug,y))));if(h.length===0)return;let x=false;return (async()=>{for(let b=0;b<h.length;b+=Ho){if(x)return;await g(h.slice(b,b+Ho),{cancelled:()=>x,markSeeded:true});}})(),()=>{x=true;}},[r,g,l]),react.useEffect(()=>{if(!r||l.length===0)return;let h=false,x=async()=>{for(let y=0;y<l.length;y+=Ho){if(h)return;await g(l.slice(y,y+Ho),{cancelled:()=>h});}},b=window.setInterval(()=>{x();},mh);return ()=>{h=true,window.clearInterval(b);}},[r,g,l]),react.useEffect(()=>{i.current.forEach(h=>{let[x,b]=h.split(":");p.has(x)||(i.current.delete(h),_o(x,b));});},[p]),react.useEffect(()=>{if(r&&o)return o.on("orderbook",h=>{let x=h.data.market_slug,b=h.data.outcome;if(b!=="yes"&&b!=="no"||!c.current.has(x))return;let y=f.current.get(x);y&&k(x,y.source,b,gh(h.data));})},[k,r,o]);let S=react.useRef(new Set);return react.useEffect(()=>{if(!r){let y=S.current;o&&y.size>0&&o.unsubscribe(["orderbook"],Array.from(y)),S.current=new Set;return}if(!o)return;let h=S.current,x=[],b=[];p.forEach(y=>{h.has(y)||x.push(y);}),h.forEach(y=>{p.has(y)||b.push(y);}),x.length>0&&o.subscribe(["orderbook"],x),b.length>0&&o.unsubscribe(["orderbook"],b),S.current=new Set(p);},[r,p,o]),react.useEffect(()=>{if(o)return ()=>{let h=Array.from(S.current);h.length>0&&o.unsubscribe(["orderbook"],h),S.current=new Set;}},[o]),v}var Nh={enabled:false};function Wo(e,t){return Jr(e.outcomes[0],t)??Number.NEGATIVE_INFINITY}function zo(e,t){if(!e.outcomes?.length)return e;let r=false,n=e.outcomes.map((o,a)=>{let i=a===0?"yes":"no",s=t.get(Ze(e.slug,i));if(!s)return o;let l=s.bestBid??o.best_bid,u=s.bestAsk??o.best_ask,p=s.bestAsk??o.price;return l===o.best_bid&&u===o.best_ask&&p===o.price?o:(r=true,{...o,best_bid:l,best_ask:u,price:p})});return r?{...e,outcomes:n}:e}function Mh(e,t){if(!e.markets?.length||t.size===0)return e;let r=false,n=e.markets.map(o=>{let a=zo(o,t);return a!==o&&(r=true),a});return r?{...e,markets:n}:e}function Eh({eventSlug:e,source:t,chain:r,lang:n,walletAddress:o,onSimilarEventClick:a,onSimilarEventHover:i,onBack:s,renderActivitySection:l,onInsufficientBalance:u,onSetupRequired:p,slippageBps:c,marketDataCapability:f=Nh,marketDataEvent:d,marketDataOrderbooks:m,onMarketDataBookSelectionChange:v}){let{t:k}=i18n.useTranslation(),{isDesktop:g}=ui$1.useScreen(),{onOpen:S}=uiScaffold.useAsyncModal(qr),{onOpen:h}=uiScaffold.useAsyncModal(No),{data:x,isLoading:b}=reactPredict.useEvent({slug:e,source:t,lang:n}),y=react.useMemo(()=>x&&yo({capability:f,legacyEvent:x,marketDataEvent:d}),[x,f,d]),P=react.useMemo(()=>{let Y=[...y?.markets||[]],re=Y.filter(ie=>ie.status==="open").sort((ie,he)=>Wo(he,f.enabled)-Wo(ie,f.enabled)),oe=Y.filter(ie=>ie.status!=="open").sort((ie,he)=>Wo(he,f.enabled)-Wo(ie,f.enabled));return [...re,...oe]},[y?.markets,f.enabled]),N=Jl(P,{enabled:!f.enabled}),w=react.useMemo(()=>y&&Mh(y,N),[y,N]),M=react.useMemo(()=>N.size===0?P:P.map(Y=>zo(Y,N)),[P,N]),[L,A]=react.useState(null),X=react.useCallback((Y,re,oe)=>{let ie=M.find(Pe=>Pe.slug===Y.slug)??zo(Y,N),he=w??y;A(Pe=>({market:ie,outcome:re,side:oe,version:(Pe?.version??0)+1})),!g&&he&&(oe==="sell"?h({params:{event:he,market:ie,initialOutcome:re,chain:r,slippageBps:c,onSetupRequired:p}}):S({params:{event:he,market:ie,initialOutcome:re,chain:r,slippageBps:c,onInsufficientBalance:u}}));},[g,y,w,M,N,r,c,S,h,u,p]),_=react.useMemo(()=>{let Y=L?.market.slug;return Y?M.find(re=>re.slug===Y)??zo(L.market,N):M[0]},[M,N,L?.market]);if(b){let Y=!!s;return g?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(rn,{showBack:Y})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(ci,{})})})]}):jsxRuntime.jsx(rn,{showBack:Y})}if(!x)return jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:"Event not found"});let U=w??y??x,q=L?`${L.market.slug}-${L.version}`:_?.slug??"default",ee=L?.side==="sell";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui$1.Button,{as:"a",onPress:s,startContent:jsxRuntime.jsx(ui$1.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:k("common.back")})}),jsxRuntime.jsx(Wn,{event:U,marketDataEnabled:f.enabled,marketDataOrderbooks:m,onMarketDataBookSelectionChange:v,orderbookQuotes:N,onTradeAction:X})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[_&&(ee?jsxRuntime.jsx(_n,{event:U,market:_,initialOutcome:L?.outcome,chain:r,slippageBps:c,onSetupRequired:p},q):jsxRuntime.jsx(Mn,{event:U,market:_,initialOutcome:L?.outcome,chain:r,slippageBps:c,onInsufficientBalance:u},q)),x&&jsxRuntime.jsx(xi,{eventSlug:e,source:U.source,lang:n,onEventClick:a,onEventHover:i})]})]}),x&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:l?l({event:U,walletAddress:o}):jsxRuntime.jsx(ii,{event:U,walletAddress:o})}),jsxRuntime.jsx(En,{}),jsxRuntime.jsx(ti,{}),jsxRuntime.jsx(Ga,{})]})}function Th({eventSlug:e,source:t,lang:r,onTradeAction:n}){let{data:o,isLoading:a,error:i}=reactPredict.useEvent({slug:e,source:t,lang:r});return a?jsxRuntime.jsx(rn,{}):i||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsxRuntime.jsx(Wn,{event:o,onTradeAction:n})}function ec(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ih(e){switch(e){case W.ONE_HOUR:return {interval:"1m",limit:100};case W.SIX_HOURS:return {interval:"5m",limit:72};case W.ONE_DAY:return {interval:"5m",limit:288};case W.ONE_MONTH:return {interval:"1h",limit:720};case W.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Dh=e=>{let{candlestickMarketSlugs:t,chartRange:r=vn,source:n}=e,o=reactPredict.usePredictClient(),a=react.useMemo(()=>Ih(r),[r]),{data:i,isLoading:s,error:l}=reactPredict.useEvent({slug:e.eventSlug,source:n}),u=react.useMemo(()=>{if(!i)return [];let m=new Set,v=Oo(i).filter(g=>m.has(g.slug)?false:(m.add(g.slug),true));return (t&&t.length>0?t.slice(0,4).map(g=>v.find(S=>S.slug===g)).filter(g=>g!==void 0):[...v].sort((g,S)=>ec(S)-ec(g)).slice(0,4)).map(g=>g.slug)},[t,i]),p=reactQuery.useQueries({queries:u.map(m=>({queryKey:reactPredict.candlesticksQueryKey(m,a),queryFn:()=>o.listCandlesticks(m,a),enabled:u.length>0}))}),c=p.some(m=>m.isLoading),f=react.useMemo(()=>{let m=new Map;return u.forEach((v,k)=>{let g=p[k]?.error;g&&m.set(v,g);}),m},[u,p]),d=react.useMemo(()=>{let m=new Map;return u.forEach((v,k)=>{let g=p[k]?.data;g&&m.set(v,g);}),m},[u,p]);return {event:i,isEventLoading:s,eventError:l,candlestickParams:a,candlesticks:d,isCandlesticksLoading:c,candlestickErrors:f}};function jo({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,a=react.useMemo(()=>Hh(e.created_at),[e.created_at]);return jsxRuntime.jsxs("div",{className:ui$1.cn("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsxRuntime.jsx(Ah,{src:n.profile_image,name:o,className:ui$1.cn("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsxRuntime.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:o}),jsxRuntime.jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",children:a})]}),jsxRuntime.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxRuntime.jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-neutral",children:[jsxRuntime.jsx(Fh,{className:"size-3.5"}),jsxRuntime.jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function Ah({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=react.useMemo(()=>Bh(t),[t]);return e?jsxRuntime.jsx("img",{src:e,alt:t,loading:"lazy",className:ui$1.cn("rounded-full object-cover",r)}):jsxRuntime.jsx("span",{className:ui$1.cn("flex items-center justify-center rounded-full text-xs font-semibold text-white",r),style:{backgroundColor:o},"aria-hidden":true,children:n})}function Fh({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsxRuntime.jsx("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})})}function Bh(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function Hh(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let a=Math.floor(o/24);if(a<7)return `${a}d`;let i=Math.floor(a/7);return i<5?`${i}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var qh={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},nc={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Qh=["latest","oldest","mostLiked"],Xh=600,Jh=112;function sc({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:a}=i18n.useTranslation(),[i,s]=react.useState("latest"),[l,u]=react.useState(false),p=qh[i],{data:c,isLoading:f,isFetchingNextPage:d,hasNextPage:m,fetchNextPage:v}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:p.order,ascending:p.ascending,holders_only:l}),k=react.useMemo(()=>c?.pages?.flatMap(M=>M.items)??[],[c?.pages]),g=react.useRef(null),{height:S}=hooks.useResizeObserver({ref:g}),h=n??(S||Xh),x=reactWindow.useDynamicRowHeight({defaultRowHeight:Jh,key:`${e}:${t}:${i}:${l}`}),b=k.length,y=b+(m?1:0),P=react.useCallback(M=>M<b,[b]),N=react.useCallback(async()=>{m&&!d&&await v();},[m,d,v]),w=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:P,loadMoreRows:N,rowCount:y,threshold:5});return jsxRuntime.jsxs("div",{className:ui$1.cn("flex h-full w-full flex-col",o),children:[jsxRuntime.jsx(e0,{sort:i,onSortChange:s,holdersOnly:l,onHoldersOnlyChange:u}),jsxRuntime.jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:g,children:f?jsxRuntime.jsx(t0,{}):k.length===0?jsxRuntime.jsx(r0,{message:a("predict.comments.empty")}):jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:h},onRowsRendered:w,rowComponent:Zh,rowCount:y,rowHeight:x,rowProps:{comments:k,itemCount:b,anonymousLabel:a("predict.comments.anonymous")},overscanCount:4})})]})}function Zh({index:e,style:t,comments:r,itemCount:n,anonymousLabel:o}){if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let a=r[e];return a?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(jo,{comment:a,anonymousLabel:o,isReply:!!a.parent_comment_id})}):null}function e0({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=i18n.useTranslation(),[a,i]=react.useState(false),s=react.useRef(null);return react.useEffect(()=>{if(!a)return;let l=p=>{s.current&&!s.current.contains(p.target)&&i(false);},u=p=>{p.key==="Escape"&&i(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[a]),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxRuntime.jsxs("div",{ref:s,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(n0,{className:"size-3.5 text-neutral"}),jsxRuntime.jsx("span",{children:o(nc[e])}),jsxRuntime.jsx(o0,{className:ui$1.cn("size-3.5 text-neutral transition-transform",a&&"rotate-180")})]}),a&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:Qh.map(l=>{let u=l===e;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(l),i(false);},className:ui$1.cn("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx("span",{className:"flex-1 font-medium",children:o(nc[l])}),u&&jsxRuntime.jsx(oc,{className:"size-4 text-primary"})]},l)})})]}),jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>n(!r),className:ui$1.cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsxRuntime.jsx("span",{className:ui$1.cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsxRuntime.jsx(oc,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function t0(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsxs("div",{className:"flex gap-x-2.5",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1 space-y-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-24 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-full rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function r0({message:e}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsxRuntime.jsx(ui$1.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function n0({className:e}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function o0({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function oc({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})}var a0=["signing","submitting","confirming","succeeded"];function i0(e){return {status:e,canSubmit:!a0.includes(e),canCancel:e!=="succeeded"&&e!=="submitting"&&e!=="confirming"}}var p0=10,cc="liberfi:predict_search_histories";function dn(){return search.createBrowserSearchHistoryStorage({key:cc,fallback:search.createMemorySearchHistoryStorage()})}function m0(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function Si(){let e=react.useMemo(()=>dn(),[]),t=react.useRef(e.read()),r=()=>{let i=e.read();return m0(t.current,i)?t.current:(t.current=i,i)},n=react.useSyncExternalStore(e.subscribe,r,r),o=react.useCallback(i=>{let s=i.trim();if(!s)return;let l=e.read().filter(u=>u!==s);e.write([s,...l].slice(0,p0));},[e]),a=react.useCallback(()=>{e.clear();},[e]);return {histories:n,addHistory:o,clearHistories:a}}function Pi({histories:e,onSelect:t,onClear:r,className:n}){let{t:o}=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:o("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(a=>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?.(a),children:a},a))})]})}function wi({onSelect:e,histories:t,onClear:r,className:n}){let o=Si(),a=t?[...t]:o.histories,i=r??o.clearHistories;return jsxRuntime.jsx(Pi,{className:ui$1.cn(n),histories:a,onSelect:e,onClear:i})}var M0=["ArrowDown","ArrowUp","Enter","Escape"];function E0(e){return M0.includes(e)}function Ni({value:e,onValueChange:t,onClear:r,onEscape:n,onNavigateKey:o,className:a}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:a,children:jsxRuntime.jsx(ui$1.StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,onKeyDown:s=>{E0(s.key)&&(s.key!=="Escape"&&s.preventDefault(),o?.(s.key));},placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent: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-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),n?.();},children:"Esc"})})})}function O0(e){switch(e.result_type){case "match_group":return "Match";case "prop_event":return "Prop";case "market":return "Market";default:return "Event"}}function I0({actionRef:e,...t}){return jsxRuntime.jsx("div",{ref:e,...t})}function Ei({result:e,href:t,LinkComponent:r,onSelect:n,onHover:o,highlighted:a=false,actionRef:i,className:s}){let{t:l}=i18n.useTranslation(),u=e.title,p=react.useMemo(()=>[O0(e),e.section,e.status].filter(Boolean).join(" \xB7 "),[e]),c=react.useMemo(()=>{function d({...m}){return jsxRuntime.jsx(r??"a",{ref:i,...m})}return d},[r,i]),f=react.useMemo(()=>{function d(m){return jsxRuntime.jsx(I0,{...m,actionRef:i})}return d},[i]);return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:c,as:f,className:ui$1.cn("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",a&&"bg-content2",s),"data-highlighted":a?"true":"false","aria-selected":a,onClick:d=>{t&&n&&d.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsxRuntime.jsx(ui$1.Avatar,{src:void 0,name:u||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:u}),jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:jsxRuntime.jsx("span",{className:"text-neutral-400",children:p||l("predict.search.title")})})]}),jsxRuntime.jsx(ui$1.ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Ci({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:a,hasNextPage:i,fetchNextPage:s}=reactPredict.useInfinitePredictSearch({q:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true}),l=react.useMemo(()=>n?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[n]);return {results:l,items:l,isLoading:o,isFetchingNextPage:a,hasNextPage:i??false,fetchNextPage:s}}var V0=64;function Ri({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,navigationRef:a,onEscape:i,...s}){let{results:l,isLoading:u,isFetchingNextPage:p,hasNextPage:c,fetchNextPage:f}=Ci(s),d=react.useRef(null),{height:m}=hooks.useResizeObserver({ref:d}),v=react.useRef(null),[k,g]=react.useState(null),S=react.useRef(null);S.current=k;let h=s.keyword??"",x=h==="",b=x||u?0:l.length,y=react.useCallback(_=>_<l.length,[l]),P=react.useCallback(async()=>{c&&!p&&await f();},[c,p,f]),N=react.useMemo(()=>c?l.length+1:l.length,[l,c]),w=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:y,loadMoreRows:P,rowCount:N,threshold:5}),M=react.useCallback(()=>{S.current=null,g(null);},[]),L=react.useCallback(_=>{if(_<0||_>=l.length){M();return}S.current=_,g(_),v.current?.scrollToRow({index:_,align:"smart",behavior:"auto"});},[M,v,l.length]),A=search.useSearchKeyboardNavigation({itemCount:b,hasNextPage:c&&!x&&!u,isFetchingNextPage:p,onSelectIndex:_=>{L(_);},onRequestNextPage:()=>{c&&!p&&f();},onEscape:()=>i?.()});a&&(a.current=A),react.useEffect(()=>()=>{a&&a.current===A&&(a.current=null);},[A,a]),react.useEffect(()=>(A.reset(),M(),()=>{M();}),[h,A,M]);let X=react.useCallback(_=>S.current!==_?false:(S.current=null,g(null),true),[]);return u?jsxRuntime.jsx(G0,{className:o}):l.length===0?jsxRuntime.jsx(Y0,{className:o}):jsxRuntime.jsx("div",{className:ui$1.cn("w-full h-full flex flex-col",o),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:d,children:jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:m},listRef:v,onRowsRendered:w,rowComponent:j0,rowCount:N,rowHeight:V0,rowProps:{results:l,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,highlightedIndex:x?null:A.highlightedIndex,pendingIndex:x?null:k,consumePending:X},overscanCount:5})})})}function j0({index:e,style:t,results:r,onSelect:n,getEventHref:o,LinkComponent:a,onHover:i,highlightedIndex:s,pendingIndex:l,consumePending:u}){let p=r[e],c=react.useRef(null);return react.useLayoutEffect(()=>{l===e&&u(e)&&c.current?.click();},[u,e,l]),p?jsxRuntime.jsx("div",{style:t,"data-index":e,children:jsxRuntime.jsx(Ei,{result:p,href:o?.(p)??p.detail_url,LinkComponent:a,onSelect:n,onHover:i,highlighted:s===e,actionRef:c})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})})}function G0({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 Y0({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")})]})}var bc=()=>{};function _i({onKeywordChange:e,onSelectResult:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:a,source:i}){let s=react.useMemo(()=>dn(),[]),l=search.useSearchController({storage:s,onQueryChange:e??bc,onDismiss:a??bc}),u=react.useRef(null),p=l.dismiss,c=react.useCallback(f=>{if(u.current){u.current.onKey(f);return}f==="Escape"&&p();},[p]);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(Ni,{value:l.text,onValueChange:l.setText,onClear:l.clearQuery,onEscape:l.dismiss,onNavigateKey:c}),!l.query&&jsxRuntime.jsx(wi,{histories:l.history,onSelect:l.commitQuery,onClear:l.clearHistory}),jsxRuntime.jsx(Ri,{className:"flex-auto min-h-0",keyword:l.query,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:i,navigationRef:u,onEscape:l.dismiss})]})}var qo="predict-search";function cb({id:e=qo}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(db,{...t})})}function db({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=i18n.useTranslation(),{isMobile:a}=ui$1.useScreen(),i=react.useCallback(l=>{n(l);},[n]),s=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:a?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxRuntime.jsxs(ui$1.ModalContent,{className:"w-full h-full",style:{borderRadius:a?void 0:14,border:a?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:a?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},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:o("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(_i,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectResult:i,onEscape:s})})]})})}function hb({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=i18n.useTranslation(),{isDesktop:o}=ui$1.useScreen(),{onOpen:a,onClose:i}=uiScaffold.useAsyncModal(qo),s=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let p=await a({params:t});p&&s(p);}),u=hooks.useCallbackRef(()=>{i();});return react.useEffect(()=>{let p=c=>{let f=document.activeElement,d=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");c.key==="/"&&!d&&(c.preventDefault(),l()),c.key==="Escape"&&(c.preventDefault(),u());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[l,u]),o?jsxRuntime.jsx(ui$1.Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsxRuntime.jsx(ui$1.SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsxRuntime.jsx(ui$1.Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:ui$1.cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:n("predict.search.placeholder")}):jsxRuntime.jsx(ui$1.Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:ui$1.cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsxRuntime.jsx(ui$1.SearchIcon,{width:16,height:16,className:"text-foreground"})})}var Pc=()=>{};function xb({onKeywordChange:e}){let t=react.useMemo(()=>dn(),[]),r=search.useSearchController({storage:t,onQueryChange:e??Pc,onDismiss:Pc});return {text:r.text,keyword:r.query,setText:r.setText,setKeyword:r.commitQuery,clearKeyword:r.clearQuery}}var Ii=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],Tc=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],Mc={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Ec={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Sb(e,t){if(!e)return "$5K+";let r=Tc.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Di({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:a,onRefresh:i}){let{t:s}=i18n.useTranslation(),[l,u]=react.useState(false),[p,c]=react.useState(false),[f,d]=react.useState(false),[m,v]=react.useState(false),k=react.useRef(null),g=react.useRef(null),S=Ii.find(b=>b.value===e)??Ii[0],h=react.useCallback(b=>{k.current&&!k.current.contains(b.target)&&u(false),g.current&&!g.current.contains(b.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)),[h]);let x=react.useCallback(()=>{i?.(),v(true),setTimeout(()=>v(false),700);},[i]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
78
+ `):vi(d)??"";if(!c)return null;let m=c.length>200&&!o?c.slice(0,200)+"...":c;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),p.length>1&&jsxRuntime.jsxs(ui.Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsxRuntime.jsx(ui.DropdownTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:An(d)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":r("predict.event.selectRules"),selectionMode:"single",selectedKeys:[String(a)],onAction:u=>{l(Number(u)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:p.map((u,f)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(f===a?"bg-content2 text-foreground":"text-text-muted","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:An(u)},String(f)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),c.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(u=>!u),className:"text-xs text-text-muted hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(u=>!u),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-text-muted lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:(()=>{let u=d.status,f=[];return d.created_at&&f.push({label:r("predict.event.timeline.created"),value:Wo(d.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Wo(d.start_at),isActive:u!=="pending"}),u==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Wo(d.closed_at??d.end_at),isActive:true}):u==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Wo(d.closed_at??d.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Wo(d.end_at),isActive:false}),f})().map((u,f,g)=>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 ${u.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:u.label}),jsxRuntime.jsx("span",{className:"text-xs text-text-muted lg:text-sm",children:u.value})]})]},u.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-text-muted mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:d.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-text-muted",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:nh(d.source)})]})]})]})]})}function lh({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-text-secondary",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Yl="hsl(var(--heroui-content3) / 0.6)",fh="hsl(var(--heroui-content4) / 0.8)";function gh(e){return e==null?"-":utils.formatAmountInUsd(e)}function bs({eventSlug:e,source:t,lang:r,limit:o=4,onEventClick:n,onEventHover:i}){let{t:s}=i18n.useTranslation(),{data:a,isLoading:l}=reactPredict.useSimilarEvents({slug:e,source:t,lang:r,limit:o});return l||!a||a.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("div",{className:"-mx-1 px-1 py-1.5 lg:sticky lg:top-0 lg:z-10 lg:bg-surface-base",children:jsxRuntime.jsx("span",{style:{color:"var(--color-text-primary)",fontSize:14,fontWeight:600},children:s("predict.similar.title")})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(p=>jsxRuntime.jsx(Ql,{event:p,onClick:n,onHover:i},`${p.source}-${p.slug}`))})]})}function Ql({event:e,onClick:t,onHover:r}){let{t:o}=i18n.useTranslation(),n=Kr(e),i=react.useMemo(()=>gh(e.volume),[e.volume]);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=fh,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=Yl;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Yl}`,background:"hsl(var(--heroui-content2) / 0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:n[0]||"?",radius:"full",className:"size-9 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,gap:2},children:[jsxRuntime.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),jsxRuntime.jsxs("span",{style:{fontSize:10,color:"var(--color-text-secondary)"},children:[i," ",o("predict.event.volume")]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"var(--color-text-muted)"}})]})}var Un=100,yh=15e3,Wn=["yes","no"];function kh(e){return e.source??"polymarket"}function Sh(e){return {market_id:e.market_slug,outcome:e.outcome,bids:e.bids,asks:e.asks,spread:e.spread}}function Ph(e){let t=e.filter(r=>r.status==="open").map(r=>({slug:r.slug,source:kh(r)})).sort((r,o)=>r.slug.localeCompare(o.slug));return JSON.stringify(t)}function Nh(e){let t=e.filter(r=>r.status==="open").flatMap(r=>Wn.map(o=>({slug:r.slug,outcome:o}))).sort((r,o)=>{let n=r.slug.localeCompare(o.slug);return n!==0?n:r.outcome.localeCompare(o.outcome)});return JSON.stringify(t)}function Jl(e,t={}){let r=t.enabled??true,o=reactPredict.usePredictClient(),{wsClient:n}=reactPredict.usePredictWsClient(),i=reactQuery.useQueryClient(),s=react.useRef(new Set),a=react.useMemo(()=>r?Ph(e):"[]",[r,e]),l=react.useMemo(()=>JSON.parse(a),[a]),p=react.useMemo(()=>new Map(l.map(x=>[x.slug,x])),[l]),d=react.useMemo(()=>new Set(l.map(x=>x.slug)),[l]),c=react.useRef(d);c.current=d;let m=react.useRef(p);m.current=p;let u=react.useMemo(()=>r?Nh(e):"[]",[r,e]),f=react.useMemo(()=>JSON.parse(u),[u]),g=Bl(f),b=react.useCallback((x,y,v,k)=>{if(!k){_n(x,v);return}let P={...k,market_id:k.market_id||x,outcome:v};i.setQueryData(reactPredict.orderbookQueryKey(x,y,v),P),Fl(x,v,P);},[i]),h=react.useCallback(async(x,y)=>{try{let v=x.flatMap(P=>Wn.map(M=>({slug:P.slug,source:P.source,outcome:M}))),k=await o.getOrderbooks(v);if(y?.cancelled?.())return;for(let P of k){let M=P.outcome,N=Ze(P.slug,M);y?.markSeeded&&s.current.add(N),b(P.slug,P.source,M,P.orderbook);}}catch{if(!y?.markSeeded||y?.cancelled?.())return;for(let v of x)for(let k of Wn)s.current.add(Ze(v.slug,k));}},[b,o]);react.useEffect(()=>{if(!r){s.current.clear();return}let x=l.filter(v=>Wn.some(k=>!s.current.has(Ze(v.slug,k))));if(x.length===0)return;let y=false;return (async()=>{for(let v=0;v<x.length;v+=Un){if(y)return;await h(x.slice(v,v+Un),{cancelled:()=>y,markSeeded:true});}})(),()=>{y=true;}},[r,h,l]),react.useEffect(()=>{if(!r||l.length===0)return;let x=false,y=async()=>{for(let k=0;k<l.length;k+=Un){if(x)return;await h(l.slice(k,k+Un),{cancelled:()=>x});}},v=window.setInterval(()=>{y();},yh);return ()=>{x=true,window.clearInterval(v);}},[r,h,l]),react.useEffect(()=>{s.current.forEach(x=>{let[y,v]=x.split(":");d.has(y)||(s.current.delete(x),_n(y,v));});},[d]),react.useEffect(()=>{if(r&&n)return n.on("orderbook",x=>{let y=x.data.market_slug,v=x.data.outcome;if(v!=="yes"&&v!=="no"||!c.current.has(y))return;let k=m.current.get(y);k&&b(y,k.source,v,Sh(x.data));})},[b,r,n]);let S=react.useRef(new Set);return react.useEffect(()=>{if(!r){let k=S.current;n&&k.size>0&&n.unsubscribe(["orderbook"],Array.from(k)),S.current=new Set;return}if(!n)return;let x=S.current,y=[],v=[];d.forEach(k=>{x.has(k)||y.push(k);}),x.forEach(k=>{d.has(k)||v.push(k);}),y.length>0&&n.subscribe(["orderbook"],y),v.length>0&&n.unsubscribe(["orderbook"],v),S.current=new Set(d);},[r,d,n]),react.useEffect(()=>{if(n)return ()=>{let x=Array.from(S.current);x.length>0&&n.unsubscribe(["orderbook"],x),S.current=new Set;}},[n]),g}var Oh={enabled:false};function zn(e,t){return Jr(e.outcomes[0],t)??Number.NEGATIVE_INFINITY}function $n(e,t){if(!e.outcomes?.length)return e;let r=false,o=e.outcomes.map((n,i)=>{let s=i===0?"yes":"no",a=t.get(Ze(e.slug,s));if(!a)return n;let l=a.bestBid??n.best_bid,p=a.bestAsk??n.best_ask,d=a.bestAsk??n.price;return l===n.best_bid&&p===n.best_ask&&d===n.price?n:(r=true,{...n,best_bid:l,best_ask:p,price:d})});return r?{...e,outcomes:o}:e}function _h(e,t){if(!e.markets?.length||t.size===0)return e;let r=false,o=e.markets.map(n=>{let i=$n(n,t);return i!==n&&(r=true),i});return r?{...e,markets:o}:e}function Ih({eventSlug:e,source:t,chain:r,lang:o,walletAddress:n,onSimilarEventClick:i,onSimilarEventHover:s,onBack:a,renderActivitySection:l,onInsufficientBalance:p,onSetupRequired:d,slippageBps:c,marketDataCapability:m=Oh,marketDataEvent:u,marketDataOrderbooks:f,onMarketDataBookSelectionChange:g}){let{t:b}=i18n.useTranslation(),{isDesktop:h}=ui.useScreen(),{onOpen:S}=uiScaffold.useAsyncModal(qr),{onOpen:x}=uiScaffold.useAsyncModal(En),{data:y,isLoading:v}=reactPredict.useEvent({slug:e,source:t,lang:o}),k=react.useMemo(()=>y&&Sn({capability:m,legacyEvent:y,marketDataEvent:u}),[y,m,u]),P=react.useMemo(()=>{let W=[...k?.markets||[]],te=W.filter(se=>se.status==="open").sort((se,he)=>zn(he,m.enabled)-zn(se,m.enabled)),ne=W.filter(se=>se.status!=="open").sort((se,he)=>zn(he,m.enabled)-zn(se,m.enabled));return [...te,...ne]},[k?.markets,m.enabled]),M=Jl(P,{enabled:!m.enabled}),N=react.useMemo(()=>k&&_h(k,M),[k,M]),w=react.useMemo(()=>M.size===0?P:P.map(W=>$n(W,M)),[P,M]),[R,A]=react.useState(null),X=react.useCallback((W,te,ne)=>{let se=w.find(Pe=>Pe.slug===W.slug)??$n(W,M),he=N??k;A(Pe=>({market:se,outcome:te,side:ne,version:(Pe?.version??0)+1})),!h&&he&&(ne==="sell"?x({params:{event:he,market:se,initialOutcome:te,chain:r,slippageBps:c,onSetupRequired:d}}):S({params:{event:he,market:se,initialOutcome:te,chain:r,slippageBps:c,onInsufficientBalance:p}}));},[h,k,N,w,M,r,c,S,x,p,d]),L=react.useMemo(()=>{let W=R?.market.slug;return W?w.find(te=>te.slug===W)??$n(R.market,M):w[0]},[w,M,R?.market]);if(v){let W=!!a;return h?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(ro,{showBack:W})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(cs,{})})})]}):jsxRuntime.jsx(ro,{showBack:W})}if(!y)return jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:b("predict.event.notFound")});let G=N??k??y,U=R?`${R.market.slug}-${R.version}`:L?.slug??"default",oe=R?.side==="sell";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[a&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:a,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-text-muted bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:b("common.back")})}),jsxRuntime.jsx($o,{event:G,marketDataEnabled:m.enabled,marketDataOrderbooks:f,onMarketDataBookSelectionChange:g,orderbookQuotes:M,onTradeAction:X})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[L&&(oe?jsxRuntime.jsx(_o,{event:G,market:L,initialOutcome:R?.outcome,chain:r,slippageBps:c,onSetupRequired:d},U):jsxRuntime.jsx(Eo,{event:G,market:L,initialOutcome:R?.outcome,chain:r,slippageBps:c,onInsufficientBalance:p},U)),y&&jsxRuntime.jsx(bs,{eventSlug:e,source:G.source,lang:o,onEventClick:i,onEventHover:s})]})]}),y&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:l?l({event:G,walletAddress:n}):jsxRuntime.jsx(ss,{event:G,walletAddress:n})}),jsxRuntime.jsx(Co,{}),jsxRuntime.jsx(ts,{}),jsxRuntime.jsx(Gi,{})]})}function Fh({eventSlug:e,source:t,lang:r,onTradeAction:o}){let{t:n}=i18n.useTranslation(),{data:i,isLoading:s,error:a}=reactPredict.useEvent({slug:e,source:t,lang:r});return s?jsxRuntime.jsx(ro,{}):a||!i?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:a?.message||n("predict.event.notFound")}):jsxRuntime.jsx($o,{event:i,onTradeAction:o})}function ec(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function zh(e){switch(e){case $.ONE_HOUR:return {interval:"1m",limit:100};case $.SIX_HOURS:return {interval:"5m",limit:72};case $.ONE_DAY:return {interval:"5m",limit:288};case $.ONE_MONTH:return {interval:"1h",limit:720};case $.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var $h=e=>{let{candlestickMarketSlugs:t,chartRange:r=bo,source:o}=e,n=reactPredict.usePredictClient(),i=react.useMemo(()=>zh(r),[r]),{data:s,isLoading:a,error:l}=reactPredict.useEvent({slug:e.eventSlug,source:o}),p=react.useMemo(()=>{if(!s)return [];let f=new Set,g=In(s).filter(h=>f.has(h.slug)?false:(f.add(h.slug),true));return (t&&t.length>0?t.slice(0,4).map(h=>g.find(S=>S.slug===h)).filter(h=>h!==void 0):[...g].sort((h,S)=>ec(S)-ec(h)).slice(0,4)).map(h=>h.slug)},[t,s]),d=reactQuery.useQueries({queries:p.map(f=>({queryKey:reactPredict.candlesticksQueryKey(f,i),queryFn:()=>n.listCandlesticks(f,i),enabled:p.length>0}))}),c=d.some(f=>f.isLoading),m=react.useMemo(()=>{let f=new Map;return p.forEach((g,b)=>{let h=d[b]?.error;h&&f.set(g,h);}),f},[p,d]),u=react.useMemo(()=>{let f=new Map;return p.forEach((g,b)=>{let h=d[b]?.data;h&&f.set(g,h);}),f},[p,d]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:u,isCandlesticksLoading:c,candlestickErrors:m}};function Gn({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:o}=e,n=o.name||o.pseudonym||t,i=react.useMemo(()=>Gh(e.created_at),[e.created_at]);return jsxRuntime.jsxs("div",{className:ui.cn("flex gap-x-2.5 px-1 py-3 border-b border-border/40 lg:px-2",r&&"pl-8 lg:pl-9"),children:[jsxRuntime.jsx(Kh,{src:o.profile_image,name:n,className:ui.cn("shrink-0",r?"size-6":"size-8 lg:size-7")}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-x-2",children:[jsxRuntime.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n}),jsxRuntime.jsx("span",{className:"ml-auto shrink-0 text-xs text-text-muted",children:i})]}),jsxRuntime.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:e.body}),jsxRuntime.jsxs("div",{className:"mt-2 flex items-center gap-x-1 text-text-muted",children:[jsxRuntime.jsx(Vh,{className:"size-3.5"}),jsxRuntime.jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function Kh({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=react.useMemo(()=>jh(t),[t]);return e?jsxRuntime.jsx("img",{src:e,alt:t,loading:"lazy",className:ui.cn("rounded-full object-cover",r)}):jsxRuntime.jsx("span",{className:ui.cn("flex items-center justify-center rounded-full text-xs font-semibold text-text-primary",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function Vh({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsxRuntime.jsx("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})})}function jh(e){let t=0;for(let o=0;o<e.length;o++)t=e.charCodeAt(o)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function Gh(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let o=Math.floor(r/60);if(o<60)return `${o}m`;let n=Math.floor(o/60);if(n<24)return `${n}h`;let i=Math.floor(n/24);if(i<7)return `${i}d`;let s=Math.floor(i/7);return s<5?`${s}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var ov={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},oc={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},nv=["latest","oldest","mostLiked"],iv=600,sv=112;function ac({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState("latest"),[l,p]=react.useState(false),d=ov[s],{data:c,isLoading:m,isFetchingNextPage:u,hasNextPage:f,fetchNextPage:g}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:d.order,ascending:d.ascending,holders_only:l}),b=react.useMemo(()=>c?.pages?.flatMap(w=>w.items)??[],[c?.pages]),h=react.useRef(null),{height:S}=hooks.useResizeObserver({ref:h}),x=o??(S||iv),y=reactWindow.useDynamicRowHeight({defaultRowHeight:sv,key:`${e}:${t}:${s}:${l}`}),v=b.length,k=v+(f?1:0),P=react.useCallback(w=>w<v,[v]),M=react.useCallback(async()=>{f&&!u&&await g();},[f,u,g]),N=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:P,loadMoreRows:M,rowCount:k,threshold:5});return jsxRuntime.jsxs("div",{className:ui.cn("flex h-full w-full flex-col",n),children:[jsxRuntime.jsx(lv,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:p}),jsxRuntime.jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:h,children:m?jsxRuntime.jsx(cv,{}):b.length===0?jsxRuntime.jsx(dv,{message:i("predict.comments.empty")}):jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:x},onRowsRendered:N,rowComponent:av,rowCount:k,rowHeight:y,rowProps:{comments:b,itemCount:v,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function av({index:e,style:t,comments:r,itemCount:o,anonymousLabel:n}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let i=r[e];return i?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(Gn,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function lv({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:o}){let{t:n}=i18n.useTranslation(),[i,s]=react.useState(false),a=react.useRef(null);return react.useEffect(()=>{if(!i)return;let l=d=>{a.current&&!a.current.contains(d.target)&&s(false);},p=d=>{d.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",p);}},[i]),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxRuntime.jsxs("div",{ref:a,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(uv,{className:"size-3.5 text-text-muted"}),jsxRuntime.jsx("span",{children:n(oc[e])}),jsxRuntime.jsx(pv,{className:ui.cn("size-3.5 text-text-muted transition-transform",i&&"rotate-180")})]}),i&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1.5 min-w-40 overflow-hidden rounded-xl border border-border bg-content1 p-1 shadow-xl",children:nv.map(l=>{let p=l===e;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(l),s(false);},className:ui.cn("flex w-full items-center gap-x-2 rounded-lg px-3 py-2 text-left text-sm transition-colors cursor-pointer",p?"bg-primary/10 text-primary":"text-text-muted hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx("span",{className:"flex-1 font-medium",children:n(oc[l])}),p&&jsxRuntime.jsx(nc,{className:"size-4 text-primary"})]},l)})})]}),jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>o(!r),className:ui.cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-text-muted hover:text-foreground"),children:[jsxRuntime.jsx("span",{className:ui.cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-border-control"),children:r&&jsxRuntime.jsx(nc,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function cv(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-4 px-1 py-3 lg:px-2",children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsxs("div",{className:"flex gap-x-2.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-8 shrink-0 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1 space-y-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-24 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-full rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-2/3 rounded"})]})]},t))})}function dv({message:e}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-text-muted"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-text-muted",children:e})]})}function uv({className:e}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function pv({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function nc({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",className:e,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})}var mv=["signing","submitting","confirming","succeeded"];function fv(e){return {status:e,canSubmit:!mv.includes(e),canCancel:e!=="succeeded"&&e!=="submitting"&&e!=="confirming"}}var yv=10,cc="liberfi:predict_search_histories";function uo(){return search.createBrowserSearchHistoryStorage({key:cc,fallback:search.createMemorySearchHistoryStorage()})}function kv(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function Ss(){let e=react.useMemo(()=>uo(),[]),t=react.useRef(e.read()),r=()=>{let s=e.read();return kv(t.current,s)?t.current:(t.current=s,s)},o=react.useSyncExternalStore(e.subscribe,r,r),n=react.useCallback(s=>{let a=s.trim();if(!a)return;let l=e.read().filter(p=>p!==a);e.write([a,...l].slice(0,yv));},[e]),i=react.useCallback(()=>{e.clear();},[e]);return {histories:o,addHistory:n,clearHistories:i}}function Ps({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-text-muted",onPress:r,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-text-muted","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function Ns({onSelect:e,histories:t,onClear:r,className:o}){let n=Ss(),i=t?[...t]:n.histories,s=r??n.clearHistories;return jsxRuntime.jsx(Ps,{className:ui.cn(o),histories:i,onSelect:e,onClear:s})}var Iv=["ArrowDown","ArrowUp","Enter","Escape"];function Dv(e){return Iv.includes(e)}function Ms({value:e,onValueChange:t,onClear:r,onEscape:o,onNavigateKey:n,className:i}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:i,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,onKeyDown:a=>{Dv(a.key)&&(a.key!=="Escape"&&a.preventDefault(),n?.(a.key));},placeholder:s("predict.search.placeholder"),classNames:{inputWrapper:["!bg-surface-strong/60","!border-border-control/50","data-[hover=true]:!bg-surface-strong","group-data-[focus=true]:!bg-surface-strong","group-data-[focus=true]:!border-border-control/80"].join(" ")},startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-text-muted"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-text-muted",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-text-muted bg-transparent border border-border-control/50 rounded-lg cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:s("common.escape")})})})}function Wv(e){switch(e.result_type){case "match_group":return "predict.search.type.match";case "prop_event":return "predict.search.type.prop";case "market":return "predict.search.type.market";default:return "predict.search.type.event"}}function zv({actionRef:e,...t}){return jsxRuntime.jsx("div",{ref:e,...t})}function Es({result:e,href:t,LinkComponent:r,onSelect:o,onHover:n,highlighted:i=false,actionRef:s,className:a}){let{t:l}=i18n.useTranslation(),p=e.title,d=react.useMemo(()=>[l(Wv(e)),e.section,e.status].filter(Boolean).join(" \xB7 "),[e,l]),c=react.useMemo(()=>{function u({...f}){return jsxRuntime.jsx(r??"a",{ref:s,...f})}return u},[r,s]),m=react.useMemo(()=>{function u(f){return jsxRuntime.jsx(zv,{...f,actionRef:s})}return u},[s]);return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:c,as:m,className:ui.cn("group w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i&&"bg-content2",a),"data-highlighted":i?"true":"false","aria-selected":i,onClick:u=>{t&&o&&u.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:void 0,name:p||l("predict.event.fallbackName"),radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:p}),jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-text-muted lg:text-xs",children:jsxRuntime.jsx("span",{className:"text-text-secondary",children:d||l("predict.search.title")})})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Cs({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=reactPredict.useInfinitePredictSearch({q:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true}),l=react.useMemo(()=>o?.pages.flatMap(p=>p.items).filter(p=>p!=null)??[],[o]);return {results:l,items:l,isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var Zv=64;function Rs({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,navigationRef:i,onEscape:s,...a}){let{results:l,isLoading:p,isFetchingNextPage:d,hasNextPage:c,fetchNextPage:m}=Cs(a),u=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:u}),g=react.useRef(null),[b,h]=react.useState(null),S=react.useRef(null);S.current=b;let x=a.keyword??"",y=x==="",v=y||p?0:l.length,k=react.useCallback(L=>L<l.length,[l]),P=react.useCallback(async()=>{c&&!d&&await m();},[c,d,m]),M=react.useMemo(()=>c?l.length+1:l.length,[l,c]),N=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:k,loadMoreRows:P,rowCount:M,threshold:5}),w=react.useCallback(()=>{S.current=null,h(null);},[]),R=react.useCallback(L=>{if(L<0||L>=l.length){w();return}S.current=L,h(L),g.current?.scrollToRow({index:L,align:"smart",behavior:"auto"});},[w,g,l.length]),A=search.useSearchKeyboardNavigation({itemCount:v,hasNextPage:c&&!y&&!p,isFetchingNextPage:d,onSelectIndex:L=>{R(L);},onRequestNextPage:()=>{c&&!d&&m();},onEscape:()=>s?.()});i&&(i.current=A),react.useEffect(()=>()=>{i&&i.current===A&&(i.current=null);},[A,i]),react.useEffect(()=>(A.reset(),w(),()=>{w();}),[x,A,w]);let X=react.useCallback(L=>S.current!==L?false:(S.current=null,h(null),true),[]);return p?jsxRuntime.jsx(tx,{className:n}):l.length===0?jsxRuntime.jsx(rx,{className:n}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",n),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:f},listRef:g,onRowsRendered:N,rowComponent:ex,rowCount:M,rowHeight:Zv,rowProps:{results:l,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,highlightedIndex:y?null:A.highlightedIndex,pendingIndex:y?null:b,consumePending:X},overscanCount:5})})})}function ex({index:e,style:t,results:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s,highlightedIndex:a,pendingIndex:l,consumePending:p}){let d=r[e],c=react.useRef(null);return react.useLayoutEffect(()=>{l===e&&p(e)&&c.current?.click();},[p,e,l]),d?jsxRuntime.jsx("div",{style:t,"data-index":e,children:jsxRuntime.jsx(Es,{result:d,href:n?.(d)??d.detail_url,LinkComponent:i,onSelect:o,onHover:s,highlighted:a===e,actionRef:c})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function tx({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-text-muted",children:t("predict.search.loading")})]})}function rx({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-text-muted"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("predict.search.noResults")})]})}var vc=()=>{};function Os({onKeywordChange:e,onSelectResult:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let a=react.useMemo(()=>uo(),[]),l=search.useSearchController({storage:a,onQueryChange:e??vc,onDismiss:i??vc}),p=react.useRef(null),d=l.dismiss,c=react.useCallback(m=>{if(p.current){p.current.onKey(m);return}m==="Escape"&&d();},[d]);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(Ms,{value:l.text,onValueChange:l.setText,onClear:l.clearQuery,onEscape:l.dismiss,onNavigateKey:c}),!l.query&&jsxRuntime.jsx(Ns,{histories:l.history,onSelect:l.commitQuery,onClear:l.clearHistory}),jsxRuntime.jsx(Rs,{className:"flex-auto min-h-0",keyword:l.query,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s,navigationRef:p,onEscape:l.dismiss})]})}var Qn="predict-search";function vx({id:e=Qn}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(xx,{...t})})}function xx({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),s=react.useCallback(l=>{o(l);},[o]),a=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:i?"full":"lg",hideCloseButton:true,backdrop:"opaque",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",style:{borderRadius:i?void 0:14,border:i?void 0:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(Os,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectResult:s,onEscape:a})})]})})}function Nx({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=i18n.useTranslation(),{isDesktop:n}=ui.useScreen(),{onOpen:i,onClose:s}=uiScaffold.useAsyncModal(Qn),a=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let d=await i({params:t});d&&a(d);}),p=hooks.useCallbackRef(()=>{s();});return react.useEffect(()=>{let d=c=>{let m=document.activeElement,u=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");c.key==="/"&&!u&&(c.preventDefault(),l()),c.key==="Escape"&&(c.preventDefault(),p());};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d);}},[l,p]),n?jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",onPress:l,variant:"bordered",startContent:jsxRuntime.jsx(ui.SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsxRuntime.jsx(ui.Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:ui.cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-text-muted",r),children:o("predict.search.placeholder")}):jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:true,onPress:l,variant:"bordered",className:ui.cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsxRuntime.jsx(ui.SearchIcon,{width:16,height:16,className:"text-foreground"})})}var Pc=()=>{};function Ex({onKeywordChange:e}){let t=react.useMemo(()=>uo(),[]),r=search.useSearchController({storage:t,onQueryChange:e??Pc,onDismiss:Pc});return {text:r.text,keyword:r.query,setText:r.setText,setKeyword:r.commitQuery,clearKeyword:r.clearQuery}}var Is=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],Tc=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],wc={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"8px 12px",fontSize:14,color:"var(--color-text-primary)",cursor:"pointer",transition:"all 0.15s"},Ec={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid var(--color-border-control)",background:"var(--color-surface-interactive)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Rx(e,t){if(!e)return "$5K+";let r=Tc.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Ds({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=i18n.useTranslation(),[l,p]=react.useState(false),[d,c]=react.useState(false),[m,u]=react.useState(false),[f,g]=react.useState(false),b=react.useRef(null),h=react.useRef(null),S=Is.find(v=>v.value===e)??Is[0],x=react.useCallback(v=>{b.current&&!b.current.contains(v.target)&&p(false),h.current&&!h.current.contains(v.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)),[x]);let y=react.useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
79
79
  @keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
80
80
  .match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
81
- .match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
82
- `}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:k,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:Mc,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(b=>!b),c(false);},children:[jsxRuntime.jsx(Pb,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(S.labelKey)}),jsxRuntime.jsx(Cc,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Ec,width:224,padding:4},children:Ii.map(b=>{let y=e===b.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:P=>{y||(P.currentTarget.style.background="rgba(39,39,42,0.5)",P.currentTarget.style.color="#fff");},onMouseLeave:P=>{y||(P.currentTarget.style.background="transparent",P.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===b.value?n(!r):t(b.value),u(false);},children:[jsxRuntime.jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsxRuntime.jsx(wb,{type:b.icon})}),jsxRuntime.jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500},children:s(b.labelKey)}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:s(b.descKey)})]}),y&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]}),a&&jsxRuntime.jsxs("div",{ref:g,style:{position:"relative"},children:[jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:Mc,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(b=>!b),u(false);},children:[jsxRuntime.jsx(Nb,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:Sb(o,s)}),jsxRuntime.jsx(Mb,{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false)}),jsxRuntime.jsx(Cc,{open:p})]}),f&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxRuntime.jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxRuntime.jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),s("predict.matches.filter.liquidityFilter")]}),jsxRuntime.jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:s("predict.matches.filter.tooltipDesc")}),jsxRuntime.jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:s("predict.matches.filter.tooltipNote")})]})]})]}),p&&jsxRuntime.jsxs("div",{style:{...Ec,right:0,width:176},children:[jsxRuntime.jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:s("predict.matches.filter.minVolumeEach")})}),jsxRuntime.jsx("div",{style:{padding:4},children:Tc.map(b=>{let y=b.value===0?!o:o===b.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:P=>{y||(P.currentTarget.style.background="rgba(39,39,42,0.5)",P.currentTarget.style.color="#fff");},onMouseLeave:P=>{y||(P.currentTarget.style.background="transparent",P.currentTarget.style.color="#a1a1aa");},onClick:()=>{a?.(b.value===0?void 0:b.value),c(false);},children:[jsxRuntime.jsx("span",{children:b.labelKey?s(b.labelKey):b.label}),y&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]})]}),i&&jsxRuntime.jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)",b.currentTarget.style.color="#fff";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)",b.currentTarget.style.color="#a1a1aa";},onClick:x,children:jsxRuntime.jsxs("svg",{className:m?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsxRuntime.jsx("path",{d:"M21 3v5h-5"}),jsxRuntime.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsxRuntime.jsx("path",{d:"M8 16H3v5"})]})})]})]})}function Pb(){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function wb({type:e}){let t={width:16,height:16},r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};return e==="trending-up"?jsxRuntime.jsxs("svg",{...r,style:t,children:[jsxRuntime.jsx("path",{d:"M16 7h6v6"}),jsxRuntime.jsx("path",{d:"m22 7-8.5 8.5-5-5L2 17"})]}):e==="chart-column"?jsxRuntime.jsxs("svg",{...r,style:t,children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}):jsxRuntime.jsx("svg",{...r,style:t,children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})})}function Nb(){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Mb({onMouseEnter:e,onMouseLeave:t}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:"hidden sm:block",style:{width:12,height:12,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",onMouseEnter:e,onMouseLeave:t,children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 16v-4"}),jsxRuntime.jsx("path",{d:"M12 8h.01"})]})}function Cc({open:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function Rb(e){return utils.formatAmountInUsd(e)}var Lb=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>utils.formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)",borderColor:"rgba(199,255,46,0.18)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)",borderColor:"rgba(247,104,22,0.18)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>utils.formatAmount(e),valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)",borderColor:"rgba(23,201,100,0.18)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:Rb,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Ai({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
81
+ .match-btn:focus-visible{outline:2px solid var(--color-focus);outline-offset:2px;z-index:10}
82
+ `}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:b,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:wc,onMouseEnter:v=>{v.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:v=>{v.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:()=>{p(v=>!v),c(false);},children:[jsxRuntime.jsx(Lx,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:a(S.labelKey)}),jsxRuntime.jsx(Cc,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Ec,width:224,padding:4},children:Is.map(v=>{let k=e===v.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:k?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"transparent",color:k?"var(--color-action-primary)":"var(--color-text-secondary)",borderRadius:10},onMouseEnter:P=>{k||(P.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)",P.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:P=>{k||(P.currentTarget.style.background="transparent",P.currentTarget.style.color="var(--color-text-secondary)");},onClick:()=>{e===v.value?o(!r):t(v.value),p(false);},children:[jsxRuntime.jsx("div",{style:{color:k?"var(--color-action-primary)":"var(--color-text-muted)"},children:jsxRuntime.jsx(Ox,{type:v.icon})}),jsxRuntime.jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500},children:a(v.labelKey)}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"var(--color-text-muted)",marginTop:1},children:a(v.descKey)})]}),k&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"var(--color-action-primary)",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},v.value)})})]}),i&&jsxRuntime.jsxs("div",{ref:h,style:{position:"relative"},children:[jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:wc,onMouseEnter:v=>{v.currentTarget.style.background="var(--color-surface-strong)";},onMouseLeave:v=>{v.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)";},onClick:()=>{c(v=>!v),p(false);},children:[jsxRuntime.jsx(_x,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"var(--color-text-primary)"},children:Rx(n,a)}),jsxRuntime.jsx(Ix,{onMouseEnter:()=>u(true),onMouseLeave:()=>u(false)}),jsxRuntime.jsx(Cc,{open:d})]}),m&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"var(--color-surface-interactive)",border:"1px solid var(--color-border-subtle)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"var(--color-surface-interactive)",borderLeft:"1px solid var(--color-border-subtle)",borderTop:"1px solid var(--color-border-subtle)"}}),jsxRuntime.jsxs("div",{style:{position:"relative",fontSize:12,color:"var(--color-text-primary)",lineHeight:1.625},children:[jsxRuntime.jsxs("div",{style:{fontWeight:600,color:"var(--color-text-primary)",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-action-primary)",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),a("predict.matches.filter.liquidityFilter")]}),jsxRuntime.jsx("p",{style:{color:"var(--color-text-secondary)",margin:"0 0 4px"},children:a("predict.matches.filter.tooltipDesc")}),jsxRuntime.jsx("p",{style:{color:"var(--color-text-muted)",fontSize:11,margin:0},children:a("predict.matches.filter.tooltipNote")})]})]})]}),d&&jsxRuntime.jsxs("div",{style:{...Ec,right:0,width:176},children:[jsxRuntime.jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--color-border-control)"},children:jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"var(--color-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:a("predict.matches.filter.minVolumeEach")})}),jsxRuntime.jsx("div",{style:{padding:4},children:Tc.map(v=>{let k=v.value===0?!n:n===v.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:k?"color-mix(in srgb, var(--color-action-primary) 8%, transparent)":"transparent",color:k?"var(--color-action-primary)":"var(--color-text-secondary)",borderRadius:10,transition:"all 0.15s"},onMouseEnter:P=>{k||(P.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)",P.currentTarget.style.color="var(--color-text-primary)");},onMouseLeave:P=>{k||(P.currentTarget.style.background="transparent",P.currentTarget.style.color="var(--color-text-secondary)");},onClick:()=>{i?.(v.value===0?void 0:v.value),c(false);},children:[jsxRuntime.jsx("span",{children:v.labelKey?a(v.labelKey):v.label}),k&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"var(--color-action-primary)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},v.value)})})]})]}),s&&jsxRuntime.jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.6)",width:36,height:36,color:"var(--color-text-secondary)",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:v=>{v.currentTarget.style.background="var(--color-surface-strong)",v.currentTarget.style.color="var(--color-text-primary)";},onMouseLeave:v=>{v.currentTarget.style.background="hsl(var(--heroui-content3) / 0.6)",v.currentTarget.style.color="var(--color-text-secondary)";},onClick:y,children:jsxRuntime.jsxs("svg",{className:f?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsxRuntime.jsx("path",{d:"M21 3v5h-5"}),jsxRuntime.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsxRuntime.jsx("path",{d:"M8 16H3v5"})]})})]})]})}function Lx(){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function Ox({type:e}){let t={width:16,height:16},r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};return e==="trending-up"?jsxRuntime.jsxs("svg",{...r,style:t,children:[jsxRuntime.jsx("path",{d:"M16 7h6v6"}),jsxRuntime.jsx("path",{d:"m22 7-8.5 8.5-5-5L2 17"})]}):e==="chart-column"?jsxRuntime.jsxs("svg",{...r,style:t,children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}):jsxRuntime.jsx("svg",{...r,style:t,children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})})}function _x(){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-secondary)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Ix({onMouseEnter:e,onMouseLeave:t}){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:"hidden sm:block",style:{width:12,height:12,color:"var(--color-text-disabled)",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",onMouseEnter:e,onMouseLeave:t,children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 16v-4"}),jsxRuntime.jsx("path",{d:"M12 8h.01"})]})}function Cc({open:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-muted)",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function Bx(e){return utils.formatAmountInUsd(e)}var Hx=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>utils.formatAmount(e),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)",borderColor:"rgba(199,255,46,0.18)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)",borderColor:"rgba(247,104,22,0.18)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>utils.formatAmount(e),valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)",borderColor:"rgba(23,201,100,0.18)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:Bx,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function As({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
83
83
  @keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
84
84
  @keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
85
85
  @keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
@@ -116,22 +116,22 @@
116
116
 
117
117
  .matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
118
118
  @media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
119
- `}),jsxRuntime.jsxs("div",{className:"matches-hero-outer",style:{display:"flex",marginBottom:0},children:[jsxRuntime.jsxs("div",{className:"matches-hero-left",style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,animation:"matchHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsxRuntime.jsx("div",{className:"matches-hero-live",style:{display:"flex",marginBottom:16},children:jsxRuntime.jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsxRuntime.jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"match-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsxRuntime.jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"match-live-breathe 2.4s ease-in-out infinite"}})]}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.matches.liveBadge")}),jsxRuntime.jsx("span",{style:{borderRadius:4,background:"rgba(199,255,46,0.12)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c7ff2e",textTransform:"uppercase",border:"1px solid rgba(199,255,46,0.22)"},children:t("predict.matches.betaTag")})]})}),jsxRuntime.jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:46,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxRuntime.jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsxRuntime.jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsxRuntime.jsx("p",{className:"matches-hero-subtitle matches-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
120
- `).map((r,n)=>jsxRuntime.jsxs("span",{children:[n>0&&jsxRuntime.jsx("br",{className:"hidden sm:block"}),r,n===0?" ":""]},n))})]}),jsxRuntime.jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:Lb.map((r,n)=>jsxRuntime.jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:n%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:n<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+n*60}ms`}:{}},children:[jsxRuntime.jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsxRuntime.jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${n*80}ms`}})}),jsxRuntime.jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsxRuntime.jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+n*80}ms`}})})]},r.key))})]})]})}var Ab={kalshi:{label:"KALSHI",color:"#00d492",bgColor:"rgba(0, 212, 146, 0.12)",icon:jsxRuntime.jsx(ui$1.KalshiIcon,{className:"w-3.5 h-3.5 shrink-0"})},polymarket:{label:"POLYMARKET",color:"#50a2ff",bgColor:"rgba(43, 127, 255, 0.12)",icon:jsxRuntime.jsx(ui$1.PolymarketIcon,{className:"w-3.5 h-3.5 shrink-0"})},dflow:{label:"DFLOW",color:"rgb(16, 185, 129)",bgColor:"rgba(16, 185, 129, 0.12)",icon:null}},Fb={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function _r(e){return Ab[e]??Fb}function Bb({source:e,className:t}){let r=_r(e);return jsxRuntime.jsxs("span",{className:ui$1.cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}function Fi(e){return e==null?"-":utils.formatAmountInUsd(e)}function Wb(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Dc={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},zb={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},_c={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function $b(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var Kb={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},Vb={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},jb={text:"#9ca3af",icon:"#9ca3af"};function Gb(e){return Vb[e]??jb}var Yb=`
119
+ `}),jsxRuntime.jsxs("div",{className:"matches-hero-outer",style:{display:"flex",marginBottom:0},children:[jsxRuntime.jsxs("div",{className:"matches-hero-left",style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,animation:"matchHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsxRuntime.jsx("div",{className:"matches-hero-live",style:{display:"flex",marginBottom:16},children:jsxRuntime.jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"hsl(var(--heroui-content3) / 0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxRuntime.jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsxRuntime.jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"match-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsxRuntime.jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"match-live-breathe 2.4s ease-in-out infinite"}})]}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)",letterSpacing:"0.025em"},children:t("predict.matches.liveBadge")}),jsxRuntime.jsx("span",{style:{borderRadius:4,background:"rgba(199,255,46,0.12)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c7ff2e",textTransform:"uppercase",border:"1px solid rgba(199,255,46,0.22)"},children:t("predict.matches.betaTag")})]})}),jsxRuntime.jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:46,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxRuntime.jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsxRuntime.jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsxRuntime.jsx("p",{className:"matches-hero-subtitle matches-hero-subtitle-text",style:{lineHeight:1.6,color:"var(--color-text-muted)",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
120
+ `).map((r,o)=>jsxRuntime.jsxs("span",{children:[o>0&&jsxRuntime.jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsxRuntime.jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid var(--color-border-subtle)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:Hx.map((r,o)=>jsxRuntime.jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"hsl(var(--heroui-foreground) / 0.02)",borderRight:o%2===0?"1px solid var(--color-border-subtle)":"none",borderBottom:o<2?"1px solid var(--color-border-subtle)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsxRuntime.jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]??0):jsxRuntime.jsx("div",{style:{height:16,width:56,borderRadius:4,background:"hsl(var(--heroui-foreground) / 0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsxRuntime.jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"var(--color-text-muted)":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsxRuntime.jsx("div",{style:{height:10,width:64,borderRadius:4,background:"hsl(var(--heroui-foreground) / 0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}var Oc={kalshi:{label:"KALSHI",color:"#00d492",bgColor:"rgba(0, 212, 146, 0.12)",icon:jsxRuntime.jsx(ui.KalshiIcon,{className:"w-3.5 h-3.5 shrink-0"})},polymarket:{label:"POLYMARKET",color:"#50a2ff",bgColor:"rgba(43, 127, 255, 0.12)",icon:jsxRuntime.jsx(ui.PolymarketIcon,{className:"w-3.5 h-3.5 shrink-0"})},dflow:{label:"DFLOW",color:"rgb(16, 185, 129)",bgColor:"rgba(16, 185, 129, 0.12)",icon:null}},Vx={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Or(e){return Oc[e]??Vx}function jx({source:e,className:t}){let{t:r}=i18n.useTranslation(),o=Or(e),n=Oc[e]?o.label:r("common.unknown");return jsxRuntime.jsxs("span",{className:ui.cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:o.bgColor,color:o.color},children:[o.icon,n]})}var qx="\u2605";function Fs(e){return e==null?"-":utils.formatAmountInUsd(e)}function Qx(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Ac={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"var(--color-text-muted)",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"var(--color-text-muted)",gaugeInactive:"rgba(113,113,122,0.12)"}},Xx={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},_c={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"var(--color-text-muted)",label:"predict.matches.signalStaleData"}};function Jx(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var Zx={fresh:"#17c964",aging:"#f5a524",stale:"var(--color-text-muted)"},eb={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},tb={text:"var(--color-text-secondary)",icon:"var(--color-text-secondary)"};function rb(e){return eb[e]??tb}var ob=`
121
121
  .match-card button:focus-visible,
122
122
  .match-card a:focus-visible,
123
123
  .match-card [role="button"]:focus-visible {
124
124
  outline: 2px solid hsl(var(--heroui-primary) / 0.4);
125
125
  outline-offset: 2px;
126
126
  }
127
- `;function qb({tier:e}){let t=Dc[e],r=e==="wide"?5:e==="moderate"?3:1;return jsxRuntime.jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(n,o)=>jsxRuntime.jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:o<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},o))})}function Qb(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function Bi({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:a,getMarketHref:i,LinkComponent:s}){let{t:l}=i18n.useTranslation(),u=Qb(e);if(!u)return null;let[p,c]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=Wb(f),m=Dc[d],v=p.best_price!=null&&c.best_price!=null?p.best_price<=c.best_price?p.source:c.source:null,k=p.event_title||c.event_title,g=e.signal_tag??"stale_data",S=_c[g]??_c.stale_data,h=r?.(e),x=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:Yb}),f!=null&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${m.bandFrom}, ${m.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:m.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxRuntime.jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:m.color},children:[f.toFixed(1),"%"]}),jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:l("predict.matches.gap")})]}),jsxRuntime.jsx(qb,{tier:d})]}),jsxRuntime.jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsxRuntime.jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:k}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsxRuntime.jsx(Oc,{leg:p,isCheaper:v===p.source,externalUrlFallback:i?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:s}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(Oc,{leg:c,isCheaper:v===c.source,externalUrlFallback:i?.(e,c.source),internalHref:o?.(e,c),onSelect:n?()=>n(e,c):void 0,LinkComponent:s})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),Fi(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Fi(e.combined_volume_24h)," ",l("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxRuntime.jsxs("span",{title:l("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"12 6 12 12 16 14"})]}),Xb(l,e.age_seconds)]})]}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsxRuntime.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:S.dot,flexShrink:0}}),l(S.label)]})]})]}),b={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:h||t?"pointer":void 0},y=N=>{let w=N.currentTarget,M=zb[d];w.style.borderColor=M.border,w.style.boxShadow=M.shadow,a?.(e);},P=N=>{let w=N.currentTarget;w.style.borderColor="rgba(39,39,42,0.6)",w.style.boxShadow="none";};return h&&s?jsxRuntime.jsx(s,{href:h,className:"group match-card",children:jsxRuntime.jsx("div",{style:b,onMouseEnter:y,onMouseLeave:P,onClick:()=>t?.(e),children:x})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:b,onMouseEnter:y,onMouseLeave:P,onClick:()=>t?.(e),onKeyDown:N=>{t&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),t(e));},children:x})}function Xb(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Oc({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:a}){let{t:i}=i18n.useTranslation(),s=_r(e.source),l=Gb(e.source),u=e.best_price,p=e.outcomes?.[0]?.label??null,c=e.external_url??r,f=$b(e.age_seconds),d=g=>{g.stopPropagation();},m=!!(n||o),v={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:m?"pointer":void 0,color:"inherit",textDecoration:"none"},k=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsxRuntime.jsx("span",{style:{width:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[s.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:s.label}),f&&jsxRuntime.jsx("span",{title:e.age_seconds!=null?i("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:Kb[f],flexShrink:0}})]}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[p&&jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),jsxRuntime.jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Fi(e.vol_24h_usd)," ",i("predict.matches.vol24h")]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsxRuntime.jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:9,color:"#71717a"},children:i("predict.matches.centsYes")})]}),c?jsxRuntime.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":i("predict.matches.viewOn",{platform:s.label}),title:i("predict.matches.viewOn",{platform:s.label}),onClick:g=>g.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:g=>{g.currentTarget.style.color="#d4d4d8",g.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:g=>{g.currentTarget.style.color="#71717a",g.currentTarget.style.background="transparent";},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})}):jsxRuntime.jsx("span",{style:{width:18,flexShrink:0}})]});return n&&a?jsxRuntime.jsx(a,{href:n,className:"match-card-leg-link",onClick:g=>{d(g),o?.();},children:jsxRuntime.jsx("div",{style:v,children:k})}):m?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:v,onClick:g=>{d(g),o?.();},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),d(g),o?.());},children:k}):jsxRuntime.jsx("div",{style:v,children:k})}var Ui=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:a,getMatchHref:i,onSelectLeg:s,getLegHref:l,onSelect:u,onHover:p,getMarketHref:c,LinkComponent:f,onStatsChange:d},m){let{t:v}=i18n.useTranslation(),{data:k,hasNextPage:g,fetchNextPage:S,isFetchingNextPage:h,isLoading:x,isPlaceholderData:b,refetch:y}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[P,N]=react.useState(0),[w,M]=react.useState(false);w&&!b?(M(false),N(ee=>ee+1)):b&&!w&&M(true),react.useImperativeHandle(m,()=>({refetch:()=>{y();}}),[y]);let L=react.useMemo(()=>k?.pages.flatMap(ee=>ee.items??[])??[],[k]),A=k?.pages[0]?.total,X=react.useMemo(()=>{let ee=0,Y=0,re=0;for(let oe of L){let ie=oe.spread??0;ie>ee&&(ee=ie),ie>=.03&&re++,oe.combined_volume!=null&&(Y+=oe.combined_volume);}return {activePairs:A??L.length,maxSpread:ee,highSpreadCount:re,totalVolume:Y}},[L,A]);react.useEffect(()=>{X.activePairs>0&&d?.(X);},[X,d]);let _=react.useRef(null),U=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let ee=_.current;if(!ee)return;let Y=new IntersectionObserver(re=>{re[0]?.isIntersecting&&g&&!h&&S();},{rootMargin:"200px"});return Y.observe(ee),()=>Y.disconnect()},[g,h,S]),react.useEffect(()=>{if(g)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[g]),x)return jsxRuntime.jsx(av,{});if(L.length===0)return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsxRuntime.jsx("p",{style:{fontSize:18},children:v("predict.matches.empty")})});let q=!g&&L.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
127
+ `;function nb({tier:e}){let t=Ac[e],r=e==="wide"?5:e==="moderate"?3:1;return jsxRuntime.jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsxRuntime.jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}function ib(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,o,n)=>({source:r,event_title:o,event_slug:n?.event_slug??"",market_id:n?.id??0,market_slug:n?.slug??"",question:n?.question??"",status:n?.status??"open",outcomes:n?.outcomes,best_price:n?.outcomes?.[0]?.best_ask??n?.outcomes?.[0]?.price??void 0,vol_24h_usd:n?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function Bs({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=i18n.useTranslation(),p=ib(e);if(!p)return null;let[d,c]=p,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,u=Qx(m),f=Ac[u],g=d.best_price!=null&&c.best_price!=null?d.best_price<=c.best_price?d.source:c.source:null,b=d.event_title||c.event_title,h=e.signal_tag??"stale_data",S=_c[h]??_c.stale_data,x=r?.(e),y=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ob}),m!=null&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${f.bandFrom}, ${f.bandTo})`,borderBottom:"1px solid var(--color-border-subtle)"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:f.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxRuntime.jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:f.color},children:[m.toFixed(1),"%"]}),jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:l("predict.matches.gap")})]}),jsxRuntime.jsx(nb,{tier:u})]}),jsxRuntime.jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsxRuntime.jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:b}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-subtle)",overflow:"hidden"},children:[jsxRuntime.jsx(Ic,{leg:d,isCheaper:g===d.source,externalUrlFallback:s?.(e,d.source),internalHref:n?.(e,d),onSelect:o?()=>o(e,d):void 0,LinkComponent:a}),jsxRuntime.jsx("div",{style:{height:1,background:"hsl(var(--heroui-content3) / 0.3)"}}),jsxRuntime.jsx(Ic,{leg:c,isCheaper:g===c.source,externalUrlFallback:s?.(e,c.source),internalHref:n?.(e,c),onSelect:o?()=>o(e,c):void 0,LinkComponent:a})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.15)",padding:"8px 14px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"var(--color-text-muted)"},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),Fs(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Fs(e.combined_volume_24h)," ",l("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxRuntime.jsxs("span",{title:l("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"12 6 12 12 16 14"})]}),sb(l,e.age_seconds)]})]}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"var(--color-text-disabled)"},children:[jsxRuntime.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:S.dot,flexShrink:0}}),l(S.label)]})]})]}),v={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",cursor:x||t?"pointer":void 0},k=M=>{let N=M.currentTarget,w=Xx[u];N.style.borderColor=w.border,N.style.boxShadow=w.shadow,i?.(e);},P=M=>{let N=M.currentTarget;N.style.borderColor="hsl(var(--heroui-content3) / 0.6)",N.style.boxShadow="none";};return x&&a?jsxRuntime.jsx(a,{href:x,className:"group match-card",children:jsxRuntime.jsx("div",{style:v,onMouseEnter:k,onMouseLeave:P,onClick:()=>t?.(e),children:y})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:v,onMouseEnter:k,onMouseLeave:P,onClick:()=>t?.(e),onKeyDown:M=>{t&&(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),t(e));},children:y})}function sb(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let o=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:o})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Ic({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=i18n.useTranslation(),a=Or(e.source),l=rb(e.source),p=e.best_price,d=e.outcomes?.[0]?.label??null,c=e.external_url??r,m=Jx(e.age_seconds),u=h=>{h.stopPropagation();},f=!!(o||n),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},b=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:qx}):jsxRuntime.jsx("span",{style:{width:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[a.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label}),m&&jsxRuntime.jsx("span",{title:e.age_seconds!=null?s("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:Zx[m],flexShrink:0}})]}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[d&&jsxRuntime.jsx("span",{style:{fontSize:10,color:"var(--color-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),jsxRuntime.jsxs("span",{style:{fontSize:9,color:"var(--color-text-disabled)"},children:[Fs(e.vol_24h_usd)," ",s("predict.matches.vol24h")]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsxRuntime.jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?"#c7ff2e":"var(--color-text-primary)"},children:p!=null?(p*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:9,color:"var(--color-text-muted)"},children:s("predict.matches.centsYes")})]}),c?jsxRuntime.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:h=>h.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"var(--color-text-muted)",flexShrink:0},onMouseEnter:h=>{h.currentTarget.style.color="var(--color-text-primary)",h.currentTarget.style.background="hsl(var(--heroui-foreground) / 0.05)";},onMouseLeave:h=>{h.currentTarget.style.color="var(--color-text-muted)",h.currentTarget.style.background="transparent";},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})}):jsxRuntime.jsx("span",{style:{width:18,flexShrink:0}})]});return o&&i?jsxRuntime.jsx(i,{href:o,className:"match-card-leg-link",onClick:h=>{u(h),n?.();},children:jsxRuntime.jsx("div",{style:g,children:b})}):f?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:g,onClick:h=>{u(h),n?.();},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h),n?.());},children:b}):jsxRuntime.jsx("div",{style:g,children:b})}var Us=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:p,onHover:d,getMarketHref:c,LinkComponent:m,onStatsChange:u},f){let{t:g}=i18n.useTranslation(),{data:b,hasNextPage:h,fetchNextPage:S,isFetchingNextPage:x,isLoading:y,isPlaceholderData:v,refetch:k}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[P,M]=react.useState(0),[N,w]=react.useState(false);N&&!v?(w(false),M(oe=>oe+1)):v&&!N&&w(true),react.useImperativeHandle(f,()=>({refetch:()=>{k();}}),[k]);let R=react.useMemo(()=>b?.pages.flatMap(oe=>oe.items??[])??[],[b]),A=b?.pages[0]?.total,X=react.useMemo(()=>{let oe=0,W=0,te=0;for(let ne of R){let se=ne.spread??0;se>oe&&(oe=se),se>=.03&&te++,ne.combined_volume!=null&&(W+=ne.combined_volume);}return {activePairs:A??R.length,maxSpread:oe,highSpreadCount:te,totalVolume:W}},[R,A]);react.useEffect(()=>{X.activePairs>0&&u?.(X);},[X,u]);let L=react.useRef(null),G=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let oe=L.current;if(!oe)return;let W=new IntersectionObserver(te=>{te[0]?.isIntersecting&&h&&!x&&S();},{rootMargin:"200px"});return W.observe(oe),()=>W.disconnect()},[h,x,S]),react.useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),y)return jsxRuntime.jsx(fb,{});if(R.length===0)return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsxRuntime.jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let U=!h&&R.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
128
128
  @media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
129
129
  @keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
130
- `}),jsxRuntime.jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:k?.pages.map(ee=>ee.items?.map((Y,re)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${re*35}ms both`},children:jsxRuntime.jsx(Bi,{match:Y,onSelectMatch:a,getMatchHref:i,onSelectLeg:s,getLegHref:l,onHover:p,onSelect:u,getMarketHref:c,LinkComponent:f})},`${P}-${Y.match_id}-${Y.source_a}-${Y.market_a?.slug??re}`)))}),jsxRuntime.jsxs("div",{ref:_,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsxRuntime.jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),h&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),v("predict.matches.loadMore")]})]}),q&&jsxRuntime.jsx(ov,{onScrollToTop:U})]})});function ov({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsxRuntime.jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#71717a"},children:t("predict.matches.endOfList")}),jsxRuntime.jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"#a1a1aa",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M12 19V5"}),jsxRuntime.jsx("path",{d:"m5 12 7-7 7 7"})]}),jsxRuntime.jsx("span",{children:t("predict.matches.backToTop")})]})]})}function av(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsxRuntime.jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(iv,{index:t},t))})]})}function iv({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxRuntime.jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsxRuntime.jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsxRuntime.jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(n=>jsxRuntime.jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:72}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:48}}),jsxRuntime.jsx("div",{style:{...r,height:20,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},n))}),jsxRuntime.jsx("div",{style:{padding:"12px 16px"},children:jsxRuntime.jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",gap:12},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:40}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:50}})]}),jsxRuntime.jsx("div",{style:{...r,height:10,width:56}})]})]})}var pv={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function mv(){let[e,t]=react.useState("");return react.useEffect(()=>{let r=()=>{let o=new Date;return `${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`};t(r());let n=setInterval(()=>t(r()),1e4);return ()=>clearInterval(n)},[]),jsxRuntime.jsx("span",{children:e})}function fv({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxRuntime.jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M12 20h.01"}),jsxRuntime.jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsxRuntime.jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsxRuntime.jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsxRuntime.jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsxRuntime.jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxRuntime.jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsxRuntime.jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsxRuntime.jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:utils.formatAmount(e.activePairs)})]}),jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),jsxRuntime.jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsxRuntime.jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsxRuntime.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsxRuntime.jsx("path",{d:"M10 9H8"}),jsxRuntime.jsx("path",{d:"M16 13H8"}),jsxRuntime.jsx("path",{d:"M16 17H8"})]}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxRuntime.jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsxRuntime.jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsxRuntime.jsx("path",{d:"M12 17h.01"})]}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsxRuntime.jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsxRuntime.jsx(mv,{})]})]})]})]})}function gv({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:a,getMarketHref:i,LinkComponent:s,bgImageSrc:l}){let{t:u}=i18n.useTranslation(),[p,c]=react.useState("spread"),[f,d]=react.useState(false),[m,v]=react.useState(void 0),[k,g]=react.useState(),S=react.useRef(null),h=react.useCallback(P=>{c(P);},[]),x=react.useCallback(P=>{d(P);},[]),b=react.useCallback(P=>{react.startTransition(()=>{g(P);});},[]),y=react.useCallback(()=>{S.current?.refetch();},[]);return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsxRuntime.jsx("style",{children:`
130
+ `}),jsxRuntime.jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:b?.pages.map(oe=>oe.items?.map((W,te)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${te*35}ms both`},children:jsxRuntime.jsx(Bs,{match:W,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:d,onSelect:p,getMarketHref:c,LinkComponent:m})},`${P}-${W.match_id}-${W.source_a}-${W.market_a?.slug??te}`)))}),jsxRuntime.jsxs("div",{ref:L,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsxRuntime.jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),x&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--color-text-muted)",fontSize:13},children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),g("predict.matches.loadMore")]})]}),U&&jsxRuntime.jsx(mb,{onScrollToTop:G})]})});function mb({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"24px 0"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,width:"100%"},children:[jsxRuntime.jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-muted)"},children:t("predict.matches.endOfList")}),jsxRuntime.jsx("div",{style:{height:1,width:64,background:"rgba(82,82,91,0.5)"}})]}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,color:"var(--color-text-secondary)",background:"none",border:"none",cursor:"pointer",padding:0},onClick:e,children:[jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M12 19V5"}),jsxRuntime.jsx("path",{d:"m5 12 7-7 7 7"})]}),jsxRuntime.jsx("span",{children:t("predict.matches.backToTop")})]})]})}function fb(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsxRuntime.jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(gb,{index:t},t))})]})}function gb({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxRuntime.jsxs("div",{style:{borderRadius:16,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsxRuntime.jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsxRuntime.jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxRuntime.jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"hsl(var(--heroui-foreground) / 0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:72}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:48}}),jsxRuntime.jsx("div",{style:{...r,height:20,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsxRuntime.jsx("div",{style:{padding:"12px 16px"},children:jsxRuntime.jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid var(--color-border-subtle)",padding:"10px 16px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",gap:12},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:40}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:50}})]}),jsxRuntime.jsx("div",{style:{...r,height:10,width:56}})]})]})}var kb={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Sb(){let[e,t]=react.useState("");return react.useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsxRuntime.jsx("span",{children:e})}function Pb({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxRuntime.jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid var(--color-border-subtle)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M12 20h.01"}),jsxRuntime.jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsxRuntime.jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsxRuntime.jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsxRuntime.jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsxRuntime.jsx("div",{style:{width:1,height:14,background:"hsl(var(--heroui-content3) / 0.8)"}}),e&&jsxRuntime.jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--color-text-muted)"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsxRuntime.jsx("span",{style:{color:"var(--color-text-disabled)"},children:t("predict.matches.status.markets")}),jsxRuntime.jsx("span",{style:{color:"var(--color-text-primary)",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:utils.formatAmount(e.activePairs)})]}),jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--color-text-muted)"},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),jsxRuntime.jsx("span",{style:{color:"var(--color-text-disabled)"},children:t("predict.matches.status.vol24h")}),jsxRuntime.jsx("span",{style:{color:"var(--color-text-primary)",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"var(--color-text-muted)",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsxRuntime.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsxRuntime.jsx("path",{d:"M10 9H8"}),jsxRuntime.jsx("path",{d:"M16 13H8"}),jsxRuntime.jsx("path",{d:"M16 17H8"})]}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxRuntime.jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"var(--color-text-muted)",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsxRuntime.jsx("div",{style:{width:1,height:14,background:"hsl(var(--heroui-content3) / 0.8)",margin:"0 4px"}}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsxRuntime.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"var(--color-text-muted)",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="var(--color-text-primary)",r.currentTarget.style.background="hsl(var(--heroui-content3) / 0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="var(--color-text-muted)",r.currentTarget.style.background="transparent";},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsxRuntime.jsx("path",{d:"M12 17h.01"})]}),jsxRuntime.jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsxRuntime.jsx("div",{style:{width:1,height:14,background:"hsl(var(--heroui-content3) / 0.8)",margin:"0 4px"}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--color-text-muted)"},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsxRuntime.jsx(Sb,{})]})]})]})]})}function Nb({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:p}=i18n.useTranslation(),[d,c]=react.useState("spread"),[m,u]=react.useState(false),[f,g]=react.useState(void 0),[b,h]=react.useState(),S=react.useRef(null),x=react.useCallback(P=>{c(P);},[]),y=react.useCallback(P=>{u(P);},[]),v=react.useCallback(P=>{react.startTransition(()=>{h(P);});},[]),k=react.useCallback(()=>{S.current?.refetch();},[]);return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsxRuntime.jsx("style",{children:`
131
131
  @keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
132
132
  .match-fade-in{animation:matchFadeIn .5s ease-out both}
133
133
  .match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
134
134
  .match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
135
- `}),jsxRuntime.jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsxRuntime.jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsxRuntime.jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsxRuntime.jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsxRuntime.jsx(Ai,{stats:k})})]}),jsxRuntime.jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxRuntime.jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxRuntime.jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsxRuntime.jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsxRuntime.jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsxRuntime.jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxRuntime.jsxs("div",{style:{minWidth:0},children:[jsxRuntime.jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u(pv[p])}),k&&k.activePairs>0&&jsxRuntime.jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:k.activePairs})})]})]}),jsxRuntime.jsx(Di,{sortBy:p,onSortChange:h,sortAsc:f,onSortAscChange:x,minVolume:m,onMinVolumeChange:v,onRefresh:y})]})]}),jsxRuntime.jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxRuntime.jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxRuntime.jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsxRuntime.jsx("span",{style:{color:"#71717a",fontWeight:500},children:u("predict.matches.experimentalFeature")})," \u2014 ",u("predict.matches.disclaimer")]})]}),jsxRuntime.jsx(Ui,{ref:S,sortBy:p,sortAsc:f,minVolume:m,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:a,getMarketHref:i,LinkComponent:s,onStatsChange:b})]}),jsxRuntime.jsx(fv,{stats:k})]})}function Wi(e){return e==null?"-":utils.formatAmountInUsd(e)}var vv={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},xv={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function yv(e){return vv[e]??xv}function kv(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let n of e.matched_markets){let o=n.spread??0;o>r&&(r=o,t=n);}return t}function Sv(e,t){let r=e.entries.find(s=>s.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(s=>s.source===(t?.source_b??e.entries[1]?.source)),o=s=>{if(!s?.outcomes?.[0])return {name:null,price:null};let l=s.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},a=o(t?.market_a),i=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:n?.event?.volume??null,event:n?.event}]}function Pv({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let{t:o}=i18n.useTranslation(),a=react.useMemo(()=>kv(e),[e]),i=e.max_spread!=null?e.max_spread*100:null,[s,l]=react.useMemo(()=>Sv(e,a),[e,a]),u=i!=null&&i>=3,p=s.yesPrice!=null&&l.yesPrice!=null?s.yesPrice<=l.yesPrice?s:l:null,c=p?_r(p.source):null,f=u?"amber":"violet";return jsxRuntime.jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:d=>{let m=d.currentTarget;m.style.borderColor="rgba(63,63,70,0.6)",m.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:d=>{let m=d.currentTarget;m.style.borderColor="rgba(39,39,42,0.6)",m.style.boxShadow="none";},children:[i!=null&&jsxRuntime.jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${u?"rgba(255,185,0,0.3)":i>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":i>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":i>=2?"#a684ff":"#9ca3af"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),i.toFixed(1),"%"]}),jsxRuntime.jsxs("div",{style:{padding:16},children:[jsxRuntime.jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxRuntime.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsxRuntime.jsx(zc,{data:s,isCheaper:p===s,onSelect:t,getEventHref:r,LinkComponent:n}),jsxRuntime.jsx(zc,{data:l,isCheaper:p===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),p&&c&&i!=null&&jsxRuntime.jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${f==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:f==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>p.event&&t?.(p.event),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:f==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:f==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:p.source.charAt(0).toUpperCase()+p.source.slice(1),spread:i.toFixed(1)})}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:f==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M5 12h14"}),jsxRuntime.jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),Wi(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Wi(e.combined_volume_24h)," ",o("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",o("predict.matches.match")]})]})]})}function zc({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:a}=i18n.useTranslation(),i=_r(e.source),s=yv(e.source),l=e.event?n?.(e.event):void 0,u=jsxRuntime.jsxs("div",{style:{borderRadius:14,border:`1px solid ${s.border}`,background:s.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=s.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[i.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:s.text,textTransform:"uppercase"},children:i.label}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsxRuntime.jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsxRuntime.jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?s.priceActiveColor:s.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a"},children:a("predict.matches.centsYes")})]}),jsxRuntime.jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[Wi(e.volume)," ",a("predict.matches.volume")]})]});return l&&o?jsxRuntime.jsx(o,{href:l,className:"block",children:u}):u}function Ev(e){return utils.formatAmountInUsd(e)}function Cv({matches:e,total:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>{let o=0,a=0,i=new Set;for(let s of e){s.max_spread!=null&&s.max_spread>o&&(o=s.max_spread),s.combined_volume!=null&&(a+=s.combined_volume);for(let l of s.entries)i.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:a,platformCount:i.size}},[e,t]);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsxRuntime.jsx(Jo,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsxRuntime.jsx(zi,{}),jsxRuntime.jsx(Jo,{label:r("predict.matches.stats.totalVolume"),value:Ev(n.totalVolume)}),jsxRuntime.jsx(zi,{}),jsxRuntime.jsx(Jo,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsxRuntime.jsx(zi,{}),jsxRuntime.jsx(Jo,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function Jo({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsxRuntime.jsx("span",{className:`font-semibold ${r}`,children:t})]})}function zi(){return jsxRuntime.jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Vc(e){return `${(e*100).toFixed(1)}\xA2`}function Tv(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function Rv({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=t!=null&&t>0;return jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center gap-x-2",r),children:[jsxRuntime.jsx("span",{className:ui$1.cn("text-sm font-semibold",Tv(e)),children:Vc(e)}),n&&jsxRuntime.jsxs("span",{className:"text-xs text-green-500/80",children:["+",Vc(t)]})]})}var qn=10,Av=64,qc=40,Zo=48;function Qc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),[o,a]=react.useState(1),{data:i,isLoading:s,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:p}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:f,fetchNextPage:d,hasNextPage:m,isFetchingNextPage:v}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),k=s||f,g=p||v,S=u||m,h=react.useMemo(()=>{let A=[];return i?.pages&&A.push(...i.pages.flatMap(X=>X.items)),c?.pages&&A.push(...c.pages.flatMap(X=>X.items)),A.sort((X,_)=>(_.timestamp??0)-(X.timestamp??0)),A},[i,c]),x=Math.max(1,Math.ceil(h.length/qn)+(S?1:0)),b=(o-1)*qn,y=h.slice(b,b+qn),P=react.useCallback(()=>{a(A=>Math.max(1,A-1));},[]),N=react.useCallback(async()=>{o*qn>=h.length&&S&&(u&&await l(),m&&await d()),a(X=>X+1);},[o,h.length,S,u,m,l,d]),w=o>1,M=o*qn<h.length||S;if(k)return jsxRuntime.jsx(zv,{height:r});if(h.length===0&&!S)return jsxRuntime.jsx(Wv,{message:n("predict.profile.noHistory"),height:r});let L=r-qc-Zo;return jsxRuntime.jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:qc},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.status")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.price")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.profile.depositWithdraw")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fee")}),jsxRuntime.jsx("div",{className:"w-10 shrink-0"})]}),jsxRuntime.jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:L},children:[y.map((A,X)=>jsxRuntime.jsx(Fv,{trade:A},A.id??`${b+X}`)),g&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})})]}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Zo},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!w,onClick:P,className:ui$1.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",w?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(x,5)},(A,X)=>{let _=X+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(_),className:ui$1.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",_===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:_},_)}),jsxRuntime.jsxs("button",{type:"button",disabled:!M,onClick:N,className:ui$1.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",M?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Zo},children:y.map((A,X)=>jsxRuntime.jsx(Bv,{trade:A},A.id??`m-${b+X}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Zo},children:[jsxRuntime.jsx("button",{type:"button",disabled:!w,onClick:P,className:ui$1.cn("text-sm cursor-pointer",w?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsxRuntime.jsx("span",{className:"text-sm text-foreground tabular-nums",children:o}),jsxRuntime.jsx("button",{type:"button",disabled:!M,onClick:N,className:ui$1.cn("text-sm cursor-pointer",M?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Fv({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,a=e.usd_size??0,i=Xc(e.type,g=>String(t(g))),s=r||n,l=s?"+":"-",u=s?"text-success":"text-foreground",p=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.outcome??"",d=td(e.timestamp),m=Jc(e),v=Hv(e),k=Uv(e);return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Av},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[c&&jsxRuntime.jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium text-sm",children:p}),jsxRuntime.jsxs("span",{className:"text-[11px] text-neutral",children:[f&&jsxRuntime.jsx("span",{className:"mr-1",children:f}),jsxRuntime.jsx("span",{children:d})]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:jsxRuntime.jsx("span",{className:ui$1.cn("text-sm font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:i}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:ed(o)}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-[1.5] pr-2 text-right font-mono",u),children:a>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l,"$",a.toFixed(2)]}):"\u2014"}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-1 pr-2 text-right font-mono",v!==null?v>=0?"text-success":"text-danger":"text-neutral"),children:v!==null?`${v>=0?"+":"-"}$${Math.abs(v).toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:k!==null?`$${k.toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"w-10 shrink-0 text-right",children:m&&jsxRuntime.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsxRuntime.jsx(Zc,{})})})]})}function Bv({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,a=e.usd_size??0,i=Xc(e.type,p=>String(t(p))),s=e.event?.title??e.market?.question??"\u2014",l=td(e.timestamp),u=Jc(e);return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsxRuntime.jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:s})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsxRuntime.jsx("span",{className:ui$1.cn("font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsxRuntime.jsx("span",{className:"text-foreground",children:i})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsxRuntime.jsx("span",{className:"font-mono text-foreground",children:ed(o)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsxRuntime.jsx("span",{className:"font-mono text-foreground",children:a>0?`$${a.toFixed(2)}`:"\u2014"})]}),u&&jsxRuntime.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsxRuntime.jsx(Zc,{})})]})]})}function Xc(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function Jc(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Hv(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function Uv(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function Zc(){return jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsxRuntime.jsx("polyline",{points:"15 3 21 3 21 9"}),jsxRuntime.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function Wv({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function zv({height:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-12 w-full rounded-md"},r))})}function ed(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function td(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),a=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${a}/${i} (${l}${u})`}var Qn=10,qv=64,nd=40,ea=48;function ad({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),o=reactPredict.useCancelOrder(),[a,i]=react.useState(1),{data:s,isLoading:l,fetchNextPage:u,hasNextPage:p,isFetchingNextPage:c}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:d,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:k}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),g=l||d,S=c||k,h=p||v,x=react.useMemo(()=>{let _=[],U=new Set(["live","open","submitted","pending"]);return s?.pages&&_.push(...s.pages.flatMap(q=>q.items).filter(q=>U.has(q.status))),f?.pages&&_.push(...f.pages.flatMap(q=>q.items).filter(q=>U.has(q.status))),_},[s,f]),b=react.useCallback(_=>{o.mutate({source:_.source,id:_.id});},[o]),y=Math.max(1,Math.ceil(x.length/Qn)+(h?1:0)),P=(a-1)*Qn,N=x.slice(P,P+Qn),w=react.useCallback(()=>{i(_=>Math.max(1,_-1));},[]),M=react.useCallback(async()=>{a*Qn>=x.length&&h&&(p&&await u(),v&&await m()),i(U=>U+1);},[a,x.length,h,p,v,u,m]),L=a>1,A=a*Qn<x.length||h;if(g)return jsxRuntime.jsx(Zv,{height:r});if(x.length===0&&!h)return jsxRuntime.jsx(Jv,{message:n("predict.profile.noOrders"),height:r});let X=r-nd-ea;return jsxRuntime.jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:nd},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:n("predict.profile.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.action")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.profile.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.fillPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.profile.cost")})]}),jsxRuntime.jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:X},children:[N.map(_=>jsxRuntime.jsx(Qv,{order:_,onCancel:b},_.id)),S&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})})]}),jsxRuntime.jsx(od,{className:"hidden lg:flex",currentPage:a,totalPages:y,canGoPrev:L,canGoNext:A,onPrev:w,onNext:M,onPage:i,paginationLabel:_=>String(n(_))}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ea},children:N.map(_=>jsxRuntime.jsx(Xv,{order:_,onCancel:b},_.id))}),jsxRuntime.jsx(od,{className:"lg:hidden",currentPage:a,totalPages:y,canGoPrev:L,canGoNext:A,onPrev:w,onNext:M,onPage:i,paginationLabel:_=>String(n(_)),compact:true})]})}function Qv({order:e}){let{t}=i18n.useTranslation(),r=e.side==="BUY",n=e.price?parseFloat(e.price):0,o=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:qv},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:jsxRuntime.jsx("span",{className:ui$1.cn("text-sm font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?id(n):"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o>0?`$${o.toFixed(2)}`:"\u2014"})]})}function Xv({order:e,onCancel:t}){let{t:r}=i18n.useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0;return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:ui$1.cn("text-xs font-medium px-1.5 py-0.5 rounded",n?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsxRuntime.jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsxRuntime.jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsxRuntime.jsx("span",{className:"font-mono text-foreground",children:o>0?id(o):"\u2014"})]}),jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function od({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:a,onNext:i,onPage:s,paginationLabel:l,compact:u}){return u?jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:ea},children:[jsxRuntime.jsx("button",{type:"button",disabled:!n,onClick:a,className:ui$1.cn("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsxRuntime.jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsxRuntime.jsx("button",{type:"button",disabled:!o,onClick:i,className:ui$1.cn("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:ea},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!n,onClick:a,className:ui$1.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,c)=>{let f=c+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>s(f),className:ui$1.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",f===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:f},f)}),jsxRuntime.jsxs("button",{type:"button",disabled:!o,onClick:i,className:ui$1.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function Jv({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Zv({height:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-12 w-full rounded-md"},r))})}function id(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Gi=10,nx=64,sd=40,ta=48;function ld({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:a}=i18n.useTranslation(),[i,s]=react.useState(1),l=react.useCallback(()=>{for(let v of e)n?.(v);},[e,n]);if(t)return jsxRuntime.jsx(sx,{height:r});if(e.length===0)return jsxRuntime.jsx(ix,{message:a("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/Gi)),p=(i-1)*Gi,c=e.slice(p,p+Gi),f=i>1,d=i<u,m=r-sd-ta;return jsxRuntime.jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:sd},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:a("predict.profile.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.markPrice")}),jsxRuntime.jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsxRuntime.jsx("span",{children:a("predict.profile.pnl")}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",a("predict.profile.pnlExcludeFees"),")"]})]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:a("predict.profile.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:a("predict.profile.estSettlement")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 text-right",children:n&&e.length>0&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:a("predict.profile.closeAll")})})]}),jsxRuntime.jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:m},children:c.map((v,k)=>jsxRuntime.jsx(ox,{position:v,onClosePosition:n,onEventClick:o},`${v.source}-${v.market?.slug??p+k}`))}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ta},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!f,onClick:()=>s(v=>Math.max(1,v-1)),className:ui$1.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",a("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(v,k)=>{let g=k+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>s(g),className:ui$1.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",g===i?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:g},g)}),jsxRuntime.jsxs("button",{type:"button",disabled:!d,onClick:()=>s(v=>v+1),className:ui$1.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[a("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ta},children:c.map((v,k)=>jsxRuntime.jsx(ax,{position:v,onClose:n,onEventClick:o},`${v.source}-${v.market?.slug??`m-${p+k}`}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ta},children:[jsxRuntime.jsx("button",{type:"button",disabled:!f,onClick:()=>s(v=>Math.max(1,v-1)),className:ui$1.cn("text-sm cursor-pointer",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsxRuntime.jsx("span",{className:"text-sm text-foreground tabular-nums",children:i}),jsxRuntime.jsx("button",{type:"button",disabled:!d,onClick:()=>s(v=>v+1),className:ui$1.cn("text-sm cursor-pointer",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function ox({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,a=e.pnl_percent??0,i=e.avg_price??0,s=e.current_price??0,l=e.current_value??e.size*s,u=e.size,p=o>0?"text-success":o<0?"text-danger":"text-foreground",c=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,m=e.side,v=e.market?.outcomes?.[0]?.label??"",k=e.market?.end_at?lx(e.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:nx},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[d&&jsxRuntime.jsx("img",{src:d,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium text-sm",children:f}),jsxRuntime.jsxs("span",{className:"text-[11px] text-neutral",children:[jsxRuntime.jsx("span",{className:ui$1.cn("font-medium",m.toLowerCase()==="yes"?"text-success":"text-danger"),children:m}),v&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1",children:"\xB7"}),jsxRuntime.jsx("span",{children:v})]})]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count:e.size})})]})}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*i).toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Yi(i)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Yi(s)}),jsxRuntime.jsxs("div",{className:ui$1.cn("flex-[1.5] pr-2 text-right font-mono",p),children:[jsxRuntime.jsxs("span",{children:[c,"$",Math.abs(o).toFixed(2)]}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",c,a.toFixed(2),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",u.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:k}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{className:"text-danger",children:"\u2715"}),n("predict.profile.close")]})})]})}function ax({position:e,onClose:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,a=e.pnl_percent??0,i=e.current_price??0,s=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsxRuntime.jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsxRuntime.jsx("span",{className:ui$1.cn("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsx(ra,{label:n("predict.profile.totalSize"),value:Pr(e.size)}),jsxRuntime.jsx(ra,{label:n("predict.profile.markPrice"),value:Yi(i)}),jsxRuntime.jsx(ra,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${a.toFixed(1)}%)`,className:s}),jsxRuntime.jsx(ra,{label:n("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:n("predict.profile.close")})})]})}function ra({label:e,value:t,className:r}){return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:e}),jsxRuntime.jsx("span",{className:ui$1.cn("font-mono text-foreground",r),children:t})]})}function ix({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function sx({height:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Yi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function lx(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),a=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${a}/${i} (${l}${u})`}catch{return "\u2014"}}function dd({positions:e,trades:t,isLoading:r,positionsValue:n,positionsValueLoading:o}){let{t:a}=i18n.useTranslation(),i=react.useMemo(()=>{let u=0,p=0;for(let v of e)u+=v.realized_pnl??0,p+=v.current_value??v.size*(v.current_price??0);let c=0,f=0,d=0;for(let v of t)c+=v.usd_size??0,v.type==="REDEEM"&&(d++,(v.usd_size??0)>0&&f++);let m=d>0?`${f} / ${d}`:"0 / 0";return {realizedPnl:u,positionsValue:n??p,volume:c,winRateStr:m}},[e,n,t]),s=i.realizedPnl>0?"text-success":i.realizedPnl<0?"text-danger":"text-foreground",l=i.realizedPnl>0?"+":"";return jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("span",{className:"text-xl text-neutral",children:a("predict.profile.realizedPnl")}),r?jsxRuntime.jsx(ui$1.Skeleton,{className:"h-14 w-48 rounded-md"}):jsxRuntime.jsxs("span",{className:ui$1.cn("text-5xl font-bold tabular-nums",s),children:[l,"$",Math.abs(i.realizedPnl).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsxRuntime.jsx(Qi,{label:a("predict.profile.winRate"),value:i.winRateStr,isLoading:r}),jsxRuntime.jsx(Qi,{label:a("predict.profile.positions"),value:`$${i.positionsValue.toFixed(2)}`,isLoading:o??r}),jsxRuntime.jsx(Qi,{label:a("predict.profile.volume"),value:`$${i.volume.toFixed(2)}`,isLoading:r})]})]})}function Qi({label:e,value:t,isLoading:r}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral whitespace-nowrap",children:e}),r?jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-14 rounded-md"}):jsxRuntime.jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var Ji=600;function fd({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=i18n.useTranslation(),[a,i]=react.useState("positions"),s=!!(e||t),{data:l,isLoading:u}=reactPredict.usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:c}=reactPredict.usePositions({source:"polymarket",user:t??""}),f=react.useMemo(()=>{let M=[];return l?.positions&&M.push(...l.positions),p?.positions&&M.push(...p.positions),M},[l,p]),d=u||c,{data:m,isLoading:v}=reactPredict.usePositionValueMulti({kalshi_user:e||void 0,polymarket_user:t||void 0}),k=react.useMemo(()=>{if(!m)return;let M=Number(m.value);return Number.isFinite(M)?M:void 0},[m]),{data:g,isLoading:S}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:x}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),b=react.useMemo(()=>[...g?.pages?.flatMap(L=>L.items)??[],...h?.pages?.flatMap(L=>L.items)??[]],[g,h]),y=d||S||x,P=f.length,w=[{key:"positions",label:P>0?`${o("predict.profile.positionsTab")} (${P})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return s?jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsxRuntime.jsx(dd,{positions:f,trades:b,isLoading:y,positionsValue:k,positionsValueLoading:v}),jsxRuntime.jsx("div",{className:"flex items-center gap-1 border-b border-border",children:w.map(M=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(M.key),className:ui$1.cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",a===M.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:M.label},M.key))}),jsxRuntime.jsxs("div",{className:"py-2",children:[a==="positions"&&jsxRuntime.jsx(ld,{positions:f,isLoading:d,listHeight:Ji,onClosePosition:r,onEventClick:n}),a==="orders"&&jsxRuntime.jsx(ad,{solanaAddress:e,evmAddress:t,listHeight:Ji}),a==="history"&&jsxRuntime.jsx(Qc,{solanaAddress:e,evmAddress:t,listHeight:Ji})]})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function kx({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:a}=i18n.useTranslation(),[i,s]=react.useState(false),[l,u]=react.useState(null),[p,c]=react.useState(false),f=r||p,d=n||p,m=f?"done":i?"running":"pending",v=d?"done":f&&i?"running":"pending",k=f&&d,g=react.useCallback(async()=>{u(null),c(false),s(true);try{await o(),c(!0);}catch(b){u(b instanceof Error?b.message:String(b));}finally{s(false);}},[o]),S=[{key:"step1",label:a("predict.setup.step1"),desc:a("predict.setup.step1Desc"),status:m},{key:"step2",label:a("predict.setup.step2"),desc:a("predict.setup.step2Desc"),status:v}],h=()=>{k?t():g();},x=a(k?"predict.setup.done":"predict.setup.setupButton");return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:e,onOpenChange:b=>{b||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui$1.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:a("predict.setup.modalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:a("predict.setup.modalDescription")}),jsxRuntime.jsx("div",{className:"space-y-2.5",children:S.map((b,y)=>jsxRuntime.jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsxRuntime.jsx(Sx,{index:y+1,status:b.status}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-zinc-200",children:b.label}),jsxRuntime.jsx("span",{className:`text-[11px] leading-none ${b.status==="done"?"text-[#c7ff2e]":b.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:b.status==="done"?a("predict.setup.stepComplete"):b.status==="running"?a("predict.setup.stepRunning"):a("predict.setup.stepPending")})]}),jsxRuntime.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:b.desc})]})]},b.key))}),l&&jsxRuntime.jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsxRuntime.jsx("p",{className:"text-xs text-red-400",children:l})}),jsxRuntime.jsx("button",{type:"button",onClick:h,disabled:i,className:k?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsxRuntime.jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),a("predict.setup.stepRunning")]}):x}),!k&&jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a("common.cancel")})]})]})})})}function Sx({index:e,status:t}){return t==="done"?jsxRuntime.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsxRuntime.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsxRuntime.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsxRuntime.jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsxRuntime.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
136
- Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"eventStatsQueryKey",{enumerable:true,get:function(){return reactPredict.eventStatsQueryKey}});Object.defineProperty(exports,"fetchMatchMarketsPage",{enumerable:true,get:function(){return reactPredict.fetchMatchMarketsPage}});Object.defineProperty(exports,"fetchMatchesPage",{enumerable:true,get:function(){return reactPredict.fetchMatchesPage}});Object.defineProperty(exports,"fetchPredictSearch",{enumerable:true,get:function(){return reactPredict.fetchPredictSearch}});Object.defineProperty(exports,"matchMarketsQueryKey",{enumerable:true,get:function(){return reactPredict.matchMarketsQueryKey}});Object.defineProperty(exports,"matchQueryKey",{enumerable:true,get:function(){return reactPredict.matchQueryKey}});Object.defineProperty(exports,"matchesQueryKey",{enumerable:true,get:function(){return reactPredict.matchesQueryKey}});Object.defineProperty(exports,"predictSearchQueryKey",{enumerable:true,get:function(){return reactPredict.predictSearchQueryKey}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowKYC",{enumerable:true,get:function(){return reactPredict.useDFlowKYC}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEventStats",{enumerable:true,get:function(){return reactPredict.useEventStats}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useInfiniteMatchMarkets",{enumerable:true,get:function(){return reactPredict.useInfiniteMatchMarkets}});Object.defineProperty(exports,"useInfiniteMatches",{enumerable:true,get:function(){return reactPredict.useInfiniteMatches}});Object.defineProperty(exports,"useInfiniteOrders",{enumerable:true,get:function(){return reactPredict.useInfiniteOrders}});Object.defineProperty(exports,"useInfinitePredictSearch",{enumerable:true,get:function(){return reactPredict.useInfinitePredictSearch}});Object.defineProperty(exports,"useInfiniteTrades",{enumerable:true,get:function(){return reactPredict.useInfiniteTrades}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useMatch",{enumerable:true,get:function(){return reactPredict.useMatch}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositionValue",{enumerable:true,get:function(){return reactPredict.usePositionValue}});Object.defineProperty(exports,"usePositionValueMulti",{enumerable:true,get:function(){return reactPredict.usePositionValueMulti}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePredictSearch",{enumerable:true,get:function(){return reactPredict.usePredictSearch}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useRedeemPosition",{enumerable:true,get:function(){return reactPredict.useRedeemPosition}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=ba;exports.CHART_RANGE_FIDELITY_MINUTES=Ld;exports.CHART_RANGE_PERIOD=Td;exports.CHART_RANGE_SAMPLE_INTERVAL=Rd;exports.CandlestickPeriod=Vr;exports.CategoriesSkeleton=Pd;exports.CategoriesUI=pa;exports.CategoriesWidget=fa;exports.ChartRange=W;exports.CommentItemUI=jo;exports.DEFAULT_CHART_RANGE=vn;exports.DEFAULT_FILTER_STATE=Xr;exports.DEFAULT_PAGE_SIZE=jr;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Dd;exports.EventCommentsWidget=sc;exports.EventDetailPage=Eh;exports.EventDetailSkeleton=rn;exports.EventDetailUI=Wn;exports.EventDetailWidget=Th;exports.EventItem=Ua;exports.EventMarketDepthChartUI=ui;exports.EventMarketDetailWidget=fi;exports.EventPriceChart=bi;exports.EventsFilterUI=_a;exports.EventsHero=dm;exports.EventsPage=im;exports.EventsPageSkeleton=yp;exports.EventsSkeleton=xo;exports.EventsToolbarUI=Ia;exports.EventsUI=za;exports.EventsWidget=$a;exports.KycModal=Nn;exports.MAX_PRICE_HISTORY_MARKETS=uo;exports.MatchGroupCard=Pv;exports.MatchMarketCard=Bi;exports.MatchesFilterBar=Di;exports.MatchesHero=Ai;exports.MatchesPage=gv;exports.MatchesStatsBar=Cv;exports.MatchesWidget=Ui;exports.ORDER_MAX_PRICE=Id;exports.ORDER_MIN_PRICE=Od;exports.ORDER_MIN_QUANTITY=xn;exports.ORDER_MIN_USDC=yn;exports.ORDER_PRICE_STEP=_d;exports.POLYMARKET_BUILDER_TAKER_FEE_BPS=ps;exports.POLYMARKET_SPORTS_TAKER_FEE_BPS=ms;exports.PREDICT_REDEEM_MODAL_ID=rl;exports.PREDICT_SEARCH_HISTORY_KEY=cc;exports.PREDICT_SEARCH_MODAL_ID=qo;exports.PREDICT_SELL_MODAL_ID=No;exports.PREDICT_TRADE_MODAL_ID=qr;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Ad;exports.PredictRedeemModal=Ga;exports.PredictSearchModal=cb;exports.PredictSellModal=ti;exports.PredictTradeModal=En;exports.PredictWalletProvider=ds;exports.PriceHistoryInterval=Sr;exports.ProfilePage=fd;exports.RedeemFormWidget=ja;exports.SORT_PRESETS=Oa;exports.STATIC_CATEGORIES=oo;exports.SearchEventsButton=hb;exports.SearchHistoryUI=Pi;exports.SearchHistoryWidget=wi;exports.SearchInputUI=Ni;exports.SearchResultItemUI=Ei;exports.SearchResultListWidget=Ri;exports.SearchWidget=_i;exports.SellFormUI=ei;exports.SellFormWidget=_n;exports.SetupModal=kx;exports.SimilarEventCard=Ql;exports.SimilarEventsSection=xi;exports.SourceBadge=Bb;exports.SpreadIndicator=Rv;exports.TradeFormSkeleton=ci;exports.TradeFormUI=La;exports.TradeFormWidget=Mn;exports.UserActivitySection=ii;exports.computeMaxBuyAmount=Sa;exports.countActiveFilters=bo;exports.createPredictSearchHistoryStorage=dn;exports.createTradeResultToast=wr;exports.estimatePolymarketBuyFee=Pa;exports.estimatePolymarketSellFee=wa;exports.fireCelebration=Na;exports.floorToDecimals=xe;exports.formatKMB=nn;exports.formatShares=Pr;exports.getSourceMeta=_r;exports.orderIntentView=i0;exports.parsePolymarketError=Pn;exports.polymarketFeeFactor=us;exports.resolveExpiration=kn;exports.resolvePolymarketDisplayFeeRateBps=ka;exports.roundToTickSize=Sn;exports.useEventDetail=Dh;exports.useEventsInfinite=Da;exports.usePredictSearchHistory=Si;exports.usePredictWallet=cr;exports.useSearchResultListScript=Ci;exports.useSearchScript=xb;exports.useSellForm=Xa;exports.useTradeForm=Ca;//# sourceMappingURL=index.js.map
135
+ `}),jsxRuntime.jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid var(--color-border-subtle)"},children:[jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[l&&jsxRuntime.jsx("img",{src:l,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsxRuntime.jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsxRuntime.jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsxRuntime.jsx(As,{stats:b})})]}),jsxRuntime.jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid var(--color-border-subtle)"},children:[jsxRuntime.jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxRuntime.jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsxRuntime.jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsxRuntime.jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsxRuntime.jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxRuntime.jsxs("div",{style:{minWidth:0},children:[jsxRuntime.jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p(kb[d])}),b&&b.activePairs>0&&jsxRuntime.jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"var(--color-text-muted)",margin:0},children:p("predict.matches.pairsFound",{count:b.activePairs})})]})]}),jsxRuntime.jsx(Ds,{sortBy:d,onSortChange:x,sortAsc:m,onSortAscChange:y,minVolume:f,onMinVolumeChange:g,onRefresh:k})]})]}),jsxRuntime.jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxRuntime.jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-subtle)",background:"rgba(24,24,27,0.25)"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"var(--color-text-disabled)",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxRuntime.jsxs("p",{style:{fontSize:11,color:"var(--color-text-disabled)",lineHeight:1.5,margin:0},children:[jsxRuntime.jsx("span",{style:{color:"var(--color-text-muted)",fontWeight:500},children:p("predict.matches.experimentalFeature")})," \u2014 ",p("predict.matches.disclaimer")]})]}),jsxRuntime.jsx(Us,{ref:S,sortBy:d,sortAsc:m,minVolume:f,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:v})]}),jsxRuntime.jsx(Pb,{stats:b})]})}function Ws(e){return e==null?"-":utils.formatAmountInUsd(e)}var Eb={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},Cb={text:"var(--color-text-secondary)",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function Tb(e){return Eb[e]??Cb}function Rb(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let o of e.matched_markets){let n=o.spread??0;n>r&&(r=n,t=o);}return t}function Lb(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),n=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let l=a.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=n(t?.market_a),s=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:o?.event?.volume??null,event:o?.event}]}function Ob({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let{t:n}=i18n.useTranslation(),i=react.useMemo(()=>Rb(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=react.useMemo(()=>Lb(e,i),[e,i]),p=s!=null&&s>=3,d=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,c=d?Or(d.source):null,m=p?"amber":"violet";return jsxRuntime.jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content2) / 0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:u=>{let f=u.currentTarget;f.style.borderColor="hsl(var(--heroui-content4) / 0.6)",f.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:u=>{let f=u.currentTarget;f.style.borderColor="hsl(var(--heroui-content3) / 0.6)",f.style.boxShadow="none";},children:[s!=null&&jsxRuntime.jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${p?"rgba(255,185,0,0.3)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:p?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:p?"#ffb900":s>=2?"#a684ff":"var(--color-text-secondary)"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s.toFixed(1),"%"]}),jsxRuntime.jsxs("div",{style:{padding:16},children:[jsxRuntime.jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"var(--color-text-primary)",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxRuntime.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsxRuntime.jsx($c,{data:a,isCheaper:d===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsxRuntime.jsx($c,{data:l,isCheaper:d===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),d&&c&&s!=null&&jsxRuntime.jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${m==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:m==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>d.event&&t?.(d.event),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:m==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:m==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:d.source.charAt(0).toUpperCase()+d.source.slice(1),spread:s.toFixed(1)})}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:m==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M5 12h14"}),jsxRuntime.jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid var(--color-border-subtle)",background:"hsl(var(--heroui-content3) / 0.2)",padding:"10px 16px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"var(--color-text-muted)"},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),Ws(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Ws(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"var(--color-text-disabled)"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",n("predict.matches.match")]})]})]})}function $c({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=i18n.useTranslation(),s=Or(e.source),a=Tb(e.source),l=e.event?o?.(e.event):void 0,p=jsxRuntime.jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:d=>{d.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:d=>{d.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[s.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:a.text,textTransform:"uppercase"},children:s.label}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"var(--color-text-disabled)",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsxRuntime.jsx("div",{style:{fontSize:10,color:"var(--color-text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsxRuntime.jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:10,color:"var(--color-text-muted)"},children:i("predict.matches.centsYes")})]}),jsxRuntime.jsxs("div",{style:{fontSize:10,color:"var(--color-text-disabled)",marginTop:6},children:[Ws(e.volume)," ",i("predict.matches.volume")]})]});return l&&n?jsxRuntime.jsx(n,{href:l,className:"block",children:p}):p}function Ab(e){return utils.formatAmountInUsd(e)}function Fb({matches:e,total:t}){let{t:r}=i18n.useTranslation(),o=react.useMemo(()=>{let n=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>n&&(n=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let l of a.entries)s.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:i,platformCount:s.size}},[e,t]);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsxRuntime.jsx(Zn,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsxRuntime.jsx(zs,{}),jsxRuntime.jsx(Zn,{label:r("predict.matches.stats.totalVolume"),value:Ab(o.totalVolume)}),jsxRuntime.jsx(zs,{}),jsxRuntime.jsx(Zn,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-success"}),jsxRuntime.jsx(zs,{}),jsxRuntime.jsx(Zn,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function Zn({label:e,value:t,valueClassName:r="text-text-primary"}){return jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsxs("span",{className:"text-text-muted",children:[e,":"]}),jsxRuntime.jsx("span",{className:`font-semibold ${r}`,children:t})]})}function zs(){return jsxRuntime.jsx("span",{className:"hidden text-text-disabled sm:inline",children:"|"})}function jc(e){return `${(e*100).toFixed(1)}\xA2`}function Bb(e){return e>=.05?"text-success":e>=.02?"text-warning":"text-text-secondary"}function Hb({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-x-2",r),children:[jsxRuntime.jsx("span",{className:ui.cn("text-sm font-semibold",Bb(e)),children:jc(e)}),o&&jsxRuntime.jsxs("span",{className:"text-xs text-success/80",children:["+",jc(t)]})]})}var Xo=10,Vb=64,Qc=40,ei=48;function Xc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=i18n.useTranslation(),[n,i]=react.useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:p,isFetchingNextPage:d}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:m,fetchNextPage:u,hasNextPage:f,isFetchingNextPage:g}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),b=a||m,h=d||g,S=p||f,x=react.useMemo(()=>{let A=[];return s?.pages&&A.push(...s.pages.flatMap(X=>X.items)),c?.pages&&A.push(...c.pages.flatMap(X=>X.items)),A.sort((X,L)=>(L.timestamp??0)-(X.timestamp??0)),A},[s,c]),y=Math.max(1,Math.ceil(x.length/Xo)+(S?1:0)),v=(n-1)*Xo,k=x.slice(v,v+Xo),P=react.useCallback(()=>{i(A=>Math.max(1,A-1));},[]),M=react.useCallback(async()=>{n*Xo>=x.length&&S&&(p&&await l(),f&&await u()),i(X=>X+1);},[n,x.length,S,p,f,l,u]),N=n>1,w=n*Xo<x.length||S;if(b)return jsxRuntime.jsx(Xb,{height:r});if(x.length===0&&!S)return jsxRuntime.jsx(Qb,{message:o("predict.profile.noHistory"),height:r});let R=r-Qc-ei;return jsxRuntime.jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:Qc},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.status")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.price")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:o("predict.profile.depositWithdraw")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fee")}),jsxRuntime.jsx("div",{className:"w-10 shrink-0"})]}),jsxRuntime.jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:R},children:[k.map((A,X)=>jsxRuntime.jsx(jb,{trade:A},A.id??`${v+X}`)),h&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ei},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!N,onClick:P,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",N?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(y,5)},(A,X)=>{let L=X+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>i(L),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",L===n?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:L},L)}),jsxRuntime.jsxs("button",{type:"button",disabled:!w,onClick:M,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",w?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:[o("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ei},children:k.map((A,X)=>jsxRuntime.jsx(Gb,{trade:A},A.id??`m-${v+X}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ei},children:[jsxRuntime.jsx("button",{type:"button",disabled:!N,onClick:P,className:ui.cn("text-sm cursor-pointer",N?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2190"}),jsxRuntime.jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsxRuntime.jsx("button",{type:"button",disabled:!w,onClick:M,className:ui.cn("text-sm cursor-pointer",w?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]})]})}function jb({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Jc(e.type,h=>String(t(h))),a=r||o,l=a?"+":"-",p=a?"text-success":"text-foreground",d=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,m=e.outcome??"",u=rd(e.timestamp),f=Zc(e),g=Yb(e),b=qb(e);return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Vb},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[c&&jsxRuntime.jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium text-sm",children:d}),jsxRuntime.jsxs("span",{className:"text-[11px] text-text-muted",children:[m&&jsxRuntime.jsx("span",{className:"mr-1",children:m}),jsxRuntime.jsx("span",{children:u})]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("text-sm font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:td(n)}),jsxRuntime.jsx("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",p),children:i>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l,"$",i.toFixed(2)]}):"\u2014"}),jsxRuntime.jsx("div",{className:ui.cn("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-text-muted"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-text-muted",children:b!==null?`$${b.toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"w-10 shrink-0 text-right",children:f&&jsxRuntime.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-text-muted hover:text-foreground transition-colors","aria-label":t("common.viewTransaction"),children:jsxRuntime.jsx(ed,{})})})]})}function Gb({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",o=e.side?.toUpperCase()==="BUY",n=e.price??0,i=e.usd_size??0,s=Jc(e.type,d=>String(t(d))),a=e.event?.title??e.market?.question??"\u2014",l=rd(e.timestamp),p=Zc(e);return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsxRuntime.jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-text-muted whitespace-nowrap",children:l})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:t("predict.profile.action")}),jsxRuntime.jsx("span",{className:ui.cn("font-medium",r?"text-primary":o?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":o?"predict.profile.buy":"predict.profile.sell")})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:t("predict.profile.status")}),jsxRuntime.jsx("span",{className:"text-foreground",children:s})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:t("predict.profile.price")}),jsxRuntime.jsx("span",{className:"font-mono text-foreground",children:td(n)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:t("predict.profile.depositWithdraw")}),jsxRuntime.jsx("span",{className:"font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]}),p&&jsxRuntime.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-text-muted hover:text-foreground transition-colors",children:jsxRuntime.jsx(ed,{})})]})]})}function Jc(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function Zc(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Yb(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function qb(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function ed(){return jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsxRuntime.jsx("polyline",{points:"15 3 21 3 21 9"}),jsxRuntime.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function Qb({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function Xb({height:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-12 w-full rounded-md"},r))})}function td(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function rd(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",p=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${p})`}var Jo=10,n0=64,nd=40,ti=48;function sd({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=i18n.useTranslation(),n=reactPredict.useCancelOrder(),[i,s]=react.useState(1),{data:a,isLoading:l,fetchNextPage:p,hasNextPage:d,isFetchingNextPage:c}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:u,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:b}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||u,S=c||b,x=d||g,y=react.useMemo(()=>{let L=[],G=new Set(["live","open","submitted","pending"]);return a?.pages&&L.push(...a.pages.flatMap(U=>U.items).filter(U=>G.has(U.status))),m?.pages&&L.push(...m.pages.flatMap(U=>U.items).filter(U=>G.has(U.status))),L},[a,m]),v=react.useCallback(L=>{n.mutate({source:L.source,id:L.id});},[n]),k=Math.max(1,Math.ceil(y.length/Jo)+(x?1:0)),P=(i-1)*Jo,M=y.slice(P,P+Jo),N=react.useCallback(()=>{s(L=>Math.max(1,L-1));},[]),w=react.useCallback(async()=>{i*Jo>=y.length&&x&&(d&&await p(),g&&await f()),s(G=>G+1);},[i,y.length,x,d,g,p,f]),R=i>1,A=i*Jo<y.length||x;if(h)return jsxRuntime.jsx(l0,{height:r});if(y.length===0&&!x)return jsxRuntime.jsx(a0,{message:o("predict.profile.noOrders"),height:r});let X=r-nd-ti;return jsxRuntime.jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:nd},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fillPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.cost")})]}),jsxRuntime.jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:X},children:[M.map(L=>jsxRuntime.jsx(i0,{order:L,onCancel:v},L.id)),S&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsx(id,{className:"hidden lg:flex",currentPage:i,totalPages:k,canGoPrev:R,canGoNext:A,onPrev:N,onNext:w,onPage:s,paginationLabel:L=>String(o(L))}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ti},children:M.map(L=>jsxRuntime.jsx(s0,{order:L,onCancel:v},L.id))}),jsxRuntime.jsx(id,{className:"lg:hidden",currentPage:i,totalPages:k,canGoPrev:R,canGoNext:A,onPrev:N,onNext:w,onPage:s,paginationLabel:L=>String(o(L)),compact:true})]})}function i0({order:e}){let{t}=i18n.useTranslation(),r=e.side==="BUY",o=e.price?parseFloat(e.price):0,n=e.in_amount?parseFloat(e.in_amount):o*parseFloat(e.original_size??"0");return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:n0},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("text-sm font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-text-muted capitalize text-sm",children:e.order_type?.toLowerCase()==="market"?t("predict.trade.market"):t("predict.trade.limit")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o>0?ad(o):"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?`$${n.toFixed(2)}`:"\u2014"})]})}function s0({order:e,onCancel:t}){let{t:r}=i18n.useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:ui.cn("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsxRuntime.jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsxRuntime.jsx("span",{className:"text-xs text-text-muted capitalize",children:e.order_type?.toLowerCase()==="market"?r("predict.trade.market"):r("predict.trade.limit")})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:r("predict.profile.fillPrice")}),jsxRuntime.jsx("span",{className:"font-mono text-foreground",children:n>0?ad(n):"\u2014"})]}),jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function id({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,paginationLabel:l,compact:p}){return p?jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:ti},children:[jsxRuntime.jsx("button",{type:"button",disabled:!o,onClick:i,className:ui.cn("text-sm cursor-pointer",o?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2190"}),jsxRuntime.jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsxRuntime.jsx("button",{type:"button",disabled:!n,onClick:s,className:ui.cn("text-sm cursor-pointer",n?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]}):jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:ti},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!o,onClick:i,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(d,c)=>{let m=c+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(m),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:m},m)}),jsxRuntime.jsxs("button",{type:"button",disabled:!n,onClick:s,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function a0({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function l0({height:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-12 w-full rounded-md"},r))})}function ad(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Gs=10,p0=64,ld=40,ri=48,m0="\u2715";function cd({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(1),l=react.useCallback(()=>{for(let g of e)o?.(g);},[e,o]);if(t)return jsxRuntime.jsx(v0,{height:r});if(e.length===0)return jsxRuntime.jsx(h0,{message:i("predict.profile.noPositions"),height:r});let p=Math.max(1,Math.ceil(e.length/Gs)),d=(s-1)*Gs,c=e.slice(d,d+Gs),m=s>1,u=s<p,f=r-ld-ri;return jsxRuntime.jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center text-text-muted text-xs font-normal shrink-0 border-b border-border/50",style:{height:ld},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:i("predict.profile.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.markPrice")}),jsxRuntime.jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsxRuntime.jsx("span",{children:i("predict.profile.pnl")}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",i("predict.profile.pnlExcludeFees"),")"]})]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:i("predict.profile.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:i("predict.profile.estSettlement")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 text-right",children:o&&e.length>0&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsxRuntime.jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:c.map((g,b)=>jsxRuntime.jsx(f0,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??d+b}`))}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ri},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(p,5)},(g,b)=>{let h=b+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(h),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",h===s?"bg-foreground/10 text-foreground font-medium":"text-text-muted hover:text-foreground"),children:h},h)}),jsxRuntime.jsxs("button",{type:"button",disabled:!u,onClick:()=>a(g=>g+1),className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",u?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ri},children:c.map((g,b)=>jsxRuntime.jsx(g0,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${d+b}`}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ri},children:[jsxRuntime.jsx("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:ui.cn("text-sm cursor-pointer",m?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2190"}),jsxRuntime.jsx("span",{className:"text-sm text-foreground tabular-nums",children:s}),jsxRuntime.jsx("button",{type:"button",disabled:!u,onClick:()=>a(g=>g+1),className:ui.cn("text-sm cursor-pointer",u?"text-text-muted hover:text-foreground":"text-text-muted/40 cursor-not-allowed"),children:"\u2192"})]})]})}function f0({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=i18n.useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,l=e.current_value??e.size*a,p=e.size,d=n>0?"text-success":n<0?"text-danger":"text-foreground",c=n>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",u=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",b=e.market?.end_at?x0(e.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:p0},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[u&&jsxRuntime.jsx("img",{src:u,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxRuntime.jsxs("span",{className:"text-[11px] text-text-muted",children:[jsxRuntime.jsx("span",{className:ui.cn("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1",children:"\xB7"}),jsxRuntime.jsx("span",{children:g})]})]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("span",{className:"text-[10px] text-text-muted",children:o("predict.profile.contracts",{count:e.size})})]})}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*s).toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ys(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Ys(a)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",d),children:[jsxRuntime.jsxs("span",{children:[c,"$",Math.abs(n).toFixed(2)]}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",c,i.toFixed(2),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",p.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-text-muted whitespace-nowrap text-xs",children:b}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{className:"text-danger",children:m0}),o("predict.profile.close")]})})]})}function g0({position:e,onClose:t,onEventClick:r}){let{t:o}=i18n.useTranslation(),n=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=n>0?"text-success":n<0?"text-danger":"text-foreground",l=n>0?"+":"",p=e.event?.title??e.market?.question??"\u2014";return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsxRuntime.jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:p})]}),jsxRuntime.jsx("span",{className:ui.cn("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsx(oi,{label:o("predict.profile.totalSize"),value:Nr(e.size)}),jsxRuntime.jsx(oi,{label:o("predict.profile.markPrice"),value:Ys(s)}),jsxRuntime.jsx(oi,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsxRuntime.jsx(oi,{label:o("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:o("predict.profile.close")})})]})}function oi({label:e,value:t,className:r}){return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-text-muted",children:e}),jsxRuntime.jsx("span",{className:ui.cn("font-mono text-foreground",r),children:t})]})}function h0({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted",style:{height:t},children:e})}function v0({height:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Ys(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function x0(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",p=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${p})`}catch{return "\u2014"}}function ud({positions:e,trades:t,isLoading:r,positionsValue:o,positionsValueLoading:n}){let{t:i}=i18n.useTranslation(),s=react.useMemo(()=>{let p=0,d=0;for(let g of e)p+=g.realized_pnl??0,d+=g.current_value??g.size*(g.current_price??0);let c=0,m=0,u=0;for(let g of t)c+=g.usd_size??0,g.type==="REDEEM"&&(u++,(g.usd_size??0)>0&&m++);let f=u>0?`${m} / ${u}`:"0 / 0";return {realizedPnl:p,positionsValue:o??d,volume:c,winRateStr:f}},[e,o,t]),a=s.realizedPnl>0?"text-success":s.realizedPnl<0?"text-danger":"text-foreground",l=s.realizedPnl>0?"+":"";return jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx("span",{className:"text-xl text-text-muted",children:i("predict.profile.realizedPnl")}),r?jsxRuntime.jsx(ui.Skeleton,{className:"h-14 w-48 rounded-md"}):jsxRuntime.jsxs("span",{className:ui.cn("text-5xl font-bold tabular-nums",a),children:[l,"$",Math.abs(s.realizedPnl).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsxRuntime.jsx(Qs,{label:i("predict.profile.winRate"),value:s.winRateStr,isLoading:r}),jsxRuntime.jsx(Qs,{label:i("predict.profile.positions"),value:`$${s.positionsValue.toFixed(2)}`,isLoading:n??r}),jsxRuntime.jsx(Qs,{label:i("predict.profile.volume"),value:`$${s.volume.toFixed(2)}`,isLoading:r})]})]})}function Qs({label:e,value:t,isLoading:r}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-text-muted whitespace-nowrap",children:e}),r?jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-14 rounded-md"}):jsxRuntime.jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var Js=600;function gd({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=i18n.useTranslation(),[i,s]=react.useState("positions"),a=!!(e||t),{data:l,isLoading:p}=reactPredict.usePositions({source:"kalshi",user:e??""}),{data:d,isLoading:c}=reactPredict.usePositions({source:"polymarket",user:t??""}),m=react.useMemo(()=>{let w=[];return l?.positions&&w.push(...l.positions),d?.positions&&w.push(...d.positions),w},[l,d]),u=p||c,{data:f,isLoading:g}=reactPredict.usePositionValueMulti({kalshi_user:e||void 0,polymarket_user:t||void 0}),b=react.useMemo(()=>{if(!f)return;let w=Number(f.value);return Number.isFinite(w)?w:void 0},[f]),{data:h,isLoading:S}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:x,isLoading:y}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),v=react.useMemo(()=>[...h?.pages?.flatMap(R=>R.items)??[],...x?.pages?.flatMap(R=>R.items)??[]],[h,x]),k=u||S||y,P=m.length,N=[{key:"positions",label:P>0?`${n("predict.profile.positionsTab")} (${P})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return a?jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsxRuntime.jsx(ud,{positions:m,trades:v,isLoading:k,positionsValue:b,positionsValueLoading:g}),jsxRuntime.jsx("div",{className:"flex items-center gap-1 border-b border-border",children:N.map(w=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(w.key),className:ui.cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===w.key?"text-foreground border-b-2 border-foreground":"text-text-muted hover:text-foreground"),children:w.label},w.key))}),jsxRuntime.jsxs("div",{className:"py-2",children:[i==="positions"&&jsxRuntime.jsx(cd,{positions:m,isLoading:u,listHeight:Js,onClosePosition:r,onEventClick:o}),i==="orders"&&jsxRuntime.jsx(sd,{solanaAddress:e,evmAddress:t,listHeight:Js}),i==="history"&&jsxRuntime.jsx(Xc,{solanaAddress:e,evmAddress:t,listHeight:Js})]})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted py-24 px-4",children:n("predict.profile.connectWallet")})}function O0({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(false),[l,p]=react.useState(null),[d,c]=react.useState(false),m=r||d,u=o||d,f=m?"done":s?"running":"pending",g=u?"done":m&&s?"running":"pending",b=m&&u,h=react.useCallback(async()=>{p(null),c(false),a(true);try{await n(),c(!0);}catch(v){p(v instanceof Error?v.message:String(v));}finally{a(false);}},[n]),S=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:f},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],x=()=>{b?t():h();},y=i(b?"predict.setup.done":"predict.setup.setupButton");return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:v=>{v||t();},size:"md",classNames:{base:ui.THEMED_MODAL_BASE_CLASS,body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-text-primary",children:i("predict.setup.modalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-surface-strong/50 text-text-secondary hover:text-text-primary transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-text-secondary text-left",children:i("predict.setup.modalDescription")}),jsxRuntime.jsx("div",{className:"space-y-2.5",children:S.map((v,k)=>jsxRuntime.jsxs("div",{className:"flex gap-3 rounded-[10px] border border-border-control/50 bg-surface-interactive/50 px-3 py-3",children:[jsxRuntime.jsx(_0,{index:k+1,status:v.status}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-text-primary",children:v.label}),jsxRuntime.jsx("span",{className:`text-[11px] leading-none ${v.status==="done"?"text-brand-primary":v.status==="running"?"text-brand-primary/70":"text-text-muted"}`,children:v.status==="done"?i("predict.setup.stepComplete"):v.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsxRuntime.jsx("p",{className:"text-xs text-text-muted mt-1",children:v.desc})]})]},v.key))}),l&&jsxRuntime.jsx("div",{className:"rounded-[10px] bg-danger/10 border border-danger/20 px-3 py-2",children:jsxRuntime.jsx("p",{className:"text-xs text-danger",children:l})}),jsxRuntime.jsx("button",{type:"button",onClick:x,disabled:s,className:b?"w-full py-3 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-action-primary text-text-inverse text-sm font-semibold hover:bg-action-primary-hover transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsxRuntime.jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),i("predict.setup.stepRunning")]}):y}),!b&&jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-text-secondary hover:text-text-primary hover:bg-surface-strong/50 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")})]})]})})})}function _0({index:e,status:t}){return t==="done"?jsxRuntime.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-action-primary/15 shrink-0",children:jsxRuntime.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-brand-primary",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsxRuntime.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-action-primary/10 shrink-0",children:jsxRuntime.jsxs("svg",{className:"animate-spin h-4 w-4 text-brand-primary",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsxRuntime.jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsxRuntime.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-surface-strong/50 text-xs font-bold text-text-secondary shrink-0",children:e})}
136
+ Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"eventStatsQueryKey",{enumerable:true,get:function(){return reactPredict.eventStatsQueryKey}});Object.defineProperty(exports,"fetchMatchMarketsPage",{enumerable:true,get:function(){return reactPredict.fetchMatchMarketsPage}});Object.defineProperty(exports,"fetchMatchesPage",{enumerable:true,get:function(){return reactPredict.fetchMatchesPage}});Object.defineProperty(exports,"fetchPredictSearch",{enumerable:true,get:function(){return reactPredict.fetchPredictSearch}});Object.defineProperty(exports,"matchMarketsQueryKey",{enumerable:true,get:function(){return reactPredict.matchMarketsQueryKey}});Object.defineProperty(exports,"matchQueryKey",{enumerable:true,get:function(){return reactPredict.matchQueryKey}});Object.defineProperty(exports,"matchesQueryKey",{enumerable:true,get:function(){return reactPredict.matchesQueryKey}});Object.defineProperty(exports,"predictSearchQueryKey",{enumerable:true,get:function(){return reactPredict.predictSearchQueryKey}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowKYC",{enumerable:true,get:function(){return reactPredict.useDFlowKYC}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEventStats",{enumerable:true,get:function(){return reactPredict.useEventStats}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useInfiniteMatchMarkets",{enumerable:true,get:function(){return reactPredict.useInfiniteMatchMarkets}});Object.defineProperty(exports,"useInfiniteMatches",{enumerable:true,get:function(){return reactPredict.useInfiniteMatches}});Object.defineProperty(exports,"useInfiniteOrders",{enumerable:true,get:function(){return reactPredict.useInfiniteOrders}});Object.defineProperty(exports,"useInfinitePredictSearch",{enumerable:true,get:function(){return reactPredict.useInfinitePredictSearch}});Object.defineProperty(exports,"useInfiniteTrades",{enumerable:true,get:function(){return reactPredict.useInfiniteTrades}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useMatch",{enumerable:true,get:function(){return reactPredict.useMatch}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositionValue",{enumerable:true,get:function(){return reactPredict.usePositionValue}});Object.defineProperty(exports,"usePositionValueMulti",{enumerable:true,get:function(){return reactPredict.usePositionValueMulti}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePredictSearch",{enumerable:true,get:function(){return reactPredict.usePredictSearch}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useRedeemPosition",{enumerable:true,get:function(){return reactPredict.useRedeemPosition}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=xi;exports.CHART_RANGE_FIDELITY_MINUTES=Od;exports.CHART_RANGE_PERIOD=Rd;exports.CHART_RANGE_SAMPLE_INTERVAL=Ld;exports.CandlestickPeriod=Vr;exports.CategoriesSkeleton=Nd;exports.CategoriesUI=mi;exports.CategoriesWidget=gi;exports.ChartRange=$;exports.CommentItemUI=Gn;exports.DEFAULT_CHART_RANGE=bo;exports.DEFAULT_FILTER_STATE=Xr;exports.DEFAULT_PAGE_SIZE=jr;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Ad;exports.EventCommentsWidget=ac;exports.EventDetailPage=Ih;exports.EventDetailSkeleton=ro;exports.EventDetailUI=$o;exports.EventDetailWidget=Fh;exports.EventItem=Ui;exports.EventMarketDepthChartUI=us;exports.EventMarketDetailWidget=fs;exports.EventPriceChart=vs;exports.EventsFilterUI=Oi;exports.EventsHero=mm;exports.EventsPage=cm;exports.EventsPageSkeleton=Pp;exports.EventsSkeleton=kn;exports.EventsToolbarUI=Ii;exports.EventsUI=zi;exports.EventsWidget=$i;exports.KycModal=wo;exports.MAX_PRICE_HISTORY_MARKETS=mn;exports.MatchGroupCard=Ob;exports.MatchMarketCard=Bs;exports.MatchesFilterBar=Ds;exports.MatchesHero=As;exports.MatchesPage=Nb;exports.MatchesStatsBar=Fb;exports.MatchesWidget=Us;exports.ORDER_MAX_PRICE=Dd;exports.ORDER_MIN_PRICE=Id;exports.ORDER_MIN_QUANTITY=yo;exports.ORDER_MIN_USDC=ko;exports.ORDER_PRICE_STEP=_d;exports.POLYMARKET_BUILDER_TAKER_FEE_BPS=pa;exports.POLYMARKET_SPORTS_TAKER_FEE_BPS=ma;exports.PREDICT_REDEEM_MODAL_ID=tl;exports.PREDICT_SEARCH_HISTORY_KEY=cc;exports.PREDICT_SEARCH_MODAL_ID=Qn;exports.PREDICT_SELL_MODAL_ID=En;exports.PREDICT_TRADE_MODAL_ID=qr;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Fd;exports.PredictRedeemModal=Gi;exports.PredictSearchModal=vx;exports.PredictSellModal=ts;exports.PredictTradeModal=Co;exports.PredictWalletProvider=da;exports.PriceHistoryInterval=Pr;exports.ProfilePage=gd;exports.RedeemFormWidget=ji;exports.SORT_PRESETS=_i;exports.STATIC_CATEGORIES=an;exports.SearchEventsButton=Nx;exports.SearchHistoryUI=Ps;exports.SearchHistoryWidget=Ns;exports.SearchInputUI=Ms;exports.SearchResultItemUI=Es;exports.SearchResultListWidget=Rs;exports.SearchWidget=Os;exports.SellFormUI=es;exports.SellFormWidget=_o;exports.SetupModal=O0;exports.SimilarEventCard=Ql;exports.SimilarEventsSection=bs;exports.SourceBadge=jx;exports.SpreadIndicator=Hb;exports.TradeFormSkeleton=cs;exports.TradeFormUI=Li;exports.TradeFormWidget=Eo;exports.UserActivitySection=ss;exports.computeMaxBuyAmount=Pi;exports.countActiveFilters=bn;exports.createPredictSearchHistoryStorage=uo;exports.createTradeResultToast=Mr;exports.estimatePolymarketBuyFee=Ni;exports.estimatePolymarketSellFee=Mi;exports.fireCelebration=wi;exports.floorToDecimals=be;exports.formatKMB=oo;exports.formatShares=Nr;exports.getSourceMeta=Or;exports.orderIntentView=fv;exports.parsePolymarketError=No;exports.polymarketFeeFactor=ua;exports.resolveExpiration=So;exports.resolvePolymarketDisplayFeeRateBps=Si;exports.roundToTickSize=Po;exports.useEventDetail=$h;exports.useEventsInfinite=Di;exports.usePredictSearchHistory=Ss;exports.usePredictWallet=cr;exports.useSearchResultListScript=Cs;exports.useSearchScript=Ex;exports.useSellForm=Xi;exports.useTradeForm=Ci;//# sourceMappingURL=index.js.map
137
137
  //# sourceMappingURL=index.js.map