PageSourceSearch

https://zebpay.com/app/_next/static/chunks/pages/subAccount-6d63b006b596648d.js

js zebpay.com collected 2026-10-02 02:26:45 UTC 356,073 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9943],{13208:(e,t,r)=>{"use strict";r.d(t,{dM:()=>c,lH:()=>s,nE:()=>d});var n=r(9484),i=function(e){return e.priceDescending="priceDescending",e.volumeDescending="volumeDescending",e.volumeWithTooltipDescending="volumeWithTooltipDescending",e}(i||{}),l=function(e){return e.currentValueDescending="currentValueDescending",e}(l||{}),o=function(e){return e.balanceDescending="balanceDescending",e.annualYieldDescending="annualYieldDescending",e}(o||{}),a=function(e){return e.idDescending="idDescending",e}(a||{});let s={[i.priceDescending]:{field:n.Mq.PRICE,direction:n.UE.DESC},[i.volumeDescending]:{field:n.Mq.VOLUME,direction:n.UE.DESC},[i.volumeWithTooltipDescending]:{field:n.Mq.VOLUME_WITH_TOOLTIP,direction:n.UE.DESC}},c={[l.currentValueDescending]:{field:n.Mq.CURRENT_VALUE,direction:n.UE.DESC}},d={[o.balanceDescending]:{field:n.Mq.BALANCE,direction:n.UE.DESC},[o.annualYieldDescending]:{field:n.Mq.ANNUAL_YIELD,direction:n.UE.DESC}};a.idDescending,n.Mq.ID,n.UE.DESC},83518:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/subAccount",function(){return r(85923)}])},85923:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>pr});var n={};r.r(n),r.d(n,{button:()=>lZ,cancelButton:()=>l0,checkbox:()=>lx,close:()=>l1,closeContainer:()=>l2,closePositionHeader:()=>l4,coinInfoTooltip:()=>ot,coinNameStyle:()=>oT,coinTooltip:()=>on,conversionBox:()=>oi,conversionContainer:()=>of,conversionInput:()=>op,conversionSubtitle:()=>oo,conversionTitle:()=>ol,convertedUNrealised:()=>oh,dash:()=>lG,editIcon:()=>o_,highlight:()=>og,iconEdit:()=>lz,infoContainer:()=>ov,infoIcon:()=>l5,infoText:()=>ob,infoTitle:()=>oA,input:()=>oE,inputText:()=>oI,leverage:()=>lj,leverageAndType:()=>lk,lightColor:()=>oc,marginBox:()=>lX,marginConversionSubtitle:()=>os,marginConversionTitle:()=>oa,percentMarginRatio:()=>lH,percentPnl:()=>lM,pnLIcon:()=>lq,popUpContainer:()=>l$,popUpsection:()=>lQ,popperSubtitle:()=>oS,positionType:()=>lL,quoteAsset:()=>oe,quoteAssetColor:()=>ou,realisedPnL:()=>lU,selectedCounts:()=>lJ,separator:()=>lW,subtitle:()=>or,tableHeader:()=>l8,tooltip:()=>om,tooltipHeader:()=>l6,tooltipLarge:()=>l7,tooltipStyle:()=>l9,tooltipSubtext:()=>l3,tooltipTitle:()=>oy,topUpInfoIcon:()=>oC,tpSl:()=>lK,tpSlContainer:()=>lV,whiteColor:()=>od});var i=r(14232),l=r(89099),o=r.n(l),a=r(3496),s=r(31777),c=r(27149),d=r(66284),u=r(38993),p=r(62540);let h=(0,u.AH)([a.vE.flexJustifiedBetween,a.Wp.g(16),{padding:"0 2.5rem",borderTop:"1.5px solid ".concat(a.Tj.Zeb_Solid_Dark_Blue),borderBottom:"1.5px solid ".concat(a.Tj.Zeb_Solid_Dark_Blue),alignItems:"flex-end",flexWrap:"wrap",minHeight:a.Wp.remConverter(50)}],"",""),g=(0,u.AH)({boxShadow:a.Tj.Zeb_Effects_Shadow_Hover,zIndex:1},"",""),m={name:"1duj7gx",styles:"align-self:flex-end"},v=(0,u.AH)([(0,p.sM)(12),a.Wp.ptb(8),{alignSelf:"center",height:a.Wp.remConverter(48)}],"",""),A=(0,u.AH)({backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(8),height:a.Wp.remConverter(34),width:a.Wp.remConverter(34),padding:"".concat(a.Wp.remConverter(2)," 0 0 ").concat(a.Wp.remConverter(2)),cursor:"pointer"},"","");var b=r(43700),y=r(68640),f=r(83652),_=r(47028),S=r(80025),T=r(18153);function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let I=function(e){return e.VIEW_STATEMENT="VIEW_STATEMENT",e.COACHMARK="COACHMARK",e.CREATE_SUB_ACCOUNT="CREATE_SUB_ACCOUNT",e.TRANSFER_FUNDS="TRANSFER_FUNDS",e.EXPORT_AUDIT_LOGS="EXPORT_AUDIT_LOGS",e.API_DETAILS="API_DETAILS",e.CREATE_API_KEYS="CREATE_API_KEYS",e}({}),D=e=>{let{selectedTab:t,handleTabChange:r,handleButtonClick:n,isExportingLogs:l=!1,showShadow:o=!1,showCoachmarkWalkthrough:d=!1,coachHighlightTarget:u,coachmarkSegment:p=_.hC.IDLE}=e,C=(0,s.d4)(e=>
1e.shared.general.hideSubAccountValuesFlag),D=(0,s.d4)(e=>e.shared.general.hideValuesFlag),P=(0,s.d4)(e=>{let{subAccountsNew:t}=e;return t.countSummary}),O=[c.C$.DASHBOARD,c.C$.ASSETS_FIAT,c.C$.ASSETS_CRYPTO,c.C$.API_MANAGEMENT,c.C$.AUDIT_LOGS].includes(t),Y=(0,i.useMemo)(()=>c.Kb.map(e=>E(E({},e),{},{style:d&&t===e.tab?S.GZ:void 0})),[d,t]);return(0,T.FD)("div",{css:[h,o&&g,"",""],children:[(0,T.Y)(a.tU,{type:"primary",tabsList:Y,onChange:e=>r(e),selectedTab:t,style:m}),O&&(0,T.FD)("div",{css:v,children:[t===c.C$.DASHBOARD&&(0,T.FD)(T.FK,{children:[(0,T.Y)(a.L5,{icon:"blog",iconSize:18,boxStyle:A,onClick:()=>n(I.VIEW_STATEMENT)}),(0,T.Y)("div",{id:(0,_.gM)(_.fU.STEP_11_COACHMARK_TUTORIAL),css:[u===_.fU.STEP_11_COACHMARK_TUTORIAL&&S.iQ,"",""],children:(0,T.Y)(a.L5,{icon:"help-2",iconSize:18,boxStyle:A,onClick:()=>n(I.COACHMARK)})}),(0,T.Y)("div",{id:(0,_.gM)(_.fU.STEP_1_DASHBOARD_CREATE_SUB_ACCOUNT),css:[u===_.fU.STEP_1_DASHBOARD_CREATE_SUB_ACCOUNT&&S.iQ,"",""],children:(0,T.Y)(a.$n,{type:"primary",size:"small",onClick:()=>n(I.CREATE_SUB_ACCOUNT),disabled:null===P,children:"CREATE SUB-ACCOUNT"})})]}),t===c.C$.ASSETS_FIAT&&(0,T.FD)(T.FK,{children:[(0,T.Y)(f.C6,{activeIconIndex:+!C,icons:b.Y$,onChange:e=>(0,y.qn)(!e)}),(0,T.Y)(a.$n,{type:"primary",size:"small",onClick:()=>n(I.TRANSFER_FUNDS),children:"Transfer Funds"})]}),t===c.C$.API_MANAGEMENT&&(0,T.FD)(T.FK,{children:[(0,T.Y)("div",{id:(0,_.gM)(_.fU.STEP_6_API_MANAGEMENT_API_DETAILS),css:[u===_.fU.STEP_6_API_MANAGEMENT_API_DETAILS&&S.iQ,"",""],children:(0,T.Y)(a.$n,{type:"secondary",size:"small",onClick:()=>n(I.API_DETAILS),children:"API Details"})}),(0,T.Y)(a.$n,{type:"primary",size:"small",onClick:()=>n(I.CREATE_API_KEYS),children:"Create API Keys"})]}),t===c.C$.ASSETS_CRYPTO&&(0,T.Y)(f.C6,{activeIconIndex:+!D,icons:b.Y$,onChange:e=>(0,y.Vv)(!e)}),t===c.C$.AUDIT_LOGS&&(0,T.Y)(a.$n,{type:"primary",size:"small",loading:l,disabled:l,onClick:()=>n(I.EXPORT_AUDIT_LOGS),width:119,children:"Export as CSV"})]})]})};function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let Y={name:"1fttcpj",styles:"display:flex;flex-direction:column"},w=(0,u.AH)([(0,p.wh)(4),a.Wp.pl(16),a.Wp.widthPercentage(100)],"",""),F=(0,u.AH)([a.p0.B5_12_regular,a.Wp.widthPercentage(100),p.gO],"",""),R=(0,u.AH)([a.p0.B6_10_regular,a.vE.textFaded,a.Wp.widthPercentage(100),p.gO],"",""),N=(0,u.AH)([a.p0.B5_12_regular,a.Wp.widthPercentage(100),p.gO],"",""),B=(0,u.AH)([a.p0.B5_12_regular,a.vE.textFaded,a.Wp.widthPercentage(100),p.gO],"",""),x=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,a.Wp.pb(12)],"",""),k=(0,u.AH)({padding:a.Wp.remConverter(12),borderRadius:a.Wp.remConverter(12),background:a.Tj.Zeb_Solid_Dark_Blue},"","");var j=r(54722),W=r(9484),L=r(44899);function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}let H=(0,u.AH)([a.vE.flexJustifiedBetween,a.Wp.g(12),{flexWrap:"wrap"}],"",""),U=e=>{var t,r,n,i,l,o,a;let{isLoading:s,countSummary:c,style:d,coachHighlightTarget:u}=e;return(0,T.FD)("div",{css:[H,d,"",""],children:[(0,T.Y)(q,{title:"Sub-Account Usage",value:"".concat((null!=(t=null==c?void 0:c.activeAccount)?t:0)+(null!=(r=null==c?void 0:c.pendingAccount)?r:0),"/").concat(null!=(n=null==c?void 0:c.totalSubAccount)?n:0),icon:"team",isLoading:s,showBorder:u===_.fU.STEP_2_DASHBOARD_STATS,coachHighlightTarget:(0,_.gM)(_.fU.STEP_2_DASHBOARD_STATS)}),(0,T.Y)(q,{title:"Active",value:null!=(i=null==c?void 0:c.activeAccount)?i:0,icon:"success",isLoading:s,showBorder:u===_.fU.STEP_2_DASHBOARD_STATS}),(0,T.Y)(q,{title:"Pending",value:null!=(l=null==c?void 0:c.pendingAccount)?l:0,icon:"instant-buy-sell",isLoading:s,showBorder:u===_.fU.STEP_2_DASHBOARD_STATS}),(0,T.Y)(q,{title:"Freeze",value:null!=(o=null==c?void 0:c.freezeAccount)?o:0,icon:"pair",isLoading:s,showBorder:u===_.fU.STEP_2_DASHBOARD_STATS}),(0,T.Y)(q,{title:"Deleted",value:null!=(a=null==c?void 0:c.deleteAccount)?a:0,icon:"circle-cross",isLoading:s,showBorder:u===_.fU.STEP_2_DASHBOARD_STATS})]})},q=e=>{let{title:t,value:r,icon:n,isLoading:i,coachHighlightTarget:l,showBorder:o}=e;return(0,T.FD)(f.$G,{containerPadding:[16],alignVertical:!0,gap:12,style:(0,u.AH)(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?M(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({flex:1,minWidth:a.Wp.remConverter(185),maxWidth:"50%"},o&&S.oL),"",""),id:l,showBorder:o,children:[(0,T.FD)("div",{css:[a.vE.flexJustifiedBetween,a.Wp.g(12),a.vE.flexAlignCenter,"",""],children:[(0,T.Y)("span",{css:[a.p0.B5_12_regular,a.Tj.Zeb_Solid_Light_Blue,"",""],children:t}),(0,T.Y)(a.L5,{icon:n,iconSize:18,boxStyle:(0,u.AH)({width:30,height:30,borderRadius:"50%",backgroundColor:a.Tj.Zeb_BG_Light_Blue},"","")})]}),(0,T.Y)(f.lG,{isLoading:i,height:22,width:50,children:(0,T.Y)("div",{css:[a.p0.B2_20_semibold,"",""],children:r})})]})},Z=(0,u.AH)([a.p0.B5_12_regular,a.Wp.ptb(8),{color:a.Tj.Zeb_Solid_Light_Blue,marginBottom:a.Wp.remConverter(8)}],"",""),V=(0,u.AH)({display:"flex",flexWrap:"wrap",gap:a.Wp.remConverter(12)},"",""),K=(0,u.AH)({display:"flex",alignItems:"center",gap:a.Wp.remConverter(8)},"",""),G=(0,u.AH)({width:a.Wp.remConverter(20),height:a.Wp.remConverter(20),borderRadius:"50%",objectFit:"cover"},"","");var z=r(99283);let X=e=>{let{recentSearches:t=[],recentCoinSearches:r=[],onSearchClick:n,onCoinSearchClick:i,align:l="left",style:o}=e,s=t.length>0,c=r.length>0;return s||c?(0,T.FD)("div",{css:[(0,u.AH)({position:"absolute",top:"100%",["left"===l?"left":"right"]:0,marginTop:a.Wp.remConverter(8),zIndex:1e3,width:"100%",maxWidth:a.Wp.remConverter(320),backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),borderRadius:a.Wp.remConverter(8),padding:a.Wp.remConverter(12),boxShadow:"0px 8px 8px -4px #0c0c1d"},"",""),o,"",""],children:[(0,T.Y)("div",{css:Z,children:"Recent Search"}),(0,T.FD)("div",{css:V,children:[s&&t.map((e,t)=>(0,T.Y)(f.$G,{bgColor:z.Tj.Zeb_Solid_BG_Blue,containerPadding:[8],onClick:()=>null==n?void 0:n(e),children:(0,T.Y)("span",{css:[a.p0.B5_12_semibold,"",""],children:e})},"text-".concat(t))),c&&r.map((e,t)=>(0,T.Y)(f.$G,{bgColor:z.Tj.Zeb_Solid_BG_Blue,containerPadding:[8,12],onClick:()=>null==i?void 0:i(e),children:(0,T.FD)("div",{css:K,children:[(0,T.Y)("img",{src:e.icon,alt:e.coinCode,css:G}),(0,T.Y)("span",{css:[a.p0.B5_12_semibold,"",""],children:e.pair})]})},"coin-".concat(t)))]})]}):null},$=e=>{if(!e)return[];try{let t=localStorage.getItem(e);if(!t)return[];return JSON.parse(t)}catch(e){return[]}},Q=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3;if(t.trim()&&e)try{let n=$(e).filter(e=>e!==t),i=[t,...n].slice(0,r);localStorage.setItem(e,JSON.stringify(i))}catch(e){}},J=e=>{if(!e)return[];try{let t=localStorage.getItem(e);if(!t)return[];return JSON.parse(t)}catch(e){return[]}};var ee=r(49496);let et=function(e){return e.SUB_ACCOUNTS="subAccounts_recentSearches",e.ASSETS_FIAT="assetsFiat_recentSearches",e.ASSETS_CRYPTO="assetsCrypto_recentSearches",e.ASSETS_CRYPTO_COINS="assetsCrypto_recentCoinSearches",e}({}),er=e=>{let{value:t,onChange:r,placeholder:n="Search",align:l="left",recentSearchesKey:o,searchInputStyles:s,recentSearchDropdownStyles:c,containerStyles:d,coinSearchMode:u=!1,coinSearchesKey:p,onCoinSearchClick:h}=e,{0:g,1:m}=(0,i.useState)(!1),{0:v,1:A}=(0,i.useState)([]),{0:b,1:y}=(0,i.useState)([]),f=(0,i.useRef)(null);(0,i.useEffect)(()=>{u&&p?y(J(p)):A($(o))},[o,u,p]),(0,i.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&(!u&&t&&t.trim()&&(Q(o,t.trim()),A($(o))),m(!1))};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[t,o,u]);let _=u?g&&!t&&b.length>0:g&&!t&&v.length>0;return(0,T.FD)("div",{ref:f,css:["position:relative;",d,"",""],onClick:()=>{t||(m(!0),u&&p?y(J(p)):A($(o)))},children:[(0,T.Y)(a.DO,{value:t,onChange:e=>{r(e.value),e.value?m(!1):(m(!0),u&&p?y(J(p)):A($(o)))},placeholder:n,customDarkBgcolor:a.Tj.Zeb_Solid_Dark_Blue,onClear:()=>r(""),style:s||(0,ee.Rt)()}),_&&(0,T.Y)(X,{recentSearches:u?void 0:v,recentCoinSearches:u?b:void 0,onSearchClick:u?void 0:e=>{r(e),m(!1)},onCoinSearchClick:u?e=>{r(e.coinCode),m(!1),null==h||h(e)}:void 0,align:l,style:c}
1)]})};var en=r(55133),ei=r(61141),el=r(25852),eo=r(21917);let ea=e=>{let{title:t,value:r,leadingIcon:n,leadingImg:i,leadingIconImgStyle:l,trailingIcon:o,trailingImg:s,trailingIconImgStyle:c,onClick:d,valueStyle:h,currency:g,currencyStyle:m}=e;return(0,T.FD)("div",{css:a.vE.flexJustifiedBetween,children:[(0,T.Y)(f.kU,{text:t,textStyle:(0,u.AH)([a.p0.B4_14_regular,a.vE.textFaded],"",""),leadingIcon:n,leadingImg:i,leadingIconImgStyle:l,trailingIcon:o,trailingImg:s,trailingIconImgStyle:c,onTrailingIconClick:d}),(0,T.FD)("div",{css:[(0,p.sM)(4),ee.Xv,h,"",""],children:[r&&(0,T.Y)("span",{children:r}),g&&(0,T.Y)("span",{css:[ee.Xv,m,"",""],children:g})]})]})};var es=r(90731);let ec=e=>{let{accountData:t,screen:r}=e,n=(0,i.useMemo)(()=>{var e,n;let i={title:"editDetails"===r?"Current Email":"Email Address",value:(null==t?void 0:t.email)||"",icon:"email"},l={title:"Label Name",value:(null==t?void 0:t.label)||"",icon:"pan"},o={title:"Account ID",value:(null==t?void 0:t.accountId)||"",icon:"facelock"},s={title:"Balance",value:(0,L.uY)((null==t?void 0:t.overallBalance)||0,t.currency,es.m9),icon:"wallet",currency:(null==t?void 0:t.currency)||""},c={title:"P&L",value:(0,T.Y)("span",{css:(()=>{if(t.overallPnl)return t.overallPnl>0?(0,u.AH)({color:a.Tj.Zeb_Solid_Green},"",""):t.overallPnl<0?(0,u.AH)({color:a.Tj.Zeb_Solid_Red},"",""):void 0})(),children:(e=>"".concat(e>0?"↑ ":e<0?"↓ ":"- ").concat(Math.abs(e).toFixed(2),"%"))((null==t?void 0:t.overallPnl)||0)}),icon:"max-supply",currency:""},d={title:"Current Status",value:(0,T.Y)(a.YD,{type:(0,j.HT)(null!=(e=null==t?void 0:t.accountStatus)?e:0),size:"small",children:(0,j.N4)(null!=(n=null==t?void 0:t.accountStatus)?n:0)}),icon:"pair"};switch(r){case"editDetails":return[i,l];case"freeze":return[l,i,o,s,c];case"unfreeze":return[l,i,o,s];case"delete":return[l,i,o,s,d]}},[r,t]);return(0,T.Y)(f.$G,{bgColor:a.Tj.Zeb_Solid_Dark_Blue,containerPadding:[16,16,12,12],gap:8,alignVertical:!0,children:null==n?void 0:n.map(e=>(0,T.Y)(ea,{title:e.title,value:e.value,leadingIcon:e.icon,leadingIconImgStyle:(0,p.Kk)(16,a.Tj.Zeb_Solid_Light_Blue),currency:e.currency},e.icon))})};var ed=r(87005);let eu=e=>{let{title:t="Checklist",items:r,isChecklistCompleted:n,isNegativeBalance:i}=e;return(0,T.FD)(f.$G,{bgColor:a.Tj.Zeb_Solid_Dark_Blue,containerPadding:[12],gap:12,alignVertical:!0,children:[(0,T.FD)("div",{css:[a.vE.flexColumn,"",""],children:[(0,T.Y)("h3",{css:[a.p0.B3_16_semibold,"",""],children:t}),(0,T.Y)("p",{css:[a.p0.B4_14_regular,{color:n?a.Tj.Zeb_Solid_Green:a.Tj.Zeb_Solid_Yellow},"",""],children:n?i?"No active trades found.":"No active trades or balance found. You can freeze this Sub-Account.":"Ensure all items below are settled before freezing the Sub-Account."})]}),(0,T.Y)(a.cG,{spacing:0,color:a.Tj.Zeb_Solid_BG_Blue}),r.map(e=>(0,T.Y)(ea,{title:e.label,value:e.value,leadingIcon:e.isCompleted?void 0:"info",leadingImg:e.isCompleted?ed.A.ic_circle_tick_filled:void 0,leadingIconImgStyle:e.isCompleted?(0,p.hj)(16,16):(0,p.Kk)(16,a.Tj.Zeb_Solid_Yellow),trailingIcon:e.isCompleted?void 0:"arrow-right",trailingIconImgStyle:(0,p.Kk)(16,a.Tj.Zeb_Solid_Bright_Blue),onClick:e.isCompleted?void 0:e.onClick,currency:e.currency},e.id))]})};var ep=r(59510),eh=r(59963),eg=r(97251);function em(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ev(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?em(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):em(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let eA=function(e){return e.FETCH_FREEZE_DETAILS="fetchFreezeDetails",e.CONSENT="consent",e.VERIFYING="verifying",e}({}),eb=e=>{var t,r,n,o,s,c,d,u,h,g,m;let{onClose:v,accountData:A}=e,b=(0,l.useRouter)(),{0:y,1:_}=(0,i.useState)(!1),{0:S,1:C}=(0,i.useState)(!1),{0:E,1:I}=(0,i.useState)(null),{0:D,1:P}=(0,i.useState)(eA.FETCH_FREEZE_DETAILS),O=A.accountId.toString(),Y=(e,t)=>
1{null==v||v();let r=new URLSearchParams(ev({[eg.X.TAB]:e,[eg.X.SUB_ACCOUNT_ID]:O},t));b.push("/subAccount?".concat(r.toString()))},w=[{id:"positions",label:"Positions",value:null!=(t=null==E?void 0:E.positions)?t:0,isCompleted:(null!=(r=null==E?void 0:E.positions)?r:0)==0,onClick:()=>Y("assets-crypto",{[eg.X.ASSET_TYPE]:"futures"})},{id:"assetsHolding",label:"Assets Holding",value:(null==E||null==(n=E.assetHolding)?void 0:n.toLowerCase())==="yes"?"Yes":"No",isCompleted:(null==E||null==(o=E.assetHolding)?void 0:o.toLowerCase())==="no",onClick:()=>Y("assets-crypto")},{id:"openOrders",label:"Open Orders",value:null!=(s=null==E?void 0:E.openOrders)?s:0,isCompleted:(null!=(c=null==E?void 0:E.openOrders)?c:0)==0,onClick:()=>Y("orders")},{id:"collateralLocked",label:"Collateral Locked",value:(0,L.uY)(null!=(d=null==E?void 0:E.collateral)?d:0,A.currency,es.m9),isCompleted:(null!=(u=null==E?void 0:E.collateral)?u:0)==0,currency:A.currency,onClick:()=>Y("assets-crypto")}];(0,i.useEffect)(()=>{(async()=>{let e=await (0,ep.py)({subAccountId:A.accountId});(null==e?void 0:e.statusCode)===200?(I(e.data),P(eA.CONSENT)):((0,eh.A)({type:"error",title:"Error",description:(null==e?void 0:e.statusDescription)||"
1Unable to fetch freeze details. Please try again."}),null==v||v())})()},[]);let F=()=>A.overallBalance<0||A.overallBalance>0&&!y||!S,R=async()=>{if(!F()){P(eA.VERIFYING);try{let e=await (0,ep.fK)({subAccountId:A.accountId,transferFundsToMaster:y});(null==e?void 0:e.statusCode)===200?((0,eh.A)({title:"Sub-Account Frozen!",description:"The ".concat(A.label," Sub-Account has been frozen successfully."),type:"success",duration:8}),(0,ep.lc)(A.accountId,j.CX.Freeze,A.accountStatus,y?{overallBalance:0}:void 0),(0,ep.nk)(),null==v||v()):((0,eh.A)({title:"Error",description:(null==e?void 0:e.statusDescription)||"Error occurred while freezing Sub-Account. Please try again.",type:"error",duration:8}),P(eA.CONSENT))}catch(e){console.error(e),(0,eh.A)({title:"Error",description:"Something went wrong. Please try again.",type:"error",duration:8}),P(eA.CONSENT)}}},N=(0,T.FD)("div",{css:(0,p.wh)(8),children:[(null!=(h=Number(null==E?void 0:E.balance))?h:A.overallBalance>0)?(0,T.Y)(f.Is,{label:"Entire balance will be transferred to the Master Account.",checked:y,value:"transfer-consent",onChange:e=>{let{checked:t}=e;return _(t)},style:a.Wp.widthPercentage(100)}):null,(0,T.Y)(f.Is,{label:"I agree to freeze this Sub-Account & restrict its access.",checked:S,value:"freeze-consent",onChange:e=>{let{checked:t}=e;return C(t)},style:a.Wp.widthPercentage(100)})]});return D===eA.VERIFYING||D===eA.FETCH_FREEZE_DETAILS?(0,T.Y)(f.fq,{text:"Processing Your Request"}):(0,T.Y)(f.Ry,{header:"Freeze Sub-Account",footerContent:N,primaryButtonText:"Freeze Sub-Account",primaryButtonClick:R,disablePrimaryBtn:F(),padding:"medium",spaceBtwContentAndCTA:20,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(12),p.TH,"",""],children:[A.overallBalance<0?(0,T.Y)(f.L7,{title:"Note: Please settle negative balance before freezing the account.",type:f.$$.INFO,allowAction:!1,style:a.Wp.p(12)}
1):null,(0,T.Y)(ec,{accountData:ev(ev({},A),{},{overallBalance:null!=(g=Number(null==E?void 0:E.balance))?g:A.overallBalance,overallPnl:null!=(m=null==E?void 0:E.pnL)?m:A.overallPnl}),screen:"freeze"}),(0,T.Y)(eu,{isChecklistCompleted:w.every(e=>e.isCompleted),items:w,isNegativeBalance:A.overallBalance<0}),(0,T.Y)(f.vS,{title:"Important Note",allowedList:["All API keys will be disabled.","You can reactivate the account anytime."]})]})})};var ey=r(3482);function ef(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function e_(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ef(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ef(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}"".concat(a.Wp.remConverter(8)," ").concat(a.Wp.remConverter(32)),a.Wp.remConverter(16);let eS=(0,u.AH)({display:"flex",flexWrap:"wrap",gap:a.Wp.remConverter(12)},"",""),eT=(0,u.AH)({minWidth:a.Wp.remConverter(125),maxWidth:"calc(33% - ".concat(a.Wp.remConverter(6),")")},"",""),eC=(0,u.AH)(e_(e_({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"","");var eE=r(98778);let eI=e=>{let{accountData:t,permissionsList:r,onUpdatePermissionsClick:n,onUnfreezeClick:l}=e,{0:o,1:s}=(0,i.useState)(!1),c=(0,T.Y)("div",{css:(0,p.wh)(8),children:(0,T.Y)(f.Is,{label:"I hereby provide my consent to un-freeze this Sub-Account.",checked:o,value:"unfreeze-consent",onChange:e=>{let{checked:t}=e;return s(t)},style:a.Wp.widthPercentage(100)})});return(0,T.Y)(ey.A,{header:"Unfreeze Sub-Account",footerContent:c,primaryButtonText:"Unfreeze Sub-Account",primaryButtonClick:l,disablePrimaryBtn:!o,padding:"medium",spaceBtwContentAndCTA:20,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(12),"",""],children:[(0,T.Y)(ec,{accountData:t,screen:"unfreeze"}),(0,T.Y)(f.vS,{title:"Important Note",allowedList:["All existing API keys need to be regenerated.","All permissions will be reactivated.","System may take a few seconds to sync updated access."]}),(0,T.FD)("div",{css:(0,p.wh)(12),children:[(0,T.FD)("div",{css:[a.vE.flexJustifiedBetween,a.vE.flexAlignCenter,"",""],children:[(0,T.Y)("span",{css:[a.p0.B3_16_semibold,"",""],children:"Previous Permissions"}),(0,T.Y)(a.$n,{type:"link",onClick:n,children:"Update"})]}),(0,T.Y)(f.$G,{containerPadding:[12,16],gap:12,style:eS,children:r.length>0?r.map(e=>(0,T.Y)(f.kU,{text:e.permissionName,textStyle:eC,leadingImg:ed.A.ic_circle_tick_filled,leadingIconImgStyle:(0,p.hj)(16,16),containerStyle:eT},e.permissionId)):(0,T.Y)("div",{css:eE.wo,children:"No permissions assigned to this Sub-Account"})})]})]})})};function eD(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function eP(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?eD(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):eD(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let eO=(0,u.AH)({display:"flex",alignItems:"center",justifyContent:"space-between",padding:a.Wp.remConverter(16),backgroundColor:"rgba(249, 195, 92, 0.08)",border:"0.5px solid ".concat(a.Tj.Zeb_Solid_Yellow),borderRadius:a.Wp.remConverter(8),width:"100%",cursor:"pointer"},"",""),eY=(0,u.AH)({display:"flex",flexDirection:"column",gap:a.Wp.remConverter(2),flex:1},"",""),ew=(0,u.AH)({display:"flex",alignItems:"center",gap:a.Wp.remConverter(8)},"",""),eF=(0,u.AH)({width:a.Wp.remConverter(16),height:a.Wp.remConverter(16),color:a.Tj.Zeb_Solid_Yellow},"",""),eR=(0,u.AH)(eP(eP({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_Yellow}),"",""),eN=(0,u.AH)(eP(eP({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_White,lineHeight:a.Wp.remConverter(18),margin:0}),"",""),eB=(0,u.AH)({width:a.Wp.remConverter(24),height:a.Wp.remConverter(24),color:a.Tj.Zeb_Solid_Yellow},"",""),ex=e=>{let{id:t,name:r,img:n,enabled:i,locked:l,infoMessage:o,onInfoMessageClick:s,onToggle:c}=e;return(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.FD)("div",{css:a.vE.flexJustifiedBetween,children:[(0,T.Y)(f.kU,{text:r,textStyle:(0,u.AH)([a.p0.B4_14_regular],"",""),leadingImg:n,leadingIconImgStyle:(0,p.hj)(20,20),leadingIconSpace:12}),(0,T.Y)(a.dO,{isSelected:i,onChange:()=>c(t),id:"permission-switch",isLocked:l,showIcon:!0})]}),o&&(0,T.Y)(f.kU,{text:o,textStyle:(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Yellow}],"",""),trailingIcon:s?"arrow-right":void 0,trailingIconImgStyle:(0,p.Kk)(16,a.Tj.Zeb_Solid_Yellow),onTrailingIconClick:s,containerStyle:a.Wp.widthPercentage(90)})]})};var ek=r(89830);let ej=e=>{let{permissions:t,selectedPermissionIds:r,isMarginTradingEnabled:n,onPermissionToggle:l,onBack:o}=e,s=e=>{switch(e){case"quicktrade":return"All trades must be closed before disabling this permission.";case"api":return"All API keys will be immediately disabled."}},c=e=>n&&("Futures"===e||"CryptoPacks"===e||"Earn"===e);return(0,T.Y)(f.Ry,{header:"Update Permissions",leadingIcon:"arrow-left",leadingIconClick:o,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(20),"",""],children:[(0,T.Y)(f.$G,{containerPadding:[12,16],gap:12,alignVertical:!0,children:t.map((e,n)=>{let o=null==s?void 0:s(e.permissionName),d=r.includes(e.permissionId),u=null==c?void 0:c(e.permissionName.toLowerCase());return(0,T.FD)(i.Fragment,{children:[(0,T.Y)(ex,{id:e.permissionId,name:e.permissionName,img:(0,es.PZ)(e.permissionId),enabled:d,locked:u,infoMessage:o,onToggle:l,onInfoMessageClick:()=>{}}),n<t.length-1&&(0,T.Y)(a.cG,{spacing:0,color:a.Tj.Zeb_Solid_BG_Blue})]},e.permissionId)})}),n&&(0,T.FD)("div",{css:eO,onClick:ek.A,children:[(0,T.FD)("div",{css:eY,children:[(0,T.FD)("div",{css:ew,children:[(0,T.Y)(a.In,{name:"info",style:eF}),(0,T.Y)("span",{css:eR,children:"Margin Trading Enabled"})]}),(0,T.FD)("p",{css:eN,children:["Futures, CryptoPacks & Earn are disabled since Margin Trading is active.",(0,T.Y)("br",{}),"In order to make any changes reach out to the customer support."]}
1)]}),(0,T.Y)(a.In,{name:"arrow-right",style:eB})]})]})})},eW=function(e){return e.DETAILS="details",e.UPDATE_PERMISSIONS="updatePermissions",e.VERIFYING="verifying",e.LIMIT_REACHED="limit_reached",e}({}),eL=e=>{var t;let{onClose:r,accountData:n,isMarginTradingEnabled:l=!1,currentActiveAndPendingAccounts:o,maxAllowedAccounts:a,handleOverlayClickCallback:c}=e,d=(0,s.d4)(e=>{var t;return null!=(t=e.subAccountsNew.subAccountMetadata.userPermissionsList)?t:[]}),{0:u,1:p}=(0,i.useState)(eW.DETAILS),{0:h,1:g}=(0,i.useState)(null!=(t=n.permissions)?t:[]),{0:m,1:v}=(0,i.useState)(n.permissions.map(e=>e.permissionId));(0,i.useEffect)(()=>{c(u===eW.DETAILS)},[c,u]),(0,i.useEffect)(()=>{o>=a&&p(eW.LIMIT_REACHED)},[o,a]);let A=async()=>{p(eW.VERIFYING);try{let e=await (0,ep.O8)({subAccountId:n.accountId,permissions:m});if((null==e?void 0:e.statusCode)===200){(0,eh.A)({type:"success",title:"Sub-Account Unfrozen!",description:"The ".concat(n.label," Sub-Account is now active & ready for trading."),duration:8});let e=d.filter(e=>m.includes(e.permissionId));(0,ep.lc)(n.accountId,j.CX.Active,n.accountStatus,{permissions:e}),(0,ep.nk)(),null==r||r()}else(0,eh.A)({type:"error",title:"Unfreeze Failed!",description:(null==e?void 0:e.statusDescription)||"
1Unable to unfreeze the ".concat(n.label," Sub-Account. Please try again."),duration:8}),p(eW.DETAILS)}catch(e){console.error(e),(0,eh.A)({type:"error",title:"Unfreeze Failed!",description:"Unable to unfreeze the ".concat(n.label," Sub-Account. Please try again."),duration:8}),p(eW.DETAILS)}};return u===eW.LIMIT_REACHED?(0,T.Y)(f.sS,{header:"Limit Reached",title:"Sub-Account Limit Reached",description:"You've reached the maximum limit of 10 Sub-Accounts. Please freeze an existing one to unfreeze this Sub-Account.",image:ed.A.i_illustration_restricted,primaryButtonText:"GOT IT",primaryButtonClick:r}):u===eW.VERIFYING?(0,T.Y)(f.fq,{text:"Processing Your Request"}):u===eW.UPDATE_PERMISSIONS?(0,T.Y)(ej,{permissions:d,selectedPermissionIds:m,isMarginTradingEnabled:l,onPermissionToggle:e=>{v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},onBack:()=>{p(eW.DETAILS),g(d.filter(e=>m.includes(e.permissionId)))}}):(0,T.Y)(eI,{accountData:n,permissionsList:h,onUpdatePermissionsClick:()=>{p(eW.UPDATE_PERMISSIONS)},onUnfreezeClick:A})},eM=function(e){return e.details="details",e.otpVerification="otpVerification",e.pinVerification="pinVerification",e.verifyingLoader="verifyingLoader",e}({}),eH=e=>{let{isFocused:t,value:r,maxLength:n=30}=e;return(0,T.FD)("span",{css:(0,ee.Dq)(t),children:[r.length,"/",n]})};var eU=r(62673);let eq=/^[A-Za-z0-9 -]*$/,eZ=e=>{let{formData:t,onContinue:r}=e,{0:n,1:l}=(0,i.useState)(t.email),{0:o,1:c}=(0,i.useState)(t.label),{0:d,1:u}=(0,i.useState)(!1),{0:h,1:g}=(0,i.useState)(!1),{0:m,1:v}=(0,i.useState)(t.emailError),{0:A,1:b}=(0,i.useState)(t.labelError),y=(0,s.d4)(e=>e.subAccountsNew.subAccountsList),f=(0,en.A)(n,500),_=(0,en.A)(o,500);return(0,i.useEffect)(()=>{let e=f.trim().toLowerCase(),r=t.email.trim().toLowerCase(),n=(y||[]).some(t=>t.email.trim().toLowerCase()===e),i=(y||[]).some(e=>e.label.trim().toLowerCase()===_.trim().toLowerCase());if(t.emailError&&e===r)v(t.emailError);else if(""!==e)eU.GN.test(f)?n?v("The email is already registered."):v(""):v("Please use a valid email address");else v("");""!==_.trim()?_.length>30?b("Maximum limit is ".concat(30," characters")):_.length<3?b("Minimum limit is ".concat(3," characters")):i?b("This label is already in use. Please choose another name"):eq.test(_)?b(""):b("Invalid label name"):b("")},[f,y,_,t.email,t.emailError]),(0,i.useEffect)(()=>{""!==n.trim()&&""!==o.trim()?m.length>0||A.length>0?g(!1):g(!0):g(!1)},[n,m,o,A]),(0,T.Y)(ey.A,{header:"Create Sub-Account",primaryButtonText:"CONTINUE TO SET PERMISSIONS",primaryButtonClick:()=>{r&&r(n,o)},disablePrimaryBtn:!h,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(20),"",""],children:[(0,T.Y)(a.pd,{label:"Email Address",placeholder:"Enter Sub-Account email",value:n,onChange:e=>{l(e.value)},invalid:!!m,errorText:m}),(0,T.Y)(a.pd,{placeholder:"e.g. Trading Team Alpha",value:o,label:"Label Name",onChange:e=>{c(e.value)},onFocus:()=>{u(!0)},onBlur:()=>{u(!1)},invalid:!!A,errorText:A,appendItem:(0,T.Y)(eH,{isFocused:d,value:o})})]})})},eV=e=>{let{formData:t,accountData:r,onContinue:n,isLoading:l=!1}=e,{0:o,1:s}=(0,i.useState)(""),{0:c,1:d}=(0,i.useState)(""),{0:u,1:h}=(0,i.useState)(r.label),{0:g,1:m}=(0,i.useState)(!1),{0:v,1:A}=(0,i.useState)(!1),{0:b,1:y}=(0,i.useState)(""),{0:f,1:_}=(0,i.useState)(""),{0:S,1:C}=(0,i.useState)(""),E=(0,en.A)(o,500),I=(0,en.A)(c,500),D=e=>eU.GN.test(e);return(0,i.useEffect)(()=>{y(t.newEmailError)},[t.newEmailError]),(0,i.useEffect)(()=>{_(t.confirmEmailError)},[t.confirmEmailError]),(0,i.useEffect)(()=>{""!==E.trim()?y(D(E)?"":"Please enter a valid email"):y("")},[E]),(0,i.useEffect)(()=>{""!==I.trim()?D(I)?I!==E?_("Emails do not match"):_(""):_("Please enter a valid email"):_("")},[I,E]),(0,i.useEffect)(()=>{let e=D(o),t=o===c,n=e&&t&&o.trim()!==r.email,i=""!==u.trim()&&u.trim()!==r.label,l=u.length<=30,a=""===u.trim()||eq.test(u);l?a?C(""):C("Invalid label name"):C("Label should be ".concat(30," characters or fewer")),A(n||i)},[o,c,u,r.email,r.label]),(0,T.Y)(ey.A,{header:"Edit Account Details",primaryButtonText:"CONTINUE TO UPDATE ACCOUNT DETAILS",primaryButtonClick:()=>
1{if(""!==o.trim()&&""==c.trim()&&_("Confirm email is missing, either enter or remove the new email"),r.email===o.trim()&&r.label===u.trim())return void(0,a.zH)({title:"Note",description:"No changes made to the account details",type:"error"});v&&n&&n({newEmail:o,confirmEmail:c,newLabelName:u,newEmailError:"",confirmEmailError:""})},disablePrimaryBtn:!v||l,isPrimaryCtaLoading:l,children:(0,T.FD)("div",{css:[(0,p.H2)([20,32]),a.Wp.g(20),"",""],children:[(0,T.Y)(ec,{accountData:r,screen:"editDetails"}),(0,T.Y)(a.pd,{label:"New Email",placeholder:"Enter new Sub-Account email",value:o,onChange:e=>s(e.value),invalid:!!b,errorText:b}),(0,T.Y)(a.pd,{label:"Confirm New Email",placeholder:"Enter new Sub-Account email",value:c,onChange:e=>d(e.value),invalid:!!f,errorText:f}),(0,T.Y)(a.pd,{label:"Label Name",placeholder:"Ex. Pro Team",value:u,onChange:e=>{e.value.length<=30&&h(e.value)},onFocus:()=>m(!0),onBlur:()=>m(!1),appendItem:(0,T.Y)(eH,{isFocused:g,value:u}),invalid:!!S,errorText:S})]})})};var eK=r(68176),eG=r(67059),ez=r(32902);function eX(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function e$(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?eX(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):eX(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let eQ=e=>{let{onClose:t,accountData:r,handleOverlayClickCallback:n}=e,{0:l,1:o}=(0,i.useState)(eM.details),{0:a,1:c}=(0,i.useState)({newEmail:"",confirmEmail:"",newLabelName:"",newEmailError:"",confirmEmailError:""}),{0:d,1:u}=(0,i.useState)(!1),{0:p,1:h}=(0,i.useState)(""),{0:g,1:m}=(0,i.useState)(0),v=(0,s.d4)(e=>e.shared.user.userStatus);(0,i.useEffect)(()=>{n&&n(l===eM.details)},[l,n]);let A=async e=>{c(e),u(!0);try{let t=e.newEmail.trim()||r.email,n=e.newLabelName.trim()||r.label,i=await (0,ep.B0)({subAccountId:r.accountId,email:t,label:n,pin:"",verificationId:""});(null==i?void 0:i.statusCode)===200?(h(i.data.verificationId||""),m(i.data.verificationIntId),o(eM.otpVerification)):(null==i?void 0:i.statusCode)===eK.$p.EmailAlreadyExists?c(e=>e$(e$({},e),{},{newEmailError:(null==i?void 0:i.statusDescription)||"The email is already registered."})):(0,eh.A)({title:"Error",description:(null==i?void 0:i.statusDescription)||"Error occurred while updating details. Please try again.",type:"error"})}catch(e){console.error(e),(0,eh.A)({title:"Error",description:"Something went wrong. Please try again.",type:"error"})}finally{u(!1)}},b=e=>{let t=a.newEmail.trim()||r.email,n=a.newLabelName.trim()||r.label;return(0,ep.B0)({subAccountId:r.accountId,email:t,label:n,pin:e,verificationId:p})},y=e=>{let n=a.newEmail.trim()||r.email,i=a.newLabelName.trim()||r.label;(0,eh.A)({title:"Details Updated!",description:"Email and label have been updated successfully.",type:"success"}),(0,ep.Bt)(r.accountId,{email:n,label:i}),t()};return(0,T.Y)(T.FK,{children:(()=>{switch(l){case eM.details:return(0,T.Y)(eV,{accountData:r,onContinue:A,isLoading:d,formData:a});case eM.otpVerification:return(0,T.Y)(eG.A,{title:"OTP Verification",description:["Enter the 6 digit OTP sent on","+".concat(null==v?void 0:v.countryISDCode," ").concat(null==v?void 0:v.mobileNumber),"& regd.","email ID "],verificationINTId:g,verificationId:p,onSuccess:e=>{h(e.verificationId),m(e.verificationIntId),o(eM.pinVerification)},onResendSuccess:e=>{h(e.verificationId),m(e.verificationIntId)},resendOtpType:eG.Z.UpdateSubAccount,alignPinOtpWarningIncenter:!0});case eM.pinVerification:return(0,T.Y)(ez.A,{title:"PIN Verification",description:"Enter the 4-digit security PIN",onVerifyPin:b,onSuccess:y,alignPinWarningInCenter:!0});case eM.verifyingLoader:return(0,T.Y)(f.fq,{text:"Processing Your Request"});default:return null}})()})},eJ=function(e){return e.loading="loading",e.permissions="permissions",e}({});var e0=r(82851);let e1=function(e){return e.SPOT="spot",e.CRYPTO_PACKS="crypto-packs",e.FUTURES="futures",e.EARN="earn",e}({}),e2=[{label:"Spot",value:e1.SPOT},{label:"CryptoPacks",value:e1.CRYPTO_PACKS},{label:"Futures",value:e1.FUTURES},{label:"Earn",value:e1.EARN}],e4=e=>{let{labelName:t,subAccountId:r,currentPermissionsIds:n,allPermissionsList:o,permissionModificationMap:s,onContinue:d,isMarginTradingEnabled:u=!1}
1=e,h=(0,l.useRouter)(),{0:g,1:m}=(0,i.useState)(n),v=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,T.Y)(f.Ry,{header:"Edit Permissions",subheader:t||"Trading alpha",primaryButtonText:"UPDATE PERMISSIONS",primaryButtonClick:()=>d(g),padding:"medium",disablePrimaryBtn:(0,e0.isEqual)((0,e0.sortBy)(g),(0,e0.sortBy)(n)),children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(20),"",""],children:[(0,T.Y)(f.$G,{containerPadding:[12,16],gap:12,alignVertical:!0,children:o.map((e,t)=>{var n;let l=s[e.permissionId],d=null==(n=null==l?void 0:l.allowModify)||n,p=((e,t)=>{let r=e.toLowerCase();return t&&("futures"===r||"cryptopacks"===r||"earn"===r)})(e.permissionName,u),m=d?void 0:((e,t)=>{switch(e){case c.PC.QUICKTRADE:case c.PC.EXCHANGE:return{message:null!=t?t:"All open trades must be closed before disabling this permission.",navigate:"/subAccount?".concat(eg.X.TAB,"=").concat(c.C$.ORDERS)};case c.PC.API:return{message:null!=t?t:"All API keys will be immediately disabled."};case c.PC.FUTURES:return{message:null!=t?t:"All open futures positions must be closed before disabling this permission.",navigate:"/subAccount?".concat(eg.X.TAB,"=").concat(c.C$.ASSETS_CRYPTO,"&").concat(eg.X.ASSET_TYPE,"=").concat(e1.FUTURES)};case c.PC.CRYPTO_PACKS:return{message:null!=t?t:"Please redeem all active packs before disabling CryptoPacks.",navigate:"/subAccount?".concat(eg.X.TAB,"=").concat(c.C$.ASSETS_CRYPTO,"&").concat(eg.X.ASSET_TYPE,"=").concat(e1.CRYPTO_PACKS)};case c.PC.EARN:return{message:null!=t?t:"Please cancel all active Earn contracts before disabling Earn.",navigate:"/subAccount?".concat(eg.X.TAB,"=").concat(c.C$.ASSETS_CRYPTO,"&").concat(eg.X.ASSET_TYPE,"=").concat(e1.EARN)};default:return}})(e.permissionId,null==l?void 0:l.modifyDescription),A=g.includes(e.permissionId);return(0,T.FD)(i.Fragment,{children:[(0,T.Y)(ex,{id:e.permissionId,name:e.permissionName,img:(0,es.PZ)(e.permissionId),enabled:A,locked:!d||p,infoMessage:null==m?void 0:m.message,onToggle:v,onInfoMessageClick:null!=m&&m.navigate?()=>{null!=m&&m.navigate&&h.push("".concat(m.navigate,"&").concat(eg.X.SUB_ACCOUNT_ID,"=").concat(r))}:void 0}),t<o.length-1&&(0,T.Y)(a.cG,{spacing:0,color:a.Tj.Zeb_Solid_BG_Blue})]},e.permissionId)})}),u&&(0,T.Y)(f.L7,{type:f.$$.INFO,title:"Margin Trading Enabled",description:"Futures, CryptoPacks & Earn are disabled since Margin Trading is active. In order to make any changes reach out to the customer support.",allowAction:!1})]})})};var e8=r(67929);let e5=e=>{let{onClose:t,subAccountId:r,labelName:n="",activePermissions:l,isMarginTradingEnabled:o=!1,handleOverlayClickCallback:a}=e,c=(0,s.d4)(e=>{var t;return null!=(t=e.subAccountsNew.subAccountMetadata.userPermissionsList)?t:[]}),{0:d,1:u}=(0,i.useState)(eJ.loading),{0:p,1:h}=(0,i.useState)(!1),{0:g,1:m}=(0,i.useState)({});(0,i.useEffect)(()=>{a&&a(d===eJ.permissions)},[d,a]),(0,i.useEffect)(()=>{(async()=>{try{var e,n;let t=await (0,ep.R0)({subAccountId:r}),i=null!=(e=null==t||null==(n=t.data)?void 0:n.permissions)?e:[];m(i.reduce((e,t)=>(e[t.permissionId]=t,e),{}))}catch(e){m({}),(0,e8.Ax)("Unable to fetch permissions. Please try again."),t()}finally{u(eJ.permissions)}})()},[t,r]);let v=async e=>{h(!0),u(eJ.loading);try{let i=await (0,ep.Rt)({subAccountId:r,permissions:e});if((null==i?void 0:i.statusCode)===200){(0,eh.A)({type:"success",title:"Permissions Updated!",description:'The permissions have been updated for "'.concat(n,'" successfully.')});let i=c.filter(t=>e.includes(t.permissionId));(0,ep.Bt)(r,{permissions:i}),t()}else(0,eh.A)({type:"error",title:"Error Occurred!",description:(null==i?void 0:i.statusDescription)||"
1Unable to update the permissions for ".concat(n,". Please try again.")}),u(eJ.permissions)}catch(e){(0,eh.A)({type:"error",title:"Error Occurred!",description:"Unable to update the permissions for ".concat(n,". Please try again.")}),u(eJ.permissions)}finally{h(!1)}};return(0,T.Y)(T.FK,{children:(()=>{var e;switch(d){case eJ.permissions:return(0,T.Y)(e4,{allPermissionsList:c,permissionModificationMap:g,labelName:n,subAccountId:r,currentPermissionsIds:null!=(e=null==l?void 0:l.map(e=>e.permissionId))?e:[],onContinue:v,isMarginTradingEnabled:o});case eJ.loading:return(0,T.Y)(f.fq,{text:"Processing Your Request"});default:return null}})()})};var e6=r(8127);let e3=function(e){return e.CONSENT="consent",e.DELETE_DETAILS="deleteDetails",e.VERIFYING="verifying",e}({}),e9=e=>{let{onClose:t,onSuccess:r,accountData:n}=e,l=n.accountId,o=n.label,s=n.accountStatus,c=s===j.CX.Pending,d=s===j.CX.Freeze,{0:h,1:g}=(0,i.useState)(()=>d?e3.DELETE_DETAILS:e3.CONSENT),{0:m,1:v}=(0,i.useState)(!1),{0:A,1:b}=(0,i.useState)(null),y=async()=>{g(e3.VERIFYING);let e=await (0,ep.Jl)({subAccountId:l});if(null!=e&&e.error){b(e.error),g(d?e3.DELETE_DETAILS:e3.CONSENT);return}(null==e?void 0:e.statusCode)===200?((0,eh.A)({title:"Sub-Account Deleted!",description:"The ".concat(o," Sub-Account has been deleted successfully."),type:"success"}),(0,ep.WR)(!0),(0,ep.nP)(l,s),r()):((0,eh.A)({title:"Error Note",description:(null==e?void 0:e.statusDescription)||"The ".concat(o," Sub-Account deletion failed. Try again"),type:"error"}),g(d?e3.DELETE_DETAILS:e3.CONSENT))};return h===e3.VERIFYING?(0,T.Y)(f.fq,{text:"Processing Your Request"}):A?(0,T.Y)(f.nE,{error:A,onClose:()=>b(null)}):h===e3.CONSENT&&c?(0,T.Y)(e6.A,{header:"Delete Sub-Account",primaryButtonText:"Yes, Delete",primaryButtonClick:y,secondaryButtonText:"Cancel",secondaryButtonClick:t,padding:"medium",image:ed.A.i_illustration_restricted,title:"Confirm Delete",description:(0,T.FD)("span",{children:["Are you sure you want to delete"," ",(0,T.Y)("span",{css:(0,u.AH)({color:a.Tj.Zeb_Solid_White},"",""),children:o})," ","Sub-Account? This action cannot be undone."]}),spaceBtwButtons:20}):(0,T.Y)(f.Ry,{header:"Delete Sub-Account",primaryButtonText:"DELETE SUB-ACCOUNT",primaryButtonClick:y,secondaryButtonText:"Cancel",secondaryButtonClick:t,disablePrimaryBtn:!m,padding:"medium",spaceBtwContentAndCTA:20,spaceBtwButtons:20,footerContent:(0,T.Y)(f.Is,{label:(0,T.Y)("span",{children:"I hereby consent to permanently delete this Sub-Account. I understand that I cannot restore this Sub-Account after deletion."}),checked:m,value:"delete-consent",onChange:e=>{let{checked:t}=e;return v(t)},style:a.Wp.widthPercentage(100),checkboxStyle:a.Wp.mt(-22)}),children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(12),p.TH,"",""],children:[(0,T.Y)(ec,{accountData:n,screen:"delete"}),(0,T.Y)(f.vS,{title:"Important Note",allowedList:["Delete is permanent and cannot be undone."]})]})})};var e7=r(38757),te=r(64890);let tt=function(e){return e.LIMIT_REACHED="limit_reached",e.SENDING="sending",e}({}),tr=e=>{let{onClose:t,accountId:r,email:n,handleOverlayClickCallback:l}=e,{0:o,1:a}=(0,i.useState)(tt.SENDING);return((0,i.useEffect)(()=>{(async()=>{l(!1);try{let e=await (0,ep.GF)({subAccountId:r});l(!0),(null==e?void 0:e.statusCode)===200?((0,eh.A)({title:"Invitation sent successfully!",description:"Resend invitation sent to ".concat(n,"."),type:e7.C.success}),t()):(null==e?void 0:e.statusCode)===eK.$p.ResendInviteLimitReached?a(tt.LIMIT_REACHED):((0,eh.A)({title:"Failed to send invite",description:(null==e?void 0:e.statusDescription)||"
1Unable to resend invitation. Please try again.",type:e7.C.error}),t())}catch(e){console.error(e),(0,eh.A)({title:"Failed to send invite",description:"Unable to resend invitation. Please try again.",type:e7.C.error}),t()}})()},[]),o===tt.LIMIT_REACHED)?(0,T.Y)(e6.A,{header:"Limit Reached",title:"Resend invite limit reached",description:"You've reached the maximum number of invite attempts. Please try again after some time.",image:ed.A.i_illustration_restricted,spaceBtwTitleAndDescription:20,primaryButtonText:"Got it",primaryButtonClick:t}):(0,T.Y)(te.A,{text:"Sending Invite..."})};var tn=r(76751),ti=r(17646);let tl=e=>{let{title:t,description:r,primaryButtonText:n,primaryButtonClick:i,containerStyle:l}=e;return(0,T.Y)(ti.A,{image:ed.A.i_zebpay_logo,imageHeight:140,imageWidth:140,title:t,description:r,primaryButtonText:n,primaryButtonClick:i,containerStyle:l})};var to={name:"vs8reh",styles:"max-width:fit-content;margin:0 auto"};let ta=e=>{let{title:t,description:r,secondaryButtonText:n,secondaryButtonClick:i}=e;return(0,T.Y)(ti.A,{image:ed.A.i_zebpay_logo,imageHeight:140,imageWidth:140,title:t,description:r,secondaryButtonText:n,secondaryButtonClick:i,buttonStyle:to})},ts=e=>{let{onCreateSubAccountClick:t,style:r}=e;return(0,T.Y)(tl,{title:"No Sub-Accounts to display",description:"You haven't created any Sub-Accounts yet.",primaryButtonText:"CREATE SUB-ACCOUNT",primaryButtonClick:t,containerStyle:r})},tc=e=>{let{onResetFilter:t}=e;return(0,T.Y)(ta,{title:"No Entries Found",description:"Entry not available for the selected filters.",secondaryButtonText:"Reset Filters",secondaryButtonClick:t})};var td=r(30775),tu=r(78414),tp=r(24035),th={name:"kxbue8",styles:"text-transform:none"},tg={name:"kxbue8",styles:"text-transform:none"};let tm=e=>{let{permissions:t,maxDisplayedPermissions:r=2,selectedPermissionId:n=[]}=e,l=(0,i.useMemo)(()=>[...t.filter(e=>n.includes(e.permissionId)),...t.filter(e=>!n.includes(e.permissionId))],[t,n]);return 0===l.length?(0,T.Y)(f.$G,{containerPadding:[0,8],borderRadius:4,bgColor:a.Tj.Zeb_Solid_BG_Blue,children:"----"}):(0,T.FD)("div",{css:ee.SL,children:[l.slice(0,r).map(e=>(0,T.Y)(a.YD,{type:"info",style:tg,children:e.permissionName},e.permissionId)),l.length>r&&(0,T.Y)(a.m_,{content:l.slice(r).map(e=>e.permissionName).join(", "),isStroke:!0,children:(0,T.FD)(a.YD,{type:"default",style:th,children:["+",l.length-r]})})]})};var tv=r(81729);let tA=e=>{let{title:t="Actions",menuItems:r,onClick:n}=e;return(0,T.FD)("div",{css:(0,u.AH)([(0,p.wh)(8),a.vE.flexAlignStart,{width:a.Wp.remConverter(200)}],"",""),children:[(0,T.Y)("div",{css:a.p0.B4_14_semibold,children:t}),r.map(e=>(0,T.Y)(tv.A,{label:e.label,iconName:e.icon,onClick:()=>n(e.id)},e.label))]})},tb=e=>{let{accountStatus:t,handleMenuClick:r}=e,n=(0,i.useMemo)(()=>{switch(t){case j.CX.Active:return[{label:"Edit Details",icon:"form",id:j.$D.EDIT_DETAILS},{label:"Edit Permissions",icon:"edit",id:j.$D.EDIT_PERMISSIONS},{label:"Freeze",icon:"cancelled",id:j.$D.FREEZE}];case j.CX.Pending:return[{label:"Resend Invite",icon:"send-email",id:j.$D.RESEND_INVITE},{label:"Delete",icon:"delete",id:j.$D.DELETE}];case j.CX.Freeze:return[{label:"Unfreeze",icon:"cancelled",id:j.$D.UNFREEZE},{label:"Delete",icon:"delete",id:j.$D.DELETE}];default:return[]}},[t]);return(0,T.Y)(tA,{title:"Actions",menuItems:n,onClick:e=>r(e)})},ty=function(e){return e.details="details",e.permissions="permissions",e.otpVerification="otpVerification",e.pinVerification="pinVerification",e}({}),tf=e=>{let{isVerifying:t,selectedPermissionIds:r,permissionsList:n,onPermissionToggle:l,onContinue:o,onBack:s}=e;return(0,T.Y)(ey.A,{header:"Set Permissions",leadingIcon:"arrow-left",leadingIconClick:s,primaryButtonText:"CONTINUE TO VERIFICATION",primaryButtonClick:o,isPrimaryCtaLoading:t,disablePrimaryBtn:t||0===r.length,children:(0,T.Y)("div",{css:[(0,p.H2)([20,32]),a.Wp.g(20),"",""],children:(0,T.Y)(f.$G,{containerPadding:[12,16],gap:12,alignVertical:!0,children:n.map((e,t)=>{let o=r.includes(e.permissionId);return(0,T.FD)(i.Fragment,{children:[(0,T.Y)(ex,{id:e.permissionId,name:e.permissionName,img:(0,es.PZ)(e.permissionId),enabled:o,onToggle:l}),t<n.length-1&&(0,T.Y)(f.cG,{spacing:"0",color:a.Tj.Zeb_Solid_BG_Blue})]},e.permissionId.toString())})})})})};var t_=r(38344);function tS(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function tT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?tS(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tS(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let tC=e=>{let{onClose:t,handleOverlayClickCallback:r}=e,{0:n,1:l}=(0,i.useState)({email:"",label:"",emailError:"",labelError:""}),{0:o,1:a}=(0,i.useState)([]),{0:c,1:d}=(0,i.useState)(!1),{0:u,1:p}=(0,i.useState)(ty.details),{0:h,1:g}=(0,i.useState)(""),{0:m,1:v}=(0,i.useState)(0),A=(0,s.d4)(e=>{var t;return null!=(t=e.subAccountsNew.subAccountMetadata.userPermissionsList)?t:[]}),b=(0,s.d4)(e=>e.shared.user.userStatus);(0,i.useEffect)(()=>{r&&r(ty.details===u)},[u,r]);let y=(e,t)=>{p(ty.permissions),l(r=>tT(tT({},r),{},{email:e,label:t}))},_=e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},S=async()=>{d(!0);try{let e=await (0,ep.ch)({email:n.email,label:n.label,pin:"",verificationId:"",permissions:o});(null==e?void 0:e.statusCode)===200&&e.data?(g(e.data.verificationId),v(e.data.verificationIntId),p(ty.otpVerification)):(null==e?void 0:e.statusCode)===eK.$p.EmailAlreadyExists?(l(t=>tT(tT({},t),{},{emailError:(null==e?void 0:e.statusDescription)||"The email is already registered."})),p(ty.details)):(0,e8.Ax)(null==e?void 0:e.statusDescription)}catch(e){console.error(e)}finally{d(!1)}},C=e=>(0,ep.ch)({email:n.email,label:n.label,pin:e,verificationId:h,permissions:o}),E=e=>{(0,eh.A)({title:"Sub-Account request shared successfully",description:"Invitation sent to ".concat(n.email,"."),type:"success"}),(0,ep.vu)(),t()},I=()=>{p(ty.details)};return(0,T.Y)(T.FK,{children:(()=>{switch(u){case ty.details:return(0,T.Y)(eZ,{formData:n,onContinue:y});case ty.permissions:return(0,T.Y)(tf,{isVerifying:c,selectedPermissionIds:o,permissionsList:A,onPermissionToggle:_,onContinue:S,onBack:I});case ty.otpVerification:return(0,T.Y)(eG.A,{title:"OTP Verification",description:["Enter the 6 digit OTP sent to","+".concat(null==b?void 0:b.countryISDCode," ").concat(null==b?void 0:b.mobileNumber),"& regd.","email ID"],verificationINTId:m,verificationId:h,onSuccess:e=>{g(e.verificationId),v(e.verificationIntId),p(ty.pinVerification)},onResendSuccess:e=>{g(e.verificationId),v(e.verificationIntId)},resendOtpType:eG.Z.CreateSubAccount,alignPinOtpWarningIncenter:!0});case ty.pinVerification:return(0,T.Y)(f.fV,{title:"PIN Verification",description:"Enter the 4-digit security PIN",onVerifyPin:C,onSuccess:E,onForgotPin:t_.F_,alignPinWarningInCenter:!0});default:return null}})()})},tE=["mousedown","keydown","scroll","touchstart"];function tI(e){let{poll:t,disabled:r,pollingIntervalMs:n=1e4,inactivityThresholdMs:l=3e4,onError:o,activityEvents:a=tE}=e,s=(0,i.useRef)(null),c=(0,i.useRef)(Date.now()),d=(0,i.useRef)(t),u=(0,i.useRef)(o),p=(0,i.useRef)(a);d.current=t,u.current=o,p.current=a,(0,i.useEffect)(()=>{if(r){s.current&&(clearInterval(s.current),s.current=null);return}c.current=Date.now();let e=async()=>{try{await d.current()}catch(t){var e;null==(e=u.current)||e.call(u,t)}finally{Date.now()-c.current>l&&s.current&&(clearInterval(s.current),s.current=null)}},t=()=>{e(),s.current=setInterval(e,n)},i=()=>{c.current=Date.now(),null===s.current&&t()},o=[...p.current];return o.forEach(e=>window.addEventListener(e,i)),t(),()=>{o.forEach(e=>window.removeEventListener(e,i)),s.current&&(clearInterval(s.current),s.current=null)}},[r,n,l])}var tD={name:"kxbue8",styles:"text-transform:none"};let tP=(0,i.forwardRef)((e,t)=>{var r,n,l;let{onCreateSubAccountClick:o,coachHighlightTarget:d,showCoachmarkWalkthrough:h=!1}=e,{0:g,1:m}=(0,i.useState)(""),v=(0,en.A)(g),{0:A,1:b}=(0,i.useState)(!1),{0:y,1:C}=(0,i.useState)({}),{0:E,1:I}=(0,i.useState)(tn.Rc),{0:D,1:P}=(0,i.useState)(null),M=(0,i.useRef)(!0),H=(0,i.useRef)(null),{0:q,1:Z}=(0,i.useState)(null),V=(0,i.useCallback)(e=>{H.current=e,h&&(e.scrollTop=0)},[h]),K=(0,s.d4)(e=>e.subAccountsNew.subAccountsList),G=(0,s.d4)(e=>e.subAccountsNew.countSummary),z=(0,s.d4)(e=>e.subAccountsNew.subAccountMetadata),X=null===K;tI({poll:async()=>{await (0,ep.vu)()},disabled:""===(0,i.useMemo)(()=>null!=K&&K.length?K.filter(e=>e.accountStatus===j.CX.Active).map(e=>e.accountId).join(","):"",[K])});let $=(0,i.useMemo)(()=>(0,tn.nq)(y).total>0,[y]),Q=(0,i.useMemo)(()=>{var e,t;return{permissions:{list:(null!=(e=null==z?void 0:z.userPermissionsList)?e:[]).map(e=>({id:e.permissionId,name:e.permissionName})),title:"Permissions",icon:"reports"},status:{list:null!=(t=null==z?void 0:z.accountStatusOptions)?t:[],title:"Status",icon:"term"}}},[null==z?void 0:z.userPermissionsList,null==z?void 0:z.accountStatusOptions]),{getCoinSetting:J}=(0,eo.A)(),ee=(0,i.useMemo)(()=>J("INR"),[J]);(0,i.useImperativeHandle)(t,()=>({openCreateSubAccountSidepanel:()=>{P(j.mo.CREATE_SUB_ACCOUNT)}}),[]);let ea=(0,i.useMemo)(()=>{let e=null!=K?K:[];return v.trim()&&(e=(0,td.Ht)(e,v.trim(),{keys:["email","label","accountId","accountStatus"],threshold:td.Ht.rankings.CONTAINS})),$&&(y.status&&(e=e.filter(e=>y.status.includes(e.accountStatus))),y.permissions&&(e=e.filter(e=>e.permissions.some(e=>y.permissions.includes(e.permissionId)))),E&&(e=e.filter(e=>{let t=new Date(e.createDate);return t>=new Date(E.startDate)&&t<=new Date(E.endDate)}))),e},[K,v,$,y.status,y.permissions,E]),{sortedData:es,sortState:ec,handleSort:ed}=(0,tu.GY)(ea,j.Gr,{field:W.Mq.ORDER_ID,direction:tu.UE.ASC}
1),eu=!X&&h&&0===es.length,eh=(0,i.useMemo)(()=>eu?[c.s1]:es,[eu,es]),eg=(e,t)=>{if(t.accountId!==c.GG)switch(Z(t),e){case j.$D.FREEZE:P(j.mo.FREEZE);break;case j.$D.EDIT_DETAILS:P(j.mo.EDIT_DETAILS);break;case j.$D.EDIT_PERMISSIONS:P(j.mo.EDIT_PERMISSIONS);break;case j.$D.DELETE:P(j.mo.DELETE);break;case j.$D.RESEND_INVITE:P(j.mo.RESEND_INVITE);break;case j.$D.UNFREEZE:P(j.mo.UNFREEZE)}},em=e=>{M.current=e},ev=()=>{P(null),M.current=!0,Z(null)},eA=[{dataField:W.Mq.ID,component:(0,T.Y)("span",{css:a.Wp.pl(16),children:"Label"}),align:"left"},{dataField:W.Mq.ORDER_ID,component:"Account ID",align:"left"},{dataField:W.Mq.DATE,component:"Created",align:"left",isSortable:!0},{dataField:W.Mq.TIME,component:"Last Active",align:"left",isSortable:!0},{dataField:W.Mq.CHANGE,component:"Overall P&L",align:"right"},{dataField:W.Mq.BALANCE,component:"Balance",align:"right"},{dataField:W.Mq.QUOTE_CURRENCY,component:"",align:"left"},{dataField:W.Mq.STATUS,component:"Permissions",align:"left"},{dataField:W.Mq.MENU,component:(0,T.Y)(a.In,{name:"filter",style:(0,p.Kk)(),onClick:()=>b(!0)}),align:"center"}],ey=()=>{C({}),m("")},ef=(0,i.useMemo)(()=>Array.from({length:10},()=>({[W.Mq.ID]:(0,T.FD)("div",{css:w,children:[(0,T.Y)(a.WA,{width:80,height:18,style:a.Wp.mb(4)}),(0,T.Y)(a.WA,{width:120,height:12})]}),[W.Mq.ORDER_ID]:(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)(a.WA,{width:40,height:14}),(0,T.Y)(a.WA,{width:50,height:12})]}),[W.Mq.DATE]:(0,T.Y)(a.WA,{width:70,height:18}),[W.Mq.TIME]:(0,T.Y)(a.WA,{width:70,height:18}),[W.Mq.CHANGE]:(0,T.Y)(a.WA,{width:60,height:18}),[W.Mq.BALANCE]:(0,T.Y)(a.WA,{width:60,height:18}),[W.Mq.QUOTE_CURRENCY]:(0,T.Y)(a.WA,{width:30,height:18}),[W.Mq.STATUS]:(0,T.Y)(a.WA,{width:140,height:22}),[W.Mq.MENU]:(0,T.Y)(a.WA,{width:24,height:24})})),[]);return(0,T.FD)("div",{css:Y,children:[(0,T.Y)(U,{isLoading:X,countSummary:G,style:a.Wp.mb(28),coachHighlightTarget:d}),(0,T.FD)("div",{css:a.vE.flexColumn,children:[(0,T.FD)("div",{css:x,children:[(0,T.Y)("div",{css:[a.p0.B3_16_semibold,"",""],children:"Sub-Accounts Overview"}),(0,T.Y)(er,{value:g,onChange:m,placeholder:"Search",recentSearchesKey:et.SUB_ACCOUNTS})]}),(0,T.Y)(f.Cu,{isOpen:A,onOpen:()=>b(!0),onClose:()=>b(!1),list:Q,filterIds:y,selectedCustomDate:E,type:el.R.Filter,onApply:(e,t)=>{C(e),I(t)},onReset:ey},String(A)),(0,T.Y)(W.Ay,{headers:eA,rows:X?ef:eh.map((e,t)=>{var r,n,i;let l=0===t&&d===_.fU.STEP_3_DASHBOARD_MENU,o={};o[W.Mq.ID]=(0,T.FD)("div",{css:w,children:[(0,T.Y)(a.m_,{content:e.label,isStroke:!0,disabled:e.label.length<=c.MT,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:[F,""],children:e.label})}),(0,T.Y)(a.m_,{content:e.email,isStroke:!0,disabled:e.email.length<=c.MT,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:[R,""],children:e.email||"-"})})]}),o[W.Mq.ORDER_ID]=(0,T.FD)("div",{css:[(0,p.wh)(4),a.Wp.widthPercentage(100),""],children:[(0,T.Y)("div",{css:[B,""],children:e.accountId}),(0,T.Y)(a.YD,{type:(0,j.HT)(e.accountStatus),size:"small",style:tD,children:(0,j.N4)(e.accountStatus)})]}),o[W.Mq.DATE]=(0,T.Y)("div",{css:B,children:(0,tp.QF)(e.createDate).date}),o[W.Mq.TIME]=(0,T.Y)("div",{css:B,children:e.lastActive||"-"});let s=null!=(r=e.overallPnl)?r:0;o[W.Mq.CHANGE]=(0,T.Y)("div",{css:a.vE.flexAlignEnd,children:(0,T.Y)(f.kU,{leadingIcon:(0,ei.uw)(s),leadingIconImgStyle:(0,p.Kk)(10,(0,ei.yC)(s)),text:"".concat(Math.abs(s).toFixed(2),"%"),textStyle:(e=>(0,u.AH)(O(O({},a.p0.B5_12_bold),{},{color:e>0?a.Tj.Zeb_Solid_Green:e<0?a.Tj.Zeb_Solid_Red:a.Tj.Zeb_Solid_Grey_01}),"",""))(s),leadingIconSpace:4,tooltipStyle:a.Wp.widthPercentage(100),showTextTooltip:!0})});let g=null!=(n=e.overallBalance)?n:0,m=null!=(i=e.currency)?i:"INR";return o[W.Mq.BALANCE]=(0,T.Y)(a.m_,{content:g.toString(),isStroke:!0,disabled:g.toString().length<=c.uP,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:N,children:(0,L.uY)(g,m,null==ee?void 0:ee.totalDecimalPlaces)})}),o[W.Mq.QUOTE_CURRENCY]=(0,T.Y)("div",{css:B,children:m}),o[W.Mq.STATUS]=(0,T.Y)(tm,{permissions:e.permissions,selectedPermissionId:y.permissions}),o[W.Mq.MENU]=e.accountStatus!==j.CX.Deleted?(0,T.Y)("div",{id:0===t?(0,_.gM)(_.fU.STEP_3_DASHBOARD_MENU):void 0,css:[l&&S.GZ,""],children:(0,T.FD)(a.ND,{content:(0,T.Y)(tb,{accountStatus:e.accountStatus,handleMenuClick:t=>eg(t,e)}),allowInsideClickClose:!0,children:[(0,T.Y)(a.In,{name:"menu",style:(0,p.Kk)()}),h?(0,T.Y)("div",{css:[l&&S.iQ,(0,u.AH)({position:"absolute",right:"100%",opacity:+!!l},"",""),""],children:(0,T.Y)("div",{css:k,children:(0,T.Y)(tb,{accountStatus:j.CX.Active,handleMenuClick:t=>eg(t,e)})})}):null]})}):(0,T.Y)(T.FK,{}),o}),noTopBorderRadius:!1,isPaginationEnabled:!1,minHeight:456,columnsSize:[22,10,9,9,10,10,5,20,5],padding:(0,u.AH)({padding:(0,p.qb)([12,3])},"",""),defaultSortConfig:ec,onSortTableValues:ed,noSearchResults:X||eu?void 0:(null==K?void 0:K.length)===0?(0,T.Y)(ts,{onCreateSubAccountClick:()=>{m(""),o()}}):0===ea.length?g?(0,T.Y)(f.Z7,{title:"No Results Found",description:"Try searching with a different term.",onReset:ey}):(0,T.Y)(tc,{onResetFilter:ey}):void 0,tableSpace:$?280:220,setTableBodyElement:V})]}),(0,T.FD)(a.wv,{open:null!==D,onClose:ev,onOverlayClick:()=>{M.current&&ev()},children:[D===j.mo.CREATE_SUB_ACCOUNT&&(0,T.Y)(tC,{onClose:ev,handleOverlayClickCallback:em}),D===j.mo.FREEZE&&q&&(0,T.Y)(eb,{onClose:ev,accountData:q}),D===j.mo.UNFREEZE&&q&&(0,T.Y)(eL,{onClose:ev,accountData:q,handleOverlayClickCallback:em,isMarginTradingEnabled:!1,currentActiveAndPendingAccounts:(null!=(r=null==G?void 0:G.activeAccount)?r:0)+(null!=(n=null==G?void 0:G.pendingAccount)?n:0),maxAllowedAccounts:null!=(l=null==G?void 0:G.totalSubAccount)?l:0}
1),D===j.mo.EDIT_DETAILS&&q&&(0,T.Y)(eQ,{onClose:ev,accountData:q,handleOverlayClickCallback:em}),D===j.mo.EDIT_PERMISSIONS&&q&&(0,T.Y)(e5,{onClose:ev,activePermissions:q.permissions,subAccountId:q.accountId,labelName:q.label,handleOverlayClickCallback:em,isMarginTradingEnabled:!1}),D===j.mo.DELETE&&q&&(0,T.Y)(e9,{onClose:ev,onSuccess:ev,accountData:q}),D===j.mo.RESEND_INVITE&&q&&(0,T.Y)(tr,{onClose:ev,accountId:q.accountId,email:q.email,handleOverlayClickCallback:em})]})]})});tP.displayName="DashboardTabScreen";let tO=(0,u.AH)([a.p0.B5_12_regular,a.Wp.widthPercentage(100),p.gO],"",""),tY=(0,u.AH)([a.p0.B6_10_regular,a.vE.textFaded,a.Wp.widthPercentage(100),p.gO],"",""),tw=(0,u.AH)([a.p0.B5_12_regular,a.Wp.widthPercentage(100),p.gO,{textAlign:"right"}],"",""),tF=(0,u.AH)([a.p0.B5_12_regular,a.vE.textFaded],"","");a.p0.B5_12_regular,a.vE.textFaded;let tR=[{field:W.Mq.BALANCE,key:"avblBalance",type:tu.r3.NUMBER},{field:W.Mq.AMNT,key:"lockedBalance",type:tu.r3.NUMBER},{field:W.Mq.CHANGE,key:"avblFuturesINR",type:tu.r3.NUMBER},{field:W.Mq.PACKS_PnL,key:"avblFuturesUSDT",type:tu.r3.NUMBER}],tN=e=>{let{onCreateSubAccountClick:t}=e;return(0,T.Y)(tl,{title:"No active Sub-Accounts to display",description:"Create a Sub-Account to view and manage funds here.",primaryButtonText:"CREATE SUB-ACCOUNT",primaryButtonClick:t})},tB=e=>{let{onResetFilter:t}=e;return(0,T.Y)(ta,{title:"No Entries Found",description:"Entry not available for the selected filters.",secondaryButtonText:"Reset Filter",secondaryButtonClick:t})};var tx=r(37200);let tk=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,a.Wp.p(20),a.Wp.br(8),{background:a.Tj.Zeb_Gradient_Dark_Blue}],"","");a.Tj.Zeb_Solid_Bright_Blue;let tj=e=>{var t,r,n,i,l;let{showCoachmarkHighlight:o=!1,style:c}=e,{userStatus:d}=(0,s.d4)(e=>{let{shared:t}=e;return t.user}),h=(0,s.d4)(e=>e.subAccountsNew.portfolioTotal);return(0,T.FD)("div",{css:[tk,o&&S.iQ,c,"",""],children:[(0,T.FD)("div",{css:[(0,p.sM)(16),"flex:1;",""],children:[(0,T.Y)("img",{src:ed.A.i_illustration_01,alt:"wallet",css:(0,p.hj)(48,48)}),(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)("span",{css:a.p0.B2_20_regular,children:"Total Portfolio Value"}),(0,T.Y)("span",{css:[a.p0.B4_14_regular,a.vE.textFaded,"",""],children:"(Aggregated Fiat + Crypto)"})]})]}),(0,T.Y)(tx.A,{isLoading:null===h,height:28,width:120,typeLightdDark:!0,children:(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)(f.AW,{text:(0,L.uY)(null!=(t=null==h?void 0:h.totalPortfolioValue)?t:0,null!=(r=null!=(n=null==h?void 0:h.currency)?n:null==d?void 0:d.currencyCode)?r:"INR",2),textStyles:(0,u.AH)([a.p0.H5_20_bold],"",""),flagType:"subAccount"}),(0,T.Y)("span",{css:a.p0.B2_20_regular,children:null!=(i=null!=(l=null==h?void 0:h.currency)?l:null==d?void 0:d.currencyCode)?i:"INR"})]})})]})};function tW(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}let tL=(0,u.AH)([a.vE.flexJustifiedBetween,a.Wp.g(12),{flexWrap:"wrap"}],"",""),tM=(0,u.AH)({width:1,height:a.Wp.remConverter(46),backgroundColor:a.Tj.Zeb_Solid_Light_Blue,opacity:.2},"",""),tH=(0,u.AH)({width:a.Wp.remConverter(20),height:a.Wp.remConverter(20),borderRadius:"50%",backgroundColor:a.Tj.Zeb_BG_Light_Blue},"",""),tU=(0,u.AH)([a.p0.B4_14_regular,a.vE.textFaded,{textDecoration:"underline"}],"",""),tq=e=>{var t,r,n,i,l,o;let{isLoading:a,masterBalance:s,subAccountFiat:c,subAccountFuture:d,style:u,coachHighlightTarget:p}=e;return(0,T.FD)("div",{css:[tL,u,"",""],children:[(0,T.Y)(tZ,{title:"Master Account",iconName:"name",leftLabel:"Available Balance",leftValue:null!=(t=null==s?void 0:s.avaiable)?t:0,rightLabel:"Locked Balance",rightValue:null!=(r=null==s?void 0:s.locked)?r:0,isLoading:a,lockedDetails:null==s?void 0:s.lockedDetails,id:(0,_.gM)(_.fU.STEP_8_ASSETS_FIAT_STATS),showBorder:p===_.fU.STEP_8_ASSETS_FIAT_STATS}),(0,T.Y)(tZ,{title:"Sub-Accounts Fiat",iconName:"team",leftLabel:"Available Balance",leftValue:null!=(n=null==c?void 0:c.avaiable)?n:0,rightLabel:"Locked Balance",rightValue:null!=(i=null==c?void 0:c.locked)?i:0,isLoading:a,lockedDetails:null==c?void 0:c.lockedDetails,showBorder:p===_.fU.STEP_8_ASSETS_FIAT_STATS}),(0,T.Y)(tZ,{title:"Sub-Accounts Futures",iconName:"team",leftLabel:"Available INR Balance",leftValue:null!=(l=null==d?void 0:d.avaiableINR)?l:0,rightLabel:"Available USDT Balance",rightValue:null!=(o=null==d?void 0:d.avaiableUSDT)?o:0,rightCurrency:"USDT",isLoading:a,showBorder:p===_.fU.STEP_8_ASSETS_FIAT_STATS})]})},tZ=e=>{var t,r;let{title:n,iconName:i,leftLabel:l,leftValue:o,leftCurrency:s="INR",rightLabel:c,rightValue:h,rightCurrency:g="INR",isLoading:m,lockedDetails:v,id:A,showBorder:b=!1}=e;return(0,T.FD)(f.$G,{alignVertical:!0,gap:20,style:(0,u.AH)(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?tW(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tW(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({flex:1,minWidth:a.Wp.remConverter(280)},b&&S.oL),"",""),showBorder:b,id:A,children:[(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)(a.L5,{icon:i,iconSize:14,boxStyle:tH}),(0,T.Y)("span",{css:a.p0.B5_12_regular,children:n})]}),(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(tV,{label:l,value:o,currency:s,isLoading:m}),(0,T.Y)("div",{css:tM}),(0,T.Y)(tV,{label:c,value:h,currency:g,isLoading:m,popperContent:v&&(0,T.Y)(tK,{data:[{title:"Open Orders",value:null!=(t=null==v?void 0:v.openorders)?t:0},{title:"Margin Collaterals",value:null!=(r=null==v?void 0:v.margincollaterl)?r:0}],currency:g})})]})]})},tV=e=>{let{label:t,value:r,currency:n,isLoading:i,displayDecimalPlaces:l=es.m9,popperContent:o}=e;return(0,T.FD)("div",{css:[(0,p.wh)(4*!!i),"flex:1;",""],children:[(0,T.FD)("div",{css:(0,p.sM)(4),children:[(0,T.Y)("span",{css:[a.p0.B5_12_regular,a.vE.textFaded,"",""],children:t}),o&&!i&&(0,T.Y)(a.ND,{content:(0,T.Y)(T.FK,{children:o}),children:(0,T.Y)(a.In,{name:"info",style:(0,p.Kk)(12,a.Tj.Zeb_Solid_Bright_Blue)})})]}),(0,T.Y)(tx.A,{isLoading:i,height:28,width:120,children:(0,T.FD)("div",{css:(0,p.sM)(4),children:[(0,T.Y)(f.AW,{text:(0,L.uY)(r,n,l),textStyles:(0,u.AH)([a.p0.B3_16_semibold],"",""),flagType:"subAccount"}),(0,T.Y)("span",{css:[a.p0.B3_16_regular,a.vE.textFaded,"",""],children:n})]})})]})},tK=e=>{let{data:t,currency:r}=e;return 0===t.length?(0,T.Y)(T.FK,{}):(0,T.FD)("div",{css:[(0,p.wh)(12),{minWidth:a.Wp.remConverter(330)},"",""],children:[(0,T.Y)(f.kU,{text:"Locked Balance",leadingIcon:"lock",textStyle:(0,u.AH)([a.p0.B4_14_semibold],"","")}),(0,T.Y)(f.$G,{containerPadding:[8,12],bgColor:a.Tj.Zeb_Solid_BG_Blue,alignVertical:!0,gap:4,children:t.map(e=>{var t;return(0,T.FD)("div",{css:[a.vE.flexJustifiedBetween,a.vE.flexAlignCenter,"",""],children:[(0,T.Y)("span",{css:tU,children:e.title}),(0,T.FD)("div",{css:(0,p.sM)(4),children:[(0,T.Y)(f.AW,{text:null!=(t=e.value)?t:0,textStyles:(0,u.AH)([a.p0.B4_14_regular],"",""),flagType:"subAccount"}),(0,T.Y)("span",{css:[a.p0.B4_14_regular,a.vE.textFaded,"",""],children:r})]})]},e.title)})})]})},tG=function(e){return e.selectAccounts="selectAccounts",e.otpVerification="otpVerification",e.pinVerification="pinVerification",e.resultScreen="resultScreen",e}({}),tz=function(e){return e.FIAT="spotfiat",e.FUTURES_INR="futurefiat",e.FUTURES_USDT="futurecrypto",e.SPOT_CRYPTO="spotcrypto",e}({}),tX=(0,u.AH)([a.vE.flexColumn,a.Wp.g(20),a.Wp.widthPercentage(100)],"",""),t$=(0,u.AH)({backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,padding:a.Wp.remConverter(4),borderRadius:a.Wp.remConverter(8),width:"100%"},"",""),tQ=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),tJ=(0,u.AH)([a.vE.flexJustifiedBetween,a.vE.flexAlignCenter,a.Wp.widthPercentage(100)],"",""),t0=(0,u.AH)([a.p0.C4_12,{color:a.Tj.Zeb_Solid_Bright_Blue,cursor:"pointer",textTransform:"uppercase"}],"",""),t1=(0,u.AH)([a.p0.B4_14_semibold,{color:a.Tj.Zeb_Solid_White}],"",""),t2=(0,u.AH)([a.vE.flexAlignCenter,a.p0.B4_14_regular,{gap:a.Wp.remConverter(4),overflow:"hidden"}],"",""),t4=(0,u.AH)([p.gO,{minWidth:0}],"",""),t8=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(4),overflow:"hidden"}],"",""),t5=(0,u.AH)([a.p0.B4_14_semibold,p.gO,{minWidth:0}],"",""),t6=(0,u.AH)([a.p0.B4_14_regular,{flexShrink:0,whiteSpace:"nowrap"}],"",""),t3=(0,u.AH)([a.p0.B5_12_regular,a.vE.textFaded,{flexShrink:0}],"",""),t9=(0,u.AH)([a.p0.B4_14_regular,a.vE.textFaded,{flexShrink:0}],"",""),t7=(0,u.AH)([a.p0.B4_14_regular,a.vE.textFaded,{border:"1px solid ".concat(a.Tj.Zeb_Solid_Dark_Blue),borderRadius:a.Wp.remConverter(8),padding:"".concat(a.Wp.remConverter(8)," ").concat(a.Wp.remConverter(12)),width:"100%"}],"","");var re=r(54587),rt=r.n(re),rr=r(44435),rn=r(87532);let ri=[{title:"FIAT",tab:tz.FIAT},{title:"FUTURES INR",tab:tz.FUTURES_INR},{title:"FUTURES USDT",tab:tz.FUTURES_USDT}],rl=e=>{var t,r,n,l,o,c,d,h,g,m;let{selectedAccountForTransfer:v,onSuccess:A,onError:b,handleOverlayClickCallback:y}=e,{0:_,1:S}=(0,i.useState)(null!=(t=null==v?void 0:v.accountId)?t:null),{0:C,1:E}=(0,i.useState)(null),{0:I,1:D}=(0,i.useState)(""),{0:P,1:O}=(0,i.useState)(tz.FIAT),{0:Y,1:w}=(0,i.useState)(!1),{0:F,1:R}=(0,i.useState)(null),{0:N,1:B}=(0,i.useState)(null),x=(0,s.d4)(e=>e.subAccountsNew.assetsFiatData),k=(0,s.d4)(e=>e.shared.user.userStatus),j=P===tz.FUTURES_USDT?"USDT":"INR";(0,i.useEffect)(()=>{Y?null==y||y(!1):null==y||y(!0)},[Y,y]),(0,i.useEffect)(()=>{let e=async()=>{var e;let t=await (0,ep.nd)("USDT");B(null!=(e=null==t?void 0:t.data)?e:[])};
1P===tz.FUTURES_USDT&&null===N&&e()},[P,N]);let W=(0,i.useMemo)(()=>{var e;return x?(null!=(e=x.subAccountBalances)?e:[]).map(e=>{var t;let r=0;switch(P){case tz.FIAT:r=e.avblBalance;break;case tz.FUTURES_INR:r=e.avblFuturesINR;break;case tz.FUTURES_USDT:r=e.avblFuturesUSDT}return{accountId:e.accountId,label:e.label,balance:r,currency:j,isMaster:e.accountId===parseInt(null!=(t=null==k?void 0:k.accountId)?t:"0")}}):[]},[x,j,P,null==k?void 0:k.accountId]),M=(0,i.useMemo)(()=>{var e,t;return x&&null!=(e=null==(t=x.subAccountBalances)?void 0:t.filter(e=>e.accountId!==_).map(e=>{var t,r;return{accountId:e.accountId,label:e.label,balance:e.avblBalance,currency:null!=(t=null==k?void 0:k.currencyCode)?t:"INR",isMaster:e.accountId===parseInt(null!=(r=null==k?void 0:k.accountId)?r:"0")}}))?e:[]},[x,k,_]),H=e=>e.map(e=>{let t=(0,L.uY)(e.balance,e.currency,es.m9);return{label:(0,T.FD)("div",{css:(0,p.sM)(4),children:[(0,T.FD)("div",{css:t2,children:[(0,T.Y)("span",{css:t4,children:e.label}),e.isMaster&&(0,T.Y)("span",{css:t6,children:"(Master Account)"})]}),(0,T.Y)(a.In,{name:"separator",style:(0,p.Kk)(12,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.FD)("span",{css:t3,children:[t," ",e.currency]})]}),displayLabel:(0,T.FD)("div",{css:[(0,p.sM)(8),"",""],children:[(0,T.FD)("div",{css:t8,children:[(0,T.Y)("span",{css:t5,children:e.label}),e.isMaster&&(0,T.Y)("span",{css:t6,children:"(Master Account)"})]}),(0,T.FD)("div",{css:t9,children:["(",t," ",e.currency,")"]})]}),value:e.accountId.toString()}}),U=(0,i.useMemo)(()=>{var e;return null==x||null==(e=x.subAccountBalances)?void 0:e.find(e=>e.accountId===_)},[x,_]),q=P===tz.FIAT?null!=(r=null==U?void 0:U.avblBalance)?r:0:P===tz.FUTURES_INR?null!=(n=null==U?void 0:U.avblFuturesINR)?n:0:null!=(l=null==U?void 0:U.avblFuturesUSDT)?l:0,Z=null!==_&&null!==C&&parseFloat(I)>0&&parseFloat(I)<=q,V=null!==_&&0===q,K=(e,t)=>{"from"===t?(S(parseInt(e,10)),P!==tz.FIAT&&E(parseInt(e,10))):E(parseInt(e,10))},G=async()=>{w(!0);try{var e,t;let r=await (0,ep.vh)({fromAccountId:_,toAccountId:C,amount:parseFloat(I),currency:j,transferType:P,pin:"",verificationId:""});if(null!=r&&r.error)return void R(r.error);let n=(null==x||null==(e=x.subAccountBalances)||null==(e=e.find(e=>e.accountId===C))?void 0:e.label)||"",i=(null==x||null==(t=x.subAccountBalances)||null==(t=t.find(e=>e.accountId===_))?void 0:t.label)||"";(null==r?void 0:r.statusCode)===200&&r.data?A({fromAccountId:_,toAccountId:C,toAccountLabel:n,fromAccountLabel:i,amount:parseFloat(I),currency:j,transferType:P,verificationId:r.data.verificationId||"",verificationIntId:r.data.verificationIntId||0,status:"success"}):b({fromAccountId:_,toAccountId:C,toAccountLabel:n,fromAccountLabel:i,amount:parseFloat(I),currency:j,transferType:P,verificationId:"",verificationIntId:0,status:"error"})}catch(e){console.error(e),(0,eh.A)({title:"Assets Transferred Failed!",description:"Transfer failed due to an unexpected error. Please try again.",type:"error"})}finally{w(!1)}},z=(0,i.useMemo)(()=>{switch(P){case tz.FIAT:return"Transfer";case tz.FUTURES_INR:case tz.FUTURES_USDT:return"Transfer funds to fiat Wallet"}},[P]);return F?(0,T.Y)(f.nE,{error:F,onClose:()=>R(null)}):(0,T.Y)(ey.A,{header:"Transfer Funds",primaryButtonText:z,primaryButtonClick:G,isPrimaryCtaLoading:Y,disablePrimaryBtn:!Z||Y,children:(0,T.FD)("div",{css:[(0,p.H2)([20,32]),a.vE.flexColumn,a.Wp.g(28),"",""],children:[(0,T.Y)(a.tU,{type:"tertiary",tabsList:ri,selectedTab:P,onChange:e=>(e=>{e!==P&&(O(e),D(""),v||S(null),E(null))})(e),style:t$}),(0,T.FD)("div",{css:tX,children:[(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:[tQ,V&&a.vE.textError,"",""],children:P===tz.FIAT?"From Account":"From Futures Wallet"}),(0,T.Y)(rr.A,{placeholder:"Select Account",selected:null!=(o=null==_?void 0:_.toString())?o:"",onChange:e=>K(e,"from"),options:H(W),maxRows:5,rowHeight:44,enableSearch:!1,search:{placeholder:"",value:"",onChange:()=>{},onClear:()=>{}},customStyles:(0,u.AH)({border:V?"1px solid ".concat(a.Tj.Zeb_Solid_Red):"none"},"","")}),V&&(0,T.FD)("span",{css:[a.p0.B4_14_regular,a.vE.textError,"",""],children:["Insufficient ",j," balance to transfer."]})]}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:tQ,children:P===tz.FIAT?"To Account":"To Fiat Wallet"}),P!==tz.FIAT?(0,T.FD)("div",{css:t7,children:[null!=(c=null==U?void 0:U.label)?c:"-"," (",P===tz.FUTURES_INR?null!=(d=null==U?void 0:U.avblBalance)?d:"0.00":null!=(h=null==N||null==(g=N.find(e=>e.id===(null==U?void 0:U.accountId)))?void 0:g.balance)?h:"0.00"," ",j,")"]}):(0,T.Y)(rr.A,{placeholder:"Select Account",selected:null!=(m=null==C?void 0:C.toString())?m:"",onChange:e=>K(e,"to"),options:H(M),maxRows:5,rowHeight:44,enableSearch:!1,search:{placeholder:"",value:"",onChange:()=>{},onClear:()=>{}},disabled:P!==tz.FIAT})]}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.FD)("div",{css:tJ,children:[(0,T.Y)("span",{css:tQ,children:"Transfer Amount"}),_&&(0,T.Y)("span",{css:t0,onClick:()=>{D(q.toString())},children:"Max"})]}),(0,T.Y)(a.pd,{label:"",placeholder:"Enter amount",value:I,onChange:e=>D(e.value),type:"number",invalid:parseFloat(I)>q,errorText:parseFloat(I)>q?"Insufficient ".concat(j," balance. Transfer amount up to ").concat((0,L.uY)(q,j,P===tz.FUTURES_USDT?es.rB:es.m9)," ").concat(j):"",appendItem:(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(a.In,{name:"separator",style:(0,p.Kk)(20,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)(rt(),{src:"INR"===j?ed.A.ic_indian_rupee:ed.A.ic_tether_usdt,alt:"indian_rupee",height:24,width:24}),(0,T.Y)("span",{css:t1,children:j})]}),onKeyDown:rn.$B})]}),P!==tz.FIAT&&(0,T.Y)(f.L7,{title:"Important Note",description:"Futures wallet supports self-account transfers only.",type:f.$$.INFO,allowAction:!1})]})]})})};var ro=r(37810),ra=r(74657);let rs=e=>{let{status:t,transferType:r,amount:n,currency:i,toAccountLabel:l,fromAccountLabel:o,onDone:s,tryAgain:c}=e,d=r===tz.SPOT_CRYPTO?n:(0,L.uY)(n,i,es.m9),u=r===tz.FUTURES_INR||r===tz.FUTURES_USDT,h="success"===t;return(0,T.Y)(f.Ry,{header:"Transfer ".concat(r===tz.SPOT_CRYPTO?i:"Funds"),primaryButtonText:h?void 0:"Try Again",primaryButtonClick:h?void 0:c,secondaryButtonText:"Okay",secondaryButtonClick:s,children:(0,T.FD)("div",{css:[(0,p.H2)(),(0,p.wh)(20),"",""],children:[(0,T.Y)(f.X9,{image:h?ed.A.i_illustration_01:ed.A.i_empty,title:"".concat(r===tz.SPOT_CRYPTO?i:"Funds"," ").concat("success"===t?"Transferred Successfully!":"Transfer Failed!"),titleStyle:h?void 0:z.vE.textError}),(0,T.FD)(f.$G,{containerPadding:[12],alignVertical:!0,gap:12,children:[(0,T.FD)("div",{css:z.vE.flexJustifiedBetween,children:[(0,T.Y)(f.kU,{text:"Status",textStyle:eE.wo}),(0,T.Y)(a.YD,{type:h?"success":"error",children:h?"Completed":"Failed"})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:z.vE.flexJustifiedBetween,children:[(0,T.Y)(f.kU,{text:r===tz.SPOT_CRYPTO?"Quantity":"Amount",textStyle:eE.wo}),(0,T.Y)("span",{css:a.p0.B4_14_regular,children:"".concat(d," ").concat(i)})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:z.vE.flexJustifiedBetween,children:[(0,T.Y)(f.kU,{text:"From Account",textStyle:eE.wo}),(0,T.FD)("span",{css:a.p0.B4_14_regular,children:[o," ",u&&"(Futures Wallet)"]})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:z.vE.flexJustifiedBetween,children:[(0,T.Y)(f.kU,{text:"To Account",textStyle:eE.wo}),(0,T.FD)("span",{css:a.p0.B4_14_regular,children:[l," ",u&&"(Fiat Wallet)"]})]})]})]})})},rc=e=>{let{onClose:t,handleOverlayClickCallback:r,selectedAccountForTransfer:n}=e,{0:l,1:o}=(0,i.useState)(tG.selectAccounts),{0:a,1:c}=(0,i.useState)(null),{0:d,1:u}=(0,i.useState)(""),{0:p,1:h}=(0,i.useState)(0),{0:g,1:m}=(0,i.useState)(null),v=(0,s.d4)(e=>e.shared.user.userStatus),A=e=>{c(e),o(tG.resultScreen),(0,ep.nk)(),e.transferType===tz.FIAT?(0,ra.CX)():(0,ro.gD)()},b=e=>{c(e),o(tG.resultScreen)},y=e=>a?(0,ep.vh)({fromAccountId:a.fromAccountId,toAccountId:a.toAccountId,amount:a.amount,currency:a.currency,transferType:a.transferType,pin:e,verificationId:d}):void(0,e8.Ax)("Transfer data not found"),_=()=>{if(!a)return;let e=(0,L.uY)(a.amount,a.currency,es.m9);(0,eh.A)({title:"Funds Transferred Successfully!",description:a.transferType===tz.FIAT?"".concat(e," ").concat(a.currency,' amount has been transferred to "').concat(a.toAccountLabel,'" account.'):"".concat(e," ").concat(a.currency,' amount has been transferred to self "Fiat Wallet".'),type:"success"}),(0,ep.nk)(),a.transferType===tz.FIAT?(0,ra.CX)():(0,ro.gD)(),t()};return(0,T.Y)(T.FK,{children:g?(0,T.Y)(f.nE,{error:g,onClose:()=>m(null)}):(()=>{var e,i,s,c,g,S;switch(l){case tG.selectAccounts:return(0,T.Y)(rl,{selectedAccountForTransfer:n,onSuccess:A,onError:b,handleOverlayClickCallback:r});case tG.otpVerification:return(0,T.Y)(eG.A,{title:"OTP Verification",description:["Enter the 6 digit OTP sent on","+".concat(null==v?void 0:v.countryISDCode," ").concat(null==v?void 0:v.mobileNumber),"& regd.","email ID"],verificationINTId:p,verificationId:d,onSuccess:e=>{u(e.verificationId),h(e.verificationIntId),o(tG.pinVerification)},onResendSuccess:e=>{u(e.verificationId),h(e.verificationIntId)},resendOtpType:eG.Z.TransferFund,alignPinOtpWarningIncenter:!0,onError:m});case tG.pinVerification:return(0,T.Y)(f.fV,{title:"PIN Verification",description:"Enter the 4-digit security PIN",onVerifyPin:y,onSuccess:_,onError:m,alignPinWarningInCenter:!0});case tG.resultScreen:return(0,T.Y)(rs,{status:null!=(e=null==a?void 0:a.status)?e:"success",transferType:null!=(i=null==a?void 0:a.transferType)?i:tz.FIAT,amount:null!=(s=null==a?void 0:a.amount)?s:0,currency:null!=(c=null==a?void 0:a.currency)?c:"",toAccountLabel:null!=(g=null==a?void 0:a.toAccountLabel)?g:"",fromAccountLabel:null!=(S=null==a?void 0:a.fromAccountLabel)?S:"",onDone:t,tryAgain:()=>o(tG.selectAccounts)});default:return null}})()})},rd=(0,i.forwardRef)((e,t)=>{var r,n,l;let{onCreateSubAccountClick:o,coachHighlightTarget:d}=e,{0:h,1:g}=(0,i.useState)(""),m=(0,en.A)(h),{0:v,1:A}=(0,i.useState)(!0),{0:b,1:y}=(0,i.useState)(!1),{0:S,1:C}=(0,i.useState)(null),E=(0,i.useRef)(!0),{0:I,1:D}=(0,i.useState)(!1),{0:P,1:O}=(0,i.useState)({});(0,i.useImperativeHandle)(t,()=>({openTransferFunds:()=>{C(null),y(!0)}}),[]);let Y=()=>{y(!1),C(null),E.current=!0},w=(0,s.d4)(e=>e.subAccountsNew.assetsFiatData),F=(0,s.d4)(e=>e.subAccountsNew.subAccountMetadata),R=(0,s.d4)(e=>e.shared.user.userStatus),N=(0,i.useMemo)(()=>(0,tn.nq)(P).total>0,[P]),B=(0,i.useMemo)(()=>{var e;return{permissions:{list:(null!=(e=null==F?void 0:F.userPermissionsList)?e:[]).map(e=>({id:e.permissionId,name:e.permissionName})),title:"Permissions",icon:"reports"}}},[F]);(0,i.useEffect)(()=>{let e=async()=>{A(!0),await (0,ep.nk)(),A(!1)};null===w?e():A(!1)},[]),(0,s.d4)(e=>e.subAccountsNew.portfolioTotal);let x=(0,i.useMemo)(()=>{var e;return null!=(e=null==w?void 0:w.subAccountBalances.filter(e=>{var t;return e.accountId!==parseInt(null!=(t=null==R?void 0:R.accountId)?t:"0")}))?e:[]},[null==w?void 0:w.subAccountBalances,null==R?void 0:R.accountId]),k=(0,i.useMemo)(()=>{let e=x;return m.trim()&&(e=(0,td.Ht)(e,m.trim(),{keys:["email","label","accountId"],threshold:td.Ht.rankings.CONTAINS})),N&&P.permissions&&(e=e.filter(e=>e.permissions.some(e=>P.permissions.includes(e.permissionId)))),e},[x,m,N,P.permissions]),{sortedData:j,sortState:M,handleSort:H}=(0,tu.GY)(k,tR,{field:W.Mq.BALANCE,direction:tu.UE.DESC}),U=[{dataField:W.Mq.ID,component:(0,T.Y)("span",{css:a.Wp.pl(16),children:"Label Name"}),align:"left"},{dataField:W.Mq.BALANCE,component:"Avbl. Balance",align:"right",isSortable:!0},{dataField:W.Mq.QUOTE_CURRENCY,component:"",align:"left"},{dataField:W.Mq.AMNT,component:"Locked Balance",align:"right",isSortable:!0},{dataField:W.Mq.QUOTE_CURRENCY_CV,component:"",align:"left"},{dataField:W.Mq.CHANGE,component:"Avbl. Futures INR",align:"right",isSortable:!0},{dataField:W.Mq.QUOTE_CURRENCY_IV,component:"",align:"left"},{dataField:W.Mq.PACKS_PnL,component:"Avbl. Futures USDT",align:"right",isSortable:!0},{dataField:W.Mq.PnL_QUOTE_CURRENCY,component:"",align:"left"},{dataField:W.Mq.STATUS,component:"Permissions",align:"left"},{dataField:W.Mq.MENU,component:(0,T.Y)(a.In,{name:"filter",style:(0,p.Kk)(),onClick:()=>D(!0)}),align:"center"}],q=()=>{g(""),O({})},Z=(0,i.useMemo)(()=>Array.from({length:8},()=>({[W.Mq.ID]:(0,T.FD)("div",{css:[(0,p.wh)(4),a.Wp.pl(16),"",""],children:[(0,T.Y)(a.WA,{width:100,height:18,style:a.Wp.mb(4)}),(0,T.Y)(a.WA,{width:140,height:12})]}),[W.Mq.BALANCE]:(0,T.Y)(a.WA,{width:60,height:18}),[W.Mq.QUOTE_CURRENCY]:(0,T.Y)(a.WA,{width:24,height:18}),[W.Mq.AMNT]:(0,T.Y)(a.WA,{width:60,height:18}),[W.Mq.QUOTE_CURRENCY_CV]:(0,T.Y)(a.WA,{width:24,height:18}),[W.Mq.CHANGE]:(0,T.Y)(a.WA,{width:60,height:18}),[W.Mq.QUOTE_CURRENCY_IV]:(0,T.Y)(a.WA,{width:24,height:18}),[W.Mq.PACKS_PnL]:(0,T.Y)(a.WA,{width:60,height:18}),[W.Mq.PnL_QUOTE_CURRENCY]:(0,T.Y)(a.WA,{width:30,height:18}),[W.Mq.STATUS]:(0,T.Y)(a.WA,{width:140,height:22}),[W.Mq.MENU]:(0,T.Y)(a.WA,{width:24,height:24})})),[]);return(0,T.FD)("div",{css:[a.vE.flexColumn,"",""],children:[(0,T.Y)(tj,{style:a.Wp.mb(20),showCoachmarkHighlight:d===_.fU.STEP_8_ASSETS_FIAT_STATS}),(0,T.Y)(tq,{isLoading:v,masterBalance:null!=(r=null==w?void 0:w.masterBalance)?r:null,subAccountFiat:null!=(n=null==w?void 0:w.subAccountFiat)?n:null,
1subAccountFuture:null!=(l=null==w?void 0:w.subAccountFuture)?l:null,style:a.Wp.mb(28),coachHighlightTarget:d}),(0,T.FD)("div",{css:a.vE.flexColumn,children:[(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,a.Wp.pb(12),"",""],children:[(0,T.Y)("div",{css:a.p0.B3_16_semibold,children:"Active Sub-Accounts"}),(0,T.Y)(er,{value:h,onChange:g,placeholder:"Search",recentSearchesKey:et.ASSETS_FIAT})]}),(0,T.Y)(f.Cu,{isOpen:I,onOpen:()=>D(!0),onClose:()=>D(!1),list:B,filterIds:P,type:el.R.Filter,onApply:e=>{O(e)},onReset:q,withDateRange:!1},String(I)),(0,T.Y)(W.Ay,{headers:U,rows:v?Z:j.map(e=>{var t,r;let n={};return e.permissions.map(e=>e.permissionName).some(e=>e.toLowerCase().includes("future")),n[W.Mq.ID]=(0,T.FD)("div",{css:[(0,p.wh)(4),a.Wp.pl(16),a.Wp.widthPercentage(100),""],children:[(0,T.Y)(a.m_,{content:e.label,isStroke:!0,disabled:e.label.length<=c.i1,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:tO,children:e.label})}),(0,T.Y)(a.m_,{content:e.email,isStroke:!0,disabled:e.email.length<=c.i1,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:tY,children:e.email||"-"})})]}),n[W.Mq.BALANCE]=(0,T.Y)(a.m_,{content:e.avblBalance.toString(),isStroke:!0,disabled:e.avblBalance.toString().length<=c.uP,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:tw,children:(0,T.Y)(f.AW,{text:(0,L.uY)(e.avblBalance,null!=(t=null==R?void 0:R.currencyCode)?t:"INR",es.m9),textStyles:(0,u.AH)([a.p0.B5_12_regular],""),flagType:"subAccount"})})}),n[W.Mq.QUOTE_CURRENCY]=(0,T.Y)("div",{css:tF,children:"INR"}),n[W.Mq.AMNT]=(0,T.Y)(a.m_,{content:e.lockedBalance.toString(),isStroke:!0,disabled:e.lockedBalance.toString().length<=c.uP,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:tw,children:(0,T.Y)(f.AW,{text:(0,L.uY)(e.lockedBalance,null!=(r=null==R?void 0:R.currencyCode)?r:"INR",es.m9),textStyles:(0,u.AH)([a.p0.B5_12_regular],""),flagType:"subAccount"})})}),n[W.Mq.QUOTE_CURRENCY_CV]=(0,T.Y)("div",{css:tF,children:null==R?void 0:R.currencyCode}),n[W.Mq.CHANGE]=(0,T.Y)(a.m_,{content:e.avblFuturesINR.toString(),isStroke:!0,disabled:e.avblFuturesINR.toString().length<=c.uP,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:tw,children:(0,T.Y)(f.AW,{text:(0,L.uY)(e.avblFuturesINR,"INR",es.m9),textStyles:(0,u.AH)([a.p0.B5_12_regular],""),flagType:"subAccount"})})}),n[W.Mq.QUOTE_CURRENCY_IV]=(0,T.Y)("div",{css:tF,children:"INR"}),n[W.Mq.PACKS_PnL]=(0,T.Y)(a.m_,{content:e.avblFuturesUSDT.toString(),isStroke:!0,disabled:e.avblFuturesUSDT.toString().length<=c.uP,style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:tw,children:(0,T.Y)(f.AW,{text:e.avblFuturesUSDT>0?(0,L.uY)(e.avblFuturesUSDT,"USDT",es.rB):"0.00",textStyles:(0,u.AH)([a.p0.B5_12_regular],""),flagType:"subAccount"})})}),n[W.Mq.PnL_QUOTE_CURRENCY]=(0,T.Y)("div",{css:tF,children:"USDT"}),n[W.Mq.STATUS]=(0,T.Y)(tm,{permissions:e.permissions,selectedPermissionId:P.permissions}),n[W.Mq.MENU]=(0,T.Y)(a.In,{name:"arrow-transfer",style:(0,p.Kk)(),onClick:()=>{C(e),y(!0)}}),n}),noTopBorderRadius:!1,isPaginationEnabled:!1,minHeight:456,columnsSize:[18,9,6,9,6,9,6,9,6,18,4],padding:(0,u.AH)({padding:(0,p.qb)([12,2])},"",""),defaultSortConfig:M,onSortTableValues:H,noSearchResults:v?void 0:0===x.length?(0,T.Y)(tN,{onCreateSubAccountClick:()=>{g(""),o()}}):0===k.length?h||N?(0,T.Y)(f.Z7,{title:"No Results Found",description:h?"Try searching with a different term.":"Try adjusting your filters.",onReset:q}):(0,T.Y)(tB,{onResetFilter:q}):void 0,tableSpace:N?280:220})]}),(0,T.Y)(a.wv,{open:b,onClose:Y,onOverlayClick:()=>{E.current&&Y()},children:b&&(0,T.Y)(rc,{onClose:Y,handleOverlayClickCallback:e=>{E.current=e},selectedAccountForTransfer:S})})]})});rd.displayName="AssetsFiatTabScreen";let ru=(0,u.AH)({padding:(0,p.qb)([20,40,0]),flex:1,overflow:"auto","&::-webkit-scrollbar":{display:"none"}},"","");var rp=r(37543);a.vE.flexColumn;let rh=(0,u.AH)([a.p0.B4_14_regular,a.vE.textFaded,p.gO],"",""),rg=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,a.Wp.mb(12),{height:a.Wp.remConverter(36)}],"","");(0,p.wh)(2),a.Wp.widthPercentage(100),a.p0.B5_12_regular,p.gO,a.Wp.widthPercentage(100),p.gO,a.p0.B5_12_regular,a.vE.textFaded,p.gO,a.Wp.widthPercentage(100),(0,p.wh)(2),a.Wp.widthPercentage(100),a.p0.B5_12_regular,a.vE.textFaded,a.Wp.widthPercentage(100),p.gO,a.p0.B5_12_regular,a.vE.textFaded,p.gO,(0,p.wh)(2),a.p0.B5_12_regular,a.p0.B5_12_regular,a.vE.textFaded,a.p0.B5_12_regular,a.vE.textFaded,p.gO;var rm=r(6950);let rv=function(e){return e.SUB_ACCOUNT="subaccount",e.MASTER_ACCOUNT="master",e}({}),rA=function(e){return e.LOGIN_ACTIVITY="LOGIN_ACTIVITY",e.FIAT_TRANSFER="FIAT_TRANSFER",e.CRYPTO_TRANSFER="ASSET_TRANSFER",e.API_KEY_ACTIVITY="API_KEY_MANAGEMENT",e.ACCOUNT_DASHBOARD_ACTION="A
1CCOUNT_DASHBOARD_ACTION",e.ACCOUNT_CREATIOPN_AND_PERMISSIONS_ACTION="ACCOUNT_CREATION_PERMISSION_MODIFICATION",e}({}),rb=(0,rm.y)(rA),ry={[rA.LOGIN_ACTIVITY]:[15,18,20,16,12,15,4],[rA.FIAT_TRANSFER]:[12,14,14,14,8,6,11,8,9,4],[rA.CRYPTO_TRANSFER]:[12,14,14,14,5,8,6,9,6,8,4],[rA.API_KEY_ACTIVITY]:[12,16,16,12,11,11,12,5,5],[rA.ACCOUNT_DASHBOARD_ACTION]:[15,18,18,18,18,10,5],[rA.ACCOUNT_CREATIOPN_AND_PERMISSIONS_ACTION]:[12,15,15,8,15,15,10,5,5]},rf={dataField:W.Mq.TIME,component:(0,T.Y)("span",{css:a.Wp.pl(12),children:"Time"}),align:"left",isSortable:!0},r_={dataField:W.Mq.NAME,component:"Label Name",align:"left"},rS={dataField:W.Mq.ACTION,component:"Action",align:"left"},rT={dataField:W.Mq.INITIATED_BY,component:"Initiated By",align:"left"},rC={dataField:W.Mq.SOURCE_ACCOUNT,component:"Source Account",align:"left"},rE={dataField:W.Mq.REFERENCE_ID,component:"Reference ID",align:"left"},rI={dataField:W.Mq.TRANSACTION_ID,component:"Txn ID",align:"left"},rD={dataField:W.Mq.AMNT,component:"Amount",align:"right"},rP={dataField:W.Mq.DESTINATION_ACCOUNT,component:"Destination Account",align:"left"},rO={dataField:W.Mq.ASSET,component:"Asset",align:"left"},rY={dataField:W.Mq.QUANTITY,component:"Quantity",align:"right"},rw={dataField:W.Mq.API_KEY_ID,component:"API Key ID",align:"left"},rF={dataField:W.Mq.OLD_PERMISSIONS,component:"Old Permissions",align:"left"},rR={dataField:W.Mq.NEW_PERMISSIONS,component:"New Permissions",align:"left"},rN={dataField:W.Mq.SCOPE,component:"Scope",align:"left"},rB={dataField:W.Mq.IP_ADDRESS,component:"IP Address",align:"left"},rx={dataField:W.Mq.DEVICE,component:"Device",align:"left"},rk={dataField:W.Mq.STATUS,component:"Status",align:"left"},rj={dataField:W.Mq.RESULT,component:"Result",align:"left",isSortable:!0},rW={dataField:W.Mq.FAILURE_REASON,component:"Failure Reason",align:"left"},rL={dataField:W.Mq.CURRENCY_BASE,component:"",align:"left",isSortable:!0},rM={dataField:W.Mq.QUOTE_CURRENCY,component:"",align:"left",isSortable:!0},rH={[rA.LOGIN_ACTIVITY]:[rf,r_,rB,rx,rj,rW],[rA.FIAT_TRANSFER]:[rf,rT,rC,rP,rD,rM,rB,rk,rE],[rA.CRYPTO_TRANSFER]:[rf,rT,rC,rP,rO,rY,rL,rB,rk,rI],[rA.API_KEY_ACTIVITY]:[rf,rC,rP,rw,rS,rN,rB,rk],[rA.ACCOUNT_DASHBOARD_ACTION]:[rf,rC,rP,rS,rB,rk],[rA.ACCOUNT_CREATIOPN_AND_PERMISSIONS_ACTION]:[rf,rC,rP,rS,rF,rR,rB,rk]},rU={field:W.Mq.TIME,key:"time",type:tu.r3.DATE},rq={field:W.Mq.STATUS,key:"status",type:tu.r3.TEXT},rZ={field:W.Mq.RESULT,key:"loginResult",type:tu.r3.TEXT},rV={[rA.LOGIN_ACTIVITY]:[rU,rZ],[rA.FIAT_TRANSFER]:[rU,rq],[rA.CRYPTO_TRANSFER]:[rU,rq],[rA.API_KEY_ACTIVITY]:[rU,rq],[rA.ACCOUNT_DASHBOARD_ACTION]:[rU,rq],[rA.ACCOUNT_CREATIOPN_AND_PERMISSIONS_ACTION]:[rU,rq]},rK=(0,u.AH)([(0,p.wh)(2),a.Wp.widthPercentage(100)],"",""),rG=(0,u.AH)([a.p0.B5_12_regular,p.gO,a.Wp.widthPercentage(100)],"",""),rz=(0,u.AH)([a.p0.B5_12_regular,a.vE.textFaded,p.gO,a.Wp.widthPercentage(100)],"",""),rX=e=>{let{text:t,subText:r,style:n,limit:i=c.i1}=e;return(0,T.FD)("div",{css:[rK,n,"",""],children:[""!==t?(0,T.Y)(a.m_,{content:(0,T.Y)(T.FK,{children:t}),isStroke:!0,disabled:r$(t,i),style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:rG,children:null!=t?t:"----"})}):null,""!==r?(0,T.Y)(a.m_,{content:(0,T.Y)(T.FK,{children:r}),isStroke:!0,disabled:r$(r,i),style:a.Wp.widthPercentage(100),children:(0,T.Y)("div",{css:rz,children:null!=r?r:"----"})}):null]})},r$=(e,t)=>null==e||e.length<=t,rQ=e=>{let{width:t=60,style:r}=e;return(0,T.FD)("div",{css:[rK,r,"",""],children:[(0,T.Y)(a.WA,{height:14,width:t,widthSizeType:"%"}),(0,T.Y)(a.WA,{height:14,width:80,widthSizeType:"%"})]})},rJ=e=>{let{width:t=80}=e;return(0,T.Y)(a.WA,{height:22,width:t,widthSizeType:"%"})};var r0=r(47271);let r1=(e,t,r)=>({list:e,title:t,icon:r}),r2=(e,t,r)=>({list:null!=e?e:[],title:t,icon:r}),r4={[rA.LOGIN_ACTIVITY]:()=>({}),[rA.FIAT_TRANSFER]:(e,t)=>({sourceAccount:r1(e,"Source Account","pan"),destinationAccount:r1(e,"Destination Account","pan"),currency:r2(null==t?void 0:t.currencyOptions,"Currency","exchange"),status:r2(null==t?void 0:t.statusOptions,"Status","term")}),[rA.CRYPTO_TRANSFER]:(e,t)=>({assets:r2(null==t?void 0:t.assets,"Assets","coins"),sourceAccount:r1(e,"Source Account","pan"),destinationAccount:r1(e,"Destination Account","pan"),status:r2(null==t?void 0:t.statusOptions,"Status","term")}),[rA.API_KEY_ACTIVITY]:(e,t)=>({sourceAccount:r1(e,"Source Account","pan"),destinationAccount:r1(e,"Destination Account","pan"),action:r2(null==t?void 0:t.apiKeyManagementAction,"Action","actions")}),[rA.ACCOUNT_DASHBOARD_ACTION]:(e,t)=>({action:r2(null==t?void 0:t.accountDashboardActionOptions,"Action Type","actions")}),[rA.ACCOUNT_CREATIOPN_AND_PERMISSIONS_ACTION]:(e,t)=>({action:r2(null==t?void 0:t.accountCreatePermissionActions,"Action","actions"),oldPermissions:r2(null==t?void 0:t.allPermissionsList,"Old Permissions","permissions"),newPermissions:r2(null==t?void 0:t.allPermissionsList,"New Permissions","permissions")})};var r8=r(33258);function r5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r6(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?r5(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):r5(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let r3=i.forwardRef((e,t)=>{let{coachHighlightTarget:r}=e,n=(0,l.useRouter)(),{0:o,1:c}=(0,i.useState)(rA.LOGIN_ACTIVITY),{0:d,1:h}=(0,i.useState)(""),{0:g,1:m}=(0,i.useState)(!0),{0:v,1:A}=(0,i.useState)(null),{0:b,1:y}=(0,i.useState)(0),{0:C,1:E}=(0,i.useState)(1),{0:I,1:D}=(0,i.useState)(25),{0:P,1:O}=(0,i.useState)(!1),{0:Y,1:w}=(0,i.useState)({}),{0:F,1:R}=(0,i.useState)(tn.Rc),N=(0,s.d4)(e=>e.subAccountsNew.subAccountMetadata),B=(0,s.d4)(e=>e.subAccountsNew.allAccountsList);(0,r8.Y)({queryKey:eg.X.LOG_TYPE,state:o,setState:c,isValid:rb});let x=(0,i.useRef)(null),k=(0,en.A)(d,500),j=(0,i.useMemo)(()=>{var e;return null!=(e=null==N?void 0:N.logTypeOptions.map(e=>({label:(0,T.Y)("div",{css:rh,children:e.name}),value:e.id.toString()})))?e:[]},[N]),M=(0,i.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:25;x.current&&x.current.abort(),x.current=new AbortController,m(!0);try{var r,n,i,l,a,s,c,d;let u={pageNumber:e,pageSize:t,logTypeId:o,searchText:k,statusId:(null==(r=Y.status)?void 0:r.join(","))||"ALL",accountTypeId:(null==(n=Y.accountType)?void 0:n.join(","))||"ALL",oldPermissionId:(null==(i=Y.oldPermissions)?void 0:i.join(","))||"ALL",newPermissionId:(null==(l=Y.newPermissions)?void 0:l.join(","))||"ALL",sourceAccount:(null==(a=Y.sourceAccount)?void 0:a.join(","))||"ALL",destinationAccount:(null==(s=Y.destinationAccount)?void 0:s.join(","))||"ALL",currency:(null==(c=Y.currency)?void 0:c.join(","))||"ALL",asset:(null==(d=Y.assets)?void 0:d.join(","))||"ALL",startDate:F.startDate,endDate:F.endDate},p=await (0,ep.wh)(u,x.current.signal);if((null==p?void 0:p.statusCode)==200)if(null!=p&&p.data){let e=p.data;A(e.logs||[]),y(e.totalCount||0)}else(0,eh.A)({title:"Note",description:(null==p?void 0:p.statusDescription)||"No data found",type:e7.C.info});else(0,e8.Ax)(null==p?void 0:p.statusDescription)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return}finally{m(!1)}},[o,k,F.startDate,F.endDate,Y]);(0,i.useEffect)(()=>(M(1,I),()=>{x.current&&x.current.abort()}),[o,k,Y,F,I]);let H=(0,i.useCallback)(async()=>{try{var e,t,r,n,i,l,a,s,c;let d={pageNumber:1,pageSize:b||1,logTypeId:o,searchText:k.trim(),statusId:(null==(e=Y.status)?void 0:e.join(","))||"ALL",accountTypeId:(null==(t=Y.accountType)?void 0:t.join(","))||"ALL",oldPermissionId:(null==(r=Y.oldPermissions)?void 0:r.join(","))||"ALL",newPermissionId:(null==(n=Y.newPermissions)?void 0:n.join(","))||"ALL",sourceAccount:(null==(i=Y.sourceAccount)?void 0:i.join(","))||"ALL",destinationAccount:(null==(l=Y.destinationAccount)?void 0:l.join(","))||"ALL",currency:(null==(a=Y.currency)?void 0:a.join(","))||"ALL",asset:(null==(s=Y.assets)?void 0:s.join(","))||"ALL",startDate:F.startDate,endDate:F.endDate,download:!0},u=await (0,ep.wh)(d),p=null==u||null==(c=u.data)?void 0:c.csvFileBase64;if(p){let e=atob(p),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);let r=new Blob([t],{type:"text/csv"}),n=window.URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download="".concat(o.toLocaleLowerCase(),"_logs-").concat(new Date().toISOString().slice(0,10),".csv"),document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n)}else(0,eh.A)({title:"Note",description:"No data found",type:e7.C.info})}catch(e){(0,e8.Ax)("Failed to download audit logs")}},[o,k,Y,F.startDate,F.endDate,b]);(0,i.useImperativeHandle)(t,()=>({exportAuditLogs:H}),[H]);let U=(0,i.useCallback)(()=>{O(!0)},[]),q=(0,i.useMemo)(()=>(e=>{let{logType:t,onFilterClick:r}=e;return[...rH[t],{dataField:W.Mq.MENU,component:(0,T.Y)(a.In,{name:"filter",style:(0,p.Kk)(),onClick:r}),align:"center"}]})({logType:o,onFilterClick:U}),[o,U]),Z=(0,i.useMemo)(()=>ry[o],[o]),V=(0,i.useMemo)(()=>{let e={};return e[W.Mq.TIME]=(0,T.Y)(rQ,{style:a.Wp.pl(10)}),e[W.Mq.INITIATED_BY]=(0,T.Y)(rQ,{}),e[W.Mq.SOURCE_ACCOUNT]=(0,T.Y)(rQ,{}),e[W.Mq.DESTINATION_ACCOUNT]=(0,T.Y)(rQ,{}),e[W.Mq.ACTION]=(0,T.Y)(rJ,{}),e[W.Mq.AMNT]=(0,T.Y)(rJ,{}),e[W.Mq.REFERENCE_ID]=(0,T.Y)(rJ,{}),e[W.Mq.TRANSACTION_ID]=(0,T.Y)(rJ,{}),e[W.Mq.ASSET]=(0,T.Y)(rJ,{}),e[W.Mq.QUANTITY]=(0,T.Y)(rJ,{}),e[W.Mq.CURRENCY_BASE]=(0,T.Y)(rJ,{}),e[W.Mq.API_KEY_ID]=(0,T.Y)(rJ,{}),e[W.Mq.OLD_PERMISSIONS]=(0,T.Y)(rJ,{}),e[W.Mq.NEW_PERMISSIONS]=(0,T.Y)(rJ,{}),e[W.Mq.SCOPE]=(0,T.Y)(rJ,{}),e[W.Mq.QUOTE_CURRENCY]=(0,T.Y)(rJ,{}),e[W.Mq.NAME]=(0,T.Y)(rQ,{}),e[W.Mq.IP_ADDRESS]=(0,T.Y)(rQ,{}),e[W.Mq.DEVICE]=(0,T.Y)(rJ,{}),e[W.Mq.STATUS]=(0,T.Y)(rJ,{width:90}),e[W.Mq.RESULT]=(0,T.Y)(rJ,{width:90}),e[W.Mq.FAILURE_REASON]=(0,T.Y)(rJ,{}),e[W.Mq.MENU]=(0,T.Y)(T.FK,{}),Array.from({length:10},()=>e)},[]),{sortedData:K,sortState:G,handleSort:z}=(0,tu.GY)(null!=v?v:[],rV[o],{field:W.Mq.TIME,direction:W.UE.DESC}),X=(0,i.useCallback)(()=>K.map(e=>{var t,r,n,i,l,s,c,d,u,p,h,g,m,v,A,b;let y={},{date:f,time:_}=(0,tp.QF)(e.time),S=(null==(t=e.status)?void 0:t.toLowerCase())==="success",C=[rA.API_KEY_ACTIVITY,rA.ACCOUNT_CREATIOPN_AND_PERMISSIONS_ACTION,rA.ACCOUNT_DASHBOARD_ACTION].includes(o)?e.parentAccountDetails:e.sourceAccountDetails;return y[W.Mq.TIME]=(0,T.Y)(rX,{text:f,subText:_,style:a.Wp.pl(12)}),y[W.Mq.NAME]=(0,T.Y)(rX,{text:(null==(r=e.accountDetails)?void 0:r.accountType.toLocaleLowerCase())===rv.MASTER_ACCOUNT?null==(n=e.accountDetails)?void 0:n.name:null==(i=e.accountDetails)?void 0:i.label,subText:null==(l=e.accountDetails)?void 0:l.email}),y[W.Mq.INITIATED_BY]=(0,T.Y)(rX,{text:(null==(s=e.initiatorAccountDetails)?void 0:s.accountType.toLocaleLowerCase())===rv.MASTER_ACCOUNT?null==(c=e.initiatorAccountDetails)?void 0:c.name:null==(d=e.initiatorAccountDetails)?void 0:d.label,subText:null==(u=e.initiatorAccountDetails)?void 0:u.email}),y[W.Mq.SOURCE_ACCOUNT]=(0,T.Y)(rX,{text:(null==C?void 0:C.accountType.toLocaleLowerCase())===rv.MASTER_ACCOUNT?null==C?void 0:C.name:null==C?void 0:C.label,subText:null==C?void 0:C.email}),y[W.Mq.DESTINATION_ACCOUNT]=(0,T.Y)(rX,{text:(null==(p=e.destinationAccountDetails)?void 0:p.accountType.toLocaleLowerCase())===rv.MASTER_ACCOUNT?null==(h=e.destinationAccountDetails)?void 0:h.name:null==(g=e.destinationAccountDetails)?void 0:g.label,subText:null==(m=e.destinationAccountDetails)?void 0:m.email}),y[W.Mq.ACTION]=(0,T.Y)(rX,{text:"",subText:e.action}),y[W.Mq.AMNT]=(0,T.Y)(rX,{text:(0,L.uY)(e.amount,e.currency,2),subText:""}),y[W.Mq.REFERENCE_ID]=(0,T.Y)(rX,{text:"",subText:e.referenceId}),y[W.Mq.TRANSACTION_ID]=(0,T.Y)(rX,{text:"",subText:e.txnId}),y[W.Mq.ASSET]=(0,T.Y)(rX,{text:e.asset,subText:""}),y[W.Mq.QUANTITY]=(0,T.Y)(rX,{text:null==(v=e.quantity)?void 0:v.toString(),subText:""}),y[W.Mq.CURRENCY_BASE]=(0,T.Y)(rX,{subText:e.asset,text:""}),y[W.Mq.API_KEY_ID]=(0,T.Y)(rX,{text:e.apiKeyId,subText:""}),y[W.Mq.OLD_PERMISSIONS]=(0,T.Y)(rX,{subText:null==(A=e.oldPermissionNames)?void 0:A.join(", "),text:""}),y[W.Mq.NEW_PERMISSIONS]=(0,T.Y)(rX,{text:"",subText:null==(b=e.newPermissionNames)?void 0:b.join(", ")}),y[W.Mq.SCOPE]=(0,T.Y)(rX,{subText:e.apiKeyScope,text:""}),y[W.Mq.QUOTE_CURRENCY]=(0,T.Y)(rX,{subText:e.currency,text:""}),y[W.Mq.IP_ADDRESS]=(0,T.Y)(rX,{text:e.location?e.ipAddress:"",subText:e.location?e.location:e.ipAddress}),y[W.Mq.DEVICE]=(0,T.Y)(rX,{subText:e.device,text:""}),y[W.Mq.STATUS]=(0,T.Y)(a.YD,{type:S?"success":"error",size:"small",children:e.status}),y[W.Mq.RESULT]=(0,T.Y)(a.YD,{type:S?"success":"error",size:"small",children:e.loginResult||e.status}),y[W.Mq.FAILURE_REASON]=(0,T.Y)(rX,{subText:e.failureReason,text:""}),y[W.Mq.MENU]=(0,T.Y)(T.FK,{}),y}),[K,o]),$=()=>{h("")},Q=(0,i.useMemo)(()=>(0,tn.nq)(Y).total>0,[Y]),J=()=>{w({})};return(0,T.FD)("div",{css:[a.vE.flexColumn,"",""],children:[(0,T.FD)("div",{css:rg,children:[(0,T.Y)("div",{css:[r===_.fU.STEP_9_AUDIT_LOG_ACCOUNT_LIST&&S.iQ,"",""],children:(0,T.Y)(rr.A,{placeholder:"Select Log Type",selected:o,onChange:e=>{c(e),n.replace({pathname:n.pathname,query:r6(r6({},n.query),{},{[eg.X.LOG_TYPE]:e})},void 0,{shallow:!0}),h(""),w({}),R(tn.Rc)},options:j,maxRows:6,rowHeight:44,search:{placeholder:"",value:"",onChange:()=>{}},style:(0,p.Ck)(345),openDropdown:r===_.fU.STEP_9_AUDIT_LOG_ACCOUNT_LIST,dropdownId:(0,_.gM)(_.fU.STEP_9_AUDIT_LOG_ACCOUNT_LIST)})}),(0,T.Y)(a.DO,{value:d,placeholder:"Search by label name, email, or IP address",onChange:e=>h(e.value),customDarkBgcolor:a.Tj.Zeb_Solid_Dark_Blue,style:(0,ee.Rt)(350),onClear:$})]}),(0,T.Y)(f.Cu,{isOpen:P,onOpen:()=>O(!0),onClose:()=>O(!1),list:((e,t,r)=>{var n;let i=null!=(n=null==e?void 0:e.map(e=>({id:e.accountId,name:"".concat(e.name).concat(e.type===r0.Zs.MASTER_ACCOUNT?" (Master Account)":"")}
1)))?n:[],l=r4[r];return l?l(i,t):{}})(B,N,o),filterIds:Y,type:el.R.Filter,onApply:(e,t)=>{w(e),R(t)},onReset:J,selectedCustomDate:F},String(P)),(0,T.Y)(W.Ay,{headers:q,rows:g?V:X(),noTopBorderRadius:!1,isPaginationEnabled:!0,minHeight:450,columnsSize:Z,padding:(0,u.AH)({padding:(0,p.qb)([12,2])},"",""),defaultSortConfig:G,onSortTableValues:z,noSearchResults:g?void 0:v&&(null==v?void 0:v.length)===0?Q||""!==d?(0,T.Y)(f.Z7,{searchValue:d,title:"No Results Found",description:"No audit logs available for the selected search/filters.",onReset:Q?J:$,buttonText:Q?"Reset Filter":"Reset Search"}):(0,T.Y)(ti.A,{imageHeight:140,imageWidth:140,image:ed.A.i_zebpay_logo,title:"No audit logs to display",description:"You don't have any activity yet."}):void 0,tableSpace:Q?285:225,pagination:{pageNo:C,pageSize:I,totalCount:b,setPageNo:E,setPageSize:D}})]})});r3.displayName="AuditLogTabScreen";let r9=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,a.Wp.mb(12),{height:a.Wp.remConverter(36)}],"","");a.p0.B4_14_regular,p.gO;let r7=function(e){return e.EDIT="edit",e.DELETE="delete",e}({}),ne=function(e){return e[e.SPOT=1]="SPOT",e[e.FUTURES=2]="FUTURES",e[e.FETCH_DETAILS=3]="FETCH_DETAILS",e}({}),nt=function(e){return e[e.RESTRICTED=1]="RESTRICTED",e[e.NON_RESTRICTED=2]="NON_RESTRICTED",e}({}),nr=[{id:ne.SPOT,name:"Spot Trading"},{id:ne.FUTURES,name:"Futures Trading"},{id:ne.FETCH_DETAILS,name:"Fetch Details"}],nn=[{id:nt.RESTRICTED,name:"Restricted IPs"},{id:nt.NON_RESTRICTED,name:"Non Restricted IPs"}],ni=(e,t)=>e.permission.some(e=>e.id===t),nl=function(e){return e.CREATE_API_KEYS="CREATE_API_KEYS",e.UPDATE_API_KEYS="UPDATE_API_KEYS",e.DELETE_API_KEYS="DELETE_API_KEYS",e.API_KEYS="API_KEYS",e}({}),no=e=>{let{handleMenuClick:t}=e,r=[{label:"Edit",icon:"edit",id:r7.EDIT},{label:"Delete",icon:"delete",id:r7.DELETE}];return(0,T.Y)(a.ND,{content:(0,T.Y)(tA,{title:"Actions",menuItems:r,onClick:e=>t(e)}),allowInsideClickClose:!0,children:(0,T.Y)(a.In,{name:"menu",style:(0,p.Kk)()})})};var na=r(50341),ns=r(70328),nc=r(99490);let nd=(0,u.AH)({padding:a.Wp.remConverter(12),borderRadius:a.Wp.remConverter(12),background:a.Tj.Zeb_Solid_Dark_Blue},"",""),nu=e=>{let{apiKey:t,isVisible:r,isFirstRow:n=!1,coachHighlightTarget:i,showCoachmarkWalkthrough:l=!1}=e,o=n&&i===_.fU.STEP_7_API_MANAGEMENT_API_KEYS_DETAILS;return(0,T.FD)("div",{id:n?(0,_.gM)(_.fU.STEP_7_API_MANAGEMENT_API_KEYS_DETAILS):void 0,css:[(0,p.sM)(8),a.Wp.widthPercentage(100),o&&S.GZ,"",""],children:[r?(0,T.Y)("div",{css:[eE.rg,p.gO,"",""],children:(0,nc.gX)(t)}):(0,T.Y)(nh,{}),(0,T.FD)(a.ND,{content:(0,T.Y)(np,{apiKey:t,isVisible:r}),position:"bottom",allowInsideClickClose:!0,children:[(0,T.Y)(a.In,{name:"info",style:(0,p.Kk)(14,a.Tj.Zeb_Solid_Bright_Blue)}),l?(0,T.Y)("div",{css:[o&&S.iQ,(0,u.AH)({position:"absolute",top:40,right:0,opacity:+!!o},"",""),"",""],children:(0,T.Y)("div",{css:nd,children:(0,T.Y)(np,{apiKey:t,isVisible:r})})}):null]})]})},np=e=>{let{apiKey:t,isVisible:r}=e,{0:n,1:l}=(0,i.useState)(r);return(0,i.useEffect)(()=>{if(r||!n)return;let e=window.setTimeout(()=>{l(!1)},1e4);return()=>window.clearTimeout(e)},[r,n]),(0,T.FD)("div",{css:(0,p.wh)(12),children:[(0,T.Y)("span",{css:[a.p0.B4_14_semibold,"",""],children:"API Key Details"}),(0,T.Y)(f.$G,{containerPadding:[16],bgColor:a.Tj.Zeb_Solid_BG_Blue,children:(0,T.FD)("div",{css:(0,p.sM)(20),children:[(0,T.Y)(na.r,{value:t,size:120,style:(0,p.l$)(8)}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)("span",{css:eE.wo,children:"API Key"}),(0,T.Y)(a.In,{name:n?"show":"hide",style:(0,p.Kk)(20,a.Tj.Zeb_Solid_Bright_Blue),onClick:()=>l(!n)})]}),(0,T.FD)("div",{css:(0,p.sM)(12),children:[n?(0,T.Y)("span",{css:[a.p0.H6_16_bold,"",""],children:(0,nc.gX)(t)}):(0,T.Y)(nh,{}),(0,T.Y)(ns.A,{textToCopy:t,copyLabel:"API Key",iconStyle:(0,p.Kk)(20,a.Tj.Zeb_Solid_Bright_Blue)})]})]})]})})]})},nh=e=>{let{length:t=20,fontSize:r=24}=e;return(0,T.Y)("span",{css:(0,u.AH)([a.vE.flexAlignCenter,p.gO,a.Wp.widthPercentage(100),a.vE.textFaded,{fontSize:a.Wp.remConverter(r),width:"max-content"}],"",""),children:"*".repeat(t)})};var ng=r(98229);let nm=(0,u.AH)([(0,p.sM)(8),a.Wp.widthPercentage(100),p.gO],"",""),nv=(0,u.AH)([a.p0.B4_14_regular,a.vE.textError],"",""),nA=(0,u.AH)([a.p0.B4_14_regular,a.Wp.pl(32),{color:a.Tj.Zeb_Solid_Yellow}],"","");var nb=r(52174);let ny=e=>{let{}=e;return(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)("span",{css:eE.wo,children:"Permissions"}),(0,T.Y)(a.ND,{content:(0,T.Y)(nf,{}),style:(0,p.YL)(330),position:"bottom",children:(0,T.Y)(a.In,{name:"info",style:(0,p.Kk)(16,a.Tj.Zeb_Solid_Bright_Blue)})})]})},nf=()=>(0,T.FD)("div",{css:(0,p.wh)(16),children:[(0,T.FD)("div",{css:(0,p.wh)(8),children:[(0,T.Y)(f.kU,{text:"Permissions Details",textStyle:(0,u.AH)([a.p0.B4_14_semibold],"",""),leadingIcon:"api"}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:eE.rg,children:"Select the permissions you want to assign to this API key. You can allow:"}),(0,T.FD)("ul",{css:(0,u.AH)([(0,p.wh)(2),{margin:0,paddingLeft:a.Wp.remConverter(24)}],"",""),children:[(0,T.Y)("li",{css:eE.rg,children:"Spot Trading (Place/cancel spot Orders)"}),(0,T.Y)("li",{css:eE.rg,children:"Futures Trading (Place limit/market orders)"}),(0,T.Y)("li",{css:eE.rg,children:"Fetch balances, positions, & orders"})]})]})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)("span",{css:(0,u.AH)([a.p0.B5_12_regular],"",""),children:"More Details"}),(0,T.Y)(a.$n,{type:"link",size:"small",onClick:()=>{window.open(nb.SY,"_blank")},children:"View Documentation"})]})]}),n_=/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/,nS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(([0-9a-fA-F]{1,4}:){1,7}:)|(([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4})|(([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2})|(([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3})|(([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4})|(([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5})|([0-9a-fA-F]{1,4}:)((:[0-9a-fA-F]{1,4}){1,6})|(:)((:[0-9a-fA-F]{1,4}){1,7}|:))$/;function nT(e,t){return 0===e.length?"":e.length>t?"Maximum of ".concat(t," IP's can be whitelisted."):e.some(e=>!(n_.test(e)||nS.test(e)))?"Enter valid addresses, separated by commas.":""}let nC=["Whitelisting your IP address adds an extra layer of security by restricting access to the API key from specific IP addresses.","Never share API keys with anyone.","API secret keys shall be shown only once. Please save it in a secure manner."],nE="Futures is disabled since Margin Trading is active. In order to make any changes reach out to the customer support.",nI=e=>{var t;let{onSuccess:r,isMarginTradingEnabled:n}=e,{0:l,1:o}=(0,i.useState)(null),{0:c,1:d}=(0,i.useState)(""),{0:h,1:g}=(0,i.useState)([]),{0:m,1:v}=(0,i.useState)(""),{0:A,1:b}=(0,i.useState)(!1),{0:y,1:_}=(0,i.useState)(!1),{0:S,1:C}=(0,i.useState)(""),{0:E,1:I}=(0,i.useState)(""),D=(0,en.A)(c,500),P=(0,s.d4)(e=>e.subAccountsNew.subAccountsList),O=(0,s.d4)(e=>e.subAccountsNew.subAccountApiKeys),Y=(0,i.useCallback)(e=>{if(!(null!=O&&O.subAccountApiKeyCounts))return 0;let t=O.subAccountApiKeyCounts.find(t=>t.subAccountId===e);return(null==t?void 0:t.totalApiKeys)||0},[O]),w=(0,i.useCallback)(e=>!!O&&Y(e)>=O.allowNoOfAPIs,[O,Y]),F=(0,i.useMemo)(()=>null!==l&&w(l),[l,w]),R=(0,i.useMemo)(()=>(null==O?void 0:O.allowNoOfIP)||10,[O]),N=(0,i.useMemo)(()=>P?P.filter(e=>e.accountStatus===j.CX.Active).map(e=>{let t=w(e.accountId);return{label:(0,T.FD)("div",{css:nm,children:[(0,T.FD)("div",{css:(0,p.sM)(4),children:[(0,T.Y)("span",{css:[a.p0.B4_14_regular,"",""],children:e.label}),(0,T.Y)(a.In,{name:"separator",style:(0,p.Kk)(12,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)("span",{css:eE.rg,children:e.email})]}),t&&(0,T.Y)(a.YD,{type:"error",children:"API Key limit reached"})]}),value:e.accountId.toString(),displayLabel:(0,T.Y)("div",{css:[a.p0.B4_14_regular,"",""],children:e.label})}}):[],[P,w]),B=e=>e.trim()?e.split(",").map(e=>e.trim()).filter(e=>e.length>0):[];(0,i.useEffect)(()=>{""!==D.trim()&&D.trim().length<3?C("API Key name must be at least 3 characters"):C("")},[D]),(0,i.useEffect)(()=>{I(nT(B(m),R))},[m,R]),(0,i.useEffect)(()=>{b(null!==l&&!F&&c.trim().length>=3&&h.length>0&&!S&&!E)},[l,F,c,h,S,E]);let x=async()=>
1{if(null===l||!A)return;_(!0);let e=B(m);try{let t=await (0,ep.Iq)({SubAccountId:l,Name:c,PermissionIds:h,IpAddress:e,PIN:"",VerificationId:"",VerificationCode:""});(null==t?void 0:t.statusCode)===200&&t.data?r(t.data.verificationId||"",t.data.verificationIntId,{subAccountId:l,apiKeyName:c,permissionIds:h,ipAddresses:e}):(0,e8.Ax)(null==t?void 0:t.statusDescription)}catch(e){console.error(e)}finally{_(!1)}};return(0,T.Y)(ey.A,{header:"Create API Key",primaryButtonText:"CONTINUE TO VERIFICATION",primaryButtonClick:x,disablePrimaryBtn:!A||y,isPrimaryCtaLoading:y,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(20),"",""],children:[(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:[eE.wo,F&&a.vE.textError,"",""],children:"Sub-Account"}),(0,T.Y)(rr.A,{placeholder:"Select",selected:null!=(t=null==l?void 0:l.toString())?t:"",onChange:e=>o(parseInt(e,10)),options:N,maxRows:5,rowHeight:44,search:{placeholder:"",value:"",onChange:()=>{}}}),F&&(0,T.Y)("span",{css:nv,children:"You have reached the maximum limit for API key generation. In order to create new API key you need to delete existing API key."})]}),(0,T.Y)(a.pd,{label:"API Key Name",placeholder:"Enter name",value:c,onChange:e=>{e.value.length<=30&&d(e.value)},invalid:!!S,errorText:S,appendItem:(0,T.Y)(eH,{isFocused:c.length>0,value:c,maxLength:30})}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)(ny,{}),(0,T.Y)(f.$G,{alignVertical:!0,gap:12,children:[{id:1,name:"Spot Trading (Place/cancel spot Orders)"},{id:2,name:"Futures Trading (Place limit/market orders)",disabled:n,message:nE},{id:3,name:"Fetch balances, positions, & orders"}].map(e=>(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(f.Is,{value:e.id,checked:h.includes(e.id),onChange:t=>{let{checked:r}=t;return((e,t)=>{g(r=>t?[...r,e]:r.filter(t=>t!==e))})(e.id,r)},disabled:e.disabled}),(0,T.Y)("span",{css:eE.wo,children:e.name})]}),e.disabled&&e.message&&(0,T.Y)("span",{css:nA,children:e.message})]},e.id))})]}),(0,T.Y)(a.pd,{label:"Whitelist IP Address (optional)",placeholder:"Multiple IP addresses, separated by commas",value:m,onChange:e=>v(e.value),invalid:!!E,errorText:E}),(0,T.Y)(f.L7,{title:"Informative Note",description:nC,type:f.$$.INFO,allowAction:!1,style:(0,u.AH)({padding:(0,p.qb)([12,24])},"","")})]})})};var nD=r(99748);let nP=e=>{let{apiSecret:t,onClose:r}=e;return(0,T.Y)(ey.A,{header:"Reminder: Save Secret Key",primaryButtonText:"GOT IT",primaryButtonClick:r,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(20),"",""],children:[(0,T.Y)("p",{css:[a.p0.H5_20_regular,{color:a.Tj.Zeb_Solid_Light_Blue},"",""],children:"Please ensure you've copied and saved your secret key. It will not be visible again."}),(0,T.FD)(f.$G,{alignVertical:!0,gap:20,children:[(0,T.Y)(na.r,{value:t,size:134,style:(0,p.l$)(8)}),(0,T.FD)("div",{css:(0,p.wh)(12),children:[(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:[(0,p.sM)(20),a.vE.flexJustifiedBetween,"",""],children:[(0,T.Y)("span",{css:eE.rg,children:"Secret Key"}),(0,T.FD)("div",{css:[(0,p.sM)(8),(0,p.p7)(50),"",""],children:[(0,T.Y)(f.hR,{textToCopy:t,iconStyle:(0,p.Kk)(16,a.Tj.Zeb_Solid_Bright_Blue)}),(0,T.Y)("span",{css:[a.p0.B4_14_semibold,p.gO,(0,p.p7)(),"",""],children:t})]})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.Y)(f.vS,{title:"Important Note",allowedList:[nD.T0],containerPadding:[0],titleStyle:(0,u.AH)([a.p0.B3_16_semibold],"","")})]})]})]})})},nO=function(e){return e.details="details",e.otpVerification="otpVerification",e.pinVerification="pinVerification",e.successScreen="successScreen",e.saveSecretKeyReminder="saveSecretKeyReminder",e}({}),nY=e=>{let{onClose:t,handleOverlayClickCallback:r,handleCloseRestrictedCallback:n}=e,{0:l,1:o}=(0,i.useState)(nO.details),{0:a,1:c}=(0,i.useState)(""),{0:d,1:u}=(0,i.useState)(0),{0:p,1:h}=(0,i.useState)(""),{0:g,1:m}=(0,i.useState)(null),{0:v,1:A}=(0,i.useState)(null),b=(0,s.d4)(e=>e.shared.user.userStatus),y=(0,s.d4)(e=>e.subAccountsNew.subAccountsList);(0,i.useEffect)(()=>{r&&r(l===nO.details)},[l,r]),(0,i.useEffect)(()=>{[nO.successScreen,nO.saveSecretKeyReminder].includes(l)&&n(!0)},[l,n]);let _=(e,t,r)=>{c(e),u(t),m(r),o(nO.otpVerification)},S=e=>g?(0,ep.Iq)({SubAccountId:g.subAccountId,Name:g.apiKeyName,PermissionIds:g.permissionIds,IpAddress:g.ipAddresses,PIN:e,VerificationId:a,VerificationCode:p}):void(0,e8.Ax)("Form data not available"),C=e=>{A(e),(0,ep.dI)(),o(nO.successScreen)},E=()=>
1{o(nO.saveSecretKeyReminder)},I=()=>{t()};return(0,T.Y)(T.FK,{children:(()=>{switch(l){case nO.details:return(0,T.Y)(nI,{onSuccess:_,isMarginTradingEnabled:!1});case nO.otpVerification:return(0,T.Y)(eG.A,{title:"OTP Verification",description:["Enter the 6 digit OTP sent on","+".concat(null==b?void 0:b.countryISDCode," ").concat(null==b?void 0:b.mobileNumber),"& regd.","email ID"],verificationINTId:d,verificationId:a,onSuccess:e=>{c(e.verificationId),u(e.verificationIntId),o(nO.pinVerification)},onResendSuccess:e=>{c(e.verificationId),u(e.verificationIntId)},resendOtpType:eG.Z.ApiCreation,alignPinOtpWarningIncenter:!0});case nO.pinVerification:return(0,T.Y)(f.fV,{title:"PIN Verification",description:"Enter the 4-digit security PIN",onVerifyPin:S,onSuccess:C,alignPinWarningInCenter:!0});case nO.successScreen:if(!g||!v)return null;return(0,T.Y)(nD.Ay,{formData:g,apiKey:v.apiKey||"",apiSecret:v.secret||"",subAccountLabel:(e=>{let t=null==y?void 0:y.find(t=>t.accountId===e);return{label:(null==t?void 0:t.email)||"Sub-Account",email:(null==t?void 0:t.email)||""}})(g.subAccountId).label,onContinue:E});case nO.saveSecretKeyReminder:if(!v)return null;return(0,T.Y)(nP,{apiSecret:v.secret||"",onClose:I});default:return null}})()})},nw=["Whitelisting your IP address adds an extra layer of security by restricting access to the API key from specific IP addresses.","Never share API keys with anyone.","API secret keys shall be shown only once. Please save it in a secure manner."],nF=e=>{let{apiKeyData:t,subAccountId:r,onSuccess:n,isMarginTradingEnabled:l}=e,{0:o,1:c}=(0,i.useState)(t.name),{0:d,1:h}=(0,i.useState)(t.permission.map(e=>e.id)),{0:g,1:m}=(0,i.useState)(t.ipAddress.join(", ")),{0:v,1:A}=(0,i.useState)(!1),{0:b,1:y}=(0,i.useState)(!1),{0:_,1:S}=(0,i.useState)(""),{0:C,1:E}=(0,i.useState)(""),I=(0,en.A)(o,500),D=(0,s.d4)(e=>e.subAccountsNew.subAccountApiKeys),P=(0,i.useMemo)(()=>(null==D?void 0:D.allowNoOfIP)||10,[D]),O=e=>e.trim()?e.split(",").map(e=>e.trim()).filter(e=>e.length>0):[];(0,i.useEffect)(()=>{""!==I.trim()&&I.trim().length<3?S("API Key name must be at least 3 characters"):S("")},[I]),(0,i.useEffect)(()=>{E(nT(O(g),P))},[g,P]),(0,i.useEffect)(()=>{A(o.trim().length>=3&&d.length>0&&!_&&!C)},[o,d,_,C]);let Y=(0,i.useMemo)(()=>{let e=o.trim()!==t.name.trim(),r=[...d].sort(),n=t.permission.map(e=>e.id).sort(),i=r.length!==n.length||r.some((e,t)=>e!==n[t]),l=[...O(g)].sort(),a=[...t.ipAddress].sort(),s=l.length!==a.length||l.some((e,t)=>e!==a[t]);return e||i||s},[o,t.name,t.permission,t.ipAddress,d,g]),w=async()=>{if(!v)return;y(!0);let e=O(g);try{let i=await (0,ep.XW)({SubAccountId:r,Id:t.id,Name:o,PermissionIds:d,IpAddress:e,PIN:"",VerificationId:"",VerificationCode:""});(null==i?void 0:i.statusCode)===200&&i.data?n(i.data.verificationId||"",i.data.verificationIntId,{subAccountId:r,apiKeyId:t.id,apiKeyName:o,permissionIds:d,ipAddresses:e}):(0,e8.Ax)(null==i?void 0:i.statusDescription)}catch(e){console.error(e)}finally{y(!1)}};return(0,T.Y)(ey.A,{header:"Edit API Key Details",subheader:t.label,primaryButtonText:"CONTINUE TO UPDATE DETAILS",primaryButtonClick:w,disablePrimaryBtn:!v||b||!Y,isPrimaryCtaLoading:b,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(20),"",""],children:[(0,T.Y)(a.pd,{label:"API Key Name",placeholder:"Enter name",value:o,onChange:e=>{e.value.length<=30&&c(e.value)},invalid:!!_,errorText:_,appendItem:(0,T.Y)(eH,{isFocused:o.length>0,value:o,maxLength:30})}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)(ny,{}),(0,T.Y)(f.$G,{alignVertical:!0,gap:12,children:[{id:1,name:"Spot Trading (Place/cancel spot Orders)"},{id:2,name:"Futures Trading (Place limit/market orders)",disabled:l,message:nE},{id:3,name:"Fetch balances, positions, & orders"}].map(e=>(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(f.Is,{value:e.id,checked:d.includes(e.id),onChange:t=>{let{checked:r}=t;return((e,t)=>{h(r=>t?[...r,e]:r.filter(t=>t!==e))})(e.id,r)},disabled:e.disabled}),(0,T.Y)("span",{css:eE.wo,children:e.name})]}),e.disabled&&e.message&&(0,T.Y)("span",{css:nA,children:e.message})]},e.id))})]}),(0,T.Y)(a.pd,{label:"Whitelist IP Address (optional)",placeholder:"Multiple IP addresses, separated by commas",value:g,onChange:e=>m(e.value),invalid:!!C,errorText:C}),(0,T.Y)(f.L7,{title:"Informative Note",description:nw,type:f.$$.INFO,allowAction:!1,style:(0,u.AH)({padding:(0,p.qb)([12,24])},"","")})]})})},nR=function(e){return e.editDetails="editDetails",e.otpVerification="otpVerification",e.pinVerification="pinVerification",e}({}),nN=e=>{let{apiKeyData:t,subAccountId:r,onClose:n,handleOverlayClickCallback:l}=e,{0:o,1:a}=(0,i.useState)(nR.editDetails),{0:c,1:d}=(0,i.useState)(""),{0:u,1:p}=(0,i.useState)(0),{0:h,1:g}=(0,i.useState)(""),{0:m,1:v}=(0,i.useState)(null),A=(0,s.d4)(e=>e.shared.user.userStatus);null==A||A.email,(0,i.useEffect)(()=>{l&&l(o===nR.editDetails)},[o,l]);let b=(e,t,r)=>{d(e),p(t),v(r),a(nR.otpVerification)},y=e=>m?(0,ep.XW)({SubAccountId:m.subAccountId,Id:m.apiKeyId,Name:m.apiKeyName,PermissionIds:m.permissionIds,IpAddress:m.ipAddresses,PIN:e,VerificationId:c,VerificationCode:h}):void(0,e8.Ax)("Form data not available"),_=e=>{(0,eh.A)({title:"API Key Details Updated!",description:"Your API key details updated successfully.",type:"success"}),m&&(0,ep.tE)({id:m.apiKeyId,name:m.apiKeyName,apiKey:t.apiKey,ipAddress:m.ipAddresses,permission:m.permissionIds.map(e=>({id:e,name:"",detail:""})),label:t.label,email:t.email||"",verificationId:null}),n()};return(0,T.Y)(T.FK,{children:(()=>{switch(o){case nR.editDetails:return(0,T.Y)(nF,{apiKeyData:t,subAccountId:r,onSuccess:b,isMarginTradingEnabled:!1});case nR.otpVerification:return(0,T.Y)(eG.A,{title:"OTP Verification",description:["Enter the 6 digit OTP sent on","+".concat(null==A?void 0:A.countryISDCode," ").concat(null==A?void 0:A.mobileNumber),"& regd.","email ID"],verificationINTId:u,verificationId:c,onSuccess:e=>{d(e.verificationId),p(e.verificationIntId),a(nR.pinVerification)},onResendSuccess:e=>{d(e.verificationId),p(e.verificationIntId)},resendOtpType:eG.Z.UpdateApiKey});case nR.pinVerification:return(0,T.Y)(f.fV,{title:"PIN Verification",description:"Enter your 4-digit PIN to update API key",onVerifyPin:y,onSuccess:_,onForgotPin:t_.F_});default:return null}})()})},nB=(0,u.AH)([a.vE.flexJustifiedBetween,a.vE.flexAlignCenter],"",""),nx=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),nk=(0,u.AH)([a.p0.B4_14_semibold,a.vE.textAlignmentRight],"",""),nj=(0,u.AH)([a.p0.B4_14_semibold,(0,p.sM)(8),a.vE.textAlignmentRight],"",""),nW=e=>{let{apiKeyData:t,subAccountId:r,onClose:n,onCancel:l}=e,{0:o,1:s}=(0,i.useState)(!1),c=async()=>{s(!0);try{let e=await (0,ep.Lh)({SubAccountId:r,Id:t.id});(null==e?void 0:e.statusCode)===200?((0,eh.A)({title:"API Key Deleted!",description:"The ".concat(t.name," has been deleted successfully."),type:"success"}),(0,ep.tt)(t.id,r),n()):(0,eh.A)({title:"Failed to Delete API Key",description:(null==e?void 0:e.statusDescription)||"Something went wrong. Please try again.",type:"error"})}catch(e){console.error(e),(0,eh.A)({title:"Failed to Delete API Key",description:"Something went wrong. Please try again.",type:"error"})}finally{s(!1)}};return(0,T.Y)(ey.A,{header:"Delete API Key?",primaryButtonText:"YES, DELETE API",primaryButtonClick:c,disablePrimaryBtn:o,isPrimaryCtaLoading:o,secondaryButtonText:"CANCEL",secondaryButtonClick:l,disableSecondaryBtn:o,children:(0,T.FD)("div",{css:[(0,p.H2)(),a.Wp.g(20),"",""],children:[(0,T.Y)("p",{css:eE.kO,children:"Are you sure you want to delete this API key?"}),(0,T.FD)(f.$G,{alignVertical:!0,gap:20,children:[(0,T.Y)(na.r,{value:t.apiKey,size:140,style:(0,p.l$)(8)}),(0,T.FD)("div",{css:(0,p.wh)(12),children:[(0,T.FD)("div",{css:nB,children:[(0,T.Y)("span",{css:nx,children:"Sub-Account Name"}),(0,T.Y)("span",{css:nk,children:t.label})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:nB,children:[(0,T.Y)("span",{css:nx,children:"API Name"}),(0,T.Y)("span",{css:nk,children:t.name})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:nB,children:[(0,T.Y)("span",{css:nx,children:"API Key"}),(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)(f.hR,{textToCopy:t.apiKey}),(0,T.Y)("span",{css:nk,children:t.apiKey})]})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:nB,children:[(0,T.Y)("span",{css:nx,children:"IP Address"}),(0,T.Y)("span",{css:nk,children:0===t.ipAddress.length?"No IP Restriction":t.ipAddress.join("  |  ")})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:nB,children:[(0,T.Y)(ny,{}),(0,T.Y)("span",{css:nj,children:0===t.permission.length?"None":t.permission.map(e=>e.name||e.detail).join("  |  ")})]})]})]})]})})},nL=(0,u.AH)({background:a.Tj.Zeb_Gradient_Dark_Blue},"",""),nM=(0,u.AH)({background:"transparent",border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),cursor:"pointer"},"",""),nH=(0,u.AH)([a.p0.H6_16_bold],"",""),nU=(0,u.AH)({display:"flex",flex:"1 1 50%",gap:a.Wp.remConverter(12),flexWrap:"wrap"},"",""),nq=(0,u.AH)({minWidth:"calc(50% - ".concat(a.Wp.remConverter(6),")")},"","");var nZ=r(7206);let nV=[{id:1,title:"1. Generate API Key",description:"Enter the key name, permissions, and IP addresses",image:ed.A.i_api_illustration_1},{id:2,title:"2. OTP Verification",description:"Enter the 6-digit OTP sent to your registered contact",image:ed.A.i_api_illustration_2},{id:3,title:"3. Check & Confirm Info",description:"Verify & save the API key details & start trading",image:ed.A.i_api_illustration_3}],nK=["350+ Crypto Pairs","$30 Million monthly trading volume"],nG=[{id:1,title:"Spot Trading",description:"Trade with crypto",image:ed.A.i_crypto},{id:2,title:"Futures Trading",description:"Trade using leverage",image:ed.A.i_api_illustration_4},{id:3,title:"INR-Margin",description:"Trade in INR",image:ed.A.ic_rupee_with_star},{id:4,title:"USDT-Margin",description:"Trade in USDT",image:ed.A.i_illustration_tether}],nz=e=>{let{onClose:t}=e,r=(0,i.useRef)(null),{isOnTop:n,isOnBottom:l}=(0,nZ.y)(r.current,250);return(0,T.Y)(ey.A,{header:"API Key Information",primaryButtonText:"GOT IT",primaryButtonClick:t,showTopShadow:!n,showBottomShadow:!l,children:(0,T.FD)("div",{ref:r,css:[(0,p.H2)(),p.TH,a.Wp.g(12),"",""],children:[(0,T.Y)(f.$G,{containerPadding:[12,16],style:nL,children:(0,T.FD)("div",{css:[(0,p.sM)(12),a.vE.flexJustifiedBetween,"",""],children:[(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(rt(),{src:ed.A.i_illustration_12,alt:"API Documentation",width:60,height:60}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:[a.p0.H6_16_bold,"",""],children:"API Documentation"}),(0,T.Y)("span",{css:[a.p0.B5_12_regular,"",""],children:"Explore the API documentation for setup and functionality details. Seamless integration awaits."})]})]}),(0,T.Y)("div",{children:(0,T.Y)(a.L5,{icon:"arrow-right",size:40,iconSize:20,boxStyle:nM,onClick:()=>{window.open(nb.SY,"_blank")}})})]})}),(0,T.FD)(f.$G,{alignVertical:!0,gap:16,children:[(0,T.Y)("span",{css:nH,children:"How to create API key?"}),(0,T.Y)("div",{css:(0,p.wh)(16),children:nV.map(e=>(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(rt(),{src:e.image,alt:e.title,width:48,height:48}),(0,T.FD)("div",{css:(0,p.wh)(2),children:[(0,T.Y)("span",{css:[a.p0.B4_14_semibold,"",""],children:e.title}),(0,T.Y)("span",{css:eE.rg,children:e.description})]})]},e.id))})]}),(0,T.FD)(f.$G,{alignVertical:!0,gap:16,children:[(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:nH,children:"Free API Trading!"}),(0,T.Y)("span",{css:eE.wo,children:"API access is completely free. Create and manage Sub-Account API keys, control permissions, whitelist IPs, and automate securely."})]}),(0,T.FD)("div",{css:(0,p.wh)(12),children:[(0,T.Y)(a.cG,{spacing:0}),(0,T.Y)("div",{css:(0,p.wh)(12),children:nK.map((e,t)=>(0,T.Y)(f.kU,{text:e,textStyle:eE.wo,leadingImg:ed.A.ic_circle_tick_filled,leadingIconImgStyle:(0,p.hj)(14,14)},t))})]})]}),(0,T.FD)(f.$G,{alignVertical:!0,gap:16,children:[(0,T.Y)("span",{css:nH,children:"Trading Options via API"}),(0,T.Y)("div",{css:nU,children:nG.map(e=>(0,T.Y)(f.$G,{bgColor:a.Tj.Zeb_Solid_BG_Blue,style:nq,children:(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(rt(),{src:e.image,alt:e.title,width:40,height:40}),(0,T.FD)("div",{css:a.vE.flexColumn,children:[(0,T.Y)("span",{css:[a.p0.B4_14_semibold,"",""],children:e.title}),(0,T.Y)("span",{css:eE.rg,children:e.description})]})]})},e.id))})]})]})})};var nX=r(46867);let n$=i.forwardRef((e,t)=>
1{let{coachHighlightTarget:r,showCoachmarkWalkthrough:n=!1}=e,{0:l,1:o}=(0,i.useState)(nX.h),{0:d,1:h}=(0,i.useState)(""),{0:g,1:m}=(0,i.useState)(!0),{0:v,1:A}=(0,i.useState)(!0),{0:b,1:y}=(0,i.useState)(null),{0:_,1:S}=(0,i.useState)(!1),C=(0,i.useRef)(!0),{0:E,1:I}=(0,i.useState)(null),{0:D,1:P}=(0,i.useState)(!1),{0:O,1:Y}=(0,i.useState)({}),w=(0,s.d4)(e=>e.subAccountsNew.subAccountsList),F=(0,s.d4)(e=>e.subAccountsNew.allAccountsList),R=(0,s.d4)(e=>e.subAccountsNew.subAccountApiKeys),N=(0,i.useMemo)(()=>(null==R?void 0:R.apiKeys)||[],[R]),B=(0,en.A)(d,500),x=(0,i.useMemo)(()=>{var e;if(l===nX.h||"0"===l)return"";let t=null==F?void 0:F.find(e=>e.accountId.toString()===l);return null!=(e=null==t?void 0:t.name)?e:""},[l,F]),k=(0,i.useMemo)(()=>(0,tn.nq)(O).total>0,[O]),j=(0,i.useMemo)(()=>({permissions:{list:nr,title:"Permissions",icon:"reports"},ipAddress:{list:nn,title:"IP Address",icon:"location"}}),[]),L=[{dataField:W.Mq.NAME,component:(0,T.Y)("span",{css:a.Wp.pl(12),children:"Label Name"}),align:"left"},{dataField:W.Mq.TYPE,component:"API Key Name",align:"left"},{dataField:W.Mq.API_KEY_ID,component:"API Key",align:"left"},{dataField:W.Mq.IP_ADDRESS,component:"IP Address",align:"left"},{dataField:W.Mq.ASSET,component:"Spot",align:"center"},{dataField:W.Mq.QUANTITY,component:"Futures",align:"center"},{dataField:W.Mq.STATUS,component:"Fetch Details",align:"center"},{dataField:W.Mq.MENU,component:(0,T.Y)(a.In,{name:"filter",style:(0,p.Kk)(),onClick:()=>P(!0)}),align:"center"}];(0,i.useEffect)(()=>{null===R?(0,ep.dI)():m(!1)},[R]),(0,i.useImperativeHandle)(t,()=>({createApiKeys:()=>{y(nl.CREATE_API_KEYS)},showApiKeysSidepanel:()=>{y(nl.API_KEYS)}}));let M=()=>{y(null),I(null),C.current=!0,S(!1)},H=(0,i.useMemo)(()=>{if(l===nX.h||"0"===l)return N;let e=null==w?void 0:w.find(e=>e.accountId.toString()===l);return e?N.filter(t=>t.email.toLowerCase()===e.email.toLowerCase()):N},[l,N,w]),U=(0,i.useMemo)(()=>{let e=H;return k&&(O.permissions&&O.permissions.length>0&&(e=e.filter(e=>O.permissions.every(t=>e.permission.some(e=>e.id===Number(t))))),O.ipAddress&&O.ipAddress.length>0&&(e=e.filter(e=>{let t=e.ipAddress.length>0;return!!(O.ipAddress.includes(nt.RESTRICTED)&&t||O.ipAddress.includes(nt.NON_RESTRICTED)&&!t)}))),e},[H,k,O]),q=(0,i.useMemo)(()=>B.trim()?(0,td.Ht)(U,B.trim(),{keys:["label","name","email","apiKey","ipAddress",{threshold:td.Ht.rankings.CONTAINS,key:"ipAddress"}]}):U,[B,U]),Z=!g&&n&&0===q.length,V=(0,i.useMemo)(()=>Z?[c.o3]:q,[Z,q]),K=(0,i.useCallback)(e=>(0,T.Y)(rt(),{src:e?ed.A.ic_circle_tick_filled:ed.A.ic_circle_cross_filled,alt:"icon",height:16,width:16}),[]),G=(0,i.useCallback)(e=>{if(0===e.length)return(0,T.Y)(rX,{text:"No IP Restriction",subText:""});let t=e.length-1;return(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)(rX,{text:e[0],subText:""}),t>0?(0,T.Y)(a.m_,{content:(0,T.Y)("div",{css:[eE.rg,"",""],children:e.slice(1).join(", ")}),isStroke:!0,children:(0,T.Y)(f.$G,{containerPadding:[2,8],bgColor:a.Tj.Zeb_Solid_BG_Blue,borderRadius:4,children:(0,T.FD)("span",{css:eE.e7,children:["+",t]})})}):null]})},[]),z=(0,i.useCallback)(e=>{let t=null==w?void 0:w.find(t=>t.label.toLocaleLowerCase()===e.toLocaleLowerCase());return(null==t?void 0:t.accountId)||0},[w]),X=(0,i.useCallback)((e,t)=>{if(!(0,c.rH)(t.id))switch(I(t),e){case r7.EDIT:y(nl.UPDATE_API_KEYS);break;case r7.DELETE:y(nl.DELETE_API_KEYS)}},[]),$=(0,i.useCallback)(()=>{let e={};return e[W.Mq.NAME]=(0,T.Y)(rQ,{width:60,style:a.Wp.pl(10)}),e[W.Mq.TYPE]=(0,T.Y)(rJ,{width:80}),e[W.Mq.API_KEY_ID]=(0,T.Y)(rJ,{width:90}),e[W.Mq.IP_ADDRESS]=(0,T.Y)(rJ,{width:70}),e[W.Mq.ASSET]=(0,T.Y)(rJ,{width:25}),e[W.Mq.QUANTITY]=(0,T.Y)(rJ,{width:25}),e[W.Mq.STATUS]=(0,T.Y)(rJ,{width:25}),e[W.Mq.MENU]=(0,T.Y)(rJ,{width:50}),e},[]),Q=(0,i.useCallback)(()=>g?Array.from({length:10},()=>$()):V.map((e,t)=>{let i={};return i[W.Mq.NAME]=(0,T.Y)(rX,{text:e.label,subText:e.email,style:a.Wp.pl(10)}),i[W.Mq.TYPE]=(0,T.Y)(rX,{text:e.name,subText:""}),i[W.Mq.API_KEY_ID]=(0,T.Y)(nu,{apiKey:e.apiKey,isVisible:v,isFirstRow:0===t,coachHighlightTarget:r,showCoachmarkWalkthrough:n}),i[W.Mq.IP_ADDRESS]=G(e.ipAddress),i[W.Mq.ASSET]=K(ni(e,ne.SPOT)),i[W.Mq.QUANTITY]=K(ni(e,ne.FUTURES)),i[W.Mq.STATUS]=K(ni(e,ne.FETCH_DETAILS)),i[W.Mq.MENU]=(0,T.Y)(no,{handleMenuClick:t=>X(t,e)}),i}),[g,V,$,G,K,v,X,r,n]),J=()=>{Y({}),h("")},et=e=>{C.current=e};return(0,T.FD)("div",{css:[a.vE.flexColumn,"",""],children:[(0,T.FD)("div",{css:r9,children:[(0,T.Y)(nX.A,{value:l,onCh
1ange:e=>{o(e)},style:(0,p.Ck)(345),withAllAccounts:!0,withMasterAccount:!0,coachHighlightTarget:r,showCoachmarkWalkthrough:n}),(0,T.FD)("div",{css:(0,p.sM)(16),children:[(0,T.Y)(a.DO,{value:d,placeholder:"Search by Label, API Key Name, IP",onChange:e=>h(e.value),customDarkBgcolor:a.Tj.Zeb_Solid_Dark_Blue,style:(0,ee.Rt)(350),onClear:()=>{h("")}}),(0,T.Y)(ng.A,{activeIconIndex:+!!v,icons:[{src:ed.A.ic_hide,alt:"Hide API Keys"},{src:ed.A.ic_show,alt:"Show API Keys"}],onChange:e=>A(1===e)})]})]}),(0,T.Y)(f.Cu,{isOpen:D,onOpen:()=>P(!0),onClose:()=>P(!1),list:j,filterIds:O,type:el.R.Filter,onApply:e=>{Y(e)},onReset:J,withDateRange:!1},String(D)),(0,T.Y)(W.Ay,{headers:L,rows:Q(),noTopBorderRadius:!1,isPaginationEnabled:!1,minHeight:500,columnsSize:[16,13,22,18,8,8,10,5],padding:(0,u.AH)({padding:(0,p.qb)([12,2])},"",""),noSearchResults:g||Z?void 0:0===H.length?(0,T.Y)(tl,{title:"No API keys to display",description:"You haven't created any API keys ".concat(x?'for "'.concat(x,'" account'):""," yet.")}):0===q.length?(0,T.Y)(f.Z7,{title:"No Results Found",description:"No API keys available for the selected search/filter.",onReset:J}):void 0,tableSpace:k?280:225}),(0,T.FD)(a.wv,{open:null!==b,onClose:()=>{_||M()},onOverlayClick:()=>{C.current&&M()},hideClose:_,children:[b===nl.CREATE_API_KEYS&&(0,T.Y)(nY,{onClose:M,handleOverlayClickCallback:et,handleCloseRestrictedCallback:e=>{S(e)}}),b===nl.UPDATE_API_KEYS&&E&&(0,T.Y)(nN,{apiKeyData:E,subAccountId:z(E.label),onClose:M,handleOverlayClickCallback:et}),b===nl.DELETE_API_KEYS&&E&&(0,T.Y)(nW,{apiKeyData:E,subAccountId:z(E.label),onClose:M,onCancel:M}),b===nl.API_KEYS&&(0,T.Y)(nz,{onClose:M})]})]})});n$.displayName="ApiManagementTabScreen";let nQ=(0,u.AH)([a.vE.flexAlignCenter,a.Wp.g(12),{height:a.Wp.remConverter(36)}],"","");a.vE.flexAlignCenter,a.Wp.remConverter(4),a.p0.B4_14_regular,a.Wp.remConverter(12),a.Wp.remConverter(12),a.Tj.Zeb_Solid_Light_Blue,a.Wp.remConverter(12),a.p0.B5_12_regular,a.Tj.Zeb_Solid_Light_Blue,a.Tj.Zeb_Solid_Dark_Blue,a.Wp.remConverter(8);
1let nJ=(0,u.AH)({height:"100%",minHeight:a.Wp.remConverter(450),width:"100%",backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(8),display:"flex",justifyContent:"center",alignItems:"center"},"","");var n0=r(81615),n1=r(39201),n2=r(31438);function n4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function n8(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n4(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n4(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let n5=(0,u.AH)({borderRadius:a.Wp.remConverter(4),border:"1px solid ".concat(a.Tj.Zeb_Solid_Dark_Grey),height:"100%",backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,display:"flex",flexDirection:"column"},"",""),n6=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,{paddingBottom:0,paddingRight:a.Wp.remConverter(8)}],"",""),n3=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,{padding:"".concat(a.Wp.remConverter(14)," ").concat(a.Wp.remConverter(16)),paddingBottom:0}],"",""),n9=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(12),position:"relative"}],"",""),n7=(0,u.AH)({fontSize:a.Wp.remConverter(20),color:a.Tj.Zeb_Solid_Bright_Blue,cursor:"pointer"}
1,"",""),ie=(0,u.AH)({height:"100%",color:a.Tj.Zeb_Solid_White,flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},"",""),it=(0,u.AH)(n8({},a.p0.H5_20_bold),"",""),ir=(0,u.AH)(n8(n8({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginTop:a.Wp.remConverter(8)}),"",""),ii=(0,u.AH)({display:"flex",marginTop:a.Wp.remConverter(20),gap:a.Wp.remConverter(9),button:{width:a.Wp.remConverter(309)}},"","");function il(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function io(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?il(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):il(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}a.Wp.remConverter(80),"".concat(a.Wp.remConverter(20)," ").concat(a.Wp.remConverter(32)),n8(n8({},a.p0.B5_12_semibold),{},{color:a.Tj.Zeb_Solid_Light_Blue,display:"flex",gap:a.Wp.remConverter(12),alignItems:"center",i:{fontSize:a.Wp.remConverter(20)}}),a.Tj.Zeb_Solid_White,n8(n8({},a.p0.B4_14_regular),{},{padding:"".concat(a.Wp.remConverter(12)," 0"),display:"flex",gap:a.Wp.remConverter(20)}),a.Wp.remConverter(12),a.Tj.Zeb_Solid_Light_Blue,n8(n8({},a.p0.C4_12),{},{color:a.Tj.Zeb_Solid_Bright_Blue,cursor:"pointer",marginTop:a.Wp.remConverter(14)}),n8(n8({},a.p0.B5_12_semibold),{},{position:"relative",marginTop:a.Wp.remConverter(14),cursor:"pointer"}),a.Wp.remConverter(4),a.Wp.remConverter(20),a.Tj.Zeb_Solid_Bright_Blue,a.Wp.remConverter(8),a.Wp.remConverter(40),a.Wp.remConverter(8),a.Wp.remConverter(16),a.Tj.Zeb_Solid_BG_Blue,a.Wp.remConverter(4),a.Tj.Zeb_Solid_Bright_Blue,a.Tj.Zeb_Effects_Shadow_Hover;let ia=function(e){return e.Positions="positions",e.OpenOrders="openorder",e.OrderHistory="orderHistory",e.TradeHistory="tradeHistory",e.TransactionHistory="transactionHistory",e}({}),is=function(e){return e.LOADING="loading",e.SET_STATEMENT_TAB="setStatementTab",e.SET_SEND_STATEMENT_DISABLED="setDownloadDisabled",e.SHOW_ALL_CANCEL_PAGE="showAllCancelPage",e.SET_CANCEL_ALL_DISABLED="cancleAllDIsabled",e.UPDATE_ON_ALL_CANCEL="updateOnAllCancel",e}({}),ic={isActionLoading:!0,showCancleAllPage:!1,statementTab:"",isSendStatementDisabled:!0,isCancleAllDisabled:!0,updateOnAllCancel:!1},id=(e,t)=>{switch(t.type){case is.LOADING:return io(io({},e),{},{isActionLoading:t.value});case is.SHOW_ALL_CANCEL_PAGE:return io(io({},e),{},{showCancleAllPage:t.value});case is.SET_STATEMENT_TAB:return io(io({},e),{},{statementTab:t.tab||ic.statementTab});case is.SET_SEND_STATEMENT_DISABLED:return io(io({},e),{},{isSendStatementDisabled:t.value});case is.SET_CANCEL_ALL_DISABLED:return io(io({},e),{},{isCancleAllDisabled:t.value});case is.UPDATE_ON_ALL_CANCEL:return io(io({},e),{},{updateOnAllCancel:t.value});default:return e}},iu=function(e){return e.orderDetail="order-detail",e.tradeHistroy="trade-history",e}({});iu.orderDetail,iu.tradeHistroy,new Date().getTime(),new Date(new Date().setFullYear(new Date().getFullYear()-1)).getTime(),new Date(2014,0,1).getTime();let ip=function(e){return e.FILLED="FILLED",e.PARTIAL="PARTIAL",e.PARTIALLY_FILLED="PARTIALLY_FILLED",e.EXPIRED="EXPIRED",e.CANCELLED="CANCELLED",e.CANCELED="CANCELED",e}({}),ih=[{title:"25%",tab:"0.25"},{title:"50%",tab:"0.50"},{title:"75%",tab:"0.75"},{title:"100%",tab:"1"}];function ig(e,t){let r=Math.pow(10,t);return Math.ceil(e*r)/r}let im="USDT",iv="INR-M",iA="USDT-M";function ib(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function iy(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ib(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ib(Object(r)).forEac
1h(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let i_=(0,u.AH)([iy({padding:0,height:"100%",display:"flex",flexDirection:"column",overflowX:"auto",overflowY:"scroll"},p.Fp)],"",""),iS=(0,u.AH)([a.vE.flexColumn,iy(iy({},a.p0.B4_14_regular),{},{backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:"8px",overflowX:"auto",margin:0,height:"100%",position:"relative"},(0,p.r)(!1))],"",""),iT=(0,u.AH)(iy(iy({padding:"".concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(2)),textTransform:"capitalize",border:"none"},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,verticalAlign:"middle",whiteSpace:"nowrap",position:"sticky",top:0,backgroundColor:a.Tj.Zeb_Solid_Dark_Blue}),"","");a.Wp.remConverter(8);let iC=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,{borderBottom:"1.5px solid ".concat(a.Tj.Zeb_Solid_BG_Blue)}],"",""),iE=(0,u.AH)({padding:"".concat(a.Wp.remConverter(8)," ").concat(a.Wp.remConverter(2)),border:"none",verticalAlign:"middle",whiteSpace:"nowrap"},"",""),iI=e=>(0,u.AH)({position:"sticky",right:0,backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,width:"".concat(e,"px"),paddingLeft:a.Wp.remConverter(16),boxShadow:a.Tj.Zeb_Table_Shadow,zIndex:1},"",""),iD=e=>{let{0:t,1:r}=(0,i.useState)(!0),{0:n,1:l}=(0,i.useState)(!1),{0:o,1:a}=(0,i.useState)(0),s=()=>{let t=e.current;if(t){let e=0===t.scrollTop,n=t.scrollTop+t.clientHeight===t.scrollHeight;r(e),l(n),a(t.scrollTop)}};return(0,i.useEffect)(()=>{let t=e.current;if(t)return l((null==t?void 0:t.clientHeight)<=t.scrollHeight),t.addEventListener("scroll",s),()=>{t.removeEventListener("scroll",s)}},[e]),{isAtTop:t,isAtBottom:n,scrollTop:o}};var iP=r(63640);function iO(e){(0,i.useEffect)(()=>{let t=t=>{e([t.ctrlKey?iP.D$.CTRL:"",t.metaKey?iP.D$.META:"",t.altKey?iP.D$.ALT:"",t.shiftKey?iP.D$.SHIFT:"",t.code].filter(Boolean))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e])}let iY=e=>"center"===e?a.vE.flexJustifiedCenter:"right"===e?a.vE.flexJustifiedEnd:a.vE.flexJustifiedStart,iw=e=>{var t,r;let{headers:n,rows:l,fetchMore:o,sort:s,cssWrapper:c,noResultScreen:d,style:h,styleData:g,isLoading:m,isStickyTable:v}=e,A=i.useRef(null),b=i.useRef(null),y=i.useRef(null),f=i.useRef(null),_=i.useRef(null),{isAtTop:S}=iD(f),C=null==(t=f.current)?void 0:t.scrollTop,E=null==(r=f.current)?void 0:r.scrollHeight,I=(0,i.useMemo)(()=>{let e=0;return n.map(t=>{if(null!=t&&t.isSticky){var r;e+=null!=(r=null==t?void 0:t.width)?r:0}}),e},[n]),D=(null!=C?C:0)>(null!=E?E:0)-495;return iO(e=>{var t,r,n,i,l,o,a,s;switch(e.join()){case[iP.D$.SHIFT,iP.D$.UP].join():v?null==(t=_.current)||t.scrollTo({top:(null==(r=_.current)?void 0:r.scrollTop)-50,behavior:"smooth"}):null==(n=f.current)||n.scrollTo({top:(null==(i=f.current)?void 0:i.scrollTop)-50,behavior:"smooth"});break;case[iP.D$.SHIFT,iP.D$.DOWN].join():v?null==(l=_.current)||l.scrollTo({top:(null==(o=_.current)?void 0:o.scrollTop)+50,behavior:"smooth"}):null==(a=f.current)||a.scrollTo({top:(null==(s=f.current)?void 0:s.scrollTop)+50,behavior:"smooth"})}}),i.useEffect(()=>{D&&o&&o()},[D]),i.useEffect(()=>{y.current=new IntersectionObserver(e=>{e[0].isIntersecting&&o&&o()},{root:A.current,threshold:1,rootMargin:"0px"}),b.current&&y.current.observe(b.current)},[b.current]),(0,T.FD)("div",{css:[i_,c,"",""],ref:A,children:[(0,T.FD)("table",{ref:_,css:[iS,a.Wp.widthPercentage(100),"",""],children:[(0,T.Y)("thead",{css:[(0,u.AH)({boxShadow:S?"none":a.Tj.Zeb_Effects_Shadow_Hover,position:"sticky",top:0,width:"fit-content",minWidth:"100%",borderBottom:"1.5px solid ".concat(a.Tj.Zeb_Solid_BG_Blue),backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,zIndex:2},"",""),h,"",""],children:(0,T.FD)("tr",{css:a.vE.flexJustifiedBetween,children:[n.map((e,t)=>{var r;if(e&&e.component&&!(null!=(r=null==e?void 0:e.isSticky)&&r))return(0,T.Y)("th",{css:[iT,e.width&&{width:"".concat(e.width,"px")},"",""],children:(0,T.Y)("div",{css:[a.vE.flexAlignCenter,e.align&&iY(e.align),"",""],children:e.component})},t)}),l.length&&v?(0,T.Y)("th",{css:[iT,iI(I),"",""],children:n.map((e,t)=>{if(e&&e.component&&e.isSticky)return(0,T.Y)("th",{css:[e.width&&{width:"".concat(e.width,"px"),fontWeight:"normal"},"",""],children:(0,T.Y)("div",{css:[a.vE.flexAlignCenter,e.align&&iY(e.align),"",""],children:e.component})},t)})}):null]})}),(0,T.Y)("tbody",{css:[(0,u.AH)(iy(iy({borderTop:"none",height:"calc(100% - ".concat(a.Wp.remConverter(44),")"),width:"fit-content",overflowY:v?"unset":"scroll",minWidth:"100%"},(0,p.r)(!1)),{},{scrollbarGutter:"auto"}),"",""),h,"",""],ref:f,children:l.length>0?l.map((e,t)=>(0,T.FD)("tr",{css:iC,children:[Object.keys(e).filter(e=>{let t=n.find(t=>t.dataField==e);return!(null!=t&&t.isSticky)}).map((r,i)=>{var l,o;return e[null==(l=n[i])?void 0:l.dataField]&&!(null!=n&&null!=(o=n[i])&&o.isSticky)&&(0,T.Y)("td",{css:[iE,n[i].width&&{width:"".concat(n[i].width,"px")}
1,g,"",""],children:(0,T.Y)("div",{css:iY(n[i].align||"left"),children:e[n[i].dataField]})},r+t)}),l.length&&v?(0,T.Y)("td",{css:[iE,iI(I),"",""],children:Object.keys(e).map((r,i)=>{var l,o,a;return e[null==(l=n[i])?void 0:l.dataField]&&null!=(o=null==n||null==(a=n[i])?void 0:a.isSticky)&&o&&(0,T.Y)("td",{css:[n[i].width&&{width:"".concat(n[i].width,"px")},g,"",""],children:(0,T.Y)("div",{css:iY(n[i].align||"left"),children:e[n[i].dataField]})},r+t)})}):null]},e.__positionId||t)):d})]}),!!l.length&&(0,T.Y)("div",{style:{height:"1px"},ref:b}),m&&(0,T.Y)(a.Fd,{size:20})]})},iF=e=>{let{heading:t,description:r,buttonProps:n}=e;return(0,T.FD)("article",{css:[a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,a.vE.flexColumn,a.Wp.heightPercentage(100),"",""],children:[(0,T.Y)("h2",{css:[a.p0.H6_16_bold,"",""],children:t}),(0,T.Y)("p",{css:[a.p0.B5_12_regular,"",""],children:r}),n&&(0,T.Y)(a.$n,{type:"primary",size:"medium",onClick:n.onClick,style:a.Wp.mt(8),children:n.label})]})},iR=e=>{let{title:t,subtitle:r,style:n}=e;return(0,T.FD)("div",{css:[a.vE.flexAlignCenter,n,"",""],children:[(0,T.Y)("span",{css:[a.p0.B5_12_semibold,"",""],children:t}),(0,T.Y)("span",{css:[a.p0.B5_12_regular,a.Wp.ml(4),{color:a.Tj.Zeb_Solid_Light_Blue},"",""],children:r})]})},iN=(0,u.AH)([a.Wp.widthPercentage(100),a.vE.flexJustifiedBetween,a.Wp.p(16),a.Wp.br(8),{border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),background:a.Tj.Zeb_Solid_Dark_Blue}],"",""),iB=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,{whiteSpace:"nowrap",minWidth:a.Wp.remConverter(157),border:"1px solid ".concat(a.Tj.Zeb_Solid_Red),background:a.Tj.Zeb_Transparent_Red}],"","");var ix=r(40980);let ik=e=>{let{orderCount:t,title:r,description:n,buttonText:i="Cancel All",onClick:l,cancelInprogress:o,onClose:s,style:c}=e;return(0,T.FD)("div",{css:[iN,c,"",""],children:[(0,T.FD)("div",{css:(0,p.sM)(12),children:[(0,T.Y)(ix.A,{bgColor:a.Tj.Zeb_Solid_Dark_Grey,containerPadding:[5,14],children:(0,T.Y)("span",{css:[a.p0.B2_20_semibold,"",""],children:t})}),(0,T.FD)("div",{css:(0,p.wh)(0),children:[(0,T.Y)("div",{css:[a.p0.B3_16_semibold,"",""],children:r}),(0,T.Y)("div",{css:[a.p0.B4_14_regular,a.vE.textFaded,"",""],children:n})]})]}),(0,T.FD)("div",{css:(0,p.sM)(16),children:[(0,T.Y)(a.$n,{type:"secondary",onClick:l,size:"small",loading:o,style:iB,children:i}),(0,T.Y)("div",{onClick:s,css:a.vE.cursorPointer,children:(0,T.Y)(a.In,{name:"cross",style:(0,p.Kk)(24)})})]})]})},ij=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250,{0:r,1:n}=(0,i.useState)(e);return(0,i.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>clearTimeout(r)},[e,t]),r},iW=e=>{let{children:t,bgColor:r=a.Tj.Zeb_Solid_Dark_Blue,borderRadius:n=[8],containerPadding:i=[12],alignVertical:l=!1,justify:o=!1,gap:s=0,onClick:c,style:d}=e,p=(0,u.AH)([l&&a.vE.flexColumn,o&&a.vE.flexJustifiedBetween,c&&a.vE.cursorPointer,{backgroundColor:r,borderRadius:iL(n),padding:iL(i),gap:a.Wp.remConverter(s)}],"","");return(0,T.Y)("div",{css:[p,d,"",""],onClick:c,children:t})},iL=e=>e.map(a.Wp.remConverter).join(" ");function iM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function iH(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?iM(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):iM(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let iU=(0,u.AH)({position:"absolute",top:"100%",right:0,width:a.Wp.remConverter(120),zIndex:1},"",""),iq={name:"1pptr1d",styles:"position:fixed;inset:0;z-index:1"},iZ=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),position:"relative",zIndex:2},"",""),iV=(0,u.AH)([a.vE.flexJustifiedBetween,a.vE.flexAlignCenter,a.Wp.p(8)],"",""),iK=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,a.p0.B4_14_regular,a.vE.textFaded,{height:a.Wp.remConverter(150)}],"",""),iG=e=>{let{selected:t,options:r,onClose:n,onChange:l,allowSearch:o=!1,highlightSeleceted:s,style:c,iconStyle:d=(0,p.Kk)(16,a.Tj.Zeb_Solid_Light_Blue)}=e,{0:h,1:g}=(0,i.useState)(""),m=ij(h)?(0,td.Ht)(r,h,{keys:["title"]}):r;return(0,T.FD)("div",{css:[iU,c,"",""],children:[(0,T.Y)("div",{css:iq,onClick:e=>{n&&n(),e.stopPropagation()}}),(0,T.FD)(iW,{containerPadding:[0],alignVertical:!0,bgColor:a.Tj.Zeb_Solid_BG_Blue,style:iZ,children:[o?(0,T.Y)("div",{css:(0,u.AH)({padding:(0,p.qb)([12,12,8])},"",""),children:(0,T.Y)(a.DO,{value:h,onChange:e=>g(e.value)})}):null,(0,T.Y)("div",{css:(0,u.AH)([(0,p.wh)(10),{padding:o?iL([4,12,12]):a.Wp.remConverter(8)}],"",""),children:!h||m.length?m.map(e=>{let r;return(0,T.Y)(iW,{containerPadding:[0],borderRadius:[8],bgColor:s&&e.value===t?a.Tj.Zeb_Solid_Dark_Blue:a.Tj.Zeb_Solid_BG_Blue,style:(r=e.value===t,(0,u.AH)(iH(iH({},a.p0.B4_14_semibold),{},{color:r?a.Tj.Zeb_Solid_White:a.Tj.Zeb_Solid_Light_Blue,cursor:"pointer"}),"","")),children:(0,T.FD)("div",{css:iV,onClick:t=>{var r;l(null!=(r=e.value)?r:e.title),t.stopPropagation()},children:[(0,T.FD)("div",{css:(0,p.sM)(8),children:[e.icon&&(0,T.Y)(a.In,{name:e.icon,style:d}),(0,T.Y)("div",{css:["",""],children:e.title})]}),e.value===t&&(0,T.Y)(a.In,{name:"tick",style:(0,p.Kk)()})]})},e.value)}):(0,T.Y)("div",{css:iK,children:"No result found"})})]})]})},iz=e=>
1{let{image:t,title:r,description:n,imageGap:i=20,imageHeight:l=140,imageWidth:o=140,titleGap:s=4,imageStyle:c,titleStyle:d,descriptionStyle:u,containerStyle:h}=e;return(0,T.Y)("div",{css:[a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,h,"",""],children:(0,T.FD)("div",{css:(0,p.wh)(i),children:[(0,T.Y)("div",{css:a.vE.textAlignmentCenter,children:(0,T.Y)("img",{src:t,height:l,width:o,alt:"image",css:c})}),(0,T.FD)("div",{css:[(0,p.wh)(s),a.vE.textAlignmentCenter,"",""],children:[(0,T.Y)("div",{css:[a.p0.H3_32_bold,d,"",""],children:r}),n&&(0,T.Y)("div",{css:[a.p0.B2_20_regular,a.vE.textFaded,u,"",""],children:n})]})]})})},iX=(0,u.AH)([a.Wp.heightPercentage(100),a.Wp.widthPercentage(100),a.vE.flexColumn,a.vE.flexJustifiedBetween],"",""),i$=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,a.Wp.g(16),{padding:iL([20,32])}],"",""),iQ=(0,u.AH)({boxShadow:a.Tj.Zeb_Effects_Shadow_Hover},"",""),iJ=(0,u.AH)({boxShadow:a.Tj.Zeb_Effects_Shadow_M_Drawer},"",""),i0=(0,u.AH)([a.p0.H4_28_bold,{flex:1,textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}],"",""),i1=(0,u.AH)([a.vE.flexColumn,{flex:1,minHeight:0}],"",""),i2=(0,u.AH)([a.vE.flexJustifiedCenter,a.vE.flexAlignCenter,a.Wp.plr(32)],"",""),i4=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16;return(0,u.AH)([a.Wp.widthPercentage(100),(0,p.wh)(t),{padding:iL(e)}],"","")},i8=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,r=arguments.length>2?arguments[2]:void 0;return e?(0,u.AH)([(0,p.wh)(t),r&&{flexDirection:"column-reverse"}],"",""):(0,u.AH)([(0,p.sM)(t),r&&{flexDirection:"row-reverse"}],"","")},i5=e=>{let{header:t,showTopShadow:r,children:n,alignInMiddle:l,leadingIcon:o,leadingIconClick:s,trainlingIcon:c,trainlingIconClick:d,footerContent:p,showBottomShadow:h,footerContentGap:g=16,primaryButtonText:m,primaryButtonClick:v=ek.A,secondaryButtonText:A,secondaryButtonClick:b=ek.A,footerPadding:y="large",alignCtaVertical:f,reverseCta:_,buttonGap:S=16,disablePrimaryBtn:C,disableSecondaryBtn:E,isPrimaryCtaLoading:I,isSecondaryLoading:D}=e,P=(0,i.useMemo)(()=>{switch(y){case"xs":return[8,32,16];case"small":return[12,32,16];case"medium":return[16,32];case"large":default:return[12,32,20];case"xLarge":return[20,32];case"regular":return[16,32,20]}},[y]);return(0,T.FD)("div",{css:iX,children:[(e=>"string"==typeof e?e.trim().length>0:!!i.isValidElement(e)||null!=e&&""!==e)(t)&&(0,T.FD)("header",{css:[i$,r&&iQ,"",""],children:[o&&(0,T.Y)(a.L5,{size:36,icon:o,bgColor:a.Tj.Zeb_Solid_Dark_Blue,onClick:s,boxStyle:a.vE.cursorPointer}),(0,T.Y)("div",{css:[i0,!c&&a.Wp.mr(52),"",""],children:t}),c&&(0,T.Y)(a.L5,{size:36,icon:c,boxStyle:(0,u.AH)([a.Wp.mr(52),a.vE.cursorPointer],"",""),bgColor:a.Tj.Zeb_Solid_Dark_Blue,onClick:d})]}),(0,T.Y)("div",{css:[i1,l&&i2,"",""],children:n}),(m||A)&&(0,T.FD)("footer",{css:[i4(P,g),h&&iJ,"",""],children:[p&&(0,T.Y)("div",{css:a.vE.flexAlignCenter,children:p}),(0,T.FD)("div",{css:i8(f,S,_),children:[A&&(0,T.Y)(a.$n,{disabled:E,loading:D,type:"secondary",onClick:b,size:"full-width",children:A}),m&&(0,T.Y)(a.$n,{disabled:C,loading:I,type:"primary",onClick:v,size:"full-width",children:m})]})]})]})},i6=e=>{let{header:t,leadingIcon:r,leadingIconClick:n,image:i,imageHeight:l,imageWidth:o,imageStyle:a,imageGap:s,title:c,titleStyle:d,titleGap:u,description:p,descriptionStyle:h,primaryButtonText:g,primaryButtonClick:m,secondaryButtonText:v,secondaryButtonClick:A}=e;return(0,T.Y)(i5,{header:t,leadingIcon:r,leadingIconClick:n,primaryButtonText:g,secondaryButtonText:v,primaryButtonClick:m,secondaryButtonClick:A,alignInMiddle:!0,children:(0,T.Y)(iz,{image:i,imageHeight:l,imageWidth:o,imageStyle:a,imageGap:s,title:c,titleStyle:d,titleGap:u,description:p,descriptionStyle:h})})};function i3(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i9(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i3(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i3(Object(r)).forEac
1h(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let i7=a.Wp.remConverter(6);a.Wp.remConverter(35);let le={background:a.Tj.Zeb_Solid_Bright_Blue,borderRadius:i7,color:a.Tj.Zeb_Solid_White};function lt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function lr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ln(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function li(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ln(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ln(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}"linear-gradient(180deg, ".concat(a.Tj.Zeb_BG_Blue," 50%, ").concat(a.Tj.Zeb_BG_Blue," 50%)"),i9({},le),i9({},le),a.vE.flexJustifiedBetween,a.Wp.remConverter(10),a.vE.flexJustifiedBetween,a.vE.flexAlignCenter,a.Wp.remConverter(9),a.vE.flexAlignCenter,a.Wp.widthPercentage(100),a.Wp.remConverter(34),i9(i9({},a.p0.H5_20_bold),{},{color:a.Tj.Zeb_Solid_Light_Blue}),a.Wp.remConverter(2),a.Tj.Zeb_Solid_BG_Blue,a.Tj.Zeb_Solid_BG_Blue,i9({},a.p0.B3_16_semibold),a.vE.flexAlignCenter,a.Wp.remConverter(2),a.Wp.remConverter(32),a.Tj.Zeb_Solid_White,a.Tj.Zeb_Solid_BG_Blue,a.Wp.remConverter(6),i9(i9({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Red}),lr(lr({},a.p0.H5_20_bold),{},{color:a.Tj.Zeb_Solid_Light_Blue}),a.Tj.Zeb_Solid_White;let ll="0.5rem";a.Wp.remConverter(12),a.Wp.remConverter(18),a.Wp.remConverter(50),a.Tj.Zeb_Solid_Dark_Blue,li(li({marginBottom:a.Wp.remConverter(4)},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),li({},a.p0.B4_14_semibold),"0 ".concat(ll," ").concat(ll," 0"),a.Tj.Zeb_Solid_Bright_Blue,a.Tj.Zeb_Solid_Bright_Blue,a.Tj.Zeb_Solid_Red,li({},a.p0.B3_16_semibold),a.Wp.remConverter(16),a.Tj.Zeb_Solid_White,li(li({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Red}),a.Wp.remConverter(14),a.Wp.remConverter(-4),a.Wp.remConverter(8),a.Wp.remConverter(8),a.Tj.Zeb_Effects_Shadow_Hover,a.vE.flexColumn,"".concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(4)," ").concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(8)),a.Wp.remConverter(364),a.Wp.remConverter(10),li(li({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginTop:"0.25rem"}),r(52729),r(304);let lo=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,a.Wp.widthPercentage(100),a.Wp.heightPercentage(100)],"",""),la=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(4)}],"",""),ls=e=>{let{tabType:t,isFilterApplied:r,onClick:n}=e,l={[ia.Positions]:{title:"No positions to display",description:"Placed position orders will be found in the list."},[ia.OpenOrders]:{title:"No open orders to display",description:"Your open orders will be found in the list."},[ia.OrderHistory]:{title:"No orders to display",description:"Placed orders will be found in the list."},[ia.TradeHistory]:{title:"No trades to display",description:"Placed orders will be found in the list."},[ia.TransactionHistory]:{title:"No transactions to display",description:"Placed orders will be found in the list."}},o=(0,T.FD)("div",{css:la,children:["To view position orders please try resetting your"," ",(0,T.Y)(a.$n,{type:"link",onClick:n||ek.A,children:"Filter"})]}),s={[ia.Positions]:{title:"No Results found for Positions",description:o},[ia.OpenOrders]:{title:"No Results found for Open Orders",description:o},[ia.OrderHistory]:{title:"No Results found for Order History",description:o},[ia.TradeHistory]:{title:"No Results found for Trade History",description:o},[ia.TransactionHistory]:{title:"No Results found for Position History",description:o}},c=(0,i.useMemo)(()=>r?s[t]:l[t],[t,r]);return(0,T.Y)("div",{css:lo,children:(0,T.Y)(iz,{image:ed.A.i_illustration_06,imageHeight:140,imageWidth:140,title:c.title,de
1scription:c.description||""})})};var lc=r(61673),ld=r(20792),lu=r(79108),lp=r(852),lh=r(91040),lg=r(77474);function lm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}let{dispatch:lv}=lp.xM;async function lA(e,t){try{lv({type:ld.X2.STATUS_UPDATE,payload:{positions:ld.VI.REQUEST}});let e=await (0,lh.A)({url:"".concat(lu.d6,"/trade/positions?status=OPEN"),method:"GET",headers:(0,lg.R)(t)});lv({type:lc.X.SET_POSITIONS,payload:e.data.data}),lv({type:ld.X2.STATUS_UPDATE,payload:{positions:ld.VI.SUCCESS}})}catch(e){var r;(null==e||null==(r=e.response)?void 0:r.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{positions:ld.VI.FAIL}}),reportError(e)}}async function lb(e,t,r,n){var i,l;try{lv({type:ld.X2.STATUS_UPDATE,payload:{openOrders:ld.VI.REQUEST}});let e=await (0,lh.A)({url:"".concat(lu.d6,"/trade/order/open-orders?page=").concat(t,"&timestamp=").concat(r,"&pageSize=").concat(20),method:"GET",headers:(0,lg.R)(n)});1===t?lv({type:lc.X.SET_OPEN_ORDERS,payload:e.data.data.data}):lv({type:lc.X.ADD_OPEN_ORDERS,payload:{page:t,orders:e.data.data.data}}),lv({type:lc.X.SET_TABLE_PAGE,payload:{currentPage:t,timeStamp:e.data.data.nextTimestamp,lastPage:(null==(i=e.data.data)||null==(i=i.data)?void 0:i.length)<20}}),lv({type:ld.X2.STATUS_UPDATE,payload:{openOrders:ld.VI.SUCCESS}})}catch(e){(null==e||null==(l=e.response)?void 0:l.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{openOrders:ld.VI.FAIL}}),reportError(e)}}async function ly(e,t,r){try{lv({type:ld.X2.STATUS_UPDATE,payload:{linkedOrder:ld.VI.REQUEST}});let t=await (0,lh.A)({url:"".concat(lu.d6,"/trade/linkedOrders/").concat(e),method:"GET",headers:(0,lg.R)(r)});return lv({type:ld.X2.STATUS_UPDATE,payload:{linkedOrder:ld.VI.SUCCESS}}),t.data.data}catch(e){var n;(null==e||null==(n=e.response)?void 0:n.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{linkedOrder:ld.VI.FAIL}}),reportError(e)}}async function lf(e,t,r){try{return(await (0,lh.A)({url:"".concat(lu.d6,"/trade/order"),method:"DELETE",data:e,headers:(0,lg.R)(r)})).data.data}catch(e){var n;(null==e||null==(n=e.response)?void 0:n.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),reportError(e)}}async function l_(e,t,r,n){var i,l;try{lv({type:ld.X2.STATUS_UPDATE,payload:{orderHistory:ld.VI.REQUEST}});let e=await (0,lh.A)({url:"".concat(lu.d6,"/trade/order/history?page=").concat(t,"&timestamp=").concat(r,"&pageSize=").concat(20),method:"GET",headers:(0,lg.R)(n)});1===t?lv({type:lc.X.SET_ORDER_HISTORY,payload:e.data.data.data}):lv({type:lc.X.ADD_ORDER_HISTORY,payload:{page:t,orders:e.data.data.data}}),lv({type:lc.X.SET_TABLE_PAGE,payload:{currentPage:t,timeStamp:e.data.data.nextTimestamp,lastPage:(null==(i=e.data.data.data)?void 0:i.length)<20}}),lv({type:ld.X2.STATUS_UPDATE,payload:{orderHistory:ld.VI.SUCCESS}})}catch(e){(null==e||null==(l=e.response)?void 0:l.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{orderHistory:ld.VI.FAIL}}),reportError(e)}}async function lS(e,t,r,n){var i,l;try{lv({type:ld.X2.STATUS_UPDATE,payload:{tradeHistory:ld.VI.REQUEST}});let e=await (0,lh.A)({url:"".concat(lu.d6,"/trade/history?page=").concat(t,"&timestamp=").concat(r,"&pageSize=").concat(20),method:"GET",headers:(0,lg.R)(n)});1===t?lv({type:lc.X.SET_TRADE_HISTORY,payload:e.data.data.data}):lv({type:lc.X.ADD_TRADE_HISTORY,payload:{page:t,orders:e.data.data.data}}),lv({type:lc.X.SET_TABLE_PAGE,payload:{currentPage:t,timeStamp:e.data.data.nextTimestamp,lastPage:(null==(i=e.data.data.data)?void 0:i.length)<20}}),lv({type:ld.X2.STATUS_UPDATE,payload:{tradeHistory:ld.VI.SUCCESS}})}catch(e){(null==e||null==(l=e.response)?void 0:l.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{tradeHistory:ld.VI.FAIL}}),reportError(e)}}async function lT(e,t,r,n){var i,l;
1try{lv({type:ld.X2.STATUS_UPDATE,payload:{trasactionHistory:ld.VI.REQUEST}});let e=await (0,lh.A)({url:"".concat(lu.d6,"/trade/transaction/history?page=").concat(t,"&timestamp=").concat(r,"&pageSize=").concat(20),method:"GET",headers:(0,lg.R)(n)});1===t?lv({type:lc.X.SET_TRANSACTION_HISTORY,payload:e.data.data.data}):lv({type:lc.X.ADD_TRANSACTION_HISTORY,payload:{page:t,orders:e.data.data.data}}),lv({type:lc.X.SET_TABLE_PAGE,payload:{currentPage:t,timeStamp:e.data.data.nextTimestamp,lastPage:(null==(i=e.data.data.data)?void 0:i.length)<20}}),lv({type:ld.X2.STATUS_UPDATE,payload:{trasactionHistory:ld.VI.SUCCESS}})}catch(e){(null==e||null==(l=e.response)?void 0:l.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{trasactionHistory:ld.VI.FAIL}}),reportError(e)}}async function lC(e,t,r,n){return(await (0,lh.A)({url:lu.q7,method:"PATCH",headers:(0,lg.R)(n),data:{positionId:t,autoTopUp:e}})).data}let lE=async(e,t)=>{try{return(await (0,lh.A)({url:lu.Vq,headers:(0,lg.R)(t)})).data.data}catch(e){throw e}},lI=async(e,t,r,n)=>{try{return(await (0,lh.A)({url:"".concat(lu.u2,"/").concat(t,"?").concat(r),method:"GET",headers:(0,lg.R)(n)})).data}catch(e){return e.response.data}},lD=async(e,t,r)=>{try{return(await (0,lh.A)({url:"".concat(lu.d6,"/trade/order/split-tp-sl"),method:"POST",data:e,headers:(0,lg.R)(r)})).data.data}catch(e){var n;(null==e||null==(n=e.response)?void 0:n.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{addSplitTPSLOrder:ld.VI.FAIL}}),lF(e)}},lP=async(e,t,r,n,i)=>{try{return(await (0,lh.A)({url:"".concat(lu.d6,"/trade/").concat(n),method:"POST",data:{positionId:e,amount:t},headers:(0,lg.R)(i)})).data.data}catch(e){lF(e)}},lO=async(e,t,r,n)=>{try{lv({type:ld.X2.STATUS_UPDATE,payload:{closeAllApi:ld.VI.REQUEST}});let e=await (0,lh.A)({url:"".concat(lu.d6,"/trade/close-all-positions?marginAsset=").concat(t),method:"DELETE",headers:(0,lg.R)(n)});lv({type:ld.X2.STATUS_UPDATE,payload:{closeAllApi:ld.VI.SUCCESS}}),200===e.data.statusCode&&((0,eh.A)({title:"All ".concat(t===iP.Tr.All?"":t," Positions Closed"),description:"All ".concat(t===iP.Tr.All?"":t," positions have been closed successfully at market price."),type:"success"}),r())}catch(e){throw lv({type:ld.X2.STATUS_UPDATE,payload:{closeAllApi:ld.VI.FAIL}}),(0,eh.A)({title:"Error closing all ".concat(t===iP.Tr.All?"":t," Positions"),description:"Error occurred while closing positions. Please try again in some time.",type:"error"}),e}},lY=async(e,t,r,n)=>{try{lv({type:ld.X2.STATUS_UPDATE,payload:{closeAllApi:ld.VI.REQUEST}});let e=await (0,lh.A)(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?lm(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lm(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({url:"".concat(lu.d6,"/trade/order/all"),method:"DELETE",headers:(0,lg.R)(n)},t===iP.Tr.All?{}:{data:{marginAsset:t}}));lv({type:ld.X2.STATUS_UPDATE,payload:{closeAllApi:ld.VI.SUCCESS}}),200===e.data.statusCode&&((0,eh.A)({title:"All ".concat(t===iP.Tr.All?"":t," open orders cancelled"),description:"All ".concat(t===iP.Tr.All?"":t," open orders have been cancelled successfully."),type:"success"}),r())}catch(e){throw lv({type:ld.X2.STATUS_UPDATE,payload:{closeAllApi:ld.VI.FAIL}}),(0,eh.A)({title:"Error cancelling all ".concat(t===iP.Tr.All?"":t," orders"),description:"Error occurred while cancelling orders. Please try again in some time.",type:"error"}),e}},lw=async(e,t,r)=>{try{return(await (0,lh.A)({url:"".concat(lu.d6,"/trade/order"),method:"PATCH",data:e,headers:(0,lg.R)(r)})).data}catch(e){var n,i;return{statusCode:null==e||null==(n=e.body)?void 0:n.statusCode,errorMessage:null==e||null==(i=e.body)?void 0:i.statusDescription}}},lF=(e,t)=>{(0,eh.A)({type:"error",title:(null==t?void 0:t.title)||"Error",description:(null==t?void 0:t.description)||e.response.data.statusDescription})};async function lR(e,t,r){try{lv({type:ld.X2.STATUS_UPDATE,payload:{tradeOrder:ld.VI.REQUEST}});let t=await (0,lh.A)({url:"".concat(lu.d6,"/trade/order"),method:"POST",data:e,headers:(0,lg.R)(r)});return lv({type:ld.X2.STATUS_UPDATE,payload:{tradeOrder:ld.VI.SUCCESS}}),t.data.data}catch(e){var n;(null==e||null==(n=e.response)?void 0:n.status)>=500&&lv({type:lc.X.SET_API_FAIL_STATUS_CODE,payload:500}),lv({type:ld.X2.STATUS_UPDATE,payload:{tradeOrder:ld.VI.FAIL}}),console.log(e),lF(e,{title:"Order Placement Error",description:""})}}function lN(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function lB(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?lN(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lN(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let lx=(0,u.AH)({height:a.Wp.remConverter(18),width:a.Wp.remConverter(18)},"",""),lk=(0,u.AH)([a.vE.flexAlignCenter,a.p0.B5_12_regular,{gap:a.Wp.remConverter(2)}],"",""),lj=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),lW=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue,fontSize:a.Wp.remConverter(12)},"",""),lL=e=>(0,u.AH)({color:"LONG"===e.toLocaleUpperCase()?a.Tj.Zeb_Solid_Green:a.Tj.Zeb_Solid_Red},"",""),lM=e=>(0,u.AH)({color:e>0?a.Tj.Zeb_Solid_Green:e<0?a.Tj.Zeb_Solid_Red:a.Tj.Zeb_Solid_Light_Blue},"",""),lH=e=>(0,u.AH)(lB(lB({},a.p0.B5_12_semibold),{},{color:e>75?a.Tj.Zeb_Solid_Red:e>35?a.Tj.Zeb_Solid_Yellow:a.Tj.Zeb_Solid_Green}),"",""),lU=e=>(0,u.AH)([lM(e),a.vE.flexAlignCenter,{gap:a.Wp.remConverter(4)}],"",""),lq=(0,u.AH)({fontSize:a.Wp.remConverter(12)},"",""),lZ={name:"ahj9ei",styles:"background:none;border:none;cursor:pointer"},lV=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(8)}],"",""),lK=(0,u.AH)([a.vE.flexAlignCenter,a.p0.B5_12_semibold,{maxWidth:"80px",gap:a.Wp.remConverter(4),flexWrap:"wrap",overflow:"hidden"}],"",""),lG=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),lz=(0,u.AH)({fontSize:a.Wp.remConverter(16),color:a.Tj.Zeb_Solid_White},"",""),lX=(0,u.AH)([a.vE.flexAlignCenter,{justifyContent:"space-between",width:"100%",marginRight:a.Wp.remConverter(8)}],"",""),l$=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,a.Wp.p(16),{position:"fixed",left:"22%",right:"22%",bottom:a.Wp.remConverter(20),border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),borderRadius:a.Wp.remConverter(8),boxShadow:a.Tj.Zeb_Effects_Shadow_Hover,background:a.Tj.Zeb_Solid_Dark_Blue,zIndex:9}],"",""),lQ=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(12)}],"",""),lJ=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,{borderRadius:a.Wp.remConverter(8),background:a.Tj.Zeb_Solid_Dark_Grey,height:a.Wp.remConverter(30),width:a.Wp.remConverter(30),color:a.Tj.Zeb_Solid_Light_Blue}],"",""),l0=(0,u.AH)({borderColor:a.Tj.Zeb_Solid_Red,backgroundColor:a.Tj.Zeb_Transparent_Red},"",""),l1=(0,u.AH)({fontSize:a.Wp.remConverter(30),color:a.Tj.Zeb_Solid_Grey,cursor:"pointer","&:hover":{color:a.Tj.Zeb_Solid_Light_Red,transition:"all 0.2s"}},"",""),l2=(0,u.AH)([a.vE.flexColumn,{gap:a.Wp.remConverter(16),background:a.Tj.Zeb_Solid_Dark_Blue}],"",""),l4={name:"d4zri6",styles:"max-width:200px;display:block;overflow:hidden;text-overflow:ellipsis"},l8=(0,u.AH)({display:"flex",alignItems:"center",gap:a.Wp.remConverter(4),div:{borderRadius:a.Wp.remConverter(8)}},"",""),l5=(0,u.AH)({color:a.Tj.Zeb_Solid_Bright_Blue,fontSize:"12px"},"",""),l6=(0,u.AH)(lB(lB({},a.p0.B4_14_semibold),{},{display:"flex",gap:a.Wp.remConverter(8),alignItems:"center",color:a.Tj.Zeb_Solid_White,i:{fontSize:"16px"}}),"",""),l3=(0,u.AH)(lB(lB({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginTop:a.Wp.remConverter(8),width:"100%",whiteSpace:"break-spaces",textDecoration:"none",textTransform:"none",textAlign:"left"}),"",""),l9=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),width:a.Wp.remConverter(310),position:"relative",top:5},"",""),l7=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),width:a.Wp.remConverter(340),position:"relative",top:5},"",""),oe=(0,u.AH)(lB(lB({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),ot=(0,u.AH)(lB(lB({},a.p0.B4_14_semibold),{},{i:{fontSize:a.Wp.remConverter(16)}}),"",""),or=(0,u.AH)(lB(lB({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginTop:a.Wp.remConverter(8)}),"",""),on=e=>(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),position:"relative",opacity:+!!e,right:-50},"",""),oi=(0,u.AH)(lB(lB({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,backgroundColor:a.Tj.Zeb_Solid_BG_Blue,borderRadius:a.Wp.remConverter(8),padding:"".concat(a.Wp.remConverter(8)," ").concat(a.Wp.remConverter(12)),display:"flex",alignItems:"center",justifyContent:"space-between"}),"",""),ol=(0,u.AH)(lB({},a.p0.B4_14_regular),"",""),oo=(0,u.AH)(lB(lB({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),oa=(0,u.AH)(lB({},a.p0.B6_10_semibold),"",""),os=(0,u.AH)(lB(lB({},a.p0.B6_10_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),oc=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),od=(0,u.AH)({color:a.Tj.Zeb_Solid_White},"",""),ou=(0,u.AH)(lB(lB({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),op=(0,u.AH)({borderRadius:a.Wp.remConverter(8),span:{color:a.Tj.Zeb_Solid_Light_Blue,background:a.Tj.Zeb_Solid_BG_Blue,":first-of-type":{paddingRight:0},":last-of-type":{paddingLeft:a.Wp.remConverter(4)}},input:lB(lB({},a.p0.B4_14_regular),{},{textAlign:"right",marginRight:a.Wp.remConverter(-12),width:a.Wp.remConverter(50),paddingLeft:a.Wp.remConverter(4),background:a.Tj.Zeb_Solid_BG_Blue,"::placeholder":{color:a.Tj.Zeb_Solid_White}}
1)},"",""),oh=(0,u.AH)(lB(lB({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,display:"flex",gap:a.Wp.remConverter(4)}),"",""),og=(0,u.AH)(lB({},a.p0.B5_12_semibold),"",""),om=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),borderRadius:a.Wp.remConverter(8)},"",""),ov=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Yellow),borderRadius:a.Wp.remConverter(8),backgroundColor:a.Tj.Zeb_BG_Yellow,padding:"".concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(16)),ul:{paddingLeft:a.Wp.remConverter(16)}},"",""),oA=(0,u.AH)(lB(lB({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_Yellow,display:"flex",gap:a.Wp.remConverter(8),paddingBottom:a.Wp.remConverter(4),i:{color:a.Tj.Zeb_Solid_Yellow}}),"",""),ob=(0,u.AH)(lB(lB({},a.p0.B5_12_regular),{},{width:"100%",textWrap:"wrap"}),"",""),oy=(0,u.AH)(lB(lB({},a.p0.B4_14_semibold),{},{display:"flex",gap:a.Wp.remConverter(8),marginBottom:a.Wp.remConverter(12),i:{fontSize:a.Wp.remConverter(16)}}),"",""),of=(0,u.AH)(lB(lB({},a.p0.B4_14_semibold),{},{display:"flex",justifyContent:"space-between",backgroundColor:a.Tj.Zeb_Solid_BG_Blue,borderRadius:a.Wp.remConverter(8),padding:a.Wp.remConverter(8),img:{width:a.Wp.remConverter(20),height:a.Wp.remConverter(20),marginRight:a.Wp.remConverter(8)}}),"",""),o_=(0,u.AH)({fontSize:a.Wp.remConverter(16),color:a.Tj.Zeb_Solid_White},"",""),oS=(0,u.AH)(a.p0.B5_12_regular,a.vE.textFaded,"white-space:wrap;text-align:left;",""),oT=(0,u.AH)(a.vE.flexColumn,{gap:a.Wp.remConverter(4),cursor:"pointer"},"",""),oC=(0,u.AH)((0,p.Kk)(12,a.Tj.Zeb_Solid_Bright_Blue),"cursor:pointer;",""),oE=(0,u.AH)({borderRadius:a.Wp.remConverter(8),span:{color:a.Tj.Zeb_Solid_Light_Blue,background:a.Tj.Zeb_Solid_BG_Blue,":first-of-type":{paddingRight:0},":last-of-type":{paddingLeft:a.Wp.remConverter(4)}},input:lB(lB({},a.p0.B4_14_regular),{},{textAlign:"right",width:a.Wp.remConverter(50),paddingLeft:a.Wp.remConverter(4),paddingRight:0,background:a.Tj.Zeb_Solid_BG_Blue,"::placeholder":{color:a.Tj.Zeb_Solid_White}})},"",""),oI=(0,u.AH)([a.p0.B4_14_regular,a.vE.flexAlignCenter,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),oD=function(e){return e.Check="Check",e.Date="date",e.Pair="pair",e.Size="size",e.Quantity="quantity",e.Entry_Price="entryPrice",e.Mark_Price="markPrice",e.Liq_Price="liqPrice",e.Margin_Ratio="marginRatio",e.Unrealised_PnL="unrealisedPnL",e.Realised_PnL="realisedPnL",e.Close_Position="closePosition",e.TP_SL="tpSL",e.Margin="margin",e.Asset="Asset",e.Margin_Isolated="marginIsolated",e.Isolated_Margin="isolatedMargin",e.PnL="PnL",e.Menu="menu",e.Order_Type="orderType",e.Side="side",e.Price="price",e.Filled="filled",e.Total="total",e.Reduce_Only="reduceOnly",e.Post_Only="postOnly",e.Amount="amount",e.Average="average",e.Executed="executed",e.Fee="fee",e.Role="role",e.Realized_Profit="realizedProfit",e.Status="status",e.Trigger_Conditions="triggerConditions",e.Type="type",e.Delete="Delete",e.MarginType="Margin Type",e.MarginTopUp="Auto Top-Up",e.Edit="Edit",e.OrderID="OrderID",e.TradeID="TradeID",e}({});var oP=r(25763);let oO=function(e){return e.Slice="slice",e.Round="round",e}({}),oY=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:oO.Slice,n=e.toString(),i=n.indexOf(".");return -1===i?n:t?r===oO.Slice?n.slice(0,i+t+1):Number(n).toFixed(t):n.slice(0,i)},ow=(e,t)=>{let r=e.toString(),n=r.indexOf(".");return -1===n?r:0===t?r.substring(0,n):r.substring(0,n)+r.substring(n,n+t+1)},oF=function(e){return e.ROUND="round",e.SLICE="slice",e}({}),oR=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:oF.SLICE,i="string"==typeof e?parseFloat(e):e,l=isNaN(i)||!isFinite(i)?0:i,o=n===oF.SLICE,a=oN(l),s=Math.min(isNaN(a)?t:a,t),c=Math.max(r,isNaN(s)?r:s);return new oP.A(l).decimalPlaces(c,o?oP.A.ROUND_FLOOR:oP.A.ROUND_HALF_EVEN).toNumber()},oN=e=>{if(isNaN(e)||!isFinite(e)||Math.floor(e)===e)return 0;let t=e.toString();if(-1!==t.indexOf(".")&&-1!==t.indexOf("-"));else if(-1!==t.indexOf("."))return t.split(".")[1].length||0;return+t.split("-")[1]||0},oB=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:oF.SLICE;return oR(e,t,r,n).toString()},ox=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:oF.SLICE;try{let r=Number(oY(e,t,oO.Slice)),n=new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:t,maximumFractionDigits:t}).resolvedOptions().maximumFractionDigits;
1return r.toLocaleString("en-IN",{minimumFractionDigits:n,maximumFractionDigits:n})}catch(n){return oB(e,t,void 0,r)}},ok=e=>{["e","+","-"].includes(e.key)&&e.preventDefault()},oj=async e=>{if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(e)};function oW(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}let oL={name:"b9l38d",styles:"width:min-content"},oM=(0,u.AH)({width:"max-content",padding:a.Wp.remConverter(12),backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),borderRadius:8,boxShadow:a.Tj.Zeb_Effects_Shadow_Hover,position:"relative",zIndex:99},"",""),oH=(0,u.AH)(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?oW(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oW(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({position:"absolute",top:a.Wp.remConverter(12),right:a.Wp.remConverter(12),width:a.Wp.remConverter(16),height:a.Wp.remConverter(16),margin:0,padding:0,background:"none",border:"none",cursor:"pointer"},a.p0.H6_16_semibold),"","");var oU=r(82148),oq={name:"16w6w5b",styles:"z-index:999"};let oZ=e=>{let{visible:t,setVisible:r,children:n,content:l,onClose:o,containerStyle:a,contentContainerStyles:s,style:c,position:d="right-start"}=e,p=i.useRef(null),h=i.useRef(null),g=i.useRef(null);function m(){r(!1),o&&o()}return i.useEffect(()=>{p.current&&h.current&&(0,oU.n4)(h.current,p.current,{placement:d,modifiers:[{name:"offset",options:{offset:[0,5]}}]})},[p,h,t,d]),i.useEffect(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&m()};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[g]),(0,T.FD)("div",{css:[oL,a,"",""],children:[(0,T.Y)("div",{ref:h,"aria-describedby":"tooltip",onClick:()=>r(!0),children:n}),(0,T.Y)("div",{ref:p,role:"tooltip",css:[oq,s,"",""],children:t&&(0,T.Y)("div",{ref:g,children:(0,T.Y)("div",{css:(0,u.AH)([oM,c],"",""),children:p.current&&(0,T.FD)(T.FK,{children:[(0,T.Y)("button",{css:oH,onClick:m,children:(0,T.Y)("i",{className:"icon icon-cross"})}),l]})})})})]})};function oV(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function oK(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?oV(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oV(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let oG=(0,u.AH)({padding:"".concat(a.Wp.remConverter(20)," ").concat(a.Wp.remConverter(32)),height:"calc(100vh - ".concat(a.Wp.remConverter(80),")"),display:"flex",flexDirection:"column",justifyContent:"space-between"},"",""),oz=(0,u.AH)(oK(oK({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),oX=(0,u.AH)({span:{paddingLeft:0},input:{paddingRight:a.Wp.remConverter(4)},flex:1,position:"relative"},"","");a.Wp.remConverter(4),a.Wp.remConverter(12),a.Tj.Zeb_Solid_Light_Blue,a.Tj.Zeb_Solid_Bright_Blue;let o$=(0,u.AH)({backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,padding:"".concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(16)),marginTop:a.Wp.remConverter(20),borderRadius:a.Wp.remConverter(12),display:"flex",flexDirection:"column",gap:a.Wp.remConverter(12)},"",""),oQ=(0,u.AH)(oK(oK({},a.p0.B4_14_regular),{},{display:"flex",justifyContent:"space-between"}),"",""),oJ=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue,display:"flex",alignItems:"center",gap:a.Wp.remConverter(4),i:{fontSize:a.Wp.remConverter(16)},img:{height:a.Wp.remConverter(16)}},"",""),o0=(0,u.AH)({minWidth:a.Wp.remConverter(122),textTransform:"none"},"",""),o1=(0,u.AH)(oK(oK({},a.p0.C3_14),{},{position:"absolute",top:0,right:0,color:a.Tj.Zeb_Solid_Bright_Blue,cursor:"pointer"}),"",""),o2=(0,u.AH)(oK(oK({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,display:"flex",flexDirection:"row-reverse"}
1),"",""),o4=(0,u.AH)({height:"1px",width:"100%",backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,marginBottom:a.Wp.remConverter(12)},"","");a.Wp.remConverter(16),a.Wp.remConverter(16);let o8=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Yellow),borderRadius:a.Wp.remConverter(8),backgroundColor:a.Tj.Zeb_BG_Yellow,padding:"".concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(16)),ul:{paddingLeft:a.Wp.remConverter(16)}},"",""),o5=(0,u.AH)(oK(oK({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_Yellow,display:"flex",gap:a.Wp.remConverter(8),paddingBottom:a.Wp.remConverter(4),i:{color:a.Tj.Zeb_Solid_Yellow}}),"",""),o6=(0,u.AH)(oK({},a.p0.B5_12_regular),"",""),o3=(0,u.AH)({display:"flex",gap:a.Wp.remConverter(20),button:{flex:1}},"",""),o9=function(e){return e.ADD="addMargin",e.REDUCE="reduceMargin",e}({}),o7=e=>{var t,r,n,l,o,s,c,d,p,h,g,m;let v,{position:A,maxAddableMargin:b,maxRemovableMargin:y,currentAssignedMargin:f,setMarginSidebarOpen:_,onClose:S}=e,{walletData:C,coinList:E,updateWalletBalanceCallback:I,subAccountId:D,userInfo:P}=(0,i.useContext)(ds),{0:O,1:Y}=(0,i.useState)(""),w=null!=(t=null==A?void 0:A.marginConversionRate)?t:1,F=(0,en.A)(O),{0:R,1:N}=(0,i.useState)(o9.ADD),{0:B,1:x}=(0,i.useState)(!1),{0:k,1:j}=(0,i.useState)(!1),W=null==(r=E.find(e=>e.pair===(null==A?void 0:A.contractPair)))?void 0:r.marginBufferPercentage,L=null==(n=E.find(e=>e.pair===(null==A?void 0:A.contractPair)))?void 0:n.maintenanceMarginPercentage,M=null==(l=E.find(e=>e.pair===(null==A?void 0:A.contractPair)))?void 0:l.maintenanceMarginConfig;(0,i.useEffect)(()=>{Y("")},[R]);let{pricePrecision:H}=(0,i.useMemo)(()=>{var e,t;let r=E.find(e=>e.pair===(null==A?void 0:A.contractPair));return{quantityPrecision:Number(null!=(e=null==r?void 0:r.quantityPrecision)?e:sN),pricePrecision:Number(null!=(t=null==r?void 0:r.pricePrecision)?t:sR)}},[E,A]),U=async()=>{x(!0);let e=await lP(A.positionId,Number(O),(null==P?void 0:P.access_token)||"",R,D);if(x(!1),e){var t;_(!1),N(o9.ADD),Y(""),(0,eh.A)({title:"Margin Updated Successfully ",description:"Margin set to ".concat(sk(f+(R===o9.ADD?1:-1)*Number(O))," ").concat(null==A?void 0:A.quoteAsset," successfully."),type:e7.C.success});let r={availableBalance:(null==(t=C.balance)?void 0:t.availableBalance)||"",lockedBalance:e.lockedBalance.toString(),withdrawableBalance:e.withdrawableBalance.toString()};I(e.asset,r)}},q=e=>{if(e){if(R===o9.ADD&&Number(e)>Number(b))return"Max. addable margin ".concat(sk(b,(null==A?void 0:A.quoteAsset)==="INR"?sR:sB)," ").concat(null==A?void 0:A.quoteAsset);else if(R===o9.REDUCE&&Number(e)>y)return"Max. removable margin ".concat(sk(y,(null==A?void 0:A.quoteAsset)==="INR"?sR:sB)," ").concat(null==A?void 0:A.quoteAsset)}return""},Z=(null!=(o=null==A?void 0:A.leverage)?o:0)>=(null!=(s=null==M||null==(c=M[0])?void 0:c.rangeStart)?s:0)&&(null!=(d=null==A?void 0:A.leverage)?d:0)<=(null!=(p=null==M||null==(h=M[0])?void 0:h.rangeEnd)?p:0),V=String(null!=(g=null==M||null==(m=M[0])?void 0:m.percentageValue)?g:L),K=((e,t,r,n)=>{if(!e)return 0;let i="LONG"===e.positionType?1:-1,l=e.entryPrice-(e.margin+n)/(e.quantity*i*(1+.01*parseFloat(t)));return l+Math.abs(Math.abs(e.positionSize/e.leverage)*(1+.01*parseFloat(t))*parseFloat(r)/100)*i/e.quantity})(A,W||"0",Z?V:L||"0",(R===o9.ADD?1:-1)*Number(O));return(0,T.FD)("div",{css:oG,children:[(0,T.FD)("div",{children:[(0,T.FD)("div",{css:[(v=!k,(0,u.AH)({display:"flex",gap:a.Wp.remConverter(12),button:{height:a.Wp.remConverter(40),border:v?"none":""},"ul:first-of-type":{width:a.Wp.remConverter(184),margin:0,padding:0}},"","")),q(F)&&a.vE.flexAlignCenter,"",""],children:[(0,T.FD)("div",{css:oX,children:[(0,T.Y)(a.pd,{appendItem:(0,T.Y)("div",{css:oz,children:null==A?void 0:A.quoteAsset}),label:"Margin",type:"number",value:O,placeholder:"Amount",onChange:e=>{e.value.length<=12&&Y(oY(e.value,(null==A?void 0:A.quoteAsset)==="INR"?sR:sB).toString())},errorText:q(F),onKeyDown:ok}),(0,T.Y)("div",{css:o1,onClick:()=>Y(ow(R===o9.ADD?b:y,(null==A?void 0:A.quoteAsset)==="INR"?sR:sB)),children:"MAX"})]}),(0,T.Y)("div",{style:{position:"relative",display:"flex",flexDirection:"column",justifyContent:"flex-end"},children:(0,T.Y)(a.l6,{placeholder:"Add",onChange:e=>N(e),selected:R,style:o0,options:[{label:"Add",value:o9.ADD},{label:"Reduce",value:o9.REDUCE}],onDropdownClick:e=>{j(e)}})})]}),(0,T.FD)("div",{css:o$,children:[(0,T.FD)("div",{children:[(0,T.FD)("div",{css:oQ,children:[(0,T.FD)("div",{css:oJ,children:[(0,T.Y)("img",{src:ed.A.ic_margin}),"Currently assigned margin"]}),(0,T.FD)("div",{children:[ox(f,(null==A?void 0:A.quoteAsset)==="INR"?sR:sB)," ",null==A?void 0:A.quoteAsset]})]}),(null==A?void 0:A.quoteAsset)!==(null==A?void 0:A.marginAsset)&&(0,T.FD)("div",{css:o2,children:["~ ",ox(f*w)," ","INR"]})]}),(0,T.FD)("div",{children:[(0,T.FD)("div",{css:oQ,children:[(0,T.FD)("div",{css:oJ,children:[(0,T.Y)(a.In,{name:"fees"}),"Maximum"," ",R===o9.ADD?"addable":"removable"," ","margin"]}),(0,T.FD)("div",{children:[ox(R===o9.ADD?b:y,(null==A?void 0:A.quoteAsset)==="INR"?sR:sB)," ",null==A?void 0:A.quoteAsset]})]}),(null==A?void 0:A.quoteAsset)!==(null==A?void 0:A.marginAsset)&&(0,T.FD)("div",{css:o2,children:["~"," ",ox(R===o9.ADD?b*w:y*w,sR)," ","INR"]})]}),(0,T.FD)("div",{children:[(0,T.FD)("div",{css:oQ,children:[(0,T.FD)("div",{css:oJ,children:[(0,T.Y)(a.In,{name:"pay-emi"}),"Est. liq price after margin modification"]}),K>=0?(0,T.FD)("div",{children:[ox(K,H)," ",null==A?void 0:A.quoteAsset]}):(0,T.Y)(a.In,{name:sx(0),style:lq})]}),(null==A?void 0:A.quoteAsset)!==(null==A?void 0:A.marginAsset)&&(0,T.Y)("div",{css:o2,children:K>=0?(0,T.FD)("div",{children:["~"," ",ox(K*w,H)," ","INR"]}):(0,T.Y)(a.In,{name:sx(0),style:lq})})]}),(null==A?void 0:A.quoteAsset)!==(null==A?void 0:A.marginAsset)&&(0,T.FD)("div",{children:[(0,T.Y)("div",{css:o4}),(0,T.FD)("div",{css:oQ,children:[(0,T.FD)("div",{css:oJ,children:[(0,T.Y)(a.In,{name:"pay-emi"}),"Conversion Rate"]}),"1 ",im]}),(0,T.FD)("div",{css:o2,children:["~ ",w," ","INR"]})]})]}),(null==A?void 0:A.quoteAsset)!==(null==A?void 0:A.marginAsset)&&(0,T.Y)("div",{style:{marginTop:"1.25rem"},children:(0,T.FD)("div",{css:o8,children:[(0,T.FD)("div",{css:o5,children:[(0,T.Y)(a.In,{name:"info"}),"How Conversion Works"]}),(0,T.Y)("div",{children:(0,T.FD)("ul",{children:[(0,T.Y)("li",{css:o6,children:"Your INR will be automatically converted to USDT when using INR margins."}),(0,T.Y)("li",{css:o6,children:"Fees and TDS are not applicable for these conversions."}),(0,T.Y)("li",{css:o6,children:"USDT-INR Conversion rate is fixed for the opening and closing of this position. Your position will not be exposed to the fluctuations of the USDT-INR exchange rate."})]})})]})})]}),(0,T.FD)("div",{css:o3,children:[(0,T.Y)(a.$n,{type:"secondary",onClick:S,children:"CANCEL"}),(0,T.Y)(a.$n,{type:"primary",disabled:!(Number(O)>0)||q(F).length>0,onClick:U,loading:B,children:"Update Margin"})]})]})};function ae(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function at(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?ae(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ae(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let ar={name:"drz3md",styles:"height:calc(100% - 80px);display:flex;flex-direction:column;position:relative"},an=(0,u.AH)(at({padding:"20px 0 0 0",flex:1,overflowY:"scroll",overflowX:"hidden"},(0,p.r)(!1)),"",""),ai=(0,u.AH)({borderRadius:"12px",padding:"12px",backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,display:"flex",flexDirection:"column",gap:"12px",margin:"0 32px 0 32px"},"",""),al=(0,u.AH)(at(at({},a.p0.B4_14_regular),{},{display:"flex",justifyContent:"space-between"}),"",""),ao=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue,display:"flex",gap:"12px"},"",""),aa={name:"1wesxqa",styles:"display:flex;gap:12px"},as=(0,u.AH)({fontSize:a.Wp.remConverter(14)},"",""),ac={name:"11g4mt0",styles:"font-size:16px"};at(at({},a.p0.H6_16_bold),{},{display:"flex",gap:a.Wp.remConverter(8),i:{fontSize:a.Wp.remConverter(20)}}),a.Wp.remConverter(12),at(at({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),a.Wp.remConverter(174),a.Wp.remConverter(302),at(at({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginTop:a.Wp.remConverter(12)}),a.Tj.Zeb_Solid_White,a.Tj.Zeb_Solid_Dark_Blue,a.Wp.remConverter(20),a.Wp.remConverter(20);let ad=(0,u.AH)({marginTop:a.Wp.remConverter(20),paddingLeft:a.Wp.remConverter(16),paddingRight:a.Wp.remConverter(16)},"","");a.Tj.Zeb_Solid_Red,a.Tj.Zeb_Solid_Green,at(at({},a.p0.C3_14),{},{color:a.Tj.Zeb_Solid_Bright_Blue,cursor:"pointer"}),at(at({},a.p0.B4_14_semibold),{},{backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(8),padding:a.Wp.remConverter(8),display:"flex",justifyContent:"space-between",gap:a.Wp.remConverter(8)}),at(at({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginBottom:a.Wp.remConverter(4),marginTop:a.Wp.remConverter(12)}),at(at({},a.p0.B4_14_semibold),{},{backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(8),height:a.Wp.remConverter(40),width:a.Wp.remConverter(100),padding:"".concat(a.Wp.remConverter(4)," ").concat(a.Wp.remConverter(12)),display:"flex",alignItems:"center"});let au=(0,u.AH)({display:"flex",gap:a.Wp.remConverter(12),i:{fontSize:a.Wp.remConverter(20)}},"",""),ap=(0,u.AH)(at(at({},a.p0.B4_14_regular),{},{position:"absolute",display:"flex",color:a.Tj.Zeb_Solid_Light_Blue,top:0,right:0}),"",""),ah=(0,u.AH)(at(at({},a.p0.C3_14),{},{color:a.Tj.Zeb_Solid_Bright_Blue,cursor:"pointer"}),"",""),ag=(0,u.AH)(at(at({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginRight:a.Wp.remConverter(4)}),"",""),am=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),av=(0,u.AH)({marginTop:a.Wp.remConverter(20),borderBottom:"2px solid ".concat(a.Tj.Zeb_Solid_Dark_Blue),padding:"0 32px 0 32px"},"",""),aA={name:"11wcdu",styles:"padding:0 32px 0 32px"},ab=(0,u.AH)({width:a.Wp.remConverter(16),height:a.Wp.remConverter(16),marginRight:a.Wp.remConverter(8)},"",""),ay=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.mt(8),at(at({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Red}),"","");function af(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function a_(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?af(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):af(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let aS=(0,u.AH)([a.p0.H4_28_bold,{padding:"".concat(a.Wp.remConverter(20)," ").concat(a.Wp.remConverter(32))}],"",""),aT=(0,u.AH)([a.vE.flexColumn,a_({padding:"".concat(a.Wp.remConverter(20)," ").concat(a.Wp.remConverter(32)),height:"calc(100% - ".concat(a.Wp.remConverter(80),")"),overflow:"auto",gap:a.Wp.remConverter(4)},p.Fp)],"",""),aC=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,{gap:a.Wp.remConverter(16)}],"",""),aE=(0,u.AH)(a_(a_({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),aI=(0,u.AH)([a.Wp.p(12),a.vE.flexAlignCenter,{gap:a.Wp.remConverter(12),borderRadius:"".concat(a.Wp.remConverter(8)," ").concat(a.Wp.remConverter(8)," 0 0"),background:a.Tj.Zeb_Gradient_Dark_Blue}],"",""),aD=(0,u.AH)([a.vE.flexColumn,{gap:a.Wp.remConverter(12),padding:"".concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(16)),background:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:"0 0".concat(a.Wp.remConverter(8)," ").concat(a.Wp.remConverter(8))}],"",""),aP=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(12),color:a.Tj.Zeb_Solid_Light_Blue}],"",""),aO=(0,u.AH)({fontSize:a.Wp.remConverter(16)},"",""),aY=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),aw=(0,u.AH)([a.vE.flexAlignCenter,a.p0.B4_14_regular,{gap:a.Wp.remConverter(12),color:a.Tj.Zeb_Solid_White}],"",""),aF=(0,u.AH)([a.vE.flexColumn,{gap:a.Wp.remConverter(12),padding:"".concat(a.Wp.remConverter(12)," ").concat(a.Wp.remConverter(16)),background:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(8)}],"",""),aR=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,{gap:a.Wp.remConverter(12),flex:"1 1 50%",flexWrap:"wrap"}],"",""),aN=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(8),width:"calc(50% - ".concat(a.Wp.remConverter(6),")"),minWidth:a.Wp.remConverter(200)}],"",""),aB=(0,u.AH)([a.vE.flexAlignCenter,a.p0.B4_14_regular,{gap:a.Wp.remConverter(4)}],"",""),ax=e=>e?e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"",ak=e=>{let{icon:t,title:r,text:n,subText:i,color:l}=e;return(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,"",""],children:[(0,T.FD)("div",{css:aP,children:[(0,T.Y)(a.In,{name:t,style:aO}),(0,T.Y)("span",{css:aY,children:r})]}),(0,T.FD)("div",{css:aw,children:[(0,T.Y)("span",{css:(0,u.AH)({color:l||a.Tj.Zeb_Solid_White},"",""),children:n}),i]})]})},aj=e=>{let{data:t,bothTPSL:r}=e,n=t.baseAsset;return(0,T.FD)("div",{css:a.vE.flexColumn,children:[(0,T.FD)("div",{css:aI,children:[(0,T.Y)("img",{src:ed.A.i_illustration_03,height:42,width:42}),(0,T.FD)("div",{css:a.vE.flexColumn,children:[(0,T.Y)("span",{css:[a.p0.B3_16_semibold,"",""],children:"Order A"}),(0,T.FD)("span",{css:aE,children:["If order A is filled partially or fully, order B"," ",r?"& C":""," will be placed"]})]})]}),(0,T.FD)("div",{css:aD,children:[(0,T.Y)(ak,{icon:"templates",title:"Market",text:ax(t.status)}),(0,T.Y)(ak,{icon:"side-2",title:"Side",text:ax(t.side),color:"SELL"===t.side?a.Tj.Zeb_Solid_Red:a.Tj.Zeb_Solid_Green}),(0,T.Y)(ak,{icon:"coins",title:"Quantity",text:t.orderAmount,subText:n})]})]})};function aW(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function aL(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?aW(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):aW(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let aM=(0,u.AH)(a.vE.flexColumn,{position:"absolute",left:a.Wp.remConverter(-580),bottom:"15%",width:a.Wp.remConverter(570),border:"2px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),borderRadius:a.Wp.remConverter(8),backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,padding:a.Wp.remConverter(16)},"",""),aH=(0,u.AH)({position:"absolute",right:a.Wp.remConverter(-10),bottom:a.Wp.remConverter(80),img:{height:a.Wp.remConverter(26),width:a.Wp.remConverter(10)}},"",""),aU=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.g(8),aL({},a.p0.H6_16_bold),"",""),aq=(0,u.AH)({color:a.Tj.Zeb_Solid_Bright_Blue,fontSize:a.Wp.remConverter(16)},"",""),aZ=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue)},"",""),aV=(0,u.AH)(a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,"",""),aK=(0,u.AH)(a.vE.flexColumn,a.Wp.g(4),"",""),aG=(0,u.AH)(aL(aL({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),az=(0,u.AH)(aL(aL({},a.p0.B4_14_semibold),{},{marginLeft:a.Wp.remConverter(4)}),"",""),aX={name:"msg6bs",styles:"position:relative;height:60px;width:60px;overflow:hidden;text-align:center"},a$=(0,u.AH)({position:"absolute",right:a.Wp.remConverter(-20),top:a.Wp.remConverter(-12),height:"50px"},"",""),aQ=(0,u.AH)(a.Wp.mtb(12),{height:a.Wp.remConverter(1),borderTop:"1px solid ".concat(a.Tj.Zeb_Solid_BG_Blue)},"",""),aJ=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.g(16),a.vE.flexJustifiedBetween,aL(aL({},a.p0.B5_12_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,padding:"".concat(a.Wp.remConverter(2)," 0")}),"",""),a0=(0,u.AH)(a.vE.flexColumn,a.Wp.g(8),"margin-bottom:auto;",""),a1=(0,u.AH)(a.Wp.ptb(12),aL(aL({},a.p0.B4_14_semibold),{},{backgroundColor:a.Tj.Zeb_Solid_BG_Blue,borderRadius:a.Wp.remConverter(8),display:"flex"}),"",""),a2=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.g(8),{flex:1.08,paddingLeft:a.Wp.remConverter(12)},"",""),a4={name:"b2ldk",styles:"flex:1.6"},a8={name:"b2ldk",styles:"flex:1.6"},a5=(0,u.AH)(a.vE.flexAlignCenter,a.vE.flexJustifiedEnd,{flex:1,paddingRight:a.Wp.remConverter(12)},"",""),a6=(0,u.AH)(a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,"",""),a3=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.g(4),{color:a.Tj.Zeb_Solid_White},"",""),a9=(0,u.AH)({fontSize:a.Wp.remConverter(18),paddingLeft:a.Wp.remConverter(12),color:a.Tj.Zeb_Solid_Light_Blue},"",""),a7=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.g(8),a.Wp.mb(8),aL(aL({},a.p0.B4_14_semibold),{},{i:{fontSize:a.Wp.remConverter(16)}}),"",""),se=(0,u.AH)(a.vE.flexAlignCenter,a.vE.flexColumn,a.Wp.g(8),{padding:"0 ".concat(a.Wp.remConverter(12)),alignItems:"start"},"","");a.Wp.mt(8),aL(aL({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Red});let st=(0,u.AH)({display:"flex",gap:a.Wp.remConverter(12)},"",""),sr=(0,u.AH)(aL(aL({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_White,marginBottom:a.Wp.remConverter(8)}),"","");var sn=r(75265);function si(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sl(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?si(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):si(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let so=[a.Tj.Zeb_Solid_Yellow,a.Tj.Zeb_Solid_Blue_02,a.Tj.Zeb_Solid_Purple_01,a.Tj.Zeb_Solid_Green_02,"#20D3D3"],sa=(0,i.memo)(function(e){let{data:t,height:r,width:n,innerRadius:i,interactive:l,onMouseEnter:o,onMouseLeave:a,style:s}=e;return(0,T.Y)("div",{css:s,children:(0,T.Y)(sn.Fq,sl(sl({},{width:n,height:null!=r?r:52,data:t,animate:!1,activeOuterRadiusOffset:2,activeInnerRadiusOffset:2}),{},{margin:{top:16,bottom:16,left:16,right:16},innerRadius:Number(i)||.6,startAngle:0,endAngle:-360,enableArcLabels:!1,width:100,tooltip:function(){return(0,T.Y)("div",{})},onMouseEnter:o,onMouseLeave:a,enableArcLinkLabels:!1,colors:{datum:"data.fill"},isInteractive:l}))})});var ss={name:"82a6rk",styles:"flex:1"};let sc=e=>{var t,r;let n,{list:l,position:o,coinList:s,isTp:c,handleRemove:d}=e,{0:p,1:h}=(0,i.useState)(""),g=l.existing.reduce((e,t)=>
1e+t.qty,0),m=l.new.reduce((e,t)=>e+t.qty,0),v=(null!=(t=null==o?void 0:o.quantity)?t:0)-g-m,A=(g+m)/o.quantity*o.margin,{0:b,1:y}=(0,i.useState)([]),f=l.existing.length+l.new.length;(0,i.useEffect)(()=>{let e=[...l.new,...l.existing].map(e=>e.orderId||e.id);y(t=>t.filter(t=>e.includes(t)))},[l]),(0,i.useEffect)(()=>{if(b.length>0){let e=setTimeout(()=>{y([])},1e4);return()=>clearTimeout(e)}},[b]);let _=s.find(e=>e.pair===(null==o?void 0:o.contractPair)),S=()=>(0,T.FD)("div",{css:aJ,children:[(0,T.Y)("div",{css:a2,children:"Split %"}),(0,T.FD)("div",{css:a4,children:["Qty used (",null==o?void 0:o.baseAsset,")"]}),(0,T.FD)("div",{css:a8,children:["TP Price (",null==o?void 0:o.quoteAsset,")"]}),(0,T.FD)("div",{css:[a5,a.Wp.pr(46),"",""],children:["P&L(",null==o?void 0:o.quoteAsset,")"]})]}),C=(e,t)=>{var r,n;let i=p===e.id,l=so[t],s="LONG"===o.positionType?1:-1,c=e.qty*(e.price-o.entryPrice)*s,h=b.includes(null!=(r=e.orderId)?r:"-"),g=c>0?a.Tj.Zeb_Solid_Green:c<0?a.Tj.Zeb_Solid_Red:a.Tj.Zeb_Solid_Light_Blue,m=Number(null!=(n=null==_?void 0:_.quantityPrecision)?n:2);return(0,T.FD)("div",{style:{border:i?"1px solid ".concat(l):""},css:a1,children:[(0,T.FD)("div",{css:a2,children:[(0,T.Y)("div",{css:(0,u.AH)({he
1ight:a.Wp.remConverter(12),width:a.Wp.remConverter(12),borderRadius:"50%",backgroundColor:l},"","")}),(0,T.FD)("div",{children:[(100*e.qty/o.quantity).toFixed(2),"%"]})]}),(0,T.Y)("div",{css:a4,children:e.qty.toFixed(m)}),(0,T.Y)("div",{css:a8,children:ox(e.price,Number(null==_?void 0:_.pricePrecision))}),(0,T.FD)("div",{css:a5,children:[(0,T.Y)("span",{css:(0,u.AH)({color:g},"",""),children:ox(c,E)}),(0,T.Y)("span",{css:a.vE.flexAlignCenter,children:h?(0,T.Y)("div",{css:a9,children:(0,T.Y)(a.Fd,{strokePercentage:75,color:a.Tj.Zeb_BG_Blue,fillColor:a.Tj.Zeb_Solid_Bright_Blue,borderWidth:2,size:10})}):(0,T.Y)(a.K0,{style:a9,type:"link",onClick:()=>{var t;y(t=>{var r;return[...t,null!=(r=e.orderId)?r:""]}),d(null!=(t=e.orderId)?t:e.id)},icon:"delete"})})]})]},t)},E="INR"===o.quoteAsset?sR:sB,I=[...[...l.new,...l.existing].map((e,t)=>({id:e.id,label:e.id,value:e.qty,fill:so[t]})),{id:"empty",label:"empty",value:v,fill:a.Tj.Zeb_Solid_BG_Blue}],D=(0,i.useMemo)(()=>(0,T.Y)(sa,{style:a$,data:I,height:84,width:84,interactive:!0,onMouseEnter:e=>h(e.label.toString()),onMouseLeave:()=>h("")}),[l,o.quantity]),P=(0,i.useMemo)(()=>{let e=0;return[...l.existing,...l.new].map(t=>{let r="LONG"===o.positionType?1:-1,n=t.qty*(t.price-o.entryPrice)*r;e+=n}),e},[l]),O=(0,i.useMemo)(()=>P>0?{text:a.Tj.Zeb_Solid_Green,background:a.Tj.Zeb_Transparent_Green,direction:"upwards",tag:"success"}:P<0?{text:a.Tj.Zeb_Solid_Red,background:a.Tj.Zeb_Transparent_Red,direction:"downwards",tag:"error"}:{text:a.Tj.Zeb_Solid_White,background:a.Tj.Zeb_Solid_Dark_Grey,direction:"",tag:"default"},[P]),Y=(0,T.FD)("div",{children:[(0,T.FD)("div",{css:a7,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("div",{children:"About Split TP/SL"})]}),(0,T.FD)("ul",{css:se,children:[(0,T.Y)("li",{children:"Divide Positions into multiple TP/SL Targets (Up to 5 Each)."}),(0,T.Y)("li",{children:"Customise portions of your position, for different price levels."}),(0,T.Y)("li",{children:"Provides over Risk and Profit taking."})]})]});return(0,T.FD)("div",{css:aM,children:[(0,T.Y)("div",{css:aH,children:(0,T.Y)("img",{src:ed.A.ic_arrow_popup})}),(0,T.FD)("div",{css:st,children:[(0,T.FD)("div",{css:ss,children:[(0,T.Y)("div",{css:a.Wp.mb(8),children:(0,T.FD)("div",{css:aU,children:[(0,T.FD)("div",{children:["Multiple Orders Summary(",c?"TP":"SL"," - ",f,"/5)"]}),(0,T.Y)("div",{children:(0,T.Y)(a.m_,{contentStyle:aZ,content:Y,children:(0,T.Y)(a.In,{style:aq,name:"info"})})})]})}),(0,T.Y)("div",{css:aV,children:(0,T.Y)("div",{css:aK,children:(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)("div",{css:aG,children:"Avbl. qty for split:"}),(0,T.FD)("div",{css:az,children:[((v>0?v:0)/o.quantity*100).toFixed(2),"%"]})]})})})]}),(0,T.Y)("div",{css:aX,children:D})]}),(0,T.Y)("div",{css:aQ}),(0,T.FD)("div",{css:a0,children:[l.new.length>0&&(0,T.FD)(T.FK,{children:[(0,T.FD)("div",{css:sr,children:["Draft Splits (",l.new.length,")"]}),S()]}),l.new.map((e,t)=>C(e,t)),l.existing.length>0&&(0,T.FD)(T.FK,{children:[(0,T.FD)("div",{css:[sr,l.new.length>0&&a.Wp.mt(20),"",""],children:["Active Splits (",l.existing.length,")"]}),S()]}),l.existing.map((e,t)=>C(e,t+l.new.length))]}),(0,T.FD)("div",{css:[a6,(n=O.background,(0,u.AH)(a.Wp.p(12),{backgroundColor:n,borderRadius:a.Wp.remConverter(8),marginTop:a.Wp.remConverter(16)},"","")),"",""],children:[(0,T.FD)("div",{children:[(0,T.Y)("div",{css:[a.p0.B4_14_semibold,a.Wp.pb(4),"",""],children:"Estimated Avg. P&L"}),(0,T.Y)("div",{children:(0,T.FD)(a.YD,{style:a3,isStroke:!0,type:O.tag,children:[(0,T.Y)(a.In,{name:O.direction}),(100*P/A).toFixed(2),"%"]})})]}),(0,T.FD)("div",{children:[(0,T.FD)("div",{css:a.p0.H6_16_bold,children:[ox(P,E)," ",o.quoteAsset]}),o.quoteAsset!=o.marginAsset&&(0,T.FD)("div",{css:[a.p0.B5_12_regular,a.vE.textAlignmentRight,"",""],children:["~",ox(P*(null!=(r=o.marginConversionRate)?r:1),sR)," ",o.marginAsset]})]})]})]})};function sd(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function su(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?sd(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sd(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let sp={name:"iqoq9n",styles:"margin-top:20px"},sh=(0,u.AH)({marginTop:"12px",display:"flex",gap:a.Wp.remConverter(12)},"",""),sg=(0,u.AH)({flex:"1",minWidth:a.Wp.remConverter(302)},"",""),sm=(0,u.AH)(su(su({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"","");su(su({},a.p0.B4_14_semibold),{},{backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(8),height:a.Wp.remConverter(40),width:a.Wp.remConverter(100),padding:"".concat(a.Wp.remConverter(4)," ").concat(a.Wp.remConverter(12)),display:"flex",alignItems:"center"});let sv=(0,u.AH)(su(su({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_Light_Blue,marginTop:a.Wp.remConverter(12),display:"flex"}),"",""),sA=(0,u.AH)({color:a.Tj.Zeb_Solid_Red},"",""),sb=(0,u.AH)({color:a.Tj.Zeb_Solid_Green},"",""),sy=(0,u.AH)(a.Wp.mlr(4),"",""),sf=(0,u.AH)(su(su({},a.p0.B4_14_regular),{},{width:a.Wp.remConverter(49),height:a.Wp.remConverter(40),borderRadius:a.Wp.remConverter(8),backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,color:a.Tj.Zeb_Solid_Light_Blue,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer","&:hover":{color:a.Tj.Zeb_Solid_Bright_Blue}}),"",""),s_=(0,u.AH)({flex:1,display:"flex",gap:a.Wp.remConverter(8)},"",""),sS=e=>{let{price:t,setPrice:r,label:n,errorText:i,pnl:l,quoteAsset:o,marginAsset:s,conversionRate:c,pricePrecision:d,allotedMargin:u,allContractDetails:p,contractPair:h}=e,g=e=>{let n=(()=>{if(t&&0!==parseFloat(t))return parseFloat(t);if(p&&h){var e;let t=null==(e=p[h.replace("-","")])?void 0:e.lastPrice;return t?parseFloat(t):0}return 0})();0!==n&&r(oY((n*(1+e/100)).toString(),d).toString())},m=()=>void 0===l||0===l?{}:l>0?sb:sA,v=e=>void 0===e?"0.00":sk(e);return(0,T.FD)("div",{css:sp,children:[(0,T.FD)("div",{css:sh,children:[(0,T.Y)(a.pd,{type:"number",style:sg,value:t,placeholder:"Enter price",label:n,errorText:i,onChange:e=>{e.value.length<=12&&r(oY(e.value,d).toString())},appendItem:o,onKeyDown:ok}),(0,T.FD)("div",{children:[(0,T.Y)("div",{css:sm,children:"\xa0"}),(0,T.FD)("div",{css:s_,children:[(0,T.Y)("div",{css:sf,onClick:()=>g(-1),children:"-1%"}),(0,T.Y)("div",{css:sf,onClick:()=>g(1),children:"+1%"})]})]})]}),(0,T.FD)("div",{css:sv,children:["Est. P&L ",(0,T.FD)("span",{style:{whiteSpace:"nowrap"},css:m(),children:[v(l)," ",o]}),s!==o&&(0,T.FD)("span",{style:{whiteSpace:"nowrap"},css:m(),children:[" ~ ",v((l||0)*c)," ","INR"]}),(0,T.Y)(a.In,{name:"separator",style:sy}),(0,T.FD)("span",{css:m(),children:[((null!=l?l:0)*100/(u>0?u:1)).toFixed(2),"%"]})]})]})};function sT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sC(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sT(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sT(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var sE=function(e){return e.TakeProfit="tp",e.StopLoss="sl",e}(sE||{});let sI=(0,s.Ng)(function(e){return{openOrders:e.futuresOrders.openOrders,apiStatus:e.status.tradeOrder}})(e=>{var t,r,n;let l,o,s,{position:c,openOrders:d,setSlTpSidebarOpen:p,apiStatus:h}=e,{allContractDetails:g,coinList:m,subAccountId:v,userInfo:A}=(0,i.useContext)(ds),{0:b,1:y}=(0,i.useState)(""),{0:f,1:_}=(0,i.useState)(""),{0:S,1:C}=(0,i.useState)(""),{0:E,1:I}=(0,i.useState)(""),{0:D,1:P}=(0,i.useState)(sE.TakeProfit),O=(0,i.useRef)(null),{0:Y,1:w}=(0,i.useState)(!1),{isAtTop:F,isAtBottom:R}=iD(O),{0:N,1:B}=(0,i.useState)({existing:[],new:[]}),{0:x,1:k}=(0,i.useState)({existing:[],new:[]}),{0:j,1:W}=(0,i.useState)(!1),L=[...N.existing,...N.new],M=[...x.existing,...x.new],H=D===sE.TakeProfit,U=(H?L.length:M.length)===5,q=null!=(t=null==c?void 0:c.marginConversionRate)?t:1,Z=(0,i.useMemo)(()=>{var e;return(null==g||null==(e=g[(null==c?void 0:c.contractPair)||""])?void 0:e.marketPrice)||0},[c,g]),{minOrderQuantity:V,quantityPrecision:K,pricePrecision:G,iconUrl:z}=(0,i.useMemo)(()=>{var e,t,r,n,i;let l=m.find(e=>e.pair===(null==c?void 0:c.contractPair));return{minOrderQuantity:ig(((null==l||null==(e=l.filters.find(e=>e.filterType===iP.Sx.MIN_NOTIONAL))?void 0:e.notional)||Number.MAX_SAFE_INTEGER)/(null!=(t=Number(Z))?t:1),Number(null!=(r=null==l?void 0:l.quantityPrecision)?r:sN)),quantityPrecision:Number(null!=(n=null==l?void 0:l.quantityPrecision)?n:sN),pricePrecision:Number(null!=(i=null==l?void 0:l.pricePrecision)?i:sR),iconUrl:(null==l?void 0:l.iconURL)||""}},[m,c]),X=(0,i.useMemo)(()=>{let e=D===sE.TakeProfit,t=e?S:E,r=e?b:f,n=e?N:x,i=Number(t)>0&&Number(r)>0,l=n.existing.length+n.new.length<5;return i&&l},[D,S,E,b,f,N,x]),$=(0,i.useMemo)(()=>{let e=0,t=0;return d.map(r=>{r.symbol===(null==c?void 0:c.contractPair)&&(r.subType===iP.JZ.TAKE_PROFIT&&(e+=r.orderAmount),r.subType===iP.JZ.STOP_LOSS&&(t+=r.orderAmount))}),N.new.map(t=>{e+=t.qty}),x.new.map(e=>{t+=e.qty}),{tpQty:Number((((null==c?void 0:c.quantity)||e)-e).toFixed(K)),slQty:Number((((null==c?void 0:c.quantity)||0)-t).toFixed(K))}},[c,d,N,x,K]);i.useEffect(()=>{let e=[],t=[];d.map(r=>{r.symbol===(null==c?void 0:c.contractPair)&&(r.subType===iP.JZ.TAKE_PROFIT&&e.push({price:r.price,qty:r.orderAmount,id:r.linkId,orderId:r.clientOrderId}),r.subType===iP.JZ.STOP_LOSS&&t.push({price:r.price,qty:r.orderAmount,id:r.linkId,orderId:r.clientOrderId}))}),B(t=>sC(sC({},t),{},{existing:e})),k(e=>sC(sC({},e),{},{existing:t}))},[d,c]),i.useEffect(()=>{let e=()=>{O.current&&w(O.current.scrollHeight>O.current.clientHeight)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]);let Q=()=>{let e=H?S:E,t=H?b:f,r=H?0===N.new.length:0===x.new.length;if(!e.length&&j&&(r||t.length>0))return"Quantity is required";if(e.length)if((H?L.length:M.length)===5)return"Max split ".concat(H?"target":"stoploss"," limit reached. To manage targets, consider adjusting existing splits.");else if(Number(e)<Number(V))return"Min. quantity ".concat(V," ").concat(null==c?void 0:c.contractPair.replace(null==c?void 0:c.quoteAsset,""));else if(Number(e)>(H?$.tpQty:$.slQty))return"Insufficient ".concat(null==c?void 0:c.contractPair.replace(null==c?void 0:c.quoteAsset,"")," balance. Order cannot be placed");else return""},J=(0,i.useMemo)(()=>{let e=0===N.new.length;if(!b.length&&j&&H&&(e||S.length>0))return"Price is required";if(b.length)if((null==c?void 0:c.positionType)==="LONG")return Number(b)<=1.001*Number(Z)?"Trigger price should be higher than ".concat(sk(1.001*Number(Z),G)," ").concat(null==c?void 0:c.quoteAsset):"";else return Number(b)>=.999*Number(Z)?"Trigger price should be lower than ".concat(sk(.999*Number(Z),G)," ").concat(null==c?void 0:c.quoteAsset):""},[b,Z,j,N.new.length,H,S.length]),ee=(0,i.useMemo)(()=>{let e=0===x.new.length;if(!f.length&&j&&!H&&(e||E.length>0))return"Price is required";if(f.length)if((null==c?void 0:c.positionType)==="LONG")return Number(f)<=c.liquidationPrice?"Trigger Price should be higher than Liquidation Price.":Number(f)>=.999*Number(Z)?"Trigger Price should be lower than ".concat(sk(.999*Number(Z),G)," ").concat(c.quoteAsset):"";else return Number(f)>=((null==c?void 0:c.liquidationPrice)||0)?"Trigger Price should be lower than Liquidation Price.":Number(f)<=1.001*Number(Z)?"Trigger Price should be higher than ".concat(sk(1.001*Number(Z),G)," ").concat(null==c?void 0:c.quoteAsset):""},[f,Z,j,x.new.length,H,E.length]),et=(0,i.useMemo)(()=>null!=c&&c.entryPrice&&b.length?((null==c?void 0:c.positionType)==="LONG"?1:-1)*(Number(b)-(null==c?void 0:c.entryPrice))*Number(S):0,[b,c,S]),er=(0,i.useMemo)(()=>null!=c&&c.entryPrice&&f.length?((null==c?void 0:c.positionType)==="LONG"?1:-1)*(Number(f)-(null==c?void 0:c.entryPrice))*Number(E):0,[f,c,E]),en=(0,i.useMemo)(()=>{switch(D){case sE.TakeProfit:return N.existing.length>0||N.new.length>0;case sE.StopLoss:return x.existing.length>0||x.new.length>0}},[x,N,D]),ei=(0,i.useMemo)(()=>
1{if(!(D===sE.TakeProfit?S:E).length&&!(D===sE.TakeProfit?b.length:f.length)&&(D===sE.TakeProfit?N.new.length:x.new.length))return!0;if(!(D===sE.TakeProfit?S:E).length||!(Number(D===sE.TakeProfit?S:E)>=Number(V)&&Number(D===sE.TakeProfit?S:E)<=(D===sE.TakeProfit?$.tpQty:$.slQty)))return!1;if(!b.length&&!f.length)return!1;{if(b.length&&D===sE.TakeProfit&&((null==c?void 0:c.positionType)==="LONG"&&Number(b)<=1.001*Number(Z)||(null==c?void 0:c.positionType)!=="LONG"&&Number(b)>=.999*Number(Z))||f.length&&D===sE.StopLoss&&((null==c?void 0:c.positionType)==="LONG"&&(Number(f)>=.999*Number(Z)||Number(f)<=((null==c?void 0:c.liquidationPrice)||0))||(null==c?void 0:c.positionType)!=="LONG"&&(Number(f)<=1.001*Number(Z)||Number(f)>=((null==c?void 0:c.liquidationPrice)||0))))return!1;let e=[...N.existing,...N.new],t=[...x.existing,...x.new];return(D===sE.TakeProfit?e.length:t.length)!==5}},[V,$,c,Z,b,f,D,N,x,S,E]),el=(0,i.useMemo)(()=>{if(!ei)return!1;let e=H?S:E,t=H?b:f;return Number(e)>0&&Number(t)>0},[ei,H,S,E,b,f]),eo=(0,i.useMemo)(()=>{let e=Q(),t=H?J:ee;return!!(e||t)},[Q,H,J,ee]),ea=(0,i.useMemo)(()=>{let e=H?N.new.length:x.new.length;return el?e+1:e},[H,N.new.length,x.new.length,el]),es=async()=>{let e=H?S:E,t=H?b:f,r=e.length>0&&!t.length||!e.length&&t.length>0;if(0===ea||r)return void W(!0);let n=N.new.map(e=>({quantity:e.qty,price:e.price})),i=x.new.map(e=>({quantity:e.qty,price:e.price}));if(el&&(H?n.push({quantity:Number(S),price:Number(b)}):i.push({quantity:Number(E),price:Number(f)})),c){let e={positionId:c.positionId,splitTakeProfitOrders:H?n:void 0,splitStopLossOrders:H?void 0:i};if(Object.keys(await lD(e,(null==A?void 0:A.access_token)||"",v)||{}).length){p(!1),D===sE.TakeProfit?C(""):I(""),_(""),y("");let e=H?"Take Profit split added successfully":"Stop loss split added successfully",t=H?"Take profit split target for ".concat(c.contractPair," added successfully"):"Stop loss split target for ".concat(c.contractPair," added successfully");(0,e7.A)({title:e,description:t,type:e7.C.success}),lb((null==A?void 0:A.access_token)||"",1,null,v)}else(0,e7.A)({type:e7.C.error,title:"".concat(H?"Take Profit":"Stop Loss"," Error"),description:"Error occurred while adding ".concat(H?"take profit":"stop loss"," split. Please try again.")})}},ec=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"new",t=Date.now(),r=Math.floor(1e3*Math.random());return"".concat(e,"-").concat(t,"-").concat(r)},eu=()=>D===sE.TakeProfit?$.tpQty:$.slQty,ep=e=>{D===sE.TakeProfit?C(e):I(e)};return(0,T.FD)("div",{css:ar,children:[(0,T.Y)("div",{css:(l=!F,(0,u.AH)({boxShadow:l?a.Tj.Zeb_Effects_Shadow_Hover:"",height:a.Wp.remConverter(10)},"",""))}),(0,T.FD)("div",{css:an,ref:O,children:[(0,T.FD)("div",{css:ai,children:[(0,T.FD)("div",{css:al,children:[(0,T.FD)("div",{css:ao,children:[(0,T.Y)(a.In,{name:"coins",style:ac}),"Pair (Perpetual)"]}),(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)("span",{css:(e=>(0,u.AH)({color:(null==e?void 0:e.toUpperCase())==="LONG"?a.Tj.Zeb_Solid_Green:a.Tj.Zeb_Solid_Red},"",""))(null==c?void 0:c.positionType),children:ax(null==c?void 0:c.positionType)}),(0,T.Y)(a.In,{name:"separator",style:as}),null==c?void 0:c.baseAsset,"/",null==c?void 0:c.quoteAsset,"\xa0",null==c?void 0:c.leverage,"X"]})]}),(0,T.FD)("div",{css:al,children:[(0,T.FD)("div",{css:ao,children:[(0,T.Y)(a.In,{name:"fees",style:ac}),"Entry Price"]}),(0,T.FD)("div",{css:aa,children:[ox((null==c?void 0:c.entryPrice)||"",G)," ",null==c?void 0:c.quoteAsset]})]}),(0,T.FD)("div",{css:al,children:[(0,T.FD)("div",{css:ao,children:[(0,T.Y)(a.In,{name:"income-source",style:ac}),"Mark Price"]}),(0,T.FD)("div",{css:aa,children:[ox(Z||"",G)," ",null==c?void 0:c.quoteAsset]})]}),(0,T.FD)("div",{css:al,children:[(0,T.FD)("div",{css:ao,children:[(0,T.Y)(a.In,{name:"liquidation-cost",style:ac}),"Liquidation Price"]}),(0,T.Y)("div",{css:aa,children:Number(null==c?void 0:c.liquidationPrice)>=0?"".concat(ox((null==c?void 0:c.liquidationPrice)||"",G)," ").concat(null==c?void 0:c.quoteAsset):(0,T.Y)(a.In,{name:sx(0),style:lq})})]}),(0,T.FD)("div",{css:al,children:[(0,T.FD)("div",{css:ao,children:[(0,T.Y)(a.In,{name:"buy-crypto",style:ac}),"Position Quantity"]}),(0,T.FD)("div",{css:aa,children:[ox((null==c?void 0:c.quantity)||"",K)," ",null==c?void 0:c.contractPair.replace(null==c?void 0:c.quoteAsset,"")]})]})]}),(0,T.Y)(a.tU,{selectedTab:D,style:av,type:"primary",onChange:e=>{P(e),W(!1)},tabsList:[{tab:sE.TakeProfit,title:"Take Profit"},{tab:sE.StopLoss,title:"Stop Loss"}]}),(0,T.FD)("div",{css:aA,children:[(0,T.FD)("div",{style:{position:"relative"},children:[(0,T.Y)(a.pd,{style:a.Wp.mt(20),label:"Quantity",value:D===sE.TakeProfit?S:E,type:"number",errorText:Q(),placeholder:"Enter quantity",onChange:e=>{let{value:t}=e;j&&W(!1),t.length<=12&&ep(oY(t,K).toString())},appendItem:(0,T.FD)("div",{css:au,children:[(0,T.Y)(a.In,{style:am,name:"separator"}),(0,T.Y)("img",{height:24,width:24,src:(null==c?void 0:c.iconUrl)||z}),(0,T.Y)("div",{children:null==c?void 0:c.contractPair.replace(null==c?void 0:c.quoteAsset,"")})]}),onKeyDown:ok}),(0,T.FD)("div",{css:ap,children:[(0,T.Y)("div",{css:a.Wp.mr(4),children:"Avbl position qty"}),(0,T.Y)("div",{css:ag,children:eu()>0?eu().toFixed(K):0..toFixed(K)}),(0,T.Y)("div",{css:a.Wp.mr(8),children:null==c?void 0:c.contractPair.replace(null==c?void 0:c.quoteAsset,"")}),(0,T.Y)("div",{css:ah,onClick:()=>{let e=eu();ep(String((e>0?e:0).toFixed(K)))},children:"ADD MAX"})]})]}),(0,T.Y)(sS,{price:D===sE.TakeProfit?b:f,setPrice:e=>{j&&W(!1),D===sE.TakeProfit?y(e):_(e)},label:D===sE.TakeProfit?"Take Profit":"Stop Loss",errorText:D===sE.TakeProfit?J:ee,pnl:D===sE.TakeProfit?et:er,quoteAsset:null==c?void 0:c.quoteAsset,marginAsset:null==c?void 0:c.marginAsset,conversionRate:q,pricePrecision:G,allotedMargin:Number(D===sE.TakeProfit?S:E)*(null!=(r=null==c?void 0:c.margin)?r:0)/(null!=(n=null==c?void 0:c.quantity)?n:1),allContractDetails:g,contractPair:(null==c?void 0:c.contractPair)||""}
1),(0,T.Y)("div",{css:(o=ei&&X,(0,u.AH)(at(at({},a.p0.C3_14),{},{marginTop:a.Wp.remConverter(20),cursor:"pointer",color:o?a.Tj.Zeb_Solid_Bright_Blue:a.Tj.Zeb_Solid_Light_Blue}),"","")),onClick:()=>{if(ei&&X)switch(D){case sE.TakeProfit:{let e={price:Number(b),qty:Number(S),id:ec()},t=[...N.new,e];N.existing.length+N.new.length<5&&(B(e=>sC(sC({},e),{},{new:t})),y(""),C(""));break}case sE.StopLoss:{let e={price:Number(f),qty:Number(E),id:ec()},t=[...x.new,e];x.existing.length+x.new.length<5&&(k(e=>sC(sC({},e),{},{new:t})),_(""),I(""))}}},children:H?"+ ADD MULTIPLE TP ORDERS":"+ ADD MULTIPLE SL ORDERS"}),U&&(0,T.FD)("div",{css:ay,children:[(0,T.Y)("img",{css:ab,src:ed.A.i_error_red}),"Limit reached: Delete an existing split to add a new split."]}),(0,T.Y)(a.y8,{style:ad,title:"Note",type:"info",description:"This setting will be applicable to the selected position only. Take Profit and Stop loss orders will be cancelled automatically if this position is closed."})]})]}),(0,T.Y)("div",{css:(s=Y||!R,(0,u.AH)({padding:"20px 32px",boxShadow:s?a.Tj.Zeb_Effects_Shadow_M_Drawer:""},"","")),children:(0,T.FD)(a.$n,{type:"primary",disabled:eo,loading:h===ld.VI.REQUEST,onClick:es,size:"full-width",children:["PLACE"," ",D===sE.TakeProfit?"".concat(N.new.length>0?"".concat(ea," "):"","TP"):"".concat(x.new.length>0?"".concat(ea," "):"","SL")," ",ea>1?"ORDERS":"ORDER"]})}),en&&c&&(0,T.Y)(sc,{coinList:m,position:c,list:D===sE.TakeProfit?N:x,handleRemove:e=>{if(e.includes("new-"))switch(D){case sE.TakeProfit:B(t=>sC(sC({},t),{},{new:t.new.filter(t=>t.id!==e)}));break;case sE.StopLoss:k(t=>sC(sC({},t),{},{new:t.new.filter(t=>t.id!==e)}))}else lf({clientOrderId:e},(null==A?void 0:A.access_token)||"",v).then(()=>{(0,e7.A)({title:"Split Deleted Successfully",description:"The split was removed successfully",type:e7.C.success}),lb((null==A?void 0:A.access_token)||"",1,null,v)}).catch(()=>{(0,e7.A)({title:"Split Deletion Error",description:"Error occurred while deleting take profit split. Please try again.",type:e7.C.error}),lb((null==A?void 0:A.access_token)||"",1,null,v)})},isTp:D===sE.TakeProfit})]})});function sD(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sP(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sD(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sD(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let sO=()=>(0,T.FD)("div",{css:[(0,p.wh)(12),{width:a.Wp.remConverter(400)},"",""],children:[(0,T.FD)("div",{css:(0,p.wh)(8),children:[(0,T.FD)("div",{css:(0,p.sM)(8),children:[(0,T.Y)(a.In,{name:"info",style:(0,p.Kk)()}),(0,T.Y)("span",{css:[a.p0.B4_14_semibold,"",""],children:"Margin Auto Top-up"})]}),(0,T.Y)("div",{css:oS,children:"When your margin ratio goes above 70%, a top-up is triggered automatically to prevent liquidation. Auto Top-up stops if wallet funds are insufficient."})]}),(0,T.FD)("div",{css:sY,children:[(0,T.FD)("div",{css:sw,children:["Leverage",(0,T.Y)("span",{children:"Margin Added"})]}),(0,T.FD)("div",{css:[sF,{borderBottom:"1px solid ".concat(a.Tj.Zeb_Solid_BG_Blue)},"",""],children:["1–20x",(0,T.Y)("span",{children:"1.5x Maintenance"})]}),(0,T.FD)("div",{css:[sF,{border:(0,p.qb)([0,0,8,8])},"",""],children:["21-75x",(0,T.Y)("span",{children:"2x Maintenance"})]})]}),(0,T.FD)("div",{css:[a.vE.flexAlignStart,a.vE.flexAlignCenter,a.Wp.g(4),"",""],children:[(0,T.FD)("span",{css:a.p0.B4_14_regular,children:["View more details about margin"," "]}),(0,T.Y)("a",{href:"https://www.zebpay.com/futures/margin-auto-topup",target:"_blank",children:(0,T.Y)(a.$n,{style:(0,u.AH)(sP(sP({},a.p0.C4_12),{},{color:a.Tj.Zeb_Solid_Bright_Blue}),"",""),type:"link",onClick:ek.A,children:"Learn more"})})]})]}),sY=(0,u.AH)([a.Wp.br(8),{border:"1px solid ".concat(a.Tj.Zeb_Solid_BG_Blue)}],"",""),sw=(0,u.AH)([a.vE.flexJustifiedBetween,a.p0.B5_12_regular,a.vE.textFaded,{padding:(0,p.qb)([12,16]),borderRadius:(0,p.qb)([8,8,0,0]),background:a.Tj.Zeb_Solid_BG_Blue}],"",""),sF=(0,u.AH)([a.vE.flexJustifiedBetween,a.p0.B4_14_regular,{padding:(0,p.qb)([8,16])}],"",""),sR=2,sN=3,sB=4,sx=e=>e>0?"positive":e<0?"negative":"subtract",sk=(e,t)=>e&&""!==e&&0!==e?0===t?ox(e,0):ox(e,t||sR):0..toFixed(t||sR);var sj={name:"1v771ry",styles:"z-index:3"},sW={name:"1v771ry",styles:"z-index:3"},sL={name:"yv4y9p",styles:"right:100px"},sM={name:"q79vxo",styles:"right:20px"};let sH=(0,s.Ng)(function(e){return{positions:e.futuresOrders.positions,openOrders:e.futuresOrders.openOrders,apiStatus:e.status.positions,tradeStatus:e.status.tradeOrder,closeAllApiStatus:e.status.closeAllApi,userSocket:e.futuresOrders.userSocket,selectedTableMarginTab:e.futuresOrders.selectedTableMargin.position}})(e=>{var t,r,n,o,c,d,h;let{positions:g,apiStatus:m,tradeStatus:v,closeAllApiStatus:A,userSocket:b,selectedTableMarginTab:y,openOrders:f}
1=e,{userInfo:_,walletData:S,allContractDetails:C,coinList:E,currencyList:I,conversionRate:D,subAccountId:P}=(0,i.useContext)(ds),O=(0,s.wA)(),{0:Y,1:w}=(0,i.useState)([]),{0:F,1:R}=(0,i.useState)({idx:-1,type:""}),{0:N,1:B}=(0,i.useState)(!1),{0:x,1:k}=(0,i.useState)(!1),{0:j,1:W}=(0,i.useState)(0),{0:L,1:M}=(0,i.useState)(""),{0:H,1:U}=(0,i.useState)(!1),{0:q,1:Z}=(0,i.useState)(),{0:V,1:K}=(0,i.useState)(!1),{0:G,1:z}=(0,i.useState)();(0,l.useRouter)(),(0,i.useEffect)(()=>{(async()=>{await lA((null==_?void 0:_.access_token)||"",P)})()},[P,null==_?void 0:_.access_token]),(0,i.useEffect)(()=>{w(g.filter(e=>y===iP.Tr.All||y===e.marginAsset))},[g,y]),(0,i.useEffect)(()=>{if(G){let e=g.find(e=>e.positionId===G.positionId);(null==e?void 0:e.quantity)!==G.quantity&&z(e)}},[g,G]);let X=()=>{O({type:lc.X.SET_SOCKET,payload:!b})},$=[{dataField:oD.Pair,component:(0,T.Y)("span",{css:a.Wp.ml(16),children:"Pair"}),width:150},{dataField:oD.MarginType,component:"Margin Type",width:100},{dataField:oD.Quantity,component:"Quantity",width:Y.length?140:80},{dataField:oD.Size,component:"Size",width:Y.length?130:50},{dataField:oD.Entry_Price,component:(0,T.FD)("div",{css:l8,children:[(0,T.Y)("span",{children:"Entry Price"}),(0,T.Y)("span",{children:(0,T.Y)(a.m_,{position:"left-end",content:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:l6,children:[(0,T.Y)(a.In,{name:"info"})," Entry Price"]}),(0,T.Y)("div",{css:l3,children:"The price when your position is opened."})]}),contentStyle:l9,children:(0,T.Y)(a.In,{style:l5,name:"info"})})})]}),width:Y.length?130:100},{dataField:oD.Mark_Price,component:(0,T.FD)("div",{css:l8,children:[(0,T.Y)("span",{children:"Mark Price"}),(0,T.Y)("span",{children:(0,T.Y)(a.m_,{position:"left-end",content:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:l6,children:[(0,T.Y)(a.In,{name:"info"})," Mark Price"]}),(0,T.Y)("div",{css:l3,children:"The current trading price of the asset."})]}),contentStyle:l9,children:(0,T.Y)(a.In,{style:l5,name:"info"})})})]}),width:Y.length?130:100},{dataField:oD.Liq_Price,component:(0,T.FD)("div",{css:l8,children:[(0,T.Y)("span",{children:"Liq Price"}),(0,T.Y)("span",{children:(0,T.Y)(a.m_,{position:"left-end",content:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:l6,children:[(0,T.Y)(a.In,{name:"info"})," Liquidation Price"]}),(0,T.Y)("div",{css:l3,children:"The price at which your position will be liquidated."})]}),contentStyle:l9,children:(0,T.Y)(a.In,{style:l5,name:"info"})})})]}),width:Y.length?130:100},{dataField:oD.Unrealised_PnL,component:"Unrealised P&L",width:180},{dataField:oD.Realised_PnL,component:"Realised P&L",width:120},{dataField:oD.Margin_Ratio,component:(0,T.FD)("div",{css:l8,children:[(0,T.Y)("span",{children:"Margin Ratio"}),(0,T.Y)("span",{children:(0,T.Y)(a.m_,{position:"left-end",content:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:l6,children:[(0,T.Y)(a.In,{name:"info"})," Margin Ratio"]}),(0,T.Y)("div",{css:l3,children:"Ratio indicating how close you are to liquidation."})]}),contentStyle:l7,children:(0,T.Y)(a.In,{style:l5,name:"info"})})})]}),width:120},{dataField:oD.Close_Position,component:"Close Position",width:150,isSticky:!0},{dataField:oD.TP_SL,component:"TP/SL",width:80,isSticky:!0},{dataField:oD.Margin,component:"Margin",width:120,isSticky:!0},{dataField:oD.MarginTopUp,component:(0,T.FD)("div",{css:(0,p.sM)(4),children:["Auto Top-up",(0,T.Y)(oZ,{visible:x,setVisible:k,content:(0,T.Y)(sO,{}),position:"left",children:(0,T.Y)(a.In,{name:"info",style:oC})})]}),width:150,isSticky:!0}],Q=async(e,t,r)=>{let n={formType:"POSITION",quantity:Number(L),side:"LONG"===e.positionType?"SELL":"BUY",positionId:e.positionId,pair:"".concat(t).concat(r),orderType:"LIMIT",leverage:e.leverage,price:j,marginAsset:e.marginAsset};Object.keys(await lR(n,(null==_?void 0:_.access_token)||"",P)||{}).length&&(R({idx:-1,type:""}),(0,eh.A)({title:"Order Submitted",description:"Limit order placed for closing the position.",type:e7.C.success}),lb((null==_?void 0:_.access_token)||"",1,null,P))},J=async(e,t)=>{let r=await lC(e,t.positionId,(null==_?void 0:_.access_token)||"",P);(null==r?void 0:r.statusCode)==200&&(O({type:lc.X.UPDATE_POSITION,payload:{positionId:t.positionId,updates:{autoTopUpEnabled:e}}}),e?(0,eh.A)({title:"Auto top-up enabled",description:"Margin will be added to ".concat(t.baseAsset,"-").concat(t.quoteAsset," position if the Margin Ratio hits 70%."),type:"success"}):(0,eh.A)({title:"Auto top-up disabled",description:"Margin for ".concat(t.baseAsset,"-").concat(t.quoteAsset," will no longer be added automatically."),type:"info"}))},ee=Y.length?Y.map((e,t)=>{var r,n,i,l,o,s,c,d,p,h,g,m,b,y,S,D;let O=null==e?void 0:e.baseAsset,Y=null==e?void 0:e.quoteAsset,w=E.find(e=>e.pair==="".concat(O).concat(Y)),N=null!=(r=Number(null==w?void 0:w.pricePrecision))?r:sR,x=null!=(n=Number(null==w?void 0:w.quantityPrecision))?n:sN,k=C?Number(null==(i=C[e.contractPair])?void 0:i.marketPrice):0,H=e.margin;null==e||e.entryPrice,null==e||e.quantity;let q=0===((null==e||null==(l=e.positionType)?void 0:l.length)||0)||0===k,V=e.leverage>=(null!=(o=null==w||null==(s=w.maintenanceMarginConfig)||null==(s=s[0])?void 0:s.rangeStart)?o:0)&&e.leverage<=(null!=(c=null==w||null==(d=w.maintenanceMarginConfig)||null==(d=d[0])?void 0:d.rangeEnd)?c:0),G=Number(null==(p=E.find(e=>e.pair==="".concat(O).concat(Y)))?void 0:p.maintenanceMarginPercentage),$=null!=(h=null==w||null==(g=w.maintenanceMarginConfig)||null==(g=g[0])?void 0:g.percentageValue)?h:G,ee=Number(null==(m=E.find(e=>e.pair==="".concat(O).concat(Y)))?void 0:m.marginBufferPercentage);null==e||e.positionType;let et=Math.abs(Math.abs(e.positionSize/e.leverage)*(1+.01*ee)*(V?$:G)/100),er="LONG"===e.positionType?k*e.quantity-e.positionSize:e.positionSize-k*e.quantity,en=Math.min(100,er<0?(et-er)/H*100:et/(er+H)*100),ei=O+"-"+Y,el=e.quoteAsset===im?(null==e?void 0:e.marginAsset)==iP.bC.INR?iv:iA:"INR",eo=e.quoteAsset===im?(null==e?void 0:e.marginAsset)==iP.bC.INR?"warning":"info":"default",ea=f.some(t=>t.symbol===e.contractPair&&(t.subType===iP.JZ.TAKE_PROFIT||t.subType===iP.JZ.STOP_LOSS));return{__positionId:e.positionId,[oD.Pair]:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.ml(16),{gap:a.Wp.remConverter(8)},"",""],children:[(0,T.Y)("img",{src:e.iconUrl||(null==w?void 0:w.iconURL),height:20,width:20}),(0,T.FD)("div",{css:oT,children:[(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.g(4),"",""],children:[(0,T.Y)(a.m_,{position:"bottom",contentStyle:on(ei.length>10),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Coin Pair"})]}),(0,T.Y)("div",{css:or,children:ei})]}),children:(0,T.Y)("span",{css:[a.p0.B5_12_semibold,"",""],children:ei.length>10?ei.slice(0,10)+"...":ei})}),e.quoteAsset!==e.marginAsset&&(0,T.Y)(a.m_,{position:"right",contentStyle:om,content:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:oy,children:[(0,T.Y)(a.In,{name:"info"})," Conversion Rate"]}),(0,T.FD)("div",{css:of,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)("img",{src:null==(b=I.find(e=>e.code===im))?void 0:b.iconLightTheme})," ","1 USDT"]}
1),(0,T.FD)("div",{css:a.p0.B4_14_regular,children:["~"," ",null==(y=e.marginConversionRate)?void 0:y.toFixed(sR)," ","INR"]})]}),(0,T.Y)("div",{style:{marginTop:"1.25rem"},children:(0,T.FD)("div",{css:ov,children:[(0,T.FD)("div",{css:oA,children:[(0,T.Y)(a.In,{name:"info"}),"How Conversion Works"]}),(0,T.Y)("div",{children:(0,T.FD)("ul",{children:[(0,T.Y)("li",{css:ob,children:"Your INR will be automatically converted to USDT when using INR margins."}),(0,T.Y)("li",{css:ob,children:"Fees and TDS are not applicable for these conversions."}),(0,T.Y)("li",{css:ob,children:"USDT-INR Conversion rate is fixed for the opening and closing of this position. Your position will not be exposed to the fluctuations of the USDT-INR exchange rate."})]})})]})})]}),children:(0,T.Y)(a.In,{style:l5,name:"info"})})]}),(0,T.FD)("div",{css:lk,children:[(0,T.FD)("span",{css:lj,children:[e.leverage,"x"]}),(0,T.Y)(a.In,{name:"separator",style:lW}),(0,T.Y)("span",{css:lL(e.positionType),children:ax(e.positionType)})]})]})]}),[oD.MarginType]:(0,T.FD)(a.YD,{type:eo,children:[(0,T.Y)(a.In,{name:e.marginAsset===iP.bC.INR?"inr-m":"usdt-m"}),(0,T.Y)("span",{style:{marginLeft:"4px"},children:el})]}),[oD.Size]:(0,T.Y)(iR,{title:(0,T.FD)("span",{children:[sk(e.positionSize,"INR"===e.quoteAsset?sR:sB),"\xa0",(0,T.Y)("span",{css:oe,children:null==e?void 0:e.quoteAsset})]})}),[oD.Quantity]:(0,T.Y)(a.m_,{contentStyle:on(O.length>5),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Quantity"})]}),(0,T.FD)("div",{css:or,children:[ox(e.quantity,x)," ",O]})]}),children:(0,T.Y)(iR,{title:ox(e.quantity,x),subtitle:O.length>5?O.slice(0,4)+"...":O})}),[oD.Entry_Price]:(0,T.Y)(iR,{title:(0,T.FD)("span",{children:[sk(e.entryPrice,N),"\xa0",(0,T.Y)("span",{css:oe,children:null==e?void 0:e.quoteAsset})]})}),[oD.Mark_Price]:(0,T.Y)(iR,{title:(0,T.FD)("span",{children:[sk(k,N),"\xa0",(0,T.Y)("span",{css:oe,children:null==e?void 0:e.quoteAsset})]})}),[oD.Liq_Price]:(0,T.Y)(iR,{title:e.liquidationPrice>=0?(0,T.FD)("span",{children:[sk(e.liquidationPrice,N),"\xa0",(0,T.Y)("span",{css:oe,children:null==e?void 0:e.quoteAsset})]}):(0,T.Y)(a.In,{name:sx(0),style:lq})}),[oD.Margin_Ratio]:(0,T.Y)("div",{css:lH(en),children:(0,T.FD)(tx.A,{height:20,width:50,isLoading:q,children:[sk(en),"%"]})}),[oD.Unrealised_PnL]:(0,T.FD)("div",{css:[a.p0.B5_12_semibold,lM(er),a.vE.flexColumn,{gap:a.Wp.remConverter(4)},"",""],children:[(0,T.Y)(tx.A,{height:15,width:50,isLoading:q,children:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.g(4),"",""],children:[(0,T.FD)("span",{children:[sk(Math.abs(er),"INR"===e.quoteAsset?sR:sB)," ",e.quoteAsset]}),(0,T.FD)("span",{css:[a.p0.B6_10_regular,lM(er),"",""],children:["(",sk(100*er/e.margin),"%)"]})]})}),Y!==e.marginAsset&&(0,T.Y)(tx.A,{height:15,width:50,isLoading:q,children:(0,T.FD)("div",{css:oh,children:["~"," ",(0,T.Y)("span",{css:og,children:sk(Math.abs(er)*(null!=(S=null==e?void 0:e.marginConversionRate)?S:1))}),"INR"]})})]}),[oD.Realised_PnL]:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:lU(e.realizedProfit),children:[(0,T.Y)(a.In,{name:sx(e.realizedProfit),style:lq}),sk(Math.abs(e.realizedProfit),"INR"===e.quoteAsset?sR:sB)," ",e.quoteAsset]}),Y!==e.marginAsset&&(0,T.Y)(tx.A,{height:15,width:50,isLoading:q,children:(0,T.FD)("div",{css:oh,children:["~"," ",(0,T.Y)("span",{css:og,children:sk(Math.abs(e.realizedProfit)*(null!=(D=null==e?void 0:e.marginConversionRate)?D:1))}),"INR"]})})]}),[oD.Close_Position]:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,{gap:a.Wp.remConverter(4)},"",""],children:[(0,T.Y)(oZ,{position:"left-start",visible:F.idx==t&&"MARKET"==F.type,setVisible:B,style:sM,onClose:()=>R({idx:-1,type:""}),content:(0,T.FD)("div",{css:l2,children:[(0,T.FD)("div",{css:l4,children:["Close ",O,"/",Y," Position"]}),(0,T.Y)(a.pd,{label:"",placeholder:"0",value:L,type:"number",onChange:e=>{let{value:t}=e;t.length<=12&&M(String(oY(t,x)))},prependItem:(0,T.Y)("p",{css:oI,children:"Quantity"}),appendItem:(0,T.Y)("p",{css:oI,children:O}),style:oE,onKeyDown:ok}),(0,T.Y)(a.$n,{type:"primary",size:"small",width:220,loading:v===ld.VI.REQUEST,disabled:!(Number(L)>0),onClick:async()=>{let t={formType:"POSITION",quantity:Number(L),positionId:e.positionId,side:"LONG"===e.positionType?"SELL":"BUY",pair:"".concat(O).concat(Y),orderType:"MARKET",leverage:e.leverage,marginAsset:e.marginAsset};Object.keys(await lR(t,(null==_?void 0:_.access_token)||"",P)||{}).length&&(R({idx:-1,type:""}),(0,eh.A)({title:"Order Submitted",description:"Market order placed for closing the position.",type:e7.C.success}))},children:"PLACE market order"})]}),children:(0,T.Y)(a.$n,{type:"link",size:"small",disabled:A===ld.VI.REQUEST,style:(0,u.AH)({color:A===ld.VI.REQUEST?"".concat(a.Tj.Zeb_Solid_Grey," !important"):""},"",""),onClick:()=>{X(),R({idx:t,type:"MARKET"}),M(String(e.quantity))},children:"Market"})}),(0,T.Y)(a.In,{name:"separator",style:(0,u.AH)({fontSize:a.Wp.remConverter(12)},"","")}),(0,T.Y)(oZ,{position:"left-start",visible:F.idx==t&&"LIMIT"==F.type,setVisible:B,style:sL,onClose:()=>R({idx:-1,type:""}),content:(0,T.FD)("div",{css:l2,children:[(0,T.FD)("div",{css:l4,children:["Close ",O,"/",Y," Position"]}),(0,T.Y)(a.pd,{label:"",name:"price",value:j,placeholder:"0",prependItem:(0,T.Y)("div",{css:oI,children:"Price"}),appendItem:(0,T.Y)("p",{css:oI,children:Y}),onChange:e=>{let{value:t}=e;t.length<=12&&W(Number(oY(t,N)))},type:"number",style:oE,onKeyDown:ok}),(0,T.Y)(a.pd,{label:"",placeholder:"0",value:L,type:"number",onChange:e=>{let{value:t}=e;t.length<=12&&M(String(oY(t,x)))},prependItem:(0,T.Y)("p",{css:oI,children:"Quantity"}),appendItem:(0,T.FD)("p",{css:oI,children:[O," "]}),style:oE,onKeyDown:ok}),(0,T.Y)(a.$n,{type:"primary",size:"small",width:220,loading:v===ld.VI.REQUEST,disabled:!(Number(L)>0)||!j,onClick:()=>{Q(e,O,Y)},children:"PLACE limit order"})]}),children:(0,T.Y)(a.$n,{type:"link",disabled:A===ld.VI.REQUEST,style:(0,u.AH)({color:A===ld.VI.REQUEST?"".concat(a.Tj.Zeb_Solid_Grey," !important"):""},"",""),onClick:()=>{X(),B(!0),R({idx:t,type:"LIMIT"}),W(k),M(String(e.quantity))},size:"small",children:"Limit"})})]}),[oD.TP_SL]:(0,T.Y)(a.$n,{type:"link",disabled:A===ld.VI.REQUEST,style:(0,u.AH)({color:A===ld.VI.REQUEST?"".concat(a.Tj.Zeb_Solid_Grey," !important"):""},"",""),onClick:()=>{X(),K(!0),z(e),lb((null==_?void 0:_.access_token)||"",1,null,P)},size:"small",children:ea?"EDIT":"ADD"}),[oD.Margin]:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:[a.p0.B5_12_semibold,"",""],children:[sk(e.margin,"INR"===e.quoteAsset?sR:sB)," ",(0,T.Y)("span",{css:oc,children:e.quoteAsset})]}),e.quoteAsset!==e.marginAsset&&(0,T.FD)("div",{css:oa,children:["~"," ",sk(e.margin*((null==e?void 0:e.marginConversionRate)||0),sR)," ",(0,T.Y)("span",{css:os,children:"INR"})]})]}),[oD.MarginTopUp]:(0,T.FD)("div",{css:lX,children:[(0,T.Y)("div",{css:a.Wp.pl(20),children:(0,T.Y)(a.dO,{id:e.positionId,isSelected:e.autoTopUpEnabled,onChange:t=>J(t,e)})}),(0,T.Y)("button",{onClick:()=>{X(),U(!0),Z(e)},css:lZ,children:(0,T.Y)(a.In,{name:"edit",style:lz})})]})}}):[],et=[...Array(10)].map(()=>({[oD.Pair]:(0,T.Y)(a.WA,{height:18,width:100,style:a.Wp.ml(16)}),[oD.MarginType]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Size]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Quantity]:(0,T.Y)(a.WA,{height:18,width:120}),[oD.Entry_Price]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Mark_Price]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Liq_Price]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Margin_Ratio]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Unrealised_PnL]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Realised_PnL]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Close_Position]:(0,T.Y)(a.WA,{height:18,width:120}),[oD.TP_SL]:(0,T.Y)(a.WA,{height:18,width:60}),[oD.Margin]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.MarginTopUp]:(0,T.Y)(a.WA,{height:18,width:80})}));return(0,T.FD)(T.FK,{children:[(0,T.Y)(iw,{headers:$,isStickyTable:!0,rows:m===ld.VI.REQUEST?et:ee,noResultScreen:(0,T.Y)(ls,{tabType:ia.Positions,isFilterApplied:!1,onClick:ek.A}),style:(0,u.AH)({width:Y.length?"fit-content":"auto","@media (min-width: 1750px)":{width:"auto"}},"",""),styleData:(0,u.AH)({padding:"".concat(a.Wp.remConverter(m===ld.VI.REQUEST?15:4)," ").concat(a.Wp.remConverter(2))},"","")}),(0,T.Y)(a.wv,{open:H,title:"Adjust Margin",onClose:()=>U(!1),overlayStyle:sW,children:(0,T.Y)(o7,{maxAddableMargin:Number(((null==q?void 0:q.quoteAsset)==="INR"?null==(t=S.balance)?void 0:t.availableBalance:(null==q?void 0:q.marginAsset)==iP.bC.INR?Number((null==(r=S.balance)?void 0:r.availableBalance)||"0")/(null!=(n=null==q?void 0:q.marginConversionRate)?n:1):Number((null==(o=S.balanceUsdt)?void 0:o.availableBalance)||"0"))||0),maxRemovableMargin:q?((e,t,r,n)=>{if(!e)return 0;let i=Number(t)/100,l=e.entryPrice*e.quantity*(1+i)/e.leverage,o=Number(r)*e.quantity,a="LONG"===e.positionType?o-e.positionSize:e.positionSize-o;if(a>=0){if(e.margin>l)return parseFloat((e.margin-l).toFixed(e.quoteAsset===im?4:2))}else{let t=Math.abs(a)*(1+n);if(e.margin>l+t)return parseFloat(((e.margin-t-l)*.98).toFixed(e.quoteAsset===im?4:2))}return 0})(q,(null==(c=E.find(e=>e.pair===(null==q?void 0:q.contractPair)))?void 0:c.marginBufferPercentage)||"",(e=>{if(C){var t;return null==(t=C[e.replace("-","")])?void 0:t.marketPrice}return"-"})((null==q?void 0:q.contractPair)||""),(null==(d=E.find(e=>e.pair===(null==q?void 0:q.contractPair)))?void 0:d.reduceMarginAllowedRatioPercent)||0):0,position:q,currentAssignedMargin:null!=(h=null==q?void 0:q.margin)?h:0,setMarginSidebarOpen:U,onClose:()=>U(!1)},H.toString())}),(0,T.Y)(a.wv,{open:V,title:"TP/SL for Entire Position",onClose:()=>K(!1),overlayStyle:sj,children:V&&(0,T.Y)(sI,{position:G,setSlTpSidebarOpen:K},V.toString())})]})}),sU=e=>{let{value:t,currency:r,allowConversion:n=!0,conversionRate:i,decimalPlace:l,displayInline:o=!1,valueStyle:s,currencyStyle:c,toDecimalPlace:
1d=2,toCurrency:u="INR",toValueStyle:h,toCurrencyStyle:g,align:m,style:v,truncationLength:A=25}=e,b=null!=c?c:s,y=null!=g?g:h,f=sk(t,l).length>A,_=sk(t*i,d).length>A;return(0,T.FD)("div",{css:[o?(0,p.sM)(4):[(0,p.wh)(0),{alignItems:m}],v,"",""],children:[(0,T.FD)("div",{css:[(0,p.sM)(4),s,"",""],children:[f?(0,T.Y)(a.m_,{content:sk(t,l),position:"top",children:(0,T.FD)("span",{children:[" ",sk(t,l).slice(0,A)+"..."]})}):(0,T.Y)("span",{children:sk(t,l)}),(0,T.Y)("span",{css:b,children:r})]}),n?(0,T.FD)("div",{css:[(0,p.sM)(4),h,"",""],children:[(0,T.FD)("div",{css:(0,p.sM)(4),children:["~"," ",_?(0,T.Y)(a.m_,{content:sk(t*i,d),position:"top",children:(0,T.Y)("span",{children:sk(t*i,d).slice(0,A)+"..."})}):sk(t*i,d)]}),(0,T.Y)("span",{css:y,children:u})]}):null]})};var sq=r(76427);let sZ=e=>{let{icon:t,title:r,text:n,subText:i,color:l}=e;return(0,T.FD)("div",{css:aN,children:[(0,T.Y)(a.L5,{icon:t,size:34}),(0,T.FD)("div",{css:a.vE.flexColumn,children:[(0,T.Y)("span",{css:aE,children:r}),(0,T.FD)("div",{css:aB,children:[(0,T.Y)("span",{css:(0,u.AH)({color:l||a.Tj.Zeb_Solid_White},"",""),children:n}),(0,T.Y)("span",{css:(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),children:i})]})]})]})},sV=e=>{let{orderName:t,orderName2:r,data:n}=e,i=n.baseAsset,l=n.quoteAsset;return(0,T.Y)("div",{css:a.vE.flexAlignCenter,children:(0,T.FD)("div",{css:aF,children:[(0,T.FD)("div",{css:a.vE.flexColumn,children:[(0,T.FD)("header",{css:[a.p0.B4_14_regular,"",""],children:["Order ",t]}),r&&(0,T.FD)("p",{css:aE,children:["If order ",t," is filled fully, order ",r," will be cancelled"]})]}),(0,T.Y)(a.cG,{spacing:0}),(0,T.FD)("div",{css:aR,children:[(0,T.Y)(sZ,{icon:"templates",title:"Stop Market ".concat("TAKE_PROFIT"===n.subType?"Take Profit":"Stop Loss"),text:ax(n.status)}),(0,T.Y)(sZ,{icon:"side-2",title:"Side",text:ax(n.side),color:"SELL"===n.side?a.Tj.Zeb_Solid_Red:a.Tj.Zeb_Solid_Green}),(0,T.Y)(sZ,{icon:"coins",title:"Quantity",text:n.orderAmount,subText:i}),(0,T.Y)(sZ,{icon:"term",title:"Stop Price",text:n.price,subText:l})]})]})})},sK=(0,s.Ng)(function(e){return{linkedOrderApiStatus:e.status.linkedOrder}})(e=>{let{linkId:t,linkedOrderApiStatus:r}=e,{subAccountId:n,userInfo:l}=(0,i.useContext)(ds),{0:o,1:s}=(0,i.useState)([]);(0,i.useEffect)(()=>{t&&(async()=>{s(await ly(t,(null==l?void 0:l.access_token)||"",n)||[])})()},[n,t,null==l?void 0:l.access_token]);let c=o.find(e=>"PRIMARY"===e.subType),d=o.find(e=>"TAKE_PROFIT"===e.subType),u=o.find(e=>"STOP_LOSS"===e.subType);return(0,T.FD)("div",{css:[a.vE.flexColumn,a.Wp.heightPercentage(100),"",""],children:[(0,T.Y)("header",{css:aS,children:(()=>{if(null!=o&&o.length)switch(o[0].linkType){case"ORDER_TP":return"Take Profit";case"ORDER_SL":return"Stop Loss";default:return"TP/SL for Entire Position"}return""})()}),"success"===r&&(0,T.FD)("main",{css:aT,children:[c&&(0,T.Y)(aj,{data:c,bothTPSL:!!(d&&u)}),c&&(d||u)&&(0,T.Y)("div",{css:a.vE.flexJustifiedCenter,children:(0,T.Y)("img",{src:d&&u?ed.A.ic_arrow_2:ed.A.ic_arrow})}),(0,T.FD)("div",{css:aC,children:[d&&(0,T.Y)(sV,{data:d,orderName:c?"B":"A",orderName2:c&&u?"C":u?"B":""}),u&&(0,T.Y)(sV,{data:u,orderName:c&&d?"C":d?"B":"A",orderName2:c&&d?"B":d?"A":""})]})]}),r===ld.VI.REQUEST&&(0,T.Y)("div",{css:[aT,a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,"",""],children:(0,T.Y)(a.Fd,{size:120,borderWidth:8,fillColor:a.Tj.Zeb_Solid_Bright_Blue,color:a.Tj.Zeb_Solid_Dark_Blue})}),r===ld.VI.FAIL&&(0,T.Y)(iF,{heading:"Oops. Something went wrong!",description:"Please try after sometime"})]})});function sG(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sz(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sG(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sG(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let sX=(0,u.AH)(a.vE.flexColumn,a.vE.flexJustifiedBetween,{padding:"0 ".concat(a.Wp.remConverter(32)),height:"100%"},"",""),s$=(0,u.AH)(a.vE.flexColumn,a.Wp.g(20),"",""),sQ=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.g(12),sz(sz({},a.p0.B4_14_regular),{},{borderRadius:a.Wp.remConverter(8),padding:a.Wp.remConverter(12),background:a.Tj.Zeb_Gradient_Dark_Blue,marginTop:a.Wp.remConverter(20),img:{height:a.Wp.remConverter(20),width:a.Wp.remConverter(20)}}),"",""),sJ=(0,u.AH)({fontSize:a.Wp.remConverter(20),color:a.Tj.Zeb_Solid_White},"",""),s0=(0,u.AH)(a.vE.flexJustifiedCenter,sz(sz({},a.p0.B4_14_regular),{},{width:a.Wp.remConverter(49),borderRadius:a.Wp.remConverter(8),color:a.Tj.Zeb_Solid_Light_Blue,backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,padding:a.Wp.remConverter(8),cursor:"pointer",":hover":{color:a.Tj.Zeb_Solid_Bright_Blue}}),"",""),s1=e=>(0,u.AH)({flex:1,input:{color:e?a.Tj.Zeb_Solid_White:a.Tj.Zeb_Solid_Light_Blue,"&:focus":{color:a.Tj.Zeb_Solid_White}}},"",""),s2=(0,u.AH)(a.vE.flexAlignCenter,a.Wp.g(12),{cursor:"pointer",img:{height:a.Wp.remConverter(24),width:a.Wp.remConverter(24)},i:{fontSize:a.Wp.remConverter(20)}},"",""),s4=(0,u.AH)(sz(sz({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue}),"",""),s8={name:"kxbue8",styles:"text-transform:none"},s5=(0,u.AH)(sz(sz({},a.p0.C3_14),{},{color:a.Tj.Zeb_Solid_Bright_Blue,cursor:"pointer"}),"",""),s6=(0,u.AH)({div:{fontWeight:"normal",color:a.Tj.Zeb_Solid_Light_Blue}},"",""),s3=(0,u.AH)([a.vE.flexAlignCenter,a.Wp.g(12)],"",""),s9={name:"19qh1x9",styles:"z-index:11"},s7=(0,u.AH)([a.vE.flexAlignStart,a.Wp.g(12)],"",""),ce=(0,u.AH)([a.vE.flexAlignEnd,a.Wp.g(8),a.Wp.mt(24)],"",""),ct=(0,u.AH)([a.vE.flexAlignStart],"",""),cr=(0,u.AH)([a.vE.flexAlignEnd,a.vE.flexJustifiedEnd,a.Wp.g(8),a.Wp.mt(24),a.Wp.ml(12)],"",""),cn=(0,u.AH)([a.Wp.mb(12),a.vE.flexAlignCenter,a.Wp.g(4)],"",""),ci=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),cl=(0,u.AH)(a.vE.flexAlignCenter,"",""),co=(0,u.AH)("gap:12px;",s6,"",""),ca=(0,u.AH)([a.vE.flexAlignCenter,a.Wp.g(12)],"",""),cs=(0,u.AH)([a.Wp.p(12),a.Wp.br(8),{background:a.Tj.Zeb_Solid_BG_Blue,minWidth:250}
1],"",""),cc=(0,u.AH)([a.p0.B4_14_semibold,a.Wp.mb(12)],"",""),cd=(0,u.AH)([a.vE.flexAlignStart,a.vE.flexJustifiedBetween,a.Wp.mb(4)],"",""),cu={name:"1bmnxg7",styles:"white-space:nowrap"},cp={name:"pzhpb9",styles:"div{white-space:nowrap;}"},ch=(0,u.AH)([a.p0.B5_12_semibold],"",""),cg=(0,u.AH)([a.p0.B5_12_regular,a.vE.textFaded],"",""),cm=(0,u.AH)({height:1,width:"100%",backgroundColor:a.Tj.Zeb_Solid_BG_Blue},"",""),cv=(0,u.AH)([a.vE.flexAlignStart,a.vE.flexJustifiedBetween,a.Wp.mb(4)],"",""),cA=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween],"",""),cb=(0,u.AH)(a.vE.flexJustifiedBetween,"",""),cy=(0,u.AH)(a.vE.flexAlignStart,"",""),cf=(0,u.AH)([(0,p.sM)(12)],"",""),c_=(0,u.AH)((0,p.sM)(8),"",""),cS=(0,u.AH)({border:"1px solid ".concat(a.Tj.Zeb_Solid_Bright_Blue),maxWidth:"fit-content"},"",""),cT=(0,u.AH)([a.vE.flexAlignEnd,a.vE.flexColumn],"",""),cC=(0,u.AH)([a.p0.B5_12_regular,a.vE.flexAlignCenter,a.Wp.g(4),{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),cE={name:"kxbue8",styles:"text-transform:none"},cI=(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),cD=(0,u.AH)([a.p0.B4_14_semibold],"",""),cP=(0,u.AH)([a.p0.B5_12_regular,a.vE.textFaded],"",""),cO=e=>{var t,r,n,l;let{order:o,data:s,conversionRate:c}=e,{coinList:d}=(0,i.useContext)(ds),h=o.type===iP.ZN.STOP_MARKET,g=o.marginAsset!=o.quoteAsset,{maintainanceMarginPercent:m,marginBufferPercent:v}=(0,i.useMemo)(()=>{let e=d.find(e=>e.pair===o.symbol);return{marginBufferPercent:null==e?void 0:e.marginBufferPercentage,maintainanceMarginPercent:null==e?void 0:e.maintenanceMarginPercentage}},[d,o]),A=e=>{let t=h?o.stopPrice:o.price,r=h?s.stopPrice:s.price,n=(e?o.orderAmount*t:s.quantity*r)*(1+Number(v)/100)/o.leverage,i=n*Number(null!=m?m:0)/100;return{marginRequired:n,maintainanceMargin:i}},b=(0,T.Y)("div",{css:ca,children:[void 0,void 0].map((e,t)=>{var r,n,i,l,s,d;let p=!t,h=A(p).marginRequired,m=A(p).maintainanceMargin;return(0,T.FD)("div",{css:cs,children:[(0,T.FD)("div",{css:cc,children:[p?"Old":"New"," Margin"]}),(0,T.FD)("div",{css:cd,children:[(0,T.Y)("div",{css:cu,children:"Maintenance Margin"}),(0,T.Y)("div",{css:cp,children:(0,T.Y)(sU,{allowConversion:g,value:m,currency:null!=(r=o.quoteAsset)?r:"",conversionRate:null!=(n=o.marginConversionRate)?n:c,decimalPlace:o.quoteAsset===im?sB:sR,valueStyle:ch,toValueStyle:cg,align:"end"})})]}),(0,T.FD)("div",{css:(0,u.AH)([a.vE.flexAlignStart,a.vE.flexJustifiedBetween,g&&a.Wp.mb(4)],"",""),children:[(0,T.Y)("div",{css:cu,children:"Margin Balance"}),(0,T.Y)("div",{css:cp,children:(0,T.Y)(sU,{allowConversion:g,value:h,currency:null!=(i=o.quoteAsset)?i:"",conversionRate:null!=(l=o.marginConversionRate)?l:c,decimalPlace:o.quoteAsset===im?sB:sR,valueStyle:ch,toValueStyle:cg,align:"end"})})]}),g&&(0,T.Y)("div",{css:[cm,cv,"",""]}),g&&(0,T.FD)("div",{css:cA,children:[(0,T.Y)("div",{children:"Conversion Rate"}),(0,T.Y)("div",{children:(0,T.Y)(sU,{allowConversion:g,value:1,currency:null!=(s=o.quoteAsset)?s:"",conversionRate:null!=(d=o.marginConversionRate)?d:c,decimalPlace:0,valueStyle:ch,toValueStyle:cg,align:"end"})})]})]},t)})});return(0,T.Y)(ix.A,{children:(0,T.FD)("div",{css:cb,children:[(0,T.Y)("div",{css:cy,children:(0,T.FD)("div",{css:cf,children:[(0,T.Y)(a.In,{name:"fees-new1",style:(0,p.Kk)()}),(0,T.FD)("div",{css:c_,children:[(0,T.Y)("span",{css:[a.p0.B4_14_regular,"",""],children:"Margin Details"}),(0,T.Y)(a.m_,{contentStyle:cS,content:b,position:"top-end",children:(0,T.Y)(a.In,{name:"info",style:(0,p.Kk)(14,a.Tj.Zeb_Solid_Bright_Blue)})})]})]})}),(0,T.FD)("div",{css:cT,children:[(0,T.Y)("div",{css:a.p0.B4_14_semibold,children:(0,T.Y)(sU,{displayInline:!0,allowConversion:g,value:A(!1).marginRequired,currency:null!=(t=o.quoteAsset)?t:"",conversionRate:null!=(r=o.marginConversionRate)?r:c,decimalPlace:o.quoteAsset===im?sB:sR,style:cD})}),(0,T.FD)("div",{css:cC,children:[(0,T.Y)(a.YD,{style:cE,type:"warning",children:"Old"}),(0,T.Y)(sU,{toCurrencyStyle:cI,displayInline:!0,allowConversion:g,value:A(!0).marginRequired,currency:null!=(n=o.quoteAsset)?n:"",conversionRate:null!=(l=o.marginConversionRate)?l:c,decimalPlace:o.quoteAsset===im?sB:sR,style:cP})]})]})]})})},cY=e=>{let{onMinusClick:t,onPlusClick:r,containerStyle:n}=e;return(0,T.FD)("div",{css:n,children:[(0,T.Y)("div",{css:s0,onClick:t,children:"-1%"}),(0,T.Y)("div",{css:s0,onClick:r,children:"+1%"})]})},cw=e=>{let{onClick:t,failedAttempts:r}=e,n=r>=3;return(0,T.Y)(i6,{header:"Order Failed",image:ed.A.i_error_red,title:"Order Update Failed",description:n?"Attempts exhausted. Please retry after sometime.":"Please try editing your order again.",primaryButtonText:n?void 0:"Retry",primaryButtonClick:t,secondaryButtonClick:t,secondaryButtonText:n?"GOT IT":void 0})},cF=e=>{let{onClick:t}=e;return(0,T.Y)(i6,{header:"Order Executed",image:ed.A.i_empty,title:"Order Already Executed",description:"This order has already been executed. You can no longer make changes. ",secondaryButtonText:"Got it",secondaryButtonClick:t})};function cR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function cN(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?cR(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):cR(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let cB=(0,u.AH)(a.vE.flexColumn,a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,"padding:20px 32px;flex:1;",""),cx=(0,u.AH)({width:a.Wp.remConverter(140),height:a.Wp.remConverter(140),marginBottom:a.Wp.remConverter(20)},"",""),ck=(0,u.AH)(cN(cN({},a.p0.B2_20_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,paddingTop:a.Wp.remConverter(4)}),"",""),cj=(0,u.AH)(a.Wp.mt(32),{backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(12),padding:a.Wp.remConverter(16),display:"flex",width:"100%",flexDirection:"column",gap:a.Wp.remConverter(16),marginBottom:a.Wp.remConverter(24)},"",""),cW={name:"1066lcq",styles:"display:flex;justify-content:space-between;align-items:center"},cL=(0,u.AH)(cN(cN({},a.p0.B4_14_regular),{},{color:a.Tj.Zeb_Solid_Light_Blue,display:"flex",alignItems:"center",gap:a.Wp.remConverter(8)}),"",""),cM=(0,u.AH)(cN(cN({},a.p0.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_White,display:"flex",alignItems:"center",gap:a.Wp.remConverter(8)}),"",""),cH=(0,u.AH)({fontSize:a.Wp.remConverter(16),color:a.Tj.Zeb_Solid_Light_Blue},"",""),cU=e=>{let{order:t,onKeep:r,onSuccess:n}=e;(0,s.wA)();let{0:l,1:o}=(0,i.useState)(!1),{userInfo:c,subAccountId:d}=(0,i.useContext)(ds),u=async()=>{if(t){o(!0);try{await lf({clientOrderId:t.clientOrderId},(null==c?void 0:c.access_token)||"",d)?((0,eh.A)({title:"Open Order Cancelled",description:"".concat(t.baseAsset,"/").concat(t.quoteAsset," order has been cancelled"),type:e7.C.success}),n()):(0,eh.A)({title:"Cancellation Failed",description:"Failed to cancel the order. Please try again.",type:e7.C.error})}catch(e){(0,eh.A)({title:"Cancellation Failed",description:"An error occurred while cancelling the order.",type:e7.C.error})}finally{o(!1)}}},p=e=>ox(e.toString(),2);return(0,T.Y)(i5,{header:"Confirm Cancellation",primaryButtonText:"Yes, CANCEL ORDER",primaryButtonClick:u,secondaryButtonText:"KEEP ORDER",secondaryButtonClick:r,disablePrimaryBtn:l,isPrimaryCtaLoading:l,footerPadding:"large",children:(0,T.FD)("div",{css:cB,children:[(0,T.Y)("img",{css:cx,src:ed.A.i_exclamation_point,alt:"exclamation point"}),(0,T.Y)("div",{css:a.p0.H3_32_bold,children:"Cancel Order?"}),(0,T.Y)("div",{css:ck,children:"Are you sure you want to cancel this open order?"}),(0,T.FD)("div",{css:cj,children:[(0,T.FD)("div",{css:cW,children:[(0,T.FD)("div",{css:cL,children:[(0,T.Y)(a.In,{name:"coins",style:cH}),"Pair (Perpetual)"]}),(0,T.FD)("div",{css:cM,children:[null==t?void 0:t.baseAsset,"/",null==t?void 0:t.quoteAsset,"\xa0",null==t?void 0:t.leverage,"X"]})]}),null!=t&&t.stopPrice?(0,T.FD)("div",{css:cW,children:[(0,T.FD)("div",{css:cL,children:[(0,T.Y)(a.In,{name:"fees",style:cH}),"Stop Price"]}),(0,T.FD)("div",{css:cM,children:[p(t.stopPrice)," ",null==t?void 0:t.quoteAsset]})]}):null,null!=t&&t.price?(0,T.FD)("div",{css:cW,children:[(0,T.FD)("div",{css:cL,children:[(0,T.Y)(a.In,{name:"fees",style:cH}),"Limit Price"]}),(0,T.FD)("div",{css:cM,children:[p((null==t?void 0:t.price)||0)," ",null==t?void 0:t.quoteAsset]})]}):null,(0,T.FD)("div",{css:cW,children:[(0,T.FD)("div",{css:cL,children:[(0,T.Y)(a.In,{name:"buy-crypto",style:cH}),"Quantity"]}),(0,T.FD)("div",{css:cM,children:[ox(((null==t?void 0:t.orderAmount)||0).toString(),8)," ",null==t?void 0:t.baseAsset]})]})]})]})})};var cq=function(e){return e[e.Edit=0]="Edit",e[e.Failed=1]="Failed",e[e.Executed=2]="Executed",e[e.Cancel=3]="Cancel",e}(cq||{});let cZ=e=>{var t,r,n,o,c,d,u,p;let{order:h,onClose:g,onSuccess:m}=e,v=(0,l.useRouter)(),{allContractDetails:A,userInfo:b,walletData:{balance:y,balanceUsdt:f},coinList:_,currencyList:S,subAccountId:C}=(0,i.useContext)(ds),{0:E,1:I}=(0,i.useState)(cq.Edit),{0:D,1:P}=(0,i.useState)([]),{0:O,1:Y}=(0,i.useState)(0),{futuresOrders:{openOrders:w,positions:F}}=(0,s.d4)(e=>e);(0,s.wA)();let R=h.quoteAsset===h.marginAsset?Number(null==(t=h.quoteAsset===im?f:y)?void 0:t.withdrawableBalance)+h.lockedMargin:Number(null!=(r=null==y?void 0:y.withdrawableBalance)?r:0)/(null!=(n=h.marginConversionRate)?n:1)+h.lockedMargin,N=h.quoteAsset===h.marginAsset?(h.quoteAsset===im?Number(null==f?void 0:f.withdrawableBalance):Number(null==y?void 0:y.withdrawableBalance))+h.lockedMargin:Number(null==y?void 0:y.withdrawableBalance)+h.lockedMargin*(null!=(o=h.marginConversionRate)?o:1),{0:B,1:x}=(0,i.useState)((h.stopPrice||0).toString()),{0:k,1:j}=(0,i.useState)((h.price||0).toString()),{0:W,1:L}=(0,i.useState)((h.orderAmount||0).toString()),{0:M,1:H}=(0,i.useState)(((h.orderAmount||0)*((h.type===iP.ZN.STOP_MARKET?h.stopPrice:h.price)||0)).toFixed(2)),{0:U,1:q}=(0,i.useState)(!1),{0:Z,1:V}=(0,i.useState)(""),{0:K,1:G}=(0,i.useState)({stop:"",price:"",quantity:"",amount:"",canSubmit:!0,addMargin:!1,isTpSlError:!1}),z=S.find(e=>e.code===h.quoteAsset),X=h.marginAsset!=h.quoteAsset;null==A||A[h.symbol].marketPrice;let{pricePrecision:$,quantityPrecision:Q,marginBuffer:J,notional:ee}=(0,i.useMemo)(()=>{var e,t,r;let n=_.find(e=>e.pair===h.symbol);return{pricePrecision:Number(null!=(e=null==n?void 0:n.pricePrecision)?e:0),quantityPrecision:Number(null!=(t=null==n?void 0:n.quantityPrecision)?t:0),marginBuffer:null==n?void 0:n.marginBufferPercentage,notional:null==n||null==(r=n.filters.find(e=>e.filterType===iP.Sx.MIN_NOTIONAL))?void 0:r.notional}},[_,h]),et=ig(ee/(h.type===iP.ZN.STOP_MARKET?Number(B):Number(k)),Number(Q)),er=ig(Number((et*(h.type===iP.ZN.STOP_MARKET?Number(B):Number(k))).toFixed(10)),h.quoteAsset===im?sB:sR),en=(null==h?void 0:h.stopPrice)||0,ei=h.price||0,el=h.orderAmount||0,eo=Number(((h.orderAmount||0)*((h.type===iP.ZN.STOP_MARKET?h.stopPrice:h.price)||0)).toFixed(2)),ea=(0,i.useMemo)(()=>Number(B)!==en||Number(k)!==ei||Number(W)!==el,[B,k,W,en,ei,el]),es=(0,i.useMemo)(()=>{switch(E){case cq.Edit:return(0,T.FD)("span",{css:s3,children:["Edit ",h.baseAsset,"/",h.quoteAsset," -",h.leverage||1,"X",(0,T.Y)(a.YD,{style:s8,type:h.side===iP.Yq.Buy?"success":"error",children:h.side===iP.Yq.Buy?"Buy":"Sell"})]});case cq.Executed:return"Order Executed";case cq.Failed:return"Order Failed";case cq.Cancel:return"Confirm Cancellation"}},[E,h.side]);(0,i.useEffect)(()=>{(async()=>{let e=await ly(h.linkId,(null==b?void 0:b.access_token)||"",C);e&&P(e)})()},[]);let ec=(0,i.useMemo)(()=>{var e,t;let r=null!=(e=null==A?void 0:A[h.symbol].marketPrice)?e:"0",n=null==(t=_.find(e=>e.pair===h.symbol))?void 0:t.pricePrecision;return"".concat(ox(r,Number(null!=n?n:"2"))," ").concat(h.quoteAsset)},[A,_]);(0,i.useEffect)(()=>{var e;let t=null!=(e=null==A?void 0:A[h.symbol].marketPrice)?e:"0",r=_.find(e=>e.pair===h.symbol),n=D.find(e=>e.linkId===h.linkId&&e.subType===iP.JZ.TAKE_PROFIT),i=D.find(e=>e.linkId===h.linkId&&e.subType===iP.JZ.STOP_LOSS),l=w.find(e=>e.linkId===h.linkId&&e.subType===iP.JZ.PRIMARY),o=1+.01*Number(J),a=0!==o?R/o:R,{stopError:s,priceError:c,amountError:d,quantityError:u,canSubmit:p,addMargin:g,isTpSlError:m}=((e,t,r,n,i,l)=>{var o,a,s,c,d,u,p,h,g,m,v,A,b,y,f,_,S,T,C,E,I,D,P,O,Y,w,F,R,N,B,x,k,j,W,L,M,H;let U="",q="",Z="",V="",K=!0,G=!1,z=!1,X=parseFloat(r.stopPrice)||0,$=parseFloat(r.price)||0,Q=parseFloat(r.quantity)||0,J=parseFloat(t)||0,ee=r.positions.find(t=>{let r=t.positionType===iP.CR.LONG&&e.side===iP.Yq.Sell||t.positionType===iP.CR.SHORT&&e.side===iP.Yq.Buy;return t.contractPair===e.symbol&&r}),et=e.placeType===iP.sx.POSITION&&e.type===iP.ZN.LIMIT&&-1!==r.positions.findIndex(t=>{let r=t.positionType===iP.CR.LONG&&e.side===iP.Yq.Sell||t.positionType===iP.CR.SHORT&&e.side===iP.Yq.Buy;return t.contractPair===e.symbol&&r}),er=r.openOrders.filter(t=>t.symbol===e.symbol&&e.side===t.side&&e.placeType===t.placeType&&e.linkType===t.linkType&&e.type===t.type&&e.clientOrderId!=t.clientOrderId).reduce((e,t)=>
1e+t.orderAmount,0),en=Math.max(((null==ee?void 0:ee.quantity)||0)-er,0),ei=Number(null!=(o=null==i||null==(a=i.filters.find(e=>e.filterType===iP.Sx.LIMIT_QTY_SIZE))?void 0:a.maxQty)?o:"0"),el=ig(((null==i||null==(s=i.filters.find(e=>e.filterType===iP.Sx.MIN_NOTIONAL))?void 0:s.notional)||Number.MAX_SAFE_INTEGER)/(e.type===iP.ZN.STOP_MARKET?X:$),Number(null!=(c=null==i?void 0:i.quantityPrecision)?c:"2")),eo=e.type===iP.ZN.STOP_MARKET?X:$,ea=Number(ig(Number((el*eo).toFixed(10)),e.quoteAsset===im?sB:sR)),es=e.type===iP.ZN.STOP_LIMIT?X||0:J||0,ec=Number(ow(es*((100+((null==i?void 0:i.limitPriceVarAllowed)||0))/100),Number(null!=(d=null==i?void 0:i.pricePrecision)?d:2))),ed=Number(ow(es*((100-((null==i?void 0:i.limitPriceVarAllowed)||0))/100),Number(null!=(u=null==i?void 0:i.pricePrecision)?u:2))),eu=e.subType===iP.JZ.TAKE_PROFIT,ep=e.subType===iP.JZ.STOP_LOSS,eh=e.type===iP.ZN.STOP_LIMIT,eg=e.type===iP.ZN.STOP_MARKET;if(Q<=0)return K=!1,{priceError:"",stopError:"",quantityError:"Please enter quantity to proceed",amountError:"Order amount must be at least ".concat(ea.toFixed(e.quoteAsset===im?sB:sR)," ").concat(e.quoteAsset),canSubmit:!1,addMargin:!1,isTpSlError:!1};if($<=0&&!eg)return K=!1,{priceError:"Please set a limit price to proceed",stopError:"",quantityError:"",amountError:"",canSubmit:!1,addMargin:!1,isTpSlError:!1};if(X<=0&&(eg||eh||eu||ep))return K=!1,{priceError:"",stopError:"Enter stop price to proceed",quantityError:"",amountError:"",canSubmit:!1,addMargin:!1,isTpSlError:!1};if(et)return(Q>en?(q="Insufficient ".concat(e.baseAsset," quantity. Order cannot be placed"),V="Insufficient ".concat(e.baseAsset," quantity. Order cannot be placed")):Q<el&&(q="The quantity should be above ".concat(el," ").concat(e.baseAsset),V="The amount should be above ".concat(ea," ").concat(e.quoteAsset)),$>0&&($<ed&&(Z="Price should not be less than ".concat(ed," ").concat(e.quoteAsset)),$>ec&&(Z="Price should not be more than ".concat(ec," ").concat(e.quoteAsset))),V.length||Z.length)?{priceError:Z,stopError:"",amountError:V,quantityError:q,canSubmit:!1,addMargin:!1,isTpSlError:!1}:{priceError:"",stopError:"",amountError:V,quantityError:q,canSubmit:!0,addMargin:!1,isTpSlError:!1};let em=parseFloat(ow(((e,t,r)=>{if(!r)return 0;let n=r.side===iP.Yq.Buy?1:-1,i=r.type===iP.ZN.STOP_MARKET?r.stopPrice||0:r.price||0,l=i*(r.orderAmount||0),o=(r.orderAmount||0)*n*(1+.01*parseFloat(e)),a=0!==o?i-(r.lockedMargin||0)/o:i,s=Number(r.leverage),c=Math.abs((0!==s?Math.abs(l/s)*(1+.01*parseFloat(e)):Math.abs(l)*(1+.01*parseFloat(e)))*parseFloat(t)/100);return a+(0!==(r.orderAmount||0)?c*n/(r.orderAmount||0):0)})(null!=(p=null==i?void 0:i.marginBufferPercentage)?p:"1",null!=(h=null==i?void 0:i.maintenanceMarginPercentage)?h:"0",r.hostOrder),Number(null!=(g=null==i?void 0:i.pricePrecision)?g:2))),ev=0,eA=0;if(r.openOrders.map(e=>{var t,n;e.linkId===(null==(t=r.hostOrder)?void 0:t.linkId)&&e.subType===iP.JZ.TAKE_PROFIT?ev+=e.orderAmount:e.linkId===(null==(n=r.hostOrder)?void 0:n.linkId)&&e.subType===iP.JZ.STOP_LOSS&&(eA+=e.orderAmount)}),eu)if(isNaN(X)||X<=0)U="Stop price must be greater than 0";else if(r.hostOrder){e.side===iP.Yq.Buy&&X<(null==(m=r.hostOrder)?void 0:m.price)?U="Stop price should be higher than entry price: ".concat(null==(A=r.hostOrder)?void 0:A.price):e.side===iP.Yq.Sell&&X>(null==(v=r.hostOrder)?void 0:v.price)&&(U="Stop price should be lower than entry price: ".concat(null==(b=r.hostOrder)?void 0:b.price));let t=r.hostOrder.orderAmount-ev+(e.orderAmount||0);Q>t&&(q="Available Quantity: ".concat(t," ").concat(e.quoteAsset))}else e.side===iP.Yq.Sell?X<=J&&(U="Take Profit stop price should be higher than current market price"):e.side===iP.Yq.Buy&&X>=J&&(U="Take Profit stop price should be lower than current market price"),Q>(e.orderAmount||0)&&(V=q="Quantity should not be more than ".concat(e.orderAmount||0," ").concat(e.baseAsset));else if(ep)if(isNaN(X)||X<=0)U="Stop price must be greater than 0";else if(r.hostOrder){e.side===iP.Yq.Buy&&X>(null==(y=r.hostOrder)?void 0:y.price)?U="Stop price should be lower than entry price: ".concat(null==(_=r.hostOrder)?void 0:_.price):e.side===iP.Yq.Sell&&X<(null==(f=r.hostOrder)?void 0:f.price)&&(U="Stop price should be higher than entry price: ".concat(null==(S=r.hostOrder)?void 0:S.price)),e.side===iP.Yq.Buy&&X<em?U="Stop price should be higher than liquidation price: ".concat(em):e.side===iP.Yq.Sell&&X>em&&(U="Stop price should be lower than liquidation price: ".concat(em));let t=r.hostOrder.orderAmount-eA+(e.orderAmount||0);Q>t&&(q="Available Quantity: ".concat(t," ").concat(e.quoteAsset))}else e.side===iP.Yq.Buy?X<=J&&(U="Stop Loss stop price should be higher than current market price"):e.side===iP.Yq.Sell&&X>=J&&(U="Stop Loss stop price should be lower than current market price"),Q>(e.orderAmount||0)&&(V=q="Quantity should not be more than ".concat(e.orderAmount||0," ").concat(e.baseAsset));else if(eg){if(isNaN(X)||X<=0)U="Stop price must be greater than 0";else if(e.side===iP.Yq.Buy){let t=1.3*J;X>t&&(U="Stop price should not be more than ".concat(ow(t,Number(null!=(T=null==i?void 0:i.pricePrecision)?T:2))," ").concat(e.quoteAsset)),X<=J&&(U="Stop price must be higher than ".concat(J," ").concat(e.quoteAsset))}else if(e.side===iP.Yq.Sell){let t=.7*J;X<t&&(U="Stop price should not be less than ".concat(ow(t,Number(null!=(C=null==i?void 0:i.pricePrecision)?C:2))," ").concat(e.quoteAsset)),X>=J&&(U="Stop price must be lower than ".concat(J," ").concat(e.quoteAsset))}if(eg&&!isNaN(X)&&X>0){let t=!!r.tpValue,n=!!r.slValue;if(t&&n){let t=Math.min(r.tpValue,r.slValue),n=Math.max(r.tpValue,r.slValue);(X<t||X>n)&&(U="Limit Price is out of TP/SL range ".concat(ox(t,Number(null!=(E=null==i?void 0:i.pricePrecision)?E:2))," - ").concat(ox(n,Number(null!=(I=null==i?void 0:i.pricePrecision)?I:2))," ").concat(e.quoteAsset),z=!0)}else t?(e.side===iP.Yq.Buy&&X>r.tpValue||e.side===iP.Yq.Sell&&X<r.tpValue)&&(U="Limit Price should not be ".concat(e.side===iP.Yq.Buy?"more":"less"," than ").concat(ox(r.tpValue,Number(null!=(D=null==i?void 0:i.pricePrecision)?D:2))," ").concat(e.quoteAsset),z=!0):n&&(e.side===iP.Yq.Buy&&X<r.slValue||e.side===iP.Yq.Sell&&X>r.slValue)&&(U="Limit Price should not be ".concat(e.side===iP.Yq.Buy?"less":"more"," than ").concat(ox(r.slValue,Number(null!=(P=null==i?void 0:i.pricePrecision)?P:2))," ").concat(e.quoteAsset),z=!0)}}else if(eh){if(isNaN($)||$<=0?Z="Limit price must be greater than 0":($<ed&&(Z="Limit price should not be less than ".concat(ed," ").concat(e.quoteAsset)),$>ec&&(Z="Limit price should not be more than ".concat(ec," ").concat(e.quoteAsset))),isNaN(X)||X<=0)U="Stop price must be greater than 0";else if(e.side===iP.Yq.Buy?X<=J&&(U="Stop price must be higher than ".concat(J," ").concat(e.quoteAsset)):e.side===iP.Yq.Sell&&X>=J&&(U="Stop price must be lower than ".concat(J," ").concat(e.quoteAsset)),!U){if(e.side===iP.Yq.Buy){let t=1.3*J;X>t&&(U="Stop price should not be more than ".concat(ow(t,Number(null!=(O=null==i?void 0:i.pricePrecision)?O:2))," ").concat(e.quoteAsset))}else if(e.side===iP.Yq.Sell){let t=.7*J;X<t&&(U="Stop price should not be less than ".concat(ow(t,Number(null!=(Y=null==i?void 0:i.pricePrecision)?Y:2))," ").concat(e.quoteAsset))}}if(!isNaN(X)&&!isNaN($)&&X>0&&$>0){if(e.side===iP.Yq.Buy){let e=1.15*X;$>e&&(Z="Limit price must not be more than ".concat(ow(e,Number(null!=(w=null==i?void 0:i.pricePrecision)?w:2)))),$<=X&&(Z="Limit price must be higher than stop price")}else if(e.side===iP.Yq.Sell){let e=.85*X;$<e&&(Z="Limit price must not be less than ".concat(ow(e,Number(null!=(F=null==i?void 0:i.pricePrecision)?F:2)))),$>=X&&(Z="Limit price must be lower than stop price")}}if(eh&&!isNaN($)&&$>0){let t=!!r.tpValue,n=!!r.slValue;if(t&&n){let t=Math.min(r.tpValue,r.slValue),n=Math.max(r.tpValue,r.slValue);($<t||$>n)&&(Z="Limit Price is out of TP/SL range ".concat(ox(t,Number(null!=(R=null==i?void 0:i.pricePrecision)?R:2))," - ").concat(ox(n,Number(null!=(N=null==i?void 0:i.pricePrecision)?N:2))," ").concat(e.quoteAsset),z=!0)}else t?(e.side===iP.Yq.Buy&&$>r.tpValue||e.side===iP.Yq.Sell&&$<r.tpValue)&&(Z="Limit Price should not be ".concat(e.side===iP.Yq.Buy?"more":"less"," than ").concat(ox(r.tpValue,Number(null!=(B=null==i?void 0:i.pricePrecision)?B:2))," ").concat(e.quoteAsset),z=!0):n&&(e.side===iP.Yq.Buy&&$<r.slValue||e.side===iP.Yq.Sell&&$>r.slValue)&&(Z="Limit Price should not be ".concat(e.side===iP.Yq.Buy?"less":"more"," than ").concat(ox(r.slValue,Number(null!=(x=null==i?void 0:i.pricePrecision)?x:2))," ").concat(e.quoteAsset),z=!0)}}else{isNaN($)||$<=0?Z="Price must be greater than 0":($<ed&&(Z="Price should not be less than ".concat(ed," ").concat(e.quoteAsset)),$>ec&&(Z="Price should not be more than ".concat(ec," ").concat(e.quoteAsset)));let t=!!r.tpValue,n=!!r.slValue;if(t&&n){let t=Math.min(r.tpValue,r.slValue),n=Math.max(r.tpValue,r.slValue);($<t||$>n)&&(Z="Limit Price is out of TP/SL range ".concat(ox(t,Number(null!=(k=null==i?void 0:i.pricePrecision)?k:2))," - ").concat(ox(n,Number(null!=(j=null==i?void 0:i.pricePrecision)?j:2))," ").concat(e.quoteAsset),z=!0)}else t?(e.side===iP.Yq.Buy&&$>r.tpValue||e.side===iP.Yq.Sell&&$<r.tpValue)&&(Z="Limit Price should not be ".concat(e.side===iP.Yq.Buy?"more":"less"," than ").concat(ox(r.tpValue,Number(null!=(W=null==i?void 0:i.pricePrecision)?W:2))," ").concat(e.quoteAsset),z=!0):n&&(e.side===iP.Yq.Buy&&$<r.slValue||e.side===iP.Yq.Sell&&$>r.slValue)&&(Z="Limit Price should not be ".concat(e.side===iP.Yq.Buy?"less":"more"," than ").concat(ox(r.slValue,Number(null!=(L=null==i?void 0:i.pricePrecision)?L:2))," ").concat(e.quoteAsset),z=!0)}if(!Z&&!U){if(isNaN(Q))V=q="Quantity must be greater than 0";else if(Q<el&&(q="The quantity should be above ".concat(el," ").concat(e.baseAsset)),Q>ei&&(V=q="The quantity should be below ".concat(ei," ").concat(e.baseAsset)),l&&$>0){let t=Number(null!=(M=e.leverage)?M:"1");(0!==t?$*Q/t:$*Q)>l&&(V=q="Insufficient ".concat(e.quoteAsset," balance"),G=!0)}}if(!isNaN($)&&!isNaN(Q)){let t=e.quoteAsset===im?sB:sR,l=Number(r.amount);if(l<=0)V="Total amount must be greater than 0";else{let r=Number(ow(n*(e.leverage||1),t)),o=ow(r/eo,Number(null!=(H=null==i?void 0:i.quantityPrecision)?H:2));l<ea?V="Order amount must be at least ".concat(ea.toFixed(t)," ").concat(e.quoteAsset):l>r&&(V="Insufficient ".concat(e.marginAsset," balance. Place an order upto ").concat(r," ").concat(e.quoteAsset),q="Insufficient ".concat(e.marginAsset," balance. Place an order upto ").concat(o," ").concat(e.baseAsset),G=!0)}}return(V.length||Z.length||U.length||q.length)&&(K=!1),{stopError:U,quantityError:q,priceError:Z,amountError:V,canSubmit:K,addMargin:G,isTpSlError:z}})(h,t,{stopPrice:B,price:k,quantity:W,amount:M,openOrders:w,tpValue:null==n?void 0:n.price,slValue:null==i?void 0:i.price,hostOrder:l,positions:F},a,r,R);G({stop:s,price:c,quantity:u,amount:d,canSubmit:p,addMargin:g,isTpSlError:m})},[B,k,W,M,A,_,R,w,D,F]);let ed=async()=>{let e={clientOrderId:h.clientOrderId,price:h.type!==iP.ZN.STOP_MARKET?Number(k):void 0,quantity:Number(W),stopPrice:h.type.includes("STOP")?Number(B):void 0},t=await lw(e,(null==b?void 0:b.access_token)||"",C);(null==t?void 0:t.statusCode)===200?(m(),(0,eh.A)({type:"success",title:"Order Updated Successfully",description:"Your ".concat(h.baseAsset,"-").concat(h.quoteAsset," trade has been modified successfully.")})):(Y(e=>e+1),I(cq.Failed))};(0,i.useEffect)(()=>
1{if(Z.length&&h.placeType!==iP.sx.POSITION){let e=R/(1+.01*Number(J));eu((("1"===Z?e:R*Number(Z))*(h.leverage||1)).toString(),!0,!0)}},[Z,Q]);let eu=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=e.length>15?e.substring(0,15):e;r||V("");let i=Number(h.type===iP.ZN.STOP_MARKET?B:k);if(t){var l;H(ow(n,null!=(l=null==z?void 0:z.currencyPrecision)?l:2)),i&&L(ow(Number(n)/i,Q))}else L(ow(n,Q)),H(ig(Number(n)*i,h.marginAsset===im?sB:sR).toString())},ep=e=>{let t=ow(e.length>15?e.substring(0,15):e,$);j(t),W.length&&H(ow(Number(W)*Number(t),h.marginAsset===im?sB:sR))},eg=e=>{let t=ow(e.length>15?e.substring(0,15):e,$);x(t),W.length&&h.type===iP.ZN.STOP_MARKET&&H(ow(Number(W)*Number(t),h.marginAsset===im?sB:sR))},em=(e,t)=>{var r;let n=null!=(r=null==A?void 0:A[h.symbol].marketPrice)?r:"0",i=(Number(Number(t?k:B)>0?t?k:B:n)*(1+e/100)).toFixed($);t?ep(i):eg(i)};return(0,T.FD)(a.wv,{hideClose:[cq.Cancel,cq.Executed].includes(E)||E===cq.Failed&&O>=3,overlayStyle:s9,open:!0,onClose:g,children:[E===cq.Edit&&(0,T.Y)(i5,{header:es,primaryButtonText:"UPDATE ORDER",secondaryButtonText:"DISCARD CHANGES",disablePrimaryBtn:!K.canSubmit||!ea,secondaryButtonClick:g,primaryButtonClick:ed,footerPadding:"regular",children:(0,T.FD)("div",{css:sX,children:[(0,T.FD)("div",{css:s$,children:[(0,T.FD)("div",{css:sQ,children:[(0,T.Y)("img",{src:null==(c=_.find(e=>e.baseAsset===h.baseAsset))?void 0:c.iconURL}),(0,T.FD)("div",{children:["Mark Price: ",(0,T.Y)("span",{css:a.p0.C3_14,children:ec})]})]}),h.type.includes("STOP")&&(0,T.FD)("div",{css:s7,children:[(0,T.Y)(a.pd,{type:"number",errorText:K.stop,style:s1(en!==Number(B)),placeholder:"Enter Stop Price",label:"Stop Price",value:B,onChange:e=>eg(e.value),appendItem:h.quoteAsset}),(0,T.Y)(cY,{onMinusClick:()=>em(-1,!1),onPlusClick:()=>em(1,!1),containerStyle:ce})]}),h.type!=iP.ZN.STOP_MARKET&&(0,T.FD)("div",{css:ct,children:[(0,T.Y)(a.pd,{type:"number",errorText:K.price,style:s1(ei!==Number(k)),placeholder:"Enter Price",label:"Price",value:k,onChange:e=>ep(e.value),appendItem:h.quoteAsset}),(0,T.FD)("div",{children:[(0,T.Y)(cY,{onMinusClick:()=>em(-1,!0),onPlusClick:()=>em(1,!0),containerStyle:cr}),K.isTpSlError&&(0,T.Y)("div",{css:s5,onClick:()=>I(cq.Cancel),children:"CANCEL ORDER"})]})]}),(0,T.FD)("div",{children:[(0,T.Y)(a.pd,{type:"number",cta:K.addMargin?{label:"ADD ".concat(h.marginAsset),onClick:()=>v.push("/subAccount?tab=assets-fiat")}:void 0,errorText:U?K.amount:K.quantity,placeholder:U?"Enter Amount":"Enter Quantity",label:U?"Amount":"Quantity",value:U?M:W,onChange:e=>eu(e.value,U),style:s1(U?eo!==Number(M):el!==Number(W)),appendItem:(0,T.FD)("div",{css:s2,onClick:()=>q(!U),children:[(0,T.Y)(a.In,{name:"separator"}),(0,T.Y)("img",{src:U?null==z?void 0:z.iconDarkTheme:null==(d=_.find(e=>e.baseAsset===h.baseAsset))?void 0:d.iconURL}),(0,T.Y)("div",{children:U?h.quoteAsset:h.baseAsset}),(0,T.Y)(a.In,{name:"sorter_01"})]})}),0===(U?K.amount:K.quantity).length?(0,T.FD)("div",{css:s4,children:[U?"Min. Amt":"Min. Qty"," ",U?er:et," ",U?h.quoteAsset:h.baseAsset]}):null]}),h.placeType!==iP.sx.POSITION&&(0,T.FD)("div",{css:a.p0.B4_14_regular,children:[(0,T.FD)("div",{css:cn,children:[(0,T.FD)("span",{css:ci,children:["Avbl. ",X&&"(Notional)"]}),(0,T.FD)(T.FK,{children:[(0,T.FD)("span",{children:[X?"".concat(ox(R,null!=(u=null==z?void 0:z.currencyPrecision)?u:2)," ").concat(h.quoteAsset):""," ",X&&"~",ox(N,h.marginAsset===im?sB:sR)]}),(0,T.Y)("span",{css:ci,children:h.marginAsset}),(0,T.Y)("span",{css:cl,children:(0,T.Y)(a.K0,{style:sJ,type:"link",icon:"arrow-right",onClick:()=>v.push("/subAccount?tab=assets-fiat")})})]})]}),(0,T.Y)(a.tU,{style:co,type:"secondary",selectedTab:Z,onChange:e=>V(e),tabsList:ih})]})]}),h.subType===iP.JZ.PRIMARY&&h.placeType!==iP.sx.POSITION&&(0,T.Y)("div",{children:(0,T.Y)(cO,{order:h,data:{price:Number(k),quantity:Number(W),stopPrice:Number(B)},conversionRate:null!=(p=h.marginConversionRate)?p:1})})]})}),E===cq.Failed&&(0,T.Y)(cw,{onClick:()=>{O>=3?g():I(cq.Edit)},failedAttempts:O}),E===cq.Executed&&(0,T.Y)(cF,{onClick:g}),E===cq.Cancel&&(0,T.Y)(cU,{order:h,onKeep:()=>I(cq.Edit),onSuccess:m})]})};var cV={name:"19qh1x9",styles:"z-index:11"};let cK=(0,s.Ng)(function(e){return{openOrders:e.futuresOrders.openOrders,apiStatus:e.status.openOrders,userSocket:e.futuresOrders.userSocket,openOrderPage:e.futuresOrders.tablePage,selectedTableMarginTab:e.futuresOrders.selectedTableMargin.openOrder}})(e=>{let{openOrders:t,openOrderPage:r,apiStatus:l,userSocket:o,selectedTableMarginTab:c}=e,d=(0,s.wA)(),{userInfo:h,coinList:g,email:m,fetchUserWalletBalance:v,subAccountId:A}=(0,i.useContext)(ds),{0:b,1:y}=(0,i.useState)([]),{0:f,1:_}=(0,i.useState)(""),{0:S,1:C}=(0,i.useState)(null),E=async()=>{await lb((null==h?void 0:h.access_token)||"",1,null,A)};(0,i.useEffect)(()=>{E()},[]),(0,i.useEffect)(()=>{y(t.filter(e=>c===iP.Tr.All||c===e.marginAsset))},[t,c]);let I=[{dataField:oD.Date,component:(0,T.Y)("span",{css:a.Wp.ml(16),children:"Date"}),width:150},{dataField:oD.Pair,component:"Pair",width:110},{dataField:oD.MarginType,component:"Margin Type",width:100},{dataField:oD.Order_Type,component:"Order Type",width:80},{dataField:oD.Side,component:"Side",width:60},{dataField:oD.Quantity,component:"Quantity",width:120},{dataField:oD.Filled,component:"Filled",width:60}
1,{dataField:oD.Trigger_Conditions,component:"Trigger Condition",width:140},{dataField:oD.Price,component:"Price",width:140},{dataField:oD.Total,component:"Total",width:150},{dataField:oD.TP_SL,component:"TP/SL",width:80,isSticky:!0},{dataField:oD.Delete,component:"Cancel Order",width:100,isSticky:!0},{dataField:oD.Edit,component:(0,T.Y)("div",{}),width:25,isSticky:!0}],D=b.length?b.map((e,t)=>{var r,i;let l=e.baseAsset||"",s=e.quoteAsset||"",c=g.find(e=>e.pair==="".concat(l).concat(s)),v=null!=(r=Number(null==c?void 0:c.pricePrecision))?r:sR,b=null!=(i=Number(null==c?void 0:c.quantityPrecision))?i:sN,y=l+"/"+s,f=e.quoteAsset===im?e.marginAsset==iP.bC.INR?iv:iA:"INR",S=e.quoteAsset===im?e.marginAsset==iP.bC.INR?"warning":"info":"default";return{[oD.Date]:(0,T.Y)(iR,{title:(0,sq.GP)(new Date(e.time),"dd MMM yy"),subtitle:(0,sq.GP)(new Date(e.time),"HH:mm:ss"),style:a.Wp.ml(16)}),[oD.Pair]:(0,T.Y)(a.m_,{contentStyle:on(y.length>10),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Coin Pair"})]}),(0,T.Y)("div",{css:or,children:y})]}),children:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.p0.B5_12_semibold,"",""],children:[y.slice(0,10).includes("/")?l:y.slice(0,10)+"...",y.slice(0,10).includes("/")?(0,T.FD)("span",{css:aE,children:["/",(null==s?void 0:s.slice(0,9-l.length))+(y.length>10?"...":"")]}):""]})}),[oD.MarginType]:(0,T.FD)(a.YD,{type:S,children:[(0,T.Y)(a.In,{name:(null==e?void 0:e.marginAsset)===iP.bC.INR?"inr-m":"usdt-m"}),(0,T.Y)("span",{style:{marginLeft:"4px"},children:f})]}),[oD.Order_Type]:(0,T.Y)("div",{css:aE,children:ax("PRIMARY"===e.subType?e.type:e.subType)}),[oD.Side]:(0,T.Y)("div",{css:lU("BUY"===e.side?1:-1),children:ax(e.side)}),[oD.Trigger_Conditions]:(0,T.Y)(iR,{title:e.stopPrice>0?(0,T.FD)("span",{css:[a.vE.flexAlignCenter,a.Wp.g(2),"",""],children:[e.type.includes("STOP")?(0,T.Y)(a.In,{style:(0,p.Kk)(10),name:e.stopPrice>e.curMarketPrice?"more-than":"less-than"}):"",sk(e.type.includes("STOP")?e.stopPrice:e.price,v)]}):"----",subtitle:e.stopPrice>0?e.quoteAsset:""}),[oD.Price]:(0,T.Y)(iR,{title:e.price>0?sk(e.price,v):"----",subtitle:e.price>0?e.quoteAsset:""}),[oD.Quantity]:(0,T.Y)(a.m_,{contentStyle:on(l.length>5),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Quantity"})]}),(0,T.FD)("div",{css:or,children:[e.orderAmount.toFixed(b)," ",l]})]}),children:(0,T.Y)(iR,{title:e.orderAmount.toFixed(b),subtitle:l.length>5?l.slice(0,4)+"...":l})}),[oD.Filled]:(0,T.Y)(iR,{title:"".concat(oY(100*e.filledAmount/e.orderAmount,sR),"%")}),[oD.Total]:(0,T.Y)(iR,{title:(0,T.FD)("span",{children:[sk(e.orderAmount*(e.type===iP.ZN.STOP_MARKET?e.stopPrice:e.price),"INR"===e.quoteAsset?sR:sB),"\xa0",(0,T.Y)("span",{css:null==n?void 0:oe,children:e.quoteAsset})]})}),[oD.TP_SL]:(0,T.Y)(T.FK,{children:"ORDER"===e.linkType?(0,T.Y)("span",{css:(0,u.AH)({color:a.Tj.Zeb_Solid_Light_Blue},"",""),children:"-"}):(0,T.Y)(a.$n,{type:"link",onClick:()=>_(e.linkId),size:"small",children:"View"})}),[oD.Delete]:(0,T.Y)(a.$n,{type:"link",onClick:async()=>{d({type:lc.X.SET_SOCKET,payload:!o}),Object.keys(await lf({clientOrderId:e.clientOrderId},(null==h?void 0:h.access_token)||"",A)||{}).length&&(window.Moengage.track_event("Futures Order Cancel",{email:m,Type:e.type.toLowerCase(),side:e.side,"Coin Pair":e.symbol,"Margin Type":e.marginAsset}),lb((null==h?void 0:h.access_token)||"",1,null,A),(0,eh.A)({title:"Open order cancelled successfully",description:"".concat(l," order cancelled successfully."),type:e7.C.success}))},size:"small",children:"Cancel"}),[oD.Edit]:"PRIMARY"===e.subType?(0,T.Y)(a.K0,{style:o_,type:"link",icon:"edit",onClick:()=>C(e)}):(0,T.Y)("div",{})}}):[],P=[...Array(10)].map(()=>({[oD.Date]:(0,T.Y)(a.WA,{height:18,width:100,style:a.Wp.ml(16)}),[oD.Pair]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.MarginType]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Order_Type]:(0,T.Y)(a.WA,{height:18,width:60}),[oD.Side]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Trigger_Conditions]:(0,T.Y)(a.WA,{height:18,width:120}),[oD.Quantity]:(0,T.Y)(a.WA,{height:18,width:110}),[oD.Filled]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Total]:(0,T.Y)(a.WA,{height:18,width:150}),[oD.TP_SL]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Delete]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Edit]:(0,T.Y)(a.WA,{height:18,width:18})}));return(0,T.FD)(T.FK,{children:[(0,T.Y)(iw,{headers:I,isStickyTable:!0,rows:l===ld.VI.REQUEST&&1===r.currentPage?P:D,noResultScreen:(0,T.Y)(ls,{tabType:ia.OpenOrders,isFilterApplied:!1,onClick:ek.A}),style:(0,u.AH)({"@media (max-width: 1150px)":{width:b.length?"fit-content":"auto"}},"",""),styleData:(0,u.AH)({padding:"".concat(a.Wp.remConverter(4)," ").concat(a.Wp.remConverter(2))},"",""),fetchMore:()=>{l!==ld.VI.SUCCESS||r.lastPage||D.length!=20*r.currentPage||lb((null==h?void 0:h.access_token)||"",r.currentPage+1,r.timeStamp,A)},isLoading:1!==r.currentPage&&l===ld.VI.REQUEST}),(0,T.Y)(a.wv,{overlayStyle:cV,open:!!f,onClose:()=>_(""),children:!!f&&(0,T.Y)(sK,{linkId:f})}),S&&(0,T.Y)(cZ,{order:S,onClose:()=>C(null),onSuccess:()=>{setTimeout(()=>{E()},1e3),C(null),v()}})]})});var cG={name:"kxbue8",styles:"text-transform:none"};let cz=(0,s.Ng)(function(e){return{orderHistory:e.futuresOrders.orderHistory,apiStatus:e.status.orderHistory,orderHistoryPage:e.futuresOrders.tablePage}}
1)(e=>{let{orderHistory:t,orderHistoryPage:r,apiStatus:n}=e,{coinList:l,subAccountId:o,userInfo:s}=(0,i.useContext)(ds);(0,i.useEffect)(()=>{(async()=>{await l_((null==s?void 0:s.access_token)||"",1,null,o)})()},[]),(0,i.useCallback)(()=>{"success"!==n||r.lastPage||l_((null==s?void 0:s.access_token)||"",r.currentPage+1,new Date().getTime(),o)},[n,r.currentPage,r.lastPage,o]);let c=[{dataField:oD.Date,component:(0,T.Y)("span",{css:a.Wp.ml(16),children:"Date"}),width:150},{dataField:oD.Pair,component:"Pair",width:110},{dataField:oD.MarginType,component:"Margin Type",width:100},{dataField:oD.Order_Type,component:"Order Type",width:100},{dataField:oD.Side,component:"Side",width:90},{dataField:oD.Average,component:"Average",width:135},{dataField:oD.Price,component:"Price",width:135},{dataField:oD.Executed,component:"Executed",width:135},{dataField:oD.Amount,component:"Amount",width:135},{dataField:oD.OrderID,component:"Order ID",width:250},{dataField:oD.Status,component:"Status",width:100}],d=t.length?t.map((e,t)=>{var r,n;let i=e.baseAsset,o=e.quoteAsset,s=l.find(e=>e.pair==="".concat(i).concat(o)),c=null!=(r=Number(null==s?void 0:s.pricePrecision))?r:sR,d=null!=(n=Number(null==s?void 0:s.quantityPrecision))?n:sN,u=i+"/"+o,p=e.quoteAsset===im?(null==e?void 0:e.marginAsset)==iP.bC.INR?iv:iA:"INR",h=e.quoteAsset===im?(null==e?void 0:e.marginAsset)==iP.bC.INR?"warning":"info":"default";return{[oD.Date]:(0,T.Y)(iR,{title:(0,sq.GP)(new Date(e.updatedAt),"dd MMM yy"),subtitle:(0,sq.GP)(new Date(e.updatedAt),"HH:mm:ss"),style:a.Wp.ml(16)}),[oD.Pair]:(0,T.Y)(a.m_,{contentStyle:on(u.length>10),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Coin Pair"})]}),(0,T.Y)("div",{css:or,children:u})]}),children:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.p0.B5_12_semibold,"",""],children:[u.slice(0,10).includes("/")?i:u.slice(0,10)+"...",u.slice(0,10).includes("/")?(0,T.FD)("span",{css:aE,children:["/",(null==o?void 0:o.slice(0,9-i.length))+(u.length>10?"...":"")]}):""]})}),[oD.MarginType]:(0,T.FD)(a.YD,{type:h,children:[(0,T.Y)(a.In,{name:(null==e?void 0:e.marginAsset)===iP.bC.INR?"inr-m":"usdt-m"}),(0,T.Y)("span",{style:{marginLeft:"4px"},children:p})]}),[oD.Order_Type]:(0,T.Y)("div",{css:aE,children:ax("PRIMARY"===e.subType?e.type:e.subType)}),[oD.Side]:(0,T.Y)("div",{css:lU("BUY"===e.side?1:-1),children:ax(e.side)}),[oD.Average]:(0,T.Y)(iR,{title:e.status===ip.EXPIRED?"-":(0,T.FD)("span",{children:[sk(e.avgPrice,c)," ",(0,T.Y)("span",{css:oe,children:e.quoteAsset})]})}),[oD.Price]:(0,T.Y)(iR,{title:e.status===ip.EXPIRED?"-":(0,T.FD)("span",{children:[sk(e.price,c)," ",(0,T.Y)("span",{css:oe,children:e.quoteAsset})]})}),[oD.Executed]:(0,T.Y)(a.m_,{contentStyle:on(i.length>5),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Quantity"})]}),(0,T.FD)("div",{css:or,children:[e.status===ip.EXPIRED?"-":Number(e.cumQty).toFixed(d)," ",i]})]}),children:(0,T.Y)(iR,{title:e.status===ip.EXPIRED?"-":Number(e.cumQty).toFixed(d),subtitle:e.status===ip.EXPIRED?"":i.length>5?i.slice(0,4)+"...":i})}),[oD.Amount]:(0,T.Y)(iR,{title:e.status===ip.EXPIRED?"-":(0,T.FD)("span",{children:[sk(e.origQty,"INR"===e.quoteAsset?sR:sB)," ",(0,T.Y)("span",{css:oe,children:e.quoteAsset})]})}),[oD.OrderID]:e.clientOrderId.length?(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.g(4),"",""],children:[e.clientOrderId,(0,T.Y)(a.K0,{icon:"copy",type:"link",onClick:()=>oj(e.clientOrderId.toString()).then(()=>(0,eh.A)({type:"success",title:"Order ID copied!",description:"Order ID copied to clipboard successfully."}))})]}):"---",[oD.Status]:(0,T.Y)(a.YD,{type:(e=>{switch(e.toLocaleUpperCase()){case ip.FILLED:return"success";case ip.PARTIAL:case ip.PARTIALLY_FILLED:return"warning";case ip.CANCELLED:case ip.CANCELED:return"error";default:return"default"}})(e.status),style:cG,children:ax("CANCELED"===e.status?"CANCELLED":e.status)})}}):[],p=[...Array(10)].map(()=>({[oD.Date]:(0,T.Y)(a.WA,{height:18,width:120,style:a.Wp.ml(16)}),[oD.Pair]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.MarginType]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Order_Type]:(0,T.Y)(a.WA,{height:18,width:60}),[oD.Side]:(0,T.Y)(a.WA,{height:18,width:60}),[oD.Average]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Price]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Executed]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Amount]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.OrderID]:(0,T.Y)(a.WA,{height:18,width:250}),[oD.Status]:(0,T.Y)(a.WA,{height:18,width:80})}));return(0,T.Y)(iw,{headers:c,rows:n===ld.VI.REQUEST&&1===r.currentPage?p:d,noResultScreen:(0,T.Y)(ls,{tabType:ia.OrderHistory,isFilterApplied:!1,onClick:ek.A}),style:(0,u.AH)({"@media (max-width: 1370px)":{width:t.length?"fit-content":"auto"}},"",""),styleData:(0,u.AH)({padding:"".concat(a.Wp.remConverter(15)," ").concat(a.Wp.remConverter(2))},"",""),fetchMore:()=>{n!==ld.VI.SUCCESS||r.lastPage||d.length!==20*r.currentPage||l_((null==s?void 0:s.access_token)||"",r.currentPage+1,r.timeStamp,o)},isLoading:1!==r.currentPage&&n===ld.VI.REQUEST})}),cX=(0,s.Ng)(function(e){return{tradeHistory:e.futuresOrders.tradeHistory,apiStatus:e.status.tradeHistory,tradeHistoryPage:e.futuresOrders.tablePage}}
1)(e=>{let{tradeHistory:t,tradeHistoryPage:r,apiStatus:n}=e;(0,s.wA)();let{coinList:l,subAccountId:o,userInfo:c}=(0,i.useContext)(ds);(0,i.useEffect)(()=>{(async()=>{await lS((null==c?void 0:c.access_token)||"",1,null,o)})()},[]);let d=[{dataField:oD.Date,component:(0,T.Y)("span",{css:a.Wp.ml(16),children:"Date"}),width:150},{dataField:oD.Pair,component:"Pair",width:110},{dataField:oD.MarginType,component:"Margin Type",width:100},{dataField:oD.Side,component:"Side",width:100},{dataField:oD.Price,component:"Price",width:130},{dataField:oD.Quantity,component:"Quantity",width:150},{dataField:oD.Fee,component:"Fee",width:120},{dataField:oD.Role,component:"Role",width:130},{dataField:oD.Realised_PnL,component:"Realised P&L",width:120},{dataField:oD.OrderID,component:"Order ID",width:250},{dataField:oD.TradeID,component:"Trade ID",width:100}],p=t.length?t.map((e,t)=>{var r,n,i,o,s;let c=null==e?void 0:e.baseAsset,d=null==e?void 0:e.quoteAsset,u=l.find(e=>e.pair==="".concat(c).concat(d)),p=null!=(r=Number(null==u?void 0:u.pricePrecision))?r:sR,h=null!=(n=Number(null==u?void 0:u.quantityPrecision))?n:sN,g=c+"/"+d,m=e.quoteAsset===im?(null==e?void 0:e.marginAsset)==iP.bC.INR?iv:iA:"INR",v=e.quoteAsset===im?(null==e?void 0:e.marginAsset)==iP.bC.INR?"warning":"info":"default";return{[oD.Date]:(0,T.Y)(iR,{title:(0,sq.GP)(new Date(e.time),"dd MMM yy"),subtitle:(0,sq.GP)(new Date(e.time),"HH:mm:ss"),style:a.Wp.ml(16)}),[oD.Pair]:(0,T.Y)(a.m_,{contentStyle:on(g.length>10),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Coin Pair"})]}),(0,T.Y)("div",{css:or,children:g})]}),children:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.p0.B5_12_semibold,"",""],children:[g.slice(0,10).includes("/")?c:g.slice(0,10)+"...",g.slice(0,10).includes("/")?(0,T.FD)("span",{css:aE,children:["/",(null==d?void 0:d.slice(0,9-c.length))+(g.length>10?"...":"")]}):""]})}),[oD.MarginType]:(0,T.FD)(a.YD,{type:v,children:[(0,T.Y)(a.In,{name:(null==e?void 0:e.marginAsset)===iP.bC.INR?"inr-m":"usdt-m"}),(0,T.Y)("span",{style:{marginLeft:"4px"},children:m})]}),[oD.Side]:(0,T.Y)("div",{css:lU("BUY"===e.side?1:-1),children:ax(e.side)}),[oD.Price]:(0,T.Y)(iR,{title:(0,T.FD)("span",{children:[sk(e.price,p),"\xa0",(0,T.Y)("span",{css:oe,children:e.quoteAsset})]})}),[oD.Quantity]:(0,T.Y)(a.m_,{contentStyle:on(c.length>5),content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Quantity"})]}),(0,T.FD)("div",{css:or,children:[e.quantity.toFixed(h)," ",c]})]}),children:(0,T.Y)(iR,{title:e.quantity.toFixed(h),subtitle:c.length>5?c.slice(0,4)+"...":c})}),[oD.Fee]:(0,T.Y)(iR,{title:(0,T.FD)("div",{children:[(0,T.FD)("div",{children:[sk(e.fee,"INR"===e.quoteAsset?sR:sB),"\xa0",(0,T.Y)("span",{css:oe,children:e.quoteAsset})]}),e.quoteAsset!==e.marginAsset&&(0,T.FD)("div",{children:[(0,T.Y)("span",{css:oe,children:"~"})," ",sk(e.fee*(null!=(i=e.marginConversionRate)?i:0),sR),"\xa0",(0,T.Y)("span",{css:oe,children:"INR"})]})]})}),[oD.Role]:(0,T.Y)(iR,{title:ax(e.role)}),[oD.Realised_PnL]:(0,T.FD)("div",{children:[(0,T.FD)("div",{css:lU(e.realizedProfit),children:[e.realizedProfit>0?"+":"",sk(e.realizedProfit,"INR"===e.quoteAsset?sR:sB)," ",e.quoteAsset]}),e.quoteAsset!==e.marginAsset&&(0,T.FD)("div",{css:a.p0.B5_12_semibold,children:[(0,T.Y)("span",{css:oe,children:"~"})," ",sk((null!=(o=e.marginConversionRate)?o:0)*Math.abs(null!=(s=e.realizedProfit)?s:0),sR),"\xa0",(0,T.Y)("span",{css:oe,children:"INR"})]})]}),[oD.OrderID]:e.clientOrderId.length?(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.g(4),"",""],children:[e.clientOrderId.length>24?(0,T.Y)(a.m_,{content:(0,T.FD)("div",{css:ot,children:[(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.Y)(a.In,{name:"info"}),(0,T.Y)("span",{css:a.Wp.pl(8),children:"Order ID"})]}),(0,T.Y)("div",{css:or,children:e.clientOrderId})]}),contentStyle:on(!0),children:(0,T.FD)("span",{children:[e.clientOrderId.slice(0,24),"..."]})}):e.clientOrderId,(0,T.Y)(a.K0,{icon:"copy",type:"link",onClick:()=>oj(e.clientOrderId.toString()).then(()=>(0,eh.A)({type:"success",title:"Order ID copied!",description:"Order ID copied to clipboard successfully."}))})]}):"---",[oD.TradeID]:e.id>0?(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.g(4),"",""],children:[e.id,(0,T.Y)(a.K0,{icon:"copy",type:"link",onClick:()=>oj(e.id.toString()).then(()=>(0,eh.A)({type:"success",title:"Trade ID copied!",description:"Trade ID copied to clipboard successfully."}))})]}):"---"}}):[],h=[...Array(10)].map(()=>({[oD.Date]:(0,T.Y)(a.WA,{height:18,width:120,style:a.Wp.ml(16)}),[oD.Pair]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.MarginType]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Side]:(0,T.Y)(a.WA,{height:18,width:80}),[oD.Price]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Quantity]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Fee]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Role]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Realised_PnL]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.OrderID]:(0,T.Y)(a.WA,{height:18,width:250}),[oD.TradeID]:(0,T.Y)(a.WA,{height:18,width:250})}
1));return(0,T.Y)(iw,{headers:d,rows:n===ld.VI.REQUEST&&1===r.currentPage?h:p,noResultScreen:(0,T.Y)(ls,{tabType:ia.TradeHistory,isFilterApplied:!1,onClick:ek.A}),style:(0,u.AH)({"@media (max-width: 1270px)":{width:t.length?"fit-content":"auto"}},"",""),styleData:(0,u.AH)({padding:"".concat(a.Wp.remConverter(15)," ").concat(a.Wp.remConverter(2))},"",""),fetchMore:()=>{n!==ld.VI.SUCCESS||r.lastPage||p.length!==20*r.currentPage||lS((null==c?void 0:c.access_token)||"",r.currentPage+1,r.timeStamp,o)},isLoading:1!==r.currentPage&&n===ld.VI.REQUEST})}),c$=(0,s.Ng)(function(e){return{transactionHistory:e.futuresOrders.transactionHistory,apiStatus:e.status.trasactionHistory,transactionHistoryPage:e.futuresOrders.tablePage}})(e=>{let{transactionHistory:t,transactionHistoryPage:r,apiStatus:n}=e;(0,s.wA)();let{subAccountId:l,userInfo:o}=(0,i.useContext)(ds);(0,i.useEffect)(()=>{(async()=>{await lT((null==o?void 0:o.access_token)||"",1,null,l)})()},[]);let c=[{dataField:oD.Date,component:(0,T.Y)("span",{css:a.Wp.ml(16),children:"Date"}),width:150},{dataField:oD.MarginType,component:"Margin Type",width:100},{dataField:oD.Type,component:"Type",width:110},{dataField:oD.Amount,component:"Amount",width:110},{dataField:oD.Asset,component:"Asset",width:110},{dataField:oD.Pair,component:"Pair",width:150},{dataField:oD.TradeID,component:"Trade ID",width:100}],d=t.length?t.map((e,t)=>{let r=e.baseAsset,n=e.quoteAsset,i=e.quoteAsset===im?(null==e?void 0:e.asset)==iP.bC.INR?iv:iA:"INR",l=e.quoteAsset===im?(null==e?void 0:e.asset)==iP.bC.INR?"warning":"info":"default";return{[oD.Date]:(0,T.Y)(iR,{title:(0,sq.GP)(new Date(e.time),"dd MMM yy"),subtitle:(0,sq.GP)(new Date(e.time),"HH:mm:ss"),style:a.Wp.ml(16)}),[oD.MarginType]:(0,T.FD)(a.YD,{type:l,children:[(0,T.Y)(a.In,{name:(null==e?void 0:e.asset)===iP.bC.INR?"inr-m":"usdt-m"}),(0,T.Y)("span",{style:{marginLeft:"4px"},children:i})]}),[oD.Type]:(0,T.Y)(iR,{title:(e=>"REALIZED_PNL"===e?"Realised P&L":e.split("_").map(e=>"gst"===e.toLowerCase()?e.toUpperCase():"on"==e.toLowerCase()?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "))(e.type)}),[oD.Amount]:(0,T.Y)(iR,{title:(0,T.FD)("span",{children:[sk(Math.abs(e.amount),"INR"===e.asset?sR:sB)," "]}),style:(0,u.AH)({span:{color:0===e.amount?a.Tj.Zeb_Solid_Light_Blue:e.amount>0?a.Tj.Zeb_Solid_Green:a.Tj.Zeb_Solid_Red}},"","")}),[oD.Asset]:(0,T.Y)(iR,{title:e.asset}),[oD.Pair]:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,{gap:a.Wp.remConverter(8)},"",""],children:[(0,T.Y)("img",{src:e.iconUrl,height:20,width:20}),(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.p0.B5_12_semibold,"",""],children:[r,"/",n]})]}),[oD.TradeID]:e.tradeId>0?(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.g(4),"",""],children:[e.tradeId,(0,T.Y)(a.K0,{icon:"copy",type:"link",onClick:()=>oj(e.tradeId.toString()).then(()=>(0,eh.A)({type:"success",title:"Trade ID copied!",description:"Trade ID copied to clipboard successfully."}))})]}):"---"}}):[],p=[...Array(10)].map(()=>({[oD.Date]:(0,T.Y)(a.WA,{height:18,width:100,style:a.Wp.ml(16)}),[oD.MarginType]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Type]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Amount]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Asset]:(0,T.Y)(a.WA,{height:18,width:100}),[oD.Pair]:(0,T.Y)(a.WA,{height:18,width:150}),[oD.TradeID]:(0,T.Y)(a.WA,{height:18,width:100})}));return(0,T.Y)(iw,{headers:c,rows:n===ld.VI.REQUEST&&1===r.currentPage?p:d,noResultScreen:(0,T.Y)(ls,{tabType:ia.TransactionHistory,isFilterApplied:!1,onClick:ek.A}),style:(0,u.AH)({"@media (max-width: 800px)":{width:t.length?"fit-content":"auto"}},"",""),styleData:(0,u.AH)({padding:"".concat(a.Wp.remConverter(15)," ").concat(a.Wp.remConverter(2))},"",""),fetchMore:()=>{n!==ld.VI.SUCCESS||r.lastPage||d.length!==20*r.currentPage||lT((null==o?void 0:o.access_token)||"",r.currentPage+1,r.timeStamp,l)},isLoading:1!==r.currentPage&&n===ld.VI.REQUEST})});var cQ={name:"bjn8wh",styles:"position:relative"};let cJ=e=>{let{allMarginOrdersCount:t,inrOrdersCount:r,usdtOrdersCount:n,selectedCount:l,selectedTableMargin:o,isCoachmarkVisible:c,tabType:d}=e,{0:u,1:h}=(0,i.useState)(!1);return(0,s.wA)(),(0,T.FD)("div",{css:cQ,children:[(0,T.FD)("div",{css:[(0,p.sM)(4),a.p0.B5_12_semibold,"",""],onClick:e=>{e.stopPropagation(),h(!0)},children:["Margin Type: ",o," (",c?4:l,")",(0,T.Y)(a.In,{name:u?"arrow-up":"arrow-down",style:(0,p.Kk)(20,a.Tj.Zeb_Solid_Bright_Blue)})]}),u&&(0,T.Y)(iG,{selected:o,options:[{title:"All (".concat(t,")"),value:iP.Tr.All},{title:"INR (".concat(r,")"),value:iP.Tr.INR},{title:"USDT (".concat(n,")"),value:iP.Tr.USDT}],onChange:e=>{var t;t=d===ia.Positions?{position:e}:{openOrder:e},lv({type:lc.X.SET_TABLE_MARGIN_TAB,payload:t}),h(!1)},onClose:()=>h(!1),style:(0,p.pg)(100)})]})},c0=(0,u.AH)({position:"fixed",bottom:a.Wp.remConverter(16),left:"20vw",alignSelf:"center",minWidth:a.Wp.remConverter(610),width:"60vw",zIndex:2},"",""),c1=(0,s.Ng)(function(e){return{closeAllApiStatus:e.status.closeAllApi}})(e=>{let{orderCount:t,selectedMarginType:r,tabType:n,closeAllApiStatus:l}=e,{userInfo:o,subAccountId:s}=(0,i.useContext)(ds),c=(0,i.useRef)(null),{0:d,1:u}=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[c]);let p=async()=>{n===ia.Positions?await lO((null==o?void 0:o.access_token)||"",r,()=>{lA((null==o?void 0:o.access_token)||"",s)},s):await lY((null==o?void 0:o.access_token)||"",r,()=>{lb((null==o?void 0:o.access_token)||"",1,null,s)},s),u(!1)},h=n===ia.Positions?"Close ".concat(r," positions?"):"Cancel ".concat(r," open orders?"),g=n===ia.Positions?"This action will settle all your ".concat(r===iP.Tr.All?"":r," open positions at market price."):"This action will cancel your all ".concat(r===iP.Tr.All?"":r," open orders."),m=n===ia.Positions?"CLOSE ".concat(r," POSITIONS"):"CANCEL ".concat(r," ORDERS");return(0,T.FD)("div",{children:[(0,T.FD)(a.$n,{onClick:()=>u(!0),type:"link",size:"small",children:[n===ia.Positions?"CLOSE":"CANCEL"," ALL"]}),d?(0,T.Y)("div",{css:c0,ref:c,children:(0,T.Y)(ik,{orderCount:t,title:h,description:g,buttonText:m,onClick:p,cancelInprogress:l===ld.VI.REQUEST,onClose:()=>u(!1)})}):null]})});var c2=r(59860);let c4=["side"],c8=["type"];function c5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function c6(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?c5(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c5(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let c3=e=>{let{isOpen:t,onOpen:r,onClose:n,tabType:l,accessToken:o}=e,{subAccountId:s}=(0,i.useContext)(ds),{0:c,1:d}=(0,i.useState)({quoteCurrency:{list:[],title:"Quote Currency",icon:"income-source"},pairs:{list:[],title:"Pair",icon:"coins",allSelect:!0,searchable:!0},side:{list:[{id:"buy",name:"Buy",icon:"negative",iconColor:a.Tj.Zeb_Solid_Green},{id:"sell",name:"Sell",icon:"positive",iconColor:a.Tj.Zeb_Solid_Red}],title:"Side",icon:"side-2"},type:{list:[],title:"Type",icon:"reports"}});(0,i.useEffect)(()=>{o&&(async()=>{let{pairs:e,types:t,quoteCurrencies:r}=await lE(o,s),n=t.map(e=>({id:e,name:"REALIZED_P&L"===e?"Realised P&L":e.length?e[0]+e.slice(1).replace(/_/g," ").toLowerCase():""})),i=null==r?void 0:r.map(e=>({id:e.code,name:e.code,fullName:e.name,imgUrl:e.iconLightTheme})),l=null==e?void 0:e.map(e=>({id:e.pair,name:e.pair,imgUrl:e.iconURL}));d(c6(c6({},c),{},{type:c6(c6({},c.type),{},{list:n}),quoteCurrency:c6(c6({},c.quoteCurrency),{},{list:i}),pairs:c6(c6({},c.pairs),{},{list:l})}))})()},[o]);let u=async(e,t)=>{let r="marginAsset=".concat((e.quoteCurrency||[]).join(",")),n="&pair=".concat((e.pairs||[]).join(",")),i=l!==ia.TransactionHistory?"&side=".concat((e.side||[]).join(",")):"",a=l===ia.TransactionHistory?"&type=".concat(encodeURIComponent((e.type||[]).join(","))):"",c="&from=".concat(t.startDate,"&to=").concat(t.endDate),d=l===ia.OrderHistory?"orders-history":l===ia.TradeHistory?"trades-history":l===ia.TransactionHistory?"txn-history":"",u=await lI(o||"",d,r+n+i+a+c,s);200===u.statusCode?u.data?(0,eh.A)({type:e7.C.success,title:"Statements Sent Successfully",description:u.statusDescription}):(0,eh.A)({type:e7.C.info,title:"No data found",description:u.statusDescription}):429===u.statusCode?(0,eh.A)({type:e7.C.info,title:"Daily Limit Exceeded",description:u.customMessage}):(0,eh.A)({type:e7.C.error,title:"Error",description:"Something went wrong, please try again later."})};return(0,T.Y)(f.Cu,{isOpen:t,onOpen:r,onClose:n,list:(()=>{if(l===ia.TransactionHistory){let{side:e}=c;return(0,c2.A)(c,c4)}{let{type:e}=c;return(0,c2.A)(c,c8)}})(),filterIds:{},type:el.R.Statement,overlayStyle:(0,p.pg)(3),onSendStatement:u,statementTitle:(()=>{switch(l){case ia.OrderHistory:return"Order History Statement";case ia.TradeHistory:return"Trade History Statement";case ia.TransactionHistory:return"Transaction History Statement";default:return"Send Statement"}})(),statementButtonText:"Send Statement"},l)};var c9=r(12692);function c7(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function de(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c7(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c7(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class dt{constructor(){this.socket=null,this.currentAuth=null}static getInstance(){return dt.instance||(dt.instance=new dt),dt.instance}connect(e,t){let r=de({token:e},null!=t&&""!==t&&{subAccountId:t}),n=!this.currentAuth||this.currentAuth.token!==r.token||this.currentAuth.subAccountId!==r.subAccountId;return this.socket&&n&&(this.socket.disconnect(),this.socket=null,this.currentAuth=null),this.socket||(this.currentAuth=r,this.socket=(0,c9.io)("".concat(lu.k1,"/auth-stream"),{transports:["websocket"],forceNew:!0,auth:de({token:e},null!=t&&""!==t&&{subAccountId:t})})),this.socket}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null,this.currentAuth=null)}}function dr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function dn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?dr(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let di=e=>{let{subAccountId:t}=e,r=(0,s.wA)(),{userInfo:n}=(0,s.d4)(e=>e.shared.user),l=(0,s.d4)(e=>e.futuresOrders.positions),o=(0,s.d4)(e=>e.futuresOrders.openOrders);return(0,i.useEffect)(()=>()=>{dt.getInstance().disconnect()},[t,null==n?void 0:n.access_token]),(0,i.useEffect)(()=>{if(null!=n&&n.access_token){let e=dt.getInstance().connect(n.access_token,t);if(e)return e.on("connect",()=>{}),e.on("orderFilled",e=>{r({type:lc.X.SET_OPEN_ORDERS,payload:o.filter(t=>t.clientOrderId!==e.clientOrderId)}),(0,eh.A)({title:"Order Filled",type:e7.C.success})}),e.on("orderPartiallyFilled",e=>{r({type:lc.X.SET_OPEN_ORDERS,payload:o.map(t=>t.clientOrderId===e.clientOrderId?dn(dn({},t),{},{filledAmount:e.cumQty}):t)})}),e.on("orderCancelled",e=>{r({type:lc.X.SET_OPEN_ORDERS,payload:o.filter(t=>t.clientOrderId!==e.clientOrderId)})}),e.on("orderFailed",e=>{(0,eh.A)({title:"Order Failed",type:e7.C.error}),r({type:lc.X.SET_OPEN_ORDERS,payload:o.filter(t=>t.clientOrderId!==e.clientOrderId)})}),e.on("newOrder",e=>{let t=[e,...o.filter(t=>t.clientOrderId!==e.clientOrderId)];r({type:lc.X.SET_OPEN_ORDERS,payload:t})}),e.on("newPosition",e=>{let t=[e,...l.filter(t=>t.positionId!==e.positionId)];r({type:lc.X.SET_POSITIONS,payload:t})}),e.on("updatePosition",e=>{r({type:lc.X.SET_POSITIONS,payload:l.map(t=>t.positionId===e.positionId?dn(dn({},t),e):t)})}),e.on("closePosition",e=>{r({type:lc.X.SET_POSITIONS,payload:l.filter(t=>t.positionId!==e.positionId)})}),e.on("balanceUpdate",e=>{r({type:"INR"===e.asset?lc.X.SET_WALLET_BALANCE:lc.X.SET_WALLET_BALANCE_USDT,payload:{availableBalance:e.updatedWalletBalance,withdrawableBalance:e.updatedAvailableBalance,lockedBalance:e.updatedLockedBalance}})}),e.on("autoTopupSuccess",e=>{(0,eh.A)({title:"Auto Top-up Successful",description:"Auto top-up done successfully for ".concat(e.contractPair,"."),type:e7.C.success})}),e.on("autoTopupFailed",e=>{(0,eh.A)({title:"Auto margin top-up stopped",description:"Auto top-up has been disabled for ".concat(e.contractPair," due to low wallet balance."),type:e7.C.error}),r({type:lc.X.SET_POSITIONS,payload:l.map(t=>t.positionId===e.positionId?dn(dn({},t),{},{autoTopUpEnabled:!1}):t)})}),()=>{e.off("orderFilled"),e.off("orderPartiallyFilled"),e.off("orderCancelled"),e.off("orderFailed"),e.off("newOrder"),e.off("newPosition"),e.off("updatePosition"),e.off("closePosition"),e.off("balanceUpdate"),e.off("autoTopupSuccess"),e.off("autoTopupFailed")}}},[null==n?void 0:n.access_token,t,o,l,r]),(0,T.Y)(T.FK,{})};class dl{constructor(){this.socket=null}static getInstance(){return dl.instance||(dl.instance=new dl),dl.instance}connect(){return this.socket||(this.socket=(0,c9.io)(lu.xH,{transports:["websocket"]})),this.socket}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null)}}let da=()=>{let e=(0,s.wA)();return(0,i.useEffect)(()=>{let t=dl.getInstance().connect();return t&&t.on("allContractDetails",t=>{e({type:lc.X.SET_ALL_CONTRACT_DETAILS,payload:t})}),()=>{t.off("allContractDetails")}},[]),(0,T.Y)(T.FK,{})},ds=(0,i.createContext)({walletData:{balance:null,balanceUsdt:null},allContractDetails:null,userInfo:null,coinList:[],currentPair:"",email:"",currencyList:[],conversionRate:0,fetchUserWalletBalance:()=>{},updateWalletBalanceCallback:(e,t)=>{},subAccountId:void 0}),dc=e=>{let{signIn:t,walletData:r,allContractDetails:n,userInfo:l,coinList:o,currentPair:c,email:d,currencyList:u,conversionRate:p,fetchUserWalletBalance:h,updateWalletBalanceCallback:g,subAccountId:m,isSubAccountOrders:v=!1}=e;(0,s.wA)();let{0:A,1:b}=(0,i.useReducer)(id,ic),{positions:y,openOrders:f,selectedTableMargin:_}=(0,s.d4)(e=>e.futuresOrders),{0:S,1:C}=(0,i.useState)(v?ia.OpenOrders:ia.Positions),E=Object.values(ia);iO(e=>{switch(e.join()){case[iP.D$.SHIFT,iP.D$.LEFT].join():C(e=>{let t=E.indexOf(e);return E[(t-1+E.length)%E.length]});break;case[iP.D$.SHIFT,iP.D$.RIGHT].join():C(e=>{let t=E.indexOf(e);return E[(t+1)%E.length]});break;case[iP.D$.CTRL,iP.D$.SHIFT,iP.D$.P].join():lO((null==l?void 0:l.access_token)||"",iP.Tr.All,()=>{lA((null==l?void 0:l.access_token)||"",m)},m);break;case[iP.D$.CTRL,iP.D$.SHIFT,iP.D$.O].join():lY((null==l?void 0:l.access_token)||"",iP.Tr.All,()=>{lb((null==l?void 0:l.access_token)||"",1,null,m)},m)}}),(0,i.useEffect)(()=>{null!=l&&l.loggedIn&&lb((null==l?void 0:l.access_token)||"",1,null,m)},[m,null==l?void 0:l.access_token,null==l?void 0:l.loggedIn]);let I=(0,i.useMemo)(()=>{switch(S){case ia.OpenOrders:return(0,T.Y)(cK,{});case ia.OrderHistory:return(0,T.Y)(cz,{});case ia.TradeHistory:return(0,T.Y)(cX,{});case ia.TransactionHistory:return(0,T.Y)(c$,{});default:return(0,T.Y)(sH,{})}},[S]),{allPositionsCount:D,allOpenOrdersCount:P}=(0,i.useMemo)(()=>({allPositionsCount:y.length,allOpenOrdersCount:f.length}),[f.length,y.length]),{inrPositiosCount:O,inrOpenOrdersCount:Y}=(0,i.useMemo)(()=>{let e=y.filter(e=>e.marginAsset===iP.Tr.INR).length;return console.log("openOrders",f,typeof f),{inrPositiosCount:e,inrOpenOrdersCount:null==f?void 0:f.filter(e=>e.marginAsset===iP.Tr.INR).length}},[f,y]),{usdtPositiosCount:w,usdtOpenOrdersCount:F}=(0,i.useMemo)(()=>({usdtPositiosCount:null==y?void 0:y.filter(e=>e.marginAsset===iP.Tr.USDT).length,usdtOpenOrdersCount:f.filter(e=>e.marginAsset===iP.Tr.USDT).length}),[f,y]),R=(0,i.useMemo)(()=>_.position===iP.Tr.INR?O:_.position===iP.Tr.USDT?w:D,[D,O,_.position,w]),N=(0,i.useMemo)(()=>_.openOrder===iP.Tr.INR?Y:_.openOrder===iP.Tr.USDT?F:P,[P,Y,_.openOrder,F]),B=v?[{title:"Open Orders (".concat(P,")"),tab:ia.OpenOrders,style:a.Wp.mr(12)},{title:"Order History",tab:ia.OrderHistory,style:a.Wp.mr(12)},{title:"Trade History",tab:ia.TradeHistory,style:a.Wp.mr(12)},{title:"Transaction History",tab:ia.TransactionHistory,style:a.Wp.mr(12)}]:[{title:"Positions (".concat(D,")"),tab:ia.Positions,style:a.Wp.mr(12)}];return(0,T.FD)(ds.Provider,{value:{walletData:r,allContractDetails:n,userInfo:l,coinList:o,currentPair:c,email:d,currencyList:u,conversionRate:p,fetchUserWalletBalance:h,updateWalletBalanceCallback:g,subAccountId:m}
1,children:[S===ia.OpenOrders&&f.length>0&&(0,T.FD)(T.FK,{children:[(0,T.Y)(di,{subAccountId:m}),(0,T.Y)(da,{})]}),(0,T.FD)("div",{css:[n5,"",""],children:[(0,T.FD)("div",{css:n6,children:[(0,T.Y)(a.tU,{selectedTab:S,tabsList:B,onChange:e=>{C(e)},style:n3,type:"primary"}),null!=l&&l.loggedIn?(0,T.FD)("div",{css:n9,children:[S===ia.Positions&&D?(0,T.FD)(T.FK,{children:[(0,T.Y)(cJ,{allMarginOrdersCount:D,inrOrdersCount:O,usdtOrdersCount:w,selectedCount:R,selectedTableMargin:_.position,tabType:S,isCoachmarkVisible:!1}),R>0?(0,T.Y)(c1,{tabType:ia.Positions,orderCount:R,selectedMarginType:_.position}):null]}):null,S===ia.OpenOrders&&P?(0,T.FD)(T.FK,{children:[(0,T.Y)(cJ,{allMarginOrdersCount:P,inrOrdersCount:Y,usdtOrdersCount:F,selectedCount:N,selectedTableMargin:_.openOrder,tabType:S,isCoachmarkVisible:!1}),N>0?(0,T.Y)(c1,{tabType:ia.OpenOrders,orderCount:N,selectedMarginType:_.openOrder}):null]}):null,[ia.OrderHistory,ia.TradeHistory,ia.TransactionHistory].includes(S)?(0,T.Y)("div",{onClick:()=>b({type:is.SET_STATEMENT_TAB,value:!0,tab:S}),children:(0,T.Y)(a.In,{name:"send-statement",style:n7})}):null]}):null]}),(0,T.Y)(a.cG,{spacing:0,spacingTop:-2,height:2}),(0,T.Y)(c3,{isOpen:""!==A.statementTab,onOpen:()=>{b({type:is.SET_STATEMENT_TAB,value:!0,tab:S})},onClose:()=>{b({type:is.SET_STATEMENT_TAB,tab:"",value:!1})},tabType:S,accessToken:(null==l?void 0:l.access_token)||""}),null!=l&&l.loggedIn?I:(0,T.FD)("div",{css:ie,children:[(0,T.Y)("div",{css:it,children:"Keep track of all your orders in one place"}),(0,T.Y)("div",{css:ir,children:"Sign up or Login to get started"}),(0,T.Y)("div",{css:ii,children:(0,T.Y)(a.$n,{type:"primary",onClick:t,size:"large",children:"Get started"})})]})]})]})};var dd=r(81908);let du=e=>{var t,r;let{subAccountId:n,isSubAccountOrders:l=!0}=e,o=(0,s.wA)(),a=(0,i.useRef)(null),c=(0,i.useRef)(null),d=(0,s.d4)(e=>e.shared.user.userInfo),u=(0,s.d4)(e=>e.shared.user.userStatus),p=(0,s.d4)(e=>e.futures.futuresBalance),h=(0,s.d4)(e=>e.futures.futuresBalanceUsdt);(0,i.useEffect)(()=>{let e=async()=>{(0,ro.EY)((e,t,r)=>{e&&t&&(a.current=t)});let e=await (0,ro.U)();e&&(c.current=e)};return a.current&&c.current?void 0:(e(),()=>{let e=dt.getInstance(),t=dl.getInstance();e.disconnect(),t.disconnect()})},[]),(0,i.useEffect)(()=>{(0,ro.gD)(void 0,n||"")},[n]);let g=(0,s.d4)(e=>e.futuresOrders.allContractDetails)||null;return(0,T.Y)(dc,{signIn:ek.A,walletData:{balance:p||null,balanceUsdt:h||null},allContractDetails:g,userInfo:d||null,coinList:(null==(t=a.current)?void 0:t.pairs)||[],currentPair:"",email:(null==u?void 0:u.email)||"",currencyList:(null==(r=a.current)?void 0:r.quoteCurrencies)||[],conversionRate:0,fetchUserWalletBalance:()=>{(0,ro.gD)(void 0,n||"")},updateWalletBalanceCallback:(e,t)=>{o({type:e===im?dd.X.WALLET_BALANCE_USDT:dd.X.WALLET_BALANCE,payload:t})},subAccountId:n,isSubAccountOrders:l})};function dp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function dh(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?dp(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dp(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let dg=(0,rm.y)(n2.ZN),dm=e=>{let{onCreateSubAccountClick:t,coachHighlightTarget:r,showCoachmarkWalkthrough:n=!1}=e,o=(0,l.useRouter)(),{0:c,1:d}=(0,i.useState)(""),{0:u,1:h}=(0,i.useState)(n2.ZN.SPOT),g=(0,s.d4)(e=>e.subAccountsNew.subAccountsList);(0,r8.Y)({queryKey:eg.X.ORDER_TYPE,state:u,setState:h,isValid:dg});let m=null!==g&&0===g.length;return(0,T.FD)("div",{css:[a.vE.flexColumn,a.Wp.heightPercentage(100),"",""],children:[(0,T.FD)("div",{css:nQ,children:[(0,T.Y)("div",{css:[r===_.fU.STEP_4_ORDERS_ACCOUNT_LIST&&S.iQ,"",""],children:(0,T.Y)(nX.A,{value:c,onChange:e=>{d(e)},style:(0,p.Ck)(280),coachHighlightTarget:r,showCoachmarkWalkthrough:n})}),(0,T.Y)("div",{css:[r===_.fU.STEP_5_ORDERS_TYPE&&S.iQ,"",""],children:(0,T.Y)(rr.A,{placeholder:"Spot",selected:u,onChange:e=>{h(e),o.replace({pathname:o.pathname,query:dh(dh({},o.query),{},{[eg.X.ORDER_TYPE]:e})},void 0,{shallow:!0})},options:n2.Bs,maxRows:6,rowHeight:44,search:{placeholder:"",value:"",onChange:()=>{}},style:(0,p.Ck)(150),openDropdown:r===_.fU.STEP_5_ORDERS_TYPE,dropdownId:(0,_.gM)(_.fU.STEP_5_ORDERS_TYPE)})})]}),(0,T.Y)("div",{css:[a.Wp.mt(20),a.Wp.heightPercentage(100),"",""],children:m?(0,T.Y)(ts,{onCreateSubAccountClick:()=>{t()},style:nJ}):(0,T.FD)(T.FK,{children:[u===n2.ZN.CRYPTO_PACK&&(0,T.Y)(n1.A,{subAccountId:c}),u===n2.ZN.SPOT&&c&&(0,T.Y)(n0.A,{subAccountId:c}),u==n2.ZN.FUTURES&&(0,T.Y)(du,{subAccountId:c})]})})]})},dv=(0,u.AH)([a.p0.B3_16_semibold,a.Wp.mb(16)],"",""),dA=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedBetween,{height:a.Wp.remConverter(36)}],"",""),db=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(12),width:"100%"}],"","");a.vE.flexAlignCenter,a.Wp.remConverter(4),a.p0.B4_14_regular,a.Wp.remConverter(12),a.Wp.remConverter(12),a.Tj.Zeb_Solid_Light_Blue,a.Wp.remConverter(12),a.p0.B5_12_regular,a.Tj.Zeb_Solid_Light_Blue,a.vE.flexAlignCenter,a.Wp.remConverter(8),a.vE.flexAlignCenter,a.Wp.remConverter(8);let dy=(0,u.AH)([{minWidth:a.Wp.remConverter(280),display:"flex",flexDirection:"column",gap:a.Wp.remConverter(12)}],"",""),df=(0,u.AH)([a.vE.flexJustifiedBetween,a.vE.flexAlignCenter,{gap:a.Wp.remConverter(8),"&:not(:last-child)":{borderBottom:"1px solid ".concat(a.Tj.Zeb_Solid_Dark_Blue)}}],"",""),d_=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(8)}],"",""),dS=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(4)}],"","");a.Wp.remConverter(450),a.Tj.Zeb_Solid_Dark_Blue,a.Wp.remConverter(8),a.Wp.remConverter(20);
1let dT=(0,u.AH)({height:"100%",minHeight:a.Wp.remConverter(450),width:"100%",backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,borderRadius:a.Wp.remConverter(8),marginTop:a.Wp.remConverter(20),display:"flex",justifyContent:"center",alignItems:"center"},"","");var dC=r(33074),dE=r(75348),dI=r(99566),dD=r(88679);let dP=e=>{let{subAccountId:t,userCurrency:r,packQuoteCurrency:n}=e,l=(0,s.wA)(),{connection:o}=(0,dD.F)(),a=(0,s.d4)(e=>e.cryptoPacks.selectedCurrency),c=(0,i.useCallback)(e=>{l({type:dI.X2.SELECTED_CURRENCY,payload:e})},[l]);return(0,i.useEffect)(()=>{let e=(null==n?void 0:n.trim())||r;e&&e!==a&&l({type:dI.X2.SELECTED_CURRENCY,payload:e})},[n,r,a,l]),(0,T.Y)(dE.Ay,{subAccountId:t,isUnderSubAccount:!0,showWalkthrough:!1,currentState:0,setCurrentState:ek.A,setWalkthrough:ek.A,setSelectedTab:ek.A,setToggle:ek.A,connection:o,setSelectedCurrency:c})};var dO=r(88009),dY=r(19076),dw=r(98088),dF=r(39263);let dR=function(e){return e.selectDetails="selectDetails",e.otpVerification="otpVerification",e.pinVerification="pinVerification",e.resultScreen="resultScreen",e}({});var dN=r(22352);let dB=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),dx=(0,u.AH)([a.p0.B4_14_semibold,{color:a.Tj.Zeb_Solid_White,backgroundColor:a.Tj.Zeb_Solid_Dark_Blue,padding:"".concat(a.Wp.remConverter(8)," ").concat(a.Wp.remConverter(12)),borderRadius:a.Wp.remConverter(8),width:"100%"}],"",""),dk=(0,u.AH)([a.vE.flexJustifiedBetween,a.vE.flexAlignCenter,a.Wp.widthPercentage(100)],"",""),dj=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),dW=(0,u.AH)([a.p0.B4_14_semibold,{color:a.Tj.Zeb_Solid_White}],"",""),dL=(0,u.AH)([a.p0.B4_14_regular,p.gO,{minWidth:0}],"",""),dM=(0,u.AH)([a.p0.B4_14_semibold,p.gO,{minWidth:0}],"",""),dH=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(8)}],"",""),dU=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Light_Blue,flexShrink:0}],"",""),dq=(0,u.AH)([a.p0.B4_14_regular,{flexShrink:0,whiteSpace:"nowrap",color:a.Tj.Zeb_Solid_Light_Blue}],"",""),dZ=(0,u.AH)([a.vE.flexAlignCenter,{gap:a.Wp.remConverter(4),width:"100%"}],"",""),dV=(0,u.AH)([a.p0.B5_12_regular,{color:a.Tj.Zeb_Solid_Light_Blue,flexShrink:0}],"",""),dK=(0,u.AH)({marginTop:a.Wp.remConverter(12),gap:a.Wp.remConverter(8)},"",""),dG=e=>{var t,r,n;let{coin:l,fromAccountId:o,fromAccountLabel:c,onSuccess:d,onError:u,handleOverlayClickCallback:h}=e,{0:g,1:m}=(0,i.useState)(null),{0:v,1:A}=(0,i.useState)(""),{0:b,1:y}=(0,i.useState)(!1),{0:_,1:S}=(0,i.useState)(""),{0:C,1:E}=(0,i.useState)([]),{0:I,1:D}=(0,i.useState)(!1),{0:P,1:O}=(0,i.useState)(null),Y=(0,s.d4)(e=>e.shared.user.userStatus),w=(null==l?void 0:l.tradeCurrency)||(null==l?void 0:l.coin)||"";null==l||l.quoteCurrency;let F=null!=(t=null==l?void 0:l.availableBalance)?t:0,R=null!=(r=null==l?void 0:l.quantityPrecision)?r:6;(0,i.useEffect)(()=>{b?null==h||h(!1):null==h||h(!0)},[b,h]),(0,i.useEffect)(()=>{let e=!0;return(async()=>{D(!0);try{let t=await (0,ep.nd)(w);if(!e)return;(null==t?void 0:t.statusCode)===200&&Array.isArray(t.data)?E(t.data):E([])}catch(e){console.error(e),E([])}finally{e&&D(!1)}})(),()=>{e=!1}},[w]);let N=(0,i.useMemo)(()=>{var e;let t=parseInt(null!=(e=null==Y?void 0:Y.accountId)?e:"0",10);return C.filter(e=>e.id!==o).map(e=>({accountId:e.id,label:e.label,balance:e.balance,isMaster:t>0&&e.id===t}))},[C,o,null==Y?void 0:Y.accountId]),B=parseFloat(v)||0,x=null!==g&&B>0&&B<=F,k=async()=>{if(o===g)return void(0,eh.A)({title:"Note",description:"From and To accounts cannot be the same",type:"info"});y(!0);try{var e;let t=await (0,ep.vh)({fromAccountId:o,toAccountId:g,amount:B,currency:w,transferType:tz.SPOT_CRYPTO,pin:"",verificationId:""});if(null!=t&&t.error)return void O(t.error);let r=(null==(e=N.find(e=>e.accountId===g))?void 0:e.label)||"";(null==t?void 0:t.statusCode)===200&&t.data?d({fromAccountId:o,toAccountId:g,toAccountLabel:r,quantity:B,coin:w,currency:w,transferType:tz.SPOT_CRYPTO,verificationId:t.data.verificationId||"",verificationIntId:t.data.verificationIntId||0,status:"success"}):u({fromAccountId:o,toAccountId:g,toAccountLabel:r,quantity:B,coin:w,currency:w,transferType:tz.SPOT_CRYPTO,verificationId:"",verificationIntId:0,status:"error"})}catch(e){console.error(e),(0,eh.A)({title:"Assets Transferred Failed!",description:"Assets transfer failed due to an unexpected error. Please try again.",type:"error"})}finally{y(!1)}};return P?(0,T.Y)(f.nE,{error:P,onClose:()=>O(null)}):(0,T.Y)(ey.A,{header:"Transfer ".concat(w),primaryButtonText:"Transfer",primaryButtonClick:k,isPrimaryCtaLoading:b,disablePrimaryBtn:!x||b,children:(0,T.FD)("div",{css:[(0,p.H2)([20,32]),a.vE.flexColumn,a.Wp.g(20),"",""],children:[(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:dB,children:"From Account"}),(0,T.Y)("div",{css:dx,children:c})]}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.Y)("span",{css:dB,children:"To Account"}),(0,T.Y)(rr.A,{placeholder:"Select",selected:null!=(n=null==g?void 0:g.toString())?n:"",onCh
1ange:e=>m(parseInt(e,10)),options:N.filter(e=>e.isMaster||e.accountId!==o).map(e=>{let t="".concat(e.balance.toFixed(R)," ").concat(w);return{label:(0,T.FD)("div",{css:dZ,children:[(0,T.FD)("span",{css:dL,children:[e.label,e.isMaster&&(0,T.Y)("span",{css:dq,children:" (Master Account)"})]}),(0,T.Y)(a.In,{name:"separator",style:(0,p.Kk)(12,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)("span",{css:dV,children:t})]}),displayLabel:(0,T.FD)("div",{css:dH,children:[(0,T.FD)("span",{css:dM,children:[e.label,e.isMaster&&(0,T.Y)("span",{css:dq,children:" (Master Account)"})]}),(0,T.FD)("span",{css:dU,children:["(",t,")"]})]}),value:e.accountId.toString()}}),disabled:I,maxRows:5,rowHeight:44,enableSearch:!1,search:{placeholder:"",value:"",onChange:()=>{},onClear:()=>{}}})]}),(0,T.FD)("div",{css:(0,p.wh)(4),children:[(0,T.FD)("div",{css:dk,children:[(0,T.Y)("span",{css:dB,children:"Quantity"}),(0,T.FD)("span",{css:dj,children:["Avbl. Quantity ",F.toFixed(R)," ",w]})]}),(0,T.Y)(a.pd,{label:"",placeholder:"Enter Quantity",value:v,onChange:e=>A(e.value),type:"number",invalid:B>F,errorText:B>F?"Insufficient balance. Max available: ".concat(F.toFixed(R)," ").concat(w):"",appendItem:(0,T.FD)("div",{css:[a.vE.flexAlignCenter,a.Wp.g(12),"",""],children:[(0,T.Y)(a.In,{name:"separator",style:(0,p.Kk)(20,a.Tj.Zeb_Solid_Light_Blue)}),(null==l?void 0:l.coinIcon)&&(0,T.Y)(rt(),{src:l.coinIcon,alt:w,height:24,width:24}),(0,T.Y)("span",{css:dW,children:w})]})}),(0,T.Y)(a.tU,{tabsList:dN.W,onChange:e=>{S(e),A((F*(100*parseFloat(e))/100).toFixed(R))},selectedTab:_,type:"secondary",style:dK})]})]})})},dz=e=>{let{coin:t,fromAccountId:r,fromAccountLabel:n,onClose:l,handleOverlayClickCallback:o}=e,{0:a,1:c}=(0,i.useState)(dR.selectDetails),{0:d,1:u}=(0,i.useState)(null),{0:p,1:h}=(0,i.useState)(""),{0:g,1:m}=(0,i.useState)(0),{0:v,1:A}=(0,i.useState)(null),b=(0,s.d4)(e=>e.shared.user.userStatus),y=e=>{u(e),c(dR.resultScreen),(0,ep.nk)()},_=e=>{u(e),c(dR.resultScreen)},S=e=>d?(0,ep.vh)({fromAccountId:d.fromAccountId,toAccountId:d.toAccountId,amount:d.quantity,currency:d.currency,transferType:d.transferType,pin:e,verificationId:p}):void(0,e8.Ax)("Transfer data not found"),C=()=>{if(!d)return;let e=d.quantity.toFixed(6);(0,eh.A)({title:"Assets Transferred Successfully!",description:"".concat(e," ").concat(d.coin,' has been transferred to "').concat(d.toAccountLabel,'".'),type:"success"}),(0,ep.nk)(),l()};return(0,T.Y)(T.FK,{children:v?(0,T.Y)(f.nE,{error:v,onClose:()=>A(null)}):(()=>{var e,i,s,u;switch(a){case dR.selectDetails:return(0,T.Y)(dG,{coin:t,fromAccountId:r,fromAccountLabel:n,onSuccess:y,onError:_,handleOverlayClickCallback:o});case dR.otpVerification:return(0,T.Y)(eG.A,{title:"OTP Verification",description:["Please enter 6 digit OTP sent to your","+".concat(null==b?void 0:b.countryISDCode," ").concat(null==b?void 0:b.mobileNumber),"& regd.","email ID"],verificationINTId:g,verificationId:p,onSuccess:e=>{h(e.verificationId),m(e.verificationIntId),c(dR.pinVerification)},onResendSuccess:e=>{h(e.verificationId),m(e.verificationIntId)},resendOtpType:eG.Z.TransferFund,onError:A});case dR.pinVerification:return(0,T.Y)(f.fV,{title:"PIN Verification",description:"Enter your 4-digit PIN to transfer crypto",onVerifyPin:S,onSuccess:C,onError:A,onForgotPin:t_.F_});case dR.resultScreen:return(0,T.Y)(rs,{status:null!=(e=null==d?void 0:d.status)?e:"success",transferType:tz.SPOT_CRYPTO,amount:null!=(i=null==d?void 0:d.quantity)?i:0,currency:null!=(s=null==d?void 0:d.coin)?s:"",toAccountLabel:null!=(u=null==d?void 0:d.toAccountLabel)?u:"",fromAccountLabel:n,onDone:l,tryAgain:()=>c(dR.selectDetails)});default:return null}})()})};var dX=r(3236);function d$(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function dQ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d$(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d$(Object(r)).forEac
1h(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let dJ=e=>{let{subAccountId:t,selectedAccountLabel:r,fiatCurrency:n,userCurrency:l,isMasterAccountSelected:d,masterAccountId:u}=e,{0:p,1:h}=(0,i.useState)(),{0:g,1:m}=(0,i.useState)(void 0),v=(0,i.useRef)(!0),A=(0,s.d4)(e=>e.shared.user.country.countryId||""),{quickTradeCoins:y}=(0,s.d4)(e=>e.quickTrade);(0,i.useEffect)(()=>{A&&(y.length>0||(0,dC.Eo)({countryCode:A}))},[A,y.length]);let f=(0,i.useCallback)(()=>{m(void 0),h(void 0)},[]),_=(0,i.useCallback)(()=>{m(void 0),h(void 0),v.current=!0},[]),S=(0,i.useCallback)(e=>{v.current=e},[]),C=(0,i.useCallback)(()=>{var e,t,r,n;if(!p)return;let i=y.find(e=>e.pair===p.pair)||y.find(e=>e.tradeCurrency===p.tradeCurrency&&e.quoteCurrency===p.quoteCurrency)||y.find(e=>e.tradeCurrency===p.tradeCurrency);if(i){let e=null!=(r=p.price)?r:0;return dQ(dQ({},(0,dX.Nr)(i,{pair:i.pair,buyPrice:"number"==typeof i.buyPrice?i.buyPrice:e,sellPrice:"number"==typeof i.sellPrice?i.sellPrice:e,priceChangePercent24hr:i.priceChangePercent24hr,priceChangeValue24hr:i.priceChangeValue24hr,volumeTraded24hr:i.volumeTraded24hr})),{},{isOTCTradeEnabled:i.isOTCTradeEnabled,isQtLimitEnabled:null!=(n=i.isQtLimitEnabled)?n:i.isOTCTradeEnabled})}let l=null!=(e=p.price)?e:0;return dQ(dQ({},p),{},{price:l,buyPrice:l,sellPrice:l,isQtLimitEnabled:null!=(t=p.isQtLimitEnabled)?t:p.isOTCTradeEnabled})},[p,y]);return(0,T.FD)(T.FK,{children:[(0,T.Y)(dO.A,{fiatCurrency:n,userCurrency:l,subAccountId:t,isUnderSubAccount:!0,onCoinAction:(e,t)=>{h(e),m(t)},sidePanelType:g,setSidePanelType:ek.A}),(0,T.FD)(a.wv,{open:!!g,onClose:g===b.Q0.quickTrade?f:_,onOverlayClick:()=>{v.current&&(g===b.Q0.quickTrade?f():_())},children:[g===b.Q0.quickTrade&&p&&(0,T.Y)(dw.A,{coin:C(),type:dY.D.sell,panelStep:dF.M5.quickTrade,closeSidePanel:f,accountButtonHandler:()=>{o().push("/subAccount?".concat(eg.X.TAB,"=").concat(c.C$.ASSETS_FIAT))},openSidePanel:(e,t)=>{h(t)},subAccountId:t}),g===b.Q0.TransferCrypto&&p&&(0,T.Y)(dz,{coin:p,fromAccountId:parseInt(d?u:t,10),fromAccountLabel:r,onClose:_,handleOverlayClickCallback:S})]})]})};var d0=r(82227);let d1=()=>(0,T.Y)(ti.A,{image:ed.A.i_zebpay_logo,imageHeight:140,imageWidth:140,title:"No Earn Contracts",description:"You don't have any active earn contracts in this Sub-Account yet."}),d2=(0,u.AH)([(0,p.hj)(28,28),{borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"}],"",""),d4=(0,u.AH)([a.vE.flexAlignCenter,a.vE.flexJustifiedCenter,a.p0.B4_14_semibold,{width:a.Wp.remConverter(28),height:a.Wp.remConverter(28),borderRadius:"50%",backgroundColor:a.Tj.Zeb_Solid_Bright_Blue,color:a.Tj.Zeb_Solid_White,flexShrink:0}],"",""),d8=(0,u.AH)([(0,p.sM)(0),{alignItems:"center"}],"",""),d5=(0,u.AH)([a.p0.B3_16_semibold,p.gO,{color:a.Tj.Zeb_Solid_White,maxWidth:a.Wp.remConverter(120)}],"",""),d6=(0,u.AH)([a.p0.B5_12_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),d3=(0,u.AH)([a.p0.B5_12_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),d9=(0,u.AH)([(0,p.wh)(4)],"",""),d7=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_White}],"",""),ue=(0,u.AH)([(0,p.sM)(4),{alignItems:"center"}],"",""),ut=(0,u.AH)([a.p0.B5_12_regular,{color:a.Tj.Zeb_Solid_Light_Blue,whiteSpace:"nowrap"}],"",""),ur=(0,u.AH)([(0,p.wh)(4),{alignItems:"flex-end"}],"",""),un=(0,u.AH)([(0,p.sM)(4),{alignItems:"baseline"}],"",""),ui=(0,u.AH)([a.p0.B4_14_semibold,{color:a.Tj.Zeb_Solid_White}],"",""),ul=(0,u.AH)([a.p0.B4_14_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),uo=(0,u.AH)([a.p0.B5_12_regular,{color:a.Tj.Zeb_Solid_Light_Blue}],"",""),ua=(0,u.AH)([(0,p.sM)(4),{alignItems:"baseline",justifyContent:"flex-end"}],"",""),us=(0,u.AH)([a.p0.B4_14_semibold,{color:a.Tj.Zeb_Solid_Green_02}],"",""),uc=(0,u.AH)([a.p0.B4_14_semibold,{color:a.Tj.Zeb_Solid_Yellow}],"",""),ud=(0,u.AH)([a.p0.B4_14_semibold,{color:a.Tj.Zeb_Solid_White}],"",""),uu=[18,14,13,13,6,10,6,6,10,4],up=[{dataField:W.Mq.COINS,component:(0,T.Y)("div",{css:a.Wp.ml(14),children:"Coins"}),align:"left"},{dataField:W.Mq.DATE,component:"Start Date",align:"left"},{dataField:W.Mq.PRICE,component:"Principal & Interest",align:"right",isSortable:!0},{dataField:W.Mq.TOTAL,component:"Maturity Value",align:"right"},{dataField:W.Mq.CURRENCY_BASE,component:"",align:"left",isSortable:!0},{dataField:W.Mq.TOTAL_EARNINGS,component:"Accrued Earning",align:"right"},{dataField:W.Mq.CURRENCY_BASE_WITH_TOOLTIP,component:"",align:"left",isSortable:!0},{dataField:W.Mq.STATUS,component:"Status",align:"left",isSortable:!0},{dataField:W.Mq.TYPE,component:"Auto Renewal",align:"center",isSortable:!0},{dataField:W.Mq.MENU,component:"",align:"center"}],uh=[{field:W.Mq.PRICE,key:"principleAmount",type:tu.r3.NUMBER},{field:W.Mq.CURRENCY_BASE,key:"maturityAmount",type:tu.r3.TEXT},{field:W.Mq.CURRENCY_BASE_WITH_TOOLTIP,key:"accruedInterest",type:tu.r3.TEXT},{field:W.Mq.STATUS,key:"contractStatus",type:tu.r3.NUMBER},{field:W.Mq.TYPE,key:"isAutoRenewal",type:tu.r3.NUMBER}];function ug(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function um(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?ug(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ug(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let uv=z.Wp.remConverter(30),uA={name:"zigog8",styles:"display:flex;flex-direction:column;align-items:center"},ub=(0,u.AH)({padding:"1rem ".concat(uv," 0 ").concat(uv),maxHeight:"77vh",overflowY:"auto","@supports (scrollbar-width: none)":{scrollbarWidth:"none"},"@supports not (scrollbar-width: none)":{"&::-webkit-scrollbar":{display:"none"}}},"",""),uy=(0,u.AH)({width:"".concat(z.Wp.remConverter(100)),margin:"0 auto ".concat(z.Wp.remConverter(17))},"",""),uf=(0,u.AH)(um(um({},z.Il.H4_28_bold),{},{textAlign:"center",marginBottom:"1.25rem",color:z.Tj.Zeb_Solid_White}),"",""),u_={name:"og0qdz",styles:"text-align:left;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start"},uS=(0,u.AH)({backgroundColor:z.Tj.Zeb_Solid_Dark_Blue,padding:"0.75rem",borderRadius:"0.5rem",marginBottom:"1rem"},"",""),uT=(0,u.AH)(um(um({},z.Il.B4_14_regular),{},{color:z.Tj.Zeb_Solid_Light_Blue}),"",""),uC=(0,u.AH)({backgroundColor:z.Tj.Zeb_Solid_White,borderColor:z.Tj.Zeb_Solid_White},"",""),uE=(0,u.AH)({display:"flex",justifyContent:"space-between",background:z.Tj.Zeb_Gradient_Dark_Blue,width:"100%",padding:"0.75rem",borderRadius:"0.5rem",marginBottom:"1rem"},"",""),uI=(0,u.AH)(um(um({},z.Il.B5_12_regular),{},{color:z.Tj.Zeb_Solid_Light_Blue}),"",""),uD=(0,u.AH)(um(um({},z.Il.H6_16_semibold),{},{color:z.Tj.Zeb_Solid_Red,textAlign:"center",marginBottom:"0.5rem"}),"",""),uP=(0,u.AH)(um(um({},z.Il.B4_14_regular),{},{textAlign:"center",marginBottom:"1.25rem",color:z.Tj.Zeb_Solid_White}),"",""),uO={name:"1y2mh23",styles:"margin-left:0.25rem"};var uY=r(29076),uw=r(11639);function uF(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function uR(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?uF(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):uF(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let uN=function(e){return e.fastRedemption="4",e.standardRedemption="3",e}({}),uB=e=>{let{cancelEarnDetails:t,onBack:r,onConfirm:n,isLoading:l}=e,{0:o,1:s}=(0,i.useState)(uN.fastRedemption),c=new Date,d=(0,tp.i$)(c,"MMM d, y"),p=null!=t&&t.termPeriod?(0,tp.Nz)(t.termPeriod):"-";return(0,T.Y)(T.FK,{children:(0,T.Y)(f.Ry,{header:"Cancel Earn Transaction",secondaryButtonText:"no go back",secondaryButtonClick:r,primaryButtonText:"confirm exit",primaryButtonClick:()=>n(o),isPrimaryCtaLoading:l,disablePrimaryBtn:l,disableSecondaryBtn:l,children:(0,T.FD)("div",{css:ub,children:[(0,T.FD)("div",{css:uA,children:[(0,T.Y)("img",{css:uy,src:ed.A.ic_verification_status_rejected,alt:"cancel"}),(0,T.Y)("div",{css:uf,children:"Are you sure you want to cancel this transaction?"})]}),(0,T.FD)("div",{children:[(0,T.Y)("p",{css:uD,children:"Your're doing premature withdrawal"}),(0,T.Y)("p",{css:uP,children:"Amount will be credited to your spot wallet after deducting a\n            ".concat(null==t?void 0:t.penaltyRate,"% penalty on accrued earnings on ").concat(d," at 00:00 UTC")})]}),(0,T.FD)("div",{css:uE,children:[(0,T.FD)("div",{children:[(0,T.Y)("p",{css:[uI,a.vE.textAlignmentLeft,"",""],children:"Invested crypto + earnings"}),(0,T.Y)("p",{css:(0,u.AH)(uR(uR({},z.Il.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_White}),"",""),children:"".concat(null==t?void 0:t.principleAmount," ").concat(null==t?void 0:t.currencyCode," | ").concat(null==t?void 0:t.interestRate,"%")})]}),(0,T.FD)("div",{children:[(0,T.Y)("p",{css:uI,children:"Term"}),(0,T.Y)("p",{css:(0,u.AH)(uR(uR({},z.Il.B4_14_semibold),{},{color:a.Tj.Zeb_Solid_White}),"",""),children:p})]})]}),(0,T.Y)("div",{css:uS,children:(0,T.Y)(uw.A,{label:(0,T.Y)("div",{css:[uO,"text-align:left;",""],children:(0,T.Y)(uY.A,{title:"Fast Redemption",subtitle:"The redeemed quantity will be returned today.",subtitleStyles:uT,color:a.Tj.Zeb_Solid_White,textContainerStyles:u_})}),value:uN.fastRedemption,name:uN.fastRedemption,checked:o===uN.fastRedemption,onChange:e=>s(e),checkStyles:uC,mode:"dark"})})]})})})},ux=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return Number.isFinite(e)&&e.toFixed(t).replace(/\.?0+$/,"")||"0"},uk=function(e){return e.CANCEL="Cancel",e}({}),uj=e=>{let{subAccountId:t}=e,{0:r,1:n}=(0,i.useState)(!0),{0:l,1:o}=(0,i.useState)([]),{0:s,1:c}=(0,i.useState)(0),{0:d,1:h}=(0,i.useState)(1),{0:g,1:m}=(0,i.useState)(25),{0:v,1:A}=(0,i.useState)(!1),{0:b,1:y}=(0,i.useState)(),{0:_,1:S}=(0,i.useState)(!1),{sortedData:C,sortState:E,handleSort:I}=(0,tu.GY)(l,uh),D=(0,i.useCallback)(async()=>{n(!0);try{var e,r,i,l;let n=await (0,ep.cX)(Number(t),d,g),a=null!=(e=null==(r=n.data)?void 0:r.list)?e:[];o(a),c(null!=(i=null==(l=n.data)?void 0:l.totalCount)?i:0)}catch(e){console.error("Error fetching earn contracts:",e),o([]),c(0)}finally{n(!1)}},[t,d,g]);(0,i.useEffect)(()=>{D()},[D]);let P=(0,i.useCallback)(e=>{let t=parseInt((null==e?void 0:e.pair)||"0",10),r=l.find(e=>e.contractId===t);r&&(y({contractId:r.contractId,currencyCode:r.currencyCode,currencyName:r.currencyName,interestRate:r.interestRate,penaltyRate:r.penaltyRate,principleAmount:r.principleAmount,termPeriod:r.termPeriod}),A(!0))},[l]),O=(0,i.useCallback)(()=>{A(!1),y(void 0)},[]),Y=(0,i.useCallback)(async e=>{if(b){S(!0);try{let n=await (0,ep.zK)(Number(t),b.contractId,Number(e));if(200===n.statusCode)(0,eh.A)({title:"Contract Cancelled",description:"Your ".concat(b.currencyCode," earn contract has been cancelled successfully."),type:"success"}),O(),D();else{var r;(0,eh.A)({title:"Error",description:null!=(r=n.statusDescription)?r:"Failed to cancel the contract. Please try again.",type:"error"})}}catch(e){console.error("Error closing earn contract:",e),(0,eh.A)({title:"Error",description:"Failed to cancel the contract. Please try again.",type:"error"})}finally{S(!1)}}},[b,O,t,D]),w=(0,i.useMemo)(()=>[{icon:"",iconName:"subtract-circle",label:uk.CANCEL,onClick:P}],[P]),F=(0,i.useMemo)(()=>(r?Array.from({length:Math.max(1,g)},(e,t)=>({contractId:-(t+1),contractNumber:"",depositType:1,contractDate:"",principleAmount:0,maturityAmount:0,interestRate:0,penaltyRate:0,maturityDate:null,ai:0,contractStatus:1,isAutoRenewal:!1,renewalType:0,actualStartDate:null,closureDate:null,disbursedAmount:null,termPeriod:0,currencyCode:"",currencyName:"",icon:""})):C).map(e=>{let t=(e=>{switch(e){case 1:default:return"Active";case 2:return"Matured";case 3:return"Closed";case 4:return"Pre-Mature";case 5:return"Renewed"}})(e.contractStatus),n="Active"===t,i=1===e.depositType?"FIXED":"OPEN",l=e.actualStartDate?(0,tp.i$)(new Date(e.actualStartDate),"dd MMM yy"):"-",o=e.maturityDate?(0,tp.i$)(new Date(e.maturityDate),"dd MMM yy"):"Ongoing",s="".concat(l," - ").concat(o),c=void 0!==e.accruedInterest&&null!==e.accruedInterest?e.accruedInterest:e.ai;return{[W.Mq.COINS]:(0,T.Y)("div",{css:a.Wp.ml(14),children:(0,T.Y)(f.lG,{isLoading:r,height:40,width:180,children:(0,T.FD)("div",{css:(0,p.sM)(12),children:[e.icon?(0,T.Y)("img",{src:e.icon,alt:"",css:d2,draggable:!1}):(0,T.Y)("div",{css:d4,children:(e.currencyCode||"?").charAt(0)}),(0,T.FD)("div",{css:(0,p.wh)(2),children:[(0,T.FD)("div",{css:d8,children:[(0,T.Y)("span",{css:d5,children:e.currencyName}),(0,T.Y)(a.In,{name:"separator",style:(0,p.Kk)(12,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)("span",{css:d6,children:e.currencyCode})]}),(0,T.FD)("div",{css:a.vE.flexAlignCenter,children:[(0,T.FD)("span",{css:d3,children:["ID: ",e.contractId]}),(0,T.Y)(a.In,{name:"separator",style:(0,p.Kk)(12,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)(a.YD,{type:"default",size:"small",children:i})]})]})]})})}),[W.Mq.DATE]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:120,children:(0,T.FD)("div",{css:d9,children:[(0,T.Y)("span",{css:d7,children:e.termPeriod>0?"".concat(e.termPeriod," Days"):"Flexible"}),(0,T.FD)("div",{css:ue,children:[(0,T.Y)(a.In,{name:"calendar",style:(0,p.Kk)(16,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)("span",{css:ut,children:s})]})]})}),[W.Mq.PRICE]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:80,children:(0,T.FD)("div",{css:ur,children:[(0,T.FD)("div",{css:un,children:[(0,T.Y)("span",{css:ui,children:ux(e.principleAmount)}),(0,T.Y)("span",{css:ul,children:e.currencyCode})]}),(0,T.FD)("span",{css:uo,children:[e.interestRate,"%"]})]})}),[W.Mq.TOTAL]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:80,children:(0,T.Y)("div",{css:ua,children:(0,T.Y)("span",{css:ui,children:ux(e.maturityAmount)})})}),[W.Mq.CURRENCY_BASE]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:80,children:(0,T.Y)("div",{css:ua,children:(0,T.Y)("span",{css:ui,children:e.currencyCode})})}),[W.Mq.TOTAL_EARNINGS]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:80,children:(0,T.Y)("div",{css:ua,children:(0,T.Y)("span",{css:ui,children:ux(c)})})}),[W.Mq.CURRENCY_BASE_WITH_TOOLTIP]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:80,children:(0,T.Y)("div",{css:ua,children:(0,T.Y)("span",{css:ui,children:e.currencyCode})})}),[W.Mq.STATUS]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:60,children:(0,T.Y)("span",{css:n?us:uc,children:t})}),[W.Mq.TYPE]:(0,T.Y)(f.lG,{isLoading:r,height:14,width:40,children:(0,T.Y)("span",{css:ud,children:e.isAutoRenewal?"On":"Off"})}),[W.Mq.MENU]:(0,T.Y)(f.lG,{isLoading:r,height:24,width:24,children:(0,T.Y)(d0.A,{coin:{pair:String(e.contractId)},menuItems:w})})}}),[C,r,w,g]),R=!r&&0===s;return(0,T.FD)("div",{css:a.Wp.mt(20),children:[(0,T.Y)(W.Ay,{headers:up,rows:F,columnsSize:uu,isPaginationEnabled:s>25,defaultSortConfig:E,onSortTableValues:I,noTopBorderRadius:!1,padding:(0,u.AH)({padding:(0,p.qb)([12,2])},"",""),tableSpace:200,noSearchResults:R?(0,T.Y)(d1,{}):void 0,pagination:{pageNo:d,pageSize:g,totalCount:s,setPageNo:h,setPageSize:m}}),(0,T.Y)(a.wv,{open:v,onClose:O,children:v&&b&&(0,T.Y)(uB,{cancelEarnDetails:b,onBack:O,onConfirm:Y,isLoading:_})})]})};var uW=r(72419),uL=r(85623);function uM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function uH(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?uM(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):uM(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let uU=(0,rm.y)(e1);var uq={name:"1o3nkn",styles:"margin-left:auto"};let uZ=e=>{let{onCreateSubAccountClick:t,coachHighlightTarget:r,showCoachmarkWalkthrough:n=!1}=e,o=(0,l.useRouter)(),c=(0,s.wA)(),{0:d,1:h}=(0,i.useState)(""),{0:g,1:m}=(0,i.useState)(e1.SPOT),v=(0,s.d4)(e=>e.subAccountsNew.subAccountsList),A=(0,s.d4)(e=>e.futuresOrders.positions),{cryptoHoldingData:b}=(0,s.d4)(e=>e.portfolio),{userStatus:y}=(0,s.d4)(e=>{let{shared:t}=e;return t.user}),_=(0,s.d4)(e=>e.shared.user.country.countryId||""),{quickTradeCoins:S}=(0,s.d4)(e=>e.quickTrade),{cpQuoteCurrencies:C,selectedCurrency:E}=(0,s.d4)(e=>e.cryptoPacks);(0,r8.Y)({queryKey:eg.X.ASSET_TYPE,state:g,setState:m,isValid:uU});let I=(0,i.useMemo)(()=>{var e;return(null==y||null==(e=y.accountId)?void 0:e.toString())||""},[null==y?void 0:y.accountId]),D=(0,i.useMemo)(()=>d===I,[d,I]),P=(null==y?void 0:y.currencyCode)||"INR",O=(null==y?void 0:y.currencyCode)||"INR";(0,i.useEffect)(()=>{_&&(S.length>0||(0,dC.Eo)({countryCode:_}))},[_,S.length]);let Y=(0,i.useMemo)(()=>{var e,t,r,n,i,l,o,s,c;if(!b)return null;let d=(null!=(e=null==(t=b.currentValue)?void 0:t.totalAvailable)?e:0)+(null!=(r=null==(n=b.currentValue)?void 0:n.totalLocked)?r:0),h=null!=(i=b.investedValue)?i:0,g=null!=(l=null==(o=b.overallPnl)?void 0:o.percent)?l:0,m=null!=(s=null==(c=b.overallPnl)?void 0:c.value)?s:0;return(0,T.FD)("div",{css:dy,children:[(0,T.FD)("div",{css:df,children:[(0,T.FD)("div",{css:d_,children:[(0,T.Y)(a.In,{name:"pay-lumpsum",style:(0,p.Kk)(16,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)("span",{css:[a.p0.B4_14_regular,"",""],children:"Current value"})]}),(0,T.FD)("div",{css:dS,children:[(0,T.Y)("span",{css:a.p0.B4_14_regular,children:(0,L.uY)(d,P,2)}),(0,T.Y)("span",{css:eE.wo,children:P})]})]}),(0,T.FD)("div",{css:df,children:[(0,T.FD)("div",{css:d_,children:[(0,T.Y)(a.In,{name:"fees",style:(0,p.Kk)(16,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)("span",{css:a.p0.B4_14_regular,children:"Invested value"})]}),(0,T.FD)("div",{css:dS,children:[(0,T.Y)("span",{css:a.p0.B4_14_regular,children:(0,L.uY)(h,P,2)}),(0,T.Y)("span",{css:eE.wo,children:P})]})]}),(0,T.FD)("div",{css:df,children:[(0,T.FD)("div",{css:d_,children:[(0,T.Y)(a.In,{name:"interest-rate",style:(0,p.Kk)(16,a.Tj.Zeb_Solid_Light_Blue)}),(0,T.Y)("span",{css:a.p0.B4_14_regular,children:"Overall P&L"})]}),(0,T.FD)("div",{css:dS,children:[(0,T.Y)(a.In,{name:(0,ei.uw)(g),style:(0,p.Kk)(10,(0,ei.yC)(g))}),(0,T.FD)("span",{css:(e=>(0,u.AH)([a.p0.B4_14_regular,{color:e>0?a.Tj.Zeb_Solid_Green:e<0?a.Tj.Zeb_Solid_Red:a.Tj.Zeb_Solid_White}],"",""))(g),children:[Math.abs(g).toFixed(2),"%"]}),(0,T.Y)("span",{css:a.p0.B4_14_regular,children:(0,L.uY)(Math.abs(m),P,2)}),(0,T.Y)("span",{css:eE.wo,children:P})]})]})]})},[b,P]),w=g===e1.CRYPTO_PACKS,F=0===C.length,R=(null==E?void 0:E.trim())||O||"INR";(0,i.useEffect)(()=>{g===e1.CRYPTO_PACKS&&_&&(C.length>0||(0,uW.IT)(_))},[g,_,C.length]),(0,i.useEffect)(()=>{var e;if(g!==e1.CRYPTO_PACKS||0===C.length||E)return;let t=sessionStorage.getItem(uL.CP_CURRENCY),r=(t&&C.some(e=>e.code===t)?t:null)||(null==(e=C[0])?void 0:e.code)||O||"INR";c({type:dI.X2.SELECTED_CURRENCY,payload:r})},[g,C,E,c,O]);let N=null!==v&&0===v.length,B=(0,i.useMemo)(()=>{if(!d||!v)return"";let e=v.find(e=>e.accountId.toString()===d);return(null==e?void 0:e.label)||""},[d,v]);return(0,T.FD)("div",{css:[a.vE.flexColumn,a.Wp.heightPercentage(100),"",""],children:[(0,T.Y)(tj,{style:a.Wp.mb(20)}),(0,T.Y)("div",{css:dv,children:"Crypto Overview"}),(0,T.Y)("div",{css:dA,children:(0,T.FD)("div",{css:db,children:[(0,T.Y)(nX.A,{value:d,onChange:e=>{h(e)},style:(0,p.Ck)(280),coachHighlightTarget:r,showCoachmarkWalkthrough:n,extraDisplayContent:Y?(0,T.Y)(a.m_,{content:Y,isStroke:!0,children:(0,T.Y)(a.In,{name:"info",style:(0,p.Kk)(16,a.Tj.Zeb_Solid_Bright_Blue)})}):null,masterAccountIdForMasterTag:I,withMasterAccount:!0}),(0,T.Y)(rr.A,{placeholder:"Spot",selected:g,onChange:e=>{m(e),o.replace({pathname:o.pathname,query:uH(uH({},o.query),{},{[eg.X.ASSET_TYPE]:e})},void 0,{shallow:!0})},options:e2,maxRows:6,rowHeight:44,search:{placeholder:"",value:"",onChange:()=>{}},style:(0,p.Ck)(150)}),w&&(0,T.Y)("div",{css:uq,children:F?(0,T.Y)(f.lG,{isLoading:!0,height:36,width:100}):C.length>1?(0,T.Y)(f.FH,{selected:R,showWalkthrough:!1,showCoachMarks:!1,onChange:e=>{c({type:dI.X2.SELECTED_CURRENCY,payload:e}),sessionStorage.setItem(uL.CP_CURRENCY,e)},options:C,showLightIcon:!0}):null})]})}),N?(0,T.Y)(ts,{onCreateSubAccountClick:()=>{t()},style:dT}):(0,T.FD)(T.FK,{children:[g===e1.SPOT&&d&&(0,T.Y)(dJ,{subAccountId:D?"":d,selectedAccountLabel:D?"".concat(null==y?void 0:y.name," 
1(Master Account)"):B,fiatCurrency:P,userCurrency:O,isMasterAccountSelected:D,masterAccountId:I}),g===e1.CRYPTO_PACKS&&d&&(0,T.Y)(dP,{subAccountId:D?"":d,userCurrency:O,packQuoteCurrency:R}),g===e1.EARN&&d&&(0,T.Y)(uj,{subAccountId:D?"":d},d),g===e1.FUTURES&&d&&(0,T.FD)(T.FK,{children:[A.length>0&&(0,T.FD)(T.FK,{children:[(0,T.Y)(di,{subAccountId:d}),(0,T.Y)(da,{})]}),(0,T.Y)("div",{css:[a.Wp.mt(20),"flex:1;",""],children:(0,T.Y)(du,{subAccountId:D?"":d,isSubAccountOrders:!1})})]})]})]})},uV=e=>{let{onClose:t,maxSubAccountsLimit:r=10}=e;return(0,T.Y)(e6.A,{header:"Limit Reached",image:ed.A.i_zebpay_logo,title:"Sub-Account Limit Reached",description:"You've reached the maximum limit of ".concat(r," Sub-Accounts. To create a new Sub-Account, please freeze an existing one."),primaryButtonText:"GOT IT",primaryButtonClick:t})};var uK=r(28710),uG=r(31527);function uz(e){if(null==e)throw TypeError("Cannot destructure "+e)}var uX=r(69296),u$=r(6677);function uQ(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function uJ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?uQ(Object(r),!0).forEach(function(t){(0,d.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):uQ(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}let u0=e=>{let{run:t,steps:r,currentState:n,setCurrentState:i,onSegmentFinished:l,onTourAborted:o}=e;return(0,T.Y)(uX.Ay,{run:t&&r.length>0,steps:r,continuous:!0,disableScrolling:!0,disableScrollParentFix:!0,disableOverlayClose:!0,tooltipComponent:e=>(0,T.Y)(f.$8,uJ(uJ({},e),{},{onDismiss:o})),callback:e=>{let{index:t,status:r,type:n,action:a}=e;if(r===u$.tO.skipped||"skip"===a||"close"===a){i(0),o();return}if(r===u$.tO.finished){i(0),l();return}"number"==typeof t&&i(t)},styles:{options:{arrowColor:a.Tj.Zeb_Solid_Bright_Blue,overlayColor:"none",zIndex:1e5},spotlight:{padding:0},overlay:{backdropFilter:"blur(10px)",zIndex:0===n?1:5}}})},u1=e=>{let t=Object.assign({},(uz(e),e)),r=(0,i.useMemo)(()=>(0,_.Jq)(_.hC.DASHBOARD_INTRO),[]);return(0,T.Y)(u0,uJ(uJ({},t),{},{steps:r}))},u2=e=>{let t=Object.assign({},(uz(e),e)),r=(0,i.useMemo)(()=>(0,_.Jq)(_.hC.ORDERS),[]);return(0,T.Y)(u0,uJ(uJ({},t),{},{steps:r}))},u4=e=>{let t=Object.assign({},(uz(e),e)),r=(0,i.useMemo)(()=>(0,_.Jq)(_.hC.API_MANAGEMENT),[]);return(0,T.Y)(u0,uJ(uJ({},t),{},{steps:r}))},u8=e=>{let t=Object.assign({},(uz(e),e)),r=(0,i.useMemo)(()=>(0,_.Jq)(_.hC.ASSETS_FIAT),[]);return(0,T.Y)(u0,uJ(uJ({},t),{},{steps:r}))},u5=e=>{let t=Object.assign({},(uz(e),e)),r=(0,i.useMemo)(()=>(0,_.Jq)(_.hC.AUDIT_LOGS),[]);return(0,T.Y)(u0,uJ(uJ({},t),{},{steps:r}))},u6=e=>{let t=Object.assign({},(uz(e),e)),r=(0,i.useMemo)(()=>(0,_.Jq)(_.hC.DASHBOARD_OUTRO),[]);return(0,T.Y)(u0,uJ(uJ({},t),{},{steps:r}))};var u3=r(2699);let u9=(0,rm.y)(c.C$);var u7=function(e){return e.CREATE_SUB_ACCOUNT_LIMIT="createSubAccountLimit",e.KYC_BANK_BLOCKER="kycBankBlocker",e}(u7||{});let pe=()=>{var e,t;let r=(0,s.wA)(),{0:n,1:o}=(0,i.useState)(c.C$.DASHBOARD),{0:d,1:u}=(0,i.useState)(!1),{0:p,1:h}=(0,i.useState)(null),g=(0,l.useRouter)(),m=(0,i.useRef)(!1),{0:v,1:A}=(0,i.useState)(!1),{0:b,1:y}=(0,i.useState)(_.hC.IDLE),{0:S,1:C}=(0,i.useState)(0),{0:E,1:P}=(0,i.useState)(0),O=(0,s.d4)(e=>{var t;let{shared:r}=e;return null==(t=r.user)?void 0:t.userStatus}),Y=(0,s.d4)(e=>{let{subAccountsNew:t}=e;return t.countSummary}),w=(0,s.d4)(e=>{let{subAccountsNew:t}=e;return t.allAccountsList}),F=null!=(e=(null!=w?w:[]).filter(e=>e.accountStatus===j.CX.Active||e.accountStatus===j.CX.Freeze).length)?e:0,R=(0,i.useMemo)(()=>!!(O&&!(O.isKycVerified&&O.isBankVerified)),[O]),N=(0,i.useRef)(null),{isOnTop:B}=(0,nZ.y)(N.current),x=(0,i.useRef)(null),k=(0,i.useRef)(null),W=(0,i.useRef)(null),L=(0,i.useRef)(null);(0,i.useEffect)(()=>((0,ep.F7)(),(0,ep.vu)(),(0,ep.dI)(),()=>{(0,ep.wP)()}),[]),(0,i.useEffect)(()=>{!m.current&&Y&&Y.activeAccount+Y.freezeAccount+1!=F&&((0,ep.WR)(!0),m.current=!0)},[F,Y]),(0,r8.Y)({queryKey:eg.X.TAB,state:n,setState:o,isValid:u9});let M=n===c.C$.ASSETS_CRYPTO||n===c.C$.ASSETS_FIAT;tI({poll:ep.F8,disabled:!M});let H=(0,i.useCallback)(e=>{o(e),g.replace({pathname:g.pathname,query:{[eg.X.TAB]:e}},void 0,{shallow:!0})},[g]),U=(0,i.useCallback)(()=>{C(0),A(!1),y(_.hC.IDLE),P(e=>e+1),H(c.C$.DASHBOARD)},[]),q=(0,i.useCallback)(()=>{switch(C(0),b){case _.hC.DASHBOARD_INTRO:H(c.C$.ORDERS),y(_.hC.ORDERS);break;case _.hC.ORDERS:H(c.C$.API_MANAGEMENT),y(_.hC.API_MANAGEMENT);break;case _.hC.API_MANAGEMENT:H(c.C$.ASSETS_FIAT),y(_.hC.ASSETS_FIAT);break;case _.hC.ASSETS_FIAT:H(c.C$.AUDIT_LOGS),y(_.hC.AUDIT_LOGS);break;case _.hC.AUDIT_LOGS:H(c.C$.DASHBOARD),y(_.hC.DASHBOARD_OUTRO);break;case _.hC.DASHBOARD_OUTRO:C(0),A(!1),y(_.hC.IDLE),P(e=>e+1)}},[b,H]),Z=(0,i.useCallback)(()=>{var e;null==(e=N.current)||e.scrollTo({top:0,behavior:"smooth"}),y(_.hC.DASHBOARD_INTRO),C(0),P(e=>e+1),H(c.C$.DASHBOARD),A(!0)},[H]);(0,i.useEffect)(()=>{let e=async()=>{let e=await (0,rp.Y)(rp.G.SubAccounts);null!=e&&e.isDisplay&&Z()};w&&(null==w?void 0:w.length)<=1&&e()},[w]);let V=()=>{var e,t,r,i;return R?void h(u7.KYC_BANK_BLOCKER):(null!=(e=null==Y?void 0:Y.activeAccount)?e:0)+(null!=(t=null==Y?void 0:Y.pendingAccount)?t:0)>=(null!=(r=null==Y?void 0:Y.totalSubAccount)?r:0)?void h(u7.CREATE_SUB_ACCOUNT_LIMIT):void(n!==c.C$.DASHBOARD?(o(c.C$.DASHBOARD),setTimeout(()=>{var e;null==(e=x.current)||e.openCreateSubAccountSidepanel()},0)):null==(i=x.current)||i.openCreateSubAccountSidepanel())},K=(0,i.useMemo)(()=>{var e;if(!v||b===_.hC.IDLE)return;let t=null==(e=(0,_.Jq)(b)[S])?void 0:e.target;if(!(0,_.iA)(t))return t},[v,b,S]),G=(0,u3.Z)();return(0,i.useEffect)(()=>{G&&(G.setCoachmarkWalkthroughActive(v),v&&K===_.fU.STEP_10_ACCOUNT_SWITCH?G.setSidenavCoachHighlightTarget(K):G.setSidenavCoachHighlightTarget(void 0))},[v,K,G]),(0,T.FD)("div",{css:[a.vE.flexColumn,a.Wp.heightPercentage(100),"",""],children:[v&&b===_.hC.DASHBOARD_INTRO&&(0,T.Y)(u1,{run:!0,currentState:S,setCurrentState:C,onSegmentFinished:q,onTourAborted:U},E),v&&b===_.hC.ORDERS&&(0,T.Y)(u2,{run:!0,currentState:S,setCurrentState:C,onSegmentFinished:q,onTourAborted:U},E),v&&b===_.hC.API_MANAGEMENT&&(0,T.Y)(u4,{run:!0,currentState:S,setCurrentState:C,onSegmentFinished:q,onTourAborted:U},E),v&&b===_.hC.ASSETS_FIAT&&(0,T.Y)(u8,{run:!0,currentState:S,setCurrentState:C,onSegmentFinished:q,onTourAborted:U},E),v&&b===_.hC.AUDIT_LOGS&&(0,T.Y)(u5,{run:!0,currentState:S,setCurrentState:C,onSegmentFinished:q,onTourAborted:U},E),v&&b===_.hC.DASHBOARD_OUTRO&&(0,T.Y)(u6,{run:!0,currentState:S,setCurrentState:C,onSegmentFinished:q,onTourAborted:U},E),(0,T.Y)(D,{selectedTab:n,handleTabChange:H,handleButtonClick:e=>{var t,n,i,l;switch(e){case I.CREATE_SUB_ACCOUNT:V();break;case I.TRANSFER_FUNDS:null==(t=k.current)||t.openTransferFunds();break;case I.VIEW_STATEMENT:r({type:uK.X2.OPEN_TOPNAVBAR_STATEMENTS,payload:uG.b.STATE
1MENTS});break;case I.COACHMARK:Z();break;case I.EXPORT_AUDIT_LOGS:u(!0),null==(n=W.current)||null==(n=n.exportAuditLogs())||n.finally(()=>u(!1));break;case I.API_DETAILS:null==(i=L.current)||i.showApiKeysSidepanel();break;case I.CREATE_API_KEYS:null==(l=L.current)||l.createApiKeys()}},isExportingLogs:d,showShadow:!B,showCoachmarkWalkthrough:v,coachHighlightTarget:K,coachmarkSegment:b}),(0,T.FD)("div",{ref:N,css:ru,children:[R&&(0,T.Y)(f.eD,{style:a.Wp.mb(20)}),n===c.C$.DASHBOARD&&(0,T.Y)(tP,{ref:x,onCreateSubAccountClick:V,coachHighlightTarget:K,showCoachmarkWalkthrough:v}),n===c.C$.ORDERS&&(0,T.Y)(dm,{onCreateSubAccountClick:V,coachHighlightTarget:K,showCoachmarkWalkthrough:v}),n===c.C$.ASSETS_FIAT&&(0,T.Y)(rd,{ref:k,onCreateSubAccountClick:V,coachHighlightTarget:K}),n===c.C$.ASSETS_CRYPTO&&(0,T.Y)(uZ,{onCreateSubAccountClick:V,coachHighlightTarget:K,showCoachmarkWalkthrough:v}),n===c.C$.AUDIT_LOGS&&(0,T.Y)(r3,{ref:W,coachHighlightTarget:K}),n===c.C$.API_MANAGEMENT&&(0,T.Y)(n$,{ref:L,coachHighlightTarget:K,showCoachmarkWalkthrough:v})]}),(0,T.FD)(a.wv,{open:null!==p,onClose:()=>h(null),children:[p===u7.KYC_BANK_BLOCKER&&(0,T.Y)(f.Hq,{onClose:()=>h(null)}),p===u7.CREATE_SUB_ACCOUNT_LIMIT&&(0,T.Y)(uV,{maxSubAccountsLimit:null!=(t=null==Y?void 0:Y.totalSubAccount)?t:0,onClose:()=>h(null)})]})]})};var pt=r(23510);let pr=()=>(0,T.Y)(u3.n,{children:(0,T.Y)(f.Pj,{layout:pt.A,component:(0,T.Y)(pe,{}),title:"Sub-Accounts"})})}},e=>{e.O(0,[5265,9296,3510,6123,2350,2734,336,3715,4997,5198,8886,7206,9922,8009,9748,636,6593,8792],()=>e(e.s=83518)),_N_E=e.O()}]);

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.