coinrayjs 2.0.12 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coinrayjs.es.js +366 -366
- package/dist/coinrayjs.es.js.map +1 -1
- package/dist/coinrayjs.js +2 -2
- package/dist/coinrayjs.js.map +1 -1
- package/package.json +1 -1
package/dist/coinrayjs.js
CHANGED
|
@@ -40,7 +40,7 @@ var Il;function z(){return Il.apply(null,arguments)}function t0(t){Il=t}function
|
|
|
40
40
|
Arguments: `+Array.prototype.slice.call(s).join("")+`
|
|
41
41
|
`+new Error().stack),n=!1}return e.apply(this,arguments)},e)}var Yl={};function Kl(t,e){z.deprecationHandler!=null&&z.deprecationHandler(t,e),Yl[t]||(Hl(e),Yl[t]=!0)}z.suppressDeprecationWarnings=!1,z.deprecationHandler=null;function wr(t){return typeof Function<"u"&&t instanceof Function||Object.prototype.toString.call(t)==="[object Function]"}function n0(t){var e,n;for(n in t)ke(t,n)&&(e=t[n],wr(e)?this[n]=e:this["_"+n]=e);this._config=t,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function So(t,e){var n=Xr({},t),s;for(s in e)ke(e,s)&&(wn(t[s])&&wn(e[s])?(n[s]={},Xr(n[s],t[s]),Xr(n[s],e[s])):e[s]!=null?n[s]=e[s]:delete n[s]);for(s in t)ke(t,s)&&!ke(e,s)&&wn(t[s])&&(n[s]=Xr({},n[s]));return n}function vo(t){t!=null&&this.set(t)}var To;Object.keys?To=Object.keys:To=function(t){var e,n=[];for(e in t)ke(t,e)&&n.push(e);return n};var i0={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function s0(t,e,n){var s=this._calendar[t]||this._calendar.sameElse;return wr(s)?s.call(e,n):s}function br(t,e,n){var s=""+Math.abs(t),a=e-s.length,c=t>=0;return(c?n?"+":"":"-")+Math.pow(10,Math.max(0,a)).toString().substr(1)+s}var Eo=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,As=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Ao={},Wn={};function ie(t,e,n,s){var a=s;typeof s=="string"&&(a=function(){return this[s]()}),t&&(Wn[t]=a),e&&(Wn[e[0]]=function(){return br(a.apply(this,arguments),e[1],e[2])}),n&&(Wn[n]=function(){return this.localeData().ordinal(a.apply(this,arguments),t)})}function a0(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function o0(t){var e=t.match(Eo),n,s;for(n=0,s=e.length;n<s;n++)Wn[e[n]]?e[n]=Wn[e[n]]:e[n]=a0(e[n]);return function(a){var c="",u;for(u=0;u<s;u++)c+=wr(e[u])?e[u].call(a,t):e[u];return c}}function Os(t,e){return t.isValid()?(e=ql(e,t.localeData()),Ao[e]=Ao[e]||o0(e),Ao[e](t)):t.localeData().invalidDate()}function ql(t,e){var n=5;function s(a){return e.longDateFormat(a)||a}for(As.lastIndex=0;n>=0&&As.test(t);)t=t.replace(As,s),As.lastIndex=0,n-=1;return t}var u0={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function c0(t){var e=this._longDateFormat[t],n=this._longDateFormat[t.toUpperCase()];return e||!n?e:(this._longDateFormat[t]=n.match(Eo).map(function(s){return s==="MMMM"||s==="MM"||s==="DD"||s==="dddd"?s.slice(1):s}).join(""),this._longDateFormat[t])}var l0="Invalid date";function f0(){return this._invalidDate}var h0="%d",d0=/\d{1,2}/;function p0(t){return this._ordinal.replace("%d",t)}var m0={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function g0(t,e,n,s){var a=this._relativeTime[n];return wr(a)?a(t,e,n,s):a.replace(/%d/i,t)}function y0(t,e){var n=this._relativeTime[t>0?"future":"past"];return wr(n)?n(e):n.replace(/%s/i,e)}var $l={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function Vt(t){return typeof t=="string"?$l[t]||$l[t.toLowerCase()]:void 0}function Oo(t){var e={},n,s;for(s in t)ke(t,s)&&(n=Vt(s),n&&(e[n]=t[s]));return e}var _0={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function w0(t){var e=[],n;for(n in t)ke(t,n)&&e.push({unit:n,priority:_0[n]});return e.sort(function(s,a){return s.priority-a.priority}),e}var Gl=/\d/,Nt=/\d\d/,Vl=/\d{3}/,ko=/\d{4}/,ks=/[+-]?\d{6}/,Ke=/\d\d?/,zl=/\d\d\d\d?/,jl=/\d\d\d\d\d\d?/,Cs=/\d{1,3}/,Co=/\d{1,4}/,xs=/[+-]?\d{1,6}/,Hn=/\d+/,Ps=/[+-]?\d+/,b0=/Z|[+-]\d\d:?\d\d/gi,Rs=/Z|[+-]\d\d(?::?\d\d)?/gi,S0=/[+-]?\d+(\.\d{1,3})?/,Ai=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,Yn=/^[1-9]\d?/,xo=/^([1-9]\d|\d)/,Ds;Ds={};function Q(t,e,n){Ds[t]=wr(e)?e:function(s,a){return s&&n?n:e}}function v0(t,e){return ke(Ds,t)?Ds[t](e._strict,e._locale):new RegExp(T0(t))}function T0(t){return Rr(t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,n,s,a,c){return n||s||a||c}))}function Rr(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function zt(t){return t<0?Math.ceil(t)||0:Math.floor(t)}function be(t){var e=+t,n=0;return e!==0&&isFinite(e)&&(n=zt(e)),n}var Po={};function Le(t,e){var n,s=e,a;for(typeof t=="string"&&(t=[t]),Pr(e)&&(s=function(c,u){u[e]=be(c)}),a=t.length,n=0;n<a;n++)Po[t[n]]=s}function Oi(t,e){Le(t,function(n,s,a,c){a._w=a._w||{},e(n,a._w,a,c)})}function E0(t,e,n){e!=null&&ke(Po,t)&&Po[t](e,n._a,n,t)}function Ms(t){return t%4===0&&t%100!==0||t%400===0}var pt=0,Dr=1,Sr=2,rt=3,ur=4,Mr=5,bn=6,A0=7,O0=8;ie("Y",0,0,function(){var t=this.year();return t<=9999?br(t,4):"+"+t}),ie(0,["YY",2],0,function(){return this.year()%100}),ie(0,["YYYY",4],0,"year"),ie(0,["YYYYY",5],0,"year"),ie(0,["YYYYYY",6,!0],0,"year"),Q("Y",Ps),Q("YY",Ke,Nt),Q("YYYY",Co,ko),Q("YYYYY",xs,ks),Q("YYYYYY",xs,ks),Le(["YYYYY","YYYYYY"],pt),Le("YYYY",function(t,e){e[pt]=t.length===2?z.parseTwoDigitYear(t):be(t)}),Le("YY",function(t,e){e[pt]=z.parseTwoDigitYear(t)}),Le("Y",function(t,e){e[pt]=parseInt(t,10)});function ki(t){return Ms(t)?366:365}z.parseTwoDigitYear=function(t){return be(t)+(be(t)>68?1900:2e3)};var Jl=Kn("FullYear",!0);function k0(){return Ms(this.year())}function Kn(t,e){return function(n){return n!=null?(Ql(this,t,n),z.updateOffset(this,e),this):Ci(this,t)}}function Ci(t,e){if(!t.isValid())return NaN;var n=t._d,s=t._isUTC;switch(e){case"Milliseconds":return s?n.getUTCMilliseconds():n.getMilliseconds();case"Seconds":return s?n.getUTCSeconds():n.getSeconds();case"Minutes":return s?n.getUTCMinutes():n.getMinutes();case"Hours":return s?n.getUTCHours():n.getHours();case"Date":return s?n.getUTCDate():n.getDate();case"Day":return s?n.getUTCDay():n.getDay();case"Month":return s?n.getUTCMonth():n.getMonth();case"FullYear":return s?n.getUTCFullYear():n.getFullYear();default:return NaN}}function Ql(t,e,n){var s,a,c,u,l;if(!(!t.isValid()||isNaN(n))){switch(s=t._d,a=t._isUTC,e){case"Milliseconds":return void(a?s.setUTCMilliseconds(n):s.setMilliseconds(n));case"Seconds":return void(a?s.setUTCSeconds(n):s.setSeconds(n));case"Minutes":return void(a?s.setUTCMinutes(n):s.setMinutes(n));case"Hours":return void(a?s.setUTCHours(n):s.setHours(n));case"Date":return void(a?s.setUTCDate(n):s.setDate(n));case"FullYear":break;default:return}c=n,u=t.month(),l=t.date(),l=l===29&&u===1&&!Ms(c)?28:l,a?s.setUTCFullYear(c,u,l):s.setFullYear(c,u,l)}}function C0(t){return t=Vt(t),wr(this[t])?this[t]():this}function x0(t,e){if(typeof t=="object"){t=Oo(t);var n=w0(t),s,a=n.length;for(s=0;s<a;s++)this[n[s].unit](t[n[s].unit])}else if(t=Vt(t),wr(this[t]))return this[t](e);return this}function P0(t,e){return(t%e+e)%e}var Xe;Array.prototype.indexOf?Xe=Array.prototype.indexOf:Xe=function(t){var e;for(e=0;e<this.length;++e)if(this[e]===t)return e;return-1};function Ro(t,e){if(isNaN(t)||isNaN(e))return NaN;var n=P0(e,12);return t+=(e-n)/12,n===1?Ms(t)?29:28:31-n%7%2}ie("M",["MM",2],"Mo",function(){return this.month()+1}),ie("MMM",0,0,function(t){return this.localeData().monthsShort(this,t)}),ie("MMMM",0,0,function(t){return this.localeData().months(this,t)}),Q("M",Ke,Yn),Q("MM",Ke,Nt),Q("MMM",function(t,e){return e.monthsShortRegex(t)}),Q("MMMM",function(t,e){return e.monthsRegex(t)}),Le(["M","MM"],function(t,e){e[Dr]=be(t)-1}),Le(["MMM","MMMM"],function(t,e,n,s){var a=n._locale.monthsParse(t,s,n._strict);a!=null?e[Dr]=a:de(n).invalidMonth=t});var R0="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Zl="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Xl=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,D0=Ai,M0=Ai;function L0(t,e){return t?ar(this._months)?this._months[t.month()]:this._months[(this._months.isFormat||Xl).test(e)?"format":"standalone"][t.month()]:ar(this._months)?this._months:this._months.standalone}function N0(t,e){return t?ar(this._monthsShort)?this._monthsShort[t.month()]:this._monthsShort[Xl.test(e)?"format":"standalone"][t.month()]:ar(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function U0(t,e,n){var s,a,c,u=t.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],s=0;s<12;++s)c=_r([2e3,s]),this._shortMonthsParse[s]=this.monthsShort(c,"").toLocaleLowerCase(),this._longMonthsParse[s]=this.months(c,"").toLocaleLowerCase();return n?e==="MMM"?(a=Xe.call(this._shortMonthsParse,u),a!==-1?a:null):(a=Xe.call(this._longMonthsParse,u),a!==-1?a:null):e==="MMM"?(a=Xe.call(this._shortMonthsParse,u),a!==-1?a:(a=Xe.call(this._longMonthsParse,u),a!==-1?a:null)):(a=Xe.call(this._longMonthsParse,u),a!==-1?a:(a=Xe.call(this._shortMonthsParse,u),a!==-1?a:null))}function B0(t,e,n){var s,a,c;if(this._monthsParseExact)return U0.call(this,t,e,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),s=0;s<12;s++){if(a=_r([2e3,s]),n&&!this._longMonthsParse[s]&&(this._longMonthsParse[s]=new RegExp("^"+this.months(a,"").replace(".","")+"$","i"),this._shortMonthsParse[s]=new RegExp("^"+this.monthsShort(a,"").replace(".","")+"$","i")),!n&&!this._monthsParse[s]&&(c="^"+this.months(a,"")+"|^"+this.monthsShort(a,""),this._monthsParse[s]=new RegExp(c.replace(".",""),"i")),n&&e==="MMMM"&&this._longMonthsParse[s].test(t))return s;if(n&&e==="MMM"&&this._shortMonthsParse[s].test(t))return s;if(!n&&this._monthsParse[s].test(t))return s}}function ef(t,e){if(!t.isValid())return t;if(typeof e=="string"){if(/^\d+$/.test(e))e=be(e);else if(e=t.localeData().monthsParse(e),!Pr(e))return t}var n=e,s=t.date();return s=s<29?s:Math.min(s,Ro(t.year(),n)),t._isUTC?t._d.setUTCMonth(n,s):t._d.setMonth(n,s),t}function tf(t){return t!=null?(ef(this,t),z.updateOffset(this,!0),this):Ci(this,"Month")}function I0(){return Ro(this.year(),this.month())}function F0(t){return this._monthsParseExact?(ke(this,"_monthsRegex")||rf.call(this),t?this._monthsShortStrictRegex:this._monthsShortRegex):(ke(this,"_monthsShortRegex")||(this._monthsShortRegex=D0),this._monthsShortStrictRegex&&t?this._monthsShortStrictRegex:this._monthsShortRegex)}function W0(t){return this._monthsParseExact?(ke(this,"_monthsRegex")||rf.call(this),t?this._monthsStrictRegex:this._monthsRegex):(ke(this,"_monthsRegex")||(this._monthsRegex=M0),this._monthsStrictRegex&&t?this._monthsStrictRegex:this._monthsRegex)}function rf(){function t(h,m){return m.length-h.length}var e=[],n=[],s=[],a,c,u,l;for(a=0;a<12;a++)c=_r([2e3,a]),u=Rr(this.monthsShort(c,"")),l=Rr(this.months(c,"")),e.push(u),n.push(l),s.push(l),s.push(u);e.sort(t),n.sort(t),s.sort(t),this._monthsRegex=new RegExp("^("+s.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+e.join("|")+")","i")}function H0(t,e,n,s,a,c,u){var l;return t<100&&t>=0?(l=new Date(t+400,e,n,s,a,c,u),isFinite(l.getFullYear())&&l.setFullYear(t)):l=new Date(t,e,n,s,a,c,u),l}function xi(t){var e,n;return t<100&&t>=0?(n=Array.prototype.slice.call(arguments),n[0]=t+400,e=new Date(Date.UTC.apply(null,n)),isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t)):e=new Date(Date.UTC.apply(null,arguments)),e}function Ls(t,e,n){var s=7+e-n,a=(7+xi(t,0,s).getUTCDay()-e)%7;return-a+s-1}function nf(t,e,n,s,a){var c=(7+n-s)%7,u=Ls(t,s,a),l=1+7*(e-1)+c+u,h,m;return l<=0?(h=t-1,m=ki(h)+l):l>ki(t)?(h=t+1,m=l-ki(t)):(h=t,m=l),{year:h,dayOfYear:m}}function Pi(t,e,n){var s=Ls(t.year(),e,n),a=Math.floor((t.dayOfYear()-s-1)/7)+1,c,u;return a<1?(u=t.year()-1,c=a+Lr(u,e,n)):a>Lr(t.year(),e,n)?(c=a-Lr(t.year(),e,n),u=t.year()+1):(u=t.year(),c=a),{week:c,year:u}}function Lr(t,e,n){var s=Ls(t,e,n),a=Ls(t+1,e,n);return(ki(t)-s+a)/7}ie("w",["ww",2],"wo","week"),ie("W",["WW",2],"Wo","isoWeek"),Q("w",Ke,Yn),Q("ww",Ke,Nt),Q("W",Ke,Yn),Q("WW",Ke,Nt),Oi(["w","ww","W","WW"],function(t,e,n,s){e[s.substr(0,1)]=be(t)});function Y0(t){return Pi(t,this._week.dow,this._week.doy).week}var K0={dow:0,doy:6};function q0(){return this._week.dow}function $0(){return this._week.doy}function G0(t){var e=this.localeData().week(this);return t==null?e:this.add((t-e)*7,"d")}function V0(t){var e=Pi(this,1,4).week;return t==null?e:this.add((t-e)*7,"d")}ie("d",0,"do","day"),ie("dd",0,0,function(t){return this.localeData().weekdaysMin(this,t)}),ie("ddd",0,0,function(t){return this.localeData().weekdaysShort(this,t)}),ie("dddd",0,0,function(t){return this.localeData().weekdays(this,t)}),ie("e",0,0,"weekday"),ie("E",0,0,"isoWeekday"),Q("d",Ke),Q("e",Ke),Q("E",Ke),Q("dd",function(t,e){return e.weekdaysMinRegex(t)}),Q("ddd",function(t,e){return e.weekdaysShortRegex(t)}),Q("dddd",function(t,e){return e.weekdaysRegex(t)}),Oi(["dd","ddd","dddd"],function(t,e,n,s){var a=n._locale.weekdaysParse(t,s,n._strict);a!=null?e.d=a:de(n).invalidWeekday=t}),Oi(["d","e","E"],function(t,e,n,s){e[s]=be(t)});function z0(t,e){return typeof t!="string"?t:isNaN(t)?(t=e.weekdaysParse(t),typeof t=="number"?t:null):parseInt(t,10)}function j0(t,e){return typeof t=="string"?e.weekdaysParse(t)%7||7:isNaN(t)?null:t}function Do(t,e){return t.slice(e,7).concat(t.slice(0,e))}var J0="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),sf="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Q0="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Z0=Ai,X0=Ai,ey=Ai;function ty(t,e){var n=ar(this._weekdays)?this._weekdays:this._weekdays[t&&t!==!0&&this._weekdays.isFormat.test(e)?"format":"standalone"];return t===!0?Do(n,this._week.dow):t?n[t.day()]:n}function ry(t){return t===!0?Do(this._weekdaysShort,this._week.dow):t?this._weekdaysShort[t.day()]:this._weekdaysShort}function ny(t){return t===!0?Do(this._weekdaysMin,this._week.dow):t?this._weekdaysMin[t.day()]:this._weekdaysMin}function iy(t,e,n){var s,a,c,u=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],s=0;s<7;++s)c=_r([2e3,1]).day(s),this._minWeekdaysParse[s]=this.weekdaysMin(c,"").toLocaleLowerCase(),this._shortWeekdaysParse[s]=this.weekdaysShort(c,"").toLocaleLowerCase(),this._weekdaysParse[s]=this.weekdays(c,"").toLocaleLowerCase();return n?e==="dddd"?(a=Xe.call(this._weekdaysParse,u),a!==-1?a:null):e==="ddd"?(a=Xe.call(this._shortWeekdaysParse,u),a!==-1?a:null):(a=Xe.call(this._minWeekdaysParse,u),a!==-1?a:null):e==="dddd"?(a=Xe.call(this._weekdaysParse,u),a!==-1||(a=Xe.call(this._shortWeekdaysParse,u),a!==-1)?a:(a=Xe.call(this._minWeekdaysParse,u),a!==-1?a:null)):e==="ddd"?(a=Xe.call(this._shortWeekdaysParse,u),a!==-1||(a=Xe.call(this._weekdaysParse,u),a!==-1)?a:(a=Xe.call(this._minWeekdaysParse,u),a!==-1?a:null)):(a=Xe.call(this._minWeekdaysParse,u),a!==-1||(a=Xe.call(this._weekdaysParse,u),a!==-1)?a:(a=Xe.call(this._shortWeekdaysParse,u),a!==-1?a:null))}function sy(t,e,n){var s,a,c;if(this._weekdaysParseExact)return iy.call(this,t,e,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),s=0;s<7;s++){if(a=_r([2e3,1]).day(s),n&&!this._fullWeekdaysParse[s]&&(this._fullWeekdaysParse[s]=new RegExp("^"+this.weekdays(a,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[s]=new RegExp("^"+this.weekdaysShort(a,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[s]=new RegExp("^"+this.weekdaysMin(a,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[s]||(c="^"+this.weekdays(a,"")+"|^"+this.weekdaysShort(a,"")+"|^"+this.weekdaysMin(a,""),this._weekdaysParse[s]=new RegExp(c.replace(".",""),"i")),n&&e==="dddd"&&this._fullWeekdaysParse[s].test(t))return s;if(n&&e==="ddd"&&this._shortWeekdaysParse[s].test(t))return s;if(n&&e==="dd"&&this._minWeekdaysParse[s].test(t))return s;if(!n&&this._weekdaysParse[s].test(t))return s}}function ay(t){if(!this.isValid())return t!=null?this:NaN;var e=Ci(this,"Day");return t!=null?(t=z0(t,this.localeData()),this.add(t-e,"d")):e}function oy(t){if(!this.isValid())return t!=null?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return t==null?e:this.add(t-e,"d")}function uy(t){if(!this.isValid())return t!=null?this:NaN;if(t!=null){var e=j0(t,this.localeData());return this.day(this.day()%7?e:e-7)}else return this.day()||7}function cy(t){return this._weekdaysParseExact?(ke(this,"_weekdaysRegex")||Mo.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(ke(this,"_weekdaysRegex")||(this._weekdaysRegex=Z0),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)}function ly(t){return this._weekdaysParseExact?(ke(this,"_weekdaysRegex")||Mo.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(ke(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=X0),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function fy(t){return this._weekdaysParseExact?(ke(this,"_weekdaysRegex")||Mo.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(ke(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=ey),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function Mo(){function t(w,T){return T.length-w.length}var e=[],n=[],s=[],a=[],c,u,l,h,m;for(c=0;c<7;c++)u=_r([2e3,1]).day(c),l=Rr(this.weekdaysMin(u,"")),h=Rr(this.weekdaysShort(u,"")),m=Rr(this.weekdays(u,"")),e.push(l),n.push(h),s.push(m),a.push(l),a.push(h),a.push(m);e.sort(t),n.sort(t),s.sort(t),a.sort(t),this._weekdaysRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+e.join("|")+")","i")}function Lo(){return this.hours()%12||12}function hy(){return this.hours()||24}ie("H",["HH",2],0,"hour"),ie("h",["hh",2],0,Lo),ie("k",["kk",2],0,hy),ie("hmm",0,0,function(){return""+Lo.apply(this)+br(this.minutes(),2)}),ie("hmmss",0,0,function(){return""+Lo.apply(this)+br(this.minutes(),2)+br(this.seconds(),2)}),ie("Hmm",0,0,function(){return""+this.hours()+br(this.minutes(),2)}),ie("Hmmss",0,0,function(){return""+this.hours()+br(this.minutes(),2)+br(this.seconds(),2)});function af(t,e){ie(t,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}af("a",!0),af("A",!1);function of(t,e){return e._meridiemParse}Q("a",of),Q("A",of),Q("H",Ke,xo),Q("h",Ke,Yn),Q("k",Ke,Yn),Q("HH",Ke,Nt),Q("hh",Ke,Nt),Q("kk",Ke,Nt),Q("hmm",zl),Q("hmmss",jl),Q("Hmm",zl),Q("Hmmss",jl),Le(["H","HH"],rt),Le(["k","kk"],function(t,e,n){var s=be(t);e[rt]=s===24?0:s}),Le(["a","A"],function(t,e,n){n._isPm=n._locale.isPM(t),n._meridiem=t}),Le(["h","hh"],function(t,e,n){e[rt]=be(t),de(n).bigHour=!0}),Le("hmm",function(t,e,n){var s=t.length-2;e[rt]=be(t.substr(0,s)),e[ur]=be(t.substr(s)),de(n).bigHour=!0}),Le("hmmss",function(t,e,n){var s=t.length-4,a=t.length-2;e[rt]=be(t.substr(0,s)),e[ur]=be(t.substr(s,2)),e[Mr]=be(t.substr(a)),de(n).bigHour=!0}),Le("Hmm",function(t,e,n){var s=t.length-2;e[rt]=be(t.substr(0,s)),e[ur]=be(t.substr(s))}),Le("Hmmss",function(t,e,n){var s=t.length-4,a=t.length-2;e[rt]=be(t.substr(0,s)),e[ur]=be(t.substr(s,2)),e[Mr]=be(t.substr(a))});function dy(t){return(t+"").toLowerCase().charAt(0)==="p"}var py=/[ap]\.?m?\.?/i,my=Kn("Hours",!0);function gy(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"}var uf={calendar:i0,longDateFormat:u0,invalidDate:l0,ordinal:h0,dayOfMonthOrdinalParse:d0,relativeTime:m0,months:R0,monthsShort:Zl,week:K0,weekdays:J0,weekdaysMin:Q0,weekdaysShort:sf,meridiemParse:py},Ge={},Ri={},Di;function yy(t,e){var n,s=Math.min(t.length,e.length);for(n=0;n<s;n+=1)if(t[n]!==e[n])return n;return s}function cf(t){return t&&t.toLowerCase().replace("_","-")}function _y(t){for(var e=0,n,s,a,c;e<t.length;){for(c=cf(t[e]).split("-"),n=c.length,s=cf(t[e+1]),s=s?s.split("-"):null;n>0;){if(a=Ns(c.slice(0,n).join("-")),a)return a;if(s&&s.length>=n&&yy(c,s)>=n-1)break;n--}e++}return Di}function wy(t){return!!(t&&t.match("^[^/\\\\]*$"))}function Ns(t){var e=null,n;if(Ge[t]===void 0&&typeof module<"u"&&module&&module.exports&&wy(t))try{e=Di._abbr,n=require,n("./locale/"+t),en(e)}catch{Ge[t]=null}return Ge[t]}function en(t,e){var n;return t&&(Ct(e)?n=Nr(t):n=No(t,e),n?Di=n:typeof console<"u"&&console.warn&&console.warn("Locale "+t+" not found. Did you forget to load it?")),Di._abbr}function No(t,e){if(e!==null){var n,s=uf;if(e.abbr=t,Ge[t]!=null)Kl("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=Ge[t]._config;else if(e.parentLocale!=null)if(Ge[e.parentLocale]!=null)s=Ge[e.parentLocale]._config;else if(n=Ns(e.parentLocale),n!=null)s=n._config;else return Ri[e.parentLocale]||(Ri[e.parentLocale]=[]),Ri[e.parentLocale].push({name:t,config:e}),null;return Ge[t]=new vo(So(s,e)),Ri[t]&&Ri[t].forEach(function(a){No(a.name,a.config)}),en(t),Ge[t]}else return delete Ge[t],null}function by(t,e){if(e!=null){var n,s,a=uf;Ge[t]!=null&&Ge[t].parentLocale!=null?Ge[t].set(So(Ge[t]._config,e)):(s=Ns(t),s!=null&&(a=s._config),e=So(a,e),s==null&&(e.abbr=t),n=new vo(e),n.parentLocale=Ge[t],Ge[t]=n),en(t)}else Ge[t]!=null&&(Ge[t].parentLocale!=null?(Ge[t]=Ge[t].parentLocale,t===en()&&en(t)):Ge[t]!=null&&delete Ge[t]);return Ge[t]}function Nr(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return Di;if(!ar(t)){if(e=Ns(t),e)return e;t=[t]}return _y(t)}function Sy(){return To(Ge)}function Uo(t){var e,n=t._a;return n&&de(t).overflow===-2&&(e=n[Dr]<0||n[Dr]>11?Dr:n[Sr]<1||n[Sr]>Ro(n[pt],n[Dr])?Sr:n[rt]<0||n[rt]>24||n[rt]===24&&(n[ur]!==0||n[Mr]!==0||n[bn]!==0)?rt:n[ur]<0||n[ur]>59?ur:n[Mr]<0||n[Mr]>59?Mr:n[bn]<0||n[bn]>999?bn:-1,de(t)._overflowDayOfYear&&(e<pt||e>Sr)&&(e=Sr),de(t)._overflowWeeks&&e===-1&&(e=A0),de(t)._overflowWeekday&&e===-1&&(e=O0),de(t).overflow=e),t}var vy=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ty=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ey=/Z|[+-]\d\d(?::?\d\d)?/,Us=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Bo=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Ay=/^\/?Date\((-?\d+)/i,Oy=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,ky={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function lf(t){var e,n,s=t._i,a=vy.exec(s)||Ty.exec(s),c,u,l,h,m=Us.length,w=Bo.length;if(a){for(de(t).iso=!0,e=0,n=m;e<n;e++)if(Us[e][1].exec(a[1])){u=Us[e][0],c=Us[e][2]!==!1;break}if(u==null){t._isValid=!1;return}if(a[3]){for(e=0,n=w;e<n;e++)if(Bo[e][1].exec(a[3])){l=(a[2]||" ")+Bo[e][0];break}if(l==null){t._isValid=!1;return}}if(!c&&l!=null){t._isValid=!1;return}if(a[4])if(Ey.exec(a[4]))h="Z";else{t._isValid=!1;return}t._f=u+(l||"")+(h||""),Fo(t)}else t._isValid=!1}function Cy(t,e,n,s,a,c){var u=[xy(t),Zl.indexOf(e),parseInt(n,10),parseInt(s,10),parseInt(a,10)];return c&&u.push(parseInt(c,10)),u}function xy(t){var e=parseInt(t,10);return e<=49?2e3+e:e<=999?1900+e:e}function Py(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function Ry(t,e,n){if(t){var s=sf.indexOf(t),a=new Date(e[0],e[1],e[2]).getDay();if(s!==a)return de(n).weekdayMismatch=!0,n._isValid=!1,!1}return!0}function Dy(t,e,n){if(t)return ky[t];if(e)return 0;var s=parseInt(n,10),a=s%100,c=(s-a)/100;return c*60+a}function ff(t){var e=Oy.exec(Py(t._i)),n;if(e){if(n=Cy(e[4],e[3],e[2],e[5],e[6],e[7]),!Ry(e[1],n,t))return;t._a=n,t._tzm=Dy(e[8],e[9],e[10]),t._d=xi.apply(null,t._a),t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),de(t).rfc2822=!0}else t._isValid=!1}function My(t){var e=Ay.exec(t._i);if(e!==null){t._d=new Date(+e[1]);return}if(lf(t),t._isValid===!1)delete t._isValid;else return;if(ff(t),t._isValid===!1)delete t._isValid;else return;t._strict?t._isValid=!1:z.createFromInputFallback(t)}z.createFromInputFallback=Gt("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""))});function qn(t,e,n){return t??e??n}function Ly(t){var e=new Date(z.now());return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function Io(t){var e,n,s=[],a,c,u;if(!t._d){for(a=Ly(t),t._w&&t._a[Sr]==null&&t._a[Dr]==null&&Ny(t),t._dayOfYear!=null&&(u=qn(t._a[pt],a[pt]),(t._dayOfYear>ki(u)||t._dayOfYear===0)&&(de(t)._overflowDayOfYear=!0),n=xi(u,0,t._dayOfYear),t._a[Dr]=n.getUTCMonth(),t._a[Sr]=n.getUTCDate()),e=0;e<3&&t._a[e]==null;++e)t._a[e]=s[e]=a[e];for(;e<7;e++)t._a[e]=s[e]=t._a[e]==null?e===2?1:0:t._a[e];t._a[rt]===24&&t._a[ur]===0&&t._a[Mr]===0&&t._a[bn]===0&&(t._nextDay=!0,t._a[rt]=0),t._d=(t._useUTC?xi:H0).apply(null,s),c=t._useUTC?t._d.getUTCDay():t._d.getDay(),t._tzm!=null&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[rt]=24),t._w&&typeof t._w.d<"u"&&t._w.d!==c&&(de(t).weekdayMismatch=!0)}}function Ny(t){var e,n,s,a,c,u,l,h,m;e=t._w,e.GG!=null||e.W!=null||e.E!=null?(c=1,u=4,n=qn(e.GG,t._a[pt],Pi(qe(),1,4).year),s=qn(e.W,1),a=qn(e.E,1),(a<1||a>7)&&(h=!0)):(c=t._locale._week.dow,u=t._locale._week.doy,m=Pi(qe(),c,u),n=qn(e.gg,t._a[pt],m.year),s=qn(e.w,m.week),e.d!=null?(a=e.d,(a<0||a>6)&&(h=!0)):e.e!=null?(a=e.e+c,(e.e<0||e.e>6)&&(h=!0)):a=c),s<1||s>Lr(n,c,u)?de(t)._overflowWeeks=!0:h!=null?de(t)._overflowWeekday=!0:(l=nf(n,s,a,c,u),t._a[pt]=l.year,t._dayOfYear=l.dayOfYear)}z.ISO_8601=function(){},z.RFC_2822=function(){};function Fo(t){if(t._f===z.ISO_8601){lf(t);return}if(t._f===z.RFC_2822){ff(t);return}t._a=[],de(t).empty=!0;var e=""+t._i,n,s,a,c,u,l=e.length,h=0,m,w;for(a=ql(t._f,t._locale).match(Eo)||[],w=a.length,n=0;n<w;n++)c=a[n],s=(e.match(v0(c,t))||[])[0],s&&(u=e.substr(0,e.indexOf(s)),u.length>0&&de(t).unusedInput.push(u),e=e.slice(e.indexOf(s)+s.length),h+=s.length),Wn[c]?(s?de(t).empty=!1:de(t).unusedTokens.push(c),E0(c,s,t)):t._strict&&!s&&de(t).unusedTokens.push(c);de(t).charsLeftOver=l-h,e.length>0&&de(t).unusedInput.push(e),t._a[rt]<=12&&de(t).bigHour===!0&&t._a[rt]>0&&(de(t).bigHour=void 0),de(t).parsedDateParts=t._a.slice(0),de(t).meridiem=t._meridiem,t._a[rt]=Uy(t._locale,t._a[rt],t._meridiem),m=de(t).era,m!==null&&(t._a[pt]=t._locale.erasConvertYear(m,t._a[pt])),Io(t),Uo(t)}function Uy(t,e,n){var s;return n==null?e:t.meridiemHour!=null?t.meridiemHour(e,n):(t.isPM!=null&&(s=t.isPM(n),s&&e<12&&(e+=12),!s&&e===12&&(e=0)),e)}function By(t){var e,n,s,a,c,u,l=!1,h=t._f.length;if(h===0){de(t).invalidFormat=!0,t._d=new Date(NaN);return}for(a=0;a<h;a++)c=0,u=!1,e=bo({},t),t._useUTC!=null&&(e._useUTC=t._useUTC),e._f=t._f[a],Fo(e),_o(e)&&(u=!0),c+=de(e).charsLeftOver,c+=de(e).unusedTokens.length*10,de(e).score=c,l?c<s&&(s=c,n=e):(s==null||c<s||u)&&(s=c,n=e,u&&(l=!0));Xr(t,n||e)}function Iy(t){if(!t._d){var e=Oo(t._i),n=e.day===void 0?e.date:e.day;t._a=Fl([e.year,e.month,n,e.hour,e.minute,e.second,e.millisecond],function(s){return s&&parseInt(s,10)}),Io(t)}}function Fy(t){var e=new Ei(Uo(hf(t)));return e._nextDay&&(e.add(1,"d"),e._nextDay=void 0),e}function hf(t){var e=t._i,n=t._f;return t._locale=t._locale||Nr(t._l),e===null||n===void 0&&e===""?Es({nullInput:!0}):(typeof e=="string"&&(t._i=e=t._locale.preparse(e)),or(e)?new Ei(Uo(e)):(Ti(e)?t._d=e:ar(n)?By(t):n?Fo(t):Wy(t),_o(t)||(t._d=null),t))}function Wy(t){var e=t._i;Ct(e)?t._d=new Date(z.now()):Ti(e)?t._d=new Date(e.valueOf()):typeof e=="string"?My(t):ar(e)?(t._a=Fl(e.slice(0),function(n){return parseInt(n,10)}),Io(t)):wn(e)?Iy(t):Pr(e)?t._d=new Date(e):z.createFromInputFallback(t)}function df(t,e,n,s,a){var c={};return(e===!0||e===!1)&&(s=e,e=void 0),(n===!0||n===!1)&&(s=n,n=void 0),(wn(t)&&go(t)||ar(t)&&t.length===0)&&(t=void 0),c._isAMomentObject=!0,c._useUTC=c._isUTC=a,c._l=n,c._i=t,c._f=e,c._strict=s,Fy(c)}function qe(t,e,n,s){return df(t,e,n,s,!1)}var Hy=Gt("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=qe.apply(null,arguments);return this.isValid()&&t.isValid()?t<this?this:t:Es()}),Yy=Gt("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=qe.apply(null,arguments);return this.isValid()&&t.isValid()?t>this?this:t:Es()});function pf(t,e){var n,s;if(e.length===1&&ar(e[0])&&(e=e[0]),!e.length)return qe();for(n=e[0],s=1;s<e.length;++s)(!e[s].isValid()||e[s][t](n))&&(n=e[s]);return n}function Ky(){var t=[].slice.call(arguments,0);return pf("isBefore",t)}function qy(){var t=[].slice.call(arguments,0);return pf("isAfter",t)}var $y=function(){return Date.now?Date.now():+new Date},Mi=["year","quarter","month","week","day","hour","minute","second","millisecond"];function Gy(t){var e,n=!1,s,a=Mi.length;for(e in t)if(ke(t,e)&&!(Xe.call(Mi,e)!==-1&&(t[e]==null||!isNaN(t[e]))))return!1;for(s=0;s<a;++s)if(t[Mi[s]]){if(n)return!1;parseFloat(t[Mi[s]])!==be(t[Mi[s]])&&(n=!0)}return!0}function Vy(){return this._isValid}function zy(){return cr(NaN)}function Bs(t){var e=Oo(t),n=e.year||0,s=e.quarter||0,a=e.month||0,c=e.week||e.isoWeek||0,u=e.day||0,l=e.hour||0,h=e.minute||0,m=e.second||0,w=e.millisecond||0;this._isValid=Gy(e),this._milliseconds=+w+m*1e3+h*6e4+l*1e3*60*60,this._days=+u+c*7,this._months=+a+s*3+n*12,this._data={},this._locale=Nr(),this._bubble()}function Is(t){return t instanceof Bs}function Wo(t){return t<0?Math.round(-1*t)*-1:Math.round(t)}function jy(t,e,n){var s=Math.min(t.length,e.length),a=Math.abs(t.length-e.length),c=0,u;for(u=0;u<s;u++)be(t[u])!==be(e[u])&&c++;return c+a}function mf(t,e){ie(t,0,0,function(){var n=this.utcOffset(),s="+";return n<0&&(n=-n,s="-"),s+br(~~(n/60),2)+e+br(~~n%60,2)})}mf("Z",":"),mf("ZZ",""),Q("Z",Rs),Q("ZZ",Rs),Le(["Z","ZZ"],function(t,e,n){n._useUTC=!0,n._tzm=Ho(Rs,t)});var Jy=/([\+\-]|\d\d)/gi;function Ho(t,e){var n=(e||"").match(t),s,a,c;return n===null?null:(s=n[n.length-1]||[],a=(s+"").match(Jy)||["-",0,0],c=+(a[1]*60)+be(a[2]),c===0?0:a[0]==="+"?c:-c)}function Yo(t,e){var n,s;return e._isUTC?(n=e.clone(),s=(or(t)||Ti(t)?t.valueOf():qe(t).valueOf())-n.valueOf(),n._d.setTime(n._d.valueOf()+s),z.updateOffset(n,!1),n):qe(t).local()}function Ko(t){return-Math.round(t._d.getTimezoneOffset())}z.updateOffset=function(){};function Qy(t,e,n){var s=this._offset||0,a;if(!this.isValid())return t!=null?this:NaN;if(t!=null){if(typeof t=="string"){if(t=Ho(Rs,t),t===null)return this}else Math.abs(t)<16&&!n&&(t=t*60);return!this._isUTC&&e&&(a=Ko(this)),this._offset=t,this._isUTC=!0,a!=null&&this.add(a,"m"),s!==t&&(!e||this._changeInProgress?wf(this,cr(t-s,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,z.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?s:Ko(this)}function Zy(t,e){return t!=null?(typeof t!="string"&&(t=-t),this.utcOffset(t,e),this):-this.utcOffset()}function Xy(t){return this.utcOffset(0,t)}function e_(t){return this._isUTC&&(this.utcOffset(0,t),this._isUTC=!1,t&&this.subtract(Ko(this),"m")),this}function t_(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var t=Ho(b0,this._i);t!=null?this.utcOffset(t):this.utcOffset(0,!0)}return this}function r_(t){return this.isValid()?(t=t?qe(t).utcOffset():0,(this.utcOffset()-t)%60===0):!1}function n_(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function i_(){if(!Ct(this._isDSTShifted))return this._isDSTShifted;var t={},e;return bo(t,this),t=hf(t),t._a?(e=t._isUTC?_r(t._a):qe(t._a),this._isDSTShifted=this.isValid()&&jy(t._a,e.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function s_(){return this.isValid()?!this._isUTC:!1}function a_(){return this.isValid()?this._isUTC:!1}function gf(){return this.isValid()?this._isUTC&&this._offset===0:!1}var o_=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,u_=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function cr(t,e){var n=t,s=null,a,c,u;return Is(t)?n={ms:t._milliseconds,d:t._days,M:t._months}:Pr(t)||!isNaN(+t)?(n={},e?n[e]=+t:n.milliseconds=+t):(s=o_.exec(t))?(a=s[1]==="-"?-1:1,n={y:0,d:be(s[Sr])*a,h:be(s[rt])*a,m:be(s[ur])*a,s:be(s[Mr])*a,ms:be(Wo(s[bn]*1e3))*a}):(s=u_.exec(t))?(a=s[1]==="-"?-1:1,n={y:Sn(s[2],a),M:Sn(s[3],a),w:Sn(s[4],a),d:Sn(s[5],a),h:Sn(s[6],a),m:Sn(s[7],a),s:Sn(s[8],a)}):n==null?n={}:typeof n=="object"&&("from"in n||"to"in n)&&(u=c_(qe(n.from),qe(n.to)),n={},n.ms=u.milliseconds,n.M=u.months),c=new Bs(n),Is(t)&&ke(t,"_locale")&&(c._locale=t._locale),Is(t)&&ke(t,"_isValid")&&(c._isValid=t._isValid),c}cr.fn=Bs.prototype,cr.invalid=zy;function Sn(t,e){var n=t&&parseFloat(t.replace(",","."));return(isNaN(n)?0:n)*e}function yf(t,e){var n={};return n.months=e.month()-t.month()+(e.year()-t.year())*12,t.clone().add(n.months,"M").isAfter(e)&&--n.months,n.milliseconds=+e-+t.clone().add(n.months,"M"),n}function c_(t,e){var n;return t.isValid()&&e.isValid()?(e=Yo(e,t),t.isBefore(e)?n=yf(t,e):(n=yf(e,t),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function _f(t,e){return function(n,s){var a,c;return s!==null&&!isNaN(+s)&&(Kl(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),c=n,n=s,s=c),a=cr(n,s),wf(this,a,t),this}}function wf(t,e,n,s){var a=e._milliseconds,c=Wo(e._days),u=Wo(e._months);t.isValid()&&(s=s??!0,u&&ef(t,Ci(t,"Month")+u*n),c&&Ql(t,"Date",Ci(t,"Date")+c*n),a&&t._d.setTime(t._d.valueOf()+a*n),s&&z.updateOffset(t,c||u))}var l_=_f(1,"add"),f_=_f(-1,"subtract");function bf(t){return typeof t=="string"||t instanceof String}function h_(t){return or(t)||Ti(t)||bf(t)||Pr(t)||p_(t)||d_(t)||t===null||t===void 0}function d_(t){var e=wn(t)&&!go(t),n=!1,s=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],a,c,u=s.length;for(a=0;a<u;a+=1)c=s[a],n=n||ke(t,c);return e&&n}function p_(t){var e=ar(t),n=!1;return e&&(n=t.filter(function(s){return!Pr(s)&&bf(t)}).length===0),e&&n}function m_(t){var e=wn(t)&&!go(t),n=!1,s=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],a,c;for(a=0;a<s.length;a+=1)c=s[a],n=n||ke(t,c);return e&&n}function g_(t,e){var n=t.diff(e,"days",!0);return n<-6?"sameElse":n<-1?"lastWeek":n<0?"lastDay":n<1?"sameDay":n<2?"nextDay":n<7?"nextWeek":"sameElse"}function y_(t,e){arguments.length===1&&(arguments[0]?h_(arguments[0])?(t=arguments[0],e=void 0):m_(arguments[0])&&(e=arguments[0],t=void 0):(t=void 0,e=void 0));var n=t||qe(),s=Yo(n,this).startOf("day"),a=z.calendarFormat(this,s)||"sameElse",c=e&&(wr(e[a])?e[a].call(this,n):e[a]);return this.format(c||this.localeData().calendar(a,this,qe(n)))}function __(){return new Ei(this)}function w_(t,e){var n=or(t)?t:qe(t);return this.isValid()&&n.isValid()?(e=Vt(e)||"millisecond",e==="millisecond"?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(e).valueOf()):!1}function b_(t,e){var n=or(t)?t:qe(t);return this.isValid()&&n.isValid()?(e=Vt(e)||"millisecond",e==="millisecond"?this.valueOf()<n.valueOf():this.clone().endOf(e).valueOf()<n.valueOf()):!1}function S_(t,e,n,s){var a=or(t)?t:qe(t),c=or(e)?e:qe(e);return this.isValid()&&a.isValid()&&c.isValid()?(s=s||"()",(s[0]==="("?this.isAfter(a,n):!this.isBefore(a,n))&&(s[1]===")"?this.isBefore(c,n):!this.isAfter(c,n))):!1}function v_(t,e){var n=or(t)?t:qe(t),s;return this.isValid()&&n.isValid()?(e=Vt(e)||"millisecond",e==="millisecond"?this.valueOf()===n.valueOf():(s=n.valueOf(),this.clone().startOf(e).valueOf()<=s&&s<=this.clone().endOf(e).valueOf())):!1}function T_(t,e){return this.isSame(t,e)||this.isAfter(t,e)}function E_(t,e){return this.isSame(t,e)||this.isBefore(t,e)}function A_(t,e,n){var s,a,c;if(!this.isValid())return NaN;if(s=Yo(t,this),!s.isValid())return NaN;switch(a=(s.utcOffset()-this.utcOffset())*6e4,e=Vt(e),e){case"year":c=Fs(this,s)/12;break;case"month":c=Fs(this,s);break;case"quarter":c=Fs(this,s)/3;break;case"second":c=(this-s)/1e3;break;case"minute":c=(this-s)/6e4;break;case"hour":c=(this-s)/36e5;break;case"day":c=(this-s-a)/864e5;break;case"week":c=(this-s-a)/6048e5;break;default:c=this-s}return n?c:zt(c)}function Fs(t,e){if(t.date()<e.date())return-Fs(e,t);var n=(e.year()-t.year())*12+(e.month()-t.month()),s=t.clone().add(n,"months"),a,c;return e-s<0?(a=t.clone().add(n-1,"months"),c=(e-s)/(s-a)):(a=t.clone().add(n+1,"months"),c=(e-s)/(a-s)),-(n+c)||0}z.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",z.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function O_(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function k_(t){if(!this.isValid())return null;var e=t!==!0,n=e?this.clone().utc():this;return n.year()<0||n.year()>9999?Os(n,e?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):wr(Date.prototype.toISOString)?e?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",Os(n,"Z")):Os(n,e?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function C_(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var t="moment",e="",n,s,a,c;return this.isLocal()||(t=this.utcOffset()===0?"moment.utc":"moment.parseZone",e="Z"),n="["+t+'("]',s=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",a="-MM-DD[T]HH:mm:ss.SSS",c=e+'[")]',this.format(n+s+a+c)}function x_(t){t||(t=this.isUtc()?z.defaultFormatUtc:z.defaultFormat);var e=Os(this,t);return this.localeData().postformat(e)}function P_(t,e){return this.isValid()&&(or(t)&&t.isValid()||qe(t).isValid())?cr({to:this,from:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function R_(t){return this.from(qe(),t)}function D_(t,e){return this.isValid()&&(or(t)&&t.isValid()||qe(t).isValid())?cr({from:this,to:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function M_(t){return this.to(qe(),t)}function Sf(t){var e;return t===void 0?this._locale._abbr:(e=Nr(t),e!=null&&(this._locale=e),this)}var vf=Gt("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(t){return t===void 0?this.localeData():this.locale(t)});function Tf(){return this._locale}var Ws=1e3,$n=60*Ws,Hs=60*$n,Ef=(365*400+97)*24*Hs;function Gn(t,e){return(t%e+e)%e}function Af(t,e,n){return t<100&&t>=0?new Date(t+400,e,n)-Ef:new Date(t,e,n).valueOf()}function Of(t,e,n){return t<100&&t>=0?Date.UTC(t+400,e,n)-Ef:Date.UTC(t,e,n)}function L_(t){var e,n;if(t=Vt(t),t===void 0||t==="millisecond"||!this.isValid())return this;switch(n=this._isUTC?Of:Af,t){case"year":e=n(this.year(),0,1);break;case"quarter":e=n(this.year(),this.month()-this.month()%3,1);break;case"month":e=n(this.year(),this.month(),1);break;case"week":e=n(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":e=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":e=n(this.year(),this.month(),this.date());break;case"hour":e=this._d.valueOf(),e-=Gn(e+(this._isUTC?0:this.utcOffset()*$n),Hs);break;case"minute":e=this._d.valueOf(),e-=Gn(e,$n);break;case"second":e=this._d.valueOf(),e-=Gn(e,Ws);break}return this._d.setTime(e),z.updateOffset(this,!0),this}function N_(t){var e,n;if(t=Vt(t),t===void 0||t==="millisecond"||!this.isValid())return this;switch(n=this._isUTC?Of:Af,t){case"year":e=n(this.year()+1,0,1)-1;break;case"quarter":e=n(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":e=n(this.year(),this.month()+1,1)-1;break;case"week":e=n(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":e=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":e=n(this.year(),this.month(),this.date()+1)-1;break;case"hour":e=this._d.valueOf(),e+=Hs-Gn(e+(this._isUTC?0:this.utcOffset()*$n),Hs)-1;break;case"minute":e=this._d.valueOf(),e+=$n-Gn(e,$n)-1;break;case"second":e=this._d.valueOf(),e+=Ws-Gn(e,Ws)-1;break}return this._d.setTime(e),z.updateOffset(this,!0),this}function U_(){return this._d.valueOf()-(this._offset||0)*6e4}function B_(){return Math.floor(this.valueOf()/1e3)}function I_(){return new Date(this.valueOf())}function F_(){var t=this;return[t.year(),t.month(),t.date(),t.hour(),t.minute(),t.second(),t.millisecond()]}function W_(){var t=this;return{years:t.year(),months:t.month(),date:t.date(),hours:t.hours(),minutes:t.minutes(),seconds:t.seconds(),milliseconds:t.milliseconds()}}function H_(){return this.isValid()?this.toISOString():null}function Y_(){return _o(this)}function K_(){return Xr({},de(this))}function q_(){return de(this).overflow}function $_(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}ie("N",0,0,"eraAbbr"),ie("NN",0,0,"eraAbbr"),ie("NNN",0,0,"eraAbbr"),ie("NNNN",0,0,"eraName"),ie("NNNNN",0,0,"eraNarrow"),ie("y",["y",1],"yo","eraYear"),ie("y",["yy",2],0,"eraYear"),ie("y",["yyy",3],0,"eraYear"),ie("y",["yyyy",4],0,"eraYear"),Q("N",qo),Q("NN",qo),Q("NNN",qo),Q("NNNN",rw),Q("NNNNN",nw),Le(["N","NN","NNN","NNNN","NNNNN"],function(t,e,n,s){var a=n._locale.erasParse(t,s,n._strict);a?de(n).era=a:de(n).invalidEra=t}),Q("y",Hn),Q("yy",Hn),Q("yyy",Hn),Q("yyyy",Hn),Q("yo",iw),Le(["y","yy","yyy","yyyy"],pt),Le(["yo"],function(t,e,n,s){var a;n._locale._eraYearOrdinalRegex&&(a=t.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?e[pt]=n._locale.eraYearOrdinalParse(t,a):e[pt]=parseInt(t,10)});function G_(t,e){var n,s,a,c=this._eras||Nr("en")._eras;for(n=0,s=c.length;n<s;++n){switch(typeof c[n].since){case"string":a=z(c[n].since).startOf("day"),c[n].since=a.valueOf();break}switch(typeof c[n].until){case"undefined":c[n].until=1/0;break;case"string":a=z(c[n].until).startOf("day").valueOf(),c[n].until=a.valueOf();break}}return c}function V_(t,e,n){var s,a,c=this.eras(),u,l,h;for(t=t.toUpperCase(),s=0,a=c.length;s<a;++s)if(u=c[s].name.toUpperCase(),l=c[s].abbr.toUpperCase(),h=c[s].narrow.toUpperCase(),n)switch(e){case"N":case"NN":case"NNN":if(l===t)return c[s];break;case"NNNN":if(u===t)return c[s];break;case"NNNNN":if(h===t)return c[s];break}else if([u,l,h].indexOf(t)>=0)return c[s]}function z_(t,e){var n=t.since<=t.until?1:-1;return e===void 0?z(t.since).year():z(t.since).year()+(e-t.offset)*n}function j_(){var t,e,n,s=this.localeData().eras();for(t=0,e=s.length;t<e;++t)if(n=this.clone().startOf("day").valueOf(),s[t].since<=n&&n<=s[t].until||s[t].until<=n&&n<=s[t].since)return s[t].name;return""}function J_(){var t,e,n,s=this.localeData().eras();for(t=0,e=s.length;t<e;++t)if(n=this.clone().startOf("day").valueOf(),s[t].since<=n&&n<=s[t].until||s[t].until<=n&&n<=s[t].since)return s[t].narrow;return""}function Q_(){var t,e,n,s=this.localeData().eras();for(t=0,e=s.length;t<e;++t)if(n=this.clone().startOf("day").valueOf(),s[t].since<=n&&n<=s[t].until||s[t].until<=n&&n<=s[t].since)return s[t].abbr;return""}function Z_(){var t,e,n,s,a=this.localeData().eras();for(t=0,e=a.length;t<e;++t)if(n=a[t].since<=a[t].until?1:-1,s=this.clone().startOf("day").valueOf(),a[t].since<=s&&s<=a[t].until||a[t].until<=s&&s<=a[t].since)return(this.year()-z(a[t].since).year())*n+a[t].offset;return this.year()}function X_(t){return ke(this,"_erasNameRegex")||$o.call(this),t?this._erasNameRegex:this._erasRegex}function ew(t){return ke(this,"_erasAbbrRegex")||$o.call(this),t?this._erasAbbrRegex:this._erasRegex}function tw(t){return ke(this,"_erasNarrowRegex")||$o.call(this),t?this._erasNarrowRegex:this._erasRegex}function qo(t,e){return e.erasAbbrRegex(t)}function rw(t,e){return e.erasNameRegex(t)}function nw(t,e){return e.erasNarrowRegex(t)}function iw(t,e){return e._eraYearOrdinalRegex||Hn}function $o(){var t=[],e=[],n=[],s=[],a,c,u,l,h,m=this.eras();for(a=0,c=m.length;a<c;++a)u=Rr(m[a].name),l=Rr(m[a].abbr),h=Rr(m[a].narrow),e.push(u),t.push(l),n.push(h),s.push(u),s.push(l),s.push(h);this._erasRegex=new RegExp("^("+s.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+e.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+t.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+n.join("|")+")","i")}ie(0,["gg",2],0,function(){return this.weekYear()%100}),ie(0,["GG",2],0,function(){return this.isoWeekYear()%100});function Ys(t,e){ie(0,[t,t.length],0,e)}Ys("gggg","weekYear"),Ys("ggggg","weekYear"),Ys("GGGG","isoWeekYear"),Ys("GGGGG","isoWeekYear"),Q("G",Ps),Q("g",Ps),Q("GG",Ke,Nt),Q("gg",Ke,Nt),Q("GGGG",Co,ko),Q("gggg",Co,ko),Q("GGGGG",xs,ks),Q("ggggg",xs,ks),Oi(["gggg","ggggg","GGGG","GGGGG"],function(t,e,n,s){e[s.substr(0,2)]=be(t)}),Oi(["gg","GG"],function(t,e,n,s){e[s]=z.parseTwoDigitYear(t)});function sw(t){return kf.call(this,t,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function aw(t){return kf.call(this,t,this.isoWeek(),this.isoWeekday(),1,4)}function ow(){return Lr(this.year(),1,4)}function uw(){return Lr(this.isoWeekYear(),1,4)}function cw(){var t=this.localeData()._week;return Lr(this.year(),t.dow,t.doy)}function lw(){var t=this.localeData()._week;return Lr(this.weekYear(),t.dow,t.doy)}function kf(t,e,n,s,a){var c;return t==null?Pi(this,s,a).year:(c=Lr(t,s,a),e>c&&(e=c),fw.call(this,t,e,n,s,a))}function fw(t,e,n,s,a){var c=nf(t,e,n,s,a),u=xi(c.year,0,c.dayOfYear);return this.year(u.getUTCFullYear()),this.month(u.getUTCMonth()),this.date(u.getUTCDate()),this}ie("Q",0,"Qo","quarter"),Q("Q",Gl),Le("Q",function(t,e){e[Dr]=(be(t)-1)*3});function hw(t){return t==null?Math.ceil((this.month()+1)/3):this.month((t-1)*3+this.month()%3)}ie("D",["DD",2],"Do","date"),Q("D",Ke,Yn),Q("DD",Ke,Nt),Q("Do",function(t,e){return t?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient}),Le(["D","DD"],Sr),Le("Do",function(t,e){e[Sr]=be(t.match(Ke)[0])});var Cf=Kn("Date",!0);ie("DDD",["DDDD",3],"DDDo","dayOfYear"),Q("DDD",Cs),Q("DDDD",Vl),Le(["DDD","DDDD"],function(t,e,n){n._dayOfYear=be(t)});function dw(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return t==null?e:this.add(t-e,"d")}ie("m",["mm",2],0,"minute"),Q("m",Ke,xo),Q("mm",Ke,Nt),Le(["m","mm"],ur);var pw=Kn("Minutes",!1);ie("s",["ss",2],0,"second"),Q("s",Ke,xo),Q("ss",Ke,Nt),Le(["s","ss"],Mr);var mw=Kn("Seconds",!1);ie("S",0,0,function(){return~~(this.millisecond()/100)}),ie(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),ie(0,["SSS",3],0,"millisecond"),ie(0,["SSSS",4],0,function(){return this.millisecond()*10}),ie(0,["SSSSS",5],0,function(){return this.millisecond()*100}),ie(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),ie(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),ie(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),ie(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),Q("S",Cs,Gl),Q("SS",Cs,Nt),Q("SSS",Cs,Vl);var tn,xf;for(tn="SSSS";tn.length<=9;tn+="S")Q(tn,Hn);function gw(t,e){e[bn]=be(("0."+t)*1e3)}for(tn="S";tn.length<=9;tn+="S")Le(tn,gw);xf=Kn("Milliseconds",!1),ie("z",0,0,"zoneAbbr"),ie("zz",0,0,"zoneName");function yw(){return this._isUTC?"UTC":""}function _w(){return this._isUTC?"Coordinated Universal Time":""}var V=Ei.prototype;V.add=l_,V.calendar=y_,V.clone=__,V.diff=A_,V.endOf=N_,V.format=x_,V.from=P_,V.fromNow=R_,V.to=D_,V.toNow=M_,V.get=C0,V.invalidAt=q_,V.isAfter=w_,V.isBefore=b_,V.isBetween=S_,V.isSame=v_,V.isSameOrAfter=T_,V.isSameOrBefore=E_,V.isValid=Y_,V.lang=vf,V.locale=Sf,V.localeData=Tf,V.max=Yy,V.min=Hy,V.parsingFlags=K_,V.set=x0,V.startOf=L_,V.subtract=f_,V.toArray=F_,V.toObject=W_,V.toDate=I_,V.toISOString=k_,V.inspect=C_,typeof Symbol<"u"&&Symbol.for!=null&&(V[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),V.toJSON=H_,V.toString=O_,V.unix=B_,V.valueOf=U_,V.creationData=$_,V.eraName=j_,V.eraNarrow=J_,V.eraAbbr=Q_,V.eraYear=Z_,V.year=Jl,V.isLeapYear=k0,V.weekYear=sw,V.isoWeekYear=aw,V.quarter=V.quarters=hw,V.month=tf,V.daysInMonth=I0,V.week=V.weeks=G0,V.isoWeek=V.isoWeeks=V0,V.weeksInYear=cw,V.weeksInWeekYear=lw,V.isoWeeksInYear=ow,V.isoWeeksInISOWeekYear=uw,V.date=Cf,V.day=V.days=ay,V.weekday=oy,V.isoWeekday=uy,V.dayOfYear=dw,V.hour=V.hours=my,V.minute=V.minutes=pw,V.second=V.seconds=mw,V.millisecond=V.milliseconds=xf,V.utcOffset=Qy,V.utc=Xy,V.local=e_,V.parseZone=t_,V.hasAlignedHourOffset=r_,V.isDST=n_,V.isLocal=s_,V.isUtcOffset=a_,V.isUtc=gf,V.isUTC=gf,V.zoneAbbr=yw,V.zoneName=_w,V.dates=Gt("dates accessor is deprecated. Use date instead.",Cf),V.months=Gt("months accessor is deprecated. Use month instead",tf),V.years=Gt("years accessor is deprecated. Use year instead",Jl),V.zone=Gt("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Zy),V.isDSTShifted=Gt("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",i_);function ww(t){return qe(t*1e3)}function bw(){return qe.apply(null,arguments).parseZone()}function Pf(t){return t}var Ce=vo.prototype;Ce.calendar=s0,Ce.longDateFormat=c0,Ce.invalidDate=f0,Ce.ordinal=p0,Ce.preparse=Pf,Ce.postformat=Pf,Ce.relativeTime=g0,Ce.pastFuture=y0,Ce.set=n0,Ce.eras=G_,Ce.erasParse=V_,Ce.erasConvertYear=z_,Ce.erasAbbrRegex=ew,Ce.erasNameRegex=X_,Ce.erasNarrowRegex=tw,Ce.months=L0,Ce.monthsShort=N0,Ce.monthsParse=B0,Ce.monthsRegex=W0,Ce.monthsShortRegex=F0,Ce.week=Y0,Ce.firstDayOfYear=$0,Ce.firstDayOfWeek=q0,Ce.weekdays=ty,Ce.weekdaysMin=ny,Ce.weekdaysShort=ry,Ce.weekdaysParse=sy,Ce.weekdaysRegex=cy,Ce.weekdaysShortRegex=ly,Ce.weekdaysMinRegex=fy,Ce.isPM=dy,Ce.meridiem=gy;function Ks(t,e,n,s){var a=Nr(),c=_r().set(s,e);return a[n](c,t)}function Rf(t,e,n){if(Pr(t)&&(e=t,t=void 0),t=t||"",e!=null)return Ks(t,e,n,"month");var s,a=[];for(s=0;s<12;s++)a[s]=Ks(t,s,n,"month");return a}function Go(t,e,n,s){typeof t=="boolean"?(Pr(e)&&(n=e,e=void 0),e=e||""):(e=t,n=e,t=!1,Pr(e)&&(n=e,e=void 0),e=e||"");var a=Nr(),c=t?a._week.dow:0,u,l=[];if(n!=null)return Ks(e,(n+c)%7,s,"day");for(u=0;u<7;u++)l[u]=Ks(e,(u+c)%7,s,"day");return l}function Sw(t,e){return Rf(t,e,"months")}function vw(t,e){return Rf(t,e,"monthsShort")}function Tw(t,e,n){return Go(t,e,n,"weekdays")}function Ew(t,e,n){return Go(t,e,n,"weekdaysShort")}function Aw(t,e,n){return Go(t,e,n,"weekdaysMin")}en("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10,n=be(t%100/10)===1?"th":e===1?"st":e===2?"nd":e===3?"rd":"th";return t+n}}),z.lang=Gt("moment.lang is deprecated. Use moment.locale instead.",en),z.langData=Gt("moment.langData is deprecated. Use moment.localeData instead.",Nr);var Ur=Math.abs;function Ow(){var t=this._data;return this._milliseconds=Ur(this._milliseconds),this._days=Ur(this._days),this._months=Ur(this._months),t.milliseconds=Ur(t.milliseconds),t.seconds=Ur(t.seconds),t.minutes=Ur(t.minutes),t.hours=Ur(t.hours),t.months=Ur(t.months),t.years=Ur(t.years),this}function Df(t,e,n,s){var a=cr(e,n);return t._milliseconds+=s*a._milliseconds,t._days+=s*a._days,t._months+=s*a._months,t._bubble()}function kw(t,e){return Df(this,t,e,1)}function Cw(t,e){return Df(this,t,e,-1)}function Mf(t){return t<0?Math.floor(t):Math.ceil(t)}function xw(){var t=this._milliseconds,e=this._days,n=this._months,s=this._data,a,c,u,l,h;return t>=0&&e>=0&&n>=0||t<=0&&e<=0&&n<=0||(t+=Mf(Vo(n)+e)*864e5,e=0,n=0),s.milliseconds=t%1e3,a=zt(t/1e3),s.seconds=a%60,c=zt(a/60),s.minutes=c%60,u=zt(c/60),s.hours=u%24,e+=zt(u/24),h=zt(Lf(e)),n+=h,e-=Mf(Vo(h)),l=zt(n/12),n%=12,s.days=e,s.months=n,s.years=l,this}function Lf(t){return t*4800/146097}function Vo(t){return t*146097/4800}function Pw(t){if(!this.isValid())return NaN;var e,n,s=this._milliseconds;if(t=Vt(t),t==="month"||t==="quarter"||t==="year")switch(e=this._days+s/864e5,n=this._months+Lf(e),t){case"month":return n;case"quarter":return n/3;case"year":return n/12}else switch(e=this._days+Math.round(Vo(this._months)),t){case"week":return e/7+s/6048e5;case"day":return e+s/864e5;case"hour":return e*24+s/36e5;case"minute":return e*1440+s/6e4;case"second":return e*86400+s/1e3;case"millisecond":return Math.floor(e*864e5)+s;default:throw new Error("Unknown unit "+t)}}function Br(t){return function(){return this.as(t)}}var Nf=Br("ms"),Rw=Br("s"),Dw=Br("m"),Mw=Br("h"),Lw=Br("d"),Nw=Br("w"),Uw=Br("M"),Bw=Br("Q"),Iw=Br("y"),Fw=Nf;function Ww(){return cr(this)}function Hw(t){return t=Vt(t),this.isValid()?this[t+"s"]():NaN}function vn(t){return function(){return this.isValid()?this._data[t]:NaN}}var Yw=vn("milliseconds"),Kw=vn("seconds"),qw=vn("minutes"),$w=vn("hours"),Gw=vn("days"),Vw=vn("months"),zw=vn("years");function jw(){return zt(this.days()/7)}var Ir=Math.round,Vn={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Jw(t,e,n,s,a){return a.relativeTime(e||1,!!n,t,s)}function Qw(t,e,n,s){var a=cr(t).abs(),c=Ir(a.as("s")),u=Ir(a.as("m")),l=Ir(a.as("h")),h=Ir(a.as("d")),m=Ir(a.as("M")),w=Ir(a.as("w")),T=Ir(a.as("y")),P=c<=n.ss&&["s",c]||c<n.s&&["ss",c]||u<=1&&["m"]||u<n.m&&["mm",u]||l<=1&&["h"]||l<n.h&&["hh",l]||h<=1&&["d"]||h<n.d&&["dd",h];return n.w!=null&&(P=P||w<=1&&["w"]||w<n.w&&["ww",w]),P=P||m<=1&&["M"]||m<n.M&&["MM",m]||T<=1&&["y"]||["yy",T],P[2]=e,P[3]=+t>0,P[4]=s,Jw.apply(null,P)}function Zw(t){return t===void 0?Ir:typeof t=="function"?(Ir=t,!0):!1}function Xw(t,e){return Vn[t]===void 0?!1:e===void 0?Vn[t]:(Vn[t]=e,t==="s"&&(Vn.ss=e-1),!0)}function e1(t,e){if(!this.isValid())return this.localeData().invalidDate();var n=!1,s=Vn,a,c;return typeof t=="object"&&(e=t,t=!1),typeof t=="boolean"&&(n=t),typeof e=="object"&&(s=Object.assign({},Vn,e),e.s!=null&&e.ss==null&&(s.ss=e.s-1)),a=this.localeData(),c=Qw(this,!n,s,a),n&&(c=a.pastFuture(+this,c)),a.postformat(c)}var zo=Math.abs;function zn(t){return(t>0)-(t<0)||+t}function qs(){if(!this.isValid())return this.localeData().invalidDate();var t=zo(this._milliseconds)/1e3,e=zo(this._days),n=zo(this._months),s,a,c,u,l=this.asSeconds(),h,m,w,T;return l?(s=zt(t/60),a=zt(s/60),t%=60,s%=60,c=zt(n/12),n%=12,u=t?t.toFixed(3).replace(/\.?0+$/,""):"",h=l<0?"-":"",m=zn(this._months)!==zn(l)?"-":"",w=zn(this._days)!==zn(l)?"-":"",T=zn(this._milliseconds)!==zn(l)?"-":"",h+"P"+(c?m+c+"Y":"")+(n?m+n+"M":"")+(e?w+e+"D":"")+(a||s||t?"T":"")+(a?T+a+"H":"")+(s?T+s+"M":"")+(t?T+u+"S":"")):"P0D"}var Ee=Bs.prototype;Ee.isValid=Vy,Ee.abs=Ow,Ee.add=kw,Ee.subtract=Cw,Ee.as=Pw,Ee.asMilliseconds=Nf,Ee.asSeconds=Rw,Ee.asMinutes=Dw,Ee.asHours=Mw,Ee.asDays=Lw,Ee.asWeeks=Nw,Ee.asMonths=Uw,Ee.asQuarters=Bw,Ee.asYears=Iw,Ee.valueOf=Fw,Ee._bubble=xw,Ee.clone=Ww,Ee.get=Hw,Ee.milliseconds=Yw,Ee.seconds=Kw,Ee.minutes=qw,Ee.hours=$w,Ee.days=Gw,Ee.weeks=jw,Ee.months=Vw,Ee.years=zw,Ee.humanize=e1,Ee.toISOString=qs,Ee.toString=qs,Ee.toJSON=qs,Ee.locale=Sf,Ee.localeData=Tf,Ee.toIsoString=Gt("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",qs),Ee.lang=vf,ie("X",0,0,"unix"),ie("x",0,0,"valueOf"),Q("x",Ps),Q("X",S0),Le("X",function(t,e,n){n._d=new Date(parseFloat(t)*1e3)}),Le("x",function(t,e,n){n._d=new Date(be(t))});//! moment.js
|
|
42
42
|
z.version="2.30.1",t0(qe),z.fn=V,z.min=Ky,z.max=qy,z.now=$y,z.utc=_r,z.unix=ww,z.months=Sw,z.isDate=Ti,z.locale=en,z.invalid=Es,z.duration=cr,z.isMoment=or,z.weekdays=Tw,z.parseZone=bw,z.localeData=Nr,z.isDuration=Is,z.monthsShort=vw,z.weekdaysMin=Aw,z.defineLocale=No,z.updateLocale=by,z.locales=Sy,z.weekdaysShort=Ew,z.normalizeUnits=Vt,z.relativeTimeRounding=Zw,z.relativeTimeThreshold=Xw,z.calendarFormat=g_,z.prototype=V,z.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};function Uf(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function t1(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.length%4===0?"":"=".repeat(4-e.length%4);return e+n}function Bf(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function r1(t){const e=atob(t),n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n}const xt=60,If=60*xt,Li=24*If,$s=7*Li;function Ff(){return new Date().getTime()/1e3}function n1(t){return t.split("").map(e=>e.charCodeAt(0))}function Gs(t){const e=new TextEncoder().encode(t);return Uf(Bf(e))}function Vs(t){const e=r1(t1(t));return new TextDecoder().decode(e)}async function Wf(t){const e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),s=new Uint8Array(n);let a="";for(let c=0;c<s.length;c++)a+=s[c].toString(16).padStart(2,"0");return a}async function jo(t,e,n="hex"){const s=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),a=await crypto.subtle.sign("HMAC",s,new TextEncoder().encode(t)),c=new Uint8Array(a);if(n==="base64url")return Uf(Bf(c));let u="";for(let l=0;l<c.length;l++)u+=c[l].toString(16).padStart(2,"0");return u}function Jo(t,e=void 0){return _n.createJWT(t,e)}function Hf(t){return _n.parseJWT(t)}function Yf(t){return _n.jwkToPublicKey(t)}function Qo(t,e){return _n.encryptPayload(t,e)}function Zo(t){if(Array.isArray(t))return t.map(Zo);if(t&&typeof t=="object"&&t.constructor===Object){const e={},n=Object.keys(t),s=n.length;for(let a=0;a<s;a+=1)e[ro.camelCase(n[a])]=Zo(t[n[a]]);return e}return t}function zs(t){if(!t)return!0;try{return JSON.parse(Vs(t.split(".")[1])).exp<Ff()}catch{return!0}}function Xo(t){return jt("root",t,"non-nullable object",!1)}function eu(t,e){return jt("root",t,"object",e)}function tu(t,e){return jt("root",t,"object",e)}function js(t,e){!Array.isArray(t)&&t!==null&&t!==void 0&&jt(e,t,"array",!0)}function _t(t,e,n){typeof t=="string"?t.match(/\d+(\.\d+)?/)||jt(n,t,"string",e):typeof t!="number"&&(!e||e&&t!==null&&t!==void 0)&&jt(n,t,"number",e)}function at(t,e,n){typeof t=="string"?t.match(/\d+(\.\d+)?/)||jt(n,t,"number",e):typeof t!="number"&&(!e||e&&t!==null&&t!==void 0)&&jt(n,t,"number",e)}function Tn(t,e,n){typeof t!="boolean"&&(!e||e&&t!==null&&t!==void 0)&&jt(n,t,"boolean",e)}function Ne(t,e,n){typeof t!="string"&&(!e||e&&t!==null&&t!==void 0)&&jt(n,t,"string",e)}function Kf(t,e){t!=null&&jt(e,t,"null or undefined",!1)}function jt(t,e,n,s){throw s&&(n+=", null, or undefined"),new TypeError("Expected "+n+" at "+t+` but found:
|
|
43
|
-
`+JSON.stringify(e))}function X(t){return Ze.isBigNumber(t)?t:t?new Ze(t):new Ze("0")}function En(t,e){return new Ze(e).toFixed(t>0?t:0)}function Ni(t){return typeof t=="number"?t:parseFloat(t)}function jn(t){return typeof t=="number"?t:parseInt(t)}function ru(t){let e=Ni(t);return e<1e10&&(e=e*1e3),new Date(e)}function qf(t){switch(t.toString().toUpperCase()){case"1S":return 1;case"2S":return 2;case"3S":return 3;case"5S":return 5;case"10S":return 10;case"15S":return 15;case"30S":return 30;case"1":return xt;case"2":return xt*2;case"3":return xt*3;case"5":return xt*5;case"10":return xt*10;case"15":return xt*15;case"30":return xt*30;case"60":return xt*60;case"120":return xt*120;case"240":return xt*240;case"360":return xt*360;case"720":return xt*720;case"D":case"1D":return Li;case"3D":return Li*3;case"W":return $s;case"1W":return $s;case"2W":return $s*2;case"1M":return Li*30}}const Js=t=>typeof t=="object"?t:new Date(t*1e3),$f=(t,e)=>{switch(t=z.utc(Js(t)),e){case"1":case"2":case"3":return t.endOf("day").unix();case"5":case"10":case"15":return t.endOf("isoWeek").unix();case"30":case"60":case"120":return t.endOf("month").unix();case"240":case"360":case"720":case"D":case"1D":return t.endOf("year").unix()}},i1=(t,e)=>{switch(t=z.utc(Js(t)),e){case"1":case"2":case"3":return t.startOf("day").unix();case"5":case"10":case"15":return t.startOf("isoWeek").unix();case"30":case"60":case"120":return t.startOf("month").unix();case"240":case"360":case"720":case"D":case"1D":return t.startOf("year").unix()}};function Gf(t){switch(t){case"1":case"2":case"3":return"day";case"5":case"10":case"15":return"week";case"30":case"60":case"120":return"month";case"240":case"360":case"720":case"D":case"1D":return"year";default:throw new Error(`Unsupported resolution: ${t}`)}}function Vf(t,e){let n=z(Js(e)),s;switch(t){case"day":s={year:n.year(),month:n.month()+1,day:n.date()};break;case"week":s={year:n.isoWeekYear(),week:n.isoWeek()};break;case"month":s={year:n.year(),month:n.month()+1};break;case"year":s={year:n.year()};break;default:throw new Error(`Unsupported bucketType: ${t}`)}return s}function zf(t,e,n){const s=[];let a=z.utc(e*1e3);const c=m=>{switch(n){case"day":return m.startOf("day");case"week":return m.startOf("isoWeek");case"month":return m.startOf("month");case"year":return m.startOf("year");default:throw new Error(`Unsupported bucketType: ${n}`)}},u=m=>{switch(n){case"day":return m.subtract(1,"day");case"week":return m.subtract(1,"week");case"month":return m.subtract(1,"month");case"year":return m.subtract(1,"year");default:throw new Error(`Unsupported bucketType: ${n}`)}};let l=c(a);const h=c(z.utc(t*1e3));for(;l>=h;)s.push(l.clone()),l=u(l);return s}function Qs(t,e,n){let s=qf(e),a=typeof n=="object"?n.getTime()/1e3:n;return Math.floor(a/s)*s-s*(t-1)}function jf(t,e){let n=e;if(typeof e=="string"?n=[{query:e,marketProperty:"fullDisplayName"}]:Array.isArray(e)?n=e.map(a=>{if(typeof a=="string")return{query:a,marketProperty:"fullDisplayName"};if(!Array.isArray(a))return a}):n=[e],n.length===0||!n.find(({query:a})=>!!a&&!!a.length))return t;let s=t;return n.forEach(({query:a,marketProperty:c})=>{let u;if(a.match(/[-_:\/\\]+/))try{u=new RegExp(a.replace(/\*/g,".*"),"i")}catch{}const l=a.toLowerCase().split(/[\s]+/).filter(Boolean);s=ct.pickBy(s,(h,m)=>{const w=h[c];if(w==null)return!1;const T=w.toLowerCase();return u&&c==="fullDisplayName"?!!u.exec(h[c]):l.filter(P=>T.includes(P)).length===l.length})}),s}let nu;class s1{static initialize=e=>{nu=e,console.log("Coinray I18n initialized")};static t=(e,n)=>nu?nu.t(`coinray:${e}`,n):`i18n uninitialized. Set the Coinray.I18n.instance. Key: ${e}`}const Jf="2.0.11";class a1 extends Error{errorCode;errorMessage;exchange;constructor({code:e,message:n,exchange:s}){super("Request failed"),this.name="CoinrayError",this.errorCode=e,this.errorMessage=n,this.exchange=s}}class xe{static I18n=s1;config;_token;_sessionKey;_credential;_firstOpen;_onTokenExpired;_tokenCheckTimeout;_onError;_onOpen;_socket;_transport;_tickerListeners=new Map;_tickerSymbols=new Map;_tradeListeners={};_tradeSnapshots={};_orderbookListeners={};_orderbookSnapshots={};_candleTradeListeners={};_candleListeners={};_candles={};_timers={};_channels={};_connected;markConnected;_publicKey;_refreshingToken;_nonceOffset;tickersSubscribed=!1;tradesSubscribed=!1;orderBookSubscribed=!1;_timeOffset;_timeOffsetTimeout;_candleCache;_candleCacheCreatedAt;constructor(e,{apiEndpoint:n,orderEndpoint:s,websocketEndpoint:a}={apiEndpoint:"https://api.coinray.eu",orderEndpoint:"https://api.coinray.eu",websocketEndpoint:"wss://ws.coinray.eu/v1"}){this._token=e,this._nonceOffset=0,this._timeOffset=0,this._firstOpen=!0,this.config={apiEndpoint:n||"https://api.coinray.eu",orderEndpoint:s||n||"https://api.coinray.eu",websocketEndpoint:a||"wss://ws.coinray.eu/v1"},this._candleCache=new Map,this.loadTimeOffset().then()}authenticateDevice=(e,n)=>{this._credential=e,this._sessionKey=n};destroy=()=>{this._tradeListeners={},this._orderbookListeners={},this._tickerListeners=new Map,this._tickerSymbols=new Map,this._channels={},this._timeOffsetTimeout&&clearTimeout(this._timeOffsetTimeout),this._tokenCheckTimeout&&clearInterval(this._tokenCheckTimeout),this.disconnect()};checkToken=async(e=!0)=>{try{if(zs(this._token)){if(console.log("Coinray token expired. Can refresh:",!!this._onTokenExpired),!this._onTokenExpired)return!1;this._refreshingToken||(this._refreshingToken=this._onTokenExpired());try{this._token=await this._refreshingToken}catch(n){return console.log("Coinray token could not be refreshed",n),this._refreshingToken=void 0,!1}if(this._refreshingToken=void 0,!zs(this._token))this.reconnect();else return!1}}catch(n){console.error(n)}return e&&(this._tokenCheckTimeout=setTimeout(this.checkToken,5e3)),!0};setTransport=e=>{this._transport=e};onTokenExpired=e=>{this._tokenCheckTimeout&&clearInterval(this._tokenCheckTimeout),this._onTokenExpired=e,this._tokenCheckTimeout=setTimeout(this.checkToken,5e3)};refreshToken=e=>{this._token=e};getNonce=()=>(this._nonceOffset>900&&(this._nonceOffset=0),this._nonceOffset+=1,this.getTime()+this._nonceOffset);getTime=()=>Math.floor(new Date().getTime()/1e3)*1e3+this._timeOffset;loadTimeOffset=async()=>{try{const{result:e}=await this.get("/coinray/time");this._timeOffset=e.time-new Date().getTime()}catch(e){console.error(e)}this._timeOffsetTimeout=setTimeout(this.loadTimeOffset,6e4)};getToken=async()=>{if(await this.checkToken(!1))return this._token;throw new Error("Token is expired. call refreshToken in the onTokenExpired callback")};reconnect=()=>{this._connected&&this.socket.conn.close()};disconnect=()=>{this._socket&&(this._socket.disconnect(),this._socket=void 0),this._connected=void 0};connect=async()=>{if(this._connected){await this._connected;return}else this._connected=new Promise(e=>{this.markConnected=e});this.socket.onOpen(e=>{this._onOpen&&this._onOpen(e)}),this.socket.onError(e=>{this._onError&&this._onError(e)}),this.socket.connect(),this.markConnected()};onOpen=e=>{this._onOpen=e};onError=e=>{this._onError=e};resubscribe=()=>{if(this._firstOpen){this._firstOpen=!1;return}Object.keys(this._tickerListeners).forEach(e=>{this._tickerListeners[e].length>0&&this.getChannel("tickers").push("subscribe",{exchangeCodes:[e]},5e3)}),Object.keys(this._tradeListeners).forEach(e=>{this._tradeListeners[e].length>0&&this.getChannel("trades").push("subscribe",{symbols:e,snapshots:!0},5e3)}),Object.keys(this._orderbookListeners).forEach(e=>{this._orderbookListeners[e].length>0&&this.getChannel("orderbooks").push("subscribe",{symbols:e,snapshots:!0},5e3)})};subscribeTickers=async(e,n=!1,s)=>{if(e.length===0)return!1;if(n&&(this._tickerListeners.clear(),this._tickerSymbols.clear()),this._tickerListeners.has(s)){let c=this._tickerListeners.get(s);e.forEach(u=>c.add(u))}else this._tickerListeners.set(s,new Set(e));e.forEach(c=>{this._tickerSymbols.has(c)||this._tickerSymbols.set(c,new Set),this._tickerSymbols.get(c).add(s)}),await this.connect();const a=this.getChannel("tickers");return a.push("subscribe",{coinraySymbols:e,reset:n},5e3),this.tickersSubscribed||(this.tickersSubscribed=!0,a.on("update",c=>{let{exchange_code:u,tickers:l}=c;const h=l.map(xe._parseTicker);this._tickerListeners.forEach((m,w)=>{const T=h.filter(P=>m.has(P.coinraySymbol));w({type:"tickers:update",exchangeCode:u,tickers:T})})}),a.on("error",c=>console.error(c))),s};unsubscribeAllTickers=()=>{this._tickerListeners.clear(),this._tickerSymbols.clear(),this.getChannel("tickers").push("unsubscribe",{all:!0},5e3)};unsubscribeTickers=(e,n)=>{if(n&&this._tickerListeners.has(n)){let s=this._tickerListeners.get(n),a=[];e.forEach(c=>{s.delete(c),this._tickerSymbols.has(c)&&(this._tickerSymbols.get(c).delete(n),this._tickerSymbols.get(c).size===0&&(this._tickerSymbols.delete(c),a.push(c)))}),s.size===0&&this._tickerListeners.delete(n),a.length>0&&this.getChannel("tickers").push("unsubscribe",{coinraySymbols:a},5e3)}};subscribeTrades=async({coinraySymbol:e},n)=>{if(this._tradeListeners[e]&&this._tradeListeners[e].length>0)return this._tradeListeners[e].includes(n)||this._tradeListeners[e].push(n),n({type:"trades:snapshot",coinraySymbol:e,trades:this._tradeSnapshots[e]}),n;this._tradeSnapshots[e]=[],this._tradeListeners[e]=[n],await this.connect();const s=this.getChannel("trades");return s.push("subscribe",{symbols:e,snapshots:!0},5e3),this.tradesSubscribed||(this.tradesSubscribed=!0,s.on("snapshot",({symbol:a,trades:c})=>{const u=Object.values(this._tradeListeners[a]),l=c.map(xe._parseTrade);this._tradeSnapshots[a]=l,u.map(h=>h({type:"trades:snapshot",coinraySymbol:a,trades:l}))}),s.on("update",({symbol:a,trades:c})=>{const u=Object.values(this._tradeListeners[a]),l=c.map(xe._parseTrade),h=[...l,...this._tradeSnapshots[a]],m=new Date(new Date().getTime()-12e4),w=h.filter(({time:T})=>T>m);w.length>100?this._tradeSnapshots[a]=w:this._tradeSnapshots[a]=h.slice(0,100),u.map(T=>T({type:"trades:update",coinraySymbol:a,trades:l}))}),s.on("error",a=>console.error(a))),n};unsubscribeTrades=({coinraySymbol:e},n)=>{n&&this._tradeListeners[e]?(this._tradeListeners[e]=this._tradeListeners[e].filter(s=>s!==n),this._tradeListeners[e].length===0&&this.getChannel("trades").push("unsubscribe",{symbols:e},5e3)):(this._tradeSnapshots[e]=[],this._tradeListeners[e]=[])};subscribeOrderBook=async({coinraySymbol:e},n)=>{if(this._orderbookListeners[e]&&this._orderbookListeners[e].length>0)return this._orderbookListeners[e].includes(n)||this._orderbookListeners[e].push(n),n({type:"orderBook:snapshot",coinraySymbol:e,orderBook:this._orderbookSnapshots[e]}),n;this._orderbookSnapshots[e]={minSeq:0,maxSeq:0,bids:{},asks:{}},this._orderbookListeners[e]=[n],await this.connect();const s=this.getChannel("orderbooks");return s.push("subscribe",{symbols:e},1e4),this.orderBookSubscribed||(this.orderBookSubscribed=!0,s.on("snapshot",({orderbooks:a})=>{Object.keys(a).forEach(u=>{const l=Object.values(this._orderbookListeners[u]),h=xe._parseOrderBookSnapshot(a[u]);this._orderbookSnapshots[u]=h,l.map(m=>m({type:"orderBook:snapshot",coinraySymbol:u,orderBook:h}))})}),s.on("update",({orderbooks:a})=>{const c=Object.keys(a);c.length!==0&&c.forEach(u=>{const l=Object.values(this._orderbookListeners[u]),h=xe._parseOrderBookUpdate(a[u]);this._orderbookSnapshots[u]=xe._updateOrderBook(this._orderbookSnapshots[u],h),l.map(m=>m({type:"orderBook:update",coinraySymbol:u,orderBook:h}))})}),s.on("error",a=>console.error(a))),n};unsubscribeOrderBook=({coinraySymbol:e},n)=>{n&&this._orderbookListeners[e]?(this._orderbookListeners[e]=this._orderbookListeners[e].filter(s=>s!==n),this._orderbookListeners[e].length===0&&this.getChannel("orderbooks").push("unsubscribe",{symbols:e},5e3)):(this._orderbookSnapshots[e]={minSeq:0,maxSeq:0,bids:{},asks:{}},this._orderbookListeners[e]=[])};subscribeCandles=async({coinraySymbol:e,resolution:n,lastCandle:s},a)=>{const c=`${e}-${n}`;if(this._candleListeners[c]&&this._candleListeners[c].length>0)return this._candleListeners[c].push(a),a;this._candleListeners[c]=[a];const u=({type:l,coinraySymbol:h,trades:m})=>{const w=Object.values(this._candleListeners[c]),T=xe._tradesToLastCandle(n,m),P=T[T.length-1];P&&(this._candles[c]&&l==="trades:snapshot"&&(this._candles[c].skipVolume=!0),this._candles[c]=xe._mergeCandle(this._candles[c],P),w.map($=>$({coinraySymbol:h,resolution:n,candle:this._candles[c],previousCandles:T})))};return this._candleTradeListeners[e]?this._candleTradeListeners[e][c]=u:this._candleTradeListeners[e]={[c]:u},this._candles[c]=s||{time:new Date(0)},await this.subscribeTrades({coinraySymbol:e},u),this.startNewCandleTimer({candleId:c,resolution:n,coinraySymbol:e}),a};startNewCandleTimer=({candleId:e,resolution:n,coinraySymbol:s})=>{this._timers[e]&&clearTimeout(this._timers[e]);let a=Qs(0,n,new Date)-new Date().getTime()/1e3;const c=Object.values(this._candleListeners[e]);this._timers[e]=setTimeout(()=>{let u=Qs(1,n,new Date)*1e3,l=this._candles[e];l&&u>l.time.getTime()&&(this._candles[e]={time:new Date(u),open:l.close,high:l.close,low:l.close,close:l.close,baseVolume:0,quoteVolume:0,numTrades:0},c.map(h=>h({coinraySymbol:s,resolution:n,candle:this._candles[e],previousCandles:[]}))),this.startNewCandleTimer({candleId:e,resolution:n,coinraySymbol:s})},a*1e3)};unsubscribeCandles=({coinraySymbol:e,resolution:n},s)=>{const a=`${e}-${n}`;s&&this._candleListeners[a]?this._candleListeners[a]=this._candleListeners[a].filter(c=>c!==s):this._candleListeners[a]=[],this._candleListeners[a].length===0&&(this.unsubscribeTrades({coinraySymbol:e},this._candleTradeListeners[e][a]),this._timers[a]&&(clearTimeout(this._timers[a]),delete this._timers[a]),delete this._candles[a],delete this._candleTradeListeners[e][a])};fetchFirstCandleTime=async({coinraySymbol:e,resolution:n})=>{let{result:{startTime:s}}=await this.get("candles/start-time",{version:"v1",params:{symbol:e,resolution:n}});return s};fetchCandles=async({coinraySymbol:e,resolution:n,start:s,end:a,useWebSocket:c})=>{if(this.flushCache(),n.endsWith("S"))return(await this.getWebsocketCandles(e,n)).filter($=>{let O=$.time.getTime()/1e3;return O>=s&&O<=a});const u=Gf(n),l=new Date().getTime()/1e3,h=[];let m=a+1;if($f(a,n)>=l){let P=await this.getOpenCandles(c,{version:"v2",params:{symbol:e,resolution:n}});if(P.length>0)m=Math.min(P[0].time.getTime()/1e3,m),h.push(...P);else return[]}let w=Qs(2,n,m),T=ro.chunk(zf(s,w,u),10);for(let P=0;P<T.length;P+=1){let $=T[P].map(F=>{let ne=Vf(u,F),Y={version:"v2",params:{symbol:e,resolution:n,...ne}};return this.getHistoryCandles(Y)}),O=await Promise.all($),I=[];for(let F=0;F<O.length;F+=1)I=O[F].filter(({time:ne})=>ne.getTime()/1e3<m),I.length>0&&(m=Math.min(I[0].time.getTime()/1e3,m),h.unshift(...I));if(I.length===0)break}return h.filter(({time:P})=>{let $=P.getTime()/1e3;return $>=s&&$<=a}).sort((P,$)=>P.time.getTime()-$.time.getTime())};flushCache=()=>{let e=new Date().getTime()/1e3;(!this._candleCacheCreatedAt||e-this._candleCacheCreatedAt>600)&&(this._candleCacheCreatedAt=e,this._candleCache=new Map)};getWebsocketCandles=async(e,n)=>await new Promise(a=>{let c=setTimeout(()=>{this.unsubscribeCandles({coinraySymbol:e,resolution:n},u),a([])},0);const u=({previousCandles:l})=>{clearTimeout(c),this.unsubscribeCandles({coinraySymbol:e,resolution:n},u),a(l)};this.subscribeCandles({coinraySymbol:e,resolution:n},u)});getOpenCandles=async(e,n)=>{const s=this.candleCacheKey({prefix:"O",...n.params});let a=this._candleCache.get(s);if(!e&&a)return a;const c=await this.getWebsocketCandles(n.params.symbol,n.params.resolution),u=ct.keyBy(c,({time:h})=>h.getTime());let{result:l}=await this.get("candles/open",n);if(l.candles){let m=l.candles.map(xe._parseCandle).map(w=>{const T=u[w.time.getTime()];return T?xe._mergeCandle(w,T):w});return this._candleCache.set(s,m),m}else return[]};getHistoryCandles=async e=>{const n=this.candleCacheKey(e.params);let s=this._candleCache.get(n);if(s)return s;{if(e.params.year<2018)return new Promise(c=>c([]));let{result:a}=await this.get("candles/history",e);if(a.candles){let c=a.candles.map(xe._parseCandle);return this._candleCache.set(n,c),c}else return[]}};candleCacheKey=({symbol:e,resolution:n,year:s,month:a="",day:c="",week:u="",prefix:l="C"})=>`${l}/${e}/${n}/${s}/${a}/${c}/${u}`;fetchExchanges=async(e,n)=>{let s=n;return s||({result:{exchanges:s}}=await this.get("exchanges",{version:"v1"})),s.map(e)};fetchMarkets=async(e,n)=>{let s=n;return s||({result:{markets:s}}=await this.get("markets",{version:"v1",params:{exchange:e.code}})),s};createCredential=async(e,n)=>{const s=await this.publicKey();try{const a=await Qo(await Jo({password:n}),s),{result:c}=await this.post("credentials",{secret:n,body:{deviceId:e,encryptedPassword:a}});return c}catch(a){throw a}};wrapApiKey=async(e,n)=>{const s=await this.publicKey();let a;try{if(n)a=e;else{const u=JSON.stringify(e);a=await Qo(await Jo({apiKey:u}),s)}const{result:c}=await this.post("credentials/wrap_api_key",{secret:this._sessionKey,body:{encryptedApiKey:a,credential:this._credential}});return c}catch(c){throw c}};testAccount=async e=>{try{const{result:n}=await this.post("account/test",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,credential:this._credential}});return n}catch(n){throw n}};createSmartOrderSignature=async e=>{try{const{result:n}=await this.post("order/smart_order_signature",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{smartOrder:e,credential:this._credential}});return n}catch(n){throw n}};createOrder=async e=>{try{const{result:n}=await this.post("order",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,credential:this._credential}});return n}catch(n){throw n}};updateOrder=async e=>{try{const{result:n}=await this.patch("order",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,credential:this._credential}});return n}catch(n){throw n}};cancelOrder=async e=>{try{const{result:n}=await this.delete("order",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,orderId:e.orderId.toString(),credential:this._credential}});return n}catch(n){throw n}};createWebSocketToken=async({exchangeCode:e,encryptedApiKey:n})=>{try{const{result:s}=await this.post("exchanges/ws_token",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{encryptedApiKey:n,exchangeCode:e,credential:this._credential}});return s}catch(s){throw s}};fetchPositions=async({exchangeCode:e,encryptedApiKey:n})=>{try{const{result:s}=await this.get("futures/positions",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,params:{credential:this._credential,exchangeCode:e,encryptedApiKey:n}});return s}catch(s){throw s}};getBalances=async({exchangeCode:e,encryptedApiKey:n})=>{try{const{result:{balances:s,positions:a}}=await this.get("account/balances",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,params:{credential:this._credential,exchangeCode:e,encryptedApiKey:n}});return{balances:s.map(xe._parseBalance),positions:a}}catch(s){throw s}};setLeverage=async({coinraySymbol:e,leverage:n,encryptedApiKey:s})=>{try{const{result:a}=await this.post("futures/leverage",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{credential:this._credential,coinraySymbol:e,leverage:n,encryptedApiKey:s}});return a}catch(a){throw a}};setMarginType=async({coinraySymbol:e,marginType:n,encryptedApiKey:s})=>{try{const{result:a}=await this.post("futures/margin_type",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{credential:this._credential,coinraySymbol:e,marginType:n,encryptedApiKey:s}});return a}catch(a){throw a}};async getProxyList({exchangeCode:e,credentialVersion:n}){let s="";e&&(s+=`?exchange=${e.toUpperCase()}`,s+=n?`&version=${n}`:"");const{result:{proxies:a}}=await this.get("credentials/ips"+s);return a}async publicKey(){if(!this._publicKey){const{result:{jwk:e}}=await this.get("credentials/certificate");this._publicKey=await Yf(e)}return this._publicKey}get clientId(){return Hf(this._token).header.kid}get socket(){if(!this._token)throw new Error("Token not present");return this._socket||(this._socket=new cg(this.config.websocketEndpoint,{heartbeatIntervalMs:5e3,transport:this._transport,reconnectAfterMs:()=>zs(this._token)?3e4:1e3}),this.onOpen(this.resubscribe)),this._socket.params=()=>({reconnect:!0,token:this._token,client:"coinrayjs",version:Jf}),this._socket}getChannel(e){if(this.connect(),this._channels[e])return this._channels[e];const n=this.socket.channel(e,{});return this._channels[e]=n,n.join(),n}get=async(e,{apiEndpoint:n=void 0,version:s="v2",headers:a={},params:c={},secret:u=""}={})=>await this._request(e,"GET",{version:s,apiEndpoint:n,headers:a,secret:u,params:c});post=async(e,n)=>await this._request(e,"POST",n);patch=async(e,n)=>await this._request(e,"PATCH",n);delete=async(e,n)=>await this._request(e,"delete",n);async _request(e,n,{apiEndpoint:s,version:a="v2",headers:c={},params:u={},body:l={},secret:h=""}){const m=await this.getToken(),w=Object.entries(u).length>0?"?"+Object.entries(u).map(([O,I])=>I?`${O}=${I}`:void 0).filter(Boolean).join("&"):"",T=this.getNonce(),P=`/api/${a}/${e}${w}`;if(a==="v2"&&!e.startsWith("candles")){const O=[T,n.toUpperCase(),P,n==="GET"?"":JSON.stringify(l)].join(""),I=h!=""?await jo(O,h):"";c={...c,"Cr-Access-Token":`${m}`,"Cr-Nonce":T,"Cr-Signature":I}}const $={method:n,url:(s||this.config.apiEndpoint)+P,timeout:2e4,headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${m}`,"Cr-Client-version":Jf,...c},data:n==="GET"?void 0:JSON.stringify(l)};try{const O=await Qe($);let I;O.status===200?I=O.data:O.status===204?I={}:I=O.data;const F=Object.fromEntries(Object.entries(O.headers).map(([ne,Y])=>[ne,Array.isArray(Y)?Y.join(", "):String(Y)]));return{result:I,_headers:F}}catch(O){const{response:I}=O;if(I){const{error:F}=I.data;throw new a1(F)}else throw O}}static _parseOrderBookSnapshot({asks:e,bids:n,min_seq:s,max_seq:a}){return{minSeq:s,maxSeq:a,asks:xe._parseBidAsk(e),bids:xe._parseBidAsk(n)}}static _parseOrderBookUpdate({asks_diff:e,bids_diff:n,min_seq:s,max_seq:a}){return{minSeq:s,maxSeq:a,asks:xe._parseBidAsk(e),bids:xe._parseBidAsk(n)}}static _updateOrderBook(e,{asks:n,bids:s,min_seq:a,max_seq:c}){const u=(l,h)=>{ct.forEach(h,(m,w)=>{m>0?l[w]=m:delete l[w]})};return e.minSeq=a,e.maxSeq=c,u(e.bids,s),u(e.asks,n),e}static _parseBidAsk(e){return Array.isArray(e)?e.reduce((n,[s,a])=>(n[s]=parseFloat(a),n),{}):Object.keys(e).reduce((n,s)=>(n[s]=parseFloat(e[s]),n),{})}static _parseCandle(e){if(e){const[n,s,a,c,u,l,h]=e;return{time:ru(n),open:parseFloat(s),high:parseFloat(a),low:parseFloat(c),close:parseFloat(u),baseVolume:parseFloat(l),quoteVolume:parseFloat(h),numTrades:0}}else throw new Error("Candle")}static _parseTrade([e,n,s,a,c]){return{id:e,time:ru(n),price:parseFloat(s),quantity:parseFloat(a),type:["1","buy"].includes(c.toString())?"buy":"sell"}}static _parseTicker(e){return{askPrice:X(e.a),baseVolume:X(e.bv),bidPrice:X(e.b),btcVolume:X(e.B),coinraySymbol:e.s,highPrice1s:X(e.h),highPrice24h:X(e.H),lastPrice:X(e.c),lowPrice1s:X(e.l),lowPrice24h:X(e.L),openPrice1s:X(e.o),openPrice24h:X(e.O),quoteVolume:X(e.qv),usdVolume:X(e.U)}}static _parseBalance(e){let n={currency:e.currency,available:X(e.available),inOrders:X(e.inOrders),total:X(e.inOrders)};return e.initialMargin&&(n={...n,initialMargin:X(e.initialMargin),openOrderInitialMargin:X(e.openOrderInitialMargin),positionInitialMargin:X(e.positionInitialMargin),unrealizedProfit:X(e.unrealizedProfit),crossWalletBalance:X(e.crossWalletBalance),crossUnrealizedProfit:X(e.crossUnrealizedProfit)}),n}static _tradesToLastCandle(e,n){n.length>0&&n[0].time>n[n.length-1].time&&(n=n.reverse());const s=xe._resolutionToSeconds(e),a=ct.groupBy(n.reverse(),({time:c})=>Math.floor(c.getTime()/s)*s);return ct.sortBy(Object.keys(a),c=>parseInt(c)).reduce((c,u)=>{const l=a[u],h=l[0].time.getTime(),m=new Date(h-h%s);if(l.length===0)return c;let w=l[0],T,P,$,O,I=0,F=0;return c.length===0?T=P=$=O=w.price:T=P=$=O=c[c.length-1].close,l.reverse().map(({price:ne,quantity:Y})=>{P=Math.min(P,ne),$=Math.max($,ne),O=ne,I+=Y,F+=Y*ne}),c.push({time:new Date(m),open:T,high:$,low:P,close:O,baseVolume:I,quoteVolume:F,numTrades:l.length}),c},[])}static _mergeCandle(e,n){return!e||e.time<n.time?n:(e.numTrades+=n.numTrades,e.high=Math.max(e.high,n.high),e.low=Math.min(e.low,n.low),e.close=n.close,e.skipVolume?e.skipVolume=!1:(e.baseVolume+=n.baseVolume,e.quoteVolume+=n.quoteVolume),e)}static _resolutionToSeconds(e){return e.indexOf("W")>0||e.indexOf("D")>0?parseInt(e)*24*60*60*1e3:e.indexOf("S")>0?parseInt(e)*1e3:e==="D"?864e5:parseInt(e)*60*1e3}}class iu{listeners;constructor(){this.listeners={}}removeAllListeners(){this.listeners={}}on=(e,n)=>(e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push(n),n);off=(e,n)=>{e in this.listeners&&(n?this.listeners[e]=this.listeners[e].filter(s=>s!==n):this.listeners[e]=[])};hasListeners=e=>this.listeners[e]&&this.listeners[e].length>0;dispatchEvent=(e,n={})=>{const s=this.listeners[e];s&&s.length>0&&s.map(a=>a({eventName:e,data:n}))}}class Ui extends iu{getExchange;api;id;coinraySymbol;symbol;symbolAlt;quoteCurrency;underlyingQuoteCurrency;baseLogoUrl;baseCurrency;exchangeCode;volume;quoteVolume;btcVolume;usdVolume;websocket;openPrice;highPrice;lowPrice;precisionBase;precisionQuote;precisionPrice;minBase;maxBase;maxBaseMarket;minQuote;maxQuote;minTrade;maxTrade;makerFee;takerFee;change;delistedOn;exchangeUrl;baseToUsd;quoteToUsd;status;note;_supportedOrderTypes;_lastPrice;_askPrice;_bidPrice;updatedAt;futuresSettings;getPriceOverrides;static Create(e,n,s){if(e==null?Xo(e):typeof e!="object"?eu(e,!1):Array.isArray(e)&&tu(e,!1),_t(e.id,!1,"id"),Ne(e.coinraySymbol,!1,"coinraySymbol"),Ne(e.symbol,!1,"symbol"),Ne(e.symbolAlt,!1,"symbolAlt"),Ne(e.quoteCurrency,!1,"quoteCurrency"),Ne(e.underlyingQuoteCurrency,!1,"underlyingQuoteCurrency"),Ne(e.baseLogoUrl,!0,"baseLogoUrl"),Ne(e.baseCurrency,!1,"baseCurrency"),Ne(e.exchangeCode,!1,"exchangeCode"),Ne(e.status||"",!1,"status"),Ne(e.note||"",!1,"note"),at(e.volume,!0,"volume"),at(e.quoteVolume,!0,"quoteVolume"),at(e.btcVolume,!0,"btcVolume"),at(e.usdVolume,!0,"usdVolume"),Tn(e.websocket,!1,"websocket"),at(e.openPrice,!0,"openPrice"),at(e.highPrice,!0,"highPrice"),at(e.lowPrice,!0,"lowPrice"),_t(e.precisionBase,!1,"precisionBase"),_t(e.precisionPrice,!1,"precisionPrice"),_t(e.precisionBase,!1,"precisionBase"),_t(e.minBase,!0,"minBase"),_t(e.precisionQuote,!1,"precisionQuote"),_t(e.minQuote,!0,"minQuote"),at(e.maxBase,!0,"maxBase"),at(e.maxBaseMarket,!0,"maxBaseMarket"),at(e.maxQuote,!0,"maxQuote"),at(e.minTrade,!1,"minTrade"),_t(e.maxTrade,!0,"maxTrade"),e.maxTrade===void 0&&(e.maxTrade=null),_t(e.makerFee,!1,"makerFee"),_t(e.takerFee,!1,"takerFee"),_t(e.change,!1,"change"),Kf(e.delistedOn,"delistedOn"),e.delistedOn===void 0&&(e.delistedOn=null),Ne(e.exchangeUrl,!1,"exchangeUrl"),at(e.lastPrice,!0,"lastPrice"),at(e.baseToUsd,!1,"baseToUsd"),at(e.quoteToUsd,!1,"quoteToUsd"),at(e.askPrice,!0,"askPrice"),at(e.bidPrice,!0,"bidPrice"),Ne(e.updatedAt,!1,"updatedAt"),e.futuresSettings!==null&&e.futuresSettings!==void 0){const a=e.futuresSettings;Ne(a.tenor,!1,"futuresSettings.tenor"),Ne(a.margin,!1,"futuresSettings.margin"),Ne(a.expiresAt,!0,"futuresSettings.expiresAt"),_t(a.fundingIntervalSeconds,!0,"futuresSettings.fundingIntervalSeconds"),at(a.maxLeverage,!0,"futuresSettings.maxLeverage"),Ne(a.groupName,!0,"futuresSettings.groupName")}return new Ui(e,n,s)}constructor(e,n,s){if(super(),this.getExchange=()=>s,this.api=n,this.id=e.id,this.coinraySymbol=e.coinraySymbol,this.symbol=e.symbol,this.symbolAlt=e.symbolAlt,this.quoteCurrency=e.quoteCurrency.toUpperCase(),this.underlyingQuoteCurrency=e.underlyingQuoteCurrency.toUpperCase(),this.baseLogoUrl=e.baseLogoUrl,this.baseCurrency=e.baseCurrency.toUpperCase(),this.exchangeCode=e.exchangeCode,this.status=e.status,this.note=e.note,this.volume=X(e.volume),this.quoteVolume=X(e.quoteVolume),this.btcVolume=X(e.btcVolume),this.usdVolume=X(e.usdVolume),this.websocket=e.websocket,this.openPrice=X(e.openPrice),this.highPrice=X(e.highPrice),this.lowPrice=X(e.lowPrice),this.precisionBase=e.precisionBase,this.precisionPrice=e.precisionPrice,this.precisionQuote=e.precisionQuote,this.minQuote=e.minQuote,this.precisionBase=e.precisionBase,this.minBase=e.minBase,this.maxBase=X(e.maxBase),this.maxBaseMarket=X(e.maxBaseMarket).isZero()?this.maxBase:X(e.maxBaseMarket),this.maxQuote=X(e.maxQuote),this.minTrade=X(e.minTrade),this.maxTrade=X(e.maxTrade),this.makerFee=Ni(e.makerFee),this.takerFee=Ni(e.takerFee),this.change=Ni(e.change),this.delistedOn=e.delistedOn,this.exchangeUrl=e.exchangeUrl,this._lastPrice=X(e.lastPrice),this.baseToUsd=X(e.baseToUsd),this.quoteToUsd=X(e.quoteToUsd),this._askPrice=X(e.askPrice),this._bidPrice=X(e.bidPrice),this._supportedOrderTypes=e.supportedOrderTypes,this.updatedAt=e.updatedAt,e.futuresSettings!==null&&e.futuresSettings!==void 0){const a=e.futuresSettings;this.futuresSettings={tenor:a.tenor,margin:a.margin,expiresAt:a.expiresAt?new Date(a.expiresAt):null,fundingIntervalSeconds:a.fundingIntervalSeconds??null,maxLeverage:a.maxLeverage!==null&&a.maxLeverage!==void 0?X(a.maxLeverage):null,groupName:a.groupName??void 0}}}get tradingDisabled(){return this.status==="INACTIVE"}get tradingEnabled(){return!this.tradingDisabled}get quoteLogoUrl(){return`https://api.coinray.eu/api/v2/explorer/currencies/${this.quoteCurrency}/thumb`}get supportedOrderTypes(){return this._supportedOrderTypes.length>0?this._supportedOrderTypes:this.getExchange().supportedOrderTypes}get isFutures(){return this.getExchange().isFutures}get groupName(){return this.futuresSettings?.groupName}get fullDisplayName(){return[this.exchangeCode,this.displayName].join(": ")}get displayName(){return[this.baseCurrency,this.quoteCurrency].join("/")}get priceOverrides(){return this.getPriceOverrides?this.getPriceOverrides():{}}get lastPrice(){return this.priceOverrides.lastPrice||this._lastPrice}get askPrice(){return this.priceOverrides.askPrice||this._askPrice}get bidPrice(){return this.priceOverrides.bidPrice||this._bidPrice}overridePrices=e=>{this.getPriceOverrides=e};updateLastPrice=e=>{this._lastPrice=e,this.change=this.openPrice.isZero()?0:this.lastPrice.minus(this.openPrice).dividedBy(this.openPrice).multipliedBy(100).toNumber(),this.dispatchEvent("price")};updateBidAsk=(e,n)=>{this._bidPrice=e,this._askPrice=n,this.dispatchEvent("bidask")};updateTicker=e=>{this.openPrice=e.openPrice24h,this.highPrice=e.highPrice24h,this.lowPrice=e.lowPrice24h,this.updateBidAsk(e.bidPrice,e.askPrice),this.updateLastPrice(e.lastPrice),this.dispatchEvent("ticker")};clone(){const e={...this,volume:this.volume,quoteVolume:this.quoteVolume,btcVolume:this.btcVolume,usdVolume:this.usdVolume,openPrice:this.openPrice,highPrice:this.highPrice,lowPrice:this.lowPrice,lastPrice:this._lastPrice,askPrice:this._askPrice,bidPrice:this._bidPrice,maxBase:this.maxBase,maxBaseMarket:this.maxBaseMarket,maxQuote:this.maxQuote,minTrade:this.minTrade,maxTrade:this.maxTrade,baseToUsd:this.baseToUsd,quoteToUsd:this.quoteToUsd},n=new Ui(e,this.api,this.getExchange());return n.getPriceOverrides=this.getPriceOverrides,n.listeners=this.listeners,n}}class Bi{api;id;name;code;websocket;active;aliasedTo;tradingEnabled;tradingEnabledFrom;isFutures;isDex;logo;btcVolume;usdVolume;totalMarkets;quoteCurrencies;supportedFeatures;supportedResolutions;supportedOrderTypes;baseCurrencyDominance;apiKeySettings;apiEndpoint;websocketEndpoint;markets;exchangeSymbols;static Create(e,n){if(e==null?Xo(e):typeof e!="object"?eu(e,!1):Array.isArray(e)&&tu(e,!1),_t(e.id,!1,"id"),Ne(e.name,!1,"name"),Ne(e.code,!1,"code"),Tn(e.websocket,!1,"websocket"),Tn(e.active,!1,"active"),Tn(e.tradingEnabled,!1,"tradingEnabled"),Ne(e.tradingEnabledFrom,!1,"tradingEnabledFrom"),Tn(e.isFutures,!0,"isFutures"),Tn(e.isDex,!0,"isDex"),Ne(e.logo,!1,"logo"),Ne(e.btcVolume,!1,"btcVolume"),Ne(e.usdVolume,!1,"usdVolume"),_t(e.totalMarkets,!1,"totalMarkets"),js(e.quoteCurrencies,"quoteCurrencies"),Ne(e.apiEndpoint,!0,"apiEndpoint"),Ne(e.websocketEndpoint,!0,"websocketEndpoint"),Ne(e.aliasedTo,!0,"aliasedTo"),e.quoteCurrencies)for(let s=0;s<e.quoteCurrencies.length;s++)Ne(e.quoteCurrencies[s],!1,"quoteCurrencies["+s+"]");if(e.quoteCurrencies===void 0&&(e.quoteCurrencies=null),js(e.supportedResolutions,"supportedResolutions"),js(e.supportedFeatures,"supportedFeatures"),e.supportedResolutions)for(let s=0;s<e.supportedResolutions.length;s++)Ne(e.supportedResolutions[s],!1,"supportedResolutions["+s+"]");return e.supportedResolutions===void 0&&(e.supportedResolutions=null),new Bi(e,n)}constructor(e,n){this.api=n,this.id=e.id,this.name=e.name,this.code=e.code,this.websocket=e.websocket,this.isFutures=!!e.isFutures,this.isDex=!!e.isDex,this.active=e.active,this.tradingEnabled=e.tradingEnabled,this.tradingEnabledFrom=e.tradingEnabledFrom,this.logo=e.logo,this.btcVolume=X(e.btcVolume),this.usdVolume=X(e.usdVolume),this.totalMarkets=jn(e.totalMarkets),this.quoteCurrencies=e.quoteCurrencies,this.supportedResolutions=e.supportedResolutions,this.supportedFeatures=e.supportedFeatures,this.supportedOrderTypes=e.supportedOrderTypes,this.baseCurrencyDominance=e.baseCurrencyDominance,this.apiKeySettings=e.apiKeySettings,this.markets={},this.exchangeSymbols={},this.apiEndpoint=e.apiEndpoint||n.config.apiEndpoint,this.websocketEndpoint=e.websocketEndpoint||n.config.websocketEndpoint,this.aliasedTo=e.aliasedTo}clone(){return new Bi({api:this.api,id:this.id,name:this.name,code:this.code,websocket:this.websocket,isFutures:this.isFutures,isDex:this.isDex,logo:this.logo,btcVolume:this.btcVolume,usdVolume:this.usdVolume,totalMarkets:this.totalMarkets,quoteCurrencies:this.quoteCurrencies,supportedResolutions:this.supportedResolutions,supportedFeatures:this.supportedFeatures,baseCurrencyDominance:this.baseCurrencyDominance,apiKeySettings:this.apiKeySettings,aliasedTo:this.aliasedTo},this.api)}async loadMarkets(e=void 0){const n=await this.api.fetchMarkets(this,e),s=n.map(a=>{try{return Ui.Create(a,this.api,this)}catch{return new Ui(a,this.api,this)}});return s.length>0&&(this.markets=ct.keyBy(s,"coinraySymbol"),this.exchangeSymbols=ct.keyBy(s,"symbol")),n}getBaseCurrencyDominance(e){return this.baseCurrencyDominance[e]}getMarketByExchangeSymbol(e){return this.exchangeSymbols[e]}getCurrencyPrice(e,n){for(let[s,a]of Object.entries(this.markets)){if(a.baseCurrency===n)return X(e).dividedBy(a.baseToUsd);if(a.quoteCurrency===n)return X(e).dividedBy(a.quoteToUsd)}return new Ze(0)}getUsdPrice(e,n){for(let[s,a]of Object.entries(this.markets)){if(a.baseCurrency===n)return a.baseToUsd.multipliedBy(e);if(a.quoteCurrency===n)return a.quoteToUsd.multipliedBy(e)}return new Ze(0)}getMarket(e){return this.markets[e]}}class o1{subscriptions;pendingAdditions;pendingRemovals;constructor(){this.subscriptions=new Map,this.pendingAdditions=new Map,this.pendingRemovals=new Map}has(e){const n=this.subscriptions.get(e);return n!==void 0&&n.size>0}subscribe(e,n,s=!1){s&&this.unsubscribeAll(e);for(let a of n)this.pendingAdditions.has(a)||this.pendingAdditions.set(a,new Set),this.pendingAdditions.get(a).add(e),this.pendingRemovals.has(a)&&(this.pendingRemovals.get(a).delete(e),this.pendingRemovals.get(a).size===0&&this.pendingRemovals.delete(a))}unsubscribe(e,n){for(let s of n)this.pendingAdditions.has(s)&&(this.pendingAdditions.get(s).delete(e),this.pendingAdditions.get(s).size===0&&this.pendingAdditions.delete(s)),this.pendingRemovals.has(s)||this.pendingRemovals.set(s,new Set),this.pendingRemovals.get(s).add(e)}unsubscribeAll(e){for(let[n,s]of this.subscriptions)s.has(e)&&(this.pendingRemovals.has(n)||this.pendingRemovals.set(n,new Set),this.pendingRemovals.get(n).add(e));this.pendingAdditions.clear()}processPendingChanges(){for(let[e,n]of this.pendingAdditions){this.subscriptions.has(e)||this.subscriptions.set(e,new Set);const s=this.subscriptions.get(e);for(let a of n)s.add(a)}for(let[e,n]of this.pendingRemovals){if(!this.subscriptions.has(e))continue;const s=this.subscriptions.get(e);for(let a of n)s.delete(a);s.size===0&&this.subscriptions.delete(e)}this.pendingAdditions.clear(),this.pendingRemovals.clear()}}class u1 extends iu{rootApi;apis;exchanges;initialized;refreshRate;refreshTimeout;_refreshingToken;tickerSubscriptions;tickerSubscriptionRefeshTimer;_onTokenExpired;onStoreCache;apiCache;constructor(e,n,s=3e4,a=void 0){super(),this.rootApi=new xe(e,n),this.apis=new Map,this.exchanges={},this.initialized=!1,this.refreshRate=s,this.tickerSubscriptions=new o1,this.tickerSubscriptionRefeshTimer=null,this.rootApi.onTokenExpired(this.refreshToken),this.onStoreCache=a?.onStoreCache,this.apiCache=a?.apiCache}async initialize(){this.initialized||(await this.start(),this.initialized=!0)}getRootApi(){return this.rootApi}authenticateDevice(e,n){this.rootApi.authenticateDevice(e,n)}refreshToken=async()=>{if(this._onTokenExpired){if(this._refreshingToken)return await this._refreshingToken;{this._refreshingToken=this._onTokenExpired();let e=await this._refreshingToken;this._refreshingToken=void 0;for(const n of this.apis.values())n.refreshToken(e);return e}}};onTokenExpired(e){this._onTokenExpired=e}async start(){this.refreshTimeout&&clearTimeout(this.refreshTimeout);try{this.apiCache?(await this.refreshExchanges(this.apiCache),this.refreshExchanges()):await this.refreshExchanges()}catch(e){console.error(e)}this.refreshTimeout=setTimeout(this.refreshExchangeInterval,this.refreshRate)}refreshExchangeInterval=async()=>{try{await this.refreshExchanges()}catch(e){console.error(e)}this.refreshTimeout=setTimeout(this.refreshExchangeInterval,this.refreshRate)};destroy(){for(const e of this.apis.values())try{e.destroy()}catch(n){console.error("Could not destroy coinray",n)}this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.initialized=!1}refreshExchanges=async(e=void 0)=>{const n={exchanges:[],markets:{}},s=await this.rootApi.fetchExchanges(c=>(n.exchanges.push(c),this.apis.has(c.code)||this.apis.set(c.code,this.rootApi),Bi.Create(c,this.apis.get(c.code))),e?.exchanges),a=await Promise.all(s.map(async c=>({[c.code]:await c.loadMarkets(e?.markets?.[c.code])})));n.markets=a.reduce((c,u)=>({...c,[Object.keys(u)[0]]:Object.values(u)[0]}),[]),this.exchanges=s.reduce((c,u)=>(c[u.code]=u,c),{}),this.dispatchEvent("marketsUpdated"),!e&&this.onStoreCache&&this.onStoreCache(n)};getProxyList=async(e={})=>await this.rootApi.getProxyList(e);getExchanges(){if(!this.initialized)throw"The cache is not initialized yet";return this.exchanges}getExchange(e){return this.getExchanges()[e]||Bi.Create({id:-1,name:e,code:e,websocket:!1,active:!1,tradingEnabled:!1,tradingEnabledFrom:"",isFutures:!1,isDex:!1,logo:`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
|
|
43
|
+
`+JSON.stringify(e))}function X(t){return Ze.isBigNumber(t)?t:t?new Ze(t):new Ze("0")}function En(t,e){return new Ze(e).toFixed(t>0?t:0)}function Ni(t){return typeof t=="number"?t:parseFloat(t)}function jn(t){return typeof t=="number"?t:parseInt(t)}function ru(t){let e=Ni(t);return e<1e10&&(e=e*1e3),new Date(e)}function qf(t){switch(t.toString().toUpperCase()){case"1S":return 1;case"2S":return 2;case"3S":return 3;case"5S":return 5;case"10S":return 10;case"15S":return 15;case"30S":return 30;case"1":return xt;case"2":return xt*2;case"3":return xt*3;case"5":return xt*5;case"10":return xt*10;case"15":return xt*15;case"30":return xt*30;case"60":return xt*60;case"120":return xt*120;case"240":return xt*240;case"360":return xt*360;case"720":return xt*720;case"D":case"1D":return Li;case"3D":return Li*3;case"W":return $s;case"1W":return $s;case"2W":return $s*2;case"1M":return Li*30}}const Js=t=>typeof t=="object"?t:new Date(t*1e3),$f=(t,e)=>{switch(t=z.utc(Js(t)),e){case"1":case"2":case"3":return t.endOf("day").unix();case"5":case"10":case"15":return t.endOf("isoWeek").unix();case"30":case"60":case"120":return t.endOf("month").unix();case"240":case"360":case"720":case"D":case"1D":return t.endOf("year").unix()}},i1=(t,e)=>{switch(t=z.utc(Js(t)),e){case"1":case"2":case"3":return t.startOf("day").unix();case"5":case"10":case"15":return t.startOf("isoWeek").unix();case"30":case"60":case"120":return t.startOf("month").unix();case"240":case"360":case"720":case"D":case"1D":return t.startOf("year").unix()}};function Gf(t){switch(t){case"1":case"2":case"3":return"day";case"5":case"10":case"15":return"week";case"30":case"60":case"120":return"month";case"240":case"360":case"720":case"D":case"1D":return"year";default:throw new Error(`Unsupported resolution: ${t}`)}}function Vf(t,e){let n=z(Js(e)),s;switch(t){case"day":s={year:n.year(),month:n.month()+1,day:n.date()};break;case"week":s={year:n.isoWeekYear(),week:n.isoWeek()};break;case"month":s={year:n.year(),month:n.month()+1};break;case"year":s={year:n.year()};break;default:throw new Error(`Unsupported bucketType: ${t}`)}return s}function zf(t,e,n){const s=[];let a=z.utc(e*1e3);const c=m=>{switch(n){case"day":return m.startOf("day");case"week":return m.startOf("isoWeek");case"month":return m.startOf("month");case"year":return m.startOf("year");default:throw new Error(`Unsupported bucketType: ${n}`)}},u=m=>{switch(n){case"day":return m.subtract(1,"day");case"week":return m.subtract(1,"week");case"month":return m.subtract(1,"month");case"year":return m.subtract(1,"year");default:throw new Error(`Unsupported bucketType: ${n}`)}};let l=c(a);const h=c(z.utc(t*1e3));for(;l>=h;)s.push(l.clone()),l=u(l);return s}function Qs(t,e,n){let s=qf(e),a=typeof n=="object"?n.getTime()/1e3:n;return Math.floor(a/s)*s-s*(t-1)}function jf(t,e){let n=e;if(typeof e=="string"?n=[{query:e,marketProperty:"fullDisplayName"}]:Array.isArray(e)?n=e.map(a=>{if(typeof a=="string")return{query:a,marketProperty:"fullDisplayName"};if(!Array.isArray(a))return a}):n=[e],n.length===0||!n.find(({query:a})=>!!a&&!!a.length))return t;let s=t;return n.forEach(({query:a,marketProperty:c})=>{let u;if(a.match(/[-_:\/\\]+/))try{u=new RegExp(a.replace(/\*/g,".*"),"i")}catch{}const l=a.toLowerCase().split(/[\s]+/).filter(Boolean);s=ct.pickBy(s,(h,m)=>{const w=h[c];if(w==null)return!1;const T=w.toLowerCase();return u&&c==="fullDisplayName"?!!u.exec(h[c]):l.filter(P=>T.includes(P)).length===l.length})}),s}let nu;class s1{static initialize=e=>{nu=e,console.log("Coinray I18n initialized")};static t=(e,n)=>nu?nu.t(`coinray:${e}`,n):`i18n uninitialized. Set the Coinray.I18n.instance. Key: ${e}`}const Jf="2.0.13";class a1 extends Error{errorCode;errorMessage;exchange;constructor({code:e,message:n,exchange:s}){super("Request failed"),this.name="CoinrayError",this.errorCode=e,this.errorMessage=n,this.exchange=s}}class xe{static I18n=s1;config;_token;_sessionKey;_credential;_firstOpen;_onTokenExpired;_tokenCheckTimeout;_onError;_onOpen;_socket;_transport;_tickerListeners=new Map;_tickerSymbols=new Map;_tradeListeners={};_tradeSnapshots={};_orderbookListeners={};_orderbookSnapshots={};_candleTradeListeners={};_candleListeners={};_candles={};_timers={};_channels={};_connected;markConnected;_publicKey;_refreshingToken;_nonceOffset;tickersSubscribed=!1;tradesSubscribed=!1;orderBookSubscribed=!1;_timeOffset;_timeOffsetTimeout;_candleCache;_candleCacheCreatedAt;constructor(e,{apiEndpoint:n,orderEndpoint:s,websocketEndpoint:a}={apiEndpoint:"https://api.coinray.eu",orderEndpoint:"https://api.coinray.eu",websocketEndpoint:"wss://ws.coinray.eu/v1"}){this._token=e,this._nonceOffset=0,this._timeOffset=0,this._firstOpen=!0,this.config={apiEndpoint:n||"https://api.coinray.eu",orderEndpoint:s||n||"https://api.coinray.eu",websocketEndpoint:a||"wss://ws.coinray.eu/v1"},this._candleCache=new Map,this.loadTimeOffset().then()}authenticateDevice=(e,n)=>{this._credential=e,this._sessionKey=n};destroy=()=>{this._tradeListeners={},this._orderbookListeners={},this._tickerListeners=new Map,this._tickerSymbols=new Map,this._channels={},this._timeOffsetTimeout&&clearTimeout(this._timeOffsetTimeout),this._tokenCheckTimeout&&clearInterval(this._tokenCheckTimeout),this.disconnect()};checkToken=async(e=!0)=>{try{if(zs(this._token)){if(console.log("Coinray token expired. Can refresh:",!!this._onTokenExpired),!this._onTokenExpired)return!1;this._refreshingToken||(this._refreshingToken=this._onTokenExpired());try{this._token=await this._refreshingToken}catch(n){return console.log("Coinray token could not be refreshed",n),this._refreshingToken=void 0,!1}if(this._refreshingToken=void 0,!zs(this._token))this.reconnect();else return!1}}catch(n){console.error(n)}return e&&(this._tokenCheckTimeout=setTimeout(this.checkToken,5e3)),!0};setTransport=e=>{this._transport=e};onTokenExpired=e=>{this._tokenCheckTimeout&&clearInterval(this._tokenCheckTimeout),this._onTokenExpired=e,this._tokenCheckTimeout=setTimeout(this.checkToken,5e3)};refreshToken=e=>{this._token=e};getNonce=()=>(this._nonceOffset>900&&(this._nonceOffset=0),this._nonceOffset+=1,this.getTime()+this._nonceOffset);getTime=()=>Math.floor(new Date().getTime()/1e3)*1e3+this._timeOffset;loadTimeOffset=async()=>{try{const{result:e}=await this.get("/coinray/time");this._timeOffset=e.time-new Date().getTime()}catch(e){console.error(e)}this._timeOffsetTimeout=setTimeout(this.loadTimeOffset,6e4)};getToken=async()=>{if(await this.checkToken(!1))return this._token;throw new Error("Token is expired. call refreshToken in the onTokenExpired callback")};reconnect=()=>{this._connected&&this.socket.conn.close()};disconnect=()=>{this._socket&&(this._socket.disconnect(),this._socket=void 0),this._connected=void 0};connect=async()=>{if(this._connected){await this._connected;return}else this._connected=new Promise(e=>{this.markConnected=e});this.socket.onOpen(e=>{this._onOpen&&this._onOpen(e)}),this.socket.onError(e=>{this._onError&&this._onError(e)}),this.socket.connect(),this.markConnected()};onOpen=e=>{this._onOpen=e};onError=e=>{this._onError=e};resubscribe=()=>{if(this._firstOpen){this._firstOpen=!1;return}Object.keys(this._tickerListeners).forEach(e=>{this._tickerListeners[e].length>0&&this.getChannel("tickers").push("subscribe",{exchangeCodes:[e]},5e3)}),Object.keys(this._tradeListeners).forEach(e=>{this._tradeListeners[e].length>0&&this.getChannel("trades").push("subscribe",{symbols:e,snapshots:!0},5e3)}),Object.keys(this._orderbookListeners).forEach(e=>{this._orderbookListeners[e].length>0&&this.getChannel("orderbooks").push("subscribe",{symbols:e,snapshots:!0},5e3)})};subscribeTickers=async(e,n=!1,s)=>{if(e.length===0)return!1;if(n&&(this._tickerListeners.clear(),this._tickerSymbols.clear()),this._tickerListeners.has(s)){let c=this._tickerListeners.get(s);e.forEach(u=>c.add(u))}else this._tickerListeners.set(s,new Set(e));e.forEach(c=>{this._tickerSymbols.has(c)||this._tickerSymbols.set(c,new Set),this._tickerSymbols.get(c).add(s)}),await this.connect();const a=this.getChannel("tickers");return a.push("subscribe",{coinraySymbols:e,reset:n},5e3),this.tickersSubscribed||(this.tickersSubscribed=!0,a.on("update",c=>{let{exchange_code:u,tickers:l}=c;const h=l.map(xe._parseTicker);this._tickerListeners.forEach((m,w)=>{const T=h.filter(P=>m.has(P.coinraySymbol));w({type:"tickers:update",exchangeCode:u,tickers:T})})}),a.on("error",c=>console.error(c))),s};unsubscribeAllTickers=()=>{this._tickerListeners.clear(),this._tickerSymbols.clear(),this.getChannel("tickers").push("unsubscribe",{all:!0},5e3)};unsubscribeTickers=(e,n)=>{if(n&&this._tickerListeners.has(n)){let s=this._tickerListeners.get(n),a=[];e.forEach(c=>{s.delete(c),this._tickerSymbols.has(c)&&(this._tickerSymbols.get(c).delete(n),this._tickerSymbols.get(c).size===0&&(this._tickerSymbols.delete(c),a.push(c)))}),s.size===0&&this._tickerListeners.delete(n),a.length>0&&this.getChannel("tickers").push("unsubscribe",{coinraySymbols:a},5e3)}};subscribeTrades=async({coinraySymbol:e},n)=>{if(this._tradeListeners[e]&&this._tradeListeners[e].length>0)return this._tradeListeners[e].includes(n)||this._tradeListeners[e].push(n),n({type:"trades:snapshot",coinraySymbol:e,trades:this._tradeSnapshots[e]}),n;this._tradeSnapshots[e]=[],this._tradeListeners[e]=[n],await this.connect();const s=this.getChannel("trades");return s.push("subscribe",{symbols:e,snapshots:!0},5e3),this.tradesSubscribed||(this.tradesSubscribed=!0,s.on("snapshot",({symbol:a,trades:c})=>{const u=Object.values(this._tradeListeners[a]),l=c.map(xe._parseTrade);this._tradeSnapshots[a]=l,u.map(h=>h({type:"trades:snapshot",coinraySymbol:a,trades:l}))}),s.on("update",({symbol:a,trades:c})=>{const u=Object.values(this._tradeListeners[a]),l=c.map(xe._parseTrade),h=[...l,...this._tradeSnapshots[a]],m=new Date(new Date().getTime()-12e4),w=h.filter(({time:T})=>T>m);w.length>100?this._tradeSnapshots[a]=w:this._tradeSnapshots[a]=h.slice(0,100),u.map(T=>T({type:"trades:update",coinraySymbol:a,trades:l}))}),s.on("error",a=>console.error(a))),n};unsubscribeTrades=({coinraySymbol:e},n)=>{n&&this._tradeListeners[e]?(this._tradeListeners[e]=this._tradeListeners[e].filter(s=>s!==n),this._tradeListeners[e].length===0&&this.getChannel("trades").push("unsubscribe",{symbols:e},5e3)):(this._tradeSnapshots[e]=[],this._tradeListeners[e]=[])};subscribeOrderBook=async({coinraySymbol:e},n)=>{if(this._orderbookListeners[e]&&this._orderbookListeners[e].length>0)return this._orderbookListeners[e].includes(n)||this._orderbookListeners[e].push(n),n({type:"orderBook:snapshot",coinraySymbol:e,orderBook:this._orderbookSnapshots[e]}),n;this._orderbookSnapshots[e]={minSeq:0,maxSeq:0,bids:{},asks:{}},this._orderbookListeners[e]=[n],await this.connect();const s=this.getChannel("orderbooks");return s.push("subscribe",{symbols:e},1e4),this.orderBookSubscribed||(this.orderBookSubscribed=!0,s.on("snapshot",({orderbooks:a})=>{Object.keys(a).forEach(u=>{const l=Object.values(this._orderbookListeners[u]),h=xe._parseOrderBookSnapshot(a[u]);this._orderbookSnapshots[u]=h,l.map(m=>m({type:"orderBook:snapshot",coinraySymbol:u,orderBook:h}))})}),s.on("update",({orderbooks:a})=>{const c=Object.keys(a);c.length!==0&&c.forEach(u=>{const l=Object.values(this._orderbookListeners[u]),h=xe._parseOrderBookUpdate(a[u]);this._orderbookSnapshots[u]=xe._updateOrderBook(this._orderbookSnapshots[u],h),l.map(m=>m({type:"orderBook:update",coinraySymbol:u,orderBook:h}))})}),s.on("error",a=>console.error(a))),n};unsubscribeOrderBook=({coinraySymbol:e},n)=>{n&&this._orderbookListeners[e]?(this._orderbookListeners[e]=this._orderbookListeners[e].filter(s=>s!==n),this._orderbookListeners[e].length===0&&this.getChannel("orderbooks").push("unsubscribe",{symbols:e},5e3)):(this._orderbookSnapshots[e]={minSeq:0,maxSeq:0,bids:{},asks:{}},this._orderbookListeners[e]=[])};subscribeCandles=async({coinraySymbol:e,resolution:n,lastCandle:s},a)=>{const c=`${e}-${n}`;if(this._candleListeners[c]&&this._candleListeners[c].length>0)return this._candleListeners[c].push(a),a;this._candleListeners[c]=[a];const u=({type:l,coinraySymbol:h,trades:m})=>{const w=Object.values(this._candleListeners[c]),T=xe._tradesToLastCandle(n,m),P=T[T.length-1];P&&(this._candles[c]&&l==="trades:snapshot"&&(this._candles[c].skipVolume=!0),this._candles[c]=xe._mergeCandle(this._candles[c],P),w.map($=>$({coinraySymbol:h,resolution:n,candle:this._candles[c],previousCandles:T})))};return this._candleTradeListeners[e]?this._candleTradeListeners[e][c]=u:this._candleTradeListeners[e]={[c]:u},this._candles[c]=s||{time:new Date(0)},await this.subscribeTrades({coinraySymbol:e},u),this.startNewCandleTimer({candleId:c,resolution:n,coinraySymbol:e}),a};startNewCandleTimer=({candleId:e,resolution:n,coinraySymbol:s})=>{this._timers[e]&&clearTimeout(this._timers[e]);let a=Qs(0,n,new Date)-new Date().getTime()/1e3;const c=Object.values(this._candleListeners[e]);this._timers[e]=setTimeout(()=>{let u=Qs(1,n,new Date)*1e3,l=this._candles[e];l&&u>l.time.getTime()&&(this._candles[e]={time:new Date(u),open:l.close,high:l.close,low:l.close,close:l.close,baseVolume:0,quoteVolume:0,numTrades:0},c.map(h=>h({coinraySymbol:s,resolution:n,candle:this._candles[e],previousCandles:[]}))),this.startNewCandleTimer({candleId:e,resolution:n,coinraySymbol:s})},a*1e3)};unsubscribeCandles=({coinraySymbol:e,resolution:n},s)=>{const a=`${e}-${n}`;s&&this._candleListeners[a]?this._candleListeners[a]=this._candleListeners[a].filter(c=>c!==s):this._candleListeners[a]=[],this._candleListeners[a].length===0&&(this.unsubscribeTrades({coinraySymbol:e},this._candleTradeListeners[e][a]),this._timers[a]&&(clearTimeout(this._timers[a]),delete this._timers[a]),delete this._candles[a],delete this._candleTradeListeners[e][a])};fetchFirstCandleTime=async({coinraySymbol:e,resolution:n})=>{let{result:{startTime:s}}=await this.get("candles/start-time",{version:"v1",params:{symbol:e,resolution:n}});return s};fetchCandles=async({coinraySymbol:e,resolution:n,start:s,end:a,useWebSocket:c})=>{if(this.flushCache(),n.endsWith("S"))return(await this.getWebsocketCandles(e,n)).filter($=>{let O=$.time.getTime()/1e3;return O>=s&&O<=a});const u=Gf(n),l=new Date().getTime()/1e3,h=[];let m=a+1;if($f(a,n)>=l){let P=await this.getOpenCandles(c,{version:"v2",params:{symbol:e,resolution:n}});if(P.length>0)m=Math.min(P[0].time.getTime()/1e3,m),h.push(...P);else return[]}let w=Qs(2,n,m),T=ro.chunk(zf(s,w,u),10);for(let P=0;P<T.length;P+=1){let $=T[P].map(F=>{let ne=Vf(u,F),Y={version:"v2",params:{symbol:e,resolution:n,...ne}};return this.getHistoryCandles(Y)}),O=await Promise.all($),I=[];for(let F=0;F<O.length;F+=1)I=O[F].filter(({time:ne})=>ne.getTime()/1e3<m),I.length>0&&(m=Math.min(I[0].time.getTime()/1e3,m),h.unshift(...I));if(I.length===0)break}return h.filter(({time:P})=>{let $=P.getTime()/1e3;return $>=s&&$<=a}).sort((P,$)=>P.time.getTime()-$.time.getTime())};flushCache=()=>{let e=new Date().getTime()/1e3;(!this._candleCacheCreatedAt||e-this._candleCacheCreatedAt>600)&&(this._candleCacheCreatedAt=e,this._candleCache=new Map)};getWebsocketCandles=async(e,n)=>await new Promise(a=>{let c=setTimeout(()=>{this.unsubscribeCandles({coinraySymbol:e,resolution:n},u),a([])},0);const u=({previousCandles:l})=>{clearTimeout(c),this.unsubscribeCandles({coinraySymbol:e,resolution:n},u),a(l)};this.subscribeCandles({coinraySymbol:e,resolution:n},u)});getOpenCandles=async(e,n)=>{const s=this.candleCacheKey({prefix:"O",...n.params});let a=this._candleCache.get(s);if(!e&&a)return a;const c=await this.getWebsocketCandles(n.params.symbol,n.params.resolution),u=ct.keyBy(c,({time:h})=>h.getTime());let{result:l}=await this.get("candles/open",n);if(l.candles){let m=l.candles.map(xe._parseCandle).map(w=>{const T=u[w.time.getTime()];return T?xe._mergeCandle(w,T):w});return this._candleCache.set(s,m),m}else return[]};getHistoryCandles=async e=>{const n=this.candleCacheKey(e.params);let s=this._candleCache.get(n);if(s)return s;{if(e.params.year<2018)return new Promise(c=>c([]));let{result:a}=await this.get("candles/history",e);if(a.candles){let c=a.candles.map(xe._parseCandle);return this._candleCache.set(n,c),c}else return[]}};candleCacheKey=({symbol:e,resolution:n,year:s,month:a="",day:c="",week:u="",prefix:l="C"})=>`${l}/${e}/${n}/${s}/${a}/${c}/${u}`;fetchExchanges=async(e,n)=>{let s=n;return s||({result:{exchanges:s}}=await this.get("exchanges",{version:"v1"})),s.map(e)};fetchMarkets=async(e,n)=>{let s=n;return s||({result:{markets:s}}=await this.get("markets",{version:"v1",params:{exchange:e.code}})),s};createCredential=async(e,n)=>{const s=await this.publicKey();try{const a=await Qo(await Jo({password:n}),s),{result:c}=await this.post("credentials",{secret:n,body:{deviceId:e,encryptedPassword:a}});return c}catch(a){throw a}};wrapApiKey=async(e,n)=>{const s=await this.publicKey();let a;try{if(n)a=e;else{const u=JSON.stringify(e);a=await Qo(await Jo({apiKey:u}),s)}const{result:c}=await this.post("credentials/wrap_api_key",{secret:this._sessionKey,body:{encryptedApiKey:a,credential:this._credential}});return c}catch(c){throw c}};testAccount=async e=>{try{const{result:n}=await this.post("account/test",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,credential:this._credential}});return n}catch(n){throw n}};createSmartOrderSignature=async e=>{try{const{result:n}=await this.post("order/smart_order_signature",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{smartOrder:e,credential:this._credential}});return n}catch(n){throw n}};createOrder=async e=>{try{const{result:n}=await this.post("order",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,credential:this._credential}});return n}catch(n){throw n}};updateOrder=async e=>{try{const{result:n}=await this.patch("order",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,credential:this._credential}});return n}catch(n){throw n}};cancelOrder=async e=>{try{const{result:n}=await this.delete("order",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{...e,orderId:e.orderId.toString(),credential:this._credential}});return n}catch(n){throw n}};createWebSocketToken=async({exchangeCode:e,encryptedApiKey:n})=>{try{const{result:s}=await this.post("exchanges/ws_token",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{encryptedApiKey:n,exchangeCode:e,credential:this._credential}});return s}catch(s){throw s}};fetchPositions=async({exchangeCode:e,encryptedApiKey:n})=>{try{const{result:s}=await this.get("futures/positions",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,params:{credential:this._credential,exchangeCode:e,encryptedApiKey:n}});return s}catch(s){throw s}};getBalances=async({exchangeCode:e,encryptedApiKey:n})=>{try{const{result:{balances:s,positions:a}}=await this.get("account/balances",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,params:{credential:this._credential,exchangeCode:e,encryptedApiKey:n}});return{balances:s.map(xe._parseBalance),positions:a}}catch(s){throw s}};setLeverage=async({coinraySymbol:e,leverage:n,encryptedApiKey:s})=>{try{const{result:a}=await this.post("futures/leverage",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{credential:this._credential,coinraySymbol:e,leverage:n,encryptedApiKey:s}});return a}catch(a){throw a}};setMarginType=async({coinraySymbol:e,marginType:n,encryptedApiKey:s})=>{try{const{result:a}=await this.post("futures/margin_type",{secret:this._sessionKey,apiEndpoint:this.config.orderEndpoint,body:{credential:this._credential,coinraySymbol:e,marginType:n,encryptedApiKey:s}});return a}catch(a){throw a}};async getProxyList({exchangeCode:e,credentialVersion:n}){let s="";e&&(s+=`?exchange=${e.toUpperCase()}`,s+=n?`&version=${n}`:"");const{result:{proxies:a}}=await this.get("credentials/ips"+s);return a}async publicKey(){if(!this._publicKey){const{result:{jwk:e}}=await this.get("credentials/certificate");this._publicKey=await Yf(e)}return this._publicKey}get clientId(){return Hf(this._token).header.kid}get socket(){if(!this._token)throw new Error("Token not present");return this._socket||(this._socket=new cg(this.config.websocketEndpoint,{heartbeatIntervalMs:5e3,transport:this._transport,reconnectAfterMs:()=>zs(this._token)?3e4:1e3}),this.onOpen(this.resubscribe)),this._socket.params=()=>({reconnect:!0,token:this._token,client:"coinrayjs",version:Jf}),this._socket}getChannel(e){if(this.connect(),this._channels[e])return this._channels[e];const n=this.socket.channel(e,{});return this._channels[e]=n,n.join(),n}get=async(e,{apiEndpoint:n=void 0,version:s="v2",headers:a={},params:c={},secret:u=""}={})=>await this._request(e,"GET",{version:s,apiEndpoint:n,headers:a,secret:u,params:c});post=async(e,n)=>await this._request(e,"POST",n);patch=async(e,n)=>await this._request(e,"PATCH",n);delete=async(e,n)=>await this._request(e,"delete",n);async _request(e,n,{apiEndpoint:s,version:a="v2",headers:c={},params:u={},body:l={},secret:h=""}){const m=await this.getToken(),w=Object.entries(u).length>0?"?"+Object.entries(u).map(([O,I])=>I?`${O}=${I}`:void 0).filter(Boolean).join("&"):"",T=this.getNonce(),P=`/api/${a}/${e}${w}`;if(a==="v2"&&!e.startsWith("candles")){const O=[T,n.toUpperCase(),P,n==="GET"?"":JSON.stringify(l)].join(""),I=h!=""?await jo(O,h):"";c={...c,"Cr-Access-Token":`${m}`,"Cr-Nonce":T,"Cr-Signature":I}}const $={method:n,url:(s||this.config.apiEndpoint)+P,timeout:2e4,headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${m}`,"Cr-Client-version":Jf,...c},data:n==="GET"?void 0:JSON.stringify(l)};try{const O=await Qe($);let I;O.status===200?I=O.data:O.status===204?I={}:I=O.data;const F=Object.fromEntries(Object.entries(O.headers).map(([ne,Y])=>[ne,Array.isArray(Y)?Y.join(", "):String(Y)]));return{result:I,_headers:F}}catch(O){const{response:I}=O;if(I){const{error:F}=I.data;throw new a1(F)}else throw O}}static _parseOrderBookSnapshot({asks:e,bids:n,min_seq:s,max_seq:a}){return{minSeq:s,maxSeq:a,asks:xe._parseBidAsk(e),bids:xe._parseBidAsk(n)}}static _parseOrderBookUpdate({asks_diff:e,bids_diff:n,min_seq:s,max_seq:a}){return{minSeq:s,maxSeq:a,asks:xe._parseBidAsk(e),bids:xe._parseBidAsk(n)}}static _updateOrderBook(e,{asks:n,bids:s,min_seq:a,max_seq:c}){const u=(l,h)=>{ct.forEach(h,(m,w)=>{m>0?l[w]=m:delete l[w]})};return e.minSeq=a,e.maxSeq=c,u(e.bids,s),u(e.asks,n),e}static _parseBidAsk(e){return Array.isArray(e)?e.reduce((n,[s,a])=>(n[s]=parseFloat(a),n),{}):Object.keys(e).reduce((n,s)=>(n[s]=parseFloat(e[s]),n),{})}static _parseCandle(e){if(e){const[n,s,a,c,u,l,h]=e;return{time:ru(n),open:parseFloat(s),high:parseFloat(a),low:parseFloat(c),close:parseFloat(u),baseVolume:parseFloat(l),quoteVolume:parseFloat(h),numTrades:0}}else throw new Error("Candle")}static _parseTrade([e,n,s,a,c]){return{id:e,time:ru(n),price:parseFloat(s),quantity:parseFloat(a),type:["1","buy"].includes(c.toString())?"buy":"sell"}}static _parseTicker(e){return{askPrice:X(e.a),baseVolume:X(e.bv),bidPrice:X(e.b),btcVolume:X(e.B),coinraySymbol:e.s,highPrice1s:X(e.h),highPrice24h:X(e.H),lastPrice:X(e.c),lowPrice1s:X(e.l),lowPrice24h:X(e.L),openPrice1s:X(e.o),openPrice24h:X(e.O),quoteVolume:X(e.qv),usdVolume:X(e.U)}}static _parseBalance(e){let n={currency:e.currency,available:X(e.available),inOrders:X(e.inOrders),total:X(e.inOrders)};return e.initialMargin&&(n={...n,initialMargin:X(e.initialMargin),openOrderInitialMargin:X(e.openOrderInitialMargin),positionInitialMargin:X(e.positionInitialMargin),unrealizedProfit:X(e.unrealizedProfit),crossWalletBalance:X(e.crossWalletBalance),crossUnrealizedProfit:X(e.crossUnrealizedProfit)}),n}static _tradesToLastCandle(e,n){n.length>0&&n[0].time>n[n.length-1].time&&(n=n.reverse());const s=xe._resolutionToSeconds(e),a=ct.groupBy(n.reverse(),({time:c})=>Math.floor(c.getTime()/s)*s);return ct.sortBy(Object.keys(a),c=>parseInt(c)).reduce((c,u)=>{const l=a[u],h=l[0].time.getTime(),m=new Date(h-h%s);if(l.length===0)return c;let w=l[0],T,P,$,O,I=0,F=0;return c.length===0?T=P=$=O=w.price:T=P=$=O=c[c.length-1].close,l.reverse().map(({price:ne,quantity:Y})=>{P=Math.min(P,ne),$=Math.max($,ne),O=ne,I+=Y,F+=Y*ne}),c.push({time:new Date(m),open:T,high:$,low:P,close:O,baseVolume:I,quoteVolume:F,numTrades:l.length}),c},[])}static _mergeCandle(e,n){return!e||e.time<n.time?n:(e.numTrades+=n.numTrades,e.high=Math.max(e.high,n.high),e.low=Math.min(e.low,n.low),e.close=n.close,e.skipVolume?e.skipVolume=!1:(e.baseVolume+=n.baseVolume,e.quoteVolume+=n.quoteVolume),e)}static _resolutionToSeconds(e){return e.indexOf("W")>0||e.indexOf("D")>0?parseInt(e)*24*60*60*1e3:e.indexOf("S")>0?parseInt(e)*1e3:e==="D"?864e5:parseInt(e)*60*1e3}}class iu{listeners;constructor(){this.listeners={}}removeAllListeners(){this.listeners={}}on=(e,n)=>(e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push(n),n);off=(e,n)=>{e in this.listeners&&(n?this.listeners[e]=this.listeners[e].filter(s=>s!==n):this.listeners[e]=[])};hasListeners=e=>this.listeners[e]&&this.listeners[e].length>0;dispatchEvent=(e,n={})=>{const s=this.listeners[e];s&&s.length>0&&s.map(a=>a({eventName:e,data:n}))}}class Ui extends iu{getExchange;api;id;coinraySymbol;symbol;symbolAlt;quoteCurrency;underlyingQuoteCurrency;baseLogoUrl;baseCurrency;exchangeCode;volume;quoteVolume;btcVolume;usdVolume;websocket;openPrice;highPrice;lowPrice;precisionBase;precisionQuote;precisionPrice;minBase;maxBase;maxBaseMarket;minQuote;maxQuote;minTrade;maxTrade;makerFee;takerFee;change;delistedOn;exchangeUrl;baseToUsd;quoteToUsd;status;note;_supportedOrderTypes;_lastPrice;_askPrice;_bidPrice;updatedAt;futuresSettings;getPriceOverrides;static Create(e,n,s){if(e==null?Xo(e):typeof e!="object"?eu(e,!1):Array.isArray(e)&&tu(e,!1),_t(e.id,!1,"id"),Ne(e.coinraySymbol,!1,"coinraySymbol"),Ne(e.symbol,!1,"symbol"),Ne(e.symbolAlt,!1,"symbolAlt"),Ne(e.quoteCurrency,!1,"quoteCurrency"),Ne(e.underlyingQuoteCurrency,!1,"underlyingQuoteCurrency"),Ne(e.baseLogoUrl,!0,"baseLogoUrl"),Ne(e.baseCurrency,!1,"baseCurrency"),Ne(e.exchangeCode,!1,"exchangeCode"),Ne(e.status||"",!1,"status"),Ne(e.note||"",!1,"note"),at(e.volume,!0,"volume"),at(e.quoteVolume,!0,"quoteVolume"),at(e.btcVolume,!0,"btcVolume"),at(e.usdVolume,!0,"usdVolume"),Tn(e.websocket,!1,"websocket"),at(e.openPrice,!0,"openPrice"),at(e.highPrice,!0,"highPrice"),at(e.lowPrice,!0,"lowPrice"),_t(e.precisionBase,!1,"precisionBase"),_t(e.precisionPrice,!1,"precisionPrice"),_t(e.precisionBase,!1,"precisionBase"),_t(e.minBase,!0,"minBase"),_t(e.precisionQuote,!1,"precisionQuote"),_t(e.minQuote,!0,"minQuote"),at(e.maxBase,!0,"maxBase"),at(e.maxBaseMarket,!0,"maxBaseMarket"),at(e.maxQuote,!0,"maxQuote"),at(e.minTrade,!1,"minTrade"),_t(e.maxTrade,!0,"maxTrade"),e.maxTrade===void 0&&(e.maxTrade=null),_t(e.makerFee,!1,"makerFee"),_t(e.takerFee,!1,"takerFee"),_t(e.change,!1,"change"),Kf(e.delistedOn,"delistedOn"),e.delistedOn===void 0&&(e.delistedOn=null),Ne(e.exchangeUrl,!1,"exchangeUrl"),at(e.lastPrice,!0,"lastPrice"),at(e.baseToUsd,!1,"baseToUsd"),at(e.quoteToUsd,!1,"quoteToUsd"),at(e.askPrice,!0,"askPrice"),at(e.bidPrice,!0,"bidPrice"),Ne(e.updatedAt,!1,"updatedAt"),e.futuresSettings!==null&&e.futuresSettings!==void 0){const a=e.futuresSettings;Ne(a.tenor,!1,"futuresSettings.tenor"),Ne(a.margin,!1,"futuresSettings.margin"),Ne(a.expiresAt,!0,"futuresSettings.expiresAt"),_t(a.fundingIntervalSeconds,!0,"futuresSettings.fundingIntervalSeconds"),at(a.maxLeverage,!0,"futuresSettings.maxLeverage"),Ne(a.groupName,!0,"futuresSettings.groupName")}return new Ui(e,n,s)}constructor(e,n,s){if(super(),this.getExchange=()=>s,this.api=n,this.id=e.id,this.coinraySymbol=e.coinraySymbol,this.symbol=e.symbol,this.symbolAlt=e.symbolAlt,this.quoteCurrency=e.quoteCurrency.toUpperCase(),this.underlyingQuoteCurrency=e.underlyingQuoteCurrency.toUpperCase(),this.baseLogoUrl=e.baseLogoUrl,this.baseCurrency=e.baseCurrency.toUpperCase(),this.exchangeCode=e.exchangeCode,this.status=e.status,this.note=e.note,this.volume=X(e.volume),this.quoteVolume=X(e.quoteVolume),this.btcVolume=X(e.btcVolume),this.usdVolume=X(e.usdVolume),this.websocket=e.websocket,this.openPrice=X(e.openPrice),this.highPrice=X(e.highPrice),this.lowPrice=X(e.lowPrice),this.precisionBase=e.precisionBase,this.precisionPrice=e.precisionPrice,this.precisionQuote=e.precisionQuote,this.minQuote=e.minQuote,this.precisionBase=e.precisionBase,this.minBase=e.minBase,this.maxBase=X(e.maxBase),this.maxBaseMarket=X(e.maxBaseMarket).isZero()?this.maxBase:X(e.maxBaseMarket),this.maxQuote=X(e.maxQuote),this.minTrade=X(e.minTrade),this.maxTrade=X(e.maxTrade),this.makerFee=Ni(e.makerFee),this.takerFee=Ni(e.takerFee),this.change=Ni(e.change),this.delistedOn=e.delistedOn,this.exchangeUrl=e.exchangeUrl,this._lastPrice=X(e.lastPrice),this.baseToUsd=X(e.baseToUsd),this.quoteToUsd=X(e.quoteToUsd),this._askPrice=X(e.askPrice),this._bidPrice=X(e.bidPrice),this._supportedOrderTypes=e.supportedOrderTypes,this.updatedAt=e.updatedAt,e.futuresSettings!==null&&e.futuresSettings!==void 0){const a=e.futuresSettings;this.futuresSettings={tenor:a.tenor,margin:a.margin,expiresAt:a.expiresAt?new Date(a.expiresAt):null,fundingIntervalSeconds:a.fundingIntervalSeconds??null,maxLeverage:a.maxLeverage!==null&&a.maxLeverage!==void 0?X(a.maxLeverage):null,groupName:a.groupName??void 0}}}get tradingDisabled(){return this.status==="INACTIVE"}get tradingEnabled(){return!this.tradingDisabled}get quoteLogoUrl(){return`https://api.coinray.eu/api/v2/explorer/currencies/${this.quoteCurrency}/thumb`}get supportedOrderTypes(){return this._supportedOrderTypes.length>0?this._supportedOrderTypes:this.getExchange().supportedOrderTypes}get isFutures(){return this.getExchange().isFutures}get groupName(){return this.futuresSettings?.groupName}get fullDisplayName(){return[this.exchangeCode,this.displayName].join(": ")}get displayName(){return[this.baseCurrency,this.quoteCurrency].join("/")}get priceOverrides(){return this.getPriceOverrides?this.getPriceOverrides():{}}get lastPrice(){return this.priceOverrides.lastPrice||this._lastPrice}get askPrice(){return this.priceOverrides.askPrice||this._askPrice}get bidPrice(){return this.priceOverrides.bidPrice||this._bidPrice}overridePrices=e=>{this.getPriceOverrides=e};updateLastPrice=e=>{this._lastPrice=e,this.change=this.openPrice.isZero()?0:this.lastPrice.minus(this.openPrice).dividedBy(this.openPrice).multipliedBy(100).toNumber(),this.dispatchEvent("price")};updateBidAsk=(e,n)=>{this._bidPrice=e,this._askPrice=n,this.dispatchEvent("bidask")};updateTicker=e=>{this.openPrice=e.openPrice24h,this.highPrice=e.highPrice24h,this.lowPrice=e.lowPrice24h,this.updateBidAsk(e.bidPrice,e.askPrice),this.updateLastPrice(e.lastPrice),this.dispatchEvent("ticker")};clone(){const e={...this,volume:this.volume,quoteVolume:this.quoteVolume,btcVolume:this.btcVolume,usdVolume:this.usdVolume,openPrice:this.openPrice,highPrice:this.highPrice,lowPrice:this.lowPrice,lastPrice:this._lastPrice,askPrice:this._askPrice,bidPrice:this._bidPrice,maxBase:this.maxBase,maxBaseMarket:this.maxBaseMarket,maxQuote:this.maxQuote,minTrade:this.minTrade,maxTrade:this.maxTrade,baseToUsd:this.baseToUsd,quoteToUsd:this.quoteToUsd},n=new Ui(e,this.api,this.getExchange());return n.getPriceOverrides=this.getPriceOverrides,n.listeners=this.listeners,n}}class Bi{api;id;name;code;websocket;active;aliasedTo;tradingEnabled;tradingEnabledFrom;isFutures;isDex;logo;btcVolume;usdVolume;totalMarkets;quoteCurrencies;supportedFeatures;supportedResolutions;supportedOrderTypes;baseCurrencyDominance;apiKeySettings;apiEndpoint;websocketEndpoint;markets;exchangeSymbols;static Create(e,n){if(e==null?Xo(e):typeof e!="object"?eu(e,!1):Array.isArray(e)&&tu(e,!1),_t(e.id,!1,"id"),Ne(e.name,!1,"name"),Ne(e.code,!1,"code"),Tn(e.websocket,!1,"websocket"),Tn(e.active,!1,"active"),Tn(e.tradingEnabled,!1,"tradingEnabled"),Ne(e.tradingEnabledFrom,!1,"tradingEnabledFrom"),Tn(e.isFutures,!0,"isFutures"),Tn(e.isDex,!0,"isDex"),Ne(e.logo,!1,"logo"),Ne(e.btcVolume,!1,"btcVolume"),Ne(e.usdVolume,!1,"usdVolume"),_t(e.totalMarkets,!1,"totalMarkets"),js(e.quoteCurrencies,"quoteCurrencies"),Ne(e.apiEndpoint,!0,"apiEndpoint"),Ne(e.websocketEndpoint,!0,"websocketEndpoint"),Ne(e.aliasedTo,!0,"aliasedTo"),e.quoteCurrencies)for(let s=0;s<e.quoteCurrencies.length;s++)Ne(e.quoteCurrencies[s],!1,"quoteCurrencies["+s+"]");if(e.quoteCurrencies===void 0&&(e.quoteCurrencies=null),js(e.supportedResolutions,"supportedResolutions"),js(e.supportedFeatures,"supportedFeatures"),e.supportedResolutions)for(let s=0;s<e.supportedResolutions.length;s++)Ne(e.supportedResolutions[s],!1,"supportedResolutions["+s+"]");return e.supportedResolutions===void 0&&(e.supportedResolutions=null),new Bi(e,n)}constructor(e,n){this.api=n,this.id=e.id,this.name=e.name,this.code=e.code,this.websocket=e.websocket,this.isFutures=!!e.isFutures,this.isDex=!!e.isDex,this.active=e.active,this.tradingEnabled=e.tradingEnabled,this.tradingEnabledFrom=e.tradingEnabledFrom,this.logo=e.logo,this.btcVolume=X(e.btcVolume),this.usdVolume=X(e.usdVolume),this.totalMarkets=jn(e.totalMarkets),this.quoteCurrencies=e.quoteCurrencies,this.supportedResolutions=e.supportedResolutions,this.supportedFeatures=e.supportedFeatures,this.supportedOrderTypes=e.supportedOrderTypes,this.baseCurrencyDominance=e.baseCurrencyDominance,this.apiKeySettings=e.apiKeySettings,this.markets={},this.exchangeSymbols={},this.apiEndpoint=e.apiEndpoint||n.config.apiEndpoint,this.websocketEndpoint=e.websocketEndpoint||n.config.websocketEndpoint,this.aliasedTo=e.aliasedTo}clone(){return new Bi({api:this.api,id:this.id,name:this.name,code:this.code,websocket:this.websocket,isFutures:this.isFutures,isDex:this.isDex,logo:this.logo,btcVolume:this.btcVolume,usdVolume:this.usdVolume,totalMarkets:this.totalMarkets,quoteCurrencies:this.quoteCurrencies,supportedResolutions:this.supportedResolutions,supportedFeatures:this.supportedFeatures,baseCurrencyDominance:this.baseCurrencyDominance,apiKeySettings:this.apiKeySettings,aliasedTo:this.aliasedTo},this.api)}async loadMarkets(e=void 0){const n=await this.api.fetchMarkets(this,e),s=n.map(a=>{try{return Ui.Create(a,this.api,this)}catch{return new Ui(a,this.api,this)}});return s.length>0&&(this.markets=ct.keyBy(s,"coinraySymbol"),this.exchangeSymbols=ct.keyBy(s,"symbol")),n}getBaseCurrencyDominance(e){return this.baseCurrencyDominance[e]}getMarketByExchangeSymbol(e){return this.exchangeSymbols[e]}getCurrencyPrice(e,n){for(let[s,a]of Object.entries(this.markets)){if(a.baseCurrency===n)return X(e).dividedBy(a.baseToUsd);if(a.quoteCurrency===n)return X(e).dividedBy(a.quoteToUsd)}return new Ze(0)}getUsdPrice(e,n){for(let[s,a]of Object.entries(this.markets)){if(a.baseCurrency===n)return a.baseToUsd.multipliedBy(e);if(a.quoteCurrency===n)return a.quoteToUsd.multipliedBy(e)}return new Ze(0)}getMarket(e){return this.markets[e]}}class o1{subscriptions;pendingAdditions;pendingRemovals;constructor(){this.subscriptions=new Map,this.pendingAdditions=new Map,this.pendingRemovals=new Map}has(e){const n=this.subscriptions.get(e);return n!==void 0&&n.size>0}subscribe(e,n,s=!1){s&&this.unsubscribeAll(e);for(let a of n)this.pendingAdditions.has(a)||this.pendingAdditions.set(a,new Set),this.pendingAdditions.get(a).add(e),this.pendingRemovals.has(a)&&(this.pendingRemovals.get(a).delete(e),this.pendingRemovals.get(a).size===0&&this.pendingRemovals.delete(a))}unsubscribe(e,n){for(let s of n)this.pendingAdditions.has(s)&&(this.pendingAdditions.get(s).delete(e),this.pendingAdditions.get(s).size===0&&this.pendingAdditions.delete(s)),this.pendingRemovals.has(s)||this.pendingRemovals.set(s,new Set),this.pendingRemovals.get(s).add(e)}unsubscribeAll(e){for(let[n,s]of this.subscriptions)s.has(e)&&(this.pendingRemovals.has(n)||this.pendingRemovals.set(n,new Set),this.pendingRemovals.get(n).add(e));this.pendingAdditions.clear()}processPendingChanges(){for(let[e,n]of this.pendingAdditions){this.subscriptions.has(e)||this.subscriptions.set(e,new Set);const s=this.subscriptions.get(e);for(let a of n)s.add(a)}for(let[e,n]of this.pendingRemovals){if(!this.subscriptions.has(e))continue;const s=this.subscriptions.get(e);for(let a of n)s.delete(a);s.size===0&&this.subscriptions.delete(e)}this.pendingAdditions.clear(),this.pendingRemovals.clear()}}class u1 extends iu{rootApi;apis;exchanges;initialized;refreshRate;refreshTimeout;_refreshingToken;tickerSubscriptions;tickerSubscriptionRefeshTimer;_onTokenExpired;onStoreCache;apiCache;constructor(e,n,s=3e4,a=void 0){super(),this.rootApi=new xe(e,n),this.apis=new Map,this.exchanges={},this.initialized=!1,this.refreshRate=s,this.tickerSubscriptions=new o1,this.tickerSubscriptionRefeshTimer=null,this.rootApi.onTokenExpired(this.refreshToken),this.onStoreCache=a?.onStoreCache,this.apiCache=a?.apiCache}async initialize(){this.initialized||(await this.start(),this.initialized=!0)}getRootApi(){return this.rootApi}authenticateDevice(e,n){this.rootApi.authenticateDevice(e,n)}refreshToken=async()=>{if(this._onTokenExpired){if(this._refreshingToken)return await this._refreshingToken;{this._refreshingToken=this._onTokenExpired();let e=await this._refreshingToken;this._refreshingToken=void 0;for(const n of this.apis.values())n.refreshToken(e);return e}}};onTokenExpired(e){this._onTokenExpired=e}async start(){this.refreshTimeout&&clearTimeout(this.refreshTimeout);try{this.apiCache?(await this.refreshExchanges(this.apiCache),this.refreshExchanges()):await this.refreshExchanges()}catch(e){console.error(e)}this.refreshTimeout=setTimeout(this.refreshExchangeInterval,this.refreshRate)}refreshExchangeInterval=async()=>{try{await this.refreshExchanges()}catch(e){console.error(e)}this.refreshTimeout=setTimeout(this.refreshExchangeInterval,this.refreshRate)};destroy(){for(const e of this.apis.values())try{e.destroy()}catch(n){console.error("Could not destroy coinray",n)}this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.initialized=!1}refreshExchanges=async(e=void 0)=>{const n={exchanges:[],markets:{}},s=await this.rootApi.fetchExchanges(c=>(n.exchanges.push(c),this.apis.has(c.code)||this.apis.set(c.code,this.rootApi),Bi.Create(c,this.apis.get(c.code))),e?.exchanges),a=await Promise.all(s.map(async c=>({[c.code]:await c.loadMarkets(e?.markets?.[c.code])})));n.markets=a.reduce((c,u)=>({...c,[Object.keys(u)[0]]:Object.values(u)[0]}),[]),this.exchanges=s.reduce((c,u)=>(c[u.code]=u,c),{}),this.dispatchEvent("marketsUpdated"),!e&&this.onStoreCache&&this.onStoreCache(n)};getProxyList=async(e={})=>await this.rootApi.getProxyList(e);getExchanges(){if(!this.initialized)throw"The cache is not initialized yet";return this.exchanges}getExchange(e){return this.getExchanges()[e]||Bi.Create({id:-1,name:e,code:e,websocket:!1,active:!1,tradingEnabled:!1,tradingEnabledFrom:"",isFutures:!1,isDex:!1,logo:`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
|
|
44
44
|
`,btcVolume:"0",usdVolume:"0",totalMarkets:0,quoteCurrencies:[]},this.rootApi)}refreshMarkets=async e=>{await this.exchanges[e].loadMarkets()};searchMarkets(e){return Object.values(this.exchanges).reduce((n,s)=>(n={...n,...jf(s.markets,e)},n),{})}getMarkets(e){switch(typeof e){case"string":return this.getExchange(e).markets;default:return e.reduce((n,s)=>{const a=this.getMarket(s);return a&&(n[s]=a),n},{})}}getMarket=e=>{const n=`${e}`.split("_");if(n.length<3)return;const s=this.getExchange(n[0]);if(s)return s.getMarket(e)};async fetchCandles({coinraySymbol:e,resolution:n,start:s,end:a,useWebSocket:c}){return this.apiForSymbol(e).fetchCandles({coinraySymbol:e,resolution:n,start:s,end:a,useWebSocket:c})}async fetchFirstCandleTime({coinraySymbol:e,resolution:n}){return this.apiForSymbol(e).fetchFirstCandleTime({coinraySymbol:e,resolution:n})}subscribeTickers(e,n,s=!1){this.tickerSubscriptions.subscribe(e,n,s),this.scheduleTickerRefresh()}scheduleTickerRefresh(){this.tickerSubscriptionRefeshTimer&&clearTimeout(this.tickerSubscriptionRefeshTimer),this.tickerSubscriptionRefeshTimer=setTimeout(async()=>{await this.flushTickerSubscriptions(),this.tickerSubscriptionRefeshTimer=null},1e3)}unsubscribeAllTickers(e){this.tickerSubscriptions.unsubscribeAll(e),this.scheduleTickerRefresh()}unsubscribeTickers(e,n){this.tickerSubscriptions.unsubscribe(e,n),this.scheduleTickerRefresh()}async flushTickerSubscriptions(){const e=[],n=[];for(const s of this.tickerSubscriptions.pendingAdditions.keys())e.push(s);for(const[s,a]of this.tickerSubscriptions.pendingRemovals.entries()){const c=new Set(this.tickerSubscriptions.subscriptions.get(s)||[]);for(const l of a)c.delete(l);const u=this.tickerSubscriptions.pendingAdditions.get(s);if(u)for(const l of u)c.add(l);c.size===0&&n.push(s)}e.length&&await this.rootApi.subscribeTickers(e,!1,this.refreshMarketsFromTickers),n.length&&this.rootApi.unsubscribeTickers(n,this.refreshMarketsFromTickers),this.tickerSubscriptions.processPendingChanges()}refreshMarketsFromTickers=async e=>{const{exchangeCode:n,tickers:s}=e,a=this.getExchange(n);if(a){let c=!1;for(const u of s)if(this.tickerSubscriptions.has(u.coinraySymbol)){const l=a.getMarket(u.coinraySymbol);l&&(l.updateTicker(u),c=!0)}c&&this.dispatchEvent("tickersUpdated",{exchangeCode:n,coinraySymbols:s.map(u=>u.coinraySymbol)})}};async subscribeCandles({coinraySymbol:e,resolution:n,lastCandle:s},a){return this.apiForSymbol(e).subscribeCandles({coinraySymbol:e,resolution:n,lastCandle:s},a)}async unsubscribeCandles({coinraySymbol:e,resolution:n},s){await this.apiForSymbol(e).unsubscribeCandles({coinraySymbol:e,resolution:n},s)}async subscribeOrderBook({coinraySymbol:e},n){await this.apiForSymbol(e).subscribeOrderBook({coinraySymbol:e},n)}async unsubscribeOrderBook({coinraySymbol:e},n){await this.apiForSymbol(e).unsubscribeOrderBook({coinraySymbol:e},n)}async subscribeTrades({coinraySymbol:e},n){await this.apiForSymbol(e).subscribeTrades({coinraySymbol:e},n)}async unsubscribeTrades({coinraySymbol:e},n){await this.apiForSymbol(e).unsubscribeTrades({coinraySymbol:e},n)}apiForSymbol(e){const n=`${e}`.split("_");if(n.length<3)return;const s=n[0];return this.apis.get(s)}}class c1 extends Error{constructor(e){super(e),this.name="MarketNotFoundError"}}const Qf=30*1e3;class l1 extends iu{coinrayCache;getPriceOverrides;coinraySymbol;orderBook;trades;tradesDelayed;maxTrades;prevTickers={lastPrice:new Ze(0),askPrice:new Ze(0),bidPrice:new Ze(0)};constructor(e,n={}){super(),this.coinrayCache=e,this.maxTrades=n.maxTrades||100,n.getPriceOverrides&&(this.getPriceOverrides=n.getPriceOverrides),this.destroy()}setCoinraySymbol(e){this.dispatchEvent("coinraySymbolWillChange",{coinraySymbol:e}),this.stop(),this.coinraySymbol=e,this.startOrderBook(),this.startTrades(),this.dispatchEvent("coinraySymbolChanged",{coinraySymbol:e})}destroy(){this.coinraySymbol=null,this.removeAllListeners(),this.stop()}stop(){this.stopOrderBook(),this.stopTrades()}getExchange(){return this.coinrayCache.getExchange(this.getMarket().exchangeCode)}getMarket(){if(this.coinraySymbol){const e=this.coinrayCache.getMarket(this.coinraySymbol);return e.overridePrices(this.getPriceOverrides),e}else throw new c1(`Market not found: ${this.coinraySymbol}`)}subscribeCoinraySymbolWillChange(e){return this.on("coinraySymbolWillChange",e)}unsubscribeCoinraySymbolWillChange(e){this.off("coinraySymbolWillChange",e)}subscribeCoinraySymbolChange(e){return this.on("coinraySymbolChanged",e)}unsubscribeCoinraySymbolChange(e){this.off("coinraySymbolChanged",e)}subscribeMarketUpdates=e=>(this.on("marketUpdated",e),this.subscribeOrderBook(this.handleMarketUpdate),this.subscribeTrades(this.handleMarketUpdate),e);updatePrevTicker=({lastPrice:e,bidPrice:n,askPrice:s})=>{e&&(this.prevTickers.lastPrice=X(e)),s&&(this.prevTickers.askPrice=X(s)),n&&(this.prevTickers.bidPrice=X(n))};handleMarketUpdate=({data:{type:e,coinraySymbol:n,...s}})=>{if(this.coinraySymbol!==n){this.unsubscribeOrderBook(this.handleOrderBook),this.unsubscribeTrades(this.handleOrderBook);return}switch(e){case"trades:snapshot":case"trades:update":{const{trades:a}=s;if(a.length===0)break;const c=this.getMarket(),u=X(a[0].price);(!c._lastPrice.eq(u)||!this.prevTickers.lastPrice.eq(u))&&(c.updateLastPrice(u),this.updatePrevTicker({lastPrice:u}),this.dispatchEvent("marketUpdated",{market:c}));break}case"orderBook:snapshot":case"orderBook:update":{const{orderBook:{bids:a,asks:c}}=s,u=this.getMarket();if(a.length===0||c.length===0)break;const l=c[0].price,h=a[0].price,m=!u._askPrice.eq(l)||!u._bidPrice.eq(h),w=!this.prevTickers.askPrice.eq(l)||!this.prevTickers.bidPrice.eq(h);(m||w)&&(u.updateBidAsk(h,l),this.updatePrevTicker({askPrice:l,bidPrice:h}),this.dispatchEvent("marketUpdated",{market:u}));break}}};unsubscribeMarketUpdates=e=>{this.off("marketUpdated",e),this.hasListeners("marketUpdated")||(this.unsubscribeOrderBook(this.handleMarketUpdate),this.unsubscribeTrades(this.handleMarketUpdate))};subscribeOrderBook=e=>(this.on("orderBookUpdated",e),this.startOrderBook(),e);startOrderBook=()=>{this.coinraySymbol&&this.hasListeners("orderBookUpdated")&&this.coinrayCache.subscribeOrderBook({coinraySymbol:this.coinraySymbol},this.handleOrderBook)};stopOrderBook=()=>{this.coinraySymbol&&this.coinrayCache.unsubscribeOrderBook({coinraySymbol:this.coinraySymbol},this.handleOrderBook),this.orderBook={minSeq:void 0,maxSeq:void 0,bids:{},asks:{}}};handleOrderBook=async({type:e,coinraySymbol:n,orderBook:s})=>{if(this.coinraySymbol!==n){this.coinrayCache.unsubscribeOrderBook({coinraySymbol:n},this.handleOrderBook);return}e==="orderBook:snapshot"&&(this.orderBook={minSeq:void 0,maxSeq:void 0,bids:{},asks:{}});const{minSeq:a,maxSeq:c,bids:u,asks:l}=s,h=(m,w)=>{ct.forEach(w,(T,P)=>{T>0?m[P]={price:new Ze(P),quantity:T}:delete m[P]})};if(a-this.orderBook.maxSeq>1){this.stopOrderBook(),this.startOrderBook();return}this.orderBook.minSeq=a,this.orderBook.maxSeq=c,h(this.orderBook.bids,u),h(this.orderBook.asks,l),this.dispatchEvent("orderBookUpdated",{type:e,coinraySymbol:n,orderBook:{minSeq:a,maxSeq:c,bids:Object.values(this.orderBook.bids).sort(({price:m},{price:w})=>w.minus(m)),asks:Object.values(this.orderBook.asks).sort(({price:m},{price:w})=>m.minus(w))}})};unsubscribeOrderBook=e=>{this.off("orderBookUpdated",e),this.hasListeners("orderBookUpdated")||this.stopOrderBook()};subscribeTrades=e=>(this.on("tradesUpdated",e),this.startTrades(),e);startTrades=()=>{this.coinraySymbol&&this.hasListeners("tradesUpdated")&&this.coinrayCache.subscribeTrades({coinraySymbol:this.coinraySymbol},this.handleTrades)};stopTrades=()=>{this.coinraySymbol&&this.coinrayCache.unsubscribeTrades({coinraySymbol:this.coinraySymbol},this.handleTrades),this.trades=[]};handleTrades=({type:e,coinraySymbol:n,trades:s})=>{if(this.coinraySymbol!==n){this.coinrayCache.unsubscribeTrades({coinraySymbol:n},this.handleTrades);return}if(e==="trades:snapshot"&&(this.trades=[]),this.trades=[...s,...this.trades].sort((c,u)=>u.time.getTime()-c.time.getTime()).slice(0,this.maxTrades),this.dispatchEvent("tradesUpdated",{type:e,coinraySymbol:n,trades:this.trades}),!this.trades.length)return;const a=Date.now()-this.trades[0].time.getTime();e==="trades:snapshot"&&this.tradesDelayed?this.dispatchTradesDelayed({type:e,coinraySymbol:n,tradesDelayed:!1,delayInMs:a}):e==="trades:update"&&(this.tradesDelayed&&a<Qf?this.dispatchTradesDelayed({type:e,coinraySymbol:n,tradesDelayed:!1,delayInMs:a}):!this.tradesDelayed&&a>=Qf&&this.dispatchTradesDelayed({type:e,coinraySymbol:n,tradesDelayed:!0,delayInMs:a}))};dispatchTradesDelayed=({type:e,coinraySymbol:n,tradesDelayed:s,delayInMs:a})=>{this.tradesDelayed=s,this.dispatchEvent("tradesDelayed",{type:e,coinraySymbol:n,tradesDelayed:s,delayInMs:a})};unsubscribeTrades=e=>{this.off("tradesUpdated",e),this.hasListeners("tradesUpdated")||this.stopTrades()};subscribeTradesDelayed=e=>(this.on("tradesDelayed",e),e);unsubscribeTradesDelayed=e=>{this.off("tradesDelayed",e)}}const f1={"en-US":{validation:{notGreaterThanOrEqualTo:"Can't be less than {{min}}",insufficientFunds:"Insufficient funds"}},nl:{validation:{notGreaterThanOrEqualTo:"Kan niet minder zijn dan {{min}}",insufficientFunds:"Onvoldoende balans"}},ru:{validation:{notGreaterThanOrEqualTo:"Не может быть меньше {{min}}",insufficientFunds:"Недостаточно средств"}}};var Ii={exports:{}};/*!
|
|
45
45
|
* validate.js 0.13.1
|
|
46
46
|
*
|
|
@@ -48,5 +48,5 @@ z.version="2.30.1",t0(qe),z.fn=V,z.min=Ky,z.max=qy,z.now=$y,z.utc=_r,z.unix=ww,z
|
|
|
48
48
|
* Validate.js may be freely distributed under the MIT license.
|
|
49
49
|
* For all details and documentation:
|
|
50
50
|
* http://validatejs.org/
|
|
51
|
-
*/var h1=Ii.exports,Zf;function d1(){return Zf||(Zf=1,(function(t,e){(function(n,s,a){var c=function(l,h,m){m=u.extend({},u.options,m);var w=u.runValidations(l,h,m);if(w.some(function(T){return u.isPromise(T.error)}))throw new Error("Use validate.async if you want support for promises");return c.processValidationResults(w,m)},u=c;u.extend=function(l){return[].slice.call(arguments,1).forEach(function(h){for(var m in h)l[m]=h[m]}),l},u.extend(c,{version:{major:0,minor:13,patch:1,metadata:null,toString:function(){var l=u.format("%{major}.%{minor}.%{patch}",u.version);return u.isEmpty(u.version.metadata)||(l+="+"+u.version.metadata),l}},Promise:typeof Promise<"u"?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(l,h,m){var w=[],T,P,$,O,I,F,ne;(u.isDomElement(l)||u.isJqueryElement(l))&&(l=u.collectFormValues(l));for(T in h){$=u.getDeepObjectValue(l,T),O=u.result(h[T],$,l,T,m,h);for(P in O){if(I=u.validators[P],!I)throw ne=u.format("Unknown validator %{name}",{name:P}),new Error(ne);F=O[P],F=u.result(F,$,l,T,m,h),F&&w.push({attribute:T,value:$,validator:P,globalOptions:m,attributes:l,options:F,error:I.call(I,$,F,T,l,m)})}}return w},processValidationResults:function(l,h){l=u.pruneEmptyErrors(l,h),l=u.expandMultipleErrors(l,h),l=u.convertErrorMessages(l,h);var m=h.format||"grouped";if(typeof u.formatters[m]=="function")l=u.formatters[m](l);else throw new Error(u.format("Unknown format %{format}",h));return u.isEmpty(l)?void 0:l},async:function(l,h,m){m=u.extend({},u.async.options,m);var w=m.wrapErrors||function(P){return P};m.cleanAttributes!==!1&&(l=u.cleanAttributes(l,h));var T=u.runValidations(l,h,m);return new u.Promise(function(P,$){u.waitForResults(T).then(function(){var O=u.processValidationResults(T,m);O?$(new w(O,m,l,h)):P(l)},function(O){$(O)})})},single:function(l,h,m){return m=u.extend({},u.single.options,m,{format:"flat",fullMessages:!1}),u({single:l},{single:h},m)},waitForResults:function(l){return l.reduce(function(h,m){return u.isPromise(m.error)?h.then(function(){return m.error.then(function(w){m.error=w||null})}):h},new u.Promise(function(h){h()}))},result:function(l){var h=[].slice.call(arguments,1);return typeof l=="function"&&(l=l.apply(null,h)),l},isNumber:function(l){return typeof l=="number"&&!isNaN(l)},isFunction:function(l){return typeof l=="function"},isInteger:function(l){return u.isNumber(l)&&l%1===0},isBoolean:function(l){return typeof l=="boolean"},isObject:function(l){return l===Object(l)},isDate:function(l){return l instanceof Date},isDefined:function(l){return l!=null},isPromise:function(l){return!!l&&u.isFunction(l.then)},isJqueryElement:function(l){return l&&u.isString(l.jquery)},isDomElement:function(l){return!l||!l.querySelectorAll||!l.querySelector?!1:u.isObject(document)&&l===document?!0:typeof HTMLElement=="object"?l instanceof HTMLElement:l&&typeof l=="object"&&l!==null&&l.nodeType===1&&typeof l.nodeName=="string"},isEmpty:function(l){var h;if(!u.isDefined(l))return!0;if(u.isFunction(l))return!1;if(u.isString(l))return u.EMPTY_STRING_REGEXP.test(l);if(u.isArray(l))return l.length===0;if(u.isDate(l))return!1;if(u.isObject(l)){for(h in l)return!1;return!0}return!1},format:u.extend(function(l,h){return u.isString(l)?l.replace(u.format.FORMAT_REGEXP,function(m,w,T){return w==="%"?"%{"+T+"}":String(h[T])}):l},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(l){return u.isNumber(l)?l*100%1===0?""+l:parseFloat(Math.round(l*100)/100).toFixed(2):u.isArray(l)?l.map(function(h){return u.prettify(h)}).join(", "):u.isObject(l)?u.isDefined(l.toString)?l.toString():JSON.stringify(l):(l=""+l,l.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(h,m,w){return""+m+" "+w.toLowerCase()}).toLowerCase())},stringifyValue:function(l,h){var m=h&&h.prettify||u.prettify;return m(l)},isString:function(l){return typeof l=="string"},isArray:function(l){return{}.toString.call(l)==="[object Array]"},isHash:function(l){return u.isObject(l)&&!u.isArray(l)&&!u.isFunction(l)},contains:function(l,h){return u.isDefined(l)?u.isArray(l)?l.indexOf(h)!==-1:h in l:!1},unique:function(l){return u.isArray(l)?l.filter(function(h,m,w){return w.indexOf(h)==m}):l},forEachKeyInKeypath:function(l,h,m){if(u.isString(h)){var w="",T,P=!1;for(T=0;T<h.length;++T)switch(h[T]){case".":P?(P=!1,w+="."):(l=m(l,w,!1),w="");break;case"\\":P?(P=!1,w+="\\"):P=!0;break;default:P=!1,w+=h[T];break}return m(l,w,!0)}},getDeepObjectValue:function(l,h){if(u.isObject(l))return u.forEachKeyInKeypath(l,h,function(m,w){if(u.isObject(m))return m[w]})},collectFormValues:function(l,h){var m={},w,T,P,$,O,I;if(u.isJqueryElement(l)&&(l=l[0]),!l)return m;for(h=h||{},$=l.querySelectorAll("input[name], textarea[name]"),w=0;w<$.length;++w)if(P=$.item(w),!u.isDefined(P.getAttribute("data-ignored"))){var F=P.name.replace(/\./g,"\\\\.");I=u.sanitizeFormValue(P.value,h),P.type==="number"?I=I?+I:null:P.type==="checkbox"?P.attributes.value?P.checked||(I=m[F]||null):I=P.checked:P.type==="radio"&&(P.checked||(I=m[F]||null)),m[F]=I}for($=l.querySelectorAll("select[name]"),w=0;w<$.length;++w)if(P=$.item(w),!u.isDefined(P.getAttribute("data-ignored"))){if(P.multiple){I=[];for(T in P.options)O=P.options[T],O&&O.selected&&I.push(u.sanitizeFormValue(O.value,h))}else{var ne=typeof P.options[P.selectedIndex]<"u"?P.options[P.selectedIndex].value:"";I=u.sanitizeFormValue(ne,h)}m[P.name]=I}return m},sanitizeFormValue:function(l,h){return h.trim&&u.isString(l)&&(l=l.trim()),h.nullify!==!1&&l===""?null:l},capitalize:function(l){return u.isString(l)?l[0].toUpperCase()+l.slice(1):l},pruneEmptyErrors:function(l){return l.filter(function(h){return!u.isEmpty(h.error)})},expandMultipleErrors:function(l){var h=[];return l.forEach(function(m){u.isArray(m.error)?m.error.forEach(function(w){h.push(u.extend({},m,{error:w}))}):h.push(m)}),h},convertErrorMessages:function(l,h){h=h||{};var m=[],w=h.prettify||u.prettify;return l.forEach(function(T){var P=u.result(T.error,T.value,T.attribute,T.options,T.attributes,T.globalOptions);if(!u.isString(P)){m.push(T);return}P[0]==="^"?P=P.slice(1):h.fullMessages!==!1&&(P=u.capitalize(w(T.attribute))+" "+P),P=P.replace(/\\\^/g,"^"),P=u.format(P,{value:u.stringifyValue(T.value,h)}),m.push(u.extend({},T,{error:P}))}),m},groupErrorsByAttribute:function(l){var h={};return l.forEach(function(m){var w=h[m.attribute];w?w.push(m):h[m.attribute]=[m]}),h},flattenErrorsToArray:function(l){return l.map(function(h){return h.error}).filter(function(h,m,w){return w.indexOf(h)===m})},cleanAttributes:function(l,h){function m(P,$,O){return u.isObject(P[$])?P[$]:P[$]=O?!0:{}}function w(P){var $={},O;for(O in P)P[O]&&u.forEachKeyInKeypath($,O,m);return $}function T(P,$){if(!u.isObject(P))return P;var O=u.extend({},P),I,F;for(F in P)I=$[F],u.isObject(I)?O[F]=T(O[F],I):I||delete O[F];return O}return!u.isObject(h)||!u.isObject(l)?{}:(h=w(h),T(l,h))},exposeModule:function(l,h,m,w,T){m?(w&&w.exports&&(m=w.exports=l),m.validate=l):(h.validate=l,l.isFunction(T)&&T.amd&&T([],function(){return l}))},warn:function(l){typeof console<"u"&&console.warn&&console.warn("[validate.js] "+l)},error:function(l){typeof console<"u"&&console.error&&console.error("[validate.js] "+l)}}),c.validators={presence:function(l,h){if(h=u.extend({},this.options,h),h.allowEmpty!==!1?!u.isDefined(l):u.isEmpty(l))return h.message||this.message||"can't be blank"},length:function(l,h,m){if(u.isDefined(l)){h=u.extend({},this.options,h);var w=h.is,T=h.maximum,P=h.minimum,$=h.tokenizer||function(ne){return ne},O,I=[];l=$(l);var F=l.length;if(!u.isNumber(F))return h.message||this.notValid||"has an incorrect length";if(u.isNumber(w)&&F!==w&&(O=h.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",I.push(u.format(O,{count:w}))),u.isNumber(P)&&F<P&&(O=h.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",I.push(u.format(O,{count:P}))),u.isNumber(T)&&F>T&&(O=h.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",I.push(u.format(O,{count:T}))),I.length>0)return h.message||I}},numericality:function(l,h,m,w,T){if(u.isDefined(l)){h=u.extend({},this.options,h);var P=[],$,O,I={greaterThan:function(ve,_e){return ve>_e},greaterThanOrEqualTo:function(ve,_e){return ve>=_e},equalTo:function(ve,_e){return ve===_e},lessThan:function(ve,_e){return ve<_e},lessThanOrEqualTo:function(ve,_e){return ve<=_e},divisibleBy:function(ve,_e){return ve%_e===0}},F=h.prettify||T&&T.prettify||u.prettify;if(u.isString(l)&&h.strict){var ne="^-?(0|[1-9]\\d*)";if(h.onlyInteger||(ne+="(\\.\\d+)?"),ne+="$",!new RegExp(ne).test(l))return h.message||h.notValid||this.notValid||this.message||"must be a valid number"}if(h.noStrings!==!0&&u.isString(l)&&!u.isEmpty(l)&&(l=+l),!u.isNumber(l))return h.message||h.notValid||this.notValid||this.message||"is not a number";if(h.onlyInteger&&!u.isInteger(l))return h.message||h.notInteger||this.notInteger||this.message||"must be an integer";for($ in I)if(O=h[$],u.isNumber(O)&&!I[$](l,O)){var Y="not"+u.capitalize($),Ae=h[Y]||this[Y]||this.message||"must be %{type} %{count}";P.push(u.format(Ae,{count:O,type:F($)}))}if(h.odd&&l%2!==1&&P.push(h.notOdd||this.notOdd||this.message||"must be odd"),h.even&&l%2!==0&&P.push(h.notEven||this.notEven||this.message||"must be even"),P.length)return h.message||P}},datetime:u.extend(function(l,h){if(!u.isFunction(this.parse)||!u.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(u.isDefined(l)){h=u.extend({},this.options,h);var m,w=[],T=h.earliest?this.parse(h.earliest,h):NaN,P=h.latest?this.parse(h.latest,h):NaN;if(l=this.parse(l,h),isNaN(l)||h.dateOnly&&l%864e5!==0)return m=h.notValid||h.message||this.notValid||"must be a valid date",u.format(m,{value:arguments[0]});if(!isNaN(T)&&l<T&&(m=h.tooEarly||h.message||this.tooEarly||"must be no earlier than %{date}",m=u.format(m,{value:this.format(l,h),date:this.format(T,h)}),w.push(m)),!isNaN(P)&&l>P&&(m=h.tooLate||h.message||this.tooLate||"must be no later than %{date}",m=u.format(m,{date:this.format(P,h),value:this.format(l,h)}),w.push(m)),w.length)return u.unique(w)}},{parse:null,format:null}),date:function(l,h){return h=u.extend({},h,{dateOnly:!0}),u.validators.datetime.call(u.validators.datetime,l,h)},format:function(l,h){(u.isString(h)||h instanceof RegExp)&&(h={pattern:h}),h=u.extend({},this.options,h);var m=h.message||this.message||"is invalid",w=h.pattern,T;if(u.isDefined(l)&&(!u.isString(l)||(u.isString(w)&&(w=new RegExp(h.pattern,h.flags)),T=w.exec(l),!T||T[0].length!=l.length)))return m},inclusion:function(l,h){if(u.isDefined(l)&&(u.isArray(h)&&(h={within:h}),h=u.extend({},this.options,h),!u.contains(h.within,l))){var m=h.message||this.message||"^%{value} is not included in the list";return u.format(m,{value:l})}},exclusion:function(l,h){if(u.isDefined(l)&&(u.isArray(h)&&(h={within:h}),h=u.extend({},this.options,h),!!u.contains(h.within,l))){var m=h.message||this.message||"^%{value} is restricted";return u.isString(h.within[l])&&(l=h.within[l]),u.format(m,{value:l})}},email:u.extend(function(l,h){h=u.extend({},this.options,h);var m=h.message||this.message||"is not a valid email";if(u.isDefined(l)&&(!u.isString(l)||!this.PATTERN.exec(l)))return m},{PATTERN:/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i}),equality:function(l,h,m,w,T){if(u.isDefined(l)){u.isString(h)&&(h={attribute:h}),h=u.extend({},this.options,h);var P=h.message||this.message||"is not equal to %{attribute}";if(u.isEmpty(h.attribute)||!u.isString(h.attribute))throw new Error("The attribute must be a non empty string");var $=u.getDeepObjectValue(w,h.attribute),O=h.comparator||function(F,ne){return F===ne},I=h.prettify||T&&T.prettify||u.prettify;if(!O(l,$,h,m,w))return u.format(P,{attribute:I(h.attribute)})}},url:function(l,h){if(u.isDefined(l)){h=u.extend({},this.options,h);var m=h.message||this.message||"is not a valid url",w=h.schemes||this.schemes||["http","https"],T=h.allowLocal||this.allowLocal||!1,P=h.allowDataUrl||this.allowDataUrl||!1;if(!u.isString(l))return m;var $="^(?:(?:"+w.join("|")+")://)(?:\\S+(?::\\S*)?@)?(?:",O="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";if(T?O+="?":$+="(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",$+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*"+O+")(?::\\d{2,5})?(?:[/?#]\\S*)?$",P){var I="\\w+\\/[-+.\\w]+(?:;[\\w=]+)*",F="[A-Za-z0-9-_.!~\\*'();\\/?:@&=+$,%]*",ne="data:(?:"+I+")?(?:;base64)?,"+F;$="(?:"+$+")|(?:^"+ne+"$)"}var Y=new RegExp($,"i");if(!Y.exec(l))return m}},type:u.extend(function(l,h,m,w,T){if(u.isString(h)&&(h={type:h}),!!u.isDefined(l)){var P=u.extend({},this.options,h),$=P.type;if(!u.isDefined($))throw new Error("No type was specified");var O;if(u.isFunction($)?O=$:O=this.types[$],!u.isFunction(O))throw new Error("validate.validators.type.types."+$+" must be a function.");if(!O(l,P,m,w,T)){var I=h.message||this.messages[$]||this.message||P.message||(u.isFunction($)?"must be of the correct type":"must be of type %{type}");return u.isFunction(I)&&(I=I(l,h,m,w,T)),u.format(I,{attribute:u.prettify(m),type:$})}}},{types:{object:function(l){return u.isObject(l)&&!u.isArray(l)},array:u.isArray,integer:u.isInteger,number:u.isNumber,string:u.isString,date:u.isDate,boolean:u.isBoolean},messages:{}})},c.formatters={detailed:function(l){return l},flat:u.flattenErrorsToArray,grouped:function(l){var h;l=u.groupErrorsByAttribute(l);for(h in l)l[h]=u.flattenErrorsToArray(l[h]);return l},constraint:function(l){var h;l=u.groupErrorsByAttribute(l);for(h in l)l[h]=l[h].map(function(m){return m.validator}).sort();return l}},c.exposeModule(c,this,n,s,a)}).call(h1,e,t,null)})(Ii,Ii.exports)),Ii.exports}var p1=d1();const su=Sl(p1);su.validators.bigNumericality=(t,e,n,s)=>su.validators.numericality(t&&t.toNumber(),e,s);var rn=(t=>(t.MARKET="MARKET",t.LIMIT="LIMIT",t.LIMIT_LADDER="LIMIT_LADDER",t.STOP_LOSS="STOP_LOSS",t.OCO="OCO",t.STOP_LOSS_LIMIT="STOP_LOSS_LIMIT",t.STOP_LOSS_MARKET="STOP_LOSS_MARKET",t.TAKE_PROFIT="TAKE_PROFIT",t.TAKE_PROFIT_LIMIT="TAKE_PROFIT_LIMIT",t.TAKE_PROFIT_MARKET="TAKE_PROFIT_MARKET",t))(rn||{}),au=(t=>(t.HEDGE_MODE="hedgeMode",t.ORDER_QUOTE_AMOUNT="orderQuoteAmount",t.MARKET_BUY_QUOTE_ONLY="marketBuyQuoteOnly",t.UPDATE_LEVERAGE_ONLY_ON_OPEN_POSITIONS="updateLeverageOnlyOnOpenPositions",t.FAST_CONNECT="fastConnect",t.UNIFIED_BALANCE="unifiedBalance",t.NO_API_KEY_LINK="noApiKeyLink",t))(au||{}),ou=(t=>(t.NONE="NONE",t.LIST="LIST",t.COMMA="COMMA",t.COMMA_SPACE="COMMA_SPACE",t.SPACE="SPACE",t))(ou||{}),uu=(t=>(t.CROSSED="CROSSED",t.ISOLATED="ISOLATED",t))(uu||{}),cu=(t=>(t.OPEN="open",t.CLOSED="closed",t.CANCELED="canceled",t))(cu||{}),wt=(t=>(t.BUY="buy",t.SELL="sell",t))(wt||{}),lu=(t=>(t.GTC="gtc",t.FOK="fok",t.IOC="ioc",t))(lu||{}),vr=(t=>(t.QUOTE="quote",t.BASE="base",t.NONE="none",t))(vr||{});const m1=Object.freeze(Object.defineProperty({__proto__:null,BalanceLimit:vr,ExchangeFeatures:au,IpWhiteList:ou,MarginType:uu,OrderSide:wt,OrderStatus:cu,OrderType:rn,TimeInForce:lu},Symbol.toStringTag,{value:"Module"})),lt=[];for(let t=0;t<256;++t)lt.push((t+256).toString(16).slice(1));function g1(t,e=0){return(lt[t[e+0]]+lt[t[e+1]]+lt[t[e+2]]+lt[t[e+3]]+"-"+lt[t[e+4]]+lt[t[e+5]]+"-"+lt[t[e+6]]+lt[t[e+7]]+"-"+lt[t[e+8]]+lt[t[e+9]]+"-"+lt[t[e+10]]+lt[t[e+11]]+lt[t[e+12]]+lt[t[e+13]]+lt[t[e+14]]+lt[t[e+15]]).toLowerCase()}let fu;const y1=new Uint8Array(16);function _1(){if(!fu){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fu=crypto.getRandomValues.bind(crypto)}return fu(y1)}const Xf={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function w1(t,e,n){t=t||{};const s=t.random??t.rng?.()??_1();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,g1(s)}function b1(t,e,n){return Xf.randomUUID&&!t?Xf.randomUUID():w1(t)}class hu{id=b1();coinraySymbol;precisionBase;precisionQuote;precisionPrice;minBase;minQuote;makerFee;takerFee;balances;balanceLimit;side;errors;isValid;orderExternalId;reduceOnly;postOnly;timeInForce;constructor(e){this.coinraySymbol=e.coinraySymbol,this.precisionBase=jn(e.precisionBase),this.precisionQuote=jn(e.precisionQuote),this.precisionPrice=jn(e.precisionPrice),this.minBase=X(e.minBase),this.minQuote=X(e.minQuote),this.makerFee=X(e.makerFee),this.takerFee=X(e.takerFee),this.balances=e.balances,this.balanceLimit=e.balanceLimit||vr.NONE,this.side=e.side,this.orderExternalId=e.externalId,this.errors={},this.isValid=!0,this.reduceOnly=e.reduceOnly,this.postOnly=e.postOnly,this.timeInForce=e.timeInForce}startEdit(e){this.orderExternalId=e}updateLockedOn(e){}resetError(){this.errors={},this.isValid=!0}validate(){const e=su(this,this.constraints());return e?(this.errors=e,this.isValid=!1):this.resetError(),!e}}class Zs extends hu{baseAmount;quoteAmount;price;lockedOn;orderType=rn.LIMIT;constraints(){let e,n;return this.balanceLimit===vr.QUOTE?n=this.balances.quote||0:this.balanceLimit===vr.BASE&&(e=this.balances.base||0),{baseAmount:{bigNumericality:{greaterThanOrEqualTo:this.minBase.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionBase,this.minBase)})}`,lessThanOrEqualTo:e?e.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},quoteAmount:{bigNumericality:{greaterThanOrEqualTo:this.minQuote.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionQuote,this.minQuote)})}`,lessThanOrEqualTo:n?n.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},price:{bigNumericality:{greaterThan:0}}}}constructor(e,n=!0){super(e),this.price=X(e.price||"0"),this.lockedOn=e.lockedOn,this.baseAmount=X(e.baseAmount),this.quoteAmount=X(e.quoteAmount),n&&(this.quoteAmount.gt(0)&&this.lockedOn==="quoteAmount"?this.updateQuoteAmount(this.quoteAmount):this.updateBaseAmount(this.baseAmount))}updateBaseAmount(e){this.baseAmount=e,this.quoteAmount=this.price.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote>0?this.precisionQuote:0,Ze.ROUND_DOWN),this.validate()}updateQuoteAmount(e){this.quoteAmount=e,this.baseAmount=e.dividedBy(this.price).decimalPlaces(this.precisionBase>0?this.precisionBase:0,Ze.ROUND_DOWN),this.validate()}updateLockedOn(e){this.lockedOn=e,this.validate()}quoteFee(){return this.quoteAmount.multipliedBy(this.takerFee)}updatePrice(e){this.price=e.decimalPlaces(this.precisionPrice),this.lockedOn==="baseAmount"?this.updateBaseAmount(this.baseAmount):this.updateQuoteAmount(this.quoteAmount)}getOrders(){return[this]}}class S1 extends hu{baseAmount;quoteAmount;price;orderType=rn.MARKET;constraints=()=>{let e,n;return this.balanceLimit===vr.QUOTE?n=this.balances.quote||0:this.balanceLimit===vr.BASE&&(e=this.balances.base||0),{baseAmount:{bigNumericality:{greaterThanOrEqualTo:e?this.minBase.toNumber():void 0,notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionBase,this.minBase)})}`,lessThanOrEqualTo:e?e.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},quoteAmount:{bigNumericality:{greaterThanOrEqualTo:n?this.minQuote.toNumber():void 0,notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionQuote,this.minQuote)})}`,lessThanOrEqualTo:n?n.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}}}};constructor(e){super(e),this.updateQuoteAmount(e.quoteAmount),this.updateBaseAmount(e.baseAmount)}updateBaseAmount(e){this.baseAmount=e,e&&(this.quoteAmount=this.price.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote>0?this.precisionQuote:0,Ze.ROUND_DOWN)),this.validate()}updateQuoteAmount(e){this.quoteAmount=e,e&&(this.baseAmount=e.dividedBy(this.price).decimalPlaces(this.precisionBase>0?this.precisionBase:0,Ze.ROUND_DOWN)),this.validate()}updatePrice(e){this.price=e.decimalPlaces(this.precisionPrice)}getOrders(){return[this]}}var eh=(t=>(t.LINEAR="LINEAR",t.EXPONENTIAL="EXPONENTIAL",t.FIBONACCI="FIBONACCI",t.CUSTOM="CUSTOM",t))(eh||{}),th=(t=>(t.EQUAL="EQUAL",t.LINEAR="LINEAR",t.LINEAR_REVERSE="LINEAR_REVERSE",t.EXPONENTIAL="EXPONENTIAL",t.EXPONENTIAL_REVERSE="EXPONENTIAL_REVERSE",t.CUSTOM="CUSTOM",t))(th||{});const rh={LINEAR:t=>ct.times(t,e=>1/(t-1)*e),EXPONENTIAL:t=>{const e=2**(t-1);return ct.times(t,n=>n==0?0:2**n/e)},FIBONACCI:t=>[0,.09,.146,.236,.382,.5,.618,.788,.886].slice(0,t-1).concat([1]),CUSTOM:t=>[]},du=t=>{const e=ct.sum(t);return t.map(n=>n/e)},Xs={EQUAL:t=>{const e=ct.times(t,()=>1);return du(e)},LINEAR:t=>{const e=ct.times(t,n=>1/t*(n+1));return du(e)},EXPONENTIAL:t=>{const e=2**t-1,n=ct.times(t,s=>2**s/e);return du(n)},LINEAR_REVERSE:t=>Xs.LINEAR(t).reverse(),EXPONENTIAL_REVERSE:t=>Xs.EXPONENTIAL(t).reverse(),CUSTOM:t=>[]};class v1 extends hu{baseAmount;quoteAmount;price;lockedOn;otherPrice;numOrders;priceScale;sizeScale;priceScales;sizeScales;orderType=rn.LIMIT_LADDER;constraints(){let e,n;return this.balanceLimit===vr.QUOTE?n=this.balances.quote:this.balanceLimit===vr.BASE&&(e=this.balances.base),{baseAmount:{bigNumericality:{greaterThanOrEqualTo:this.minBase.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionBase,this.minBase)})}`,lessThanOrEqualTo:e?e.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},quoteAmount:{bigNumericality:{greaterThanOrEqualTo:this.minQuote.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionQuote,this.minQuote)})}`,lessThanOrEqualTo:n?n.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},price:{bigNumericality:{greaterThan:0}},otherPrice:{bigNumericality:{greaterThan:0}},numOrders:{numericality:{greaterThanOrEqualTo:2}}}}constructor(e){super(e),this.otherPrice=X(e.otherPrice),this.numOrders=jn(e.numOrders),this.priceScale=e.priceScale||"CUSTOM",this.sizeScale=e.sizeScale||"CUSTOM",this.price=X(e.price||"0"),this.lockedOn=e.lockedOn,this.baseAmount=X(e.baseAmount||"0"),this.quoteAmount=X(e.quoteAmount||"0"),this.priceScales=e.priceScales||rh[this.priceScale](this.numOrders),this.sizeScales=e.sizeScales||Xs[this.sizeScale](this.numOrders),this.quoteAmount.gt(0)&&this.lockedOn==="quoteAmount"?this.updateQuoteAmount(this.quoteAmount):this.updateBaseAmount(this.baseAmount)}updateNumOrders(e){this.numOrders=e}updatePrice(e,n=.05){if(this.price=e.decimalPlaces(this.precisionPrice),e&&this.otherPrice.eq(0)){const s=this.side===wt.BUY?1+n:1-n;this.otherPrice=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}this.recalculate()}updateOtherPrice(e,n=.05){if(this.otherPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1-n:1+n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}this.recalculate()}updatePriceScales(e){this.priceScales=e,this.priceScale="CUSTOM",this.recalculate()}updatePriceScale(e){this.priceScales=rh[e](this.numOrders),this.priceScale=e,this.recalculate()}updateSizeScales(e){this.sizeScales=e,this.sizeScale="CUSTOM",this.recalculate()}updateSizeScale(e){this.sizeScales=Xs[e](this.numOrders),this.sizeScale=e,this.recalculate()}updateLockedOn(e){this.lockedOn=e}recalculate(){this.lockedOn==="baseAmount"?this.updateBaseAmount(this.baseAmount):this.updateQuoteAmount(this.quoteAmount),this.validate()}updateQuoteAmount(e){this.quoteAmount=e,this.numOrders=Math.max(2,+this.numOrders);const n=this.getOrders("quoteAmount");n.length>0?this.baseAmount=ct.reduce(n,(s,a)=>s.plus(a.baseAmount),new Ze(0)):this.baseAmount=new Ze(0)}updateBaseAmount(e){this.baseAmount=e,this.numOrders=Math.max(2,+this.numOrders);const n=this.getOrders("baseAmount");n.length>0?this.quoteAmount=ct.reduce(n,(s,a)=>s.plus(a.quoteAmount),new Ze(0)):this.quoteAmount=new Ze(0)}getOrders(e=this.lockedOn){const n=e==="baseAmount"?this.baseAmount:this.quoteAmount,s=e==="baseAmount"?this.precisionBase:this.precisionQuote;if(!(this.priceScales&&this.priceScales.length>0&&this.sizeScales.length>0&&n.gt(0)))return[];const a=this.priceScales.slice(0,this.numOrders),c=this.sizeScales.slice(0,this.numOrders),u=this.otherPrice.minus(this.price);let l=n;return ct.times(this.numOrders,h=>{let m=n.multipliedBy(c[h]).decimalPlaces(s>0?s:0,Ze.ROUND_DOWN);return l=l.minus(m),h===this.numOrders-1&&(m=m.plus(l)),new Zs({...this,[e]:m,lockedOn:e,price:this.price.plus(u.multipliedBy(a[h])).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)})})}}class T1 extends Zs{stopPrice;orderType=rn.STOP_LOSS_LIMIT;constraints(){return{...super.constraints(),stopPrice:{bigNumericality:{greaterThan:0}}}}constructor(e){super(e),this.stopPrice=X(e.stopPrice)}updatePrice(e,n=.05){if(super.updatePrice(e),e&&this.stopPrice.eq(0)){const s=this.side===wt.BUY?1-n:1+n;this.stopPrice=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}updateStopPrice(e,n=.05){if(this.stopPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1+n:1-n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}}class E1 extends Zs{linkedOrderId;otherPrice;stopPrice;orderType=rn.OCO;constraints(){return{...super.constraints(),otherPrice:{bigNumericality:{greaterThan:0}},stopPrice:{bigNumericality:{greaterThan:0}}}}constructor(e){super(e,!1),this.otherPrice=X(e.otherPrice),this.stopPrice=X(e.stopPrice),this.quoteAmount.gt(0)&&this.lockedOn==="quoteAmount"?this.updateQuoteAmount(this.quoteAmount):this.updateBaseAmount(this.baseAmount)}updateQuoteAmount(e){this.quoteAmount=e;let n=this.side===wt.BUY?this.otherPrice:this.price;this.baseAmount=e.dividedBy(n).decimalPlaces(this.precisionBase>0?this.precisionBase:0,Ze.ROUND_DOWN),this.validate()}updateBaseAmount(e){this.baseAmount=e;let n=this.side===wt.BUY?this.otherPrice:this.price;this.quoteAmount=n.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote>0?this.precisionQuote:0,Ze.ROUND_DOWN),this.validate()}updatePrice(e,n=.05){if(super.updatePrice(e),e&&this.otherPrice.eq(0)){const s=this.side===wt.BUY?1+n*2:1-n*2,a=this.side===wt.BUY?1+n:1-n;this.otherPrice=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0),this.stopPrice=e.multipliedBy(a).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}updateOtherPrice(e,n=.05){if(this.otherPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1-n*2:1+n*2,a=this.side===wt.BUY?1-n:1+n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0),this.stopPrice=e.multipliedBy(a).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}updateStopPrice(e,n=.05){if(this.stopPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1-n:1+n,a=this.side===wt.BUY?1+n:1-n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0),this.otherPrice=e.multipliedBy(a).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}}return ee.BalanceLimit=vr,ee.CoinrayCache=u1,ee.CurrentMarket=l1,ee.DAYS=Li,ee.ExchangeFeatures=au,ee.HOURS=If,ee.IpWhiteList=ou,ee.LimitLadderOrder=v1,ee.LimitOrder=Zs,ee.MINUTES=xt,ee.MarginType=uu,ee.MarketOrder=S1,ee.OcoOrder=E1,ee.OrderSide=wt,ee.OrderStatus=cu,ee.OrderType=rn,ee.PriceScales=eh,ee.SizeScales=th,ee.StopLimitOrder=T1,ee.TimeInForce=lu,ee.WEEK=$s,ee.base64UrlDecode=Vs,ee.base64UrlEncode=Gs,ee.camelize=Zo,ee.candleTime=Qs,ee.checkArray=js,ee.checkBigNumber=at,ee.checkBoolean=Tn,ee.checkNull=Kf,ee.checkNumber=_t,ee.checkString=Ne,ee.correctNumberPrecision=En,ee.createJWT=Jo,ee.default=xe,ee.encryptPayload=Qo,ee.errorHelper=jt,ee.filterMarkets=jf,ee.getBucketStartDates=zf,ee.getTimeParams=Vf,ee.jwkToPublicKey=Yf,ee.jwtExpired=zs,ee.locales=f1,ee.parseJWT=Hf,ee.resolutionToBucketType=Gf,ee.resolutionToDuration=qf,ee.safeBigNumber=X,ee.safeFloat=Ni,ee.safeInteger=jn,ee.safeTime=ru,ee.sha256hexdigest=Wf,ee.signHMAC=jo,ee.strToArray=n1,ee.throwIsArray=tu,ee.throwNotObject=eu,ee.throwNull2NonNull=Xo,ee.toBucketEnd=$f,ee.toBucketStart=i1,ee.toSafeDate=Js,ee.types=m1,ee.unix=Ff,Object.defineProperties(ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),ee})({});
|
|
51
|
+
*/var h1=Ii.exports,Zf;function d1(){return Zf||(Zf=1,(function(t,e){(function(n,s,a){var c=function(l,h,m){m=u.extend({},u.options,m);var w=u.runValidations(l,h,m);if(w.some(function(T){return u.isPromise(T.error)}))throw new Error("Use validate.async if you want support for promises");return c.processValidationResults(w,m)},u=c;u.extend=function(l){return[].slice.call(arguments,1).forEach(function(h){for(var m in h)l[m]=h[m]}),l},u.extend(c,{version:{major:0,minor:13,patch:1,metadata:null,toString:function(){var l=u.format("%{major}.%{minor}.%{patch}",u.version);return u.isEmpty(u.version.metadata)||(l+="+"+u.version.metadata),l}},Promise:typeof Promise<"u"?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(l,h,m){var w=[],T,P,$,O,I,F,ne;(u.isDomElement(l)||u.isJqueryElement(l))&&(l=u.collectFormValues(l));for(T in h){$=u.getDeepObjectValue(l,T),O=u.result(h[T],$,l,T,m,h);for(P in O){if(I=u.validators[P],!I)throw ne=u.format("Unknown validator %{name}",{name:P}),new Error(ne);F=O[P],F=u.result(F,$,l,T,m,h),F&&w.push({attribute:T,value:$,validator:P,globalOptions:m,attributes:l,options:F,error:I.call(I,$,F,T,l,m)})}}return w},processValidationResults:function(l,h){l=u.pruneEmptyErrors(l,h),l=u.expandMultipleErrors(l,h),l=u.convertErrorMessages(l,h);var m=h.format||"grouped";if(typeof u.formatters[m]=="function")l=u.formatters[m](l);else throw new Error(u.format("Unknown format %{format}",h));return u.isEmpty(l)?void 0:l},async:function(l,h,m){m=u.extend({},u.async.options,m);var w=m.wrapErrors||function(P){return P};m.cleanAttributes!==!1&&(l=u.cleanAttributes(l,h));var T=u.runValidations(l,h,m);return new u.Promise(function(P,$){u.waitForResults(T).then(function(){var O=u.processValidationResults(T,m);O?$(new w(O,m,l,h)):P(l)},function(O){$(O)})})},single:function(l,h,m){return m=u.extend({},u.single.options,m,{format:"flat",fullMessages:!1}),u({single:l},{single:h},m)},waitForResults:function(l){return l.reduce(function(h,m){return u.isPromise(m.error)?h.then(function(){return m.error.then(function(w){m.error=w||null})}):h},new u.Promise(function(h){h()}))},result:function(l){var h=[].slice.call(arguments,1);return typeof l=="function"&&(l=l.apply(null,h)),l},isNumber:function(l){return typeof l=="number"&&!isNaN(l)},isFunction:function(l){return typeof l=="function"},isInteger:function(l){return u.isNumber(l)&&l%1===0},isBoolean:function(l){return typeof l=="boolean"},isObject:function(l){return l===Object(l)},isDate:function(l){return l instanceof Date},isDefined:function(l){return l!=null},isPromise:function(l){return!!l&&u.isFunction(l.then)},isJqueryElement:function(l){return l&&u.isString(l.jquery)},isDomElement:function(l){return!l||!l.querySelectorAll||!l.querySelector?!1:u.isObject(document)&&l===document?!0:typeof HTMLElement=="object"?l instanceof HTMLElement:l&&typeof l=="object"&&l!==null&&l.nodeType===1&&typeof l.nodeName=="string"},isEmpty:function(l){var h;if(!u.isDefined(l))return!0;if(u.isFunction(l))return!1;if(u.isString(l))return u.EMPTY_STRING_REGEXP.test(l);if(u.isArray(l))return l.length===0;if(u.isDate(l))return!1;if(u.isObject(l)){for(h in l)return!1;return!0}return!1},format:u.extend(function(l,h){return u.isString(l)?l.replace(u.format.FORMAT_REGEXP,function(m,w,T){return w==="%"?"%{"+T+"}":String(h[T])}):l},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(l){return u.isNumber(l)?l*100%1===0?""+l:parseFloat(Math.round(l*100)/100).toFixed(2):u.isArray(l)?l.map(function(h){return u.prettify(h)}).join(", "):u.isObject(l)?u.isDefined(l.toString)?l.toString():JSON.stringify(l):(l=""+l,l.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(h,m,w){return""+m+" "+w.toLowerCase()}).toLowerCase())},stringifyValue:function(l,h){var m=h&&h.prettify||u.prettify;return m(l)},isString:function(l){return typeof l=="string"},isArray:function(l){return{}.toString.call(l)==="[object Array]"},isHash:function(l){return u.isObject(l)&&!u.isArray(l)&&!u.isFunction(l)},contains:function(l,h){return u.isDefined(l)?u.isArray(l)?l.indexOf(h)!==-1:h in l:!1},unique:function(l){return u.isArray(l)?l.filter(function(h,m,w){return w.indexOf(h)==m}):l},forEachKeyInKeypath:function(l,h,m){if(u.isString(h)){var w="",T,P=!1;for(T=0;T<h.length;++T)switch(h[T]){case".":P?(P=!1,w+="."):(l=m(l,w,!1),w="");break;case"\\":P?(P=!1,w+="\\"):P=!0;break;default:P=!1,w+=h[T];break}return m(l,w,!0)}},getDeepObjectValue:function(l,h){if(u.isObject(l))return u.forEachKeyInKeypath(l,h,function(m,w){if(u.isObject(m))return m[w]})},collectFormValues:function(l,h){var m={},w,T,P,$,O,I;if(u.isJqueryElement(l)&&(l=l[0]),!l)return m;for(h=h||{},$=l.querySelectorAll("input[name], textarea[name]"),w=0;w<$.length;++w)if(P=$.item(w),!u.isDefined(P.getAttribute("data-ignored"))){var F=P.name.replace(/\./g,"\\\\.");I=u.sanitizeFormValue(P.value,h),P.type==="number"?I=I?+I:null:P.type==="checkbox"?P.attributes.value?P.checked||(I=m[F]||null):I=P.checked:P.type==="radio"&&(P.checked||(I=m[F]||null)),m[F]=I}for($=l.querySelectorAll("select[name]"),w=0;w<$.length;++w)if(P=$.item(w),!u.isDefined(P.getAttribute("data-ignored"))){if(P.multiple){I=[];for(T in P.options)O=P.options[T],O&&O.selected&&I.push(u.sanitizeFormValue(O.value,h))}else{var ne=typeof P.options[P.selectedIndex]<"u"?P.options[P.selectedIndex].value:"";I=u.sanitizeFormValue(ne,h)}m[P.name]=I}return m},sanitizeFormValue:function(l,h){return h.trim&&u.isString(l)&&(l=l.trim()),h.nullify!==!1&&l===""?null:l},capitalize:function(l){return u.isString(l)?l[0].toUpperCase()+l.slice(1):l},pruneEmptyErrors:function(l){return l.filter(function(h){return!u.isEmpty(h.error)})},expandMultipleErrors:function(l){var h=[];return l.forEach(function(m){u.isArray(m.error)?m.error.forEach(function(w){h.push(u.extend({},m,{error:w}))}):h.push(m)}),h},convertErrorMessages:function(l,h){h=h||{};var m=[],w=h.prettify||u.prettify;return l.forEach(function(T){var P=u.result(T.error,T.value,T.attribute,T.options,T.attributes,T.globalOptions);if(!u.isString(P)){m.push(T);return}P[0]==="^"?P=P.slice(1):h.fullMessages!==!1&&(P=u.capitalize(w(T.attribute))+" "+P),P=P.replace(/\\\^/g,"^"),P=u.format(P,{value:u.stringifyValue(T.value,h)}),m.push(u.extend({},T,{error:P}))}),m},groupErrorsByAttribute:function(l){var h={};return l.forEach(function(m){var w=h[m.attribute];w?w.push(m):h[m.attribute]=[m]}),h},flattenErrorsToArray:function(l){return l.map(function(h){return h.error}).filter(function(h,m,w){return w.indexOf(h)===m})},cleanAttributes:function(l,h){function m(P,$,O){return u.isObject(P[$])?P[$]:P[$]=O?!0:{}}function w(P){var $={},O;for(O in P)P[O]&&u.forEachKeyInKeypath($,O,m);return $}function T(P,$){if(!u.isObject(P))return P;var O=u.extend({},P),I,F;for(F in P)I=$[F],u.isObject(I)?O[F]=T(O[F],I):I||delete O[F];return O}return!u.isObject(h)||!u.isObject(l)?{}:(h=w(h),T(l,h))},exposeModule:function(l,h,m,w,T){m?(w&&w.exports&&(m=w.exports=l),m.validate=l):(h.validate=l,l.isFunction(T)&&T.amd&&T([],function(){return l}))},warn:function(l){typeof console<"u"&&console.warn&&console.warn("[validate.js] "+l)},error:function(l){typeof console<"u"&&console.error&&console.error("[validate.js] "+l)}}),c.validators={presence:function(l,h){if(h=u.extend({},this.options,h),h.allowEmpty!==!1?!u.isDefined(l):u.isEmpty(l))return h.message||this.message||"can't be blank"},length:function(l,h,m){if(u.isDefined(l)){h=u.extend({},this.options,h);var w=h.is,T=h.maximum,P=h.minimum,$=h.tokenizer||function(ne){return ne},O,I=[];l=$(l);var F=l.length;if(!u.isNumber(F))return h.message||this.notValid||"has an incorrect length";if(u.isNumber(w)&&F!==w&&(O=h.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",I.push(u.format(O,{count:w}))),u.isNumber(P)&&F<P&&(O=h.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",I.push(u.format(O,{count:P}))),u.isNumber(T)&&F>T&&(O=h.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",I.push(u.format(O,{count:T}))),I.length>0)return h.message||I}},numericality:function(l,h,m,w,T){if(u.isDefined(l)){h=u.extend({},this.options,h);var P=[],$,O,I={greaterThan:function(ve,_e){return ve>_e},greaterThanOrEqualTo:function(ve,_e){return ve>=_e},equalTo:function(ve,_e){return ve===_e},lessThan:function(ve,_e){return ve<_e},lessThanOrEqualTo:function(ve,_e){return ve<=_e},divisibleBy:function(ve,_e){return ve%_e===0}},F=h.prettify||T&&T.prettify||u.prettify;if(u.isString(l)&&h.strict){var ne="^-?(0|[1-9]\\d*)";if(h.onlyInteger||(ne+="(\\.\\d+)?"),ne+="$",!new RegExp(ne).test(l))return h.message||h.notValid||this.notValid||this.message||"must be a valid number"}if(h.noStrings!==!0&&u.isString(l)&&!u.isEmpty(l)&&(l=+l),!u.isNumber(l))return h.message||h.notValid||this.notValid||this.message||"is not a number";if(h.onlyInteger&&!u.isInteger(l))return h.message||h.notInteger||this.notInteger||this.message||"must be an integer";for($ in I)if(O=h[$],u.isNumber(O)&&!I[$](l,O)){var Y="not"+u.capitalize($),Ae=h[Y]||this[Y]||this.message||"must be %{type} %{count}";P.push(u.format(Ae,{count:O,type:F($)}))}if(h.odd&&l%2!==1&&P.push(h.notOdd||this.notOdd||this.message||"must be odd"),h.even&&l%2!==0&&P.push(h.notEven||this.notEven||this.message||"must be even"),P.length)return h.message||P}},datetime:u.extend(function(l,h){if(!u.isFunction(this.parse)||!u.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(u.isDefined(l)){h=u.extend({},this.options,h);var m,w=[],T=h.earliest?this.parse(h.earliest,h):NaN,P=h.latest?this.parse(h.latest,h):NaN;if(l=this.parse(l,h),isNaN(l)||h.dateOnly&&l%864e5!==0)return m=h.notValid||h.message||this.notValid||"must be a valid date",u.format(m,{value:arguments[0]});if(!isNaN(T)&&l<T&&(m=h.tooEarly||h.message||this.tooEarly||"must be no earlier than %{date}",m=u.format(m,{value:this.format(l,h),date:this.format(T,h)}),w.push(m)),!isNaN(P)&&l>P&&(m=h.tooLate||h.message||this.tooLate||"must be no later than %{date}",m=u.format(m,{date:this.format(P,h),value:this.format(l,h)}),w.push(m)),w.length)return u.unique(w)}},{parse:null,format:null}),date:function(l,h){return h=u.extend({},h,{dateOnly:!0}),u.validators.datetime.call(u.validators.datetime,l,h)},format:function(l,h){(u.isString(h)||h instanceof RegExp)&&(h={pattern:h}),h=u.extend({},this.options,h);var m=h.message||this.message||"is invalid",w=h.pattern,T;if(u.isDefined(l)&&(!u.isString(l)||(u.isString(w)&&(w=new RegExp(h.pattern,h.flags)),T=w.exec(l),!T||T[0].length!=l.length)))return m},inclusion:function(l,h){if(u.isDefined(l)&&(u.isArray(h)&&(h={within:h}),h=u.extend({},this.options,h),!u.contains(h.within,l))){var m=h.message||this.message||"^%{value} is not included in the list";return u.format(m,{value:l})}},exclusion:function(l,h){if(u.isDefined(l)&&(u.isArray(h)&&(h={within:h}),h=u.extend({},this.options,h),!!u.contains(h.within,l))){var m=h.message||this.message||"^%{value} is restricted";return u.isString(h.within[l])&&(l=h.within[l]),u.format(m,{value:l})}},email:u.extend(function(l,h){h=u.extend({},this.options,h);var m=h.message||this.message||"is not a valid email";if(u.isDefined(l)&&(!u.isString(l)||!this.PATTERN.exec(l)))return m},{PATTERN:/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i}),equality:function(l,h,m,w,T){if(u.isDefined(l)){u.isString(h)&&(h={attribute:h}),h=u.extend({},this.options,h);var P=h.message||this.message||"is not equal to %{attribute}";if(u.isEmpty(h.attribute)||!u.isString(h.attribute))throw new Error("The attribute must be a non empty string");var $=u.getDeepObjectValue(w,h.attribute),O=h.comparator||function(F,ne){return F===ne},I=h.prettify||T&&T.prettify||u.prettify;if(!O(l,$,h,m,w))return u.format(P,{attribute:I(h.attribute)})}},url:function(l,h){if(u.isDefined(l)){h=u.extend({},this.options,h);var m=h.message||this.message||"is not a valid url",w=h.schemes||this.schemes||["http","https"],T=h.allowLocal||this.allowLocal||!1,P=h.allowDataUrl||this.allowDataUrl||!1;if(!u.isString(l))return m;var $="^(?:(?:"+w.join("|")+")://)(?:\\S+(?::\\S*)?@)?(?:",O="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";if(T?O+="?":$+="(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",$+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*"+O+")(?::\\d{2,5})?(?:[/?#]\\S*)?$",P){var I="\\w+\\/[-+.\\w]+(?:;[\\w=]+)*",F="[A-Za-z0-9-_.!~\\*'();\\/?:@&=+$,%]*",ne="data:(?:"+I+")?(?:;base64)?,"+F;$="(?:"+$+")|(?:^"+ne+"$)"}var Y=new RegExp($,"i");if(!Y.exec(l))return m}},type:u.extend(function(l,h,m,w,T){if(u.isString(h)&&(h={type:h}),!!u.isDefined(l)){var P=u.extend({},this.options,h),$=P.type;if(!u.isDefined($))throw new Error("No type was specified");var O;if(u.isFunction($)?O=$:O=this.types[$],!u.isFunction(O))throw new Error("validate.validators.type.types."+$+" must be a function.");if(!O(l,P,m,w,T)){var I=h.message||this.messages[$]||this.message||P.message||(u.isFunction($)?"must be of the correct type":"must be of type %{type}");return u.isFunction(I)&&(I=I(l,h,m,w,T)),u.format(I,{attribute:u.prettify(m),type:$})}}},{types:{object:function(l){return u.isObject(l)&&!u.isArray(l)},array:u.isArray,integer:u.isInteger,number:u.isNumber,string:u.isString,date:u.isDate,boolean:u.isBoolean},messages:{}})},c.formatters={detailed:function(l){return l},flat:u.flattenErrorsToArray,grouped:function(l){var h;l=u.groupErrorsByAttribute(l);for(h in l)l[h]=u.flattenErrorsToArray(l[h]);return l},constraint:function(l){var h;l=u.groupErrorsByAttribute(l);for(h in l)l[h]=l[h].map(function(m){return m.validator}).sort();return l}},c.exposeModule(c,this,n,s,a)}).call(h1,e,t,null)})(Ii,Ii.exports)),Ii.exports}var p1=d1();const su=Sl(p1);su.validators.bigNumericality=(t,e,n,s)=>su.validators.numericality(t&&t.toNumber(),e,s);var rn=(t=>(t.MARKET="MARKET",t.LIMIT="LIMIT",t.LIMIT_LADDER="LIMIT_LADDER",t.STOP_LOSS="STOP_LOSS",t.OCO="OCO",t.STOP_LOSS_LIMIT="STOP_LOSS_LIMIT",t.STOP_LOSS_MARKET="STOP_LOSS_MARKET",t.TAKE_PROFIT="TAKE_PROFIT",t.TAKE_PROFIT_LIMIT="TAKE_PROFIT_LIMIT",t.TAKE_PROFIT_MARKET="TAKE_PROFIT_MARKET",t))(rn||{}),au=(t=>(t.HEDGE_MODE="hedgeMode",t.HEDGE_MODE_ONLY="hedgeModeOnly",t.ORDER_QUOTE_AMOUNT="orderQuoteAmount",t.MARKET_BUY_QUOTE_ONLY="marketBuyQuoteOnly",t.UPDATE_LEVERAGE_ONLY_ON_OPEN_POSITIONS="updateLeverageOnlyOnOpenPositions",t.IGNORE_LEVERAGE_ON_QUICK_SYNC="ignoreLeverageOnQuickSync",t.MULTIPLE_MARGIN_TYPE_POSITIONS="multipleMarginTypePositions",t.SET_LEVERAGE_NOT_AVAILABLE="setLeverageNotAvailable",t.SET_MARGIN_TYPE_NOT_AVAILABLE="setMarginTypeNotAvailable",t.FIXED_CROSSED_LEVERAGE="fixedCrossedLeverage",t.FAST_CONNECT="fastConnect",t.UNIFIED_BALANCE="unifiedBalance",t.NO_API_KEY_LINK="noApiKeyLink",t))(au||{}),ou=(t=>(t.NONE="NONE",t.LIST="LIST",t.COMMA="COMMA",t.COMMA_SPACE="COMMA_SPACE",t.SPACE="SPACE",t))(ou||{}),uu=(t=>(t.CROSSED="CROSSED",t.ISOLATED="ISOLATED",t))(uu||{}),cu=(t=>(t.OPEN="open",t.CLOSED="closed",t.CANCELED="canceled",t))(cu||{}),wt=(t=>(t.BUY="buy",t.SELL="sell",t))(wt||{}),lu=(t=>(t.GTC="gtc",t.FOK="fok",t.IOC="ioc",t))(lu||{}),vr=(t=>(t.QUOTE="quote",t.BASE="base",t.NONE="none",t))(vr||{});const m1=Object.freeze(Object.defineProperty({__proto__:null,BalanceLimit:vr,ExchangeFeatures:au,IpWhiteList:ou,MarginType:uu,OrderSide:wt,OrderStatus:cu,OrderType:rn,TimeInForce:lu},Symbol.toStringTag,{value:"Module"})),lt=[];for(let t=0;t<256;++t)lt.push((t+256).toString(16).slice(1));function g1(t,e=0){return(lt[t[e+0]]+lt[t[e+1]]+lt[t[e+2]]+lt[t[e+3]]+"-"+lt[t[e+4]]+lt[t[e+5]]+"-"+lt[t[e+6]]+lt[t[e+7]]+"-"+lt[t[e+8]]+lt[t[e+9]]+"-"+lt[t[e+10]]+lt[t[e+11]]+lt[t[e+12]]+lt[t[e+13]]+lt[t[e+14]]+lt[t[e+15]]).toLowerCase()}let fu;const y1=new Uint8Array(16);function _1(){if(!fu){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fu=crypto.getRandomValues.bind(crypto)}return fu(y1)}const Xf={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function w1(t,e,n){t=t||{};const s=t.random??t.rng?.()??_1();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,g1(s)}function b1(t,e,n){return Xf.randomUUID&&!t?Xf.randomUUID():w1(t)}class hu{id=b1();coinraySymbol;precisionBase;precisionQuote;precisionPrice;minBase;minQuote;makerFee;takerFee;balances;balanceLimit;side;errors;isValid;orderExternalId;reduceOnly;postOnly;timeInForce;constructor(e){this.coinraySymbol=e.coinraySymbol,this.precisionBase=jn(e.precisionBase),this.precisionQuote=jn(e.precisionQuote),this.precisionPrice=jn(e.precisionPrice),this.minBase=X(e.minBase),this.minQuote=X(e.minQuote),this.makerFee=X(e.makerFee),this.takerFee=X(e.takerFee),this.balances=e.balances,this.balanceLimit=e.balanceLimit||vr.NONE,this.side=e.side,this.orderExternalId=e.externalId,this.errors={},this.isValid=!0,this.reduceOnly=e.reduceOnly,this.postOnly=e.postOnly,this.timeInForce=e.timeInForce}startEdit(e){this.orderExternalId=e}updateLockedOn(e){}resetError(){this.errors={},this.isValid=!0}validate(){const e=su(this,this.constraints());return e?(this.errors=e,this.isValid=!1):this.resetError(),!e}}class Zs extends hu{baseAmount;quoteAmount;price;lockedOn;orderType=rn.LIMIT;constraints(){let e,n;return this.balanceLimit===vr.QUOTE?n=this.balances.quote||0:this.balanceLimit===vr.BASE&&(e=this.balances.base||0),{baseAmount:{bigNumericality:{greaterThanOrEqualTo:this.minBase.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionBase,this.minBase)})}`,lessThanOrEqualTo:e?e.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},quoteAmount:{bigNumericality:{greaterThanOrEqualTo:this.minQuote.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionQuote,this.minQuote)})}`,lessThanOrEqualTo:n?n.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},price:{bigNumericality:{greaterThan:0}}}}constructor(e,n=!0){super(e),this.price=X(e.price||"0"),this.lockedOn=e.lockedOn,this.baseAmount=X(e.baseAmount),this.quoteAmount=X(e.quoteAmount),n&&(this.quoteAmount.gt(0)&&this.lockedOn==="quoteAmount"?this.updateQuoteAmount(this.quoteAmount):this.updateBaseAmount(this.baseAmount))}updateBaseAmount(e){this.baseAmount=e,this.quoteAmount=this.price.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote>0?this.precisionQuote:0,Ze.ROUND_DOWN),this.validate()}updateQuoteAmount(e){this.quoteAmount=e,this.baseAmount=e.dividedBy(this.price).decimalPlaces(this.precisionBase>0?this.precisionBase:0,Ze.ROUND_DOWN),this.validate()}updateLockedOn(e){this.lockedOn=e,this.validate()}quoteFee(){return this.quoteAmount.multipliedBy(this.takerFee)}updatePrice(e){this.price=e.decimalPlaces(this.precisionPrice),this.lockedOn==="baseAmount"?this.updateBaseAmount(this.baseAmount):this.updateQuoteAmount(this.quoteAmount)}getOrders(){return[this]}}class S1 extends hu{baseAmount;quoteAmount;price;orderType=rn.MARKET;constraints=()=>{let e,n;return this.balanceLimit===vr.QUOTE?n=this.balances.quote||0:this.balanceLimit===vr.BASE&&(e=this.balances.base||0),{baseAmount:{bigNumericality:{greaterThanOrEqualTo:e?this.minBase.toNumber():void 0,notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionBase,this.minBase)})}`,lessThanOrEqualTo:e?e.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},quoteAmount:{bigNumericality:{greaterThanOrEqualTo:n?this.minQuote.toNumber():void 0,notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionQuote,this.minQuote)})}`,lessThanOrEqualTo:n?n.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}}}};constructor(e){super(e),this.updateQuoteAmount(e.quoteAmount),this.updateBaseAmount(e.baseAmount)}updateBaseAmount(e){this.baseAmount=e,e&&(this.quoteAmount=this.price.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote>0?this.precisionQuote:0,Ze.ROUND_DOWN)),this.validate()}updateQuoteAmount(e){this.quoteAmount=e,e&&(this.baseAmount=e.dividedBy(this.price).decimalPlaces(this.precisionBase>0?this.precisionBase:0,Ze.ROUND_DOWN)),this.validate()}updatePrice(e){this.price=e.decimalPlaces(this.precisionPrice)}getOrders(){return[this]}}var eh=(t=>(t.LINEAR="LINEAR",t.EXPONENTIAL="EXPONENTIAL",t.FIBONACCI="FIBONACCI",t.CUSTOM="CUSTOM",t))(eh||{}),th=(t=>(t.EQUAL="EQUAL",t.LINEAR="LINEAR",t.LINEAR_REVERSE="LINEAR_REVERSE",t.EXPONENTIAL="EXPONENTIAL",t.EXPONENTIAL_REVERSE="EXPONENTIAL_REVERSE",t.CUSTOM="CUSTOM",t))(th||{});const rh={LINEAR:t=>ct.times(t,e=>1/(t-1)*e),EXPONENTIAL:t=>{const e=2**(t-1);return ct.times(t,n=>n==0?0:2**n/e)},FIBONACCI:t=>[0,.09,.146,.236,.382,.5,.618,.788,.886].slice(0,t-1).concat([1]),CUSTOM:t=>[]},du=t=>{const e=ct.sum(t);return t.map(n=>n/e)},Xs={EQUAL:t=>{const e=ct.times(t,()=>1);return du(e)},LINEAR:t=>{const e=ct.times(t,n=>1/t*(n+1));return du(e)},EXPONENTIAL:t=>{const e=2**t-1,n=ct.times(t,s=>2**s/e);return du(n)},LINEAR_REVERSE:t=>Xs.LINEAR(t).reverse(),EXPONENTIAL_REVERSE:t=>Xs.EXPONENTIAL(t).reverse(),CUSTOM:t=>[]};class v1 extends hu{baseAmount;quoteAmount;price;lockedOn;otherPrice;numOrders;priceScale;sizeScale;priceScales;sizeScales;orderType=rn.LIMIT_LADDER;constraints(){let e,n;return this.balanceLimit===vr.QUOTE?n=this.balances.quote:this.balanceLimit===vr.BASE&&(e=this.balances.base),{baseAmount:{bigNumericality:{greaterThanOrEqualTo:this.minBase.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionBase,this.minBase)})}`,lessThanOrEqualTo:e?e.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},quoteAmount:{bigNumericality:{greaterThanOrEqualTo:this.minQuote.toNumber(),notGreaterThanOrEqualTo:`^${xe.I18n.t("validation.notGreaterThanOrEqualTo",{min:En(this.precisionQuote,this.minQuote)})}`,lessThanOrEqualTo:n?n.toNumber():void 0,notLessThanOrEqualTo:`^${xe.I18n.t("validation.insufficientFunds")}`}},price:{bigNumericality:{greaterThan:0}},otherPrice:{bigNumericality:{greaterThan:0}},numOrders:{numericality:{greaterThanOrEqualTo:2}}}}constructor(e){super(e),this.otherPrice=X(e.otherPrice),this.numOrders=jn(e.numOrders),this.priceScale=e.priceScale||"CUSTOM",this.sizeScale=e.sizeScale||"CUSTOM",this.price=X(e.price||"0"),this.lockedOn=e.lockedOn,this.baseAmount=X(e.baseAmount||"0"),this.quoteAmount=X(e.quoteAmount||"0"),this.priceScales=e.priceScales||rh[this.priceScale](this.numOrders),this.sizeScales=e.sizeScales||Xs[this.sizeScale](this.numOrders),this.quoteAmount.gt(0)&&this.lockedOn==="quoteAmount"?this.updateQuoteAmount(this.quoteAmount):this.updateBaseAmount(this.baseAmount)}updateNumOrders(e){this.numOrders=e}updatePrice(e,n=.05){if(this.price=e.decimalPlaces(this.precisionPrice),e&&this.otherPrice.eq(0)){const s=this.side===wt.BUY?1+n:1-n;this.otherPrice=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}this.recalculate()}updateOtherPrice(e,n=.05){if(this.otherPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1-n:1+n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}this.recalculate()}updatePriceScales(e){this.priceScales=e,this.priceScale="CUSTOM",this.recalculate()}updatePriceScale(e){this.priceScales=rh[e](this.numOrders),this.priceScale=e,this.recalculate()}updateSizeScales(e){this.sizeScales=e,this.sizeScale="CUSTOM",this.recalculate()}updateSizeScale(e){this.sizeScales=Xs[e](this.numOrders),this.sizeScale=e,this.recalculate()}updateLockedOn(e){this.lockedOn=e}recalculate(){this.lockedOn==="baseAmount"?this.updateBaseAmount(this.baseAmount):this.updateQuoteAmount(this.quoteAmount),this.validate()}updateQuoteAmount(e){this.quoteAmount=e,this.numOrders=Math.max(2,+this.numOrders);const n=this.getOrders("quoteAmount");n.length>0?this.baseAmount=ct.reduce(n,(s,a)=>s.plus(a.baseAmount),new Ze(0)):this.baseAmount=new Ze(0)}updateBaseAmount(e){this.baseAmount=e,this.numOrders=Math.max(2,+this.numOrders);const n=this.getOrders("baseAmount");n.length>0?this.quoteAmount=ct.reduce(n,(s,a)=>s.plus(a.quoteAmount),new Ze(0)):this.quoteAmount=new Ze(0)}getOrders(e=this.lockedOn){const n=e==="baseAmount"?this.baseAmount:this.quoteAmount,s=e==="baseAmount"?this.precisionBase:this.precisionQuote;if(!(this.priceScales&&this.priceScales.length>0&&this.sizeScales.length>0&&n.gt(0)))return[];const a=this.priceScales.slice(0,this.numOrders),c=this.sizeScales.slice(0,this.numOrders),u=this.otherPrice.minus(this.price);let l=n;return ct.times(this.numOrders,h=>{let m=n.multipliedBy(c[h]).decimalPlaces(s>0?s:0,Ze.ROUND_DOWN);return l=l.minus(m),h===this.numOrders-1&&(m=m.plus(l)),new Zs({...this,[e]:m,lockedOn:e,price:this.price.plus(u.multipliedBy(a[h])).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)})})}}class T1 extends Zs{stopPrice;orderType=rn.STOP_LOSS_LIMIT;constraints(){return{...super.constraints(),stopPrice:{bigNumericality:{greaterThan:0}}}}constructor(e){super(e),this.stopPrice=X(e.stopPrice)}updatePrice(e,n=.05){if(super.updatePrice(e),e&&this.stopPrice.eq(0)){const s=this.side===wt.BUY?1-n:1+n;this.stopPrice=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}updateStopPrice(e,n=.05){if(this.stopPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1+n:1-n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}}class E1 extends Zs{linkedOrderId;otherPrice;stopPrice;orderType=rn.OCO;constraints(){return{...super.constraints(),otherPrice:{bigNumericality:{greaterThan:0}},stopPrice:{bigNumericality:{greaterThan:0}}}}constructor(e){super(e,!1),this.otherPrice=X(e.otherPrice),this.stopPrice=X(e.stopPrice),this.quoteAmount.gt(0)&&this.lockedOn==="quoteAmount"?this.updateQuoteAmount(this.quoteAmount):this.updateBaseAmount(this.baseAmount)}updateQuoteAmount(e){this.quoteAmount=e;let n=this.side===wt.BUY?this.otherPrice:this.price;this.baseAmount=e.dividedBy(n).decimalPlaces(this.precisionBase>0?this.precisionBase:0,Ze.ROUND_DOWN),this.validate()}updateBaseAmount(e){this.baseAmount=e;let n=this.side===wt.BUY?this.otherPrice:this.price;this.quoteAmount=n.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote>0?this.precisionQuote:0,Ze.ROUND_DOWN),this.validate()}updatePrice(e,n=.05){if(super.updatePrice(e),e&&this.otherPrice.eq(0)){const s=this.side===wt.BUY?1+n*2:1-n*2,a=this.side===wt.BUY?1+n:1-n;this.otherPrice=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0),this.stopPrice=e.multipliedBy(a).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}updateOtherPrice(e,n=.05){if(this.otherPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1-n*2:1+n*2,a=this.side===wt.BUY?1-n:1+n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0),this.stopPrice=e.multipliedBy(a).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}updateStopPrice(e,n=.05){if(this.stopPrice=e.decimalPlaces(this.precisionPrice),e&&this.price.eq(0)){const s=this.side===wt.BUY?1-n:1+n,a=this.side===wt.BUY?1+n:1-n;this.price=e.multipliedBy(s).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0),this.otherPrice=e.multipliedBy(a).decimalPlaces(this.precisionPrice>0?this.precisionPrice:0)}}}return ee.BalanceLimit=vr,ee.CoinrayCache=u1,ee.CurrentMarket=l1,ee.DAYS=Li,ee.ExchangeFeatures=au,ee.HOURS=If,ee.IpWhiteList=ou,ee.LimitLadderOrder=v1,ee.LimitOrder=Zs,ee.MINUTES=xt,ee.MarginType=uu,ee.MarketOrder=S1,ee.OcoOrder=E1,ee.OrderSide=wt,ee.OrderStatus=cu,ee.OrderType=rn,ee.PriceScales=eh,ee.SizeScales=th,ee.StopLimitOrder=T1,ee.TimeInForce=lu,ee.WEEK=$s,ee.base64UrlDecode=Vs,ee.base64UrlEncode=Gs,ee.camelize=Zo,ee.candleTime=Qs,ee.checkArray=js,ee.checkBigNumber=at,ee.checkBoolean=Tn,ee.checkNull=Kf,ee.checkNumber=_t,ee.checkString=Ne,ee.correctNumberPrecision=En,ee.createJWT=Jo,ee.default=xe,ee.encryptPayload=Qo,ee.errorHelper=jt,ee.filterMarkets=jf,ee.getBucketStartDates=zf,ee.getTimeParams=Vf,ee.jwkToPublicKey=Yf,ee.jwtExpired=zs,ee.locales=f1,ee.parseJWT=Hf,ee.resolutionToBucketType=Gf,ee.resolutionToDuration=qf,ee.safeBigNumber=X,ee.safeFloat=Ni,ee.safeInteger=jn,ee.safeTime=ru,ee.sha256hexdigest=Wf,ee.signHMAC=jo,ee.strToArray=n1,ee.throwIsArray=tu,ee.throwNotObject=eu,ee.throwNull2NonNull=Xo,ee.toBucketEnd=$f,ee.toBucketStart=i1,ee.toSafeDate=Js,ee.types=m1,ee.unix=Ff,Object.defineProperties(ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),ee})({});
|
|
52
52
|
//# sourceMappingURL=coinrayjs.js.map
|