notbank
Version:
The Notbank for Node.js
3 lines (2 loc) • 45 kB
JavaScript
var NotbankSdk=(()=>{var sr=Object.create;var Z=Object.defineProperty,cr=Object.defineProperties,ur=Object.getOwnPropertyDescriptor,mr=Object.getOwnPropertyDescriptors,ar=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols,Sr=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty,pr=Object.prototype.propertyIsEnumerable;var He=i=>{throw TypeError(i)};var We=(i,e,t)=>e in i?Z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,b=(i,e)=>{for(var t in e||(e={}))Be.call(e,t)&&We(i,t,e[t]);if(Fe)for(var t of Fe(e))pr.call(e,t)&&We(i,t,e[t]);return i},re=(i,e)=>cr(i,mr(e));var Rr=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Ve=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Ye=(i,e)=>{for(var t in e)Z(i,t,{get:e[t],enumerable:!0})},Ke=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ar(e))!Be.call(i,o)&&o!==t&&Z(i,o,{get:()=>e[o],enumerable:!(r=ur(e,o))||r.enumerable});return i};var Ue=(i,e,t)=>(t=i!=null?sr(Sr(i)):{},Ke(e||!i||!i.__esModule?Z(t,"default",{value:i,enumerable:!0}):t,i)),Tr=i=>Ke(Z({},"__esModule",{value:!0}),i);var De=(i,e,t)=>e.has(i)||He("Cannot "+t);var T=(i,e,t)=>(De(i,e,"read from private field"),t?t.call(i):e.get(i)),E=(i,e,t)=>e.has(i)?He("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),C=(i,e,t,r)=>(De(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),a=(i,e,t)=>(De(i,e,"access private method"),t);var u=(i,e,t)=>new Promise((r,o)=>{var n=m=>{try{R(t.next(m))}catch(be){o(be)}},s=m=>{try{R(t.throw(m))}catch(be){o(be)}},R=m=>m.done?r(m.value):Promise.resolve(m.value).then(n,s);R((t=t.apply(i,e)).next())});var Ht=Ve((w,Bt)=>{"use strict";var Er=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("unable to locate global object")},U=Er();Bt.exports=w=U.fetch;U.fetch&&(w.default=U.fetch.bind(U));w.Headers=U.Headers;w.Request=U.Request;w.Response=U.Response});var Zt=Ve((fm,$t)=>{"use strict";$t.exports=WebSocket});var Ir={};Ye(Ir,{NotbankClient:()=>Ne,models:()=>we});var we={};Ye(we,{AccountType:()=>Qe,ActionType:()=>Je,ArgentinaBankAccountKind:()=>je,BrazilBankAccountKind:()=>Xe,ChangeReason:()=>et,ChileBankAccountKind:()=>$e,ColombiaBankAccountKind:()=>ze,DepositFeeMessages:()=>rt,DepositStatus:()=>ot,Direction:()=>it,FeeCalcType:()=>wt,FeeProductType:()=>nt,FeeType:()=>Lt,InstrumentStateArgument:()=>st,InstrumentType:()=>ct,MakerTaker:()=>ut,NotbankError:()=>O,OrderFlag:()=>mt,OrderSide:()=>at,OrderState:()=>St,OrderTypeInt:()=>pt,OrderTypeStr:()=>Rt,PegPriceType:()=>Tt,PeruBankAccountKind:()=>Ze,PixType:()=>lt,ProductType:()=>Et,ReferenceType:()=>dt,ReportFlavor:()=>Ot,ReportFrequency:()=>ht,ReportRequestStatus:()=>ft,ReportWriterResultStatus:()=>vt,RiskType:()=>_t,SessionStatus:()=>Ct,SideType:()=>At,SubscriptionResponse:()=>xe,SupportedCountry:()=>tt,TimeInForce:()=>It,TradeDirection:()=>Pt,TradeSide:()=>gt,TransactionReferenceTypes:()=>Nt,TransactionTypes:()=>bt,UnsubscribeLevel2ErrorCode:()=>Ut,UnsubscribeTradesError:()=>Dt,UnsubscriptionResponse:()=>Me,WithdrawErrorCode:()=>qt,WithdrawFeeMessages:()=>Mt,WithdrawTemplateType:()=>xt,orderbookFromRaw:()=>qe});var Qe=(t=>(t.ASSET="Asset",t.LIABILITY="Liability",t))(Qe||{});var Je=(r=>(r[r.NEW=0]="NEW",r[r.UPDATE=1]="UPDATE",r[r.DELETION=2]="DELETION",r))(Je||{});var je=(R=>(R.CORRIENTE="corriente",R.VISTA="vista",R.AHORRO="ahorro",R.ELECTRONIC_CHECKBOOK="electronic_checkbook",R.AR_CBU="ar_cbu",R.AR_CVU="ar_cvu",R.AR_ALIAS="ar_alias",R))(je||{}),Xe=(R=>(R.BR_CORRIENTE_FISICA="br_corriente_fisica",R.BR_SIMPLE_FISICA="br_simple_fisica",R.BR_CORRIENTE_JURIDICA="br_corriente_juridica",R.BR_POUPANCA_FISICA="br_poupanca_fisica",R.BR_POUPANCA_JURIDICA="br_poupanca_juridica",R.BR_CAIXA_FACIL="br_caixa_facil",R.BR_PIX="br_pix",R))(Xe||{}),$e=(o=>(o.CORRIENTE="corriente",o.VISTA="vista",o.AHORRO="ahorro",o.ELECTRONIC_CHECKBOOK="electronic_checkbook",o))($e||{}),Ze=(t=>(t.CORRIENTE="corriente",t.AHORRO="ahorro",t))(Ze||{}),ze=(t=>(t.CORRIENTE="corriente",t.AHORRO="ahorro",t))(ze||{});var et=(d=>(d.UNKNOWN="Unknown",d.NEWINPUTACCEPTED="NewInputAccepted",d.NEWINPUTREJECTED="NewInputRejected",d.OTHERREJECTED="OtherRejected",d.EXPIRED="Expired",d.TRADE="Trade",d.SYSTEMCANCELED_NOMOREDMARKET="SystemCanceled_NoMoreMarket",d.SYSTEMCANCELED_BELOWMINIMUM="SystemCanceled_BelowMinimum",d.SYSTEMCANCELED_PRICECOLLAR="SystemCanceled_PriceCollar",d.SYSTEMCANCELED_MARGINFAILED="SystemCanceled_MarginFailed",d.USERMODIFIED="UserModified",d))(et||{});var tt=(n=>(n.AR="AR",n.BR="BR",n.CL="CL",n.PE="PE",n.CO="CO",n))(tt||{});var rt=(r=>(r.Success="Fee calculated successfully",r.InvalidRequest="Invalid Request",r.AccountOrProductNotFound="Account or Product not found",r))(rt||{});var ot=(o=>(o.New="New",o.Pending="Pending",o.FullyProcessed="FullyProcessed",o.Error="Error",o))(ot||{});var it=(r=>(r[r.NoChange=0]="NoChange",r[r.Uptick=1]="Uptick",r[r.DownTick=2]="DownTick",r))(it||{});var nt=(t=>(t.BASE_PRODUCT="BaseProduct",t.SINGLE_PRODUCT="SingleProduct",t))(nt||{});var st=(t=>(t.BOTH="BOTH",t.INACTIVE="INACTIVE",t))(st||{});var ct=(t=>(t.UNKNOWN="Unknown",t.STANDARD="Standard",t))(ct||{});var ut=(r=>(r[r.Unknown=0]="Unknown",r[r.Maker=1]="Maker",r[r.Taker=2]="Taker",r))(ut||{});var mt=(s=>(s.NoAccountRiskCheck="NoAccountRiskCheck",s.AddedToBook="AddedToBook",s.RemovedFromBook="RemovedFromBook",s.PostOnly="PostOnly",s.Liquidation="Liquidation",s.ReverseMarginPosition="ReverseMarginPosition",s))(mt||{});var at=(t=>(t[t.Buy=0]="Buy",t[t.Sell=1]="Sell",t))(at||{});var St=(s=>(s.Unknown="Unknown",s.Working="Working",s.Rejected="Rejected",s.Canceled="Canceled",s.Expired="Expired",s.FullyExecuted="Fully Executed",s))(St||{});var pt=(m=>(m[m.Unknown=0]="Unknown",m[m.Market=1]="Market",m[m.Limit=2]="Limit",m[m.StopMarket=3]="StopMarket",m[m.StopLimit=4]="StopLimit",m[m.TrailingStopMarket=5]="TrailingStopMarket",m[m.TrailingStopLimit=6]="TrailingStopLimit",m[m.BlockTrade=7]="BlockTrade",m))(pt||{}),Rt=(m=>(m.Unknown="Unknown",m.Market="Market",m.Limit="Limit",m.StopMarket="StopMarket",m.StopLimit="StopLimit",m.TrailingStopMarket="TrailingStopMarket",m.TrailingStopLimit="TrailingStopLimit",m.BlockTrade="BlockTrade",m))(Rt||{});var Tt=(o=>(o[o.Last=1]="Last",o[o.Bid=2]="Bid",o[o.Ask=3]="Ask",o[o.Midpoint=4]="Midpoint",o))(Tt||{});var lt=(n=>(n.CPF="CPF",n.CNPJ="CNPJ",n.EMAIL="Email",n.PHONE="Phone",n.OTRO="Otro",n))(lt||{});var Et=(o=>(o.UNKNOWN="Unknown",o.NATIONAL_CURRENCY="NationalCurrency",o.CRYPTO_CURRENCY="CryptoCurrency",o.CONTRACT="Contract",o))(Et||{});var dt=(e=>(e.Withdraw="Withdraw",e))(dt||{});var Ot=(s=>(s.TradeActivity="TradeActivity",s.TransactionActivity="TransactionActivity",s.ProductDelta="ProductDelta",s.ProfitAndLoss="ProfitAndLoss",s.Transaction="Transaction",s.Treasury="Treasury",s))(Ot||{});var ht=(s=>(s.OnDemand="OnDemand",s.Hourly="Hourly",s.Daily="Daily",s.Weekly="Weekly",s.Monthly="Monthly",s.Annually="Annually",s))(ht||{});var ft=(d=>(d.Submitted="Submitted",d.Validating="Validating",d.Scheduled="Scheduled",d.InProgress="InProgress",d.Completed="Completed",d.Aborting="Aborting",d.Aborted="Aborted",d.UserCancelled="UserCancelled",d.SysRetired="SysRetired",d.Pending="Pending",d.UserCancelPending="UserCancelPending",d))(ft||{});var vt=(n=>(n.NotStarted="NotStarted",n.NotComplete="NotComplete",n.ErrorComplete="ErrorComplete",n.SuccessComplete="SuccessComplete",n.Cancelled="Cancelled",n))(vt||{});var _t=(n=>(n.UNKNOWN="Unknown",n.NORMAL="Normal",n.NO_RISK_CHECK="NoRiskCheck",n.NO_TRADING="NoTrading",n.CREDIT="Credit",n))(_t||{});var Ct=(s=>(s.UNKNOWN="Unknown",s.RUNNING="Running",s.PAUSED="Paused",s.STOPPED="Stopped",s.STARTING="Starting",s.RUNNING_POST_ONLY="RunningPostOnly",s))(Ct||{});var At=(t=>(t.BUY="Buy",t.SELL="Sell",t))(At||{});var It=(R=>(R[R.Unknown=0]="Unknown",R[R.GTC=1]="GTC",R[R.OPG=2]="OPG",R[R.IOC=3]="IOC",R[R.FOK=4]="FOK",R[R.GTX=5]="GTX",R[R.GTD=6]="GTD",R))(It||{});var Pt=(r=>(r[r.NoChange=0]="NoChange",r[r.Uptick=1]="Uptick",r[r.DownTick=2]="DownTick",r))(Pt||{});var gt=(o=>(o[o.Buy=0]="Buy",o[o.Sell=1]="Sell",o[o.Short=2]="Short",o[o.Unknown=3]="Unknown",o))(gt||{});var Nt=(S=>(S.Trade="Trade",S.Deposit="Deposit",S.Withdraw="Withdraw",S.Transfer="Transfer",S.OrderHold="OrderHold",S.WithdrawHold="WithdrawHold",S.DepositHold="DepositHold",S.MarginHold="MarginHold",S.ManualHold="ManualHold",S.ManualEntry="ManualEntry",S.MarginAcquisition="MarginAcquisition",S.MarginRelinquish="MarginRelinquish",S.MarginInterestNetting="MarginInterestNetting",S.MarginOperatorTransferToMarginAccount="MarginOperatorTransferToMarginAccount",S.MarginOperatorTransferToAssetAccount="MarginOperatorTransferToAssetAccount",S.MarginUserTransfer="MarginUserTransfer",S.MarginPositionReverseTrade="MarginPositionReverseTrade",S.AffiliateRebate="AffiliateRebate",S.DistributionEntry="DistributionEntry",S.TransferHold="TransferHold",S.AirDrop="AirDrop",S))(Nt||{});var bt=(S=>(S.Fee="Fee",S.Trade="Trade",S.Other="Other",S.Reverse="Reverse",S.Hold="Hold",S.Rebate="Rebate",S.MarginAcquisition="MarginAcquisition",S.MarginRelinquishByTrade="MarginRelinquishByTrade",S.MarginInterestTransfer="MarginInterestTransfer",S.MarginOperatorTransferToMarginAccount="MarginOperatorTransferToMarginAccount",S.MarginOperatorTransferToAssetAccount="MarginOperatorTransferToAssetAccount",S.MarginUserTransfer="MarginUserTransfer",S.MarginRelinquishByTransfer="MarginRelinquishByTransfer",S.MarginRelinquishByReverseTrade="MarginRelinquishByReverseTrade",S.Distribution="Distribution",S.Payment="Payment",S.OperatorLend="OperatorLend",S.OperatorReceived="OperatorReceived",S.Rebalance="Rebalance",S.Commission="Commission",S.AirDrop="AirDrop",S))(bt||{});var Ut=(s=>(s[s.SUCCESS=0]="SUCCESS",s[s.NOT_AUTHORIZED=20]="NOT_AUTHORIZED",s[s.INVALID_REQUEST=100]="INVALID_REQUEST",s[s.OPERATION_FAILED=101]="OPERATION_FAILED",s[s.SERVER_ERROR=102]="SERVER_ERROR",s[s.RESOURCE_NOT_FOUND=104]="RESOURCE_NOT_FOUND",s))(Ut||{});var Dt=(n=>(n[n.NotAuthorized=20]="NotAuthorized",n[n.InvalidRequest=100]="InvalidRequest",n[n.OperationFailed=101]="OperationFailed",n[n.ServerError=102]="ServerError",n[n.ResourceNotFound=104]="ResourceNotFound",n))(Dt||{});var qt=(s=>(s[s.NoError=0]="NoError",s[s.NotAuthorized=20]="NotAuthorized",s[s.InvalidRequest=100]="InvalidRequest",s[s.OperationFailed=101]="OperationFailed",s[s.ServerError=102]="ServerError",s[s.ResourceNotFound=104]="ResourceNotFound",s))(qt||{});var Mt=(r=>(r.Success="Fee calculated successfully",r.InvalidRequest="Invalid Request",r.AccountOrProductNotFound="Account or Product not found",r))(Mt||{});var xt=(r=>(r.ToExternalBitcoinAddress="ToExternalBitcoinAddress",r.ToInternalAccount="ToInternalAccount",r.ToBankAccount="ToBankAccount",r))(xt||{});var wt=(t=>(t.Flat="Flat",t.Percentage="Percentage",t))(wt||{}),Lt=(n=>(n.Flat="Flat",n.MakerFee="MakerFee",n.TakerFee="TakerFee",n.PeggedProductFee="PeggedProductFee",n.AffiliateFee="AffiliateFee",n))(Lt||{});function qe(i){return{timestamp:i.timestamp,bids:i.bids.map(e=>({quantity:e[0],price:e[1]})),asks:i.asks.map(e=>({quantity:e[0],price:e[1]}))}}var z=class z extends Error{constructor(e,t){super("Notbank Error. "+e),this.code=t}};z.Factory=class{static createFromApResponse(t){var r="";return t.errorcode&&(r+=`(code=${t.errorcode})`),t.errormsg&&(r+=" "+t.errormsg+"."),t.detail&&(r+=" "+t.detail+"."),new z(r,t.errorcode||t.statusCode)}static createFromNbResponse(t){var r="";return t.message&&(r+=t.message,t.message.endsWith(".")||(r+=".")),t.detail&&(r+=" "+t.detail,t.detail.endsWith(".")||(r+=".")),new z(r,-1)}};var O=z;var Me=class{};var xe=class{};var Gt=Ue(Rr("crypto"),1);function lr(i){return Math.floor(Math.random()*i)}function oe(){return lr(1e6).toString()}function ie(i,e,t,r){var o=r+t+i;let n=Gt.default.createHmac("sha256",e);return n.update(o),n.digest("hex")}var kt=(m=>(m[m.UNDEFINED=-1]="UNDEFINED",m[m.NOT_AN_ERROR=0]="NOT_AN_ERROR",m[m.NOT_AUTHORIZED=20]="NOT_AUTHORIZED",m[m.INVALID_RESPONSE=100]="INVALID_RESPONSE",m[m.OPERATION_FAILED=101]="OPERATION_FAILED",m[m.SERVER_ERROR=102]="SERVER_ERROR",m[m.RESOURCE_NOT_FOUND=104]="RESOURCE_NOT_FOUND",m[m.OPERATION_IN_PROCESS=107]="OPERATION_IN_PROCESS",m))(kt||{}),ne=kt;var x,yt,Ft,ee=class ee{static handle(e){return u(this,null,function*(){var o,n;if(e.status>=400||e.status<200)throw new Error(`http error (${e.status}) not a successfull response. ${yield a(o=ee,x,Ft).call(o,e)}`);var t=yield a(n=ee,x,yt).call(n,e);if(!t)throw new O("http error. (status="+e.status+")",-1);var r=t;if((r==null?void 0:r.result)===!1&&(r==null?void 0:r.errorcode)!=null&&!(r.errorcode==ne.OPERATION_IN_PROCESS&&r.errormsg==="Operation In Process"))throw O.Factory.createFromApResponse(r);return t})}};x=new WeakSet,yt=function(e){return u(this,null,function*(){try{return yield e.json()}catch(t){return null}})},Ft=function(e){return u(this,null,function*(){try{return yield e.text()}catch(t){return null}})},E(ee,x);var se=ee;var ue,Wt,me=class me{static handle(e,t){return u(this,null,function*(){var n;try{var r=yield a(n=me,ue,Wt).call(n,e);if(!r)throw new O("http error. (status="+e.status+")",-1);var o=r;if((o==null?void 0:o.status)==="success")return t?r:o.data;throw O.Factory.createFromNbResponse(o)}catch(s){throw s}})}};ue=new WeakSet,Wt=function(e){return u(this,null,function*(){try{return yield e.json()}catch(t){return null}})},E(me,ue);var ce=me;var Vt=Ue(Ht(),1);var D,ae=class{constructor(){E(this,D);C(this,D,null)}updateSessionToken(e){C(this,D,e)}request(e){let t=["POST","DELETE"].includes(e.requestType);var r=t?e.url:this.getUrlWithSearchParams(e.url,e.params),o=t?e.params:null,n={method:e.requestType,headers:this.getHeaders(e.extraHeaders)};return o&&(n.body=JSON.stringify(o)),(0,Vt.default)(r,n)}getHeaders(e){var t={"Content-type":"application/json",charset:"UTF-8"};return T(this,D)&&(t.aptoken=T(this,D)),e?b(b({},t),e):t}getUrlWithSearchParams(e,t){return t?e+"?"+new URLSearchParams(t):e}};D=new WeakMap;var N,L,Se=class{constructor(e){E(this,N);E(this,L);C(this,N,new ae),C(this,L,"https://"+e)}nbRequest(e,t,r,o=!1){return u(this,null,function*(){let n=this.getNbUrl(e);var s=yield T(this,N).request({url:n,requestType:t,params:r});return yield ce.handle(s,o)})}apRequest(e,t,r,o){return u(this,null,function*(){let n=this.getApUrl(e);var s=yield T(this,N).request({url:n,requestType:t,params:r,extraHeaders:o});return yield se.handle(s)})}updateSessionToken(e){T(this,N).updateSessionToken(e)}authenticateUser(e){return u(this,null,function*(){var t=yield this.apRequest("AuthenticateUser","GET",null,e);T(this,N).updateSessionToken(t.SessionToken)})}subscribe(e,t,r,o,n){throw new Error("Method not implemented.")}unsubscribe(e,t,r,o,n){throw new Error("Method not implemented.")}setResponseHandler(e){throw new Error("Method not implemented.")}setResponseHandlers(e){throw new Error("Method not implemented.")}getApUrl(e){return T(this,L)+"/ap/"+e}getNbUrl(e){return T(this,L)+"/api/nb/"+e}connect(){return Promise.resolve()}close(){return Promise.resolve()}};N=new WeakMap,L=new WeakMap;function c(i,e){return re(b({},i),{OMSId:e})}var G=class{constructor(e){this.OMS_ID=1;this.connection=e}getAccountTransactions(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountTransactions","POST",t)}getAccountPositions(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountPositions","POST",t)}getAccountInstrumentStatistics(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountInstrumentStatistics","POST",t)}getAccountInfo(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountInfo","POST",t)})}};var k=class{constructor(e){this.connection=e}webAuthenticateUser(e){return u(this,null,function*(){return yield this.connection.apRequest("WebAuthenticateUser","NONE",e)})}logOut(){return u(this,null,function*(){return yield this.connection.apRequest("LogOut","POST")})}};var y=class{constructor(e){this.OMS_ID=1;this.connection=e}getDepositFee(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetDepositFee","POST",t)}getWithdrawFee(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetWithdrawFee","POST",t)}getOMSWithdrawFees(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOMSWithdrawFees","POST",t)}getOMSDepositFees(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOMSDepositFees","POST",t)})}getAccountFees(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountFees","POST",t)})}getOrderFee(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderFee","POST",t)})}};var F=class{constructor(e){this.OMS_ID=1;this.connection=e,this.instrumentCache={}}getInstruments(e={}){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetInstruments","POST",t)}getInstrument(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetInstrument","POST",t)}getInstrumentBySymbol(e){return u(this,null,function*(){if(!(e.symbol in this.instrumentCache)){var t=yield this.getInstruments();t.map(r=>this.instrumentCache[r.Symbol]=r)}if(e.symbol in this.instrumentCache)return Promise.resolve(this.instrumentCache[e.symbol]);throw new O("no instrument found for symbol "+e.symbol,-1)})}getInstrumentVerificationLevelConfigs(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetInstrumentVerificationLevelConfig","POST",t)})}};var W=class{constructor(e){this.OMS_ID=1;this.connection=e,this.productCache={}}getProduct(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetProduct","POST",t)}getProducts(){return u(this,arguments,function*(e={}){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetProducts","POST",t)})}getProductBySymbol(e){return u(this,null,function*(){if(!(e.symbol in this.productCache)){var t=yield this.getProducts();t.map(r=>this.productCache[r.Product]=r)}if(e.symbol in this.productCache)return Promise.resolve(this.productCache[e.symbol]);throw new O("no product found for symbol "+e.symbol,-1)})}getVerificationLevelConfig(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return yield this.connection.apRequest("GetVerificationLevelConfig","POST",t)})}};var B=class{constructor(e){this.OMS_ID=1;this.connection=e}generateTradeActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GenerateTradeActivityReport","POST",t)}generateTransactionActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GenerateTransactionActivityReport","POST",t)}generateProductDeltaActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GenerateProductDeltaActivityReport","POST",t)}generatePnLActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GeneratePnLActivityReport","POST",t)}scheduleTradeActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleTradeActivityReport","POST",t)}scheduleTransactionActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleTransactionActivityReport","POST",t)}scheduleProductDeltaActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleProductDeltaActivityReport","POST",t)}scheduleProfitAndLossActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleProfitAndLossActivityReport","POST",t)}cancelUserReport(e){return this.connection.apRequest("CancelUserReport","POST",e)}getUserReportWriterResultRecords(e){return this.connection.apRequest("GetUserReportWriterResultRecords","POST",e)}getUserReportTickets(e){return this.connection.apRequest("GetUserReportTickets","POST",e)}removeUserReportTicket(e){return this.connection.apRequest("RemoveUserReportTicket","POST",e.UserReportTicketId)}getUserReportTicketsByStatus(e){return this.connection.apRequest("GetUserReportTicketsByStatus","POST",e)}downloadDocument(e){return this.connection.apRequest("DownloadDocument","POST",e)}downloadDocumentSlice(e){return this.connection.apRequest("DownloadDocumentSlice","POST",e)}};var H=class{constructor(e){this.connection=e}ping(){return this.connection.apRequest("Ping","POST")}healthCheck(){return this.connection.apRequest("HealthCheck","POST")}};function pe(i,e){return i.map(t=>re(b({},t),{OMSId:e}))}function Re(i){return{TradeId:i[0],InstrumentId:i[1],Quantity:i[2],Price:i[3],Order1:i[4],Order2:i[5],Tradetime:i[6],Direction:i[7],TakerSide:i[8],BlockTrade:i[9]==1,OrderClientId:i[10]}}var V=class{constructor(e){this.OMS_ID=1;this.connection=e}sendOrderList(e){let t=pe(e,this.OMS_ID);return this.connection.apRequest("SendOrderList","POST",t)}sendCancelList(e){let t=pe(e,this.OMS_ID);return this.connection.apRequest("SendCancelList","POST",t)}sendCancelReplaceList(e){let t=pe(e,this.OMS_ID);return this.connection.apRequest("SendCancelReplaceList","POST",t)}modifyOrder(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ModifyOrder","POST",t)}cancelAllOrders(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("CancelAllOrders","POST",t)}getOrderStatus(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderStatus","POST",t)})}getOrdersHistory(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrdersHistory","POST",t)}getTradesHistory(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetTradesHistory","POST",t)}getOrderHistoryByOrderId(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderHistoryByOrderId","POST",t)}getTickerHistory(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetTickerHistory","POST",t)).map(o=>({EndDateTime:o[0],High:o[1],Low:o[2],Open:o[3],Close:o[4],Volume:o[5],Bid:o[6],Ask:o[7],InstrumentId:o[8],BeginDateTime:o[9]}))})}getLastTrades(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetLastTrades","POST",t)).map(o=>Re(o))})}getLevel1Summary(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetLevel1Summary","POST",t)})}getLevel1SummaryMin(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetLevel1SummaryMin","POST",t)).map(o=>({InstrumentId:o[0],InstrumentSymbol:o[1].toString(),LastTradedPx:o[2],Rolling24HrPxChange:o[3],Rolling24HrPxChangePercent:o[4],Rolling24HrVolume:o[5]}))})}getOpenTradeReports(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOpenTradeReports","POST",t)}getOrders(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrders","POST",t)}getOrderHistory(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderHistory","POST",t)}sendOrder(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("SendOrder","POST",t)})}cancelReplaceOrder(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("CancelReplaceOrder","POST",t)}cancelOrder(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("CancelOrder","POST",t)}getOpenOrders(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOpenOrders","POST",t)}getAccountTrades(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountTrades","POST",t)}getSummary(){return this.connection.apRequest("Summary","POST")}getTicker(){return this.connection.apRequest("Ticker","POST")}getOrderBook(e){return u(this,null,function*(){let t=yield this.connection.apRequest("OrderBook","POST",e);return qe(t)})}getOrderBookRaw(e){return this.connection.apRequest("OrderBook","POST",e)}getTrades(e){return this.connection.apRequest("Trades","POST",e)}getL2Snapshot(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetL2Snapshot","POST",t)).map(o=>({MDUpdateID:o[0],NumberOfUniqueAccounts:o[1],ActionDateTime:o[2],ActionType:o[3],LastTradePrice:o[4],NumberOfOrders:o[5],Price:o[6],ProductPairCode:o[7],Quantity:o[8],Side:o[9]}))})}getLevel1(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetLevel1","POST",t)}getEnums(){return this.connection.apRequest("GetEnums","POST")}};var Y=class{constructor(e){this.OMS_ID=1;this.connection=e}getUserAccounts(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetUserAccounts","POST",t)}getUserDevices(e){return this.connection.apRequest("GetUserDevices","POST",e)}getUserInfo(e){return this.connection.apRequest("GetUserInfo","POST",e)}getUserPermissions(e){return this.connection.apRequest("GetUserPermissions","POST",e)}};var K,Te,Q=class{constructor(e){E(this,K);this.connection=e}getBanks(e){return a(this,K,Te).call(this,"banks","GET",e)}AddClientBankAccount(e){return this.connection.nbRequest("bank-accounts","POST",e)}getClientBankAccount(e){return this.connection.nbRequest("bank-accounts/"+e.bankAccountId,"GET")}getClientBankAccounts(e){return a(this,K,Te).call(this,"bank-accounts","GET",e)}deleteClientBankAccount(e){return this.connection.nbRequest("bank-accounts/"+e.bankAccountId,"DELETE")}getNetworksTemplates(e){return this.connection.nbRequest("wallet/crypto/withdrawal/templates","GET",e)}getDepositAddresses(e){return this.connection.nbRequest("wallet/crypto","GET",e)}createDepositAddress(e){return this.connection.nbRequest("wallet/crypto","POST",e)}getWhitelistedAddresses(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses","GET",e)}addWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses","POST",e)}confirmWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/"+e.whitelistedAddressId+"/verification","POST",{sms_code:e.sms_code,account_id:e.account_id})}resendVerificationCodeWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/"+e.whitelistedAddressId+"/verification","GET",{account_id:e.account_id})}deleteWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/"+e.whitelistedAddressId,"DELETE",{account_id:e.account_id,otp:e.otp})}updateOneStepWithdraw(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/one-step/status","POST",e)}createCryptoWithdraw(e){return this.connection.nbRequest("wallet/crypto/withdrawal","POST",e)}createFiatDeposit(e){return u(this,null,function*(){let t=yield this.connection.nbRequest("wallet/fiat/deposit","POST",e);return t==null?void 0:t.url})}getOwnersFiatWithdraw(e){return this.connection.nbRequest("wallet/fiat/withdrawal/owners","GET",e)}createFiatWithdraw(e){return u(this,null,function*(){let t=yield this.connection.nbRequest("wallet/fiat/withdrawal","POST",e);return t==null?void 0:t.withdrawal_id})}confirmFiatWithdraw(e){return this.connection.nbRequest("wallet/fiat/withdrawal/"+e.withdrawal_id,"POST",{attempt_code:e.attempt_code})}transferFunds(e){return this.connection.nbRequest("wallet/transfer-funds","POST",e)}getTransactions(e){return a(this,K,Te).call(this,"wallet/transactions","GET",e)}};K=new WeakSet,Te=function(e,t,r){return this.connection.nbRequest(e,t,r,!0)};var J=class{constructor(e){this.connection=e}getQuotes(e){return this.connection.nbRequest("quotes","GET",e)}createDirectQuote(e){return u(this,null,function*(){return(yield this.connection.nbRequest("quotes/direct","POST",e)).id})}createInverseQuote(e){return u(this,null,function*(){return(yield this.connection.nbRequest("quotes/inverse","POST",e)).id})}getQuote(e){return this.connection.nbRequest("quotes/"+e.quote_id,"GET",e)}executeQuote(e){return this.connection.nbRequest("quotes/"+e.quote_id,"POST",e)}};var dr="api.notbank.exchange",h,le=class{constructor(e){E(this,h);let t=e||dr;C(this,h,new Se(t))}authenticateUser(e){var t=oe(),r=ie(e.ApiPublicKey,e.ApiSecretKey,e.UserId,t);return T(this,h).authenticateUser({APIKey:e.ApiPublicKey,Signature:r,UserId:e.UserId,Nonce:t})}updateSessionToken(e){this.getConnection().updateSessionToken(e)}getConnection(){return T(this,h)}newAccountService(){return new G(T(this,h))}newAuthService(){return new k(T(this,h))}newFeeService(){return new y(T(this,h))}newInstrumentService(){return new F(T(this,h))}newProductService(){return new W(T(this,h))}newReportService(){return new B(T(this,h))}newSystemService(){return new H(T(this,h))}newTradingService(){return new V(T(this,h))}newUserService(){return new Y(T(this,h))}newWalletService(){return new Q(T(this,h))}newQuoteService(){return new J(T(this,h))}};h=new WeakMap;var Ee=class{constructor(e=1e4,t=5e3){this.pingIntervalMillis=e,this.pingTimeoutMillis=t}startPing(e,t){this.stop(),this.interval=setInterval(()=>u(this,null,function*(){try{yield Promise.race([e.apRequest("Ping","NONE"),new Promise((r,o)=>setTimeout(o,this.pingTimeoutMillis))])}catch(r){yield t.reconnect();return}}),this.pingIntervalMillis),typeof this.interval.unref=="function"&&this.interval.unref()}stop(){this.interval&&clearTimeout(this.interval)}};var de=class{constructor(){this.authenticateFn=null}updateAuthentication(e){this.authenticateFn=e}removeAuthentication(){this.authenticateFn=null}makeAuthentication(e){this.authenticateFn!==null&&this.authenticateFn(e)}};var he,p,Le,Ge,ke,ye,Yt,A,Kt,Oe,Qt,Jt,jt,l=class l{static get(e,t=null,r=null){var o,n;return e+a(o=l,p,Le).call(o,t)+a(n=l,p,Le).call(n,r)}static getFromMessageFrame(e){var t,r,o;return(o=(r=(t=T(this,he))[e.n])==null?void 0:r.call(t,e.n,e.o))!=null?o:e.n}};he=new WeakMap,p=new WeakSet,Le=function(e){return e!=null?"_"+e:""},Ge=function(e,t){var o;let r=a(o=l,p,Oe).call(o,t,8);return r==null?e:e+"_"+r},ke=function(e,t){var r;return e+"_"+a(r=l,p,Qt).call(r,t)},ye=function(e,t){var o;let r=a(o=l,p,Oe).call(o,t,7);return r==null?e:e+"_"+r},Yt=function(e,t){var o;let r=a(o=l,p,Oe).call(o,t,1);return r==null?e:e+"_"+r},A=function(e,t){var o;let r=a(o=l,p,Jt).call(o,t);return r!=null||(r=a(this,p,jt).call(this,t),r!=null)?e+"_"+r:e},Kt=function(e,t){let r=JSON.parse(t),o=e+"_"+r.AccountId;return r.Instrument&&(o=o+"_"+r.Instrument),o},Oe=function(e,t){let r=JSON.parse(e);return r.length==0||r[0].length<=t?null:r[0][t]},Qt=function(e){return JSON.parse(e).InstrumentId},Jt=function(e){return JSON.parse(e).AccountId},jt=function(e){return JSON.parse(e).Account},E(l,p),E(l,he,{SubscribeLevel1:a(l,p,ke),Level1UpdateEvent:a(l,p,ke),SubscribeLevel2:a(l,p,ye),Level2UpdateEvent:a(l,p,ye),SubscribeTicker:a(l,p,Ge),TickerDataUpdateEvent:a(l,p,Ge),SubscribeTrades:a(l,p,Yt),SubscribeOrderStateEvents:a(l,p,Kt),TransactionEvent:a(l,p,A),WithdrawTicketUpdateEvent:a(l,p,A),AccountPositionEvent:a(l,p,A),OrderTradeEvent:a(l,p,A),OrderStateEvent:a(l,p,A),DepositTicketUpdateEvent:a(l,p,A),AccountInfoUpdateEvent:a(l,p,A),CancelOrderRejectEvent:a(l,p,A),DepositEvent:a(l,p,A)});var I=l;var ve,Xt,fe=class{constructor(){E(this,ve);this.currentSubscriptions=[]}saveSubscription(e){this.currentSubscriptions.push(e)}removeSubscription(e){for(let r=0;r<e.length;r++)for(let o=0;o<this.currentSubscriptions.length;o++){var t=a(this,ve,Xt).call(this,this.currentSubscriptions[o],e[r]);if(t){this.currentSubscriptions.splice(o,1);return}}}makeSubscriptions(e){this.currentSubscriptions.forEach(t=>e.subscribe(t.endpoint,t.firstIdentifier,t.secondIdentifier,t.message,t.subscriptionHandlers))}};ve=new WeakSet,Xt=function(e,t){var r=I.get(e.endpoint,e.firstIdentifier,e.secondIdentifier);return r===t};var zt=Ue(Zt(),1);var q,M,j,_e=class{constructor(){E(this,q);E(this,M);E(this,j);C(this,q,{}),C(this,M,{}),C(this,j,2)}putCallback(e){var t=T(this,j);return T(this,M)[t]=e,C(this,j,T(this,j)+2),t}popCallback(e){let t=T(this,M)[e];return delete T(this,M)[e],t!=null?t:r=>null}addSubscriptionCallback(e,t){T(this,q)[e]=t}getSubscriptionCallback(e){return T(this,q)[e]||null}removeSubscriptionCallback(e){e.map(t=>delete T(this,q)[t])}};q=new WeakMap,M=new WeakMap,j=new WeakMap;var hr=i=>{},fr="api.notbank.exchange",_,er,tr,Ce,rr,or,X=class{constructor(e){E(this,_);this.domain=(e==null?void 0:e.domain)||fr,this.callbackManager=new _e,this.hooks=(e==null?void 0:e.websocketHooks)||{},this.peekMessageIn=(e==null?void 0:e.peekMessageIn)||(t=>{}),this.peekMessageOut=(e==null?void 0:e.peekMessageOut)||(t=>{})}updateSessionToken(e){throw new Error("Method not implemented.")}nbRequest(e,t,r){throw new Error("websocket client does not support nb methods.")}connect(){return u(this,null,function*(){return this.websocket=new zt.default("wss://"+this.domain+"/wsgateway"),this.websocket.onopen=e=>{var t,r;return(r=(t=this.hooks).onOpen)==null?void 0:r.call(t,e)},this.websocket.onclose=e=>{var t,r;return(r=(t=this.hooks).onClose)==null?void 0:r.call(t,e)},this.websocket.onerror=e=>{var t,r;return(r=(t=this.hooks).onError)==null?void 0:r.call(t,e)},this.websocket.addEventListener("message",e=>{let t=JSON.parse(e.data);a(this,_,tr).call(this,t)}),this.websocket.addEventListener("message",e=>{var t,r;return(r=(t=this.hooks).onMessage)==null?void 0:r.call(t,e)}),new Promise((e,t)=>this.websocket.addEventListener("open",r=>e()))})}close(){return this.websocket.close()}get readyState(){return this.websocket.readyState}apRequest(e,t,r){return a(this,_,Ce).call(this,e,r,0)}subscribe(e,t,r,o,n){return u(this,null,function*(){return n.map(s=>this.callbackManager.addSubscriptionCallback(I.get(s.eventName,t,r),s.eventHandler)),a(this,_,Ce).call(this,e,o,0)})}unsubscribe(e,t,r,o,n){return u(this,null,function*(){return this.callbackManager.removeSubscriptionCallback(n.map(s=>I.get(s,t,r))),yield a(this,_,Ce).call(this,e,o,0)})}closeConnection(){this.websocket.socket.close()}authenticateUser(e){return u(this,null,function*(){yield this.apRequest("AuthenticateUser","NONE",e)})}};_=new WeakSet,er=function(e){return I.getFromMessageFrame(e)},tr=function(e){this.peekMessageIn(e);let t=this.callbackManager.popCallback(e.i);if(t!=null&&(t(e),_r(e)))return;let r=a(this,_,er).call(this,e),o=this.callbackManager.getSubscriptionCallback(r);if(o!=null){o(e);return}var n=r.lastIndexOf("_");if(n==-1)return;let s=r.substring(0,n),R=this.callbackManager.getSubscriptionCallback(r);if(R!=null){R(e);return}},Ce=function(e,t,r=0){return new Promise((o,n)=>{a(this,_,or).call(this,e,JSON.stringify(t)||"{}",r,a(this,_,rr).call(this,n,o))})},rr=function(e,t){return r=>{try{var o=JSON.parse(r.o)}catch(s){e(vr(r.o));return}if(r.m===5){e(O.Factory.createFromApResponse(o));return}var n=o;if((n==null?void 0:n.result)===!1&&(n==null?void 0:n.errormsg)!=null){e(O.Factory.createFromApResponse(o));return}t(o)}},or=function(e,t,r,o=hr){let n=this.callbackManager.putCallback(o),s={m:r,i:n,n:e,o:t};this.peekMessageOut(s),this.websocket.send(JSON.stringify(s))};function vr(i){return O.Factory.createFromApResponse({result:!1,errormsg:i,errorcode:ne.UNDEFINED,statusCode:-1,detail:""})}function _r(i){if(i.m===5)return!0;try{return i.o.result==!1}catch(t){return!1}}var $,ir,nr,Ae=class{constructor(e){E(this,$);this.closeRequested=!1,this.reconnecting=!1,this.connectionConfiguration=e.connectionConfiguration,this.pinger=new Ee,this.resubscriber=new fe,this.reauther=new de,this.connection=null}getResubscriber(){return this.resubscriber}getReauther(){return this.reauther}getConnection(){if(this.reconnecting)throw new O("unable to make notbank request. websocket reconnecting",-1);return this.connection}reconnect(){return u(this,null,function*(){this.reconnecting||this.closeRequested||(this.reconnecting=!0,this.closeCurrentConnection(),this.connection=a(this,$,nr).call(this),yield a(this,$,ir).call(this),this.reauther.makeAuthentication(this.connection),this.resubscriber.makeSubscriptions(this.connection),this.pinger.startPing(this.connection,this),this.reconnecting=!1)})}closeCurrentConnection(){var t;this.pinger.stop();var e=(t=this.connection)==null?void 0:t.close();return e}close(){this.closeRequested=!0;var e=this.closeCurrentConnection();return e}};$=new WeakSet,ir=function(){return u(this,null,function*(){for(;!this.closeRequested;)try{yield Promise.race([this.connection.connect(),new Promise((e,t)=>setTimeout(t,1e4))]);return}catch(e){}})},nr=function(){var e,t;return new X({domain:this.connectionConfiguration.domain,peekMessageIn:this.connectionConfiguration.peekMessageIn,peekMessageOut:this.connectionConfiguration.peekMessageOut,websocketHooks:{onMessage:(e=this.connectionConfiguration.websocketHooks)==null?void 0:e.onMessage,onOpen:(t=this.connectionConfiguration.websocketHooks)==null?void 0:t.onOpen,onError:r=>{var o,n;this.reconnecting||(n=(o=this.connectionConfiguration.websocketHooks)==null?void 0:o.onError)==null||n.call(o,r)},onClose:r=>{var o,n;this.reconnecting||!this.closeRequested||(n=(o=this.connectionConfiguration.websocketHooks)==null?void 0:o.onClose)==null||n.call(o,r)}}})};var Ie=class{constructor(e){this.restarter=e.restarter}updateSessionToken(e){throw new Error("Method not implemented.")}apRequest(e,t,r){return e==="LogOut"&&this.restarter.getReauther().removeAuthentication(),this.restarter.getConnection().apRequest(e,t,r)}nbRequest(e,t,r,o){throw new Error("websocket client does not support nb methods.")}authenticateUser(e){return u(this,null,function*(){yield this.restarter.getConnection().authenticateUser(e),this.restarter.getReauther().updateAuthentication(t=>t.authenticateUser(e))})}subscribe(e,t,r,o,n){return u(this,null,function*(){yield this.restarter.getConnection().subscribe(e,t,r,o,n),this.restarter.getResubscriber().saveSubscription({endpoint:e,firstIdentifier:t,secondIdentifier:r,message:o,subscriptionHandlers:n})})}unsubscribe(e,t,r,o,n){return u(this,null,function*(){yield this.restarter.getConnection().unsubscribe(e,t,r,o,n),this.restarter.getResubscriber().removeSubscription(n)})}get readyState(){return this.restarter.getConnection().readyState}connect(){return this.restarter.reconnect()}close(){return this.restarter.close()}};function P(i,e){return e==null?null:g(i,e)}function g(i,e){return{eventName:i,eventHandler:t=>e(Cr(t.o))}}function Cr(i){return JSON.parse(i)}var Pe=class{constructor(e){this.OMS_ID=1;this.connection=e}subscribeLevel1(e,t,r){let o=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeLevel1",e.InstrumentId||null,null,o,[g("SubscribeLevel1",t),g("Level1UpdateEvent",r)])}unsubscribeLevel1(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);yield this.connection.unsubscribe("UnsubscribeLevel1",e.InstrumentId||null,null,t,["SubscribeLevel1","UnsubscribeLevel1"])})}subscribeLevel2(e,t,r){let o=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeLevel2",e.InstrumentId,null,o,[g("SubscribeLevel2",t),g("Level2UpdateEvent",r)])}unsubscribeLevel2(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeLevel2",e.InstrumentId||null,null,t,[I.get("SubscribeLevel2",e.InstrumentId)])}subscribeTrades(e,t){let r=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeTrades",e.InstrumentId,null,r,[g("SubscribeTrades",o=>t(Re(o)))])}unsubscribeTrades(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeTrades",e.InstrumentId,null,t,["SubscribeTrades"])}subscribeTicker(e,t,r){let o=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeTicker",e.InstrumentId||null,null,o,[g("SubscribeTicker",t),g("TickerDataUpdateEvent_"+e.InstrumentId,r)])}unsubscribeTicker(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeTicker",e.InstrumentId||null,null,t,["SubscribeTicker"])}subscribeAccountEvents(e,t){let r=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeAccountEvents",e.AccountId,null,r,[P("WithdrawTicketUpdateEvent",t.withdrawTicketUpdateEventHandler||null),P("OrderTradeEvent",t.orderTradeEventHandler||null),P("OrderStateEvent",t.orderStateEventHandler||null),P("DepositTicketUpdateEvent",t.depositTicketUpdateEventHandler||null),P("AccountPositionEvent",t.accountPositionEventHandler||null),P("AccountInfoUpdateEvent",t.accountInfoUpdateEventHandler||null),P("CancelOrderRejectEvent",t.cancelOrderRejectEventHandler||null),P("DepositEvent",t.depositEventHandler||null),P("TransactionEvent",t.transactionEventHandler||null)].filter(o=>o!=null))}unsubscribeAccountEvents(e){return u(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeAccountEvents",e.AccountId,null,t,["WithdrawTicketUpdateEvent","OrderTradeEvent","OrderStateEvent","DepositTicketUpdateEvent","AccountPositionEvent","AccountInfoUpdateEvent","CancelOrderRejectEvent","DepositEvent","TransactionEvent"])})}subscribeOrderStateEvents(e,t){let r=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeOrderStateEvents",e.AccountId,e.InstrumentId||null,r,[g("OrderStateEvent",t)])}unsubscribeOrderStateEvents(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeOrderStateEvents",e.AccountId,e.InstrumentId||null,t,["SubscribeOrderStateEvents"])}};var ge=class{constructor(e){var t=e!=null&&e.withReconnect?new Ie({restarter:new Ae({connectionConfiguration:e||{}})}):new X(e);this.serviceConnection=t,this.getReadyState=()=>t.readyState}connect(){return this.serviceConnection.connect()}close(){return this.serviceConnection.close()}get isConnecting(){return this.getReadyState()===WebSocket.CONNECTING}get isConnected(){return this.getReadyState()===WebSocket.OPEN}get isClosing(){return this.getReadyState()===WebSocket.CLOSING}get isClosed(){return this.getReadyState()===WebSocket.CLOSED}authenticateUser(e){return u(this,null,function*(){var t=oe(),r=ie(e.ApiPublicKey,e.ApiSecretKey,e.UserId,t);yield this.serviceConnection.authenticateUser({APIKey:e.ApiPublicKey,Signature:r,UserId:e.UserId,Nonce:t})})}getConnection(){return this.serviceConnection}newAccountService(){return new G(this.serviceConnection)}newAuthService(){return new k(this.serviceConnection)}newFeeService(){return new y(this.serviceConnection)}newInstrumentService(){return new F(this.serviceConnection)}newProductService(){return new W(this.serviceConnection)}newReportService(){return new B(this.serviceConnection)}newSystemService(){return new H(this.serviceConnection)}getSubscriptionService(){return new Pe(this.serviceConnection)}newTradingService(){return new V(this.serviceConnection)}newUserService(){return new Y(this.serviceConnection)}newWalletService(){return new Q(this.serviceConnection)}newQuoteService(){return new J(this.serviceConnection)}};var Ar="api.notbank.exchange",te=class te{constructor(e){this.connection=e.connection,this.accountService=e.accountService,this.authService=e.authService,this.feeService=e.feeService,this.instrumentService=e.instrumentService,this.productService=e.productService,this.reportService=e.reportService,this.getSubscriptionService=()=>e.getSubscriptionService(),this.systemService=e.systemService,this.tradingService=e.tradingService,this.userService=e.userService,this.walletService=e.walletService,this.quoteService=e.quoteService,this.authenticateUser=e.authenticate,this.connect=e.connect,this.close=e.close}getAccountService(){return this.accountService}getAuthService(){return this.authService}getFeeService(){return this.feeService}getInstrumentService(){return this.instrumentService}getProductService(){return this.productService}getReportService(){return this.reportService}getSystemService(){return this.systemService}getTradingService(){return this.tradingService}getUserService(){return this.userService}getWalletService(){return this.walletService}getQuoteService(){return this.quoteService}getConnection(){return this.connection}};te.Factory=class{static createRestClient(t=Ar){var r=new le(t);return new te({connection:r.getConnection(),accountService:r.newAccountService(),authService:r.newAuthService(),feeService:r.newFeeService(),instrumentService:r.newInstrumentService(),productService:r.newProductService(),reportService:r.newReportService(),getSubscriptionService:()=>{throw new O("NotbankError. subcription service only exists for websocket connection",-1)},systemService:r.newSystemService(),tradingService:r.newTradingService(),userService:r.newUserService(),walletService:r.newWalletService(),quoteService:r.newQuoteService(),authenticate:o=>r.authenticateUser(o),connect:()=>Promise.resolve(null),close:()=>Promise.resolve(null)})}static createWebsocketClient(t){var r=new ge(t);return new te({connection:r.getConnection(),accountService:r.newAccountService(),authService:r.newAuthService(),feeService:r.newFeeService(),instrumentService:r.newInstrumentService(),productService:r.newProductService(),reportService:r.newReportService(),getSubscriptionService:()=>r.getSubscriptionService(),systemService:r.newSystemService(),tradingService:r.newTradingService(),userService:r.newUserService(),walletService:r.newWalletService(),quoteService:r.newQuoteService(),authenticate:o=>r.authenticateUser(o),connect:()=>r.connect(),close:()=>r.close()})}};var Ne=te;return Tr(Ir);})();
//# sourceMappingURL=bundle.min.js.map