PageSourceSearch

https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-RVS22MEO.js

js coinswitch.co collected 2026-10-01 10:40:42 UTC 269,713 bytes, 4 lines download raw bytes

1import{a as Fa,b as ka}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-5QJWNVPO.js";import{c as Ra}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-QKVMJIZE.js";import{a as $s,b as tn,c as Po,e as Oa,g as Ma}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-EAIOORZR.js";import{a as Ia,b as La,c as Pa}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-KPOR3CFV.js";import{a as Vs}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-QEBX2WF7.js";import{a as _a}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-EWIXUBWM.js";import{q as Ea}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-UDLLOAYI.js";import{A as ba,B as ha,C as xa,D as va,G as Io,H as Lo,I as Aa,J as qs,K as Ta,a as Ji,b as na,c as sa,d as oa,k as ma,m as pa,n as fa,o as _o,p as Us,q as Bs,r as ga}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-7NH7ZUI4.js";import{j as as,k as qn,n as Ds}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-FTMHPR66.js";import{b as ca}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-XY54CNME.js";import{a as os}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-EA5KB6OO.js";import{b as ia,g as aa,j as la,n as Fs}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-QJ7AY7AH.js";import{i as Un}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-JPKCMB2R.js";import{a as wa,e as da,f as ks}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-3JYAIORH.js";import{c as Zi}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-3Y2TLFQZ.js";import{e as ya,f as Sa,g as Ca,h as Na}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-VLWQ63HB.js";import{a as Me,b as Eo}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-YQC7DAZB.js";import{a as No,b as Ao}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-XDC7YZWU.js";import{c as yo,d as ta,l as So,o as Co,p as Os,q as ea,s as Ms,v as Rs,w as ra}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-63WJN3CC.js";import{a as To,c as is,h as ua,l as yn,m as Dn}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-RGZTBBWD.js";import{a as Bn}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-XDQHJCV6.js";import{a as ue}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-NCXAFE3P.js";import{a as ji}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-BVZXIAXV.js";import{b as Xi}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-LWO4GXEQ.js";import{$h as Oi,$j as $i,Ah as Zr,Ai as Es,Bl as Vt,Dl as zi,Ee as Ni,Fe as Ai,Fg as Yr,Fh as le,Fl as Gr,Gg as Ei,H as bn,Hc as wo,Ic as xi,Ie as go,Ig as Cs,Ih as Ns,J as hs,Jm as Hr,K as uo,Kc as Mc,Li as bo,Lm as Jr,M as es,Mi as Uc,Mm as vn,P as wi,Qa as be,Qh as Ii,Qi as _s,R as Lc,Ra as vs,S as di,Si as qt,T as mi,Th as Li,Ti as ho,Tj as Lr,U as pi,Ui as ns,Vh as Pi,Vk as xo,Wk as Is,Wm as Wi,Wn as I,X as fi,Xn as Oe,a as Ec,ak as Nr,bk as Yi,bl as Vc,d as co,di as Rn,dj as ze,dn as Ps,e as _c,eb as hi,ei as Mi,fb as Oc,gi as Ri,gj as xn,ie as yi,ii as Fn,je as ys,ji as Fi,kd as vi,ke as mo,ki as As,kj as Bi,kl as Ls,ld as Rc,le as po,li as ki,lj as qi,mi as Ts,mn as pr,ni as Di,oa as gi,oe as fo,ok as Gi,pa as Pc,qk as Bc,re as Fc,rf as Ti,rl as ss,se as Si,sl as kn,tf as Dc,ti as Ui,tj as Vi,tl as vo,ua as xs,ue as Ci,uh as _i,vm as Qi,we as kc,wm as Ki,ye as Ss,yk as Hi,zk as qc}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-I7IEEDYB.js";import{a as rr,c as Ic,e as Bt,f as jr,g as Xr,h as vr}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-DKQD472P.js";import{e as ne,f as hn,g as et,h as he}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-HAS4PDZR.js";import{a as bi,b as mr,d as $r,h as rs,p as _,wa as Ne}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-EERLKPTV.js";import{a as gs,b as ui,c as Vr,d as Cr,j as bs,x as Ir,y as Y}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-WHNMQWGZ.js";import{a as Qt}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-AQ6Q6WWQ.js";import{e as N}from"https://files-pro.coinswitch.co/cspro/1790767973354/build/_shared/chunk-OCHB5LEJ.js";var Sn=N(Y()),$c=()=>(0,Sn.jsx)("div",{className:"tw-h-8 tw-w-8 tw-animate-spin tw-rounded-full tw-border-2 tw-border-white/20 tw-border-t-white"}),Yc=({isOpen:t,accountName:e,mode:r="create"})=>t?(0,Sn.jsxs)("div",{className:"tw-fixed tw-inset-0 tw-z-[10000] tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-4 tw-bg-black/80",children:[(0,Sn.jsx)($c,{}),(0,Sn.jsx)("p",{className:"tw-font-roboto tw-text-sm tw-font-normal tw-leading-6 tw-text-gray-500 lg:tw-text-base",children:(()=>{switch(r){case"edit":return"Renaming Sub-Account to";case"switch":return"Switching to";case"create":default:return"Creating new Sub-Account"}})()}),(0,Sn.jsx)("div",{className:"tw-flex tw-h-10 tw-w-fit tw-flex-row tw-items-center tw-justify-center tw-gap-2 tw-rounded tw-bg-[#323542] tw-px-3 tw-py-1.5",children:(0,Sn.jsxs)("span",{className:"tw-font-roboto tw-text-base tw-font-medium tw-leading-6 tw-text-gray-100",children:['"',e,'"']})})]}):null,Ys=Yc;var Da=N(Qt());hn();var Pn=N(Y()),Gc=({value:t,onChange:e,badge:r="Futures",maxLength:n=12,placeholder:s="",hasError:o=!1,id:i})=>{let a=(0,Da.useMemo)(()=>`subaccount-name-input-${Math.random().toString(36).slice(2,9)}`,[]),l=i!=null?i:a,p=f=>{e(f.target.value)};return(0,Pn.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-col tw-items-start tw-gap-1",children:[(0,Pn.jsx)("label",{htmlFor:l,className:"tw-font-roboto tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[0.03em] tw-text-[#A0AEC0]",children:"Sub Account Name"}),(0,Pn.jsxs)("div",{className:ne("tw-flex tw-h-10 tw-w-full tw-min-w-[120px] tw-flex-row tw-items-center tw-justify-between tw-gap-0.5 tw-rounded tw-bg-[#1B1E2D] tw-px-3 tw-py-2",{"tw-border tw-border-red-01":o}),children:[(0,Pn.jsx)("input",{id:l,type:"text",value:t,onChange:p,maxLength:n,placeholder:s,className:"tw-flex-1 tw-bg-transparent tw-font-roboto tw-text-xs tw-font-medium tw-leading-3 tw-tracking-[0.03em] tw-text-white tw-outline-none placeholder:tw-text-gray-600"}),r&&(0,Pn.jsx)("span",{className:"tw-flex tw-items-center tw-gap-2.5 tw-rounded tw-bg-[#323542] tw-px-1.5 tw-py-0 tw-font-roboto tw-text-sm tw-font-medium tw-leading-[22px] tw-text-[#A0AEC0]",children:r})]})]})},Ua=Gc;he();mo();var Ye={NAME:{MIN_LENGTH:5,MAX_LENGTH:12,ALLOWED_PATTERN:/^[a-zA-Z0-9 ]*$/,STRIP_PATTERN:/[^a-zA-Z0-9 ]/g},MAX_SUB_ACCOUNTS:ys,TYPES:{FUTURES:"Futures",OPTIONS:"Options"}},On={LENGTH:`${Ye.NAME.MIN_LENGTH} - ${Ye.NAME.MAX_LENGTH} characters long`,ALPHANUMERIC:"Only alphabets & numbers are allowed",DUPLICATE:"A sub-account with this name already exists. Please choose a different one.",GENERIC_ERROR:"Something went wrong. Please try again."};var en=N(Y()),Hc=({name:t,onNameChange:e,accountType:r=Ye.TYPES.FUTURES,validationRules:n,hasErrors:s,apiError:o})=>(0,en.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-col tw-items-start tw-justify-center tw-gap-4",children:[(0,en.jsx)(Ua,{value:t,onChange:e,badge:r,maxLength:Ye.NAME.MAX_LENGTH,hasError:s||!!o}),o&&(0,en.jsx)("p",{className:"-tw-mt-1 tw-mb-2 tw-font-roboto tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[0.03em] tw-text-[#F3667B]",children:o}),(0,en.jsx)("div",{className:" tw-flex tw-w-full tw-flex-col tw-items-start tw-gap-1",children:n.map(i=>(0,en.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-row tw-items-center tw-gap-2",children:[(0,en.jsx)(et,{name:i.isValid?"green-tick":"exclamation-red",className:"tw-h-4 tw-w-4 tw-flex-shrink-0"}),(0,en.jsx)("span",{className:`tw-flex-1 tw-font-roboto tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[0.03em] ${i.isValid?"tw-text-[#718096]":"tw-text-red-01"}`,children:i.message})]},i.id))})]}),Oo=Hc;var fr=N(Qt());Lr();ho();he();Mi();var lr=N(Y()),zc=({isOpen:t,onClose:e,onSubmit:r,isLoading:n=!1,mode:s="create",initialName:o="",accountType:i=Ye.TYPES.FUTURES,error:a=null,existingNames:l=[]})=>{let p=s==="edit",[f,g]=(0,fr.useState)(o),[u,d]=(0,fr.useState)(null);(0,fr.useEffect)(()=>{d(a!=null?a:null)},[a]),(0,fr.useEffect)(()=>{t&&(g(o),d(null))},[t,o]);let c=(0,fr.useCallback)(dt=>{let M=dt.slice(0,Ye.NAME.MAX_LENGTH);g(M),u&&d(null)},[u]),m=(0,fr.useMemo)(()=>f.trim(),[f]),w=(0,fr.useMemo)(()=>{let dt=m.length>=Ye.NAME.MIN_LENGTH&&m.length<=Ye.NAME.MAX_LENGTH,M=Ye.NAME.ALLOWED_PATTERN.test(f),Ct=l.some(O=>{let ht=O.trim().toLowerCase(),B=m.toLowerCase();return p&&o.trim().toLowerCase()===ht?!1:ht===B});return{isLengthValid:dt,isAlphanumeric:M,isDuplicate:Ct}},[f,m,l,p,o]),b=(0,fr.useMemo)(()=>{let{isLengthValid:dt,isAlphanumeric:M}=w;return[{id:Rn.LENGTH,message:On.LENGTH,isValid:f.length===0||dt},{id:Rn.ALPHANUMERIC,message:On.ALPHANUMERIC,isValid:f.length===0||M}]},[f,w]),A=(0,fr.useMemo)(()=>
1{if(m.length===0)return!1;let{isLengthValid:dt,isAlphanumeric:M,isDuplicate:Ct}=w;return dt&&M&&!Ct},[m,w]),x=f.length>0&&!A,T=(0,fr.useMemo)(()=>m.length>0&&w.isDuplicate?On.DUPLICATE:null,[m,w.isDuplicate]),R=u||T,S=p&&m!==o.trim(),E=p?"Edit Sub Account Name":"Create Sub Account",Q=p?"Save":"Confirm",L=p?"Saving...":"Creating...",D=()=>{A&&!n&&(!p||S)&&r(f.trim())},q=()=>{g(""),d(null),e()},K=!A||n||p&&!S;return(0,lr.jsxs)(xn,{isOpen:t,onOpenChange:dt=>!dt&&q(),style:{zIndex:1e4},children:[(0,lr.jsx)(xn.Overlay,{className:"tw-fixed tw-bg-[#1D202C]/70 tw-opacity-100",style:{backdropFilter:"blur(7px)",WebkitBackdropFilter:"blur(7px)",zIndex:1e4}}),(0,lr.jsxs)(xn.Content,{className:"tw-flex tw-w-full tw-max-w-[400px] tw-flex-col tw-rounded-2xl tw-bg-black tw-px-6 tw-pb-6 tw-pt-6",style:{zIndex:10001},children:[(0,lr.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-row tw-items-center tw-justify-between tw-gap-2 tw-pb-4",children:[(0,lr.jsx)("h2",{className:"tw-font-roboto tw-text-[19px] tw-font-medium tw-leading-[27px] tw-text-[#EDF2F7]",children:E}),(0,lr.jsx)("button",{onClick:q,className:"tw-flex tw-h-5 tw-w-5 tw-items-center tw-justify-center",children:(0,lr.jsx)(et,{name:"close-white-icon",className:"tw-h-5 tw-w-5"})})]}),(0,lr.jsx)(Oo,{name:f,onNameChange:c,accountType:i,validationRules:b,hasErrors:x,apiError:R}),(0,lr.jsx)("div",{className:"tw-pt-8",children:p?(0,lr.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-row tw-items-center tw-gap-3",children:[(0,lr.jsx)(qt,{variant:qt.Variants.Default,onClick:q,className:"tw-flex tw-h-10 tw-w-1/2 tw-items-center tw-justify-center tw-gap-2 tw-rounded tw-border tw-border-[#CDA954] tw-bg-transparent tw-font-roboto tw-text-base tw-font-medium tw-leading-6 tw-text-[#CDA954] hover:tw-bg-[#CDA954]/10",disabled:n,children:"Cancel"}),(0,lr.jsx)(qt,{variant:qt.Variants.Default,onClick:D,disabled:K,className:`tw-flex tw-h-10 tw-w-1/2 tw-items-center tw-justify-center tw-gap-2 tw-rounded tw-bg-[#CDA954] tw-px-5 tw-py-4 tw-font-roboto tw-text-base tw-font-medium tw-leading-6 tw-text-black hover:tw-bg-[#CDA954]/90 ${K?"tw-cursor-not-allowed tw-opacity-50":""}`,children:n?L:Q})]}):(0,lr.jsx)(qt,{variant:qt.Variants.Default,onClick:D,disabled:K,className:`tw-flex tw-h-10 tw-w-full tw-items-center tw-justify-center tw-gap-2 tw-rounded tw-bg-[#CDA954] tw-px-5 tw-py-4 tw-font-roboto tw-text-base tw-font-medium tw-leading-6 tw-text-black hover:tw-bg-[#CDA954]/90 ${K?"tw-cursor-not-allowed tw-opacity-50":""}`,children:n?L:Q})})]})]})},Mo=zc;pi();he();var Ae=N(Y());function Qc({type:t,title:e,message:r}){let n=t==="success",s=n?"tw-text-[#C7D2E0]":"tw-text-[#A0AEC0]";return(0,Ae.jsxs)("div",{className:"tw-flex tw-flex-row tw-items-center tw-gap-3 tw-pr-8",children:[(0,Ae.jsx)(et,{name:n?"success-green-circle":"important-red-fill",className:"tw-h-6 tw-w-6 tw-flex-shrink-0"}),(0,Ae.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-1",children:[e&&(0,Ae.jsx)("p",{className:"tw-font-roboto tw-text-sm tw-font-medium tw-leading-[22px] tw-text-[#F7FAFC]",children:e}),r&&(0,Ae.jsx)("p",{className:`tw-font-roboto tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[0.03em] ${s}`,children:r})]})]})}function Kc({closeToast:t}){return(0,Ae.jsx)("button",{onClick:t,className:"tw-absolute tw-right-4 tw-top-4 tw-flex tw-h-5 tw-w-5 tw-items-center tw-justify-center",children:(0,Ae.jsx)(et,{name:"close-white-icon",className:"tw-h-5 tw-w-5"})})}function Cn(t,e,r,n){let s={position:(n==null?void 0:n.position)||"bottom-left",autoClose:(n==null?void 0:n.duration)||3e3,hideProgressBar:!0,closeOnClick:!0,pauseOnHover:!0,draggable:!0,closeButton:Kc,style:{width:"326px",padding:"16px",background:"#1A202C",border:"1.5px solid #4A5568",borderRadius:"8px",boxSizing:"border-box"},bodyStyle:{padding:0,margin:0}};return mi((0,Ae.jsx)(Qc,{type:t,title:e,message:r}),s)}function Vn({name:t}){return(0,Ae.jsxs)("span",{className:"tw-font-medium tw-text-white",children:['"',t,'"']})}var Wc={success:(t,e,r)=>Cn("success",t,e,r),error:(t,e,r)=>Cn("error",t,e,r),renameSuccess:(t,e,r)=>Cn("success","",(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)(Vn,{name:t})," was successfully renamed to"," ",(0,Ae.jsx)(Vn,{name:e}),"."]}),{duration:r?5e3:3e3}),renameError:(t,e)=>Cn("error","Account Rename Failed",t||"Something went wrong. Please try again.",{duration:e?5e3:3e3}),createSuccess:t=>
1Cn("success","Account Created Successfully!",(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)(Vn,{name:t})," was successfully created."]})),createError:t=>Cn("error","Account Creation Failed",t||"Something went wrong. Please try again."),switchSuccess:(t,e)=>Cn("success","",(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)(Vn,{name:t})," was successfully switched to"," ",(0,Ae.jsx)(Vn,{name:e}),"."]})),switchError:t=>Cn("error","",t||"We're unable to switch accounts right now. Please try again")},Gs=Wc;vr();var $t=N(Qt());es();Ic();var Ba=10,jc={accounts:[],active_account_id:null,is_loading:!1,error:null},Te=rr(jc),qa=rr(t=>{let e=t(Te);return e.active_account_id&&e.accounts.find(r=>r.id===e.active_account_id)||null}),Va=rr(t=>{let e=t(Te);return e.accounts.filter(r=>r.id!==e.active_account_id)}),$a=rr(t=>t(Te).accounts.reduce((r,n)=>r+n.unrealised_pnl,0)),Ya=rr(t=>t(Te).accounts.filter(r=>r.is_liquidation_risk)),Ga=rr(t=>t(Te).accounts.length>=Ba),Ha=rr(t=>({current:t(Te).accounts.length,max:Ba})),ud=rr(null,(t,e,r)=>{let n=t(Te);e(Te,{...n,accounts:r,is_loading:!1,error:null})}),za=rr(null,(t,e,r)=>{let n=t(Te),s=n.accounts.map(o=>({...o,is_active:o.id===r}));e(Te,{...n,accounts:s,active_account_id:r})}),Qa=rr(null,(t,e,r)=>{let n=t(Te);e(Te,{...n,accounts:[...n.accounts,r]})}),Ka=rr(null,(t,e,r,n)=>{let s=t(Te),o=s.accounts.map(i=>i.id===r?{...i,...n}:i);e(Te,{...s,accounts:o})}),wd=rr(null,(t,e,r)=>{let n=t(Te),s=n.accounts.filter(a=>a.id!==r),o=n.active_account_id;n.active_account_id===r&&s.length>0&&(o=s[0].id);let i=s.map(a=>({...a,is_active:a.id===o}));e(Te,{...n,accounts:i,active_account_id:o})}),dd=rr(null,(t,e,r)=>{let n=t(Te);e(Te,{...n,is_loading:r})}),md=rr(null,(t,e,r)=>{let n=t(Te);e(Te,{...n,error:r,is_loading:!1})}),pd=rr(null,(t,e)=>{let r=[{id:"acc_1",name:"Safe BTC Long",trading_mode:"INR",price_mode:"INR",margin_mode:"ISOLATED",unrealised_pnl:16e4,unrealised_pnl_percentage:12.19,noOfOpenPositions:11,noOfOpenPositionsAtLiquidationRisk:2,is_active:!0,is_liquidation_risk:!0,created_at:"2024-01-15T10:00:00Z",updated_at:"2024-01-16T14:30:00Z"},{id:"acc_2",name:"ETH Scalping",trading_mode:"USDT",price_mode:"USDT",margin_mode:"ISOLATED",unrealised_pnl:-25e3,unrealised_pnl_percentage:-3.5,noOfOpenPositions:5,noOfOpenPositionsAtLiquidationRisk:0,is_active:!1,is_liquidation_risk:!1,created_at:"2024-01-10T08:00:00Z",updated_at:"2024-01-16T12:00:00Z"},{id:"acc_3",name:"Hedge Account",trading_mode:"INR",price_mode:"INR",margin_mode:"ISOLATED",unrealised_pnl:45e3,unrealised_pnl_percentage:8.2,noOfOpenPositions:3,noOfOpenPositionsAtLiquidationRisk:0,is_active:!1,is_liquidation_risk:!1,created_at:"2024-01-12T15:00:00Z",updated_at:"2024-01-16T11:00:00Z"},{id:"acc_4",name:"Risky Alts",trading_mode:"USDT",price_mode:"USDT",margin_mode:"ISOLATED",unrealised_pnl:-8e4,unrealised_pnl_percentage:-15.5,noOfOpenPositions:8,noOfOpenPositionsAtLiquidationRisk:2,is_active:!1,is_liquidation_risk:!0,created_at:"2024-01-08T09:00:00Z",updated_at:"2024-01-16T13:00:00Z"},{id:"acc_5",name:"Conservative",trading_mode:"INR",price_mode:"INR",margin_mode:"ISOLATED",unrealised_pnl:12e3,unrealised_pnl_percentage:2.1,noOfOpenPositions:2,noOfOpenPositionsAtLiquidationRisk:0,is_active:!1,is_liquidation_risk:!1,created_at:"2024-01-14T11:00:00Z",updated_at:"2024-01-16T10:00:00Z"},{id:"acc_6",name:"Swing Trader",trading_mode:"INR",price_mode:"INR",margin_mode:"ISOLATED",unrealised_pnl:98e3,unrealised_pnl_percentage:18.9,noOfOpenPositions:6,noOfOpenPositionsAtLiquidationRisk:0,is_active:!1,is_liquidation_risk:!1,created_at:"2024-01-11T14:00:00Z",updated_at:"2024-01-16T09:00:00Z"}],n=r[0].id,s=r.map(o=>({...o,is_active:o.id===n}));e(Te,{accounts:s,active_account_id:n,is_loading:!1,error:null})});Zr();var Xc=(t=500)=>new Promise(e=>setTimeout(e,t));var Wa=async t=>(await Xc(300),{success:!0,data:{active_account_id:t},msg:"Switched successfully"});Mi();var Ro=(t={})=>{let{type:e=Ye.TYPES.FUTURES,initialName:r="",initialAccountName:n="",onSuccess:s,onError:o}=t,i=Bt(Te),a=Bt(qa),l=Bt(Va),p=Bt($a),f=Bt(Ya),g=Bt(Ga),u=Bt(Ha),d=jr(za),c=jr(Qa),m=jr(Ka),w=bn(),b=Bt(Yr),[A,x]=(0,$t.useState)(!0),[T,R]=(0,$t.useState)({create:!1,switch:!1,rename:!1,delete:!1}),[S,E]=(0,$t.useState)(r),[Q,L]=(0,$t.useState)(e),[D,q]=(0,$t.useState)(null),[K,dt]=(0,$t.useState)(!1),[M,Ct]=(0,$t.useState)("create"),[O,ht]=(0,$t.useState)("idle"),[B,at]=(0,$t.useState)(""),[h,y]=(0,$t.useState)(""),[P,G]=(0,$t.useState)(n),[U,H]=(0,$t.useState)(null),vt=(0,$t.useRef)(!1);(0,$t.useEffect)(()=>{vt.current||(vt.current=!0,x(!1))},[]),(0,$t.useEffect)(()=>{E(r),q(null)},[r]),(0,$t.useEffect)(()=>{L(e)},[e]);let X=(0,$t.useCallback)(Nt=>{let pt=Nt.slice(0,Ye.NAME.MAX_LENGTH);E(pt),D&&q(null)},[D]),At=(0,$t.useCallback)(()=>{E(M==="edit"?P:""),L(e),q(null)},[M,P,e]),xt=(0,$t.useCallback)(()=>{q(null)},[]),ut=(0,$t.useMemo)(()=>S.trim(),[S]),F=(0,$t.useMemo)(()=>{let Nt=ut.length>=Ye.NAME.MIN_LENGTH&&ut.length<=Ye.NAME.MAX_LENGTH,pt=Ye.NAME.ALLOWED_PATTERN.test(S);return[{id:Rn.LENGTH,message:On.LENGTH,isValid:S.length===0||Nt},{id:Rn.ALPHANUMERIC,message:On.ALPHANUMERIC,isValid:S.length===0||pt}]},[S,ut]),Z=(0,$t.useMemo)(()=>
1{if(ut.length===0)return!1;let Nt=ut.length>=Ye.NAME.MIN_LENGTH&&ut.length<=Ye.NAME.MAX_LENGTH,pt=Ye.NAME.ALLOWED_PATTERN.test(S);return Nt&&pt},[S,ut]),ct=(0,$t.useMemo)(()=>S.length>0&&!Z,[S,Z]),mt=(0,$t.useMemo)(()=>M==="edit"&&ut!==P.trim(),[M,ut,P]),it=(0,$t.useMemo)(()=>ut,[ut]),J=(0,$t.useCallback)(()=>{Ct("create"),E(""),q(null),H(null),dt(!0)},[]),wt=(0,$t.useCallback)(Nt=>{Ct("edit"),E(P),q(null),H(Nt||null),dt(!0)},[P]),lt=(0,$t.useCallback)(()=>{dt(!1),q(null),H(null)},[]),bt=uo({mutationKey:["CREATE_NEW_SUBACCOUNT",b==null?void 0:b.user_uuid],mutationFn:async Nt=>{let _t=await Rs({name:Nt});return No("CSK_PRO_BACKEND_ENDPOINT")(_t)},throwOnError:!1,onSuccess:async()=>{await Promise.all([w.invalidateQueries({queryKey:["ALL_SUBACCOUNTS",b==null?void 0:b.user_uuid]}),w.invalidateQueries({queryKey:["ALL_SUBACCOUNTS_WITH_POSITION_DETAILS",b==null?void 0:b.user_uuid]})])}}),Xt=uo({mutationKey:["UPDATE_SUBACCOUNT_DETAILS",b==null?void 0:b.user_uuid],mutationFn:async({subaccountId:Nt,subaccountName:pt})=>{let Jt=await ra(Nt,{name:pt});return No("CSK_PRO_BACKEND_ENDPOINT")(Jt)},throwOnError:!1,onSuccess:async()=>{await Promise.all([w.invalidateQueries({queryKey:["ALL_SUBACCOUNTS",b==null?void 0:b.user_uuid]}),w.invalidateQueries({queryKey:["ALL_SUBACCOUNTS_WITH_POSITION_DETAILS",b==null?void 0:b.user_uuid]})])}}),Mt=(0,$t.useCallback)(async Nt=>{let pt=P;M==="edit"&&y(pt),at(Nt),q(null),dt(!1),ht("loading");try{if(M==="create"){let _t=await bt.mutateAsync(Nt.trim()),Jt={id:(_t==null?void 0:_t.client_id)||`acc_${Date.now()}`,name:(_t==null?void 0:_t.name)||Nt.trim(),trading_mode:"INR",price_mode:"INR",margin_mode:"ISOLATED",unrealised_pnl:0,unrealised_pnl_percentage:0,noOfOpenPositions:0,noOfOpenPositionsAtLiquidationRisk:0,is_active:!1,is_liquidation_risk:!1,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};c(Jt),G(Nt),ht("success"),s==null||s({name:Nt,oldName:void 0,mode:M,accountId:_t==null?void 0:_t.client_id})}else if(M==="edit"){let _t=U||(a==null?void 0:a.id);if(!_t)throw new Error("No account ID to edit");let Jt=await Xt.mutateAsync({subaccountId:_t,subaccountName:Nt.trim()});m(_t,{name:(Jt==null?void 0:Jt.name)||Nt.trim()}),G(Nt),H(null),ht("success"),s==null||s({name:Nt,oldName:pt,mode:M})}}catch(_t){let Jt=(_t==null?void 0:_t.message)||"Operation failed. Please try again";q(Jt),ht("error"),o==null||o({name:Nt,mode:M,error:Jt})}},[M,P,s,o,c,a,m,U,bt,Xt]),Lt=(0,$t.useCallback)(()=>{ht("idle"),dt(!0)},[]),Ft=(0,$t.useCallback)(()=>{ht("idle"),at(""),y("")},[]),oe=(0,$t.useCallback)(async Nt=>{if((a==null?void 0:a.id)===Nt)return{success:!0};R(pt=>({...pt,switch:!0}));try{let pt=await Wa(Nt);return pt.success?(d(Nt),{success:!0}):{success:!1,error:pt.msg}}catch{return{success:!1,error:"Failed to switch account"}}finally{R(pt=>({...pt,switch:!1}))}},[a,d]);return{accounts:i.accounts,activeAccount:a,inactiveAccounts:l,totalUnrealisedPnl:p,accountsWithRisk:f,totalAccounts:u.current,maxAccounts:u.max,hasReachedMax:g,isInitializing:A,operationLoading:T,name:S,type:Q,handleNameChange:X,resetForm:At,setType:L,validationRules:F,isValid:Z,hasErrors:ct,apiError:D,setApiError:q,clearApiError:xt,isNameChanged:mt,sanitizedName:it,isFormOpen:K,mode:M,status:O,submittedName:B,oldName:h,currentAccountName:P,openCreateForm:J,openEditForm:wt,closeForm:lt,handleSubmit:Mt,handleRetry:Lt,handleStatusClose:Ft,setCurrentAccountName:G,handleSwitchAccount:oe}};vr();var Nn=N(Qt());Ne();Zr();Oe();pr();var Be=N(Qt());Ir();hn();he();mo();Oe();Ne();pr();var zt=N(Y()),Zc=({subaccountsPage:t,currentPage:e,isMobile:r=!0,activeSubaccountPositionCount:n,hideActiveUnderline:s=!1})=>{var ht,B,at;let[o]=bs(),i=(0,Be.useRef)(null),a=(0,Be.useRef)(new Map),l=o.get("nav"),[p,f]=(0,Be.useState)(!1),[g,u]=(0,Be.useState)(""),d=(0,Be.useMemo)(()=>{var h,y,P;return(P=(y=(h=t==null?void 0:t.subaccountsData)==null?void 0:h.data)==null?void 0:y.subaccountsList)!=null?P:[]},[(B=(ht=t==null?void 0:t.subaccountsData)==null?void 0:ht.data)==null?void 0:B.subaccountsList]),c=t==null?void 0:t.activeSubaccountId,m=(0,Be.useMemo)(()=>d.length===0?Ao:`Subaccount ${d.length+1}`,[d.length]),{isFormOpen:w,mode:b,status:A,submittedName:x,apiError:T,openCreateForm:R,closeForm:S,handleSubmit:E}=Ro({initialAccountName:m,onSuccess:({name:h,mode:y,accountId:P})=>{y==="create"&&P&&t.subaccountsHandlers.onSwitchSubaccount(P),!r&&y==="create"&&Gs.createSuccess(h)},onError:({mode:h,error:y})=>{!r&&h==="create"&&Gs.createError(y)}});(0,Be.useEffect)(()=>
1{if(!c||d.length===0)return;let h=setTimeout(()=>{let y=a.current.get(c);y&&(l==="positions"||l==="futures-orders")&&y.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},100);return()=>clearTimeout(h)},[c,d.length,l]);let Q=(0,Be.useMemo)(()=>d.length>=ys,[d]),L=(0,Be.useMemo)(()=>d.length>1,[d]),D=(0,Be.useCallback)(()=>{switch(e){case"positions":return"positions page";case"open_orders":return"open orders page";case"order_history":return"order history page";case"trade_history":return"trade history page";case"transactions":return"transactions page";case"trades":return"trades page";default:return e}},[e]),q=(0,Be.useCallback)(async(h,y)=>{var G,U;if(!h||!(t!=null&&t.subaccountsHandlers)||h===c)return;let P=(U=(G=d.find(H=>H.subaccountId===c))==null?void 0:G.subaccountName)!=null?U:"";I(_.SubAccountSwitchButtonClicked,{page:D(),device:r?"m-web":"desktop","From account":P,"To account":y}),r&&t.overlayHandlers?await t.overlayHandlers.handleSwitchSubaccount(h,y):(u(y),f(!0),t.subaccountsHandlers.onSwitchSubaccount(h),await Ps(1500),f(!1))},[t,d,c,D,r]),K=(0,Be.useCallback)(()=>{if(I(_.SubAccountCreateNewButtonClicked,{page:D(),device:r?"m-web":"desktop"}),r&&t.overlayHandlers)t.overlayHandlers.handleOpenCreateForm();else{if(d.length===0){t.handleCreateSubaccount(Ao);return}R()}},[D,r,d.length,t,R]),dt=(0,Be.useCallback)(()=>Q?null:L?(0,zt.jsx)("button",{onClick:K,className:"tw-absolute tw-right-3 tw-flex tw-items-center tw-justify-center tw-rounded-full tw-bg-pro-black-200 tw-p-1.5 [box-shadow:-12px_0px_12px_4px_#090A11,12px_0px_12px_4px_#090A11,0px_-12px_12px_4px_#090A11]","aria-label":"Create new sub-account",children:(0,zt.jsx)(et,{name:"futures-plus-gold",className:"tw-size-3"})}):(0,zt.jsxs)("button",{onClick:K,className:"tw-flex tw-shrink-0 tw-ml-2 tw-flex-row tw-items-center tw-justify-center tw-gap-1 tw-whitespace-nowrap","aria-label":"Create new sub-account",children:[(0,zt.jsx)("span",{className:"tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[2%] tw-text-gray-600",children:"Create New Account"}),(0,zt.jsx)("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-bg-pro-black-200 tw-p-1.5","aria-label":"Create new sub-account",children:(0,zt.jsx)(et,{name:"futures-plus-gold",className:"tw-size-2"})})]}),[Q,L,K]),M=(0,Be.useCallback)(()=>Q?null:(0,zt.jsxs)("button",{onClick:K,className:"tw-flex tw-shrink-0 tw-flex-row tw-items-center tw-justify-center tw-gap-1.5 tw-whitespace-nowrap tw-rounded-lg tw-px-3 tw-py-1.5 tw-transition-colors hover:tw-bg-white/5 [box-shadow:-12px_0px_12px_4px_#090A11,12px_0px_12px_4px_#090A11,0px_-12px_12px_4px_#090A11,0px_12px_12px_4px_#090A11]","aria-label":"Create new sub-account",children:[(0,zt.jsx)("span",{className:"tw-text-xs tw-font-medium tw-leading-5 tw-text-gray-600",children:"Create New Account"}),(0,zt.jsx)("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-bg-pro-black-200 tw-p-1","aria-label":"Create new sub-account",children:(0,zt.jsx)(et,{name:"futures-plus-gold",className:"tw-size-3.5"})})]}),[Q,K]),O=!(r?o.get("nav")==="futures-orders":e==="order_history");return!((at=t==null?void 0:t.subaccountsData)!=null&&at.isDataAvailable)&&!p||d.length===0&&!p?null:r?(0,zt.jsx)("div",{className:"tw-relative tw-mb-4 tw-w-full tw-bg-black tw-px-3 tw-pt-3 tw-border-b tw-border-gray-800",children:(0,zt.jsxs)("div",{ref:i,className:"no-scrollbar tw-flex tw-w-full tw-flex-row tw-items-center tw-gap-2 tw-overflow-x-auto tw-pr-10 tw-pb-1",children:[d.map((h,y)=>{let P=h.subaccountId===c,G=y===d.length-1,U=h.subaccountName,H=P&&n!=null?n:h.noOfOpenPositions,vt=h.noOfOpenPositionsAtLiquidationRisk>0;return(0,zt.jsxs)("button",{ref:X=>{X?a.current.set(h.subaccountId,X):a.current.delete(h.subaccountId)},onClick:()=>q(h.subaccountId,h.subaccountName),className:"tw-relative tw-flex tw-h-8 tw-shrink-0 tw-flex-col tw-items-center tw-justify-center tw-px-3 tw-transition-colors",children:[(0,zt.jsxs)("div",{className:"tw-flex tw-flex-row tw-items-center tw-gap-1",children:[(0,zt.jsxs)("span",{className:ne("tw-whitespace-nowrap tw-text-xs tw-leading-5 tw-tracking-[2%]",P?"tw-font-bold tw-text-white/85":"tw-font-normal tw-text-white/50"),children:[U,O&&H>0&&` (${H})`]}),vt&&(0,zt.jsx)(et,{name:"subaccount-warning",className:"tw-size-4"})]}),P&&(0,zt.jsx)("div",{className:"tw-absolute -tw-bottom-1 tw-left-1/2 tw-h-px tw-w-1/2 -tw-translate-x-1/2 tw-rounded-full tw-bg-white"}),(!G||!L&&!Q)&&(0,zt.jsx)("div",{className:"tw-absolute -tw-right-1 tw-h-4 tw-w-px tw-rounded-full tw-bg-gray-800"})]},h.subaccountId)}),dt()]})}):(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsx)("div",{className:"tw-relative tw-w-full tw-px-3 tw-pt-2.5",children:(0,zt.jsxs)("div",{ref:i,className:"no-scrollbar tw-flex tw-w-full tw-flex-row tw-items-center tw-gap-4 tw-overflow-x-auto tw-pr-4",children:[d.map((h,y)=>{var ut;let P=h.subaccountId===c,G=y===0,U=y===d.length-1,H=!U&&((ut=d[y+1])==null?void 0:ut.subaccountId)===c,vt=h.subaccountName,X=P&&n!=null?n:h.noOfOpenPositions,At=h.noOfOpenPositionsAtLiquidationRisk>0,xt=!U&&!P&&!H||U&&!Q&&L;return(0,zt.jsxs)("button",{ref:F=>{F?a.current.set(h.subaccountId,F):a.current.delete(h.subaccountId)},onClick:()=>q(h.subaccountId,h.subaccountName),className:ne("tw-relative tw-flex tw-py-2 tw-shrink-0 tw-flex-col tw-items-center tw-justify-center tw-px-4 tw-transition-colors",P&&"tw-bg-black-01 tw-rounded-t -tw-mx-3",G&&"tw-ml-0"),children:[(0,zt.jsxs)("div",{className:"tw-flex tw-flex-row tw-items-center tw-gap-1",children:[(0,zt.jsxs)("span",{className:ne("tw-whitespace-nowrap tw-text-xs tw-leading-5",P?"tw-font-bold tw-text-white":"tw-font-normal tw-text-gray-600"),children:[vt,O&&X>0&&` (${X})`]}),At&&(0,zt.jsx)(et,{name:"subaccount-warning",className:"tw-size-4"})]}),P&&!s&&(0,zt.jsx)("div",{className:"tw-absolute tw-bottom-0 tw-left-1/2 tw-h-px tw-w-1/2 -tw-translate-x-1/2 tw-rounded-full tw-bg-white"}),xt&&(0,zt.jsx)("div",{className:"tw-absolute -tw-right-1 tw-h-5 tw-w-px tw-rounded-full tw-bg-gray-800"})]},h.subaccountId)}),M()]})}),(0,zt.jsx)(Mo,{isOpen:w,onClose:S,onSubmit:E,mode:b,initialName:m,isLoading:A==="loading",error:T,existingNames:d.map(h=>h.subaccountName)}),(0,zt.jsx)(Ys,{isOpen:p,accountName:g,mode:"switch"}),(0,zt.jsx)(Ys,{isOpen:A==="loading",accountName:x,mode:b})]})},ja=(0,Be.memo)(Zc);he();var Et=N(Y());
1function Jc({futures:t,ticker_view_details:e,subaccountsPage:r,activeSubaccountPositionCount:n,enableOrdersCollapse:s=!1}){let[o,i]=(0,Nn.useState)(!0),[a,l]=(0,Nn.useState)(!0),[p,f]=(0,Nn.useState)(!0),[g]=Xr(Yr),u=Bn({feature:"futures_critical_fields_mask"}),d=s&&u;(0,Nn.useEffect)(()=>{if(!d||typeof window=="undefined")return;window.localStorage.getItem("pro_futures_orders_panel_minimized")==="true"&&f(!1)},[d]);let c=()=>{let w=!p;f(w),typeof window!="undefined"&&window.localStorage.setItem("pro_futures_orders_panel_minimized",w?"false":"true"),I(_.FuturesOrdersPanelToggled,{collapsed:!w})},m=d&&!p;return(0,Nn.useEffect)(()=>{I(_.FuturesPageLoaded)},[]),(0,Nn.useEffect)(()=>{if(typeof window=="undefined")return;window.__csBoltHooks=Object.assign(window.__csBoltHooks||{},{orderBookCollapse:!0});let w=()=>{window.__boltExtSidebarOpen===!0&&l(!1)},b=0,A=window.setInterval(()=>{w(),b+=1,(b>=30||window.__boltExtSidebarOpen!==void 0)&&window.clearInterval(A)},500),x=T=>{T&&T.detail&&T.detail.open===!0&&l(!1)};return window.addEventListener("boltExtSidebarOpenChanged",x),()=>{window.clearInterval(A),window.removeEventListener("boltExtSidebarOpenChanged",x)}},[]),(0,Et.jsxs)(Et.Fragment,{children:[t.futures_quiz,(0,Et.jsxs)("div",{className:"tw-flex tw-h-fit tw-min-h-[824px] tw-w-full tw-flex-col tw-divide-y tw-divide-black-06 tw-border-y tw-border-black-06",children:[e&&(t==null?void 0:t.ticker_details),(0,Et.jsxs)("div",{className:"tw-flex tw-min-h-[894px] tw-w-full tw-divide-x tw-divide-black-06 3xl:tw-h-full",children:[(0,Et.jsx)("div",{className:"tw-h-[894px] tw-w-9 tw-bg-black",children:t.coin_list}),(0,Et.jsxs)("div",{id:"main-class-div",className:"tw-flex tw-w-[calc(100vw-(288px+36px+2px))] tw-flex-col tw-divide-y tw-divide-black-06",children:[(0,Et.jsxs)("div",{className:"tw-flex tw-h-[54px] tw-w-full tw-items-center tw-border-b tw-border-black-06 tw-bg-black-01",children:[(0,Et.jsx)("div",{className:"tw-h-full tw-min-w-[235px] tw-flex-shrink-0",children:t.ticker_tile}),(0,Et.jsx)("div",{className:"tw-h-full tw-min-w-0 tw-flex-1",children:t.ticker_tape}),(0,Et.jsx)("div",{className:"tw-flex tw-h-full tw-flex-shrink-0 tw-items-center tw-overflow-visible",children:t.header_bar}),(0,Et.jsx)("div",{className:`tw-flex tw-h-full tw-w-[264px] tw-flex-shrink-0 tw-items-center ${a?"":"tw-bg-black tw-px-0"} `,children:a?(0,Et.jsxs)(Et.Fragment,{children:[(0,Et.jsx)("button",{type:"button",onClick:()=>l(!1),className:"tw-flex tw-p-2 tw-shrink-0 tw-cursor-pointer tw-items-center tw-justify-center tw-border-l-2 tw-border-[#494B57] tw-text-white tw-bg-black-05 tw-rounded-r-md",children:(0,Et.jsx)(et,{name:"futures-panel-chevron-right",className:"tw-h-[10px] tw-w-[5px] tw-shrink-0"})}),(0,Et.jsxs)("div",{className:"tw-flex tw-flex-1 tw-items-center tw-justify-center tw-gap-x-2",children:[(0,Et.jsx)("div",{onClick:()=>{i(!0),I(_.FuturesTradeOrderBookCilcked)},className:`tw-flex tw-h-7 tw-cursor-pointer tw-items-center tw-justify-center tw-whitespace-nowrap tw-rounded-lg tw-px-3 tw-text-xs tw-font-medium ${o?"tw-bg-gold-1000 tw-text-white":"tw-border tw-border-pro-gold-200 tw-bg-inherit tw-text-gold-700"}`,children:"ORDER BOOK"}),(0,Et.jsx)("div",{onClick:()=>{i(!1),I(_.FuturesTradeLastTradeClicked)},className:`tw-flex tw-h-7 tw-cursor-pointer tw-items-center tw-justify-center tw-whitespace-nowrap tw-rounded-lg tw-px-3 tw-text-xs tw-font-medium ${o?"tw-border tw-border-pro-gold-200 tw-bg-inherit tw-text-gold-700":"tw-bg-gold-1000 tw-text-white"}`,children:"LAST TRADES"})]})]}):(0,Et.jsxs)("button",{type:"button",onClick:()=>l(!0),className:"tw-ml-auto tw-flex tw-h-8 tw-w-[98px]  tw-cursor-pointer tw-flex-row tw-items-center tw-justify-center tw-gap-2 tw-whitespace-nowrap tw-rounded-bl-lg tw-rounded-tl-lg tw-bg-[#90763B] tw-py-[6px] tw-pl-1 tw-pr-2 tw-text-xs tw-font-medium  tw-text-white",children:[(0,Et.jsx)(et,{name:"futures-panel-chevron-right",className:"tw-h-[10px] tw-w-[5px] tw-shrink-0 tw-rotate-180"}),(0,Et.jsx)("span",{children:"Order Book"})]})})]}),(0,Et.jsxs)("div",{className:`tw-flex tw-divide-x tw-divide-black-06 3xl:tw-h-[70vh] ${m?"tw-min-h-[856px]":"tw-min-h-[531px]"}`,children:[(0,Et.jsx)("div",{className:"tw-h-full tw-flex-1 tw-bg-black-01",children:t.chart}),a&&(0,Et.jsx)("div",{className:"tw-relative tw-h-full tw-w-[264px]",style:{borderLeft:"2px s
1olid #494B57"},children:(0,Et.jsx)("div",{className:"tw-h-full tw-bg-black-01 tw-px-2 tw-py-2",children:o?t.order_book:t.trade_history})})]}),(0,Et.jsxs)("div",{className:`tw-flex tw-w-[calc(100vw-(288px+36px+2px))] tw-flex-col tw-bg-black ${m?"tw-h-auto":"tw-h-[365px]"}`,children:[(g==null?void 0:g.is_logged_in)&&r&&(0,Et.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center",children:[(0,Et.jsx)("div",{className:"tw-min-w-0 tw-flex-1",children:(0,Et.jsx)(ja,{subaccountsPage:r,currentPage:"positions",isMobile:!1,activeSubaccountPositionCount:n,hideActiveUnderline:m})}),d&&(0,Et.jsx)("button",{type:"button",onClick:c,"aria-label":m?"Expand orders panel":"Collapse orders panel",className:"tw-mr-3 tw-flex tw-h-6 tw-w-6 tw-shrink-0 tw-cursor-pointer tw-items-center tw-justify-center tw-rounded tw-bg-dark-gold tw-text-white tw-transition-colors hover:tw-bg-gold-500",children:(0,Et.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"tw-h-3 tw-w-3 tw-shrink-0",children:m?(0,Et.jsx)("path",{d:"M5 15l7-7 7 7",stroke:"currentColor",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round"}):(0,Et.jsx)("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"3.5",strokeLinecap:"round"})})})]}),!m&&(0,Et.jsx)("div",{className:"tw-flex-1 tw-overflow-hidden",children:g!=null&&g.is_logged_in?t==null?void 0:t.my_orders:(0,Et.jsxs)("div",{className:"tw-flex tw-h-full tw-w-full tw-flex-col",children:[(0,Et.jsxs)("div",{className:"tw-flex tw-h-8 tw-w-full tw-items-center tw-border-b tw-border-pro-gray-200 tw-text-xs tw-font-semibold tw-uppercase tw-text-pro-gray-500",children:[(0,Et.jsx)("div",{className:"tw-px-3 tw-py-2",children:"Open Orders"}),(0,Et.jsx)("div",{className:"tw-px-3 tw-py-2",children:"Open Positions"}),(0,Et.jsx)("div",{className:"tw-px-3 tw-py-2",children:"Trade History"}),(0,Et.jsx)("div",{className:"tw-px-3 tw-py-2",children:"Order History"})]}),(0,Et.jsx)("div",{className:"tw-mx-auto tw-flex tw-w-full tw-max-w-[850px] tw-flex-1 tw-items-center tw-justify-center",children:(0,Et.jsx)("img",{src:mr("/pro/assets/images/futures/my-order-default_new.png"),alt:"",width:"98%"})})]})})]})]}),(0,Et.jsx)("div",{className:"tw-h-full tw-w-[288px] tw-bg-black tw-px-2",children:t==null?void 0:t.trade_widget})]}),(0,Et.jsx)("div",{className:"tw-sticky tw-bottom-0 tw-z-40 tw-h-8 tw-w-full tw-overflow-y-hidden tw-bg-gray-800",children:t.info_bar})]}),(0,Et.jsx)(Ra,{page:"Futures"})]})}var ll=N(Qt());Ir();he();Ne();Oe();hn();var Za=N(Qt()),te=N(Y()),Xa=()=>(0,te.jsxs)("svg",{width:"16",height:"12",viewBox:"0 0 14 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,te.jsx)("path",{d:"M0.498225 8.92253L4.02737 3.98231C4.69887 3.04233 6.10745 3.07798 6.73054 4.05072L7.58313 5.38175C8.21318 6.36535 9.64224 6.38834 10.3036 5.4255L12.9088 1.63262",stroke:"#A0AEC0",strokeWidth:"1.2"}),(0,te.jsx)("path",{d:"M0.663636 0.408171L10.8673 0.408552",stroke:"#A0AEC0",strokeWidth:"0.8"}),(0,te.jsx)("path",{d:"M3.11291 9.59184L12.0921 9.59145",stroke:"#A0AEC0",strokeWidth:"0.8"})]}),Zd=()=>(0,te.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,te.jsx)("path",{d:"M2.80027 10.3629V6.90858H1.4003H0.000336015V10.3629V13.8172H1.4003H2.80027V10.3629ZM8.40013 6.90858V3.45429H7.00017H5.6002V6.90858V10.3629H7.00017H8.40013V6.90858ZM14 3.45429V0H12.6H11.2001V3.45429V6.90858H12.6H14V3.45429Z",fill:"#A0AEC0"})}),tu=()=>(0,te.jsx)("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"tw-ml-0.5",children:(0,te.jsx)("path",{d:"M1 1L5 5L1 9",stroke:"#A0AEC0",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),eu=()=>(0,te.jsxs)("svg",{width:"16",height:"12",viewBox:"0 0 14 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,te.jsx)("path",{d:"M0.498225 8.92253L4.02737 3.98231C4.69887 3.04233 6.10745 3.07798 6.73054 4.05072L7.58313 5.38175C8.21318 6.36535 9.64224 6.38834 10.3036 5.4255L12.9088 1.63262",stroke:"#CDA953",strokeWidth:"1.2"}),(0,te.jsx)("path",{d:"M0.663636 0.408171L10.8673 0.408552",stroke:"#CDA953",strokeWidth:"0.8"}),(0,te.jsx)("path",{d:"M3.11291 9.59184L12.0921 9.59145",stroke:"#CDA953",strokeWidth:"0.8"})]}),ru=()=>(0,te.jsx)("svg",{width:"6",height:"10",viewBox:"0 0 6 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"tw-ml-0.5",children:(0,te.jsx)("path",{d:"M1 1L5 5L1 9",stroke:"#CDA953",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),nu=({onClick:t,showBadge:e=!1,variant:r="pill",customStyle:n={}})=>r==="link"?(0,te.jsxs)("button",{onClick:t,className:"tw-flex tw-items-center tw-gap-x-1.5",style:n,children:[(0,te.jsx)(eu,{}),(0,te.jsx)("span",{className:"tw-text-xs tw-font-medium tw-text-gold-500",children:"Scalper Mode"}),(0,te.jsx)(ru,{})]}):r==="pill"?(0,te.jsxs)("div",{className:"tw-relative tw-shrink-0 tw-rounded-lg tw-p-[0.5px]",style:{background:"linear-gradient(135deg, rgba(82,68,34,0.7), rgba(184,153,76,0.7))",...n},children:[(0,te.jsxs)("button",{onClick:t,className:"tw-flex tw-h-8 tw-items-center tw-gap-x-2 tw-whitespace-nowrap tw-rounded-lg tw-bg-black tw-px-2 tw-text-xs tw-font-medium tw-text-[#A0AEC0]",children:[(0,te.jsx)(Xa,{}),(0,te.jsx)("span",{children:"Scalper Mode"}),(0,te.jsx)(tu,{})]}),e&&(0,te.jsx)("span",{className:"tw-absolute -tw-right-1 -tw-top-1.5 tw-h-2.5 tw-w-2.5 tw-rounded-full tw-border tw-border-black tw-bg-red-500"})]}):(0,te.jsxs)("button",{onClick:t,className:"tw-relative tw-flex tw-flex-1 tw-items-center tw-justify-center tw-gap-x-2 tw-rounded-xl tw-border tw-border-[rgba(205,169,84,0.3)] tw-bg-[rgba(205,169,84,0.05)] tw-px-4 tw-py-3",children:[(0,te.jsx)(Xa,{}),(0,te.jsx)("span",{className:"tw-text-xs tw-font-medium tw-text-white",children:"Scalper Mode"}),e&&(0,te.jsx)("span",{className:"tw-absolute -tw-right-1 -tw-top-2 tw-rounded tw-bg-red-02 tw-px-1.5 tw-py-0.5 tw-text-[10px] tw-font-bold tw-leading-none tw-text-white",children:"NEW"})]});var Hs=(0,Za.memo)(nu);var Re=N(Qt());vr();Bc();es();qc();Oe();Ne();Es();pr();vo();Ir();As();go();kc();Fc();Zr();mo();Yi();es();Gr();pr();vo();var $n=bi("production"),su=()=>{var a;
1let t=kn(ss(),"9.3.8"),e=!!($n!=null&&$n.XP_CONFIG_COLLECTION)&&t,{data:r,isError:n,isFetching:s,isFetched:o}=hs({queryKey:["is-bolt-enabled"],queryFn:async()=>{try{return await zi({collection:$n==null?void 0:$n.XP_CONFIG_COLLECTION,path:"bolt"})}catch(l){throw console.error("[bolt] error",l),l}},enabled:e,staleTime:5*60*1e3,retry:!1}),i=e?!o||s:!1;return n?{is_enabled:!1,isLoading:!1}:{is_enabled:(a=r==null?void 0:r.is_enabled)!=null?a:!1,isLoading:i}},Ja=su;var tl={SUBACCOUNT_CREATE_FAILURE:{header:"Couldn't start Scalper",content:"Please try again."}},ou="Subaccount 1",ls="scalper_intro_show_count",iu=3,el="scalper_nudge_dismissed",ol="scalper_intro_last_session_id",rl=!0,nl=Gi(!1),Ar=null;function il(){return typeof window=="undefined"?"":window.appSessionId||""}var al="scalper_intro_shown_session";function au(){let t=il();return t?vn(ol)===t:Qi(al)===!0}function sl(){let t=il();t&&Jr(ol,t),Ki(al,!0)}function zs(){let{sendMessage:t}=Hi.useSender(),e=Bt(Ui),r=Bt(_i),n=Bt(Ri),s=Bt(Ss),o=Bt(Ni),i=jr(Fi),a=bn(),l=Bt(Si),p=Bt(Ci),f=Bt(nl),g=jr(nl),[u,d]=(0,Re.useState)(!1),[c,m]=(0,Re.useState)(!1),w=ui(),b=w.pathname.includes("dma-futures"),{futuresInrUsdtText:A}=ue(),x=Bn({feature:"many_to_one"}),{is_enabled:T,isLoading:R}=Ja();(0,Re.useEffect)(()=>{if(!n)return;let B=Object.values(n).some(y=>y===94),at=ss(),h=kn(at,"9.3.0");m(Hr()&&rl&&kn(at,"9.2.6")&&!B&&(!x||h)&&!(r&&b)&&Object.keys(o!=null?o:{}).length>0&&!R)},[n,x,r,b,o,R]);let S=(0,Re.useMemo)(()=>!rl||!c||!Hr()||!n||!!kn(ss(),"9.3.4")?!1:Object.values(n).some(at=>typeof at=="number"&&at>100),[n,c]);(0,Re.useEffect)(()=>{if(!c)return;vn(el)||(d(!0),I(_.ScalperNudgeShown))},[c]);let E=(0,Re.useCallback)(()=>au()?!1:(vn(ls)||0)<iu,[]),Q=(0,Re.useCallback)((B,at,h)=>{var G,U,H;let y=s?o==null?void 0:o[s]:null,P={source:B,symbol:at,usdt_inr_rate:e,check_open_positions:h,client_id:(G=y==null?void 0:y.id)!=null?G:null,custody_wallet_id:(U=y==null?void 0:y.cwId)!=null?U:null,subaccount_usdt_rate:(H=y==null?void 0:y.usdtRate)!=null?H:null,asset_price_in:fo[l],account_value_in:po[p],bolt_enabled:T};t({action_type:"OPEN_SCALPER",...P})},[t,e,s,o,l,p,T]),L=(0,Re.useRef)(null),D=(0,Re.useCallback)(async(B,at,h)=>{var P,G,U;let y=(P=L.current)!=null?P:Rs({name:ou});L.current=y;try{let H=await y;if(!(H!=null&&H.success)||!((G=H==null?void 0:H.data)!=null&&G.client_id)){Nr(tl.SUBACCOUNT_CREATE_FAILURE);return}let vt={source:B,symbol:at,usdt_inr_rate:e,check_open_positions:h,client_id:H.data.client_id,custody_wallet_id:(U=H.data.user_custody_wallet_id)!=null?U:null,subaccount_usdt_rate:e!=null?e:null,asset_price_in:fo[l],account_value_in:po[p],bolt_enabled:T};t({action_type:"OPEN_SCALPER",...vt}),a.invalidateQueries({queryKey:["ALL_SUBACCOUNTS"]}),a.invalidateQueries({queryKey:["ALL_SUBACCOUNTS_WITH_POSITION_DETAILS"]})}catch(H){Nr(tl.SUBACCOUNT_CREATE_FAILURE),console.warn("[Scalper] create-subaccount threw",H)}finally{L.current=null}},[t,e,a,l,p,T]),q=(0,Re.useCallback)((B,at,h)=>{Object.keys(o!=null?o:{}).some(P=>P!==yi)?Q(B,at,h):D(B,at,h)},[o,D,Q]),K=(0,Re.useRef)(null),dt=(0,Re.useRef)("");if(w.search!==dt.current){dt.current=w.search;let B=new URLSearchParams(w.search);B.get("autoOpenScalper")==="true"&&(K.current={symbol:B.get("scalperSymbol")||"BTCUSDT"})}(0,Re.useEffect)(()=>{if(!c||!K.current)return;let B=K.current.symbol;K.current=null;let h=`${B.replace(/(USDT|INR)$/i,"").toUpperCase()}${A()}`,y=new URLSearchParams(window.location.search);y.delete("autoOpenScalper"),y.delete("scalperSymbol");let P=y.toString(),G=window.location.pathname+(P?`?${P}`:"");if(window.history.replaceState(null,"",G),S){i(!0);return}q("deeplink",h,!1)},[c,w.search,q,A,S,i]);let M=(0,Re.useCallback)((B,at="BTC",h=!1)=>{if(I(_.ScalperModeEntryClicked,{source:B,symbol:at}),S){i(!0);return}E()?(Ar={source:B,symbol:at,checkOpenPositions:h},I(_.ScalperIntroShown,{source:B,symbol:at}),g(!0)):q(B,at,h)},[S,E,i,g,q]),Ct=(0,Re.useCallback)((B="BTC")=>{sl();let at=vn(ls)||0;Jr(ls,at+1),I(_.ScalperTryNow),g(!1);let h=(Ar==null?void 0:Ar.source)||"unknown",y=(Ar==null?void 0:Ar.symbol)||B,P=(Ar==null?void 0:Ar.checkOpenPositions)||!1;Ar=null,q(h,y,P)},[q,g]),O=(0,Re.useCallback)(()=>{sl();let B=vn(ls)||0;
1Jr(ls,B+1),I(_.ScalperIntroDismissed),g(!1),Ar=null},[g]),ht=(0,Re.useCallback)(()=>{I(_.ScalperNudgeDismissed),Jr(el,!0),d(!1)},[]);return{isEnabled:c,onScalperClick:M,onIntroTryNow:Ct,showIntro:f,dismissIntro:O,showTooltip:u,dismissTooltip:ht,isAppUpdateNeeded:S}}var Tt=N(Y()),lu=({isDMA:t,data:{display_contract:e,contract:r,type:n,price:s,percentage_change:o,is_positive:i},additional_data:a,setIsHovered:l,isLoading:p,contract_config:f,precision:g})=>{var q,K,dt,M,Ct,O,ht,B,at,h;let{is_mobile:u}=Cr(),d=g==null?void 0:g.limit_precision,c=Vr(),[m]=bs(),w=m.get("via_deeplink"),{isInr:b,isUsdt:A,unit:x,futuresInrUsdtConverter:T,toggleUnitWithConsent:R,CURRENCY_UNIT:S,isInrEnable:E,isUsdtModeEnabled:Q}=ue(),{isEnabled:L,onScalperClick:D}=zs();return p||!s?u?(0,Tt.jsxs)("div",{className:"tw-mx-auto tw-flex tw-h-full tw-w-[98%] tw-items-center tw-justify-between tw-gap-x-2",children:[(0,Tt.jsx)("div",{className:"tw-h-[80%] tw-flex-1 tw-animate-pulse tw-bg-pro-black-200"}),(0,Tt.jsx)("div",{className:"tw-h-[80%] tw-w-[30%] tw-animate-pulse tw-bg-pro-black-200"})]}):(0,Tt.jsx)("div",{className:"tw-flex tw-h-full tw-w-full tw-items-center tw-justify-center",children:(0,Tt.jsx)("div",{className:"tw-h-[80%] tw-w-[98%] tw-animate-pulse tw-bg-pro-black-200"})}):u?(0,Tt.jsx)("div",{className:"tw-flex tw-h-full tw-w-full tw-items-center tw-bg-black-01  tw-px-4 tw-text-sm",children:e&&(0,Tt.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between",children:[(0,Tt.jsxs)("div",{className:ne("tw-flex tw-items-start tw-gap-x-2",L&&"tw-mt-[5px]"),children:[(0,Tt.jsx)("div",{onClick:()=>{let y=t?$r.dma_futures.url:$r.futures_trade_page_v2.url;c(w?`${y}?nav=${"futures-market"}`:-1),I(_.FuturesContractListClicked)},children:(0,Tt.jsx)(et,{name:"kuber-arrow-back-white",className:"tw-size-6"})}),(0,Tt.jsxs)("div",{className:"tw-flex tw-cursor-pointer tw-items-start tw-gap-x-2",onClick:()=>{let y=t?$r.dma_futures.url:$r.futures_trade_page_v2.url;c(`${y}?nav=${"futures-market"}`),I(_.FuturesContractListClicked)},children:[(0,Tt.jsx)("img",{src:(B=a==null?void 0:a.logo)!=null?B:"",alt:"coin_icon",width:20,className:"tw-h-full"}),(0,Tt.jsxs)("div",{className:"tw-flex tw-flex-col tw-justify-between",children:[(0,Tt.jsxs)("div",{className:"tw-flex tw-cursor-pointer tw-items-center tw-gap-x-0.5",children:[(0,Tt.jsxs)("h1",{className:"tw-flex",children:[(0,Tt.jsx)("div",{className:"tw-text-base tw-font-medium tw-leading-3 tw-text-white",children:(at=e==null?void 0:e.split(","))==null?void 0:at[0]}),(0,Tt.jsxs)("div",{className:"tw-text-base tw-font-medium tw-leading-3 tw-text-gray-600",children:["/",(h=e==null?void 0:e.split(","))==null?void 0:h[1]]})]}),(0,Tt.jsx)(et,{name:"coin-selector-icon",width:"tw-w-[10px]",height:"tw-h-[14px]",className:"tw-ml-1"}),(f==null?void 0:f.is_pre_market)&&(0,Tt.jsxs)("div",{onClick:y=>{y.stopPropagation()},className:"tw-group tw-relative tw-left-1",children:[(0,Tt.jsx)(et,{name:"innovation-logo",width:"tw-w-4",height:"tw-h-4"}),(0,Tt.jsx)("div",{className:"tw-absolute tw-left-[-28px] tw-top-6 tw-z-50 tw-hidden tw-w-[220px] tw-rounded tw-bg-gray-800 tw-p-3 tw-text-xs tw-tracking-wide tw-text-gray-500 group-hover:tw-block",children:"This is a Pre Market contract that carries a high element of risk. Please do your research before trading."})]})]}),(0,Tt.jsx)("div",{className:"tw-flex tw-items-center tw-gap-x-1 tw-text-xxs tw-font-medium tw-text-gray-600",children:L?(0,Tt.jsxs)("p",{className:"tw-text-xxs tw-font-normal tw-text-gray-500",children:["Up to ",a==null?void 0:a.max_leverage,"x Leverage"]}):(0,Tt.jsx)("div",{children:n})})]})]})]}),L?(0,Tt.jsx)("div",{className:"tw-flex tw-flex-col tw-items-end tw-gap-y-1",children:(0,Tt.jsx)(Hs,{variant:"pill",onClick:()=>{var y;return D("asset_page",((y=e==null?void 0:e.replace(",",""))==null?void 0:y.toUpperCase())||"BTCINR")},showBadge:!0})}):(0,Tt.jsx)("div",{children:(0,Tt.jsxs)("p",{className:"tw-text-xxs tw-font-normal tw-text-gray-500",children:["Up to ",a==null?void 0:a.max_leverage,"x Leverage"]})})]})}):(0,Tt.jsxs)("div",{className:"tw-flex tw-h-full tw-w-full tw-select-none tw-items-center tw-gap-x-2.5 tw-pl-3",children:[(0,Tt.jsx)("div",{className:"tw-min-w-[28px]",children:(a==null?void 0:a.logo)&&(0,Tt.jsx)("img",{className:"tw-h-7 tw-w-7",src:(q=a==null?void 0:a.logo)!=null?q:"",alt:""})}),(0,Tt.jsx)("div",{className:"tw-flex tw-h-full tw-w-full tw-gap-x-4 tw-text-base tw-font-medium",children:e&&(0,Tt.jsxs)(Tt.Fragment,{children:[(0,Tt.jsxs)("div",{className:"tw-flex tw-min-w-20 tw-cursor-pointer tw-flex-col tw-items-start tw-justify-center",onClick:()=>l(y=>!y),children:[(0,Tt.jsxs)("div",{className:"tw-flex",children:[(0,Tt.jsxs)("h1",{className:"tw-flex",children:[(0,Tt.jsx)("div",{className:"tw-text-white",children:(dt=(K=e==null?void 0:e.split(","))==null?void 0:K[0])==null?void 0:dt.toUpperCase()}),(0,Tt.jsx)("div",{className:"tw-text-gray-600",children:(Ct=(M=e==null?void 0:e.split(","))==null?void 0:M[1])!=null&&Ct.toUpperCase()?`/${(ht=(O=e==null?void 0:e.split(","))==null?void 0:O[1])==null?void 0:ht.toUpperCase()}`:""})]}),(f==null?void 0:f.is_pre_market)&&(0,Tt.jsxs)("div",{onClick:y=>{y.stopPropagation()},className:"tw-group tw-relative tw-left-1 tw-top-1",children:[(0,Tt.jsx)(et,{name:"innovation-logo",width:"tw-w-4",height:"tw-h-4"}),(0,Tt.jsx)("div",{className:"tw-absolute tw-left-[-28px] tw-top-6 tw-z-50 tw-hidden tw-w-[220px] tw-rounded tw-bg-gray-800 tw-p-3 tw-text-xs tw-tracking-wide tw-text-gray-500 group-hover:tw-block",children:"This is a Pre Market contract that carries a high element of risk. Please do your research before trading."})]})]}),(0,Tt.jsx)("div",{className:"tw-text-sm tw-text-gray-600",children:n})]}),(0,Tt.jsxs)("div",{className:ne("tw-flex tw-min-w-[76px] tw-flex-col tw-items-start tw-justify-center",{"tw-text-pro-green-500":i,"tw-text-pro-red-500":!i,"tw-min-w-[110px]":b}),children:[(0,Tt.jsx)("div",{children:s?T(Number(s),!0,d||2):"--"}),(0,Tt.jsx)("div",{className:"tw-text-sm",children:o||"--"})]})]})})]})},km=(0,ll.memo)(lu);var Mn=N(Qt());vr();Ir();Ne();Oe();he();Lr();Gr();var ae=N(Y()),cr={symbol:{},data:{funding_rate:{id:"funding_rate",title:"Funding Rate",value:null,info:`The payment rate exchanged between the long and short positions for the next funding. If the funding rate is positive, longs pay shorts. If negative, shorts pay longs.
2 Funding countdown refers to the timer that counts down to the next funding fee exchange`},funding_countdown:{id:"funding_countdown",title:"Funding Time",value:null,info:""},"24h_high":{id:"24h_high",title:"24h High",value:null,info:""},"24h_low":{id:"24h_low",title:"24h Low",value:null,info:""},"24h_volume_base":{id:"24h_volume_base",title:"24h Volume",value:null,info:""},"24h_volume_quote":{id:"24h_volume_quote",title:"24h Volume",value:null,info:""},mark_price:{id:"mark_price",title:"Mark Price",value:null,info:""},exchange:{id:"exchange",title:"Exchange",value:rs.binance,info:""}}},cu=({ticker_data:t,mark_price_data:e,precision:r,setTickerViewDetails:n,tickerTile:s,isLoading:o})=>{let{is_mobile:i}=Cr(),[a,l]=Xr(_a),{unit:p,futuresInrUsdtVolConverter:f,futuresInrUsdtConverter:g,futuresInrUsdtText:u}=ue(),d=(m,w)=>{i&&l({...a,currentBottomSheet:"toolTip",toolTipBody:{title:m,content:w}})},c=(0,Mn.useMemo)(()=>{var R;if(!t||!e||!r)return[];let m=`${Vt.usdtFormat((e==null?void 0:e.funding_rate)*100,4)}%`,w=(e==null?void 0:e.funding_countdown)||"--",b=g(e==null?void 0:e.mark_price,!0,r==null?void 0:r.limit_precision),A=g(t==null?void 0:t.highPrice,!0,r==null?void 0:r.limit_precision),x=g(t==null?void 0:t.lowPrice,!0,r==null?void 0:r.limit_precision),T=f(t==null?void 0:t.quoteVolume,!0,2);return i?[{id:"contract_price",title:g(s==null?void 0:s.price,!0,r==null?void 0:r.limit_precision),value:(R=s==null?void 0:s.percentage_change)!=null?R:"",info:cr.data.funding_rate.info,showMarketColor:!0},{id:"funding_rate",title:"Funding / Countdown",value:`${m!=null?m:"--"} / ${w!=null?w:"--"}`,info:cr.data.funding_rate.info,showMarketColor:!1},{id:"mark_price",title:"Mark Price",value:b!=null?b:"--",info:cr.data.mark_price.info,showMarketColor:!1},{id:"24h_volume_quote",title:`24h Volume (${u()})`,value:T!=null?T:"--",info:cr.data["24h_volume_quote"].info,showMarketColor:!1},{id:"24h_high/24h_low",title:"24h High / Low",value:`${A!=null?A:"--"} / ${x!=null?x:"--"}`,info:cr.data["24h_high"].info,showMarketColor:!1}]:[{id:"funding_rate/funding_countdown",title:"Funding / Countdown",value:`${m!=null?m:"--"} / ${w!=null?w:"--"}`,info:cr.data.funding_rate.info},{id:"mark_price",title:"Mark Price",value:b!=null?b:"--",info:cr.data.mark_price.info},{id:"24h_volume_quote",title:`24h Volume (${u()})`,value:T!=null?T:"--",info:cr.data["24h_volume_quote"].info},{id:"24h_high/24h_low",title:"24h High / Low",value:`${A!=null?A:"--"} / ${x!=null?x:"--"}`,info:cr.data["24h_high"].info}]},[t,e,r,i,s==null?void 0:s.price,s==null?void 0:s.percentage_change,g,f,u]);return o||c.length===0?i?(0,ae.jsxs)("div",{className:"tw-mx-auto tw-flex tw-h-[40px] tw-w-[98%] tw-items-center tw-justify-between tw-gap-x-2",children:[(0,ae.jsx)("div",{className:"tw-h-full tw-w-[20%] tw-animate-pulse tw-bg-pro-black-200"}),(0,ae.jsx)("div",{className:"tw-flex tw-h-full tw-w-full tw-items-center tw-gap-x-2 tw-overflow-x-scroll tw-scrollbar-hide",children:Array.from({length:5}
2,(m,w)=>(0,ae.jsx)("div",{className:"tw-h-full tw-min-w-[100px] tw-flex-1 tw-animate-pulse tw-bg-pro-black-200"},w))})]}):(0,ae.jsx)("div",{className:"tw-flex tw-h-full tw-w-full tw-items-center tw-justify-center",children:(0,ae.jsx)("div",{className:"tw-h-[80%] tw-w-[98%] tw-animate-pulse tw-bg-pro-black-200"})}):(0,ae.jsxs)("div",{className:"tw-relative tw-flex tw-h-full tw-w-full tw-min-w-0 tw-items-center tw-justify-between tw-overflow-hidden tw-text-xs max-lg:tw-bg-black-01",children:[(0,ae.jsx)("div",{onClick:()=>{i&&(n(!0),I(_.FuturesDetailsButtonClicked,{click:"Shadow Click"}))},className:`tw-absolute tw-right-0 tw-top-0 tw-z-10 tw-h-full tw-w-10 tw-bg-gradient-to-r tw-from-transparent tw-to-black-01 ${i?"tw-pointer-events-auto":"tw-pointer-events-none"}`}),i&&(0,ae.jsxs)("div",{className:`tw-flex tw-h-full tw-items-center tw-justify-between tw-overflow-x-scroll tw-transition-all tw-duration-300 tw-scrollbar-hide lg:tw-max-w-[950px] lg:tw-pl-2 max-lg:tw-ml-4 max-lg:tw-pl-0 ${o?"tw-w-0":"tw-w-full"}`,children:[i&&c.map(m=>{var A,x,T,R;let w=(x=(A=cr==null?void 0:cr.data)==null?void 0:A[m.id])==null?void 0:x.title,b=(R=(T=cr==null?void 0:cr.data)==null?void 0:T[m.id])==null?void 0:R.info;return(0,ae.jsx)(Mn.Fragment,{children:(0,ae.jsxs)("div",{className:"tw-flex tw-h-fit tw-min-h-[36px] tw-min-w-fit tw-flex-col tw-gap-y-1 tw-pr-4 max-lg:tw-gap-y-0.5",children:[(0,ae.jsxs)("div",{className:`tw-flex tw-items-center tw-gap-x-1 max-lg:tw-text-xxs ${m.showMarketColor?s.is_positive?"tw-text-pro-green-500":"tw-text-pro-red-600":"tw-text-gray-600"}`,children:[(0,ae.jsx)("p",{onClick:()=>{b&&d(w!=null?w:"--",b)},children:m!=null&&m.title?m==null?void 0:m.title:"--"}),b&&(0,ae.jsx)(et,{name:"exclamation-mark-info-gold",width:"tw-w-3",height:"tw-h-3"})]}),(0,ae.jsx)("div",{className:`tw-font-medium tw-tabular-nums max-lg:tw-text-xs ${m.showMarketColor?s.is_positive?"tw-text-pro-green-500":"tw-text-pro-red-600":"tw-text-gray-400"}`,children:m.value?m.value:"--"})]})},`${m.id}-ticker`)}),(0,ae.jsx)(qt,{variant:qt.Variants.Outlined,className:"tw-mr-6 tw-h-6 tw-w-14 tw-px-2 tw-py-1 tw-text-xs tw-font-medium tw-leading-[8px]",onClick:()=>{n(!0),I(_.FuturesDetailsButtonClicked,{click:"Button Click"})},children:"Details"})]}),!i&&(0,ae.jsx)(Vi,{shadowColor:"#121319",className:"tw-pr-10",children:c==null?void 0:c.map(m=>{var w,b,A;return(0,ae.jsx)(Mn.Fragment,{children:(0,ae.jsxs)("div",{className:"tw-flex tw-h-fit tw-min-h-[36px] tw-min-w-fit tw-flex-col tw-gap-y-1 tw-px-2 max-lg:tw-gap-y-0.5",children:[(0,ae.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-x-1 tw-text-gray-600 max-lg:tw-text-xxs",children:[(0,ae.jsx)("p",{onClick:()=>{var x;return m!=null&&m.info?d((x=m==null?void 0:m.title)!=null?x:"--",m==null?void 0:m.info):void 0},children:(w=m==null?void 0:m.title)!=null?w:"--"}),(m==null?void 0:m.info)&&!i&&(0,ae.jsx)(Bi,{content:(b=m==null?void 0:m.info)!=null?b:"",id:"info_tooltip",WrapperContentClass:"tw-w-[260px]",offsetY:20})]}),(0,ae.jsx)("div",{className:"tw-font-medium tw-tabular-nums tw-text-gray-200",children:t?(A=m==null?void 0:m.value)!=null?A:"--":null})]})},`${m.title}-ticker`)})}),!i&&(0,ae.jsx)("div",{onClick:()=>{n(!0),I(_.FuturesTradeViewDetailsClicked)},className:"tw-absolute tw-right-0 tw-top-0 tw-z-20 tw-flex tw-h-full tw-cursor-pointer tw-items-center tw-bg-black-01 tw-px-2",children:(0,ae.jsx)("div",{className:"tw-mt-0.5",children:(0,ae.jsx)(et,{name:"exclamation-mark-info-gold",width:"tw-w-3",height:"tw-h-3"})})})]})},Qm=(0,Mn.memo)(cu);var Tr="all";var ee=N(Qt());Lr();he();Ne();Oe();vr();Es();Lr();var Qs=N(Y());function uu({activeTab:t,enableTabs:e,setActiveTab:r}){let n=(e!=null?e:[]).map(s=>typeof s=="string"?{id:s,label:s}:s);return(0,Qs.jsx)("div",{className:"tw-w-full tw-bg-pro-gray-100 tw-px-4 max-lg:tw-bg-black max-lg:tw-pb-3 max-lg:tw-pt-1",children:(0,Qs.jsx)(ns,{variant:ns.Variants.Underline,size:ns.Sizes.Small,defaultActive:t,onChange:s=>r(String(s)),className:"tw-w-1/2 tw-gap-x-3 max-lg:tw-h-8 max-lg:tw-w-fit max-lg:tw-gap-3 max-lg:tw-bg-transparent",activeClass:"tw-h-[3px] tw-rounded-none max-lg:tw-bg-transparent lg:tw-min-w-[40px]",children:n.map(({id:s,label:o})=>{let i=s===Tr||o==="All";return(0,Qs.jsx)(ns.Item,{id:s,label:o,activeClass:"tw-text-gold-500 max-lg:tw-text-black",className:`tw-text-gray-500 max-lg:tw-h-8 max-lg:tw-py-[10px] max-lg:tw-text-xs max-lg:tw-font-medium max-lg:tw-text-gold-700 max-lg:tw-transition-none ${t===s?"max-lg:tw-border-0 max-lg:tw-bg-gold-500":"max-lg:tw-border max-lg:tw-border-pro-gold-200 max-lg:tw-bg-transparent"} ${i?"lg:tw-max-w-[40px]":"lg:tw-max-w-[100px]"}`},s)})})})}var Ks=uu;hn();Gr();Ir();var ul=N(Qt());Lr();var Qe=N(Y()),wl="/pro/images/scalper-intro-hero.png",wu=()=>(0,Qe.jsx)("img",{src:wl,alt:"","aria-hidden":!0,width:1,height:1,decoding:"async",style:{position:"fixed",left:-9999,top:-9999,opacity:0,pointerEvents:"none"}}),du=({isOpen:t,onClose:e,onTryNow:r})=>(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(wu,{}),t&&(0,Qe.jsxs)(ze,{open:t,onOpenChange:n=>!n&&e(),children:[(0,Qe.jsx)(ze.Overlay,{className:"tw-z-[100] tw-bg-black-02/50"}),(0,Qe.jsx)(ze.Content,{className:"tw-z-[101] tw-max-h-[85%] tw-rounded-t-[24px] tw-bg-black-01 tw-px-4 focus:tw-outline-none",children:(0,Qe.jsxs)("div",{className:"tw-flex tw-flex-col tw-items-center tw-pb-8 tw-pt-6",children:[(0,Qe.jsx)("p",{className:"tw-text-xs tw-font-medium tw-tracking-widest tw-text-gray-500",children:"\u2726 INTRODUCING \u2726"}),(0,Qe.jsx)("h2",{className:"tw-mt-2 tw-text-2xl tw-font-bold tw-text-gold-500",children:"Scalper Mode"}
2),(0,Qe.jsx)("div",{className:"tw-my-6 tw-w-full tw-overflow-hidden tw-rounded-xl",children:(0,Qe.jsx)("img",{src:wl,alt:"Scalper Mode",width:933,height:563,decoding:"async",fetchpriority:"high",className:"tw-h-auto tw-w-full"})}),(0,Qe.jsx)("h2",{className:"tw-text-center tw-font-bold tw-text-[24px] tw-text-white tw-px-6",children:"Now trade futures directly on the chart"}),(0,Qe.jsx)("p",{className:"tw-mt-2 tw-text-center tw-text-sm tw-text-gray-500",children:"Place trades faster. Make smarter hedging strategies."}),(0,Qe.jsx)("button",{onClick:()=>{r()},className:"tw-mt-6 tw-w-full tw-rounded-lg tw-bg-gold-500 tw-py-3.5 tw-text-base tw-font-semibold tw-text-black",children:"Try Now"})]})})]})]}),dl=(0,ul.memo)(du);var Ht=N(Y());var mu=["tw-w-[45%]","tw-w-[20%]","tw-w-[30%]"],pu=({searchContracts:t,setSearchContracts:e})=>{let r=(0,ee.useRef)(null),n=()=>{I(_.FuturesCoinListingSearch,{value:t}),r.current&&r.current.focus()},s=()=>{I(_.CoinListingSearchCrossClicked,{Search:t}),e("")};return(0,Ht.jsx)("div",{className:"tw-flex tw-items-center tw-gap-4 tw-bg-black tw-px-4 tw-py-3",children:(0,Ht.jsxs)(_s.Group,{className:"tw-h-[36px] tw-font-medium max-lg:tw-h-9",isError:!1,children:[(0,Ht.jsx)(_s,{type:"text",ref:r,autoComplete:"off",placeholder:"Search contracts",className:"tw-text-xs",maxLength:15,value:t,autoFocus:!1,onChange:o=>{let i=o.target.value.replace(/^\s+/,"");e(i)},onFocus:n}),(0,Ht.jsx)(_s.Right,{children:t!==""?(0,Ht.jsx)("span",{onClick:s,className:"tw-cursor-pointer tw-text-nowrap tw-text-xs tw-text-gold-500",children:"CLEAR"}):(0,Ht.jsx)(et,{name:"search-icon",className:"tw-h-[18px] tw-w-[18px]"})})]})})},fu=({sortStatus:t,updateSortStatus:e})=>(0,Ht.jsx)("div",{id:"futures-coin-list-sort",className:"tw-flex tw-w-full tw-justify-between tw-border-t tw-border-black-02 tw-bg-black tw-px-3 tw-py-2 tw-text-xs tw-font-normal tw-text-gray-500",children:t.map(r=>(0,Ht.jsxs)("div",{onClick:()=>e(r.id),className:ne("tw-flex tw-cursor-pointer tw-items-center tw-justify-end tw-gap-1 first:tw-justify-start first:tw-pl-8",r.width),children:[(0,Ht.jsx)("div",{className:ne("tw-whitespace-nowrap tw-text-gray-500",r.is_selected===!0?"tw-text-gold-500":""),children:r.title}),(0,Ht.jsx)(et,{height:"tw-h-3.5",width:"tw-w-2",name:r.is_selected&&r.state==="desc"?"sort-desc":r.is_selected&&r.state==="asc"?"sort-asc":"sort-default"})]},`${r.id}-sort`))}),gu=({isDma:t,is_loading:e,ticker_data:r,mark_price_data:n,updateSelectedContract:s,selected_contract:o,selected_contract_price:i,all_contracts:a,all_precision:l,contract_config:p})=>{let[f,g]=Xr(Di),[u,d]=Xr(ki),[c,m]=(0,ee.useState)(""),[w,b]=(0,ee.useState)([]),[A,x]=(0,ee.useState)(Tr),[T,R]=(0,ee.useState)(0),S=(0,ee.useRef)(null),[E,Q]=(0,ee.useState)({left:!1,right:!1}),{unit:L,isInr:D,futuresInrUsdtConverter:q,futuresInrUsdtVolConverter:K,futuresInrUsdtText:dt}=ue(),M=(0,ee.useCallback)((F,Z)=>F-Z,[]),Ct=Vr(),{isEnabled:O,onScalperClick:ht,onIntroTryNow:B,showIntro:at,dismissIntro:h,showTooltip:y,dismissTooltip:P}=zs(),G=(0,ee.useCallback)(F=>{g(Z=>Z.map(mt=>mt.id===F?{...mt,is_selected:mt.state!=="asc",state:mt.state==="default"?"desc":mt.state==="desc"?"asc":"default"}:{...mt,is_selected:!1,state:"default"}))},[g]),U=(0,ee.useMemo)(()=>r?Object.keys(r).length>10:!1,[r]),H=(0,ee.useMemo)(()=>{var Z;let F=new Set;for(let ct of a!=null?a:[]){let mt=(Z=p==null?void 0:p[ct==null?void 0:ct.toLowerCase()])==null?void 0:Z.category;if(Array.isArray(mt))for(let it of mt)F.add(it)}return[{id:Tr,label:"All"},...ks(F)]},[a,p]);(0,ee.useEffect)(()=>{H.length<=1||H.some(F=>F.id===A)||x(Tr)},[H,A]),(0,ee.useEffect)(()=>{u&&H.some(F=>F.id===u)&&(x(u),d(null))},[H,u,d]);let vt=(0,ee.useCallback)(()=>{let F=S.current;if(!F)return;let{scrollLeft:Z,scrollWidth:ct,clientWidth:mt}=F,it=Z>1,J=Z+mt<ct-1;Q(wt=>wt.left===it&&wt.right===J?wt:{left:it,right:J})},[]);(0,ee.useEffect)(()=>{vt();let F=S.current;if(!F)return;F.addEventListener("scroll",vt,{passive:!0});let Z=new ResizeObserver(vt);return Z.observe(F),()=>{F.removeEventListener("scroll",vt),Z.disconnect()}},[vt,H]);let X=(0,ee.useMemo)(()=>{let{left:F,right:Z}=E;if(!F&&!Z)return;let ct="24px",J=`linear-gradient(to right, ${F?"transparent":"black"} 0, black ${ct}, black calc(100% - ${ct}), ${Z?"transparent":"black"} 100%)`;return{WebkitMaskImage:J,maskImage:J}},[E]);(0,ee.useEffect)(()=>
2{if((a==null?void 0:a.length)>0&&U){let F=a==null?void 0:a.sort((Z,ct)=>{var J,wt;let mt=Number((J=r==null?void 0:r[Z])==null?void 0:J.quoteVolume)||0,it=Number((wt=r==null?void 0:r[ct])==null?void 0:wt.quoteVolume)||0;return mt?it?M(it,mt):-1:1});b(F)}},[U,a,r,M]),(0,ee.useEffect)(()=>{if((a==null?void 0:a.length)>0){let F=f.find(ct=>ct.is_selected),Z=[];(F==null?void 0:F.id)==="volume"?Z=[...a].sort((ct,mt)=>{var wt,lt;let it=Number((wt=r==null?void 0:r[ct])==null?void 0:wt.quoteVolume)||0,J=Number((lt=r==null?void 0:r[mt])==null?void 0:lt.quoteVolume)||0;return it?J?(F==null?void 0:F.state)==="desc"?M(J,it):M(it,J):-1:1}):(F==null?void 0:F.id)==="price"?Z=[...a].sort((ct,mt)=>{var wt,lt;let it=Number((wt=r==null?void 0:r[ct])==null?void 0:wt.lastPrice)||0,J=Number((lt=r==null?void 0:r[mt])==null?void 0:lt.lastPrice)||0;return it?J?(F==null?void 0:F.state)==="desc"?M(J,it):M(it,J):-1:1}):(F==null?void 0:F.id)==="change"?Z=[...a].sort((ct,mt)=>{var wt,lt;let it=Number((wt=r==null?void 0:r[ct])==null?void 0:wt.percentageChange)||0,J=Number((lt=r==null?void 0:r[mt])==null?void 0:lt.percentageChange)||0;return it?J?(F==null?void 0:F.state)==="desc"?M(J,it):M(it,J):-1:1}):(F==null?void 0:F.id)==="funding"?Z=[...a].sort((ct,mt)=>{var wt,lt;let it=Number((wt=n==null?void 0:n[ct])==null?void 0:wt.funding_rate)||0,J=Number((lt=n==null?void 0:n[mt])==null?void 0:lt.funding_rate)||0;return it?J?(F==null?void 0:F.state)==="desc"?M(J,it):M(it,J):-1:1}):Z=[...a].sort((ct,mt)=>{var wt,lt;let it=Number((wt=r==null?void 0:r[ct])==null?void 0:wt.quoteVolume)||0,J=Number((lt=r==null?void 0:r[mt])==null?void 0:lt.quoteVolume)||0;return it?J?M(J,it):-1:1}),b(Z)}},[a,r,n,f,M]),(0,ee.useEffect)(()=>{f.forEach(F=>{F.state!=="default"&&F.is_selected&&I(_.FuturesCoinLisitingSortingClick,{type:F.title,state:F.state})})},[f]),(0,ee.useEffect)(()=>{I(_.FuturesContractListShown)},[]);let At=(0,ee.useCallback)(F=>{var ct;if(A===Tr)return!0;let Z=(ct=p==null?void 0:p[F==null?void 0:F.toLowerCase()])==null?void 0:ct.category;return Array.isArray(Z)&&Z.includes(A)},[A,p]),xt=(0,ee.useMemo)(()=>{var it,J,wt;let F=c.replace(/^\s+/g,"").toLowerCase(),Z=D?"inr":"usdt",ct=D?"usdt":"inr";if(F===Z)return(it=w==null?void 0:w.filter(At))==null?void 0:it.filter(lt=>!Un(p==null?void 0:p[lt==null?void 0:lt.toLowerCase()]));let mt=F;return D?mt=mt.replace(/\/inr$|,inr$|inr$/i,"").replace(/\/usdt$|,usdt$|usdt$/i,"").replace(/^\s+|\/+|,+/g,""):mt=mt.replace(/\/usdt$|,usdt$|usdt$/i,"").replace(/\/inr$|,inr$|inr$/i,"").replace(/^\s+|\/+|,+/g,""),F===ct||F.includes(`/${ct}`)||F.endsWith(ct)?[]:(wt=(J=w==null?void 0:w.filter(lt=>{var Lt,Ft,oe,Nt;let bt=lt==null?void 0:lt.toLowerCase(),Xt=((Ft=(Lt=lt.split(","))==null?void 0:Lt[0])==null?void 0:Ft.toLowerCase())||"",Mt=((Nt=(oe=p==null?void 0:p[bt])==null?void 0:oe.name)==null?void 0:Nt.toLowerCase())||"";return F===""||Xt.indexOf(mt)>=0||bt.replace(",","").includes(mt)||Mt.indexOf(mt)>=0}))==null?void 0:J.filter(At))==null?void 0:wt.filter(lt=>!Un(p==null?void 0:p[lt==null?void 0:lt.toLowerCase()]))},[w,c,At,p,D]),ut=(0,ee.useCallback)(F=>{var Lt,Ft,oe,Nt;let Z=xt==null?void 0:xt[F];if(!Z)return null;let ct=(Ft=(Lt=Z==null?void 0:Z.split(","))==null?void 0:Lt[0])==null?void 0:Ft.toUpperCase(),mt=o===(Z==null?void 0:Z.toLowerCase()),it=p==null?void 0:p[Z==null?void 0:Z.toLowerCase()],J=r==null?void 0:r[Z],wt=Number(J==null?void 0:J.percentageChange)>0,lt=(oe=l==null?void 0:l[Z==null?void 0:Z.toLowerCase()])==null?void 0:oe.limit_precision,bt=mt&&i?i:J==null?void 0:J.lastPrice;bt=q(Number(bt),!0,lt);let Xt=D?Vt.inrPercent(Number(J==null?void 0:J.percentageChange),2):Vt.usdtPercent(Number(J==null?void 0:J.percentageChange),2),Mt=K(Number(J==null?void 0:J.quoteVolume),!0,2);return(0,Ht.jsx)("div",{className:"tw-bg-black",children:(0,Ht.jsx)(Fa,{baseSymbol:ct,quoteSymbol:dt(),leverage:it==null?void 0:it.max_leverage,percentageChange:J!=null&&J.percentageChange?Xt:"--",price:J!=null&&J.lastPrice?bt:"--",volumeChange:J!=null&&J.quoteVolume?Mt:"--",isActive:mt,onClick:()=>{s(Z==null?void 0:Z.toLowerCase());let pt=t?$r.dma_futures.url:$r.futures_trade_page_v2.url;Ct(pt)},childWidths:mu,iconLink:(Nt=it==null?void 0:it.logo)!=null?Nt:"",isPositive:wt})})},[xt,o,p,r,l,i,D,L,s,q,K]);return(0,Ht.jsxs)("div",{className:"tw-flex tw-h-full tw-w-full tw-flex-col tw-scrollbar-hide",children:[(0,Ht.jsxs)("div",{className:"tw-sticky tw-left-0 tw-top-0 tw-z-10",children:[(0,Ht.jsx)(pu,{searchContracts:c,setSearchContracts:m}),(0,Ht.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-x-2 tw-bg-black tw-pr-4",children:[(0,Ht.jsx)("div",{ref:S,style:X,className:"no-scrollbar tw-min-w-0 tw-flex-1 tw-overflow-x-auto",children:(0,Ht.jsx)(Ks,{activeTab:A,setActiveTab:x,enableTabs:H})}),O&&(0,Ht.jsxs)("div",{className:"tw-relative",children:[(0,Ht.jsx)(Hs,{variant:"pill",onClick:()=>ht("market_page",`BTC${dt()}`,!0),showBadge:!0,customStyle:{marginTop:"-8px"}}),y&&(0,Ht.jsxs)("div",{className:"tw-absolute tw-right-0 tw-top-[calc(100%+8px)] tw-z-50",children:[(0,Ht.jsx)("div",{className:"tw-absolute -tw-top-[5px] tw-right-4 tw-h-[10px] tw-w-[10px] tw-rotate-45",style:{backgroundColor:"#CDA954"}}),(0,Ht.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-x-2 tw-rounded-lg tw-py-2 tw-pl-3 tw-pr-2",style:{backgroundColor:"#CDA954"},children:[(0,Ht.jsx)("p",{className:"tw-whitespace-nowrap tw-text-xs tw-font-medium tw-tracking-wide",style:{color:"#121319"},children:"Manage positions or orders directly on the chart"}),(0,Ht.jsx)("button",{onClick:P,className:"tw-flex tw-h-5 tw-w-5 tw-shrink-0 tw-items-center tw-justify-center",children:(0,Ht.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ht.jsx)("path",{d:"M1 1L9 9M9 1L1 9",stroke:"#121319",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})]})]}),(0,Ht.jsx)(fu,{sortStatus:f,updateSortStatus:G})]}),(e||r===null)&&(0,Ht.jsx)("div",{className:"no-scrollbar tw-h-[calc(100dvh-145px)] tw-w-full tw-overflow-y-scroll",children:new Array(10).fill(0).map((F,Z)=>(0,Ht.jsx)("div",{className:"tw-mt-4 tw-h-[64px] tw-animate-pulse tw-rounded-lg tw-bg-black-01"},Z))}),!e&&r!==null&&(0,Ht.jsx)("div",{className:"tw-h-[calc(100dvh-145px)] tw-w-full",children:(0,Ht.jsx)(Vs,{style:{height:"100%"},totalCount:(xt==null?void 0:xt.length)||0,itemContent:ut,initialTopM
2ostItemIndex:T,rangeChanged:F=>{R(F.startIndex)},className:"no-scrollbar"})}),O&&(0,Ht.jsx)(dl,{isOpen:at,onClose:h,onTryNow:()=>B()})]})},vp=(0,ee.memo)(gu);var An=N(Qt());he();var ml=[{id:1,key:"default",logo:{selected:"buy-sell-orderbook-unselected-icon",unselected:"buy-sell-orderbook-icon"}},{id:2,key:"sell",logo:{selected:"sell-orderbook-icon",unselected:"sell-orderbook-selected-icon"}},{id:3,key:"buy",logo:{selected:"buy-orderbook-icon",unselected:"buy-orderbook-selected-icon"}}],Yn=10,rn=Yn*2;var Gn=N(Qt());hn();Gr();var Pr=N(Y()),bu=({data:t,type:e,is_mobile:r=!1,handlePriceQuantityFromOutside:n,isLoading:s,loaderCount:o,precision:i,isQuantityToggle:a,isQuantityAndDepthToggle:l})=>{let{futuresInrUsdtConverter:p}=ue(),[f,g]=(0,Gn.useState)(1/0);return(0,Gn.useEffect)(()=>{function u(d){var m;if(!(d!=null&&d.length)||!((m=d==null?void 0:d[0])!=null&&m.length))return 1/0;let c=-1/0;return d.forEach(w=>{c=Math.max(l&&w[2]?w[2]:w[1],c)}),c}g(u(t))},[t,l]),s||!t.length?(0,Pr.jsx)("div",{className:"tw-flex tw-min-h-[228px] tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-y-0.5 tw-py-1 max-lg:tw-gap-y-1 max-lg:tw-py-2",children:Array.from({length:o},(u,d)=>(0,Pr.jsx)("div",{className:"tw-h-5 tw-w-[98%] tw-animate-pulse tw-bg-pro-black-200 max-lg:tw-h-8"},`loader-${d+1}`))}):(0,Pr.jsx)("div",{id:`orderbook-${e}`,className:ne("tw-flex tw-min-h-[228px] tw-w-full tw-py-1 lg:tw-gap-y-0.5 max-lg:tw-gap-y-1 max-lg:tw-py-2",e==="sell"&&!r?"tw-flex-col-reverse":"tw-flex-col"),children:t==null?void 0:t.map((u,d)=>(0,Pr.jsxs)("div",{className:"tw-relative tw-cursor-pointer",children:[(0,Pr.jsx)("div",{onClick:()=>n(u[0],u[1]),className:ne("tw-absolute tw-flex tw-h-full tw-w-full",e==="sell"&&r?"tw-flex-row":"tw-flex-row-reverse"),children:(0,Pr.jsx)("div",{style:{width:`${(l&&u[2]?u[2]:u[1])*100/f}%`},className:ne("tw-transition-all tw-delay-100 tw-ease-in-out",e==="sell"?"tw-bg-[#F1436633]":"tw-bg-[#0ECB8126]")})}),(0,Pr.jsxs)("div",{className:ne("tw-flex tw-h-5 tw-w-full tw-items-center tw-justify-between tw-px-3 tw-text-xs tw-font-medium max-lg:tw-h-8 max-lg:tw-px-0",r&&e==="buy"?"tw-flex-row-reverse":"tw-flex-row"),children:[(0,Pr.jsx)("div",{className:ne("tw-max-w-1/2 tw-truncate tw-tabular-nums",e==="sell"?"tw-text-pro-red-600 max-lg:tw-ml-2":"tw-text-pro-green-700 max-lg:tw-mr-2"),children:p(Number(u[0]),!0,i.limit_precision)}),(0,Pr.jsx)("div",{className:"tw-max-w-1/2 tw-truncate tw-text-right tw-tabular-nums tw-text-gray-400",children:l&&u[2]?p(Number(u[2]),!0,i.quote_precision):a?p(Number(u[1]),!0,i.quote_precision):Vt.usdtFormat(u[1],i.base_precision)})]})]},d))})},cs=(0,Gn.memo)(bu);Ir();Oe();Ne();var pl=N(Qt()),nr=N(Y()),hu=({isLoading:t,bids:e,asks:r,qty_toggle:n})=>{if(t||!(e!=null&&e.length)||!(r!=null&&r.length))return(0,nr.jsxs)("div",{className:"tw-flex tw-h-full tw-w-full tw-items-center tw-justify-between tw-gap-x-2 tw-px-4 tw-py-2.5",children:[(0,nr.jsx)("div",{className:"tw-h-full tw-w-[20%] tw-animate-pulse tw-bg-pro-black-200"}),(0,nr.jsx)("div",{className:"tw-h-full tw-flex-1 tw-animate-pulse tw-bg-pro-black-200"}),(0,nr.jsx)("div",{className:"tw-h-full tw-w-[20%] tw-animate-pulse tw-bg-pro-black-200"})]});if((r==null?void 0:r.length)===0&&(e==null?void 0:e.length)===0)return null;let s=e==null?void 0:e.reduce((l,p)=>l+(n?parseFloat(p[1])*parseFloat(p[0]):parseFloat(p[1])),0),o=r==null?void 0:r.reduce((l,p)=>l+(n?parseFloat(p[1])*parseFloat(p[0]):parseFloat(p[1])),0),i=Math.round(o/(o+s)*100),a=100-i;return(0,nr.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between tw-px-4 tw-pb-[10px] tw-pt-4 max-lg:tw-pb-2",children:[(0,nr.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,nr.jsx)("p",{className:"tw-text-xs tw-font-medium tw-text-gray-600",children:"Bids"}),(0,nr.jsxs)("p",{className:"tw-text-xs tw-font-medium tw-text-green-01",children:[Math.floor(a),"%"]})]}),(0,nr.jsxs)("div",{className:"tw-flex tw-h-3 tw-flex-grow tw-items-center tw-gap-[2px]",children:[(0,nr.jsx)("div",{style:{width:`${a}%`,background:"linear-gradient(270deg, #0BA267 0%, rgba(11, 162, 103, 0) 100%)"},className:"tw-flex tw-h-full tw-items-center tw-justify-between tw-transition-all tw-duration-100 tw-ease-in-out"}),(0,nr.jsx)("div",{style:{width:`${i}%`,background:"linear-gradient(90deg, #F14366 0%, rgba(241, 67, 102, 0) 100%)"},className:"tw-flex tw-h-full tw-items-center tw-justify-between tw-transition-all tw-duration-100 tw-ease-in-out"})]}),(0,nr.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,nr.jsxs)("p",{className:"tw-text-xs tw-font-medium tw-text-pro-red-600",children:[Math.ceil(i),"%"]}),(0,nr.jsx)("p",{className:"tw-text-xs tw-font-medium tw-text-gray-600",children:"Asks"})]})]})},fl=(0,pl.memo)(hu);
2var gt=N(Y()),xu=({is_error:t,is_loading:e,isTradeLoading:r,data:n,precision:s,ltp_data:o,handlePriceQuantityFromOutside:i,qty_toggle:a,depth_toggle:l,setDesktopQtyToggle:p,setDepthToggleHandler:f,orderBookCount:g=void 0})=>{let u=Cr(),{is_mobile:d}=u,[c,m]=(0,An.useState)("default"),[w,b]=(0,An.useState)([]),[A,x]=(0,An.useState)([]),{futuresInrUsdtConverter:T,futuresInrUsdtText:R}=ue();function S(E,Q,L){if(!Array.isArray(E)||(E==null?void 0:E.length)===0)return[];let D=E.slice();if(Q&&L){let q=0;D=E.map(K=>(q=q+(Number(K[0])*Number(K[1])||0),[Number(K[0]),Number(K[1]),q]))}else if(L){let q=0;D=E.map(K=>(q=q+(Number(K[1])||0),[Number(K[0]),q]))}else Q?D=E.map(q=>{let K=Number(q[0])*Number(q[1])||0;return[Number(q[0]),K]}):D=E.map(q=>[Number(q[0]),Number(q[1])]);return D}return(0,An.useEffect)(()=>{b(S(n==null?void 0:n.asks,a,l)),x(S(n==null?void 0:n.bids,a,l))},[n==null?void 0:n.asks,n==null?void 0:n.bids,l,a]),d?(0,gt.jsxs)("div",{className:"tw-h-full tw-w-full tw-bg-black-01",children:[(0,gt.jsxs)("div",{className:"tw-flex tw-h-10 tw-w-full tw-items-center tw-justify-between tw-px-4 tw-pb-1 tw-text-xs tw-font-medium",children:[(0,gt.jsxs)("div",{children:[r&&(0,gt.jsx)("div",{className:"tw-h-6 tw-w-[100px] tw-animate-pulse tw-bg-pro-black-200"}),(o==null?void 0:o.price)&&!r&&(0,gt.jsx)("div",{className:`tw-w-full tw-text-sm tw-transition-colors tw-delay-[20ms] tw-ease-in-out ${o!=null&&o.is_maker?"tw-text-pro-red-700":"tw-text-pro-green-900"}`,children:T(o==null?void 0:o.price,!0,s==null?void 0:s.limit_precision)})]}),(0,gt.jsxs)("div",{className:"tw-flex tw-h-full tw-w-fit tw-items-center tw-gap-x-2",children:[(0,gt.jsx)("div",{className:"tw-text-gray-600",children:"Depth"}),(0,gt.jsx)("div",{className:"tw-w-fit tw-cursor-pointer",onClick:()=>{f(),I(_.FuturesTradeOrderBookDepthToggle,{Depth:!l})},children:(0,gt.jsx)(et,{width:"tw-w-5",height:"tw-h-4",name:l?"toggle-on-icon":"toggle-off-icon"})}),(0,gt.jsxs)("div",{className:"tw-ml-6 tw-flex tw-h-full tw-items-center tw-text-xs tw-font-medium",onClick:()=>{p(),I(_.FuturesTradeOrderBookQuantityToggle,{Amount:!a})},children:[(0,gt.jsx)("span",{className:`${a?"tw-font-normal tw-text-gray-600":"tw-font-medium tw-text-gray-500"}`,children:"Qty"}),(0,gt.jsx)("span",{className:"tw-text-gray-600",children:"/"}),(0,gt.jsx)("span",{className:`${a?"tw-font-medium tw-text-gray-500":"tw-font-normal tw-text-gray-600"}`,children:"Amt"}),(0,gt.jsx)("div",{className:"tw-ml-2 tw-w-fit tw-cursor-pointer",children:(0,gt.jsx)(et,{name:"futures-swap",width:"tw-w-3",height:"tw-h-3"})})]})]})]}),(0,gt.jsx)("div",{className:"tw-mx-4 tw-h-[1px] tw-bg-gray-800"}),(0,gt.jsx)("div",{className:"tw-h-12 tw-w-full",children:(0,gt.jsx)(fl,{bids:A,asks:w,qty_toggle:a,isLoading:e})}),(0,gt.jsxs)("div",{className:"tw-flex tw-h-6 tw-w-full tw-items-center tw-px-4 tw-text-xxs tw-font-medium tw-text-gray-600",children:[(0,gt.jsxs)("div",{className:"tw-flex tw-w-1/2 tw-items-center tw-justify-between tw-pr-2",children:[(0,gt.jsx)("div",{children:a?"Amount":"Quantity"}),(0,gt.jsxs)("div",{children:["Price(",R(),")"]})]}),(0,gt.jsxs)("div",{className:"tw-flex tw-w-1/2 tw-items-center tw-justify-between tw-pl-2",children:[(0,gt.jsxs)("div",{children:["Price(",R(),")"]}),(0,gt.jsx)("div",{children:a?"Amount":"Quantity"})]})]}),(0,gt.jsxs)("div",{className:"tw-flex tw-h-auto tw-w-full tw-gap-x-1 tw-px-4",children:[(0,gt.jsx)("div",{className:"tw-w-1/2",children:(0,gt.jsx)(cs,{data:A==null?void 0:A.slice(0,g!=null?g:rn),type:"buy",is_mobile:!0,handlePriceQuantityFromOutside:i,isLoading:e,loaderCount:g!=null?g:rn,precision:s,isQuantityToggle:a,isQuantityAndDepthToggle:a&&l})}),(0,gt.jsx)("div",{className:"tw-w-1/2",children:(0,gt.jsx)(cs,{data:w==null?void 0:w.slice(0,g!=null?g:rn),type:"sell",is_mobile:!0,handlePriceQuantityFromOutside:i,isLoading:e,loaderCount:g!=null?g:rn,precision:s,isQuantityToggle:a,isQuantityAndDepthToggle:a&&l})})]})]}):(0,gt.jsxs)("div",{className:"tw-w-full",children:[(0,gt.jsxs)("div",{className:"tw-flex tw-h-6 tw-w-full tw-items-center tw-justify-between tw-px-3 tw-py-1",children:[(0,gt.jsx)("div",{className:"tw-flex tw-h-full tw-w-[72px] tw-items-center tw-gap-x-3",children:ml.map(E=>(0,gt.jsx)("div",{onClick:()=>{m(E.key)},className:"tw-cursor-pointer",children:(0,gt.jsx)(et,{width:"tw-w-[24px]",height:"tw-h-[20px]",name:c!==E.key?E.logo.selected:E.logo.unselected})},`orderbook-type-${E.id}`))}),(0,gt.jsxs)("div",{className:"tw-flex tw-h-full tw-w-fit tw-items-center tw-gap-x-1 tw-text-xs",children:[(0,gt.jsx)("div",{className:"tw-text-white",children:"Depth"}),(0,gt.jsx)("div",{className:"tw-w-fit tw-cursor-pointer",onClick:()=>{f(),I(_.FuturesTradeOrderBookDepthToggle,{Depth:!l})},children:(0,gt.jsx)(et,{width:"tw-w-[22px]",height:"tw-h-3",name:l?"futures-toggle-on":"futures-toggle-off"})})]})]}),(0,gt.jsx)("div",{className:"tw-my-0.5 tw-w-full"}),(0,gt.jsxs)("div",{className:"tw-flex tw-h-6 tw-w-full tw-items-center tw-justify-between tw-px-3 tw-py-1 tw-text-xs tw-text-pro-gray-600",children:[(0,gt.jsxs)("div",{children:["Price (",R(),")"]}),(0,gt.jsxs)("div",{className:"tw-flex tw-h-full tw-cursor-pointer tw-select-none tw-items-center tw-text-xs",onClick:()=>
2{p(),I(_.FuturesTradeOrderBookQuantityToggle,{Amount:!a})},children:[(0,gt.jsx)("div",{children:a?"Amount":"Quantity"}),(0,gt.jsx)("div",{className:"tw-w-fit tw-p-1",children:(0,gt.jsx)(et,{name:"futures-swap",width:"tw-w-2.5",height:"tw-h-2.5"})})]})]}),(0,gt.jsx)("div",{className:"tw-w-full",children:t?null:(0,gt.jsxs)(gt.Fragment,{children:[(c==="default"||c==="sell")&&(0,gt.jsx)(cs,{data:w==null?void 0:w.slice(0,c==="sell"?rn:Yn),type:"sell",handlePriceQuantityFromOutside:i,isLoading:e,loaderCount:c==="sell"?rn:Yn,precision:s,isQuantityToggle:a,isQuantityAndDepthToggle:a&&l}),(0,gt.jsxs)("div",{className:"tw-flex tw-h-8 tw-w-full tw-items-center tw-justify-between",children:[r&&(0,gt.jsx)("div",{className:"tw-m-1 tw-h-6 tw-w-full tw-animate-pulse tw-bg-pro-black-200"}),(o==null?void 0:o.price)&&!r&&(0,gt.jsx)("div",{className:`tw-w-full tw-px-3 tw-text-lg tw-font-bold tw-transition-colors tw-delay-[20ms] tw-ease-in-out ${o!=null&&o.is_maker?"tw-text-pro-red-600":"tw-text-pro-green-700"}`,children:T(o==null?void 0:o.price,!0,s==null?void 0:s.limit_precision)})]}),(c==="default"||c==="buy")&&(0,gt.jsx)(cs,{data:A==null?void 0:A.slice(0,c==="buy"?rn:Yn),type:"buy",handlePriceQuantityFromOutside:i,isLoading:e,loaderCount:c==="buy"?rn:Yn,precision:s,isQuantityToggle:a,isQuantityAndDepthToggle:a&&l})]})})]})},Dp=(0,An.memo)(xu);Ir();var gl=N(Qt());he();Ne();Oe();Gr();var Ge=N(Y()),vu=({is_error:t,is_loading:e,data:r,precision:n,handlePriceQuantityFromOutside:s,qty_toggle:o,setQtyToggleHandler:i})=>{let{is_mobile:a}=Cr(),{futuresInrUsdtConverter:l,futuresInrUsdtText:p}=ue();return(0,Ge.jsxs)("div",{className:"tw-w-full tw-bg-black-01",children:[(0,Ge.jsx)("div",{className:"tw-mb-1 tw-h-[1px] lg:tw-my-1 lg:tw-w-full max-lg:tw-mx-4 max-lg:tw-mb-4 max-lg:tw-bg-black-02"}),(0,Ge.jsxs)("div",{className:"tw-flex tw-h-6 tw-w-full tw-items-center tw-justify-between tw-p-1 tw-text-xs tw-tracking-tighter tw-text-gray-600 max-lg:tw-px-4 max-lg:tw-pb-4",children:[(0,Ge.jsxs)("div",{className:"tw-w-[76px] tw-tracking-tighter",children:["Price (",p(),")"]}),(0,Ge.jsxs)("div",{className:"tw-flex tw-h-full tw-w-[95px] tw-cursor-pointer tw-select-none tw-items-center tw-text-xs lg:tw-w-[58px] max-lg:tw-justify-end max-lg:tw-pr-2",onClick:()=>{i(),I(_.FuturesTradeLastTradeToggle,{Amount:!o})},children:[(0,Ge.jsx)("div",{children:o?"Amount":"Quantity"}),(0,Ge.jsx)("div",{className:"tw-w-fit tw-p-1",children:(0,Ge.jsx)(et,{name:"futures-swap",width:"tw-w-2.5",height:"tw-h-2.5"})})]}),(0,Ge.jsx)("div",{className:"tw-w-[52px] tw-text-right",children:"Time"})]}),e&&(0,Ge.jsx)("div",{className:"tw-space-y-3 tw-p-4 lg:tw-space-y-[7px] lg:tw-p-2",children:Array.from({length:a?10:18},(f,g)=>(0,Ge.jsx)("div",{className:"tw-h-6 tw-flex-1 tw-animate-pulse tw-bg-pro-black-200 lg:tw-h-5"},g))}),!e&&!t&&r!==null&&(0,Ge.jsx)("div",{className:"tw-flex tw-min-h-[252px] tw-flex-col tw-gap-y-2 tw-px-1 tw-py-2 lg:tw-gap-y-[7px] max-lg:tw-px-4 max-lg:tw-pb-6",children:r==null?void 0:r.slice(0,18).map((f,g)=>{var u,d;return(0,Ge.jsxs)("div",{onClick:()=>{s(f==null?void 0:f.p)},className:"tw-flex tw-h-5 tw-w-full tw-cursor-pointer tw-items-center tw-justify-between tw-text-xs tw-font-medium tw-tracking-tighter lg:tw-py-1",children:[(0,Ge.jsx)("div",{className:`tw-flex-1 tw-tabular-nums ${f!=null&&f.m?"tw-text-pro-red-700":"tw-text-pro-green-900"}`,children:l(Number(f==null?void 0:f.p),!0,n==null?void 0:n.limit_precision)}),(0,Ge.jsx)("div",{className:"tw-max-w-[95px] tw-flex-1 tw-text-right tw-tabular-nums tw-text-pro-gray-700",children:o?l(Number((f==null?void 0:f.p)*(f==null?void 0:f.q)),!0,n==null?void 0:n.quote_precision):Vt.usdtFormat(f==null?void 0:f.q,n==null?void 0:n.base_precision)}),(0,Ge.jsx)("div",{className:"tw-flex-1 tw-truncate tw-text-right tw-text-xxs tw-tabular-nums tw-text-pro-gray-700 max-lg:tw-text-xs",children:(d=(u=new Date(f==null?void 0:f.E))==null?void 0:u.toLocaleTimeString("en-GB",{hour12:!1}))!=null?d:"--"})]},`${g}th-trade`)})}),!(r!=null&&r.length)&&!e&&(0,Ge.jsx)("div",{className:"tw-flex tw-h-[300px] tw-items-center tw-justify-center tw-p-4 tw-text-gray-500",children:"No trades"})]})},Hp=(0,gl.memo)(vu);var sn=N(Qt());he();Ne();Oe();Gr();var je=N(Y());var nn={[0]:{id:"funding-rate",title:"Funding Rate",empty_dec:"Hello"},[1]:{id:"top-gainers",title:"Top Gainers",empty_dec:"Hello"},[2]:{id:"top-losers",title:"Top Losers",empty_dec:"Hello"}},yu=({ticker_data:t,mark_price_data:e={},all_contracts:r,all_precision:n,updateSelectedContract:s})=>{let[o,i]=(0,sn.useState)(0),[a,l]=(0,sn.useState)([]),{unit:p,isPriceModeInr:f,isUsdt:g,convertUsdtToInr:u,futuresInrUsdtText:d}=ue();return(0,sn.useEffect)(()=>{var c;if((r==null?void 0:r.length)>0)if(o===0){let m=r==null?void 0:r.filter(w=>{var b;return(b=e==null?void 0:e[w])==null?void 0:b.funding_rate}).sort((w,b)=>{var A,x;return Number((A=e==null?void 0:e[b])==null?void 0:A.funding_rate)-Number((x=e==null?void 0:e[w])==null?void 0:x.funding_rate)}).map(w=>{var b,A,x,T,R;return{contract:w,contract_title:((b=w==null?void 0:w.split(",")[0])==null?void 0:b.toUpperCase())+`/${d()}`,type:"Perpetual",value_one:(A=e==null?void 0:e[w])!=null&&A.funding_countdown?(x=e==null?void 0:e[w])==null?void 0:x.funding_countdown:"--",value_two:Vt.usdtFormat(((T=e[w])==null?void 0:T.funding_rate)*100,4),is_positive:To((R=e[w])==null?void 0:R.funding_rate)}});l([...m==null?void 0:m.slice(0,2),...m==null?void 0:m.slice(-2)])}else{let m=r==null?void 0:r.filter(w=>{var b;return(b=t==null?void 0:t[w])==null?void 0:b.percentageChange}).sort((w,b)=>{var A,x;return Number((A=t[b])==null?void 0:A.percentageChange)-Number((x=t[w])==null?void 0:x.percentageChange)}).map(w=>{var A,x,T,R,S,E;let b=(A=n==null?void 0:n[w==null?void 0:w.toLowerCase()])==null?void 0:A.limit_precision;return{contract:w,contract_title:((x=w==null?void 0:w.split(",")[0])==null?void 0:x.toUpperCase())+`/${d()}`,type:"Perpetual",value_one:f?Vt.inrCurrency(u((T=t==null?void 0:t[w])==null?void 0:T.lastPrice),b):Vt.usdtFormat((R=t==null?void 0:t[w])==null?void 0:R.lastPrice,b),value_two:Vt.usdtFormat((S=t==null?void 0:t[w])==null?void 0:S.percentageChange,2),value_two_add:p,is_positive:To((E=t[w])==null?void 0:E.percentageChange)}});l(o===1?m==null?void 0:m.slice(0,4):o===2?(c=m==null?void 0:m.slice(-4))==null?void 0:c.reverse():[])}},[r,n,o,e,t,p,u,d,f]),(0,je.jsxs)("div",{className:"tw-flex tw-h-full tw-w-full tw-items-center tw-bg-gray-800 tw-text-xs max-lg:tw-bg-black max-lg:tw-text-xxs",children:[(0,je.jsxs)("div",{onClick:()=>{i(c=>
2(c===0&&c+1===1?I(_.FuturesTickerInfobar,{from:nn[0].title,to:nn[1].title}):c===1&&c+1===2?I(_.FuturesTickerInfobar,{from:nn[1].title,to:nn[2].title}):I(_.FuturesTickerInfobar,{from:nn[2].title,to:nn[0].title}),(c+1)%3))},className:"tw-z-20 tw-flex tw-h-full tw-min-w-[112px] tw-cursor-pointer tw-items-center tw-justify-between tw-px-2  lg:tw-flex-row-reverse lg:tw-gap-x-3 lg:tw-px-4 max-lg:tw-min-w-[90px]",children:[(0,je.jsx)("div",{className:"tw-tracking-tight tw-text-gold-500",children:nn==null?void 0:nn[o].title}),(0,je.jsx)("div",{className:"tw-h-fit tw-w-fit",children:(0,je.jsx)(et,{name:"info-bar-rotate",width:"tw-w-2.5",height:"tw-h-5 max-lg:tw-h-3"})})]}),(0,je.jsx)("div",{className:"tw-flex tw-h-full tw-items-center tw-overflow-hidden max-lg:tw-pr-2",children:(0,je.jsx)("div",{className:"tw-flex tw-h-full tw-flex-1 tw-items-center tw-justify-start max-lg:tw-translate-x-full max-lg:tw-animate-marquee-css max-lg:tw-text-center",children:a.map((c,m,w)=>(0,je.jsxs)(sn.Fragment,{children:[(0,je.jsxs)("div",{onClick:()=>{var b;return s((b=c.contract)==null?void 0:b.toLowerCase())},className:"tw-flex tw-cursor-pointer tw-gap-x-1 tw-px-2 tw-font-medium tw-text-gray-500",children:[(0,je.jsx)("div",{children:c==null?void 0:c.contract_title}),(0,je.jsx)("div",{children:c==null?void 0:c.type}),(0,je.jsxs)("div",{className:`${c!=null&&c.is_positive?"tw-text-pro-green-500":"tw-text-pro-red-500"}`,children:[c==null?void 0:c.value_two,"%"]}),(0,je.jsx)("div",{className:"tw-pl-1 tw-text-pro-gray-700",children:c==null?void 0:c.value_one}),(c==null?void 0:c.value_two_add)&&g&&(0,je.jsx)("div",{className:"tw-text-xxs tw-font-medium tw-text-pro-gray-500",children:c==null?void 0:c.value_two_add})]}),m!==w.length-1&&(0,je.jsx)("div",{className:"tw-px-1 tw-text-gray-700",children:"\u2022"})]},`${m}-info-data`))})})]})},tf=(0,sn.memo)(yu);Ir();vr();var tt=N(Qt());Ne();var hl=["1","5","15","30","60","120","240","360","720","1D","3D","1W","1M"],Su={supported_resolutions:hl,supports_time:!0};function Fo(t,e,r,n,s,o,i){let a=new Map,l={},p=u=>{var A,x,T,R,S;u=u==null?void 0:u.toLowerCase();let d=u.split(":"),c=d.length>1?d[1]:d[0],m=d.length>1?d[0]:"",w=(x=(A=c==null?void 0:c.split("~"))==null?void 0:A[0])==null?void 0:x.toLowerCase(),b=(S=(R=(T=c==null?void 0:c.split("~"))==null?void 0:T[1])!=null?R:o)==null?void 0:S.toUpperCase();return{exchange:m,symbol:c,pureSymbol:w,quote:b}},f=(u,{exchange:d,symbol:c,pureSymbol:m,quote:w})=>{var T,R,S,E,Q,L;let b=(R=(T=e==null?void 0:e[m])==null?void 0:T.limit_precision)!=null?R:2,A=(E=(S=e==null?void 0:e[m])==null?void 0:S.base_precision)!=null?E:3,x=`${(L=(Q=c==null?void 0:c.split(","))==null?void 0:Q[0])==null?void 0:L.toUpperCase()}/${w}`;return{name:x,full_name:u==null?void 0:u.toUpperCase(),description:x,type:"crypto",session:"24x7",timezone:"Etc/UTC",ticker:u.toUpperCase(),minmov:1,pricescale:10**b,has_intraday:!0,supported_resolutions:hl,volume_precision:A,data_status:"streaming",exchange:rs[d],listed_exchange:d,currency_code:o,format:"price"}};return{onReady:u=>{setTimeout(()=>u(Su),0)},searchSymbols:(u,d,c,m)=>{u=u.toLowerCase();let w=t.filter(b=>b.indexOf(u)>=0).map(b=>{var R,S;let A=b.split(":")[0],x=b.split(":")[1].toLowerCase(),T=`${(S=(R=x==null?void 0:x.split(","))==null?void 0:R[0])==null?void 0:S.toUpperCase()}/${o}`;return{symbol:T,full_name:T,description:T,ticker:b,exchange:rs[A],type:"crypto"}});m(w)},resolveSymbol:(u,d,c)=>{let m=u,w=p(u),b=f(m,w);setTimeout(()=>d(b),0)},getBars:function(u,d,c,m,w){let{from:b,to:A,countBack:x,firstDataRequest:T}=c;xa.getBars(u,d,b,A,x,T,n,s).then(({bars:R,noData:S})=>{m(R,{noData:S})}).catch(R=>{w(R)})},subscribeBars:(u,d,c,m,w)=>{r.current=w;let b=A=>{var T,R;let x=((R=(T=u.ticker)!=null?T:u.name)!=null?R:"").toUpperCase();x&&a.set(x,A.close),c(A)};Io().subscribeBars(u,d,b,m,w)},unsubscribeBars:u=>{Io().unsubscribeBars(u)},calculateHistoryDepth:u=>Number(u)<60?{resolutionBack:"D",intervalBack:"1"}:void 0,getMarks:(u,d,c,m,w)=>{},getTimeScaleMarks:(u,d,c,m,w)=>{},getServerTime:u=>{Pa(u)},getQuotes:(u,d,c)=>{let m=u.map(w=>{var A,x;let b=(x=(A=a.get(w.toUpperCase()))!=null?A:a.get(w))!=null?x:0;return{s:"ok",n:w,v:{ch:0,chp:0,lp:b,ask:b,bid:b,short_name:w,exchange:"",description:w,open_price:b,high_price:b,low_price:b,prev_close_price:b,volume:0}}});d(m)},subscribeQuotes:(u,d,c,m)=>{let w=[...new Set([...u,...d])],b=setInterval(()=>{let A=w.map(x=>{var R,S;let T=(S=(R=a.get(x.toUpperCase()))!=null?R:a.get(x))!=null?S:0;return{s:"ok",n:x,v:{ch:0,chp:0,lp:T,ask:T,bid:T,short_name:x,exchange:"",description:x,open_price:T,high_price:T,low_price:T,prev_close_price:T,volume:0}}});c(A)},5e3);l[m]=b},unsubscribeQuotes:u=>{l[u]&&(clearInterval(l[u]),delete l[u])},dispose:()=>{for(let u of Object.keys(l))clearInterval(l[u]),delete l[u]}}}Oi();Ne();Oe();var Cu="tv-futures-user-settings";function ko(){return Ca(Cu,{"trading.chart.proterty":JSON.stringify({noConfirmEnabled:!0})})}var Do={"paneProperties.background":"#121319","paneProperties.backgroundType":"solid","platformProperties.background":"#121319","platformProperties.backgroundType":"solid","mainSeriesProperties.candleStyle.wickUpColor":"#0ECB81","mainSeriesProperties.candleStyle.wickDownColor":"#F14366","mainSeriesProperties.candleStyle.downColor":"#F14366","mainSeriesProperties.candleStyle.upColor":"#0ECB81","mainSeriesProperties.candleStyle.borderUpColor":"#0ECB81","mainSeriesProperties.candleStyle.borderDownColor":"#F14366","mainSeriesProperties.hollowCandleStyle.wickUpColor":"#0ECB81","mainSeriesProperties.hollowCandleStyle.wickDownColor":"#F14366","mainSeriesProperties.hollowCandleStyle.downColor":"#F14366","mainSeriesProperties.hollowCandleStyle.upColor":"#0ECB81","mainSeriesProperties.hollowCandleStyle.borderUpColor":"#0ECB81","mainSeriesProperties.hollowCandleStyle.borderDownColor":"#F14366","mainSeriesProperties.haStyle.wickUpColor":"#0ECB81","mainSeriesProperties.haStyle.wickDownColor":"#F14366","mainSeriesProperties.haStyle.downColor":"#F14366","mainSeriesProperties.haStyle.upColor":"#0ECB81","mainSeriesProperties.haStyle.borderUpColor":"#0ECB81","mainSeriesProperties.haStyle.borderDownColor":"#F14366","mainSeriesProperties.barStyle.downColor":"#F14366","mainSeriesProperties.barStyle.upColor":"#0ECB81","mainSeriesProperties.baselineStyle.baselineColor":"rgba( 117, 134, 150, 1)","mainSeriesProperties.baselineStyle.topFillColor1":"#0ECB81","mainSeriesProperties.baselineStyle.topFillColor2":"#0ECB81","mainSeriesProperties.baselineStyle.bottomFillColor1":"#F14366","mainSeriesProperties.baselineStyle.bottomFillColor2":"#F14366"},Ws=Sa({...ya,settings_overrides:{"tradingProperties.positionPL.visibility":!0}
2,interval:"15",save_load_adapter:Na("tv-futures-chart-layouts-v2")});var js=(t,e)=>`${e==null?void 0:e.toLowerCase()}:${t==null?void 0:t.toLowerCase()}`,us=t=>{var e;return(e=t==null?void 0:t.split(","))==null?void 0:e.join("")},xl=t=>{t==null||t.subscribe("onAutoSaveNeeded",()=>{t==null||t.saveChartToServer(void 0,void 0,{chartName:"default",defaultChartName:"coin-switch-default"})})},vl=()=>{I(_.FuturesTradeChartViewFullScreenClicked)},yl=(t,e,r)=>{t==null||t.onIntervalChanged().subscribe(null,(n,s)=>{I(_.FuturesTradeChartViewTimeToggled,{coin:us(e),exchange:r,time_frame:n,time_line:(s==null?void 0:s.timeframe)||""})}),t==null||t.onChartTypeChanged().subscribe(null,n=>I(_.FuturesTradeChartViewChartToggled,{coin:us(e),exchange:r,chart_type:n}))},Sl=(t,e,r)=>{t==null||t.subscribe("toggle_sidebar",n=>{I(_.TvGraphToolClicked,{tool_bar:n?"Closed":"Open",coin:us(e),exchange:r})}),t==null||t.subscribe("indicators_dialog",function(){I(_.FuturesTradeChartViewIndicatorsClicked,{coin:us(e),exchange:r})}),t==null||t.subscribe("study",n=>{I(_.FuturesTradeChartViewIndicatorAdded,{indicator_name:n==null?void 0:n.value,coin:us(e),exchange:r})})};function Cl({tvSymbol:t,pageContract:e,knownContracts:r}){let n=Me(t!=null?t:"").contract;if(!n)return null;let s=(e!=null?e:"").trim().toLowerCase();if(n===s)return null;let o=(r!=null?r:[]).map(i=>(i!=null?i:"").trim().toLowerCase());return!o.length||!o.includes(n)?null:n}pr();Mc();Rc();Zr();Es();function Nl(t,{isOn:e,onToggle:r}){t&&t.headerReady().then(()=>{Nu(t,{isOn:e,onToggle:r})})}function Nu(t,{isOn:e,onToggle:r}){var u;let n=(u=t.createButton)==null?void 0:u.call(t);if(!n)return;n.className="",n.type="button",n.setAttribute("aria-label","Trade on Chart"),n.style.display="flex",n.style.flexDirection="row",n.style.justifyContent="center",n.style.alignItems="center",n.style.padding="8px",n.style.gap="8px",n.style.height="36px",n.style.background="transparent",n.style.border="none",n.style.cursor="default",n.style.boxSizing="border-box",n.style.order="8";let s=document.createElement("span");s.style.display="flex",s.style.flexDirection="row",s.style.justifyContent="center",s.style.alignItems="center",s.style.padding="0px 4px",s.style.gap="8px",s.style.width="28px",s.style.height="18px",s.style.background="#C13652",s.style.borderRadius="4px",s.style.flexGrow="0",s.style.flexShrink="0",s.style.order="0";let o=document.createElement("span");o.textContent="New",o.style.display="inline-flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.width="20px",o.style.height="18px",o.style.fontStyle="normal",o.style.fontWeight="500",o.style.fontSize="10px",o.style.lineHeight="18px",o.style.color="#FFFFFF",o.style.flexGrow="0",o.style.flexShrink="0",o.style.order="0",s.appendChild(o);let i=document.createElement("span");i.textContent="Trade on Chart",i.style.display="inline-flex",i.style.alignItems="center",i.style.whiteSpace="nowrap",i.style.height="20px",i.style.fontStyle="normal",i.style.fontWeight="500",i.style.fontSize="12px",i.style.lineHeight="20px",i.style.letterSpacing="0.03em",i.style.color="#C7D2E0",i.style.order="1",i.style.flexGrow="0",i.style.flexShrink="0";let a=document.createElement("span");a.style.display="inline-block",a.style.position="relative",a.style.width="22px",a.style.height="12px",a.style.borderRadius="30px",a.style.flexGrow="0",a.style.flexShrink="0",a.style.order="2",a.style.cursor="pointer";let l=document.createElement("span");l.style.position="absolute",l.style.width="8px",l.style.height="8px",l.style.top="calc(50% - 8px/2)",l.style.background="#FFFFFF",l.style.borderRadius="50px";let p=d=>{let c=d?"#A48743":"rgba(199, 210, 224, 0.24)";a.style.setProperty("background",c,"important"),a.style.setProperty("background-color",c,"important"),l.style.setProperty("left",d?"auto":"2px","important"),l.style.setProperty("right",d?"2px":"auto","important")},f=e;p(f),a.appendChild(l),i.style.cursor="pointer",n.replaceChildren(s,i,a),n.onclick=d=>{d.preventDefault(),d.stopPropagation()};let g=d=>{d.preventDefault(),d.stopPropagation(),f=!f,p(f),r(f)};i.onclick=g,a.onclick=g}var Al="default";function Tl(t){return Promise.resolve([{id:Al,name:"CoinSwitch Pro",currency:t?"INR":"",currencySign:t?"\u20B9":""}])}function El(){return Al}function _l(){return{accountTitle:"CoinSwitch Pro",summary:[],positionColumns:[{id:"symbol",label:"Symbol",dataFields:["symbol"],formatter:"symbol"},{id:"side",label:"Side",dataFields:["side"],formatter:"positionSide"},{id:"qty",label:"Qty",dataFields:["qty"],formatter:"formatQuantity"},{id:"avgPrice",label:"Entry",dataFields:["avgPrice"],formatter:"formatPrice"}],orderColumns:[{id:"symbol",label:"Symbol",dataFields:["symbol"],formatter:"symbol"},{id:"side",label:"Side",dataFields:["side"],formatter:"side"},{id:"qty",label:"Qty",dataFields:["qty"],formatter:"formatQuantity"},{id:"price",label:"Price",dataFields:["limitPrice"],formatter:"formatPrice"},{id:"status",label:"Status",dataFields:["status"],formatter:"status"}],pages:[]}}Vc();Es();Zr();Gr();Ns();vs();var Uo={["TAKE_PROFIT_MARKET"]:{["success"]:{["title"]:"Take Profit Order Placed",["msg"]:"Your take profit order was placed successfully"},["failure"]:{["title"]:"Take Profit Order Failed",["msg"]:""},["fallback"]:{["title"]:"Something Went Wrong",["msg"]:"Please Try Again"}},["STOP_MARKET"]:{["success"]:{["title"]:"Stop Loss Order Placed",["msg"]:"Your stop loss order was placed successfully"},["failure"]:{["title"]:"Stop Loss Order Failed",["msg"]:""},["fallback"]:{["title"]:"Something Went Wrong",["msg"]:"Please Try Again"}}},Il={["TAKE_PROFIT_MARKET"]:{["success"]:{["title"]:"Take Profit Modified",["msg"]:"Your TP order was modified successfully"},["failure"]:{["title"]:"Take Profit Modification Failed",["msg"]:""},["fallback"]:{["title"]:"Something Went Wrong",["msg"]:"Please Try Again"}},["STOP_MARKET"]:{["success"]:{["title"]:"Stop Loss Modified",["msg"]:"Your SL order was modified successfully"},["failure"]:{["title"]:"Stop Loss Modification Failed",["msg"]:""},["fallback"]:{["title"]:"Something Went Wrong",["msg"]:"Please Try Again"}}};var Sf={["TAKE_PROFIT_MARKET"]:{long:"TP Price should be more than last price",short:"TP Price should be less than last price"},["STOP_MARKET"]:{long:"SL Price should be less than last price",short:"SL Price should be more than last price",liquidationError:{long:"SL price can\u2019t be lower than liquidation price",short:"SL price can\u2019t be higher than liquidation price"}}};async function Cf(t,e){try{let r=await Oa({order_id:t,exchange:e});return r!=null&&r.success?le(be({type:"success",header:"Order Cancelled",content:"Your order was cancelled successfully"})):le(be({type:"failure",header:"Order Cancellellation Failed",content:r==null?void 0:r.msg})),r}catch{le(be({type:"failure",header:"Something Went Wrong",content:"Please Try Again"}))}}async function Nf(t,e,r){return await Xs(async()=>await Os({payload:r==="TAKE_PROFIT_MARKET"?e==null?void 0:e.getTakeProfitPayload(t):e==null?void 0:e.getStopLossPayload(t)}),Uo[r])}var Xs=async(t,e)=>{var r,n,s,o,i;try{let a=await t();return a!=null&&a.success?le(be({type:"success",header:(r=e==null?void 0:e["success"])==null?void 0:r["title"],content:(n=e==null?void 0:e["success"])==null?void 0:n["msg"]})):le(be({type:"failure",header:(s=e==null?void 0:e["failure"])==null?void 0:s["title"],content:a==null?void 0:a.msg})),a}catch(a){console.log(a),le(be({type:"failure",header:(o=e==null?void 0:e["fallback"])==null?void 0:o["title"],content:(i=e==null?void 0:e["fallback"])==null?void 0:i["msg"]}))}};Yi();var Au="Something Went Wrong",zr={LIMIT_ORDER_PLACEMENT_SUCCESS:{header:"Limit Order Placed",content:"Your limit order was placed successfully"},ORDER_PLACEMENT_FAILURE:{header:"Order Placement Failed",content:Au},EDIT_TP_NOT_ALLOWED:{header:"Take Profit Modification Restricted",content:"Please cancel the existing order to place a new TP order."},EDIT_SL_NOT_ALLOWED:{header:"Stop Loss Modification Restricted",content:"Please cancel the existing order to place a new SL order."},INVALID_TP_PRICE:{header:"Take Profit order placement failed",content:"Invalid TP price, please try again with a price within range."},INVALID_SL_PRICE:{header:"Stop Loss order placement failed",content:"Invalid SL price, please try again with a price within range"}};Oe();Ne();pr();As();var Qr={connectionStatus:{Connected:1},orderType:{Limit:1,Market:2,Stop:3},side:{Buy:1,Sell:-1}}
2,Bo=class{constructor({host:e,allPrecision:r,isPriceModeInr:n,isMarginModeInr:s,isInr:o,selectedExchange:i,getLeverageMap:a=()=>({}),tradeConfig:l,getTradeConfig:p,onHost:f,getIsEnabled:g=()=>!0}){this.orderExchangeById=new Map;this._positionById={};this._positions=[];this._orderById={};this._orders=[];this.quoteListeners={};var u;this.host=e,this.allPrecision=r,this.isPriceModeInr=n,this.isMarginModeInr=s,this.isInr=o,this.selectedExchange=(i||"BINANCE").toString().toUpperCase(),this.getLeverageMap=a,this.getTradeConfig=p!=null?p:()=>l,this.onHost=f,this.getIsEnabled=g;try{(u=this.onHost)==null||u.call(this,e)}catch{}}getUsdtRate(){return Is.get(Fn)||1}getOpenOrdersFromGlobalStore(){let e=Is.get(Ts);return Array.isArray(e)?e:[]}getPositionFromGlobalStore(){let e=Is.get(Cs);return Array.isArray(e==null?void 0:e.data)?e==null?void 0:e.data:[]}getPositionFromGlobalStoreById(e){return this.getPositionFromGlobalStore().find(n=>na(n==null?void 0:n.exchange,n==null?void 0:n.base_currency,n==null?void 0:n.quote_currency)===e)}findExistingTpSlOrder(e,r){let n=this.getOpenOrdersFromGlobalStore(),{base:s,quote:o}=Me(e);return n.find(i=>{var a,l;return(i==null?void 0:i.user_order_type)===r&&((a=i==null?void 0:i.base_currency)==null?void 0:a.toLowerCase())===s&&((l=i==null?void 0:i.quote_currency)==null?void 0:l.toLowerCase())===o&&(i==null?void 0:i.status)==="RAISED"})}async invalidateOpenOrdersAndPositions(){try{await Promise.all([xo.invalidateQueries({queryKey:["futures-open-orders"]}),xo.invalidateQueries({queryKey:["futures-open-positions"]})])}catch{}}priceMultiplierForUi(){return this.isPriceModeInr?this.getUsdtRate():1}valueMultiplierForUi(){return this.isMarginModeInr&&this.isInr?this.getUsdtRate():1}priceDividerForBackend(){return this.isPriceModeInr?1/this.getUsdtRate():1}extractPositionUnrealizedPlUsdt(e){var s,o,i,a,l,p,f,g,u,d;let r=(d=(u=(g=(f=(p=(l=(a=(o=(s=e==null?void 0:e.unrealized_pl)==null?void 0:s.value)==null?void 0:o.val)!=null?a:(i=e==null?void 0:e.unrealized_pl)==null?void 0:i.val)!=null?l:e==null?void 0:e.unrealized_pl)!=null?p:e==null?void 0:e.unrealized_pnl)!=null?f:e==null?void 0:e.unrealised_pnl)!=null?g:e==null?void 0:e.pnl)!=null?u:e==null?void 0:e.unrealizedPl)!=null?d:null,n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?n:null}getExitPositionPayload(e){var g;let r=this._positionById[e],n=r==null?void 0:r.symbol,{exchange:s,base:o,quote:i}=Me(n),a=(r==null?void 0:r.qty)||0,l=(r==null?void 0:r.avgPrice)||0,p=(g=this.getLeverageMap()[`${o}${i}`.toUpperCase()])!=null?g:"";return{exchange:s,side:(r==null?void 0:r.side)===1?"SELL":"BUY",base_qty:r==null?void 0:r.qty.toString(),base_currency:o,quote_qty:Math.abs(a*l*this.priceDividerForBackend()).toFixed(2),quote_currency:i,reduce_only:!0,type:"MARKET",...Number(p)&&{leverage:Number(p)}}}connectionStatus(){return Qr.connectionStatus.Connected}async chartContextMenuActions(e){return this.getIsEnabled()?[]:[]}async isTradable(e){return!0}async accountsMetainfo(){return Tl(this.isMarginModeInr&&this.isInr)}currentAccount(){return El()}accountManagerInfo(){return _l()}async orders(){if(!this.getIsEnabled())return[];let e=this.getOpenOrdersFromGlobalStore(),r=this.priceMultiplierForUi(),n=e.flatMap(s=>{var a,l,p;let o=((a=s==null?void 0:s.exchange)!=null?a:this.selectedExchange).toString().toUpperCase(),i=String((p=(l=s==null?void 0:s.order_id)!=null?l:s==null?void 0:s.id)!=null?p:"");return i&&this.orderExchangeById.set(i,o),sa([s],r)}).map(s=>{var i;let o=String((i=s==null?void 0:s.parentId)!=null?i:"");if(o){let a=this.getPositionFromGlobalStoreById(o),l=Number(a==null?void 0:a.size)||0;return{...s,qty:l}}return s}).filter(s=>s.beStatus==="CANCELLATION_RAISED"?!1:s.parentId?!(s.beStatus==="INIT"||s.qty==0):!0);return this._orderById=n.reduce((s,o)=>(s[o.id]=o,s),{}),this._orders=n,n}async positions(){if(!this.getIsEnabled())return[];let e=this.getPositionFromGlobalStore(),r=this.priceMultiplierForUi(),n=e.flatMap(s=>{let o=oa([s],r),i=this.extractPositionUnrealizedPlUsdt(s),a=o==null?void 0:o[0];if(a!=null&&a.id&&i!==null)try{this.host.plUpdate(String(a.id),i*this.valueMultiplierForUi())}catch{}return o}
2);return this._positionById=n.reduce((s,o)=>(s[o.id]=o,s),{}),this._positions=n,n}getPositionAnalyticsProps(e){var l,p,f;let r=this._positionById[e];if(!r)return{};let{base:n}=Me(r.symbol),s=this.getPositionFromGlobalStoreById(e),o=this.extractPositionUnrealizedPlUsdt(s),i=this.getLeverageMap(),a=`${n}usdt`.toUpperCase();return{price:String((l=r.avgPrice)!=null?l:""),asset:n.toUpperCase(),leverage:(p=i[a])!=null?p:"",order_value:String(Math.abs(Number(r.qty)*Number(r.avgPrice)||0)),qty:String((f=r.qty)!=null?f:""),"p&l":o!==null?String(o*this.valueMultiplierForUi()):""}}async editPositionBrackets(e,r){var q,K,dt,M,Ct;let n=this._positionById[e];if(!n)throw new Error("Position not found");let{base:s}=Me(n.symbol),o=(dt=(K=(q=this.allPrecision)==null?void 0:q[`${s},usdt`])==null?void 0:K.limit_precision)!=null?dt:2,i=this.getPositionFromGlobalStoreById(e),a=Number(i==null?void 0:i.last_price)*this.priceMultiplierForUi()||Number(n.avgPrice),l=Number(n.liquidationPrice),p=n.side===Qr.side.Buy,f=Number(r==null?void 0:r.takeProfit),g=Number(r==null?void 0:r.stopLoss),u=Number.isFinite(f)&&f>0?f:null,d=Number.isFinite(g)&&g>0?g:null,c=Number(n.takeProfit)>0,m=Number(n.stopLoss)>0,w=O=>p?O>a:O<a,b=O=>p?O<a&&O>l:O>a&&O<l,A=!1,x=!1,T=this.getPositionAnalyticsProps(e),R=!1,S=null;if(u)if(I(_.TradeOnChartPositionTPInteracted,{...T,tp_price:String(u)}),c){if(Number(n.takeProfit)!==u){if(!w(u))throw I(_.TradeOnChartOpenPositionTPSLChangeErrorShown),Nr(zr.INVALID_TP_PRICE),this.host.positionsFullUpdate(),new Error("");if(S=this.findExistingTpSlOrder(e,"TAKE_PROFIT_MARKET"),S)R=!0;else throw Nr(zr.EDIT_TP_NOT_ALLOWED),this.host.positionsFullUpdate(),new Error("")}}else{if(!w(u))throw I(_.TradeOnChartOpenPositionTPSLChangeErrorShown),Nr(zr.INVALID_TP_PRICE),this.host.positionsFullUpdate(),new Error("");A=!0}!u&&c&&I(_.TradeOnChartPositionTPClosed,{...T,tp_price:String((M=n.takeProfit)!=null?M:"")});let E=!1,Q=null;if(d)if(I(_.TradeOnChartPositionSLInteracted,{...T,sl_price:String(d)}),m){if(Number(n.stopLoss)!==d){if(!b(d))throw I(_.TradeOnChartOpenPositionTPSLChangeErrorShown),Nr(zr.INVALID_SL_PRICE),this.host.positionsFullUpdate(),new Error("");if(Q=this.findExistingTpSlOrder(e,"STOP_MARKET"),Q)E=!0;else throw Nr(zr.EDIT_SL_NOT_ALLOWED),this.host.positionsFullUpdate(),new Error("")}}else{if(!b(d))throw I(_.TradeOnChartOpenPositionTPSLChangeErrorShown),Nr(zr.INVALID_SL_PRICE),this.host.positionsFullUpdate(),new Error("");x=!0}if(!d&&m&&I(_.TradeOnChartPositionSLClosed,{...T,sl_price:String((Ct=n.stopLoss)!=null?Ct:"")}),!A&&!x&&!R&&!E)return;let L=async(O,ht)=>{let B=Vt.round(this.priceDividerForBackend()*ht,o),{base_qty:at,...h}=this.getExitPositionPayload(e),y={...h,type:O,stop_price:B.toString()};return Xs(()=>Os({payload:y}),Uo[O==="TAKE_PROFIT_MARKET"?"TAKE_PROFIT_MARKET":"STOP_MARKET"])},D=async(O,ht,B)=>{var y;let at=Vt.round(this.priceDividerForBackend()*B,o),h={order_id:O==null?void 0:O.order_id,new_trigger_price:at.toString(),user_custody_wallet_id:O==null?void 0:O.user_custody_wallet_id,asset_id:O==null?void 0:O.asset_id,exchange:((y=O==null?void 0:O.exchange)!=null?y:this.selectedExchange).toString().toUpperCase()};return Xs(()=>ea(h),Il[ht==="TAKE_PROFIT_MARKET"?"TAKE_PROFIT_MARKET":"STOP_MARKET"])};try{if(R&&S){let O=await D(S,"TAKE_PROFIT_MARKET",u);if(!(O!=null&&O.success))throw this.host.positionsFullUpdate(),new Error("")}else if(A){let O=await L("TAKE_PROFIT_MARKET",u);if(!(O!=null&&O.success))throw this.host.positionsFullUpdate(),new Error("")}if(E&&Q){let O=await D(Q,"STOP_MARKET",d);if(!(O!=null&&O.success))throw this.host.positionsFullUpdate(),new Error("")}else if(x){let O=await L("STOP_MARKET",d);if(!(O!=null&&O.success))throw this.host.positionsFullUpdate(),new Error("")}}catch{throw this.host.positionsFullUpdate(),new Error("")}await this.invalidateOpenOrdersAndPositions(),await Ps(5e3),this.host.positionsFullUpdate()}async closePosition(e){var a,l;if(!this.getIsEnabled())throw new Error("Trading on chart is disabled");let r=this._positionById[e];if(!r)throw new Error("Position not found");if(Math.abs(Number(r.qty)||0)<=0)throw new Error("Invalid position quantity");let s=this.getPositionAnalyticsProps(e);I(_.TradeOnChartPositionExitClicked,{...s,sl_price:String((a=r.stopLoss)!=null?a:""),tp_price:String((l=r.takeProfit)!=null?l:"")});let{base:o,quote:i}=Me(e);throw typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("futures:chart:open-exit-modal",{detail:{base_currency:o,quote_currency:i||"usdt"}})),this.host.positionsFullUpdate(),new Error("")}async executions(e){return[]}async symbolInfo(e){var x,T,R,S,E,Q,L,D,q;let{base:r,quote:n,contract:s}=Me(e),o=(E=(R=(x=this.allPrecision)==null?void 0:x[s])!=null?R:(T=this.allPrecision)==null?void 0:T[`${r},${n}`])!=null?E:(S=this.allPrecision)==null?void 0:S[r],i=(Q=o==null?void 0:o.limit_precision)!=null?Q:2,a=(L=o==null?void 0:o.base_precision)!=null?L:4,l=Math.pow(10,-1*i),p=Math.pow(10,-1*a),f=this.priceMultiplierForUi(),g=this.valueMultiplierForUi(),u=f>0?g/f:1,d=this.getTradeConfig(),c=Number((D=d==null?void 0:d.client_market)==null?void 0:D.min_base_quantity),m=Number.isFinite(c)&&c>0?Math.max(yn(c,a),p):p,w=Number((q=d==null?void 0:d.client_market)==null?void 0:q.max_base_quantity),b=Number.isFinite(w)&&w>0?w:1e12;return{qty:{min:m,max:b,step:p,uiStep:p,default:m},pipValue:l*u,pipSize:l,minTick:l,type:"crypto",units:r.toUpperCase(),description:`${r.toUpperCase()}/${n.toUpperCase()}`,currency:n.toUpperCase(),baseCurrency:r.toUpperCase(),quoteCurrency:n.toUpperCase(),allowedOrderTypes:[Qr.orderType.Limit,Qr.orderType.Market,Qr.orderType.Stop]}}async formatter(e,r){var o,i,a;let{base:n}=Me(e),s=(a=(i=(o=this.allPrecision)==null?void 0:o[`${n},usdt`])==null?void 0:i.limit_precision)!=null?a:2;return this.host.numericFormatter(s)}async spreadFormatter(e){var s,o,i;let{base:r}=Me(e),n=(i=(o=(s=this.allPrecision)==null?void 0:s[`${r},usdt`])==null?void 0:o.limit_precision)!=null?i:2;return this.host.numericFormatter(n)}async quantityFormatter(e){var s,o,i;let{base:r}=Me(e),n=(i=(o=(s=this.allPrecision)==null?void 0:s[`${r},usdt`])==null?void 0:o.base_precision)!=null?i:3;return this.host.numericFormatter(n)}async placeOrder(e){var p,f,g,u,d,c,m,w,b,A,x,T,R,S;if(!this.getIsEnabled())throw new Error("Trading on chart is disabled");let r=e.side===Qr.side.Sell?"SELL":"BUY",n=e.type===Qr.orderType.Market?"MARKET":e.type===Qr.orderType.Limit?"LIMIT":e.type===Qr.orderType.Stop?"STOP":"UNKNOWN";if(n==="STOP")throw new Error("Stop orders are not supported yet");if(n==="UNKNOWN")throw new Error("Unsupported order type");let{base:s,quote:o}=Me(e.symbol);if(n==="LIMIT"){let E=this.getLeverageMap(),Q=`${s}${o}`.toUpperCase();I(_.TradeOnChartLimitOrderPlaced,{exchange:this.selectedExchange,side:r==="BUY"?"long":"short",type:n,base_qty:String((p=e.qty)!=null?p:""),base_currency:s.toUpperCase(),quote_currency:o.toUpperCase(),limit_price:String((f=e.limitPrice)!=null?f:""),leverage:(g=E[Q])!=null?g:"","Card type":""})}let i=(x=(A=(b=(w=(c=(u=e==null?void 0:e.currentQuotes)==null?void 0:u.ask)!=null?c:(d=e==null?void 0:e.currentQuotes)==null?void 0:d.bid)!=null?w:(m
2=e==null?void 0:e.currentQuotes)==null?void 0:m.trade)!=null?b:e.limitPrice)!=null?A:e.stopPrice)!=null?x:"",a=Number(n==="MARKET"?i:e.limitPrice),l=await ga({symbol:e.symbol,side:r,type:n,qty:String((T=e.qty)!=null?T:""),limitPriceInUi:a,usdtRate:this.getUsdtRate(),isPriceModeInr:this.isPriceModeInr,isInr:this.isInr,getLeverageMap:this.getLeverageMap,allPrecision:this.allPrecision,tradeConfig:this.getTradeConfig(),getCostExternal:E=>0});if(!l.success){let E=(S=(R=l.validationErrors)!=null?R:l.error)!=null?S:"Order placement failed";throw Nr(zr.ORDER_PLACEMENT_FAILURE,E),new Error(E)}if(!l.orderId)throw Nr(zr.ORDER_PLACEMENT_FAILURE,"Order placement failed (missing order id)"),new Error("Order placement failed (missing order id)");return $i(zr.LIMIT_ORDER_PLACEMENT_SUCCESS),{orderId:l.orderId}}async modifyOrder(e){}async cancelOrder(e){var s,o,i,a,l,p;if(!this.getIsEnabled())throw new Error("Trading on chart is disabled");let r=this._orderById[e];if(r){let{base:f,quote:g}=Me(r.symbol),u=this.getLeverageMap(),d=`${f}${g}`.toUpperCase();I(_.TradeOnChartLimitOrderCancelled,{exchange:this.selectedExchange,side:r.side===Qr.side.Buy?"long":"short",type:"LIMIT",base_qty:String((s=r.qty)!=null?s:""),base_currency:f.toUpperCase(),quote_currency:g.toUpperCase(),limit_price:String((o=r.limitPrice)!=null?o:""),leverage:(i=u[d])!=null?i:"","Card type":"",tp_price:String((a=r.takeProfit)!=null?a:""),sl_price:String((l=r.stopLoss)!=null?l:"")})}let n=(p=this.orderExchangeById.get(e))!=null?p:"BINANCE";await aa(async()=>await Ms({order_id:e,exchange:n})),await this.invalidateOpenOrdersAndPositions(),this.host.ordersFullUpdate()}};function Ll(t){return e=>{var r;return new Bo({host:e,allPrecision:t.allPrecision,isPriceModeInr:t.isPriceModeInr,isMarginModeInr:t.isMarginModeInr,isInr:t.isInr,selectedExchange:t.selectedExchange,getLeverageMap:(r=t.getLeverageMap)!=null?r:()=>({}),tradeConfig:t.tradeConfig,getTradeConfig:t.getTradeConfig,onHost:t.onHost,getIsEnabled:t.getIsEnabled})}}var Gt=N(Qt()),wc=N(gs());vr();he();he();var on=N(Y());function qo(t){return(0,on.jsxs)("div",{className:"tw-relative tw-mb-1 tw-w-max",children:[(0,on.jsx)("div",{className:"tw-absolute -tw-bottom-[5px] tw-left-[calc(50%-76px)] tw-h-2.5 tw-w-2.5 tw-rotate-45 tw-border-b tw-border-r tw-border-[#F14366] tw-bg-[#1B1E2D]"}),(0,on.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between tw-gap-3 tw-rounded-lg tw-border tw-border-[#F14366] tw-bg-[#1B1E2D] tw-px-2 tw-py-[7px]",children:[(0,on.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,on.jsx)(et,{name:"warning-red",className:"tw-h-4 tw-w-4 tw-shrink-0"}),(0,on.jsxs)("span",{className:"tw-whitespace-nowrap tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[0.03em] tw-text-white",children:["Min quantity is ",t.minQty," ",t.baseCurrency]})]}),(0,on.jsx)("button",{type:"button",onClick:t.onUseMinimum,className:"tw-whitespace-nowrap tw-text-xs tw-font-medium tw-leading-3 tw-tracking-[0.03em] tw-text-[#CDA954]",children:"Use Minimum"})]})]})}he();var an=N(Y());function Vo(t){return(0,an.jsxs)("div",{className:"tw-relative tw-mb-1 tw-w-max",children:[(0,an.jsx)("div",{className:"tw-absolute -tw-bottom-[5px] tw-left-[calc(50%-76px)] tw-h-2.5 tw-w-2.5 tw-rotate-45 tw-border-b tw-border-r tw-border-[#F14366] tw-bg-[#1B1E2D]"}),(0,an.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between tw-gap-3 tw-rounded-lg tw-border tw-border-[#F14366] tw-bg-[#1B1E2D] tw-px-2 tw-py-[7px]",children:[(0,an.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,an.jsx)(et,{name:"warning-red",className:"tw-h-4 tw-w-4 tw-shrink-0"}),(0,an.jsxs)("span",{className:"tw-whitespace-nowrap tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[0.03em] tw-text-white",children:["Max quantity is ",t.maxQty," ",t.baseCurrency]})]}),(0,an.jsx)("button",{type:"button",onClick:t.onUseMaximum,className:"tw-whitespace-nowrap tw-text-xs tw-font-medium tw-leading-3 tw-tracking-[0.03em] tw-text-[#CDA954]",children:"Use Maximum"})]})]})}var Kr=N(Y());function Hn(t){let e=t.side==="BUY",r=t.align==="right";return(0,Kr.jsx)("div",{className:`tw-absolute tw-bottom-full tw-z-50 tw-mb-3 tw-w-max ${r?"tw-right-0":"tw-left-1/2 -tw-translate-x-1/2"}`,style:{pointerEvents:"none"},children:(0,Kr.jsxs)("div",{className:"tw-relative tw-pb-[5px]",children:[(0,Kr.jsxs)("div",{className:"tw-relative tw-z-10 tw-flex tw-items-center tw-gap-1 tw-whitespace-nowrap tw-rounded tw-bg-[#494B57] tw-px-3 tw-py-1.5",children:[(0,Kr.jsx)("div",{className:`tw-flex tw-h-4 tw-w-[15p
2x] tw-shrink-0 tw-items-center tw-justify-center tw-rounded-sm ${e?"tw-bg-[#0A8E5A]":"tw-bg-[#F14366]"}`,children:(0,Kr.jsx)("span",{className:"tw-text-xs tw-font-medium tw-leading-3 tw-tracking-[0.03em] tw-text-white",children:e?"L":"S"})}),(0,Kr.jsx)("span",{className:"tw-text-xs tw-font-medium tw-leading-5 tw-tracking-[0.03em] tw-text-[#C7D2E0]",children:"Req. Margin"}),(0,Kr.jsx)("span",{className:"tw-text-xs tw-font-medium tw-leading-5 tw-tracking-[0.03em] tw-text-[#EDF2F7]",children:t.margin})]}),(0,Kr.jsx)("div",{className:`tw-absolute tw-bottom-0 tw-h-[10px] tw-w-[10px] tw-rotate-45 tw-bg-[#494B57] ${r?"tw-right-4":"tw-left-1/2 -tw-translate-x-1/2"}`})]})})}Oe();Ne();var Ve=N(Qt());var Tn=N(Qt()),Or=N(Y());function $o({min:t,max:e,value:r,step:n=1,onChange:s}){let o=(0,Tn.useRef)(null),[i,a]=(0,Tn.useState)(!1),l=(0,Tn.useMemo)(()=>e===t?0:(r-t)/(e-t)*100,[r,t,e]),p=(0,Tn.useCallback)(w=>{if(!o.current)return r;let b=o.current.getBoundingClientRect(),A=Math.max(0,Math.min(1,(w-b.left)/b.width)),x=t+A*(e-t);return n>0&&(x=Math.round(x/n)*n),Math.max(t,Math.min(e,x))},[t,e,n,r]),f=w=>{a(!0),w.target.setPointerCapture(w.pointerId);let b=p(w.clientX);b!==r&&s(b)},g=w=>{if(!i)return;let b=p(w.clientX);b!==r&&s(b)},u=w=>{a(!1),w.target.releasePointerCapture(w.pointerId)};return(0,Or.jsx)("div",{className:"tw-flex tw-w-full tw-select-none tw-flex-col",children:(0,Or.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-col tw-justify-center",children:[(0,Or.jsxs)("div",{ref:o,className:"tw-relative tw-flex tw-h-[15px] tw-w-full tw-cursor-pointer tw-items-center",onPointerDown:f,onPointerMove:g,onPointerUp:u,onPointerCancel:u,onTouchStart:w=>{a(!0);let b=p(w.touches[0].clientX);b!==r&&s(b)},onTouchMove:w=>{if(!i)return;w.preventDefault();let b=p(w.touches[0].clientX);b!==r&&s(b)},onTouchEnd:()=>{a(!1)},style:{touchAction:"none"},children:[(0,Or.jsx)("div",{className:"tw-absolute tw-h-[2px] tw-w-full tw-rounded-full tw-bg-[#494B57]"}),(0,Or.jsx)("div",{className:"tw-absolute tw-h-[2px] tw-rounded-full tw-bg-[#A0AEC0]",style:{width:`${l}%`}}),(0,Or.jsx)("div",{className:"tw-absolute tw-h-4 tw-w-4 tw-rounded-full tw-border-[2px] tw-border-[#323542] tw-bg-[#FFFFFF]",style:{left:`calc(${l}% - 8px)`,boxShadow:i?"0 0 0 4px rgba(226, 232, 240, 0.15)":"none",transition:i?"none":"box-shadow 0.15s ease"}})]}),(0,Or.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between tw-h-[7px]",children:[(0,Or.jsxs)("span",{className:"tw-text-[10px] tw-font-medium tw-text-[#A0AEC0]",children:[t,"x"]}),(0,Or.jsxs)("span",{className:"tw-text-[10px] tw-font-medium tw-text-[#A0AEC0]",children:[e,"x"]})]})]})})}pr();he();Lr();var xe=N(Y());function Yo({leverage:t,priceFallPercent:e,onClose:r,onConfirm:n}){return(0,xe.jsxs)("div",{className:"tw-fixed tw-inset-0 tw-z-[9999] tw-flex tw-items-center tw-justify-center",children:[(0,xe.jsx)("div",{className:"tw-absolute tw-inset-0 tw-bg-transparent tw-opacity-100 tw-backdrop-blur-sm",onClick:r}),(0,xe.jsxs)("div",{className:"tw-relative tw-h-fit tw-w-[360px] tw-border tw-border-gray-800 tw-bg-[#121319] tw-p-6",children:[(0,xe.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,xe.jsx)("p",{className:"tw-text-xl tw-font-medium tw-text-gray-100",children:"Adjust Leverage"}),(0,xe.jsx)("div",{className:"tw-h-fit tw-w-fit tw-cursor-pointer",onClick:r,children:(0,xe.jsx)(et,{width:"tw-w-5",height:"tw-h-5",name:"cross-gray"})})]}),(0,xe.jsx)("div",{className:"tw-min-h-[160px] tw-w-full tw-flex-1",children:(0,xe.jsxs)("div",{className:"tw-mt-6",children:[(0,xe.jsxs)("div",{className:"tw-flex tw-flex-col tw-items-center tw-justify-center",children:[(0,xe.jsxs)("div",{className:"tw-relative tw-h-10 tw-w-[115px]",children:[(0,xe.jsxs)("div",{className:"tw-absolute tw-bottom-0 tw-flex tw-w-full tw-justify-center tw-text-base tw-font-medium tw-text-white",children:[t,"x"]}),(0,xe.jsx)("img",{width:"100%",src:mr("/pro/assets/images/futures/high-risk.png"),alt:""})]}),(0,xe.jsx)("p",{className:"tw-mt-2 tw-rounded tw-bg-pro-red-700 tw-px-2 tw-py-0.5 tw-text-xs tw-font-medium tw-text-white",children:"Caution : High Risk"})]}),(0,xe.jsxs)("div",{className:"tw-mt-5 tw-flex tw-gap-x-2 tw-text-sm tw-text-gray-500",children:[(0,xe.jsx)(et,{name:"important-red-fill",width:"tw-w-5",height:"tw-h-5"}),(0,xe.jsxs)("p",{children:["At"," ",(0,xe.jsxs)("span",{className:"tw-font-medium tw-text-gray-200",children:[t,"X leverage"]}),", if the price falls by"," ",(0,xe.jsxs)("span",{className:"tw-font-medium tw-text-gray-200",children:["~ ",e,"%"]})," ","your position will get liquidated"]})]})]})}),(0,xe.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-x-2 ",children:[(0,xe.jsx)(qt,{onClick:r,variant:"outline",className:"tw-h-10 tw-w-full",children:"CLOSE"}),(0,xe.jsx)(qt,{onClick:n,className:"tw-h-10 tw-w-full tw-font-semibold tw-uppercase",children:"CONFIRM"})]})]})]})}var We=N(Qt());vr();es();var zn="https://files-pro.coinswitch.co/cspro/1790767973354/build/_assets/close-VUMLXNQL.svg";Ir();Lr();var En=N(Y());function Eu({isOpen:t,setIsOpen:e,children:r,contentClassName:n="tw-w-[360px]",portalContainer:s}){let{is_mobile:o}=Cr();
2return o?(0,En.jsxs)(ze,{open:t,onOpenChange:e,dismissible:!1,children:[(0,En.jsx)(ze.Overlay,{className:"tw-bg-black-01/70"}),(0,En.jsx)(ze.Content,{className:"tw-w-full tw-rounded-2xl tw-border-t tw-border-pro-gray-200 tw-bg-[#121319] tw-p-[16px]",children:r})]}):(0,En.jsxs)(xn,{isOpen:t,onOpenChange:e,isDismissable:!1,portalContainer:s,children:[(0,En.jsx)(xn.Overlay,{className:"tw-bg-[#121319] tw-opacity-80"}),(0,En.jsx)(xn.Content,{className:`${n} tw-border tw-border-[#2D3748] tw-bg-[#121319] tw-backdrop-blur-sm`,children:r})]})}var Zs=Eu;var Dt=N(Qt());var Pl=[{title:"Margin",key:0,val:"margin"},{title:"Liq. Price",key:1,val:"liquidation_price"}];Oe();Ne();Lr();he();Oe();Ne();var Go=N(Y()),_u=({activeTab:t,setActiveTab:e})=>{var r;return(0,Go.jsx)("div",{className:"tw-flex tw-w-full tw-gap-x-[12px]",children:(r=Pl)==null?void 0:r.map(({title:n},s)=>(0,Go.jsx)("div",{className:`${t===n?"tw-border-none tw-bg-[#7B6532] tw-text-white":"tw-border tw-border-[#524422] tw-bg-none"} tw-w-full tw-cursor-pointer tw-rounded-[4px] tw-py-[10px] tw-text-center tw-text-[12px] tw-font-[500] tw-leading-[12px] tw-text-[#CDA954]`,onClick:()=>{t==="Margin"?I(_.FuturesMarginTabClick):I(_.FuturesLiquidationTabClick),e(n)},children:n},s))})},Ol=_u;pr();var Mr=N(Y()),Iu=({label:t,initial:e,final:r,percentage:n})=>(0,Mr.jsx)("div",{children:(0,Mr.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between",children:[(0,Mr.jsx)("p",{className:"tw-whitespace-nowrap tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#718096]",children:t}),(0,Mr.jsxs)("div",{className:"tw-flex tw-w-[260px] tw-items-center tw-justify-between md:tw-w-[210px]",children:[(0,Mr.jsx)("p",{className:"tw-w-[90px] tw-min-w-[90px] tw-overflow-x-scroll tw-whitespace-nowrap tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#A0AEC0]",style:{scrollbarWidth:"none"},children:e}),(0,Mr.jsx)("img",{src:mr("/pro/assets/images/futures/Arrow.svg"),alt:"arrow"}),(0,Mr.jsxs)("div",{className:"tw-flex tw-w-[120px] tw-min-w-[100px] tw-overflow-x-scroll tw-whitespace-nowrap",style:{scrollbarWidth:"none"},children:[r!==null&&(0,Mr.jsx)("p",{className:"tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#A0AEC0]",children:r}),(0,Mr.jsx)("p",{className:` ${n&&Number(n)<0?"tw-text-[#F25575]":"tw-text-[#0ECB81]"} tw-ml-[3px] tw-text-[12px] tw-font-[400] tw-leading-[20px]`,children:(n==null?void 0:n.toString())==="--"?n:`(${n}%)`})]})]})]})}),Js=Iu;_c();hn();var Ml=N(Qt()),zo=N(Y()),Lu=Ml.default.forwardRef(function({value:e,onChange:r},n){return(0,zo.jsx)("input",{maxLength:12,ref:n,type:"text",inputMode:"numeric",className:"tw-w-[130px] tw-bg-[#1B1E2D] tw-text-right tw-text-[16px] tw-font-[500] tw-leading-[16px] tw-text-white tw-outline-none",value:e,onChange:s=>{r(s.target.value)}})}),Qn=({text:t,extraClass:e})=>(0,zo.jsx)("p",{className:ne("tw-w-full tw-overflow-x-scroll tw-whitespace-nowrap tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#F14366]",e),style:{scrollbarWidth:"none"},children:t}),Ho=Lu;Gr();vr();Zr();Ir();pr();Dc();var ot=N(Y()),Pu=({isOpen:t,setIsOpen:e,position:r,config:n,precision:s,walletUpdateCallback:o,ordersUpdateCallback:i,clickedKey:a,setIsQuickBuyOpen:l,walletBalance:p,isMobile:f,inrBalance:g,setTopupOpen:u,embedded:d=!1})=>{let{isInr:c,convertUsdtToInr:m,convertInrToUsdt:w,futuresInrUsdtValueConverter:b,futuresInrUsdtConverter:A,isPriceModeInr:x,isMarginModeInr:T}=ue(),R=d?c?Hr()&&!u:!l:!1,S=(0,Dt.useMemo)(()=>new $s(r,s,{...n,isInr:c,isPriceModeInr:x}),[n,c,r,s,x]),E=(0,Dt.useMemo)(()=>c?Vt.roundDown(g||0,2):Vt.roundDown(p,2),[g,c,p]),Q=(0,Dt.useMemo)(()=>Vt.roundDown(w(g||0),2),[w,g]),L=(0,Dt.useMemo)(()=>S.parseDisplayData(),[S]),[D,q]=(0,Dt.useState)(!1),[K,dt]=(0,Dt.useState)("Margin"),[M,Ct]=(0,Dt.useState)(!0),[O,ht]=(0,Dt.useState)(""),[B,at]=(0,Dt.useState)(""),[h,y]=(0,Dt.useState)(0),P=(0,Dt.useRef)(null),G=(0,Dt.useRef)(null),[U,H]=(0,Dt.useState)(!1),[vt,X]=(0,Dt.useState)(!1),[At,xt]=(0,Dt.useState)(!1),ut=Bt(Yr),{is_mobile:F}=Cr(),Z=Vr(),ct=()=>{if(f)X(ft=>!ft);else return},mt=(0,Dt.useCallback)(ft=>{let v=Po(ft,2);ht(v)},[]),it=(0,Dt.useCallback)((ft,v)=>{let C=Po(ft,L.limitPrecision);at(C);let nt=x?w(tn(C)):tn(C);typeof v=="number"&&!isNaN(v)?y(v):y(S.getMarginDiff(nt))},[w,x,S,L.limitPrecision]),J=(0,Dt.useCallback)(ft=>{ft==="margin"?dt("Margin"):ft==="liquidation_price"&&dt("Liq. Price")},[]),wt=(0,Dt.useCallback)(ft=>{if(B==="")return;let v=tn(B);if(isNaN(v))return;let C=ft?new co(v).multipliedBy(1.01):new co(v).multipliedBy(.99);C!=null&&C.toString().includes("e")?it(parseFloat(C==null?void 0:C.toString()).toFixed(10)):it(C==null?void 0:C.toString())},[it,B]),lt=(0,Dt.useMemo)(()=>({maxRemovableMargin:S.maxRemovableMargin(),maxLimitPrice:S.maxLimitPrice().liquidationPrice,maxAvailable:S.getLiquidationPrice(E).liquidationPrice}),[S,E]),bt=(0,Dt.useMemo)(()=>K==="Margin"&&M?c&&T?Vt.roundDown(w(tn(O)),4):tn(O):K==="Margin"?c&&T?Vt.roundDown(w(-tn(O)),4):-tn(O):h,[K,w,O,c,h,M,T]),Xt=(0,Dt.useMemo)(()=>c&&!T?w(E):E,[E,c,T,w]),Mt=(0,Dt.useMemo)(()=>c&&T?m(bt):bt,[m,c,bt,T]),Lt=(0,Dt.useMemo)(()=>{let ft=S.margin,v=S.rawLiquidationPrice,C=Math.round(S.getLiquidationRisk(0).finalRisk),nt=Math.max(ft+bt,0),yt=Math.round((nt-ft)*100/ft),Zt=S.getLiquidationPrice(bt).rawLiquidationPrice,ve=Math.round(S.getLiquidationPrice(bt).liquidationPriceChange),pe=M
2ath.round(S.getLiquidationRisk(bt).finalRisk);return{initMargin:ft,initLiqPrice:v,initLiqRisk:C,finalMargin:nt,finalMarginChange:yt,finalLiqPrice:Zt,finalLiqPriceChange:ve,finalLiqRisk:pe}},[bt,S]),Ft=(0,Dt.useCallback)(async()=>{q(!0),await la(async()=>{let ft=await Ma({base_currency:L.base_currency,quote_currency:L.quote_currency,exchange:L==null?void 0:L.exchange,margin:Math.abs(bt).toFixed(4),margin_type:bt<0?"REMOVE_MARGIN":"ADD_MARGIN"});return ft!=null&&ft.success&&ca(o,i),ft}),e(!1),q(!1),K==="Margin"?I(_.FuturesUpdateMarginOrderPlaced,{type:bt<0?"REMOVE_MARGIN":"ADD_MARGIN"}):I(_.FuturesUpdateMarginLiquidationOrderPlaced,{type:bt<0?"Decrease":"Increase"})},[K,bt,i,L.base_currency,L==null?void 0:L.exchange,L.quote_currency,e,o]),oe=(0,Dt.useCallback)(()=>{var C;let ft=c&&!T?Q:E,v=c&&T?Vt.roundDown(w(ft),2):ft;if(K==="Margin")mt(ft==null?void 0:ft.toString());else{let nt=S.getLiquidationPrice(v).liquidationPrice;it(x?(C=m(nt))==null?void 0:C.toString():nt==null?void 0:nt.toString(),v)}},[c,T,x,w,E,K,mt,it,m,S]),Nt=(0,Dt.useCallback)(()=>{var ft,v,C;K==="Margin"?mt(c&&T?(ft=m(lt.maxRemovableMargin))==null?void 0:ft.toString():lt.maxRemovableMargin.toString()):it(x?(v=m(S.maxLimitPrice().liquidationPrice))==null?void 0:v.toString():(C=S.maxLimitPrice().liquidationPrice)==null?void 0:C.toString(),-lt.maxRemovableMargin)},[K,m,it,mt,c,T,lt.maxRemovableMargin,S,x]),pt=(0,Dt.useMemo)(()=>Mt>0&&Mt>Xt?1:bt<0&&Math.abs(bt)>(lt==null?void 0:lt.maxRemovableMargin)?2:(B===""||Number(B)===0)&&K==="Liq. Price"?3:!1,[Mt,Xt,bt,lt==null?void 0:lt.maxRemovableMargin,B,K]);(0,Dt.useEffect)(()=>{let ft=setTimeout(()=>{H(pt)});return()=>{clearTimeout(ft)}},[pt]);let _t=(0,Dt.useMemo)(()=>Mt>0&&Mt>Number(Xt)?"USE_AVAILBALE":bt<0&&Math.abs(bt)>(lt==null?void 0:lt.maxRemovableMargin)?"USE_MAX_REMOVABLE":K==="Margin"&&M?"ADD_MARGIN":K==="Margin"?"REMOVE_MARGIN":tn(B)>=(c&&x?m(S.liquidationPrice):S.liquidationPrice)?"INC_LIQ_PRICE":"DEC_LIQ_PRICE",[Mt,Xt,bt,lt==null?void 0:lt.maxRemovableMargin,K,M,c,x,m,B,S.liquidationPrice]);(0,Dt.useEffect)(()=>{J(a)},[a,J]),(0,Dt.useEffect)(()=>{var ft,v;K=="Liq. Price"&&it(x?(ft=m(S.rawLiquidationPrice))==null?void 0:ft.toString():(v=S.liquidationPrice)==null?void 0:v.toString(),0)},[K]);let Jt=(0,ot.jsxs)("div",{className:"tw-mt-[8px]",children:[(0,ot.jsxs)("div",{className:"tw-flex tw-justify-between",children:[(0,ot.jsxs)("p",{className:"tw-text-[12px] tw-font-[500] tw-leading-[20px] tw-text-[#C7D2E0]",children:[L==null?void 0:L.contract,(0,ot.jsx)("span",{className:`${L!=null&&L.isLong?"tw-text-[#0ECB81]":"tw-text-[#F46985]"} tw-ml-[8px] tw-text-[12px] tw-font-[500] tw-leading-[20px]`,children:ia(L==null?void 0:L.side)}),(0,ot.jsx)("span",{className:"tw-ml-[8px] tw-text-[12px] tw-font-[500] tw-leading-[20px] tw-text-[#718096]",children:L==null?void 0:L.leverage})]}),(0,ot.jsxs)("p",{className:"tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#718096]",children:["Liq. Price"," ",(0,ot.jsx)("span",{className:"tw-ml-[4px]",children:A(L==null?void 0:L.liquidation_price,!0,L.limitPrecision)})]})]}),(0,ot.jsxs)("div",{className:"tw-mb-[24px] tw-flex tw-items-center tw-justify-between",children:[(0,ot.jsxs)("p",{className:"tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#718096]",children:["Margin"," ",(0,ot.jsxs)("span",{className:"tw-ml-[4px]",children:[b(L==null?void 0:L.margin,!0,2)," ",c&&T?"":"USDT"]})]}),(0,ot.jsx)("div",{children:(0,ot.jsxs)("p",{className:"tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#718096]",children:["Last Price"," ",(0,ot.jsx)("span",{className:"tw-ml-[4px]",children:A(L==null?void 0:L.last_price,!0,L.limitPrecision)})]})})]}
2),!d&&(0,ot.jsx)(Ol,{activeTab:K,setActiveTab:dt}),K==="Margin"?(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:`${pt?"tw-border tw-border-[#F14366]":"tw-border-none"} tw-mb-[8px] tw-mt-[20px] tw-flex tw-h-[40px] tw-items-center tw-justify-between tw-rounded-[4px] tw-bg-[#1B1E2D] tw-px-[12px]`,children:[(0,ot.jsxs)("div",{className:"tw-flex tw-cursor-pointer tw-items-center",onClick:()=>(I(_.FuturesMarginToggleClick,{toggle_option:M?"Add Margin":"Remove Margin"}),Ct(ft=>!ft)),children:[(0,ot.jsxs)("p",{className:"tw-mr-[4px] tw-whitespace-nowrap tw-text-[11px] tw-font-[500] tw-leading-[12px] tw-text-gold-500",children:[M?"ADD":"REMOVE"," MARGIN"]}),(0,ot.jsx)("img",{src:mr("/pro/assets/images/futures/IconVariant.svg"),alt:"toggle_icon",className:"tw-h-[12px] tw-w-[12px] tw-cursor-pointer"})]}),(0,ot.jsxs)("div",{className:"tw-flex tw-items-center",children:[(0,ot.jsx)(Ho,{onChange:ft=>{I(_.FuturesMarginInputClick),mt(ft)},value:O,ref:P}),(0,ot.jsx)("p",{onClick:()=>{P!=null&&P.current&&P.current.focus()}
2,className:"tw-ml-[2px] tw-text-[16px] tw-font-[500] tw-leading-[16px] tw-text-[#4A5568]",children:c&&T?"INR":"USDT"})]})]}),(0,ot.jsxs)("div",{className:"tw-flex tw-h-5 tw-justify-between",children:[M&&(0,ot.jsx)("p",{className:`${M?"tw-w-[148px] tw-min-w-[148px]":"tw-w-full"} tw-overflow-x-scroll tw-whitespace-nowrap tw-text-[12px] tw-font-[400] tw-leading-[20px] tw-text-[#718096]`,style:{scrollbarWidth:"none"},children:`Available ${c?T?Vt.inrCurrency(E):Vt.usdtFormat(Q,2):E} ${c&&T?"":"USDT"}`}),!M&&(0,ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,ot.jsx)(Qn,{text:`Max removable ${b(lt.maxRemovableMargin,!0,2)} ${c&&T?"":"USDT"}`,extraClass:`tw-w-full tw-overflow-x-scroll tw-whitespace-nowrap tw-text-[12px] tw-font-[400] tw-leading-[20px] ${pt===2?"tw-text-[#F14366]":"tw-text-[#718096]"}`}),(0,ot.jsxs)("div",{className:"tw-group tw-relative",onClick:()=>{ct()},children:[(0,ot.jsx)(et,{name:"exclamation-mark-info-gold",width:"tw-w-3",height:"tw-h-3"}),!f&&(0,ot.jsx)("div",{className:"tw-absolute tw-top-[68px] tw-z-20 tw-hidden tw-h-[50px] tw-w-[238px] -tw-translate-x-1/2 -tw-translate-y-full tw-rounded tw-border tw-border-gray-700 tw-bg-black tw-p-2 tw-text-xs tw-text-grey-01 tw-shadow-sm group-hover:tw-block",children:"Only added margin can be removed. Unrealized profit cannot be removed."})]}),vt&&(0,ot.jsxs)(ze,{open:vt,onOpenChange:X,children:[(0,ot.jsx)(ze.Overlay,{className:" tw-bg-black-01/50"}),(0,ot.jsxs)(ze.Content,{className:"tw-bg-black tw-p-4 tw-pt-0 tw-text-xs tw-text-gray-400",children:[(0,ot.jsx)(ze.Nudge,{className:"tw-mt-1.5 tw-h-1 tw-w-[50px]"}),(0,ot.jsx)("p",{className:"tw-py-4",children:"Only added margin can be removed. Unrealized profit cannot be removed."})]})]})]}),M&&pt===1&&(0,ot.jsx)(Qn,{text:`Need 
3                  ${c&&T?"\u20B9":""}${Number(Math.abs(Mt-Xt)).toFixed(2)}
4                  ${c&&T?"":"USDT"} more`,extraClass:"tw-w-[160px] tw-min-w-[160px] tw-overflow-x-scroll tw-whitespace-nowrap tw-text-[12px] tw-font-[500] tw-leading-[20px] tw-text-[#F14366]"})]})]}):(0,ot.jsxs)("div",{className:"tw-mb-[20px]",children:[(0,ot.jsxs)("div",{className:"tw-mb-2 tw-mt-[20px] tw-flex tw-items-center tw-justify-between tw-gap-[10px]",children:[(0,ot.jsxs)("div",{onClick:()=>{G!=null&&G.current&&G.current.focus()},className:`tw-flex tw-h-[40px] tw-items-center tw-justify-between tw-rounded-[4px] tw-bg-[#1B1E2D] tw-p-[12px] ${U&&pt?"tw-border tw-border-[#F14366]":"tw-border-none"} ${f?"tw-w-auto tw-min-w-[232px] tw-flex-grow":"tw-w-[232px]"}`,children:[(0,ot.jsx)("p",{className:"tw-ml-[10px] tw-text-[12px] tw-font-[500] tw-leading-[12px] tw-text-[#718096]",children:"Liq. Price"}),(0,ot.jsx)(Ho,{value:B,ref:G,onChange:ft=>{I(_.FuturesLiquidationInputClick),it(ft)}})]}),(0,ot.jsx)(qt,{type:"button",onClick:()=>wt(!1),className:"tw-h-[40px] tw-w-[40px] tw-cursor-pointer tw-rounded-[4px] tw-bg-[#1A202C] tw-text-center tw-text-[24px] tw-text-[#D2B265]",children:"-"}),(0,ot.jsx)(qt,{type:"button",onClick:()=>wt(!0),className:"tw-h-[40px] tw-w-[40px] tw-cursor-pointer tw-rounded-[4px] tw-bg-[#1A202C] tw-text-center tw-text-[24px] tw-text-[#D2B265]",children:"+"})]}),(0,ot.jsxs)("div",{className:"tw-h-5",children:[pt===2&&(0,ot.jsx)(Qn,{text:`Liq. Price can only be changed upto ${A(lt.maxLimitPrice||0,!0,L.limitPrecision)}`}),pt===1&&(0,ot.jsx)(Qn,{text:`Need ${S.roundDown(Math.abs(Mt)-Number(Xt),2)} ${c&&T?"INR":"USDT"} more`}),U&&pt===3&&(0,ot.jsx)(Qn,{text:"Enter Liq. Price greater than 0"})]})]}),(0,ot.jsxs)("div",{className:"tw-mt-[20px] tw-border-t tw-border-[#2D3748] tw-pt-[16px]",children:[(0,ot.jsx)(Js,{label:"Liq. Price Change",initial:A(Lt.initLiqPrice,!0,L.limitPrecision),final:A(Lt.finalLiqPrice,!0,L.limitPrecision),percentage:Lt.finalLiqPriceChange}),(0,ot.jsx)(Js,{label:"Margin Change",initial:b(Lt.initMargin,!0,2),final:b(Lt.finalMargin,!0,2),percentage:Lt.finalMarginChange}),(0,ot.jsx)(Js,{label:"Liq. Risk",initial:(Lt==null?void 0:Lt.initLiqRisk)<0?"--":`${is(Lt==null?void 0:Lt.initLiqRisk,2)}%`,final:null,percentage:(Lt==null?void 0:Lt.finalLiqRisk)<0?"--":`${is(Lt==null?void 0:Lt.finalLiqRisk,2)}`})]}),(0,ot.jsx)("div",{className:"tw-mt-4 tw-flex tw-items-center tw-gap-x-4",children:_t==="ADD_MARGIN"||_t==="REMOVE_MARGIN"?(0,ot.jsx)(qt,{type:"button",disabled:D||bt===0,className:"tw-h-10 tw-w-full tw-text-center tw-text-base tw-font-[700] disabled:tw-cursor-not-allowed disabled:tw-bg-gold-1000",onClick:Ft,children:_t==="REMOVE_MARGIN"?"Remove Margin":"Add Margin"}):_t==="INC_LIQ_PRICE"||_t==="DEC_LIQ_PRICE"?(0,ot.jsx)(qt,{type:"button",disabled:D||bt===0||Number(B)===0||B==="",className:"tw-h-10 tw-w-full tw-text-center tw-text-base tw-font-[700] disabled:tw-cursor-not-allowed disabled:tw-bg-gold-1000",onClick:Ft,children:_t==="INC_LIQ_PRICE"?"Increase Liq. Price":"Decrease Liq. Price"}):_t==="USE_MAX_REMOVABLE"?(0,ot.jsx)(qt,{type:"button",variant:"outline",disabled:D||bt===0,className:"tw-h-10 tw-w-full tw-text-base tw-font-[700]",onClick:Nt,children:"Use Max Removable"}):_t==="USE_AVAILBALE"?(0,ot.jsxs)(ot.Fragment,{children:[!R&&(0,ot.jsxs)(qt,{type:"button",disabled:D||bt===0,className:"tw-h-10 tw-w-1/2 tw-text-base tw-font-[700]",onClick:()=>{c?(e(!1),I(_.FuturesQuickBuyAddInrClicked,{upi_enabled:ut==null?void 0:ut.is_upi_enabled,user_uuid:ut.user_uuid}),Hr()?(I(_.FuturesQuickBuyAddInrClicked,{redirection_source:"Pro",upi_enabled:ut==null?void 0:ut.is_upi_enabled,user_uuid:ut.user_uuid},!0),u==null||u(!0)):(I(_.ProDepositCTAClicked,{Page:Ti.futuresOrderpad}),xt(!0))):(I(_.FuturesMarginQuickBuyClick),l==null||l(!0),e(!1))},children:["Quick Buy ",c?"INR":"USDT"]}),(0,ot.jsx)(qt,{type:"button",variant:"outline",disabled:D||bt===0,className:`tw-h-10 ${R?"tw-w-full":"tw-w-1/2"} tw-text-base tw-font-[700]`,onClick:()=>{I(_.FuturesMarginQuickBuyClick),oe()},children:"Use Available"})]}):(0,ot.jsx)(qt,{type:"button",disabled:D||bt===0,className:"tw-h-10 tw-w-full tw-text-center tw-text-base tw-font-[700] disabled:tw-cursor-not-allowed disabled:tw-bg-gold-1000",onClick:Ft,children:"Add Margin"})})]});return d?(0,ot.jsxs)(ot.Fragment,{children:[At&&(0,ot.jsx)(os,{onClose:()=>xt(!1)}),Jt]}):(0,ot.jsxs)(ot.Fragment,{children:[At&&(0,ot.jsx)(os,{onClose:()=>xt(!1)}),(0,ot.jsxs)(Zs,{isOpen:t,setIsOpen:e,children:[(0,ot.jsxs)("div",{className:"tw-flex tw-justify-between",children:[(0,ot.jsx)("p",{className:"tw-text-[16
4px] tw-font-[500] tw-leading-[24px] tw-text-[#EDF2F7]",children:"Adjust Position"}),(0,ot.jsx)("div",{className:"tw-flex tw-justify-end",onClick:()=>{I(_.FuturesCrossClicked)},children:(0,ot.jsx)("img",{className:"tw-cursor-pointer",src:zn,alt:"Close",width:20,height:20,onClick:()=>e(!1)})})]}),Jt]})]})},Rl=(0,Dt.memo)(Pu);Zr();var Kn=N(Qt());var Ou=300;function Fl({baseCurrency:t,quoteCurrency:e,exchange:r,isLong:n,leverage:s,enabled:o=!0}){let[i,a]=(0,Kn.useState)(null),[l,p]=(0,Kn.useState)(s);(0,Kn.useEffect)(()=>{if(l===void 0){p(s);return}if(s===l)return;let g=setTimeout(()=>p(s),Ou);return()=>clearTimeout(g)},[s,l]);let f=n?"SELL":"BUY";return(0,Kn.useEffect)(()=>{if(!o||!t||!e)return;let g=!1;if(typeof yo=="function")return yo({exchange:r,orderType:"MARKET",side:f,base_currency:t==null?void 0:t.toLowerCase(),quote_currency:e==null?void 0:e.toLowerCase(),...l!==void 0?{leverage:l}:{}}).then(u=>{var w,b;if(g||!(u!=null&&u.success))return;let d=Number((w=u==null?void 0:u.data)==null?void 0:w.net_taker_fee)||0,c=Number((b=u==null?void 0:u.data)==null?void 0:b.taker_fee)||0,m=d>0?d:c;a(m>0&&Number.isFinite(m)?m:null)}).catch(()=>{}),()=>{g=!0}},[o,t,e,r,f,l]),i}go();var Mu=["EXPERT_PICKS","BOLT","ZING"];function to(t){return typeof t!="string"?!1:Mu.includes(t.trim().toUpperCase())}Oe();Ne();Ne();Oe();var ur=N(Qt());ho();Gr();he();pr();var _n=N(Y());function Qo({cap:t,message:e,leftPct:r,onDismiss:n}){return(0,_n.jsxs)("div",{"data-testid":"leverage-lock-popover",role:"status",className:"tw-absolute tw-z-20 tw-w-[276px] tw-rounded-lg tw-bg-white tw-p-3 tw-shadow-[0_4px_16px_rgba(0,0,0,0.35)]",style:{top:28,left:`calc(${r}% - 138px)`},children:[(0,_n.jsx)("div",{"aria-hidden":"true",className:"tw-absolute tw-h-[11px] tw-w-[11px] tw-rotate-45 tw-bg-white",style:{top:-5,left:132}}),(0,_n.jsxs)("div",{className:"tw-flex tw-items-start tw-justify-between tw-gap-x-2",children:[(0,_n.jsx)("p",{className:"tw-text-[13px] tw-font-[600] tw-leading-[18px] tw-text-[#121319]",children:`Leverage locked at ${t}x`}),(0,_n.jsx)("button",{type:"button","data-testid":"leverage-lock-popover-close","aria-label":"Dismiss",onClick:n,className:"tw-shrink-0 tw-text-[14px] tw-leading-none tw-text-[#4A5568]",children:"\u2715"})]}),(0,_n.jsx)("p",{className:"tw-mt-1 tw-text-[12px] tw-font-normal tw-leading-[18px] tw-text-[#4A5568]",children:e})]})}var kl=!1;function Dl(){return kl?!1:(kl=!0,!0)}var Ul={mweb:{addFundsOnly:!1,addFundsVariant:"filled",shortfallInline:!1,inlineCapCaption:!0,tightMetricRowGap:!1},desktop:{addFundsOnly:!0,addFundsVariant:"outlined",shortfallInline:!0,inlineCapCaption:!1,tightMetricRowGap:!0}};var Ko=1.01,Ru=1.5,Fu=(t,e)=>e?Ko*t/e:0,Bl=({isLong:t,entryPrice:e,qty:r,leverage:n,mmrPercent:s,mmDeduction:o})=>{if(!n||!r)return 0;let i=s/100+1,l=(Ko*r*e/n+o)/r;return t?i*e-l:(e+l)/i},Wo=({isLong:t,qty:e,entryPrice:r,leverage:n,mmrPercent:s,mmDeduction:o,clientTakerFee:i,cumCtc:a})=>{if(!n||!e)return 0;let l=Fu(e*r,n),p=Number.isFinite(i)?i:0,f=Number.isFinite(a)?a:0,g=e*Bl({isLong:t,entryPrice:r,qty:e,leverage:n,mmrPercent:s,mmDeduction:o})*p,u=Math.max(0,Number.isFinite(g)?g:0,f);return l+u},ku=({isLong:t,margin:e,qty:r,entryPrice:n,ltp:s,requestedLeverage:o,mmrPercent:i,mmDeduction:a,takerFeePercent:l,clientTakerFee:p,cumCtc:f})=>{if(!o||!r)return 0;let g=t?1:-1,u=r*(s-n)*g,d=i/100,c=t?n:Bl({isLong:t,entryPrice:n,qty:r,leverage:o,mmrPercent:i,mmDeduction:a}),m=r*c*Ru*d,w=Ko*r*n/o,b=Wo({isLong:t,qty:r,entryPrice:n,leverage:o,mmrPercent:i,mmDeduction:a,clientTakerFee:p,cumCtc:f}),A=e+u-m,x=e-b;return Math.max(0,Math.min(A,x))},ql=({isLong:t,margin:e,qty:r,entryPrice:n,ltp:s,currentLeverage:o,requestedLeverage:i,mmrPercent:a,mmDeduction:l,takerFeePercent:p,clientTakerFee:f,cumCtc:g})=>{if(!o||!i||!r||i===o)return 0;let u=r*n,d=Wo({isLong:t,qty:r,entryPrice:n,leverage:i,mmrPercent:a,mmDeduction:l,clientTakerFee:f,cumCtc:g}),c=()=>ku({isLong:t,margin:e,qty:r,entryPrice:n,ltp:s,requestedLeverage:i,mmrPercent:a,mmDeduction:l,takerFeePercent:p,clientTakerFee:f,cumCtc:g}),m=b=>{let A=Math.max(0,Math.min(b,c()));return A===0?0:-A};if(i<o){let b=d-e;return b>=0?b:m(-b)}let w=e-d;return m(w)},jo=({isLong:t,entryPrice:e,markPrice:r,liqPrice:n})=>{let s=t?e-n:n-e;return s?(t?e-r:r-e)/s*100:0}
4,Vl=({isLong:t,newLiqPrice:e,protectionPrice:r})=>r==null||!Number.isFinite(r)||r<=0?"none":e===r?"at":(t?e>r:e<r)?"crossed":"none",$l=(t,e)=>t&&e>=.8,Yl=(t,e)=>{if(!t||t.length===0)return null;let r=t.filter(o=>o.riskLimitValue>=e);if(r.length===0)return null;let n=r.reduce((o,i)=>i.riskLimitValue<o.riskLimitValue?i:o),s=Number(n.maxLeverage);return Number.isFinite(s)&&s>0?s:null},Gl=({notional:t,currentMargin:e,currentLeverage:r,requestedLeverage:n,availableBalance:s,isLong:o,qty:i,entryPrice:a,mmrPercent:l,mmDeduction:p,clientTakerFee:f,cumCtc:g})=>{let u=n<=r?1:-1;for(let d=n;u>0?d<=r:d>=r;d+=u){if(!d)continue;if((d===r?0:d<r?Wo({isLong:o,qty:i,entryPrice:a,leverage:d,mmrPercent:l,mmDeduction:p,clientTakerFee:f,cumCtc:g})-e:0)<=s)return d}return null};var Hl=(t,e)=>t?"position":"legacy",zl=({base_currency:t,quote_currency:e,side:r,leverage:n,exchange:s})=>({base_currency:t,quote_currency:e,side:r,leverage:n,margin:0,avg_price:0,size:0,exchange:s}),Z0=t=>t==="legacy"?"openLegacy":"openSheet",Ql=t=>t!=null&&to(t.tag),Kl=(t,e)=>{var l,p;let r=(l=e==null?void 0:e.base_currency)==null?void 0:l.toUpperCase(),n=(p=e==null?void 0:e.quote_currency)==null?void 0:p.toUpperCase(),s=(t!=null?t:[]).find(f=>{var m,w;let g=f,u=((m=g==null?void 0:g.base_currency)==null?void 0:m.toUpperCase())===r&&((w=g==null?void 0:g.quote_currency)==null?void 0:w.toUpperCase())===n,d=!!(g!=null&&g.reduce_only),c=g==null?void 0:g.user_order_type;return u&&d&&(c==="STOP_MARKET"||c==="STOP_LIMIT")});if(!s)return null;let o=s,i=(o==null?void 0:o.user_order_type)==="STOP_LIMIT",a=Number(i?o==null?void 0:o.limit_price:o==null?void 0:o.stop_price);return Number.isFinite(a)&&a>0?a:null},Wl=(t,e)=>{let r=e>as?2*e/5:as,n=e>as?3*e/5:as;return t>n?"#F14366":t>r?"#B8984C":"#0A8E5A"},ws=.3,jl=({value:t,cap:e,sliderMax:r})=>{let n=Math.max(r-1,1),s=a=>Math.min(Math.max(a,0),1);if(e>=r)return s((t-1)/n);let o=1-ws,i=Math.max(r-e,1);return e<=1?t<=1?0:s(o+ws*((t-e)/i)):t<=e?s(o*((t-1)/(e-1))):s(o+ws*((t-e)/i))};var rt=N(Y()),Du="You can't increase leverage above 80% liquidation risk. Decrease leverage to continue.",Uu=(t,e,r)=>`Your new liquidation price (${e}) ${t==="crossed"?"has crossed":"is at"} your Stop Loss (${r}). Modify it to stay protected.`,Bu=()=>(0,rt.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,rt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 2.66667C5.05448 2.66667 2.66667 5.05448 2.66667 8C2.66667 10.9455 5.05448 13.3333 8 13.3333C10.9455 13.3333 13.3333 10.9455 13.3333 8C13.3333 5.05448 10.9455 2.66667 8 2.66667ZM1.33333 8C1.33333 4.3181 4.3181 1.33333 8 1.33333C11.6819 1.33333 14.6667 4.3181 14.6667 8C14.6667 11.6819 11.6819 14.6667 8 14.6667C4.3181 14.6667 1.33333 11.6819 1.33333 8Z",fill:"#ED4B68"}),(0,rt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 7.33333C8.36819 7.33333 8.66667 7.63181 8.66667 8V10.4C8.66667 10.7682 8.36819 11.0667 8 11.0667C7.63181 11.0667 7.33333 10.7682 7.33333 10.4V8C7.33333 7.63181 7.63181 7.33333 8 7.33333Z",fill:"#ED4B68"}),(0,rt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.33333 5.6C7.33333 5.23181 7.63181 4.93333 8 4.93333H8.006C8.37419 4.93333 8.67267 5.23181 8.67267 5.6C8.67267 5.96819 8.37419 6.26667 8.006 6.26667H8C7.63181 6.26667 7.33333 5.96819 7.33333 5.6Z",fill:"#ED4B68"})]}),Xl=({role:t,children:e})=>(0,rt.jsxs)("div",{role:t,className:"tw-mt-3 tw-flex tw-items-start tw-gap-2 tw-rounded-lg tw-bg-gray-900 tw-p-2",children:[(0,rt.jsx)("span",{className:"tw-flex tw-shrink-0 tw-pt-px",children:(0,rt.jsx)(Bu,{})}),(0,rt.jsx)("p",{className:"tw-min-w-0 tw-flex-1 tw-text-xs tw-font-normal tw-leading-4 tw-tracking-[0.24px] tw-text-pro-red-600",children:e})]}),Zl="url(data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%276%27%20height%3D%276%27%3E%3Crect%20width%3D%272%27%20height%3D%276%27%20rx%3D%271%27%20fill%3D%27%23B3C9F8%27%20fill-opacity%3D%270.25%27%2F%3E%3C%2Fsvg%3E)",Rr=(t,e,r,n)=>{let s=!!e&&Number.isFinite(r)&&(r!=null?r:0)>0,o=s?t*r:t,i=n!=null&&n.truncate?Vt.roundDown(Math.round(o*1e8)/1e8,2):o;return s?Vt.inrCurrency(i,2):`${Vt.usdtFormat(i,2)} USDT`},Wn=(t,e,r,n)=>r&&Number.isFinite(n)&&(n!=null?n:0)>0?Vt.inrCurrency(t*n,e):Vt.usdtFormat(t,e),Xo=({label:t,before:e,after:r,dottedLabel:n=!1,afterClassName:s,layout:o="wide"})=>{let i=o==="compact";return(0,rt.jsxs)("div",{className:"tw-contents",children:[(0,rt.jsx)("p",{className:`tw-whitespace-nowrap tw-font-[400] tw-text-[#718096] ${i?"tw-min-w-[110px] tw-flex-none tw-text-[11px] tw-leading-4":"tw-text-[12px] tw-leading-[20px]"}
4 ${n?"tw-underline tw-decoration-dotted tw-underline-offset-2":""}`,children:t}),(0,rt.jsxs)("div",{className:`tw-contents ${i?"tw-flex tw-items-center tw-gap-2":"tw-flex tw-min-w-[260px] tw-items-center tw-justify-between md:tw-min-w-[210px]"}`,children:[(0,rt.jsx)("p",{className:`tw-whitespace-nowrap tw-text-left tw-font-[400] tw-text-[#A0AEC0] ${i?"tw-min-w-[62px] tw-text-[12px] tw-leading-4":"tw-min-w-[90px] tw-text-[12px] tw-leading-[20px]"}`,children:e}),(0,rt.jsx)("span",{className:"tw-flex tw-items-center tw-justify-center",children:(0,rt.jsx)("img",{src:mr("/pro/assets/images/futures/Arrow.svg"),alt:"arrow"})}),(0,rt.jsx)("div",{className:i?"tw-min-w-[62px]":"tw-min-w-[100px]",children:(0,rt.jsx)("p",{className:`tw-whitespace-nowrap tw-text-right tw-font-[400] ${i?"tw-text-[12px] tw-leading-4":"tw-text-[12px] tw-leading-[20px]"} ${s!=null?s:"tw-text-[#A0AEC0]"}`,children:r})})]})]})},qu=({position:t,precision:e,onRequestedLeverageChange:r,mmrTiers:n,assetMmr:s,exchangeTakerFee:o,clientTakerFee:i,onConfirmAnalytics:a,tierCapLeverage:l,assetMaxLeverage:p,availableBalance:f,inrBalance:g,isMarginModeInr:u,isInr:d,isPriceModeInr:c,usdtRate:m,protectionPrice:w=null,symbolLastPrice:b,markPrice:A,initialLeverage:x,onConfirm:T,onClose:R,pending:S=!1,setTopupOpen:E,metricRowLayout:Q="wide",surface:L="mweb"})=>{var Je,tr;let D=Ul[L],q=Number(t==null?void 0:t.leverage)||1,K=Number(t==null?void 0:t.margin)||0,dt=Number(t==null?void 0:t.size)||0,M=Number(t==null?void 0:t.avg_price)||0,Ct=dt*M,O=(t==null?void 0:t.side)==="LONG"||(t==null?void 0:t.side)==="BUY",ht=Number(t==null?void 0:t.cumulative_cost_to_close)||0,B=(Number(b)||0)>0?Number(b):(Number(t==null?void 0:t.last_price)||0)>0?Number(t==null?void 0:t.last_price):M,at=(Number(A)||0)>0?Number(A):B,h=Math.max(p,1),y=Math.min(l,h),P=y<h,G=P?(1-ws)*100:100,[U,H]=(0,ur.useState)(x!=null?x:q);(0,ur.useEffect)(()=>{r==null||r(U)},[U,r]);let[vt,X]=(0,ur.useState)(!1),At=(0,ur.useRef)(!1);(0,ur.useEffect)(()=>{!P||At.current||(At.current=!0,Dl()&&X(!0))},[P]);let xt=It=>Math.min(Math.max(Math.round(It),1),y||q);(0,ur.useEffect)(()=>{!y||y<=0||H(It=>It>y?y:It)},[y]);let ut=(0,ur.useMemo)(()=>{var It;return!P||!n?null:(It=n.find(Se=>Se.maxLeverage===l&&Se.riskLimitValue>=Ct))!=null?It:null},[P,n,l,Ct]),F=P?`Leverage locked at ${y}x \u2014 Max at a ${Rr((Je=ut==null?void 0:ut.riskLimitValue)!=null?Je:Ct,u,m)} position size, reduce position size to unlock higher leverage.`:null,Z=`For your position size the max leverage is ${y}x. For higher leverage you have to reduce the position size.`,ct=(0,ur.useMemo)(()=>qs({totalNotionalUsdt:Ct,leverage:U,mmrTiers:n,assetMmr:s,exchangeTakerFee:o}),[Ct,U,n,s,o]),mt=(0,ur.useMemo)(()=>new $s(t,e,{mmr:ct.mmr,mmDeduction:ct.mmDeduction,takerFee:0}),[t,e,ct]),it=ql({isLong:O,margin:K,qty:dt,entryPrice:M,ltp:B,currentLeverage:q,requestedLeverage:U,mmrPercent:ct.mmr,mmDeduction:ct.mmDeduction,takerFeePercent:o,clientTakerFee:i,cumCtc:ht}),J=mt.getLiquidationPrice(it),wt=(tr=e==null?void 0:e.limit_precision)!=null?tr:2,lt=Wn(J.liquidationPrice,wt,c,m),bt=jo({isLong:O,entryPrice:M,markPrice:at,liqPrice:J.liquidationPrice}),Xt=U>q,Mt=$l(Xt,bt/100),Lt=Vl({isLong:O,newLiqPrice:J.liquidationPrice,protectionPrice:w}),Ft=d?g!=null?g:0:f,oe=d&&Number.isFinite(m)&&(m!=null?m:0)>0?Ft/m:Ft,Nt=it>0?it-oe:0,pt=Nt>0,_t=U>y,Jt=Mt||pt||_t||U===q||S,ft=()=>{var Se;
4I(_.FuturesUseAvailableClicked,{coin:(Se=t==null?void 0:t.base_currency)==null?void 0:Se.toUpperCase(),tab:"leverage",available_balance:oe});let It=Gl({notional:Ct,currentMargin:K,currentLeverage:q,requestedLeverage:U,availableBalance:oe,isLong:O,qty:dt,entryPrice:M,mmrPercent:ct.mmr,mmDeduction:ct.mmDeduction,clientTakerFee:i,cumCtc:ht});It!==null&&H(It)},v=It=>{H(Se=>xt(Se+It))},C=(0,ur.useRef)(null),nt=()=>((0,ur.useEffect)(()=>{var Se;let It=`${q}->${U}`;C.current!==It&&(C.current=It,I(_.FuturesAdjustLiquidationRiskWarningShown,{coin:(Se=t==null?void 0:t.base_currency)==null?void 0:Se.toUpperCase(),old_leverage:q,new_leverage:U}))},[]),null),yt=()=>{if(Jt)return;a==null||a({newLiqPrice:J.liquidationPrice,slCrossed:Lt!=="none"});let It=Math.min(U,y||U);T(It,it)},Zt=jl({value:U,cap:y,sliderMax:h})*100,ve=Wl(U,h),ie=[0,100/3,200/3,100].filter(It=>!P||It<=G),Ze=Wn(Number(t==null?void 0:t.liquidation_price)||0,wt,c,m),V=Rr(K,u,m),k=jo({isLong:O,entryPrice:M,markPrice:at,liqPrice:Number(t==null?void 0:t.liquidation_price)||0}),Ot=k<0?"--":`${k.toFixed(2)}%`,jt=bt<0?"--":`${bt.toFixed(2)}%`,Ee=void 0,fe=pt?(0,rt.jsxs)("span",{"data-testid":"use-available-label",role:"button",tabIndex:0,onClick:ft,onKeyDown:It=>{(It.key==="Enter"||It.key===" ")&&(It.preventDefault(),ft())},className:"tw-cursor-pointer tw-text-gold tw-underline",children:["Use Available:"," "]}):(0,rt.jsx)("span",{className:"tw-text-[rgba(207,222,252,0.58)]",children:"Available: "}),ye=(0,rt.jsx)("span",{className:"tw-text-[rgba(221,232,253,0.72)]",children:Rr(oe,u,m,{truncate:!0})});return(0,rt.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-col tw-gap-3",children:[(0,rt.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-col",children:[(0,rt.jsxs)("div",{"data-testid":"leverage-slider-card",className:`tw-flex tw-w-full tw-flex-col tw-items-center tw-gap-4 tw-rounded-lg tw-bg-[#1b1f2c] tw-px-3 tw-pb-2 tw-pt-4${pt?" tw-border tw-border-[#F14366]":""}`,children:[(0,rt.jsxs)("div",{className:"tw-flex tw-w-[128px] tw-items-center tw-justify-center tw-gap-x-0.5",children:[(0,rt.jsx)("button",{type:"button","aria-label":"Decrease leverage",onClick:()=>v(-1),disabled:U<=1,className:`tw-flex tw-h-6 tw-w-6 tw-flex-none tw-items-center tw-justify-center tw-rounded tw-bg-[rgba(179,201,248,0.13)]${U<=1?" tw-opacity-40":""}`,children:(0,rt.jsx)(et,{width:"tw-w-4",height:"tw-h-4",name:"futures-minus-gold"})}),(0,rt.jsxs)("p",{"data-testid":"requested-leverage",className:"tw-mx-0.5 tw-flex-1 tw-whitespace-nowrap tw-text-center tw-text-[16px] tw-font-semibold tw-leading-5 tw-tracking-[0.32px] tw-text-white",children:[U,"x"]}),(0,rt.jsx)("button",{type:"button","aria-label":"Increase leverage",onClick:()=>v(1),disabled:!!y&&U>=y,className:`tw-flex tw-h-6 tw-w-6 tw-flex-none tw-items-center tw-justify-center tw-rounded tw-bg-[rgba(179,201,248,0.13)]${y&&U>=y?" tw-opacity-40":""}`,children:(0,rt.jsx)(et,{width:"tw-w-4",height:"tw-h-4",name:"futures-plus-gold"})})]}),(0,rt.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-col tw-gap-1",children:[(0,rt.jsxs)("div",{className:"tw-relative tw-h-5 tw-w-full",children:[(0,rt.jsx)("div",{"data-testid":"leverage-slider-track",className:"tw-absolute tw-left-0 tw-top-1/2 tw-h-2 -tw-translate-y-1/2 tw-rounded-full tw-bg-[rgba(164,190,244,0.2)]",style:{width:P?`${G}%`:"100%"}}),(0,rt.jsx)("div",{"data-testid":"leverage-slider-fill",className:"tw-absolute tw-left-0 tw-top-1/2 tw-h-2 -tw-translate-y-1/2 tw-rounded-full",style:{width:`${Zt}%`,backgroundColor:ve}}),ie.map(It=>(0,rt.jsx)("div",{"aria-hidden":"true",className:"tw-pointer-events-none tw-absolute tw-top-1/2 tw-h-1 tw-w-1 -tw-translate-y-1/2 tw-rounded-full tw-bg-white/60",style:It>=100?{right:0}:{left:`${It}%`}},It)),P&&(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsx)("div",{"data-testid":"leverage-slider-locked-cap-dot","aria-hidden":"true",className:"tw-pointer-events-none tw-absolute tw-top-1/2 tw-h-1 tw-w-1 -tw-translate-y-1/2 tw-rounded-full tw-bg-[rgba(207,222,252,0.3)]",style:{left:`calc(${G}% - 6px)`}}),(0,rt.jsxs)("div",{"data-testid":"leverage-slider-locked-zone","aria-hidden":"true",className:"tw-pointer-events-none tw-absolute tw-inset-y-0 tw-right-0 tw-flex tw-items-center",style:{left:`${G}%`},children:[(0,rt.jsx)("span",{className:"tw-w-0.5 tw-flex-none"}),(0,rt.jsx)("span",{"data-testid":"leverage-slider-locked-dashes",className:"tw-h-1.5 tw-min-w-0 tw-flex-1",style:{backgroundImage:Zl,backgroundRepeat:"repeat-x"}}),(0,rt.jsx)("span",{className:"tw-w-1 tw-flex-none"}),(0,rt.jsx)(et,{"data-testid":"leverage-slider-locked-padlock",name:"leverage-locked-padlock",width:"tw-w-2.5",height:"tw-h-3",className:"tw-flex-none"}),(0,rt.jsx)("span",{className:"tw-w-1 tw-flex-none"}),(0,rt.jsx)("span",{"data-testid":"leverage-slider-locked-dashes",className:"tw-h-1.5 tw-min-w-0 tw-flex-1",style:{backgroundImage:Zl,backgroundRepeat:"repeat-x"}}),(0,rt.jsx)("span",{className:"tw-w-0.5 tw-flex-none"}),(0,rt.jsx)("span",{"data-testid":"leverage-slider-locked-end-dot",className:"tw-h-1 tw-w-1 tw-flex-none tw-rounded-full tw-bg-[rgba(207,222,252,0.3)]"})]})]}),vt&&(0,rt.jsx)(Qo,{cap:y,message:Z,leftPct:G,onDismiss:()=>X(!1)}),(0,rt.jsx)("div",{"aria-hidden":"true",className:"tw-pointer-events-none tw-absolute tw-top-1/2 tw-h-4 tw-w-4 -tw-translate-y-1/2 tw-rounded-full tw-bg-white tw-shadow-[0_1px_2px_rgba(0,0,0,0.35)]",style:{left:`calc(${Zt}% - 8px)`}}),(0,rt.jsx)("input",{type:"range","aria-label":"Leverage slider",min:1,max:P?y:h,value:U,onChange:It=>H(xt(Number(It.target.value))),style:{width:`${G}%`},className:"tw-absolute tw-bottom-0 tw-left-0 tw-top-0 tw-z-10 tw-h-full tw-cursor-pointer tw-appearance-none tw-bg-transparent [&::-moz-range-thumb]:tw-h-4 [&::-moz-range-thumb]:tw-w-4 [&::-moz-range-thumb]:tw-appearance-none [&::-moz-range-thumb]:tw-border-0 [&::-moz-range-thumb]:tw-bg-transparent [&::-moz-range-track]:tw-bg-transparent [&::-webkit-slider-runnable-track]:tw-bg-transparent [&::-webkit-slider-thumb]:tw-h-4 [&::-webkit-slider-thumb]:tw-w-4 [&::-webkit-slider-thumb]:tw-appearance-none [&::-webkit-slider-thumb]:tw-bg-transparent"})]}),(0,rt.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between tw-text-[12px] tw-font-normal tw-leading-4 tw-tracking-[0.24px] tw-text-[rgba(207,222,252,0.58)]",children:[(0,rt.jsx)("span",{children:"1x"}),(0,rt.jsxs)("span",{children:[h,"x"]})]})]})]}),D.inlineCapCaption&&F&&(0,rt.jsx)("p",{className:"tw-mt-3 tw-text-xs tw-text-gray-500",children:F}),Mt&&(0,rt.jsx)(nt,{}),Mt&&(0,rt.jsx)(Xl,{role:"alert",children:Du}),!Mt&&Lt!=="none"&&(0,rt.jsx)(Xl,{role:"status",children:Uu(Lt,lt,Wn(w!=null?w:0,wt,c,m))}),(0,rt.jsxs)("div",{className:`tw-mt-3 tw-text-[11px] tw-font-normal tw-leading-4 tw-tracking-[0.22px]${D.shortfallInline?" tw-flex tw-items-center tw-justify-between":""}`,children:[D.shortfallInline?(0,rt.jsxs)("span",{children:[fe,ye]}):(0,rt.jsxs)(rt.Fragment,{children:[fe,ye]}),D.shortfallInline&&pt&&(0,rt.jsxs)("span",{className:"tw-text-[#F14366]",children:["Need ",Rr(Nt,u,m)," more"]})]}),(0,rt.jsx)("div",{className:"tw-mt-4 tw-h-px tw-w-full tw-bg-[rgba(164,190,244,0.2)]"}
4),(0,rt.jsxs)("div",{className:`tw-mt-4 tw-grid tw-grid-cols-[auto_auto_1fr_auto] tw-items-center tw-gap-x-4 ${D.tightMetricRowGap?"tw-gap-y-1":"tw-gap-y-2"}`,children:[(0,rt.jsx)(Xo,{label:"Liq. Price Change",before:Ze,after:lt,layout:Q}),(0,rt.jsx)(Xo,{label:"Margin Change",before:V,after:Rr(Math.max(K+it,0),u,m),layout:Q}),(0,rt.jsx)(Xo,{label:"Liq. Risk",before:Ot,after:jt,afterClassName:Ee,layout:Q})]})]}),pt&&!D.shortfallInline&&(0,rt.jsxs)("p",{"data-testid":"shortfall-standalone",className:"tw-text-xs tw-text-[#F14366]",children:["Need ",Rr(Nt,u,m)," more"]}),(0,rt.jsx)("div",{className:"tw-flex tw-items-center tw-gap-x-2",children:pt?D.addFundsOnly?(0,rt.jsx)(qt,{type:"button",variant:D.addFundsVariant==="outlined"?qt.Variants.Outlined:qt.Variants.Default,className:"tw-h-10 tw-w-full tw-text-base tw-font-[700]",onClick:E?()=>E(!0):R,children:`Add funds ${Rr(Nt,u,m)}`}):(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsx)(qt,{type:"button",variant:qt.Variants.Outlined,className:"tw-h-10 tw-w-1/2 tw-text-base tw-font-[700]",onClick:ft,children:"Use Available"}),(0,rt.jsx)(qt,{type:"button",className:"tw-h-10 tw-w-1/2 tw-text-base tw-font-[700]",onClick:E?()=>E(!0):R,children:`Add funds ${Rr(Nt,u,m)}`})]}):(0,rt.jsx)(qt,{type:"button",disabled:Jt,className:"tw-h-10 tw-w-full tw-text-center tw-text-base tw-font-[700]",onClick:yt,children:S?"Confirming...":`Confirm ${U}x leverage`})})]})},Jl=qu;var ec=N(gs());var tc=N(Qt());ho();he();var Kt=N(Y()),Zo=2,Vu=t=>t.toLowerCase().split("_").map(e=>e&&e[0].toUpperCase()+e.slice(1)).join(" "),$u=t=>{var f,g,u,d,c;let e=t,r=((f=e==null?void 0:e.base_currency)!=null?f:"").toUpperCase(),n=String((g=e==null?void 0:e.side)!=null?g:"").toUpperCase(),s=n==="BUY"||n==="LONG",o=Number(e==null?void 0:e.leverage),i=Number.isFinite(o)&&o>0?`${o}x`:null,a=String((u=e==null?void 0:e.user_order_type)!=null?u:""),l=(c=(d=e==null?void 0:e.qty)==null?void 0:d.value)!=null?c:"",p=Number(e==null?void 0:e.limit_price)||0;
4return{baseSymbol:r,isLong:s,leverageText:i,orderType:a,qty:l,priceValue:p}},Yu=()=>(0,Kt.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true",className:"tw-flex-none",children:[(0,Kt.jsx)("path",{d:"M9 18C13.9706 18 18 13.9706 18 9C18 4.02944 13.9706 0 9 0C4.02944 0 0 4.02944 0 9C0 13.9706 4.02944 18 9 18Z",fill:"#CAA349"}),(0,Kt.jsx)("path",{d:"M9 13.5C8.84467 13.5 8.71875 13.3741 8.71875 13.2188C8.71875 13.0634 8.84467 12.9375 9 12.9375",stroke:"#292211",strokeWidth:"1.5"}),(0,Kt.jsx)("path",{d:"M9 13.5C9.15533 13.5 9.28125 13.3741 9.28125 13.2188C9.28125 13.0634 9.15533 12.9375 9 12.9375",stroke:"#292211",strokeWidth:"1.5"}),(0,Kt.jsx)("path",{d:"M9 10L9 5",stroke:"#292211",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round"})]}),Gu=({orders:t,pending:e=!1,onKeepCurrentLeverage:r,onCancelAndProceed:n,symbolLastPrice:s=0,usdtRate:o,isPriceModeInr:i,precision:a})=>{var w;let[l,p]=(0,tc.useState)(!1),f=t.length>Zo,g=l?t:t.slice(0,Zo),u=t.length-Zo,d=t.length===1?"1 open order will be cancelled":`${t.length} open orders will be cancelled`,c=(w=a==null?void 0:a.limit_precision)!=null?w:2,m=Wn(s,c,i,o);return(0,Kt.jsxs)(Kt.Fragment,{children:[(0,Kt.jsxs)("div",{"data-testid":"cancel-open-orders-warning-card",className:"tw-mt-3 tw-flex tw-items-start tw-gap-x-2 tw-rounded-lg tw-border tw-border-[#685422] tw-bg-[#1C170D] tw-p-3",children:[(0,Kt.jsx)(Yu,{}),(0,Kt.jsxs)("div",{children:[(0,Kt.jsx)("p",{className:"tw-text-[14px] tw-font-[600] tw-leading-5 tw-text-[#EDF2F7]",children:d}),(0,Kt.jsx)("p",{className:"tw-mt-1 tw-text-xs tw-text-[#718096]",children:"Leverage change isn't allowed while these orders are open."})]})]}),(0,Kt.jsxs)("div",{className:`tw-mt-3 tw-flex tw-flex-col tw-gap-2 ${l?"tw-max-h-[40vh] tw-overflow-y-auto":""}`,children:[g.map(b=>{let{baseSymbol:A,isLong:x,leverageText:T,orderType:R,qty:S,priceValue:E}=$u(b),Q=b==null?void 0:b.order_id;return(0,Kt.jsxs)("div",{"data-testid":"cancel-open-orders-row",className:"tw-flex tw-flex-col tw-gap-1 tw-rounded tw-bg-[#1A202C] tw-px-3 tw-py-2",children:[(0,Kt.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,Kt.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-x-1.5",children:[(0,Kt.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-white",children:A}),(0,Kt.jsx)("span",{className:`tw-text-[12px] tw-font-medium ${x?"tw-text-[#4CAF50]":"tw-text-[#F14366]"}`,children:x?"Long":"Short"}),T&&(0,Kt.jsx)("span",{className:"tw-text-[12px] tw-text-white",children:T})]}),(0,Kt.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-white",children:Wn(E,c,i,o)})]}),(0,Kt.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between tw-text-[12px] tw-text-[#718096]",children:[(0,Kt.jsx)("span",{children:[R&&Vu(R),S&&`${S} ${A}`].filter(Boolean).join(" \xB7 ")}),(0,Kt.jsx)("span",{children:`LTP: ${m}`})]})]},Q)}),f&&(0,Kt.jsxs)("button",{type:"button","data-testid":"cancel-open-orders-more",onClick:()=>p(b=>!b),className:"tw-flex tw-items-center tw-justify-center tw-gap-x-1 tw-text-xs tw-font-[500] tw-text-gold-500",children:[l?"Show less":`+${u} more`,(0,Kt.jsx)(et,{name:"gold-chevron",width:"tw-w-2.5",height:"tw-h-2.5",className:l?"tw-rotate-180":""})]})]}),(0,Kt.jsx)("div",{className:"tw-mt-4 tw-h-px tw-w-full tw-bg-[rgba(164,190,244,0.2)]"}),(0,Kt.jsxs)("div",{className:"tw-mt-4 tw-flex tw-items-center tw-gap-x-2",children:[(0,Kt.jsx)("button",{type:"button",disabled:e,className:"tw-h-10 tw-w-1/2 tw-rounded-md tw-bg-[rgba(164,190,244,0.2)] tw-text-sm tw-font-[700] tw-text-white disabled:tw-opacity-50",onClick:r,children:"Keep current leverage"}),(0,Kt.jsxs)(qt,{type:"button",disabled:e,className:"tw-h-10 tw-w-1/2 tw-text-sm tw-font-[700]",onClick:n,children:[e&&(0,Kt.jsx)("span",{"data-testid":"cancel-proceed-loader",className:"tw-mr-2 tw-h-3 tw-w-3 tw-animate-spin tw-rounded-full tw-border-2 tw-border-black/30 tw-border-t-black"}),"Proceed"]})]})]})},eo=Gu;var ln=N(Y()),Hu=t=>{let{pending:e=!1,onKeepCurrentLeverage:r}=t;return(0,ec.createPortal)((0,ln.jsx)("div",{role:"dialog","aria-label":"Adjust Leverage","data-testid":"cancel-open-orders-portal",className:"tw-pointer-events-auto tw-fixed tw-inset-0 tw-z-50 tw-flex tw-items-end tw-justify-center tw-bg-black-01/70",children:(0,ln.jsxs)("div",{className:"tw-flex tw-w-full tw-max-w-[430px] tw-flex-col tw-rounded-t-2xl tw-bg-[#121319] tw-p-[16px]",children:[(0,ln.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,ln.jsx)("p",{className:"tw-text-[16
4px] tw-font-[500] tw-leading-[24px] tw-text-[#EDF2F7]",children:"Adjust Leverage"}),(0,ln.jsx)("img",{className:`tw-cursor-pointer ${e?"tw-pointer-events-none tw-opacity-50":""}`,src:zn,alt:"Close",width:20,height:20,"aria-disabled":e,onClick:e?void 0:r})]}),(0,ln.jsx)("div",{className:"tw-mt-3 tw-h-px tw-w-full tw-bg-[rgba(164,190,244,0.2)]"}),(0,ln.jsx)(eo,{...t})]})}),document.body)},rc=Hu;he();var Ke=N(Y()),zu=({position:t,isMarginModeInr:e,usdtRate:r,isPriceModeInr:n=!1,variant:s="position",symbolLastPrice:o})=>{var D,q;let i=s==="ordersOnly",a=(t==null?void 0:t.side)==="LONG"||(t==null?void 0:t.side)==="BUY",l=((D=t==null?void 0:t.base_currency)!=null?D:"").toUpperCase(),p=((q=t==null?void 0:t.quote_currency)!=null?q:"").toUpperCase(),f=p&&n?"INR":p,g=l&&f?`${l}/${f}`:l||f,u=Number(t==null?void 0:t.leverage)||0,d=(Number(t==null?void 0:t.size)||0)*(Number(t==null?void 0:t.avg_price)||0),c=t==null?void 0:t.margin,m=Number(o)||0,w=Number(t==null?void 0:t.size)||0,b=Number(t==null?void 0:t.avg_price)||0,A=m>0&&w>0&&b>0?w*(a?m-b:b-m):NaN,x=Number.isFinite(A)?A:Number(t==null?void 0:t.unrealized_pl),T=Number(typeof c=="object"&&c!==null?c.value:c)||0,R=Number.isFinite(x)&&T>0,S=x>0,E=x<0,Q=R?Math.abs(x)/T*100:0,L=R?`(${E?"-":"+"}${Q.toFixed(1)}%)`:null;return(0,Ke.jsxs)("div",{"data-testid":"current-position-card",className:"tw-flex tw-flex-col tw-gap-y-3",children:[(0,Ke.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-x-3",children:[(0,Ke.jsx)("div",{className:"tw-flex tw-h-6 tw-w-6 tw-flex-none tw-items-center tw-justify-center tw-rounded tw-bg-[#2C303F]",children:(0,Ke.jsx)(et,{name:"position-bar-chart-gold",width:"tw-w-5",height:"tw-h-5"})}),(0,Ke.jsxs)("div",{children:[(0,Ke.jsx)("p",{className:"tw-text-[16px] tw-font-[500] tw-leading-[24px] tw-text-[#EDF2F7]",children:"Current Position"}),(0,Ke.jsx)("p",{className:"tw-text-[12px] tw-leading-[16px] tw-text-[#718096]",children:"The leverage will change for your current position"})]})]}),(0,Ke.jsx)("div",{className:"tw-h-px tw-w-full tw-bg-[rgba(179,201,248,0.09)]"}),(0,Ke.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between",children:[(0,Ke.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-x-2",children:[(0,Ke.jsx)("span",{className:"tw-text-[14px] tw-font-[500] tw-text-[#EDF2F7]",children:g}),!i&&(0,Ke.jsx)("span",{className:`tw-text-[12px] tw-font-[500] ${a?"tw-text-[#4CAF50]":"tw-text-[#F14366]"}`,children:a?"Long":"Short"}),(0,Ke.jsxs)("span",{className:"tw-text-[12px] tw-text-[#718096]",children:[u,"x"]})]}),!i&&(0,Ke.jsxs)("span",{className:"tw-flex tw-items-center tw-gap-x-1",children:[(0,Ke.jsx)("span",{className:`tw-text-[14px] ${R?`tw-font-[500] ${S?"tw-text-[#0ABD70]":E?"tw-text-[#F14366]":"tw-text-gray-400"}`:"tw-text-[#EDF2F7]"}`,children:R?`${E?"-":""}${Rr(Math.abs(x),e,r)}`:Rr(d,e,r)}),L&&(0,Ke.jsx)("span",{className:`tw-text-[14px] tw-font-[500] ${S?"tw-text-[#0ABD70]":E?"tw-text-[#F14366]":"tw-text-gray-400"}`,children:L})]})]})]})},nc=zu;he();var Er=N(Y()),Qu=()=>(0,Er.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"tw-flex-none",children:[(0,Er.jsx)("rect",{width:"24",height:"24",rx:"4",fill:"#2C303F"}),(0,Er.jsx)("path",{d:"M17.0836 13.2508C17.5721 13.2509 17.9683 13.647 17.9683 14.1356C17.9682 14.6241 17.5721 15.0203 17.0836 15.0203H8.858L11.4459 17.6082C11.7911 17.9537 11.7911 18.5138 11.4459 18.8592C11.1004 19.2047 10.5395 19.2047 10.1939 18.8592L6.24667 14.912C5.63397 14.2988 6.06829 13.2509 6.93515 13.2508H17.0836ZM12.5553 5.14047C12.9008 4.79499 13.4607 4.79496 13.8062 5.14047L17.7535 9.08773C18.3664 9.70087 17.932 10.7489 17.065 10.7489H6.91757C6.42892 10.7489 6.0328 10.3527 6.0328 9.8641C6.03284 9.37548 6.42894 8.97933 6.91757 8.97933H15.1432L12.5553 6.39144C12.2097 6.04592 12.2097 5.48599 12.5553 5.14047Z",fill:"#CAA349"})]}),Ku=({onSwitchSubAccount:t,disabled:e=!1})=>(0,Er.jsxs)("div",{"data-testid":"switch-subaccount-card",className:"tw-flex tw-items-center tw-gap-x-3 tw-rounded-xl tw-border tw-border-[rgba(179,201,248,0.09)] tw-bg-[#11141c] tw-p-3",children:[(0,Er.jsx)(Qu,{}),(0,Er.jsxs)("div",{className:"tw-flex tw-flex-1 tw-flex-col tw-gap-y-0.5",children:[(0,Er.jsx)("p",{className:"tw-text-[12px] tw-font-semibold tw-leading-4 tw-tracking-[0.24px] tw-text-white",children:"Switch Sub Account"}),(0,Er.jsx)("p",{className:"tw-text-[10px] tw-font-normal tw-leading-3 tw-tracking-[0.2px] tw-text-[#718096]",children:"Switch to a new account to manage and hedge your positions."})]}),(0,Er.jsxs)("button",{type:"button",onClick:e?void 0:t,disabled:e,className:`tw-flex tw-flex-none tw-items-center tw-gap-x-1 tw-rounded tw-bg-[#2F3545] tw-px-3 tw-py-1.5 tw-text-[11px] tw-font-[600] tw-text-[#CDA954]${e?" tw-cursor-not-allowed tw-opacity-50":""}`,children:["Switch Now",(0,Er.jsx)(et,{name:"right-arrow-gold",width:"tw-w-2.5",height:"tw-h-2.5"})]})]}),sc=Ku;var Fr=N(Qt());es();vr();Oc();Ns();vs();Zr();go();var Wu=new Set(["TAKE_PROFIT_MARKET","STOP_MARKET"]),Jo=(t,e)=>{var s,o;
4let r=(s=e==null?void 0:e.base_currency)==null?void 0:s.toUpperCase(),n=(o=e==null?void 0:e.quote_currency)==null?void 0:o.toUpperCase();return(t!=null?t:[]).filter(i=>{var g,u;let a=i,l=((g=a==null?void 0:a.base_currency)==null?void 0:g.toUpperCase())===r&&((u=a==null?void 0:a.quote_currency)==null?void 0:u.toUpperCase())===n,p=!!(a!=null&&a.reduce_only),f=Wu.has(a==null?void 0:a.user_order_type);return l&&!p&&!f})},ro=(t,e)=>be({type:"failure",header:"Leverage Update Failed",content:`Failed to change leverage from ${t}x to ${e}x`}),oc=3,ju=300,Xu=t=>new Promise(e=>setTimeout(e,t)),Zu=5e3,Ju=500,no="futures:v2:orders-positions-changed",tw=()=>{let t=new Set,e=r=>{var s;let n=(s=r==null?void 0:r.detail)==null?void 0:s.order_id;typeof n=="string"&&n&&t.add(n)};return typeof window!="undefined"&&window.addEventListener(no,e),{confirmed:t,stop:()=>{typeof window!="undefined"&&window.removeEventListener(no,e)}}},ew=t=>new Promise(e=>{let r=!1,n=()=>{r||(r=!0,clearTimeout(s),typeof window!="undefined"&&window.removeEventListener(no,n),e())},s=setTimeout(n,t);typeof window!="undefined"&&window.addEventListener(no,n)}),rw=(t,e)=>new Promise(r=>{let n=!1,s=setTimeout(()=>{n||(n=!0,r({timedOut:!0}))},e);So({exchange:t}).then(o=>{n||(n=!0,clearTimeout(s),r({timedOut:!1,response:o}))},o=>{n||(n=!0,clearTimeout(s),r({timedOut:!1,error:o}))})}),nw=async(t,e,r,n)=>{var i,a,l;let s=Date.now()+Zu,o=()=>!r&&!!n&&e.size>0&&Array.from(e).every(p=>n.has(p));if(o())return"cleared";for(;;){let p=s-Date.now();if(p<=0)return"timeout";let f=await rw(t,p);if(f.timedOut)return"timeout";if(f.error)console.error("useAdjustLeverage: cancel-confirmation poll threw",f.error);else{let u=(i=f.response)==null?void 0:i.success,d=(l=(a=f.response)==null?void 0:a.data)==null?void 0:l.orders;if(u&&Array.isArray(d)){let c=new Set(d.map(w=>w==null?void 0:w.order_id).filter(Boolean));if(!Array.from(e).some(w=>c.has(w))&&!r)return"cleared"}}if(o())return"cleared";let g=s-Date.now();if(g<=0)return"timeout";if(await ew(Math.min(Ju,g)),o())return"cleared"}};var sw=t=>{if(!Number.isFinite(t)||t===0)return 0;let e=Math.abs(t)*1e4,r=t>0?Math.ceil(e-1e-6)/1e4:Math.floor(e+1e-6)/1e4;return r<=0?0:r};function ow(t,{openOrders:e,quoteCurrencyPrice:r=0,takerFee:n=0,onSuccess:s,onFailure:o,applyLeverage:i}={}){var R;let[a,l]=(0,Fr.useState)(!1),p=(0,Fr.useRef)(!1),f=(0,Fr.useRef)(null),g=bn(),u=Bt(Yr),d=(R=Bt(Ss))!=null?R:"",c=(t==null?void 0:t.exchange)||"BYBIT",m=["futures-open-orders-adjust-leverage",c,d],w=hs({queryKey:m,queryFn:async()=>{var L;let S=await So({exchange:c}),E=S==null?void 0:S.success,Q=(L=S==null?void 0:S.data)==null?void 0:L.orders;return!E||!Array.isArray(Q)?[]:Q},enabled:e===void 0}),b=(0,Fr.useCallback)(async()=>{e===void 0&&await g.invalidateQueries({queryKey:m})},[e,g,c,d]),A=(0,Fr.useMemo)(()=>{var S;return(S=e!=null?e:w.data)!=null?S:[]},[e,w.data]),x=(0,Fr.useMemo)(()=>Jo(A,t),[A,t]);return{confirm:(0,Fr.useCallback)(async(S,E)=>{var D,q;if(p.current)return;p.current=!0;let Q=Number(t==null?void 0:t.leverage)||1;l(!0);let L=null;try{f.current||(f.current=hi());let K=[],dt=0,M=!1;L=tw();for(let ht of x){let B=ht,at=!1;for(let y=1;y<=oc;y+=1){try{let P=await Ms({order_id:B==null?void 0:B.order_id,exchange:(B==null?void 0:B.exchange)||c,symbol:B==null?void 0:B.pair});if(P!=null&&P.success){at=!0;break}}catch(P){console.error("useAdjustLeverage: cancel attempt threw",P)}y<oc&&await Xu(ju)}if(!at){le(ro(Q,S)),await b(),o==null||o();return}dt+=1;let h=B==null?void 0:B.order_id;typeof h=="string"&&h?K.push(h):M=!0}if(dt>0&&await nw(c,new Set(K),M,L.confirmed)==="timeout"){le(ro(Q,S)),await b(),o==null||o();return}let Ct=E>=0?"ADD_MARGIN":"REMOVE_MARGIN",O=i?await i(S):await ta({payload:{leverage:Q,new_leverage:S,margin_type:Ct,margin:sw(E),exchange:c.toUpperCase(),base_currency:t.base_currency,quote_currency:t.quote_currency,client_txn_id:f.current,position_size:Number(t.size),avg_price:Number(t.avg_price),quote_currency_price:r,taker_fee:n,side:String((D=t==null?void 0:t.side)!=null?D:"").toUpperCase()==="SHORT"||String((q=t==null?void 0:t.side)!=null?q:"").toUpperCase()==="SELL"?"SHORT"
4:"LONG"}});O!=null&&O.success?(le(be({type:"success",header:"Leverage Updated Successfully",content:`Leverage changed from ${Q}x to ${S}x`})),await Promise.all([g.invalidateQueries({queryKey:["ALL_SUBACCOUNTS",u==null?void 0:u.user_uuid]}),g.invalidateQueries({queryKey:["ALL_SUBACCOUNTS_WITH_POSITION_DETAILS",u==null?void 0:u.user_uuid]}),g.invalidateQueries({queryKey:["futures-open-positions",c,d]}),g.invalidateQueries({queryKey:["futures-open-orders",c,d]}),g.invalidateQueries({queryKey:["futures-assets",u==null?void 0:u.user_uuid,d]})]),s==null||s(S,E)):(le(ro(Q,S)),await b(),o==null||o())}catch(K){console.error("useAdjustLeverage: confirm failed",K),le(ro(Q,S)),await b(),o==null||o()}finally{L==null||L.stop(),p.current=!1,l(!1)}},[i,x,c,d,s,o,t,r,n,g,b,u==null?void 0:u.user_uuid]),pending:a,blockingOrders:x,openOrders:A}}var ic=ow;var Wt=N(Y()),iw=10,aw=({position:t,initialTab:e,onClose:r,onConfirm:n,config:s,precision:o,walletUpdateCallback:i,ordersUpdateCallback:a,setIsQuickBuyOpen:l,walletBalance:p,inrBalance:f,setTopupOpen:g,isMobile:u=!0,mmrTiers:d,assetMmr:c,exchangeTakerFee:m,clientTakerFee:w,clientTakerFeeType:b,tierCapLeverage:A,assetMaxLeverage:x,availableBalance:T,isMarginModeInr:R,protectionPrice:S,symbolLastPrice:E,symbolMarkPrice:Q,mode:L="full",applyLeverage:D,onSwitchSubAccount:q,currentPositionCardVariant:K="position",openOrders:dt,surface:M="mweb",renderMarginTab:Ct,subHeaderLastPrice:O,showPositionContext:ht=!0,portalContainer:B})=>{var un,wn,dn,mn,pn,fn,_r,Rt,qr,hr,ir,gn,Wr,xr,ar,Ln;let at=to(t==null?void 0:t.tag),[h,y]=(0,We.useState)(at&&e===2?0:e),[P,G]=(0,We.useState)(!0),[U,H]=(0,We.useState)(null),[vt,X]=(0,We.useState)(!1),At=(0,We.useRef)(!1);At.current=U!==null||vt;let{getMmrTiersForContract:xt,contractConfig:ut,allPrecision:F}=ma({futuresAdditionalData:{}});Ji();let Z=Bt(Ei),{isMarginModeInr:ct,isPriceModeInr:mt,isInr:it,USDT_RATE:J,futuresInrUsdtConverter:wt}=ue(),lt=it&&mt,bt=R!=null?R:it&&ct,Xt=`${(un=t==null?void 0:t.base_currency)!=null?un:""}${(wn=t==null?void 0:t.quote_currency)!=null?wn:""}`.toUpperCase(),Mt=(Number(t==null?void 0:t.size)||0)*(Number(t==null?void 0:t.avg_price)||0),Lt=ua(t==null?void 0:t.base_currency,t==null?void 0:t.quote_currency),Ft=(ut==null?void 0:ut[Lt])||{},oe=Number(Ft==null?void 0:Ft.mmr)||0,Nt=Number(Ft==null?void 0:Ft.exchange_taker_fee)||0,pt=F==null?void 0:F[Lt],Jt=String((mn=(dn=t==null?void 0:t.exchange)!=null?dn:Ft==null?void 0:Ft.exchange)!=null?mn:"").toUpperCase()==="BINANCE",ft=c!=null?c:oe,v=m!=null?m:Nt,C=Number(Ft==null?void 0:Ft.taker_fee)||0,[nt,yt]=(0,We.useState)(()=>Number(t==null?void 0:t.leverage)||void 0),Zt=Fl({baseCurrency:t==null?void 0:t.base_currency,quoteCurrency:t==null?void 0:t.quote_currency,leverage:nt,exchange:String((pn=t==null?void 0:t.exchange)!=null?pn:"").toUpperCase()||void 0,isLong:String((fn=t==null?void 0:t.side)!=null?fn:"").toUpperCase()==="LONG"}),ve=b!=null?b:"factor",pe=Zt!=null?Zt:ve==="factor"&&w!==void 0?w:C,ie=(_r=o!=null?o:pt)!=null?_r:{},Ze=(0,We.useMemo)(()=>xt(Xt),[xt,Xt]),V=d!=null?d:Ze,k=Number(x!=null?x:Ft==null?void 0:Ft.max_leverage)||iw,Ot=(0,We.useMemo)(()=>{var Ut;return(Ut=Yl(V,Mt))!=null?Ut:k},[V,Mt,k]),jt=Jt?k:A!=null?A:Ot,Ee=Number((Rt=Z==null?void 0:Z.usdt)==null?void 0:Rt.main_balance)||0,fe=(qr=T!=null?T:p)!=null?qr:Ee,ye=fe,Je=
4Bt(Ai),tr=it&&Je,{data:It}=Zi(tr),Se=(Number((hr=Z==null?void 0:Z.inr)==null?void 0:hr.main_balance)||0)+(tr&&Number(It==null?void 0:It.balance)||0),ms=f!=null?f:Se,Zn=(0,We.useMemo)(()=>qs({totalNotionalUsdt:Mt,leverage:Number(t==null?void 0:t.leverage)||0,mmrTiers:V,assetMmr:ft,exchangeTakerFee:v}),[Mt,t==null?void 0:t.leverage,V,ft,v]),sr=(0,We.useMemo)(()=>({mmr:Zn.mmr,takerFee:v,mmDeduction:Zn.mmDeduction}),[Zn,v]),io=s!=null?s:sr,In=bn(),ao=(0,We.useCallback)(()=>{In.invalidateQueries({queryKey:["futures-balance"]})},[In]),lo=(0,We.useCallback)(()=>{In.invalidateQueries({queryKey:["futures-open-positions"]}),In.invalidateQueries({queryKey:["futures-open-orders"]})},[In]),ps=i!=null?i:ao,fs=a!=null?a:lo,$=Ut=>{G(Ut),Ut||r()},W=Ut=>{if(Ut){$(!0);return}At.current||$(!1)},st=Number(t==null?void 0:t.leverage)||0,z=(0,We.useRef)(null),Pt={coin:(ir=t==null?void 0:t.base_currency)==null?void 0:ir.toUpperCase(),currency:(gn=t==null?void 0:t.quote_currency)==null?void 0:gn.toUpperCase(),side:String((Wr=t==null?void 0:t.side)!=null?Wr:"").toUpperCase(),source:L==="leverageOnly"?"orderpad":"positions",platform:M=="desktop"?"desktop":"mweb"},j=()=>{I(_.FuturesAdjustSwitchSubAccountClicked,{...Pt}),$(!1),q==null||q()},{confirm:Fe,pending:_e,blockingOrders:Ie,openOrders:Ce}=ic(t,{quoteCurrencyPrice:J,takerFee:pe,onSuccess:(Ut,Sr)=>{I(_.FuturesAdjustLeverageUpdated,{...Pt,old_leverage:st,new_leverage:Ut,direction:Ut>st?"increased":"decreased"}),n(Ut,Sr),H(null),X(!1),$(!1)},onFailure:()=>{var Ut;I(_.FuturesAdjustLeverageUpdateFailed,{...Pt,old_leverage:st,new_leverage:(Ut=U==null?void 0:U.newLeverage)!=null?Ut:st}),H(null),X(!1),$(!1)},applyLeverage:D,openOrders:dt}),He=(0,We.useMemo)(()=>Kl(Ce,t),[Ce,t]),Le=S!=null?S:He,$e=(Ut,Sr)=>{var Jn,ts,li,ci;I(_.FuturesAdjustLeverageOrderPlaced,{...Pt,old_leverage:st,new_leverage:Ut,direction:Ut>st?"increased":"decreased",margin_delta:Sr,old_liq_price:Number(t==null?void 0:t.liquidation_price)||0,new_liq_price:(ts=(Jn=z.current)==null?void 0:Jn.newLiqPrice)!=null?ts:0,sl_crossed:(ci=(li=z.current)==null?void 0:li.slCrossed)!=null?ci:!1}),Ie.length>0?(I(_.FuturesAdjustCancelOpenOrdersViewed,{...Pt,open_orders_count:Ie.length,new_leverage:Ut}),H({newLeverage:Ut,marginDelta:Sr})):Fe(Ut,Sr)},de=()=>{if(!U)return;let{newLeverage:Ut,marginDelta:Sr}=U;I(_.FuturesAdjustCancelOpenOrdersProceedClicked,{...Pt,open_orders_count:Ie.length,new_leverage:Ut}),X(!0),Fe(Ut,Sr)},Pe=()=>{var Ut;I(_.FuturesAdjustKeepCurrentLeverageClicked,{...Pt,current_leverage:st,abandoned_leverage:(Ut=U==null?void 0:U.newLeverage)!=null?Ut:st}),H(null),$(!1)},ke=L==="full"&&h!==2,ge=M==="desktop",or=ge?P:P&&!U&&!vt,ce=ge&&U!==null,De=ce&&_e,Ue=ht&&!!q,er=String((xr=t==null?void 0:t.base_currency)!=null?xr:"").toUpperCase(),me=String((ar=t==null?void 0:t.quote_currency)!=null?ar:"").toUpperCase(),dr=lt?"INR":me,Ur=er&&dr?`${er}/${dr}`:er||dr,gr=String((Ln=t==null?void 0:t.side)!=null?Ln:"").toUpperCase(),br=gr==="LONG"||gr==="BUY",Br=(0,Wt.jsx)(Jl,{position:t,precision:ie,onRequestedLeverageChange:yt,mmrTiers:V,assetMmr:ft,exchangeTakerFee:v,clientTakerFee:pe,tierCapLeverage:jt,assetMaxLeverage:k,availableBalance:fe,inrBalance:ms,isMarginModeInr:bt,isInr:it,isPriceModeInr:lt,usdtRate:J,protectionPrice:Le,symbolLastPrice:E!=null?E:Number(t==null?void 0:t.last_price)||0,markPrice:Q!=null?Q:Number(t==null?void 0:t.mark_price)||0,onConfirm:$e,onConfirmAnalytics:Ut=>{z.current=Ut},onClose:()=>$(!1),pending:_e,setTopupOpen:g,metricRowLayout:L==="leverageOnly"?"compact":"wide",surface:M}),yr=(0,Wt.jsx)("div",{className:"tw-mt-4 tw-flex tw-w-full tw-flex-col tw-rounded-xl tw-border tw-border-[rgba(179,201,248,0.09)] tw-bg-[#11141c] tw-p-3",children:(0,Wt.jsx)(eo,{orders:Ie,pending:_e,onKeepCurrentLeverage:Pe,onCancelAndProceed:de,symbolLastPrice:E!=null?E:Number(t==null?void 0:t.last_price)||0,isMarginModeInr:bt,usdtRate:J,isPriceModeInr:lt,precision:ie})});return(0,Wt.jsxs)(Wt.Fragment,{children:[(0,Wt.jsxs)(Zs,{isOpen:or,setIsOpen:W,contentClassName:ge?"tw-w-[420px]":void 0,portalContainer:B,children:[(0,Wt.jsxs)("div",{className:"tw-flex tw-justify-between",children:[(0,Wt.jsx)("p",{className:"tw-text-[16
4px] tw-font-[500] tw-leading-[24px] tw-text-[#EDF2F7]",children:L==="full"?"Adjust Position":"Adjust Leverage"}),(0,Wt.jsx)("img",{className:`tw-cursor-pointer${De?" tw-pointer-events-none tw-opacity-50":""}`,src:zn,alt:"Close",width:20,height:20,"aria-disabled":De||void 0,onClick:De?void 0:()=>{I(_.FuturesCrossClicked),$(!1)}})]}),ge&&L==="full"&&!ce&&(0,Wt.jsxs)("div",{"data-testid":"adjust-sub-header",className:"tw-mt-2 tw-flex tw-items-center tw-justify-between tw-text-[12px] tw-font-[500] tw-leading-[20px]",children:[(0,Wt.jsxs)("p",{className:"tw-text-[#C7D2E0]",children:[Ur,(0,Wt.jsx)("span",{className:`tw-ml-2 ${br?"tw-text-[#0ECB81]":"tw-text-[#F46985]"}`,children:br?"Long":"Short"}),(0,Wt.jsx)("span",{className:"tw-ml-2 tw-text-[#718096]",children:`${Number(t==null?void 0:t.leverage)||0}x`})]}),(0,Wt.jsxs)("p",{className:"tw-font-normal tw-text-[#718096]",children:["Last Price"," ",(0,Wt.jsx)("span",{className:"tw-ml-1 tw-text-[#C7D2E0]",children:(()=>{var Sr,Jn,ts;let Ut=(Sr=O!=null?O:E)!=null?Sr:Number(t==null?void 0:t.last_price)||0;return lt?wt(Ut,!0,(Jn=ie==null?void 0:ie.limit_precision)!=null?Jn:2):is(Ut,(ts=ie==null?void 0:ie.limit_precision)!=null?ts:2)})()})]})]}),L==="full"&&!ce&&(0,Wt.jsx)("div",{className:"tw-mb-6 tw-mt-4 tw-flex tw-w-full tw-gap-x-[12px]",children:[{tab:0,label:"Margin"},{tab:1,label:"Liq. Price"},...at?[]:[{tab:2,label:"Leverage"}]].map(({tab:Ut,label:Sr})=>(0,Wt.jsx)("div",{onClick:ce?void 0:()=>{Ut===2&&h!==2&&I(_.FuturesAdjustLeverageTabClick,{...Pt,previous_tab:h===0?"margin":"liq_price"}),y(Ut)},className:`${h===Ut?"tw-border-none tw-bg-[#7B6532] tw-text-white":"tw-border tw-border-[#524422] tw-bg-none"} tw-w-full tw-cursor-pointer tw-rounded-[4px] tw-py-[10px] tw-text-center tw-text-[12px] tw-font-[500] tw-leading-[12px] tw-text-[#CDA954]${ce?" tw-pointer-events-none":""}`,children:Sr},Ut))}),L==="full"?ce?yr:ke?Ct?Ct(h===0?"margin":"liquidation_price"):(0,Wt.jsx)(Rl,{embedded:!0,isOpen:P,setIsOpen:$,isMobile:u,position:t,config:io,precision:ie,walletUpdateCallback:ps,ordersUpdateCallback:fs,clickedKey:h===0?"margin":"liquidation_price",setIsQuickBuyOpen:l,walletBalance:ye,inrBalance:ms,setTopupOpen:g}):Br:(0,Wt.jsxs)(Wt.Fragment,{children:[ce?yr:(0,Wt.jsxs)("div",{className:"tw-mt-4 tw-flex tw-w-full tw-flex-col tw-gap-y-5 tw-rounded-xl tw-border tw-border-[rgba(179,201,248,0.09)] tw-bg-[#11141c] tw-p-3",children:[ht&&(0,Wt.jsx)(nc,{position:t,isMarginModeInr:bt,usdtRate:J,isPriceModeInr:lt,variant:K,symbolLastPrice:E!=null?E:Number(t==null?void 0:t.last_price)||0}),Br]}),Ue&&(0,Wt.jsxs)(Wt.Fragment,{children:[(0,Wt.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-gap-x-3 tw-py-3",children:[(0,Wt.jsx)("div",{className:"tw-h-px tw-flex-1 tw-bg-[rgba(164,190,244,0.2)]"}),(0,Wt.jsx)("span",{className:"tw-text-[11px] tw-text-[rgba(207,222,252,0.58)]",children:"OR"}),(0,Wt.jsx)("div",{className:"tw-h-px tw-flex-1 tw-bg-[rgba(164,190,244,0.2)]"})]}),(0,Wt.jsx)(sc,{onSwitchSubAccount:j,disabled:De})]})]})]}),!ge&&U&&(0,Wt.jsx)(rc,{orders:Ie,pending:_e,onKeepCurrentLeverage:Pe,onCancelAndProceed:de,symbolLastPrice:E!=null?E:Number(t==null?void 0:t.last_price)||0,isMarginModeInr:bt,usdtRate:J,isPriceModeInr:lt,precision:ie})]})},ac=aw;he();Ns();vs();var qe=N(Y());function ti({currentLeverage:t,exchange:e,exchangeKey:r,baseCurrency:n,quoteCurrency:s,isLoggedIn:o,minLeverageConfig:i,maxLeverageConfig:a,validateLeverage:l,getLeveragePriceFall:p,setLeverageMap:f,activeSubaccountId:g,onOpenSubAccounts:u,openPosition:d,openOrders:c,precision:m,symbolLastPrice:w,symbolMarkPrice:b,portalContainer:A}){let x=i||1,T=a||10,[R,S]=(0,Ve.useState)("none"),[E,Q]=(0,Ve.useState)(Number(t)||x),[L,D]=(0,Ve.useState)(!1),[q,K]=(0,Ve.useState)(!1),[dt,M]=(0,Ve.useState)(!1),{isMarginModeInr:Ct}=ue(),O=(0,Ve.useMemo)(()=>fa(T).goldMax,[T]);(0,Ve.useEffect)(()=>{t&&Q(Number(t))},[t]);let ht=(0,Ve.useMemo)(()=>{if(!l)return!1;let X=Number(t);return X?l(X)&&!l(X===x?X+1:x):!1},[l,t,x]);(0,Ve.useEffect)(()=>{S("none"),K(!1)},[g,n]);let B=(0,Ve.useMemo)(()=>Jo(c!=null?c:[],{base_currency:n,quote_currency:s}),[c,n,s]),at=Hl(!!d,B.length>0),h=Ql(d);(0,Ve.useEffect)(()=>{S(X=>
4X==="slider"&&at!=="legacy"||X==="adjust"&&at==="legacy"?"none":X)},[at]);let y=(0,Ve.useMemo)(()=>zl({base_currency:n,quote_currency:s,side:"LONG",leverage:Number(t)||x,exchange:e||r}),[n,s,t,x,e,r]),P=(0,Ve.useCallback)(async X=>{var xt;let At=await Co({payload:{leverage:String(X),exchange:(xt=e||r)==null?void 0:xt.toUpperCase(),base_currency:n==null?void 0:n.toLowerCase(),quote_currency:s==null?void 0:s.toLowerCase()}});if(At.success){let ut=`${n}${s}`;f==null||f(F=>({...F,[ut]:String(X)}))}return At},[e,r,n,s,f]),G=(0,Ve.useCallback)(async()=>{var xt;let X=String(E);D(!0);let At=await Co({payload:{leverage:X,exchange:(xt=e||r)==null?void 0:xt.toUpperCase(),base_currency:n==null?void 0:n.toLowerCase(),quote_currency:s==null?void 0:s.toLowerCase()}});if(At.success){let ut=`${n}${s}`;f==null||f(F=>({...F,[ut]:X})),S("none")}else le(be({type:"failure",header:"Setting Leverage Failed",content:At.msg}));K(!1),D(!1)},[E,e,r,n,s,f]),U=(0,Ve.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen().then(()=>u==null?void 0:u()):u==null||u()},[u]),H=(0,Ve.useCallback)(()=>{if(!(ht||L)){if(E===Number(t)){S("none");return}if(E>O){S("none"),K(!0);return}G()}},[ht,L,E,t,O,G]),vt=(0,Ve.useMemo)(()=>p?p(E):(1/(Number(E)||1)*100).toFixed(1),[E,p]);return(0,qe.jsxs)("div",{className:"tw-relative tw-shrink-0",children:[(0,qe.jsxs)("button",{type:"button",onClick:()=>{if(o){if(at!=="legacy"){S("adjust");return}S(X=>{let At=X==="slider"?"none":"slider";return At==="slider"&&Q(Number(t)||x),At})}},disabled:!o||h,className:"tw-flex tw-h-[34px] tw-w-[50px] tw-cursor-pointer tw-items-center tw-justify-between tw-rounded tw-bg-[#1B1E2D] tw-px-[6px] disabled:tw-cursor-not-allowed disabled:tw-opacity-60","aria-label":"Set leverage",children:[(0,qe.jsx)("span",{className:"tw-text-xs tw-font-medium tw-tracking-[0.03em] tw-text-[#EDF2F7]",children:t?`${t}x`:"--"}),(0,qe.jsx)(et,{name:"leverage-chevron-down",className:"tw-h-3 tw-w-3"})]}),R==="adjust"&&(0,qe.jsx)(ac,{surface:"desktop",mode:"leverageOnly",position:at==="position"?d:y,initialTab:2,onClose:()=>S("none"),onConfirm:X=>{if(S("none"),at!=="position")return;let At=`${n}${s}`;f==null||f(xt=>({...xt,[At]:String(X)}))},isMarginModeInr:Ct,setTopupOpen:M,applyLeverage:at==="ordersOnly"?P:void 0,currentPositionCardVariant:at==="ordersOnly"?"ordersOnly":"position",openOrders:c!=null?c:[],onSwitchSubAccount:u?U:void 0,symbolLastPrice:w,symbolMarkPrice:b,assetMaxLeverage:T,precision:m,portalContainer:A}),dt&&(0,qe.jsx)(os,{onClose:()=>M(!1)}),R==="slider"&&(0,qe.jsxs)("div",{"data-testid":"pretrade-leverage-slider-panel",className:"tw-absolute -tw-left-4 tw-top-[50px] tw-z-20 tw-w-[374px] tw-rounded-lg tw-bg-[#323542] tw-px-2 tw-py-1",children:[(0,qe.jsx)("div",{className:"tw-absolute tw-h-[11px] tw-w-[11px] tw-rotate-45 tw-bg-[#323542]",style:{to
4p:-5,left:39}}),(0,qe.jsxs)("div",{className:"tw-flex tw-h-[40px] tw-items-center tw-gap-3",children:[(0,qe.jsx)("button",{type:"button",onClick:()=>S("none"),className:"tw-flex tw-h-8 tw-w-8 tw-shrink-0 tw-items-center tw-justify-center tw-rounded tw-border tw-border-[#494B57] tw-px-[6px] tw-py-0",children:(0,qe.jsx)(et,{name:"cross-gray",className:"tw-h-[14px] tw-w-[14px]"})}),(0,qe.jsx)("div",{className:"tw-min-w-0 tw-flex-1",children:(0,qe.jsx)($o,{onChange:X=>Q(X),value:E,min:x,max:T})}),(0,qe.jsxs)("div",{className:"tw-flex tw-shrink-0 tw-items-center tw-gap-2",children:[(0,qe.jsx)("div",{className:"tw-flex tw-h-8 tw-w-[44px] tw-items-center tw-justify-center tw-rounded tw-border tw-border-[#90763B] tw-bg-[#1B1E2D]",children:(0,qe.jsxs)("span",{className:"tw-text-xs tw-font-medium tw-tracking-[0.03em] tw-text-[#EDF2F7]",children:[E,"x"]})}),(0,qe.jsx)("button",{type:"button",onClick:H,disabled:L||ht,title:ht?"Cannot change leverage, as an open order already exists on this contract.":void 0,className:"tw-flex tw-h-8 tw-w-8 tw-shrink-0 tw-items-center tw-justify-center tw-rounded tw-bg-[#CDA954] tw-px-[6px] tw-py-0 disabled:tw-cursor-not-allowed disabled:tw-opacity-60",children:(0,qe.jsx)(et,{name:"leverage-confirm",className:"tw-h-4 tw-w-4"})})]})]})]}),q&&(0,qe.jsx)(Yo,{leverage:E,priceFallPercent:vt,onClose:()=>K(!1),onConfirm:G})]})}As();function lc(t,e){if(!t||!e)return!1;if(e.tagName==="IFRAME"){let r=e.contentDocument;return!!r&&t.ownerDocument===r&&r.contains(t)}return t===e&&t.isConnected}var Yt=N(Y());function jn(t,e,r){return Math.max(e,Math.min(r,t))}var cc="draggable-chart-widget-iframe-root",uc=new WeakSet;function lw(t){if(!(typeof document=="undefined"||uc.has(t)))try{document.head.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let n=t.createElement("link");n.rel="stylesheet",n.href=r.href,t.head.appendChild(n)}),uc.add(t)}catch{}}function cw(t){try{let e=t.contentDocument;if(!e||!e.body)return null;let r=e.getElementById(cc);return r||(r=e.createElement("div"),r.id=cc,r.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483647",e.body.appendChild(r),lw(e)),r}catch{return null}}function uw(t){return t?t.tagName==="IFRAME"?cw(t):t:null}function ei(t){var lt,bt,Xt,Mt,Lt,Ft,oe,Nt,pt,_t,Jt,ft;let{containerEl:e,storageKey:r="tv_futures_draggable_widget_pos_v1",symbol:n="",lastPrice:s=0,isLoggedIn:o,onPlaceMarketOrder:i}=t,a=Bt(Fn)||1,l=(0,Gt.useMemo)(()=>{var C;let v=Number((C=t.precision)==null?void 0:C.base_precision);return Number.isFinite(v)?Math.max(0,Math.floor(v)):3},[(lt=t.precision)==null?void 0:lt.base_precision]),p=(0,Gt.useMemo)(()=>{var C;let v=Number((C=t.precision)==null?void 0:C.limit_precision);return Number.isFinite(v)?Math.max(0,Math.floor(v)):2},[(bt=t.precision)==null?void 0:bt.limit_precision]),{minQtyRounded:f,maxQtyRounded:g,lotSize:u}=(0,Gt.useMemo)(()=>{var ve,pe,ie,Ze,V,k;let v=Number((pe=(ve=t.tradeConfig)==null?void 0:ve.client_market)==null?void 0:pe.min_base_quantity),C=Number((Ze=(ie=t.tradeConfig)==null?void 0:ie.client_market)==null?void 0:Ze.max_base_quantity),nt=Number((k=(V=t.tradeConfig)==null?void 0:V.client_market)==null?void 0:k.lot_size)||1,yt=Number.isFinite(v)&&v>0?yn(v,l):0,Zt=Number.isFinite(C)&&C>0?C:0;return{minQtyRounded:yt,maxQtyRounded:Zt,lotSize:nt}},[(Mt=(Xt=t.tradeConfig)==null?void 0:Xt.client_market)==null?void 0:Mt.lot_size,(Ft=(Lt=t.tradeConfig)==null?void 0:Lt.client_market)==null?void 0:Ft.min_base_quantity,(Nt=(oe=t.tradeConfig)==null?void 0:oe.client_market)==null?void 0:Nt.max_base_quantity,l]),d=(0,Gt.useMemo)(()=>{let v=Math.pow(10,-1*l);return f>0?parseFloat(Number(f).toFixed(l)).toString():parseFloat(v.toFixed(l)).toString()},[l,f]),c=t.isMarginModeInr&&t.isInr,m=()=>{let v=Number(s)||0;return c?v*a:v},[w,b]=(0,Gt.useState)(d),[A,x]=(0,Gt.useState)(""),[T,R]=(0,Gt.useState)("base"),[S,E]=(0,Gt.useState)(null),[Q,L]=(0,Gt.useState)(null);(0,Gt.useEffect)(()=>{let v=m(),C=Number(w);v>0&&Number.isFinite(C)&&C>0&&x((C*v).toFixed(p))},[c,a]),(0,Gt.useEffect)(()=>{if(A)return;let v=m(),C=Number(w);v>0&&Number.isFinite(C)&&C>0&&x((C*v).toFixed(p))},[s]);let D=(0,Gt.useMemo)(()=>
4{if(f<=0)return!1;let v=w.trim();if(v===""||v===".")return!1;let C=Number(v);return Number.isFinite(C)?C<f:!1},[w,f]),q=(0,Gt.useMemo)(()=>{if(g<=0)return!1;let v=w.trim();if(v===""||v===".")return!1;let C=Number(v);return Number.isFinite(C)?C>g:!1},[w,g]),K=(0,Gt.useMemo)(()=>{if(u<=1)return!1;let v=w.trim();if(v===""||v===".")return!1;let C=Number(v);return!Number.isFinite(C)||C<=0?!1:C%u!==0},[w,u]),{baseCurrency:dt,quoteCurrency:M,exchangeKey:Ct}=(0,Gt.useMemo)(()=>{let{base:v,quote:C,exchange:nt}=Me(n);return{baseCurrency:v.toUpperCase(),quoteCurrency:(C||"usdt").toUpperCase(),exchangeKey:(nt||"BINANCE").toUpperCase()}},[n]),O=(0,Gt.useMemo)(()=>{var C,nt,yt,Zt,ve,pe;let v=Number((nt=(C=t.tradeConfig)==null?void 0:C.client_market)==null?void 0:nt.max_leverage);return v?String(pa(v,(yt=t.leverageMap)==null?void 0:yt[`${dt}${M}`],Number((Zt=t.openPosition)==null?void 0:Zt.leverage)||Number((pe=(ve=t.openOrders)==null?void 0:ve[0])==null?void 0:pe.leverage))):""},[dt,M,t.leverageMap,t.tradeConfig,t.openPosition,t.openOrders]),ht=()=>{let v=parseFloat(Number(f).toFixed(l)).toString();b(v);let C=m();if(C>0){let nt=(Number(v)*C).toFixed(p);x(nt)}},B=()=>{let v=Dn(g,l);b(v);let C=m();if(C>0){let nt=(Number(v)*C).toFixed(p);x(nt)}},at=()=>{let v=T==="base"?"quote":"base";R(v),I(_.TradeOnChartOrderQtyToggleClicked,{to_side:v==="base"?"qty":"order_value"})},h=v=>{let C=qn(v,l);b(C),I(_.TradeOnChartQtyInputChanged,{current_qty:C});let nt=m(),yt=Number(C);nt>0&&Number.isFinite(yt)&&yt>0?x((yt*nt).toFixed(p)):x("")},y=v=>{let C=qn(v,p);x(C),I(_.TradeOnChartOrderValueInputChanged,{current_qty:C});let nt=m(),yt=Number(C);if(nt>0&&Number.isFinite(yt)&&yt>0){let Zt=yt/nt;b(parseFloat(Zt.toFixed(l)).toString())}else b("")},P=(0,Gt.useRef)(null),G=(0,Gt.useRef)(null),U=(0,Gt.useRef)(null),H=(0,Gt.useRef)(null),vt=(0,Gt.useRef)(!1),X=(0,Gt.useRef)(!1),[At,xt]=(0,Gt.useState)({x:16,y:48}),[ut,F]=(0,Gt.useState)(null);(0,Gt.useEffect)(()=>{b(d);let v=Number(s)||0,C=c?v*a:v,nt=Number(d);C>0&&Number.isFinite(nt)&&nt>0?x((nt*C).toFixed(p)):x(""),R("base")},[d,n]),(0,Gt.useEffect)(()=>{if(typeof window!="undefined")try{let v=window.localStorage.getItem(r);if(!v)return;let C=JSON.parse(v);typeof C.x=="number"&&typeof C.y=="number"&&(xt({x:C.x,y:C.y}),vt.current=!0)}catch{}},[r]),(0,Gt.useEffect)(()=>{if(!e||!P.current||vt.current||X.current)return;let v=e.getBoundingClientRect(),C=P.current.getBoundingClientRect(),nt=8,yt=83,Zt=48,ve=jn(v.width-C.width-yt,nt,v.width-C.width-nt),pe=jn(Zt,nt,v.height-C.height-nt);X.current=!0,xt({x:ve,y:pe})},[e]),(0,Gt.useEffect)(()=>{if(typeof window!="undefined")try{window.localStorage.setItem(r,JSON.stringify(At))}catch{}},[At,r]),(0,Gt.useEffect)(()=>{if(typeof document=="undefined")return;let v=()=>{var nt,yt;return(yt=(nt=document.fullscreenElement)!=null?nt:document.webkitFullscreenElement)!=null?yt:null},C=()=>{let nt=v(),yt=typeof document!="undefined"?document.getElementById("chart_container"):null,Zt=nt&&(nt.id==="chart_container"||yt&&nt.contains(yt)||e&&(nt===e||e.contains(nt)));F(Zt?nt:null)};return C(),document.addEventListener("fullscreenchange",C),document.addEventListener("webkitfullscreenchange",C),()=>{document.removeEventListener("fullscreenchange",C),document.removeEventListener("webkitfullscreenchange",C)}},[e]);let Z=ut!=null?ut:e,ct=(0,Gt.useRef)(null),mt=ct.current,it=lc(mt,ut)?mt:uw(ut);ct.current=it,(0,Gt.useEffect)(()=>{let v=requestAnimationFrame(()=>xt(C=>J(C)));return()=>cancelAnimationFrame(v)},[ut]);let J=(v,C=8)=>{if(!Z||!P.current)return v;let nt=Z.getBoundingClientRect(),yt=P.current.getBoundingClientRect();return{x:jn(v.x,C,nt.width-yt.width-C),y:jn(v.y,C,nt.height-yt.height-C)}};(0,Gt.useEffect)(()=>{if(typeof window=="undefined"||!Z)return;let v=()=>xt(nt=>J(nt)),C=window.requestAnimationFrame(v);return window.addEventListener("resize",v),()=>{window.cancelAnimationFrame(C),window.removeEventListener("resize",v)}},[Z]);let wt=(0,Yt.jsxs)("div",{ref:P,className:"tw-pointer-events-auto tw-absolute  tw-select-none",style:{left:At.x,top:At.y,touchAction:"none"},children:[(0,Yt.jsxs)("div",{id:"draggable-chart-widget",className:"tw-flex tw-h-[42px] tw-w-fit tw-max-w-full tw-flex-nowrap tw-items-center tw-gap-2 tw-rounded-lg tw-bg-[#323542] tw-p-1",style:{maxWidth:Z!=null&&Z.clientWidth?Math.max(0,Z.clientWidth-16):void 0},children:[(0,Yt.jsxs)("button",{ref:G,type:"button",className:"tw-active:tw-cursor-grabbing tw-flex tw-h-5 tw-w-3 tw-shrink-0 tw-cursor-grab tw-flex-col tw-items-center tw-justify-center tw-gap-[3px] tw-rounded","aria-label":"Drag widget",onPointerDown:v
4=>{var yt;if(!Z||!P.current||v.button!==void 0&&v.button!==0)return;let C=Z.getBoundingClientRect(),nt=P.current.getBoundingClientRect();H.current={pointerId:v.pointerId,startClientX:v.clientX,startClientY:v.clientY,startX:At.x,startY:At.y,containerW:C.width,containerH:C.height,widgetW:nt.width,widgetH:nt.height},(yt=G.current)==null||yt.setPointerCapture(v.pointerId)},onPointerMove:v=>{let C=H.current;if(!C||v.pointerId!==C.pointerId)return;let nt=v.clientX-C.startClientX,yt=v.clientY-C.startClientY,Zt=8,ve=jn(C.startX+nt,Zt,C.containerW-C.widgetW-Zt),pe=jn(C.startY+yt,Zt,C.containerH-C.widgetH-Zt);xt({x:ve,y:pe})},onPointerUp:v=>{var yt;let C=H.current;if(!C||v.pointerId!==C.pointerId)return;let nt=Math.abs(v.clientX-C.startClientX)>2||Math.abs(v.clientY-C.startClientY)>2;H.current=null,(yt=G.current)==null||yt.releasePointerCapture(v.pointerId),nt&&I(_.TradeOnChartWidgetMoved)},onPointerCancel:v=>{var nt;let C=H.current;C&&v.pointerId===C.pointerId&&(H.current=null,(nt=G.current)==null||nt.releasePointerCapture(v.pointerId))},children:[(0,Yt.jsx)("span",{className:"tw-h-[1px] tw-w-1 tw-bg-[#C7D2E0]"}),(0,Yt.jsx)("span",{className:"tw-h-[1px] tw-w-1 tw-bg-[#C7D2E0]"}),(0,Yt.jsx)("span",{className:"tw-h-[1px] tw-w-1 tw-bg-[#C7D2E0]"}),(0,Yt.jsx)("span",{className:"tw-h-[1px] tw-w-1 tw-bg-[#C7D2E0]"})]}),(0,Yt.jsx)(ti,{currentLeverage:O,exchange:t.exchange,exchangeKey:Ct,baseCurrency:dt,quoteCurrency:M,isLoggedIn:o,minLeverageConfig:Number((_t=(pt=t.tradeConfig)==null?void 0:pt.client_market)==null?void 0:_t.min_leverage)||1,maxLeverageConfig:Number((ft=(Jt=t.tradeConfig)==null?void 0:Jt.client_market)==null?void 0:ft.max_leverage)||10,activeSubaccountId:t.activeSubaccountId,validateLeverage:t.validateLeverage,getLeveragePriceFall:t.getLeveragePriceFall,setLeverageMap:t.setLeverageMap,onOpenSubAccounts:t.onOpenSubAccounts,openPosition:t.openPosition,openOrders:t.openOrders,precision:t.precision,symbolLastPrice:s,symbolMarkPrice:t.markPrice,portalContainer:it}),(0,Yt.jsx)("div",{className:"tw-flex tw-h-[34px] tw-w-[112px] tw-shrink-0 tw-items-center",children:(0,Yt.jsxs)("div",{className:"tw-flex tw-h-[34px] tw-w-[112px] tw-shrink-0 tw-cursor-text tw-items-center tw-justify-between tw-rounded tw-bg-[#1B1E2D] tw-pl-2",onClick:()=>{var v;return(v=U.current)==null?void 0:v.focus()},children:[(0,Yt.jsxs)("div",{className:"tw-flex tw-flex-col tw-justify-center tw-py-[2px]",children:[(0,Yt.jsx)("span",{className:"tw-text-[10px] tw-font-medium  tw-text-[#A0AEC0]",children:T==="base"?"Quantity":"Order Value"}),T==="base"?(0,Yt.jsx)("input",{ref:U,value:w,onChange:v=>h(v.target.value),inputMode:"decimal",disabled:!o,placeholder:f>0?f.toFixed(l):void 0,className:"tw-w-16 tw-min-w-0 tw-bg-transparent tw-text-xs tw-font-medium tw-tracking-[0.03em] tw-text-[#EDF2F7] placeholder:tw-text-gray-600 focus:tw-outline-none disabled:tw-cursor-not-allowed disabled:tw-opacity-60","aria-label":"Quantity"}):(0,Yt.jsx)("input",{ref:U,value:A,onChange:v=>y(v.target.value),inputMode:"decimal",disabled:!o,placeholder:"0.00",className:"tw-w-16 tw-min-w-0 tw-bg-transparent tw-text-xs tw-font-medium tw-tracking-[0.03em] tw-text-[#EDF2F7] placeholder:tw-text-gray-600 focus:tw-outline-none disabled:tw-cursor-not-allowed disabled:tw-opacity-60","aria-label":"Order Value"})]}),(0,Yt.jsx)("div",{onClick:v=>{v.stopPropagation(),at()},className:"tw-flex tw-h-full tw-w-5 tw-shrink-0 tw-cursor-pointer tw-items-center tw-justify-center tw-border-l tw-border-l-[#323542] tw-text-[#718096]",children:(0,Yt.jsx)(et,{name:"futures-swap-grey",className:"tw-h-3 tw-w-3","aria-hidden":"true",focusable:"false"})})]})}),(()=>{var jt,Ee;let v=Number(s)||0,C=w.trim(),nt=Us({qty:C,lotSize:u,basePrecision:l}),yt=nt.ok?nt.baseQty:"",Zt={side:"buy",type:"market",input:{size:{["base"]:{value:yt}},price:String(v||"")}},ve={client_market:(Ee=(jt=t.tradeConfig)==null?void 0:jt.client_market)!=null?Ee:{}},pe=nt.ok&&Ds(Zt,ve),ie=i&&n&&o&&v>0&&pe&&!S,Ze=async()=>{if(ie){I(_.TradeOnChartPlaceOrderClicked,{exchange:Ct,side:"short",type:"market",base_qty:yt,base_currency:dt,quote_currency:M,limit_price:String(v),leverage:O,"Card type":"",Initial_Fee_Amount:"",Fee_Factor_After_Points:"",Fee_Points_Available_Balance:""}),E("short");
4try{await i({symbol:n,side:"SELL",qty:yt})}finally{E(null)}}},V=async()=>{if(ie){I(_.TradeOnChartPlaceOrderClicked,{exchange:Ct,side:"long",type:"market",base_qty:yt,base_currency:dt,quote_currency:M,limit_price:String(v),leverage:O,"Card type":"",Initial_Fee_Amount:"",Fee_Factor_After_Points:"",Fee_Points_Available_Balance:""}),E("long");try{await i({symbol:n,side:"BUY",qty:yt})}finally{E(null)}}},k=D||q||K,Ot=fe=>{if(!t.getCostExternal||!yt||v<=0)return"";let ye=t.getCostExternal({side:fe,type:"market",price:v,qty:yt});if(!Number.isFinite(ye)||ye<0)return"";let Je=c?ye*a:ye;return(c?"\u20B9":"")+Je.toLocaleString(c?"en-IN":void 0,{minimumFractionDigits:2,maximumFractionDigits:2})};return(0,Yt.jsxs)("div",{className:"tw-flex tw-h-[34px] tw-items-center tw-gap-0.5",children:[(0,Yt.jsxs)("button",{type:"button",disabled:!ie,onClick:V,onMouseEnter:()=>L("long"),onMouseLeave:()=>L(null),className:`tw-relative tw-flex tw-h-[34px] tw-min-w-[88px] tw-items-center tw-justify-center tw-whitespace-nowrap tw-px-3 disabled:tw-cursor-not-allowed ${k?"tw-rounded-l tw-bg-[#4A5568]":"tw-rounded-l tw-bg-[#0A8E5A] disabled:tw-opacity-60"}`,children:[Q==="long"&&!k&&(0,Yt.jsx)(Hn,{side:"BUY",margin:Ot("buy")}),(0,Yt.jsx)("span",{className:`tw-whitespace-nowrap tw-text-center tw-text-xs tw-font-medium tw-tracking-[0.03em] ${k?"tw-text-[#A0AEC0]":"tw-text-white"}`,children:S==="long"?"Placing...":"Market Long"})]}),(0,Yt.jsxs)("button",{type:"button",disabled:!ie,onClick:Ze,onMouseEnter:()=>L("short"),onMouseLeave:()=>L(null),className:`tw-relative tw-flex tw-h-[34px] tw-min-w-[88px] tw-items-center tw-justify-center tw-whitespace-nowrap tw-px-3 disabled:tw-cursor-not-allowed ${k?"tw-rounded-r tw-bg-[#4A5568]":"tw-rounded-r tw-bg-[#F14366] disabled:tw-opacity-60"}`,children:[Q==="short"&&!k&&(0,Yt.jsx)(Hn,{side:"SELL",margin:Ot("sell")}),(0,Yt.jsx)("span",{className:`tw-whitespace-nowrap tw-text-center tw-text-xs tw-font-medium tw-tracking-[0.03em] ${k?"tw-text-[#A0AEC0]":"tw-text-white"}`,children:S==="short"?"Placing...":"Market Short"})]})]})})()]}),D&&(0,Yt.jsx)("div",{className:"tw-absolute tw-bottom-full tw-left-20",children:(0,Yt.jsx)(qo,{minQty:f.toFixed(l),baseCurrency:dt,onUseMinimum:ht})}),q&&!D&&(0,Yt.jsx)("div",{className:"tw-absolute tw-bottom-full tw-left-20",children:(0,Yt.jsx)(Vo,{maxQty:Dn(g,l),baseCurrency:dt,onUseMaximum:B})}),K&&!D&&!q&&(0,Yt.jsx)("div",{className:"tw-absolute tw-bottom-full tw-left-0",children:(0,Yt.jsxs)("div",{className:"tw-relative tw-mb-1 tw-w-fit",children:[(0,Yt.jsx)("div",{className:"tw-absolute -tw-bottom-[5px] tw-left-[calc(50%-76px)] tw-h-2.5 tw-w-2.5 tw-rotate-45 tw-border-b tw-border-r tw-border-[#F14366] tw-bg-[#1B1E2D]"}),(0,Yt.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1 tw-rounded-lg tw-border tw-border-[#F14366] tw-bg-[#1B1E2D] tw-px-2 tw-py-[7px]",children:[(0,Yt.jsx)(et,{name:"warning-red",className:"tw-h-4 tw-w-4 tw-shrink-0"}),(0,Yt.jsxs)("span",{className:"tw-whitespace-nowrap tw-text-xs tw-font-normal tw-leading-5 tw-tracking-[0.03em] tw-text-white",children:["Quantity should be multiple of ",u]})]})]})})]});if(ut){let v=ut.tagName==="IFRAME",C=it;return C?(0,wc.createPortal)((0,Yt.jsx)("div",{className:"tw-relative tw-h-full tw-w-full","data-draggable-widget-portal":"true",style:v?{position:"fixed",inset:0,pointerEvents:"none",zIndex:2147483647}:void 0,children:wt}),C):wt}return wt}var re=N(Qt()),fc=N(gs());vr();he();Oe();Ne();As();var kt=N(Y());function dc(t,e,r){return Math.max(e,Math.min(r,t))}var mc="price-scale-plus-overlay-iframe-root",pc=new WeakSet;function ww(t){if(!(typeof document=="undefined"||pc.has(t)))try{document.head.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let n=t.createElement("link");n.rel="stylesheet",n.href=r.href,t.head.appendChild(n)}),pc.add(t)}catch{}}function dw(t){try{let e=t.contentDocument;if(!e||!e.body)return null;let r=e.getElementById(mc);return r||(r=e.createElement("div"),r.id=mc,r.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483647",e.body.appendChild(r),ww(e)),r}catch{return null}}function ri(t){var Jt,ft,v,C,nt,yt,Zt,ve,pe,ie,Ze;let{containerEl:e,params:r,onClose:n,symbol:s="",lastPrice:o=0,isPriceModeInr:i,isLoggedIn:a,onPlaceLimitOrder:l}=t,p=Bt(Fn)||1,f=(0,re.useRef)(null),g=(0,re.useRef)(null),[u,d]=(0,re.useState)(null),[c,m]=(0,re.useState)(null),[w,b]=(0,re.useState)("base"),[A,x]=(0,re.useState)(""),[T,R]=(0,re.useState)(!1),[S,E]=(0,re.useState)(!1),Q=(0,re.useMemo)(()=>{var k;let V=Number((k=t.precision)==null?void 0:k.base_precision);return Number.isFinite(V)?Math.max(0,Math.floor(V)):3},[(Jt=t.precision)==null?void 0:Jt.base_precision]),L=(0,re.useMemo)(()=>{var k;let V=Number((k=t.precision)==null?void 0:k.limit_precision);return Number.isFinite(V)?Math.max(0,Math.floor(V)):2},[(ft=t.precision)==null?void 0:ft.limit_precision]),{minQtyRounded:D,maxQtyRounded:q,lotSize:K}=(0,re.useMemo)(()=>{var fe,ye,Je,tr,It,Se;let V=Number((ye=(fe=t.tradeConfig)==null?void 0:fe.client_market)==null?void 0:ye.min_base_quantity),k=Number((tr=(Je=t.tradeConfig)==null?void 0:Je.client_market)==null?void 0:tr.max_base_quantity),Ot=Number((Se=(It=t.tradeConfig)==null?void 0:It.client_market)==null?void 0:Se.lot_size)||1,jt=Number.isFinite(V)&&V>0?yn(V,Q):0,Ee=Number.isFinite(k)&&k>0?k:0;return{minQtyRounded:jt,maxQtyRounded:Ee,lotSize:Ot}},[(C=(v=t.tradeConfig)==null?void 0:v.client_market)==null?void 0:C.lot_size,(yt=(nt=t.tradeConfig)==null?void 0:nt.client_market)==null?void 0:yt.min_base_quantity,(ve=(Zt=t.tradeConfig)==null?void 0:Zt.client_market)==null?void 0:ve.max_base_quantity,Q]),dt=(0,re.useMemo)(()=>{let V=Math.pow(10,-1*Q);return D>0?parseFloat(Number(D).toFixed(Q)).toString():parseFloat(V.toFixed(Q)).toString()},[Q,D]),[M,Ct]=(0,re.useState)(dt),O=c!=null?c:e,ht=Boolean(O&&r),B=t.isMarginModeInr&&t.isInr,at=(()=>!!i===!!B?1:B?p:1/p)();(0,re.useEffect)(()=>
4{if(r){Ct(dt),b("base");let V=Number.isFinite(r.price)?r.price:0,k=Number(dt);V>0&&Number.isFinite(k)&&k>0?x((k*V*at).toFixed(L)):x("")}},[r,dt,L,at]),(0,re.useEffect)(()=>{if(!r)return;let V=Number.isFinite(r.price)?r.price:0;if(V<=0)return;let k=Number(M);Number.isFinite(k)&&k>0&&x((k*V*at).toFixed(L))},[B,p]),(0,re.useEffect)(()=>{r||d(null)},[r]);let h=(0,re.useMemo)(()=>{if(D<=0)return!1;let V=M.trim();if(V===""||V===".")return!1;let k=Number(V);return Number.isFinite(k)?k<D:!1},[M,D]),y=(0,re.useMemo)(()=>{if(q<=0)return!1;let V=M.trim();if(V===""||V===".")return!1;let k=Number(V);return Number.isFinite(k)?k>q:!1},[M,q]),P=(0,re.useMemo)(()=>{if(K<=1)return!1;let V=M.trim();if(V===""||V===".")return!1;let k=Number(V);return!Number.isFinite(k)||k<=0?!1:k%K!==0},[M,K]),G=(0,re.useMemo)(()=>{let{base:V}=Me(s);return V.toUpperCase()},[s]),U=()=>{let V=parseFloat(Number(D).toFixed(Q)).toString();if(Ct(V),r){let k=Number.isFinite(r.price)?r.price:0;k>0&&x((Number(V)*k*at).toFixed(L))}},H=()=>{let V=Dn(q,Q);if(Ct(V),r){let k=Number.isFinite(r.price)?r.price:0;k>0&&x((Number(V)*k*at).toFixed(L))}},vt=()=>{let V=w==="base"?"quote":"base";b(V),I(_.TradeOnChartLimitValueQtyToggleClicked,{side:ct==="BUY"?"long":"short",limit_price:r?String(r.price):"",tp_price:"",sl_price:"",order_value:A,qty:M})},X=V=>{let k=qn(V,Q);if(Ct(k),I(_.TradeOnChartLimitQtyChanged,{side:ct==="BUY"?"long":"short",limit_price:r?String(r.price):"",tp_price:"",sl_price:"",order_value:A,qty:k}),r){let Ot=Number.isFinite(r.price)?r.price:0,jt=Number(k);Ot>0&&Number.isFinite(jt)&&jt>0?x((jt*Ot*at).toFixed(L)):x("")}},At=V=>{let k=qn(V,L);if(x(k),I(_.TradeOnChartLimitOrderValueChanged,{side:ct==="BUY"?"long":"short",limit_price:r?String(r.price):"",tp_price:"",sl_price:"",order_value:k,qty:M}),r){let Ot=Number.isFinite(r.price)?r.price:0,jt=Number(k),Ee=Ot*at;if(Ee>0&&Number.isFinite(jt)&&jt>0){let fe=jt/Ee;Ct(parseFloat(fe.toFixed(Q)).toString())}else Ct("")}};(0,re.useEffect)(()=>{if(typeof document=="undefined")return;let V=()=>{var Ot,jt;return(jt=(Ot=document.fullscreenElement)!=null?Ot:document.webkitFullscreenElement)!=null?jt:null},k=()=>{let Ot=V(),jt=typeof document!="undefined"?document.getElementById("chart_container"):null,Ee=Ot&&(Ot.id==="chart_container"||jt&&Ot.contains(jt)||e&&(Ot===e||e.contains(Ot)));m(Ee?Ot:null)};return k(),document.addEventListener("fullscreenchange",k),document.addEventListener("webkitfullscreenchange",k),()=>{document.removeEventListener("fullscreenchange",k),document.removeEventListener("webkitfullscreenchange",k)}},[e]);let xt=(0,re.useMemo)(()=>{if(!O||!r)return null;let V=O.getBoundingClientRect();return{x:r.clientX,y:r.clientY,w:V.width,h:V.height}},[O,r]);if((0,re.useEffect)(()=>{xt&&d({left:xt.x,top:xt.y})},[xt]),(0,re.useLayoutEffect)(()=>{if(!xt||!f.current)return;let V=f.current,k=8,Ot=20,{width:jt,height:Ee}=V.getBoundingClientRect(),fe=xt.x-Ot,ye=dc(fe-jt,k,xt.w-jt-k),Je=dc(xt.y-Ee/2,k,xt.h-Ee-k);d(tr=>tr?Math.abs(tr.left-ye)<.5&&Math.abs(tr.top-Je)<.5?tr:{left:ye,top:Je}:{left:ye,top:Je})}),(0,re.useEffect)(()=>{if(!ht)return;let V=Ot=>{Ot.key==="Escape"&&n()},k=Ot=>{var Ee;let jt=Ot.target;jt&&((Ee=f.current)!=null&&Ee.contains(jt)||n())};return document.addEventListener("keydown",V),document.addEventListener("pointerdown",k,!0),()=>{document.removeEventListener("keydown",V),document.removeEventListener("pointerdown",k,!0)}},[ht,n]),!ht||!u||!r)return null;let ut=Number.isFinite(r.price)?r.price:0,F=Number(o)||0,Z=i?F*p:F,ct=ut>=Z?"SELL":"BUY",mt=ct==="SELL"?"Limit Short":"Limit Long",it=h||y||P,J=M.trim(),wt=Us({qty:J,lotSize:K,basePrecision:Q}),lt=wt.ok?wt.baseQty:"",bt={side:ct==="BUY"?"buy":"sell",type:"limit",input:{size:{["base"]:{value:lt}},price:String(ut||"")}},Xt={client_market:(ie=(pe=t.tradeConfig)==null?void 0:pe.client_market)!=null?ie:{}},Mt=wt.ok&&Ds(bt,Xt),Lt=i?2:Math.max(0,Math.floor(Number((Ze=t.precision)==null?void 0:Ze.limit_precision)||2)),Ft=ut>0?(i?"\u20B9":"")+ut.toLocaleString(i?"en-IN":void 0,{minimumFractionDigits:Lt,maximumFractionDigits:Lt}):"-",oe=Boolean(l&&s&&a&&ut>0&&Mt&&!T),Nt=(()=>
4{if(!t.getCostExternal||!lt||ut<=0)return"";let V=i&&p>0?ut/p:ut,k=t.getCostExternal({side:ct==="BUY"?"buy":"sell",type:"limit",price:V,qty:lt});if(!Number.isFinite(k)||k<0)return"";let Ot=B?k*p:k;return(B?"\u20B9":"")+Ot.toLocaleString(B?"en-IN":void 0,{minimumFractionDigits:2,maximumFractionDigits:2})})(),pt=async()=>{if(!(!l||!s||!a)&&Mt){I(_.TradeOnChartLimitButtonClicked,{side:ct==="BUY"?"long":"short",limit_price:String(ut),tp_price:"",sl_price:"",order_value:A,qty:M}),R(!0);try{await l({symbol:s,side:ct,qty:lt,limitPrice:ut})}finally{R(!1),n()}}},_t=(0,kt.jsx)("div",{ref:f,className:"tw-pointer-events-auto tw-absolute tw-z-10",style:{left:u.left,top:u.top},role:"dialog","aria-label":"Quick trade",children:(0,kt.jsxs)("div",{className:"tw-relative tw-flex tw-h-[42px] tw-items-center tw-gap-2 tw-rounded-lg tw-bg-[#323542] tw-py-1 tw-pl-2 tw-pr-1",children:[h&&(0,kt.jsx)("div",{className:"tw-absolute tw-bottom-full tw-right-0 tw-mb-1 tw-w-max",children:(0,kt.jsxs)("div",{className:"tw-relative",children:[(0,kt.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-3 tw-rounded-lg tw-border tw-border-[#F14366] tw-bg-[#1B1E2D] tw-px-2 tw-py-[7px]",children:[(0,kt.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,kt.jsx)(et,{name:"warning-red",className:"tw-h-4 tw-w-4 tw-shrink-0"}),(0,kt.jsxs)("span",{className:"tw-whitespace-nowrap tw-text-xs tw-font-normal tw-tracking-[0.03em] tw-text-white",children:["Min quantity is ",D.toFixed(Q)," ",G]})]}),(0,kt.jsx)("button",{type:"button",onClick:U,className:"tw-whitespace-nowrap tw-text-xs tw-font-medium tw-tracking-[0.03em] tw-text-[#CDA954]",children:"Use Minimum"})]}),(0,kt.jsx)("div",{className:"tw-absolute -tw-bottom-[5px] tw-right-4 tw-h-2.5 tw-w-2.5 tw-rotate-45 tw-border-b tw-border-r tw-border-[#F14366] tw-bg-[#1B1E2D]"})]})}),y&&!h&&(0,kt.jsx)("div",{className:"tw-absolute tw-bottom-full tw-right-0 tw-mb-1 tw-w-max",children:(0,kt.jsxs)("div",{className:"tw-relative",children:[(0,kt.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-3 tw-rounded-lg tw-border tw-border-[#F14366] tw-bg-[#1B1E2D] tw-px-2 tw-py-[7px]",children:[(0,kt.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1",children:[(0,kt.jsx)(et,{name:"warning-red",className:"tw-h-4 tw-w-4 tw-shrink-0"}),(0,kt.jsxs)("span",{className:"tw-whitespace-nowrap tw-text-xs tw-font-normal tw-tracking-[0.03em] tw-text-white",children:["Max quantity is"," ",Dn(q,Q)," ",G]})]}),(0,kt.jsx)("button",{type:"button",onClick:H,className:"tw-whitespace-nowrap tw-text-xs tw-font-medium tw-tracking-[0.03em] tw-text-[#CDA954]",children:"Use Maximum"})]}),(0,kt.jsx)("div",{className:"tw-absolute -tw-bottom-[5px] tw-right-4 tw-h-2.5 tw-w-2.5 tw-rotate-45 tw-border-b tw-border-r tw-border-[#F14366] tw-bg-[#1B1E2D]"})]})}),P&&!h&&!y&&(0,kt.jsx)("div",{className:"tw-absolute tw-bottom-full tw-right-0 tw-mb-1 tw-w-auto",children:(0,kt.jsxs)("div",{className:"tw-relative",children:[(0,kt.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1 tw-rounded-lg tw-border tw-border-[#F14366] tw-bg-[#1B1E2D] tw-px-2 tw-py-[7px]",children:[(0,kt.jsx)(et,{name:"warning-red",className:"tw-h-4 tw-w-4 tw-shrink-0"}),(0,kt.jsxs)("span",{className:"tw-whitespace-nowrap tw-text-xs tw-font-normal tw-tracking-[0.03em] tw-text-white",children:["Quantity should be multiple of ",K]})]}),(0,kt.jsx)("div",{className:"tw-absolute -tw-bottom-[5px] tw-right-4 tw-h-2.5 tw-w-2.5 tw-rotate-45 tw-border-b tw-border-r tw-border-[#F14366] tw-bg-[#1B1E2D]"})]})}),(0,kt.jsx)("button",{type:"button",className:"tw-flex tw-h-4 tw-w-4 tw-shrink-0 tw-items-center tw-justify-center tw-text-white hover:tw-opacity-80","aria-label":"Close",onClick:()=>{I(_.TradeOnChartLimitOrderWidgetClosed,{side:ct==="BUY"?"long":"short"}),n()},children:(0,kt.jsx)(et,{name:"cross-white",className:"tw-h-3 tw-w-3"})}),(0,kt.jsxs)("div",{className:"tw-flex tw-h-[34px] tw-w-[112px] tw-shrink-0 tw-cursor-text tw-items-center tw-justify-between tw-rounded tw-bg-[#1B1E2D] tw-pl-2",onClick:()=>{var V;return(V=g.current)==null?void 0:V.focus()},children:[(0,kt.jsxs)("div",{className:"tw-flex tw-flex-col tw-items-start tw-pr-1",style:{height:34},children:[(0,kt.jsx)("span",{className:"tw-text-[10px] tw-font-medium tw-text-[#A0AEC0]",children:w==="base"?"Quantity":"Order Value"}),w==="base"?(0,kt.jsx)("input",{ref:g,value:M,onChange:V=>X(V.target.value),inputMode:"decimal",disabled:!a,placeholder:D>0?D.toFixed(Q):void 0,className:"tw-w-16 tw-min-w-0 tw-bg-transparent tw-text-xs tw-font-medium  tw-tracking-[0.03em] tw-text-[#EDF2F7] placeholder:tw-text-gray-600 focus:tw-outline-none disabled:tw-cursor-not-allowed disabled:tw-opacity-60","aria-label":"Quantity"}):(0,kt.jsx)("input",{ref:g,value:A,onChange:V=>At(V.target.value),inputMode:"decimal",disabled:!a,placeholder:"0.00",className:"tw-w-16 tw-min-w-0 tw-bg-transparent tw-text-xs tw-font-medium  tw-tracking-[0.03em] tw-text-[#EDF2F7] placeholder:tw-text-gray-600 focus:tw-outline-none disabled:tw-cursor-not-allowed disabled:tw-opacity-60","aria-label":"Order Value"})]}),(0,kt.jsx)("div",{onClick:V=>{V.stopPropagation(),vt()},className:"tw-flex tw-h-full tw-w-5 tw-shrink-0 tw-cursor-pointer tw-items-center tw-justify-center tw-border-l tw-border-l-[#323542] tw-text-[#718096]",children:(0,kt.jsx)(et,{name:"futures-swap-grey",className:"tw-h-3 tw-w-3","aria-hidden":"true",focusable:"false"})})]}),(0,kt.jsxs)("button",{type:"button",disabled:!oe,onClick:pt,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),className:`tw-relative tw-flex tw-min-w-[88px] tw-flex-col tw-items-center tw-justify-center tw-rounded tw-px-3 disabled:tw-cursor-not-allowed disabled:tw-opacity-60 ${it?"tw-bg-[#4A5568]":ct==="BUY"?"tw-bg-[#0A8E5A]":"tw-bg-[#F14366]"}`,children:[S&&!it&&(0,kt.jsx)(Hn,{side:ct,margin:Nt,align:"right"}),(0,kt.jsx)("span",{className:`tw-whitespace-nowrap tw-text-center tw-text-xs tw-font-medium tw-tracking-[0.03em] ${it?"tw-text-[#A0AEC0]":"tw-text-white"}`,children:T?"Placing...":mt}),(0,kt.jsx)("span",{className:`tw-whitespace-nowrap tw-text-center tw-text-[10px] tw-font-normal ${it?"tw-text-[#A0AEC0]":"tw-text-white"}`,children:Ft})]})]})});if(c){let V=c.tagName==="IFRAME",k=V?dw(c):c;return k?(0,fc.createPortal)((0,kt.jsx)("div",{className:"tw-relative tw-h-full tw-w-full",style:V?{position:"fixed",inset:0,pointerEvents:"none",zIndex:2147483647}:void 0,children:_t}),k):_t}return _t}var so=N(Qt()),hc=N(gs());pi();var ni=N(Y()),gc="fullscreen-toast-iframe-root",bc=new WeakSet;function mw(t){if(!(typeof document=="undefined"||bc.has(t)))try{document.head.querySelectorAll('link[rel="stylesheet"]').forEach(r=>{let n=t.createElement("link");n.rel="stylesheet",n.href=r.href,t.head.appendChild(n)}),bc.add(t)}catch{}}function pw(t){try{let e=t.contentDocument;if(!e||!e.body)return null;let r=e.getElementById(gc);return r||(r=e.createElement("div"),r.id=gc,r.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483647",e.body.appendChild(r),mw(e)),r}catch{return null}}function si({containerEl:t}){let[e,r]=(0,so.useState)(null);if((0,so.useEffect)(()=>
4{if(typeof document=="undefined")return;let o=()=>{var a,l;return(l=(a=document.fullscreenElement)!=null?a:document.webkitFullscreenElement)!=null?l:null},i=()=>{let a=o(),l=document.getElementById("chart_container"),p=a&&(a.id==="chart_container"||l&&a.contains(l)||t&&(a===t||t.contains(a)));r(p?a:null)};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i)}},[t]),!e)return null;let s=e.tagName==="IFRAME"?pw(e):e;return s?(0,hc.createPortal)((0,ni.jsx)("div",{style:{pointerEvents:"auto"},children:(0,ni.jsx)(di,{})}),s):null}vs();Ns();Oe();Ne();var cn=N(Y()),xc="futures_trade_on_chart_enabled",vc="futures:v2:orders-positions-changed";function oi(t){var e,r,n,s;return Math.abs(Number((s=(n=(r=(e=t==null?void 0:t.size)!=null?e:t==null?void 0:t.qty)!=null?r:t==null?void 0:t.base_qty)!=null?n:t==null?void 0:t.position_qty)!=null?s:0)||0)}function gw(t){var r;let e=String((r=t==null?void 0:t.status)!=null?r:"").toUpperCase();return e?!(e==="CLOSED"||e==="CANCELLED"||e==="CANCELED"||e==="FILLED"||e==="EXECUTED"||e==="EXITED"||e==="FAILED"||e==="PARTIALLY_EXECUTED"):oi(t)>0}function ii(t){let e=Number(t==null?void 0:t.liquidation_price);return Number.isFinite(e)&&e>0?e:NaN}function bw(t){var r,n,s;let e=Number((s=(n=(r=t==null?void 0:t.avg_entry)!=null?r:t==null?void 0:t.avg_entry_price)!=null?n:t==null?void 0:t.entry_price)!=null?s:t==null?void 0:t.avg_price)||NaN;return Number.isFinite(e)&&e>0?e:NaN}var hw={linecolor:"#A0AEC0",linewidth:1,linestyle:2,showPriceLabels:!1},xw=t=>["liquidation","liq"].includes(String(t!=null?t:"").toLowerCase());function Sc(t,e){var o;let r=(e.exchangeKey||"").toUpperCase(),n=(e.baseLower||"").toLowerCase(),s=new Set(((o=e.quoteCandidates)!=null?o:[]).map(i=>(i!=null?i:"").toLowerCase()).filter(Boolean));return(t!=null?t:[]).filter(i=>{var f,g,u;if(!gw(i))return!1;let a=String((f=i==null?void 0:i.exchange)!=null?f:r).toUpperCase().trim(),l=String((g=i==null?void 0:i.base_currency)!=null?g:"").toLowerCase().trim(),p=String((u=i==null?void 0:i.quote_currency)!=null?u:"usdt").toLowerCase().trim();return a&&r&&a!==r||!l||l!==n?!1:s.has(p)})}function yc(t){var r;let e=Sc(t.positions,{exchangeKey:t.exchangeKey,baseLower:t.baseLower,quoteCandidates:t.quoteCandidates});return e.length?(e.sort((n,s)=>{var d,c,m,w,b,A;let o=ii(n),i=ii(s),a=Number.isFinite(o)&&o>0,l=Number.isFinite(i)&&i>0;if(a!==l)return l?1:-1;let p=oi(n),f=oi(s);if(p!==f)return f-p;let g=Number((m=(c=(d=n==null?void 0:n.updated_at)!=null?d:n==null?void 0:n.update_time)!=null?c:n==null?void 0:n.timestamp)!=null?m:0)||0,u=Number((A=(b=(w=s==null?void 0:s.updated_at)!=null?w:s==null?void 0:s.update_time)!=null?b:s==null?void 0:s.timestamp)!=null?A:0)||0;return g!==u?u-g:0}),(r=e[0])!=null?r:null):null}var vw=({selected_contract:t,selectedExchange:e,all_contracts:r,all_precision:n,leverageMap:s={},lastPrice:o,tradeConfig:i,precision:a,isLoggedIn:l,depth:p,mark_price:f,getCostExternal:g,validateLeverage:u,getLeveragePriceFall:d,setLeverageMap:c,onOpenSubAccounts:m,activeSubaccountId:w,onChartContractChange:b})=>{let A=Bt(vi),{screen:x}=Bt(Li),T=Bt(Cs),R=T==null?void 0:T.data,S=Bt(Ts),E=(0,tt.useRef)(null),[Q,L]=(0,tt.useState)(null),D=(0,tt.useRef)(null),q=(0,tt.useRef)(null),K=(0,tt.useRef)(Date.now()),dt=Vr(),[M,Ct]=(0,tt.useState)(!1),O=(0,tt.useRef)(null),ht=(0,tt.useRef)(null),B=(0,tt.useRef)(null),at=(0,tt.useRef)(null),h=(0,tt.useRef)(null),y=(0,tt.useRef)(null),P=(0,tt.useRef)(null),[G,U]=(0,tt.useState)(!1),H=(0,tt.useRef)(!1),vt=(0,tt.useRef)(!!l),X=x==="LARGE",At=Bn({feature:"trade_on_charts_enabled"}),[xt,ut]=(0,tt.useState)(0),{studies:F,settled:Z}=ha(),ct=(0,tt.useRef)(null),mt=xt>0;Aa(O,mt&&F.includes("ttc")),va(O,mt&&F.includes("commodityPulse"));let[it,J]=(0,tt.useState)(0),[wt,lt]=(0,tt.useState)(null),bt=(0,tt.useRef)(new Map),Xt=(0,tt.useRef)(new Map),Mt=(0,tt.useRef)(new Map),Lt=(0,tt.useRef)(new Map),Ft=(0,tt.useRef)(0),oe=(0,tt.useRef)(null),Nt=(0,tt.useRef)(0),pt=(0,tt.useRef)(null),_t=(0,tt.useRef)(null),Jt=(0,tt.useRef)(s),ft=(0,tt.useRef)(i),v=(0,tt.useRef)(b),C=(0,tt.useRef)(t),nt=(0,tt.useRef)(r),yt=(0,tt.useRef)(null),[Zt,ve]=(0,tt.useState)(null),pe=(0,tt.useRef)(!1),ie=(0,tt.useRef)(null),{unit:Ze,isInr:V,isPriceModeInr:k,isMarginModeInr:Ot,futuresPriceMode:jt,futuresInrUsdtText:Ee,USDT_RATE:fe}=ue(),ye=(0,tt.useMemo)(()=>
4{if(!p||!t||(p==null?void 0:p.contract)!==t)return{best_bid:0,best_ask:0};let $=Number(p==null?void 0:p.top_asks)||0,W=Number(p==null?void 0:p.top_bids)||0;return{best_bid:$,best_ask:W}},[p,t]);(0,tt.useEffect)(()=>{Jt.current=s},[s]),(0,tt.useEffect)(()=>{ft.current=i},[i]),(0,tt.useEffect)(()=>{v.current=b},[b]),(0,tt.useEffect)(()=>{C.current=t},[t]),(0,tt.useEffect)(()=>{nt.current=r},[r]),(0,tt.useEffect)(()=>{if(!b||!xt)return;let $=D.current;if(typeof($==null?void 0:$.onSymbolChanged)!="function")return;let W=()=>{var z,Pt;try{let j=Cl({tvSymbol:(z=$.symbol)==null?void 0:z.call($),pageContract:C.current,knownContracts:nt.current});if(!j)return;(Pt=v.current)==null||Pt.call(v,j)}catch(j){wo(j,{extraDetail:"componentBreak",componentName:"chart",message:"Chart symbol change could not be synced to the page",market:"FUTURES"})}},st=null;try{st=$.onSymbolChanged(),st==null||st.subscribe(null,W)}catch{return}return()=>{var z;try{(z=st==null?void 0:st.unsubscribe)==null||z.call(st,null,W)}catch{}}},[xt,b]);let Je=(0,tt.useCallback)(()=>{G&&typeof window!="undefined"&&(_t.current||(_t.current=window.setTimeout(()=>{var $,W;console.log("[tv][index] scheduleTvBrokerFullRefresh()"),_t.current=null;try{($=pt.current)==null||$.ordersFullUpdate()}catch{}try{(W=pt.current)==null||W.positionsFullUpdate()}catch{}},250)))},[G,t,e]);(0,tt.useEffect)(()=>{if(!G||typeof window=="undefined")return;let $=()=>{Je()};return window.addEventListener(vc,$),()=>{if(window.removeEventListener(vc,$),_t.current){try{window.clearTimeout(_t.current)}catch{}_t.current=null}}},[G,Je,t,e]),(0,tt.useEffect)(()=>{let $=vn(xc);typeof $=="boolean"&&U($)},[]),(0,tt.useEffect)(()=>{H.current=G},[G]),(0,tt.useEffect)(()=>{var $,W;if(vt.current=!!l,!l){try{($=pt.current)==null||$.positionsFullUpdate()}catch{}try{(W=pt.current)==null||W.ordersFullUpdate()}catch{}}},[l]),(0,tt.useEffect)(()=>()=>{if(oe.current){try{window.clearTimeout(oe.current)}catch{}oe.current=null}let $=D.current;$&&(bt.current.forEach(W=>{try{$.removeEntity(W)}catch{}}),bt.current.clear(),Xt.current.forEach(W=>{try{$.removeEntity(W)}catch{}}),Xt.current.clear(),Mt.current.forEach(W=>{try{$.removeEntity(W)}catch{}}),Mt.current.clear())},[]),(0,tt.useEffect)(()=>{L(E.current)},[]);let tr=(0,tt.useCallback)($=>{var W,st;U($),H.current=$,Jr(xc,$),I(_.TradeOnChartToggleClicked,{state:$?"on":"off"});try{(W=pt.current)==null||W.positionsFullUpdate()}catch{}try{(st=pt.current)==null||st.ordersFullUpdate()}catch{}},[]),It=(0,tt.useMemo)(()=>js(t,e),[t,e]),Se=(0,tt.useMemo)(()=>{var Ie;let{exchange:$,base:W,quote:st,contract:z}=Me(It),Pt=($||e||"BINANCE").toUpperCase(),j=(W||"").toLowerCase(),Fe=(st||"").toLowerCase();if((!Fe||!j)&&z){let Ce=String(z).toLowerCase(),Le=(Ie=["usdt","inr"].find($e=>Ce.endsWith($e)))!=null?Ie:"";Le&&(Fe=Le,j=Ce.slice(0,-Le.length))}let _e=Array.from(new Set([Fe,"usdt"].filter(Boolean)));return{exchangeKey:Pt,baseLower:j,quoteCandidates:_e}},[It,e]),ms=(0,tt.useMemo)(()=>{var z;let $=(z=wt==null?void 0:wt.exchange)==null?void 0:z.toString().toUpperCase(),st=!$||$===Se.exchangeKey?wt==null?void 0:wt.positions:null;return st?yc({positions:st,exchangeKey:Se.exchangeKey,baseLower:Se.baseLower,quoteCandidates:Se.quoteCandidates}):null},[wt,Se]),Zn=(0,tt.useMemo)(()=>Sc(S,Se),[S,Se]),sr=(0,tt.useMemo)(()=>{let $=(e||"BINANCE").toString().toUpperCase();return(Array.isArray(R)?R:[]).filter(st=>{var Pt;let z=String((Pt=st==null?void 0:st.exchange)!=null?Pt:$).toUpperCase();return!$||z===$})},[e,R]),io=(0,tt.useMemo)(()=>{let $=(e||"BINANCE").toString().toUpperCase(),W=Number(fe),z=Ot&&V&&Number.isFinite(W)&&W>0?W:1,Pt=(sr!=null?sr:[]).map(j=>{var Le,$e,de,Pe,ke,ge,or,ce,De,Ue,er,me;let Fe=String((Le=j==null?void 0:j.base_currency)!=null?Le:"").toLowerCase(),_e=String(($e=j==null?void 0:j.quote_currency)!=null?$e:"usdt").toLowerCase(),Ie=Eo({exchange:$,base:Fe,quote:_e}),Ce=(me=Number((er=(Ue=(De=(ce=(or=(ge=(Pe=(de=j==null?void 0:j.unrealized_pl)==null?void 0:de.value)==null?void 0:Pe.val)!=null?ge:(ke=j==null?void 0:j.unrealized_pl)==null?void 0:ke.val)!=null?or:j==null?void 0:j.unrealized_pl)!=null?ce:j==null?void 0:j.unrealised_pnl)!=null?De:j==null?void 0:j.unrealised_pl)!=null?Ue:j==null?void 0:j.upl)!=null?er:NaN))!=null?me:NaN,He=Number.isFinite(Ce)?Ce*z:NaN;return`${Ie}:${Number.isFinite(He)?He:"nan"}`});return Pt.sort(),Pt.join("|")},[sr,e,Ot,V,fe]);(0,tt.useEffect)(()=>
4{if(!G)return;let $=pt.current;if(!$)return;let W=(e||"BINANCE").toString().toUpperCase(),st=Number(fe),Pt=Ot&&V&&Number.isFinite(st)&&st>0?st:1;(sr!=null?sr:[]).forEach(j=>{var He,Le,$e,de,Pe,ke,ge,or,ce,De,Ue;let Fe=String((He=j==null?void 0:j.base_currency)!=null?He:"").toLowerCase(),_e=String((Le=j==null?void 0:j.quote_currency)!=null?Le:"usdt").toLowerCase(),Ie=Eo({exchange:W,base:Fe,quote:_e}),Ce=Number((Ue=(De=(ce=(or=(ge=(ke=(de=($e=j==null?void 0:j.unrealized_pl)==null?void 0:$e.value)==null?void 0:de.val)!=null?ke:(Pe=j==null?void 0:j.unrealized_pl)==null?void 0:Pe.val)!=null?ge:j==null?void 0:j.unrealized_pl)!=null?or:j==null?void 0:j.unrealised_pnl)!=null?ce:j==null?void 0:j.unrealised_pl)!=null?De:j==null?void 0:j.upl)!=null?Ue:NaN);if(Number.isFinite(Ce))try{$.plUpdate(Ie,Ce*Pt)}catch{}})},[io,G]);let In=(0,tt.useMemo)(()=>{let $=(sr!=null?sr:[]).map(W=>{var Ie,Ce,He,Le,$e,de,Pe,ke,ge,or,ce,De,Ue;let st=String((Ce=(Ie=W==null?void 0:W.exchange)!=null?Ie:e)!=null?Ce:"").toUpperCase(),z=String((He=W==null?void 0:W.base_currency)!=null?He:"").toLowerCase(),Pt=String((Le=W==null?void 0:W.quote_currency)!=null?Le:"usdt").toLowerCase(),j=String(($e=W==null?void 0:W.side)!=null?$e:"").toUpperCase(),Fe=Math.abs(Number((ge=(ke=(Pe=(de=W==null?void 0:W.size)!=null?de:W==null?void 0:W.qty)!=null?Pe:W==null?void 0:W.base_qty)!=null?ke:W==null?void 0:W.position_qty)!=null?ge:0)||0),_e=Number((Ue=(De=(ce=(or=W==null?void 0:W.avg_price)!=null?or:W==null?void 0:W.avg_entry)!=null?ce:W==null?void 0:W.avg_entry_price)!=null?De:W==null?void 0:W.avgPrice)!=null?Ue:0)||0;return`${st}|${z}|${Pt}|${j}|${Fe}|${_e}`});return $.sort(),$.join(";")},[sr,e]);(0,tt.useEffect)(()=>{if(!G||!l)return;let $=(e||"BINANCE").toString().toUpperCase();lt({positions:sr,exchange:$,fetchedAt:Date.now()})},[G,l,e,In,t,sr]),(0,tt.useEffect)(()=>{let $=++Ft.current;(async()=>{var wn,dn,mn,pn,fn,_r;let st=It,z=D.current,Pt=(wn=bt.current.get(st))!=null?wn:null,j=(dn=Xt.current.get(st))!=null?dn:null,Fe=()=>{if(Pt&&z)try{z.removeEntity(Pt)}catch{}if(bt.current.delete(st),j&&z)try{z.removeEntity(j)}catch{}Xt.current.delete(st);let Rt=Mt.current.get(st);if(Rt&&z)try{z.removeEntity(Rt)}catch{}Mt.current.delete(st),Lt.current.delete(st)},_e=()=>{if(z)try{z.getAllShapes().filter(Rt=>(Rt==null?void 0:Rt.name)==="horizontal_line"||(Rt==null?void 0:Rt.name)==="horizontal_ray").forEach(Rt=>{var qr,hr,ir,gn,Wr;try{let xr=z.getShapeById(Rt.id),ar=(qr=xr.getProperties)==null?void 0:qr.call(xr),Ln=(Wr=(ir=ar==null?void 0:ar.text)!=null?ir:(hr=ar==null?void 0:ar.linetoolhorzline)==null?void 0:hr.text)!=null?Wr:(gn=ar==null?void 0:ar.linetoolhorzline)==null?void 0:gn.labelText;xw(Ln)&&z.removeEntity(Rt.id)}catch{}})}catch{}};if(!G||!l){z&&_e(),Fe();return}if(!z)return;let{exchange:Ie,base:Ce,quote:He,contract:Le}=Me(It),$e=(Ie||e||"BINANCE").toUpperCase(),de=(Ce||"").toLowerCase(),Pe=(He||"").toLowerCase();if((!Pe||!de)&&Le){let Rt=String(Le).toLowerCase(),hr=(mn=["usdt","inr"].find(ir=>Rt.endsWith(ir)))!=null?mn:"";hr&&(Pe=hr,de=Rt.slice(0,-hr.length))}let ke=Array.from(new Set([Pe,"usdt"].filter(Boolean))),ge=(pn=wt==null?void 0:wt.exchange)==null?void 0:pn.toString().toUpperCase(),ce=!ge||ge===$e?wt==null?void 0:wt.positions:null;if(!ce){let Rt=Date.now();if(Rt-Nt.current>1500){Nt.current=Rt;try{(fn=pt.current)==null||fn.positionsFullUpdate()}catch{}}return}let De=yc({positions:ce,exchangeKey:$e,baseLower:de,quoteCandidates:ke}),Ue=ii(De),er=Number(fe);if(k&&!(Number.isFinite(er)&&er>0))return;let me=Number.isFinite(Ue)&&Ue>0?k?Ue*er:Ue:NaN;if(!Number.isFinite(me)||me<=0){_e(),Fe();return}if(Pt&&j&&Lt.current.get(st)===me)return;Lt.current.set(st,me),_e();let dr=Math.floor(Date.now()/1e3)-5e4,Ur=()=>({time:dr,price:me}),gr=Pt;if(gr)try{let Rt=z.getShapeById(gr);Rt.setPoints([Ur()]),Rt.bringToFront()}catch{try{z.removeEntity(gr)}catch{}bt.current.delete(st),gr=null}if(!gr)try{let Rt=await z.createShape(Ur(),{shape:"horizontal_ray",lock:!0,disableSelection:!0,disableSave:!0,disableUndo:!0,text:"Liq",overrides:{linecolor:"#FF3A36",linewidth:1,linestyle:2,showPrice:!0,showLabel:!0,textcolor:"#FFFFFF",fontsize:11,bold:!0,backgroundColor:"#FF0033",borderColor:"#FF0033",horzLabelsAlign:"left"}});if($!==Ft.current){try{z.removeEntity(Rt)}catch{}return}gr=Rt,bt.current.set(st,gr)}catch{oe.current||(oe.current=window.setTimeout(()=>{oe.current=null,J(Rt=>Rt+1)},600));return}let br=(_r=Xt.current.get(st))!=null?_r:null;if(br)try{let Rt=z.getShapeById(br);Rt.setPoints([Ur()]),Rt.bringToFront()}catch{try{z.removeEntity(br)}catch{}Xt.current.delete(st),br=null}if(!br)try{let Rt=await z.createShape(Ur(),{shape:"text",lock:!0,disableSelection:!0,disableSave:!0,disableUndo:!0,text:"Liq",overrides:{color:"#FFFFFF",fontsize:12,bold:!1,backgroundColor:"#FF0033",borderColor:"#FF0033",drawBorder:!0,fillBackgroun
4d:!0,fixedSize:!0}});if($!==Ft.current){try{z.removeEntity(Rt)}catch{}return}br=Rt,Xt.current.set(st,br)}catch{}let Br=bw(De),yr=Number.isFinite(Br)&&Br>0?k?Br*er:Br:NaN,un=[{time:dr,price:yr},{time:dr,price:me}];if(Number.isFinite(yr)&&yr>0&&yr!==me){let Rt=Mt.current.get(st);try{if(Rt)z.getShapeById(Rt).setPoints(un);else{let qr=[];z.getAllShapes().forEach(ir=>{var gn;if((ir==null?void 0:ir.name)==="trend_line")try{let Wr=z.getShapeById(ir.id),xr=(gn=Wr.getPoints)==null?void 0:gn.call(Wr);if(!Array.isArray(xr)||xr.length!==2||xr[0].time!==xr[1].time)return;let[ar,Ln]=[xr[0].price,xr[1].price];(Math.abs(ar-yr)<.01&&Math.abs(Ln-me)<.01||Math.abs(ar-me)<.01&&Math.abs(Ln-yr)<.01)&&qr.push(ir.id)}catch{}}),qr.forEach(ir=>{try{z.removeEntity(ir)}catch{}});let hr=await z.createMultipointShape(un,{shape:"trend_line",lock:!0,disableSelection:!0,disableSave:!0,disableUndo:!0,overrides:hw});if(z.getShapeById(hr),$===Ft.current)Mt.current.set(st,hr);else try{z.removeEntity(hr)}catch{}}}catch{Mt.current.delete(st)}}else{let Rt=Mt.current.get(st);if(Rt){try{z.removeEntity(Rt)}catch{}Mt.current.delete(st)}}})()},[wt==null?void 0:wt.fetchedAt,xt,it,It,e,G,l,k,fe]);let ao=(0,tt.useCallback)(async $=>{var z,Pt;let W=Number(o)||0;if(W<=0)return le(be({type:"failure",header:"Order Failed",content:"Last price not available"})),{success:!1};let st=await Bs({symbol:$.symbol,side:$.side,type:"MARKET",qty:$.qty,limitPriceInUsdt:W,isPriceModeInr:k,isInr:V,getLeverageMap:()=>Jt.current,allPrecision:n,tradeConfig:i,getCostExternal:g});if(st.success){let j=await Fs(st,"Market Order Placed");j!=null&&j.skipSuccessToast||le(be({type:"success",header:"Market Order Placed",content:"Your market order was placed successfully"}))}else le(be({type:"failure",header:"Order Failed",content:(Pt=(z=st.error)!=null?z:st.validationErrors)!=null?Pt:"Failed to place order"}));return st},[o,k,V,n,i,g]),lo=(0,tt.useCallback)(async $=>{var z,Pt;let W=_o({priceUi:$.limitPrice,isPriceModeInr:k,usdtRate:fe});if(!Number.isFinite(W)||W<=0)return le(be({type:"failure",header:"Order Failed",content:k?"Exchange rate not available. Please try again.":"Invalid price"})),{success:!1};let st=await Bs({symbol:$.symbol,side:$.side,type:"LIMIT",qty:$.qty,limitPriceInUsdt:W,isPriceModeInr:k,isInr:V,getLeverageMap:()=>Jt.current,allPrecision:n,tradeConfig:i,getCostExternal:g});if(st.success){let j=await Fs(st,"Limit Order Placed");j!=null&&j.skipSuccessToast||le(be({type:"success",header:"Limit Order Placed",content:"Your limit order was placed successfully"}))}else le(be({type:"failure",header:"Order Failed",content:(Pt=(z=st.error)!=null?z:st.validationErrors)!=null?Pt:"Failed to place order"}));return st},[k,V,fe,n,i,g]);(0,tt.useEffect)(()=>{yt.current=async z=>{var Ue,er,me,dr,Ur,gr,br,Br,yr,un,wn,dn,mn,pn,fn;if(!H.current)return!0;if(!l)return le(be({type:"failure",header:"Login Required",content:"Please log in to place orders from chart"})),!0;let Pt=z==null?void 0:z.type;if(Pt!==1&&Pt!==2){let _r=(z==null?void 0:z.side)!==-1;return le(be({type:"failure",header:"Order Not Allowed",content:_r?"Limit Price for Buy Order cannot be greater than the last traded price.":"Limit Price for Sell Order cannot be less than the last traded price."})),!0}let j=(z==null?void 0:z.symbol)||It,Fe=(z==null?void 0:z.side)===-1?"SELL":"BUY",_e=Pt===2?"MARKET":"LIMIT",Ie=Number(_e==="MARKET"?(br=(gr=(Ur=(me=(Ue=z==null?void 0:z.currentQuotes)==null?void 0:Ue.ask)!=null?me:(er=z==null?void 0:z.currentQuotes)==null?void 0:er.bid)!=null?Ur:(dr=z==null?void 0:z.currentQuotes)==null?void 0:dr.trade)!=null?gr:z==null?void 0:z.limitPrice)!=null?br:0:(Br=z==null?void 0:z.limitPrice)!=null?Br:0),Ce=_o({priceUi:Ie,isPriceModeInr:k,usdtRate:fe});if(!Number.isFinite(Ce)||Ce<=0)return le(be({type:"failure",header:"Order Failed",content:k?"Exchange rate not available. Please try again.":"Invalid price"})),!0;let{base:He,quote:Le,contract:$e}=Me(j),de=(dn=(wn=(yr=n==null?void 0:n[$e])==null?void 0:yr.base_precision)!=null?wn:(un=n==null?void 0:n[`${He},${Le}`])==null?void 0:un.base_precision)!=null?dn:3,Pe=Number((mn=i==null?void 0:i.client_market)==null?void 0:mn.min_base_quantity),ke=Math.pow(10,-1*de),ge=Number.isFinite(Pe)&&Pe>0?yn(Pe,de):0,or=ge>0?parseFloat(Number(ge).toFixed(de)).toString():parseFloat(ke.toFixed(de)).toString(),ce=await Bs({symbol
4:j,side:Fe,type:_e,qty:or,limitPriceInUsdt:Ce,isPriceModeInr:k,isInr:V,getLeverageMap:()=>Jt.current,allPrecision:n,tradeConfig:i,getCostExternal:g}),De=`${_e==="LIMIT"?"Limit":"Market"} Order Placed`;if(ce.success){let _r=await Fs(ce,De);_r!=null&&_r.skipSuccessToast||le(be({type:"success",header:De,content:"Your order was placed successfully"}))}else le(be({type:"failure",header:"Order Failed",content:(fn=(pn=ce.error)!=null?pn:ce.validationErrors)!=null?fn:"Failed to place order"}));return!0}},[k,V,fe,n,i,It,l,g]);let ps=(0,tt.useCallback)($=>{$&&$.onChartReady(()=>{var Pt;let W=$.activeChart();$.applyOverrides(Do),X&&At&&Nl($,{isOn:H.current,onToggle:tr}),yl(W,t,e);let st=Date.now()-K.current;xi("componentLoadTime",{loadTime:st,componentName:"chart",market:"FUTURES"}),Ia();let z=()=>{W.executeActionById("chartReset")};if(B.current=z,W.onIntervalChanged().subscribe(null,z),X&&At){let j=Fe=>{H.current&&(pe.current=!0,ve(Fe))};ie.current=j,$.subscribe("onPlusClick",j)}D.current=W,ut(j=>j+1);try{(Pt=pt.current)==null||Pt.positionsFullUpdate()}catch{}})},[tr,x,t,e,dt]),fs=A.isConnected;return(0,tt.useEffect)(()=>{La()},[]),(0,tt.useEffect)(()=>{if(typeof document!="undefined"&&document.getElementById("chart-library")===null){let $=document.createElement("script");$.id="chart-library",$.src=mr("/pro/charting_library/charting_library.js?v=4"),$.onload=()=>Ct(!0),document.body.appendChild($)}else document.getElementById("chart-library")&&Ct(!0)},[]),(0,tt.useEffect)(()=>()=>{var $;if(O.current){try{D.current&&B.current&&D.current.onIntervalChanged().unsubscribe(null,B.current)}catch{}try{ie.current&&O.current.unsubscribe("onPlusClick",ie.current)}catch{}try{Lo(),($=ht.current)==null||$.dispose(),ht.current=null,O.current.remove()}catch{}O.current=null,D.current=null,B.current=null,ie.current=null,pt.current=null}},[]),(0,tt.useEffect)(()=>{var Ie,Ce,He,Le,$e,de,Pe;if(!M||!((Ie=Object.keys(n))!=null&&Ie.length)||!t||!fs||!e||x===null||!D.current&&!Z)return;let $=js(t,e),W=r.map(ke=>js(ke,e)),st=at.current!==null&&at.current!==Ze,z=P.current!==$,Pt=!D.current,j=h.current!==jt,Fe=y.current!==null&&y.current!==Ot,_e=ct.current!==null&&ct.current!==F;if(Pt||st||j||Fe||_e){if(O.current){try{D.current&&B.current&&D.current.onIntervalChanged().unsubscribe(null,B.current)}catch{}B.current=null,Mt.current.clear(),Lo(),(Ce=ht.current)==null||Ce.dispose(),ht.current=null,O.current.remove(),O.current=null,D.current=null,pt.current=null}let ke=Ee(),ge=X&&At?Ll({allPrecision:n,isPriceModeInr:k,isMarginModeInr:Ot,isInr:V,selectedExchange:e,getLeverageMap:()=>Jt.current,tradeConfig:i,getTradeConfig:()=>ft.current,getIsEnabled:()=>H.current&&vt.current,onHost:me=>{pt.current=me}}):void 0,or=X&&At?{configFlags:{supportPositions:!0,supportReversePosition:!1,supportNativeReversePosition:!1,supportClosePosition:!0,supportModifyOrderPrice:!1,supportEditAmount:!0,supportModifyBrackets:!0,supportOrderBrackets:!1,supportPositionBrackets:!0,supportIndividualPositionBrackets:!0,supportModifyPositionBrackets:!0,supportModifyIndividualPositionBrackets:!0,supportCryptoBrackets:!0,supportLevel2Data:!1,supportLeverage:!1,supportLeverageButton:!1},customUI:{showOrderDialog:me=>{var dr;return(dr=yt.current)==null||dr.call(yt,me),Promise.resolve(!0)}}}:void 0,ce=(He=Ws.disabled_features)!=null?He:[],De=X?ko():void 0,Ue=Fo(W,n,q,Ze,k,ke,e);ht.current=Ue;let er={...Ws,disabled_features:ce,context_menu:{items_processor:async(me,dr,Ur)=>pe.current?[]:me},datafeed:Ue,symbol:$,broker_config:or,broker_factory:ge,settings_adapter:De,...F.length?{custom_indicators_getter:ba(F)}:{}};if(O.current=(Le=window.TradingView)!=null&&Le.widget?new window.TradingView.widget(er):null,O.current===null){let me=new Error("Chart Loading Error");wo(me,{extraDetail:"componentBreak",componentName:"chart",message:"Cannot Load Initial Config",market:"FUTURES"})}else xl(O.current),Sl(O.current,t,e),ps(O.current)}else if(D.current)if(!z)($e=q==null?void 0:q.current)==null||$e.call(q),D.current.resetData();else{let ke=D.current;try{(Pe=(de=O.current)==null?void 0:de.closePopupsAndDialogs)==null||Pe.call(de)}catch{}ke.setSymbol($,{dataReady:()=>{ut(ge=>ge+1);try{ke.executeActionById("Chart.PriceScale.ToggleAddOrderPlusButtonVisibility")}catch{}}})}at.current=Ze,P.current=$,h.current=jt,y.current=Ot,ct.current=F},[t,e,fs,n,M,Ze,r,x,ps,k,Ot,jt,Ee,F,Z]),(0,cn.jsxs)("div",{ref:E,className:"tw-relative tw-h-full tw-w-full",children:[(0,cn.jsx)("div",{onClick:vl,id:"chart_container",className:"tw-h-full tw-w-full"}),(0,cn.jsx)(si,{containerEl:Q}),mt&&(0,cn.jsx)(Ta,{tvWidgetRef:O,containerId:"chart_container",enabled:F.includes("trendikaterr"),positionEl:Q}),(0,cn.jsx)("div",{className:"tw-pointer-events-none tw-absolute tw-inset-0",children:G&&X&&At&&(0,cn.jsx)(ei,{containerEl:Q,symbol:It,lastPrice:o,tradeConfig:i,precision:a,isPriceModeInr:k,isMarginModeInr:Ot,isInr:V,isLoggedIn:l,onPlaceMarketOrder:ao,bestBidPrice:ye==null?void 0:ye.best_bid,bestAskPrice:ye==null?void 0:ye.best_ask,getCostExternal:g,leverageMap:s,exchange:e,activeSubaccountId:w,validateLeverage:u,getLeveragePriceFall:d,setLeverageMap:c,onOpenSubAccounts:m,openPosition:ms,openOrders:Zn,markPrice:Number(f)||0})}),G&&X&&At&&(0,cn.jsx)(ri,{containerEl:Q,params:Zt,onClose:()=>{pe.current=!1,ve(null)},symbol:It,lastPrice:o,tradeConfig:i,precision:a,isPriceModeInr:k,isMarginModeInr:Ot,isInr:V,isLoggedIn:l,onPlaceLimitOrder:lo,getCostExternal:g})]})},_h=(0,tt.memo)(vw);var se=N(Qt());Ii();Pc();he();Ne();Oe();Gr();hn();var St=N(Y()),yw=t=>[{id:"pair",title:"Pair",state:"default",is_selected:!1,width:"tw-w-[190px]"},{id:"price",title:"Price",state:"default",is_selected:!1,width:"tw-w-[100px]"},{id:"funding",title:"Funding Rate",state:"default",is_selected:!1,width:"tw-w-[85px]"},{id:"volume",title:`Vol (${t})`,state:"desc",is_selected:!0,width:"tw-w-[80px]"},{id:"change",title:"%Change",state:"default",is_selected:!1,width:"tw-w-[70px]"}],Sw=(t,e)=>{let[r,n]=(0,se.useState)(yw(t));(0,se.useEffect)(()=>{n(o=>o.map(i=>i.id==="volume"?{...i,title:`Vol (${e?"INR":"USDT"})`,width:e?"tw-w-[90px]":"tw-w-[80px]"}:i.id==="price"?{...i,width:e?"tw-w-[85px]":"tw-w-[100px]"}:i))},[t,e]);let s=(0,se.useCallback)(o=>{n(i=>i.map(l=>l.id===o?{...l,is_selected:l.state!=="asc",state:l.state==="default"?"desc":l.state==="desc"?"asc":"default"}:{...l,is_selected:!1,state:"default"}))},[]);return{sortStatus:r,updateSortStatus:s}},Cw=t=>{let e=(0,se.useRef)(null),r=(0,se.useCallback)(()=>{e.current!==null&&clearTimeout(e.current),e.current=setTimeout(()=>{I(_.FuturesTradeCoinListShown),t(!0)},200)},[t]),n=(0,se.useCallback)(()=>{e.current!==null&&clearTimeout(e.current),e.current=setTimeout(()=>{t(!1)},300)},[t]);return{handleMouseEnter:r,handleMouseLeave:n}},Nw=({sortStatus:t,updateSortStatus:e})=>(0,St.jsx)("div",{id:"futures-coin-list-sort",className:"tw-flex tw-w-full tw-gap-x-3 tw-border-b tw-border-pro-gray-200 tw-p-2 tw-text-xxs tw-font-medium tw-text-gray-600",children:t.map(r=>(0,St.jsxs)("div",{onClick:()=>e(r.id),className:ne("tw-flex tw-cursor-pointer tw-items-center tw-gap-x-1 first:tw-justify-center",r==null?void 0:r.width),children:[(0,St.jsx)("div",{className:ne("tw-text-gray-600",r.is_selected===!0?"tw-text-gold-500":""),children:r.title}),(0,St.jsx)(et,{height:"tw-h-3.5",width:"tw-w-2",name:r.is_selected&&r.state==="desc"?"sort-desc":r.is_selected&&r.state==="asc"?"sort-asc":"sort-default"})]},`${r.id}-sort`))}),Aw=({searchContracts:t,setSearchContracts:e})=>{let r=(0,se.useRef)(null),n=()=>{I(_.FuturesCoinListingSearch,{value:t}),r.current&&r.current.focus()},s=()=>{I(_.CoinListingSearchCrossClicked,{Search:t}),e("")};return(0,St.jsxs)("div",{id:"futures-coin-list-search",className:"tw-relative tw-h-12 tw-w-full tw-rounded-t tw-bg-pro-gray-100 tw-p-2",children:[(0,St.jsx)("div",{className:"tw-absolute tw-z-10 tw-flex tw-h-8 tw-items-center tw-px-2",children:(0,St.jsx)(et,{width:"tw-w-4",height:"tw-h-4",name:"contract-list-search-icon"})}),(0,St.jsxs)("div",{className:"tw-relative tw-flex tw-h-full",children:[(0,St.jsx)("input",{ref:r,className:"tw-h-full tw-w-full tw-rounded tw-border tw-border-pro-gray-200 tw-bg-gray-800 tw-px-2 tw-py-2 tw-pl-8 tw-text-xs tw-text-white tw-placeholder-gray-600 tw-outline-none",type:"text",placeholder:"Search contracts",autoComplete:"off",value:t,onChange:o=>{let i=o.target.value.replace(/^\s+/,"");e(i)},autoFocus:!1,onFocus:n,maxLength:15}),t!==""&&(0,St.jsx)("div",{className:"tw-absolute tw-right-3 tw-flex tw-h-full tw-w-[10px] tw-cursor-pointer tw-items-center",onClick:s,children:(0,St.jsx)(xs,{name:fi})})]})]})},Tw=({base:t,quote:e,isInr:r,selected:n,ticker:s,markPrice:o,precision:i,config:a,onSelect:l,futuresInrUsdtC
4onverter:p,futuresInrUsdtVolConverter:f,selected_contract_price:g})=>{var T,R,S;let u=Number(s==null?void 0:s.percentageChange)>0,d=i==null?void 0:i.limit_precision,c=n&&g?g:s==null?void 0:s.lastPrice;c=p(Number(c),!0,d);let m=f(Number(s==null?void 0:s.quoteVolume),!0,2),w=Number(o==null?void 0:o.funding_rate),b=Number.isFinite(w)?w:0,A=r?Vt.inrPercent(b*100,4):Vt.usdtPercent(b*100,4),x=r?Vt.inrPercent(Number(s==null?void 0:s.percentageChange),2):Vt.usdtPercent(Number(s==null?void 0:s.percentageChange),2);return(0,St.jsxs)("div",{onClick:l,className:ne("tw-flex tw-h-14 tw-w-full tw-cursor-pointer tw-gap-x-3 tw-border-b tw-border-black-01 tw-px-2 tw-py-2 tw-text-xs tw-font-medium",{"tw-bg-gold-1000/50 tw-text-white":n,"tw-text-gray-400 hover:tw-bg-black-01":!n}),children:[(0,St.jsxs)("div",{className:"tw-flex tw-h-full tw-w-[190px] tw-gap-x-2 tw-truncate",children:[(0,St.jsx)("div",{className:"tw-flex tw-h-full tw-w-5 tw-items-center tw-justify-center",children:(0,St.jsx)("img",{src:(T=a==null?void 0:a.logo)!=null?T:"",alt:"",className:"tw-h-[20px] tw-w-[20px]"})}),(0,St.jsxs)("div",{className:"tw-flex tw-h-full tw-w-auto tw-flex-col tw-justify-between",children:[(0,St.jsxs)("div",{className:"tw-flex tw-items-center",children:[(0,St.jsx)("div",{children:t==null?void 0:t.toUpperCase()}),(0,St.jsxs)("div",{className:`tw-text-xs ${n?"tw-text-gray-400":"tw-text-gray-600"}`,children:["/",e==null?void 0:e.toUpperCase()]}),(0,St.jsx)("div",{className:"tw-ml-1 tw-rounded tw-bg-pro-gold-1100 tw-px-1 tw-text-xxs tw-text-pro-gold-500",children:`${a==null?void 0:a.max_leverage}x`})]}),(0,St.jsxs)("div",{className:`tw-flex tw-gap-x-0.5 tw-text-xxs ${n?"tw-text-gray-500":"tw-text-gray-700"}`,children:[(0,St.jsx)("p",{children:(()=>{let E=(a==null?void 0:a.name)||(t==null?void 0:t.toUpperCase())||"";return E.length>10?`${E.slice(0,7)}...`:E})()}),(0,St.jsx)("p",{children:"|"}),(0,St.jsx)("p",{children:da(((R=a==null?void 0:a.category)==null?void 0:R[0])||wa)})]})]})]}),(0,St.jsx)("div",{className:ne("tw-h-full tw-w-[100px] tw-truncate",{"tw-w-[85px]":r}),children:(0,St.jsx)("div",{className:"tw-tabular-nums",children:s!=null&&s.lastPrice?c:"--"})}),(0,St.jsxs)("div",{className:"tw-flex tw-h-full tw-w-[85px] tw-flex-col tw-justify-between tw-truncate",children:[(0,St.jsx)("div",{className:"tw-tabular-nums",children:A}),(0,St.jsxs)("div",{className:`tw-flex tw-items-center tw-gap-x-0.5 tw-text-xxs tw-font-normal ${n?"tw-text-gray-500":"tw-text-gray-700"}`,children:[(0,St.jsx)("div",{children:(0,St.jsx)(et,{name:"countdown-timer",width:"tw-w-3",height:"tw-h-3"})}),(0,St.jsx)("div",{className:"tw-tabular-nums",children:(S=o==null?void 0:o.funding_countdown)!=null?S:"--"})]})]}),(0,St.jsx)("div",{className:ne("tw-h-full tw-w-[80px] tw-truncate",{"tw-w-[90px]":r}),children:(0,St.jsx)("div",{className:"tw-tabular-nums",children:s!=null&&s.quoteVolume?m:"--"})}),(0,St.jsx)("div",{className:"tw-h-full tw-w-[70px] tw-truncate",children:(0,St.jsx)("div",{className:`tw-tabular-nums ${u?"tw-text-pro-green-500":"tw-text-pro-red-500"}`,children:s!=null&&s.percentageChange?`${u?"+":""}${x}`:"--"})})]})},Ew=({contracts:t,contractConfig:e})=>{var r;return(0,St.jsxs)("div",{className:"tw-flex tw-h-full tw-flex-col tw-items-center",children:[(0,St.jsx)("img",{className:"tw-max-h-20",src:ka,alt:"drawer"}),(r=t==null?void 0:t.slice(0,16))==null?void 0:r.map((n,s)=>{var o,i;return(0,St.jsx)("div",{className:"tw-flex tw-h-14 tw-items-center tw-justify-center",children:(0,St.jsx)("img",{src:(i=(o=e==null?void 0:e[n==null?void 0:n.toLowerCase()])==null?void 0:o.logo)!=null?i:"",alt:"",className:"tw-h-[20px] tw-w-[20px]"})},`coin-list-web-closed-${s}`)})]})},_w=({is_loading:t,ticker_data:e,mark_price_data:r,updateSelectedContract:n,selected_contract:s,selected_contract_price:o,all_contracts:i,all_precision:a,contract_config:l,isHovered:p,setIsHovered:f})=>{let[g,u]=(0,se.useState)(""),[d,c]=(0,se.useState)([]),[m,w]=(0,se.useState)(Tr),b=(0,se.useRef)(null),{handleMouseEnter:A,handleMouseLeave:x}=Cw(f),{unit:T,isInr:R,futuresInrUsdtConverter:S,futuresInrUsdtVolConverter:E,isPriceModeInr:Q,futuresInrUsdtText:L}=ue(),{sortStatus:D,updateSortStatus:q}=Sw(T,Q),[K,dt]=(0,se.useState)(0),M=(0,se.useCallback)((h,y)=>h-y,[]),Ct=(0,se.useMemo)(()=>{var y;let h=new Set;for(let P of i!=null?i:[]){let G=(y=l==null?void 0:l[P==null?void 0:P.toLowerCase()])==null?void 0:y.category;if(Array.isArray(G))for(let U of G)h.add(U)}return[{id:Tr,label:"All"},...ks(h)]},[i,l]);(0,se.useEffect)(()=>{Ct.some(h=>h.id===m)||w(Tr)},[Ct,m]);let O=(0,se.useMemo)(()=>e?Object.keys(e).length>10:!1,[e]);(0,se.useEffect)(()=>
4{if((i==null?void 0:i.length)>0&&O){let h=i==null?void 0:i.sort((y,P)=>{var H,vt;let G=Number((H=e==null?void 0:e[y])==null?void 0:H.quoteVolume)||0,U=Number((vt=e==null?void 0:e[P])==null?void 0:vt.quoteVolume)||0;return G?U?M(U,G):-1:1});c(h)}},[O,i,e,M]),(0,se.useEffect)(()=>{if((i==null?void 0:i.length)>0){let h=D.find(P=>P.is_selected),y=[];(h==null?void 0:h.id)==="pair"?y=[...i].sort((P,G)=>{var U,H;return P[0]?G[0]?(h==null?void 0:h.state)==="desc"?(U=G[0])==null?void 0:U.localeCompare(P[0]):(H=P[0])==null?void 0:H.localeCompare(G[0]):-1:1}):(h==null?void 0:h.id)==="volume"?y=[...i].sort((P,G)=>{var vt,X;let U=Number((vt=e==null?void 0:e[P])==null?void 0:vt.quoteVolume)||0,H=Number((X=e==null?void 0:e[G])==null?void 0:X.quoteVolume)||0;return U?H?(h==null?void 0:h.state)==="desc"?M(H,U):M(U,H):-1:1}):(h==null?void 0:h.id)==="price"?y=[...i].sort((P,G)=>{var vt,X;let U=Number((vt=e==null?void 0:e[P])==null?void 0:vt.lastPrice)||0,H=Number((X=e==null?void 0:e[G])==null?void 0:X.lastPrice)||0;return U?H?(h==null?void 0:h.state)==="desc"?M(H,U):M(U,H):-1:1}):(h==null?void 0:h.id)==="change"?y=[...i].sort((P,G)=>{var vt,X;let U=Number((vt=e==null?void 0:e[P])==null?void 0:vt.percentageChange)||0,H=Number((X=e==null?void 0:e[G])==null?void 0:X.percentageChange)||0;return U?H?(h==null?void 0:h.state)==="desc"?M(H,U):M(U,H):-1:1}):(h==null?void 0:h.id)==="funding"?y=[...i].sort((P,G)=>{var At,xt;let U=Number((At=r==null?void 0:r[P])==null?void 0:At.funding_rate),H=Number((xt=r==null?void 0:r[G])==null?void 0:xt.funding_rate),vt=Number.isFinite(U)?U:0,X=Number.isFinite(H)?H:0;return(h==null?void 0:h.state)==="desc"?M(X,vt):M(vt,X)}):y=[...i].sort((P,G)=>{var vt,X;let U=Number((vt=e==null?void 0:e[P])==null?void 0:vt.quoteVolume)||0,H=Number((X=e==null?void 0:e[G])==null?void 0:X.quoteVolume)||0;return U?H?M(H,U):-1:1}),c(y)}},[i,e,r,D,M]),(0,se.useEffect)(()=>{D.forEach(h=>{h.state!=="default"&&h.is_selected&&I(_.FuturesCoinLisitingSortingClick,{type:h.title,state:h.state})})},[D]);let ht=(0,se.useCallback)(h=>{var P;if(m===Tr)return!0;let y=(P=l==null?void 0:l[h==null?void 0:h.toLowerCase()])==null?void 0:P.category;return Array.isArray(y)&&y.includes(m)},[m,l]),B=(0,se.useMemo)(()=>{var U,H,vt;let h=g.replace(/^\s+/g,"").toLowerCase(),y=R?"inr":"usdt",P=R?"usdt":"inr";if(h===y)return(U=d==null?void 0:d.filter(ht))==null?void 0:U.filter(X=>!Un(l==null?void 0:l[X==null?void 0:X.toLowerCase()]));let G=h;return R?G=G.replace(/\/inr$|,inr$|inr$/i,"").replace(/\/usdt$|,usdt$|usdt$/i,"").replace(/^\s+|\/+|,+/g,""):G=G.replace(/\/usdt$|,usdt$|usdt$/i,"").replace(/\/inr$|,inr$|inr$/i,"").replace(/^\s+|\/+|,+/g,""),h===P||h.includes(`/${P}`)||h.endsWith(P)?[]:(vt=(H=d==null?void 0:d.filter(X=>{var F,Z,ct,mt;let At=X==null?void 0:X.toLowerCase(),xt=((Z=(F=X.split(","))==null?void 0:F[0])==null?void 0:Z.toLowerCase())||"",ut=((mt=(ct=l==null?void 0:l[At])==null?void 0:ct.name)==null?void 0:mt.toLowerCase())||"";return h===""||xt.indexOf(G)>=0||At.replace(",","").includes(G)||ut.indexOf(G)>=0}))==null?void 0:H.filter(ht))==null?void 0:vt.filter(X=>!Un(l==null?void 0:l[X==null?void 0:X.toLowerCase()]))},[d,g,ht,l,R]),at=(0,se.useCallback)(h=>{var P;let y=B==null?void 0:B[h];return y?(0,St.jsx)(Tw,{isInr:R,quote:L(),base:(P=y==null?void 0:y.split(","))==null?void 0:P[0],futuresInrUsdtConverter:S,futuresInrUsdtVolConverter:E,selected:s===(y==null?void 0:y.toLowerCase()),selected_contract_price:o,ticker:e==null?void 0:e[y],markPrice:r==null?void 0:r[y],precision:a==null?void 0:a[y==null?void 0:y.toLowerCase()],config:l==null?void 0:l[y==null?void 0:y.toLowerCase()],onSelect:()=>n(y==null?void 0:y.toLowerCase())},`${y}-coin-list`):null},[B,R,L,S,E,s,o,e,r,a,l,n]);return(0,St.jsx)("div",{className:"tw-relative tw-h-full",children:(0,St.jsx)("div",{className:ne("tw-absolute tw-top-0 tw-z-40 tw-h-full tw-bg-black tw-transition-all tw-ease-in-out",{"tw-w-[590px] tw-border-r tw-border-black-04":p,"tw-w-[36px]":!p,"tw-w-[590px]":p&&R}),onMouseEnter:A,onMouseLeave:x,style:{boxShadow:p?"8px 0px 20px 0px rgba(0, 0, 0, 0.45)":"none"}
4,children:p?(0,St.jsx)("div",{className:"tw-block tw-h-full",children:(0,St.jsxs)("div",{className:"tw-flex tw-h-full tw-w-full tw-flex-col tw-rounded tw-bg-black-01",children:[(0,St.jsx)(Aw,{searchContracts:g,setSearchContracts:u}),(0,St.jsx)(Ks,{activeTab:m,setActiveTab:w,enableTabs:Ct}),(0,St.jsx)(Nw,{sortStatus:D,updateSortStatus:q}),!t&&e!==null&&(0,St.jsx)("div",{ref:b,className:"tw-w-full tw-max-w-full tw-flex-1 tw-bg-black",children:(0,St.jsx)(Vs,{style:{height:"100%"},totalCount:(B==null?void 0:B.length)||0,itemContent:at,overscan:200,className:"no-scrollbar",initialTopMostItemIndex:K,rangeChanged:h=>{dt(h.startIndex)}})})]})}):(0,St.jsx)(Ew,{contracts:i,contractConfig:l})})})},Hh=(0,se.memo)(_w);var oo=N(Qt());pr();var kr=N(Y()),Iw=({handleOpenQuiz:t})=>(0,kr.jsxs)("div",{className:"tw-flex tw-h-[440px] tw-w-full tw-flex-col tw-justify-between tw-text-[#e9ebee] lg:tw-h-[468px] ",children:[(0,kr.jsxs)("div",{children:[(0,kr.jsx)("h1",{className:"tw-h-[34px] tw-text-center tw-text-[19px] lg:tw-text-2xl",children:"Welcome to Coinswitch PRO Futures"}),(0,kr.jsx)("div",{className:"tw-mt-2 tw-flex tw-h-[152px] tw-w-full tw-items-center tw-justify-center",children:(0,kr.jsx)("img",{src:mr("/pro/assets/images/futures/quiz-onboard.png"),alt:"",width:"99%"})})]}),(0,kr.jsx)("div",{className:"tw-min-h-[1px] tw-w-full tw-bg-black-05"}),(0,kr.jsxs)("div",{className:"tw-flex tw-w-full tw-flex-col tw-items-center",children:[(0,kr.jsx)("p",{className:"tw-text-center tw-text-3xl tw-font-medium tw-text-gold-500 lg:tw-max-w-[424px]",children:"Are you a PRO Futures Trader? Take this quiz to find out"}),(0,kr.jsx)("button",{onClick:t,className:"tw-mt-7 tw-h-[48px] tw-w-full tw-rounded-md tw-bg-[#CDA954] tw-py-2 tw-text-sm tw-font-medium tw-uppercase tw-text-black  lg:tw-mt-[42px] lg:tw-max-w-[424px]",children:"start quiz"})]})]}),Cc=Iw;var ds=N(Qt());Lr();hn();var wr=N(Y()),Lw=({handleImportantMessage:t,questions:e})=>{let[r,n]=(0,ds.useState)(!1),[s,o]=(0,ds.useState)({currentQuestionIndex:0,isShow:!1,isSubmit:!1,quizData:e.map(()=>({selectedOption:null,isCorrect:!1}))}),i=u=>{let{currentQuestionIndex:d,quizData:c}=s,m=[...c];m[d].selectedOption=u,m[d].isCorrect=u===e[d].correct_answer,o({...s,isShow:u===e[d].correct_answer,quizData:m}),u===e[d].correct_answer?n(!1):n(!0)},a=()=>{let{currentQuestionIndex:u,quizData:d}=s,c=u+1;c<e.length&&o({...s,currentQuestionIndex:c,isShow:d[c].isCorrect})},l=()=>{let{currentQuestionIndex:u}=s,d=u-1;d>=0&&o({...s,currentQuestionIndex:d,isShow:!0})},p=u=>u===e[s.currentQuestionIndex].correct_answer,f=s.quizData[s.currentQuestionIndex],g=e[s.currentQuestionIndex];return(0,ds.useEffect)(()=>{o({...s,isSubmit:s.quizData.every(u=>u.isCorrect)})},[s.isShow,s.isSubmit]),(0,wr.jsxs)("div",{className:"tw-h-[440px] tw-w-full lg:tw-h-[385px]",children:[(0,wr.jsxs)("div",{className:"tw-mb-3 tw-flex tw-items-center tw-justify-between",children:[(0,wr.jsx)("h1",{className:"tw-text-2xl",children:"Futures Quiz"}),r&&(0,wr.jsx)("div",{className:"tw-text-[11px] tw-font-bold tw-text-pro-gold-300",children:"Refer CoinSwitch blogs"})]}),(0,wr.jsxs)("div",{className:"tw-h-[343px] tw-w-full tw-overflow-y-scroll tw-py-2 tw-text-base lg:tw-h-[290px]",children:[(0,wr.jsxs)("p",{className:"tw-text-base tw-font-semibold tw-text-[#eaecef]",children:[g.id,". ",g.question]}),(0,wr.jsx)("div",{className:"tw-mt-4",children:g.options.map((u,d)=>(0,wr.jsx)(qi,{value:d,label:u,onChange:c=>{i(c)},selected:f.selectedOption,selectedColor:f.selectedOption!==null&&p(d)?"#26D08D":"#e74258",labelClass:ne(f.selectedOption!==null&&p(d)?"tw-text-[#26D08D]":d===f.selectedOption&&!p(d)?"tw-text-[#e74258]":"tw-text-[#EDF2F7]","tw-m-0 "),deselectedColor:f.selectedOption!==null&&p(d)?"#26D08D":"#fff",size:"sm",wrapperClass:"tw-items-start tw-mb-2 tw-w-full ",radioClass:"tw-mt-1"},u))}),"hint"in g&&(0,wr.jsx)("p",{className:"tw-mt-6 tw-text-sm tw-text-[#848e9c] lg:tw-mt-4",children:(g==null?void 0:g.hint)&&"Hint : "+(g==null?void 0:g.hint)})]}),(0,wr.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between",children:[s.currentQuestionIndex>0&&(0,wr.jsx)("button",{className:"tw-flex tw-h-[48px]  tw-w-[140px] tw-items-center tw-justify-center tw-rounded-md tw-border tw-border-[#CDA954] tw-px-4 tw-py-2 tw-text-sm tw-font-medium tw-uppercase tw-text-[#CDA954] lg:tw-w-[200px]",onClick:l,children:"previous"}),s.currentQuestionIndex<e.length-1&&(0,wr.jsx)("button",{className:`tw-flex tw-h-[48px] tw-w-[140px] tw-items-center tw-justify-center tw-rounded-md tw-bg-[#CDA954] tw-px-4 tw-py-2 tw-text-sm tw-font-medium tw-uppercase tw-text-black lg:tw-w-[200px] ${s.currentQuestionIndex===0&&"tw-ml-auto"} ${s.isShow?"tw-bg-[#CDA954] tw-text-black":"tw-cursor-not-allowed tw-bg-[#474d56] tw-text-[#848e9c]"}`,onClick:s.isShow?a:void 0,disabled:s.isShow===null,children:"next"}),s.currentQuestionIndex===e.length-1&&(0,wr.jsx)("button",{className:`tw-h-[48px] tw-w-[140px] tw-rounded-md tw-bg-[#CDA954] tw-px-4  tw-py-2 tw-text-sm tw-font-medium tw-uppercase tw-text-black lg:tw-w-[200px] ${s.isSubmit?"tw-bg-[#CDA954] tw-text-black":"tw-cursor-not-allowed tw-bg-[#474d56] tw-text-[#848e9c]"} ${s.currentQuestionIndex===e.length-1&&"tw-ml-auto"}`,onClick:s.isSubmit?t:void 0,disabled:!s.isSubmit,children:"submit"})]})]})},Nc=Lw;Ii();var ai="https://files-pro.coinswitch.co/cspro/1790767973354/build/_assets/linear-gradient-RHOI42AX.svg";var Ac=[{id:1,question:"What is a futures Virtual Digital Asset (VDA) contract?",options:["A contract to buy or sell a Virtual Digital Asset (VDA) at a future date","A contract that instantly grants ownership of a Virtual Digital Asset (VDA)","A contract for immediate delivery of a Virtual Digital Asset (VDA)","A contract can only be traded on weekends"],correct_answer:0},{id:2,question:"What is the initial deposit required to open a position in a futures Virtual Digital Asset (VDA) contract called?",options:["Premium","Margin","Commision","Spread"],correct_answer:1},{id:3,question:"What is the role of leverage in Virtual Digital Asset (VDA) futures trading?",options:["It increases the initial investment required to open a futures position.","It reduces the potential returns on a futures investment.","It allows traders to control a larger position size with a smaller amount of capital.","It eliminates the risk of market fluctuations in futures contracts."],correct_answer:2},{id:4,question:"In a futures Virtual Digital Asset (VDA) contract, if the mark price is 50 and the liquidation price is 40, what is the percentage loss that would trigger a liquidation of the position?",options:["20%","10%","25%","5%"],correct_answer:0},{id:5,question:"A trader shorts 3 Virtual Digital Asset (VDA) futures contracts at 1,500 each and later covers the position at 1,480 each. What is the total profit or loss on the position?",options:["3
400 loss","900 profit","900 loss","60 profit"],correct_answer:3},{id:6,question:"What is Funding Rate?",options:["The funding rate in futures adjusts periodically to ensure that the price of perpetual contracts closely tracks the spot price of the underlying asset.","The funding rate in futures is irrelevant and does not affect the price of perpetual contracts.","The funding rate is calculated based on the performance of cryptocurrencies unrelated to the underlying asset.","The funding rate only applies to spot trading and has no impact on futures contracts."],correct_answer:0},{id:7,question:"What is Insurance Clearance?",options:["Insurance Clearance is applied if a trader manually closes their position, not if it\u2019s automatically liquidated.","Insurance Clearance is fixed and does not vary based on market conditions or size of the position.","Insurance Clearance is a charged when a position is liquidated due to insufficient margin to maintain the position. It\u2019s used to cover the costs associated with the liquidation process.","Insurance Clearance is the fee refunded to the trader when a position is liquidated."],correct_answer:2}];Oe();Ne();pr();Uc();var Xe=N(Y()),Ow=({setIsOpenState:t,handleUpdateUserQuizStatus:e})=>{let[r,n]=(0,oo.useState)({isQuiz:!1,isVideo:!0,importantMessage:!1,isConfirmationModalOpen:!1}),s=()=>{t(!1),I(_.FuturesQuizCrossClicked)},o=()=>{e(),Jr("isQuizCompleted",!0),t(!1),n(i=>({...i,importantMessage:!1})),I(_.FuturesIUnderstandButtonClicked),bo({page:"pro_inr_futures_consent",value:!0}),bo({page:"pro_inr_futures_tootip_shown",value:!0})};return(0,oo.useEffect)(()=>{I(_.FuturesQuizPopupShow)},[]),(0,Xe.jsxs)("div",{className:"tw-fixed tw-inset-0 tw-z-[60] tw-flex tw-h-full tw-w-full tw-items-center tw-justify-center tw-overscroll-contain tw-backdrop-blur-sm",children:[!r.importantMessage&&(0,Xe.jsxs)("div",{className:"tw-mx-auto tw-flex tw-w-[342px] tw-select-none tw-flex-col tw-gap-2 tw-rounded-lg tw-bg-[#2D3748] tw-px-6 tw-py-4 tw-text-[#EDF2F7] lg:tw-w-[672px]",children:[(0,Xe.jsx)("div",{className:"tw-flex tw-h-8 tw-w-full tw-items-center tw-justify-end",children:(0,Xe.jsx)("button",{onClick:s,children:(0,Xe.jsx)(xs,{name:gi.CLOSE_ICON})})}),r.isQuiz&&(0,Xe.jsx)(Nc,{questions:Ac,handleImportantMessage:()=>{n(i=>({...i,importantMessage:!0,isQuiz:!1})),I(_.FuturesQuizSubmitButtonClicked)}}),r.isVideo&&(0,Xe.jsx)(Cc,{handleOpenQuiz:()=>{n(i=>({...i,isQuiz:!0,isVideo:!1})),I(_.FuturesStartQuizButtonClicked)}})]}),r.importantMessage&&(0,Xe.jsxs)("div",{className:"tw-relative tw-mx-auto tw-h-[495px] tw-w-[90%] tw-overflow-y-scroll tw-bg-[#121319] tw-px-10 tw-py-4 tw-text-[#EDF2F7] lg:tw-w-[400px]",children:[(0,Xe.jsx)("img",{src:ai,alt:"linear-gradient",className:"tw-absolute tw-left-0 tw-top-[94px] tw-opacity-40"}),(0,Xe.jsx)("img",{src:ai,alt:"linear-gradient",className:"tw-absolute tw-left-0 tw-top-[121px] tw-opacity-40"}),(0,Xe.jsx)("p",{className:"tw-text-3xl",children:"Important"}),(0,Xe.jsxs)("p",{className:"tw-relative tw-z-10 tw-py-3 tw-text-base tw-leading-6",children:["There is a high element of risk while trading on crypto futures. You have the potential to earn high profits but also face the risk of suffering significant losses. In the event of an extreme price movement, there is a chance that all your locked balance will be liquidated. Please analyze your investment objectives and risk appetite carefully before going ahead. CoinSwitch will not be liable for any losses suffered.",(0,Xe.jsx)("a",{onClick:()=>{I(_.FuturesTermAndConditionClicked)},className:"tw-ml-1 tw-text-pro-gold-500",target:"_black",href:Ea,children:"T&C"})]}),(0,Xe.jsx)("div",{className:"tw-my-6 tw-h-[1px] tw-w-full tw-bg-gray-600"}),(0,Xe.jsx)("button",{onClick:o,className:"tw-h-[48px] tw-w-full tw-rounded-md tw-bg-[#CDA954] tw-py-2 tw-text-sm tw-font-medium tw-uppercase tw-text-black",children:"i understand"})]})]})},mx=Ow;Lc();Ir();vr();Zr();Oe();Ne();Lr();vo();pr();var Dr=N(Y()),Mw=({updateSignupDialog:t,openLoginDialog:e})=>{let r=Vr(),[n]=Xr(Yr),s=jr(Xi),{t:o,ready:i}=wi("translations"),a=()=>{e(),I(_.TradeWidgetLoginButtonClicked)},l=()=>{I(_.TradeWidgetSignUpClicked),t({new_stage:ji,should_open:!0})},p=()=>
4{if(!n.is_kyc_complete&&!(n!=null&&n.is_kyc_expired)){if(I(_.ClickCompleKycTrade),Hr()){Ls.goToAppKycPage();return}s()}else if(!n.is_kyc_complete&&(n!=null&&n.is_kyc_expired)){if(Hr()){Ls.goToAppKycPage();return}r(`${$r.profile_page.url}?section=re-kyc`)}else if(!n.is_bank_linked){if(I(_.ClickLinkBankTrade),Hr()){Ls.goToAppBankPage();return}s()}};return i?(0,Dr.jsx)(Dr.Fragment,{children:n!=null&&n.is_logged_in?(0,Dr.jsx)(qt,{className:"tw-grow tw-rounded tw-p-0 tw-uppercase",onClick:()=>{p()},children:!(n!=null&&n.is_kyc_complete)||!(n!=null&&n.is_pmla_done)?o("bottom_nav.complete_kyc"):o("bottom_nav.add_bank_details")}):(0,Dr.jsxs)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between tw-gap-2",children:[(0,Dr.jsx)(qt,{className:"tw-flex-1 tw-rounded tw-pl-0 tw-pr-0 tw-uppercase tw-text-black-01",onClick:()=>{a()},children:o("bottom_nav.login")}),(0,Dr.jsx)(qt,{variant:qt.Variants.Outlined,className:"tw-flex-1 tw-rounded tw-pl-0 tw-pr-0 tw-uppercase",onClick:()=>{l()},children:o("bottom_nav.sign_up")})]})}):(0,Dr.jsx)(Dr.Fragment,{})},Tx=Mw;var Xn=N(Qt());he();Lr();var Tc=N(Ec());Oe();Ne();Oi();vr();pr();var we=N(Y()),Rw=({})=>{let[t,e]=(0,Xn.useState)(!1),r=()=>{I(_.RewardsCardClicked),Tc.isMobile?e(!0):window.open("/pro/wallet?tab=rewards","_blank")},n=Bt(Pi),s=(0,Xn.useMemo)(()=>{let o={config:n,feature:"futures_rewards",fallback:!1};return Wi(o)},[n]);return(0,Xn.useEffect)(()=>{I(_.RewardsCrossClicked)},[t]),s?(0,we.jsxs)("div",{className:"tw-cursor-pointer tw-rounded-[4px] tw-bg-pro-black-200",children:[(0,we.jsxs)("div",{onClick:r,className:"tw-rounded-[4px] tw-px-3 tw-py-2",style:{background:"linear-gradient(65.3deg, rgba(205, 169, 84, 0) 14.92%, rgba(205, 169, 84, 0.3) 73.15%)"},children:[(0,we.jsxs)("div",{className:"tw-flex tw-h-[26px] tw-items-center tw-justify-between",children:[(0,we.jsx)("div",{className:"tw-text-[13px] tw-font-medium tw-leading-[22px] tw-text-gray-200",children:"Rewards up to 50,000 USDT"}),(0,we.jsx)(et,{name:"info-icon",width:"tw-w-5",height:"tw-h-5"})]}),(0,we.jsx)("div",{className:"tw-text-[12px] tw-font-normal tw-leading-5 tw-tracking-[0.03em] tw-text-gray-400",children:"By trading more on futures"})]}),(0,we.jsxs)(ze,{open:t,onOpenChange:e,children:[(0,we.jsx)(ze.Overlay,{className:"tw-bg-black-06/70"}),(0,we.jsxs)(ze.Content,{className:"tw-h-fit tw-w-full tw-rounded-t-2xl tw-border tw-border-highligh-gray tw-bg-black-01",children:[(0,we.jsxs)("div",{className:"tw-flex tw-h-14 tw-w-full tw-items-center tw-justify-between tw-border-b tw-border-pro-gray-200 tw-p-4",children:[(0,we.jsx)("p",{className:"tw-text-lg tw-font-semibold tw-leading-6 tw-text-gray-200",children:"Trading Rewards"}),(0,we.jsx)(ze.Close,{className:"tw-h-fit tw-w-fit tw-cursor-pointer",children:(0,we.jsx)(et,{width:"tw-w-5",height:"tw-h-5",name:"cross-gray"})})]}),(0,we.jsxs)("div",{children:[(0,we.jsxs)("div",{className:"tw-p-4",children:[(0,we.jsx)("div",{className:"tw-mb-1 tw-text-[16
4px] tw-font-medium tw-leading-[24px] tw-text-white",children:"Get USDT rewards on trading more on futures"}),(0,we.jsx)("div",{className:"tw-text-[12px] tw-font-normal tw-leading-[20px] tw-tracking-[0.03em] tw-text-gray-500",children:"Get USDT based on your monthly trading volume"})]}),(0,we.jsxs)("div",{className:"tw-pb-4 tw-pt-2 tw-text-[12px] tw-font-medium tw-leading-[20px] tw-tracking-[0.03em]",children:[(0,we.jsxs)("div",{className:"tw-flex tw-justify-between tw-bg-pro-black-200 tw-px-4 tw-py-2 tw-text-gray-600",children:[(0,we.jsx)("div",{children:"30 Day Trading Volume"}),(0,we.jsx)("div",{children:"Reward"})]}),Fw.map(o=>(0,we.jsxs)("div",{className:"tw-flex tw-justify-between tw-border-b tw-border-b-black-06 tw-px-4 tw-py-2 tw-text-gray-200",children:[(0,we.jsx)("div",{children:o.vol}),(0,we.jsx)("div",{children:o.reward})]}))]})]})]})]})]}):null},Fw=[{vol:"500 K",reward:"50 USDT"},{vol:"1 MN",reward:"120 USDT"},{vol:"2 MN",reward:"280 USDT"},{vol:"5 MN",reward:"750 USDT"},{vol:"10 MN",reward:"2000 USDT"},{vol:"20 MN",reward:"5000 USDT"},{vol:"50 MN",reward:"15000 USDT"},{vol:"150 MN",reward:"50000 USDT"}],Fx=Rw;export{Ye as a,On as b,Oo as c,Ys as d,Mo as e,Gs as f,Ro as g,ja as h,Jc as i,Zd as j,Hs as k,zs as l,km as m,Qm as n,dl as o,vp as p,Dp as q,Hp as r,tf as s,Sf as t,Cf as u,Nf as v,zn as w,Rl as x,to as y,Hl as z,zl as A,Z0 as B,Ql as C,Jo as D,ac as E,_h as F,Hh as G,Fx as H,mx as I,Tx as J};

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.