@liberfi.io/ui-predict 4.0.58 → 4.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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:c}){let{t:u}=i18n.useTranslation(),m=react.useCallback(()=>{o(null);},[o]),l=u("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",c),children:[jsxRuntime.jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxRuntime.jsxs("div",{className:"cat-primary-row",children:[jsxRuntime.jsx("div",{className:"cat-tabs hideScrollbar",children:jsxRuntime.jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsxRuntime.jsx(Fi,{label:l,isSelected:t===null,onPress:m,showPulse:l===s}),jsxRuntime.jsx(Tc,{}),e.map(f=>{let d=f.slug??f.category,p=f.label??f.category;return jsxRuntime.jsx(Fi,{label:p,isSelected:t===d,onPress:()=>o(d),badge:f.badge,showPulse:d===s||p===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((p,g)=>{let h=n(p);return typeof h=="string"&&h!==p?h:g},[n]),[i,a]=react.useState(null),[s,c]=react.useState(null),u=react.useCallback(p=>{a(p),c(null),e?.({categorySlug:p,tagSlug:null});},[e]),m=react.useCallback(p=>{c(p),e?.({categorySlug:i,tagSlug:p});},[i,e]),l=Rc(Io,o),f=Io.find(p=>p.slug===i),d=_c(f,o);return jsxRuntime.jsx(Hi,{categories:l,selectedCategory:i,selectedTag:s,activeTags:d,onCategorySelect:u,onTagSelect:m,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(E=>E.chainNamespace===types.ChainNamespace.SOLANA&&E.isConnected)?.address,[o]),a=react.useMemo(()=>o.find(E=>E.chainNamespace===types.ChainNamespace.EVM&&E.isConnected)?.address,[o]),{data:s,isLoading:c,isFetching:u,error:m}=reactPredict.useBalance({source:"kalshi",user:i??""},{enabled:t&&r&&!!i,refetchInterval:e}),{data:l,isLoading:f}=reactPredict.useDFlowKYC(i,{enabled:t&&r&&!!i,refetchInterval:3e4}),{data:d,isLoading:p}=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:C,error:R}=reactPredict.useBalance({source:"polymarket",user:a??""},{enabled:t&&v&&!!a,refetchInterval:e}),P=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:l?.verified??false,kalshiKycUrl:l?.kyc_url??null,kalshiKycLoading:f,polymarketSetupVerified:v,polymarketSafeDeployed:d?.safe_deployed??false,polymarketTokenApproved:d?.token_approved??false,polymarketSetupLoading:p,isLoading:c||y,isFetching:u||C,error:m??R??null}),[i,a,h,k,x,S,g,s,b,v,l,f,d,p,c,y,u,C,m,R]);return jsxRuntime.jsx(ji.Provider,{value:P,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,c=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(c,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function 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(),c=reactPredict.usePredictClient(),u=react.useContext(reactPredict.PolymarketContext),{start:m}=reactPredict.useTradeResultConfirmation(),l=e.source,f=l==="polymarket",d=s.find(_=>_.chainNamespace===types.ChainNamespace.SOLANA&&_.isConnected),p=s.find(_=>_.chainNamespace===types.ChainNamespace.EVM&&_.isConnected&&"switchChain"in _),g=a==="authenticated",v=d?.address,h=p?.address,[x,k]=react.useState(t),[S,b]=react.useState("market"),[y,C]=react.useState(NaN),[R,P]=react.useState(NaN),[E,D]=react.useState(false),[U,Q]=react.useState(null),[B,Y]=react.useState(false),[q,te]=react.useState(false),[N,M]=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(_,Ae)=>{let We=zr({celebrateOnCompleted:true,messages:Ke});We.submitted(),await m({source:l,user:l==="kalshi"?v:h,kalshiUser:v,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:_,getOrdersHeaders:Ae})==="confirmed"?We.completed():We.delayed();},[m,h,e.event_slug,e.slug,l,Ke,v]),w=react.useMemo(()=>{if(l!=="polymarket")return;let _=e.provider_meta?.["polymarket.clobTokenIds"];return _?(typeof _=="string"?JSON.parse(_):_)[x==="yes"?0:1]:void 0},[l,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 _=xr();at={kalshiUsdcBalance:_.kalshiUsdcBalance,polymarketUsdcBalance:_.polymarketUsdcBalance,isLoading:_.isLoading},_t=_.kalshiKycVerified,Mt=_.kalshiKycUrl,Tt=_.polymarketSetupVerified,et=_.polymarketSafeAddress,gt=_.polymarketWalletKind,ze=_.polymarketWalletAddress;}catch{}let Gt=l==="kalshi"&&!_t,Re=l==="polymarket"&&!Tt,{data:je}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:l,outcome:x},{enabled:e.status==="open"}),ge=react.useMemo(()=>{let _=reactPredict.pickBestAsk(je,x);if(_!=null&&_>0)return _;let Ae=x==="yes"?0:1,We=e.outcomes[Ae];return We?.best_ask??We?.price??.5},[je,e.outcomes,x]),lt=react.useCallback(_=>{b(_);},[]),ht=react.useCallback(_=>{k(_),P(NaN);},[]);react.useEffect(()=>{ht(t);},[t,ht]),react.useEffect(()=>{S==="limit"&&isNaN(R)&&P(Math.round(ge*1e4)/1e4);},[S,R,ge]);let Ne=react.useMemo(()=>S==="limit"&&f&&!isNaN(R)?R:ge,[S,f,R,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=l==="kalshi"?v??"":h??"",{data:Jr,isLoading:Co}=reactPredict.usePositionsMulti({kalshi_user:l==="kalshi"?Dt:void 0,polymarket_user:l==="polymarket"?Dt:void 0},{enabled:!!Dt}),Cn=l==="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?l==="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,l]),Rr=at?at.isLoading:Co,_r=react.useMemo(()=>qi({source:l,usdcBalance:qe,feeRateBps:Pe,pricePerShare:Ne}),[l,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(()=>l!=="polymarket"||isNaN(y)||y<=0?0:Yi({usdcAmount:y,pricePerShare:Ne,feeRateBps:Pe}),[l,y,Ne,Pe]),Tn=qt-Ir-Mn,Mo=react.useCallback(_=>{if(isNaN(_)){C(NaN);return}C(Math.round(Math.max(0,_)*100)/100);},[]),pr=react.useCallback(_=>{if(isNaN(_)){P(NaN);return}P(Math.round(_*1e4)/1e4);},[]),Bt=react.useCallback(()=>{C(NaN),P(NaN),b("market"),te(false),M("1h"),J(30),ae("minutes");},[]),Yt=react.useMemo(()=>{let _=[];return isNaN(y)||y<=0?_.push(o("predict.trade.minAmountUsd",{amount:Wn})):y<Wn&&_.push(o("predict.trade.minAmountUsd",{amount:Wn})),e.status!=="open"&&_.push(o("predict.trade.marketNotActive")),Ft!=null&&!isNaN(y)&&y>0&&y>Ft&&_.push(o("predict.trade.insufficientBalance")),S==="limit"&&f&&(isNaN(R)||R<.01||R>.99)&&_.push(o("predict.trade.limitPriceRange")),S==="limit"&&f&&q&&N==="custom"&&(isNaN(z)||z<=0)&&_.push(o("predict.trade.expiration.invalidDate")),l==="polymarket"&&S==="market"&&!isNaN(y)&&y>0&&ut>0&&(Ce.status==="insufficient_liquidity"?_.push(o("predict.trade.insufficientLiquidity",{available:xe(Ce.totalAvailable,2)})):Ce.status==="exceeds_slippage"&&_.push(o("predict.trade.priceImpactTooHigh",{impact:(Ce.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:_.length===0,errors:_}},[y,e.status,Ft,S,f,R,q,N,z,l,ut,Ce,r,o]),Or=react.useMemo(()=>Ft==null||isNaN(y)||y<=0?false:y>Ft,[Ft,y]),To=react.useCallback(()=>{n?.(l);},[n,l]),{mutateAsync:Zr}=reactPredict.useDFlowSubmit(),{data:mr}=reactPredict.useOrder({id:U??"",source:l},{enabled:!!U});react.useEffect(()=>{if(!mr||!U)return;let{status:_}=mr;_==="closed"?(Q(null),D(false),Ee("buy-market"),Bt()):(_==="failed"||_==="expired")&&(D(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"),D(false);return}if(!_t){Y(true),D(false);return}let Et=(await Lr()).data?.transaction;if(!Et){ui.toast.error(o("predict.trade.submitError")),D(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(!p||!u)return;let _=p.chain,Ae=_!==types.Chain.POLYGON;Ae&&await p.switchChain(types.Chain.POLYGON);try{let We=await p.getEip1193Provider();if(!We){ui.toast.error(o("predict.trade.submitError")),D(!1);return}let Et=gt==="deposit"&&!!ze,en=!Et&&!!et,hr=Et?ze:et,Qt={address:p.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:[p.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(R)?R: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(N,z,ue)}},T;if(Et)T=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);T=reactPredict.buildClobPayload(rt,ct.apiKey);}await c.executePolymarketOrder({payload:T,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(),D(!1);}finally{Ae&&_&&p.switchChain(_).catch(()=>{});}},[p,u,x,e.provider_meta,S,Ee,R,I,y,c,q,N,z,ue,Bt,o,we,st,et,gt,ze,Le]),gr=react.useCallback(async()=>{if(!(!Yt.isValid||!g)){D(true),Q(null),Y(false);try{l==="kalshi"?await bt():await fr();}catch(_){let Ae=_ instanceof Error?_.message:"",We=l==="polymarket"&&Ae?Kn(Ae,o,"buy"):Ae||void 0;ui.toast.error(We||o("predict.trade.submitError")),D(false);}}},[Yt.isValid,g,l,bt,fr,o]);return {outcome:x,orderType:S,quantity:y,limitPrice:R,shares:ut,effectivePrice:Ne,estimatedCost:Ir,estimatedFee:Mn,potentialPayout:qt,potentialProfit:Tn,pricePerShare:ge,usdcBalance:qe,maxBuyAmount:_r,spendableUsdcBalance:Ft,isBalanceLoading:Rr,isMarketDataLoading:l==="polymarket"&&(Oe||Je),isSubmitting:E,authStatus:a,validation:Yt,isInsufficientBalance:Or,source:l,supportsLimitOrder:f,kycRequired:B,needsKyc:Gt,needsSetup:Re,kycUrl:Mt,expirationEnabled:q,expirationPreset:N,customDuration:z,customDurationUnit:ue,setOutcome:ht,setOrderType:lt,setQuantity:Mo,setLimitPrice:pr,setExpirationEnabled:te,setExpirationPreset:M,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:c,potentialProfit:u,potentialPayout:m,estimatedCost:l,estimatedFee:f=0,usdcBalance:d,isBalanceLoading:p,isMarketDataLoading:g,isSubmitting:v,authStatus:h,isValid:x,validationErrors:k,isInsufficientBalance:S,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:C,kycRequired:R,needsKyc:P,needsSetup:E,kycUrl:D,expirationEnabled:U,expirationPreset:Q,customDuration:B,customDurationUnit:Y,oddsFormatter:q,onOutcomeChange:te,onOrderTypeChange:N,onQuantityChange:M,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==="."){M(NaN);return}let vt=parseFloat(A);isNaN(vt)||M(vt);},[M]);react.useEffect(()=>{R&&!we.isOpen&&we.onOpen();},[R]);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(c)?parseFloat((c*100).toFixed(2)):null,gt=Number.isFinite(c)&&q?q(c):et!=null?`${et} \xA2`:sr,ze=!isNaN(i)&&i>0,Gt=ze?l+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&&(P||E),Ne=react.useMemo(()=>{if(lt)return w("predict.trade.checkingLogin");if(!ge)return w("predict.trade.loginToTrade");if(P)return w("predict.trade.kycRequired");if(E)return w("predict.trade.setupRequired");if(p)return w("predict.trade.loadingBalance");if(g)return w("predict.trade.loadingMarketData");if(v)return w("predict.trade.submitting");if(R)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,P,E,p,g,v,R,ze,n,u,w]),ut="primary",Ce=()=>{let A=C??xe(d??0,2);M(xe(A/2,2));},I=()=>{M(C??xe(d??0,2));},[pe,tt]=react.useState(false),Xr=()=>{if(!ge){tt(false),Ee();return}if(P){we.onOpen();return}if(E&&b){tt(false),b();return}if(R){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=>N(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(c)?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?`$${l.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?`$${m.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&&(p||g||!ze||v),isLoading:lt||ge&&!ht&&(v||p||g),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Xr,children:Ne})]}),jsxRuntime.jsx(jn,{isOpen:we.isOpen,onClose:we.onClose,kycUrl:D})]})}function qn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:a,onOutcomeChange:s,oddsFormatter:c}){let{outcome:u,orderType:m,quantity:l,limitPrice:f,shares:d,effectivePrice:p,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,pricePerShare:k,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:C,isSubmitting:R,authStatus:P,validation:E,isInsufficientBalance:D,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:N,customDuration:M,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:m,quantity:l,limitPrice:f,shares:d,effectivePrice:p,estimatedCost:g,estimatedFee:v,potentialPayout:h,potentialProfit:x,usdcBalance:S,maxBuyAmount:b,isBalanceLoading:y,isMarketDataLoading:C,isSubmitting:R,authStatus:P,isValid:E.isValid,validationErrors:E.errors,isInsufficientBalance:D,onInsufficientBalance:a?Ct:void 0,supportsLimitOrder:U,kycRequired:Q,needsKyc:B,needsSetup:Y,kycUrl:q,expirationEnabled:te,expirationPreset:N,customDuration:M,customDurationUnit:z,oddsFormatter:c,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),c=react.useMemo(()=>o?sn:{...sn,source:"polymarket"},[o]),u=react.useCallback(x=>{x?s(r):t();},[r,t]),m=react.useCallback(()=>{s(c);},[c]),l=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]),p=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:p,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:m,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:l,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(),[c,u]=react.useState(false),m=react.useRef(null),l=react.useCallback(d=>{m.current&&!m.current.contains(d.target)&&u(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)),[l]),react.useEffect(()=>{if(!c)return;let d=p=>{p.key==="Escape"&&u(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[c]);let f=hs[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:m,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:c})]}),c&&jsxRuntime.jsx("div",{style:{...uu,width:224,padding:4},children:du.map(d=>{let p=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(p,{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=e.lang??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,e.lang]),{data:o,isLoading:i,isFetching:a,isFetchingNextPage:s,isError:c,error:u,hasNextPage:m,fetchNextPage:l,refetch:f}=reactPredict.useInfiniteEvents(n),d=react.useMemo(()=>o?.pages.flatMap(v=>v.items).filter(v=>v!=null)??[],[o]),p=react.useCallback(()=>{l();},[l]),g=react.useCallback(()=>{f();},[f]);return {data:d,isLoading:i,isFetching:a&&!s,isFetchingMore:s,isError:c,error:u??null,hasMore:m??false,fetchMore:p,refetch:g}}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},Bi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Io=(()=>{let e=t=>{let r=Bi.indexOf(t);return r===-1?Bi.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 Wi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:s="Trending",className:l}){let{t:u}=i18n.useTranslation(),m=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(Hi,{label:c,isSelected:t===null,onPress:m,showPulse:c===s}),jsxRuntime.jsx(Tc,{}),e.map(f=>{let d=f.slug??f.category,p=f.label??f.category;return jsxRuntime.jsx(Hi,{label:p,isSelected:t===d,onPress:()=>o(d),badge:f.badge,showPulse:d===s||p===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(zi,{label:u("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(f=>{let d=f.slug??f.label;return jsxRuntime.jsx(zi,{label:f.label,icon:f.icon,isSelected:r===d,onPress:()=>i(d)},d)})]})})]})}function Hi({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 zi({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 $i(e){return e.trim().toLowerCase().replace(/&/g,"and").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function Lc(e){return `predict.categories.category.${$i(e)}`}function Ki(e){return `predict.categories.tag.${$i(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(Ki(n.slug),n.label),icon:n.icon}))}))}function _c(e,t){return e?e.tags.map(r=>({slug:r.slug,label:t(Ki(r.slug),r.label),icon:r.icon})):[]}function Vi({onSelect:e,trailing:t,className:r}){let{t:n}=i18n.useTranslation(),o=react.useCallback((p,g)=>{let h=n(p);return typeof h=="string"&&h!==p?h:g},[n]),[i,a]=react.useState(null),[s,l]=react.useState(null),u=react.useCallback(p=>{a(p),l(null),e?.({categorySlug:p,tagSlug:null});},[e]),m=react.useCallback(p=>{l(p),e?.({categorySlug:i,tagSlug:p});},[i,e]),c=Rc(Io,o),f=Io.find(p=>p.slug===i),d=_c(f,o);return jsxRuntime.jsx(Wi,{categories:c,selectedCategory:i,selectedTag:s,activeTags:d,onCategorySelect:u,onTagSelect:m,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 qi=react.createContext(null);function xr(){let e=react.useContext(qi);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(R=>R.chainNamespace===types.ChainNamespace.SOLANA&&R.isConnected)?.address,[o]),a=react.useMemo(()=>o.find(R=>R.chainNamespace===types.ChainNamespace.EVM&&R.isConnected)?.address,[o]),{data:s,isLoading:l,isFetching:u,error:m}=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:p}=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,S=h==="safe"?d?.safe_address:x,k=h==="safe"?d?.safe_deployed??false:d?.deposit_wallet_deployed??false,{data:b,isLoading:y,isFetching:N,error:E}=reactPredict.useBalance({source:"polymarket",user:a??""},{enabled:t&&v&&!!a,refetchInterval:e}),P=react.useMemo(()=>({solanaAddress:i,evmAddress:a,polymarketWalletKind:h,polymarketWalletAddress:S,polymarketDepositWalletAddress:x,polymarketWalletDeployed:k,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:p,isLoading:l||y,isFetching:u||N,error:m??E??null}),[i,a,h,S,x,k,g,s,b,v,c,f,d,p,l,y,u,N,m,E]);return jsxRuntime.jsx(qi.Provider,{value:P,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 Yi(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 Xi({usdcAmount:e,pricePerShare:t,feeRateBps:r}){if(!Number.isFinite(e)||e<=0)return 0;let n=Bo(r,t);return e*n}function Ji({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 Zi(){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 es={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)?es.zh:es.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&&Zi();},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 ns({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:m}=reactPredict.useTradeResultConfirmation(),c=e.source,f=c==="polymarket",d=s.find(_=>_.chainNamespace===types.ChainNamespace.SOLANA&&_.isConnected),p=s.find(_=>_.chainNamespace===types.ChainNamespace.EVM&&_.isConnected&&"switchChain"in _),g=a==="authenticated",v=d?.address,h=p?.address,[x,S]=react.useState(t),[k,b]=react.useState("market"),[y,N]=react.useState(NaN),[E,P]=react.useState(NaN),[R,D]=react.useState(false),[U,Q]=react.useState(null),[H,Y]=react.useState(false),[q,te]=react.useState(false),[C,T]=react.useState("1h"),[B,J]=react.useState(30),[ue,se]=react.useState("minutes"),Ge=react.useMemo(()=>Hr(o,i),[i,o]),We=react.useCallback(async(_,Fe)=>{let Ke=zr({celebrateOnCompleted:true,messages:Ge});Ke.submitted(),await m({source:c,user:c==="kalshi"?v:h,kalshiUser:v,polymarketUser:h,marketSlug:e.slug,eventSlug:e.event_slug,expectation:_,getOrdersHeaders:Fe})==="confirmed"?Ke.completed():Ke.delayed();},[m,h,e.event_slug,e.slug,c,Ge,v]),st=react.useMemo(()=>{if(c!=="polymarket")return;let _=e.provider_meta?.["polymarket.clobTokenIds"];return _?(typeof _=="string"?JSON.parse(_):_)[x==="yes"?0:1]:void 0},[c,e.provider_meta,x]),{data:w,isLoading:gt}=reactPredict.useTickSize(st),Ae=w?.minimum_tick_size?String(w.minimum_tick_size):"0.01",{data:Ue,isLoading:Nt}=reactPredict.useFeeRate(st),Pe=Ue?.base_fee??0,at=String(Pe),qe=react.useMemo(()=>Yi(e.provider_meta),[e.provider_meta]),{data:De}=reactPredict.useRebateConfig(),Re=De?.builder_enabled&&De.builder_code?De.builder_code:void 0,_e=null,Ct=false,Mt=null,At=false,ut,et,Tt;try{let _=xr();_e={kalshiUsdcBalance:_.kalshiUsdcBalance,polymarketUsdcBalance:_.polymarketUsdcBalance,isLoading:_.isLoading},Ct=_.kalshiKycVerified,Mt=_.kalshiKycUrl,At=_.polymarketSetupVerified,ut=_.polymarketSafeAddress,et=_.polymarketWalletKind,Tt=_.polymarketWalletAddress;}catch{}let lt=c==="kalshi"&&!Ct,ht=c==="polymarket"&&!At,{data:Ne}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:c,outcome:x},{enabled:e.status==="open"}),ye=react.useMemo(()=>{let _=reactPredict.pickBestAsk(Ne,x);if(_!=null&&_>0)return _;let Fe=x==="yes"?0:1,Ke=e.outcomes[Fe];return Ke?.best_ask??Ke?.price??.5},[Ne,e.outcomes,x]),Et=react.useCallback(_=>{b(_);},[]),Ye=react.useCallback(_=>{S(_),P(NaN);},[]);react.useEffect(()=>{Ye(t);},[t,Ye]),react.useEffect(()=>{k==="limit"&&isNaN(E)&&P(Math.round(ye*1e4)/1e4);},[k,E,ye]);let ve=react.useMemo(()=>k==="limit"&&f&&!isNaN(E)?E:ye,[k,f,E,ye]),$e=react.useMemo(()=>isNaN(y)||y<=0?0:ve>0?y/ve:0,[y,ve]),be=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:Ne,outcome:x,side:"buy",sharesNeeded:$e,slippageBps:r}),[Ne,x,$e,r]),Lt=react.useMemo(()=>be.status==="ok"&&be.worstPrice!=null&&be.worstPrice>0?be.worstPrice:ye,[be,ye]),Rt=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),I=e.provider_meta?.["dflow.yesMint"]??"",Me=e.provider_meta?.["dflow.noMint"]??"",Ce=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,Xr=x==="yes"?I:Me,O=Ce,Te=Xr,tt=c==="kalshi"?v??"":h??"",{data:Jr,isLoading:Co}=reactPredict.usePositionsMulti({kalshi_user:c==="kalshi"?tt:void 0,polymarket_user:c==="polymarket"?tt:void 0},{enabled:!!tt}),Cn=c==="kalshi"&&!!O&&!!Te&&!!v&&Rt!=="0",{refetch:Lr}=reactPredict.useDFlowQuote({inputMint:O,outputMint:Te,amount:Rt,userPublicKey:v??"",slippageBps:100},{enabled:Cn}),Qe=react.useMemo(()=>_e?c==="kalshi"?_e.kalshiUsdcBalance:_e.polymarketUsdcBalance:Jr&&Jr.positions.reduce((Fe,Ke)=>Ke.side==="USDC"||Ke.side==="collateral"?Fe+(Ke.current_value??0):Fe,0)||null,[_e,Jr,c]),Rr=_e?_e.isLoading:Co,_r=react.useMemo(()=>Qi({source:c,usdcBalance:Qe,feeRateBps:qe,pricePerShare:ve}),[c,Qe,qe,ve]),Ht=Qe==null?null:_r,Ir=react.useMemo(()=>isNaN(y)||y<=0?0:y,[y]),Yt=react.useMemo(()=>isNaN(y)||y<=0?0:ve>0?y/ve*1:0,[y,ve]),Mn=react.useMemo(()=>c!=="polymarket"||isNaN(y)||y<=0?0:Xi({usdcAmount:y,pricePerShare:ve,feeRateBps:qe}),[c,y,ve,qe]),Tn=Yt-Ir-Mn,Mo=react.useCallback(_=>{if(isNaN(_)){N(NaN);return}N(Math.round(Math.max(0,_)*100)/100);},[]),pr=react.useCallback(_=>{if(isNaN(_)){P(NaN);return}P(Math.round(_*1e4)/1e4);},[]),zt=react.useCallback(()=>{N(NaN),P(NaN),b("market"),te(false),T("1h"),J(30),se("minutes");},[]),Qt=react.useMemo(()=>{let _=[];return isNaN(y)||y<=0?_.push(o("predict.trade.minAmountUsd",{amount:Wn})):y<Wn&&_.push(o("predict.trade.minAmountUsd",{amount:Wn})),e.status!=="open"&&_.push(o("predict.trade.marketNotActive")),Ht!=null&&!isNaN(y)&&y>0&&y>Ht&&_.push(o("predict.trade.insufficientBalance")),k==="limit"&&f&&(isNaN(E)||E<.01||E>.99)&&_.push(o("predict.trade.limitPriceRange")),k==="limit"&&f&&q&&C==="custom"&&(isNaN(B)||B<=0)&&_.push(o("predict.trade.expiration.invalidDate")),c==="polymarket"&&k==="market"&&!isNaN(y)&&y>0&&$e>0&&(be.status==="insufficient_liquidity"?_.push(o("predict.trade.insufficientLiquidity",{available:xe(be.totalAvailable,2)})):be.status==="exceeds_slippage"&&_.push(o("predict.trade.priceImpactTooHigh",{impact:(be.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:_.length===0,errors:_}},[y,e.status,Ht,k,f,E,q,C,B,c,$e,be,r,o]),Or=react.useMemo(()=>Ht==null||isNaN(y)||y<=0?false:y>Ht,[Ht,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:_}=mr;_==="closed"?(Q(null),D(false),We("buy-market"),zt()):(_==="failed"||_==="expired")&&(D(false),Q(null),ui.toast.error(o("predict.trade.submitError")));},[We,mr,U,zt,o]);let vt=react.useCallback(async()=>{if(!v||!d)return;if(!O||!Te){ui.toast.error("Missing token mint addresses"),D(false);return}if(!Ct){Y(true),D(false);return}let _t=(await Lr()).data?.transaction;if(!_t){ui.toast.error(o("predict.trade.submitError")),D(false);return}let en=Uint8Array.from(atob(_t),ct=>ct.charCodeAt(0)),hr=await d.signTransaction(en),Xt=await Zr({signedTransaction:btoa(String.fromCharCode(...hr)),orderContext:{user_public_key:v,input_mint:O,output_mint:Te,amount:Rt,price:String(ye),side:"BUY",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});Q(Xt.signature);},[v,d,Lr,Zr,O,Te,Rt,ye,x,e.slug,o,Ct]),fr=react.useCallback(async()=>{if(!p||!u)return;let _=p.chain,Fe=_!==types.Chain.POLYGON;Fe&&await p.switchChain(types.Chain.POLYGON);try{let Ke=await p.getEip1193Provider();if(!Ke){ui.toast.error(o("predict.trade.submitError")),D(!1);return}let _t=et==="deposit"&&!!Tt,en=!_t&&!!ut,hr=_t?Tt:ut,Xt={address:p.address,signatureType:_t?3:en?2:0,signTypedData:async(le,ke,Xe,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 It={EIP712Domain:nt,...ke};return await Ke.request({method:"eth_signTypedData_v4",params:[p.address,JSON.stringify({domain:le,types:It,primaryType:Xe,message:rt})]})}},ct=u.credentials??await u.authenticate(Xt),vr=x==="yes"?0:1,Ar="",Jt=e.provider_meta?.["polymarket.clobTokenIds"];Jt&&(Ar=(typeof Jt=="string"?JSON.parse(Jt):Jt)[vr]??"");let Dr=e.provider_meta?.["polymarket.negRisk"]??!1,En=k==="limit"&&!isNaN(E)?E:Lt,Zt=$n(En,Ae),Ln=k==="limit"?q?"GTD":"GTC":"FOK",Rn=k==="market"?y:Zt>0?y/Zt:0,tn={tokenId:Ar,price:Zt,size:Rn,side:"BUY",orderType:Ln,tickSize:Ae,negRisk:Dr,...hr&&{funderAddress:hr},...Re&&{builderCode:Re},...k==="limit"&&q&&{expiration:Un(C,B,ue)}},M;if(_t)M=await reactPredict.buildSignedV2OrderPayload({signer:Xt,depositWalletAddress:hr,input:tn,owner:ct.apiKey});else {let le=reactPredict.buildCtfExchangeDomain(Dr),ke=reactPredict.buildOrderMessage({...tn,signerAddress:Xt.address,signatureType:Xt.signatureType,feeRateBps:at}),Xe=await Xt.signTypedData(le,reactPredict.CTF_ORDER_TYPES,"Order",ke),rt=reactPredict.buildSignedOrder(ke,Xe,tn.orderType);M=reactPredict.buildClobPayload(rt,ct.apiKey);}await l.executePolymarketOrder({payload:M,l2_api_key:ct.apiKey,l2_secret:ct.secret,l2_passphrase:ct.passphrase,signer_address:ct.address,owner:ct.apiKey}),We(k==="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"})),zt(),D(!1);}finally{Fe&&_&&p.switchChain(_).catch(()=>{});}},[p,u,x,e.provider_meta,k,We,E,Lt,y,l,q,C,B,ue,zt,o,Ae,at,ut,et,Tt,Re]),gr=react.useCallback(async()=>{if(!(!Qt.isValid||!g)){D(true),Q(null),Y(false);try{c==="kalshi"?await vt():await fr();}catch(_){let Fe=_ instanceof Error?_.message:"",Ke=c==="polymarket"&&Fe?Kn(Fe,o,"buy"):Fe||void 0;ui.toast.error(Ke||o("predict.trade.submitError")),D(false);}}},[Qt.isValid,g,c,vt,fr,o]);return {outcome:x,orderType:k,quantity:y,limitPrice:E,shares:$e,effectivePrice:ve,estimatedCost:Ir,estimatedFee:Mn,potentialPayout:Yt,potentialProfit:Tn,pricePerShare:ye,usdcBalance:Qe,maxBuyAmount:_r,spendableUsdcBalance:Ht,isBalanceLoading:Rr,isMarketDataLoading:c==="polymarket"&&(Nt||gt),isSubmitting:R,authStatus:a,validation:Qt,isInsufficientBalance:Or,source:c,supportsLimitOrder:f,kycRequired:H,needsKyc:lt,needsSetup:ht,kycUrl:Mt,expirationEnabled:q,expirationPreset:C,customDuration:B,customDurationUnit:ue,setOutcome:Ye,setOrderType:Et,setQuantity:Mo,setLimitPrice:pr,setExpirationEnabled:te,setExpirationPreset:T,setCustomDuration:J,setCustomDurationUnit:se,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},ar="-";function us({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:s,effectivePrice:l,potentialProfit:u,potentialPayout:m,estimatedCost:c,estimatedFee:f=0,usdcBalance:d,isBalanceLoading:p,isMarketDataLoading:g,isSubmitting:v,authStatus:h,isValid:x,validationErrors:S,isInsufficientBalance:k,onInsufficientBalance:b,supportsLimitOrder:y,maxBuyAmount:N,kycRequired:E,needsKyc:P,needsSetup:R,kycUrl:D,expirationEnabled:U,expirationPreset:Q,customDuration:H,customDurationUnit:Y,oddsFormatter:q,outcomeLabels:te,onOutcomeChange:C,onOrderTypeChange:T,onQuantityChange:B,onLimitPriceChange:J,onExpirationEnabledChange:ue,onExpirationPresetChange:se,onCustomDurationChange:Ge,onCustomDurationUnitChange:We,onSubmit:st}){let{t:w}=i18n.useTranslation(),[gt,Ae]=react.useState(true),Ue=ui.useDisclosure(),[Nt,Pe]=react.useState(""),at=react.useRef(false);react.useEffect(()=>{at.current||Pe(isNaN(i)?"":String(i));},[i]);let[qe,De]=react.useState(""),Re=react.useRef(false);react.useEffect(()=>{Re.current||(isNaN(a)?De(""):De(String(parseFloat((a*100).toFixed(2)))));},[a]);let _e=react.useCallback(O=>{if(O!==""&&!/^\d*\.?\d{0,2}$/.test(O))return;if(De(O),O===""||O==="."){J(NaN);return}let tt=parseFloat(O);isNaN(tt)||J(tt/100);},[J]),Ct=react.useCallback(O=>{if(O!==""&&!/^\d*\.?\d{0,2}$/.test(O))return;if(Pe(O),Ce(false),O===""||O==="."){B(NaN);return}let tt=parseFloat(O);isNaN(tt)||B(tt);},[B]);react.useEffect(()=>{E&&!Ue.isOpen&&Ue.onOpen();},[E]);let Mt=react.useMemo(()=>{let O=n==="yes"?t.yesAsk:t.noAsk;return O!=null?parseFloat((Number(O)*100).toFixed(2)):null},[n,t]),At=n==="yes"?t.yesAsk:t.noAsk,ut=At!=null&&q?q(Number(At)):Mt!=null?`${Mt} \xA2`:ar,et=Number.isFinite(l)?parseFloat((l*100).toFixed(2)):null,Tt=Number.isFinite(l)&&q?q(l):et!=null?`${et} \xA2`:ar,lt=!isNaN(i)&&i>0,ht=lt?c+f:0,Ne=lt&&s>0?ht/s:0,ye=Ne>0&&q?q(Ne):Ne>0?`${parseFloat((Ne*100).toFixed(2))}\xA2`:ar,Et=h==="authenticated",Ye=h==="authenticating"||h==="deauthenticating",ve=Et&&(P||R),$e=react.useCallback(O=>te?.[O]??w(O==="yes"?"predict.trade.yes":"predict.trade.no"),[te,w]),be=react.useMemo(()=>{if(Ye)return w("predict.trade.checkingLogin");if(!Et)return w("predict.trade.loginToTrade");if(P)return w("predict.trade.kycRequired");if(R)return w("predict.trade.setupRequired");if(p)return w("predict.trade.loadingBalance");if(g)return w("predict.trade.loadingMarketData");if(v)return w("predict.trade.submitting");if(E)return w("predict.trade.kycRequired");if(!lt)return w("predict.trade.enterAmount");let O=$e(n),Te=u>0?` \u2192 Win $${u.toFixed(2)}`:"";return `${w("predict.trade.buy")} ${O}${Te}`},[Ye,Et,P,R,p,g,v,E,lt,n,$e,u,w]),Lt="primary",Rt=()=>{let O=N??xe(d??0,2);B(xe(O/2,2));},I=()=>{B(N??xe(d??0,2));},[Me,Ce]=react.useState(false),Xr=()=>{if(!Et){Ce(false),st();return}if(P){Ue.onOpen();return}if(R&&b){Ce(false),b();return}if(E){Ue.onOpen();return}if(k&&b){Ce(false),b();return}if(!x){Ce(true);return}Ce(false),st();};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:O=>{r==="bordered"&&(O.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:O=>{r==="bordered"&&(O.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")," ",$e(n)]}),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:O=>T(O),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:qe,onChange:O=>_e(O.target.value),onFocus:()=>{Re.current=true;},onBlur:()=>{Re.current=false,isNaN(a)?De(""):De(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"}}):ut!=null&&jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums",children:ut})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(O=>{let Te=O==="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:()=>C(O),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===O?"border-bullish bg-bullish/10 text-bullish":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:$e(O)}),Te!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:q?q(Number(Te)):`${parseFloat((Number(Te)*100).toFixed(2))}\xA2`})]})},O)})}),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:Rt,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:Nt,onChange:O=>Ct(O.target.value),onFocus:()=>{at.current=true;},onBlur:()=>{at.current=false,Pe(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"}}),Me&&S.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:S.map(O=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:O},O))})]}),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:ue,"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:O=>{let Te=Array.from(O)[0];Te&&se(Te);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Dd.map(O=>jsxRuntime.jsx(ui.SelectItem,{children:w(Fd[O])},O))}),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(H)?void 0:H,onValueChange:Ge,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:O=>{let Te=Array.from(O)[0];Te&&We(Te);},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(O=>jsxRuntime.jsx(ui.SelectItem,{children:w(Hd[O])},O))})]})]})]}),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:()=>Ae(O=>!O),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",gt&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:q&&Number.isFinite(l)?Tt:et!=null?w("predict.trade.chance",{percent:et}):ar})]}),gt&&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)}`:ar})]}),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):ar})]}),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:`$${ht.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:ye})]}),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?`$${m.toFixed(2)}`:ar})]}),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)}`:ar})]})]})]}),jsxRuntime.jsx(ui.Button,{color:Lt,fullWidth:true,radius:"lg",size:"lg",isDisabled:Ye||Et&&!ve&&(p||g||!lt||v),isLoading:Ye||Et&&!ve&&(v||p||g),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Xr,children:be})]}),jsxRuntime.jsx(jn,{isOpen:Ue.isOpen,onClose:Ue.onClose,kycUrl:D})]})}function qn({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:a,onOutcomeChange:s,oddsFormatter:l,outcomeLabels:u}){let{outcome:m,orderType:c,quantity:f,limitPrice:d,shares:p,effectivePrice:g,estimatedCost:v,estimatedFee:h,potentialPayout:x,potentialProfit:S,pricePerShare:k,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:N,isMarketDataLoading:E,isSubmitting:P,authStatus:R,validation:D,isInsufficientBalance:U,supportsLimitOrder:Q,kycRequired:H,needsKyc:Y,needsSetup:q,kycUrl:te,expirationEnabled:C,expirationPreset:T,customDuration:B,customDurationUnit:J,setOutcome:ue,setOrderType:se,setQuantity:Ge,setLimitPrice:We,setExpirationEnabled:st,setExpirationPreset:w,setCustomDuration:gt,setCustomDurationUnit:Ae,submit:Ue,notifyInsufficientBalance:Nt}=ns({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:a}),Pe=walletConnector.useAuthCallback(Ue),at=react.useCallback(Re=>{ue(Re),s?.(Re);},[ue,s]),qe=react.useMemo(()=>e?Dn(e):void 0,[e]),De=react.useMemo(()=>Fn(t,{yesAsk:m==="yes"?k:void 0,noAsk:m==="no"?k:void 0}),[t,m,k]);return jsxRuntime.jsx(us,{event:qe,market:De,variant:r,outcome:m,orderType:c,quantity:f,limitPrice:d,shares:p,effectivePrice:g,estimatedCost:v,estimatedFee:h,potentialPayout:x,potentialProfit:S,usdcBalance:b,maxBuyAmount:y,isBalanceLoading:N,isMarketDataLoading:E,isSubmitting:P,authStatus:R,isValid:D.isValid,validationErrors:D.errors,isInsufficientBalance:U,onInsufficientBalance:a?Nt:void 0,supportsLimitOrder:Q,kycRequired:H,needsKyc:Y,needsSetup:q,kycUrl:te,expirationEnabled:C,expirationPreset:T,customDuration:B,customDurationUnit:J,oddsFormatter:l,outcomeLabels:u,onOutcomeChange:at,onOrderTypeChange:se,onQuantityChange:Ge,onLimitPriceChange:We,onExpirationEnabledChange:st,onExpirationPresetChange:w,onCustomDurationChange:gt,onCustomDurationUnitChange:Ae,onSubmit:Pe})}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 $o(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function ms({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]),m=react.useCallback(()=>{s(l);},[l]),c=react.useCallback(()=>{n(a),t();},[a,n,t]),f=react.useCallback((x,S)=>{s(k=>({...k,[x]:S}));},[]),d=react.useMemo(()=>$o(a,o),[a,o]),p=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:p,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:m,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 bs={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},gs={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"],hs={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 xs({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),m=react.useRef(null),c=react.useCallback(d=>{m.current&&!m.current.contains(d.target)&&u(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)),[c]),react.useEffect(()=>{if(!l)return;let d=p=>{p.key==="Escape"&&u(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let f=vs[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:m,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:hs,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(gs[e])}),jsxRuntime.jsx(fu,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...uu,width:224,padding:4},children:du.map(d=>{let p=vs[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(p,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:s(gs[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:hs,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 vs={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 Ss(e={}){let{i18n:t}=i18n.useTranslation(),r=e.lang??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,e.lang]),{data:o,isLoading:i,isFetching:a,isFetchingNextPage:s,isError:l,error:u,hasNextPage:m,fetchNextPage:c,refetch:f}=reactPredict.useInfiniteEvents(n),d=react.useMemo(()=>o?.pages.flatMap(v=>v.items).filter(v=>v!=null)??[],[o]),p=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:m??false,fetchMore:p,refetch:g}}var ws=`
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(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=`
6
+ `,Ps={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 {...Ps,animationDelay:`${e}ms`}}function Ko({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:ws}),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={...Ps,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:ws}),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(Ko,{count:e})})]})}var Ns=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)"},jo={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Rs={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 Cs(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 [jo,Ru];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [jo,Rs];let r=t[0]??"",n=t[1]??"",o=Cs(r)%an.length,i=Cs(n)%an.length;return i===o&&(i=(i+1)%an.length),[an[o],an[i]]}function Ms(e){return e.title_trans||e.title}function Iu(e){return e.question_trans||e.question}function Go(e,t){return e?.label_trans||e?.label||t}function _s(e){return Go(e.outcomes?.[0],Iu(e))}function Ou(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Is(e){let t=Ou(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Os(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Ts(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Es(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),c=e.markets??[],m=react.useMemo(()=>c.length>2?[...c].sort((b,y)=>(y.outcomes?.[0]?.price??0)-(b.outcomes?.[0]?.price??0)):c,[c]).filter(b=>b.status==="open"),l=m.length===1,f=m.slice(0,Ps),d=m.length-Ps,p=react.useMemo(()=>utils$1.formatAmountInUsd(e.volume??0),[e.volume]),g=a?m.find(b=>b.slug===a)??null:null,v=!!g||l,h=()=>{v||n?.(e);},x=b=>{b.stopPropagation(),g&&(b.preventDefault(),s(null));},k=b=>{b.stopPropagation(),t||(b.preventDefault(),n?.(e));},S=l?jsxRuntime.jsx(qu,{event:e,formattedVolume:p,href:t,LinkComponent:r,onSelect:n}):g?jsxRuntime.jsx(Qu,{onCollapse:()=>s(null)}):jsxRuntime.jsx(Ku,{moreCount:d,formattedVolume:p,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,C=Eu[e.source]??Lu;y.style.borderColor=C.border,y.style.boxShadow=C.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:l?jsxRuntime.jsx(Gu,{market:m[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 c=s.currentTarget;c.style.setProperty("--shadow-offset","2px"),c.style.transform="translateY(2px)";},onMouseLeave:s=>{let c=s.currentTarget;c.style.setProperty("--shadow-offset","4px"),c.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],c=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",m=o==="label"&&c===u?"action":o,l=m==="label"?`${jo(e.outcomes?.[0],"Yes")} ${Ms(e)}\xA2`:i("predict.market.action.yes",{price:Ms(e)}),f=m==="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:l}),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:c}){let{t:u}=i18n.useTranslation(),m=react.useRef(null);react.useEffect(()=>{let d=m.current;if(!d)return;let p=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return p.observe(d),()=>p.disconnect()},[t,r,n]);let l=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 As({event:e,href:t,LinkComponent:r,onSelect:n,onSelectOutcome:o,onHover:i}){let[a,s]=react.useState(null),l=e.markets??[],m=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=m.length===1,f=m.slice(0,Ns),d=m.length-Ns,p=react.useMemo(()=>utils$1.formatAmountInUsd(e.volume??0),[e.volume]),g=a?m.find(b=>b.slug===a)??null:null,v=!!g||c,h=()=>{v||n?.(e);},x=b=>{b.stopPropagation(),g&&(b.preventDefault(),s(null));},S=b=>{b.stopPropagation(),t||(b.preventDefault(),n?.(e));},k=c?jsxRuntime.jsx(qu,{event:e,formattedVolume:p,href:t,LinkComponent:r,onSelect:n}):g?jsxRuntime.jsx(Qu,{onCollapse:()=>s(null)}):jsxRuntime.jsx(Ku,{moreCount:d,formattedVolume:p,source:e.source,href:t,LinkComponent:r,onShowMore:S});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:m[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:k})]})}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:Ms(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:Ms(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=Is(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:_s(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:Os(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(Fs,{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(Bs,{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 Ls({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 Ds({market:e,event:t,onSelectOutcome:r,dynamicColors:n=false,labelFormat:o="action"}){let{t:i}=i18n.useTranslation(),[a,s]=n?_u(e):[jo,Rs],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",u=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",m=o==="label"&&l===u?"action":o,c=m==="label"?`${Go(e.outcomes?.[0],"Yes")} ${Ts(e)}\xA2`:i("predict.market.action.yes",{price:Ts(e)}),f=m==="label"?`${Go(e.outcomes?.[1],"No")} ${Es(e)}\xA2`:i("predict.market.action.no",{price:Es(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Ls,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"yes");},children:c}),jsxRuntime.jsx(Ls,{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(Ds,{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(Fs,{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(Bs,{source:e.source})]})]})}function Yu({market:e,event:t,onCollapse:r,onSelectOutcome:n}){let o=Is(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:_s(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:Os(o)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{style:{marginTop:12},children:jsxRuntime.jsx(Ds,{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 Fs({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 Bs({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 zs({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(),m=react.useRef(null);react.useEffect(()=>{let d=m.current;if(!d)return;let p=new IntersectionObserver(g=>{g[0]?.isIntersecting&&t&&!r&&n?.();},{rootMargin:"300px"});return p.observe(d),()=>p.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((d,p)=>d==null?null:jsxRuntime.jsx("div",{style:{padding:tp,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${p%4*35}ms both`},children:jsxRuntime.jsx(Os,{event:d,href:a?.(d),LinkComponent:s,onSelect:o,onSelectOutcome:i,onHover:c})},`${d.source}-${d.slug}`))}),jsxRuntime.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#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:l})]})}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:c,minLiquidity:u,markets_limit:m,lang:l,onSelect:f,onSelectOutcome:d,getEventHref:p,LinkComponent:g,onHover:v}){let{data:h,hasMore:x,fetchMore:k,isFetching:S,isFetchingMore:b}=ks({tagSlugSelection:e,limit:t,status:r,sort_by:n,sort_asc:o,source:i,with_markets:a,timeRemaining:s,minVolume:c,minLiquidity:u,markets_limit:m,lang:l});return S?jsxRuntime.jsx($o,{count:24}):jsxRuntime.jsx(Hs,{events:h,hasMore:x,isFetchingMore:b,onFetchMore:k,onSelect:f,onSelectOutcome:d,getEventHref:p,LinkComponent:g,onHover:v})}function $x({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:a,enableKalshi:s=true,lang:c}){let[u,m]=react.useState({categorySlug:null,tagSlug:null}),[l,f]=react.useState(()=>s?sn:{...sn,source:"polymarket"}),{isOpen:d,onOpen:p,onClose:g}=ui.useDisclosure(),{onOpen:v}=uiScaffold.useAsyncModal(on),h=react.useCallback((P,E,D)=>{t?.(P,E,D),v({params:{event:P,market:E,initialOutcome:D,onInsufficientBalance:a}});},[t,v,a]),x=react.useCallback(P=>{m(P);},[]),k=react.useCallback(P=>{f(E=>({...E,sortPreset:P}));},[]),S=react.useCallback(P=>{f(E=>({...E,sortAsc:P}));},[]),b=react.useCallback(P=>{f(P);},[]),y=react.useMemo(()=>vs[l.sortPreset].sort_by,[l.sortPreset]),C=react.useMemo(()=>Uo(l,s),[l,s]),R=react.useMemo(()=>jsxRuntime.jsx(bs,{sortPreset:l.sortPreset,onSortChange:k,sortAsc:l.sortAsc,onSortAscChange:S,onFilterPress:p,filterCount:C}),[l.sortPreset,l.sortAsc,C,k,S,p]);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:x,trailing:R})}),jsxRuntime.jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsxRuntime.jsx(ps,{isOpen:d,onClose:g,value:l,onChange:b,enableKalshi:s}),jsxRuntime.jsx(Ws,{tagSlugSelection:u,lang:c,sort_by:y,sort_asc:l.sortAsc,source:l.source,timeRemaining:l.timeRemaining,minVolume:l.minVolume,minLiquidity:l.minLiquidity,onSelect:e,onSelectOutcome:h,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:`
36
+ `}),jsxRuntime.jsx("div",{className:"evt-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)"},children:e.map((d,p)=>d==null?null:jsxRuntime.jsx("div",{style:{padding:tp,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${p%4*35}ms both`},children:jsxRuntime.jsx(As,{event:d,href:a?.(d),LinkComponent:s,onSelect:o,onSelectOutcome:i,onHover:l})},`${d.source}-${d.slug}`))}),jsxRuntime.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:r&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#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 Us({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:m,lang:c,onSelect:f,onSelectOutcome:d,getEventHref:p,LinkComponent:g,onHover:v}){let{data:h,hasMore:x,fetchMore:S,isFetching:k,isFetchingMore:b}=Ss({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:m,lang:c});return k?jsxRuntime.jsx(Ko,{count:24}):jsxRuntime.jsx(zs,{events:h,hasMore:x,isFetchingMore:b,onFetchMore:S,onSelect:f,onSelectOutcome:d,getEventHref:p,LinkComponent:g,onHover:v})}function $x({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:n,onHover:o,bgImageSrc:i,onInsufficientBalance:a,enableKalshi:s=true,lang:l}){let[u,m]=react.useState({categorySlug:null,tagSlug:null}),[c,f]=react.useState(()=>s?sn:{...sn,source:"polymarket"}),{isOpen:d,onOpen:p,onClose:g}=ui.useDisclosure(),{onOpen:v}=uiScaffold.useAsyncModal(on),h=react.useCallback((P,R,D)=>{t?.(P,R,D),v({params:{event:P,market:R,initialOutcome:D,onInsufficientBalance:a}});},[t,v,a]),x=react.useCallback(P=>{m(P);},[]),S=react.useCallback(P=>{f(R=>({...R,sortPreset:P}));},[]),k=react.useCallback(P=>{f(R=>({...R,sortAsc:P}));},[]),b=react.useCallback(P=>{f(P);},[]),y=react.useMemo(()=>bs[c.sortPreset].sort_by,[c.sortPreset]),N=react.useMemo(()=>$o(c,s),[c,s]),E=react.useMemo(()=>jsxRuntime.jsx(xs,{sortPreset:c.sortPreset,onSortChange:S,sortAsc:c.sortAsc,onSortAscChange:k,onFilterPress:p,filterCount:N}),[c.sortPreset,c.sortAsc,N,S,k,p]);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(Vi,{onSelect:x,trailing:E})}),jsxRuntime.jsxs("div",{style:{padding:"12px 8px 80px"},children:[jsxRuntime.jsx(ms,{isOpen:d,onClose:g,value:c,onChange:b,enableKalshi:s}),jsxRuntime.jsx(Us,{tagSlugSelection:u,lang:l,sort_by:y,sort_asc:c.sortAsc,source:c.source,timeRemaining:c.timeRemaining,minVolume:c.minVolume,minLiquidity:c.minLiquidity,onSelect:e,onSelectOutcome:h,getEventHref:r,LinkComponent:n,onHover:o})]}),jsxRuntime.jsx(Yn,{})]})}function js(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:js,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:js,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: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:c}=reactPredict.useTradeResultConfirmation(),{evmAddress:u}=xr(),m=walletConnector.useWallets(),[l,f]=react.useState("idle"),[d,p]=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(()=>m.find(Y=>Y.chainNamespace===types.ChainNamespace.EVM&&Y.isConnected),[m]),S=qs(r.side,t.outcomes),y=t.outcomes?.[S]?.label??r.side,C=t.result!=null?qs(t.result,t.outcomes):-1,P=(C>=0?t.outcomes?.[C]:void 0)?.label??t.result??"",E=t.result!=null?S===C:true,D=react.useMemo(()=>E?r.size:0,[E,r.size]),U=react.useCallback(async()=>{if(!(!g||!h||!k)){f("pending"),p(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 N=>await Y.request({method:"personal_sign",params:[N,h]}),signTypedData:async N=>await Y.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(N)]})}),f("confirming");let q=zr({messages:x});q.submitted(),await c({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"),p(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,h,v,k,s,x,c,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,n,i]),Q=walletConnector.useAuthCallback(U),B=l==="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:E?"text-green-400":"text-red-400"}),t.result!=null&&jsxRuntime.jsx(eo,{label:i("predict.redeem.result"),value:P,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:`$${D.toFixed(2)}`,valueClassName:D>0?"text-green-400":"text-zinc-400"})]}),!E&&D===0&&jsxRuntime.jsx("p",{className:"text-sm text-zinc-500",children:i("predict.redeem.noWinnings")}),l==="error"&&d&&jsxRuntime.jsx("p",{className:"text-sm text-red-400",children:d}),l==="success"&&jsxRuntime.jsx("p",{className:"text-sm text-green-400",children:i("predict.redeem.success")}),l==="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:[l!=="success"&&l!=="delayed"&&jsxRuntime.jsx(ui.Button,{color:"success",className:"w-full h-12 rounded-xl text-sm font-semibold",isDisabled:!B,isLoading:l==="pending"||l==="confirming",onPress:Q,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),children:i("predict.redeem.confirm")}),o&&l!=="success"&&l!=="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")}),(l==="success"||l==="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:c}=walletConnector.useAuth(),u=walletConnector.useWallets(),m=reactPredict.usePredictClient(),l=react.useContext(reactPredict.PolymarketContext),f=reactQuery.useQueryClient(),{start:d}=reactPredict.useTradeResultConfirmation(),p=e.source,g=p==="polymarket",v=u.find(T=>T.chainNamespace===types.ChainNamespace.SOLANA&&T.isConnected),h=u.find(T=>T.chainNamespace===types.ChainNamespace.EVM&&T.isConnected&&"switchChain"in T),x=c==="authenticated",k=v?.address,S=h?.address,[b,y]=react.useState(t),[C,R]=react.useState("market"),[P,E]=react.useState(NaN),[D,U]=react.useState(NaN),[Q,B]=react.useState(false),[Y,q]=react.useState(false),[te,N]=react.useState(null),[M,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(T,le)=>{let ye=zr({messages:Oe});ye.submitted(),await d({source:p,user:p==="kalshi"?k:S,kalshiUser:k,polymarketUser:S,marketSlug:e.slug,eventSlug:e.event_slug,expectation:T,getOrdersHeaders:le})==="confirmed"?ye.completed():ye.delayed();},[d,S,e.event_slug,e.slug,p,Oe,k]),st=react.useMemo(()=>{if(p!=="polymarket")return;let T=e.provider_meta?.["polymarket.clobTokenIds"];return T?(typeof T=="string"?JSON.parse(T):T)[b==="yes"?0:1]:void 0},[p,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 T=xr();gt=T.kalshiKycVerified,ze=T.kalshiKycUrl,Gt=T.polymarketSetupVerified,Re=T.polymarketSafeAddress,je=T.polymarketWalletKind,ge=T.polymarketWalletAddress;}catch{}let lt=p==="kalshi"&&!gt,ht=p==="polymarket"&&!Gt,Ne=react.useCallback(async()=>{if(!h||!l)return null;let T=await h.getEip1193Provider();if(!T)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 T.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:rt,types:_n,primaryType:Lt,message:_e})]})}};return l.credentials??await l.authenticate(Ye)},[Re,je,ge,h,l]),{data:ut}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:p,outcome:b},{enabled:e.status==="open"}),Ce=react.useMemo(()=>{let T=reactPredict.pickBestBid(ut,b);if(T!=null&&T>0)return T;let le=b==="yes"?0:1,ye=e.outcomes[le];return ye?.best_bid??ye?.price??.5},[ut,e.outcomes,b]),I=p==="kalshi"?k??"":S??"",{data:pe,isLoading:tt}=reactPredict.usePositionsMulti({kalshi_user:p==="kalshi"?I:void 0,polymarket_user:p==="polymarket"?I:void 0},{enabled:!!I,refetchInterval:3e4}),Xr=react.useCallback(async()=>{let T=await Ne();return T?await reactPredict.buildPolymarketL2Headers(T.address,{apiKey:T.apiKey,secret:T.secret,passphrase:T.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[Ne]),{data:A,isLoading:Ge}=reactPredict.useAvailableShares({source:p,user:I,market:e.slug,side:b},p==="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(T=>T.side?.trim().toLowerCase()===Cn&&T.market?.slug===e.slug)??null:null,[pe,e.slug,Cn]),qe=react.useMemo(()=>p==="polymarket"?reactPredict.getPolymarketSharesPrecision(Le):A?.precision??0,[p,Le,A?.precision]),Rr=A?.active_order_shares??0,_r=p==="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(P)||P<=0?"0":String(Math.round(P*1e6)),[P]),To=p==="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(P)||P<=0?0:P,[P]),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(()=>C==="limit"&&g&&!isNaN(D)?D:fr,[C,g,D,fr]),_=react.useMemo(()=>isNaN(P)||P<=0?0:P*gr,[P,gr]),Ae=react.useMemo(()=>p!=="polymarket"?0:Qi({grossReturn:_,pricePerShare:gr,feeRateBps:Number(Mt)}),[p,_,gr,Mt]),We=react.useMemo(()=>Math.max(0,_-Ae),[_,Ae]),Et=react.useCallback(T=>{y(T),U(NaN),E(NaN),q(false);},[]);react.useEffect(()=>{Et(t);},[t,Et]);let en=react.useCallback(T=>{R(T);},[]);react.useEffect(()=>{C==="limit"&&U(Math.round(Ce*1e4)/1e4);},[C,b]);let hr=react.useCallback(T=>{if(q(false),isNaN(T)){E(NaN);return}E(xe(Math.max(0,T),qe));},[qe]),Qt=react.useCallback(()=>{q(true),E(xe(qt,qe));},[qt,qe]),ct=react.useCallback(T=>{if(isNaN(T)){U(NaN);return}U(Math.round(T*1e4)/1e4);},[]),vr=react.useCallback(()=>{E(NaN),U(NaN),R("market"),q(false),Ke(false),w("1h"),Je(30),Ct("minutes");},[]),Ar=react.useMemo(()=>{let T=[];return isNaN(P)||P<=0?T.push(i("predict.trade.minQuantity",{amount:zn})):P<zn&&T.push(i("predict.trade.minQuantity",{amount:zn})),e.status!=="open"&&T.push(i("predict.trade.marketNotActive")),!isNaN(P)&&P>0&&!Y&&P>qt&&T.push(i("predict.trade.insufficientSharesDetail",{total:xe(Ir,qe).toFixed(qe),active:xe(Rr,qe).toFixed(qe),available:xe(qt,qe).toFixed(qe)})),C==="limit"&&g&&(isNaN(D)||D<.01||D>.99)&&T.push(i("predict.trade.limitPriceRange")),C==="limit"&&g&&ae&&Ee==="custom"&&(isNaN(He)||He<=0)&&T.push(i("predict.trade.expiration.invalidDate")),p==="polymarket"&&C==="market"&&!isNaN(P)&&P>0&&(bt.status==="insufficient_liquidity"?T.push(i("predict.trade.insufficientLiquidity",{available:xe(bt.totalAvailable,2)})):bt.status==="exceeds_slippage"&&T.push(i("predict.trade.priceImpactTooHigh",{impact:(bt.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:T.length===0,errors:T}},[P,e.status,qt,Ir,Rr,Y,C,g,D,ae,Ee,He,qe,p,bt,n,i]),{mutateAsync:Xt}=reactPredict.useDFlowSubmit(),{data:Dr}=reactPredict.useOrder({id:te??"",source:p},{enabled:!!te}),En=react.useCallback(async()=>{if(!M||!k||!v)return;let{cashAmount:T,collateral:le}=M;z(null);try{let Ye=(await m.createDFlowQuote({inputMint:le,outputMint:Dt,amount:T,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:T,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[M,k,v,m,Xt,Dt]),Jt=react.useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);react.useEffect(()=>{if(!Dr||!te)return;let{status:T}=Dr;T==="closed"?(N(null),M?En().finally(()=>{B(false),Ve("sell-market"),Jt(),vr(),s.current?.();}):(B(false),Ve("sell-market"),Jt(),vr(),s.current?.())):(T==="failed"||T==="expired")&&(B(false),N(null),z(null),ui.toast.error(i("predict.trade.submitError")));},[Dr,te,M,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}});N(Lt.signature);},[k,v,Zr,Xt,Bt,Yt,Or,Ce,b,e.slug,pr,Dt,i,gt]),Rn=react.useCallback(async()=>{if(!h||!l)return;let T=h.chain,le=T!==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=C==="limit"&&!isNaN(D)?D:fr,Sc=$n(kc,Le),Eo={tokenId:_n,price:Sc,size:P,side:"SELL",orderType:C==="limit"?ae?"GTD":"GTC":"FOK",tickSize:Le,negRisk:Ai,...nt&&{funderAddress:nt},...et&&{builderCode:et},...C==="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 m.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(C==="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&&T&&h.switchChain(T).catch(()=>{});}},[h,l,Ne,b,e.provider_meta,C,Ve,D,fr,P,m,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),N(null),ue(false);try{p==="kalshi"?await Ln():await Rn();}catch(T){let le=T instanceof Error?T.message:"",ye=p==="polymarket"&&le?Kn(le,i,"sell"):le||void 0;ui.toast.error(ye||i("predict.trade.submitError")),B(false);}}},[Ar.isValid,x,p,Ln,Rn,i]);return {outcome:b,orderType:C,quantity:P,limitPrice:D,shares:mr,effectivePrice:gr,grossReturn:_,estimatedFee:Ae,estimatedReturn:We,pricePerShare:Ce,isMarketDataLoading:p==="polymarket"&&(_t||Ze),isSubmitting:Q,authStatus:c,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:c,estimatedFee:u,estimatedReturn:m,isMarketDataLoading:l,isSubmitting:f,authStatus:d,isValid:p,validationErrors:g,supportsLimitOrder:v,kycRequired:h,needsKyc:x,needsSetup:k,onSetupRequired:S,kycUrl:b,totalShares:y,activeOrderShares:C,availableShares:R,isAvailableLoading:P,precision:E,expirationEnabled:D,expirationPreset:U,customDuration:Q,customDurationUnit:B,oddsFormatter:Y,onOutcomeChange:q,onOrderTypeChange:te,onQuantityChange:N,onLimitPriceChange:M,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==="."){M(NaN);return}let tt=parseFloat(I);isNaN(tt)||M(tt/100);},[M]),Mt=react.useCallback(I=>{let pe=new RegExp(`^\\d*\\.?\\d{0,${E}}$`);if(I!==""&&!pe.test(I))return;if(st(I),Je(false),I===""||I==="."){N(NaN);return}let tt=parseFloat(I);isNaN(tt)||N(tt);},[N,E]);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?m/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(P)return w("predict.trade.loadingBalance");if(l)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,P,l,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(!p){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,E);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{N(Math.floor(R*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:P?"\u2013":`${xe(y,E).toFixed(E)}${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:P?"\u2013":C>0?`-${xe(C,E).toFixed(E)}${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:P?"\u2013":`${xe(R,E).toFixed(E)}${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?`$${m.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?`$${c.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?`$${m.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:D,onValueChange:J,"aria-label":w("predict.trade.setExpiration")})]}),D&&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&&(P||l||!Re||f),isLoading:ht||lt&&!Ne&&(f||P||l),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:c,onSuccess:u,oddsFormatter:m}){let{outcome:l,orderType:f,quantity:d,limitPrice:p,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,pricePerShare:k,isMarketDataLoading:S,isSubmitting:b,authStatus:y,validation:C,supportsLimitOrder:R,kycRequired:P,needsKyc:E,needsSetup:D,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:N,expirationPreset:M,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:l==="yes"?k:void 0,noBid:l==="no"?k:void 0}),[t,l,k]);return jsxRuntime.jsx(da,{event:Pe,market:Ze,variant:r,outcome:l,orderType:f,quantity:d,limitPrice:p,effectivePrice:g,grossReturn:v,estimatedFee:h,estimatedReturn:x,isMarketDataLoading:S,isSubmitting:b,authStatus:y,isValid:C.isValid,validationErrors:C.errors,supportsLimitOrder:R,kycRequired:P,needsKyc:E,needsSetup:D,onSetupRequired:c,kycUrl:U,totalShares:Q,activeOrderShares:B,availableShares:Y,isAvailableLoading:q,precision:te,expirationEnabled:N,expirationPreset:M,customDuration:z,customDurationUnit:J,oddsFormatter:m,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(l=>l.slug)??[],[e.markets]),{data:s}=reactPredict.usePositionsMulti({kalshi_user:e.source==="kalshi"?t:void 0,polymarket_user:e.source==="polymarket"?t:void 0}),c=react.useMemo(()=>!s?.positions||!t?0:a.length===0?s.positions.length:s.positions.filter(l=>l.market&&a.includes(l.market.slug)).length,[s?.positions,a,t]),m=[{key:"positions",label:c>0?`${n("predict.positions.title")} (${c})`:n("predict.positions.title")},{key:"orders",label:n("predict.openOrders.title")},{key:"trades",label:n("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:m.map(l=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(l.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",o===l.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:l.label},l.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,c=o.current_price??0,u=i>0?"text-success":i<0?"text-danger":"text-foreground",m=i>0?"+":"",l=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,d=o.size,p=o.size*c,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:l}),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:["$",p.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(c)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",u),children:[m,"$",Math.abs(i).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",m,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:c}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),u=reactPredict.useCancelOrder(),m=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]),l=react.useCallback(h=>{n?n(h.id):u.mutate({source:h.source,id:h.id});},[n,u]),f=m.length,d=f+(c?1:0),p=react.useCallback(h=>h<f,[f]),g=react.useCallback(async()=>{await s();},[s]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:g,rowCount:d,threshold:5});return a?jsxRuntime.jsx(ii,{}):m.length===0&&!c?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:m,itemCount:f,onCancel:l,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 c=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",c?"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]),c=s.length,u=c+(a?1:0),m=react.useCallback(d=>d<c,[c]),l=react.useCallback(async()=>{await i();},[i]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:l,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:c}})]})}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,c=o.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:o.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:o.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children: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:["$",c.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=`
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 Qs({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(),m=walletConnector.useWallets(),[c,f]=react.useState("idle"),[d,p]=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]),S=react.useMemo(()=>m.find(Y=>Y.chainNamespace===types.ChainNamespace.EVM&&Y.isConnected),[m]),k=Ys(r.side,t.outcomes),y=t.outcomes?.[k]?.label??r.side,N=t.result!=null?Ys(t.result,t.outcomes):-1,P=(N>=0?t.outcomes?.[N]:void 0)?.label??t.result??"",R=t.result!=null?k===N:true,D=react.useMemo(()=>R?r.size:0,[R,r.size]),U=react.useCallback(async()=>{if(!(!g||!h||!S)){f("pending"),p(null);try{let Y=await S.getEip1193Provider();if(!Y)throw new Error("EIP-1193 provider unavailable");await s({wallet_address:h,condition_id:g,neg_risk:v,signMessage:async C=>await Y.request({method:"personal_sign",params:[C,h]}),signTypedData:async C=>await Y.request({method:"eth_signTypedData_v4",params:[h,JSON.stringify(C)]})}),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"),p(Y instanceof Error?Y.message:i("predict.redeem.error"));}}},[g,h,v,S,s,x,l,r.source,r.market?.slug,r.event?.slug,t.slug,e?.slug,n,i]),Q=walletConnector.useAuthCallback(U),H=c==="idle"&&!!g&&!!h&&!!S&&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:R?"text-green-400":"text-red-400"}),t.result!=null&&jsxRuntime.jsx(eo,{label:i("predict.redeem.result"),value:P,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:`$${D.toFixed(2)}`,valueClassName:D>0?"text-green-400":"text-zinc-400"})]}),!R&&D===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:!H,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 Ys(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 Js({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(Qs,{event:e.event,market:e.market,position:e.position,onSuccess:()=>{setTimeout(()=>r(false),1500);},onCancel:()=>r(false)})]})})}):null}function ra({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(),m=reactPredict.usePredictClient(),c=react.useContext(reactPredict.PolymarketContext),f=reactQuery.useQueryClient(),{start:d}=reactPredict.useTradeResultConfirmation(),p=e.source,g=p==="polymarket",v=u.find(M=>M.chainNamespace===types.ChainNamespace.SOLANA&&M.isConnected),h=u.find(M=>M.chainNamespace===types.ChainNamespace.EVM&&M.isConnected&&"switchChain"in M),x=l==="authenticated",S=v?.address,k=h?.address,[b,y]=react.useState(t),[N,E]=react.useState("market"),[P,R]=react.useState(NaN),[D,U]=react.useState(NaN),[Q,H]=react.useState(false),[Y,q]=react.useState(false),[te,C]=react.useState(null),[T,B]=react.useState(null),[J,ue]=react.useState(false),[se,Ge]=react.useState(false),[We,st]=react.useState("1h"),[w,gt]=react.useState(30),[Ae,Ue]=react.useState("minutes"),Nt=react.useMemo(()=>Hr(i,a),[a,i]),Pe=react.useCallback(async(M,le)=>{let ke=zr({messages:Nt});ke.submitted(),await d({source:p,user:p==="kalshi"?S:k,kalshiUser:S,polymarketUser:k,marketSlug:e.slug,eventSlug:e.event_slug,expectation:M,getOrdersHeaders:le})==="confirmed"?ke.completed():ke.delayed();},[d,k,e.event_slug,e.slug,p,Nt,S]),at=react.useMemo(()=>{if(p!=="polymarket")return;let M=e.provider_meta?.["polymarket.clobTokenIds"];return M?(typeof M=="string"?JSON.parse(M):M)[b==="yes"?0:1]:void 0},[p,e.provider_meta,b]),{data:qe,isLoading:De}=reactPredict.useTickSize(at),Re=qe?.minimum_tick_size?String(qe.minimum_tick_size):"0.01",{data:_e,isLoading:Ct}=reactPredict.useFeeRate(at),Mt=String(_e?.base_fee??0),{data:At}=reactPredict.useRebateConfig(),ut=At?.builder_enabled&&At.builder_code?At.builder_code:void 0,et=false,Tt=null,lt=false,ht,Ne,ye;try{let M=xr();et=M.kalshiKycVerified,Tt=M.kalshiKycUrl,lt=M.polymarketSetupVerified,ht=M.polymarketSafeAddress,Ne=M.polymarketWalletKind,ye=M.polymarketWalletAddress;}catch{}let Et=p==="kalshi"&&!et,Ye=p==="polymarket"&&!lt,ve=react.useCallback(async()=>{if(!h||!c)return null;let M=await h.getEip1193Provider();if(!M)return null;let le=Ne==="deposit"&&!!ye,ke=!le&&!!ht,Xe={address:h.address,signatureType:le?3:ke?2:0,signTypedData:async(rt,nt,It,Ie)=>{let sr=[];"name"in rt&&sr.push({name:"name",type:"string"}),"version"in rt&&sr.push({name:"version",type:"string"}),"chainId"in rt&&sr.push({name:"chainId",type:"uint256"}),"verifyingContract"in rt&&sr.push({name:"verifyingContract",type:"address"}),"salt"in rt&&sr.push({name:"salt",type:"bytes32"});let _n={EIP712Domain:sr,...nt};return await M.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:rt,types:_n,primaryType:It,message:Ie})]})}};return c.credentials??await c.authenticate(Xe)},[ht,Ne,ye,h,c]),{data:$e}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:p,outcome:b},{enabled:e.status==="open"}),be=react.useMemo(()=>{let M=reactPredict.pickBestBid($e,b);if(M!=null&&M>0)return M;let le=b==="yes"?0:1,ke=e.outcomes[le];return ke?.best_bid??ke?.price??.5},[$e,e.outcomes,b]),Lt=p==="kalshi"?S??"":k??"",{data:Rt,isLoading:I}=reactPredict.usePositionsMulti({kalshi_user:p==="kalshi"?Lt:void 0,polymarket_user:p==="polymarket"?Lt:void 0},{enabled:!!Lt,refetchInterval:3e4}),Me=react.useCallback(async()=>{let M=await ve();return M?await reactPredict.buildPolymarketL2Headers(M.address,{apiKey:M.apiKey,secret:M.secret,passphrase:M.passphrase,method:"GET",requestPath:"/data/orders",body:""}):{}},[ve]),{data:Ce,isLoading:Xr}=reactPredict.useAvailableShares({source:p,user:Lt,market:e.slug,side:b},p==="polymarket"?{getHeaders:Me}:void 0,{enabled:!!Lt&&!!e.slug,refetchOnMount:"always"}),O=e.provider_meta?.["dflow.yesMint"]??"",Te=e.provider_meta?.["dflow.noMint"]??"",tt=utils$1.SOLANA_TOKENS.stablecoins.USDC.address,Jr=e.provider_meta?.["dflow.collateralMint"]||"",Co=b==="yes"?O:Te,Cn=(r||b).trim().toLowerCase(),Lr=react.useMemo(()=>Rt?Rt.positions.find(M=>M.side?.trim().toLowerCase()===Cn&&M.market?.slug===e.slug)??null:null,[Rt,e.slug,Cn]),Qe=react.useMemo(()=>p==="polymarket"?reactPredict.getPolymarketSharesPrecision(Re):Ce?.precision??0,[p,Re,Ce?.precision]),Rr=Ce?.active_order_shares??0,_r=p==="polymarket"&&!!r&&!!Lr?.size&&(Ce?.total_shares??0)<=0&&(Ce?.available_shares??0)<=0,Ht=_r?Lr?.size??0:0,Ir=_r?Ht:Ce?.total_shares??0,Yt=_r?Math.max(0,Ht-Rr):Ce?.available_shares??0,Mn=Xr||I,Tn=Lr?.market?.provider_meta,Mo=Tn?.["dflow.outcomeMint"]||Co,pr=Tn?.["dflow.collateralMint"]||Jr,zt=Mo,Qt=pr||tt,Or=react.useMemo(()=>isNaN(P)||P<=0?"0":String(Math.round(P*1e6)),[P]),To=p==="kalshi"&&!!zt&&!!Qt&&!!S&&Or!=="0",{refetch:Zr}=reactPredict.useDFlowQuote({inputMint:zt,outputMint:Qt,amount:Or,userPublicKey:S??"",slippageBps:100},{enabled:To}),mr=react.useMemo(()=>isNaN(P)||P<=0?0:P,[P]),vt=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:$e,outcome:b,side:"sell",sharesNeeded:mr,slippageBps:n}),[$e,b,mr,n]),fr=react.useMemo(()=>vt.status==="ok"&&vt.worstPrice!=null&&vt.worstPrice>0?vt.worstPrice:be,[vt,be]),gr=react.useMemo(()=>N==="limit"&&g&&!isNaN(D)?D:fr,[N,g,D,fr]),_=react.useMemo(()=>isNaN(P)||P<=0?0:P*gr,[P,gr]),Fe=react.useMemo(()=>p!=="polymarket"?0:Ji({grossReturn:_,pricePerShare:gr,feeRateBps:Number(Mt)}),[p,_,gr,Mt]),Ke=react.useMemo(()=>Math.max(0,_-Fe),[_,Fe]),_t=react.useCallback(M=>{y(M),U(NaN),R(NaN),q(false);},[]);react.useEffect(()=>{_t(t);},[t,_t]);let en=react.useCallback(M=>{E(M);},[]);react.useEffect(()=>{N==="limit"&&U(Math.round(be*1e4)/1e4);},[N,b]);let hr=react.useCallback(M=>{if(q(false),isNaN(M)){R(NaN);return}R(xe(Math.max(0,M),Qe));},[Qe]),Xt=react.useCallback(()=>{q(true),R(xe(Yt,Qe));},[Yt,Qe]),ct=react.useCallback(M=>{if(isNaN(M)){U(NaN);return}U(Math.round(M*1e4)/1e4);},[]),vr=react.useCallback(()=>{R(NaN),U(NaN),E("market"),q(false),Ge(false),st("1h"),gt(30),Ue("minutes");},[]),Ar=react.useMemo(()=>{let M=[];return isNaN(P)||P<=0?M.push(i("predict.trade.minQuantity",{amount:zn})):P<zn&&M.push(i("predict.trade.minQuantity",{amount:zn})),e.status!=="open"&&M.push(i("predict.trade.marketNotActive")),!isNaN(P)&&P>0&&!Y&&P>Yt&&M.push(i("predict.trade.insufficientSharesDetail",{total:xe(Ir,Qe).toFixed(Qe),active:xe(Rr,Qe).toFixed(Qe),available:xe(Yt,Qe).toFixed(Qe)})),N==="limit"&&g&&(isNaN(D)||D<.01||D>.99)&&M.push(i("predict.trade.limitPriceRange")),N==="limit"&&g&&se&&We==="custom"&&(isNaN(w)||w<=0)&&M.push(i("predict.trade.expiration.invalidDate")),p==="polymarket"&&N==="market"&&!isNaN(P)&&P>0&&(vt.status==="insufficient_liquidity"?M.push(i("predict.trade.insufficientLiquidity",{available:xe(vt.totalAvailable,2)})):vt.status==="exceeds_slippage"&&M.push(i("predict.trade.priceImpactTooHigh",{impact:(vt.priceImpactBps/100).toFixed(2),slippage:(n/100).toFixed(2)}))),{isValid:M.length===0,errors:M}},[P,e.status,Yt,Ir,Rr,Y,N,g,D,se,We,w,Qe,p,vt,n,i]),{mutateAsync:Jt}=reactPredict.useDFlowSubmit(),{data:Dr}=reactPredict.useOrder({id:te??"",source:p},{enabled:!!te}),En=react.useCallback(async()=>{if(!T||!S||!v)return;let{cashAmount:M,collateral:le}=T;B(null);try{let Xe=(await m.createDFlowQuote({inputMint:le,outputMint:tt,amount:M,userPublicKey:S,slippageBps:100}))?.transaction;if(!Xe)return;let rt=Uint8Array.from(atob(Xe),It=>It.charCodeAt(0)),nt=await v.signTransaction(rt);await Jt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:S,input_mint:le,output_mint:tt,amount:M,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[T,S,v,m,Jt,tt]),Zt=react.useCallback(()=>{f.invalidateQueries({queryKey:["predict","available-shares"]});},[f]);react.useEffect(()=>{if(!Dr||!te)return;let{status:M}=Dr;M==="closed"?(C(null),T?En().finally(()=>{H(false),Pe("sell-market"),Zt(),vr(),s.current?.();}):(H(false),Pe("sell-market"),Zt(),vr(),s.current?.())):(M==="failed"||M==="expired")&&(H(false),C(null),B(null),ui.toast.error(i("predict.trade.submitError")));},[Dr,te,T,En,Pe,Zt,vr,i]);let Ln=react.useCallback(async()=>{if(!S||!v)return;if(!zt||!Qt){ui.toast.error("Missing token mint addresses"),H(false);return}if(!et){ue(true),H(false);return}let ke=(await Zr()).data,Xe=ke?.transaction;if(!Xe){ui.toast.error(i("predict.trade.submitError")),H(false);return}if(pr&&pr!==tt){let Ie=String(ke?.outAmount??"");Ie&&Ie!=="0"&&B({cashAmount:Ie,collateral:pr});}let rt=Uint8Array.from(atob(Xe),Ie=>Ie.charCodeAt(0)),nt=await v.signTransaction(rt),It=await Jt({signedTransaction:btoa(String.fromCharCode(...nt)),orderContext:{user_public_key:S,input_mint:zt,output_mint:Qt,amount:Or,price:String(be),side:"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});C(It.signature);},[S,v,Zr,Jt,zt,Qt,Or,be,b,e.slug,pr,tt,i,et]),Rn=react.useCallback(async()=>{if(!h||!c)return;let M=h.chain,le=M!==types.Chain.POLYGON;le&&await h.switchChain(types.Chain.POLYGON);try{let ke=await h.getEip1193Provider();if(!ke){ui.toast.error(i("predict.trade.submitError")),H(!1);return}let Xe=Ne==="deposit"&&!!ye,rt=!Xe&&!!ht,nt=Xe?ye:ht,It={address:h.address,signatureType:Xe?3:rt?2:0,signTypedData:async(Wt,On,Ro,_o)=>{let Fr=[];"name"in Wt&&Fr.push({name:"name",type:"string"}),"version"in Wt&&Fr.push({name:"version",type:"string"}),"chainId"in Wt&&Fr.push({name:"chainId",type:"uint256"}),"verifyingContract"in Wt&&Fr.push({name:"verifyingContract",type:"address"}),"salt"in Wt&&Fr.push({name:"salt",type:"bytes32"});let wc={EIP712Domain:Fr,...On};return await ke.request({method:"eth_signTypedData_v4",params:[h.address,JSON.stringify({domain:Wt,types:wc,primaryType:Ro,message:_o})]})}},Ie=await ve();if(!Ie){ui.toast.error(i("predict.trade.submitError")),H(!1);return}let sr=b==="yes"?0:1,_n="",In=e.provider_meta?.["polymarket.clobTokenIds"];In&&(_n=(typeof In=="string"?JSON.parse(In):In)[sr]??"");let Fi=e.provider_meta?.["polymarket.negRisk"]??!1,kc=N==="limit"&&!isNaN(D)?D:fr,Sc=$n(kc,Re),Eo={tokenId:_n,price:Sc,size:P,side:"SELL",orderType:N==="limit"?se?"GTD":"GTC":"FOK",tickSize:Re,negRisk:Fi,...nt&&{funderAddress:nt},...ut&&{builderCode:ut},...N==="limit"&&se&&{expiration:Un(We,w,Ae)}},Lo;if(Xe)Lo=await reactPredict.buildSignedV2OrderPayload({signer:It,depositWalletAddress:nt,input:Eo,owner:Ie.apiKey});else {let Wt=reactPredict.buildCtfExchangeDomain(Fi),On=reactPredict.buildOrderMessage({...Eo,signerAddress:It.address,signatureType:It.signatureType,feeRateBps:Mt}),Ro=await It.signTypedData(Wt,reactPredict.CTF_ORDER_TYPES,"Order",On),_o=reactPredict.buildSignedOrder(On,Ro,Eo.orderType);Lo=reactPredict.buildClobPayload(_o,Ie.apiKey);}await m.executePolymarketOrder({payload:Lo,l2_api_key:Ie.apiKey,l2_secret:Ie.secret,l2_passphrase:Ie.passphrase,signer_address:Ie.address,owner:Ie.apiKey}),Zt(),Pe(N==="limit"?"sell-limit":"sell-market",async()=>await reactPredict.buildPolymarketL2Headers(Ie.address,{apiKey:Ie.apiKey,secret:Ie.secret,passphrase:Ie.passphrase,method:"GET",requestPath:"/data/orders"})),vr(),H(!1),s.current?.();}finally{le&&M&&h.switchChain(M).catch(()=>{});}},[h,c,ve,b,e.provider_meta,N,Pe,D,fr,P,m,Zt,se,We,w,Ae,vr,i,Re,Mt,e.slug,ht,Ne,ye,ut]),tn=react.useCallback(async()=>{if(!(!Ar.isValid||!x)){H(true),C(null),ue(false);try{p==="kalshi"?await Ln():await Rn();}catch(M){let le=M instanceof Error?M.message:"",ke=p==="polymarket"&&le?Kn(le,i,"sell"):le||void 0;ui.toast.error(ke||i("predict.trade.submitError")),H(false);}}},[Ar.isValid,x,p,Ln,Rn,i]);return {outcome:b,orderType:N,quantity:P,limitPrice:D,shares:mr,effectivePrice:gr,grossReturn:_,estimatedFee:Fe,estimatedReturn:Ke,pricePerShare:be,isMarketDataLoading:p==="polymarket"&&(Ct||De),isSubmitting:Q,authStatus:l,validation:Ar,supportsLimitOrder:g,kycRequired:J,needsKyc:Et,needsSetup:Ye,kycUrl:Tt,totalShares:Ir,activeOrderShares:Rr,availableShares:Yt,isAvailableLoading:Mn,isSellAll:Y,precision:Qe,expirationEnabled:se,expirationPreset:We,customDuration:w,customDurationUnit:Ae,setOutcome:_t,setOrderType:en,setQuantity:hr,setLimitPrice:ct,setSellAll:Xt,setExpirationEnabled:Ge,setExpirationPreset:st,setCustomDuration:gt,setCustomDurationUnit:Ue,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:m,isMarketDataLoading:c,isSubmitting:f,authStatus:d,isValid:p,validationErrors:g,supportsLimitOrder:v,kycRequired:h,needsKyc:x,needsSetup:S,onSetupRequired:k,kycUrl:b,totalShares:y,activeOrderShares:N,availableShares:E,isAvailableLoading:P,precision:R,expirationEnabled:D,expirationPreset:U,customDuration:Q,customDurationUnit:H,oddsFormatter:Y,outcomeLabels:q,onOutcomeChange:te,onOrderTypeChange:C,onQuantityChange:T,onLimitPriceChange:B,onSellAll:J,onExpirationEnabledChange:ue,onExpirationPresetChange:se,onCustomDurationChange:Ge,onCustomDurationUnitChange:We,onSubmit:st}){let{t:w}=i18n.useTranslation(),[gt,Ae]=react.useState(false),[Ue,Nt]=react.useState(true),Pe=ui.useDisclosure(),[at,qe]=react.useState(""),De=react.useRef(false);react.useEffect(()=>{De.current||qe(isNaN(i)?"":String(i));},[i]);let[Re,_e]=react.useState(""),Ct=react.useRef(false);react.useEffect(()=>{Ct.current||(isNaN(a)?_e(""):_e(String(parseFloat((a*100).toFixed(2)))));},[a]);let Mt=react.useCallback(I=>{if(I!==""&&!/^\d*\.?\d{0,2}$/.test(I))return;if(_e(I),I===""||I==="."){B(NaN);return}let Ce=parseFloat(I);isNaN(Ce)||B(Ce/100);},[B]),At=react.useCallback(I=>{let Me=new RegExp(`^\\d*\\.?\\d{0,${R}}$`);if(I!==""&&!Me.test(I))return;if(qe(I),Ae(false),I===""||I==="."){T(NaN);return}let Ce=parseFloat(I);isNaN(Ce)||T(Ce);},[T,R]);react.useEffect(()=>{h&&!Pe.isOpen&&Pe.onOpen();},[h]);let ut=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,Tt=et!=null&&Y?Y(Number(et)):ut!=null?`${ut} \xA2`:null,lt=Number.isFinite(s)?parseFloat((s*100).toFixed(2)):null,ht=Number.isFinite(s)&&Y?Y(s):lt!=null?`${lt} \xA2`:null,Ne=!isNaN(i)&&i>0,ye=Ne&&i>0?m/i:0,Et=ye>0&&Y?Y(ye):ye>0?`${parseFloat((ye*100).toFixed(2))} \xA2`:dn,Ye=d==="authenticated",ve=d==="authenticating"||d==="deauthenticating",$e=Ye&&(x||S),be=react.useCallback(I=>q?.[I]??w(I==="yes"?"predict.trade.yes":"predict.trade.no"),[q,w]),Lt=react.useMemo(()=>{if(ve)return w("predict.trade.checkingLogin");if(!Ye)return w("predict.trade.loginToTrade");if(x)return w("predict.trade.kycRequired");if(S)return w("predict.trade.setupRequired");if(P)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(!Ne)return w("predict.trade.enterAmount");let I=be(n);return `${w("predict.trade.sell")} ${I}`},[ve,Ye,x,S,P,c,f,h,Ne,n,be,w]),Rt=()=>{if(!Ye){Ae(false),st();return}if(x){Pe.onOpen();return}if(S&&k){Ae(false),k();return}if(h){Pe.onOpen();return}if(!p){Ae(true);return}Ae(false),st();};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")," ",be(n)]}),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=>C(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:Re,onChange:I=>Mt(I.target.value),onFocus:()=>{Ct.current=true;},onBlur:()=>{Ct.current=false,isNaN(a)?_e(""):_e(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(I=>{let Me=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:()=>te(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:be(I)}),Me!=null&&jsxRuntime.jsx("span",{className:"ml-1 opacity-70",children:Y?Y(Number(Me)):`${parseFloat((Number(Me)*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 Me=Math.pow(10,R);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{T(Math.floor(E*I/100*Me)/Me);},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:J,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:at,onChange:I=>At(I.target.value),onFocus:()=>{De.current=true;},onBlur:()=>{De.current=false,qe(isNaN(i)?"":String(i));},classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),gt&&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:P?"\u2013":`${xe(y,R).toFixed(R)}${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:P?"\u2013":N>0?`-${xe(N,R).toFixed(R)}${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:P?"\u2013":`${xe(E,R).toFixed(R)}${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?`$${m.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:()=>Nt(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",Ue&&"rotate-180")})]}),jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:Y&&Number.isFinite(s)?ht:lt!=null?w("predict.trade.chance",{percent:lt}):dn})]}),Ue&&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:Ne?`$${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:Ne?`$${m.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:Et})]})]})]}),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:D,onValueChange:ue,"aria-label":w("predict.trade.setExpiration")})]}),D&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":w("predict.trade.setExpiration"),selectedKeys:[U],onSelectionChange:I=>{let Me=Array.from(I)[0];Me&&se(Me);},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:Ge,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:[H],onSelectionChange:I=>{let Me=Array.from(I)[0];Me&&We(Me);},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:ve||Ye&&!$e&&(P||c||!Ne||f),isLoading:ve||Ye&&!$e&&(f||P||c),spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:Rt,children:Lt})]}),jsxRuntime.jsx(jn,{isOpen:Pe.isOpen,onClose:Pe.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:m,outcomeLabels:c}){let{outcome:f,orderType:d,quantity:p,limitPrice:g,effectivePrice:v,grossReturn:h,estimatedFee:x,estimatedReturn:S,pricePerShare:k,isMarketDataLoading:b,isSubmitting:y,authStatus:N,validation:E,supportsLimitOrder:P,kycRequired:R,needsKyc:D,needsSetup:U,kycUrl:Q,totalShares:H,activeOrderShares:Y,availableShares:q,isAvailableLoading:te,precision:C,expirationEnabled:T,expirationPreset:B,customDuration:J,customDurationUnit:ue,setOutcome:se,setOrderType:Ge,setQuantity:We,setLimitPrice:st,setSellAll:w,setExpirationEnabled:gt,setExpirationPreset:Ae,setCustomDuration:Ue,setCustomDurationUnit:Nt,submit:Pe}=ra({market:t,initialOutcome:n,initialPositionSide:o,slippageBps:a,onSuccess:u}),at=walletConnector.useAuthCallback(Pe),qe=react.useCallback(_e=>{se(_e),s?.(_e);},[se,s]),De=react.useMemo(()=>e?Dn(e):void 0,[e]),Re=react.useMemo(()=>Fn(t,{yesBid:f==="yes"?k:void 0,noBid:f==="no"?k:void 0}),[t,f,k]);return jsxRuntime.jsx(da,{event:De,market:Re,variant:r,outcome:f,orderType:d,quantity:p,limitPrice:g,effectivePrice:v,grossReturn:h,estimatedFee:x,estimatedReturn:S,isMarketDataLoading:b,isSubmitting:y,authStatus:N,isValid:E.isValid,validationErrors:E.errors,supportsLimitOrder:P,kycRequired:R,needsKyc:D,needsSetup:U,onSetupRequired:l,kycUrl:Q,totalShares:H,activeOrderShares:Y,availableShares:q,isAvailableLoading:te,precision:C,expirationEnabled:T,expirationPreset:B,customDuration:J,customDurationUnit:ue,oddsFormatter:m,outcomeLabels:c,onOutcomeChange:qe,onOrderTypeChange:Ge,onQuantityChange:We,onLimitPriceChange:st,onSellAll:w,onExpirationEnabledChange:gt,onExpirationPresetChange:Ae,onCustomDurationChange:Ue,onCustomDurationUnitChange:Nt,onSubmit:at})}var ti="predict-sell";function pa({id:e=ti}){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 oi=40,so=36,mn=480,ii=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]),m=[{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:m.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(ai,{}):a.length===0?jsxRuntime.jsx(si,{message:n("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height: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:ii},rowComponent:Tm,rowCount:a.length,rowHeight:oi,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",m=i>0?"+":"",c=o.market?.outcomes?.[0]?.label??o.market?.question??"\u2014",f=o.side,d=o.size,p=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:["$",p.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:[m,"$",Math.abs(i).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",m,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(),m=react.useMemo(()=>{let h=i?.pages?.flatMap(k=>k.items)??[],x=new Set(["live","open","submitted","pending"]),S=h.filter(k=>x.has(k.status));return r.length>0&&(S=S.filter(k=>k.market_id&&r.includes(k.market_id))),S},[i?.pages,r]),c=react.useCallback(h=>{n?n(h.id):u.mutate({source:h.source,id:h.id});},[n,u]),f=m.length,d=f+(l?1:0),p=react.useCallback(h=>h<f,[f]),g=react.useCallback(async()=>{await s();},[s]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:g,rowCount:d,threshold:5});return a?jsxRuntime.jsx(ai,{}):m.length===0&&!l?jsxRuntime.jsx(si,{message:o("predict.openOrders.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height: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:ii},onRowsRendered:v,rowComponent:Lm,rowCount:d,rowHeight:oi,rowProps:{orders:m,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),m=react.useCallback(d=>d<l,[l]),c=react.useCallback(async()=>{await i();},[i]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:c,rowCount:u,threshold:5});return o?jsxRuntime.jsx(ai,{}):s.length===0&&!a?jsxRuntime.jsx(si,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height: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:ii},onRowsRendered:f,rowComponent:Im,rowCount:u,rowHeight:oi,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 si({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:mn},children:e})}function ai(){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 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 p=Math.round(d.price*100);p>=0&&p<=100&&(r[p]+=d.quantity);}for(let d of t){let p=Math.round(d.price*100);p>=0&&p<=100&&(n[p]+=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 c=0,u=0,m=new Float64Array(101),l=new Float64Array(101);for(let d=0;d<=100;d++)c+=n[d],u+=n[d]*d/100,m[d]=c,l[d]=u;let f=Math.max(a[0]??0,m[100]??0);return Array.from({length:101},(d,p)=>{let g=a[p]>0,v=m[p]>0,h=a[p]||m[p],x=r[p]>0||n[p]>0;return {priceCents:p,displayHeight:Bm(h,f),opacity:h>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[p],askCumTotal:m[p],bidCumCost:s[p],askCumCost:l[p]}})}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 l=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((l+f)/2*100)},[e,t]),i=react.useMemo(()=>n.some(l=>l.isBid||l.isAsk),[n]),[a,s]=react.useState(null),c=react.useRef(null),u=react.useCallback((l,f)=>{c.current&&(c.current.style.filter=""),f?(f.style.filter="brightness(1.5)",c.current=f):c.current=null,l.isBid||l.isAsk?s({priceCents:l.priceCents,isBid:l.isBid,cumTotal:l.isBid?l.bidCumTotal:l.askCumTotal,cumCost:l.isBid?l.bidCumCost:l.askCumCost,leftPct:l.priceCents}):s(null);},[]),m=react.useCallback(()=>{c.current&&(c.current.style.filter="",c.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(l=>jsxRuntime.jsx(Wm,{slot:l,onEnter:u,onLeave:m},l.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,c]=react.useState(n),u=i??Ra,m=e.source,{data:l,isLoading:f,isFetching:d,refetch:p}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:m,outcome:t}),g=react.useMemo(()=>(l?.bids??[]).map(S=>({price:S.price,quantity:S.size})),[l?.bids]),v=react.useMemo(()=>(l?.asks??[]).map(S=>({price:S.price,quantity:S.size})),[l?.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:()=>c(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:()=>p(),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,c=t.length>ai||e.length>ai,u=react.useMemo(()=>[...t].sort((d,p)=>d.price-p.price).slice(0,s).reverse(),[t,s]),m=react.useMemo(()=>[...e].sort((d,p)=>p.price-d.price).slice(0,s),[e,s]),l=react.useMemo(()=>{let d=[...u,...m].map(p=>p.quantity);return Math.max(...d,1)},[u,m]);return u.length===0&&m.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:l,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`]}),c&&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")})]}),m.map(d=>jsxRuntime.jsx(Ta,{price:d.price,quantity:d.quantity,side:"bid",maxQty:l,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",c=i?"text-bearish":"text-bullish",u=gn(Math.round(t)),m=Math.round(t*e),l=`$${gn(m)}`;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 ${c}`,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:l})]})}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(),c=(o.clientX-s.left)/s.width*100;a.style.background=`linear-gradient(to right, transparent ${c}%, rgba(0,0,0,0.55) ${c}%)`,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(c=>a.set(c.dataKey,c));let s=o.map(c=>a.get(c.slug)??{dataKey:c.slug,value:void 0,stroke:c.color,color:c.color});return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?cf(r,i):r}),s.map(c=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:c.stroke??c.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:n.get(c.dataKey)??c.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:c.value!=null?Aa(c.value):"--"})]},c.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(m){a.current&&!a.current.contains(m.target)&&i(false);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[o]);let s=t.length>=hn,c=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(u=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(u)??"#6b7280",display:"inline-block"}},u))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let u=e.find(m=>m.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:[c,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),o&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",hn," markets"]}),e.map((u,m)=>{let l=t.includes(u.slug),f=!l&&s,d=l&&t.length===1,p=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:l?"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=l?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:l?`2px solid ${p}`:"2px solid rgba(255,255,255,0.2)",background:l?`${p}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:l&&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:p,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:l?"#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:p,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${m}-${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),c=s.map(u=>u.price).sort((u,m)=>u-m);r.push({timestamp:s[s.length-1].timestamp,price:hf(c)});}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(c=>n.add(c.timestamp)));let o=Array.from(n).sort((s,c)=>s-c),i=r.map(s=>{let c=new Map;return s.data.forEach(u=>c.set(u.timestamp,u.price)),{slug:s.marketSlug,map:c}}),a=new Map;return o.map(s=>{let c={timestamp:s};return i.forEach(({slug:u,map:m})=>{let l=m.get(s);if(l!==void 0)a.set(u,l),c[u]=l;else {let f=a.get(u);f!==void 0&&(c[u]=f);}}),c})}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 N=new Set;return (e.markets??[]).filter(M=>N.has(M.slug)?false:(N.add(M.slug),true))},[e.markets]),a=react.useMemo(()=>[...i].sort((N,M)=>{let z=J=>(J.outcomes.find(ue=>ue.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return z(M)-z(N)}),[i]),[s,c]=react.useState(()=>a.slice(0,hn).map(N=>N.slug));react.useEffect(()=>{let N=new Set(i.map(M=>M.slug));c(M=>{let z=M.filter(J=>N.has(J));return z.length===M.length?M:z.length>0?z:a.slice(0,hn).map(J=>J.slug)});},[i,a]);let[u,m]=react.useState(Hn),l=react.useMemo(()=>{let N=new Map;return s.forEach((M,z)=>{N.set(M,Ia[z%Ia.length]);}),N},[s]),f=react.useMemo(()=>i.filter(N=>s.includes(N.slug)),[i,s]),{series:d,isLoading:p}=reactPredict.useMarketHistory(f,u),g=t||p,v=react.useMemo(()=>{if(d.length>0&&d.some(z=>z.data.length>0))return d;let N=Date.now(),M=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:N-7*M,price:ue},{timestamp:N,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 N=1/0,M=-1/0;if(s.forEach(J=>{x.forEach(ue=>{let ae=ue[J];ae!=null&&(ae<N&&(N=ae),ae>M&&(M=ae));});}),!isFinite(N))return [0,1];let z=Math.max((M-N)*.15,.05);return [Math.max(0,N-z),Math.min(1,M+z)]},[x,s]),S=react.useMemo(()=>{let N=new Map;return v.forEach(M=>{M.data.length>0&&N.set(M.marketSlug,M.data[M.data.length-1].price);}),N},[v]),b=react.useMemo(()=>{let N=new Map;return v.forEach(M=>N.set(M.marketSlug,M.label)),N},[v]),y=react.useMemo(()=>v.map(N=>({slug:N.marketSlug,color:l.get(N.marketSlug)??"#6b7280"})),[v,l]),{wrapperRef:C,overlayRef:R,onMouseMove:P,onMouseLeave:E}=pf(),D=react.useCallback(N=>{c(M=>M.includes(N)?M.length<=1?M:M.filter(z=>z!==N):M.length>=hn?M:[...M,N]);},[]),[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:l,displayValues:U??S}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,...o?{flex:1,minHeight:0}:null},children:[jsxRuntime.jsx("div",{ref:C,style:{width:"100%",userSelect:"none",position:"relative",...o?{flex:1,minHeight:240}:{height:300}},onMouseMove:te?N=>{P(N),cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{Q(B.current);});}:void 0,onMouseLeave:te?()=>{E(),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:R,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:x,margin:{top:8,right:16,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:N=>lf(N,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:k,tickFormatter:N=>`${Math.round(N*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:N=>{let M=N;if(M.active&&M.payload?.length){let z=M.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if(z!==Y.current){Y.current=z;let J=new Map;M.payload.forEach(ue=>{ue.value!=null&&J.set(ue.dataKey,ue.value);}),B.current=J;}}return jsxRuntime.jsx(mf,{...M,labelMap:b,allSeries:y,range:u})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),v.map(N=>{let M=l.get(N.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:N.marketSlug,stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:M},connectNulls:true,isAnimationActive:false},N.marketSlug)}),U==null&&x.length>0&&v.map(N=>{let M=x[x.length-1],z=M[N.marketSlug];if(z==null)return null;let J=l.get(N.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:M.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-${N.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:m}),a.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(ff,{markets:a,selectedSlugs:s,colorMap:l,onToggle:D})})]})]})]})}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 m=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(m)},[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),c=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(c).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(),c=s>=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${c}${u})`}function Va({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:n,isCollapsed:o}=hooks.useScrollCollapse(),i=react.useMemo(()=>{let l=[...e.markets||[]],f=l.filter(p=>p.status==="open").sort((p,g)=>co(g)-co(p)),d=l.filter(p=>p.status!=="open").sort((p,g)=>co(g)-co(p));return [...f,...d]},[e.markets]),a=e.status==="closed"||e.status==="voided",s=za(a?void 0:e.start_at),c=za(a?void 0:e.end_at),u=Wa(e.start_at),m=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((l,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:l.label})]},l.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||c||a)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?m&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:m})}):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})]})]}):c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:c})}),m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:m})]})]}):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),c=react.useMemo(()=>{let v=new Set;return e.filter(h=>v.has(h.slug)?false:(v.add(h.slug),true))},[e]),u=c.find(v=>v.status==="open")?.slug,[m,l]=react.useState(u?`${u}:yes`:null);if(c.length===0)return null;let f=c.length>Ua,d=o?c:c.slice(0,Ua),p=v=>{s(h=>h===v?null:v);},g=(v,h,x)=>{l(`${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:m===`${v.slug}:yes`,activeNo:m===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>p(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",c=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:m}=reactPredict.useOrderbook({slug:e.slug,source:e.source,outcome:"no"},{enabled:false,refetchInterval:false}),l=reactPredict.pickBestAsk(u,"yes")??Ba(e,"yes")??0,f=reactPredict.pickBestAsk(m,"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)}),c&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:c})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Af(l)}),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(l)})}),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,c]=react.useState(0),u=e.filter(d=>d.rules&&d.rules.length>0||d.description);if(u.length===0)return null;let m=u[s]??u[0],l=m.rules&&m.rules.length>0?m.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 fe(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:{...fe(0),height:14,width:48}}),jsxRuntime.jsx("div",{style:{...fe(30),height:14,width:40}}),jsxRuntime.jsx("div",{style:{...fe(60),height:14,width:40}})]}),jsxRuntime.jsx("div",{style:{...fe(80),height:20,width:"80%",maxWidth:384,borderRadius:4}})]})]}),jsxRuntime.jsx("div",{style:{...fe(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:{...fe(120),height:16,width:96}}),jsxRuntime.jsx("div",{style:{...fe(140),height:16,width:80}})]}),jsxRuntime.jsx("div",{style:{...fe(160),height:300,width:"100%",borderRadius:12}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("div",{style:{...fe(180),height:16,width:80}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...fe(200),height:28,width:200,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...fe(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:{...fe(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:{...fe(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:{...fe(280+n*40),height:14,width:n%2===0?192:160}}),jsxRuntime.jsx("div",{style:{...fe(300+n*40),height:10,width:64}})]}),jsxRuntime.jsx("div",{style:{...fe(320+n*40),height:16,width:40}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsx("div",{style:{...fe(340+n*40),height:32,width:80,borderRadius:8}}),jsxRuntime.jsx("div",{style:{...fe(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:{...fe(400),height:16,width:64}}),jsxRuntime.jsx("div",{style:{...fe(420),height:14,width:"100%"}}),jsxRuntime.jsx("div",{style:{...fe(440),height:14,width:"80%"}}),jsxRuntime.jsx("div",{style:{...fe(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:{...fe(0),height:40,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...fe(60),height:96,width:"100%",borderRadius:8}}),jsxRuntime.jsx("div",{style:{...fe(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 p=Math.round(d.price*100);p>=0&&p<=100&&(r[p]+=d.quantity);}for(let d of t){let p=Math.round(d.price*100);p>=0&&p<=100&&(n[p]+=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,m=new Float64Array(101),c=new Float64Array(101);for(let d=0;d<=100;d++)l+=n[d],u+=n[d]*d/100,m[d]=l,c[d]=u;let f=Math.max(a[0]??0,m[100]??0);return Array.from({length:101},(d,p)=>{let g=a[p]>0,v=m[p]>0,h=a[p]||m[p],x=r[p]>0||n[p]>0;return {priceCents:p,displayHeight:Bm(h,f),opacity:h>0?x?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[p],askCumTotal:m[p],bidCumCost:s[p],askCumCost:c[p]}})}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);},[]),m=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:m},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,m=e.source,{data:c,isLoading:f,isFetching:d,refetch:p}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:m,outcome:t}),g=react.useMemo(()=>(c?.bids??[]).map(k=>({price:k.price,quantity:k.size})),[c?.bids]),v=react.useMemo(()=>(c?.asks??[]).map(k=>({price:k.price,quantity:k.size})),[c?.asks]),h=react.useMemo(()=>g.length>0?Math.max(...g.map(k=>k.price)):null,[g]),x=react.useMemo(()=>v.length>0?Math.min(...v.map(k=>k.price)):null,[v]),S=react.useMemo(()=>{if(h==null||x==null)return null;let k=(x-h)*100;return Math.round(k*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:S!=null?`${a("predict.orderBook.spread")}: ${Number.isInteger(S)?`${S}\xA2`:`${S.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(k=>k==="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:()=>p(),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:S??void 0,oddsFormatter:i})})]})]})}var ci=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:ci,l=t.length>ci||e.length>ci,u=react.useMemo(()=>[...t].sort((d,p)=>d.price-p.price).slice(0,s).reverse(),[t,s]),m=react.useMemo(()=>[...e].sort((d,p)=>p.price-d.price).slice(0,s),[e,s]),c=react.useMemo(()=>{let d=[...u,...m].map(p=>p.quantity);return Math.max(...d,1)},[u,m]);return u.length===0&&m.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")})]}),m.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)),m=Math.round(t*e),c=`$${gn(m)}`;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 pi=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(m){a.current&&!a.current.contains(m.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(m=>m.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,m)=>{let c=t.includes(u.slug),f=!c&&s,d=c&&t.length===1,p=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 ${p}`:"2px solid rgba(255,255,255,0.2)",background:c?`${p}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:p,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p,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:p,fontWeight:700,fontSize:12,flexShrink:0},children:v})]},u.id??`${m}-${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,m)=>u-m);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:m})=>{let c=m.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(pi,{children:jsxRuntime.jsx(xf,{...e})})}function xf({event:e,isLoading:t,className:r,volume:n,fillHeight:o=false}){let i=react.useMemo(()=>{let C=new Set;return (e.markets??[]).filter(T=>C.has(T.slug)?false:(C.add(T.slug),true))},[e.markets]),a=react.useMemo(()=>[...i].sort((C,T)=>{let B=J=>(J.outcomes.find(ue=>ue.label.toLowerCase()==="yes")??J.outcomes[0])?.price??0;return B(T)-B(C)}),[i]),[s,l]=react.useState(()=>a.slice(0,hn).map(C=>C.slug));react.useEffect(()=>{let C=new Set(i.map(T=>T.slug));l(T=>{let B=T.filter(J=>C.has(J));return B.length===T.length?T:B.length>0?B:a.slice(0,hn).map(J=>J.slug)});},[i,a]);let[u,m]=react.useState(Hn),c=react.useMemo(()=>{let C=new Map;return s.forEach((T,B)=>{C.set(T,Ia[B%Ia.length]);}),C},[s]),f=react.useMemo(()=>i.filter(C=>s.includes(C.slug)),[i,s]),{series:d,isLoading:p}=reactPredict.useMarketHistory(f,u),g=t||p,v=react.useMemo(()=>{if(d.length>0&&d.some(B=>B.data.length>0))return d;let C=Date.now(),T=864e5;return f.map(B=>{let ue=(B.outcomes?.find(se=>se.label.toLowerCase()==="yes")??B.outcomes?.[0])?.price??.5;return {marketSlug:B.slug,label:B.outcomes?.[0]?.label??B.question,data:[{timestamp:C-7*T,price:ue},{timestamp:C,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]),S=react.useMemo(()=>{if(x.length===0)return [0,1];let C=1/0,T=-1/0;if(s.forEach(J=>{x.forEach(ue=>{let se=ue[J];se!=null&&(se<C&&(C=se),se>T&&(T=se));});}),!isFinite(C))return [0,1];let B=Math.max((T-C)*.15,.05);return [Math.max(0,C-B),Math.min(1,T+B)]},[x,s]),k=react.useMemo(()=>{let C=new Map;return v.forEach(T=>{T.data.length>0&&C.set(T.marketSlug,T.data[T.data.length-1].price);}),C},[v]),b=react.useMemo(()=>{let C=new Map;return v.forEach(T=>C.set(T.marketSlug,T.label)),C},[v]),y=react.useMemo(()=>v.map(C=>({slug:C.marketSlug,color:c.get(C.marketSlug)??"#6b7280"})),[v,c]),{wrapperRef:N,overlayRef:E,onMouseMove:P,onMouseLeave:R}=pf(),D=react.useCallback(C=>{l(T=>T.includes(C)?T.length<=1?T:T.filter(B=>B!==C):T.length>=hn?T:[...T,C]);},[]),[U,Q]=react.useState(null),H=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??k}),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?C=>{P(C),cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{Q(H.current);});}:void 0,onMouseLeave:te?()=>{R(),cancelAnimationFrame(q.current),Y.current="",H.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:E,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:C=>lf(C,u),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:S,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:C=>{let T=C;if(T.active&&T.payload?.length){let B=T.payload.map(J=>`${J.dataKey}:${J.value}`).join(",");if(B!==Y.current){Y.current=B;let J=new Map;T.payload.forEach(ue=>{ue.value!=null&&J.set(ue.dataKey,ue.value);}),H.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(C=>{let T=c.get(C.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:C.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},C.marketSlug)}),U==null&&x.length>0&&v.map(C=>{let T=x[x.length-1],B=T[C.marketSlug];if(B==null)return null;let J=c.get(C.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:T.timestamp,y:B,ifOverflow:"extendDomain",shape:ue=>{let{cx:se,cy:Ge}=ue;return se==null||Ge==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:se,cy:Ge,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:se,cy:Ge,r:3.5,fill:J})]})}},`pulse-${C.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:m}),a.length>1&&jsxRuntime.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(ff,{markets:a,selectedSlugs:s,colorMap:c,onToggle:D})})]})]})]})}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 m=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(m)},[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(p=>p.status==="open").sort((p,g)=>co(g)-co(p)),d=c.filter(p=>p.status!=="open").sort((p,g)=>co(g)-co(p));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),m=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?m&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:m})}):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})}),m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:m})]})]}):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,[m,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),p=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:m===`${v.slug}:yes`,activeNo:m===`${v.slug}:no`,isExpanded:x,onToggleExpand:()=>p(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:m}=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(m,"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 m=u[s]??u[0],c=m.rules&&m.rules.length>0?m.rules.join(`
77
77
 
78
- `):m.description??"";if(!l)return null;let f=l.length>200&&!n?l.slice(0,200)+"...":l;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(m)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:d=>{c(Number(d)),o(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:u.map((d,p)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(p===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:uo(d)},String(p)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),l.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=m.status,p=[];return m.created_at&&p.push({label:r("predict.event.timeline.created"),value:vn(m.created_at),isActive:true}),p.push({label:r("predict.event.timeline.open"),value:vn(m.start_at),isActive:d!=="pending"}),d==="voided"?p.push({label:r("predict.event.timeline.voided"),value:vn(m.closed_at??m.end_at),isActive:true}):d==="closed"?p.push({label:r("predict.event.timeline.closed"),value:vn(m.closed_at??m.end_at),isActive:true}):p.push({label:r("predict.event.timeline.close"),value:vn(m.end_at),isActive:false}),p})().map((d,p,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"}`}),p<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<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:m.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(m.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(c=>jsxRuntime.jsx(tg,{event:c,onClick:n,onHover:o},`${c.source}-${c.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:c,onSetupRequired:u,slippageBps:m}){let{t:l}=i18n.useTranslation(),{isDesktop:f}=ui.useScreen(),{onOpen:d}=uiScaffold.useAsyncModal(on),{onOpen:p}=uiScaffold.useAsyncModal(Zo),{data:g,isLoading:v}=reactPredict.useEvent({slug:e,source:t}),h=react.useMemo(()=>{let R=[...g?.markets||[]],P=R.filter(D=>D.status==="open").sort((D,U)=>mo(U)-mo(D)),E=R.filter(D=>D.status!=="open").sort((D,U)=>mo(U)-mo(D));return [...P,...E]},[g?.markets]),[x,k]=react.useState(null),S=react.useCallback((R,P,E)=>{k(D=>({market:R,outcome:P,side:E,version:(D?.version??0)+1})),!f&&g&&(E==="sell"?p({params:{event:g,market:R,initialOutcome:P,chain:r,slippageBps:m,onSetupRequired:u}}):d({params:{event:g,market:R,initialOutcome:P,chain:r,slippageBps:m,onInsufficientBalance:c}}));},[f,g,r,m,d,p,c,u]),b=x?.market??h[0];if(v){let R=!!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:R})}),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:R})}let y=x?`${x.market.slug}-${x.version}`:b?.slug??"default",C=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:l("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&&(C?jsxRuntime.jsx(no,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,onSetupRequired:u},y):jsxRuntime.jsx(qn,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,onInsufficientBalance:c},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:c}=reactPredict.useEvent({slug:e.eventSlug,source:n}),u=react.useMemo(()=>{if(!a?.markets)return [];let p=new Set,g=a.markets.filter(h=>p.has(h.slug)?false:(p.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]),m=reactQuery.useQueries({queries:u.map(p=>({queryKey:reactPredict.candlesticksQueryKey(p,i),queryFn:()=>o.listCandlesticks(p,i),enabled:u.length>0}))}),l=m.some(p=>p.isLoading),f=react.useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.error;h&&p.set(g,h);}),p},[u,m]),d=react.useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.data;h&&p.set(g,h);}),p},[u,m]);return {event:a,isEventLoading:s,eventError:c,candlestickParams:i,candlesticks:d,isCandlesticksLoading:l,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"),[c,u]=react.useState(false),m=Eg[a],{data:l,isLoading:f,isFetchingNextPage:d,hasNextPage:p,fetchNextPage:g}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:m.order,ascending:m.ascending,holders_only:c}),v=react.useMemo(()=>l?.pages?.flatMap(E=>E.items)??[],[l?.pages]),h=react.useRef(null),{height:x}=hooks.useResizeObserver({ref:h}),k=n??(x||Rg),S=reactWindow.useDynamicRowHeight({defaultRowHeight:_g,key:`${e}:${t}:${a}:${c}`}),b=v.length,y=b+(p?1:0),C=react.useCallback(E=>E<b,[b]),R=react.useCallback(async()=>{p&&!d&&await g();},[p,d,g]),P=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:C,loadMoreRows:R,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:c,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:P,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 c=m=>{s.current&&!s.current.contains(m.target)&&a(false);},u=m=>{m.key==="Escape"&&a(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u);}},[i]),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 py-2 lg:px-2",children:[jsxRuntime.jsxs("div",{ref:s,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(c=>!c),className:"inline-flex items-center gap-x-1.5 rounded-lg border border-border bg-content2/40 px-3 py-1.5 text-sm text-foreground transition-colors hover:bg-content2 cursor-pointer",children:[jsxRuntime.jsx(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(c=>{let u=c===e;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(c),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[c])}),u&&jsxRuntime.jsx(rl,{className:"size-4 text-primary"})]},c)})})]}),jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>n(!r),className:ui.cn("inline-flex items-center gap-x-1.5 rounded-lg border px-3 py-1.5 text-sm transition-colors cursor-pointer",r?"border-primary/40 bg-primary/10 text-primary":"border-border bg-content2/40 text-neutral hover:text-foreground"),children:[jsxRuntime.jsx("span",{className:ui.cn("flex size-4 items-center justify-center rounded border",r?"border-primary bg-primary":"border-neutral"),children:r&&jsxRuntime.jsx(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(c=>c!==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],c=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:m=>{t&&n&&m.preventDefault(),n?.(e);},onMouseEnter:()=>o?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:c.color},children:[c.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:c.label})]}),jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxRuntime.jsxs("span",{className:"text-neutral-400",children:[u," ",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:c,hasNextPage:u,fetchNextPage:m}=pl(i),l=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:l}),d=react.useCallback(h=>h<a.length,[a]),p=react.useCallback(async()=>{u&&!c&&await m();},[u,c,m]),g=react.useMemo(()=>u?a.length+1:a.length,[a,u]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,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:l,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),c=react.useMemo(()=>utils$1.debounce(f=>{o(f),a(f),f&&s(f);},500),[a,s]),u=react.useCallback(f=>{r(f),c(f);},[c]),m=react.useCallback(f=>{c.cancel(),r(f),o(f),a(f),f&&s(f);},[c,a,s]),l=react.useCallback(()=>m(""),[m]);return {text:t,keyword:n,setText:u,setKeyword:m,clearKeyword:l}}function kl({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:n,onHover:o,onEscape:i,source:a}){let{text:s,keyword:c,setText:u,setKeyword:m,clearKeyword:l}=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:l,onEscape:i}),!c&&jsxRuntime.jsx(cl,{onSelect:m}),jsxRuntime.jsx(hl,{className:"flex-auto min-h-0",keyword:c,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(c=>{n(c);},[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),c=hooks.useCallbackRef(async()=>{let m=await i({params:t});m&&s(m);}),u=hooks.useCallbackRef(()=>{a();});return react.useEffect(()=>{let m=l=>{let f=document.activeElement,d=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");l.key==="/"&&!d&&(l.preventDefault(),c()),l.key==="Escape"&&(l.preventDefault(),u());};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m);}},[c,u]),o?jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",onPress:c,variant:"bordered",startContent:jsxRuntime.jsx(ui.SearchIcon,{width:16,height:16,className:"text-foreground"}),endContent:jsxRuntime.jsx(ui.Kbd,{className:"min-w-6 justify-center text-xs text-foreground bg-content3 rounded-lg",children:"/"}),className:ui.cn("w-56 min-w-0 h-8 min-h-0 border-transparent hover:border-border bg-content2 pl-3 pr-1.5 text-neutral",r),children:n("predict.search.placeholder")}):jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:true,onPress:c,variant:"bordered",className:ui.cn("w-8 min-w-0 h-8 min-h-0 border-1 border-border bg-content2",r),children:jsxRuntime.jsx(ui.SearchIcon,{width:16,height:16,className:"text-foreground"})})}var 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(),[c,u]=react.useState(false),[m,l]=react.useState(false),[f,d]=react.useState(false),[p,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)&&l(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
+ `):m.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(m)})}),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,p)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(p===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:uo(d)},String(p)))})]})]}),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=m.status,p=[];return m.created_at&&p.push({label:r("predict.event.timeline.created"),value:vn(m.created_at),isActive:true}),p.push({label:r("predict.event.timeline.open"),value:vn(m.start_at),isActive:d!=="pending"}),d==="voided"?p.push({label:r("predict.event.timeline.voided"),value:vn(m.closed_at??m.end_at),isActive:true}):d==="closed"?p.push({label:r("predict.event.timeline.closed"),value:vn(m.closed_at??m.end_at),isActive:true}):p.push({label:r("predict.event.timeline.close"),value:vn(m.end_at),isActive:false}),p})().map((d,p,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"}`}),p<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<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:m.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(m.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 Kt(e){return Vf[e]??jf}function Y1({source:e,className:t}){let r=Kt(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=Kt(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:m}){let{t:c}=i18n.useTranslation(),{isDesktop:f}=ui.useScreen(),{onOpen:d}=uiScaffold.useAsyncModal(on),{onOpen:p}=uiScaffold.useAsyncModal(ti),{data:g,isLoading:v}=reactPredict.useEvent({slug:e,source:t}),h=react.useMemo(()=>{let E=[...g?.markets||[]],P=E.filter(D=>D.status==="open").sort((D,U)=>mo(U)-mo(D)),R=E.filter(D=>D.status!=="open").sort((D,U)=>mo(U)-mo(D));return [...P,...R]},[g?.markets]),[x,S]=react.useState(null),k=react.useCallback((E,P,R)=>{S(D=>({market:E,outcome:P,side:R,version:(D?.version??0)+1})),!f&&g&&(R==="sell"?p({params:{event:g,market:E,initialOutcome:P,chain:r,slippageBps:m,onSetupRequired:u}}):d({params:{event:g,market:E,initialOutcome:P,chain:r,slippageBps:m,onInsufficientBalance:l}}));},[f,g,r,m,d,p,l,u]),b=x?.market??h[0];if(v){let E=!!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:E})}),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:E})}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:k})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[b&&(N?jsxRuntime.jsx(no,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,onSetupRequired:u},y):jsxRuntime.jsx(qn,{event:g,market:b,initialOutcome:x?.outcome,chain:r,slippageBps:m,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(Js,{})]})}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 p=new Set,g=a.markets.filter(h=>p.has(h.slug)?false:(p.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]),m=reactQuery.useQueries({queries:u.map(p=>({queryKey:reactPredict.candlesticksQueryKey(p,i),queryFn:()=>o.listCandlesticks(p,i),enabled:u.length>0}))}),c=m.some(p=>p.isLoading),f=react.useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.error;h&&p.set(g,h);}),p},[u,m]),d=react.useMemo(()=>{let p=new Map;return u.forEach((g,v)=>{let h=m[v]?.data;h&&p.set(g,h);}),p},[u,m]);return {event:a,isEventLoading:s,eventError:l,candlestickParams:i,candlesticks:d,isCandlesticksLoading:c,candlestickErrors:f}};function gi({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),m=Eg[a],{data:c,isLoading:f,isFetchingNextPage:d,hasNextPage:p,fetchNextPage:g}=reactPredict.useInfiniteComments({slug:e,source:t,limit:r,order:m.order,ascending:m.ascending,holders_only:l}),v=react.useMemo(()=>c?.pages?.flatMap(R=>R.items)??[],[c?.pages]),h=react.useRef(null),{height:x}=hooks.useResizeObserver({ref:h}),S=n??(x||Rg),k=reactWindow.useDynamicRowHeight({defaultRowHeight:_g,key:`${e}:${t}:${a}:${l}`}),b=v.length,y=b+(p?1:0),N=react.useCallback(R=>R<b,[b]),E=react.useCallback(async()=>{p&&!d&&await g();},[p,d,g]),P=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:N,loadMoreRows:E,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:S},onRowsRendered:P,rowComponent:Og,rowCount:y,rowHeight:k,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(gi,{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=m=>{s.current&&!s.current.contains(m.target)&&a(false);},u=m=>{m.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=Kt(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:m=>{t&&n&&m.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:m}=pl(i),c=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:c}),d=react.useCallback(h=>h<a.length,[a]),p=react.useCallback(async()=>{u&&!l&&await m();},[u,l,m]),g=react.useMemo(()=>u?a.length+1:a.length,[a,u]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:p,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]),m=react.useCallback(f=>{l.cancel(),r(f),o(f),a(f),f&&s(f);},[l,a,s]),c=react.useCallback(()=>m(""),[m]);return {text:t,keyword:n,setText:u,setKeyword:m,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:m,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:m}),jsxRuntime.jsx(hl,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:n,onHover:o,source:a})]})}var yi="predict-search";function yS({id:e=yi}){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(yi),s=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let m=await i({params:t});m&&s(m);}),u=hooks.useCallbackRef(()=>{a();});return react.useEffect(()=>{let m=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",m),()=>{window.removeEventListener("keydown",m);}},[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 Si=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],_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),[m,c]=react.useState(false),[f,d]=react.useState(false),[p,g]=react.useState(false),v=react.useRef(null),h=react.useRef(null),x=Si.find(b=>b.value===e)??Si[0],S=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",S),()=>document.removeEventListener("mousedown",S)),[S]);let k=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),l(false);},children:[jsxRuntime.jsx(K0,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:s(x.labelKey)}),jsxRuntime.jsx(Rl,{open:c})]}),c&&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:C=>{y||(C.currentTarget.style.background="rgba(39,39,42,0.5)",C.currentTarget.style.color="#fff");},onMouseLeave:C=>{y||(C.currentTarget.style.background="transparent",C.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:()=>{l(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:m})]}),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")})]})]})]}),m&&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:C=>{y||(C.currentTarget.style.background="rgba(39,39,42,0.5)",C.currentTarget.style.color="#fff");},onMouseLeave:C=>{y||(C.currentTarget.style.background="transparent",C.currentTarget.style.color="#a1a1aa");},onClick:()=>{i?.(b.value===0?void 0:b.value),l(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:p?"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:`
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:Si.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:m})]}),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")})]})]})]}),m&&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:k,children:jsxRuntime.jsxs("svg",{className:p?"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: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=`
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 wi(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 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:c}=i18n.useTranslation(),u=dh(e);if(!u)return null;let[m,l]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=th(f),p=Hl[d],g=m.best_price!=null&&l.best_price!=null?m.best_price<=l.best_price?m.source:l.source:null,v=m.event_title||l.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, ${p.bandFrom}, ${p.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:p.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:p.color},children:[f.toFixed(1),"%"]}),jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:c("predict.matches.gap")})]}),jsxRuntime.jsx(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:m,isCheaper:g===m.source,externalUrlFallback:a?.(e,m.source),internalHref:o?.(e,m),onSelect:n?()=>n(e,m):void 0,LinkComponent:s}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(Fl,{leg:l,isCheaper:g===l.source,externalUrlFallback:a?.(e,l.source),internalHref:o?.(e,l),onSelect:n?()=>n(e,l):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)," ",c("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxRuntime.jsxs("span",{title:c("predict.matches.updatedAgo",{seconds:e.age_seconds}),style:{display:"flex",alignItems:"center",gap:4},children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("polyline",{points:"12 6 12 12 16 14"})]}),uh(c,e.age_seconds)]})]}),jsxRuntime.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsxRuntime.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:x.dot,flexShrink:0}}),c(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=R=>{let P=R.currentTarget,E=rh[d];P.style.borderColor=E.border,P.style.boxShadow=E.shadow,i?.(e);},C=R=>{let P=R.currentTarget;P.style.borderColor="rgba(39,39,42,0.6)",P.style.boxShadow="none";};return k&&s?jsxRuntime.jsx(s,{href:k,className:"group match-card",children:jsxRuntime.jsx("div",{style:b,onMouseEnter:y,onMouseLeave:C,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:C,onClick:()=>t?.(e),onKeyDown:R=>{t&&(R.key==="Enter"||R.key===" ")&&(R.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),c=ah(e.source),u=e.best_price,m=e.outcomes?.[0]?.label??null,l=e.external_url??r,f=nh(e.age_seconds),d=h=>{h.stopPropagation();},p=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:p?"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:c.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:[m&&jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),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")})]}),l?jsxRuntime.jsx("a",{href:l,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})}):p?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:c,onSelect:u,onHover:m,getMarketHref:l,LinkComponent:f,onStatsChange:d},p){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}),[C,R]=react.useState(0),[P,E]=react.useState(false);P&&!b?(E(false),R(te=>te+1)):b&&!P&&E(true),react.useImperativeHandle(p,()=>({refetch:()=>{y();}}),[y]);let D=react.useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),U=v?.pages[0]?.total,Q=react.useMemo(()=>{let te=0,N=0,M=0;for(let z of D){let J=z.spread??0;J>te&&(te=J),J>=.03&&M++,z.combined_volume!=null&&(N+=z.combined_volume);}return {activePairs:U??D.length,maxSpread:te,highSpreadCount:M,totalVolume:N}},[D,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 N=new IntersectionObserver(M=>{M[0]?.isIntersecting&&h&&!k&&x();},{rootMargin:"200px"});return N.observe(te),()=>N.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(D.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&&D.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[m,c]=u,f=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=th(f),p=Hl[d],g=m.best_price!=null&&c.best_price!=null?m.best_price<=c.best_price?m.source:c.source:null,v=m.event_title||c.event_title,h=e.signal_tag??"stale_data",x=Dl[h]??Dl.stale_data,S=r?.(e),k=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, ${p.bandFrom}, ${p.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:p.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:p.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:m,isCheaper:g===m.source,externalUrlFallback:a?.(e,m.source),internalHref:o?.(e,m),onSelect:n?()=>n(e,m):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"})]}),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: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"})}),wi(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:S||t?"pointer":void 0},y=E=>{let P=E.currentTarget,R=rh[d];P.style.borderColor=R.border,P.style.boxShadow=R.shadow,i?.(e);},N=E=>{let P=E.currentTarget;P.style.borderColor="rgba(39,39,42,0.6)",P.style.boxShadow="none";};return S&&s?jsxRuntime.jsx(s,{href:S,className:"group match-card",children:jsxRuntime.jsx("div",{style:b,onMouseEnter:y,onMouseLeave:N,onClick:()=>t?.(e),children:k})}):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:E=>{t&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),t(e));},children:k})}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=Kt(e.source),l=ah(e.source),u=e.best_price,m=e.outcomes?.[0]?.label??null,c=e.external_url??r,f=nh(e.age_seconds),d=h=>{h.stopPropagation();},p=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:p?"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:[m&&jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),jsxRuntime.jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[wi(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})}):p?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:m,getMarketHref:c,LinkComponent:f,onStatsChange:d},p){let{t:g}=i18n.useTranslation(),{data:v,hasNextPage:h,fetchNextPage:x,isFetchingNextPage:S,isLoading:k,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,E]=react.useState(0),[P,R]=react.useState(false);P&&!b?(R(false),E(te=>te+1)):b&&!P&&R(true),react.useImperativeHandle(p,()=>({refetch:()=>{y();}}),[y]);let D=react.useMemo(()=>v?.pages.flatMap(te=>te.items??[])??[],[v]),U=v?.pages[0]?.total,Q=react.useMemo(()=>{let te=0,C=0,T=0;for(let B of D){let J=B.spread??0;J>te&&(te=J),J>=.03&&T++,B.combined_volume!=null&&(C+=B.combined_volume);}return {activePairs:U??D.length,maxSpread:te,highSpreadCount:T,totalVolume:C}},[D,U]);react.useEffect(()=>{Q.activePairs>0&&d?.(Q);},[Q,d]);let H=react.useRef(null),Y=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let te=H.current;if(!te)return;let C=new IntersectionObserver(T=>{T[0]?.isIntersecting&&h&&!S&&x();},{rootMargin:"200px"});return C.observe(te),()=>C.disconnect()},[h,S,x]),react.useEffect(()=>{if(h)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[h]),k)return jsxRuntime.jsx(xh,{});if(D.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&&D.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
128
128
  @media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
129
129
  @keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
130
- `}),jsxRuntime.jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:v?.pages.map(te=>te.items?.map((N,M)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${M*35}ms both`},children:jsxRuntime.jsx(zl,{match:N,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:c,onHover:m,onSelect:u,getMarketHref:l,LinkComponent:f})},`${C}-${N.match_id}-${N.source_a}-${N.market_a?.slug??M}`)))}),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:c}){let{t:u}=i18n.useTranslation(),[m,l]=react.useState("spread"),[f,d]=react.useState(false),[p,g]=react.useState(void 0),[v,h]=react.useState(),x=react.useRef(null),k=react.useCallback(C=>{l(C);},[]),S=react.useCallback(C=>{d(C);},[]),b=react.useCallback(C=>{react.startTransition(()=>{h(C);});},[]),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((C,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:C,onSelectMatch:i,getMatchHref:a,onSelectLeg:s,getLegHref:l,onHover:m,onSelect:u,getMarketHref:c,LinkComponent:f})},`${N}-${C.match_id}-${C.source_a}-${C.market_a?.slug??T}`)))}),jsxRuntime.jsxs("div",{ref:H,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)}}"}),S&&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(),[m,c]=react.useState("spread"),[f,d]=react.useState(false),[p,g]=react.useState(void 0),[v,h]=react.useState(),x=react.useRef(null),S=react.useCallback(N=>{c(N);},[]),k=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:[c&&jsxRuntime.jsx("img",{src:c,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsxRuntime.jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsxRuntime.jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsxRuntime.jsx(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[m])}),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:m,onSortChange:k,sortAsc:f,onSortAscChange:S,minVolume:p,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:m,sortAsc:f,minVolume:p,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 c=s.outcomes[0];return {name:c.label||null,price:c.best_ask??c.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,c]=react.useMemo(()=>Ah(e,i),[e,i]),u=a!=null&&a>=3;s.yesPrice!=null&&c.yesPrice!=null?s.source==="kalshi"?s.yesPrice>c.yesPrice:c.yesPrice>s.yesPrice:false;let l=s.yesPrice!=null&&c.yesPrice!=null?s.yesPrice<=c.yesPrice?s:c:null,f=l?Ut(l.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:p=>{let g=p.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:p=>{let g=p.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:l===s,onSelect:t,getEventHref:r,LinkComponent:n}),jsxRuntime.jsx(ql,{data:c,isCheaper:l===c,onSelect:t,getEventHref:r,LinkComponent:n})]}),l&&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:()=>l.event&&t?.(l.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:l.source.charAt(0).toUpperCase()+l.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),c=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:c||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:m=>{m.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:m=>{m.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 c&&o?jsxRuntime.jsx(o,{href:c,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 c of s.entries)a.add(typeof c.source=="string"?c.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:c,hasNextPage:u,isFetchingNextPage:m}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:l,isLoading:f,fetchNextPage:d,hasNextPage:p,isFetchingNextPage:g}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=s||f,h=m||g,x=u||p,k=react.useMemo(()=>{let U=[];return a?.pages&&U.push(...a.pages.flatMap(Q=>Q.items)),l?.pages&&U.push(...l.pages.flatMap(Q=>Q.items)),U.sort((Q,B)=>(B.timestamp??0)-(Q.timestamp??0)),U},[a,l]),S=Math.max(1,Math.ceil(k.length/wn)+(x?1:0)),b=(o-1)*wn,y=k.slice(b,b+wn),C=react.useCallback(()=>{i(U=>Math.max(1,U-1));},[]),R=react.useCallback(async()=>{o*wn>=k.length&&x&&(u&&await c(),p&&await d()),i(Q=>Q+1);},[o,k.length,x,u,p,c,d]),P=o>1,E=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 D=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:D},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:!P,onClick:C,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",P?"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:!E,onClick:R,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",E?"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:!P,onClick:C,className:ui.cn("text-sm cursor-pointer",P?"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:!E,onClick:R,className:ui.cn("text-sm cursor-pointer",E?"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,c=s?"+":"-",u=s?"text-success":"text-foreground",m=e.event?.title??e.market?.question??"\u2014",l=e.event?.image_url,f=e.outcome??"",d=ac(e.timestamp),p=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:[l&&jsxRuntime.jsx("img",{src:l,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),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:[c,"$",i.toFixed(2)]}):"\u2014"}),jsxRuntime.jsx("div",{className:ui.cn("flex-1 pr-2 text-right font-mono",g!==null?g>=0?"text-success":"text-danger":"text-neutral"),children:g!==null?`${g>=0?"+":"-"}$${Math.abs(g).toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:v!==null?`$${v.toFixed(2)}`:"\u2014"}),jsxRuntime.jsx("div",{className:"w-10 shrink-0 text-right",children:p&&jsxRuntime.jsx("a",{href:p,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",c=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:c})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsxRuntime.jsx("span",{className:ui.cn("font-medium",r?"text-primary":n?"text-success":"text-danger"),children:t(r?"predict.profile.redeem":n?"predict.profile.buy":"predict.profile.sell")})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsxRuntime.jsx("span",{className:"text-foreground",children: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(),c=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${c}${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:c,fetchNextPage:u,hasNextPage:m,isFetchingNextPage:l}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:d,fetchNextPage:p,hasNextPage:g,isFetchingNextPage:v}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=c||d,x=l||v,k=m||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)),C=(i-1)*Pn,R=S.slice(C,C+Pn),P=react.useCallback(()=>{a(B=>Math.max(1,B-1));},[]),E=react.useCallback(async()=>{i*Pn>=S.length&&k&&(m&&await u(),g&&await p()),a(Y=>Y+1);},[i,S.length,k,m,g,u,p]),D=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:[R.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:D,canGoNext:U,onPrev:P,onNext:E,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:R.map(B=>jsxRuntime.jsx(av,{order:B,onCancel:b},B.id))}),jsxRuntime.jsx(dc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:D,canGoNext:U,onPrev:P,onNext:E,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:c,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 ",c("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(m,l)=>{let f=l+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:[c("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),c=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)),m=(a-1)*Ei,l=e.slice(m,m+Ei),f=a>1,d=a<u,p=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:c,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:i("predict.profile.closeAll")})})]}),jsxRuntime.jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:p},children:l.map((g,v)=>jsxRuntime.jsx(fv,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??m+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:l.map((g,v)=>jsxRuntime.jsx(gv,{position:g,onClose:n,onEventClick:o},`${g.source}-${g.market?.slug??`m-${m+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,c=e.current_value??e.size*s,u=e.size,m=o>0?"text-success":o<0?"text-danger":"text-foreground",l=o>0?"+":"",f=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,p=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",p.toLowerCase()==="yes"?"text-success":"text-danger"),children:p}),g&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1",children:"\xB7"}),jsxRuntime.jsx("span",{children:g})]})]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-mono text-foreground",children:["$",c.toFixed(2)]}),jsxRuntime.jsx("span",{className:"text-[10px] text-neutral",children:n("predict.profile.contracts",{count: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",m),children:[jsxRuntime.jsxs("span",{children:[l,"$",Math.abs(o).toFixed(2)]}),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",l,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",c=o>0?"+":"",u=e.event?.title??e.market?.question??"\u2014";return jsxRuntime.jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsxRuntime.jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:u})]}),jsxRuntime.jsx("span",{className:ui.cn("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxRuntime.jsx(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:`${c}$${Math.abs(o).toFixed(2)} (${c}${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(),c=s<=0?"+":"-",u=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${n} ${o}/${i}/${a} (${c}${u})`}catch{return "\u2014"}}function hc({positions:e,trades:t,isLoading:r}){let{t:n}=i18n.useTranslation(),o=react.useMemo(()=>{let s=0,c=0;for(let d of e)s+=d.realized_pnl??0,c+=d.current_value??d.size*(d.current_price??0);let u=0,m=0,l=0;for(let d of t)u+=d.usd_size??0,d.type==="REDEEM"&&(l++,(d.usd_size??0)>0&&m++);let f=l>0?`${m} / ${l}`:"0 / 0";return {realizedPnl:s,positionsValue:c,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:c,isLoading:u}=reactPredict.usePositions({source:"kalshi",user:e??""}),{data:m,isLoading:l}=reactPredict.usePositions({source:"polymarket",user:t??""}),f=react.useMemo(()=>{let C=[];return c?.positions&&C.push(...c.positions),m?.positions&&C.push(...m.positions),C},[c,m]),d=u||l,{data:p,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(()=>[...p?.pages?.flatMap(R=>R.items)??[],...v?.pages?.flatMap(R=>R.items)??[]],[p,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(C=>jsxRuntime.jsx("button",{type:"button",onClick:()=>a(C.key),className:ui.cn("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",i===C.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:C.label},C.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),[c,u]=react.useState(null),[m,l]=react.useState(false),f=r||m,d=n||m,p=f?"done":a?"running":"pending",g=d?"done":f&&a?"running":"pending",v=f&&d,h=react.useCallback(async()=>{u(null),l(false),s(true);try{await o(),l(!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:p},{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))}),c&&jsxRuntime.jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsxRuntime.jsx("p",{className:"text-xs text-red-400",children:c})}),jsxRuntime.jsx("button",{type:"button",onClick: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
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[m])}),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:m,onSortChange:S,sortAsc:f,onSortAscChange:k,minVolume:p,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:m,sortAsc:f,minVolume:p,onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:s,onStatsChange:b})]}),jsxRuntime.jsx(Th,{stats:v})]})}function Ni(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?Kt(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:p=>{let g=p.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:p=>{let g=p.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"})]}),Ni(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"})}),Ni(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=Kt(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:m=>{m.currentTarget.style.borderColor=s.hoverBorder;},onMouseLeave:m=>{m.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:[Ni(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(Ci,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.totalVolume"),value:Hh(n.totalVolume)}),jsxRuntime.jsx(Ci,{}),jsxRuntime.jsx(ko,{label:r("predict.matches.stats.highestSpread"),value:`${(n.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsxRuntime.jsx(Ci,{}),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 Ci(){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:m}=reactPredict.useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:c,isLoading:f,fetchNextPage:d,hasNextPage:p,isFetchingNextPage:g}=reactPredict.useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),v=s||f,h=m||g,x=u||p,S=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,H)=>(H.timestamp??0)-(Q.timestamp??0)),U},[a,c]),k=Math.max(1,Math.ceil(S.length/wn)+(x?1:0)),b=(o-1)*wn,y=S.slice(b,b+wn),N=react.useCallback(()=>{i(U=>Math.max(1,U-1));},[]),E=react.useCallback(async()=>{o*wn>=S.length&&x&&(u&&await l(),p&&await d()),i(Q=>Q+1);},[o,S.length,x,u,p,l,d]),P=o>1,R=o*wn<S.length||x;if(v)return jsxRuntime.jsx(Jh,{height:r});if(S.length===0&&!x)return jsxRuntime.jsx(Xh,{message:n("predict.profile.noHistory"),height:r});let D=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:D},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:!P,onClick:N,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",P?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",n("predict.profile.previous")]}),Array.from({length:Math.min(k,5)},(U,Q)=>{let H=Q+1;return jsxRuntime.jsx("button",{type:"button",onClick:()=>i(H),className:ui.cn("w-8 h-8 rounded text-sm transition-colors cursor-pointer",H===o?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:H},H)}),jsxRuntime.jsxs("button",{type:"button",disabled:!R,onClick:E,className:ui.cn("text-sm transition-colors cursor-pointer flex items-center gap-1",R?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[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:!P,onClick:N,className:ui.cn("text-sm cursor-pointer",P?"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:!R,onClick:E,className:ui.cn("text-sm cursor-pointer",R?"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",m=e.event?.title??e.market?.question??"\u2014",c=e.event?.image_url,f=e.outcome??"",d=ac(e.timestamp),p=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:m}),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:p&&jsxRuntime.jsx("a",{href:p,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:m,isFetchingNextPage:c}=reactPredict.useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:f,isLoading:d,fetchNextPage:p,hasNextPage:g,isFetchingNextPage:v}=reactPredict.useInfiniteOrders({source:"polymarket",wallet_address:t??""}),h=l||d,x=c||v,S=m||g,k=react.useMemo(()=>{let H=[],Y=new Set(["live","open","submitted","pending"]);return s?.pages&&H.push(...s.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),f?.pages&&H.push(...f.pages.flatMap(q=>q.items).filter(q=>Y.has(q.status))),H},[s,f]),b=react.useCallback(H=>{o.mutate({source:H.source,id:H.id});},[o]),y=Math.max(1,Math.ceil(k.length/Pn)+(S?1:0)),N=(i-1)*Pn,E=k.slice(N,N+Pn),P=react.useCallback(()=>{a(H=>Math.max(1,H-1));},[]),R=react.useCallback(async()=>{i*Pn>=k.length&&S&&(m&&await u(),g&&await p()),a(Y=>Y+1);},[i,k.length,S,m,g,u,p]),D=i>1,U=i*Pn<k.length||S;if(h)return jsxRuntime.jsx(cv,{height:r});if(k.length===0&&!S)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:[E.map(H=>jsxRuntime.jsx(sv,{order:H,onCancel:b},H.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:D,canGoNext:U,onPrev:P,onNext:R,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:E.map(H=>jsxRuntime.jsx(av,{order:H,onCancel:b},H.id))}),jsxRuntime.jsx(dc,{className:"lg:hidden",currentPage:i,totalPages:y,canGoPrev:D,canGoNext:U,onPrev:P,onNext:R,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)},(m,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 Ri=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/Ri)),m=(a-1)*Ri,c=e.slice(m,m+Ri),f=a>1,d=a<u,p=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:p},children:c.map((g,v)=>jsxRuntime.jsx(fv,{position:g,onClosePosition:n,onEventClick:o},`${g.source}-${g.market?.slug??m+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-${m+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,m=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,p=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",p.toLowerCase()==="yes"?"text-success":"text-danger"),children:p}),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:_i(a)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:_i(s)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono",m),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:_i(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 _i(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,m=0,c=0;for(let d of t)u+=d.usd_size??0,d.type==="REDEEM"&&(c++,(d.usd_size??0)>0&&m++);let f=c>0?`${m} / ${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(Oi,{label:n("predict.profile.winRate"),value:o.winRateStr,isLoading:r}),jsxRuntime.jsx(Oi,{label:n("predict.profile.positions"),value:`$${o.positionsValue.toFixed(2)}`,isLoading:r}),jsxRuntime.jsx(Oi,{label:n("predict.profile.volume"),value:`$${o.volume.toFixed(2)}`,isLoading:r})]})]})}function Oi({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 Ai=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:m,isLoading:c}=reactPredict.usePositions({source:"polymarket",user:t??""}),f=react.useMemo(()=>{let N=[];return l?.positions&&N.push(...l.positions),m?.positions&&N.push(...m.positions),N},[l,m]),d=u||c,{data:p,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(()=>[...p?.pages?.flatMap(E=>E.items)??[],...v?.pages?.flatMap(E=>E.items)??[]],[p,v]),S=d||g||h,k=f.length,y=[{key:"positions",label:k>0?`${o("predict.profile.positionsTab")} (${k})`:o("predict.profile.positionsTab")},{key:"orders",label:o("predict.profile.openOrdersTab")},{key:"history",label:o("predict.profile.historyTab")}];return 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:S}),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:Ai,onClosePosition:r,onEventClick:n}),i==="orders"&&jsxRuntime.jsx(uc,{solanaAddress:e,evmAddress:t,listHeight:Ai}),i==="history"&&jsxRuntime.jsx(rc,{solanaAddress:e,evmAddress:t,listHeight:Ai})]})]}):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),[m,c]=react.useState(false),f=r||m,d=n||m,p=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:p},{key:"step2",label:i("predict.setup.step2"),desc:i("predict.setup.step2Desc"),status:g}],S=()=>{v?t():h();},k=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:S,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")]}):k}),!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=Wi;exports.CategoriesWidget=Vi;exports.ChartRange=ce;exports.CommentItemUI=gi;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=As;exports.EventMarketDepthChartUI=Na;exports.EventMarketDetailWidget=_a;exports.EventPriceChart=Da;exports.EventsFilterUI=ms;exports.EventsHero=qx;exports.EventsPage=$x;exports.EventsPageSkeleton=gx;exports.EventsSkeleton=Ko;exports.EventsToolbarUI=xs;exports.EventsUI=zs;exports.EventsWidget=Us;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=yi;exports.PREDICT_SELL_MODAL_ID=ti;exports.PREDICT_TRADE_MODAL_ID=on;exports.PRICE_HISTORY_SAMPLE_INTERVAL=eb;exports.PredictRedeemModal=Js;exports.PredictSearchModal=yS;exports.PredictSellModal=pa;exports.PredictTradeModal=Yn;exports.PredictWalletProvider=zc;exports.PriceHistoryInterval=Br;exports.ProfilePage=Cv;exports.RedeemFormWidget=Qs;exports.SORT_PRESETS=bs;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=us;exports.TradeFormWidget=qn;exports.UserActivitySection=ga;exports.computeMaxBuyAmount=Qi;exports.countActiveFilters=$o;exports.createTradeResultToast=zr;exports.estimatePolymarketBuyFee=Xi;exports.estimatePolymarketSellFee=Ji;exports.fireCelebration=Zi;exports.floorToDecimals=xe;exports.formatKMB=gn;exports.formatShares=yr;exports.getSourceMeta=Kt;exports.parsePolymarketError=Kn;exports.polymarketFeeFactor=$c;exports.resolveExpiration=Un;exports.resolvePolymarketDisplayFeeRateBps=Yi;exports.roundToTickSize=$n;exports.useEventDetail=M2;exports.useEventsInfinite=Ss;exports.usePredictSearchHistory=bo;exports.usePredictWallet=xr;exports.useSearchResultListScript=pl;exports.useSearchScript=yl;exports.useSellForm=ra;exports.useTradeForm=ns;//# sourceMappingURL=index.js.map
137
137
  //# sourceMappingURL=index.js.map