@liberfi.io/ui-predict 0.1.113 → 0.1.115

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 CHANGED
@@ -13,7 +13,7 @@ declare global {
13
13
  };
14
14
  }
15
15
  }
16
- declare const _default: "0.1.113";
16
+ declare const _default: "0.1.115";
17
17
 
18
18
  /**
19
19
  * A single category entry in the static navigation model.
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ declare global {
13
13
  };
14
14
  }
15
15
  }
16
- declare const _default: "0.1.113";
16
+ declare const _default: "0.1.115";
17
17
 
18
18
  /**
19
19
  * A single category entry in the static navigation model.
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.113");var ma="0.1.113";var fa={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},eo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Wr=(()=>{let e=t=>{let r=eo.indexOf(t);return r===-1?eo.length:r};return Object.entries(fa).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 no({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:a,pulsingTab:i="Trending",className:l}){let{t:c}=i18n.useTranslation(),p=react.useCallback(()=>{n(null);},[n]),u=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",l),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(to,{label:u,isSelected:t===null,onPress:p,showPulse:u===i}),jsxRuntime.jsx(va,{}),e.map(m=>jsxRuntime.jsx(to,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===i},m.category))]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),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(ro,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(m=>jsxRuntime.jsx(ro,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>s(m.label)},m.label))]})})]})}function to({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 va(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function ro({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 gf({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 ba(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function ya(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),[s,a]=react.useState(null),i=react.useCallback(m=>{n(m),a(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=react.useCallback(m=>{a(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),c=ba(Wr),p=Wr.find(m=>m.slug===o),u=ya(p);return jsxRuntime.jsx(no,{categories:c,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:l,trailing:t,className:r})}function ao(e){return {title:e.title,imageUrl:e.image_url}}function lo(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 At=48,Ur=4,cr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Me={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},dr=Me.ALL,Nf={[Me.ONE_DAY]:cr.ONE_MINUTE,[Me.ONE_WEEK]:cr.ONE_HOUR,[Me.ONE_MONTH]:cr.ONE_HOUR,[Me.ALL]:cr.ONE_DAY},Pf={[Me.ONE_DAY]:300,[Me.ONE_WEEK]:3600,[Me.ONE_MONTH]:10800,[Me.ALL]:1440*60},Cf={[Me.ONE_DAY]:1440*60,[Me.ONE_WEEK]:10080*60,[Me.ONE_MONTH]:720*60*60,[Me.ALL]:null},Kr=1,Mf=1,Ef=1,Tf=99,bt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Lf=bt.ONE_WEEK,_f={[bt.ONE_HOUR]:60,[bt.SIX_HOURS]:60,[bt.ONE_DAY]:300,[bt.ONE_WEEK]:1800,[bt.MAX]:1800};var po=react.createContext(null);function jr(){let e=react.useContext(po);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Ma=1e4;function Ea({pollingInterval:e=Ma,enabled:t=true,children:r}){let o=walletConnector.useWallets(),n=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.SOLANA&&v.isConnected)?.address,[o]),s=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.EVM&&v.isConnected)?.address,[o]),{data:a,isLoading:i,isFetching:l,error:c}=reactPredict.useBalance({source:"kalshi",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:p,isLoading:u}=reactPredict.useDFlowKYC(n,{enabled:t&&!!n,refetchInterval:3e4}),{data:m,isLoading:d}=reactPredict.usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:x,isFetching:N,error:E}=reactPredict.useBalance({source:"polymarket",user:s??""},{enabled:t&&g&&!!s,refetchInterval:e}),S=react.useMemo(()=>({solanaAddress:n,evmAddress:s,polymarketSafeAddress:f,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:u,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:d,isLoading:i||x,isFetching:l||N,error:c??E??null}),[n,s,f,a,h,g,p,u,m,d,i,x,l,N,c,E]);return jsxRuntime.jsx(po.Provider,{value:S,children:r})}var Qa={minutes:60,hours:3600,days:86400};function Xa(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*Qa[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 ho({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=i18n.useTranslation(),{status:n}=walletConnector.useAuth(),s=walletConnector.useWallets(),a=walletConnector.useSwitchChain(),i=reactPredict.usePredictClient(),l=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),p=e.source,u=p==="polymarket",m=s.find(k=>k.chainNamespace===types.ChainNamespace.SOLANA&&k.isConnected),d=s.find(k=>k.chainNamespace===types.ChainNamespace.EVM&&k.isConnected&&"switchChain"in k),f=n==="authenticated",g=m?.address,h=d?.address,x=react.useMemo(()=>{if(p!=="polymarket")return;let k=e.provider_meta?.["polymarket.clobTokenIds"];return k?(typeof k=="string"?JSON.parse(k):k)[0]:void 0},[p,e.provider_meta]),{data:N}=reactPredict.useTickSize(x),E=N?.minimum_tick_size?String(N.minimum_tick_size):"0.01",[S,v]=react.useState(t),[b,H]=react.useState(r),[K,me]=react.useState("market"),[C,X]=react.useState(NaN),[D,$]=react.useState(NaN),[z,oe]=react.useState(false),[fe,M]=react.useState(null),[L,V]=react.useState(null),[I,ue]=react.useState(false),[ie,Ne]=react.useState(false),[Re,gt]=react.useState("1h"),[Xe,er]=react.useState(30),[Tt,tr]=react.useState("minutes"),We=null,ht=false,rr=null,F;try{let k=jr();We={kalshiUsdcBalance:k.kalshiUsdcBalance,polymarketUsdcBalance:k.polymarketUsdcBalance,isLoading:k.isLoading},ht=k.kalshiKycVerified,rr=k.kalshiKycUrl,F=k.polymarketSafeAddress;}catch{}let ae=react.useMemo(()=>{let k=S==="yes"?0:1,j=e.outcomes[k];return b==="buy"?j?.best_ask??j?.price??.5:j?.best_bid??j?.price??.5},[e.outcomes,S,b]),xt=react.useCallback(k=>{me(k);},[]),Wi=react.useCallback(k=>{v(k),$(NaN);},[]);react.useEffect(()=>{K==="limit"&&isNaN(D)&&$(Math.round(ae*100)/100);},[K,D,ae]);let Ui=react.useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?ae>0?C/ae:0:C,[b,C,ae]),nr=react.useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),Ki=e.provider_meta?.["dflow.yesMint"]??"",Vi=e.provider_meta?.["dflow.noMint"]??"",it=utils.SOLANA_TOKENS.stablecoins.USDC.address,ji=e.provider_meta?.["dflow.collateralMint"]||"",Wn=S==="yes"?Ki:Vi,Un=p==="kalshi"?g??"":h??"",{data:Ie,isLoading:Gi}=reactPredict.usePositions({source:p,user:Un},{enabled:!!Un}),Kn=react.useMemo(()=>!Ie||b!=="sell"?null:Ie.positions.find(k=>k.side?.toLowerCase()===S&&k.market?.slug===e.slug)??null,[Ie,e.slug,S,b])?.market?.provider_meta,Yi=b==="sell"&&Kn?.["dflow.outcomeMint"]||Wn,Lt=b==="sell"&&Kn?.["dflow.collateralMint"]||ji,_t=b==="buy"?it:Yi,Rt=b==="buy"?Wn:Lt||it,qi=p==="kalshi"&&!!_t&&!!Rt&&!!g&&nr!=="0",{refetch:Vn}=reactPredict.useDFlowQuote({inputMint:_t,outputMint:Rt,amount:nr,userPublicKey:g??"",slippageBps:100},{enabled:qi}),or=react.useMemo(()=>We?p==="kalshi"?We.kalshiUsdcBalance:We.polymarketUsdcBalance:Ie&&Ie.positions.reduce((j,Ce)=>Ce.side==="USDC"||Ce.side==="collateral"?j+(Ce.current_value??0):j,0)||null,[We,Ie,p]),Qi=We?We.isLoading:Gi,Dr=react.useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="yes"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Fr=react.useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="no"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Hr=react.useMemo(()=>K==="limit"&&u&&!isNaN(D)?D:ae,[K,u,D,ae]),sr=react.useMemo(()=>{if(isNaN(C)||C<=0)return 0;if(b==="buy")return C;let k=S==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return C*k},[b,S,C,e.outcomes]),jn=react.useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?Hr>0?C/Hr*1:0:sr,[b,C,Hr,sr]),Xi=jn-sr,Zi=react.useCallback(k=>{H(k),X(NaN);},[]),Ji=react.useCallback(k=>{if(isNaN(k)){X(NaN);return}let j=Math.max(0,k),Ce=b==="buy"?Math.round(j*100)/100:Math.round(j);X(Ce);},[b]),ea=react.useCallback(k=>{if(isNaN(k)){$(NaN);return}let j=Math.max(.01,Math.min(.99,k));$(Math.round(j*100)/100);},[]),It=react.useCallback(()=>{X(NaN),$(NaN),me("market"),Ne(false),gt("1h"),er(30),tr("minutes");},[]),Br=react.useMemo(()=>{let k=[];(isNaN(C)||C<Kr)&&k.push(`Minimum quantity is ${Kr}`),e.status!=="open"&&k.push("Market is not active"),b==="buy"&&or!=null&&!isNaN(C)&&C>0&&C>or&&k.push("Insufficient USDC balance");let j=S==="yes"?Dr:Fr;return b==="sell"&&j!=null&&!isNaN(C)&&C>0&&C>j&&k.push("Insufficient shares"),K==="limit"&&u&&(isNaN(D)||D<.01||D>.99)&&k.push("Limit price must be between $0.01 and $0.99"),K==="limit"&&u&&ie&&Re==="custom"&&(isNaN(Xe)||Xe<=0)&&k.push(o("predict.trade.expiration.invalidDate")),{isValid:k.length===0,errors:k}},[C,e.status,b,or,Dr,Fr,S,K,u,D,ie,Re,Xe,o]),{mutateAsync:ir}=reactPredict.useDFlowSubmit(),{data:$r}=reactPredict.useOrder({id:fe??"",source:p},{enabled:!!fe}),Gn=react.useCallback(async()=>{if(!L||!g||!m)return;let{cashAmount:k,collateral:j}=L;V(null);try{let at=(await i.createDFlowQuote({inputMint:j,outputMint:it,amount:k,userPublicKey:g,slippageBps:100}))?.transaction;if(!at)return;let Ze=Uint8Array.from(atob(at),Ot=>Ot.charCodeAt(0)),Ue=await m.signTransaction(Ze);await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:j,output_mint:it,amount:k,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[L,g,m,i,ir,it]);react.useEffect(()=>{if(!$r||!fe)return;let{status:k}=$r;k==="closed"?(M(null),L?Gn().finally(()=>{oe(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),It();}):(oe(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),It())):(k==="failed"||k==="expired")&&(oe(false),M(null),V(null),ui.toast.error(o("predict.trade.submitError")));},[$r,fe,L,Gn,It,o]);let Yn=react.useCallback(async()=>{if(!g||!m)return;if(!_t||!Rt){ui.toast.error("Missing token mint addresses"),oe(false);return}if(!ht){ue(true),oe(false);return}let Ce=(await Vn()).data,at=Ce?.transaction;if(!at){ui.toast.error(o("predict.trade.submitError")),oe(false);return}if(b==="sell"&&Lt&&Lt!==it){let Je=String(Ce?.outAmount??"");Je&&Je!=="0"&&V({cashAmount:Je,collateral:Lt});}let Ze=Uint8Array.from(atob(at),Je=>Je.charCodeAt(0)),Ue=await m.signTransaction(Ze),Ot=await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:_t,output_mint:Rt,amount:nr,price:String(ae),side:b==="buy"?"BUY":"SELL",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});M(Ot.signature);},[g,m,i,Vn,ir,_t,Rt,nr,ae,b,S,e.slug,Lt,it,o]),qn=react.useCallback(async()=>{if(!d||!l)return;let k=d.chain,j=k!==types.Chain.POLYGON;j&&await a(types.Chain.POLYGON);try{let Ce=await d.getEip1193Provider();if(!Ce){ui.toast.error(o("predict.trade.submitError")),oe(!1);return}let at=!!F,Ze={address:d.address,signatureType:at?2:0,signTypedData:async(lt,ca,da,ua)=>{let vt=[];"name"in lt&&vt.push({name:"name",type:"string"}),"version"in lt&&vt.push({name:"version",type:"string"}),"chainId"in lt&&vt.push({name:"chainId",type:"uint256"}),"verifyingContract"in lt&&vt.push({name:"verifyingContract",type:"address"}),"salt"in lt&&vt.push({name:"salt",type:"bytes32"});let pa={EIP712Domain:vt,...ca};return await Ce.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:lt,types:pa,primaryType:da,message:ua})]})}},Ue=l.credentials??await l.authenticate(Ze),Ot=S==="yes"?0:1,Je="",ar=e.provider_meta?.["polymarket.clobTokenIds"];ar&&(Je=(typeof ar=="string"?JSON.parse(ar):ar)[Ot]??"");let Qn=e.provider_meta?.["polymarket.negRisk"]??!1,zr=K==="limit"&&!isNaN(D)?D:ae,ra=K==="limit"?ie?"GTD":"GTC":"FOK",na=b==="buy"&&zr>0?C/zr:C,Xn={tokenId:Je,price:zr,size:na,side:b==="buy"?"BUY":"SELL",orderType:ra,tickSize:E,negRisk:Qn,...F&&{funderAddress:F},...K==="limit"&&ie&&{expiration:Xa(Re,Xe,Tt)}},oa=reactPredict.buildCtfExchangeDomain(Qn),Zn=reactPredict.buildOrderMessage({...Xn,signerAddress:Ze.address,signatureType:Ze.signatureType}),sa=await Ze.signTypedData(oa,reactPredict.CTF_ORDER_TYPES,"Order",Zn),ia=reactPredict.buildSignedOrder(Zn,sa,Xn.orderType),Jn=reactPredict.buildClobPayload(ia,Ue.apiKey),aa=JSON.stringify(Jn),la=await reactPredict.buildPolymarketL2Headers(Ue.address,{apiKey:Ue.apiKey,secret:Ue.secret,passphrase:Ue.passphrase,method:"POST",requestPath:"/order",body:aa});await i.createPolymarketOrder(Jn,la),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),It(),oe(!1);}finally{j&&k&&a(k).catch(()=>{});}},[d,l,a,S,e.provider_meta,K,D,ae,C,b,i,c,ie,Re,Xe,Tt,It,o]),ta=react.useCallback(async()=>{if(!(!Br.isValid||!f)){oe(true),M(null),ue(false);try{p==="kalshi"?await Yn():await qn();}catch(k){let j=k instanceof Error?k.message:void 0;ui.toast.error(j||o("predict.trade.submitError")),oe(false);}}},[Br.isValid,f,p,Yn,qn,o]);return {outcome:S,side:b,orderType:K,quantity:C,limitPrice:D,shares:Ui,estimatedCost:sr,potentialPayout:jn,potentialProfit:Xi,usdcBalance:or,yesTokenBalance:Dr,noTokenBalance:Fr,isBalanceLoading:Qi,isSubmitting:z,validation:Br,supportsLimitOrder:u,kycRequired:I,kycUrl:rr,expirationEnabled:ie,expirationPreset:Re,customDuration:Xe,customDurationUnit:Tt,setOutcome:Wi,setSide:Zi,setOrderType:xt,setQuantity:Ji,setLimitPrice:ea,setExpirationEnabled:Ne,setExpirationPreset:gt,setCustomDuration:er,setCustomDurationUnit:tr,submit:ta}}function xo({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),jsxRuntime.jsx("span",{children:o(n)})]},n))}),r&&jsxRuntime.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsxRuntime.jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var cl=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,dl=["5m","1h","12h","24h","eod","custom"],ul={"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"},pl=["minutes","hours","days"],ml={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function No({event:e,market:t,variant:r="bordered",outcome:o,side:n,orderType:s,quantity:a,limitPrice:i,shares:l,potentialProfit:c,potentialPayout:p,estimatedCost:u,usdcBalance:m,yesTokenBalance:d,noTokenBalance:f,isBalanceLoading:g,isSubmitting:h,isValid:x,validationErrors:N,supportsLimitOrder:E,kycRequired:S,kycUrl:v,expirationEnabled:b,expirationPreset:H,customDuration:K,customDurationUnit:me,onOutcomeChange:C,onSideChange:X,onOrderTypeChange:D,onQuantityChange:$,onLimitPriceChange:z,onExpirationEnabledChange:oe,onExpirationPresetChange:fe,onCustomDurationChange:M,onCustomDurationUnitChange:L,onSubmit:V}){let{t:I}=i18n.useTranslation(),[ue,ie]=react.useState(false),Ne=ui.useDisclosure();react.useEffect(()=>{S&&!Ne.isOpen&&Ne.onOpen();},[S]);let Re=react.useMemo(()=>{let F=n==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,o,t]),gt=!isNaN(a)&&a>0,Xe=react.useMemo(()=>{if(h)return I("predict.trade.submitting");if(S)return I("predict.trade.kycRequired");if(!gt)return I("predict.trade.enterAmount");let F=I(n==="buy"?"predict.trade.buy":"predict.trade.sell"),ae=I(o==="yes"?"predict.trade.yes":"predict.trade.no"),xt=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${F} ${ae}${xt}`},[h,S,gt,n,o,c,I]),er=react.useMemo(()=>o==="yes"?"primary":"secondary",[o]),Tt=()=>{$(Math.floor((m??0)/2*100)/100);},tr=()=>{$(m??0);},[We,ht]=react.useState(false),rr=()=>{if(S){Ne.onOpen();return}if(!x){ht(true);return}ht(false),V();};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:[I(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",I(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:[E?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:s,onSelectionChange:F=>D(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:I("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:I("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:I("predict.trade.market")}),s==="limit"&&E?jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(i)?void 0:parseFloat((i*100).toFixed(2)),onValueChange:F=>z(F/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"}}):Re!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Re," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let ae=F==="yes"?d:f;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>C(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===F?F==="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:I(F==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let xt=n==="buy"?F==="yes"?t.yesAsk:t.noAsk:F==="yes"?t.yesBid:t.noBid;return xt!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(xt)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===F&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${ae??0} shares`})]},F)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:I(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:cl,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`${m.toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:Tt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:tr,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(a)?void 0:a,onValueChange:F=>{ht(false),$(F);},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(F=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{$(Math.floor((o==="yes"?d??0:f??0)*F/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:[F,"%"]},F)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{$(o==="yes"?d??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:I("common.all")})]}),We&&N.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:N.map(F=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:F},F))})]}),s==="limit"&&E&&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:I("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:b,onValueChange:oe,"aria-label":I("predict.trade.setExpiration")})]}),b&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":I("predict.trade.setExpiration"),selectedKeys:[H],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&fe(ae);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:dl.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:I(ul[F])},F))}),H==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(K)?void 0:K,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:[me],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&L(ae);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pl.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:I(ml[F])},F))})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>ie(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:I("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",ue&&"rotate-180")})]}),Re!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Re,"% chance"]})]}),ue&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Total Size"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?`$${u.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(l)&&l>0?parseFloat(l.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(a)&&a>0?`$${p.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(a)&&a>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:er,fullWidth:true,radius:"lg",size:"lg",isDisabled:!gt||h,isLoading:h,onPress:rr,children:Xe})]}),jsxRuntime.jsx(xo,{isOpen:Ne.isOpen,onClose:Ne.onClose,kycUrl:v})]})}function ur({event:e,market:t,variant:r,initialSide:o,initialOutcome:n,chain:s}){let{outcome:a,side:i,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:N,isSubmitting:E,validation:S,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,setOutcome:D,setSide:$,setOrderType:z,setQuantity:oe,setLimitPrice:fe,setExpirationEnabled:M,setExpirationPreset:L,setCustomDuration:V,setCustomDurationUnit:I,submit:ue}=ho({market:t,initialSide:o,initialOutcome:n}),ie=walletConnector.useAuthCallback(ue),Ne=react.useMemo(()=>e?ao(e):void 0,[e]),Re=react.useMemo(()=>lo(t),[t]);return jsxRuntime.jsx(No,{event:Ne,market:Re,variant:r,outcome:a,side:i,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:N,isSubmitting:E,isValid:S.isValid,validationErrors:S.errors,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,onOutcomeChange:D,onSideChange:$,onOrderTypeChange:z,onQuantityChange:oe,onLimitPriceChange:fe,onExpirationEnabledChange:M,onExpirationPresetChange:L,onCustomDurationChange:V,onCustomDurationUnitChange:I,onSubmit:ie})}var Dt="predict-trade";function pr({id:e=Dt}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(kl,{...t})})}function kl({params:e,isOpen:t,onOpenChange:r}){let{t:o}=i18n.useTranslation(),{isMobile:n}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"blur",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.action")}),jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsx("div",{className:"px-5 pb-5",children:jsxRuntime.jsx(ur,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})]})})}):null}var Zr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Jr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Co({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[s,a]=react.useState(r),i=react.useCallback(h=>{h?a(r):t();},[r,t]),l=react.useCallback(()=>{a(Zr);},[]),c=react.useCallback(()=>{o(s),t();},[s,o,t]),p=react.useCallback((h,x)=>{a(N=>({...N,[h]:x}));},[]),u=react.useMemo(()=>Jr(s),[s]),m=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]),d=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:i,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.filter.title")}),jsxRuntime.jsx(Cl,{onClick:()=>i(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsxRuntime.jsx(fr,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(gr,{options:m,selected:s.source,onSelect:h=>p("source",h)})}),jsxRuntime.jsx(fr,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(gr,{options:d,selected:s.timeRemaining,onSelect:h=>p("timeRemaining",h)})}),jsxRuntime.jsx(fr,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(gr,{options:f,selected:s.minVolume,onSelect:h=>p("minVolume",h)})}),jsxRuntime.jsx(fr,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(gr,{options:g,selected:s.minLiquidity,onSelect:h=>p("minLiquidity",h)})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsxRuntime.jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:l,children:n("predict.filter.reset")}),jsxRuntime.jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[n("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",u,")"]})]})]})]})})})}function fr({label:e,children:t}){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function Cl({onClick:e}){return jsxRuntime.jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function gr({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let s=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:s?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:s?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:s?"#c7ff2e":"#a1a1aa"},onMouseEnter:a=>{s||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{s||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var _o={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Eo={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Al=["start_time","volume","liquidity","ending_soon"],To={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Dl={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Ro({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:a}){let{t:i}=i18n.useTranslation(),[l,c]=react.useState(false),p=react.useRef(null),u=react.useCallback(d=>{p.current&&!p.current.contains(d.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)),[u]),react.useEffect(()=>{if(!l)return;let d=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let m=Lo[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:p,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:To,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(d=>!d),children:[jsxRuntime.jsx(Fl,{}),jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i(Eo[e])}),jsxRuntime.jsx(Bl,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Dl,width:224,padding:4},children:Al.map(d=>{let f=Lo[d],g=e===d;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?o(!r):t(d),c(false);},children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:i(Eo[d])}),g&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})]}),jsxRuntime.jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:To,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsxRuntime.jsx(Hl,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i("predict.filter.title")})]}),s>0&&jsxRuntime.jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:s})]})]})}var Lo={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function Fl(){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function Hl(){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Bl({open:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function Ao(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:s,isError:a,error:i,hasNextPage:l,fetchNextPage:c,refetch:p}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=react.useCallback(()=>{c();},[c]),d=react.useCallback(()=>{p();},[p]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:a,error:i??null,hasMore:l??false,fetchMore:m,refetch:d}}var Do="@keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}@media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}}@media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}";function en({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:Do}),jsxRuntime.jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(Wl,{index:r},r))})]})}function Wl({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:`evtShimmer 1.8s ease-in-out infinite ${e*120}ms`,borderRadius:6},o=e%3===0?"85%":e%3===1?"70%":"60%";return jsxRuntime.jsx("div",{style:{padding:8},children:jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsxRuntime.jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:12,width:o}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(n=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:n===0?"55%":n===1?"45%":"35%"}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:32}}),jsxRuntime.jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},n))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Fg({count:e=48}){let t={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",maxWidth:1680,margin:"0 auto",gap:12},children:[jsxRuntime.jsx("style",{children:Do}),jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:[48,64,48,56,72,56].map((r,o)=>jsxRuntime.jsx("div",{style:{...t,height:24,width:r}},o))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,minHeight:36},children:[jsxRuntime.jsx("div",{style:{...t,height:32,width:120,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...t,height:32,width:32,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...t,height:32,width:80,borderRadius:10}})]}),jsxRuntime.jsx("div",{style:{flex:1,minHeight:0},children:jsxRuntime.jsx(en,{count:e})})]})}var Fo=3,Xl={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},Zl={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},rn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Wo={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Jl={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Ht=[{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 Ho(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 ec(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [rn,Jl];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [rn,Wo];let r=t[0]??"",o=t[1]??"",n=Ho(r)%Ht.length,s=Ho(o)%Ht.length;return s===n&&(s=(s+1)%Ht.length),[Ht[n],Ht[s]]}function tc(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Uo(e){let t=tc(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Ko(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Bo(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function $o(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 rc(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),s=[];return r>0&&s.push(`${r}d`),o>0&&s.push(`${o}h`),s.push(`${n}m`),s.join(" ")}var nc=`
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.115");var ma="0.1.115";var fa={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},eo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Wr=(()=>{let e=t=>{let r=eo.indexOf(t);return r===-1?eo.length:r};return Object.entries(fa).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 no({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:a,pulsingTab:i="Trending",className:l}){let{t:c}=i18n.useTranslation(),p=react.useCallback(()=>{n(null);},[n]),u=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",l),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(to,{label:u,isSelected:t===null,onPress:p,showPulse:u===i}),jsxRuntime.jsx(va,{}),e.map(m=>jsxRuntime.jsx(to,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===i},m.category))]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),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(ro,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(m=>jsxRuntime.jsx(ro,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>s(m.label)},m.label))]})})]})}function to({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 va(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function ro({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 gf({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 ba(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function ya(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),[s,a]=react.useState(null),i=react.useCallback(m=>{n(m),a(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=react.useCallback(m=>{a(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),c=ba(Wr),p=Wr.find(m=>m.slug===o),u=ya(p);return jsxRuntime.jsx(no,{categories:c,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:l,trailing:t,className:r})}function ao(e){return {title:e.title,imageUrl:e.image_url}}function lo(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 At=48,Ur=4,cr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Me={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},dr=Me.ALL,Nf={[Me.ONE_DAY]:cr.ONE_MINUTE,[Me.ONE_WEEK]:cr.ONE_HOUR,[Me.ONE_MONTH]:cr.ONE_HOUR,[Me.ALL]:cr.ONE_DAY},Pf={[Me.ONE_DAY]:300,[Me.ONE_WEEK]:3600,[Me.ONE_MONTH]:10800,[Me.ALL]:1440*60},Cf={[Me.ONE_DAY]:1440*60,[Me.ONE_WEEK]:10080*60,[Me.ONE_MONTH]:720*60*60,[Me.ALL]:null},Kr=1,Mf=1,Ef=1,Tf=99,bt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Lf=bt.ONE_WEEK,_f={[bt.ONE_HOUR]:60,[bt.SIX_HOURS]:60,[bt.ONE_DAY]:300,[bt.ONE_WEEK]:1800,[bt.MAX]:1800};var po=react.createContext(null);function jr(){let e=react.useContext(po);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Ma=1e4;function Ea({pollingInterval:e=Ma,enabled:t=true,children:r}){let o=walletConnector.useWallets(),n=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.SOLANA&&v.isConnected)?.address,[o]),s=react.useMemo(()=>o.find(v=>v.chainNamespace===types.ChainNamespace.EVM&&v.isConnected)?.address,[o]),{data:a,isLoading:i,isFetching:l,error:c}=reactPredict.useBalance({source:"kalshi",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:p,isLoading:u}=reactPredict.useDFlowKYC(n,{enabled:t&&!!n,refetchInterval:3e4}),{data:m,isLoading:d}=reactPredict.usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:x,isFetching:N,error:E}=reactPredict.useBalance({source:"polymarket",user:s??""},{enabled:t&&g&&!!s,refetchInterval:e}),S=react.useMemo(()=>({solanaAddress:n,evmAddress:s,polymarketSafeAddress:f,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:u,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:d,isLoading:i||x,isFetching:l||N,error:c??E??null}),[n,s,f,a,h,g,p,u,m,d,i,x,l,N,c,E]);return jsxRuntime.jsx(po.Provider,{value:S,children:r})}var Qa={minutes:60,hours:3600,days:86400};function Xa(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*Qa[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 ho({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=i18n.useTranslation(),{status:n}=walletConnector.useAuth(),s=walletConnector.useWallets(),a=walletConnector.useSwitchChain(),i=reactPredict.usePredictClient(),l=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),p=e.source,u=p==="polymarket",m=s.find(k=>k.chainNamespace===types.ChainNamespace.SOLANA&&k.isConnected),d=s.find(k=>k.chainNamespace===types.ChainNamespace.EVM&&k.isConnected&&"switchChain"in k),f=n==="authenticated",g=m?.address,h=d?.address,x=react.useMemo(()=>{if(p!=="polymarket")return;let k=e.provider_meta?.["polymarket.clobTokenIds"];return k?(typeof k=="string"?JSON.parse(k):k)[0]:void 0},[p,e.provider_meta]),{data:N}=reactPredict.useTickSize(x),E=N?.minimum_tick_size?String(N.minimum_tick_size):"0.01",[S,v]=react.useState(t),[b,H]=react.useState(r),[K,me]=react.useState("market"),[C,X]=react.useState(NaN),[D,$]=react.useState(NaN),[z,oe]=react.useState(false),[fe,M]=react.useState(null),[L,V]=react.useState(null),[I,ue]=react.useState(false),[ie,Ne]=react.useState(false),[Re,gt]=react.useState("1h"),[Xe,er]=react.useState(30),[Tt,tr]=react.useState("minutes"),We=null,ht=false,rr=null,F;try{let k=jr();We={kalshiUsdcBalance:k.kalshiUsdcBalance,polymarketUsdcBalance:k.polymarketUsdcBalance,isLoading:k.isLoading},ht=k.kalshiKycVerified,rr=k.kalshiKycUrl,F=k.polymarketSafeAddress;}catch{}let ae=react.useMemo(()=>{let k=S==="yes"?0:1,j=e.outcomes[k];return b==="buy"?j?.best_ask??j?.price??.5:j?.best_bid??j?.price??.5},[e.outcomes,S,b]),xt=react.useCallback(k=>{me(k);},[]),Wi=react.useCallback(k=>{v(k),$(NaN);},[]);react.useEffect(()=>{K==="limit"&&isNaN(D)&&$(Math.round(ae*100)/100);},[K,D,ae]);let Ui=react.useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?ae>0?C/ae:0:C,[b,C,ae]),nr=react.useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),Ki=e.provider_meta?.["dflow.yesMint"]??"",Vi=e.provider_meta?.["dflow.noMint"]??"",it=utils.SOLANA_TOKENS.stablecoins.USDC.address,ji=e.provider_meta?.["dflow.collateralMint"]||"",Wn=S==="yes"?Ki:Vi,Un=p==="kalshi"?g??"":h??"",{data:Ie,isLoading:Gi}=reactPredict.usePositions({source:p,user:Un},{enabled:!!Un}),Kn=react.useMemo(()=>!Ie||b!=="sell"?null:Ie.positions.find(k=>k.side?.toLowerCase()===S&&k.market?.slug===e.slug)??null,[Ie,e.slug,S,b])?.market?.provider_meta,Yi=b==="sell"&&Kn?.["dflow.outcomeMint"]||Wn,Lt=b==="sell"&&Kn?.["dflow.collateralMint"]||ji,_t=b==="buy"?it:Yi,Rt=b==="buy"?Wn:Lt||it,qi=p==="kalshi"&&!!_t&&!!Rt&&!!g&&nr!=="0",{refetch:Vn}=reactPredict.useDFlowQuote({inputMint:_t,outputMint:Rt,amount:nr,userPublicKey:g??"",slippageBps:100},{enabled:qi}),or=react.useMemo(()=>We?p==="kalshi"?We.kalshiUsdcBalance:We.polymarketUsdcBalance:Ie&&Ie.positions.reduce((j,Ce)=>Ce.side==="USDC"||Ce.side==="collateral"?j+(Ce.current_value??0):j,0)||null,[We,Ie,p]),Qi=We?We.isLoading:Gi,Dr=react.useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="yes"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Fr=react.useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="no"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Hr=react.useMemo(()=>K==="limit"&&u&&!isNaN(D)?D:ae,[K,u,D,ae]),sr=react.useMemo(()=>{if(isNaN(C)||C<=0)return 0;if(b==="buy")return C;let k=S==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return C*k},[b,S,C,e.outcomes]),jn=react.useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?Hr>0?C/Hr*1:0:sr,[b,C,Hr,sr]),Xi=jn-sr,Zi=react.useCallback(k=>{H(k),X(NaN);},[]),Ji=react.useCallback(k=>{if(isNaN(k)){X(NaN);return}let j=Math.max(0,k),Ce=b==="buy"?Math.round(j*100)/100:Math.round(j);X(Ce);},[b]),ea=react.useCallback(k=>{if(isNaN(k)){$(NaN);return}let j=Math.max(.01,Math.min(.99,k));$(Math.round(j*100)/100);},[]),It=react.useCallback(()=>{X(NaN),$(NaN),me("market"),Ne(false),gt("1h"),er(30),tr("minutes");},[]),Br=react.useMemo(()=>{let k=[];(isNaN(C)||C<Kr)&&k.push(`Minimum quantity is ${Kr}`),e.status!=="open"&&k.push("Market is not active"),b==="buy"&&or!=null&&!isNaN(C)&&C>0&&C>or&&k.push("Insufficient USDC balance");let j=S==="yes"?Dr:Fr;return b==="sell"&&j!=null&&!isNaN(C)&&C>0&&C>j&&k.push("Insufficient shares"),K==="limit"&&u&&(isNaN(D)||D<.01||D>.99)&&k.push("Limit price must be between $0.01 and $0.99"),K==="limit"&&u&&ie&&Re==="custom"&&(isNaN(Xe)||Xe<=0)&&k.push(o("predict.trade.expiration.invalidDate")),{isValid:k.length===0,errors:k}},[C,e.status,b,or,Dr,Fr,S,K,u,D,ie,Re,Xe,o]),{mutateAsync:ir}=reactPredict.useDFlowSubmit(),{data:$r}=reactPredict.useOrder({id:fe??"",source:p},{enabled:!!fe}),Gn=react.useCallback(async()=>{if(!L||!g||!m)return;let{cashAmount:k,collateral:j}=L;V(null);try{let at=(await i.createDFlowQuote({inputMint:j,outputMint:it,amount:k,userPublicKey:g,slippageBps:100}))?.transaction;if(!at)return;let Ze=Uint8Array.from(atob(at),Ot=>Ot.charCodeAt(0)),Ue=await m.signTransaction(Ze);await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:j,output_mint:it,amount:k,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[L,g,m,i,ir,it]);react.useEffect(()=>{if(!$r||!fe)return;let{status:k}=$r;k==="closed"?(M(null),L?Gn().finally(()=>{oe(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),It();}):(oe(false),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),It())):(k==="failed"||k==="expired")&&(oe(false),M(null),V(null),ui.toast.error(o("predict.trade.submitError")));},[$r,fe,L,Gn,It,o]);let Yn=react.useCallback(async()=>{if(!g||!m)return;if(!_t||!Rt){ui.toast.error("Missing token mint addresses"),oe(false);return}if(!ht){ue(true),oe(false);return}let Ce=(await Vn()).data,at=Ce?.transaction;if(!at){ui.toast.error(o("predict.trade.submitError")),oe(false);return}if(b==="sell"&&Lt&&Lt!==it){let Je=String(Ce?.outAmount??"");Je&&Je!=="0"&&V({cashAmount:Je,collateral:Lt});}let Ze=Uint8Array.from(atob(at),Je=>Je.charCodeAt(0)),Ue=await m.signTransaction(Ze),Ot=await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:_t,output_mint:Rt,amount:nr,price:String(ae),side:b==="buy"?"BUY":"SELL",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});M(Ot.signature);},[g,m,i,Vn,ir,_t,Rt,nr,ae,b,S,e.slug,Lt,it,o]),qn=react.useCallback(async()=>{if(!d||!l)return;let k=d.chain,j=k!==types.Chain.POLYGON;j&&await a(types.Chain.POLYGON);try{let Ce=await d.getEip1193Provider();if(!Ce){ui.toast.error(o("predict.trade.submitError")),oe(!1);return}let at=!!F,Ze={address:d.address,signatureType:at?2:0,signTypedData:async(lt,ca,da,ua)=>{let vt=[];"name"in lt&&vt.push({name:"name",type:"string"}),"version"in lt&&vt.push({name:"version",type:"string"}),"chainId"in lt&&vt.push({name:"chainId",type:"uint256"}),"verifyingContract"in lt&&vt.push({name:"verifyingContract",type:"address"}),"salt"in lt&&vt.push({name:"salt",type:"bytes32"});let pa={EIP712Domain:vt,...ca};return await Ce.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:lt,types:pa,primaryType:da,message:ua})]})}},Ue=l.credentials??await l.authenticate(Ze),Ot=S==="yes"?0:1,Je="",ar=e.provider_meta?.["polymarket.clobTokenIds"];ar&&(Je=(typeof ar=="string"?JSON.parse(ar):ar)[Ot]??"");let Qn=e.provider_meta?.["polymarket.negRisk"]??!1,zr=K==="limit"&&!isNaN(D)?D:ae,ra=K==="limit"?ie?"GTD":"GTC":"FOK",na=b==="buy"&&zr>0?C/zr:C,Xn={tokenId:Je,price:zr,size:na,side:b==="buy"?"BUY":"SELL",orderType:ra,tickSize:E,negRisk:Qn,...F&&{funderAddress:F},...K==="limit"&&ie&&{expiration:Xa(Re,Xe,Tt)}},oa=reactPredict.buildCtfExchangeDomain(Qn),Zn=reactPredict.buildOrderMessage({...Xn,signerAddress:Ze.address,signatureType:Ze.signatureType}),sa=await Ze.signTypedData(oa,reactPredict.CTF_ORDER_TYPES,"Order",Zn),ia=reactPredict.buildSignedOrder(Zn,sa,Xn.orderType),Jn=reactPredict.buildClobPayload(ia,Ue.apiKey),aa=JSON.stringify(Jn),la=await reactPredict.buildPolymarketL2Headers(Ue.address,{apiKey:Ue.apiKey,secret:Ue.secret,passphrase:Ue.passphrase,method:"POST",requestPath:"/order",body:aa});await i.createPolymarketOrder(Jn,la),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),Yr(),It(),oe(!1);}finally{j&&k&&a(k).catch(()=>{});}},[d,l,a,S,e.provider_meta,K,D,ae,C,b,i,c,ie,Re,Xe,Tt,It,o]),ta=react.useCallback(async()=>{if(!(!Br.isValid||!f)){oe(true),M(null),ue(false);try{p==="kalshi"?await Yn():await qn();}catch(k){let j=k instanceof Error?k.message:void 0;ui.toast.error(j||o("predict.trade.submitError")),oe(false);}}},[Br.isValid,f,p,Yn,qn,o]);return {outcome:S,side:b,orderType:K,quantity:C,limitPrice:D,shares:Ui,estimatedCost:sr,potentialPayout:jn,potentialProfit:Xi,usdcBalance:or,yesTokenBalance:Dr,noTokenBalance:Fr,isBalanceLoading:Qi,isSubmitting:z,validation:Br,supportsLimitOrder:u,kycRequired:I,kycUrl:rr,expirationEnabled:ie,expirationPreset:Re,customDuration:Xe,customDurationUnit:Tt,setOutcome:Wi,setSide:Zi,setOrderType:xt,setQuantity:Ji,setLimitPrice:ea,setExpirationEnabled:Ne,setExpirationPreset:gt,setCustomDuration:er,setCustomDurationUnit:tr,submit:ta}}function xo({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),jsxRuntime.jsx("span",{children:o(n)})]},n))}),r&&jsxRuntime.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsxRuntime.jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var cl=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,dl=["5m","1h","12h","24h","eod","custom"],ul={"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"},pl=["minutes","hours","days"],ml={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function No({event:e,market:t,variant:r="bordered",outcome:o,side:n,orderType:s,quantity:a,limitPrice:i,shares:l,potentialProfit:c,potentialPayout:p,estimatedCost:u,usdcBalance:m,yesTokenBalance:d,noTokenBalance:f,isBalanceLoading:g,isSubmitting:h,isValid:x,validationErrors:N,supportsLimitOrder:E,kycRequired:S,kycUrl:v,expirationEnabled:b,expirationPreset:H,customDuration:K,customDurationUnit:me,onOutcomeChange:C,onSideChange:X,onOrderTypeChange:D,onQuantityChange:$,onLimitPriceChange:z,onExpirationEnabledChange:oe,onExpirationPresetChange:fe,onCustomDurationChange:M,onCustomDurationUnitChange:L,onSubmit:V}){let{t:I}=i18n.useTranslation(),[ue,ie]=react.useState(false),Ne=ui.useDisclosure();react.useEffect(()=>{S&&!Ne.isOpen&&Ne.onOpen();},[S]);let Re=react.useMemo(()=>{let F=n==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,o,t]),gt=!isNaN(a)&&a>0,Xe=react.useMemo(()=>{if(h)return I("predict.trade.submitting");if(S)return I("predict.trade.kycRequired");if(!gt)return I("predict.trade.enterAmount");let F=I(n==="buy"?"predict.trade.buy":"predict.trade.sell"),ae=I(o==="yes"?"predict.trade.yes":"predict.trade.no"),xt=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${F} ${ae}${xt}`},[h,S,gt,n,o,c,I]),er=react.useMemo(()=>o==="yes"?"primary":"secondary",[o]),Tt=()=>{$(Math.floor((m??0)/2*100)/100);},tr=()=>{$(m??0);},[We,ht]=react.useState(false),rr=()=>{if(S){Ne.onOpen();return}if(!x){ht(true);return}ht(false),V();};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:[I(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",I(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:[E?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:s,onSelectionChange:F=>D(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:I("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:I("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:I("predict.trade.market")}),s==="limit"&&E?jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(i)?void 0:parseFloat((i*100).toFixed(2)),onValueChange:F=>z(F/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"}}):Re!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Re," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let ae=F==="yes"?d:f;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>C(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===F?F==="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:I(F==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let xt=n==="buy"?F==="yes"?t.yesAsk:t.noAsk:F==="yes"?t.yesBid:t.noBid;return xt!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(xt)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===F&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${ae??0} shares`})]},F)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:I(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:cl,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`${m.toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:Tt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:tr,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(a)?void 0:a,onValueChange:F=>{ht(false),$(F);},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(F=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{$(Math.floor((o==="yes"?d??0:f??0)*F/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:[F,"%"]},F)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{$(o==="yes"?d??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:I("common.all")})]}),We&&N.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:N.map(F=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:F},F))})]}),s==="limit"&&E&&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:I("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:b,onValueChange:oe,"aria-label":I("predict.trade.setExpiration")})]}),b&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":I("predict.trade.setExpiration"),selectedKeys:[H],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&fe(ae);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:dl.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:I(ul[F])},F))}),H==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(K)?void 0:K,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:[me],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&L(ae);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pl.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:I(ml[F])},F))})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>ie(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:I("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",ue&&"rotate-180")})]}),Re!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Re,"% chance"]})]}),ue&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Total Size"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?`$${u.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(l)&&l>0?parseFloat(l.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(a)&&a>0?`$${p.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(a)&&a>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:er,fullWidth:true,radius:"lg",size:"lg",isDisabled:!gt||h,isLoading:h,onPress:rr,children:Xe})]}),jsxRuntime.jsx(xo,{isOpen:Ne.isOpen,onClose:Ne.onClose,kycUrl:v})]})}function ur({event:e,market:t,variant:r,initialSide:o,initialOutcome:n,chain:s}){let{outcome:a,side:i,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:N,isSubmitting:E,validation:S,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,setOutcome:D,setSide:$,setOrderType:z,setQuantity:oe,setLimitPrice:fe,setExpirationEnabled:M,setExpirationPreset:L,setCustomDuration:V,setCustomDurationUnit:I,submit:ue}=ho({market:t,initialSide:o,initialOutcome:n}),ie=walletConnector.useAuthCallback(ue),Ne=react.useMemo(()=>e?ao(e):void 0,[e]),Re=react.useMemo(()=>lo(t),[t]);return jsxRuntime.jsx(No,{event:Ne,market:Re,variant:r,outcome:a,side:i,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:N,isSubmitting:E,isValid:S.isValid,validationErrors:S.errors,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,onOutcomeChange:D,onSideChange:$,onOrderTypeChange:z,onQuantityChange:oe,onLimitPriceChange:fe,onExpirationEnabledChange:M,onExpirationPresetChange:L,onCustomDurationChange:V,onCustomDurationUnitChange:I,onSubmit:ie})}var Dt="predict-trade";function pr({id:e=Dt}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(kl,{...t})})}function kl({params:e,isOpen:t,onOpenChange:r}){let{t:o}=i18n.useTranslation(),{isMobile:n}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"blur",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.action")}),jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsx("div",{className:"px-5 pb-5",children:jsxRuntime.jsx(ur,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})]})})}):null}var Zr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Jr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Co({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[s,a]=react.useState(r),i=react.useCallback(h=>{h?a(r):t();},[r,t]),l=react.useCallback(()=>{a(Zr);},[]),c=react.useCallback(()=>{o(s),t();},[s,o,t]),p=react.useCallback((h,x)=>{a(N=>({...N,[h]:x}));},[]),u=react.useMemo(()=>Jr(s),[s]),m=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]),d=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:i,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.filter.title")}),jsxRuntime.jsx(Cl,{onClick:()=>i(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsxRuntime.jsx(fr,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(gr,{options:m,selected:s.source,onSelect:h=>p("source",h)})}),jsxRuntime.jsx(fr,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(gr,{options:d,selected:s.timeRemaining,onSelect:h=>p("timeRemaining",h)})}),jsxRuntime.jsx(fr,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(gr,{options:f,selected:s.minVolume,onSelect:h=>p("minVolume",h)})}),jsxRuntime.jsx(fr,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(gr,{options:g,selected:s.minLiquidity,onSelect:h=>p("minLiquidity",h)})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsxRuntime.jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:l,children:n("predict.filter.reset")}),jsxRuntime.jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[n("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",u,")"]})]})]})]})})})}function fr({label:e,children:t}){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsxRuntime.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function Cl({onClick:e}){return jsxRuntime.jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function gr({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let s=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:s?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:s?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:s?"#c7ff2e":"#a1a1aa"},onMouseEnter:a=>{s||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{s||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var _o={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Eo={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Al=["start_time","volume","liquidity","ending_soon"],To={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Dl={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Ro({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:a}){let{t:i}=i18n.useTranslation(),[l,c]=react.useState(false),p=react.useRef(null),u=react.useCallback(d=>{p.current&&!p.current.contains(d.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)),[u]),react.useEffect(()=>{if(!l)return;let d=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let m=Lo[e];return jsxRuntime.jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:p,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:To,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(d=>!d),children:[jsxRuntime.jsx(Fl,{}),jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i(Eo[e])}),jsxRuntime.jsx(Bl,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Dl,width:224,padding:4},children:Al.map(d=>{let f=Lo[d],g=e===d;return jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?o(!r):t(d),c(false);},children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsxRuntime.jsx("span",{style:{flex:1,fontWeight:500},children:i(Eo[d])}),g&&jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})]}),jsxRuntime.jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:To,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsxRuntime.jsx(Hl,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i("predict.filter.title")})]}),s>0&&jsxRuntime.jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:s})]})]})}var Lo={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function Fl(){return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"m21 16-4 4-4-4"}),jsxRuntime.jsx("path",{d:"M17 20V4"}),jsxRuntime.jsx("path",{d:"m3 8 4-4 4 4"}),jsxRuntime.jsx("path",{d:"M7 4v16"})]})}function Hl(){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Bl({open:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function Ao(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:s,isError:a,error:i,hasNextPage:l,fetchNextPage:c,refetch:p}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=react.useCallback(()=>{c();},[c]),d=react.useCallback(()=>{p();},[p]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:a,error:i??null,hasMore:l??false,fetchMore:m,refetch:d}}var Do="@keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}@media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}}@media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}";function en({count:e=6}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:Do}),jsxRuntime.jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(Wl,{index:r},r))})]})}function Wl({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:`evtShimmer 1.8s ease-in-out infinite ${e*120}ms`,borderRadius:6},o=e%3===0?"85%":e%3===1?"70%":"60%";return jsxRuntime.jsx("div",{style:{padding:8},children:jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsxRuntime.jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxRuntime.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:12,width:o}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(n=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:n===0?"55%":n===1?"45%":"35%"}}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxRuntime.jsx("div",{style:{...r,height:11,width:32}}),jsxRuntime.jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},n))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxRuntime.jsx("div",{style:{...r,height:10,width:56}}),jsxRuntime.jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Fg({count:e=48}){let t={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",maxWidth:1680,margin:"0 auto",gap:12},children:[jsxRuntime.jsx("style",{children:Do}),jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:[48,64,48,56,72,56].map((r,o)=>jsxRuntime.jsx("div",{style:{...t,height:24,width:r}},o))}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,minHeight:36},children:[jsxRuntime.jsx("div",{style:{...t,height:32,width:120,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...t,height:32,width:32,borderRadius:10}}),jsxRuntime.jsx("div",{style:{...t,height:32,width:80,borderRadius:10}})]}),jsxRuntime.jsx("div",{style:{flex:1,minHeight:0},children:jsxRuntime.jsx(en,{count:e})})]})}var Fo=3,Xl={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},Zl={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},rn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Wo={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Jl={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Ht=[{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 Ho(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 ec(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [rn,Jl];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [rn,Wo];let r=t[0]??"",o=t[1]??"",n=Ho(r)%Ht.length,s=Ho(o)%Ht.length;return s===n&&(s=(s+1)%Ht.length),[Ht[n],Ht[s]]}function tc(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Uo(e){let t=tc(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Ko(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Bo(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function $o(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 rc(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),s=[];return r>0&&s.push(`${r}d`),o>0&&s.push(`${o}h`),s.push(`${n}m`),s.join(" ")}var nc=`
2
2
  .badge-shine { position: relative; overflow: hidden; }
3
3
  .badge-shine::after {
4
4
  content: "";