@liberfi.io/ui-predict 4.0.52 → 4.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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'),reactQuery=require('@tanstack/react-query'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils$1=require('@liberfi.io/utils'),No=require('canvas-confetti'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var No__default=/*#__PURE__*/_interopDefault(No);var sc={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},Si=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],ko=(()=>{let e=t=>{let r=Si.indexOf(t);return r===-1?Si.length:r};return Object.entries(sc).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 Ni({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:u}=i18n.useTranslation(),d=react.useCallback(()=>{n(null);},[n]),p=u("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(wi,{label:p,isSelected:t===null,onPress:d,showPulse:p===a}),jsxRuntime.jsx(dc,{}),e.map(f=>{let c=f.slug??f.category,m=f.label??f.category;return jsxRuntime.jsx(wi,{label:m,isSelected:t===c,onPress:()=>n(c),badge:f.badge,showPulse:c===a||m===a},c)})]})}),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(Pi,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(f=>{let c=f.slug??f.label;return jsxRuntime.jsx(Pi,{label:f.label,icon:f.icon,isSelected:r===c,onPress:()=>i(c)},c)})]})})]})}function wi({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-neutral-500 hover:text-neutral-300"),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-neutral-950",children:o})]})}function dc(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Pi({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-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function sv({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 Mi(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function pc(e){return `predict.categories.category.${Mi(e)}`}function Ei(e){return `predict.categories.tag.${Mi(e)}`}function mc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(pc(r.slug),r.label),tags:r.tags.map(o=>({slug:o.slug,label:t(Ei(o.slug),o.label),icon:o.icon}))}))}function fc(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Ei(r.slug),r.label),icon:r.icon})):[]}function Ti({onSelect:e,trailing:t,className:r}){let{t:o}=i18n.useTranslation(),n=react.useCallback((m,g)=>{let b=o(m);return typeof b=="string"&&b!==m?b:g},[o]),[i,s]=react.useState(null),[a,l]=react.useState(null),u=react.useCallback(m=>{s(m),l(null),e?.({categorySlug:m,tagSlug:null});},[e]),d=react.useCallback(m=>{l(m),e?.({categorySlug:i,tagSlug:m});},[i,e]),p=mc(ko,n),f=ko.find(m=>m.slug===i),c=fc(f,n);return jsxRuntime.jsx(Ni,{categories:p,selectedCategory:i,selectedTag:a,activeTags:c,onCategorySelect:u,onTagSelect:d,trailing:t,className:r})}function Sn(e){return {title:e.title,imageUrl:e.image_url}}function wn(e,t){let r=e.outcomes[0],o=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??o?.best_ask??o?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??o?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:o?.label??"No"}}var qr=24,wo=4,Pn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},le={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Nn=le.ALL,hv={[le.ONE_DAY]:Pn.ONE_MINUTE,[le.ONE_WEEK]:Pn.ONE_HOUR,[le.ONE_MONTH]:Pn.ONE_HOUR,[le.ALL]:Pn.ONE_DAY},vv={[le.ONE_DAY]:300,[le.ONE_WEEK]:3600,[le.ONE_MONTH]:10800,[le.ALL]:1440*60},bv={[le.ONE_DAY]:1440*60,[le.ONE_WEEK]:10080*60,[le.ONE_MONTH]:720*60*60,[le.ALL]:null},Cn=1,Mn=1,xv=1,yv=1,kv=99,Rr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Sv=Rr.ONE_WEEK,wv={[Rr.ONE_HOUR]:60,[Rr.SIX_HOURS]:60,[Rr.ONE_DAY]:300,[Rr.ONE_WEEK]:1800,[Rr.MAX]:1800};var _i=react.createContext(null);function pr(){let e=react.useContext(_i);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var kc=1e4;function Sc({pollingInterval:e=kc,enabled:t=true,enableKalshi:r=true,children:o}){let n=walletConnector.useWallets(),i=react.useMemo(()=>n.find(F=>F.chainNamespace===types.ChainNamespace.SOLANA&&F.isConnected)?.address,[n]),s=react.useMemo(()=>n.find(F=>F.chainNamespace===types.ChainNamespace.EVM&&F.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:u,error:d}=reactPredict.useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:p,isLoading:f}=reactPredict.useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:c,isLoading:m}=reactPredict.usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=c?.safe_address,v=c?.verified??false,b=c?.wallet_kind??"deposit",x=c?.deposit_wallet_address,w=b==="safe"?c?.safe_address:x,S=b==="safe"?c?.safe_deployed??false:c?.deposit_wallet_deployed??false,{data:h,isLoading:y,isFetching:k,error:P}=reactPredict.useBalance({source:"polymarket",user:s??""},{enabled:t&&v&&!!s,refetchInterval:e}),O=react.useMemo(()=>({solanaAddress:i,evmAddress:s,polymarketWalletKind:b,polymarketWalletAddress:w,polymarketDepositWalletAddress:x,polymarketWalletDeployed:S,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:v&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:v,polymarketSafeDeployed:c?.safe_deployed??false,polymarketTokenApproved:c?.token_approved??false,polymarketSetupLoading:m,isLoading:l||y,isFetching:u||k,error:d??P??null}),[i,s,b,w,x,S,g,a,h,v,p,f,c,m,l,y,u,k,d,P]);return jsxRuntime.jsx(_i.Provider,{value:O,children:o})}var Pc={minutes:60,hours:3600,days:86400};function En(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*Pc[r]}}function Tn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function ve(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function Ii(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Nc=300;function Cc(e,t){let r=e?.[t],o=typeof r=="number"?r:Number(r);return Number.isFinite(o)?o:void 0}function Mc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Oi(e){let t=Cc(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:Mc(e,"polymarket.sportsMarketType")?Nc:0}function Ai({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:o=0,pricePerShare:n}){if(t==null||!Number.isFinite(t))return 0;let i=ve(Math.max(0,t),2);if(e!=="polymarket")return i;let s=Math.max(0,o)/1e4*Ii(n??NaN),a=i/(1+s)-r;return ve(Math.max(0,a),2)}function Di({usdcAmount:e,pricePerShare:t,feeRateBps:r}){let o=Math.max(0,r)/1e4;return o<=0||!Number.isFinite(e)||e<=0?0:e*o*Ii(t)}function Ln(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:ve(s,2).toFixed(2),active:ve(a,2).toFixed(2),available:ve(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 Gr(e,t=2){return parseFloat(ve(e,t).toFixed(t)).toString()}function mr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};No__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{No__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{No__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Hi({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:o}){let{t:n}=i18n.useTranslation(),{status:i}=walletConnector.useAuth(),s=walletConnector.useWallets(),a=reactPredict.usePredictClient(),l=react.useContext(reactPredict.PolymarketContext),u=reactQuery.useQueryClient(),d=e.source,p=d==="polymarket",f=s.find(L=>L.chainNamespace===types.ChainNamespace.SOLANA&&L.isConnected),c=s.find(L=>L.chainNamespace===types.ChainNamespace.EVM&&L.isConnected&&"switchChain"in L),m=i==="authenticated",g=f?.address,v=c?.address,[b,x]=react.useState(t),[w,S]=react.useState("market"),[h,y]=react.useState(NaN),[k,P]=react.useState(NaN),[O,F]=react.useState(false),[W,A]=react.useState(null),[G,q]=react.useState(false),[Y,re]=react.useState(false),[te,N]=react.useState("1h"),[C,U]=react.useState(30),[X,se]=react.useState("minutes"),_=react.useMemo(()=>{if(d!=="polymarket")return;let L=e.provider_meta?.["polymarket.clobTokenIds"];return L?(typeof L=="string"?JSON.parse(L):L)[b==="yes"?0:1]:void 0},[d,e.provider_meta,b]),{data:Se,isLoading:B}=reactPredict.useTickSize(_),Pe=Se?.minimum_tick_size?String(Se.minimum_tick_size):"0.01",{data:yt,isLoading:Le}=reactPredict.useFeeRate(_),rt=yt?.base_fee??0,nt=String(rt),he=react.useMemo(()=>Oi(e.provider_meta),[e.provider_meta]),{data:je}=reactPredict.useRebateConfig(),Qe=je?.builder_enabled&&je.builder_code?je.builder_code:void 0,Re=null,dt=false,Nt=null,Xe=false,Je,Be,we;try{let L=pr();Re={kalshiUsdcBalance:L.kalshiUsdcBalance,polymarketUsdcBalance:L.polymarketUsdcBalance,isLoading:L.isLoading},dt=L.kalshiKycVerified,Nt=L.kalshiKycUrl,Xe=L.polymarketSetupVerified,Je=L.polymarketSafeAddress,Be=L.polymarketWalletKind,we=L.polymarketWalletAddress;}catch{}let ut=d==="kalshi"&&!dt,Ze=d==="polymarket"&&!Xe,{data:_t}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:d,outcome:b},{enabled:e.status==="open"}),E=react.useMemo(()=>{let L=reactPredict.pickBestAsk(_t,b);if(L!=null&&L>0)return L;let We=b==="yes"?0:1,Ue=e.outcomes[We];return Ue?.best_ask??Ue?.price??.5},[_t,e.outcomes,b]),de=react.useCallback(L=>{S(L);},[]),He=react.useCallback(L=>{x(L),P(NaN);},[]);react.useEffect(()=>{He(t);},[t,He]),react.useEffect(()=>{w==="limit"&&isNaN(k)&&P(Math.round(E*1e4)/1e4);},[w,k,E]);let qe=react.useMemo(()=>isNaN(h)||h<=0?0:E>0?h/E:0,[h,E]),ze=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:_t,outcome:b,side:"buy",sharesNeeded:qe,slippageBps:r}),[_t,b,qe,r]),Zt=react.useMemo(()=>ze.status==="ok"&&ze.worstPrice!=null&&ze.worstPrice>0?ze.worstPrice:E,[ze,E]),er=react.useMemo(()=>isNaN(h)||h<=0?"0":String(Math.round(h*1e6)),[h]),Wr=e.provider_meta?.["dflow.yesMint"]??"",ot=e.provider_meta?.["dflow.noMint"]??"",Ur=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,D=b==="yes"?Wr:ot,be=Ur,Ae=D,et=d==="kalshi"?g??"":v??"",{data:$r,isLoading:co}=reactPredict.usePositions({source:d,user:et},{enabled:!!et}),uo=d==="kalshi"&&!!be&&!!Ae&&!!g&&er!=="0",{refetch:Wt}=reactPredict.useDFlowQuote({inputMint:be,outputMint:Ae,amount:er,userPublicKey:g??"",slippageBps:100},{enabled:uo}),Nr=react.useMemo(()=>Re?d==="kalshi"?Re.kalshiUsdcBalance:Re.polymarketUsdcBalance:$r&&$r.positions.reduce((We,Ue)=>Ue.side==="USDC"||Ue.side==="collateral"?We+(Ue.current_value??0):We,0)||null,[Re,$r,d]),po=Re?Re.isLoading:co,tr=react.useMemo(()=>w==="limit"&&p&&!isNaN(k)?k:E,[w,p,k,E]),Kr=react.useMemo(()=>Ai({source:d,usdcBalance:Nr,feeRateBps:he,pricePerShare:tr}),[d,Nr,he,tr]),Ut=Nr==null?null:Kr,rr=react.useMemo(()=>isNaN(h)||h<=0?0:h,[h]),nr=react.useMemo(()=>isNaN(h)||h<=0?0:tr>0?h/tr*1:0,[h,tr]),or=react.useMemo(()=>d!=="polymarket"||isNaN(h)||h<=0?0:Di({usdcAmount:h,pricePerShare:tr,feeRateBps:he}),[d,h,tr,he]),Cr=nr-rr-or,mo=react.useCallback(L=>{if(isNaN(L)){y(NaN);return}y(Math.round(Math.max(0,L)*100)/100);},[]),hn=react.useCallback(L=>{if(isNaN(L)){P(NaN);return}P(Math.round(L*1e4)/1e4);},[]),ir=react.useCallback(()=>{y(NaN),P(NaN),S("market"),re(false),N("1h"),U(30),se("minutes");},[]),it=react.useMemo(()=>{let L=[];return isNaN(h)||h<=0?L.push(n("predict.trade.minAmountUsd",{amount:Mn})):h<Mn&&L.push(n("predict.trade.minAmountUsd",{amount:Mn})),e.status!=="open"&&L.push(n("predict.trade.marketNotActive")),Ut!=null&&!isNaN(h)&&h>0&&h>Ut&&L.push(n("predict.trade.insufficientBalance")),w==="limit"&&p&&(isNaN(k)||k<.01||k>.99)&&L.push(n("predict.trade.limitPriceRange")),w==="limit"&&p&&Y&&te==="custom"&&(isNaN(C)||C<=0)&&L.push(n("predict.trade.expiration.invalidDate")),d==="polymarket"&&w==="market"&&!isNaN(h)&&h>0&&qe>0&&(ze.status==="insufficient_liquidity"?L.push(n("predict.trade.insufficientLiquidity",{available:ve(ze.totalAvailable,2)})):ze.status==="exceeds_slippage"&&L.push(n("predict.trade.priceImpactTooHigh",{impact:(ze.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:L.length===0,errors:L}},[h,e.status,Ut,w,p,k,Y,te,C,d,qe,ze,r,n]),vn=react.useMemo(()=>Ut==null||isNaN(h)||h<=0?false:h>Ut,[Ut,h]),fo=react.useCallback(()=>{o?.(d);},[o,d]),{mutateAsync:Mr}=reactPredict.useDFlowSubmit(),{data:Vr}=reactPredict.useOrder({id:W??"",source:d},{enabled:!!W});react.useEffect(()=>{if(!Vr||!W)return;let{status:L}=Vr;L==="closed"?(A(null),F(false),ui.toast.success(n("predict.trade.submitSuccess")),mr(),ir(),u.invalidateQueries({queryKey:["predict","positions"]})):(L==="failed"||L==="expired")&&(F(false),A(null),ui.toast.error(n("predict.trade.submitError")));},[Vr,W,u,ir,n]);let bn=react.useCallback(async()=>{if(!g||!f)return;if(!be||!Ae){ui.toast.error("Missing token mint addresses"),F(false);return}if(!dt){q(true),F(false);return}let Ct=(await Wt()).data?.transaction;if(!Ct){ui.toast.error(n("predict.trade.submitError")),F(false);return}let Er=Uint8Array.from(atob(Ct),kt=>kt.charCodeAt(0)),Mt=await f.signTransaction(Er),It=await Mr({signedTransaction:btoa(String.fromCharCode(...Mt)),orderContext:{user_public_key:g,input_mint:be,output_mint:Ae,amount:er,price:String(E),side:"BUY",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});A(It.signature);},[g,f,Wt,Mr,be,Ae,er,E,b,e.slug,n,dt]),xn=react.useCallback(async()=>{if(!c||!l)return;let L=c.chain,We=L!==types.Chain.POLYGON;We&&await c.switchChain(types.Chain.POLYGON);try{let Ue=await c.getEip1193Provider();if(!Ue){ui.toast.error(n("predict.trade.submitError")),F(!1);return}let Ct=Be==="deposit"&&!!we,Er=!Ct&&!!Je,Mt=Ct?we:Je,It={address:c.address,signatureType:Ct?3:Er?2:0,signTypedData:async(at,$t,Tr,jr)=>{let sr=[];"name"in at&&sr.push({name:"name",type:"string"}),"version"in at&&sr.push({name:"version",type:"string"}),"chainId"in at&&sr.push({name:"chainId",type:"uint256"}),"verifyingContract"in at&&sr.push({name:"verifyingContract",type:"address"}),"salt"in at&&sr.push({name:"salt",type:"bytes32"});let ki={EIP712Domain:sr,...$t};return await Ue.request({method:"eth_signTypedData_v4",params:[c.address,JSON.stringify({domain:at,types:ki,primaryType:Tr,message:jr})]})}},kt=l.credentials??await l.authenticate(It),ho=b==="yes"?0:1,M="",Ne=e.provider_meta?.["polymarket.clobTokenIds"];Ne&&(M=(typeof Ne=="string"?JSON.parse(Ne):Ne)[ho]??"");let $e=e.provider_meta?.["polymarket.negRisk"]??!1,st=w==="limit"&&!isNaN(k)?k:Zt,Ge=Tn(st,Pe),Et=w==="limit"?Y?"GTD":"GTC":"FOK",St=w==="market"?h:Ge>0?h/Ge:0,Ee={tokenId:M,price:Ge,size:St,side:"BUY",orderType:Et,tickSize:Pe,negRisk:$e,...Mt&&{funderAddress:Mt},...Qe&&{builderCode:Qe},...w==="limit"&&Y&&{expiration:En(te,C,X)}},wt;if(Ct)wt=await reactPredict.buildSignedV2OrderPayload({signer:It,depositWalletAddress:Mt,input:Ee,owner:kt.apiKey});else {let at=reactPredict.buildCtfExchangeDomain($e),$t=reactPredict.buildOrderMessage({...Ee,signerAddress:It.address,signatureType:It.signatureType,feeRateBps:nt}),Tr=await It.signTypedData(at,reactPredict.CTF_ORDER_TYPES,"Order",$t),jr=reactPredict.buildSignedOrder($t,Tr,Ee.orderType);wt=reactPredict.buildClobPayload(jr,kt.apiKey);}await a.executePolymarketOrder({payload:wt,l2_api_key:kt.apiKey,l2_secret:kt.secret,l2_passphrase:kt.passphrase,signer_address:kt.address,owner:kt.apiKey}),u.invalidateQueries({queryKey:["predict","orders"]}),u.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(n("predict.trade.submitSuccess")),mr(),ir(),F(!1);}finally{We&&L&&c.switchChain(L).catch(()=>{});}},[c,l,b,e.provider_meta,w,k,Zt,h,a,u,Y,te,C,X,ir,n,Pe,nt,Je,Be,we,Qe]),go=react.useCallback(async()=>{if(!(!it.isValid||!m)){F(true),A(null),q(false);try{d==="kalshi"?await bn():await xn();}catch(L){let We=L instanceof Error?L.message:"",Ue=d==="polymarket"&&We?Ln(We,n,"buy"):We||void 0;ui.toast.error(Ue||n("predict.trade.submitError")),F(false);}}},[it.isValid,m,d,bn,xn,n]);return {outcome:b,orderType:w,quantity:h,limitPrice:k,shares:qe,estimatedCost:rr,estimatedFee:or,potentialPayout:nr,potentialProfit:Cr,pricePerShare:E,usdcBalance:Nr,maxBuyAmount:Kr,spendableUsdcBalance:Ut,isBalanceLoading:po,isMarketDataLoading:d==="polymarket"&&(Le||B),isSubmitting:O,authStatus:i,validation:it,isInsufficientBalance:vn,source:d,supportsLimitOrder:p,kycRequired:G,needsKyc:ut,needsSetup:Ze,kycUrl:Nt,expirationEnabled:Y,expirationPreset:te,customDuration:C,customDurationUnit:X,setOutcome:He,setOrderType:de,setQuantity:mo,setLimitPrice:hn,setExpirationEnabled:re,setExpirationPreset:N,setCustomDuration:U,setCustomDurationUnit:se,submit:go,notifyInsufficientBalance:fo}}function Rn({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:"!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.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:o("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: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-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:o(n)})]},n))}),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:[o("predict.trade.goToKYC")," \u2192"]}),jsxRuntime.jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("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:o("common.ok")})]})]})})})}var dd=["5m","1h","12h","24h","eod","custom"],ud={"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"},pd=["minutes","hours","days"],md={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},fd={maximumFractionDigits:0},gr="-";function Gi({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:u,estimatedCost:d,estimatedFee:p=0,usdcBalance:f,isBalanceLoading:c,isMarketDataLoading:m,isSubmitting:g,authStatus:v,isValid:b,validationErrors:x,isInsufficientBalance:w,onInsufficientBalance:S,supportsLimitOrder:h,maxBuyAmount:y,kycRequired:k,needsKyc:P,needsSetup:O,kycUrl:F,expirationEnabled:W,expirationPreset:A,customDuration:G,customDurationUnit:q,oddsFormatter:Y,onOutcomeChange:re,onOrderTypeChange:te,onQuantityChange:N,onLimitPriceChange:C,onExpirationEnabledChange:U,onExpirationPresetChange:X,onCustomDurationChange:se,onCustomDurationUnitChange:_,onSubmit:Se}){let{t:B}=i18n.useTranslation(),[Pe,yt]=react.useState(true),Le=ui.useDisclosure(),[rt,nt]=react.useState(""),he=react.useRef(false);react.useEffect(()=>{he.current||nt(isNaN(i)?"":String(i));},[i]);let[je,Qe]=react.useState(""),Re=react.useRef(false);react.useEffect(()=>{Re.current||(isNaN(s)?Qe(""):Qe(String(parseFloat((s*100).toFixed(2)))));},[s]);let dt=react.useCallback(D=>{if(D!==""&&!/^\d*\.?\d{0,2}$/.test(D))return;if(Qe(D),D===""||D==="."){C(NaN);return}let Ae=parseFloat(D);isNaN(Ae)||C(Ae/100);},[C]),Nt=react.useCallback(D=>{if(D!==""&&!/^\d*\.?\d{0,2}$/.test(D))return;if(nt(D),ot(false),D===""||D==="."){N(NaN);return}let Ae=parseFloat(D);isNaN(Ae)||N(Ae);},[N]);react.useEffect(()=>{k&&!Le.isOpen&&Le.onOpen();},[k]);let Xe=react.useMemo(()=>{let D=o==="yes"?t.yesAsk:t.noAsk;return D!=null?parseFloat((Number(D)*100).toFixed(2)):null},[o,t]),Je=o==="yes"?t.yesAsk:t.noAsk,Be=Je!=null&&Y?Y(Number(Je)):Xe!=null?`${Xe} \xA2`:gr,we=!isNaN(i)&&i>0,ut=we?d+p:0,Ze=we&&a>0?ut/a:0,_t=Ze>0&&Y?Y(Ze):Ze>0?`${parseFloat((Ze*100).toFixed(2))}\xA2`:gr,E=v==="authenticated",de=v==="authenticating"||v==="deauthenticating",He=E&&(P||O),qe=react.useMemo(()=>{if(de)return B("predict.trade.checkingLogin");if(!E)return B("predict.trade.loginToTrade");if(P)return B("predict.trade.kycRequired");if(O)return B("predict.trade.setupRequired");if(c)return B("predict.trade.loadingBalance");if(m)return B("predict.trade.loadingMarketData");if(g)return B("predict.trade.submitting");if(k)return B("predict.trade.kycRequired");if(!we)return B("predict.trade.enterAmount");let D=B(o==="yes"?"predict.trade.yes":"predict.trade.no"),be=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${B("predict.trade.buy")} ${D}${be}`},[de,E,P,O,c,m,g,k,we,o,l,B]),ze="primary",Zt=()=>{let D=y??ve(f??0,2);N(ve(D/2,2));},er=()=>{N(y??ve(f??0,2));},[Wr,ot]=react.useState(false),Ur=()=>{if(!E){ot(false),Se();return}if(P){Le.onOpen();return}if(O&&S){ot(false),S();return}if(k){Le.onOpen();return}if(w&&S){ot(false),S();return}if(!b){ot(true);return}ot(false),Se();};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:D=>{r==="bordered"&&(D.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:D=>{r==="bordered"&&(D.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:"text-bullish",children:[B("predict.trade.buy")," ",B(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[h?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:D=>te(D),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:B("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:B("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:B("predict.trade.market")}),n==="limit"&&h?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:je,onChange:D=>dt(D.target.value),onFocus:()=>{Re.current=true;},onBlur:()=>{Re.current=false,isNaN(s)?Qe(""):Qe(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"}}):Be!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:Be})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(D=>{let be=D==="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:()=>re(D),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===D?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:B(D==="yes"?"predict.trade.yes":"predict.trade.no")}),be!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(be)):`${parseFloat((Number(be)*100).toFixed(2))}\xA2`})]})},D)})}),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:B("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:Zt,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:B("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:er,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:B("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:rt,onChange:D=>Nt(D.target.value),onFocus:()=>{he.current=true;},onBlur:()=>{he.current=false,nt(isNaN(i)?"":String(i));},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"}}),Wr&&x.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:x.map(D=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:D},D))})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"text-neutral-500",children:B("predict.trade.balance")}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:f!=null?`$${ve(f,2).toFixed(2)}`:"$0"})]}),n==="limit"&&h&&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:B("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:W,onValueChange:U,"aria-label":B("predict.trade.setExpiration")})]}),W&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":B("predict.trade.setExpiration"),selectedKeys:[A],onSelectionChange:D=>{let be=Array.from(D)[0];be&&X(be);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:dd.map(D=>jsxRuntime.jsx(ui.SelectItem,{children:B(ud[D])},D))}),A==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(G)?void 0:G,onValueChange:se,minValue:1,step:1,formatOptions:fd,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":"Duration unit",selectedKeys:[q],onSelectionChange:D=>{let be=Array.from(D)[0];be&&_(be);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pd.map(D=>jsxRuntime.jsx(ui.SelectItem,{children:B(md[D])},D))})]})]})]}),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:()=>yt(D=>!D),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:B("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",Pe&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Je!=null?Be:Xe!=null?B("predict.trade.chance",{percent:Xe}):gr})]}),Pe&&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:B("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:gr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:B("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?Gr(a):gr})]}),p>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:B("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${p.toFixed(2)}`})]}),p>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:B("predict.trade.totalPayment")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${ut.toFixed(2)}`})]}),p>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:B("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:_t})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:B("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:gr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:B("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:gr})]})]})]}),jsxRuntime.jsx(ui.Button,{color:ze,fullWidth:true,radius:"lg",size:"lg",isDisabled:de||E&&!He&&(c||m||!we||g),isLoading:de||E&&!He&&(g||c||m),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Ur,children:qe})]}),jsxRuntime.jsx(Rn,{isOpen:Le.isOpen,onClose:Le.onClose,kycUrl:F})]})}function In({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:l}){let{outcome:u,orderType:d,quantity:p,limitPrice:f,shares:c,estimatedCost:m,estimatedFee:g,potentialPayout:v,potentialProfit:b,pricePerShare:x,usdcBalance:w,maxBuyAmount:S,isBalanceLoading:h,isMarketDataLoading:y,isSubmitting:k,authStatus:P,validation:O,isInsufficientBalance:F,supportsLimitOrder:W,kycRequired:A,needsKyc:G,needsSetup:q,kycUrl:Y,expirationEnabled:re,expirationPreset:te,customDuration:N,customDurationUnit:C,setOutcome:U,setOrderType:X,setQuantity:se,setLimitPrice:_,setExpirationEnabled:Se,setExpirationPreset:B,setCustomDuration:Pe,setCustomDurationUnit:yt,submit:Le,notifyInsufficientBalance:rt}=Hi({market:t,initialOutcome:o,slippageBps:i,onInsufficientBalance:s}),nt=walletConnector.useAuthCallback(Le),he=react.useCallback(Re=>{U(Re),a?.(Re);},[U,a]),je=react.useMemo(()=>e?Sn(e):void 0,[e]),Qe=react.useMemo(()=>wn(t,{yesAsk:u==="yes"?x:void 0,noAsk:u==="no"?x:void 0}),[t,u,x]);return jsxRuntime.jsx(Gi,{event:je,market:Qe,variant:r,outcome:u,orderType:d,quantity:p,limitPrice:f,shares:c,estimatedCost:m,estimatedFee:g,potentialPayout:v,potentialProfit:b,usdcBalance:w,maxBuyAmount:S,isBalanceLoading:h,isMarketDataLoading:y,isSubmitting:k,authStatus:P,isValid:O.isValid,validationErrors:O.errors,isInsufficientBalance:F,onInsufficientBalance:s?rt:void 0,supportsLimitOrder:W,kycRequired:A,needsKyc:G,needsSetup:q,kycUrl:Y,expirationEnabled:re,expirationPreset:te,customDuration:N,customDurationUnit:C,oddsFormatter:l,onOutcomeChange:he,onOrderTypeChange:X,onQuantityChange:se,onLimitPriceChange:_,onExpirationEnabledChange:Se,onExpirationPresetChange:B,onCustomDurationChange:Pe,onCustomDurationUnitChange:yt,onSubmit:nt})}var Yr="predict-trade";function On({id:e=Yr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(wd,{...t})})}function wd({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:"!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.ModalContent,{children:jsxRuntime.jsxs("div",{className:n?"":"p-2",children:[jsxRuntime.jsx(In,{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:o("common.cancel")})})]})})}):null}var Qr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Eo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function Qi({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?Qr:{...Qr,source:"polymarket"},[n]),u=react.useCallback(x=>{x?a(r):t();},[r,t]),d=react.useCallback(()=>{a(l);},[l]),p=react.useCallback(()=>{o(s),t();},[s,o,t]),f=react.useCallback((x,w)=>{a(S=>({...S,[x]:w}));},[]),c=react.useMemo(()=>Eo(s,n),[s,n]),m=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]),v=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]),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]);return jsxRuntime.jsx(ui.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.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:i("predict.filter.title")}),jsxRuntime.jsx(Td,{onClick:()=>u(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[n&&jsxRuntime.jsx(Dn,{label:i("predict.filter.platform"),children:jsxRuntime.jsx(Fn,{options:m,selected:s.source,onSelect:x=>f("source",x)})}),jsxRuntime.jsx(Dn,{label:i("predict.filter.timeRemaining"),children:jsxRuntime.jsx(Fn,{options:g,selected:s.timeRemaining,onSelect:x=>f("timeRemaining",x)})}),jsxRuntime.jsx(Dn,{label:i("predict.filter.minVolume"),children:jsxRuntime.jsx(Fn,{options:v,selected:s.minVolume,onSelect:x=>f("minVolume",x)})}),jsxRuntime.jsx(Dn,{label:i("predict.filter.minLiquidity"),children:jsxRuntime.jsx(Fn,{options:b,selected:s.minLiquidity,onSelect:x=>f("minLiquidity",x)})})]}),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: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-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:p,children:[i("predict.filter.showResults"),c>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",c,")"]})]})]})]})})})}function Dn({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 Td({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 Fn({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 rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var ts={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Ji={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Bd=["start_time","volume","liquidity","ending_soon"],Zi={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"},Hd={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 rs({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:s}){let{t:a}=i18n.useTranslation(),[l,u]=react.useState(false),d=react.useRef(null),p=react.useCallback(c=>{d.current&&!d.current.contains(c.target)&&u(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),react.useEffect(()=>{if(!l)return;let c=m=>{m.key==="Escape"&&u(false);};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l]);let f=es[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:Zi,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(c=>!c),children:[jsxRuntime.jsx(zd,{}),jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Ji[e])}),jsxRuntime.jsx(Ud,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Hd,width:224,padding:4},children:Bd.map(c=>{let m=es[c],g=e===c;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?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:v=>{g||(v.currentTarget.style.background="rgba(39,39,42,0.5)",v.currentTarget.style.color="#fff");},onMouseLeave:v=>{g||(v.currentTarget.style.background="transparent",v.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===c?o(!r):t(c),u(false);},children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:a(Ji[c])}),g&&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"})})]},c)})})]}),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:c=>{c.currentTarget.style.background="rgba(39,39,42,1)",c.currentTarget.style.color="#fff";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)",c.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:Zi,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsxRuntime.jsx(Wd,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},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:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var es={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function zd(){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 Wd(){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 Ud({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 is(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:u,refetch:d}=reactPredict.useInfiniteEvents(t),p=react.useMemo(()=>r?.pages.flatMap(m=>m.items).filter(m=>m!=null)??[],[r]),f=react.useCallback(()=>{u();},[u]),c=react.useCallback(()=>{d();},[d]);return {data:p,isLoading:o,isFetching:n&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:f,refetch:c}}var ss=`
|
|
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$1=require('@liberfi.io/utils'),Ro=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'),jotai=require('jotai'),utils=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ro__default=/*#__PURE__*/_interopDefault(Ro);var gc={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Ei=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Mo=(()=>{let e=t=>{let r=Ei.indexOf(t);return r===-1?Ei.length:r};return Object.entries(gc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function _i({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:c}){let{t:u}=i18n.useTranslation(),p=react.useCallback(()=>{o(null);},[o]),d=u("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",c),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(Li,{label:d,isSelected:t===null,onPress:p,showPulse:d===a}),jsxRuntime.jsx(xc,{}),e.map(f=>{let l=f.slug??f.category,m=f.label??f.category;return jsxRuntime.jsx(Li,{label:m,isSelected:t===l,onPress:()=>o(l),badge:f.badge,showPulse:l===a||m===a},l)})]})}),s&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:s})]}),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(Ri,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(f=>{let l=f.slug??f.label;return jsxRuntime.jsx(Ri,{label:f.label,icon:f.icon,isSelected:r===l,onPress:()=>i(l)},l)})]})})]})}function Li({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){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-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 xc(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Ri({label:e,icon:t,isSelected:r,onPress:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:n,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-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function wv({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 Oi(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function kc(e){return `predict.categories.category.${Oi(e)}`}function Di(e){return `predict.categories.tag.${Oi(e)}`}function Sc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(kc(r.slug),r.label),tags:r.tags.map(n=>({slug:n.slug,label:t(Di(n.slug),n.label),icon:n.icon}))}))}function wc(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Di(r.slug),r.label),icon:r.icon})):[]}function Ai({onSelect:e,trailing:t,className:r}){let{t:n}=i18n.useTranslation(),o=react.useCallback((m,g)=>{let v=n(m);return typeof v=="string"&&v!==m?v:g},[n]),[i,s]=react.useState(null),[a,c]=react.useState(null),u=react.useCallback(m=>{s(m),c(null),e?.({categorySlug:m,tagSlug:null});},[e]),p=react.useCallback(m=>{c(m),e?.({categorySlug:i,tagSlug:m});},[i,e]),d=Sc(Mo,o),f=Mo.find(m=>m.slug===i),l=wc(f,o);return jsxRuntime.jsx(_i,{categories:d,selectedCategory:i,selectedTag:a,activeTags:l,onCategorySelect:u,onTagSelect:p,trailing:t,className:r})}function Cn(e){return {title:e.title,imageUrl:e.image_url}}function Mn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var jr=24,Eo=4,Tn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},le={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},En=le.ALL,Iv={[le.ONE_DAY]:Tn.ONE_MINUTE,[le.ONE_WEEK]:Tn.ONE_HOUR,[le.ONE_MONTH]:Tn.ONE_HOUR,[le.ALL]:Tn.ONE_DAY},Ov={[le.ONE_DAY]:300,[le.ONE_WEEK]:3600,[le.ONE_MONTH]:10800,[le.ALL]:1440*60},Dv={[le.ONE_DAY]:1440*60,[le.ONE_WEEK]:10080*60,[le.ONE_MONTH]:720*60*60,[le.ALL]:null},Ln=1,Rn=1,Av=1,Fv=1,Bv=99,_r={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Hv=_r.ONE_WEEK,zv={[_r.ONE_HOUR]:60,[_r.SIX_HOURS]:60,[_r.ONE_DAY]:300,[_r.ONE_WEEK]:1800,[_r.MAX]:1800};var Hi=react.createContext(null);function br(){let e=react.useContext(Hi);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Lc=1e4;function Rc({pollingInterval:e=Lc,enabled:t=true,enableKalshi:r=true,children:n}){let o=walletConnector.useWallets(),i=react.useMemo(()=>o.find(I=>I.chainNamespace===types.ChainNamespace.SOLANA&&I.isConnected)?.address,[o]),s=react.useMemo(()=>o.find(I=>I.chainNamespace===types.ChainNamespace.EVM&&I.isConnected)?.address,[o]),{data:a,isLoading:c,isFetching:u,error:p}=reactPredict.useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:d,isLoading:f}=reactPredict.useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:l,isLoading:m}=reactPredict.usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),g=l?.safe_address,h=l?.verified??false,v=l?.wallet_kind??"deposit",b=l?.deposit_wallet_address,N=v==="safe"?l?.safe_address:b,k=v==="safe"?l?.safe_deployed??false:l?.deposit_wallet_deployed??false,{data:x,isLoading:y,isFetching:P,error:S}=reactPredict.useBalance({source:"polymarket",user:s??""},{enabled:t&&h&&!!s,refetchInterval:e}),R=react.useMemo(()=>({solanaAddress:i,evmAddress:s,polymarketWalletKind:v,polymarketWalletAddress:N,polymarketDepositWalletAddress:b,polymarketWalletDeployed:k,polymarketSafeAddress:g,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:h&&x?Number(x.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:h,polymarketSafeDeployed:l?.safe_deployed??false,polymarketTokenApproved:l?.token_approved??false,polymarketSetupLoading:m,isLoading:c||y,isFetching:u||P,error:p??S??null}),[i,s,v,N,b,k,g,a,x,h,d,f,l,m,c,y,u,P,p,S]);return jsxRuntime.jsx(Hi.Provider,{value:R,children:n})}var Ic={minutes:60,hours:3600,days:86400};function _n(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*Ic[r]}}function In(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function ve(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function zi(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Oc=300;function Dc(e,t){let r=e?.[t],n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:void 0}function Ac(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Wi(e){let t=Dc(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:Ac(e,"polymarket.sportsMarketType")?Oc:0}function Ui({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:n=0,pricePerShare:o}){if(t==null||!Number.isFinite(t))return 0;let i=ve(Math.max(0,t),2);if(e!=="polymarket")return i;let s=Math.max(0,n)/1e4*zi(o??NaN),a=i/(1+s)-r;return ve(Math.max(0,a),2)}function $i({usdcAmount:e,pricePerShare:t,feeRateBps:r}){let n=Math.max(0,r)/1e4;return n<=0||!Number.isFinite(e)||e<=0?0:e*n*zi(t)}function On(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let s=parseInt(o[1],10)/1e6,a=parseInt(o[2],10)/1e6,c=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:ve(s,2).toFixed(2),active:ve(a,2).toFixed(2),available:ve(c,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function qr(e,t=2){return parseFloat(ve(e,t).toFixed(t)).toString()}function Ki(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Ro__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Ro__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Ro__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var Vi={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function Fc(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function _o(e,t,r){let n=e(t);return n&&n!==t?n:r}function Ir(e,t){let r=Fc(t)?Vi.zh:Vi.en;return {submitted:_o(e,"predict.trade.resultSubmitted",r.submitted),completed:_o(e,"predict.trade.resultCompleted",r.completed),delayed:_o(e,"predict.trade.resultDelayed",r.delayed)}}function Wc({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 Or({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.toast.progress({id:e,message:n.submitted,duration:t,progress:true,action:react.createElement(Wc,{deadlineAt:o})});},completed:()=>{ui.toast.update(e,{type:"success",message:n.completed,duration:5e3}),r&&Ki();},delayed:()=>{ui.toast.update(e,{type:"blank",message:n.delayed,duration:8e3});},failed:o=>{ui.toast.update(e,{type:"error",message:o,duration:8e3});}}}function Gi({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o,i18n:i}=i18n.useTranslation(),{status:s}=walletConnector.useAuth(),a=walletConnector.useWallets(),c=reactPredict.usePredictClient(),u=react.useContext(reactPredict.PolymarketContext),{start:p}=reactPredict.useTradeResultConfirmation(),d=e.source,f=d==="polymarket",l=a.find(L=>L.chainNamespace===types.ChainNamespace.SOLANA&&L.isConnected),m=a.find(L=>L.chainNamespace===types.ChainNamespace.EVM&&L.isConnected&&"switchChain"in L),g=s==="authenticated",h=l?.address,v=m?.address,[b,N]=react.useState(t),[k,x]=react.useState("market"),[y,P]=react.useState(NaN),[S,R]=react.useState(NaN),[I,z]=react.useState(false),[K,W]=react.useState(null),[G,Y]=react.useState(false),[Q,re]=react.useState(false),[w,M]=react.useState("1h"),[$,J]=react.useState(30),[ne,O]=react.useState("minutes"),Se=react.useMemo(()=>Ir(o,i),[i,o]),A=react.useCallback(async(L,Ne)=>{let Re=Or({celebrateOnCompleted:true,messages:Se});Re.submitted(),await p({source:d,user:d==="kalshi"?h:v,kalshiUser:h,polymarketUser:v,marketSlug:e.slug,eventSlug:e.event_slug,expectation:L,getOrdersHeaders:Ne})==="confirmed"?Re.completed():Re.delayed();},[p,v,e.event_slug,e.slug,d,Se,h]),be=react.useMemo(()=>{if(d!=="polymarket")return;let L=e.provider_meta?.["polymarket.clobTokenIds"];return L?(typeof L=="string"?JSON.parse(L):L)[b==="yes"?0:1]:void 0},[d,e.provider_meta,b]),{data:pt,isLoading:Ee}=reactPredict.useTickSize(be),qe=pt?.minimum_tick_size?String(pt.minimum_tick_size):"0.01",{data:st,isLoading:we}=reactPredict.useFeeRate(be),Ze=st?.base_fee??0,et=String(Ze),tt=react.useMemo(()=>Wi(e.provider_meta),[e.provider_meta]),{data:at}=reactPredict.useRebateConfig(),Ot=at?.builder_enabled&&at.builder_code?at.builder_code:void 0,ze=null,rt=false,We=null,Ue=false,nt,mt,Mt;try{let L=br();ze={kalshiUsdcBalance:L.kalshiUsdcBalance,polymarketUsdcBalance:L.polymarketUsdcBalance,isLoading:L.isLoading},rt=L.kalshiKycVerified,We=L.kalshiKycUrl,Ue=L.polymarketSetupVerified,nt=L.polymarketSafeAddress,mt=L.polymarketWalletKind,Mt=L.polymarketWalletAddress;}catch{}let E=d==="kalshi"&&!rt,de=d==="polymarket"&&!Ue,{data:Le}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:d,outcome:b},{enabled:e.status==="open"}),Ge=react.useMemo(()=>{let L=reactPredict.pickBestAsk(Le,b);if(L!=null&&L>0)return L;let Ne=b==="yes"?0:1,Re=e.outcomes[Ne];return Re?.best_ask??Re?.price??.5},[Le,e.outcomes,b]),Vr=react.useCallback(L=>{x(L);},[]),Dt=react.useCallback(L=>{N(L),R(NaN);},[]);react.useEffect(()=>{Dt(t);},[t,Dt]),react.useEffect(()=>{k==="limit"&&isNaN(S)&&R(Math.round(Ge*1e4)/1e4);},[k,S,Ge]);let Pt=react.useMemo(()=>isNaN(y)||y<=0?0:Ge>0?y/Ge:0,[y,Ge]),Pe=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:Le,outcome:b,side:"buy",sharesNeeded:Pt,slippageBps:r}),[Le,b,Pt,r]),ot=react.useMemo(()=>Pe.status==="ok"&&Pe.worstPrice!=null&&Pe.worstPrice>0?Pe.worstPrice:Ge,[Pe,Ge]),At=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),F=e.provider_meta?.["dflow.yesMint"]??"",$e=e.provider_meta?.["dflow.noMint"]??"",ft=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,go=b==="yes"?F:$e,qt=ft,Gt=go,Ft=d==="kalshi"?h??"":v??"",{data:Ye,isLoading:ho}=reactPredict.usePositionsMulti({kalshi_user:d==="kalshi"?Ft:void 0,polymarket_user:d==="polymarket"?Ft:void 0},{enabled:!!Ft}),vo=d==="kalshi"&&!!qt&&!!Gt&&!!h&&At!=="0",{refetch:hn}=reactPredict.useDFlowQuote({inputMint:qt,outputMint:Gt,amount:At,userPublicKey:h??"",slippageBps:100},{enabled:vo}),Tt=react.useMemo(()=>ze?d==="kalshi"?ze.kalshiUsdcBalance:ze.polymarketUsdcBalance:Ye&&Ye.positions.reduce((Ne,Re)=>Re.side==="USDC"||Re.side==="collateral"?Ne+(Re.current_value??0):Ne,0)||null,[ze,Ye,d]),bo=ze?ze.isLoading:ho,Yt=react.useMemo(()=>k==="limit"&&f&&!isNaN(S)?S:Ge,[k,f,S,Ge]),xo=react.useMemo(()=>Ui({source:d,usdcBalance:Tt,feeRateBps:tt,pricePerShare:Yt}),[d,Tt,tt,Yt]),Bt=Tt==null?null:xo,vn=react.useMemo(()=>isNaN(y)||y<=0?0:y,[y]),nr=react.useMemo(()=>isNaN(y)||y<=0?0:Yt>0?y/Yt*1:0,[y,Yt]),or=react.useMemo(()=>d!=="polymarket"||isNaN(y)||y<=0?0:$i({usdcAmount:y,pricePerShare:Yt,feeRateBps:tt}),[d,y,Yt,tt]),pr=nr-vn-or,Er=react.useCallback(L=>{if(isNaN(L)){P(NaN);return}P(Math.round(Math.max(0,L)*100)/100);},[]),yo=react.useCallback(L=>{if(isNaN(L)){R(NaN);return}R(Math.round(L*1e4)/1e4);},[]),mr=react.useCallback(()=>{P(NaN),R(NaN),x("market"),re(false),M("1h"),J(30),O("minutes");},[]),fr=react.useMemo(()=>{let L=[];return isNaN(y)||y<=0?L.push(o("predict.trade.minAmountUsd",{amount:Rn})):y<Rn&&L.push(o("predict.trade.minAmountUsd",{amount:Rn})),e.status!=="open"&&L.push(o("predict.trade.marketNotActive")),Bt!=null&&!isNaN(y)&&y>0&&y>Bt&&L.push(o("predict.trade.insufficientBalance")),k==="limit"&&f&&(isNaN(S)||S<.01||S>.99)&&L.push(o("predict.trade.limitPriceRange")),k==="limit"&&f&&Q&&w==="custom"&&(isNaN($)||$<=0)&&L.push(o("predict.trade.expiration.invalidDate")),d==="polymarket"&&k==="market"&&!isNaN(y)&&y>0&&Pt>0&&(Pe.status==="insufficient_liquidity"?L.push(o("predict.trade.insufficientLiquidity",{available:ve(Pe.totalAvailable,2)})):Pe.status==="exceeds_slippage"&&L.push(o("predict.trade.priceImpactTooHigh",{impact:(Pe.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:L.length===0,errors:L}},[y,e.status,Bt,k,f,S,Q,w,$,d,Pt,Pe,r,o]),Nt=react.useMemo(()=>Bt==null||isNaN(y)||y<=0?false:y>Bt,[Bt,y]),bn=react.useCallback(()=>{n?.(d);},[n,d]),{mutateAsync:xn}=reactPredict.useDFlowSubmit(),{data:gr}=reactPredict.useOrder({id:K??"",source:d},{enabled:!!K});react.useEffect(()=>{if(!gr||!K)return;let{status:L}=gr;L==="closed"?(W(null),z(false),A("buy-market"),mr()):(L==="failed"||L==="expired")&&(z(false),W(null),ui.toast.error(o("predict.trade.submitError")));},[A,gr,K,mr,o]);let yn=react.useCallback(async()=>{if(!h||!l)return;if(!qt||!Gt){ui.toast.error("Missing token mint addresses"),z(false);return}if(!rt){Y(true),z(false);return}let gt=(await hn()).data?.transaction;if(!gt){ui.toast.error(o("predict.trade.submitError")),z(false);return}let hr=Uint8Array.from(atob(gt),Qe=>Qe.charCodeAt(0)),ir=await l.signTransaction(hr),ht=await xn({signedTransaction:btoa(String.fromCharCode(...ir)),orderContext:{user_public_key:h,input_mint:qt,output_mint:Gt,amount:At,price:String(Ge),side:"BUY",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});W(ht.signature);},[h,l,hn,xn,qt,Gt,At,Ge,b,e.slug,o,rt]),kn=react.useCallback(async()=>{if(!m||!u)return;let L=m.chain,Ne=L!==types.Chain.POLYGON;Ne&&await m.switchChain(types.Chain.POLYGON);try{let Re=await m.getEip1193Provider();if(!Re){ui.toast.error(o("predict.trade.submitError")),z(!1);return}let gt=mt==="deposit"&&!!Mt,hr=!gt&&!!nt,ir=gt?Mt:nt,ht={address:m.address,signatureType:gt?3:hr?2:0,signTypedData:async(Oe,Qt,sr,Lr)=>{let ar=[];"name"in Oe&&ar.push({name:"name",type:"string"}),"version"in Oe&&ar.push({name:"version",type:"string"}),"chainId"in Oe&&ar.push({name:"chainId",type:"uint256"}),"verifyingContract"in Oe&&ar.push({name:"verifyingContract",type:"address"}),"salt"in Oe&&ar.push({name:"salt",type:"bytes32"});let So={EIP712Domain:ar,...Qt};return await Re.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Oe,types:So,primaryType:sr,message:Lr})]})}},Qe=u.credentials??await u.authenticate(ht),Sn=b==="yes"?0:1,wn="",C=e.provider_meta?.["polymarket.clobTokenIds"];C&&(wn=(typeof C=="string"?JSON.parse(C):C)[Sn]??"");let Ce=e.provider_meta?.["polymarket.negRisk"]??!1,_e=k==="limit"&&!isNaN(S)?S:ot,Ke=In(_e,qe),lt=k==="limit"?Q?"GTD":"GTC":"FOK",Et=k==="market"?y:Ke>0?y/Ke:0,ct={tokenId:wn,price:Ke,size:Et,side:"BUY",orderType:lt,tickSize:qe,negRisk:Ce,...ir&&{funderAddress:ir},...Ot&&{builderCode:Ot},...k==="limit"&&Q&&{expiration:_n(w,$,ne)}},he;if(gt)he=await reactPredict.buildSignedV2OrderPayload({signer:ht,depositWalletAddress:ir,input:ct,owner:Qe.apiKey});else {let Oe=reactPredict.buildCtfExchangeDomain(Ce),Qt=reactPredict.buildOrderMessage({...ct,signerAddress:ht.address,signatureType:ht.signatureType,feeRateBps:et}),sr=await ht.signTypedData(Oe,reactPredict.CTF_ORDER_TYPES,"Order",Qt),Lr=reactPredict.buildSignedOrder(Qt,sr,ct.orderType);he=reactPredict.buildClobPayload(Lr,Qe.apiKey);}await c.executePolymarketOrder({payload:he,l2_api_key:Qe.apiKey,l2_secret:Qe.secret,l2_passphrase:Qe.passphrase,signer_address:Qe.address,owner:Qe.apiKey}),A(k==="limit"?"buy-limit":"buy-market",async()=>await reactPredict.buildPolymarketL2Headers(Qe.address,{apiKey:Qe.apiKey,secret:Qe.secret,passphrase:Qe.passphrase,method:"GET",requestPath:"/data/orders"})),mr(),z(!1);}finally{Ne&&L&&m.switchChain(L).catch(()=>{});}},[m,u,b,e.provider_meta,k,A,S,ot,y,c,Q,w,$,ne,mr,o,qe,et,nt,mt,Mt,Ot]),ko=react.useCallback(async()=>{if(!(!fr.isValid||!g)){z(true),W(null),Y(false);try{d==="kalshi"?await yn():await kn();}catch(L){let Ne=L instanceof Error?L.message:"",Re=d==="polymarket"&&Ne?On(Ne,o,"buy"):Ne||void 0;ui.toast.error(Re||o("predict.trade.submitError")),z(false);}}},[fr.isValid,g,d,yn,kn,o]);return {outcome:b,orderType:k,quantity:y,limitPrice:S,shares:Pt,estimatedCost:vn,estimatedFee:or,potentialPayout:nr,potentialProfit:pr,pricePerShare:Ge,usdcBalance:Tt,maxBuyAmount:xo,spendableUsdcBalance:Bt,isBalanceLoading:bo,isMarketDataLoading:d==="polymarket"&&(we||Ee),isSubmitting:I,authStatus:s,validation:fr,isInsufficientBalance:Nt,source:d,supportsLimitOrder:f,kycRequired:G,needsKyc:E,needsSetup:de,kycUrl:We,expirationEnabled:Q,expirationPreset:w,customDuration:$,customDurationUnit:ne,setOutcome:Dt,setOrderType:Vr,setQuantity:Er,setLimitPrice:yo,setExpirationEnabled:re,setExpirationPreset:M,setCustomDuration:J,setCustomDurationUnit:O,submit:ko,notifyInsufficientBalance:bn}}function An({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=i18n.useTranslation();return jsxRuntime.jsx(ui.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.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 Nd=["5m","1h","12h","24h","eod","custom"],Cd={"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"},Md=["minutes","hours","days"],Td={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Ed={maximumFractionDigits:0},xr="-";function ns({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:a,potentialProfit:c,potentialPayout:u,estimatedCost:p,estimatedFee:d=0,usdcBalance:f,isBalanceLoading:l,isMarketDataLoading:m,isSubmitting:g,authStatus:h,isValid:v,validationErrors:b,isInsufficientBalance:N,onInsufficientBalance:k,supportsLimitOrder:x,maxBuyAmount:y,kycRequired:P,needsKyc:S,needsSetup:R,kycUrl:I,expirationEnabled:z,expirationPreset:K,customDuration:W,customDurationUnit:G,oddsFormatter:Y,onOutcomeChange:Q,onOrderTypeChange:re,onQuantityChange:w,onLimitPriceChange:M,onExpirationEnabledChange:$,onExpirationPresetChange:J,onCustomDurationChange:ne,onCustomDurationUnitChange:O,onSubmit:Se}){let{t:A}=i18n.useTranslation(),[be,pt]=react.useState(true),Ee=ui.useDisclosure(),[qe,st]=react.useState(""),we=react.useRef(false);react.useEffect(()=>{we.current||st(isNaN(i)?"":String(i));},[i]);let[Ze,et]=react.useState(""),tt=react.useRef(false);react.useEffect(()=>{tt.current||(isNaN(s)?et(""):et(String(parseFloat((s*100).toFixed(2)))));},[s]);let at=react.useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(et(F),F===""||F==="."){M(NaN);return}let ft=parseFloat(F);isNaN(ft)||M(ft/100);},[M]),Ot=react.useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(st(F),ot(false),F===""||F==="."){w(NaN);return}let ft=parseFloat(F);isNaN(ft)||w(ft);},[w]);react.useEffect(()=>{P&&!Ee.isOpen&&Ee.onOpen();},[P]);let ze=react.useMemo(()=>{let F=n==="yes"?t.yesAsk:t.noAsk;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,t]),rt=n==="yes"?t.yesAsk:t.noAsk,We=rt!=null&&Y?Y(Number(rt)):ze!=null?`${ze} \xA2`:xr,Ue=!isNaN(i)&&i>0,nt=Ue?p+d:0,mt=Ue&&a>0?nt/a:0,Mt=mt>0&&Y?Y(mt):mt>0?`${parseFloat((mt*100).toFixed(2))}\xA2`:xr,E=h==="authenticated",de=h==="authenticating"||h==="deauthenticating",Le=E&&(S||R),Ge=react.useMemo(()=>{if(de)return A("predict.trade.checkingLogin");if(!E)return A("predict.trade.loginToTrade");if(S)return A("predict.trade.kycRequired");if(R)return A("predict.trade.setupRequired");if(l)return A("predict.trade.loadingBalance");if(m)return A("predict.trade.loadingMarketData");if(g)return A("predict.trade.submitting");if(P)return A("predict.trade.kycRequired");if(!Ue)return A("predict.trade.enterAmount");let F=A(n==="yes"?"predict.trade.yes":"predict.trade.no"),$e=c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${A("predict.trade.buy")} ${F}${$e}`},[de,E,S,R,l,m,g,P,Ue,n,c,A]),Vr="primary",Dt=()=>{let F=y??ve(f??0,2);w(ve(F/2,2));},Pt=()=>{w(y??ve(f??0,2));},[Pe,ot]=react.useState(false),At=()=>{if(!E){ot(false),Se();return}if(S){Ee.onOpen();return}if(R&&k){ot(false),k();return}if(P){Ee.onOpen();return}if(N&&k){ot(false),k();return}if(!v){ot(true);return}ot(false),Se();};return 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:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:"text-bullish",children:[A("predict.trade.buy")," ",A(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[x?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:F=>re(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:A("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:A("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:A("predict.trade.market")}),o==="limit"&&x?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ze,onChange:F=>at(F.target.value),onFocus:()=>{tt.current=true;},onBlur:()=>{tt.current=false,isNaN(s)?et(""):et(String(parseFloat((s*100).toFixed(2))));},endContent: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"}}):We!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:We})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let $e=F==="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:()=>Q(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===F?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:A(F==="yes"?"predict.trade.yes":"predict.trade.no")}),$e!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number($e)):`${parseFloat((Number($e)*100).toFixed(2))}\xA2`})]})},F)})}),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:A("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:Dt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:A("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:Pt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:A("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:qe,onChange:F=>Ot(F.target.value),onFocus:()=>{we.current=true;},onBlur:()=>{we.current=false,st(isNaN(i)?"":String(i));},startContent: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"}}),Pe&&b.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:b.map(F=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:F},F))})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"text-neutral-500",children:A("predict.trade.balance")}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:f!=null?`$${ve(f,2).toFixed(2)}`:"$0"})]}),o==="limit"&&x&&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:A("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:z,onValueChange:$,"aria-label":A("predict.trade.setExpiration")})]}),z&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":A("predict.trade.setExpiration"),selectedKeys:[K],onSelectionChange:F=>{let $e=Array.from(F)[0];$e&&J($e);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Nd.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:A(Cd[F])},F))}),K==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(W)?void 0:W,onValueChange:ne,minValue:1,step:1,formatOptions:Ed,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":"Duration unit",selectedKeys:[G],onSelectionChange:F=>{let $e=Array.from(F)[0];$e&&O($e);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Md.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:A(Td[F])},F))})]})]})]}),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:()=>pt(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:A("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",be&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&rt!=null?We:ze!=null?A("predict.trade.chance",{percent:ze}):xr})]}),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:A("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:xr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:A("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?qr(a):xr})]}),d>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:A("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${d.toFixed(2)}`})]}),d>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:A("predict.trade.totalPayment")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${nt.toFixed(2)}`})]}),d>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:A("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:Mt})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:A("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:xr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:A("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&c>0?`+$${c.toFixed(2)}`:xr})]})]})]}),jsxRuntime.jsx(ui.Button,{color:Vr,fullWidth:true,radius:"lg",size:"lg",isDisabled:de||E&&!Le&&(l||m||!Ue||g),isLoading:de||E&&!Le&&(g||l||m),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:At,children:Ge})]}),jsxRuntime.jsx(An,{isOpen:Ee.isOpen,onClose:Ee.onClose,kycUrl:I})]})}function Bn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:s,onOutcomeChange:a,oddsFormatter:c}){let{outcome:u,orderType:p,quantity:d,limitPrice:f,shares:l,estimatedCost:m,estimatedFee:g,potentialPayout:h,potentialProfit:v,pricePerShare:b,usdcBalance:N,maxBuyAmount:k,isBalanceLoading:x,isMarketDataLoading:y,isSubmitting:P,authStatus:S,validation:R,isInsufficientBalance:I,supportsLimitOrder:z,kycRequired:K,needsKyc:W,needsSetup:G,kycUrl:Y,expirationEnabled:Q,expirationPreset:re,customDuration:w,customDurationUnit:M,setOutcome:$,setOrderType:J,setQuantity:ne,setLimitPrice:O,setExpirationEnabled:Se,setExpirationPreset:A,setCustomDuration:be,setCustomDurationUnit:pt,submit:Ee,notifyInsufficientBalance:qe}=Gi({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:s}),st=walletConnector.useAuthCallback(Ee),we=react.useCallback(tt=>{$(tt),a?.(tt);},[$,a]),Ze=react.useMemo(()=>e?Cn(e):void 0,[e]),et=react.useMemo(()=>Mn(t,{yesAsk:u==="yes"?b:void 0,noAsk:u==="no"?b:void 0}),[t,u,b]);return jsxRuntime.jsx(ns,{event:Ze,market:et,variant:r,outcome:u,orderType:p,quantity:d,limitPrice:f,shares:l,estimatedCost:m,estimatedFee:g,potentialPayout:h,potentialProfit:v,usdcBalance:N,maxBuyAmount:k,isBalanceLoading:x,isMarketDataLoading:y,isSubmitting:P,authStatus:S,isValid:R.isValid,validationErrors:R.errors,isInsufficientBalance:I,onInsufficientBalance:s?qe:void 0,supportsLimitOrder:z,kycRequired:K,needsKyc:W,needsSetup:G,kycUrl:Y,expirationEnabled:Q,expirationPreset:re,customDuration:w,customDurationUnit:M,oddsFormatter:c,onOutcomeChange:we,onOrderTypeChange:J,onQuantityChange:ne,onLimitPriceChange:O,onExpirationEnabledChange:Se,onExpirationPresetChange:A,onCustomDurationChange:be,onCustomDurationUnitChange:pt,onSubmit:st})}var Yr="predict-trade";function Hn({id:e=Yr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Bd,{...t})})}function Bd({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.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.ModalContent,{children:jsxRuntime.jsxs("div",{className:o?"":"p-2",children:[jsxRuntime.jsx(Bn,{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 Qr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Do(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function is({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(r),c=react.useMemo(()=>o?Qr:{...Qr,source:"polymarket"},[o]),u=react.useCallback(b=>{b?a(r):t();},[r,t]),p=react.useCallback(()=>{a(c);},[c]),d=react.useCallback(()=>{n(s),t();},[s,n,t]),f=react.useCallback((b,N)=>{a(k=>({...k,[b]:N}));},[]),l=react.useMemo(()=>Do(s,o),[s,o]),m=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]),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]),v=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: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.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:i("predict.filter.title")}),jsxRuntime.jsx(Kd,{onClick:()=>u(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsxRuntime.jsx(Wn,{label:i("predict.filter.platform"),children:jsxRuntime.jsx(Un,{options:m,selected:s.source,onSelect:b=>f("source",b)})}),jsxRuntime.jsx(Wn,{label:i("predict.filter.timeRemaining"),children:jsxRuntime.jsx(Un,{options:g,selected:s.timeRemaining,onSelect:b=>f("timeRemaining",b)})}),jsxRuntime.jsx(Wn,{label:i("predict.filter.minVolume"),children:jsxRuntime.jsx(Un,{options:h,selected:s.minVolume,onSelect:b=>f("minVolume",b)})}),jsxRuntime.jsx(Wn,{label:i("predict.filter.minLiquidity"),children:jsxRuntime.jsx(Un,{options:v,selected:s.minLiquidity,onSelect:b=>f("minLiquidity",b)})})]}),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: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-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:d,children:[i("predict.filter.showResults"),l>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",l,")"]})]})]})]})})})}function Wn({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 Kd({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 Un({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 i=t===o.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var ds={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},as={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Zd=["start_time","volume","liquidity","ending_soon"],ls={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},eu={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function us({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:a}=i18n.useTranslation(),[c,u]=react.useState(false),p=react.useRef(null),d=react.useCallback(l=>{p.current&&!p.current.contains(l.target)&&u(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)),[d]),react.useEffect(()=>{if(!c)return;let l=m=>{m.key==="Escape"&&u(false);};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[c]);let f=cs[e];return jsxRuntime.jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:p,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:ls,onMouseEnter:l=>{l.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(l=>!l),children:[jsxRuntime.jsx(tu,{}),jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(as[e])}),jsxRuntime.jsx(nu,{open:c})]}),c&&jsxRuntime.jsx("div",{style:{...eu,width:224,padding:4},children:Zd.map(l=>{let m=cs[l],g=e===l;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?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===l?n(!r):t(l),u(false);},children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:a(as[l])}),g&&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"})})]},l)})})]}),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:l=>{l.currentTarget.style.background="rgba(39,39,42,1)",l.currentTarget.style.color="#fff";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(39,39,42,0.6)",l.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:ls,onMouseEnter:l=>{l.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:l=>{l.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsxRuntime.jsx(ru,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},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:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var cs={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function tu(){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 ru(){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 nu({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 fs(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:s,error:a,hasNextPage:c,fetchNextPage:u,refetch:p}=reactPredict.useInfiniteEvents(t),d=react.useMemo(()=>r?.pages.flatMap(m=>m.items).filter(m=>m!=null)??[],[r]),f=react.useCallback(()=>{u();},[u]),l=react.useCallback(()=>{p();},[p]);return {data:d,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:c??false,fetchMore:f,refetch:l}}var gs=`
|
|
2
2
|
@keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
3
3
|
@media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
|
|
4
4
|
@media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}
|
|
5
5
|
@media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}
|
|
6
|
-
`,
|
|
6
|
+
`,hs={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 $n(e){return {...hs,animationDelay:`${e}ms`}}function Ao({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:gs}),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(su,{index:r},r))})]})}function su({index:e}){let t=e*120,r={...hs,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 au(){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:{...$n(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:{...$n(0),height:36,width:120,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...$n(50),height:36,width:36,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...$n(100),height:36,width:80,borderRadius:10}})]})]})}function ex({count:e=24}){return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsxRuntime.jsx("style",{children:gs}),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(au,{})}),jsxRuntime.jsx("div",{style:{padding:"12px 8px 80px"},children:jsxRuntime.jsx(Ao,{count:e})})]})}var vs=3,vu={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)"}},bu={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Bo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ws={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},xu={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Xr=[{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 bs(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 yu(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Bo,xu];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Bo,ws];let r=t[0]??"",n=t[1]??"",o=bs(r)%Xr.length,i=bs(n)%Xr.length;return i===o&&(i=(i+1)%Xr.length),[Xr[o],Xr[i]]}function xs(e){return e.title_trans||e.title}function ku(e){return e.question_trans||e.question}function Ho(e,t){return e?.label_trans||e?.label||t}function Ps(e){return Ho(e.outcomes?.[0],ku(e))}function Su(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Ns(e){let t=Su(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Cs(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function ys(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function ks(e){let t=e.outcomes?.[1];if(t){let o=t.best_ask??t.price??0;return parseFloat((o*100).toFixed(2)).toString()}let r=e.outcomes?.[0],n=r?.best_ask??r?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function wu(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),o=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),n>0&&i.push(`${n}h`),i.push(`${o}m`),i.join(" ")}var Pu=`
|
|
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 bs({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:i}){let[s,a]=react.useState(null),l=e.markets??[],d=react.useMemo(()=>l.length>2?[...l].sort((h,y)=>(y.outcomes?.[0]?.price??0)-(h.outcomes?.[0]?.price??0)):l,[l]).filter(h=>h.status==="open"),p=d.length===1,f=d.slice(0,ls),c=d.length-ls,m=react.useMemo(()=>utils$1.formatAmountInUsd(e.volume??0),[e.volume]),g=s?d.find(h=>h.slug===s)??null:null,v=!!g||p,b=()=>{v||o?.(e);},x=h=>{h.stopPropagation(),g&&(h.preventDefault(),a(null));},w=h=>{h.stopPropagation(),t||(h.preventDefault(),o?.(e));},S=p?jsxRuntime.jsx(ku,{event:e,formattedVolume:m,href:t,LinkComponent:r,onSelect:o}):g?jsxRuntime.jsx(wu,{onCollapse:()=>a(null)}):jsxRuntime.jsx(vu,{moreCount:c,formattedVolume:m,source:e.source,href:t,LinkComponent:r,onShowMore:w});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:v?void 0:"pointer"},onMouseEnter:h=>{let y=h.currentTarget,k=ru[e.source]??nu;y.style.borderColor=k.border,y.style.boxShadow=k.shadow,i?.(e);},onMouseLeave:h=>{let y=h.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:b,children:[jsxRuntime.jsx("style",{children:cu}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsxRuntime.jsx(du,{event:e,href:t,LinkComponent:r,onClick:x,isExpanded:v}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:p?jsxRuntime.jsx(yu,{market:d[0],event:e,onSelectOutcome:n}):g?jsxRuntime.jsx(Su,{market:g,event:e,onCollapse:()=>a(null),onSelectOutcome:n}):jsxRuntime.jsx(hu,{displayedMarkets:f,onMarketClick:h=>a(h.slug)})})]}),jsxRuntime.jsx(bu,{children:S})]})}function du({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let i=e.start_at?lu(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: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.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:ds(e)}),i&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsxRuntime.jsx(pu,{event:e})]})}function uu(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 pu({event:e}){let t=react.useMemo(()=>uu(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(mu,{},o);case "crypto-short":return jsxRuntime.jsx(fu,{label:r.label,color:r.color},o);case "closed":return jsxRuntime.jsx(gu,{},o)}})})}function mu(){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 fu({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 gu(){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 hu({displayedMarkets:e,onMarketClick:t}){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(r=>{let o=hs(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:n=>{n.stopPropagation(),t(r);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:gs(r)}),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:vs(o)}),jsxRuntime.jsx(xu,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function vu({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-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsxRuntime.jsx(ys,{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," ",s("predict.event.volume"),jsxRuntime.jsx(ks,{source:r})]})]})}function bu({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 ms({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 xs({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:i}=i18n.useTranslation(),[s,a]=o?iu(e):[Ro,fs],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=n==="label"&&l===u?"action":n,p=d==="label"?`${_o(e.outcomes?.[0],"Yes")} ${us(e)}\xA2`:i("predict.market.action.yes",{price:us(e)}),f=d==="label"?`${_o(e.outcomes?.[1],"No")} ${ps(e)}\xA2`:i("predict.market.action.no",{price:ps(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(ms,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"yes");},children:p}),jsxRuntime.jsx(ms,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"no");},children:f})]})}function xu(){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 yu({market:e,event:t,onSelectOutcome:r}){return jsxRuntime.jsx("div",{style:{flex:1},children:jsxRuntime.jsx(xs,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function ku({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-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(ys,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsxRuntime.jsx(ks,{source:e.source})]})]})}function Su({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let n=hs(e);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:gs(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:vs(n)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{style:{marginTop:12},children:jsxRuntime.jsx(xs,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]})}function wu({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(Pu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsxRuntime.jsx("div",{})]})}function ys({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 Pu({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 ks({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.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Eu=8;function ws({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:o,onSelect:n,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:l}){let{t:u}=i18n.useTranslation(),d=react.useRef(null);react.useEffect(()=>{let c=d.current;if(!c)return;let m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&o?.();},{rootMargin:"300px"});return m.observe(c),()=>m.disconnect()},[t,r,o]);let p=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:`
|
|
30
|
+
`;function Ms({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[s,a]=react.useState(null),c=e.markets??[],p=react.useMemo(()=>c.length>2?[...c].sort((x,y)=>(y.outcomes?.[0]?.price??0)-(x.outcomes?.[0]?.price??0)):c,[c]).filter(x=>x.status==="open"),d=p.length===1,f=p.slice(0,vs),l=p.length-vs,m=react.useMemo(()=>utils$1.formatAmountInUsd(e.volume??0),[e.volume]),g=s?p.find(x=>x.slug===s)??null:null,h=!!g||d,v=()=>{h||n?.(e);},b=x=>{x.stopPropagation(),g&&(x.preventDefault(),a(null));},N=x=>{x.stopPropagation(),t||(x.preventDefault(),n?.(e));},k=d?jsxRuntime.jsx(Au,{event:e,formattedVolume:m,href:t,LinkComponent:r,onSelect:n}):g?jsxRuntime.jsx(Bu,{onCollapse:()=>a(null)}):jsxRuntime.jsx(_u,{moreCount:l,formattedVolume:m,source:e.source,href:t,LinkComponent:r,onShowMore:N});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:x=>{let y=x.currentTarget,P=vu[e.source]??bu;y.style.borderColor=P.border,y.style.boxShadow=P.shadow,i?.(e);},onMouseLeave:x=>{let y=x.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:v,children:[jsxRuntime.jsx("style",{children:Pu}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsxRuntime.jsx(Nu,{event:e,href:t,LinkComponent:r,onClick:b,isExpanded:h}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:d?jsxRuntime.jsx(Du,{market:p[0],event:e,onSelectOutcome:o}):g?jsxRuntime.jsx(Fu,{market:g,event:e,onCollapse:()=>a(null),onSelectOutcome:o}):jsxRuntime.jsx(Ru,{displayedMarkets:f,onMarketClick:x=>a(x.slug)})})]}),jsxRuntime.jsx(Iu,{children:k})]})}function Nu({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?wu(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:n,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:xs(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),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-slate-200 line-clamp-2 lg:text-base",o&&"group-hover/header:text-neutral-400"),children:xs(e)}),i&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsxRuntime.jsx(Mu,{event:e})]})}function Cu(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(o>0&&o<=s){let a=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:a});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Mu({event:e}){let t=react.useMemo(()=>Cu(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(Tu,{},n);case "crypto-short":return jsxRuntime.jsx(Eu,{label:r.label,color:r.color},n);case "closed":return jsxRuntime.jsx(Lu,{},n)}})})}function Tu(){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 Eu({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 Lu(){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 Ru({displayedMarkets:e,onMarketClick:t}){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(r=>{let n=Ns(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:o=>{o.stopPropagation(),t(r);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:Ps(r)}),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:Cs(n)}),jsxRuntime.jsx(Ou,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function _u({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e>0?jsxRuntime.jsxs(ui.Linkable,{href:n,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[s("predict.event.showMore"),jsxRuntime.jsx(Es,{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," ",s("predict.event.volume"),jsxRuntime.jsx(Ls,{source:r})]})]})}function Iu({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 Ss({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:a=>{let c=a.currentTarget;c.style.setProperty("--shadow-offset","2px"),c.style.transform="translateY(2px)";},onMouseLeave:a=>{let c=a.currentTarget;c.style.setProperty("--shadow-offset","4px"),c.style.transform="translateY(0px)";},onClick:n,children:o})}function Ts({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=i18n.useTranslation(),[s,a]=n?yu(e):[Bo,ws],c=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",p=o==="label"&&c===u?"action":o,d=p==="label"?`${Ho(e.outcomes?.[0],"Yes")} ${ys(e)}\xA2`:i("predict.market.action.yes",{price:ys(e)}),f=p==="label"?`${Ho(e.outcomes?.[1],"No")} ${ks(e)}\xA2`:i("predict.market.action.no",{price:ks(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Ss,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:l=>{l.stopPropagation(),r?.(t,e,"yes");},children:d}),jsxRuntime.jsx(Ss,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:l=>{l.stopPropagation(),r?.(t,e,"no");},children:f})]})}function Ou(){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 Du({market:e,event:t,onSelectOutcome:r}){return jsxRuntime.jsx("div",{style:{flex:1},children:jsxRuntime.jsx(Ts,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function Au({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ui.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:a=>{a.stopPropagation(),r||(a.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(Es,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsxRuntime.jsx(Ls,{source:e.source})]})]})}function Fu({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Ns(e);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:Ps(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:Cs(o)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{style:{marginTop:12},children:jsxRuntime.jsx(Ts,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function Bu({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(Hu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsxRuntime.jsx("div",{})]})}function Es({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 Hu({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 Ls({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.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var $u=8;function _s({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:s,LinkComponent:a,onHover:c}){let{t:u}=i18n.useTranslation(),p=react.useRef(null);react.useEffect(()=>{let l=p.current;if(!l)return;let m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return m.observe(l),()=>m.disconnect()},[t,r,n]);let d=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((
|
|
36
|
+
`}),jsxRuntime.jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((l,m)=>l==null?null:jsxRuntime.jsx("div",{style:{padding:$u,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${m%4*35}ms both`},children:jsxRuntime.jsx(Ms,{event:l,href:s?.(l),LinkComponent:a,onSelect:o,onSelectOutcome:i,onHover:c})},`${l.source}-${l.slug}`))}),jsxRuntime.jsx("div",{ref:p,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"})}),u("predict.events.loadMore")]})}),f&&jsxRuntime.jsx(Ku,{onScrollToTop:d})]})}function Ku({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 Os({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:a,minVolume:c,minLiquidity:u,markets_limit:p,onSelect:d,onSelectOutcome:f,getEventHref:l,LinkComponent:m,onHover:g}){let{data:h,hasMore:v,fetchMore:b,isFetching:N,isFetchingMore:k}=fs({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:s,timeRemaining:a,minVolume:c,minLiquidity:u,markets_limit:p});return N?jsxRuntime.jsx(Ao,{count:24}):jsxRuntime.jsx(_s,{events:h,hasMore:v,isFetchingMore:k,onFetchMore:b,onSelect:d,onSelectOutcome:f,getEventHref:l,LinkComponent:m,onHover:g})}function Tx({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:s,enableKalshi:a=true}){let[c,u]=react.useState({categorySlug:null,tagSlug:null}),[p,d]=react.useState(()=>a?Qr:{...Qr,source:"polymarket"}),{isOpen:f,onOpen:l,onClose:m}=ui.useDisclosure(),{onOpen:g}=uiScaffold.useAsyncModal(Yr),h=react.useCallback((S,R,I)=>{t?.(S,R,I),g({params:{event:S,market:R,initialOutcome:I,onInsufficientBalance:s}});},[t,g,s]),v=react.useCallback(S=>{u(S);},[]),b=react.useCallback(S=>{d(R=>({...R,sortPreset:S}));},[]),N=react.useCallback(S=>{d(R=>({...R,sortAsc:S}));},[]),k=react.useCallback(S=>{d(S);},[]),x=react.useMemo(()=>ds[p.sortPreset].sort_by,[p.sortPreset]),y=react.useMemo(()=>Do(p,a),[p,a]),P=react.useMemo(()=>jsxRuntime.jsx(us,{sortPreset:p.sortPreset,onSortChange:b,sortAsc:p.sortAsc,onSortAscChange:N,onFilterPress:l,filterCount:y}),[p.sortPreset,p.sortAsc,y,b,N,l]);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(Ai,{onSelect:v,trailing:P})}),jsxRuntime.jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsxRuntime.jsx(is,{isOpen:f,onClose:m,value:p,onChange:k,enableKalshi:a}),jsxRuntime.jsx(Os,{tagSlugSelection:c,sort_by:x,sort_asc:p.sortAsc,source:p.source,timeRemaining:p.timeRemaining,minVolume:p.minVolume,minLiquidity:p.minLiquidity,onSelect:e,onSelectOutcome:h,getEventHref:r,LinkComponent:n,onHover:o})]}),jsxRuntime.jsx(Hn,{})]})}function Bs(e){return utils$1.formatAmountInUsd(e)}var Yu=[{key:"total_events",labelKey:"predict.events.stats.totalEvents",format:e=>utils$1.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:Bs,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:Bs,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$1.formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function Ix({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)}}
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
.evt-stat-label{font-size:11px;line-height:16px;min-height:16px;white-space:nowrap}
|
|
72
72
|
@media(min-width:640px){.evt-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
73
73
|
`}),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,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:Ou.map((r,o)=>jsxRuntime.jsxs("div",{style:{padding:"14px 16px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"evtStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[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:`${o*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+o*80}ms`}})})]},r.key))})]})]})}function Os({event:e,market:t,position:r,onSuccess:o,onCancel:n}){let{t:i}=i18n.useTranslation(),{mutateAsync:s}=reactPredict.useRedeemPosition(),{evmAddress:a}=pr(),l=walletConnector.useWallets(),[u,d]=react.useState("idle"),[p,f]=react.useState(null),c=t.provider_meta?.["polymarket.conditionId"],m=t.provider_meta?.["polymarket.negRisk"]??false,g=a??"",v=react.useMemo(()=>l.find(A=>A.chainNamespace===types.ChainNamespace.EVM&&A.isConnected),[l]),b=Is(r.side,t.outcomes),w=t.outcomes?.[b]?.label??r.side,S=t.result!=null?Is(t.result,t.outcomes):-1,y=(S>=0?t.outcomes?.[S]:void 0)?.label??t.result??"",k=t.result!=null?b===S:true,P=react.useMemo(()=>k?r.size:0,[k,r.size]),O=react.useCallback(async()=>{if(!(!c||!g||!v)){d("pending"),f(null);try{let A=await v.getEip1193Provider();if(!A)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:g,condition_id:c,neg_risk:m,signMessage:async G=>await A.request({method:"personal_sign",params:[G,g]}),signTypedData:async G=>await A.request({method:"eth_signTypedData_v4",params:[g,JSON.stringify(G)]})}),d("success"),o?.();}catch(A){d("error"),f(A instanceof Error?A.message:i("predict.redeem.error"));}}},[c,g,m,v,s,o,i]),F=walletConnector.useAuthCallback(O),W=u==="idle"&&!!c&&!!g&&!!v&&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(Hn,{label:i("predict.positions.side"),value:w,valueClassName:k?"text-green-400":"text-red-400"}),t.result!=null&&jsxRuntime.jsx(Hn,{label:i("predict.redeem.result"),value:y,valueClassName:"text-green-400"}),jsxRuntime.jsx(Hn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsxRuntime.jsx(Hn,{label:i("predict.redeem.expectedPayout"),value:`$${P.toFixed(2)}`,valueClassName:P>0?"text-green-400":"text-zinc-400"})]}),!k&&P===0&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),u==="error"&&p&&jsxRuntime.jsx("p",{className:"text-sm text-red-400",children:p}),u==="success"&&jsxRuntime.jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[u!=="success"&&jsxRuntime.jsx(ui.Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!W,isLoading:u==="pending",onPress:F,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),n&&u!=="success"&&jsxRuntime.jsx("button",{type:"button",onClick:n,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),u==="success"&&n&&jsxRuntime.jsx(ui.Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:n,children:i("common.ok")})]})]})}function Hn({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 Is(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 Gu="predict-redeem";function Ds({id:e=Gu}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Yu,{...t})})}function Yu({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:"!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.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-white",children:o("predict.redeem.title")}),jsxRuntime.jsx("p",{className:"text-sm text-zinc-400 mt-1",children:o("predict.redeem.description")})]}),jsxRuntime.jsx(Os,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Hs({market:e,initialOutcome:t="yes",slippageBps:r=100,onSuccess:o}){let{t:n}=i18n.useTranslation(),i=react.useRef(o);i.current=o;let{status:s}=walletConnector.useAuth(),a=walletConnector.useWallets(),l=reactPredict.usePredictClient(),u=react.useContext(reactPredict.PolymarketContext),d=reactQuery.useQueryClient(),p=e.source,f=p==="polymarket",c=a.find(M=>M.chainNamespace===types.ChainNamespace.SOLANA&&M.isConnected),m=a.find(M=>M.chainNamespace===types.ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),g=s==="authenticated",v=c?.address,b=m?.address,[x,w]=react.useState(t),[S,h]=react.useState("market"),[y,k]=react.useState(NaN),[P,O]=react.useState(NaN),[F,W]=react.useState(false),[A,G]=react.useState(false),[q,Y]=react.useState(null),[re,te]=react.useState(null),[N,C]=react.useState(false),[U,X]=react.useState(false),[se,_]=react.useState("1h"),[Se,B]=react.useState(30),[Pe,yt]=react.useState("minutes"),Le=react.useMemo(()=>{if(p!=="polymarket")return;let M=e.provider_meta?.["polymarket.clobTokenIds"];return M?(typeof M=="string"?JSON.parse(M):M)[x==="yes"?0:1]:void 0},[p,e.provider_meta,x]),{data:rt,isLoading:nt}=reactPredict.useTickSize(Le),he=rt?.minimum_tick_size?String(rt.minimum_tick_size):"0.01",{data:je,isLoading:Qe}=reactPredict.useFeeRate(Le),Re=String(je?.base_fee??0),{data:dt}=reactPredict.useRebateConfig(),Nt=dt?.builder_enabled&&dt.builder_code?dt.builder_code:void 0,Xe=false,Je=null,Be=false,we,ut,Ze;try{let M=pr();Xe=M.kalshiKycVerified,Je=M.kalshiKycUrl,Be=M.polymarketSetupVerified,we=M.polymarketSafeAddress,ut=M.polymarketWalletKind,Ze=M.polymarketWalletAddress;}catch{}let _t=p==="kalshi"&&!Xe,E=p==="polymarket"&&!Be,de=react.useCallback(async()=>{if(!m||!u)return null;let M=await m.getEip1193Provider();if(!M)return null;let Ne=ut==="deposit"&&!!Ze,$e=!Ne&&!!we,st={address:m.address,signatureType:Ne?3:$e?2:0,signTypedData:async(Ge,Et,St,Ee)=>{let wt=[];"name"in Ge&&wt.push({name:"name",type:"string"}),"version"in Ge&&wt.push({name:"version",type:"string"}),"chainId"in Ge&&wt.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ge&&wt.push({name:"verifyingContract",type:"address"}),"salt"in Ge&&wt.push({name:"salt",type:"bytes32"});let at={EIP712Domain:wt,...Et};return await M.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Ge,types:at,primaryType:St,message:Ee})]})}};return u.credentials??await u.authenticate(st)},[we,ut,Ze,m,u]),{data:He}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:p,outcome:x},{enabled:e.status==="open"}),qe=react.useMemo(()=>{let M=reactPredict.pickBestBid(He,x);if(M!=null&&M>0)return M;let Ne=x==="yes"?0:1,$e=e.outcomes[Ne];return $e?.best_bid??$e?.price??.5},[He,e.outcomes,x]),ze=p==="kalshi"?v??"":b??"",{data:Zt,isLoading:er}=reactPredict.usePositions({source:p,user:ze},{enabled:!!ze,refetchInterval:3e4}),Wr=react.useCallback(async()=>{let M=await de();return M?await reactPredict.buildPolymarketL2Headers(M.address,{apiKey:M.apiKey,secret:M.secret,passphrase:M.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[de]),{data:ot,isLoading:Ur}=reactPredict.useAvailableShares({source:p,user:ze,market:e.slug,side:x},p==="polymarket"?{getHeaders:Wr}:void 0,{enabled:!!ze&&!!e.slug,refetchOnMount:"always"}),D=ot?.total_shares??0,be=ot?.active_order_shares??0,Ae=ot?.available_shares??0,et=react.useMemo(()=>p==="polymarket"?reactPredict.getPolymarketSharesPrecision(he):ot?.precision??0,[p,he,ot?.precision]),$r=Ur||er,co=e.provider_meta?.["dflow.yesMint"]??"",uo=e.provider_meta?.["dflow.noMint"]??"",Wt=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,Nr=e.provider_meta?.["dflow.collateralMint"]||"",po=x==="yes"?co:uo,Kr=react.useMemo(()=>Zt?Zt.positions.find(M=>M.side?.toLowerCase()===x&&M.market?.slug===e.slug)??null:null,[Zt,e.slug,x])?.market?.provider_meta,Ut=Kr?.["dflow.outcomeMint"]||po,rr=Kr?.["dflow.collateralMint"]||Nr,nr=Ut,or=rr||Wt,Cr=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),mo=p==="kalshi"&&!!nr&&!!or&&!!v&&Cr!=="0",{refetch:hn}=reactPredict.useDFlowQuote({inputMint:nr,outputMint:or,amount:Cr,userPublicKey:v??"",slippageBps:100},{enabled:mo}),ir=react.useMemo(()=>isNaN(y)||y<=0?0:y,[y]),it=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:He,outcome:x,side:"sell",sharesNeeded:ir,slippageBps:r}),[He,x,ir,r]),vn=react.useMemo(()=>it.status==="ok"&&it.worstPrice!=null&&it.worstPrice>0?it.worstPrice:qe,[it,qe]),fo=react.useMemo(()=>{if(isNaN(y)||y<=0)return 0;let M=S==="limit"&&f&&!isNaN(P)?P:qe;return y*M},[y,S,f,P,qe]),Mr=react.useCallback(M=>{w(M),O(NaN),k(NaN),G(false);},[]);react.useEffect(()=>{Mr(t);},[t,Mr]);let Vr=react.useCallback(M=>{h(M);},[]);react.useEffect(()=>{S==="limit"&&O(Math.round(qe*1e4)/1e4);},[S,x]);let bn=react.useCallback(M=>{if(G(false),isNaN(M)){k(NaN);return}k(ve(Math.max(0,M),et));},[et]),xn=react.useCallback(()=>{G(true),k(ve(Ae,et));},[Ae,et]),go=react.useCallback(M=>{if(isNaN(M)){O(NaN);return}O(Math.round(M*1e4)/1e4);},[]),L=react.useCallback(()=>{k(NaN),O(NaN),h("market"),G(false),X(false),_("1h"),B(30),yt("minutes");},[]),We=react.useMemo(()=>{let M=[];return isNaN(y)||y<=0?M.push(n("predict.trade.minQuantity",{amount:Cn})):y<Cn&&M.push(n("predict.trade.minQuantity",{amount:Cn})),e.status!=="open"&&M.push(n("predict.trade.marketNotActive")),!isNaN(y)&&y>0&&!A&&y>Ae&&M.push(n("predict.trade.insufficientSharesDetail",{total:ve(D,et).toFixed(et),active:ve(be,et).toFixed(et),available:ve(Ae,et).toFixed(et)})),S==="limit"&&f&&(isNaN(P)||P<.01||P>.99)&&M.push(n("predict.trade.limitPriceRange")),S==="limit"&&f&&U&&se==="custom"&&(isNaN(Se)||Se<=0)&&M.push(n("predict.trade.expiration.invalidDate")),p==="polymarket"&&S==="market"&&!isNaN(y)&&y>0&&(it.status==="insufficient_liquidity"?M.push(n("predict.trade.insufficientLiquidity",{available:ve(it.totalAvailable,2)})):it.status==="exceeds_slippage"&&M.push(n("predict.trade.priceImpactTooHigh",{impact:(it.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:M.length===0,errors:M}},[y,e.status,Ae,D,be,A,S,f,P,U,se,Se,et,p,it,r,n]),{mutateAsync:Ue}=reactPredict.useDFlowSubmit(),{data:Ct}=reactPredict.useOrder({id:q??"",source:p},{enabled:!!q}),Er=react.useCallback(async()=>{if(!re||!v||!c)return;let{cashAmount:M,collateral:Ne}=re;te(null);try{let st=(await l.createDFlowQuote({inputMint:Ne,outputMint:Wt,amount:M,userPublicKey:v,slippageBps:100}))?.transaction;if(!st)return;let Ge=Uint8Array.from(atob(st),St=>St.charCodeAt(0)),Et=await c.signTransaction(Ge);await Ue({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:v,input_mint:Ne,output_mint:Wt,amount:M,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[re,v,c,l,Ue,Wt]),Mt=react.useCallback(()=>{d.invalidateQueries({queryKey:["predict","positions"]}),d.invalidateQueries({queryKey:["predict","orders"]}),d.invalidateQueries({queryKey:["predict","available-shares"]});},[d]);react.useEffect(()=>{if(!Ct||!q)return;let{status:M}=Ct;M==="closed"?(Y(null),re?Er().finally(()=>{W(false),ui.toast.success(n("predict.trade.submitSuccess")),mr(),Mt(),L(),i.current?.();}):(W(false),ui.toast.success(n("predict.trade.submitSuccess")),mr(),Mt(),L(),i.current?.())):(M==="failed"||M==="expired")&&(W(false),Y(null),te(null),ui.toast.error(n("predict.trade.submitError")));},[Ct,q,re,Er,Mt,L,n]);let It=react.useCallback(async()=>{if(!v||!c)return;if(!nr||!or){ui.toast.error("Missing token mint addresses"),W(false);return}if(!Xe){C(true),W(false);return}let $e=(await hn()).data,st=$e?.transaction;if(!st){ui.toast.error(n("predict.trade.submitError")),W(false);return}if(rr&&rr!==Wt){let Ee=String($e?.outAmount??"");Ee&&Ee!=="0"&&te({cashAmount:Ee,collateral:rr});}let Ge=Uint8Array.from(atob(st),Ee=>Ee.charCodeAt(0)),Et=await c.signTransaction(Ge),St=await Ue({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:v,input_mint:nr,output_mint:or,amount:Cr,price:String(qe),side:"SELL",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Y(St.signature);},[v,c,hn,Ue,nr,or,Cr,qe,x,e.slug,rr,Wt,n,Xe]),kt=react.useCallback(async()=>{if(!m||!u)return;let M=m.chain,Ne=M!==types.Chain.POLYGON;Ne&&await m.switchChain(types.Chain.POLYGON);try{let $e=await m.getEip1193Provider();if(!$e){ui.toast.error(n("predict.trade.submitError")),W(!1);return}let st=ut==="deposit"&&!!Ze,Ge=!st&&!!we,Et=st?Ze:we,St={address:m.address,signatureType:st?3:Ge?2:0,signTypedData:async(Kt,yn,xo,yo)=>{let Lr=[];"name"in Kt&&Lr.push({name:"name",type:"string"}),"version"in Kt&&Lr.push({name:"version",type:"string"}),"chainId"in Kt&&Lr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Kt&&Lr.push({name:"verifyingContract",type:"address"}),"salt"in Kt&&Lr.push({name:"salt",type:"bytes32"});let ic={EIP712Domain:Lr,...yn};return await $e.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:Kt,types:ic,primaryType:xo,message:yo})]})}},Ee=await de();if(!Ee){ui.toast.error(n("predict.trade.submitError")),W(!1);return}let wt=x==="yes"?0:1,at="",$t=e.provider_meta?.["polymarket.clobTokenIds"];$t&&(at=(typeof $t=="string"?JSON.parse($t):$t)[wt]??"");let Tr=e.provider_meta?.["polymarket.negRisk"]??!1,jr=S==="limit"&&!isNaN(P)?P:vn,sr=Tn(jr,he),vo={tokenId:at,price:sr,size:y,side:"SELL",orderType:S==="limit"?U?"GTD":"GTC":"FOK",tickSize:he,negRisk:Tr,...Et&&{funderAddress:Et},...Nt&&{builderCode:Nt},...S==="limit"&&U&&{expiration:En(se,Se,Pe)}},bo;if(st)bo=await reactPredict.buildSignedV2OrderPayload({signer:St,depositWalletAddress:Et,input:vo,owner:Ee.apiKey});else {let Kt=reactPredict.buildCtfExchangeDomain(Tr),yn=reactPredict.buildOrderMessage({...vo,signerAddress:St.address,signatureType:St.signatureType,feeRateBps:Re}),xo=await St.signTypedData(Kt,reactPredict.CTF_ORDER_TYPES,"Order",yn),yo=reactPredict.buildSignedOrder(yn,xo,vo.orderType);bo=reactPredict.buildClobPayload(yo,Ee.apiKey);}await l.executePolymarketOrder({payload:bo,l2_api_key:Ee.apiKey,l2_secret:Ee.secret,l2_passphrase:Ee.passphrase,signer_address:Ee.address,owner:Ee.apiKey}),Mt(),ui.toast.success(n("predict.trade.submitSuccess")),mr(),L(),W(!1),i.current?.();}finally{Ne&&M&&m.switchChain(M).catch(()=>{});}},[m,u,de,x,e.provider_meta,S,P,vn,y,l,Mt,U,se,Se,Pe,L,n,he,Re,e.slug,we,ut,Ze,Nt]),ho=react.useCallback(async()=>{if(!(!We.isValid||!g)){W(true),Y(null),C(false);try{p==="kalshi"?await It():await kt();}catch(M){let Ne=M instanceof Error?M.message:"",$e=p==="polymarket"&&Ne?Ln(Ne,n,"sell"):Ne||void 0;ui.toast.error($e||n("predict.trade.submitError")),W(false);}}},[We.isValid,g,p,It,kt,n]);return {outcome:x,orderType:S,quantity:y,limitPrice:P,shares:ir,estimatedReturn:fo,pricePerShare:qe,isMarketDataLoading:p==="polymarket"&&(Qe||nt),isSubmitting:F,authStatus:s,validation:We,supportsLimitOrder:f,kycRequired:N,needsKyc:_t,needsSetup:E,kycUrl:Je,totalShares:D,activeOrderShares:be,availableShares:Ae,isAvailableLoading:$r,isSellAll:A,precision:et,expirationEnabled:U,expirationPreset:se,customDuration:Se,customDurationUnit:Pe,setOutcome:Mr,setOrderType:Vr,setQuantity:bn,setLimitPrice:go,setSellAll:xn,setExpirationEnabled:X,setExpirationPreset:_,setCustomDuration:B,setCustomDurationUnit:yt,submit:ho}}var Rp=["5m","1h","12h","24h","eod","custom"],_p={"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"},Ip=["minutes","hours","days"],Op={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Ap={maximumFractionDigits:0};function Gs({event:e,market:t,variant:r="bordered",outcome:o,orderType:n,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:l,isSubmitting:u,authStatus:d,isValid:p,validationErrors:f,supportsLimitOrder:c,kycRequired:m,needsKyc:g,needsSetup:v,onSetupRequired:b,kycUrl:x,totalShares:w,activeOrderShares:S,availableShares:h,isAvailableLoading:y,precision:k,expirationEnabled:P,expirationPreset:O,customDuration:F,customDurationUnit:W,oddsFormatter:A,onOutcomeChange:G,onOrderTypeChange:q,onQuantityChange:Y,onLimitPriceChange:re,onSellAll:te,onExpirationEnabledChange:N,onExpirationPresetChange:C,onCustomDurationChange:U,onCustomDurationUnitChange:X,onSubmit:se}){let{t:_}=i18n.useTranslation(),[Se,B]=react.useState(false),Pe=ui.useDisclosure(),[yt,Le]=react.useState(""),rt=react.useRef(false);react.useEffect(()=>{rt.current||Le(isNaN(i)?"":String(i));},[i]);let[nt,he]=react.useState(""),je=react.useRef(false);react.useEffect(()=>{je.current||(isNaN(s)?he(""):he(String(parseFloat((s*100).toFixed(2)))));},[s]);let Qe=react.useCallback(E=>{if(E!==""&&!/^\d*\.?\d{0,2}$/.test(E))return;if(he(E),E===""||E==="."){re(NaN);return}let He=parseFloat(E);isNaN(He)||re(He/100);},[re]),Re=react.useCallback(E=>{let de=new RegExp(`^\\d*\\.?\\d{0,${k}}$`);if(E!==""&&!de.test(E))return;if(Le(E),B(false),E===""||E==="."){Y(NaN);return}let He=parseFloat(E);isNaN(He)||Y(He);},[Y,k]);react.useEffect(()=>{m&&!Pe.isOpen&&Pe.onOpen();},[m]);let dt=react.useMemo(()=>{let E=o==="yes"?t.yesBid:t.noBid;return E!=null?parseFloat((Number(E)*100).toFixed(2)):null},[o,t]),Nt=o==="yes"?t.yesBid:t.noBid,Xe=Nt!=null&&A?A(Number(Nt)):dt!=null?`${dt} \xA2`:null,Je=!isNaN(i)&&i>0,Be=d==="authenticated",we=d==="authenticating"||d==="deauthenticating",ut=Be&&(g||v),Ze=react.useMemo(()=>{if(we)return _("predict.trade.checkingLogin");if(!Be)return _("predict.trade.loginToTrade");if(g)return _("predict.trade.kycRequired");if(v)return _("predict.trade.setupRequired");if(y)return _("predict.trade.loadingBalance");if(l)return _("predict.trade.loadingMarketData");if(u)return _("predict.trade.submitting");if(m)return _("predict.trade.kycRequired");if(!Je)return _("predict.trade.enterAmount");let E=_(o==="yes"?"predict.trade.yes":"predict.trade.no");return `${_("predict.trade.sell")} ${E}`},[we,Be,g,v,y,l,u,m,Je,o,_]),_t=()=>{if(!Be){B(false),se();return}if(g){Pe.onOpen();return}if(v&&b){B(false),b();return}if(m){Pe.onOpen();return}if(!p){B(true);return}B(false),se();};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:E=>{r==="bordered"&&(E.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:E=>{r==="bordered"&&(E.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:"text-bearish",children:[_("predict.trade.sell")," ",_(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[c?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:E=>q(E),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:_("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:_("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:_("predict.trade.market")}),n==="limit"&&c?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:nt,onChange:E=>Qe(E.target.value),onFocus:()=>{je.current=true;},onBlur:()=>{je.current=false,isNaN(s)?he(""):he(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"}}):Xe!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:Xe})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(E=>{let de=E==="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:()=>G(E),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===E?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:_(E==="yes"?"predict.trade.yes":"predict.trade.no")}),de!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:A?A(Number(de)):`${parseFloat((Number(de)*100).toFixed(2))}\xA2`})]})},E)})}),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:_("predict.trade.sellContracts")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(E=>{let de=Math.pow(10,k);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{Y(Math.floor(h*E/100*de)/de);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[E,"%"]},E)}),jsxRuntime.jsx("button",{type:"button",onClick:te,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:_("common.all")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:yt,onChange:E=>Re(E.target.value),onFocus:()=>{rt.current=true;},onBlur:()=>{rt.current=false,Le(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Se&&f.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:f.map(E=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:E},E))})]}),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:_("predict.trade.totalShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:y?"\u2013":`${ve(w,k).toFixed(k)}${_("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:_("predict.trade.activeOrders")}),jsxRuntime.jsx("span",{className:"tabular-nums text-warning",children:y?"\u2013":S>0?`-${ve(S,k).toFixed(k)}${_("predict.trade.sharesUnit")}`:`0${_("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:_("predict.trade.availableShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-success font-medium",children:y?"\u2013":`${ve(h,k).toFixed(k)}${_("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:_("predict.trade.estReturn")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),n==="limit"&&c&&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:_("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:P,onValueChange:N,"aria-label":_("predict.trade.setExpiration")})]}),P&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":_("predict.trade.setExpiration"),selectedKeys:[O],onSelectionChange:E=>{let de=Array.from(E)[0];de&&C(de);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Rp.map(E=>jsxRuntime.jsx(ui.SelectItem,{children:_(_p[E])},E))}),O==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(F)?void 0:F,onValueChange:U,minValue:1,step:1,formatOptions:Ap,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":"Duration unit",selectedKeys:[W],onSelectionChange:E=>{let de=Array.from(E)[0];de&&X(de);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Ip.map(E=>jsxRuntime.jsx(ui.SelectItem,{children:_(Op[E])},E))})]})]})]}),jsxRuntime.jsx(ui.Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:we||Be&&!ut&&(y||l||!Je||u),isLoading:we||Be&&!ut&&(u||y||l),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:_t,children:Ze})]}),jsxRuntime.jsx(Rn,{isOpen:Pe.isOpen,onClose:Pe.onClose,kycUrl:x})]})}function Wn({event:e,market:t,variant:r,initialOutcome:o,chain:n,slippageBps:i,onOutcomeChange:s,onSetupRequired:a,onSuccess:l,oddsFormatter:u}){let{outcome:d,orderType:p,quantity:f,limitPrice:c,estimatedReturn:m,pricePerShare:g,isMarketDataLoading:v,isSubmitting:b,authStatus:x,validation:w,supportsLimitOrder:S,kycRequired:h,needsKyc:y,needsSetup:k,kycUrl:P,totalShares:O,activeOrderShares:F,availableShares:W,isAvailableLoading:A,precision:G,expirationEnabled:q,expirationPreset:Y,customDuration:re,customDurationUnit:te,setOutcome:N,setOrderType:C,setQuantity:U,setLimitPrice:X,setSellAll:se,setExpirationEnabled:_,setExpirationPreset:Se,setCustomDuration:B,setCustomDurationUnit:Pe,submit:yt}=Hs({market:t,initialOutcome:o,slippageBps:i,onSuccess:l}),Le=walletConnector.useAuthCallback(yt),rt=react.useCallback(je=>{N(je),s?.(je);},[N,s]),nt=react.useMemo(()=>e?Sn(e):void 0,[e]),he=react.useMemo(()=>wn(t,{yesBid:d==="yes"?g:void 0,noBid:d==="no"?g:void 0}),[t,d,g]);return jsxRuntime.jsx(Gs,{event:nt,market:he,variant:r,outcome:d,orderType:p,quantity:f,limitPrice:c,estimatedReturn:m,isMarketDataLoading:v,isSubmitting:b,authStatus:x,isValid:w.isValid,validationErrors:w.errors,supportsLimitOrder:S,kycRequired:h,needsKyc:y,needsSetup:k,onSetupRequired:a,kycUrl:P,totalShares:O,activeOrderShares:F,availableShares:W,isAvailableLoading:A,precision:G,expirationEnabled:q,expirationPreset:Y,customDuration:re,customDurationUnit:te,oddsFormatter:u,onOutcomeChange:rt,onOrderTypeChange:C,onQuantityChange:U,onLimitPriceChange:X,onSellAll:se,onExpirationEnabledChange:_,onExpirationPresetChange:Se,onCustomDurationChange:B,onCustomDurationUnitChange:Pe,onSubmit:Le})}var Ho="predict-sell";function Qs({id:e=Ho}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Kp,{...t})})}function Kp({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:"!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.ModalContent,{children:jsxRuntime.jsxs("div",{className:n?"":"p-2",children:[jsxRuntime.jsx(Wn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,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:o("common.cancel")})})]})})}):null}var Uo=40,Kn=36,rn=480,$o=rn-Kn;function Zs({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=i18n.useTranslation(),[n,i]=react.useState("positions"),s=react.useMemo(()=>e.markets?.map(p=>p.slug)??[],[e.markets]),{data:a}=reactPredict.usePositions({source:e.source,user:t??""}),l=react.useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(p=>p.market&&s.includes(p.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(p=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(p.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===p.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:p.label},p.key))}),t?jsxRuntime.jsxs("div",{style:{height:rn},children:[n==="positions"&&jsxRuntime.jsx(Xp,{source:e.source,walletAddress:t,marketSlugs:s}),n==="orders"&&jsxRuntime.jsx(Zp,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),n==="trades"&&jsxRuntime.jsx(rm,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:o("predict.trade.connectWallet")})]})}function Xp({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=i18n.useTranslation(),{data:n,isLoading:i}=reactPredict.usePositions({source:e,user:t}),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(Vo,{}):s.length===0?jsxRuntime.jsx(Ko,{message:o("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:Kn},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:$o},rowComponent:Jp,rowCount:s.length,rowHeight:Uo,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function Jp({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,u=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",p=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",f=n.side,c=n.size,m=n.size*l,g=n.market?.end_at?im(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:p}),jsxRuntime.jsx("span",{className:ui.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:n.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:Un(a)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:Un(l)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),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:["$",c.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),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:o})})]})}function Zp({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}),u=reactPredict.useCancelOrder(),d=react.useMemo(()=>{let b=i?.pages?.flatMap(S=>S.items)??[],x=new Set(["live","open","submitted","pending"]),w=b.filter(S=>x.has(S.status));return r.length>0&&(w=w.filter(S=>S.market_id&&r.includes(S.market_id))),w},[i?.pages,r]),p=react.useCallback(b=>{o?o(b.id):u.mutate({source:b.source,id:b.id});},[o,u]),f=d.length,c=f+(l?1:0),m=react.useCallback(b=>b<f,[f]),g=react.useCallback(async()=>{await a();},[a]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:c,threshold:5});return s?jsxRuntime.jsx(Vo,{}):d.length===0&&!l?jsxRuntime.jsx(Ko,{message:n("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:Kn},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:$o},onRowsRendered:v,rowComponent:em,rowCount:c,rowHeight:Uo,rowProps:{orders:d,itemCount:f,onCancel:p,isCancelling:u.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function em({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:i,cancelLabel:s}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let l=a.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",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?Un(parseFloat(a.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(tm,{status:a.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>n(a),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):s})})]})}function tm({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-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function rm({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:o,isLoading:n,fetchNextPage:i,hasNextPage:s}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),a=react.useMemo(()=>o?.pages?.flatMap(c=>c.items)??[],[o?.pages]),l=a.length,u=l+(s?1:0),d=react.useCallback(c=>c<l,[l]),p=react.useCallback(async()=>{await i();},[i]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,rowCount:u,threshold:5});return n?jsxRuntime.jsx(Vo,{}):a.length===0&&!s?jsxRuntime.jsx(Ko,{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:Kn},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:$o},onRowsRendered:f,rowComponent:nm,rowCount:u,rowHeight:Uo,rowProps:{trades:a,itemCount:l}})]})}function nm({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=om(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:Un(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-neutral whitespace-nowrap",children:s})]})}function Ko({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:e})}function Vo(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:rn},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function Un(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function om(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),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 im(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var ea=`
|
|
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:Yu.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 Us({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i,i18n:s}=i18n.useTranslation(),{mutateAsync:a}=reactPredict.useRedeemPosition(),{start:c}=reactPredict.useTradeResultConfirmation(),{evmAddress:u}=br(),p=walletConnector.useWallets(),[d,f]=react.useState("idle"),[l,m]=react.useState(null),g=t.provider_meta?.["polymarket.conditionId"],h=t.provider_meta?.["polymarket.negRisk"]??false,v=u??"",b=react.useMemo(()=>Ir(i,s),[s,i]),N=react.useMemo(()=>p.find(Y=>Y.chainNamespace===types.ChainNamespace.EVM&&Y.isConnected),[p]),k=Ws(r.side,t.outcomes),y=t.outcomes?.[k]?.label??r.side,P=t.result!=null?Ws(t.result,t.outcomes):-1,R=(P>=0?t.outcomes?.[P]:void 0)?.label??t.result??"",I=t.result!=null?k===P:true,z=react.useMemo(()=>I?r.size:0,[I,r.size]),K=react.useCallback(async()=>{if(!(!g||!v||!N)){f("pending"),m(null);try{let Y=await N.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await a({wallet_address:v,condition_id:g,neg_risk:h,signMessage:async w=>await Y.request({method:"personal_sign",params:[w,v]}),signTypedData:async w=>await Y.request({method:"eth_signTypedData_v4",params:[v,JSON.stringify(w)]})}),f("confirming");let Q=Or({messages:b});Q.submitted(),await c({source:r.source,user:v,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem"})==="confirmed"?(f("success"),Q.completed()):(f("delayed"),Q.delayed()),n?.();}catch(Y){f("error"),m(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,v,h,N,a,b,c,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,n,i]),W=walletConnector.useAuthCallback(K),G=d==="idle"&&!!g&&!!v&&!!N&&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(Kn,{label:i("predict.positions.side"),value:y,valueClassName:I?"text-green-400":"text-red-400"}),t.result!=null&&jsxRuntime.jsx(Kn,{label:i("predict.redeem.result"),value:R,valueClassName:"text-green-400"}),jsxRuntime.jsx(Kn,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsxRuntime.jsx(Kn,{label:i("predict.redeem.expectedPayout"),value:`$${z.toFixed(2)}`,valueClassName:z>0?"text-green-400":"text-zinc-400"})]}),!I&&z===0&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),d==="error"&&l&&jsxRuntime.jsx("p",{className:"text-sm text-red-400",children:l}),d==="success"&&jsxRuntime.jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),d==="delayed"&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-400",children:i("predict.trade.resultDelayed",{defaultValue:"Your trade was submitted successfully. Confirmation is taking a little longer."})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[d!=="success"&&d!=="delayed"&&jsxRuntime.jsx(ui.Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!G,isLoading:d==="pending"||d==="confirming",onPress:W,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&d!=="success"&&d!=="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:i("common.cancel")}),(d==="success"||d==="delayed")&&o&&jsxRuntime.jsx(ui.Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:i("common.ok")})]})]})}function Kn({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 Ws(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 dp="predict-redeem";function Ks({id:e=dp}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(up,{...t})})}function up({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.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.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(Us,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function Gs({market:e,initialOutcome:t="yes",slippageBps:r=100,onSuccess:n}){let{t:o,i18n:i}=i18n.useTranslation(),s=react.useRef(n);s.current=n;let{status:a}=walletConnector.useAuth(),c=walletConnector.useWallets(),u=reactPredict.usePredictClient(),p=react.useContext(reactPredict.PolymarketContext),d=reactQuery.useQueryClient(),{start:f}=reactPredict.useTradeResultConfirmation(),l=e.source,m=l==="polymarket",g=c.find(C=>C.chainNamespace===types.ChainNamespace.SOLANA&&C.isConnected),h=c.find(C=>C.chainNamespace===types.ChainNamespace.EVM&&C.isConnected&&"switchChain"in C),v=a==="authenticated",b=g?.address,N=h?.address,[k,x]=react.useState(t),[y,P]=react.useState("market"),[S,R]=react.useState(NaN),[I,z]=react.useState(NaN),[K,W]=react.useState(false),[G,Y]=react.useState(false),[Q,re]=react.useState(null),[w,M]=react.useState(null),[$,J]=react.useState(false),[ne,O]=react.useState(false),[Se,A]=react.useState("1h"),[be,pt]=react.useState(30),[Ee,qe]=react.useState("minutes"),st=react.useMemo(()=>Ir(o,i),[i,o]),we=react.useCallback(async(C,Ce)=>{let _e=Or({messages:st});_e.submitted(),await f({source:l,user:l==="kalshi"?b:N,kalshiUser:b,polymarketUser:N,marketSlug:e.slug,eventSlug:e.event_slug,expectation:C,getOrdersHeaders:Ce})==="confirmed"?_e.completed():_e.delayed();},[f,N,e.event_slug,e.slug,l,st,b]),Ze=react.useMemo(()=>{if(l!=="polymarket")return;let C=e.provider_meta?.["polymarket.clobTokenIds"];return C?(typeof C=="string"?JSON.parse(C):C)[k==="yes"?0:1]:void 0},[l,e.provider_meta,k]),{data:et,isLoading:tt}=reactPredict.useTickSize(Ze),at=et?.minimum_tick_size?String(et.minimum_tick_size):"0.01",{data:Ot,isLoading:ze}=reactPredict.useFeeRate(Ze),rt=String(Ot?.base_fee??0),{data:We}=reactPredict.useRebateConfig(),Ue=We?.builder_enabled&&We.builder_code?We.builder_code:void 0,nt=false,mt=null,Mt=false,E,de,Le;try{let C=br();nt=C.kalshiKycVerified,mt=C.kalshiKycUrl,Mt=C.polymarketSetupVerified,E=C.polymarketSafeAddress,de=C.polymarketWalletKind,Le=C.polymarketWalletAddress;}catch{}let Ge=l==="kalshi"&&!nt,Vr=l==="polymarket"&&!Mt,Dt=react.useCallback(async()=>{if(!h||!p)return null;let C=await h.getEip1193Provider();if(!C)return null;let Ce=de==="deposit"&&!!Le,_e=!Ce&&!!E,Ke={address:h.address,signatureType:Ce?3:_e?2:0,signTypedData:async(lt,Et,ct,he)=>{let Oe=[];"name"in lt&&Oe.push({name:"name",type:"string"}),"version"in lt&&Oe.push({name:"version",type:"string"}),"chainId"in lt&&Oe.push({name:"chainId",type:"uint256"}),"verifyingContract"in lt&&Oe.push({name:"verifyingContract",type:"address"}),"salt"in lt&&Oe.push({name:"salt",type:"bytes32"});let Qt={EIP712Domain:Oe,...Et};return await C.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:lt,types:Qt,primaryType:ct,message:he})]})}};return p.credentials??await p.authenticate(Ke)},[E,de,Le,h,p]),{data:Pt}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:l,outcome:k},{enabled:e.status==="open"}),Pe=react.useMemo(()=>{let C=reactPredict.pickBestBid(Pt,k);if(C!=null&&C>0)return C;let Ce=k==="yes"?0:1,_e=e.outcomes[Ce];return _e?.best_bid??_e?.price??.5},[Pt,e.outcomes,k]),ot=l==="kalshi"?b??"":N??"",{data:At,isLoading:F}=reactPredict.usePositionsMulti({kalshi_user:l==="kalshi"?ot:void 0,polymarket_user:l==="polymarket"?ot:void 0},{enabled:!!ot,refetchInterval:3e4}),$e=react.useCallback(async()=>{let C=await Dt();return C?await reactPredict.buildPolymarketL2Headers(C.address,{apiKey:C.apiKey,secret:C.secret,passphrase:C.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Dt]),{data:ft,isLoading:go}=reactPredict.useAvailableShares({source:l,user:ot,market:e.slug,side:k},l==="polymarket"?{getHeaders:$e}:void 0,{enabled:!!ot&&!!e.slug,refetchOnMount:"always"}),qt=ft?.total_shares??0,Gt=ft?.active_order_shares??0,Ft=ft?.available_shares??0,Ye=react.useMemo(()=>l==="polymarket"?reactPredict.getPolymarketSharesPrecision(at):ft?.precision??0,[l,at,ft?.precision]),ho=go||F,vo=e.provider_meta?.["dflow.yesMint"]??"",hn=e.provider_meta?.["dflow.noMint"]??"",Tt=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,bo=e.provider_meta?.["dflow.collateralMint"]||"",Yt=k==="yes"?vo:hn,Bt=react.useMemo(()=>At?At.positions.find(C=>C.side?.toLowerCase()===k&&C.market?.slug===e.slug)??null:null,[At,e.slug,k])?.market?.provider_meta,vn=Bt?.["dflow.outcomeMint"]||Yt,nr=Bt?.["dflow.collateralMint"]||bo,or=vn,pr=nr||Tt,Er=react.useMemo(()=>isNaN(S)||S<=0?"0":String(Math.round(S*1e6)),[S]),yo=l==="kalshi"&&!!or&&!!pr&&!!b&&Er!=="0",{refetch:mr}=reactPredict.useDFlowQuote({inputMint:or,outputMint:pr,amount:Er,userPublicKey:b??"",slippageBps:100},{enabled:yo}),fr=react.useMemo(()=>isNaN(S)||S<=0?0:S,[S]),Nt=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:Pt,outcome:k,side:"sell",sharesNeeded:fr,slippageBps:r}),[Pt,k,fr,r]),bn=react.useMemo(()=>Nt.status==="ok"&&Nt.worstPrice!=null&&Nt.worstPrice>0?Nt.worstPrice:Pe,[Nt,Pe]),xn=react.useMemo(()=>{if(isNaN(S)||S<=0)return 0;let C=y==="limit"&&m&&!isNaN(I)?I:Pe;return S*C},[S,y,m,I,Pe]),gr=react.useCallback(C=>{x(C),z(NaN),R(NaN),Y(false);},[]);react.useEffect(()=>{gr(t);},[t,gr]);let yn=react.useCallback(C=>{P(C);},[]);react.useEffect(()=>{y==="limit"&&z(Math.round(Pe*1e4)/1e4);},[y,k]);let kn=react.useCallback(C=>{if(Y(false),isNaN(C)){R(NaN);return}R(ve(Math.max(0,C),Ye));},[Ye]),ko=react.useCallback(()=>{Y(true),R(ve(Ft,Ye));},[Ft,Ye]),L=react.useCallback(C=>{if(isNaN(C)){z(NaN);return}z(Math.round(C*1e4)/1e4);},[]),Ne=react.useCallback(()=>{R(NaN),z(NaN),P("market"),Y(false),O(false),A("1h"),pt(30),qe("minutes");},[]),Re=react.useMemo(()=>{let C=[];return isNaN(S)||S<=0?C.push(o("predict.trade.minQuantity",{amount:Ln})):S<Ln&&C.push(o("predict.trade.minQuantity",{amount:Ln})),e.status!=="open"&&C.push(o("predict.trade.marketNotActive")),!isNaN(S)&&S>0&&!G&&S>Ft&&C.push(o("predict.trade.insufficientSharesDetail",{total:ve(qt,Ye).toFixed(Ye),active:ve(Gt,Ye).toFixed(Ye),available:ve(Ft,Ye).toFixed(Ye)})),y==="limit"&&m&&(isNaN(I)||I<.01||I>.99)&&C.push(o("predict.trade.limitPriceRange")),y==="limit"&&m&&ne&&Se==="custom"&&(isNaN(be)||be<=0)&&C.push(o("predict.trade.expiration.invalidDate")),l==="polymarket"&&y==="market"&&!isNaN(S)&&S>0&&(Nt.status==="insufficient_liquidity"?C.push(o("predict.trade.insufficientLiquidity",{available:ve(Nt.totalAvailable,2)})):Nt.status==="exceeds_slippage"&&C.push(o("predict.trade.priceImpactTooHigh",{impact:(Nt.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:C.length===0,errors:C}},[S,e.status,Ft,qt,Gt,G,y,m,I,ne,Se,be,Ye,l,Nt,r,o]),{mutateAsync:gt}=reactPredict.useDFlowSubmit(),{data:hr}=reactPredict.useOrder({id:Q??"",source:l},{enabled:!!Q}),ir=react.useCallback(async()=>{if(!w||!b||!g)return;let{cashAmount:C,collateral:Ce}=w;M(null);try{let Ke=(await u.createDFlowQuote({inputMint:Ce,outputMint:Tt,amount:C,userPublicKey:b,slippageBps:100}))?.transaction;if(!Ke)return;let lt=Uint8Array.from(atob(Ke),ct=>ct.charCodeAt(0)),Et=await g.signTransaction(lt);await gt({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:b,input_mint:Ce,output_mint:Tt,amount:C,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[w,b,g,u,gt,Tt]),ht=react.useCallback(()=>{d.invalidateQueries({queryKey:["predict","available-shares"]});},[d]);react.useEffect(()=>{if(!hr||!Q)return;let{status:C}=hr;C==="closed"?(re(null),w?ir().finally(()=>{W(false),we("sell-market"),ht(),Ne(),s.current?.();}):(W(false),we("sell-market"),ht(),Ne(),s.current?.())):(C==="failed"||C==="expired")&&(W(false),re(null),M(null),ui.toast.error(o("predict.trade.submitError")));},[hr,Q,w,ir,we,ht,Ne,o]);let Qe=react.useCallback(async()=>{if(!b||!g)return;if(!or||!pr){ui.toast.error("Missing token mint addresses"),W(false);return}if(!nt){J(true),W(false);return}let _e=(await mr()).data,Ke=_e?.transaction;if(!Ke){ui.toast.error(o("predict.trade.submitError")),W(false);return}if(nr&&nr!==Tt){let he=String(_e?.outAmount??"");he&&he!=="0"&&M({cashAmount:he,collateral:nr});}let lt=Uint8Array.from(atob(Ke),he=>he.charCodeAt(0)),Et=await g.signTransaction(lt),ct=await gt({signedTransaction:btoa(String.fromCharCode(...Et)),orderContext:{user_public_key:b,input_mint:or,output_mint:pr,amount:Er,price:String(Pe),side:"SELL",outcome:k==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});re(ct.signature);},[b,g,mr,gt,or,pr,Er,Pe,k,e.slug,nr,Tt,o,nt]),Sn=react.useCallback(async()=>{if(!h||!p)return;let C=h.chain,Ce=C!==types.Chain.POLYGON;Ce&&await h.switchChain(types.Chain.POLYGON);try{let _e=await h.getEip1193Provider();if(!_e){ui.toast.error(o("predict.trade.submitError")),W(!1);return}let Ke=de==="deposit"&&!!Le,lt=!Ke&&!!E,Et=Ke?Le:E,ct={address:h.address,signatureType:Ke?3:lt?2:0,signTypedData:async(Ht,Pn,No,Co)=>{let Rr=[];"name"in Ht&&Rr.push({name:"name",type:"string"}),"version"in Ht&&Rr.push({name:"version",type:"string"}),"chainId"in Ht&&Rr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ht&&Rr.push({name:"verifyingContract",type:"address"}),"salt"in Ht&&Rr.push({name:"salt",type:"bytes32"});let fc={EIP712Domain:Rr,...Pn};return await _e.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Ht,types:fc,primaryType:No,message:Co})]})}},he=await Dt();if(!he){ui.toast.error(o("predict.trade.submitError")),W(!1);return}let Oe=k==="yes"?0:1,Qt="",sr=e.provider_meta?.["polymarket.clobTokenIds"];sr&&(Qt=(typeof sr=="string"?JSON.parse(sr):sr)[Oe]??"");let Lr=e.provider_meta?.["polymarket.negRisk"]??!1,ar=y==="limit"&&!isNaN(I)?I:bn,So=In(ar,at),wo={tokenId:Qt,price:So,size:S,side:"SELL",orderType:y==="limit"?ne?"GTD":"GTC":"FOK",tickSize:at,negRisk:Lr,...Et&&{funderAddress:Et},...Ue&&{builderCode:Ue},...y==="limit"&&ne&&{expiration:_n(Se,be,Ee)}},Po;if(Ke)Po=await reactPredict.buildSignedV2OrderPayload({signer:ct,depositWalletAddress:Et,input:wo,owner:he.apiKey});else {let Ht=reactPredict.buildCtfExchangeDomain(Lr),Pn=reactPredict.buildOrderMessage({...wo,signerAddress:ct.address,signatureType:ct.signatureType,feeRateBps:rt}),No=await ct.signTypedData(Ht,reactPredict.CTF_ORDER_TYPES,"Order",Pn),Co=reactPredict.buildSignedOrder(Pn,No,wo.orderType);Po=reactPredict.buildClobPayload(Co,he.apiKey);}await u.executePolymarketOrder({payload:Po,l2_api_key:he.apiKey,l2_secret:he.secret,l2_passphrase:he.passphrase,signer_address:he.address,owner:he.apiKey}),ht(),we(y==="limit"?"sell-limit":"sell-market",async()=>await reactPredict.buildPolymarketL2Headers(he.address,{apiKey:he.apiKey,secret:he.secret,passphrase:he.passphrase,method:"GET",requestPath:"/data/orders"})),Ne(),W(!1),s.current?.();}finally{Ce&&C&&h.switchChain(C).catch(()=>{});}},[h,p,Dt,k,e.provider_meta,y,we,I,bn,S,u,ht,ne,Se,be,Ee,Ne,o,at,rt,e.slug,E,de,Le,Ue]),wn=react.useCallback(async()=>{if(!(!Re.isValid||!v)){W(true),re(null),J(false);try{l==="kalshi"?await Qe():await Sn();}catch(C){let Ce=C instanceof Error?C.message:"",_e=l==="polymarket"&&Ce?On(Ce,o,"sell"):Ce||void 0;ui.toast.error(_e||o("predict.trade.submitError")),W(false);}}},[Re.isValid,v,l,Qe,Sn,o]);return {outcome:k,orderType:y,quantity:S,limitPrice:I,shares:fr,estimatedReturn:xn,pricePerShare:Pe,isMarketDataLoading:l==="polymarket"&&(ze||tt),isSubmitting:K,authStatus:a,validation:Re,supportsLimitOrder:m,kycRequired:$,needsKyc:Ge,needsSetup:Vr,kycUrl:mt,totalShares:qt,activeOrderShares:Gt,availableShares:Ft,isAvailableLoading:ho,isSellAll:G,precision:Ye,expirationEnabled:ne,expirationPreset:Se,customDuration:be,customDurationUnit:Ee,setOutcome:gr,setOrderType:yn,setQuantity:kn,setLimitPrice:L,setSellAll:ko,setExpirationEnabled:O,setExpirationPreset:A,setCustomDuration:pt,setCustomDurationUnit:qe,submit:wn}}var qp=["5m","1h","12h","24h","eod","custom"],Gp={"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"},Yp=["minutes","hours","days"],Qp={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Xp={maximumFractionDigits:0};function na({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,estimatedReturn:a,isMarketDataLoading:c,isSubmitting:u,authStatus:p,isValid:d,validationErrors:f,supportsLimitOrder:l,kycRequired:m,needsKyc:g,needsSetup:h,onSetupRequired:v,kycUrl:b,totalShares:N,activeOrderShares:k,availableShares:x,isAvailableLoading:y,precision:P,expirationEnabled:S,expirationPreset:R,customDuration:I,customDurationUnit:z,oddsFormatter:K,onOutcomeChange:W,onOrderTypeChange:G,onQuantityChange:Y,onLimitPriceChange:Q,onSellAll:re,onExpirationEnabledChange:w,onExpirationPresetChange:M,onCustomDurationChange:$,onCustomDurationUnitChange:J,onSubmit:ne}){let{t:O}=i18n.useTranslation(),[Se,A]=react.useState(false),be=ui.useDisclosure(),[pt,Ee]=react.useState(""),qe=react.useRef(false);react.useEffect(()=>{qe.current||Ee(isNaN(i)?"":String(i));},[i]);let[st,we]=react.useState(""),Ze=react.useRef(false);react.useEffect(()=>{Ze.current||(isNaN(s)?we(""):we(String(parseFloat((s*100).toFixed(2)))));},[s]);let et=react.useCallback(E=>{if(E!==""&&!/^\d*\.?\d{0,2}$/.test(E))return;if(we(E),E===""||E==="."){Q(NaN);return}let Le=parseFloat(E);isNaN(Le)||Q(Le/100);},[Q]),tt=react.useCallback(E=>{let de=new RegExp(`^\\d*\\.?\\d{0,${P}}$`);if(E!==""&&!de.test(E))return;if(Ee(E),A(false),E===""||E==="."){Y(NaN);return}let Le=parseFloat(E);isNaN(Le)||Y(Le);},[Y,P]);react.useEffect(()=>{m&&!be.isOpen&&be.onOpen();},[m]);let at=react.useMemo(()=>{let E=n==="yes"?t.yesBid:t.noBid;return E!=null?parseFloat((Number(E)*100).toFixed(2)):null},[n,t]),Ot=n==="yes"?t.yesBid:t.noBid,ze=Ot!=null&&K?K(Number(Ot)):at!=null?`${at} \xA2`:null,rt=!isNaN(i)&&i>0,We=p==="authenticated",Ue=p==="authenticating"||p==="deauthenticating",nt=We&&(g||h),mt=react.useMemo(()=>{if(Ue)return O("predict.trade.checkingLogin");if(!We)return O("predict.trade.loginToTrade");if(g)return O("predict.trade.kycRequired");if(h)return O("predict.trade.setupRequired");if(y)return O("predict.trade.loadingBalance");if(c)return O("predict.trade.loadingMarketData");if(u)return O("predict.trade.submitting");if(m)return O("predict.trade.kycRequired");if(!rt)return O("predict.trade.enterAmount");let E=O(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${O("predict.trade.sell")} ${E}`},[Ue,We,g,h,y,c,u,m,rt,n,O]),Mt=()=>{if(!We){A(false),ne();return}if(g){be.onOpen();return}if(h&&v){A(false),v();return}if(m){be.onOpen();return}if(!d){A(true);return}A(false),ne();};return 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:E=>{r==="bordered"&&(E.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:E=>{r==="bordered"&&(E.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:"text-bearish",children:[O("predict.trade.sell")," ",O(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[l?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:E=>G(E),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:O("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:O("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:O("predict.trade.market")}),o==="limit"&&l?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:st,onChange:E=>et(E.target.value),onFocus:()=>{Ze.current=true;},onBlur:()=>{Ze.current=false,isNaN(s)?we(""):we(String(parseFloat((s*100).toFixed(2))));},endContent: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"}}):ze!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:ze})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(E=>{let de=E==="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:()=>W(E),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===E?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:O(E==="yes"?"predict.trade.yes":"predict.trade.no")}),de!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:K?K(Number(de)):`${parseFloat((Number(de)*100).toFixed(2))}\xA2`})]})},E)})}),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:O("predict.trade.sellContracts")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(E=>{let de=Math.pow(10,P);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{Y(Math.floor(x*E/100*de)/de);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[E,"%"]},E)}),jsxRuntime.jsx("button",{type:"button",onClick:re,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:O("common.all")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:pt,onChange:E=>tt(E.target.value),onFocus:()=>{qe.current=true;},onBlur:()=>{qe.current=false,Ee(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),Se&&f.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:f.map(E=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:E},E))})]}),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:O("predict.trade.totalShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:y?"\u2013":`${ve(N,P).toFixed(P)}${O("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:O("predict.trade.activeOrders")}),jsxRuntime.jsx("span",{className:"tabular-nums text-warning",children:y?"\u2013":k>0?`-${ve(k,P).toFixed(P)}${O("predict.trade.sharesUnit")}`:`0${O("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:O("predict.trade.availableShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-success font-medium",children:y?"\u2013":`${ve(x,P).toFixed(P)}${O("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:O("predict.trade.estReturn")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${a.toFixed(2)}`:"\u2013"})]})]}),o==="limit"&&l&&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:O("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:S,onValueChange:w,"aria-label":O("predict.trade.setExpiration")})]}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":O("predict.trade.setExpiration"),selectedKeys:[R],onSelectionChange:E=>{let de=Array.from(E)[0];de&&M(de);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:qp.map(E=>jsxRuntime.jsx(ui.SelectItem,{children:O(Gp[E])},E))}),R==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(I)?void 0:I,onValueChange:$,minValue:1,step:1,formatOptions:Xp,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":"Duration unit",selectedKeys:[z],onSelectionChange:E=>{let de=Array.from(E)[0];de&&J(de);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Yp.map(E=>jsxRuntime.jsx(ui.SelectItem,{children:O(Qp[E])},E))})]})]})]}),jsxRuntime.jsx(ui.Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:Ue||We&&!nt&&(y||c||!rt||u),isLoading:Ue||We&&!nt&&(u||y||c),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Mt,children:mt})]}),jsxRuntime.jsx(An,{isOpen:be.isOpen,onClose:be.onClose,kycUrl:b})]})}function jn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onOutcomeChange:s,onSetupRequired:a,onSuccess:c,oddsFormatter:u}){let{outcome:p,orderType:d,quantity:f,limitPrice:l,estimatedReturn:m,pricePerShare:g,isMarketDataLoading:h,isSubmitting:v,authStatus:b,validation:N,supportsLimitOrder:k,kycRequired:x,needsKyc:y,needsSetup:P,kycUrl:S,totalShares:R,activeOrderShares:I,availableShares:z,isAvailableLoading:K,precision:W,expirationEnabled:G,expirationPreset:Y,customDuration:Q,customDurationUnit:re,setOutcome:w,setOrderType:M,setQuantity:$,setLimitPrice:J,setSellAll:ne,setExpirationEnabled:O,setExpirationPreset:Se,setCustomDuration:A,setCustomDurationUnit:be,submit:pt}=Gs({market:t,initialOutcome:n,slippageBps:i,onSuccess:c}),Ee=walletConnector.useAuthCallback(pt),qe=react.useCallback(Ze=>{w(Ze),s?.(Ze);},[w,s]),st=react.useMemo(()=>e?Cn(e):void 0,[e]),we=react.useMemo(()=>Mn(t,{yesBid:p==="yes"?g:void 0,noBid:p==="no"?g:void 0}),[t,p,g]);return jsxRuntime.jsx(na,{event:st,market:we,variant:r,outcome:p,orderType:d,quantity:f,limitPrice:l,estimatedReturn:m,isMarketDataLoading:h,isSubmitting:v,authStatus:b,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:k,kycRequired:x,needsKyc:y,needsSetup:P,onSetupRequired:a,kycUrl:S,totalShares:R,activeOrderShares:I,availableShares:z,isAvailableLoading:K,precision:W,expirationEnabled:G,expirationPreset:Y,customDuration:Q,customDurationUnit:re,oddsFormatter:u,onOutcomeChange:qe,onOrderTypeChange:M,onQuantityChange:$,onLimitPriceChange:J,onSellAll:ne,onExpirationEnabledChange:O,onExpirationPresetChange:Se,onCustomDurationChange:A,onCustomDurationUnitChange:be,onSubmit:Ee})}var qo="predict-sell";function ia({id:e=qo}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(sm,{...t})})}function sm({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.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.ModalContent,{children:jsxRuntime.jsxs("div",{className:o?"":"p-2",children:[jsxRuntime.jsx(jn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),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 Qo=40,Yn=36,rn=480,Xo=rn-Yn;function la({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=i18n.useTranslation(),[o,i]=react.useState("positions"),s=react.useMemo(()=>e.markets?.map(d=>d.slug)??[],[e.markets]),{data:a}=reactPredict.usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),c=react.useMemo(()=>!a?.positions||!t?0:s.length===0?a.positions.length:a.positions.filter(d=>d.market&&s.includes(d.market.slug)).length,[a?.positions,s,t]),p=[{key:"positions",label:c>0?`${n("predict.positions.title")} (${c})`: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(d=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(d.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===d.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:d.label},d.key))}),t?jsxRuntime.jsxs("div",{style:{height:rn},children:[o==="positions"&&jsxRuntime.jsx(mm,{source:e.source,walletAddress:t,marketSlugs:s}),o==="orders"&&jsxRuntime.jsx(gm,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:r}),o==="trades"&&jsxRuntime.jsx(bm,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:n("predict.trade.connectWallet")})]})}function mm({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=i18n.useTranslation(),{data:o,isLoading:i}=reactPredict.usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),s=react.useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[o?.positions,r]);return i?jsxRuntime.jsx(Zo,{}):s.length===0?jsxRuntime.jsx(Jo,{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:Yn},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:Xo},rowComponent:fm,rowCount:s.length,rowHeight:Qo,rowProps:{positions:s,closeLabel:n("predict.positions.close")}})]})}function fm({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,s=o.pnl_percent??0,a=o.avg_price??0,c=o.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",p=i>0?"+":"",d=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,l=o.size,m=o.size*c,g=o.market?.end_at?km(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:d}),jsxRuntime.jsx("span",{className:ui.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:qn(a)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:qn(c)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[p,"$",Math.abs(i).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,s.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),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 gm({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=i18n.useTranslation(),{data:i,isLoading:s,fetchNextPage:a,hasNextPage:c}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),u=reactPredict.useCancelOrder(),p=react.useMemo(()=>{let v=i?.pages?.flatMap(k=>k.items)??[],b=new Set(["live","open","submitted","pending"]),N=v.filter(k=>b.has(k.status));return r.length>0&&(N=N.filter(k=>k.market_id&&r.includes(k.market_id))),N},[i?.pages,r]),d=react.useCallback(v=>{n?n(v.id):u.mutate({source:v.source,id:v.id});},[n,u]),f=p.length,l=f+(c?1:0),m=react.useCallback(v=>v<f,[f]),g=react.useCallback(async()=>{await a();},[a]),h=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:l,threshold:5});return s?jsxRuntime.jsx(Zo,{}):p.length===0&&!c?jsxRuntime.jsx(Jo,{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:Yn},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:Xo},onRowsRendered:h,rowComponent:hm,rowCount:l,rowHeight:Qo,rowProps:{orders:p,itemCount:f,onCancel:d,isCancelling:u.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function hm({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:s}){if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let c=a.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",c?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?qn(parseFloat(a.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(vm,{status:a.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>o(a),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 vm({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-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 bm({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:s}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),a=react.useMemo(()=>n?.pages?.flatMap(l=>l.items)??[],[n?.pages]),c=a.length,u=c+(s?1:0),p=react.useCallback(l=>l<c,[c]),d=react.useCallback(async()=>{await i();},[i]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:d,rowCount:u,threshold:5});return o?jsxRuntime.jsx(Zo,{}):a.length===0&&!s?jsxRuntime.jsx(Jo,{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:Yn},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:Xo},onRowsRendered:f,rowComponent:xm,rowCount:u,rowHeight:Qo,rowProps:{trades:a,itemCount:c}})]})}function xm({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.Spinner,{size:"sm"})});let o=r[e];if(!o)return null;let i=o.side?.toUpperCase()==="BUY",s=ym(o.timestamp),a=o.price??0,c=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.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:o.side})}),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:qn(a)}),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:["$",c.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function Jo({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:rn},children:e})}function Zo(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:rn},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function qn(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function ym(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${i}`}function km(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var ca=`
|
|
75
75
|
@keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
76
|
-
`,ta={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function me(e){return {...ta,animationDelay:`${e}ms`}}function nn({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ea}),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:{...ta,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:{...me(0),height:14,width:48}}),jsxRuntime.jsx("div",{style:{...me(30),height:14,width:40}}),jsxRuntime.jsx("div",{style:{...me(60),height:14,width:40}})]}),jsxRuntime.jsx("div",{style:{...me(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsxRuntime.jsx("div",{style:{...me(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:{...me(120),height:16,width:96}}),jsxRuntime.jsx("div",{style:{...me(140),height:16,width:80}})]}),jsxRuntime.jsx("div",{style:{...me(160),height:300,width:"100%",borderRadius:12}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("div",{style:{...me(180),height:16,width:80}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...me(200),height:28,width:200,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(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:{...me(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 rgba(39,39,42,0.5)"},children:[jsxRuntime.jsx("div",{style:{...me(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:{...me(280+o*40),height:14,width:o%2===0?192:160}}),jsxRuntime.jsx("div",{style:{...me(300+o*40),height:10,width:64}})]}),jsxRuntime.jsx("div",{style:{...me(320+o*40),height:16,width:40}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...me(340+o*40),height:32,width:80,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(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:{...me(400),height:16,width:64}}),jsxRuntime.jsx("div",{style:{...me(420),height:14,width:"100%"}}),jsxRuntime.jsx("div",{style:{...me(440),height:14,width:"80%"}}),jsxRuntime.jsx("div",{style:{...me(460),height:14,width:"60%"}})]})]})]})}function ra(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ea}),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:{...me(0),height:40,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(60),height:96,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(120),height:40,width:"100%",borderRadius:8}})]})]})}var aa="var(--color-bullish)",la="var(--color-bearish)";function on(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function lm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function cm(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let c of e){let m=Math.round(c.price*100);m>=0&&m<=100&&(r[m]+=c.quantity);}for(let c of t){let m=Math.round(c.price*100);m>=0&&m<=100&&(o[m]+=c.quantity);}let n=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let c=100;c>=0;c--)n+=r[c],i+=r[c]*c/100,s[c]=n,a[c]=i;let l=0,u=0,d=new Float64Array(101),p=new Float64Array(101);for(let c=0;c<=100;c++)l+=o[c],u+=o[c]*c/100,d[c]=l,p[c]=u;let f=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(c,m)=>{let g=s[m]>0,v=d[m]>0,b=s[m]||d[m],x=r[m]>0||o[m]>0;return {priceCents:m,displayHeight:lm(b,f),opacity:b>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:s[m],askCumTotal:d[m],bidCumCost:a[m],askCumCost:p[m]}})}function dm({info:e}){let{t}=i18n.useTranslation(),r=e.isBid?aa:la,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:"#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:on(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:r},children:["$",on(Math.round(e.cumCost))]})]})}var um=react.memo(function({slot:t,onEnter:r,onLeave:o}){let n=react.useRef(null),i=t.isBid||t.isAsk,s=t.isBid?aa:t.isAsk?la: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}})})}),pm=[0,10,20,30,40,50,60,70,80,90,100];function mm(){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:pm.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 ca({bids:e,asks:t}){let{t:r}=i18n.useTranslation(),o=react.useMemo(()=>cm(e,t),[e,t]),n=react.useMemo(()=>{let p=e.length>0?Math.max(...e.map(c=>c.price)):0,f=t.length>0?Math.min(...t.map(c=>c.price)):1;return Math.round((p+f)/2*100)},[e,t]),i=react.useMemo(()=>o.some(p=>p.isBid||p.isAsk),[o]),[s,a]=react.useState(null),l=react.useRef(null),u=react.useCallback((p,f)=>{l.current&&(l.current.style.filter=""),f?(f.style.filter="brightness(1.5)",l.current=f):l.current=null,p.isBid||p.isAsk?a({priceCents:p.priceCents,isBid:p.isBid,cumTotal:p.isBid?p.bidCumTotal:p.askCumTotal,cumCost:p.isBid?p.bidCumCost:p.askCumCost,leftPct:p.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(dm,{info:s}),o.map(p=>jsxRuntime.jsx(um,{slot:p,onEnter:u,onLeave:d},p.priceCents))]}),jsxRuntime.jsx(mm,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function ga(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function ua(){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 ha({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:o="depth",className:n,oddsFormatter:i}){let{t:s}=i18n.useTranslation(),[a,l]=react.useState(o),u=i??ga,d=e.source,{data:p,isLoading:f,isFetching:c,refetch:m}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:d,outcome:t}),g=react.useMemo(()=>(p?.bids??[]).map(S=>({price:S.price,quantity:S.size})),[p?.bids]),v=react.useMemo(()=>(p?.asks??[]).map(S=>({price:S.price,quantity:S.size})),[p?.asks]),b=react.useMemo(()=>g.length>0?Math.max(...g.map(S=>S.price)):null,[g]),x=react.useMemo(()=>v.length>0?Math.min(...v.map(S=>S.price)):null,[v]),w=react.useMemo(()=>{if(b==null||x==null)return null;let S=(x-b)*100;return Math.round(S*10)/10},[b,x]);return jsxRuntime.jsxs("div",{className:ui.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:w!=null?`${s("predict.orderBook.spread")}: ${Number.isInteger(w)?`${w}\xA2`:`${w.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[b!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[s("predict.trade.bestBid"),": ",u(b)]}),b!=null&&x!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),x!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[s("predict.trade.bestAsk"),": ",u(x)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",title:a==="depth"?"Orderbook":"Depth chart",onClick:()=>l(S=>S==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:a==="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:"Refresh",onClick:()=>m(),disabled:c,className:ui.cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",c&&"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:[a==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(ua,{}):jsxRuntime.jsx(ca,{bids:g,asks:v})}),a==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(ua,{}):jsxRuntime.jsx(xm,{bids:g,asks:v,bestBid:b??void 0,bestAsk:x??void 0,spread:w??void 0,oddsFormatter:i})})]})]})}var qo=4,bm=8;function xm({bids:e,asks:t,spread:r,oddsFormatter:o}){let{t:n}=i18n.useTranslation(),[i,s]=react.useState(false),a=i?bm:qo,l=t.length>qo||e.length>qo,u=react.useMemo(()=>[...t].sort((c,m)=>c.price-m.price).slice(0,a).reverse(),[t,a]),d=react.useMemo(()=>[...e].sort((c,m)=>m.price-c.price).slice(0,a),[e,a]),p=react.useMemo(()=>{let c=[...u,...d].map(m=>m.quantity);return Math.max(...c,1)},[u,d]);return u.length===0&&d.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:n("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(c=>jsxRuntime.jsx(pa,{price:c.price,quantity:c.quantity,side:"ask",maxQty:p,oddsFormatter:o},`ask-${c.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:[n("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(c=>!c),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:n(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),d.map(c=>jsxRuntime.jsx(pa,{price:c.price,quantity:c.quantity,side:"bid",maxQty:p,oddsFormatter:o},`bid-${c.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: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 pa({price:e,quantity:t,side:r,maxQty:o,oddsFormatter:n}){let i=r==="ask",s=Math.min(t/o*100,100),a=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=on(Math.round(t)),d=Math.round(t*e),p=`$${on(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):ga(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:p})]})}var Qo=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}},sn=4,va=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Rm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function _m(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===le.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function xa(e){return `${(e*100).toFixed(2)}%`}var Im=[{range:le.ONE_DAY,label:"1D"},{range:le.ONE_WEEK,label:"1W"},{range:le.ONE_MONTH,label:"1M"},{range:le.ALL,label:"ALL"}];function Om({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Im.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?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function Am(){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 Dm({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:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?_m(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:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?xa(l.value):"--"})]},l.dataKey))]})}function Fm({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,i]=react.useState(false),s=react.useRef(null);react.useEffect(()=>{if(!n)return;function u(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n]);let a=t.length>=sn,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(d=>d.slug===t[0]);return u?.outcomes?.[0]?.label??u?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>i(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&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 ",sn," markets"]}),e.map((u,d)=>{let p=t.includes(u.slug),f=!p&&a,c=p&&t.length===1,m=r.get(u.slug)??"#6b7280",g=u.outcomes.find(b=>b.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{c||f||o(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:p?"rgba(255,255,255,0.05)":"transparent",cursor:f||c?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:b=>{!f&&!c&&(b.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:b=>{b.currentTarget.style.background=p?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:p?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:p?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:p&&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:p?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),v&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${d}-${u.slug}`)})]})]})}function Bm({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)??"#6b7280",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:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?xa(i):"--"})]})]},o.marketSlug)})})}function Hm(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function zm(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.map(u=>u.price).sort((u,d)=>u-d);r.push({timestamp:a[a.length-1].timestamp,price:Hm(l)});}return r}function Wm(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:zm(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(u=>l.set(u.timestamp,u.price)),{slug:a.marketSlug,map:l}}),s=new Map;return n.map(a=>{let l={timestamp:a};return i.forEach(({slug:u,map:d})=>{let p=d.get(a);if(p!==void 0)s.set(u,p),l[u]=p;else {let f=s.get(u);f!==void 0&&(l[u]=f);}}),l})}function ya(e){return jsxRuntime.jsx(Qo,{children:jsxRuntime.jsx(Um,{...e})})}function Um({event:e,isLoading:t,className:r,volume:o,fillHeight:n=false}){let i=react.useMemo(()=>{let N=new Set;return (e.markets??[]).filter(C=>N.has(C.slug)?false:(N.add(C.slug),true))},[e.markets]),s=react.useMemo(()=>[...i].sort((N,C)=>{let U=X=>(X.outcomes.find(se=>se.label.toLowerCase()==="yes")??X.outcomes[0])?.price??0;return U(C)-U(N)}),[i]),[a,l]=react.useState(()=>s.slice(0,sn).map(N=>N.slug));react.useEffect(()=>{let N=new Set(i.map(C=>C.slug));l(C=>{let U=C.filter(X=>N.has(X));return U.length===C.length?C:U.length>0?U:s.slice(0,sn).map(X=>X.slug)});},[i,s]);let[u,d]=react.useState(Nn),p=react.useMemo(()=>{let N=new Map;return a.forEach((C,U)=>{N.set(C,va[U%va.length]);}),N},[a]),f=react.useMemo(()=>i.filter(N=>a.includes(N.slug)),[i,a]),{series:c,isLoading:m}=reactPredict.useMarketHistory(f,u),g=t||m,v=react.useMemo(()=>{if(c.length>0&&c.some(U=>U.data.length>0))return c;let N=Date.now(),C=864e5;return f.map(U=>{let se=(U.outcomes?.find(_=>_.label.toLowerCase()==="yes")??U.outcomes?.[0])?.price??.5;return {marketSlug:U.slug,label:U.outcomes?.[0]?.label??U.question,data:[{timestamp:N-7*C,price:se},{timestamp:N,price:se}]}})},[c,f]),b=react.useMemo(()=>u===le.ONE_DAY?96:u===le.ONE_WEEK?168:u===le.ONE_MONTH?180:300,[u]),x=react.useMemo(()=>Wm(v,b),[v,b]),w=react.useMemo(()=>{if(x.length===0)return [0,1];let N=1/0,C=-1/0;if(a.forEach(X=>{x.forEach(se=>{let _=se[X];_!=null&&(_<N&&(N=_),_>C&&(C=_));});}),!isFinite(N))return [0,1];let U=Math.max((C-N)*.15,.05);return [Math.max(0,N-U),Math.min(1,C+U)]},[x,a]),S=react.useMemo(()=>{let N=new Map;return v.forEach(C=>{C.data.length>0&&N.set(C.marketSlug,C.data[C.data.length-1].price);}),N},[v]),h=react.useMemo(()=>{let N=new Map;return v.forEach(C=>N.set(C.marketSlug,C.label)),N},[v]),y=react.useMemo(()=>v.map(N=>({slug:N.marketSlug,color:p.get(N.marketSlug)??"#6b7280"})),[v,p]),{wrapperRef:k,overlayRef:P,onMouseMove:O,onMouseLeave:F}=Am(),W=react.useCallback(N=>{l(C=>C.includes(N)?C.length<=1?C:C.filter(U=>U!==N):C.length>=sn?C:[...C,N]);},[]),[A,G]=react.useState(null),q=react.useRef(null),Y=react.useRef(""),re=react.useRef(0),te=!g&&x.length>0;return jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...n?{height:"100%",minHeight:0}:null},children:[jsxRuntime.jsx(Bm,{series:v,colorMap:p,displayValues:A??S}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...n?{flex:1,minHeight:0}:null},children:[jsxRuntime.jsx("div",{ref:k,style:{width:"100%",userSelect:"none",position:"relative",...n?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?N=>{O(N),cancelAnimationFrame(re.current),re.current=requestAnimationFrame(()=>{G(q.current);});}:void 0,onMouseLeave:te?()=>{F(),cancelAnimationFrame(re.current),Y.current="",q.current=null,G(null);}:void 0,children:g?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"}})}):x.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:P,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:x,margin:{top:8,right:16,left:0,bottom:0},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:["dataMin","dataMax"],tickFormatter:N=>Rm(N,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:w,tickFormatter:N=>`${Math.round(N*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:N=>{let C=N;if(C.active&&C.payload?.length){let U=C.payload.map(X=>`${X.dataKey}:${X.value}`).join(",");if(U!==Y.current){Y.current=U;let X=new Map;C.payload.forEach(se=>{se.value!=null&&X.set(se.dataKey,se.value);}),q.current=X;}}return jsxRuntime.jsx(Dm,{...C,labelMap:h,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(N=>{let C=p.get(N.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:N.marketSlug,stroke:C,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:C},connectNulls:true,isAnimationActive:false},N.marketSlug)}),A==null&&x.length>0&&v.map(N=>{let C=x[x.length-1],U=C[N.marketSlug];if(U==null)return null;let X=p.get(N.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:C.timestamp,y:U,ifOverflow:"extendDomain",shape:se=>{let{cx:_,cy:Se}=se;return _==null||Se==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:_,cy:Se,r:6,fill:X,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:_,cy:Se,r:3.5,fill:X})]})}},`pulse-${N.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$1.formatAmountInUsd(o)," vol"]}),jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}}),jsxRuntime.jsx(Om,{value:u,onChange:d}),s.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(Fm,{markets:s,selectedSlugs:a,colorMap:p,onToggle:W})})]})]})]})}function qn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Sa(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function of(e){return `${parseFloat((e*100).toFixed(2))}%`}function wa(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Gn(e){return e.outcomes?.[0]?.label??e.question}function sf(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function an(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${i}:${s}`}function Pa(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),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(s).padStart(2,"0")}h`),u.push(`${String(a).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function Na(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?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}function Ta({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:o,isCollapsed:n}=hooks.useScrollCollapse(),i=react.useMemo(()=>{let p=[...e.markets||[]],f=p.filter(m=>m.status==="open").sort((m,g)=>qn(g)-qn(m)),c=p.filter(m=>m.status!=="open").sort((m,g)=>qn(g)-qn(m));return [...f,...c]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=Pa(s?void 0:e.start_at),l=Pa(s?void 0:e.end_at),u=Na(e.start_at),d=Na(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:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((p,f)=>jsxRuntime.jsxs(react.Fragment,{children:[f>0&&jsxRuntime.jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral truncate",children:p.label})]},p.slug)),jsxRuntime.jsx(df,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||l||s)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?d&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:d})}):a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),u&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:u})]})]}):l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsxRuntime.jsx(ya,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(af,{markets:i,onTradeAction:t}),jsxRuntime.jsx(cf,{markets:i,event:e})]})}var Ca=5;function af({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{isDesktop:o}=ui.useScreen(),[n,i]=react.useState(false),[s,a]=react.useState(null),l=react.useMemo(()=>{let v=new Set;return e.filter(b=>v.has(b.slug)?false:(v.add(b.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[d,p]=react.useState(u?`${u}:yes`:null);if(l.length===0)return null;let f=l.length>Ca,c=n?l:l.slice(0,Ca),m=v=>{a(b=>b===v?null:v);},g=(v,b,x)=>{p(`${v.slug}:${b}`),o&&a(v.slug),t?.(v,b,x);};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:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:c.map((v,b)=>{let x=s===v.slug;return jsxRuntime.jsx(lf,{market:v,activeYes:d===`${v.slug}:yes`,activeNo:d===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>m(v.slug),onTradeAction:g},v.id??`${b}-${v.slug}`)})})]}),f&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",n&&"rotate-180")})]})]})}function lf({market:e,activeYes:t,activeNo:r,isExpanded:o,onToggleExpand:n,onTradeAction:i}){let{t:s}=i18n.useTranslation(),a=e.status==="open",l=e.volume?`${utils$1.formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:a}),{data:d}=reactPredict.useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),p=reactPredict.pickBestAsk(u,"yes")??Sa(e,"yes")??0,f=reactPredict.pickBestAsk(d,"no")??Sa(e,"no");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:n,role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n());},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:Gn(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:Gn(e)}),l&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:l})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:of(p)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[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",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:c=>{c.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:wa(p)})}),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",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:c=>{c.stopPropagation(),i?.(e,"no","buy");},children:f!=null?s("predict.market.action.no",{price:wa(f)}):s("predict.market.no")})]}):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-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),o&&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(ha,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function cf({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[i,s]=react.useState(false),[a,l]=react.useState(0),u=e.filter(c=>c.rules&&c.rules.length>0||c.description);if(u.length===0)return null;let d=u[a]??u[0],p=d.rules&&d.rules.length>0?d.rules.join(`
|
|
76
|
+
`,da={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function me(e){return {...da,animationDelay:`${e}ms`}}function nn({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ca}),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:{...da,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:{...me(0),height:14,width:48}}),jsxRuntime.jsx("div",{style:{...me(30),height:14,width:40}}),jsxRuntime.jsx("div",{style:{...me(60),height:14,width:40}})]}),jsxRuntime.jsx("div",{style:{...me(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsxRuntime.jsx("div",{style:{...me(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:{...me(120),height:16,width:96}}),jsxRuntime.jsx("div",{style:{...me(140),height:16,width:80}})]}),jsxRuntime.jsx("div",{style:{...me(160),height:300,width:"100%",borderRadius:12}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("div",{style:{...me(180),height:16,width:80}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...me(200),height:28,width:200,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(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:{...me(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:{...me(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:{...me(280+n*40),height:14,width:n%2===0?192:160}}),jsxRuntime.jsx("div",{style:{...me(300+n*40),height:10,width:64}})]}),jsxRuntime.jsx("div",{style:{...me(320+n*40),height:16,width:40}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...me(340+n*40),height:32,width:80,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(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:{...me(400),height:16,width:64}}),jsxRuntime.jsx("div",{style:{...me(420),height:14,width:"100%"}}),jsxRuntime.jsx("div",{style:{...me(440),height:14,width:"80%"}}),jsxRuntime.jsx("div",{style:{...me(460),height:14,width:"60%"}})]})]})]})}function ua(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ca}),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:{...me(0),height:40,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(60),height:96,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...me(120),height:40,width:"100%",borderRadius:8}})]})]})}var ha="var(--color-bullish)",va="var(--color-bearish)";function on(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Pm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Nm(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let l of e){let m=Math.round(l.price*100);m>=0&&m<=100&&(r[m]+=l.quantity);}for(let l of t){let m=Math.round(l.price*100);m>=0&&m<=100&&(n[m]+=l.quantity);}let o=0,i=0,s=new Float64Array(101),a=new Float64Array(101);for(let l=100;l>=0;l--)o+=r[l],i+=r[l]*l/100,s[l]=o,a[l]=i;let c=0,u=0,p=new Float64Array(101),d=new Float64Array(101);for(let l=0;l<=100;l++)c+=n[l],u+=n[l]*l/100,p[l]=c,d[l]=u;let f=Math.max(s[0]??0,p[100]??0);return Array.from({length:101},(l,m)=>{let g=s[m]>0,h=p[m]>0,v=s[m]||p[m],b=r[m]>0||n[m]>0;return {priceCents:m,displayHeight:Pm(v,f),opacity:v>0?b?1:.5:0,isBid:g,isAsk:h,bidCumTotal:s[m],askCumTotal:p[m],bidCumCost:a[m],askCumCost:d[m]}})}function Cm({info:e}){let{t}=i18n.useTranslation(),r=e.isBid?ha:va,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:on(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:r},children:["$",on(Math.round(e.cumCost))]})]})}var Mm=react.memo(function({slot:t,onEnter:r,onLeave:n}){let o=react.useRef(null),i=t.isBid||t.isAsk,s=t.isBid?ha:t.isAsk?va: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,o.current),onMouseLeave:n,children:i&&jsxRuntime.jsx("div",{ref:o,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),Tm=[0,10,20,30,40,50,60,70,80,90,100];function Em(){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:Tm.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 ba({bids:e,asks:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>Nm(e,t),[e,t]),o=react.useMemo(()=>{let d=e.length>0?Math.max(...e.map(l=>l.price)):0,f=t.length>0?Math.min(...t.map(l=>l.price)):1;return Math.round((d+f)/2*100)},[e,t]),i=react.useMemo(()=>n.some(d=>d.isBid||d.isAsk),[n]),[s,a]=react.useState(null),c=react.useRef(null),u=react.useCallback((d,f)=>{c.current&&(c.current.style.filter=""),f?(f.style.filter="brightness(1.5)",c.current=f):c.current=null,d.isBid||d.isAsk?a({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):a(null);},[]),p=react.useCallback(()=>{c.current&&(c.current.style.filter="",c.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:[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"}}),s&&jsxRuntime.jsx(Cm,{info:s}),n.map(d=>jsxRuntime.jsx(Mm,{slot:d,onEnter:u,onLeave:p},d.priceCents))]}),jsxRuntime.jsx(Em,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Pa(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function ya(){let{t:e}=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 Na({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o,oddsFormatter:i}){let{t:s}=i18n.useTranslation(),[a,c]=react.useState(n),u=i??Pa,p=e.source,{data:d,isLoading:f,isFetching:l,refetch:m}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:p,outcome:t}),g=react.useMemo(()=>(d?.bids??[]).map(k=>({price:k.price,quantity:k.size})),[d?.bids]),h=react.useMemo(()=>(d?.asks??[]).map(k=>({price:k.price,quantity:k.size})),[d?.asks]),v=react.useMemo(()=>g.length>0?Math.max(...g.map(k=>k.price)):null,[g]),b=react.useMemo(()=>h.length>0?Math.min(...h.map(k=>k.price)):null,[h]),N=react.useMemo(()=>{if(v==null||b==null)return null;let k=(b-v)*100;return Math.round(k*10)/10},[v,b]);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-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:[v!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[s("predict.trade.bestBid"),": ",u(v)]}),v!=null&&b!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),b!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[s("predict.trade.bestAsk"),": ",u(b)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",title:a==="depth"?"Orderbook":"Depth chart",onClick:()=>c(k=>k==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:a==="depth"?jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"}):jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Refresh",onClick:()=>m(),disabled:l,className:ui.cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",l&&"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:[a==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(ya,{}):jsxRuntime.jsx(ba,{bids:g,asks:h})}),a==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(ya,{}):jsxRuntime.jsx(Dm,{bids:g,asks:h,bestBid:v??void 0,bestAsk:b??void 0,spread:N??void 0,oddsFormatter:i})})]})]})}var ti=4,Om=8;function Dm({bids:e,asks:t,spread:r,oddsFormatter:n}){let{t:o}=i18n.useTranslation(),[i,s]=react.useState(false),a=i?Om:ti,c=t.length>ti||e.length>ti,u=react.useMemo(()=>[...t].sort((l,m)=>l.price-m.price).slice(0,a).reverse(),[t,a]),p=react.useMemo(()=>[...e].sort((l,m)=>m.price-l.price).slice(0,a),[e,a]),d=react.useMemo(()=>{let l=[...u,...p].map(m=>m.quantity);return Math.max(...l,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(l=>jsxRuntime.jsx(ka,{price:l.price,quantity:l.quantity,side:"ask",maxQty:d,oddsFormatter:n},`ask-${l.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`]}),c&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(l=>!l),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:o(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),p.map(l=>jsxRuntime.jsx(ka,{price:l.price,quantity:l.quantity,side:"bid",maxQty:d,oddsFormatter:n},`bid-${l.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 ka({price:e,quantity:t,side:r,maxQty:n,oddsFormatter:o}){let i=r==="ask",s=Math.min(t/n*100,100),a=i?"bg-bearish/10":"bg-bullish/10",c=i?"text-bearish":"text-bullish",u=on(Math.round(t)),p=Math.round(t*e),d=`$${on(p)}`;return 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 ${c}`,children:o?o(e):Pa(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:d})]})}var oi=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}},sn=4,Ca=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function qm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Gm(e,t){let r=new Date(e);return t===le.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===le.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ta(e){return `${(e*100).toFixed(2)}%`}var Ym=[{range:le.ONE_DAY,label:"1D"},{range:le.ONE_WEEK,label:"1W"},{range:le.ONE_MONTH,label:"1M"},{range:le.ALL,label:"ALL"}];function Qm({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Ym.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 Xm(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(o=>{let i=e.current,s=t.current;if(!i||!s)return;let a=i.getBoundingClientRect(),c=(o.clientX-a.left)/a.width*100;s.style.background=`linear-gradient(to right, transparent ${c}%, rgba(0,0,0,0.55) ${c}%)`,s.style.opacity="1";},[]),n=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function Jm({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let s=new Map;t?.forEach(c=>s.set(c.dataKey,c));let a=o.map(c=>s.get(c.slug)??{dataKey:c.slug,value:void 0,stroke:c.color,color:c.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"?Gm(r,i):r}),a.map(c=>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:c.stroke??c.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(c.dataKey)??c.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:c.value!=null?Ta(c.value):"--"})]},c.dataKey))]})}function Zm({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=react.useState(false),s=react.useRef(null);react.useEffect(()=>{if(!o)return;function u(p){s.current&&!s.current.contains(p.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let a=t.length>=sn,c=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?.outcomes?.[0]?.label??u?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>i(u=>!u),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[c,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 ",sn," markets"]}),e.map((u,p)=>{let d=t.includes(u.slug),f=!d&&a,l=d&&t.length===1,m=r.get(u.slug)??"#6b7280",g=u.outcomes.find(v=>v.label.toLowerCase()==="yes")??u.outcomes[0],h=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{l||f||n(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:f||l?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!f&&!l&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:d?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&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:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),h&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},u.id??`${p}-${u.slug}`)})]})]})}function ef({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",i=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:i!=null?Ta(i):"--"})]})]},n.marketSlug)})})}function tf(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function rf(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),s=Math.min(Math.floor((o+1)*n),e.length),a=e.slice(i,s),c=a.map(u=>u.price).sort((u,p)=>u-p);r.push({timestamp:a[a.length-1].timestamp,price:tf(c)});}return r}function nf(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:rf(a.data,t)})),n=new Set;r.forEach(a=>a.data.forEach(c=>n.add(c.timestamp)));let o=Array.from(n).sort((a,c)=>a-c),i=r.map(a=>{let c=new Map;return a.data.forEach(u=>c.set(u.timestamp,u.price)),{slug:a.marketSlug,map:c}}),s=new Map;return o.map(a=>{let c={timestamp:a};return i.forEach(({slug:u,map:p})=>{let d=p.get(a);if(d!==void 0)s.set(u,d),c[u]=d;else {let f=s.get(u);f!==void 0&&(c[u]=f);}}),c})}function Ea(e){return jsxRuntime.jsx(oi,{children:jsxRuntime.jsx(of,{...e})})}function of({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=react.useMemo(()=>{let w=new Set;return (e.markets??[]).filter(M=>w.has(M.slug)?false:(w.add(M.slug),true))},[e.markets]),s=react.useMemo(()=>[...i].sort((w,M)=>{let $=J=>(J.outcomes.find(ne=>ne.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return $(M)-$(w)}),[i]),[a,c]=react.useState(()=>s.slice(0,sn).map(w=>w.slug));react.useEffect(()=>{let w=new Set(i.map(M=>M.slug));c(M=>{let $=M.filter(J=>w.has(J));return $.length===M.length?M:$.length>0?$:s.slice(0,sn).map(J=>J.slug)});},[i,s]);let[u,p]=react.useState(En),d=react.useMemo(()=>{let w=new Map;return a.forEach((M,$)=>{w.set(M,Ca[$%Ca.length]);}),w},[a]),f=react.useMemo(()=>i.filter(w=>a.includes(w.slug)),[i,a]),{series:l,isLoading:m}=reactPredict.useMarketHistory(f,u),g=t||m,h=react.useMemo(()=>{if(l.length>0&&l.some($=>$.data.length>0))return l;let w=Date.now(),M=864e5;return f.map($=>{let ne=($.outcomes?.find(O=>O.label.toLowerCase()==="yes")??$.outcomes?.[0])?.price??.5;return {marketSlug:$.slug,label:$.outcomes?.[0]?.label??$.question,data:[{timestamp:w-7*M,price:ne},{timestamp:w,price:ne}]}})},[l,f]),v=react.useMemo(()=>u===le.ONE_DAY?96:u===le.ONE_WEEK?168:u===le.ONE_MONTH?180:300,[u]),b=react.useMemo(()=>nf(h,v),[h,v]),N=react.useMemo(()=>{if(b.length===0)return [0,1];let w=1/0,M=-1/0;if(a.forEach(J=>{b.forEach(ne=>{let O=ne[J];O!=null&&(O<w&&(w=O),O>M&&(M=O));});}),!isFinite(w))return [0,1];let $=Math.max((M-w)*.15,.05);return [Math.max(0,w-$),Math.min(1,M+$)]},[b,a]),k=react.useMemo(()=>{let w=new Map;return h.forEach(M=>{M.data.length>0&&w.set(M.marketSlug,M.data[M.data.length-1].price);}),w},[h]),x=react.useMemo(()=>{let w=new Map;return h.forEach(M=>w.set(M.marketSlug,M.label)),w},[h]),y=react.useMemo(()=>h.map(w=>({slug:w.marketSlug,color:d.get(w.marketSlug)??"#6b7280"})),[h,d]),{wrapperRef:P,overlayRef:S,onMouseMove:R,onMouseLeave:I}=Xm(),z=react.useCallback(w=>{c(M=>M.includes(w)?M.length<=1?M:M.filter($=>$!==w):M.length>=sn?M:[...M,w]);},[]),[K,W]=react.useState(null),G=react.useRef(null),Y=react.useRef(""),Q=react.useRef(0),re=!g&&b.length>0;return jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsxRuntime.jsx(ef,{series:h,colorMap:d,displayValues:K??k}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsxRuntime.jsx("div",{ref:P,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:re?w=>{R(w),cancelAnimationFrame(Q.current),Q.current=requestAnimationFrame(()=>{W(G.current);});}:void 0,onMouseLeave:re?()=>{I(),cancelAnimationFrame(Q.current),Y.current="",G.current=null,W(null);}:void 0,children:g?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"}})}):b.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:S,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:b,margin:{top:8,right:16,left:0,bottom:0},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:["dataMin","dataMax"],tickFormatter:w=>qm(w,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:N,tickFormatter:w=>`${Math.round(w*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:w=>{let M=w;if(M.active&&M.payload?.length){let $=M.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if($!==Y.current){Y.current=$;let J=new Map;M.payload.forEach(ne=>{ne.value!=null&&J.set(ne.dataKey,ne.value);}),G.current=J;}}return jsxRuntime.jsx(Jm,{...M,labelMap:x,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),h.map(w=>{let M=d.get(w.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:w.marketSlug,stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:M},connectNulls:true,isAnimationActive:false},w.marketSlug)}),K==null&&b.length>0&&h.map(w=>{let M=b[b.length-1],$=M[w.marketSlug];if($==null)return null;let J=d.get(w.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:M.timestamp,y:$,ifOverflow:"extendDomain",shape:ne=>{let{cx:O,cy:Se}=ne;return O==null||Se==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:O,cy:Se,r:6,fill:J,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:O,cy:Se,r:3.5,fill:J})]})}},`pulse-${w.marketSlug}`)})]})})]})}),jsxRuntime.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[n!=null&&n>0&&jsxRuntime.jsxs("span",{style:{color:"#6b7280",fontSize:12},children:[utils$1.formatAmountInUsd(n)," vol"]}),jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}}),jsxRuntime.jsx(Qm,{value:u,onChange:p}),s.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(Zm,{markets:s,selectedSlugs:a,colorMap:d,onToggle:z})})]})]})]})}function Jn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ra(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function kf(e){return `${parseFloat((e*100).toFixed(2))}%`}function _a(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Zn(e){return e.outcomes?.[0]?.label??e.question}function Sf(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function an(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${s}`}function Ia(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 i=Math.floor(o/864e5),s=Math.floor(o%864e5/36e5),a=Math.floor(o%36e5/6e4),c=Math.floor(o%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(s).padStart(2,"0")}h`),u.push(`${String(a).padStart(2,"0")}m`),u.push(`${String(c).padStart(2,"0")}s`),u.join(" ")}function Oa(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),a=-t.getTimezoneOffset(),c=a>=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${c}${u})`}function Ba({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:n,isCollapsed:o}=hooks.useScrollCollapse(),i=react.useMemo(()=>{let d=[...e.markets||[]],f=d.filter(m=>m.status==="open").sort((m,g)=>Jn(g)-Jn(m)),l=d.filter(m=>m.status!=="open").sort((m,g)=>Jn(g)-Jn(m));return [...f,...l]},[e.markets]),s=e.status==="closed"||e.status==="voided",a=Ia(s?void 0:e.start_at),c=Ia(s?void 0:e.end_at),u=Oa(e.start_at),p=Oa(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:n,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${o?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${o?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!o&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((d,f)=>jsxRuntime.jsxs(react.Fragment,{children:[f>0&&jsxRuntime.jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral truncate",children:d.label})]},d.slug)),jsxRuntime.jsx(Cf,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${o?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||c||s)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?p&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:p})}):a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),u&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:u})]})]}):c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:c})}),p&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:p})]})]}):null}),jsxRuntime.jsx(Ea,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(wf,{markets:i,onTradeAction:t}),jsxRuntime.jsx(Nf,{markets:i,event:e})]})}var Da=5;function wf({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{isDesktop:n}=ui.useScreen(),[o,i]=react.useState(false),[s,a]=react.useState(null),c=react.useMemo(()=>{let h=new Set;return e.filter(v=>h.has(v.slug)?false:(h.add(v.slug),true))},[e]),u=c.find(h=>h.status==="open")?.slug,[p,d]=react.useState(u?`${u}:yes`:null);if(c.length===0)return null;let f=c.length>Da,l=o?c:c.slice(0,Da),m=h=>{a(v=>v===h?null:h);},g=(h,v,b)=>{d(`${h.slug}:${v}`),n&&a(h.slug),t?.(h,v,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:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:l.map((h,v)=>{let b=s===h.slug;return jsxRuntime.jsx(Pf,{market:h,activeYes:p===`${h.slug}:yes`,activeNo:p===`${h.slug}:no`,isExpanded:b,onToggleExpand:()=>m(h.slug),onTradeAction:g},h.id??`${v}-${h.slug}`)})})]}),f&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>i(h=>!h),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function Pf({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:s}=i18n.useTranslation(),a=e.status==="open",c=e.volume?`${utils$1.formatAmountInUsd(e.volume)} vol`:void 0,{data:u}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:e.source,outcome:"yes"},{enabled:a}),{data:p}=reactPredict.useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),d=reactPredict.pickBestAsk(u,"yes")??Ra(e,"yes")??0,f=reactPredict.pickBestAsk(p,"no")??Ra(e,"no");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:o,role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o());},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:Zn(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:Zn(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:kf(d)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:a?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[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",t?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:l=>{l.stopPropagation(),i?.(e,"yes","buy");},children:s("predict.market.action.yes",{price:_a(d)})}),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",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:l=>{l.stopPropagation(),i?.(e,"no","buy");},children:f!=null?s("predict.market.action.no",{price:_a(f)}):s("predict.market.no")})]}):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-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?s("predict.event.status.closed"):e.status==="voided"?s("predict.event.status.voided"):s("predict.event.status.pending")})})})]}),n&&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(Na,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Nf({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[n,o]=react.useState(false),[i,s]=react.useState(false),[a,c]=react.useState(0),u=e.filter(l=>l.rules&&l.rules.length>0||l.description);if(u.length===0)return null;let p=u[a]??u[0],d=p.rules&&p.rules.length>0?p.rules.join(`
|
|
77
77
|
|
|
78
|
-
`):d.description??"";if(!p)return null;let f=p.length>200&&!o?p.slice(0,200)+"...":p;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.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:Gn(d)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:c=>{l(Number(c)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((c,m)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(m===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Gn(c)},String(m)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),p.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(c=>!c),className:"text-xs text-neutral 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(c=>!c),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[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 c=d.status,m=[];return d.created_at&&m.push({label:r("predict.event.timeline.created"),value:an(d.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:an(d.start_at),isActive:c!=="pending"}),c==="voided"?m.push({label:r("predict.event.timeline.voided"),value:an(d.closed_at??d.end_at),isActive:true}):c==="closed"?m.push({label:r("predict.event.timeline.closed"),value:an(d.closed_at??d.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:an(d.end_at),isActive:false}),m})().map((c,m,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 ${c.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),m<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${m<g.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:c.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:c.value})]})]},c.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:d.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:sf(d.source)})]})]})]})]})}function df({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.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function La({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:i}=reactPredict.useEvent({slug:e,source:t});return n?jsxRuntime.jsx(nn,{}):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(Ta,{event:o,onTradeAction:r})}var gf={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}},hf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Dt(e){return gf[e]??hf}function l1({source:e,className:t}){let r=Dt(e);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:r.bgColor,color:r.color},children:[r.icon,r.label]})}var _a="rgba(39,39,42,0.6)",wf="rgba(63,63,70,0.8)";function Pf(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function Oa({eventSlug:e,source:t,limit:r=4,onEventClick:o,onEventHover:n}){let{t:i}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return a||!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("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(l=>jsxRuntime.jsx(Nf,{event:l,onClick:o,onHover:n},`${l.source}-${l.slug}`))})]})}function Nf({event:e,onClick:t,onHover:r}){let{t:o}=i18n.useTranslation(),n=Dt(e.source),i=react.useMemo(()=>Pf(e.volume),[e.volume]),s=e.tags?.[0];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=wf,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=_a;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${_a}`,background:"rgba(24,24,27,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:e.title?.[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:e.title}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:n.color,flexShrink:0},children:[n.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:n.label})]}),jsxRuntime.jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxRuntime.jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",o("predict.event.volume")]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxRuntime.jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function Qn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function I1({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:l,onSetupRequired:u,slippageBps:d}){let{t:p}=i18n.useTranslation(),{isDesktop:f}=ui.useScreen(),{onOpen:c}=uiScaffold.useAsyncModal(Yr),{onOpen:m}=uiScaffold.useAsyncModal(Ho),{data:g,isLoading:v}=reactPredict.useEvent({slug:e,source:t}),b=react.useMemo(()=>{let P=[...g?.markets||[]],O=P.filter(W=>W.status==="open").sort((W,A)=>Qn(A)-Qn(W)),F=P.filter(W=>W.status!=="open").sort((W,A)=>Qn(A)-Qn(W));return [...O,...F]},[g?.markets]),[x,w]=react.useState(null),S=react.useCallback((P,O,F)=>{w(W=>({market:P,outcome:O,side:F,version:(W?.version??0)+1})),!f&&g&&(F==="sell"?m({params:{event:g,market:P,initialOutcome:O,chain:r,slippageBps:d,onSetupRequired:u}}):c({params:{event:g,market:P,initialOutcome:O,chain:r,slippageBps:d,onInsufficientBalance:l}}));},[f,g,r,d,c,m,l,u]),h=x?.market??b[0];if(v){let P=!!s;return f?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(nn,{showBack:P})}),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(ra,{})})})]}):jsxRuntime.jsx(nn,{showBack:P})}let y=x?`${x.market.slug}-${x.version}`:h?.slug??"default",k=x?.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.Button,{as:"a",onPress:s,startContent:jsxRuntime.jsx(ui.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:p("common.back")})}),jsxRuntime.jsx(La,{eventSlug:e,source:t,onTradeAction:S})]}),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:[h&&(k?jsxRuntime.jsx(Wn,{event:g,market:h,initialOutcome:x?.outcome,chain:r,slippageBps:d,onSetupRequired:u},y):jsxRuntime.jsx(In,{event:g,market:h,initialOutcome:x?.outcome,chain:r,slippageBps:d,onInsufficientBalance:l},y)),g&&jsxRuntime.jsx(Oa,{eventSlug:e,source:g.source,onEventClick:n,onEventHover:i})]})]}),g&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:a?a({event:g,walletAddress:o}):jsxRuntime.jsx(Zs,{event:g,walletAddress:o})}),jsxRuntime.jsx(On,{}),jsxRuntime.jsx(Qs,{}),jsxRuntime.jsx(Ds,{})]})}function Da(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Hf(e){switch(e){case le.ONE_DAY:return {interval:"15m",limit:96};case le.ONE_WEEK:return {interval:"1h",limit:168};case le.ONE_MONTH:return {interval:"4h",limit:180};case le.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var z1=e=>{let{candlestickMarketSlugs:t,chartRange:r=Nn,source:o}=e,n=reactPredict.usePredictClient(),i=react.useMemo(()=>Hf(r),[r]),{data:s,isLoading:a,error:l}=reactPredict.useEvent({slug:e.eventSlug,source:o}),u=react.useMemo(()=>{if(!s?.markets)return [];let m=new Set,g=s.markets.filter(b=>m.has(b.slug)?false:(m.add(b.slug),true));return (t&&t.length>0?t.slice(0,4).map(b=>g.find(x=>x.slug===b)).filter(b=>b!==void 0):[...g].sort((b,x)=>Da(x)-Da(b)).slice(0,4)).map(b=>b.slug)},[t,s?.markets]),d=reactQuery.useQueries({queries:u.map(m=>({queryKey:reactPredict.candlesticksQueryKey(m,i),queryFn:()=>n.listCandlesticks(m,i),enabled:u.length>0}))}),p=d.some(m=>m.isLoading),f=react.useMemo(()=>{let m=new Map;return u.forEach((g,v)=>{let b=d[v]?.error;b&&m.set(g,b);}),m},[u,d]),c=react.useMemo(()=>{let m=new Map;return u.forEach((g,v)=>{let b=d[v]?.data;b&&m.set(g,b);}),m},[u,d]);return {event:s,isEventLoading:a,eventError:l,candlestickParams:i,candlesticks:c,isCandlesticksLoading:p,candlestickErrors:f}};function Zo({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:o}=e,n=o.name||o.pseudonym||t,i=react.useMemo(()=>$f(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(zf,{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-neutral",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-neutral",children:[jsxRuntime.jsx(Wf,{className:"size-3.5"}),jsxRuntime.jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function zf({src:e,name:t,className:r}){let o=t.trim().charAt(0).toUpperCase()||"?",n=react.useMemo(()=>Uf(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-white",r),style:{backgroundColor:n},"aria-hidden":true,children:o})}function Wf({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 Uf(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 $f(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 Zf={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},Ha={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},eg=["latest","oldest","mostLiked"],tg=600,rg=112;function ng({slug:e,source:t,limit:r=20,height:o,className:n}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState("latest"),[l,u]=react.useState(false),d=Zf[s],{data:p,isLoading:f,isFetchingNextPage:c,hasNextPage:m,fetchNextPage:g}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:d.order,ascending:d.ascending,holders_only:l}),v=react.useMemo(()=>p?.pages?.flatMap(F=>F.items)??[],[p?.pages]),b=react.useRef(null),{height:x}=hooks.useResizeObserver({ref:b}),w=o??(x||tg),S=reactWindow.useDynamicRowHeight({defaultRowHeight:rg,key:`${e}:${t}:${s}:${l}`}),h=v.length,y=h+(m?1:0),k=react.useCallback(F=>F<h,[h]),P=react.useCallback(async()=>{m&&!c&&await g();},[m,c,g]),O=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:k,loadMoreRows:P,rowCount:y,threshold:5});return jsxRuntime.jsxs("div",{className:ui.cn("flex h-full w-full flex-col",n),children:[jsxRuntime.jsx(ig,{sort:s,onSortChange:a,holdersOnly:l,onHoldersOnlyChange:u}),jsxRuntime.jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:b,children:f?jsxRuntime.jsx(sg,{}):v.length===0?jsxRuntime.jsx(ag,{message:i("predict.comments.empty")}):jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:w},onRowsRendered:O,rowComponent:og,rowCount:y,rowHeight:S,rowProps:{comments:v,itemCount:h,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function og({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(Zo,{comment:i,anonymousLabel:n,isReply:!!i.parent_comment_id})}):null}function ig({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);},u=d=>{d.key==="Escape"&&s(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[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(lg,{className:"size-3.5 text-neutral"}),jsxRuntime.jsx("span",{children:n(Ha[e])}),jsxRuntime.jsx(cg,{className:ui.cn("size-3.5 text-neutral 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:eg.map(l=>{let u=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",u?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx("span",{className:"flex-1 font-medium",children:n(Ha[l])}),u&&jsxRuntime.jsx(za,{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-neutral 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-neutral"),children:r&&jsxRuntime.jsx(za,{className:"size-3 text-background"})}),n("predict.comments.holdersOnly")]})]})}function sg(){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 ag({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-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function lg({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 cg({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 za({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 pg=10,mg=utils.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function to(){let[e,t]=jotai.useAtom(mg),r=react.useCallback(n=>{let i=n.trim();i&&t(s=>{let a=s.filter(l=>l!==i);return [i,...a].slice(0,pg)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function ja({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-neutral",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-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function qa({onSelect:e,className:t}){let{histories:r,clearHistories:o}=to();return jsxRuntime.jsx(ja,{className:ui.cn(t),histories:r,onSelect:e,onClear:o})}function Ga({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:n,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function Ig(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function Ya({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:i}){let{t:s}=i18n.useTranslation(),a=e.tags?.[0],l=Dt(e.source),u=react.useMemo(()=>Ig(e.volume),[e.volume]);return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,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),onClick:d=>{t&&o&&d.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex 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:e.title}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxRuntime.jsxs("span",{className:"text-neutral-400",children:[u," ",s("predict.event.volume")]}),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Qa({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=reactPredict.useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[o]),isLoading:n,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var $g=64;function el({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...i}){let{events:s,isLoading:a,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:d}=Qa(i),p=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:p}),c=react.useCallback(b=>b<s.length,[s]),m=react.useCallback(async()=>{u&&!l&&await d();},[u,l,d]),g=react.useMemo(()=>u?s.length+1:s.length,[s,u]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:c,loadMoreRows:m,rowCount:g,threshold:5});return a?jsxRuntime.jsx(Vg,{className:n}):s.length===0?jsxRuntime.jsx(jg,{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:p,children:jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:f},onRowsRendered:v,rowComponent:Kg,rowCount:g,rowHeight:$g,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Kg({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:i,onHover:s}){let a=r[e];return a?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(Ya,{event:a,href:n?.(a),LinkComponent:i,onSelect:o,onHover:s})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function Vg({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-neutral",children:t("predict.search.loading")})]})}function jg({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-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function ol({onKeywordChange:e}){let[t,r]=react.useState(""),[o,n]=react.useState(""),{addHistory:i}=to(),s=hooks.useCallbackRef(e),a=hooks.useCallbackRef(i),l=react.useMemo(()=>utils$1.debounce(f=>{n(f),s(f),f&&a(f);},500),[s,a]),u=react.useCallback(f=>{r(f),l(f);},[l]),d=react.useCallback(f=>{l.cancel(),r(f),n(f),s(f),f&&a(f);},[l,s,a]),p=react.useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:u,setKeyword:d,clearKeyword:p}}function il({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:i,source:s}){let{text:a,keyword:l,setText:u,setKeyword:d,clearKeyword:p}=ol({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(Ga,{value:a,onValueChange:u,onClear:p,onEscape:i}),!l&&jsxRuntime.jsx(qa,{onSelect:d}),jsxRuntime.jsx(el,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:s})]})}var oi="predict-search";function _k({id:e=oi}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(i0,{...t})})}function i0({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 rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[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(il,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function Wk({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=i18n.useTranslation(),{isDesktop:n}=ui.useScreen(),{onOpen:i,onClose:s}=uiScaffold.useAsyncModal(oi),a=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let d=await i({params:t});d&&a(d);}),u=hooks.useCallbackRef(()=>{s();});return react.useEffect(()=>{let d=p=>{let f=document.activeElement,c=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");p.key==="/"&&!c&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),u());};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d);}},[l,u]),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-neutral",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 si=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],hl=[{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}],ml={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"},fl={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 m0(e,t){if(!e)return "$5K+";let r=hl.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function vl({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:i,onRefresh:s}){let{t:a}=i18n.useTranslation(),[l,u]=react.useState(false),[d,p]=react.useState(false),[f,c]=react.useState(false),[m,g]=react.useState(false),v=react.useRef(null),b=react.useRef(null),x=si.find(h=>h.value===e)??si[0],w=react.useCallback(h=>{v.current&&!v.current.contains(h.target)&&u(false),b.current&&!b.current.contains(h.target)&&p(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)),[w]);let S=react.useCallback(()=>{s?.(),g(true),setTimeout(()=>g(false),700);},[s]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
|
|
78
|
+
`):p.description??"";if(!d)return null;let f=d.length>200&&!n?d.slice(0,200)+"...":d;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.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:Zn(p)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:l=>{c(Number(l)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((l,m)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(m===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Zn(l)},String(m)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),d.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>o(l=>!l),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:()=>s(l=>!l),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[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 l=p.status,m=[];return p.created_at&&m.push({label:r("predict.event.timeline.created"),value:an(p.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:an(p.start_at),isActive:l!=="pending"}),l==="voided"?m.push({label:r("predict.event.timeline.voided"),value:an(p.closed_at??p.end_at),isActive:true}):l==="closed"?m.push({label:r("predict.event.timeline.closed"),value:an(p.closed_at??p.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:an(p.end_at),isActive:false}),m})().map((l,m,g)=>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 ${l.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),m<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${m<g.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:l.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:l.value})]})]},l.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:Sf(p.source)})]})]})]})]})}function Cf({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.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function Ha({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=reactPredict.useEvent({slug:e,source:t});return o?jsxRuntime.jsx(nn,{}):i||!n?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsxRuntime.jsx(Ba,{event:n,onTradeAction:r})}var Rf={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}},_f={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Ut(e){return Rf[e]??_f}function D1({source:e,className:t}){let r=Ut(e);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:r.bgColor,color:r.color},children:[r.icon,r.label]})}var Wa="rgba(39,39,42,0.6)",Hf="rgba(63,63,70,0.8)";function zf(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function $a({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return a||!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("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(c=>jsxRuntime.jsx(Wf,{event:c,onClick:n,onHover:o},`${c.source}-${c.slug}`))})]})}function Wf({event:e,onClick:t,onHover:r}){let{t:n}=i18n.useTranslation(),o=Ut(e.source),i=react.useMemo(()=>zf(e.volume),[e.volume]),s=e.tags?.[0];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:a=>{a.currentTarget.style.borderColor=Hf,r?.(e);},onMouseLeave:a=>{a.currentTarget.style.borderColor=Wa;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${Wa}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[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:e.title}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:o.color,flexShrink:0},children:[o.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:o.label})]}),jsxRuntime.jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxRuntime.jsxs("span",{style:{color:"#a1a1aa"},children:[i," ",n("predict.event.volume")]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxRuntime.jsx("span",{style:{color:"#71717a"},children:s.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function to(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function s2({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:s,renderActivitySection:a,onInsufficientBalance:c,onSetupRequired:u,slippageBps:p}){let{t:d}=i18n.useTranslation(),{isDesktop:f}=ui.useScreen(),{onOpen:l}=uiScaffold.useAsyncModal(Yr),{onOpen:m}=uiScaffold.useAsyncModal(qo),{data:g,isLoading:h}=reactPredict.useEvent({slug:e,source:t}),v=react.useMemo(()=>{let S=[...g?.markets||[]],R=S.filter(z=>z.status==="open").sort((z,K)=>to(K)-to(z)),I=S.filter(z=>z.status!=="open").sort((z,K)=>to(K)-to(z));return [...R,...I]},[g?.markets]),[b,N]=react.useState(null),k=react.useCallback((S,R,I)=>{N(z=>({market:S,outcome:R,side:I,version:(z?.version??0)+1})),!f&&g&&(I==="sell"?m({params:{event:g,market:S,initialOutcome:R,chain:r,slippageBps:p,onSetupRequired:u}}):l({params:{event:g,market:S,initialOutcome:R,chain:r,slippageBps:p,onInsufficientBalance:c}}));},[f,g,r,p,l,m,c,u]),x=b?.market??v[0];if(h){let S=!!s;return f?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(nn,{showBack:S})}),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(ua,{})})})]}):jsxRuntime.jsx(nn,{showBack:S})}let y=b?`${b.market.slug}-${b.version}`:x?.slug??"default",P=b?.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.Button,{as:"a",onPress:s,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:d("common.back")})}),jsxRuntime.jsx(Ha,{eventSlug:e,source:t,onTradeAction:k})]}),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:[x&&(P?jsxRuntime.jsx(jn,{event:g,market:x,initialOutcome:b?.outcome,chain:r,slippageBps:p,onSetupRequired:u},y):jsxRuntime.jsx(Bn,{event:g,market:x,initialOutcome:b?.outcome,chain:r,slippageBps:p,onInsufficientBalance:c},y)),g&&jsxRuntime.jsx($a,{eventSlug:e,source:g.source,onEventClick:o,onEventHover:i})]})]}),g&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:a?a({event:g,walletAddress:n}):jsxRuntime.jsx(la,{event:g,walletAddress:n})}),jsxRuntime.jsx(Hn,{}),jsxRuntime.jsx(ia,{}),jsxRuntime.jsx(Ks,{})]})}function Va(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function tg(e){switch(e){case le.ONE_DAY:return {interval:"15m",limit:96};case le.ONE_WEEK:return {interval:"1h",limit:168};case le.ONE_MONTH:return {interval:"4h",limit:180};case le.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var m2=e=>{let{candlestickMarketSlugs:t,chartRange:r=En,source:n}=e,o=reactPredict.usePredictClient(),i=react.useMemo(()=>tg(r),[r]),{data:s,isLoading:a,error:c}=reactPredict.useEvent({slug:e.eventSlug,source:n}),u=react.useMemo(()=>{if(!s?.markets)return [];let m=new Set,g=s.markets.filter(v=>m.has(v.slug)?false:(m.add(v.slug),true));return (t&&t.length>0?t.slice(0,4).map(v=>g.find(b=>b.slug===v)).filter(v=>v!==void 0):[...g].sort((v,b)=>Va(b)-Va(v)).slice(0,4)).map(v=>v.slug)},[t,s?.markets]),p=reactQuery.useQueries({queries:u.map(m=>({queryKey:reactPredict.candlesticksQueryKey(m,i),queryFn:()=>o.listCandlesticks(m,i),enabled:u.length>0}))}),d=p.some(m=>m.isLoading),f=react.useMemo(()=>{let m=new Map;return u.forEach((g,h)=>{let v=p[h]?.error;v&&m.set(g,v);}),m},[u,p]),l=react.useMemo(()=>{let m=new Map;return u.forEach((g,h)=>{let v=p[h]?.data;v&&m.set(g,v);}),m},[u,p]);return {event:s,isEventLoading:a,eventError:c,candlestickParams:i,candlesticks:l,isCandlesticksLoading:d,candlestickErrors:f}};function ai({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=react.useMemo(()=>ig(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(rg,{src:n.profile_image,name:o,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:o}),jsxRuntime.jsx("span",{className:"ml-auto shrink-0 text-xs text-neutral",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-neutral",children:[jsxRuntime.jsx(ng,{className:"size-3.5"}),jsxRuntime.jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function rg({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=react.useMemo(()=>og(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-white",r),style:{backgroundColor:o},"aria-hidden":true,children:n})}function ng({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 og(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 ig(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let i=Math.floor(o/24);if(i<7)return `${i}d`;let s=Math.floor(i/7);return s<5?`${s}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var gg={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},Ga={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},hg=["latest","oldest","mostLiked"],vg=600,bg=112;function xg({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState("latest"),[c,u]=react.useState(false),p=gg[s],{data:d,isLoading:f,isFetchingNextPage:l,hasNextPage:m,fetchNextPage:g}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:p.order,ascending:p.ascending,holders_only:c}),h=react.useMemo(()=>d?.pages?.flatMap(I=>I.items)??[],[d?.pages]),v=react.useRef(null),{height:b}=hooks.useResizeObserver({ref:v}),N=n??(b||vg),k=reactWindow.useDynamicRowHeight({defaultRowHeight:bg,key:`${e}:${t}:${s}:${c}`}),x=h.length,y=x+(m?1:0),P=react.useCallback(I=>I<x,[x]),S=react.useCallback(async()=>{m&&!l&&await g();},[m,l,g]),R=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:P,loadMoreRows:S,rowCount:y,threshold:5});return jsxRuntime.jsxs("div",{className:ui.cn("flex h-full w-full flex-col",o),children:[jsxRuntime.jsx(kg,{sort:s,onSortChange:a,holdersOnly:c,onHoldersOnlyChange:u}),jsxRuntime.jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:v,children:f?jsxRuntime.jsx(Sg,{}):h.length===0?jsxRuntime.jsx(wg,{message:i("predict.comments.empty")}):jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:N},onRowsRendered:R,rowComponent:yg,rowCount:y,rowHeight:k,rowProps:{comments:h,itemCount:x,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function yg({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.Spinner,{size:"sm"})});let i=r[e];return i?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ai,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function kg({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=i18n.useTranslation(),[i,s]=react.useState(false),a=react.useRef(null);return react.useEffect(()=>{if(!i)return;let c=p=>{a.current&&!a.current.contains(p.target)&&s(false);},u=p=>{p.key==="Escape"&&s(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u);}},[i]),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(c=>!c),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(Pg,{className:"size-3.5 text-neutral"}),jsxRuntime.jsx("span",{children:o(Ga[e])}),jsxRuntime.jsx(Ng,{className:ui.cn("size-3.5 text-neutral 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:hg.map(c=>{let u=c===e;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(c),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",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(Ga[c])}),u&&jsxRuntime.jsx(Ya,{className:"size-4 text-primary"})]},c)})})]}),jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>n(!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-neutral 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-neutral"),children:r&&jsxRuntime.jsx(Ya,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function Sg(){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 wg({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-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:e})]})}function Pg({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 Ng({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 Ya({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 Tg=10,Eg=utils.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function so(){let[e,t]=jotai.useAtom(Eg),r=react.useCallback(o=>{let i=o.trim();i&&t(s=>{let a=s.filter(c=>c!==i);return [i,...a].slice(0,Tg)});},[t]),n=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function tl({histories:e,onSelect:t,onClear:r,className:n}){let{t:o}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.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.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",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-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function rl({onSelect:e,className:t}){let{histories:r,clearHistories:n}=so();return jsxRuntime.jsx(tl,{className:ui.cn(t),histories:r,onSelect:e,onClear:n})}function nl({value:e,onValueChange:t,onClear:r,onEscape:n,className:o}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:o,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.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 Yg(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function ol({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:s}=i18n.useTranslation(),a=e.tags?.[0],c=Ut(e.source),u=react.useMemo(()=>Yg(e.volume),[e.volume]);return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,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),onClick:p=>{t&&n&&p.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex 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:e.title}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:c.color},children:[c.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:c.label})]}),jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxRuntime.jsxs("span",{className:"text-neutral-400",children:[u," ",s("predict.event.volume")]}),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function il({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:a}=reactPredict.useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:react.useMemo(()=>n?.pages.flatMap(u=>u.items).filter(u=>u!=null)??[],[n]),isLoading:o,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:a}}var i0=64;function cl({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:s,isLoading:a,isFetchingNextPage:c,hasNextPage:u,fetchNextPage:p}=il(i),d=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:d}),l=react.useCallback(v=>v<s.length,[s]),m=react.useCallback(async()=>{u&&!c&&await p();},[u,c,p]),g=react.useMemo(()=>u?s.length+1:s.length,[s,u]),h=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:l,loadMoreRows:m,rowCount:g,threshold:5});return a?jsxRuntime.jsx(a0,{className:o}):s.length===0?jsxRuntime.jsx(l0,{className:o}):jsxRuntime.jsx("div",{className:ui.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:f},onRowsRendered:h,rowComponent:s0,rowCount:g,rowHeight:i0,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function s0({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:s}){let a=r[e];return a?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ol,{event:a,href:o?.(a),LinkComponent:i,onSelect:n,onHover:s})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function a0({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-neutral",children:t("predict.search.loading")})]})}function l0({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-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function ml({onKeywordChange:e}){let[t,r]=react.useState(""),[n,o]=react.useState(""),{addHistory:i}=so(),s=hooks.useCallbackRef(e),a=hooks.useCallbackRef(i),c=react.useMemo(()=>utils$1.debounce(f=>{o(f),s(f),f&&a(f);},500),[s,a]),u=react.useCallback(f=>{r(f),c(f);},[c]),p=react.useCallback(f=>{c.cancel(),r(f),o(f),s(f),f&&a(f);},[c,s,a]),d=react.useCallback(()=>p(""),[p]);return {text:t,keyword:n,setText:u,setKeyword:p,clearKeyword:d}}function fl({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:s}){let{text:a,keyword:c,setText:u,setKeyword:p,clearKeyword:d}=ml({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(nl,{value:a,onValueChange:u,onClear:d,onEscape:i}),!c&&jsxRuntime.jsx(rl,{onSelect:p}),jsxRuntime.jsx(cl,{className:"flex-auto min-h-0",keyword:c,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:s})]})}var pi="predict-search";function sS({id:e=pi}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(k0,{...t})})}function k0({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),s=react.useCallback(c=>{n(c);},[n]),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 rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:i?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[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:o("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(fl,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:a})})]})})}function gS({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=i18n.useTranslation(),{isDesktop:o}=ui.useScreen(),{onOpen:i,onClose:s}=uiScaffold.useAsyncModal(pi),a=hooks.useCallbackRef(e),c=hooks.useCallbackRef(async()=>{let p=await i({params:t});p&&a(p);}),u=hooks.useCallbackRef(()=>{s();});return react.useEffect(()=>{let p=d=>{let f=document.activeElement,l=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");d.key==="/"&&!l&&(d.preventDefault(),c()),d.key==="Escape"&&(d.preventDefault(),u());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[c,u]),o?jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",onPress:c,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-neutral",r),children:n("predict.search.placeholder")}):jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:true,onPress:c,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 fi=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],Nl=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],Sl={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},wl={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function E0(e,t){if(!e)return "$5K+";let r=Nl.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Cl({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:s}){let{t:a}=i18n.useTranslation(),[c,u]=react.useState(false),[p,d]=react.useState(false),[f,l]=react.useState(false),[m,g]=react.useState(false),h=react.useRef(null),v=react.useRef(null),b=fi.find(x=>x.value===e)??fi[0],N=react.useCallback(x=>{h.current&&!h.current.contains(x.target)&&u(false),v.current&&!v.current.contains(x.target)&&d(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)),[N]);let k=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
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:
|
|
82
|
+
`}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:h,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:Sl,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(x=>!x),d(false);},children:[jsxRuntime.jsx(L0,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(b.labelKey)}),jsxRuntime.jsx(Pl,{open:c})]}),c&&jsxRuntime.jsx("div",{style:{...wl,width:224,padding:4},children:fi.map(x=>{let y=e===x.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===x.value?n(!r):t(x.value),u(false);},children:[jsxRuntime.jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsxRuntime.jsx(R0,{type:x.icon})}),jsxRuntime.jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500},children:a(x.labelKey)}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:a(x.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"})})]},x.value)})})]}),i&&jsxRuntime.jsxs("div",{ref:v,style:{position:"relative"},children:[jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:Sl,onMouseEnter:x=>{x.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{d(x=>!x),u(false);},children:[jsxRuntime.jsx(_0,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:E0(o,a)}),jsxRuntime.jsx(I0,{onMouseEnter:()=>l(true),onMouseLeave:()=>l(false)}),jsxRuntime.jsx(Pl,{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"})}),a("predict.matches.filter.liquidityFilter")]}),jsxRuntime.jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:a("predict.matches.filter.tooltipDesc")}),jsxRuntime.jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:a("predict.matches.filter.tooltipNote")})]})]})]}),p&&jsxRuntime.jsxs("div",{style:{...wl,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:a("predict.matches.filter.minVolumeEach")})}),jsxRuntime.jsx("div",{style:{padding:4},children:Nl.map(x=>{let y=x.value===0?!o:o===x.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:()=>{i?.(x.value===0?void 0:x.value),d(false);},children:[jsxRuntime.jsx("span",{children:x.labelKey?a(x.labelKey):x.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"})})]},x.value)})})]})]}),s&&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:x=>{x.currentTarget.style.background="rgba(39,39,42,1)",x.currentTarget.style.color="#fff";},onMouseLeave:x=>{x.currentTarget.style.background="rgba(39,39,42,0.6)",x.currentTarget.style.color="#a1a1aa";},onClick:k,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 L0(){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 R0({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 _0(){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 I0({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 Pl({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 F0(e){return utils$1.formatAmountInUsd(e)}var B0=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>utils$1.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$1.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:F0,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Tl({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)}}
|
|
@@ -117,21 +117,21 @@
|
|
|
117
117
|
.matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
|
|
118
118
|
@media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
119
119
|
`}),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,
|
|
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:B0.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))})]})]})}function gi(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function W0(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var _l={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)"}},U0={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)"}},El={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 $0(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var K0={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},V0={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},j0={text:"#9ca3af",icon:"#9ca3af"};function q0(e){return V0[e]??j0}var G0=`
|
|
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 I0({tier:e}){let t=wl[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 O0(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 Pl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:o,getLegHref:n,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:l}=i18n.useTranslation(),u=O0(e);if(!u)return null;let[d,p]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=N0(f),m=wl[c],g=d.best_price!=null&&p.best_price!=null?d.best_price<=p.best_price?d.source:p.source:null,v=d.event_title||p.event_title,b=e.signal_tag??"stale_data",x=yl[b]??yl.stale_data,w=r?.(e),S=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:_0}),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(I0,{tier:c})]}),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:v}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsxRuntime.jsx(kl,{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:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(kl,{leg:p,isCheaper:g===p.source,externalUrlFallback:s?.(e,p.source),internalHref:n?.(e,p),onSelect:o?()=>o(e,p):void 0,LinkComponent:a})]})]}),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"})]}),ai(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"})}),ai(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"})]}),A0(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:x.dot,flexShrink:0}}),l(x.label)]})]})]}),h={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:w||t?"pointer":void 0},y=P=>{let O=P.currentTarget,F=C0[c];O.style.borderColor=F.border,O.style.boxShadow=F.shadow,i?.(e);},k=P=>{let O=P.currentTarget;O.style.borderColor="rgba(39,39,42,0.6)",O.style.boxShadow="none";};return w&&a?jsxRuntime.jsx(a,{href:w,className:"group match-card",children:jsxRuntime.jsx("div",{style:h,onMouseEnter:y,onMouseLeave:k,onClick:()=>t?.(e),children:S})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:h,onMouseEnter:y,onMouseLeave:k,onClick:()=>t?.(e),onKeyDown:P=>{t&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),t(e));},children:S})}function A0(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 kl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:o,onSelect:n,LinkComponent:i}){let{t:s}=i18n.useTranslation(),a=Dt(e.source),l=R0(e.source),u=e.best_price,d=e.outcomes?.[0]?.label??null,p=e.external_url??r,f=M0(e.age_seconds),c=b=>{b.stopPropagation();},m=!!(o||n),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:m?"pointer":void 0,color:"inherit",textDecoration:"none"},v=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:[a.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label}),f&&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:E0[f],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:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),jsxRuntime.jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[ai(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":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),p?jsxRuntime.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:b=>b.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:b=>{b.currentTarget.style.color="#d4d4d8",b.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:b=>{b.currentTarget.style.color="#71717a",b.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:b=>{c(b),n?.();},children:jsxRuntime.jsx("div",{style:g,children:v})}):m?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:g,onClick:b=>{c(b),n?.();},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(b),n?.());},children:v}):jsxRuntime.jsx("div",{style:g,children:v})}var Tl=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,signal:n,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onSelect:u,onHover:d,getMarketHref:p,LinkComponent:f,onStatsChange:c},m){let{t:g}=i18n.useTranslation(),{data:v,hasNextPage:b,fetchNextPage:x,isFetchingNextPage:w,isLoading:S,isPlaceholderData:h,refetch:y}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,signal:n,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[k,P]=react.useState(0),[O,F]=react.useState(false);O&&!h?(F(false),P(te=>te+1)):h&&!O&&F(true),react.useImperativeHandle(m,()=>({refetch:()=>{y();}}),[y]);let W=react.useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),A=v?.pages[0]?.total,G=react.useMemo(()=>{let te=0,N=0,C=0;for(let U of W){let X=U.spread??0;X>te&&(te=X),X>=.03&&C++,U.combined_volume!=null&&(N+=U.combined_volume);}return {activePairs:A??W.length,maxSpread:te,highSpreadCount:C,totalVolume:N}},[W,A]);react.useEffect(()=>{G.activePairs>0&&c?.(G);},[G,c]);let q=react.useRef(null),Y=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let te=q.current;if(!te)return;let N=new IntersectionObserver(C=>{C[0]?.isIntersecting&&b&&!w&&x();},{rootMargin:"200px"});return N.observe(te),()=>N.disconnect()},[b,w,x]),react.useEffect(()=>{if(b)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[b]),S)return jsxRuntime.jsx($0,{});if(W.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 re=!b&&W.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
|
|
127
|
+
`;function Y0({tier:e}){let t=_l[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 Q0(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 Il({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:s,LinkComponent:a}){let{t:c}=i18n.useTranslation(),u=Q0(e);if(!u)return null;let[p,d]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,l=W0(f),m=_l[l],g=p.best_price!=null&&d.best_price!=null?p.best_price<=d.best_price?p.source:d.source:null,h=p.event_title||d.event_title,v=e.signal_tag??"stale_data",b=El[v]??El.stale_data,N=r?.(e),k=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:G0}),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:c("predict.matches.gap")})]}),jsxRuntime.jsx(Y0,{tier:l})]}),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:h}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsxRuntime.jsx(Ll,{leg:p,isCheaper:g===p.source,externalUrlFallback:s?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:a}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(Ll,{leg:d,isCheaper:g===d.source,externalUrlFallback:s?.(e,d.source),internalHref:o?.(e,d),onSelect:n?()=>n(e,d):void 0,LinkComponent:a})]})]}),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"})]}),gi(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"})}),gi(e.combined_volume_24h)," ",c("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxRuntime.jsxs("span",{title:c("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"})]}),X0(c,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:b.dot,flexShrink:0}}),c(b.label)]})]})]}),x={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:N||t?"pointer":void 0},y=S=>{let R=S.currentTarget,I=U0[l];R.style.borderColor=I.border,R.style.boxShadow=I.shadow,i?.(e);},P=S=>{let R=S.currentTarget;R.style.borderColor="rgba(39,39,42,0.6)",R.style.boxShadow="none";};return N&&a?jsxRuntime.jsx(a,{href:N,className:"group match-card",children:jsxRuntime.jsx("div",{style:x,onMouseEnter:y,onMouseLeave:P,onClick:()=>t?.(e),children:k})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:x,onMouseEnter:y,onMouseLeave:P,onClick:()=>t?.(e),onKeyDown:S=>{t&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),t(e));},children:k})}function X0(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 Ll({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:s}=i18n.useTranslation(),a=Ut(e.source),c=q0(e.source),u=e.best_price,p=e.outcomes?.[0]?.label??null,d=e.external_url??r,f=$0(e.age_seconds),l=v=>{v.stopPropagation();},m=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:m?"pointer":void 0,color:"inherit",textDecoration:"none"},h=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:[a.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:c.text,textTransform:"uppercase"},children:a.label}),f&&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:K0[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:[gi(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":"#f4f4f5"},children:u!=null?(u*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:9,color:"#71717a"},children:s("predict.matches.centsYes")})]}),d?jsxRuntime.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer","aria-label":s("predict.matches.viewOn",{platform:a.label}),title:s("predict.matches.viewOn",{platform:a.label}),onClick:v=>v.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.color="#d4d4d8",v.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:v=>{v.currentTarget.style.color="#71717a",v.currentTarget.style.background="transparent";},children: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&&i?jsxRuntime.jsx(i,{href:n,className:"match-card-leg-link",onClick:v=>{l(v),o?.();},children:jsxRuntime.jsx("div",{style:g,children:h})}):m?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:g,onClick:v=>{l(v),o?.();},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),l(v),o?.());},children:h}):jsxRuntime.jsx("div",{style:g,children:h})}var Bl=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:c,onSelect:u,onHover:p,getMarketHref:d,LinkComponent:f,onStatsChange:l},m){let{t:g}=i18n.useTranslation(),{data:h,hasNextPage:v,fetchNextPage:b,isFetchingNextPage:N,isLoading:k,isPlaceholderData:x,refetch:y}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[P,S]=react.useState(0),[R,I]=react.useState(false);R&&!x?(I(false),S(re=>re+1)):x&&!R&&I(true),react.useImperativeHandle(m,()=>({refetch:()=>{y();}}),[y]);let z=react.useMemo(()=>h?.pages.flatMap(re=>re.items??[])??[],[h]),K=h?.pages[0]?.total,W=react.useMemo(()=>{let re=0,w=0,M=0;for(let $ of z){let J=$.spread??0;J>re&&(re=J),J>=.03&&M++,$.combined_volume!=null&&(w+=$.combined_volume);}return {activePairs:K??z.length,maxSpread:re,highSpreadCount:M,totalVolume:w}},[z,K]);react.useEffect(()=>{W.activePairs>0&&l?.(W);},[W,l]);let G=react.useRef(null),Y=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let re=G.current;if(!re)return;let w=new IntersectionObserver(M=>{M[0]?.isIntersecting&&v&&!N&&b();},{rootMargin:"200px"});return w.observe(re),()=>w.disconnect()},[v,N,b]),react.useEffect(()=>{if(v)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[v]),k)return jsxRuntime.jsx(ih,{});if(z.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 Q=!v&&z.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:v?.pages.map(te=>te.items?.map((N,C)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${C*35}ms both`},children:jsxRuntime.jsx(Pl,{match:N,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:l,onHover:d,onSelect:u,getMarketHref:p,LinkComponent:f})},`${k}-${N.match_id}-${N.source_a}-${N.market_a?.slug??C}`)))}),jsxRuntime.jsxs("div",{ref:q,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)}}"}),w&&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"})}),g("predict.matches.loadMore")]})]}),re&&jsxRuntime.jsx(U0,{onScrollToTop:Y})]})});function U0({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 $0(){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(K0,{index:t},t))})]})}function K0({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(o=>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}})]},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 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 Q0={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function X0(){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 J0({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$1.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(X0,{})]})]})]})]})}function ES({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:l}){let{t:u}=i18n.useTranslation(),[d,p]=react.useState("spread"),[f,c]=react.useState(false),[m,g]=react.useState(void 0),[v,b]=react.useState(),x=react.useRef(null),w=react.useCallback(k=>{p(k);},[]),S=react.useCallback(k=>{c(k);},[]),h=react.useCallback(k=>{react.startTransition(()=>{b(k);});},[]),y=react.useCallback(()=>{x.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:h?.pages.map(re=>re.items?.map((w,M)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${M*35}ms both`},children:jsxRuntime.jsx(Il,{match:w,onSelectMatch:i,getMatchHref:s,onSelectLeg:a,getLegHref:c,onHover:p,onSelect:u,getMarketHref:d,LinkComponent:f})},`${P}-${w.match_id}-${w.source_a}-${w.market_a?.slug??M}`)))}),jsxRuntime.jsxs("div",{ref:G,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)}}"}),N&&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"})}),g("predict.matches.loadMore")]})]}),Q&&jsxRuntime.jsx(oh,{onScrollToTop:Y})]})});function oh({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 ih(){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(sh,{index:t},t))})]})}function sh({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 ph={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function mh(){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 fh({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$1.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(mh,{})]})]})]})]})}function rw({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,bgImageSrc:c}){let{t:u}=i18n.useTranslation(),[p,d]=react.useState("spread"),[f,l]=react.useState(false),[m,g]=react.useState(void 0),[h,v]=react.useState(),b=react.useRef(null),N=react.useCallback(P=>{d(P);},[]),k=react.useCallback(P=>{l(P);},[]),x=react.useCallback(P=>{react.startTransition(()=>{v(P);});},[]),y=react.useCallback(()=>{b.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(xl,{stats:v})})]}),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(Q0[d])}),v&&v.activePairs>0&&jsxRuntime.jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:v.activePairs})})]})]}),jsxRuntime.jsx(vl,{sortBy:d,onSortChange:w,sortAsc:f,onSortAscChange:S,minVolume:m,onMinVolumeChange:g,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(Tl,{ref:x,sortBy:d,sortAsc:f,minVolume:m,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:o,onHover:n,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:h})]}),jsxRuntime.jsx(J0,{stats:v})]})}function ci(e){return e==null?"-":utils$1.formatAmountInUsd(e)}var th={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},rh={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function nh(e){return th[e]??rh}function oh(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 ih(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 AS({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=i18n.useTranslation(),i=react.useMemo(()=>oh(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,l]=react.useMemo(()=>ih(e,i),[e,i]),u=s!=null&&s>=3;a.yesPrice!=null&&l.yesPrice!=null?a.source==="kalshi"?a.yesPrice>l.yesPrice:l.yesPrice>a.yesPrice:false;let p=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,f=p?Dt(p.source):null,c=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:m=>{let g=m.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:m=>{let g=m.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[s!=null&&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)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[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:"#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(_l,{data:a,isCheaper:p===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsxRuntime.jsx(_l,{data:l,isCheaper:p===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),p&&f&&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 ${c==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:c==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>p.event&&t?.(p.event),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:c==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children: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:c==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:p.source.charAt(0).toUpperCase()+p.source.slice(1),spread:s.toFixed(1)})}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:c==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[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"})]}),ci(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"})}),ci(e.combined_volume_24h)," ",n("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),"%"," ",n("predict.matches.match")]})]})]})}function _l({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:i}=i18n.useTranslation(),s=Dt(e.source),a=nh(e.source),l=e.event?o?.(e.event):void 0,u=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:"#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?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxRuntime.jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[ci(e.volume)," ",i("predict.matches.volume")]})]});return l&&n?jsxRuntime.jsx(n,{href:l,className:"block",children:u}):u}function ch(e){return utils$1.formatAmountInUsd(e)}function WS({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(oo,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsxRuntime.jsx(di,{}),jsxRuntime.jsx(oo,{label:r("predict.matches.stats.totalVolume"),value:ch(o.totalVolume)}),jsxRuntime.jsx(di,{}),jsxRuntime.jsx(oo,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsxRuntime.jsx(di,{}),jsxRuntime.jsx(oo,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function oo({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 di(){return jsxRuntime.jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Al(e){return `${(e*100).toFixed(1)}\xA2`}function dh(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function VS({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",dh(e)),children:Al(e)}),o&&jsxRuntime.jsxs("span",{className:"text-xs text-green-500/80",children:["+",Al(t)]})]})}var mn=10,hh=64,Hl=40,io=48;function zl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=i18n.useTranslation(),[n,i]=react.useState(1),{data:s,isLoading:a,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:d}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:p,isLoading:f,fetchNextPage:c,hasNextPage:m,isFetchingNextPage:g}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=a||f,b=d||g,x=u||m,w=react.useMemo(()=>{let A=[];return s?.pages&&A.push(...s.pages.flatMap(G=>G.items)),p?.pages&&A.push(...p.pages.flatMap(G=>G.items)),A.sort((G,q)=>(q.timestamp??0)-(G.timestamp??0)),A},[s,p]),S=Math.max(1,Math.ceil(w.length/mn)+(x?1:0)),h=(n-1)*mn,y=w.slice(h,h+mn),k=react.useCallback(()=>{i(A=>Math.max(1,A-1));},[]),P=react.useCallback(async()=>{n*mn>=w.length&&x&&(u&&await l(),m&&await c()),i(G=>G+1);},[n,w.length,x,u,m,l,c]),O=n>1,F=n*mn<w.length||x;if(v)return jsxRuntime.jsx(Sh,{height:r});if(w.length===0&&!x)return jsxRuntime.jsx(kh,{message:o("predict.profile.noHistory"),height:r});let W=r-Hl-io;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:Hl},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:W},children:[y.map((A,G)=>jsxRuntime.jsx(vh,{trade:A},A.id??`${h+G}`)),b&&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:io},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!O,onClick:k,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",O?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(S,5)},(A,G)=>{let q=G+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>i(q),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",q===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:q},q)}),jsxRuntime.jsxs("button",{type:"button",disabled:!F,onClick:P,className:ui.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:[o("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-io},children:y.map((A,G)=>jsxRuntime.jsx(bh,{trade:A},A.id??`m-${h+G}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:io},children:[jsxRuntime.jsx("button",{type:"button",disabled:!O,onClick:k,className:ui.cn("text-sm cursor-pointer",O?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsxRuntime.jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsxRuntime.jsx("button",{type:"button",disabled:!F,onClick:P,className:ui.cn("text-sm cursor-pointer",F?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function vh({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=Wl(e.type,t),a=r||o,l=a?"+":"-",u=a?"text-success":"text-foreground",d=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,f=e.outcome??"",c=Vl(e.timestamp),m=Ul(e),g=xh(e),v=yh(e);return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:hh},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:[p&&jsxRuntime.jsx("img",{src:p,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-neutral",children:[f&&jsxRuntime.jsx("span",{className:"mr-1",children:f}),jsxRuntime.jsx("span",{children:c})]})]})]})}),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:Kl(n)}),jsxRuntime.jsx("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",u),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-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.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($l,{})})})]})}function bh({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=Wl(e.type,t),a=e.event?.title??e.market?.question??"\u2014",l=Vl(e.timestamp),u=Ul(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-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.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-neutral",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-neutral",children:t("predict.profile.price")}),jsxRuntime.jsx("span",{className:"font-mono text-foreground",children:Kl(n)})]}),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:i>0?`$${i.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($l,{})})]})]})}function Wl(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 Ul(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function xh(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 yh(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function $l(){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 kh({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Sh({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 Kl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Vl(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?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}var fn=10,Th=64,ql=40,so=48;function Yl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=i18n.useTranslation(),n=reactPredict.useCancelOrder(),[i,s]=react.useState(1),{data:a,isLoading:l,fetchNextPage:u,hasNextPage:d,isFetchingNextPage:p}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:c,fetchNextPage:m,hasNextPage:g,isFetchingNextPage:v}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),b=l||c,x=p||v,w=d||g,S=react.useMemo(()=>{let q=[],Y=new Set(["live","open","submitted","pending"]);return a?.pages&&q.push(...a.pages.flatMap(re=>re.items).filter(re=>Y.has(re.status))),f?.pages&&q.push(...f.pages.flatMap(re=>re.items).filter(re=>Y.has(re.status))),q},[a,f]),h=react.useCallback(q=>{n.mutate({source:q.source,id:q.id});},[n]),y=Math.max(1,Math.ceil(S.length/fn)+(w?1:0)),k=(i-1)*fn,P=S.slice(k,k+fn),O=react.useCallback(()=>{s(q=>Math.max(1,q-1));},[]),F=react.useCallback(async()=>{i*fn>=S.length&&w&&(d&&await u(),g&&await m()),s(Y=>Y+1);},[i,S.length,w,d,g,u,m]),W=i>1,A=i*fn<S.length||w;if(b)return jsxRuntime.jsx(Ih,{height:r});if(S.length===0&&!w)return jsxRuntime.jsx(_h,{message:o("predict.profile.noOrders"),height:r});let G=r-ql-so;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:ql},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:G},children:[P.map(q=>jsxRuntime.jsx(Lh,{order:q,onCancel:h},q.id)),x&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsx(Gl,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:W,canGoNext:A,onPrev:O,onNext:F,onPage:s,t:o}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-so},children:P.map(q=>jsxRuntime.jsx(Rh,{order:q,onCancel:h},q.id))}),jsxRuntime.jsx(Gl,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:W,canGoNext:A,onPrev:O,onNext:F,onPage:s,t:o,compact:true})]})}function Lh({order:e,onCancel:t}){let{t:r}=i18n.useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Th},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",o?"text-success":"text-danger"),children:r(o?"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?Ql(n):"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function Rh({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-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:n>0?Ql(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 Gl({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:i,onNext:s,onPage:a,t:l,compact:u}){return u?jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:so},children:[jsxRuntime.jsx("button",{type:"button",disabled:!o,onClick:i,className:ui.cn("text-sm cursor-pointer",o?"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:!n,onClick:s,className:ui.cn("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:so},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-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(d,p)=>{let f=p+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(f),className:ui.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:!n,onClick:s,className:ui.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:[l("predict.profile.next")," \u2192"]})]})}function _h({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Ih({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 Ql(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var gi=10,Fh=64,Xl=40,ao=48;function Jl({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(Wh,{height:r});if(e.length===0)return jsxRuntime.jsx(zh,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/gi)),d=(s-1)*gi,p=e.slice(d,d+gi),f=s>1,c=s<u,m=r-Xl-ao;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:Xl},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:m},children:p.map((g,v)=>jsxRuntime.jsx(Bh,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??d+v}`))}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:ao},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!f,onClick:()=>a(g=>Math.max(1,g-1)),className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,v)=>{let b=v+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(b),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",b===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:b},b)}),jsxRuntime.jsxs("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-ao},children:p.map((g,v)=>jsxRuntime.jsx(Hh,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${d+v}`}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:ao},children:[jsxRuntime.jsx("button",{type:"button",disabled:!f,onClick:()=>a(g=>Math.max(1,g-1)),className:ui.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:s}),jsxRuntime.jsx("button",{type:"button",disabled:!c,onClick:()=>a(g=>g+1),className:ui.cn("text-sm cursor-pointer",c?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Bh({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,u=e.size,d=n>0?"text-success":n<0?"text-danger":"text-foreground",p=n>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,m=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?Uh(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:Fh},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:[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:f}),jsxRuntime.jsxs("span",{className:"text-[11px] text-neutral",children:[jsxRuntime.jsx("span",{className:ui.cn("font-medium",m.toLowerCase()==="yes"?"text-success":"text-danger"),children:m}),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-neutral",children:o("predict.profile.contracts",{count:Gr(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:hi(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:hi(a)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",d),children:[jsxRuntime.jsxs("span",{children:[p,"$",Math.abs(n).toFixed(2)]}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.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:v}),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"}),o("predict.profile.close")]})})]})}function Hh({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?"+":"",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.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(lo,{label:o("predict.profile.totalSize"),value:Gr(e.size)}),jsxRuntime.jsx(lo,{label:o("predict.profile.markPrice"),value:hi(s)}),jsxRuntime.jsx(lo,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:a}),jsxRuntime.jsx(lo,{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 lo({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.cn("font-mono text-foreground",r),children:t})]})}function zh({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Wh({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 hi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Uh(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?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${i}/${s} (${l}${u})`}catch{return "\u2014"}}function ec({positions:e,trades:t,isLoading:r}){let{t:o}=i18n.useTranslation(),n=react.useMemo(()=>{let a=0,l=0;for(let c of e)a+=c.realized_pnl??0,l+=c.current_value??c.size*(c.current_price??0);let u=0,d=0,p=0;for(let c of t)u+=c.usd_size??0,c.type==="REDEEM"&&(p++,(c.usd_size??0)>0&&d++);let f=p>0?`${d} / ${p}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:u,winRateStr:f}},[e,t]),i=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",s=n.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:o("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",i),children:[s,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsxRuntime.jsx(bi,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsxRuntime.jsx(bi,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsxRuntime.jsx(bi,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function bi({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.Skeleton,{className:"h-6 w-14 rounded-md"}):jsxRuntime.jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var xi=600;function Qh({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=i18n.useTranslation(),[i,s]=react.useState("positions"),a=!!(e||t),{data:l,isLoading:u}=reactPredict.usePositions({source:"kalshi",user:e??""}),{data:d,isLoading:p}=reactPredict.usePositions({source:"polymarket",user:t??""}),f=react.useMemo(()=>{let k=[];return l?.positions&&k.push(...l.positions),d?.positions&&k.push(...d.positions),k},[l,d]),c=u||p,{data:m,isLoading:g}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:b}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),x=react.useMemo(()=>[...m?.pages?.flatMap(P=>P.items)??[],...v?.pages?.flatMap(P=>P.items)??[]],[m,v]),w=c||g||b,S=f.length,y=[{key:"positions",label:S>0?`${n("predict.profile.positionsTab")} (${S})`: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(ec,{positions:f,trades:x,isLoading:w}),jsxRuntime.jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(k.key),className:ui.cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===k.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:k.label},k.key))}),jsxRuntime.jsxs("div",{className:"py-2",children:[i==="positions"&&jsxRuntime.jsx(Jl,{positions:f,isLoading:c,listHeight:xi,onClosePosition:r,onEventClick:o}),i==="orders"&&jsxRuntime.jsx(Yl,{solanaAddress:e,evmAddress:t,listHeight:xi}),i==="history"&&jsxRuntime.jsx(zl,{solanaAddress:e,evmAddress:t,listHeight:xi})]})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}function Uw({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(false),[l,u]=react.useState(null),[d,p]=react.useState(false),f=r||d,c=o||d,m=f?"done":s?"running":"pending",g=c?"done":f&&s?"running":"pending",v=f&&c,b=react.useCallback(async()=>{u(null),p(false),a(true);try{await n(),p(!0);}catch(h){u(h instanceof Error?h.message:String(h));}finally{a(false);}},[n]),x=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:m},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],w=()=>{v?t():b();},S=i(v?"predict.setup.done":"predict.setup.setupButton");return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:h=>{h||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.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:i("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:i("predict.setup.modalDescription")}),jsxRuntime.jsx("div",{className:"space-y-2.5",children:x.map((h,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(tv,{index:y+1,status:h.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:h.label}),jsxRuntime.jsx("span",{className:`text-[11px] leading-none ${h.status==="done"?"text-[#c7ff2e]":h.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:h.status==="done"?i("predict.setup.stepComplete"):h.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsxRuntime.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:h.desc})]})]},h.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:w,disabled:s,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children: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")]}):S}),!v&&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:i("common.cancel")})]})]})})})}function tv({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,"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,"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,"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,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});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=
|
|
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:[c&&jsxRuntime.jsx("img",{src:c,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),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(Tl,{stats:h})})]}),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(ph[p])}),h&&h.activePairs>0&&jsxRuntime.jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:u("predict.matches.pairsFound",{count:h.activePairs})})]})]}),jsxRuntime.jsx(Cl,{sortBy:p,onSortChange:N,sortAsc:f,onSortAscChange:k,minVolume:m,onMinVolumeChange:g,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(Bl,{ref:b,sortBy:p,sortAsc:f,minVolume:m,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:s,LinkComponent:a,onStatsChange:x})]}),jsxRuntime.jsx(fh,{stats:h})]})}function vi(e){return e==null?"-":utils$1.formatAmountInUsd(e)}var vh={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"}},bh={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 xh(e){return vh[e]??bh}function yh(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 kh(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),o=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let c=a.outcomes[0];return {name:c.label||null,price:c.best_ask??c.price??null}},i=o(t?.market_a),s=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:n?.event?.volume??null,event:n?.event}]}function cw({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=i18n.useTranslation(),i=react.useMemo(()=>yh(e),[e]),s=e.max_spread!=null?e.max_spread*100:null,[a,c]=react.useMemo(()=>kh(e,i),[e,i]),u=s!=null&&s>=3;a.yesPrice!=null&&c.yesPrice!=null?a.source==="kalshi"?a.yesPrice>c.yesPrice:c.yesPrice>a.yesPrice:false;let d=a.yesPrice!=null&&c.yesPrice!=null?a.yesPrice<=c.yesPrice?a:c:null,f=d?Ut(d.source):null,l=u?"amber":"violet";return 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:m=>{let g=m.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:m=>{let g=m.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[s!=null&&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)":s>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":s>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":s>=2?"#a684ff":"#9ca3af"},children:[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:"#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(Wl,{data:a,isCheaper:d===a,onSelect:t,getEventHref:r,LinkComponent:n}),jsxRuntime.jsx(Wl,{data:c,isCheaper:d===c,onSelect:t,getEventHref:r,LinkComponent:n})]}),d&&f&&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 ${l==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:l==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>d.event&&t?.(d.event),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:l==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children: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:l==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:d.source.charAt(0).toUpperCase()+d.source.slice(1),spread:s.toFixed(1)})}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:l==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[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"})]}),vi(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"})}),vi(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 Wl({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=i18n.useTranslation(),s=Ut(e.source),a=xh(e.source),c=e.event?n?.(e.event):void 0,u=jsxRuntime.jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:c||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[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:"#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?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxRuntime.jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[vi(e.volume)," ",i("predict.matches.volume")]})]});return c&&o?jsxRuntime.jsx(o,{href:c,className:"block",children:u}):u}function Nh(e){return utils$1.formatAmountInUsd(e)}function gw({matches:e,total:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>{let o=0,i=0,s=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>o&&(o=a.max_spread),a.combined_volume!=null&&(i+=a.combined_volume);for(let c of a.entries)s.add(typeof c.source=="string"?c.source:"");}return {count:t??e.length,maxSpread:o,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(co,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsxRuntime.jsx(bi,{}),jsxRuntime.jsx(co,{label:r("predict.matches.stats.totalVolume"),value:Nh(n.totalVolume)}),jsxRuntime.jsx(bi,{}),jsxRuntime.jsx(co,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsxRuntime.jsx(bi,{}),jsxRuntime.jsx(co,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function co({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 bi(){return jsxRuntime.jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Kl(e){return `${(e*100).toFixed(1)}\xA2`}function Ch(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function xw({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=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",Ch(e)),children:Kl(e)}),n&&jsxRuntime.jsxs("span",{className:"text-xs text-green-500/80",children:["+",Kl(t)]})]})}var mn=10,_h=64,Gl=40,uo=48;function Yl({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),[o,i]=react.useState(1),{data:s,isLoading:a,fetchNextPage:c,hasNextPage:u,isFetchingNextPage:p}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:d,isLoading:f,fetchNextPage:l,hasNextPage:m,isFetchingNextPage:g}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),h=a||f,v=p||g,b=u||m,N=react.useMemo(()=>{let K=[];return s?.pages&&K.push(...s.pages.flatMap(W=>W.items)),d?.pages&&K.push(...d.pages.flatMap(W=>W.items)),K.sort((W,G)=>(G.timestamp??0)-(W.timestamp??0)),K},[s,d]),k=Math.max(1,Math.ceil(N.length/mn)+(b?1:0)),x=(o-1)*mn,y=N.slice(x,x+mn),P=react.useCallback(()=>{i(K=>Math.max(1,K-1));},[]),S=react.useCallback(async()=>{o*mn>=N.length&&b&&(u&&await c(),m&&await l()),i(W=>W+1);},[o,N.length,b,u,m,c,l]),R=o>1,I=o*mn<N.length||b;if(h)return jsxRuntime.jsx(Bh,{height:r});if(N.length===0&&!b)return jsxRuntime.jsx(Fh,{message:n("predict.profile.noHistory"),height:r});let z=r-Gl-uo;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:Gl},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:z},children:[y.map((K,W)=>jsxRuntime.jsx(Ih,{trade:K},K.id??`${x+W}`)),v&&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:uo},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!R,onClick:P,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(k,5)},(K,W)=>{let G=W+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>i(G),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",G===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:G},G)}),jsxRuntime.jsxs("button",{type:"button",disabled:!I,onClick:S,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",I?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-uo},children:y.map((K,W)=>jsxRuntime.jsx(Oh,{trade:K},K.id??`m-${x+W}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:uo},children:[jsxRuntime.jsx("button",{type:"button",disabled:!R,onClick:P,className:ui.cn("text-sm cursor-pointer",R?"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:!I,onClick:S,className:ui.cn("text-sm cursor-pointer",I?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Ih({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=Ql(e.type,t),a=r||n,c=a?"+":"-",u=a?"text-success":"text-foreground",p=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.outcome??"",l=ec(e.timestamp),m=Xl(e),g=Dh(e),h=Ah(e);return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:_h},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:[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:p}),jsxRuntime.jsxs("span",{className:"text-[11px] text-neutral",children:[f&&jsxRuntime.jsx("span",{className:"mr-1",children:f}),jsxRuntime.jsx("span",{children:l})]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:jsxRuntime.jsx("span",{className:ui.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:s}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Zl(o)}),jsxRuntime.jsx("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",u),children:i>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c,"$",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-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:h!==null?`$${h.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(Jl,{})})})]})}function Oh({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,s=Ql(e.type,t),a=e.event?.title??e.market?.question??"\u2014",c=ec(e.timestamp),u=Xl(e);return 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-neutral whitespace-nowrap",children:c})]}),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.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:s})]}),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:Zl(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:i>0?`$${i.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(Jl,{})})]})]})}function Ql(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function Xl(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Dh(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 Ah(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 Jl(){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 Fh({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Bh({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 Zl(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ec(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),c=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${c}${u})`}var fn=10,Vh=64,rc=40,po=48;function oc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),o=reactPredict.useCancelOrder(),[i,s]=react.useState(1),{data:a,isLoading:c,fetchNextPage:u,hasNextPage:p,isFetchingNextPage:d}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:l,fetchNextPage:m,hasNextPage:g,isFetchingNextPage:h}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),v=c||l,b=d||h,N=p||g,k=react.useMemo(()=>{let G=[],Y=new Set(["live","open","submitted","pending"]);return a?.pages&&G.push(...a.pages.flatMap(Q=>Q.items).filter(Q=>Y.has(Q.status))),f?.pages&&G.push(...f.pages.flatMap(Q=>Q.items).filter(Q=>Y.has(Q.status))),G},[a,f]),x=react.useCallback(G=>{o.mutate({source:G.source,id:G.id});},[o]),y=Math.max(1,Math.ceil(k.length/fn)+(N?1:0)),P=(i-1)*fn,S=k.slice(P,P+fn),R=react.useCallback(()=>{s(G=>Math.max(1,G-1));},[]),I=react.useCallback(async()=>{i*fn>=k.length&&N&&(p&&await u(),g&&await m()),s(Y=>Y+1);},[i,k.length,N,p,g,u,m]),z=i>1,K=i*fn<k.length||N;if(v)return jsxRuntime.jsx(Yh,{height:r});if(k.length===0&&!N)return jsxRuntime.jsx(Gh,{message:n("predict.profile.noOrders"),height:r});let W=r-rc-po;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:rc},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:W},children:[S.map(G=>jsxRuntime.jsx(jh,{order:G,onCancel:x},G.id)),b&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsx(nc,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:z,canGoNext:K,onPrev:R,onNext:I,onPage:s,t:n}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-po},children:S.map(G=>jsxRuntime.jsx(qh,{order:G,onCancel:x},G.id))}),jsxRuntime.jsx(nc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:z,canGoNext:K,onPrev:R,onNext:I,onPage:s,t:n,compact:true})]})}function jh({order:e,onCancel:t}){let{t:r}=i18n.useTranslation(),n=e.side==="BUY",o=e.price?parseFloat(e.price):0,i=e.in_amount?parseFloat(e.in_amount):o*parseFloat(e.original_size??"0");return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Vh},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",n?"text-success":"text-danger"),children:r(n?"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:o>0?ic(o):"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function qh({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.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?ic(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 nc({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:s,onPage:a,t:c,compact:u}){return u?jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:po},children:[jsxRuntime.jsx("button",{type:"button",disabled:!n,onClick:i,className:ui.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:s,className:ui.cn("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 shrink-0",e),style:{height:po},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!n,onClick:i,className:ui.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 ",c("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,d)=>{let f=d+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(f),className:ui.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:s,className:ui.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:[c("predict.profile.next")," \u2192"]})]})}function Gh({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Yh({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 ic(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var wi=10,Zh=64,sc=40,mo=48;function ac({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(1),c=react.useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsxRuntime.jsx(nv,{height:r});if(e.length===0)return jsxRuntime.jsx(rv,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/wi)),p=(s-1)*wi,d=e.slice(p,p+wi),f=s>1,l=s<u,m=r-sc-mo;return 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:sc},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:n&&e.length>0&&jsxRuntime.jsx("button",{type:"button",onClick:c,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:m},children:d.map((g,h)=>jsxRuntime.jsx(ev,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??p+h}`))}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:mo},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!f,onClick:()=>a(g=>Math.max(1,g-1)),className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",f?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",i("predict.profile.previous")]}),Array.from({length:Math.min(u,5)},(g,h)=>{let v=h+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>a(v),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",v===s?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:v},v)}),jsxRuntime.jsxs("button",{type:"button",disabled:!l,onClick:()=>a(g=>g+1),className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",l?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-mo},children:d.map((g,h)=>jsxRuntime.jsx(tv,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${p+h}`}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:mo},children:[jsxRuntime.jsx("button",{type:"button",disabled:!f,onClick:()=>a(g=>Math.max(1,g-1)),className:ui.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:s}),jsxRuntime.jsx("button",{type:"button",disabled:!l,onClick:()=>a(g=>g+1),className:ui.cn("text-sm cursor-pointer",l?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function ev({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.avg_price??0,a=e.current_price??0,c=e.current_value??e.size*a,u=e.size,p=o>0?"text-success":o<0?"text-danger":"text-foreground",d=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",l=e.event?.image_url,m=e.side,g=e.market?.outcomes?.[0]?.label??"",h=e.market?.end_at?ov(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:Zh},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:[l&&jsxRuntime.jsx("img",{src:l,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.cn("font-medium",m.toLowerCase()==="yes"?"text-success":"text-danger"),children:m}),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:["$",c.toFixed(2)]}),jsxRuntime.jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count:qr(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:Pi(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Pi(a)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",p),children:[jsxRuntime.jsxs("span",{children:[d,"$",Math.abs(o).toFixed(2)]}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,i.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:h}),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 tv({position:e,onClose:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,s=e.current_price??0,a=o>0?"text-success":o<0?"text-danger":"text-foreground",c=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.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(fo,{label:n("predict.profile.totalSize"),value:qr(e.size)}),jsxRuntime.jsx(fo,{label:n("predict.profile.markPrice"),value:Pi(s)}),jsxRuntime.jsx(fo,{label:n("predict.profile.pnl"),value:`${c}$${Math.abs(o).toFixed(2)} (${c}${i.toFixed(1)}%)`,className:a}),jsxRuntime.jsx(fo,{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 fo({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.cn("font-mono text-foreground",r),children:t})]})}function rv({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function nv({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 Pi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ov(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear(),a=t.getTimezoneOffset(),c=a<=0?"+":"-",u=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${s} (${c}${u})`}catch{return "\u2014"}}function cc({positions:e,trades:t,isLoading:r}){let{t:n}=i18n.useTranslation(),o=react.useMemo(()=>{let a=0,c=0;for(let l of e)a+=l.realized_pnl??0,c+=l.current_value??l.size*(l.current_price??0);let u=0,p=0,d=0;for(let l of t)u+=l.usd_size??0,l.type==="REDEEM"&&(d++,(l.usd_size??0)>0&&p++);let f=d>0?`${p} / ${d}`:"0 / 0";return {realizedPnl:a,positionsValue:c,volume:u,winRateStr:f}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",s=o.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:n("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",i),children:[s,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsxRuntime.jsx(Ci,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsxRuntime.jsx(Ci,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsxRuntime.jsx(Ci,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function Ci({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.Skeleton,{className:"h-6 w-14 rounded-md"}):jsxRuntime.jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var Mi=600;function pv({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=i18n.useTranslation(),[i,s]=react.useState("positions"),a=!!(e||t),{data:c,isLoading:u}=reactPredict.usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:d}=reactPredict.usePositions({source:"polymarket",user:t??""}),f=react.useMemo(()=>{let P=[];return c?.positions&&P.push(...c.positions),p?.positions&&P.push(...p.positions),P},[c,p]),l=u||d,{data:m,isLoading:g}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:v}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),b=react.useMemo(()=>[...m?.pages?.flatMap(S=>S.items)??[],...h?.pages?.flatMap(S=>S.items)??[]],[m,h]),N=l||g||v,k=f.length,y=[{key:"positions",label:k>0?`${o("predict.profile.positionsTab")} (${k})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("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(cc,{positions:f,trades:b,isLoading:N}),jsxRuntime.jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(P=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(P.key),className:ui.cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===P.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:P.label},P.key))}),jsxRuntime.jsxs("div",{className:"py-2",children:[i==="positions"&&jsxRuntime.jsx(ac,{positions:f,isLoading:l,listHeight:Mi,onClosePosition:r,onEventClick:n}),i==="orders"&&jsxRuntime.jsx(oc,{solanaAddress:e,evmAddress:t,listHeight:Mi}),i==="history"&&jsxRuntime.jsx(Yl,{solanaAddress:e,evmAddress:t,listHeight:Mi})]})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function hP({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(false),[c,u]=react.useState(null),[p,d]=react.useState(false),f=r||p,l=n||p,m=f?"done":s?"running":"pending",g=l?"done":f&&s?"running":"pending",h=f&&l,v=react.useCallback(async()=>{u(null),d(false),a(true);try{await o(),d(!0);}catch(x){u(x instanceof Error?x.message:String(x));}finally{a(false);}},[o]),b=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:m},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],N=()=>{h?t():v();},k=i(h?"predict.setup.done":"predict.setup.setupButton");return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:x=>{x||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children: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-white",children:i("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:i("predict.setup.modalDescription")}),jsxRuntime.jsx("div",{className:"space-y-2.5",children:b.map((x,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(vv,{index:y+1,status:x.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:x.label}),jsxRuntime.jsx("span",{className:`text-[11px] leading-none ${x.status==="done"?"text-[#c7ff2e]":x.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:x.status==="done"?i("predict.setup.stepComplete"):x.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsxRuntime.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:x.desc})]})]},x.key))}),c&&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:c})}),jsxRuntime.jsx("button",{type:"button",onClick:N,disabled:s,className:h?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s?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")]}):k}),!h&&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:i("common.cancel")})]})]})})})}function vv({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,"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,"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,"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,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});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=Dv;exports.CHART_RANGE_PERIOD=Iv;exports.CHART_RANGE_SAMPLE_INTERVAL=Ov;exports.CandlestickPeriod=Tn;exports.CategoriesSkeleton=wv;exports.CategoriesUI=_i;exports.CategoriesWidget=Ai;exports.ChartRange=le;exports.CommentItemUI=ai;exports.DEFAULT_CHART_RANGE=En;exports.DEFAULT_FILTER_STATE=Qr;exports.DEFAULT_PAGE_SIZE=jr;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Hv;exports.EventCommentsWidget=xg;exports.EventDetailPage=s2;exports.EventDetailSkeleton=nn;exports.EventDetailUI=Ba;exports.EventDetailWidget=Ha;exports.EventItem=Ms;exports.EventMarketDepthChartUI=ba;exports.EventMarketDetailWidget=Na;exports.EventPriceChart=Ea;exports.EventsFilterUI=is;exports.EventsHero=Ix;exports.EventsPage=Tx;exports.EventsPageSkeleton=ex;exports.EventsSkeleton=Ao;exports.EventsToolbarUI=us;exports.EventsUI=_s;exports.EventsWidget=Os;exports.KycModal=An;exports.MAX_PRICE_HISTORY_MARKETS=Eo;exports.MatchGroupCard=cw;exports.MatchMarketCard=Il;exports.MatchesFilterBar=Cl;exports.MatchesHero=Tl;exports.MatchesPage=rw;exports.MatchesStatsBar=gw;exports.MatchesWidget=Bl;exports.ORDER_MAX_PRICE=Bv;exports.ORDER_MIN_PRICE=Fv;exports.ORDER_MIN_QUANTITY=Ln;exports.ORDER_MIN_USDC=Rn;exports.ORDER_PRICE_STEP=Av;exports.POLYMARKET_SPORTS_TAKER_FEE_BPS=Oc;exports.PREDICT_REDEEM_MODAL_ID=dp;exports.PREDICT_SEARCH_MODAL_ID=pi;exports.PREDICT_SELL_MODAL_ID=qo;exports.PREDICT_TRADE_MODAL_ID=Yr;exports.PRICE_HISTORY_SAMPLE_INTERVAL=zv;exports.PredictRedeemModal=Ks;exports.PredictSearchModal=sS;exports.PredictSellModal=ia;exports.PredictTradeModal=Hn;exports.PredictWalletProvider=Rc;exports.PriceHistoryInterval=_r;exports.ProfilePage=pv;exports.RedeemFormWidget=Us;exports.SORT_PRESETS=ds;exports.STATIC_CATEGORIES=Mo;exports.SearchEventsButton=gS;exports.SearchHistoryUI=tl;exports.SearchHistoryWidget=rl;exports.SearchInputUI=nl;exports.SearchResultItemUI=ol;exports.SearchResultListWidget=cl;exports.SearchWidget=fl;exports.SellFormUI=na;exports.SellFormWidget=jn;exports.SetupModal=hP;exports.SimilarEventCard=Wf;exports.SimilarEventsSection=$a;exports.SourceBadge=D1;exports.SpreadIndicator=xw;exports.TradeFormSkeleton=ua;exports.TradeFormUI=ns;exports.TradeFormWidget=Bn;exports.UserActivitySection=la;exports.computeMaxBuyAmount=Ui;exports.countActiveFilters=Do;exports.createTradeResultToast=Or;exports.estimatePolymarketBuyFee=$i;exports.fireCelebration=Ki;exports.floorToDecimals=ve;exports.formatKMB=on;exports.formatShares=qr;exports.getSourceMeta=Ut;exports.parsePolymarketError=On;exports.polymarketFeeFactor=zi;exports.resolveExpiration=_n;exports.resolvePolymarketDisplayFeeRateBps=Wi;exports.roundToTickSize=In;exports.useEventDetail=m2;exports.useEventsInfinite=fs;exports.usePredictSearchHistory=so;exports.usePredictWallet=br;exports.useSearchResultListScript=il;exports.useSearchScript=ml;exports.useSellForm=Gs;exports.useTradeForm=Gi;//# sourceMappingURL=index.js.map
|
|
137
137
|
//# sourceMappingURL=index.js.map
|