histropediajs 1.6.1 → 1.6.2

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- HistropediaJS v1.6.1 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
2
+ HistropediaJS v1.6.2 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
3
3
  Use of this software is subject to our End User Licence Agreement: https://js.histropedia.com/licence.html
4
4
  */
5
- (function(H,Y){typeof exports=="object"&&typeof module!="undefined"?module.exports=Y():typeof define=="function"&&define.amd?define(Y):(H=typeof globalThis!="undefined"?globalThis:H||self,H.Histropedia=Y())})(this,(function(){"use strict";var Ja=Object.defineProperty,Qa=Object.defineProperties;var tl=Object.getOwnPropertyDescriptors;var To=Object.getOwnPropertySymbols;var el=Object.prototype.hasOwnProperty,il=Object.prototype.propertyIsEnumerable;var Po=(H,Y,k)=>Y in H?Ja(H,Y,{enumerable:!0,configurable:!0,writable:!0,value:k}):H[Y]=k,W=(H,Y)=>{for(var k in Y||(Y={}))el.call(Y,k)&&Po(H,k,Y[k]);if(To)for(var k of To(Y))il.call(Y,k)&&Po(H,k,Y[k]);return H},Ft=(H,Y)=>Qa(H,tl(Y));const H={linear:t=>t,swing:t=>.5-Math.cos(t*Math.PI)/2,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,easeInCubic:t=>t**3,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t**3:1+--t*(2*t)**2};function Y({from:t=0,to:e=1,duration:i=400,easing:n=H.linear,onUpdate:o,onComplete:s,autoStart:r=!0}={}){let a=null,l=!1;function h(u){if(l)return;a===null&&(a=u);const m=Math.min(1,(u-a)/i),d=n(m),g=t+(e-t)*d;o==null||o(g,d),m<1?requestAnimationFrame(h):s==null||s()}function c(){l=!1,a=null,requestAnimationFrame(h)}return r&&c(),{stop(){l=!0},restart(){l=!1,c()}}}const k=0,F=1,ko=2,lt=-4,G=-3,K=-2,j=-1,O=0,$=1,rt=2,de=3,Rt=4,fe=5,zi=6,Fi=7,Bi=8,Hi=9,Yi=10,Wi=11,Vi="millisecond",Zi="second",Ui="minute",Gi="hour",ji="day",Ro="month",Oo="year",Eo="decade",No="century",xo="millennium",zo="million-years",Fo="billion-years",Bo={3:{label:" ka",value:1e3},6:{label:" Ma",value:1e6},9:{label:" Ga",value:1e9}},Ho="low",Yo="medium",Wo="high",Vo="all",Zo="all",Uo="screen",Je=[{region:-26,zoom:{from:Number.NEGATIVE_INFINITY,to:-80.86},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:134217728}},{region:-25,zoom:{from:-80.86,to:-77.75},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:67108864}},{region:-24,zoom:{from:-77.75,to:-74.64},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:33554432}},{region:-23,zoom:{from:-74.64,to:-71.53},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:16777216}},{region:-22,zoom:{from:-71.53,to:-68.42},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:8388608}},{region:-21,zoom:{from:-68.42,to:-65.31},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:4194304}},{region:-20,zoom:{from:-65.31,to:-62.2},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:2097152}},{region:-19,zoom:{from:-62.2,to:-59.09},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:1048576}},{region:-18,zoom:{from:-59.09,to:-55.98},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:524288}},{region:-17,zoom:{from:-55.98,to:-52.87},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:262144}},{region:-16,zoom:{from:-52.87,to:-49.76},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:131072}},{region:-15,zoom:{from:-49.76,to:-46.65},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:65536}},{region:-14,zoom:{from:-46.65,to:-43.54},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:32768}},{region:-13,zoom:{from:-43.54,to:-40.43},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:16384}},{region:-12,zoom:{from:-40.43,to:-37.32},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:8192}},{region:-11,zoom:{from:-37.32,to:-34.21},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:4096}},{region:-10,zoom:{from:-34.21,to:-31.1},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:2048}},{region:-9,zoom:{from:-31.1,to:-27.99},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:1024}},{region:-8,zoom:{from:-27.99,to:-24.88},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:512}},{region:-7,zoom:{from:-24.88,to:-21.77},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:256}},{region:-6,zoom:{from:-21.77,to:-18.66},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:128}},{region:-5,zoom:{from:-18.66,to:-15.55},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:64}},{region:-4,zoom:{from:-15.55,to:-12.44},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:32}},{region:-3,zoom:{from:-12.44,to:-9.33},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:16}},{region:-2,zoom:{from:-9.33,to:-6.22},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:8}},{region:-1,zoom:{from:-6.22,to:-3.11},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:4}},{region:0,zoom:{from:-3.11,to:0},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:2}},{region:1,zoom:{from:0,to:3.11},low:1,medium:2,high:3,all:25,step:{months:0,days:1}},{region:2,zoom:{from:3.11,to:6.22},low:1,medium:2,high:3,all:25,step:{months:0,days:2}},{region:3,zoom:{from:6.22,to:9.33},low:1,medium:2,high:3,all:25,step:{months:0,days:4}},{region:4,zoom:{from:9.33,to:12.44},low:1,medium:2,high:3,all:25,step:{months:0,days:8}},{region:5,zoom:{from:12.44,to:15.55},low:1,medium:2,high:3,all:25,step:{months:0,days:16}},{region:6,zoom:{from:15.55,to:18.66},low:1,medium:2,high:3,all:25,step:{months:0,days:32}},{region:7,zoom:{from:18.66,to:21.77},low:1,medium:2,high:3,all:25,step:{months:0,days:64}},{region:8,zoom:{from:21.77,to:24.88},low:1,medium:2,high:3,all:25,step:{months:0,days:128}},{region:9,zoom:{from:24.88,to:27.99},low:1,medium:2,high:3,all:25,step:{months:0,days:256}},{region:10,zoom:{from:27.99,to:31.1},low:1,medium:2,high:3,all:25,step:{months:0,days:512}},{region:11,zoom:{from:31.1,to:34.21},low:1,medium:2,high:3,all:25,step:{months:0,days:1024}},{region:12,zoom:{from:34.21,to:37.32},low:1,medium:2,high:3,all:25,step:{months:0,days:2048}},{region:13,zoom:{from:37.32,to:40.43},low:1,medium:2,high:3,all:25,step:{months:0,days:4096}},{region:14,zoom:{from:40.43,to:43.54},low:1,medium:2,high:3,all:25,step:{months:0,days:8192}},{region:15,zoom:{from:43.54,to:46.65},low:1,medium:2,high:3,all:25,step:{months:0,days:16384}},{region:16,zoom:{from:46.65,to:49.76},low:1,medium:2,high:3,all:25,step:{months:0,days:32768}},{region:17,zoom:{from:49.76,to:52.87},low:1,medium:2,high:3,all:25,step:{months:0,days:65536}},{region:18,zoom:{from:52.87,to:55.98},low:1,medium:2,high:3,all:25,step:{months:0,days:131072}},{region:19,zoom:{from:55.98,to:59.09},low:1,medium:2,high:3,all:25,step:{months:0,days:262144}},{region:20,zoom:{from:59.09,to:62.2},low:1,medium:2,high:3,all:25,step:{months:0,days:524288}},{region:21,zoom:{from:62.2,to:65.31},low:1,medium:2,high:3,all:25,step:{months:0,days:1048576}},{region:22,zoom:{from:65.31,to:68.42},low:1,medium:2,high:3,all:25,step:{months:0,days:2097152}},{region:23,zoom:{from:68.42,to:71.53},low:1,medium:2,high:3,all:25,step:{months:0,days:4194304}},{region:24,zoom:{from:71.53,to:74.64},low:1,medium:2,high:3,all:25,step:{months:0,days:8388608}},{region:25,zoom:{from:74.64,to:77.75},low:1,medium:2,high:3,all:25,step:{months:0,days:16777216}},{region:26,zoom:{from:77.75,to:80.86},low:1,medium:2,high:3,all:25,step:{months:0,days:33554432}},{region:27,zoom:{from:80.86,to:83.97},low:1,medium:2,high:3,all:25,step:{months:0,days:67108864}},{region:28,zoom:{from:83.97,to:87.08},low:1,medium:2,high:3,all:25,step:{months:0,days:134217728}},{region:29,zoom:{from:87.08,to:90.19},low:1,medium:2,high:3,all:25,step:{months:0,days:268435456}},{region:30,zoom:{from:90.19,to:93.3},low:1,medium:2,high:3,all:25,step:{months:0,days:536870912}},{region:31,zoom:{from:93.3,to:96.41},low:1,medium:2,high:3,all:25,step:{months:0,days:1073741824}},{region:32,zoom:{from:96.41,to:99.52},low:1,medium:2,high:3,all:25,step:{months:0,days:2147483648}},{region:33,zoom:{from:99.52,to:102.63},low:1,medium:2,high:3,all:25,step:{months:0,days:4294967296}},{region:34,zoom:{from:102.63,to:105.74},low:1,medium:2,high:3,all:25,step:{months:0,days:8589934592}},{region:35,zoom:{from:105.74,to:108.85},low:1,medium:2,high:3,all:25,step:{months:0,days:17179869184}},{region:36,zoom:{from:108.85,to:111.96},low:1,medium:2,high:3,all:25,step:{months:0,days:34359738368}},{region:37,zoom:{from:111.96,to:115.07},low:1,medium:2,high:3,all:25,step:{months:0,days:68719476736}},{region:38,zoom:{from:115.07,to:118.18},low:1,medium:2,high:3,all:25,step:{months:0,days:137438953472}},{region:39,zoom:{from:118.18,to:121.29},low:1,medium:2,high:3,all:25,step:{months:0,days:274877906944}},{region:40,zoom:{from:121.29,to:124.4},low:1,medium:2,high:3,all:25,step:{months:0,days:549755813888}}],Go=Object.freeze(Object.defineProperty({__proto__:null,DENSITY_ALL:Vo,DENSITY_HIGH:Wo,DENSITY_LOW:Ho,DENSITY_MEDIUM:Yo,DENSITY_SETTINGS:Je,ERA_MARKER:ko,MAJOR_MARKER:F,MINOR_MARKER:k,PRECISION_BILLION_YEARS:Fo,PRECISION_CENTURY:No,PRECISION_DAY:ji,PRECISION_DECADE:Eo,PRECISION_HOUR:Gi,PRECISION_MILLENNIUM:xo,PRECISION_MILLION_YEARS:zo,PRECISION_MILLISECOND:Vi,PRECISION_MINUTE:Ui,PRECISION_MONTH:Ro,PRECISION_SECOND:Zi,PRECISION_YEAR:Oo,RANGE_ALL:Zo,RANGE_SCREEN:Uo,YEAR_PREFIXES:Bo,ZOOM_100_MILLION_YEARS:Yi,ZOOM_100_THOUSAND_YEARS:Fi,ZOOM_10_MILLION_YEARS:Hi,ZOOM_10_THOUSAND_YEARS:zi,ZOOM_BILLION_YEARS:Wi,ZOOM_CENTURY:Rt,ZOOM_DAY:O,ZOOM_DECADE:de,ZOOM_HOUR:j,ZOOM_MILLENNIUM:fe,ZOOM_MILLION_YEARS:Bi,ZOOM_MILLISECOND:lt,ZOOM_MINUTE:K,ZOOM_MONTH:$,ZOOM_SECOND:G,ZOOM_YEAR:rt},Symbol.toStringTag,{value:"Module"}));class jo{constructor(){this._enabled=!1,this._prefix="[Histropedia]";const e=typeof console!="undefined"?console:null;this._console=e,this._fns={log:e&&e.log?e.log.bind(e):()=>{},warn:e&&e.warn?e.warn.bind(e):()=>{},error:e&&e.error?e.error.bind(e):()=>{},info:e&&e.info?e.info.bind(e):()=>{},debug:e&&e.debug?e.debug.bind(e):e&&e.log?e.log.bind(e):()=>{},group:e&&e.group?e.group.bind(e):e&&e.log?e.log.bind(e):()=>{},groupCollapsed:e&&e.groupCollapsed?e.groupCollapsed.bind(e):e&&e.group?e.group.bind(e):e&&e.log?e.log.bind(e):()=>{},groupEnd:e&&e.groupEnd?e.groupEnd.bind(e):()=>{}}}setEnabled(e){this._enabled=!!e}isEnabled(){return!!this._enabled}setPrefix(e){this._prefix=String(e||"")}getPrefix(){return this._prefix}_withPrefixedArgs(e){if(!this._prefix)return e;if(e&&e.length>0&&typeof e[0]=="string"){const i=e.slice();return i[0]=`${this._prefix} ${i[0]}`,i}return[this._prefix,...e]}_log(e,i){if(!this._enabled)return;(this._fns[e]||this._fns.log)(...this._withPrefixedArgs(i))}log(...e){this._log("log",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}group(...e){this._enabled&&this._fns.group(...this._withPrefixedArgs(e))}groupCollapsed(...e){this._enabled&&this._fns.groupCollapsed(...this._withPrefixedArgs(e))}groupEnd(){this._enabled&&this._fns.groupEnd()}}const T=new jo,Ae=[31,28,31,30,31,30,31,31,30,31,30,31],$o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],$i={1:"billion-years",3:"million-years",6:"millennium",7:"century",8:"decade",9:"year",10:"month",11:"day",12:"hour",13:"minute",14:"second",15:"millisecond"},Xo=/^(-?\d+)(?:-(\d{1,2}))?(?:-(\d{1,2}))?(?:[T ](\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?$/,Bt=1e3,Ht=60*Bt,Yt=60*Ht,U=24*Yt;function Qe(t){return Object.prototype.hasOwnProperty.call($i,t)?$i[t]:t||"day"}function me(t){if(t.precision!==void 0)return t.precision;if(!(t instanceof y)){for(const e of[Vi,Zi,Ui,Gi])if(t[e]!==void 0)return e}return ji}function Ie(t,e){const i=Math.ceil(t/e)*e;return{startYear:i-e+1,endYear:i}}function Me(t,e,i,n){const o=Number(t);return Number.isFinite(o)?Math.min(n,Math.max(i,Math.trunc(o))):e}function Xi(t,e,i,n,o){const s={hour:Me(e,0,0,23),minute:Me(i,0,0,59),second:Me(n,0,0,59),millisecond:Me(o,0,0,999)};for(const[r,a]of Object.entries(s))Object.defineProperty(t,r,{value:a,enumerable:a!==0,configurable:!0,writable:!0})}function qo(t,e){e!==void 0&&Object.defineProperty(t,"precision",{value:e,enumerable:!1,configurable:!0,writable:!0})}function Xt(t,e){return new y(Ft(W({},e),{precision:me(t)}))}function y(t,e,i,n,o,s,r){if(typeof t=="object"){const a=t;this.year=a.year,this.month=a.month,this.day=qi(a.year,a.month,a.day),Xi(this,a.hour,a.minute,a.second,a.millisecond),qo(this,me(a))}else this.year=t,this.month=e,this.day=qi(t,e,i),Xi(this,n,o,s,r)}function qi(t,e,i){return i>28?Math.min(i,qt(t,e)):i}function qt(t,e){return e===2&&(t%4===0&&t%100!==0||t%400===0)?29:Ae[e-1]}function Ce(t,e){return t=t.toString(),e=typeof e=="string"?e:",",t.length<=4?t:t.replace(/\B(?=(\d{3})+(?!\d))/g,e)}y.prototype.getDaysTo=function(t){const e=t.getDaysSinceYearZero()-this.getDaysSinceYearZero(),i=t.getMillisecondsOfDay()-this.getMillisecondsOfDay();return e+i/U},y.prototype.getMillisecondsOfDay=function(){return this.hour*Yt+this.minute*Ht+this.second*Bt+this.millisecond},y.prototype.getMonthsTo=function(t){return this.getYearsTo(t)*12},y.prototype.getYearsTo=function(t){let e=t.year-this.year;return e+=(t.month-this.month)/12+(t.day-this.day)/365.2422+(t.getMillisecondsOfDay()-this.getMillisecondsOfDay())/(U*365.2422),e},y.prototype.getLeapYearsSinceYearZero=function(){let t=this.year;return this.month<3&&t--,Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400)},y.prototype.getDaysSinceYearZero=function(){let e=this.year*365+this.day;for(let i=0;i<this.month-1;i++)e+=Ae[i];return e+=this.getLeapYearsSinceYearZero(),e},y.prototype.getDayOfYear=function(){let t=this.day;for(let e=1;e<this.month;e++)t+=qt(this.year,e);return t},y.getByDayOfYear=function(t,e){const i=new y(t,1,1);let n=Ae[0];for(let o=0;o<e-1;o++)i.day++,i.day>n&&(i.day=1,i.month++,i.month>12&&(i.month=1,i.year++),n=i.month===2?qt(i.year,i.month):Ae[i.month-1]);return i},y.prototype.getNextDay=function(){return this.addDays(1)},y.prototype.addDays=function(t){let e=this.day,i=this.month,n=this.year;const o=t<0?-1:1;let s=Math.abs(Math.trunc(t));for(;s>0;)o>0?(e++,e>qt(n,i)&&(e=1,i++,i>12&&(i=1,n++))):(e--,e<1&&(i--,i<1&&(i=12,n--),e=qt(n,i))),s--;return Xt(this,{year:n,month:i,day:e,hour:this.hour,minute:this.minute,second:this.second,millisecond:this.millisecond})},y.prototype.addMilliseconds=function(t){let e=this,i=this.getMillisecondsOfDay()+Math.trunc(t);for(;i<0;)e=e.addDays(-1),i+=U;for(;i>=U;)e=e.addDays(1),i-=U;const n=Math.floor(i/Yt);i-=n*Yt;const o=Math.floor(i/Ht);i-=o*Ht;const s=Math.floor(i/Bt),r=i-s*Bt;return Xt(this,{year:e.year,month:e.month,day:e.day,hour:n,minute:o,second:s,millisecond:r})},y.prototype.addSeconds=function(t){return this.addMilliseconds(t*Bt)},y.prototype.addMinutes=function(t){return this.addMilliseconds(t*Ht)},y.prototype.addHours=function(t){return this.addMilliseconds(t*Yt)},y.prototype.addMonths=function(t){let e=this.month,i=this.year;for(let n=0;n<t;n++)e++,e>12&&(e=1,i++);return Xt(this,{year:i,month:e,day:1})},y.prototype.getPreviousDay=function(){return this.addDays(-1)},y.prototype.getNextMonth=function(){let t=this.month,e=this.year;return t++,t>12&&(t=1,e++),Xt(this,{year:e,month:t,day:1})},y.prototype.getPreviousMonth=function(){let t=this.month,e=this.year;return t--,t<1&&(t=12,e--),Xt(this,{year:e,month:t,day:1})},y.prototype.addYears=function(t){return Xt(this,{year:this.year+t,month:1,day:1})};function De(t,e){return String(t).padStart(e,"0")}y.prototype.format=function(t,e){e=e||{},t=t||"D MMM YYYY";const i=e.yearPrefix,n=typeof e.bceText=="string"?e.bceText:" ʙᴄᴇ",o=this.year<=0,s=this.year===0,r=e.thousandsSeparator;if(i&&!s){const a=i.value||1,l=i.label||"";let h;return o?h=Ce((-this.year+1)/a,r)+l+n:h=Ce(this.year/a,r)+l,h}return t.replace("YYYY",o?Ce(-this.year+1,r)+n:Ce(this.year,r)).replace("D",this.day).replace("MMM",$o[this.month-1]).replace("HH",De(this.hour,2)).replace("mm",De(this.minute,2)).replace("ss",De(this.second,2)).replace("SSS",De(this.millisecond,3))},y.prototype.isSame=function(t){return t.year===this.year&&t.month===this.month&&t.day===this.day&&(t.hour||0)===this.hour&&(t.minute||0)===this.minute&&(t.second||0)===this.second&&(t.millisecond||0)===this.millisecond},y.prototype.toKeyString=function(){const t=`${this.year}|${this.month}|${this.day}`;return this.getMillisecondsOfDay()===0?t:`${t}|${this.hour}|${this.minute}|${this.second}|${this.millisecond}`},y.prototype.isAfter=function(t){const e=["year","month","day","hour","minute","second","millisecond"];for(let i=0;i<e.length;i++){const n=e[i],o=this[n]||0,s=t[n]||0;if(o!==s)return o>s}return!1},y.prototype.isBetween=function(t,e){return this.isAfter(t)&&e.isAfter(this)},y.prototype.compare=function(t){return this.isSame(t)?0:this.isAfter(t)?1:-1},y.prototype.asFloat=function(){const t=this.month-1,e=this.day-1,i=this.getMillisecondsOfDay()/U;return t===0&&e===0&&i===0?this.year:Math.round((this.year+(t*31+e+i)/371)*100)/100},y.prototype.isInFuture=function(){const t=new Date,e=new y(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds());return this.isAfter(e)},y.prototype.convertToIso=function(){return this.year<0&&(this.year+=1),this},y.CreateAsStartOfPeriod=function(t,e){const i=t.year,n=t.month||1,o=t.day||1;return e=Qe(e),e==="millisecond"?new y(t):e==="second"?new y(i,n,o,t.hour,t.minute,t.second,0):e==="minute"?new y(i,n,o,t.hour,t.minute,0,0):e==="hour"?new y(i,n,o,t.hour,0,0,0):e==="day"?new y(i,n,o):e==="month"?new y(i,n,1):e==="year"||e==="million-years"||e==="billion-years"?new y(i,1,1):e==="decade"?new y(Math.floor(i/10)*10,1,1):e==="century"?new y(Ie(i,100).startYear,1,1):e==="millennium"?new y(Ie(i,1e3).startYear,1,1):new y(i,n,o)},y.CreateAsEndOfPeriod=function(t,e){const i=t.year,n=t.month||1,o=t.day||1;return e=Qe(e),e==="millisecond"?new y(t):e==="second"?new y(i,n,o,t.hour,t.minute,t.second,999):e==="minute"?new y(i,n,o,t.hour,t.minute,59,999):e==="hour"?new y(i,n,o,t.hour,59,59,999):e==="day"?new y(i,n,o):e==="month"?new y(i,n,qt(i,n)):e==="year"?new y(i,12,31):e==="decade"?new y(Math.floor(i/10)*10+9,12,31):e==="century"?new y(Ie(i,100).endYear,12,31):e==="millennium"?new y(Ie(i,1e3).endYear,12,31):e==="million-years"?new y(i+999999,12,31):e==="billion-years"?new y(i+999999999,12,31):(T.error("precision is not implemented"),new y(i,n,o))},y.CreateAsExclusiveEndOfPeriod=function(t,e){e=Qe(e);const i=y.CreateAsStartOfPeriod(t,e);return e==="millisecond"?i.addMilliseconds(1):e==="second"?i.addSeconds(1):e==="minute"?i.addMinutes(1):e==="hour"?i.addHours(1):e==="day"?i.addDays(1):y.CreateAsEndOfPeriod(t,e).addDays(1)},y.now=function(){const t=new Date;return new y({year:t.getYear()+1900,month:t.getMonth()+1,day:t.getDate()})};function ti(t){const e=String(t).match(Xo);if(!e)return null;const i=parseInt(e[1],10),n=e[2]==null?1:parseInt(e[2],10),o=e[3]==null?1:parseInt(e[3],10),s=e[4]==null?0:parseInt(e[4],10),r=e[5]==null?0:parseInt(e[5],10),a=e[6]==null?0:parseInt(e[6],10),l=e[7]?parseInt(e[7].padEnd(3,"0"),10):0;return{date:new y(i,n,o,s,r,a,l),hasMonth:e[2]!=null,hasDay:e[3]!=null,hasTime:e[4]!=null}}y.fromString=function(t){const e=ti(t);return e?e.date:new y(NaN,1,1)};function ei(t,...e){return Object.assign(t,...e)}function L(t,...e){const i=s=>{if(s&&typeof s=="object"&&!Object.prototype.hasOwnProperty.call(s,"__proto__"))try{Object.defineProperty(s,"__proto__",{value:void 0,writable:!0,enumerable:!1,configurable:!0})}catch(r){}};i(t);const n=s=>s==="__proto__"||s==="constructor"||s==="prototype",o=s=>{if(s===null||typeof s!="object")return!1;const r=Object.getPrototypeOf(s);return r===Object.prototype||r===null};for(const s of e)if(!(!s||typeof s!="object"))for(const r of Object.keys(s)){if(n(r))continue;const a=s[r];if(Array.isArray(a)){t[r]=a.slice();continue}if(o(a)){const l=o(t[r])?t[r]:{};i(l),t[r]=L(l,a);continue}t[r]=a}return i(t),t}function bt(t,e){const i=t.split("."),n=i[i.length-1];let o={};o[n]=e;for(let s=i.length-2;s>=0;s--){const r=i[s],a=L({},o);o={},o[r]=a}return o}function Ki(t,e){const i=`_${e}`;t[i]=void 0,Object.defineProperty(t,e,{get(){const n=this[i];return typeof n=="function"?n(this):n},set(n){this[i]=n},enumerable:!0,configurable:!1})}function Te(t){return typeof t=="undefined"}const Ji={id:"i",title:"t",rank:"r",subtitle:"s","from.year":"fy","from.month":"fm","from.day":"fd","from.hour":"fhr","from.minute":"fmi","from.second":"fs","from.millisecond":"fms","from.precision":"fp","to.year":"ty","to.month":"tm","to.day":"td","to.hour":"thr","to.minute":"tmi","to.second":"ts","to.millisecond":"tms","to.precision":"tp",isToPresent:"p",isStarred:"v","offset.left":"ol","offset.top":"ot",imageUrl:"m",lane:"ln",style:"st",activeStyle:"ast",hiddenByFilter:"h",hidePeriodLine:"hp"};function Qi(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:t[Ji[e]]}function tn(t,e){const n=e.split(".").reduce((o,s)=>o?o[s]:void 0,t);return Te(n)?t[Ji[e]]:n}function en(t){return t.indexOf(".")>-1}function _(t,e){return en(e)?tn(t,e):Qi(t,e)}function Pe(t,e){const i=me(Object.fromEntries(["precision","hour","minute","second","millisecond"].map(o=>[o,_(t,`${e}.${o}`)]))),n=Object.fromEntries(["year","month","day","hour","minute","second","millisecond"].map(o=>[o,parseInt(_(t,`${e}.${o}`))]));return new y(Ft(W({},n),{precision:i}))}function A(t,e){return en(e)?!Te(tn(t,e)):!Te(Qi(t,e))}Ki(I.prototype,"hidePeriodLine"),Ki(I.prototype,"hiddenByFilter");function I(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.imageLoaded=!1,this.stacking=0,this.groupIndex=0,this.isActive=!1,this.isVisible=!1,this.isVisibleInLane=!0,this.isInRange=!1,this.isInView=!1,this.isVisibleInGroup=!1,this.isVisibleInRows=!0,this.isStarred=!1,this.isMouseOverStar=!1,this.isMouseover=!1,this.isDragging=!1,this.registeredPosition={left:0,top:0},this.position={left:0,top:0},this.dragStartOffset={left:0,top:0},this.indicator={fromX:0,toX:0},this.offset={left:0,top:0},this.finalOffset={left:0,top:0},this.isVisibleAfterFade=!1,this.opacity=0,this.fadeAnimation={finalOpacity:0,dummyElement:null},this.moveAnimation={finalOffset:{left:0,top:0},dummyElement:void 0},this.row=0,this.laneId=null,this.laneOrder=0,this.isFading=!1,this.isMoving=!1,this._cachedHeight=0,this._cachedWidth=0,this._sizeValid=!1,this._sizeCacheKey=null,this._layoutCaches=null,this._resolvedDefaultCardLayout=null,this._resolvedCardLayoutName=null}I.prototype.setupByReceivedData=function(t){this.owner._assignArticleToLane(this,this.owner._resolveLaneIdFromArticleData(t));const e=this.owner._getResolvedArticleOptions(this).defaultData,i=L({},e,t);A(t,"to")||delete i.to,this.data=L({},t),this.title=_(i,"title")||"",this.rank=_(i,"rank")||0,this.subtitle=_(i,"subtitle")||"",this._setupArticlePeriod(i),this.offset.left=this.finalOffset.left=this.moveAnimation.finalOffset.left=i.offsetLeft||0,this.offset.top=this.finalOffset.top=this.moveAnimation.finalOffset.top=i.offsetTop||0,this.isStarred=!!i.starred,this.cardLayout=_(i,"cardLayout")||null,this.initialiseStyles(i),this.hiddenByFilter=_(i,"hiddenByFilter"),this.hidePeriodLine=A(i,"hidePeriodLine")?_(i,"hidePeriodLine"):this.owner.options.article.periodLine.defaultHide,this.isDataLoaded=!0,this.isImageInfoLoaded=!1},I.prototype._setupArticlePeriod=function(t){let e=Pe(t,"from");e=this.owner.getDmyFromInput(e);const i=e.precision,n=_(t,"isToPresent"),o=n===!0||n===1;let s,r;o?s=y.now():A(t,"to")?(s=Pe(t,"to"),s=this.owner.getDmyFromInput(s),r=s.precision):(s=e,r=i);const a=y.CreateAsStartOfPeriod(e,i),l=y.CreateAsExclusiveEndOfPeriod(s,r);this.period={from:a,to:l,isToPresent:o},this.period.years=this.period.to.asFloat()-this.period.from.asFloat()},I.prototype.setImage=function(){this.isImageInfoLoaded=!0,_(this.data,"imageUrl")?this.owner.enqueueImageLoad(this):(this._releaseImageResource(),this.image=null,this.imageLoaded=!1)},I.prototype._releaseImageResource=function(t={}){const e=typeof this._closeImage=="function"?this._closeImage:null;if(e){this._closeImage=null;try{e(t)}catch(i){}return}t.keepState||(this.image=null,this.imageLoaded=!1,this._loadedImageKey=null)},I.prototype.registerPosition=function(t){this.registeredPosition=this.position=t},I.prototype.overlaps=function(t){return t.period.from.isSame(this.period.from)&&t.period.to.isSame(this.period.to)||t.period.from.isBetween(this.period.from,this.period.to)||t.period.to.isBetween(this.period.from,this.period.to)||this.period.from.isBetween(t.period.from,t.period.to)||this.period.to.isBetween(t.period.from,t.period.to)},I.prototype.overlapsInclusiveWithDates=function(t,e){return!(this.period.from.isAfter(e)||t.isAfter(this.period.to))},I.prototype.overlapsInclusive=function(t){return this.overlapsInclusiveWithDates(t.period.from,t.period.to)},I.prototype.isInside=function(t){if(!this.isVisible)return!1;this._ensureSizeCache();const e=this.position.left,i=this.position.top,n=this._cachedWidth,o=this._cachedHeight;return t.left>=e&&t.left<=e+n&&t.top>=i&&t.top<=i+o},I.prototype.pointerEnter=function(t){this.isMouseover=!0,this.owner.trigger("article-pointerenter",this,t)},I.prototype.pointerLeave=function(t){this.isMouseover=!1,this.owner.trigger("article-pointerleave",this,t)},I.prototype.updateIsMouseOverStar=function(t){const e=this.getIconBox();if(!e)return!1;const i=this.isMouseOverStar;return this.isMouseOverStar=t.left>=e.left&&t.left<=e.left+e.width&&t.top>=e.top&&t.top<=e.top+e.height,this.isMouseOverStar!==i&&!this.owner.isAnimating&&this.owner.redraw(),this.isMouseOverStar},I.prototype.getCursor=function(t){const e=this.owner.options.style.cursor;return this.isDragging?e.article.dragging:(this.updateIsMouseOverStar(t),this.owner.options.article.draggable&&this.isActive?this.isMouseOverStar?e.clickable:e.article.hoverDraggable:e.clickable)},I.prototype.clicked=function(t){return this.updateIsMouseOverStar(t),this.isMouseOverStar?(this.isStarred=!this.isStarred,!0):!1},I.prototype.getStatusForSave=function(){const t={i:this.id};return this.offset.left!==0&&(t.l=this.offset.left),this.offset.top!==0&&(t.t=this.offset.top),this.isStarred&&(t.v=!0),t},I.prototype.headerOverlapsWith=function(t){const e=this.registeredPosition.left,i=t.registeredPosition.left,n=e+this.getWidth();return i+t.getWidth()>=e&&n>=i},I.prototype._getWidth=function(){return this.getCurrentStyle().width},I.prototype.getWidth=function(){return this._ensureSizeCache(),this._cachedWidth},I.prototype.getHeight=function(){return this._ensureSizeCache(),this._cachedHeight},I.prototype.setOption=function(t,e){let i=!1;if(typeof t=="string"){if(typeof e=="undefined")return _(this.data,t);t=bt(t,e)}L(this.data,t),A(t,"id")&&(this.id=t.id),A(t,"title")&&(this.title=t.title,this.titleLines=void 0),A(t,"subtitle")&&(this.subtitle=t.subtitle,this.summarisedSubtitle=void 0),(A(t,"from")||A(t,"to")||A(t,"isToPresent"))&&(this._setupArticlePeriod(this.data),i=!0),A(t,"imageUrl")&&this.setImage(),A(t,"rank")&&(this.rank=t.rank,i=!0),A(t,"starred")&&(this.isStarred=t.starred),A(t,"hiddenByFilter")&&(this.hiddenByFilter=t.hiddenByFilter),A(t,"hidePeriodLine")&&(this.hidePeriodLine=t.hidePeriodLine);const n=A(t,"lane");n&&(this.owner._assignArticleToLane(this,t.lane),this.initialiseStyles(this.data),this.invalidateCaches(),i=!0);const o=A(t,"style"),s=A(t,"activeStyle"),r=A(t,"hoverStyle");(o||r||s)&&this.initialiseStyles(this.data),this.invalidateCaches(),A(t,"cardLayout")&&this.setCardLayout(t.cardLayout),n&&this.owner.updateArticlesGroupIndex(),i?this.owner.requestRedraw():this.owner.requestRedraw(this.redraw)},I.prototype.initialiseStyles=function(t=this.data){const e=this.owner._resolveDefaultCardLayoutName(this),n=this.owner._getExplicitArticleCardLayout(this)||e;this._resolvedDefaultCardLayout=e,this._resolvedCardLayoutName=n;const o=this.owner._getResolvedArticleStyleOverrides(this,n),s=L({},o.style,_(t,"style")||{}),r=L({},o.activeStyle,_(t,"activeStyle")||{}),a=L({},o.hoverStyle,_(t,"hoverStyle")||{});this.style=s,this.activeStyle=L({},s,r),this.hoverStyle=L({},s,a),this.activeHoverStyle=L({},s,a,r)},I.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t),this.initialiseStyles(this.data),this.invalidateCaches(),this.owner.requestRedraw()},I.prototype.setHoverStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.activeStyle,t);t=bt(t,e)}this.data.hoverStyle=L(this.data.hoverStyle||{},t),this.initialiseStyles(this.data),this.owner.requestRedraw()},I.prototype.setActiveStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.activeStyle,t);t=bt(t,e)}this.data.activeStyle=L(this.data.activeStyle||{},t),this.initialiseStyles(this.data),this.owner.requestRedraw()},I.prototype.activated=function(){T.warn('DEPRECATION WARNING: article.activated() was deprecated in v1.3.0. Use timeline.select(article.id) and handle selection with options.on["article-select"] instead.'),this.owner.trigger("article-click",this)},I.prototype.updateVisibility=function(){const t=this.isVisibleAfterFade,e=this.isInRange&&this.isVisibleInLane&&this.isVisibleInGroup&&this.isVisibleInRows&&!this.isHiddenByFilter;if(!this.isVisibleInLane){this.setVisibility(!1);return}if(t!==e){if(e&&!this.isImageInfoLoaded&&this.setImage(),!this.owner.options.article.animation.fade.active){this.setVisibility(e);return}this.setVisibilityWithFade(e)}},I.prototype.setVisibility=function(t){var e,i,n,o;this.isFading&&((i=(e=this.fadeAnimation)==null?void 0:e.dummyElement)!=null&&i.stop)&&(this.fadeAnimation.dummyElement.stop(),this.isFading=!1,((o=(n=this.owner)==null?void 0:n.lastAnimatingArticle)==null?void 0:o.id)===this.id&&this.owner.lastAnimatingArticle.animationType==="fade"&&(this.owner.isAnimatingArticles=!1)),this.isVisible=t,this.isVisibleAfterFade=t,this.opacity=t?1:0,t||this._releaseImageResource({skipRedraw:!0})},I.prototype.setVisibilityWithFade=function(t){var h,c,u,m;const e=this;if(t===e.isVisibleAfterFade)return;e.isFading&&((c=(h=e.fadeAnimation)==null?void 0:h.dummyElement)!=null&&c.stop)&&e.fadeAnimation.dummyElement.stop(),e.isFading=!0,e.isVisibleAfterFade=t,e.fadeAnimation=e.fadeAnimation||{},e.fadeAnimation.finalOpacity=t,t&&(e.isVisible=!0),e.owner.notifyArticleAnimating("fade",e.id);const i=e.owner.options.article.animation.fade,n=(u=i.duration)!=null?u:400,o=(m=i.easing)!=null?m:"swing",s=H[o]||H.swing,r=e.opacity,l=Y({from:r,to:t?1:0,duration:n,easing:s,onUpdate(d){e.opacity=d,e.owner.requestRedraw()},onComplete(){e.isFading=!1,t||(e.isVisible=!1,e._releaseImageResource({skipRedraw:!0}));const d=e.owner.lastAnimatingArticle;e.id===d.id&&d.animationType==="fade"&&(e.owner.isAnimatingArticles=!1),typeof i.complete=="function"&&i.complete.call(e)}});e.fadeAnimation.dummyElement=l},I.prototype.moveToOffset=function(t){this.finalOffset.top=this.offset.top=t.top||this.offset.top,this.finalOffset.left=this.offset.left=t.left||this.offset.left,this.position.top=this.registeredPosition.top+this.offset.top,this.position.left=this.registeredPosition.left+this.offset.left},I.prototype.moveTo=function(t){const e={left:t.left-this.registeredPosition.left,top:t.top-this.registeredPosition.top};this.moveToOffset(e)},I.prototype.moveToWithAnim=function(t){const e={left:t.left-this.registeredPosition.left,top:t.top-this.registeredPosition.top};this.moveToOffsetWithAnim(e)},I.prototype.moveToOffsetWithAnim=function(t){var m,d,g;const e=this,i=e.moveAnimation;if(t.top===i.finalOffset.top&&t.left===i.finalOffset.left)return;e.isMoving&&((m=i==null?void 0:i.dummyElement)!=null&&m.stop)&&i.dummyElement.stop(),i.finalOffset=this.finalOffset={left:t.left,top:t.top},e.isMoving=!0,e.owner.notifyArticleAnimating("move",e.id);const n=e.owner.options.article.animation.move,o=(d=n.duration)!=null?d:400,s=(g=n.easing)!=null?g:"swing",r=H[s]||H.swing,a=e.offset.top,l=e.offset.left,h=t.top-a,c=t.left-l,u=Y({from:0,to:1,duration:o,easing:r,onUpdate(p){e.offset.top=a+h*p,e.offset.left=l+c*p,e.position.top=e.registeredPosition.top+e.offset.top,e.position.left=e.registeredPosition.left+e.offset.left,e.owner.requestRedraw()},onComplete(){e.offset.top=t.top,e.offset.left=t.left,e.position.top=e.registeredPosition.top+t.top,e.position.left=e.registeredPosition.left+t.left,e.isMoving=!1;const p=e.owner.lastAnimatingArticle;e.id===p.id&&p.animationType==="move"&&(e.owner.isAnimatingArticles=!1)}});i.dummyElement=u};function ke(t){return Math.round(t)}function Ko(t,e=1){const i=typeof e=="number"&&isFinite(e)&&e>0?e:1;return Math.round(t*i)/i}function nn(t){return t}function on(t=1,e="device"){return e===!1||e==="none"?nn:e==="css"?ke:function(n){return Ko(n,t)}}function Jo(t=1,e="device",i=1){if(e===!1||e==="none")return nn;const n=typeof t=="number"&&isFinite(t)&&t>0?t:1,o=e==="css"?1:n,r=(typeof i=="number"&&isFinite(i)&&i>0?i:1)*o/2;return function(l){return(Math.round(l*o-r)+r)/o}}function Qo(t,e,i){i||(i=ke);const n=e/2;return{left:i(t.left+n),top:i(t.top+n),width:i(t.width-e),height:i(t.height-e)}}I.prototype.draw=function(t){if(!this.isDataLoaded||isNaN(this.position.left))return;this._ensureSizeCache(),t.globalAlpha=this.opacity,this._getCurrentCardLayout().draw.call(this,t)},I.prototype.getCurrentStyle=function(){return this.isActive?this.isMouseover?this.activeHoverStyle:this.activeStyle:this.isMouseover?this.hoverStyle:this.style},I.prototype._getCurrentStyle=function(){return this.getCurrentStyle()},I.prototype._getPeriodLineRenderGeometry=function(t){const i=this.owner._getResolvedArticleOptions(this).periodLine||{},o=(this.owner.options.article.periodLine||{}).position||"axis",s=Number.isFinite(i.baselineGap)?i.baselineGap:0,r=this.hidePeriodLine?0:i.spacing||0,a=this.hidePeriodLine?0:i.thickness||0,l=(r+a)*this.stacking;let h=t,c=this.owner.options.style.mainLine.size/2;if(o==="lane"&&this.owner._isLaneLayoutActive()){const m=this.owner.getLaneById(this.laneId);m&&m.geometry&&(h=Math.floor(m.geometry.bottom),c=0)}const u=h-s-l-c-a/2;return{position:o,baselineGap:s,spacing:r,thickness:a,anchorY:h,anchorOffset:c,y:u}},I.prototype.drawPeriodLinesAndConnectors=function(t,e){var v,S,M,P,E,x;t.globalAlpha=this.opacity;const i=this.getCurrentStyle(),n=this._getPeriodLineRenderGeometry(e),o=n.y;if(!this.hidePeriodLine){const Z=this.indicator.fromX,R=this.indicator.toX;if(t.beginPath(),t.lineWidth=n.thickness,t.moveTo(Z,o),t.lineTo(R,o),this.period.isToPresent){const V=R-Z,B=15,z=Math.max(1-B/V,.7),it=t.createLinearGradient(Z,o,R,o);it.addColorStop(0,i.color),it.addColorStop(z,i.color),it.addColorStop(1,"rgba(255,255,255,0)"),t.strokeStyle=it}else t.strokeStyle=i.color;t.stroke()}if(!i.connectorLine.visible)return;const s=this._getCurrentCardLayout(),r=typeof s.getConnectorEnd=="function"?s.getConnectorEnd.call(this):{left:this.position.left+i.connectorLine.offsetX,top:this.position.top+this.getHeight()+i.connectorLine.offsetY},a=Math.max(0,this.indicator.fromX),l=o,h=r.left,c=r.top,u=Math.abs(a-h)<Number.EPSILON,m=(P=(M=(S=(v=this.owner)==null?void 0:v.options)==null?void 0:S.article)==null?void 0:M.rendering)==null?void 0:P.pixelSnap,d=Jo(((x=(E=this.owner)==null?void 0:E.getCanvasDpr)==null?void 0:x.call(E))||1,m,i.connectorLine.thickness),g=u?d(h):null,p=g!=null?g:a,w=g!=null?g:h;t.strokeStyle=t.fillStyle=i.color,t.lineWidth=i.connectorLine.thickness,t.beginPath(),t.moveTo(p,l),t.lineTo(w,c),t.stroke();const b=Math.atan((c-l)/(w-p))+(w>=p?-90:90)*Math.PI/180;t.save(),t.beginPath(),t.translate(w,c),t.rotate(b),t.moveTo(-i.connectorLine.arrow.width,0),t.lineTo(i.connectorLine.arrow.width,0),t.lineTo(0,-i.connectorLine.arrow.height),t.closePath(),t.restore(),t.fill()},I.prototype.getIconBox=function(){return this._getCurrentCardLayout().getIconBox.call(this)},I.prototype.startDragging=function(t,e){this.isMoving&&this.moveAnimation.dummyElement.stop(),this.isDragging=!0,this.dragInitialPosition={left:this.position.left,top:this.position.top},this.lastDragPosition={left:this.position.left,top:this.position.top},this.dragStartOffset={left:t.left-this.position.left,top:t.top-this.position.top},this.owner.startAnimation(),this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag-start",this,e)},I.prototype.stopDragging=function(t){var e,i;this.offset=this.finalOffset=this.moveAnimation.finalOffset={left:this.position.left-this.registeredPosition.left,top:this.position.top-this.registeredPosition.top},this.isDragging=!1,(i=(e=this.owner)==null?void 0:e._markTimelineStateChanged)==null||i.call(e),this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag-end",this,t)},I.prototype.dragging=function(t,e){const i={left:t.left-this.dragStartOffset.left,top:t.top-this.dragStartOffset.top},n=this.lastDragPosition||{left:this.position.left,top:this.position.top},o=this.dragInitialPosition||n,s=i.left-n.left,r=i.top-n.top,a=i.left-o.left,l=i.top-o.top;this.position=i,this.lastDragPosition=i,this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag",this,{dx:s,dy:r,totalDx:a,totalDy:l},e)},I.prototype._cacheBucket=function(){const t=this._getCurrentCardLayoutName();return this._layoutCaches||(this._layoutCaches=Object.create(null)),this._layoutCaches[t]||(this._layoutCaches[t]=Object.create(null))},I.prototype.memo=function(t,e){const i=this._cacheBucket();return t in i?i[t]:i[t]=e.call(this)},I.prototype._getSizeCacheKey=function(){var l,h;const t=typeof this.getCurrentStyle=="function"?this.getCurrentStyle():null,e=t&&t.image||{},i=t&&t.header||{},n=t&&t.subheader||{},o=t&&t.border||{},s=typeof this._getCurrentCardLayoutName=="function"?this._getCurrentCardLayoutName():"",r=this.imageLoaded&&this.image;return[s,t&&t.width,t&&t.height,i.height,n.height,o.width,(l=e.margin)!=null?l:0,e.shape||"",(h=e.maxHeight)!=null?h:"",t&&t.maxImageHeight!==void 0?t.maxImageHeight:"",r?this.image.width:"noimg",r?this.image.height:""].join("|")},I.prototype.updateCachedSize=function(){const t=this._getCurrentCardLayout();this._cachedWidth=t.getWidth.call(this),this._cachedHeight=t.getHeight.call(this),this.height=this._cachedHeight,this._sizeValid=!0,this._sizeCacheKey=this._getSizeCacheKey()},I.prototype._ensureSizeCache=function(){const t=this._getSizeCacheKey();(!this._sizeValid||t!==this._sizeCacheKey)&&this.updateCachedSize()},I.prototype.invalidateCaches=function(){if(this._sizeValid=!1,this._sizeCacheKey=null,this._layoutCaches){const t=this._layoutCaches;for(const e in t){const i=t[e];if(i)for(const n in i){const o=i[n];if(o&&typeof o.close=="function")try{o.close()}catch(s){}}}}this._layoutCaches=null},I.prototype._getCurrentCardLayoutName=function(){return this._resolvedCardLayoutName||this.cardLayout||this._resolvedDefaultCardLayout||this.owner._resolveArticleCardLayoutName(this)},I.prototype._getCurrentCardLayout=function(){return this.owner.getCardLayout(this._getCurrentCardLayoutName())},I.prototype.setCardLayout=function(t){if(!this.owner.getCardLayout(t))throw new Error(`Card layout "${t}" not found`);this.cardLayout=t,this._resolvedCardLayoutName=t,this.initialiseStyles(),this.invalidateCaches(),this.owner.requestRedraw(this.redraw)};function Mt(t,e){const i=Number(t),n=Number(e);if(Number.isFinite(i)&&Number.isFinite(n))return i-n;const s=String(t),r=String(e);return s===r?0:s<r?-1:1}function ts(t,e){const i=t.period.from.getDaysTo(t.period.to),n=e.period.from.getDaysTo(e.period.to);return i<n?1:i>n?-1:Mt(t.id,e.id)}function es(t,e){const i=t.period.years,n=e.period.years;return i<n?1:i>n?-1:Mt(t.id,e.id)}function is(t,e){const i=t.isInView&&t.isVisible,n=e.isInView&&e.isVisible;return!i&&n?-1:i&&!n?1:t.position.top-e.position.top}function sn(t,e){const i=t.period.from,n=e.period.from;let o=i.compare(n);return o===0&&(o=Mt(e.id,t.id)),o}function ns(t,e){const i=t.period.to;let o=e.period.to.compare(i);return o===0&&(o=Mt(e.id,t.id)),o}function os(t,e){const i=t.position.top,n=e.position.top;return i<n?-1:i>n?1:Mt(e.id,t.id)}function ii(t,e){const i=t.laneOrder||0,n=e.laneOrder||0;if(i>n)return-1;if(i<n)return 1;const o=t.row,s=e.row;return o<s?1:o>s?-1:Mt(e.id,t.id)}function ni(t,e){const i=t.rank,n=e.rank;return i<n?1:i>n?-1:Mt(e.id,t.id)}function ss(t,e){const i=t.effectiveRank,n=e.effectiveRank;return i<n?1:i>n?-1:Mt(e.id,t.id)}function rs(t,e){const i=t.position.left,n=e.position.left;let o=i<n?1:i>n?-1:0;return o===0&&(o=t.position.top-e.position.top,o===0&&(o=t.period.from.compare(e.period.from),o===0&&(o=Mt(t.id,e.id)))),o}const as=Object.freeze(Object.defineProperty({__proto__:null,ARTICLE_DURATION_SORTER:ts,ARTICLE_DURATION_YEARS_SORTER:es,ARTICLE_EFFECTIVE_RANK_SORTER:ss,ARTICLE_FROM_SORTER:sn,ARTICLE_IMAGE_QUEUE_SORTER:is,ARTICLE_POSITION_SORTER:rs,ARTICLE_RANK_SORTER:ni,ARTICLE_ROW_SORTER:ii,ARTICLE_TOP_SORTER:os,ARTICLE_TO_SORTER:ns},Symbol.toStringTag,{value:"Module"})),rn=new Map;function an(t,e){!t||typeof e!="function"||rn.set(t,e)}function ls(t){return rn.get(t)}const oi=["#2563eb","#dc2626","#16a34a","#9333ea","#ea580c","#0891b2","#be123c","#4f46e5"],Kt={source:"data",includeZero:!1,padding:.05,tickMode:"round",tickTarget:5},hs={area:{stacking:{active:!0,interpolation:"linear"}}},ln={lineWidth:2,lineDash:[],area:{fillColor:null,opacity:.2},point:{visible:!1,radius:2.5,fillColor:null,strokeColor:null,lineWidth:1}},hn={padding:{top:8,right:12,bottom:8,left:48},backgroundColor:"rgba(255, 255, 255, 0)",gridLine:{x:{major:{visible:!0,color:"rgba(0, 0, 0, 0.08)",thickness:1},minor:{visible:!0,color:"rgba(0, 0, 0, 0.035)",thickness:1,minimumSpacing:20}},y:{major:{visible:!0,color:"rgba(120, 120, 120, 0.24)",thickness:1}}},axis:{visible:!0,color:"rgba(80, 80, 80, 0.45)",lineWidth:1},yAxis:{visible:!0,font:"normal 11px Calibri",color:"#555",margin:6,thousandsSeparator:",",formatter:null},legend:{visible:"auto",position:"top-left",font:"normal 12px Calibri",color:"#333",markerSize:10,markerGap:4,itemGap:12,inset:{x:8,y:8}},series:W({},ln)};function Ct(t){return typeof t=="number"&&Number.isFinite(t)}function si(t){return t!=null&&t.date&&typeof t.date.toKeyString=="function"?t.date.toKeyString():null}function cn(t){var n,o;const e=((o=(n=t==null?void 0:t.typeOptions)==null?void 0:n.area)==null?void 0:o.stacking)||{},i=e.interpolation;return{active:e.active!==!1,interpolation:i==="step"||i==="none"?i:"linear"}}function cs(t,e){return(t==null?void 0:t.date)&&t.date.compare(e)===0}function us(t,e,i){let n=null;for(let o=i;o<t.length&&cs(t[o],e);o++)n=t[o];return n}function ds(t,e){let i=0,n=t.length;for(;i<n;){const o=Math.floor((i+n)/2);t[o].date.compare(e)<0?i=o+1:n=o}return i}function fs(t,e){var i,n;for(let o=e-1;o>=0;o--){if(Ct((i=t[o])==null?void 0:i.value))return t[o];if(((n=t[o])==null?void 0:n.value)===null)return null}return null}function ms(t,e){var i,n;for(let o=e;o<t.length;o++){if(Ct((i=t[o])==null?void 0:i.value))return t[o];if(((n=t[o])==null?void 0:n.value)===null)return null}return null}function gs(t,e,i){if(!e||!i||!e.date||!i.date)return 0;const n=e.date.getDaysTo(i.date);if(!Ct(n)||n===0)return e.value;const o=e.date.getDaysTo(t);return Ct(o)?e.value+(i.value-e.value)*(o/n):0}function ps(t,e,i,n){const o=fs(t,i),s=ms(t,i);return!o||!s||n==="none"?0:n==="step"?o.value:gs(e,o,s)}function ys(t){var i;const e=new Map;for(let n=0;n<t.length;n++){const o=Array.isArray((i=t[n])==null?void 0:i.points)?t[n].points:[];for(let s=0;s<o.length;s++){const r=o[s],a=si(r);a&&e.set(a,r.date)}}return Array.from(e.values()).sort((n,o)=>n.compare(o))}function ws(t,e,i){const n=Array.isArray(t==null?void 0:t.points)?t.points:[];return e.map(o=>{const s=ds(n,o),r=us(n,o,s);return r?{date:o,value:Ct(r.value)?r.value:null,sourcePoint:r,isResolved:!0}:{date:o,value:ps(n,o,s,i),sourcePoint:null,isResolved:!0}})}function bs(t){const e=new Map,i=Array.isArray(t==null?void 0:t.series)?t.series:[],n=ys(i),{interpolation:o}=cn(t),s=i.map(r=>{const l=ws(r,n,o).map(h=>{const c=si(h);if(!Ct(h.value))return{date:h.date,value:null,baseValue:null,sourcePoint:h.sourcePoint,isResolved:!0};const u=c&&e.get(c)||0;return{date:h.date,value:u+h.value,baseValue:u,sourcePoint:h.sourcePoint,isResolved:!0}});for(let h=0;h<l.length;h++){const c=l[h],u=si(c);u&&Ct(c.value)&&e.set(u,c.value)}return{series:r,points:l}});return t._resolvedAreaXDomain=n,t._resolvedStackedAreaSeries=s,t._resolvedStackedAreaDirty=!1,s}function un(t){return(t==null?void 0:t.type)==="area"&&cn(t).active}function dn(t){return(Array.isArray(t==null?void 0:t.series)?t.series:[]).map(i=>{const n=Array.isArray(i==null?void 0:i.points)?i.points.map(o=>({date:o==null?void 0:o.date,value:Ct(o==null?void 0:o.value)?o.value:null,baseValue:Ct(o==null?void 0:o.value)?0:null,sourcePoint:o})):[];return{series:i,points:n}})}function vs(t){return un(t)?t&&t._resolvedStackedAreaDirty!==!0&&Array.isArray(t._resolvedStackedAreaSeries)?t._resolvedStackedAreaSeries:bs(t):dn(t)}function fn(t){return un(t)?vs(t):dn(t)}function Jt(t){return typeof t=="number"&&Number.isFinite(t)}function Re(t){const e=Number(t);return Number.isFinite(e)?e:null}function ri(t,e=5){const i=Number(t),n=Number.isFinite(i)?i:e;return Math.max(2,Math.round(n))}function mn(t){const e=t!=null&&t.scale?Re(t.scale.tickTarget):null;return e!=null?ri(e):Kt.tickTarget}function gn(t,e){const i=e&&e.tokens?e.tokens:null;return!i||!i.start||!i.end||!t.date?!0:!t.date.isAfter(i.end)&&!i.start.isAfter(t.date)}function pn(t,e,i){return!i||!i.start||!i.end||!(t!=null&&t.date)||!(e!=null&&e.date)?!0:t.date.compare(i.end)<=0&&e.date.compare(i.start)>=0}function Ss(t,e){Jt(t)&&(e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),e.hasValues=!0)}function Qt(t,e){Ss(t==null?void 0:t.value,e)}function Ls(t,e){const i=e&&e.tokens?e.tokens:null,n=(t.scale||Kt).source==="viewport",o={min:1/0,max:-1/0,hasValues:!1},s=fn(t);for(let r=0;r<s.length;r++){const a=s[r].points;for(let l=0;l<a.length;l++){const h=a[l];if(!Jt(h==null?void 0:h.value)||((!n||gn(h,e))&&Qt(h,o),!n||l>=a.length-1))continue;const c=a[l+1];Jt(c==null?void 0:c.value)&&pn(h,c,i)&&(Qt(h,o),Qt(c,o))}}return o.hasValues?{min:o.min,max:o.max}:null}function _s(t,e){const i=e&&e.tokens?e.tokens:null,n={min:1/0,max:-1/0,hasValues:!1};for(let o=0;o<t.series.length;o++){const s=t.series[o];for(let r=0;r<s.points.length;r++){const a=s.points[r];if(gn(a,e)&&Qt(a,n),r>=s.points.length-1)continue;const l=s.points[r+1];Jt(a==null?void 0:a.value)&&Jt(l==null?void 0:l.value)&&pn(a,l,i)&&(Qt(a,n),Qt(l,n))}}return n.hasValues?{min:n.min,max:n.max}:null}function As(t,e){if(t.type==="area")return Ls(t,e);if((t.scale||Kt).source==="viewport")return _s(t,e);let o=1/0,s=-1/0,r=!1;for(let a=0;a<t.series.length;a++){const l=t.series[a];for(let h=0;h<l.points.length;h++){const c=l.points[h];Jt(c.value)&&(o=Math.min(o,c.value),s=Math.max(s,c.value),r=!0)}}return r?{min:o,max:s}:null}function ai(t,e){if(t!==e)return{min:t,max:e};const i=Math.abs(t)||1;return{min:t-i*.5,max:e+i*.5}}function li(t,e){if(!Number.isFinite(t)||t<=0)return 1;const i=Math.floor(Math.log10(t)),n=t/Math.pow(10,i);let o;return e?n<1.5?o=1:n<3?o=2:n<7?o=5:o=10:n<=1?o=1:n<=2?o=2:n<=5?o=5:o=10,o*Math.pow(10,i)}function Is(t){if(!Number.isFinite(t))return 0;const e=t.toExponential(),i=Number(e.split("e")[1]);return Math.max(0,-i+1)}function yn(t,e){const i=Math.min(12,Is(e));return Number(t.toFixed(i))}function Ms(t,e,i,n,o){const s=e-t,r=li(s,!1),a=li(r/(ri(i)-1),!0);return{min:n?t:Math.floor(t/a)*a,max:o?e:Math.ceil(e/a)*a}}function Cs(t,e){const i=W(W({},Kt),t.scale||{}),n=As(t,e),o=Re(i.min),s=Re(i.max),r=o!=null,a=s!=null;let l,h;n?(l=n.min,h=n.max):o!=null&&s!=null?(l=o,h=s):o!=null?(l=o,h=o+1):s!=null?(l=s-1,h=s):(l=0,h=1),i.includeZero&&(l=Math.min(0,l),h=Math.max(0,h)),{min:l,max:h}=ai(l,h);const c=Re(i.padding);if(c!=null&&c>0){const u=h-l;l-=u*c,h+=u*c}if(o!=null&&(l=o),s!=null&&(h=s),h<l){const u=l;l=h,h=u}return{min:l,max:h}=ai(l,h),i.tickMode!=="exact"&&({min:l,max:h}=Ms(l,h,mn(t),r,a),{min:l,max:h}=ai(l,h)),{min:l,max:h}}function Ds(t,e,i=5){const n=Math.max(2,Math.round(Number.isFinite(i)?i:5)),o=[],s=(e-t)/(n-1);for(let r=0;r<n;r++)o.push(t+s*r);return o}function Ts(t,e,i=5){const n=ri(i),o=li((e-t)/(n-1),!0),s=[];let r=t;for(;r<e&&s.length<1e3;)s.push(yn(r,o)),r+=o;return(s.length===0||s[s.length-1]!==e)&&s.push(yn(e,o)),s}function Ps(t,e){var o;const i=mn(t);return(((o=t==null?void 0:t.scale)==null?void 0:o.tickMode)||Kt.tickMode)==="exact"?Ds(e.min,e.max,i):Ts(e.min,e.max,i)}function ks(t,e){if(typeof e!="string"||e.length===0)return t;const i=t.split(".");return i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,e),i.join(".")}function Rs(t,e,i){if(typeof e=="function")return e(t);let n;return Math.abs(t)>=1e3||Math.abs(t)<.01?n=Number(t.toPrecision(4)).toString():n=Number(t.toFixed(2)).toString(),ks(n,i)}function X(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function Os(t){const e=t.padding||{};return{top:X(e.top,8),right:X(e.right,12),bottom:X(e.bottom,8),left:X(e.left,48)}}function Es(t){switch(t){case"top-right":case"bottom-left":case"bottom-right":return t;default:return"top-left"}}function Ns(t){const e=t.inset||{};return{x:X(e.x,8),y:X(e.y,8)}}function xs(t,e){const i=t.left+e.left,n=t.top+e.top,o=t.right-e.right,s=t.bottom-e.bottom;return{left:i,top:n,right:o,bottom:s,width:Math.max(0,o-i),height:Math.max(0,s-n)}}function te(t,e,i){return i.bottom-(t-e.min)/(e.max-e.min)*i.height}function ee(t,e,i){return Math.max(e,Math.min(i,t))}function wn(t,e){const i=e&&e.tokens?e.tokens:null;if(!i||!i.start||!i.end||t.length===0)return{start:0,end:t.length-1};let n=0,o=t.length;for(;n<o;){const a=Math.floor((n+o)/2);t[a].date.compare(i.start)<0?n=a+1:o=a}const s=n;if(s===t.length)return{start:t.length-1,end:t.length-1};for(n=s,o=t.length;n<o;){const a=Math.floor((n+o)/2);t[a].date.compare(i.end)<=0?n=a+1:o=a}const r=n;return{start:Math.max(0,s-1),end:Math.min(t.length-1,r)}}function hi(t,e){t.beginPath(),t.moveTo(e.left,e.top),t.lineTo(e.right,e.top),t.lineTo(e.right,e.bottom),t.lineTo(e.left,e.bottom),t.closePath(),t.clip()}function zs(t,e,i){const n=e.x-t.x,o=e.y-t.y;let s=0,r=1,a=null,l=null;const h=[[-n,t.x-i.left],[n,i.right-t.x],[-o,t.y-i.top],[o,i.bottom-t.y]];for(let u=0;u<h.length;u++){const[m,d]=h[u];if(m===0){if(d<0)return null;continue}const g=d/m;if(m<0?g>s&&(s=g,a=u):g<r&&(r=g,l=u),s>r)return null}const c=(u,m)=>{if(u===0)return t;if(u===1)return e;const d={x:ee(t.x+n*u,i.left,i.right),y:ee(t.y+o*u,i.top,i.bottom)};return m===0?d.x=i.left:m===1?d.x=i.right:m===2?d.y=i.top:m===3&&(d.y=i.bottom),d};return{from:c(s,a),to:c(r,l)}}function Fs(t,e){return t&&e&&t.x===e.x&&t.y===e.y}function bn(t,e,i){if(t.length===0)return t;const n=[];let o=t[t.length-1],s=e(o);for(let r=0;r<t.length;r++){const a=t[r],l=e(a);l?(s||n.push(i(o,a)),n.push(a)):s&&n.push(i(o,a)),o=a,s=l}return n}function Bs(t,e){const i=(s,r,a)=>bn(s,l=>a?l.x>=r:l.x<=r,(l,h)=>{const c=(r-l.x)/(h.x-l.x);return{x:r,y:ee(l.y+(h.y-l.y)*c,e.top,e.bottom)}}),n=(s,r,a)=>bn(s,l=>a?l.y>=r:l.y<=r,(l,h)=>{const c=(r-l.y)/(h.y-l.y);return{x:ee(l.x+(h.x-l.x)*c,e.left,e.right),y:r}});let o=i(t,e.left,!0);return o=i(o,e.right,!1),o=n(o,e.top,!0),n(o,e.bottom,!1)}function Hs(t,e,i){i.backgroundColor&&(t.fillStyle=i.backgroundColor,t.fillRect(e.left,e.top,e.width,e.height))}function Ys(t,e,i,n,o){const s=e.style||{},r=s.gridLine||{},a=s.axis||{},l=s.yAxis||{},h=Ps(e,n);Vs(t,i,r,e.owner,o);const c=r.y&&r.y.major?r.y.major:{};if(c.visible!==!1){t.beginPath(),t.lineWidth=X(c.thickness,1),t.strokeStyle=c.color||"rgba(120, 120, 120, 0.24)";for(let u=0;u<h.length;u++){const m=Math.round(te(h[u],n,i))+.5;t.moveTo(i.left,m),t.lineTo(i.right,m)}t.stroke()}if(a.visible!==!1&&(t.beginPath(),t.lineWidth=X(a.lineWidth,1),t.strokeStyle=a.color||"rgba(80, 80, 80, 0.45)",t.moveTo(i.left,i.top),t.lineTo(i.left,i.bottom),t.lineTo(i.right,i.bottom),t.stroke()),l.visible!==!1){t.font=l.font||"normal 11px Calibri",t.fillStyle=l.color||"#555",t.textAlign="right",t.textBaseline="middle";const u=X(l.margin,6);for(let m=0;m<h.length;m++){const d=te(h[m],n,i);t.fillText(Rs(h[m],l.formatter,l.thousandsSeparator),i.left-u,d)}}}function vn(t,e){const i=t&&t.markers?t.markers:null,n=i?i[e]:null;return Array.isArray(n)?n:[]}function Ws(t,e){var n;if(e<=0)return!0;const i=(n=t==null?void 0:t.timescaleManager)==null?void 0:n.unitSizeInPixels;return typeof i!="number"||!Number.isFinite(i)?!0:i>=e}function Sn(t,e,i,n,o=0){if(!(!n||n.visible!==!0||i.length===0)){t.beginPath(),t.lineWidth=X(n.thickness,1),t.strokeStyle=n.color||"rgba(0, 0, 0, 0.08)";for(let s=0;s<i.length;s++){const r=i[s];if(r.adaptive&&r.markerSpacingInPixels<o||typeof r.drawX!="number"||!Number.isFinite(r.drawX))continue;const a=Math.round(r.drawX)+.5;a<e.left||a>e.right||(t.moveTo(a,e.top),t.lineTo(a,e.bottom))}t.stroke()}}function Vs(t,e,i,n,o){const s=i.x||{},r=s.major||{},a=s.minor||{},l=Math.max(0,X(a.minimumSpacing,20));Sn(t,e,vn(o,F),r),Ws(n,l)&&Sn(t,e,vn(o,k),a,l)}function Zs(t,e,i){const n=e.style.legend||{},o=n.visible==null?"auto":n.visible,s=e.series.filter(v=>v.title);if(o===!1||o==="auto"&&s.length<2)return;t.save(),t.font=n.font||"normal 12px Calibri",t.fillStyle=n.color||"#333",t.textAlign="left",t.textBaseline="middle";const r=X(n.markerSize,10),a=X(n.markerGap,4),l=X(n.itemGap,12),h=Ns(n),c=Es(n.position),u=[],m=Math.max(0,i.width-h.x);let d=0;for(let v=0;v<s.length;v++){const S=s[v],M=t.measureText(S.title).width,P=r+a+M,E=d===0?P:d+l+P;if(E>m)break;u.push({series:S,entryWidth:P}),d=E}const g=c==="top-right"||c==="bottom-right",p=c==="bottom-left"||c==="bottom-right";let w=g?i.right-h.x-d:i.left+h.x;const b=p?i.bottom-h.y-r/2:i.top+h.y+r/2;for(let v=0;v<u.length;v++){const S=u[v];t.fillStyle=S.series.style.color,t.fillRect(w,b-r/2,r,r),t.fillStyle=n.color||"#333",t.fillText(S.series.title,w+r+a,b),w+=S.entryWidth+l}t.restore()}function Ln(t,e,i,n,o,s,r=i.points){const a=i.style||{},l=X(a.lineWidth,2);t.save(),hi(t,o),t.beginPath(),t.lineWidth=l,t.strokeStyle=a.color||"#2563eb",Array.isArray(a.lineDash)&&typeof t.setLineDash=="function"&&t.setLineDash(a.lineDash);let h=null,c=null;const u=wn(r,s);for(let m=u.start;m<=u.end;m++){const d=r[m];if(typeof d.value!="number"||!Number.isFinite(d.value)){h=null,c=null;continue}const g=e.getPixel(d.date,s),p=te(d.value,n,o),w={x:g,y:p};if(h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&Number.isFinite(w.x)&&Number.isFinite(w.y)){const b=zs(h,w,o);b?(Fs(c,b.from)||t.moveTo(b.from.x,b.from.y),t.lineTo(b.to.x,b.to.y),c=b.to):c=null}h=w}t.stroke(),typeof t.setLineDash=="function"&&t.setLineDash([]),t.restore()}function Us(t,e,i,n,o,s){const r=i.series||{},a=i.points||[],l=r.style||{},h=l.area||{},c=ee(X(h.opacity,.2),0,1);t.save(),hi(t,o),t.fillStyle=h.fillColor||l.color||"#2563eb",t.globalAlpha=X(t.globalAlpha,1)*c;let u=[];const m=wn(a,s),d=()=>{if(u.length===0)return;const g=[];for(let w=0;w<u.length;w++)g.push({x:u[w].x,y:u[w].y});for(let w=u.length-1;w>=0;w--)g.push({x:u[w].x,y:u[w].baseY});const p=Bs(g,o);if(p.length>=3){t.beginPath(),t.moveTo(p[0].x,p[0].y);for(let w=1;w<p.length;w++)t.lineTo(p[w].x,p[w].y);t.closePath(),t.fill()}u=[]};for(let g=m.start;g<=m.end;g++){const p=a[g];if(typeof p.value!="number"||!Number.isFinite(p.value)||typeof p.baseValue!="number"||!Number.isFinite(p.baseValue)){d();continue}const w=e.getPixel(p.date,s),b=te(p.value,n,o),v=ee(te(p.baseValue,n,o),o.top,o.bottom);u.push({x:w,y:b,baseY:v})}d(),t.restore()}function _n(t,e,i,n,o,s,r=i.points,a={}){var u;const l=((u=i.style)==null?void 0:u.point)||{};if(l.visible!==!0)return;const h=X(l.radius,2.5),c=X(l.lineWidth,1);t.save(),hi(t,o),t.lineWidth=c,t.fillStyle=l.fillColor||i.style.color||"#2563eb",t.strokeStyle=l.strokeColor||"#fff";for(let m=0;m<r.length;m++){const d=r[m];if(a.sourcePointsOnly&&!d.sourcePoint||typeof d.value!="number"||!Number.isFinite(d.value))continue;const g=e.getPixel(d.date,s);if(g<o.left-h||g>o.right+h)continue;const p=te(d.value,n,o);t.beginPath(),t.arc(g,p,h,0,Math.PI*2),t.fill(),c>0&&t.stroke()}t.restore()}function An({chart:t,ctx:e,geometry:i,drawCycleContext:n,stackArea:o=!1}){if(!i||i.width<=0||i.height<=0)return;const s=t.style||{},r=Os(s),a=xs(i,r);if(a.width<=0||a.height<=0)return;const l=t.getScaleDomain(n);Hs(e,i,s),Ys(e,t,a,l,n);const h=o?fn(t):t.series;for(let c=0;c<h.length;c++)if(o){const u=h[c];Us(e,t.owner,u,l,a,n),Ln(e,t.owner,u.series,l,a,n,u.points),_n(e,t.owner,u.series,l,a,n,u.points,{sourcePointsOnly:!0})}else Ln(e,t.owner,h[c],l,a,n),_n(e,t.owner,h[c],l,a,n);Zs(e,t,a)}function Gs(t){An(t)}function js(t){An(Ft(W({},t),{stackArea:!0}))}an("line",Gs),an("area",js);function ie(t,e,...i){return typeof t=="function"?t.call(e,...i):t}function Wt(t,e=null){const i=parseInt(t,10);return Number.isFinite(i)?i:e}function $s(t,e){if(!e||typeof e!="object")return null;const i=Wt(e.year);if(i==null)return null;const n=Wt(e.month,1),o=Wt(e.day,1),s=me(e);let r=new y({year:i,month:n,day:o,precision:s,hour:Wt(e.hour,0),minute:Wt(e.minute,0),second:Wt(e.second,0),millisecond:Wt(e.millisecond,0)});return r=t.getDmyFromInput(r),y.CreateAsStartOfPeriod(r,s)}function Xs(t,e){if(!e||typeof e!="object")return null;const i=$s(t,e.date);if(!i)return null;const n=e.value===null?null:Number(e.value);return{date:i,value:Number.isFinite(n)?n:null}}function qs(t,e){return t!=null&&Object.prototype.hasOwnProperty.call(t,e)}function Ks(t){return qs(t==null?void 0:t.style,"color")}function Js(t){var e;return!!((e=t==null?void 0:t.series)!=null&&e.color)}function Qs(t,e){const i=Array.isArray(t==null?void 0:t._seriesColors)?t._seriesColors:[];for(let n=0;n<i.length;n++)if(i[n].id===e)return i[n].color}function tr(t,e,i){if(t){Array.isArray(t._seriesColors)||(t._seriesColors=[]);for(let n=0;n<t._seriesColors.length;n++)if(t._seriesColors[n].id===e){t._seriesColors[n].color=i;return}t._seriesColors.push({id:e,color:i})}}function er(t){const e=t&&t.seriesColors;if(!Array.isArray(e))return oi;const i=e.filter(n=>typeof n=="string"&&n.length>0);return i.length>0?i:oi}function ir(t,e,i,n,o,s){const r=i||{},a=L({},ln,e.series||{});a.color||(a.color=o||s[n%s.length]);const l=Array.isArray(r.points)?r.points.map(h=>Xs(t,h)).filter(Boolean):[];return l.sort((h,c)=>h.date.compare(c.date)),{id:r.id!=null?r.id:n,title:r.title||"",style:L({},a,r.style||{}),points:l}}function In(t,e){return t&&t.id!=null?t.id:e}function Mn(t){const e=t._getResolvedData();return Array.isArray(e.series)?e.series.slice():[]}function Cn(t,e){t.data||(t.data={id:t.id}),t.data.series=e,t._resolveFromData(),t.owner&&typeof t.owner.requestRedraw=="function"&&t.owner.requestRedraw()}function ht(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.type="line",this.title="",this.laneId=null,this.area=null,this.scale={},this.typeOptions={},this.style={},this.series=[],this._seriesColors=[],this._resolvedAreaXDomain=[],this._resolvedStackedAreaSeries=null,this._resolvedStackedAreaDirty=!0}ht.prototype.setupByReceivedData=function(t){this.data=L({},t||{}),this.id=this.data.id!=null?this.data.id:this.id,this._resolveFromData(),this.isDataLoaded=!0},ht.prototype._getResolvedData=function(){const t=this.owner&&this.owner.options?this.owner.options.chart||{}:{},e=L({},t.defaultData||{});return delete e.id,L({},e,this.data||{})},ht.prototype._resolveFromData=function(){const t=this.owner&&this.owner.options?this.owner.options.chart||{}:{},e=this._getResolvedData(),i=_(e,"type")||"line",n=_(e,"lane");this.type=i==="line"?i:String(i),this.title=_(e,"title")||"",this.laneId=n!=null&&n!==""?n:null,this.area=_(e,"area")||null,this.scale=L({},Kt,_(e,"scale")||{}),this.typeOptions=L({},hs,_(e,"typeOptions")||{}),this.style=L({},hn,t.defaultStyle||{},_(e,"style")||{});const o=Array.isArray(e.series)?e.series:[],s=er(t);this.series=o.map((r,a)=>{const l=In(r,a),h=Qs(this,l),c=ir(this.owner,this.style,r,a,h,s);return(Ks(r)||!Js(this.style))&&tr(this,l,c.style.color),c}),this._resolvedStackedAreaDirty=!0},ht.prototype.addSeries=function(t){const e=Mn(this);e.push(t||{}),Cn(this,e)},ht.prototype.removeSeriesById=function(t){const e=Mn(this);for(let i=0;i<e.length;i++)if(In(e[i],i)===t)return e.splice(i,1),Cn(this,e),!0;return!1},ht.prototype.getSeriesById=function(t){for(let e=0;e<this.series.length;e++){const i=this.series[e];if(i.id===t)return i}},ht.prototype.getScaleDomain=function(t){return Cs(this,t)},ht.prototype.draw=function(t,e,i){const n=ls(this.type);if(!n){T.warn(`Unknown chart type "${this.type}". Skipping chart render.`,{chartId:this.id});return}n({chart:this,ctx:t,geometry:e,drawCycleContext:i})},ht.prototype.setOption=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.data,t);t=bt(t,e)}t=L({},t);const i=A(t,"lane");if(!(A(t,"id")&&(T.warn("Ignoring chart id change; chart ids are immutable after load",{chartId:this.id,nextId:_(t,"id")}),delete t.id,Object.keys(t).length===0))){if(L(this.data,t),i&&this.owner&&typeof this.owner._ensureChartLane=="function"){const o=_(this.data,"lane");o!=null&&o!==""&&this.owner._ensureChartLane(o)}this._resolveFromData(),i&&this.owner&&(typeof this.owner._refreshLaneOrder=="function"&&this.owner._refreshLaneOrder(),typeof this.owner._updateLaneLayout=="function"&&this.owner._updateLaneLayout()),this.owner.requestRedraw()}},ht.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t),this._resolveFromData(),this.owner.requestRedraw()},Object.defineProperty(ht.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=ie(t,this,this);return e==="visible"||e==="hidden"?e:(T.warn("Invalid Chart.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{chartId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});const nr=["defaultCardLayout","defaultStyle","defaultHoverStyle","defaultActiveStyle","layoutStyles"],or=["defaultData","density","distanceToBaseline","autoStacking.active","autoStacking.rowSpacing","autoStacking.fitToHeight","autoStacking.topGap","periodLine.baselineGap","periodLine.spacing","periodLine.thickness"];function Dn(t,e){if(!t||typeof t!="object")return!1;for(let i=0;i<e.length;i++)if(A(t,e[i]))return!0;return!1}function ge(t){return typeof t=="number"&&Number.isFinite(t)}function ci(t,e,i){return Math.min(Math.max(t,e),i)}function Tn(t){const e=Dn(t,nr);return{cacheChanged:e||Dn(t,or),styleChanged:e}}function Pn(t={},e={}){const i=t||{},n=e||{},o=i.autoStacking||{},s=n.autoStacking||{},r=i.periodLine||{},a=n.periodLine||{};return{defaultData:L({},i.defaultData||{},n.defaultData||{}),density:Object.prototype.hasOwnProperty.call(n,"density")?n.density:i.density,distanceToBaseline:L({},i.distanceToBaseline||{},n.distanceToBaseline||{}),defaultCardLayout:Object.prototype.hasOwnProperty.call(n,"defaultCardLayout")?n.defaultCardLayout:i.defaultCardLayout,defaultStyle:L({},i.defaultStyle||{},n.defaultStyle||{}),defaultHoverStyle:L({},i.defaultHoverStyle||{},n.defaultHoverStyle||{}),defaultActiveStyle:L({},i.defaultActiveStyle||{},n.defaultActiveStyle||{}),layoutStyles:L({},i.layoutStyles||{},n.layoutStyles||{}),autoStacking:{active:A(n,"autoStacking.active")?s.active:o.active,rowSpacing:A(n,"autoStacking.rowSpacing")?s.rowSpacing:o.rowSpacing,fitToHeight:A(n,"autoStacking.fitToHeight")?s.fitToHeight:o.fitToHeight,topGap:A(n,"autoStacking.topGap")?s.topGap:o.topGap},periodLine:{baselineGap:A(n,"periodLine.baselineGap")?a.baselineGap:r.baselineGap,spacing:A(n,"periodLine.spacing")?a.spacing:r.spacing,thickness:A(n,"periodLine.thickness")?a.thickness:r.thickness}}}function sr(t,e,i,n){var p;if(!t||t.active!==!0)return null;const o=t.lanesOnly!==!1;if(!i&&o)return null;const s=(p=t.byCardLayout)==null?void 0:p[n];if(!s)return null;const r=Math.max(0,ge(e)?e:0),a=Math.max(0,ge(s.ratio)?s.ratio:0),l=ge(s.min)?s.min:0,h=ge(s.max)?s.max:Number.POSITIVE_INFINITY,c=Math.max(0,Math.min(l,h)),u=Math.max(c,h),m=ci(c,0,r),d=ci(u,m,r),g=Math.round(r*a);return ci(g,m,d)}function Oe(t,e,i,n){const o=sr(t==null?void 0:t.responsive,e,i,n);return Number.isFinite(o)?o:ge(t==null?void 0:t.value)?t.value:0}const rr={from:{},to:{},rank:0,starred:!1,hidePeriodLine:!1,hiddenByFilter:!1},ar={width:150,color:"#e5e5e5",backgroundColor:"#fff",topRadius:3,maxImageHeight:400,image:{shape:"natural",margin:0,maxHeight:200,borderRadius:0},header:{height:50,text:{font:"normal 14px 'Segoe UI'",align:"left",baseline:"middle",margin:10,color:"#333",lineHeight:18,numberOfLines:2,offsetY:0}},subheader:{height:30,color:"#555",text:{font:"normal 11px 'Segoe UI'",color:"#eee",align:"left",baseline:"middle",margin:10,lineHeight:6,offsetY:0}},shadow:{x:0,y:0,amount:0,color:"#000"},border:{color:"#ddd",width:1},connectorLine:{visible:!0,offsetX:18,offsetY:-20,thickness:1,arrow:{width:16,height:45}},star:{width:16,margin:3}},lr={color:"#a6c6e2"},hr={color:"#337ab7",header:{text:{color:"#fff"}},subheader:{color:"#333"},shadow:{x:3,y:3,amount:5,color:"#333"},border:{width:2,color:"#2e6da4"},connectorLine:{thickness:2}},cr={heightWeight:1,header:{visible:!0,height:24,padding:{left:12,right:12}}},ur={header:{},body:{},title:{}},dr={backgroundColor:"rgba(200, 200, 200, 0.25)",border:{color:"rgba(120, 120, 120, 0.25)",width:1},text:{font:"normal 16px Calibri",color:"#555",align:"left",baseline:"bottom",verticalAlign:"bottom",margin:4,offsetY:0}},kn="#cdd2d8",Rn={width:1e3,height:500,verticalOffset:40,enableUserControl:!0,enableCursor:!0,canvas:{dpr:"auto",dprMode:"stable",maxDpr:3},debugOverlays:{densityRegions:!1},zoom:{initial:34,minimum:0,maximum:123,wheelStep:.2,wheelSpeed:3,allowCtrlWheel:!1,wheelMode:"auto",discreteWheelAnimation:{active:!0,duration:250},proportionalGain:2,proportionalExponent:1.1,ratio:.8,unitSize:{initial:200,showMinorLabels:48,minimum:8,minimumMajor:120}},initialDate:{year:1990,month:1,day:1},bounds:{minDate:null,maxDate:null,overflow:"elastic"},shiftBceDates:!1,draggingVicinity:!0,pan:{momentum:{active:!0,sampleWindow:100,minVelocity:.01,stopVelocity:.005,friction:.005,maxDuration:5600}},style:{mainLine:{visible:!0,position:"bottom",size:8,color:kn,opacity:.75,dateIndicators:{visible:!0,shape:"rectangle",size:4,color:"#666",opacity:1,hiddenStyle:{opacity:.25},activeStyle:{color:"article",opacity:1}}},draggingHighlight:{visible:!0,color:"rgba(237, 247, 255, 0.5)",area:{up:0,down:"edge"}},marker:{minor:{height:12,extend:!1,color:"#6097f2",futureColor:"#ccc"},major:{height:30,extend:!1,color:"#0c3a88",futureColor:"#ccc"}},dateLabel:{minor:{font:"normal 10px Calibri",color:"#333",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},bceText:"",thousandsSeparator:",",yearPrefixes:{ka:{label:"ka",value:1e3,minDivision:1e3},Ma:{label:"Ma",value:1e6,minDivision:1e5},Ga:{label:"Ga",value:1e9,minDivision:1e8}}},major:{font:"normal 16px Calibri",color:"#000",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},sticky:{enabled:"auto",offsetX:4},bceText:" ʙᴄᴇ",thousandsSeparator:",",yearPrefixes:{ka:{label:"ka",value:1e3,minDivision:1e5},Ma:{label:"Ma",value:1e6,minDivision:1e6},Ga:{label:"Ga",value:1e9,minDivision:1e9}}},parent:{visible:!1,levels:"all",height:20,font:"normal 14px Calibri",color:"#444",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},sticky:{enabled:!0,offsetX:4}}},cursor:{timeline:{hover:"default",dragging:"e-resize"},clickable:"pointer",article:{hoverDraggable:"move",dragging:"move"}}},timeBand:{visible:!0,reserveSpace:!0,reserveSpacePixels:20,area:{up:0,down:"edge"},defaultStyle:dr,data:[]},chart:{visible:!0,area:{up:"edge",down:0},seriesColors:[...oi],defaultData:{},defaultStyle:L({},hn),data:[]},lane:{visible:!0,defaultId:"default",gap:0,topGap:0,axisGap:0,defaultLayout:L({},cr),defaultStyle:L({},ur),defaultClassName:"",defaultHeaderClassName:"",defaultBodyClassName:"",defaultTitleClassName:"",data:[]},image:{maxConcurrent:6,maxCacheBytes:64*1024*1024,requireCORS:!1,decodeMode:"auto",sanitizer:{allowedSchemes:["http","https","data","blob"]}},article:{density:"all",rendering:{pixelSnap:"device"},draggable:!0,distanceToBaseline:{value:350,responsive:{active:!0,lanesOnly:!0,byCardLayout:{portrait:{ratio:.6,min:310,max:410},landscape:{ratio:.6,min:100,max:160}}}},collectOngoing:!1,autoStacking:{active:!0,rowSpacing:50,range:"all",fitToHeight:!0,topGap:10},periodLine:{position:"lane",baselineGap:0,spacing:4,thickness:10,stacking:{sorter:sn,reverseOrder:!1}},animation:{fade:{active:!0,duration:1500,easing:"swing"},move:{active:!0,duration:1500,easing:"swing"}},star:{visible:!0},defaultData:W({},rr),defaultCardLayout:"portrait",cardLayoutBreakpoints:[{maxHeight:320,layout:"landscape"}],defaultStyle:W({},ar),defaultHoverStyle:W({},lr),defaultActiveStyle:W({},hr),layoutStyles:{}}};function fr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function ui(t,e){T.warn(`DEPRECATION WARNING: ${t} is deprecated. Use ${e} instead.`)}const mr=new Set(["rectangle","circle"]);function di(t,e,{allowVisible:i=!1}={}){if(t!==void 0){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object`);if(i&&t.visible!==void 0&&typeof t.visible!="boolean")throw new TypeError(`${e}.visible must be a boolean`);if(t.shape!==void 0&&!mr.has(t.shape))throw new TypeError(`${e}.shape must be "rectangle" or "circle"`);if(t.size!==void 0&&(typeof t.size!="number"||!Number.isFinite(t.size)||t.size<=0))throw new TypeError(`${e}.size must be a positive finite number`);if(t.color!==void 0&&typeof t.color!="string")throw new TypeError(`${e}.color must be a CSS colour string or "article"`);if(t.opacity!==void 0&&(typeof t.opacity!="number"||!Number.isFinite(t.opacity)||t.opacity<0||t.opacity>1))throw new TypeError(`${e}.opacity must be a finite number between 0 and 1`)}}function gr(t){var i,n;const e=(n=(i=t==null?void 0:t.style)==null?void 0:i.mainLine)==null?void 0:n.dateIndicators;di(e,"style.mainLine.dateIndicators",{allowVisible:!0}),di(e==null?void 0:e.hiddenStyle,"style.mainLine.dateIndicators.hiddenStyle"),di(e==null?void 0:e.activeStyle,"style.mainLine.dateIndicators.activeStyle")}function On(t,e,i){(t==null?void 0:t.distanceToMainLine)!==void 0&&(ui(`${i}.distanceToMainLine`,`${i}.distanceToBaseline.value`),e&&((!e.distanceToBaseline||typeof e.distanceToBaseline!="object")&&(e.distanceToBaseline={}),fr(e.distanceToBaseline,"value")||(e.distanceToBaseline.value=t.distanceToMainLine),delete e.distanceToMainLine))}function En(t){if(typeof t!="string")return t;const e=t.replace(/(^article\.|\.article\.)distanceToMainLine$/,"$1distanceToBaseline.value").replace(/^chart\.gridLine(?=\.|$)/,"chart.defaultStyle.gridLine");return e!==t&&ui(t,e),e}function fi(t){var i;if(!t)return t;const e=L({},t);return((i=t.article)==null?void 0:i.distanceToMainLine)!==void 0&&(e.article||(e.article={}),On(t.article,e.article,"lane.article")),e}function Nn(t){var n,o,s,r,a,l;if(!t)return t;gr(t);const e=L({},t);if(((n=t.chart)==null?void 0:n.gridLine)!==void 0&&(ui("chart.gridLine","chart.defaultStyle.gridLine"),e.chart.defaultStyle||(e.chart.defaultStyle={}),e.chart.defaultStyle.gridLine=L({},t.chart.gridLine,((o=t.chart.defaultStyle)==null?void 0:o.gridLine)||{}),delete e.chart.gridLine),((s=t.article)==null?void 0:s.distanceToMainLine)!==void 0&&(e.article||(e.article={}),On(t.article,e.article,"article")),Array.isArray((r=t.lane)==null?void 0:r.data)){e.lane||(e.lane={}),e.lane.data=e.lane.data||[];for(let h=0;h<t.lane.data.length;h++)e.lane.data[h]=fi(t.lane.data[h])}if(((l=(a=t.article)==null?void 0:a.periodLine)==null?void 0:l.defaultHide)!==void 0&&(T.warn("DEPRECATION WARNING: article.periodLine.defaultHide is deprecated. Use article.defaultData.hidePeriodLine instead."),e.article||(e.article={}),e.article.defaultData||(e.article.defaultData={}),e.article.defaultData.hidePeriodLine=t.article.periodLine.defaultHide),["defaultStyle","defaultHoverStyle","defaultActiveStyle"].forEach(h=>{var c,u;((u=(c=t.article)==null?void 0:c[h])==null?void 0:u.maxImageHeight)!==void 0&&(T.warn(`DEPRECATION WARNING: article.${h}.maxImageHeight is deprecated. Use article.${h}.image.maxHeight instead.`),e.article||(e.article={}),e.article[h]||(e.article[h]={}),e.article[h].image||(e.article[h].image={}),e.article[h].image.maxHeight=t.article[h].maxImageHeight)}),t.onSave!==void 0&&(T.warn('DEPRECATION WARNING: onSave is deprecated. Use options.on["timeline-state-change"] instead.'),e.on||(e.on={}),!e.on["timeline-state-change"])){const h=t.onSave;typeof h=="function"&&(e.on["timeline-state-change"]=function(c){h.call(this,c)})}if(t.onArticleClick!==void 0&&(T.warn('DEPRECATION WARNING: onArticleClick is deprecated. Use options.on["article-click"] for click events, or options.on["article-select"] for selection by any means.'),e.on||(e.on={}),!e.on["article-click"])){const h=t.onArticleClick;typeof h=="function"&&(e.on["article-click"]=function(c,u){h.call(this,c)})}if(t.onArticleDoubleClick!==void 0&&(T.warn('DEPRECATION WARNING: onArticleDoubleClick is deprecated. Use options.on["article-dblclick"] instead.'),e.on||(e.on={}),!e.on["article-dblclick"])){const h=t.onArticleDoubleClick;typeof h=="function"&&(e.on["article-dblclick"]=function(c,u){h.call(this,c)})}if(t.onRedraw!==void 0){if(T.warn('DEPRECATION WARNING: onRedraw is deprecated. Use options.on["timeline-render-end"] instead.'),e.on||(e.on={}),!e.on["timeline-render-end"]){const h=t.onRedraw;typeof h=="function"&&(e.on["timeline-render-end"]=function(c){h.call(this,c)})}delete e.onRedraw}return e}const mi=L({},Rn);function et(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.isImplicit=!1,this.order=0,this.title="",this.className="",this.headerClassName="",this.bodyClassName="",this.titleClassName="",this.layout={},this.style={},this.articleOptions={},this.resolvedArticleOptions={},this._runtimeArticleOptions={},this.geometry=null,this.currentVisibility="visible"}et.prototype.setupByReceivedData=function(t,{implicit:e=!1}={}){this.data=fi(t),this.isImplicit=!!e,this._resolveFromData(),this.isDataLoaded=!0},et.prototype._resolveFromData=function(){var i,n;const t=this.owner&&this.owner.options?this.owner.options.lane||{}:{},e=this.data||{};this.title=_(e,"title")||"",this.className=_(e,"className")||"",this.headerClassName=_(e,"headerClassName")||"",this.bodyClassName=_(e,"bodyClassName")||"",this.titleClassName=_(e,"titleClassName")||"",this.layout=L({},t.defaultLayout||{},e.layout||{}),this.style=L({},t.defaultStyle||{},e.style||{}),this.articleOptions=L({},e.article||{}),this.resolvedArticleOptions=Pn(((n=(i=this.owner)==null?void 0:i.options)==null?void 0:n.article)||{},this.articleOptions)},et.prototype._applyOption=function(t,{suppressRedraw:e=!1,markExplicit:i=!1,suppressArticleRefresh:n=!1}={}){if(!t||typeof t!="object")return;t=fi(t);const o=this.id,s=A(t,"id")?t.id:o;if(s!==o){const a=this.owner.getLaneById(s);if(a&&a!==this)throw new Error(`Lane "${s}" already exists`)}L(this.data,t),i&&(this.isImplicit=!1),s!==o&&(this.id=s);const r=Tn(_(t,"article"));return this._resolveFromData(),s!==o&&this.owner._handleLaneIdChange(this,o),r.styleChanged&&!n&&this.owner._refreshArticlesForLane(this,{refreshStyles:!0}),this.owner._handleLaneChange({requestRedraw:!e}),{articleImpact:r,idChanged:s!==o,laneId:this.id}},et.prototype.setOption=function(t,e){if(typeof t=="string"){const i=En(t);if(typeof e=="undefined")return _(this.data,i);t=bt(i,e)}this._applyOption(t)},et.prototype.hide=function(){this.setOption("visibility","hidden")},et.prototype.show=function(){this.setOption("visibility","visible")},et.prototype.moveToIndex=function(t){return this.owner.moveLaneToIndex(this,t)},et.prototype.moveBefore=function(t){return this.owner.moveLaneBefore(this,t)},et.prototype.moveAfter=function(t){return this.owner.moveLaneAfter(this,t)},et.prototype.moveUp=function(){return this.owner.moveLaneUp(this)},et.prototype.moveDown=function(){return this.owner.moveLaneDown(this)},et.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t),this._resolveFromData(),this.owner._handleLaneChange({requestRedraw:!0,refreshOrder:!1})},Object.defineProperty(et.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=ie(t,this,this);return e==="visible"||e==="hidden"?e:(T.warn("Invalid Lane.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{laneId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});function Dt(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.title="",this.style={},this.period={from:null,to:null,isToPresent:!1}}Dt.prototype.setupByReceivedData=function(t){this.data=W({},t),this.title=_(t,"title")||"",this.style=_(t,"style")||{},this._setupPeriod(t),this.isDataLoaded=!0},Dt.prototype._setupPeriod=function(t){let e=Pe(t,"from");e=this.owner.getDmyFromInput(e);const i=e.precision,n=_(t,"isToPresent"),o=n===!0||n===1;let s,r;o?s=y.now():A(t,"to")?(s=Pe(t,"to"),s=this.owner.getDmyFromInput(s),r=s.precision):(s=e,r=i);const a=y.CreateAsStartOfPeriod(e,i),l=y.CreateAsExclusiveEndOfPeriod(s,r);this.period={from:a,to:l,isToPresent:o}},Dt.prototype.overlapsInclusiveWithDates=function(t,e){return!(this.period.from.isAfter(e)||t.isAfter(this.period.to))},Dt.prototype.setOption=function(t,e){let i=!1;if(typeof t=="string"){if(typeof e=="undefined")return _(this.data,t);t=bt(t,e)}if(L(this.data,t),A(t,"id")&&(this.id=t.id),A(t,"title")&&(this.title=t.title),(A(t,"from")||A(t,"to")||A(t,"isToPresent"))&&(this._setupPeriod(this.data),i=!0),A(t,"style")){const n=this.owner.options.timeBand&&this.owner.options.timeBand.defaultStyle||{};this.style=L({},n,this.data.style||{})}i?this.owner.requestRedraw():this.owner.requestRedraw(this.owner.redraw)},Dt.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t);const i=this.owner.options.timeBand&&this.owner.options.timeBand.defaultStyle||{};this.style=L({},i,this.data.style||{}),this.owner.requestRedraw()},Object.defineProperty(Dt.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=ie(t,this,this);return e==="visible"||e==="hidden"?e:(T.warn("Invalid TimeBand.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{bandId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});function pr(t,e,i){if(i>=t.length){let n=i-t.length;for(;n--+1;)t.push(void 0)}return t.splice(i,0,t.splice(e,1)[0]),t}function yr(t,e){if(t.length===0)return-1;let i=0,n=t[0][e];for(let o=1;o<t.length;o++)t[o][e]<n&&(n=t[o][e],i=o);return i}function gi(t){return t==="screen"||t===1}class wr{constructor(e){this.invalidateCb=e,this.seen=new Set,this.loading=new Set,this.loaded=new Set,typeof document!="undefined"&&document.fonts&&document.fonts.addEventListener&&document.fonts.addEventListener("loadingdone",i=>{for(const n of i.fontfaces)this._notifyFamily(n.family)})}use(e){!e||this.loading.has(e)||this.loaded.has(e)||(this.seen.add(e),typeof document!="undefined"&&document.fonts&&document.fonts.load&&(this.loading.add(e),document.fonts.load(e).then(()=>{this.loading.delete(e),this.loaded.add(e),this.invalidateCb(e)}).catch(i=>{T.warn("[FontWatcher] Font load failed:",e,i),this.loading.delete(e)})))}_notifyFamily(e){for(const i of this.seen)i.includes(e)&&(this.loading.delete(i),this.loaded.add(i),this.invalidateCb(i))}}const br=64*1024*1024,vr=new Set(["square","circle"]),Sr=new Set(["auto","prefer-bitmap","bitmap","prefer-img","img"]);function Vt(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function ct(t){return Math.max(1,Math.floor(t||0))}class Lr{constructor(e={}){const{maxConcurrent:i=6,maxCacheBytes:n,requireCORS:o=!1,decodeMode:s="auto"}=e;this.maxConcurrent=Math.max(1,i|0),this.requireCORS=!!o;let r;typeof n=="number"?r=Number.isFinite(n)?Math.max(0,n):1/0:r=br,this.maxCacheBytes=r;let a=typeof s=="string"?s.toLowerCase():"auto";Sr.has(a)||(a="auto"),this.decodeMode=a,this.queue=[],this.active=0,this.cache=new Map,this.totalBytes=0,this.inflight=new Map}enqueue(e,i,n,o={}){if(!e||!i||typeof n!="function")return()=>{};const s=typeof o.shape=="string"?o.shape.toLowerCase():"natural",r={key:e,url:i,onReady:n,options:{targetW:Vt(o.targetW)?o.targetW:null,targetH:Vt(o.targetH)?o.targetH:null,shape:s,article:o.article||null},cancelled:!1,delivered:!1},a=this.cache.get(e);if(a){const h=this._acquire(a,r.options.article);r.delivered=!0;try{n(a.image,a.tainted,a.kind,a.close,h)}catch(c){throw h({keepState:!0,skipRedraw:!0}),c}return()=>{}}const l=this.inflight.get(e);return l?l.requests.push(r):r.options.article&&r.options.article.isInView?this.queue.unshift(r):this.queue.push(r),this._pump(),()=>this._cancel(r)}_cancel(e){var n;if(!e||e.cancelled||e.delivered)return;e.cancelled=!0;const i=this.inflight.get(e.key);if(i){const o=i.requests.indexOf(e);if(o!==-1&&i.requests.splice(o,1),i.requests.length===0)try{(n=i.controller)==null||n.abort()}catch(s){}}else{const o=this.queue.indexOf(e);o!==-1&&this.queue.splice(o,1)}}_pump(){if(!(this.active>=this.maxConcurrent))for(;this.active<this.maxConcurrent&&this.queue.length;){const e=this.queue.shift();if(!e||e.cancelled)continue;const i=e.options&&e.options.article;if(i&&i.isInRange===!1){e.cancelled=!0;try{i._pendingImageKey===e.key&&(i._pendingImageKey=null,typeof i._imageCancel=="function"&&(i._imageCancel=null))}catch(o){}continue}if(this.cache.has(e.key)){this._serveFromCache(e);continue}const n=this.inflight.get(e.key);if(n){n.requests.push(e);continue}this._startLoad(e)}}_serveFromCache(e){const i=this.cache.get(e.key);if(!i||e.cancelled)return;const n=this._acquire(i,e.options.article);e.delivered=!0;try{e.onReady(i.image,i.tainted,i.kind,i.close,n)}catch(o){throw n({keepState:!0,skipRedraw:!0}),o}}_startLoad(e){const i=typeof AbortController!="undefined"?new AbortController:null,n={requests:[e],controller:i};this.inflight.set(e.key,n),this.active++;const o=i?i.signal:void 0,s=this._loadResource(e,o);n.promise=s,s.then(r=>{if(!r)return;const a=this.cache.get(e.key);a&&this._evictEntry(e.key,a),r.key=e.key,r.refs=0,r.articles=new Set,r.lastUsed=this._now(),this.cache.set(e.key,r),this.totalBytes+=r.bytes||0;const l=n.requests.slice();for(const h of l){if(!h||h.cancelled)continue;const c=this._acquire(r,h.options.article);h.delivered=!0;try{h.onReady(r.image,r.tainted,r.kind,r.close,c)}catch(u){throw c({keepState:!0,skipRedraw:!0}),u}}this._trimCache()}).catch(()=>{}).finally(()=>{this.inflight.delete(e.key),this.active=Math.max(0,this.active-1),this._pump()})}_acquire(e,i){e.refs=(e.refs||0)+1,e.lastUsed=this._now(),i&&e.articles.add(i);let n=!1;const o=(s={})=>{n||(n=!0,this._releaseInternal(e.key,i,s))};return o._key=e.key,i&&(o._article=i),o}_releaseInternal(e,i,n={}){const o=this.cache.get(e);o&&(o.refs>0&&(o.refs-=1),o.lastUsed=this._now(),i&&o.articles instanceof Set&&o.articles.delete(i),this._dropArticleState(i,e,n),this._trimCache())}_dropArticleState(e,i,n){if(!e||!i)return;const o=!!n.keepState,s=!!n.skipRedraw;if(!o&&e._loadedImageKey===i){if(e.imageLoaded=!1,e.image=null,e._loadedImageKey=null,typeof e._cacheBucket=="function")try{const a=e._cacheBucket(),l=`imageRaster:${i}`;a&&Object.prototype.hasOwnProperty.call(a,l)&&delete a[l]}catch(a){}if(typeof e.updateCachedSize=="function")try{e.updateCachedSize()}catch(a){}const r=e.owner;if(!s&&r&&typeof r.requestRedraw=="function")try{r.requestRedraw()}catch(a){}}e._closeImage&&e._closeImage._key===i&&(e._closeImage=null)}_trimCache(){if(!Number.isFinite(this.maxCacheBytes)||this.totalBytes<=this.maxCacheBytes)return;const e=[];for(const[i,n]of this.cache.entries())n&&e.push({key:i,entry:n});e.sort((i,n)=>{const o=typeof i.entry.lastUsed=="number"?i.entry.lastUsed:0,s=typeof n.entry.lastUsed=="number"?n.entry.lastUsed:0;return o-s});for(const{key:i,entry:n}of e){if(this.totalBytes<=this.maxCacheBytes)break;n.refs>0||this._evictEntry(i,n)}}_evictEntry(e,i){if(this.cache.has(e)&&(this.cache.delete(e),this.totalBytes=Math.max(0,this.totalBytes-(i.bytes||0)),i&&typeof i.close=="function"))try{i.close()}catch(n){}}async _loadResource(e,i){if(!e||e.cancelled)return null;const n=this.decodeMode,o=typeof createImageBitmap=="function",s=async a=>{if(!o){if(a)throw new Error("ImageBitmap not supported");return null}try{return await this._loadViaFetch(e,i)}catch(l){if(a)throw l}try{return await this._loadViaImageElement(e,!0)}catch(l){if(a)throw l;return null}},r=async a=>{try{return await this._loadViaImageElement(e,!1)}catch(l){if(!a)throw l;return await s(!1)}};switch(n){case"bitmap":return await s(!0);case"prefer-bitmap":case"auto":{const a=await s(!1);return a||await r(!1)}case"prefer-img":{const a=await r(!0);return a||await s(!1)}case"img":return await r(!1);default:{const a=await s(!1);return a||await r(!1)}}}async _loadViaFetch(e,i){const n={signal:i,mode:"cors",credentials:this.requireCORS?"same-origin":"omit"},o=await fetch(e.url,n);if(!o.ok)throw new Error("image fetch failed");const s=await o.blob(),r=await createImageBitmap(s),a=this._computeTransform(e.options,r.width,r.height);let l=r;if(a.needsCrop||a.needsResize){const h=a.sw,c=a.sh,u={};a.resizeWidth&&(u.resizeWidth=a.resizeWidth),a.resizeHeight&&(u.resizeHeight=a.resizeHeight),l=await createImageBitmap(r,a.sx,a.sy,h,c,u);try{r.close()}catch(m){}}return this._buildEntryFromBitmap(l,!1)}async _loadViaImageElement(e,i){const n=await this._createImageElement(e.url),o=ct(n.naturalWidth||n.width||0),s=ct(n.naturalHeight||n.height||0),r=e.options.shape||"natural",a=this._computeTransform(e.options,o,s);if(!i&&r==="natural"&&(a.needsResize=!1,a.resizeWidth=null,a.resizeHeight=null),i&&typeof createImageBitmap=="function"){const l={};a.resizeWidth&&(l.resizeWidth=a.resizeWidth),a.resizeHeight&&(l.resizeHeight=a.resizeHeight);const h=await createImageBitmap(n,a.sx,a.sy,a.sw,a.sh,l);return this._buildEntryFromBitmap(h,!this.requireCORS)}if(a.needsCrop||a.needsResize){const l=this._drawToCanvas(n,a);return this._buildEntryFromCanvas(l,!this.requireCORS)}return{image:n,kind:"img",tainted:!this.requireCORS,close:()=>{},bytes:this._estimateBytes(o,s)}}_drawToCanvas(e,i){let n=i.resizeWidth!=null?i.resizeWidth:i.sw,o=i.resizeHeight!=null?i.resizeHeight:i.sh;if(i.resizeWidth!=null&&i.resizeHeight==null&&i.sw>0){const a=i.resizeWidth/i.sw;o=Math.max(1,Math.round(i.sh*a))}else if(i.resizeHeight!=null&&i.resizeWidth==null&&i.sh>0){const a=i.resizeHeight/i.sh;n=Math.max(1,Math.round(i.sw*a))}n=Math.max(1,Math.round(n)),o=Math.max(1,Math.round(o));const s=this._createCanvas(n,o),r=s.getContext&&s.getContext("2d");return r&&r.drawImage(e,i.sx,i.sy,i.sw,i.sh,0,0,n,o),s}_createCanvas(e,i){const n=ct(e),o=ct(i);if(typeof document!="undefined"&&typeof document.createElement=="function"){const s=document.createElement("canvas");return s.width=n,s.height=o,s}return typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(n,o):{width:n,height:o,getContext:()=>null}}_buildEntryFromBitmap(e,i){return{image:e,kind:"bitmap",tainted:i,close:()=>{try{e.close()}catch(o){}},bytes:this._estimateBytes(e.width,e.height)}}_buildEntryFromCanvas(e,i){return{image:e,kind:"canvas",tainted:i,close:()=>{if(typeof e.close=="function")try{e.close()}catch(o){}},bytes:this._estimateBytes(e.width,e.height)}}_computeTransform(e,i,n){const o={sx:0,sy:0,sw:ct(i),sh:ct(n),resizeWidth:null,resizeHeight:null,needsCrop:!1,needsResize:!1},s=e.shape||"natural";if(vr.has(s)){o.sw!==o.sh&&(o.sw>o.sh?(o.sx=Math.floor((o.sw-o.sh)/2),o.sw=o.sh):(o.sy=Math.floor((o.sh-o.sw)/2),o.sh=o.sw),o.needsCrop=!0);const r=e.targetW||e.targetH;if(Vt(r)){const a=ct(r);o.resizeWidth=a,o.resizeHeight=a,o.needsResize=!0}}else{const r=e.targetW,a=e.targetH,l=o.sw,h=o.sh,c=u=>{if(!Number.isFinite(u)||u<=0)return;const m=ct(l*u),d=ct(h*u);m===l&&d===h||(o.resizeWidth=m,o.resizeHeight=d,o.needsResize=!0)};if(Vt(r)&&Vt(a)){const u=Math.min(r/l,a/h);c(u)}else Vt(r)?c(r/l):Vt(a)&&c(a/h)}return o.resizeWidth!=null&&o.resizeHeight==null?o.resizeHeight=ct(o.sh):o.resizeHeight!=null&&o.resizeWidth==null&&(o.resizeWidth=ct(o.sw)),o}_estimateBytes(e,i){return ct(e)*ct(i)*4}_now(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}_createImageElement(e){return new Promise((i,n)=>{const o=new Image;this.requireCORS&&(o.crossOrigin="anonymous"),o.decoding="async",o.fetchPriority="low",o.onload=()=>i(o),o.onerror=()=>n(new Error("image load error")),o.src=e,typeof o.decode=="function"&&o.decode().then(()=>i(o)).catch(()=>{})})}}const Ee={[lt]:1,[G]:Bt,[K]:Ht,[j]:Yt},_r={[j]:[12,6,3,1],[K]:[30,10,5,1],[G]:[30,10,5,1],[lt]:[500,100,50,10,5,1]},xn=[{majorUnit:O,majorMilliseconds:U,minorUnit:j},{majorUnit:j,majorMilliseconds:Yt,minorUnit:K},{majorUnit:K,majorMilliseconds:Ht,minorUnit:G},{majorUnit:G,majorMilliseconds:Bt,minorUnit:lt}],Ar=Rt;function Ne(t){return t<O?Ee[t]/U:t===O?1:null}function Ir(t,e,i){return e===O?t.format("D MMM YYYY",i):e===G?t.format("HH:mm:ss"):t.format("HH:mm")}function pe(t,e){return e===j||e===K?t.format("HH:mm"):e===G?`:${t.format("ss")}`:`.${t.format("SSS")}`}function Mr(t,e){const i=t%100;let n;if(i>=11&&i<=13)n="th";else switch(t%10){case 1:n="st";break;case 2:n="nd";break;case 3:n="rd";break;default:n="th"}return`${new y(t,1,1).format("YYYY",{thousandsSeparator:e,bceText:""})}${n}`}function Cr(t,e){switch(e){case G:return new y(t.year,t.month,t.day,t.hour,t.minute,t.second);case K:return new y(t.year,t.month,t.day,t.hour,t.minute);case j:return new y(t.year,t.month,t.day,t.hour);case O:return new y(t.year,t.month,t.day);case $:return new y(t.year,t.month,1);case rt:return new y(t.year,1,1);case de:{if(t.year>0)return new y(Math.floor(t.year/10)*10,1,1);const i=1-t.year,n=Math.floor(i/10)*10;return new y(1-(n+9),1,1)}case Rt:return y.CreateAsStartOfPeriod(t,"century");case fe:return y.CreateAsStartOfPeriod(t,"millennium");default:return null}}function Dr(t,e){switch(e){case G:return t.addSeconds(1);case K:return t.addMinutes(1);case j:return t.addHours(1);case O:return t.getNextDay();case $:return t.getNextMonth();case rt:return t.addYears(1);case de:return t.addYears(10);case Rt:return y.CreateAsExclusiveEndOfPeriod(t,"century");case fe:return y.CreateAsExclusiveEndOfPeriod(t,"millennium");default:return null}}class D{constructor(e,i){this.owner=e,this.zoomOptions=i,this.zoom=0,this.startToken=null,this.unit=O,this.unitSizeInPixels=100,this.adaptiveMinorUnit=null,this.adaptiveMinorInterval=null,this.adaptiveMinorMarkerSpacingInPixels=null,this.unitLengthInYears=1,this.zoomChangedHandlers=[],this.yearPrefix={minor:!1,major:!1},this.unitLevels=[],this.unitOrder=[]}}D.prototype.getUnitSizeInPixelsForZoom=function(t){var s;const e=this.zoomOptions.ratio,i=this.unitLevels[this.unit],n=(s=i.referenceZoom)!=null?s:i.zoomStart;return i.startUnitSize*Math.pow(e,t-n)},D.prototype.getChangePoint=function(t){return this.unitLevels[this.unit].zoomStart},D.prototype.getUnitFromZoom=function(t){for(let e=this.unitOrder.length-1;e>=0;e--){const i=this.unitOrder[e];if(t>=this.unitLevels[i].zoomStart)return i}throw new Error(`Zoom ${t} is out of range`)},D.prototype.getAdaptiveMinorInterval=function(t=this.unit,e=this.unitSizeInPixels){var r;const i=_r[t];if(!i)return 1;const n=this.zoomOptions.unitSize.minimum,o=(r=this.zoomOptions.unitSize.showMinorLabels)!=null?r:n,s=Math.max(n,o);for(let a=i.length-1;a>=0;a--)if(e*i[a]>=s)return i[a];return null},D.prototype.getSubdayVisualMarkerLayout=function(){var r;if(this.zoomOptions.minimum>=O||this.zoom>O||this.unit>O)return null;const t=this.unit===O?U:Ee[this.unit],e=this.unitSizeInPixels/t,i=(r=this.zoomOptions.unitSize.minimumMajor)!=null?r:120;let n=null;for(let a=xn.length-1;a>=0;a--){const l=xn[a];if(l.majorMilliseconds*e>=i){n=l;break}}if(!n)return null;const o=Ee[n.minorUnit]*e,s=this.getAdaptiveMinorInterval(n.minorUnit,o);return Ft(W({},n),{majorMarkerSpacingInPixels:n.majorMilliseconds*e,minorInterval:s,minorMarkerSpacingInPixels:s?o*s:null,minorMilliseconds:s?Ee[n.minorUnit]*s:null,pixelsPerMillisecond:e})},D.prototype.getParentContextScale=function(){const t=this.getSubdayVisualMarkerLayout(),e=t?t.majorUnit:this.unit+1;return e<lt||e>Ar?null:{level:this.zoomUnitToString(e),levelUnit:e,parentUnit:e<=j?O:e+1}},D.prototype.isParentContextTextVisible=function(t){if((t==null?void 0:t.visible)!==!0)return!1;const e=this.getParentContextScale();return e?t.levels==="all"?!0:Array.isArray(t.levels)&&t.levels.includes(e.level):!1},D.prototype.formatParentContextLabel=function(t,e){const i=this.getDateLabelFormatOptions(F);switch(e){case G:case K:case j:case O:return t.format("D MMM YYYY",i);case $:return t.format("MMM YYYY",i);case rt:return t.format("YYYY",i);case de:{const n=t.year<=0?1-t.year:t.year,o=Math.floor(n/10)*10;return`${new y(o,1,1).format("YYYY",{thousandsSeparator:i.thousandsSeparator,bceText:""})}s${t.year<=0?i.bceText:""}`}case Rt:case fe:{const n=t.year<=0?1-t.year:t.year,s=Math.ceil(n/(e===Rt?100:1e3)),r=e===Rt?"century":"millennium";return`${Mr(s,i.thousandsSeparator)} ${r}${t.year<=0?i.bceText:""}`}default:return""}},D.prototype.createParentContextTokens=function(t,e,i){const n=this.getParentContextScale();if(!n||!t||!this.startToken)return[];const o=[];let s=Cr(t,n.parentUnit),r=i+this.getPixelsBetween(this.startToken.value,s);do{const a=Dr(s,n.parentUnit);if(!a)break;const l=i+this.getPixelsBetween(this.startToken.value,a);o.push({drawX:r,label:this.formatParentContextLabel(s,n.parentUnit),length:l-r,unit:n.parentUnit,value:s}),s=a,r=l}while(o.length<1e3&&o[o.length-1].drawX<=e);return o},D.prototype.setAdaptiveMinorInterval=function(){const t=this.getSubdayVisualMarkerLayout();if(!t){this.adaptiveMinorUnit=null,this.adaptiveMinorInterval=null,this.adaptiveMinorMarkerSpacingInPixels=null;return}this.adaptiveMinorUnit=t.minorUnit,this.adaptiveMinorInterval=t.minorInterval,this.adaptiveMinorMarkerSpacingInPixels=t.minorMarkerSpacingInPixels},D.prototype.createSubdayVisualMarkers=function(t,e,i=this.getSubdayVisualMarkerLayout()){const n={[F]:[],[k]:[]};if(!i||!this.startToken)return n;const o=150,s=i.minorMilliseconds||i.majorMilliseconds,r=Math.floor((-o-e)/i.pixelsPerMillisecond),a=this.startToken.value.addMilliseconds(r),l=new y(a.year,a.month,a.day),h=Math.floor(a.getMillisecondsOfDay()/s)*s;let c=l.addMilliseconds(h);const u=i.minorMarkerSpacingInPixels>=this.zoomOptions.unitSize.showMinorLabels,m=p=>({drawX:e+this.getPixelsBetween(this.startToken.value,p),label:Ir(p,i.majorUnit,this.getDateLabelFormatOptions(F)),length:i.majorMarkerSpacingInPixels,markerSpacingInPixels:i.majorMarkerSpacingInPixels,type:F,unit:i.majorUnit,value:p,visual:!0}),d=Math.floor(a.getMillisecondsOfDay()/i.majorMilliseconds)*i.majorMilliseconds,g=l.addMilliseconds(d);for(g.isAfter(c)===!1&&!g.isSame(c)&&n[F].push(m(g));;){const p=e+this.getPixelsBetween(this.startToken.value,c);if(p>t+o)break;c.getMillisecondsOfDay()%i.majorMilliseconds===0?n[F].push(m(c)):i.minorMilliseconds&&n[k].push({adaptive:i.minorInterval!==1,drawX:p,label:u?pe(c,i.minorUnit):void 0,length:i.minorMarkerSpacingInPixels,markerSpacingInPixels:i.minorMarkerSpacingInPixels,type:k,unit:i.minorUnit,value:c,visual:!0}),c=c.addMilliseconds(s)}return n},D.prototype.createHourToken=function(t){const e={unit:j,value:t,length:this.unitSizeInPixels},i=this.unitLevels[j];return t.hour===0?(e.label=t.format("D MMM YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,j))),e},D.prototype.createMinuteToken=function(t){const e={unit:K,value:t,length:this.unitSizeInPixels},i=this.unitLevels[K];return t.minute===0?(e.label=t.format("HH:mm"),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,K))),e},D.prototype.createSecondToken=function(t){const e={unit:G,value:t,length:this.unitSizeInPixels},i=this.unitLevels[G];return t.second===0?(e.label=t.format("HH:mm:ss"),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,G))),e},D.prototype.createMillisecondToken=function(t){const e={unit:lt,value:t,length:this.unitSizeInPixels},i=this.unitLevels[lt];return t.millisecond===0?(e.label=t.format("HH:mm:ss.SSS"),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,lt))),e},D.prototype.getDateLabelFormatOptions=function(t){t=t===F?"major":"minor";const e=this.owner.options.style.dateLabel[t];return{thousandsSeparator:e.thousandsSeparator,bceText:e.bceText,yearPrefix:this.yearPrefix[t]}},D.prototype.createYearToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels};let i=t.year;const n=i===0;i<=0&&(i=-i+1);const o=this.unitLengthInYears,s=this.unitLevels[this.unit];return i%(o*10)===0||n?(e.label=t.format("YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<s.zoomHideMinorLabels&&(e.label=t.format("YYYY",this.getDateLabelFormatOptions(k)))),e},D.prototype.createMonthToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels},i=this.unitLevels[$];return t.month===1?(e.label=t.format("YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=t.format("MMM"))),e},D.prototype.createDayToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels},i=this.unitLevels[O];return t.day===1?(e.label=t.format("MMM YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=t.format("D"))),e},D.prototype.addZoomChangedHandler=function(t,e){this.zoomChangedHandlers.push({callback:t,context:e||this})},D.prototype.notifyZoomChanged=function(){for(let t=0;t<this.zoomChangedHandlers.length;t++)this.zoomChangedHandlers[t].callback.call(this.zoomChangedHandlers[t].context)},D.prototype.setZoom=function(t){var o,s;const e=this.zoom;let i=parseFloat(t.toFixed(4));i<this.zoomOptions.minimum&&(i=this.zoomOptions.minimum),i>this.zoomOptions.maximum&&(i=this.zoomOptions.maximum),this.zoom=i,this.unit=this.getUnitFromZoom(this.zoom),this.unitSizeInPixels=this.getUnitSizeInPixelsForZoom(this.zoom),this.setAdaptiveMinorInterval();let n=0;if(this.unit>=rt){const r=this.unit-rt;n=Math.pow(10,r)}if(this.unitLengthInYears=n,this.setCurrentYearPrefixes(),this.owner._isInitialized){const r=this.zoom-e;this.owner.trigger("zoom",{zoom:this.zoom,zoomDelta:r})}return(s=(o=this.owner)._markTimelineStateChanged)==null||s.call(o),this.notifyZoomChanged(),this.zoom},D.prototype.getPixelsBetween=function(t,e){const i=this.unit;return i<=O?t.getDaysTo(e)*this.unitSizeInPixels/Ne(i):i===$?t.getMonthsTo(e)*this.unitSizeInPixels:t.getYearsTo(e)*this.unitSizeInPixels/this.unitLengthInYears},D.prototype.setStartToken=function(t){return this.startToken=t},D.prototype.setStartDate=function(t){let e=0;switch(t.year<0&&(e=1),this.unit){case lt:return this.startToken=this.createMillisecondToken(new y(t)),0;case G:{const i=new y(t.year,t.month,t.day,t.hour,t.minute,t.second);return this.startToken=this.createSecondToken(i),-this.getPixelsBetween(i,t)}case K:{const i=new y(t.year,t.month,t.day,t.hour,t.minute);return this.startToken=this.createMinuteToken(i),-this.getPixelsBetween(i,t)}case j:{const i=new y(t.year,t.month,t.day,t.hour);return this.startToken=this.createHourToken(i),-this.getPixelsBetween(i,t)}case O:return this.startToken=this.createDayToken(new y(t.year,t.month,t.day)),-this.getPixelsBetween(this.startToken.value,t);case $:return this.startToken=this.createMonthToken(new y(t.year,t.month,1)),this.unitSizeInPixels/30.44*(this.startToken.value.day-t.day);case rt:return this.startToken=this.createYearToken(new y(t.year,1,1)),this.unitSizeInPixels/365.2422*((this.startToken.value.month-t.month)*30.44+(this.startToken.value.day-t.day));default:{const i=this.unitLengthInYears;return this.startToken=this.createYearToken(new y(Math.floor(t.year/i)*i+e,1,1)),this.unitSizeInPixels/(365.2422*i)*((this.startToken.value.year-t.year)*365.2422+(this.startToken.value.month-t.month)*30.44+(this.startToken.value.day-t.day))}}},D.prototype.getStartTokenCloned=function(){switch(this.startToken.unit){case lt:return this.createMillisecondToken(this.startToken.value);case G:return this.createSecondToken(this.startToken.value);case K:return this.createMinuteToken(this.startToken.value);case j:return this.createHourToken(this.startToken.value);case O:return this.createDayToken(this.startToken.value);case $:return this.createMonthToken(this.startToken.value);default:return this.createYearToken(this.startToken.value)}},D.prototype.getNext=function(t){switch(t.unit){case lt:return this.createMillisecondToken(t.value.addMilliseconds(1));case G:return this.createSecondToken(t.value.addSeconds(1));case K:return this.createMinuteToken(t.value.addMinutes(1));case j:return this.createHourToken(t.value.addHours(1));case O:return this.createDayToken(t.value.getNextDay());case $:return this.createMonthToken(t.value.getNextMonth());case rt:return this.createYearToken(t.value.addYears(1));default:{const e=this.unitLengthInYears;return this.createYearToken(t.value.addYears(t.value.year===-(e-1)?e-1:e))}}},D.prototype.getPrevious=function(t){switch(t.unit){case lt:return this.createMillisecondToken(t.value.addMilliseconds(-1));case G:return this.createSecondToken(t.value.addSeconds(-1));case K:return this.createMinuteToken(t.value.addMinutes(-1));case j:return this.createHourToken(t.value.addHours(-1));case O:return this.createDayToken(t.value.getPreviousDay());case $:return this.createMonthToken(t.value.getPreviousMonth());case rt:return this.createYearToken(t.value.addYears(-1));default:{const e=this.unitLengthInYears;return this.createYearToken(t.value.addYears(t.value.year===0?1-e:-e))}}},D.prototype.getPreviousNth=function(t,e){for(let i=0;i<e;i++)t=this.getPrevious(t);return t},D.prototype.zoomUnitToString=function(t){switch(t){case lt:return"millisecond";case G:return"second";case K:return"minute";case j:return"hour";case O:return"day";case $:return"month";case rt:return"year";case de:return"decade";case Rt:return"century";case fe:return"millennium";case zi:return"10 thousand years";case Fi:return"100 thousand years";case Bi:return"million years";case Hi:return"10 million years";case Yi:return"100 million years";case Wi:return"billion years";default:return"unknown"}},D.prototype.setUnitLevels=function(){this.unitLevels=[],this.unitOrder=[];const t=this.zoomOptions.unitSize.minimum,e=this.zoomOptions.unitSize.showMinorLabels,i=0,n=(z,it)=>{this.unitLevels[z]=it,this.unitOrder.push(z)},o=this.getZoomChangeByDistance(e,t),s=this.zoomOptions.unitSize.initial,r=this.getZoomChangeByDistance(s,t),a=i+r,l=a-o;n(O,{startUnitSize:s,zoomStart:i,zoomHideMinorLabels:l,zoomEnd:a});const c=s/24,u=this.getZoomChangeByDistance(c,t*60);n(j,{startUnitSize:t*60,zoomStart:u,zoomEnd:i,zoomHideMinorLabels:u+this.getZoomChangeByDistance(t*60,e)});const m=u+this.getZoomChangeByDistance(t,t*60);n(K,{startUnitSize:t*60,zoomStart:m,zoomEnd:u,zoomHideMinorLabels:m+this.getZoomChangeByDistance(t*60,e)});const d=m+this.getZoomChangeByDistance(t,t*1e3);n(G,{startUnitSize:t*1e3,zoomStart:d,zoomEnd:m,zoomHideMinorLabels:d+this.getZoomChangeByDistance(t*1e3,e)}),n(lt,{startUnitSize:t,referenceZoom:d,zoomStart:Number.NEGATIVE_INFINITY,zoomEnd:d,zoomHideMinorLabels:d+this.getZoomChangeByDistance(t,e)});const g=t*31,p=this.getZoomChangeByDistance(g,t),w=a+p,b=w-o;n($,{startUnitSize:g,zoomStart:a,zoomHideMinorLabels:b,zoomEnd:w});const v=t*12,S=this.getZoomChangeByDistance(v,t),M=w+S,P=M-o;n(rt,{startUnitSize:v,zoomStart:w,zoomHideMinorLabels:P,zoomEnd:M});let E,x,Z=M,R,V;const B=8;for(let z=1;z<=B;z++)E=t*10,x=this.getZoomChangeByDistance(E,t),R=Z+x,V=R-o,n(rt+z,{startUnitSize:E,zoomStart:Z,zoomHideMinorLabels:V,zoomEnd:R}),Z=R,z===B&&(this.zoomOptions.maximum=Math.min(this.zoomOptions.maximum,R));this.unitOrder.sort((z,it)=>z-it)},D.prototype.getZoomChangeByDistance=function(t,e){const i=this.zoomOptions.ratio;return Math.log(e/t)/Math.log(i)},D.prototype.scaleDistanceByZoomChange=function(t,e){const i=this.zoomOptions.ratio;return t*Math.pow(i,e)},D.prototype.setCurrentYearPrefixes=function(){const t=["minor","major"];if(this.unit<rt){for(let n=0;n<t.length;n++)this.yearPrefix[t[n]]=!1;return}const e=this.owner.options.style.dateLabel,i={minor:this.unitLengthInYears,major:this.unitLengthInYears*10};for(let n=0;n<t.length;n++){const o=t[n],s=Object.values(e[o].yearPrefixes);this.yearPrefix[o]=!1,s.sort(function(r,a){return a.minDivision-r.minDivision});for(let r=0;r<s.length;r++){const a=s[r];if(a.minDivision<=i[o]){this.yearPrefix[o]={label:a.label,value:a.value};break}}}};const zn=["http","https","data","blob"];function Tr(t,e=zn){if(typeof t!="string")return!1;const i=t.trim(),n=i.toLowerCase();if(n.startsWith("data:"))return e.includes("data");if(n.startsWith("blob:"))return e.includes("blob");try{const o=new URL(i,typeof window!="undefined"?window.location.href:void 0);return e.includes(o.protocol.replace(":",""))}catch(o){return!1}}function Pr(t){return/^data:image\//i.test(t)}function kr(t,e){if(!Array.isArray(e)||e.length===0)return!0;try{const i=new URL(t,typeof window!="undefined"?window.location.href:void 0),n=i.origin.toLowerCase(),o=i.hostname.toLowerCase();for(const s of e){if(typeof s!="string")continue;const r=s.trim().toLowerCase();if(r.includes("://")){try{const a=new URL(r).origin.toLowerCase();if(n===a)return!0}catch(a){}continue}if(r.startsWith("*.")&&(o===r.slice(2)||o.endsWith(`.${r.slice(2)}`))||r.startsWith(".")&&(o===r.slice(1)||o.endsWith(r))||o===r||o.endsWith(`.${r}`))return!0}return!1}catch(i){return!0}}function Rr(t,e={}){if(typeof t!="string")return null;const i=Array.isArray(e.allowedSchemes)&&e.allowedSchemes.length?e.allowedSchemes:zn;if(!Tr(t,i))return null;const n=t.trim().toLowerCase();return n.startsWith("data:")?Pr(n)?t:null:kr(t,e.allowedOrigins)?t:null}function Or(){const t=typeof globalThis!="undefined"&&globalThis.devicePixelRatio||1;return typeof t!="number"||!isFinite(t)||t<=0?1:t}function Er(t){const e=t&&t.dprMode==="native",i=Or(),n=e?i:Math.ceil(i),o=t&&typeof t.dpr=="number"&&isFinite(t.dpr)&&t.dpr>0?t.dpr:n,s=t&&typeof t.maxDpr=="number"&&isFinite(t.maxDpr)&&t.maxDpr>0?t.maxDpr:4;return Math.min(s,Math.max(1,o))}function pi(t,e,i,n,o){const s=Er(o),r=Math.max(1,Math.round(e!=null?e:t.clientWidth||t.width||1)),a=Math.max(1,Math.round(i!=null?i:t.clientHeight||t.height||1));t.style&&(t.style.width!==`${r}px`&&(t.style.width=`${r}px`),t.style.height!==`${a}px`&&(t.style.height=`${a}px`));const l=r*s,h=a*s;t.width!==l&&(t.width=l),t.height!==h&&(t.height=h);const c=n||t.getContext&&t.getContext("2d")||null;return c&&typeof c.setTransform=="function"&&c.setTransform(s,0,0,s,0,0),t._dpr=s,s}function Fn(t,e){const i=t.canvas._dpr||1;t.shadowOffsetX=e.x*i,t.shadowOffsetY=e.y*i,t.shadowBlur=e.amount*i,t.shadowColor=e.color}function Nr(t){return t instanceof HTMLCanvasElement||t&&t.nodeName==="CANVAS"}function xr({width:t,height:e,className:i,style:n}={}){const o=document.createElement("canvas");return t!=null&&(o.width=t),e!=null&&(o.height=e),i&&(o.className=i),o.style.touchAction="none",n&&Object.assign(o.style,n),o}function Bn(t,e){return t!=null&&t.append?t.append(e):t.appendChild(e),e}function zr(t){const e=t.getBoundingClientRect();return{left:e.left,top:e.top}}function Fr(){document.selection?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()}const vt=typeof window!="undefined"&&"onpointerdown"in window,Br=750,Hn=vt?{down:"pointerdown",move:"pointermove",up:"pointerup",cancel:"pointercancel",leave:"pointerleave"}:{down:"mousedown",move:"mousemove",up:"mouseup",cancel:"mouseleave",leave:"mouseleave"};function xe(t,e,i,n){const o=Hn[e]||e;t.addEventListener(o,i,n),vt||(e==="down"&&t.addEventListener("touchstart",i,n),e==="move"&&t.addEventListener("touchmove",i,n),e==="up"&&(t.addEventListener("touchend",i,n),t.addEventListener("touchcancel",i,n)))}function ze(t,e,i,n){const o=Hn[e]||e;t.removeEventListener(o,i,n),vt||(e==="down"&&t.removeEventListener("touchstart",i,n),e==="move"&&t.removeEventListener("touchmove",i,n),e==="up"&&(t.removeEventListener("touchend",i,n),t.removeEventListener("touchcancel",i,n)))}function ne(t){if(t.touches&&t.touches[0]){const e=t.touches[0];return{x:e.clientX,y:e.clientY}}if(t.changedTouches&&t.changedTouches[0]){const e=t.changedTouches[0];return{x:e.clientX,y:e.clientY}}return{x:t.clientX,y:t.clientY}}class Hr{constructor(e,{onStart:i,onMove:n,onEnd:o}={}){this.target=e,this.onStart=i,this.onMove=n,this.onEnd=o,this.pointers=new Map,this.lastTouchTime=0,this._handleDown=this._handleDown.bind(this),this._handleMove=this._handleMove.bind(this),this._handleUp=this._handleUp.bind(this),xe(e,"down",this._handleDown),xe(window,"move",this._handleMove),xe(window,"up",this._handleUp),vt&&xe(window,"cancel",this._handleUp)}destroy(){ze(this.target,"down",this._handleDown),ze(window,"move",this._handleMove),ze(window,"up",this._handleUp),vt&&ze(window,"cancel",this._handleUp),this.pointers.clear()}_handleDown(e){if(!vt){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}vt?this._addOrUpdatePointer(e):e.touches?this._syncTouches(e):this.pointers.set("mouse",{id:"mouse",x:e.clientX,y:e.clientY,type:"mouse"}),this.onStart&&this.onStart(e,this)}_handleMove(e){if(!vt){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}if(vt)this.pointers.has(this._getPointerId(e))&&this._addOrUpdatePointer(e);else if(e.touches)this._syncTouches(e);else if(this.pointers.has("mouse")){const i=this.pointers.get("mouse");i.x=e.clientX,i.y=e.clientY}this.onMove&&this.onMove(e,this)}_handleUp(e){if(!vt){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}if(vt)this.pointers.delete(this._getPointerId(e));else if(e.changedTouches){for(const i of e.changedTouches)this.pointers.delete(i.identifier);(!e.touches||e.touches.length===0)&&this.pointers.delete("mouse")}else this.pointers.delete("mouse");this.onEnd&&this.onEnd(e,this)}_getPointerId(e){return e.pointerId!=null?e.pointerId:"mouse"}_isTouchEvent(e){return!!(e.touches||e.changedTouches)}_shouldIgnoreMouseEvent(e){return!this._isTouchEvent(e)&&Date.now()-this.lastTouchTime<Br}_addOrUpdatePointer(e){this.pointers.set(this._getPointerId(e),{id:this._getPointerId(e),x:e.clientX,y:e.clientY,type:e.pointerType||"mouse"})}_syncTouches(e){this.pointers.clear();for(const i of e.touches)this.pointers.set(i.identifier,{id:i.identifier,x:i.clientX,y:i.clientY,type:"touch"})}get list(){return Array.from(this.pointers.values())}}function Yr(t){return t.list[0]||null}function Yn(t){const e=t.list;return e.length===0?null:e.length===1?{x:e[0].x,y:e[0].y}:{x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2}}function Wn(t){const e=t.list;if(e.length<2)return 0;const i=e[0].x-e[1].x,n=e[0].y-e[1].y;return Math.hypot(i,n)}function f(t,e){var l;const i=Nn(e);this._registeredArticleLayoutStyles=L({},mi.article.layoutStyles||{}),this._explicitArticleOptions=L({},(i==null?void 0:i.article)||{}),this.options=L({},mi,i),Nr(t)?this.canvas=t:(this.canvas=xr(),Bn(t,this.canvas)),this.canvas&&this.canvas.style&&(this.options.width!=null&&(this.canvas.style.width=`${this.options.width}px`),this.options.height!=null&&(this.canvas.style.height=`${this.options.height}px`)),this.canvasContext=this.canvas.getContext("2d"),this.canvasDpr=pi(this.canvas,this.options.width,this.options.height,this.canvasContext,this.options.canvas),this.fontWatcher=new wr(h=>{this.forLoadedArticles(c=>c.invalidateCaches()),this.requestRedraw()});const n=this.canvasContext,o=n.measureText.bind(n);n.measureText=h=>(this.fontWatcher.use(n.font),o(h)),this.width=this.canvas.clientWidth||this.options.width,this.top=this.options.height-this._getEffectiveVerticalOffset(),this.repositionWindow=0,this.uniqueId=`tl${new Date().getTime()}`,this.title="My timeline",this.ownerId=void 0,this.cursor="default",this.mouseoverArticle=null,this.isDragging=!1,this.draggingArticle=null,this.dragStartX=0,this.isPanning=!1,this.isPinching=!1,this.isAnimating=!1,this.isAnimatingArticles=!1,this.isCustomAnimating=!1,this.animation={redrawFunction:!1,defaultRedrawFunction:this.repositionRedraw,dragRedrawFunction:this.defaultRedraw,pan:null,zoom:null},this.lastAnimatingArticle={id:null,endTime:0},this.topRow=0,this.loadingHttpRequests=[],this.articles=[],this.lanes=[],this.timeBands=[],this.charts=[],this._runtimeArticleOptions={},this.redrawRequests={default:!1,reposition:!1},this._initialiseLaneHost(t),this.handlers={},this.options.on&&this.onMultiple(this.options.on),this._isInitialized=!1,this._hasPendingTimelineStateChange=!1;const s=this.options.zoom,r=this.getDmyFromInput(this.options.initialDate);this.timescaleManager=new D(this,s),this.timescaleManager.setUnitLevels(),this.timescaleManager.addZoomChangedHandler(this.zoomChanged,this),this.timescaleManager.setZoom(s.initial),this.timescaleManager.setStartDate(r),(l=this.settleDateBounds)==null||l.call(this,{animate:!1}),this.options.enableUserControl&&(this.enableZoomByWheel(),this.enableDragging()),this.groups={level:-1,periods:[]};const a=this.options.image||{};this.imageLoader=new Lr({maxConcurrent:a.maxConcurrent,maxCacheBytes:a.maxCacheBytes,requireCORS:a.requireCORS,decodeMode:a.decodeMode}),this.options.lane&&Array.isArray(this.options.lane.data)&&this.options.lane.data.length>0&&this.addLanes(this.options.lane.data),this.options.timeBand&&Array.isArray(this.options.timeBand.data)&&this.options.timeBand.data.length>0&&typeof this.addTimeBands=="function"&&this.addTimeBands(this.options.timeBand.data),this.options.chart&&Array.isArray(this.options.chart.data)&&this.options.chart.data.length>0&&typeof this.addCharts=="function"&&this.addCharts(this.options.chart.data),this.requestRedraw(),this._isInitialized=!0}f.prototype.setTitle=function(t){this.title=t,this._emitTimelineStateChange()},f.prototype.getWidth=function(){return this.canvas.clientWidth||this.options.width},f.prototype.getCanvasDpr=function(){return this.canvasDpr||1},f.prototype.isInVicinity=function(t,e,i){if(e=ie(e,this,t,i),typeof e=="boolean")return e;const n=i||this.getRelativePosition(t),o=e.up===void 0||n.top>this.top-e.up,s=e.down===void 0||n.top<this.top+e.down;return o&&s},f.prototype.getPixel=function(t,e){let i;const n=t.toKeyString();if(e){if(i=e.tokens,Object.prototype.hasOwnProperty.call(i,n))return i[n]}else i={};const o=this.repositionWindow,s=this.timescaleManager.startToken;return i[n]=this.timescaleManager.getPixelsBetween(s.value,t)+o},f.prototype.getRelativePosition=function(t){const{x:e,y:i}=ne(t),n=this.canvas.getBoundingClientRect();return{left:e-n.left,top:i-n.top}},f.prototype.updateCursor=function(t){const e=this.cursor,i=this.cursor=this.getCursor(t);e!==i&&(this.canvas.style.cursor=i)},f.prototype.getCursor=function(t){const e=this.options.style.cursor;if(this.isDragging)return e.timeline.dragging;const i=this.getRelativePosition(t);return this.draggingArticle?this.draggingArticle.getCursor(i):!this.options.disableBranding&&(this._isInsideHistropediaJSLink(i)||this._isInsideTermsLink(i))?e.clickable:this.mouseoverArticle!==null?this.mouseoverArticle.getCursor(i):e.timeline.hover},f.prototype.onRedraw=function(t){T.warn('DEPRECATION WARNING: timeline.onRedraw(handler) is deprecated. Use timeline.on("timeline-render-end", handler) instead.'),typeof this.on=="function"&&this.on("timeline-render-end",t)},f.prototype.zoomChanged=function(){let t;this.currentDensitySetting&&(t=this.currentDensitySetting.region),this.updateCurrentDensitySetting(),t!==this.currentDensitySetting.region&&this.updateArticlesGroupIndex()},f.prototype.updateCurrentDensitySetting=function(){for(let t=0;t<Je.length;t++){const e=Je[t];if(this.timescaleManager.zoom>=e.zoom.from&&this.timescaleManager.zoom<e.zoom.to){this.currentDensitySetting=e;break}}},f.prototype.calculateEndToken=function(){const t=this.getWidth();let e=this.repositionWindow,n=this.timescaleManager.startToken,o;do o=n,n=this.timescaleManager.getNext(n),e+=n.length;while(e<t);return o},f.prototype.getDensityPick=function(t=this.options.article.density){switch(t){case"low":case 1:return this.currentDensitySetting.low;case"medium":case 2:return this.currentDensitySetting.medium;case"high":case 3:return this.currentDensitySetting.high;case"all":case 0:return this.currentDensitySetting.all}T.error(`Unknown density selector:${t}`)},f.prototype.invoke=function(t,e,i){Object.prototype.hasOwnProperty.call(e,t)&&e[t].call(this,i)},f.prototype.forLoadedArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&t.call(this,i)}},f.prototype.forVisibleArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&i.isVisible&&t.call(this,i)}},f.prototype.forInRangeArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&(i.isInRange||i.isFading)&&t.call(this,i)}},f.prototype.enqueueImageLoad=function(t){let e=_(t.data,"imageUrl");if(!e){if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(l){}t.image=null,t.imageLoaded=!1,t._closeImage=null,t._loadedImageKey=null,t._pendingImageKey=null;return}const{sanitizer:i,customSanitizer:n}=this.options.image;if(typeof n=="function")try{e=n(e,i)}catch(l){e=null}else e=Rr(e,i);if(!e){if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(l){}t.image=null,t.imageLoaded=!1,t._closeImage=null,t._loadedImageKey=null,t._pendingImageKey=null;return}const o=this._getArticleImageTargetSpec(t),s=o&&Number.isFinite(o.dpr)&&o.dpr>0?Math.round(Math.max(1,o.dpr)*1e3)/1e3:1,r=`img:${e}:${o.layout}:${o.shape}:${o.targetW||0}x${o.targetH||0}@${s}`;if(t._loadedImageKey===r&&t.imageLoaded&&t.image||t._pendingImageKey===r&&typeof t._imageCancel=="function")return;if(t._pendingImageKey&&t._pendingImageKey!==r&&typeof t._imageCancel=="function"){try{t._imageCancel()}catch(l){}t._imageCancel=null}t.imageLoaded&&t.image||(t.imageLoaded=!1),t._pendingImageKey=r;const a=this.imageLoader.enqueue(r,e,(l,h,c,u,m)=>{if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(g){}let d=null;typeof m=="function"?d=m:typeof u=="function"&&(d=function(){try{u()}catch(g){}}),t.image=l,t.imageLoaded=!0,t._loadedImageKey=r,t._pendingImageKey=null,t._imageCancel=null,t._closeImage=d,t._closeImage&&t._closeImage._key==null&&typeof m=="function"&&(t._closeImage._key=r,t._closeImage._article=t),typeof t.updateCachedSize=="function"&&t.updateCachedSize(),this.requestRedraw(this.redraw)},{targetW:o.targetW,targetH:o.targetH,shape:o.shape,article:t});t._imageCancel=a},f.prototype._getArticleImageTargetSpec=function(t){const e=t._getCurrentCardLayoutName(),i=t.getCurrentStyle(),n=i&&i.image?i.image:{},o=n.shape||"square";let s=null,r=null;if(e==="landscape"){const m=n.margin||0,d=Math.max(1,(i.height||0)-m*2);s=d,r=d}else if(e==="portrait"){const m=n.margin||0,g=Math.max(1,(i.width||0)-0-m*2);o==="square"||o==="circle"?(s=g,r=g):s=g}else i&&typeof i.width=="number"&&(s=i.width);const a=typeof this.getCanvasDpr=="function"?this.getCanvasDpr():Number(this.canvasDpr),l=Number.isFinite(a)&&a>0?a:1,h=m=>typeof m!="number"||!Number.isFinite(m)||m<=0?null:Math.max(1,Math.round(m*l)),c=h(s),u=h(r);return{layout:e,targetW:c,targetH:u,shape:o,dpr:l}},f.prototype.setOption=function(t,e){if(typeof t=="string"){const d=En(t),g=_(this.options,d);if(typeof e=="undefined")return g;t=bt(d,e)}const i=this.top;t=Nn(t),A(t,"article")&&L(this._explicitArticleOptions,t.article||{}),L(this.options,t);const n=t.width||t.height;n&&this.setSize(this.options.width,this.options.height);const o=A(t,"canvas.dpr")||A(t,"canvas.dprMode")||A(t,"canvas.maxDpr");!n&&o&&(this.canvasDpr=pi(this.canvas,this.options.width,this.options.height,this.canvasContext,this.options.canvas)),typeof t.verticalOffset=="number"&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),(A(t,"timeBand.visible")||A(t,"timeBand.reserveSpace")||A(t,"timeBand.reserveSpacePixels"))&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),(A(t,"style.dateLabel.parent.visible")||A(t,"style.dateLabel.parent.height"))&&(this.top=this.options.height-this._getEffectiveVerticalOffset());const a=Tn(_(t,"article"));if(A(t,"timeBand.defaultStyle")&&Array.isArray(this.timeBands)&&this.timeBands.length>0){const d=this.options.timeBand&&this.options.timeBand.defaultStyle?this.options.timeBand.defaultStyle:{};for(let g=0;g<this.timeBands.length;g++){const p=this.timeBands[g],w=p&&p.data&&p.data.style?p.data.style:{};p.style=L({},d,w)}}const h=_(t,"chart.data");Array.isArray(h)&&typeof this.addCharts=="function"&&this.addCharts(h);const c=A(t,"chart.seriesColors");if((c||A(t,"chart.defaultData")||A(t,"chart.defaultStyle"))&&Array.isArray(this.charts)&&this.charts.length>0){let d=!1;for(let g=0;g<this.charts.length;g++){const p=this.charts[g].laneId;c&&(this.charts[g]._seriesColors=[]),this.charts[g]._resolveFromData(),A(t,"chart.defaultData")&&this.charts[g].laneId!=null&&this._ensureChartLane(this.charts[g].laneId),d=d||p!==this.charts[g].laneId}d&&(this._refreshLaneOrder(),this._updateLaneLayout())}let m={styleLaneIds:new Set};if(A(t,"lane")){const d=_(t,"lane.data");Array.isArray(d)&&(m=this.addLanes(d,{suppressArticleRefresh:!0}))}if(A(t,"lane")||a.cacheChanged){const d=a.styleChanged?"all":m.styleLaneIds.size>0?m.styleLaneIds:null;this._refreshResolvedLanesFromOptions({articleStyleScope:d})}this.top!==i&&this.options.article.autoStacking.fitToHeight&&!this._isLaneLayoutActive()&&this.fitToHeight(),this.requestRedraw()},f.prototype.setSize=function(t,e){this.canvas&&this.canvas.style&&(typeof t=="number"&&(this.canvas.style.width=`${t}px`),typeof e=="number"&&(this.canvas.style.height=`${e}px`)),this.options.width=t,this.options.height=e,this.canvasDpr=pi(this.canvas,t,e,this.canvasContext,this.options.canvas),typeof this._syncLaneViewportSize=="function"&&this._syncLaneViewportSize(),this.width=this.canvas.clientWidth||t,this.top=e-this._getEffectiveVerticalOffset(),this.requestRedraw()},f.prototype._getEffectiveVerticalOffset=function(){var a,l;const t=this.options.verticalOffset||0,e=this.options.timeBand||{},i=Array.isArray(this.timeBands)&&this.timeBands.length>0,o=!!e.reserveSpace&&e.visible&&i&&e.reserveSpacePixels||0,s=((l=(a=this.options.style)==null?void 0:a.dateLabel)==null?void 0:l.parent)||{},r=s.visible===!0&&s.height||0;return t+o+r},f.prototype.generateDensitySettings=function(){const t=this.timescaleManager.zoomOptions.ratio,e=[],i=a=>Math.round(a*100)/100,n=i(Math.log(.5)/Math.log(t)),o=Math.ceil(Math.log2(U));for(let a=o;a>=1;a--)e.push({region:1-a,zoom:{from:a===o?Number.NEGATIVE_INFINITY:i(-a*n),to:i(-(a-1)*n)},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:Math.pow(2,a)}});const s=Math.ceil(this.timescaleManager.zoomOptions.maximum/n);for(let a=0;a<s;a++){const l=i(a*n),h=i((a+1)*n),c={region:a+1,zoom:{from:l,to:h},low:1,medium:2,high:3,all:25,step:{months:0,days:Math.pow(2,a)}};e.push(c)}const r=JSON.stringify(e,(a,l)=>l===Number.NEGATIVE_INFINITY?"__DENSITY_NEGATIVE_INFINITY__":l,2).replace('"__DENSITY_NEGATIVE_INFINITY__"',"Number.NEGATIVE_INFINITY");T.log(r)};function oe(t){return t!=null&&typeof t=="object"}function Wr(t,e){return{day:t.getDaysSinceYearZero(),division:Math.floor(t.getMillisecondsOfDay()*e/U),divisionsPerDay:e}}function se(t,e){return!oe(t)&&!oe(e)?t===e?0:t<e?-1:1:t.day!==e.day?t.day<e.day?-1:1:t.division!==e.division?t.division<e.division?-1:1:0}function St(t,e){if(!oe(t))return t+e;const i=t.division+e,n=Math.floor(i/t.divisionsPerDay);return{day:t.day+n,division:i-n*t.divisionsPerDay,divisionsPerDay:t.divisionsPerDay}}function Vn(t,e,i){return se(t,e)<0?e:se(t,i)>0?i:t}function yi(t){return oe(t)?`${t.day}:${t.division}`:String(t)}function Vr(t){return{dayNumber:t.day,dayFraction:t.division/t.divisionsPerDay}}function Zr(t,e){return`${t}::${yi(e)}`}const Ur=1e7,Gr=2e7;function jr(t){return t.isActive?t.rank+Gr:t.rank+(t.isStarred?Ur:0)}function $r(t,e){const i=[];let n=0;for(let o=0;o<t.length;o++){const s=t[o];if(s.effectiveRank=jr(s),i.length<e){i.push(s),s.effectiveRank<i[n].effectiveRank&&(n=i.length-1);continue}s.effectiveRank>i[n].effectiveRank&&(i[n]=s,n=yr(i,"effectiveRank"))}return i}f.prototype.updateArticlesGroupIndex=function(){this.forLoadedArticles(function(t){t.groupIndex=this.calculateGroupIndex(t.period.from)})},f.prototype.updateVisibleArticlesOfGroups=function(t){if(this._isLaneLayoutActive()){this.groups={};const o=gi(this.options.article.autoStacking.range)?1:20,s=St(this.calculateGroupIndex(t.tokens.start),-o),r=St(this.calculateGroupIndex(t.tokens.end),o),a=this._getActiveLanesForLayout();this.forLoadedArticles(function(l){l.isVisibleInGroup=!1});for(let l=0;l<a.length;l++){const h=a[l];for(let c=s;se(c,r)<=0;c=St(c,1)){const u=Zr(h.id,c);this.groups[u]=this.getArticlesInGroup(c,s,r,h.id).map(function(m){return m.isVisibleInGroup=!0,m.id})}}return}this.groups={};const e=gi(this.options.article.autoStacking.range)?1:20,i=St(this.calculateGroupIndex(t.tokens.start),-e),n=St(this.calculateGroupIndex(t.tokens.end),e);this.forLoadedArticles(function(o){o.isVisibleInGroup=!1});for(let o=i;se(o,n)<=0;o=St(o,1))this.groups[yi(o)]=this.getArticlesInGroup(o,i,n).map(function(s){return s.isVisibleInGroup=!0,s.id})},f.prototype.getArticlesInGroup=function(t,e,i,n){const o=typeof n!="undefined"?this.getLaneById(n):null,s=o&&o.resolvedArticleOptions?o.resolvedArticleOptions.density:this.options.article.density,r=this.getDensityPick(s),a=[];for(let l=0;l<this.articles.length;l++){const h=this.articles[l];!h.isDataLoaded||h.isHiddenByFilter||typeof n!="undefined"&&h.laneId!==n||!(se(Vn(h.groupIndex,e,i),t)===0)||a.push(h)}return $r(a,r)},f.prototype.calculateGroupIndex=function(t){if(this.currentDensitySetting.step.divisionsPerDay)return Wr(t,this.currentDensitySetting.step.divisionsPerDay);if(this.timescaleManager.unit>=$&&this.currentDensitySetting.step.months!==0){const i=t.year*12+(t.month-1);return Math.floor(i/this.currentDensitySetting.step.months)}const e=t.year*372+(t.month-1)*31+t.day;return this.currentDensitySetting.step.days===0?Math.floor(e/(this.currentDensitySetting.step.months*30)):Math.floor(e/this.currentDensitySetting.step.days)},f.prototype.canBeVisibleInGroup=function(t,e,i){if(t.isActive)return!0;e=e||this.timescaleManager.startToken,i=i||this.calculateEndToken();const n=St(this.calculateGroupIndex(e.value),-1),o=St(this.calculateGroupIndex(i.value),1),s=Vn(t.groupIndex,n,o),r=yi(s);return Object.prototype.hasOwnProperty.call(this.groups,r)?this.groups[r].indexOf(t.id)>=0:!1};const Xr=64;function qr({velocity:t,friction:e,minVelocity:i,maxDuration:n,maxFrameDelta:o=Xr,shouldStop:s,onUpdate:r,onComplete:a}={}){let l=t;const h=performance.now();let c=h,u=!1;if(!Number.isFinite(l)||!Number.isFinite(e)||e<=0||!Number.isFinite(i)||i<0||!Number.isFinite(n)||n<=0)return{stop(){}};function m(){u=!0}function d(){u||(u=!0,a==null||a())}function g(p){if(u)return;if(s!=null&&s()){m();return}if(p-h>=n||Math.abs(l)<i){d();return}const w=Math.min(Math.max(p-c,0),o);if(c=p,w>0){const b=Math.exp(-e*w),v=l*(1-b)/e;l*=b,v!==0&&(r==null||r(v,l))}requestAnimationFrame(g)}return requestAnimationFrame(g),{stop:m}}function Zn(t=0){var e,i;return typeof t=="number"?{left:t,right:t}:{left:(e=t==null?void 0:t.left)!=null?e:0,right:(i=t==null?void 0:t.right)!=null?i:0}}function Ot(t){var i,n,o,s,r,a,l;const e=typeof t=="string"?(i=ti(t))==null?void 0:i.date:t;if(!e||!Number.isFinite(e.year))throw new Error("Date input requires a numeric year or canonical Histropedia date string");return new y({precision:me(e),year:e.year,month:(n=e.month)!=null?n:1,day:(o=e.day)!=null?o:1,hour:(s=e.hour)!=null?s:0,minute:(r=e.minute)!=null?r:0,second:(a=e.second)!=null?a:0,millisecond:(l=e.millisecond)!=null?l:0})}function wi(t){const e=Math.floor(t.millisecond/U);return{dayNumber:t.dayNumber+e,millisecond:t.millisecond-e*U}}function re(t){return{dayNumber:t.getDaysSinceYearZero(),millisecond:t.getMillisecondsOfDay()}}function Et(t,e){return t.dayNumber!==e.dayNumber?t.dayNumber<e.dayNumber?-1:1:t.millisecond!==e.millisecond?t.millisecond<e.millisecond?-1:1:0}function Lt(t,e){const i=e.dayNumber-t.dayNumber,n=e.millisecond-t.millisecond;return i+n/U}function Tt(t,e){const i=Math.floor(e);return wi({dayNumber:t.dayNumber+i,millisecond:t.millisecond+(e-i)*U})}function Un(t,e,i){if(i<=0)return W({},t);if(i>=1)return W({},e);const n=(e.dayNumber-t.dayNumber)*i,o=Math.floor(n),s=t.millisecond+(n-o)*U+(e.millisecond-t.millisecond)*i;return wi({dayNumber:t.dayNumber+o,millisecond:s})}function ye(t){return new y(t===-1?1:t+1,1,1)}function Kr(t,e){return e===12?ye(t):new y(t,e+1,1)}function Gn(t){const e=Ot(t),i=typeof t=="string"?ti(t):null,n=i?i.hasMonth:t.month!=null,o=i?i.hasDay:t.day!=null,s=i?i.hasTime:t.hour!=null||t.minute!=null||t.second!=null||t.millisecond!=null;return!n&&!s?{start:e,end:ye(e.year)}:!o&&!s?{start:e,end:Kr(e.year,e.month)}:{start:e,end:Ot(t)}}function bi(t,e){return Math.max(1,t.getWidth()-e.left-e.right)}function Jr(t,e){var s,r;const i=(s=t.zoomOptions)==null?void 0:s.minimum,n=(r=t.zoomOptions)==null?void 0:r.maximum;let o=e;return Number.isFinite(i)&&o<i&&(o=i),Number.isFinite(n)&&o>n&&(o=n),o}function Fe(t,e){return Number.isFinite(e)?parseFloat(Jr(t,e).toFixed(4)):e}function jn(t,e){if(typeof t.getUnitFromZoom=="function")return t.getUnitFromZoom(e);const i=t.unitLevels;if(!Array.isArray(i)||i.length===0)return t.unit;const n=t.unitOrder||i.map((o,s)=>s);for(let o=n.length-1;o>=0;o--){const s=n[o];if(e>=i[s].zoomStart)return s}return t.unit}function $n(t,e,i){var r,a,l,h;const n=(r=t.unitLevels)==null?void 0:r[e],o=(a=t.zoomOptions)==null?void 0:a.ratio;if(n&&Number.isFinite(n.startUnitSize)&&Number.isFinite((l=n.referenceZoom)!=null?l:n.zoomStart)&&Number.isFinite(o)&&o>0)return n.startUnitSize*Math.pow(o,i-((h=n.referenceZoom)!=null?h:n.zoomStart));if(!Number.isFinite(t.unitSizeInPixels))return NaN;const s=i-t.zoom;return t.scaleDistanceByZoomChange?t.scaleDistanceByZoomChange(t.unitSizeInPixels,s):NaN}function Xn(t){return t>=rt?Math.pow(10,t-rt):0}function Qr(t,e,i,n){const o=Fe(t,n),s=jn(t,o),r=$n(t,s,o);return!Number.isFinite(r)||r<=0?NaN:s<=O?e.getDaysTo(i)*r/Ne(s):s===$?e.getMonthsTo(i)*r:e.getYearsTo(i)*r/Xn(s)}function ta(t,e,i,n){const o=Fe(t,n),s=jn(t,o),r=$n(t,s,o);if(!Number.isFinite(r)||r<=0)return NaN;const a=Lt(e,i);return s<=O?a*r/Ne(s):s===$?a*r/30.44:a*r/(365.2422*Xn(s))}function ea(t,e,i,n){const o=t.timescaleManager,s=o.getPixelsBetween(e,i);if(!Number.isFinite(s)||s<=0)return o.zoom;const r=bi(t,n),a=o.getZoomChangeByDistance(s,r);if(!Number.isFinite(a))return o.zoom;let l=o.zoom+a;for(let h=0;h<4;h++){const c=Qr(o,e,i,l);if(!Number.isFinite(c)||c<=0)break;const u=o.getZoomChangeByDistance(c,r);if(!Number.isFinite(u)||(l+=u,Math.abs(u)<5e-5))break}return Fe(o,l)}function ia(t,e,i,n){return ea(t,t.getDmyFromInput(Ot(e)),t.getDmyFromInput(Ot(i)),n)}function qn(t,e){return e==null?null:t.getDmyFromInput(Ot(e))}function we(t){var o;const e=(o=t.options)==null?void 0:o.bounds;if(!e)return null;let i=qn(t,e.minDate),n=qn(t,e.maxDate);return!i&&!n?null:(i&&n&&i.compare(n)>0&&([i,n]=[n,i]),{minDate:i,maxDate:n,minPoint:i?re(i):null,maxPoint:n?re(n):null,minDay:i?Ut(i):null,maxDay:n?Ut(n):null,overflow:e.overflow==="clamp"?"clamp":"elastic"})}function Kn(t){const e=He(t,0),i=He(t,t.getWidth());return Et(e,i)<=0?{start:e,end:i}:{start:i,end:e}}function na(t,e,i){const n=t.minPoint?Lt(e.start,t.minPoint):0,o=t.maxPoint?Lt(t.maxPoint,e.end):0;return n>0&&n>=o?{type:"min",dayPoint:t.minPoint,dayNumber:t.minDay,pixelOffset:0,overflowDays:n}:o>0?{type:"max",dayPoint:t.maxPoint,dayNumber:t.maxDay,pixelOffset:i,overflowDays:o}:null}function Be(t,e=we(t),i={}){if(!e)return null;const n=Kn(t),o=t.getWidth(),s=na(e,n,o);return i.mode==="elastic"&&e.overflow==="elastic"&&s?s:e.minPoint&&e.maxPoint&&Lt(n.start,n.end)>Lt(e.minPoint,e.maxPoint)?{type:"range",zoom:Qn(t,e.minPoint,e.maxPoint,{left:0,right:0},t.timescaleManager.zoom),dayPoint:e.minPoint,dayNumber:e.minDay,pixelOffset:0}:s}function vi(t,e){const i=At(t);if(!i||!Number.isFinite(e)||e<=0)return 0;const n=Math.max(1,t.getWidth()),o=Math.max(32,n*.22),s=e*i;return o*s/(o+s)/i}function Jn(t,e){const i=At(t);if(!i||!Number.isFinite(e)||e<=0)return 0;const n=Math.max(1,t.getWidth()),o=Math.max(32,n*.22),s=e*i;return s>=o?Number.MAX_SAFE_INTEGER/i:o*s/(o-s)/i}function oa(t,e,i){const n=we(t);let o=e;if((n==null?void 0:n.overflow)==="elastic"&&Number.isFinite(i)){const s=Tt(e,i);if(n.minPoint&&Et(e,n.minPoint)<0){const r=Lt(e,n.minPoint);o=Tt(n.minPoint,-vi(t,r))}else if(n.maxPoint&&Et(s,n.maxPoint)>0){const r=Lt(n.maxPoint,s);o=Tt(n.maxPoint,vi(t,r)-i)}}Zt(t,o,0,!1,{skipDateBounds:!0})}function Nt(t,e={}){const i=we(t);if(!i)return!1;const n=e.mode||"clamp",o=Be(t,i,{mode:n});if(!o)return!1;if(o.type==="range")return o.zoom!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(o.zoom),Zt(t,o.dayPoint,o.pixelOffset,!1,{skipDateBounds:!0}),!0;if(n==="elastic"&&i.overflow==="elastic"){const s=vi(t,o.overflowDays);return o.type==="min"?Zt(t,Tt(o.dayPoint,-s),0,!1,{skipDateBounds:!0}):Zt(t,Tt(o.dayPoint,s),o.pixelOffset,!1,{skipDateBounds:!0}),!0}return Zt(t,o.dayPoint,o.pixelOffset,!1,{skipDateBounds:!0}),!0}function sa(t){return!!Be(t)}function At(t){var o;const e=t.timescaleManager,i=e.unitSizeInPixels;if(!Number.isFinite(i)||i<=0)return 0;if(e.unit==null||e.unit<=O)return i/Ne((o=e.unit)!=null?o:O);if(e.unit===$)return i/30.44;const n=Number.isFinite(e.unitLengthInYears)&&e.unitLengthInYears>0?e.unitLengthInYears:1;return i/(365.2422*n)}function Zt(t,e,i,n=!1,o={}){var u;const s=wi(e),r=Math.floor(s.millisecond),a=s.millisecond-r,l=Si(s.dayNumber).addMilliseconds(r),h=a*At(t)/U,c=t.timescaleManager.setStartDate(l);t.repositionWindow=c-h,i&&t.updateFromByPixels(-i,{skipDateBounds:!0}),o.skipDateBounds||Nt(t,{mode:o.boundsMode||"clamp"}),t.requestRedraw(),(u=t._markTimelineStateChanged)==null||u.call(t),n&&t._emitTimelineStateChange()}function ra(t,e,i,n=!1,o={}){Zt(t,re(e),i,n,o)}function aa(t,e){const i=At(t),n=re(e.date);return i?Tt(n,e.fraction/i):n}function He(t,e){return aa(t,t.getPivotPoint(e))}function Ut(t){return t.getDaysSinceYearZero()+t.getMillisecondsOfDay()/U}function Si(t){const e=Math.floor(t);let i=Math.floor(e/365.2422),n=Ut(new y(i,1,1)),o=Ut(ye(i));for(;n>e;)i-=1,n=Ut(new y(i,1,1)),o=Ut(ye(i));for(;o<=e;)i=i===-1?1:i+1,n=o,o=Ut(ye(i));return y.getByDayOfYear(i,e-n+1)}function la(t,e,i){return t+(e-t)*i}function Qn(t,e,i,n,o){if(Et(i,e)<=0)return o;const s=t.timescaleManager,r=Lt(e,i)*At(t);if(!Number.isFinite(r)||r<=0)return o;const a=bi(t,n),l=s.getZoomChangeByDistance(r,a);if(!Number.isFinite(l))return o;let h=s.zoom+l;for(let c=0;c<4;c++){const u=ta(s,e,i,h);if(!Number.isFinite(u)||u<=0)break;const m=s.getZoomChangeByDistance(u,a);if(!Number.isFinite(m)||(h+=m,Math.abs(m)<5e-5))break}return Fe(s,h)}function ha(t){var e,i,n,o,s;typeof t.stopPanAnimation=="function"?t.stopPanAnimation():(t.isPanning&&((i=(e=t.animation)==null?void 0:e.pan)!=null&&i.stop)&&t.animation.pan.stop(),t.isPanning=!1),typeof t.stopZoomAnimation=="function"?t.stopZoomAnimation():((o=(n=t.animation)==null?void 0:n.zoom)!=null&&o.stop&&t.animation.zoom.stop(),((s=t.animation)==null?void 0:s.wheelZoomFrame)!=null&&cancelAnimationFrame(t.animation.wheelZoomFrame),t.animation&&(t.animation.zoom=null,t.animation.wheelZoomTarget=null,t.animation.wheelZoomPivotPoint=null,t.animation.wheelZoomPivotPixel=null,t.animation.wheelZoomLastFrameTime=null,t.animation.wheelZoomFrame=null))}function ca(t,e,i,n,o,s={}){var w;ha(t),t.switchToPositiveRepositionWindow(),t.isPanning=!0,t.startAnimation();const r=t.timescaleManager.zoom,a=bi(t,o),l=He(t,o.left),h=He(t,o.left+a),c=t.getDmyFromInput(Ot(e)),u=t.getDmyFromInput(Ot(i)),m=re(c),d=re(u),g=Et(h,l)>0&&Et(d,m)>0,p=Y({from:0,to:1,duration:(w=s.duration)!=null?w:2e3,easing:H[s.easing]||H.swing,onUpdate(b){if(t.isPinching){t.isPanning=!1,p.stop();return}const v=Un(l,m,b);let S=r;b>0&&(S=g?Qn(t,v,Un(h,d,b),o,t.timescaleManager.zoom):la(r,n,b)),S!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(S),Zt(t,v,o.left)},onComplete(){n!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(n),ra(t,c,o.left,!0),t.isPanning=!1}});t.animation.pan=p}function ua(t,e){var a,l,h,c;const i=t.articles||[];let n=null,o=null,s=0,r=0;for(let u=0;u<i.length;u++){const m=i[u];if(!e(m)||!((a=m.period)!=null&&a.from))continue;const d=m.period.from;(!n||d.compare(n)<0)&&(n=d),(!o||d.compare(o)>0)&&(o=d);const g=m.getCurrentStyle(),p=(h=(l=g.connectorLine)==null?void 0:l.offsetX)!=null?h:0,w=(c=g.width)!=null?c:0;s=Math.max(s,p),r=Math.max(r,w-p)}return n?{earliest:n,latest:o,maxCardLeftOffset:s,maxCardRightOffset:r}:null}f.prototype._drawBranding=function(t){this._drawCopyrightLinks(t)};const Ye=117,Li=22,to=0,eo=0,We=8,_i=0,ae=12,da="HistropediaJS",io=75,fa="Terms",ma=33,ga=10,pa=`${da} | ${fa}`;f.prototype._drawCopyrightLinks=function(t){t.beginPath(),t.fillStyle="rgba(255, 255, 255, 0.8)",t.fillRect(this.width-Ye-to-We*2,this.top-Math.floor(this.options.style.mainLine.size/2)-Li-eo-_i*2,Ye+We*2,Li+_i*2),t.textAlign="left",t.textBaseline="middle",t.fillStyle="#000000",t.font=`normal ${ae}px "Helvetica Neue", Helvetica, Arial, sans-serif`;const e=this._getBrandingTextCoords();t.fillText(pa,e.left,e.top,Ye+We)},f.prototype._getBrandingTextCoords=function(){return{left:this.width-Ye-to-We,top:this.top-Math.floor(this.options.style.mainLine.size/2)-Li-eo+ae-_i}},f.prototype._isInsideHistropediaJSLink=function(t){const e=this._getBrandingTextCoords();return no(t,{left:e.left,top:e.top-ae/2,width:io,height:ae})},f.prototype._isInsideTermsLink=function(t){const e=this._getBrandingTextCoords();return no(t,{left:e.left+io+ga,top:e.top-ae/2,width:ma,height:ae})};function ya(){const t=window.open("https://js.histropedia.com","_blank","noopener,noreferrer");t&&(t.opener=null)}function wa(){const t=window.open("https://js.histropedia.com/licence.html","_blank","noopener,noreferrer");t&&(t.opener=null)}function no(t,e){return t.left>=e.left&&t.left<=e.left+e.width&&t.top>=e.top&&t.top<=e.top+e.height}const Ai=({startToken:t,offsetX:e=0,dx:i=0,totalDx:n=0}={})=>({startToken:t,offsetX:e,dx:i,totalDx:n}),Ii=({centre:t=null,scale:e=0,zoom:i=0,distance:n=0,zoomDelta:o=0,dx:s=0,totalZoomDelta:r=0,pointers:a=[]}={})=>({centre:t,scale:e,zoom:i,distance:n,zoomDelta:o,dx:s,totalZoomDelta:r,pointers:a}),ba=({centre:t=null,zoom:e=0,zoomDelta:i=0}={})=>({centre:t,zoom:e,zoomDelta:i}),va=({viewport:t}={})=>{var n,o;if(!t)return{viewport:{x:0,y:0}};const{x:e=(n=t.left)!=null?n:0,y:i=(o=t.top)!=null?o:0}=t;return{viewport:{x:e,y:i}}},oo=100,Sa=.01,La=.005,_a=.004,Aa=1200;function le(t,e){return Number.isFinite(t)&&t>0?t:e}function Ia(t,e){if(!(t!=null&&t.canvas))return!1;const i=t.canvas.ownerDocument;if(!i||typeof i.elementFromPoint!="function")return!0;const{x:n,y:o}=ne(e),s=i.elementFromPoint(n,o);if(!s)return!1;const r=t._laneViewportElement||t.canvas;return r===s||r.contains(s)}f.prototype.enableDragging=function(){const e=this,i={relativePos:null,isDoubleClick:!1,isArticleClick:!1,isArticleDoubleClick:!1,isTermsClick:!1,isHjsClick:!1,article:null,lastClick:{time:0,targetType:null,articleId:null,relativePos:null}},n={initial:{distance:0,zoom:0},centre:{},scale:1,prevActualZoom:0},o=2,s=5,r=500;function a(b,v,S=o){return Math.abs(b.left-v.left)<=S&&Math.abs(b.top-v.top)<=S}function l(b){const v=zr(e.canvas);return{x:b.x-v.left,y:b.y-v.top}}function h(){i.relativePos=null,i.isDoubleClick=!1,i.isArticleClick=!1,i.isArticleDoubleClick=!1,i.isTermsClick=!1,i.isHjsClick=!1,i.article=null}function c(){i.lastClick.time=0,i.lastClick.targetType=null,i.lastClick.articleId=null,i.lastClick.relativePos=null}function u(){return i.isHjsClick?"branding-hjs":i.isTermsClick?"branding-terms":i.isArticleClick&&i.article?"article":"timeline"}function m(b,v){const{lastClick:S}=i,M=u();return!S.time||b-S.time>=r||S.targetType!==M?!1:M==="article"?!!i.article&&S.articleId===i.article.id:M==="timeline"?!!S.relativePos&&a(S.relativePos,v,s):!1}function d(b){i.lastClick.time=Date.now(),i.lastClick.targetType=u(),i.lastClick.articleId=i.article?i.article.id:null,i.lastClick.relativePos=b?W({},b):null}function g(b,v){if(Fr(),v.list.length>=2){h(),c(),e.isPinching||(n.centre=l(Yn(v)),n.initial.distance=Wn(v),n.initial.zoom=e.timescaleManager.zoom,e.isPinching=!0,n.prevActualZoom=n.initial.zoom,e.startAnimation(),e.trigger("zoom-pinch-start",Ii({centre:n.centre,scale:1,distance:n.initial.distance,zoom:n.initial.zoom,zoomDelta:0,totalZoomDelta:0,pointers:[...v.list]}),b));return}h();const S=i.relativePos=e.getRelativePosition(b);e.options.disableBranding||(i.isHjsClick=e._isInsideHistropediaJSLink(S),i.isTermsClick=e._isInsideTermsLink(S));let M=!1;if(!(i.isHjsClick||i.isTermsClick))for(let E=e.articles.length-1;E>=0;E--){const x=e.articles[E];if(x.isVisible&&x.isInside(S)){i.isArticleClick=!0,i.article=x,x.isActive&&e.options.article.draggable&&(M=!0);break}}const P=Date.now();if(i.isDoubleClick=m(P,S),i.isArticleDoubleClick=i.isArticleClick&&i.isDoubleClick,M){e.draggingArticle=i.article,i.article.startDragging(S,b);return}e.draggingArticle===null&&e.isInVicinity(b,e.options.draggingVicinity,S)&&e.startDragging(b)}function p(b,v){if(e.isPinching){const S=e.timescaleManager.zoomOptions.ratio,M=n.centre.x;n.centre=l(Yn(v));const P=Wn(v);n.scale=P/n.initial.distance;const E=Math.log(n.scale)/Math.log(S),x=n.initial.zoom+E,Z=M-n.centre.x;e.setZoomByPivotPixel(x,n.centre.x,Z);const R=e.timescaleManager.zoom,V=R-n.initial.zoom,B=R-n.prevActualZoom;n.prevActualZoom=R,e.trigger("zoom-pinch",Ii({centre:n.centre,scale:n.scale,distance:P,zoom:R,pointers:[...v.list],dx:Z,zoomDelta:B,totalZoomDelta:V}),b)}else if(e.isDragging)e.doDrag(b);else if(e.draggingArticle!==null){const S=e.getRelativePosition(b);e.draggingArticle.dragging(S,b)}else b.pointerType==="mouse"&&(e.updateMouseoverArticle(b),e.mouseoverArticle!==null&&e.trigger("article-pointermove",e.mouseoverArticle,b));e.options.enableCursor&&e.updateCursor(b)}function w(b,v){var x,Z,R;if(e.isPinching&&v.list.length<2){const V=v.list.length===1?Yr(v):null,B=n.scale||1,z=e.timescaleManager.zoom,it=z-n.initial.zoom,kt=z,ut=(n.initial.distance||0)*B;e.isPinching=!1,h(),e.trigger("zoom-pinch-end",Ii({centre:n.centre,scale:B,distance:ut,zoom:kt,zoomDelta:0,dx:0,totalZoomDelta:it,pointers:[...v.list]}),b),V?e.isDragging&&e.resetDragTracking(V):e.isDragging?(e.resetDragTracking(ne(b)),e.endDragging(b)):((x=e.settleDateBounds)==null||x.call(e),e.isPanning||(Z=e._flushTimelineStateChange)==null||Z.call(e));return}const S=e.getRelativePosition(b),M=b.type==="pointercancel"||b.type==="touchcancel";let P=!1;if(!M&&i.relativePos&&a(i.relativePos,S)){if(i.isHjsClick)ya();else if(i.isTermsClick)wa();else if(i.isArticleClick)e.select(i.article.id),i.article.clicked(i.relativePos),e.options.enableCursor&&(e.canvas.style.cursor=i.article.getCursor(S)),e.trigger("article-click",i.article,b),i.isArticleDoubleClick&&e.trigger("article-dblclick",i.article,b);else{const{left:V=0,top:B=0}=i.relativePos||{},z=va({viewport:{x:V,y:B}});e.trigger("timeline-click",z,b),i.isDoubleClick&&e.trigger("timeline-dblclick",z,b)}P=!0}P?d(i.relativePos):i.relativePos&&c(),h();const E=e.draggingArticle;E!==null?(E.stopDragging(b),e.draggingArticle=null,(R=e._flushTimelineStateChange)==null||R.call(e)):e.isDragging&&e.endDragging(b),e.redraw()}this._dragPointerTracker=new Hr(this.canvas,{onStart:g,onMove:p,onEnd:w})},f.prototype.startDragging=function(e){var n,o;(n=this.stopPanAnimation)==null||n.call(this),(o=this.stopZoomAnimation)==null||o.call(this),this.isDragging=!0;const i=ne(e);f.prototype.resetDragTracking.call(this,i),this.trigger("viewport-drag-start",Ai({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow}),e)},f.prototype.resetDragTracking=function(e){this.dragOrigin={left:e.x,top:e.y},this.dragStartX=e.x,this.dragStartY=e.y,this.dragMomentumSamples=[{time:Date.now(),x:e.x}],this.dragDateBoundsState=null;const i=we(this);if((i==null?void 0:i.overflow)==="elastic"){const n=At(this);if(!n)return;const o=Kn(this),s=Lt(o.start,o.end);let r=o.start;if(i.minPoint&&Et(o.start,i.minPoint)<0){const a=Lt(o.start,i.minPoint);r=Tt(i.minPoint,-Jn(this,a))}else if(i.maxPoint&&Et(o.end,i.maxPoint)>0){const a=Lt(i.maxPoint,o.end);r=Tt(i.maxPoint,Jn(this,a)-s)}this.dragDateBoundsState={leftDayPoint:r,pixelsPerDay:n,viewportSpanDays:s}}},f.prototype.endDragging=function(e){var o,s,r;this.isDragging=!1;const i=ne(e),n=this.dragOrigin.left-i.x;if(this.trackDragMomentumSample(i.x),this.trigger("viewport-drag-end",Ai({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow,totalDx:n}),e),(o=this.settleDateBounds)!=null&&o.call(this)){this.dragDateBoundsState=null,this.isPanning||(s=this._flushTimelineStateChange)==null||s.call(this);return}this.dragDateBoundsState=null,this.startDragMomentum(),this.isPanning||(r=this._flushTimelineStateChange)==null||r.call(this)},f.prototype.doDrag=function(e){var r;this.isPanning&&((r=this.stopPanAnimation)==null||r.call(this));const i=ne(e),n=this.dragStartX-i.x,o=this.dragOrigin.left-i.x,s=Math.abs(o);if(this.dragStartX=i.x,this.trackDragMomentumSample(i.x),this.isAnimating||this.startAnimation(),s>30&&(this.animation.dragRedrawFunction=this.defaultRedraw),this.dragDateBoundsState){const a=Tt(this.dragDateBoundsState.leftDayPoint,o/this.dragDateBoundsState.pixelsPerDay);oa(this,a,this.dragDateBoundsState.viewportSpanDays)}else this.updateFromByPixels(n);this.trigger("viewport-drag",Ai({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow,dx:n,totalDx:o}),e)},f.prototype.trackDragMomentumSample=function(e){var a;const i=Date.now(),n=((a=this.options.pan)==null?void 0:a.momentum)||{},o=le(n.sampleWindow,oo),s=this.dragMomentumSamples||[],r=i-o;for(;s.length>0&&s[0].time<r;)s.shift();s.push({time:i,x:e}),this.dragMomentumSamples=s},f.prototype.startDragMomentum=function(){var p,w,b;const e=((p=this.options.pan)==null?void 0:p.momentum)||{};if(e.active!==!0){this.dragMomentumSamples=[];return}const i=le(e.sampleWindow,oo),n=Date.now()-i,o=(this.dragMomentumSamples||[]).filter(v=>v.time>=n);if(this.dragMomentumSamples=[],o.length<2||this.isPinching||this.draggingArticle!==null)return;const s=o[0],r=o[o.length-1],a=r.time-s.time;if(a<=0)return;const l=(s.x-r.x)/a,h=le(e.minVelocity,Sa);if(Math.abs(l)<h)return;this.isPanning&&((w=this.animation.pan)!=null&&w.stop)&&this.animation.pan.stop(),(b=this.stopZoomAnimation)==null||b.call(this);const c=le(e.friction,_a),u=le(e.stopVelocity,La),m=le(e.maxDuration,Aa);if(!Number.isFinite(l)||!Number.isFinite(c))return;this.isPanning=!0,this.startAnimation();const d=this,g=qr({velocity:l,friction:c,minVelocity:u,maxDuration:m,shouldStop(){return d.isDragging||d.isPinching?(d.isPanning=!1,!0):!1},onUpdate(v){var S;d.updateFromByPixels(v),d.requestRedraw(),sa(d)&&(d.isPanning=!1,d.animation.pan===g&&(d.animation.pan=null),g.stop(),(S=d.settleDateBounds)==null||S.call(d))},onComplete(){var v;d.isPanning=!1,d.animation.pan===g&&(d.animation.pan=null),(v=d.settleDateBounds)==null||v.call(d)}});this.animation.pan=g},f.prototype.updateFromByPixels=function(t,e={}){var o;this.repositionWindow-=t;let i=this.timescaleManager.startToken,n=this.timescaleManager.getPrevious(i);for(;this.repositionWindow>=n.length;)this.repositionWindow-=n.length,i=n,n=this.timescaleManager.getPrevious(i);for(;-this.repositionWindow>=i.length;)this.repositionWindow+=i.length,i=this.timescaleManager.getNext(i);this.timescaleManager.setStartToken(i),(o=this._markTimelineStateChanged)==null||o.call(this),!(e.skipDateBounds||!we(this))&&Nt(this,{mode:this.isDragging||this.isPinching?"elastic":"clamp"})},f.prototype.updateMouseoverArticle=function(t,e=this.articles){const i=this.mouseoverArticle;let n=null;if(Ia(this,t)){const o=this.getRelativePosition(t);for(let s=e.length-1;s>=0;s--){const r=e[s];if(r.isVisible&&r.isInside(o)){n=r;break}}}this.mouseoverArticle=n,i!==n&&(i!==null&&i.pointerLeave(t),n!==null&&n.pointerEnter(t),this.requestRedraw(this.redraw))},f.prototype.load=function(t){this.addArticles(t),this.updateCurrentDensitySetting(),this.updateArticlesGroupIndex(),this.requestRedraw()},f.prototype.addArticles=function(t,e,i){if(t.length===0){i&&i.call(this);return}const n=this.articles.map(function(s){return s.id}),o=[];for(let s=0;s<t.length;s++){const r=t[s];n.indexOf(_(r,"id"))===-1&&(o.push(r),this._createImplicitLane(this._resolveLaneIdFromArticleData(r)))}this._updateLaneLayout();for(let s=0;s<o.length;s++){const r=new I(this,_(o[s],"id"));this.articles.push(r),r.setupByReceivedData(o[s]),r.registerPosition(this.getOriginalPosition(r))}this._refreshLaneOrder(),this.updateIsActiveStatus(),i&&i.call(this)},f.prototype.getDmyFromInput=function(t){var i,n,o;let e;if(typeof t=="string"){if(e=y.fromString(t),!Number.isFinite(e.year))throw new Error(`Invalid Histropedia date string: ${t}`)}else t instanceof y?e=new y(t):e=new y({precision:t.precision,year:t.year,month:(i=t.month)!=null?i:1,day:(n=t.day)!=null?n:1,hour:t.hour,minute:t.minute,second:t.second,millisecond:t.millisecond});return(o=this.options)!=null&&o.shiftBceDates&&e.year<0&&(e.year+=1),e},f.prototype.getActiveArticle=function(){for(let t=this.articles.length-1;t>=0;t--)if(this.articles[t].isActive)return this.articles[t];return null},f.prototype.getArticleById=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];if(i.id===t)return i}},f.prototype.bringFront=function(t){const e=so(this.articles,t);e>=0&&pr(this.articles,e,this.articles.length-1)},f.prototype.select=function(t){this.bringFront(t);const e=this.getActiveArticle();this.updateIsActiveStatus();const i=this.getActiveArticle();i!==e&&i&&this.trigger("article-select",i),this._emitTimelineStateChange()},f.prototype.activated=function(t){this.select(t.id)},f.prototype.updateIsActiveStatus=function(){for(let t=0;t<this.articles.length;t++)this.articles[t].isActive=!1;for(let t=this.articles.length-1;t>=0;t--)if(this.articles[t].isDataLoaded){this.articles[t].isActive=!0;return}},f.prototype.getVisibleArticlesClone=function(){const t=[];for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isVisible&&i.isDataLoaded&&t.push(i)}return t},f.prototype.hasArticle=function(t){let e;for(let i=0;i<this.articles.length;i++)this.articles[i].id===t&&(e=this.articles[i]);return!Te(e)},f.prototype.reposition=function(t,e){if(t.isDragging)return;const i=this.getOriginalPosition(t,e);t.registeredPosition=i;const n=t.finalOffset;if(!this.options.article.animation.move.active){t.position={left:i.left+n.left,top:i.top+n.top},t.offset={left:n.left,top:n.top};return}t.moveAnimation.finalOffset.top!==n.top||t.moveAnimation.finalOffset.left!==n.left?t.moveToOffsetWithAnim(n,!0):t.position={left:i.left+t.offset.left,top:i.top+t.offset.top}},f.prototype.getOriginalPosition=function(t,e){let i=this.getPixel(t.period.from,e);if(this.options.article.collectOngoing){const s=this.getPixel(t.period.to,e),r=isNaN(i)||i<0,a=isNaN(s)||s>0;r&&a&&(i=0)}const n=t.getCurrentStyle(),o=this.getLaneById(t.laneId);return this._isLaneLayoutActive()&&o&&o.geometry?{left:i-n.connectorLine.offsetX,top:o.geometry.bodyContentBottom-this._getLaneDistanceToBaseline(o)}:{left:i-n.connectorLine.offsetX,top:this.top-this._getTimelineDistanceToBaseline()}},f.prototype.reorderArticles=function(t){const e=[];for(let o=0;o<t.length;o++){const s=so(this.articles,t[o]);e.push(this.articles[s])}const i=this.getActiveArticle();this.articles=e,this.updateIsActiveStatus();const n=this.getActiveArticle();n!==i&&n&&this.trigger("article-select",n)},f.prototype.getSortedByYearClone=function(){},f.prototype.removeArticleById=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];if(i.id===t){if(typeof i._imageCancel=="function")try{i._imageCancel()}catch(n){}if(typeof i._closeImage=="function")try{i._closeImage({skipRedraw:!0})}catch(n){}i._pendingImageKey=null,this.articles.splice(e,1),this._emitTimelineStateChange();break}}},f.prototype.deleteCurrentArticle=function(){if(this.articles.length!==0){this.removeById(this.articles,this.getActiveArticle().id),this.requestRedraw();for(let t=this.articles.length-1;t>=0;t--){const e=this.articles[t];if(e.isVisible){this.select(e.id),this.requestRedraw();return}}}},f.prototype.pp=function(t){let e="";for(let i=0;i<this.articles.length;i++)e+=`${this.articles[i].title.split(" ")[0]},`;t=t||"",T.log(`${t}:${e}`)};function so(t,e){return t.findIndex(i=>i.id===e)}Dt.prototype.draw=function(t,e){t.globalAlpha=1;const i=e.left,n=e.right,o=e.top,s=e.height,r=Math.max(0,n-i);if(r<=0)return;const a=this.style||{};t.fillStyle=a.backgroundColor||"rgba(200,200,200,0.25)",t.fillRect(i,o,r,s);const l=a.border||null;l&&l.width&&(t.lineWidth=l.width,t.strokeStyle=l.color||"rgba(120,120,120,0.6)",t.strokeRect(i+.5,o+.5,r-1,s-1));const h=a.text||{},c=h.margin||6,u=Math.max(0,r-c*2);if(u>2){t.font=h.font||"500 12px Calibri",t.textAlign=h.align||"center",t.textBaseline=h.baseline||"middle",t.fillStyle=h.color||"#222";const m=this.title||"",d=t.measureText(m).width;let g=m;if(d>u){const v=t.measureText.bind(t);let S=0,M=m.length,P=0;const x=v("…").width,Z=Math.max(0,u-x);for(;S<=M;){const R=Math.floor((S+M)/2),V=m.substring(0,R);v(V).width<=Z?(P=R,S=R+1):M=R-1}g=P>0?`${m.substring(0,P)}…`:""}const p=h.align==="left"?i+c:h.align==="right"?n-c:Math.floor((i+n)/2);let w;switch(h.verticalAlign||"middle"){case"top":w=o+(h.margin||0);break;case"bottom":w=o+s-(h.margin||0);break;default:w=o+Math.floor(s/2);break}w+=h.offsetY||0,t.fillText(g,p,w)}};function ro(t){t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor="transparent black"}function ao(t,e,i,n,o,s){t.moveTo(e+s,i),t.lineTo(e+n-s,i),s>0&&t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+o),t.lineTo(e,i+o),t.lineTo(e,i+s),s>0&&t.quadraticCurveTo(e,i,e+s,i),s===0&&t.closePath()}function Ve(t,e,i,n,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.arcTo(e+n,i,e+n,i+s,s),t.lineTo(e+n,i+o-s),t.arcTo(e+n,i+o,e+n-s,i+o,s),t.lineTo(e+s,i+o),t.arcTo(e,i+o,e,i+o-s,s),t.lineTo(e,i+s),t.arcTo(e,i,e+s,i,s),t.closePath()}function lo(t,e,i,n,o,s,r,a){t.beginPath();const l=Math.PI/n;for(let h=0;h<2*n;h++){const c=(h&1)===0?s:o,u=e+Math.cos(1+h*l)*c,m=i+Math.sin(1+h*l)*c;h===0?t.moveTo(u,m):t.lineTo(u,m)}t.closePath(),t.lineWidth=1,t.strokeStyle=a,t.fillStyle=r,t.stroke(),t.fill()}function ho(t,e,i,n,o){let s;switch(i){case"left":s=t+n;break;case"center":s=t+e/2;break;case"right":s=t+e-n;break;default:s=t+n}return typeof o=="function"?o(s):i==="center"?t+Math.floor(e/2):s}function co(t,e,i,n,o,s,r,a,l){const h=l/2;t.save(),t.beginPath(),t.arc(r+h,a+h,h,0,Math.PI*2,!1),t.closePath(),t.clip(),t.drawImage(e,i,n,o,s,r,a,l,l),t.restore()}function Ze(t,e,i){const n=t.split(" "),o=[];let s=n[0];for(let r=1;r<n.length;r++){const a=n[r];e.measureText(`${s} ${a}`).width<i?s+=` ${a}`:(o.push(s),s=a)}return o.push(s),o}function Mi(t,e,i,n="…"){if(!t||typeof t.measureText!="function")throw new Error("Invalid canvas context provided");if(typeof e!="string"||e===""||typeof i!="number"||i<=0)return"";if(typeof n!="string"&&(n="…"),t.measureText(e).width<=i)return e;const s=t.measureText(n).width;if(s>=i)return"";const r=i-s;if(r<=0)return"";let a=0,l=e.length,h=0;for(;a<=l;){const c=Math.floor((a+l)/2),u=e.substring(0,c);t.measureText(u).width<=r?(h=c,a=c+1):l=c-1}return h===0?"":e.substring(0,h)+n}function Ue(t,e,i=null,n=null){if(!Array.isArray(t)||t.length===0)return t;if(typeof e!="number"||e<=0)return[];const o=t.length>e,s=o?t.slice(0,e):[...t];if(s.length>0){const r=s.length-1,a=s[r];if(i&&typeof n=="number"&&n>0)if(o){const l=Mi(i,a,n);s[r]=l,l===a&&(s[r]=Mi(i,`${a}…`,n,"…"))}else s[r]=Mi(i,a,n);else o&&(s[r]+="...")}return s}const uo={up:0,down:0};function Ci(t,e={}){const{anchorY:i=0,canvasHeight:n=0,fallbackArea:o=uo}=e,s=Number.isFinite(i)?i:0,r=Number.isFinite(n)?n:0,a=typeof(o==null?void 0:o.up)=="number"&&Number.isFinite(o.up)?Math.max(0,o.up):0,l=typeof(o==null?void 0:o.down)=="number"&&Number.isFinite(o.down)?Math.max(0,o.down):0,h=t||o||uo,c=!!t,u=typeof h.up=="undefined"?c?0:a:h.up,m=typeof h.down=="undefined"?c?0:l:h.down,d=(w,b)=>{if(typeof b=="number")return Number.isFinite(b)?Math.max(0,b):0;const v=typeof b=="object"&&b!==null&&b.value==="edge";if(b==="edge"||v){const S=v?b.padding:0,M=typeof S=="number"&&Number.isFinite(S)?Math.max(0,S):0,P=w==="up"?Math.max(0,s):Math.max(0,r-s);return Math.max(0,P-M)}return 0},g=d("up",u),p=d("down",m);return{up:g,down:p,height:g+p}}const fo=150;f.prototype.defaultRedraw=function(){this.redraw({onArticlesInRangeIsReady:function(e){this.updateVisibleArticlesOfGroups(e),this.forInRangeArticles(function(n){this.reposition(n,e)}),this.stack(e)},onArticlesVisiblityIsReady:function(e){this.updateArticleLines()}})},f.prototype.repositionRedraw=function(){this.redraw({onArticlesInRangeIsReady:function(e){this.updateVisibleArticlesOfGroups(e),this.forInRangeArticles(function(n){this.reposition(n,e)})},onArticlesVisiblityIsReady:function(e){this.updateArticleLines()}})},f.prototype.redraw=function(t){if(this.redrawInProgress)return;this.redrawInProgress=!0;const e=this.topRow;t=t||{};const i=this.canvasContext,n=this.getWidth(),o=this.top;this.trigger("timeline-render-start",{canvasContext:i,top:o});const s={},r=this.getTokensAndMarkers(n),a=r.markers,l=r.tokens;s.tokens=l,s.markers=a,this._updateLaneLayout(),this._refreshAdaptiveArticleRuntimeOptions(),this._syncLaneDom(),this.invoke("onMainRangeIsReady",t,s),this.forLoadedArticles(function(c){c.isInView=c.overlapsInclusiveWithDates(s.tokens.start,s.tokens.end),gi(this.options.article.autoStacking.range)?c.isInRange=c.isInView:c.isInRange=!0,c.isVisibleInLane=this._isArticleLaneVisible(c),c.isInRange&&(c.isHiddenByFilter=c.hiddenByFilter)}),this.invoke("onArticlesInRangeIsReady",t,s),this.forLoadedArticles(function(c){c.updateVisibility()}),this.forVisibleArticles(function(c){this.enqueueImageLoad(c)}),this.invoke("onArticlesVisiblityIsReady",t,s),this.forInRangeArticles(function(c){c.indicator={fromX:Math.max(-3,Math.round(this.getPixel(c.period.from,s))),toX:Math.min(this.options.width,Math.round(this.getPixel(c.period.to,s)))},c.indicator.toX-c.indicator.fromX<2&&(c.indicator.toX=c.indicator.fromX+2)}),!this._isLaneLayoutActive()&&this.options.article.autoStacking.fitToHeight&&e!==this.topRow&&this.fitToHeight(!0),this.render(i,o,n,a,s),this.redrawInProgress=!1,this.trigger("timeline-render-end",{canvasContext:i,drawCycleContext:s,top:o})},f.prototype.render=function(t,e,i,n,o){const s=this._getEffectiveVerticalOffset?this._getEffectiveVerticalOffset():this.options.verticalOffset;this.owner||t.clearRect(0,0,i,this.top+s),this.drawTimeBands(t,e,i,o),typeof this.drawCharts=="function"&&this.drawCharts(t,e,i,o),this.drawDraggingHighlight(t,e,i);const r=this.options.style.mainLine.position==="top"?-s:e;this.drawMainline(t,r,i,n),this.drawDateIndicators(t,r),t.globalAlpha=1;for(let l=0;l<this.articles.length;l++){const h=this.articles[l];h.isDataLoaded&&h.isVisible&&!h.isActive&&h.drawPeriodLinesAndConnectors(t,e)}for(let l=0;l<this.articles.length;l++){const h=this.articles[l];h.isDataLoaded&&h.isVisible&&!h.isActive&&h.draw(t)}const a=this.getActiveArticle();a&&a.isVisible&&(a.drawPeriodLinesAndConnectors(t,e),a.draw(t)),this.options.disableBranding||(t.globalAlpha=1,this._drawBranding(t)),this.drawDebugOverlays(t,i,o)},f.prototype.drawDebugOverlays=function(t,e,i){var n;(n=this.options.debugOverlays)!=null&&n.densityRegions&&this.drawDensityRegionBoundaries(t,e,i)};function Ma(t,e,i,n){var o,s,r;return i!=="article"?i:n?((o=e.activeStyle)==null?void 0:o.color)||((s=e.style)==null?void 0:s.color)||t.options.article.defaultStyle.color:((r=e.style)==null?void 0:r.color)||t.options.article.defaultStyle.color}f.prototype.drawDateIndicators=function(t,e){const i=this.options.style.mainLine.dateIndicators;if(!i.visible)return;const n=this.options.style.mainLine.size,o=n/2;t.save(),t.globalAlpha=1,this.forInRangeArticles(function(r){var p;if(r.isHiddenByFilter||!r.isInView)return;const a=r.isActive===!0,l=!a&&r.isVisibleInLane!==!1&&r.isVisibleInGroup===!1,h=a?i.activeStyle:l?i.hiddenStyle:null,c=h?W(W({},i),h):i,u=c.size,m=u/2,d=r.indicator.fromX,g=a&&(h==null?void 0:h.color)==="article";if(t.globalAlpha=(p=c.opacity)!=null?p:1,t.fillStyle=Ma(this,r,c.color,g),c.shape==="circle"){t.beginPath(),t.arc(d,e,m,0,Math.PI*2),t.fill();return}t.fillRect(d-m,e-o,u,n)}),t.restore()},f.prototype.getDensityRegionBoundaryDate=function(t){if(oe(t))return Si(t.day);const e=this.currentDensitySetting.step;if(this.timescaleManager.unit>=$&&e.months!==0){const h=t*e.months,c=Math.floor(h/12),u=h-c*12+1;return new y(c,u,1)}const i=e.days===0?e.months*30:e.days,n=t*i;let o=Math.floor((n-1)/372);const s=n-o*372;let r=Math.floor((s-1)/31)+1;const a=(s-1)%31+1,l=new y(o,r,a);return l.day!==a?(r++,r>12&&(r=1,o++),new y(o,r,1)):l},f.prototype.getDensityRegionBoundaryPoint=function(t){if(oe(t)){const e=Vr(t);return{date:Si(e.dayNumber),dayFraction:e.dayFraction}}return{date:this.getDensityRegionBoundaryDate(t),dayFraction:0}},f.prototype.drawDensityRegionBoundaries=function(t,e,i){var c;const n=i==null?void 0:i.tokens;if(!(n!=null&&n.start)||!(n!=null&&n.end)||!((c=this.currentDensitySetting)!=null&&c.step))return;const o=St(this.calculateGroupIndex(n.start),-1),s=St(this.calculateGroupIndex(n.end),1),r=this.timescaleManager.startToken.value,a=At(this),l=this.options.height;let h=null;t.save(),t.beginPath(),t.globalAlpha=1,t.lineWidth=1,t.strokeStyle="rgba(204, 0, 153, 0.8)",t.setLineDash([4,4]);for(let u=o;se(u,s)<=0;u=St(u,1)){const m=this.getDensityRegionBoundaryPoint(u),d=this.timescaleManager.getPixelsBetween(r,m.date)+m.dayFraction*a+this.repositionWindow,g=Math.round(d)+.5;g<0||g>e||g===h||(t.moveTo(g,0),t.lineTo(g,l),h=g)}t.stroke(),t.restore()},f.prototype.drawMainline=function(t,e,i,n){if(this.options.style.mainLine.visible){t.globalAlpha=1;const o=this.options.style.mainLine.size>>1,s=this.options.style.mainLine.color;let r=typeof s=="string"?s:kn;(s==null?void 0:s.type)==="gradient"&&typeof s.topColor=="string"&&typeof s.bottomColor=="string"&&(r=t.createLinearGradient(0,e-o,0,e+o),r.addColorStop(0,s.topColor),r.addColorStop(1,s.bottomColor)),t.beginPath(),t.lineWidth=this.options.style.mainLine.size,t.strokeStyle=t.fillStyle=r,t.moveTo(0,e),t.lineTo(i,e),t.stroke();for(const a in n)this.drawMarkersAndLabels(t,n[a],a,e+o,{minorTokens:n[k],viewportWidth:i});this.drawParentDateLabels(t,e+o,i)}},f.prototype.drawDraggingHighlight=function(t,e,i){if(!this.isDragging)return;const n=this.options.style.draggingHighlight||{};if(!n.visible)return;t.fillStyle=n.color;const o=this.top,s=this.options.height,r={up:0,down:60},{up:a,height:l}=Ci(n.area,{anchorY:o,canvasHeight:s,fallbackArea:r});l<=0||t.fillRect(0,o-a,i,l)},f.prototype.drawTimeBands=function(t,e,i,n){const o=this.options.timeBand||{};if(!o.visible||!this.timeBands||this.timeBands.length===0)return;const s=n||{tokens:this.getTokensAndMarkers(i).tokens},r=this._getVisibleTimeBands(s);if(r.length===0)return;const a=this.top,l=this.options.height,h={up:0,down:40},{up:c,height:u}=Ci(o.area,{anchorY:a,canvasHeight:l,fallbackArea:h});if(u<=0)return;const m=a-c;t.save();for(let d=0;d<r.length;d++){const g=r[d];let p=Math.round(this.getPixel(g.period.from,s)),w=Math.round(this.getPixel(g.period.to,s));w<0||p>i||(p=Math.max(0,p),w=Math.min(i,w),!(w-p<=0)&&g.draw(t,{left:p,right:w,top:m,height:u}))}t.restore()},f.prototype.getTokensAndMarkers=function(t){var h,c;const e={},i={};i[F]=[],i[k]=[];const n=(c=(h=this.timescaleManager).getSubdayVisualMarkerLayout)==null?void 0:c.call(h);let o=this.repositionWindow,s=this.timescaleManager.startToken;e.start=s.value;const r=9;let a=0,l=s.type===F&&o<=0;for(;a<r||!l;)s=this.timescaleManager.getPrevious(s),o-=s.length,a++,s.type===F&&o<=0&&(l=!0);do s.drawX=o,e[s.value.toKeyString()]=o,n||i[s.type].push(s),o+=s.length,s=this.timescaleManager.getNext(s);while(o<t+fo);if(n){const u=this.timescaleManager.createSubdayVisualMarkers(t,this.repositionWindow,n);i[F]=u[F],i[k]=u[k]}return e.end=this.getPivotPoint(t+fo).date,{tokens:e,markers:i}};function Ge(t,e,i){var a;const n=t.measureText(e.label).width,o=Number.isFinite((a=i.offset)==null?void 0:a.x)?i.offset.x:0;let r=Math.round(e.drawX)+o;return i.textAlign==="center"?r-=n/2:(i.textAlign==="right"||i.textAlign==="end")&&(r-=n),{left:r,width:n}}function mo(t,e,i){return i==="center"?t+e/2:i==="right"||i==="end"?t+e:t}function Ca(t,e){var i;return(t==null?void 0:t.enabled)===!0?!0:(t==null?void 0:t.enabled)!=="auto"?!1:Number.isFinite((i=e[0])==null?void 0:i.unit)&&e[0].unit<=$}const Di=8;function Da(t,e,i,n){var c;if(((c=i.sticky)==null?void 0:c.enabled)!==!0||!Number.isFinite(n))return null;const o=Number.isFinite(i.sticky.offsetX)?i.sticky.offsetX:0;let s=-1,r;for(let u=0;u<e.length;u++){const m=Ge(t,e[u],i);m.left<=o&&(s=u,r=m)}if(s<0)return null;const a=e[s],l=e[s+1];if(a.drawX>n||!l&&a.drawX+a.length<0)return null;let h=o;if(l){const u=Ge(t,l,i);h=Math.min(h,u.left-r.width-Di)}return{token:a,labelX:mo(h,r.width,i.textAlign)}}function Ta(t,e,i,n){const o=i.sticky,s=n.minorTokens||[],r=n.viewportWidth;if(!Ca(o,e)||!Number.isFinite(r))return null;const a=Number.isFinite(o.offsetX)?o.offsetX:0;let l=-1,h;for(let g=0;g<e.length;g++){const p=Ge(t,e[g],i);p.left<=a&&(l=g,h=p)}if(l<0)return null;const c=e[l],u=e[l+1];if(!(c.drawX<=r&&(u?u.drawX>=0:c.visual===!0&&c.drawX+c.length>=0||s.some(g=>g.drawX>=0&&g.drawX<=r&&g.drawX>c.drawX))))return null;let d=a;if(u){const g=Ge(t,u,i);d=Math.min(d,g.left-h.width-Di)}return{token:c,labelX:mo(d,h.width,i.textAlign)}}f.prototype.drawParentDateLabels=function(t,e,i){const n=this.options.style.dateLabel.parent;if(!this.timescaleManager.isParentContextTextVisible(n))return;const o=this.getPivotPoint(0).date,s=this.timescaleManager.createParentContextTokens(o,i,this.repositionWindow);if(s.length===0)return;const r=this.options.style.mainLine.position==="top"?-1:1,a=this.options.style.dateLabel.major,l=this.options.style.marker.major.height,h=e+l*r+a.offset.y+n.height*r+n.offset.y;t.font=n.font,t.textAlign=n.textAlign,t.textBaseline=r===1?"alphabetic":"top";const c=Da(t,s,n,i);let u=Number.NEGATIVE_INFINITY;for(let m=0;m<s.length;m++){const d=s[m],g=(c==null?void 0:c.token)===d?c.labelX:Math.round(d.drawX)+n.offset.x,p=t.measureText(d.label).width;let w=g;n.textAlign==="center"?w-=p/2:(n.textAlign==="right"||n.textAlign==="end")&&(w-=p),!((c==null?void 0:c.token)!==d&&w<u+Di)&&(t.fillStyle=d.value.isInFuture()?n.futureColor:n.color,t.fillText(d.label,g,h),u=w+p)}},f.prototype.drawMarkersAndLabels=function(t,e,i,n,o={}){if(e.length===0)return;switch(i){case JSON.stringify(k):i="minor";break;case JSON.stringify(F):i="major";break;default:T.log("token type not recognised",i,k)}const s=this.options.style.marker[i],r=s.extend,a=this.options.style.mainLine.position==="top"?-1:1,l=s.height,h=e.some(p=>p.label);let c=e[0].value.isInFuture(),u=!c,m,d;a===-1&&(n-=this.options.style.mainLine.size),h&&(m=this.options.style.dateLabel[i],t.font=m.font,t.textAlign=m.textAlign,t.textBaseline=a===1?"alphabetic":"top",d=n+l*a+m.offset.y);const g=h&&i==="major"?Ta(t,e,m,o):null;t.beginPath();for(let p=0;p<e.length;p++){const w=e[p];c=w.value.isInFuture(),u&&c&&(u=!1,t.strokeStyle=s.color,t.lineWidth=1,t.stroke(),t.beginPath());const b=Math.round(w.drawX);t.moveTo(b,n+l*a);const v=r?n+-1*a*this.top:n;if(t.lineTo(b,v),h&&w.label){const S=(g==null?void 0:g.token)===w?g.labelX:b+m.offset.x;t.fillStyle=c?m.futureColor:m.color,t.fillText(w.label,S,d)}}t.strokeStyle=c?s.futureColor:s.color,t.lineWidth=1,t.stroke()},f.prototype.loadTimeBands=function(t){this.addTimeBands(t),typeof this._getEffectiveVerticalOffset=="function"&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),this.requestRedraw()},f.prototype.addTimeBands=function(t){if(!Array.isArray(t)||t.length===0)return;const e=this.timeBands.map(o=>o.id),i=t.filter(o=>e.indexOf(o.id)===-1),n=this.options.timeBand&&this.options.timeBand.defaultStyle||{};for(let o=0;o<i.length;o++){const s=i[o],r=new Dt(this,s.id);r.setupByReceivedData(s),r.style=L({},n,s.style||{}),this.timeBands.push(r)}typeof this._getEffectiveVerticalOffset=="function"&&(this.top=this.options.height-this._getEffectiveVerticalOffset())},f.prototype._getVisibleTimeBands=function(t){if(!this.timeBands||this.timeBands.length===0)return[];const e=t.tokens.start,i=t.tokens.end;return this.timeBands.filter(n=>n.isDataLoaded&&n.visibility!=="hidden"&&n.overlapsInclusiveWithDates(e,i))};function Ti(t,e){return e&&e.resolvedArticleOptions?e.resolvedArticleOptions:Pn(t.options.article||{})}f.prototype._getResolvedArticleOptions=function(t){const e=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t),i=this.getLaneById(e);return Ti(this,i)},f.prototype._getResolvedArticleStyleOverrides=function(t,e){var c,u,m;const i=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t),n=this.getLaneById(i),o=Rn.article||{},s=((c=this._registeredArticleLayoutStyles)==null?void 0:c[e])||{},r=this._explicitArticleOptions||{},a=((u=r.layoutStyles)==null?void 0:u[e])||{},l=(n==null?void 0:n.articleOptions)||{},h=((m=l.layoutStyles)==null?void 0:m[e])||{};return{style:L({},o.defaultStyle||{},s.style||{},r.defaultStyle||{},a.style||{},l.defaultStyle||{},h.style||{}),hoverStyle:L({},o.defaultHoverStyle||{},s.hoverStyle||{},r.defaultHoverStyle||{},a.hoverStyle||{},l.defaultHoverStyle||{},h.hoverStyle||{}),activeStyle:L({},o.defaultActiveStyle||{},s.activeStyle||{},r.defaultActiveStyle||{},a.activeStyle||{},l.defaultActiveStyle||{},h.activeStyle||{})}},f.prototype._getExplicitArticleCardLayout=function(t){if(!t)return null;if(typeof t.cardLayout=="string"&&t.cardLayout!=="")return t.cardLayout;const e=t.data||t,i=_(e,"cardLayout");return typeof i=="string"&&i!==""?i:null},f.prototype._getResolvedArticleTopGap=function(t=this.options.article||{}){const e=t.autoStacking||{};let i=Number(ie(e.topGap,this))||0;return this.options.style.mainLine.position==="top"&&(i-=this.options.verticalOffset),i},f.prototype._getTimelineArticleAvailableHeight=function(){return Math.max(0,this.top-this._getResolvedArticleTopGap())},f.prototype._getLaneArticleAvailableHeight=function(t){return!t||!t.geometry?0:Math.max(0,t.geometry.bodyContentBottom-t.geometry.bodyContentTop)},f.prototype._getAvailableHeightForArticle=function(t){const e=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t);return this._isLaneLayoutActive()?this._getLaneArticleAvailableHeight(this.getLaneById(e)):this._getTimelineArticleAvailableHeight()},f.prototype._resolveCardLayoutFromBreakpoints=function(t){var i;const e=Array.isArray((i=this.options.article)==null?void 0:i.cardLayoutBreakpoints)?this.options.article.cardLayoutBreakpoints:[];for(let n=0;n<e.length;n++){const o=e[n];if(!(!o||!Number.isFinite(o.maxHeight)||typeof o.layout!="string"||o.layout==="")&&t<=o.maxHeight)return o.layout}return null},f.prototype._resolveDefaultCardLayoutName=function(t){const e=this._getResolvedArticleOptions(t),i=this._resolveCardLayoutFromBreakpoints(this._getAvailableHeightForArticle(t));if(i)return i;const n=e.defaultCardLayout;return typeof n=="string"&&n!==""?n:"portrait"},f.prototype._resolveArticleCardLayoutName=function(t){return this._getExplicitArticleCardLayout(t)||this._resolveDefaultCardLayoutName(t)},f.prototype._getTimelineDistanceToBaseline=function(){var e,i;if(Number.isFinite((e=this._runtimeArticleOptions)==null?void 0:e.distanceToBaseline))return this._runtimeArticleOptions.distanceToBaseline;const t=this._resolveDefaultCardLayoutName();return Oe((i=this.options.article)==null?void 0:i.distanceToBaseline,this._getTimelineArticleAvailableHeight(),!1,t)},f.prototype._getLaneAutoStackingOptions=function(t){return Ti(this,t).autoStacking||{}},f.prototype._getLaneDistanceToBaseline=function(t){var n;if(!this._isLaneLayoutActive())return this._getTimelineDistanceToBaseline();if(Number.isFinite((n=t==null?void 0:t._runtimeArticleOptions)==null?void 0:n.distanceToBaseline))return t._runtimeArticleOptions.distanceToBaseline;const e=Ti(this,t),i=this._resolveDefaultCardLayoutName({laneId:t==null?void 0:t.id});return Oe(e.distanceToBaseline,this._getLaneArticleAvailableHeight(t),!0,i)},f.prototype._refreshAdaptiveArticleRuntimeOptions=function(){var n,o;const t=this._isLaneLayoutActive(),e=this._getTimelineArticleAvailableHeight(),i=this._resolveDefaultCardLayoutName();this._runtimeArticleOptions={availableHeight:e,defaultCardLayout:i,distanceToBaseline:Oe((n=this.options.article)==null?void 0:n.distanceToBaseline,e,!1,i)};for(let s=0;s<this.lanes.length;s++){const r=this.lanes[s],a=t&&r.geometry?this._getLaneArticleAvailableHeight(r):0,l=(o=r==null?void 0:r.resolvedArticleOptions)==null?void 0:o.distanceToBaseline,h=this._resolveDefaultCardLayoutName({laneId:r==null?void 0:r.id});r._runtimeArticleOptions={availableHeight:a,defaultCardLayout:h,distanceToBaseline:Oe(l,a,t,h)}}this.forLoadedArticles(s=>{const r=this._resolveDefaultCardLayoutName(s),a=this._resolveArticleCardLayoutName(s);if(s._resolvedCardLayoutName!==a){s.initialiseStyles(s.data),s.invalidateCaches();return}s._resolvedDefaultCardLayout=r,s._resolvedCardLayoutName=a})};function xt(...t){return t.filter(Boolean).join(" ")}function Pt(t){return`${Math.round(t||0)}px`}function go(t,e){const i=e===t.length-1,n=e===0,o=["histropedia-lane",`histropedia-lane-index-${e}`];return i&&o.push("histropedia-lane-position-top"),n&&o.push("histropedia-lane-position-bottom"),!i&&!n&&o.push("histropedia-lane-position-middle"),o}function Pa(t){switch(t){case"center":return"center";case"right":return"flex-end";default:return"flex-start"}}function zt(t,e){return A(t||{},e)?_(t,e):void 0}function po(t,e,i){return e?{visible:!1,rootClassName:xt(...go(t.lanes,i),t.options.lane.defaultClassName,e.className),zIndex:String(t.lanes.length-i),headerClassName:xt("histropedia-lane-header",t.options.lane.defaultHeaderClassName,e.headerClassName),bodyClassName:xt("histropedia-lane-body",t.options.lane.defaultBodyClassName,e.bodyClassName),titleClassName:xt("histropedia-lane-title",t.options.lane.defaultTitleClassName,e.titleClassName)}:{visible:!1}}function ka(t,e,i){var l,h;const n=e.geometry,o=e.style||{},s=zt(o,"title.textAlign"),r=zt(o,"body.borderWidth"),a=zt(o,"body.borderRadius");return{visible:!0,rootClassName:xt(...go(t.lanes,i),t.options.lane.defaultClassName,e.className),zIndex:String(t.lanes.length-i),headerClassName:xt("histropedia-lane-header",t.options.lane.defaultHeaderClassName,e.headerClassName),bodyClassName:xt("histropedia-lane-body",t.options.lane.defaultBodyClassName,e.bodyClassName),titleClassName:xt("histropedia-lane-title",t.options.lane.defaultTitleClassName,e.titleClassName),top:Pt(n.top),height:Pt(n.height),headerHeight:Pt(n.headerHeight||0),headerDisplay:n.headerHeight>0?"":"none",headerBackgroundColor:zt(o,"header.backgroundColor"),bodyTop:Pt(n.bodyTop-n.top),bodyBottom:Pt(n.bottom-n.bodyBottom),bodyBackgroundColor:zt(o,"body.backgroundColor"),bodyBorderColor:zt(o,"body.borderColor"),bodyBorderWidth:typeof r=="undefined"?void 0:Pt(r),bodyBorderStyle:typeof r=="undefined"?void 0:"solid",bodyBorderRadius:typeof a=="undefined"?void 0:Pt(a),titleLeft:Pt(((l=n.headerPadding)==null?void 0:l.left)||0),titleRight:Pt(((h=n.headerPadding)==null?void 0:h.right)||0),titleJustifyContent:typeof s=="undefined"?void 0:Pa(s),titleColor:zt(o,"title.color"),titleFont:zt(o,"title.font"),titleTextAlign:s,titleText:e.title||""}}function _t(t,e,i){t[e]=typeof i=="undefined"?"":i}function Ra(t,e){const i=[];for(let n=t.lanes.length-1;n>=0;n--){const o=String(t.lanes[n].id),s=t._laneDomNodes.get(o);s&&i.push(s.root)}for(let n=0;n<i.length;n++)e.children[n]!==i[n]&&e.insertBefore(i[n],e.children[n]||null)}function yo(t,e,i){if((!e||e.rootClassName!==i.rootClassName)&&(t.root.className=i.rootClassName),(!e||e.headerClassName!==i.headerClassName)&&(t.header.className=i.headerClassName),(!e||e.bodyClassName!==i.bodyClassName)&&(t.body.className=i.bodyClassName),(!e||e.titleClassName!==i.titleClassName)&&(t.title.className=i.titleClassName),(!e||e.zIndex!==i.zIndex)&&_t(t.root.style,"zIndex",i.zIndex),!(e&&e.visible===i.visible&&i.visible===!1)){if(!i.visible){t.root.style.display="none";return}(!e||e.visible!==!0)&&(t.root.style.display=""),(!e||e.top!==i.top)&&(t.root.style.top=i.top),(!e||e.height!==i.height)&&(t.root.style.height=i.height),(!e||e.headerHeight!==i.headerHeight)&&(t.header.style.height=i.headerHeight),(!e||e.headerDisplay!==i.headerDisplay)&&(t.header.style.display=i.headerDisplay),(!e||e.headerBackgroundColor!==i.headerBackgroundColor)&&_t(t.header.style,"backgroundColor",i.headerBackgroundColor),(!e||e.bodyTop!==i.bodyTop)&&(t.body.style.top=i.bodyTop),(!e||e.bodyBottom!==i.bodyBottom)&&(t.body.style.bottom=i.bodyBottom),(!e||e.bodyBackgroundColor!==i.bodyBackgroundColor)&&_t(t.body.style,"backgroundColor",i.bodyBackgroundColor),(!e||e.bodyBorderColor!==i.bodyBorderColor)&&_t(t.body.style,"borderColor",i.bodyBorderColor),(!e||e.bodyBorderWidth!==i.bodyBorderWidth)&&_t(t.body.style,"borderWidth",i.bodyBorderWidth),(!e||e.bodyBorderStyle!==i.bodyBorderStyle)&&_t(t.body.style,"borderStyle",i.bodyBorderStyle),(!e||e.bodyBorderRadius!==i.bodyBorderRadius)&&_t(t.body.style,"borderRadius",i.bodyBorderRadius),(!e||e.titleLeft!==i.titleLeft)&&(t.title.style.left=i.titleLeft),(!e||e.titleRight!==i.titleRight)&&(t.title.style.right=i.titleRight),(!e||e.titleJustifyContent!==i.titleJustifyContent)&&_t(t.title.style,"justifyContent",i.titleJustifyContent),(!e||e.titleColor!==i.titleColor)&&_t(t.title.style,"color",i.titleColor),(!e||e.titleFont!==i.titleFont)&&_t(t.title.style,"font",i.titleFont),(!e||e.titleTextAlign!==i.titleTextAlign)&&_t(t.title.style,"textAlign",i.titleTextAlign),(!e||e.titleText!==i.titleText)&&(t.title.textContent=i.titleText)}}f.prototype._initialiseLaneHost=function(t){if(this._laneHostElement=null,this._laneViewportElement=null,this._laneLayer=null,this._laneDomNodes=new Map,this._laneDomState=new Map,this._laneDomDirty=!0,this._laneLayerDisplay=null,this._hasExplicitLanes=!1,!(t&&t===this.canvas)&&t&&t.nodeName!=="CANVAS"){this._laneHostElement=t;return}const i=this.canvas?this.canvas.parentElement:null;i&&i.firstElementChild===this.canvas&&i.children.length===1&&(this._laneHostElement=i)},f.prototype._ensureLaneViewport=function(){if(!this._laneHostElement||!this.canvas)return null;if(this._laneViewportElement)return this._laneViewportElement;const t=this.canvas.parentElement;if(!t)return null;const e=document.createElement("div");return e.className="histropedia-viewport",e.style.display="block",e.style.position="relative",t.insertBefore(e,this.canvas),e.appendChild(this.canvas),this._laneViewportElement=e,this._syncLaneViewportSize(),e},f.prototype._syncLaneViewportSize=function(){if(!this._laneViewportElement||!this.canvas)return;const t=this.canvas.style&&this.canvas.style.width?this.canvas.style.width:"",e=this.canvas.style&&this.canvas.style.height?this.canvas.style.height:"";this._laneViewportElement.style.width=t,this._laneViewportElement.style.height=e},f.prototype._markLaneDomDirty=function(){this._laneDomDirty=!0},f.prototype._setLaneLayerDisplay=function(t){!this._laneLayer||this._laneLayerDisplay===t||(this._laneLayer.style.display=t,this._laneLayerDisplay=t)},f.prototype._isLaneChromeActive=function(){return this._isLaneLayoutActive()&&this.options.lane.visible!==!1},f.prototype._ensureLaneLayer=function(){const t=this._ensureLaneViewport();if(!t)return null;if(!this._laneLayer){const e=document.createElement("div");e.setAttribute("aria-hidden","true"),e.dataset.histropediaLaneLayer="true",e.style.position="absolute",e.style.inset="0",e.style.pointerEvents="none",e.style.zIndex="0",e.style.overflow="hidden";const i=typeof window!="undefined"&&window.getComputedStyle?window.getComputedStyle(this.canvas).position:this.canvas.style.position;(!i||i==="static")&&(this.canvas.style.position="relative"),this.canvas.style.zIndex="1",this.canvas.style.display||(this.canvas.style.display="block"),this.canvas.parentElement===t?t.insertBefore(e,this.canvas):Bn(t,e),this._laneLayer=e}return this._laneLayer},f.prototype._syncLaneDom=function(){if(!this._isLaneChromeActive()){this._laneLayer&&this._setLaneLayerDisplay("none");return}const t=this._ensureLaneLayer();if(!t)return;this._setLaneLayerDisplay("");const e=this._laneDomDirty,i=new Set;for(let n=0;n<this.lanes.length;n++){const o=this.lanes[n],s=o.geometry,r=o.currentVisibility!=="hidden"&&s,a=String(o.id);let l=this._laneDomNodes.get(a);if(!l){const u=document.createElement("div"),m=document.createElement("div"),d=document.createElement("div"),g=document.createElement("div");u.dataset.histropediaLaneId=a,m.appendChild(d),u.appendChild(m),u.appendChild(g),t.appendChild(u),u.style.position="absolute",u.style.left="0",u.style.right="0",u.style.boxSizing="border-box",u.style.pointerEvents="none",m.style.position="absolute",m.style.left="0",m.style.right="0",m.style.top="0",m.style.boxSizing="border-box",m.style.pointerEvents="none",g.style.position="absolute",g.style.left="0",g.style.right="0",g.style.boxSizing="border-box",g.style.pointerEvents="none",d.style.position="absolute",d.style.top="0",d.style.bottom="0",d.style.display="flex",d.style.alignItems="center",d.style.boxSizing="border-box",d.style.pointerEvents="none",d.style.overflow="hidden",d.style.whiteSpace="nowrap",d.style.textOverflow="ellipsis",l={root:u,header:m,title:d,body:g},this._laneDomNodes.set(a,l)}i.add(a);const h=r?ka(this,o,n):po(this,o,n),c=this._laneDomState.get(a);yo(l,c,h),this._laneDomState.set(a,h)}this._laneDomNodes.forEach((n,o)=>{if(!i.has(o)){const s=po(),r=this._laneDomState.get(o);yo(n,r,s),this._laneDomState.set(o,s)}}),e&&Ra(this,t),this._laneDomDirty=!1};function he(t,e){return t===e}function Oa(t){const e=t&&t.layout?t.layout:{},i=Number.isFinite(e.height)?e.height:null,n=Number.isFinite(e.heightWeight)&&e.heightWeight>0?e.heightWeight:1;return{explicitHeight:i,heightWeight:n}}function je(t){return Math.round(t||0)}function Ea(t,e){return e&&(t.cacheChanged=t.cacheChanged||!!e.cacheChanged,e.styleChanged&&e.laneId!=null&&t.styleLaneIds.add(String(e.laneId))),t}function wo(t,e){if(!Number.isFinite(t))throw new Error(`Lane index must be a finite number. Received: ${t}`);return e<=1?0:Math.min(Math.max(Math.trunc(t),0),e-1)}f.prototype._getDefaultLaneId=function(){const t=this.options&&this.options.lane?this.options.lane:{};return t.defaultId!=null?t.defaultId:"default"},f.prototype._isLaneLayoutActive=function(){if(!Array.isArray(this.lanes)||this.lanes.length===0)return!1;if(this.lanes.length!==1)return!0;const t=this.lanes[0];return!(t&&t.isImplicit&&he(t.id,this._getDefaultLaneId())&&!this._hasExplicitLanes)},f.prototype.getLaneById=function(t){for(let e=0;e<this.lanes.length;e++){const i=this.lanes[e];if(he(i.id,t))return i}},f.prototype._resolveLaneReference=function(t){if(t instanceof et||t&&typeof t=="object"&&t.owner){if(t.owner===this){const e=this.lanes.indexOf(t);if(e>=0)return this.lanes[e]}throw new Error(`Lane "${t.id}" does not belong to this timeline`)}if(t!=null&&t!==""){const e=this.getLaneById(t);if(e)return e}throw new Error(`Lane "${t}" does not exist on this timeline`)},f.prototype._getLanePublicIndex=function(t){const e=this.lanes.indexOf(t);if(e<0)throw new Error(`Lane "${t&&t.id}" does not belong to this timeline`);return e},f.prototype._getInternalLaneIndexFromPublicIndex=function(t,e=this.lanes.length){return wo(t,e)},f.prototype._handleLaneChange=function({requestRedraw:t=!1,refreshOrder:e=!0}={}){e&&this._refreshLaneOrder(),this._markLaneDomDirty(),t&&this.requestRedraw()},f.prototype._createImplicitLane=function(t){const e=t!=null&&t!==""?t:this._getDefaultLaneId(),i=this.getLaneById(e);if(i)return i;const n=new et(this,e);return n.setupByReceivedData({id:e},{implicit:!0}),this.lanes.push(n),this._handleLaneChange(),n},f.prototype._resolveLaneIdFromArticleData=function(t){const e=t?_(t,"lane"):void 0;return e!=null&&e!==""?e:this._getDefaultLaneId()},f.prototype._assignArticleToLane=function(t,e){const i=this._createImplicitLane(e);return t.laneId=i.id,t.laneOrder=i.order||0,i},f.prototype._refreshLaneOrder=function(){for(let t=0;t<this.lanes.length;t++)this.lanes[t].order=t;for(let t=0;t<this.articles.length;t++){const e=this.articles[t],i=this.getLaneById(e.laneId);e.laneOrder=i?i.order:0}this._hasExplicitLanes=this.lanes.some(t=>!t.isImplicit)},f.prototype._handleLaneIdChange=function(t,e){for(let i=0;i<this.articles.length;i++){const n=this.articles[i];he(n.laneId,e)&&(n.laneId=t.id,n.data&&_(n.data,"lane")!=null&&(n.data.lane=t.id))}for(let i=0;i<this.charts.length;i++){const n=this.charts[i];he(n.laneId,e)&&(n.laneId=t.id,n.data&&n.data.lane!=null&&(n.data.lane=t.id))}this._markLaneDomDirty()},f.prototype._refreshArticlesForLane=function(t,{refreshStyles:e=!0}={}){if(e)for(let i=0;i<this.articles.length;i++){const n=this.articles[i];!n.isDataLoaded||!he(n.laneId,t.id)||(n.initialiseStyles(n.data),n.invalidateCaches())}},f.prototype._refreshAllLaneArticleStyles=function(){this.forLoadedArticles(t=>{t.initialiseStyles(t.data),t.invalidateCaches()})},f.prototype._refreshLaneArticleStylesByIds=function(t){!t||t.size===0||this.forLoadedArticles(e=>{t.has(String(e.laneId))&&(e.initialiseStyles(e.data),e.invalidateCaches())})},f.prototype._refreshResolvedLanesFromOptions=function({articleStyleScope:t=null}={}){for(let e=0;e<this.lanes.length;e++)this.lanes[e]._resolveFromData();this._handleLaneChange(),t==="all"?this._refreshAllLaneArticleStyles():t instanceof Set&&this._refreshLaneArticleStylesByIds(t)},f.prototype.loadLanes=function(t){this.addLanes(t),this.requestRedraw()},f.prototype.addLanes=function(t,{suppressArticleRefresh:e=!1}={}){var n,o;if(!Array.isArray(t)||t.length===0)return{cacheChanged:!1,styleLaneIds:new Set};const i={cacheChanged:!1,styleLaneIds:new Set};for(let s=0;s<t.length;s++){const r=t[s]||{},a=r.id!=null?r.id:this._getDefaultLaneId(),l=this.getLaneById(a);if(l){const c=l._applyOption(L({},r,{id:a}),{suppressRedraw:!0,markExplicit:!0,suppressArticleRefresh:e});Ea(i,{cacheChanged:(n=c==null?void 0:c.articleImpact)==null?void 0:n.cacheChanged,styleChanged:(o=c==null?void 0:c.articleImpact)==null?void 0:o.styleChanged,laneId:c==null?void 0:c.laneId});continue}const h=new et(this,a);h.setupByReceivedData(L({},r,{id:a}),{implicit:!1}),this.lanes.push(h)}return this._handleLaneChange(),i},f.prototype.moveLaneToIndex=function(t,e){const i=this._resolveLaneReference(t),n=this._getLanePublicIndex(i),o=wo(e,this.lanes.length);if(n===o)return i;const s=this._getInternalLaneIndexFromPublicIndex(n),r=this._getInternalLaneIndexFromPublicIndex(o),a=this.lanes.splice(s,1)[0];return this.lanes.splice(r,0,a),this._handleLaneChange({requestRedraw:!0}),a},f.prototype.moveLaneBefore=function(t,e){const i=this._resolveLaneReference(t),n=this._resolveLaneReference(e);if(i===n)return i;const o=this._getLanePublicIndex(i),s=this._getLanePublicIndex(n),r=o<s?s-1:s;return this.moveLaneToIndex(i,r)},f.prototype.moveLaneAfter=function(t,e){const i=this._resolveLaneReference(t),n=this._resolveLaneReference(e);if(i===n)return i;const o=this._getLanePublicIndex(i),s=this._getLanePublicIndex(n),r=o<s?s:s+1;return this.moveLaneToIndex(i,r)},f.prototype.moveLaneUp=function(t){const e=this._resolveLaneReference(t);return this.moveLaneToIndex(e,e.order+1)},f.prototype.moveLaneDown=function(t){const e=this._resolveLaneReference(t);return this.moveLaneToIndex(e,e.order-1)},f.prototype.loadLaneArticles=function(t,e){const i=t!=null&&t!==""?t:this._getDefaultLaneId(),o=(Array.isArray(e)?e:[]).map(s=>{const r=L({},s),a=_(s,"lane");return a!=null&&a!==""&&!he(a,i)&&T.warn("loadLaneArticles overriding conflicting article.lane value",{articleId:_(s,"id"),from:a,to:i}),r.lane=i,r});this._createImplicitLane(i),this.load(o)},f.prototype._getActiveLanesForLayout=function(){if(!Array.isArray(this.lanes)||this.lanes.length===0)return[];const t=[];for(let e=0;e<this.lanes.length;e++){const i=this.lanes[e];i.currentVisibility=i.visibility,i.currentVisibility!=="hidden"?t.push(i):i.geometry=null}return t},f.prototype._updateLaneLayout=function(){var w,b,v;const t=this._getActiveLanesForLayout();if(!this._isLaneLayoutActive()||t.length===0){for(let S=0;S<this.lanes.length;S++)this.lanes[S].geometry=null;return}const e=this.options.lane||{},i=typeof e.gap=="number"?e.gap:0,n=typeof e.topGap=="number"?e.topGap:0,o=typeof e.axisGap=="number"?e.axisGap:0,s=this.top-this.options.style.mainLine.size/2-o,r=i*Math.max(t.length-1,0),a=s-n-r,l=t.map(S=>Oa(S));let h=0,c=0;for(let S=0;S<l.length;S++){const M=l[S];M.explicitHeight!=null?h+=M.explicitHeight:c+=M.heightWeight}const u=Math.max(0,a-h),m=this.getWidth(),d=je(s),g=c>0;let p=n;for(let S=t.length-1;S>=0;S--){const M=t[S],P=l[S],E=P.explicitHeight!=null?P.explicitHeight:c>0?u*P.heightWeight/c:0,x=je(p),Z=p+E,R=S===0&&g?d:je(Z),V=Math.max(0,R-x),B=x+V,z=((w=M.layout.header)==null?void 0:w.padding)||{},kt=((b=M.layout.header)==null?void 0:b.visible)!==!1&&typeof((v=M.layout.header)==null?void 0:v.height)=="number"?je(M.layout.header.height):0,ut=x+kt,Gt=B;M.geometry={top:x,left:0,width:m,height:V,bottom:B,headerTop:x,headerHeight:kt,headerBottom:ut,bodyTop:ut,bodyBottom:Gt,bodyLeft:0,bodyRight:m,bodyContentTop:ut,bodyContentBottom:Gt,bodyContentLeft:0,bodyContentRight:m,headerPadding:z},p=Z+i}},f.prototype._isArticleLaneVisible=function(t){const e=this.getLaneById(t.laneId);return!e||!this._isLaneLayoutActive()?!0:e.currentVisibility!=="hidden"};function be(t){return t!=null&&t!==""}function bo(t){return be(t==null?void 0:t.lane)?t.lane:null}function vo(t,e){return be(e)?e:t._getDefaultLaneId()}f.prototype.getChartById=function(t){for(let e=0;e<this.charts.length;e++){const i=this.charts[e];if(i.id===t)return i}},f.prototype.loadCharts=function(t){this.addCharts(t),this.requestRedraw()},f.prototype.removeChart=function(t){for(let e=0;e<this.charts.length;e++)if(this.charts[e].id===t)return this.charts.splice(e,1),this.requestRedraw(),!0;return!1},f.prototype.clearCharts=function(){!Array.isArray(this.charts)||this.charts.length===0||(this.charts=[],this.requestRedraw())},f.prototype.loadLaneCharts=function(t,e){const i=vo(this,t),o=(Array.isArray(e)?e:[]).map(s=>{const r=L({},s),a=bo(s);return a!=null&&a!==i&&T.warn("loadLaneCharts overriding conflicting chart.lane value",{chartId:s==null?void 0:s.id,from:a,to:i}),r.lane=i,r});this.addCharts(o),this.requestRedraw()},f.prototype.addCharts=function(t){if(!Array.isArray(t)||t.length===0)return;const e=this.charts.map(i=>i.id);for(let i=0;i<t.length;i++){const n=t[i]||{};if(n.id==null){T.warn("Skipping chart without id",n);continue}if(e.indexOf(n.id)!==-1){T.warn("Skipping chart with duplicate id",{chartId:n.id,chart:n});continue}const o=bo(n);o!=null&&this._ensureChartLane(o);const s=new ht(this,n.id);s.setupByReceivedData(n),be(s.laneId)&&this._ensureChartLane(s.laneId),this.charts.push(s),e.push(s.id)}this._refreshLaneOrder(),this._updateLaneLayout()},f.prototype._ensureChartLane=function(t){const e=vo(this,t),i=this.getLaneById(e);return i&&!i.isImplicit?i:(typeof this.addLanes=="function"&&this.addLanes([{id:e}],{suppressArticleRefresh:!0}),this.getLaneById(e))},f.prototype._isChartLaneVisible=function(t){if(!be(t.laneId))return!0;const e=this.getLaneById(t.laneId);return e?this._isLaneLayoutActive()?e.currentVisibility!=="hidden":!0:!1},f.prototype._getVisibleCharts=function(){return!this.charts||this.charts.length===0?[]:this.charts.filter(t=>t.isDataLoaded&&t.visibility!=="hidden"&&this._isChartLaneVisible(t))},f.prototype._getChartGeometry=function(t,e){if(be(t.laneId)){const l=this.getLaneById(t.laneId),h=l&&l.geometry?l.geometry:null;return h?{left:h.bodyContentLeft,right:h.bodyContentRight,top:h.bodyContentTop,bottom:h.bodyContentBottom,width:h.bodyContentRight-h.bodyContentLeft,height:h.bodyContentBottom-h.bodyContentTop,lane:l}:null}const i=this.options.chart||{},n=t.area||i.area,o={up:this.top,down:0},{up:s,height:r}=Ci(n,{anchorY:this.top,canvasHeight:this.options.height,fallbackArea:o});if(r<=0)return null;const a=this.top-s;return{left:0,right:e,top:a,bottom:a+r,width:e,height:r}},f.prototype.drawCharts=function(t,e,i,n){if(!(this.options.chart||{}).visible)return;const s=this._getVisibleCharts();if(s.length!==0){t.save();for(let r=0;r<s.length;r++){const a=s[r],l=this._getChartGeometry(a,i);!l||l.width<=0||l.height<=0||a.draw(t,l,n)}t.restore()}},f.prototype._getLaneRowSpacing=function(t,e){const i=this._getLaneAutoStackingOptions(t),n=Array.isArray(e)?e.length:e;if(!t||!i.fitToHeight||n<=1||!t.geometry)return i.rowSpacing;const o=Number(ie(i.topGap,this))||0,s=t.geometry.bodyContentBottom-this._getLaneDistanceToBaseline(t),r=t.geometry.bodyContentTop+o,a=Math.max(0,s-r);return Math.max(Math.round(a/(n-1)),1)},f.prototype.updateArticleLines=function(){const t=this,e=this.options.article.periodLine||{},i=this._isLaneLayoutActive()&&e.position==="lane";function n(l){const h=[];return t.forVisibleArticles(function(c){c.hidePeriodLine||(h.push(c),h[h.length-1].stacking=-1)}),h.sort(t.options.article.periodLine.stacking.sorter),t.options.article.periodLine.stacking.reverseOrder&&h.reverse(),h}function o(l,h){for(let c=0;c<h.length;c++)if(l.overlaps(h[c]))return!1;return!0}function s(l){let h=0;const c=[];let u;do{c[h]=[],u=!1;for(let m=0;m<l.length;m++){const d=l[m];d.stacking>=0||o(d,c[h])&&(c[h].push(d),d.stacking=h,u=!0)}h++}while(u)}const r=n(this.articles);if(!i){s(r);return}const a=new Map;for(let l=0;l<r.length;l++){const h=r[l],c=String(h.laneId),u=a.get(c)||[];u.push(h),a.set(c,u)}a.forEach(l=>{s(l)})},f.prototype.stack=function(t){if(this.articles.length===0||!this.options.article.autoStacking.active)return;function e(h){let c;const u=[],m=[];for(let d=0;d<h.length;d++){const g=h[d];g.isDataLoaded&&g.isInRange&&g.isVisibleInGroup&&!g.isHiddenByFilter&&(g.isActive?c=g:g.isStarred?u.push(g):m.push(g))}return u.sort(ni),m.sort(ni),[].concat(c||[],u,m)}function i(h,c){for(let u=0;u<h.length;u++){const m=h[u];if(c.headerOverlapsWith(m))return!1}return!0}function n(h,c){for(let u=0;u<h.length;u++)if(i(h[u],c))return u;return h.length}function o(h,c){const u=n(h,c);return u>=h.length&&(h[u]=[]),h[u].push(c),!0}const s=e(this.articles);if(this._isLaneLayoutActive()){const h=new Map;for(let u=0;u<s.length;u++){const m=s[u],d=this.getLaneById(m.laneId),g=this._getLaneAutoStackingOptions(d),p=String(m.laneId),w=h.get(p)||[];g.active===!1?(w[0]||(w[0]=[]),w[0].push(m),m.isVisibleInRows=!0):m.isVisibleInRows=o(w,m),h.set(p,w)}this.topRow=0,h.forEach((u,m)=>{const d=this.getLaneById(m),g=this._getLaneAutoStackingOptions(d),p=g.active===!1?0:this._getLaneRowSpacing(d,u);d&&(d.topRow=0);for(let w=0;w<u.length;w++)for(let b=0;b<u[w].length;b++){const v=u[w][b],S=g.active===!1;S||(v.finalOffset={left:0,top:w*-p}),v.row=S?0:w,d&&(d.topRow=Math.max(d.topRow,v.row)),v.isInView&&(this.topRow=Math.max(this.topRow,v.row)),S||this.reposition(v,t)}});const c=this.getActiveArticle();this.articles.sort(ii),c&&this.bringFront(c.id);return}const r=this.options.article.autoStacking.rowSpacing,a=[];for(let h=0;h<s.length;h++)s[h].isVisibleInRows=o(a,s[h]);this.topRow=0;for(let h=0;h<a.length;h++)for(let c=0;c<a[h].length;c++){const u=a[h][c];u.finalOffset={left:0,top:h*-r},u.row=h,u.isInView&&(this.topRow=Math.max(this.topRow,h)),this.reposition(u,t)}const l=this.getActiveArticle();this.articles.sort(ii),l&&this.bringFront(l.id)},f.prototype.notifyEventSpacingChanged=function(){this.requestRedraw(this.defaultRedraw)};const So=.001,Na=120,xa=1e3/60,Lo=120,za=24,Fa=1e-7,_o=[.25,1/3,.5,.67,.75,.8,.9,1,1.1,1.25,1.5,1.75,2,2.5,3,4,5];function Ba(t,e="discrete"){let i=0;if("deltaY"in t&&typeof t.deltaY=="number"&&t.deltaY!==0?i=-t.deltaY:"wheelDelta"in t&&typeof t.wheelDelta=="number"&&t.wheelDelta!==0?i=t.wheelDelta:"detail"in t&&typeof t.detail=="number"&&t.detail!==0&&(i=-t.detail),e==="discrete")return i>0?1:-1;const n=i/120;return n===0?0:n}function Ao(t,e){const i=Math.max(1,Math.abs(e)*.015);return Math.abs(t-e)<=i}function Io(t){const e=Math.abs(t);if(e<za)return!1;for(let i=0;i<_o.length;i++){const n=_o[i];if(Ao(e,Lo*n)||Ao(e,Lo/n))return!0}return!1}function Ha(t){return!!(t.deltaMode===1||typeof t.deltaY=="number"&&Io(t.deltaY)||"wheelDelta"in t&&typeof t.wheelDelta=="number"&&Io(t.wheelDelta))}function Ya(t,e){const i=t.discreteWheelAnimation;return i!=null&&i.active?e:!1}function Wa(t,e){return e&&Number.isFinite(t.animation.wheelZoomTarget)?t.animation.wheelZoomTarget:t.timescaleManager.zoom}function Mo(t,e){let i=e;return i>t.maximum&&(i=t.maximum),i<t.minimum&&(i=t.minimum),i}function Va(t,e){var n;const i=((n=t.discreteWheelAnimation)==null?void 0:n.duration)||250;return i<=0?1:1-Math.pow(.05,Math.max(e,0)/i)}function Pi(t){t.wheelZoomTarget=null,t.wheelZoomPivotPoint=null,t.wheelZoomPivotPixel=null,t.wheelZoomLastFrameTime=null,t.wheelZoomFrame=null}function Za(t){t._wheelZoomStateChangeTimer!=null&&clearTimeout(t._wheelZoomStateChangeTimer),t._wheelZoomStateChangeTimer=setTimeout(()=>{var e;t._wheelZoomStateChangeTimer=null,(e=t._flushTimelineStateChange)==null||e.call(t)},Na)}f.prototype.enableZoomByWheel=function(){this._wheelEnabled||(this._wheelEnabled=!0,this._wheelHandler=e=>{const{allowCtrlWheel:i=!1,wheelMode:n="auto"}=this.options.zoom||{};if(!i&&e.ctrlKey)return;const s=Ba(e,n==="discrete"?"discrete":"proportional");this.onWheel(e,s)},this.canvas.addEventListener("wheel",this._wheelHandler,{passive:!1}),this.canvas.addEventListener("DOMMouseScroll",this._wheelHandler,{passive:!1}))},f.prototype.disableZoomByWheel=function(){this._wheelEnabled&&(this.canvas.removeEventListener("wheel",this._wheelHandler),this.canvas.removeEventListener("DOMMouseScroll",this._wheelHandler),this._wheelEnabled=!1,this._wheelHandler=null)},f.prototype.onWheel=function(e,i){const{wheelSpeed:n,wheelStep:o,maximum:s,minimum:r,proportionalGain:a,proportionalExponent:l,wheelMode:h}=this.options.zoom,c=h!=="discrete",u=Ha(e);if(c&&!u){const S=Math.sign(i)||1;let M=Math.abs(i);M>=1&&l&&l!==1&&(M=Math.pow(M,l)),M*=a,i=S*M}else c&&u&&(i=i>0?1:-1);const m=Ya(this.options.zoom,u);let d=Wa(this,m)+-i*n*o;d=Mo({maximum:s,minimum:r},d);let g,p;if(e.target===this.canvas&&"offsetX"in e&&typeof e.offsetX=="number")g=e.offsetX,p=e.offsetY;else{const S=this.canvas.getBoundingClientRect();g=e.clientX-S.left,p=e.clientY-S.top}const w=this.timescaleManager.zoom;m?this.animateZoomByPivotPoint(d,this.getPivotPoint(g),g):(this.animation.wheelZoomFrame!=null&&cancelAnimationFrame(this.animation.wheelZoomFrame),Pi(this.animation),this.setZoomByPivotPixel(d,g),Za(this));const b=this.timescaleManager.zoom,v=d-w;this.requestRedraw(),e.preventDefault(),this.trigger("zoom-wheel",ba({centre:{x:g,y:p},zoom:m?d:b,zoomDelta:v}),e)},f.prototype.animateZoomByPivotPoint=function(e,i,n){var r,a;if((r=this.stopPanAnimation)==null||r.call(this),this.animation.wheelZoomFrame==null&&((a=this.animation.zoom)!=null&&a.stop)&&(this.animation.zoom.stop(),this.animation.zoom=null),this.animation.wheelZoomTarget=Mo(this.options.zoom,e),this.animation.wheelZoomPivotPoint=i,this.animation.wheelZoomPivotPixel=n,this.animation.wheelZoomFrame!=null)return;const o=this;function s(l){var v;const h=o.animation.wheelZoomTarget;if(!Number.isFinite(h)){Pi(o.animation);return}const c=o.timescaleManager.zoom,u=h-c,m=o.animation.wheelZoomPivotPoint,d=o.animation.wheelZoomPivotPixel;if(Math.abs(u)<=So){o.setZoomByPivotPoint(h,m,d),o.requestRedraw(),Pi(o.animation),(v=o._flushTimelineStateChange)==null||v.call(o);return}const g=o.animation.wheelZoomLastFrameTime,p=g==null?xa:l-g;o.animation.wheelZoomLastFrameTime=l;const w=Va(o.options.zoom,p),b=c+u*w;o.setZoomByPivotPoint(b,m,d),Math.abs(o.timescaleManager.zoom-b)>So&&(o.animation.wheelZoomTarget=o.timescaleManager.zoom),o.requestRedraw(o.repositionRedraw),o.animation.wheelZoomFrame=requestAnimationFrame(s)}this.animation.wheelZoomFrame=requestAnimationFrame(s)},f.prototype.setZoom=function(e,i,n=0){var r,a,l;(r=this.stopPanAnimation)==null||r.call(this),(a=this.stopZoomAnimation)==null||a.call(this);const o=i==null?this.width/2:i,s=n?Math.round(n):0;this.setZoomByPivotPixel(e,o,s),this.requestRedraw(),(l=this._flushTimelineStateChange)==null||l.call(this)},f.prototype.setZoomByPivotPixel=function(e,i,n=0){this.setZoomByPivotPoint(e,this.getPivotPoint(i),i,n)},f.prototype.setZoomByPivotPoint=function(e,i,n,o=0){this.timescaleManager.setZoom(e);const s=this.timescaleManager.setStartDate(i.date),r=Number.isFinite(i.millisecondFraction)?i.millisecondFraction*At(this)/U:i.fraction;this.repositionWindow=s-r,this.updateFromByPixels(-n+o),Nt(this,{mode:this.isDragging||this.isPinching?"elastic":"clamp"})},f.prototype.getPivotPoint=function(e){let i=this.timescaleManager.getStartTokenCloned(),n=this.repositionWindow;n>=0&&(i=this.timescaleManager.getPrevious(i),n-=i.length);let o=i;for(;n<=e;)n+=i.length,o=i,i=this.timescaleManager.getNext(i);const s=o.unit,r=o.length;let a=e-(n-i.length);const l=o.value;let{year:h,month:c,day:u}=l;if(s<=O){const m=At(this)/U;let d=m>0?a/m:0;const g=Math.round(d);Math.abs(d-g)<Fa&&(d=g);const p=Math.floor(d),w=d-p;return o.value=o.value.addMilliseconds(p),a-=p*m,{date:o.value,fraction:a,millisecondFraction:w}}else if(s===$)u=Math.floor(a/r*30.44)+1,a-=(u-1)*r/30.44,o.value=new y(h,c,u);else if(s!==O){const m=this.timescaleManager.unitLengthInYears;let d=Math.floor(a*365.2422*m/r)+1,g=0;d>365&&(g=Math.floor(d/365),d=d-365*g),a=0,o.value=y.getByDayOfYear(h+g,d)}return{date:o.value,fraction:a}},f.prototype.startAnimation=function(t){this.isAnimating||(this.isAnimating=!0,this.animation.redrawFunction=t,this.drawAnimationFrame())},f.prototype.stopAnimation=function(){var t;this.isAnimating=!1,this.animation.dragRedrawFunction=this.repositionRedraw,this.animation.redrawFunction=!1,(t=this._flushTimelineStateChange)==null||t.call(this)},f.prototype.areAnimationsFinished=function(){return!(this.isDragging||this.isPanning||this.isPinching||this.draggingArticle!==null||this.isAnimatingArticles||this.isCustomAnimating)},f.prototype.drawAnimationFrame=function(){if(this.areAnimationsFinished())return this.stopAnimation();const t=this,e=this.getAnimationRedrawFunction();this.updateRedrawRequests(e),requestAnimationFrame(function(i){e.call(t),t.drawAnimationFrame()})},f.prototype.requestRedraw=function(t){t=t||this.defaultRedraw;const e=this;if(!this.isAnimating)return t.call(e);t===this.defaultRedraw&&(this.redrawRequests.default=!0),t===this.repositionRedraw&&(this.redrawRequests.reposition=!0)},f.prototype.updateRedrawRequests=function(t){t===this.defaultRedraw&&(this.redrawRequests.default=!1,this.redrawRequests.reposition=!1),t===this.repositionRedraw&&(this.redrawRequests.reposition=!1)},f.prototype.getAnimationRedrawFunction=function(){return this.isDragging?this.animation.dragRedrawFunction:this.isPanning||this.isPinching?this.defaultRedraw:this.redrawRequests.default?this.defaultRedraw:this.redrawRequests.reposition?this.repositionRedraw:this.animation.redrawFunction||this.animation.defaultRedrawFunction},f.prototype.stopPanAnimation=function(){var t;(t=this.animation.pan)!=null&&t.stop&&this.animation.pan.stop(),this.animation.pan=null,this.isPanning=!1},f.prototype.stopZoomAnimation=function(){var t;(t=this.animation.zoom)!=null&&t.stop&&this.animation.zoom.stop(),this.animation.zoom=null,this.animation.wheelZoomFrame!=null&&cancelAnimationFrame(this.animation.wheelZoomFrame),this._wheelZoomStateChangeTimer!=null&&(clearTimeout(this._wheelZoomStateChangeTimer),this._wheelZoomStateChangeTimer=null),this.animation.wheelZoomTarget=null,this.animation.wheelZoomPivotPoint=null,this.animation.wheelZoomPivotPixel=null,this.animation.wheelZoomLastFrameTime=null,this.animation.wheelZoomFrame=null},f.prototype.switchToPositiveRepositionWindow=function(){if(this.repositionWindow<0){let t=this.timescaleManager.startToken;this.repositionWindow=t.length+this.repositionWindow,t=this.timescaleManager.getNext(t),this.timescaleManager.setStartToken(t)}},f.prototype.zoomToAnim=function(t,e){this.stopPanAnimation(),this.stopZoomAnimation();const i=this.timescaleManager.zoom,n=2e3,o=H.swing,s=this,r=Y({from:i,to:t,duration:n,easing:o,onUpdate(a){s.setZoomByPivotPixel(a,s.width/2),s.requestRedraw()},onComplete(){var a;s.animation.zoom=null,(a=s._flushTimelineStateChange)==null||a.call(s),typeof e=="function"&&e.call(s)}});this.animation.zoom=r},f.prototype.goToPixelAnim=function(t,e={}){var a;this.stopPanAnimation(),this.stopZoomAnimation(),this.isPanning=!0;const i=1e8;let n=!1;Math.abs(t)>i&&(t=Math.sign(t)*i,n=!0),this.startAnimation();let o=0;const s=this,r=Y({from:0,to:t,duration:(a=e.duration)!=null?a:2e3,easing:H[e.easing]||H.swing,onUpdate(l){const h=l-o;o=l,s.updateFromByPixels(h),s.isPinching?(s.isPanning=!1,r.stop()):s.requestRedraw()},onComplete(){var l;n&&e.targetDmy&&s.setStartDate(e.targetDmy),s.isPanning=!1,(l=e.complete)==null||l.call(s)}});this.animation.pan=r},f.prototype.goToDateAnim=function(t,e={}){var i;T.warn("DEPRECATION WARNING: timeline.goToDateAnim(dmy, options) is deprecated. Use timeline.setStartDate(dmy, { padding, animation: { active: true, ... } }) instead."),this.setStartDate(t,{padding:(i=e.offsetX)!=null?i:0,animation:{active:!0,duration:e.duration,easing:e.easing,complete:e.complete}})},f.prototype.repositionWithAnim=function(t){const e=this.getOriginalPosition(t);t.registeredPosition=e;const i={left:e.left+t.dragFinishOffset.left,top:e.top+t.dragFinishOffset.top};t.moveToWithAnim(i)},f.prototype.notifyArticleAnimating=function(t,e){const i=new Date().getTime(),n=this.options.article.animation[t].duration,o=i+n;o>this.lastAnimatingArticle.endTime&&(this.lastAnimatingArticle.id=e,this.lastAnimatingArticle.endTime=o,this.lastAnimatingArticle.animationType=t),this.isAnimatingArticles=!0,this.startAnimation()},f.prototype.toggleAutoFit=function(){const t=this.options.article.autoStacking.fitToHeight=!this.options.article.autoStacking.fitToHeight;return t&&this.fitToHeight(!0),t},f.prototype.fitToHeight=function(t){if(this.topRow+1===1)return;const i=this.options.article.autoStacking.rowSpacing=this.getFitToHeightRowSpacing();return t&&this.requestRedraw(),i},f.prototype.getFitToHeightRowSpacing=function(){const t=this.top-this._getTimelineDistanceToBaseline(),e=this._getResolvedArticleTopGap(),i=this.topRow;if(i===0)return!1;const n=Math.abs(t-e);return Math.max(Math.round(n/i),1)},f.prototype.incrementRowSpacing=function(t,e){return this.options.article.rowSpacing=Math.max(this.options.article.rowSpacing+t,1),e&&this.requestRedraw(),this.options.article.rowSpacing};function Ua(t){return typeof t=="number"?(T.warn("DEPRECATION WARNING: timeline.setStartDate(date, pixelOffset) is deprecated. Use timeline.setStartDate(date, { padding }) instead."),{padding:t}):t||{}}function Ga(t,e,i,n){t.switchToPositiveRepositionWindow();const o=t.timescaleManager.startToken.value,s=t.repositionWindow-t.timescaleManager.getPixelsBetween(e,o)-i;t.goToPixelAnim(s,Ft(W({},n),{targetDmy:e}))}f.prototype.setStartDate=function(t,e){var s;const i=Ua(e),n=i.padding||0;if(t=this.getDmyFromInput(Ot(t)),(s=i.animation)!=null&&s.active){Ga(this,t,n,i.animation);return}const o=this.timescaleManager.setStartDate(t);this.repositionWindow=o,n&&this.updateFromByPixels(-n),Nt(this),this.requestRedraw(),this._emitTimelineStateChange()},f.prototype.getZoom=function(){return this.timescaleManager.zoom},f.prototype.setCentreDate=function(t,e){this.setStartDate(t,{padding:this.getWidth()/2+(e||0)})},f.prototype.fitDateRange=function(e,i,n={}){var c;const o=Zn(n.padding);let s=Gn(e),r=Gn(i);s.start.compare(r.start)>0&&([s,r]=[r,s]);const a=s.start,l=r.end,h=ia(this,a,l,o);if((c=n.animation)!=null&&c.active){ca(this,a,l,h,o,n.animation);return}h!==this.timescaleManager.zoom&&this.setZoom(h),this.setStartDate(a,{padding:o.left})},f.prototype.settleDateBounds=function(e={}){var c;let i=Be(this);if(!i)return!1;if(i.type==="range"&&i.zoom===this.timescaleManager.zoom&&(i=Be(this,void 0,{mode:"elastic"})||i),e.animate===!1||i.type==="range")return Nt(this,{mode:"clamp"}),!0;const n=At(this);if(!n)return Nt(this,{mode:"clamp"}),!0;const o=i.type==="min"?i.overflowDays*n:-i.overflowDays*n;if(!Number.isFinite(o)||o===0)return Nt(this,{mode:"clamp"}),!0;(c=this.stopPanAnimation)==null||c.call(this),this.isPanning=!0,this.startAnimation();let s=0;const r=300,a=H.swing,l=this,h=Y({from:0,to:o,duration:r,easing:a,onUpdate(u){const m=u-s;s=u,l.updateFromByPixels(m,{skipDateBounds:!0}),l.requestRedraw()},onComplete(){l.isPanning=!1,l.animation.pan===h&&(l.animation.pan=null),Nt(l,{mode:"clamp"})}});return this.animation.pan=h,!0},f.prototype.fitArticleRange=function(e,i={}){var n;return!((n=e==null?void 0:e.period)!=null&&n.from)||!e.period.to?!1:(this.fitDateRange(e.period.from,e.period.to,{padding:i.padding,animation:i.animation}),!0)},f.prototype.fitArticles=function(e={}){var r;const i=e.articleFilter||function(l){return!l.hiddenByFilter},n=ua(this,i);if(!n)return!1;const o=Zn((r=e.padding)!=null?r:40),s={left:o.left+n.maxCardLeftOffset,right:o.right+n.maxCardRightOffset};return this.fitDateRange(n.earliest,n.latest,{padding:s,animation:e.animation}),!0},f.prototype.on=function(t,e){if(typeof t=="object")return this.onMultiple(t);this.handlers[t]||(this.handlers[t]=[]),this.handlers[t].push(e)},f.prototype.trigger=function(t,...e){if(!this.handlers[t])return;const i=this.handlers[t];for(let n=0;n<i.length;n++)i[n].call(this,...e)},f.prototype.onMultiple=function(t){for(const e in t)this.on(e,t[e])},f.prototype.off=function(t,e){if(typeof t=="object")return this.offMultiple(t);this.handlers[t]&&(this.handlers[t]=this.handlers[t].filter(i=>i!==e))},f.prototype.offMultiple=function(t){for(const e in t)this.off(e,t[e])};function ki(t){var n,o,s,r,a,l;const e=((o=(n=t.owner)==null?void 0:n.getCanvasDpr)==null?void 0:o.call(n))||1,i=(l=(a=(r=(s=t.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.rendering)==null?void 0:l.pixelSnap;return on(e,i)}function Ri(t){const e=ki(t);return{top:e(t.position.top),left:e(t.position.left)}}const ja={name:"landscape",draw(t){var ot,J,Q,at;if(!this.isDataLoaded||isNaN(this.position.left))return;const e=this.getCurrentStyle(),i=ki(this),n=Ri(this),o=n.top,s=n.left,r=e.width,a=e.height,l=e.backgroundColor||"#FFF",h=e.shadow,c=e.borderRadius||0;Fn(t,h),t.fillStyle=l,c>0?(Ve(t,s,o,r,a,c),t.fill()):t.fillRect(s,o,r,a),ro(t);let u=s,m=r;if(this.imageLoaded){const C=e.image,q=C.margin,tt=s+q,pt=o+q,mt=a-q*2;let yt,wt,ue,qe;this.image.width>this.image.height?(yt=ke((this.image.width-this.image.height)/2),wt=0,ue=qe=this.image.height):(yt=0,wt=0,ue=qe=this.image.width);const Ka=C.shape||"square",Co=C.borderRadius||0,Do=(ve,Se,Le,Ke,_e,Ei,Ni,xi)=>{Co>0?(t.save(),Ve(t,_e,Ei,Ni,xi,Co),t.clip(),t.drawImage(this.image,ve,Se,Le,Ke,_e,Ei,Ni,xi),t.restore()):t.drawImage(this.image,ve,Se,Le,Ke,_e,Ei,Ni,xi)};switch(Ka){case"circle":{co(t,this.image,yt,wt,ue,qe,tt,pt,mt);break}case"square":{Do(yt,wt,ue,qe,tt,pt,mt,mt);break}default:{const ve=Math.min(mt/this.image.width,mt/this.image.height),Se=i(this.image.width*ve),Le=i(this.image.height*ve),Ke=i(tt+(mt-Se)/2),_e=i(pt+(mt-Le)/2);Do(0,0,this.image.width,this.image.height,Ke,_e,Se,Le);break}}u=s+mt+q,m=r-mt-q}const d=((at=(Q=(J=(ot=this.owner)==null?void 0:ot.options)==null?void 0:J.article)==null?void 0:Q.star)==null?void 0:at.visible)!==!1&&(this.isActive||this.isStarred);if(d){const C=e.star.width,q=e.star.margin,tt=C+q;m=Math.max(0,m-tt)}const g=e.header.text,p=g.margin,w=g.lineHeight,b=u+p,v=m-p*2,S=g.offsetY||0,M=this.title,P=g.numberOfLines,E=this.memo(`titleLines:${M}:${v}:${g.font}:${P}`,()=>{t.font=g.font;let C=Ze(M,t,v);return C.length>P&&(C=Ue(C,P,t,v)),C}),x=E.length,R=this.memo(`headerMetrics:${g.font}`,()=>(t.font=g.font,t.measureText("Hg"))).actualBoundingBoxAscent,V=`${this.subtitle}`,B=e.subheader.text,z=B.font,it=B.margin,kt=u+it,ut=m-it*2,Gt=B.offsetY||0,N=this.memo(`subtitle:${V}:${ut}:${z}`,()=>{t.font=z;const C=Ze(V,t,ut);return C.length>1?Ue(C,1,t,ut)[0]:C[0]}),dt=this.memo(`subheaderMetrics:${z}`,()=>(t.font=z,t.measureText("Hg"))),ft=dt.actualBoundingBoxAscent,gt=dt.actualBoundingBoxDescent,jt=x*w,nt=ft+gt,st=jt+nt;let It=i(o+(a-st)/2)+R+S;t.font=g.font,t.fillStyle=g.color,t.textAlign=g.align,t.textBaseline=g.baseline;for(let C=0;C<E.length;C++)t.fillText(E[C],b,It,v),It+=w;It+=Gt,t.font=B.font,t.fillStyle=B.color,t.textAlign=B.align,t.textBaseline=B.baseline,t.fillText(N,kt,It,ut);const ce=e.border;if(ce.width>0&&(t.strokeStyle=ce.color,t.lineWidth=ce.width,c>0?(Ve(t,s,o,r,a,c),t.stroke()):t.strokeRect(s,o,r,a)),d){const C=this.getIconBox(),q=i(C.left+C.width/2),tt=i(C.top+C.height/2),pt=i(Math.min(C.width,C.height)/2),mt=i(pt/2);let yt,wt;this.isStarred?this.isMouseOverStar?(yt="#8A8A8A",wt="#fff800"):(yt="#a5a5a5",wt="#fff800"):this.isMouseOverStar?(yt="#8A8A8A",wt="#dfdfdf"):(yt="#a5a5a5",wt="#ebebeb"),lo(t,q,tt,5,mt,pt,wt,yt)}},getWidth(){return this.getCurrentStyle().width},getHeight(){return this.getCurrentStyle().height},getConnectorEnd(){const t=this.getCurrentStyle(),e=Ri(this);return{left:e.left+t.connectorLine.offsetX,top:e.top+this.getHeight()+t.connectorLine.offsetY}},getIconBox(){var r,a,l,h;if(((h=(l=(a=(r=this.owner)==null?void 0:r.options)==null?void 0:a.article)==null?void 0:l.star)==null?void 0:h.visible)===!1)return!1;const t=this.getCurrentStyle(),e=ki(this),i=t.star.width,n={width:i,height:i},o=t.borderRadius||0,s=Ri(this);return n.left=e(s.left-o/4+this._getWidth()-n.width-t.star.margin),n.top=e(s.top+o/4+t.star.margin),n},defaultStyle:{width:220,height:70,borderRadius:4,image:{shape:"square",margin:4,borderRadius:4},header:{text:{color:"#333",baseline:"alphabetic"}},subheader:{text:{color:"#777",baseline:"alphabetic"}}},defaultHoverStyle:{border:{color:"#a6c6e2"}},defaultActiveStyle:{header:{text:{color:"#000"}},subheader:{text:{color:"#333"}}}};function $e(t){var n,o,s,r,a,l;const e=((o=(n=t.owner)==null?void 0:n.getCanvasDpr)==null?void 0:o.call(n))||1,i=(l=(a=(r=(s=t.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.rendering)==null?void 0:l.pixelSnap;return on(e,i)}function Oi(t){const e=$e(t);return{top:e(t.position.top),left:e(t.position.left)}}const $a={name:"portrait",draw(t){var R,V,B,z,it,kt,ut,Gt;const e=this.getCurrentStyle(),i=$e(this),n=e.border.width,o=Math.max(n,((V=(R=this.hoverStyle)==null?void 0:R.border)==null?void 0:V.width)||0,((z=(B=this.activeStyle)==null?void 0:B.border)==null?void 0:z.width)||0),s=e.header.height,r=e.subheader.height,a=Oi(this),l={top:a.top,left:a.left,width:i(this._getWidth()),height:i(this._cachedHeight)},h=i(l.top+n/2),u=i(h+s),m=u+r,d=Qo(l,o,i);e.shadow&&(Fn(t,e.shadow),t.fillStyle=e.backgroundColor,t.fillRect(l.left,l.top+e.topRadius,l.width,l.height-e.topRadius),ro(t)),t.save(),t.beginPath(),ao(t,l.left,l.top,l.width,l.height,e.topRadius),t.clip(),t.fillStyle=e.color,t.fillRect(l.left,l.top,l.width,i(s+n/2)),t.restore(),r!==0&&(t.fillStyle=e.subheader.color,t.fillRect(l.left,u,l.width,r),t.beginPath(),t.lineWidth=1,t.moveTo(d.left+5,u+1),t.lineTo(d.left+10,u-5),t.lineTo(d.left+15,u+1),t.closePath(),t.fill());const g=e.header.text.align;t.fillStyle=e.header.text.color,t.font=e.header.text.font,t.textAlign=g,t.textBaseline=e.header.text.baseline;const p=e.header.text.margin,w=e.header.text.lineHeight,b=d.width-p*2,v=e.header.text.numberOfLines,S=this.memo(`titleLines:${this.title}:${b}:${e.header.text.font}:${v}`,()=>{t.font=e.header.text.font;let N=Ze(this.title,t,b);return N.length>v&&(N=Ue(N,v,t,b)),this.titleLines=N,N}),M=Math.min(v,S.length),P=(M-1)*w,x=h+(s-P)/2,Z=ho(d.left,d.width,g,p,i);for(let N=0;N<M;N++){const dt=i(x+N*w);t.fillText(S[N],Z,dt,b)}if(e.subheader.height!==0){const N=e.subheader.text.align,dt=e.subheader.text.margin,ft=d.width-dt*2;t.textAlign=N,t.textBaseline=e.subheader.text.baseline,t.fillStyle=e.subheader.text.color,t.font=e.subheader.text.font;const gt=`${this.subtitle}`,jt=this.memo(`subtitle:${gt}:${ft}:${e.subheader.text.font}`,()=>{t.font=e.subheader.text.font;const $t=Ze(gt,t,ft),It=$t.length>1?Ue($t,1,t,ft)[0]:$t[0];return this.summarisedSubtitle=It,It}),nt=ho(d.left,d.width,N,dt,i),st=i(u+r/2);t.fillText(jt,nt,st,ft)}if(this.imageLoaded){const N=e.image,dt=N.margin||0,ft=i(l.left+dt),gt=i(m+dt),jt=Math.max(0,l.width-dt*2),nt=i(jt);let st;const $t=N.shape||"square";switch($t){case"circle":case"square":st=nt;break;default:const ot=nt/this.image.width,J=this.image.height*ot,Q=N.maxHeight||e.maxImageHeight||400;st=Math.min(J,Q);break}st=i(st),t.fillStyle=e.backgroundColor,t.fillRect(ft,gt,nt,st);const It=N.borderRadius||0,ce=(ot,J,Q,at,C,q,tt,pt)=>{It>0?(t.save(),Ve(t,C,q,tt,pt,It),t.clip(),t.drawImage(this.image,ot,J,Q,at,C,q,tt,pt),t.restore()):t.drawImage(this.image,ot,J,Q,at,C,q,tt,pt)};switch($t){case"circle":{let ot,J,Q,at;this.image.width>this.image.height?(ot=(this.image.width-this.image.height)/2,J=0,Q=at=this.image.height):(ot=0,J=(this.image.height-this.image.width)/2,Q=at=this.image.width);const C=nt,q=ft,tt=gt;co(t,this.image,ot,J,Q,at,q,tt,C);break}case"square":{let ot,J,Q,at;this.image.width>this.image.height?(ot=(this.image.width-this.image.height)/2,J=0,Q=at=this.image.height):(ot=0,J=(this.image.height-this.image.width)/2,Q=at=this.image.width);const C=nt;ce(ot,J,Q,at,ft,gt,C,C);break}default:{const ot=nt/this.image.width,J=this.image.height*ot,Q=N.maxHeight||e.maxImageHeight||400,at=0;let C=0;const q=this.image.width;let tt=this.image.height;const pt=nt,mt=st,yt=ft,wt=gt;if(J>Q){const ue=Q/J;tt=this.image.height*ue,C=ke((this.image.height-tt)/2)}ce(at,C,q,tt,yt,wt,pt,mt);break}}}if(e.border.width>0&&(t.beginPath(),ao(t,l.left,l.top,l.width,l.height,e.topRadius),t.lineWidth=e.border.width,t.strokeStyle=e.border.color,t.stroke()),((Gt=(ut=(kt=(it=this.owner)==null?void 0:it.options)==null?void 0:kt.article)==null?void 0:ut.star)==null?void 0:Gt.visible)!==!1&&(this.isActive||this.isStarred)){const N=this.getIconBox(),dt=i(N.left+N.width/2),ft=i(N.top+N.height/2),gt=i(Math.min(N.width,N.height)/2),jt=i(gt/2);let nt,st;this.isStarred?this.isMouseOverStar?(nt="#8A8A8A",st="#fff800"):(nt="#a5a5a5",st="#fff800"):this.isMouseOverStar?(nt="#8A8A8A",st="#dfdfdf"):(nt="#a5a5a5",st="#ebebeb"),lo(t,dt,ft,5,jt,gt,st,nt)}},getWidth(){return this.getCurrentStyle().width},getHeight(){const t=this.getCurrentStyle(),e=$e(this);let i=0;if(this.imageLoaded){const o=t.image,s=o.margin||0,r=o.shape||"square",a=e(t.width-t.border.width/2-s*2);switch(r){case"circle":case"square":i=a+s*2;break;default:const l=a/this.image.width,h=this.image.height*l,c=t.image.maxHeight||t.maxImageHeight||400;i=Math.min(h,c)+s*2;break}}const n=e(t.header.height+t.subheader.height);return i+n+t.border.width},getConnectorEnd(){const t=this.getCurrentStyle(),e=Oi(this);return{left:e.left+t.connectorLine.offsetX,top:e.top+this.getHeight()+t.connectorLine.offsetY}},getIconBox(){var s,r,a,l;if(((l=(a=(r=(s=this.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.star)==null?void 0:l.visible)===!1)return!1;const t=this.getCurrentStyle(),e=$e(this),i=Oi(this),n=t.star.width,o={width:n,height:n};return o.left=e(i.left-t.topRadius/4+this._getWidth()-o.width-t.star.margin),o.top=e(i.top+t.topRadius/4+t.star.margin),o}},Xe=new Map;function Xa(t){return typeof t.getWidth!="function"&&(t.getWidth=function(){return this.getCurrentStyle().width}),typeof t.getHeight!="function"&&(t.getHeight=function(){return this.getCurrentStyle().height}),typeof t.getIconBox!="function"&&(t.getIconBox=function(){return!1}),t}function qa(t){return t&&t.aliasOf?Xe.get(t.aliasOf):t}return f.registerCardLayout=function(e){if(!e||typeof e!="object")throw new Error("Card layout definition must be an object");const{name:i,draw:n,aliasOf:o}=e;if(!i||typeof i!="string")throw new Error("Card layout must have a unique string 'name'");if(o){Xe.set(i,{aliasOf:o});return}if(typeof n!="function")throw new Error(`Card layout "${i}" must implement draw(ctx)`);Xe.set(i,Xa(W({},e)));const{defaultStyle:s,defaultHoverStyle:r,defaultActiveStyle:a}=e,l=mi.article.layoutStyles[i]={};s&&(l.style=ei({},s)),r&&(l.hoverStyle=ei({},r)),a&&(l.activeStyle=ei({},a))},f.getCardLayout=function(e){const i=qa(Xe.get(e));return i||(T.warn(`Unknown card layout "${e}"`),null)},f.prototype._getCurrentCardLayoutName=function(){return this.options.article.defaultCardLayout},f.prototype.registerCardLayout=f.registerCardLayout,f.prototype.getCardLayout=f.getCardLayout,f.registerCardLayout($a),f.registerCardLayout(ja),f.registerCardLayout({name:"default",aliasOf:"portrait"}),f.prototype.getStatusForSave=function(){const t=this.timescaleManager.startToken.value,e=[],i={};t.hour&&(i.fhr=t.hour),t.minute&&(i.fmi=t.minute),t.second&&(i.fs=t.second),t.millisecond&&(i.fms=t.millisecond);for(let n=0;n<this.articles.length;n++)e.push(this.articles[n].getStatusForSave());return JSON.stringify(Ft(W({t:this.title,o:this.ownerId,z:this.timescaleManager.zoom,fy:t.year,fm:t.month,fd:t.day},i),{w:this.repositionWindow,a:e}))},f.prototype._emitTimelineStateChange=function(){this&&this._isInitialized===!0&&(this._hasPendingTimelineStateChange=!1,this.trigger("timeline-state-change",this.getStatusForSave()))},f.prototype._markTimelineStateChanged=function(){this&&this._isInitialized===!0&&(this._hasPendingTimelineStateChange=!0)},f.prototype._flushTimelineStateChange=function(){this&&this._hasPendingTimelineStateChange===!0&&this._emitTimelineStateChange()},Ft(W(W({Timeline:f,Article:I,Chart:ht,Lane:et,TimeBand:Dt,Dmy:y},Go),as),{Logger:T,setDebug(t){T.setEnabled(!!t)},isDebugEnabled(){return T.isEnabled()},enableDebug(){T.setEnabled(!0)},disableDebug(){T.setEnabled(!1)}})}));
5
+ (function(H,Y){typeof exports=="object"&&typeof module!="undefined"?module.exports=Y():typeof define=="function"&&define.amd?define(Y):(H=typeof globalThis!="undefined"?globalThis:H||self,H.Histropedia=Y())})(this,(function(){"use strict";var Qa=Object.defineProperty,tl=Object.defineProperties;var el=Object.getOwnPropertyDescriptors;var Ro=Object.getOwnPropertySymbols;var il=Object.prototype.hasOwnProperty,nl=Object.prototype.propertyIsEnumerable;var Oo=(H,Y,k)=>Y in H?Qa(H,Y,{enumerable:!0,configurable:!0,writable:!0,value:k}):H[Y]=k,W=(H,Y)=>{for(var k in Y||(Y={}))il.call(Y,k)&&Oo(H,k,Y[k]);if(Ro)for(var k of Ro(Y))nl.call(Y,k)&&Oo(H,k,Y[k]);return H},zt=(H,Y)=>tl(H,el(Y));const H={linear:t=>t,swing:t=>.5-Math.cos(t*Math.PI)/2,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,easeInCubic:t=>t**3,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t**3:1+--t*(2*t)**2};function Y({from:t=0,to:e=1,duration:i=400,easing:n=H.linear,onUpdate:o,onComplete:s,autoStart:r=!0}={}){let a=null,l=!1;function c(u){if(l)return;a===null&&(a=u);const m=Math.min(1,(u-a)/i),d=n(m),g=t+(e-t)*d;o==null||o(g,d),m<1?requestAnimationFrame(c):s==null||s()}function h(){l=!1,a=null,requestAnimationFrame(c)}return r&&h(),{stop(){l=!0},restart(){l=!1,h()}}}const k=0,F=1,Eo=2,lt=-4,G=-3,K=-2,j=-1,O=0,$=1,rt=2,de=3,Rt=4,fe=5,Fi=6,Bi=7,Hi=8,Yi=9,Wi=10,Vi=11,Zi="millisecond",Ui="second",Gi="minute",ji="hour",$i="day",No="month",xo="year",zo="decade",Fo="century",Bo="millennium",Ho="million-years",Yo="billion-years",Wo={3:{label:" ka",value:1e3},6:{label:" Ma",value:1e6},9:{label:" Ga",value:1e9}},Vo="low",Zo="medium",Uo="high",Go="all",jo="all",$o="screen",Je=[{region:-26,zoom:{from:Number.NEGATIVE_INFINITY,to:-80.86},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:134217728}},{region:-25,zoom:{from:-80.86,to:-77.75},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:67108864}},{region:-24,zoom:{from:-77.75,to:-74.64},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:33554432}},{region:-23,zoom:{from:-74.64,to:-71.53},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:16777216}},{region:-22,zoom:{from:-71.53,to:-68.42},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:8388608}},{region:-21,zoom:{from:-68.42,to:-65.31},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:4194304}},{region:-20,zoom:{from:-65.31,to:-62.2},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:2097152}},{region:-19,zoom:{from:-62.2,to:-59.09},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:1048576}},{region:-18,zoom:{from:-59.09,to:-55.98},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:524288}},{region:-17,zoom:{from:-55.98,to:-52.87},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:262144}},{region:-16,zoom:{from:-52.87,to:-49.76},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:131072}},{region:-15,zoom:{from:-49.76,to:-46.65},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:65536}},{region:-14,zoom:{from:-46.65,to:-43.54},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:32768}},{region:-13,zoom:{from:-43.54,to:-40.43},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:16384}},{region:-12,zoom:{from:-40.43,to:-37.32},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:8192}},{region:-11,zoom:{from:-37.32,to:-34.21},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:4096}},{region:-10,zoom:{from:-34.21,to:-31.1},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:2048}},{region:-9,zoom:{from:-31.1,to:-27.99},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:1024}},{region:-8,zoom:{from:-27.99,to:-24.88},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:512}},{region:-7,zoom:{from:-24.88,to:-21.77},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:256}},{region:-6,zoom:{from:-21.77,to:-18.66},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:128}},{region:-5,zoom:{from:-18.66,to:-15.55},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:64}},{region:-4,zoom:{from:-15.55,to:-12.44},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:32}},{region:-3,zoom:{from:-12.44,to:-9.33},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:16}},{region:-2,zoom:{from:-9.33,to:-6.22},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:8}},{region:-1,zoom:{from:-6.22,to:-3.11},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:4}},{region:0,zoom:{from:-3.11,to:0},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:2}},{region:1,zoom:{from:0,to:3.11},low:1,medium:2,high:3,all:25,step:{months:0,days:1}},{region:2,zoom:{from:3.11,to:6.22},low:1,medium:2,high:3,all:25,step:{months:0,days:2}},{region:3,zoom:{from:6.22,to:9.33},low:1,medium:2,high:3,all:25,step:{months:0,days:4}},{region:4,zoom:{from:9.33,to:12.44},low:1,medium:2,high:3,all:25,step:{months:0,days:8}},{region:5,zoom:{from:12.44,to:15.55},low:1,medium:2,high:3,all:25,step:{months:0,days:16}},{region:6,zoom:{from:15.55,to:18.66},low:1,medium:2,high:3,all:25,step:{months:0,days:32}},{region:7,zoom:{from:18.66,to:21.77},low:1,medium:2,high:3,all:25,step:{months:0,days:64}},{region:8,zoom:{from:21.77,to:24.88},low:1,medium:2,high:3,all:25,step:{months:0,days:128}},{region:9,zoom:{from:24.88,to:27.99},low:1,medium:2,high:3,all:25,step:{months:0,days:256}},{region:10,zoom:{from:27.99,to:31.1},low:1,medium:2,high:3,all:25,step:{months:0,days:512}},{region:11,zoom:{from:31.1,to:34.21},low:1,medium:2,high:3,all:25,step:{months:0,days:1024}},{region:12,zoom:{from:34.21,to:37.32},low:1,medium:2,high:3,all:25,step:{months:0,days:2048}},{region:13,zoom:{from:37.32,to:40.43},low:1,medium:2,high:3,all:25,step:{months:0,days:4096}},{region:14,zoom:{from:40.43,to:43.54},low:1,medium:2,high:3,all:25,step:{months:0,days:8192}},{region:15,zoom:{from:43.54,to:46.65},low:1,medium:2,high:3,all:25,step:{months:0,days:16384}},{region:16,zoom:{from:46.65,to:49.76},low:1,medium:2,high:3,all:25,step:{months:0,days:32768}},{region:17,zoom:{from:49.76,to:52.87},low:1,medium:2,high:3,all:25,step:{months:0,days:65536}},{region:18,zoom:{from:52.87,to:55.98},low:1,medium:2,high:3,all:25,step:{months:0,days:131072}},{region:19,zoom:{from:55.98,to:59.09},low:1,medium:2,high:3,all:25,step:{months:0,days:262144}},{region:20,zoom:{from:59.09,to:62.2},low:1,medium:2,high:3,all:25,step:{months:0,days:524288}},{region:21,zoom:{from:62.2,to:65.31},low:1,medium:2,high:3,all:25,step:{months:0,days:1048576}},{region:22,zoom:{from:65.31,to:68.42},low:1,medium:2,high:3,all:25,step:{months:0,days:2097152}},{region:23,zoom:{from:68.42,to:71.53},low:1,medium:2,high:3,all:25,step:{months:0,days:4194304}},{region:24,zoom:{from:71.53,to:74.64},low:1,medium:2,high:3,all:25,step:{months:0,days:8388608}},{region:25,zoom:{from:74.64,to:77.75},low:1,medium:2,high:3,all:25,step:{months:0,days:16777216}},{region:26,zoom:{from:77.75,to:80.86},low:1,medium:2,high:3,all:25,step:{months:0,days:33554432}},{region:27,zoom:{from:80.86,to:83.97},low:1,medium:2,high:3,all:25,step:{months:0,days:67108864}},{region:28,zoom:{from:83.97,to:87.08},low:1,medium:2,high:3,all:25,step:{months:0,days:134217728}},{region:29,zoom:{from:87.08,to:90.19},low:1,medium:2,high:3,all:25,step:{months:0,days:268435456}},{region:30,zoom:{from:90.19,to:93.3},low:1,medium:2,high:3,all:25,step:{months:0,days:536870912}},{region:31,zoom:{from:93.3,to:96.41},low:1,medium:2,high:3,all:25,step:{months:0,days:1073741824}},{region:32,zoom:{from:96.41,to:99.52},low:1,medium:2,high:3,all:25,step:{months:0,days:2147483648}},{region:33,zoom:{from:99.52,to:102.63},low:1,medium:2,high:3,all:25,step:{months:0,days:4294967296}},{region:34,zoom:{from:102.63,to:105.74},low:1,medium:2,high:3,all:25,step:{months:0,days:8589934592}},{region:35,zoom:{from:105.74,to:108.85},low:1,medium:2,high:3,all:25,step:{months:0,days:17179869184}},{region:36,zoom:{from:108.85,to:111.96},low:1,medium:2,high:3,all:25,step:{months:0,days:34359738368}},{region:37,zoom:{from:111.96,to:115.07},low:1,medium:2,high:3,all:25,step:{months:0,days:68719476736}},{region:38,zoom:{from:115.07,to:118.18},low:1,medium:2,high:3,all:25,step:{months:0,days:137438953472}},{region:39,zoom:{from:118.18,to:121.29},low:1,medium:2,high:3,all:25,step:{months:0,days:274877906944}},{region:40,zoom:{from:121.29,to:124.4},low:1,medium:2,high:3,all:25,step:{months:0,days:549755813888}}],Xo=Object.freeze(Object.defineProperty({__proto__:null,DENSITY_ALL:Go,DENSITY_HIGH:Uo,DENSITY_LOW:Vo,DENSITY_MEDIUM:Zo,DENSITY_SETTINGS:Je,ERA_MARKER:Eo,MAJOR_MARKER:F,MINOR_MARKER:k,PRECISION_BILLION_YEARS:Yo,PRECISION_CENTURY:Fo,PRECISION_DAY:$i,PRECISION_DECADE:zo,PRECISION_HOUR:ji,PRECISION_MILLENNIUM:Bo,PRECISION_MILLION_YEARS:Ho,PRECISION_MILLISECOND:Zi,PRECISION_MINUTE:Gi,PRECISION_MONTH:No,PRECISION_SECOND:Ui,PRECISION_YEAR:xo,RANGE_ALL:jo,RANGE_SCREEN:$o,YEAR_PREFIXES:Wo,ZOOM_100_MILLION_YEARS:Wi,ZOOM_100_THOUSAND_YEARS:Bi,ZOOM_10_MILLION_YEARS:Yi,ZOOM_10_THOUSAND_YEARS:Fi,ZOOM_BILLION_YEARS:Vi,ZOOM_CENTURY:Rt,ZOOM_DAY:O,ZOOM_DECADE:de,ZOOM_HOUR:j,ZOOM_MILLENNIUM:fe,ZOOM_MILLION_YEARS:Hi,ZOOM_MILLISECOND:lt,ZOOM_MINUTE:K,ZOOM_MONTH:$,ZOOM_SECOND:G,ZOOM_YEAR:rt},Symbol.toStringTag,{value:"Module"}));class qo{constructor(){this._enabled=!1,this._prefix="[Histropedia]";const e=typeof console!="undefined"?console:null;this._console=e,this._fns={log:e&&e.log?e.log.bind(e):()=>{},warn:e&&e.warn?e.warn.bind(e):()=>{},error:e&&e.error?e.error.bind(e):()=>{},info:e&&e.info?e.info.bind(e):()=>{},debug:e&&e.debug?e.debug.bind(e):e&&e.log?e.log.bind(e):()=>{},group:e&&e.group?e.group.bind(e):e&&e.log?e.log.bind(e):()=>{},groupCollapsed:e&&e.groupCollapsed?e.groupCollapsed.bind(e):e&&e.group?e.group.bind(e):e&&e.log?e.log.bind(e):()=>{},groupEnd:e&&e.groupEnd?e.groupEnd.bind(e):()=>{}}}setEnabled(e){this._enabled=!!e}isEnabled(){return!!this._enabled}setPrefix(e){this._prefix=String(e||"")}getPrefix(){return this._prefix}_withPrefixedArgs(e){if(!this._prefix)return e;if(e&&e.length>0&&typeof e[0]=="string"){const i=e.slice();return i[0]=`${this._prefix} ${i[0]}`,i}return[this._prefix,...e]}_log(e,i){if(!this._enabled)return;(this._fns[e]||this._fns.log)(...this._withPrefixedArgs(i))}log(...e){this._log("log",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}group(...e){this._enabled&&this._fns.group(...this._withPrefixedArgs(e))}groupCollapsed(...e){this._enabled&&this._fns.groupCollapsed(...this._withPrefixedArgs(e))}groupEnd(){this._enabled&&this._fns.groupEnd()}}const T=new qo,Ae=[31,28,31,30,31,30,31,31,30,31,30,31],Ko=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xi={1:"billion-years",3:"million-years",6:"millennium",7:"century",8:"decade",9:"year",10:"month",11:"day",12:"hour",13:"minute",14:"second",15:"millisecond"},Jo=/^(-?\d+)(?:-(\d{1,2}))?(?:-(\d{1,2}))?(?:[T ](\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?$/,Ft=1e3,Bt=60*Ft,Ht=60*Bt,U=24*Ht;function Qe(t){return Object.prototype.hasOwnProperty.call(Xi,t)?Xi[t]:t||"day"}function me(t){if(t.precision!==void 0)return t.precision;if(!(t instanceof y)){for(const e of[Zi,Ui,Gi,ji])if(t[e]!==void 0)return e}return $i}function $t(t,e){if(t<=0){const n=1-t,o=Math.ceil(n/e)*e;return{startYear:1-o,endYear:e-o}}const i=Math.ceil(t/e)*e;return{startYear:i-e+1,endYear:i}}function qi(t){if(t<=0){const i=Math.floor((1-t)/10)*10;return{startYear:1-(i+9),endYear:1-Math.max(1,i)}}const e=Math.floor(t/10)*10;return{startYear:Math.max(1,e),endYear:e+9}}function Ie(t,e,i,n){const o=Number(t);return Number.isFinite(o)?Math.min(n,Math.max(i,Math.trunc(o))):e}function Ki(t,e,i,n,o){const s={hour:Ie(e,0,0,23),minute:Ie(i,0,0,59),second:Ie(n,0,0,59),millisecond:Ie(o,0,0,999)};for(const[r,a]of Object.entries(s))Object.defineProperty(t,r,{value:a,enumerable:a!==0,configurable:!0,writable:!0})}function Qo(t,e){e!==void 0&&Object.defineProperty(t,"precision",{value:e,enumerable:!1,configurable:!0,writable:!0})}function Xt(t,e){return new y(zt(W({},e),{precision:me(t)}))}function y(t,e,i,n,o,s,r){if(typeof t=="object"){const a=t;this.year=a.year,this.month=a.month,this.day=Ji(a.year,a.month,a.day),Ki(this,a.hour,a.minute,a.second,a.millisecond),Qo(this,me(a))}else this.year=t,this.month=e,this.day=Ji(t,e,i),Ki(this,n,o,s,r)}function Ji(t,e,i){return i>28?Math.min(i,qt(t,e)):i}function qt(t,e){return e===2&&(t%4===0&&t%100!==0||t%400===0)?29:Ae[e-1]}function Me(t,e){return t=t.toString(),e=typeof e=="string"?e:",",t.length<=4?t:t.replace(/\B(?=(\d{3})+(?!\d))/g,e)}y.prototype.getDaysTo=function(t){const e=t.getDaysSinceYearZero()-this.getDaysSinceYearZero(),i=t.getMillisecondsOfDay()-this.getMillisecondsOfDay();return e+i/U},y.prototype.getMillisecondsOfDay=function(){return this.hour*Ht+this.minute*Bt+this.second*Ft+this.millisecond},y.prototype.getMonthsTo=function(t){return this.getYearsTo(t)*12},y.prototype.getYearsTo=function(t){let e=t.year-this.year;return e+=(t.month-this.month)/12+(t.day-this.day)/365.2422+(t.getMillisecondsOfDay()-this.getMillisecondsOfDay())/(U*365.2422),e},y.prototype.getLeapYearsSinceYearZero=function(){let t=this.year;return this.month<3&&t--,Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400)},y.prototype.getDaysSinceYearZero=function(){let e=this.year*365+this.day;for(let i=0;i<this.month-1;i++)e+=Ae[i];return e+=this.getLeapYearsSinceYearZero(),e},y.prototype.getDayOfYear=function(){let t=this.day;for(let e=1;e<this.month;e++)t+=qt(this.year,e);return t},y.getByDayOfYear=function(t,e){const i=new y(t,1,1);let n=Ae[0];for(let o=0;o<e-1;o++)i.day++,i.day>n&&(i.day=1,i.month++,i.month>12&&(i.month=1,i.year++),n=i.month===2?qt(i.year,i.month):Ae[i.month-1]);return i},y.prototype.getNextDay=function(){return this.addDays(1)},y.prototype.addDays=function(t){let e=this.day,i=this.month,n=this.year;const o=t<0?-1:1;let s=Math.abs(Math.trunc(t));for(;s>0;)o>0?(e++,e>qt(n,i)&&(e=1,i++,i>12&&(i=1,n++))):(e--,e<1&&(i--,i<1&&(i=12,n--),e=qt(n,i))),s--;return Xt(this,{year:n,month:i,day:e,hour:this.hour,minute:this.minute,second:this.second,millisecond:this.millisecond})},y.prototype.addMilliseconds=function(t){let e=this,i=this.getMillisecondsOfDay()+Math.trunc(t);for(;i<0;)e=e.addDays(-1),i+=U;for(;i>=U;)e=e.addDays(1),i-=U;const n=Math.floor(i/Ht);i-=n*Ht;const o=Math.floor(i/Bt);i-=o*Bt;const s=Math.floor(i/Ft),r=i-s*Ft;return Xt(this,{year:e.year,month:e.month,day:e.day,hour:n,minute:o,second:s,millisecond:r})},y.prototype.addSeconds=function(t){return this.addMilliseconds(t*Ft)},y.prototype.addMinutes=function(t){return this.addMilliseconds(t*Bt)},y.prototype.addHours=function(t){return this.addMilliseconds(t*Ht)},y.prototype.addMonths=function(t){let e=this.month,i=this.year;for(let n=0;n<t;n++)e++,e>12&&(e=1,i++);return Xt(this,{year:i,month:e,day:1})},y.prototype.getPreviousDay=function(){return this.addDays(-1)},y.prototype.getNextMonth=function(){let t=this.month,e=this.year;return t++,t>12&&(t=1,e++),Xt(this,{year:e,month:t,day:1})},y.prototype.getPreviousMonth=function(){let t=this.month,e=this.year;return t--,t<1&&(t=12,e--),Xt(this,{year:e,month:t,day:1})},y.prototype.addYears=function(t){return Xt(this,{year:this.year+t,month:1,day:1})};function Ce(t,e){return String(t).padStart(e,"0")}y.prototype.format=function(t,e){e=e||{},t=t||"D MMM YYYY";const i=e.yearPrefix,n=typeof e.bceText=="string"?e.bceText:" ʙᴄᴇ",o=this.year<=0,s=this.year===0,r=e.thousandsSeparator;if(i&&!s){const a=i.value||1,l=i.label||"";let c;return o?c=Me((-this.year+1)/a,r)+l+n:c=Me(this.year/a,r)+l,c}return t.replace("YYYY",o?Me(-this.year+1,r)+n:Me(this.year,r)).replace("D",this.day).replace("MMM",Ko[this.month-1]).replace("HH",Ce(this.hour,2)).replace("mm",Ce(this.minute,2)).replace("ss",Ce(this.second,2)).replace("SSS",Ce(this.millisecond,3))},y.prototype.isSame=function(t){return t.year===this.year&&t.month===this.month&&t.day===this.day&&(t.hour||0)===this.hour&&(t.minute||0)===this.minute&&(t.second||0)===this.second&&(t.millisecond||0)===this.millisecond},y.prototype.toKeyString=function(){const t=`${this.year}|${this.month}|${this.day}`;return this.getMillisecondsOfDay()===0?t:`${t}|${this.hour}|${this.minute}|${this.second}|${this.millisecond}`},y.prototype.isAfter=function(t){const e=["year","month","day","hour","minute","second","millisecond"];for(let i=0;i<e.length;i++){const n=e[i],o=this[n]||0,s=t[n]||0;if(o!==s)return o>s}return!1},y.prototype.isBetween=function(t,e){return this.isAfter(t)&&e.isAfter(this)},y.prototype.compare=function(t){return this.isSame(t)?0:this.isAfter(t)?1:-1},y.prototype.asFloat=function(){const t=this.month-1,e=this.day-1,i=this.getMillisecondsOfDay()/U;return t===0&&e===0&&i===0?this.year:Math.round((this.year+(t*31+e+i)/371)*100)/100},y.prototype.isInFuture=function(){const t=new Date,e=new y(t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds());return this.isAfter(e)},y.prototype.convertToIso=function(){return this.year<0&&(this.year+=1),this},y.CreateAsStartOfPeriod=function(t,e){const i=t.year,n=t.month||1,o=t.day||1;if(e=Qe(e),e==="millisecond")return new y(t);if(e==="second")return new y(i,n,o,t.hour,t.minute,t.second,0);if(e==="minute")return new y(i,n,o,t.hour,t.minute,0,0);if(e==="hour")return new y(i,n,o,t.hour,0,0,0);if(e==="day")return new y(i,n,o);if(e==="month")return new y(i,n,1);if(e==="year")return new y(i,1,1);if(e==="million-years"||e==="billion-years"){const s=e==="million-years"?1e6:1e9;return new y(i<=0?$t(i,s).startYear:i,1,1)}return e==="decade"?new y(qi(i).startYear,1,1):e==="century"?new y($t(i,100).startYear,1,1):e==="millennium"?new y($t(i,1e3).startYear,1,1):new y(i,n,o)},y.CreateAsEndOfPeriod=function(t,e){const i=t.year,n=t.month||1,o=t.day||1;if(e=Qe(e),e==="millisecond")return new y(t);if(e==="second")return new y(i,n,o,t.hour,t.minute,t.second,999);if(e==="minute")return new y(i,n,o,t.hour,t.minute,59,999);if(e==="hour")return new y(i,n,o,t.hour,59,59,999);if(e==="day")return new y(i,n,o);if(e==="month")return new y(i,n,qt(i,n));if(e==="year")return new y(i,12,31);if(e==="decade")return new y(qi(i).endYear,12,31);if(e==="century")return new y($t(i,100).endYear,12,31);if(e==="millennium")return new y($t(i,1e3).endYear,12,31);if(e==="million-years"||e==="billion-years"){const s=e==="million-years"?1e6:1e9;return new y(i<=0?$t(i,s).endYear:i+s-1,12,31)}return T.error("precision is not implemented"),new y(i,n,o)},y.CreateAsExclusiveEndOfPeriod=function(t,e){e=Qe(e);const i=y.CreateAsStartOfPeriod(t,e);return e==="millisecond"?i.addMilliseconds(1):e==="second"?i.addSeconds(1):e==="minute"?i.addMinutes(1):e==="hour"?i.addHours(1):e==="day"?i.addDays(1):y.CreateAsEndOfPeriod(t,e).addDays(1)},y.now=function(){const t=new Date;return new y({year:t.getYear()+1900,month:t.getMonth()+1,day:t.getDate()})};function ti(t){const e=String(t).match(Jo);if(!e)return null;const i=parseInt(e[1],10),n=e[2]==null?1:parseInt(e[2],10),o=e[3]==null?1:parseInt(e[3],10),s=e[4]==null?0:parseInt(e[4],10),r=e[5]==null?0:parseInt(e[5],10),a=e[6]==null?0:parseInt(e[6],10),l=e[7]?parseInt(e[7].padEnd(3,"0"),10):0;return{date:new y(i,n,o,s,r,a,l),hasMonth:e[2]!=null,hasDay:e[3]!=null,hasTime:e[4]!=null}}y.fromString=function(t){const e=ti(t);return e?e.date:new y(NaN,1,1)};function ei(t,...e){return Object.assign(t,...e)}function L(t,...e){const i=s=>{if(s&&typeof s=="object"&&!Object.prototype.hasOwnProperty.call(s,"__proto__"))try{Object.defineProperty(s,"__proto__",{value:void 0,writable:!0,enumerable:!1,configurable:!0})}catch(r){}};i(t);const n=s=>s==="__proto__"||s==="constructor"||s==="prototype",o=s=>{if(s===null||typeof s!="object")return!1;const r=Object.getPrototypeOf(s);return r===Object.prototype||r===null};for(const s of e)if(!(!s||typeof s!="object"))for(const r of Object.keys(s)){if(n(r))continue;const a=s[r];if(Array.isArray(a)){t[r]=a.slice();continue}if(o(a)){const l=o(t[r])?t[r]:{};i(l),t[r]=L(l,a);continue}t[r]=a}return i(t),t}function bt(t,e){const i=t.split("."),n=i[i.length-1];let o={};o[n]=e;for(let s=i.length-2;s>=0;s--){const r=i[s],a=L({},o);o={},o[r]=a}return o}function Qi(t,e){const i=`_${e}`;t[i]=void 0,Object.defineProperty(t,e,{get(){const n=this[i];return typeof n=="function"?n(this):n},set(n){this[i]=n},enumerable:!0,configurable:!1})}function De(t){return typeof t=="undefined"}const tn={id:"i",title:"t",rank:"r",subtitle:"s","from.year":"fy","from.month":"fm","from.day":"fd","from.hour":"fhr","from.minute":"fmi","from.second":"fs","from.millisecond":"fms","from.precision":"fp","to.year":"ty","to.month":"tm","to.day":"td","to.hour":"thr","to.minute":"tmi","to.second":"ts","to.millisecond":"tms","to.precision":"tp",isToPresent:"p",isStarred:"v","offset.left":"ol","offset.top":"ot",imageUrl:"m",lane:"ln",style:"st",activeStyle:"ast",hiddenByFilter:"h",hidePeriodLine:"hp"};function en(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:t[tn[e]]}function nn(t,e){const n=e.split(".").reduce((o,s)=>o?o[s]:void 0,t);return De(n)?t[tn[e]]:n}function on(t){return t.indexOf(".")>-1}function _(t,e){return on(e)?nn(t,e):en(t,e)}function Te(t,e){const i=me(Object.fromEntries(["precision","hour","minute","second","millisecond"].map(o=>[o,_(t,`${e}.${o}`)]))),n=Object.fromEntries(["year","month","day","hour","minute","second","millisecond"].map(o=>[o,parseInt(_(t,`${e}.${o}`))]));return new y(zt(W({},n),{precision:i}))}function A(t,e){return on(e)?!De(nn(t,e)):!De(en(t,e))}Qi(I.prototype,"hidePeriodLine"),Qi(I.prototype,"hiddenByFilter");function I(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.imageLoaded=!1,this.stacking=0,this.groupIndex=0,this.isActive=!1,this.isVisible=!1,this.isVisibleInLane=!0,this.isInRange=!1,this.isInView=!1,this.isVisibleInGroup=!1,this.isVisibleInRows=!0,this.isStarred=!1,this.isMouseOverStar=!1,this.isMouseover=!1,this.isDragging=!1,this.registeredPosition={left:0,top:0},this.position={left:0,top:0},this.dragStartOffset={left:0,top:0},this.indicator={fromX:0,toX:0},this.offset={left:0,top:0},this.finalOffset={left:0,top:0},this.isVisibleAfterFade=!1,this.opacity=0,this.fadeAnimation={finalOpacity:0,dummyElement:null},this.moveAnimation={finalOffset:{left:0,top:0},dummyElement:void 0},this.row=0,this.laneId=null,this.laneOrder=0,this.isFading=!1,this.isMoving=!1,this._cachedHeight=0,this._cachedWidth=0,this._sizeValid=!1,this._sizeCacheKey=null,this._layoutCaches=null,this._resolvedDefaultCardLayout=null,this._resolvedCardLayoutName=null}I.prototype.setupByReceivedData=function(t){this.owner._assignArticleToLane(this,this.owner._resolveLaneIdFromArticleData(t));const e=this.owner._getResolvedArticleOptions(this).defaultData,i=L({},e,t);A(t,"to")||delete i.to,this.data=L({},t),this.title=_(i,"title")||"",this.rank=_(i,"rank")||0,this.subtitle=_(i,"subtitle")||"",this._setupArticlePeriod(i),this.offset.left=this.finalOffset.left=this.moveAnimation.finalOffset.left=i.offsetLeft||0,this.offset.top=this.finalOffset.top=this.moveAnimation.finalOffset.top=i.offsetTop||0,this.isStarred=!!i.starred,this.cardLayout=_(i,"cardLayout")||null,this.initialiseStyles(i),this.hiddenByFilter=_(i,"hiddenByFilter"),this.hidePeriodLine=A(i,"hidePeriodLine")?_(i,"hidePeriodLine"):this.owner.options.article.periodLine.defaultHide,this.isDataLoaded=!0,this.isImageInfoLoaded=!1},I.prototype._setupArticlePeriod=function(t){let e=Te(t,"from");e=this.owner.getDmyFromInput(e);const i=e.precision,n=_(t,"isToPresent"),o=n===!0||n===1;let s,r;o?s=y.now():A(t,"to")?(s=Te(t,"to"),s=this.owner.getDmyFromInput(s),r=s.precision):(s=e,r=i);const a=y.CreateAsStartOfPeriod(e,i),l=y.CreateAsExclusiveEndOfPeriod(s,r);this.period={from:a,to:l,isToPresent:o},this.period.years=this.period.to.asFloat()-this.period.from.asFloat()},I.prototype.setImage=function(){this.isImageInfoLoaded=!0,_(this.data,"imageUrl")?this.owner.enqueueImageLoad(this):(this._releaseImageResource(),this.image=null,this.imageLoaded=!1)},I.prototype._releaseImageResource=function(t={}){const e=typeof this._closeImage=="function"?this._closeImage:null;if(e){this._closeImage=null;try{e(t)}catch(i){}return}t.keepState||(this.image=null,this.imageLoaded=!1,this._loadedImageKey=null)},I.prototype.registerPosition=function(t){this.registeredPosition=this.position=t},I.prototype.overlaps=function(t){return t.period.from.isSame(this.period.from)&&t.period.to.isSame(this.period.to)||t.period.from.isBetween(this.period.from,this.period.to)||t.period.to.isBetween(this.period.from,this.period.to)||this.period.from.isBetween(t.period.from,t.period.to)||this.period.to.isBetween(t.period.from,t.period.to)},I.prototype.overlapsInclusiveWithDates=function(t,e){return!(this.period.from.isAfter(e)||t.isAfter(this.period.to))},I.prototype.overlapsInclusive=function(t){return this.overlapsInclusiveWithDates(t.period.from,t.period.to)},I.prototype.isInside=function(t){if(!this.isVisible)return!1;this._ensureSizeCache();const e=this.position.left,i=this.position.top,n=this._cachedWidth,o=this._cachedHeight;return t.left>=e&&t.left<=e+n&&t.top>=i&&t.top<=i+o},I.prototype.pointerEnter=function(t){this.isMouseover=!0,this.owner.trigger("article-pointerenter",this,t)},I.prototype.pointerLeave=function(t){this.isMouseover=!1,this.owner.trigger("article-pointerleave",this,t)},I.prototype.updateIsMouseOverStar=function(t){const e=this.getIconBox();if(!e)return!1;const i=this.isMouseOverStar;return this.isMouseOverStar=t.left>=e.left&&t.left<=e.left+e.width&&t.top>=e.top&&t.top<=e.top+e.height,this.isMouseOverStar!==i&&!this.owner.isAnimating&&this.owner.redraw(),this.isMouseOverStar},I.prototype.getCursor=function(t){const e=this.owner.options.style.cursor;return this.isDragging?e.article.dragging:(this.updateIsMouseOverStar(t),this.owner.options.article.draggable&&this.isActive?this.isMouseOverStar?e.clickable:e.article.hoverDraggable:e.clickable)},I.prototype.clicked=function(t){return this.updateIsMouseOverStar(t),this.isMouseOverStar?(this.isStarred=!this.isStarred,!0):!1},I.prototype.getStatusForSave=function(){const t={i:this.id};return this.offset.left!==0&&(t.l=this.offset.left),this.offset.top!==0&&(t.t=this.offset.top),this.isStarred&&(t.v=!0),t},I.prototype.headerOverlapsWith=function(t){const e=this.registeredPosition.left,i=t.registeredPosition.left,n=e+this.getWidth();return i+t.getWidth()>=e&&n>=i},I.prototype._getWidth=function(){return this.getCurrentStyle().width},I.prototype.getWidth=function(){return this._ensureSizeCache(),this._cachedWidth},I.prototype.getHeight=function(){return this._ensureSizeCache(),this._cachedHeight},I.prototype.setOption=function(t,e){let i=!1;if(typeof t=="string"){if(typeof e=="undefined")return _(this.data,t);t=bt(t,e)}L(this.data,t),A(t,"id")&&(this.id=t.id),A(t,"title")&&(this.title=t.title,this.titleLines=void 0),A(t,"subtitle")&&(this.subtitle=t.subtitle,this.summarisedSubtitle=void 0),(A(t,"from")||A(t,"to")||A(t,"isToPresent"))&&(this._setupArticlePeriod(this.data),i=!0),A(t,"imageUrl")&&this.setImage(),A(t,"rank")&&(this.rank=t.rank,i=!0),A(t,"starred")&&(this.isStarred=t.starred),A(t,"hiddenByFilter")&&(this.hiddenByFilter=t.hiddenByFilter),A(t,"hidePeriodLine")&&(this.hidePeriodLine=t.hidePeriodLine);const n=A(t,"lane");n&&(this.owner._assignArticleToLane(this,t.lane),this.initialiseStyles(this.data),this.invalidateCaches(),i=!0);const o=A(t,"style"),s=A(t,"activeStyle"),r=A(t,"hoverStyle");(o||r||s)&&this.initialiseStyles(this.data),this.invalidateCaches(),A(t,"cardLayout")&&this.setCardLayout(t.cardLayout),n&&this.owner.updateArticlesGroupIndex(),i?this.owner.requestRedraw():this.owner.requestRedraw(this.redraw)},I.prototype.initialiseStyles=function(t=this.data){const e=this.owner._resolveDefaultCardLayoutName(this),n=this.owner._getExplicitArticleCardLayout(this)||e;this._resolvedDefaultCardLayout=e,this._resolvedCardLayoutName=n;const o=this.owner._getResolvedArticleStyleOverrides(this,n),s=L({},o.style,_(t,"style")||{}),r=L({},o.activeStyle,_(t,"activeStyle")||{}),a=L({},o.hoverStyle,_(t,"hoverStyle")||{});this.style=s,this.activeStyle=L({},s,r),this.hoverStyle=L({},s,a),this.activeHoverStyle=L({},s,a,r)},I.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t),this.initialiseStyles(this.data),this.invalidateCaches(),this.owner.requestRedraw()},I.prototype.setHoverStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.activeStyle,t);t=bt(t,e)}this.data.hoverStyle=L(this.data.hoverStyle||{},t),this.initialiseStyles(this.data),this.owner.requestRedraw()},I.prototype.setActiveStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.activeStyle,t);t=bt(t,e)}this.data.activeStyle=L(this.data.activeStyle||{},t),this.initialiseStyles(this.data),this.owner.requestRedraw()},I.prototype.activated=function(){T.warn('DEPRECATION WARNING: article.activated() was deprecated in v1.3.0. Use timeline.select(article.id) and handle selection with options.on["article-select"] instead.'),this.owner.trigger("article-click",this)},I.prototype.updateVisibility=function(){const t=this.isVisibleAfterFade,e=this.isInRange&&this.isVisibleInLane&&this.isVisibleInGroup&&this.isVisibleInRows&&!this.isHiddenByFilter;if(!this.isVisibleInLane){this.setVisibility(!1);return}if(t!==e){if(e&&!this.isImageInfoLoaded&&this.setImage(),!this.owner.options.article.animation.fade.active){this.setVisibility(e);return}this.setVisibilityWithFade(e)}},I.prototype.setVisibility=function(t){var e,i,n,o;this.isFading&&((i=(e=this.fadeAnimation)==null?void 0:e.dummyElement)!=null&&i.stop)&&(this.fadeAnimation.dummyElement.stop(),this.isFading=!1,((o=(n=this.owner)==null?void 0:n.lastAnimatingArticle)==null?void 0:o.id)===this.id&&this.owner.lastAnimatingArticle.animationType==="fade"&&(this.owner.isAnimatingArticles=!1)),this.isVisible=t,this.isVisibleAfterFade=t,this.opacity=t?1:0,t||this._releaseImageResource({skipRedraw:!0})},I.prototype.setVisibilityWithFade=function(t){var c,h,u,m;const e=this;if(t===e.isVisibleAfterFade)return;e.isFading&&((h=(c=e.fadeAnimation)==null?void 0:c.dummyElement)!=null&&h.stop)&&e.fadeAnimation.dummyElement.stop(),e.isFading=!0,e.isVisibleAfterFade=t,e.fadeAnimation=e.fadeAnimation||{},e.fadeAnimation.finalOpacity=t,t&&(e.isVisible=!0),e.owner.notifyArticleAnimating("fade",e.id);const i=e.owner.options.article.animation.fade,n=(u=i.duration)!=null?u:400,o=(m=i.easing)!=null?m:"swing",s=H[o]||H.swing,r=e.opacity,l=Y({from:r,to:t?1:0,duration:n,easing:s,onUpdate(d){e.opacity=d,e.owner.requestRedraw()},onComplete(){e.isFading=!1,t||(e.isVisible=!1,e._releaseImageResource({skipRedraw:!0}));const d=e.owner.lastAnimatingArticle;e.id===d.id&&d.animationType==="fade"&&(e.owner.isAnimatingArticles=!1),typeof i.complete=="function"&&i.complete.call(e)}});e.fadeAnimation.dummyElement=l},I.prototype.moveToOffset=function(t){this.finalOffset.top=this.offset.top=t.top||this.offset.top,this.finalOffset.left=this.offset.left=t.left||this.offset.left,this.position.top=this.registeredPosition.top+this.offset.top,this.position.left=this.registeredPosition.left+this.offset.left},I.prototype.moveTo=function(t){const e={left:t.left-this.registeredPosition.left,top:t.top-this.registeredPosition.top};this.moveToOffset(e)},I.prototype.moveToWithAnim=function(t){const e={left:t.left-this.registeredPosition.left,top:t.top-this.registeredPosition.top};this.moveToOffsetWithAnim(e)},I.prototype.moveToOffsetWithAnim=function(t){var m,d,g;const e=this,i=e.moveAnimation;if(t.top===i.finalOffset.top&&t.left===i.finalOffset.left)return;e.isMoving&&((m=i==null?void 0:i.dummyElement)!=null&&m.stop)&&i.dummyElement.stop(),i.finalOffset=this.finalOffset={left:t.left,top:t.top},e.isMoving=!0,e.owner.notifyArticleAnimating("move",e.id);const n=e.owner.options.article.animation.move,o=(d=n.duration)!=null?d:400,s=(g=n.easing)!=null?g:"swing",r=H[s]||H.swing,a=e.offset.top,l=e.offset.left,c=t.top-a,h=t.left-l,u=Y({from:0,to:1,duration:o,easing:r,onUpdate(p){e.offset.top=a+c*p,e.offset.left=l+h*p,e.position.top=e.registeredPosition.top+e.offset.top,e.position.left=e.registeredPosition.left+e.offset.left,e.owner.requestRedraw()},onComplete(){e.offset.top=t.top,e.offset.left=t.left,e.position.top=e.registeredPosition.top+t.top,e.position.left=e.registeredPosition.left+t.left,e.isMoving=!1;const p=e.owner.lastAnimatingArticle;e.id===p.id&&p.animationType==="move"&&(e.owner.isAnimatingArticles=!1)}});i.dummyElement=u};function Pe(t){return Math.round(t)}function ts(t,e=1){const i=typeof e=="number"&&isFinite(e)&&e>0?e:1;return Math.round(t*i)/i}function sn(t){return t}function rn(t=1,e="device"){return e===!1||e==="none"?sn:e==="css"?Pe:function(n){return ts(n,t)}}function es(t=1,e="device",i=1){if(e===!1||e==="none")return sn;const n=typeof t=="number"&&isFinite(t)&&t>0?t:1,o=e==="css"?1:n,r=(typeof i=="number"&&isFinite(i)&&i>0?i:1)*o/2;return function(l){return(Math.round(l*o-r)+r)/o}}function is(t,e,i){i||(i=Pe);const n=e/2;return{left:i(t.left+n),top:i(t.top+n),width:i(t.width-e),height:i(t.height-e)}}I.prototype.draw=function(t){if(!this.isDataLoaded||isNaN(this.position.left))return;this._ensureSizeCache(),t.globalAlpha=this.opacity,this._getCurrentCardLayout().draw.call(this,t)},I.prototype.getCurrentStyle=function(){return this.isActive?this.isMouseover?this.activeHoverStyle:this.activeStyle:this.isMouseover?this.hoverStyle:this.style},I.prototype._getCurrentStyle=function(){return this.getCurrentStyle()},I.prototype._getPeriodLineRenderGeometry=function(t){const i=this.owner._getResolvedArticleOptions(this).periodLine||{},o=(this.owner.options.article.periodLine||{}).position||"axis",s=Number.isFinite(i.baselineGap)?i.baselineGap:0,r=this.hidePeriodLine?0:i.spacing||0,a=this.hidePeriodLine?0:i.thickness||0,l=(r+a)*this.stacking;let c=t,h=this.owner.options.style.mainLine.size/2;if(o==="lane"&&this.owner._isLaneLayoutActive()){const m=this.owner.getLaneById(this.laneId);m&&m.geometry&&(c=Math.floor(m.geometry.bottom),h=0)}const u=c-s-l-h-a/2;return{position:o,baselineGap:s,spacing:r,thickness:a,anchorY:c,anchorOffset:h,y:u}},I.prototype.drawPeriodLinesAndConnectors=function(t,e){var v,S,M,P,E,x;t.globalAlpha=this.opacity;const i=this.getCurrentStyle(),n=this._getPeriodLineRenderGeometry(e),o=n.y;if(!this.hidePeriodLine){const Z=this.indicator.fromX,R=this.indicator.toX;if(t.beginPath(),t.lineWidth=n.thickness,t.moveTo(Z,o),t.lineTo(R,o),this.period.isToPresent){const V=R-Z,B=15,z=Math.max(1-B/V,.7),it=t.createLinearGradient(Z,o,R,o);it.addColorStop(0,i.color),it.addColorStop(z,i.color),it.addColorStop(1,"rgba(255,255,255,0)"),t.strokeStyle=it}else t.strokeStyle=i.color;t.stroke()}if(!i.connectorLine.visible)return;const s=this._getCurrentCardLayout(),r=typeof s.getConnectorEnd=="function"?s.getConnectorEnd.call(this):{left:this.position.left+i.connectorLine.offsetX,top:this.position.top+this.getHeight()+i.connectorLine.offsetY},a=Math.max(0,this.indicator.fromX),l=o,c=r.left,h=r.top,u=Math.abs(a-c)<Number.EPSILON,m=(P=(M=(S=(v=this.owner)==null?void 0:v.options)==null?void 0:S.article)==null?void 0:M.rendering)==null?void 0:P.pixelSnap,d=es(((x=(E=this.owner)==null?void 0:E.getCanvasDpr)==null?void 0:x.call(E))||1,m,i.connectorLine.thickness),g=u?d(c):null,p=g!=null?g:a,w=g!=null?g:c;t.strokeStyle=t.fillStyle=i.color,t.lineWidth=i.connectorLine.thickness,t.beginPath(),t.moveTo(p,l),t.lineTo(w,h),t.stroke();const b=Math.atan((h-l)/(w-p))+(w>=p?-90:90)*Math.PI/180;t.save(),t.beginPath(),t.translate(w,h),t.rotate(b),t.moveTo(-i.connectorLine.arrow.width,0),t.lineTo(i.connectorLine.arrow.width,0),t.lineTo(0,-i.connectorLine.arrow.height),t.closePath(),t.restore(),t.fill()},I.prototype.getIconBox=function(){return this._getCurrentCardLayout().getIconBox.call(this)},I.prototype.startDragging=function(t,e){this.isMoving&&this.moveAnimation.dummyElement.stop(),this.isDragging=!0,this.dragInitialPosition={left:this.position.left,top:this.position.top},this.lastDragPosition={left:this.position.left,top:this.position.top},this.dragStartOffset={left:t.left-this.position.left,top:t.top-this.position.top},this.owner.startAnimation(),this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag-start",this,e)},I.prototype.stopDragging=function(t){var e,i;this.offset=this.finalOffset=this.moveAnimation.finalOffset={left:this.position.left-this.registeredPosition.left,top:this.position.top-this.registeredPosition.top},this.isDragging=!1,(i=(e=this.owner)==null?void 0:e._markTimelineStateChanged)==null||i.call(e),this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag-end",this,t)},I.prototype.dragging=function(t,e){const i={left:t.left-this.dragStartOffset.left,top:t.top-this.dragStartOffset.top},n=this.lastDragPosition||{left:this.position.left,top:this.position.top},o=this.dragInitialPosition||n,s=i.left-n.left,r=i.top-n.top,a=i.left-o.left,l=i.top-o.top;this.position=i,this.lastDragPosition=i,this.owner&&typeof this.owner.trigger=="function"&&this.owner.trigger("article-drag",this,{dx:s,dy:r,totalDx:a,totalDy:l},e)},I.prototype._cacheBucket=function(){const t=this._getCurrentCardLayoutName();return this._layoutCaches||(this._layoutCaches=Object.create(null)),this._layoutCaches[t]||(this._layoutCaches[t]=Object.create(null))},I.prototype.memo=function(t,e){const i=this._cacheBucket();return t in i?i[t]:i[t]=e.call(this)},I.prototype._getSizeCacheKey=function(){var l,c;const t=typeof this.getCurrentStyle=="function"?this.getCurrentStyle():null,e=t&&t.image||{},i=t&&t.header||{},n=t&&t.subheader||{},o=t&&t.border||{},s=typeof this._getCurrentCardLayoutName=="function"?this._getCurrentCardLayoutName():"",r=this.imageLoaded&&this.image;return[s,t&&t.width,t&&t.height,i.height,n.height,o.width,(l=e.margin)!=null?l:0,e.shape||"",(c=e.maxHeight)!=null?c:"",t&&t.maxImageHeight!==void 0?t.maxImageHeight:"",r?this.image.width:"noimg",r?this.image.height:""].join("|")},I.prototype.updateCachedSize=function(){const t=this._getCurrentCardLayout();this._cachedWidth=t.getWidth.call(this),this._cachedHeight=t.getHeight.call(this),this.height=this._cachedHeight,this._sizeValid=!0,this._sizeCacheKey=this._getSizeCacheKey()},I.prototype._ensureSizeCache=function(){const t=this._getSizeCacheKey();(!this._sizeValid||t!==this._sizeCacheKey)&&this.updateCachedSize()},I.prototype.invalidateCaches=function(){if(this._sizeValid=!1,this._sizeCacheKey=null,this._layoutCaches){const t=this._layoutCaches;for(const e in t){const i=t[e];if(i)for(const n in i){const o=i[n];if(o&&typeof o.close=="function")try{o.close()}catch(s){}}}}this._layoutCaches=null},I.prototype._getCurrentCardLayoutName=function(){return this._resolvedCardLayoutName||this.cardLayout||this._resolvedDefaultCardLayout||this.owner._resolveArticleCardLayoutName(this)},I.prototype._getCurrentCardLayout=function(){return this.owner.getCardLayout(this._getCurrentCardLayoutName())},I.prototype.setCardLayout=function(t){if(!this.owner.getCardLayout(t))throw new Error(`Card layout "${t}" not found`);this.cardLayout=t,this._resolvedCardLayoutName=t,this.initialiseStyles(),this.invalidateCaches(),this.owner.requestRedraw(this.redraw)};function Mt(t,e){const i=Number(t),n=Number(e);if(Number.isFinite(i)&&Number.isFinite(n))return i-n;const s=String(t),r=String(e);return s===r?0:s<r?-1:1}function ns(t,e){const i=t.period.from.getDaysTo(t.period.to),n=e.period.from.getDaysTo(e.period.to);return i<n?1:i>n?-1:Mt(t.id,e.id)}function os(t,e){const i=t.period.years,n=e.period.years;return i<n?1:i>n?-1:Mt(t.id,e.id)}function ss(t,e){const i=t.isInView&&t.isVisible,n=e.isInView&&e.isVisible;return!i&&n?-1:i&&!n?1:t.position.top-e.position.top}function an(t,e){const i=t.period.from,n=e.period.from;let o=i.compare(n);return o===0&&(o=Mt(e.id,t.id)),o}function rs(t,e){const i=t.period.to;let o=e.period.to.compare(i);return o===0&&(o=Mt(e.id,t.id)),o}function as(t,e){const i=t.position.top,n=e.position.top;return i<n?-1:i>n?1:Mt(e.id,t.id)}function ii(t,e){const i=t.laneOrder||0,n=e.laneOrder||0;if(i>n)return-1;if(i<n)return 1;const o=t.row,s=e.row;return o<s?1:o>s?-1:Mt(e.id,t.id)}function ni(t,e){const i=t.rank,n=e.rank;return i<n?1:i>n?-1:Mt(e.id,t.id)}function ls(t,e){const i=t.effectiveRank,n=e.effectiveRank;return i<n?1:i>n?-1:Mt(e.id,t.id)}function cs(t,e){const i=t.position.left,n=e.position.left;let o=i<n?1:i>n?-1:0;return o===0&&(o=t.position.top-e.position.top,o===0&&(o=t.period.from.compare(e.period.from),o===0&&(o=Mt(t.id,e.id)))),o}const hs=Object.freeze(Object.defineProperty({__proto__:null,ARTICLE_DURATION_SORTER:ns,ARTICLE_DURATION_YEARS_SORTER:os,ARTICLE_EFFECTIVE_RANK_SORTER:ls,ARTICLE_FROM_SORTER:an,ARTICLE_IMAGE_QUEUE_SORTER:ss,ARTICLE_POSITION_SORTER:cs,ARTICLE_RANK_SORTER:ni,ARTICLE_ROW_SORTER:ii,ARTICLE_TOP_SORTER:as,ARTICLE_TO_SORTER:rs},Symbol.toStringTag,{value:"Module"})),ln=new Map;function cn(t,e){!t||typeof e!="function"||ln.set(t,e)}function us(t){return ln.get(t)}const oi=["#2563eb","#dc2626","#16a34a","#9333ea","#ea580c","#0891b2","#be123c","#4f46e5"],Kt={source:"data",includeZero:!1,padding:.05,tickMode:"round",tickTarget:5},ds={area:{stacking:{active:!0,interpolation:"linear"}}},hn={lineWidth:2,lineDash:[],area:{fillColor:null,opacity:.2},point:{visible:!1,radius:2.5,fillColor:null,strokeColor:null,lineWidth:1}},un={padding:{top:8,right:12,bottom:8,left:48},backgroundColor:"rgba(255, 255, 255, 0)",gridLine:{x:{major:{visible:!0,color:"rgba(0, 0, 0, 0.08)",thickness:1},minor:{visible:!0,color:"rgba(0, 0, 0, 0.035)",thickness:1,minimumSpacing:20}},y:{major:{visible:!0,color:"rgba(120, 120, 120, 0.24)",thickness:1}}},axis:{visible:!0,color:"rgba(80, 80, 80, 0.45)",lineWidth:1},yAxis:{visible:!0,font:"normal 11px Calibri",color:"#555",margin:6,thousandsSeparator:",",formatter:null},legend:{visible:"auto",position:"top-left",font:"normal 12px Calibri",color:"#333",markerSize:10,markerGap:4,itemGap:12,inset:{x:8,y:8}},series:W({},hn)};function Ct(t){return typeof t=="number"&&Number.isFinite(t)}function si(t){return t!=null&&t.date&&typeof t.date.toKeyString=="function"?t.date.toKeyString():null}function dn(t){var n,o;const e=((o=(n=t==null?void 0:t.typeOptions)==null?void 0:n.area)==null?void 0:o.stacking)||{},i=e.interpolation;return{active:e.active!==!1,interpolation:i==="step"||i==="none"?i:"linear"}}function fs(t,e){return(t==null?void 0:t.date)&&t.date.compare(e)===0}function ms(t,e,i){let n=null;for(let o=i;o<t.length&&fs(t[o],e);o++)n=t[o];return n}function gs(t,e){let i=0,n=t.length;for(;i<n;){const o=Math.floor((i+n)/2);t[o].date.compare(e)<0?i=o+1:n=o}return i}function ps(t,e){var i,n;for(let o=e-1;o>=0;o--){if(Ct((i=t[o])==null?void 0:i.value))return t[o];if(((n=t[o])==null?void 0:n.value)===null)return null}return null}function ys(t,e){var i,n;for(let o=e;o<t.length;o++){if(Ct((i=t[o])==null?void 0:i.value))return t[o];if(((n=t[o])==null?void 0:n.value)===null)return null}return null}function ws(t,e,i){if(!e||!i||!e.date||!i.date)return 0;const n=e.date.getDaysTo(i.date);if(!Ct(n)||n===0)return e.value;const o=e.date.getDaysTo(t);return Ct(o)?e.value+(i.value-e.value)*(o/n):0}function bs(t,e,i,n){const o=ps(t,i),s=ys(t,i);return!o||!s||n==="none"?0:n==="step"?o.value:ws(e,o,s)}function vs(t){var i;const e=new Map;for(let n=0;n<t.length;n++){const o=Array.isArray((i=t[n])==null?void 0:i.points)?t[n].points:[];for(let s=0;s<o.length;s++){const r=o[s],a=si(r);a&&e.set(a,r.date)}}return Array.from(e.values()).sort((n,o)=>n.compare(o))}function Ss(t,e,i){const n=Array.isArray(t==null?void 0:t.points)?t.points:[];return e.map(o=>{const s=gs(n,o),r=ms(n,o,s);return r?{date:o,value:Ct(r.value)?r.value:null,sourcePoint:r,isResolved:!0}:{date:o,value:bs(n,o,s,i),sourcePoint:null,isResolved:!0}})}function Ls(t){const e=new Map,i=Array.isArray(t==null?void 0:t.series)?t.series:[],n=vs(i),{interpolation:o}=dn(t),s=i.map(r=>{const l=Ss(r,n,o).map(c=>{const h=si(c);if(!Ct(c.value))return{date:c.date,value:null,baseValue:null,sourcePoint:c.sourcePoint,isResolved:!0};const u=h&&e.get(h)||0;return{date:c.date,value:u+c.value,baseValue:u,sourcePoint:c.sourcePoint,isResolved:!0}});for(let c=0;c<l.length;c++){const h=l[c],u=si(h);u&&Ct(h.value)&&e.set(u,h.value)}return{series:r,points:l}});return t._resolvedAreaXDomain=n,t._resolvedStackedAreaSeries=s,t._resolvedStackedAreaDirty=!1,s}function fn(t){return(t==null?void 0:t.type)==="area"&&dn(t).active}function mn(t){return(Array.isArray(t==null?void 0:t.series)?t.series:[]).map(i=>{const n=Array.isArray(i==null?void 0:i.points)?i.points.map(o=>({date:o==null?void 0:o.date,value:Ct(o==null?void 0:o.value)?o.value:null,baseValue:Ct(o==null?void 0:o.value)?0:null,sourcePoint:o})):[];return{series:i,points:n}})}function _s(t){return fn(t)?t&&t._resolvedStackedAreaDirty!==!0&&Array.isArray(t._resolvedStackedAreaSeries)?t._resolvedStackedAreaSeries:Ls(t):mn(t)}function gn(t){return fn(t)?_s(t):mn(t)}function Jt(t){return typeof t=="number"&&Number.isFinite(t)}function ke(t){const e=Number(t);return Number.isFinite(e)?e:null}function ri(t,e=5){const i=Number(t),n=Number.isFinite(i)?i:e;return Math.max(2,Math.round(n))}function pn(t){const e=t!=null&&t.scale?ke(t.scale.tickTarget):null;return e!=null?ri(e):Kt.tickTarget}function yn(t,e){const i=e&&e.tokens?e.tokens:null;return!i||!i.start||!i.end||!t.date?!0:!t.date.isAfter(i.end)&&!i.start.isAfter(t.date)}function wn(t,e,i){return!i||!i.start||!i.end||!(t!=null&&t.date)||!(e!=null&&e.date)?!0:t.date.compare(i.end)<=0&&e.date.compare(i.start)>=0}function As(t,e){Jt(t)&&(e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),e.hasValues=!0)}function Qt(t,e){As(t==null?void 0:t.value,e)}function Is(t,e){const i=e&&e.tokens?e.tokens:null,n=(t.scale||Kt).source==="viewport",o={min:1/0,max:-1/0,hasValues:!1},s=gn(t);for(let r=0;r<s.length;r++){const a=s[r].points;for(let l=0;l<a.length;l++){const c=a[l];if(!Jt(c==null?void 0:c.value)||((!n||yn(c,e))&&Qt(c,o),!n||l>=a.length-1))continue;const h=a[l+1];Jt(h==null?void 0:h.value)&&wn(c,h,i)&&(Qt(c,o),Qt(h,o))}}return o.hasValues?{min:o.min,max:o.max}:null}function Ms(t,e){const i=e&&e.tokens?e.tokens:null,n={min:1/0,max:-1/0,hasValues:!1};for(let o=0;o<t.series.length;o++){const s=t.series[o];for(let r=0;r<s.points.length;r++){const a=s.points[r];if(yn(a,e)&&Qt(a,n),r>=s.points.length-1)continue;const l=s.points[r+1];Jt(a==null?void 0:a.value)&&Jt(l==null?void 0:l.value)&&wn(a,l,i)&&(Qt(a,n),Qt(l,n))}}return n.hasValues?{min:n.min,max:n.max}:null}function Cs(t,e){if(t.type==="area")return Is(t,e);if((t.scale||Kt).source==="viewport")return Ms(t,e);let o=1/0,s=-1/0,r=!1;for(let a=0;a<t.series.length;a++){const l=t.series[a];for(let c=0;c<l.points.length;c++){const h=l.points[c];Jt(h.value)&&(o=Math.min(o,h.value),s=Math.max(s,h.value),r=!0)}}return r?{min:o,max:s}:null}function ai(t,e){if(t!==e)return{min:t,max:e};const i=Math.abs(t)||1;return{min:t-i*.5,max:e+i*.5}}function li(t,e){if(!Number.isFinite(t)||t<=0)return 1;const i=Math.floor(Math.log10(t)),n=t/Math.pow(10,i);let o;return e?n<1.5?o=1:n<3?o=2:n<7?o=5:o=10:n<=1?o=1:n<=2?o=2:n<=5?o=5:o=10,o*Math.pow(10,i)}function Ds(t){if(!Number.isFinite(t))return 0;const e=t.toExponential(),i=Number(e.split("e")[1]);return Math.max(0,-i+1)}function bn(t,e){const i=Math.min(12,Ds(e));return Number(t.toFixed(i))}function Ts(t,e,i,n,o){const s=e-t,r=li(s,!1),a=li(r/(ri(i)-1),!0);return{min:n?t:Math.floor(t/a)*a,max:o?e:Math.ceil(e/a)*a}}function Ps(t,e){const i=W(W({},Kt),t.scale||{}),n=Cs(t,e),o=ke(i.min),s=ke(i.max),r=o!=null,a=s!=null;let l,c;n?(l=n.min,c=n.max):o!=null&&s!=null?(l=o,c=s):o!=null?(l=o,c=o+1):s!=null?(l=s-1,c=s):(l=0,c=1),i.includeZero&&(l=Math.min(0,l),c=Math.max(0,c)),{min:l,max:c}=ai(l,c);const h=ke(i.padding);if(h!=null&&h>0){const u=c-l;l-=u*h,c+=u*h}if(o!=null&&(l=o),s!=null&&(c=s),c<l){const u=l;l=c,c=u}return{min:l,max:c}=ai(l,c),i.tickMode!=="exact"&&({min:l,max:c}=Ts(l,c,pn(t),r,a),{min:l,max:c}=ai(l,c)),{min:l,max:c}}function ks(t,e,i=5){const n=Math.max(2,Math.round(Number.isFinite(i)?i:5)),o=[],s=(e-t)/(n-1);for(let r=0;r<n;r++)o.push(t+s*r);return o}function Rs(t,e,i=5){const n=ri(i),o=li((e-t)/(n-1),!0),s=[];let r=t;for(;r<e&&s.length<1e3;)s.push(bn(r,o)),r+=o;return(s.length===0||s[s.length-1]!==e)&&s.push(bn(e,o)),s}function Os(t,e){var o;const i=pn(t);return(((o=t==null?void 0:t.scale)==null?void 0:o.tickMode)||Kt.tickMode)==="exact"?ks(e.min,e.max,i):Rs(e.min,e.max,i)}function Es(t,e){if(typeof e!="string"||e.length===0)return t;const i=t.split(".");return i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,e),i.join(".")}function Ns(t,e,i){if(typeof e=="function")return e(t);let n;return Math.abs(t)>=1e3||Math.abs(t)<.01?n=Number(t.toPrecision(4)).toString():n=Number(t.toFixed(2)).toString(),Es(n,i)}function X(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function xs(t){const e=t.padding||{};return{top:X(e.top,8),right:X(e.right,12),bottom:X(e.bottom,8),left:X(e.left,48)}}function zs(t){switch(t){case"top-right":case"bottom-left":case"bottom-right":return t;default:return"top-left"}}function Fs(t){const e=t.inset||{};return{x:X(e.x,8),y:X(e.y,8)}}function Bs(t,e){const i=t.left+e.left,n=t.top+e.top,o=t.right-e.right,s=t.bottom-e.bottom;return{left:i,top:n,right:o,bottom:s,width:Math.max(0,o-i),height:Math.max(0,s-n)}}function te(t,e,i){return i.bottom-(t-e.min)/(e.max-e.min)*i.height}function ee(t,e,i){return Math.max(e,Math.min(i,t))}function vn(t,e){const i=e&&e.tokens?e.tokens:null;if(!i||!i.start||!i.end||t.length===0)return{start:0,end:t.length-1};let n=0,o=t.length;for(;n<o;){const a=Math.floor((n+o)/2);t[a].date.compare(i.start)<0?n=a+1:o=a}const s=n;if(s===t.length)return{start:t.length-1,end:t.length-1};for(n=s,o=t.length;n<o;){const a=Math.floor((n+o)/2);t[a].date.compare(i.end)<=0?n=a+1:o=a}const r=n;return{start:Math.max(0,s-1),end:Math.min(t.length-1,r)}}function ci(t,e){t.beginPath(),t.moveTo(e.left,e.top),t.lineTo(e.right,e.top),t.lineTo(e.right,e.bottom),t.lineTo(e.left,e.bottom),t.closePath(),t.clip()}function Hs(t,e,i){const n=e.x-t.x,o=e.y-t.y;let s=0,r=1,a=null,l=null;const c=[[-n,t.x-i.left],[n,i.right-t.x],[-o,t.y-i.top],[o,i.bottom-t.y]];for(let u=0;u<c.length;u++){const[m,d]=c[u];if(m===0){if(d<0)return null;continue}const g=d/m;if(m<0?g>s&&(s=g,a=u):g<r&&(r=g,l=u),s>r)return null}const h=(u,m)=>{if(u===0)return t;if(u===1)return e;const d={x:ee(t.x+n*u,i.left,i.right),y:ee(t.y+o*u,i.top,i.bottom)};return m===0?d.x=i.left:m===1?d.x=i.right:m===2?d.y=i.top:m===3&&(d.y=i.bottom),d};return{from:h(s,a),to:h(r,l)}}function Ys(t,e){return t&&e&&t.x===e.x&&t.y===e.y}function Sn(t,e,i){if(t.length===0)return t;const n=[];let o=t[t.length-1],s=e(o);for(let r=0;r<t.length;r++){const a=t[r],l=e(a);l?(s||n.push(i(o,a)),n.push(a)):s&&n.push(i(o,a)),o=a,s=l}return n}function Ws(t,e){const i=(s,r,a)=>Sn(s,l=>a?l.x>=r:l.x<=r,(l,c)=>{const h=(r-l.x)/(c.x-l.x);return{x:r,y:ee(l.y+(c.y-l.y)*h,e.top,e.bottom)}}),n=(s,r,a)=>Sn(s,l=>a?l.y>=r:l.y<=r,(l,c)=>{const h=(r-l.y)/(c.y-l.y);return{x:ee(l.x+(c.x-l.x)*h,e.left,e.right),y:r}});let o=i(t,e.left,!0);return o=i(o,e.right,!1),o=n(o,e.top,!0),n(o,e.bottom,!1)}function Vs(t,e,i){i.backgroundColor&&(t.fillStyle=i.backgroundColor,t.fillRect(e.left,e.top,e.width,e.height))}function Zs(t,e,i,n,o){const s=e.style||{},r=s.gridLine||{},a=s.axis||{},l=s.yAxis||{},c=Os(e,n);Gs(t,i,r,e.owner,o);const h=r.y&&r.y.major?r.y.major:{};if(h.visible!==!1){t.beginPath(),t.lineWidth=X(h.thickness,1),t.strokeStyle=h.color||"rgba(120, 120, 120, 0.24)";for(let u=0;u<c.length;u++){const m=Math.round(te(c[u],n,i))+.5;t.moveTo(i.left,m),t.lineTo(i.right,m)}t.stroke()}if(a.visible!==!1&&(t.beginPath(),t.lineWidth=X(a.lineWidth,1),t.strokeStyle=a.color||"rgba(80, 80, 80, 0.45)",t.moveTo(i.left,i.top),t.lineTo(i.left,i.bottom),t.lineTo(i.right,i.bottom),t.stroke()),l.visible!==!1){t.font=l.font||"normal 11px Calibri",t.fillStyle=l.color||"#555",t.textAlign="right",t.textBaseline="middle";const u=X(l.margin,6);for(let m=0;m<c.length;m++){const d=te(c[m],n,i);t.fillText(Ns(c[m],l.formatter,l.thousandsSeparator),i.left-u,d)}}}function Ln(t,e){const i=t&&t.markers?t.markers:null,n=i?i[e]:null;return Array.isArray(n)?n:[]}function Us(t,e){var n;if(e<=0)return!0;const i=(n=t==null?void 0:t.timescaleManager)==null?void 0:n.unitSizeInPixels;return typeof i!="number"||!Number.isFinite(i)?!0:i>=e}function _n(t,e,i,n,o=0){if(!(!n||n.visible!==!0||i.length===0)){t.beginPath(),t.lineWidth=X(n.thickness,1),t.strokeStyle=n.color||"rgba(0, 0, 0, 0.08)";for(let s=0;s<i.length;s++){const r=i[s];if(r.adaptive&&r.markerSpacingInPixels<o||typeof r.drawX!="number"||!Number.isFinite(r.drawX))continue;const a=Math.round(r.drawX)+.5;a<e.left||a>e.right||(t.moveTo(a,e.top),t.lineTo(a,e.bottom))}t.stroke()}}function Gs(t,e,i,n,o){const s=i.x||{},r=s.major||{},a=s.minor||{},l=Math.max(0,X(a.minimumSpacing,20));_n(t,e,Ln(o,F),r),Us(n,l)&&_n(t,e,Ln(o,k),a,l)}function js(t,e,i){const n=e.style.legend||{},o=n.visible==null?"auto":n.visible,s=e.series.filter(v=>v.title);if(o===!1||o==="auto"&&s.length<2)return;t.save(),t.font=n.font||"normal 12px Calibri",t.fillStyle=n.color||"#333",t.textAlign="left",t.textBaseline="middle";const r=X(n.markerSize,10),a=X(n.markerGap,4),l=X(n.itemGap,12),c=Fs(n),h=zs(n.position),u=[],m=Math.max(0,i.width-c.x);let d=0;for(let v=0;v<s.length;v++){const S=s[v],M=t.measureText(S.title).width,P=r+a+M,E=d===0?P:d+l+P;if(E>m)break;u.push({series:S,entryWidth:P}),d=E}const g=h==="top-right"||h==="bottom-right",p=h==="bottom-left"||h==="bottom-right";let w=g?i.right-c.x-d:i.left+c.x;const b=p?i.bottom-c.y-r/2:i.top+c.y+r/2;for(let v=0;v<u.length;v++){const S=u[v];t.fillStyle=S.series.style.color,t.fillRect(w,b-r/2,r,r),t.fillStyle=n.color||"#333",t.fillText(S.series.title,w+r+a,b),w+=S.entryWidth+l}t.restore()}function An(t,e,i,n,o,s,r=i.points){const a=i.style||{},l=X(a.lineWidth,2);t.save(),ci(t,o),t.beginPath(),t.lineWidth=l,t.strokeStyle=a.color||"#2563eb",Array.isArray(a.lineDash)&&typeof t.setLineDash=="function"&&t.setLineDash(a.lineDash);let c=null,h=null;const u=vn(r,s);for(let m=u.start;m<=u.end;m++){const d=r[m];if(typeof d.value!="number"||!Number.isFinite(d.value)){c=null,h=null;continue}const g=e.getPixel(d.date,s),p=te(d.value,n,o),w={x:g,y:p};if(c&&Number.isFinite(c.x)&&Number.isFinite(c.y)&&Number.isFinite(w.x)&&Number.isFinite(w.y)){const b=Hs(c,w,o);b?(Ys(h,b.from)||t.moveTo(b.from.x,b.from.y),t.lineTo(b.to.x,b.to.y),h=b.to):h=null}c=w}t.stroke(),typeof t.setLineDash=="function"&&t.setLineDash([]),t.restore()}function $s(t,e,i,n,o,s){const r=i.series||{},a=i.points||[],l=r.style||{},c=l.area||{},h=ee(X(c.opacity,.2),0,1);t.save(),ci(t,o),t.fillStyle=c.fillColor||l.color||"#2563eb",t.globalAlpha=X(t.globalAlpha,1)*h;let u=[];const m=vn(a,s),d=()=>{if(u.length===0)return;const g=[];for(let w=0;w<u.length;w++)g.push({x:u[w].x,y:u[w].y});for(let w=u.length-1;w>=0;w--)g.push({x:u[w].x,y:u[w].baseY});const p=Ws(g,o);if(p.length>=3){t.beginPath(),t.moveTo(p[0].x,p[0].y);for(let w=1;w<p.length;w++)t.lineTo(p[w].x,p[w].y);t.closePath(),t.fill()}u=[]};for(let g=m.start;g<=m.end;g++){const p=a[g];if(typeof p.value!="number"||!Number.isFinite(p.value)||typeof p.baseValue!="number"||!Number.isFinite(p.baseValue)){d();continue}const w=e.getPixel(p.date,s),b=te(p.value,n,o),v=ee(te(p.baseValue,n,o),o.top,o.bottom);u.push({x:w,y:b,baseY:v})}d(),t.restore()}function In(t,e,i,n,o,s,r=i.points,a={}){var u;const l=((u=i.style)==null?void 0:u.point)||{};if(l.visible!==!0)return;const c=X(l.radius,2.5),h=X(l.lineWidth,1);t.save(),ci(t,o),t.lineWidth=h,t.fillStyle=l.fillColor||i.style.color||"#2563eb",t.strokeStyle=l.strokeColor||"#fff";for(let m=0;m<r.length;m++){const d=r[m];if(a.sourcePointsOnly&&!d.sourcePoint||typeof d.value!="number"||!Number.isFinite(d.value))continue;const g=e.getPixel(d.date,s);if(g<o.left-c||g>o.right+c)continue;const p=te(d.value,n,o);t.beginPath(),t.arc(g,p,c,0,Math.PI*2),t.fill(),h>0&&t.stroke()}t.restore()}function Mn({chart:t,ctx:e,geometry:i,drawCycleContext:n,stackArea:o=!1}){if(!i||i.width<=0||i.height<=0)return;const s=t.style||{},r=xs(s),a=Bs(i,r);if(a.width<=0||a.height<=0)return;const l=t.getScaleDomain(n);Vs(e,i,s),Zs(e,t,a,l,n);const c=o?gn(t):t.series;for(let h=0;h<c.length;h++)if(o){const u=c[h];$s(e,t.owner,u,l,a,n),An(e,t.owner,u.series,l,a,n,u.points),In(e,t.owner,u.series,l,a,n,u.points,{sourcePointsOnly:!0})}else An(e,t.owner,c[h],l,a,n),In(e,t.owner,c[h],l,a,n);js(e,t,a)}function Xs(t){Mn(t)}function qs(t){Mn(zt(W({},t),{stackArea:!0}))}cn("line",Xs),cn("area",qs);function ie(t,e,...i){return typeof t=="function"?t.call(e,...i):t}function Yt(t,e=null){const i=parseInt(t,10);return Number.isFinite(i)?i:e}function Ks(t,e){if(!e||typeof e!="object")return null;const i=Yt(e.year);if(i==null)return null;const n=Yt(e.month,1),o=Yt(e.day,1),s=me(e);let r=new y({year:i,month:n,day:o,precision:s,hour:Yt(e.hour,0),minute:Yt(e.minute,0),second:Yt(e.second,0),millisecond:Yt(e.millisecond,0)});return r=t.getDmyFromInput(r),y.CreateAsStartOfPeriod(r,s)}function Js(t,e){if(!e||typeof e!="object")return null;const i=Ks(t,e.date);if(!i)return null;const n=e.value===null?null:Number(e.value);return{date:i,value:Number.isFinite(n)?n:null}}function Qs(t,e){return t!=null&&Object.prototype.hasOwnProperty.call(t,e)}function tr(t){return Qs(t==null?void 0:t.style,"color")}function er(t){var e;return!!((e=t==null?void 0:t.series)!=null&&e.color)}function ir(t,e){const i=Array.isArray(t==null?void 0:t._seriesColors)?t._seriesColors:[];for(let n=0;n<i.length;n++)if(i[n].id===e)return i[n].color}function nr(t,e,i){if(t){Array.isArray(t._seriesColors)||(t._seriesColors=[]);for(let n=0;n<t._seriesColors.length;n++)if(t._seriesColors[n].id===e){t._seriesColors[n].color=i;return}t._seriesColors.push({id:e,color:i})}}function or(t){const e=t&&t.seriesColors;if(!Array.isArray(e))return oi;const i=e.filter(n=>typeof n=="string"&&n.length>0);return i.length>0?i:oi}function sr(t,e,i,n,o,s){const r=i||{},a=L({},hn,e.series||{});a.color||(a.color=o||s[n%s.length]);const l=Array.isArray(r.points)?r.points.map(c=>Js(t,c)).filter(Boolean):[];return l.sort((c,h)=>c.date.compare(h.date)),{id:r.id!=null?r.id:n,title:r.title||"",style:L({},a,r.style||{}),points:l}}function Cn(t,e){return t&&t.id!=null?t.id:e}function Dn(t){const e=t._getResolvedData();return Array.isArray(e.series)?e.series.slice():[]}function Tn(t,e){t.data||(t.data={id:t.id}),t.data.series=e,t._resolveFromData(),t.owner&&typeof t.owner.requestRedraw=="function"&&t.owner.requestRedraw()}function ct(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.type="line",this.title="",this.laneId=null,this.area=null,this.scale={},this.typeOptions={},this.style={},this.series=[],this._seriesColors=[],this._resolvedAreaXDomain=[],this._resolvedStackedAreaSeries=null,this._resolvedStackedAreaDirty=!0}ct.prototype.setupByReceivedData=function(t){this.data=L({},t||{}),this.id=this.data.id!=null?this.data.id:this.id,this._resolveFromData(),this.isDataLoaded=!0},ct.prototype._getResolvedData=function(){const t=this.owner&&this.owner.options?this.owner.options.chart||{}:{},e=L({},t.defaultData||{});return delete e.id,L({},e,this.data||{})},ct.prototype._resolveFromData=function(){const t=this.owner&&this.owner.options?this.owner.options.chart||{}:{},e=this._getResolvedData(),i=_(e,"type")||"line",n=_(e,"lane");this.type=i==="line"?i:String(i),this.title=_(e,"title")||"",this.laneId=n!=null&&n!==""?n:null,this.area=_(e,"area")||null,this.scale=L({},Kt,_(e,"scale")||{}),this.typeOptions=L({},ds,_(e,"typeOptions")||{}),this.style=L({},un,t.defaultStyle||{},_(e,"style")||{});const o=Array.isArray(e.series)?e.series:[],s=or(t);this.series=o.map((r,a)=>{const l=Cn(r,a),c=ir(this,l),h=sr(this.owner,this.style,r,a,c,s);return(tr(r)||!er(this.style))&&nr(this,l,h.style.color),h}),this._resolvedStackedAreaDirty=!0},ct.prototype.addSeries=function(t){const e=Dn(this);e.push(t||{}),Tn(this,e)},ct.prototype.removeSeriesById=function(t){const e=Dn(this);for(let i=0;i<e.length;i++)if(Cn(e[i],i)===t)return e.splice(i,1),Tn(this,e),!0;return!1},ct.prototype.getSeriesById=function(t){for(let e=0;e<this.series.length;e++){const i=this.series[e];if(i.id===t)return i}},ct.prototype.getScaleDomain=function(t){return Ps(this,t)},ct.prototype.draw=function(t,e,i){const n=us(this.type);if(!n){T.warn(`Unknown chart type "${this.type}". Skipping chart render.`,{chartId:this.id});return}n({chart:this,ctx:t,geometry:e,drawCycleContext:i})},ct.prototype.setOption=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.data,t);t=bt(t,e)}t=L({},t);const i=A(t,"lane");if(!(A(t,"id")&&(T.warn("Ignoring chart id change; chart ids are immutable after load",{chartId:this.id,nextId:_(t,"id")}),delete t.id,Object.keys(t).length===0))){if(L(this.data,t),i&&this.owner&&typeof this.owner._ensureChartLane=="function"){const o=_(this.data,"lane");o!=null&&o!==""&&this.owner._ensureChartLane(o)}this._resolveFromData(),i&&this.owner&&(typeof this.owner._refreshLaneOrder=="function"&&this.owner._refreshLaneOrder(),typeof this.owner._updateLaneLayout=="function"&&this.owner._updateLaneLayout()),this.owner.requestRedraw()}},ct.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t),this._resolveFromData(),this.owner.requestRedraw()},Object.defineProperty(ct.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=ie(t,this,this);return e==="visible"||e==="hidden"?e:(T.warn("Invalid Chart.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{chartId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});const rr=["defaultCardLayout","defaultStyle","defaultHoverStyle","defaultActiveStyle","layoutStyles"],ar=["defaultData","density","distanceToBaseline","autoStacking.active","autoStacking.rowSpacing","autoStacking.fitToHeight","autoStacking.topGap","periodLine.baselineGap","periodLine.spacing","periodLine.thickness"];function Pn(t,e){if(!t||typeof t!="object")return!1;for(let i=0;i<e.length;i++)if(A(t,e[i]))return!0;return!1}function ge(t){return typeof t=="number"&&Number.isFinite(t)}function hi(t,e,i){return Math.min(Math.max(t,e),i)}function kn(t){const e=Pn(t,rr);return{cacheChanged:e||Pn(t,ar),styleChanged:e}}function Rn(t={},e={}){const i=t||{},n=e||{},o=i.autoStacking||{},s=n.autoStacking||{},r=i.periodLine||{},a=n.periodLine||{};return{defaultData:L({},i.defaultData||{},n.defaultData||{}),density:Object.prototype.hasOwnProperty.call(n,"density")?n.density:i.density,distanceToBaseline:L({},i.distanceToBaseline||{},n.distanceToBaseline||{}),defaultCardLayout:Object.prototype.hasOwnProperty.call(n,"defaultCardLayout")?n.defaultCardLayout:i.defaultCardLayout,defaultStyle:L({},i.defaultStyle||{},n.defaultStyle||{}),defaultHoverStyle:L({},i.defaultHoverStyle||{},n.defaultHoverStyle||{}),defaultActiveStyle:L({},i.defaultActiveStyle||{},n.defaultActiveStyle||{}),layoutStyles:L({},i.layoutStyles||{},n.layoutStyles||{}),autoStacking:{active:A(n,"autoStacking.active")?s.active:o.active,rowSpacing:A(n,"autoStacking.rowSpacing")?s.rowSpacing:o.rowSpacing,fitToHeight:A(n,"autoStacking.fitToHeight")?s.fitToHeight:o.fitToHeight,topGap:A(n,"autoStacking.topGap")?s.topGap:o.topGap},periodLine:{baselineGap:A(n,"periodLine.baselineGap")?a.baselineGap:r.baselineGap,spacing:A(n,"periodLine.spacing")?a.spacing:r.spacing,thickness:A(n,"periodLine.thickness")?a.thickness:r.thickness}}}function lr(t,e,i,n){var p;if(!t||t.active!==!0)return null;const o=t.lanesOnly!==!1;if(!i&&o)return null;const s=(p=t.byCardLayout)==null?void 0:p[n];if(!s)return null;const r=Math.max(0,ge(e)?e:0),a=Math.max(0,ge(s.ratio)?s.ratio:0),l=ge(s.min)?s.min:0,c=ge(s.max)?s.max:Number.POSITIVE_INFINITY,h=Math.max(0,Math.min(l,c)),u=Math.max(h,c),m=hi(h,0,r),d=hi(u,m,r),g=Math.round(r*a);return hi(g,m,d)}function Re(t,e,i,n){const o=lr(t==null?void 0:t.responsive,e,i,n);return Number.isFinite(o)?o:ge(t==null?void 0:t.value)?t.value:0}const cr={from:{},to:{},rank:0,starred:!1,hidePeriodLine:!1,hiddenByFilter:!1},hr={width:150,color:"#e5e5e5",backgroundColor:"#fff",topRadius:3,maxImageHeight:400,image:{shape:"natural",margin:0,maxHeight:200,borderRadius:0},header:{height:50,text:{font:"normal 14px 'Segoe UI'",align:"left",baseline:"middle",margin:10,color:"#333",lineHeight:18,numberOfLines:2,offsetY:0}},subheader:{height:30,color:"#555",text:{font:"normal 11px 'Segoe UI'",color:"#eee",align:"left",baseline:"middle",margin:10,lineHeight:6,offsetY:0}},shadow:{x:0,y:0,amount:0,color:"#000"},border:{color:"#ddd",width:1},connectorLine:{visible:!0,offsetX:18,offsetY:-20,thickness:1,arrow:{width:16,height:45}},star:{width:16,margin:3}},ur={color:"#a6c6e2"},dr={color:"#337ab7",header:{text:{color:"#fff"}},subheader:{color:"#333"},shadow:{x:3,y:3,amount:5,color:"#333"},border:{width:2,color:"#2e6da4"},connectorLine:{thickness:2}},fr={heightWeight:1,header:{visible:!0,height:24,padding:{left:12,right:12}}},mr={header:{},body:{},title:{}},gr={backgroundColor:"rgba(200, 200, 200, 0.25)",border:{color:"rgba(120, 120, 120, 0.25)",width:1},text:{font:"normal 16px Calibri",color:"#555",align:"left",baseline:"bottom",verticalAlign:"bottom",margin:4,offsetY:0}},On="#cdd2d8",En={width:1e3,height:500,verticalOffset:40,enableUserControl:!0,enableCursor:!0,canvas:{dpr:"auto",dprMode:"stable",maxDpr:3},debugOverlays:{densityRegions:!1},zoom:{initial:34,minimum:0,maximum:123,wheelStep:.2,wheelSpeed:3,allowCtrlWheel:!1,wheelMode:"auto",discreteWheelAnimation:{active:!0,duration:250},proportionalGain:2,proportionalExponent:1.1,ratio:.8,unitSize:{initial:200,showMinorLabels:48,minimum:8,minimumMajor:120}},initialDate:{year:1990,month:1,day:1},bounds:{minDate:null,maxDate:null,overflow:"elastic"},shiftBceDates:!1,draggingVicinity:!0,pan:{momentum:{active:!0,sampleWindow:100,minVelocity:.01,stopVelocity:.005,friction:.005,maxDuration:5600}},style:{mainLine:{visible:!0,position:"bottom",size:8,color:On,opacity:.75,dateIndicators:{visible:!0,shape:"rectangle",size:4,color:"#666",opacity:1,hiddenStyle:{opacity:.25},activeStyle:{color:"article",opacity:1}}},draggingHighlight:{visible:!0,color:"rgba(237, 247, 255, 0.5)",area:{up:0,down:"edge"}},marker:{minor:{height:12,extend:!1,color:"#6097f2",futureColor:"#ccc"},major:{height:30,extend:!1,color:"#0c3a88",futureColor:"#ccc"}},dateLabel:{minor:{font:"normal 10px Calibri",color:"#333",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},bceText:"",thousandsSeparator:",",yearPrefixes:{ka:{label:"ka",value:1e3,minDivision:1e3},Ma:{label:"Ma",value:1e6,minDivision:1e5},Ga:{label:"Ga",value:1e9,minDivision:1e8}}},major:{font:"normal 16px Calibri",color:"#000",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},sticky:{enabled:"auto",offsetX:4},bceText:" ʙᴄᴇ",thousandsSeparator:",",yearPrefixes:{ka:{label:"ka",value:1e3,minDivision:1e5},Ma:{label:"Ma",value:1e6,minDivision:1e6},Ga:{label:"Ga",value:1e9,minDivision:1e9}}},parent:{visible:!1,levels:"all",height:20,font:"normal 14px Calibri",color:"#444",futureColor:"#ccc",textAlign:"start",offset:{x:4,y:0},sticky:{enabled:!0,offsetX:4}}},cursor:{timeline:{hover:"default",dragging:"e-resize"},clickable:"pointer",article:{hoverDraggable:"move",dragging:"move"}}},timeBand:{visible:!0,reserveSpace:!0,reserveSpacePixels:20,area:{up:0,down:"edge"},defaultStyle:gr,data:[]},chart:{visible:!0,area:{up:"edge",down:0},seriesColors:[...oi],defaultData:{},defaultStyle:L({},un),data:[]},lane:{visible:!0,defaultId:"default",gap:0,topGap:0,axisGap:0,defaultLayout:L({},fr),defaultStyle:L({},mr),defaultClassName:"",defaultHeaderClassName:"",defaultBodyClassName:"",defaultTitleClassName:"",data:[]},image:{maxConcurrent:6,maxCacheBytes:64*1024*1024,requireCORS:!1,decodeMode:"auto",sanitizer:{allowedSchemes:["http","https","data","blob"]}},article:{density:"all",rendering:{pixelSnap:"device"},draggable:!0,distanceToBaseline:{value:350,responsive:{active:!0,lanesOnly:!0,byCardLayout:{portrait:{ratio:.6,min:310,max:410},landscape:{ratio:.6,min:100,max:160}}}},collectOngoing:!1,autoStacking:{active:!0,rowSpacing:50,range:"all",fitToHeight:!0,topGap:10},periodLine:{position:"lane",baselineGap:0,spacing:4,thickness:10,stacking:{sorter:an,reverseOrder:!1}},animation:{fade:{active:!0,duration:1500,easing:"swing"},move:{active:!0,duration:1500,easing:"swing"}},star:{visible:!0},defaultData:W({},cr),defaultCardLayout:"portrait",cardLayoutBreakpoints:[{maxHeight:320,layout:"landscape"}],defaultStyle:W({},hr),defaultHoverStyle:W({},ur),defaultActiveStyle:W({},dr),layoutStyles:{}}};function pr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function ui(t,e){T.warn(`DEPRECATION WARNING: ${t} is deprecated. Use ${e} instead.`)}const yr=new Set(["rectangle","circle"]);function di(t,e,{allowVisible:i=!1}={}){if(t!==void 0){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object`);if(i&&t.visible!==void 0&&typeof t.visible!="boolean")throw new TypeError(`${e}.visible must be a boolean`);if(t.shape!==void 0&&!yr.has(t.shape))throw new TypeError(`${e}.shape must be "rectangle" or "circle"`);if(t.size!==void 0&&(typeof t.size!="number"||!Number.isFinite(t.size)||t.size<=0))throw new TypeError(`${e}.size must be a positive finite number`);if(t.color!==void 0&&typeof t.color!="string")throw new TypeError(`${e}.color must be a CSS colour string or "article"`);if(t.opacity!==void 0&&(typeof t.opacity!="number"||!Number.isFinite(t.opacity)||t.opacity<0||t.opacity>1))throw new TypeError(`${e}.opacity must be a finite number between 0 and 1`)}}function wr(t){var i,n;const e=(n=(i=t==null?void 0:t.style)==null?void 0:i.mainLine)==null?void 0:n.dateIndicators;di(e,"style.mainLine.dateIndicators",{allowVisible:!0}),di(e==null?void 0:e.hiddenStyle,"style.mainLine.dateIndicators.hiddenStyle"),di(e==null?void 0:e.activeStyle,"style.mainLine.dateIndicators.activeStyle")}function Nn(t,e,i){(t==null?void 0:t.distanceToMainLine)!==void 0&&(ui(`${i}.distanceToMainLine`,`${i}.distanceToBaseline.value`),e&&((!e.distanceToBaseline||typeof e.distanceToBaseline!="object")&&(e.distanceToBaseline={}),pr(e.distanceToBaseline,"value")||(e.distanceToBaseline.value=t.distanceToMainLine),delete e.distanceToMainLine))}function xn(t){if(typeof t!="string")return t;const e=t.replace(/(^article\.|\.article\.)distanceToMainLine$/,"$1distanceToBaseline.value").replace(/^chart\.gridLine(?=\.|$)/,"chart.defaultStyle.gridLine");return e!==t&&ui(t,e),e}function fi(t){var i;if(!t)return t;const e=L({},t);return((i=t.article)==null?void 0:i.distanceToMainLine)!==void 0&&(e.article||(e.article={}),Nn(t.article,e.article,"lane.article")),e}function zn(t){var n,o,s,r,a,l;if(!t)return t;wr(t);const e=L({},t);if(((n=t.chart)==null?void 0:n.gridLine)!==void 0&&(ui("chart.gridLine","chart.defaultStyle.gridLine"),e.chart.defaultStyle||(e.chart.defaultStyle={}),e.chart.defaultStyle.gridLine=L({},t.chart.gridLine,((o=t.chart.defaultStyle)==null?void 0:o.gridLine)||{}),delete e.chart.gridLine),((s=t.article)==null?void 0:s.distanceToMainLine)!==void 0&&(e.article||(e.article={}),Nn(t.article,e.article,"article")),Array.isArray((r=t.lane)==null?void 0:r.data)){e.lane||(e.lane={}),e.lane.data=e.lane.data||[];for(let c=0;c<t.lane.data.length;c++)e.lane.data[c]=fi(t.lane.data[c])}if(((l=(a=t.article)==null?void 0:a.periodLine)==null?void 0:l.defaultHide)!==void 0&&(T.warn("DEPRECATION WARNING: article.periodLine.defaultHide is deprecated. Use article.defaultData.hidePeriodLine instead."),e.article||(e.article={}),e.article.defaultData||(e.article.defaultData={}),e.article.defaultData.hidePeriodLine=t.article.periodLine.defaultHide),["defaultStyle","defaultHoverStyle","defaultActiveStyle"].forEach(c=>{var h,u;((u=(h=t.article)==null?void 0:h[c])==null?void 0:u.maxImageHeight)!==void 0&&(T.warn(`DEPRECATION WARNING: article.${c}.maxImageHeight is deprecated. Use article.${c}.image.maxHeight instead.`),e.article||(e.article={}),e.article[c]||(e.article[c]={}),e.article[c].image||(e.article[c].image={}),e.article[c].image.maxHeight=t.article[c].maxImageHeight)}),t.onSave!==void 0&&(T.warn('DEPRECATION WARNING: onSave is deprecated. Use options.on["timeline-state-change"] instead.'),e.on||(e.on={}),!e.on["timeline-state-change"])){const c=t.onSave;typeof c=="function"&&(e.on["timeline-state-change"]=function(h){c.call(this,h)})}if(t.onArticleClick!==void 0&&(T.warn('DEPRECATION WARNING: onArticleClick is deprecated. Use options.on["article-click"] for click events, or options.on["article-select"] for selection by any means.'),e.on||(e.on={}),!e.on["article-click"])){const c=t.onArticleClick;typeof c=="function"&&(e.on["article-click"]=function(h,u){c.call(this,h)})}if(t.onArticleDoubleClick!==void 0&&(T.warn('DEPRECATION WARNING: onArticleDoubleClick is deprecated. Use options.on["article-dblclick"] instead.'),e.on||(e.on={}),!e.on["article-dblclick"])){const c=t.onArticleDoubleClick;typeof c=="function"&&(e.on["article-dblclick"]=function(h,u){c.call(this,h)})}if(t.onRedraw!==void 0){if(T.warn('DEPRECATION WARNING: onRedraw is deprecated. Use options.on["timeline-render-end"] instead.'),e.on||(e.on={}),!e.on["timeline-render-end"]){const c=t.onRedraw;typeof c=="function"&&(e.on["timeline-render-end"]=function(h){c.call(this,h)})}delete e.onRedraw}return e}const mi=L({},En);function et(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.isImplicit=!1,this.order=0,this.title="",this.className="",this.headerClassName="",this.bodyClassName="",this.titleClassName="",this.layout={},this.style={},this.articleOptions={},this.resolvedArticleOptions={},this._runtimeArticleOptions={},this.geometry=null,this.currentVisibility="visible"}et.prototype.setupByReceivedData=function(t,{implicit:e=!1}={}){this.data=fi(t),this.isImplicit=!!e,this._resolveFromData(),this.isDataLoaded=!0},et.prototype._resolveFromData=function(){var i,n;const t=this.owner&&this.owner.options?this.owner.options.lane||{}:{},e=this.data||{};this.title=_(e,"title")||"",this.className=_(e,"className")||"",this.headerClassName=_(e,"headerClassName")||"",this.bodyClassName=_(e,"bodyClassName")||"",this.titleClassName=_(e,"titleClassName")||"",this.layout=L({},t.defaultLayout||{},e.layout||{}),this.style=L({},t.defaultStyle||{},e.style||{}),this.articleOptions=L({},e.article||{}),this.resolvedArticleOptions=Rn(((n=(i=this.owner)==null?void 0:i.options)==null?void 0:n.article)||{},this.articleOptions)},et.prototype._applyOption=function(t,{suppressRedraw:e=!1,markExplicit:i=!1,suppressArticleRefresh:n=!1}={}){if(!t||typeof t!="object")return;t=fi(t);const o=this.id,s=A(t,"id")?t.id:o;if(s!==o){const a=this.owner.getLaneById(s);if(a&&a!==this)throw new Error(`Lane "${s}" already exists`)}L(this.data,t),i&&(this.isImplicit=!1),s!==o&&(this.id=s);const r=kn(_(t,"article"));return this._resolveFromData(),s!==o&&this.owner._handleLaneIdChange(this,o),r.styleChanged&&!n&&this.owner._refreshArticlesForLane(this,{refreshStyles:!0}),this.owner._handleLaneChange({requestRedraw:!e}),{articleImpact:r,idChanged:s!==o,laneId:this.id}},et.prototype.setOption=function(t,e){if(typeof t=="string"){const i=xn(t);if(typeof e=="undefined")return _(this.data,i);t=bt(i,e)}this._applyOption(t)},et.prototype.hide=function(){this.setOption("visibility","hidden")},et.prototype.show=function(){this.setOption("visibility","visible")},et.prototype.moveToIndex=function(t){return this.owner.moveLaneToIndex(this,t)},et.prototype.moveBefore=function(t){return this.owner.moveLaneBefore(this,t)},et.prototype.moveAfter=function(t){return this.owner.moveLaneAfter(this,t)},et.prototype.moveUp=function(){return this.owner.moveLaneUp(this)},et.prototype.moveDown=function(){return this.owner.moveLaneDown(this)},et.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t),this._resolveFromData(),this.owner._handleLaneChange({requestRedraw:!0,refreshOrder:!1})},Object.defineProperty(et.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=ie(t,this,this);return e==="visible"||e==="hidden"?e:(T.warn("Invalid Lane.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{laneId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});function Dt(t,e){this.id=e,this.owner=t,this.isDataLoaded=!1,this.title="",this.style={},this.period={from:null,to:null,isToPresent:!1}}Dt.prototype.setupByReceivedData=function(t){this.data=W({},t),this.title=_(t,"title")||"",this.style=_(t,"style")||{},this._setupPeriod(t),this.isDataLoaded=!0},Dt.prototype._setupPeriod=function(t){let e=Te(t,"from");e=this.owner.getDmyFromInput(e);const i=e.precision,n=_(t,"isToPresent"),o=n===!0||n===1;let s,r;o?s=y.now():A(t,"to")?(s=Te(t,"to"),s=this.owner.getDmyFromInput(s),r=s.precision):(s=e,r=i);const a=y.CreateAsStartOfPeriod(e,i),l=y.CreateAsExclusiveEndOfPeriod(s,r);this.period={from:a,to:l,isToPresent:o}},Dt.prototype.overlapsInclusiveWithDates=function(t,e){return!(this.period.from.isAfter(e)||t.isAfter(this.period.to))},Dt.prototype.setOption=function(t,e){let i=!1;if(typeof t=="string"){if(typeof e=="undefined")return _(this.data,t);t=bt(t,e)}if(L(this.data,t),A(t,"id")&&(this.id=t.id),A(t,"title")&&(this.title=t.title),(A(t,"from")||A(t,"to")||A(t,"isToPresent"))&&(this._setupPeriod(this.data),i=!0),A(t,"style")){const n=this.owner.options.timeBand&&this.owner.options.timeBand.defaultStyle||{};this.style=L({},n,this.data.style||{})}i?this.owner.requestRedraw():this.owner.requestRedraw(this.owner.redraw)},Dt.prototype.setStyle=function(t,e){if(typeof t=="string"){if(typeof e=="undefined")return _(this.style,t);t=bt(t,e)}this.data.style=L(this.data.style||{},t);const i=this.owner.options.timeBand&&this.owner.options.timeBand.defaultStyle||{};this.style=L({},i,this.data.style||{}),this.owner.requestRedraw()},Object.defineProperty(Dt.prototype,"visibility",{get(){const t=this&&this.data?this.data.visibility:void 0;if(typeof t=="undefined")return"visible";const e=ie(t,this,this);return e==="visible"||e==="hidden"?e:(T.warn("Invalid TimeBand.visibility value; expected 'visible'|'hidden'. Defaulting to 'visible'",{bandId:this&&this.id,value:e}),"visible")},set(t){this.data||(this.data={}),this.data.visibility=t},enumerable:!0,configurable:!1});function br(t,e,i){if(i>=t.length){let n=i-t.length;for(;n--+1;)t.push(void 0)}return t.splice(i,0,t.splice(e,1)[0]),t}function vr(t,e){if(t.length===0)return-1;let i=0,n=t[0][e];for(let o=1;o<t.length;o++)t[o][e]<n&&(n=t[o][e],i=o);return i}function gi(t){return t==="screen"||t===1}class Sr{constructor(e){this.invalidateCb=e,this.seen=new Set,this.loading=new Set,this.loaded=new Set,typeof document!="undefined"&&document.fonts&&document.fonts.addEventListener&&document.fonts.addEventListener("loadingdone",i=>{for(const n of i.fontfaces)this._notifyFamily(n.family)})}use(e){!e||this.loading.has(e)||this.loaded.has(e)||(this.seen.add(e),typeof document!="undefined"&&document.fonts&&document.fonts.load&&(this.loading.add(e),document.fonts.load(e).then(()=>{this.loading.delete(e),this.loaded.add(e),this.invalidateCb(e)}).catch(i=>{T.warn("[FontWatcher] Font load failed:",e,i),this.loading.delete(e)})))}_notifyFamily(e){for(const i of this.seen)i.includes(e)&&(this.loading.delete(i),this.loaded.add(i),this.invalidateCb(i))}}const Lr=64*1024*1024,_r=new Set(["square","circle"]),Ar=new Set(["auto","prefer-bitmap","bitmap","prefer-img","img"]);function Wt(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function ht(t){return Math.max(1,Math.floor(t||0))}class Ir{constructor(e={}){const{maxConcurrent:i=6,maxCacheBytes:n,requireCORS:o=!1,decodeMode:s="auto"}=e;this.maxConcurrent=Math.max(1,i|0),this.requireCORS=!!o;let r;typeof n=="number"?r=Number.isFinite(n)?Math.max(0,n):1/0:r=Lr,this.maxCacheBytes=r;let a=typeof s=="string"?s.toLowerCase():"auto";Ar.has(a)||(a="auto"),this.decodeMode=a,this.queue=[],this.active=0,this.cache=new Map,this.totalBytes=0,this.inflight=new Map}enqueue(e,i,n,o={}){if(!e||!i||typeof n!="function")return()=>{};const s=typeof o.shape=="string"?o.shape.toLowerCase():"natural",r={key:e,url:i,onReady:n,options:{targetW:Wt(o.targetW)?o.targetW:null,targetH:Wt(o.targetH)?o.targetH:null,shape:s,article:o.article||null},cancelled:!1,delivered:!1},a=this.cache.get(e);if(a){const c=this._acquire(a,r.options.article);r.delivered=!0;try{n(a.image,a.tainted,a.kind,a.close,c)}catch(h){throw c({keepState:!0,skipRedraw:!0}),h}return()=>{}}const l=this.inflight.get(e);return l?l.requests.push(r):r.options.article&&r.options.article.isInView?this.queue.unshift(r):this.queue.push(r),this._pump(),()=>this._cancel(r)}_cancel(e){var n;if(!e||e.cancelled||e.delivered)return;e.cancelled=!0;const i=this.inflight.get(e.key);if(i){const o=i.requests.indexOf(e);if(o!==-1&&i.requests.splice(o,1),i.requests.length===0)try{(n=i.controller)==null||n.abort()}catch(s){}}else{const o=this.queue.indexOf(e);o!==-1&&this.queue.splice(o,1)}}_pump(){if(!(this.active>=this.maxConcurrent))for(;this.active<this.maxConcurrent&&this.queue.length;){const e=this.queue.shift();if(!e||e.cancelled)continue;const i=e.options&&e.options.article;if(i&&i.isInRange===!1){e.cancelled=!0;try{i._pendingImageKey===e.key&&(i._pendingImageKey=null,typeof i._imageCancel=="function"&&(i._imageCancel=null))}catch(o){}continue}if(this.cache.has(e.key)){this._serveFromCache(e);continue}const n=this.inflight.get(e.key);if(n){n.requests.push(e);continue}this._startLoad(e)}}_serveFromCache(e){const i=this.cache.get(e.key);if(!i||e.cancelled)return;const n=this._acquire(i,e.options.article);e.delivered=!0;try{e.onReady(i.image,i.tainted,i.kind,i.close,n)}catch(o){throw n({keepState:!0,skipRedraw:!0}),o}}_startLoad(e){const i=typeof AbortController!="undefined"?new AbortController:null,n={requests:[e],controller:i};this.inflight.set(e.key,n),this.active++;const o=i?i.signal:void 0,s=this._loadResource(e,o);n.promise=s,s.then(r=>{if(!r)return;const a=this.cache.get(e.key);a&&this._evictEntry(e.key,a),r.key=e.key,r.refs=0,r.articles=new Set,r.lastUsed=this._now(),this.cache.set(e.key,r),this.totalBytes+=r.bytes||0;const l=n.requests.slice();for(const c of l){if(!c||c.cancelled)continue;const h=this._acquire(r,c.options.article);c.delivered=!0;try{c.onReady(r.image,r.tainted,r.kind,r.close,h)}catch(u){throw h({keepState:!0,skipRedraw:!0}),u}}this._trimCache()}).catch(()=>{}).finally(()=>{this.inflight.delete(e.key),this.active=Math.max(0,this.active-1),this._pump()})}_acquire(e,i){e.refs=(e.refs||0)+1,e.lastUsed=this._now(),i&&e.articles.add(i);let n=!1;const o=(s={})=>{n||(n=!0,this._releaseInternal(e.key,i,s))};return o._key=e.key,i&&(o._article=i),o}_releaseInternal(e,i,n={}){const o=this.cache.get(e);o&&(o.refs>0&&(o.refs-=1),o.lastUsed=this._now(),i&&o.articles instanceof Set&&o.articles.delete(i),this._dropArticleState(i,e,n),this._trimCache())}_dropArticleState(e,i,n){if(!e||!i)return;const o=!!n.keepState,s=!!n.skipRedraw;if(!o&&e._loadedImageKey===i){if(e.imageLoaded=!1,e.image=null,e._loadedImageKey=null,typeof e._cacheBucket=="function")try{const a=e._cacheBucket(),l=`imageRaster:${i}`;a&&Object.prototype.hasOwnProperty.call(a,l)&&delete a[l]}catch(a){}if(typeof e.updateCachedSize=="function")try{e.updateCachedSize()}catch(a){}const r=e.owner;if(!s&&r&&typeof r.requestRedraw=="function")try{r.requestRedraw()}catch(a){}}e._closeImage&&e._closeImage._key===i&&(e._closeImage=null)}_trimCache(){if(!Number.isFinite(this.maxCacheBytes)||this.totalBytes<=this.maxCacheBytes)return;const e=[];for(const[i,n]of this.cache.entries())n&&e.push({key:i,entry:n});e.sort((i,n)=>{const o=typeof i.entry.lastUsed=="number"?i.entry.lastUsed:0,s=typeof n.entry.lastUsed=="number"?n.entry.lastUsed:0;return o-s});for(const{key:i,entry:n}of e){if(this.totalBytes<=this.maxCacheBytes)break;n.refs>0||this._evictEntry(i,n)}}_evictEntry(e,i){if(this.cache.has(e)&&(this.cache.delete(e),this.totalBytes=Math.max(0,this.totalBytes-(i.bytes||0)),i&&typeof i.close=="function"))try{i.close()}catch(n){}}async _loadResource(e,i){if(!e||e.cancelled)return null;const n=this.decodeMode,o=typeof createImageBitmap=="function",s=async a=>{if(!o){if(a)throw new Error("ImageBitmap not supported");return null}try{return await this._loadViaFetch(e,i)}catch(l){if(a)throw l}try{return await this._loadViaImageElement(e,!0)}catch(l){if(a)throw l;return null}},r=async a=>{try{return await this._loadViaImageElement(e,!1)}catch(l){if(!a)throw l;return await s(!1)}};switch(n){case"bitmap":return await s(!0);case"prefer-bitmap":case"auto":{const a=await s(!1);return a||await r(!1)}case"prefer-img":{const a=await r(!0);return a||await s(!1)}case"img":return await r(!1);default:{const a=await s(!1);return a||await r(!1)}}}async _loadViaFetch(e,i){const n={signal:i,mode:"cors",credentials:this.requireCORS?"same-origin":"omit"},o=await fetch(e.url,n);if(!o.ok)throw new Error("image fetch failed");const s=await o.blob(),r=await createImageBitmap(s),a=this._computeTransform(e.options,r.width,r.height);let l=r;if(a.needsCrop||a.needsResize){const c=a.sw,h=a.sh,u={};a.resizeWidth&&(u.resizeWidth=a.resizeWidth),a.resizeHeight&&(u.resizeHeight=a.resizeHeight),l=await createImageBitmap(r,a.sx,a.sy,c,h,u);try{r.close()}catch(m){}}return this._buildEntryFromBitmap(l,!1)}async _loadViaImageElement(e,i){const n=await this._createImageElement(e.url),o=ht(n.naturalWidth||n.width||0),s=ht(n.naturalHeight||n.height||0),r=e.options.shape||"natural",a=this._computeTransform(e.options,o,s);if(!i&&r==="natural"&&(a.needsResize=!1,a.resizeWidth=null,a.resizeHeight=null),i&&typeof createImageBitmap=="function"){const l={};a.resizeWidth&&(l.resizeWidth=a.resizeWidth),a.resizeHeight&&(l.resizeHeight=a.resizeHeight);const c=await createImageBitmap(n,a.sx,a.sy,a.sw,a.sh,l);return this._buildEntryFromBitmap(c,!this.requireCORS)}if(a.needsCrop||a.needsResize){const l=this._drawToCanvas(n,a);return this._buildEntryFromCanvas(l,!this.requireCORS)}return{image:n,kind:"img",tainted:!this.requireCORS,close:()=>{},bytes:this._estimateBytes(o,s)}}_drawToCanvas(e,i){let n=i.resizeWidth!=null?i.resizeWidth:i.sw,o=i.resizeHeight!=null?i.resizeHeight:i.sh;if(i.resizeWidth!=null&&i.resizeHeight==null&&i.sw>0){const a=i.resizeWidth/i.sw;o=Math.max(1,Math.round(i.sh*a))}else if(i.resizeHeight!=null&&i.resizeWidth==null&&i.sh>0){const a=i.resizeHeight/i.sh;n=Math.max(1,Math.round(i.sw*a))}n=Math.max(1,Math.round(n)),o=Math.max(1,Math.round(o));const s=this._createCanvas(n,o),r=s.getContext&&s.getContext("2d");return r&&r.drawImage(e,i.sx,i.sy,i.sw,i.sh,0,0,n,o),s}_createCanvas(e,i){const n=ht(e),o=ht(i);if(typeof document!="undefined"&&typeof document.createElement=="function"){const s=document.createElement("canvas");return s.width=n,s.height=o,s}return typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(n,o):{width:n,height:o,getContext:()=>null}}_buildEntryFromBitmap(e,i){return{image:e,kind:"bitmap",tainted:i,close:()=>{try{e.close()}catch(o){}},bytes:this._estimateBytes(e.width,e.height)}}_buildEntryFromCanvas(e,i){return{image:e,kind:"canvas",tainted:i,close:()=>{if(typeof e.close=="function")try{e.close()}catch(o){}},bytes:this._estimateBytes(e.width,e.height)}}_computeTransform(e,i,n){const o={sx:0,sy:0,sw:ht(i),sh:ht(n),resizeWidth:null,resizeHeight:null,needsCrop:!1,needsResize:!1},s=e.shape||"natural";if(_r.has(s)){o.sw!==o.sh&&(o.sw>o.sh?(o.sx=Math.floor((o.sw-o.sh)/2),o.sw=o.sh):(o.sy=Math.floor((o.sh-o.sw)/2),o.sh=o.sw),o.needsCrop=!0);const r=e.targetW||e.targetH;if(Wt(r)){const a=ht(r);o.resizeWidth=a,o.resizeHeight=a,o.needsResize=!0}}else{const r=e.targetW,a=e.targetH,l=o.sw,c=o.sh,h=u=>{if(!Number.isFinite(u)||u<=0)return;const m=ht(l*u),d=ht(c*u);m===l&&d===c||(o.resizeWidth=m,o.resizeHeight=d,o.needsResize=!0)};if(Wt(r)&&Wt(a)){const u=Math.min(r/l,a/c);h(u)}else Wt(r)?h(r/l):Wt(a)&&h(a/c)}return o.resizeWidth!=null&&o.resizeHeight==null?o.resizeHeight=ht(o.sh):o.resizeHeight!=null&&o.resizeWidth==null&&(o.resizeWidth=ht(o.sw)),o}_estimateBytes(e,i){return ht(e)*ht(i)*4}_now(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}_createImageElement(e){return new Promise((i,n)=>{const o=new Image;this.requireCORS&&(o.crossOrigin="anonymous"),o.decoding="async",o.fetchPriority="low",o.onload=()=>i(o),o.onerror=()=>n(new Error("image load error")),o.src=e,typeof o.decode=="function"&&o.decode().then(()=>i(o)).catch(()=>{})})}}const Oe={[lt]:1,[G]:Ft,[K]:Bt,[j]:Ht},Mr={[j]:[12,6,3,1],[K]:[30,10,5,1],[G]:[30,10,5,1],[lt]:[500,100,50,10,5,1]},Fn=[{majorUnit:O,majorMilliseconds:U,minorUnit:j},{majorUnit:j,majorMilliseconds:Ht,minorUnit:K},{majorUnit:K,majorMilliseconds:Bt,minorUnit:G},{majorUnit:G,majorMilliseconds:Ft,minorUnit:lt}],Cr=Rt;function Ee(t){return t<O?Oe[t]/U:t===O?1:null}function Dr(t,e,i){return e===O?t.format("D MMM YYYY",i):e===G?t.format("HH:mm:ss"):t.format("HH:mm")}function pe(t,e){return e===j||e===K?t.format("HH:mm"):e===G?`:${t.format("ss")}`:`.${t.format("SSS")}`}function Tr(t,e){const i=t%100;let n;if(i>=11&&i<=13)n="th";else switch(t%10){case 1:n="st";break;case 2:n="nd";break;case 3:n="rd";break;default:n="th"}return`${new y(t,1,1).format("YYYY",{thousandsSeparator:e,bceText:""})}${n}`}function Pr(t,e){switch(e){case G:return new y(t.year,t.month,t.day,t.hour,t.minute,t.second);case K:return new y(t.year,t.month,t.day,t.hour,t.minute);case j:return new y(t.year,t.month,t.day,t.hour);case O:return new y(t.year,t.month,t.day);case $:return new y(t.year,t.month,1);case rt:return new y(t.year,1,1);case de:return y.CreateAsStartOfPeriod(t,"decade");case Rt:return y.CreateAsStartOfPeriod(t,"century");case fe:return y.CreateAsStartOfPeriod(t,"millennium");default:return null}}function kr(t,e){switch(e){case G:return t.addSeconds(1);case K:return t.addMinutes(1);case j:return t.addHours(1);case O:return t.getNextDay();case $:return t.getNextMonth();case rt:return t.addYears(1);case de:return y.CreateAsExclusiveEndOfPeriod(t,"decade");case Rt:return y.CreateAsExclusiveEndOfPeriod(t,"century");case fe:return y.CreateAsExclusiveEndOfPeriod(t,"millennium");default:return null}}class D{constructor(e,i){this.owner=e,this.zoomOptions=i,this.zoom=0,this.startToken=null,this.unit=O,this.unitSizeInPixels=100,this.adaptiveMinorUnit=null,this.adaptiveMinorInterval=null,this.adaptiveMinorMarkerSpacingInPixels=null,this.unitLengthInYears=1,this.zoomChangedHandlers=[],this.yearPrefix={minor:!1,major:!1},this.unitLevels=[],this.unitOrder=[]}}D.prototype.getUnitSizeInPixelsForZoom=function(t){var s;const e=this.zoomOptions.ratio,i=this.unitLevels[this.unit],n=(s=i.referenceZoom)!=null?s:i.zoomStart;return i.startUnitSize*Math.pow(e,t-n)},D.prototype.getChangePoint=function(t){return this.unitLevels[this.unit].zoomStart},D.prototype.getUnitFromZoom=function(t){for(let e=this.unitOrder.length-1;e>=0;e--){const i=this.unitOrder[e];if(t>=this.unitLevels[i].zoomStart)return i}throw new Error(`Zoom ${t} is out of range`)},D.prototype.getAdaptiveMinorInterval=function(t=this.unit,e=this.unitSizeInPixels){var r;const i=Mr[t];if(!i)return 1;const n=this.zoomOptions.unitSize.minimum,o=(r=this.zoomOptions.unitSize.showMinorLabels)!=null?r:n,s=Math.max(n,o);for(let a=i.length-1;a>=0;a--)if(e*i[a]>=s)return i[a];return null},D.prototype.getSubdayVisualMarkerLayout=function(){var r;if(this.zoomOptions.minimum>=O||this.zoom>O||this.unit>O)return null;const t=this.unit===O?U:Oe[this.unit],e=this.unitSizeInPixels/t,i=(r=this.zoomOptions.unitSize.minimumMajor)!=null?r:120;let n=null;for(let a=Fn.length-1;a>=0;a--){const l=Fn[a];if(l.majorMilliseconds*e>=i){n=l;break}}if(!n)return null;const o=Oe[n.minorUnit]*e,s=this.getAdaptiveMinorInterval(n.minorUnit,o);return zt(W({},n),{majorMarkerSpacingInPixels:n.majorMilliseconds*e,minorInterval:s,minorMarkerSpacingInPixels:s?o*s:null,minorMilliseconds:s?Oe[n.minorUnit]*s:null,pixelsPerMillisecond:e})},D.prototype.getParentContextScale=function(){const t=this.getSubdayVisualMarkerLayout(),e=t?t.majorUnit:this.unit+1;return e<lt||e>Cr?null:{level:this.zoomUnitToString(e),levelUnit:e,parentUnit:e<=j?O:e+1}},D.prototype.isParentContextTextVisible=function(t){if((t==null?void 0:t.visible)!==!0)return!1;const e=this.getParentContextScale();return e?t.levels==="all"?!0:Array.isArray(t.levels)&&t.levels.includes(e.level):!1},D.prototype.formatParentContextLabel=function(t,e){const i=this.getDateLabelFormatOptions(F);switch(e){case G:case K:case j:case O:return t.format("D MMM YYYY",i);case $:return t.format("MMM YYYY",i);case rt:return t.format("YYYY",i);case de:{const n=t.year<=0?1-t.year:t.year,o=Math.floor(n/10)*10;return o===0?t.year<=0?`9–1${i.bceText}`:"1–9":`${new y(o,1,1).format("YYYY",{thousandsSeparator:i.thousandsSeparator,bceText:""})}s${t.year<=0?i.bceText:""}`}case Rt:case fe:{const n=t.year<=0?1-t.year:t.year,s=Math.ceil(n/(e===Rt?100:1e3)),r=e===Rt?"century":"millennium";return`${Tr(s,i.thousandsSeparator)} ${r}${t.year<=0?i.bceText:""}`}default:return""}},D.prototype.createParentContextTokens=function(t,e,i){const n=this.getParentContextScale();if(!n||!t||!this.startToken)return[];const o=[];let s=Pr(t,n.parentUnit),r=i+this.getPixelsBetween(this.startToken.value,s);do{const a=kr(s,n.parentUnit);if(!a)break;const l=i+this.getPixelsBetween(this.startToken.value,a);o.push({drawX:r,label:this.formatParentContextLabel(s,n.parentUnit),length:l-r,unit:n.parentUnit,value:s}),s=a,r=l}while(o.length<1e3&&o[o.length-1].drawX<=e);return o},D.prototype.setAdaptiveMinorInterval=function(){const t=this.getSubdayVisualMarkerLayout();if(!t){this.adaptiveMinorUnit=null,this.adaptiveMinorInterval=null,this.adaptiveMinorMarkerSpacingInPixels=null;return}this.adaptiveMinorUnit=t.minorUnit,this.adaptiveMinorInterval=t.minorInterval,this.adaptiveMinorMarkerSpacingInPixels=t.minorMarkerSpacingInPixels},D.prototype.createSubdayVisualMarkers=function(t,e,i=this.getSubdayVisualMarkerLayout()){const n={[F]:[],[k]:[]};if(!i||!this.startToken)return n;const o=150,s=i.minorMilliseconds||i.majorMilliseconds,r=Math.floor((-o-e)/i.pixelsPerMillisecond),a=this.startToken.value.addMilliseconds(r),l=new y(a.year,a.month,a.day),c=Math.floor(a.getMillisecondsOfDay()/s)*s;let h=l.addMilliseconds(c);const u=i.minorMarkerSpacingInPixels>=this.zoomOptions.unitSize.showMinorLabels,m=p=>({drawX:e+this.getPixelsBetween(this.startToken.value,p),label:Dr(p,i.majorUnit,this.getDateLabelFormatOptions(F)),length:i.majorMarkerSpacingInPixels,markerSpacingInPixels:i.majorMarkerSpacingInPixels,type:F,unit:i.majorUnit,value:p,visual:!0}),d=Math.floor(a.getMillisecondsOfDay()/i.majorMilliseconds)*i.majorMilliseconds,g=l.addMilliseconds(d);for(g.isAfter(h)===!1&&!g.isSame(h)&&n[F].push(m(g));;){const p=e+this.getPixelsBetween(this.startToken.value,h);if(p>t+o)break;h.getMillisecondsOfDay()%i.majorMilliseconds===0?n[F].push(m(h)):i.minorMilliseconds&&n[k].push({adaptive:i.minorInterval!==1,drawX:p,label:u?pe(h,i.minorUnit):void 0,length:i.minorMarkerSpacingInPixels,markerSpacingInPixels:i.minorMarkerSpacingInPixels,type:k,unit:i.minorUnit,value:h,visual:!0}),h=h.addMilliseconds(s)}return n},D.prototype.createHourToken=function(t){const e={unit:j,value:t,length:this.unitSizeInPixels},i=this.unitLevels[j];return t.hour===0?(e.label=t.format("D MMM YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,j))),e},D.prototype.createMinuteToken=function(t){const e={unit:K,value:t,length:this.unitSizeInPixels},i=this.unitLevels[K];return t.minute===0?(e.label=t.format("HH:mm"),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,K))),e},D.prototype.createSecondToken=function(t){const e={unit:G,value:t,length:this.unitSizeInPixels},i=this.unitLevels[G];return t.second===0?(e.label=t.format("HH:mm:ss"),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,G))),e},D.prototype.createMillisecondToken=function(t){const e={unit:lt,value:t,length:this.unitSizeInPixels},i=this.unitLevels[lt];return t.millisecond===0?(e.label=t.format("HH:mm:ss.SSS"),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=pe(t,lt))),e},D.prototype.getDateLabelFormatOptions=function(t){t=t===F?"major":"minor";const e=this.owner.options.style.dateLabel[t];return{thousandsSeparator:e.thousandsSeparator,bceText:e.bceText,yearPrefix:this.yearPrefix[t]}},D.prototype.createYearToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels};let i=t.year;const n=i===0;i<=0&&(i=-i+1);const o=this.unitLengthInYears,s=this.unitLevels[this.unit];return i%(o*10)===0||n?(e.label=t.format("YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<s.zoomHideMinorLabels&&(e.label=t.format("YYYY",this.getDateLabelFormatOptions(k)))),e},D.prototype.createMonthToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels},i=this.unitLevels[$];return t.month===1?(e.label=t.format("YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=t.format("MMM"))),e},D.prototype.createDayToken=function(t){const e={unit:this.unit,value:t,length:this.unitSizeInPixels},i=this.unitLevels[O];return t.day===1?(e.label=t.format("MMM YYYY",this.getDateLabelFormatOptions(F)),e.type=F):(e.type=k,this.zoom<i.zoomHideMinorLabels&&(e.label=t.format("D"))),e},D.prototype.addZoomChangedHandler=function(t,e){this.zoomChangedHandlers.push({callback:t,context:e||this})},D.prototype.notifyZoomChanged=function(){for(let t=0;t<this.zoomChangedHandlers.length;t++)this.zoomChangedHandlers[t].callback.call(this.zoomChangedHandlers[t].context)},D.prototype.setZoom=function(t){var o,s;const e=this.zoom;let i=parseFloat(t.toFixed(4));i<this.zoomOptions.minimum&&(i=this.zoomOptions.minimum),i>this.zoomOptions.maximum&&(i=this.zoomOptions.maximum),this.zoom=i,this.unit=this.getUnitFromZoom(this.zoom),this.unitSizeInPixels=this.getUnitSizeInPixelsForZoom(this.zoom),this.setAdaptiveMinorInterval();let n=0;if(this.unit>=rt){const r=this.unit-rt;n=Math.pow(10,r)}if(this.unitLengthInYears=n,this.setCurrentYearPrefixes(),this.owner._isInitialized){const r=this.zoom-e;this.owner.trigger("zoom",{zoom:this.zoom,zoomDelta:r})}return(s=(o=this.owner)._markTimelineStateChanged)==null||s.call(o),this.notifyZoomChanged(),this.zoom},D.prototype.getPixelsBetween=function(t,e){const i=this.unit;return i<=O?t.getDaysTo(e)*this.unitSizeInPixels/Ee(i):i===$?t.getMonthsTo(e)*this.unitSizeInPixels:t.getYearsTo(e)*this.unitSizeInPixels/this.unitLengthInYears},D.prototype.setStartToken=function(t){return this.startToken=t},D.prototype.setStartDate=function(t){let e=0;switch(t.year<0&&(e=1),this.unit){case lt:return this.startToken=this.createMillisecondToken(new y(t)),0;case G:{const i=new y(t.year,t.month,t.day,t.hour,t.minute,t.second);return this.startToken=this.createSecondToken(i),-this.getPixelsBetween(i,t)}case K:{const i=new y(t.year,t.month,t.day,t.hour,t.minute);return this.startToken=this.createMinuteToken(i),-this.getPixelsBetween(i,t)}case j:{const i=new y(t.year,t.month,t.day,t.hour);return this.startToken=this.createHourToken(i),-this.getPixelsBetween(i,t)}case O:return this.startToken=this.createDayToken(new y(t.year,t.month,t.day)),-this.getPixelsBetween(this.startToken.value,t);case $:return this.startToken=this.createMonthToken(new y(t.year,t.month,1)),this.unitSizeInPixels/30.44*(this.startToken.value.day-t.day);case rt:return this.startToken=this.createYearToken(new y(t.year,1,1)),this.unitSizeInPixels/365.2422*((this.startToken.value.month-t.month)*30.44+(this.startToken.value.day-t.day));default:{const i=this.unitLengthInYears;return this.startToken=this.createYearToken(new y(Math.floor(t.year/i)*i+e,1,1)),this.unitSizeInPixels/(365.2422*i)*((this.startToken.value.year-t.year)*365.2422+(this.startToken.value.month-t.month)*30.44+(this.startToken.value.day-t.day))}}},D.prototype.getStartTokenCloned=function(){switch(this.startToken.unit){case lt:return this.createMillisecondToken(this.startToken.value);case G:return this.createSecondToken(this.startToken.value);case K:return this.createMinuteToken(this.startToken.value);case j:return this.createHourToken(this.startToken.value);case O:return this.createDayToken(this.startToken.value);case $:return this.createMonthToken(this.startToken.value);default:return this.createYearToken(this.startToken.value)}},D.prototype.getNext=function(t){switch(t.unit){case lt:return this.createMillisecondToken(t.value.addMilliseconds(1));case G:return this.createSecondToken(t.value.addSeconds(1));case K:return this.createMinuteToken(t.value.addMinutes(1));case j:return this.createHourToken(t.value.addHours(1));case O:return this.createDayToken(t.value.getNextDay());case $:return this.createMonthToken(t.value.getNextMonth());case rt:return this.createYearToken(t.value.addYears(1));default:{const e=this.unitLengthInYears;return this.createYearToken(t.value.addYears(t.value.year===-(e-1)?e-1:e))}}},D.prototype.getPrevious=function(t){switch(t.unit){case lt:return this.createMillisecondToken(t.value.addMilliseconds(-1));case G:return this.createSecondToken(t.value.addSeconds(-1));case K:return this.createMinuteToken(t.value.addMinutes(-1));case j:return this.createHourToken(t.value.addHours(-1));case O:return this.createDayToken(t.value.getPreviousDay());case $:return this.createMonthToken(t.value.getPreviousMonth());case rt:return this.createYearToken(t.value.addYears(-1));default:{const e=this.unitLengthInYears;return this.createYearToken(t.value.addYears(t.value.year===0?1-e:-e))}}},D.prototype.getPreviousNth=function(t,e){for(let i=0;i<e;i++)t=this.getPrevious(t);return t},D.prototype.zoomUnitToString=function(t){switch(t){case lt:return"millisecond";case G:return"second";case K:return"minute";case j:return"hour";case O:return"day";case $:return"month";case rt:return"year";case de:return"decade";case Rt:return"century";case fe:return"millennium";case Fi:return"10 thousand years";case Bi:return"100 thousand years";case Hi:return"million years";case Yi:return"10 million years";case Wi:return"100 million years";case Vi:return"billion years";default:return"unknown"}},D.prototype.setUnitLevels=function(){this.unitLevels=[],this.unitOrder=[];const t=this.zoomOptions.unitSize.minimum,e=this.zoomOptions.unitSize.showMinorLabels,i=0,n=(z,it)=>{this.unitLevels[z]=it,this.unitOrder.push(z)},o=this.getZoomChangeByDistance(e,t),s=this.zoomOptions.unitSize.initial,r=this.getZoomChangeByDistance(s,t),a=i+r,l=a-o;n(O,{startUnitSize:s,zoomStart:i,zoomHideMinorLabels:l,zoomEnd:a});const h=s/24,u=this.getZoomChangeByDistance(h,t*60);n(j,{startUnitSize:t*60,zoomStart:u,zoomEnd:i,zoomHideMinorLabels:u+this.getZoomChangeByDistance(t*60,e)});const m=u+this.getZoomChangeByDistance(t,t*60);n(K,{startUnitSize:t*60,zoomStart:m,zoomEnd:u,zoomHideMinorLabels:m+this.getZoomChangeByDistance(t*60,e)});const d=m+this.getZoomChangeByDistance(t,t*1e3);n(G,{startUnitSize:t*1e3,zoomStart:d,zoomEnd:m,zoomHideMinorLabels:d+this.getZoomChangeByDistance(t*1e3,e)}),n(lt,{startUnitSize:t,referenceZoom:d,zoomStart:Number.NEGATIVE_INFINITY,zoomEnd:d,zoomHideMinorLabels:d+this.getZoomChangeByDistance(t,e)});const g=t*31,p=this.getZoomChangeByDistance(g,t),w=a+p,b=w-o;n($,{startUnitSize:g,zoomStart:a,zoomHideMinorLabels:b,zoomEnd:w});const v=t*12,S=this.getZoomChangeByDistance(v,t),M=w+S,P=M-o;n(rt,{startUnitSize:v,zoomStart:w,zoomHideMinorLabels:P,zoomEnd:M});let E,x,Z=M,R,V;const B=8;for(let z=1;z<=B;z++)E=t*10,x=this.getZoomChangeByDistance(E,t),R=Z+x,V=R-o,n(rt+z,{startUnitSize:E,zoomStart:Z,zoomHideMinorLabels:V,zoomEnd:R}),Z=R,z===B&&(this.zoomOptions.maximum=Math.min(this.zoomOptions.maximum,R));this.unitOrder.sort((z,it)=>z-it)},D.prototype.getZoomChangeByDistance=function(t,e){const i=this.zoomOptions.ratio;return Math.log(e/t)/Math.log(i)},D.prototype.scaleDistanceByZoomChange=function(t,e){const i=this.zoomOptions.ratio;return t*Math.pow(i,e)},D.prototype.setCurrentYearPrefixes=function(){const t=["minor","major"];if(this.unit<rt){for(let n=0;n<t.length;n++)this.yearPrefix[t[n]]=!1;return}const e=this.owner.options.style.dateLabel,i={minor:this.unitLengthInYears,major:this.unitLengthInYears*10};for(let n=0;n<t.length;n++){const o=t[n],s=Object.values(e[o].yearPrefixes);this.yearPrefix[o]=!1,s.sort(function(r,a){return a.minDivision-r.minDivision});for(let r=0;r<s.length;r++){const a=s[r];if(a.minDivision<=i[o]){this.yearPrefix[o]={label:a.label,value:a.value};break}}}};const Bn=["http","https","data","blob"];function Rr(t,e=Bn){if(typeof t!="string")return!1;const i=t.trim(),n=i.toLowerCase();if(n.startsWith("data:"))return e.includes("data");if(n.startsWith("blob:"))return e.includes("blob");try{const o=new URL(i,typeof window!="undefined"?window.location.href:void 0);return e.includes(o.protocol.replace(":",""))}catch(o){return!1}}function Or(t){return/^data:image\//i.test(t)}function Er(t,e){if(!Array.isArray(e)||e.length===0)return!0;try{const i=new URL(t,typeof window!="undefined"?window.location.href:void 0),n=i.origin.toLowerCase(),o=i.hostname.toLowerCase();for(const s of e){if(typeof s!="string")continue;const r=s.trim().toLowerCase();if(r.includes("://")){try{const a=new URL(r).origin.toLowerCase();if(n===a)return!0}catch(a){}continue}if(r.startsWith("*.")&&(o===r.slice(2)||o.endsWith(`.${r.slice(2)}`))||r.startsWith(".")&&(o===r.slice(1)||o.endsWith(r))||o===r||o.endsWith(`.${r}`))return!0}return!1}catch(i){return!0}}function Nr(t,e={}){if(typeof t!="string")return null;const i=Array.isArray(e.allowedSchemes)&&e.allowedSchemes.length?e.allowedSchemes:Bn;if(!Rr(t,i))return null;const n=t.trim().toLowerCase();return n.startsWith("data:")?Or(n)?t:null:Er(t,e.allowedOrigins)?t:null}function xr(){const t=typeof globalThis!="undefined"&&globalThis.devicePixelRatio||1;return typeof t!="number"||!isFinite(t)||t<=0?1:t}function zr(t){const e=t&&t.dprMode==="native",i=xr(),n=e?i:Math.ceil(i),o=t&&typeof t.dpr=="number"&&isFinite(t.dpr)&&t.dpr>0?t.dpr:n,s=t&&typeof t.maxDpr=="number"&&isFinite(t.maxDpr)&&t.maxDpr>0?t.maxDpr:4;return Math.min(s,Math.max(1,o))}function pi(t,e,i,n,o){const s=zr(o),r=Math.max(1,Math.round(e!=null?e:t.clientWidth||t.width||1)),a=Math.max(1,Math.round(i!=null?i:t.clientHeight||t.height||1));t.style&&(t.style.width!==`${r}px`&&(t.style.width=`${r}px`),t.style.height!==`${a}px`&&(t.style.height=`${a}px`));const l=r*s,c=a*s;t.width!==l&&(t.width=l),t.height!==c&&(t.height=c);const h=n||t.getContext&&t.getContext("2d")||null;return h&&typeof h.setTransform=="function"&&h.setTransform(s,0,0,s,0,0),t._dpr=s,s}function Hn(t,e){const i=t.canvas._dpr||1;t.shadowOffsetX=e.x*i,t.shadowOffsetY=e.y*i,t.shadowBlur=e.amount*i,t.shadowColor=e.color}function Fr(t){return t instanceof HTMLCanvasElement||t&&t.nodeName==="CANVAS"}function Br({width:t,height:e,className:i,style:n}={}){const o=document.createElement("canvas");return t!=null&&(o.width=t),e!=null&&(o.height=e),i&&(o.className=i),o.style.touchAction="none",n&&Object.assign(o.style,n),o}function Yn(t,e){return t!=null&&t.append?t.append(e):t.appendChild(e),e}function Hr(t){const e=t.getBoundingClientRect();return{left:e.left,top:e.top}}function Yr(){document.selection?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()}const vt=typeof window!="undefined"&&"onpointerdown"in window,Wr=750,Wn=vt?{down:"pointerdown",move:"pointermove",up:"pointerup",cancel:"pointercancel",leave:"pointerleave"}:{down:"mousedown",move:"mousemove",up:"mouseup",cancel:"mouseleave",leave:"mouseleave"};function Ne(t,e,i,n){const o=Wn[e]||e;t.addEventListener(o,i,n),vt||(e==="down"&&t.addEventListener("touchstart",i,n),e==="move"&&t.addEventListener("touchmove",i,n),e==="up"&&(t.addEventListener("touchend",i,n),t.addEventListener("touchcancel",i,n)))}function xe(t,e,i,n){const o=Wn[e]||e;t.removeEventListener(o,i,n),vt||(e==="down"&&t.removeEventListener("touchstart",i,n),e==="move"&&t.removeEventListener("touchmove",i,n),e==="up"&&(t.removeEventListener("touchend",i,n),t.removeEventListener("touchcancel",i,n)))}function ne(t){if(t.touches&&t.touches[0]){const e=t.touches[0];return{x:e.clientX,y:e.clientY}}if(t.changedTouches&&t.changedTouches[0]){const e=t.changedTouches[0];return{x:e.clientX,y:e.clientY}}return{x:t.clientX,y:t.clientY}}class Vr{constructor(e,{onStart:i,onMove:n,onEnd:o}={}){this.target=e,this.onStart=i,this.onMove=n,this.onEnd=o,this.pointers=new Map,this.lastTouchTime=0,this._handleDown=this._handleDown.bind(this),this._handleMove=this._handleMove.bind(this),this._handleUp=this._handleUp.bind(this),Ne(e,"down",this._handleDown),Ne(window,"move",this._handleMove),Ne(window,"up",this._handleUp),vt&&Ne(window,"cancel",this._handleUp)}destroy(){xe(this.target,"down",this._handleDown),xe(window,"move",this._handleMove),xe(window,"up",this._handleUp),vt&&xe(window,"cancel",this._handleUp),this.pointers.clear()}_handleDown(e){if(!vt){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}vt?this._addOrUpdatePointer(e):e.touches?this._syncTouches(e):this.pointers.set("mouse",{id:"mouse",x:e.clientX,y:e.clientY,type:"mouse"}),this.onStart&&this.onStart(e,this)}_handleMove(e){if(!vt){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}if(vt)this.pointers.has(this._getPointerId(e))&&this._addOrUpdatePointer(e);else if(e.touches)this._syncTouches(e);else if(this.pointers.has("mouse")){const i=this.pointers.get("mouse");i.x=e.clientX,i.y=e.clientY}this.onMove&&this.onMove(e,this)}_handleUp(e){if(!vt){if(this._isTouchEvent(e))this.lastTouchTime=Date.now();else if(this._shouldIgnoreMouseEvent(e))return}if(vt)this.pointers.delete(this._getPointerId(e));else if(e.changedTouches){for(const i of e.changedTouches)this.pointers.delete(i.identifier);(!e.touches||e.touches.length===0)&&this.pointers.delete("mouse")}else this.pointers.delete("mouse");this.onEnd&&this.onEnd(e,this)}_getPointerId(e){return e.pointerId!=null?e.pointerId:"mouse"}_isTouchEvent(e){return!!(e.touches||e.changedTouches)}_shouldIgnoreMouseEvent(e){return!this._isTouchEvent(e)&&Date.now()-this.lastTouchTime<Wr}_addOrUpdatePointer(e){this.pointers.set(this._getPointerId(e),{id:this._getPointerId(e),x:e.clientX,y:e.clientY,type:e.pointerType||"mouse"})}_syncTouches(e){this.pointers.clear();for(const i of e.touches)this.pointers.set(i.identifier,{id:i.identifier,x:i.clientX,y:i.clientY,type:"touch"})}get list(){return Array.from(this.pointers.values())}}function Zr(t){return t.list[0]||null}function Vn(t){const e=t.list;return e.length===0?null:e.length===1?{x:e[0].x,y:e[0].y}:{x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2}}function Zn(t){const e=t.list;if(e.length<2)return 0;const i=e[0].x-e[1].x,n=e[0].y-e[1].y;return Math.hypot(i,n)}function f(t,e){var l;const i=zn(e);this._registeredArticleLayoutStyles=L({},mi.article.layoutStyles||{}),this._explicitArticleOptions=L({},(i==null?void 0:i.article)||{}),this.options=L({},mi,i),Fr(t)?this.canvas=t:(this.canvas=Br(),Yn(t,this.canvas)),this.canvas&&this.canvas.style&&(this.options.width!=null&&(this.canvas.style.width=`${this.options.width}px`),this.options.height!=null&&(this.canvas.style.height=`${this.options.height}px`)),this.canvasContext=this.canvas.getContext("2d"),this.canvasDpr=pi(this.canvas,this.options.width,this.options.height,this.canvasContext,this.options.canvas),this.fontWatcher=new Sr(c=>{this.forLoadedArticles(h=>h.invalidateCaches()),this.requestRedraw()});const n=this.canvasContext,o=n.measureText.bind(n);n.measureText=c=>(this.fontWatcher.use(n.font),o(c)),this.width=this.canvas.clientWidth||this.options.width,this.top=this.options.height-this._getEffectiveVerticalOffset(),this.repositionWindow=0,this.uniqueId=`tl${new Date().getTime()}`,this.title="My timeline",this.ownerId=void 0,this.cursor="default",this.mouseoverArticle=null,this.isDragging=!1,this.draggingArticle=null,this.dragStartX=0,this.isPanning=!1,this.isPinching=!1,this.isAnimating=!1,this.isAnimatingArticles=!1,this.isCustomAnimating=!1,this.animation={redrawFunction:!1,defaultRedrawFunction:this.repositionRedraw,dragRedrawFunction:this.defaultRedraw,pan:null,zoom:null},this.lastAnimatingArticle={id:null,endTime:0},this.topRow=0,this.loadingHttpRequests=[],this.articles=[],this.lanes=[],this.timeBands=[],this.charts=[],this._runtimeArticleOptions={},this.redrawRequests={default:!1,reposition:!1},this._initialiseLaneHost(t),this.handlers={},this.options.on&&this.onMultiple(this.options.on),this._isInitialized=!1,this._hasPendingTimelineStateChange=!1;const s=this.options.zoom,r=this.getDmyFromInput(this.options.initialDate);this.timescaleManager=new D(this,s),this.timescaleManager.setUnitLevels(),this.timescaleManager.addZoomChangedHandler(this.zoomChanged,this),this.timescaleManager.setZoom(s.initial),this.timescaleManager.setStartDate(r),(l=this.settleDateBounds)==null||l.call(this,{animate:!1}),this.options.enableUserControl&&(this.enableZoomByWheel(),this.enableDragging()),this.groups={level:-1,periods:[]};const a=this.options.image||{};this.imageLoader=new Ir({maxConcurrent:a.maxConcurrent,maxCacheBytes:a.maxCacheBytes,requireCORS:a.requireCORS,decodeMode:a.decodeMode}),this.options.lane&&Array.isArray(this.options.lane.data)&&this.options.lane.data.length>0&&this.addLanes(this.options.lane.data),this.options.timeBand&&Array.isArray(this.options.timeBand.data)&&this.options.timeBand.data.length>0&&typeof this.addTimeBands=="function"&&this.addTimeBands(this.options.timeBand.data),this.options.chart&&Array.isArray(this.options.chart.data)&&this.options.chart.data.length>0&&typeof this.addCharts=="function"&&this.addCharts(this.options.chart.data),this.requestRedraw(),this._isInitialized=!0}f.prototype.setTitle=function(t){this.title=t,this._emitTimelineStateChange()},f.prototype.getWidth=function(){return this.canvas.clientWidth||this.options.width},f.prototype.getCanvasDpr=function(){return this.canvasDpr||1},f.prototype.isInVicinity=function(t,e,i){if(e=ie(e,this,t,i),typeof e=="boolean")return e;const n=i||this.getRelativePosition(t),o=e.up===void 0||n.top>this.top-e.up,s=e.down===void 0||n.top<this.top+e.down;return o&&s},f.prototype.getPixel=function(t,e){let i;const n=t.toKeyString();if(e){if(i=e.tokens,Object.prototype.hasOwnProperty.call(i,n))return i[n]}else i={};const o=this.repositionWindow,s=this.timescaleManager.startToken;return i[n]=this.timescaleManager.getPixelsBetween(s.value,t)+o},f.prototype.getRelativePosition=function(t){const{x:e,y:i}=ne(t),n=this.canvas.getBoundingClientRect();return{left:e-n.left,top:i-n.top}},f.prototype.updateCursor=function(t){const e=this.cursor,i=this.cursor=this.getCursor(t);e!==i&&(this.canvas.style.cursor=i)},f.prototype.getCursor=function(t){const e=this.options.style.cursor;if(this.isDragging)return e.timeline.dragging;const i=this.getRelativePosition(t);return this.draggingArticle?this.draggingArticle.getCursor(i):!this.options.disableBranding&&(this._isInsideHistropediaJSLink(i)||this._isInsideTermsLink(i))?e.clickable:this.mouseoverArticle!==null?this.mouseoverArticle.getCursor(i):e.timeline.hover},f.prototype.onRedraw=function(t){T.warn('DEPRECATION WARNING: timeline.onRedraw(handler) is deprecated. Use timeline.on("timeline-render-end", handler) instead.'),typeof this.on=="function"&&this.on("timeline-render-end",t)},f.prototype.zoomChanged=function(){let t;this.currentDensitySetting&&(t=this.currentDensitySetting.region),this.updateCurrentDensitySetting(),t!==this.currentDensitySetting.region&&this.updateArticlesGroupIndex()},f.prototype.updateCurrentDensitySetting=function(){for(let t=0;t<Je.length;t++){const e=Je[t];if(this.timescaleManager.zoom>=e.zoom.from&&this.timescaleManager.zoom<e.zoom.to){this.currentDensitySetting=e;break}}},f.prototype.calculateEndToken=function(){const t=this.getWidth();let e=this.repositionWindow,n=this.timescaleManager.startToken,o;do o=n,n=this.timescaleManager.getNext(n),e+=n.length;while(e<t);return o},f.prototype.getDensityPick=function(t=this.options.article.density){switch(t){case"low":case 1:return this.currentDensitySetting.low;case"medium":case 2:return this.currentDensitySetting.medium;case"high":case 3:return this.currentDensitySetting.high;case"all":case 0:return this.currentDensitySetting.all}T.error(`Unknown density selector:${t}`)},f.prototype.invoke=function(t,e,i){Object.prototype.hasOwnProperty.call(e,t)&&e[t].call(this,i)},f.prototype.forLoadedArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&t.call(this,i)}},f.prototype.forVisibleArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&i.isVisible&&t.call(this,i)}},f.prototype.forInRangeArticles=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isDataLoaded&&(i.isInRange||i.isFading)&&t.call(this,i)}},f.prototype.enqueueImageLoad=function(t){let e=_(t.data,"imageUrl");if(!e){if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(l){}t.image=null,t.imageLoaded=!1,t._closeImage=null,t._loadedImageKey=null,t._pendingImageKey=null;return}const{sanitizer:i,customSanitizer:n}=this.options.image;if(typeof n=="function")try{e=n(e,i)}catch(l){e=null}else e=Nr(e,i);if(!e){if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(l){}t.image=null,t.imageLoaded=!1,t._closeImage=null,t._loadedImageKey=null,t._pendingImageKey=null;return}const o=this._getArticleImageTargetSpec(t),s=o&&Number.isFinite(o.dpr)&&o.dpr>0?Math.round(Math.max(1,o.dpr)*1e3)/1e3:1,r=`img:${e}:${o.layout}:${o.shape}:${o.targetW||0}x${o.targetH||0}@${s}`;if(t._loadedImageKey===r&&t.imageLoaded&&t.image||t._pendingImageKey===r&&typeof t._imageCancel=="function")return;if(t._pendingImageKey&&t._pendingImageKey!==r&&typeof t._imageCancel=="function"){try{t._imageCancel()}catch(l){}t._imageCancel=null}t.imageLoaded&&t.image||(t.imageLoaded=!1),t._pendingImageKey=r;const a=this.imageLoader.enqueue(r,e,(l,c,h,u,m)=>{if(typeof t._closeImage=="function")try{t._closeImage({keepState:!1,skipRedraw:!0})}catch(g){}let d=null;typeof m=="function"?d=m:typeof u=="function"&&(d=function(){try{u()}catch(g){}}),t.image=l,t.imageLoaded=!0,t._loadedImageKey=r,t._pendingImageKey=null,t._imageCancel=null,t._closeImage=d,t._closeImage&&t._closeImage._key==null&&typeof m=="function"&&(t._closeImage._key=r,t._closeImage._article=t),typeof t.updateCachedSize=="function"&&t.updateCachedSize(),this.requestRedraw(this.redraw)},{targetW:o.targetW,targetH:o.targetH,shape:o.shape,article:t});t._imageCancel=a},f.prototype._getArticleImageTargetSpec=function(t){const e=t._getCurrentCardLayoutName(),i=t.getCurrentStyle(),n=i&&i.image?i.image:{},o=n.shape||"square";let s=null,r=null;if(e==="landscape"){const m=n.margin||0,d=Math.max(1,(i.height||0)-m*2);s=d,r=d}else if(e==="portrait"){const m=n.margin||0,g=Math.max(1,(i.width||0)-0-m*2);o==="square"||o==="circle"?(s=g,r=g):s=g}else i&&typeof i.width=="number"&&(s=i.width);const a=typeof this.getCanvasDpr=="function"?this.getCanvasDpr():Number(this.canvasDpr),l=Number.isFinite(a)&&a>0?a:1,c=m=>typeof m!="number"||!Number.isFinite(m)||m<=0?null:Math.max(1,Math.round(m*l)),h=c(s),u=c(r);return{layout:e,targetW:h,targetH:u,shape:o,dpr:l}},f.prototype.setOption=function(t,e){if(typeof t=="string"){const d=xn(t),g=_(this.options,d);if(typeof e=="undefined")return g;t=bt(d,e)}const i=this.top;t=zn(t),A(t,"article")&&L(this._explicitArticleOptions,t.article||{}),L(this.options,t);const n=t.width||t.height;n&&this.setSize(this.options.width,this.options.height);const o=A(t,"canvas.dpr")||A(t,"canvas.dprMode")||A(t,"canvas.maxDpr");!n&&o&&(this.canvasDpr=pi(this.canvas,this.options.width,this.options.height,this.canvasContext,this.options.canvas)),typeof t.verticalOffset=="number"&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),(A(t,"timeBand.visible")||A(t,"timeBand.reserveSpace")||A(t,"timeBand.reserveSpacePixels"))&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),(A(t,"style.dateLabel.parent.visible")||A(t,"style.dateLabel.parent.height"))&&(this.top=this.options.height-this._getEffectiveVerticalOffset());const a=kn(_(t,"article"));if(A(t,"timeBand.defaultStyle")&&Array.isArray(this.timeBands)&&this.timeBands.length>0){const d=this.options.timeBand&&this.options.timeBand.defaultStyle?this.options.timeBand.defaultStyle:{};for(let g=0;g<this.timeBands.length;g++){const p=this.timeBands[g],w=p&&p.data&&p.data.style?p.data.style:{};p.style=L({},d,w)}}const c=_(t,"chart.data");Array.isArray(c)&&typeof this.addCharts=="function"&&this.addCharts(c);const h=A(t,"chart.seriesColors");if((h||A(t,"chart.defaultData")||A(t,"chart.defaultStyle"))&&Array.isArray(this.charts)&&this.charts.length>0){let d=!1;for(let g=0;g<this.charts.length;g++){const p=this.charts[g].laneId;h&&(this.charts[g]._seriesColors=[]),this.charts[g]._resolveFromData(),A(t,"chart.defaultData")&&this.charts[g].laneId!=null&&this._ensureChartLane(this.charts[g].laneId),d=d||p!==this.charts[g].laneId}d&&(this._refreshLaneOrder(),this._updateLaneLayout())}let m={styleLaneIds:new Set};if(A(t,"lane")){const d=_(t,"lane.data");Array.isArray(d)&&(m=this.addLanes(d,{suppressArticleRefresh:!0}))}if(A(t,"lane")||a.cacheChanged){const d=a.styleChanged?"all":m.styleLaneIds.size>0?m.styleLaneIds:null;this._refreshResolvedLanesFromOptions({articleStyleScope:d})}this.top!==i&&this.options.article.autoStacking.fitToHeight&&!this._isLaneLayoutActive()&&this.fitToHeight(),this.requestRedraw()},f.prototype.setSize=function(t,e){this.canvas&&this.canvas.style&&(typeof t=="number"&&(this.canvas.style.width=`${t}px`),typeof e=="number"&&(this.canvas.style.height=`${e}px`)),this.options.width=t,this.options.height=e,this.canvasDpr=pi(this.canvas,t,e,this.canvasContext,this.options.canvas),typeof this._syncLaneViewportSize=="function"&&this._syncLaneViewportSize(),this.width=this.canvas.clientWidth||t,this.top=e-this._getEffectiveVerticalOffset(),this.requestRedraw()},f.prototype._getEffectiveVerticalOffset=function(){var a,l;const t=this.options.verticalOffset||0,e=this.options.timeBand||{},i=Array.isArray(this.timeBands)&&this.timeBands.length>0,o=!!e.reserveSpace&&e.visible&&i&&e.reserveSpacePixels||0,s=((l=(a=this.options.style)==null?void 0:a.dateLabel)==null?void 0:l.parent)||{},r=s.visible===!0&&s.height||0;return t+o+r},f.prototype.generateDensitySettings=function(){const t=this.timescaleManager.zoomOptions.ratio,e=[],i=a=>Math.round(a*100)/100,n=i(Math.log(.5)/Math.log(t)),o=Math.ceil(Math.log2(U));for(let a=o;a>=1;a--)e.push({region:1-a,zoom:{from:a===o?Number.NEGATIVE_INFINITY:i(-a*n),to:i(-(a-1)*n)},low:1,medium:2,high:3,all:25,step:{months:0,days:0,divisionsPerDay:Math.pow(2,a)}});const s=Math.ceil(this.timescaleManager.zoomOptions.maximum/n);for(let a=0;a<s;a++){const l=i(a*n),c=i((a+1)*n),h={region:a+1,zoom:{from:l,to:c},low:1,medium:2,high:3,all:25,step:{months:0,days:Math.pow(2,a)}};e.push(h)}const r=JSON.stringify(e,(a,l)=>l===Number.NEGATIVE_INFINITY?"__DENSITY_NEGATIVE_INFINITY__":l,2).replace('"__DENSITY_NEGATIVE_INFINITY__"',"Number.NEGATIVE_INFINITY");T.log(r)};function oe(t){return t!=null&&typeof t=="object"}function Ur(t,e){return{day:t.getDaysSinceYearZero(),division:Math.floor(t.getMillisecondsOfDay()*e/U),divisionsPerDay:e}}function se(t,e){return!oe(t)&&!oe(e)?t===e?0:t<e?-1:1:t.day!==e.day?t.day<e.day?-1:1:t.division!==e.division?t.division<e.division?-1:1:0}function St(t,e){if(!oe(t))return t+e;const i=t.division+e,n=Math.floor(i/t.divisionsPerDay);return{day:t.day+n,division:i-n*t.divisionsPerDay,divisionsPerDay:t.divisionsPerDay}}function Un(t,e,i){return se(t,e)<0?e:se(t,i)>0?i:t}function yi(t){return oe(t)?`${t.day}:${t.division}`:String(t)}function Gr(t){return{dayNumber:t.day,dayFraction:t.division/t.divisionsPerDay}}function jr(t,e){return`${t}::${yi(e)}`}const $r=1e7,Xr=2e7;function qr(t){return t.isActive?t.rank+Xr:t.rank+(t.isStarred?$r:0)}function Kr(t,e){const i=[];let n=0;for(let o=0;o<t.length;o++){const s=t[o];if(s.effectiveRank=qr(s),i.length<e){i.push(s),s.effectiveRank<i[n].effectiveRank&&(n=i.length-1);continue}s.effectiveRank>i[n].effectiveRank&&(i[n]=s,n=vr(i,"effectiveRank"))}return i}f.prototype.updateArticlesGroupIndex=function(){this.forLoadedArticles(function(t){t.groupIndex=this.calculateGroupIndex(t.period.from)})},f.prototype.updateVisibleArticlesOfGroups=function(t){if(this._isLaneLayoutActive()){this.groups={};const o=gi(this.options.article.autoStacking.range)?1:20,s=St(this.calculateGroupIndex(t.tokens.start),-o),r=St(this.calculateGroupIndex(t.tokens.end),o),a=this._getActiveLanesForLayout();this.forLoadedArticles(function(l){l.isVisibleInGroup=!1});for(let l=0;l<a.length;l++){const c=a[l];for(let h=s;se(h,r)<=0;h=St(h,1)){const u=jr(c.id,h);this.groups[u]=this.getArticlesInGroup(h,s,r,c.id).map(function(m){return m.isVisibleInGroup=!0,m.id})}}return}this.groups={};const e=gi(this.options.article.autoStacking.range)?1:20,i=St(this.calculateGroupIndex(t.tokens.start),-e),n=St(this.calculateGroupIndex(t.tokens.end),e);this.forLoadedArticles(function(o){o.isVisibleInGroup=!1});for(let o=i;se(o,n)<=0;o=St(o,1))this.groups[yi(o)]=this.getArticlesInGroup(o,i,n).map(function(s){return s.isVisibleInGroup=!0,s.id})},f.prototype.getArticlesInGroup=function(t,e,i,n){const o=typeof n!="undefined"?this.getLaneById(n):null,s=o&&o.resolvedArticleOptions?o.resolvedArticleOptions.density:this.options.article.density,r=this.getDensityPick(s),a=[];for(let l=0;l<this.articles.length;l++){const c=this.articles[l];!c.isDataLoaded||c.isHiddenByFilter||typeof n!="undefined"&&c.laneId!==n||!(se(Un(c.groupIndex,e,i),t)===0)||a.push(c)}return Kr(a,r)},f.prototype.calculateGroupIndex=function(t){if(this.currentDensitySetting.step.divisionsPerDay)return Ur(t,this.currentDensitySetting.step.divisionsPerDay);if(this.timescaleManager.unit>=$&&this.currentDensitySetting.step.months!==0){const i=t.year*12+(t.month-1);return Math.floor(i/this.currentDensitySetting.step.months)}const e=t.year*372+(t.month-1)*31+t.day;return this.currentDensitySetting.step.days===0?Math.floor(e/(this.currentDensitySetting.step.months*30)):Math.floor(e/this.currentDensitySetting.step.days)},f.prototype.canBeVisibleInGroup=function(t,e,i){if(t.isActive)return!0;e=e||this.timescaleManager.startToken,i=i||this.calculateEndToken();const n=St(this.calculateGroupIndex(e.value),-1),o=St(this.calculateGroupIndex(i.value),1),s=Un(t.groupIndex,n,o),r=yi(s);return Object.prototype.hasOwnProperty.call(this.groups,r)?this.groups[r].indexOf(t.id)>=0:!1};const Jr=64;function Qr({velocity:t,friction:e,minVelocity:i,maxDuration:n,maxFrameDelta:o=Jr,shouldStop:s,onUpdate:r,onComplete:a}={}){let l=t;const c=performance.now();let h=c,u=!1;if(!Number.isFinite(l)||!Number.isFinite(e)||e<=0||!Number.isFinite(i)||i<0||!Number.isFinite(n)||n<=0)return{stop(){}};function m(){u=!0}function d(){u||(u=!0,a==null||a())}function g(p){if(u)return;if(s!=null&&s()){m();return}if(p-c>=n||Math.abs(l)<i){d();return}const w=Math.min(Math.max(p-h,0),o);if(h=p,w>0){const b=Math.exp(-e*w),v=l*(1-b)/e;l*=b,v!==0&&(r==null||r(v,l))}requestAnimationFrame(g)}return requestAnimationFrame(g),{stop:m}}function Gn(t=0){var e,i;return typeof t=="number"?{left:t,right:t}:{left:(e=t==null?void 0:t.left)!=null?e:0,right:(i=t==null?void 0:t.right)!=null?i:0}}function ze(t){var i,n,o,s,r,a,l;const e=typeof t=="string"?(i=ti(t))==null?void 0:i.date:t;if(!e||!Number.isFinite(e.year))throw new Error("Date input requires a numeric year or canonical Histropedia date string");return new y({precision:me(e),year:e.year,month:(n=e.month)!=null?n:1,day:(o=e.day)!=null?o:1,hour:(s=e.hour)!=null?s:0,minute:(r=e.minute)!=null?r:0,second:(a=e.second)!=null?a:0,millisecond:(l=e.millisecond)!=null?l:0})}function wi(t){const e=Math.floor(t.millisecond/U);return{dayNumber:t.dayNumber+e,millisecond:t.millisecond-e*U}}function re(t){return{dayNumber:t.getDaysSinceYearZero(),millisecond:t.getMillisecondsOfDay()}}function Ot(t,e){return t.dayNumber!==e.dayNumber?t.dayNumber<e.dayNumber?-1:1:t.millisecond!==e.millisecond?t.millisecond<e.millisecond?-1:1:0}function Lt(t,e){const i=e.dayNumber-t.dayNumber,n=e.millisecond-t.millisecond;return i+n/U}function Tt(t,e){const i=Math.floor(e);return wi({dayNumber:t.dayNumber+i,millisecond:t.millisecond+(e-i)*U})}function jn(t,e,i){if(i<=0)return W({},t);if(i>=1)return W({},e);const n=(e.dayNumber-t.dayNumber)*i,o=Math.floor(n),s=t.millisecond+(n-o)*U+(e.millisecond-t.millisecond)*i;return wi({dayNumber:t.dayNumber+o,millisecond:s})}function ye(t){return new y(t===-1?1:t+1,1,1)}function ta(t,e){return e===12?ye(t):new y(t,e+1,1)}function $n(t){const e=ze(t),i=typeof t=="string"?ti(t):null,n=i?i.hasMonth:t.month!=null,o=i?i.hasDay:t.day!=null,s=i?i.hasTime:t.hour!=null||t.minute!=null||t.second!=null||t.millisecond!=null;return!n&&!s?{start:e,end:ye(e.year)}:!o&&!s?{start:e,end:ta(e.year,e.month)}:{start:e,end:ze(t)}}function bi(t,e){return Math.max(1,t.getWidth()-e.left-e.right)}function ea(t,e){var s,r;const i=(s=t.zoomOptions)==null?void 0:s.minimum,n=(r=t.zoomOptions)==null?void 0:r.maximum;let o=e;return Number.isFinite(i)&&o<i&&(o=i),Number.isFinite(n)&&o>n&&(o=n),o}function Fe(t,e){return Number.isFinite(e)?parseFloat(ea(t,e).toFixed(4)):e}function Xn(t,e){if(typeof t.getUnitFromZoom=="function")return t.getUnitFromZoom(e);const i=t.unitLevels;if(!Array.isArray(i)||i.length===0)return t.unit;const n=t.unitOrder||i.map((o,s)=>s);for(let o=n.length-1;o>=0;o--){const s=n[o];if(e>=i[s].zoomStart)return s}return t.unit}function qn(t,e,i){var r,a,l,c;const n=(r=t.unitLevels)==null?void 0:r[e],o=(a=t.zoomOptions)==null?void 0:a.ratio;if(n&&Number.isFinite(n.startUnitSize)&&Number.isFinite((l=n.referenceZoom)!=null?l:n.zoomStart)&&Number.isFinite(o)&&o>0)return n.startUnitSize*Math.pow(o,i-((c=n.referenceZoom)!=null?c:n.zoomStart));if(!Number.isFinite(t.unitSizeInPixels))return NaN;const s=i-t.zoom;return t.scaleDistanceByZoomChange?t.scaleDistanceByZoomChange(t.unitSizeInPixels,s):NaN}function Kn(t){return t>=rt?Math.pow(10,t-rt):0}function ia(t,e,i,n){const o=Fe(t,n),s=Xn(t,o),r=qn(t,s,o);return!Number.isFinite(r)||r<=0?NaN:s<=O?e.getDaysTo(i)*r/Ee(s):s===$?e.getMonthsTo(i)*r:e.getYearsTo(i)*r/Kn(s)}function na(t,e,i,n){const o=Fe(t,n),s=Xn(t,o),r=qn(t,s,o);if(!Number.isFinite(r)||r<=0)return NaN;const a=Lt(e,i);return s<=O?a*r/Ee(s):s===$?a*r/30.44:a*r/(365.2422*Kn(s))}function oa(t,e,i,n){const o=t.timescaleManager,s=o.getPixelsBetween(e,i);if(!Number.isFinite(s)||s<=0)return o.zoom;const r=bi(t,n),a=o.getZoomChangeByDistance(s,r);if(!Number.isFinite(a))return o.zoom;let l=o.zoom+a;for(let c=0;c<4;c++){const h=ia(o,e,i,l);if(!Number.isFinite(h)||h<=0)break;const u=o.getZoomChangeByDistance(h,r);if(!Number.isFinite(u)||(l+=u,Math.abs(u)<5e-5))break}return Fe(o,l)}function Jn(t,e){return e==null?null:t.getDmyFromInput(ze(e))}function we(t){var o;const e=(o=t.options)==null?void 0:o.bounds;if(!e)return null;let i=Jn(t,e.minDate),n=Jn(t,e.maxDate);return!i&&!n?null:(i&&n&&i.compare(n)>0&&([i,n]=[n,i]),{minDate:i,maxDate:n,minPoint:i?re(i):null,maxPoint:n?re(n):null,minDay:i?Zt(i):null,maxDay:n?Zt(n):null,overflow:e.overflow==="clamp"?"clamp":"elastic"})}function Qn(t){const e=He(t,0),i=He(t,t.getWidth());return Ot(e,i)<=0?{start:e,end:i}:{start:i,end:e}}function sa(t,e,i){const n=t.minPoint?Lt(e.start,t.minPoint):0,o=t.maxPoint?Lt(t.maxPoint,e.end):0;return n>0&&n>=o?{type:"min",dayPoint:t.minPoint,dayNumber:t.minDay,pixelOffset:0,overflowDays:n}:o>0?{type:"max",dayPoint:t.maxPoint,dayNumber:t.maxDay,pixelOffset:i,overflowDays:o}:null}function Be(t,e=we(t),i={}){if(!e)return null;const n=Qn(t),o=t.getWidth(),s=sa(e,n,o);return i.mode==="elastic"&&e.overflow==="elastic"&&s?s:e.minPoint&&e.maxPoint&&Lt(n.start,n.end)>Lt(e.minPoint,e.maxPoint)?{type:"range",zoom:io(t,e.minPoint,e.maxPoint,{left:0,right:0},t.timescaleManager.zoom),dayPoint:e.minPoint,dayNumber:e.minDay,pixelOffset:0}:s}function vi(t,e){const i=At(t);if(!i||!Number.isFinite(e)||e<=0)return 0;const n=Math.max(1,t.getWidth()),o=Math.max(32,n*.22),s=e*i;return o*s/(o+s)/i}function to(t,e){const i=At(t);if(!i||!Number.isFinite(e)||e<=0)return 0;const n=Math.max(1,t.getWidth()),o=Math.max(32,n*.22),s=e*i;return s>=o?Number.MAX_SAFE_INTEGER/i:o*s/(o-s)/i}function ra(t,e,i){const n=we(t);let o=e;if((n==null?void 0:n.overflow)==="elastic"&&Number.isFinite(i)){const s=Tt(e,i);if(n.minPoint&&Ot(e,n.minPoint)<0){const r=Lt(e,n.minPoint);o=Tt(n.minPoint,-vi(t,r))}else if(n.maxPoint&&Ot(s,n.maxPoint)>0){const r=Lt(n.maxPoint,s);o=Tt(n.maxPoint,vi(t,r)-i)}}Vt(t,o,0,!1,{skipDateBounds:!0})}function Et(t,e={}){const i=we(t);if(!i)return!1;const n=e.mode||"clamp",o=Be(t,i,{mode:n});if(!o)return!1;if(o.type==="range")return o.zoom!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(o.zoom),Vt(t,o.dayPoint,o.pixelOffset,!1,{skipDateBounds:!0}),!0;if(n==="elastic"&&i.overflow==="elastic"){const s=vi(t,o.overflowDays);return o.type==="min"?Vt(t,Tt(o.dayPoint,-s),0,!1,{skipDateBounds:!0}):Vt(t,Tt(o.dayPoint,s),o.pixelOffset,!1,{skipDateBounds:!0}),!0}return Vt(t,o.dayPoint,o.pixelOffset,!1,{skipDateBounds:!0}),!0}function aa(t){return!!Be(t)}function At(t){var o;const e=t.timescaleManager,i=e.unitSizeInPixels;if(!Number.isFinite(i)||i<=0)return 0;if(e.unit==null||e.unit<=O)return i/Ee((o=e.unit)!=null?o:O);if(e.unit===$)return i/30.44;const n=Number.isFinite(e.unitLengthInYears)&&e.unitLengthInYears>0?e.unitLengthInYears:1;return i/(365.2422*n)}function Vt(t,e,i,n=!1,o={}){var u;const s=wi(e),r=Math.floor(s.millisecond),a=s.millisecond-r,l=Si(s.dayNumber).addMilliseconds(r),c=a*At(t)/U,h=t.timescaleManager.setStartDate(l);t.repositionWindow=h-c,i&&t.updateFromByPixels(-i,{skipDateBounds:!0}),o.skipDateBounds||Et(t,{mode:o.boundsMode||"clamp"}),t.requestRedraw(),(u=t._markTimelineStateChanged)==null||u.call(t),n&&t._emitTimelineStateChange()}function eo(t,e,i,n=!1,o={}){Vt(t,re(e),i,n,o)}function la(t,e){const i=At(t),n=re(e.date);return i?Tt(n,e.fraction/i):n}function He(t,e){return la(t,t.getPivotPoint(e))}function Zt(t){return t.getDaysSinceYearZero()+t.getMillisecondsOfDay()/U}function Si(t){const e=Math.floor(t);let i=Math.floor(e/365.2422),n=Zt(new y(i,1,1)),o=Zt(ye(i));for(;n>e;)i-=1,n=Zt(new y(i,1,1)),o=Zt(ye(i));for(;o<=e;)i=i===-1?1:i+1,n=o,o=Zt(ye(i));return y.getByDayOfYear(i,e-n+1)}function ca(t,e,i){return t+(e-t)*i}function io(t,e,i,n,o){if(Ot(i,e)<=0)return o;const s=t.timescaleManager,r=Lt(e,i)*At(t);if(!Number.isFinite(r)||r<=0)return o;const a=bi(t,n),l=s.getZoomChangeByDistance(r,a);if(!Number.isFinite(l))return o;let c=s.zoom+l;for(let h=0;h<4;h++){const u=na(s,e,i,c);if(!Number.isFinite(u)||u<=0)break;const m=s.getZoomChangeByDistance(u,a);if(!Number.isFinite(m)||(c+=m,Math.abs(m)<5e-5))break}return Fe(s,c)}function ha(t){var e,i,n,o,s;typeof t.stopPanAnimation=="function"?t.stopPanAnimation():(t.isPanning&&((i=(e=t.animation)==null?void 0:e.pan)!=null&&i.stop)&&t.animation.pan.stop(),t.isPanning=!1),typeof t.stopZoomAnimation=="function"?t.stopZoomAnimation():((o=(n=t.animation)==null?void 0:n.zoom)!=null&&o.stop&&t.animation.zoom.stop(),((s=t.animation)==null?void 0:s.wheelZoomFrame)!=null&&cancelAnimationFrame(t.animation.wheelZoomFrame),t.animation&&(t.animation.zoom=null,t.animation.wheelZoomTarget=null,t.animation.wheelZoomPivotPoint=null,t.animation.wheelZoomPivotPixel=null,t.animation.wheelZoomLastFrameTime=null,t.animation.wheelZoomFrame=null))}function ua(t,e,i,n,o,s={}){var g;ha(t),t.switchToPositiveRepositionWindow(),t.isPanning=!0,t.startAnimation();const r=t.timescaleManager.zoom,a=bi(t,o),l=He(t,o.left),c=He(t,o.left+a),h=re(e),u=re(i),m=Ot(c,l)>0&&Ot(u,h)>0,d=Y({from:0,to:1,duration:(g=s.duration)!=null?g:2e3,easing:H[s.easing]||H.swing,onUpdate(p){if(t.isPinching){t.isPanning=!1,d.stop();return}const w=jn(l,h,p);let b=r;p>0&&(b=m?io(t,w,jn(c,u,p),o,t.timescaleManager.zoom):ca(r,n,p)),b!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(b),Vt(t,w,o.left)},onComplete(){n!==t.timescaleManager.zoom&&t.timescaleManager.setZoom(n),eo(t,e,o.left,!0),t.isPanning=!1}});t.animation.pan=d}function da(t,e){var a,l,c,h;const i=t.articles||[];let n=null,o=null,s=0,r=0;for(let u=0;u<i.length;u++){const m=i[u];if(!e(m)||!((a=m.period)!=null&&a.from))continue;const d=m.period.from;(!n||d.compare(n)<0)&&(n=d),(!o||d.compare(o)>0)&&(o=d);const g=m.getCurrentStyle(),p=(c=(l=g.connectorLine)==null?void 0:l.offsetX)!=null?c:0,w=(h=g.width)!=null?h:0;s=Math.max(s,p),r=Math.max(r,w-p)}return n?{earliest:n,latest:o,maxCardLeftOffset:s,maxCardRightOffset:r}:null}f.prototype._drawBranding=function(t){this._drawCopyrightLinks(t)};const Ye=117,Li=22,no=0,oo=0,We=8,_i=0,ae=12,fa="HistropediaJS",so=75,ma="Terms",ga=33,pa=10,ya=`${fa} | ${ma}`;f.prototype._drawCopyrightLinks=function(t){t.beginPath(),t.fillStyle="rgba(255, 255, 255, 0.8)",t.fillRect(this.width-Ye-no-We*2,this.top-Math.floor(this.options.style.mainLine.size/2)-Li-oo-_i*2,Ye+We*2,Li+_i*2),t.textAlign="left",t.textBaseline="middle",t.fillStyle="#000000",t.font=`normal ${ae}px "Helvetica Neue", Helvetica, Arial, sans-serif`;const e=this._getBrandingTextCoords();t.fillText(ya,e.left,e.top,Ye+We)},f.prototype._getBrandingTextCoords=function(){return{left:this.width-Ye-no-We,top:this.top-Math.floor(this.options.style.mainLine.size/2)-Li-oo+ae-_i}},f.prototype._isInsideHistropediaJSLink=function(t){const e=this._getBrandingTextCoords();return ro(t,{left:e.left,top:e.top-ae/2,width:so,height:ae})},f.prototype._isInsideTermsLink=function(t){const e=this._getBrandingTextCoords();return ro(t,{left:e.left+so+pa,top:e.top-ae/2,width:ga,height:ae})};function wa(){const t=window.open("https://js.histropedia.com","_blank","noopener,noreferrer");t&&(t.opener=null)}function ba(){const t=window.open("https://js.histropedia.com/licence.html","_blank","noopener,noreferrer");t&&(t.opener=null)}function ro(t,e){return t.left>=e.left&&t.left<=e.left+e.width&&t.top>=e.top&&t.top<=e.top+e.height}const Ai=({startToken:t,offsetX:e=0,dx:i=0,totalDx:n=0}={})=>({startToken:t,offsetX:e,dx:i,totalDx:n}),Ii=({centre:t=null,scale:e=0,zoom:i=0,distance:n=0,zoomDelta:o=0,dx:s=0,totalZoomDelta:r=0,pointers:a=[]}={})=>({centre:t,scale:e,zoom:i,distance:n,zoomDelta:o,dx:s,totalZoomDelta:r,pointers:a}),va=({centre:t=null,zoom:e=0,zoomDelta:i=0}={})=>({centre:t,zoom:e,zoomDelta:i}),Sa=({viewport:t}={})=>{var n,o;if(!t)return{viewport:{x:0,y:0}};const{x:e=(n=t.left)!=null?n:0,y:i=(o=t.top)!=null?o:0}=t;return{viewport:{x:e,y:i}}},ao=100,La=.01,_a=.005,Aa=.004,Ia=1200;function le(t,e){return Number.isFinite(t)&&t>0?t:e}function Ma(t,e){if(!(t!=null&&t.canvas))return!1;const i=t.canvas.ownerDocument;if(!i||typeof i.elementFromPoint!="function")return!0;const{x:n,y:o}=ne(e),s=i.elementFromPoint(n,o);if(!s)return!1;const r=t._laneViewportElement||t.canvas;return r===s||r.contains(s)}f.prototype.enableDragging=function(){const e=this,i={relativePos:null,isDoubleClick:!1,isArticleClick:!1,isArticleDoubleClick:!1,isTermsClick:!1,isHjsClick:!1,article:null,lastClick:{time:0,targetType:null,articleId:null,relativePos:null}},n={initial:{distance:0,zoom:0},centre:{},scale:1,prevActualZoom:0},o=2,s=5,r=500;function a(b,v,S=o){return Math.abs(b.left-v.left)<=S&&Math.abs(b.top-v.top)<=S}function l(b){const v=Hr(e.canvas);return{x:b.x-v.left,y:b.y-v.top}}function c(){i.relativePos=null,i.isDoubleClick=!1,i.isArticleClick=!1,i.isArticleDoubleClick=!1,i.isTermsClick=!1,i.isHjsClick=!1,i.article=null}function h(){i.lastClick.time=0,i.lastClick.targetType=null,i.lastClick.articleId=null,i.lastClick.relativePos=null}function u(){return i.isHjsClick?"branding-hjs":i.isTermsClick?"branding-terms":i.isArticleClick&&i.article?"article":"timeline"}function m(b,v){const{lastClick:S}=i,M=u();return!S.time||b-S.time>=r||S.targetType!==M?!1:M==="article"?!!i.article&&S.articleId===i.article.id:M==="timeline"?!!S.relativePos&&a(S.relativePos,v,s):!1}function d(b){i.lastClick.time=Date.now(),i.lastClick.targetType=u(),i.lastClick.articleId=i.article?i.article.id:null,i.lastClick.relativePos=b?W({},b):null}function g(b,v){if(Yr(),v.list.length>=2){c(),h(),e.isPinching||(n.centre=l(Vn(v)),n.initial.distance=Zn(v),n.initial.zoom=e.timescaleManager.zoom,e.isPinching=!0,n.prevActualZoom=n.initial.zoom,e.startAnimation(),e.trigger("zoom-pinch-start",Ii({centre:n.centre,scale:1,distance:n.initial.distance,zoom:n.initial.zoom,zoomDelta:0,totalZoomDelta:0,pointers:[...v.list]}),b));return}c();const S=i.relativePos=e.getRelativePosition(b);e.options.disableBranding||(i.isHjsClick=e._isInsideHistropediaJSLink(S),i.isTermsClick=e._isInsideTermsLink(S));let M=!1;if(!(i.isHjsClick||i.isTermsClick))for(let E=e.articles.length-1;E>=0;E--){const x=e.articles[E];if(x.isVisible&&x.isInside(S)){i.isArticleClick=!0,i.article=x,x.isActive&&e.options.article.draggable&&(M=!0);break}}const P=Date.now();if(i.isDoubleClick=m(P,S),i.isArticleDoubleClick=i.isArticleClick&&i.isDoubleClick,M){e.draggingArticle=i.article,i.article.startDragging(S,b);return}e.draggingArticle===null&&e.isInVicinity(b,e.options.draggingVicinity,S)&&e.startDragging(b)}function p(b,v){if(e.isPinching){const S=e.timescaleManager.zoomOptions.ratio,M=n.centre.x;n.centre=l(Vn(v));const P=Zn(v);n.scale=P/n.initial.distance;const E=Math.log(n.scale)/Math.log(S),x=n.initial.zoom+E,Z=M-n.centre.x;e.setZoomByPivotPixel(x,n.centre.x,Z);const R=e.timescaleManager.zoom,V=R-n.initial.zoom,B=R-n.prevActualZoom;n.prevActualZoom=R,e.trigger("zoom-pinch",Ii({centre:n.centre,scale:n.scale,distance:P,zoom:R,pointers:[...v.list],dx:Z,zoomDelta:B,totalZoomDelta:V}),b)}else if(e.isDragging)e.doDrag(b);else if(e.draggingArticle!==null){const S=e.getRelativePosition(b);e.draggingArticle.dragging(S,b)}else b.pointerType==="mouse"&&(e.updateMouseoverArticle(b),e.mouseoverArticle!==null&&e.trigger("article-pointermove",e.mouseoverArticle,b));e.options.enableCursor&&e.updateCursor(b)}function w(b,v){var x,Z,R;if(e.isPinching&&v.list.length<2){const V=v.list.length===1?Zr(v):null,B=n.scale||1,z=e.timescaleManager.zoom,it=z-n.initial.zoom,kt=z,ut=(n.initial.distance||0)*B;e.isPinching=!1,c(),e.trigger("zoom-pinch-end",Ii({centre:n.centre,scale:B,distance:ut,zoom:kt,zoomDelta:0,dx:0,totalZoomDelta:it,pointers:[...v.list]}),b),V?e.isDragging&&e.resetDragTracking(V):e.isDragging?(e.resetDragTracking(ne(b)),e.endDragging(b)):((x=e.settleDateBounds)==null||x.call(e),e.isPanning||(Z=e._flushTimelineStateChange)==null||Z.call(e));return}const S=e.getRelativePosition(b),M=b.type==="pointercancel"||b.type==="touchcancel";let P=!1;if(!M&&i.relativePos&&a(i.relativePos,S)){if(i.isHjsClick)wa();else if(i.isTermsClick)ba();else if(i.isArticleClick)e.select(i.article.id),i.article.clicked(i.relativePos),e.options.enableCursor&&(e.canvas.style.cursor=i.article.getCursor(S)),e.trigger("article-click",i.article,b),i.isArticleDoubleClick&&e.trigger("article-dblclick",i.article,b);else{const{left:V=0,top:B=0}=i.relativePos||{},z=Sa({viewport:{x:V,y:B}});e.trigger("timeline-click",z,b),i.isDoubleClick&&e.trigger("timeline-dblclick",z,b)}P=!0}P?d(i.relativePos):i.relativePos&&h(),c();const E=e.draggingArticle;E!==null?(E.stopDragging(b),e.draggingArticle=null,(R=e._flushTimelineStateChange)==null||R.call(e)):e.isDragging&&e.endDragging(b),e.redraw()}this._dragPointerTracker=new Vr(this.canvas,{onStart:g,onMove:p,onEnd:w})},f.prototype.startDragging=function(e){var n,o;(n=this.stopPanAnimation)==null||n.call(this),(o=this.stopZoomAnimation)==null||o.call(this),this.isDragging=!0;const i=ne(e);f.prototype.resetDragTracking.call(this,i),this.trigger("viewport-drag-start",Ai({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow}),e)},f.prototype.resetDragTracking=function(e){this.dragOrigin={left:e.x,top:e.y},this.dragStartX=e.x,this.dragStartY=e.y,this.dragMomentumSamples=[{time:Date.now(),x:e.x}],this.dragDateBoundsState=null;const i=we(this);if((i==null?void 0:i.overflow)==="elastic"){const n=At(this);if(!n)return;const o=Qn(this),s=Lt(o.start,o.end);let r=o.start;if(i.minPoint&&Ot(o.start,i.minPoint)<0){const a=Lt(o.start,i.minPoint);r=Tt(i.minPoint,-to(this,a))}else if(i.maxPoint&&Ot(o.end,i.maxPoint)>0){const a=Lt(i.maxPoint,o.end);r=Tt(i.maxPoint,to(this,a)-s)}this.dragDateBoundsState={leftDayPoint:r,pixelsPerDay:n,viewportSpanDays:s}}},f.prototype.endDragging=function(e){var o,s,r;this.isDragging=!1;const i=ne(e),n=this.dragOrigin.left-i.x;if(this.trackDragMomentumSample(i.x),this.trigger("viewport-drag-end",Ai({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow,totalDx:n}),e),(o=this.settleDateBounds)!=null&&o.call(this)){this.dragDateBoundsState=null,this.isPanning||(s=this._flushTimelineStateChange)==null||s.call(this);return}this.dragDateBoundsState=null,this.startDragMomentum(),this.isPanning||(r=this._flushTimelineStateChange)==null||r.call(this)},f.prototype.doDrag=function(e){var r;this.isPanning&&((r=this.stopPanAnimation)==null||r.call(this));const i=ne(e),n=this.dragStartX-i.x,o=this.dragOrigin.left-i.x,s=Math.abs(o);if(this.dragStartX=i.x,this.trackDragMomentumSample(i.x),this.isAnimating||this.startAnimation(),s>30&&(this.animation.dragRedrawFunction=this.defaultRedraw),this.dragDateBoundsState){const a=Tt(this.dragDateBoundsState.leftDayPoint,o/this.dragDateBoundsState.pixelsPerDay);ra(this,a,this.dragDateBoundsState.viewportSpanDays)}else this.updateFromByPixels(n);this.trigger("viewport-drag",Ai({startToken:this.timescaleManager.startToken,offsetX:this.repositionWindow,dx:n,totalDx:o}),e)},f.prototype.trackDragMomentumSample=function(e){var a;const i=Date.now(),n=((a=this.options.pan)==null?void 0:a.momentum)||{},o=le(n.sampleWindow,ao),s=this.dragMomentumSamples||[],r=i-o;for(;s.length>0&&s[0].time<r;)s.shift();s.push({time:i,x:e}),this.dragMomentumSamples=s},f.prototype.startDragMomentum=function(){var p,w,b;const e=((p=this.options.pan)==null?void 0:p.momentum)||{};if(e.active!==!0){this.dragMomentumSamples=[];return}const i=le(e.sampleWindow,ao),n=Date.now()-i,o=(this.dragMomentumSamples||[]).filter(v=>v.time>=n);if(this.dragMomentumSamples=[],o.length<2||this.isPinching||this.draggingArticle!==null)return;const s=o[0],r=o[o.length-1],a=r.time-s.time;if(a<=0)return;const l=(s.x-r.x)/a,c=le(e.minVelocity,La);if(Math.abs(l)<c)return;this.isPanning&&((w=this.animation.pan)!=null&&w.stop)&&this.animation.pan.stop(),(b=this.stopZoomAnimation)==null||b.call(this);const h=le(e.friction,Aa),u=le(e.stopVelocity,_a),m=le(e.maxDuration,Ia);if(!Number.isFinite(l)||!Number.isFinite(h))return;this.isPanning=!0,this.startAnimation();const d=this,g=Qr({velocity:l,friction:h,minVelocity:u,maxDuration:m,shouldStop(){return d.isDragging||d.isPinching?(d.isPanning=!1,!0):!1},onUpdate(v){var S;d.updateFromByPixels(v),d.requestRedraw(),aa(d)&&(d.isPanning=!1,d.animation.pan===g&&(d.animation.pan=null),g.stop(),(S=d.settleDateBounds)==null||S.call(d))},onComplete(){var v;d.isPanning=!1,d.animation.pan===g&&(d.animation.pan=null),(v=d.settleDateBounds)==null||v.call(d)}});this.animation.pan=g},f.prototype.updateFromByPixels=function(t,e={}){var o;this.repositionWindow-=t;let i=this.timescaleManager.startToken,n=this.timescaleManager.getPrevious(i);for(;this.repositionWindow>=n.length;)this.repositionWindow-=n.length,i=n,n=this.timescaleManager.getPrevious(i);for(;-this.repositionWindow>=i.length;)this.repositionWindow+=i.length,i=this.timescaleManager.getNext(i);this.timescaleManager.setStartToken(i),(o=this._markTimelineStateChanged)==null||o.call(this),!(e.skipDateBounds||!we(this))&&Et(this,{mode:this.isDragging||this.isPinching?"elastic":"clamp"})},f.prototype.updateMouseoverArticle=function(t,e=this.articles){const i=this.mouseoverArticle;let n=null;if(Ma(this,t)){const o=this.getRelativePosition(t);for(let s=e.length-1;s>=0;s--){const r=e[s];if(r.isVisible&&r.isInside(o)){n=r;break}}}this.mouseoverArticle=n,i!==n&&(i!==null&&i.pointerLeave(t),n!==null&&n.pointerEnter(t),this.requestRedraw(this.redraw))},f.prototype.load=function(t){this.addArticles(t),this.updateCurrentDensitySetting(),this.updateArticlesGroupIndex(),this.requestRedraw()},f.prototype.addArticles=function(t,e,i){if(t.length===0){i&&i.call(this);return}const n=this.articles.map(function(s){return s.id}),o=[];for(let s=0;s<t.length;s++){const r=t[s];n.indexOf(_(r,"id"))===-1&&(o.push(r),this._createImplicitLane(this._resolveLaneIdFromArticleData(r)))}this._updateLaneLayout();for(let s=0;s<o.length;s++){const r=new I(this,_(o[s],"id"));this.articles.push(r),r.setupByReceivedData(o[s]),r.registerPosition(this.getOriginalPosition(r))}this._refreshLaneOrder(),this.updateIsActiveStatus(),i&&i.call(this)},f.prototype.getDmyFromInput=function(t){var i,n,o;let e;if(typeof t=="string"){if(e=y.fromString(t),!Number.isFinite(e.year))throw new Error(`Invalid Histropedia date string: ${t}`)}else t instanceof y?e=new y(t):e=new y({precision:t.precision,year:t.year,month:(i=t.month)!=null?i:1,day:(n=t.day)!=null?n:1,hour:t.hour,minute:t.minute,second:t.second,millisecond:t.millisecond});return(o=this.options)!=null&&o.shiftBceDates&&e.year<0&&(e.year+=1),e},f.prototype.getActiveArticle=function(){for(let t=this.articles.length-1;t>=0;t--)if(this.articles[t].isActive)return this.articles[t];return null},f.prototype.getArticleById=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];if(i.id===t)return i}},f.prototype.bringFront=function(t){const e=lo(this.articles,t);e>=0&&br(this.articles,e,this.articles.length-1)},f.prototype.select=function(t){this.bringFront(t);const e=this.getActiveArticle();this.updateIsActiveStatus();const i=this.getActiveArticle();i!==e&&i&&this.trigger("article-select",i),this._emitTimelineStateChange()},f.prototype.activated=function(t){this.select(t.id)},f.prototype.updateIsActiveStatus=function(){for(let t=0;t<this.articles.length;t++)this.articles[t].isActive=!1;for(let t=this.articles.length-1;t>=0;t--)if(this.articles[t].isDataLoaded){this.articles[t].isActive=!0;return}},f.prototype.getVisibleArticlesClone=function(){const t=[];for(let e=0;e<this.articles.length;e++){const i=this.articles[e];i.isVisible&&i.isDataLoaded&&t.push(i)}return t},f.prototype.hasArticle=function(t){let e;for(let i=0;i<this.articles.length;i++)this.articles[i].id===t&&(e=this.articles[i]);return!De(e)},f.prototype.reposition=function(t,e){if(t.isDragging)return;const i=this.getOriginalPosition(t,e);t.registeredPosition=i;const n=t.finalOffset;if(!this.options.article.animation.move.active){t.position={left:i.left+n.left,top:i.top+n.top},t.offset={left:n.left,top:n.top};return}t.moveAnimation.finalOffset.top!==n.top||t.moveAnimation.finalOffset.left!==n.left?t.moveToOffsetWithAnim(n,!0):t.position={left:i.left+t.offset.left,top:i.top+t.offset.top}},f.prototype.getOriginalPosition=function(t,e){let i=this.getPixel(t.period.from,e);if(this.options.article.collectOngoing){const s=this.getPixel(t.period.to,e),r=isNaN(i)||i<0,a=isNaN(s)||s>0;r&&a&&(i=0)}const n=t.getCurrentStyle(),o=this.getLaneById(t.laneId);return this._isLaneLayoutActive()&&o&&o.geometry?{left:i-n.connectorLine.offsetX,top:o.geometry.bodyContentBottom-this._getLaneDistanceToBaseline(o)}:{left:i-n.connectorLine.offsetX,top:this.top-this._getTimelineDistanceToBaseline()}},f.prototype.reorderArticles=function(t){const e=[];for(let o=0;o<t.length;o++){const s=lo(this.articles,t[o]);e.push(this.articles[s])}const i=this.getActiveArticle();this.articles=e,this.updateIsActiveStatus();const n=this.getActiveArticle();n!==i&&n&&this.trigger("article-select",n)},f.prototype.getSortedByYearClone=function(){},f.prototype.removeArticleById=function(t){for(let e=0;e<this.articles.length;e++){const i=this.articles[e];if(i.id===t){if(typeof i._imageCancel=="function")try{i._imageCancel()}catch(n){}if(typeof i._closeImage=="function")try{i._closeImage({skipRedraw:!0})}catch(n){}i._pendingImageKey=null,this.articles.splice(e,1),this._emitTimelineStateChange();break}}},f.prototype.deleteCurrentArticle=function(){if(this.articles.length!==0){this.removeById(this.articles,this.getActiveArticle().id),this.requestRedraw();for(let t=this.articles.length-1;t>=0;t--){const e=this.articles[t];if(e.isVisible){this.select(e.id),this.requestRedraw();return}}}},f.prototype.pp=function(t){let e="";for(let i=0;i<this.articles.length;i++)e+=`${this.articles[i].title.split(" ")[0]},`;t=t||"",T.log(`${t}:${e}`)};function lo(t,e){return t.findIndex(i=>i.id===e)}Dt.prototype.draw=function(t,e){t.globalAlpha=1;const i=e.left,n=e.right,o=e.top,s=e.height,r=Math.max(0,n-i);if(r<=0)return;const a=this.style||{};t.fillStyle=a.backgroundColor||"rgba(200,200,200,0.25)",t.fillRect(i,o,r,s);const l=a.border||null;l&&l.width&&(t.lineWidth=l.width,t.strokeStyle=l.color||"rgba(120,120,120,0.6)",t.strokeRect(i+.5,o+.5,r-1,s-1));const c=a.text||{},h=c.margin||6,u=Math.max(0,r-h*2);if(u>2){t.font=c.font||"500 12px Calibri",t.textAlign=c.align||"center",t.textBaseline=c.baseline||"middle",t.fillStyle=c.color||"#222";const m=this.title||"",d=t.measureText(m).width;let g=m;if(d>u){const v=t.measureText.bind(t);let S=0,M=m.length,P=0;const x=v("…").width,Z=Math.max(0,u-x);for(;S<=M;){const R=Math.floor((S+M)/2),V=m.substring(0,R);v(V).width<=Z?(P=R,S=R+1):M=R-1}g=P>0?`${m.substring(0,P)}…`:""}const p=c.align==="left"?i+h:c.align==="right"?n-h:Math.floor((i+n)/2);let w;switch(c.verticalAlign||"middle"){case"top":w=o+(c.margin||0);break;case"bottom":w=o+s-(c.margin||0);break;default:w=o+Math.floor(s/2);break}w+=c.offsetY||0,t.fillText(g,p,w)}};function co(t){t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor="transparent black"}function ho(t,e,i,n,o,s){t.moveTo(e+s,i),t.lineTo(e+n-s,i),s>0&&t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+o),t.lineTo(e,i+o),t.lineTo(e,i+s),s>0&&t.quadraticCurveTo(e,i,e+s,i),s===0&&t.closePath()}function Ve(t,e,i,n,o,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.arcTo(e+n,i,e+n,i+s,s),t.lineTo(e+n,i+o-s),t.arcTo(e+n,i+o,e+n-s,i+o,s),t.lineTo(e+s,i+o),t.arcTo(e,i+o,e,i+o-s,s),t.lineTo(e,i+s),t.arcTo(e,i,e+s,i,s),t.closePath()}function uo(t,e,i,n,o,s,r,a){t.beginPath();const l=Math.PI/n;for(let c=0;c<2*n;c++){const h=(c&1)===0?s:o,u=e+Math.cos(1+c*l)*h,m=i+Math.sin(1+c*l)*h;c===0?t.moveTo(u,m):t.lineTo(u,m)}t.closePath(),t.lineWidth=1,t.strokeStyle=a,t.fillStyle=r,t.stroke(),t.fill()}function fo(t,e,i,n,o){let s;switch(i){case"left":s=t+n;break;case"center":s=t+e/2;break;case"right":s=t+e-n;break;default:s=t+n}return typeof o=="function"?o(s):i==="center"?t+Math.floor(e/2):s}function mo(t,e,i,n,o,s,r,a,l){const c=l/2;t.save(),t.beginPath(),t.arc(r+c,a+c,c,0,Math.PI*2,!1),t.closePath(),t.clip(),t.drawImage(e,i,n,o,s,r,a,l,l),t.restore()}function Ze(t,e,i){const n=t.split(" "),o=[];let s=n[0];for(let r=1;r<n.length;r++){const a=n[r];e.measureText(`${s} ${a}`).width<i?s+=` ${a}`:(o.push(s),s=a)}return o.push(s),o}function Mi(t,e,i,n="…"){if(!t||typeof t.measureText!="function")throw new Error("Invalid canvas context provided");if(typeof e!="string"||e===""||typeof i!="number"||i<=0)return"";if(typeof n!="string"&&(n="…"),t.measureText(e).width<=i)return e;const s=t.measureText(n).width;if(s>=i)return"";const r=i-s;if(r<=0)return"";let a=0,l=e.length,c=0;for(;a<=l;){const h=Math.floor((a+l)/2),u=e.substring(0,h);t.measureText(u).width<=r?(c=h,a=h+1):l=h-1}return c===0?"":e.substring(0,c)+n}function Ue(t,e,i=null,n=null){if(!Array.isArray(t)||t.length===0)return t;if(typeof e!="number"||e<=0)return[];const o=t.length>e,s=o?t.slice(0,e):[...t];if(s.length>0){const r=s.length-1,a=s[r];if(i&&typeof n=="number"&&n>0)if(o){const l=Mi(i,a,n);s[r]=l,l===a&&(s[r]=Mi(i,`${a}…`,n,"…"))}else s[r]=Mi(i,a,n);else o&&(s[r]+="...")}return s}const go={up:0,down:0};function Ci(t,e={}){const{anchorY:i=0,canvasHeight:n=0,fallbackArea:o=go}=e,s=Number.isFinite(i)?i:0,r=Number.isFinite(n)?n:0,a=typeof(o==null?void 0:o.up)=="number"&&Number.isFinite(o.up)?Math.max(0,o.up):0,l=typeof(o==null?void 0:o.down)=="number"&&Number.isFinite(o.down)?Math.max(0,o.down):0,c=t||o||go,h=!!t,u=typeof c.up=="undefined"?h?0:a:c.up,m=typeof c.down=="undefined"?h?0:l:c.down,d=(w,b)=>{if(typeof b=="number")return Number.isFinite(b)?Math.max(0,b):0;const v=typeof b=="object"&&b!==null&&b.value==="edge";if(b==="edge"||v){const S=v?b.padding:0,M=typeof S=="number"&&Number.isFinite(S)?Math.max(0,S):0,P=w==="up"?Math.max(0,s):Math.max(0,r-s);return Math.max(0,P-M)}return 0},g=d("up",u),p=d("down",m);return{up:g,down:p,height:g+p}}const po=150;f.prototype.defaultRedraw=function(){this.redraw({onArticlesInRangeIsReady:function(e){this.updateVisibleArticlesOfGroups(e),this.forInRangeArticles(function(n){this.reposition(n,e)}),this.stack(e)},onArticlesVisiblityIsReady:function(e){this.updateArticleLines()}})},f.prototype.repositionRedraw=function(){this.redraw({onArticlesInRangeIsReady:function(e){this.updateVisibleArticlesOfGroups(e),this.forInRangeArticles(function(n){this.reposition(n,e)})},onArticlesVisiblityIsReady:function(e){this.updateArticleLines()}})},f.prototype.redraw=function(t){if(this.redrawInProgress)return;this.redrawInProgress=!0;const e=this.topRow;t=t||{};const i=this.canvasContext,n=this.getWidth(),o=this.top;this.trigger("timeline-render-start",{canvasContext:i,top:o});const s={},r=this.getTokensAndMarkers(n),a=r.markers,l=r.tokens;s.tokens=l,s.markers=a,this._updateLaneLayout(),this._refreshAdaptiveArticleRuntimeOptions(),this._syncLaneDom(),this.invoke("onMainRangeIsReady",t,s),this.forLoadedArticles(function(h){h.isInView=h.overlapsInclusiveWithDates(s.tokens.start,s.tokens.end),gi(this.options.article.autoStacking.range)?h.isInRange=h.isInView:h.isInRange=!0,h.isVisibleInLane=this._isArticleLaneVisible(h),h.isInRange&&(h.isHiddenByFilter=h.hiddenByFilter)}),this.invoke("onArticlesInRangeIsReady",t,s),this.forLoadedArticles(function(h){h.updateVisibility()}),this.forVisibleArticles(function(h){this.enqueueImageLoad(h)}),this.invoke("onArticlesVisiblityIsReady",t,s),this.forInRangeArticles(function(h){h.indicator={fromX:Math.max(-3,Math.round(this.getPixel(h.period.from,s))),toX:Math.min(this.options.width,Math.round(this.getPixel(h.period.to,s)))},h.indicator.toX-h.indicator.fromX<2&&(h.indicator.toX=h.indicator.fromX+2)}),!this._isLaneLayoutActive()&&this.options.article.autoStacking.fitToHeight&&e!==this.topRow&&this.fitToHeight(!0),this.render(i,o,n,a,s),this.redrawInProgress=!1,this.trigger("timeline-render-end",{canvasContext:i,drawCycleContext:s,top:o})},f.prototype.render=function(t,e,i,n,o){const s=this._getEffectiveVerticalOffset?this._getEffectiveVerticalOffset():this.options.verticalOffset;this.owner||t.clearRect(0,0,i,this.top+s),this.drawTimeBands(t,e,i,o),typeof this.drawCharts=="function"&&this.drawCharts(t,e,i,o),this.drawDraggingHighlight(t,e,i);const r=this.options.style.mainLine.position==="top"?-s:e;this.drawMainline(t,r,i,n),this.drawDateIndicators(t,r),t.globalAlpha=1;for(let l=0;l<this.articles.length;l++){const c=this.articles[l];c.isDataLoaded&&c.isVisible&&!c.isActive&&c.drawPeriodLinesAndConnectors(t,e)}for(let l=0;l<this.articles.length;l++){const c=this.articles[l];c.isDataLoaded&&c.isVisible&&!c.isActive&&c.draw(t)}const a=this.getActiveArticle();a&&a.isVisible&&(a.drawPeriodLinesAndConnectors(t,e),a.draw(t)),this.options.disableBranding||(t.globalAlpha=1,this._drawBranding(t)),this.drawDebugOverlays(t,i,o)},f.prototype.drawDebugOverlays=function(t,e,i){var n;(n=this.options.debugOverlays)!=null&&n.densityRegions&&this.drawDensityRegionBoundaries(t,e,i)};function Ca(t,e,i,n){var o,s,r;return i!=="article"?i:n?((o=e.activeStyle)==null?void 0:o.color)||((s=e.style)==null?void 0:s.color)||t.options.article.defaultStyle.color:((r=e.style)==null?void 0:r.color)||t.options.article.defaultStyle.color}f.prototype.drawDateIndicators=function(t,e){const i=this.options.style.mainLine.dateIndicators;if(!i.visible)return;const n=this.options.style.mainLine.size,o=n/2;t.save(),t.globalAlpha=1,this.forInRangeArticles(function(r){var p;if(r.isHiddenByFilter||!r.isInView)return;const a=r.isActive===!0,l=!a&&r.isVisibleInLane!==!1&&r.isVisibleInGroup===!1,c=a?i.activeStyle:l?i.hiddenStyle:null,h=c?W(W({},i),c):i,u=h.size,m=u/2,d=r.indicator.fromX,g=a&&(c==null?void 0:c.color)==="article";if(t.globalAlpha=(p=h.opacity)!=null?p:1,t.fillStyle=Ca(this,r,h.color,g),h.shape==="circle"){t.beginPath(),t.arc(d,e,m,0,Math.PI*2),t.fill();return}t.fillRect(d-m,e-o,u,n)}),t.restore()},f.prototype.getDensityRegionBoundaryDate=function(t){if(oe(t))return Si(t.day);const e=this.currentDensitySetting.step;if(this.timescaleManager.unit>=$&&e.months!==0){const c=t*e.months,h=Math.floor(c/12),u=c-h*12+1;return new y(h,u,1)}const i=e.days===0?e.months*30:e.days,n=t*i;let o=Math.floor((n-1)/372);const s=n-o*372;let r=Math.floor((s-1)/31)+1;const a=(s-1)%31+1,l=new y(o,r,a);return l.day!==a?(r++,r>12&&(r=1,o++),new y(o,r,1)):l},f.prototype.getDensityRegionBoundaryPoint=function(t){if(oe(t)){const e=Gr(t);return{date:Si(e.dayNumber),dayFraction:e.dayFraction}}return{date:this.getDensityRegionBoundaryDate(t),dayFraction:0}},f.prototype.drawDensityRegionBoundaries=function(t,e,i){var h;const n=i==null?void 0:i.tokens;if(!(n!=null&&n.start)||!(n!=null&&n.end)||!((h=this.currentDensitySetting)!=null&&h.step))return;const o=St(this.calculateGroupIndex(n.start),-1),s=St(this.calculateGroupIndex(n.end),1),r=this.timescaleManager.startToken.value,a=At(this),l=this.options.height;let c=null;t.save(),t.beginPath(),t.globalAlpha=1,t.lineWidth=1,t.strokeStyle="rgba(204, 0, 153, 0.8)",t.setLineDash([4,4]);for(let u=o;se(u,s)<=0;u=St(u,1)){const m=this.getDensityRegionBoundaryPoint(u),d=this.timescaleManager.getPixelsBetween(r,m.date)+m.dayFraction*a+this.repositionWindow,g=Math.round(d)+.5;g<0||g>e||g===c||(t.moveTo(g,0),t.lineTo(g,l),c=g)}t.stroke(),t.restore()},f.prototype.drawMainline=function(t,e,i,n){if(this.options.style.mainLine.visible){t.globalAlpha=1;const o=this.options.style.mainLine.size>>1,s=this.options.style.mainLine.color;let r=typeof s=="string"?s:On;(s==null?void 0:s.type)==="gradient"&&typeof s.topColor=="string"&&typeof s.bottomColor=="string"&&(r=t.createLinearGradient(0,e-o,0,e+o),r.addColorStop(0,s.topColor),r.addColorStop(1,s.bottomColor)),t.beginPath(),t.lineWidth=this.options.style.mainLine.size,t.strokeStyle=t.fillStyle=r,t.moveTo(0,e),t.lineTo(i,e),t.stroke();for(const a in n)this.drawMarkersAndLabels(t,n[a],a,e+o,{minorTokens:n[k],viewportWidth:i});this.drawParentDateLabels(t,e+o,i)}},f.prototype.drawDraggingHighlight=function(t,e,i){if(!this.isDragging)return;const n=this.options.style.draggingHighlight||{};if(!n.visible)return;t.fillStyle=n.color;const o=this.top,s=this.options.height,r={up:0,down:60},{up:a,height:l}=Ci(n.area,{anchorY:o,canvasHeight:s,fallbackArea:r});l<=0||t.fillRect(0,o-a,i,l)},f.prototype.drawTimeBands=function(t,e,i,n){const o=this.options.timeBand||{};if(!o.visible||!this.timeBands||this.timeBands.length===0)return;const s=n||{tokens:this.getTokensAndMarkers(i).tokens},r=this._getVisibleTimeBands(s);if(r.length===0)return;const a=this.top,l=this.options.height,c={up:0,down:40},{up:h,height:u}=Ci(o.area,{anchorY:a,canvasHeight:l,fallbackArea:c});if(u<=0)return;const m=a-h;t.save();for(let d=0;d<r.length;d++){const g=r[d];let p=Math.round(this.getPixel(g.period.from,s)),w=Math.round(this.getPixel(g.period.to,s));w<0||p>i||(p=Math.max(0,p),w=Math.min(i,w),!(w-p<=0)&&g.draw(t,{left:p,right:w,top:m,height:u}))}t.restore()},f.prototype.getTokensAndMarkers=function(t){var c,h;const e={},i={};i[F]=[],i[k]=[];const n=(h=(c=this.timescaleManager).getSubdayVisualMarkerLayout)==null?void 0:h.call(c);let o=this.repositionWindow,s=this.timescaleManager.startToken;e.start=s.value;const r=9;let a=0,l=s.type===F&&o<=0;for(;a<r||!l;)s=this.timescaleManager.getPrevious(s),o-=s.length,a++,s.type===F&&o<=0&&(l=!0);do s.drawX=o,e[s.value.toKeyString()]=o,n||i[s.type].push(s),o+=s.length,s=this.timescaleManager.getNext(s);while(o<t+po);if(n){const u=this.timescaleManager.createSubdayVisualMarkers(t,this.repositionWindow,n);i[F]=u[F],i[k]=u[k]}return e.end=this.getPivotPoint(t+po).date,{tokens:e,markers:i}};function Ge(t,e,i){var a;const n=t.measureText(e.label).width,o=Number.isFinite((a=i.offset)==null?void 0:a.x)?i.offset.x:0;let r=Math.round(e.drawX)+o;return i.textAlign==="center"?r-=n/2:(i.textAlign==="right"||i.textAlign==="end")&&(r-=n),{left:r,width:n}}function yo(t,e,i){return i==="center"?t+e/2:i==="right"||i==="end"?t+e:t}function Da(t,e){var i;return(t==null?void 0:t.enabled)===!0?!0:(t==null?void 0:t.enabled)!=="auto"?!1:Number.isFinite((i=e[0])==null?void 0:i.unit)&&e[0].unit<=$}const Di=8;function Ta(t,e,i,n){var h;if(((h=i.sticky)==null?void 0:h.enabled)!==!0||!Number.isFinite(n))return null;const o=Number.isFinite(i.sticky.offsetX)?i.sticky.offsetX:0;let s=-1,r;for(let u=0;u<e.length;u++){const m=Ge(t,e[u],i);m.left<=o&&(s=u,r=m)}if(s<0)return null;const a=e[s],l=e[s+1];if(a.drawX>n||!l&&a.drawX+a.length<0)return null;let c=o;if(l){const u=Ge(t,l,i);c=Math.min(c,u.left-r.width-Di)}return{token:a,labelX:yo(c,r.width,i.textAlign)}}function Pa(t,e,i,n){const o=i.sticky,s=n.minorTokens||[],r=n.viewportWidth;if(!Da(o,e)||!Number.isFinite(r))return null;const a=Number.isFinite(o.offsetX)?o.offsetX:0;let l=-1,c;for(let g=0;g<e.length;g++){const p=Ge(t,e[g],i);p.left<=a&&(l=g,c=p)}if(l<0)return null;const h=e[l],u=e[l+1];if(!(h.drawX<=r&&(u?u.drawX>=0:h.visual===!0&&h.drawX+h.length>=0||s.some(g=>g.drawX>=0&&g.drawX<=r&&g.drawX>h.drawX))))return null;let d=a;if(u){const g=Ge(t,u,i);d=Math.min(d,g.left-c.width-Di)}return{token:h,labelX:yo(d,c.width,i.textAlign)}}f.prototype.drawParentDateLabels=function(t,e,i){const n=this.options.style.dateLabel.parent;if(!this.timescaleManager.isParentContextTextVisible(n))return;const o=this.getPivotPoint(0).date,s=this.timescaleManager.createParentContextTokens(o,i,this.repositionWindow);if(s.length===0)return;const r=this.options.style.mainLine.position==="top"?-1:1,a=this.options.style.dateLabel.major,l=this.options.style.marker.major.height,c=e+l*r+a.offset.y+n.height*r+n.offset.y;t.font=n.font,t.textAlign=n.textAlign,t.textBaseline=r===1?"alphabetic":"top";const h=Ta(t,s,n,i);let u=Number.NEGATIVE_INFINITY;for(let m=0;m<s.length;m++){const d=s[m],g=(h==null?void 0:h.token)===d?h.labelX:Math.round(d.drawX)+n.offset.x,p=t.measureText(d.label).width;let w=g;n.textAlign==="center"?w-=p/2:(n.textAlign==="right"||n.textAlign==="end")&&(w-=p),!((h==null?void 0:h.token)!==d&&w<u+Di)&&(t.fillStyle=d.value.isInFuture()?n.futureColor:n.color,t.fillText(d.label,g,c),u=w+p)}},f.prototype.drawMarkersAndLabels=function(t,e,i,n,o={}){if(e.length===0)return;switch(i){case JSON.stringify(k):i="minor";break;case JSON.stringify(F):i="major";break;default:T.log("token type not recognised",i,k)}const s=this.options.style.marker[i],r=s.extend,a=this.options.style.mainLine.position==="top"?-1:1,l=s.height,c=e.some(p=>p.label);let h=e[0].value.isInFuture(),u=!h,m,d;a===-1&&(n-=this.options.style.mainLine.size),c&&(m=this.options.style.dateLabel[i],t.font=m.font,t.textAlign=m.textAlign,t.textBaseline=a===1?"alphabetic":"top",d=n+l*a+m.offset.y);const g=c&&i==="major"?Pa(t,e,m,o):null;t.beginPath();for(let p=0;p<e.length;p++){const w=e[p];h=w.value.isInFuture(),u&&h&&(u=!1,t.strokeStyle=s.color,t.lineWidth=1,t.stroke(),t.beginPath());const b=Math.round(w.drawX);t.moveTo(b,n+l*a);const v=r?n+-1*a*this.top:n;if(t.lineTo(b,v),c&&w.label){const S=(g==null?void 0:g.token)===w?g.labelX:b+m.offset.x;t.fillStyle=h?m.futureColor:m.color,t.fillText(w.label,S,d)}}t.strokeStyle=h?s.futureColor:s.color,t.lineWidth=1,t.stroke()},f.prototype.loadTimeBands=function(t){this.addTimeBands(t),typeof this._getEffectiveVerticalOffset=="function"&&(this.top=this.options.height-this._getEffectiveVerticalOffset()),this.requestRedraw()},f.prototype.addTimeBands=function(t){if(!Array.isArray(t)||t.length===0)return;const e=this.timeBands.map(o=>o.id),i=t.filter(o=>e.indexOf(o.id)===-1),n=this.options.timeBand&&this.options.timeBand.defaultStyle||{};for(let o=0;o<i.length;o++){const s=i[o],r=new Dt(this,s.id);r.setupByReceivedData(s),r.style=L({},n,s.style||{}),this.timeBands.push(r)}typeof this._getEffectiveVerticalOffset=="function"&&(this.top=this.options.height-this._getEffectiveVerticalOffset())},f.prototype._getVisibleTimeBands=function(t){if(!this.timeBands||this.timeBands.length===0)return[];const e=t.tokens.start,i=t.tokens.end;return this.timeBands.filter(n=>n.isDataLoaded&&n.visibility!=="hidden"&&n.overlapsInclusiveWithDates(e,i))};function Ti(t,e){return e&&e.resolvedArticleOptions?e.resolvedArticleOptions:Rn(t.options.article||{})}f.prototype._getResolvedArticleOptions=function(t){const e=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t),i=this.getLaneById(e);return Ti(this,i)},f.prototype._getResolvedArticleStyleOverrides=function(t,e){var h,u,m;const i=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t),n=this.getLaneById(i),o=En.article||{},s=((h=this._registeredArticleLayoutStyles)==null?void 0:h[e])||{},r=this._explicitArticleOptions||{},a=((u=r.layoutStyles)==null?void 0:u[e])||{},l=(n==null?void 0:n.articleOptions)||{},c=((m=l.layoutStyles)==null?void 0:m[e])||{};return{style:L({},o.defaultStyle||{},s.style||{},r.defaultStyle||{},a.style||{},l.defaultStyle||{},c.style||{}),hoverStyle:L({},o.defaultHoverStyle||{},s.hoverStyle||{},r.defaultHoverStyle||{},a.hoverStyle||{},l.defaultHoverStyle||{},c.hoverStyle||{}),activeStyle:L({},o.defaultActiveStyle||{},s.activeStyle||{},r.defaultActiveStyle||{},a.activeStyle||{},l.defaultActiveStyle||{},c.activeStyle||{})}},f.prototype._getExplicitArticleCardLayout=function(t){if(!t)return null;if(typeof t.cardLayout=="string"&&t.cardLayout!=="")return t.cardLayout;const e=t.data||t,i=_(e,"cardLayout");return typeof i=="string"&&i!==""?i:null},f.prototype._getResolvedArticleTopGap=function(t=this.options.article||{}){const e=t.autoStacking||{};let i=Number(ie(e.topGap,this))||0;return this.options.style.mainLine.position==="top"&&(i-=this.options.verticalOffset),i},f.prototype._getTimelineArticleAvailableHeight=function(){return Math.max(0,this.top-this._getResolvedArticleTopGap())},f.prototype._getLaneArticleAvailableHeight=function(t){return!t||!t.geometry?0:Math.max(0,t.geometry.bodyContentBottom-t.geometry.bodyContentTop)},f.prototype._getAvailableHeightForArticle=function(t){const e=t&&t.laneId!=null?t.laneId:this._resolveLaneIdFromArticleData(t);return this._isLaneLayoutActive()?this._getLaneArticleAvailableHeight(this.getLaneById(e)):this._getTimelineArticleAvailableHeight()},f.prototype._resolveCardLayoutFromBreakpoints=function(t){var i;const e=Array.isArray((i=this.options.article)==null?void 0:i.cardLayoutBreakpoints)?this.options.article.cardLayoutBreakpoints:[];for(let n=0;n<e.length;n++){const o=e[n];if(!(!o||!Number.isFinite(o.maxHeight)||typeof o.layout!="string"||o.layout==="")&&t<=o.maxHeight)return o.layout}return null},f.prototype._resolveDefaultCardLayoutName=function(t){const e=this._getResolvedArticleOptions(t),i=this._resolveCardLayoutFromBreakpoints(this._getAvailableHeightForArticle(t));if(i)return i;const n=e.defaultCardLayout;return typeof n=="string"&&n!==""?n:"portrait"},f.prototype._resolveArticleCardLayoutName=function(t){return this._getExplicitArticleCardLayout(t)||this._resolveDefaultCardLayoutName(t)},f.prototype._getTimelineDistanceToBaseline=function(){var e,i;if(Number.isFinite((e=this._runtimeArticleOptions)==null?void 0:e.distanceToBaseline))return this._runtimeArticleOptions.distanceToBaseline;const t=this._resolveDefaultCardLayoutName();return Re((i=this.options.article)==null?void 0:i.distanceToBaseline,this._getTimelineArticleAvailableHeight(),!1,t)},f.prototype._getLaneAutoStackingOptions=function(t){return Ti(this,t).autoStacking||{}},f.prototype._getLaneDistanceToBaseline=function(t){var n;if(!this._isLaneLayoutActive())return this._getTimelineDistanceToBaseline();if(Number.isFinite((n=t==null?void 0:t._runtimeArticleOptions)==null?void 0:n.distanceToBaseline))return t._runtimeArticleOptions.distanceToBaseline;const e=Ti(this,t),i=this._resolveDefaultCardLayoutName({laneId:t==null?void 0:t.id});return Re(e.distanceToBaseline,this._getLaneArticleAvailableHeight(t),!0,i)},f.prototype._refreshAdaptiveArticleRuntimeOptions=function(){var n,o;const t=this._isLaneLayoutActive(),e=this._getTimelineArticleAvailableHeight(),i=this._resolveDefaultCardLayoutName();this._runtimeArticleOptions={availableHeight:e,defaultCardLayout:i,distanceToBaseline:Re((n=this.options.article)==null?void 0:n.distanceToBaseline,e,!1,i)};for(let s=0;s<this.lanes.length;s++){const r=this.lanes[s],a=t&&r.geometry?this._getLaneArticleAvailableHeight(r):0,l=(o=r==null?void 0:r.resolvedArticleOptions)==null?void 0:o.distanceToBaseline,c=this._resolveDefaultCardLayoutName({laneId:r==null?void 0:r.id});r._runtimeArticleOptions={availableHeight:a,defaultCardLayout:c,distanceToBaseline:Re(l,a,t,c)}}this.forLoadedArticles(s=>{const r=this._resolveDefaultCardLayoutName(s),a=this._resolveArticleCardLayoutName(s);if(s._resolvedCardLayoutName!==a){s.initialiseStyles(s.data),s.invalidateCaches();return}s._resolvedDefaultCardLayout=r,s._resolvedCardLayoutName=a})};function Nt(...t){return t.filter(Boolean).join(" ")}function Pt(t){return`${Math.round(t||0)}px`}function wo(t,e){const i=e===t.length-1,n=e===0,o=["histropedia-lane",`histropedia-lane-index-${e}`];return i&&o.push("histropedia-lane-position-top"),n&&o.push("histropedia-lane-position-bottom"),!i&&!n&&o.push("histropedia-lane-position-middle"),o}function ka(t){switch(t){case"center":return"center";case"right":return"flex-end";default:return"flex-start"}}function xt(t,e){return A(t||{},e)?_(t,e):void 0}function bo(t,e,i){return e?{visible:!1,rootClassName:Nt(...wo(t.lanes,i),t.options.lane.defaultClassName,e.className),zIndex:String(t.lanes.length-i),headerClassName:Nt("histropedia-lane-header",t.options.lane.defaultHeaderClassName,e.headerClassName),bodyClassName:Nt("histropedia-lane-body",t.options.lane.defaultBodyClassName,e.bodyClassName),titleClassName:Nt("histropedia-lane-title",t.options.lane.defaultTitleClassName,e.titleClassName)}:{visible:!1}}function Ra(t,e,i){var l,c;const n=e.geometry,o=e.style||{},s=xt(o,"title.textAlign"),r=xt(o,"body.borderWidth"),a=xt(o,"body.borderRadius");return{visible:!0,rootClassName:Nt(...wo(t.lanes,i),t.options.lane.defaultClassName,e.className),zIndex:String(t.lanes.length-i),headerClassName:Nt("histropedia-lane-header",t.options.lane.defaultHeaderClassName,e.headerClassName),bodyClassName:Nt("histropedia-lane-body",t.options.lane.defaultBodyClassName,e.bodyClassName),titleClassName:Nt("histropedia-lane-title",t.options.lane.defaultTitleClassName,e.titleClassName),top:Pt(n.top),height:Pt(n.height),headerHeight:Pt(n.headerHeight||0),headerDisplay:n.headerHeight>0?"":"none",headerBackgroundColor:xt(o,"header.backgroundColor"),bodyTop:Pt(n.bodyTop-n.top),bodyBottom:Pt(n.bottom-n.bodyBottom),bodyBackgroundColor:xt(o,"body.backgroundColor"),bodyBorderColor:xt(o,"body.borderColor"),bodyBorderWidth:typeof r=="undefined"?void 0:Pt(r),bodyBorderStyle:typeof r=="undefined"?void 0:"solid",bodyBorderRadius:typeof a=="undefined"?void 0:Pt(a),titleLeft:Pt(((l=n.headerPadding)==null?void 0:l.left)||0),titleRight:Pt(((c=n.headerPadding)==null?void 0:c.right)||0),titleJustifyContent:typeof s=="undefined"?void 0:ka(s),titleColor:xt(o,"title.color"),titleFont:xt(o,"title.font"),titleTextAlign:s,titleText:e.title||""}}function _t(t,e,i){t[e]=typeof i=="undefined"?"":i}function Oa(t,e){const i=[];for(let n=t.lanes.length-1;n>=0;n--){const o=String(t.lanes[n].id),s=t._laneDomNodes.get(o);s&&i.push(s.root)}for(let n=0;n<i.length;n++)e.children[n]!==i[n]&&e.insertBefore(i[n],e.children[n]||null)}function vo(t,e,i){if((!e||e.rootClassName!==i.rootClassName)&&(t.root.className=i.rootClassName),(!e||e.headerClassName!==i.headerClassName)&&(t.header.className=i.headerClassName),(!e||e.bodyClassName!==i.bodyClassName)&&(t.body.className=i.bodyClassName),(!e||e.titleClassName!==i.titleClassName)&&(t.title.className=i.titleClassName),(!e||e.zIndex!==i.zIndex)&&_t(t.root.style,"zIndex",i.zIndex),!(e&&e.visible===i.visible&&i.visible===!1)){if(!i.visible){t.root.style.display="none";return}(!e||e.visible!==!0)&&(t.root.style.display=""),(!e||e.top!==i.top)&&(t.root.style.top=i.top),(!e||e.height!==i.height)&&(t.root.style.height=i.height),(!e||e.headerHeight!==i.headerHeight)&&(t.header.style.height=i.headerHeight),(!e||e.headerDisplay!==i.headerDisplay)&&(t.header.style.display=i.headerDisplay),(!e||e.headerBackgroundColor!==i.headerBackgroundColor)&&_t(t.header.style,"backgroundColor",i.headerBackgroundColor),(!e||e.bodyTop!==i.bodyTop)&&(t.body.style.top=i.bodyTop),(!e||e.bodyBottom!==i.bodyBottom)&&(t.body.style.bottom=i.bodyBottom),(!e||e.bodyBackgroundColor!==i.bodyBackgroundColor)&&_t(t.body.style,"backgroundColor",i.bodyBackgroundColor),(!e||e.bodyBorderColor!==i.bodyBorderColor)&&_t(t.body.style,"borderColor",i.bodyBorderColor),(!e||e.bodyBorderWidth!==i.bodyBorderWidth)&&_t(t.body.style,"borderWidth",i.bodyBorderWidth),(!e||e.bodyBorderStyle!==i.bodyBorderStyle)&&_t(t.body.style,"borderStyle",i.bodyBorderStyle),(!e||e.bodyBorderRadius!==i.bodyBorderRadius)&&_t(t.body.style,"borderRadius",i.bodyBorderRadius),(!e||e.titleLeft!==i.titleLeft)&&(t.title.style.left=i.titleLeft),(!e||e.titleRight!==i.titleRight)&&(t.title.style.right=i.titleRight),(!e||e.titleJustifyContent!==i.titleJustifyContent)&&_t(t.title.style,"justifyContent",i.titleJustifyContent),(!e||e.titleColor!==i.titleColor)&&_t(t.title.style,"color",i.titleColor),(!e||e.titleFont!==i.titleFont)&&_t(t.title.style,"font",i.titleFont),(!e||e.titleTextAlign!==i.titleTextAlign)&&_t(t.title.style,"textAlign",i.titleTextAlign),(!e||e.titleText!==i.titleText)&&(t.title.textContent=i.titleText)}}f.prototype._initialiseLaneHost=function(t){if(this._laneHostElement=null,this._laneViewportElement=null,this._laneLayer=null,this._laneDomNodes=new Map,this._laneDomState=new Map,this._laneDomDirty=!0,this._laneLayerDisplay=null,this._hasExplicitLanes=!1,!(t&&t===this.canvas)&&t&&t.nodeName!=="CANVAS"){this._laneHostElement=t;return}const i=this.canvas?this.canvas.parentElement:null;i&&i.firstElementChild===this.canvas&&i.children.length===1&&(this._laneHostElement=i)},f.prototype._ensureLaneViewport=function(){if(!this._laneHostElement||!this.canvas)return null;if(this._laneViewportElement)return this._laneViewportElement;const t=this.canvas.parentElement;if(!t)return null;const e=document.createElement("div");return e.className="histropedia-viewport",e.style.display="block",e.style.position="relative",t.insertBefore(e,this.canvas),e.appendChild(this.canvas),this._laneViewportElement=e,this._syncLaneViewportSize(),e},f.prototype._syncLaneViewportSize=function(){if(!this._laneViewportElement||!this.canvas)return;const t=this.canvas.style&&this.canvas.style.width?this.canvas.style.width:"",e=this.canvas.style&&this.canvas.style.height?this.canvas.style.height:"";this._laneViewportElement.style.width=t,this._laneViewportElement.style.height=e},f.prototype._markLaneDomDirty=function(){this._laneDomDirty=!0},f.prototype._setLaneLayerDisplay=function(t){!this._laneLayer||this._laneLayerDisplay===t||(this._laneLayer.style.display=t,this._laneLayerDisplay=t)},f.prototype._isLaneChromeActive=function(){return this._isLaneLayoutActive()&&this.options.lane.visible!==!1},f.prototype._ensureLaneLayer=function(){const t=this._ensureLaneViewport();if(!t)return null;if(!this._laneLayer){const e=document.createElement("div");e.setAttribute("aria-hidden","true"),e.dataset.histropediaLaneLayer="true",e.style.position="absolute",e.style.inset="0",e.style.pointerEvents="none",e.style.zIndex="0",e.style.overflow="hidden";const i=typeof window!="undefined"&&window.getComputedStyle?window.getComputedStyle(this.canvas).position:this.canvas.style.position;(!i||i==="static")&&(this.canvas.style.position="relative"),this.canvas.style.zIndex="1",this.canvas.style.display||(this.canvas.style.display="block"),this.canvas.parentElement===t?t.insertBefore(e,this.canvas):Yn(t,e),this._laneLayer=e}return this._laneLayer},f.prototype._syncLaneDom=function(){if(!this._isLaneChromeActive()){this._laneLayer&&this._setLaneLayerDisplay("none");return}const t=this._ensureLaneLayer();if(!t)return;this._setLaneLayerDisplay("");const e=this._laneDomDirty,i=new Set;for(let n=0;n<this.lanes.length;n++){const o=this.lanes[n],s=o.geometry,r=o.currentVisibility!=="hidden"&&s,a=String(o.id);let l=this._laneDomNodes.get(a);if(!l){const u=document.createElement("div"),m=document.createElement("div"),d=document.createElement("div"),g=document.createElement("div");u.dataset.histropediaLaneId=a,m.appendChild(d),u.appendChild(m),u.appendChild(g),t.appendChild(u),u.style.position="absolute",u.style.left="0",u.style.right="0",u.style.boxSizing="border-box",u.style.pointerEvents="none",m.style.position="absolute",m.style.left="0",m.style.right="0",m.style.top="0",m.style.boxSizing="border-box",m.style.pointerEvents="none",g.style.position="absolute",g.style.left="0",g.style.right="0",g.style.boxSizing="border-box",g.style.pointerEvents="none",d.style.position="absolute",d.style.top="0",d.style.bottom="0",d.style.display="flex",d.style.alignItems="center",d.style.boxSizing="border-box",d.style.pointerEvents="none",d.style.overflow="hidden",d.style.whiteSpace="nowrap",d.style.textOverflow="ellipsis",l={root:u,header:m,title:d,body:g},this._laneDomNodes.set(a,l)}i.add(a);const c=r?Ra(this,o,n):bo(this,o,n),h=this._laneDomState.get(a);vo(l,h,c),this._laneDomState.set(a,c)}this._laneDomNodes.forEach((n,o)=>{if(!i.has(o)){const s=bo(),r=this._laneDomState.get(o);vo(n,r,s),this._laneDomState.set(o,s)}}),e&&Oa(this,t),this._laneDomDirty=!1};function ce(t,e){return t===e}function Ea(t){const e=t&&t.layout?t.layout:{},i=Number.isFinite(e.height)?e.height:null,n=Number.isFinite(e.heightWeight)&&e.heightWeight>0?e.heightWeight:1;return{explicitHeight:i,heightWeight:n}}function je(t){return Math.round(t||0)}function Na(t,e){return e&&(t.cacheChanged=t.cacheChanged||!!e.cacheChanged,e.styleChanged&&e.laneId!=null&&t.styleLaneIds.add(String(e.laneId))),t}function So(t,e){if(!Number.isFinite(t))throw new Error(`Lane index must be a finite number. Received: ${t}`);return e<=1?0:Math.min(Math.max(Math.trunc(t),0),e-1)}f.prototype._getDefaultLaneId=function(){const t=this.options&&this.options.lane?this.options.lane:{};return t.defaultId!=null?t.defaultId:"default"},f.prototype._isLaneLayoutActive=function(){if(!Array.isArray(this.lanes)||this.lanes.length===0)return!1;if(this.lanes.length!==1)return!0;const t=this.lanes[0];return!(t&&t.isImplicit&&ce(t.id,this._getDefaultLaneId())&&!this._hasExplicitLanes)},f.prototype.getLaneById=function(t){for(let e=0;e<this.lanes.length;e++){const i=this.lanes[e];if(ce(i.id,t))return i}},f.prototype._resolveLaneReference=function(t){if(t instanceof et||t&&typeof t=="object"&&t.owner){if(t.owner===this){const e=this.lanes.indexOf(t);if(e>=0)return this.lanes[e]}throw new Error(`Lane "${t.id}" does not belong to this timeline`)}if(t!=null&&t!==""){const e=this.getLaneById(t);if(e)return e}throw new Error(`Lane "${t}" does not exist on this timeline`)},f.prototype._getLanePublicIndex=function(t){const e=this.lanes.indexOf(t);if(e<0)throw new Error(`Lane "${t&&t.id}" does not belong to this timeline`);return e},f.prototype._getInternalLaneIndexFromPublicIndex=function(t,e=this.lanes.length){return So(t,e)},f.prototype._handleLaneChange=function({requestRedraw:t=!1,refreshOrder:e=!0}={}){e&&this._refreshLaneOrder(),this._markLaneDomDirty(),t&&this.requestRedraw()},f.prototype._createImplicitLane=function(t){const e=t!=null&&t!==""?t:this._getDefaultLaneId(),i=this.getLaneById(e);if(i)return i;const n=new et(this,e);return n.setupByReceivedData({id:e},{implicit:!0}),this.lanes.push(n),this._handleLaneChange(),n},f.prototype._resolveLaneIdFromArticleData=function(t){const e=t?_(t,"lane"):void 0;return e!=null&&e!==""?e:this._getDefaultLaneId()},f.prototype._assignArticleToLane=function(t,e){const i=this._createImplicitLane(e);return t.laneId=i.id,t.laneOrder=i.order||0,i},f.prototype._refreshLaneOrder=function(){for(let t=0;t<this.lanes.length;t++)this.lanes[t].order=t;for(let t=0;t<this.articles.length;t++){const e=this.articles[t],i=this.getLaneById(e.laneId);e.laneOrder=i?i.order:0}this._hasExplicitLanes=this.lanes.some(t=>!t.isImplicit)},f.prototype._handleLaneIdChange=function(t,e){for(let i=0;i<this.articles.length;i++){const n=this.articles[i];ce(n.laneId,e)&&(n.laneId=t.id,n.data&&_(n.data,"lane")!=null&&(n.data.lane=t.id))}for(let i=0;i<this.charts.length;i++){const n=this.charts[i];ce(n.laneId,e)&&(n.laneId=t.id,n.data&&n.data.lane!=null&&(n.data.lane=t.id))}this._markLaneDomDirty()},f.prototype._refreshArticlesForLane=function(t,{refreshStyles:e=!0}={}){if(e)for(let i=0;i<this.articles.length;i++){const n=this.articles[i];!n.isDataLoaded||!ce(n.laneId,t.id)||(n.initialiseStyles(n.data),n.invalidateCaches())}},f.prototype._refreshAllLaneArticleStyles=function(){this.forLoadedArticles(t=>{t.initialiseStyles(t.data),t.invalidateCaches()})},f.prototype._refreshLaneArticleStylesByIds=function(t){!t||t.size===0||this.forLoadedArticles(e=>{t.has(String(e.laneId))&&(e.initialiseStyles(e.data),e.invalidateCaches())})},f.prototype._refreshResolvedLanesFromOptions=function({articleStyleScope:t=null}={}){for(let e=0;e<this.lanes.length;e++)this.lanes[e]._resolveFromData();this._handleLaneChange(),t==="all"?this._refreshAllLaneArticleStyles():t instanceof Set&&this._refreshLaneArticleStylesByIds(t)},f.prototype.loadLanes=function(t){this.addLanes(t),this.requestRedraw()},f.prototype.addLanes=function(t,{suppressArticleRefresh:e=!1}={}){var n,o;if(!Array.isArray(t)||t.length===0)return{cacheChanged:!1,styleLaneIds:new Set};const i={cacheChanged:!1,styleLaneIds:new Set};for(let s=0;s<t.length;s++){const r=t[s]||{},a=r.id!=null?r.id:this._getDefaultLaneId(),l=this.getLaneById(a);if(l){const h=l._applyOption(L({},r,{id:a}),{suppressRedraw:!0,markExplicit:!0,suppressArticleRefresh:e});Na(i,{cacheChanged:(n=h==null?void 0:h.articleImpact)==null?void 0:n.cacheChanged,styleChanged:(o=h==null?void 0:h.articleImpact)==null?void 0:o.styleChanged,laneId:h==null?void 0:h.laneId});continue}const c=new et(this,a);c.setupByReceivedData(L({},r,{id:a}),{implicit:!1}),this.lanes.push(c)}return this._handleLaneChange(),i},f.prototype.moveLaneToIndex=function(t,e){const i=this._resolveLaneReference(t),n=this._getLanePublicIndex(i),o=So(e,this.lanes.length);if(n===o)return i;const s=this._getInternalLaneIndexFromPublicIndex(n),r=this._getInternalLaneIndexFromPublicIndex(o),a=this.lanes.splice(s,1)[0];return this.lanes.splice(r,0,a),this._handleLaneChange({requestRedraw:!0}),a},f.prototype.moveLaneBefore=function(t,e){const i=this._resolveLaneReference(t),n=this._resolveLaneReference(e);if(i===n)return i;const o=this._getLanePublicIndex(i),s=this._getLanePublicIndex(n),r=o<s?s-1:s;return this.moveLaneToIndex(i,r)},f.prototype.moveLaneAfter=function(t,e){const i=this._resolveLaneReference(t),n=this._resolveLaneReference(e);if(i===n)return i;const o=this._getLanePublicIndex(i),s=this._getLanePublicIndex(n),r=o<s?s:s+1;return this.moveLaneToIndex(i,r)},f.prototype.moveLaneUp=function(t){const e=this._resolveLaneReference(t);return this.moveLaneToIndex(e,e.order+1)},f.prototype.moveLaneDown=function(t){const e=this._resolveLaneReference(t);return this.moveLaneToIndex(e,e.order-1)},f.prototype.loadLaneArticles=function(t,e){const i=t!=null&&t!==""?t:this._getDefaultLaneId(),o=(Array.isArray(e)?e:[]).map(s=>{const r=L({},s),a=_(s,"lane");return a!=null&&a!==""&&!ce(a,i)&&T.warn("loadLaneArticles overriding conflicting article.lane value",{articleId:_(s,"id"),from:a,to:i}),r.lane=i,r});this._createImplicitLane(i),this.load(o)},f.prototype._getActiveLanesForLayout=function(){if(!Array.isArray(this.lanes)||this.lanes.length===0)return[];const t=[];for(let e=0;e<this.lanes.length;e++){const i=this.lanes[e];i.currentVisibility=i.visibility,i.currentVisibility!=="hidden"?t.push(i):i.geometry=null}return t},f.prototype._updateLaneLayout=function(){var w,b,v;const t=this._getActiveLanesForLayout();if(!this._isLaneLayoutActive()||t.length===0){for(let S=0;S<this.lanes.length;S++)this.lanes[S].geometry=null;return}const e=this.options.lane||{},i=typeof e.gap=="number"?e.gap:0,n=typeof e.topGap=="number"?e.topGap:0,o=typeof e.axisGap=="number"?e.axisGap:0,s=this.top-this.options.style.mainLine.size/2-o,r=i*Math.max(t.length-1,0),a=s-n-r,l=t.map(S=>Ea(S));let c=0,h=0;for(let S=0;S<l.length;S++){const M=l[S];M.explicitHeight!=null?c+=M.explicitHeight:h+=M.heightWeight}const u=Math.max(0,a-c),m=this.getWidth(),d=je(s),g=h>0;let p=n;for(let S=t.length-1;S>=0;S--){const M=t[S],P=l[S],E=P.explicitHeight!=null?P.explicitHeight:h>0?u*P.heightWeight/h:0,x=je(p),Z=p+E,R=S===0&&g?d:je(Z),V=Math.max(0,R-x),B=x+V,z=((w=M.layout.header)==null?void 0:w.padding)||{},kt=((b=M.layout.header)==null?void 0:b.visible)!==!1&&typeof((v=M.layout.header)==null?void 0:v.height)=="number"?je(M.layout.header.height):0,ut=x+kt,Ut=B;M.geometry={top:x,left:0,width:m,height:V,bottom:B,headerTop:x,headerHeight:kt,headerBottom:ut,bodyTop:ut,bodyBottom:Ut,bodyLeft:0,bodyRight:m,bodyContentTop:ut,bodyContentBottom:Ut,bodyContentLeft:0,bodyContentRight:m,headerPadding:z},p=Z+i}},f.prototype._isArticleLaneVisible=function(t){const e=this.getLaneById(t.laneId);return!e||!this._isLaneLayoutActive()?!0:e.currentVisibility!=="hidden"};function be(t){return t!=null&&t!==""}function Lo(t){return be(t==null?void 0:t.lane)?t.lane:null}function _o(t,e){return be(e)?e:t._getDefaultLaneId()}f.prototype.getChartById=function(t){for(let e=0;e<this.charts.length;e++){const i=this.charts[e];if(i.id===t)return i}},f.prototype.loadCharts=function(t){this.addCharts(t),this.requestRedraw()},f.prototype.removeChart=function(t){for(let e=0;e<this.charts.length;e++)if(this.charts[e].id===t)return this.charts.splice(e,1),this.requestRedraw(),!0;return!1},f.prototype.clearCharts=function(){!Array.isArray(this.charts)||this.charts.length===0||(this.charts=[],this.requestRedraw())},f.prototype.loadLaneCharts=function(t,e){const i=_o(this,t),o=(Array.isArray(e)?e:[]).map(s=>{const r=L({},s),a=Lo(s);return a!=null&&a!==i&&T.warn("loadLaneCharts overriding conflicting chart.lane value",{chartId:s==null?void 0:s.id,from:a,to:i}),r.lane=i,r});this.addCharts(o),this.requestRedraw()},f.prototype.addCharts=function(t){if(!Array.isArray(t)||t.length===0)return;const e=this.charts.map(i=>i.id);for(let i=0;i<t.length;i++){const n=t[i]||{};if(n.id==null){T.warn("Skipping chart without id",n);continue}if(e.indexOf(n.id)!==-1){T.warn("Skipping chart with duplicate id",{chartId:n.id,chart:n});continue}const o=Lo(n);o!=null&&this._ensureChartLane(o);const s=new ct(this,n.id);s.setupByReceivedData(n),be(s.laneId)&&this._ensureChartLane(s.laneId),this.charts.push(s),e.push(s.id)}this._refreshLaneOrder(),this._updateLaneLayout()},f.prototype._ensureChartLane=function(t){const e=_o(this,t),i=this.getLaneById(e);return i&&!i.isImplicit?i:(typeof this.addLanes=="function"&&this.addLanes([{id:e}],{suppressArticleRefresh:!0}),this.getLaneById(e))},f.prototype._isChartLaneVisible=function(t){if(!be(t.laneId))return!0;const e=this.getLaneById(t.laneId);return e?this._isLaneLayoutActive()?e.currentVisibility!=="hidden":!0:!1},f.prototype._getVisibleCharts=function(){return!this.charts||this.charts.length===0?[]:this.charts.filter(t=>t.isDataLoaded&&t.visibility!=="hidden"&&this._isChartLaneVisible(t))},f.prototype._getChartGeometry=function(t,e){if(be(t.laneId)){const l=this.getLaneById(t.laneId),c=l&&l.geometry?l.geometry:null;return c?{left:c.bodyContentLeft,right:c.bodyContentRight,top:c.bodyContentTop,bottom:c.bodyContentBottom,width:c.bodyContentRight-c.bodyContentLeft,height:c.bodyContentBottom-c.bodyContentTop,lane:l}:null}const i=this.options.chart||{},n=t.area||i.area,o={up:this.top,down:0},{up:s,height:r}=Ci(n,{anchorY:this.top,canvasHeight:this.options.height,fallbackArea:o});if(r<=0)return null;const a=this.top-s;return{left:0,right:e,top:a,bottom:a+r,width:e,height:r}},f.prototype.drawCharts=function(t,e,i,n){if(!(this.options.chart||{}).visible)return;const s=this._getVisibleCharts();if(s.length!==0){t.save();for(let r=0;r<s.length;r++){const a=s[r],l=this._getChartGeometry(a,i);!l||l.width<=0||l.height<=0||a.draw(t,l,n)}t.restore()}},f.prototype._getLaneRowSpacing=function(t,e){const i=this._getLaneAutoStackingOptions(t),n=Array.isArray(e)?e.length:e;if(!t||!i.fitToHeight||n<=1||!t.geometry)return i.rowSpacing;const o=Number(ie(i.topGap,this))||0,s=t.geometry.bodyContentBottom-this._getLaneDistanceToBaseline(t),r=t.geometry.bodyContentTop+o,a=Math.max(0,s-r);return Math.max(Math.round(a/(n-1)),1)},f.prototype.updateArticleLines=function(){const t=this,e=this.options.article.periodLine||{},i=this._isLaneLayoutActive()&&e.position==="lane";function n(l){const c=[];return t.forVisibleArticles(function(h){h.hidePeriodLine||(c.push(h),c[c.length-1].stacking=-1)}),c.sort(t.options.article.periodLine.stacking.sorter),t.options.article.periodLine.stacking.reverseOrder&&c.reverse(),c}function o(l,c){for(let h=0;h<c.length;h++)if(l.overlaps(c[h]))return!1;return!0}function s(l){let c=0;const h=[];let u;do{h[c]=[],u=!1;for(let m=0;m<l.length;m++){const d=l[m];d.stacking>=0||o(d,h[c])&&(h[c].push(d),d.stacking=c,u=!0)}c++}while(u)}const r=n(this.articles);if(!i){s(r);return}const a=new Map;for(let l=0;l<r.length;l++){const c=r[l],h=String(c.laneId),u=a.get(h)||[];u.push(c),a.set(h,u)}a.forEach(l=>{s(l)})},f.prototype.stack=function(t){if(this.articles.length===0||!this.options.article.autoStacking.active)return;function e(c){let h;const u=[],m=[];for(let d=0;d<c.length;d++){const g=c[d];g.isDataLoaded&&g.isInRange&&g.isVisibleInGroup&&!g.isHiddenByFilter&&(g.isActive?h=g:g.isStarred?u.push(g):m.push(g))}return u.sort(ni),m.sort(ni),[].concat(h||[],u,m)}function i(c,h){for(let u=0;u<c.length;u++){const m=c[u];if(h.headerOverlapsWith(m))return!1}return!0}function n(c,h){for(let u=0;u<c.length;u++)if(i(c[u],h))return u;return c.length}function o(c,h){const u=n(c,h);return u>=c.length&&(c[u]=[]),c[u].push(h),!0}const s=e(this.articles);if(this._isLaneLayoutActive()){const c=new Map;for(let u=0;u<s.length;u++){const m=s[u],d=this.getLaneById(m.laneId),g=this._getLaneAutoStackingOptions(d),p=String(m.laneId),w=c.get(p)||[];g.active===!1?(w[0]||(w[0]=[]),w[0].push(m),m.isVisibleInRows=!0):m.isVisibleInRows=o(w,m),c.set(p,w)}this.topRow=0,c.forEach((u,m)=>{const d=this.getLaneById(m),g=this._getLaneAutoStackingOptions(d),p=g.active===!1?0:this._getLaneRowSpacing(d,u);d&&(d.topRow=0);for(let w=0;w<u.length;w++)for(let b=0;b<u[w].length;b++){const v=u[w][b],S=g.active===!1;S||(v.finalOffset={left:0,top:w*-p}),v.row=S?0:w,d&&(d.topRow=Math.max(d.topRow,v.row)),v.isInView&&(this.topRow=Math.max(this.topRow,v.row)),S||this.reposition(v,t)}});const h=this.getActiveArticle();this.articles.sort(ii),h&&this.bringFront(h.id);return}const r=this.options.article.autoStacking.rowSpacing,a=[];for(let c=0;c<s.length;c++)s[c].isVisibleInRows=o(a,s[c]);this.topRow=0;for(let c=0;c<a.length;c++)for(let h=0;h<a[c].length;h++){const u=a[c][h];u.finalOffset={left:0,top:c*-r},u.row=c,u.isInView&&(this.topRow=Math.max(this.topRow,c)),this.reposition(u,t)}const l=this.getActiveArticle();this.articles.sort(ii),l&&this.bringFront(l.id)},f.prototype.notifyEventSpacingChanged=function(){this.requestRedraw(this.defaultRedraw)};const Ao=.001,xa=120,za=1e3/60,Io=120,Fa=24,Ba=1e-7,Mo=[.25,1/3,.5,.67,.75,.8,.9,1,1.1,1.25,1.5,1.75,2,2.5,3,4,5];function Ha(t,e="discrete"){let i=0;if("deltaY"in t&&typeof t.deltaY=="number"&&t.deltaY!==0?i=-t.deltaY:"wheelDelta"in t&&typeof t.wheelDelta=="number"&&t.wheelDelta!==0?i=t.wheelDelta:"detail"in t&&typeof t.detail=="number"&&t.detail!==0&&(i=-t.detail),e==="discrete")return i>0?1:-1;const n=i/120;return n===0?0:n}function Co(t,e){const i=Math.max(1,Math.abs(e)*.015);return Math.abs(t-e)<=i}function Do(t){const e=Math.abs(t);if(e<Fa)return!1;for(let i=0;i<Mo.length;i++){const n=Mo[i];if(Co(e,Io*n)||Co(e,Io/n))return!0}return!1}function Ya(t){return!!(t.deltaMode===1||typeof t.deltaY=="number"&&Do(t.deltaY)||"wheelDelta"in t&&typeof t.wheelDelta=="number"&&Do(t.wheelDelta))}function Wa(t,e){const i=t.discreteWheelAnimation;return i!=null&&i.active?e:!1}function Va(t,e){return e&&Number.isFinite(t.animation.wheelZoomTarget)?t.animation.wheelZoomTarget:t.timescaleManager.zoom}function To(t,e){let i=e;return i>t.maximum&&(i=t.maximum),i<t.minimum&&(i=t.minimum),i}function Za(t,e){var n;const i=((n=t.discreteWheelAnimation)==null?void 0:n.duration)||250;return i<=0?1:1-Math.pow(.05,Math.max(e,0)/i)}function Pi(t){t.wheelZoomTarget=null,t.wheelZoomPivotPoint=null,t.wheelZoomPivotPixel=null,t.wheelZoomLastFrameTime=null,t.wheelZoomFrame=null}function Ua(t){t._wheelZoomStateChangeTimer!=null&&clearTimeout(t._wheelZoomStateChangeTimer),t._wheelZoomStateChangeTimer=setTimeout(()=>{var e;t._wheelZoomStateChangeTimer=null,(e=t._flushTimelineStateChange)==null||e.call(t)},xa)}f.prototype.enableZoomByWheel=function(){this._wheelEnabled||(this._wheelEnabled=!0,this._wheelHandler=e=>{const{allowCtrlWheel:i=!1,wheelMode:n="auto"}=this.options.zoom||{};if(!i&&e.ctrlKey)return;const s=Ha(e,n==="discrete"?"discrete":"proportional");this.onWheel(e,s)},this.canvas.addEventListener("wheel",this._wheelHandler,{passive:!1}),this.canvas.addEventListener("DOMMouseScroll",this._wheelHandler,{passive:!1}))},f.prototype.disableZoomByWheel=function(){this._wheelEnabled&&(this.canvas.removeEventListener("wheel",this._wheelHandler),this.canvas.removeEventListener("DOMMouseScroll",this._wheelHandler),this._wheelEnabled=!1,this._wheelHandler=null)},f.prototype.onWheel=function(e,i){const{wheelSpeed:n,wheelStep:o,maximum:s,minimum:r,proportionalGain:a,proportionalExponent:l,wheelMode:c}=this.options.zoom,h=c!=="discrete",u=Ya(e);if(h&&!u){const S=Math.sign(i)||1;let M=Math.abs(i);M>=1&&l&&l!==1&&(M=Math.pow(M,l)),M*=a,i=S*M}else h&&u&&(i=i>0?1:-1);const m=Wa(this.options.zoom,u);let d=Va(this,m)+-i*n*o;d=To({maximum:s,minimum:r},d);let g,p;if(e.target===this.canvas&&"offsetX"in e&&typeof e.offsetX=="number")g=e.offsetX,p=e.offsetY;else{const S=this.canvas.getBoundingClientRect();g=e.clientX-S.left,p=e.clientY-S.top}const w=this.timescaleManager.zoom;m?this.animateZoomByPivotPoint(d,this.getPivotPoint(g),g):(this.animation.wheelZoomFrame!=null&&cancelAnimationFrame(this.animation.wheelZoomFrame),Pi(this.animation),this.setZoomByPivotPixel(d,g),Ua(this));const b=this.timescaleManager.zoom,v=d-w;this.requestRedraw(),e.preventDefault(),this.trigger("zoom-wheel",va({centre:{x:g,y:p},zoom:m?d:b,zoomDelta:v}),e)},f.prototype.animateZoomByPivotPoint=function(e,i,n){var r,a;if((r=this.stopPanAnimation)==null||r.call(this),this.animation.wheelZoomFrame==null&&((a=this.animation.zoom)!=null&&a.stop)&&(this.animation.zoom.stop(),this.animation.zoom=null),this.animation.wheelZoomTarget=To(this.options.zoom,e),this.animation.wheelZoomPivotPoint=i,this.animation.wheelZoomPivotPixel=n,this.animation.wheelZoomFrame!=null)return;const o=this;function s(l){var v;const c=o.animation.wheelZoomTarget;if(!Number.isFinite(c)){Pi(o.animation);return}const h=o.timescaleManager.zoom,u=c-h,m=o.animation.wheelZoomPivotPoint,d=o.animation.wheelZoomPivotPixel;if(Math.abs(u)<=Ao){o.setZoomByPivotPoint(c,m,d),o.requestRedraw(),Pi(o.animation),(v=o._flushTimelineStateChange)==null||v.call(o);return}const g=o.animation.wheelZoomLastFrameTime,p=g==null?za:l-g;o.animation.wheelZoomLastFrameTime=l;const w=Za(o.options.zoom,p),b=h+u*w;o.setZoomByPivotPoint(b,m,d),Math.abs(o.timescaleManager.zoom-b)>Ao&&(o.animation.wheelZoomTarget=o.timescaleManager.zoom),o.requestRedraw(o.repositionRedraw),o.animation.wheelZoomFrame=requestAnimationFrame(s)}this.animation.wheelZoomFrame=requestAnimationFrame(s)},f.prototype.setZoom=function(e,i,n=0){var r,a,l;(r=this.stopPanAnimation)==null||r.call(this),(a=this.stopZoomAnimation)==null||a.call(this);const o=i==null?this.width/2:i,s=n?Math.round(n):0;this.setZoomByPivotPixel(e,o,s),this.requestRedraw(),(l=this._flushTimelineStateChange)==null||l.call(this)},f.prototype.setZoomByPivotPixel=function(e,i,n=0){this.setZoomByPivotPoint(e,this.getPivotPoint(i),i,n)},f.prototype.setZoomByPivotPoint=function(e,i,n,o=0){this.timescaleManager.setZoom(e);const s=this.timescaleManager.setStartDate(i.date),r=Number.isFinite(i.millisecondFraction)?i.millisecondFraction*At(this)/U:i.fraction;this.repositionWindow=s-r,this.updateFromByPixels(-n+o),Et(this,{mode:this.isDragging||this.isPinching?"elastic":"clamp"})},f.prototype.getPivotPoint=function(e){let i=this.timescaleManager.getStartTokenCloned(),n=this.repositionWindow;n>=0&&(i=this.timescaleManager.getPrevious(i),n-=i.length);let o=i;for(;n<=e;)n+=i.length,o=i,i=this.timescaleManager.getNext(i);const s=o.unit,r=o.length;let a=e-(n-i.length);const l=o.value;let{year:c,month:h,day:u}=l;if(s<=O){const m=At(this)/U;let d=m>0?a/m:0;const g=Math.round(d);Math.abs(d-g)<Ba&&(d=g);const p=Math.floor(d),w=d-p;return o.value=o.value.addMilliseconds(p),a-=p*m,{date:o.value,fraction:a,millisecondFraction:w}}else if(s===$)u=Math.floor(a/r*30.44)+1,a-=(u-1)*r/30.44,o.value=new y(c,h,u);else if(s!==O){const m=this.timescaleManager.unitLengthInYears;let d=Math.floor(a*365.2422*m/r)+1,g=0;d>365&&(g=Math.floor(d/365),d=d-365*g),a=0,o.value=y.getByDayOfYear(c+g,d)}return{date:o.value,fraction:a}},f.prototype.startAnimation=function(t){this.isAnimating||(this.isAnimating=!0,this.animation.redrawFunction=t,this.drawAnimationFrame())},f.prototype.stopAnimation=function(){var t;this.isAnimating=!1,this.animation.dragRedrawFunction=this.repositionRedraw,this.animation.redrawFunction=!1,(t=this._flushTimelineStateChange)==null||t.call(this)},f.prototype.areAnimationsFinished=function(){return!(this.isDragging||this.isPanning||this.isPinching||this.draggingArticle!==null||this.isAnimatingArticles||this.isCustomAnimating)},f.prototype.drawAnimationFrame=function(){if(this.areAnimationsFinished())return this.stopAnimation();const t=this,e=this.getAnimationRedrawFunction();this.updateRedrawRequests(e),requestAnimationFrame(function(i){e.call(t),t.drawAnimationFrame()})},f.prototype.requestRedraw=function(t){t=t||this.defaultRedraw;const e=this;if(!this.isAnimating)return t.call(e);t===this.defaultRedraw&&(this.redrawRequests.default=!0),t===this.repositionRedraw&&(this.redrawRequests.reposition=!0)},f.prototype.updateRedrawRequests=function(t){t===this.defaultRedraw&&(this.redrawRequests.default=!1,this.redrawRequests.reposition=!1),t===this.repositionRedraw&&(this.redrawRequests.reposition=!1)},f.prototype.getAnimationRedrawFunction=function(){return this.isDragging?this.animation.dragRedrawFunction:this.isPanning||this.isPinching?this.defaultRedraw:this.redrawRequests.default?this.defaultRedraw:this.redrawRequests.reposition?this.repositionRedraw:this.animation.redrawFunction||this.animation.defaultRedrawFunction},f.prototype.stopPanAnimation=function(){var t;(t=this.animation.pan)!=null&&t.stop&&this.animation.pan.stop(),this.animation.pan=null,this.isPanning=!1},f.prototype.stopZoomAnimation=function(){var t;(t=this.animation.zoom)!=null&&t.stop&&this.animation.zoom.stop(),this.animation.zoom=null,this.animation.wheelZoomFrame!=null&&cancelAnimationFrame(this.animation.wheelZoomFrame),this._wheelZoomStateChangeTimer!=null&&(clearTimeout(this._wheelZoomStateChangeTimer),this._wheelZoomStateChangeTimer=null),this.animation.wheelZoomTarget=null,this.animation.wheelZoomPivotPoint=null,this.animation.wheelZoomPivotPixel=null,this.animation.wheelZoomLastFrameTime=null,this.animation.wheelZoomFrame=null},f.prototype.switchToPositiveRepositionWindow=function(){if(this.repositionWindow<0){let t=this.timescaleManager.startToken;this.repositionWindow=t.length+this.repositionWindow,t=this.timescaleManager.getNext(t),this.timescaleManager.setStartToken(t)}},f.prototype.zoomToAnim=function(t,e){this.stopPanAnimation(),this.stopZoomAnimation();const i=this.timescaleManager.zoom,n=2e3,o=H.swing,s=this,r=Y({from:i,to:t,duration:n,easing:o,onUpdate(a){s.setZoomByPivotPixel(a,s.width/2),s.requestRedraw()},onComplete(){var a;s.animation.zoom=null,(a=s._flushTimelineStateChange)==null||a.call(s),typeof e=="function"&&e.call(s)}});this.animation.zoom=r},f.prototype.goToPixelAnim=function(t,e={}){var a;this.stopPanAnimation(),this.stopZoomAnimation(),this.isPanning=!0;const i=1e8;let n=!1;Math.abs(t)>i&&(t=Math.sign(t)*i,n=!0),this.startAnimation();let o=0;const s=this,r=Y({from:0,to:t,duration:(a=e.duration)!=null?a:2e3,easing:H[e.easing]||H.swing,onUpdate(l){const c=l-o;o=l,s.updateFromByPixels(c),s.isPinching?(s.isPanning=!1,r.stop()):s.requestRedraw()},onComplete(){var l;n&&e.targetDmy&&s.setStartDate(e.targetDmy),s.isPanning=!1,(l=e.complete)==null||l.call(s)}});this.animation.pan=r},f.prototype.goToDateAnim=function(t,e={}){var i;T.warn("DEPRECATION WARNING: timeline.goToDateAnim(dmy, options) is deprecated. Use timeline.setStartDate(dmy, { padding, animation: { active: true, ... } }) instead."),this.setStartDate(t,{padding:(i=e.offsetX)!=null?i:0,animation:{active:!0,duration:e.duration,easing:e.easing,complete:e.complete}})},f.prototype.repositionWithAnim=function(t){const e=this.getOriginalPosition(t);t.registeredPosition=e;const i={left:e.left+t.dragFinishOffset.left,top:e.top+t.dragFinishOffset.top};t.moveToWithAnim(i)},f.prototype.notifyArticleAnimating=function(t,e){const i=new Date().getTime(),n=this.options.article.animation[t].duration,o=i+n;o>this.lastAnimatingArticle.endTime&&(this.lastAnimatingArticle.id=e,this.lastAnimatingArticle.endTime=o,this.lastAnimatingArticle.animationType=t),this.isAnimatingArticles=!0,this.startAnimation()},f.prototype.toggleAutoFit=function(){const t=this.options.article.autoStacking.fitToHeight=!this.options.article.autoStacking.fitToHeight;return t&&this.fitToHeight(!0),t},f.prototype.fitToHeight=function(t){if(this.topRow+1===1)return;const i=this.options.article.autoStacking.rowSpacing=this.getFitToHeightRowSpacing();return t&&this.requestRedraw(),i},f.prototype.getFitToHeightRowSpacing=function(){const t=this.top-this._getTimelineDistanceToBaseline(),e=this._getResolvedArticleTopGap(),i=this.topRow;if(i===0)return!1;const n=Math.abs(t-e);return Math.max(Math.round(n/i),1)},f.prototype.incrementRowSpacing=function(t,e){return this.options.article.rowSpacing=Math.max(this.options.article.rowSpacing+t,1),e&&this.requestRedraw(),this.options.article.rowSpacing};function Ga(t){return typeof t=="number"?(T.warn("DEPRECATION WARNING: timeline.setStartDate(date, pixelOffset) is deprecated. Use timeline.setStartDate(date, { padding }) instead."),{padding:t}):t||{}}function ja(t,e,i,n){t.switchToPositiveRepositionWindow();const o=t.timescaleManager.startToken.value,s=t.repositionWindow-t.timescaleManager.getPixelsBetween(e,o)-i;t.goToPixelAnim(s,zt(W({},n),{targetDmy:e}))}f.prototype.setStartDate=function(t,e){var s;const i=Ga(e),n=i.padding||0;if(t=this.getDmyFromInput(ze(t)),(s=i.animation)!=null&&s.active){ja(this,t,n,i.animation);return}const o=this.timescaleManager.setStartDate(t);this.repositionWindow=o,n&&this.updateFromByPixels(-n),Et(this),this.requestRedraw(),this._emitTimelineStateChange()},f.prototype.getZoom=function(){return this.timescaleManager.zoom},f.prototype.setCentreDate=function(t,e){this.setStartDate(t,{padding:this.getWidth()/2+(e||0)})};function ki(t,e,i,n={}){var r;const o=Gn(n.padding),s=oa(t,e,i,o);if((r=n.animation)!=null&&r.active){ua(t,e,i,s,o,n.animation);return}s!==t.timescaleManager.zoom&&t.setZoom(s),eo(t,e,o.left,!0)}f.prototype.fitDateRange=function(e,i,n={}){let o=$n(e),s=$n(i);o.start.compare(s.start)>0&&([o,s]=[s,o]),ki(this,this.getDmyFromInput(o.start),this.getDmyFromInput(s.end),n)},f.prototype.settleDateBounds=function(e={}){var h;let i=Be(this);if(!i)return!1;if(i.type==="range"&&i.zoom===this.timescaleManager.zoom&&(i=Be(this,void 0,{mode:"elastic"})||i),e.animate===!1||i.type==="range")return Et(this,{mode:"clamp"}),!0;const n=At(this);if(!n)return Et(this,{mode:"clamp"}),!0;const o=i.type==="min"?i.overflowDays*n:-i.overflowDays*n;if(!Number.isFinite(o)||o===0)return Et(this,{mode:"clamp"}),!0;(h=this.stopPanAnimation)==null||h.call(this),this.isPanning=!0,this.startAnimation();let s=0;const r=300,a=H.swing,l=this,c=Y({from:0,to:o,duration:r,easing:a,onUpdate(u){const m=u-s;s=u,l.updateFromByPixels(m,{skipDateBounds:!0}),l.requestRedraw()},onComplete(){l.isPanning=!1,l.animation.pan===c&&(l.animation.pan=null),Et(l,{mode:"clamp"})}});return this.animation.pan=c,!0},f.prototype.fitArticleRange=function(e,i={}){var n;return!((n=e==null?void 0:e.period)!=null&&n.from)||!e.period.to?!1:(ki(this,e.period.from,e.period.to,{padding:i.padding,animation:i.animation}),!0)},f.prototype.fitArticles=function(e={}){var r;const i=e.articleFilter||function(l){return!l.hiddenByFilter},n=da(this,i);if(!n)return!1;const o=Gn((r=e.padding)!=null?r:40),s={left:o.left+n.maxCardLeftOffset,right:o.right+n.maxCardRightOffset};return ki(this,n.earliest,n.latest,{padding:s,animation:e.animation}),!0},f.prototype.on=function(t,e){if(typeof t=="object")return this.onMultiple(t);this.handlers[t]||(this.handlers[t]=[]),this.handlers[t].push(e)},f.prototype.trigger=function(t,...e){if(!this.handlers[t])return;const i=this.handlers[t];for(let n=0;n<i.length;n++)i[n].call(this,...e)},f.prototype.onMultiple=function(t){for(const e in t)this.on(e,t[e])},f.prototype.off=function(t,e){if(typeof t=="object")return this.offMultiple(t);this.handlers[t]&&(this.handlers[t]=this.handlers[t].filter(i=>i!==e))},f.prototype.offMultiple=function(t){for(const e in t)this.off(e,t[e])};function Ri(t){var n,o,s,r,a,l;const e=((o=(n=t.owner)==null?void 0:n.getCanvasDpr)==null?void 0:o.call(n))||1,i=(l=(a=(r=(s=t.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.rendering)==null?void 0:l.pixelSnap;return rn(e,i)}function Oi(t){const e=Ri(t);return{top:e(t.position.top),left:e(t.position.left)}}const $a={name:"landscape",draw(t){var ot,J,Q,at;if(!this.isDataLoaded||isNaN(this.position.left))return;const e=this.getCurrentStyle(),i=Ri(this),n=Oi(this),o=n.top,s=n.left,r=e.width,a=e.height,l=e.backgroundColor||"#FFF",c=e.shadow,h=e.borderRadius||0;Hn(t,c),t.fillStyle=l,h>0?(Ve(t,s,o,r,a,h),t.fill()):t.fillRect(s,o,r,a),co(t);let u=s,m=r;if(this.imageLoaded){const C=e.image,q=C.margin,tt=s+q,pt=o+q,mt=a-q*2;let yt,wt,ue,qe;this.image.width>this.image.height?(yt=Pe((this.image.width-this.image.height)/2),wt=0,ue=qe=this.image.height):(yt=0,wt=0,ue=qe=this.image.width);const Ja=C.shape||"square",Po=C.borderRadius||0,ko=(ve,Se,Le,Ke,_e,Ni,xi,zi)=>{Po>0?(t.save(),Ve(t,_e,Ni,xi,zi,Po),t.clip(),t.drawImage(this.image,ve,Se,Le,Ke,_e,Ni,xi,zi),t.restore()):t.drawImage(this.image,ve,Se,Le,Ke,_e,Ni,xi,zi)};switch(Ja){case"circle":{mo(t,this.image,yt,wt,ue,qe,tt,pt,mt);break}case"square":{ko(yt,wt,ue,qe,tt,pt,mt,mt);break}default:{const ve=Math.min(mt/this.image.width,mt/this.image.height),Se=i(this.image.width*ve),Le=i(this.image.height*ve),Ke=i(tt+(mt-Se)/2),_e=i(pt+(mt-Le)/2);ko(0,0,this.image.width,this.image.height,Ke,_e,Se,Le);break}}u=s+mt+q,m=r-mt-q}const d=((at=(Q=(J=(ot=this.owner)==null?void 0:ot.options)==null?void 0:J.article)==null?void 0:Q.star)==null?void 0:at.visible)!==!1&&(this.isActive||this.isStarred);if(d){const C=e.star.width,q=e.star.margin,tt=C+q;m=Math.max(0,m-tt)}const g=e.header.text,p=g.margin,w=g.lineHeight,b=u+p,v=m-p*2,S=g.offsetY||0,M=this.title,P=g.numberOfLines,E=this.memo(`titleLines:${M}:${v}:${g.font}:${P}`,()=>{t.font=g.font;let C=Ze(M,t,v);return C.length>P&&(C=Ue(C,P,t,v)),C}),x=E.length,R=this.memo(`headerMetrics:${g.font}`,()=>(t.font=g.font,t.measureText("Hg"))).actualBoundingBoxAscent,V=`${this.subtitle}`,B=e.subheader.text,z=B.font,it=B.margin,kt=u+it,ut=m-it*2,Ut=B.offsetY||0,N=this.memo(`subtitle:${V}:${ut}:${z}`,()=>{t.font=z;const C=Ze(V,t,ut);return C.length>1?Ue(C,1,t,ut)[0]:C[0]}),dt=this.memo(`subheaderMetrics:${z}`,()=>(t.font=z,t.measureText("Hg"))),ft=dt.actualBoundingBoxAscent,gt=dt.actualBoundingBoxDescent,Gt=x*w,nt=ft+gt,st=Gt+nt;let It=i(o+(a-st)/2)+R+S;t.font=g.font,t.fillStyle=g.color,t.textAlign=g.align,t.textBaseline=g.baseline;for(let C=0;C<E.length;C++)t.fillText(E[C],b,It,v),It+=w;It+=Ut,t.font=B.font,t.fillStyle=B.color,t.textAlign=B.align,t.textBaseline=B.baseline,t.fillText(N,kt,It,ut);const he=e.border;if(he.width>0&&(t.strokeStyle=he.color,t.lineWidth=he.width,h>0?(Ve(t,s,o,r,a,h),t.stroke()):t.strokeRect(s,o,r,a)),d){const C=this.getIconBox(),q=i(C.left+C.width/2),tt=i(C.top+C.height/2),pt=i(Math.min(C.width,C.height)/2),mt=i(pt/2);let yt,wt;this.isStarred?this.isMouseOverStar?(yt="#8A8A8A",wt="#fff800"):(yt="#a5a5a5",wt="#fff800"):this.isMouseOverStar?(yt="#8A8A8A",wt="#dfdfdf"):(yt="#a5a5a5",wt="#ebebeb"),uo(t,q,tt,5,mt,pt,wt,yt)}},getWidth(){return this.getCurrentStyle().width},getHeight(){return this.getCurrentStyle().height},getConnectorEnd(){const t=this.getCurrentStyle(),e=Oi(this);return{left:e.left+t.connectorLine.offsetX,top:e.top+this.getHeight()+t.connectorLine.offsetY}},getIconBox(){var r,a,l,c;if(((c=(l=(a=(r=this.owner)==null?void 0:r.options)==null?void 0:a.article)==null?void 0:l.star)==null?void 0:c.visible)===!1)return!1;const t=this.getCurrentStyle(),e=Ri(this),i=t.star.width,n={width:i,height:i},o=t.borderRadius||0,s=Oi(this);return n.left=e(s.left-o/4+this._getWidth()-n.width-t.star.margin),n.top=e(s.top+o/4+t.star.margin),n},defaultStyle:{width:220,height:70,borderRadius:4,image:{shape:"square",margin:4,borderRadius:4},header:{text:{color:"#333",baseline:"alphabetic"}},subheader:{text:{color:"#777",baseline:"alphabetic"}}},defaultHoverStyle:{border:{color:"#a6c6e2"}},defaultActiveStyle:{header:{text:{color:"#000"}},subheader:{text:{color:"#333"}}}};function $e(t){var n,o,s,r,a,l;const e=((o=(n=t.owner)==null?void 0:n.getCanvasDpr)==null?void 0:o.call(n))||1,i=(l=(a=(r=(s=t.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.rendering)==null?void 0:l.pixelSnap;return rn(e,i)}function Ei(t){const e=$e(t);return{top:e(t.position.top),left:e(t.position.left)}}const Xa={name:"portrait",draw(t){var R,V,B,z,it,kt,ut,Ut;const e=this.getCurrentStyle(),i=$e(this),n=e.border.width,o=Math.max(n,((V=(R=this.hoverStyle)==null?void 0:R.border)==null?void 0:V.width)||0,((z=(B=this.activeStyle)==null?void 0:B.border)==null?void 0:z.width)||0),s=e.header.height,r=e.subheader.height,a=Ei(this),l={top:a.top,left:a.left,width:i(this._getWidth()),height:i(this._cachedHeight)},c=i(l.top+n/2),u=i(c+s),m=u+r,d=is(l,o,i);e.shadow&&(Hn(t,e.shadow),t.fillStyle=e.backgroundColor,t.fillRect(l.left,l.top+e.topRadius,l.width,l.height-e.topRadius),co(t)),t.save(),t.beginPath(),ho(t,l.left,l.top,l.width,l.height,e.topRadius),t.clip(),t.fillStyle=e.color,t.fillRect(l.left,l.top,l.width,i(s+n/2)),t.restore(),r!==0&&(t.fillStyle=e.subheader.color,t.fillRect(l.left,u,l.width,r),t.beginPath(),t.lineWidth=1,t.moveTo(d.left+5,u+1),t.lineTo(d.left+10,u-5),t.lineTo(d.left+15,u+1),t.closePath(),t.fill());const g=e.header.text.align;t.fillStyle=e.header.text.color,t.font=e.header.text.font,t.textAlign=g,t.textBaseline=e.header.text.baseline;const p=e.header.text.margin,w=e.header.text.lineHeight,b=d.width-p*2,v=e.header.text.numberOfLines,S=this.memo(`titleLines:${this.title}:${b}:${e.header.text.font}:${v}`,()=>{t.font=e.header.text.font;let N=Ze(this.title,t,b);return N.length>v&&(N=Ue(N,v,t,b)),this.titleLines=N,N}),M=Math.min(v,S.length),P=(M-1)*w,x=c+(s-P)/2,Z=fo(d.left,d.width,g,p,i);for(let N=0;N<M;N++){const dt=i(x+N*w);t.fillText(S[N],Z,dt,b)}if(e.subheader.height!==0){const N=e.subheader.text.align,dt=e.subheader.text.margin,ft=d.width-dt*2;t.textAlign=N,t.textBaseline=e.subheader.text.baseline,t.fillStyle=e.subheader.text.color,t.font=e.subheader.text.font;const gt=`${this.subtitle}`,Gt=this.memo(`subtitle:${gt}:${ft}:${e.subheader.text.font}`,()=>{t.font=e.subheader.text.font;const jt=Ze(gt,t,ft),It=jt.length>1?Ue(jt,1,t,ft)[0]:jt[0];return this.summarisedSubtitle=It,It}),nt=fo(d.left,d.width,N,dt,i),st=i(u+r/2);t.fillText(Gt,nt,st,ft)}if(this.imageLoaded){const N=e.image,dt=N.margin||0,ft=i(l.left+dt),gt=i(m+dt),Gt=Math.max(0,l.width-dt*2),nt=i(Gt);let st;const jt=N.shape||"square";switch(jt){case"circle":case"square":st=nt;break;default:const ot=nt/this.image.width,J=this.image.height*ot,Q=N.maxHeight||e.maxImageHeight||400;st=Math.min(J,Q);break}st=i(st),t.fillStyle=e.backgroundColor,t.fillRect(ft,gt,nt,st);const It=N.borderRadius||0,he=(ot,J,Q,at,C,q,tt,pt)=>{It>0?(t.save(),Ve(t,C,q,tt,pt,It),t.clip(),t.drawImage(this.image,ot,J,Q,at,C,q,tt,pt),t.restore()):t.drawImage(this.image,ot,J,Q,at,C,q,tt,pt)};switch(jt){case"circle":{let ot,J,Q,at;this.image.width>this.image.height?(ot=(this.image.width-this.image.height)/2,J=0,Q=at=this.image.height):(ot=0,J=(this.image.height-this.image.width)/2,Q=at=this.image.width);const C=nt,q=ft,tt=gt;mo(t,this.image,ot,J,Q,at,q,tt,C);break}case"square":{let ot,J,Q,at;this.image.width>this.image.height?(ot=(this.image.width-this.image.height)/2,J=0,Q=at=this.image.height):(ot=0,J=(this.image.height-this.image.width)/2,Q=at=this.image.width);const C=nt;he(ot,J,Q,at,ft,gt,C,C);break}default:{const ot=nt/this.image.width,J=this.image.height*ot,Q=N.maxHeight||e.maxImageHeight||400,at=0;let C=0;const q=this.image.width;let tt=this.image.height;const pt=nt,mt=st,yt=ft,wt=gt;if(J>Q){const ue=Q/J;tt=this.image.height*ue,C=Pe((this.image.height-tt)/2)}he(at,C,q,tt,yt,wt,pt,mt);break}}}if(e.border.width>0&&(t.beginPath(),ho(t,l.left,l.top,l.width,l.height,e.topRadius),t.lineWidth=e.border.width,t.strokeStyle=e.border.color,t.stroke()),((Ut=(ut=(kt=(it=this.owner)==null?void 0:it.options)==null?void 0:kt.article)==null?void 0:ut.star)==null?void 0:Ut.visible)!==!1&&(this.isActive||this.isStarred)){const N=this.getIconBox(),dt=i(N.left+N.width/2),ft=i(N.top+N.height/2),gt=i(Math.min(N.width,N.height)/2),Gt=i(gt/2);let nt,st;this.isStarred?this.isMouseOverStar?(nt="#8A8A8A",st="#fff800"):(nt="#a5a5a5",st="#fff800"):this.isMouseOverStar?(nt="#8A8A8A",st="#dfdfdf"):(nt="#a5a5a5",st="#ebebeb"),uo(t,dt,ft,5,Gt,gt,st,nt)}},getWidth(){return this.getCurrentStyle().width},getHeight(){const t=this.getCurrentStyle(),e=$e(this);let i=0;if(this.imageLoaded){const o=t.image,s=o.margin||0,r=o.shape||"square",a=e(t.width-t.border.width/2-s*2);switch(r){case"circle":case"square":i=a+s*2;break;default:const l=a/this.image.width,c=this.image.height*l,h=t.image.maxHeight||t.maxImageHeight||400;i=Math.min(c,h)+s*2;break}}const n=e(t.header.height+t.subheader.height);return i+n+t.border.width},getConnectorEnd(){const t=this.getCurrentStyle(),e=Ei(this);return{left:e.left+t.connectorLine.offsetX,top:e.top+this.getHeight()+t.connectorLine.offsetY}},getIconBox(){var s,r,a,l;if(((l=(a=(r=(s=this.owner)==null?void 0:s.options)==null?void 0:r.article)==null?void 0:a.star)==null?void 0:l.visible)===!1)return!1;const t=this.getCurrentStyle(),e=$e(this),i=Ei(this),n=t.star.width,o={width:n,height:n};return o.left=e(i.left-t.topRadius/4+this._getWidth()-o.width-t.star.margin),o.top=e(i.top+t.topRadius/4+t.star.margin),o}},Xe=new Map;function qa(t){return typeof t.getWidth!="function"&&(t.getWidth=function(){return this.getCurrentStyle().width}),typeof t.getHeight!="function"&&(t.getHeight=function(){return this.getCurrentStyle().height}),typeof t.getIconBox!="function"&&(t.getIconBox=function(){return!1}),t}function Ka(t){return t&&t.aliasOf?Xe.get(t.aliasOf):t}return f.registerCardLayout=function(e){if(!e||typeof e!="object")throw new Error("Card layout definition must be an object");const{name:i,draw:n,aliasOf:o}=e;if(!i||typeof i!="string")throw new Error("Card layout must have a unique string 'name'");if(o){Xe.set(i,{aliasOf:o});return}if(typeof n!="function")throw new Error(`Card layout "${i}" must implement draw(ctx)`);Xe.set(i,qa(W({},e)));const{defaultStyle:s,defaultHoverStyle:r,defaultActiveStyle:a}=e,l=mi.article.layoutStyles[i]={};s&&(l.style=ei({},s)),r&&(l.hoverStyle=ei({},r)),a&&(l.activeStyle=ei({},a))},f.getCardLayout=function(e){const i=Ka(Xe.get(e));return i||(T.warn(`Unknown card layout "${e}"`),null)},f.prototype._getCurrentCardLayoutName=function(){return this.options.article.defaultCardLayout},f.prototype.registerCardLayout=f.registerCardLayout,f.prototype.getCardLayout=f.getCardLayout,f.registerCardLayout(Xa),f.registerCardLayout($a),f.registerCardLayout({name:"default",aliasOf:"portrait"}),f.prototype.getStatusForSave=function(){const t=this.timescaleManager.startToken.value,e=[],i={};t.hour&&(i.fhr=t.hour),t.minute&&(i.fmi=t.minute),t.second&&(i.fs=t.second),t.millisecond&&(i.fms=t.millisecond);for(let n=0;n<this.articles.length;n++)e.push(this.articles[n].getStatusForSave());return JSON.stringify(zt(W({t:this.title,o:this.ownerId,z:this.timescaleManager.zoom,fy:t.year,fm:t.month,fd:t.day},i),{w:this.repositionWindow,a:e}))},f.prototype._emitTimelineStateChange=function(){this&&this._isInitialized===!0&&(this._hasPendingTimelineStateChange=!1,this.trigger("timeline-state-change",this.getStatusForSave()))},f.prototype._markTimelineStateChanged=function(){this&&this._isInitialized===!0&&(this._hasPendingTimelineStateChange=!0)},f.prototype._flushTimelineStateChange=function(){this&&this._hasPendingTimelineStateChange===!0&&this._emitTimelineStateChange()},zt(W(W({Timeline:f,Article:I,Chart:ct,Lane:et,TimeBand:Dt,Dmy:y},Xo),hs),{Logger:T,setDebug(t){T.setEnabled(!!t)},isDebugEnabled(){return T.isEnabled()},enableDebug(){T.setEnabled(!0)},disableDebug(){T.setEnabled(!1)}})}));