"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[48834],{988124:(e,t,s)=>{var n=s(414879),r=s(783433).tzData;let i;function o(e){this._name=e;var t=r[e];if(t||(t={time:[],offset:[]},this._invalid=!0),t.time.length!==t.offset.length&&(t={time:[],offset:[]},this._invalid=!0),!t.time_utc){for(var s=t.time,n=t.offset,i=s.length,o=new Array(i),a=0;at){if((r=i-1)0&&e-t[n-1]<=r)return r;return 0},o.prototype.is_valid=function(){return!this._invalid},o._offset=function(e,t,s){var n=a(e,s);return-1===n?0:t[n]};var _=function(e){return 0|e},d=function(e){return 60*e*1e3},h=function(e,t){return c(e)-c(t)},c=function(e){return e<0?_(e/1e3)-(e%1e3!=0?1:0):_(e/1e3)};function u(e){return e%4==0&&(e%100!=0||e%400==0)}var f={0:0,1:31,2:59,3:90,4:120,5:151,6:181,7:212,8:243,9:273,10:304,11:334},l={...n.WeekDays,...n.Months,YEAR:1,MONTH:2,WEEK_OF_YEAR:3,DAY_OF_MONTH:5,DAY_OF_YEAR:6,DAY_OF_WEEK:7,HOUR_OF_DAY:11,MINUTE:12,SECOND:13,minutesPerDay:1440,millisecondsPerDay:d(1440),get_minutes_from_hhmm:function(e){return-1!==e.indexOf(":")&&(e=e.split(":").join("")),e%100+60*_(e/100)},get_year:function(e){return e.getUTCFullYear()},get_month:function(e){return e.getUTCMonth()},get_hours:function(e){return e.getUTCHours()},get_minutes:function(e){return e.getUTCMinutes()},get_seconds:function(e){return e.getUTCSeconds()},get_day_of_month:function(e){return e.getUTCDate()},get_day_of_week:function(e){return e.getUTCDay()+1},get_day_of_year:function(e){var t=e.getUTCMonth(),s=f[t];return t>l.JANUARY+1&&u(e.getUTCFullYear())&&(s+=1),s+e.getUTCDate()},get_week_of_year:function(e){var t=new Date(Date.UTC(e.getUTCFullYear(),0,1)).getUTCDay(),s=0===t?1:8-t,n=l.get_day_of_year(e)-s;return Math.ceil(n/7)+1},get_minutes_from_midnight:function(e){return 60*l.get_hours(e)+l.get_minutes(e)},set_hms:function(e,t,s,n,r,i){e.setUTCHours(t),e.setUTCMinutes(s),e.setUTCSeconds(n),e.setUTCMilliseconds(r),void 0!==i&&l.correct_time(e,i)},correct_time:function(e,t){var s=e.getTime(),n=t.correction_loc(s);e.setTime(s+n)},add_days_considering_dst:function(e,t,s){var n=e.offset_utc(t),r=this.clone(t);this.add_date(r,s);var i=e.offset_utc(r);return r.setTime(r.getTime()+n-i),r},add_years_considering_dst:function(e,t,s){let n=t;for(let t=Math.abs(s);t>0;t--)n=this.add_days_considering_dst(e,n,this.get_days_per_year(n)*Math.sign(s));return n},add_date:function(e,t){e.setTime(e.getTime()+t*l.millisecondsPerDay)},add_minutes:function(e,t){ e.setTime(e.getTime()+d(t))},clone:function(e){return new Date(e.getTime())},get_days_per_year:function(e){var t=e.getUTCFullYear();return this.days_per_year(t)},days_per_year:function(e){return u(e)?366:365},get_days_in_month:function(e,t){let s;switch(e){case 0:case 2:case 4:case 6:case 7:case 9:case 11:s=31;break;case 1:s=28,u(t)&&s++;break;default:s=30}return s},get_part:function(e,t){switch(t){case l.YEAR:return l.get_year(e);case l.MONTH:return l.get_month(e);case l.DAY_OF_MONTH:return l.get_day_of_month(e);case l.WEEK_OF_YEAR:return l.get_week_of_year(e);case l.DAY_OF_WEEK:return l.get_day_of_week(e);case l.HOUR_OF_DAY:return l.get_hours(e);case l.MINUTE:return l.get_minutes(e);case l.DAY_OF_YEAR:return l.get_day_of_year(e);case l.SECOND:return l.get_seconds(e);default:return e.getTime()}},time_minutes:d,time_seconds:function(e){return 1e3*e},time_minutes_diff:function(e,t){return _(h(e,t)/60)},time_seconds_diff:h,utc_to_cal:function(e,t){return new Date(l.utc_to_cal_ts(e,t))},utc_to_cal_ts:function(e,t){return t+e.offset_utc(t)},get_cal:function(e,t,s,n,r,i,o){var a=new Date(Date.UTC(t,s,n,r||0,i||0,o||0)),_=e.offset_utc(+a);return new Date(a.valueOf()-_)},get_cal_from_unix_timestamp_ms:function(e,t){return new Date(t+e.offset_utc(t))},get_cal_utc:function(e,t,s){return new Date(Date.UTC(e,t,s))},cal_to_utc:function(e,t){var s=t.getTime();return s-e.offset_loc(s)},get_timezone:function(e){return new o(e)},shift_day:function(e,t){var s=e-1;return(s+=t)>6?s%=7:s<0&&(s=(7+s%7)%7),s+1},setCustomTimezones:function(e){i=e}};e.exports=l},547944:(e,t,s)=>{s.d(t,{SessionInfo:()=>o.SessionInfo,getPeriodsBetweenDates:()=>E,newBarBuilder:()=>p});var n=s(988124),r=s(223699),i=s(678515),o=s(995310),a=s(987571);class _ extends o.BarBuilderBase{constructor(e,t){super(),this._sessionStartMs=-Number.MAX_VALUE,this._sessionEndMs=-Number.MAX_VALUE,this._periodSec=e,this._session=t}alignTimeIfPossible(e){const t=this.alignTime(e);return isNaN(t)?e:t}indexOfBar(e){return e=this._sessionEndMs?a.SessionStage.POST_SESSION:(0,i.toInt)(n.time_seconds_diff(e,this._sessionStartMs)/this._periodSec)}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=n.get_cal_from_unix_timestamp_ms(this._session.timezone,this._sessionStartMs-1),t=this._session.spec.alignToNearestSessionEnd(e,-1);return n.cal_to_utc(this._session.timezone,t)}if(e===a.SessionStage.POST_SESSION)return this._sessionEndMs;if(e<0)throw new Error("Negative offset is not supported");return this._sessionStartMs+n.time_seconds(this._periodSec*e)}endOfBar(e){if(e<0)throw new Error("Index cannot be negative");const t=this.startOfBar(e)+1e3*this._periodSec;return t>this._sessionEndMs?this._sessionEndMs:t}isLastBar(e,t){return t>=this._sessionStartMs+n.time_seconds(this._periodSec*(e+1)-1)}moveTo(e){const t=this._session.timezone,s=n.utc_to_cal(t,e),r=this._session.spec.alignToSessionStart(s);this._sessionStartMs=n.cal_to_utc(t,s),n.add_minutes(s,r),this._sessionEndMs=n.cal_to_utc(t,s)}indexOfLastBarInSession(){return(0, i.toInt)((this._sessionEndMs-1-this._sessionStartMs)/1e3/this._periodSec)}moveNext(){this.moveTo(this._sessionEndMs)}}var d=s(476172);function h(e,t){const s=n.clone(t),r=e.businessDaysToCalendarDays(s,1);r>1&&n.add_date(s,r-1);const i=e.leftBorderOfDailyBar(s);if(null===i)throw new Error("Cannot calculate left border of daily bar");return n.cal_to_utc(n.get_timezone(e.timezone()),i)}class c extends o.BarBuilderBase{constructor(e,t,s,n,r=!1){super(),this._periodStart=-Number.MAX_VALUE,this._periodEnd=-Number.MAX_VALUE,this._periodLastBarStart=-Number.MAX_VALUE,this._periodStartDay=new d.BusinessDay(0,0,0),this._periodEndDay=new d.BusinessDay(0,0,0),this._period=s,this._sessionTgt=e,this._builder=n,this._useBusinessDays=r,this._sessionSrc=r?new o.SessionInfo("Etc/UTC","24x7"):t||e}builder(){return this._builder}alignTimeIfPossible(e){return this.tradingDayToSessionStart(e)}tradingDayToSessionStart(e){return this.moveTo(e),this.startOfBar(0)}indexOfBar(e){if(this._useBusinessDays){const t=d.BusinessDay.fromCalendar(n.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e));return t.before(this._periodStartDay)?a.SessionStage.PRE_SESSION:this._periodEndDay.before(t)?a.SessionStage.POST_SESSION:0}return e=this._periodEnd?a.SessionStage.POST_SESSION:0}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=n.get_cal_from_unix_timestamp_ms(this._sessionTgt.timezone,this._periodStart-1),t=this._sessionTgt.spec.alignToNearestSessionEnd(e,-1);return n.cal_to_utc(this._sessionTgt.timezone,t)-1}return e===a.SessionStage.POST_SESSION||e>0?this._periodEnd:e===a.SessionStage.LASTBAR_SESSION?this._periodLastBarStart:this._periodStart}moveTo(e){const t=n.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e);this._sessionSrc.spec.correctTradingDay(t);const s=n.get_year(t),r=this._indexOfPeriodInYear(t),i=r+this._period,o=this._sessionTgt.spec,a=this._sessionTgt.timezone,_=this._builder.startOfPeriod(a,r,s);this._periodStart=h(o,_);const c=n.clone(_),u=o.businessDaysToCalendarDays(c,1);u>1&&n.add_date(c,u-1),this._periodStartDay=d.BusinessDay.fromCalendar(c);const f=this._builder.startOfPeriod(a,i,s);this._periodEnd=h(o,f);const l=n.clone(f);for(n.add_date(l,-1);o.isCalWeekEnd(l);)n.add_date(l,-1);this._periodEndDay=d.BusinessDay.fromCalendar(l),n.add_date(f,-1),function(e,t){for(;e.isCalWeekEnd(t);)n.add_date(t,-1)}(this._sessionTgt.spec,f),this._periodLastBarStart=h(o,f),(this._periodLastBarStart=this._periodLastBarStart}currentRange(){return{from:this._periodStartDay,to:this._periodEndDay}}indexOfBarInYear(e){const t=n.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e),s=n.get_year(t),r=this._builder.indexOfPeriod(t),o=this._sessionTgt.timezone ;let a=this._builder.startOfPeriod(o,r,s),_=h(this._sessionTgt.spec,a);return a=n.get_cal_from_unix_timestamp_ms(n.get_timezone("Etc/UTC"),_),s=0&&(r-=7),(0,i.toInt)((r+s)/7))}class l{indexOfPeriod(e){return n.get_day_of_year(e)-1}startOfPeriod(e,t,s){const r=n.days_per_year(s);return n.get_cal(n.get_timezone("Etc/UTC"),s,n.JANUARY,1+Math.min(t,r))}}class g extends l{constructor(e){super(),this._sessionsSpec=e}indexOfPeriod(e){return super.indexOfPeriod(e)-function(e,t){const s=f(e,t),r=n.get_cal(n.get_timezone("Etc/UTC"),n.get_year(t),n.JANUARY,1);n.add_date(r,7*s);const i=s*e.weekEndsCount()+e.holidaysFromYearStart(r),o=n.get_day_of_year(t)-n.get_day_of_year(r);return i+o-e.calendarDaysToBusinessDays(r,o)}(this._sessionsSpec,e)}startOfPeriod(e,t,s){const r=7-this._sessionsSpec.weekEndsCount(),o=Math.max(0,(0,i.toInt)(t/r)-1),a=n.get_cal(n.get_timezone("Etc/UTC"),s,n.JANUARY,1),_=n.get_days_per_year(a);if(n.add_date(a,7*o),(t-=r*o-this._sessionsSpec.holidaysFromYearStart(a))>0){const e=this._sessionsSpec.businessDaysToCalendarDays(a,t);n.add_date(a,e)}let d=n.get_day_of_year(a)-1;return sn.get_days_per_year(r)?this.startOfPeriod(e,0,s+1):(n.add_date(r,a),r)}}class S{indexOfPeriod(e){return n.get_month(e)}startOfPeriod(e,t,s){if(t<0){const e=(0,i.toInt)((11-t)/12);s-=e,t+=12*e}else t>n.DECEMBER&&(s++,t=n.JANUARY);return n.get_cal(n.get_timezone("Etc/UTC"),s,t,1)}}function p(e,t,s,n=!1){const i=r.Interval.parse(e),o=i.multiplier();return i.isMinutes()?new _(60*o,t):i.isSeconds()?new _(o,t):i.isTicks()?new _(1,t):i.isRange()?new _(60*o,t):new c(t,s,o,function(e,t){switch(e){ case r.ResolutionKind.Days:return new y(t);case r.ResolutionKind.Weeks:return new m(t);case r.ResolutionKind.Months:return new S}throw new Error(`Unknown dwm resolution: ${e}`)}(i.kind(),t),n)}function E(e,t,s,n,i,a,_){const d=r.Interval.parse(i+n);if(d.isMonths()){const e=new Date(a),t=new Date(_);let s=12*(t.getUTCFullYear()-e.getUTCFullYear());return s+=t.getUTCMonth()-e.getUTCMonth(),Math.ceil(s/d.multiplier())}const h=new o.SessionInfo("Etc/UTC",e,t,s),c=d.inMilliseconds();let u;u=d.isDWM()?864e5:60*h.spec.maxTradingDayLength()*1e3;let f=0;f=d.isWeeks()?7:7-h.spec.weekEndsCount();const l=_-a,g=u/c,y=f*g;let m=l/864e5*g;m>=y&&(m=l/6048e5*y);return m%1<=Number.EPSILON*Math.ceil(m)?Math.round(m):Math.ceil(m)}},476172:(e,t,s)=>{s.d(t,{BusinessDay:()=>r});var n=s(988124);class r{constructor(e,t,s){this.year=e,this.month=t,this.day=s}toString(){return`${this.year}-${this.month}-${this.day}`}compareTo(e){return this.year>e.year||this.year===e.year&&this.month>e.month||this.year===e.year&&this.month===e.month&&this.day>e.day?1:this.year===e.year&&this.month===e.month&&this.day===e.day?0:-1}before(e){return-1===this.compareTo(e)}toCalendar(e){return n.get_cal(n.get_timezone("Etc/UTC"),this.year,this.month-1,this.day)}addDays(e){const t=this.toCalendar(n.get_timezone("Etc/UTC"));return n.add_date(t,e),r.fromCalendar(t)}static fromCalendar(e){return new r(n.get_year(e),n.get_month(e)+1,n.get_day_of_month(e))}}},44031:(e,t,s)=>{s.d(t,{SessionSpec:()=>S});var n=s(988124),r=s(674981),i=s(476172);function o(e,t){return e.compareTo(t)}class a{constructor(e,t,s){this._dayOfWeek=e,this._start=t,this._length=s}start(){return this._start+n.minutesPerDay*this.sessionStartDaysOffset()}startOffset(){return this._start}sessionStartDaysOffset(){return this._start>=0?0:this._start%n.minutesPerDay==0?-Math.ceil(this._start/n.minutesPerDay):-Math.floor(this._start/n.minutesPerDay)}sessionEndDaysOffset(){const e=this._start+this._length;return e>=0?0:e%n.minutesPerDay==0?-Math.ceil(e/n.minutesPerDay):-Math.floor(e/n.minutesPerDay)}isOvernight(){return this._start<0}dayOfWeek(){return this._dayOfWeek}sessionStartDayOfWeek(){let e=this._dayOfWeek-this.sessionStartDaysOffset();return en.SATURDAY&&(e=1),e}length(){return this._length}weight(){return this._dayOfWeek*n.minutesPerDay+this._start}compareTo(e){const t=this.weight(),s=t+this._length,n=e.weight(),r=n+e._length;return t<=n&&nn?1:-1}contains(e){const t=60*n.get_hours(e)+n.get_minutes(e);let s=n.get_day_of_week(e)-this._dayOfWeek;s>0&&(s-=7);const r=s*n.minutesPerDay+t;return r>=this._start&&r=48&&e<=57}class l{constructor(){this.entries=[],this.firstDayOfWeek=n.MONDAY,this.weekEndsCount=-1,this.maxTradingDayLength=0}parseSessions(e,t){var s;let n=!1;this._clear(),this.timezone=e;const{hasErrors:r,spec:i}=this._parseFirstDayOfWeek(t);if("24x7"===i.toLowerCase())for(const e of c)this.entries.push(l._createSessionEntry(e,0,0,0,0));else{let e=!1;const t=new Map;for(const s of i.split("|")){const r=s.split(":");if(1!==r.length&&2!==r.length){n=!0,u.logError(`Bad session section: ${s}`);continue}const i=1===r.length;if(i){if(e){n=!0,u.logError(`Duplicated default section: ${s}`);continue}e=!0}const o=i?h:l._parseWorkingDays(r[1]);for(const e of o)i&&t.has(e)||t.set(e,r[0])}for(const e of c){const s=t.get(e);if(void 0!==s)for(const t of s.split(",")){const{hasErrors:s,sessionEntry:r}=l._parseSessionEntry(e,t);s&&(n=s),this.entries.push(r)}}}this.entries.sort(o);const a=new Map;for(const e of this.entries){const t=e.dayOfWeek();a.set(t,e.length()+(null!==(s=a.get(t))&&void 0!==s?s:0))}return this.maxTradingDayLength=0,a.forEach((e=>{this.maxTradingDayLength=Math.max(this.maxTradingDayLength,e)})),this.weekEndsCount=7-a.size,n||r}static parseHolidaysAndCorrections(e,t,s){const r=new Map,i=new Map,o=e=>{const t=this._parseDay(e),s=t.toString(),n=i.get(s);return void 0!==n?n:(i.set(s,t),t)};if(""!==t){const e=[];for(const s of t.split(",")){if(8!==s.length)throw new Error(`bad holiday date: ${s}`);const t=o(s);r.set(t,e)}}if(""===s)return r;const _=n.get_timezone("Etc/UTC");for(const e of s.split(";")){const t=e.split(":");if(2!==t.length)throw new Error(`bad correction section: ${e}`);const s=[];if("dayoff"!==t[0])for(const e of t[0].split(","))s.push(this._parseSessionEntry(1,e).sessionEntry);for(const e of t[1].split(",")){if(8!==e.length)throw new Error(`bad correction date: ${e}`);const t=o(e),i=n.get_day_of_week(n.get_cal(_,t.year,t.month-1,t.day)),d=[];for(const e of s)d.push(new a(i,e.startOffset(),e.length()));r.set(t,d)}}return r}_clear(){this.entries=[],this.timezone="",this.firstDayOfWeek=n.MONDAY,this.weekEndsCount=-1}_parseFirstDayOfWeek(e){const t=e.split(";");if(t.length>2)return u.logError(`Only one \`first day\` specification expected @ session ${e}`),{hasErrors:!0,spec:e};if(1===t.length)return{hasErrors:!1,spec:e};let s=1;let r=t[0].indexOf("-")>=0?NaN:parseInt(t[0]);return isNaN(r)&&(s=0,r=parseInt(t[1])),rn.SATURDAY?(u.logError(`Unexpected day index @ session: ${e}; day index ${r}`),{hasErrors:!0,spec:e}):(this.firstDayOfWeek=r,{hasErrors:!1,spec:t[s]})}static _parseDay(e){const t=parseInt(e.substring(0,4)),s=parseInt(e.substring(4,6)),n=parseInt(e.substring(6,8));return new i.BusinessDay(t,s,n)}static _parseSessionEntry(e,t){let s=!1,n=t.split("-");2!==n.length&&(s=!0,u.logError(`Bad sessions entry: ${t}`),n=["0000","0000"]);let r=0,i=n[0];if(i.includes("F")){const e=i.split("F");i=e[0],r=""!==e[1]?parseInt(e[1]):1}let o=0,a=n[1];if(a.includes("F")){const e=a.split("F");a=e[0],o=""!==e[1]?parseInt(e[1]):1} if(!this._isCorrectSession(i)||!this._isCorrectSession(a))throw new Error(`Incorrect entry syntax: ${t}`);const _=i,d=a;return{hasErrors:s,sessionEntry:this._createSessionEntry(e,l._minutesFromHHMM(_),l._minutesFromHHMM(d),r,o)}}static _isCorrectSession(e){return 4===e.length&&f(e.charCodeAt(0))&&f(e.charCodeAt(1))&&f(e.charCodeAt(2))&&f(e.charCodeAt(3))}static _parseWorkingDays(e){const t=[];for(let s=0;s0&&(t-=r*n.minutesPerDay),i>0&&(s-=i*n.minutesPerDay);return new a(e,t,s-t)}}function g(e,t){return e.compareTo(t)<0}function y(e,t){const s=(0,r.lowerbound)(e,t,((e,t)=>-1===e.day.compareTo(t)));return s===e.length?null:e[s]}const m=621672192e5;class S{constructor(e="Etc/UTC",t="0000-0000",s="",r=""){this._entries=[],this._firstDayOfWeek=n.MONDAY,this._entriesHash=new Map,this._holidayAndCorrectionMap=new Map,this._holidaySessions=[],t=function(e){const t=e.lastIndexOf("/");return-1===t?e:e.slice(t+1)}(t);const i=new l;i.parseSessions(e,t),this._entries=i.entries,this._timezone=i.timezone,this._spec=t,this._firstDayOfWeek=i.firstDayOfWeek,this._weekEndsCount=i.weekEndsCount,this._maxTradingDayLength=i.maxTradingDayLength;const o=l.parseHolidaysAndCorrections(e,s,r),a=n.get_timezone(e);this._isThereCorrections=""!==s||""!==r,o.forEach(((e,t)=>{this._holidayAndCorrectionMap.set(t.toString(),e),this._holidaySessions.push({day:t,sessions:e});const s=this.getWeekIndex(t.toCalendar(a));this._entriesHash.set(s,null)})),this._holidaySessions.sort(((e,t)=>e.day.compareTo(t.day)))}entries(){return this._entries}timezone(){return this._timezone}spec(){return this._spec}firstDayOfWeek(){return this._firstDayOfWeek}addSessionEntry(e,t,s,r,i){0===s&&(s=n.minutesPerDay),r===i&&s<=t&&(r+=1),r>0&&(t-=r*n.minutesPerDay),i>0&&(s-=i*n.minutesPerDay);const o=s-t;this._entries.push(new a(e,t,o))}longestSessionLength(){let e=0,t=0;for(const t of this._holidaySessions)t.sessions.forEach((t=>{e=Math.max(e,t.length())}));return this._entries.forEach((e=>{t=Math.max(t,e.length())})),Math.max(e,t)}isWeekEnd(e){const t=(0,r.lowerbound)(this._entries,new a(e,0,0),((e,t)=>e.dayOfWeek()this._entries.length-1||this._entries[t].dayOfWeek()!==e}isCalWeekEnd(e){const t=n.get_day_of_week(e);if(!this._isThereCorrections)return this.isWeekEnd(t);const s=i.BusinessDay.fromCalendar(e),r=this._holidayAndCorrectionMap.get(s.toString());return void 0===r?this.isWeekEnd(t):0===r.length}hasWeekEnds(){return this.weekEndsCount()>0}weekEndsCount(){return this._weekEndsCount}maxTradingDayLength(){return this._maxTradingDayLength}holidaysFromYearStart(e){if(!this._isThereCorrections)return 0;const t=n.get_timezone(this._timezone),s=new i.BusinessDay(n.get_year(e),n.JANUARY,1),r=i.BusinessDay.fromCalendar(e);let o=0;const a=this._selectHolidays(s,r);for(let e=0;et.start()%e==0&&t.length()%e==0))}indexOfSession(e,t,s){const i=this._getEntriesForWeek(e);let o=(0,r.lowerbound)(i,new a(t,s,0),g);if(o!==i.length)return new _(e,o,i);let d=e;const h=7-t+this._firstDayOfWeek-1;for(s=-(n.minutesPerDay-s+h*n.minutesPerDay);;){d++;const e=this._getEntriesForWeek(d);if(0!==e.length)return o=(0,r.lowerbound)(e,new a(this._firstDayOfWeek,s,0),g),new _(d,o,e)}}findSession(e,t,s,n=0){const r=this.indexOfSession(e,t,s),i=r.entries;let o=r.entryIndex;if(0!==n){const e=i[o].dayOfWeek(),t=n>0?1:-1;for(;;){const s=o+t;if(s<0||s>=i.length||i[s].dayOfWeek()!==e)break;o=s}}return new _(r.weekIndex,o,i)}getWeekIndex(e){if(!this._isThereCorrections)return 0;const t=n.get_day_of_week(e)-n.SUNDAY,s=n.get_timezone("Etc/UTC"),r=n.get_cal(s,n.get_year(e),n.get_month(e),n.get_day_of_month(e)-t);return Math.floor((r.getTime()+m)/1e3/86400/7)}correctTradingDay(e){const t=n.get_day_of_week(e),s=60*n.get_hours(e)+n.get_minutes(e),r=this.getWeekIndex(e),i=this.findSession(r,t,s,0),o=i.getEntry().dayOfWeek()-t+7*(i.weekIndex-r);return 0!==o&&n.add_date(e,o),e}alignToSessionStart(e,t=0){const s=n.get_day_of_week(e),r=60*n.get_hours(e)+n.get_minutes(e),i=this.getWeekIndex(e),o=this.findSession(i,s,r,t),a=o.getEntry(),_=a.dayOfWeek()-s+7*(o.weekIndex-i);0!==_&&n.add_date(e,_);const d=a.startOffset();return n.set_hms(e,d/60,d%60,0,0,n.get_timezone(this._timezone)),a.length()}businessDaysToCalendarDays(e,t){let s=this.getWeekIndex(e),r=n.get_day_of_week(e),i=0,o=0;for(;os);)e[a].dayOfWeek()=t)return i}s++,r=n.SUNDAY}return i}calendarDaysToBusinessDays(e,t){let s=this.getWeekIndex(e),r=n.get_day_of_week(e),i=0,o=0;for(;is);)e[a].dayOfWeek()=t)return o}s++,r=n.SUNDAY}return o}alignToNearestSessionStart(e,t){return this._alignToNearestSessionValue(e,t,this._entrySessionStart.bind(this))}alignToNearestSessionEnd(e,t){return this._alignToNearestSessionValue(e,t,this._entrySessionEnd.bind(this))}leftBorderOfDailyBar(e){const t=this._getEntriesForDay(e);return 0===t.length?null:(t.sort(o),this._getLeftEntryBorder(e,t[0]))}bordersOfDailyBar(e){const t=this._getEntriesForDay(e);if(0===t.length)return null;t.sort(o);const s=this._getLeftEntryBorder(e,t[0]),r=t[t.length-1],i=n.clone(e);let a=60*(r.startOffset()+r.length())-1;const _=Math.floor(a/3600);return a-=3600*_,n.set_hms(i,_,a/60,a%60,0,n.get_timezone(this._timezone)),{from:s,to:i}}getEntriesForWeekByCalendar(e){const t=this.getWeekIndex(e);return this._getEntriesForWeek(t)}_getEntriesForWeek(e){let t=this._entriesHash.get(e);if(void 0===t)return this._entries;if(null!==t)return t ;const s=n.get_timezone(this._timezone);t=this._entries.slice();const r=this._weekIndexToCalendar(e),a=this._weekIndexToCalendar(e+1),_=i.BusinessDay.fromCalendar(r),d=i.BusinessDay.fromCalendar(a),h=this._selectHolidays(_,d);for(const e of h){const r=e.day.toCalendar(s),i=n.get_day_of_week(r);t=t.filter((e=>e.dayOfWeek()!==i)),t=t.concat(e.sessions)}return t.sort(o),this._entriesHash.set(e,t),t}_selectHolidays(e,t){const s=[];let n=e;for(;;){const e=y(this._holidaySessions,n);if(null===e)return s;if(!e.day.before(t))return s;s.push(e),n=e.day.addDays(1)}}_weekIndexToCalendar(e){const t=1e3*(86400*e*7+86400)-m,s=n.get_cal_from_unix_timestamp_ms(n.get_timezone("Etc/UTC"),t),r=n.get_timezone("Etc/UTC");return n.get_cal(r,n.get_year(s),n.get_month(s),n.get_day_of_month(s))}_alignToNearestSessionValue(e,t,s){const r=n.get_day_of_week(e),i=60*n.get_hours(e)+n.get_minutes(e),o=this.getWeekIndex(e);let a=this.findSession(o,r,i);if(a.getEntry().contains(e)&&o===a.weekIndex||1===t)return s(a,n.clone(e),t);const d=a.getEntry(),h=d.contains(e),c=o===a.weekIndex,u=d.sessionStartDaysOffset()-d.dayOfWeek()>=0;if(h&&(c||u))return s(a,n.clone(e),t);let f=a.entryIndex-1;if(f<0){let e=a.weekIndex,t=a.entries;for(;f<0;)e--,t=this._getEntriesForWeek(e),f+=t.length;a=new _(e,f,t)}else a=new _(a.weekIndex,f,a.entries);return s(a,n.clone(e),t)}_entrySessionStart(e,t,s){return this._entrySessionValue(e,t,s,(e=>60*e.start()))}_entrySessionEnd(e,t,s){return this._entrySessionValue(e,t,s,(e=>60*(e.start()+e.length())-1))}_entrySessionValue(e,t,s,r){let i=n.get_day_of_week(t);const o=e.getEntry();let a=o.dayOfWeek()-o.sessionStartDaysOffset();const _=this.getWeekIndex(t);let d=e.weekIndex-_,h=!1;if(a0&&s>=0||d<0&&s<0)&&n.add_date(t,7*d),!o.contains(t)){let e=a-i;h&&s<0&&(e=-(7-a+i)),n.add_date(t,e),i=n.get_day_of_week(t)}o.isOvernight()&&i===o.dayOfWeek()&&n.add_date(t,-o.sessionStartDaysOffset());let c=r(o);const u=Math.floor(c/3600);return c-=3600*u,n.set_hms(t,u,c/60,c%60,0,n.get_timezone(this._timezone)),t}_getEntriesForDay(e){const t=n.get_day_of_week(e);return this._getEntriesForWeek(this.getWeekIndex(e)).filter((e=>e.dayOfWeek()===t))}_getLeftEntryBorder(e,t){const s=n.clone(e),r=t.startOffset();return n.set_hms(s,r/60,r%60,0,0,n.get_timezone(this._timezone)),s}}}}]);