@liberfi.io/ui-predict 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactQuery=require('@tanstack/react-query'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),eo=require('canvas-confetti'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var eo__default=/*#__PURE__*/_interopDefault(eo);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="1.0.5");var kl="1.0.5";var Sl={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},Qo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Xn=(()=>{let e=t=>{let r=Qo.indexOf(t);return r===-1?Qo.length:r};return Object.entries(Sl).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 Zo({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:l="Trending",className:s}){let{t:c}=i18n.useTranslation(),u=react.useCallback(()=>{o(null);},[o]),p=c("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",s),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(Xo,{label:p,isSelected:t===null,onPress:u,showPulse:p===l}),jsxRuntime.jsx(Cl,{}),e.map(m=>jsxRuntime.jsx(Xo,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===l},m.category))]})}),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(Jo,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsxRuntime.jsx(Jo,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function Xo({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 Cl(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Jo({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 L0({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 Ml(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function El(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function ri({onSelect:e,trailing:t,className:r}){let[n,o]=react.useState(null),[i,a]=react.useState(null),l=react.useCallback(m=>{o(m),a(null),e?.({categorySlug:m,tagSlug:null});},[e]),s=react.useCallback(m=>{a(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=Ml(Xn),u=Xn.find(m=>m.slug===n),p=El(u);return jsxRuntime.jsx(Zo,{categories:c,selectedCategory:n,selectedTag:i,activeTags:p,onCategorySelect:l,onTagSelect:s,trailing:t,className:r})}function on(e){return {title:e.title,imageUrl:e.image_url}}function an(e){let t=e.outcomes[0],r=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}var Er=24,Jn=4,sn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},qe={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ln=qe.ALL,H0={[qe.ONE_DAY]:sn.ONE_MINUTE,[qe.ONE_WEEK]:sn.ONE_HOUR,[qe.ONE_MONTH]:sn.ONE_HOUR,[qe.ALL]:sn.ONE_DAY},z0={[qe.ONE_DAY]:300,[qe.ONE_WEEK]:3600,[qe.ONE_MONTH]:10800,[qe.ALL]:1440*60},$0={[qe.ONE_DAY]:1440*60,[qe.ONE_WEEK]:10080*60,[qe.ONE_MONTH]:720*60*60,[qe.ALL]:null},cn=1,dn=1,W0=1,U0=1,K0=99,fr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},V0=fr.ONE_WEEK,j0={[fr.ONE_HOUR]:60,[fr.SIX_HOURS]:60,[fr.ONE_DAY]:300,[fr.ONE_WEEK]:1800,[fr.MAX]:1800};var ii=react.createContext(null);function Zt(){let e=react.useContext(ii);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Dl=1e4;function Al({pollingInterval:e=Dl,enabled:t=true,children:r}){let n=walletConnector.useWallets(),o=react.useMemo(()=>n.find(x=>x.chainNamespace===types.ChainNamespace.SOLANA&&x.isConnected)?.address,[n]),i=react.useMemo(()=>n.find(x=>x.chainNamespace===types.ChainNamespace.EVM&&x.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:s,error:c}=reactPredict.useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:u,isLoading:p}=reactPredict.useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:d}=reactPredict.usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:v,isFetching:w,error:P}=reactPredict.useBalance({source:"polymarket",user:i??""},{enabled:t&&g&&!!i,refetchInterval:e}),E=react.useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:u?.verified??false,kalshiKycUrl:u?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:d,isLoading:l||v,isFetching:s||w,error:c??P??null}),[o,i,f,a,h,g,u,p,m,d,l,v,s,w,c,P]);return jsxRuntime.jsx(ii.Provider,{value:E,children:r})}var Bl={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*Bl[r]}}function pn(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 mn(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,l=parseInt(o[2],10)/1e6,s=Math.max(0,a-l);return t("predict.trade.polymarket.insufficientBalance",{total:xe(a,2).toFixed(2),active:xe(l,2).toFixed(2),available:xe(s,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 Tr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function er(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};eo__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{eo__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{eo__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function ci({market:e,initialOutcome:t="yes",onInsufficientBalance:r}){let{t:n}=i18n.useTranslation(),{status:o}=walletConnector.useAuth(),i=walletConnector.useWallets(),a=walletConnector.useSwitchChain(),l=reactPredict.usePredictClient(),s=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),u=e.source,p=u==="polymarket",m=i.find(F=>F.chainNamespace===types.ChainNamespace.SOLANA&&F.isConnected),d=i.find(F=>F.chainNamespace===types.ChainNamespace.EVM&&F.isConnected&&"switchChain"in F),f=o==="authenticated",g=m?.address,h=d?.address,v=react.useMemo(()=>{if(u!=="polymarket")return;let F=e.provider_meta?.["polymarket.clobTokenIds"];return F?(typeof F=="string"?JSON.parse(F):F)[0]:void 0},[u,e.provider_meta]),{data:w,isLoading:P}=reactPredict.useTickSize(v),E=w?.minimum_tick_size?String(w.minimum_tick_size):"0.01",{data:x,isLoading:M}=reactPredict.useFeeRate(v),y=String(x?.base_fee??0),[O,D]=react.useState(t),[U,z]=react.useState("market"),[S,$]=react.useState(NaN),[I,ie]=react.useState(NaN),[X,k]=react.useState(false),[b,N]=react.useState(null),[q,Y]=react.useState(false),[Z,_e]=react.useState(false),[Re,Fe]=react.useState("1h"),[Ee,we]=react.useState(30),[ot,je]=react.useState("minutes"),Be=null,Ie=false,lt=null,Ge;try{let F=Zt();Be={kalshiUsdcBalance:F.kalshiUsdcBalance,polymarketUsdcBalance:F.polymarketUsdcBalance,isLoading:F.isLoading},Ie=F.kalshiKycVerified,lt=F.kalshiKycUrl,Ge=F.polymarketSafeAddress;}catch{}let L=react.useMemo(()=>{let F=O==="yes"?0:1,Pe=e.outcomes[F];return Pe?.best_ask??Pe?.price??.5},[e.outcomes,O]),fe=react.useCallback(F=>{z(F);},[]),He=react.useCallback(F=>{D(F),ie(NaN);},[]);react.useEffect(()=>{U==="limit"&&isNaN(I)&&ie(Math.round(L*100)/100);},[U,I,L]);let ct=react.useMemo(()=>isNaN(S)||S<=0?0:L>0?S/L:0,[S,L]),ze=react.useMemo(()=>isNaN(S)||S<=0?"0":String(Math.round(S*1e6)),[S]),jt=e.provider_meta?.["dflow.yesMint"]??"",A=e.provider_meta?.["dflow.noMint"]??"",Oe=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ye=O==="yes"?jt:A,Gt=Oe,Nt=Ye,ur=u==="kalshi"?g??"":h??"",{data:ft,isLoading:$e}=reactPredict.usePositions({source:u,user:ur},{enabled:!!ur}),Vn=u==="kalshi"&&!!Gt&&!!Nt&&!!g&&ze!=="0",{refetch:Yr}=reactPredict.useDFlowQuote({inputMint:Gt,outputMint:Nt,amount:ze,userPublicKey:g??"",slippageBps:100},{enabled:Vn}),Ct=react.useMemo(()=>Be?u==="kalshi"?Be.kalshiUsdcBalance:Be.polymarketUsdcBalance:ft&&ft.positions.reduce((Pe,dt)=>dt.side==="USDC"||dt.side==="collateral"?Pe+(dt.current_value??0):Pe,0)||null,[Be,ft,u]),Bt=Be?Be.isLoading:$e,wr=react.useMemo(()=>U==="limit"&&p&&!isNaN(I)?I:L,[U,p,I,L]),qr=react.useMemo(()=>isNaN(S)||S<=0?0:S,[S]),jn=react.useMemo(()=>isNaN(S)||S<=0?0:wr>0?S/wr*1:0,[S,wr]),Qr=jn-qr,Gn=react.useCallback(F=>{if(isNaN(F)){$(NaN);return}$(Math.round(Math.max(0,F)*100)/100);},[]),Yt=react.useCallback(F=>{if(isNaN(F)){ie(NaN);return}let Pe=Math.max(.01,Math.min(.99,F));ie(Math.round(Pe*100)/100);},[]),gt=react.useCallback(()=>{$(NaN),ie(NaN),z("market"),_e(false),Fe("1h"),we(30),je("minutes");},[]),Mt=react.useMemo(()=>{let F=[];return isNaN(S)||S<=0?F.push(n("predict.trade.minAmountUsd",{amount:dn})):S<dn&&F.push(n("predict.trade.minAmountUsd",{amount:dn})),e.status!=="open"&&F.push(n("predict.trade.marketNotActive")),Ct!=null&&!isNaN(S)&&S>0&&S>xe(Ct,2)&&F.push(n("predict.trade.insufficientBalance")),U==="limit"&&p&&(isNaN(I)||I<.01||I>.99)&&F.push(n("predict.trade.limitPriceRange")),U==="limit"&&p&&Z&&Re==="custom"&&(isNaN(Ee)||Ee<=0)&&F.push(n("predict.trade.expiration.invalidDate")),{isValid:F.length===0,errors:F}},[S,e.status,Ct,U,p,I,Z,Re,Ee,n]),pr=react.useMemo(()=>Ct==null||isNaN(S)||S<=0?false:S>xe(Ct,2),[Ct,S]),Yn=react.useCallback(()=>{r?.(u);},[r,u]),{mutateAsync:Pr}=reactPredict.useDFlowSubmit(),{data:Nr}=reactPredict.useOrder({id:b??"",source:u},{enabled:!!b});react.useEffect(()=>{if(!Nr||!b)return;let{status:F}=Nr;F==="closed"?(N(null),k(false),ui.toast.success(n("predict.trade.submitSuccess")),er(),gt(),c.invalidateQueries({queryKey:["predict","positions"]})):(F==="failed"||F==="expired")&&(k(false),N(null),ui.toast.error(n("predict.trade.submitError")));},[Nr,b,c,gt,n]);let Xr=react.useCallback(async()=>{if(!g||!m)return;if(!Gt||!Nt){ui.toast.error("Missing token mint addresses"),k(false);return}if(!Ie){Y(true),k(false);return}let ht=(await Yr()).data?.transaction;if(!ht){ui.toast.error(n("predict.trade.submitError")),k(false);return}let vt=Uint8Array.from(atob(ht),Qt=>Qt.charCodeAt(0)),it=await m.signTransaction(vt),qt=await Pr({signedTransaction:btoa(String.fromCharCode(...it)),orderContext:{user_public_key:g,input_mint:Gt,output_mint:Nt,amount:ze,price:String(L),side:"BUY",outcome:O==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});N(qt.signature);},[g,m,Yr,Pr,Gt,Nt,ze,L,O,e.slug,n,Ie]),Jr=react.useCallback(async()=>{if(!d||!s)return;let F=d.chain,Pe=F!==types.Chain.POLYGON;Pe&&await a(types.Chain.POLYGON);try{let dt=await d.getEip1193Provider();if(!dt){ui.toast.error(n("predict.trade.submitError")),k(!1);return}let ht=!!Ge,vt={address:d.address,signatureType:ht?2:0,signTypedData:async(Tt,Qn,Yo,tn)=>{let zt=[];"name"in Tt&&zt.push({name:"name",type:"string"}),"version"in Tt&&zt.push({name:"version",type:"string"}),"chainId"in Tt&&zt.push({name:"chainId",type:"uint256"}),"verifyingContract"in Tt&&zt.push({name:"verifyingContract",type:"address"}),"salt"in Tt&&zt.push({name:"salt",type:"bytes32"});let rn={EIP712Domain:zt,...Qn};return await dt.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:Tt,types:rn,primaryType:Yo,message:tn})]})}},it=s.credentials??await s.authenticate(vt),qt=O==="yes"?0:1,Qt="",xt=e.provider_meta?.["polymarket.clobTokenIds"];xt&&(Qt=(typeof xt=="string"?JSON.parse(xt):xt)[qt]??"");let Cr=e.provider_meta?.["polymarket.negRisk"]??!1,Zr=U==="limit"&&!isNaN(I)?I:L,Mr=pn(Zr,E),T=U==="limit"?Z?"GTD":"GTC":"FOK",ve=U==="market"?S:Mr>0?S/Mr:0,We={tokenId:Qt,price:Mr,size:ve,side:"BUY",orderType:T,tickSize:E,negRisk:Cr,...Ge&&{funderAddress:Ge},...U==="limit"&&Z&&{expiration:un(Re,Ee,ot)}},De=reactPredict.buildCtfExchangeDomain(Cr),at=reactPredict.buildOrderMessage({...We,signerAddress:vt.address,signatureType:vt.signatureType,feeRateBps:y}),Ue=await vt.signTypedData(De,reactPredict.CTF_ORDER_TYPES,"Order",at),Et=reactPredict.buildSignedOrder(at,Ue,We.orderType),Ne=reactPredict.buildClobPayload(Et,it.apiKey),Ht=JSON.stringify(Ne),en=await reactPredict.buildPolymarketL2Headers(it.address,{apiKey:it.apiKey,secret:it.secret,passphrase:it.passphrase,method:"POST",requestPath:"/order",body:Ht});await l.createPolymarketOrder(Ne,en),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(n("predict.trade.submitSuccess")),er(),gt(),k(!1);}finally{Pe&&F&&a(F).catch(()=>{});}},[d,s,a,O,e.provider_meta,U,I,L,S,l,c,Z,Re,Ee,ot,gt,n,E,y,Ge]),qn=react.useCallback(async()=>{if(!(!Mt.isValid||!f)){k(true),N(null),Y(false);try{u==="kalshi"?await Xr():await Jr();}catch(F){let Pe=F instanceof Error?F.message:"",dt=u==="polymarket"&&Pe?mn(Pe,n,"buy"):Pe||void 0;ui.toast.error(dt||n("predict.trade.submitError")),k(false);}}},[Mt.isValid,f,u,Xr,Jr,n]);return {outcome:O,orderType:U,quantity:S,limitPrice:I,shares:ct,estimatedCost:qr,potentialPayout:jn,potentialProfit:Qr,usdcBalance:Ct,isBalanceLoading:Bt,isMarketDataLoading:u==="polymarket"&&(M||P),isSubmitting:X,validation:Mt,isInsufficientBalance:pr,source:u,supportsLimitOrder:p,kycRequired:q,kycUrl:lt,expirationEnabled:Z,expirationPreset:Re,customDuration:Ee,customDurationUnit:ot,setOutcome:He,setOrderType:fe,setQuantity:Gn,setLimitPrice:Yt,setExpirationEnabled:_e,setExpirationPreset:Fe,setCustomDuration:we,setCustomDurationUnit:je,submit:qn,notifyInsufficientBalance:Yn}}function fn({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 bc=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,yc=["5m","1h","12h","24h","eod","custom"],kc={"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"},Sc=["minutes","hours","days"],wc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Pc={maximumFractionDigits:0};function vi({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:l,potentialProfit:s,potentialPayout:c,estimatedCost:u,usdcBalance:p,isBalanceLoading:m,isMarketDataLoading:d,isSubmitting:f,isValid:g,validationErrors:h,isInsufficientBalance:v,onInsufficientBalance:w,supportsLimitOrder:P,kycRequired:E,kycUrl:x,expirationEnabled:M,expirationPreset:y,customDuration:O,customDurationUnit:D,onOutcomeChange:U,onOrderTypeChange:z,onQuantityChange:S,onLimitPriceChange:$,onExpirationEnabledChange:I,onExpirationPresetChange:ie,onCustomDurationChange:X,onCustomDurationUnitChange:k,onSubmit:b}){let{t:N}=i18n.useTranslation(),[q,Y]=react.useState(false),Z=ui.useDisclosure(),[_e,Re]=react.useState(""),Fe=react.useRef(false);react.useEffect(()=>{Fe.current||Re(isNaN(i)?"":String(i));},[i]);let[Ee,we]=react.useState(""),ot=react.useRef(false);react.useEffect(()=>{ot.current||(isNaN(a)?we(""):we(String(parseFloat((a*100).toFixed(2)))));},[a]);let je=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(we(A),A===""||A==="."){$(NaN);return}let Ye=parseFloat(A);isNaN(Ye)||$(Ye/100);},[$]),Be=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Re(A),ze(false),A===""||A==="."){S(NaN);return}let Ye=parseFloat(A);isNaN(Ye)||S(Ye);},[S]);react.useEffect(()=>{E&&!Z.isOpen&&Z.onOpen();},[E]);let Ie=react.useMemo(()=>{let A=n==="yes"?t.yesAsk:t.noAsk;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),lt=!isNaN(i)&&i>0,Ge=react.useMemo(()=>{if(m)return N("predict.trade.loadingBalance");if(d)return N("predict.trade.loadingMarketData");if(f)return N("predict.trade.submitting");if(E)return N("predict.trade.kycRequired");if(!lt)return N("predict.trade.enterAmount");let A=N(n==="yes"?"predict.trade.yes":"predict.trade.no"),Oe=s>0?` \u2192 Win $${s.toFixed(2)}`:"";return `${N("predict.trade.buy")} ${A}${Oe}`},[m,d,f,E,lt,n,s,N]),L=react.useMemo(()=>n==="yes"?"primary":"secondary",[n]),fe=()=>{S(Math.floor((p??0)/2*100)/100);},He=()=>{S(xe(p??0,2));},[ct,ze]=react.useState(false),jt=()=>{if(E){Z.onOpen();return}if(v&&w){ze(false),w();return}if(!g){ze(true);return}ze(false),b();};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:n==="yes"?"text-bullish":"text-bearish",children:[N("predict.trade.buy")," ",N(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:[P?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>z(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:N("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:N("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:N("predict.trade.market")}),o==="limit"&&P?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ee,onChange:A=>je(A.target.value),onFocus:()=>{ot.current=true;},onBlur:()=>{ot.current=false,isNaN(a)?we(""):we(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"}}):Ie!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ie," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(A=>{let Oe=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:()=>U(A),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===A?A==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:N(A==="yes"?"predict.trade.yes":"predict.trade.no")}),Oe!=null&&jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Oe)*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:N("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:bc,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:p!=null?`${xe(p,2).toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:fe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:He,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:_e,onChange:A=>Be(A.target.value),onFocus:()=>{Fe.current=true;},onBlur:()=>{Fe.current=false,Re(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"}}),ct&&h.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:h.map(A=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:A},A))})]}),o==="limit"&&P&&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:N("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:M,onValueChange:I,"aria-label":N("predict.trade.setExpiration")})]}),M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":N("predict.trade.setExpiration"),selectedKeys:[y],onSelectionChange:A=>{let Oe=Array.from(A)[0];Oe&&ie(Oe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:yc.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:N(kc[A])},A))}),y==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(O)?void 0:O,onValueChange:X,minValue:1,step:1,formatOptions:Pc,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:[D],onSelectionChange:A=>{let Oe=Array.from(A)[0];Oe&&k(Oe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Sc.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:N(wc[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:()=>Y(A=>!A),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:N("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",q&&"rotate-180")})]}),Ie!=null&&jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:N("predict.trade.chance",{percent:Ie})})]}),q&&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:N("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:N("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?Tr(l):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:N("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:N("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&s>0?`+$${s.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:L,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||d||!lt||f,isLoading:f||m||d,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:jt,children:Ge})]}),jsxRuntime.jsx(fn,{isOpen:Z.isOpen,onClose:Z.onClose,kycUrl:x})]})}function hn({event:e,market:t,variant:r,initialOutcome:n,chain:o,onInsufficientBalance:i}){let{outcome:a,orderType:l,quantity:s,limitPrice:c,shares:u,estimatedCost:p,potentialPayout:m,potentialProfit:d,usdcBalance:f,isBalanceLoading:g,isMarketDataLoading:h,isSubmitting:v,validation:w,isInsufficientBalance:P,supportsLimitOrder:E,kycRequired:x,kycUrl:M,expirationEnabled:y,expirationPreset:O,customDuration:D,customDurationUnit:U,setOutcome:z,setOrderType:S,setQuantity:$,setLimitPrice:I,setExpirationEnabled:ie,setExpirationPreset:X,setCustomDuration:k,setCustomDurationUnit:b,submit:N,notifyInsufficientBalance:q}=ci({market:t,initialOutcome:n,onInsufficientBalance:i}),Y=walletConnector.useAuthCallback(N),Z=react.useMemo(()=>e?on(e):void 0,[e]),_e=react.useMemo(()=>an(t),[t]);return jsxRuntime.jsx(vi,{event:Z,market:_e,variant:r,outcome:a,orderType:l,quantity:s,limitPrice:c,shares:u,estimatedCost:p,potentialPayout:m,potentialProfit:d,usdcBalance:f,isBalanceLoading:g,isMarketDataLoading:h,isSubmitting:v,isValid:w.isValid,validationErrors:w.errors,isInsufficientBalance:P,onInsufficientBalance:i?q:void 0,supportsLimitOrder:E,kycRequired:x,kycUrl:M,expirationEnabled:y,expirationPreset:O,customDuration:D,customDurationUnit:U,onOutcomeChange:z,onOrderTypeChange:S,onQuantityChange:$,onLimitPriceChange:I,onExpirationEnabledChange:ie,onExpirationPresetChange:X,onCustomDurationChange:k,onCustomDurationUnitChange:b,onSubmit:Y})}var Lr="predict-trade";function vn({id:e=Lr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Rc,{...t})})}function Rc({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:"blur",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(hn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,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 no={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function oo(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function bi({isOpen:e,onClose:t,value:r,onChange:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState(r),l=react.useCallback(h=>{h?a(r):t();},[r,t]),s=react.useCallback(()=>{a(no);},[]),c=react.useCallback(()=>{n(i),t();},[i,n,t]),u=react.useCallback((h,v)=>{a(w=>({...w,[h]:v}));},[]),p=react.useMemo(()=>oo(i),[i]),m=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"polymarket",label:o("predict.platform.polymarket")},{value:"kalshi",label:o("predict.platform.kalshi")}],[o]),d=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1d",label:o("predict.filter.lessThanDay")},{value:"7d",label:o("predict.filter.lessThanWeek")},{value:"30d",label:o("predict.filter.lessThanMonth")}],[o]),f=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]),g=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:l,size:"md",backdrop:"blur",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:o("predict.filter.title")}),jsxRuntime.jsx(Bc,{onClick:()=>l(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsxRuntime.jsx(bn,{label:o("predict.filter.platform"),children:jsxRuntime.jsx(yn,{options:m,selected:i.source,onSelect:h=>u("source",h)})}),jsxRuntime.jsx(bn,{label:o("predict.filter.timeRemaining"),children:jsxRuntime.jsx(yn,{options:d,selected:i.timeRemaining,onSelect:h=>u("timeRemaining",h)})}),jsxRuntime.jsx(bn,{label:o("predict.filter.minVolume"),children:jsxRuntime.jsx(yn,{options:f,selected:i.minVolume,onSelect:h=>u("minVolume",h)})}),jsxRuntime.jsx(bn,{label:o("predict.filter.minLiquidity"),children:jsxRuntime.jsx(yn,{options:g,selected:i.minLiquidity,onSelect:h=>u("minLiquidity",h)})})]}),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:s,children:o("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:[o("predict.filter.showResults"),p>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",p,")"]})]})]})]})})})}function bn({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 Bc({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 yn({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 Pi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},ki={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Gc=["start_time","volume","liquidity","ending_soon"],Si={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"},Yc={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 Ni({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:a}){let{t:l}=i18n.useTranslation(),[s,c]=react.useState(false),u=react.useRef(null),p=react.useCallback(d=>{u.current&&!u.current.contains(d.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),react.useEffect(()=>{if(!s)return;let d=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[s]);let m=wi[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:u,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:Si,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(d=>!d),children:[jsxRuntime.jsx(qc,{}),jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l(ki[e])}),jsxRuntime.jsx(Xc,{open:s})]}),s&&jsxRuntime.jsx("div",{style:{...Yc,width:224,padding:4},children:Gc.map(d=>{let f=wi[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:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?n(!r):t(d),c(false);},children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:l(ki[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:Si,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(Qc,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l("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 wi={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function qc(){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 Qc(){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 Xc({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 Ei(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:a,error:l,hasNextPage:s,fetchNextPage:c,refetch:u}=reactPredict.useInfiniteEvents(t),p=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=react.useCallback(()=>{c();},[c]),d=react.useCallback(()=>{u();},[u]);return {data:p,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:a,error:l??null,hasMore:s??false,fetchMore:m,refetch:d}}var Ti=`
|
|
1
|
+
'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactQuery=require('@tanstack/react-query'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),eo=require('canvas-confetti'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var eo__default=/*#__PURE__*/_interopDefault(eo);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="1.0.6");var kl="1.0.6";var Sl={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},Qo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Xn=(()=>{let e=t=>{let r=Qo.indexOf(t);return r===-1?Qo.length:r};return Object.entries(Sl).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 Zo({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:a,pulsingTab:l="Trending",className:s}){let{t:c}=i18n.useTranslation(),u=react.useCallback(()=>{o(null);},[o]),p=c("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",s),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(Xo,{label:p,isSelected:t===null,onPress:u,showPulse:p===l}),jsxRuntime.jsx(Cl,{}),e.map(m=>jsxRuntime.jsx(Xo,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===l},m.category))]})}),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(Jo,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsxRuntime.jsx(Jo,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function Xo({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 Cl(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Jo({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 L0({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 Ml(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function El(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function ri({onSelect:e,trailing:t,className:r}){let[n,o]=react.useState(null),[i,a]=react.useState(null),l=react.useCallback(m=>{o(m),a(null),e?.({categorySlug:m,tagSlug:null});},[e]),s=react.useCallback(m=>{a(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=Ml(Xn),u=Xn.find(m=>m.slug===n),p=El(u);return jsxRuntime.jsx(Zo,{categories:c,selectedCategory:n,selectedTag:i,activeTags:p,onCategorySelect:l,onTagSelect:s,trailing:t,className:r})}function on(e){return {title:e.title,imageUrl:e.image_url}}function an(e){let t=e.outcomes[0],r=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}var Er=24,Jn=4,sn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},qe={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ln=qe.ALL,H0={[qe.ONE_DAY]:sn.ONE_MINUTE,[qe.ONE_WEEK]:sn.ONE_HOUR,[qe.ONE_MONTH]:sn.ONE_HOUR,[qe.ALL]:sn.ONE_DAY},z0={[qe.ONE_DAY]:300,[qe.ONE_WEEK]:3600,[qe.ONE_MONTH]:10800,[qe.ALL]:1440*60},$0={[qe.ONE_DAY]:1440*60,[qe.ONE_WEEK]:10080*60,[qe.ONE_MONTH]:720*60*60,[qe.ALL]:null},cn=1,dn=1,W0=1,U0=1,K0=99,fr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},V0=fr.ONE_WEEK,j0={[fr.ONE_HOUR]:60,[fr.SIX_HOURS]:60,[fr.ONE_DAY]:300,[fr.ONE_WEEK]:1800,[fr.MAX]:1800};var ii=react.createContext(null);function Zt(){let e=react.useContext(ii);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Dl=1e4;function Al({pollingInterval:e=Dl,enabled:t=true,children:r}){let n=walletConnector.useWallets(),o=react.useMemo(()=>n.find(x=>x.chainNamespace===types.ChainNamespace.SOLANA&&x.isConnected)?.address,[n]),i=react.useMemo(()=>n.find(x=>x.chainNamespace===types.ChainNamespace.EVM&&x.isConnected)?.address,[n]),{data:a,isLoading:l,isFetching:s,error:c}=reactPredict.useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:u,isLoading:p}=reactPredict.useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:d}=reactPredict.usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:v,isFetching:w,error:P}=reactPredict.useBalance({source:"polymarket",user:i??""},{enabled:t&&g&&!!i,refetchInterval:e}),E=react.useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:u?.verified??false,kalshiKycUrl:u?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:d,isLoading:l||v,isFetching:s||w,error:c??P??null}),[o,i,f,a,h,g,u,p,m,d,l,v,s,w,c,P]);return jsxRuntime.jsx(ii.Provider,{value:E,children:r})}var Bl={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*Bl[r]}}function pn(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 mn(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,l=parseInt(o[2],10)/1e6,s=Math.max(0,a-l);return t("predict.trade.polymarket.insufficientBalance",{total:xe(a,2).toFixed(2),active:xe(l,2).toFixed(2),available:xe(s,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 Tr(e,t=2){return parseFloat(xe(e,t).toFixed(t)).toString()}function er(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};eo__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{eo__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{eo__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function ci({market:e,initialOutcome:t="yes",onInsufficientBalance:r}){let{t:n}=i18n.useTranslation(),{status:o}=walletConnector.useAuth(),i=walletConnector.useWallets(),a=walletConnector.useSwitchChain(),l=reactPredict.usePredictClient(),s=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),u=e.source,p=u==="polymarket",m=i.find(F=>F.chainNamespace===types.ChainNamespace.SOLANA&&F.isConnected),d=i.find(F=>F.chainNamespace===types.ChainNamespace.EVM&&F.isConnected&&"switchChain"in F),f=o==="authenticated",g=m?.address,h=d?.address,v=react.useMemo(()=>{if(u!=="polymarket")return;let F=e.provider_meta?.["polymarket.clobTokenIds"];return F?(typeof F=="string"?JSON.parse(F):F)[0]:void 0},[u,e.provider_meta]),{data:w,isLoading:P}=reactPredict.useTickSize(v),E=w?.minimum_tick_size?String(w.minimum_tick_size):"0.01",{data:x,isLoading:M}=reactPredict.useFeeRate(v),y=String(x?.base_fee??0),[O,D]=react.useState(t),[U,z]=react.useState("market"),[S,$]=react.useState(NaN),[I,ie]=react.useState(NaN),[X,k]=react.useState(false),[b,N]=react.useState(null),[q,Y]=react.useState(false),[Z,_e]=react.useState(false),[Re,Fe]=react.useState("1h"),[Ee,we]=react.useState(30),[ot,je]=react.useState("minutes"),Be=null,Ie=false,lt=null,Ge;try{let F=Zt();Be={kalshiUsdcBalance:F.kalshiUsdcBalance,polymarketUsdcBalance:F.polymarketUsdcBalance,isLoading:F.isLoading},Ie=F.kalshiKycVerified,lt=F.kalshiKycUrl,Ge=F.polymarketSafeAddress;}catch{}let L=react.useMemo(()=>{let F=O==="yes"?0:1,Pe=e.outcomes[F];return Pe?.best_ask??Pe?.price??.5},[e.outcomes,O]),fe=react.useCallback(F=>{z(F);},[]),He=react.useCallback(F=>{D(F),ie(NaN);},[]);react.useEffect(()=>{U==="limit"&&isNaN(I)&&ie(Math.round(L*100)/100);},[U,I,L]);let ct=react.useMemo(()=>isNaN(S)||S<=0?0:L>0?S/L:0,[S,L]),ze=react.useMemo(()=>isNaN(S)||S<=0?"0":String(Math.round(S*1e6)),[S]),jt=e.provider_meta?.["dflow.yesMint"]??"",A=e.provider_meta?.["dflow.noMint"]??"",Oe=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ye=O==="yes"?jt:A,Gt=Oe,Nt=Ye,ur=u==="kalshi"?g??"":h??"",{data:ft,isLoading:$e}=reactPredict.usePositions({source:u,user:ur},{enabled:!!ur}),Vn=u==="kalshi"&&!!Gt&&!!Nt&&!!g&&ze!=="0",{refetch:Yr}=reactPredict.useDFlowQuote({inputMint:Gt,outputMint:Nt,amount:ze,userPublicKey:g??"",slippageBps:100},{enabled:Vn}),Ct=react.useMemo(()=>Be?u==="kalshi"?Be.kalshiUsdcBalance:Be.polymarketUsdcBalance:ft&&ft.positions.reduce((Pe,dt)=>dt.side==="USDC"||dt.side==="collateral"?Pe+(dt.current_value??0):Pe,0)||null,[Be,ft,u]),Bt=Be?Be.isLoading:$e,wr=react.useMemo(()=>U==="limit"&&p&&!isNaN(I)?I:L,[U,p,I,L]),qr=react.useMemo(()=>isNaN(S)||S<=0?0:S,[S]),jn=react.useMemo(()=>isNaN(S)||S<=0?0:wr>0?S/wr*1:0,[S,wr]),Qr=jn-qr,Gn=react.useCallback(F=>{if(isNaN(F)){$(NaN);return}$(Math.round(Math.max(0,F)*100)/100);},[]),Yt=react.useCallback(F=>{if(isNaN(F)){ie(NaN);return}let Pe=Math.max(.01,Math.min(.99,F));ie(Math.round(Pe*100)/100);},[]),gt=react.useCallback(()=>{$(NaN),ie(NaN),z("market"),_e(false),Fe("1h"),we(30),je("minutes");},[]),Mt=react.useMemo(()=>{let F=[];return isNaN(S)||S<=0?F.push(n("predict.trade.minAmountUsd",{amount:dn})):S<dn&&F.push(n("predict.trade.minAmountUsd",{amount:dn})),e.status!=="open"&&F.push(n("predict.trade.marketNotActive")),Ct!=null&&!isNaN(S)&&S>0&&S>xe(Ct,2)&&F.push(n("predict.trade.insufficientBalance")),U==="limit"&&p&&(isNaN(I)||I<.01||I>.99)&&F.push(n("predict.trade.limitPriceRange")),U==="limit"&&p&&Z&&Re==="custom"&&(isNaN(Ee)||Ee<=0)&&F.push(n("predict.trade.expiration.invalidDate")),{isValid:F.length===0,errors:F}},[S,e.status,Ct,U,p,I,Z,Re,Ee,n]),pr=react.useMemo(()=>Ct==null||isNaN(S)||S<=0?false:S>xe(Ct,2),[Ct,S]),Yn=react.useCallback(()=>{r?.(u);},[r,u]),{mutateAsync:Pr}=reactPredict.useDFlowSubmit(),{data:Nr}=reactPredict.useOrder({id:b??"",source:u},{enabled:!!b});react.useEffect(()=>{if(!Nr||!b)return;let{status:F}=Nr;F==="closed"?(N(null),k(false),ui.toast.success(n("predict.trade.submitSuccess")),er(),gt(),c.invalidateQueries({queryKey:["predict","positions"]})):(F==="failed"||F==="expired")&&(k(false),N(null),ui.toast.error(n("predict.trade.submitError")));},[Nr,b,c,gt,n]);let Xr=react.useCallback(async()=>{if(!g||!m)return;if(!Gt||!Nt){ui.toast.error("Missing token mint addresses"),k(false);return}if(!Ie){Y(true),k(false);return}let ht=(await Yr()).data?.transaction;if(!ht){ui.toast.error(n("predict.trade.submitError")),k(false);return}let vt=Uint8Array.from(atob(ht),Qt=>Qt.charCodeAt(0)),it=await m.signTransaction(vt),qt=await Pr({signedTransaction:btoa(String.fromCharCode(...it)),orderContext:{user_public_key:g,input_mint:Gt,output_mint:Nt,amount:ze,price:String(L),side:"BUY",outcome:O==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});N(qt.signature);},[g,m,Yr,Pr,Gt,Nt,ze,L,O,e.slug,n,Ie]),Jr=react.useCallback(async()=>{if(!d||!s)return;let F=d.chain,Pe=F!==types.Chain.POLYGON;Pe&&await a(types.Chain.POLYGON);try{let dt=await d.getEip1193Provider();if(!dt){ui.toast.error(n("predict.trade.submitError")),k(!1);return}let ht=!!Ge,vt={address:d.address,signatureType:ht?2:0,signTypedData:async(Tt,Qn,Yo,tn)=>{let zt=[];"name"in Tt&&zt.push({name:"name",type:"string"}),"version"in Tt&&zt.push({name:"version",type:"string"}),"chainId"in Tt&&zt.push({name:"chainId",type:"uint256"}),"verifyingContract"in Tt&&zt.push({name:"verifyingContract",type:"address"}),"salt"in Tt&&zt.push({name:"salt",type:"bytes32"});let rn={EIP712Domain:zt,...Qn};return await dt.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:Tt,types:rn,primaryType:Yo,message:tn})]})}},it=s.credentials??await s.authenticate(vt),qt=O==="yes"?0:1,Qt="",xt=e.provider_meta?.["polymarket.clobTokenIds"];xt&&(Qt=(typeof xt=="string"?JSON.parse(xt):xt)[qt]??"");let Cr=e.provider_meta?.["polymarket.negRisk"]??!1,Zr=U==="limit"&&!isNaN(I)?I:L,Mr=pn(Zr,E),T=U==="limit"?Z?"GTD":"GTC":"FOK",ve=U==="market"?S:Mr>0?S/Mr:0,We={tokenId:Qt,price:Mr,size:ve,side:"BUY",orderType:T,tickSize:E,negRisk:Cr,...Ge&&{funderAddress:Ge},...U==="limit"&&Z&&{expiration:un(Re,Ee,ot)}},De=reactPredict.buildCtfExchangeDomain(Cr),at=reactPredict.buildOrderMessage({...We,signerAddress:vt.address,signatureType:vt.signatureType,feeRateBps:y}),Ue=await vt.signTypedData(De,reactPredict.CTF_ORDER_TYPES,"Order",at),Et=reactPredict.buildSignedOrder(at,Ue,We.orderType),Ne=reactPredict.buildClobPayload(Et,it.apiKey),Ht=JSON.stringify(Ne),en=await reactPredict.buildPolymarketL2Headers(it.address,{apiKey:it.apiKey,secret:it.secret,passphrase:it.passphrase,method:"POST",requestPath:"/order",body:Ht});await l.createPolymarketOrder(Ne,en),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(n("predict.trade.submitSuccess")),er(),gt(),k(!1);}finally{Pe&&F&&a(F).catch(()=>{});}},[d,s,a,O,e.provider_meta,U,I,L,S,l,c,Z,Re,Ee,ot,gt,n,E,y,Ge]),qn=react.useCallback(async()=>{if(!(!Mt.isValid||!f)){k(true),N(null),Y(false);try{u==="kalshi"?await Xr():await Jr();}catch(F){let Pe=F instanceof Error?F.message:"",dt=u==="polymarket"&&Pe?mn(Pe,n,"buy"):Pe||void 0;ui.toast.error(dt||n("predict.trade.submitError")),k(false);}}},[Mt.isValid,f,u,Xr,Jr,n]);return {outcome:O,orderType:U,quantity:S,limitPrice:I,shares:ct,estimatedCost:qr,potentialPayout:jn,potentialProfit:Qr,usdcBalance:Ct,isBalanceLoading:Bt,isMarketDataLoading:u==="polymarket"&&(M||P),isSubmitting:X,validation:Mt,isInsufficientBalance:pr,source:u,supportsLimitOrder:p,kycRequired:q,kycUrl:lt,expirationEnabled:Z,expirationPreset:Re,customDuration:Ee,customDurationUnit:ot,setOutcome:He,setOrderType:fe,setQuantity:Gn,setLimitPrice:Yt,setExpirationEnabled:_e,setExpirationPreset:Fe,setCustomDuration:we,setCustomDurationUnit:je,submit:qn,notifyInsufficientBalance:Yn}}function fn({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 bc=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,yc=["5m","1h","12h","24h","eod","custom"],kc={"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"},Sc=["minutes","hours","days"],wc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Pc={maximumFractionDigits:0};function vi({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:a,shares:l,potentialProfit:s,potentialPayout:c,estimatedCost:u,usdcBalance:p,isBalanceLoading:m,isMarketDataLoading:d,isSubmitting:f,isValid:g,validationErrors:h,isInsufficientBalance:v,onInsufficientBalance:w,supportsLimitOrder:P,kycRequired:E,kycUrl:x,expirationEnabled:M,expirationPreset:y,customDuration:O,customDurationUnit:D,onOutcomeChange:U,onOrderTypeChange:z,onQuantityChange:S,onLimitPriceChange:$,onExpirationEnabledChange:I,onExpirationPresetChange:ie,onCustomDurationChange:X,onCustomDurationUnitChange:k,onSubmit:b}){let{t:N}=i18n.useTranslation(),[q,Y]=react.useState(false),Z=ui.useDisclosure(),[_e,Re]=react.useState(""),Fe=react.useRef(false);react.useEffect(()=>{Fe.current||Re(isNaN(i)?"":String(i));},[i]);let[Ee,we]=react.useState(""),ot=react.useRef(false);react.useEffect(()=>{ot.current||(isNaN(a)?we(""):we(String(parseFloat((a*100).toFixed(2)))));},[a]);let je=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(we(A),A===""||A==="."){$(NaN);return}let Ye=parseFloat(A);isNaN(Ye)||$(Ye/100);},[$]),Be=react.useCallback(A=>{if(A!==""&&!/^\d*\.?\d{0,2}$/.test(A))return;if(Re(A),ze(false),A===""||A==="."){S(NaN);return}let Ye=parseFloat(A);isNaN(Ye)||S(Ye);},[S]);react.useEffect(()=>{E&&!Z.isOpen&&Z.onOpen();},[E]);let Ie=react.useMemo(()=>{let A=n==="yes"?t.yesAsk:t.noAsk;return A!=null?parseFloat((Number(A)*100).toFixed(2)):null},[n,t]),lt=!isNaN(i)&&i>0,Ge=react.useMemo(()=>{if(m)return N("predict.trade.loadingBalance");if(d)return N("predict.trade.loadingMarketData");if(f)return N("predict.trade.submitting");if(E)return N("predict.trade.kycRequired");if(!lt)return N("predict.trade.enterAmount");let A=N(n==="yes"?"predict.trade.yes":"predict.trade.no"),Oe=s>0?` \u2192 Win $${s.toFixed(2)}`:"";return `${N("predict.trade.buy")} ${A}${Oe}`},[m,d,f,E,lt,n,s,N]),L=react.useMemo(()=>n==="yes"?"primary":"secondary",[n]),fe=()=>{S(Math.floor((p??0)/2*100)/100);},He=()=>{S(xe(p??0,2));},[ct,ze]=react.useState(false),jt=()=>{if(E){Z.onOpen();return}if(v&&w){ze(false),w();return}if(!g){ze(true);return}ze(false),b();};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:n==="yes"?"text-bullish":"text-bearish",children:[N("predict.trade.buy")," ",N(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:[P?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:A=>z(A),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:N("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:N("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:N("predict.trade.market")}),o==="limit"&&P?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:Ee,onChange:A=>je(A.target.value),onFocus:()=>{ot.current=true;},onBlur:()=>{ot.current=false,isNaN(a)?we(""):we(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"}}):Ie!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ie," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(A=>{let Oe=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:()=>U(A),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===A?A==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:N(A==="yes"?"predict.trade.yes":"predict.trade.no")}),Oe!=null&&jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Oe)*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:N("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:bc,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:p!=null?`${xe(p,2).toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:fe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:He,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:_e,onChange:A=>Be(A.target.value),onFocus:()=>{Fe.current=true;},onBlur:()=>{Fe.current=false,Re(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"}}),ct&&h.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:h.map(A=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:A},A))})]}),o==="limit"&&P&&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:N("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:M,onValueChange:I,"aria-label":N("predict.trade.setExpiration")})]}),M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":N("predict.trade.setExpiration"),selectedKeys:[y],onSelectionChange:A=>{let Oe=Array.from(A)[0];Oe&&ie(Oe);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:yc.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:N(kc[A])},A))}),y==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(O)?void 0:O,onValueChange:X,minValue:1,step:1,formatOptions:Pc,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:[D],onSelectionChange:A=>{let Oe=Array.from(A)[0];Oe&&k(Oe);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Sc.map(A=>jsxRuntime.jsx(ui.SelectItem,{children:N(wc[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:()=>Y(A=>!A),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:N("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",q&&"rotate-180")})]}),Ie!=null&&jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:N("predict.trade.chance",{percent:Ie})})]}),q&&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:N("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:N("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?Tr(l):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:N("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:N("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&s>0?`+$${s.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:L,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||d||!lt||f,isLoading:f||m||d,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:jt,children:Ge})]}),jsxRuntime.jsx(fn,{isOpen:Z.isOpen,onClose:Z.onClose,kycUrl:x})]})}function hn({event:e,market:t,variant:r,initialOutcome:n,chain:o,onInsufficientBalance:i}){let{outcome:a,orderType:l,quantity:s,limitPrice:c,shares:u,estimatedCost:p,potentialPayout:m,potentialProfit:d,usdcBalance:f,isBalanceLoading:g,isMarketDataLoading:h,isSubmitting:v,validation:w,isInsufficientBalance:P,supportsLimitOrder:E,kycRequired:x,kycUrl:M,expirationEnabled:y,expirationPreset:O,customDuration:D,customDurationUnit:U,setOutcome:z,setOrderType:S,setQuantity:$,setLimitPrice:I,setExpirationEnabled:ie,setExpirationPreset:X,setCustomDuration:k,setCustomDurationUnit:b,submit:N,notifyInsufficientBalance:q}=ci({market:t,initialOutcome:n,onInsufficientBalance:i}),Y=walletConnector.useAuthCallback(N),Z=react.useMemo(()=>e?on(e):void 0,[e]),_e=react.useMemo(()=>an(t),[t]);return jsxRuntime.jsx(vi,{event:Z,market:_e,variant:r,outcome:a,orderType:l,quantity:s,limitPrice:c,shares:u,estimatedCost:p,potentialPayout:m,potentialProfit:d,usdcBalance:f,isBalanceLoading:g,isMarketDataLoading:h,isSubmitting:v,isValid:w.isValid,validationErrors:w.errors,isInsufficientBalance:P,onInsufficientBalance:i?q:void 0,supportsLimitOrder:E,kycRequired:x,kycUrl:M,expirationEnabled:y,expirationPreset:O,customDuration:D,customDurationUnit:U,onOutcomeChange:z,onOrderTypeChange:S,onQuantityChange:$,onLimitPriceChange:I,onExpirationEnabledChange:ie,onExpirationPresetChange:X,onCustomDurationChange:k,onCustomDurationUnitChange:b,onSubmit:Y})}var Lr="predict-trade";function vn({id:e=Lr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Rc,{...t})})}function Rc({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:"blur",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(hn,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,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 no={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function oo(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function bi({isOpen:e,onClose:t,value:r,onChange:n}){let{t:o}=i18n.useTranslation(),[i,a]=react.useState(r),l=react.useCallback(h=>{h?a(r):t();},[r,t]),s=react.useCallback(()=>{a(no);},[]),c=react.useCallback(()=>{n(i),t();},[i,n,t]),u=react.useCallback((h,v)=>{a(w=>({...w,[h]:v}));},[]),p=react.useMemo(()=>oo(i),[i]),m=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"polymarket",label:o("predict.platform.polymarket")},{value:"kalshi",label:o("predict.platform.kalshi")}],[o]),d=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1d",label:o("predict.filter.lessThanDay")},{value:"7d",label:o("predict.filter.lessThanWeek")},{value:"30d",label:o("predict.filter.lessThanMonth")}],[o]),f=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]),g=react.useMemo(()=>[{value:void 0,label:o("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[o]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:l,size:"md",backdrop:"blur",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:o("predict.filter.title")}),jsxRuntime.jsx(Bc,{onClick:()=>l(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsxRuntime.jsx(bn,{label:o("predict.filter.platform"),children:jsxRuntime.jsx(yn,{options:m,selected:i.source,onSelect:h=>u("source",h)})}),jsxRuntime.jsx(bn,{label:o("predict.filter.timeRemaining"),children:jsxRuntime.jsx(yn,{options:d,selected:i.timeRemaining,onSelect:h=>u("timeRemaining",h)})}),jsxRuntime.jsx(bn,{label:o("predict.filter.minVolume"),children:jsxRuntime.jsx(yn,{options:f,selected:i.minVolume,onSelect:h=>u("minVolume",h)})}),jsxRuntime.jsx(bn,{label:o("predict.filter.minLiquidity"),children:jsxRuntime.jsx(yn,{options:g,selected:i.minLiquidity,onSelect:h=>u("minLiquidity",h)})})]}),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:s,children:o("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:[o("predict.filter.showResults"),p>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",p,")"]})]})]})]})})})}function bn({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 Bc({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 yn({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 Pi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},ki={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Gc=["start_time","volume","liquidity","ending_soon"],Si={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"},Yc={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 Ni({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:a}){let{t:l}=i18n.useTranslation(),[s,c]=react.useState(false),u=react.useRef(null),p=react.useCallback(d=>{u.current&&!u.current.contains(d.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),react.useEffect(()=>{if(!s)return;let d=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[s]);let m=wi[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:u,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:Si,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(d=>!d),children:[jsxRuntime.jsx(qc,{}),jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l(ki[e])}),jsxRuntime.jsx(Xc,{open:s})]}),s&&jsxRuntime.jsx("div",{style:{...Yc,width:224,padding:4},children:Gc.map(d=>{let f=wi[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:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?n(!r):t(d),c(false);},children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:l(ki[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:Si,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(Qc,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:l("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 wi={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function qc(){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 Qc(){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 Xc({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 Ei(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:a,error:l,hasNextPage:s,fetchNextPage:c,refetch:u}=reactPredict.useInfiniteEvents(t),p=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=react.useCallback(()=>{c();},[c]),d=react.useCallback(()=>{u();},[u]);return {data:p,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:a,error:l??null,hasMore:s??false,fetchMore:m,refetch:d}}var Ti=`
|
|
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}}
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
outline: 2px solid hsl(var(--heroui-primary) / 0.4);
|
|
125
125
|
outline-offset: 2px;
|
|
126
126
|
}
|
|
127
|
-
`;function ig({tier:e}){let t=_s[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 ag(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 Rs({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:a,LinkComponent:l}){let{t:s}=i18n.useTranslation(),c=ag(e);if(!c)return null;let[u,p]=c,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=Xf(m),f=_s[d],g=u.best_price!=null&&p.best_price!=null?u.best_price<=p.best_price?u.source:p.source:null,h=u.event_title||p.event_title,v=e.signal_tag??"stale_data",w=Es[v]??Es.stale_data,P=r?.(e),E=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:og}),m!=null&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${f.bandFrom}, ${f.bandTo})`,borderBottom:"1px solid 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:f.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxRuntime.jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:f.color},children:[m.toFixed(1),"%"]}),jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:s("predict.matches.gap")})]}),jsxRuntime.jsx(ig,{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",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",margin:"0 0 12px"},children:h}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsxRuntime.jsx(Ts,{leg:u,isCheaper:g===u.source,externalUrlFallback:a?.(e,u.source),internalHref:o?.(e,u),onSelect:n?()=>n(e,u):void 0,LinkComponent:l}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(Ts,{leg:p,isCheaper:g===p.source,externalUrlFallback:a?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:l})]})]}),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"})]}),Oo(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"})}),Oo(e.combined_volume_24h)," ",s("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxRuntime.jsxs("span",{title:s("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"})]}),sg(s,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:w.dot,flexShrink:0}}),s(w.label)]})]})]}),x={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:P||t?"pointer":void 0},M=O=>{let D=O.currentTarget,U=Jf[d];D.style.borderColor=U.border,D.style.boxShadow=U.shadow,i?.(e);},y=O=>{let D=O.currentTarget;D.style.borderColor="rgba(39,39,42,0.6)",D.style.boxShadow="none";};return P&&l?jsxRuntime.jsx(l,{href:P,className:"group match-card",children:jsxRuntime.jsx("div",{style:x,onMouseEnter:M,onMouseLeave:y,onClick:()=>t?.(e),children:E})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:x,onMouseEnter:M,onMouseLeave:y,onClick:()=>t?.(e),onKeyDown:O=>{t&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),t(e));},children:E})}function sg(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 Ts({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:a}=i18n.useTranslation(),l=St(e.source),s=ng(e.source),c=e.best_price,u=e.outcomes?.[0]?.label??null,p=e.external_url??r,m=Zf(e.age_seconds),d=v=>{v.stopPropagation();},f=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},h=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsxRuntime.jsx("span",{style:{width:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[l.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:s.text,textTransform:"uppercase"},children:l.label}),m&&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:eg[m],flexShrink:0}})]}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[u&&jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),jsxRuntime.jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Oo(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:c!=null?(c*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:9,color:"#71717a"},children:a("predict.matches.centsYes")})]}),p?jsxRuntime.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":a("predict.matches.viewOn",{platform:l.label}),title:a("predict.matches.viewOn",{platform:l.label}),onClick:v=>v.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.color="#d4d4d8",v.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:v=>{v.currentTarget.style.color="#71717a",v.currentTarget.style.background="transparent";},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})}):jsxRuntime.jsx("span",{style:{width:18,flexShrink:0}})]});return n&&i?jsxRuntime.jsx(i,{href:n,className:"match-card-leg-link",onClick:v=>{d(v),o?.();},children:jsxRuntime.jsx("div",{style:g,children:h})}):f?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:g,onClick:v=>{d(v),o?.();},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),d(v),o?.());},children:h}):jsxRuntime.jsx("div",{style:g,children:h})}var Fs=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:a,onSelectLeg:l,getLegHref:s,onSelect:c,onHover:u,getMarketHref:p,LinkComponent:m,onStatsChange:d},f){let{t:g}=i18n.useTranslation(),{data:h,hasNextPage:v,fetchNextPage:w,isFetchingNextPage:P,isLoading:E,isPlaceholderData:x,refetch:M}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[y,O]=react.useState(0),[D,U]=react.useState(false);D&&!x?(U(false),O(k=>k+1)):x&&!D&&U(true),react.useImperativeHandle(f,()=>({refetch:()=>{M();}}),[M]);let z=react.useMemo(()=>h?.pages.flatMap(k=>k.items??[])??[],[h]),S=h?.pages[0]?.total,$=react.useMemo(()=>{let k=0,b=0,N=0;for(let q of z){let Y=q.spread??0;Y>k&&(k=Y),Y>=.03&&N++,q.combined_volume!=null&&(b+=q.combined_volume);}return {activePairs:S??z.length,maxSpread:k,highSpreadCount:N,totalVolume:b}},[z,S]);react.useEffect(()=>{$.activePairs>0&&d?.($);},[$,d]);let I=react.useRef(null),ie=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let k=I.current;if(!k)return;let b=new IntersectionObserver(N=>{N[0]?.isIntersecting&&v&&!P&&w();},{rootMargin:"200px"});return b.observe(k),()=>b.disconnect()},[v,P,w]),react.useEffect(()=>{if(v)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[v]),E)return jsxRuntime.jsx(gg,{});if(z.length===0)return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsxRuntime.jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let X=!v&&z.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
|
|
127
|
+
`;function ig({tier:e}){let t=_s[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 ag(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 Rs({match:e,onSelectMatch:t,getMatchHref:r,onSelectLeg:n,getLegHref:o,onHover:i,getMarketHref:a,LinkComponent:l}){let{t:s}=i18n.useTranslation(),c=ag(e);if(!c)return null;let[u,p]=c,m=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,d=Xf(m),f=_s[d],g=u.best_price!=null&&p.best_price!=null?u.best_price<=p.best_price?u.source:p.source:null,h=u.event_title||p.event_title,v=e.signal_tag??"stale_data",w=Es[v]??Es.stale_data,P=r?.(e),E=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:og}),m!=null&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${f.bandFrom}, ${f.bandTo})`,borderBottom:"1px solid 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:f.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxRuntime.jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:f.color},children:[m.toFixed(1),"%"]}),jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:s("predict.matches.gap")})]}),jsxRuntime.jsx(ig,{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",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",margin:"0 0 12px",height:"calc(1.4em * 2)"},children:h}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsxRuntime.jsx(Ts,{leg:u,isCheaper:g===u.source,externalUrlFallback:a?.(e,u.source),internalHref:o?.(e,u),onSelect:n?()=>n(e,u):void 0,LinkComponent:l}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(Ts,{leg:p,isCheaper:g===p.source,externalUrlFallback:a?.(e,p.source),internalHref:o?.(e,p),onSelect:n?()=>n(e,p):void 0,LinkComponent:l})]})]}),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"})]}),Oo(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"})}),Oo(e.combined_volume_24h)," ",s("predict.matches.vol24h")]}),e.age_seconds!=null&&jsxRuntime.jsxs("span",{title:s("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"})]}),sg(s,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:w.dot,flexShrink:0}}),s(w.label)]})]})]}),x={display:"block",color:"inherit",textDecoration:"none",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:P||t?"pointer":void 0},M=O=>{let D=O.currentTarget,U=Jf[d];D.style.borderColor=U.border,D.style.boxShadow=U.shadow,i?.(e);},y=O=>{let D=O.currentTarget;D.style.borderColor="rgba(39,39,42,0.6)",D.style.boxShadow="none";};return P&&l?jsxRuntime.jsx(l,{href:P,className:"group match-card",children:jsxRuntime.jsx("div",{style:x,onMouseEnter:M,onMouseLeave:y,onClick:()=>t?.(e),children:E})}):jsxRuntime.jsx("div",{className:"group match-card",role:t?"button":void 0,tabIndex:t?0:void 0,style:x,onMouseEnter:M,onMouseLeave:y,onClick:()=>t?.(e),onKeyDown:O=>{t&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),t(e));},children:E})}function sg(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 Ts({leg:e,isCheaper:t,externalUrlFallback:r,internalHref:n,onSelect:o,LinkComponent:i}){let{t:a}=i18n.useTranslation(),l=St(e.source),s=ng(e.source),c=e.best_price,u=e.outcomes?.[0]?.label??null,p=e.external_url??r,m=Zf(e.age_seconds),d=v=>{v.stopPropagation();},f=!!(n||o),g={display:"flex",alignItems:"center",gap:8,padding:"10px 12px",background:t?"rgba(199,255,46,0.03)":"transparent",cursor:f?"pointer":void 0,color:"inherit",textDecoration:"none"},h=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsxRuntime.jsx("span",{style:{width:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:100,flexShrink:0},children:[l.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:s.text,textTransform:"uppercase"},children:l.label}),m&&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:eg[m],flexShrink:0}})]}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[u&&jsxRuntime.jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),jsxRuntime.jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Oo(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:c!=null?(c*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:9,color:"#71717a"},children:a("predict.matches.centsYes")})]}),p?jsxRuntime.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer","aria-label":a("predict.matches.viewOn",{platform:l.label}),title:a("predict.matches.viewOn",{platform:l.label}),onClick:v=>v.stopPropagation(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,color:"#71717a",flexShrink:0},onMouseEnter:v=>{v.currentTarget.style.color="#d4d4d8",v.currentTarget.style.background="rgba(255,255,255,0.05)";},onMouseLeave:v=>{v.currentTarget.style.color="#71717a",v.currentTarget.style.background="transparent";},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7 7h10v10"}),jsxRuntime.jsx("path",{d:"M7 17 17 7"})]})}):jsxRuntime.jsx("span",{style:{width:18,flexShrink:0}})]});return n&&i?jsxRuntime.jsx(i,{href:n,className:"match-card-leg-link",onClick:v=>{d(v),o?.();},children:jsxRuntime.jsx("div",{style:g,children:h})}):f?jsxRuntime.jsx("div",{role:"link",tabIndex:0,style:g,onClick:v=>{d(v),o?.();},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),d(v),o?.());},children:h}):jsxRuntime.jsx("div",{style:g,children:h})}var Fs=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:n,signal:o,onSelectMatch:i,getMatchHref:a,onSelectLeg:l,getLegHref:s,onSelect:c,onHover:u,getMarketHref:p,LinkComponent:m,onStatsChange:d},f){let{t:g}=i18n.useTranslation(),{data:h,hasNextPage:v,fetchNextPage:w,isFetchingNextPage:P,isLoading:E,isPlaceholderData:x,refetch:M}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:n,signal:o,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[y,O]=react.useState(0),[D,U]=react.useState(false);D&&!x?(U(false),O(k=>k+1)):x&&!D&&U(true),react.useImperativeHandle(f,()=>({refetch:()=>{M();}}),[M]);let z=react.useMemo(()=>h?.pages.flatMap(k=>k.items??[])??[],[h]),S=h?.pages[0]?.total,$=react.useMemo(()=>{let k=0,b=0,N=0;for(let q of z){let Y=q.spread??0;Y>k&&(k=Y),Y>=.03&&N++,q.combined_volume!=null&&(b+=q.combined_volume);}return {activePairs:S??z.length,maxSpread:k,highSpreadCount:N,totalVolume:b}},[z,S]);react.useEffect(()=>{$.activePairs>0&&d?.($);},[$,d]);let I=react.useRef(null),ie=react.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"});},[]);if(react.useEffect(()=>{let k=I.current;if(!k)return;let b=new IntersectionObserver(N=>{N[0]?.isIntersecting&&v&&!P&&w();},{rootMargin:"200px"});return b.observe(k),()=>b.disconnect()},[v,P,w]),react.useEffect(()=>{if(v)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[v]),E)return jsxRuntime.jsx(gg,{});if(z.length===0)return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsxRuntime.jsx("p",{style:{fontSize:18},children:g("predict.matches.empty")})});let X=!v&&z.length>0;return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
|
|
128
128
|
@media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
|
|
129
129
|
@keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
130
130
|
`}),jsxRuntime.jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},children:h?.pages.map(k=>k.items?.map((b,N)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${N*35}ms both`},children:jsxRuntime.jsx(Rs,{match:b,onSelectMatch:i,getMatchHref:a,onSelectLeg:l,getLegHref:s,onHover:u,onSelect:c,getMarketHref:p,LinkComponent:m})},`${y}-${b.match_id}-${b.source_a}-${b.market_a?.slug??N}`)))}),jsxRuntime.jsxs("div",{ref:I,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)}}"}),P&&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")]})]}),X&&jsxRuntime.jsx(fg,{onScrollToTop:ie})]})});function fg({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 gg(){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(hg,{index:t},t))})]})}function hg({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 kg={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Sg(){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 wg({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:e.activePairs.toLocaleString()})]}),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(Sg,{})]})]})]})]})}function N2({onSelectMatch:e,getMatchHref:t,onSelectLeg:r,getLegHref:n,onHover:o,onSelect:i,getMarketHref:a,LinkComponent:l,bgImageSrc:s}){let{t:c}=i18n.useTranslation(),[u,p]=react.useState("spread"),[m,d]=react.useState(false),[f,g]=react.useState(void 0),[h,v]=react.useState(),w=react.useRef(null),P=react.useCallback(y=>{p(y);},[]),E=react.useCallback(y=>{d(y);},[]),x=react.useCallback(y=>{react.startTransition(()=>{v(y);});},[]),M=react.useCallback(()=>{w.current?.refetch();},[]);return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsxRuntime.jsx("style",{children:`
|