@liberfi.io/ui-predict 0.1.103 → 0.1.104
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'),Gr=require('canvas-confetti'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),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 Gr__default=/*#__PURE__*/_interopDefault(Gr);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.103");var gi="0.1.103";var hi={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},to=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Wr=(()=>{let e=t=>{let r=to.indexOf(t);return r===-1?to.length:r};return Object.entries(hi).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function oo({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:l,pulsingTab:a="Trending",className:s}){let{t:c}=i18n.useTranslation(),u=react.useCallback(()=>{n(null);},[n]),d=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-1 lg:px-2 lg:py-1",s),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(ro,{label:d,isSelected:t===null,onPress:u,showPulse:d===a}),jsxRuntime.jsx(yi,{}),e.map(p=>jsxRuntime.jsx(ro,{label:p.category,isSelected:t===p.category,onPress:()=>n(p.category),badge:p.badge,showPulse:p.category===a},p.category))]})}),l&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:l})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(no,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(p=>jsxRuntime.jsx(no,{label:p.label,icon:p.icon,isSelected:r===p.label,onPress:()=>i(p.label)},p.label))]})})]})}function ro({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function yi(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function no({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function df({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function ki(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Si(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function io({onSelect:e,trailing:t,className:r}){let[o,n]=react.useState(null),[i,l]=react.useState(null),a=react.useCallback(p=>{n(p),l(null),e?.({categorySlug:p,tagSlug:null});},[e]),s=react.useCallback(p=>{l(p),e?.({categorySlug:o,tagSlug:p});},[o,e]),c=ki(Wr),u=Wr.find(p=>p.slug===o),d=Si(u);return jsxRuntime.jsx(oo,{categories:c,selectedCategory:o,selectedTag:i,activeTags:d,onCategorySelect:a,onTagSelect:s,trailing:t,className:r})}function lo(e){return {title:e.title,imageUrl:e.image_url}}function co(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 Rt=48,Ur=4,sr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Me={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ar=Me.ALL,bf={[Me.ONE_DAY]:sr.ONE_MINUTE,[Me.ONE_WEEK]:sr.ONE_HOUR,[Me.ONE_MONTH]:sr.ONE_HOUR,[Me.ALL]:sr.ONE_DAY},yf={[Me.ONE_DAY]:300,[Me.ONE_WEEK]:3600,[Me.ONE_MONTH]:10800,[Me.ALL]:1440*60},kf={[Me.ONE_DAY]:1440*60,[Me.ONE_WEEK]:10080*60,[Me.ONE_MONTH]:720*60*60,[Me.ALL]:null},Kr=1,Sf=1,Nf=1,wf=99,xt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Pf=xt.ONE_WEEK,Cf={[xt.ONE_HOUR]:60,[xt.SIX_HOURS]:60,[xt.ONE_DAY]:300,[xt.ONE_WEEK]:1800,[xt.MAX]:1800};var mo=react.createContext(null);function jr(){let e=react.useContext(mo);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Ti=1e4;function Li({pollingInterval:e=Ti,enabled:t=true,children:r}){let o=walletConnector.useWallets(),n=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.SOLANA&&v.isConnected)?.address,[o]),i=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.EVM&&v.isConnected)?.address,[o]),{data:l,isLoading:a,isFetching:s,error:c}=reactPredict.useBalance({source:"kalshi",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:u,isLoading:d}=reactPredict.useDFlowKYC(n,{enabled:t&&!!n,refetchInterval:3e4}),{data:p,isLoading:m}=reactPredict.usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=p?.safe_address,g=p?.verified??false,{data:h,isLoading:x,isFetching:C,error:b}=reactPredict.useBalance({source:"polymarket",user:f??""},{enabled:t&&g&&!!f,refetchInterval:e}),N=react.useMemo(()=>({solanaAddress:n,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:l?Number(l.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:u?.verified??false,kalshiKycUrl:u?.kyc_url??null,kalshiKycLoading:d,polymarketSetupVerified:g,polymarketSafeDeployed:p?.safe_deployed??false,polymarketTokenApproved:p?.token_approved??false,polymarketSetupLoading:m,isLoading:a||x,isFetching:s||C,error:c??b??null}),[n,i,f,l,h,g,u,d,p,m,a,x,s,C,c,b]);return jsxRuntime.jsx(mo.Provider,{value:N,children:r})}var Xi={minutes:60,hours:3600,days:86400};function Zi(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*Xi[r]}}function Yr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Gr__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Gr__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Gr__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function xo({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=i18n.useTranslation(),{status:n}=walletConnector.useAuth(),i=walletConnector.useWallets(),l=walletConnector.useSwitchChain(),a=reactPredict.usePredictClient(),s=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),u=e.source,d=u==="polymarket",p=i.find(P=>P.chainNamespace===types.ChainNamespace.SOLANA&&P.isConnected),m=i.find(P=>P.chainNamespace===types.ChainNamespace.EVM&&P.isConnected&&"switchChain"in P),f=n==="authenticated",g=p?.address,h=m?.address,[x,C]=react.useState(t),[b,N]=react.useState(r),[v,$]=react.useState("market"),[y,X]=react.useState(NaN),[V,ae]=react.useState(NaN),[K,O]=react.useState(false),[F,H]=react.useState(null),[se,me]=react.useState(null),[M,L]=react.useState(false),[W,_]=react.useState(false),[oe,he]=react.useState("1h"),[fe,Ze]=react.useState(30),[at,Or]=react.useState("minutes"),We=null,Zt=false,Jt=null,gt;try{let P=jr();We={kalshiUsdcBalance:P.kalshiUsdcBalance,polymarketUsdcBalance:P.polymarketUsdcBalance,isLoading:P.isLoading},Zt=P.kalshiKycVerified,Jt=P.kalshiKycUrl,gt=P.polymarketSafeAddress;}catch{}let ke=react.useMemo(()=>{let P=x==="yes"?0:1,Q=e.outcomes[P];return b==="buy"?Q?.best_ask??Q?.price??.5:Q?.best_bid??Q?.price??.5},[e.outcomes,x,b]),Ar=react.useCallback(P=>{$(P);},[]),D=react.useCallback(P=>{C(P),ae(NaN);},[]);react.useEffect(()=>{v==="limit"&&isNaN(V)&&ae(Math.round(ke*100)/100);},[v,V,ke]);let _e=react.useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?ke>0?y/ke:0:y,[b,y,ke]),Ue=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),ja=e.provider_meta?.["dflow.yesMint"]??"",Ga=e.provider_meta?.["dflow.noMint"]??"",it=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ya=e.provider_meta?.["dflow.collateralMint"]||"",Un=x==="yes"?ja:Ga,Kn=u==="kalshi"?g??"":h??"",{data:Re,isLoading:qa}=reactPredict.usePositions({source:u,user:Kn},{enabled:!!Kn}),Vn=react.useMemo(()=>!Re||b!=="sell"?null:Re.positions.find(P=>P.side?.toLowerCase()===x&&P.market?.slug===e.slug)??null,[Re,e.slug,x,b])?.market?.provider_meta,Qa=b==="sell"&&Vn?.["dflow.outcomeMint"]||Un,Et=b==="sell"&&Vn?.["dflow.collateralMint"]||Ya,Tt=b==="buy"?it:Qa,Lt=b==="buy"?Un:Et||it,Xa=u==="kalshi"&&!!Tt&&!!Lt&&!!g&&Ue!=="0",{refetch:jn}=reactPredict.useDFlowQuote({inputMint:Tt,outputMint:Lt,amount:Ue,userPublicKey:g??"",slippageBps:100},{enabled:Xa}),er=react.useMemo(()=>We?u==="kalshi"?We.kalshiUsdcBalance:We.polymarketUsdcBalance:Re&&Re.positions.reduce((Q,Ce)=>Ce.side==="USDC"||Ce.side==="collateral"?Q+(Ce.current_value??0):Q,0)||null,[We,Re,u]),Za=We?We.isLoading:qa,Dr=react.useMemo(()=>Re?Re.positions.find(Q=>Q.side?.toLowerCase()==="yes"&&Q.market?.slug===e.slug)?.size??0:null,[Re,e.slug]),Fr=react.useMemo(()=>Re?Re.positions.find(Q=>Q.side?.toLowerCase()==="no"&&Q.market?.slug===e.slug)?.size??0:null,[Re,e.slug]),Hr=react.useMemo(()=>v==="limit"&&d&&!isNaN(V)?V:ke,[v,d,V,ke]),tr=react.useMemo(()=>{if(isNaN(y)||y<=0)return 0;if(b==="buy")return y;let P=x==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return y*P},[b,x,y,e.outcomes]),Gn=react.useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?Hr>0?y/Hr*1:0:tr,[b,y,Hr,tr]),Ja=Gn-tr,ei=react.useCallback(P=>{N(P),X(NaN);},[]),ti=react.useCallback(P=>{if(isNaN(P)){X(NaN);return}let Q=Math.max(0,P),Ce=b==="buy"?Math.round(Q*100)/100:Math.round(Q);X(Ce);},[b]),ri=react.useCallback(P=>{if(isNaN(P)){ae(NaN);return}let Q=Math.max(.01,Math.min(.99,P));ae(Math.round(Q*100)/100);},[]),Br=react.useMemo(()=>{let P=[];(isNaN(y)||y<Kr)&&P.push(`Minimum quantity is ${Kr}`),e.status!=="open"&&P.push("Market is not active"),b==="buy"&&er!=null&&!isNaN(y)&&y>0&&y>er&&P.push("Insufficient USDC balance");let Q=x==="yes"?Dr:Fr;return b==="sell"&&Q!=null&&!isNaN(y)&&y>0&&y>Q&&P.push("Insufficient shares"),v==="limit"&&d&&(isNaN(V)||V<.01||V>.99)&&P.push("Limit price must be between $0.01 and $0.99"),v==="limit"&&d&&W&&oe==="custom"&&(isNaN(fe)||fe<=0)&&P.push(o("predict.trade.expiration.invalidDate")),{isValid:P.length===0,errors:P}},[y,e.status,b,er,Dr,Fr,x,v,d,V,W,oe,fe,o]),{mutateAsync:rr}=reactPredict.useDFlowSubmit(),{data:$r}=reactPredict.useOrder({id:F??"",source:u},{enabled:!!F}),Yn=react.useCallback(async()=>{if(!se||!g||!p)return;let{cashAmount:P,collateral:Q}=se;me(null);try{let lt=(await a.createDFlowQuote({inputMint:Q,outputMint:it,amount:P,userPublicKey:g,slippageBps:100}))?.transaction;if(!lt)return;let Je=Uint8Array.from(atob(lt),_t=>_t.charCodeAt(0)),Ke=await p.signTransaction(Je);await rr({signedTransaction:btoa(String.fromCharCode(...Ke)),orderContext:{user_public_key:g,input_mint:Q,output_mint:it,amount:P,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[se,g,p,a,rr,it]);react.useEffect(()=>{if(!$r||!F)return;let{status:P}=$r;P==="closed"?(H(null),se?Yn().finally(()=>{O(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),X(NaN);}):(O(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),X(NaN))):(P==="failed"||P==="expired")&&(O(false),H(null),me(null),ui.toast.error(o("predict.trade.submitError")));},[$r,F,se,Yn,o]);let qn=react.useCallback(async()=>{if(!g||!p)return;if(!Tt||!Lt){ui.toast.error("Missing token mint addresses"),O(false);return}if(!Zt){L(true),O(false);return}let Ce=(await jn()).data,lt=Ce?.transaction;if(!lt){ui.toast.error(o("predict.trade.submitError")),O(false);return}if(b==="sell"&&Et&&Et!==it){let et=String(Ce?.outAmount??"");et&&et!=="0"&&me({cashAmount:et,collateral:Et});}let Je=Uint8Array.from(atob(lt),et=>et.charCodeAt(0)),Ke=await p.signTransaction(Je),_t=await rr({signedTransaction:btoa(String.fromCharCode(...Ke)),orderContext:{user_public_key:g,input_mint:Tt,output_mint:Lt,amount:Ue,price:String(ke),side:b==="buy"?"BUY":"SELL",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});H(_t.signature);},[g,p,a,jn,rr,Tt,Lt,Ue,ke,b,x,e.slug,Et,it,o]),Qn=react.useCallback(async()=>{if(!m||!s)return;let P=m.chain,Q=P!==types.Chain.POLYGON;Q&&await l(types.Chain.POLYGON);try{let Ce=await m.getEip1193Provider();if(!Ce){ui.toast.error(o("predict.trade.submitError")),O(!1);return}let lt=!!gt,Je={address:m.address,signatureType:lt?2:0,signTypedData:async(ct,ui,pi,mi)=>{let ht=[];"name"in ct&&ht.push({name:"name",type:"string"}),"version"in ct&&ht.push({name:"version",type:"string"}),"chainId"in ct&&ht.push({name:"chainId",type:"uint256"}),"verifyingContract"in ct&&ht.push({name:"verifyingContract",type:"address"}),"salt"in ct&&ht.push({name:"salt",type:"bytes32"});let fi={EIP712Domain:ht,...ui};return await Ce.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:ct,types:fi,primaryType:pi,message:mi})]})}},Ke=s.credentials??await s.authenticate(Je),_t=x==="yes"?0:1,et="",nr=e.provider_meta?.["polymarket.clobTokenIds"];nr&&(et=(typeof nr=="string"?JSON.parse(nr):nr)[_t]??"");let Xn=e.provider_meta?.["polymarket.negRisk"]??!1,zr=v==="limit"&&!isNaN(V)?V:ke,oi=v==="limit"?W?"GTD":"GTC":"FOK",si=b==="buy"&&zr>0?y/zr:y,Zn={tokenId:et,price:zr,size:si,side:b==="buy"?"BUY":"SELL",orderType:oi,tickSize:"0.01",negRisk:Xn,...gt&&{funderAddress:gt},...v==="limit"&&W&&{expiration:Zi(oe,fe,at)}},ai=reactPredict.buildCtfExchangeDomain(Xn),Jn=reactPredict.buildOrderMessage({...Zn,signerAddress:Je.address,signatureType:Je.signatureType}),ii=await Je.signTypedData(ai,reactPredict.CTF_ORDER_TYPES,"Order",Jn),li=reactPredict.buildSignedOrder(Jn,ii,Zn.orderType),eo=reactPredict.buildClobPayload(li,Ke.apiKey),ci=JSON.stringify(eo),di=await reactPredict.buildPolymarketL2Headers(Ke.address,{apiKey:Ke.apiKey,secret:Ke.secret,passphrase:Ke.passphrase,method:"POST",requestPath:"/order",body:ci});await a.createPolymarketOrder(eo,di),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),X(NaN),O(!1);}finally{Q&&P&&l(P).catch(()=>{});}},[m,s,l,x,e.provider_meta,v,V,ke,y,b,a,c,W,oe,fe,at,o]),ni=react.useCallback(async()=>{if(!(!Br.isValid||!f)){O(true),H(null),L(false);try{u==="kalshi"?await qn():await Qn();}catch{ui.toast.error(o("predict.trade.submitError")),O(false);}}},[Br.isValid,f,u,qn,Qn,o]);return {outcome:x,side:b,orderType:v,quantity:y,limitPrice:V,shares:_e,estimatedCost:tr,potentialPayout:Gn,potentialProfit:Ja,usdcBalance:er,yesTokenBalance:Dr,noTokenBalance:Fr,isBalanceLoading:Za,isSubmitting:K,validation:Br,supportsLimitOrder:d,kycRequired:M,kycUrl:Jt,expirationEnabled:W,expirationPreset:oe,customDuration:fe,customDurationUnit:at,setOutcome:D,setSide:ei,setOrderType:Ar,setQuantity:ti,setLimitPrice:ri,setExpirationEnabled:_,setExpirationPreset:he,setCustomDuration:Ze,setCustomDurationUnit:Or,submit:ni}}function bo({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Modal,{isOpen:e,onClose:t,size:"md",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"flex flex-col gap-1",children:jsxRuntime.jsxs("span",{className:"text-lg",children:["\u{1F6E1}\uFE0F ",o("predict.trade.kycModalTitle")]})}),jsxRuntime.jsxs(ui.ModalBody,{className:"gap-y-4",children:[jsxRuntime.jsx("p",{className:"text-sm text-default-600",children:o("predict.trade.kycModalDescription")}),jsxRuntime.jsxs("ul",{className:"flex flex-col gap-y-2 text-sm text-foreground",children:[jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:o("predict.trade.kycModalBullet1")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:o("predict.trade.kycModalBullet2")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:o("predict.trade.kycModalBullet3")})]})]}),jsxRuntime.jsx("p",{className:"text-xs text-default-400",children:o("predict.trade.kycModalNote")})]}),jsxRuntime.jsxs(ui.ModalFooter,{children:[jsxRuntime.jsx(ui.Button,{variant:"light",onPress:t,children:o("common.cancel")}),r&&jsxRuntime.jsx(ui.Button,{color:"primary",onPress:()=>{window.open(r,"_blank","noopener,noreferrer"),t();},children:o("predict.trade.goToKYC")})]})]})})}var ml=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,fl=["5m","1h","12h","24h","eod","custom"],gl={"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"},hl=["minutes","hours","days"],xl={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function Co({event:e,market:t,variant:r="bordered",outcome:o,side:n,orderType:i,quantity:l,limitPrice:a,shares:s,potentialProfit:c,potentialPayout:u,estimatedCost:d,usdcBalance:p,yesTokenBalance:m,noTokenBalance:f,isBalanceLoading:g,isSubmitting:h,isValid:x,validationErrors:C,supportsLimitOrder:b,kycRequired:N,kycUrl:v,expirationEnabled:$,expirationPreset:y,customDuration:X,customDurationUnit:V,onOutcomeChange:ae,onSideChange:K,onOrderTypeChange:O,onQuantityChange:F,onLimitPriceChange:H,onExpirationEnabledChange:se,onExpirationPresetChange:me,onCustomDurationChange:M,onCustomDurationUnitChange:L,onSubmit:W}){let{t:_}=i18n.useTranslation(),[oe,he]=react.useState(false),fe=ui.useDisclosure();react.useEffect(()=>{N&&!fe.isOpen&&fe.onOpen();},[N]);let Ze=react.useMemo(()=>{let D=n==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return D!=null?parseFloat((Number(D)*100).toFixed(2)):null},[n,o,t]),at=!isNaN(l)&&l>0,Or=react.useMemo(()=>{if(h)return _("predict.trade.submitting");if(N)return _("predict.trade.kycRequired");if(!at)return _("predict.trade.enterAmount");let D=_(n==="buy"?"predict.trade.buy":"predict.trade.sell"),_e=_(o==="yes"?"predict.trade.yes":"predict.trade.no"),Ue=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${D} ${_e}${Ue}`},[h,N,at,n,o,c,_]),We=react.useMemo(()=>o==="yes"?"primary":"secondary",[o]),Zt=()=>{F(Math.floor((p??0)/2*100)/100);},Jt=()=>{F(p??0);},[gt,ke]=react.useState(false),Ar=()=>{if(N){fe.onOpen();return}if(!x){ke(true);return}ke(false),W();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui.cn("flex w-full flex-col gap-y-4 p-4",r==="bordered"&&"rounded-xl border border-default-200 bg-content1"),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:o==="yes"?"text-bullish":"text-bearish",children:[_(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",_(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[b?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:i,onSelectionChange:D=>O(D),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:_("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:_("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:_("predict.trade.market")}),i==="limit"&&b?jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(a)?void 0:parseFloat((a*100).toFixed(2)),onValueChange:D=>H(D/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits:2},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ze!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ze," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(D=>{let _e=D==="yes"?m:f;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>ae(D),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===D?D==="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:_(D==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let Ue=n==="buy"?D==="yes"?t.yesAsk:t.noAsk:D==="yes"?t.yesBid:t.noBid;return Ue!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Ue)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===D&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${_e??0} shares`})]},D)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:_(n==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),n==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:ml,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?`${p.toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:Zt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:_("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:Jt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:_("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(l)?void 0:l,onValueChange:D=>{ke(false),F(D);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},n),n==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(D=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{F(Math.floor((o==="yes"?m??0:f??0)*D/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[D,"%"]},D)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{F(o==="yes"?m??0:f??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:_("common.all")})]}),gt&&C.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:C.map(D=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:D},D))})]}),i==="limit"&&b&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:_("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:$,onValueChange:se,"aria-label":_("predict.trade.setExpiration")})]}),$&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":_("predict.trade.setExpiration"),selectedKeys:[y],onSelectionChange:D=>{let _e=Array.from(D)[0];_e&&me(_e);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:fl.map(D=>jsxRuntime.jsx(ui.SelectItem,{children:_(gl[D])},D))}),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(X)?void 0:X,onValueChange:M,minValue:1,step:1,formatOptions:{maximumFractionDigits:0},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:[V],onSelectionChange:D=>{let _e=Array.from(D)[0];_e&&L(_e);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:hl.map(D=>jsxRuntime.jsx(ui.SelectItem,{children:_(xl[D])},D))})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>he(D=>!D),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:_("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",oe&&"rotate-180")})]}),Ze!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Ze,"% chance"]})]}),oe&&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:"Total Size"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"No. of Contracts"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?parseFloat(s.toFixed(2)):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Payout"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Est. Profit"}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(l)&&l>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:We,fullWidth:true,radius:"lg",size:"lg",isDisabled:!at||h,isLoading:h,onPress:Ar,children:Or})]}),jsxRuntime.jsx(bo,{isOpen:fe.isOpen,onClose:fe.onClose,kycUrl:v})]})}function ir({event:e,market:t,variant:r,initialSide:o,initialOutcome:n,chain:i}){let{outcome:l,side:a,orderType:s,quantity:c,limitPrice:u,shares:d,estimatedCost:p,potentialPayout:m,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:C,isSubmitting:b,validation:N,supportsLimitOrder:v,kycRequired:$,kycUrl:y,expirationEnabled:X,expirationPreset:V,customDuration:ae,customDurationUnit:K,setOutcome:O,setSide:F,setOrderType:H,setQuantity:se,setLimitPrice:me,setExpirationEnabled:M,setExpirationPreset:L,setCustomDuration:W,setCustomDurationUnit:_,submit:oe}=xo({market:t,initialSide:o,initialOutcome:n}),he=walletConnector.useAuthCallback(oe),fe=react.useMemo(()=>e?lo(e):void 0,[e]),Ze=react.useMemo(()=>co(t),[t]);return jsxRuntime.jsx(Co,{event:fe,market:Ze,variant:r,outcome:l,side:a,orderType:s,quantity:c,limitPrice:u,shares:d,estimatedCost:p,potentialPayout:m,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:C,isSubmitting:b,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:v,kycRequired:$,kycUrl:y,expirationEnabled:X,expirationPreset:V,customDuration:ae,customDurationUnit:K,onOutcomeChange:O,onSideChange:F,onOrderTypeChange:H,onQuantityChange:se,onLimitPriceChange:me,onExpirationEnabledChange:M,onExpirationPresetChange:L,onCustomDurationChange:W,onCustomDurationUnitChange:_,onSubmit:he})}var It="predict-trade";function lr({id:e=It}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Pl,{...t})})}function Pl({params:e,isOpen:t,onOpenChange:r}){let{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",radius:"lg",children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsx(ui.ModalBody,{className:"p-2",children:jsxRuntime.jsx(ir,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})})}):null}var Xr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Zr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function To({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[i,l]=react.useState(r),a=react.useCallback(h=>{h?l(r):t();},[r,t]),s=react.useCallback(()=>{l(Xr);},[]),c=react.useCallback(()=>{o(i),t();},[i,o,t]),u=react.useCallback((h,x)=>{l(C=>({...C,[h]:x}));},[]),d=react.useMemo(()=>Zr(i),[i]),p=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"kalshi",label:n("predict.platform.kalshi")}],[n]),m=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),f=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),g=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:a,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(dr,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(ur,{options:p,selected:i.source,onSelect:h=>u("source",h)})}),jsxRuntime.jsx(dr,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(ur,{options:m,selected:i.timeRemaining,onSelect:h=>u("timeRemaining",h)})}),jsxRuntime.jsx(dr,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(ur,{options:f,selected:i.minVolume,onSelect:h=>u("minVolume",h)})}),jsxRuntime.jsx(dr,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(ur,{options:g,selected:i.minLiquidity,onSelect:h=>u("minLiquidity",h)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:s,children:n("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[n("predict.filter.showResults"),d>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",d,")"]})]})]})})]})})}function dr({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function ur({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let i=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&o?void 0:n.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var Io={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},_o={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Vl=["start_time","volume","liquidity","ending_soon"];function Oo({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:l}){let{t:a}=i18n.useTranslation(),[s,c]=react.useState(false),u=react.useRef(null);react.useEffect(()=>{if(!s)return;let p=f=>{u.current&&!u.current.contains(f.target)&&c(false);},m=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m);}},[s]);let d=Ro[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",l),children:[jsxRuntime.jsxs("div",{ref:u,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(d,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:a(_o[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),s&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:Vl.map(p=>{let m=Ro[p];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(p),c(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",p===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:a(_o[p])})]},p)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:a("predict.filter.title")})]})})]})}var Ro={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function Fo(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]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:i,isError:l,error:a,hasNextPage:s,fetchNextPage:c,refetch:u}=reactPredict.useInfiniteEvents(t),d=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),p=react.useCallback(()=>{c();},[c]),m=react.useCallback(()=>{u();},[u]);return {data:d,isLoading:o,isFetching:n&&!i,isFetchingMore:i,isError:l,error:a??null,hasMore:s??false,fetchMore:p,refetch:m}}function Jr({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-11/12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-1/2 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-3/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-2/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-24 rounded"})]})]})},r))})}function Rg({count:e=48}){return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Jr,{count:e})})]})}var Ho=3,tn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ko={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},ec={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Dt=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function Bo(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function tc(e){let t=e.outcomes?.map(l=>l.label?.toLowerCase().trim()??"")??[];if(t.some(l=>l==="up")&&t.some(l=>l==="down"))return [tn,ec];if(t.some(l=>l==="yes")&&t.some(l=>l==="no"))return [tn,Ko];let r=t[0]??"",o=t[1]??"",n=Bo(r)%Dt.length,i=Bo(o)%Dt.length;return i===n&&(i=(i+1)%Dt.length),[Dt[n],Dt[i]]}function rc(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Vo(e){let t=rc(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function jo(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function $o(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function zo(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return parseFloat((n*100).toFixed(2)).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function nc(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),o>0&&i.push(`${o}h`),i.push(`${n}m`),i.join(" ")}var oc=`
|
|
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'),Gr=require('canvas-confetti'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),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 Gr__default=/*#__PURE__*/_interopDefault(Gr);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.104");var gi="0.1.104";var hi={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},to=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Wr=(()=>{let e=t=>{let r=to.indexOf(t);return r===-1?to.length:r};return Object.entries(hi).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function oo({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:i,trailing:l,pulsingTab:a="Trending",className:s}){let{t:c}=i18n.useTranslation(),u=react.useCallback(()=>{n(null);},[n]),d=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-1 lg:px-2 lg:py-1",s),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(ro,{label:d,isSelected:t===null,onPress:u,showPulse:d===a}),jsxRuntime.jsx(yi,{}),e.map(p=>jsxRuntime.jsx(ro,{label:p.category,isSelected:t===p.category,onPress:()=>n(p.category),badge:p.badge,showPulse:p.category===a},p.category))]})}),l&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:l})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(no,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),o.map(p=>jsxRuntime.jsx(no,{label:p.label,icon:p.icon,isSelected:r===p.label,onPress:()=>i(p.label)},p.label))]})})]})}function ro({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function yi(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function no({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function df({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function ki(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Si(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function io({onSelect:e,trailing:t,className:r}){let[o,n]=react.useState(null),[i,l]=react.useState(null),a=react.useCallback(p=>{n(p),l(null),e?.({categorySlug:p,tagSlug:null});},[e]),s=react.useCallback(p=>{l(p),e?.({categorySlug:o,tagSlug:p});},[o,e]),c=ki(Wr),u=Wr.find(p=>p.slug===o),d=Si(u);return jsxRuntime.jsx(oo,{categories:c,selectedCategory:o,selectedTag:i,activeTags:d,onCategorySelect:a,onTagSelect:s,trailing:t,className:r})}function lo(e){return {title:e.title,imageUrl:e.image_url}}function co(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 Rt=48,Ur=4,sr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Me={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ar=Me.ALL,bf={[Me.ONE_DAY]:sr.ONE_MINUTE,[Me.ONE_WEEK]:sr.ONE_HOUR,[Me.ONE_MONTH]:sr.ONE_HOUR,[Me.ALL]:sr.ONE_DAY},yf={[Me.ONE_DAY]:300,[Me.ONE_WEEK]:3600,[Me.ONE_MONTH]:10800,[Me.ALL]:1440*60},kf={[Me.ONE_DAY]:1440*60,[Me.ONE_WEEK]:10080*60,[Me.ONE_MONTH]:720*60*60,[Me.ALL]:null},Kr=1,Sf=1,Nf=1,wf=99,xt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Pf=xt.ONE_WEEK,Cf={[xt.ONE_HOUR]:60,[xt.SIX_HOURS]:60,[xt.ONE_DAY]:300,[xt.ONE_WEEK]:1800,[xt.MAX]:1800};var mo=react.createContext(null);function jr(){let e=react.useContext(mo);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Ti=1e4;function Li({pollingInterval:e=Ti,enabled:t=true,children:r}){let o=walletConnector.useWallets(),n=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.SOLANA&&v.isConnected)?.address,[o]),i=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.EVM&&v.isConnected)?.address,[o]),{data:l,isLoading:a,isFetching:s,error:c}=reactPredict.useBalance({source:"kalshi",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:u,isLoading:d}=reactPredict.useDFlowKYC(n,{enabled:t&&!!n,refetchInterval:3e4}),{data:p,isLoading:m}=reactPredict.usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=p?.safe_address,g=p?.verified??false,{data:h,isLoading:x,isFetching:C,error:b}=reactPredict.useBalance({source:"polymarket",user:f??""},{enabled:t&&g&&!!f,refetchInterval:e}),N=react.useMemo(()=>({solanaAddress:n,evmAddress:i,polymarketSafeAddress:f,kalshiUsdcBalance:l?Number(l.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:u?.verified??false,kalshiKycUrl:u?.kyc_url??null,kalshiKycLoading:d,polymarketSetupVerified:g,polymarketSafeDeployed:p?.safe_deployed??false,polymarketTokenApproved:p?.token_approved??false,polymarketSetupLoading:m,isLoading:a||x,isFetching:s||C,error:c??b??null}),[n,i,f,l,h,g,u,d,p,m,a,x,s,C,c,b]);return jsxRuntime.jsx(mo.Provider,{value:N,children:r})}var Xi={minutes:60,hours:3600,days:86400};function Zi(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*Xi[r]}}function Yr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Gr__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Gr__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Gr__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function xo({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=i18n.useTranslation(),{status:n}=walletConnector.useAuth(),i=walletConnector.useWallets(),l=walletConnector.useSwitchChain(),a=reactPredict.usePredictClient(),s=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),u=e.source,d=u==="polymarket",p=i.find(P=>P.chainNamespace===types.ChainNamespace.SOLANA&&P.isConnected),m=i.find(P=>P.chainNamespace===types.ChainNamespace.EVM&&P.isConnected&&"switchChain"in P),f=n==="authenticated",g=p?.address,h=m?.address,[x,C]=react.useState(t),[b,N]=react.useState(r),[v,$]=react.useState("market"),[y,X]=react.useState(NaN),[V,ae]=react.useState(NaN),[K,O]=react.useState(false),[F,H]=react.useState(null),[se,me]=react.useState(null),[M,L]=react.useState(false),[W,_]=react.useState(false),[oe,he]=react.useState("1h"),[fe,Ze]=react.useState(30),[at,Or]=react.useState("minutes"),We=null,Zt=false,Jt=null,gt;try{let P=jr();We={kalshiUsdcBalance:P.kalshiUsdcBalance,polymarketUsdcBalance:P.polymarketUsdcBalance,isLoading:P.isLoading},Zt=P.kalshiKycVerified,Jt=P.kalshiKycUrl,gt=P.polymarketSafeAddress;}catch{}let ke=react.useMemo(()=>{let P=x==="yes"?0:1,Q=e.outcomes[P];return b==="buy"?Q?.best_ask??Q?.price??.5:Q?.best_bid??Q?.price??.5},[e.outcomes,x,b]),Ar=react.useCallback(P=>{$(P);},[]),D=react.useCallback(P=>{C(P),ae(NaN);},[]);react.useEffect(()=>{v==="limit"&&isNaN(V)&&ae(Math.round(ke*100)/100);},[v,V,ke]);let _e=react.useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?ke>0?y/ke:0:y,[b,y,ke]),Ue=react.useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),ja=e.provider_meta?.["dflow.yesMint"]??"",Ga=e.provider_meta?.["dflow.noMint"]??"",it=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ya=e.provider_meta?.["dflow.collateralMint"]||"",Un=x==="yes"?ja:Ga,Kn=u==="kalshi"?g??"":h??"",{data:Re,isLoading:qa}=reactPredict.usePositions({source:u,user:Kn},{enabled:!!Kn}),Vn=react.useMemo(()=>!Re||b!=="sell"?null:Re.positions.find(P=>P.side?.toLowerCase()===x&&P.market?.slug===e.slug)??null,[Re,e.slug,x,b])?.market?.provider_meta,Qa=b==="sell"&&Vn?.["dflow.outcomeMint"]||Un,Et=b==="sell"&&Vn?.["dflow.collateralMint"]||Ya,Tt=b==="buy"?it:Qa,Lt=b==="buy"?Un:Et||it,Xa=u==="kalshi"&&!!Tt&&!!Lt&&!!g&&Ue!=="0",{refetch:jn}=reactPredict.useDFlowQuote({inputMint:Tt,outputMint:Lt,amount:Ue,userPublicKey:g??"",slippageBps:100},{enabled:Xa}),er=react.useMemo(()=>We?u==="kalshi"?We.kalshiUsdcBalance:We.polymarketUsdcBalance:Re&&Re.positions.reduce((Q,Ce)=>Ce.side==="USDC"||Ce.side==="collateral"?Q+(Ce.current_value??0):Q,0)||null,[We,Re,u]),Za=We?We.isLoading:qa,Dr=react.useMemo(()=>Re?Re.positions.find(Q=>Q.side?.toLowerCase()==="yes"&&Q.market?.slug===e.slug)?.size??0:null,[Re,e.slug]),Fr=react.useMemo(()=>Re?Re.positions.find(Q=>Q.side?.toLowerCase()==="no"&&Q.market?.slug===e.slug)?.size??0:null,[Re,e.slug]),Hr=react.useMemo(()=>v==="limit"&&d&&!isNaN(V)?V:ke,[v,d,V,ke]),tr=react.useMemo(()=>{if(isNaN(y)||y<=0)return 0;if(b==="buy")return y;let P=x==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return y*P},[b,x,y,e.outcomes]),Gn=react.useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?Hr>0?y/Hr*1:0:tr,[b,y,Hr,tr]),Ja=Gn-tr,ei=react.useCallback(P=>{N(P),X(NaN);},[]),ti=react.useCallback(P=>{if(isNaN(P)){X(NaN);return}let Q=Math.max(0,P),Ce=b==="buy"?Math.round(Q*100)/100:Math.round(Q);X(Ce);},[b]),ri=react.useCallback(P=>{if(isNaN(P)){ae(NaN);return}let Q=Math.max(.01,Math.min(.99,P));ae(Math.round(Q*100)/100);},[]),Br=react.useMemo(()=>{let P=[];(isNaN(y)||y<Kr)&&P.push(`Minimum quantity is ${Kr}`),e.status!=="open"&&P.push("Market is not active"),b==="buy"&&er!=null&&!isNaN(y)&&y>0&&y>er&&P.push("Insufficient USDC balance");let Q=x==="yes"?Dr:Fr;return b==="sell"&&Q!=null&&!isNaN(y)&&y>0&&y>Q&&P.push("Insufficient shares"),v==="limit"&&d&&(isNaN(V)||V<.01||V>.99)&&P.push("Limit price must be between $0.01 and $0.99"),v==="limit"&&d&&W&&oe==="custom"&&(isNaN(fe)||fe<=0)&&P.push(o("predict.trade.expiration.invalidDate")),{isValid:P.length===0,errors:P}},[y,e.status,b,er,Dr,Fr,x,v,d,V,W,oe,fe,o]),{mutateAsync:rr}=reactPredict.useDFlowSubmit(),{data:$r}=reactPredict.useOrder({id:F??"",source:u},{enabled:!!F}),Yn=react.useCallback(async()=>{if(!se||!g||!p)return;let{cashAmount:P,collateral:Q}=se;me(null);try{let lt=(await a.createDFlowQuote({inputMint:Q,outputMint:it,amount:P,userPublicKey:g,slippageBps:100}))?.transaction;if(!lt)return;let Je=Uint8Array.from(atob(lt),_t=>_t.charCodeAt(0)),Ke=await p.signTransaction(Je);await rr({signedTransaction:btoa(String.fromCharCode(...Ke)),orderContext:{user_public_key:g,input_mint:Q,output_mint:it,amount:P,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[se,g,p,a,rr,it]);react.useEffect(()=>{if(!$r||!F)return;let{status:P}=$r;P==="closed"?(H(null),se?Yn().finally(()=>{O(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),X(NaN);}):(O(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),X(NaN))):(P==="failed"||P==="expired")&&(O(false),H(null),me(null),ui.toast.error(o("predict.trade.submitError")));},[$r,F,se,Yn,o]);let qn=react.useCallback(async()=>{if(!g||!p)return;if(!Tt||!Lt){ui.toast.error("Missing token mint addresses"),O(false);return}if(!Zt){L(true),O(false);return}let Ce=(await jn()).data,lt=Ce?.transaction;if(!lt){ui.toast.error(o("predict.trade.submitError")),O(false);return}if(b==="sell"&&Et&&Et!==it){let et=String(Ce?.outAmount??"");et&&et!=="0"&&me({cashAmount:et,collateral:Et});}let Je=Uint8Array.from(atob(lt),et=>et.charCodeAt(0)),Ke=await p.signTransaction(Je),_t=await rr({signedTransaction:btoa(String.fromCharCode(...Ke)),orderContext:{user_public_key:g,input_mint:Tt,output_mint:Lt,amount:Ue,price:String(ke),side:b==="buy"?"BUY":"SELL",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});H(_t.signature);},[g,p,a,jn,rr,Tt,Lt,Ue,ke,b,x,e.slug,Et,it,o]),Qn=react.useCallback(async()=>{if(!m||!s)return;let P=m.chain,Q=P!==types.Chain.POLYGON;Q&&await l(types.Chain.POLYGON);try{let Ce=await m.getEip1193Provider();if(!Ce){ui.toast.error(o("predict.trade.submitError")),O(!1);return}let lt=!!gt,Je={address:m.address,signatureType:lt?2:0,signTypedData:async(ct,ui,pi,mi)=>{let ht=[];"name"in ct&&ht.push({name:"name",type:"string"}),"version"in ct&&ht.push({name:"version",type:"string"}),"chainId"in ct&&ht.push({name:"chainId",type:"uint256"}),"verifyingContract"in ct&&ht.push({name:"verifyingContract",type:"address"}),"salt"in ct&&ht.push({name:"salt",type:"bytes32"});let fi={EIP712Domain:ht,...ui};return await Ce.request({method:"eth_signTypedData_v4",params:[m.address,JSON.stringify({domain:ct,types:fi,primaryType:pi,message:mi})]})}},Ke=s.credentials??await s.authenticate(Je),_t=x==="yes"?0:1,et="",nr=e.provider_meta?.["polymarket.clobTokenIds"];nr&&(et=(typeof nr=="string"?JSON.parse(nr):nr)[_t]??"");let Xn=e.provider_meta?.["polymarket.negRisk"]??!1,zr=v==="limit"&&!isNaN(V)?V:ke,oi=v==="limit"?W?"GTD":"GTC":"FOK",si=b==="buy"&&zr>0?y/zr:y,Zn={tokenId:et,price:zr,size:si,side:b==="buy"?"BUY":"SELL",orderType:oi,tickSize:"0.01",negRisk:Xn,...gt&&{funderAddress:gt},...v==="limit"&&W&&{expiration:Zi(oe,fe,at)}},ai=reactPredict.buildCtfExchangeDomain(Xn),Jn=reactPredict.buildOrderMessage({...Zn,signerAddress:Je.address,signatureType:Je.signatureType}),ii=await Je.signTypedData(ai,reactPredict.CTF_ORDER_TYPES,"Order",Jn),li=reactPredict.buildSignedOrder(Jn,ii,Zn.orderType),eo=reactPredict.buildClobPayload(li,Ke.apiKey),ci=JSON.stringify(eo),di=await reactPredict.buildPolymarketL2Headers(Ke.address,{apiKey:Ke.apiKey,secret:Ke.secret,passphrase:Ke.passphrase,method:"POST",requestPath:"/order",body:ci});await a.createPolymarketOrder(eo,di),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),X(NaN),O(!1);}finally{Q&&P&&l(P).catch(()=>{});}},[m,s,l,x,e.provider_meta,v,V,ke,y,b,a,c,W,oe,fe,at,o]),ni=react.useCallback(async()=>{if(!(!Br.isValid||!f)){O(true),H(null),L(false);try{u==="kalshi"?await qn():await Qn();}catch{ui.toast.error(o("predict.trade.submitError")),O(false);}}},[Br.isValid,f,u,qn,Qn,o]);return {outcome:x,side:b,orderType:v,quantity:y,limitPrice:V,shares:_e,estimatedCost:tr,potentialPayout:Gn,potentialProfit:Ja,usdcBalance:er,yesTokenBalance:Dr,noTokenBalance:Fr,isBalanceLoading:Za,isSubmitting:K,validation:Br,supportsLimitOrder:d,kycRequired:M,kycUrl:Jt,expirationEnabled:W,expirationPreset:oe,customDuration:fe,customDurationUnit:at,setOutcome:D,setSide:ei,setOrderType:Ar,setQuantity:ti,setLimitPrice:ri,setExpirationEnabled:_,setExpirationPreset:he,setCustomDuration:Ze,setCustomDurationUnit:Or,submit:ni}}function bo({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Modal,{isOpen:e,onClose:t,size:"md",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"flex flex-col gap-1",children:jsxRuntime.jsxs("span",{className:"text-lg",children:["\u{1F6E1}\uFE0F ",o("predict.trade.kycModalTitle")]})}),jsxRuntime.jsxs(ui.ModalBody,{className:"gap-y-4",children:[jsxRuntime.jsx("p",{className:"text-sm text-default-600",children:o("predict.trade.kycModalDescription")}),jsxRuntime.jsxs("ul",{className:"flex flex-col gap-y-2 text-sm text-foreground",children:[jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:o("predict.trade.kycModalBullet1")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:o("predict.trade.kycModalBullet2")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:o("predict.trade.kycModalBullet3")})]})]}),jsxRuntime.jsx("p",{className:"text-xs text-default-400",children:o("predict.trade.kycModalNote")})]}),jsxRuntime.jsxs(ui.ModalFooter,{children:[jsxRuntime.jsx(ui.Button,{variant:"light",onPress:t,children:o("common.cancel")}),r&&jsxRuntime.jsx(ui.Button,{color:"primary",onPress:()=>{window.open(r,"_blank","noopener,noreferrer"),t();},children:o("predict.trade.goToKYC")})]})]})})}var ml=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,fl=["5m","1h","12h","24h","eod","custom"],gl={"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"},hl=["minutes","hours","days"],xl={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function Co({event:e,market:t,variant:r="bordered",outcome:o,side:n,orderType:i,quantity:l,limitPrice:a,shares:s,potentialProfit:c,potentialPayout:u,estimatedCost:d,usdcBalance:p,yesTokenBalance:m,noTokenBalance:f,isBalanceLoading:g,isSubmitting:h,isValid:x,validationErrors:C,supportsLimitOrder:b,kycRequired:N,kycUrl:v,expirationEnabled:$,expirationPreset:y,customDuration:X,customDurationUnit:V,onOutcomeChange:ae,onSideChange:K,onOrderTypeChange:O,onQuantityChange:F,onLimitPriceChange:H,onExpirationEnabledChange:se,onExpirationPresetChange:me,onCustomDurationChange:M,onCustomDurationUnitChange:L,onSubmit:W}){let{t:_}=i18n.useTranslation(),[oe,he]=react.useState(false),fe=ui.useDisclosure();react.useEffect(()=>{N&&!fe.isOpen&&fe.onOpen();},[N]);let Ze=react.useMemo(()=>{let D=n==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return D!=null?parseFloat((Number(D)*100).toFixed(2)):null},[n,o,t]),at=!isNaN(l)&&l>0,Or=react.useMemo(()=>{if(h)return _("predict.trade.submitting");if(N)return _("predict.trade.kycRequired");if(!at)return _("predict.trade.enterAmount");let D=_(n==="buy"?"predict.trade.buy":"predict.trade.sell"),_e=_(o==="yes"?"predict.trade.yes":"predict.trade.no"),Ue=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${D} ${_e}${Ue}`},[h,N,at,n,o,c,_]),We=react.useMemo(()=>o==="yes"?"primary":"secondary",[o]),Zt=()=>{F(Math.floor((p??0)/2*100)/100);},Jt=()=>{F(p??0);},[gt,ke]=react.useState(false),Ar=()=>{if(N){fe.onOpen();return}if(!x){ke(true);return}ke(false),W();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui.cn("flex w-full flex-col gap-y-4 p-4",r==="bordered"&&"rounded-xl border border-default-200 bg-content1"),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:o==="yes"?"text-bullish":"text-bearish",children:[_(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",_(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[b?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:i,onSelectionChange:D=>O(D),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:_("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:_("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:_("predict.trade.market")}),i==="limit"&&b?jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(a)?void 0:parseFloat((a*100).toFixed(2)),onValueChange:D=>H(D/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits:2},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ze!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ze," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(D=>{let _e=D==="yes"?m:f;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>ae(D),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===D?D==="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:_(D==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let Ue=n==="buy"?D==="yes"?t.yesAsk:t.noAsk:D==="yes"?t.yesBid:t.noBid;return Ue!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Ue)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===D&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${_e??0} shares`})]},D)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:_(n==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),n==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:ml,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?`${p.toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:Zt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:_("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:Jt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:_("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(l)?void 0:l,onValueChange:D=>{ke(false),F(D);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},n),n==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(D=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{F(Math.floor((o==="yes"?m??0:f??0)*D/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[D,"%"]},D)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{F(o==="yes"?m??0:f??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:_("common.all")})]}),gt&&C.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:C.map(D=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:D},D))})]}),i==="limit"&&b&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:_("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:$,onValueChange:se,"aria-label":_("predict.trade.setExpiration")})]}),$&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":_("predict.trade.setExpiration"),selectedKeys:[y],onSelectionChange:D=>{let _e=Array.from(D)[0];_e&&me(_e);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:fl.map(D=>jsxRuntime.jsx(ui.SelectItem,{children:_(gl[D])},D))}),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(X)?void 0:X,onValueChange:M,minValue:1,step:1,formatOptions:{maximumFractionDigits:0},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:[V],onSelectionChange:D=>{let _e=Array.from(D)[0];_e&&L(_e);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:hl.map(D=>jsxRuntime.jsx(ui.SelectItem,{children:_(xl[D])},D))})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>he(D=>!D),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:_("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",oe&&"rotate-180")})]}),Ze!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Ze,"% chance"]})]}),oe&&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:"Total Size"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"No. of Contracts"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?parseFloat(s.toFixed(2)):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Payout"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Est. Profit"}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(l)&&l>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:We,fullWidth:true,radius:"lg",size:"lg",isDisabled:!at||h,isLoading:h,onPress:Ar,children:Or})]}),jsxRuntime.jsx(bo,{isOpen:fe.isOpen,onClose:fe.onClose,kycUrl:v})]})}function ir({event:e,market:t,variant:r,initialSide:o,initialOutcome:n,chain:i}){let{outcome:l,side:a,orderType:s,quantity:c,limitPrice:u,shares:d,estimatedCost:p,potentialPayout:m,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:C,isSubmitting:b,validation:N,supportsLimitOrder:v,kycRequired:$,kycUrl:y,expirationEnabled:X,expirationPreset:V,customDuration:ae,customDurationUnit:K,setOutcome:O,setSide:F,setOrderType:H,setQuantity:se,setLimitPrice:me,setExpirationEnabled:M,setExpirationPreset:L,setCustomDuration:W,setCustomDurationUnit:_,submit:oe}=xo({market:t,initialSide:o,initialOutcome:n}),he=walletConnector.useAuthCallback(oe),fe=react.useMemo(()=>e?lo(e):void 0,[e]),Ze=react.useMemo(()=>co(t),[t]);return jsxRuntime.jsx(Co,{event:fe,market:Ze,variant:r,outcome:l,side:a,orderType:s,quantity:c,limitPrice:u,shares:d,estimatedCost:p,potentialPayout:m,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:C,isSubmitting:b,isValid:N.isValid,validationErrors:N.errors,supportsLimitOrder:v,kycRequired:$,kycUrl:y,expirationEnabled:X,expirationPreset:V,customDuration:ae,customDurationUnit:K,onOutcomeChange:O,onSideChange:F,onOrderTypeChange:H,onQuantityChange:se,onLimitPriceChange:me,onExpirationEnabledChange:M,onExpirationPresetChange:L,onCustomDurationChange:W,onCustomDurationUnitChange:_,onSubmit:he})}var It="predict-trade";function lr({id:e=It}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Pl,{...t})})}function Pl({params:e,isOpen:t,onOpenChange:r}){let{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",radius:"lg",children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsx(ui.ModalBody,{className:"p-2",children:jsxRuntime.jsx(ir,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})})}):null}var Xr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Zr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function To({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[i,l]=react.useState(r),a=react.useCallback(h=>{h?l(r):t();},[r,t]),s=react.useCallback(()=>{l(Xr);},[]),c=react.useCallback(()=>{o(i),t();},[i,o,t]),u=react.useCallback((h,x)=>{l(C=>({...C,[h]:x}));},[]),d=react.useMemo(()=>Zr(i),[i]),p=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"kalshi",label:n("predict.platform.kalshi")}],[n]),m=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),f=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),g=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:a,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(dr,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(ur,{options:p,selected:i.source,onSelect:h=>u("source",h)})}),jsxRuntime.jsx(dr,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(ur,{options:m,selected:i.timeRemaining,onSelect:h=>u("timeRemaining",h)})}),jsxRuntime.jsx(dr,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(ur,{options:f,selected:i.minVolume,onSelect:h=>u("minVolume",h)})}),jsxRuntime.jsx(dr,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(ur,{options:g,selected:i.minLiquidity,onSelect:h=>u("minLiquidity",h)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:s,children:n("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[n("predict.filter.showResults"),d>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",d,")"]})]})]})})]})})}function dr({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function ur({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let i=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&o?void 0:n.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var Io={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},_o={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Vl=["start_time","volume","liquidity","ending_soon"];function Oo({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:i=0,className:l}){let{t:a}=i18n.useTranslation(),[s,c]=react.useState(false),u=react.useRef(null);react.useEffect(()=>{if(!s)return;let p=f=>{u.current&&!u.current.contains(f.target)&&c(false);},m=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m);}},[s]);let d=Ro[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",l),children:[jsxRuntime.jsxs("div",{ref:u,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(d,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:a(_o[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),s&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:Vl.map(p=>{let m=Ro[p];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(p),c(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",p===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:a(_o[p])})]},p)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:a("predict.filter.title")})]})})]})}var Ro={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function Fo(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]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:i,isError:l,error:a,hasNextPage:s,fetchNextPage:c,refetch:u}=reactPredict.useInfiniteEvents(t),d=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),p=react.useCallback(()=>{c();},[c]),m=react.useCallback(()=>{u();},[u]);return {data:d,isLoading:o,isFetching:n&&!i,isFetchingMore:i,isError:l,error:a??null,hasMore:s??false,fetchMore:p,refetch:m}}function Jr({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-11/12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-1/2 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-3/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-2/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-24 rounded"})]})]})},r))})}function Rg({count:e=48}){return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Jr,{count:e})})]})}var Ho=3,tn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ko={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},ec={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Dt=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function Bo(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function tc(e){let t=e.outcomes?.map(l=>l.label?.toLowerCase().trim()??"")??[];if(t.some(l=>l==="up")&&t.some(l=>l==="down"))return [tn,ec];if(t.some(l=>l==="yes")&&t.some(l=>l==="no"))return [tn,Ko];let r=t[0]??"",o=t[1]??"",n=Bo(r)%Dt.length,i=Bo(o)%Dt.length;return i===n&&(i=(i+1)%Dt.length),[Dt[n],Dt[i]]}function rc(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Vo(e){let t=rc(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function jo(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function $o(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function zo(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return parseFloat((n*100).toFixed(2)).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function nc(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),i=[];return r>0&&i.push(`${r}d`),o>0&&i.push(`${o}h`),i.push(`${n}m`),i.join(" ")}var oc=`
|
|
2
2
|
.badge-shine { position: relative; overflow: hidden; }
|
|
3
3
|
.badge-shine::after {
|
|
4
4
|
content: "";
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
`).map((r,o)=>jsxRuntime.jsxs("span",{children:[o>0&&jsxRuntime.jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsxRuntime.jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:Cp.map((r,o)=>jsxRuntime.jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsxRuntime.jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsxRuntime.jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsxRuntime.jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsxRuntime.jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}var _p={kalshi:{label:"KALSHI",color:"#00d492",bgColor:"rgba(0, 212, 146, 0.12)",icon:jsxRuntime.jsx(ui.KalshiIcon,{className:"w-3.5 h-3.5 shrink-0"})},polymarket:{label:"POLYMARKET",color:"#50a2ff",bgColor:"rgba(43, 127, 255, 0.12)",icon:jsxRuntime.jsx(ui.PolymarketIcon,{className:"w-3.5 h-3.5 shrink-0"})},dflow:{label:"DFLOW",color:"rgb(16, 185, 129)",bgColor:"rgba(16, 185, 129, 0.12)",icon:null}},Rp={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function Mt(e){return _p[e]??Rp}function Lv({source:e,className:t}){let r=Mt(e);return jsxRuntime.jsxs("span",{className:ui.cn("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}function Cn(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function Mn(e){let t=e.outcomes?.[0];return t?.best_ask??t?.price??null}function Op(e){return e.outcomes?.[0]?.label||null}function Ap(e){return e==null?"low":e>=3?"high":e>=2?"medium":"low"}var ua={high:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},medium:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},low:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},la={high:{dot:"#17c964",label:"predict.matches.confidenceHigh"},medium:{dot:"#f5a524",label:"predict.matches.confidenceMed"},low:{dot:"#71717a",label:"predict.matches.confidenceLow"}};function Dp(e,t){return e||(t==null?"low":t>=.9?"high":t>=.7?"medium":"low")}function Fp({tier:e}){let t=ua[e],r=e==="high"?5:e==="medium"?3:1;return jsxRuntime.jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsxRuntime.jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}var Hp={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},Bp={text:"#9ca3af",icon:"#9ca3af"};function $p(e){return Hp[e]??Bp}function pa({match:e,onSelect:t,onHover:r,getMarketHref:o,LinkComponent:n}){let{t:i}=i18n.useTranslation(),l=Mn(e.market_a),a=Mn(e.market_b),s=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=Ap(s),u=ua[c],d=l!=null&&a!=null?l<=a?e.source_a:e.source_b:null,p=e.event_a_title||e.event_b_title,m=Dp(e.confidence_tier,e.similarity_score),f=la[m]??la.low,g=c==="high"?"orange":"lime";return jsxRuntime.jsxs("div",{className:"group",style:{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s"},onMouseEnter:h=>{let x=h.currentTarget;x.style.borderColor="rgba(63,63,70,0.6)",x.style.boxShadow=`0 8px 24px -4px ${c==="high"?"rgba(247,104,22,0.10)":"rgba(199,255,46,0.08)"}`,r?.(e);},onMouseLeave:h=>{let x=h.currentTarget;x.style.borderColor="rgba(39,39,42,0.6)",x.style.boxShadow="none";},children:[s!=null&&jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${u.bandFrom}, ${u.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:u.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:u.color},children:[s.toFixed(1),"%"]}),jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"SPREAD"})]}),jsxRuntime.jsx(Fp,{tier:c})]}),jsxRuntime.jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsxRuntime.jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",margin:"0 0 12px"},children:p}),jsxRuntime.jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsxRuntime.jsx(ca,{source:e.source_a,market:e.market_a,isCheaper:d===e.source_a,onClick:()=>t?.(e,e.source_a),href:o?.(e,e.source_a),LinkComponent:n}),jsxRuntime.jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsxRuntime.jsx(ca,{source:e.source_b,market:e.market_b,isCheaper:d===e.source_b,onClick:()=>t?.(e,e.source_b),href:o?.(e,e.source_b),LinkComponent:n})]}),d&&s!=null&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:jsxRuntime.jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 12px",borderRadius:8,border:`1px solid ${g==="orange"?"rgba(247,104,22,0.2)":"rgba(199,255,46,0.15)"}`,background:g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)",cursor:"pointer",transition:"all 0.15s",fontSize:11,fontWeight:500,color:g==="orange"?"rgba(247,104,22,0.9)":"rgba(199,255,46,0.85)"},onMouseEnter:h=>{let x=h.currentTarget;x.style.background=g==="orange"?"rgba(247,104,22,0.14)":"rgba(199,255,46,0.10)";},onMouseLeave:h=>{let x=h.currentTarget;x.style.background=g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)";},onClick:()=>t?.(e,d),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,flexShrink:0,color:g==="orange"?"#f76816":"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),i("predict.matches.buyEdge",{platform:d.charAt(0).toUpperCase()+d.slice(1),spread:s.toFixed(1)}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:10,height:10,color:g==="orange"?"rgba(247,104,22,0.5)":"rgba(199,255,46,0.4)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M5 12h14"}),jsxRuntime.jsx("path",{d:"m12 5 7 7-7 7"})]})]})})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.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"})]}),Cn(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"})}),Cn(e.combined_volume_24h)," ",i("predict.matches.vol24h")]})]}),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:f.dot,flexShrink:0}}),i(f.label)]})]})]})}function ca({source:e,market:t,isCheaper:r,onClick:o,href:n,LinkComponent:i}){let{t:l}=i18n.useTranslation(),a=Mt(e),s=$p(e),c=Mn(t),u=Op(t),d=t.volume,p=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",cursor:n||o?"pointer":void 0,transition:"background 0.15s",background:r?"rgba(199,255,46,0.03)":"transparent"},onMouseEnter:m=>{m.currentTarget.style.background=r?"rgba(199,255,46,0.06)":"rgba(255,255,255,0.02)";},onMouseLeave:m=>{m.currentTarget.style.background=r?"rgba(199,255,46,0.03)":"transparent";},onClick:o,children:[r?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:90,flexShrink:0},children:[a.icon,jsxRuntime.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:s.text,textTransform:"uppercase"},children:a.label})]}),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:[Cn(d)," ",l("predict.matches.volume")]})]}),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:r?"#c7ff2e":"#f4f4f5"},children:c!=null?(c*100).toFixed(1):"-"}),jsxRuntime.jsx("span",{style:{fontSize:9,color:"#71717a"},children:l("predict.matches.centsYes")})]}),jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",flexShrink:0},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"})]})]});return n&&i?jsxRuntime.jsx(i,{href:n,className:"block",children:p}):p}var ga=react.forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,onSelect:n,onHover:i,getMarketHref:l,LinkComponent:a,onStatsChange:s},c){let{t:u}=i18n.useTranslation(),{data:d,hasNextPage:p,fetchNextPage:m,isFetchingNextPage:f,isLoading:g,isPlaceholderData:h,refetch:x}=reactPredict.useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,status:"active",limit:20},{placeholderData:reactQuery.keepPreviousData}),[C,b]=react.useState(0),[N,v]=react.useState(false);N&&!h?(v(false),b(K=>K+1)):h&&!N&&v(true);let $=react.useMemo(()=>{let K=d?.pages;return !K||K.length<=1?0:K.slice(0,-1).reduce((O,F)=>O+(F.items?.length??0),0)},[d?.pages]);react.useImperativeHandle(c,()=>({refetch:()=>{x();}}),[x]);let y=react.useMemo(()=>d?.pages.flatMap(K=>K.items??[])??[],[d]),X=d?.pages[0]?.total,V=react.useMemo(()=>{let K=0,O=0,F=0;for(let H of y){let se=H.spread??0;se>K&&(K=se),se>=.03&&F++,H.combined_volume!=null&&(O+=H.combined_volume);}return {activePairs:X??y.length,maxSpread:K,highSpreadCount:F,totalVolume:O}},[y,X]);react.useEffect(()=>{V.activePairs>0&&s?.(V);},[V,s]);let ae=react.useRef(null);return react.useEffect(()=>{let K=ae.current;if(!K)return;let O=new IntersectionObserver(F=>{F[0]?.isIntersecting&&p&&!f&&m();},{rootMargin:"200px"});return O.observe(K),()=>O.disconnect()},[p,f,m]),g?jsxRuntime.jsx(Gp,{}):y.length===0?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:u("predict.matches.empty")})}):jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsxRuntime.jsx("style",{children:`
|
|
63
63
|
@media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
|
|
64
64
|
@keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
65
|
-
`}),jsxRuntime.jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:y.map((K,O)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${Math.max(0,O-$)*35}ms both`},children:jsxRuntime.jsx(pa,{match:K,onSelect:n,onHover:i,getMarketHref:l,LinkComponent:a})},`${C}-${K.match_id}-${K.source_a}-${K.market_a?.slug??O}`))}),jsxRuntime.jsxs("div",{ref:ae,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)}}"}),f&&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"})}),u("predict.matches.loadMore")]})]})]})});function Gp(){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, 1fr)",gap:16},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(Yp,{index:t},t))})]})}function Yp({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxRuntime.jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsxRuntime.jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsxRuntime.jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxRuntime.jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:72}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:48}}),jsxRuntime.jsx("div",{style:{...r,height:20,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsxRuntime.jsx("div",{style:{padding:"12px 16px"},children:jsxRuntime.jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",gap:12},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:40}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:50}})]}),jsxRuntime.jsx("div",{style:{...r,height:10,width:56}})]})]})}var Zp={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Jp(){let[e,t]=react.useState("");return react.useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsxRuntime.jsx("span",{children:e})}function em({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(Jp,{})]})]})]})]})}function Qv({onSelect:e,onHover:t,getMarketHref:r,LinkComponent:o,bgImageSrc:n}){let{t:i}=i18n.useTranslation(),[l,a]=react.useState("spread"),[s,c]=react.useState(false),[u,d]=react.useState(5e3),[p,m]=react.useState(),f=react.useRef(null),g=react.useCallback(b=>{a(b);},[]),h=react.useCallback(b=>{c(b);},[]),x=react.useCallback(b=>{m(b);},[]),C=react.useCallback(()=>{f.current?.refetch();},[]);return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[n&&jsxRuntime.jsx("img",{src:n,alt:"","aria-hidden":"true",style:{position:"fixed",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"bottom",opacity:.4,pointerEvents:"none",zIndex:0}}),jsxRuntime.jsx("style",{children:`
|
|
65
|
+
`}),jsxRuntime.jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:y.map((K,O)=>jsxRuntime.jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${Math.max(0,O-$)*35}ms both`},children:jsxRuntime.jsx(pa,{match:K,onSelect:n,onHover:i,getMarketHref:l,LinkComponent:a})},`${C}-${K.match_id}-${K.source_a}-${K.market_a?.slug??O}`))}),jsxRuntime.jsxs("div",{ref:ae,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)}}"}),f&&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"})}),u("predict.matches.loadMore")]})]})]})});function Gp(){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, 1fr)",gap:16},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(Yp,{index:t},t))})]})}function Yp({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxRuntime.jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsxRuntime.jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsxRuntime.jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxRuntime.jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:72}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:48}}),jsxRuntime.jsx("div",{style:{...r,height:20,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsxRuntime.jsx("div",{style:{padding:"12px 16px"},children:jsxRuntime.jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",gap:12},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:40}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:50}})]}),jsxRuntime.jsx("div",{style:{...r,height:10,width:56}})]})]})}var Zp={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Jp(){let[e,t]=react.useState("");return react.useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsxRuntime.jsx("span",{children:e})}function em({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(Jp,{})]})]})]})]})}function Qv({onSelect:e,onHover:t,getMarketHref:r,LinkComponent:o,bgImageSrc:n}){let{t:i}=i18n.useTranslation(),[l,a]=react.useState("spread"),[s,c]=react.useState(false),[u,d]=react.useState(5e3),[p,m]=react.useState(),f=react.useRef(null),g=react.useCallback(b=>{a(b);},[]),h=react.useCallback(b=>{c(b);},[]),x=react.useCallback(b=>{m(b);},[]),C=react.useCallback(()=>{f.current?.refetch();},[]);return jsxRuntime.jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[n&&jsxRuntime.jsx("img",{src:n,alt:"","aria-hidden":"true",style:{position:"fixed",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"bottom",opacity:.8,mixBlendMode:"lighten",pointerEvents:"none",zIndex:0}}),jsxRuntime.jsx("style",{children:`
|
|
66
66
|
@keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
|
|
67
67
|
.match-fade-in{animation:matchFadeIn .5s ease-out both}
|
|
68
68
|
.match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
|