@liberfi.io/ui-predict 4.0.56 → 4.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- 'use strict';var react=require('react'),ui=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'),Fo=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 Fo__default=/*#__PURE__*/_interopDefault(Fo);var Pc={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Di=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Io=(()=>{let e=t=>{let r=Di.indexOf(t);return r===-1?Di.length:r};return Object.entries(Pc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Hi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:s="Trending",className:l}){let{t:u}=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",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(Fi,{label:d,isSelected:t===null,onPress:p,showPulse:d===s}),jsxRuntime.jsx(Tc,{}),e.map(f=>{let c=f.slug??f.category,m=f.label??f.category;return jsxRuntime.jsx(Fi,{label:m,isSelected:t===c,onPress:()=>o(c),badge:f.badge,showPulse:c===s||m===s},c)})]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),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(Bi,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(f=>{let c=f.slug??f.label;return jsxRuntime.jsx(Bi,{label:f.label,icon:f.icon,isSelected:r===c,onPress:()=>i(c)},c)})]})})]})}function Fi({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return 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 Tc(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Bi({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 Dv({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 Wi(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Lc(e){return `predict.categories.category.${Wi(e)}`}function Ui(e){return `predict.categories.tag.${Wi(e)}`}function Rc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Lc(r.slug),r.label),tags:r.tags.map(n=>({slug:n.slug,label:t(Ui(n.slug),n.label),icon:n.icon}))}))}function _c(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Ui(r.slug),r.label),icon:r.icon})):[]}function $i({onSelect:e,trailing:t,className:r}){let{t:n}=i18n.useTranslation(),o=react.useCallback((m,g)=>{let h=n(m);return typeof h=="string"&&h!==m?h:g},[n]),[i,a]=react.useState(null),[s,l]=react.useState(null),u=react.useCallback(m=>{a(m),l(null),e?.({categorySlug:m,tagSlug:null});},[e]),p=react.useCallback(m=>{l(m),e?.({categorySlug:i,tagSlug:m});},[i,e]),d=Rc(Io,o),f=Io.find(m=>m.slug===i),c=_c(f,o);return jsxRuntime.jsx(Hi,{categories:d,selectedCategory:i,selectedTag:s,activeTags:c,onCategorySelect:u,onTagSelect:p,trailing:t,className:r})}function Dn(e){return {title:e.title,imageUrl:e.image_url}}function Fn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var rn=24,Ao=4,Bn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ce={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Hn=ce.ALL,jv={[ce.ONE_DAY]:Bn.ONE_MINUTE,[ce.ONE_WEEK]:Bn.ONE_HOUR,[ce.ONE_MONTH]:Bn.ONE_HOUR,[ce.ALL]:Bn.ONE_DAY},Gv={[ce.ONE_DAY]:300,[ce.ONE_WEEK]:3600,[ce.ONE_MONTH]:10800,[ce.ALL]:1440*60},qv={[ce.ONE_DAY]:1440*60,[ce.ONE_WEEK]:10080*60,[ce.ONE_MONTH]:720*60*60,[ce.ALL]:null},zn=1,Wn=1,Yv=1,Qv=1,Xv=99,Br={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Jv=Br.ONE_WEEK,Zv={[Br.ONE_HOUR]:60,[Br.SIX_HOURS]:60,[Br.ONE_DAY]:300,[Br.ONE_WEEK]:1800,[Br.MAX]:1800};var ji=react.createContext(null);function xr(){let e=react.useContext(ji);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Hc=1e4;function zc({pollingInterval:e=Hc,enabled:t=true,enableKalshi:r=true,children:n}){let o=walletConnector.useWallets(),i=react.useMemo(()=>o.find(_=>_.chainNamespace===types.ChainNamespace.SOLANA&&_.isConnected)?.address,[o]),a=react.useMemo(()=>o.find(_=>_.chainNamespace===types.ChainNamespace.EVM&&_.isConnected)?.address,[o]),{data:s,isLoading:l,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:c,isLoading:m}=reactPredict.usePolymarketSetup(a,{enabled:t&&!!a,refetchInterval:3e4}),g=c?.safe_address,v=c?.verified??false,h=c?.wallet_kind??"deposit",x=c?.deposit_wallet_address,k=h==="safe"?c?.safe_address:x,S=h==="safe"?c?.safe_deployed??false:c?.deposit_wallet_deployed??false,{data:b,isLoading:y,isFetching:N,error:M}=reactPredict.useBalance({source:"polymarket",user:a??""},{enabled:t&&v&&!!a,refetchInterval:e}),C=react.useMemo(()=>({solanaAddress:i,evmAddress:a,polymarketWalletKind:h,polymarketWalletAddress:k,polymarketDepositWalletAddress:x,polymarketWalletDeployed:S,polymarketSafeAddress:g,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:v&&b?Number(b.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:v,polymarketSafeDeployed:c?.safe_deployed??false,polymarketTokenApproved:c?.token_approved??false,polymarketSetupLoading:m,isLoading:l||y,isFetching:u||N,error:p??M??null}),[i,a,h,k,x,S,g,s,b,v,d,f,c,m,l,y,u,N,p,M]);return jsxRuntime.jsx(ji.Provider,{value:C,children:n})}var Uc={minutes:60,hours:3600,days:86400};function Un(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*Uc[r]}}function $n(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function xe(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function $c(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Kc=100,Vc=300;function Bo(e,t){return Kc/1e4+Math.max(0,e)/1e4*$c(t)}function jc(e,t){let r=e?.[t],n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:void 0}function Gc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Gi(e){let t=jc(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],n=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(n)&&n>=0?n*1e4:Gc(e,"polymarket.sportsMarketType")?Vc:0}function qi({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:n=0,pricePerShare:o}){if(t==null||!Number.isFinite(t))return 0;let i=xe(Math.max(0,t),2);if(e!=="polymarket")return i;let a=Bo(n,o??NaN),s=i/(1+a)-r;return xe(Math.max(0,s),2)}function Yi({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Qi({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Kn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let a=parseInt(o[1],10)/1e6,s=parseInt(o[2],10)/1e6,l=Math.max(0,a-s);return t("predict.trade.polymarket.insufficientBalance",{total:xe(a,2).toFixed(2),active:xe(s,2).toFixed(2),available:xe(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function yr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function Xi(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Fo__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Fo__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Fo__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var Ji={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function qc(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function Ho(e,t,r){let n=e(t);return n&&n!==t?n:r}function Hr(e,t){let r=qc(t)?Ji.zh:Ji.en;return {submitted:Ho(e,"predict.trade.resultSubmitted",r.submitted),completed:Ho(e,"predict.trade.resultCompleted",r.completed),delayed:Ho(e,"predict.trade.resultDelayed",r.delayed)}}function Jc({deadlineAt:e}){let[t,r]=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 zr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:n}){return {id:e,submitted:()=>{let o=Date.now()+t;ui.toast.progress({id:e,message:n.submitted,duration:t,progress:true,action:react.createElement(Jc,{deadlineAt:o})});},completed:()=>{ui.toast.update(e,{type:"success",message:n.completed,duration:5e3}),r&&Xi();},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 ts({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o,i18n:i}=i18n.useTranslation(),{status:a}=walletConnector.useAuth(),s=walletConnector.useWallets(),l=reactPredict.usePredictClient(),u=react.useContext(reactPredict.PolymarketContext),{start:p}=reactPredict.useTradeResultConfirmation(),d=e.source,f=d==="polymarket",c=s.find(R=>R.chainNamespace===types.ChainNamespace.SOLANA&&R.isConnected),m=s.find(R=>R.chainNamespace===types.ChainNamespace.EVM&&R.isConnected&&"switchChain"in R),g=a==="authenticated",v=c?.address,h=m?.address,[x,k]=react.useState(t),[S,b]=react.useState("market"),[y,N]=react.useState(NaN),[M,C]=react.useState(NaN),[_,F]=react.useState(false),[U,Q]=react.useState(null),[B,Y]=react.useState(false),[q,te]=react.useState(false),[P,T]=react.useState("1h"),[z,J]=react.useState(30),[ue,ae]=react.useState("minutes"),Ke=react.useMemo(()=>Hr(o,i),[i,o]),Ee=react.useCallback(async(R,Ae)=>{let We=zr({celebrateOnCompleted:true,messages:Ke});We.submitted(),await p({source:d,user:d==="kalshi"?v:h,kalshiUser:v,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:R,getOrdersHeaders:Ae})==="confirmed"?We.completed():We.delayed();},[p,h,e.event_slug,e.slug,d,Ke,v]),w=react.useMemo(()=>{if(d!=="polymarket")return;let R=e.provider_meta?.["polymarket.clobTokenIds"];return R?(typeof R=="string"?JSON.parse(R):R)[x==="yes"?0:1]:void 0},[d,e.provider_meta,x]),{data:He,isLoading:Je}=reactPredict.useTickSize(w),we=He?.minimum_tick_size?String(He.minimum_tick_size):"0.01",{data:Ct,isLoading:Oe}=reactPredict.useFeeRate(w),Ve=Ct?.base_fee??0,st=String(Ve),Pe=react.useMemo(()=>Gi(e.provider_meta),[e.provider_meta]),{data:Ze}=reactPredict.useRebateConfig(),Le=Ze?.builder_enabled&&Ze.builder_code?Ze.builder_code:void 0,at=null,_t=false,Mt=null,Tt=false,et,gt,ze;try{let R=xr();at={kalshiUsdcBalance:R.kalshiUsdcBalance,polymarketUsdcBalance:R.polymarketUsdcBalance,isLoading:R.isLoading},_t=R.kalshiKycVerified,Mt=R.kalshiKycUrl,Tt=R.polymarketSetupVerified,et=R.polymarketSafeAddress,gt=R.polymarketWalletKind,ze=R.polymarketWalletAddress;}catch{}let Gt=d==="kalshi"&&!_t,Re=d==="polymarket"&&!Tt,{data:je}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:d,outcome:x},{enabled:e.status==="open"}),ge=react.useMemo(()=>{let R=reactPredict.pickBestAsk(je,x);if(R!=null&&R>0)return R;let Ae=x==="yes"?0:1,We=e.outcomes[Ae];return We?.best_ask??We?.price??.5},[je,e.outcomes,x]),lt=react.useCallback(R=>{b(R);},[]),ht=react.useCallback(R=>{k(R),C(NaN);},[]);react.useEffect(()=>{ht(t);},[t,ht]),react.useEffect(()=>{S==="limit"&&isNaN(M)&&C(Math.round(ge*1e4)/1e4);},[S,M,ge]);let Ne=react.useMemo(()=>S==="limit"&&f&&!isNaN(M)?M:ge,[S,f,M,ge]),ut=react.useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne:0,[y,Ne]),Ce=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:je,outcome:x,side:"buy",sharesNeeded:ut,slippageBps:r}),[je,x,ut,r]),I=react.useMemo(()=>Ce.status==="ok"&&Ce.worstPrice!=null&&Ce.worstPrice>0?Ce.worstPrice:ge,[Ce,ge]),pe=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),tt=e.provider_meta?.["dflow.yesMint"]??"",Xr=e.provider_meta?.["dflow.noMint"]??"",A=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,Ge=x==="yes"?tt:Xr,vt=A,ur=Ge,Dt=d==="kalshi"?v??"":h??"",{data:Jr,isLoading:Co}=reactPredict.usePositionsMulti({kalshi_user:d==="kalshi"?Dt:void 0,polymarket_user:d==="polymarket"?Dt:void 0},{enabled:!!Dt}),Cn=d==="kalshi"&&!!vt&&!!ur&&!!v&&pe!=="0",{refetch:Lr}=reactPredict.useDFlowQuote({inputMint:vt,outputMint:ur,amount:pe,userPublicKey:v??"",slippageBps:100},{enabled:Cn}),qe=react.useMemo(()=>at?d==="kalshi"?at.kalshiUsdcBalance:at.polymarketUsdcBalance:Jr&&Jr.positions.reduce((Ae,We)=>We.side==="USDC"||We.side==="collateral"?Ae+(We.current_value??0):Ae,0)||null,[at,Jr,d]),Rr=at?at.isLoading:Co,_r=react.useMemo(()=>qi({source:d,usdcBalance:qe,feeRateBps:Pe,pricePerShare:Ne}),[d,qe,Pe,Ne]),Ft=qe==null?null:_r,Ir=react.useMemo(()=>isNaN(y)||y<=0?0:y,[y]),qt=react.useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne*1:0,[y,Ne]),Mn=react.useMemo(()=>d!=="polymarket"||isNaN(y)||y<=0?0:Yi({usdcAmount:y,pricePerShare:Ne,feeRateBps:Pe}),[d,y,Ne,Pe]),Tn=qt-Ir-Mn,Mo=react.useCallback(R=>{if(isNaN(R)){N(NaN);return}N(Math.round(Math.max(0,R)*100)/100);},[]),pr=react.useCallback(R=>{if(isNaN(R)){C(NaN);return}C(Math.round(R*1e4)/1e4);},[]),Bt=react.useCallback(()=>{N(NaN),C(NaN),b("market"),te(false),T("1h"),J(30),ae("minutes");},[]),Yt=react.useMemo(()=>{let R=[];return isNaN(y)||y<=0?R.push(o("predict.trade.minAmountUsd",{amount:Wn})):y<Wn&&R.push(o("predict.trade.minAmountUsd",{amount:Wn})),e.status!=="open"&&R.push(o("predict.trade.marketNotActive")),Ft!=null&&!isNaN(y)&&y>0&&y>Ft&&R.push(o("predict.trade.insufficientBalance")),S==="limit"&&f&&(isNaN(M)||M<.01||M>.99)&&R.push(o("predict.trade.limitPriceRange")),S==="limit"&&f&&q&&P==="custom"&&(isNaN(z)||z<=0)&&R.push(o("predict.trade.expiration.invalidDate")),d==="polymarket"&&S==="market"&&!isNaN(y)&&y>0&&ut>0&&(Ce.status==="insufficient_liquidity"?R.push(o("predict.trade.insufficientLiquidity",{available:xe(Ce.totalAvailable,2)})):Ce.status==="exceeds_slippage"&&R.push(o("predict.trade.priceImpactTooHigh",{impact:(Ce.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:R.length===0,errors:R}},[y,e.status,Ft,S,f,M,q,P,z,d,ut,Ce,r,o]),Or=react.useMemo(()=>Ft==null||isNaN(y)||y<=0?false:y>Ft,[Ft,y]),To=react.useCallback(()=>{n?.(d);},[n,d]),{mutateAsync:Zr}=reactPredict.useDFlowSubmit(),{data:mr}=reactPredict.useOrder({id:U??"",source:d},{enabled:!!U});react.useEffect(()=>{if(!mr||!U)return;let{status:R}=mr;R==="closed"?(Q(null),F(false),Ee("buy-market"),Bt()):(R==="failed"||R==="expired")&&(F(false),Q(null),ui.toast.error(o("predict.trade.submitError")));},[Ee,mr,U,Bt,o]);let bt=react.useCallback(async()=>{if(!v||!c)return;if(!vt||!ur){ui.toast.error("Missing token mint addresses"),F(false);return}if(!_t){Y(true),F(false);return}let Et=(await Lr()).data?.transaction;if(!Et){ui.toast.error(o("predict.trade.submitError")),F(false);return}let en=Uint8Array.from(atob(Et),ct=>ct.charCodeAt(0)),hr=await c.signTransaction(en),Qt=await Zr({signedTransaction:btoa(String.fromCharCode(...hr)),orderContext:{user_public_key:v,input_mint:vt,output_mint:ur,amount:pe,price:String(ge),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(Qt.signature);},[v,c,Lr,Zr,vt,ur,pe,ge,x,e.slug,o,_t]),fr=react.useCallback(async()=>{if(!m||!u)return;let R=m.chain,Ae=R!==types.Chain.POLYGON;Ae&&await m.switchChain(types.Chain.POLYGON);try{let We=await m.getEip1193Provider();if(!We){ui.toast.error(o("predict.trade.submitError")),F(!1);return}let Et=gt==="deposit"&&!!ze,en=!Et&&!!et,hr=Et?ze:et,Qt={address:m.address,signatureType:Et?3:en?2:0,signTypedData:async(le,ye,Ye,rt)=>{let nt=[];"name"in le&&nt.push({name:"name",type:"string"}),"version"in le&&nt.push({name:"version",type:"string"}),"chainId"in le&&nt.push({name:"chainId",type:"uint256"}),"verifyingContract"in le&&nt.push({name:"verifyingContract",type:"address"}),"salt"in le&&nt.push({name:"salt",type:"bytes32"});let Lt={EIP712Domain:nt,...ye};return await We.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:le,types:Lt,primaryType:Ye,message:rt})]})}},ct=u.credentials??await u.authenticate(Qt),vr=x==="yes"?0:1,Ar="",Xt=e.provider_meta?.["polymarket.clobTokenIds"];Xt&&(Ar=(typeof Xt=="string"?JSON.parse(Xt):Xt)[vr]??"");let Dr=e.provider_meta?.["polymarket.negRisk"]??!1,En=S==="limit"&&!isNaN(M)?M:I,Jt=$n(En,we),Ln=S==="limit"?q?"GTD":"GTC":"FOK",Rn=S==="market"?y:Jt>0?y/Jt:0,tn={tokenId:Ar,price:Jt,size:Rn,side:"BUY",orderType:Ln,tickSize:we,negRisk:Dr,...hr&&{funderAddress:hr},...Le&&{builderCode:Le},...S==="limit"&&q&&{expiration:Un(P,z,ue)}},E;if(Et)E=await reactPredict.buildSignedV2OrderPayload({signer:Qt,depositWalletAddress:hr,input:tn,owner:ct.apiKey});else {let le=reactPredict.buildCtfExchangeDomain(Dr),ye=reactPredict.buildOrderMessage({...tn,signerAddress:Qt.address,signatureType:Qt.signatureType,feeRateBps:st}),Ye=await Qt.signTypedData(le,reactPredict.CTF_ORDER_TYPES,"Order",ye),rt=reactPredict.buildSignedOrder(ye,Ye,tn.orderType);E=reactPredict.buildClobPayload(rt,ct.apiKey);}await l.executePolymarketOrder({payload:E,l2_api_key:ct.apiKey,l2_secret:ct.secret,l2_passphrase:ct.passphrase,signer_address:ct.address,owner:ct.apiKey}),Ee(S==="limit"?"buy-limit":"buy-market",async()=>await reactPredict.buildPolymarketL2Headers(ct.address,{apiKey:ct.apiKey,secret:ct.secret,passphrase:ct.passphrase,method:"GET",requestPath:"/data/orders"})),Bt(),F(!1);}finally{Ae&&R&&m.switchChain(R).catch(()=>{});}},[m,u,x,e.provider_meta,S,Ee,M,I,y,l,q,P,z,ue,Bt,o,we,st,et,gt,ze,Le]),gr=react.useCallback(async()=>{if(!(!Yt.isValid||!g)){F(true),Q(null),Y(false);try{d==="kalshi"?await bt():await fr();}catch(R){let Ae=R instanceof Error?R.message:"",We=d==="polymarket"&&Ae?Kn(Ae,o,"buy"):Ae||void 0;ui.toast.error(We||o("predict.trade.submitError")),F(false);}}},[Yt.isValid,g,d,bt,fr,o]);return {outcome:x,orderType:S,quantity:y,limitPrice:M,shares:ut,effectivePrice:Ne,estimatedCost:Ir,estimatedFee:Mn,potentialPayout:qt,potentialProfit:Tn,pricePerShare:ge,usdcBalance:qe,maxBuyAmount:_r,spendableUsdcBalance:Ft,isBalanceLoading:Rr,isMarketDataLoading:d==="polymarket"&&(Oe||Je),isSubmitting:_,authStatus:a,validation:Yt,isInsufficientBalance:Or,source:d,supportsLimitOrder:f,kycRequired:B,needsKyc:Gt,needsSetup:Re,kycUrl:Mt,expirationEnabled:q,expirationPreset:P,customDuration:z,customDurationUnit:ue,setOutcome:ht,setOrderType:lt,setQuantity:Mo,setLimitPrice:pr,setExpirationEnabled:te,setExpirationPreset:T,setCustomDuration:J,setCustomDurationUnit:ae,submit:gr,notifyInsufficientBalance:To}}function jn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=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 Dd=["5m","1h","12h","24h","eod","custom"],Fd={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},Bd=["minutes","hours","days"],Hd={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},zd={maximumFractionDigits:0},sr="-";function ds({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:s,effectivePrice:l,potentialProfit:u,potentialPayout:p,estimatedCost:d,estimatedFee:f=0,usdcBalance:c,isBalanceLoading:m,isMarketDataLoading:g,isSubmitting:v,authStatus:h,isValid:x,validationErrors:k,isInsufficientBalance:S,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:N,kycRequired:M,needsKyc:C,needsSetup:_,kycUrl:F,expirationEnabled:U,expirationPreset:Q,customDuration:B,customDurationUnit:Y,oddsFormatter:q,onOutcomeChange:te,onOrderTypeChange:P,onQuantityChange:T,onLimitPriceChange:z,onExpirationEnabledChange:J,onExpirationPresetChange:ue,onCustomDurationChange:ae,onCustomDurationUnitChange:Ke,onSubmit:Ee}){let{t:w}=i18n.useTranslation(),[He,Je]=react.useState(true),we=ui.useDisclosure(),[Ct,Oe]=react.useState(""),Ve=react.useRef(false);react.useEffect(()=>{Ve.current||Oe(isNaN(i)?"":String(i));},[i]);let[st,Pe]=react.useState(""),Ze=react.useRef(false);react.useEffect(()=>{Ze.current||(isNaN(a)?Pe(""):Pe(String(parseFloat((a*100).toFixed(2)))));},[a]);let Le=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Pe(A),A===""||A==="."){z(NaN);return}let vt=parseFloat(A);isNaN(vt)||z(vt/100);},[z]),at=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Oe(A),tt(false),A===""||A==="."){T(NaN);return}let vt=parseFloat(A);isNaN(vt)||T(vt);},[T]);react.useEffect(()=>{M&&!we.isOpen&&we.onOpen();},[M]);let _t=react.useMemo(()=>{let A=n==="yes"?t.yesAsk:t.noAsk;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),Mt=n==="yes"?t.yesAsk:t.noAsk,Tt=Mt!=null&&q?q(Number(Mt)):_t!=null?`${_t} \xA2`:sr,et=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,gt=Number.isFinite(l)&&q?q(l):et!=null?`${et} \xA2`:sr,ze=!isNaN(i)&&i>0,Gt=ze?d+f:0,Re=ze&&s>0?Gt/s:0,je=Re>0&&q?q(Re):Re>0?`${parseFloat((Re*100).toFixed(2))}\xA2`:sr,ge=h==="authenticated",lt=h==="authenticating"||h==="deauthenticating",ht=ge&&(C||_),Ne=react.useMemo(()=>{if(lt)return w("predict.trade.checkingLogin");if(!ge)return w("predict.trade.loginToTrade");if(C)return w("predict.trade.kycRequired");if(_)return w("predict.trade.setupRequired");if(m)return w("predict.trade.loadingBalance");if(g)return w("predict.trade.loadingMarketData");if(v)return w("predict.trade.submitting");if(M)return w("predict.trade.kycRequired");if(!ze)return w("predict.trade.enterAmount");let A=w(n==="yes"?"predict.trade.yes":"predict.trade.no"),Ge=u>0?` \u2192 Win $${u.toFixed(2)}`:"";return `${w("predict.trade.buy")} ${A}${Ge}`},[lt,ge,C,_,m,g,v,M,ze,n,u,w]),ut="primary",Ce=()=>{let A=N??xe(c??0,2);T(xe(A/2,2));},I=()=>{T(N??xe(c??0,2));},[pe,tt]=react.useState(false),Xr=()=>{if(!ge){tt(false),Ee();return}if(C){we.onOpen();return}if(_&&b){tt(false),b();return}if(M){we.onOpen();return}if(S&&b){tt(false),b();return}if(!x){tt(true);return}tt(false),Ee();};return 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:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&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:[w("predict.trade.buy")," ",w(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:[y?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>P(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&y?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:st,onChange:A=>Le(A.target.value),onFocus:()=>{Ze.current=true;},onBlur:()=>{Ze.current=false,isNaN(a)?Pe(""):Pe(String(parseFloat((a*100).toFixed(2))));},endContent: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"}}):Tt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:Tt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(A=>{let Ge=A==="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:()=>te(A),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===A?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:w(A==="yes"?"predict.trade.yes":"predict.trade.no")}),Ge!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:q?q(Number(Ge)):`${parseFloat((Number(Ge)*100).toFixed(2))}\xA2`})]})},A)})}),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:w("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:Ce,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:I,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ct,onChange:A=>at(A.target.value),onFocus:()=>{Ve.current=true;},onBlur:()=>{Ve.current=false,Oe(isNaN(i)?"":String(i));},startContent: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&&k.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:k.map(A=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:A},A))})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"text-neutral-500",children:w("predict.trade.balance")}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:c!=null?`$${xe(c,2).toFixed(2)}`:"$0"})]}),o==="limit"&&y&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:w("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:U,onValueChange:J,"aria-label":w("predict.trade.setExpiration")})]}),U&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[Q],onSelectionChange:A=>{let Ge=Array.from(A)[0];Ge&&ue(Ge);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Dd.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:w(Fd[A])},A))}),Q==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(B)?void 0:B,onValueChange:ae,minValue:1,step:1,formatOptions:zd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsxRuntime.jsx(ui.Select,{"aria-label":"Duration unit",selectedKeys:[Y],onSelectionChange:A=>{let Ge=Array.from(A)[0];Ge&&Ke(Ge);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Bd.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:w(Hd[A])},A))})]})]})]}),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:()=>Je(A=>!A),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:w("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",He&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:q&&Number.isFinite(l)?gt:et!=null?w("predict.trade.chance",{percent:et}):sr})]}),He&&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:w("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:sr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?yr(s):sr})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${f.toFixed(2)}`})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.totalPayment")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${Gt.toFixed(2)}`})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:je})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:sr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&u>0?`+$${u.toFixed(2)}`:sr})]})]})]}),jsxRuntime.jsx(ui.Button,{color:ut,fullWidth:true,radius:"lg",size:"lg",isDisabled:lt||ge&&!ht&&(m||g||!ze||v),isLoading:lt||ge&&!ht&&(v||m||g),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Xr,children:Ne})]}),jsxRuntime.jsx(jn,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:F})]})}function qn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:a,onOutcomeChange:s,oddsFormatter:l}){let{outcome:u,orderType:p,quantity:d,limitPrice:f,shares:c,effectivePrice:m,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,pricePerShare:k,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:N,isSubmitting:M,authStatus:C,validation:_,isInsufficientBalance:F,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:P,customDuration:T,customDurationUnit:z,setOutcome:J,setOrderType:ue,setQuantity:ae,setLimitPrice:Ke,setExpirationEnabled:Ee,setExpirationPreset:w,setCustomDuration:He,setCustomDurationUnit:Je,submit:we,notifyInsufficientBalance:Ct}=ts({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:a}),Oe=walletConnector.useAuthCallback(we),Ve=react.useCallback(Ze=>{J(Ze),s?.(Ze);},[J,s]),st=react.useMemo(()=>e?Dn(e):void 0,[e]),Pe=react.useMemo(()=>Fn(t,{yesAsk:u==="yes"?k:void 0,noAsk:u==="no"?k:void 0}),[t,u,k]);return jsxRuntime.jsx(ds,{event:st,market:Pe,variant:r,outcome:u,orderType:p,quantity:d,limitPrice:f,shares:c,effectivePrice:m,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:N,isSubmitting:M,authStatus:C,isValid:_.isValid,validationErrors:_.errors,isInsufficientBalance:F,onInsufficientBalance:a?Ct:void 0,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:P,customDuration:T,customDurationUnit:z,oddsFormatter:l,onOutcomeChange:Ve,onOrderTypeChange:ue,onQuantityChange:ae,onLimitPriceChange:Ke,onExpirationEnabledChange:Ee,onExpirationPresetChange:w,onCustomDurationChange:He,onCustomDurationUnitChange:Je,onSubmit:Oe})}var on="predict-trade";function Yn({id:e=on}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Yd,{...t})})}function Yd({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(qn,{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 sn={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Uo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function ps({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState(r),l=react.useMemo(()=>o?sn:{...sn,source:"polymarket"},[o]),u=react.useCallback(x=>{x?s(r):t();},[r,t]),p=react.useCallback(()=>{s(l);},[l]),d=react.useCallback(()=>{n(a),t();},[a,n,t]),f=react.useCallback((x,k)=>{s(S=>({...S,[x]:k}));},[]),c=react.useMemo(()=>Uo(a,o),[a,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]),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]),h=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange: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(tu,{onClick:()=>u(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsxRuntime.jsx(Xn,{label:i("predict.filter.platform"),children:jsxRuntime.jsx(Jn,{options:m,selected:a.source,onSelect:x=>f("source",x)})}),jsxRuntime.jsx(Xn,{label:i("predict.filter.timeRemaining"),children:jsxRuntime.jsx(Jn,{options:g,selected:a.timeRemaining,onSelect:x=>f("timeRemaining",x)})}),jsxRuntime.jsx(Xn,{label:i("predict.filter.minVolume"),children:jsxRuntime.jsx(Jn,{options:v,selected:a.minVolume,onSelect:x=>f("minVolume",x)})}),jsxRuntime.jsx(Xn,{label:i("predict.filter.minLiquidity"),children:jsxRuntime.jsx(Jn,{options:h,selected:a.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: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"),c>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",c,")"]})]})]})]})})})}function Xn({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 tu({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 Jn({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:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var vs={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},fs={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},du=["start_time","volume","liquidity","ending_soon"],gs={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},uu={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function bs({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:a}){let{t:s}=i18n.useTranslation(),[l,u]=react.useState(false),p=react.useRef(null),d=react.useCallback(c=>{p.current&&!p.current.contains(c.target)&&u(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)),[d]),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=hs[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:p,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:gs,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(c=>!c),children:[jsxRuntime.jsx(pu,{}),jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(fs[e])}),jsxRuntime.jsx(fu,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...uu,width:224,padding:4},children:du.map(c=>{let m=hs[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?n(!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:s(fs[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:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:gs,onMouseEnter:c=>{c.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:c=>{c.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsxRuntime.jsx(mu,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s("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 hs={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function pu(){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 mu(){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 fu({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 ks(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:a,error:s,hasNextPage:l,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]),c=react.useCallback(()=>{p();},[p]);return {data:d,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:a,error:s??null,hasMore:l??false,fetchMore:f,refetch:c}}var Ss=`
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'),Fo=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 Fo__default=/*#__PURE__*/_interopDefault(Fo);var Pc={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Di=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Io=(()=>{let e=t=>{let r=Di.indexOf(t);return r===-1?Di.length:r};return Object.entries(Pc).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Hi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:s="Trending",className:l}){let{t:u}=i18n.useTranslation(),p=react.useCallback(()=>{o(null);},[o]),c=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(Fi,{label:c,isSelected:t===null,onPress:p,showPulse:c===s}),jsxRuntime.jsx(Tc,{}),e.map(f=>{let d=f.slug??f.category,m=f.label??f.category;return jsxRuntime.jsx(Fi,{label:m,isSelected:t===d,onPress:()=>o(d),badge:f.badge,showPulse:d===s||m===s},d)})]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),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(Bi,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(f=>{let d=f.slug??f.label;return jsxRuntime.jsx(Bi,{label:f.label,icon:f.icon,isSelected:r===d,onPress:()=>i(d)},d)})]})})]})}function Fi({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 Tc(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Bi({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 Fv({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 Wi(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Lc(e){return `predict.categories.category.${Wi(e)}`}function Ui(e){return `predict.categories.tag.${Wi(e)}`}function Rc(e,t){return e.map(r=>({category:r.slug,slug:r.slug,label:t(Lc(r.slug),r.label),tags:r.tags.map(n=>({slug:n.slug,label:t(Ui(n.slug),n.label),icon:n.icon}))}))}function _c(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Ui(r.slug),r.label),icon:r.icon})):[]}function $i({onSelect:e,trailing:t,className:r}){let{t:n}=i18n.useTranslation(),o=react.useCallback((m,g)=>{let h=n(m);return typeof h=="string"&&h!==m?h:g},[n]),[i,a]=react.useState(null),[s,l]=react.useState(null),u=react.useCallback(m=>{a(m),l(null),e?.({categorySlug:m,tagSlug:null});},[e]),p=react.useCallback(m=>{l(m),e?.({categorySlug:i,tagSlug:m});},[i,e]),c=Rc(Io,o),f=Io.find(m=>m.slug===i),d=_c(f,o);return jsxRuntime.jsx(Hi,{categories:c,selectedCategory:i,selectedTag:s,activeTags:d,onCategorySelect:u,onTagSelect:p,trailing:t,className:r})}function Dn(e){return {title:e.title,imageUrl:e.image_url}}function Fn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var rn=24,Ao=4,Bn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ce={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Hn=ce.ALL,Gv={[ce.ONE_DAY]:Bn.ONE_MINUTE,[ce.ONE_WEEK]:Bn.ONE_HOUR,[ce.ONE_MONTH]:Bn.ONE_HOUR,[ce.ALL]:Bn.ONE_DAY},qv={[ce.ONE_DAY]:300,[ce.ONE_WEEK]:3600,[ce.ONE_MONTH]:10800,[ce.ALL]:1440*60},Yv={[ce.ONE_DAY]:1440*60,[ce.ONE_WEEK]:10080*60,[ce.ONE_MONTH]:720*60*60,[ce.ALL]:null},zn=1,Wn=1,Qv=1,Xv=1,Jv=99,Br={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Zv=Br.ONE_WEEK,eb={[Br.ONE_HOUR]:60,[Br.SIX_HOURS]:60,[Br.ONE_DAY]:300,[Br.ONE_WEEK]:1800,[Br.MAX]:1800};var ji=react.createContext(null);function xr(){let e=react.useContext(ji);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Hc=1e4;function zc({pollingInterval:e=Hc,enabled:t=true,enableKalshi:r=true,children:n}){let o=walletConnector.useWallets(),i=react.useMemo(()=>o.find(_=>_.chainNamespace===types.ChainNamespace.SOLANA&&_.isConnected)?.address,[o]),a=react.useMemo(()=>o.find(_=>_.chainNamespace===types.ChainNamespace.EVM&&_.isConnected)?.address,[o]),{data:s,isLoading:l,isFetching:u,error:p}=reactPredict.useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:c,isLoading:f}=reactPredict.useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:d,isLoading:m}=reactPredict.usePolymarketSetup(a,{enabled:t&&!!a,refetchInterval:3e4}),g=d?.safe_address,v=d?.verified??false,h=d?.wallet_kind??"deposit",x=d?.deposit_wallet_address,k=h==="safe"?d?.safe_address:x,S=h==="safe"?d?.safe_deployed??false:d?.deposit_wallet_deployed??false,{data:b,isLoading:y,isFetching:N,error:M}=reactPredict.useBalance({source:"polymarket",user:a??""},{enabled:t&&v&&!!a,refetchInterval:e}),C=react.useMemo(()=>({solanaAddress:i,evmAddress:a,polymarketWalletKind:h,polymarketWalletAddress:k,polymarketDepositWalletAddress:x,polymarketWalletDeployed:S,polymarketSafeAddress:g,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:v&&b?Number(b.balance):null,kalshiKycVerified:c?.verified??false,kalshiKycUrl:c?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:v,polymarketSafeDeployed:d?.safe_deployed??false,polymarketTokenApproved:d?.token_approved??false,polymarketSetupLoading:m,isLoading:l||y,isFetching:u||N,error:p??M??null}),[i,a,h,k,x,S,g,s,b,v,c,f,d,m,l,y,u,N,p,M]);return jsxRuntime.jsx(ji.Provider,{value:C,children:n})}var Uc={minutes:60,hours:3600,days:86400};function Un(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*Uc[r]}}function $n(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function xe(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function $c(e){let t=e;return !Number.isFinite(t)||t<=0||t>=1?1:1-t}var Kc=100,Vc=300;function Bo(e,t){return Kc/1e4+Math.max(0,e)/1e4*$c(t)}function jc(e,t){let r=e?.[t],n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:void 0}function Gc(e,t){let r=e?.[t];return typeof r=="string"?r:void 0}function Gi(e){let t=jc(e,"polymarket.effectiveTakerFeeBps");if(t!==void 0&&t>=0)return t;let r=e?.["polymarket.feeDescriptor"],n=typeof r?.r=="number"?r.r:Number(r?.r);return Number.isFinite(n)&&n>=0?n*1e4:Gc(e,"polymarket.sportsMarketType")?Vc:0}function qi({source:e,usdcBalance:t,safetyBufferUsd:r=.01,feeRateBps:n=0,pricePerShare:o}){if(t==null||!Number.isFinite(t))return 0;let i=xe(Math.max(0,t),2);if(e!=="polymarket")return i;let a=Bo(n,o??NaN),s=i/(1+a)-r;return xe(Math.max(0,s),2)}function Yi({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Qi({grossReturn:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Kn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let a=parseInt(o[1],10)/1e6,s=parseInt(o[2],10)/1e6,l=Math.max(0,a-s);return t("predict.trade.polymarket.insufficientBalance",{total:xe(a,2).toFixed(2),active:xe(s,2).toFixed(2),available:xe(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function yr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function Xi(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Fo__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Fo__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Fo__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}var Ji={en:{submitted:"Your trade was submitted successfully. Confirming the result.",completed:"Trade completed",delayed:"Your trade was submitted successfully. Confirmation is taking a little longer."},zh:{submitted:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u7ED3\u679C",completed:"\u4EA4\u6613\u5DF2\u5B8C\u6210",delayed:"\u60A8\u7684\u4EA4\u6613\u5DF2\u6210\u529F\u63D0\u4EA4\uFF0C\u786E\u8BA4\u65F6\u95F4\u6BD4\u9884\u671F\u7A0D\u957F"}};function qc(e){return (e?.resolvedLanguage??e?.language??"").toLowerCase().startsWith("zh")}function Ho(e,t,r){let n=e(t);return n&&n!==t?n:r}function Hr(e,t){let r=qc(t)?Ji.zh:Ji.en;return {submitted:Ho(e,"predict.trade.resultSubmitted",r.submitted),completed:Ho(e,"predict.trade.resultCompleted",r.completed),delayed:Ho(e,"predict.trade.resultDelayed",r.delayed)}}function Jc({deadlineAt:e}){let[t,r]=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 zr({id:e=`predict-trade-result-${Date.now()}`,durationMs:t=3e4,celebrateOnCompleted:r=false,messages:n}){return {id:e,submitted:()=>{let o=Date.now()+t;ui.toast.progress({id:e,message:n.submitted,duration:t,progress:true,action:react.createElement(Jc,{deadlineAt:o})});},completed:()=>{ui.toast.update(e,{type:"success",message:n.completed,duration:5e3}),r&&Xi();},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 ts({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o,i18n:i}=i18n.useTranslation(),{status:a}=walletConnector.useAuth(),s=walletConnector.useWallets(),l=reactPredict.usePredictClient(),u=react.useContext(reactPredict.PolymarketContext),{start:p}=reactPredict.useTradeResultConfirmation(),c=e.source,f=c==="polymarket",d=s.find(R=>R.chainNamespace===types.ChainNamespace.SOLANA&&R.isConnected),m=s.find(R=>R.chainNamespace===types.ChainNamespace.EVM&&R.isConnected&&"switchChain"in R),g=a==="authenticated",v=d?.address,h=m?.address,[x,k]=react.useState(t),[S,b]=react.useState("market"),[y,N]=react.useState(NaN),[M,C]=react.useState(NaN),[_,F]=react.useState(false),[U,Q]=react.useState(null),[B,Y]=react.useState(false),[q,te]=react.useState(false),[P,T]=react.useState("1h"),[z,J]=react.useState(30),[ue,ae]=react.useState("minutes"),Ke=react.useMemo(()=>Hr(o,i),[i,o]),Ee=react.useCallback(async(R,Ae)=>{let We=zr({celebrateOnCompleted:true,messages:Ke});We.submitted(),await p({source:c,user:c==="kalshi"?v:h,kalshiUser:v,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:R,getOrdersHeaders:Ae})==="confirmed"?We.completed():We.delayed();},[p,h,e.event_slug,e.slug,c,Ke,v]),w=react.useMemo(()=>{if(c!=="polymarket")return;let R=e.provider_meta?.["polymarket.clobTokenIds"];return R?(typeof R=="string"?JSON.parse(R):R)[x==="yes"?0:1]:void 0},[c,e.provider_meta,x]),{data:He,isLoading:Je}=reactPredict.useTickSize(w),we=He?.minimum_tick_size?String(He.minimum_tick_size):"0.01",{data:Ct,isLoading:Oe}=reactPredict.useFeeRate(w),Ve=Ct?.base_fee??0,st=String(Ve),Pe=react.useMemo(()=>Gi(e.provider_meta),[e.provider_meta]),{data:Ze}=reactPredict.useRebateConfig(),Le=Ze?.builder_enabled&&Ze.builder_code?Ze.builder_code:void 0,at=null,_t=false,Mt=null,Tt=false,et,gt,ze;try{let R=xr();at={kalshiUsdcBalance:R.kalshiUsdcBalance,polymarketUsdcBalance:R.polymarketUsdcBalance,isLoading:R.isLoading},_t=R.kalshiKycVerified,Mt=R.kalshiKycUrl,Tt=R.polymarketSetupVerified,et=R.polymarketSafeAddress,gt=R.polymarketWalletKind,ze=R.polymarketWalletAddress;}catch{}let Gt=c==="kalshi"&&!_t,Re=c==="polymarket"&&!Tt,{data:je}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:c,outcome:x},{enabled:e.status==="open"}),ge=react.useMemo(()=>{let R=reactPredict.pickBestAsk(je,x);if(R!=null&&R>0)return R;let Ae=x==="yes"?0:1,We=e.outcomes[Ae];return We?.best_ask??We?.price??.5},[je,e.outcomes,x]),lt=react.useCallback(R=>{b(R);},[]),ht=react.useCallback(R=>{k(R),C(NaN);},[]);react.useEffect(()=>{ht(t);},[t,ht]),react.useEffect(()=>{S==="limit"&&isNaN(M)&&C(Math.round(ge*1e4)/1e4);},[S,M,ge]);let Ne=react.useMemo(()=>S==="limit"&&f&&!isNaN(M)?M:ge,[S,f,M,ge]),ut=react.useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne:0,[y,Ne]),Ce=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:je,outcome:x,side:"buy",sharesNeeded:ut,slippageBps:r}),[je,x,ut,r]),I=react.useMemo(()=>Ce.status==="ok"&&Ce.worstPrice!=null&&Ce.worstPrice>0?Ce.worstPrice:ge,[Ce,ge]),pe=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),tt=e.provider_meta?.["dflow.yesMint"]??"",Xr=e.provider_meta?.["dflow.noMint"]??"",A=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,Ge=x==="yes"?tt:Xr,vt=A,ur=Ge,Dt=c==="kalshi"?v??"":h??"",{data:Jr,isLoading:Co}=reactPredict.usePositionsMulti({kalshi_user:c==="kalshi"?Dt:void 0,polymarket_user:c==="polymarket"?Dt:void 0},{enabled:!!Dt}),Cn=c==="kalshi"&&!!vt&&!!ur&&!!v&&pe!=="0",{refetch:Lr}=reactPredict.useDFlowQuote({inputMint:vt,outputMint:ur,amount:pe,userPublicKey:v??"",slippageBps:100},{enabled:Cn}),qe=react.useMemo(()=>at?c==="kalshi"?at.kalshiUsdcBalance:at.polymarketUsdcBalance:Jr&&Jr.positions.reduce((Ae,We)=>We.side==="USDC"||We.side==="collateral"?Ae+(We.current_value??0):Ae,0)||null,[at,Jr,c]),Rr=at?at.isLoading:Co,_r=react.useMemo(()=>qi({source:c,usdcBalance:qe,feeRateBps:Pe,pricePerShare:Ne}),[c,qe,Pe,Ne]),Ft=qe==null?null:_r,Ir=react.useMemo(()=>isNaN(y)||y<=0?0:y,[y]),qt=react.useMemo(()=>isNaN(y)||y<=0?0:Ne>0?y/Ne*1:0,[y,Ne]),Mn=react.useMemo(()=>c!=="polymarket"||isNaN(y)||y<=0?0:Yi({usdcAmount:y,pricePerShare:Ne,feeRateBps:Pe}),[c,y,Ne,Pe]),Tn=qt-Ir-Mn,Mo=react.useCallback(R=>{if(isNaN(R)){N(NaN);return}N(Math.round(Math.max(0,R)*100)/100);},[]),pr=react.useCallback(R=>{if(isNaN(R)){C(NaN);return}C(Math.round(R*1e4)/1e4);},[]),Bt=react.useCallback(()=>{N(NaN),C(NaN),b("market"),te(false),T("1h"),J(30),ae("minutes");},[]),Yt=react.useMemo(()=>{let R=[];return isNaN(y)||y<=0?R.push(o("predict.trade.minAmountUsd",{amount:Wn})):y<Wn&&R.push(o("predict.trade.minAmountUsd",{amount:Wn})),e.status!=="open"&&R.push(o("predict.trade.marketNotActive")),Ft!=null&&!isNaN(y)&&y>0&&y>Ft&&R.push(o("predict.trade.insufficientBalance")),S==="limit"&&f&&(isNaN(M)||M<.01||M>.99)&&R.push(o("predict.trade.limitPriceRange")),S==="limit"&&f&&q&&P==="custom"&&(isNaN(z)||z<=0)&&R.push(o("predict.trade.expiration.invalidDate")),c==="polymarket"&&S==="market"&&!isNaN(y)&&y>0&&ut>0&&(Ce.status==="insufficient_liquidity"?R.push(o("predict.trade.insufficientLiquidity",{available:xe(Ce.totalAvailable,2)})):Ce.status==="exceeds_slippage"&&R.push(o("predict.trade.priceImpactTooHigh",{impact:(Ce.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:R.length===0,errors:R}},[y,e.status,Ft,S,f,M,q,P,z,c,ut,Ce,r,o]),Or=react.useMemo(()=>Ft==null||isNaN(y)||y<=0?false:y>Ft,[Ft,y]),To=react.useCallback(()=>{n?.(c);},[n,c]),{mutateAsync:Zr}=reactPredict.useDFlowSubmit(),{data:mr}=reactPredict.useOrder({id:U??"",source:c},{enabled:!!U});react.useEffect(()=>{if(!mr||!U)return;let{status:R}=mr;R==="closed"?(Q(null),F(false),Ee("buy-market"),Bt()):(R==="failed"||R==="expired")&&(F(false),Q(null),ui.toast.error(o("predict.trade.submitError")));},[Ee,mr,U,Bt,o]);let bt=react.useCallback(async()=>{if(!v||!d)return;if(!vt||!ur){ui.toast.error("Missing token mint addresses"),F(false);return}if(!_t){Y(true),F(false);return}let Et=(await Lr()).data?.transaction;if(!Et){ui.toast.error(o("predict.trade.submitError")),F(false);return}let en=Uint8Array.from(atob(Et),ct=>ct.charCodeAt(0)),hr=await d.signTransaction(en),Qt=await Zr({signedTransaction:btoa(String.fromCharCode(...hr)),orderContext:{user_public_key:v,input_mint:vt,output_mint:ur,amount:pe,price:String(ge),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(Qt.signature);},[v,d,Lr,Zr,vt,ur,pe,ge,x,e.slug,o,_t]),fr=react.useCallback(async()=>{if(!m||!u)return;let R=m.chain,Ae=R!==types.Chain.POLYGON;Ae&&await m.switchChain(types.Chain.POLYGON);try{let We=await m.getEip1193Provider();if(!We){ui.toast.error(o("predict.trade.submitError")),F(!1);return}let Et=gt==="deposit"&&!!ze,en=!Et&&!!et,hr=Et?ze:et,Qt={address:m.address,signatureType:Et?3:en?2:0,signTypedData:async(le,ye,Ye,rt)=>{let nt=[];"name"in le&&nt.push({name:"name",type:"string"}),"version"in le&&nt.push({name:"version",type:"string"}),"chainId"in le&&nt.push({name:"chainId",type:"uint256"}),"verifyingContract"in le&&nt.push({name:"verifyingContract",type:"address"}),"salt"in le&&nt.push({name:"salt",type:"bytes32"});let Lt={EIP712Domain:nt,...ye};return await We.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:le,types:Lt,primaryType:Ye,message:rt})]})}},ct=u.credentials??await u.authenticate(Qt),vr=x==="yes"?0:1,Ar="",Xt=e.provider_meta?.["polymarket.clobTokenIds"];Xt&&(Ar=(typeof Xt=="string"?JSON.parse(Xt):Xt)[vr]??"");let Dr=e.provider_meta?.["polymarket.negRisk"]??!1,En=S==="limit"&&!isNaN(M)?M:I,Jt=$n(En,we),Ln=S==="limit"?q?"GTD":"GTC":"FOK",Rn=S==="market"?y:Jt>0?y/Jt:0,tn={tokenId:Ar,price:Jt,size:Rn,side:"BUY",orderType:Ln,tickSize:we,negRisk:Dr,...hr&&{funderAddress:hr},...Le&&{builderCode:Le},...S==="limit"&&q&&{expiration:Un(P,z,ue)}},E;if(Et)E=await reactPredict.buildSignedV2OrderPayload({signer:Qt,depositWalletAddress:hr,input:tn,owner:ct.apiKey});else {let le=reactPredict.buildCtfExchangeDomain(Dr),ye=reactPredict.buildOrderMessage({...tn,signerAddress:Qt.address,signatureType:Qt.signatureType,feeRateBps:st}),Ye=await Qt.signTypedData(le,reactPredict.CTF_ORDER_TYPES,"Order",ye),rt=reactPredict.buildSignedOrder(ye,Ye,tn.orderType);E=reactPredict.buildClobPayload(rt,ct.apiKey);}await l.executePolymarketOrder({payload:E,l2_api_key:ct.apiKey,l2_secret:ct.secret,l2_passphrase:ct.passphrase,signer_address:ct.address,owner:ct.apiKey}),Ee(S==="limit"?"buy-limit":"buy-market",async()=>await reactPredict.buildPolymarketL2Headers(ct.address,{apiKey:ct.apiKey,secret:ct.secret,passphrase:ct.passphrase,method:"GET",requestPath:"/data/orders"})),Bt(),F(!1);}finally{Ae&&R&&m.switchChain(R).catch(()=>{});}},[m,u,x,e.provider_meta,S,Ee,M,I,y,l,q,P,z,ue,Bt,o,we,st,et,gt,ze,Le]),gr=react.useCallback(async()=>{if(!(!Yt.isValid||!g)){F(true),Q(null),Y(false);try{c==="kalshi"?await bt():await fr();}catch(R){let Ae=R instanceof Error?R.message:"",We=c==="polymarket"&&Ae?Kn(Ae,o,"buy"):Ae||void 0;ui.toast.error(We||o("predict.trade.submitError")),F(false);}}},[Yt.isValid,g,c,bt,fr,o]);return {outcome:x,orderType:S,quantity:y,limitPrice:M,shares:ut,effectivePrice:Ne,estimatedCost:Ir,estimatedFee:Mn,potentialPayout:qt,potentialProfit:Tn,pricePerShare:ge,usdcBalance:qe,maxBuyAmount:_r,spendableUsdcBalance:Ft,isBalanceLoading:Rr,isMarketDataLoading:c==="polymarket"&&(Oe||Je),isSubmitting:_,authStatus:a,validation:Yt,isInsufficientBalance:Or,source:c,supportsLimitOrder:f,kycRequired:B,needsKyc:Gt,needsSetup:Re,kycUrl:Mt,expirationEnabled:q,expirationPreset:P,customDuration:z,customDurationUnit:ue,setOutcome:ht,setOrderType:lt,setQuantity:Mo,setLimitPrice:pr,setExpirationEnabled:te,setExpirationPreset:T,setCustomDuration:J,setCustomDurationUnit:ae,submit:gr,notifyInsufficientBalance:To}}function jn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=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 Dd=["5m","1h","12h","24h","eod","custom"],Fd={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},Bd=["minutes","hours","days"],Hd={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},zd={maximumFractionDigits:0},sr="-";function ds({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:s,effectivePrice:l,potentialProfit:u,potentialPayout:p,estimatedCost:c,estimatedFee:f=0,usdcBalance:d,isBalanceLoading:m,isMarketDataLoading:g,isSubmitting:v,authStatus:h,isValid:x,validationErrors:k,isInsufficientBalance:S,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:N,kycRequired:M,needsKyc:C,needsSetup:_,kycUrl:F,expirationEnabled:U,expirationPreset:Q,customDuration:B,customDurationUnit:Y,oddsFormatter:q,onOutcomeChange:te,onOrderTypeChange:P,onQuantityChange:T,onLimitPriceChange:z,onExpirationEnabledChange:J,onExpirationPresetChange:ue,onCustomDurationChange:ae,onCustomDurationUnitChange:Ke,onSubmit:Ee}){let{t:w}=i18n.useTranslation(),[He,Je]=react.useState(true),we=ui.useDisclosure(),[Ct,Oe]=react.useState(""),Ve=react.useRef(false);react.useEffect(()=>{Ve.current||Oe(isNaN(i)?"":String(i));},[i]);let[st,Pe]=react.useState(""),Ze=react.useRef(false);react.useEffect(()=>{Ze.current||(isNaN(a)?Pe(""):Pe(String(parseFloat((a*100).toFixed(2)))));},[a]);let Le=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Pe(A),A===""||A==="."){z(NaN);return}let vt=parseFloat(A);isNaN(vt)||z(vt/100);},[z]),at=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Oe(A),tt(false),A===""||A==="."){T(NaN);return}let vt=parseFloat(A);isNaN(vt)||T(vt);},[T]);react.useEffect(()=>{M&&!we.isOpen&&we.onOpen();},[M]);let _t=react.useMemo(()=>{let A=n==="yes"?t.yesAsk:t.noAsk;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),Mt=n==="yes"?t.yesAsk:t.noAsk,Tt=Mt!=null&&q?q(Number(Mt)):_t!=null?`${_t} \xA2`:sr,et=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,gt=Number.isFinite(l)&&q?q(l):et!=null?`${et} \xA2`:sr,ze=!isNaN(i)&&i>0,Gt=ze?c+f:0,Re=ze&&s>0?Gt/s:0,je=Re>0&&q?q(Re):Re>0?`${parseFloat((Re*100).toFixed(2))}\xA2`:sr,ge=h==="authenticated",lt=h==="authenticating"||h==="deauthenticating",ht=ge&&(C||_),Ne=react.useMemo(()=>{if(lt)return w("predict.trade.checkingLogin");if(!ge)return w("predict.trade.loginToTrade");if(C)return w("predict.trade.kycRequired");if(_)return w("predict.trade.setupRequired");if(m)return w("predict.trade.loadingBalance");if(g)return w("predict.trade.loadingMarketData");if(v)return w("predict.trade.submitting");if(M)return w("predict.trade.kycRequired");if(!ze)return w("predict.trade.enterAmount");let A=w(n==="yes"?"predict.trade.yes":"predict.trade.no"),Ge=u>0?` \u2192 Win $${u.toFixed(2)}`:"";return `${w("predict.trade.buy")} ${A}${Ge}`},[lt,ge,C,_,m,g,v,M,ze,n,u,w]),ut="primary",Ce=()=>{let A=N??xe(d??0,2);T(xe(A/2,2));},I=()=>{T(N??xe(d??0,2));},[pe,tt]=react.useState(false),Xr=()=>{if(!ge){tt(false),Ee();return}if(C){we.onOpen();return}if(_&&b){tt(false),b();return}if(M){we.onOpen();return}if(S&&b){tt(false),b();return}if(!x){tt(true);return}tt(false),Ee();};return 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:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:A=>{r==="bordered"&&(A.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&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:[w("predict.trade.buy")," ",w(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:[y?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>P(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&y?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:st,onChange:A=>Le(A.target.value),onFocus:()=>{Ze.current=true;},onBlur:()=>{Ze.current=false,isNaN(a)?Pe(""):Pe(String(parseFloat((a*100).toFixed(2))));},endContent: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"}}):Tt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:Tt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(A=>{let Ge=A==="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:()=>te(A),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===A?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:w(A==="yes"?"predict.trade.yes":"predict.trade.no")}),Ge!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:q?q(Number(Ge)):`${parseFloat((Number(Ge)*100).toFixed(2))}\xA2`})]})},A)})}),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:w("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",onClick:Ce,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:I,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ct,onChange:A=>at(A.target.value),onFocus:()=>{Ve.current=true;},onBlur:()=>{Ve.current=false,Oe(isNaN(i)?"":String(i));},startContent: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&&k.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:k.map(A=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:A},A))})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-1.5 text-sm",children:[jsxRuntime.jsx("span",{className:"text-neutral-500",children:w("predict.trade.balance")}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`$${xe(d,2).toFixed(2)}`:"$0"})]}),o==="limit"&&y&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:w("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:U,onValueChange:J,"aria-label":w("predict.trade.setExpiration")})]}),U&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[Q],onSelectionChange:A=>{let Ge=Array.from(A)[0];Ge&&ue(Ge);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Dd.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:w(Fd[A])},A))}),Q==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(B)?void 0:B,onValueChange:ae,minValue:1,step:1,formatOptions:zd,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsxRuntime.jsx(ui.Select,{"aria-label":"Duration unit",selectedKeys:[Y],onSelectionChange:A=>{let Ge=Array.from(A)[0];Ge&&Ke(Ge);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Bd.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:w(Hd[A])},A))})]})]})]}),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:()=>Je(A=>!A),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:w("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",He&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:q&&Number.isFinite(l)?gt:et!=null?w("predict.trade.chance",{percent:et}):sr})]}),He&&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:w("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:sr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?yr(s):sr})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${f.toFixed(2)}`})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.totalPayment")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${Gt.toFixed(2)}`})]}),f>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:je})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:sr})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&u>0?`+$${u.toFixed(2)}`:sr})]})]})]}),jsxRuntime.jsx(ui.Button,{color:ut,fullWidth:true,radius:"lg",size:"lg",isDisabled:lt||ge&&!ht&&(m||g||!ze||v),isLoading:lt||ge&&!ht&&(v||m||g),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Xr,children:Ne})]}),jsxRuntime.jsx(jn,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:F})]})}function qn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:a,onOutcomeChange:s,oddsFormatter:l}){let{outcome:u,orderType:p,quantity:c,limitPrice:f,shares:d,effectivePrice:m,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,pricePerShare:k,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:N,isSubmitting:M,authStatus:C,validation:_,isInsufficientBalance:F,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:P,customDuration:T,customDurationUnit:z,setOutcome:J,setOrderType:ue,setQuantity:ae,setLimitPrice:Ke,setExpirationEnabled:Ee,setExpirationPreset:w,setCustomDuration:He,setCustomDurationUnit:Je,submit:we,notifyInsufficientBalance:Ct}=ts({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:a}),Oe=walletConnector.useAuthCallback(we),Ve=react.useCallback(Ze=>{J(Ze),s?.(Ze);},[J,s]),st=react.useMemo(()=>e?Dn(e):void 0,[e]),Pe=react.useMemo(()=>Fn(t,{yesAsk:u==="yes"?k:void 0,noAsk:u==="no"?k:void 0}),[t,u,k]);return jsxRuntime.jsx(ds,{event:st,market:Pe,variant:r,outcome:u,orderType:p,quantity:c,limitPrice:f,shares:d,effectivePrice:m,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:N,isSubmitting:M,authStatus:C,isValid:_.isValid,validationErrors:_.errors,isInsufficientBalance:F,onInsufficientBalance:a?Ct:void 0,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:P,customDuration:T,customDurationUnit:z,oddsFormatter:l,onOutcomeChange:Ve,onOrderTypeChange:ue,onQuantityChange:ae,onLimitPriceChange:Ke,onExpirationEnabledChange:Ee,onExpirationPresetChange:w,onCustomDurationChange:He,onCustomDurationUnitChange:Je,onSubmit:Oe})}var on="predict-trade";function Yn({id:e=on}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Yd,{...t})})}function Yd({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(qn,{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 sn={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Uo(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function ps({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState(r),l=react.useMemo(()=>o?sn:{...sn,source:"polymarket"},[o]),u=react.useCallback(x=>{x?s(r):t();},[r,t]),p=react.useCallback(()=>{s(l);},[l]),c=react.useCallback(()=>{n(a),t();},[a,n,t]),f=react.useCallback((x,k)=>{s(S=>({...S,[x]:k}));},[]),d=react.useMemo(()=>Uo(a,o),[a,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]),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]),h=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange: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(tu,{onClick:()=>u(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsxRuntime.jsx(Xn,{label:i("predict.filter.platform"),children:jsxRuntime.jsx(Jn,{options:m,selected:a.source,onSelect:x=>f("source",x)})}),jsxRuntime.jsx(Xn,{label:i("predict.filter.timeRemaining"),children:jsxRuntime.jsx(Jn,{options:g,selected:a.timeRemaining,onSelect:x=>f("timeRemaining",x)})}),jsxRuntime.jsx(Xn,{label:i("predict.filter.minVolume"),children:jsxRuntime.jsx(Jn,{options:v,selected:a.minVolume,onSelect:x=>f("minVolume",x)})}),jsxRuntime.jsx(Xn,{label:i("predict.filter.minLiquidity"),children:jsxRuntime.jsx(Jn,{options:h,selected:a.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: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:c,children:[i("predict.filter.showResults"),d>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",d,")"]})]})]})]})})})}function Xn({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 tu({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 Jn({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:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{i||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var vs={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},fs={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},du=["start_time","volume","liquidity","ending_soon"],gs={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},uu={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function bs({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:a}){let{t:s}=i18n.useTranslation(),[l,u]=react.useState(false),p=react.useRef(null),c=react.useCallback(d=>{p.current&&!p.current.contains(d.target)&&u(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),react.useEffect(()=>{if(!l)return;let d=m=>{m.key==="Escape"&&u(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let f=hs[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:p,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:gs,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>u(d=>!d),children:[jsxRuntime.jsx(pu,{}),jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(fs[e])}),jsxRuntime.jsx(fu,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...uu,width:224,padding:4},children:du.map(d=>{let m=hs[d],g=e===d;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background: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===d?n(!r):t(d),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:s(fs[d])}),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"})})]},d)})})]}),jsxRuntime.jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:gs,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsxRuntime.jsx(mu,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s("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 hs={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function pu(){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 mu(){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 fu({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 ks(e={}){let{i18n:t}=i18n.useTranslation(),r=t.resolvedLanguage??t.language,n=react.useMemo(()=>reactPredict.resolveEventsParams({...e,lang:r}),[r,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:o,isLoading:i,isFetching:a,isFetchingNextPage:s,isError:l,error:u,hasNextPage:p,fetchNextPage:c,refetch:f}=reactPredict.useInfiniteEvents(n),d=react.useMemo(()=>o?.pages.flatMap(v=>v.items).filter(v=>v!=null)??[],[o]),m=react.useCallback(()=>{c();},[c]),g=react.useCallback(()=>{f();},[f]);return {data:d,isLoading:i,isFetching:a&&!s,isFetchingMore:s,isError:l,error:u??null,hasMore:p??false,fetchMore:m,refetch:g}}var Ss=`
2
2
  @keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
3
3
  @media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
4
4
  @media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}
5
5
  @media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}
6
- `,ws={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function Zn(e){return {...ws,animationDelay:`${e}ms`}}function $o({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:Ss}),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(vu,{index:r},r))})]})}function vu({index:e}){let t=e*120,r={...ws,animationDelay:`${t}ms`},n=e%3===0?"85%":e%3===1?"70%":"60%";return 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 bu(){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:{...Zn(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:{...Zn(0),height:36,width:120,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...Zn(50),height:36,width:36,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...Zn(100),height:36,width:80,borderRadius:10}})]})]})}function mx({count:e=24}){return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsxRuntime.jsx("style",{children:Ss}),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(bu,{})}),jsxRuntime.jsx("div",{style:{padding:"12px 8px 80px"},children:jsxRuntime.jsx($o,{count:e})})]})}var Ps=3,Tu={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},Eu={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Vo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ls={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Lu={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},an=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function Ns(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function Ru(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [Vo,Lu];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [Vo,Ls];let r=t[0]??"",n=t[1]??"",o=Ns(r)%an.length,i=Ns(n)%an.length;return i===o&&(i=(i+1)%an.length),[an[o],an[i]]}function Cs(e){return e.title_trans||e.title}function _u(e){return e.question_trans||e.question}function jo(e,t){return e?.label_trans||e?.label||t}function Rs(e){return jo(e.outcomes?.[0],_u(e))}function Iu(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function _s(e){let t=Iu(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Is(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Ms(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Ts(e){let t=e.outcomes?.[1];if(t){let o=t.best_ask??t.price??0;return parseFloat((o*100).toFixed(2)).toString()}let r=e.outcomes?.[0],n=r?.best_ask??r?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function Ou(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),n=Math.floor(t%864e5/36e5),o=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),n>0&&i.push(`${n}h`),i.push(`${o}m`),i.join(" ")}var Au=`
6
+ `,ws={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};function Zn(e){return {...ws,animationDelay:`${e}ms`}}function $o({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:Ss}),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(bu,{index:r},r))})]})}function bu({index:e}){let t=e*120,r={...ws,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 xu(){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:{...Zn(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:{...Zn(0),height:36,width:120,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...Zn(50),height:36,width:36,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...Zn(100),height:36,width:80,borderRadius:10}})]})]})}function gx({count:e=24}){return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative",width:"100%",maxWidth:1680,margin:"0 auto"},children:[jsxRuntime.jsx("style",{children:Ss}),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(xu,{})}),jsxRuntime.jsx("div",{style:{padding:"12px 8px 80px"},children:jsxRuntime.jsx($o,{count:e})})]})}var Ps=3,Eu={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)"}},Lu={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},Vo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ls={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Ru={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},an=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function Ns(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function _u(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [Vo,Ru];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [Vo,Ls];let r=t[0]??"",n=t[1]??"",o=Ns(r)%an.length,i=Ns(n)%an.length;return i===o&&(i=(i+1)%an.length),[an[o],an[i]]}function Cs(e){return e.title_trans||e.title}function Iu(e){return e.question_trans||e.question}function jo(e,t){return e?.label_trans||e?.label||t}function Rs(e){return jo(e.outcomes?.[0],Iu(e))}function Ou(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function _s(e){let t=Ou(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Is(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Ms(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Ts(e){let t=e.outcomes?.[1];if(t){let o=t.best_ask??t.price??0;return parseFloat((o*100).toFixed(2)).toString()}let r=e.outcomes?.[0],n=r?.best_ask??r?.price??0;return parseFloat(((1-n)*100).toFixed(2)).toString()}function Au(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 Du=`
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 Os({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[a,s]=react.useState(null),l=e.markets??[],p=react.useMemo(()=>l.length>2?[...l].sort((b,y)=>(y.outcomes?.[0]?.price??0)-(b.outcomes?.[0]?.price??0)):l,[l]).filter(b=>b.status==="open"),d=p.length===1,f=p.slice(0,Ps),c=p.length-Ps,m=react.useMemo(()=>utils$1.formatAmountInUsd(e.volume??0),[e.volume]),g=a?p.find(b=>b.slug===a)??null:null,v=!!g||d,h=()=>{v||n?.(e);},x=b=>{b.stopPropagation(),g&&(b.preventDefault(),s(null));},k=b=>{b.stopPropagation(),t||(b.preventDefault(),n?.(e));},S=d?jsxRuntime.jsx(Gu,{event:e,formattedVolume:m,href:t,LinkComponent:r,onSelect:n}):g?jsxRuntime.jsx(Yu,{onCollapse:()=>s(null)}):jsxRuntime.jsx($u,{moreCount:c,formattedVolume:m,source:e.source,href:t,LinkComponent:r,onShowMore:k});return jsxRuntime.jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:b=>{let y=b.currentTarget,N=Tu[e.source]??Eu;y.style.borderColor=N.border,y.style.boxShadow=N.shadow,i?.(e);},onMouseLeave:b=>{let y=b.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:h,children:[jsxRuntime.jsx("style",{children:Au}),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:d?jsxRuntime.jsx(ju,{market:p[0],event:e,onSelectOutcome:o}):g?jsxRuntime.jsx(qu,{market:g,event:e,onCollapse:()=>s(null),onSelectOutcome:o}):jsxRuntime.jsx(Uu,{displayedMarkets:f,onMarketClick:b=>s(b.slug)})})]}),jsxRuntime.jsx(Ku,{children:S})]})}function Du({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?Ou(e.start_at):null;return 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:Cs(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),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:Cs(e)}),i&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsxRuntime.jsx(Bu,{event:e})]})}function Fu(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,a=900*1e3;if(o>0&&o<=a){let s=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:s});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Bu({event:e}){let t=react.useMemo(()=>Fu(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(Hu,{},n);case "crypto-short":return jsxRuntime.jsx(zu,{label:r.label,color:r.color},n);case "closed":return jsxRuntime.jsx(Wu,{},n)}})})}function Hu(){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 zu({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 Wu(){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 Uu({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=_s(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:Rs(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:Is(n)}),jsxRuntime.jsx(Vu,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function $u({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:a}=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:[a("predict.event.showMore"),jsxRuntime.jsx(Ds,{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," ",a("predict.event.volume"),jsxRuntime.jsx(Fs,{source:r})]})]})}function Ku({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 Es({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function As({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=i18n.useTranslation(),[a,s]=n?Ru(e):[Vo,Ls],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",p=o==="label"&&l===u?"action":o,d=p==="label"?`${jo(e.outcomes?.[0],"Yes")} ${Ms(e)}\xA2`:i("predict.market.action.yes",{price:Ms(e)}),f=p==="label"?`${jo(e.outcomes?.[1],"No")} ${Ts(e)}\xA2`:i("predict.market.action.no",{price:Ts(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Es,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"yes");},children:d}),jsxRuntime.jsx(Es,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:c=>{c.stopPropagation(),r?.(t,e,"no");},children:f})]})}function Vu(){let{t:e}=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 ju({market:e,event:t,onSelectOutcome:r}){return jsxRuntime.jsx("div",{style:{flex:1},children:jsxRuntime.jsx(As,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function Gu({event:e,formattedVolume:t,href:r,LinkComponent:n,onSelect:o}){let{t:i}=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:s=>{s.stopPropagation(),r||(s.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(Ds,{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(Fs,{source:e.source})]})]})}function qu({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=_s(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:Rs(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:Is(o)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{style:{marginTop:12},children:jsxRuntime.jsx(As,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function Yu({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(Qu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsxRuntime.jsx("div",{})]})}function Ds({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 Qu({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 Fs({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 ep=8;function Hs({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:a,LinkComponent:s,onHover:l}){let{t:u}=i18n.useTranslation(),p=react.useRef(null);react.useEffect(()=>{let c=p.current;if(!c)return;let m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return m.observe(c),()=>m.disconnect()},[t,r,n]);let d=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 Os({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[a,s]=react.useState(null),l=e.markets??[],p=react.useMemo(()=>l.length>2?[...l].sort((b,y)=>(y.outcomes?.[0]?.price??0)-(b.outcomes?.[0]?.price??0)):l,[l]).filter(b=>b.status==="open"),c=p.length===1,f=p.slice(0,Ps),d=p.length-Ps,m=react.useMemo(()=>utils$1.formatAmountInUsd(e.volume??0),[e.volume]),g=a?p.find(b=>b.slug===a)??null:null,v=!!g||c,h=()=>{v||n?.(e);},x=b=>{b.stopPropagation(),g&&(b.preventDefault(),s(null));},k=b=>{b.stopPropagation(),t||(b.preventDefault(),n?.(e));},S=c?jsxRuntime.jsx(qu,{event:e,formattedVolume:m,href:t,LinkComponent:r,onSelect:n}):g?jsxRuntime.jsx(Qu,{onCollapse:()=>s(null)}):jsxRuntime.jsx(Ku,{moreCount:d,formattedVolume:m,source:e.source,href:t,LinkComponent:r,onShowMore:k});return jsxRuntime.jsxs("div",{className:"group evt-card",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:v?void 0:"pointer"},onMouseEnter:b=>{let y=b.currentTarget,N=Eu[e.source]??Lu;y.style.borderColor=N.border,y.style.boxShadow=N.shadow,i?.(e);},onMouseLeave:b=>{let y=b.currentTarget;y.style.borderColor="rgba(39,39,42,0.6)",y.style.boxShadow="none";},onClick:h,children:[jsxRuntime.jsx("style",{children:Du}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsxRuntime.jsx(Fu,{event:e,href:t,LinkComponent:r,onClick:x,isExpanded:v}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:c?jsxRuntime.jsx(Gu,{market:p[0],event:e,onSelectOutcome:o}):g?jsxRuntime.jsx(Yu,{market:g,event:e,onCollapse:()=>s(null),onSelectOutcome:o}):jsxRuntime.jsx($u,{displayedMarkets:f,onMarketClick:b=>s(b.slug)})})]}),jsxRuntime.jsx(Vu,{children:S})]})}function Fu({event:e,href:t,LinkComponent:r,onClick:n,isExpanded:o}){let i=e.start_at?Au(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:Cs(e)||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),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:Cs(e)}),i&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsxRuntime.jsx(Hu,{event:e})]})}function Bu(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(o=>o.label?.toLowerCase()==="crypto"),n=e.tags?.some(o=>o.label?.toLowerCase()==="live");if(r&&e.end_at){let o=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,a=900*1e3;if(o>0&&o<=a){let s=o<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:o<=i?"5m":"15m",color:s});}}return n&&t.push({kind:"live"}),t.slice(0,2)}function Hu({event:e}){let t=react.useMemo(()=>Bu(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(zu,{},n);case "crypto-short":return jsxRuntime.jsx(Wu,{label:r.label,color:r.color},n);case "closed":return jsxRuntime.jsx(Uu,{},n)}})})}function zu(){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 Wu({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 Uu(){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 $u({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=_s(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:Rs(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:Is(n)}),jsxRuntime.jsx(ju,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function Ku({moreCount:e,formattedVolume:t,source:r,href:n,LinkComponent:o,onShowMore:i}){let{t:a}=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:[a("predict.event.showMore"),jsxRuntime.jsx(Ds,{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," ",a("predict.event.volume"),jsxRuntime.jsx(Fs,{source:r})]})]})}function Vu({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 Es({bgColor:e,textColor:t,shadowColor:r,onClick:n,children:o}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:n,children:o})}function As({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=i18n.useTranslation(),[a,s]=n?_u(e):[Vo,Ls],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",p=o==="label"&&l===u?"action":o,c=p==="label"?`${jo(e.outcomes?.[0],"Yes")} ${Ms(e)}\xA2`:i("predict.market.action.yes",{price:Ms(e)}),f=p==="label"?`${jo(e.outcomes?.[1],"No")} ${Ts(e)}\xA2`:i("predict.market.action.no",{price:Ts(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Es,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"yes");},children:c}),jsxRuntime.jsx(Es,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"no");},children:f})]})}function ju(){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 Gu({market:e,event:t,onSelectOutcome:r}){return jsxRuntime.jsx("div",{style:{flex:1},children:jsxRuntime.jsx(As,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function qu({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:s=>{s.stopPropagation(),r||(s.preventDefault(),o?.(e));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(Ds,{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(Fs,{source:e.source})]})]})}function Yu({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=_s(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:Rs(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:Is(o)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{style:{marginTop:12},children:jsxRuntime.jsx(As,{market:e,event:t,onSelectOutcome:n,labelFormat:"action"})})]})}function Qu({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(Xu,{className:"h-3 w-3"}),t("predict.event.back")]}),jsxRuntime.jsx("div",{})]})}function Ds({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 Xu({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 Fs({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 tp=8;function Hs({events:e,hasMore:t=false,isFetchingMore:r=false,onFetchMore:n,onSelect:o,onSelectOutcome:i,getEventHref:a,LinkComponent:s,onHover:l}){let{t:u}=i18n.useTranslation(),p=react.useRef(null);react.useEffect(()=>{let d=p.current;if(!d)return;let m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return m.observe(d),()=>m.disconnect()},[t,r,n]);let c=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((c,m)=>c==null?null:jsxRuntime.jsx("div",{style:{padding:ep,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${m%4*35}ms both`},children:jsxRuntime.jsx(Os,{event:c,href:a?.(c),LinkComponent:s,onSelect:o,onSelectOutcome:i,onHover:l})},`${c.source}-${c.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(tp,{onScrollToTop:d})]})}function tp({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 Ws({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p,onSelect:d,onSelectOutcome:f,getEventHref:c,LinkComponent:m,onHover:g}){let{data:v,hasMore:h,fetchMore:x,isFetching:k,isFetchingMore:S}=ks({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p});return k?jsxRuntime.jsx($o,{count:24}):jsxRuntime.jsx(Hs,{events:v,hasMore:h,isFetchingMore:S,onFetchMore:x,onSelect:d,onSelectOutcome:f,getEventHref:c,LinkComponent:m,onHover:g})}function Wx({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:a,enableKalshi:s=true}){let[l,u]=react.useState({categorySlug:null,tagSlug:null}),[p,d]=react.useState(()=>s?sn:{...sn,source:"polymarket"}),{isOpen:f,onOpen:c,onClose:m}=ui.useDisclosure(),{onOpen:g}=uiScaffold.useAsyncModal(on),v=react.useCallback((M,C,_)=>{t?.(M,C,_),g({params:{event:M,market:C,initialOutcome:_,onInsufficientBalance:a}});},[t,g,a]),h=react.useCallback(M=>{u(M);},[]),x=react.useCallback(M=>{d(C=>({...C,sortPreset:M}));},[]),k=react.useCallback(M=>{d(C=>({...C,sortAsc:M}));},[]),S=react.useCallback(M=>{d(M);},[]),b=react.useMemo(()=>vs[p.sortPreset].sort_by,[p.sortPreset]),y=react.useMemo(()=>Uo(p,s),[p,s]),N=react.useMemo(()=>jsxRuntime.jsx(bs,{sortPreset:p.sortPreset,onSortChange:x,sortAsc:p.sortAsc,onSortAscChange:k,onFilterPress:c,filterCount:y}),[p.sortPreset,p.sortAsc,y,x,k,c]);return 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($i,{onSelect:h,trailing:N})}),jsxRuntime.jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsxRuntime.jsx(ps,{isOpen:f,onClose:m,value:p,onChange:S,enableKalshi:s}),jsxRuntime.jsx(Ws,{tagSlugSelection:l,sort_by:b,sort_asc:p.sortAsc,source:p.source,timeRemaining:p.timeRemaining,minVolume:p.minVolume,minLiquidity:p.minLiquidity,onSelect:e,onSelectOutcome:v,getEventHref:r,LinkComponent:n,onHover:o})]}),jsxRuntime.jsx(Yn,{})]})}function Vs(e){return utils$1.formatAmountInUsd(e)}var sp=[{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:Vs,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:Vs,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>utils$1.formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function jx({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
36
+ `}),jsxRuntime.jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((d,m)=>d==null?null:jsxRuntime.jsx("div",{style:{padding:tp,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${m%4*35}ms both`},children:jsxRuntime.jsx(Os,{event:d,href:a?.(d),LinkComponent:s,onSelect:o,onSelectOutcome:i,onHover:l})},`${d.source}-${d.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(rp,{onScrollToTop:c})]})}function rp({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 Ws({tagSlugSelection:e,limit:t=24,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p,onSelect:c,onSelectOutcome:f,getEventHref:d,LinkComponent:m,onHover:g}){let{data:v,hasMore:h,fetchMore:x,isFetching:k,isFetchingMore:S}=ks({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:l,minLiquidity:u,markets_limit:p});return k?jsxRuntime.jsx($o,{count:24}):jsxRuntime.jsx(Hs,{events:v,hasMore:h,isFetchingMore:S,onFetchMore:x,onSelect:c,onSelectOutcome:f,getEventHref:d,LinkComponent:m,onHover:g})}function $x({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:a,enableKalshi:s=true}){let[l,u]=react.useState({categorySlug:null,tagSlug:null}),[p,c]=react.useState(()=>s?sn:{...sn,source:"polymarket"}),{isOpen:f,onOpen:d,onClose:m}=ui.useDisclosure(),{onOpen:g}=uiScaffold.useAsyncModal(on),v=react.useCallback((M,C,_)=>{t?.(M,C,_),g({params:{event:M,market:C,initialOutcome:_,onInsufficientBalance:a}});},[t,g,a]),h=react.useCallback(M=>{u(M);},[]),x=react.useCallback(M=>{c(C=>({...C,sortPreset:M}));},[]),k=react.useCallback(M=>{c(C=>({...C,sortAsc:M}));},[]),S=react.useCallback(M=>{c(M);},[]),b=react.useMemo(()=>vs[p.sortPreset].sort_by,[p.sortPreset]),y=react.useMemo(()=>Uo(p,s),[p,s]),N=react.useMemo(()=>jsxRuntime.jsx(bs,{sortPreset:p.sortPreset,onSortChange:x,sortAsc:p.sortAsc,onSortAscChange:k,onFilterPress:d,filterCount:y}),[p.sortPreset,p.sortAsc,y,x,k,d]);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($i,{onSelect:h,trailing:N})}),jsxRuntime.jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsxRuntime.jsx(ps,{isOpen:f,onClose:m,value:p,onChange:S,enableKalshi:s}),jsxRuntime.jsx(Ws,{tagSlugSelection:l,sort_by:b,sort_asc:p.sortAsc,source:p.source,timeRemaining:p.timeRemaining,minVolume:p.minVolume,minLiquidity:p.minLiquidity,onSelect:e,onSelectOutcome:v,getEventHref:r,LinkComponent:n,onHover:o})]}),jsxRuntime.jsx(Yn,{})]})}function Vs(e){return utils$1.formatAmountInUsd(e)}var ap=[{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:Vs,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)"},{key:"avg_liquidity",labelKey:"predict.events.stats.avgLiquidity",format:Vs,valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)"},{key:"active_sources",labelKey:"predict.events.stats.activeSources",format:e=>utils$1.formatAmount(e),valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)"}];function qx({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,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:sp.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 Ys({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i,i18n:a}=i18n.useTranslation(),{mutateAsync:s}=reactPredict.useRedeemPosition(),{start:l}=reactPredict.useTradeResultConfirmation(),{evmAddress:u}=xr(),p=walletConnector.useWallets(),[d,f]=react.useState("idle"),[c,m]=react.useState(null),g=t.provider_meta?.["polymarket.conditionId"],v=t.provider_meta?.["polymarket.negRisk"]??false,h=u??"",x=react.useMemo(()=>Hr(i,a),[a,i]),k=react.useMemo(()=>p.find(Y=>Y.chainNamespace===types.ChainNamespace.EVM&&Y.isConnected),[p]),S=qs(r.side,t.outcomes),y=t.outcomes?.[S]?.label??r.side,N=t.result!=null?qs(t.result,t.outcomes):-1,C=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",_=t.result!=null?S===N:true,F=react.useMemo(()=>_?r.size:0,[_,r.size]),U=react.useCallback(async()=>{if(!(!g||!h||!k)){f("pending"),m(null);try{let Y=await k.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:g,neg_risk:v,signMessage:async P=>await Y.request({method:"personal_sign",params:[P,h]}),signTypedData:async P=>await Y.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(P)]})}),f("confirming");let q=zr({messages:x});q.submitted(),await l({source:r.source,user:h,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem"})==="confirmed"?(f("success"),q.completed()):(f("delayed"),q.delayed()),n?.();}catch(Y){f("error"),m(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,h,v,k,s,x,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,n,i]),Q=walletConnector.useAuthCallback(U),B=d==="idle"&&!!g&&!!h&&!!k&&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(eo,{label:i("predict.positions.side"),value:y,valueClassName:_?"text-green-400":"text-red-400"}),t.result!=null&&jsxRuntime.jsx(eo,{label:i("predict.redeem.result"),value:C,valueClassName:"text-green-400"}),jsxRuntime.jsx(eo,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsxRuntime.jsx(eo,{label:i("predict.redeem.expectedPayout"),value:`$${F.toFixed(2)}`,valueClassName:F>0?"text-green-400":"text-zinc-400"})]}),!_&&F===0&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),d==="error"&&c&&jsxRuntime.jsx("p",{className:"text-sm text-red-400",children:c}),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:!B,isLoading:d==="pending"||d==="confirming",onPress:Q,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 eo({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 qs(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var kp="predict-redeem";function Xs({id:e=kp}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Sp,{...t})})}function Sp({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(Ys,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function ta({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:n=100,onSuccess:o}){let{t:i,i18n:a}=i18n.useTranslation(),s=react.useRef(o);s.current=o;let{status:l}=walletConnector.useAuth(),u=walletConnector.useWallets(),p=reactPredict.usePredictClient(),d=react.useContext(reactPredict.PolymarketContext),f=reactQuery.useQueryClient(),{start:c}=reactPredict.useTradeResultConfirmation(),m=e.source,g=m==="polymarket",v=u.find(E=>E.chainNamespace===types.ChainNamespace.SOLANA&&E.isConnected),h=u.find(E=>E.chainNamespace===types.ChainNamespace.EVM&&E.isConnected&&"switchChain"in E),x=l==="authenticated",k=v?.address,S=h?.address,[b,y]=react.useState(t),[N,M]=react.useState("market"),[C,_]=react.useState(NaN),[F,U]=react.useState(NaN),[Q,B]=react.useState(false),[Y,q]=react.useState(false),[te,P]=react.useState(null),[T,z]=react.useState(null),[J,ue]=react.useState(false),[ae,Ke]=react.useState(false),[Ee,w]=react.useState("1h"),[He,Je]=react.useState(30),[we,Ct]=react.useState("minutes"),Oe=react.useMemo(()=>Hr(i,a),[a,i]),Ve=react.useCallback(async(E,le)=>{let ye=zr({messages:Oe});ye.submitted(),await c({source:m,user:m==="kalshi"?k:S,kalshiUser:k,polymarketUser:S,marketSlug:e.slug,eventSlug:e.event_slug,expectation:E,getOrdersHeaders:le})==="confirmed"?ye.completed():ye.delayed();},[c,S,e.event_slug,e.slug,m,Oe,k]),st=react.useMemo(()=>{if(m!=="polymarket")return;let E=e.provider_meta?.["polymarket.clobTokenIds"];return E?(typeof E=="string"?JSON.parse(E):E)[b==="yes"?0:1]:void 0},[m,e.provider_meta,b]),{data:Pe,isLoading:Ze}=reactPredict.useTickSize(st),Le=Pe?.minimum_tick_size?String(Pe.minimum_tick_size):"0.01",{data:at,isLoading:_t}=reactPredict.useFeeRate(st),Mt=String(at?.base_fee??0),{data:Tt}=reactPredict.useRebateConfig(),et=Tt?.builder_enabled&&Tt.builder_code?Tt.builder_code:void 0,gt=false,ze=null,Gt=false,Re,je,ge;try{let E=xr();gt=E.kalshiKycVerified,ze=E.kalshiKycUrl,Gt=E.polymarketSetupVerified,Re=E.polymarketSafeAddress,je=E.polymarketWalletKind,ge=E.polymarketWalletAddress;}catch{}let lt=m==="kalshi"&&!gt,ht=m==="polymarket"&&!Gt,Ne=react.useCallback(async()=>{if(!h||!d)return null;let E=await h.getEip1193Provider();if(!E)return null;let le=je==="deposit"&&!!ge,ye=!le&&!!Re,Ye={address:h.address,signatureType:le?3:ye?2:0,signTypedData:async(rt,nt,Lt,_e)=>{let ir=[];"name"in rt&&ir.push({name:"name",type:"string"}),"version"in rt&&ir.push({name:"version",type:"string"}),"chainId"in rt&&ir.push({name:"chainId",type:"uint256"}),"verifyingContract"in rt&&ir.push({name:"verifyingContract",type:"address"}),"salt"in rt&&ir.push({name:"salt",type:"bytes32"});let _n={EIP712Domain:ir,...nt};return await E.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:rt,types:_n,primaryType:Lt,message:_e})]})}};return d.credentials??await d.authenticate(Ye)},[Re,je,ge,h,d]),{data:ut}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:m,outcome:b},{enabled:e.status==="open"}),Ce=react.useMemo(()=>{let E=reactPredict.pickBestBid(ut,b);if(E!=null&&E>0)return E;let le=b==="yes"?0:1,ye=e.outcomes[le];return ye?.best_bid??ye?.price??.5},[ut,e.outcomes,b]),I=m==="kalshi"?k??"":S??"",{data:pe,isLoading:tt}=reactPredict.usePositionsMulti({kalshi_user:m==="kalshi"?I:void 0,polymarket_user:m==="polymarket"?I:void 0},{enabled:!!I,refetchInterval:3e4}),Xr=react.useCallback(async()=>{let E=await Ne();return E?await reactPredict.buildPolymarketL2Headers(E.address,{apiKey:E.apiKey,secret:E.secret,passphrase:E.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Ne]),{data:A,isLoading:Ge}=reactPredict.useAvailableShares({source:m,user:I,market:e.slug,side:b},m==="polymarket"?{getHeaders:Xr}:void 0,{enabled:!!I&&!!e.slug,refetchOnMount:"always"}),vt=e.provider_meta?.["dflow.yesMint"]??"",ur=e.provider_meta?.["dflow.noMint"]??"",Dt=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,Jr=e.provider_meta?.["dflow.collateralMint"]||"",Co=b==="yes"?vt:ur,Cn=(r||b).trim().toLowerCase(),Lr=react.useMemo(()=>pe?pe.positions.find(E=>E.side?.trim().toLowerCase()===Cn&&E.market?.slug===e.slug)??null:null,[pe,e.slug,Cn]),qe=react.useMemo(()=>m==="polymarket"?reactPredict.getPolymarketSharesPrecision(Le):A?.precision??0,[m,Le,A?.precision]),Rr=A?.active_order_shares??0,_r=m==="polymarket"&&!!r&&!!Lr?.size&&(A?.total_shares??0)<=0&&(A?.available_shares??0)<=0,Ft=_r?Lr?.size??0:0,Ir=_r?Ft:A?.total_shares??0,qt=_r?Math.max(0,Ft-Rr):A?.available_shares??0,Mn=Ge||tt,Tn=Lr?.market?.provider_meta,Mo=Tn?.["dflow.outcomeMint"]||Co,pr=Tn?.["dflow.collateralMint"]||Jr,Bt=Mo,Yt=pr||Dt,Or=react.useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),To=m==="kalshi"&&!!Bt&&!!Yt&&!!k&&Or!=="0",{refetch:Zr}=reactPredict.useDFlowQuote({inputMint:Bt,outputMint:Yt,amount:Or,userPublicKey:k??"",slippageBps:100},{enabled:To}),mr=react.useMemo(()=>isNaN(C)||C<=0?0:C,[C]),bt=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:ut,outcome:b,side:"sell",sharesNeeded:mr,slippageBps:n}),[ut,b,mr,n]),fr=react.useMemo(()=>bt.status==="ok"&&bt.worstPrice!=null&&bt.worstPrice>0?bt.worstPrice:Ce,[bt,Ce]),gr=react.useMemo(()=>N==="limit"&&g&&!isNaN(F)?F:fr,[N,g,F,fr]),R=react.useMemo(()=>isNaN(C)||C<=0?0:C*gr,[C,gr]),Ae=react.useMemo(()=>m!=="polymarket"?0:Qi({grossReturn:R,pricePerShare:gr,feeRateBps:Number(Mt)}),[m,R,gr,Mt]),We=react.useMemo(()=>Math.max(0,R-Ae),[R,Ae]),Et=react.useCallback(E=>{y(E),U(NaN),_(NaN),q(false);},[]);react.useEffect(()=>{Et(t);},[t,Et]);let en=react.useCallback(E=>{M(E);},[]);react.useEffect(()=>{N==="limit"&&U(Math.round(Ce*1e4)/1e4);},[N,b]);let hr=react.useCallback(E=>{if(q(false),isNaN(E)){_(NaN);return}_(xe(Math.max(0,E),qe));},[qe]),Qt=react.useCallback(()=>{q(true),_(xe(qt,qe));},[qt,qe]),ct=react.useCallback(E=>{if(isNaN(E)){U(NaN);return}U(Math.round(E*1e4)/1e4);},[]),vr=react.useCallback(()=>{_(NaN),U(NaN),M("market"),q(false),Ke(false),w("1h"),Je(30),Ct("minutes");},[]),Ar=react.useMemo(()=>{let E=[];return isNaN(C)||C<=0?E.push(i("predict.trade.minQuantity",{amount:zn})):C<zn&&E.push(i("predict.trade.minQuantity",{amount:zn})),e.status!=="open"&&E.push(i("predict.trade.marketNotActive")),!isNaN(C)&&C>0&&!Y&&C>qt&&E.push(i("predict.trade.insufficientSharesDetail",{total:xe(Ir,qe).toFixed(qe),active:xe(Rr,qe).toFixed(qe),available:xe(qt,qe).toFixed(qe)})),N==="limit"&&g&&(isNaN(F)||F<.01||F>.99)&&E.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&ae&&Ee==="custom"&&(isNaN(He)||He<=0)&&E.push(i("predict.trade.expiration.invalidDate")),m==="polymarket"&&N==="market"&&!isNaN(C)&&C>0&&(bt.status==="insufficient_liquidity"?E.push(i("predict.trade.insufficientLiquidity",{available:xe(bt.totalAvailable,2)})):bt.status==="exceeds_slippage"&&E.push(i("predict.trade.priceImpactTooHigh",{impact:(bt.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:E.length===0,errors:E}},[C,e.status,qt,Ir,Rr,Y,N,g,F,ae,Ee,He,qe,m,bt,n,i]),{mutateAsync:Xt}=reactPredict.useDFlowSubmit(),{data:Dr}=reactPredict.useOrder({id:te??"",source:m},{enabled:!!te}),En=react.useCallback(async()=>{if(!T||!k||!v)return;let{cashAmount:E,collateral:le}=T;z(null);try{let Ye=(await p.createDFlowQuote({inputMint:le,outputMint:Dt,amount:E,userPublicKey:k,slippageBps:100}))?.transaction;if(!Ye)return;let rt=Uint8Array.from(atob(Ye),Lt=>Lt.charCodeAt(0)),nt=await v.signTransaction(rt);await Xt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:k,input_mint:le,output_mint:Dt,amount:E,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[T,k,v,p,Xt,Dt]),Jt=react.useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);react.useEffect(()=>{if(!Dr||!te)return;let{status:E}=Dr;E==="closed"?(P(null),T?En().finally(()=>{B(false),Ve("sell-market"),Jt(),vr(),s.current?.();}):(B(false),Ve("sell-market"),Jt(),vr(),s.current?.())):(E==="failed"||E==="expired")&&(B(false),P(null),z(null),ui.toast.error(i("predict.trade.submitError")));},[Dr,te,T,En,Ve,Jt,vr,i]);let Ln=react.useCallback(async()=>{if(!k||!v)return;if(!Bt||!Yt){ui.toast.error("Missing token mint addresses"),B(false);return}if(!gt){ue(true),B(false);return}let ye=(await Zr()).data,Ye=ye?.transaction;if(!Ye){ui.toast.error(i("predict.trade.submitError")),B(false);return}if(pr&&pr!==Dt){let _e=String(ye?.outAmount??"");_e&&_e!=="0"&&z({cashAmount:_e,collateral:pr});}let rt=Uint8Array.from(atob(Ye),_e=>_e.charCodeAt(0)),nt=await v.signTransaction(rt),Lt=await Xt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:k,input_mint:Bt,output_mint:Yt,amount:Or,price:String(Ce),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});P(Lt.signature);},[k,v,Zr,Xt,Bt,Yt,Or,Ce,b,e.slug,pr,Dt,i,gt]),Rn=react.useCallback(async()=>{if(!h||!d)return;let E=h.chain,le=E!==types.Chain.POLYGON;le&&await h.switchChain(types.Chain.POLYGON);try{let ye=await h.getEip1193Provider();if(!ye){ui.toast.error(i("predict.trade.submitError")),B(!1);return}let Ye=je==="deposit"&&!!ge,rt=!Ye&&!!Re,nt=Ye?ge:Re,Lt={address:h.address,signatureType:Ye?3:rt?2:0,signTypedData:async(Ht,On,Ro,_o)=>{let Fr=[];"name"in Ht&&Fr.push({name:"name",type:"string"}),"version"in Ht&&Fr.push({name:"version",type:"string"}),"chainId"in Ht&&Fr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ht&&Fr.push({name:"verifyingContract",type:"address"}),"salt"in Ht&&Fr.push({name:"salt",type:"bytes32"});let wc={EIP712Domain:Fr,...On};return await ye.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Ht,types:wc,primaryType:Ro,message:_o})]})}},_e=await Ne();if(!_e){ui.toast.error(i("predict.trade.submitError")),B(!1);return}let ir=b==="yes"?0:1,_n="",In=e.provider_meta?.["polymarket.clobTokenIds"];In&&(_n=(typeof In=="string"?JSON.parse(In):In)[ir]??"");let Ai=e.provider_meta?.["polymarket.negRisk"]??!1,kc=N==="limit"&&!isNaN(F)?F:fr,Sc=$n(kc,Le),Eo={tokenId:_n,price:Sc,size:C,side:"SELL",orderType:N==="limit"?ae?"GTD":"GTC":"FOK",tickSize:Le,negRisk:Ai,...nt&&{funderAddress:nt},...et&&{builderCode:et},...N==="limit"&&ae&&{expiration:Un(Ee,He,we)}},Lo;if(Ye)Lo=await reactPredict.buildSignedV2OrderPayload({signer:Lt,depositWalletAddress:nt,input:Eo,owner:_e.apiKey});else {let Ht=reactPredict.buildCtfExchangeDomain(Ai),On=reactPredict.buildOrderMessage({...Eo,signerAddress:Lt.address,signatureType:Lt.signatureType,feeRateBps:Mt}),Ro=await Lt.signTypedData(Ht,reactPredict.CTF_ORDER_TYPES,"Order",On),_o=reactPredict.buildSignedOrder(On,Ro,Eo.orderType);Lo=reactPredict.buildClobPayload(_o,_e.apiKey);}await p.executePolymarketOrder({payload:Lo,l2_api_key:_e.apiKey,l2_secret:_e.secret,l2_passphrase:_e.passphrase,signer_address:_e.address,owner:_e.apiKey}),Jt(),Ve(N==="limit"?"sell-limit":"sell-market",async()=>await reactPredict.buildPolymarketL2Headers(_e.address,{apiKey:_e.apiKey,secret:_e.secret,passphrase:_e.passphrase,method:"GET",requestPath:"/data/orders"})),vr(),B(!1),s.current?.();}finally{le&&E&&h.switchChain(E).catch(()=>{});}},[h,d,Ne,b,e.provider_meta,N,Ve,F,fr,C,p,Jt,ae,Ee,He,we,vr,i,Le,Mt,e.slug,Re,je,ge,et]),tn=react.useCallback(async()=>{if(!(!Ar.isValid||!x)){B(true),P(null),ue(false);try{m==="kalshi"?await Ln():await Rn();}catch(E){let le=E instanceof Error?E.message:"",ye=m==="polymarket"&&le?Kn(le,i,"sell"):le||void 0;ui.toast.error(ye||i("predict.trade.submitError")),B(false);}}},[Ar.isValid,x,m,Ln,Rn,i]);return {outcome:b,orderType:N,quantity:C,limitPrice:F,shares:mr,effectivePrice:gr,grossReturn:R,estimatedFee:Ae,estimatedReturn:We,pricePerShare:Ce,isMarketDataLoading:m==="polymarket"&&(_t||Ze),isSubmitting:Q,authStatus:l,validation:Ar,supportsLimitOrder:g,kycRequired:J,needsKyc:lt,needsSetup:ht,kycUrl:ze,totalShares:Ir,activeOrderShares:Rr,availableShares:qt,isAvailableLoading:Mn,isSellAll:Y,precision:qe,expirationEnabled:ae,expirationPreset:Ee,customDuration:He,customDurationUnit:we,setOutcome:Et,setOrderType:en,setQuantity:hr,setLimitPrice:ct,setSellAll:Qt,setExpirationEnabled:Ke,setExpirationPreset:w,setCustomDuration:Je,setCustomDurationUnit:Ct,submit:tn}}var sm=["5m","1h","12h","24h","eod","custom"],am={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},lm=["minutes","hours","days"],cm={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},dm={maximumFractionDigits:0},dn="-";function da({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,effectivePrice:s,grossReturn:l,estimatedFee:u,estimatedReturn:p,isMarketDataLoading:d,isSubmitting:f,authStatus:c,isValid:m,validationErrors:g,supportsLimitOrder:v,kycRequired:h,needsKyc:x,needsSetup:k,onSetupRequired:S,kycUrl:b,totalShares:y,activeOrderShares:N,availableShares:M,isAvailableLoading:C,precision:_,expirationEnabled:F,expirationPreset:U,customDuration:Q,customDurationUnit:B,oddsFormatter:Y,onOutcomeChange:q,onOrderTypeChange:te,onQuantityChange:P,onLimitPriceChange:T,onSellAll:z,onExpirationEnabledChange:J,onExpirationPresetChange:ue,onCustomDurationChange:ae,onCustomDurationUnitChange:Ke,onSubmit:Ee}){let{t:w}=i18n.useTranslation(),[He,Je]=react.useState(false),[we,Ct]=react.useState(true),Oe=ui.useDisclosure(),[Ve,st]=react.useState(""),Pe=react.useRef(false);react.useEffect(()=>{Pe.current||st(isNaN(i)?"":String(i));},[i]);let[Ze,Le]=react.useState(""),at=react.useRef(false);react.useEffect(()=>{at.current||(isNaN(a)?Le(""):Le(String(parseFloat((a*100).toFixed(2)))));},[a]);let _t=react.useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(Le(I),I===""||I==="."){T(NaN);return}let tt=parseFloat(I);isNaN(tt)||T(tt/100);},[T]),Mt=react.useCallback(I=>{let pe=new RegExp(`^\\d*\\.?\\d{0,${_}}$`);if(I!==""&&!pe.test(I))return;if(st(I),Je(false),I===""||I==="."){P(NaN);return}let tt=parseFloat(I);isNaN(tt)||P(tt);},[P,_]);react.useEffect(()=>{h&&!Oe.isOpen&&Oe.onOpen();},[h]);let Tt=react.useMemo(()=>{let I=n==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[n,t]),et=n==="yes"?t.yesBid:t.noBid,gt=et!=null&&Y?Y(Number(et)):Tt!=null?`${Tt} \xA2`:null,ze=Number.isFinite(s)?parseFloat((s*100).toFixed(2)):null,Gt=Number.isFinite(s)&&Y?Y(s):ze!=null?`${ze} \xA2`:null,Re=!isNaN(i)&&i>0,je=Re&&i>0?p/i:0,ge=je>0&&Y?Y(je):je>0?`${parseFloat((je*100).toFixed(2))} \xA2`:dn,lt=c==="authenticated",ht=c==="authenticating"||c==="deauthenticating",Ne=lt&&(x||k),ut=react.useMemo(()=>{if(ht)return w("predict.trade.checkingLogin");if(!lt)return w("predict.trade.loginToTrade");if(x)return w("predict.trade.kycRequired");if(k)return w("predict.trade.setupRequired");if(C)return w("predict.trade.loadingBalance");if(d)return w("predict.trade.loadingMarketData");if(f)return w("predict.trade.submitting");if(h)return w("predict.trade.kycRequired");if(!Re)return w("predict.trade.enterAmount");let I=w(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${w("predict.trade.sell")} ${I}`},[ht,lt,x,k,C,d,f,h,Re,n,w]),Ce=()=>{if(!lt){Je(false),Ee();return}if(x){Oe.onOpen();return}if(k&&S){Je(false),S();return}if(h){Oe.onOpen();return}if(!m){Je(true);return}Je(false),Ee();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:"text-bearish",children:[w("predict.trade.sell")," ",w(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:[v?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:I=>te(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&v?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ze,onChange:I=>_t(I.target.value),onFocus:()=>{at.current=true;},onBlur:()=>{at.current=false,isNaN(a)?Le(""):Le(String(parseFloat((a*100).toFixed(2))));},endContent: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"}}):gt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:gt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let pe=I==="yes"?t.yesBid:t.noBid;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>q(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===I?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:w(I==="yes"?"predict.trade.yes":"predict.trade.no")}),pe!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(pe)):`${parseFloat((Number(pe)*100).toFixed(2))}\xA2`})]})},I)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.sellContracts")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let pe=Math.pow(10,_);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{P(Math.floor(M*I/100*pe)/pe);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[I,"%"]},I)}),jsxRuntime.jsx("button",{type:"button",onClick:z,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("common.all")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ve,onChange:I=>Mt(I.target.value),onFocus:()=>{Pe.current=true;},onBlur:()=>{Pe.current=false,st(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),He&&g.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(I=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:I},I))})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.totalShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:C?"\u2013":`${xe(y,_).toFixed(_)}${w("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.activeOrders")}),jsxRuntime.jsx("span",{className:"tabular-nums text-warning",children:C?"\u2013":N>0?`-${xe(N,_).toFixed(_)}${w("predict.trade.sharesUnit")}`:`0${w("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.availableShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-success font-medium",children:C?"\u2013":`${xe(M,_).toFixed(_)}${w("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estReturn")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:"\u2013"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Ct(I=>!I),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:w("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",we&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Number.isFinite(s)?Gt:ze!=null?w("predict.trade.chance",{percent:ze}):dn})]}),we&&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:w("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?yr(i):dn})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:Re?`$${l.toFixed(2)}`:dn})]}),(u??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${(u??0).toFixed(2)}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estReturnAfterFees")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:Re?`$${p.toFixed(2)}`:dn})]}),(u??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:ge})]})]})]}),o==="limit"&&v&&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:w("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:F,onValueChange:J,"aria-label":w("predict.trade.setExpiration")})]}),F&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[U],onSelectionChange:I=>{let pe=Array.from(I)[0];pe&&ue(pe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:sm.map(I=>jsxRuntime.jsx(ui.SelectItem,{children:w(am[I])},I))}),U==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(Q)?void 0:Q,onValueChange:ae,minValue:1,step:1,formatOptions:dm,classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsxRuntime.jsx(ui.Select,{"aria-label":"Duration unit",selectedKeys:[B],onSelectionChange:I=>{let pe=Array.from(I)[0];pe&&Ke(pe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:lm.map(I=>jsxRuntime.jsx(ui.SelectItem,{children:w(cm[I])},I))})]})]})]}),jsxRuntime.jsx(ui.Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:ht||lt&&!Ne&&(C||d||!Re||f),isLoading:ht||lt&&!Ne&&(f||C||d),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Ce,children:ut})]}),jsxRuntime.jsx(jn,{isOpen:Oe.isOpen,onClose:Oe.onClose,kycUrl:b})]})}function no({event:e,market:t,variant:r,initialOutcome:n,initialPositionSide:o,chain:i,slippageBps:a,onOutcomeChange:s,onSetupRequired:l,onSuccess:u,oddsFormatter:p}){let{outcome:d,orderType:f,quantity:c,limitPrice:m,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,pricePerShare:k,isMarketDataLoading:S,isSubmitting:b,authStatus:y,validation:N,supportsLimitOrder:M,kycRequired:C,needsKyc:_,needsSetup:F,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:P,expirationPreset:T,customDuration:z,customDurationUnit:J,setOutcome:ue,setOrderType:ae,setQuantity:Ke,setLimitPrice:Ee,setSellAll:w,setExpirationEnabled:He,setExpirationPreset:Je,setCustomDuration:we,setCustomDurationUnit:Ct,submit:Oe}=ta({market:t,initialOutcome:n,initialPositionSide:o,slippageBps:a,onSuccess:u}),Ve=walletConnector.useAuthCallback(Oe),st=react.useCallback(Le=>{ue(Le),s?.(Le);},[ue,s]),Pe=react.useMemo(()=>e?Dn(e):void 0,[e]),Ze=react.useMemo(()=>Fn(t,{yesBid:d==="yes"?k:void 0,noBid:d==="no"?k:void 0}),[t,d,k]);return jsxRuntime.jsx(da,{event:Pe,market:Ze,variant:r,outcome:d,orderType:f,quantity:c,limitPrice:m,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,isMarketDataLoading:S,isSubmitting:b,authStatus:y,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:M,kycRequired:C,needsKyc:_,needsSetup:F,onSetupRequired:l,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:P,expirationPreset:T,customDuration:z,customDurationUnit:J,oddsFormatter:p,onOutcomeChange:st,onOrderTypeChange:ae,onQuantityChange:Ke,onLimitPriceChange:Ee,onSellAll:w,onExpirationEnabledChange:He,onExpirationPresetChange:Je,onCustomDurationChange:we,onCustomDurationUnitChange:Ct,onSubmit:Ve})}var Zo="predict-sell";function pa({id:e=Zo}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(xm,{...t})})}function xm({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(no,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialPositionSide:e.initialPositionSide,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),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 ri=40,so=36,mn=480,ni=mn-so;function ga({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=i18n.useTranslation(),[o,i]=react.useState("positions"),a=react.useMemo(()=>e.markets?.map(d=>d.slug)??[],[e.markets]),{data:s}=reactPredict.usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=react.useMemo(()=>!s?.positions||!t?0:a.length===0?s.positions.length:s.positions.filter(d=>d.market&&a.includes(d.market.slug)).length,[s?.positions,a,t]),p=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return 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:mn},children:[o==="positions"&&jsxRuntime.jsx(Cm,{source:e.source,walletAddress:t,marketSlugs:a}),o==="orders"&&jsxRuntime.jsx(Tm,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),o==="trades"&&jsxRuntime.jsx(Rm,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:n("predict.trade.connectWallet")})]})}function Cm({source:e,walletAddress:t,marketSlugs:r}){let{t:n}=i18n.useTranslation(),{data:o,isLoading:i}=reactPredict.usePositionsMulti({kalshi_user:e==="kalshi"?t:void 0,polymarket_user:e==="polymarket"?t:void 0}),a=react.useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[o?.positions,r]);return i?jsxRuntime.jsx(ii,{}):a.length===0?jsxRuntime.jsx(oi,{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:so},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:ni},rowComponent:Mm,rowCount:a.length,rowHeight:ri,rowProps:{positions:a,closeLabel:n("predict.positions.close")}})]})}function Mm({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,a=o.pnl_percent??0,s=o.avg_price??0,l=o.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",p=i>0?"+":"",d=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,c=o.size,m=o.size*l,g=o.market?.end_at?Om(o.market.end_at):"\u2014";return 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:oo(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:oo(l)}),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,a.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:n})})]})}function Tm({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=i18n.useTranslation(),{data:i,isLoading:a,fetchNextPage:s,hasNextPage:l}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),u=reactPredict.useCancelOrder(),p=react.useMemo(()=>{let h=i?.pages?.flatMap(S=>S.items)??[],x=new Set(["live","open","submitted","pending"]),k=h.filter(S=>x.has(S.status));return r.length>0&&(k=k.filter(S=>S.market_id&&r.includes(S.market_id))),k},[i?.pages,r]),d=react.useCallback(h=>{n?n(h.id):u.mutate({source:h.source,id:h.id});},[n,u]),f=p.length,c=f+(l?1:0),m=react.useCallback(h=>h<f,[f]),g=react.useCallback(async()=>{await s();},[s]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:c,threshold:5});return a?jsxRuntime.jsx(ii,{}):p.length===0&&!l?jsxRuntime.jsx(oi,{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:so},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:ni},onRowsRendered:v,rowComponent:Em,rowCount:c,rowHeight:ri,rowProps:{orders:p,itemCount:f,onCancel:d,isCancelling:u.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Em({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:a}){if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:s.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?oo(parseFloat(s.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(Lm,{status:s.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>o(s),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):a})})]})}function Lm({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:n,isLoading:o,fetchNextPage:i,hasNextPage:a}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),s=react.useMemo(()=>n?.pages?.flatMap(c=>c.items)??[],[n?.pages]),l=s.length,u=l+(a?1:0),p=react.useCallback(c=>c<l,[l]),d=react.useCallback(async()=>{await i();},[i]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:d,rowCount:u,threshold:5});return o?jsxRuntime.jsx(ii,{}):s.length===0&&!a?jsxRuntime.jsx(oi,{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:so},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:ni},onRowsRendered:f,rowComponent:_m,rowCount:u,rowHeight:ri,rowProps:{trades:s,itemCount:l}})]})}function _m({index:e,style:t,trades:r,itemCount:n}){if(e>=n)return 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",a=Im(o.timestamp),s=o.price??0,l=o.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.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:oo(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:a})]})}function oi({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:e})}function ii(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:mn},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function oo(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Im(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),o=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r}/${n} ${o}:${i}`}function Om(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var ha=`
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:ap.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 Ys({event:e,market:t,position:r,onSuccess:n,onCancel:o}){let{t:i,i18n:a}=i18n.useTranslation(),{mutateAsync:s}=reactPredict.useRedeemPosition(),{start:l}=reactPredict.useTradeResultConfirmation(),{evmAddress:u}=xr(),p=walletConnector.useWallets(),[c,f]=react.useState("idle"),[d,m]=react.useState(null),g=t.provider_meta?.["polymarket.conditionId"],v=t.provider_meta?.["polymarket.negRisk"]??false,h=u??"",x=react.useMemo(()=>Hr(i,a),[a,i]),k=react.useMemo(()=>p.find(Y=>Y.chainNamespace===types.ChainNamespace.EVM&&Y.isConnected),[p]),S=qs(r.side,t.outcomes),y=t.outcomes?.[S]?.label??r.side,N=t.result!=null?qs(t.result,t.outcomes):-1,C=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",_=t.result!=null?S===N:true,F=react.useMemo(()=>_?r.size:0,[_,r.size]),U=react.useCallback(async()=>{if(!(!g||!h||!k)){f("pending"),m(null);try{let Y=await k.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:g,neg_risk:v,signMessage:async P=>await Y.request({method:"personal_sign",params:[P,h]}),signTypedData:async P=>await Y.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(P)]})}),f("confirming");let q=zr({messages:x});q.submitted(),await l({source:r.source,user:h,marketSlug:r.market?.slug??t.slug,eventSlug:r.event?.slug??e?.slug,expectation:"redeem"})==="confirmed"?(f("success"),q.completed()):(f("delayed"),q.delayed()),n?.();}catch(Y){f("error"),m(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,h,v,k,s,x,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,n,i]),Q=walletConnector.useAuthCallback(U),B=c==="idle"&&!!g&&!!h&&!!k&&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(eo,{label:i("predict.positions.side"),value:y,valueClassName:_?"text-green-400":"text-red-400"}),t.result!=null&&jsxRuntime.jsx(eo,{label:i("predict.redeem.result"),value:C,valueClassName:"text-green-400"}),jsxRuntime.jsx(eo,{label:i("predict.positions.size"),value:r.size.toFixed(2)}),jsxRuntime.jsx(eo,{label:i("predict.redeem.expectedPayout"),value:`$${F.toFixed(2)}`,valueClassName:F>0?"text-green-400":"text-zinc-400"})]}),!_&&F===0&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),c==="error"&&d&&jsxRuntime.jsx("p",{className:"text-sm text-red-400",children:d}),c==="success"&&jsxRuntime.jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),c==="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:[c!=="success"&&c!=="delayed"&&jsxRuntime.jsx(ui.Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!B,isLoading:c==="pending"||c==="confirming",onPress:Q,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&c!=="success"&&c!=="delayed"&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i("common.cancel")}),(c==="success"||c==="delayed")&&o&&jsxRuntime.jsx(ui.Button,{className:"w-full h-12 rounded-xl text-sm font-medium",onPress:o,children:i("common.ok")})]})]})}function eo({label:e,value:t,valueClassName:r="text-white"}){return 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 qs(e,t){let r=e.toLowerCase();if(r==="yes")return 0;if(r==="no"||!t)return 1;let n=t.findIndex(o=>o.label.toLowerCase()===r);return n>=0?n:1}var Sp="predict-redeem";function Xs({id:e=Sp}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(wp,{...t})})}function wp({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(Ys,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function ta({market:e,initialOutcome:t="yes",initialPositionSide:r,slippageBps:n=100,onSuccess:o}){let{t:i,i18n:a}=i18n.useTranslation(),s=react.useRef(o);s.current=o;let{status:l}=walletConnector.useAuth(),u=walletConnector.useWallets(),p=reactPredict.usePredictClient(),c=react.useContext(reactPredict.PolymarketContext),f=reactQuery.useQueryClient(),{start:d}=reactPredict.useTradeResultConfirmation(),m=e.source,g=m==="polymarket",v=u.find(E=>E.chainNamespace===types.ChainNamespace.SOLANA&&E.isConnected),h=u.find(E=>E.chainNamespace===types.ChainNamespace.EVM&&E.isConnected&&"switchChain"in E),x=l==="authenticated",k=v?.address,S=h?.address,[b,y]=react.useState(t),[N,M]=react.useState("market"),[C,_]=react.useState(NaN),[F,U]=react.useState(NaN),[Q,B]=react.useState(false),[Y,q]=react.useState(false),[te,P]=react.useState(null),[T,z]=react.useState(null),[J,ue]=react.useState(false),[ae,Ke]=react.useState(false),[Ee,w]=react.useState("1h"),[He,Je]=react.useState(30),[we,Ct]=react.useState("minutes"),Oe=react.useMemo(()=>Hr(i,a),[a,i]),Ve=react.useCallback(async(E,le)=>{let ye=zr({messages:Oe});ye.submitted(),await d({source:m,user:m==="kalshi"?k:S,kalshiUser:k,polymarketUser:S,marketSlug:e.slug,eventSlug:e.event_slug,expectation:E,getOrdersHeaders:le})==="confirmed"?ye.completed():ye.delayed();},[d,S,e.event_slug,e.slug,m,Oe,k]),st=react.useMemo(()=>{if(m!=="polymarket")return;let E=e.provider_meta?.["polymarket.clobTokenIds"];return E?(typeof E=="string"?JSON.parse(E):E)[b==="yes"?0:1]:void 0},[m,e.provider_meta,b]),{data:Pe,isLoading:Ze}=reactPredict.useTickSize(st),Le=Pe?.minimum_tick_size?String(Pe.minimum_tick_size):"0.01",{data:at,isLoading:_t}=reactPredict.useFeeRate(st),Mt=String(at?.base_fee??0),{data:Tt}=reactPredict.useRebateConfig(),et=Tt?.builder_enabled&&Tt.builder_code?Tt.builder_code:void 0,gt=false,ze=null,Gt=false,Re,je,ge;try{let E=xr();gt=E.kalshiKycVerified,ze=E.kalshiKycUrl,Gt=E.polymarketSetupVerified,Re=E.polymarketSafeAddress,je=E.polymarketWalletKind,ge=E.polymarketWalletAddress;}catch{}let lt=m==="kalshi"&&!gt,ht=m==="polymarket"&&!Gt,Ne=react.useCallback(async()=>{if(!h||!c)return null;let E=await h.getEip1193Provider();if(!E)return null;let le=je==="deposit"&&!!ge,ye=!le&&!!Re,Ye={address:h.address,signatureType:le?3:ye?2:0,signTypedData:async(rt,nt,Lt,_e)=>{let ir=[];"name"in rt&&ir.push({name:"name",type:"string"}),"version"in rt&&ir.push({name:"version",type:"string"}),"chainId"in rt&&ir.push({name:"chainId",type:"uint256"}),"verifyingContract"in rt&&ir.push({name:"verifyingContract",type:"address"}),"salt"in rt&&ir.push({name:"salt",type:"bytes32"});let _n={EIP712Domain:ir,...nt};return await E.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:rt,types:_n,primaryType:Lt,message:_e})]})}};return c.credentials??await c.authenticate(Ye)},[Re,je,ge,h,c]),{data:ut}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:m,outcome:b},{enabled:e.status==="open"}),Ce=react.useMemo(()=>{let E=reactPredict.pickBestBid(ut,b);if(E!=null&&E>0)return E;let le=b==="yes"?0:1,ye=e.outcomes[le];return ye?.best_bid??ye?.price??.5},[ut,e.outcomes,b]),I=m==="kalshi"?k??"":S??"",{data:pe,isLoading:tt}=reactPredict.usePositionsMulti({kalshi_user:m==="kalshi"?I:void 0,polymarket_user:m==="polymarket"?I:void 0},{enabled:!!I,refetchInterval:3e4}),Xr=react.useCallback(async()=>{let E=await Ne();return E?await reactPredict.buildPolymarketL2Headers(E.address,{apiKey:E.apiKey,secret:E.secret,passphrase:E.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Ne]),{data:A,isLoading:Ge}=reactPredict.useAvailableShares({source:m,user:I,market:e.slug,side:b},m==="polymarket"?{getHeaders:Xr}:void 0,{enabled:!!I&&!!e.slug,refetchOnMount:"always"}),vt=e.provider_meta?.["dflow.yesMint"]??"",ur=e.provider_meta?.["dflow.noMint"]??"",Dt=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,Jr=e.provider_meta?.["dflow.collateralMint"]||"",Co=b==="yes"?vt:ur,Cn=(r||b).trim().toLowerCase(),Lr=react.useMemo(()=>pe?pe.positions.find(E=>E.side?.trim().toLowerCase()===Cn&&E.market?.slug===e.slug)??null:null,[pe,e.slug,Cn]),qe=react.useMemo(()=>m==="polymarket"?reactPredict.getPolymarketSharesPrecision(Le):A?.precision??0,[m,Le,A?.precision]),Rr=A?.active_order_shares??0,_r=m==="polymarket"&&!!r&&!!Lr?.size&&(A?.total_shares??0)<=0&&(A?.available_shares??0)<=0,Ft=_r?Lr?.size??0:0,Ir=_r?Ft:A?.total_shares??0,qt=_r?Math.max(0,Ft-Rr):A?.available_shares??0,Mn=Ge||tt,Tn=Lr?.market?.provider_meta,Mo=Tn?.["dflow.outcomeMint"]||Co,pr=Tn?.["dflow.collateralMint"]||Jr,Bt=Mo,Yt=pr||Dt,Or=react.useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),To=m==="kalshi"&&!!Bt&&!!Yt&&!!k&&Or!=="0",{refetch:Zr}=reactPredict.useDFlowQuote({inputMint:Bt,outputMint:Yt,amount:Or,userPublicKey:k??"",slippageBps:100},{enabled:To}),mr=react.useMemo(()=>isNaN(C)||C<=0?0:C,[C]),bt=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:ut,outcome:b,side:"sell",sharesNeeded:mr,slippageBps:n}),[ut,b,mr,n]),fr=react.useMemo(()=>bt.status==="ok"&&bt.worstPrice!=null&&bt.worstPrice>0?bt.worstPrice:Ce,[bt,Ce]),gr=react.useMemo(()=>N==="limit"&&g&&!isNaN(F)?F:fr,[N,g,F,fr]),R=react.useMemo(()=>isNaN(C)||C<=0?0:C*gr,[C,gr]),Ae=react.useMemo(()=>m!=="polymarket"?0:Qi({grossReturn:R,pricePerShare:gr,feeRateBps:Number(Mt)}),[m,R,gr,Mt]),We=react.useMemo(()=>Math.max(0,R-Ae),[R,Ae]),Et=react.useCallback(E=>{y(E),U(NaN),_(NaN),q(false);},[]);react.useEffect(()=>{Et(t);},[t,Et]);let en=react.useCallback(E=>{M(E);},[]);react.useEffect(()=>{N==="limit"&&U(Math.round(Ce*1e4)/1e4);},[N,b]);let hr=react.useCallback(E=>{if(q(false),isNaN(E)){_(NaN);return}_(xe(Math.max(0,E),qe));},[qe]),Qt=react.useCallback(()=>{q(true),_(xe(qt,qe));},[qt,qe]),ct=react.useCallback(E=>{if(isNaN(E)){U(NaN);return}U(Math.round(E*1e4)/1e4);},[]),vr=react.useCallback(()=>{_(NaN),U(NaN),M("market"),q(false),Ke(false),w("1h"),Je(30),Ct("minutes");},[]),Ar=react.useMemo(()=>{let E=[];return isNaN(C)||C<=0?E.push(i("predict.trade.minQuantity",{amount:zn})):C<zn&&E.push(i("predict.trade.minQuantity",{amount:zn})),e.status!=="open"&&E.push(i("predict.trade.marketNotActive")),!isNaN(C)&&C>0&&!Y&&C>qt&&E.push(i("predict.trade.insufficientSharesDetail",{total:xe(Ir,qe).toFixed(qe),active:xe(Rr,qe).toFixed(qe),available:xe(qt,qe).toFixed(qe)})),N==="limit"&&g&&(isNaN(F)||F<.01||F>.99)&&E.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&ae&&Ee==="custom"&&(isNaN(He)||He<=0)&&E.push(i("predict.trade.expiration.invalidDate")),m==="polymarket"&&N==="market"&&!isNaN(C)&&C>0&&(bt.status==="insufficient_liquidity"?E.push(i("predict.trade.insufficientLiquidity",{available:xe(bt.totalAvailable,2)})):bt.status==="exceeds_slippage"&&E.push(i("predict.trade.priceImpactTooHigh",{impact:(bt.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:E.length===0,errors:E}},[C,e.status,qt,Ir,Rr,Y,N,g,F,ae,Ee,He,qe,m,bt,n,i]),{mutateAsync:Xt}=reactPredict.useDFlowSubmit(),{data:Dr}=reactPredict.useOrder({id:te??"",source:m},{enabled:!!te}),En=react.useCallback(async()=>{if(!T||!k||!v)return;let{cashAmount:E,collateral:le}=T;z(null);try{let Ye=(await p.createDFlowQuote({inputMint:le,outputMint:Dt,amount:E,userPublicKey:k,slippageBps:100}))?.transaction;if(!Ye)return;let rt=Uint8Array.from(atob(Ye),Lt=>Lt.charCodeAt(0)),nt=await v.signTransaction(rt);await Xt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:k,input_mint:le,output_mint:Dt,amount:E,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[T,k,v,p,Xt,Dt]),Jt=react.useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);react.useEffect(()=>{if(!Dr||!te)return;let{status:E}=Dr;E==="closed"?(P(null),T?En().finally(()=>{B(false),Ve("sell-market"),Jt(),vr(),s.current?.();}):(B(false),Ve("sell-market"),Jt(),vr(),s.current?.())):(E==="failed"||E==="expired")&&(B(false),P(null),z(null),ui.toast.error(i("predict.trade.submitError")));},[Dr,te,T,En,Ve,Jt,vr,i]);let Ln=react.useCallback(async()=>{if(!k||!v)return;if(!Bt||!Yt){ui.toast.error("Missing token mint addresses"),B(false);return}if(!gt){ue(true),B(false);return}let ye=(await Zr()).data,Ye=ye?.transaction;if(!Ye){ui.toast.error(i("predict.trade.submitError")),B(false);return}if(pr&&pr!==Dt){let _e=String(ye?.outAmount??"");_e&&_e!=="0"&&z({cashAmount:_e,collateral:pr});}let rt=Uint8Array.from(atob(Ye),_e=>_e.charCodeAt(0)),nt=await v.signTransaction(rt),Lt=await Xt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:k,input_mint:Bt,output_mint:Yt,amount:Or,price:String(Ce),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});P(Lt.signature);},[k,v,Zr,Xt,Bt,Yt,Or,Ce,b,e.slug,pr,Dt,i,gt]),Rn=react.useCallback(async()=>{if(!h||!c)return;let E=h.chain,le=E!==types.Chain.POLYGON;le&&await h.switchChain(types.Chain.POLYGON);try{let ye=await h.getEip1193Provider();if(!ye){ui.toast.error(i("predict.trade.submitError")),B(!1);return}let Ye=je==="deposit"&&!!ge,rt=!Ye&&!!Re,nt=Ye?ge:Re,Lt={address:h.address,signatureType:Ye?3:rt?2:0,signTypedData:async(Ht,On,Ro,_o)=>{let Fr=[];"name"in Ht&&Fr.push({name:"name",type:"string"}),"version"in Ht&&Fr.push({name:"version",type:"string"}),"chainId"in Ht&&Fr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Ht&&Fr.push({name:"verifyingContract",type:"address"}),"salt"in Ht&&Fr.push({name:"salt",type:"bytes32"});let wc={EIP712Domain:Fr,...On};return await ye.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Ht,types:wc,primaryType:Ro,message:_o})]})}},_e=await Ne();if(!_e){ui.toast.error(i("predict.trade.submitError")),B(!1);return}let ir=b==="yes"?0:1,_n="",In=e.provider_meta?.["polymarket.clobTokenIds"];In&&(_n=(typeof In=="string"?JSON.parse(In):In)[ir]??"");let Ai=e.provider_meta?.["polymarket.negRisk"]??!1,kc=N==="limit"&&!isNaN(F)?F:fr,Sc=$n(kc,Le),Eo={tokenId:_n,price:Sc,size:C,side:"SELL",orderType:N==="limit"?ae?"GTD":"GTC":"FOK",tickSize:Le,negRisk:Ai,...nt&&{funderAddress:nt},...et&&{builderCode:et},...N==="limit"&&ae&&{expiration:Un(Ee,He,we)}},Lo;if(Ye)Lo=await reactPredict.buildSignedV2OrderPayload({signer:Lt,depositWalletAddress:nt,input:Eo,owner:_e.apiKey});else {let Ht=reactPredict.buildCtfExchangeDomain(Ai),On=reactPredict.buildOrderMessage({...Eo,signerAddress:Lt.address,signatureType:Lt.signatureType,feeRateBps:Mt}),Ro=await Lt.signTypedData(Ht,reactPredict.CTF_ORDER_TYPES,"Order",On),_o=reactPredict.buildSignedOrder(On,Ro,Eo.orderType);Lo=reactPredict.buildClobPayload(_o,_e.apiKey);}await p.executePolymarketOrder({payload:Lo,l2_api_key:_e.apiKey,l2_secret:_e.secret,l2_passphrase:_e.passphrase,signer_address:_e.address,owner:_e.apiKey}),Jt(),Ve(N==="limit"?"sell-limit":"sell-market",async()=>await reactPredict.buildPolymarketL2Headers(_e.address,{apiKey:_e.apiKey,secret:_e.secret,passphrase:_e.passphrase,method:"GET",requestPath:"/data/orders"})),vr(),B(!1),s.current?.();}finally{le&&E&&h.switchChain(E).catch(()=>{});}},[h,c,Ne,b,e.provider_meta,N,Ve,F,fr,C,p,Jt,ae,Ee,He,we,vr,i,Le,Mt,e.slug,Re,je,ge,et]),tn=react.useCallback(async()=>{if(!(!Ar.isValid||!x)){B(true),P(null),ue(false);try{m==="kalshi"?await Ln():await Rn();}catch(E){let le=E instanceof Error?E.message:"",ye=m==="polymarket"&&le?Kn(le,i,"sell"):le||void 0;ui.toast.error(ye||i("predict.trade.submitError")),B(false);}}},[Ar.isValid,x,m,Ln,Rn,i]);return {outcome:b,orderType:N,quantity:C,limitPrice:F,shares:mr,effectivePrice:gr,grossReturn:R,estimatedFee:Ae,estimatedReturn:We,pricePerShare:Ce,isMarketDataLoading:m==="polymarket"&&(_t||Ze),isSubmitting:Q,authStatus:l,validation:Ar,supportsLimitOrder:g,kycRequired:J,needsKyc:lt,needsSetup:ht,kycUrl:ze,totalShares:Ir,activeOrderShares:Rr,availableShares:qt,isAvailableLoading:Mn,isSellAll:Y,precision:qe,expirationEnabled:ae,expirationPreset:Ee,customDuration:He,customDurationUnit:we,setOutcome:Et,setOrderType:en,setQuantity:hr,setLimitPrice:ct,setSellAll:Qt,setExpirationEnabled:Ke,setExpirationPreset:w,setCustomDuration:Je,setCustomDurationUnit:Ct,submit:tn}}var am=["5m","1h","12h","24h","eod","custom"],lm={"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"},cm=["minutes","hours","days"],dm={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},um={maximumFractionDigits:0},dn="-";function da({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,effectivePrice:s,grossReturn:l,estimatedFee:u,estimatedReturn:p,isMarketDataLoading:c,isSubmitting:f,authStatus:d,isValid:m,validationErrors:g,supportsLimitOrder:v,kycRequired:h,needsKyc:x,needsSetup:k,onSetupRequired:S,kycUrl:b,totalShares:y,activeOrderShares:N,availableShares:M,isAvailableLoading:C,precision:_,expirationEnabled:F,expirationPreset:U,customDuration:Q,customDurationUnit:B,oddsFormatter:Y,onOutcomeChange:q,onOrderTypeChange:te,onQuantityChange:P,onLimitPriceChange:T,onSellAll:z,onExpirationEnabledChange:J,onExpirationPresetChange:ue,onCustomDurationChange:ae,onCustomDurationUnitChange:Ke,onSubmit:Ee}){let{t:w}=i18n.useTranslation(),[He,Je]=react.useState(false),[we,Ct]=react.useState(true),Oe=ui.useDisclosure(),[Ve,st]=react.useState(""),Pe=react.useRef(false);react.useEffect(()=>{Pe.current||st(isNaN(i)?"":String(i));},[i]);let[Ze,Le]=react.useState(""),at=react.useRef(false);react.useEffect(()=>{at.current||(isNaN(a)?Le(""):Le(String(parseFloat((a*100).toFixed(2)))));},[a]);let _t=react.useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(Le(I),I===""||I==="."){T(NaN);return}let tt=parseFloat(I);isNaN(tt)||T(tt/100);},[T]),Mt=react.useCallback(I=>{let pe=new RegExp(`^\\d*\\.?\\d{0,${_}}$`);if(I!==""&&!pe.test(I))return;if(st(I),Je(false),I===""||I==="."){P(NaN);return}let tt=parseFloat(I);isNaN(tt)||P(tt);},[P,_]);react.useEffect(()=>{h&&!Oe.isOpen&&Oe.onOpen();},[h]);let Tt=react.useMemo(()=>{let I=n==="yes"?t.yesBid:t.noBid;return I!=null?parseFloat((Number(I)*100).toFixed(2)):null},[n,t]),et=n==="yes"?t.yesBid:t.noBid,gt=et!=null&&Y?Y(Number(et)):Tt!=null?`${Tt} \xA2`:null,ze=Number.isFinite(s)?parseFloat((s*100).toFixed(2)):null,Gt=Number.isFinite(s)&&Y?Y(s):ze!=null?`${ze} \xA2`:null,Re=!isNaN(i)&&i>0,je=Re&&i>0?p/i:0,ge=je>0&&Y?Y(je):je>0?`${parseFloat((je*100).toFixed(2))} \xA2`:dn,lt=d==="authenticated",ht=d==="authenticating"||d==="deauthenticating",Ne=lt&&(x||k),ut=react.useMemo(()=>{if(ht)return w("predict.trade.checkingLogin");if(!lt)return w("predict.trade.loginToTrade");if(x)return w("predict.trade.kycRequired");if(k)return w("predict.trade.setupRequired");if(C)return w("predict.trade.loadingBalance");if(c)return w("predict.trade.loadingMarketData");if(f)return w("predict.trade.submitting");if(h)return w("predict.trade.kycRequired");if(!Re)return w("predict.trade.enterAmount");let I=w(n==="yes"?"predict.trade.yes":"predict.trade.no");return `${w("predict.trade.sell")} ${I}`},[ht,lt,x,k,C,c,f,h,Re,n,w]),Ce=()=>{if(!lt){Je(false),Ee();return}if(x){Oe.onOpen();return}if(k&&S){Je(false),S();return}if(h){Oe.onOpen();return}if(!m){Je(true);return}Je(false),Ee();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:I=>{r==="bordered"&&(I.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:"text-bearish",children:[w("predict.trade.sell")," ",w(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:[v?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:I=>te(I),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:w("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.market")}),o==="limit"&&v?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ze,onChange:I=>_t(I.target.value),onFocus:()=>{at.current=true;},onBlur:()=>{at.current=false,isNaN(a)?Le(""):Le(String(parseFloat((a*100).toFixed(2))));},endContent: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"}}):gt!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:gt})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(I=>{let pe=I==="yes"?t.yesBid:t.noBid;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>q(I),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===I?"border-bearish bg-bearish/10 text-bearish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:w(I==="yes"?"predict.trade.yes":"predict.trade.no")}),pe!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(pe)):`${parseFloat((Number(pe)*100).toFixed(2))}\xA2`})]})},I)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:w("predict.trade.sellContracts")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[[25,50].map(I=>{let pe=Math.pow(10,_);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{P(Math.floor(M*I/100*pe)/pe);},className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:[I,"%"]},I)}),jsxRuntime.jsx("button",{type:"button",onClick:z,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-neutral-500 hover:text-foreground font-medium",children:w("common.all")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Sell quantity",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:Ve,onChange:I=>Mt(I.target.value),onFocus:()=>{Pe.current=true;},onBlur:()=>{Pe.current=false,st(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),He&&g.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:g.map(I=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:I},I))})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.totalShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:C?"\u2013":`${xe(y,_).toFixed(_)}${w("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.activeOrders")}),jsxRuntime.jsx("span",{className:"tabular-nums text-warning",children:C?"\u2013":N>0?`-${xe(N,_).toFixed(_)}${w("predict.trade.sharesUnit")}`:`0${w("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.availableShares")}),jsxRuntime.jsx("span",{className:"tabular-nums text-success font-medium",children:C?"\u2013":`${xe(M,_).toFixed(_)}${w("predict.trade.sharesUnit")}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estReturn")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:"\u2013"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>Ct(I=>!I),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:w("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",we&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Number.isFinite(s)?Gt:ze!=null?w("predict.trade.chance",{percent:ze}):dn})]}),we&&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:w("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?yr(i):dn})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:Re?`$${l.toFixed(2)}`:dn})]}),(u??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estFee")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:`$${(u??0).toFixed(2)}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.estReturnAfterFees")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:Re?`$${p.toFixed(2)}`:dn})]}),(u??0)>0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:w("predict.trade.effectiveOdds")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:ge})]})]})]}),o==="limit"&&v&&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:w("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:F,onValueChange:J,"aria-label":w("predict.trade.setExpiration")})]}),F&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[U],onSelectionChange:I=>{let pe=Array.from(I)[0];pe&&ue(pe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:am.map(I=>jsxRuntime.jsx(ui.SelectItem,{children:w(lm[I])},I))}),U==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(Q)?void 0:Q,onValueChange:ae,minValue:1,step:1,formatOptions:um,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:[B],onSelectionChange:I=>{let pe=Array.from(I)[0];pe&&Ke(pe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:cm.map(I=>jsxRuntime.jsx(ui.SelectItem,{children:w(dm[I])},I))})]})]})]}),jsxRuntime.jsx(ui.Button,{color:"secondary",fullWidth:true,radius:"lg",size:"lg",isDisabled:ht||lt&&!Ne&&(C||c||!Re||f),isLoading:ht||lt&&!Ne&&(f||C||c),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Ce,children:ut})]}),jsxRuntime.jsx(jn,{isOpen:Oe.isOpen,onClose:Oe.onClose,kycUrl:b})]})}function no({event:e,market:t,variant:r,initialOutcome:n,initialPositionSide:o,chain:i,slippageBps:a,onOutcomeChange:s,onSetupRequired:l,onSuccess:u,oddsFormatter:p}){let{outcome:c,orderType:f,quantity:d,limitPrice:m,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,pricePerShare:k,isMarketDataLoading:S,isSubmitting:b,authStatus:y,validation:N,supportsLimitOrder:M,kycRequired:C,needsKyc:_,needsSetup:F,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:P,expirationPreset:T,customDuration:z,customDurationUnit:J,setOutcome:ue,setOrderType:ae,setQuantity:Ke,setLimitPrice:Ee,setSellAll:w,setExpirationEnabled:He,setExpirationPreset:Je,setCustomDuration:we,setCustomDurationUnit:Ct,submit:Oe}=ta({market:t,initialOutcome:n,initialPositionSide:o,slippageBps:a,onSuccess:u}),Ve=walletConnector.useAuthCallback(Oe),st=react.useCallback(Le=>{ue(Le),s?.(Le);},[ue,s]),Pe=react.useMemo(()=>e?Dn(e):void 0,[e]),Ze=react.useMemo(()=>Fn(t,{yesBid:c==="yes"?k:void 0,noBid:c==="no"?k:void 0}),[t,c,k]);return jsxRuntime.jsx(da,{event:Pe,market:Ze,variant:r,outcome:c,orderType:f,quantity:d,limitPrice:m,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,isMarketDataLoading:S,isSubmitting:b,authStatus:y,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:M,kycRequired:C,needsKyc:_,needsSetup:F,onSetupRequired:l,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:P,expirationPreset:T,customDuration:z,customDurationUnit:J,oddsFormatter:p,onOutcomeChange:st,onOrderTypeChange:ae,onQuantityChange:Ke,onLimitPriceChange:Ee,onSellAll:w,onExpirationEnabledChange:He,onExpirationPresetChange:Je,onCustomDurationChange:we,onCustomDurationUnitChange:Ct,onSubmit:Ve})}var Zo="predict-sell";function pa({id:e=Zo}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(ym,{...t})})}function ym({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(no,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialPositionSide:e.initialPositionSide,chain:e.chain,slippageBps:e.slippageBps,onSetupRequired:e.onSetupRequired,onSuccess:()=>r(false),variant:"flat"}),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 ri=40,so=36,mn=480,ni=mn-so;function ga({event:e,walletAddress:t,onCancelOrder:r}){let{t:n}=i18n.useTranslation(),[o,i]=react.useState("positions"),a=react.useMemo(()=>e.markets?.map(c=>c.slug)??[],[e.markets]),{data:s}=reactPredict.usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),l=react.useMemo(()=>!s?.positions||!t?0:a.length===0?s.positions.length:s.positions.filter(c=>c.market&&a.includes(c.market.slug)).length,[s?.positions,a,t]),p=[{key:"positions",label:l>0?`${n("predict.positions.title")} (${l})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:p.map(c=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(c.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===c.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:c.label},c.key))}),t?jsxRuntime.jsxs("div",{style:{height:mn},children:[o==="positions"&&jsxRuntime.jsx(Mm,{source:e.source,walletAddress:t,marketSlugs:a}),o==="orders"&&jsxRuntime.jsx(Em,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),o==="trades"&&jsxRuntime.jsx(_m,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},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}),a=react.useMemo(()=>o?.positions?r.length===0?o.positions:o.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[o?.positions,r]);return i?jsxRuntime.jsx(ii,{}):a.length===0?jsxRuntime.jsx(oi,{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:so},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:ni},rowComponent:Tm,rowCount:a.length,rowHeight:ri,rowProps:{positions:a,closeLabel:n("predict.positions.close")}})]})}function Tm({index:e,style:t,positions:r,closeLabel:n}){let o=r[e];if(!o)return null;let i=o.pnl??0,a=o.pnl_percent??0,s=o.avg_price??0,l=o.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",p=i>0?"+":"",c=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,d=o.size,m=o.size*l,g=o.market?.end_at?Am(o.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsxRuntime.jsx("span",{className:ui.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:oo(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:oo(l)}),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,a.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children: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 Em({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:n}){let{t:o}=i18n.useTranslation(),{data:i,isLoading:a,fetchNextPage:s,hasNextPage:l}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),u=reactPredict.useCancelOrder(),p=react.useMemo(()=>{let h=i?.pages?.flatMap(S=>S.items)??[],x=new Set(["live","open","submitted","pending"]),k=h.filter(S=>x.has(S.status));return r.length>0&&(k=k.filter(S=>S.market_id&&r.includes(S.market_id))),k},[i?.pages,r]),c=react.useCallback(h=>{n?n(h.id):u.mutate({source:h.source,id:h.id});},[n,u]),f=p.length,d=f+(l?1:0),m=react.useCallback(h=>h<f,[f]),g=react.useCallback(async()=>{await s();},[s]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:d,threshold:5});return a?jsxRuntime.jsx(ii,{}):p.length===0&&!l?jsxRuntime.jsx(oi,{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:so},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:ni},onRowsRendered:v,rowComponent:Lm,rowCount:d,rowHeight:ri,rowProps:{orders:p,itemCount:f,onCancel:c,isCancelling:u.isPending,cancelLabel:o("predict.openOrders.cancel")}})]})}function Lm({index:e,style:t,orders:r,itemCount:n,onCancel:o,isCancelling:i,cancelLabel:a}){if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:s.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?oo(parseFloat(s.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(Rm,{status:s.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>o(s),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):a})})]})}function Rm({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 _m({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:n,isLoading:o,fetchNextPage:i,hasNextPage:a}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),s=react.useMemo(()=>n?.pages?.flatMap(d=>d.items)??[],[n?.pages]),l=s.length,u=l+(a?1:0),p=react.useCallback(d=>d<l,[l]),c=react.useCallback(async()=>{await i();},[i]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:c,rowCount:u,threshold:5});return o?jsxRuntime.jsx(ii,{}):s.length===0&&!a?jsxRuntime.jsx(oi,{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:so},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:ni},onRowsRendered:f,rowComponent:Im,rowCount:u,rowHeight:ri,rowProps:{trades:s,itemCount:l}})]})}function Im({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",a=Om(o.timestamp),s=o.price??0,l=o.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.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:oo(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:o.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:a})]})}function oi({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:e})}function ii(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:mn},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function oo(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Om(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 Am(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}var ha=`
75
75
  @keyframes detailShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
76
- `,va={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function he(e){return {...va,animationDelay:`${e}ms`}}function fn({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ha}),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:{...va,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:{...he(0),height:14,width:48}}),jsxRuntime.jsx("div",{style:{...he(30),height:14,width:40}}),jsxRuntime.jsx("div",{style:{...he(60),height:14,width:40}})]}),jsxRuntime.jsx("div",{style:{...he(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsxRuntime.jsx("div",{style:{...he(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:{...he(120),height:16,width:96}}),jsxRuntime.jsx("div",{style:{...he(140),height:16,width:80}})]}),jsxRuntime.jsx("div",{style:{...he(160),height:300,width:"100%",borderRadius:12}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("div",{style:{...he(180),height:16,width:80}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...he(200),height:28,width:200,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(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:{...he(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:{...he(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:{...he(280+n*40),height:14,width:n%2===0?192:160}}),jsxRuntime.jsx("div",{style:{...he(300+n*40),height:10,width:64}})]}),jsxRuntime.jsx("div",{style:{...he(320+n*40),height:16,width:40}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...he(340+n*40),height:32,width:80,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(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:{...he(400),height:16,width:64}}),jsxRuntime.jsx("div",{style:{...he(420),height:14,width:"100%"}}),jsxRuntime.jsx("div",{style:{...he(440),height:14,width:"80%"}}),jsxRuntime.jsx("div",{style:{...he(460),height:14,width:"60%"}})]})]})]})}function ba(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ha}),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:{...he(0),height:40,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(60),height:96,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(120),height:40,width:"100%",borderRadius:8}})]})]})}var wa="var(--color-bullish)",Pa="var(--color-bearish)";function gn(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Fm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Bm(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let c of e){let m=Math.round(c.price*100);m>=0&&m<=100&&(r[m]+=c.quantity);}for(let c of t){let m=Math.round(c.price*100);m>=0&&m<=100&&(n[m]+=c.quantity);}let o=0,i=0,a=new Float64Array(101),s=new Float64Array(101);for(let c=100;c>=0;c--)o+=r[c],i+=r[c]*c/100,a[c]=o,s[c]=i;let l=0,u=0,p=new Float64Array(101),d=new Float64Array(101);for(let c=0;c<=100;c++)l+=n[c],u+=n[c]*c/100,p[c]=l,d[c]=u;let f=Math.max(a[0]??0,p[100]??0);return Array.from({length:101},(c,m)=>{let g=a[m]>0,v=p[m]>0,h=a[m]||p[m],x=r[m]>0||n[m]>0;return {priceCents:m,displayHeight:Fm(h,f),opacity:h>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[m],askCumTotal:p[m],bidCumCost:s[m],askCumCost:d[m]}})}function Hm({info:e}){let{t}=i18n.useTranslation(),r=e.isBid?wa:Pa,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:gn(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:r},children:["$",gn(Math.round(e.cumCost))]})]})}var zm=react.memo(function({slot:t,onEnter:r,onLeave:n}){let o=react.useRef(null),i=t.isBid||t.isAsk,a=t.isBid?wa:t.isAsk?Pa: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:a,opacity:t.opacity}})})}),Wm=[0,10,20,30,40,50,60,70,80,90,100];function Um(){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:Wm.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 Na({bids:e,asks:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>Bm(e,t),[e,t]),o=react.useMemo(()=>{let d=e.length>0?Math.max(...e.map(c=>c.price)):0,f=t.length>0?Math.min(...t.map(c=>c.price)):1;return Math.round((d+f)/2*100)},[e,t]),i=react.useMemo(()=>n.some(d=>d.isBid||d.isAsk),[n]),[a,s]=react.useState(null),l=react.useRef(null),u=react.useCallback((d,f)=>{l.current&&(l.current.style.filter=""),f?(f.style.filter="brightness(1.5)",l.current=f):l.current=null,d.isBid||d.isAsk?s({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):s(null);},[]),p=react.useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),s(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"}}),a&&jsxRuntime.jsx(Hm,{info:a}),n.map(d=>jsxRuntime.jsx(zm,{slot:d,onEnter:u,onLeave:p},d.priceCents))]}),jsxRuntime.jsx(Um,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Ra(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ma(){let{t:e}=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 _a({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o,oddsFormatter:i}){let{t:a}=i18n.useTranslation(),[s,l]=react.useState(n),u=i??Ra,p=e.source,{data:d,isLoading:f,isFetching:c,refetch:m}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:p,outcome:t}),g=react.useMemo(()=>(d?.bids??[]).map(S=>({price:S.price,quantity:S.size})),[d?.bids]),v=react.useMemo(()=>(d?.asks??[]).map(S=>({price:S.price,quantity:S.size})),[d?.asks]),h=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]),k=react.useMemo(()=>{if(h==null||x==null)return null;let S=(x-h)*100;return Math.round(S*10)/10},[h,x]);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:k!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(k)?`${k}\xA2`:`${k.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[h!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",u(h)]}),h!=null&&x!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),x!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("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:s==="depth"?"Orderbook":"Depth chart",onClick:()=>l(S=>S==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:s==="depth"?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:[s==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(Ma,{}):jsxRuntime.jsx(Na,{bids:g,asks:v})}),s==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(Ma,{}):jsxRuntime.jsx(qm,{bids:g,asks:v,bestBid:h??void 0,bestAsk:x??void 0,spread:k??void 0,oddsFormatter:i})})]})]})}var ai=4,Gm=8;function qm({bids:e,asks:t,spread:r,oddsFormatter:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState(false),s=i?Gm:ai,l=t.length>ai||e.length>ai,u=react.useMemo(()=>[...t].sort((c,m)=>c.price-m.price).slice(0,s).reverse(),[t,s]),p=react.useMemo(()=>[...e].sort((c,m)=>m.price-c.price).slice(0,s),[e,s]),d=react.useMemo(()=>{let c=[...u,...p].map(m=>m.quantity);return Math.max(...c,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(c=>jsxRuntime.jsx(Ta,{price:c.price,quantity:c.quantity,side:"ask",maxQty:d,oddsFormatter:n},`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:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsxRuntime.jsx("button",{type:"button",onClick:()=>a(c=>!c),className:"absolute right-2 text-[10px] text-neutral transition-colors cursor-pointer hover:text-foreground",children:o(i?"predict.orderBook.collapse":"predict.orderBook.expand")})]}),p.map(c=>jsxRuntime.jsx(Ta,{price:c.price,quantity:c.quantity,side:"bid",maxQty:d,oddsFormatter:n},`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: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 Ta({price:e,quantity:t,side:r,maxQty:n,oddsFormatter:o}){let i=r==="ask",a=Math.min(t/n*100,100),s=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=gn(Math.round(t)),p=Math.round(t*e),d=`$${gn(p)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${a}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 ${l}`,children:o?o(e):Ra(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 di=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}},hn=4,Ia=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function af(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function lf(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ce.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Aa(e){return `${(e*100).toFixed(2)}%`}var cf=[{range:ce.ONE_DAY,label:"1D"},{range:ce.ONE_WEEK,label:"1W"},{range:ce.ONE_MONTH,label:"1M"},{range:ce.ALL,label:"ALL"}];function df({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:cf.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 uf(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(o=>{let i=e.current,a=t.current;if(!i||!a)return;let s=i.getBoundingClientRect(),l=(o.clientX-s.left)/s.width*100;a.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,a.style.opacity="1";},[]),n=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function pf({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let a=new Map;t?.forEach(l=>a.set(l.dataKey,l));let s=o.map(l=>a.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return 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"?lf(r,i):r}),s.map(l=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Aa(l.value):"--"})]},l.dataKey))]})}function mf({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=react.useState(false),a=react.useRef(null);react.useEffect(()=>{if(!o)return;function u(p){a.current&&!a.current.contains(p.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let s=t.length>=hn,l=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:a,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: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 ",hn," markets"]}),e.map((u,p)=>{let d=t.includes(u.slug),f=!d&&s,c=d&&t.length===1,m=r.get(u.slug)??"#6b7280",g=u.outcomes.find(h=>h.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{c||f||n(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:f||c?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!f&&!c&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[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}),v&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${p}-${u.slug}`)})]})]})}function ff({series:e,colorMap:t,displayValues:r}){return 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?Aa(i):"--"})]})]},n.marketSlug)})})}function gf(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function hf(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),a=Math.min(Math.floor((o+1)*n),e.length),s=e.slice(i,a),l=s.map(u=>u.price).sort((u,p)=>u-p);r.push({timestamp:s[s.length-1].timestamp,price:gf(l)});}return r}function vf(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:hf(s.data,t)})),n=new Set;r.forEach(s=>s.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((s,l)=>s-l),i=r.map(s=>{let l=new Map;return s.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:s.marketSlug,map:l}}),a=new Map;return o.map(s=>{let l={timestamp:s};return i.forEach(({slug:u,map:p})=>{let d=p.get(s);if(d!==void 0)a.set(u,d),l[u]=d;else {let f=a.get(u);f!==void 0&&(l[u]=f);}}),l})}function Da(e){return jsxRuntime.jsx(di,{children:jsxRuntime.jsx(bf,{...e})})}function bf({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=react.useMemo(()=>{let P=new Set;return (e.markets??[]).filter(T=>P.has(T.slug)?false:(P.add(T.slug),true))},[e.markets]),a=react.useMemo(()=>[...i].sort((P,T)=>{let z=J=>(J.outcomes.find(ue=>ue.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return z(T)-z(P)}),[i]),[s,l]=react.useState(()=>a.slice(0,hn).map(P=>P.slug));react.useEffect(()=>{let P=new Set(i.map(T=>T.slug));l(T=>{let z=T.filter(J=>P.has(J));return z.length===T.length?T:z.length>0?z:a.slice(0,hn).map(J=>J.slug)});},[i,a]);let[u,p]=react.useState(Hn),d=react.useMemo(()=>{let P=new Map;return s.forEach((T,z)=>{P.set(T,Ia[z%Ia.length]);}),P},[s]),f=react.useMemo(()=>i.filter(P=>s.includes(P.slug)),[i,s]),{series:c,isLoading:m}=reactPredict.useMarketHistory(f,u),g=t||m,v=react.useMemo(()=>{if(c.length>0&&c.some(z=>z.data.length>0))return c;let P=Date.now(),T=864e5;return f.map(z=>{let ue=(z.outcomes?.find(ae=>ae.label.toLowerCase()==="yes")??z.outcomes?.[0])?.price??.5;return {marketSlug:z.slug,label:z.outcomes?.[0]?.label??z.question,data:[{timestamp:P-7*T,price:ue},{timestamp:P,price:ue}]}})},[c,f]),h=react.useMemo(()=>u===ce.ONE_DAY?96:u===ce.ONE_WEEK?168:u===ce.ONE_MONTH?180:300,[u]),x=react.useMemo(()=>vf(v,h),[v,h]),k=react.useMemo(()=>{if(x.length===0)return [0,1];let P=1/0,T=-1/0;if(s.forEach(J=>{x.forEach(ue=>{let ae=ue[J];ae!=null&&(ae<P&&(P=ae),ae>T&&(T=ae));});}),!isFinite(P))return [0,1];let z=Math.max((T-P)*.15,.05);return [Math.max(0,P-z),Math.min(1,T+z)]},[x,s]),S=react.useMemo(()=>{let P=new Map;return v.forEach(T=>{T.data.length>0&&P.set(T.marketSlug,T.data[T.data.length-1].price);}),P},[v]),b=react.useMemo(()=>{let P=new Map;return v.forEach(T=>P.set(T.marketSlug,T.label)),P},[v]),y=react.useMemo(()=>v.map(P=>({slug:P.marketSlug,color:d.get(P.marketSlug)??"#6b7280"})),[v,d]),{wrapperRef:N,overlayRef:M,onMouseMove:C,onMouseLeave:_}=uf(),F=react.useCallback(P=>{l(T=>T.includes(P)?T.length<=1?T:T.filter(z=>z!==P):T.length>=hn?T:[...T,P]);},[]),[U,Q]=react.useState(null),B=react.useRef(null),Y=react.useRef(""),q=react.useRef(0),te=!g&&x.length>0;return jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsxRuntime.jsx(ff,{series:v,colorMap:d,displayValues:U??S}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsxRuntime.jsx("div",{ref:N,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?P=>{C(P),cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{Q(B.current);});}:void 0,onMouseLeave:te?()=>{_(),cancelAnimationFrame(q.current),Y.current="",B.current=null,Q(null);}:void 0,children:g?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:M,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:P=>af(P,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:k,tickFormatter:P=>`${Math.round(P*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:P=>{let T=P;if(T.active&&T.payload?.length){let z=T.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if(z!==Y.current){Y.current=z;let J=new Map;T.payload.forEach(ue=>{ue.value!=null&&J.set(ue.dataKey,ue.value);}),B.current=J;}}return jsxRuntime.jsx(pf,{...T,labelMap:b,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(P=>{let T=d.get(P.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:P.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},P.marketSlug)}),U==null&&x.length>0&&v.map(P=>{let T=x[x.length-1],z=T[P.marketSlug];if(z==null)return null;let J=d.get(P.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:T.timestamp,y:z,ifOverflow:"extendDomain",shape:ue=>{let{cx:ae,cy:Ke}=ue;return ae==null||Ke==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:ae,cy:Ke,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:ae,cy:Ke,r:3.5,fill:J})]})}},`pulse-${P.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(df,{value:u,onChange:p}),a.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(mf,{markets:a,selectedSlugs:s,colorMap:d,onToggle:F})})]})]})]})}function co(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ba(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Of(e){return `${parseFloat((e*100).toFixed(2))}%`}function Ha(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function uo(e){return e.outcomes?.[0]?.label??e.question}function Af(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function vn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${a}`}function za(e){let[t,r]=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),a=Math.floor(o%864e5/36e5),s=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(a).padStart(2,"0")}h`),u.push(`${String(s).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function Wa(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}function Va({event:e,onTradeAction:t}){let{t:r}=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)=>co(g)-co(m)),c=d.filter(m=>m.status!=="open").sort((m,g)=>co(g)-co(m));return [...f,...c]},[e.markets]),a=e.status==="closed"||e.status==="voided",s=za(a?void 0:e.start_at),l=za(a?void 0:e.end_at),u=Wa(e.start_at),p=Wa(e.end_at);return 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(Hf,{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})]})]}),(s||l||a)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?p&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:p})}):s?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:s})}),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})}),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(Da,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(Df,{markets:i,onTradeAction:t}),jsxRuntime.jsx(Bf,{markets:i,event:e})]})}var Ua=5;function Df({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{isDesktop:n}=ui.useScreen(),[o,i]=react.useState(false),[a,s]=react.useState(null),l=react.useMemo(()=>{let v=new Set;return e.filter(h=>v.has(h.slug)?false:(v.add(h.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[p,d]=react.useState(u?`${u}:yes`:null);if(l.length===0)return null;let f=l.length>Ua,c=o?l:l.slice(0,Ua),m=v=>{s(h=>h===v?null:v);},g=(v,h,x)=>{d(`${v.slug}:${h}`),n&&s(v.slug),t?.(v,h,x);};return 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,h)=>{let x=a===v.slug;return jsxRuntime.jsx(Ff,{market:v,activeYes:p===`${v.slug}:yes`,activeNo:p===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>m(v.slug),onTradeAction:g},v.id??`${h}-${v.slug}`)})})]}),f&&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(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 Ff({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:a}=i18n.useTranslation(),s=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:s}),{data:p}=reactPredict.useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),d=reactPredict.pickBestAsk(u,"yes")??Ba(e,"yes")??0,f=reactPredict.pickBestAsk(p,"no")??Ba(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:c=>{(c.key==="Enter"||c.key===" ")&&(c.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:uo(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:uo(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(d)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:s?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:a("predict.market.action.yes",{price:Ha(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:c=>{c.stopPropagation(),i?.(e,"no","buy");},children:f!=null?a("predict.market.action.no",{price:Ha(f)}):a("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"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("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(_a,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Bf({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[n,o]=react.useState(false),[i,a]=react.useState(false),[s,l]=react.useState(0),u=e.filter(c=>c.rules&&c.rules.length>0||c.description);if(u.length===0)return null;let p=u[s]??u[0],d=p.rules&&p.rules.length>0?p.rules.join(`
76
+ `,va={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"detailShimmer 1.8s ease-in-out infinite",borderRadius:6};function he(e){return {...va,animationDelay:`${e}ms`}}function fn({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ha}),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:{...va,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:{...he(0),height:14,width:48}}),jsxRuntime.jsx("div",{style:{...he(30),height:14,width:40}}),jsxRuntime.jsx("div",{style:{...he(60),height:14,width:40}})]}),jsxRuntime.jsx("div",{style:{...he(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsxRuntime.jsx("div",{style:{...he(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:{...he(120),height:16,width:96}}),jsxRuntime.jsx("div",{style:{...he(140),height:16,width:80}})]}),jsxRuntime.jsx("div",{style:{...he(160),height:300,width:"100%",borderRadius:12}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("div",{style:{...he(180),height:16,width:80}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...he(200),height:28,width:200,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(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:{...he(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:{...he(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:{...he(280+n*40),height:14,width:n%2===0?192:160}}),jsxRuntime.jsx("div",{style:{...he(300+n*40),height:10,width:64}})]}),jsxRuntime.jsx("div",{style:{...he(320+n*40),height:16,width:40}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...he(340+n*40),height:32,width:80,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(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:{...he(400),height:16,width:64}}),jsxRuntime.jsx("div",{style:{...he(420),height:14,width:"100%"}}),jsxRuntime.jsx("div",{style:{...he(440),height:14,width:"80%"}}),jsxRuntime.jsx("div",{style:{...he(460),height:14,width:"60%"}})]})]})]})}function ba(){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ha}),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:{...he(0),height:40,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(60),height:96,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...he(120),height:40,width:"100%",borderRadius:8}})]})]})}var wa="var(--color-bullish)",Pa="var(--color-bearish)";function gn(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Bm(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Hm(e,t){let r=new Float64Array(101),n=new Float64Array(101);for(let d of e){let m=Math.round(d.price*100);m>=0&&m<=100&&(r[m]+=d.quantity);}for(let d of t){let m=Math.round(d.price*100);m>=0&&m<=100&&(n[m]+=d.quantity);}let o=0,i=0,a=new Float64Array(101),s=new Float64Array(101);for(let d=100;d>=0;d--)o+=r[d],i+=r[d]*d/100,a[d]=o,s[d]=i;let l=0,u=0,p=new Float64Array(101),c=new Float64Array(101);for(let d=0;d<=100;d++)l+=n[d],u+=n[d]*d/100,p[d]=l,c[d]=u;let f=Math.max(a[0]??0,p[100]??0);return Array.from({length:101},(d,m)=>{let g=a[m]>0,v=p[m]>0,h=a[m]||p[m],x=r[m]>0||n[m]>0;return {priceCents:m,displayHeight:Bm(h,f),opacity:h>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[m],askCumTotal:p[m],bidCumCost:s[m],askCumCost:c[m]}})}function zm({info:e}){let{t}=i18n.useTranslation(),r=e.isBid?wa:Pa,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:gn(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:r},children:["$",gn(Math.round(e.cumCost))]})]})}var Wm=react.memo(function({slot:t,onEnter:r,onLeave:n}){let o=react.useRef(null),i=t.isBid||t.isAsk,a=t.isBid?wa:t.isAsk?Pa: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:a,opacity:t.opacity}})})}),Um=[0,10,20,30,40,50,60,70,80,90,100];function $m(){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:Um.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 Na({bids:e,asks:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>Hm(e,t),[e,t]),o=react.useMemo(()=>{let c=e.length>0?Math.max(...e.map(d=>d.price)):0,f=t.length>0?Math.min(...t.map(d=>d.price)):1;return Math.round((c+f)/2*100)},[e,t]),i=react.useMemo(()=>n.some(c=>c.isBid||c.isAsk),[n]),[a,s]=react.useState(null),l=react.useRef(null),u=react.useCallback((c,f)=>{l.current&&(l.current.style.filter=""),f?(f.style.filter="brightness(1.5)",l.current=f):l.current=null,c.isBid||c.isAsk?s({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.priceCents}):s(null);},[]),p=react.useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),s(null);},[]);return 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"}}),a&&jsxRuntime.jsx(zm,{info:a}),n.map(c=>jsxRuntime.jsx(Wm,{slot:c,onEnter:u,onLeave:p},c.priceCents))]}),jsxRuntime.jsx($m,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function Ra(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function Ma(){let{t:e}=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 _a({market:e,outcome:t="yes",onTradeAction:r,initialViewMode:n="depth",className:o,oddsFormatter:i}){let{t:a}=i18n.useTranslation(),[s,l]=react.useState(n),u=i??Ra,p=e.source,{data:c,isLoading:f,isFetching:d,refetch:m}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:p,outcome:t}),g=react.useMemo(()=>(c?.bids??[]).map(S=>({price:S.price,quantity:S.size})),[c?.bids]),v=react.useMemo(()=>(c?.asks??[]).map(S=>({price:S.price,quantity:S.size})),[c?.asks]),h=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]),k=react.useMemo(()=>{if(h==null||x==null)return null;let S=(x-h)*100;return Math.round(S*10)/10},[h,x]);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:k!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(k)?`${k}\xA2`:`${k.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[h!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[a("predict.trade.bestBid"),": ",u(h)]}),h!=null&&x!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),x!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[a("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:s==="depth"?"Orderbook":"Depth chart",onClick:()=>l(S=>S==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:s==="depth"?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:d,className:ui.cn("flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground disabled:cursor-default disabled:opacity-50",d&&"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:[s==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(Ma,{}):jsxRuntime.jsx(Na,{bids:g,asks:v})}),s==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx(Ma,{}):jsxRuntime.jsx(Ym,{bids:g,asks:v,bestBid:h??void 0,bestAsk:x??void 0,spread:k??void 0,oddsFormatter:i})})]})]})}var ai=4,qm=8;function Ym({bids:e,asks:t,spread:r,oddsFormatter:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState(false),s=i?qm:ai,l=t.length>ai||e.length>ai,u=react.useMemo(()=>[...t].sort((d,m)=>d.price-m.price).slice(0,s).reverse(),[t,s]),p=react.useMemo(()=>[...e].sort((d,m)=>m.price-d.price).slice(0,s),[e,s]),c=react.useMemo(()=>{let d=[...u,...p].map(m=>m.quantity);return Math.max(...d,1)},[u,p]);return u.length===0&&p.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[u.map(d=>jsxRuntime.jsx(Ta,{price:d.price,quantity:d.quantity,side:"ask",maxQty:c,oddsFormatter:n},`ask-${d.price}`)),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:[r!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]}),l&&jsxRuntime.jsx("button",{type:"button",onClick:()=>a(d=>!d),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(d=>jsxRuntime.jsx(Ta,{price:d.price,quantity:d.quantity,side:"bid",maxQty:c,oddsFormatter:n},`bid-${d.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Ta({price:e,quantity:t,side:r,maxQty:n,oddsFormatter:o}){let i=r==="ask",a=Math.min(t/n*100,100),s=i?"bg-bearish/10":"bg-bullish/10",l=i?"text-bearish":"text-bullish",u=gn(Math.round(t)),p=Math.round(t*e),c=`$${gn(p)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${a}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 ${l}`,children:o?o(e):Ra(e)}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-center",children:u}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:c})]})}var di=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}},hn=4,Ia=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function lf(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function cf(e,t){let r=new Date(e);return t===ce.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ce.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Aa(e){return `${(e*100).toFixed(2)}%`}var df=[{range:ce.ONE_DAY,label:"1D"},{range:ce.ONE_WEEK,label:"1W"},{range:ce.ONE_MONTH,label:"1M"},{range:ce.ALL,label:"ALL"}];function uf({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:df.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 pf(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(o=>{let i=e.current,a=t.current;if(!i||!a)return;let s=i.getBoundingClientRect(),l=(o.clientX-s.left)/s.width*100;a.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,a.style.opacity="1";},[]),n=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:n}}function mf({active:e,payload:t,label:r,labelMap:n,allSeries:o,range:i}){if(!e||!o?.length)return null;let a=new Map;t?.forEach(l=>a.set(l.dataKey,l));let s=o.map(l=>a.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return 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"?cf(r,i):r}),s.map(l=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(l.dataKey)??l.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Aa(l.value):"--"})]},l.dataKey))]})}function ff({markets:e,selectedSlugs:t,colorMap:r,onToggle:n}){let[o,i]=react.useState(false),a=react.useRef(null);react.useEffect(()=>{if(!o)return;function u(p){a.current&&!a.current.contains(p.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let s=t.length>=hn,l=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:a,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: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 ",hn," markets"]}),e.map((u,p)=>{let c=t.includes(u.slug),f=!c&&s,d=c&&t.length===1,m=r.get(u.slug)??"#6b7280",g=u.outcomes.find(h=>h.label.toLowerCase()==="yes")??u.outcomes[0],v=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{d||f||n(u.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:c?"rgba(255,255,255,0.05)":"transparent",cursor:f||d?"not-allowed":"pointer",opacity:f?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!f&&!d&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=c?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:c?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:c?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:c&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:c?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.outcomes?.[0]?.label??u.question}),v&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${p}-${u.slug}`)})]})]})}function gf({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?Aa(i):"--"})]})]},n.marketSlug)})})}function hf(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function vf(e,t){if(e.length<=t)return e;let r=[],n=e.length/t;for(let o=0;o<t;o++){let i=Math.floor(o*n),a=Math.min(Math.floor((o+1)*n),e.length),s=e.slice(i,a),l=s.map(u=>u.price).sort((u,p)=>u-p);r.push({timestamp:s[s.length-1].timestamp,price:hf(l)});}return r}function bf(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:vf(s.data,t)})),n=new Set;r.forEach(s=>s.data.forEach(l=>n.add(l.timestamp)));let o=Array.from(n).sort((s,l)=>s-l),i=r.map(s=>{let l=new Map;return s.data.forEach(u=>l.set(u.timestamp,u.price)),{slug:s.marketSlug,map:l}}),a=new Map;return o.map(s=>{let l={timestamp:s};return i.forEach(({slug:u,map:p})=>{let c=p.get(s);if(c!==void 0)a.set(u,c),l[u]=c;else {let f=a.get(u);f!==void 0&&(l[u]=f);}}),l})}function Da(e){return jsxRuntime.jsx(di,{children:jsxRuntime.jsx(xf,{...e})})}function xf({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=react.useMemo(()=>{let P=new Set;return (e.markets??[]).filter(T=>P.has(T.slug)?false:(P.add(T.slug),true))},[e.markets]),a=react.useMemo(()=>[...i].sort((P,T)=>{let z=J=>(J.outcomes.find(ue=>ue.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return z(T)-z(P)}),[i]),[s,l]=react.useState(()=>a.slice(0,hn).map(P=>P.slug));react.useEffect(()=>{let P=new Set(i.map(T=>T.slug));l(T=>{let z=T.filter(J=>P.has(J));return z.length===T.length?T:z.length>0?z:a.slice(0,hn).map(J=>J.slug)});},[i,a]);let[u,p]=react.useState(Hn),c=react.useMemo(()=>{let P=new Map;return s.forEach((T,z)=>{P.set(T,Ia[z%Ia.length]);}),P},[s]),f=react.useMemo(()=>i.filter(P=>s.includes(P.slug)),[i,s]),{series:d,isLoading:m}=reactPredict.useMarketHistory(f,u),g=t||m,v=react.useMemo(()=>{if(d.length>0&&d.some(z=>z.data.length>0))return d;let P=Date.now(),T=864e5;return f.map(z=>{let ue=(z.outcomes?.find(ae=>ae.label.toLowerCase()==="yes")??z.outcomes?.[0])?.price??.5;return {marketSlug:z.slug,label:z.outcomes?.[0]?.label??z.question,data:[{timestamp:P-7*T,price:ue},{timestamp:P,price:ue}]}})},[d,f]),h=react.useMemo(()=>u===ce.ONE_DAY?96:u===ce.ONE_WEEK?168:u===ce.ONE_MONTH?180:300,[u]),x=react.useMemo(()=>bf(v,h),[v,h]),k=react.useMemo(()=>{if(x.length===0)return [0,1];let P=1/0,T=-1/0;if(s.forEach(J=>{x.forEach(ue=>{let ae=ue[J];ae!=null&&(ae<P&&(P=ae),ae>T&&(T=ae));});}),!isFinite(P))return [0,1];let z=Math.max((T-P)*.15,.05);return [Math.max(0,P-z),Math.min(1,T+z)]},[x,s]),S=react.useMemo(()=>{let P=new Map;return v.forEach(T=>{T.data.length>0&&P.set(T.marketSlug,T.data[T.data.length-1].price);}),P},[v]),b=react.useMemo(()=>{let P=new Map;return v.forEach(T=>P.set(T.marketSlug,T.label)),P},[v]),y=react.useMemo(()=>v.map(P=>({slug:P.marketSlug,color:c.get(P.marketSlug)??"#6b7280"})),[v,c]),{wrapperRef:N,overlayRef:M,onMouseMove:C,onMouseLeave:_}=pf(),F=react.useCallback(P=>{l(T=>T.includes(P)?T.length<=1?T:T.filter(z=>z!==P):T.length>=hn?T:[...T,P]);},[]),[U,Q]=react.useState(null),B=react.useRef(null),Y=react.useRef(""),q=react.useRef(0),te=!g&&x.length>0;return jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12,...o?{height:"100%",minHeight:0}:null},children:[jsxRuntime.jsx(gf,{series:v,colorMap:c,displayValues:U??S}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsxRuntime.jsx("div",{ref:N,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?P=>{C(P),cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{Q(B.current);});}:void 0,onMouseLeave:te?()=>{_(),cancelAnimationFrame(q.current),Y.current="",B.current=null,Q(null);}:void 0,children:g?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:M,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:P=>lf(P,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:k,tickFormatter:P=>`${Math.round(P*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:P=>{let T=P;if(T.active&&T.payload?.length){let z=T.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if(z!==Y.current){Y.current=z;let J=new Map;T.payload.forEach(ue=>{ue.value!=null&&J.set(ue.dataKey,ue.value);}),B.current=J;}}return jsxRuntime.jsx(mf,{...T,labelMap:b,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(P=>{let T=c.get(P.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:P.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},P.marketSlug)}),U==null&&x.length>0&&v.map(P=>{let T=x[x.length-1],z=T[P.marketSlug];if(z==null)return null;let J=c.get(P.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:T.timestamp,y:z,ifOverflow:"extendDomain",shape:ue=>{let{cx:ae,cy:Ke}=ue;return ae==null||Ke==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:ae,cy:Ke,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:ae,cy:Ke,r:3.5,fill:J})]})}},`pulse-${P.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(uf,{value:u,onChange:p}),a.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(ff,{markets:a,selectedSlugs:s,colorMap:c,onToggle:F})})]})]})]})}function co(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ba(e,t){let r=e.outcomes[t==="yes"?0:1];return r?.best_ask??r?.price}function Af(e){return `${parseFloat((e*100).toFixed(2))}%`}function Ha(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function uo(e){return e.outcomes?.[0]?.label??e.question}function Df(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function vn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),n=t.getDate(),o=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${n}, ${o} ${i}:${a}`}function za(e){let[t,r]=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),a=Math.floor(o%864e5/36e5),s=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3),u=[];return i>0&&u.push(`${i}d`),u.push(`${String(a).padStart(2,"0")}h`),u.push(`${String(s).padStart(2,"0")}m`),u.push(`${String(l).padStart(2,"0")}s`),u.join(" ")}function Wa(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}function Va({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:n,isCollapsed:o}=hooks.useScrollCollapse(),i=react.useMemo(()=>{let c=[...e.markets||[]],f=c.filter(m=>m.status==="open").sort((m,g)=>co(g)-co(m)),d=c.filter(m=>m.status!=="open").sort((m,g)=>co(g)-co(m));return [...f,...d]},[e.markets]),a=e.status==="closed"||e.status==="voided",s=za(a?void 0:e.start_at),l=za(a?void 0:e.end_at),u=Wa(e.start_at),p=Wa(e.end_at);return 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((c,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:c.label})]},c.slug)),jsxRuntime.jsx(zf,{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})]})]}),(s||l||a)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?p&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:p})}):s?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:s})}),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})}),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(Da,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(Ff,{markets:i,onTradeAction:t}),jsxRuntime.jsx(Hf,{markets:i,event:e})]})}var Ua=5;function Ff({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{isDesktop:n}=ui.useScreen(),[o,i]=react.useState(false),[a,s]=react.useState(null),l=react.useMemo(()=>{let v=new Set;return e.filter(h=>v.has(h.slug)?false:(v.add(h.slug),true))},[e]),u=l.find(v=>v.status==="open")?.slug,[p,c]=react.useState(u?`${u}:yes`:null);if(l.length===0)return null;let f=l.length>Ua,d=o?l:l.slice(0,Ua),m=v=>{s(h=>h===v?null:v);},g=(v,h,x)=>{c(`${v.slug}:${h}`),n&&s(v.slug),t?.(v,h,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:d.map((v,h)=>{let x=a===v.slug;return jsxRuntime.jsx(Bf,{market:v,activeYes:p===`${v.slug}:yes`,activeNo:p===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>m(v.slug),onTradeAction:g},v.id??`${h}-${v.slug}`)})})]}),f&&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(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 Bf({market:e,activeYes:t,activeNo:r,isExpanded:n,onToggleExpand:o,onTradeAction:i}){let{t:a}=i18n.useTranslation(),s=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:s}),{data:p}=reactPredict.useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),c=reactPredict.pickBestAsk(u,"yes")??Ba(e,"yes")??0,f=reactPredict.pickBestAsk(p,"no")??Ba(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:d=>{(d.key==="Enter"||d.key===" ")&&(d.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:uo(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:uo(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:Af(c)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:s?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:d=>{d.stopPropagation(),i?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:Ha(c)})}),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:d=>{d.stopPropagation(),i?.(e,"no","buy");},children:f!=null?a("predict.market.action.no",{price:Ha(f)}):a("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"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("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(_a,{market:e,outcome:r?"no":"yes",onTradeAction:i})})})})]})}function Hf({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[n,o]=react.useState(false),[i,a]=react.useState(false),[s,l]=react.useState(0),u=e.filter(d=>d.rules&&d.rules.length>0||d.description);if(u.length===0)return null;let p=u[s]??u[0],c=p.rules&&p.rules.length>0?p.rules.join(`
77
77
 
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:uo(p)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:c=>{l(Number(c)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((c,m)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(m===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:uo(c)},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(c=>!c),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(c=>!c),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[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=p.status,m=[];return p.created_at&&m.push({label:r("predict.event.timeline.created"),value:vn(p.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:vn(p.start_at),isActive:c!=="pending"}),c==="voided"?m.push({label:r("predict.event.timeline.voided"),value:vn(p.closed_at??p.end_at),isActive:true}):c==="closed"?m.push({label:r("predict.event.timeline.closed"),value:vn(p.closed_at??p.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:vn(p.end_at),isActive:false}),m})().map((c,m,g)=>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: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:Af(p.source)})]})]})]})]})}function Hf({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 ja({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=reactPredict.useEvent({slug:e,source:t});return o?jsxRuntime.jsx(fn,{}):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(Va,{event:n,onTradeAction:r})}var Kf={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}},Vf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Ut(e){return Kf[e]??Vf}function G1({source:e,className:t}){let r=Ut(e);return 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 qa="rgba(39,39,42,0.6)",Jf="rgba(63,63,70,0.8)";function Zf(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function Qa({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=i18n.useTranslation(),{data:a,isLoading:s}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return s||!a||a.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(l=>jsxRuntime.jsx(eg,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function eg({event:e,onClick:t,onHover:r}){let{t:n}=i18n.useTranslation(),o=Ut(e.source),i=react.useMemo(()=>Zf(e.volume),[e.volume]),a=e.tags?.[0];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=Jf,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=qa;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${qa}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[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")]}),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxRuntime.jsx("span",{style:{color:"#71717a"},children:a.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function mo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function b2({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:a,renderActivitySection:s,onInsufficientBalance:l,onSetupRequired:u,slippageBps:p}){let{t:d}=i18n.useTranslation(),{isDesktop:f}=ui.useScreen(),{onOpen:c}=uiScaffold.useAsyncModal(on),{onOpen:m}=uiScaffold.useAsyncModal(Zo),{data:g,isLoading:v}=reactPredict.useEvent({slug:e,source:t}),h=react.useMemo(()=>{let M=[...g?.markets||[]],C=M.filter(F=>F.status==="open").sort((F,U)=>mo(U)-mo(F)),_=M.filter(F=>F.status!=="open").sort((F,U)=>mo(U)-mo(F));return [...C,..._]},[g?.markets]),[x,k]=react.useState(null),S=react.useCallback((M,C,_)=>{k(F=>({market:M,outcome:C,side:_,version:(F?.version??0)+1})),!f&&g&&(_==="sell"?m({params:{event:g,market:M,initialOutcome:C,chain:r,slippageBps:p,onSetupRequired:u}}):c({params:{event:g,market:M,initialOutcome:C,chain:r,slippageBps:p,onInsufficientBalance:l}}));},[f,g,r,p,c,m,l,u]),b=x?.market??h[0];if(v){let M=!!a;return f?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(fn,{showBack:M})}),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(ba,{})})})]}):jsxRuntime.jsx(fn,{showBack:M})}let y=x?`${x.market.slug}-${x.version}`:b?.slug??"default",N=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:[a&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:a,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-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(ja,{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:[b&&(N?jsxRuntime.jsx(no,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:p,onSetupRequired:u},y):jsxRuntime.jsx(qn,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:p,onInsufficientBalance:l},y)),g&&jsxRuntime.jsx(Qa,{eventSlug:e,source:g.source,onEventClick:o,onEventHover:i})]})]}),g&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:s?s({event:g,walletAddress:n}):jsxRuntime.jsx(ga,{event:g,walletAddress:n})}),jsxRuntime.jsx(Yn,{}),jsxRuntime.jsx(pa,{}),jsxRuntime.jsx(Xs,{})]})}function Ja(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function fg(e){switch(e){case ce.ONE_DAY:return {interval:"15m",limit:96};case ce.ONE_WEEK:return {interval:"1h",limit:168};case ce.ONE_MONTH:return {interval:"4h",limit:180};case ce.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var N2=e=>{let{candlestickMarketSlugs:t,chartRange:r=Hn,source:n}=e,o=reactPredict.usePredictClient(),i=react.useMemo(()=>fg(r),[r]),{data:a,isLoading:s,error:l}=reactPredict.useEvent({slug:e.eventSlug,source:n}),u=react.useMemo(()=>{if(!a?.markets)return [];let m=new Set,g=a.markets.filter(h=>m.has(h.slug)?false:(m.add(h.slug),true));return (t&&t.length>0?t.slice(0,4).map(h=>g.find(x=>x.slug===h)).filter(h=>h!==void 0):[...g].sort((h,x)=>Ja(x)-Ja(h)).slice(0,4)).map(h=>h.slug)},[t,a?.markets]),p=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,v)=>{let h=p[v]?.error;h&&m.set(g,h);}),m},[u,p]),c=react.useMemo(()=>{let m=new Map;return u.forEach((g,v)=>{let h=p[v]?.data;h&&m.set(g,h);}),m},[u,p]);return {event:a,isEventLoading:s,eventError:l,candlestickParams:i,candlesticks:c,isCandlesticksLoading:d,candlestickErrors:f}};function mi({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=react.useMemo(()=>bg(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(gg,{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(hg,{className:"size-3.5"}),jsxRuntime.jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function gg({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=react.useMemo(()=>vg(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 hg({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 vg(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return `hsl(${Math.abs(t)%360}, 55%, 45%)`}function bg(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let i=Math.floor(o/24);if(i<7)return `${i}d`;let a=Math.floor(i/7);return a<5?`${a}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Tg={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},tl={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Eg=["latest","oldest","mostLiked"],Lg=600,Rg=112;function _g({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState("latest"),[l,u]=react.useState(false),p=Tg[a],{data:d,isLoading:f,isFetchingNextPage:c,hasNextPage:m,fetchNextPage:g}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:p.order,ascending:p.ascending,holders_only:l}),v=react.useMemo(()=>d?.pages?.flatMap(_=>_.items)??[],[d?.pages]),h=react.useRef(null),{height:x}=hooks.useResizeObserver({ref:h}),k=n??(x||Lg),S=reactWindow.useDynamicRowHeight({defaultRowHeight:Rg,key:`${e}:${t}:${a}:${l}`}),b=v.length,y=b+(m?1:0),N=react.useCallback(_=>_<b,[b]),M=react.useCallback(async()=>{m&&!c&&await g();},[m,c,g]),C=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:N,loadMoreRows:M,rowCount:y,threshold:5});return jsxRuntime.jsxs("div",{className:ui.cn("flex h-full w-full flex-col",o),children:[jsxRuntime.jsx(Og,{sort:a,onSortChange:s,holdersOnly:l,onHoldersOnlyChange:u}),jsxRuntime.jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:h,children:f?jsxRuntime.jsx(Ag,{}):v.length===0?jsxRuntime.jsx(Dg,{message:i("predict.comments.empty")}):jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:k},onRowsRendered:C,rowComponent:Ig,rowCount:y,rowHeight:S,rowProps:{comments:v,itemCount:b,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Ig({index:e,style:t,comments:r,itemCount:n,anonymousLabel:o}){if(e>=n)return 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(mi,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function Og({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState(false),s=react.useRef(null);return react.useEffect(()=>{if(!i)return;let l=p=>{s.current&&!s.current.contains(p.target)&&a(false);},u=p=>{p.key==="Escape"&&a(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[i]),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxRuntime.jsxs("div",{ref:s,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(Fg,{className:"size-3.5 text-neutral"}),jsxRuntime.jsx("span",{children:o(tl[e])}),jsxRuntime.jsx(Bg,{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),a(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(tl[l])}),u&&jsxRuntime.jsx(rl,{className:"size-4 text-primary"})]},l)})})]}),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(rl,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function Ag(){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 Dg({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 Fg({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 Bg({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 rl({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 Wg=10,Ug=utils.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function bo(){let[e,t]=jotai.useAtom(Ug),r=react.useCallback(o=>{let i=o.trim();i&&t(a=>{let s=a.filter(l=>l!==i);return [i,...s].slice(0,Wg)});},[t]),n=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function ll({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 cl({onSelect:e,className:t}){let{histories:r,clearHistories:n}=bo();return jsxRuntime.jsx(ll,{className:ui.cn(t),histories:r,onSelect:e,onClear:n})}function dl({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:a=>{a.preventDefault(),n?.();},children:"Esc"})})})}function l0(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function ul({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:a}=i18n.useTranslation(),s=e.tags?.[0],l=Ut(e.source),u=react.useMemo(()=>l0(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: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," ",a("predict.event.volume")]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral-500",children:s.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function pl({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:a,fetchNextPage:s}=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:a??false,fetchNextPage:s}}var b0=64;function hl({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:a,isLoading:s,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:p}=pl(i),d=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:d}),c=react.useCallback(h=>h<a.length,[a]),m=react.useCallback(async()=>{u&&!l&&await p();},[u,l,p]),g=react.useMemo(()=>u?a.length+1:a.length,[a,u]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:c,loadMoreRows:m,rowCount:g,threshold:5});return s?jsxRuntime.jsx(y0,{className:o}):a.length===0?jsxRuntime.jsx(k0,{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:v,rowComponent:x0,rowCount:g,rowHeight:b0,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function x0({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:a}){let s=r[e];return s?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ul,{event:s,href:o?.(s),LinkComponent:i,onSelect:n,onHover:a})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function y0({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 k0({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 yl({onKeywordChange:e}){let[t,r]=react.useState(""),[n,o]=react.useState(""),{addHistory:i}=bo(),a=hooks.useCallbackRef(e),s=hooks.useCallbackRef(i),l=react.useMemo(()=>utils$1.debounce(f=>{o(f),a(f),f&&s(f);},500),[a,s]),u=react.useCallback(f=>{r(f),l(f);},[l]),p=react.useCallback(f=>{l.cancel(),r(f),o(f),a(f),f&&s(f);},[l,a,s]),d=react.useCallback(()=>p(""),[p]);return {text:t,keyword:n,setText:u,setKeyword:p,clearKeyword:d}}function kl({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:a}){let{text:s,keyword:l,setText:u,setKeyword:p,clearKeyword:d}=yl({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(dl,{value:s,onValueChange:u,onClear:d,onEscape:i}),!l&&jsxRuntime.jsx(cl,{onSelect:p}),jsxRuntime.jsx(hl,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:a})]})}var bi="predict-search";function bS({id:e=bi}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(O0,{...t})})}function O0({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),a=react.useCallback(l=>{n(l);},[n]),s=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(kl,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:s})})]})})}function MS({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=i18n.useTranslation(),{isDesktop:o}=ui.useScreen(),{onOpen:i,onClose:a}=uiScaffold.useAsyncModal(bi),s=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let p=await i({params:t});p&&s(p);}),u=hooks.useCallbackRef(()=>{a();});return react.useEffect(()=>{let p=d=>{let f=document.activeElement,c=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");d.key==="/"&&!c&&(d.preventDefault(),l()),d.key==="Escape"&&(d.preventDefault(),u());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[l,u]),o?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:n("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 yi=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],_l=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],El={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Ll={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function U0(e,t){if(!e)return "$5K+";let r=_l.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Il({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:a}){let{t:s}=i18n.useTranslation(),[l,u]=react.useState(false),[p,d]=react.useState(false),[f,c]=react.useState(false),[m,g]=react.useState(false),v=react.useRef(null),h=react.useRef(null),x=yi.find(b=>b.value===e)??yi[0],k=react.useCallback(b=>{v.current&&!v.current.contains(b.target)&&u(false),h.current&&!h.current.contains(b.target)&&d(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)),[k]);let S=react.useCallback(()=>{a?.(),g(true),setTimeout(()=>g(false),700);},[a]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
78
+ `):p.description??"";if(!c)return null;let f=c.length>200&&!n?c.slice(0,200)+"...":c;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),u.length>1&&jsxRuntime.jsxs(ui.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:uo(p)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:d=>{l(Number(d)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((d,m)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(m===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:uo(d)},String(m)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),c.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>o(d=>!d),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(n?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(d=>!d),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.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 d=p.status,m=[];return p.created_at&&m.push({label:r("predict.event.timeline.created"),value:vn(p.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:vn(p.start_at),isActive:d!=="pending"}),d==="voided"?m.push({label:r("predict.event.timeline.voided"),value:vn(p.closed_at??p.end_at),isActive:true}):d==="closed"?m.push({label:r("predict.event.timeline.closed"),value:vn(p.closed_at??p.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:vn(p.end_at),isActive:false}),m})().map((d,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 ${d.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:d.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:d.value})]})]},d.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:p.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:Df(p.source)})]})]})]})]})}function zf({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 ja({eventSlug:e,source:t,onTradeAction:r}){let{data:n,isLoading:o,error:i}=reactPredict.useEvent({slug:e,source:t});return o?jsxRuntime.jsx(fn,{}):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(Va,{event:n,onTradeAction:r})}var Vf={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}},jf={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Ut(e){return Vf[e]??jf}function Y1({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 qa="rgba(39,39,42,0.6)",Zf="rgba(63,63,70,0.8)";function eg(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function Qa({eventSlug:e,source:t,limit:r=4,onEventClick:n,onEventHover:o}){let{t:i}=i18n.useTranslation(),{data:a,isLoading:s}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return s||!a||a.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{style:{color:"#f4f4f5",fontSize:14,fontWeight:600},children:i("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-2",children:a.map(l=>jsxRuntime.jsx(tg,{event:l,onClick:n,onHover:o},`${l.source}-${l.slug}`))})]})}function tg({event:e,onClick:t,onHover:r}){let{t:n}=i18n.useTranslation(),o=Ut(e.source),i=react.useMemo(()=>eg(e.volume),[e.volume]),a=e.tags?.[0];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),onMouseEnter:s=>{s.currentTarget.style.borderColor=Zf,r?.(e);},onMouseLeave:s=>{s.currentTarget.style.borderColor=qa;},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:14,border:`1px solid ${qa}`,background:"rgba(24,24,27,0.4)",cursor:"pointer",textAlign:"left",width:"100%",transition:"border-color 0.2s"},className:"group",children:[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")]}),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{style:{color:"#52525b"},children:"\xB7"}),jsxRuntime.jsx("span",{style:{color:"#71717a"},children:a.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:14,height:14,className:"shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",style:{color:"#71717a"}})]})}function mo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function y2({eventSlug:e,source:t,chain:r,walletAddress:n,onSimilarEventClick:o,onSimilarEventHover:i,onBack:a,renderActivitySection:s,onInsufficientBalance:l,onSetupRequired:u,slippageBps:p}){let{t:c}=i18n.useTranslation(),{isDesktop:f}=ui.useScreen(),{onOpen:d}=uiScaffold.useAsyncModal(on),{onOpen:m}=uiScaffold.useAsyncModal(Zo),{data:g,isLoading:v}=reactPredict.useEvent({slug:e,source:t}),h=react.useMemo(()=>{let M=[...g?.markets||[]],C=M.filter(F=>F.status==="open").sort((F,U)=>mo(U)-mo(F)),_=M.filter(F=>F.status!=="open").sort((F,U)=>mo(U)-mo(F));return [...C,..._]},[g?.markets]),[x,k]=react.useState(null),S=react.useCallback((M,C,_)=>{k(F=>({market:M,outcome:C,side:_,version:(F?.version??0)+1})),!f&&g&&(_==="sell"?m({params:{event:g,market:M,initialOutcome:C,chain:r,slippageBps:p,onSetupRequired:u}}):d({params:{event:g,market:M,initialOutcome:C,chain:r,slippageBps:p,onInsufficientBalance:l}}));},[f,g,r,p,d,m,l,u]),b=x?.market??h[0];if(v){let M=!!a;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(fn,{showBack:M})}),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(ba,{})})})]}):jsxRuntime.jsx(fn,{showBack:M})}let y=x?`${x.market.slug}-${x.version}`:b?.slug??"default",N=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:[a&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:a,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:c("common.back")})}),jsxRuntime.jsx(ja,{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:[b&&(N?jsxRuntime.jsx(no,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:p,onSetupRequired:u},y):jsxRuntime.jsx(qn,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:p,onInsufficientBalance:l},y)),g&&jsxRuntime.jsx(Qa,{eventSlug:e,source:g.source,onEventClick:o,onEventHover:i})]})]}),g&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:s?s({event:g,walletAddress:n}):jsxRuntime.jsx(ga,{event:g,walletAddress:n})}),jsxRuntime.jsx(Yn,{}),jsxRuntime.jsx(pa,{}),jsxRuntime.jsx(Xs,{})]})}function Ja(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function gg(e){switch(e){case ce.ONE_DAY:return {interval:"15m",limit:96};case ce.ONE_WEEK:return {interval:"1h",limit:168};case ce.ONE_MONTH:return {interval:"4h",limit:180};case ce.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var M2=e=>{let{candlestickMarketSlugs:t,chartRange:r=Hn,source:n}=e,o=reactPredict.usePredictClient(),i=react.useMemo(()=>gg(r),[r]),{data:a,isLoading:s,error:l}=reactPredict.useEvent({slug:e.eventSlug,source:n}),u=react.useMemo(()=>{if(!a?.markets)return [];let m=new Set,g=a.markets.filter(h=>m.has(h.slug)?false:(m.add(h.slug),true));return (t&&t.length>0?t.slice(0,4).map(h=>g.find(x=>x.slug===h)).filter(h=>h!==void 0):[...g].sort((h,x)=>Ja(x)-Ja(h)).slice(0,4)).map(h=>h.slug)},[t,a?.markets]),p=reactQuery.useQueries({queries:u.map(m=>({queryKey:reactPredict.candlesticksQueryKey(m,i),queryFn:()=>o.listCandlesticks(m,i),enabled:u.length>0}))}),c=p.some(m=>m.isLoading),f=react.useMemo(()=>{let m=new Map;return u.forEach((g,v)=>{let h=p[v]?.error;h&&m.set(g,h);}),m},[u,p]),d=react.useMemo(()=>{let m=new Map;return u.forEach((g,v)=>{let h=p[v]?.data;h&&m.set(g,h);}),m},[u,p]);return {event:a,isEventLoading:s,eventError:l,candlestickParams:i,candlesticks:d,isCandlesticksLoading:c,candlestickErrors:f}};function mi({comment:e,anonymousLabel:t,isReply:r=false}){let{profile:n}=e,o=n.name||n.pseudonym||t,i=react.useMemo(()=>xg(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(hg,{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(vg,{className:"size-3.5"}),jsxRuntime.jsx("span",{className:"text-xs tabular-nums",children:e.reaction_count})]})]})]})}function hg({src:e,name:t,className:r}){let n=t.trim().charAt(0).toUpperCase()||"?",o=react.useMemo(()=>bg(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 vg({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 bg(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 xg(e){let t=new Date(e).getTime();if(Number.isNaN(t))return "";let r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<60)return "now";let n=Math.floor(r/60);if(n<60)return `${n}m`;let o=Math.floor(n/60);if(o<24)return `${o}h`;let i=Math.floor(o/24);if(i<7)return `${i}d`;let a=Math.floor(i/7);return a<5?`${a}w`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Eg={latest:{order:"createdAt",ascending:false},oldest:{order:"createdAt",ascending:true},mostLiked:{order:"reactionCount",ascending:false}},tl={latest:"predict.comments.sortLatest",oldest:"predict.comments.sortOldest",mostLiked:"predict.comments.sortMostLiked"},Lg=["latest","oldest","mostLiked"],Rg=600,_g=112;function Ig({slug:e,source:t,limit:r=20,height:n,className:o}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState("latest"),[l,u]=react.useState(false),p=Eg[a],{data:c,isLoading:f,isFetchingNextPage:d,hasNextPage:m,fetchNextPage:g}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:p.order,ascending:p.ascending,holders_only:l}),v=react.useMemo(()=>c?.pages?.flatMap(_=>_.items)??[],[c?.pages]),h=react.useRef(null),{height:x}=hooks.useResizeObserver({ref:h}),k=n??(x||Rg),S=reactWindow.useDynamicRowHeight({defaultRowHeight:_g,key:`${e}:${t}:${a}:${l}`}),b=v.length,y=b+(m?1:0),N=react.useCallback(_=>_<b,[b]),M=react.useCallback(async()=>{m&&!d&&await g();},[m,d,g]),C=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:N,loadMoreRows:M,rowCount:y,threshold:5});return jsxRuntime.jsxs("div",{className:ui.cn("flex h-full w-full flex-col",o),children:[jsxRuntime.jsx(Ag,{sort:a,onSortChange:s,holdersOnly:l,onHoldersOnlyChange:u}),jsxRuntime.jsx("div",{className:"min-h-0 flex-auto overflow-hidden",ref:h,children:f?jsxRuntime.jsx(Dg,{}):v.length===0?jsxRuntime.jsx(Fg,{message:i("predict.comments.empty")}):jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:k},onRowsRendered:C,rowComponent:Og,rowCount:y,rowHeight:S,rowProps:{comments:v,itemCount:b,anonymousLabel:i("predict.comments.anonymous")},overscanCount:4})})]})}function Og({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(mi,{comment:i,anonymousLabel:o,isReply:!!i.parent_comment_id})}):null}function Ag({sort:e,onSortChange:t,holdersOnly:r,onHoldersOnlyChange:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState(false),s=react.useRef(null);return react.useEffect(()=>{if(!i)return;let l=p=>{s.current&&!s.current.contains(p.target)&&a(false);},u=p=>{p.key==="Escape"&&a(false);};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u);}},[i]),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxRuntime.jsxs("div",{ref:s,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(l=>!l),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(Bg,{className:"size-3.5 text-neutral"}),jsxRuntime.jsx("span",{children:o(tl[e])}),jsxRuntime.jsx(Hg,{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:Lg.map(l=>{let u=l===e;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(l),a(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(tl[l])}),u&&jsxRuntime.jsx(rl,{className:"size-4 text-primary"})]},l)})})]}),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(rl,{className:"size-3 text-background"})}),o("predict.comments.holdersOnly")]})]})}function Dg(){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 Fg({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 Bg({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 Hg({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 rl({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 Ug=10,$g=utils.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function bo(){let[e,t]=jotai.useAtom($g),r=react.useCallback(o=>{let i=o.trim();i&&t(a=>{let s=a.filter(l=>l!==i);return [i,...s].slice(0,Ug)});},[t]),n=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:n}}function ll({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 cl({onSelect:e,className:t}){let{histories:r,clearHistories:n}=bo();return jsxRuntime.jsx(ll,{className:ui.cn(t),histories:r,onSelect:e,onClear:n})}function dl({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:a=>{a.preventDefault(),n?.();},children:"Esc"})})})}function c0(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function ul({event:e,href:t,LinkComponent:r,onSelect:n,onHover:o,className:i}){let{t:a}=i18n.useTranslation(),s=e.tags?.[0],l=Ut(e.source),u=react.useMemo(()=>c0(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: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," ",a("predict.event.volume")]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral-500",children:s.label})]})]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function pl({keyword:e="",limit:t,source:r}){let{data:n,isLoading:o,isFetchingNextPage:i,hasNextPage:a,fetchNextPage:s}=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:a??false,fetchNextPage:s}}var x0=64;function hl({onSelect:e,getEventHref:t,LinkComponent:r,onHover:n,className:o,...i}){let{events:a,isLoading:s,isFetchingNextPage:l,hasNextPage:u,fetchNextPage:p}=pl(i),c=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:c}),d=react.useCallback(h=>h<a.length,[a]),m=react.useCallback(async()=>{u&&!l&&await p();},[u,l,p]),g=react.useMemo(()=>u?a.length+1:a.length,[a,u]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:m,rowCount:g,threshold:5});return s?jsxRuntime.jsx(k0,{className:o}):a.length===0?jsxRuntime.jsx(S0,{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:c,children:jsxRuntime.jsx(reactWindow.List,{className:"no-scrollbar",style:{height:f},onRowsRendered:v,rowComponent:y0,rowCount:g,rowHeight:x0,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:n},overscanCount:5})})})}function y0({index:e,style:t,events:r,onSelect:n,getEventHref:o,LinkComponent:i,onHover:a}){let s=r[e];return s?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ul,{event:s,href:o?.(s),LinkComponent:i,onSelect:n,onHover:a})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function k0({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 S0({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 yl({onKeywordChange:e}){let[t,r]=react.useState(""),[n,o]=react.useState(""),{addHistory:i}=bo(),a=hooks.useCallbackRef(e),s=hooks.useCallbackRef(i),l=react.useMemo(()=>utils$1.debounce(f=>{o(f),a(f),f&&s(f);},500),[a,s]),u=react.useCallback(f=>{r(f),l(f);},[l]),p=react.useCallback(f=>{l.cancel(),r(f),o(f),a(f),f&&s(f);},[l,a,s]),c=react.useCallback(()=>p(""),[p]);return {text:t,keyword:n,setText:u,setKeyword:p,clearKeyword:c}}function kl({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:a}){let{text:s,keyword:l,setText:u,setKeyword:p,clearKeyword:c}=yl({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(dl,{value:s,onValueChange:u,onClear:c,onEscape:i}),!l&&jsxRuntime.jsx(cl,{onSelect:p}),jsxRuntime.jsx(hl,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:a})]})}var bi="predict-search";function yS({id:e=bi}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(A0,{...t})})}function A0({params:e,isOpen:t,onOpenChange:r,onResult:n}){let{t:o}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),a=react.useCallback(l=>{n(l);},[n]),s=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(kl,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:s})})]})})}function ES({onSelectEvent:e,modalParams:t,className:r}){let{t:n}=i18n.useTranslation(),{isDesktop:o}=ui.useScreen(),{onOpen:i,onClose:a}=uiScaffold.useAsyncModal(bi),s=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let p=await i({params:t});p&&s(p);}),u=hooks.useCallbackRef(()=>{a();});return react.useEffect(()=>{let p=c=>{let f=document.activeElement,d=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");c.key==="/"&&!d&&(c.preventDefault(),l()),c.key==="Escape"&&(c.preventDefault(),u());};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p);}},[l,u]),o?jsxRuntime.jsx(ui.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:n("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 yi=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],_l=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],El={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Ll={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function $0(e,t){if(!e)return "$5K+";let r=_l.find(n=>n.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Il({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:n,minVolume:o,onMinVolumeChange:i,onRefresh:a}){let{t:s}=i18n.useTranslation(),[l,u]=react.useState(false),[p,c]=react.useState(false),[f,d]=react.useState(false),[m,g]=react.useState(false),v=react.useRef(null),h=react.useRef(null),x=yi.find(b=>b.value===e)??yi[0],k=react.useCallback(b=>{v.current&&!v.current.contains(b.target)&&u(false),h.current&&!h.current.contains(b.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)),[k]);let S=react.useCallback(()=>{a?.(),g(true),setTimeout(()=>g(false),700);},[a]);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:v,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:El,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(b=>!b),d(false);},children:[jsxRuntime.jsx($0,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(x.labelKey)}),jsxRuntime.jsx(Rl,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Ll,width:224,padding:4},children:yi.map(b=>{let y=e===b.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===b.value?n(!r):t(b.value),u(false);},children:[jsxRuntime.jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsxRuntime.jsx(K0,{type:b.icon})}),jsxRuntime.jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500},children:s(b.labelKey)}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:s(b.descKey)})]}),y&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]}),i&&jsxRuntime.jsxs("div",{ref:h,style:{position:"relative"},children:[jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:El,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{d(b=>!b),u(false);},children:[jsxRuntime.jsx(V0,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:U0(o,s)}),jsxRuntime.jsx(j0,{onMouseEnter:()=>c(true),onMouseLeave:()=>c(false)}),jsxRuntime.jsx(Rl,{open:p})]}),f&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxRuntime.jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxRuntime.jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),s("predict.matches.filter.liquidityFilter")]}),jsxRuntime.jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:s("predict.matches.filter.tooltipDesc")}),jsxRuntime.jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:s("predict.matches.filter.tooltipNote")})]})]})]}),p&&jsxRuntime.jsxs("div",{style:{...Ll,right:0,width:176},children:[jsxRuntime.jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:s("predict.matches.filter.minVolumeEach")})}),jsxRuntime.jsx("div",{style:{padding:4},children:_l.map(b=>{let y=b.value===0?!o:o===b.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(b.value===0?void 0:b.value),d(false);},children:[jsxRuntime.jsx("span",{children:b.labelKey?s(b.labelKey):b.label}),y&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]})]}),a&&jsxRuntime.jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)",b.currentTarget.style.color="#fff";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)",b.currentTarget.style.color="#a1a1aa";},onClick:S,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 $0(){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 K0({type:e}){let t={width:16,height:16},r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};return e==="trending-up"?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 V0(){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 j0({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 Rl({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 Q0(e){return utils$1.formatAmountInUsd(e)}var X0=[{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:Q0,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Al({stats:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
82
+ `}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:v,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:El,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(b=>!b),c(false);},children:[jsxRuntime.jsx(K0,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(x.labelKey)}),jsxRuntime.jsx(Rl,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Ll,width:224,padding:4},children:yi.map(b=>{let y=e===b.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===b.value?n(!r):t(b.value),u(false);},children:[jsxRuntime.jsx("div",{style:{color:y?"#c7ff2e":"#71717a"},children:jsxRuntime.jsx(V0,{type:b.icon})}),jsxRuntime.jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsxRuntime.jsx("div",{style:{fontWeight:500},children:s(b.labelKey)}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:s(b.descKey)})]}),y&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]}),i&&jsxRuntime.jsxs("div",{ref:h,style:{position:"relative"},children:[jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",className:"match-btn",style:El,onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(b=>!b),u(false);},children:[jsxRuntime.jsx(j0,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:$0(o,s)}),jsxRuntime.jsx(G0,{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false)}),jsxRuntime.jsx(Rl,{open:p})]}),f&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxRuntime.jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxRuntime.jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),s("predict.matches.filter.liquidityFilter")]}),jsxRuntime.jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:s("predict.matches.filter.tooltipDesc")}),jsxRuntime.jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:s("predict.matches.filter.tooltipNote")})]})]})]}),p&&jsxRuntime.jsxs("div",{style:{...Ll,right:0,width:176},children:[jsxRuntime.jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:s("predict.matches.filter.minVolumeEach")})}),jsxRuntime.jsx("div",{style:{padding:4},children:_l.map(b=>{let y=b.value===0?!o:o===b.value;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:y?"rgba(199,255,46,0.08)":"transparent",color:y?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:N=>{y||(N.currentTarget.style.background="rgba(39,39,42,0.5)",N.currentTarget.style.color="#fff");},onMouseLeave:N=>{y||(N.currentTarget.style.background="transparent",N.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(b.value===0?void 0:b.value),c(false);},children:[jsxRuntime.jsx("span",{children:b.labelKey?s(b.labelKey):b.label}),y&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},b.value)})})]})]}),a&&jsxRuntime.jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:b=>{b.currentTarget.style.background="rgba(39,39,42,1)",b.currentTarget.style.color="#fff";},onMouseLeave:b=>{b.currentTarget.style.background="rgba(39,39,42,0.6)",b.currentTarget.style.color="#a1a1aa";},onClick:S,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 K0(){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 V0({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 j0(){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 G0({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 Rl({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 X0(e){return utils$1.formatAmountInUsd(e)}var J0=[{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:X0,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function Al({stats:e}){let{t}=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,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:X0.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 ki(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function eh(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Hl={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},th={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},Dl={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function rh(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var nh={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},oh={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},ih={text:"#9ca3af",icon:"#9ca3af"};function sh(e){return oh[e]??ih}var ah=`
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:J0.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 ki(e){return e==null?"-":utils$1.formatAmountInUsd(e)}function th(e){return e==null?"narrow":e>=5?"wide":e>=3?"moderate":"narrow"}var Hl={wide:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},moderate:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},narrow:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},rh={wide:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},moderate:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},narrow:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},Dl={liquid_gap:{dot:"#17c964",label:"predict.matches.signalLiquidGap"},active_gap:{dot:"#c7ff2e",label:"predict.matches.signalActiveGap"},stale_gap:{dot:"#f5a524",label:"predict.matches.signalStaleGap"},stale_data:{dot:"#71717a",label:"predict.matches.signalStaleData"}};function nh(e){return e==null?null:e<120?"fresh":e<300?"aging":"stale"}var oh={fresh:"#17c964",aging:"#f5a524",stale:"#71717a"},ih={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},sh={text:"#9ca3af",icon:"#9ca3af"};function ah(e){return ih[e]??sh}var lh=`
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 lh({tier:e}){let t=Hl[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 ch(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function zl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:a,LinkComponent:s}){let{t:l}=i18n.useTranslation(),u=ch(e);if(!u)return null;let[p,d]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=eh(f),m=Hl[c],g=p.best_price!=null&&d.best_price!=null?p.best_price<=d.best_price?p.source:d.source:null,v=p.event_title||d.event_title,h=e.signal_tag??"stale_data",x=Dl[h]??Dl.stale_data,k=r?.(e),S=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ah}),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(lh,{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(Fl,{leg:p,isCheaper:g===p.source,externalUrlFallback:a?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:s}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(Fl,{leg:d,isCheaper:g===d.source,externalUrlFallback:a?.(e,d.source),internalHref:o?.(e,d),onSelect:n?()=>n(e,d):void 0,LinkComponent:s})]})]}),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"})]}),ki(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"})}),ki(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"})]}),dh(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)]})]})]}),b={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:k||t?"pointer":void 0},y=M=>{let C=M.currentTarget,_=th[c];C.style.borderColor=_.border,C.style.boxShadow=_.shadow,i?.(e);},N=M=>{let C=M.currentTarget;C.style.borderColor="rgba(39,39,42,0.6)",C.style.boxShadow="none";};return k&&s?jsxRuntime.jsx(s,{href:k,className:"group match-card",children:jsxRuntime.jsx("div",{style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),children:S})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),onKeyDown:M=>{t&&(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),t(e));},children:S})}function dh(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Fl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:a}=i18n.useTranslation(),s=Ut(e.source),l=sh(e.source),u=e.best_price,p=e.outcomes?.[0]?.label??null,d=e.external_url??r,f=rh(e.age_seconds),c=h=>{h.stopPropagation();},m=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:m?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsxRuntime.jsx("span",{style:{width:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[s.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:s.label}),f&&jsxRuntime.jsx("span",{title:e.age_seconds!=null?a("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:nh[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:[ki(e.vol_24h_usd)," ",a("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:a("predict.matches.centsYes")})]}),d?jsxRuntime.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer","aria-label":a("predict.matches.viewOn",{platform:s.label}),title:a("predict.matches.viewOn",{platform:s.label}),onClick:h=>h.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:h=>{h.currentTarget.style.color="#d4d4d8",h.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:h=>{h.currentTarget.style.color="#71717a",h.currentTarget.style.background="transparent";},children: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:h=>{c(h),o?.();},children:jsxRuntime.jsx("div",{style:g,children:v})}):m?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:g,onClick:h=>{c(h),o?.();},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),c(h),o?.());},children:v}):jsxRuntime.jsx("div",{style:g,children:v})}var Vl=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onSelect:u,onHover:p,getMarketHref:d,LinkComponent:f,onStatsChange:c},m){let{t:g}=i18n.useTranslation(),{data:v,hasNextPage:h,fetchNextPage:x,isFetchingNextPage:k,isLoading:S,isPlaceholderData:b,refetch:y}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[N,M]=react.useState(0),[C,_]=react.useState(false);C&&!b?(_(false),M(te=>te+1)):b&&!C&&_(true),react.useImperativeHandle(m,()=>({refetch:()=>{y();}}),[y]);let F=react.useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),U=v?.pages[0]?.total,Q=react.useMemo(()=>{let te=0,P=0,T=0;for(let z of F){let J=z.spread??0;J>te&&(te=J),J>=.03&&T++,z.combined_volume!=null&&(P+=z.combined_volume);}return {activePairs:U??F.length,maxSpread:te,highSpreadCount:T,totalVolume:P}},[F,U]);react.useEffect(()=>{Q.activePairs>0&&c?.(Q);},[Q,c]);let B=react.useRef(null),Y=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let te=B.current;if(!te)return;let P=new IntersectionObserver(T=>{T[0]?.isIntersecting&&h&&!k&&x();},{rootMargin:"200px"});return P.observe(te),()=>P.disconnect()},[h,k,x]),react.useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),S)return jsxRuntime.jsx(bh,{});if(F.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=!h&&F.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
127
+ `;function ch({tier:e}){let t=Hl[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 dh(e){if(Array.isArray(e.legs)&&e.legs.length===2)return [e.legs[0],e.legs[1]];let t=(r,n,o)=>({source:r,event_title:n,event_slug:o?.event_slug??"",market_id:o?.id??0,market_slug:o?.slug??"",question:o?.question??"",status:o?.status??"open",outcomes:o?.outcomes,best_price:o?.outcomes?.[0]?.best_ask??o?.outcomes?.[0]?.price??void 0,vol_24h_usd:o?.volume_24h??void 0});return !e.market_a||!e.market_b?null:[t(e.source_a,e.event_a_title??"",e.market_a),t(e.source_b,e.event_b_title??"",e.market_b)]}function zl({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:a,LinkComponent:s}){let{t:l}=i18n.useTranslation(),u=dh(e);if(!u)return null;let[p,c]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=th(f),m=Hl[d],g=p.best_price!=null&&c.best_price!=null?p.best_price<=c.best_price?p.source:c.source:null,v=p.event_title||c.event_title,h=e.signal_tag??"stale_data",x=Dl[h]??Dl.stale_data,k=r?.(e),S=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:lh}),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(ch,{tier:d})]}),jsxRuntime.jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsxRuntime.jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",margin:"0 0 12px"},children:v}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsxRuntime.jsx(Fl,{leg:p,isCheaper:g===p.source,externalUrlFallback:a?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:s}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(Fl,{leg:c,isCheaper:g===c.source,externalUrlFallback:a?.(e,c.source),internalHref:o?.(e,c),onSelect:n?()=>n(e,c):void 0,LinkComponent:s})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),ki(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"})}),ki(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"})]}),uh(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)]})]})]}),b={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:k||t?"pointer":void 0},y=M=>{let C=M.currentTarget,_=rh[d];C.style.borderColor=_.border,C.style.boxShadow=_.shadow,i?.(e);},N=M=>{let C=M.currentTarget;C.style.borderColor="rgba(39,39,42,0.6)",C.style.boxShadow="none";};return k&&s?jsxRuntime.jsx(s,{href:k,className:"group match-card",children:jsxRuntime.jsx("div",{style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),children:S})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),onKeyDown:M=>{t&&(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),t(e));},children:S})}function uh(e,t){if(t<60)return e("predict.matches.ageJustNow");if(t<3600){let n=Math.floor(t/60);return e("predict.matches.ageMinutes",{count:n})}let r=Math.floor(t/3600);return e("predict.matches.ageHours",{count:r})}function Fl({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:a}=i18n.useTranslation(),s=Ut(e.source),l=ah(e.source),u=e.best_price,p=e.outcomes?.[0]?.label??null,c=e.external_url??r,f=nh(e.age_seconds),d=h=>{h.stopPropagation();},m=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:m?"pointer":void 0,color:"inherit",textDecoration:"none"},v=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsxRuntime.jsx("span",{style:{width:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[s.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:s.label}),f&&jsxRuntime.jsx("span",{title:e.age_seconds!=null?a("predict.matches.updatedAgo",{seconds:e.age_seconds}):void 0,style:{width:6,height:6,borderRadius:"50%",background:oh[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:[ki(e.vol_24h_usd)," ",a("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:a("predict.matches.centsYes")})]}),c?jsxRuntime.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer","aria-label":a("predict.matches.viewOn",{platform:s.label}),title:a("predict.matches.viewOn",{platform:s.label}),onClick:h=>h.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:h=>{h.currentTarget.style.color="#d4d4d8",h.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:h=>{h.currentTarget.style.color="#71717a",h.currentTarget.style.background="transparent";},children: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:h=>{d(h),o?.();},children:jsxRuntime.jsx("div",{style:g,children:v})}):m?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:g,onClick:h=>{d(h),o?.();},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),d(h),o?.());},children:v}):jsxRuntime.jsx("div",{style:g,children:v})}var Vl=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onSelect:u,onHover:p,getMarketHref:c,LinkComponent:f,onStatsChange:d},m){let{t:g}=i18n.useTranslation(),{data:v,hasNextPage:h,fetchNextPage:x,isFetchingNextPage:k,isLoading:S,isPlaceholderData:b,refetch:y}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[N,M]=react.useState(0),[C,_]=react.useState(false);C&&!b?(_(false),M(te=>te+1)):b&&!C&&_(true),react.useImperativeHandle(m,()=>({refetch:()=>{y();}}),[y]);let F=react.useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),U=v?.pages[0]?.total,Q=react.useMemo(()=>{let te=0,P=0,T=0;for(let z of F){let J=z.spread??0;J>te&&(te=J),J>=.03&&T++,z.combined_volume!=null&&(P+=z.combined_volume);}return {activePairs:U??F.length,maxSpread:te,highSpreadCount:T,totalVolume:P}},[F,U]);react.useEffect(()=>{Q.activePairs>0&&d?.(Q);},[Q,d]);let B=react.useRef(null),Y=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let te=B.current;if(!te)return;let P=new IntersectionObserver(T=>{T[0]?.isIntersecting&&h&&!k&&x();},{rootMargin:"200px"});return P.observe(te),()=>P.disconnect()},[h,k,x]),react.useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),S)return jsxRuntime.jsx(xh,{});if(F.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=!h&&F.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((P,T)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${T*35}ms both`},children:jsxRuntime.jsx(zl,{match:P,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onHover:p,onSelect:u,getMarketHref:d,LinkComponent:f})},`${N}-${P.match_id}-${P.source_a}-${P.market_a?.slug??T}`)))}),jsxRuntime.jsxs("div",{ref:B,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)}}"}),k&&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(vh,{onScrollToTop:Y})]})});function vh({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 bh(){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(xh,{index:t},t))})]})}function xh({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return 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 Nh={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Ch(){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 Mh({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(Ch,{})]})]})]})]})}function fw({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,bgImageSrc:l}){let{t:u}=i18n.useTranslation(),[p,d]=react.useState("spread"),[f,c]=react.useState(false),[m,g]=react.useState(void 0),[v,h]=react.useState(),x=react.useRef(null),k=react.useCallback(N=>{d(N);},[]),S=react.useCallback(N=>{c(N);},[]),b=react.useCallback(N=>{react.startTransition(()=>{h(N);});},[]),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:v?.pages.map(te=>te.items?.map((P,T)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${T*35}ms both`},children:jsxRuntime.jsx(zl,{match:P,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onHover:p,onSelect:u,getMarketHref:c,LinkComponent:f})},`${N}-${P.match_id}-${P.source_a}-${P.market_a?.slug??T}`)))}),jsxRuntime.jsxs("div",{ref:B,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)}}"}),k&&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(bh,{onScrollToTop:Y})]})});function bh({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 xh(){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(yh,{index:t},t))})]})}function yh({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 Ch={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 Th({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 hw({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,bgImageSrc:l}){let{t:u}=i18n.useTranslation(),[p,c]=react.useState("spread"),[f,d]=react.useState(false),[m,g]=react.useState(void 0),[v,h]=react.useState(),x=react.useRef(null),k=react.useCallback(N=>{c(N);},[]),S=react.useCallback(N=>{d(N);},[]),b=react.useCallback(N=>{react.startTransition(()=>{h(N);});},[]),y=react.useCallback(()=>{x.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(Al,{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(Nh[p])}),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(Il,{sortBy:p,onSortChange:k,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(Vl,{ref:x,sortBy:p,sortAsc:f,minVolume:m,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,onStatsChange:b})]}),jsxRuntime.jsx(Mh,{stats:v})]})}function wi(e){return e==null?"-":utils$1.formatAmountInUsd(e)}var Lh={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},Rh={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function _h(e){return Lh[e]??Rh}function Ih(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let n of e.matched_markets){let o=n.spread??0;o>r&&(r=o,t=n);}return t}function Oh(e,t){let r=e.entries.find(s=>s.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(s=>s.source===(t?.source_b??e.entries[1]?.source)),o=s=>{if(!s?.outcomes?.[0])return {name:null,price:null};let l=s.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=o(t?.market_a),a=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:n?.event?.volume??null,event:n?.event}]}function kw({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=i18n.useTranslation(),i=react.useMemo(()=>Ih(e),[e]),a=e.max_spread!=null?e.max_spread*100:null,[s,l]=react.useMemo(()=>Oh(e,i),[e,i]),u=a!=null&&a>=3;s.yesPrice!=null&&l.yesPrice!=null?s.source==="kalshi"?s.yesPrice>l.yesPrice:l.yesPrice>s.yesPrice:false;let d=s.yesPrice!=null&&l.yesPrice!=null?s.yesPrice<=l.yesPrice?s:l:null,f=d?Ut(d.source):null,c=u?"amber":"violet";return 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:[a!=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)":a>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":a>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":a>=2?"#a684ff":"#9ca3af"},children:[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"})}),a.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(ql,{data:s,isCheaper:d===s,onSelect:t,getEventHref:r,LinkComponent:n}),jsxRuntime.jsx(ql,{data:l,isCheaper:d===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),d&&f&&a!=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:()=>d.event&&t?.(d.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:o("predict.matches.buyEdge",{platform:d.source.charAt(0).toUpperCase()+d.source.slice(1),spread:a.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"})]}),wi(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),wi(e.combined_volume_24h)," ",o("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",o("predict.matches.match")]})]})]})}function ql({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=i18n.useTranslation(),a=Ut(e.source),s=_h(e.source),l=e.event?n?.(e.event):void 0,u=jsxRuntime.jsxs("div",{style:{borderRadius:14,border:`1px solid ${s.border}`,background:s.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=s.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[a.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:s.text,textTransform:"uppercase"},children:a.label}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsxRuntime.jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsxRuntime.jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?s.priceActiveColor:s.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxRuntime.jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[wi(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsxRuntime.jsx(o,{href:l,className:"block",children:u}):u}function Bh(e){return utils$1.formatAmountInUsd(e)}function Mw({matches:e,total:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>{let o=0,i=0,a=new Set;for(let s of e){s.max_spread!=null&&s.max_spread>o&&(o=s.max_spread),s.combined_volume!=null&&(i+=s.combined_volume);for(let l of s.entries)a.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:a.size}},[e,t]);return 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(ko,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsxRuntime.jsx(Pi,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.totalVolume"),value:Bh(n.totalVolume)}),jsxRuntime.jsx(Pi,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsxRuntime.jsx(Pi,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function ko({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 Pi(){return jsxRuntime.jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Xl(e){return `${(e*100).toFixed(1)}\xA2`}function Hh(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function Rw({spread:e,arbProfit:t,className:r}){if(e==null)return null;let n=t!=null&&t>0;return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-x-2",r),children:[jsxRuntime.jsx("span",{className:ui.cn("text-sm font-semibold",Hh(e)),children:Xl(e)}),n&&jsxRuntime.jsxs("span",{className:"text-xs text-green-500/80",children:["+",Xl(t)]})]})}var wn=10,Vh=64,tc=40,So=48;function rc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),[o,i]=react.useState(1),{data:a,isLoading:s,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:p}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:d,isLoading:f,fetchNextPage:c,hasNextPage:m,isFetchingNextPage:g}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=s||f,h=p||g,x=u||m,k=react.useMemo(()=>{let U=[];return a?.pages&&U.push(...a.pages.flatMap(Q=>Q.items)),d?.pages&&U.push(...d.pages.flatMap(Q=>Q.items)),U.sort((Q,B)=>(B.timestamp??0)-(Q.timestamp??0)),U},[a,d]),S=Math.max(1,Math.ceil(k.length/wn)+(x?1:0)),b=(o-1)*wn,y=k.slice(b,b+wn),N=react.useCallback(()=>{i(U=>Math.max(1,U-1));},[]),M=react.useCallback(async()=>{o*wn>=k.length&&x&&(u&&await l(),m&&await c()),i(Q=>Q+1);},[o,k.length,x,u,m,l,c]),C=o>1,_=o*wn<k.length||x;if(v)return jsxRuntime.jsx(Xh,{height:r});if(k.length===0&&!x)return jsxRuntime.jsx(Qh,{message:n("predict.profile.noHistory"),height:r});let F=r-tc-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:tc},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:F},children:[y.map((U,Q)=>jsxRuntime.jsx(jh,{trade:U},U.id??`${b+Q}`)),h&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:So},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!C,onClick:N,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:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(S,5)},(U,Q)=>{let B=Q+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>i(B),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",B===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:B},B)}),jsxRuntime.jsxs("button",{type:"button",disabled:!_,onClick:M,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",_?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-So},children:y.map((U,Q)=>jsxRuntime.jsx(Gh,{trade:U},U.id??`m-${b+Q}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:So},children:[jsxRuntime.jsx("button",{type:"button",disabled:!C,onClick:N,className:ui.cn("text-sm cursor-pointer",C?"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:!_,onClick:M,className:ui.cn("text-sm cursor-pointer",_?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function jh({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=r||n,l=s?"+":"-",u=s?"text-success":"text-foreground",p=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.outcome??"",c=ac(e.timestamp),m=oc(e),g=qh(e),v=Yh(e);return 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.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:c})]})]})]})}),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:a}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:sc(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:[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(ic,{})})})]})}function Gh({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=e.event?.title??e.market?.question??"\u2014",l=ac(e.timestamp),u=oc(e);return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsxRuntime.jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:s})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsxRuntime.jsx("span",{className:ui.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:a})]}),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:sc(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(ic,{})})]})]})}function nc(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function oc(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function qh(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function Yh(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function ic(){return 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 Qh({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Xh({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 sc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ac(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}var Pn=10,ov=64,cc=40,wo=48;function uc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),o=reactPredict.useCancelOrder(),[i,a]=react.useState(1),{data:s,isLoading:l,fetchNextPage:u,hasNextPage:p,isFetchingNextPage:d}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:c,fetchNextPage:m,hasNextPage:g,isFetchingNextPage:v}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||c,x=d||v,k=p||g,S=react.useMemo(()=>{let B=[],Y=new Set(["live","open","submitted","pending"]);return s?.pages&&B.push(...s.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),f?.pages&&B.push(...f.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),B},[s,f]),b=react.useCallback(B=>{o.mutate({source:B.source,id:B.id});},[o]),y=Math.max(1,Math.ceil(S.length/Pn)+(k?1:0)),N=(i-1)*Pn,M=S.slice(N,N+Pn),C=react.useCallback(()=>{a(B=>Math.max(1,B-1));},[]),_=react.useCallback(async()=>{i*Pn>=S.length&&k&&(p&&await u(),g&&await m()),a(Y=>Y+1);},[i,S.length,k,p,g,u,m]),F=i>1,U=i*Pn<S.length||k;if(h)return jsxRuntime.jsx(lv,{height:r});if(S.length===0&&!k)return jsxRuntime.jsx(av,{message:n("predict.profile.noOrders"),height:r});let Q=r-cc-wo;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:cc},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:Q},children:[M.map(B=>jsxRuntime.jsx(iv,{order:B,onCancel:b},B.id)),x&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsx(dc,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:F,canGoNext:U,onPrev:C,onNext:_,onPage:a,t:n}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-wo},children:M.map(B=>jsxRuntime.jsx(sv,{order:B,onCancel:b},B.id))}),jsxRuntime.jsx(dc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:F,canGoNext:U,onPrev:C,onNext:_,onPage:a,t:n,compact:true})]})}function iv({order:e,onCancel:t}){let{t:r}=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:ov},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?pc(o):"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function sv({order:e,onCancel:t}){let{t:r}=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?pc(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 dc({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:a,onPage:s,t:l,compact:u}){return u?jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:wo},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:a,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:wo},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 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,d)=>{let f=d+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>s(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:a,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:[l("predict.profile.next")," \u2192"]})]})}function av({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function lv({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 pc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Ei=10,pv=64,mc=40,Po=48;function fc({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState(1),l=react.useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsxRuntime.jsx(hv,{height:r});if(e.length===0)return jsxRuntime.jsx(gv,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/Ei)),p=(a-1)*Ei,d=e.slice(p,p+Ei),f=a>1,c=a<u,m=r-mc-Po;return 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:mc},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: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:d.map((g,v)=>jsxRuntime.jsx(mv,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??p+v}`))}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Po},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!f,onClick:()=>s(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 h=v+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>s(h),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",h===a?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:h},h)}),jsxRuntime.jsxs("button",{type:"button",disabled:!c,onClick:()=>s(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-Po},children:d.map((g,v)=>jsxRuntime.jsx(fv,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${p+v}`}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Po},children:[jsxRuntime.jsx("button",{type:"button",disabled:!f,onClick:()=>s(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:a}),jsxRuntime.jsx("button",{type:"button",disabled:!c,onClick:()=>s(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 mv({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.avg_price??0,s=e.current_price??0,l=e.current_value??e.size*s,u=e.size,p=o>0?"text-success":o<0?"text-danger":"text-foreground",d=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,m=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?vv(e.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:pv},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:n("predict.profile.contracts",{count:yr(e.size)})})]})}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*a).toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Li(a)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Li(s)}),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: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"}),n("predict.profile.close")]})})]})}function fv({position:e,onClose:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.current_price??0,s=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return 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(No,{label:n("predict.profile.totalSize"),value:yr(e.size)}),jsxRuntime.jsx(No,{label:n("predict.profile.markPrice"),value:Li(a)}),jsxRuntime.jsx(No,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:s}),jsxRuntime.jsx(No,{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 No({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 gv({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function hv({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 Li(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function vv(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}catch{return "\u2014"}}function hc({positions:e,trades:t,isLoading:r}){let{t:n}=i18n.useTranslation(),o=react.useMemo(()=>{let s=0,l=0;for(let c of e)s+=c.realized_pnl??0,l+=c.current_value??c.size*(c.current_price??0);let u=0,p=0,d=0;for(let c of t)u+=c.usd_size??0,c.type==="REDEEM"&&(d++,(c.usd_size??0)>0&&p++);let f=d>0?`${p} / ${d}`:"0 / 0";return {realizedPnl:s,positionsValue:l,volume:u,winRateStr:f}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",a=o.realizedPnl>0?"+":"";return 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:[a,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsxRuntime.jsx(_i,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsxRuntime.jsx(_i,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsxRuntime.jsx(_i,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function _i({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 Ii=600;function Nv({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState("positions"),s=!!(e||t),{data:l,isLoading:u}=reactPredict.usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:d}=reactPredict.usePositions({source:"polymarket",user:t??""}),f=react.useMemo(()=>{let N=[];return l?.positions&&N.push(...l.positions),p?.positions&&N.push(...p.positions),N},[l,p]),c=u||d,{data:m,isLoading:g}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:h}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),x=react.useMemo(()=>[...m?.pages?.flatMap(M=>M.items)??[],...v?.pages?.flatMap(M=>M.items)??[]],[m,v]),k=c||g||h,S=f.length,y=[{key:"positions",label:S>0?`${o("predict.profile.positionsTab")} (${S})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return s?jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsxRuntime.jsx(hc,{positions:f,trades:x,isLoading:k}),jsxRuntime.jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>a(N.key),className:ui.cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===N.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:N.label},N.key))}),jsxRuntime.jsxs("div",{className:"py-2",children:[i==="positions"&&jsxRuntime.jsx(fc,{positions:f,isLoading:c,listHeight:Ii,onClosePosition:r,onEventClick:n}),i==="orders"&&jsxRuntime.jsx(uc,{solanaAddress:e,evmAddress:t,listHeight:Ii}),i==="history"&&jsxRuntime.jsx(rc,{solanaAddress:e,evmAddress:t,listHeight:Ii})]})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function TP({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState(false),[l,u]=react.useState(null),[p,d]=react.useState(false),f=r||p,c=n||p,m=f?"done":a?"running":"pending",g=c?"done":f&&a?"running":"pending",v=f&&c,h=react.useCallback(async()=>{u(null),d(false),s(true);try{await o(),d(!0);}catch(b){u(b instanceof Error?b.message:String(b));}finally{s(false);}},[o]),x=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:m},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],k=()=>{v?t():h();},S=i(v?"predict.setup.done":"predict.setup.setupButton");return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:b=>{b||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.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((b,y)=>jsxRuntime.jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsxRuntime.jsx(Lv,{index:y+1,status:b.status}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-zinc-200",children:b.label}),jsxRuntime.jsx("span",{className:`text-[11px] leading-none ${b.status==="done"?"text-[#c7ff2e]":b.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:b.status==="done"?i("predict.setup.stepComplete"):b.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsxRuntime.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:b.desc})]})]},b.key))}),l&&jsxRuntime.jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsxRuntime.jsx("p",{className:"text-xs text-red-400",children:l})}),jsxRuntime.jsx("button",{type:"button",onClick:k,disabled:a,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a?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 Lv({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=qv;exports.CHART_RANGE_PERIOD=jv;exports.CHART_RANGE_SAMPLE_INTERVAL=Gv;exports.CandlestickPeriod=Bn;exports.CategoriesSkeleton=Dv;exports.CategoriesUI=Hi;exports.CategoriesWidget=$i;exports.ChartRange=ce;exports.CommentItemUI=mi;exports.DEFAULT_CHART_RANGE=Hn;exports.DEFAULT_FILTER_STATE=sn;exports.DEFAULT_PAGE_SIZE=rn;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Jv;exports.EventCommentsWidget=_g;exports.EventDetailPage=b2;exports.EventDetailSkeleton=fn;exports.EventDetailUI=Va;exports.EventDetailWidget=ja;exports.EventItem=Os;exports.EventMarketDepthChartUI=Na;exports.EventMarketDetailWidget=_a;exports.EventPriceChart=Da;exports.EventsFilterUI=ps;exports.EventsHero=jx;exports.EventsPage=Wx;exports.EventsPageSkeleton=mx;exports.EventsSkeleton=$o;exports.EventsToolbarUI=bs;exports.EventsUI=Hs;exports.EventsWidget=Ws;exports.KycModal=jn;exports.MAX_PRICE_HISTORY_MARKETS=Ao;exports.MatchGroupCard=kw;exports.MatchMarketCard=zl;exports.MatchesFilterBar=Il;exports.MatchesHero=Al;exports.MatchesPage=fw;exports.MatchesStatsBar=Mw;exports.MatchesWidget=Vl;exports.ORDER_MAX_PRICE=Xv;exports.ORDER_MIN_PRICE=Qv;exports.ORDER_MIN_QUANTITY=zn;exports.ORDER_MIN_USDC=Wn;exports.ORDER_PRICE_STEP=Yv;exports.POLYMARKET_BUILDER_TAKER_FEE_BPS=Kc;exports.POLYMARKET_SPORTS_TAKER_FEE_BPS=Vc;exports.PREDICT_REDEEM_MODAL_ID=kp;exports.PREDICT_SEARCH_MODAL_ID=bi;exports.PREDICT_SELL_MODAL_ID=Zo;exports.PREDICT_TRADE_MODAL_ID=on;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Zv;exports.PredictRedeemModal=Xs;exports.PredictSearchModal=bS;exports.PredictSellModal=pa;exports.PredictTradeModal=Yn;exports.PredictWalletProvider=zc;exports.PriceHistoryInterval=Br;exports.ProfilePage=Nv;exports.RedeemFormWidget=Ys;exports.SORT_PRESETS=vs;exports.STATIC_CATEGORIES=Io;exports.SearchEventsButton=MS;exports.SearchHistoryUI=ll;exports.SearchHistoryWidget=cl;exports.SearchInputUI=dl;exports.SearchResultItemUI=ul;exports.SearchResultListWidget=hl;exports.SearchWidget=kl;exports.SellFormUI=da;exports.SellFormWidget=no;exports.SetupModal=TP;exports.SimilarEventCard=eg;exports.SimilarEventsSection=Qa;exports.SourceBadge=G1;exports.SpreadIndicator=Rw;exports.TradeFormSkeleton=ba;exports.TradeFormUI=ds;exports.TradeFormWidget=qn;exports.UserActivitySection=ga;exports.computeMaxBuyAmount=qi;exports.countActiveFilters=Uo;exports.createTradeResultToast=zr;exports.estimatePolymarketBuyFee=Yi;exports.estimatePolymarketSellFee=Qi;exports.fireCelebration=Xi;exports.floorToDecimals=xe;exports.formatKMB=gn;exports.formatShares=yr;exports.getSourceMeta=Ut;exports.parsePolymarketError=Kn;exports.polymarketFeeFactor=$c;exports.resolveExpiration=Un;exports.resolvePolymarketDisplayFeeRateBps=Gi;exports.roundToTickSize=$n;exports.useEventDetail=N2;exports.useEventsInfinite=ks;exports.usePredictSearchHistory=bo;exports.usePredictWallet=xr;exports.useSearchResultListScript=pl;exports.useSearchScript=yl;exports.useSellForm=ta;exports.useTradeForm=ts;//# sourceMappingURL=index.js.map
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(Al,{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(Ch[p])}),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(Il,{sortBy:p,onSortChange:k,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(Vl,{ref:x,sortBy:p,sortAsc:f,minVolume:m,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,onStatsChange:b})]}),jsxRuntime.jsx(Th,{stats:v})]})}function wi(e){return e==null?"-":utils$1.formatAmountInUsd(e)}var Rh={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"}},_h={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 Ih(e){return Rh[e]??_h}function Oh(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 Ah(e,t){let r=e.entries.find(s=>s.source===(t?.source_a??e.entries[0]?.source)),n=e.entries.find(s=>s.source===(t?.source_b??e.entries[1]?.source)),o=s=>{if(!s?.outcomes?.[0])return {name:null,price:null};let l=s.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},i=o(t?.market_a),a=o(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??n?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:n?.event?.volume??null,event:n?.event}]}function ww({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:n}){let {t:o}=i18n.useTranslation(),i=react.useMemo(()=>Oh(e),[e]),a=e.max_spread!=null?e.max_spread*100:null,[s,l]=react.useMemo(()=>Ah(e,i),[e,i]),u=a!=null&&a>=3;s.yesPrice!=null&&l.yesPrice!=null?s.source==="kalshi"?s.yesPrice>l.yesPrice:l.yesPrice>s.yesPrice:false;let c=s.yesPrice!=null&&l.yesPrice!=null?s.yesPrice<=l.yesPrice?s:l:null,f=c?Ut(c.source):null,d=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:[a!=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)":a>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:u?"rgba(255,185,0,0.15)":a>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:u?"#ffb900":a>=2?"#a684ff":"#9ca3af"},children:[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"})}),a.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(ql,{data:s,isCheaper:c===s,onSelect:t,getEventHref:r,LinkComponent:n}),jsxRuntime.jsx(ql,{data:l,isCheaper:c===l,onSelect:t,getEventHref:r,LinkComponent:n})]}),c&&f&&a!=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 ${d==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:d==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>c.event&&t?.(c.event),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:d==="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:d==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:o("predict.matches.buyEdge",{platform:c.source.charAt(0).toUpperCase()+c.source.slice(1),spread:a.toFixed(1)})}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:d==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M5 12h14"}),jsxRuntime.jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsxRuntime.jsx("path",{d:"M18 17V9"}),jsxRuntime.jsx("path",{d:"M13 17V5"}),jsxRuntime.jsx("path",{d:"M8 17v-3"})]}),wi(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),wi(e.combined_volume_24h)," ",o("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",o("predict.matches.match")]})]})]})}function ql({data:e,isCheaper:t,onSelect:r,getEventHref:n,LinkComponent:o}){let{t:i}=i18n.useTranslation(),a=Ut(e.source),s=Ih(e.source),l=e.event?n?.(e.event):void 0,u=jsxRuntime.jsxs("div",{style:{borderRadius:14,border:`1px solid ${s.border}`,background:s.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=s.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[a.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:s.text,textTransform:"uppercase"},children:a.label}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsxRuntime.jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsxRuntime.jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?s.priceActiveColor:s.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxRuntime.jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[wi(e.volume)," ",i("predict.matches.volume")]})]});return l&&o?jsxRuntime.jsx(o,{href:l,className:"block",children:u}):u}function Hh(e){return utils$1.formatAmountInUsd(e)}function Ew({matches:e,total:t}){let{t:r}=i18n.useTranslation(),n=react.useMemo(()=>{let o=0,i=0,a=new Set;for(let s of e){s.max_spread!=null&&s.max_spread>o&&(o=s.max_spread),s.combined_volume!=null&&(i+=s.combined_volume);for(let l of s.entries)a.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:o,totalVolume:i,platformCount:a.size}},[e,t]);return 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(ko,{label:r("predict.matches.stats.matchedMarkets"),value:n.count.toLocaleString()}),jsxRuntime.jsx(Pi,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.totalVolume"),value:Hh(n.totalVolume)}),jsxRuntime.jsx(Pi,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsxRuntime.jsx(Pi,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.platforms"),value:String(n.platformCount)})]})}function ko({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 Pi(){return jsxRuntime.jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function Xl(e){return `${(e*100).toFixed(1)}\xA2`}function zh(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function Iw({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",zh(e)),children:Xl(e)}),n&&jsxRuntime.jsxs("span",{className:"text-xs text-green-500/80",children:["+",Xl(t)]})]})}var wn=10,jh=64,tc=40,So=48;function rc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),[o,i]=react.useState(1),{data:a,isLoading:s,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:p}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:f,fetchNextPage:d,hasNextPage:m,isFetchingNextPage:g}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=s||f,h=p||g,x=u||m,k=react.useMemo(()=>{let U=[];return a?.pages&&U.push(...a.pages.flatMap(Q=>Q.items)),c?.pages&&U.push(...c.pages.flatMap(Q=>Q.items)),U.sort((Q,B)=>(B.timestamp??0)-(Q.timestamp??0)),U},[a,c]),S=Math.max(1,Math.ceil(k.length/wn)+(x?1:0)),b=(o-1)*wn,y=k.slice(b,b+wn),N=react.useCallback(()=>{i(U=>Math.max(1,U-1));},[]),M=react.useCallback(async()=>{o*wn>=k.length&&x&&(u&&await l(),m&&await d()),i(Q=>Q+1);},[o,k.length,x,u,m,l,d]),C=o>1,_=o*wn<k.length||x;if(v)return jsxRuntime.jsx(Jh,{height:r});if(k.length===0&&!x)return jsxRuntime.jsx(Xh,{message:n("predict.profile.noHistory"),height:r});let F=r-tc-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:tc},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:F},children:[y.map((U,Q)=>jsxRuntime.jsx(Gh,{trade:U},U.id??`${b+Q}`)),h&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:So},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!C,onClick:N,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:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(S,5)},(U,Q)=>{let B=Q+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>i(B),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",B===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:B},B)}),jsxRuntime.jsxs("button",{type:"button",disabled:!_,onClick:M,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",_?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[n("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-So},children:y.map((U,Q)=>jsxRuntime.jsx(qh,{trade:U},U.id??`m-${b+Q}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:So},children:[jsxRuntime.jsx("button",{type:"button",disabled:!C,onClick:N,className:ui.cn("text-sm cursor-pointer",C?"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:!_,onClick:M,className:ui.cn("text-sm cursor-pointer",_?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Gh({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=r||n,l=s?"+":"-",u=s?"text-success":"text-foreground",p=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.outcome??"",d=ac(e.timestamp),m=oc(e),g=Yh(e),v=Qh(e);return jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:jh},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[c&&jsxRuntime.jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium text-sm",children:p}),jsxRuntime.jsxs("span",{className:"text-[11px] text-neutral",children:[f&&jsxRuntime.jsx("span",{className:"mr-1",children:f}),jsxRuntime.jsx("span",{children:d})]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:jsxRuntime.jsx("span",{className:ui.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:a}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:sc(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:[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(ic,{})})})]})}function qh({trade:e}){let{t}=i18n.useTranslation(),r=e.type==="REDEEM",n=e.side?.toUpperCase()==="BUY",o=e.price??0,i=e.usd_size??0,a=nc(e.type,t),s=e.event?.title??e.market?.question??"\u2014",l=ac(e.timestamp),u=oc(e);return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsxRuntime.jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:s})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:l})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsxRuntime.jsx("span",{className:ui.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:a})]}),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:sc(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(ic,{})})]})]})}function nc(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function oc(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function Yh(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 Qh(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let n=parseFloat(r);if(!Number.isNaN(n))return n}}return null}function ic(){return 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 Xh({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Jh({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 sc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function ac(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}var Pn=10,iv=64,cc=40,wo=48;function uc({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:n}=i18n.useTranslation(),o=reactPredict.useCancelOrder(),[i,a]=react.useState(1),{data:s,isLoading:l,fetchNextPage:u,hasNextPage:p,isFetchingNextPage:c}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:d,fetchNextPage:m,hasNextPage:g,isFetchingNextPage:v}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||d,x=c||v,k=p||g,S=react.useMemo(()=>{let B=[],Y=new Set(["live","open","submitted","pending"]);return s?.pages&&B.push(...s.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),f?.pages&&B.push(...f.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),B},[s,f]),b=react.useCallback(B=>{o.mutate({source:B.source,id:B.id});},[o]),y=Math.max(1,Math.ceil(S.length/Pn)+(k?1:0)),N=(i-1)*Pn,M=S.slice(N,N+Pn),C=react.useCallback(()=>{a(B=>Math.max(1,B-1));},[]),_=react.useCallback(async()=>{i*Pn>=S.length&&k&&(p&&await u(),g&&await m()),a(Y=>Y+1);},[i,S.length,k,p,g,u,m]),F=i>1,U=i*Pn<S.length||k;if(h)return jsxRuntime.jsx(cv,{height:r});if(S.length===0&&!k)return jsxRuntime.jsx(lv,{message:n("predict.profile.noOrders"),height:r});let Q=r-cc-wo;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:cc},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:Q},children:[M.map(B=>jsxRuntime.jsx(sv,{order:B,onCancel:b},B.id)),x&&jsxRuntime.jsx("div",{className:"flex justify-center items-center py-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})]}),jsxRuntime.jsx(dc,{className:"hidden lg:flex",currentPage:i,totalPages:y,canGoPrev:F,canGoNext:U,onPrev:C,onNext:_,onPage:a,t:n}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-wo},children:M.map(B=>jsxRuntime.jsx(av,{order:B,onCancel:b},B.id))}),jsxRuntime.jsx(dc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:F,canGoNext:U,onPrev:C,onNext:_,onPage:a,t:n,compact:true})]})}function sv({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:iv},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?pc(o):"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i>0?`$${i.toFixed(2)}`:"\u2014"})]})}function av({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?pc(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 dc({className:e,currentPage:t,totalPages:r,canGoPrev:n,canGoNext:o,onPrev:i,onNext:a,onPage:s,t:l,compact:u}){return u?jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-3 shrink-0",e),style:{height:wo},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:a,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:wo},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 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,c)=>{let f=c+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>s(f),className:ui.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:a,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:[l("predict.profile.next")," \u2192"]})]})}function lv({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function cv({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 pc(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var Ei=10,mv=64,mc=40,Po=48;function fc({positions:e,isLoading:t,listHeight:r,onClosePosition:n,onEventClick:o}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState(1),l=react.useCallback(()=>{for(let g of e)n?.(g);},[e,n]);if(t)return jsxRuntime.jsx(vv,{height:r});if(e.length===0)return jsxRuntime.jsx(hv,{message:i("predict.profile.noPositions"),height:r});let u=Math.max(1,Math.ceil(e.length/Ei)),p=(a-1)*Ei,c=e.slice(p,p+Ei),f=a>1,d=a<u,m=r-mc-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:mc},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: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:c.map((g,v)=>jsxRuntime.jsx(fv,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??p+v}`))}),jsxRuntime.jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Po},children:[jsxRuntime.jsxs("button",{type:"button",disabled:!f,onClick:()=>s(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 h=v+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>s(h),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",h===a?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:h},h)}),jsxRuntime.jsxs("button",{type:"button",disabled:!d,onClick:()=>s(g=>g+1),className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[i("predict.profile.next")," \u2192"]})]}),jsxRuntime.jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Po},children:c.map((g,v)=>jsxRuntime.jsx(gv,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${p+v}`}`))}),jsxRuntime.jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Po},children:[jsxRuntime.jsx("button",{type:"button",disabled:!f,onClick:()=>s(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:a}),jsxRuntime.jsx("button",{type:"button",disabled:!d,onClick:()=>s(g=>g+1),className:ui.cn("text-sm cursor-pointer",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function fv({position:e,onClosePosition:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.avg_price??0,s=e.current_price??0,l=e.current_value??e.size*s,u=e.size,p=o>0?"text-success":o<0?"text-danger":"text-foreground",c=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,m=e.side,g=e.market?.outcomes?.[0]?.label??"",v=e.market?.end_at?bv(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:mv},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[d&&jsxRuntime.jsx("img",{src:d,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium text-sm",children:f}),jsxRuntime.jsxs("span",{className:"text-[11px] text-neutral",children:[jsxRuntime.jsx("span",{className:ui.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:n("predict.profile.contracts",{count:yr(e.size)})})]})}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*a).toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Li(a)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Li(s)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",p),children:[jsxRuntime.jsxs("span",{children:[c,"$",Math.abs(o).toFixed(2)]}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",c,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"}),n("predict.profile.close")]})})]})}function gv({position:e,onClose:t,onEventClick:r}){let{t:n}=i18n.useTranslation(),o=e.pnl??0,i=e.pnl_percent??0,a=e.current_price??0,s=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return 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(No,{label:n("predict.profile.totalSize"),value:yr(e.size)}),jsxRuntime.jsx(No,{label:n("predict.profile.markPrice"),value:Li(a)}),jsxRuntime.jsx(No,{label:n("predict.profile.pnl"),value:`${l}$${Math.abs(o).toFixed(2)} (${l}${i.toFixed(1)}%)`,className:s}),jsxRuntime.jsx(No,{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 No({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 hv({message:e,height:t}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function vv({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 Li(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function bv(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),s=t.getTimezoneOffset(),l=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${l}${u})`}catch{return "\u2014"}}function hc({positions:e,trades:t,isLoading:r}){let{t:n}=i18n.useTranslation(),o=react.useMemo(()=>{let s=0,l=0;for(let d of e)s+=d.realized_pnl??0,l+=d.current_value??d.size*(d.current_price??0);let u=0,p=0,c=0;for(let d of t)u+=d.usd_size??0,d.type==="REDEEM"&&(c++,(d.usd_size??0)>0&&p++);let f=c>0?`${p} / ${c}`:"0 / 0";return {realizedPnl:s,positionsValue:l,volume:u,winRateStr:f}},[e,t]),i=o.realizedPnl>0?"text-success":o.realizedPnl<0?"text-danger":"text-foreground",a=o.realizedPnl>0?"+":"";return 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:[a,"$",Math.abs(o.realizedPnl).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsxRuntime.jsx(_i,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsxRuntime.jsx(_i,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsxRuntime.jsx(_i,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function _i({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 Ii=600;function Cv({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState("positions"),s=!!(e||t),{data:l,isLoading:u}=reactPredict.usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:c}=reactPredict.usePositions({source:"polymarket",user:t??""}),f=react.useMemo(()=>{let N=[];return l?.positions&&N.push(...l.positions),p?.positions&&N.push(...p.positions),N},[l,p]),d=u||c,{data:m,isLoading:g}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:v,isLoading:h}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),x=react.useMemo(()=>[...m?.pages?.flatMap(M=>M.items)??[],...v?.pages?.flatMap(M=>M.items)??[]],[m,v]),k=d||g||h,S=f.length,y=[{key:"positions",label:S>0?`${o("predict.profile.positionsTab")} (${S})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return s?jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsxRuntime.jsx(hc,{positions:f,trades:x,isLoading:k}),jsxRuntime.jsx("div",{className:"flex items-center gap-1 border-b border-border",children:y.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>a(N.key),className:ui.cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===N.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:N.label},N.key))}),jsxRuntime.jsxs("div",{className:"py-2",children:[i==="positions"&&jsxRuntime.jsx(fc,{positions:f,isLoading:d,listHeight:Ii,onClosePosition:r,onEventClick:n}),i==="orders"&&jsxRuntime.jsx(uc,{solanaAddress:e,evmAddress:t,listHeight:Ii}),i==="history"&&jsxRuntime.jsx(rc,{solanaAddress:e,evmAddress:t,listHeight:Ii})]})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:o("predict.profile.connectWallet")})}function LP({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:n,onDeployAndApprove:o}){let{t:i}=i18n.useTranslation(),[a,s]=react.useState(false),[l,u]=react.useState(null),[p,c]=react.useState(false),f=r||p,d=n||p,m=f?"done":a?"running":"pending",g=d?"done":f&&a?"running":"pending",v=f&&d,h=react.useCallback(async()=>{u(null),c(false),s(true);try{await o(),c(!0);}catch(b){u(b instanceof Error?b.message:String(b));}finally{s(false);}},[o]),x=[{key:"step1",label:i("predict.setup.step1"),desc:i("predict.setup.step1Desc"),status:m},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],k=()=>{v?t():h();},S=i(v?"predict.setup.done":"predict.setup.setupButton");return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:b=>{b||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.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((b,y)=>jsxRuntime.jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsxRuntime.jsx(Rv,{index:y+1,status:b.status}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-zinc-200",children:b.label}),jsxRuntime.jsx("span",{className:`text-[11px] leading-none ${b.status==="done"?"text-[#c7ff2e]":b.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:b.status==="done"?i("predict.setup.stepComplete"):b.status==="running"?i("predict.setup.stepRunning"):i("predict.setup.stepPending")})]}),jsxRuntime.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:b.desc})]})]},b.key))}),l&&jsxRuntime.jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsxRuntime.jsx("p",{className:"text-xs text-red-400",children:l})}),jsxRuntime.jsx("button",{type:"button",onClick:k,disabled:a,className:v?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a?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 Rv({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=Yv;exports.CHART_RANGE_PERIOD=Gv;exports.CHART_RANGE_SAMPLE_INTERVAL=qv;exports.CandlestickPeriod=Bn;exports.CategoriesSkeleton=Fv;exports.CategoriesUI=Hi;exports.CategoriesWidget=$i;exports.ChartRange=ce;exports.CommentItemUI=mi;exports.DEFAULT_CHART_RANGE=Hn;exports.DEFAULT_FILTER_STATE=sn;exports.DEFAULT_PAGE_SIZE=rn;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Zv;exports.EventCommentsWidget=Ig;exports.EventDetailPage=y2;exports.EventDetailSkeleton=fn;exports.EventDetailUI=Va;exports.EventDetailWidget=ja;exports.EventItem=Os;exports.EventMarketDepthChartUI=Na;exports.EventMarketDetailWidget=_a;exports.EventPriceChart=Da;exports.EventsFilterUI=ps;exports.EventsHero=qx;exports.EventsPage=$x;exports.EventsPageSkeleton=gx;exports.EventsSkeleton=$o;exports.EventsToolbarUI=bs;exports.EventsUI=Hs;exports.EventsWidget=Ws;exports.KycModal=jn;exports.MAX_PRICE_HISTORY_MARKETS=Ao;exports.MatchGroupCard=ww;exports.MatchMarketCard=zl;exports.MatchesFilterBar=Il;exports.MatchesHero=Al;exports.MatchesPage=hw;exports.MatchesStatsBar=Ew;exports.MatchesWidget=Vl;exports.ORDER_MAX_PRICE=Jv;exports.ORDER_MIN_PRICE=Xv;exports.ORDER_MIN_QUANTITY=zn;exports.ORDER_MIN_USDC=Wn;exports.ORDER_PRICE_STEP=Qv;exports.POLYMARKET_BUILDER_TAKER_FEE_BPS=Kc;exports.POLYMARKET_SPORTS_TAKER_FEE_BPS=Vc;exports.PREDICT_REDEEM_MODAL_ID=Sp;exports.PREDICT_SEARCH_MODAL_ID=bi;exports.PREDICT_SELL_MODAL_ID=Zo;exports.PREDICT_TRADE_MODAL_ID=on;exports.PRICE_HISTORY_SAMPLE_INTERVAL=eb;exports.PredictRedeemModal=Xs;exports.PredictSearchModal=yS;exports.PredictSellModal=pa;exports.PredictTradeModal=Yn;exports.PredictWalletProvider=zc;exports.PriceHistoryInterval=Br;exports.ProfilePage=Cv;exports.RedeemFormWidget=Ys;exports.SORT_PRESETS=vs;exports.STATIC_CATEGORIES=Io;exports.SearchEventsButton=ES;exports.SearchHistoryUI=ll;exports.SearchHistoryWidget=cl;exports.SearchInputUI=dl;exports.SearchResultItemUI=ul;exports.SearchResultListWidget=hl;exports.SearchWidget=kl;exports.SellFormUI=da;exports.SellFormWidget=no;exports.SetupModal=LP;exports.SimilarEventCard=tg;exports.SimilarEventsSection=Qa;exports.SourceBadge=Y1;exports.SpreadIndicator=Iw;exports.TradeFormSkeleton=ba;exports.TradeFormUI=ds;exports.TradeFormWidget=qn;exports.UserActivitySection=ga;exports.computeMaxBuyAmount=qi;exports.countActiveFilters=Uo;exports.createTradeResultToast=zr;exports.estimatePolymarketBuyFee=Yi;exports.estimatePolymarketSellFee=Qi;exports.fireCelebration=Xi;exports.floorToDecimals=xe;exports.formatKMB=gn;exports.formatShares=yr;exports.getSourceMeta=Ut;exports.parsePolymarketError=Kn;exports.polymarketFeeFactor=$c;exports.resolveExpiration=Un;exports.resolvePolymarketDisplayFeeRateBps=Gi;exports.roundToTickSize=$n;exports.useEventDetail=M2;exports.useEventsInfinite=ks;exports.usePredictSearchHistory=bo;exports.usePredictWallet=xr;exports.useSearchResultListScript=pl;exports.useSearchScript=yl;exports.useSellForm=ta;exports.useTradeForm=ts;//# sourceMappingURL=index.js.map
137
137
  //# sourceMappingURL=index.js.map