@liberfi.io/ui-predict 4.0.34 → 4.0.35

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
@@ -1234,7 +1234,8 @@ interface SetupModalProps {
1234
1234
  * Which Polymarket wallet model is being set up. `deposit` wallets deploy
1235
1235
  * gaslessly server-side (no signature) and only require one approval
1236
1236
  * signature; `safe` wallets require a deploy signature + an approval
1237
- * signature. Defaults to `safe` for backward compatibility.
1237
+ * signature. Informational only the actual deploy path is decided by the
1238
+ * caller-provided `onDeployAndApprove`; this modal does not branch on it.
1238
1239
  */
1239
1240
  walletKind?: "safe" | "deposit";
1240
1241
  /** Whether the active wallet (Safe or deposit wallet) is deployed. */
package/dist/index.d.ts CHANGED
@@ -1234,7 +1234,8 @@ interface SetupModalProps {
1234
1234
  * Which Polymarket wallet model is being set up. `deposit` wallets deploy
1235
1235
  * gaslessly server-side (no signature) and only require one approval
1236
1236
  * signature; `safe` wallets require a deploy signature + an approval
1237
- * signature. Defaults to `safe` for backward compatibility.
1237
+ * signature. Informational only the actual deploy path is decided by the
1238
+ * caller-provided `onDeployAndApprove`; this modal does not branch on it.
1238
1239
  */
1239
1240
  walletKind?: "safe" | "deposit";
1240
1241
  /** Whether the active wallet (Safe or deposit wallet) is deployed. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactQuery=require('@tanstack/react-query'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),xo=require('canvas-confetti'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var xo__default=/*#__PURE__*/_interopDefault(xo);var jl={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},pi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],go=(()=>{let e=t=>{let r=pi.indexOf(t);return r===-1?pi.length:r};return Object.entries(jl).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function gi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:c}=i18n.useTranslation(),d=react.useCallback(()=>{o(null);},[o]),p=c("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsxRuntime.jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxRuntime.jsxs("div",{className:"cat-primary-row",children:[jsxRuntime.jsx("div",{className:"cat-tabs hideScrollbar",children:jsxRuntime.jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsxRuntime.jsx(mi,{label:p,isSelected:t===null,onPress:d,showPulse:p===a}),jsxRuntime.jsx(Ql,{}),e.map(m=>jsxRuntime.jsx(mi,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),s&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:s})]}),t&&n.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(fi,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsxRuntime.jsx(fi,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function mi({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,n&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:n})]})}function Ql(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function fi({label:e,icon:t,isSelected:r,onPress:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:n,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function zh({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsxRuntime.jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function Xl(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Jl(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function xi({onSelect:e,trailing:t,className:r}){let[n,o]=react.useState(null),[i,s]=react.useState(null),a=react.useCallback(m=>{o(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=react.useCallback(m=>{s(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=Xl(go),d=go.find(m=>m.slug===n),p=Jl(d);return jsxRuntime.jsx(gi,{categories:c,selectedCategory:n,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function vn(e){return {title:e.title,imageUrl:e.image_url}}function xn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var Hr=24,ho=4,bn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ae={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},yn=ae.ALL,Yh={[ae.ONE_DAY]:bn.ONE_MINUTE,[ae.ONE_WEEK]:bn.ONE_HOUR,[ae.ONE_MONTH]:bn.ONE_HOUR,[ae.ALL]:bn.ONE_DAY},Qh={[ae.ONE_DAY]:300,[ae.ONE_WEEK]:3600,[ae.ONE_MONTH]:10800,[ae.ALL]:1440*60},Xh={[ae.ONE_DAY]:1440*60,[ae.ONE_WEEK]:10080*60,[ae.ONE_MONTH]:720*60*60,[ae.ALL]:null},kn=1,Sn=1,Jh=1,Zh=1,ev=99,wr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},tv=wr.ONE_WEEK,rv={[wr.ONE_HOUR]:60,[wr.SIX_HOURS]:60,[wr.ONE_DAY]:300,[wr.ONE_WEEK]:1800,[wr.MAX]:1800};var ki=react.createContext(null);function sr(){let e=react.useContext(ki);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var ic=1e4;function sc({pollingInterval:e=ic,enabled:t=true,children:r}){let n=walletConnector.useWallets(),o=react.useMemo(()=>n.find(T=>T.chainNamespace===types.ChainNamespace.SOLANA&&T.isConnected)?.address,[n]),i=react.useMemo(()=>n.find(T=>T.chainNamespace===types.ChainNamespace.EVM&&T.isConnected)?.address,[n]),{data:s,isLoading:a,isFetching:l,error:c}=reactPredict.useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:d,isLoading:p}=reactPredict.useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:u}=reactPredict.usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,h=m?.wallet_kind,v=m?.deposit_wallet_address,k=h==="safe"?m?.safe_address:v,S=h==="safe"?m?.safe_deployed??false:m?.deposit_wallet_deployed??false,{data:w,isLoading:x,isFetching:E,error:P}=reactPredict.useBalance({source:"polymarket",user:i??""},{enabled:t&&g&&!!i,refetchInterval:e}),L=react.useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketWalletKind:h,polymarketWalletAddress:k,polymarketDepositWalletAddress:v,polymarketWalletDeployed:S,polymarketSafeAddress:f,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:g&&w?Number(w.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:u,isLoading:a||x,isFetching:l||E,error:c??P??null}),[o,i,h,k,v,S,f,s,w,g,d,p,m,u,a,x,l,E,c,P]);return jsxRuntime.jsx(ki.Provider,{value:L,children:r})}var lc={minutes:60,hours:3600,days:86400};function wn(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*lc[r]}}function Pn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function ye(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function Nn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let s=parseInt(o[1],10)/1e6,a=parseInt(o[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:ye(s,2).toFixed(2),active:ye(a,2).toFixed(2),available:ye(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function zr(e,t=2){return parseFloat(ye(e,t).toFixed(t)).toString()}function ar(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};xo__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{xo__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{xo__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Ni({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o}=i18n.useTranslation(),{status:i}=walletConnector.useAuth(),s=walletConnector.useWallets(),a=reactPredict.usePredictClient(),l=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),d=e.source,p=d==="polymarket",m=s.find(O=>O.chainNamespace===types.ChainNamespace.SOLANA&&O.isConnected),u=s.find(O=>O.chainNamespace===types.ChainNamespace.EVM&&O.isConnected&&"switchChain"in O),f=i==="authenticated",g=m?.address,h=u?.address,v=react.useMemo(()=>{if(d!=="polymarket")return;let O=e.provider_meta?.["polymarket.clobTokenIds"];return O?(typeof O=="string"?JSON.parse(O):O)[0]:void 0},[d,e.provider_meta]),{data:k,isLoading:S}=reactPredict.useTickSize(v),w=k?.minimum_tick_size?String(k.minimum_tick_size):"0.01",{data:x,isLoading:E}=reactPredict.useFeeRate(v),P=String(x?.base_fee??0),{data:L}=reactPredict.useRebateConfig(),T=L?.builder_enabled&&L.builder_code?L.builder_code:void 0,[D,V]=react.useState(t),[R,_]=react.useState("market"),[N,X]=react.useState(NaN),[G,te]=react.useState(NaN),[b,y]=react.useState(false),[z,j]=react.useState(null),[re,oe]=react.useState(false),[fe,ut]=react.useState(false),[He,Ce]=react.useState("1h"),[Ke,pt]=react.useState(30),[vt,Re]=react.useState("minutes"),ze=null,xt=false,B=null,xe,qe,et;try{let O=sr();ze={kalshiUsdcBalance:O.kalshiUsdcBalance,polymarketUsdcBalance:O.polymarketUsdcBalance,isLoading:O.isLoading},xt=O.kalshiKycVerified,B=O.kalshiKycUrl,xe=O.polymarketSafeAddress,qe=O.polymarketWalletKind,et=O.polymarketWalletAddress;}catch{}let{data:Ve}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:d},{enabled:e.status==="open"}),ke=react.useMemo(()=>{let O=reactPredict.pickBestAsk(Ve,D);if(O!=null&&O>0)return O;let De=D==="yes"?0:1,Ye=e.outcomes[De];return Ye?.best_ask??Ye?.price??.5},[Ve,e.outcomes,D]),F=react.useCallback(O=>{_(O);},[]),Me=react.useCallback(O=>{V(O),te(NaN);},[]);react.useEffect(()=>{R==="limit"&&isNaN(G)&&te(Math.round(ke*100)/100);},[R,G,ke]);let Pe=react.useMemo(()=>isNaN(N)||N<=0?0:ke>0?N/ke:0,[N,ke]),je=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:Ve,outcome:D,side:"buy",sharesNeeded:Pe,slippageBps:r}),[Ve,D,Pe,r]),xr=react.useMemo(()=>je.status==="ok"&&je.worstPrice!=null&&je.worstPrice>0?je.worstPrice:ke,[je,ke]),br=react.useMemo(()=>isNaN(N)||N<=0?"0":String(Math.round(N*1e6)),[N]),oo=e.provider_meta?.["dflow.yesMint"]??"",Jt=e.provider_meta?.["dflow.noMint"]??"",io=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ir=D==="yes"?oo:Jt,_t=io,mt=Ir,Ge=d==="kalshi"?g??"":h??"",{data:Or,isLoading:so}=reactPredict.usePositions({source:d,user:Ge},{enabled:!!Ge}),ao=d==="kalshi"&&!!_t&&!!mt&&!!g&&br!=="0",{refetch:It}=reactPredict.useDFlowQuote({inputMint:_t,outputMint:mt,amount:br,userPublicKey:g??"",slippageBps:100},{enabled:ao}),Ot=react.useMemo(()=>ze?d==="kalshi"?ze.kalshiUsdcBalance:ze.polymarketUsdcBalance:Or&&Or.positions.reduce((De,Ye)=>Ye.side==="USDC"||Ye.side==="collateral"?De+(Ye.current_value??0):De,0)||null,[ze,Or,d]),lo=ze?ze.isLoading:so,ln=react.useMemo(()=>R==="limit"&&p&&!isNaN(G)?G:ke,[R,p,G,ke]),Dr=react.useMemo(()=>isNaN(N)||N<=0?0:N,[N]),cn=react.useMemo(()=>isNaN(N)||N<=0?0:ln>0?N/ln*1:0,[N,ln]),Zt=cn-Dr,er=react.useCallback(O=>{if(isNaN(O)){X(NaN);return}X(Math.round(Math.max(0,O)*100)/100);},[]),tr=react.useCallback(O=>{if(isNaN(O)){te(NaN);return}let De=Math.max(.01,Math.min(.99,O));te(Math.round(De*100)/100);},[]),Dt=react.useCallback(()=>{X(NaN),te(NaN),_("market"),ut(false),Ce("1h"),pt(30),Re("minutes");},[]),Ar=react.useMemo(()=>{let O=[];return isNaN(N)||N<=0?O.push(o("predict.trade.minAmountUsd",{amount:Sn})):N<Sn&&O.push(o("predict.trade.minAmountUsd",{amount:Sn})),e.status!=="open"&&O.push(o("predict.trade.marketNotActive")),Ot!=null&&!isNaN(N)&&N>0&&N>ye(Ot,2)&&O.push(o("predict.trade.insufficientBalance")),R==="limit"&&p&&(isNaN(G)||G<.01||G>.99)&&O.push(o("predict.trade.limitPriceRange")),R==="limit"&&p&&fe&&He==="custom"&&(isNaN(Ke)||Ke<=0)&&O.push(o("predict.trade.expiration.invalidDate")),d==="polymarket"&&R==="market"&&!isNaN(N)&&N>0&&Pe>0&&(je.status==="insufficient_liquidity"?O.push(o("predict.trade.insufficientLiquidity",{available:ye(je.totalAvailable,2)})):je.status==="exceeds_slippage"&&O.push(o("predict.trade.priceImpactTooHigh",{impact:(je.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:O.length===0,errors:O}},[N,e.status,Ot,R,p,G,fe,He,Ke,d,Pe,je,r,o]),dn=react.useMemo(()=>Ot==null||isNaN(N)||N<=0?false:N>ye(Ot,2),[Ot,N]),Fr=react.useCallback(()=>{n?.(d);},[n,d]),{mutateAsync:tt}=reactPredict.useDFlowSubmit(),{data:yr}=reactPredict.useOrder({id:z??"",source:d},{enabled:!!z});react.useEffect(()=>{if(!yr||!z)return;let{status:O}=yr;O==="closed"?(j(null),y(false),ui.toast.success(o("predict.trade.submitSuccess")),ar(),Dt(),c.invalidateQueries({queryKey:["predict","positions"]})):(O==="failed"||O==="expired")&&(y(false),j(null),ui.toast.error(o("predict.trade.submitError")));},[yr,z,c,Dt,o]);let un=react.useCallback(async()=>{if(!g||!m)return;if(!_t||!mt){ui.toast.error("Missing token mint addresses"),y(false);return}if(!xt){oe(true),y(false);return}let rt=(await It()).data?.transaction;if(!rt){ui.toast.error(o("predict.trade.submitError")),y(false);return}let rr=Uint8Array.from(atob(rt),yt=>yt.charCodeAt(0)),Pt=await m.signTransaction(rr),bt=await tt({signedTransaction:btoa(String.fromCharCode(...Pt)),orderContext:{user_public_key:g,input_mint:_t,output_mint:mt,amount:br,price:String(ke),side:"BUY",outcome:D==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});j(bt.signature);},[g,m,It,tt,_t,mt,br,ke,D,e.slug,o,xt]),pn=react.useCallback(async()=>{if(!u||!l)return;let O=u.chain,De=O!==types.Chain.POLYGON;De&&await u.switchChain(types.Chain.POLYGON);try{let Ye=await u.getEip1193Provider();if(!Ye){ui.toast.error(o("predict.trade.submitError")),y(!1);return}let rt=qe==="deposit"&&!!et,rr=!rt&&!!xe,Pt=rt?et:xe,bt={address:u.address,signatureType:rt?3:rr?2:0,signTypedData:async(_e,At,jt,kr)=>{let Gt=[];"name"in _e&&Gt.push({name:"name",type:"string"}),"version"in _e&&Gt.push({name:"version",type:"string"}),"chainId"in _e&&Gt.push({name:"chainId",type:"uint256"}),"verifyingContract"in _e&&Gt.push({name:"verifyingContract",type:"address"}),"salt"in _e&&Gt.push({name:"salt",type:"bytes32"});let uo={EIP712Domain:Gt,...At};return await Ye.request({method:"eth_signTypedData_v4",params:[u.address,JSON.stringify({domain:_e,types:uo,primaryType:jt,message:kr})]})}},yt=l.credentials??await l.authenticate(bt),nr=D==="yes"?0:1,Br="",or=e.provider_meta?.["polymarket.clobTokenIds"];or&&(Br=(typeof or=="string"?JSON.parse(or):or)[nr]??"");let mn=e.provider_meta?.["polymarket.negRisk"]??!1,C=R==="limit"&&!isNaN(G)?G:xr,be=Pn(C,w),We=R==="limit"?fe?"GTD":"GTC":"FOK",Qe=R==="market"?N:be>0?N/be:0,Ue={tokenId:Br,price:be,size:Qe,side:"BUY",orderType:We,tickSize:w,negRisk:mn,...Pt&&{funderAddress:Pt},...T&&{builderCode:T},...R==="limit"&&fe&&{expiration:wn(He,Ke,vt)}},Xe;if(rt)Xe=await reactPredict.buildSignedV2OrderPayload({signer:bt,depositWalletAddress:Pt,input:Ue,owner:yt.apiKey});else {let _e=reactPredict.buildCtfExchangeDomain(mn),At=reactPredict.buildOrderMessage({...Ue,signerAddress:bt.address,signatureType:bt.signatureType,feeRateBps:P}),jt=await bt.signTypedData(_e,reactPredict.CTF_ORDER_TYPES,"Order",At),kr=reactPredict.buildSignedOrder(At,jt,Ue.orderType);Xe=reactPredict.buildClobPayload(kr,yt.apiKey);}let ft=JSON.stringify(Xe),Ae=await reactPredict.buildPolymarketL2Headers(yt.address,{apiKey:yt.apiKey,secret:yt.secret,passphrase:yt.passphrase,method:"POST",requestPath:"/order",body:ft});await a.createPolymarketOrder(Xe,Ae),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),ar(),Dt(),y(!1);}finally{De&&O&&u.switchChain(O).catch(()=>{});}},[u,l,D,e.provider_meta,R,G,xr,N,a,c,fe,He,Ke,vt,Dt,o,w,P,xe,qe,et,T]),co=react.useCallback(async()=>{if(!(!Ar.isValid||!f)){y(true),j(null),oe(false);try{d==="kalshi"?await un():await pn();}catch(O){let De=O instanceof Error?O.message:"",Ye=d==="polymarket"&&De?Nn(De,o,"buy"):De||void 0;ui.toast.error(Ye||o("predict.trade.submitError")),y(false);}}},[Ar.isValid,f,d,un,pn,o]);return {outcome:D,orderType:R,quantity:N,limitPrice:G,shares:Pe,estimatedCost:Dr,potentialPayout:cn,potentialProfit:Zt,pricePerShare:ke,usdcBalance:Ot,isBalanceLoading:lo,isMarketDataLoading:d==="polymarket"&&(E||S),isSubmitting:b,validation:Ar,isInsufficientBalance:dn,source:d,supportsLimitOrder:p,kycRequired:re,kycUrl:B,expirationEnabled:fe,expirationPreset:He,customDuration:Ke,customDurationUnit:vt,setOutcome:Me,setOrderType:F,setQuantity:er,setLimitPrice:tr,setExpirationEnabled:ut,setExpirationPreset:Ce,setCustomDuration:pt,setCustomDurationUnit:Re,submit:co,notifyInsufficientBalance:Fr}}function Cn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=i18n.useTranslation();return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),jsxRuntime.jsx("span",{children:n(o)})]},o))}),r&&jsxRuntime.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsxRuntime.jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Gc=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,qc=["5m","1h","12h","24h","eod","custom"],Yc={"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"},Qc=["minutes","hours","days"],Xc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Jc={maximumFractionDigits:0};function Ii({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:c,estimatedCost:d,usdcBalance:p,isBalanceLoading:m,isMarketDataLoading:u,isSubmitting:f,isValid:g,validationErrors:h,isInsufficientBalance:v,onInsufficientBalance:k,supportsLimitOrder:S,kycRequired:w,kycUrl:x,expirationEnabled:E,expirationPreset:P,customDuration:L,customDurationUnit:T,onOutcomeChange:D,onOrderTypeChange:V,onQuantityChange:R,onLimitPriceChange:_,onExpirationEnabledChange:N,onExpirationPresetChange:X,onCustomDurationChange:G,onCustomDurationUnitChange:te,onSubmit:b}){let{t:y}=i18n.useTranslation(),[z,j]=react.useState(false),re=ui.useDisclosure(),[oe,fe]=react.useState(""),ut=react.useRef(false);react.useEffect(()=>{ut.current||fe(isNaN(i)?"":String(i));},[i]);let[He,Ce]=react.useState(""),Ke=react.useRef(false);react.useEffect(()=>{Ke.current||(isNaN(s)?Ce(""):Ce(String(parseFloat((s*100).toFixed(2)))));},[s]);let pt=react.useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(Ce(F),F===""||F==="."){_(NaN);return}let Pe=parseFloat(F);isNaN(Pe)||_(Pe/100);},[_]),vt=react.useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(fe(F),Ve(false),F===""||F==="."){R(NaN);return}let Pe=parseFloat(F);isNaN(Pe)||R(Pe);},[R]);react.useEffect(()=>{w&&!re.isOpen&&re.onOpen();},[w]);let Re=react.useMemo(()=>{let F=n==="yes"?t.yesAsk:t.noAsk;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,t]),ze=!isNaN(i)&&i>0,xt=react.useMemo(()=>{if(m)return y("predict.trade.loadingBalance");if(u)return y("predict.trade.loadingMarketData");if(f)return y("predict.trade.submitting");if(w)return y("predict.trade.kycRequired");if(!ze)return y("predict.trade.enterAmount");let F=y(n==="yes"?"predict.trade.yes":"predict.trade.no"),Me=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${y("predict.trade.buy")} ${F}${Me}`},[m,u,f,w,ze,n,l,y]),B=react.useMemo(()=>n==="yes"?"primary":"secondary",[n]),xe=()=>{R(Math.floor((p??0)/2*100)/100);},qe=()=>{R(ye(p??0,2));},[et,Ve]=react.useState(false),ke=()=>{if(w){re.onOpen();return}if(v&&k){Ve(false),k();return}if(!g){Ve(true);return}Ve(false),b();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:n==="yes"?"text-bullish":"text-bearish",children:[y("predict.trade.buy")," ",y(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[S?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:F=>V(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:y("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:y("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.market")}),o==="limit"&&S?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:He,onChange:F=>pt(F.target.value),onFocus:()=>{Ke.current=true;},onBlur:()=>{Ke.current=false,isNaN(s)?Ce(""):Ce(String(parseFloat((s*100).toFixed(2))));},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):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 Me=F==="yes"?t.yesAsk:t.noAsk;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>D(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===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:y(F==="yes"?"predict.trade.yes":"predict.trade.no")}),Me!=null&&jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Me)*100).toFixed(2)),"\xA2"]})]})},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:y("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:Gc,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:p!=null?`${ye(p,2).toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:xe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:qe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:oe,onChange:F=>vt(F.target.value),onFocus:()=>{ut.current=true;},onBlur:()=>{ut.current=false,fe(isNaN(i)?"":String(i));},startContent:jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),et&&h.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:h.map(F=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:F},F))})]}),o==="limit"&&S&&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:y("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:E,onValueChange:N,"aria-label":y("predict.trade.setExpiration")})]}),E&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[P],onSelectionChange:F=>{let Me=Array.from(F)[0];Me&&X(Me);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:qc.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:y(Yc[F])},F))}),P==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(L)?void 0:L,onValueChange:G,minValue:1,step:1,formatOptions:Jc,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:[T],onSelectionChange:F=>{let Me=Array.from(F)[0];Me&&te(Me);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Qc.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:y(Xc[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:()=>j(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:y("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",z&&"rotate-180")})]}),Re!=null&&jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:y("predict.trade.chance",{percent:Re})})]}),z&&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:y("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:y("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?zr(a):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:y("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:y("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:B,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||u||!ze||f,isLoading:f||m||u,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:ke,children:xt})]}),jsxRuntime.jsx(Cn,{isOpen:re.isOpen,onClose:re.onClose,kycUrl:x})]})}function En({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:s}){let{outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,pricePerShare:g,usdcBalance:h,isBalanceLoading:v,isMarketDataLoading:k,isSubmitting:S,validation:w,isInsufficientBalance:x,supportsLimitOrder:E,kycRequired:P,kycUrl:L,expirationEnabled:T,expirationPreset:D,customDuration:V,customDurationUnit:R,setOutcome:_,setOrderType:N,setQuantity:X,setLimitPrice:G,setExpirationEnabled:te,setExpirationPreset:b,setCustomDuration:y,setCustomDurationUnit:z,submit:j,notifyInsufficientBalance:re}=Ni({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:s}),oe=walletConnector.useAuthCallback(j),fe=react.useMemo(()=>e?vn(e):void 0,[e]),ut=react.useMemo(()=>xn(t,{yesAsk:a==="yes"?g:void 0,noAsk:a==="no"?g:void 0}),[t,a,g]);return jsxRuntime.jsx(Ii,{event:fe,market:ut,variant:r,outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,usdcBalance:h,isBalanceLoading:v,isMarketDataLoading:k,isSubmitting:S,isValid:w.isValid,validationErrors:w.errors,isInsufficientBalance:x,onInsufficientBalance:s?re:void 0,supportsLimitOrder:E,kycRequired:P,kycUrl:L,expirationEnabled:T,expirationPreset:D,customDuration:V,customDurationUnit:R,onOutcomeChange:_,onOrderTypeChange:N,onQuantityChange:X,onLimitPriceChange:G,onExpirationEnabledChange:te,onExpirationPresetChange:b,onCustomDurationChange:y,onCustomDurationUnitChange:z,onSubmit:oe})}var Wr="predict-trade";function Tn({id:e=Wr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(sd,{...t})})}function sd({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{className:o?"":"p-2",children:[jsxRuntime.jsx(En,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsxRuntime.jsx("div",{className:"px-4 pb-4",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var Ur={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function ko(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function Di({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(r),l=react.useMemo(()=>o?Ur:{...Ur,source:"polymarket"},[o]),c=react.useCallback(k=>{k?a(r):t();},[r,t]),d=react.useCallback(()=>{a(l);},[l]),p=react.useCallback(()=>{n(s),t();},[s,n,t]),m=react.useCallback((k,S)=>{a(w=>({...w,[k]:S}));},[]),u=react.useMemo(()=>ko(s,o),[s,o]),f=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),h=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),v=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:c,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:i("predict.filter.title")}),jsxRuntime.jsx(pd,{onClick:()=>c(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsxRuntime.jsx(Rn,{label:i("predict.filter.platform"),children:jsxRuntime.jsx(_n,{options:f,selected:s.source,onSelect:k=>m("source",k)})}),jsxRuntime.jsx(Rn,{label:i("predict.filter.timeRemaining"),children:jsxRuntime.jsx(_n,{options:g,selected:s.timeRemaining,onSelect:k=>m("timeRemaining",k)})}),jsxRuntime.jsx(Rn,{label:i("predict.filter.minVolume"),children:jsxRuntime.jsx(_n,{options:h,selected:s.minVolume,onSelect:k=>m("minVolume",k)})}),jsxRuntime.jsx(Rn,{label:i("predict.filter.minLiquidity"),children:jsxRuntime.jsx(_n,{options:v,selected:s.minLiquidity,onSelect:k=>m("minLiquidity",k)})})]}),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:d,children:i("predict.filter.reset")}),jsxRuntime.jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:p,children:[i("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",u,")"]})]})]})]})})})}function Rn({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 pd({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 _n({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var zi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Fi={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},kd=["start_time","volume","liquidity","ending_soon"],Bi={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"},Sd={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 Wi({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:a}=i18n.useTranslation(),[l,c]=react.useState(false),d=react.useRef(null),p=react.useCallback(u=>{d.current&&!d.current.contains(u.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),react.useEffect(()=>{if(!l)return;let u=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[l]);let m=Hi[e];return jsxRuntime.jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:d,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:Bi,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(u=>!u),children:[jsxRuntime.jsx(wd,{}),jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Fi[e])}),jsxRuntime.jsx(Nd,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Sd,width:224,padding:4},children:kd.map(u=>{let f=Hi[u],g=e===u;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===u?n(!r):t(u),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:a(Fi[u])}),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"})})]},u)})})]}),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:u=>{u.currentTarget.style.background="rgba(39,39,42,1)",u.currentTarget.style.color="#fff";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)",u.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:Bi,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsxRuntime.jsx(Pd,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsxRuntime.jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Hi={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function wd(){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 Pd(){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 Nd({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 Ki(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:c,refetch:d}=reactPredict.useInfiniteEvents(t),p=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=react.useCallback(()=>{c();},[c]),u=react.useCallback(()=>{d();},[d]);return {data:p,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:m,refetch:u}}var Vi=`
1
+ 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactQuery=require('@tanstack/react-query'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),xo=require('canvas-confetti'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var xo__default=/*#__PURE__*/_interopDefault(xo);var jl={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},pi=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],go=(()=>{let e=t=>{let r=pi.indexOf(t);return r===-1?pi.length:r};return Object.entries(jl).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(n=>({slug:n,label:n}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function gi({categories:e,selectedCategory:t,selectedTag:r,activeTags:n,onCategorySelect:o,onTagSelect:i,trailing:s,pulsingTab:a="Trending",className:l}){let{t:c}=i18n.useTranslation(),d=react.useCallback(()=>{o(null);},[o]),p=c("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-2.5 lg:px-4 lg:py-2",l),children:[jsxRuntime.jsx("style",{children:".cat-primary-row{display:flex;width:100%;flex-direction:column;gap:8px}@media(min-width:1024px){.cat-primary-row{flex-direction:row;align-items:center}}.cat-primary-row>.cat-tabs{min-width:0;overflow-x:auto;overflow-y:hidden;-ms-overflow-style:none;scrollbar-width:none}.cat-primary-row>.cat-tabs::-webkit-scrollbar{display:none}@media(min-width:1024px){.cat-primary-row>.cat-tabs{flex:1 1 0%}}"}),jsxRuntime.jsxs("div",{className:"cat-primary-row",children:[jsxRuntime.jsx("div",{className:"cat-tabs hideScrollbar",children:jsxRuntime.jsxs("div",{className:"flex min-h-9 items-stretch gap-x-3 lg:min-h-10",children:[jsxRuntime.jsx(mi,{label:p,isSelected:t===null,onPress:d,showPulse:p===a}),jsxRuntime.jsx(Ql,{}),e.map(m=>jsxRuntime.jsx(mi,{label:m.category,isSelected:t===m.category,onPress:()=>o(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),s&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:s})]}),t&&n.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1.5 pl-1 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(fi,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>i(null)}),n.map(m=>jsxRuntime.jsx(fi,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function mi({label:e,isSelected:t,onPress:r,badge:n,showPulse:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b px-2.5 py-1.5 text-sm font-medium capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[o?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,n&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:n})]})}function Ql(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function fi({label:e,icon:t,isSelected:r,onPress:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:n,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-3 py-1.5 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-primary/40 bg-primary/15 text-primary":"border-border/80 text-neutral-500 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function zh({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-2.5 lg:px-4 lg:py-2",children:jsxRuntime.jsx("div",{className:"flex min-h-9 items-center gap-x-3 lg:min-h-10",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function Xl(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Jl(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function xi({onSelect:e,trailing:t,className:r}){let[n,o]=react.useState(null),[i,s]=react.useState(null),a=react.useCallback(m=>{o(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=react.useCallback(m=>{s(m),e?.({categorySlug:n,tagSlug:m});},[n,e]),c=Xl(go),d=go.find(m=>m.slug===n),p=Jl(d);return jsxRuntime.jsx(gi,{categories:c,selectedCategory:n,selectedTag:i,activeTags:p,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function vn(e){return {title:e.title,imageUrl:e.image_url}}function xn(e,t){let r=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.yesAsk??r?.best_ask??r?.price,noAsk:t?.noAsk??n?.best_ask??n?.price,yesBid:t?.yesBid??r?.best_bid,noBid:t?.noBid??n?.best_bid,yesSubTitle:r?.label??"Yes",noSubTitle:n?.label??"No"}}var Hr=24,ho=4,bn={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ae={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},yn=ae.ALL,Yh={[ae.ONE_DAY]:bn.ONE_MINUTE,[ae.ONE_WEEK]:bn.ONE_HOUR,[ae.ONE_MONTH]:bn.ONE_HOUR,[ae.ALL]:bn.ONE_DAY},Qh={[ae.ONE_DAY]:300,[ae.ONE_WEEK]:3600,[ae.ONE_MONTH]:10800,[ae.ALL]:1440*60},Xh={[ae.ONE_DAY]:1440*60,[ae.ONE_WEEK]:10080*60,[ae.ONE_MONTH]:720*60*60,[ae.ALL]:null},kn=1,Sn=1,Jh=1,Zh=1,ev=99,wr={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},tv=wr.ONE_WEEK,rv={[wr.ONE_HOUR]:60,[wr.SIX_HOURS]:60,[wr.ONE_DAY]:300,[wr.ONE_WEEK]:1800,[wr.MAX]:1800};var ki=react.createContext(null);function sr(){let e=react.useContext(ki);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var ic=1e4;function sc({pollingInterval:e=ic,enabled:t=true,children:r}){let n=walletConnector.useWallets(),o=react.useMemo(()=>n.find(T=>T.chainNamespace===types.ChainNamespace.SOLANA&&T.isConnected)?.address,[n]),i=react.useMemo(()=>n.find(T=>T.chainNamespace===types.ChainNamespace.EVM&&T.isConnected)?.address,[n]),{data:s,isLoading:a,isFetching:l,error:c}=reactPredict.useBalance({source:"kalshi",user:o??""},{enabled:t&&!!o,refetchInterval:e}),{data:d,isLoading:p}=reactPredict.useDFlowKYC(o,{enabled:t&&!!o,refetchInterval:3e4}),{data:m,isLoading:u}=reactPredict.usePolymarketSetup(i,{enabled:t&&!!i,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,h=m?.wallet_kind??"deposit",v=m?.deposit_wallet_address,k=h==="safe"?m?.safe_address:v,S=h==="safe"?m?.safe_deployed??false:m?.deposit_wallet_deployed??false,{data:w,isLoading:x,isFetching:E,error:P}=reactPredict.useBalance({source:"polymarket",user:i??""},{enabled:t&&g&&!!i,refetchInterval:e}),L=react.useMemo(()=>({solanaAddress:o,evmAddress:i,polymarketWalletKind:h,polymarketWalletAddress:k,polymarketDepositWalletAddress:v,polymarketWalletDeployed:S,polymarketSafeAddress:f,kalshiUsdcBalance:s?Number(s.balance):null,polymarketUsdcBalance:g&&w?Number(w.balance):null,kalshiKycVerified:d?.verified??false,kalshiKycUrl:d?.kyc_url??null,kalshiKycLoading:p,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:u,isLoading:a||x,isFetching:l||E,error:c??P??null}),[o,i,h,k,v,S,f,s,w,g,d,p,m,u,a,x,l,E,c,P]);return jsxRuntime.jsx(ki.Provider,{value:L,children:r})}var lc={minutes:60,hours:3600,days:86400};function wn(e,t,r){let n=Math.floor(Date.now()/1e3);switch(e){case "5m":return n+300;case "1h":return n+3600;case "12h":return n+720*60;case "24h":return n+1440*60;case "eod":{let o=new Date;return o.setUTCHours(23,59,59,0),Math.floor(o.getTime()/1e3)}case "custom":return n+t*lc[r]}}function Pn(e,t){let r=parseFloat(t);return !r||r<=0?e:Math.round(e/r)*r}function ye(e,t){let r=Math.pow(10,t);return Math.floor(e*r)/r}function Nn(e,t,r){let n=e.match(/Size\s*\(([\d.]+)\)\s*lower than the minimum:\s*([\d.]+)/i);if(n)return t("predict.trade.polymarket.minOrderSize",{current:n[1],min:n[2]});let o=e.match(/balance:\s*(\d+),\s*sum of active orders:\s*(\d+)/i);if(o){let s=parseInt(o[1],10)/1e6,a=parseInt(o[2],10)/1e6,l=Math.max(0,s-a);return t("predict.trade.polymarket.insufficientBalance",{total:ye(s,2).toFixed(2),active:ye(a,2).toFixed(2),available:ye(l,2).toFixed(2)})}return /not enough balance/i.test(e)?t(r==="sell"?"predict.trade.insufficientShares":"predict.trade.insufficientBalance"):/max accuracy of/i.test(e)?t("predict.trade.polymarket.decimalAccuracy"):/tick size/i.test(e)?t("predict.trade.polymarket.tickSizeError"):/couldn.*fully filled|FOK.*filled or killed/i.test(e)?t("predict.trade.polymarket.fokNotFilled"):e.replace(/order\s+0x[a-f0-9]+\s+is invalid\.\s*/i,"")||e}function zr(e,t=2){return parseFloat(ye(e,t).toFixed(t)).toString()}function ar(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};xo__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{xo__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{xo__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Ni({market:e,initialOutcome:t="yes",slippageBps:r=100,onInsufficientBalance:n}){let{t:o}=i18n.useTranslation(),{status:i}=walletConnector.useAuth(),s=walletConnector.useWallets(),a=reactPredict.usePredictClient(),l=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),d=e.source,p=d==="polymarket",m=s.find(O=>O.chainNamespace===types.ChainNamespace.SOLANA&&O.isConnected),u=s.find(O=>O.chainNamespace===types.ChainNamespace.EVM&&O.isConnected&&"switchChain"in O),f=i==="authenticated",g=m?.address,h=u?.address,v=react.useMemo(()=>{if(d!=="polymarket")return;let O=e.provider_meta?.["polymarket.clobTokenIds"];return O?(typeof O=="string"?JSON.parse(O):O)[0]:void 0},[d,e.provider_meta]),{data:k,isLoading:S}=reactPredict.useTickSize(v),w=k?.minimum_tick_size?String(k.minimum_tick_size):"0.01",{data:x,isLoading:E}=reactPredict.useFeeRate(v),P=String(x?.base_fee??0),{data:L}=reactPredict.useRebateConfig(),T=L?.builder_enabled&&L.builder_code?L.builder_code:void 0,[D,V]=react.useState(t),[R,_]=react.useState("market"),[N,X]=react.useState(NaN),[G,te]=react.useState(NaN),[b,y]=react.useState(false),[z,j]=react.useState(null),[re,oe]=react.useState(false),[fe,ut]=react.useState(false),[He,Ce]=react.useState("1h"),[Ke,pt]=react.useState(30),[vt,Re]=react.useState("minutes"),ze=null,xt=false,B=null,xe,qe,et;try{let O=sr();ze={kalshiUsdcBalance:O.kalshiUsdcBalance,polymarketUsdcBalance:O.polymarketUsdcBalance,isLoading:O.isLoading},xt=O.kalshiKycVerified,B=O.kalshiKycUrl,xe=O.polymarketSafeAddress,qe=O.polymarketWalletKind,et=O.polymarketWalletAddress;}catch{}let{data:Ve}=reactPredict.useRealtimeOrderbook({slug:e.slug,source:d},{enabled:e.status==="open"}),ke=react.useMemo(()=>{let O=reactPredict.pickBestAsk(Ve,D);if(O!=null&&O>0)return O;let De=D==="yes"?0:1,Ye=e.outcomes[De];return Ye?.best_ask??Ye?.price??.5},[Ve,e.outcomes,D]),F=react.useCallback(O=>{_(O);},[]),Me=react.useCallback(O=>{V(O),te(NaN);},[]);react.useEffect(()=>{R==="limit"&&isNaN(G)&&te(Math.round(ke*100)/100);},[R,G,ke]);let Pe=react.useMemo(()=>isNaN(N)||N<=0?0:ke>0?N/ke:0,[N,ke]),je=react.useMemo(()=>reactPredict.walkOrderbook({orderbook:Ve,outcome:D,side:"buy",sharesNeeded:Pe,slippageBps:r}),[Ve,D,Pe,r]),xr=react.useMemo(()=>je.status==="ok"&&je.worstPrice!=null&&je.worstPrice>0?je.worstPrice:ke,[je,ke]),br=react.useMemo(()=>isNaN(N)||N<=0?"0":String(Math.round(N*1e6)),[N]),oo=e.provider_meta?.["dflow.yesMint"]??"",Jt=e.provider_meta?.["dflow.noMint"]??"",io=utils.SOLANA_TOKENS.stablecoins.USDC.address,Ir=D==="yes"?oo:Jt,_t=io,mt=Ir,Ge=d==="kalshi"?g??"":h??"",{data:Or,isLoading:so}=reactPredict.usePositions({source:d,user:Ge},{enabled:!!Ge}),ao=d==="kalshi"&&!!_t&&!!mt&&!!g&&br!=="0",{refetch:It}=reactPredict.useDFlowQuote({inputMint:_t,outputMint:mt,amount:br,userPublicKey:g??"",slippageBps:100},{enabled:ao}),Ot=react.useMemo(()=>ze?d==="kalshi"?ze.kalshiUsdcBalance:ze.polymarketUsdcBalance:Or&&Or.positions.reduce((De,Ye)=>Ye.side==="USDC"||Ye.side==="collateral"?De+(Ye.current_value??0):De,0)||null,[ze,Or,d]),lo=ze?ze.isLoading:so,ln=react.useMemo(()=>R==="limit"&&p&&!isNaN(G)?G:ke,[R,p,G,ke]),Dr=react.useMemo(()=>isNaN(N)||N<=0?0:N,[N]),cn=react.useMemo(()=>isNaN(N)||N<=0?0:ln>0?N/ln*1:0,[N,ln]),Zt=cn-Dr,er=react.useCallback(O=>{if(isNaN(O)){X(NaN);return}X(Math.round(Math.max(0,O)*100)/100);},[]),tr=react.useCallback(O=>{if(isNaN(O)){te(NaN);return}let De=Math.max(.01,Math.min(.99,O));te(Math.round(De*100)/100);},[]),Dt=react.useCallback(()=>{X(NaN),te(NaN),_("market"),ut(false),Ce("1h"),pt(30),Re("minutes");},[]),Ar=react.useMemo(()=>{let O=[];return isNaN(N)||N<=0?O.push(o("predict.trade.minAmountUsd",{amount:Sn})):N<Sn&&O.push(o("predict.trade.minAmountUsd",{amount:Sn})),e.status!=="open"&&O.push(o("predict.trade.marketNotActive")),Ot!=null&&!isNaN(N)&&N>0&&N>ye(Ot,2)&&O.push(o("predict.trade.insufficientBalance")),R==="limit"&&p&&(isNaN(G)||G<.01||G>.99)&&O.push(o("predict.trade.limitPriceRange")),R==="limit"&&p&&fe&&He==="custom"&&(isNaN(Ke)||Ke<=0)&&O.push(o("predict.trade.expiration.invalidDate")),d==="polymarket"&&R==="market"&&!isNaN(N)&&N>0&&Pe>0&&(je.status==="insufficient_liquidity"?O.push(o("predict.trade.insufficientLiquidity",{available:ye(je.totalAvailable,2)})):je.status==="exceeds_slippage"&&O.push(o("predict.trade.priceImpactTooHigh",{impact:(je.priceImpactBps/100).toFixed(2),slippage:(r/100).toFixed(2)}))),{isValid:O.length===0,errors:O}},[N,e.status,Ot,R,p,G,fe,He,Ke,d,Pe,je,r,o]),dn=react.useMemo(()=>Ot==null||isNaN(N)||N<=0?false:N>ye(Ot,2),[Ot,N]),Fr=react.useCallback(()=>{n?.(d);},[n,d]),{mutateAsync:tt}=reactPredict.useDFlowSubmit(),{data:yr}=reactPredict.useOrder({id:z??"",source:d},{enabled:!!z});react.useEffect(()=>{if(!yr||!z)return;let{status:O}=yr;O==="closed"?(j(null),y(false),ui.toast.success(o("predict.trade.submitSuccess")),ar(),Dt(),c.invalidateQueries({queryKey:["predict","positions"]})):(O==="failed"||O==="expired")&&(y(false),j(null),ui.toast.error(o("predict.trade.submitError")));},[yr,z,c,Dt,o]);let un=react.useCallback(async()=>{if(!g||!m)return;if(!_t||!mt){ui.toast.error("Missing token mint addresses"),y(false);return}if(!xt){oe(true),y(false);return}let rt=(await It()).data?.transaction;if(!rt){ui.toast.error(o("predict.trade.submitError")),y(false);return}let rr=Uint8Array.from(atob(rt),yt=>yt.charCodeAt(0)),Pt=await m.signTransaction(rr),bt=await tt({signedTransaction:btoa(String.fromCharCode(...Pt)),orderContext:{user_public_key:g,input_mint:_t,output_mint:mt,amount:br,price:String(ke),side:"BUY",outcome:D==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});j(bt.signature);},[g,m,It,tt,_t,mt,br,ke,D,e.slug,o,xt]),pn=react.useCallback(async()=>{if(!u||!l)return;let O=u.chain,De=O!==types.Chain.POLYGON;De&&await u.switchChain(types.Chain.POLYGON);try{let Ye=await u.getEip1193Provider();if(!Ye){ui.toast.error(o("predict.trade.submitError")),y(!1);return}let rt=qe==="deposit"&&!!et,rr=!rt&&!!xe,Pt=rt?et:xe,bt={address:u.address,signatureType:rt?3:rr?2:0,signTypedData:async(_e,At,jt,kr)=>{let Gt=[];"name"in _e&&Gt.push({name:"name",type:"string"}),"version"in _e&&Gt.push({name:"version",type:"string"}),"chainId"in _e&&Gt.push({name:"chainId",type:"uint256"}),"verifyingContract"in _e&&Gt.push({name:"verifyingContract",type:"address"}),"salt"in _e&&Gt.push({name:"salt",type:"bytes32"});let uo={EIP712Domain:Gt,...At};return await Ye.request({method:"eth_signTypedData_v4",params:[u.address,JSON.stringify({domain:_e,types:uo,primaryType:jt,message:kr})]})}},yt=l.credentials??await l.authenticate(bt),nr=D==="yes"?0:1,Br="",or=e.provider_meta?.["polymarket.clobTokenIds"];or&&(Br=(typeof or=="string"?JSON.parse(or):or)[nr]??"");let mn=e.provider_meta?.["polymarket.negRisk"]??!1,C=R==="limit"&&!isNaN(G)?G:xr,be=Pn(C,w),We=R==="limit"?fe?"GTD":"GTC":"FOK",Qe=R==="market"?N:be>0?N/be:0,Ue={tokenId:Br,price:be,size:Qe,side:"BUY",orderType:We,tickSize:w,negRisk:mn,...Pt&&{funderAddress:Pt},...T&&{builderCode:T},...R==="limit"&&fe&&{expiration:wn(He,Ke,vt)}},Xe;if(rt)Xe=await reactPredict.buildSignedV2OrderPayload({signer:bt,depositWalletAddress:Pt,input:Ue,owner:yt.apiKey});else {let _e=reactPredict.buildCtfExchangeDomain(mn),At=reactPredict.buildOrderMessage({...Ue,signerAddress:bt.address,signatureType:bt.signatureType,feeRateBps:P}),jt=await bt.signTypedData(_e,reactPredict.CTF_ORDER_TYPES,"Order",At),kr=reactPredict.buildSignedOrder(At,jt,Ue.orderType);Xe=reactPredict.buildClobPayload(kr,yt.apiKey);}let ft=JSON.stringify(Xe),Ae=await reactPredict.buildPolymarketL2Headers(yt.address,{apiKey:yt.apiKey,secret:yt.secret,passphrase:yt.passphrase,method:"POST",requestPath:"/order",body:ft});await a.createPolymarketOrder(Xe,Ae),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),ar(),Dt(),y(!1);}finally{De&&O&&u.switchChain(O).catch(()=>{});}},[u,l,D,e.provider_meta,R,G,xr,N,a,c,fe,He,Ke,vt,Dt,o,w,P,xe,qe,et,T]),co=react.useCallback(async()=>{if(!(!Ar.isValid||!f)){y(true),j(null),oe(false);try{d==="kalshi"?await un():await pn();}catch(O){let De=O instanceof Error?O.message:"",Ye=d==="polymarket"&&De?Nn(De,o,"buy"):De||void 0;ui.toast.error(Ye||o("predict.trade.submitError")),y(false);}}},[Ar.isValid,f,d,un,pn,o]);return {outcome:D,orderType:R,quantity:N,limitPrice:G,shares:Pe,estimatedCost:Dr,potentialPayout:cn,potentialProfit:Zt,pricePerShare:ke,usdcBalance:Ot,isBalanceLoading:lo,isMarketDataLoading:d==="polymarket"&&(E||S),isSubmitting:b,validation:Ar,isInsufficientBalance:dn,source:d,supportsLimitOrder:p,kycRequired:re,kycUrl:B,expirationEnabled:fe,expirationPreset:He,customDuration:Ke,customDurationUnit:vt,setOutcome:Me,setOrderType:F,setQuantity:er,setLimitPrice:tr,setExpirationEnabled:ut,setExpirationPreset:Ce,setCustomDuration:pt,setCustomDurationUnit:Re,submit:co,notifyInsufficientBalance:Fr}}function Cn({isOpen:e,onClose:t,kycUrl:r}){let{t:n}=i18n.useTranslation();return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:o=>{o||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsxRuntime.jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.trade.kycModalTitle")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxRuntime.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxRuntime.jsxs("div",{className:"px-5 pb-5",children:[jsxRuntime.jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:n("predict.trade.kycModalDescription")}),jsxRuntime.jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(o=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),jsxRuntime.jsx("span",{children:n(o)})]},o))}),r&&jsxRuntime.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[n("predict.trade.goToKYC")," \u2192"]}),jsxRuntime.jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:n("predict.trade.kycModalNote")}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.ok")})]})]})})})}var Gc=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,qc=["5m","1h","12h","24h","eod","custom"],Yc={"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"},Qc=["minutes","hours","days"],Xc={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"},Jc={maximumFractionDigits:0};function Ii({event:e,market:t,variant:r="bordered",outcome:n,orderType:o,quantity:i,limitPrice:s,shares:a,potentialProfit:l,potentialPayout:c,estimatedCost:d,usdcBalance:p,isBalanceLoading:m,isMarketDataLoading:u,isSubmitting:f,isValid:g,validationErrors:h,isInsufficientBalance:v,onInsufficientBalance:k,supportsLimitOrder:S,kycRequired:w,kycUrl:x,expirationEnabled:E,expirationPreset:P,customDuration:L,customDurationUnit:T,onOutcomeChange:D,onOrderTypeChange:V,onQuantityChange:R,onLimitPriceChange:_,onExpirationEnabledChange:N,onExpirationPresetChange:X,onCustomDurationChange:G,onCustomDurationUnitChange:te,onSubmit:b}){let{t:y}=i18n.useTranslation(),[z,j]=react.useState(false),re=ui.useDisclosure(),[oe,fe]=react.useState(""),ut=react.useRef(false);react.useEffect(()=>{ut.current||fe(isNaN(i)?"":String(i));},[i]);let[He,Ce]=react.useState(""),Ke=react.useRef(false);react.useEffect(()=>{Ke.current||(isNaN(s)?Ce(""):Ce(String(parseFloat((s*100).toFixed(2)))));},[s]);let pt=react.useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(Ce(F),F===""||F==="."){_(NaN);return}let Pe=parseFloat(F);isNaN(Pe)||_(Pe/100);},[_]),vt=react.useCallback(F=>{if(F!==""&&!/^\d*\.?\d{0,2}$/.test(F))return;if(fe(F),Ve(false),F===""||F==="."){R(NaN);return}let Pe=parseFloat(F);isNaN(Pe)||R(Pe);},[R]);react.useEffect(()=>{w&&!re.isOpen&&re.onOpen();},[w]);let Re=react.useMemo(()=>{let F=n==="yes"?t.yesAsk:t.noAsk;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,t]),ze=!isNaN(i)&&i>0,xt=react.useMemo(()=>{if(m)return y("predict.trade.loadingBalance");if(u)return y("predict.trade.loadingMarketData");if(f)return y("predict.trade.submitting");if(w)return y("predict.trade.kycRequired");if(!ze)return y("predict.trade.enterAmount");let F=y(n==="yes"?"predict.trade.yes":"predict.trade.no"),Me=l>0?` \u2192 Win $${l.toFixed(2)}`:"";return `${y("predict.trade.buy")} ${F}${Me}`},[m,u,f,w,ze,n,l,y]),B=react.useMemo(()=>n==="yes"?"primary":"secondary",[n]),xe=()=>{R(Math.floor((p??0)/2*100)/100);},qe=()=>{R(ye(p??0,2));},[et,Ve]=react.useState(false),ke=()=>{if(w){re.onOpen();return}if(v&&k){Ve(false),k();return}if(!g){Ve(true);return}Ve(false),b();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 p-4",style:r==="bordered"?{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",transition:"border-color 0.2s"}:void 0,onMouseEnter:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(63,63,70,0.8)");},onMouseLeave:F=>{r==="bordered"&&(F.currentTarget.style.borderColor="rgba(39,39,42,0.6)");},children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:n==="yes"?"text-bullish":"text-bearish",children:[y("predict.trade.buy")," ",y(n==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[S?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:F=>V(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:y("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:y("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.market")}),o==="limit"&&S?jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",inputMode:"decimal",value:He,onChange:F=>pt(F.target.value),onFocus:()=>{Ke.current=true;},onBlur:()=>{Ke.current=false,isNaN(s)?Ce(""):Ce(String(parseFloat((s*100).toFixed(2))));},endContent:jsxRuntime.jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):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 Me=F==="yes"?t.yesAsk:t.noAsk;return jsxRuntime.jsx("div",{className:"flex flex-1 flex-col gap-y-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>D(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${n===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:y(F==="yes"?"predict.trade.yes":"predict.trade.no")}),Me!=null&&jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Me)*100).toFixed(2)),"\xA2"]})]})},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:y("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:Gc,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:p!=null?`${ye(p,2).toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:xe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:qe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",inputMode:"decimal",value:oe,onChange:F=>vt(F.target.value),onFocus:()=>{ut.current=true;},onBlur:()=>{ut.current=false,fe(isNaN(i)?"":String(i));},startContent:jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}),classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}}),et&&h.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:h.map(F=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:F},F))})]}),o==="limit"&&S&&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:y("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:E,onValueChange:N,"aria-label":y("predict.trade.setExpiration")})]}),E&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[P],onSelectionChange:F=>{let Me=Array.from(F)[0];Me&&X(Me);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:qc.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:y(Yc[F])},F))}),P==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(L)?void 0:L,onValueChange:G,minValue:1,step:1,formatOptions:Jc,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:[T],onSelectionChange:F=>{let Me=Array.from(F)[0];Me&&te(Me);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Qc.map(F=>jsxRuntime.jsx(ui.SelectItem,{children:y(Xc[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:()=>j(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:y("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",z&&"rotate-180")})]}),Re!=null&&jsxRuntime.jsx("span",{className:"text-foreground font-medium tabular-nums",children:y("predict.trade.chance",{percent:Re})})]}),z&&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:y("predict.trade.totalSize")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:y("predict.trade.numContracts")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?zr(a):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:y("predict.trade.payout")}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${c.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:y("predict.trade.estProfit")}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&l>0?`+$${l.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:B,fullWidth:true,radius:"lg",size:"lg",isDisabled:m||u||!ze||f,isLoading:f||m||u,spinner:jsxRuntime.jsx(ui.Spinner,{size:"sm",color:"current"}),onPress:ke,children:xt})]}),jsxRuntime.jsx(Cn,{isOpen:re.isOpen,onClose:re.onClose,kycUrl:x})]})}function En({event:e,market:t,variant:r,initialOutcome:n,chain:o,slippageBps:i,onInsufficientBalance:s}){let{outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,pricePerShare:g,usdcBalance:h,isBalanceLoading:v,isMarketDataLoading:k,isSubmitting:S,validation:w,isInsufficientBalance:x,supportsLimitOrder:E,kycRequired:P,kycUrl:L,expirationEnabled:T,expirationPreset:D,customDuration:V,customDurationUnit:R,setOutcome:_,setOrderType:N,setQuantity:X,setLimitPrice:G,setExpirationEnabled:te,setExpirationPreset:b,setCustomDuration:y,setCustomDurationUnit:z,submit:j,notifyInsufficientBalance:re}=Ni({market:t,initialOutcome:n,slippageBps:i,onInsufficientBalance:s}),oe=walletConnector.useAuthCallback(j),fe=react.useMemo(()=>e?vn(e):void 0,[e]),ut=react.useMemo(()=>xn(t,{yesAsk:a==="yes"?g:void 0,noAsk:a==="no"?g:void 0}),[t,a,g]);return jsxRuntime.jsx(Ii,{event:fe,market:ut,variant:r,outcome:a,orderType:l,quantity:c,limitPrice:d,shares:p,estimatedCost:m,potentialPayout:u,potentialProfit:f,usdcBalance:h,isBalanceLoading:v,isMarketDataLoading:k,isSubmitting:S,isValid:w.isValid,validationErrors:w.errors,isInsufficientBalance:x,onInsufficientBalance:s?re:void 0,supportsLimitOrder:E,kycRequired:P,kycUrl:L,expirationEnabled:T,expirationPreset:D,customDuration:V,customDurationUnit:R,onOutcomeChange:_,onOrderTypeChange:N,onQuantityChange:X,onLimitPriceChange:G,onExpirationEnabledChange:te,onExpirationPresetChange:b,onCustomDurationChange:y,onCustomDurationUnitChange:z,onSubmit:oe})}var Wr="predict-trade";function Tn({id:e=Wr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(sd,{...t})})}function sd({params:e,isOpen:t,onOpenChange:r}){let{t:n}=i18n.useTranslation(),{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",hideCloseButton:true,classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsxs("div",{className:o?"":"p-2",children:[jsxRuntime.jsx(En,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,chain:e.chain,slippageBps:e.slippageBps,variant:"flat",onInsufficientBalance:e.onInsufficientBalance}),jsxRuntime.jsx("div",{className:"px-4 pb-4",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(false),className:"w-full h-12 rounded-xl text-sm font-medium text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:n("common.cancel")})})]})})}):null}var Ur={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function ko(e,t=true){let r=0;return t&&e.source&&r++,e.timeRemaining&&r++,e.minVolume&&r++,e.minLiquidity&&r++,r}function Di({isOpen:e,onClose:t,value:r,onChange:n,enableKalshi:o=true}){let{t:i}=i18n.useTranslation(),[s,a]=react.useState(r),l=react.useMemo(()=>o?Ur:{...Ur,source:"polymarket"},[o]),c=react.useCallback(k=>{k?a(r):t();},[r,t]),d=react.useCallback(()=>{a(l);},[l]),p=react.useCallback(()=>{n(s),t();},[s,n,t]),m=react.useCallback((k,S)=>{a(w=>({...w,[k]:S}));},[]),u=react.useMemo(()=>ko(s,o),[s,o]),f=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"polymarket",label:i("predict.platform.polymarket")},{value:"kalshi",label:i("predict.platform.kalshi")}],[i]),g=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1d",label:i("predict.filter.lessThanDay")},{value:"7d",label:i("predict.filter.lessThanWeek")},{value:"30d",label:i("predict.filter.lessThanMonth")}],[i]),h=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]),v=react.useMemo(()=>[{value:void 0,label:i("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[i]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:c,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:i("predict.filter.title")}),jsxRuntime.jsx(pd,{onClick:()=>c(false)})]}),jsxRuntime.jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[o&&jsxRuntime.jsx(Rn,{label:i("predict.filter.platform"),children:jsxRuntime.jsx(_n,{options:f,selected:s.source,onSelect:k=>m("source",k)})}),jsxRuntime.jsx(Rn,{label:i("predict.filter.timeRemaining"),children:jsxRuntime.jsx(_n,{options:g,selected:s.timeRemaining,onSelect:k=>m("timeRemaining",k)})}),jsxRuntime.jsx(Rn,{label:i("predict.filter.minVolume"),children:jsxRuntime.jsx(_n,{options:h,selected:s.minVolume,onSelect:k=>m("minVolume",k)})}),jsxRuntime.jsx(Rn,{label:i("predict.filter.minLiquidity"),children:jsxRuntime.jsx(_n,{options:v,selected:s.minLiquidity,onSelect:k=>m("minLiquidity",k)})})]}),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:d,children:i("predict.filter.reset")}),jsxRuntime.jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:p,children:[i("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{style:{opacity:.7},children:["(",u,")"]})]})]})]})})})}function Rn({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 pd({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 _n({options:e,selected:t,onSelect:r,allowDeselect:n=true}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(o=>{let i=t===o.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i&&n?void 0:o.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:i?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:i?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:i?"#c7ff2e":"#a1a1aa"},onMouseEnter:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.8)",s.currentTarget.style.color="#fff");},onMouseLeave:s=>{i||(s.currentTarget.style.background="rgba(39,39,42,0.4)",s.currentTarget.style.color="#a1a1aa");},children:o.label},o.value??"__all")})})}var zi={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Fi={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},kd=["start_time","volume","liquidity","ending_soon"],Bi={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"},Sd={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 Wi({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:n,onFilterPress:o,filterCount:i=0,className:s}){let{t:a}=i18n.useTranslation(),[l,c]=react.useState(false),d=react.useRef(null),p=react.useCallback(u=>{d.current&&!d.current.contains(u.target)&&c(false);},[]);react.useEffect(()=>(document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p]),react.useEffect(()=>{if(!l)return;let u=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[l]);let m=Hi[e];return jsxRuntime.jsxs("div",{className:s,style:{display:"flex",alignItems:"center",gap:8},children:[jsxRuntime.jsxs("div",{ref:d,style:{position:"relative"},children:[jsxRuntime.jsxs("button",{type:"button",style:Bi,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(u=>!u),children:[jsxRuntime.jsx(wd,{}),jsxRuntime.jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Fi[e])}),jsxRuntime.jsx(Nd,{open:l})]}),l&&jsxRuntime.jsx("div",{style:{...Sd,width:224,padding:4},children:kd.map(u=>{let f=Hi[u],g=e===u;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===u?n(!r):t(u),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:a(Fi[u])}),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"})})]},u)})})]}),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:u=>{u.currentTarget.style.background="rgba(39,39,42,1)",u.currentTarget.style.color="#fff";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)",u.currentTarget.style.color="#a1a1aa";},onClick:()=>n(!r),children:r?"\u2191":"\u2193"}),jsxRuntime.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsxs("button",{type:"button",style:Bi,onMouseEnter:u=>{u.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:u=>{u.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:o,children:[jsxRuntime.jsx(Pd,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),i>0&&jsxRuntime.jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:i})]})]})}var Hi={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function wd(){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 Pd(){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 Nd({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 Ki(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining,e.markets_limit]),{data:r,isLoading:n,isFetching:o,isFetchingNextPage:i,isError:s,error:a,hasNextPage:l,fetchNextPage:c,refetch:d}=reactPredict.useInfiniteEvents(t),p=react.useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=react.useCallback(()=>{c();},[c]),u=react.useCallback(()=>{d();},[d]);return {data:p,isLoading:n,isFetching:o&&!i,isFetchingMore:i,isError:s,error:a??null,hasMore:l??false,fetchMore:m,refetch:u}}var Vi=`
2
2
  @keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
3
3
  @media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}
4
4
  @media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}.evt-skel-card{min-height:200px!important}}