@liberfi.io/ui-predict 0.1.82 → 0.1.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,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'),kt=require('canvas-confetti'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var kt__default=/*#__PURE__*/_interopDefault(kt);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.82");var qn="0.1.82";var Gn={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},er=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],bt=(()=>{let e=t=>{let r=er.indexOf(t);return r===-1?er.length:r};return Object.entries(Gn).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function nr({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:a,trailing:i,pulsingTab:s="Trending",className:l}){let{t:c}=i18n.useTranslation(),d=react.useCallback(()=>{n(null);},[n]),u=c("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",l),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(tr,{label:u,isSelected:t===null,onPress:d,showPulse:u===s}),jsxRuntime.jsx(Jn,{}),e.map(f=>jsxRuntime.jsx(tr,{label:f.category,isSelected:t===f.category,onPress:()=>n(f.category),badge:f.badge,showPulse:f.category===s},f.category))]})}),i&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:i})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(rr,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>a(null)}),o.map(f=>jsxRuntime.jsx(rr,{label:f.label,icon:f.icon,isSelected:r===f.label,onPress:()=>a(f.label)},f.label))]})})]})}function tr({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function Jn(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function rr({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function El({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function eo(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function to(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function ir({onSelect:e,trailing:t,className:r}){let[o,n]=react.useState(null),[a,i]=react.useState(null),s=react.useCallback(f=>{n(f),i(null),e?.({categorySlug:f,tagSlug:null});},[e]),l=react.useCallback(f=>{i(f),e?.({categorySlug:o,tagSlug:f});},[o,e]),c=eo(bt),d=bt.find(f=>f.slug===o),u=to(d);return jsxRuntime.jsx(nr,{categories:c,selectedCategory:o,selectedTag:a,activeTags:u,onCategorySelect:s,onTagSelect:l,trailing:t,className:r})}function ar(e){return {title:e.title,imageUrl:e.image_url}}function lr(e){let t=e.outcomes[0],r=e.outcomes[1];return {yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}var _e=48,yt=4,Xe={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},J={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Qe=J.ALL,Al={[J.ONE_DAY]:Xe.ONE_MINUTE,[J.ONE_WEEK]:Xe.ONE_HOUR,[J.ONE_MONTH]:Xe.ONE_HOUR,[J.ALL]:Xe.ONE_DAY},Dl={[J.ONE_DAY]:300,[J.ONE_WEEK]:3600,[J.ONE_MONTH]:10800,[J.ALL]:1440*60},Hl={[J.ONE_DAY]:1440*60,[J.ONE_WEEK]:10080*60,[J.ONE_MONTH]:720*60*60,[J.ALL]:null},St=1,Fl=1,Bl=1,Ul=99,be={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},$l=be.ONE_WEEK,Wl={[be.ONE_HOUR]:60,[be.SIX_HOURS]:60,[be.ONE_DAY]:300,[be.ONE_WEEK]:1800,[be.MAX]:1800};function mo(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};kt__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{kt__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{kt__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function cr({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:o="buy"}){let{t:n}=i18n.useTranslation(),{status:a}=walletConnector.useAuth(),s=walletConnector.useWallets().find(L=>L.chainNamespace===types.ChainNamespace.SOLANA&&L.isConnected),l=a==="authenticated",c=s?.address,d=e.source,[u,f]=react.useState(r),[p,m]=react.useState(o),[g,x]=react.useState(NaN),[v,_]=react.useState(false),[M,N]=react.useState(null),C=react.useMemo(()=>{let L=u==="yes"?0:1,U=e.outcomes[L];return p==="buy"?U?.best_ask??U?.price??.5:U?.best_bid??U?.price??.5},[e.outcomes,u,p]),B=react.useMemo(()=>isNaN(g)||g<=0?0:p==="buy"?C>0?g/C:0:g,[p,g,C]),Z=react.useMemo(()=>isNaN(g)||g<=0?"0":String(Math.round(g*1e6)),[g]),Re=e.provider_meta?.["dflow.yesMint"]??"",Le=e.provider_meta?.["dflow.noMint"]??"",xe=e.provider_meta?.["dflow.collateralMint"]??"",P=u==="yes"?Re:Le,te=p==="buy"?xe:P,se=p==="buy"?P:xe,Ie=!!te&&!!se&&!!c&&Z!=="0",{refetch:he}=reactPredict.useDFlowQuote({inputMint:te,outputMint:se,amount:Z,userPublicKey:c??"",slippageBps:100},{enabled:Ie}),{data:re,isLoading:y}=reactPredict.usePositions({source:d,user:c??""},{enabled:!!c}),k=react.useMemo(()=>re&&re.positions.reduce((U,ue)=>ue.side==="USDC"||ue.side==="collateral"?U+(ue.current_value??0):U,0)||null,[re]),R=react.useMemo(()=>re?re.positions.find(U=>U.side?.toLowerCase()==="yes"&&U.market?.slug===e.slug)?.size??0:null,[re,e.slug]),W=react.useMemo(()=>re?re.positions.find(U=>U.side?.toLowerCase()==="no"&&U.market?.slug===e.slug)?.size??0:null,[re,e.slug]),K=react.useMemo(()=>{if(isNaN(g)||g<=0)return 0;if(p==="buy")return g;let L=u==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return g*L},[p,u,g,e.outcomes]),X=react.useMemo(()=>isNaN(g)||g<=0?0:p==="buy"?B*1:K,[p,B,K,g]),Oe=X-K,zn=react.useCallback(L=>{m(L),x(NaN);},[]),Kn=react.useCallback(L=>{if(isNaN(L)){x(NaN);return}let U=Math.max(0,L),ue=p==="buy"?Math.round(U*100)/100:Math.round(U);x(ue);},[p]),xt=react.useMemo(()=>{let L=[];(isNaN(g)||g<St)&&L.push(`Minimum quantity is ${St}`),e.status!=="open"&&L.push("Market is not active"),p==="buy"&&k!=null&&!isNaN(g)&&g>0&&g>k&&L.push("Insufficient USDC balance");let U=u==="yes"?R:W;return p==="sell"&&U!=null&&!isNaN(g)&&g>0&&g>U&&L.push("Insufficient shares"),{isValid:L.length===0,errors:L}},[g,e.status,p,k,R,W,u]),{mutateAsync:Zt}=reactPredict.useDFlowSubmit(),{data:ht}=reactPredict.useOrder({id:M??"",source:d},{enabled:!!M});react.useEffect(()=>{if(!ht||!M)return;let{status:L}=ht;L==="closed"?(_(false),N(null),ui.toast.success(n("predict.trade.submitSuccess")),mo(),x(NaN)):(L==="failed"||L==="expired")&&(_(false),N(null),ui.toast.error(n("predict.trade.submitError")));},[ht,M,n]);let Vn=react.useCallback(async()=>{if(!(!xt.isValid||!l||!c||!s)){_(true),N(null);try{let ue=(await he()).data?.transaction;if(!ue){ui.toast.error(n("predict.trade.submitError")),_(!1);return}let Jt=Uint8Array.from(atob(ue),jn=>jn.charCodeAt(0)),Yn=await s.sendTransaction(Jt);await Zt({signedTransaction:btoa(String.fromCharCode(...Jt)),orderContext:{user_public_key:c,input_mint:te,output_mint:se,amount:Z,price:String(C),side:p==="buy"?"BUY":"SELL",outcome:u==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}}),N(Yn);}catch{ui.toast.error(n("predict.trade.submitError")),_(false);}}},[xt.isValid,l,c,s,he,Zt,te,se,Z,C,p,u,e.slug,n]);return {outcome:u,side:p,quantity:g,estimatedCost:K,potentialPayout:X,potentialProfit:Oe,usdcBalance:k,yesTokenBalance:R,noTokenBalance:W,isBalanceLoading:y,isSubmitting:v,validation:xt,setOutcome:f,setSide:zn,setQuantity:Kn,submit:Vn}}var yo=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function pr({event:e,market:t,outcome:r,side:o,quantity:n,potentialProfit:a,estimatedCost:i,usdcBalance:s,yesTokenBalance:l,noTokenBalance:c,isBalanceLoading:d,isSubmitting:u,isValid:f,onOutcomeChange:p,onSideChange:m,onQuantityChange:g,onSubmit:x}){let{t:v}=i18n.useTranslation(),[_,M]=react.useState("market"),[N,C]=react.useState(false),B=react.useMemo(()=>{let P=o==="buy"?r==="yes"?t.yesAsk:t.noAsk:r==="yes"?t.yesBid:t.noBid;return P!=null?Math.round(Number(P)*100):null},[o,r,t]),Z=react.useMemo(()=>{if(u)return v("predict.trade.submitting");if(!n||isNaN(n)||n<=0)return v("predict.trade.enterAmount");let P=v(o==="buy"?"predict.trade.buy":"predict.trade.sell"),te=v(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${P} ${te}`},[u,n,o,r,v]),Re=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]),Le=()=>{g(Math.floor((s??0)/2*100)/100);},xe=()=>{g(s??0);};return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",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:r==="yes"?"text-bullish":"text-bearish",children:[v(o==="buy"?"predict.trade.buy":"predict.trade.sell")," ",v(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:_,onSelectionChange:P=>M(P),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.limit")},"limit")]}),B!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[B," \xA2"]})]}),jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:P=>m(P),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(P=>{let te=P==="yes"?l:c;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>p(P),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===P?P==="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:v(P==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let se=o==="buy"?P==="yes"?t.yesAsk:t.noAsk:P==="yes"?t.yesBid:t.noBid;return se!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(se)*100),"\xA2"]}):null})()]}),o==="sell"&&r===P&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:d?"\u2013":`${te??0} shares`})]},P)})}),o==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{children:v("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:yo,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s!=null?`${s.toFixed(6)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:Le,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:v("predict.trade.half")}),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:v("predict.trade.max")})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:v(o==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(n)?void 0:n,onValueChange:P=>{g(P);},minValue:0,step:o==="buy"?.01:1,formatOptions:o==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:o==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},o),o==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(P=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{g(Math.floor((r==="yes"?l??0:c??0)*P/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[P,"%"]},P)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{g(r==="yes"?l??0:c??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:v("common.all")})]})]}),!isNaN(n)&&n>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:v(o==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(o==="buy"?a:i).toFixed(2)]})]}),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:()=>C(P=>!P),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:v("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",N&&"rotate-180")})]}),B!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[B,"% chance"]})]}),N&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsxs("span",{children:[v("predict.trade.bestBid"),":"," ",Math.round((t.yesBid??0)*100),"\xA2"]}),jsxRuntime.jsxs("span",{children:[v("predict.trade.bestAsk"),":"," ",Math.round((t.yesAsk??0)*100),"\xA2"]})]})]}),jsxRuntime.jsx(ui.Button,{color:Re,fullWidth:true,radius:"lg",size:"lg",isDisabled:!f||u||!n||isNaN(n)||n<=0,isLoading:u,onPress:x,children:Z})]})}function et({event:e,market:t,initialSide:r,initialOutcome:o,chain:n}){let{outcome:a,side:i,quantity:s,estimatedCost:l,potentialPayout:c,potentialProfit:d,usdcBalance:u,yesTokenBalance:f,noTokenBalance:p,isBalanceLoading:m,isSubmitting:g,validation:x,setOutcome:v,setSide:_,setQuantity:M,submit:N}=cr({market:t,initialSide:r,initialOutcome:o,chain:n}),C=walletConnector.useAuthCallback(N),B=react.useMemo(()=>e?ar(e):void 0,[e]),Z=react.useMemo(()=>lr(t),[t]);return jsxRuntime.jsx(pr,{event:B,market:Z,outcome:a,side:i,quantity:s,estimatedCost:l,potentialPayout:c,potentialProfit:d,usdcBalance:u,yesTokenBalance:f,noTokenBalance:p,isBalanceLoading:m,isSubmitting:g,isValid:x.isValid,validationErrors:x.errors,onOutcomeChange:v,onSideChange:_,onQuantityChange:M,onSubmit:C})}var Pt="predict-trade";function fr({id:e=Pt}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(To,{...t})})}function To({params:e,isOpen:t,onOpenChange:r}){let{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:o?"full":"md",backdrop:"blur",radius:"lg",children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(et,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:"buy",chain:e.chain})})})}):null}var Et={sortPreset:"volume",sortAsc:false,source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Ct(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function vr({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[a,i]=react.useState(r),s=react.useCallback(x=>{x?i(r):t();},[r,t]),l=react.useCallback(()=>{i(Et);},[]),c=react.useCallback(()=>{o(a),t();},[a,o,t]),d=react.useCallback((x,v)=>{i(_=>({..._,[x]:v}));},[]),u=react.useMemo(()=>Ct(a),[a]),f=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"dflow",label:n("predict.platform.dflow")}],[n]),p=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),m=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),g=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:s,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(rt,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(nt,{options:f,selected:a.source,onSelect:x=>d("source",x)})}),jsxRuntime.jsx(rt,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(nt,{options:p,selected:a.timeRemaining,onSelect:x=>d("timeRemaining",x)})}),jsxRuntime.jsx(rt,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(nt,{options:m,selected:a.minVolume,onSelect:x=>d("minVolume",x)})}),jsxRuntime.jsx(rt,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(nt,{options:g,selected:a.minLiquidity,onSelect:x=>d("minLiquidity",x)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:l,children:n("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[n("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",u,")"]})]})]})})]})})}function rt({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function nt({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let a=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(a&&o?void 0:n.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",a?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var yr={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},hr={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},qo=["start_time","volume","liquidity","ending_soon"];function Sr({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:a=0,className:i}){let{t:s}=i18n.useTranslation(),[l,c]=react.useState(false),d=react.useRef(null);react.useEffect(()=>{if(!l)return;let f=m=>{d.current&&!d.current.contains(m.target)&&c(false);},p=m=>{m.key==="Escape"&&c(false);};return document.addEventListener("mousedown",f),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",p);}},[l]);let u=br[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",i),children:[jsxRuntime.jsxs("div",{ref:d,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(f=>!f),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(u,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:s(hr[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),l&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:qo.map(f=>{let p=br[f];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(f),c(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",f===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(p,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:s(hr[f])})]},f)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:a>0?a:void 0,color:"primary",size:"sm",isInvisible:a===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:s("predict.filter.title")})]})})]})}var br={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function Nr(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]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:a,isError:i,error:s,hasNextPage:l,fetchNextPage:c,refetch:d}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>r?.pages.flatMap(m=>m.items).filter(m=>m!=null)??[],[r]),f=react.useCallback(()=>{c();},[c]),p=react.useCallback(()=>{d();},[d]);return {data:u,isLoading:o,isFetching:n&&!a,isFetchingMore:a,isError:i,error:s??null,hasMore:l??false,fetchMore:f,refetch:p}}function Tt({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-11/12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-1/2 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-3/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-2/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-24 rounded"})]})]})},r))})}function Ic({count:e=48}){return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Tt,{count:e})})]})}var Pr=3,Rt={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Lr={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},ns={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Fe=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function Er(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function os(e){let t=e.outcomes?.map(i=>i.label?.toLowerCase().trim()??"")??[];if(t.some(i=>i==="up")&&t.some(i=>i==="down"))return [Rt,ns];if(t.some(i=>i==="yes")&&t.some(i=>i==="no"))return [Rt,Lr];let r=t[0]??"",o=t[1]??"",n=Er(r)%Fe.length,a=Er(o)%Fe.length;return a===n&&(a=(a+1)%Fe.length),[Fe[n],Fe[a]]}function ss(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Ir(e){let t=ss(e);return t!=null?Math.round(t*100):0}function Or(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Cr(e){let t=e.outcomes?.[0];return ((t?.best_ask??t?.price??0)*100).toFixed(1)}function Tr(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return Math.round(n*100).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return Math.round((1-o)*100).toString()}function is(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),a=[];return r>0&&a.push(`${r}d`),o>0&&a.push(`${o}h`),a.push(`${n}m`),a.join(" ")}var as=`
1
+ 'use strict';var react=require('react'),ui$1=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'),Ht=require('canvas-confetti'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ht__default=/*#__PURE__*/_interopDefault(Ht);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.84");var Bo="0.1.84";var Fo={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},Nr=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Ot=(()=>{let e=t=>{let r=Nr.indexOf(t);return r===-1?Nr.length:r};return Object.entries(Fo).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Cr({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:a,pulsingTab:i="Trending",className:l}){let{t:d}=i18n.useTranslation(),c=react.useCallback(()=>{n(null);},[n]),u=d("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui$1.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",l),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(Pr,{label:u,isSelected:t===null,onPress:c,showPulse:u===i}),jsxRuntime.jsx(zo,{}),e.map(m=>jsxRuntime.jsx(Pr,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===i},m.category))]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(Er,{label:d("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(m=>jsxRuntime.jsx(Er,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>s(m.label)},m.label))]})})]})}function Pr({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui$1.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function zo(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Er({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui$1.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui$1.cn("iconify size-4",t)}),e]})}function Tc({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function Ko(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function Vo(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Rr({onSelect:e,trailing:t,className:r}){let[o,n]=react.useState(null),[s,a]=react.useState(null),i=react.useCallback(m=>{n(m),a(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=react.useCallback(m=>{a(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),d=Ko(Ot),c=Ot.find(m=>m.slug===o),u=Vo(c);return jsxRuntime.jsx(Cr,{categories:d,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:l,trailing:t,className:r})}function Lr(e){return {title:e.title,imageUrl:e.image_url}}function Or(e){let t=e.outcomes[0],r=e.outcomes[1];return {yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}var Ue=48,It=4,st={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},te={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},at=te.ALL,Hc={[te.ONE_DAY]:st.ONE_MINUTE,[te.ONE_WEEK]:st.ONE_HOUR,[te.ONE_MONTH]:st.ONE_HOUR,[te.ALL]:st.ONE_DAY},Bc={[te.ONE_DAY]:300,[te.ONE_WEEK]:3600,[te.ONE_MONTH]:10800,[te.ALL]:1440*60},Fc={[te.ONE_DAY]:1440*60,[te.ONE_WEEK]:10080*60,[te.ONE_MONTH]:720*60*60,[te.ALL]:null},_t=1,Uc=1,Wc=1,$c=99,Ee={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},zc=Ee.ONE_WEEK,Kc={[Ee.ONE_HOUR]:60,[Ee.SIX_HOURS]:60,[Ee.ONE_DAY]:300,[Ee.ONE_WEEK]:1800,[Ee.MAX]:1800};var Ar=react.createContext(null);function Dt(){let e=react.useContext(Ar);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Xo=3e4;function Qo({pollingInterval:e=Xo,enabled:t=true,children:r}){let o=walletConnector.useWallets(),n=react.useMemo(()=>o.find(f=>f.chainNamespace===types.ChainNamespace.SOLANA&&f.isConnected)?.address,[o]),s=react.useMemo(()=>o.find(f=>f.chainNamespace===types.ChainNamespace.EVM&&f.isConnected)?.address,[o]),{data:a,isLoading:i,error:l}=reactPredict.useBalance({source:"dflow",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:d,isLoading:c,error:u}=reactPredict.useBalance({source:"polymarket",user:s??""},{enabled:t&&!!s,refetchInterval:e}),m=react.useMemo(()=>({solanaAddress:n,evmAddress:s,dflowUsdcBalance:a?Number(a.balance):0,polymarketUsdcBalance:d?Number(d.balance):0,isLoading:i||c,error:l??u??null}),[n,s,a,d,i,c,l,u]);return jsxRuntime.jsx(Ar.Provider,{value:m,children:r})}function Br(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Ht__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Ht__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Ht__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Fr({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=i18n.useTranslation(),{status:n}=walletConnector.useAuth(),s=walletConnector.useWallets(),a=walletConnector.useSwitchChain(),i=reactPredict.usePredictClient(),l=react.useContext(reactPredict.PolymarketContext),d=reactQuery.useQueryClient(),c=e.source,u=c==="polymarket",m=s.find(P=>P.chainNamespace===types.ChainNamespace.SOLANA&&P.isConnected),f=s.find(P=>P.chainNamespace===types.ChainNamespace.EVM&&P.isConnected&&"switchChain"in P),p=n==="authenticated",g=m?.address,v=f?.address,[b,U]=react.useState(t),[E,M]=react.useState(r),[T,G]=react.useState("market"),[C,N]=react.useState(NaN),[z,he]=react.useState(NaN),[ne,K]=react.useState(false),[oe,se]=react.useState(null),[we,Se]=react.useState(false),[w,x]=react.useState(null),R=null;try{let P=Dt();R={dflowUsdcBalance:P.dflowUsdcBalance,polymarketUsdcBalance:P.polymarketUsdcBalance,isLoading:P.isLoading};}catch{}let A=react.useMemo(()=>{let P=b==="yes"?0:1,H=e.outcomes[P];return E==="buy"?H?.best_ask??H?.price??.5:H?.best_bid??H?.price??.5},[e.outcomes,b,E]);react.useMemo(()=>isNaN(C)||C<=0?0:E==="buy"?A>0?C/A:0:C,[E,C,A]);let j=react.useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),Fe=e.provider_meta?.["dflow.yesMint"]??"",yo=e.provider_meta?.["dflow.noMint"]??"",mr=e.provider_meta?.["dflow.collateralMint"]??"",fr=b==="yes"?Fe:yo,et=E==="buy"?mr:fr,tt=E==="buy"?fr:mr,wo=c==="dflow"&&!!et&&!!tt&&!!g&&j!=="0",{refetch:gr}=reactPredict.useDFlowQuote({inputMint:et,outputMint:tt,amount:j,userPublicKey:g??"",slippageBps:100},{enabled:wo}),vr=c==="dflow"?g??"":v??"",{data:me,isLoading:So}=reactPredict.usePositions({source:c,user:vr},{enabled:!!vr}),rt=react.useMemo(()=>R?c==="dflow"?R.dflowUsdcBalance:R.polymarketUsdcBalance:me&&me.positions.reduce((H,fe)=>fe.side==="USDC"||fe.side==="collateral"?H+(fe.current_value??0):H,0)||null,[R,me,c]),ko=R?R.isLoading:So,Pt=react.useMemo(()=>me?me.positions.find(H=>H.side?.toLowerCase()==="yes"&&H.market?.slug===e.slug)?.size??0:null,[me,e.slug]),Et=react.useMemo(()=>me?me.positions.find(H=>H.side?.toLowerCase()==="no"&&H.market?.slug===e.slug)?.size??0:null,[me,e.slug]),Ct=react.useMemo(()=>T==="limit"&&u&&!isNaN(z)?z:A,[T,u,z,A]),nt=react.useMemo(()=>{if(isNaN(C)||C<=0)return 0;if(E==="buy")return C;let P=b==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return C*P},[E,b,C,e.outcomes]),xr=react.useMemo(()=>isNaN(C)||C<=0?0:E==="buy"?Ct>0?C/Ct*1:0:nt,[E,C,Ct,nt]),No=xr-nt,Po=react.useCallback(P=>{M(P),N(NaN);},[]),Eo=react.useCallback(P=>{if(isNaN(P)){N(NaN);return}let H=Math.max(0,P),fe=E==="buy"?Math.round(H*100)/100:Math.round(H);N(fe);},[E]),Co=react.useCallback(P=>{if(isNaN(P)){he(NaN);return}let H=Math.max(.01,Math.min(.99,P));he(Math.round(H*100)/100);},[]),Tt=react.useMemo(()=>{let P=[];(isNaN(C)||C<_t)&&P.push(`Minimum quantity is ${_t}`),e.status!=="open"&&P.push("Market is not active"),E==="buy"&&rt!=null&&!isNaN(C)&&C>0&&C>rt&&P.push("Insufficient USDC balance");let H=b==="yes"?Pt:Et;return E==="sell"&&H!=null&&!isNaN(C)&&C>0&&C>H&&P.push("Insufficient shares"),T==="limit"&&u&&(isNaN(z)||z<.01||z>.99)&&P.push("Limit price must be between $0.01 and $0.99"),{isValid:P.length===0,errors:P}},[C,e.status,E,rt,Pt,Et,b,T,u,z]),{mutateAsync:hr}=reactPredict.useDFlowSubmit(),{data:Mt}=reactPredict.useOrder({id:oe??"",source:c},{enabled:!!oe});react.useEffect(()=>{if(!Mt||!oe)return;let{status:P}=Mt;P==="closed"?(K(false),se(null),ui$1.toast.success(o("predict.trade.submitSuccess")),Br(),N(NaN)):(P==="failed"||P==="expired")&&(K(false),se(null),ui$1.toast.error(o("predict.trade.submitError")));},[Mt,oe,o]);let br=react.useCallback(async()=>{if(!g||!m)return;let P=await i.checkDFlowKYC(g);if(!P.verified){Se(true),x(P.kyc_url||null),K(false);return}let ge=(await gr()).data?.transaction;if(!ge){ui$1.toast.error(o("predict.trade.submitError")),K(false);return}let ce=Uint8Array.from(atob(ge),Lt=>Lt.charCodeAt(0)),Rt=await m.sendTransaction(ce);await hr({signedTransaction:btoa(String.fromCharCode(...ce)),orderContext:{user_public_key:g,input_mint:et,output_mint:tt,amount:j,price:String(A),side:E==="buy"?"BUY":"SELL",outcome:b==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}}),se(Rt);},[g,m,i,gr,hr,et,tt,j,A,E,b,e.slug,o]),yr=react.useCallback(async()=>{if(!f||!l)return;let P=f.chain,H=P!==types.Chain.POLYGON;H&&await a(types.Chain.POLYGON);try{let fe=await f.getEip1193Provider();if(!fe){ui$1.toast.error(o("predict.trade.submitError")),K(!1);return}let ge={address:f.address,signatureType:0,signTypedData:async(Ao,Do,Ho)=>await fe.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Ao,types:Do,message:Ho})]})},ce=l.credentials;if(!ce&&(await l.authenticate(ge),ce=l.credentials,!ce))throw new Error("Polymarket authentication failed");let Rt=b==="yes"?0:1,Lt=e.provider_meta?.[`polymarket.tokenId${Rt}`]??e.provider_meta?.["polymarket.conditionId"]??"",wr=e.provider_meta?.["polymarket.negRisk"]??!1,Mo=T==="limit"&&!isNaN(z)?z:A,Sr={tokenId:Lt,price:Mo,size:C,side:E==="buy"?"BUY":"SELL",orderType:T==="limit"?"GTC":"FOK",tickSize:"0.01",negRisk:wr},Ro=reactPredict.buildCtfExchangeDomain(wr),Lo=reactPredict.buildOrderMessage({...Sr,signerAddress:ge.address,signatureType:ge.signatureType}),Oo=await ge.signTypedData(Ro,reactPredict.CTF_ORDER_TYPES,Lo),kr=reactPredict.buildSignedOrder({...Sr,signerAddress:ge.address,signatureType:ge.signatureType,signature:Oo}),Io=JSON.stringify(kr),_o=await reactPredict.buildPolymarketL2Headers(ce.address,{apiKey:ce.apiKey,secret:ce.secret,passphrase:ce.passphrase,method:"POST",requestPath:"/api/v1/orders/polymarket",body:Io});await i.createPolymarketOrder(kr,_o),d.invalidateQueries({queryKey:["predict","orders"]}),d.invalidateQueries({queryKey:["predict","positions"]}),ui$1.toast.success(o("predict.trade.submitSuccess")),Br(),N(NaN),K(!1);}finally{H&&P&&a(P).catch(()=>{});}},[f,l,a,b,e.provider_meta,T,z,A,C,E,i,d,o]),To=react.useCallback(async()=>{if(!(!Tt.isValid||!p)){K(true),se(null),Se(false);try{c==="dflow"?await br():await yr();}catch{ui$1.toast.error(o("predict.trade.submitError")),K(false);}}},[Tt.isValid,p,c,br,yr,o]);return {outcome:b,side:E,orderType:T,quantity:C,limitPrice:z,estimatedCost:nt,potentialPayout:xr,potentialProfit:No,usdcBalance:rt,yesTokenBalance:Pt,noTokenBalance:Et,isBalanceLoading:ko,isSubmitting:ne,validation:Tt,supportsLimitOrder:u,kycRequired:we,kycUrl:w,setOutcome:U,setSide:Po,setOrderType:G,setQuantity:Eo,setLimitPrice:Co,submit:To}}var Ts=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function $r({event:e,market:t,outcome:r,side:o,orderType:n,quantity:s,limitPrice:a,potentialProfit:i,estimatedCost:l,usdcBalance:d,yesTokenBalance:c,noTokenBalance:u,isBalanceLoading:m,isSubmitting:f,isValid:p,supportsLimitOrder:g,kycRequired:v,kycUrl:b,onOutcomeChange:U,onSideChange:E,onOrderTypeChange:M,onQuantityChange:T,onLimitPriceChange:G,onSubmit:C}){let{t:N}=i18n.useTranslation(),[z,he]=react.useState(false),ne=ui$1.useDisclosure(),K=react.useMemo(()=>{let x=o==="buy"?r==="yes"?t.yesAsk:t.noAsk:r==="yes"?t.yesBid:t.noBid;return x!=null?Math.round(Number(x)*100):null},[o,r,t]),oe=react.useMemo(()=>{if(f)return N("predict.trade.submitting");if(v)return N("predict.trade.kycRequired");if(!s||isNaN(s)||s<=0)return N("predict.trade.enterAmount");let x=N(o==="buy"?"predict.trade.buy":"predict.trade.sell"),R=N(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${x} ${R}`},[f,v,s,o,r,N]),se=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]),we=()=>{T(Math.floor((d??0)/2*100)/100);},Se=()=>{T(d??0);},w=()=>{if(v){ne.onOpen();return}C();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",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:r==="yes"?"text-bullish":"text-bearish",children:[N(o==="buy"?"predict.trade.buy":"predict.trade.sell")," ",N(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[g?jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:n,onSelectionChange:x=>M(x),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:N("predict.trade.market")},"market"),jsxRuntime.jsx(ui$1.Tab,{title:N("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:N("predict.trade.market")}),K!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[K," \xA2"]})]}),jsxRuntime.jsxs(ui$1.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:x=>E(x),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui$1.Tab,{title:N("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui$1.Tab,{title:N("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(x=>{let R=x==="yes"?c:u;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>U(x),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===x?x==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:N(x==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let A=o==="buy"?x==="yes"?t.yesAsk:t.noAsk:x==="yes"?t.yesBid:t.noBid;return A!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(A)*100),"\xA2"]}):null})()]}),o==="sell"&&r===x&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:m?"\u2013":`${R??0} shares`})]},x)})}),g&&n==="limit"&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:N("predict.trade.limitPrice")}),jsxRuntime.jsx(ui$1.StyledNumberInput,{fullWidth:true,placeholder:"0.50",radius:"lg",size:"lg",value:isNaN(a)?void 0:a,onValueChange:x=>G(x),minValue:.01,maxValue:.99,step:.01,formatOptions:{maximumFractionDigits:2},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"}})]}),o==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{children:N("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:Ts,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:d!=null?`${d.toFixed(6)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:we,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:Se,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.max")})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:N(o==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui$1.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(s)?void 0:s,onValueChange:x=>{T(x);},minValue:0,step:o==="buy"?.01:1,formatOptions:o==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:o==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},o),o==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(x=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{T(Math.floor((r==="yes"?c??0:u??0)*x/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[x,"%"]},x)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{T(r==="yes"?c??0:u??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:N("common.all")})]})]}),!isNaN(s)&&s>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:N(o==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(o==="buy"?i:l).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>he(x=>!x),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:N("predict.trade.odds")}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:ui$1.cn("h-3.5 w-3.5 transition-transform",z&&"rotate-180")})]}),K!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[K,"% chance"]})]}),z&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsxs("span",{children:[N("predict.trade.bestBid"),":"," ",Math.round((t.yesBid??0)*100),"\xA2"]}),jsxRuntime.jsxs("span",{children:[N("predict.trade.bestAsk"),":"," ",Math.round((t.yesAsk??0)*100),"\xA2"]})]})]}),jsxRuntime.jsx(ui$1.Button,{color:se,fullWidth:true,radius:"lg",size:"lg",isDisabled:!v&&!p||f||!v&&(!s||isNaN(s)||s<=0),isLoading:f,onPress:w,children:oe})]}),jsxRuntime.jsx(ui$1.Modal,{isOpen:ne.isOpen,onClose:ne.onClose,children:jsxRuntime.jsxs(ui$1.ModalContent,{children:[jsxRuntime.jsx(ui$1.ModalHeader,{className:"flex flex-col gap-1",children:N("predict.trade.kycModalTitle")}),jsxRuntime.jsx(ui$1.ModalBody,{children:jsxRuntime.jsx("p",{className:"text-sm text-default-600",children:N("predict.trade.kycModalDescription")})}),jsxRuntime.jsxs(ui$1.ModalFooter,{children:[jsxRuntime.jsx(ui$1.Button,{variant:"light",onPress:ne.onClose,children:N("common.cancel")}),b&&jsxRuntime.jsx(ui$1.Button,{color:"primary",onPress:()=>{window.open(b,"_blank","noopener,noreferrer"),ne.onClose();},children:N("predict.trade.goToKYC")})]})]})})]})}function lt({event:e,market:t,initialSide:r,initialOutcome:o,chain:n}){let{outcome:s,side:a,orderType:i,quantity:l,limitPrice:d,estimatedCost:c,potentialPayout:u,potentialProfit:m,usdcBalance:f,yesTokenBalance:p,noTokenBalance:g,isBalanceLoading:v,isSubmitting:b,validation:U,supportsLimitOrder:E,kycRequired:M,kycUrl:T,setOutcome:G,setSide:C,setOrderType:N,setQuantity:z,setLimitPrice:he,submit:ne}=Fr({market:t,initialSide:r,initialOutcome:o}),K=walletConnector.useAuthCallback(ne),oe=react.useMemo(()=>e?Lr(e):void 0,[e]),se=react.useMemo(()=>Or(t),[t]);return jsxRuntime.jsx($r,{event:oe,market:se,outcome:s,side:a,orderType:i,quantity:l,limitPrice:d,estimatedCost:c,potentialPayout:u,potentialProfit:m,usdcBalance:f,yesTokenBalance:p,noTokenBalance:g,isBalanceLoading:v,isSubmitting:b,isValid:U.isValid,validationErrors:U.errors,supportsLimitOrder:E,kycRequired:M,kycUrl:T,onOutcomeChange:G,onSideChange:C,onOrderTypeChange:N,onQuantityChange:z,onLimitPriceChange:he,onSubmit:K})}var Ut="predict-trade";function Kr({id:e=Ut}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Hs,{...t})})}function Hs({params:e,isOpen:t,onOpenChange:r}){let{isMobile:o}=ui$1.useScreen();return e?jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:o?"full":"md",backdrop:"blur",radius:"lg",children:jsxRuntime.jsx(ui$1.ModalContent,{children:jsxRuntime.jsx(ui$1.ModalBody,{className:"p-4",children:jsxRuntime.jsx(lt,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:"buy",chain:e.chain})})})}):null}var Wt={sortPreset:"volume",sortAsc:false,source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function $t(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Yr({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[s,a]=react.useState(r),i=react.useCallback(v=>{v?a(r):t();},[r,t]),l=react.useCallback(()=>{a(Wt);},[]),d=react.useCallback(()=>{o(s),t();},[s,o,t]),c=react.useCallback((v,b)=>{a(U=>({...U,[v]:b}));},[]),u=react.useMemo(()=>$t(s),[s]),m=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"dflow",label:n("predict.platform.dflow")}],[n]),f=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),p=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),g=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:e,onOpenChange:i,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui$1.ModalContent,{children:[jsxRuntime.jsx(ui$1.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxRuntime.jsxs(ui$1.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(dt,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(ut,{options:m,selected:s.source,onSelect:v=>c("source",v)})}),jsxRuntime.jsx(dt,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(ut,{options:f,selected:s.timeRemaining,onSelect:v=>c("timeRemaining",v)})}),jsxRuntime.jsx(dt,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(ut,{options:p,selected:s.minVolume,onSelect:v=>c("minVolume",v)})}),jsxRuntime.jsx(dt,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(ut,{options:g,selected:s.minLiquidity,onSelect:v=>c("minLiquidity",v)})})]}),jsxRuntime.jsx(ui$1.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui$1.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui$1.RefreshIcon,{width:16,height:16}),onPress:l,children:n("predict.filter.reset")}),jsxRuntime.jsxs(ui$1.Button,{color:"primary",size:"sm",radius:"full",onPress:d,children:[n("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",u,")"]})]})]})})]})})}function dt({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function ut({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let s=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},className:ui$1.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",s?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var Xr={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Gr={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},na=["start_time","volume","liquidity","ending_soon"];function Qr({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:a}){let{t:i}=i18n.useTranslation(),[l,d]=react.useState(false),c=react.useRef(null);react.useEffect(()=>{if(!l)return;let m=p=>{c.current&&!c.current.contains(p.target)&&d(false);},f=p=>{p.key==="Escape"&&d(false);};return document.addEventListener("mousedown",m),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",f);}},[l]);let u=jr[e];return jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center gap-2",a),children:[jsxRuntime.jsxs("div",{ref:c,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>d(m=>!m),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(u,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i(Gr[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),l&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:na.map(m=>{let f=jr[m];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(m),d(false);},className:ui$1.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",m===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:i(Gr[m])})]},m)})})]}),jsxRuntime.jsx(ui$1.StyledBadge,{content:s>0?s:void 0,color:"primary",size:"sm",isInvisible:s===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui$1.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i("predict.filter.title")})]})})]})}var jr={start_time:ui$1.CalendarIcon,volume:ui$1.ChartLineIcon,liquidity:ui$1.DropletIcon,ending_soon:ui$1.TimerIcon};function en(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]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:s,isError:a,error:i,hasNextPage:l,fetchNextPage:d,refetch:c}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>r?.pages.flatMap(p=>p.items).filter(p=>p!=null)??[],[r]),m=react.useCallback(()=>{d();},[d]),f=react.useCallback(()=>{c();},[c]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:a,error:i??null,hasMore:l??false,fetchMore:m,refetch:f}}function zt({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-11/12 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-1/2 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-3/5 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-2/5 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-20 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3 w-24 rounded"})]})]})},r))})}function $d({count:e=48}){return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-20 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-6 w-20 rounded"})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-28 rounded-full"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(zt,{count:e})})]})}var tn=3,Vt={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ln={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},pa={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},ze=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function rn(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function ma(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [Vt,pa];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [Vt,ln];let r=t[0]??"",o=t[1]??"",n=rn(r)%ze.length,s=rn(o)%ze.length;return s===n&&(s=(s+1)%ze.length),[ze[n],ze[s]]}function fa(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function cn(e){let t=fa(e);return t!=null?Math.round(t*100):0}function dn(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function nn(e){let t=e.outcomes?.[0];return ((t?.best_ask??t?.price??0)*100).toFixed(1)}function on(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return Math.round(n*100).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return Math.round((1-o)*100).toString()}function ga(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),s=[];return r>0&&s.push(`${r}d`),o>0&&s.push(`${o}h`),s.push(`${n}m`),s.join(" ")}var va=`
2
2
  .badge-shine { position: relative; overflow: hidden; }
3
3
  .badge-shine::after {
4
4
  content: "";
@@ -16,7 +16,7 @@
16
16
  60% { transform: translate(200%); }
17
17
  100% { transform: translate(200%); }
18
18
  }
19
- `;function _r({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:a}){let[i,s]=react.useState(null),l=e.markets??[],c=react.useMemo(()=>l.length>2?[...l].sort((N,C)=>(C.outcomes?.[0]?.price??0)-(N.outcomes?.[0]?.price??0)):l,[l]),d=c.filter(N=>N.status==="open"),u=c.length===1,f=d.slice(0,Pr),p=d.length-Pr,m=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=i?d.find(N=>N.slug===i)??null:null,x=!!g||u,v=()=>{x||o?.(e);},_=N=>{N.stopPropagation(),g&&(N.preventDefault(),s(null));},M=N=>{N.stopPropagation(),t||(N.preventDefault(),o?.(e));};return jsxRuntime.jsxs("div",{className:ui.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!x&&"cursor-pointer"),onMouseEnter:()=>a?.(e),onClick:v,children:[jsxRuntime.jsx("style",{children:as}),jsxRuntime.jsx(ls,{event:e,href:t,LinkComponent:r,onClick:_,isExpanded:x}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:u?jsxRuntime.jsx(vs,{market:d[0],event:e,formattedVolume:m,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n}):g?jsxRuntime.jsx(xs,{market:g,event:e,onCollapse:()=>s(null),onSelectOutcome:n}):jsxRuntime.jsx(fs,{displayedMarkets:f,moreCount:p,formattedVolume:m,source:e.source,href:t,LinkComponent:r,onMarketClick:N=>s(N.slug),onShowMore:M})})]})}function ls({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let a=e.start_at?is(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),a&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",a]})]}),jsxRuntime.jsx(ds,{event:e})]})}function cs(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),a=300*1e3,i=900*1e3;if(n>0&&n<=i){let s=n<=a?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=a?"5m":"15m",color:s});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function ds({event:e}){let t=react.useMemo(()=>cs(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsxRuntime.jsx(us,{},o);case "crypto-short":return jsxRuntime.jsx(ps,{label:r.label,color:r.color},o);case "closed":return jsxRuntime.jsx(ms,{},o)}})})}function us(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function ps({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function ms(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function fs({displayedMarkets:e,moreCount:t,formattedVolume:r,source:o,href:n,LinkComponent:a,onMarketClick:i,onShowMore:s}){let{t:l}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(c=>{let d=Ir(c);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:u=>{u.stopPropagation(),i(c);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:c.outcomes?.[0]?.label??c.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Or(d)}),jsxRuntime.jsx(gs,{})]})]},c.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui.Linkable,{href:n,LinkComponent:a,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s,children:[l("predict.event.showMore"),jsxRuntime.jsx(Dr,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",l("predict.event.volume"),jsxRuntime.jsx(Hr,{source:o})]})]})]})}function Mr({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:s=>{let l=s.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function Ar({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:a}=i18n.useTranslation(),[i,s]=o?os(e):[Rt,Lr],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=n==="label"&&l===c?"action":n,u=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${Cr(e)}\xA2`:a("predict.market.action.yes",{price:Cr(e)}),f=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${Tr(e)}\xA2`:a("predict.market.action.no",{price:Tr(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Mr,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:p=>{p.stopPropagation(),r?.(t,e,"yes");},children:u}),jsxRuntime.jsx(Mr,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:p=>{p.stopPropagation(),r?.(t,e,"no");},children:f})]})}function gs(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function vs({market:e,event:t,formattedVolume:r,href:o,LinkComponent:n,onSelect:a,onSelectOutcome:i}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(Ar,{market:e,event:t,onSelectOutcome:i,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui.Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:c=>{c.stopPropagation(),o||(c.preventDefault(),a?.(t));},children:[s("predict.event.viewEvent"),jsxRuntime.jsx(Dr,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",s("predict.event.volume"),jsxRuntime.jsx(Hr,{source:t.source})]})]})]})}function xs({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let{t:n}=i18n.useTranslation(),a=Ir(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:i=>{i.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Or(a)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(Ar,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i=>{i.stopPropagation(),r();},children:[jsxRuntime.jsx(hs,{className:"h-3 w-3"}),n("predict.event.back")]})]})}function Dr({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function hs({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Hr({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Ns=768,Br=1024,Ps=1280,Es=8,Cs=224,Ts=304,Ms=114;function Rs(e){return e>=Ps?4:e>=Br?3:e>=Ns?2:1}function Ls(e){return e>=Br?Ts:Cs}function Ur({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:a,LinkComponent:i,onHover:s}){let l=react.useRef(null),c=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:l}),f=Rs(d),p=Ls(d),m=Math.ceil(e.length/f)||0,g=!t&&e.length>0,x=m+(t?1:0)+(g?1:0),v=react.useCallback(C=>C<m,[m]),_=react.useCallback(async()=>{r?.();},[r]),M=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:v,loadMoreRows:_,rowCount:x,threshold:3}),N=react.useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:l,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{listRef:c,className:"no-scrollbar",style:{height:u},onRowsRendered:M,rowComponent:Is,rowCount:x,rowHeight:C=>g&&C===x-1?Ms:(p),rowProps:{events:e,columnCount:f,dataRowCount:m,showEndOfList:g,totalRowCount:x,onSelect:o,onSelectOutcome:n,getEventHref:a,LinkComponent:i,onHover:s,onScrollToTop:N}})})}function Is({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:a,totalRowCount:i,onSelect:s,onSelectOutcome:l,getEventHref:c,LinkComponent:d,onHover:u,onScrollToTop:f}){if(a&&e===i-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(Os,{onScrollToTop:f})});if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let p=e*o,m=r.slice(p,p+o),g=o-m.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[m.map(x=>x==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:Es},children:jsxRuntime.jsx(_r,{event:x,href:c?.(x),LinkComponent:d,onSelect:s,onSelectOutcome:l,onHover:u})},x.slug)),g>0&&Array.from({length:g}).map((x,v)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${v}`))]})})}function Os({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function Wr({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:a,with_markets:i,onSelect:s,onSelectOutcome:l,getEventHref:c,LinkComponent:d,onHover:u}){let{data:f,hasMore:p,fetchMore:m,isFetching:g}=Nr({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:a,with_markets:i});return g?jsxRuntime.jsx(Tt,{count:48}):jsxRuntime.jsx(Ur,{events:f,hasMore:p,onFetchMore:m,onSelect:s,onSelectOutcome:l,getEventHref:c,LinkComponent:d,onHover:u})}function cd({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[a,i]=react.useState({categorySlug:null,tagSlug:null}),[s,l]=react.useState(Et),{isOpen:c,onOpen:d,onClose:u}=ui.useDisclosure(),{onOpen:f}=uiScaffold.useAsyncModal(Pt),p=react.useCallback((C,B,Z)=>{t?.(C,B,Z),f({params:{event:C,market:B,initialOutcome:Z}});},[t,f]),m=react.useCallback(C=>{i(C);},[]),g=react.useCallback(C=>{l(B=>({...B,sortPreset:C}));},[]),x=react.useCallback(C=>{l(B=>({...B,sortAsc:C}));},[]),v=react.useCallback(C=>{l(C);},[]),_=react.useMemo(()=>yr[s.sortPreset].sort_by,[s.sortPreset]),M=react.useMemo(()=>Ct(s),[s]),N=jsxRuntime.jsx(Sr,{sortPreset:s.sortPreset,onSortChange:g,sortAsc:s.sortAsc,onSortAscChange:x,onFilterPress:d,filterCount:M});return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(ir,{onSelect:m,trailing:N}),jsxRuntime.jsx(vr,{isOpen:c,onClose:u,value:s,onChange:v}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Wr,{tagSlugSelection:a,sort_by:_,sort_asc:s.sortAsc,source:s.source,onSelect:e,onSelectOutcome:p,getEventHref:r,LinkComponent:o,onHover:n})}),jsxRuntime.jsx(fr,{})]})}var Dt=40,at=36,We=480,Ht=We-at;function jr({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=i18n.useTranslation(),[n,a]=react.useState("positions"),i=react.useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:s}=reactPredict.usePositions({source:e.source,user:t??""}),l=react.useMemo(()=>!s?.positions||!t?0:i.length===0?s.positions.length:s.positions.filter(u=>u.market&&i.includes(u.market.slug)).length,[s?.positions,i,t]),d=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>a(u.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===u.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:u.label},u.key))}),t?jsxRuntime.jsxs("div",{style:{height:We},children:[n==="positions"&&jsxRuntime.jsx(Ws,{source:e.source,walletAddress:t,marketSlugs:i}),n==="orders"&&jsxRuntime.jsx(Ks,{source:e.source,walletAddress:t,marketSlugs:i,onCancelOrder:r}),n==="trades"&&jsxRuntime.jsx(js,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:We},children:o("predict.trade.connectWallet")})]})}function Ws({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=i18n.useTranslation(),{data:n,isLoading:a}=reactPredict.usePositions({source:e,user:t}),i=react.useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(s=>s.market&&r.includes(s.market.slug)):[],[n?.positions,r]);return a?jsxRuntime.jsx(Bt,{}):i.length===0?jsxRuntime.jsx(Ft,{message:o("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:at},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:Ht},rowComponent:zs,rowCount:i.length,rowHeight:Dt,rowProps:{positions:i,closeLabel:o("predict.positions.close")}})]})}function zs({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let a=n.pnl??0,i=n.pnl_percent??0,s=n.avg_price??0,l=n.current_price??0,c=a>0?"text-success":a<0?"text-danger":"text-foreground",d=a>0?"+":"",u=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",f=n.side,p=n.size,m=n.size*l,g=n.market?.end_at?Xs(n.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:u}),jsxRuntime.jsx("span",{className:ui.cn("text-[10px] font-medium",f.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:f})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",m.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:st(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:st(l)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[d,"$",Math.abs(a).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,i.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Ks({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=i18n.useTranslation(),{data:a,isLoading:i,fetchNextPage:s,hasNextPage:l}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),c=reactPredict.useCancelOrder(),d=react.useMemo(()=>{let v=a?.pages?.flatMap(N=>N.items)??[],_=new Set(["live","open","submitted","pending"]),M=v.filter(N=>_.has(N.status));return r.length>0&&(M=M.filter(N=>N.market_id&&r.includes(N.market_id))),M},[a?.pages,r]),u=react.useCallback(v=>{o?o(v.id):c.mutate({source:v.source,id:v.id});},[o,c]),f=d.length,p=f+(l?1:0),m=react.useCallback(v=>v<f,[f]),g=react.useCallback(async()=>{await s();},[s]),x=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:p,threshold:5});return i?jsxRuntime.jsx(Bt,{}):d.length===0&&!l?jsxRuntime.jsx(Ft,{message:n("predict.openOrders.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:at},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:Ht},onRowsRendered:x,rowComponent:Vs,rowCount:p,rowHeight:Dt,rowProps:{orders:d,itemCount:f,onCancel:u,isCancelling:c.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function Vs({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:a,cancelLabel:i}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let s=r[e];if(!s)return null;let l=s.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:s.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:s.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:s.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s.price?st(parseFloat(s.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[s.size_matched??"0","/",s.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(Ys,{status:s.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>n(s),disabled:a,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:a?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):i})})]})}function Ys({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function js({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:o,isLoading:n,fetchNextPage:a,hasNextPage:i}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),s=react.useMemo(()=>o?.pages?.flatMap(p=>p.items)??[],[o?.pages]),l=s.length,c=l+(i?1:0),d=react.useCallback(p=>p<l,[l]),u=react.useCallback(async()=>{await a();},[a]),f=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:u,rowCount:c,threshold:5});return n?jsxRuntime.jsx(Bt,{}):s.length===0&&!i?jsxRuntime.jsx(Ft,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:at},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:Ht},onRowsRendered:f,rowComponent:qs,rowCount:c,rowHeight:Dt,rowProps:{trades:s,itemCount:l}})]})}function qs({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let a=n.side?.toUpperCase()==="BUY",i=Gs(n.timestamp),s=n.price??0,l=n.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",a?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:st(s)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:i})]})}function Ft({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:We},children:e})}function Bt(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:We},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function st(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Gs(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${a}`}function Xs(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function ze({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsxRuntime.jsx("div",{className:"h-5"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-10 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-48 rounded"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-24 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center py-2",children:[jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-14 rounded"}),jsxRuntime.jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((r,o)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-10 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-full rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function qr(){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-24 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"})]})}var Qr="var(--color-bullish)",Zr="var(--color-bearish)";function Ke(e){if(Math.abs(e)>=1e4){let t=e/1e4;return `${parseFloat(t.toFixed(2))}\u4E07`}return e.toLocaleString()}function Js(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function ei(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let p of e){let m=Math.round(p.price*100);m>=0&&m<=100&&(r[m]+=p.quantity);}for(let p of t){let m=Math.round(p.price*100);m>=0&&m<=100&&(o[m]+=p.quantity);}let n=0,a=0,i=new Float64Array(101),s=new Float64Array(101);for(let p=100;p>=0;p--)n+=r[p],a+=r[p]*p/100,i[p]=n,s[p]=a;let l=0,c=0,d=new Float64Array(101),u=new Float64Array(101);for(let p=0;p<=100;p++)l+=o[p],c+=o[p]*p/100,d[p]=l,u[p]=c;let f=Math.max(i[0]??0,d[100]??0);return Array.from({length:101},(p,m)=>{let g=i[m]>0,x=d[m]>0,v=i[m]||d[m],_=r[m]>0||o[m]>0;return {priceCents:m,displayHeight:Js(v,f),opacity:v>0?_?1:.5:0,isBid:g,isAsk:x,bidCumTotal:i[m],askCumTotal:d[m],bidCumCost:s[m],askCumCost:u[m]}})}function ti({info:e}){let t=e.isBid?Qr:Zr,r=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:r,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsxs("div",{style:{marginBottom:4,fontWeight:600},children:[e.priceCents,"\xA2"]}),jsxRuntime.jsxs("div",{style:{color:t},children:[Ke(Math.round(e.cumTotal))," contracts"]}),jsxRuntime.jsxs("div",{style:{color:t},children:["$",Ke(Math.round(e.cumCost))]})]})}var ri=react.memo(function({slot:t,onEnter:r,onLeave:o}){let n=react.useRef(null),a=t.isBid||t.isAsk,i=t.isBid?Qr:t.isAsk?Zr:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:a?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:a&&jsxRuntime.jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:i,opacity:t.opacity}})})}),ni=[0,10,20,30,40,50,60,70,80,90,100];function oi(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:ni.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Jr({bids:e,asks:t}){let r=react.useMemo(()=>ei(e,t),[e,t]),o=react.useMemo(()=>{let d=e.length>0?Math.max(...e.map(f=>f.price)):0,u=t.length>0?Math.min(...t.map(f=>f.price)):1;return Math.round((d+u)/2*100)},[e,t]),n=react.useMemo(()=>r.some(d=>d.isBid||d.isAsk),[r]),[a,i]=react.useState(null),s=react.useRef(null),l=react.useCallback((d,u)=>{s.current&&(s.current.style.filter=""),u?(u.style.filter="brightness(1.5)",s.current=u):s.current=null,d.isBid||d.isAsk?i({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):i(null);},[]),c=react.useCallback(()=>{s.current&&(s.current.style.filter="",s.current=null),i(null);},[]);return n?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),a&&jsxRuntime.jsx(ti,{info:a}),r.map(d=>jsxRuntime.jsx(ri,{slot:d,onEnter:l,onLeave:c},d.priceCents))]}),jsxRuntime.jsx(oi,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No depth data"})}function en(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function tn(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})]})}function sn({market:e,outcome:t="yes",onTradeAction:r}){let{t:o}=i18n.useTranslation(),[n,a]=react.useState("depth"),i=t==="no",s=e.source,{data:l,isLoading:c}=reactPredict.useOrderbook({slug:e.slug,source:s}),d=react.useMemo(()=>((i?l?.asks:l?.bids)??[]).map(x=>({price:i?1-x.price:x.price,quantity:x.size})),[l?.bids,l?.asks,i]),u=react.useMemo(()=>((i?l?.bids:l?.asks)??[]).map(x=>({price:i?1-x.price:x.price,quantity:x.size})),[l?.bids,l?.asks,i]),f=react.useMemo(()=>d.length>0?Math.max(...d.map(g=>g.price)):null,[d]),p=react.useMemo(()=>u.length>0?Math.min(...u.map(g=>g.price)):null,[u]),m=react.useMemo(()=>{if(f==null||p==null)return null;let g=(p-f)*100;return Math.round(g*10)/10},[f,p]);return jsxRuntime.jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxRuntime.jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:m!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(m)?`${m}\xA2`:`${m.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[f!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",en(f)]}),f!=null&&p!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),p!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",en(p)]})]}),jsxRuntime.jsx("div",{className:"flex flex-1 justify-end",children:jsxRuntime.jsx("button",{type:"button",title:n==="depth"?"Orderbook":"Depth chart",onClick:()=>a(g=>g==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:n==="depth"?jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"}):jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[n==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:c?jsxRuntime.jsx(tn,{}):jsxRuntime.jsx(Jr,{bids:d,asks:u})}),n==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:c?jsxRuntime.jsx(tn,{}):jsxRuntime.jsx(di,{bids:d,asks:u,bestBid:f??void 0,bestAsk:p??void 0,spread:m??void 0})})]})]})}var rn=8;function di({bids:e,asks:t,spread:r}){let{t:o}=i18n.useTranslation(),n=react.useMemo(()=>[...t].sort((l,c)=>c.price-l.price).slice(0,rn),[t]),a=react.useMemo(()=>[...e].sort((l,c)=>c.price-l.price).slice(0,rn),[e]),i=react.useMemo(()=>{let l=[...n,...a].map(c=>c.quantity);return Math.max(...l,1)},[n,a]);return n.length===0&&a.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(l=>jsxRuntime.jsx(nn,{price:l.price,quantity:l.quantity,side:"ask",maxQty:i},`ask-${l.price}`)),jsxRuntime.jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),a.map(l=>jsxRuntime.jsx(nn,{price:l.price,quantity:l.quantity,side:"bid",maxQty:i},`bid-${l.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function nn({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",a=Math.min(t/o*100,100),i=n?"bg-bullish/10":"bg-bearish/10",s=n?"text-bullish":"text-bearish",l=Math.round(e*100),c=Ke(Math.round(t)),d=Math.round(t*e),u=`$${Ke(d)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${i} transition-[width] duration-200`,style:{width:`${a}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 ${s}`,children:[l,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-center",children:c}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var zt=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},ct=4,an=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function wi(e,t){let r=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function ki(e,t){let r=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===reactPredict.ChartRange.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function cn(e){return `${(e*100).toFixed(2)}%`}var Ni=[{range:reactPredict.ChartRange.ONE_DAY,label:"1D"},{range:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{range:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{range:reactPredict.ChartRange.ALL,label:"ALL"}];function Pi({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Ni.map(({range:r,label:o})=>{let n=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function Ei(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(n=>{let a=e.current,i=t.current;if(!a||!i)return;let s=a.getBoundingClientRect(),l=(n.clientX-s.left)/s.width*100;i.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,i.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function Ci({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:a}){if(!e||!n?.length)return null;let i=new Map;t?.forEach(l=>i.set(l.dataKey,l));let s=n.map(l=>i.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?ki(r,a):r}),s.map(l=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?cn(l.value):"--"})]},l.dataKey))]})}function Ti({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,a]=react.useState(false),i=react.useRef(null);react.useEffect(()=>{if(!n)return;function c(d){i.current&&!i.current.contains(d.target)&&a(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);let s=t.length>=ct,l=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(d=>d.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:i,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>a(c=>!c),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",ct," markets"]}),e.map(c=>{let d=t.includes(c.slug),u=!d&&s,f=d&&t.length===1,p=r.get(c.slug)??"#6b7280",m=c.outcomes.find(x=>x.label.toLowerCase()==="yes")??c.outcomes[0],g=m?.price!=null?`${Math.round(m.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{f||u||o(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:u||f?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:x=>{!u&&!f&&(x.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:x=>{x.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${p}`:"2px solid rgba(255,255,255,0.2)",background:d?`${p}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:p,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),g&&jsxRuntime.jsx("span",{style:{color:p,fontWeight:700,fontSize:12,flexShrink:0},children:g})]},c.slug)})]})]})}function Mi({series:e,colorMap:t,displayValues:r}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",a=r.get(o.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:a!=null?cn(a):"--"})]})]},o.marketSlug)})})}function Ri(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function Li(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let a=Math.floor(n*o),i=Math.min(Math.floor((n+1)*o),e.length),s=e.slice(a,i),l=s.map(c=>c.price).sort((c,d)=>c-d);r.push({timestamp:s[s.length-1].timestamp,price:Ri(l)});}return r}function Ii(e,t=200){if(e.length===0)return [];let r=e.map(s=>({...s,data:Li(s.data,t)})),o=new Set;r.forEach(s=>s.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((s,l)=>s-l),a=r.map(s=>{let l=new Map;return s.data.forEach(c=>l.set(c.timestamp,c.price)),{slug:s.marketSlug,map:l}}),i=new Map;return n.map(s=>{let l={timestamp:s};return a.forEach(({slug:c,map:d})=>{let u=d.get(s);if(u!==void 0)i.set(c,u),l[c]=u;else {let f=i.get(c);f!==void 0&&(l[c]=f);}}),l})}function dn(e){return jsxRuntime.jsx(zt,{children:jsxRuntime.jsx(Oi,{...e})})}function Oi({event:e,isLoading:t,className:r,volume:o}){let n=react.useMemo(()=>(e.markets??[]).filter(y=>y.status==="open"),[e.markets]),a=react.useMemo(()=>[...n].sort((y,k)=>{let R=W=>(W.outcomes.find(K=>K.label.toLowerCase()==="yes")??W.outcomes[0])?.price??0;return R(k)-R(y)}),[n]),[i,s]=react.useState(()=>a.slice(0,ct).map(y=>y.slug)),[l,c]=react.useState(Qe),d=react.useMemo(()=>{let y=new Map;return i.forEach((k,R)=>{y.set(k,an[R%an.length]);}),y},[i]),u=react.useMemo(()=>n.filter(y=>i.includes(y.slug)),[n,i]),{series:f,isLoading:p}=reactPredict.useMarketHistory(u,l),m=t||p,g=react.useMemo(()=>{if(f.length>0&&f.some(R=>R.data.length>0))return f;let y=Date.now(),k=864e5;return u.map(R=>{let K=(R.outcomes?.find(X=>X.label.toLowerCase()==="yes")??R.outcomes?.[0])?.price??.5;return {marketSlug:R.slug,label:R.outcomes?.[0]?.label??R.question,data:[{timestamp:y-7*k,price:K},{timestamp:y,price:K}]}})},[f,u]),x=react.useMemo(()=>l===reactPredict.ChartRange.ONE_DAY?96:l===reactPredict.ChartRange.ONE_WEEK?168:l===reactPredict.ChartRange.ONE_MONTH?180:300,[l]),v=react.useMemo(()=>Ii(g,x),[g,x]),_=react.useMemo(()=>{if(v.length===0)return [0,1];let y=1/0,k=-1/0;if(i.forEach(W=>{v.forEach(K=>{let X=K[W];X!=null&&(X<y&&(y=X),X>k&&(k=X));});}),!isFinite(y))return [0,1];let R=Math.max((k-y)*.15,.05);return [Math.max(0,y-R),Math.min(1,k+R)]},[v,i]),M=react.useMemo(()=>{let y=new Map;return g.forEach(k=>{k.data.length>0&&y.set(k.marketSlug,k.data[k.data.length-1].price);}),y},[g]),N=react.useMemo(()=>{let y=new Map;return g.forEach(k=>y.set(k.marketSlug,k.label)),y},[g]),C=react.useMemo(()=>g.map(y=>({slug:y.marketSlug,color:d.get(y.marketSlug)??"#6b7280"})),[g,d]),{wrapperRef:B,overlayRef:Z,onMouseMove:Re,onMouseLeave:Le}=Ei(),xe=react.useCallback(y=>{s(k=>k.includes(y)?k.length<=1?k:k.filter(R=>R!==y):k.length>=ct?k:[...k,y]);},[]),[P,te]=react.useState(null),se=react.useRef(null),Ie=react.useRef(""),he=react.useRef(0),re=!m&&v.length>0;return jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsx(Mi,{series:g,colorMap:d,displayValues:P??M}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsx("div",{ref:B,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:re?y=>{Re(y),cancelAnimationFrame(he.current),he.current=requestAnimationFrame(()=>{te(se.current);});}:void 0,onMouseLeave:re?()=>{Le(),cancelAnimationFrame(he.current),Ie.current="",se.current=null,te(null);}:void 0,children:m?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):v.length===0?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:Z,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:v,margin:{top:8,right:16,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:y=>wi(y,l),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:_,tickFormatter:y=>`${Math.round(y*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:y=>{let k=y;if(k.active&&k.payload?.length){let R=k.payload.map(W=>`${W.dataKey}:${W.value}`).join(",");if(R!==Ie.current){Ie.current=R;let W=new Map;k.payload.forEach(K=>{K.value!=null&&W.set(K.dataKey,K.value);}),se.current=W;}}return jsxRuntime.jsx(Ci,{...k,labelMap:N,allSeries:C,range:l})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(y=>{let k=d.get(y.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:y.marketSlug,stroke:k,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:k},connectNulls:true,isAnimationActive:false},y.marketSlug)}),P==null&&v.length>0&&g.map(y=>{let k=v[v.length-1],R=k[y.marketSlug];if(R==null)return null;let W=d.get(y.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:k.timestamp,y:R,ifOverflow:"extendDomain",shape:K=>{let{cx:X,cy:Oe}=K;return X==null||Oe==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:X,cy:Oe,r:6,fill:W,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:X,cy:Oe,r:3.5,fill:W})]})}},`pulse-${y.marketSlug}`)})]})})]})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(o).toLocaleString()," vol"]}),jsxRuntime.jsx("div",{style:{flex:1}}),a.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ti,{markets:a,selectedSlugs:i,colorMap:d,onToggle:xe}),jsxRuntime.jsx("span",{style:{width:1,height:14,background:"#374151",flexShrink:0}})]}),jsxRuntime.jsx(Pi,{value:l,onChange:c})]})]})]})}function Ye(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Vi(e){return `${Math.round(e*100)}%`}function un(e){let t=e*100;return t<1&&t>0?"< 1":Number.isInteger(t)?`${t}`:t.toFixed(1)}function dt(e){return e.outcomes?.[0]?.label??e.question}function Yi(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function Ve(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),a=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${a}:${i}`}function pn(e){let[t,r]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let a=Math.floor(n/864e5),i=Math.floor(n%864e5/36e5),s=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),c=[];return a>0&&c.push(`${a}d`),c.push(`${String(i).padStart(2,"0")}h`),c.push(`${String(s).padStart(2,"0")}m`),c.push(`${String(l).padStart(2,"0")}s`),c.join(" ")}function mn(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0"),i=t.getFullYear(),s=-t.getTimezoneOffset(),l=s>=0?"+":"-",c=String(Math.abs(Math.floor(s/60))).padStart(2,"0");return `${r}:${o} ${n}/${a}/${i} (${l}${c})`}function vn({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:o,isCollapsed:n}=hooks.useScrollCollapse(),a=react.useMemo(()=>{let u=[...e.markets||[]],f=u.filter(m=>m.status==="open").sort((m,g)=>Ye(g)-Ye(m)),p=u.filter(m=>m.status!=="open").sort((m,g)=>Ye(g)-Ye(m));return [...f,...p]},[e.markets]),i=e.status==="closed"||e.status==="voided",s=pn(i?void 0:e.start_at),l=pn(i?void 0:e.end_at),c=mn(e.start_at),d=mn(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((u,f)=>jsxRuntime.jsxs(react.Fragment,{children:[f>0&&jsxRuntime.jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral truncate",children:u.label})]},u.slug)),jsxRuntime.jsx(Xi,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(s||l||i)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:i?d&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:d})}):s?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:s})}),c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:c})]})]}):l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsxRuntime.jsx(dn,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(ji,{markets:a,onTradeAction:t}),jsxRuntime.jsx(Gi,{markets:a,event:e})]})}var fn=5;function ji({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[a,i]=react.useState(null),s=e.find(m=>m.status==="open")?.slug,[l,c]=react.useState(s?`${s}:yes`:null);if(e.length===0)return null;let d=e.length>fn,u=o?e:e.slice(0,fn),f=m=>{i(g=>g===m?null:m);},p=(m,g,x)=>{c(`${m.slug}:${g}`),i(m.slug),t?.(m,g,x);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:u.map(m=>{let g=Ye(m),x=m.outcomes[1]?.best_ask??m.outcomes[1]?.price,v=a===m.slug;return jsxRuntime.jsx(qi,{market:m,yesPrice:g,noPrice:x??void 0,activeYes:l===`${m.slug}:yes`,activeNo:l===`${m.slug}:no`,isExpanded:v,onToggleExpand:()=>f(m.slug),onTradeAction:p},m.slug)})})]}),d&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>n(m=>!m),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function qi({market:e,yesPrice:t,noPrice:r,activeYes:o,activeNo:n,isExpanded:a,onToggleExpand:i,onTradeAction:s}){let{t:l}=i18n.useTranslation(),c=e.status==="open",d=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:i,role:"button",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),i());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsxRuntime.jsx(ui.Avatar,{src:e.image_url,name:dt(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:dt(e)}),d&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:d})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Vi(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:u=>{u.stopPropagation(),s?.(e,"yes","buy");},children:l("predict.market.action.yes",{price:un(t)})}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",n?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:u=>{u.stopPropagation(),s?.(e,"no","buy");},children:r!=null?l("predict.market.action.no",{price:un(r)}):l("predict.market.no")})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-end",children:jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?l("predict.event.status.closed"):e.status==="voided"?l("predict.event.status.voided"):l("predict.event.status.pending")})})})]}),a&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(sn,{market:e,outcome:n?"no":"yes",onTradeAction:s})})})})]})}function Gi({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[a,i]=react.useState(false),[s,l]=react.useState(0),c=e.filter(p=>p.rules&&p.rules.length>0||p.description);if(c.length===0)return null;let d=c[s]??c[0],u=d.rules&&d.rules.length>0?d.rules.join(`
19
+ `;function un({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:s}){let[a,i]=react.useState(null),l=e.markets??[],d=react.useMemo(()=>l.length>2?[...l].sort((M,T)=>(T.outcomes?.[0]?.price??0)-(M.outcomes?.[0]?.price??0)):l,[l]),c=d.filter(M=>M.status==="open"),u=d.length===1,m=c.slice(0,tn),f=c.length-tn,p=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=a?c.find(M=>M.slug===a)??null:null,v=!!g||u,b=()=>{v||o?.(e);},U=M=>{M.stopPropagation(),g&&(M.preventDefault(),i(null));},E=M=>{M.stopPropagation(),t||(M.preventDefault(),o?.(e));};return jsxRuntime.jsxs("div",{className:ui$1.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!v&&"cursor-pointer"),onMouseEnter:()=>s?.(e),onClick:b,children:[jsxRuntime.jsx("style",{children:va}),jsxRuntime.jsx(xa,{event:e,href:t,LinkComponent:r,onClick:U,isExpanded:v}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:u?jsxRuntime.jsx(Pa,{market:c[0],event:e,formattedVolume:p,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n}):g?jsxRuntime.jsx(Ea,{market:g,event:e,onCollapse:()=>i(null),onSelectOutcome:n}):jsxRuntime.jsx(ka,{displayedMarkets:m,moreCount:f,formattedVolume:p,source:e.source,href:t,LinkComponent:r,onMarketClick:M=>i(M.slug),onShowMore:E})})]})}function xa({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let s=e.start_at?ga(e.start_at):null;return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui$1.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),s&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",s]})]}),jsxRuntime.jsx(ba,{event:e})]})}function ha(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),s=300*1e3,a=900*1e3;if(n>0&&n<=a){let i=n<=s?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=s?"5m":"15m",color:i});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function ba({event:e}){let t=react.useMemo(()=>ha(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsxRuntime.jsx(ya,{},o);case "crypto-short":return jsxRuntime.jsx(wa,{label:r.label,color:r.color},o);case "closed":return jsxRuntime.jsx(Sa,{},o)}})})}function ya(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function wa({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui$1.TimerIcon,{className:"size-3 shrink-0"}),e]})}function Sa(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function ka({displayedMarkets:e,moreCount:t,formattedVolume:r,source:o,href:n,LinkComponent:s,onMarketClick:a,onShowMore:i}){let{t:l}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(d=>{let c=cn(d);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:u=>{u.stopPropagation(),a(d);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:d.outcomes?.[0]?.label??d.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:dn(c)}),jsxRuntime.jsx(Na,{})]})]},d.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui$1.Linkable,{href:n,LinkComponent:s,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[l("predict.event.showMore"),jsxRuntime.jsx(mn,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",l("predict.event.volume"),jsxRuntime.jsx(fn,{source:o})]})]})]})}function sn({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:i=>{let l=i.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:i=>{let l=i.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function pn({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:s}=i18n.useTranslation(),[a,i]=o?ma(e):[Vt,ln],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",d=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",c=n==="label"&&l===d?"action":n,u=c==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${nn(e)}\xA2`:s("predict.market.action.yes",{price:nn(e)}),m=c==="label"?`${e.outcomes?.[1]?.label??"No"} ${on(e)}\xA2`:s("predict.market.action.no",{price:on(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(sn,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"yes");},children:u}),jsxRuntime.jsx(sn,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:f=>{f.stopPropagation(),r?.(t,e,"no");},children:m})]})}function Na(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Pa({market:e,event:t,formattedVolume:r,href:o,LinkComponent:n,onSelect:s,onSelectOutcome:a}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(pn,{market:e,event:t,onSelectOutcome:a,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui$1.Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:d=>{d.stopPropagation(),o||(d.preventDefault(),s?.(t));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(mn,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",i("predict.event.volume"),jsxRuntime.jsx(fn,{source:t.source})]})]})]})}function Ea({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let{t:n}=i18n.useTranslation(),s=cn(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:dn(s)}),jsxRuntime.jsx(ui$1.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(pn,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx(Ca,{className:"h-3 w-3"}),n("predict.event.back")]})]})}function mn({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ca({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function fn({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui$1.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui$1.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Ia=768,vn=1024,_a=1280,Aa=8,Da=224,Ha=304,Ba=114;function Fa(e){return e>=_a?4:e>=vn?3:e>=Ia?2:1}function Ua(e){return e>=vn?Ha:Da}function xn({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i}){let l=react.useRef(null),d=react.useRef(null),{width:c=0,height:u=0}=hooks.useResizeObserver({ref:l}),m=Fa(c),f=Ua(c),p=Math.ceil(e.length/m)||0,g=!t&&e.length>0,v=p+(t?1:0)+(g?1:0),b=react.useCallback(T=>T<p,[p]),U=react.useCallback(async()=>{r?.();},[r]),E=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:b,loadMoreRows:U,rowCount:v,threshold:3}),M=react.useCallback(()=>{d.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:l,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{listRef:d,className:"no-scrollbar",style:{height:u},onRowsRendered:E,rowComponent:Wa,rowCount:v,rowHeight:T=>g&&T===v-1?Ba:(f),rowProps:{events:e,columnCount:m,dataRowCount:p,showEndOfList:g,totalRowCount:v,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i,onScrollToTop:M}})})}function Wa({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:s,totalRowCount:a,onSelect:i,onSelectOutcome:l,getEventHref:d,LinkComponent:c,onHover:u,onScrollToTop:m}){if(s&&e===a-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx($a,{onScrollToTop:m})});if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let f=e*o,p=r.slice(f,f+o),g=o-p.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[p.map(v=>v==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:Aa},children:jsxRuntime.jsx(un,{event:v,href:d?.(v),LinkComponent:c,onSelect:i,onSelectOutcome:l,onHover:u})},v.slug)),g>0&&Array.from({length:g}).map((v,b)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${b}`))]})})}function $a({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function bn({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a,onSelect:i,onSelectOutcome:l,getEventHref:d,LinkComponent:c,onHover:u}){let{data:m,hasMore:f,fetchMore:p,isFetching:g}=en({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a});return g?jsxRuntime.jsx(zt,{count:48}):jsxRuntime.jsx(xn,{events:m,hasMore:f,onFetchMore:p,onSelect:i,onSelectOutcome:l,getEventHref:d,LinkComponent:c,onHover:u})}function bu({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[s,a]=react.useState({categorySlug:null,tagSlug:null}),[i,l]=react.useState(Wt),{isOpen:d,onOpen:c,onClose:u}=ui$1.useDisclosure(),{onOpen:m}=uiScaffold.useAsyncModal(Ut),f=react.useCallback((T,G,C)=>{t?.(T,G,C),m({params:{event:T,market:G,initialOutcome:C}});},[t,m]),p=react.useCallback(T=>{a(T);},[]),g=react.useCallback(T=>{l(G=>({...G,sortPreset:T}));},[]),v=react.useCallback(T=>{l(G=>({...G,sortAsc:T}));},[]),b=react.useCallback(T=>{l(T);},[]),U=react.useMemo(()=>Xr[i.sortPreset].sort_by,[i.sortPreset]),E=react.useMemo(()=>$t(i),[i]),M=jsxRuntime.jsx(Qr,{sortPreset:i.sortPreset,onSortChange:g,sortAsc:i.sortAsc,onSortAscChange:v,onFilterPress:c,filterCount:E});return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(Rr,{onSelect:p,trailing:M}),jsxRuntime.jsx(Yr,{isOpen:d,onClose:u,value:i,onChange:b}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(bn,{tagSlugSelection:s,sort_by:U,sort_asc:i.sortAsc,source:i.source,onSelect:e,onSelectOutcome:f,getEventHref:r,LinkComponent:o,onHover:n})}),jsxRuntime.jsx(Kr,{})]})}var Qt=40,gt=36,qe=480,Jt=qe-gt;function Nn({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=i18n.useTranslation(),[n,s]=react.useState("positions"),a=react.useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:i}=reactPredict.usePositions({source:e.source,user:t??""}),l=react.useMemo(()=>!i?.positions||!t?0:a.length===0?i.positions.length:i.positions.filter(u=>u.market&&a.includes(u.market.slug)).length,[i?.positions,a,t]),c=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:c.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u.key),className:ui$1.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===u.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:u.label},u.key))}),t?jsxRuntime.jsxs("div",{style:{height:qe},children:[n==="positions"&&jsxRuntime.jsx(Qa,{source:e.source,walletAddress:t,marketSlugs:a}),n==="orders"&&jsxRuntime.jsx(Za,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),n==="trades"&&jsxRuntime.jsx(ri,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:qe},children:o("predict.trade.connectWallet")})]})}function Qa({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=i18n.useTranslation(),{data:n,isLoading:s}=reactPredict.usePositions({source:e,user:t}),a=react.useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(i=>i.market&&r.includes(i.market.slug)):[],[n?.positions,r]);return s?jsxRuntime.jsx(er,{}):a.length===0?jsxRuntime.jsx(Zt,{message:o("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:gt},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:Jt},rowComponent:Ja,rowCount:a.length,rowHeight:Qt,rowProps:{positions:a,closeLabel:o("predict.positions.close")}})]})}function Ja({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let s=n.pnl??0,a=n.pnl_percent??0,i=n.avg_price??0,l=n.current_price??0,d=s>0?"text-success":s<0?"text-danger":"text-foreground",c=s>0?"+":"",u=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",m=n.side,f=n.size,p=n.size*l,g=n.market?.end_at?si(n.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:u}),jsxRuntime.jsx("span",{className:ui$1.cn("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:mt(i)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:mt(l)}),jsxRuntime.jsxs("div",{className:ui$1.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",d),children:[c,"$",Math.abs(s).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",c,a.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Za({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a,fetchNextPage:i,hasNextPage:l}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),d=reactPredict.useCancelOrder(),c=react.useMemo(()=>{let b=s?.pages?.flatMap(M=>M.items)??[],U=new Set(["live","open","submitted","pending"]),E=b.filter(M=>U.has(M.status));return r.length>0&&(E=E.filter(M=>M.market_id&&r.includes(M.market_id))),E},[s?.pages,r]),u=react.useCallback(b=>{o?o(b.id):d.mutate({source:b.source,id:b.id});},[o,d]),m=c.length,f=m+(l?1:0),p=react.useCallback(b=>b<m,[m]),g=react.useCallback(async()=>{await i();},[i]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:g,rowCount:f,threshold:5});return a?jsxRuntime.jsx(er,{}):c.length===0&&!l?jsxRuntime.jsx(Zt,{message:n("predict.openOrders.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:gt},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:Jt},onRowsRendered:v,rowComponent:ei,rowCount:f,rowHeight:Qt,rowProps:{orders:c,itemCount:m,onCancel:u,isCancelling:d.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function ei({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:s,cancelLabel:a}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let i=r[e];if(!i)return null;let l=i.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui$1.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:i.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:i.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:i.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i.price?mt(parseFloat(i.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[i.size_matched??"0","/",i.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(ti,{status:i.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>n(i),disabled:s,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:s?jsxRuntime.jsx(ui$1.Spinner,{size:"sm"}):a})})]})}function ti({status:e}){return jsxRuntime.jsx("span",{className:ui$1.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function ri({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:o,isLoading:n,fetchNextPage:s,hasNextPage:a}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),i=react.useMemo(()=>o?.pages?.flatMap(f=>f.items)??[],[o?.pages]),l=i.length,d=l+(a?1:0),c=react.useCallback(f=>f<l,[l]),u=react.useCallback(async()=>{await s();},[s]),m=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:c,loadMoreRows:u,rowCount:d,threshold:5});return n?jsxRuntime.jsx(er,{}):i.length===0&&!a?jsxRuntime.jsx(Zt,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:gt},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:Jt},onRowsRendered:m,rowComponent:ni,rowCount:d,rowHeight:Qt,rowProps:{trades:i,itemCount:l}})]})}function ni({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let s=n.side?.toUpperCase()==="BUY",a=oi(n.timestamp),i=n.price??0,l=n.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui$1.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",s?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:n.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:mt(i)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:a})]})}function Zt({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:qe},children:e})}function er(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:qe},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function mt(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function oi(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${s}`}function si(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function Ge({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsxRuntime.jsx("div",{className:"h-5"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-12 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-10 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-48 rounded"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-24 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-20 rounded"})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-20 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center py-2",children:[jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-14 rounded"}),jsxRuntime.jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((r,o)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-10 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-4 w-16 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-full rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function Pn(){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 w-full rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-24 w-full rounded-lg"}),jsxRuntime.jsx(ui$1.Skeleton,{className:"h-10 w-full rounded-lg"})]})}var Tn="var(--color-bullish)",Mn="var(--color-bearish)";function je(e){if(Math.abs(e)>=1e4){let t=e/1e4;return `${parseFloat(t.toFixed(2))}\u4E07`}return e.toLocaleString()}function li(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function ci(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let f of e){let p=Math.round(f.price*100);p>=0&&p<=100&&(r[p]+=f.quantity);}for(let f of t){let p=Math.round(f.price*100);p>=0&&p<=100&&(o[p]+=f.quantity);}let n=0,s=0,a=new Float64Array(101),i=new Float64Array(101);for(let f=100;f>=0;f--)n+=r[f],s+=r[f]*f/100,a[f]=n,i[f]=s;let l=0,d=0,c=new Float64Array(101),u=new Float64Array(101);for(let f=0;f<=100;f++)l+=o[f],d+=o[f]*f/100,c[f]=l,u[f]=d;let m=Math.max(a[0]??0,c[100]??0);return Array.from({length:101},(f,p)=>{let g=a[p]>0,v=c[p]>0,b=a[p]||c[p],U=r[p]>0||o[p]>0;return {priceCents:p,displayHeight:li(b,m),opacity:b>0?U?1:.5:0,isBid:g,isAsk:v,bidCumTotal:a[p],askCumTotal:c[p],bidCumCost:i[p],askCumCost:u[p]}})}function di({info:e}){let t=e.isBid?Tn:Mn,r=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:r,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsxs("div",{style:{marginBottom:4,fontWeight:600},children:[e.priceCents,"\xA2"]}),jsxRuntime.jsxs("div",{style:{color:t},children:[je(Math.round(e.cumTotal))," contracts"]}),jsxRuntime.jsxs("div",{style:{color:t},children:["$",je(Math.round(e.cumCost))]})]})}var ui=react.memo(function({slot:t,onEnter:r,onLeave:o}){let n=react.useRef(null),s=t.isBid||t.isAsk,a=t.isBid?Tn:t.isAsk?Mn:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:s?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:s&&jsxRuntime.jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),pi=[0,10,20,30,40,50,60,70,80,90,100];function mi(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:pi.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Rn({bids:e,asks:t}){let r=react.useMemo(()=>ci(e,t),[e,t]),o=react.useMemo(()=>{let c=e.length>0?Math.max(...e.map(m=>m.price)):0,u=t.length>0?Math.min(...t.map(m=>m.price)):1;return Math.round((c+u)/2*100)},[e,t]),n=react.useMemo(()=>r.some(c=>c.isBid||c.isAsk),[r]),[s,a]=react.useState(null),i=react.useRef(null),l=react.useCallback((c,u)=>{i.current&&(i.current.style.filter=""),u?(u.style.filter="brightness(1.5)",i.current=u):i.current=null,c.isBid||c.isAsk?a({priceCents:c.priceCents,isBid:c.isBid,cumTotal:c.isBid?c.bidCumTotal:c.askCumTotal,cumCost:c.isBid?c.bidCumCost:c.askCumCost,leftPct:c.priceCents}):a(null);},[]),d=react.useCallback(()=>{i.current&&(i.current.style.filter="",i.current=null),a(null);},[]);return n?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsxRuntime.jsx(di,{info:s}),r.map(c=>jsxRuntime.jsx(ui,{slot:c,onEnter:l,onLeave:d},c.priceCents))]}),jsxRuntime.jsx(mi,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No depth data"})}function Ln(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function On(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsxRuntime.jsx(ui$1.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})]})}function Dn({market:e,outcome:t="yes",onTradeAction:r}){let{t:o}=i18n.useTranslation(),[n,s]=react.useState("depth"),a=t==="no",i=e.source,{data:l,isLoading:d}=reactPredict.useOrderbook({slug:e.slug,source:i}),c=react.useMemo(()=>((a?l?.asks:l?.bids)??[]).map(v=>({price:a?1-v.price:v.price,quantity:v.size})),[l?.bids,l?.asks,a]),u=react.useMemo(()=>((a?l?.bids:l?.asks)??[]).map(v=>({price:a?1-v.price:v.price,quantity:v.size})),[l?.bids,l?.asks,a]),m=react.useMemo(()=>c.length>0?Math.max(...c.map(g=>g.price)):null,[c]),f=react.useMemo(()=>u.length>0?Math.min(...u.map(g=>g.price)):null,[u]),p=react.useMemo(()=>{if(m==null||f==null)return null;let g=(f-m)*100;return Math.round(g*10)/10},[m,f]);return jsxRuntime.jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxRuntime.jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:p!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(p)?`${p}\xA2`:`${p.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[m!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",Ln(m)]}),m!=null&&f!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),f!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",Ln(f)]})]}),jsxRuntime.jsx("div",{className:"flex flex-1 justify-end",children:jsxRuntime.jsx("button",{type:"button",title:n==="depth"?"Orderbook":"Depth chart",onClick:()=>s(g=>g==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:n==="depth"?jsxRuntime.jsx(ui$1.OrderbookTableIcon,{className:"h-4 w-4"}):jsxRuntime.jsx(ui$1.OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[n==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:d?jsxRuntime.jsx(On,{}):jsxRuntime.jsx(Rn,{bids:c,asks:u})}),n==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:d?jsxRuntime.jsx(On,{}):jsxRuntime.jsx(bi,{bids:c,asks:u,bestBid:m??void 0,bestAsk:f??void 0,spread:p??void 0})})]})]})}var In=8;function bi({bids:e,asks:t,spread:r}){let{t:o}=i18n.useTranslation(),n=react.useMemo(()=>[...t].sort((l,d)=>d.price-l.price).slice(0,In),[t]),s=react.useMemo(()=>[...e].sort((l,d)=>d.price-l.price).slice(0,In),[e]),a=react.useMemo(()=>{let l=[...n,...s].map(d=>d.quantity);return Math.max(...l,1)},[n,s]);return n.length===0&&s.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(l=>jsxRuntime.jsx(_n,{price:l.price,quantity:l.quantity,side:"ask",maxQty:a},`ask-${l.price}`)),jsxRuntime.jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),s.map(l=>jsxRuntime.jsx(_n,{price:l.price,quantity:l.quantity,side:"bid",maxQty:a},`bid-${l.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function _n({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",s=Math.min(t/o*100,100),a=n?"bg-bullish/10":"bg-bearish/10",i=n?"text-bullish":"text-bearish",l=Math.round(e*100),d=je(Math.round(t)),c=Math.round(t*e),u=`$${je(c)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 ${i}`,children:[l,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-center",children:d}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var or=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},xt=4,Hn=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Li(e,t){let r=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Oi(e,t){let r=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===reactPredict.ChartRange.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Fn(e){return `${(e*100).toFixed(2)}%`}var Ii=[{range:reactPredict.ChartRange.ONE_DAY,label:"1D"},{range:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{range:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{range:reactPredict.ChartRange.ALL,label:"ALL"}];function _i({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Ii.map(({range:r,label:o})=>{let n=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function Ai(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(n=>{let s=e.current,a=t.current;if(!s||!a)return;let i=s.getBoundingClientRect(),l=(n.clientX-i.left)/i.width*100;a.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,a.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function Di({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:s}){if(!e||!n?.length)return null;let a=new Map;t?.forEach(l=>a.set(l.dataKey,l));let i=n.map(l=>a.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?Oi(r,s):r}),i.map(l=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?Fn(l.value):"--"})]},l.dataKey))]})}function Hi({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,s]=react.useState(false),a=react.useRef(null);react.useEffect(()=>{if(!n)return;function d(c){a.current&&!a.current.contains(c.target)&&s(false);}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]);let i=t.length>=xt,l=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(d=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(d)??"#6b7280",display:"inline-block"}},d))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let d=e.find(c=>c.slug===t[0]);return d?.outcomes?.[0]?.label??d?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>s(d=>!d),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[l,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",xt," markets"]}),e.map(d=>{let c=t.includes(d.slug),u=!c&&i,m=c&&t.length===1,f=r.get(d.slug)??"#6b7280",p=d.outcomes.find(v=>v.label.toLowerCase()==="yes")??d.outcomes[0],g=p?.price!=null?`${Math.round(p.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{m||u||o(d.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:c?"rgba(255,255,255,0.05)":"transparent",cursor:u||m?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!u&&!m&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=c?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:c?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:c?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:c&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:c?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.outcomes?.[0]?.label??d.question}),g&&jsxRuntime.jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:g})]},d.slug)})]})]})}function Bi({series:e,colorMap:t,displayValues:r}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",s=r.get(o.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:s!=null?Fn(s):"--"})]})]},o.marketSlug)})})}function Fi(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function Ui(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let s=Math.floor(n*o),a=Math.min(Math.floor((n+1)*o),e.length),i=e.slice(s,a),l=i.map(d=>d.price).sort((d,c)=>d-c);r.push({timestamp:i[i.length-1].timestamp,price:Fi(l)});}return r}function Wi(e,t=200){if(e.length===0)return [];let r=e.map(i=>({...i,data:Ui(i.data,t)})),o=new Set;r.forEach(i=>i.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((i,l)=>i-l),s=r.map(i=>{let l=new Map;return i.data.forEach(d=>l.set(d.timestamp,d.price)),{slug:i.marketSlug,map:l}}),a=new Map;return n.map(i=>{let l={timestamp:i};return s.forEach(({slug:d,map:c})=>{let u=c.get(i);if(u!==void 0)a.set(d,u),l[d]=u;else {let m=a.get(d);m!==void 0&&(l[d]=m);}}),l})}function Un(e){return jsxRuntime.jsx(or,{children:jsxRuntime.jsx($i,{...e})})}function $i({event:e,isLoading:t,className:r,volume:o}){let n=react.useMemo(()=>(e.markets??[]).filter(w=>w.status==="open"),[e.markets]),s=react.useMemo(()=>[...n].sort((w,x)=>{let R=A=>(A.outcomes.find(ee=>ee.label.toLowerCase()==="yes")??A.outcomes[0])?.price??0;return R(x)-R(w)}),[n]),[a,i]=react.useState(()=>s.slice(0,xt).map(w=>w.slug)),[l,d]=react.useState(at),c=react.useMemo(()=>{let w=new Map;return a.forEach((x,R)=>{w.set(x,Hn[R%Hn.length]);}),w},[a]),u=react.useMemo(()=>n.filter(w=>a.includes(w.slug)),[n,a]),{series:m,isLoading:f}=reactPredict.useMarketHistory(u,l),p=t||f,g=react.useMemo(()=>{if(m.length>0&&m.some(R=>R.data.length>0))return m;let w=Date.now(),x=864e5;return u.map(R=>{let ee=(R.outcomes?.find(j=>j.label.toLowerCase()==="yes")??R.outcomes?.[0])?.price??.5;return {marketSlug:R.slug,label:R.outcomes?.[0]?.label??R.question,data:[{timestamp:w-7*x,price:ee},{timestamp:w,price:ee}]}})},[m,u]),v=react.useMemo(()=>l===reactPredict.ChartRange.ONE_DAY?96:l===reactPredict.ChartRange.ONE_WEEK?168:l===reactPredict.ChartRange.ONE_MONTH?180:300,[l]),b=react.useMemo(()=>Wi(g,v),[g,v]),U=react.useMemo(()=>{if(b.length===0)return [0,1];let w=1/0,x=-1/0;if(a.forEach(A=>{b.forEach(ee=>{let j=ee[A];j!=null&&(j<w&&(w=j),j>x&&(x=j));});}),!isFinite(w))return [0,1];let R=Math.max((x-w)*.15,.05);return [Math.max(0,w-R),Math.min(1,x+R)]},[b,a]),E=react.useMemo(()=>{let w=new Map;return g.forEach(x=>{x.data.length>0&&w.set(x.marketSlug,x.data[x.data.length-1].price);}),w},[g]),M=react.useMemo(()=>{let w=new Map;return g.forEach(x=>w.set(x.marketSlug,x.label)),w},[g]),T=react.useMemo(()=>g.map(w=>({slug:w.marketSlug,color:c.get(w.marketSlug)??"#6b7280"})),[g,c]),{wrapperRef:G,overlayRef:C,onMouseMove:N,onMouseLeave:z}=Ai(),he=react.useCallback(w=>{i(x=>x.includes(w)?x.length<=1?x:x.filter(R=>R!==w):x.length>=xt?x:[...x,w]);},[]),[ne,K]=react.useState(null),oe=react.useRef(null),se=react.useRef(""),we=react.useRef(0),Se=!p&&b.length>0;return jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsx(Bi,{series:g,colorMap:c,displayValues:ne??E}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsx("div",{ref:G,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:Se?w=>{N(w),cancelAnimationFrame(we.current),we.current=requestAnimationFrame(()=>{K(oe.current);});}:void 0,onMouseLeave:Se?()=>{z(),cancelAnimationFrame(we.current),se.current="",oe.current=null,K(null);}:void 0,children:p?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):b.length===0?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:C,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:b,margin:{top:8,right:16,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:w=>Li(w,l),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:U,tickFormatter:w=>`${Math.round(w*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:w=>{let x=w;if(x.active&&x.payload?.length){let R=x.payload.map(A=>`${A.dataKey}:${A.value}`).join(",");if(R!==se.current){se.current=R;let A=new Map;x.payload.forEach(ee=>{ee.value!=null&&A.set(ee.dataKey,ee.value);}),oe.current=A;}}return jsxRuntime.jsx(Di,{...x,labelMap:M,allSeries:T,range:l})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(w=>{let x=c.get(w.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:w.marketSlug,stroke:x,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:x},connectNulls:true,isAnimationActive:false},w.marketSlug)}),ne==null&&b.length>0&&g.map(w=>{let x=b[b.length-1],R=x[w.marketSlug];if(R==null)return null;let A=c.get(w.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:x.timestamp,y:R,ifOverflow:"extendDomain",shape:ee=>{let{cx:j,cy:Fe}=ee;return j==null||Fe==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:j,cy:Fe,r:6,fill:A,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:j,cy:Fe,r:3.5,fill:A})]})}},`pulse-${w.marketSlug}`)})]})})]})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(o).toLocaleString()," vol"]}),jsxRuntime.jsx("div",{style:{flex:1}}),s.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hi,{markets:s,selectedSlugs:a,colorMap:c,onToggle:he}),jsxRuntime.jsx("span",{style:{width:1,height:14,background:"#374151",flexShrink:0}})]}),jsxRuntime.jsx(_i,{value:l,onChange:d})]})]})]})}function Qe(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function el(e){return `${Math.round(e*100)}%`}function Wn(e){let t=e*100;return t<1&&t>0?"< 1":Number.isInteger(t)?`${t}`:t.toFixed(1)}function ht(e){return e.outcomes?.[0]?.label??e.question}function tl(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function Xe(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),s=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${s}:${a}`}function $n(e){let[t,r]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let c=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(c)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let s=Math.floor(n/864e5),a=Math.floor(n%864e5/36e5),i=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),d=[];return s>0&&d.push(`${s}d`),d.push(`${String(a).padStart(2,"0")}h`),d.push(`${String(i).padStart(2,"0")}m`),d.push(`${String(l).padStart(2,"0")}s`),d.join(" ")}function zn(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),i=-t.getTimezoneOffset(),l=i>=0?"+":"-",d=String(Math.abs(Math.floor(i/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${a} (${l}${d})`}function Yn({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:o,isCollapsed:n}=hooks.useScrollCollapse(),s=react.useMemo(()=>{let u=[...e.markets||[]],m=u.filter(p=>p.status==="open").sort((p,g)=>Qe(g)-Qe(p)),f=u.filter(p=>p.status!=="open").sort((p,g)=>Qe(g)-Qe(p));return [...m,...f]},[e.markets]),a=e.status==="closed"||e.status==="voided",i=$n(a?void 0:e.start_at),l=$n(a?void 0:e.end_at),d=zn(e.start_at),c=zn(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((u,m)=>jsxRuntime.jsxs(react.Fragment,{children:[m>0&&jsxRuntime.jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral truncate",children:u.label})]},u.slug)),jsxRuntime.jsx(sl,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(i||l||a)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?c&&jsxRuntime.jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:c})}):i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:i})}),d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:d})]})]}):l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:c})]})]}):null}),jsxRuntime.jsx(Un,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(rl,{markets:s,onTradeAction:t}),jsxRuntime.jsx(ol,{markets:s,event:e})]})}var Kn=5;function rl({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(null),i=e.find(p=>p.status==="open")?.slug,[l,d]=react.useState(i?`${i}:yes`:null);if(e.length===0)return null;let c=e.length>Kn,u=o?e:e.slice(0,Kn),m=p=>{a(g=>g===p?null:p);},f=(p,g,v)=>{d(`${p.slug}:${g}`),a(p.slug),t?.(p,g,v);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:u.map(p=>{let g=Qe(p),v=p.outcomes[1]?.best_ask??p.outcomes[1]?.price,b=s===p.slug;return jsxRuntime.jsx(nl,{market:p,yesPrice:g,noPrice:v??void 0,activeYes:l===`${p.slug}:yes`,activeNo:l===`${p.slug}:no`,isExpanded:b,onToggleExpand:()=>m(p.slug),onTradeAction:f},p.slug)})})]}),c&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>n(p=>!p),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:ui$1.cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function nl({market:e,yesPrice:t,noPrice:r,activeYes:o,activeNo:n,isExpanded:s,onToggleExpand:a,onTradeAction:i}){let{t:l}=i18n.useTranslation(),d=e.status==="open",c=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:a,role:"button",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),a());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url,name:ht(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:ht(e)}),c&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:c})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:el(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:d?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui$1.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:u=>{u.stopPropagation(),i?.(e,"yes","buy");},children:l("predict.market.action.yes",{price:Wn(t)})}),jsxRuntime.jsx("button",{type:"button",className:ui$1.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",n?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:u=>{u.stopPropagation(),i?.(e,"no","buy");},children:r!=null?l("predict.market.action.no",{price:Wn(r)}):l("predict.market.no")})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-end",children:jsxRuntime.jsx("span",{className:ui$1.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?l("predict.event.status.closed"):e.status==="voided"?l("predict.event.status.voided"):l("predict.event.status.pending")})})})]}),s&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(Dn,{market:e,outcome:n?"no":"yes",onTradeAction:i})})})})]})}function ol({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(false),[i,l]=react.useState(0),d=e.filter(f=>f.rules&&f.rules.length>0||f.description);if(d.length===0)return null;let c=d[i]??d[0],u=c.rules&&c.rules.length>0?c.rules.join(`
20
20
 
21
- `):d.description??"";if(!u)return null;let f=u.length>200&&!o?u.slice(0,200)+"...":u;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),c.length>1&&jsxRuntime.jsxs(ui.Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsxRuntime.jsx(ui.DropdownTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:dt(d)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(s)],onAction:p=>{l(Number(p)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((p,m)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(m===s?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:dt(p)},String(m)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:f}),u.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(p=>!p),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>i(p=>!p),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",a&&"rotate-180")})]}),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:(()=>{let p=d.status,m=[];return d.created_at&&m.push({label:r("predict.event.timeline.created"),value:Ve(d.created_at),isActive:true}),m.push({label:r("predict.event.timeline.open"),value:Ve(d.start_at),isActive:p!=="pending"}),p==="voided"?m.push({label:r("predict.event.timeline.voided"),value:Ve(d.closed_at??d.end_at),isActive:true}):p==="closed"?m.push({label:r("predict.event.timeline.closed"),value:Ve(d.closed_at??d.end_at),isActive:true}):m.push({label:r("predict.event.timeline.close"),value:Ve(d.end_at),isActive:false}),m})().map((p,m,g)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${p.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),m<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${m<g.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:p.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:p.value})]})]},p.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:d.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:Yi(d.source)})]})]})]})]})}function Xi({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function xn({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:a}=reactPredict.useEvent({slug:e,source:t});return n?jsxRuntime.jsx(ze,{}):a||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:a?.message||"Event not found"}):jsxRuntime.jsx(vn,{event:o,onTradeAction:r})}function hn({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=i18n.useTranslation(),{data:a,isLoading:i}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return i||!a||a.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:a.map(s=>jsxRuntime.jsx(ra,{event:s,onClick:o},s.slug))})]})}function ra({event:e,onClick:t}){let r=e.volume;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function bn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function wu({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:a}){let{t:i}=i18n.useTranslation(),{isMobile:s}=ui.useScreen(),{isOpen:l,onOpen:c,onClose:d}=ui.useDisclosure(),{data:u,isLoading:f}=reactPredict.useEvent({slug:e,source:t}),p=react.useMemo(()=>[...u?.markets||[]].sort((M,N)=>bn(N)-bn(M)),[u?.markets]),[m,g]=react.useState(null),x=react.useCallback((M,N,C)=>{g(B=>({market:M,outcome:N,side:C,version:(B?.version??0)+1})),s&&c();},[s,c]),v=m?.market??p[0];if(f){let M=!!a;return s?jsxRuntime.jsx(ze,{showBack:M}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(ze,{showBack:M})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(qr,{})})})]})}let _=m?`${m.market.slug}-${m.version}`:v?.slug??"default";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[a&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:a,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:i("common.back")})}),jsxRuntime.jsx(xn,{eventSlug:e,source:t,onTradeAction:x})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[v&&jsxRuntime.jsx(et,{event:u,market:v,initialSide:m?.side,initialOutcome:m?.outcome,chain:r},_),u&&jsxRuntime.jsx(hn,{eventSlug:e,source:u.source,onEventClick:n})]})]}),u&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx(jr,{event:u,walletAddress:o})})]})}function yn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function va(e){switch(e){case reactPredict.ChartRange.ONE_DAY:return {interval:"15m",limit:96};case reactPredict.ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case reactPredict.ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case reactPredict.ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Mu=e=>{let{candlestickMarketSlugs:t,chartRange:r=Qe,source:o}=e,n=reactPredict.usePredictClient(),a=react.useMemo(()=>va(r),[r]),{data:i,isLoading:s,error:l}=reactPredict.useEvent({slug:e.eventSlug,source:o}),c=react.useMemo(()=>i?.markets?(t&&t.length>0?t.slice(0,4).map(g=>i.markets.find(x=>x.slug===g)).filter(g=>g!==void 0):[...i.markets].sort((g,x)=>yn(x)-yn(g)).slice(0,4)).map(g=>g.slug):[],[t,i?.markets]),d=reactQuery.useQueries({queries:c.map(m=>({queryKey:reactPredict.candlesticksQueryKey(m,a),queryFn:()=>n.listCandlesticks(m,a),enabled:c.length>0}))}),u=d.some(m=>m.isLoading),f=react.useMemo(()=>{let m=new Map;return c.forEach((g,x)=>{let v=d[x]?.error;v&&m.set(g,v);}),m},[c,d]),p=react.useMemo(()=>{let m=new Map;return c.forEach((g,x)=>{let v=d[x]?.data;v&&m.set(g,v);}),m},[c,d]);return {event:i,isEventLoading:s,eventError:l,candlestickParams:a,candlesticks:p,isCandlesticksLoading:u,candlestickErrors:f}};var ba=10,ya=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function gt(){let[e,t]=jotai.useAtom(ya),r=react.useCallback(n=>{let a=n.trim();a&&t(i=>{let s=i.filter(l=>l!==a);return [a,...s].slice(0,ba)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function Nn({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(a=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(a),children:a},a))})]})}function Pn({onSelect:e,className:t}){let{histories:r,clearHistories:o}=gt();return jsxRuntime.jsx(Nn,{className:ui.cn(t),histories:r,onSelect:e,onClear:o})}function En({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:a}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:n,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:a("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:i=>{i.preventDefault(),o?.();},children:"Esc"})})})}function Mn({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:a}){let i=e.tags?.[0];return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,className:ui.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",a),onClick:s=>{t&&o&&s.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),i&&jsxRuntime.jsx("span",{className:ui.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:i.label})]})]})}function Rn({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:a,hasNextPage:i,fetchNextPage:s}=reactPredict.useSearchEvents({keyword:e,limit:t,source:r},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[o]),isLoading:n,isFetchingNextPage:a,hasNextPage:i??false,fetchNextPage:s}}var za=56;function _n({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...a}){let{events:i,isLoading:s,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:d}=Rn(a),u=react.useRef(null),{height:f}=hooks.useResizeObserver({ref:u}),p=react.useCallback(v=>v<i.length,[i]),m=react.useCallback(async()=>{c&&!l&&await d();},[c,l,d]),g=react.useMemo(()=>c?i.length+1:i.length,[i,c]),x=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:m,rowCount:g,threshold:5});return s?jsxRuntime.jsx(Va,{className:n}):i.length===0?jsxRuntime.jsx(Ya,{className:n}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",n),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{style:{height:f},onRowsRendered:x,rowComponent:Ka,rowCount:g,rowHeight:za,rowProps:{events:i,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Ka({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:a,onHover:i}){let s=r[e];return s?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(Mn,{event:s,href:n?.(s),LinkComponent:a,onSelect:o,onHover:i})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function Va({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function Ya({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Fn({onKeywordChange:e}){let[t,r]=react.useState(""),[o,n]=react.useState(""),{addHistory:a}=gt(),i=hooks.useCallbackRef(e),s=hooks.useCallbackRef(a),l=react.useMemo(()=>utils.debounce(f=>{n(f),i(f),f&&s(f);},500),[i,s]),c=react.useCallback(f=>{r(f),l(f);},[l]),d=react.useCallback(f=>{l.cancel(),r(f),n(f),i(f),f&&s(f);},[l,i,s]),u=react.useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:c,setKeyword:d,clearKeyword:u}}function Bn({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:a,source:i}){let{text:s,keyword:l,setText:c,setKeyword:d,clearKeyword:u}=Fn({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(En,{value:s,onValueChange:c,onClear:u,onEscape:a}),!l&&jsxRuntime.jsx(Pn,{onSelect:d}),jsxRuntime.jsx(_n,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:i})]})}var Xt="predict-search";function jp({id:e=Xt}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(sl,{...t})})}function sl({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=i18n.useTranslation(),{isMobile:a}=ui.useScreen(),i=react.useCallback(l=>{o(l);},[o]),s=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:a?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(Bn,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:i,onEscape:s})})]})})}function rm({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=i18n.useTranslation(),{isDesktop:n,isMobile:a}=ui.useScreen(),{onOpen:i,onClose:s}=uiScaffold.useAsyncModal(Xt),l=hooks.useCallbackRef(e),c=hooks.useCallbackRef(async()=>{let u=await i({params:t});u&&l(u);}),d=hooks.useCallbackRef(()=>{s();});return react.useEffect(()=>{let u=f=>{let p=document.activeElement,m=!!p&&(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.getAttribute("contenteditable")==="true");f.key==="/"&&!m&&(f.preventDefault(),c()),f.key==="Escape"&&(f.preventDefault(),d());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[c,d]),jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:c,variant:a?"flat":"bordered",startContent:n?jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsxRuntime.jsx(ui.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui.cn(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"})})}var xl=react.createContext(null);var hl=3e4;function bl({walletAddress:e,source:t,pollingInterval:r=hl,enabled:o=true,children:n}){let a=o&&!!e,{data:i,isLoading:s,error:l,refetch:c}=reactPredict.usePositions({user:e,source:t},{enabled:a,refetchInterval:r}),{data:d,isLoading:u,error:f}=reactPredict.useBalance({user:e,source:t??"dflow"},{enabled:a,refetchInterval:r}),p=react.useMemo(()=>({positions:i?.positions??[],usdcBalance:d?Number(d.balance):0,isLoading:s||u,error:l??f??null,refetch:c}),[i?.positions,d,s,u,l,f,c]);return jsxRuntime.jsx(xl.Provider,{value:p,children:n})}Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=Hl;exports.CHART_RANGE_PERIOD=Al;exports.CHART_RANGE_SAMPLE_INTERVAL=Dl;exports.CandlestickPeriod=Xe;exports.CategoriesSkeleton=El;exports.CategoriesUI=nr;exports.CategoriesWidget=ir;exports.ChartRange=J;exports.DEFAULT_CHART_RANGE=Qe;exports.DEFAULT_FILTER_STATE=Et;exports.DEFAULT_PAGE_SIZE=_e;exports.DEFAULT_PRICE_HISTORY_INTERVAL=$l;exports.EventDetailPage=wu;exports.EventDetailSkeleton=ze;exports.EventDetailUI=vn;exports.EventDetailWidget=xn;exports.EventItem=_r;exports.EventMarketDepthChartUI=Jr;exports.EventMarketDetailWidget=sn;exports.EventPriceChart=dn;exports.EventsFilterUI=vr;exports.EventsPage=cd;exports.EventsPageSkeleton=Ic;exports.EventsSkeleton=Tt;exports.EventsToolbarUI=Sr;exports.EventsUI=Ur;exports.EventsWidget=Wr;exports.MAX_PRICE_HISTORY_MARKETS=yt;exports.ORDER_MAX_PRICE=Ul;exports.ORDER_MIN_PRICE=Bl;exports.ORDER_MIN_QUANTITY=St;exports.ORDER_PRICE_STEP=Fl;exports.PREDICT_SEARCH_MODAL_ID=Xt;exports.PREDICT_TRADE_MODAL_ID=Pt;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Wl;exports.PredictSearchModal=jp;exports.PredictTradeModal=fr;exports.PriceHistoryInterval=be;exports.SORT_PRESETS=yr;exports.STATIC_CATEGORIES=bt;exports.SearchEventsButton=rm;exports.SearchHistoryUI=Nn;exports.SearchHistoryWidget=Pn;exports.SearchInputUI=En;exports.SearchResultItemUI=Mn;exports.SearchResultListWidget=_n;exports.SearchWidget=Bn;exports.SimilarEventCard=ra;exports.SimilarEventsSection=hn;exports.TradeFormSkeleton=qr;exports.TradeFormUI=pr;exports.TradeFormWidget=et;exports.UserActivitySection=jr;exports.UserPredictProvider=bl;exports.countActiveFilters=Ct;exports.formatWan=Ke;exports.useEventDetail=Mu;exports.useEventsInfinite=Nr;exports.usePredictSearchHistory=gt;exports.useSearchResultListScript=Rn;exports.useSearchScript=Fn;exports.useTradeForm=cr;exports.version=qn;//# sourceMappingURL=index.js.map
21
+ `):c.description??"";if(!u)return null;let m=u.length>200&&!o?u.slice(0,200)+"...":u;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),d.length>1&&jsxRuntime.jsxs(ui$1.Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsxRuntime.jsx(ui$1.DropdownTrigger,{children:jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:ht(c)})}),jsxRuntime.jsx(ui$1.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(i)],onAction:f=>{l(Number(f)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:d.map((f,p)=>jsxRuntime.jsx(ui$1.DropdownItem,{className:ui$1.cn(p===i?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:ht(f)},String(p)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),u.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(f=>!f),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(f=>!f),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui$1.ChevronDownIcon,{className:ui$1.cn("h-4 w-4 transition-transform",s&&"rotate-180")})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:(()=>{let f=c.status,p=[];return c.created_at&&p.push({label:r("predict.event.timeline.created"),value:Xe(c.created_at),isActive:true}),p.push({label:r("predict.event.timeline.open"),value:Xe(c.start_at),isActive:f!=="pending"}),f==="voided"?p.push({label:r("predict.event.timeline.voided"),value:Xe(c.closed_at??c.end_at),isActive:true}):f==="closed"?p.push({label:r("predict.event.timeline.closed"),value:Xe(c.closed_at??c.end_at),isActive:true}):p.push({label:r("predict.event.timeline.close"),value:Xe(c.end_at),isActive:false}),p})().map((f,p,g)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${f.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),p<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<g.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:f.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:f.value})]})]},f.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:c.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:tl(c.source)})]})]})]})]})}function sl({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui$1.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui$1.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function qn({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:s}=reactPredict.useEvent({slug:e,source:t});return n?jsxRuntime.jsx(Ge,{}):s||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:s?.message||"Event not found"}):jsxRuntime.jsx(Yn,{event:o,onTradeAction:r})}function Gn({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:s.map(i=>jsxRuntime.jsx(ul,{event:i,onClick:o},i.slug))})]})}function ul({event:e,onClick:t}){let r=e.volume;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsxRuntime.jsx(ui$1.ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function jn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Op({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:s}){let{t:a}=i18n.useTranslation(),{isMobile:i}=ui$1.useScreen(),{isOpen:l,onOpen:d,onClose:c}=ui$1.useDisclosure(),{data:u,isLoading:m}=reactPredict.useEvent({slug:e,source:t}),f=react.useMemo(()=>[...u?.markets||[]].sort((E,M)=>jn(M)-jn(E)),[u?.markets]),[p,g]=react.useState(null),v=react.useCallback((E,M,T)=>{g(G=>({market:E,outcome:M,side:T,version:(G?.version??0)+1})),i&&d();},[i,d]),b=p?.market??f[0];if(m){let E=!!s;return i?jsxRuntime.jsx(Ge,{showBack:E}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Ge,{showBack:E})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(Pn,{})})})]})}let U=p?`${p.market.slug}-${p.version}`:b?.slug??"default";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui$1.Button,{as:"a",onPress:s,startContent:jsxRuntime.jsx(ui$1.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:a("common.back")})}),jsxRuntime.jsx(qn,{eventSlug:e,source:t,onTradeAction:v})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[b&&jsxRuntime.jsx(lt,{event:u,market:b,initialSide:p?.side,initialOutcome:p?.outcome,chain:r},U),u&&jsxRuntime.jsx(Gn,{eventSlug:e,source:u.source,onEventClick:n})]})]}),u&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx(Nn,{event:u,walletAddress:o})})]})}function Xn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Pl(e){switch(e){case reactPredict.ChartRange.ONE_DAY:return {interval:"15m",limit:96};case reactPredict.ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case reactPredict.ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case reactPredict.ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Fp=e=>{let{candlestickMarketSlugs:t,chartRange:r=at,source:o}=e,n=reactPredict.usePredictClient(),s=react.useMemo(()=>Pl(r),[r]),{data:a,isLoading:i,error:l}=reactPredict.useEvent({slug:e.eventSlug,source:o}),d=react.useMemo(()=>a?.markets?(t&&t.length>0?t.slice(0,4).map(g=>a.markets.find(v=>v.slug===g)).filter(g=>g!==void 0):[...a.markets].sort((g,v)=>Xn(v)-Xn(g)).slice(0,4)).map(g=>g.slug):[],[t,a?.markets]),c=reactQuery.useQueries({queries:d.map(p=>({queryKey:reactPredict.candlesticksQueryKey(p,s),queryFn:()=>n.listCandlesticks(p,s),enabled:d.length>0}))}),u=c.some(p=>p.isLoading),m=react.useMemo(()=>{let p=new Map;return d.forEach((g,v)=>{let b=c[v]?.error;b&&p.set(g,b);}),p},[d,c]),f=react.useMemo(()=>{let p=new Map;return d.forEach((g,v)=>{let b=c[v]?.data;b&&p.set(g,b);}),p},[d,c]);return {event:a,isEventLoading:i,eventError:l,candlestickParams:s,candlesticks:f,isCandlesticksLoading:u,candlestickErrors:m}};var Tl=10,Ml=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function kt(){let[e,t]=jotai.useAtom(Ml),r=react.useCallback(n=>{let s=n.trim();s&&t(a=>{let i=a.filter(l=>l!==s);return [s,...i].slice(0,Tl)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function eo({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui$1.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui$1.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(s=>jsxRuntime.jsx(ui$1.Chip,{size:"sm",variant:"bordered",className:ui$1.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(s),children:s},s))})]})}function to({onSelect:e,className:t}){let{histories:r,clearHistories:o}=kt();return jsxRuntime.jsx(eo,{className:ui$1.cn(t),histories:r,onSelect:e,onClear:o})}function ro({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:n,children:jsxRuntime.jsx(ui$1.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:s("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui$1.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui$1.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:"Esc"})})})}function so({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:s}){let a=e.tags?.[0];return jsxRuntime.jsxs(ui$1.Linkable,{href:t,LinkComponent:r,className:ui$1.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",s),onClick:i=>{t&&o&&i.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsxRuntime.jsx(ui$1.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),a&&jsxRuntime.jsx("span",{className:ui$1.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:a.label})]})]})}function ao({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:s,hasNextPage:a,fetchNextPage:i}=reactPredict.useSearchEvents({keyword:e,limit:t,source:r},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(d=>d.items).filter(d=>d!=null)??[],[o]),isLoading:n,isFetchingNextPage:s,hasNextPage:a??false,fetchNextPage:i}}var Jl=56;function uo({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...s}){let{events:a,isLoading:i,isFetchingNextPage:l,hasNextPage:d,fetchNextPage:c}=ao(s),u=react.useRef(null),{height:m}=hooks.useResizeObserver({ref:u}),f=react.useCallback(b=>b<a.length,[a]),p=react.useCallback(async()=>{d&&!l&&await c();},[d,l,c]),g=react.useMemo(()=>d?a.length+1:a.length,[a,d]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:f,loadMoreRows:p,rowCount:g,threshold:5});return i?jsxRuntime.jsx(ec,{className:n}):a.length===0?jsxRuntime.jsx(tc,{className:n}):jsxRuntime.jsx("div",{className:ui$1.cn("w-full h-full flex flex-col",n),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{style:{height:m},onRowsRendered:v,rowComponent:Zl,rowCount:g,rowHeight:Jl,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Zl({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:s,onHover:a}){let i=r[e];return i?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(so,{event:i,href:n?.(i),LinkComponent:s,onSelect:o,onHover:a})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui$1.Spinner,{size:"sm"})})}function ec({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui$1.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function tc({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui$1.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui$1.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function go({onKeywordChange:e}){let[t,r]=react.useState(""),[o,n]=react.useState(""),{addHistory:s}=kt(),a=hooks.useCallbackRef(e),i=hooks.useCallbackRef(s),l=react.useMemo(()=>utils.debounce(m=>{n(m),a(m),m&&i(m);},500),[a,i]),d=react.useCallback(m=>{r(m),l(m);},[l]),c=react.useCallback(m=>{l.cancel(),r(m),n(m),a(m),m&&i(m);},[l,a,i]),u=react.useCallback(()=>c(""),[c]);return {text:t,keyword:o,setText:d,setKeyword:c,clearKeyword:u}}function vo({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:s,source:a}){let{text:i,keyword:l,setText:d,setKeyword:c,clearKeyword:u}=go({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(ro,{value:i,onValueChange:d,onClear:u,onEscape:s}),!l&&jsxRuntime.jsx(to,{onSelect:c}),jsxRuntime.jsx(uo,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:a})]})}var ur="predict-search";function nf({id:e=ur}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(fc,{...t})})}function fc({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=i18n.useTranslation(),{isMobile:s}=ui$1.useScreen(),a=react.useCallback(l=>{o(l);},[o]),i=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui$1.StyledModal,{isOpen:t,onOpenChange:r,size:s?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui$1.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui$1.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsxRuntime.jsx(ui$1.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui$1.ModalBody,{className:"p-4",children:jsxRuntime.jsx(vo,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:i})})]})})}function mf({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=i18n.useTranslation(),{isDesktop:n,isMobile:s}=ui$1.useScreen(),{onOpen:a,onClose:i}=uiScaffold.useAsyncModal(ur),l=hooks.useCallbackRef(e),d=hooks.useCallbackRef(async()=>{let u=await a({params:t});u&&l(u);}),c=hooks.useCallbackRef(()=>{i();});return react.useEffect(()=>{let u=m=>{let f=document.activeElement,p=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");m.key==="/"&&!p&&(m.preventDefault(),d()),m.key==="Escape"&&(m.preventDefault(),c());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[d,c]),jsxRuntime.jsx(ui$1.Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:d,variant:s?"flat":"bordered",startContent:n?jsxRuntime.jsx(ui$1.SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsxRuntime.jsx(ui$1.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui$1.cn(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsxRuntime.jsx(ui$1.SearchIcon,{className:"text-neutral"})})}Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowKYC",{enumerable:true,get:function(){return reactPredict.useDFlowKYC}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=Fc;exports.CHART_RANGE_PERIOD=Hc;exports.CHART_RANGE_SAMPLE_INTERVAL=Bc;exports.CandlestickPeriod=st;exports.CategoriesSkeleton=Tc;exports.CategoriesUI=Cr;exports.CategoriesWidget=Rr;exports.ChartRange=te;exports.DEFAULT_CHART_RANGE=at;exports.DEFAULT_FILTER_STATE=Wt;exports.DEFAULT_PAGE_SIZE=Ue;exports.DEFAULT_PRICE_HISTORY_INTERVAL=zc;exports.EventDetailPage=Op;exports.EventDetailSkeleton=Ge;exports.EventDetailUI=Yn;exports.EventDetailWidget=qn;exports.EventItem=un;exports.EventMarketDepthChartUI=Rn;exports.EventMarketDetailWidget=Dn;exports.EventPriceChart=Un;exports.EventsFilterUI=Yr;exports.EventsPage=bu;exports.EventsPageSkeleton=$d;exports.EventsSkeleton=zt;exports.EventsToolbarUI=Qr;exports.EventsUI=xn;exports.EventsWidget=bn;exports.MAX_PRICE_HISTORY_MARKETS=It;exports.ORDER_MAX_PRICE=$c;exports.ORDER_MIN_PRICE=Wc;exports.ORDER_MIN_QUANTITY=_t;exports.ORDER_PRICE_STEP=Uc;exports.PREDICT_SEARCH_MODAL_ID=ur;exports.PREDICT_TRADE_MODAL_ID=Ut;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Kc;exports.PredictSearchModal=nf;exports.PredictTradeModal=Kr;exports.PredictWalletProvider=Qo;exports.PriceHistoryInterval=Ee;exports.SORT_PRESETS=Xr;exports.STATIC_CATEGORIES=Ot;exports.SearchEventsButton=mf;exports.SearchHistoryUI=eo;exports.SearchHistoryWidget=to;exports.SearchInputUI=ro;exports.SearchResultItemUI=so;exports.SearchResultListWidget=uo;exports.SearchWidget=vo;exports.SimilarEventCard=ul;exports.SimilarEventsSection=Gn;exports.TradeFormSkeleton=Pn;exports.TradeFormUI=$r;exports.TradeFormWidget=lt;exports.UserActivitySection=Nn;exports.countActiveFilters=$t;exports.formatWan=je;exports.useEventDetail=Fp;exports.useEventsInfinite=en;exports.usePredictSearchHistory=kt;exports.usePredictWallet=Dt;exports.useSearchResultListScript=ao;exports.useSearchScript=go;exports.useTradeForm=Fr;exports.version=Bo;//# sourceMappingURL=index.js.map
22
22
  //# sourceMappingURL=index.js.map