PageSourceSearch

https://app.valinity.io/assets/index-CSDyeR2z.js

js valinity.io collected 2026-10-02 15:22:37 UTC 72,243 bytes, 1 lines download raw bytes

1import{hi as Vs,aa as Z,aN as $e,hj as Ce,r as h,hk as Me,hl as xs,hm as kt,hn as Hs,ho as Ve,hp as Et,hq as vt,hr as tt,i as ae,hs,Y as At,aU as Gs,aO as qs,ht as Rt,b0 as De,aI as bs,ae as Q,aR as wt,aQ as st,aX as St,hu as Ks,b2 as gs,m as e,o as C,F as p,T as a,a6 as Ys,S as Ue,a3 as Xs,gv as fs,hv as Qs,hw as Ye,aF as Pt,eR as Zs,hx as Lt,aH as Js,aV as er,aW as tr,hy as sr,gt as rr,hz as or,gz as it,a$ as ms,u as le,e2 as vs,cf as jt,hA as Be,hB as Ot,B as z,bc as me,a7 as ve,bd as ws,bp as ne,cR as Fe,cS as ke,hC as Ss,hD as at,bG as js,cj as nr,hb as Ie,fn as ys,fo as Ne,fp as Cs,fq as _e,hE as ir,h9 as ze,h as Fs,N as zt,Z as ar,a4 as lr,Q as Dt,hF as cr,hG as Wt,P as dr,cW as pr,cX as ur,cY as xr,cZ as hr,ch as br,hH as lt,hI as ct}from"./index-BVQYYB-n.js";import{r as yt,V as Xe,a as gr,f as fr,b as mr,p as It,l as vr,q as Nt,c as dt,d as wr,U as pt}from"./vyPools-_OjYsxXO.js";import{u as ks,a as Es,b as As,c as Sr,f as _t,d as jr,e as Bt,t as yr,g as Cr,h as Fr,i as kr,j as Er,k as Ar,P as zr}from"./PositionsPanel-BO580_m3.js";import{u as ie,m as Ut,a as Dr,d as Mr,T as Tr}from"./TVChart-D4yMjWTU.js";import{p as $t,s as Vt,b as Rr}from"./surfaces-Ckwcw1d_.js";import{M as zs}from"./chunk-PXDTSMWR-l679wYiD.js";import{M as Ds}from"./chunk-XY72533R-zOzz_75C.js";import"./lightweight-charts.production-B6THzaiW.js";import{k as Pr}from"./aaveTransactions-829QuKfV.js";import{O as Lr}from"./OpenPositionSuccessModal-Cj-iM1KO.js";/* empty css                    */import{S as Ms,a as Ts,b as Rs,c as Ps}from"./chunk-SLN6KARO-BHh8u958.js";import{C as Ls}from"./chunk-VFYM6BU6-CzihccTZ.js";import{B as Or}from"./chunk-FQXH56BT-BQCRYl0s.js";var Wr=Vs({d:"M23.384,21.619,16.855,15.09a9.284,9.284,0,1,0-1.768,1.768l6.529,6.529a1.266,1.266,0,0,0,1.768,0A1.251,1.251,0,0,0,23.384,21.619ZM2.75,9.5a6.75,6.75,0,1,1,6.75,6.75A6.758,6.758,0,0,1,2.75,9.5Z",displayName:"SearchIcon"});function Os(t=!0){return Z({queryKey:["perps","ethUsd"],enabled:t,queryFn:async()=>{const s=await $e().allMids(),o=parseFloat(s.ETH);return Number.isFinite(o)&&o>0?o:void 0},staleTime:15e3,refetchInterval:15e3})}function Ir(t=!0){return Z({queryKey:["vylev","spotUsd"],enabled:t,queryFn:async()=>({vyUsd:await yt(Ce())}),refetchInterval:1e4,staleTime:8e3})}const Nr={coin:vt,symbol:vt,category:"crypto",maxLeverage:2,szDecimals:4};function Mt(){return Z({queryKey:["perps","catalog"],staleTime:5*6e4,queryFn:async()=>
1{const t=$e(),[s,o]=await Promise.all([t.meta(),t.meta({dex:kt}).catch(()=>({universe:[]}))]),r=[...s.universe,...o.universe].filter(n=>!n.isDelisted&&!Hs.has(n.name)).map(n=>({coin:n.name,symbol:Ve(n.name),category:Et(n.name),maxLeverage:n.maxLeverage,szDecimals:n.szDecimals}));return[Nr,...r]}})}function _r(t){const[s,o]=h.useState({coin:t});return h.useEffect(()=>{let r=!0,n;if(o({coin:t}),Me(t)==="hl")return xs().activeAssetCtx({coin:t},d=>{r&&o({coin:t,ctx:d.ctx})}).then(d=>{n=d,r||d.unsubscribe()}).catch(()=>{}),()=>{r=!1,n==null||n.unsubscribe()}},[t]),s.coin===t?s.ctx:void 0}function Ws(t){var l;const s=Me(t)==="vylev",o=_r(t),r=Ir(s);if(s)return{mark:(l=r.data)==null?void 0:l.vyUsd,prevDay:void 0,changePct:void 0,ctx:void 0};const n=o!=null&&o.markPx?parseFloat(o.markPx):void 0,d=o!=null&&o.prevDayPx?parseFloat(o.prevDayPx):void 0,c=n!==void 0&&d?(n-d)/d*100:void 0;return{mark:n,prevDay:d,changePct:c,ctx:o}}const Br=tt("event LongLevered(address indexed user, uint256 usdcIn, uint8 loops, uint256 vyLong, uint256 marginHeld)"),Ur=tt("event ShortLevered(address indexed user, uint256 usdcIn, uint8 loops, uint256 vyShort, uint256 marginHeld)"),$r=tt("event LongClosed(address indexed user, uint16 fractionBps, uint256 returnedUsdc, uint256 carryPaid)"),Vr=tt("event ShortClosed(address indexed user, uint16 fractionBps, uint256 returnedUsdc, uint256 carryPaid)"),Ht=300000n;async function Hr(t){const s=hs(),o=await s.getBlockNumber(),r=o>Ht?o-Ht:0n,[n,d,c,l]=await Promise.all([s.getLogs({address:Xe,event:Br,args:{user:t},fromBlock:r,toBlock:o}),s.getLogs({address:Xe,event:Ur,args:{user:t},fromBlock:r,toBlock:o}),s.getLogs({address:Xe,event:$r,args:{user:t},fromBlock:r,toBlock:o}),s.getLogs({address:Xe,event:Vr,args:{user:t},fromBlock:r,toBlock:o})]),g=[...[...n,...d].map(m=>({block:m.blockNumber,side:"buy"})),...[...c,...l].map(m=>({block:m.blockNumber,side:"sell"}))].filter(m=>m.block!=null);if(!g.length)return[];const i=[...new Set(g.map(m=>m.block))],b=new Map;return await Promise.all(i.map(async m=>{try{const[v,j]=await Promise.all([s.getBlock({blockNumber:m}),gr(Ce(),m)]);j>0&&b.set(m,{time:Number(v.timestamp)*1e3,price:j})}catch{}})),g.map(m=>{const v=b.get(m.block);return v?{time:v.time,price:v.price,side:m.side}:null}).filter(m=>m!==null).sort((m,v)=>m.time-v.time)}async function Gr(t,s){return(await $e().userFills({user:t})??[]).filter(r=>r.coin===s).map(r=>({time:r.time,price:parseFloat(r.px),side:r.side==="B"?"buy":"sell"})).filter(r=>Number.isFinite(r.price)&&r.price>0).sort((r,n)=>r.time-n.time)}function qr(t){const{address:s}=ae();return Z({queryKey:["perps","marks",t,s],enabled:!!s&&!!t,staleTime:6e4,gcTime:3e5,refetchOnWindowFocus:!1,queryFn:async()=>{const o=s;return Me(t)==="vylev"?Hr(o):Gr(o,t)}})}function Kr(t=100){const{address:s}=ae();return Z({queryKey:["perps","history",s],enabled:!!s,refetchInterval:2e4,queryFn:async()=>(await $e().userFills({user:s})??[]).map(r=>{const n=Math.abs(parseFloat(r.sz)),d=parseFloat(r.px),c=r.dir??"";return{id:`${r.tid}`,time:r.time,coin:r.coin,symbol:Ve(r.coin),dir:c,isClose:/close|liquidat/i.test(c),size:n,price:d,value:n*d,pnl:parseFloat(r.closedPnl??"0"),fee:parseFloat(r.fee??"0")}}).filter(r=>Number.isFinite(r.price)&&r.price>0).sort((r,n)=>n.time-r.time).slice(0,t)})}function Yr(t){if(gs(t))return t;const o=(t instanceof Error?t.message:String(t??"")).replace(/\s+/g," ").trim().slice(0,200);return new St(o?`Withdraw failed: ${o}`:"Withdraw failed — please try again.")}const Gt=[{type:"function",name:"calculateCrossChainWithdrawalFee",stateMutability:"view",inputs:[{name:"shouldForward",type:"bool"},{name:"destinationChainId",type:"uint32"}],outputs:[{name:"maxFee",type:"uint256"}]},{type:"function",name:"paused",stateMutability:"view",inputs:[],outputs:[{type:"bool"}]}],Xr=new Set(["unifiedAccount","portfolioMargin"]);function rt(){const{address:t}=ae();return Z({queryKey:["perps","account",t],enabled:!!t,refetchInterval:15e3,queryFn:async()=>{const s=$e(),o=t,[r,n,d]=await Promise.all([s.clearinghouseState({user:o}),s.clearinghouseState({user:o,dex:kt}).catch(()=>null),s.userAbstraction({user:o}).catch(()=>"default")]),c=[r,n].flatMap(b=>(b==null?void 0:b.assetPositions)??[]).reduce((b,{position:m})=>b+parseFloat(m.marginUsed)+parseFloat(m.unrealizedPnl),0);let l=parseFloat(r.marginSummary.accountValue),g=parseFloat(r.withdrawable),i="";if(Xr.has(d)){const b=await s.spotClearinghouseState({user:o}).catch(()=>null),m=b==null?void 0:b.balances.find(j=>j.coin==="USDC"),v=parseFloat((m==null?void 0:m.total)??"0");v>0&&(l=v,g=Math.max(0,v-parseFloat((m==null?void 0:m.hold)??"0")),i="spot")}return{accountValue:l,available:Math.max(0,l-Math.max(0,c)),withdrawable:g,withdrawSourceDex:i,inPositions:Math.max(0,c)}}})}async function Is(){const t=qs(),[s,o]=await Promise.all([t.readContract({address:Rt,abi:Gt,functionName:"
1calculateCrossChainWithdrawalFee",args:[!0,De.ethereum]}),t.readContract({address:Rt,abi:Gt,functionName:"paused"})]);return{fee:Number(s)/1e6,paused:o}}function Qr(){return Z({queryKey:["perps","withdrawFee"],queryFn:Is,staleTime:3e4,refetchInterval:6e4})}function Zr(){const t=At(),{address:s}=ae(),o=Gs(),[r,n]=h.useState("idle"),[d,c]=h.useState(),l=h.useRef(0n),g=h.useRef(!1),i=async()=>await bs(t,{chainId:Q,abi:wt,address:st[Q],functionName:"balanceOf",args:[s]}),b=Z({queryKey:["perps","withdrawArrival",s],enabled:r==="arriving"&&!!s,refetchInterval:4e3,queryFn:i});return h.useEffect(()=>{r==="arriving"&&b.data!==void 0&&b.data>l.current&&n("success")},[r,b.data]),{execute:async(j,f,w="")=>{if(!(!o||!s)&&!g.current){g.current=!0;try{c(void 0),n("submitting");const[{fee:A,paused:L},R]=await Promise.all([Is(),i()]);if(L)throw new St("Withdrawals are temporarily paused by the bridge operator. Your funds are safe — please try again later.");if(!(parseFloat(j)>A+.3))throw new St(`The amount must exceed the ${A.toFixed(2)} USDC network fee with margin. Please withdraw a larger amount.`);l.current=R,await o.sendToEvmWithData({token:Ks,amount:j,sourceDex:w,destinationRecipient:f??s,addressEncoding:"hex",destinationChainId:De.ethereum,gasLimit:2e5,data:"0x"}),n("arriving")}catch(A){c(Yr(A)),n("error")}finally{g.current=!1}}},reset:()=>{n("idle"),c(void 0)},step:r,error:d}}const Jr=({state:t})=>t==="done"?e.jsx(p,{boxSize:"22px",flexShrink:0,align:"center",justify:"center",rounded:"full",bgGradient:"linear(to-b, gold.300, gold.500)",boxShadow:"0 1px 2px rgba(12,15,20,0.25)",children:e.jsx(a,{fontSize:"12px",fontWeight:"900",color:"#0C0F14",lineHeight:"1",children:"✓"})}):t==="active"?e.jsx(p,{boxSize:"22px",flexShrink:0,align:"center",justify:"center",rounded:"full",bg:"white",borderWidth:"1px",borderColor:"blue.200",children:e.jsx(Ue,{size:"xs",color:"blue.500",thickness:"2px",speed:"0.7s"})}):e.jsx(p,{boxSize:"22px",flexShrink:0,align:"center",justify:"center",rounded:"full",bg:"white",borderWidth:"2px",borderColor:"gray.300",children:e.jsx(C,{boxSize:"6px",rounded:"full",bg:"gray.300"})}),eo=({def:t,last:s})=>e.jsxs(p,{gap:3,align:"stretch",children:[e.jsxs(p,{direction:"column",align:"center",children:[e.jsx(Jr,{state:t.state}),!s&&e.jsx(C,{w:"2px",flex:"1",minH:"14px",my:"3px",borderRadius:"full",bg:t.state==="done"?"gold.400":"gray.200"})]}),e.jsxs(C,{pt:"1px",pb:s?0:3,children:[e.jsx(a,{fontSize:"14px",fontWeight:"700",lineHeight:"1.2",color:t.state==="pending"?"gray.400":"#0C0F14",children:t.title}),e.jsx(a,{fontSize:"12px",color:"gray.500",mt:"2px",children:t.sub}),t.href&&t.linkLabel&&e.jsxs(Ys,{fontSize:"12px",fontWeight:"600",color:"blue.500",href:t.href,isExternal:!0,mt:"3px",display:"inline-block",children:[t.linkLabel," ↗"]})]})]}),Ns=({steps:t})=>e.jsx(C,{children:t.map((s,o)=>e.jsx(eo,{def:s,last:o===t.length-1},o))}),_s=1e3;function to(t,s){return rr([fs(or,{size:24,dir:"right"}),it(0,{size:4}),it(24,{size:4}),t,it(s>>>0,{size:4})])}async function Bs(){var n;const t=`${ms}/v2/burn/USDC/fees/${De.ethereum}/${De.hyperEVM}?forward=true`,s=await fetch(t);if(!s.ok)throw new Error("Could not fetch the deposit fee quote");const o=await s.json(),r=o.find(d=>d.finalityThreshold===_s)??o[0];return{forwardFee:BigInt(((n=r==null?void 0:r.forwardFee)==null?void 0:n.high)??0),protocolFeeBps:(r==null?void 0:r.minimumFee)??0}}const so=4n,qt=400000n;function ro(t){const s=((t==null?void 0:t.forwardFee)??0n)*so;return s>qt?s:qt}function Us(t,s){return ro(s)+t*BigInt((s==null?void 0:s.protocolFeeBps)??0)/10000n}function oo(){return Z({queryKey:["perps","depositFee"],queryFn:Bs,staleTime:3e4,refetchInterval:6e4})}const no=3*60*60*1e3,Tt=t=>`hl:deposit:${t.toLowerCase()}`;function io(t,s){try{localStorage.setItem(Tt(t),JSON.stringify(s))}catch{}}function ao(t){if(t)try{const s=localStorage.getItem(Tt(t));return s?JSON.parse(s):void 0}catch{return}}function Qe(t){if(t)try{localStorage.removeItem(Tt(t))}catch{}}async function lo(t){var d;const s=`${ms}/v2/messages/${De.ethereum}?transactionHash=${t}`,o=await fetch(s);if(!o.ok)return{forwarded:!1};const n=(d=(await o.json()).messages)==null?void 0:d[0];return{forwarded:!!(n!=null&&n.forwardTxHash),forwardTxHash:n==null?void 0:n.forwardTxHash,status:n==null?void 0:n.status}}function co(){var j,f;const t=At(),{address:s}=ae(),[o,r]=h.useState("idle"),[n,d]=h.useState(),[c,l]=h.useState(),g=h.useRef(!1),i=h.useRef(void 0);h.useEffect(()=>{if(i.current===s)return;const w=i.current!==void 0&&i.current!==s;i.current=s,w&&(r("idle"),d(void 0),l(void 0));const A=ao(s);if(A){if(Date.now()-A.startedAt>no){Qe(s);return}d(A.burnTxHash),r("forwarding")}},[s]);const b=Z({queryKey:["perps","depositStatus",n],queryFn:()=>lo(n),enabled:!!n&&o==="forwarding",refetchInterval:5e3});return h.useEffect(()=>{var w;o==="forwarding"&&((w=b.data)!=null&&w.forwarded)&&(Qe(s),r("success"))},[o,(j=b.data)==null?void 0:j.forwarded,s]),{execute:async(w,A=sr.perps)=>{if(!s||g.current)return;g.current=!0;const L=st[Q];try{l(void 0),r("approving"),await Xs(t,{chainId:Q});const R=await Bs(),G=Us(w,R),M=fs(Qs,{size:32}),F=[w,De.hyperEVM,M,L,M,G,_s,to(s,A)];r("approving");const U=await bs(t,{chainId:Q,abi:wt,address:L,functionName:"allowance",args:[s,Ye]}),q=[],N=U<w;N&&q.push({to:L,data:Pt({abi:wt,functionName:"approve",args:[Ye,Zs]})});const J=q.length;q.push({to:Ye,data:Pt({abi:Lt,functionName:"depositForBurnWithHook",args:F})}),r("burning");const k=await Js(t,{chainId:Q,from:s,calls:q}),$=(O,S)=>{if(d(O),io(s,{burnTxHash:O,amount:w.toString(),startedAt:Date.now()}),S)throw Qe(s),new Error("The deposit transaction reverted on-chain. Please try again.");r("forwarding")},_=k.hashes[J],se=k.receipts[J];if(k.status===200){_?$(_,!1):r("forwarding");return}if(N){const O=k.receipts[0];if(O&&O.status!=="success")throw new Error("The approval transaction reverted on-chain. Please try again.")}if(_){$(_,(se==null?void 0:se.status)==="reverted");return}const he=await er(t,{chainId:Q,abi:Lt,address:Ye,functionName:"depositForBurnWithHook",args:F}),ce=await tr(t,{chainId:Q,hash:he});$(he,ce.status!=="success")}catch(R){l(R),r("error")}finally{g.current=!1}},reset:()=>{Qe(s),r("idle"),d(void 0),l(void 0)},step:o,burnTxHash:n,forwardTxHash:(f=b.data)==null?void 0:f.forwardTxHash,error:c}}const po=/^\d*\.?\d*$/,ut=t=>
1parseFloat(ne(t,Be)).toLocaleString(void 0,{maximumFractionDigits:2}),uo=()=>{var J;const{t}=le(),{address:s}=ae(),[o,r]=h.useState(""),n=vs({address:s,token:st[Q],chainId:Q}),d=oo(),c=co(),{resolved:l}=ks(),g=Es(l==null?void 0:l.builder),i=As(),{mutate:b}=i,m=h.useRef(!1),v=g.isApproved||i.isSuccess,f=(((J=rt().data)==null?void 0:J.accountValue)??0)>0;h.useEffect(()=>{c.step==="idle"&&(m.current=!1),c.step==="success"&&f&&(l!=null&&l.builder)&&g.isFetched&&!g.isApproved&&!m.current&&(m.current=!0,b(l.builder))},[c.step,f,l==null?void 0:l.builder,g.isFetched,g.isApproved,b]);const w=h.useMemo(()=>{if(!o)return null;try{const k=jt(o,Be);return k>0n?k:null}catch{return null}},[o]),A=w?Us(w,d.data):0n,L=w&&w>A?w-A:0n,R=jt(String(Ot),Be),G=!!w&&L<R,M=!!w&&!!n.data&&w>n.data.value,F=c.step==="approving"||c.step==="burning",U=!w||G||M||F||L===0n,q=k=>{(k===""||po.test(k))&&r(k)},N=c.step==="approving"?t("views.perps.deposit.approving"):c.step==="burning"?t("views.perps.deposit.depositing"):t("views.perps.deposit.cta");if(c.step==="forwarding"||c.step==="success"){const k=c.step==="success",$=k&&f,_=[{state:"done",title:t("views.perps.deposit.stepBurnTitle"),sub:t("views.perps.deposit.stepBurnSub"),href:c.burnTxHash?`https://etherscan.io/tx/${c.burnTxHash}`:void 0,linkLabel:t("views.perps.deposit.viewTx")},{state:k?"done":"active",title:t("views.perps.deposit.stepMintTitle"),sub:t("views.perps.deposit.stepMintSub"),href:c.forwardTxHash?`https://hyperevmscan.io/tx/${c.forwardTxHash}`:void 0,linkLabel:t("views.perps.deposit.viewMintTx")},{state:k?$?"done":"active":"pending",title:t("views.perps.deposit.stepCreditTitle"),sub:t("views.perps.deposit.stepCreditSub")}];return e.jsxs(p,{direction:"column",gap:3,align:"stretch",children:[e.jsx(a,{fontSize:"15px",fontWeight:"800",color:"#0C0F14",children:t($?"views.perps.deposit.creditedTitle":"views.perps.deposit.processingTitle")}),e.jsx(Ns,{steps:_}),e.jsx(a,{fontSize:"12px",color:"gray.500",children:t($?"views.perps.deposit.creditedBody":"views.perps.deposit.processingBody")}),k&&e.jsx(p,{align:"center",gap:2,px:3,py:2,borderRadius:"lg",bg:"rgba(255,251,242,0.92)",borderWidth:"1px",borderColor:"gold.300",w:"100%",children:v?e.jsxs(e.Fragment,{children:[e.jsx(p,{boxSize:"16px",align:"center",justify:"center",rounded:"full",bgGradient:"linear(to-b, gold.300, gold.500)",children:e.jsx(a,{fontSize:"10px",fontWeight:"900",color:"#0C0F14",lineHeight:"1",children:"✓"})}),e.jsx(a,{fontSize:"12px",fontWeight:"700",color:"gold.800",children:t("views.perps.deposit.tradingActivated")})]}):i.isError?e.jsxs(e.Fragment,{children:[e.jsx(a,{fontSize:"12px",color:"gold.800",flex:1,children:t("views.perps.deposit.activateNeeded")}),e.jsx(z,{size:"xs",borderRadius:"full",colorScheme:"yellow",isLoading:i.isPending,onClick:()=>l&&b(l.builder),children:t("views.perps.deposit.activateCta")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{size:"sm",color:"gold.500"}),e.jsx(a,{fontSize:"12px",fontWeight:"600",color:"gold.800",children:t("views.perps.deposit.activating")})]})}),e.jsx(z,{mt:1,size:"sm",borderRadius:"full",variant:"outline",alignSelf:"flex-start",onClick:c.reset,children:t("views.perps.deposit.newDeposit")})]})}return e.jsxs(p,{direction:"column",gap:3,children:[e.jsx(p,{justify:"flex-end",children:n.data&&e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.deposit.balance",{amount:ut(n.data.value)})})}),e.jsxs(me,{children:[e.jsx(ve,{value:o,onChange:k=>q(k.target.value),placeholder:"0.00",inputMode:"decimal",fontSize:"20px",fontWeight:"700",h:"3.25rem",bg:"white",borderColor:"spaceGray.300",_focusVisible:{borderColor:"gold.500",boxShadow:"0 0 0 1px var(--chakra-colors-gold-500)"}}),e.jsx(ws,{width:"4.5rem",h:"3.25rem",children:e.jsx(z,{h:"1.7rem",size:"xs",variant:"ghost",colorScheme:"gray",onClick:()=>n.data&&r(ne(n.data.value,Be)),children:t("views.perps.deposit.max")})})]}),w!=null&&!G&&!M&&e.jsxs(p,{direction:"column",gap:1.5,px:1,children:[e.jsxs(p,{justify:"space-between",children:[e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.deposit.networkFee")}),e.jsxs(a,{fontSize:"12px",color:"gray.700",children:["≈ ",ut(A)," USDC"]})]}),e.jsxs(p,{justify:"space-between",children:[e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.deposit.youReceive")}),e.jsxs(a,{fontSize:"13px",color:"#0C0F14",fontWeight:"700",children:["≈ ",ut(L)," USDC"]})]})]}),G&&e.jsxs(Fe,{status:"warning",borderRadius:"md",fontSize:"12px",py:2,children:[e.jsx(ke,{}),t("views.perps.deposit.belowMin",{min:Ot})]}),M&&e.jsxs(Fe,{status:"warning",borderRadius:"md",fontSize:"12px",py:2,children:[e.jsx(ke,{}),t("views.perps.deposit.insufficient")]}),c.step==="error"&&c.error&&e.jsxs(Fe,{status:"error",borderRadius:"md",fontSize:"12px",py:2,children:[e.jsx(ke,{}),Ss(c.error,"ETH")]}),e.jsx(z,{borderRadius:"full",size:"lg",h:"3rem",isDisabled:U,isLoading:F,loadingText:N,onClick:()=>w&&c.execute(w),children:N}),e.jsx(C,{children:e.jsx(a,{fontSize:"11px",color:"gray.400",lineHeight:"1.4",children:t("views.perps.deposit.note")})})]})},xo=/^\d*\.?\d*$/,Ae=t=>
1t.toLocaleString(void 0,{maximumFractionDigits:2}),ho=()=>{var R,G,M;const{t}=le(),[s,o]=h.useState(""),r=rt(),n=Qr(),d=Zr(),c=((R=r.data)==null?void 0:R.withdrawable)??0,l=((G=n.data)==null?void 0:G.fee)??0,g=((M=n.data)==null?void 0:M.paused)??!1,i=s?parseFloat(s):0,b=Math.max(0,c-at),m=l>0?l+.3:0,v=i>l?i-l:0,j=i>b,f=s!==""&&i>0&&m>0&&i<=m,w=d.step==="submitting",A=!i||i<=0||j||f||w||g,L=F=>{(F===""||xo.test(F))&&o(F)};if(d.step==="arriving"||d.step==="success"){const F=d.step==="success",U=[{state:"done",title:t("views.perps.withdraw.stepSendTitle"),sub:t("views.perps.withdraw.stepSendSub")},{state:F?"done":"active",title:t("views.perps.withdraw.stepBridgeTitle"),sub:t("views.perps.withdraw.stepBridgeSub")},{state:F?"done":"pending",title:t("views.perps.withdraw.stepArriveTitle"),sub:t("views.perps.withdraw.stepArriveSub")}];return e.jsxs(p,{direction:"column",gap:3,align:"stretch",children:[e.jsx(a,{fontSize:"15px",fontWeight:"800",color:"#0C0F14",children:t(F?"views.perps.withdraw.arrivedTitle":"views.perps.withdraw.submittedTitle")}),e.jsx(Ns,{steps:U}),e.jsx(a,{fontSize:"12px",color:"gray.500",children:t(F?"views.perps.withdraw.arrivedBody":"views.perps.withdraw.submittedBody")}),e.jsx(z,{mt:1,size:"sm",borderRadius:"full",variant:"outline",alignSelf:"flex-start",onClick:d.reset,children:t("views.perps.withdraw.newWithdraw")})]})}return e.jsxs(p,{direction:"column",gap:3,children:[e.jsx(p,{justify:"flex-end",children:e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.withdraw.available",{amount:Ae(c)})})}),e.jsxs(me,{children:[e.jsx(ve,{value:s,onChange:F=>L(F.target.value),placeholder:"0.00",inputMode:"decimal",fontSize:"20px",fontWeight:"700",h:"3.25rem",bg:"white",borderColor:"spaceGray.300",_focusVisible:{borderColor:"gold.500",boxShadow:"0 0 0 1px var(--chakra-colors-gold-500)"}}),e.jsx(ws,{width:"4.5rem",h:"3.25rem",children:e.jsx(z,{h:"1.7rem",size:"xs",variant:"ghost",colorScheme:"gray",onClick:()=>o(b>0?String(Math.floor(b*100)/100):""),children:t("views.perps.withdraw.max")})})]}),i>0&&!j&&v>0&&e.jsxs(p,{direction:"column",gap:1.5,px:1,children:[e.jsxs(p,{justify:"space-between",children:[e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.withdraw.hlFee")}),e.jsxs(a,{fontSize:"12px",color:"gray.700",children:["≈ ",Ae(at)," USDC"]})]}),e.jsxs(p,{justify:"space-between",children:[e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.withdraw.networkFee")}),e.jsxs(a,{fontSize:"12px",color:"gray.700",children:["≈ ",Ae(l)," USDC"]})]}),e.jsxs(p,{justify:"space-between",children:[e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.withdraw.youReceive")}),e.jsxs(a,{fontSize:"13px",color:"#0C0F14",fontWeight:"700",children:["≈ ",Ae(v)," USDC"]})]})]}),f&&e.jsxs(Fe,{status:"warning",borderRadius:"md",fontSize:"12px",py:2,children:[e.jsx(ke,{}),t("views.perps.withdraw.belowFee",{fee:Ae(m)})]}),g&&e.jsxs(Fe,{status:"warning",borderRadius:"md",fontSize:"12px",py:2,children:[e.jsx(ke,{}),t("views.perps.withdraw.paused")]}),j&&e.jsxs(Fe,{status:"warning",borderRadius:"md",fontSize:"12px",py:2,children:[e.jsx(ke,{}),t("views.perps.withdraw.overBalance",{reserve:Ae(at)})]}),d.step==="error"&&d.error&&e.jsxs(Fe,{status:"error",borderRadius:"md",fontSize:"12px",py:2,children:[e.jsx(ke,{}),Ss(d.error,"HYPE")]}),e.jsx(z,{borderRadius:"full",size:"lg",h:"3rem",isDisabled:A,isLoading:w,loadingText:t("views.perps.withdraw.submitting"),onClick:()=>{var F;return s&&d.execute(s,void 0,((F=r.data)==null?void 0:F.withdrawSourceDex)??"")},children:t("views.perps.withdraw.cta")}),e.jsx(C,{children:e.jsx(a,{fontSize:"11px",color:"gray.400",lineHeight:"1.4",children:t("views.perps.withdraw.note")})})]})},xt=t=>t===void 0?"—":t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),bo=()=>{var g,i,b,m;const{t}=le(),[s,o]=h.useState("deposit"),{address:r}=ae(),n=ie(v=>v.coin),d=rt(),c=vs({address:r,token:st[Q],chainId:Q}),l=c.data?parseFloat(ne(c.data.value,Be)):void 0;return Me(n)==="vylev"?e.jsxs(C,{rounded:"2xl",borderWidth:"1px",borderColor:"spaceGray.300",bgGradient:$t,boxShadow:Vt,p:6,children:[e.jsx(a,{fontSize:"15px",fontWeight:"800",color:"blue.800",mb:2,children:"VALINITY"}),e.jsx(a,{fontSize:"13px",color:"blackAlpha.700",lineHeight:1.6,children:t("views.perps.vylev.fundsNote","Valinity leverage positions are funded directly from your connected wallet — no deposit needed. One-tap USDC trading unlocks shortly.")})]}):e.jsx(p,{direction:"column",gap:3,children:e.jsxs(C,{position:"relative",rounded:"2xl",overflow:"hidden",borderWidth:"1px",borderColor:"spaceGray.300",bgGradient:$t,boxShadow:Vt,children:[e.jsx(C,{position:"absolute",inset:0,bgGradient:Rr,pointerEvents:"none"}),e.jsxs(p,{direction:"column",position:"relative",p:5,gap:5,children:[e.jsxs(p,{direction:"column",gap:1,children:[e.jsx(a,{fontSize:"11px",fontWeight:"800",letterSpacing:"0.14em",textTransform:"uppercase",color:"gold.600",children:t("views.perps.funds.balanceLabel")}),e.jsxs(a,{fontSize:"36px",fontWeight:"800",lineHeight:"1",color:"#0C0F14",letterSpacing:"-0.5px",sx:{fontVariantNumeric:"tabular-nums lining-nums"},children:["$",xt((g=d.data)==null?void 0:g.accountValue)]}),e.jsx(p,{mt:2,borderRadius:"lg",borderWidth:"1px",borderColor:"blackAlpha.100",bg:"blackAlpha.50",overflow:"hidden",children:[{key:"available",amount:(i=d.data)==null?void 0:i.available,color:"#0C0F14"},{key:"inPositions",amount:(b=d.data)==null?void 0:b.inPositions,color:"gold.600"}].map((v,j)=>e.jsxs(C,{flex:1,px:3,py:2,borderLeftWidth:j?"1px":0,borderColor:"blackAlpha.100",children:[e.jsx(a,{fontSize:"10px",fontWeight:"700",letterSpacing:"0.06em",textTransform:"uppercase",color:"gray.500",children:t(`views.perps.funds.${v.key}`)}),e.jsxs(a,{fontSize:"15px",fontWeight:"800",color:v.color,sx:{fontVariantNumeric:"tabular-nums"},children:["$",xt(v.amount)]})]},v.key))}),(((m=d.data)==null?void 0:m.inPositions)??0)>0&&e.jsx(a,{fontSize:"11px",color:"gray.500",mt:1,children:t("views.perps.funds.inPositionsNote")}),l!==void 0&&e.jsxs(p,{align:"center",gap:2,mt:1,flexWrap:"wrap",children:[e.jsx(a,{fontSize:"10px",color:"gold.500",children:"●"}),e.jsx(a,{fontSize:"12px",color:"gray.500",children:t("views.perps.funds.ethReady",{amount:xt(l)})})]})]}),e.jsx(p,{bg:"rgba(0,0,0,0.05)",p:"4px",borderRadius:"full",boxShadow:"inset 0 1px 3px rgba(12,15,20,0.16), inset 0 -1px 0 rgba(255,255,255,0.6)",children:["deposit","withdraw"].map(v=>{const j=s===v;return e.jsx(z,{flex:1,size:"sm",h:"2rem",borderRadius:"full",fontWeight:"700",fontSize:"13px",color:j?"#0C0F14":"blackAlpha.600",bgGradient:j?"linear(to-b, #FFFFFF, #F6F7F9)":void 0,bg:j?void 0:"transparent",boxShadow:j?"0 1px 1px rgba(12,15,20,0.04), 0 4px 10px -4px rgba(12,15,20,0.2), inset 0 1px 0 rgba(255,255,255,0.9)":"none",_hover:{bg:j?void 0:"blackAlpha.50"},_active:{},onClick:()=>o(v),children:t(`views.perps.funds.${v}`)},v)})}),e.jsx(C,{display:s==="deposit"?"block":"none",children:e.jsx(uo,{})}),e.jsx(C,{display:s==="withdraw"?"block":"none",children:e.jsx(ho,{})})]})]})})},go={EUR:"eu",GBP:"gb",JPY:"jp",KRW:"kr",DXY:"us"},fo={AAPL:"apple.com",MSFT:"microsoft.com",NVDA:"nvidia.com",TSLA:"tesla.com",AMZN:"amazon.com",GOOGL:"google.com",META:"meta.com",AMD:"amd.com",INTC:"intel.com",MU:"micron.com",ORCL:"oracle.com",AVGO:"broadcom.com",QCOM:"qualcomm.com",IBM:"ibm.com",DELL:"dell.com",AMAT:"appliedmaterials.com",MRVL:"marvell.com",WDC:"westerndigital.com",NOW:"servicenow.com",PLTR:"palantir.com",COIN:"coinbase.com",HOOD:"robinhood.com",MSTR:"microstrategy.com",CRCL:"circle.com",NFLX:"netflix.com",COST:"costco.com",LLY:"lilly.com",RIVN:"rivian.com",GME:"gamestop.com",DKNG:"draftkings.com",HIMS:"hims.com",EBAY:"ebay.com",ZM:"zoom.com",BX:"blackstone.com",RKLB:"rocketlabusa.com",NBIS:"nebius.com",BE:"bloomenergy.com",CRWV:"coreweave.com",BB:"blackberry.com",SNDK:"sandisk.com",ARM:"arm.com",LITE:"lumentum.com",SPCX:"spacex.
1com",BABA:"alibaba.com",TSM:"tsmc.com",ASML:"asml.com",NOK:"nokia.com",SMSN:"samsung.com",SKHX:"skhynix.com",SKHY:"skhynix.com",SOFTBANK:"softbank.jp",HYUNDAI:"hyundai.com",KIOXIA:"kioxia.com",IBIDEN:"ibiden.com",GIGADEV:"gigadevice.com"},mo=new Set(["SP500","JP225","NIFTY","KR200","IBOV","VIX","SMH","XLE","EWY","EWJ","EWZ","EWT","URNM","XYZ100"]),vo=t=>{const s=fo[t];return[...s?[`https://logo.clearbit.com/${s}`]:[],`https://assets.parqet.com/logos/symbol/${t}`,`https://financialmodelingprep.com/image-stock/${t}.png`,`https://eodhd.com/img/logos/US/${t.toLowerCase()}.png`]},wo={GOLD:["#FFE59A","#D9A11B"],SILVER:["#F1F4F8","#B4BCC6"],PLATINUM:["#EAF1F3","#A6B4BB"],PALLADIUM:["#ECECF4","#ADADBD"],COPPER:["#F6C6A0","#B5652E"],ALUMINIUM:["#EEF1F4","#C0C6CD"]},So=new Set(["CL","BRENTOIL"]),jo=new Set(["NATGAS","TTF"]),yo={CORN:"🌽",WHEAT:"🌾",URANIUM:"☢️"},Kt=({light:t,dark:s,size:o})=>{const r=h.useId();return e.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0",stopColor:t}),e.jsx("stop",{offset:"1",stopColor:s})]})}),e.jsx("path",{d:"M8 8.5 H16 L19.5 15.5 H4.5 Z",fill:`url(#${r})`,stroke:s,strokeWidth:"0.6",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 8.5 H16 L14.8 11 H9.2 Z",fill:t,opacity:"0.55"})]})},Co=({size:t})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M12 3.5 C12 3.5 6.5 10.5 6.5 15 a5.5 5.5 0 0 0 11 0 C17.5 10.5 12 3.5 12 3.5 Z",fill:"#23262B"}),e.jsx("path",{d:"M9.6 14.4 a2.6 2.6 0 0 0 2 4.2",stroke:"rgba(255,255,255,0.35)",strokeWidth:"1.1",fill:"none",strokeLinecap:"round"})]}),Fo=({size:t})=>{const s=h.useId();return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:s,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0",stopColor:"#9BD8FF"}),e.jsx("stop",{offset:"0.6",stopColor:"#3B82F6"}),e.jsx("stop",{offset:"1",stopColor:"#1D4ED8"})]})}),e.jsx("path",{d:"M12 2.5 C12 2.5 7 7.5 7 13 a5 5 0 0 0 10 0 c0 -2 -1 -3.6 -2.2 -5 c-.4 1.5 -1.4 2.1 -2.4 2.1 C13.6 8.4 13 5.4 12 2.5 Z",fill:`url(#${s})`})]})}
1,ko=({symbol:t,size:s})=>{const o=wo[t];if(o)return e.jsx(Kt,{light:o[0],dark:o[1],size:s});if(So.has(t))return e.jsx(Co,{size:s});if(jo.has(t))return e.jsx(Fo,{size:s});const r=yo[t];return r?e.jsx(a,{fontSize:`${Math.round(s*.58)}px`,lineHeight:"1",children:r}):e.jsx(Kt,{light:"#EEF1F4",dark:"#B7BEC7",size:s})},Eo=({size:t})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:[e.jsx("rect",{x:"4.8",y:"13",width:"3.6",height:"6",rx:"1",fill:"#274156"}),e.jsx("rect",{x:"10.2",y:"9.5",width:"3.6",height:"9.5",rx:"1",fill:"#274156"}),e.jsx("rect",{x:"15.6",y:"6",width:"3.6",height:"13",rx:"1",fill:"#C8A24C"})]}),Ao=t=>{let s=0;for(let o=0;o<t.length;o++)s=s*31+t.charCodeAt(o)>>>0;return s%360},zo=({label:t,size:s})=>{const o=Ao(t||"?");return e.jsx(p,{boxSize:`${s}px`,align:"center",justify:"center",borderRadius:"full",sx:{background:`linear-gradient(to bottom, hsl(${o} 52% 58%), hsl(${o} 58% 40%))`},children:e.jsx(a,{fontWeight:"800",fontSize:`${Math.max(9,Math.round(s*.36))}px`,color:"white",letterSpacing:"-0.03em",lineHeight:"1",children:t.slice(0,2)})})},ht=({urls:t,alt:s,fallback:o})=>{const[r,n]=h.useState(0),d=t.join("|");return h.useEffect(()=>{n(0)},[d]),t.length===0||r>=t.length?o:e.jsx(js,{src:t[r],alt:s,w:"100%",h:"100%",objectFit:"cover",sx:{display:"block",transform:"translateZ(0)"},fallback:o,onError:()=>n(c=>c+1)})},Yt=({coin:t,size:s=32,elevated:o=!1})=>{const r=Et(t),n=Ve(t),d=e.jsx(p,{boxSize:`${s}px`,align:"center",justify:"center",borderRadius:"full",bg:"#0C0F14",children:e.jsx(a,{fontWeight:"800",fontSize:`${Math.max(8,Math.round(s*.3))}px`,color:"white",children:n.slice(0,3)})});let c;if(t===vt)c=e.jsx(js,{src:nr,alt:"VALINITY",w:"100%",h:"100%",objectFit:"cover",sx:{display:"block"}});else if(r==="commodities")c=e.jsx(ko,{symbol:n,size:s});else if(r==="fx"){const l=go[n];c=e.jsx(ht,{urls:l?[`https://flagcdn.com/w160/${l}.png`]:[],alt:n,fallback:d})}else r==="stocks"?c=mo.has(n)?e.jsx(Eo,{size:s}):e.jsx(ht,{urls:vo(n),alt:n,fallback:e.jsx(zo,{label:n,size:s})}):c=e.jsx(ht,{urls:[`https://app.hyperliquid.xyz/coins/${n}.svg`],alt:n,fallback:d});return e.jsx(p,{boxSize:`${s}px`,flexShrink:0,align:"center",justify:"center",borderRadius:"full",bg:"white",overflow:"hidden",boxShadow:o?"0 0 0 1px rgba(12,15,20,0.14), 0 2px 6px -1px rgba(12,15,20,0.25)":"0 0 0 1px rgba(12,15,20,0.10)",children:c})},Do=()=>{const{t}=le(),{isOpen:s,onOpen:o,onClose:r}=Ie(),n=ie(f=>f.coin),d=ie(f=>f.setCoin),c=ie(f=>f.category),l=ie(f=>f.setCategory),{data:g}=Mt(),[i,b]=h.useState(""),m=h.useMemo(()=>{const f=i.trim().toUpperCase();return(g??[]).filter(w=>w.category===c).filter(w=>!f||w.symbol.toUpperCase().includes(f)||Ut(w.coin).toUpperCase().includes(f))},[g,c,i]),v=f=>{d(f),b(""),r()},j=()=>{l(Et(n)),b(""),o()};return e.jsxs(e.Fragment,{children:[e.jsx(z,{variant:"ghost",size:"xs",w:"100%",h:"100%",minW:0,p:0,borderRadius:0,fontWeight:"800",color:"blackAlpha.700",bg:"transparent",_hover:{bg:"blackAlpha.50"},_active:{bg:"blackAlpha.100"},onClick:j,"aria-label":`${Ve(n)}-PERP`,children:e.jsx(Yt,{coin:n,size:32,elevated:!0})}),e.jsxs(ys,{isOpen:s,onClose:r,isCentered:!0,scrollBehavior:"inside",children:[e.jsx(Ne,{}),e.jsxs(Cs,{borderRadius:"2xl",mx:3,children:[e.jsx(zs,{pb:2,fontSize:"16px",fontWeight:"800",color:"blue.800",children:t("views.perps.market.selectTitle")}),e.jsx(Ds,{}),e.jsxs(_e,{pb:5,children:[e.jsx(p,{gap:2,mb:3,overflowX:"auto",pb:1,children:ir.map(f=>{const w=f===c;return e.jsx(z,{size:"sm",flexShrink:0,borderRadius:"full",variant:"outline",bg:w?"blue.800":"transparent",color:w?"white":"gray.600",borderColor:w?"blue.800":"gray.200",_hover:{bg:w?"blue.800":"gray.50"},onClick:()=>l(f),children:t(`views.perps.categories.${f}`)},f)})}),e.jsxs(me,{size:"sm",mb:3,children:[e.jsx(ze,{pointerEvents:"none",color:"gray.400",children:e.jsx(Wr,{boxSize:3})}),e.jsx(ve,{value:i,onChange:f=>b(f.target.value),placeholder:t("views.perps.market.search"),borderRadius:"lg"})]}),e.jsxs(p,{direction:"column",gap:1,maxH:"46vh",overflowY:"auto",children:[m.length===0&&e.jsx(a,{fontSize:"13px",color:"gray.400",py:8,textAlign:"center",children:t("views.perps.market.empty")}),m.map(f=>{const w=f.coin===n;return e.jsxs(p,{align:"center",justify:"space-between",gap:3,px:3,py:2,borderRadius:"lg",cursor:"pointer",bg:w?"gold.100":"transparent",_hover:{bg:w?"gold.100":"gray.50"},onClick:()=>v(f.coin),children:[e.jsxs(p,{align:"center",gap:2.5,minW:0,children:[e.jsx(Yt,{coin:f.coin,size:26}),e.jsxs(p,{direction:"column",minW:0,children:[e.jsx(a,{fontWeight:"700",fontSize:"14px",color:"blue.800",noOfLines:1,children:Ut(f.coin)}),e.jsx(a,{fontSize:"11px",color:"gray.400",fontWeight:"600",letterSpacing:"0.04em",children:Dr(f.coin)??`${f.symbol} · PERP`})]})]}),e.jsxs(a,{fontSize:"11px",color:"gold.600",fontWeight:"700",flexShrink:0,children:[f.maxLeverage,"x"]})]},f.coin)})]})]})]})]})]})},Xt=40;function Mo(t,s=!0){const[o,r]=h.useState([]);return h.useEffect(()=>{if(!s){r([]);return}let n=!0,d,c=[];return r([]),xs().trades({coin:t},l=>{if(!n)return;const g=new Set(c.map(i=>i.id));for(const i of l){const b=`${i.hash}:${i.tid}`;g.has(b)||(g.add(b),c.push({id:b,price:parseFloat(i.px),side:i.side==="B"?"buy":"sell",size:parseFloat(i.sz),timeMs:i.time}))}c.sort((i,b)=>b.timeMs-i.timeMs),c.length>Xt&&(c=c.slice(0,Xt)),r(c)}).then(l=>{d=l,n||l.unsubscribe()}).catch(()=>{}),()=>{n=!1,d==null||d.unsubscribe()}},[t,s]),o}const Qt="#00934C",Zt="#D50202",To="#0C0F14",Ro=6,Po=t=>{const s=Math.max(0,(Date.now()-t)/1e3);if(s<60)return`${Math.floor(s)}s`;const o=s/60;if(o<60)return`${Math.floor(o)}m`;const r=o/60;return r<24?`${Math.floor(r)}h`:`${Math.floor(r/24)}d`}
1,$s=({rows:t,fmtPrice:s,fmtSize:o,label:r,emptyText:n})=>{const d=ie(i=>i.livePrice),c=ie(i=>i.liveUp),l=t.slice(0,Ro),g=Math.max(1,...l.map(i=>i.size));return e.jsxs(C,{w:"100%",h:"100%",overflow:"hidden",children:[e.jsxs(p,{align:"center",justify:"space-between",h:"22px",px:2.5,children:[e.jsx(a,{fontSize:"14px",fontWeight:"800",color:c===void 0?To:c?Qt:Zt,sx:{fontVariantNumeric:"tabular-nums"},children:d===void 0?"—":s(d)}),e.jsx(a,{fontSize:"8px",fontWeight:"700",color:"blackAlpha.400",textTransform:"uppercase",letterSpacing:"0.08em",children:r})]}),l.length===0?e.jsx(p,{h:"calc(100% - 22px)",align:"center",justify:"center",children:e.jsx(a,{fontSize:"10px",color:"blackAlpha.400",children:n})}):l.map(i=>{const b=i.side==="buy"?Qt:Zt,m=Math.min(100,i.size/g*100);return e.jsxs(p,{position:"relative",align:"center",justify:"space-between",gap:2,h:"15px",px:2.5,children:[e.jsx(C,{position:"absolute",top:"0.5px",bottom:"0.5px",right:0,width:`${m}%`,borderRadius:"2px",bg:i.side==="buy"?"rgba(0,147,76,0.12)":"rgba(213,2,2,0.10)",pointerEvents:"none"}),e.jsx(a,{position:"relative",fontSize:"11px",fontWeight:"800",color:b,sx:{fontVariantNumeric:"tabular-nums"},children:s(i.price)}),e.jsxs(p,{position:"relative",align:"baseline",gap:1.5,children:[e.jsx(a,{fontSize:"10px",fontWeight:"600",color:"blackAlpha.600",sx:{fontVariantNumeric:"tabular-nums"},children:o(i.size)}),e.jsx(a,{fontSize:"9px",color:"blackAlpha.400",minW:"20px",textAlign:"right",children:Po(i.timeMs)})]})]},i.id)})]})},Lo=t=>t>0?Math.min(6,Math.max(2,5-Math.floor(Math.log10(t)))):2,Oo=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:t>=1?t.toLocaleString(void 0,{maximumFractionDigits:1}):parseFloat(t.toPrecision(2)).toString(),Wo=({coin:t})=>{var c;const{t:s}=le(),o=Mo(t,!0),r=Lo(((c=o[0])==null?void 0:c.price)??0),n=l=>`$${l.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}`,d=o.map(l=>({id:l.id,price:l.price,side:l.side,size:l.size,timeMs:l.timeMs}));return e.jsx($s,{rows:d,fmtPrice:n,fmtSize:Oo,label:s("views.perps.tape.hlLabel",{symbol:Mr(t)}),emptyText:s("views.perps.tape.empty")})},Jt=30000n,es=120000n,Io=3n,bt=9000n,No=60,_o=25,Bo=12,ts=t=>`${t.txHash}:${t.logIndex}`,te={swaps:[],lastBlock:0n};async function Uo(t,s,o,r){const n=[];for(let d=s;d<=o;d+=bt+1n){const c=d+bt>o?o:d+bt,[l,g]=await Promise.all([fr(t,d,c).catch(()=>[]),mr(t,d,c,r).catch(()=>[])]);n.push(...l,...g)}return n}async function $o(t){const s=hs(),o=await s.getBlockNumber(),r=o>es?o-es:0n;let n=te.lastBlock>0n?te.lastBlock+1n-Io:o>Jt?o-Jt:0n;if(n<r&&(n=r),n<=o){const l=await Uo(s,n,o,t),g=new Set(te.swaps.map(ts));for(const i of l){const b=ts(i);g.has(b)||(g.add(b),te.swaps.push(i))}te.swaps.sort((i,b)=>Number(b.blockNumber-i.blockNumber)),te.swaps=te.swaps.slice(0,No),o>te.lastBlock&&(te.lastBlock=o)}const d=o>te.lastBlock?o:te.lastBlock,c=Date.now();return te.swaps.slice(0,_o).map(l=>({...l,timeMs:c-Number(d-l.blockNumber)*Bo*1e3}))}function Vo(t=!0){const{data:s}=Os(t);return Z({queryKey:["vylev","tape"],enabled:t&&s!==void 0,queryFn:()=>$o(s),refetchInterval:12e3,staleTime:8e3})}const Ho=t=>`$${t.toLocaleString(void 0,{minimumFractionDigits:4,maximumFractionDigits:4})}`,Go=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:t>=1?t.toLocaleString(void 0,{maximumFractionDigits:1}):parseFloat(t.toPrecision(2)).toString(),qo=()=>{const{t}=le(),{data:s}=Vo(!0),o=(s??[]).map(r=>({id:`${r.txHash}:${r.logIndex}`,price:r.price,side:r.side,size:r.vy,timeMs:r.timeMs}));return e.jsx($s,{rows:o,fmtPrice:Ho,fmtSize:Go,label:t("views.perps.tape.vyLabel"),emptyText:t("views.perps.tape.vyEmpty")})},Ko=({coin:t})=>Me(t)==="vylev"?e.jsx(qo,{}):e.jsx(Wo,{coin:t}),Ct="#1FA45E",ss=/^\d*\.?\d*$/,Ze=1,Yo=6,Xo=2,Qo=130000n,Zo=200000n,rs=t=>t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:t<1?6:t<100?4:2});function os(t){const[s,o=""]=t.split(".");return jt(`${s||"0"}.${(o||"0").slice(0,6)}`,6)}const Jo=({initialSide:t="long",onDone:s}={})=>{var je;const{t:o}=le(),r=Fs(),{address:n,isConnected:d}=ae(),c=At(),l=zt(),g=ar(),i=Pr(Q),[b,m]=h.useState(t),[v,j]=h.useState(""),[f,w]=h.useState(Xo),[A,L]=h.useState(""),[R,G]=h.useState(!1),[M,F]=h.useState(!1),[U,q]=h.useState(!1),[N,J]=h.useState(""),[k,$]=h.useState(""),_=h.useRef(!1),se=h.useRef(null),[he,ce]=h.useState(null),O=b==="long",S=O?Ct:"#F0524D",W="#0C0F14",de=v?parseFloat(v):0,ee=!O;h.useEffect(()=>{const x=setTimeout(()=>L(v),350);return()=>clearTimeout(x)},[v]);const Ee=v!==A,He=A?parseFloat(A):0,pe=Z({queryKey:["vlo","preview",ee,A],enabled:He>=Ze,refetchInterval:15e3,queryFn:async()=>{const x=Ce(),y=os(A),T=await yt(x),V=await Promise.allSettled(Array.from({length:Yo},(I,H)=>H+1).map(I=>It(x,ee,y,I))),oe=[];for(let I=0;I<V.length;I++){const H=V[I];if(H.status!=="fulfilled")break;const D=H.value,Y=Number(ne(D.totalVy,18)),X=D.spotPriceX18>0n?T*(Number(D.entryLiqPriceX18)/Number(D.spotPriceX18)):0;oe.push({loops:I+1,leverageX:vr(D.leverageBps),sizeUsd:Y*T,liqUsd:X,seed:D.seed,totalVy:D.totalVy})}return{spotUsd:T,points:oe}}}),Ge=((je=pe.data)==null?void 0:je.points)??[],we=Ge.length,ge=Math.min(Math.max(f,1),Math.max(we,1)),P=Ge.find(x=>x.loops===ge),re=Os(!0).data,K=Z({queryKey:["vlo","gasfee"],refetchInterval:3e4,queryFn:async()=>{const x=await Ce().estimateFeesPerGas();return x.maxFeePerGas??x.gasPrice??0n}}),fe=K.data&&re?Number(lr((Qo+BigInt(ge)*Zo)*K.data))*re:void 0,ot=x=>{(x===""||ss.test(x))&&j(x)},Te=x=>j(String(Math.max(0,Math.round((de+x)*100)/100)||"")),qe=async()=>{var V,oe;if(!n||de<Ze||_.current||i.isRunning)return;const x=M&&N?parseFloat(N):0,y=U&&k?parseFloat(k):0;if(x>0&&y>0&&(ee?x>=y:x<=y)){r({status:"error",description:ee?o("views.perps.vylev.tpslInvertedShort","For a short, take-profit must be below stop-loss."):o("views.perps.vylev.tpslInvertedLong","For a long, take-profit must be above stop-loss.")}
1);return}_.current=!0,G(!0);const T=os(v);i.reset();try{const I=await It(Ce(),ee,T,ge),H=await Nt(Ce(),n,ee).catch(()=>null);se.current={isShort:ee,hadPosition:!!(H!=null&&H.active)&&H.notionalVY>0n,spotUsd:((V=pe.data)==null?void 0:V.spotUsd)??0};const D=jr(c,n,{isShort:ee,usdcIn:T,loops:ge,previewSeed:I.seed,previewTotalVy:I.totalVy},{approve:o("views.perps.vylev.approveUsdc","Approve USDC"),open:o(O?"views.perps.vylev.openLong":"views.perps.vylev.openShort",O?"Open long":"Open short")}),Y=(oe=pe.data)==null?void 0:oe.spotUsd;if(Y&&Y>0&&(x>0||y>0)){const X=Number(ne(I.totalVy,18)),xe=y>0?Bt(y,Y,I.spotPriceX18):0n,B=x>0?Bt(x,Y,I.spotPriceX18):0n,ye=yr({isShort:ee,spotUsd:Y,unwindValueUsdc:T,notionalVy:X,stopUsd:y>0?y:void 0,tpUsd:x>0?x:void 0,fractionBps:1e4}),u=Cr({isShort:ee,stopX18:xe,tpX18:B,fractionBps:1e4,minUsdcOut:ye},o("views.perps.positions.setTpsl")).map(E=>({...E,allowFailedSimulate:!0}));D.push(...u)}await i.run(D)}catch(I){r({status:"error",description:_t(I)})}finally{_.current=!1,G(!1)}},nt=async(x,y)=>{const T=Ce(),V=x.spotUsd>0?x.spotUsd:await yt(T).catch(()=>0);let oe=(P==null?void 0:P.totalVy)!=null?Number(ne(P.totalVy,dt)):0,I=parseFloat(v||"0"),H=!0;if(y)try{const B=await wr(T,y,x.isShort);B&&(oe=Number(ne(B.vyAdded,dt)),I=Number(ne(B.usdcIn,pt)),H=!1)}catch{}let D=oe,Y=V,X=null,xe=(P==null?void 0:P.leverageX)??0;try{const B=await Nt(T,n,x.isShort);if(B.active&&B.notionalVY>0n){D=Number(ne(B.notionalVY,dt));const ye=Number(ne(B.basis,pt)),u=Number(ne(B.pnl,pt));Y=D>0?x.isShort?V+u/D:V-u/D:V,ye>0&&(xe=D*V/ye),B.liqPriceX18>0n&&B.spotPriceX18>0n&&(X=V*(Number(B.liqPriceX18)/Number(B.spotPriceX18)))}}catch{}ce({symbol:"VALINITY",side:x.isShort?"short":"long",isAdd:x.hadPosition,leverage:xe,vyAdded:oe,usdcIn:I,entryPx:V,avgEntryPx:Y,totalSize:D,liqPx:X,txHash:y??null,estimated:H})};h.useEffect(()=>{if(!i.isDone)return;const x=se.current;if(se.current=null,x?nt(x,i.txHashes.open):r({status:"success",description:o("views.perps.vylev.opened","Position opened")}),j(""),J(""),$(""),Sr(),g.invalidateQueries({queryKey:["perps"]}),x)return;const y=setTimeout(()=>s==null?void 0:s(),650);return()=>clearTimeout(y)},[i.isDone]),h.useEffect(()=>{if(i.error){if(gs(i.error)){i.reset();return}r({status:"error",description:_t(i.error)})}},[i.error]);const Re=i.steps.length>0&&(i.isRunning||i.isDone||!!i.error),Se={bg:"rgba(255,255,255,0.85)",borderColor:"rgba(0,0,0,0.12)"},Ke={bg:"rgba(255,255,255,0.72)",borderColor:S,color:W,boxShadow:"inset 0 1px 2px rgba(12,15,20,0.10)",_placeholder:{color:"blackAlpha.400"},_hover:{borderColor:S},_focusVisible:{borderColor:S,boxShadow:`inset 0 1px 2px rgba(12,15,20,0.10), 0 0 0 1px ${S}`}},ue=h.useMemo(()=>{const x=O?"linear(to-b, #34C07D, #1C8A55)":"linear(to-b, #EC6A65, #C5403C)";if(!d)return{label:o("actions.connectWallet"),gradient:"linear(to-b, #2A2E37, #0C0F14)",text:"white",beam:!0,onClick:()=>l.open(Dt),loading:!1,disabled:!1};const y=o(O?"views.perps.vylev.openLongCta":"views.perps.vylev.openShortCta",O?"Open Long":"Open Short"),T=de<Ze||Ee||!P||pe.isError||R;return{label:y,gradient:x,text:"white",beam:!1,onClick:qe,loading:i.isRunning||R,disabled:T}},[d,O,de,Ee,P,pe.isError,i.isRunning,R]);return e.jsxs(p,{direction:"column",gap:2,position:"relative",children:[e.jsx(p,{bgGradient:"linear(to-b, rgba(255,255,255,0.80), rgba(255,255,255,0.62))",backdropFilter:"blur(6px) saturate(1.2)",sx:{WebkitBackdropFilter:"blur(6px) saturate(1.2)"},borderRadius:"xl",p:1,boxShadow:"0 3px 6px -2px rgba(12,15,20,0.14), 0 18px 34px -14px rgba(12,15,20,0.34), inset 0 1px 0 rgba(255,255,255,0.8)",children:["long","short"].map(x=>{const y=b===x,T=x==="long"?"linear(to-b, #34C07D, #1C8A55)":"linear(to-b, #EC6A65, #C5403C)";return e.jsx(z,{flex:1,size:"sm",borderRadius:"lg",variant:"ghost",bgGradient:y?T:void 0,color:y?"white":"blackAlpha.600",boxShadow:y?"inset 0 1px 0 rgba(255,255,255,0.4), 0 4px 10px -4px rgba(12,15,20,0.40)":void 0,_hover:{bgGradient:y?T:void 0,bg:y?void 0:"blackAlpha.100"},_active:{transform:"translateY(0.5px)"},fontWeight:"700",onClick:()=>m(x),children:o(`views.perps.order.${x}`)},x)})}),e.jsxs(C,{className:"vy-glass-frame",position:"relative",borderRadius:"2xl",bgGradient:"linear(to-b, rgba(255,255,255,0.40), rgba(255,255,255,0.24))",backdropFilter:"blur(2px) saturate(1.15)",sx:{WebkitBackdropFilter:"blur(2px) saturate(1.15)"},borderWidth:"1px",borderColor:"rgba(0,0,0,0.10)",px:3,pt:2,pb:2,boxShadow:"0 2px 6px rgba(12,15,20,0.10), 0 16px 30px -10px rgba(12,15,20,0.30), 0 42px 70px -22px rgba(12,15,20,0.46), inset 0 1px 0 rgba(255,255,255,0.95), inset 0 -1px 0 rgba(12,15,20,0.06)",children:[e.jsxs(p,{align:"flex-end",justify:"space-between",mb:1,children:[e.jsx(a,{fontSize:"13px",fontWeight:"700",color:W,children:o("views.perps.vylev.amount","Amount (USDC)")}),e.jsxs(p,{align:"baseline",gap:1.5,children:[e.jsx(a,{fontSize:"10px",color:"blackAlpha.700",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:"700",children:o("views.perps.order.liqPrice")}),e.jsx(a,{fontSize:"12px",fontWeight:"800",color:"#C5403C",sx:{fontVariantNumeric:"tabular-nums"},children:P&&P.liqUsd>0?`~$${rs(P.liqUsd)}`:"—"})]})]}),e.jsxs(p,{gap:2,mb:1,children:[e.jsx(z,{size:"sm",variant:"outline",borderRadius:"lg",color:W,bg:Se.bg,borderColor:Se.borderColor,_active:{transform:"translateY(1px)"},onClick:()=>Te(-50),"aria-label":o("views.perps.order.decrease"),children:"−"}),e.jsxs(me,{flex:1,size:"sm",children:[e.jsx(ze,{pointerEvents:"none",color:"blackAlpha.700",children:"$"}
1),e.jsx(ve,{value:v,onChange:x=>ot(x.target.value),placeholder:"0.00",inputMode:"decimal",textAlign:"right",fontSize:"16px",fontWeight:"600",sx:{fontVariantNumeric:"tabular-nums"},...Ke})]}),e.jsx(z,{size:"sm",variant:"outline",borderRadius:"lg",color:W,bg:Se.bg,borderColor:Se.borderColor,_active:{transform:"translateY(1px)"},onClick:()=>Te(50),"aria-label":o("views.perps.order.increase"),children:"+"})]}),e.jsxs(p,{justify:"space-between",align:"baseline",mt:2,mb:1,children:[e.jsx(a,{fontSize:"11px",color:"blackAlpha.700",textTransform:"uppercase",letterSpacing:"0.07em",fontWeight:"700",children:o("views.perps.order.leverage")}),e.jsxs(p,{align:"baseline",gap:1,children:[pe.isFetching&&He>=Ze?e.jsx(Ue,{size:"xs",color:S,mr:1}):null,e.jsx(a,{fontSize:"15px",fontWeight:"800",color:S,sx:{fontVariantNumeric:"tabular-nums"},children:P?`${P.leverageX.toFixed(2)}×`:"—"})]})]}),e.jsxs(Ms,{min:1,max:Math.max(we,1),step:1,value:ge,onChange:w,isDisabled:we===0,children:[e.jsx(Ts,{bg:"blackAlpha.200",children:e.jsx(Rs,{bg:S})}),e.jsx(Ps,{boxSize:5,borderWidth:"2px",borderColor:S,bg:"#FFFFFF"})]}),e.jsxs(p,{justify:"space-between",mt:1,children:[e.jsx(a,{fontSize:"10px",color:"blackAlpha.600",fontWeight:"600",children:o("views.perps.vylev.loops","{{n}} loops",{n:ge})}),e.jsx(a,{fontSize:"10px",color:"blackAlpha.600",fontWeight:"600",sx:{fontVariantNumeric:"tabular-nums"},children:P?o("views.perps.vylev.size",{defaultValue:"Size ~{{usd}} USD",usd:rs(P.sizeUsd)}):""})]}),e.jsx(C,{h:"1px",bg:"rgba(0,0,0,0.08)",mt:3,mb:2}),e.jsx(p,{gap:2,mb:1,children:[{key:"tp",label:o("views.perps.order.takeProfit"),color:"#00934C",scheme:"green",on:M,setOn:F},{key:"sl",label:o("views.perps.order.stopLoss"),color:"#D50202",scheme:"red",on:U,setOn:q}].map(x=>e.jsxs(p,{flex:1,align:"center",gap:1.5,children:[e.jsx(a,{fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:"700",color:x.color,children:x.label}),e.jsx(Ls,{isChecked:x.on,onChange:y=>x.setOn(y.target.checked),size:"sm",colorScheme:x.scheme,sx:{"& .chakra-checkbox__control":{borderColor:"rgba(0,0,0,0.28)",borderRadius:"4px"}}})]},x.key))}),e.jsx(p,{gap:2,children:[{key:"tp",val:N,set:J,color:"#00934C",on:M},{key:"sl",val:k,set:$,color:"#D50202",on:U}].map(x=>e.jsx(C,{flex:1,opacity:x.on?1:.4,transition:"opacity 0.15s ease",children:e.jsxs(me,{size:"sm",children:[e.jsx(ze,{pointerEvents:"none",color:"blackAlpha.600",fontSize:"13px",children:"$"}),e.jsx(ve,{value:x.val,onChange:y=>(y.target.value===""||ss.test(y.target.value))&&x.set(y.target.value),placeholder:o("views.perps.order.price"),inputMode:"decimal",textAlign:"right",isDisabled:!x.on,sx:{fontVariantNumeric:"tabular-nums"},bg:"rgba(255,255,255,0.72)",borderColor:"rgba(0,0,0,0.12)",color:W,boxShadow:"inset 0 1px 2px rgba(12,15,20,0.10)",_placeholder:{color:"blackAlpha.400"},_hover:{borderColor:x.color},_focusVisible:{borderColor:x.color,boxShadow:`inset 0 1px 2px rgba(12,15,20,0.10), 0 0 0 1px ${x.color}`}})]})},x.key))}),Re&&e.jsx(p,{direction:"column",gap:1.5,mt:3,p:2.5,borderRadius:"lg",bg:"rgba(0,0,0,0.035)",borderWidth:"1px",borderColor:"rgba(0,0,0,0.06)",children:i.steps.map((x,y)=>{const T=i.states[y];return e.jsxs(p,{align:"center",gap:2,children:[e.jsx(C,{w:"16px",textAlign:"center",children:T==="done"?e.jsx(a,{color:Ct,fontWeight:"800",children:"✓"}):T==="active"?e.jsx(Ue,{size:"xs",color:S}):T==="error"?e.jsx(a,{color:"#C5403C",fontWeight:"800",children:"×"}):e.jsx(C,{w:"6px",h:"6px",borderRadius:"full",bg:"blackAlpha.300",mx:"auto"})}),e.jsx(a,{fontSize:"12px",fontWeight:"600",color:T==="idle"?"blackAlpha.500":W,children:x.label})]},x.id)})})]}),e.jsx(z,{width:"100%",size:"lg",h:"48px",mt:1,borderRadius:"xl",borderWidth:"1.5px",borderColor:"#7D8991",className:ue.beam?"vy-beam-border":void 0,bgGradient:ue.gradient,color:ue.text,fontSize:"16px",fontWeight:"700",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.5), 0 10px 22px -10px rgba(12,15,20,0.5)",_hover:{filter:"brightness(1.05)"},_active:{filter:"brightness(0.98)",transform:"translateY(1px)"},isLoading:ue.loading,isDisabled:ue.disabled,onClick:ue.onClick,children:ue.label}),e.jsx(a,{fontSize:"10px",color:"blackAlpha.600",textAlign:"center",px:2,children:fe!=null?o("views.perps.vylev.feeNote",{defaultValue:"Est. network fee ≈ {{fee}} · settles in USDC on Ethereum",fee:`$${fe<.01?"0.01":fe.toFixed(2)}`}):o("views.perps.vylev.chainNote","Trades settle on Ethereum in USDC · network gas applies")}),e.jsx(Lr,{isOpen:!!he,onClose:()=>{ce(null),s==null||s()},summary:he})]})},gt=/^\d*\.?\d*$/,en=({initialSide:t="long",onGoToFunds:s,onOpened:o}={})=>{var ye;const{t:r}=le(),n=Fs(),{isConnected:d}=ae(),c=zt(),l=h.useCallback(u=>{n.closeAll(),n({duration:2500,isClosable:!0,...u})},[n]),{data:g}=rt(),i=ie(u=>u.coin),b=Ve(i),{mark:m}=Ws(i),{data:v}=Mt(),j=((ye=v==null?void 0:v.find(u=>u.coin===i))==null?void 0:ye.maxLeverage)??20,{resolved:f}=ks(),w=Es(f==null?void 0:f.builder),A=As(),L=Fr(),R=kr(),M=cr(i)===kt&&R.isEnabled===!1,F=Er(),[
1U,q]=h.useState(t),[N,J]=h.useState("market"),[k,$]=h.useState(""),[_,se]=h.useState(""),[he,ce]=h.useState(5),[O,S]=h.useState(!1),W=Math.min(he,j),[de,ee]=h.useState(!0),[Ee,He]=h.useState(!0),[pe,Ge]=h.useState(""),[we,ge]=h.useState(""),P=U==="long",re=P?Ct:"#F0524D",K=k?parseFloat(k):0,fe=K*W,ot=N==="market"?!m:!parseFloat(_||"0"),Te=K>0&&fe<Wt,qe=(g==null?void 0:g.available)??0,nt=!!g&&K>0&&K>qe,Re=N==="limit"?parseFloat(_||"0"):m??0,Se=j>0?1/(2*j):0,Ke=P?1:-1,ue=(()=>{const u=Re>0?fe/Re:0;if(!(u>0))return;const be=(g!=null&&g.accountValue&&g.accountValue>0?g.accountValue:K)-fe*Se;if(!(be>0))return;const Pe=Re-Ke*(be/u)/(1-Se*Ke);return Pe>0?Pe:void 0})(),je=u=>u.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:u<1?6:u<100?4:2}),x=u=>{(u===""||gt.test(u))&&$(u)},y=u=>$(String(Math.max(0,Math.round((K+u)*100)/100)||"")),T=async()=>{if(g&&g.accountValue<=0){l({status:"info",description:r("views.perps.order.depositFirst","Deposit funds first to start trading")}),s==null||s();return}try{f!=null&&f.builder&&!w.isApproved&&await A.mutateAsync(f.builder),L.isEnabled||await L.enable.mutateAsync(),M&&await R.enable.mutateAsync(),l({status:"success",description:r("views.perps.order.tradingEnabled")})}catch(u){const E=u.message;if(/must deposit|deposit before/i.test(E)){l({status:"info",description:r("views.perps.order.depositFirst","Deposit funds first to start trading")}),s==null||s();return}l({status:"error",description:E})}},V=async()=>{try{await R.enable.mutateAsync(),l({status:"success",description:r("views.perps.order.marketsEnabled")})}catch(u){l({status:"error",description:u.message})}},oe=async()=>{try{const u=de&&pe?pe:void 0,E=Ee&&we?we:void 0,be=await F.mutateAsync({coin:i,isBuy:P,marginUsd:K,mark:m,orderType:N,limitPrice:_,leverage:W,isCross:O,tpsl:u??E?{tp:u,sl:E}:void 0});l({status:"success",description:be.filled?r("views.perps.order.filled",{size:be.filled.size,symbol:b,price:be.filled.avgPx}):r("views.perps.order.placed")}),$("")}catch(u){const E=u.message;/agent|not.*approved|does not exist/i.test(E)&&L.disable(),l({status:"error",description:E})}},I=r(P?"views.perps.order.buyCta":"views.perps.order.sellCta",{coin:b}),H="linear(to-b, #FFFFFF, #FFFFFF)",D="#0C0F14",Y=P?"linear(to-b, #34C07D, #1C8A55)":"linear(to-b, #EC6A65, #C5403C)",X=d?f?!w.isApproved||!L.isEnabled?{label:r("views.perps.order.enableTrading"),gradient:H,text:D,beam:!0,onClick:T,loading:L.enable.isPending||A.isPending||R.enable.isPending,disabled:!1}:M?{label:r("views.perps.order.enableMarkets"),gradient:H,text:D,beam:!0,onClick:V,loading:R.enable.isPending,disabled:!1}:{label:I,gradient:Y,text:"white",beam:!1,onClick:oe,loading:F.isPending,disabled:!K||ot||Te}:{label:I,gradient:Y,text:"white",beam:!1,onClick:()=>{},loading:!0,disabled:!0}:{label:r("actions.connectWallet"),gradient:"linear(to-b, #2A2E37, #0C0F14)",text:"white",beam:!0,onClick:()=>c.open(Dt),loading:!1,disabled:!1};if(Me(i)==="vylev")return e.jsx(Jo,{initialSide:t,onDone:o});const xe={bg:"rgba(255,255,255,0.85)",borderColor:"rgba(0,0,0,0.12)"},B={...xe,bg:"rgba(255,255,255,0.72)",borderColor:re,color:D,boxShadow:"inset 0 1px 2px rgba(12,15,20,0.10)",_placeholder:{color:"blackAlpha.400"},_hover:{borderColor:re},_focusVisible:{borderColor:re,boxShadow:`inset 0 1px 2px rgba(12,15,20,0.10), 0 0 0 1px ${re}`}};return e.jsxs(p,{direction:"column",gap:2,position:"relative",children:[e.jsx(p,{bgGradient:"linear(to-b, rgba(255,255,255,0.80), rgba(255,255,255,0.62))",backdropFilter:"blur(6px) saturate(1.2)",sx:{WebkitBackdropFilter:"blur(6px) saturate(1.2)"},borderRadius:"xl",p:1,boxShadow:"0 3px 6px -2px rgba(12,15,20,0.14), 0 18px 34px -14px rgba(12,15,20,0.34), inset 0 1px 0 rgba(255,255,255,0.8)",children:["long","short"].map(u=>{const E=U===u,be=u==="long"?"linear(to-b, #34C07D, #1C8A55)":"linear(to-b, #EC6A65, #C5403C)",Pe="inset 0 1px 0 rgba(255,255,255,0.4), 0 4px 10px -4px rgba(12,15,20,0.40)";return e.jsx(z,{flex:1,size:"sm",borderRadius:"lg",variant:"ghost",bgGradient:E?be:void 0,color:E?"white":"blackAlpha.600",boxShadow:E?Pe:void 0,transition:"transform 0.08s ease",_hover:{bgGradient:E?be:void 0,bg:E?void 0:"blackAlpha.100",boxShadow:E?Pe:void 0},_active:{transform:"translateY(0.5px)"},fontWeight:"700",onClick:()=>q(u),children:r(`views.perps.order.${u}`)},u)})}),e.jsxs(C,{className:"vy-glass-frame",position:"relative",borderRadius:"2xl",bgGradient:"linear(to-b, rgba(255,255,255,0.40), rgba(255,255,255,0.24))",backdropFilter:"blur(2px) saturate(1.15)",sx:{WebkitBackdropFilter:"blur(2px) saturate(1.15)"},borderWidth:"1px",borderColor:"rgba(0,0,0,0.10)",px:3,pt:2,pb:2,boxShadow:"0 2px 6px rgba(12,15,20,0.10), 0 16px 30px -10px rgba(12,15,20,0.30), 0 42px 70px -22px rgba(12,15,20,0.46), inset 0 1px 0 rgba(255,255,255,0.95), inset 0 -1px 0 rgba(12,15,20,0.06)",children:[N==="limit"&&e.jsxs(me,{mb:2,children:[e.jsx(ze,{pointerEvents:"none",color:"blackAlpha.700",fontSize:"13px",children:"$"}
1),e.jsx(ve,{value:_,onChange:u=>(u.target.value===""||gt.test(u.target.value))&&se(u.target.value),placeholder:r("views.perps.order.limitPrice"),inputMode:"decimal",...B})]}),e.jsxs(p,{align:"flex-end",justify:"space-between",mb:1,children:[e.jsx(p,{gap:4,children:["market","limit"].map(u=>e.jsx(a,{fontSize:"13px",fontWeight:N===u?"700":"500",color:N===u?D:"blackAlpha.700",cursor:"pointer",borderBottomWidth:"2px",borderColor:N===u?re:"transparent",pb:1,onClick:()=>J(u),children:r(`views.perps.order.${u}`)},u))}),e.jsxs(p,{align:"baseline",gap:1.5,pr:"71px",children:[e.jsx(a,{fontSize:"10px",color:"blackAlpha.700",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:"700",children:r("views.perps.order.liqPrice")}),e.jsx(a,{fontSize:"12px",fontWeight:"800",color:"#C5403C",sx:{fontVariantNumeric:"tabular-nums"},children:ue?`~$${je(ue)}`:"—"})]})]}),e.jsxs(p,{gap:2,mb:1,children:[e.jsx(z,{size:"sm",variant:"outline",borderRadius:"lg",color:D,bg:xe.bg,borderColor:xe.borderColor,boxShadow:"inset 0 1px 0 rgba(255,255,255,0.85), 0 1px 2px rgba(12,15,20,0.10)",transition:"transform 0.07s ease, box-shadow 0.1s ease",_hover:{bg:"rgba(255,255,255,0.95)"},_active:{transform:"translateY(1px)",boxShadow:"inset 0 1px 2px rgba(12,15,20,0.18)"},onClick:()=>y(-50),"aria-label":r("views.perps.order.decrease"),children:"−"}),e.jsxs(me,{flex:1,size:"sm",children:[e.jsx(ze,{pointerEvents:"none",color:"blackAlpha.700",children:"$"}),e.jsx(ve,{value:k,onChange:u=>x(u.target.value),placeholder:"0.00",inputMode:"decimal",textAlign:"right",fontSize:"16px",fontWeight:"600","aria-label":r("views.perps.order.size"),sx:{fontVariantNumeric:"tabular-nums"},...B})]}),e.jsx(z,{size:"sm",variant:"outline",borderRadius:"lg",color:D,bg:xe.bg,borderColor:xe.borderColor,boxShadow:"inset 0 1px 0 rgba(255,255,255,0.85), 0 1px 2px rgba(12,15,20,0.10)",transition:"transform 0.07s ease, box-shadow 0.1s ease",_hover:{bg:"rgba(255,255,255,0.95)"},_active:{transform:"translateY(1px)",boxShadow:"inset 0 1px 2px rgba(12,15,20,0.18)"},onClick:()=>y(50),"aria-label":r("views.perps.order.increase"),children:"+"})]}),K>0&&e.jsx(a,{fontSize:"11px",color:"blackAlpha.700",fontWeight:"600",mb:1,sx:{fontVariantNumeric:"tabular-nums"},children:r("views.perps.order.marginBreakdown",{margin:je(K),exposure:je(fe),lev:W})}),Te&&e.jsx(a,{fontSize:"11px",color:"#C5403C",fontWeight:"600",mb:1,children:r("views.perps.order.minOrder",{min:Wt})}),nt&&e.jsx(a,{fontSize:"11px",color:"#C5403C",fontWeight:"600",mb:1,sx:{fontVariantNumeric:"tabular-nums"},children:r("views.perps.order.insufficientMargin",{amount:je(qe)})}),e.jsxs(p,{justify:"space-between",align:"center",mb:1,children:[e.jsx(p,{bg:"rgba(0,0,0,0.06)",borderRadius:"full",p:"2px",gap:"2px",children:[!1,!0].map(u=>{const E=O===u;return e.jsx(z,{h:"22px",px:2.5,minW:0,variant:"unstyled",borderRadius:"full",fontSize:"10px",fontWeight:E?"800":"600",color:E?D:"blackAlpha.600",bg:E?"rgba(255,255,255,0.95)":"transparent",boxShadow:E?"0 1px 3px rgba(12,15,20,0.18)":"none",onClick:()=>S(u),children:r(u?"views.perps.order.cross":"views.perps.order.isolated")},String(u))})}),e.jsx(a,{fontSize:"10px",color:"blackAlpha.600",children:r(O?"views.perps.order.crossNote":"views.perps.order.isolatedNote")})]}),e.jsxs(p,{justify:"space-between",mb:1,children:[e.jsx(a,{fontSize:"11px",color:"blackAlpha.700",textTransform:"uppercase",letterSpacing:"0.07em",fontWeight:"700",children:r("views.perps.order.leverage")}),e.jsxs(a,{fontSize:"12px",fontWeight:"700",color:re,letterSpacing:"0.2px",sx:{fontVariantNumeric:"tabular-nums"},children:[W,"x"]})]}),e.jsxs(Ms,{min:1,max:j,step:1,value:W,onChange:ce,children:[e.jsx(Ts,{bg:"blackAlpha.200",children:e.jsx(Rs,{bg:re})}),e.jsx(Ps,{boxSize:5,borderWidth:"2px",borderColor:re,bg:"#FFFFFF",boxShadow:"0 2px 5px -1px rgba(12,15,20,0.30), inset 0 1px 0 rgba(255,255,255,0.95)",_active:{boxShadow:"0 1px 3px rgba(12,15,20,0.35), inset 0 1px 0 rgba(255,255,255,0.95)"}})]}),e.jsx(C,{h:"1px",bg:"rgba(0,0,0,0.08)",mt:3,mb:2}),e.jsx(p,{gap:2,mb:1,children:[{key:"tp",label:r("views.perps.order.takeProfit"),color:"#00934C",scheme:"green",on:de,setOn:ee},{key:"sl",label:r("views.perps.order.stopLoss"),color:"#D50202",scheme:"red",on:Ee,setOn:He}].map(u=>e.jsxs(p,{flex:1,align:"center",gap:1.5,children:[e.jsx(a,{fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:"700",color:u.color,children:u.label}),e.jsx(Ls,{isChecked:u.on,onChange:E=>
1u.setOn(E.target.checked),size:"sm",colorScheme:u.scheme,sx:{"& .chakra-checkbox__control":{borderColor:"rgba(0,0,0,0.28)",borderRadius:"4px"}}})]},u.key))}),e.jsx(p,{gap:2,children:[{key:"tp",val:pe,set:Ge,color:"#00934C",on:de},{key:"sl",val:we,set:ge,color:"#D50202",on:Ee}].map(u=>e.jsx(C,{flex:1,opacity:u.on?1:.4,transition:"opacity 0.15s ease",children:e.jsxs(me,{size:"sm",children:[e.jsx(ze,{pointerEvents:"none",color:"blackAlpha.600",fontSize:"13px",children:"$"}),e.jsx(ve,{value:u.val,onChange:E=>(E.target.value===""||gt.test(E.target.value))&&u.set(E.target.value),placeholder:r("views.perps.order.price"),inputMode:"decimal",textAlign:"right",isDisabled:!u.on,sx:{fontVariantNumeric:"tabular-nums"},bg:"rgba(255,255,255,0.72)",borderColor:"rgba(0,0,0,0.12)",color:D,boxShadow:"inset 0 1px 2px rgba(12,15,20,0.10)",_placeholder:{color:"blackAlpha.400"},_hover:{borderColor:u.color},_focusVisible:{borderColor:u.color,boxShadow:`inset 0 1px 2px rgba(12,15,20,0.10), 0 0 0 1px ${u.color}`}})]})},u.key))})]}),e.jsx(z,{width:"100%",size:"lg",h:"48px",mt:1,borderRadius:"xl",borderWidth:"1.5px",borderColor:"#7D8991",bgGradient:X.gradient,color:X.text,fontSize:"16px",fontWeight:"700",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.5), 0 10px 22px -10px rgba(12,15,20,0.5)",transition:"transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease",_hover:{filter:"brightness(1.05)"},_active:{filter:"brightness(0.98)",transform:"translateY(1px)"},isLoading:X.loading,isDisabled:X.disabled,onClick:X.onClick,children:X.label})]})},ns="#00934C",is="#D50202",Ft="#0C0F14",Le=t=>t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),tn=t=>{const s=t<1?6:t<100?4:2;return t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:s})},sn=t=>t.toLocaleString(void 0,{maximumFractionDigits:t<1?6:t<1e3?3:2}),rn=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),on=({r:t})=>{const{t:s}=le(),o=/long/i.test(t.dir),r=t.pnl-t.fee,n=r>=0;return e.jsx(C,{borderWidth:"1px",borderColor:"rgba(0,0,0,0.08)",borderLeftWidth:"3px",borderLeftColor:o?"#C3A573":"#2C6E97",borderRadius:"lg",px:3,py:2.5,bgGradient:"linear(to-b, #FFFFFF, #F7F2E7)",boxShadow:"0 8px 18px -16px rgba(0,0,0,0.35)",children:e.jsxs(p,{justify:"space-between",align:"flex-start",gap:2,children:[e.jsxs(C,{minW:0,children:[e.jsxs(p,{align:"center",gap:2,children:[e.jsx(a,{fontWeight:"800",fontSize:"13px",color:Ft,children:t.symbol}),e.jsx(Or,{borderRadius:"full",px:2,fontSize:"9px",bg:o?"rgba(43,174,111,0.18)":"rgba(229,79,79,0.18)",color:o?ns:is,children:t.dir})]}),e.jsxs(a,{fontSize:"11px",color:"blackAlpha.600",mt:"2px",sx:{fontVariantNumeric:"tabular-nums"},children:[sn(t.size)," @ $",tn(t.price)," · $",Le(t.value)]}),e.jsx(a,{fontSize:"10px",color:"blackAlpha.500",mt:"1px",children:rn(t.time)})]}),e.jsx(C,{textAlign:"right",flexShrink:0,children:t.isClose?e.jsxs(e.Fragment,{children:[e.jsxs(a,{fontSize:"14px",fontWeight:"800",color:n?ns:is,sx:{fontVariantNumeric:"tabular-nums"},children:[n?"+":"−","$",Le(Math.abs(r))]}),e.jsx(a,{fontSize:"10px",color:"blackAlpha.600",sx:{fontVariantNumeric:"tabular-nums"},children:s("views.perps.transactions.netOf",{pnl:`${t.pnl>=0?"+":"−"}$${Le(Math.abs(t.pnl))}`,fee:`$${Le(t.fee)}`})})]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{fontSize:"10px",color:"blackAlpha.500",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:"600",children:s("views.perps.transactions.fee")}),e.jsxs(a,{fontSize:"13px",fontWeight:"700",color:Ft,sx:{fontVariantNumeric:"tabular-nums"},children:["$",Le(t.fee)]})]})})]})})},nn=()=>{var r;const{t}=le(),{isConnected:s}=ae(),o=Kr();return s?o.isLoading?e.jsx(p,{justify:"center",py:8,children:e.jsx(Ue,{size:"sm",color:"gold.500"})}):(r=o.data)!=null&&r.length?e.jsx(p,{direction:"column",gap:2,children:o.data.map(n=>e.jsx(on,{r:n},n.id))}):e.jsxs(p,{direction:"column",align:"center",gap:1,py:8,children:[e.jsx(a,{fontSize:"14px",fontWeight:"700",color:Ft,children:t("views.perps.transactions.empty")}),e.jsx(a,{fontSize:"12px",color:"blackAlpha.600",children:t("views.perps.transactions.emptyHint")})]}):e.jsx(a,{fontSize:"13px",color:"blackAlpha.600",py:6,textAlign:"center",children:t("views.perps.transactions.connect")})},as="#00934C",ls="#D50202",ft={maxW:"520px !important",insetInline:0,mx:"auto"},cs=112,Oe={w:"56px",h:"56px",minW:"56px",p:0,borderRadius:0,fontSize:"13px",fontWeight:"700",color:"blackAlpha.700",bg:"transparent",_hover:{bg:"blackAlpha.50"},_active:{bg:"blackAlpha.100"}},We="1px solid rgba(12,15,20,0.12)",ds="1px solid rgba(12,15,20,0.18)",Je="53px",mt={h:"40px",fontSize:"11px",letterSpacing:"0.01em"},et={bgGradient:"linear(to-b, #FFFFFF, #F0F2F5)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.9), inset 0 -1px 0 rgba(12,15,20,0.07)"},ps=[["1","1m"],["5","5m"],["15","15m"],["30","30m"],["60","1H"],["240","4H"],["1D","1D"],["1W","1W"]],us="1D",an=({demoPosition:t}={})=>{var O;const{t:s}=le(),{isConnected:o}
1=ae(),r=zt(),n=ie(S=>S.coin),d=ie(S=>S.setCoin),c=ie(S=>S.livePrice),{mark:l}=Ws(n),{data:g}=Mt(),[i,b]=h.useState(),m=qr(n).data,[v,j]=h.useState(us),[f,w]=h.useState("long"),A=Ar(),L=h.useMemo(()=>{var W;if(t!==void 0)return t;const S=(W=A.data)==null?void 0:W.find(de=>de.coin===n);return S?{side:S.side,entry:S.entryPx,liq:S.liquidationPx,tp:S.tp??null,sl:S.sl??null}:null},[t,A.data,n]),[R,G]=h.useState(!0),M=Ie(),F=Ie(),U=Ie(),q=Ie(),N=c!==void 0&&l!==void 0&&!!g,[J,k]=h.useState(!1),[$,_]=h.useState(!1),[se,he]=h.useState(n);se!==n&&(he(n),k(!1),_(!1),j(us)),h.useEffect(()=>{const S=setTimeout(()=>k(!0),700),W=setTimeout(()=>_(!0),5e3);return()=>{clearTimeout(S),clearTimeout(W)}},[n]);const ce=!$&&(!N||!J);return e.jsxs(dr,{title:s("views.nav.perps"),sx:{background:["linear-gradient(to bottom, rgba(146,154,168,0.52) 0%, rgba(188,194,205,0.24) 14%, rgba(255,255,255,0) 33%)","linear-gradient(to top, rgba(92,100,114,0.74) 0%, rgba(116,124,138,0.52) 15%, rgba(168,174,186,0.26) 30%, rgba(255,255,255,0) 46%)","radial-gradient(88% 78% at 50% 38%, #FFFFFF 0%, #FFFFFF 27%, #E3E7ED 58%, #BCC2CF 100%)","#EDEFF3"].join(", ")},children:[e.jsxs(p,{direction:"column",w:"100%",maxW:"520px",mx:"auto",px:"10px",pt:"9px",pb:"10px",flex:"1",h:"calc(100dvh - 54px)",overflow:"hidden",position:"relative",children:[e.jsxs(C,{flex:"1",minH:0,display:"flex",flexDirection:"column",borderRadius:"12px",overflow:"hidden",children:[e.jsxs(p,{h:`${cs}px`,flexShrink:0,bg:"#FFFFFF",children:[R&&e.jsxs(p,{direction:"column",flexShrink:0,borderRight:We,children:[e.jsxs(pr,{placement:"bottom-start",autoSelect:!1,children:[e.jsx(ur,{as:z,...Oe,w:Je,minW:Je,children:((O=ps.find(([S])=>S===v))==null?void 0:O[1])??v}),e.jsx(xr,{minW:"72px",py:1,borderRadius:"14px",border:"1px solid rgba(195,165,115,0.35)",boxShadow:"0 14px 30px -12px rgba(15,23,42,0.4)",children:ps.map(([S,W])=>e.jsx(hr,{fontSize:"12px",fontWeight:v===S?"800":"600",color:v===S?"#AD854C":"#0C0F14",onClick:()=>{j(S),i==null||i.setResolution(S)},children:W},S))})]}),e.jsx(z,{...Oe,w:Je,minW:Je,fontSize:"14px",isDisabled:!i,onClick:()=>i==null?void 0:i.openIndicators(),children:e.jsx(a,{as:"span",fontStyle:"italic",children:"ƒx"})})]}),e.jsx(C,{flex:"1",minW:0,h:`${cs}px`,borderBottom:ds,children:e.jsx(Ko,{coin:n})}),e.jsxs(p,{direction:"column",flexShrink:0,borderLeft:We,borderBottom:ds,children:[e.jsx(C,{w:"56px",h:"56px",borderBottom:We,...et,children:e.jsx(Do,{})}),e.jsx(z,{...Oe,...et,...mt,onClick:U.onOpen,children:s("views.perps.tabs.funds")}),o&&e.jsxs(e.Fragment,{children:[e.jsx(z,{...Oe,...et,...mt,borderTop:We,onClick:F.onOpen,children:s("views.perps.terminal.positionsShort","Pos.")}),e.jsx(z,{...Oe,...et,...mt,borderTop:We,onClick:q.onOpen,children:s("views.perps.tabs.transactionsShort","Txns")})]})]})]}),e.jsx(C,{position:"relative",flex:"1",minH:0,bg:"#FFFFFF",children:e.jsx(C,{position:"absolute",top:0,left:0,right:0,bottom:0,children:e.jsx(Tr,{coin:n,height:"100%",onApi:b,onToolbar:G,position:L,marks:m})})})]}),e.jsxs(p,{gap:2,mt:2,mb:"4px",mx:"16px",children:[e.jsx(z,{flex:"1",h:"42px",borderRadius:"13px",fontSize:"14px",fontWeight:"800",color:"white",bgGradient:`linear(to-b, #00A857, ${as})`,boxShadow:"0 8px 18px -10px rgba(0,147,76,0.55), inset 0 1px 0 rgba(255,255,255,0.25)",_hover:{bgGradient:`linear(to-b, #00B25D, ${as})`},_active:{transform:"translateY(1px)"},onClick:()=>{w("long"),M.onOpen()},children:s("views.perps.order.long")}),e.jsx(z,{flex:"1",h:"42px",borderRadius:"13px",fontSize:"14px",fontWeight:"800",color:"white",bgGradient:`linear(to-b, #E51616, ${ls})`,boxShadow:"0 8px 18px -10px rgba(213,2,2,0.5), inset 0 1px 0 rgba(255,255,255,0.22)",_hover:{bgGradient:`linear(to-b, #EF2222, ${ls})`},_active:{transform:"translateY(1px)"},onClick:()=>{w("short"),M.onOpen()},children:s("views.perps.order.short")})]}),e.jsx(p,{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:5,align:"center",justify:"center",bgGradient:"linear(to-b, #DEE1E7 0%, #FBFCFD 30%, #FFFFFF 52%, #EDEFF3 78%, #B7BCC6 100%)",opacity:ce?1:0,pointerEvents:ce?"auto":"none",transition:ce?"none":"opacity 0.45s ease",children:e.jsx(br,{size:"xl",sx:{filter:"drop-shadow(0 10px 26px rgba(12,15,20,0.22))"}})})]}),e.jsxs(lt,{placement:"bottom",isOpen:M.isOpen,onClose:M.onClose,autoFocus:!1,children:[e.jsx(Ne,{bg:"rgba(12,15,20,0.55)",backdropFilter:"blur(4px)"}),e.jsxs(ct,{...ft,borderTopRadius:"24px",bgGradient:"linear(to-b, #FFFFFF, #EEF0F2)",boxShadow:"0 -18px 44px -18px rgba(15,23,42,0.45), 0 0 0 1px rgba(195,165,115,0.30)",children:[e.jsx(p,{justify:"center",pt:2.5,pb:1,children:e.jsx(C,{w:"42px",h:"4px",borderRadius:"full",bgGradient:"linear(to-r, gold.400, gold.600)",opacity:.7})}),e.jsx(_e,{px:3,pt:1,pb:4,children:e.jsx(en,{initialSide:f,onGoToFunds:()=>{M.onClose(),U.onOpen()},onOpened:M.onClose},`${f}:${n}`)})]})]}),e.jsxs(lt,{placement:"bottom",isOpen:F.isOpen,onClose:F.onClose,autoFocus:!1,children:[e.jsx(Ne,{bg:"rgba(12,15,20,0.55)",backdropFilter:"blur(4px)"}),e.jsxs(ct,{...ft,borderTopRadius:"24px",bgGradient:"linear(to-b, #FFFFFF, #EEF0F2)",boxShadow:"0 -18px 44px -18px rgba(15,23,42,0.45), 0 0 0 1px rgba(195,165,115,0.30)",maxH:"70dvh",children:[e.jsx(p,{justify:"center",pt:2.5,pb:1,children:e.jsx(C,{w:"42px",h:"4px",borderRadius:"full",bgGradient:"linear(to-r, gold.400, gold.600)",opacity:.7})}),e.jsx(_e,{px:3,pt:1,pb:4,overflowY:"auto",children:e.jsx(zr,{onAdd:(S,W)=>{d(W),w(S),F.onClose(),M.onOpen()}})})]})]}),e.jsxs(lt,{placement:"bottom",isOpen:q.isOpen,onClose:q.onClose,autoFocus:!1,children:[e.jsx(Ne,{bg:"rgba(12,15,20,0.55)",backdropFilter:"blur(4px)"}),e.jsxs(ct,{...ft,borderTopRadius:"24px",bgGradient:"linear(to-b, #FFFFFF, #EEF0F2)",boxShadow:"0 -18px 44px -18px rgba(15,23,42,0.45), 0 0 0 1px rgba(195,165,115,0.30)",maxH:"70dvh",children:[e.jsx(p,{justify:"center",pt:2.5,pb:1,children:e.jsx(C,{w:"42px",h:"4px",borderRadius:"full",bgGradient:"linear(to-r, gold.400, gold.600)",opacity:.7})}),e.jsxs(_e,{px:3,pt:1,pb:4,overflowY:"auto",children:[e.jsx(a,{fontSize:"11px",fontWeight:"800",letterSpacing:"0.14em",textTransform:"uppercase",color:"gold.600",mb:2,children:s("views.perps.tabs.transactions")}),e.jsx(nn,{})]})]})]}),e.jsxs(ys,{isOpen:U.isOpen,onClose:U.onClose,isCentered:!0,size:"md",children:[e.jsx(Ne,{bg:"rgba(12,15,20,0.55)",backdropFilter:"blur(4px)"}),e.jsxs(Cs,{borderRadius:"2xl",mx:3,bgGradient:"linear(to-b, #FFFFFF, #EEF0F2)",children:[e.jsx(zs,{pb:2,fontSize:"16px",fontWeight:"800",color:"blue.800",children:s("views.perps.tabs.funds")}),e.jsx(Ds,{}),e.jsx(_e,{pb:5,children:o?e.jsx(bo,{}):e.jsxs(p,{direction:"column",align:"center",justify:"center",gap:4,py:8,children:[e.jsx(a,{fontSize:"14px",color:"blackAlpha.700",textAlign:"center",children:s("views.perps.connectPrompt")}),e.jsx(z,{borderRadius:30,onClick:()=>r.open(Dt),children:s("actions.connectWallet")})]})})]})]})]})},jn=Object.freeze(Object.defineProperty({__proto__:null,Perps:an},Symbol.toStringTag,{value:"Module"}));
1export{an as P,jn as i,Ws as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.