From b0f0016477a46bcc156fea2f08f67117b1b19b73 Mon Sep 17 00:00:00 2001 From: Dan Danache Date: Wed, 14 Aug 2024 21:41:46 +0300 Subject: [PATCH] Add option to configure grid cell height --- watchtower-app/CHANGELOG.md | 1 + watchtower-app/packageManifest.json | 2 +- .../src/components/dashboard-grid.js | 4 + .../src/components/dashboard-menu.js | 64 ++++++++++++- .../src/components/watchtower-app.js | 16 +++- watchtower-app/watchtower.groovy | 1 + watchtower-app/watchtower.js | 94 ++++++++++++++----- 7 files changed, 154 insertions(+), 28 deletions(-) diff --git a/watchtower-app/CHANGELOG.md b/watchtower-app/CHANGELOG.md index b3a78b1..fd97cf2 100644 --- a/watchtower-app/CHANGELOG.md +++ b/watchtower-app/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.3.0] - 2024-08-15 ### Added - Hub Info tile: add platform update available and alerts notifications - `@amithalp` +- Add option to configure grid cell height ### Changed - Hub Info tile: add more hub details and make the widget configurable - `@amithalp` diff --git a/watchtower-app/packageManifest.json b/watchtower-app/packageManifest.json index f2ae69b..4b58292 100644 --- a/watchtower-app/packageManifest.json +++ b/watchtower-app/packageManifest.json @@ -1,7 +1,7 @@ { "packageName": "Watchtower", "version": "1.3.0", - "releaseNotes": "v1.3.0\n - Added: Hub Info tile: add platform update available and alerts notifications - @amithalp\n - Changed: Hub Info tile: add more hub details and make the widget configurable - @amithalp\n - Fixed: Fix Iframe tile margins - @amithalp", + "releaseNotes": "v1.3.0\n - Added: Hub Info tile: add platform update available and alerts notifications - @amithalp\n - Added: Add option to configure grid cell height\n - Changed: Hub Info tile: add more hub details and make the widget configurable - @amithalp\n - Fixed: Fix Iframe tile margins - @amithalp", "minimumHEVersion": "2.1.9", "author": "Dan Danache (@dandanache)", "dateReleased": "2024-08-15", diff --git a/watchtower-app/src/components/dashboard-grid.js b/watchtower-app/src/components/dashboard-grid.js index dbecf89..0c4833d 100644 --- a/watchtower-app/src/components/dashboard-grid.js +++ b/watchtower-app/src/components/dashboard-grid.js @@ -168,6 +168,10 @@ export class DashboardGrid extends LitElement { this.renderRoot.querySelectorAll('device-panel, attribute-panel').forEach(panel => panel.setYScale(yScale)) } + setCellHeight(cellHeight) { + this.grid.cellHeight(cellHeight, true) + } + addPanel(config, w = 2, h = 1, x = undefined, y = undefined) { const content = `
diff --git a/watchtower-app/src/components/dashboard-menu.js b/watchtower-app/src/components/dashboard-menu.js index 4a2973a..39af6d2 100644 --- a/watchtower-app/src/components/dashboard-menu.js +++ b/watchtower-app/src/components/dashboard-menu.js @@ -66,7 +66,7 @@ export class DashboardMenu extends LitElement { display: block; width: 100%; margin-bottom: 5px; - padding: .5em; + height: 30px; background-color: var(--bg-color-darker); color: var(--text-color); border: 1px var(--border-color) solid; @@ -74,7 +74,7 @@ export class DashboardMenu extends LitElement { } select:focus, button:focus { outline: 1px var(--Blue) solid; - border-color: var(--Blue) + border-color: var(--Blue); } aside { color: var(--text-color-darker); @@ -85,6 +85,49 @@ export class DashboardMenu extends LitElement { user-select: none; font-size: .75rem; } + form { + border: 1px solid grey; + padding: 0; + background-color: var(--bg-color-darker); + color: var(--text-color); + border: 1px var(--border-color) solid; + border-radius: 5px; + position: relative; + display: block; + width: 100%; + } + form input[type="text"] { + box-sizing: border-box; + border: none; + color: var(--text-color); + background-color: transparent; + padding-right: 30px; + padding-left: 5px; + width: 100%; + height: 28px; + } + form input:focus { + outline: none; + } + form:focus-within { + border-color: var(--Blue); + outline: 1px solid var(--Blue); + } + form:invalid { + border-color: var(--Red); + outline: 1px solid var(--Red); + } + form input[type="submit"] { + border: none; + color: var(--text-color); + background-color: transparent; + position: absolute; + top: 50%; + right: 0px; + transform: translateY(-50%); + cursor: pointer; + width: 30px; + } `; static properties = { @@ -92,6 +135,7 @@ export class DashboardMenu extends LitElement { refreshInterval: { type: String, state: true }, theme: { type: String, state: true }, yScale: { type: String, state: true }, + cellHeight: { type: Number, state: true }, mobileView: { type: Boolean, state: true } } @@ -101,6 +145,7 @@ export class DashboardMenu extends LitElement { this.refreshInterval = '0' this.theme = 'light' this.yScale = 'auto' + this.cellHeight = 206 } render() { @@ -129,6 +174,14 @@ export class DashboardMenu extends LitElement { + +
+ + +
${this.mobileView ? nothing: html`
@@ -162,6 +215,7 @@ export class DashboardMenu extends LitElement { theme: this.theme, refresh: this.refreshInterval, yScale: this.yScale, + cellHeight: this.cellHeight, }})) } @@ -178,6 +232,12 @@ export class DashboardMenu extends LitElement { this.yScale = event.target.value this.dispatchEvent(new CustomEvent('changeYScale', { detail: this.yScale })) } + changeCellHeight(event) { + event.preventDefault() + const formProps = Object.fromEntries(new FormData(event.target)) + this.cellHeight = parseInt(formProps.cellHeight) + this.dispatchEvent(new CustomEvent('changeCellHeight', { detail: this.cellHeight })) + } setTheme(theme) { this.theme = theme diff --git a/watchtower-app/src/components/watchtower-app.js b/watchtower-app/src/components/watchtower-app.js index c235441..d5f6969 100644 --- a/watchtower-app/src/components/watchtower-app.js +++ b/watchtower-app/src/components/watchtower-app.js @@ -58,8 +58,9 @@ export class WatchtowerApp extends LitElement { @@ -81,6 +82,7 @@ export class WatchtowerApp extends LitElement { const refreshInterval = layout.refresh ? parseInt(layout.refresh) : 0 const theme = layout.theme === 'dark' ? 'dark' : 'light' const yScale = layout.yScale == 'fixed' ? 'fixed' : 'auto' + const cellHeight = layout.cellHeight ? parseInt(layout.cellHeight) : 206 // Show menu if dashboard contains no panels if (layout.panels.length === 0) this.menuElm.open = true @@ -90,10 +92,12 @@ export class WatchtowerApp extends LitElement { this.gridElm.init(layout.panels) this.gridElm.setRefreshInterval(refreshInterval) this.gridElm.setYScale(yScale) + this.gridElm.setCellHeight(cellHeight) // Update menu this.menuElm.refreshInterval = refreshInterval this.menuElm.yScale = yScale + this.menuElm.cellHeight = cellHeight this.menuElm.setTheme(theme) // Apply mobile view @@ -137,12 +141,16 @@ export class WatchtowerApp extends LitElement { this.gridElm.addPanel(event.detail) } - changeRefreshInterval(event) { + applyRefreshInterval(event) { const refreshInterval = parseInt(event.detail) this.gridElm.setRefreshInterval(refreshInterval) } - changeYScale(event) { + applyYScale(event) { this.gridElm.setYScale(event.detail) } + + applyCellHeight(event) { + this.gridElm.setCellHeight(event.detail) + } } diff --git a/watchtower-app/watchtower.groovy b/watchtower-app/watchtower.groovy index aeaa07f..6fd9d6f 100644 --- a/watchtower-app/watchtower.groovy +++ b/watchtower-app/watchtower.groovy @@ -663,6 +663,7 @@ Map changelog() { paragraph '''\ diff --git a/watchtower-app/watchtower.js b/watchtower-app/watchtower.js index 725a291..5f30f39 100644 --- a/watchtower-app/watchtower.js +++ b/watchtower-app/watchtower.js @@ -1,13 +1,13 @@ -(()=>{var ys=(D=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(D,{get:(h,f)=>(typeof require<"u"?require:h)[f]}):D)(function(D){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+D+'" is not supported')});var Sn=globalThis,Io=Sn.ShadowRoot&&(Sn.ShadyCSS===void 0||Sn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ho=Symbol(),Aa=new WeakMap,Cn=class{constructor(h,f,C){if(this._$cssResult$=!0,C!==Ho)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=h,this.t=f}get styleSheet(){let h=this.i,f=this.t;if(Io&&h===void 0){let C=f!==void 0&&f.length===1;C&&(h=Aa.get(f)),h===void 0&&((this.i=h=new CSSStyleSheet).replaceSync(this.cssText),C&&Aa.set(f,h))}return h}toString(){return this.cssText}},Mh=D=>new Cn(typeof D=="string"?D:D+"",void 0,Ho),Xe=(D,...h)=>{let f=D.length===1?D[0]:h.reduce((C,H,X)=>C+(W=>{if(W._$cssResult$===!0)return W.cssText;if(typeof W=="number")return W;throw Error("Value passed to 'css' function must be a 'css' function result: "+W+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(H)+D[X+1],D[0]);return new Cn(f,D,Ho)},Sh=(D,h)=>{if(Io)D.adoptedStyleSheets=h.map(f=>f instanceof CSSStyleSheet?f:f.styleSheet);else for(let f of h){let C=document.createElement("style"),H=Sn.litNonce;H!==void 0&&C.setAttribute("nonce",H),C.textContent=f.cssText,D.appendChild(C)}},Ra=Io?D=>D:D=>D instanceof CSSStyleSheet?(h=>{let f="";for(let C of h.cssRules)f+=C.cssText;return Mh(f)})(D):D,{is:Ch,defineProperty:Th,getOwnPropertyDescriptor:Eh,getOwnPropertyNames:Dh,getOwnPropertySymbols:Ph,getPrototypeOf:Ah}=Object,Hn=globalThis,Oa=Hn.trustedTypes,Rh=Oa?Oa.emptyScript:"",Oh=Hn.reactiveElementPolyfillSupport,Js=(D,h)=>D,Oo={toAttribute(D,h){switch(h){case Boolean:D=D?Rh:null;break;case Object:case Array:D=D==null?D:JSON.stringify(D)}return D},fromAttribute(D,h){let f=D;switch(h){case Boolean:f=D!==null;break;case Number:f=D===null?null:Number(D);break;case Object:case Array:try{f=JSON.parse(D)}catch{f=null}}return f}},Xa=(D,h)=>!Ch(D,h),za={attribute:!0,type:String,converter:Oo,reflect:!1,hasChanged:Xa};Symbol.metadata??=Symbol("metadata"),Hn.litPropertyMetadata??=new WeakMap;var vs=class extends HTMLElement{static addInitializer(h){this.o(),(this.l??=[]).push(h)}static get observedAttributes(){return this.finalize(),this.u&&[...this.u.keys()]}static createProperty(h,f=za){if(f.state&&(f.attribute=!1),this.o(),this.elementProperties.set(h,f),!f.noAccessor){let C=Symbol(),H=this.getPropertyDescriptor(h,C,f);H!==void 0&&Th(this.prototype,h,H)}}static getPropertyDescriptor(h,f,C){let{get:H,set:X}=Eh(this.prototype,h)??{get(){return this[f]},set(W){this[f]=W}};return{get(){return H?.call(this)},set(W){let at=H?.call(this);X.call(this,W),this.requestUpdate(h,at,C)},configurable:!0,enumerable:!0}}static getPropertyOptions(h){return this.elementProperties.get(h)??za}static o(){if(this.hasOwnProperty(Js("elementProperties")))return;let h=Ah(this);h.finalize(),h.l!==void 0&&(this.l=[...h.l]),this.elementProperties=new Map(h.elementProperties)}static finalize(){if(this.hasOwnProperty(Js("finalized")))return;if(this.finalized=!0,this.o(),this.hasOwnProperty(Js("properties"))){let f=this.properties,C=[...Dh(f),...Ph(f)];for(let H of C)this.createProperty(H,f[H])}let h=this[Symbol.metadata];if(h!==null){let f=litPropertyMetadata.get(h);if(f!==void 0)for(let[C,H]of f)this.elementProperties.set(C,H)}this.u=new Map;for(let[f,C]of this.elementProperties){let H=this.p(f,C);H!==void 0&&this.u.set(H,f)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(h){let f=[];if(Array.isArray(h)){let C=new Set(h.flat(1/0).reverse());for(let H of C)f.unshift(Ra(H))}else h!==void 0&&f.push(Ra(h));return f}static p(h,f){let C=f.attribute;return C===!1?void 0:typeof C=="string"?C:typeof h=="string"?h.toLowerCase():void 0}constructor(){super(),this.v=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this.m=null,this._()}_(){this.S=new Promise(h=>this.enableUpdating=h),this._$AL=new Map,this.$(),this.requestUpdate(),this.constructor.l?.forEach(h=>h(this))}addController(h){(this.P??=new Set).add(h),this.renderRoot!==void 0&&this.isConnected&&h.hostConnected?.()}removeController(h){this.P?.delete(h)}$(){let h=new Map,f=this.constructor.elementProperties;for(let C of f.keys())this.hasOwnProperty(C)&&(h.set(C,this[C]),delete this[C]);h.size>0&&(this.v=h)}createRenderRoot(){let h=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Sh(h,this.constructor.elementStyles),h}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this.P?.forEach(h=>h.hostConnected?.())}enableUpdating(h){}disconnectedCallback(){this.P?.forEach(h=>h.hostDisconnected?.())}attributeChangedCallback(h,f,C){this._$AK(h,C)}C(h,f){let C=this.constructor.elementProperties.get(h),H=this.constructor.p(h,C);if(H!==void 0&&C.reflect===!0){let X=(C.converter?.toAttribute!==void 0?C.converter:Oo).toAttribute(f,C.type);this.m=h,X==null?this.removeAttribute(H):this.setAttribute(H,X),this.m=null}}_$AK(h,f){let C=this.constructor,H=C.u.get(h);if(H!==void 0&&this.m!==H){let X=C.getPropertyOptions(H),W=typeof X.converter=="function"?{fromAttribute:X.converter}:X.converter?.fromAttribute!==void 0?X.converter:Oo;this.m=H,this[H]=W.fromAttribute(f,X.type),this.m=null}}requestUpdate(h,f,C){if(h!==void 0){if(C??=this.constructor.getPropertyOptions(h),!(C.hasChanged??Xa)(this[h],f))return;this.T(h,f,C)}this.isUpdatePending===!1&&(this.S=this.A())}T(h,f,C){this._$AL.has(h)||this._$AL.set(h,f),C.reflect===!0&&this.m!==h&&(this.M??=new Set).add(h)}async A(){this.isUpdatePending=!0;try{await this.S}catch(f){Promise.reject(f)}let h=this.scheduleUpdate();return h!=null&&await h,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this.v){for(let[H,X]of this.v)this[H]=X;this.v=void 0}let C=this.constructor.elementProperties;if(C.size>0)for(let[H,X]of C)X.wrapped!==!0||this._$AL.has(H)||this[H]===void 0||this.T(H,this[H],X)}let h=!1,f=this._$AL;try{h=this.shouldUpdate(f),h?(this.willUpdate(f),this.P?.forEach(C=>C.hostUpdate?.()),this.update(f)):this.k()}catch(C){throw h=!1,this.k(),C}h&&this._$AE(f)}willUpdate(h){}_$AE(h){this.P?.forEach(f=>f.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(h)),this.updated(h)}k(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.S}shouldUpdate(h){return!0}update(h){this.M&&=this.M.forEach(f=>this.C(f,this[f])),this.k()}updated(h){}firstUpdated(h){}};vs.elementStyles=[],vs.shadowRootOptions={mode:"open"},vs[Js("elementProperties")]=new Map,vs[Js("finalized")]=new Map,Oh?.({ReactiveElement:vs}),(Hn.reactiveElementVersions??=[]).push("2.0.4");var No=globalThis,Tn=No.trustedTypes,La=Tn?Tn.createPolicy("lit-html",{createHTML:D=>D}):void 0,$o="$lit$",cs=`lit$${Math.random().toFixed(9).slice(2)}$`,Fo="?"+cs,zh=`<${Fo}>`,Ps=document,en=()=>Ps.createComment(""),sn=D=>D===null||typeof D!="object"&&typeof D!="function",Ga=Array.isArray,Qa=D=>Ga(D)||typeof D?.[Symbol.iterator]=="function",Po=`[ -\f\r]`,Zs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ia=/-->/g,Ha=/>/g,Es=RegExp(`>|${Po}(?:([^\\s"'>=/]+)(${Po}*=${Po}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),Na=/'/g,$a=/"/g,Ka=/^(?:script|style|textarea|title)$/i,Za=D=>(h,...f)=>({_$litType$:D,strings:h,values:f}),Kt=Za(1),Lh=Za(2),Fe=Symbol.for("lit-noChange"),ee=Symbol.for("lit-nothing"),Fa=new WeakMap,Ds=Ps.createTreeWalker(Ps,129);function Ja(D,h){if(!Array.isArray(D)||!D.hasOwnProperty("raw"))throw Error("invalid template strings array");return La!==void 0?La.createHTML(h):h}var tl=(D,h)=>{let f=D.length-1,C=[],H,X=h===2?"":"",W=Zs;for(let at=0;at"?(W=H??Zs,ft=-1):Ot[1]===void 0?ft=-2:(ft=W.lastIndex-Ot[2].length,Rt=Ot[1],W=Ot[3]===void 0?Es:Ot[3]==='"'?$a:Na):W===$a||W===Na?W=Es:W===Ia||W===Ha?W=Zs:(W=Es,H=void 0);let jt=W===Es&&D[at+1].startsWith("/>")?" ":"";X+=W===Zs?q+zh:ft>=0?(C.push(Rt),q.slice(0,ft)+$o+q.slice(ft)+cs+jt):q+cs+(ft===-2?at:jt)}return[Ja(D,X+(D[f]||"")+(h===2?"":"")),C]},nn=class D{constructor({strings:h,_$litType$:f},C){let H;this.parts=[];let X=0,W=0,at=h.length-1,q=this.parts,[Rt,Ot]=tl(h,f);if(this.el=D.createElement(Rt,C),Ds.currentNode=this.el.content,f===2){let ft=this.el.content.firstChild;ft.replaceWith(...ft.childNodes)}for(;(H=Ds.nextNode())!==null&&q.length0){H.textContent=Tn?Tn.emptyScript:"";for(let jt=0;jt2||C[0]!==""||C[1]!==""?(this._$AH=Array(C.length-1).fill(new String),this.strings=C):this._$AH=ee}_$AI(h,f=this,C,H){let X=this.strings,W=!1;if(X===void 0)h=As(this,h,f,0),W=!sn(h)||h!==this._$AH&&h!==Fe,W&&(this._$AH=h);else{let at=h,q,Rt;for(h=X[0],q=0;q{let C=f?.renderBefore??h,H=C._$litPart$;if(H===void 0){let X=f?.renderBefore??null;C._$litPart$=H=new Nn(h.insertBefore(en(),X),X,void 0,f??{})}return H._$AI(D),H};var ke=class extends vs{constructor(){super(...arguments),this.renderOptions={host:this},this.ht=void 0}createRenderRoot(){let h=super.createRenderRoot();return this.renderOptions.renderBefore??=h.firstChild,h}update(h){let f=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(h),this.ht=il(f,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.ht?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.ht?.setConnected(!1)}render(){return Fe}};ke._$litElement$=!0,ke.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:ke});var Nh=globalThis.litElementPolyfillSupport;Nh?.({LitElement:ke});(globalThis.litElementVersions??=[]).push("4.0.6");var{Y:$h}=Ih,Fh=D=>D===null||typeof D!="object"&&typeof D!="function";var Wa=(D,h)=>h===void 0?D?._$litType$!==void 0:D?._$litType$===h,Wh=D=>D?._$litType$?.h!=null;var sl=D=>D.strings===void 0,Ba=()=>document.createComment(""),ws=(D,h,f)=>{let C=D._$AA.parentNode,H=h===void 0?D._$AB:h._$AA;if(f===void 0){let X=C.insertBefore(Ba(),H),W=C.insertBefore(Ba(),H);f=new $h(X,W,D,D.options)}else{let X=f._$AB.nextSibling,W=f._$AM,at=W!==D;if(at){let q;f._$AQ?.(D),f._$AM=D,f._$AP!==void 0&&(q=D._$AU)!==W._$AU&&f._$AP(q)}if(X!==H||at){let q=f._$AA;for(;q!==X;){let Rt=q.nextSibling;C.insertBefore(q,H),q=Rt}}}return f},xs=(D,h,f=D)=>(D._$AI(h,f),D),Bh={},on=(D,h=Bh)=>D._$AH=h,zo=D=>D._$AH,Ao=D=>{D._$AP?.(!1,!0);let h=D._$AA,f=D._$AB.nextSibling;for(;h!==f;){let C=h.nextSibling;h.remove(),h=C}},nl=D=>{D._$AR()};var Ti=D=>(...h)=>({_$litDirective$:D,values:h}),Bi=class{constructor(h){}get _$AU(){return this._$AM._$AU}_$AT(h,f,C){this.nt=h,this._$AM=f,this.rt=C}_$AS(h,f){return this.update(h,f)}update(h,f){return this.render(...f)}};var tn=(D,h)=>{let f=D._$AN;if(f===void 0)return!1;for(let C of f)C._$AO?.(h,!1),tn(C,h);return!0},On=D=>{let h,f;do{if((h=D._$AM)===void 0)break;f=h._$AN,f.delete(D),D=h}while(f?.size===0)},ol=D=>{for(let h;h=D._$AM;D=h){let f=h._$AN;if(f===void 0)h._$AN=f=new Set;else if(f.has(D))break;f.add(D),Vh(h)}};function Uh(D){this._$AN!==void 0?(On(this),this._$AM=D,ol(this)):this._$AM=D}function jh(D,h=!1,f=0){let C=this._$AH,H=this._$AN;if(H!==void 0&&H.size!==0)if(h)if(Array.isArray(C))for(let X=f;X{D.type==2&&(D._$AP??=jh,D._$AQ??=Uh)},rn=class extends Bi{constructor(){super(...arguments),this._$AN=void 0}_$AT(h,f,C){super._$AT(h,f,C),ol(this),this.isConnected=h._$AU}_$AO(h,f=!0){h!==this.isConnected&&(this.isConnected=h,h?this.reconnected?.():this.disconnected?.()),f&&(tn(this,h),On(this))}setValue(h){if(sl(this.nt))this.nt._$AI(h,this);else{let f=[...this.nt._$AH];f[this.rt]=h,this.nt._$AI(f,this,0)}}disconnected(){}reconnected(){}};var zn=class{constructor(h){this.ct=h}disconnect(){this.ct=void 0}reconnect(h){this.ct=h}deref(){return this.ct}},Ln=class{constructor(){this.lt=void 0,this.ut=void 0}get(){return this.lt}pause(){this.lt??=new Promise(h=>this.ut=h)}resume(){this.ut?.(),this.lt=this.ut=void 0}};var In=class extends rn{constructor(){super(...arguments),this.dt=new zn(this),this.ft=new Ln}render(h,f){return Fe}update(h,[f,C]){if(this.isConnected||this.disconnected(),f===this.vt)return Fe;this.vt=f;let H=0,{dt:X,ft:W}=this;return(async(at,q)=>{for await(let Rt of at)if(await q(Rt)===!1)return})(f,async at=>{for(;W.get();)await W.get();let q=X.deref();if(q!==void 0){if(q.vt!==f)return!1;C!==void 0&&(at=C(at,H)),q.commitValue(at,H),H++}return!0}),Fe}commitValue(h,f){this.setValue(h)}disconnected(){this.dt.disconnect(),this.ft.pause()}reconnected(){this.dt.reconnect(this),this.ft.resume()}},Kh=Ti(In),Zh=Ti(class extends In{constructor(D){if(super(D),D.type!==2)throw Error("asyncAppend can only be used in child expressions")}update(D,h){return this.ht=D,super.update(D,h)}commitValue(D,h){h===0&&nl(this.ht);let f=ws(this.ht);xs(f,D)}}),Ua=D=>Wh(D)?D._$litType$.h:D.strings,Jh=Ti(class extends Bi{constructor(D){super(D),this.yt=new WeakMap}render(D){return[D]}update(D,[h]){let f=Wa(this.bt)?Ua(this.bt):null,C=Wa(h)?Ua(h):null;if(f!==null&&(C===null||f!==C)){let H=zo(D).pop(),X=this.yt.get(f);if(X===void 0){let W=document.createDocumentFragment();X=il(ee,W),X.setConnected(!1),this.yt.set(f,X)}on(X,[H]),ws(X,void 0,H)}if(C!==null){if(f===null||f!==C){let H=this.yt.get(C);if(H!==void 0){let X=zo(H).pop();nl(D),ws(D,void 0,X),on(D,[X])}}this.bt=h}else this.bt=void 0;return this.render(h)}});var tc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==1||D.name!=="class"||D.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(D){return" "+Object.keys(D).filter(h=>D[h]).join(" ")+" "}update(D,[h]){if(this.gt===void 0){this.gt=new Set,D.strings!==void 0&&(this.wt=new Set(D.strings.join(" ").split(/\s/).filter(C=>C!=="")));for(let C in h)h[C]&&!this.wt?.has(C)&&this.gt.add(C);return this.render(h)}let f=D.element.classList;for(let C of this.gt)C in h||(f.remove(C),this.gt.delete(C));for(let C in h){let H=!!h[C];H===this.gt.has(C)||this.wt?.has(C)||(H?(f.add(C),this.gt.add(C)):(f.remove(C),this.gt.delete(C)))}return Fe}}),Yh={},ec=Ti(class extends Bi{constructor(){super(...arguments),this._t=Yh}render(D,h){return h()}update(D,[h,f]){if(Array.isArray(h)){if(Array.isArray(this._t)&&this._t.length===h.length&&h.every((C,H)=>C===this._t[H]))return Fe}else if(this._t===h)return Fe;return this._t=Array.isArray(h)?Array.from(h):h,this.render(h,f)}});var ic=Ti(class extends Bi{constructor(){super(...arguments),this.key=ee}render(D,h){return this.key=D,h}update(D,[h,f]){return h!==this.key&&(on(D),this.key=h),f}}),sc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==3&&D.type!==1&&D.type!==4)throw Error("The `live` directive is not allowed on child or event bindings");if(!sl(D))throw Error("`live` bindings can only contain a single expression")}render(D){return D}update(D,[h]){if(h===Fe||h===ee)return h;let f=D.element,C=D.name;if(D.type===3){if(h===f[C])return Fe}else if(D.type===4){if(!!h===f.hasAttribute(C))return Fe}else if(D.type===1&&f.getAttribute(C)===h+"")return Fe;return on(D),h}});var Ro=new WeakMap,nc=Ti(class extends rn{render(D){return ee}update(D,[h]){let f=h!==this.ct;return f&&this.ct!==void 0&&this.St(void 0),(f||this.$t!==this.Tt)&&(this.ct=h,this.xt=D.options?.host,this.St(this.Tt=D.element)),ee}St(D){if(this.isConnected||(D=void 0),typeof this.ct=="function"){let h=this.xt??globalThis,f=Ro.get(h);f===void 0&&(f=new WeakMap,Ro.set(h,f)),f.get(this.ct)!==void 0&&this.ct.call(this.xt,void 0),f.set(this.ct,D),D!==void 0&&this.ct.call(this.xt,D)}else this.ct.value=D}get $t(){return typeof this.ct=="function"?Ro.get(this.xt??globalThis)?.get(this.ct):this.ct?.value}disconnected(){this.$t===this.Tt&&this.St(void 0)}reconnected(){this.St(this.Tt)}}),ja=(D,h,f)=>{let C=new Map;for(let H=h;H<=f;H++)C.set(D[H],H);return C},oc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==2)throw Error("repeat() can only be used in text expressions")}Et(D,h,f){let C;f===void 0?f=h:h!==void 0&&(C=h);let H=[],X=[],W=0;for(let at of D)H[W]=C?C(at,W):W,X[W]=f(at,W),W++;return{values:X,keys:H}}render(D,h,f){return this.Et(D,h,f).values}update(D,[h,f,C]){let H=zo(D),{values:X,keys:W}=this.Et(h,f,C);if(!Array.isArray(H))return this.Ct=W,X;let at=this.Ct??=[],q=[],Rt,Ot,ft=0,xt=H.length-1,jt=0,te=X.length-1;for(;ft<=xt&&jt<=te;)if(H[ft]===null)ft++;else if(H[xt]===null)xt--;else if(at[ft]===W[jt])q[jt]=xs(H[ft],X[jt]),ft++,jt++;else if(at[xt]===W[te])q[te]=xs(H[xt],X[te]),xt--,te--;else if(at[ft]===W[te])q[te]=xs(H[ft],X[te]),ws(D,q[te+1],H[ft]),ft++,te--;else if(at[xt]===W[jt])q[jt]=xs(H[xt],X[jt]),ws(D,H[ft],H[xt]),xt--,jt++;else if(Rt===void 0&&(Rt=ja(W,jt,te),Ot=ja(at,ft,xt)),Rt.has(at[ft]))if(Rt.has(at[xt])){let ae=Ot.get(W[jt]),Ae=ae!==void 0?H[ae]:null;if(Ae===null){let ue=ws(D,H[ft]);xs(ue,X[jt]),q[jt]=ue}else q[jt]=xs(Ae,X[jt]),ws(D,H[ft],Ae),H[ae]=null;jt++}else Ao(H[xt]),xt--;else Ao(H[ft]),ft++;for(;jt<=te;){let ae=ws(D,q[te+1]);xs(ae,X[jt]),q[jt++]=ae}for(;ft<=xt;){let ae=H[ft++];ae!==null&&Ao(ae)}return this.Ct=W,on(D,q),Fe}}),rl="important",qh=" !"+rl,rc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==1||D.name!=="style"||D.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(D){return Object.keys(D).reduce((h,f)=>{let C=D[f];return C==null?h:h+`${f=f.includes("-")?f:f.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${C};`},"")}update(D,[h]){let{style:f}=D.element;if(this.Pt===void 0)return this.Pt=new Set(Object.keys(h)),this.render(h);for(let C of this.Pt)h[C]==null&&(this.Pt.delete(C),C.includes("-")?f.removeProperty(C):f[C]=null);for(let C in h){let H=h[C];if(H!=null){this.Pt.add(C);let X=typeof H=="string"&&H.endsWith(qh);C.includes("-")||X?f.setProperty(C,X?H.slice(0,-11):H,X?rl:""):f[C]=H}}return Fe}}),ac=Ti(class extends Bi{constructor(D){if(super(D),D.type!==2)throw Error("templateContent can only be used in child bindings")}render(D){return this.At===D?Fe:(this.At=D,document.importNode(D.content,!0))}}),Ns=class extends Bi{constructor(h){if(super(h),this.bt=ee,h.type!==2)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(h){if(h===ee||h==null)return this.kt=void 0,this.bt=h;if(h===Fe)return h;if(typeof h!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(h===this.bt)return this.kt;this.bt=h;let f=[h];return f.raw=f,this.kt={_$litType$:this.constructor.resultType,strings:f,values:[]}}};Ns.directiveName="unsafeHTML",Ns.resultType=1;var $n=Ti(Ns);var an=class extends Ns{};an.directiveName="unsafeSVG",an.resultType=2;var lc=Ti(an),Va=D=>!Fh(D)&&typeof D.then=="function",Ya=1073741823;var Lo=class extends rn{constructor(){super(...arguments),this.Mt=Ya,this.Ut=[],this.dt=new zn(this),this.ft=new Ln}render(...h){return h.find(f=>!Va(f))??Fe}update(h,f){let C=this.Ut,H=C.length;this.Ut=f;let X=this.dt,W=this.ft;this.isConnected||this.disconnected();for(let at=0;atthis.Mt);at++){let q=f[at];if(!Va(q))return this.Mt=at,q;at{for(;W.get();)await W.get();let Ot=X.deref();if(Ot!==void 0){let ft=Ot.Ut.indexOf(q);ft>-1&&ft{if(D?.r===Xh)return D?._$litStatic$};var qa=new Map,al=D=>(h,...f)=>{let C=f.length,H,X,W=[],at=[],q,Rt=0,Ot=!1;for(;Rt(()=>{"use strict";var D={d:(St,r)=>{for(var d in r)D.o(r,d)&&!D.o(St,d)&&Object.defineProperty(St,d,{enumerable:!0,get:r[d]})},o:(St,r)=>Object.prototype.hasOwnProperty.call(St,r)},h={};D.d(h,{GridStack:()=>Bt});class f{static getElements(r,d=document){if(typeof r=="string"){let y="getElementById"in d?d:void 0;if(y&&!isNaN(+r[0])){let P=y.getElementById(r);return P?[P]:[]}let v=d.querySelectorAll(r);return v.length||r[0]==="."||r[0]==="#"||(v=d.querySelectorAll("."+r),v.length||(v=d.querySelectorAll("#"+r))),Array.from(v)}return[r]}static getElement(r,d=document){if(typeof r=="string"){let y="getElementById"in d?d:void 0;if(!r.length)return null;if(y&&r[0]==="#")return y.getElementById(r.substring(1));if(r[0]==="#"||r[0]==="."||r[0]==="[")return d.querySelector(r);if(y&&!isNaN(+r[0]))return y.getElementById(r);let v=d.querySelector(r);return y&&!v&&(v=y.getElementById(r)),v||(v=d.querySelector("."+r)),v}return r}static shouldSizeToContent(r,d=!1){return r?.grid&&(d?r.sizeToContent===!0||r.grid.opts.sizeToContent===!0&&r.sizeToContent===void 0:!!r.sizeToContent||r.grid.opts.sizeToContent&&r.sizeToContent!==!1)}static isIntercepted(r,d){return!(r.y>=d.y+d.h||r.y+r.h<=d.y||r.x+r.w<=d.x||r.x>=d.x+d.w)}static isTouching(r,d){return f.isIntercepted(r,{x:d.x-.5,y:d.y-.5,w:d.w+1,h:d.h+1})}static areaIntercept(r,d){let y=r.x>d.x?r.x:d.x,v=r.x+r.wd.y?r.y:d.y,F=r.y+r.h{let F=d*((v.y??1e4)-(P.y??1e4));return F===0?d*((v.x??1e4)-(P.x??1e4)):F})}static find(r,d){return d?r.find(y=>y.id===d):void 0}static createStylesheet(r,d,y){let v=document.createElement("style"),P=y?.nonce;return P&&(v.nonce=P),v.setAttribute("type","text/css"),v.setAttribute("gs-style-id",r),v.styleSheet?v.styleSheet.cssText="":v.appendChild(document.createTextNode("")),d?d.insertBefore(v,d.firstChild):(d=document.getElementsByTagName("head")[0]).appendChild(v),v.sheet}static removeStylesheet(r,d){let y=(d||document).querySelector("STYLE[gs-style-id="+r+"]");y&&y.parentNode&&y.remove()}static addCSSRule(r,d,y){typeof r.addRule=="function"?r.addRule(d,y):typeof r.insertRule=="function"&&r.insertRule(`${d}{${y}}`)}static toBool(r){return typeof r=="boolean"?r:typeof r=="string"?!((r=r.toLowerCase())===""||r==="no"||r==="false"||r==="0"):!!r}static toNumber(r){return r===null||r.length===0?void 0:Number(r)}static parseHeight(r){let d,y="px";if(typeof r=="string")if(r==="auto"||r==="")d=0;else{let v=r.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!v)throw new Error(`Invalid height val = ${r}`);y=v[2]||"px",d=parseFloat(v[1])}else d=r;return{h:d,unit:y}}static defaults(r,...d){return d.forEach(y=>{for(let v in y){if(!y.hasOwnProperty(v))return;r[v]===null||r[v]===void 0?r[v]=y[v]:typeof y[v]=="object"&&typeof r[v]=="object"&&this.defaults(r[v],y[v])}}),r}static same(r,d){if(typeof r!="object")return r==d;if(typeof r!=typeof d||Object.keys(r).length!==Object.keys(d).length)return!1;for(let y in r)if(r[y]!==d[y])return!1;return!0}static copyPos(r,d,y=!1){return d.x!==void 0&&(r.x=d.x),d.y!==void 0&&(r.y=d.y),d.w!==void 0&&(r.w=d.w),d.h!==void 0&&(r.h=d.h),y&&(d.minW&&(r.minW=d.minW),d.minH&&(r.minH=d.minH),d.maxW&&(r.maxW=d.maxW),d.maxH&&(r.maxH=d.maxH)),r}static samePos(r,d){return r&&d&&r.x===d.x&&r.y===d.y&&(r.w||1)===(d.w||1)&&(r.h||1)===(d.h||1)}static sanitizeMinMax(r){r.minW||delete r.minW,r.minH||delete r.minH,r.maxW||delete r.maxW,r.maxH||delete r.maxH}static removeInternalAndSame(r,d){if(typeof r=="object"&&typeof d=="object")for(let y in r){let v=r[y],P=d[y];y[0]==="_"||v===P?delete r[y]:v&&typeof v=="object"&&P!==void 0&&(f.removeInternalAndSame(v,P),Object.keys(v).length||delete r[y])}}static removeInternalForSave(r,d=!0){for(let y in r)y[0]!=="_"&&r[y]!==null&&r[y]!==void 0||delete r[y];delete r.grid,d&&delete r.el,r.autoPosition||delete r.autoPosition,r.noResize||delete r.noResize,r.noMove||delete r.noMove,r.locked||delete r.locked,r.w!==1&&r.w!==r.minW||delete r.w,r.h!==1&&r.h!==r.minH||delete r.h}static throttle(r,d){let y=!1;return(...v)=>{y||(y=!0,setTimeout(()=>{r(...v),y=!1},d))}}static removePositioningStyles(r){let d=r.style;d.position&&d.removeProperty("position"),d.left&&d.removeProperty("left"),d.top&&d.removeProperty("top"),d.width&&d.removeProperty("width"),d.height&&d.removeProperty("height")}static getScrollElement(r){if(!r)return document.scrollingElement||document.documentElement;let d=getComputedStyle(r);return/(auto|scroll)/.test(d.overflow+d.overflowY)?r:this.getScrollElement(r.parentElement)}static updateScrollPosition(r,d,y){let v=r.getBoundingClientRect(),P=window.innerHeight||document.documentElement.clientHeight;if(v.top<0||v.bottom>P){let F=v.bottom-P,Y=v.top,nt=this.getScrollElement(r);if(nt!==null){let V=nt.scrollTop;v.top<0&&y<0?r.offsetHeight>P?nt.scrollTop+=y:nt.scrollTop+=Math.abs(Y)>Math.abs(y)?y:Y:y>0&&(r.offsetHeight>P?nt.scrollTop+=y:nt.scrollTop+=F>y?y:F),d.top+=nt.scrollTop-V}}}static updateScrollResize(r,d,y){let v=this.getScrollElement(d),P=v.clientHeight,F=v===this.getScrollElement()?0:v.getBoundingClientRect().top,Y=r.clientY-F,nt=Y>P-y;YP===v)&&(y[v]=f.cloneDeep(r[v]));return y}static cloneNode(r){let d=r.cloneNode(!0);return d.removeAttribute("id"),d}static appendTo(r,d){let y;y=typeof d=="string"?f.getElement(d):d,y&&y.appendChild(r)}static addElStyles(r,d){if(d instanceof Object)for(let y in d)d.hasOwnProperty(y)&&(Array.isArray(d[y])?d[y].forEach(v=>{r.style[y]=v}):r.style[y]=d[y])}static initEvent(r,d){let y={type:d.type},v={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:d.target?d.target:r.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(P=>y[P]=r[P]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(P=>y[P]=r[P]),{...y,...v}}static simulateMouseEvent(r,d,y){let v=document.createEvent("MouseEvents");v.initMouseEvent(d,!0,!0,window,1,r.screenX,r.screenY,r.clientX,r.clientY,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,0,r.target),(y||r.target).dispatchEvent(v)}static getValuesFromTransformedElement(r){let d=document.createElement("div");f.addElStyles(d,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),r.appendChild(d);let y=d.getBoundingClientRect();return r.removeChild(d),d.remove(),{xScale:1/y.width,yScale:1/y.height,xOffset:y.left,yOffset:y.top}}static swap(r,d,y){if(!r)return;let v=r[d];r[d]=r[y],r[y]=v}static canBeRotated(r){return!(!r||r.w===r.h||r.locked||r.noResize||r.grid?.opts.disableResize||r.minW&&r.minW===r.maxW||r.minH&&r.minH===r.maxH)}}class C{constructor(r={}){this.addedNodes=[],this.removedNodes=[],this.column=r.column||12,this.maxRow=r.maxRow,this._float=r.float,this.nodes=r.nodes||[],this.onChange=r.onChange}batchUpdate(r=!0,d=!0){return!!this.batchMode===r||(this.batchMode=r,r?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,d&&this._packNodes(),this._notify())),this}_useEntireRowArea(r,d){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!r._moving||r._skipDown||d.y<=r.y)}_fixCollisions(r,d=r,y,v={}){if(this.sortNodes(-1),!(y=y||this.collide(r,d)))return!1;if(r._moving&&!v.nested&&!this.float&&this.swap(r,y))return!0;let P=d;!this._loading&&this._useEntireRowArea(r,d)&&(P={x:0,w:this.column,y:d.y,h:d.h},y=this.collide(r,P,v.skip));let F=!1,Y={nested:!0,pack:!1};for(;y=y||this.collide(r,P,v.skip);){let nt;if(y.locked||this._loading||r._moving&&!r._skipDown&&d.y>r.y&&!this.float&&(!this.collide(y,{...y,y:r.y},r)||!this.collide(y,{...y,y:d.y-y.h},r))?(r._skipDown=r._skipDown||d.y>r.y,nt=this.moveNode(r,{...d,y:y.y+y.h,...Y}),(y.locked||this._loading)&&nt?f.copyPos(d,r):!y.locked&&nt&&v.pack&&(this._packNodes(),d.y=y.y+y.h,f.copyPos(r,d)),F=F||nt):nt=this.moveNode(y,{...y,y:d.y+d.h,skip:r,...Y}),!nt)return F;y=void 0}return F}collide(r,d=r,y){let v=r._id,P=y?._id;return this.nodes.find(F=>F._id!==v&&F._id!==P&&f.isIntercepted(F,d))}collideAll(r,d=r,y){let v=r._id,P=y?._id;return this.nodes.filter(F=>F._id!==v&&F._id!==P&&f.isIntercepted(F,d))}directionCollideCoverage(r,d,y){if(!d.rect||!r._rect)return;let v,P=r._rect,F={...d.rect};F.y>P.y?(F.h+=F.y-P.y,F.y=P.y):F.h+=P.y-F.y,F.x>P.x?(F.w+=F.x-P.x,F.x=P.x):F.w+=P.x-F.x;let Y=.5;for(let nt of y){if(nt.locked||!nt._rect)break;let V=nt._rect,it=Number.MAX_VALUE,kt=Number.MAX_VALUE;P.yV.y+V.h&&(it=(V.y+V.h-F.y)/V.h),P.xV.x+V.w&&(kt=(V.x+V.w-F.x)/V.w);let Et=Math.min(kt,it);Et>Y&&(Y=Et,v=nt)}return d.collide=v,v}cacheRects(r,d,y,v,P,F){return this.nodes.forEach(Y=>Y._rect={y:Y.y*d+y,x:Y.x*r+F,w:Y.w*r-F-v,h:Y.h*d-y-P}),this}swap(r,d){if(!d||d.locked||!r||r.locked)return!1;function y(){let P=d.x,F=d.y;return d.x=r.x,d.y=r.y,r.h!=d.h?(r.x=P,r.y=d.y+d.h):r.w!=d.w?(r.x=d.x+d.w,r.y=F):(r.x=P,r.y=F),r._dirty=d._dirty=!0,!0}let v;if(r.w===d.w&&r.h===d.h&&(r.x===d.x||r.y===d.y)&&(v=f.isTouching(r,d)))return y();if(v!==!1){if(r.w===d.w&&r.x===d.x&&(v||(v=f.isTouching(r,d)))){if(d.y{let V;F.locked||(F.autoPosition=!0,r==="list"&&Y&&(V=nt[Y-1])),this.addNode(F,!1,V)}),v||delete this._inColumnResize,y||this.batchUpdate(!1),this}set float(r){this._float!==r&&(this._float=r||!1,r||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(r=1){return this.nodes=f.sort(this.nodes,r),this}_packNodes(){return this.batchMode||(this.sortNodes(),this.float?this.nodes.forEach(r=>{if(r._updating||r._orig===void 0||r.y===r._orig.y)return;let d=r.y;for(;d>r._orig.y;)--d,this.collide(r,{x:r.x,y:d,w:r.w,h:r.h})||(r._dirty=!0,r.y=d)}):this.nodes.forEach((r,d)=>{if(!r.locked)for(;r.y>0;){let y=d===0?0:r.y-1;if(d!==0&&this.collide(r,{x:r.x,y,w:r.w,h:r.h}))break;r._dirty=r.y!==y,r.y=y}})),this}prepareNode(r,d){r._id=r._id??C._idSeq++,r.x!==void 0&&r.y!==void 0&&r.x!==null&&r.y!==null||(r.autoPosition=!0);let y={x:0,y:0,w:1,h:1};return f.defaults(r,y),r.autoPosition||delete r.autoPosition,r.noResize||delete r.noResize,r.noMove||delete r.noMove,f.sanitizeMinMax(r),typeof r.x=="string"&&(r.x=Number(r.x)),typeof r.y=="string"&&(r.y=Number(r.y)),typeof r.w=="string"&&(r.w=Number(r.w)),typeof r.h=="string"&&(r.h=Number(r.h)),isNaN(r.x)&&(r.x=y.x,r.autoPosition=!0),isNaN(r.y)&&(r.y=y.y,r.autoPosition=!0),isNaN(r.w)&&(r.w=y.w),isNaN(r.h)&&(r.h=y.h),this.nodeBoundFix(r,d),r}nodeBoundFix(r,d){let y=r._orig||f.copyPos({},r);if(r.maxW&&(r.w=Math.min(r.w,r.maxW)),r.maxH&&(r.h=Math.min(r.h,r.maxH)),r.minW&&r.minW<=this.column&&(r.w=Math.max(r.w,r.minW)),r.minH&&(r.h=Math.max(r.h,r.minH)),(r.x||0)+(r.w||1)>this.column&&this.column<12&&!this._inColumnResize&&r._id&&this.findCacheLayout(r,12)===-1){let v={...r};v.autoPosition||v.x===void 0?(delete v.x,delete v.y):v.x=Math.min(11,v.x),v.w=Math.min(12,v.w||1),this.cacheOneLayout(v,12)}return r.w>this.column?r.w=this.column:r.w<1&&(r.w=1),this.maxRow&&r.h>this.maxRow?r.h=this.maxRow:r.h<1&&(r.h=1),r.x<0&&(r.x=0),r.y<0&&(r.y=0),r.x+r.w>this.column&&(d?r.w=this.column-r.x:r.x=this.column-r.w),this.maxRow&&r.y+r.h>this.maxRow&&(d?r.h=this.maxRow-r.y:r.y=this.maxRow-r.h),f.samePos(r,y)||(r._dirty=!0),this}getDirtyNodes(r){return r?this.nodes.filter(d=>d._dirty&&!f.samePos(d,d._orig)):this.nodes.filter(d=>d._dirty)}_notify(r){if(this.batchMode||!this.onChange)return this;let d=(r||[]).concat(this.getDirtyNodes());return this.onChange(d),this}cleanNodes(){return this.batchMode||this.nodes.forEach(r=>{delete r._dirty,delete r._lastTried}),this}saveInitial(){return this.nodes.forEach(r=>{r._orig=f.copyPos({},r),delete r._dirty}),this._hasLocked=this.nodes.some(r=>r.locked),this}restoreInitial(){return this.nodes.forEach(r=>{f.samePos(r,r._orig)||(f.copyPos(r,r._orig),r._dirty=!0)}),this._notify(),this}findEmptyPosition(r,d=this.nodes,y=this.column,v){let P=!1;for(let F=v?v.y*y+(v.x+v.w):0;!P;++F){let Y=F%y,nt=Math.floor(F/y);if(Y+r.w>y)continue;let V={x:Y,y:nt,w:r.w,h:r.h};d.find(it=>f.isIntercepted(V,it))||(r.x===Y&&r.y===nt||(r._dirty=!0),r.x=Y,r.y=nt,delete r.autoPosition,P=!0)}return P}addNode(r,d=!1,y){let v;return this.nodes.find(P=>P._id===r._id)||(this._inColumnResize?this.nodeBoundFix(r):this.prepareNode(r),delete r._temporaryRemoved,delete r._removeDOM,r.autoPosition&&this.findEmptyPosition(r,this.nodes,this.column,y)&&(delete r.autoPosition,v=!0),this.nodes.push(r),d&&this.addedNodes.push(r),v||this._fixCollisions(r),this.batchMode||this._packNodes()._notify(),r)}removeNode(r,d=!0,y=!1){return this.nodes.find(v=>v._id===r._id)?(y&&this.removedNodes.push(r),d&&(r._removeDOM=!0),this.nodes=this.nodes.filter(v=>v._id!==r._id),r._isAboutToRemove||this._packNodes(),this._notify([r]),this):this}removeAll(r=!0,d=!0){if(delete this._layouts,!this.nodes.length)return this;r&&this.nodes.forEach(v=>v._removeDOM=!0);let y=this.nodes;return this.removedNodes=d?y:[],this.nodes=[],this._notify(y)}moveNodeCheck(r,d){if(!this.changedPosConstrain(r,d))return!1;if(d.pack=!0,!this.maxRow)return this.moveNode(r,d);let y,v=new C({column:this.column,float:this.float,nodes:this.nodes.map(F=>F._id===r._id?(y={...F},y):{...F})});if(!y)return!1;let P=v.moveNode(y,d)&&v.getRow()<=Math.max(this.getRow(),this.maxRow);if(!P&&!d.resizing&&d.collide){let F=d.collide.el.gridstackNode;if(this.swap(r,F))return this._notify(),!0}return!!P&&(v.nodes.filter(F=>F._dirty).forEach(F=>{let Y=this.nodes.find(nt=>nt._id===F._id);Y&&(f.copyPos(Y,F),Y._dirty=!0)}),this._notify(),!0)}willItFit(r){if(delete r._willFitPos,!this.maxRow)return!0;let d=new C({column:this.column,float:this.float,nodes:this.nodes.map(v=>({...v}))}),y={...r};return this.cleanupNode(y),delete y.el,delete y._id,delete y.content,delete y.grid,d.addNode(y),d.getRow()<=this.maxRow&&(r._willFitPos=f.copyPos({},y),!0)}changedPosConstrain(r,d){return d.w=d.w||r.w,d.h=d.h||r.h,r.x!==d.x||r.y!==d.y||(r.maxW&&(d.w=Math.min(d.w,r.maxW)),r.maxH&&(d.h=Math.min(d.h,r.maxH)),r.minW&&(d.w=Math.max(d.w,r.minW)),r.minH&&(d.h=Math.max(d.h,r.minH)),r.w!==d.w||r.h!==d.h)}moveNode(r,d){if(!r||!d)return!1;let y;d.pack!==void 0||this.batchMode||(y=d.pack=!0),typeof d.x!="number"&&(d.x=r.x),typeof d.y!="number"&&(d.y=r.y),typeof d.w!="number"&&(d.w=r.w),typeof d.h!="number"&&(d.h=r.h);let v=r.w!==d.w||r.h!==d.h,P=f.copyPos({},r,!0);if(f.copyPos(P,d),this.nodeBoundFix(P,v),f.copyPos(d,P),!d.forceCollide&&f.samePos(r,d))return!1;let F=f.copyPos({},r),Y=this.collideAll(r,P,d.skip),nt=!0;if(Y.length){let V=r._moving&&!d.nested,it=V?this.directionCollideCoverage(r,d,Y):Y[0];if(V&&it&&r.grid?.opts?.subGridDynamic&&!r.grid._isTemp){let kt=f.areaIntercept(d.rect,it._rect),Et=f.area(d.rect),ie=f.area(it._rect);kt/(Et.8&&(it.grid.makeSubGrid(it.el,void 0,r),it=void 0)}it?nt=!this._fixCollisions(r,P,it,d):(nt=!1,y&&delete d.pack)}return nt&&(r._dirty=!0,f.copyPos(r,P)),d.pack&&this._packNodes()._notify(),!f.samePos(r,F)}getRow(){return this.nodes.reduce((r,d)=>Math.max(r,d.y+d.h),0)}beginUpdate(r){return r._updating||(r._updating=!0,delete r._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){let r=this.nodes.find(d=>d._updating);return r&&(delete r._updating,delete r._skipDown),this}save(r=!0,d){let y=this._layouts?.length,v=y&&this.column!==y-1?this._layouts[y-1]:null,P=[];return this.sortNodes(),this.nodes.forEach(F=>{let Y=v?.find(V=>V._id===F._id),nt={...F,...Y||{}};f.removeInternalForSave(nt,!r),d&&d(F,nt),P.push(nt)}),P}layoutsNodesChange(r){return!this._layouts||this._inColumnResize||this._layouts.forEach((d,y)=>{if(!d||y===this.column)return this;if(y{if(!P._orig)return;let F=d.find(Y=>Y._id===P._id);F&&(F.y>=0&&P.y!==P._orig.y&&(F.y+=P.y-P._orig.y),P.x!==P._orig.x&&(F.x=Math.round(P.x*v)),P.w!==P._orig.w&&(F.w=Math.round(P.w*v)))})}}),this}columnChanged(r,d,y="moveScale"){if(!this.nodes.length||!d||r===d)return this;if(y==="none")return this;let v=y==="compact"||y==="list";v&&this.sortNodes(1),dr&&this._layouts){let Y=this._layouts[d]||[],nt=this._layouts.length-1;!Y.length&&r!==nt&&this._layouts[nt]?.length&&(r=nt,this._layouts[nt].forEach(V=>{let it=F.find(kt=>kt._id===V._id);it&&(v||V.autoPosition||(it.x=V.x??it.x,it.y=V.y??it.y),it.w=V.w??it.w,V.x!=null&&V.y!==void 0||(it.autoPosition=!0))})),Y.forEach(V=>{let it=F.findIndex(kt=>kt._id===V._id);if(it!==-1){let kt=F[it];if(v)return void(kt.w=V.w);(V.autoPosition||isNaN(V.x)||isNaN(V.y))&&this.findEmptyPosition(V,P),V.autoPosition||(kt.x=V.x??kt.x,kt.y=V.y??kt.y,kt.w=V.w??kt.w,P.push(kt)),F.splice(it,1)}})}if(v)this.compact(y,!1);else{if(F.length)if(typeof y=="function")y(d,r,P,F);else{let Y=v?1:d/r,nt=y==="move"||y==="moveScale",V=y==="scale"||y==="moveScale";F.forEach(it=>{it.x=d===1?0:nt?Math.round(it.x*Y):Math.min(it.x,d-1),it.w=d===1||r===1?1:V?Math.round(it.w*Y)||1:Math.min(it.w,d),P.push(it)}),F=[]}P=f.sort(P,-1),this._inColumnResize=!0,this.nodes=[],P.forEach(Y=>{this.addNode(Y,!1),delete Y._orig})}return this.nodes.forEach(Y=>delete Y._orig),this.batchUpdate(!1,!v),delete this._inColumnResize,this}cacheLayout(r,d,y=!1){let v=[];return r.forEach((P,F)=>{if(P._id===void 0){let Y=P.id?this.nodes.find(nt=>nt.id===P.id):void 0;P._id=Y?._id??C._idSeq++}v[F]={x:P.x,y:P.y,w:P.w,_id:P._id}}),this._layouts=y?[]:this._layouts||[],this._layouts[d]=v,this}cacheOneLayout(r,d){r._id=r._id??C._idSeq++;let y={x:r.x,y:r.y,w:r.w,_id:r._id};(r.autoPosition||r.x===void 0)&&(delete y.x,delete y.y,r.autoPosition&&(y.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[d]=this._layouts[d]||[];let v=this.findCacheLayout(r,d);return v===-1?this._layouts[d].push(y):this._layouts[d][v]=y,this}findCacheLayout(r,d){return this._layouts?.[d]?.findIndex(y=>y._id===r._id)??-1}removeNodeFromLayoutCache(r){if(this._layouts)for(let d=0;d0||navigator.msMaxTouchPoints>0);class q{}function Rt(St,r){if(St.touches.length>1)return;St.cancelable&&St.preventDefault();let d=St.changedTouches[0],y=document.createEvent("MouseEvents");y.initMouseEvent(r,!0,!0,window,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,null),St.target.dispatchEvent(y)}function Ot(St,r){St.cancelable&&St.preventDefault();let d=document.createEvent("MouseEvents");d.initMouseEvent(r,!0,!0,window,1,St.screenX,St.screenY,St.clientX,St.clientY,!1,!1,!1,!1,0,null),St.target.dispatchEvent(d)}function ft(St){q.touchHandled||(q.touchHandled=!0,Rt(St,"mousedown"))}function xt(St){q.touchHandled&&Rt(St,"mousemove")}function jt(St){if(!q.touchHandled)return;q.pointerLeaveTimeout&&(window.clearTimeout(q.pointerLeaveTimeout),delete q.pointerLeaveTimeout);let r=!!W.dragElement;Rt(St,"mouseup"),r||Rt(St,"click"),q.touchHandled=!1}function te(St){St.pointerType!=="mouse"&&St.target.releasePointerCapture(St.pointerId)}function ae(St){W.dragElement&&St.pointerType!=="mouse"&&Ot(St,"mouseenter")}function Ae(St){W.dragElement&&St.pointerType!=="mouse"&&(q.pointerLeaveTimeout=window.setTimeout(()=>{delete q.pointerLeaveTimeout,Ot(St,"mouseleave")},10))}class ue{constructor(r,d,y){this.host=r,this.dir=d,this.option=y,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){let r=this.el=document.createElement("div");return r.classList.add("ui-resizable-handle"),r.classList.add(`${ue.prefix}${this.dir}`),r.style.zIndex="100",r.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),at&&(this.el.addEventListener("touchstart",ft),this.el.addEventListener("pointerdown",te)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),at&&(this.el.removeEventListener("touchstart",ft),this.el.removeEventListener("pointerdown",te)),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(r){this.mouseDownEvent=r,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),at&&(this.el.addEventListener("touchmove",xt),this.el.addEventListener("touchend",jt)),r.stopPropagation(),r.preventDefault()}_mouseMove(r){let d=this.mouseDownEvent;this.moving?this._triggerEvent("move",r):Math.abs(r.x-d.x)+Math.abs(r.y-d.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",r),document.addEventListener("keydown",this._keyEvent)),r.stopPropagation()}_mouseUp(r){this.moving&&(this._triggerEvent("stop",r),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),at&&(this.el.removeEventListener("touchmove",xt),this.el.removeEventListener("touchend",jt)),delete this.moving,delete this.mouseDownEvent,r.stopPropagation(),r.preventDefault()}_keyEvent(r){r.key==="Escape"&&(this.host.gridstackNode?.grid?.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(r,d){return this.option[r]&&this.option[r](d),this}}ue.prefix="ui-resizable-";class _e{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(r,d){this._eventRegister[r]=d}off(r){delete this._eventRegister[r]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(r,d){if(!this.disabled&&this._eventRegister&&this._eventRegister[r])return this._eventRegister[r](d)}}class Oe extends _e{constructor(r,d={}){super(),this.el=r,this.option=d,this.rectScale={x:1,y:1},this._ui=()=>{let y=this.el.parentElement.getBoundingClientRect(),v={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},P=this.temporalRect||v;return{position:{left:(P.left-y.left)*this.rectScale.x,top:(P.top-y.top)*this.rectScale.y},size:{width:P.width*this.rectScale.x,height:P.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(r,d){super.on(r,d)}off(r){super.off(r)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(r){let d=r.handles&&r.handles!==this.option.handles,y=r.autoHide&&r.autoHide!==this.option.autoHide;return Object.keys(r).forEach(v=>this.option[v]=r[v]),d&&(this._removeHandlers(),this._setupHandlers()),y&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(r){return r?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),W.overResizeElement===this&&delete W.overResizeElement),this}_mouseOver(r){W.overResizeElement||W.dragElement||(W.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(r){W.overResizeElement===this&&(delete W.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(r=>r.trim()).map(r=>new ue(this.el,r,{start:d=>{this._resizeStart(d)},stop:d=>{this._resizeStop(d)},move:d=>{this._resizing(d,r)}})),this}_resizeStart(r){this.sizeToContent=f.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=f.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=r,this._setupHelper(),this._applyChange();let d=f.initEvent(r,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(d,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",d),this}_resizing(r,d){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(r,d),this._applyChange();let y=f.initEvent(r,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(y,this._ui()),this.triggerEvent("resize",y),this}_resizeStop(r){let d=f.initEvent(r,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(d),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",d),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=Oe._originStyleProp.map(y=>this.el.style[y]),this.parentOriginStylePosition=this.el.parentElement.style.position;let r=this.el.parentElement,d=f.getValuesFromTransformedElement(r);return this.rectScale={x:d.xScale,y:d.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return Oe._originStyleProp.forEach((r,d)=>{this.el.style[r]=this.elOriginStyleVal[d]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(r,d){let y=this.startEvent,v={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},P=r.clientX-y.clientX,F=this.sizeToContent?0:r.clientY-y.clientY,Y,nt;d.indexOf("e")>-1?v.width+=P:d.indexOf("w")>-1&&(v.width-=P,v.left+=P,Y=!0),d.indexOf("s")>-1?v.height+=F:d.indexOf("n")>-1&&(v.height-=F,v.top+=F,nt=!0);let V=this._constrainSize(v.width,v.height,Y,nt);return Math.round(v.width)!==Math.round(V.width)&&(d.indexOf("w")>-1&&(v.left+=v.width-V.width),v.width=V.width),Math.round(v.height)!==Math.round(V.height)&&(d.indexOf("n")>-1&&(v.top+=v.height-V.height),v.height=V.height),v}_constrainSize(r,d,y,v){let P=this.option,F=(y?P.maxWidthMoveLeft:P.maxWidth)||Number.MAX_SAFE_INTEGER,Y=P.minWidth/this.rectScale.x||r,nt=(v?P.maxHeightMoveUp:P.maxHeight)||Number.MAX_SAFE_INTEGER,V=P.minHeight/this.rectScale.y||d;return{width:Math.min(F,Math.max(Y,r)),height:Math.min(nt,Math.max(V,d))}}_applyChange(){let r={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){let d=this.el.parentElement,{left:y,top:v}=d.getBoundingClientRect();r={left:y,top:v,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(d=>{let y=this.temporalRect[d],v=d==="width"||d==="left"?this.rectScale.x:d==="height"||d==="top"?this.rectScale.y:1;this.el.style[d]=(y-r[d])*v+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(r=>r.destroy()),delete this.handlers,this}}Oe._originStyleProp=["width","height","position","left","top","opacity","zIndex"];class Ee extends _e{constructor(r,d={}){super(),this.el=r,this.option=d,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};let y=d.handle.substring(1),v=r.gridstackNode;this.dragEls=r.classList.contains(y)?[r]:v?.subGrid?[r.querySelector(d.handle)||r]:Array.from(r.querySelectorAll(d.handle)),this.dragEls.length===0&&(this.dragEls=[r]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}on(r,d){super.on(r,d)}off(r){super.off(r)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(r=>{r.addEventListener("mousedown",this._mouseDown),at&&(r.addEventListener("touchstart",ft),r.addEventListener("pointerdown",te))}),this.el.classList.remove("ui-draggable-disabled"))}disable(r=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(d=>{d.removeEventListener("mousedown",this._mouseDown),at&&(d.removeEventListener("touchstart",ft),d.removeEventListener("pointerdown",te))}),r||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(r){return Object.keys(r).forEach(d=>this.option[d]=r[d]),this}_mouseDown(r){if(!W.mouseHandled)return r.button!==0||!this.dragEls.find(d=>d===r.target)&&r.target.closest('input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle')||this.option.cancel&&r.target.closest(this.option.cancel)||(this.mouseDownEvent=r,delete this.dragging,delete W.dragElement,delete W.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),at&&(r.target.addEventListener("touchmove",xt),r.target.addEventListener("touchend",jt)),r.preventDefault(),document.activeElement&&document.activeElement.blur(),W.mouseHandled=!0),!0}_callDrag(r){if(!this.dragging)return;let d=f.initEvent(r,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(d,this.ui()),this.triggerEvent("drag",d)}_mouseMove(r){let d=this.mouseDownEvent;if(this.lastDrag=r,this.dragging)if(this._dragFollow(r),W.pauseDrag){let y=Number.isInteger(W.pauseDrag)?W.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(r),y)}else this._callDrag(r);else if(Math.abs(r.x-d.x)+Math.abs(r.y-d.y)>3){this.dragging=!0,W.dragElement=this;let y=this.el.gridstackNode?.grid;y?W.dropElement=y.el.ddElement.ddDroppable:delete W.dropElement,this.helper=this._createHelper(r),this._setupHelperContainmentStyle(),this.dragTransform=f.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(r,this.el,this.helperContainment),this._setupHelperStyle(r);let v=f.initEvent(r,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(v,this.ui()),this.triggerEvent("dragstart",v),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(r){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),at&&(r.target.removeEventListener("touchmove",xt,!0),r.target.removeEventListener("touchend",jt,!0)),this.dragging){delete this.dragging,delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),W.dropElement?.el===this.el.parentElement&&delete W.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper===this.el?this._removeHelperStyle():this.helper.remove();let d=f.initEvent(r,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(d),this.triggerEvent("dragstop",d),W.dropElement&&W.dropElement.drop(r)}delete this.helper,delete this.mouseDownEvent,delete W.dragElement,delete W.dropElement,delete W.mouseHandled,r.preventDefault()}_keyEvent(r){let d=this.el.gridstackNode;if(!d?.grid)return;let y=d.grid;if(r.key==="Escape")d._origRotate&&(d._orig=d._origRotate,delete d._origRotate),y.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent);else if(r.key==="r"||r.key==="R"){if(!f.canBeRotated(d))return;d._origRotate=d._origRotate||{...d._orig},delete d._moving,y.setAnimation(!1).rotate(d.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetLeft}).setAnimation(),d._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,d.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",f.swap(d._orig,"w","h"),delete d._rect,this._mouseMove(this.lastDrag)}}_createHelper(r){let d=this.el;return typeof this.option.helper=="function"?d=this.option.helper(r):this.option.helper==="clone"&&(d=f.cloneNode(this.el)),document.body.contains(d)||f.appendTo(d,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),d===this.el&&(this.dragElementOriginStyle=Ee.originStyleProp.map(y=>this.el.style[y])),d}_setupHelperStyle(r){this.helper.classList.add("ui-draggable-dragging");let d=this.helper.style;return d.pointerEvents="none",d.width=this.dragOffset.width+"px",d.height=this.dragOffset.height+"px",d.willChange="left, top",d.position="fixed",this._dragFollow(r),d.transition="none",setTimeout(()=>{this.helper&&(d.transition=null)},0),this}_removeHelperStyle(){if(this.helper.classList.remove("ui-draggable-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){let d=this.helper,y=this.dragElementOriginStyle.transition||null;d.style.transition=this.dragElementOriginStyle.transition="none",Ee.originStyleProp.forEach(v=>d.style[v]=this.dragElementOriginStyle[v]||null),setTimeout(()=>d.style.transition=y,50)}return delete this.dragElementOriginStyle,this}_dragFollow(r){let d=this.helper.style,y=this.dragOffset;d.left=(r.clientX+y.offsetLeft-0)*this.dragTransform.xScale+"px",d.top=(r.clientY+y.offsetTop-0)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(r,d,y){let v=0,P=0;y&&(v=this.dragTransform.xOffset,P=this.dragTransform.yOffset);let F=d.getBoundingClientRect();return{left:F.left,top:F.top,offsetLeft:-r.clientX+F.left-v,offsetTop:-r.clientY+F.top-P,width:F.width*this.dragTransform.xScale,height:F.height*this.dragTransform.yScale}}ui(){let r=this.el.parentElement.getBoundingClientRect(),d=this.helper.getBoundingClientRect();return{position:{top:(d.top-r.top)*this.dragTransform.yScale,left:(d.left-r.left)*this.dragTransform.xScale}}}}Ee.originStyleProp=["transition","pointerEvents","position","left","top","minWidth","willChange"];class Ge extends _e{constructor(r,d={}){super(),this.el=r,this.option=d,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(r,d){super.on(r,d)}off(r){super.off(r)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),at&&(this.el.addEventListener("pointerenter",ae),this.el.addEventListener("pointerleave",Ae)))}disable(r=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),r||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),at&&(this.el.removeEventListener("pointerenter",ae),this.el.removeEventListener("pointerleave",Ae)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(r){return Object.keys(r).forEach(d=>this.option[d]=r[d]),this._setupAccept(),this}_mouseEnter(r){if(!W.dragElement||!this._canDrop(W.dragElement.el))return;r.preventDefault(),r.stopPropagation(),W.dropElement&&W.dropElement!==this&&W.dropElement._mouseLeave(r,!0),W.dropElement=this;let d=f.initEvent(r,{target:this.el,type:"dropover"});this.option.over&&this.option.over(d,this._ui(W.dragElement)),this.triggerEvent("dropover",d),this.el.classList.add("ui-droppable-over")}_mouseLeave(r,d=!1){if(!W.dragElement||W.dropElement!==this)return;r.preventDefault(),r.stopPropagation();let y=f.initEvent(r,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(y,this._ui(W.dragElement)),this.triggerEvent("dropout",y),W.dropElement===this&&(delete W.dropElement,!d)){let v,P=this.el.parentElement;for(;!v&&P;)v=P.ddElement?.ddDroppable,P=P.parentElement;v&&v._mouseEnter(r)}}drop(r){r.preventDefault();let d=f.initEvent(r,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(d,this._ui(W.dragElement)),this.triggerEvent("drop",d)}_canDrop(r){return r&&(!this.accept||this.accept(r))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=r=>r.classList.contains(this.option.accept)||r.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(r){return{draggable:r.el,...r.ui()}}}class De{static init(r){return r.ddElement||(r.ddElement=new De(r)),r.ddElement}constructor(r){this.el=r}on(r,d){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(r)>-1?this.ddDraggable.on(r,d):this.ddDroppable&&["drop","dropover","dropout"].indexOf(r)>-1?this.ddDroppable.on(r,d):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(r)>-1&&this.ddResizable.on(r,d),this}off(r){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(r)>-1?this.ddDraggable.off(r):this.ddDroppable&&["drop","dropover","dropout"].indexOf(r)>-1?this.ddDroppable.off(r):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(r)>-1&&this.ddResizable.off(r),this}setupDraggable(r){return this.ddDraggable?this.ddDraggable.updateOption(r):this.ddDraggable=new Ee(this.el,r),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(r){return this.ddResizable?this.ddResizable.updateOption(r):this.ddResizable=new Oe(this.el,r),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(r){return this.ddDroppable?this.ddDroppable.updateOption(r):this.ddDroppable=new Ge(this.el,r),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}let se=new class{resizable(St,r,d,y){return this._getDDElements(St).forEach(v=>{if(r==="disable"||r==="enable")v.ddResizable&&v.ddResizable[r]();else if(r==="destroy")v.ddResizable&&v.cleanResizable();else if(r==="option")v.setupResizable({[d]:y});else{let P=v.el.gridstackNode.grid,F=v.el.getAttribute("gs-resize-handles")||P.opts.resizable.handles||"e,s,se";F==="all"&&(F="n,e,s,w,se,sw,ne,nw");let Y=!P.opts.alwaysShowResizeHandle;v.setupResizable({...P.opts.resizable,handles:F,autoHide:Y,start:r.start,stop:r.stop,resize:r.resize})}}),this}draggable(St,r,d,y){return this._getDDElements(St).forEach(v=>{if(r==="disable"||r==="enable")v.ddDraggable&&v.ddDraggable[r]();else if(r==="destroy")v.ddDraggable&&v.cleanDraggable();else if(r==="option")v.setupDraggable({[d]:y});else{let P=v.el.gridstackNode.grid;v.setupDraggable({...P.opts.draggable,start:r.start,stop:r.stop,drag:r.drag})}}),this}dragIn(St,r){return this._getDDElements(St).forEach(d=>d.setupDraggable(r)),this}droppable(St,r,d,y){return typeof r.accept!="function"||r._accept||(r._accept=r.accept,r.accept=v=>r._accept(v)),this._getDDElements(St).forEach(v=>{r==="disable"||r==="enable"?v.ddDroppable&&v.ddDroppable[r]():r==="destroy"?v.ddDroppable&&v.cleanDroppable():r==="option"?v.setupDroppable({[d]:y}):v.setupDroppable(r)}),this}isDroppable(St){return!(!(St&&St.ddElement&&St.ddElement.ddDroppable)||St.ddElement.ddDroppable.disabled)}isDraggable(St){return!(!(St&&St.ddElement&&St.ddElement.ddDraggable)||St.ddElement.ddDraggable.disabled)}isResizable(St){return!(!(St&&St.ddElement&&St.ddElement.ddResizable)||St.ddElement.ddResizable.disabled)}on(St,r,d){return this._getDDElements(St).forEach(y=>y.on(r,v=>{d(v,W.dragElement?W.dragElement.el:v.target,W.dragElement?W.dragElement.helper:null)})),this}off(St,r){return this._getDDElements(St).forEach(d=>d.off(r)),this}_getDDElements(St,r=!0){let d=f.getElements(St);if(!d.length)return[];let y=d.map(v=>v.ddElement||(r?De.init(v):null));return r||y.filter(v=>v),y}};class Bt{static init(r={},d=".grid-stack"){if(typeof document>"u")return null;let y=Bt.getGridElement(d);return y?(y.gridstack||(y.gridstack=new Bt(y,f.cloneDeep(r))),y.gridstack):(console.error(typeof d=="string"?'GridStack.initAll() no grid was found with selector "'+d+`" - element missing or wrong selector ? +(()=>{var ys=(D=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(D,{get:(h,f)=>(typeof require<"u"?require:h)[f]}):D)(function(D){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+D+'" is not supported')});var Sn=globalThis,Ho=Sn.ShadowRoot&&(Sn.ShadyCSS===void 0||Sn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Io=Symbol(),Aa=new WeakMap,Cn=class{constructor(h,f,C){if(this._$cssResult$=!0,C!==Io)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=h,this.t=f}get styleSheet(){let h=this.i,f=this.t;if(Ho&&h===void 0){let C=f!==void 0&&f.length===1;C&&(h=Aa.get(f)),h===void 0&&((this.i=h=new CSSStyleSheet).replaceSync(this.cssText),C&&Aa.set(f,h))}return h}toString(){return this.cssText}},Mh=D=>new Cn(typeof D=="string"?D:D+"",void 0,Io),Xe=(D,...h)=>{let f=D.length===1?D[0]:h.reduce((C,I,X)=>C+(W=>{if(W._$cssResult$===!0)return W.cssText;if(typeof W=="number")return W;throw Error("Value passed to 'css' function must be a 'css' function result: "+W+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(I)+D[X+1],D[0]);return new Cn(f,D,Io)},Sh=(D,h)=>{if(Ho)D.adoptedStyleSheets=h.map(f=>f instanceof CSSStyleSheet?f:f.styleSheet);else for(let f of h){let C=document.createElement("style"),I=Sn.litNonce;I!==void 0&&C.setAttribute("nonce",I),C.textContent=f.cssText,D.appendChild(C)}},Ra=Ho?D=>D:D=>D instanceof CSSStyleSheet?(h=>{let f="";for(let C of h.cssRules)f+=C.cssText;return Mh(f)})(D):D,{is:Ch,defineProperty:Th,getOwnPropertyDescriptor:Eh,getOwnPropertyNames:Dh,getOwnPropertySymbols:Ph,getPrototypeOf:Ah}=Object,In=globalThis,Oa=In.trustedTypes,Rh=Oa?Oa.emptyScript:"",Oh=In.reactiveElementPolyfillSupport,Js=(D,h)=>D,Oo={toAttribute(D,h){switch(h){case Boolean:D=D?Rh:null;break;case Object:case Array:D=D==null?D:JSON.stringify(D)}return D},fromAttribute(D,h){let f=D;switch(h){case Boolean:f=D!==null;break;case Number:f=D===null?null:Number(D);break;case Object:case Array:try{f=JSON.parse(D)}catch{f=null}}return f}},Xa=(D,h)=>!Ch(D,h),za={attribute:!0,type:String,converter:Oo,reflect:!1,hasChanged:Xa};Symbol.metadata??=Symbol("metadata"),In.litPropertyMetadata??=new WeakMap;var vs=class extends HTMLElement{static addInitializer(h){this.o(),(this.l??=[]).push(h)}static get observedAttributes(){return this.finalize(),this.u&&[...this.u.keys()]}static createProperty(h,f=za){if(f.state&&(f.attribute=!1),this.o(),this.elementProperties.set(h,f),!f.noAccessor){let C=Symbol(),I=this.getPropertyDescriptor(h,C,f);I!==void 0&&Th(this.prototype,h,I)}}static getPropertyDescriptor(h,f,C){let{get:I,set:X}=Eh(this.prototype,h)??{get(){return this[f]},set(W){this[f]=W}};return{get(){return I?.call(this)},set(W){let at=I?.call(this);X.call(this,W),this.requestUpdate(h,at,C)},configurable:!0,enumerable:!0}}static getPropertyOptions(h){return this.elementProperties.get(h)??za}static o(){if(this.hasOwnProperty(Js("elementProperties")))return;let h=Ah(this);h.finalize(),h.l!==void 0&&(this.l=[...h.l]),this.elementProperties=new Map(h.elementProperties)}static finalize(){if(this.hasOwnProperty(Js("finalized")))return;if(this.finalized=!0,this.o(),this.hasOwnProperty(Js("properties"))){let f=this.properties,C=[...Dh(f),...Ph(f)];for(let I of C)this.createProperty(I,f[I])}let h=this[Symbol.metadata];if(h!==null){let f=litPropertyMetadata.get(h);if(f!==void 0)for(let[C,I]of f)this.elementProperties.set(C,I)}this.u=new Map;for(let[f,C]of this.elementProperties){let I=this.p(f,C);I!==void 0&&this.u.set(I,f)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(h){let f=[];if(Array.isArray(h)){let C=new Set(h.flat(1/0).reverse());for(let I of C)f.unshift(Ra(I))}else h!==void 0&&f.push(Ra(h));return f}static p(h,f){let C=f.attribute;return C===!1?void 0:typeof C=="string"?C:typeof h=="string"?h.toLowerCase():void 0}constructor(){super(),this.v=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this.m=null,this._()}_(){this.S=new Promise(h=>this.enableUpdating=h),this._$AL=new Map,this.$(),this.requestUpdate(),this.constructor.l?.forEach(h=>h(this))}addController(h){(this.P??=new Set).add(h),this.renderRoot!==void 0&&this.isConnected&&h.hostConnected?.()}removeController(h){this.P?.delete(h)}$(){let h=new Map,f=this.constructor.elementProperties;for(let C of f.keys())this.hasOwnProperty(C)&&(h.set(C,this[C]),delete this[C]);h.size>0&&(this.v=h)}createRenderRoot(){let h=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Sh(h,this.constructor.elementStyles),h}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this.P?.forEach(h=>h.hostConnected?.())}enableUpdating(h){}disconnectedCallback(){this.P?.forEach(h=>h.hostDisconnected?.())}attributeChangedCallback(h,f,C){this._$AK(h,C)}C(h,f){let C=this.constructor.elementProperties.get(h),I=this.constructor.p(h,C);if(I!==void 0&&C.reflect===!0){let X=(C.converter?.toAttribute!==void 0?C.converter:Oo).toAttribute(f,C.type);this.m=h,X==null?this.removeAttribute(I):this.setAttribute(I,X),this.m=null}}_$AK(h,f){let C=this.constructor,I=C.u.get(h);if(I!==void 0&&this.m!==I){let X=C.getPropertyOptions(I),W=typeof X.converter=="function"?{fromAttribute:X.converter}:X.converter?.fromAttribute!==void 0?X.converter:Oo;this.m=I,this[I]=W.fromAttribute(f,X.type),this.m=null}}requestUpdate(h,f,C){if(h!==void 0){if(C??=this.constructor.getPropertyOptions(h),!(C.hasChanged??Xa)(this[h],f))return;this.T(h,f,C)}this.isUpdatePending===!1&&(this.S=this.A())}T(h,f,C){this._$AL.has(h)||this._$AL.set(h,f),C.reflect===!0&&this.m!==h&&(this.M??=new Set).add(h)}async A(){this.isUpdatePending=!0;try{await this.S}catch(f){Promise.reject(f)}let h=this.scheduleUpdate();return h!=null&&await h,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this.v){for(let[I,X]of this.v)this[I]=X;this.v=void 0}let C=this.constructor.elementProperties;if(C.size>0)for(let[I,X]of C)X.wrapped!==!0||this._$AL.has(I)||this[I]===void 0||this.T(I,this[I],X)}let h=!1,f=this._$AL;try{h=this.shouldUpdate(f),h?(this.willUpdate(f),this.P?.forEach(C=>C.hostUpdate?.()),this.update(f)):this.k()}catch(C){throw h=!1,this.k(),C}h&&this._$AE(f)}willUpdate(h){}_$AE(h){this.P?.forEach(f=>f.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(h)),this.updated(h)}k(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.S}shouldUpdate(h){return!0}update(h){this.M&&=this.M.forEach(f=>this.C(f,this[f])),this.k()}updated(h){}firstUpdated(h){}};vs.elementStyles=[],vs.shadowRootOptions={mode:"open"},vs[Js("elementProperties")]=new Map,vs[Js("finalized")]=new Map,Oh?.({ReactiveElement:vs}),(In.reactiveElementVersions??=[]).push("2.0.4");var No=globalThis,Tn=No.trustedTypes,La=Tn?Tn.createPolicy("lit-html",{createHTML:D=>D}):void 0,$o="$lit$",cs=`lit$${Math.random().toFixed(9).slice(2)}$`,Fo="?"+cs,zh=`<${Fo}>`,Ps=document,en=()=>Ps.createComment(""),sn=D=>D===null||typeof D!="object"&&typeof D!="function",Ga=Array.isArray,Qa=D=>Ga(D)||typeof D?.[Symbol.iterator]=="function",Po=`[ +\f\r]`,Zs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ha=/-->/g,Ia=/>/g,Es=RegExp(`>|${Po}(?:([^\\s"'>=/]+)(${Po}*=${Po}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),Na=/'/g,$a=/"/g,Ka=/^(?:script|style|textarea|title)$/i,Za=D=>(h,...f)=>({_$litType$:D,strings:h,values:f}),Kt=Za(1),Lh=Za(2),Fe=Symbol.for("lit-noChange"),ee=Symbol.for("lit-nothing"),Fa=new WeakMap,Ds=Ps.createTreeWalker(Ps,129);function Ja(D,h){if(!Array.isArray(D)||!D.hasOwnProperty("raw"))throw Error("invalid template strings array");return La!==void 0?La.createHTML(h):h}var tl=(D,h)=>{let f=D.length-1,C=[],I,X=h===2?"":"",W=Zs;for(let at=0;at"?(W=I??Zs,ft=-1):Ot[1]===void 0?ft=-2:(ft=W.lastIndex-Ot[2].length,Rt=Ot[1],W=Ot[3]===void 0?Es:Ot[3]==='"'?$a:Na):W===$a||W===Na?W=Es:W===Ha||W===Ia?W=Zs:(W=Es,I=void 0);let jt=W===Es&&D[at+1].startsWith("/>")?" ":"";X+=W===Zs?q+zh:ft>=0?(C.push(Rt),q.slice(0,ft)+$o+q.slice(ft)+cs+jt):q+cs+(ft===-2?at:jt)}return[Ja(D,X+(D[f]||"")+(h===2?"":"")),C]},nn=class D{constructor({strings:h,_$litType$:f},C){let I;this.parts=[];let X=0,W=0,at=h.length-1,q=this.parts,[Rt,Ot]=tl(h,f);if(this.el=D.createElement(Rt,C),Ds.currentNode=this.el.content,f===2){let ft=this.el.content.firstChild;ft.replaceWith(...ft.childNodes)}for(;(I=Ds.nextNode())!==null&&q.length0){I.textContent=Tn?Tn.emptyScript:"";for(let jt=0;jt2||C[0]!==""||C[1]!==""?(this._$AH=Array(C.length-1).fill(new String),this.strings=C):this._$AH=ee}_$AI(h,f=this,C,I){let X=this.strings,W=!1;if(X===void 0)h=As(this,h,f,0),W=!sn(h)||h!==this._$AH&&h!==Fe,W&&(this._$AH=h);else{let at=h,q,Rt;for(h=X[0],q=0;q{let C=f?.renderBefore??h,I=C._$litPart$;if(I===void 0){let X=f?.renderBefore??null;C._$litPart$=I=new Nn(h.insertBefore(en(),X),X,void 0,f??{})}return I._$AI(D),I};var ke=class extends vs{constructor(){super(...arguments),this.renderOptions={host:this},this.ht=void 0}createRenderRoot(){let h=super.createRenderRoot();return this.renderOptions.renderBefore??=h.firstChild,h}update(h){let f=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(h),this.ht=il(f,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.ht?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.ht?.setConnected(!1)}render(){return Fe}};ke._$litElement$=!0,ke.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:ke});var Nh=globalThis.litElementPolyfillSupport;Nh?.({LitElement:ke});(globalThis.litElementVersions??=[]).push("4.0.6");var{Y:$h}=Hh,Fh=D=>D===null||typeof D!="object"&&typeof D!="function";var Wa=(D,h)=>h===void 0?D?._$litType$!==void 0:D?._$litType$===h,Wh=D=>D?._$litType$?.h!=null;var sl=D=>D.strings===void 0,Ba=()=>document.createComment(""),ws=(D,h,f)=>{let C=D._$AA.parentNode,I=h===void 0?D._$AB:h._$AA;if(f===void 0){let X=C.insertBefore(Ba(),I),W=C.insertBefore(Ba(),I);f=new $h(X,W,D,D.options)}else{let X=f._$AB.nextSibling,W=f._$AM,at=W!==D;if(at){let q;f._$AQ?.(D),f._$AM=D,f._$AP!==void 0&&(q=D._$AU)!==W._$AU&&f._$AP(q)}if(X!==I||at){let q=f._$AA;for(;q!==X;){let Rt=q.nextSibling;C.insertBefore(q,I),q=Rt}}}return f},xs=(D,h,f=D)=>(D._$AI(h,f),D),Bh={},on=(D,h=Bh)=>D._$AH=h,zo=D=>D._$AH,Ao=D=>{D._$AP?.(!1,!0);let h=D._$AA,f=D._$AB.nextSibling;for(;h!==f;){let C=h.nextSibling;h.remove(),h=C}},nl=D=>{D._$AR()};var Ti=D=>(...h)=>({_$litDirective$:D,values:h}),Bi=class{constructor(h){}get _$AU(){return this._$AM._$AU}_$AT(h,f,C){this.nt=h,this._$AM=f,this.rt=C}_$AS(h,f){return this.update(h,f)}update(h,f){return this.render(...f)}};var tn=(D,h)=>{let f=D._$AN;if(f===void 0)return!1;for(let C of f)C._$AO?.(h,!1),tn(C,h);return!0},On=D=>{let h,f;do{if((h=D._$AM)===void 0)break;f=h._$AN,f.delete(D),D=h}while(f?.size===0)},ol=D=>{for(let h;h=D._$AM;D=h){let f=h._$AN;if(f===void 0)h._$AN=f=new Set;else if(f.has(D))break;f.add(D),Vh(h)}};function Uh(D){this._$AN!==void 0?(On(this),this._$AM=D,ol(this)):this._$AM=D}function jh(D,h=!1,f=0){let C=this._$AH,I=this._$AN;if(I!==void 0&&I.size!==0)if(h)if(Array.isArray(C))for(let X=f;X{D.type==2&&(D._$AP??=jh,D._$AQ??=Uh)},rn=class extends Bi{constructor(){super(...arguments),this._$AN=void 0}_$AT(h,f,C){super._$AT(h,f,C),ol(this),this.isConnected=h._$AU}_$AO(h,f=!0){h!==this.isConnected&&(this.isConnected=h,h?this.reconnected?.():this.disconnected?.()),f&&(tn(this,h),On(this))}setValue(h){if(sl(this.nt))this.nt._$AI(h,this);else{let f=[...this.nt._$AH];f[this.rt]=h,this.nt._$AI(f,this,0)}}disconnected(){}reconnected(){}};var zn=class{constructor(h){this.ct=h}disconnect(){this.ct=void 0}reconnect(h){this.ct=h}deref(){return this.ct}},Ln=class{constructor(){this.lt=void 0,this.ut=void 0}get(){return this.lt}pause(){this.lt??=new Promise(h=>this.ut=h)}resume(){this.ut?.(),this.lt=this.ut=void 0}};var Hn=class extends rn{constructor(){super(...arguments),this.dt=new zn(this),this.ft=new Ln}render(h,f){return Fe}update(h,[f,C]){if(this.isConnected||this.disconnected(),f===this.vt)return Fe;this.vt=f;let I=0,{dt:X,ft:W}=this;return(async(at,q)=>{for await(let Rt of at)if(await q(Rt)===!1)return})(f,async at=>{for(;W.get();)await W.get();let q=X.deref();if(q!==void 0){if(q.vt!==f)return!1;C!==void 0&&(at=C(at,I)),q.commitValue(at,I),I++}return!0}),Fe}commitValue(h,f){this.setValue(h)}disconnected(){this.dt.disconnect(),this.ft.pause()}reconnected(){this.dt.reconnect(this),this.ft.resume()}},Kh=Ti(Hn),Zh=Ti(class extends Hn{constructor(D){if(super(D),D.type!==2)throw Error("asyncAppend can only be used in child expressions")}update(D,h){return this.ht=D,super.update(D,h)}commitValue(D,h){h===0&&nl(this.ht);let f=ws(this.ht);xs(f,D)}}),Ua=D=>Wh(D)?D._$litType$.h:D.strings,Jh=Ti(class extends Bi{constructor(D){super(D),this.yt=new WeakMap}render(D){return[D]}update(D,[h]){let f=Wa(this.bt)?Ua(this.bt):null,C=Wa(h)?Ua(h):null;if(f!==null&&(C===null||f!==C)){let I=zo(D).pop(),X=this.yt.get(f);if(X===void 0){let W=document.createDocumentFragment();X=il(ee,W),X.setConnected(!1),this.yt.set(f,X)}on(X,[I]),ws(X,void 0,I)}if(C!==null){if(f===null||f!==C){let I=this.yt.get(C);if(I!==void 0){let X=zo(I).pop();nl(D),ws(D,void 0,X),on(D,[X])}}this.bt=h}else this.bt=void 0;return this.render(h)}});var tc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==1||D.name!=="class"||D.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(D){return" "+Object.keys(D).filter(h=>D[h]).join(" ")+" "}update(D,[h]){if(this.gt===void 0){this.gt=new Set,D.strings!==void 0&&(this.wt=new Set(D.strings.join(" ").split(/\s/).filter(C=>C!=="")));for(let C in h)h[C]&&!this.wt?.has(C)&&this.gt.add(C);return this.render(h)}let f=D.element.classList;for(let C of this.gt)C in h||(f.remove(C),this.gt.delete(C));for(let C in h){let I=!!h[C];I===this.gt.has(C)||this.wt?.has(C)||(I?(f.add(C),this.gt.add(C)):(f.remove(C),this.gt.delete(C)))}return Fe}}),Yh={},ec=Ti(class extends Bi{constructor(){super(...arguments),this._t=Yh}render(D,h){return h()}update(D,[h,f]){if(Array.isArray(h)){if(Array.isArray(this._t)&&this._t.length===h.length&&h.every((C,I)=>C===this._t[I]))return Fe}else if(this._t===h)return Fe;return this._t=Array.isArray(h)?Array.from(h):h,this.render(h,f)}});var ic=Ti(class extends Bi{constructor(){super(...arguments),this.key=ee}render(D,h){return this.key=D,h}update(D,[h,f]){return h!==this.key&&(on(D),this.key=h),f}}),sc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==3&&D.type!==1&&D.type!==4)throw Error("The `live` directive is not allowed on child or event bindings");if(!sl(D))throw Error("`live` bindings can only contain a single expression")}render(D){return D}update(D,[h]){if(h===Fe||h===ee)return h;let f=D.element,C=D.name;if(D.type===3){if(h===f[C])return Fe}else if(D.type===4){if(!!h===f.hasAttribute(C))return Fe}else if(D.type===1&&f.getAttribute(C)===h+"")return Fe;return on(D),h}});var Ro=new WeakMap,nc=Ti(class extends rn{render(D){return ee}update(D,[h]){let f=h!==this.ct;return f&&this.ct!==void 0&&this.St(void 0),(f||this.$t!==this.Tt)&&(this.ct=h,this.xt=D.options?.host,this.St(this.Tt=D.element)),ee}St(D){if(this.isConnected||(D=void 0),typeof this.ct=="function"){let h=this.xt??globalThis,f=Ro.get(h);f===void 0&&(f=new WeakMap,Ro.set(h,f)),f.get(this.ct)!==void 0&&this.ct.call(this.xt,void 0),f.set(this.ct,D),D!==void 0&&this.ct.call(this.xt,D)}else this.ct.value=D}get $t(){return typeof this.ct=="function"?Ro.get(this.xt??globalThis)?.get(this.ct):this.ct?.value}disconnected(){this.$t===this.Tt&&this.St(void 0)}reconnected(){this.St(this.Tt)}}),ja=(D,h,f)=>{let C=new Map;for(let I=h;I<=f;I++)C.set(D[I],I);return C},oc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==2)throw Error("repeat() can only be used in text expressions")}Et(D,h,f){let C;f===void 0?f=h:h!==void 0&&(C=h);let I=[],X=[],W=0;for(let at of D)I[W]=C?C(at,W):W,X[W]=f(at,W),W++;return{values:X,keys:I}}render(D,h,f){return this.Et(D,h,f).values}update(D,[h,f,C]){let I=zo(D),{values:X,keys:W}=this.Et(h,f,C);if(!Array.isArray(I))return this.Ct=W,X;let at=this.Ct??=[],q=[],Rt,Ot,ft=0,xt=I.length-1,jt=0,te=X.length-1;for(;ft<=xt&&jt<=te;)if(I[ft]===null)ft++;else if(I[xt]===null)xt--;else if(at[ft]===W[jt])q[jt]=xs(I[ft],X[jt]),ft++,jt++;else if(at[xt]===W[te])q[te]=xs(I[xt],X[te]),xt--,te--;else if(at[ft]===W[te])q[te]=xs(I[ft],X[te]),ws(D,q[te+1],I[ft]),ft++,te--;else if(at[xt]===W[jt])q[jt]=xs(I[xt],X[jt]),ws(D,I[ft],I[xt]),xt--,jt++;else if(Rt===void 0&&(Rt=ja(W,jt,te),Ot=ja(at,ft,xt)),Rt.has(at[ft]))if(Rt.has(at[xt])){let ae=Ot.get(W[jt]),Ae=ae!==void 0?I[ae]:null;if(Ae===null){let ue=ws(D,I[ft]);xs(ue,X[jt]),q[jt]=ue}else q[jt]=xs(Ae,X[jt]),ws(D,I[ft],Ae),I[ae]=null;jt++}else Ao(I[xt]),xt--;else Ao(I[ft]),ft++;for(;jt<=te;){let ae=ws(D,q[te+1]);xs(ae,X[jt]),q[jt++]=ae}for(;ft<=xt;){let ae=I[ft++];ae!==null&&Ao(ae)}return this.Ct=W,on(D,q),Fe}}),rl="important",qh=" !"+rl,rc=Ti(class extends Bi{constructor(D){if(super(D),D.type!==1||D.name!=="style"||D.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(D){return Object.keys(D).reduce((h,f)=>{let C=D[f];return C==null?h:h+`${f=f.includes("-")?f:f.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${C};`},"")}update(D,[h]){let{style:f}=D.element;if(this.Pt===void 0)return this.Pt=new Set(Object.keys(h)),this.render(h);for(let C of this.Pt)h[C]==null&&(this.Pt.delete(C),C.includes("-")?f.removeProperty(C):f[C]=null);for(let C in h){let I=h[C];if(I!=null){this.Pt.add(C);let X=typeof I=="string"&&I.endsWith(qh);C.includes("-")||X?f.setProperty(C,X?I.slice(0,-11):I,X?rl:""):f[C]=I}}return Fe}}),ac=Ti(class extends Bi{constructor(D){if(super(D),D.type!==2)throw Error("templateContent can only be used in child bindings")}render(D){return this.At===D?Fe:(this.At=D,document.importNode(D.content,!0))}}),Ns=class extends Bi{constructor(h){if(super(h),this.bt=ee,h.type!==2)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(h){if(h===ee||h==null)return this.kt=void 0,this.bt=h;if(h===Fe)return h;if(typeof h!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(h===this.bt)return this.kt;this.bt=h;let f=[h];return f.raw=f,this.kt={_$litType$:this.constructor.resultType,strings:f,values:[]}}};Ns.directiveName="unsafeHTML",Ns.resultType=1;var $n=Ti(Ns);var an=class extends Ns{};an.directiveName="unsafeSVG",an.resultType=2;var lc=Ti(an),Va=D=>!Fh(D)&&typeof D.then=="function",Ya=1073741823;var Lo=class extends rn{constructor(){super(...arguments),this.Mt=Ya,this.Ut=[],this.dt=new zn(this),this.ft=new Ln}render(...h){return h.find(f=>!Va(f))??Fe}update(h,f){let C=this.Ut,I=C.length;this.Ut=f;let X=this.dt,W=this.ft;this.isConnected||this.disconnected();for(let at=0;atthis.Mt);at++){let q=f[at];if(!Va(q))return this.Mt=at,q;at{for(;W.get();)await W.get();let Ot=X.deref();if(Ot!==void 0){let ft=Ot.Ut.indexOf(q);ft>-1&&ft{if(D?.r===Xh)return D?._$litStatic$};var qa=new Map,al=D=>(h,...f)=>{let C=f.length,I,X,W=[],at=[],q,Rt=0,Ot=!1;for(;Rt(()=>{"use strict";var D={d:(St,r)=>{for(var d in r)D.o(r,d)&&!D.o(St,d)&&Object.defineProperty(St,d,{enumerable:!0,get:r[d]})},o:(St,r)=>Object.prototype.hasOwnProperty.call(St,r)},h={};D.d(h,{GridStack:()=>Bt});class f{static getElements(r,d=document){if(typeof r=="string"){let y="getElementById"in d?d:void 0;if(y&&!isNaN(+r[0])){let P=y.getElementById(r);return P?[P]:[]}let v=d.querySelectorAll(r);return v.length||r[0]==="."||r[0]==="#"||(v=d.querySelectorAll("."+r),v.length||(v=d.querySelectorAll("#"+r))),Array.from(v)}return[r]}static getElement(r,d=document){if(typeof r=="string"){let y="getElementById"in d?d:void 0;if(!r.length)return null;if(y&&r[0]==="#")return y.getElementById(r.substring(1));if(r[0]==="#"||r[0]==="."||r[0]==="[")return d.querySelector(r);if(y&&!isNaN(+r[0]))return y.getElementById(r);let v=d.querySelector(r);return y&&!v&&(v=y.getElementById(r)),v||(v=d.querySelector("."+r)),v}return r}static shouldSizeToContent(r,d=!1){return r?.grid&&(d?r.sizeToContent===!0||r.grid.opts.sizeToContent===!0&&r.sizeToContent===void 0:!!r.sizeToContent||r.grid.opts.sizeToContent&&r.sizeToContent!==!1)}static isIntercepted(r,d){return!(r.y>=d.y+d.h||r.y+r.h<=d.y||r.x+r.w<=d.x||r.x>=d.x+d.w)}static isTouching(r,d){return f.isIntercepted(r,{x:d.x-.5,y:d.y-.5,w:d.w+1,h:d.h+1})}static areaIntercept(r,d){let y=r.x>d.x?r.x:d.x,v=r.x+r.wd.y?r.y:d.y,F=r.y+r.h{let F=d*((v.y??1e4)-(P.y??1e4));return F===0?d*((v.x??1e4)-(P.x??1e4)):F})}static find(r,d){return d?r.find(y=>y.id===d):void 0}static createStylesheet(r,d,y){let v=document.createElement("style"),P=y?.nonce;return P&&(v.nonce=P),v.setAttribute("type","text/css"),v.setAttribute("gs-style-id",r),v.styleSheet?v.styleSheet.cssText="":v.appendChild(document.createTextNode("")),d?d.insertBefore(v,d.firstChild):(d=document.getElementsByTagName("head")[0]).appendChild(v),v.sheet}static removeStylesheet(r,d){let y=(d||document).querySelector("STYLE[gs-style-id="+r+"]");y&&y.parentNode&&y.remove()}static addCSSRule(r,d,y){typeof r.addRule=="function"?r.addRule(d,y):typeof r.insertRule=="function"&&r.insertRule(`${d}{${y}}`)}static toBool(r){return typeof r=="boolean"?r:typeof r=="string"?!((r=r.toLowerCase())===""||r==="no"||r==="false"||r==="0"):!!r}static toNumber(r){return r===null||r.length===0?void 0:Number(r)}static parseHeight(r){let d,y="px";if(typeof r=="string")if(r==="auto"||r==="")d=0;else{let v=r.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!v)throw new Error(`Invalid height val = ${r}`);y=v[2]||"px",d=parseFloat(v[1])}else d=r;return{h:d,unit:y}}static defaults(r,...d){return d.forEach(y=>{for(let v in y){if(!y.hasOwnProperty(v))return;r[v]===null||r[v]===void 0?r[v]=y[v]:typeof y[v]=="object"&&typeof r[v]=="object"&&this.defaults(r[v],y[v])}}),r}static same(r,d){if(typeof r!="object")return r==d;if(typeof r!=typeof d||Object.keys(r).length!==Object.keys(d).length)return!1;for(let y in r)if(r[y]!==d[y])return!1;return!0}static copyPos(r,d,y=!1){return d.x!==void 0&&(r.x=d.x),d.y!==void 0&&(r.y=d.y),d.w!==void 0&&(r.w=d.w),d.h!==void 0&&(r.h=d.h),y&&(d.minW&&(r.minW=d.minW),d.minH&&(r.minH=d.minH),d.maxW&&(r.maxW=d.maxW),d.maxH&&(r.maxH=d.maxH)),r}static samePos(r,d){return r&&d&&r.x===d.x&&r.y===d.y&&(r.w||1)===(d.w||1)&&(r.h||1)===(d.h||1)}static sanitizeMinMax(r){r.minW||delete r.minW,r.minH||delete r.minH,r.maxW||delete r.maxW,r.maxH||delete r.maxH}static removeInternalAndSame(r,d){if(typeof r=="object"&&typeof d=="object")for(let y in r){let v=r[y],P=d[y];y[0]==="_"||v===P?delete r[y]:v&&typeof v=="object"&&P!==void 0&&(f.removeInternalAndSame(v,P),Object.keys(v).length||delete r[y])}}static removeInternalForSave(r,d=!0){for(let y in r)y[0]!=="_"&&r[y]!==null&&r[y]!==void 0||delete r[y];delete r.grid,d&&delete r.el,r.autoPosition||delete r.autoPosition,r.noResize||delete r.noResize,r.noMove||delete r.noMove,r.locked||delete r.locked,r.w!==1&&r.w!==r.minW||delete r.w,r.h!==1&&r.h!==r.minH||delete r.h}static throttle(r,d){let y=!1;return(...v)=>{y||(y=!0,setTimeout(()=>{r(...v),y=!1},d))}}static removePositioningStyles(r){let d=r.style;d.position&&d.removeProperty("position"),d.left&&d.removeProperty("left"),d.top&&d.removeProperty("top"),d.width&&d.removeProperty("width"),d.height&&d.removeProperty("height")}static getScrollElement(r){if(!r)return document.scrollingElement||document.documentElement;let d=getComputedStyle(r);return/(auto|scroll)/.test(d.overflow+d.overflowY)?r:this.getScrollElement(r.parentElement)}static updateScrollPosition(r,d,y){let v=r.getBoundingClientRect(),P=window.innerHeight||document.documentElement.clientHeight;if(v.top<0||v.bottom>P){let F=v.bottom-P,Y=v.top,nt=this.getScrollElement(r);if(nt!==null){let V=nt.scrollTop;v.top<0&&y<0?r.offsetHeight>P?nt.scrollTop+=y:nt.scrollTop+=Math.abs(Y)>Math.abs(y)?y:Y:y>0&&(r.offsetHeight>P?nt.scrollTop+=y:nt.scrollTop+=F>y?y:F),d.top+=nt.scrollTop-V}}}static updateScrollResize(r,d,y){let v=this.getScrollElement(d),P=v.clientHeight,F=v===this.getScrollElement()?0:v.getBoundingClientRect().top,Y=r.clientY-F,nt=Y>P-y;YP===v)&&(y[v]=f.cloneDeep(r[v]));return y}static cloneNode(r){let d=r.cloneNode(!0);return d.removeAttribute("id"),d}static appendTo(r,d){let y;y=typeof d=="string"?f.getElement(d):d,y&&y.appendChild(r)}static addElStyles(r,d){if(d instanceof Object)for(let y in d)d.hasOwnProperty(y)&&(Array.isArray(d[y])?d[y].forEach(v=>{r.style[y]=v}):r.style[y]=d[y])}static initEvent(r,d){let y={type:d.type},v={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:d.target?d.target:r.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(P=>y[P]=r[P]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(P=>y[P]=r[P]),{...y,...v}}static simulateMouseEvent(r,d,y){let v=document.createEvent("MouseEvents");v.initMouseEvent(d,!0,!0,window,1,r.screenX,r.screenY,r.clientX,r.clientY,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,0,r.target),(y||r.target).dispatchEvent(v)}static getValuesFromTransformedElement(r){let d=document.createElement("div");f.addElStyles(d,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),r.appendChild(d);let y=d.getBoundingClientRect();return r.removeChild(d),d.remove(),{xScale:1/y.width,yScale:1/y.height,xOffset:y.left,yOffset:y.top}}static swap(r,d,y){if(!r)return;let v=r[d];r[d]=r[y],r[y]=v}static canBeRotated(r){return!(!r||r.w===r.h||r.locked||r.noResize||r.grid?.opts.disableResize||r.minW&&r.minW===r.maxW||r.minH&&r.minH===r.maxH)}}class C{constructor(r={}){this.addedNodes=[],this.removedNodes=[],this.column=r.column||12,this.maxRow=r.maxRow,this._float=r.float,this.nodes=r.nodes||[],this.onChange=r.onChange}batchUpdate(r=!0,d=!0){return!!this.batchMode===r||(this.batchMode=r,r?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,d&&this._packNodes(),this._notify())),this}_useEntireRowArea(r,d){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!r._moving||r._skipDown||d.y<=r.y)}_fixCollisions(r,d=r,y,v={}){if(this.sortNodes(-1),!(y=y||this.collide(r,d)))return!1;if(r._moving&&!v.nested&&!this.float&&this.swap(r,y))return!0;let P=d;!this._loading&&this._useEntireRowArea(r,d)&&(P={x:0,w:this.column,y:d.y,h:d.h},y=this.collide(r,P,v.skip));let F=!1,Y={nested:!0,pack:!1};for(;y=y||this.collide(r,P,v.skip);){let nt;if(y.locked||this._loading||r._moving&&!r._skipDown&&d.y>r.y&&!this.float&&(!this.collide(y,{...y,y:r.y},r)||!this.collide(y,{...y,y:d.y-y.h},r))?(r._skipDown=r._skipDown||d.y>r.y,nt=this.moveNode(r,{...d,y:y.y+y.h,...Y}),(y.locked||this._loading)&&nt?f.copyPos(d,r):!y.locked&&nt&&v.pack&&(this._packNodes(),d.y=y.y+y.h,f.copyPos(r,d)),F=F||nt):nt=this.moveNode(y,{...y,y:d.y+d.h,skip:r,...Y}),!nt)return F;y=void 0}return F}collide(r,d=r,y){let v=r._id,P=y?._id;return this.nodes.find(F=>F._id!==v&&F._id!==P&&f.isIntercepted(F,d))}collideAll(r,d=r,y){let v=r._id,P=y?._id;return this.nodes.filter(F=>F._id!==v&&F._id!==P&&f.isIntercepted(F,d))}directionCollideCoverage(r,d,y){if(!d.rect||!r._rect)return;let v,P=r._rect,F={...d.rect};F.y>P.y?(F.h+=F.y-P.y,F.y=P.y):F.h+=P.y-F.y,F.x>P.x?(F.w+=F.x-P.x,F.x=P.x):F.w+=P.x-F.x;let Y=.5;for(let nt of y){if(nt.locked||!nt._rect)break;let V=nt._rect,it=Number.MAX_VALUE,kt=Number.MAX_VALUE;P.yV.y+V.h&&(it=(V.y+V.h-F.y)/V.h),P.xV.x+V.w&&(kt=(V.x+V.w-F.x)/V.w);let Et=Math.min(kt,it);Et>Y&&(Y=Et,v=nt)}return d.collide=v,v}cacheRects(r,d,y,v,P,F){return this.nodes.forEach(Y=>Y._rect={y:Y.y*d+y,x:Y.x*r+F,w:Y.w*r-F-v,h:Y.h*d-y-P}),this}swap(r,d){if(!d||d.locked||!r||r.locked)return!1;function y(){let P=d.x,F=d.y;return d.x=r.x,d.y=r.y,r.h!=d.h?(r.x=P,r.y=d.y+d.h):r.w!=d.w?(r.x=d.x+d.w,r.y=F):(r.x=P,r.y=F),r._dirty=d._dirty=!0,!0}let v;if(r.w===d.w&&r.h===d.h&&(r.x===d.x||r.y===d.y)&&(v=f.isTouching(r,d)))return y();if(v!==!1){if(r.w===d.w&&r.x===d.x&&(v||(v=f.isTouching(r,d)))){if(d.y{let V;F.locked||(F.autoPosition=!0,r==="list"&&Y&&(V=nt[Y-1])),this.addNode(F,!1,V)}),v||delete this._inColumnResize,y||this.batchUpdate(!1),this}set float(r){this._float!==r&&(this._float=r||!1,r||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(r=1){return this.nodes=f.sort(this.nodes,r),this}_packNodes(){return this.batchMode||(this.sortNodes(),this.float?this.nodes.forEach(r=>{if(r._updating||r._orig===void 0||r.y===r._orig.y)return;let d=r.y;for(;d>r._orig.y;)--d,this.collide(r,{x:r.x,y:d,w:r.w,h:r.h})||(r._dirty=!0,r.y=d)}):this.nodes.forEach((r,d)=>{if(!r.locked)for(;r.y>0;){let y=d===0?0:r.y-1;if(d!==0&&this.collide(r,{x:r.x,y,w:r.w,h:r.h}))break;r._dirty=r.y!==y,r.y=y}})),this}prepareNode(r,d){r._id=r._id??C._idSeq++,r.x!==void 0&&r.y!==void 0&&r.x!==null&&r.y!==null||(r.autoPosition=!0);let y={x:0,y:0,w:1,h:1};return f.defaults(r,y),r.autoPosition||delete r.autoPosition,r.noResize||delete r.noResize,r.noMove||delete r.noMove,f.sanitizeMinMax(r),typeof r.x=="string"&&(r.x=Number(r.x)),typeof r.y=="string"&&(r.y=Number(r.y)),typeof r.w=="string"&&(r.w=Number(r.w)),typeof r.h=="string"&&(r.h=Number(r.h)),isNaN(r.x)&&(r.x=y.x,r.autoPosition=!0),isNaN(r.y)&&(r.y=y.y,r.autoPosition=!0),isNaN(r.w)&&(r.w=y.w),isNaN(r.h)&&(r.h=y.h),this.nodeBoundFix(r,d),r}nodeBoundFix(r,d){let y=r._orig||f.copyPos({},r);if(r.maxW&&(r.w=Math.min(r.w,r.maxW)),r.maxH&&(r.h=Math.min(r.h,r.maxH)),r.minW&&r.minW<=this.column&&(r.w=Math.max(r.w,r.minW)),r.minH&&(r.h=Math.max(r.h,r.minH)),(r.x||0)+(r.w||1)>this.column&&this.column<12&&!this._inColumnResize&&r._id&&this.findCacheLayout(r,12)===-1){let v={...r};v.autoPosition||v.x===void 0?(delete v.x,delete v.y):v.x=Math.min(11,v.x),v.w=Math.min(12,v.w||1),this.cacheOneLayout(v,12)}return r.w>this.column?r.w=this.column:r.w<1&&(r.w=1),this.maxRow&&r.h>this.maxRow?r.h=this.maxRow:r.h<1&&(r.h=1),r.x<0&&(r.x=0),r.y<0&&(r.y=0),r.x+r.w>this.column&&(d?r.w=this.column-r.x:r.x=this.column-r.w),this.maxRow&&r.y+r.h>this.maxRow&&(d?r.h=this.maxRow-r.y:r.y=this.maxRow-r.h),f.samePos(r,y)||(r._dirty=!0),this}getDirtyNodes(r){return r?this.nodes.filter(d=>d._dirty&&!f.samePos(d,d._orig)):this.nodes.filter(d=>d._dirty)}_notify(r){if(this.batchMode||!this.onChange)return this;let d=(r||[]).concat(this.getDirtyNodes());return this.onChange(d),this}cleanNodes(){return this.batchMode||this.nodes.forEach(r=>{delete r._dirty,delete r._lastTried}),this}saveInitial(){return this.nodes.forEach(r=>{r._orig=f.copyPos({},r),delete r._dirty}),this._hasLocked=this.nodes.some(r=>r.locked),this}restoreInitial(){return this.nodes.forEach(r=>{f.samePos(r,r._orig)||(f.copyPos(r,r._orig),r._dirty=!0)}),this._notify(),this}findEmptyPosition(r,d=this.nodes,y=this.column,v){let P=!1;for(let F=v?v.y*y+(v.x+v.w):0;!P;++F){let Y=F%y,nt=Math.floor(F/y);if(Y+r.w>y)continue;let V={x:Y,y:nt,w:r.w,h:r.h};d.find(it=>f.isIntercepted(V,it))||(r.x===Y&&r.y===nt||(r._dirty=!0),r.x=Y,r.y=nt,delete r.autoPosition,P=!0)}return P}addNode(r,d=!1,y){let v;return this.nodes.find(P=>P._id===r._id)||(this._inColumnResize?this.nodeBoundFix(r):this.prepareNode(r),delete r._temporaryRemoved,delete r._removeDOM,r.autoPosition&&this.findEmptyPosition(r,this.nodes,this.column,y)&&(delete r.autoPosition,v=!0),this.nodes.push(r),d&&this.addedNodes.push(r),v||this._fixCollisions(r),this.batchMode||this._packNodes()._notify(),r)}removeNode(r,d=!0,y=!1){return this.nodes.find(v=>v._id===r._id)?(y&&this.removedNodes.push(r),d&&(r._removeDOM=!0),this.nodes=this.nodes.filter(v=>v._id!==r._id),r._isAboutToRemove||this._packNodes(),this._notify([r]),this):this}removeAll(r=!0,d=!0){if(delete this._layouts,!this.nodes.length)return this;r&&this.nodes.forEach(v=>v._removeDOM=!0);let y=this.nodes;return this.removedNodes=d?y:[],this.nodes=[],this._notify(y)}moveNodeCheck(r,d){if(!this.changedPosConstrain(r,d))return!1;if(d.pack=!0,!this.maxRow)return this.moveNode(r,d);let y,v=new C({column:this.column,float:this.float,nodes:this.nodes.map(F=>F._id===r._id?(y={...F},y):{...F})});if(!y)return!1;let P=v.moveNode(y,d)&&v.getRow()<=Math.max(this.getRow(),this.maxRow);if(!P&&!d.resizing&&d.collide){let F=d.collide.el.gridstackNode;if(this.swap(r,F))return this._notify(),!0}return!!P&&(v.nodes.filter(F=>F._dirty).forEach(F=>{let Y=this.nodes.find(nt=>nt._id===F._id);Y&&(f.copyPos(Y,F),Y._dirty=!0)}),this._notify(),!0)}willItFit(r){if(delete r._willFitPos,!this.maxRow)return!0;let d=new C({column:this.column,float:this.float,nodes:this.nodes.map(v=>({...v}))}),y={...r};return this.cleanupNode(y),delete y.el,delete y._id,delete y.content,delete y.grid,d.addNode(y),d.getRow()<=this.maxRow&&(r._willFitPos=f.copyPos({},y),!0)}changedPosConstrain(r,d){return d.w=d.w||r.w,d.h=d.h||r.h,r.x!==d.x||r.y!==d.y||(r.maxW&&(d.w=Math.min(d.w,r.maxW)),r.maxH&&(d.h=Math.min(d.h,r.maxH)),r.minW&&(d.w=Math.max(d.w,r.minW)),r.minH&&(d.h=Math.max(d.h,r.minH)),r.w!==d.w||r.h!==d.h)}moveNode(r,d){if(!r||!d)return!1;let y;d.pack!==void 0||this.batchMode||(y=d.pack=!0),typeof d.x!="number"&&(d.x=r.x),typeof d.y!="number"&&(d.y=r.y),typeof d.w!="number"&&(d.w=r.w),typeof d.h!="number"&&(d.h=r.h);let v=r.w!==d.w||r.h!==d.h,P=f.copyPos({},r,!0);if(f.copyPos(P,d),this.nodeBoundFix(P,v),f.copyPos(d,P),!d.forceCollide&&f.samePos(r,d))return!1;let F=f.copyPos({},r),Y=this.collideAll(r,P,d.skip),nt=!0;if(Y.length){let V=r._moving&&!d.nested,it=V?this.directionCollideCoverage(r,d,Y):Y[0];if(V&&it&&r.grid?.opts?.subGridDynamic&&!r.grid._isTemp){let kt=f.areaIntercept(d.rect,it._rect),Et=f.area(d.rect),ie=f.area(it._rect);kt/(Et.8&&(it.grid.makeSubGrid(it.el,void 0,r),it=void 0)}it?nt=!this._fixCollisions(r,P,it,d):(nt=!1,y&&delete d.pack)}return nt&&(r._dirty=!0,f.copyPos(r,P)),d.pack&&this._packNodes()._notify(),!f.samePos(r,F)}getRow(){return this.nodes.reduce((r,d)=>Math.max(r,d.y+d.h),0)}beginUpdate(r){return r._updating||(r._updating=!0,delete r._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){let r=this.nodes.find(d=>d._updating);return r&&(delete r._updating,delete r._skipDown),this}save(r=!0,d){let y=this._layouts?.length,v=y&&this.column!==y-1?this._layouts[y-1]:null,P=[];return this.sortNodes(),this.nodes.forEach(F=>{let Y=v?.find(V=>V._id===F._id),nt={...F,...Y||{}};f.removeInternalForSave(nt,!r),d&&d(F,nt),P.push(nt)}),P}layoutsNodesChange(r){return!this._layouts||this._inColumnResize||this._layouts.forEach((d,y)=>{if(!d||y===this.column)return this;if(y{if(!P._orig)return;let F=d.find(Y=>Y._id===P._id);F&&(F.y>=0&&P.y!==P._orig.y&&(F.y+=P.y-P._orig.y),P.x!==P._orig.x&&(F.x=Math.round(P.x*v)),P.w!==P._orig.w&&(F.w=Math.round(P.w*v)))})}}),this}columnChanged(r,d,y="moveScale"){if(!this.nodes.length||!d||r===d)return this;if(y==="none")return this;let v=y==="compact"||y==="list";v&&this.sortNodes(1),dr&&this._layouts){let Y=this._layouts[d]||[],nt=this._layouts.length-1;!Y.length&&r!==nt&&this._layouts[nt]?.length&&(r=nt,this._layouts[nt].forEach(V=>{let it=F.find(kt=>kt._id===V._id);it&&(v||V.autoPosition||(it.x=V.x??it.x,it.y=V.y??it.y),it.w=V.w??it.w,V.x!=null&&V.y!==void 0||(it.autoPosition=!0))})),Y.forEach(V=>{let it=F.findIndex(kt=>kt._id===V._id);if(it!==-1){let kt=F[it];if(v)return void(kt.w=V.w);(V.autoPosition||isNaN(V.x)||isNaN(V.y))&&this.findEmptyPosition(V,P),V.autoPosition||(kt.x=V.x??kt.x,kt.y=V.y??kt.y,kt.w=V.w??kt.w,P.push(kt)),F.splice(it,1)}})}if(v)this.compact(y,!1);else{if(F.length)if(typeof y=="function")y(d,r,P,F);else{let Y=v?1:d/r,nt=y==="move"||y==="moveScale",V=y==="scale"||y==="moveScale";F.forEach(it=>{it.x=d===1?0:nt?Math.round(it.x*Y):Math.min(it.x,d-1),it.w=d===1||r===1?1:V?Math.round(it.w*Y)||1:Math.min(it.w,d),P.push(it)}),F=[]}P=f.sort(P,-1),this._inColumnResize=!0,this.nodes=[],P.forEach(Y=>{this.addNode(Y,!1),delete Y._orig})}return this.nodes.forEach(Y=>delete Y._orig),this.batchUpdate(!1,!v),delete this._inColumnResize,this}cacheLayout(r,d,y=!1){let v=[];return r.forEach((P,F)=>{if(P._id===void 0){let Y=P.id?this.nodes.find(nt=>nt.id===P.id):void 0;P._id=Y?._id??C._idSeq++}v[F]={x:P.x,y:P.y,w:P.w,_id:P._id}}),this._layouts=y?[]:this._layouts||[],this._layouts[d]=v,this}cacheOneLayout(r,d){r._id=r._id??C._idSeq++;let y={x:r.x,y:r.y,w:r.w,_id:r._id};(r.autoPosition||r.x===void 0)&&(delete y.x,delete y.y,r.autoPosition&&(y.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[d]=this._layouts[d]||[];let v=this.findCacheLayout(r,d);return v===-1?this._layouts[d].push(y):this._layouts[d][v]=y,this}findCacheLayout(r,d){return this._layouts?.[d]?.findIndex(y=>y._id===r._id)??-1}removeNodeFromLayoutCache(r){if(this._layouts)for(let d=0;d0||navigator.msMaxTouchPoints>0);class q{}function Rt(St,r){if(St.touches.length>1)return;St.cancelable&&St.preventDefault();let d=St.changedTouches[0],y=document.createEvent("MouseEvents");y.initMouseEvent(r,!0,!0,window,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,null),St.target.dispatchEvent(y)}function Ot(St,r){St.cancelable&&St.preventDefault();let d=document.createEvent("MouseEvents");d.initMouseEvent(r,!0,!0,window,1,St.screenX,St.screenY,St.clientX,St.clientY,!1,!1,!1,!1,0,null),St.target.dispatchEvent(d)}function ft(St){q.touchHandled||(q.touchHandled=!0,Rt(St,"mousedown"))}function xt(St){q.touchHandled&&Rt(St,"mousemove")}function jt(St){if(!q.touchHandled)return;q.pointerLeaveTimeout&&(window.clearTimeout(q.pointerLeaveTimeout),delete q.pointerLeaveTimeout);let r=!!W.dragElement;Rt(St,"mouseup"),r||Rt(St,"click"),q.touchHandled=!1}function te(St){St.pointerType!=="mouse"&&St.target.releasePointerCapture(St.pointerId)}function ae(St){W.dragElement&&St.pointerType!=="mouse"&&Ot(St,"mouseenter")}function Ae(St){W.dragElement&&St.pointerType!=="mouse"&&(q.pointerLeaveTimeout=window.setTimeout(()=>{delete q.pointerLeaveTimeout,Ot(St,"mouseleave")},10))}class ue{constructor(r,d,y){this.host=r,this.dir=d,this.option=y,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){let r=this.el=document.createElement("div");return r.classList.add("ui-resizable-handle"),r.classList.add(`${ue.prefix}${this.dir}`),r.style.zIndex="100",r.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),at&&(this.el.addEventListener("touchstart",ft),this.el.addEventListener("pointerdown",te)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),at&&(this.el.removeEventListener("touchstart",ft),this.el.removeEventListener("pointerdown",te)),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(r){this.mouseDownEvent=r,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),at&&(this.el.addEventListener("touchmove",xt),this.el.addEventListener("touchend",jt)),r.stopPropagation(),r.preventDefault()}_mouseMove(r){let d=this.mouseDownEvent;this.moving?this._triggerEvent("move",r):Math.abs(r.x-d.x)+Math.abs(r.y-d.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",r),document.addEventListener("keydown",this._keyEvent)),r.stopPropagation()}_mouseUp(r){this.moving&&(this._triggerEvent("stop",r),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),at&&(this.el.removeEventListener("touchmove",xt),this.el.removeEventListener("touchend",jt)),delete this.moving,delete this.mouseDownEvent,r.stopPropagation(),r.preventDefault()}_keyEvent(r){r.key==="Escape"&&(this.host.gridstackNode?.grid?.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(r,d){return this.option[r]&&this.option[r](d),this}}ue.prefix="ui-resizable-";class _e{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(r,d){this._eventRegister[r]=d}off(r){delete this._eventRegister[r]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(r,d){if(!this.disabled&&this._eventRegister&&this._eventRegister[r])return this._eventRegister[r](d)}}class Oe extends _e{constructor(r,d={}){super(),this.el=r,this.option=d,this.rectScale={x:1,y:1},this._ui=()=>{let y=this.el.parentElement.getBoundingClientRect(),v={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},P=this.temporalRect||v;return{position:{left:(P.left-y.left)*this.rectScale.x,top:(P.top-y.top)*this.rectScale.y},size:{width:P.width*this.rectScale.x,height:P.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(r,d){super.on(r,d)}off(r){super.off(r)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(r){let d=r.handles&&r.handles!==this.option.handles,y=r.autoHide&&r.autoHide!==this.option.autoHide;return Object.keys(r).forEach(v=>this.option[v]=r[v]),d&&(this._removeHandlers(),this._setupHandlers()),y&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(r){return r?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),W.overResizeElement===this&&delete W.overResizeElement),this}_mouseOver(r){W.overResizeElement||W.dragElement||(W.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(r){W.overResizeElement===this&&(delete W.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(r=>r.trim()).map(r=>new ue(this.el,r,{start:d=>{this._resizeStart(d)},stop:d=>{this._resizeStop(d)},move:d=>{this._resizing(d,r)}})),this}_resizeStart(r){this.sizeToContent=f.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=f.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=r,this._setupHelper(),this._applyChange();let d=f.initEvent(r,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(d,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",d),this}_resizing(r,d){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(r,d),this._applyChange();let y=f.initEvent(r,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(y,this._ui()),this.triggerEvent("resize",y),this}_resizeStop(r){let d=f.initEvent(r,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(d),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",d),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=Oe._originStyleProp.map(y=>this.el.style[y]),this.parentOriginStylePosition=this.el.parentElement.style.position;let r=this.el.parentElement,d=f.getValuesFromTransformedElement(r);return this.rectScale={x:d.xScale,y:d.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return Oe._originStyleProp.forEach((r,d)=>{this.el.style[r]=this.elOriginStyleVal[d]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(r,d){let y=this.startEvent,v={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},P=r.clientX-y.clientX,F=this.sizeToContent?0:r.clientY-y.clientY,Y,nt;d.indexOf("e")>-1?v.width+=P:d.indexOf("w")>-1&&(v.width-=P,v.left+=P,Y=!0),d.indexOf("s")>-1?v.height+=F:d.indexOf("n")>-1&&(v.height-=F,v.top+=F,nt=!0);let V=this._constrainSize(v.width,v.height,Y,nt);return Math.round(v.width)!==Math.round(V.width)&&(d.indexOf("w")>-1&&(v.left+=v.width-V.width),v.width=V.width),Math.round(v.height)!==Math.round(V.height)&&(d.indexOf("n")>-1&&(v.top+=v.height-V.height),v.height=V.height),v}_constrainSize(r,d,y,v){let P=this.option,F=(y?P.maxWidthMoveLeft:P.maxWidth)||Number.MAX_SAFE_INTEGER,Y=P.minWidth/this.rectScale.x||r,nt=(v?P.maxHeightMoveUp:P.maxHeight)||Number.MAX_SAFE_INTEGER,V=P.minHeight/this.rectScale.y||d;return{width:Math.min(F,Math.max(Y,r)),height:Math.min(nt,Math.max(V,d))}}_applyChange(){let r={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){let d=this.el.parentElement,{left:y,top:v}=d.getBoundingClientRect();r={left:y,top:v,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(d=>{let y=this.temporalRect[d],v=d==="width"||d==="left"?this.rectScale.x:d==="height"||d==="top"?this.rectScale.y:1;this.el.style[d]=(y-r[d])*v+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(r=>r.destroy()),delete this.handlers,this}}Oe._originStyleProp=["width","height","position","left","top","opacity","zIndex"];class Ee extends _e{constructor(r,d={}){super(),this.el=r,this.option=d,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};let y=d.handle.substring(1),v=r.gridstackNode;this.dragEls=r.classList.contains(y)?[r]:v?.subGrid?[r.querySelector(d.handle)||r]:Array.from(r.querySelectorAll(d.handle)),this.dragEls.length===0&&(this.dragEls=[r]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}on(r,d){super.on(r,d)}off(r){super.off(r)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(r=>{r.addEventListener("mousedown",this._mouseDown),at&&(r.addEventListener("touchstart",ft),r.addEventListener("pointerdown",te))}),this.el.classList.remove("ui-draggable-disabled"))}disable(r=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(d=>{d.removeEventListener("mousedown",this._mouseDown),at&&(d.removeEventListener("touchstart",ft),d.removeEventListener("pointerdown",te))}),r||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(r){return Object.keys(r).forEach(d=>this.option[d]=r[d]),this}_mouseDown(r){if(!W.mouseHandled)return r.button!==0||!this.dragEls.find(d=>d===r.target)&&r.target.closest('input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle')||this.option.cancel&&r.target.closest(this.option.cancel)||(this.mouseDownEvent=r,delete this.dragging,delete W.dragElement,delete W.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),at&&(r.target.addEventListener("touchmove",xt),r.target.addEventListener("touchend",jt)),r.preventDefault(),document.activeElement&&document.activeElement.blur(),W.mouseHandled=!0),!0}_callDrag(r){if(!this.dragging)return;let d=f.initEvent(r,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(d,this.ui()),this.triggerEvent("drag",d)}_mouseMove(r){let d=this.mouseDownEvent;if(this.lastDrag=r,this.dragging)if(this._dragFollow(r),W.pauseDrag){let y=Number.isInteger(W.pauseDrag)?W.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(r),y)}else this._callDrag(r);else if(Math.abs(r.x-d.x)+Math.abs(r.y-d.y)>3){this.dragging=!0,W.dragElement=this;let y=this.el.gridstackNode?.grid;y?W.dropElement=y.el.ddElement.ddDroppable:delete W.dropElement,this.helper=this._createHelper(r),this._setupHelperContainmentStyle(),this.dragTransform=f.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(r,this.el,this.helperContainment),this._setupHelperStyle(r);let v=f.initEvent(r,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(v,this.ui()),this.triggerEvent("dragstart",v),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(r){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),at&&(r.target.removeEventListener("touchmove",xt,!0),r.target.removeEventListener("touchend",jt,!0)),this.dragging){delete this.dragging,delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),W.dropElement?.el===this.el.parentElement&&delete W.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper===this.el?this._removeHelperStyle():this.helper.remove();let d=f.initEvent(r,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(d),this.triggerEvent("dragstop",d),W.dropElement&&W.dropElement.drop(r)}delete this.helper,delete this.mouseDownEvent,delete W.dragElement,delete W.dropElement,delete W.mouseHandled,r.preventDefault()}_keyEvent(r){let d=this.el.gridstackNode;if(!d?.grid)return;let y=d.grid;if(r.key==="Escape")d._origRotate&&(d._orig=d._origRotate,delete d._origRotate),y.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent);else if(r.key==="r"||r.key==="R"){if(!f.canBeRotated(d))return;d._origRotate=d._origRotate||{...d._orig},delete d._moving,y.setAnimation(!1).rotate(d.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetLeft}).setAnimation(),d._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,d.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",f.swap(d._orig,"w","h"),delete d._rect,this._mouseMove(this.lastDrag)}}_createHelper(r){let d=this.el;return typeof this.option.helper=="function"?d=this.option.helper(r):this.option.helper==="clone"&&(d=f.cloneNode(this.el)),document.body.contains(d)||f.appendTo(d,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),d===this.el&&(this.dragElementOriginStyle=Ee.originStyleProp.map(y=>this.el.style[y])),d}_setupHelperStyle(r){this.helper.classList.add("ui-draggable-dragging");let d=this.helper.style;return d.pointerEvents="none",d.width=this.dragOffset.width+"px",d.height=this.dragOffset.height+"px",d.willChange="left, top",d.position="fixed",this._dragFollow(r),d.transition="none",setTimeout(()=>{this.helper&&(d.transition=null)},0),this}_removeHelperStyle(){if(this.helper.classList.remove("ui-draggable-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){let d=this.helper,y=this.dragElementOriginStyle.transition||null;d.style.transition=this.dragElementOriginStyle.transition="none",Ee.originStyleProp.forEach(v=>d.style[v]=this.dragElementOriginStyle[v]||null),setTimeout(()=>d.style.transition=y,50)}return delete this.dragElementOriginStyle,this}_dragFollow(r){let d=this.helper.style,y=this.dragOffset;d.left=(r.clientX+y.offsetLeft-0)*this.dragTransform.xScale+"px",d.top=(r.clientY+y.offsetTop-0)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(r,d,y){let v=0,P=0;y&&(v=this.dragTransform.xOffset,P=this.dragTransform.yOffset);let F=d.getBoundingClientRect();return{left:F.left,top:F.top,offsetLeft:-r.clientX+F.left-v,offsetTop:-r.clientY+F.top-P,width:F.width*this.dragTransform.xScale,height:F.height*this.dragTransform.yScale}}ui(){let r=this.el.parentElement.getBoundingClientRect(),d=this.helper.getBoundingClientRect();return{position:{top:(d.top-r.top)*this.dragTransform.yScale,left:(d.left-r.left)*this.dragTransform.xScale}}}}Ee.originStyleProp=["transition","pointerEvents","position","left","top","minWidth","willChange"];class Ge extends _e{constructor(r,d={}){super(),this.el=r,this.option=d,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(r,d){super.on(r,d)}off(r){super.off(r)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),at&&(this.el.addEventListener("pointerenter",ae),this.el.addEventListener("pointerleave",Ae)))}disable(r=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),r||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),at&&(this.el.removeEventListener("pointerenter",ae),this.el.removeEventListener("pointerleave",Ae)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(r){return Object.keys(r).forEach(d=>this.option[d]=r[d]),this._setupAccept(),this}_mouseEnter(r){if(!W.dragElement||!this._canDrop(W.dragElement.el))return;r.preventDefault(),r.stopPropagation(),W.dropElement&&W.dropElement!==this&&W.dropElement._mouseLeave(r,!0),W.dropElement=this;let d=f.initEvent(r,{target:this.el,type:"dropover"});this.option.over&&this.option.over(d,this._ui(W.dragElement)),this.triggerEvent("dropover",d),this.el.classList.add("ui-droppable-over")}_mouseLeave(r,d=!1){if(!W.dragElement||W.dropElement!==this)return;r.preventDefault(),r.stopPropagation();let y=f.initEvent(r,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(y,this._ui(W.dragElement)),this.triggerEvent("dropout",y),W.dropElement===this&&(delete W.dropElement,!d)){let v,P=this.el.parentElement;for(;!v&&P;)v=P.ddElement?.ddDroppable,P=P.parentElement;v&&v._mouseEnter(r)}}drop(r){r.preventDefault();let d=f.initEvent(r,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(d,this._ui(W.dragElement)),this.triggerEvent("drop",d)}_canDrop(r){return r&&(!this.accept||this.accept(r))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=r=>r.classList.contains(this.option.accept)||r.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(r){return{draggable:r.el,...r.ui()}}}class De{static init(r){return r.ddElement||(r.ddElement=new De(r)),r.ddElement}constructor(r){this.el=r}on(r,d){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(r)>-1?this.ddDraggable.on(r,d):this.ddDroppable&&["drop","dropover","dropout"].indexOf(r)>-1?this.ddDroppable.on(r,d):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(r)>-1&&this.ddResizable.on(r,d),this}off(r){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(r)>-1?this.ddDraggable.off(r):this.ddDroppable&&["drop","dropover","dropout"].indexOf(r)>-1?this.ddDroppable.off(r):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(r)>-1&&this.ddResizable.off(r),this}setupDraggable(r){return this.ddDraggable?this.ddDraggable.updateOption(r):this.ddDraggable=new Ee(this.el,r),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(r){return this.ddResizable?this.ddResizable.updateOption(r):this.ddResizable=new Oe(this.el,r),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(r){return this.ddDroppable?this.ddDroppable.updateOption(r):this.ddDroppable=new Ge(this.el,r),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}let se=new class{resizable(St,r,d,y){return this._getDDElements(St).forEach(v=>{if(r==="disable"||r==="enable")v.ddResizable&&v.ddResizable[r]();else if(r==="destroy")v.ddResizable&&v.cleanResizable();else if(r==="option")v.setupResizable({[d]:y});else{let P=v.el.gridstackNode.grid,F=v.el.getAttribute("gs-resize-handles")||P.opts.resizable.handles||"e,s,se";F==="all"&&(F="n,e,s,w,se,sw,ne,nw");let Y=!P.opts.alwaysShowResizeHandle;v.setupResizable({...P.opts.resizable,handles:F,autoHide:Y,start:r.start,stop:r.stop,resize:r.resize})}}),this}draggable(St,r,d,y){return this._getDDElements(St).forEach(v=>{if(r==="disable"||r==="enable")v.ddDraggable&&v.ddDraggable[r]();else if(r==="destroy")v.ddDraggable&&v.cleanDraggable();else if(r==="option")v.setupDraggable({[d]:y});else{let P=v.el.gridstackNode.grid;v.setupDraggable({...P.opts.draggable,start:r.start,stop:r.stop,drag:r.drag})}}),this}dragIn(St,r){return this._getDDElements(St).forEach(d=>d.setupDraggable(r)),this}droppable(St,r,d,y){return typeof r.accept!="function"||r._accept||(r._accept=r.accept,r.accept=v=>r._accept(v)),this._getDDElements(St).forEach(v=>{r==="disable"||r==="enable"?v.ddDroppable&&v.ddDroppable[r]():r==="destroy"?v.ddDroppable&&v.cleanDroppable():r==="option"?v.setupDroppable({[d]:y}):v.setupDroppable(r)}),this}isDroppable(St){return!(!(St&&St.ddElement&&St.ddElement.ddDroppable)||St.ddElement.ddDroppable.disabled)}isDraggable(St){return!(!(St&&St.ddElement&&St.ddElement.ddDraggable)||St.ddElement.ddDraggable.disabled)}isResizable(St){return!(!(St&&St.ddElement&&St.ddElement.ddResizable)||St.ddElement.ddResizable.disabled)}on(St,r,d){return this._getDDElements(St).forEach(y=>y.on(r,v=>{d(v,W.dragElement?W.dragElement.el:v.target,W.dragElement?W.dragElement.helper:null)})),this}off(St,r){return this._getDDElements(St).forEach(d=>d.off(r)),this}_getDDElements(St,r=!0){let d=f.getElements(St);if(!d.length)return[];let y=d.map(v=>v.ddElement||(r?De.init(v):null));return r||y.filter(v=>v),y}};class Bt{static init(r={},d=".grid-stack"){if(typeof document>"u")return null;let y=Bt.getGridElement(d);return y?(y.gridstack||(y.gridstack=new Bt(y,f.cloneDeep(r))),y.gridstack):(console.error(typeof d=="string"?'GridStack.initAll() no grid was found with selector "'+d+`" - element missing or wrong selector ? Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(r={},d=".grid-stack"){let y=[];return typeof document>"u"||(Bt.getGridElements(d).forEach(v=>{v.gridstack||(v.gridstack=new Bt(v,f.cloneDeep(r))),y.push(v.gridstack)}),y.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+d+`" - element missing or wrong selector ? -Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),y}static addGrid(r,d={}){if(!r)return null;let y=r;if(y.gridstack){let v=y.gridstack;return d&&(v.opts={...v.opts,...d}),d.children!==void 0&&v.load(d.children),v}if(!r.classList.contains("grid-stack")||Bt.addRemoveCB)if(Bt.addRemoveCB)y=Bt.addRemoveCB(r,d,!0,!0);else{let v=document.implementation.createHTMLDocument("");v.body.innerHTML=`
`,y=v.body.children[0],r.appendChild(y)}return Bt.init(d,y)}static registerEngine(r){Bt.engineClass=r}get placeholder(){if(!this._placeholder){let r=document.createElement("div");r.className="placeholder-content",this.opts.placeholderText&&(r.innerHTML=this.opts.placeholderText),this._placeholder=document.createElement("div"),this._placeholder.classList.add(this.opts.placeholderClass,H.itemClass,this.opts.itemClass),this.placeholder.appendChild(r)}return this._placeholder}constructor(r,d={}){this.el=r,this.opts=d,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},r.gridstack=this,d=d||{},r.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),d.row&&(d.minRow=d.maxRow=d.row,delete d.row);let y=f.toNumber(r.getAttribute("gs-row"));d.column==="auto"&&delete d.column,d.alwaysShowResizeHandle!==void 0&&(d._alwaysShowResizeHandle=d.alwaysShowResizeHandle);let v=d.columnOpts?.breakpoints,P=d;if(P.oneColumnModeDomSort&&(delete P.oneColumnModeDomSort,console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")),P.oneColumnSize||P.disableOneColumnMode===!1){let kt=P.oneColumnSize||768;delete P.oneColumnSize,delete P.disableOneColumnMode,d.columnOpts=d.columnOpts||{},v=d.columnOpts.breakpoints=d.columnOpts.breakpoints||[];let Et=v.find(ie=>ie.c===1);Et?Et.w=kt:(Et={c:1,w:kt},v.push(Et,{c:12,w:kt+1}))}let F=d.columnOpts;F&&(F.columnWidth||F.breakpoints?.length?F.columnMax=F.columnMax||12:(delete d.columnOpts,v=void 0)),v?.length>1&&v.sort((kt,Et)=>(Et.w||0)-(kt.w||0));let Y={...f.cloneDeep(H),column:f.toNumber(r.getAttribute("gs-column"))||H.column,minRow:y||f.toNumber(r.getAttribute("gs-min-row"))||H.minRow,maxRow:y||f.toNumber(r.getAttribute("gs-max-row"))||H.maxRow,staticGrid:f.toBool(r.getAttribute("gs-static"))||H.staticGrid,draggable:{handle:(d.handleClass?"."+d.handleClass:d.handle?d.handle:"")||H.draggable.handle},removableOptions:{accept:d.itemClass||H.removableOptions.accept,decline:H.removableOptions.decline}};r.getAttribute("gs-animate")&&(Y.animate=f.toBool(r.getAttribute("gs-animate"))),d=f.defaults(d,Y),this._initMargin(),this.checkDynamicColumn(),this.el.classList.add("gs-"+d.column),d.rtl==="auto"&&(d.rtl=r.style.direction==="rtl"),d.rtl&&this.el.classList.add("grid-stack-rtl");let nt=this.el.parentElement?.parentElement,V=nt?.classList.contains(H.itemClass)?nt.gridstackNode:void 0;V&&(V.subGrid=this,this.parentGridItem=V,this.el.classList.add("grid-stack-nested"),V.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=d.cellHeight==="auto",this._isAutoCellHeight||d.cellHeight==="initial"?this.cellHeight(void 0,!1):(typeof d.cellHeight=="number"&&d.cellHeightUnit&&d.cellHeightUnit!==H.cellHeightUnit&&(d.cellHeight=d.cellHeight+d.cellHeightUnit,delete d.cellHeightUnit),this.cellHeight(d.cellHeight,!1)),d.alwaysShowResizeHandle==="mobile"&&(d.alwaysShowResizeHandle=at),this._styleSheetClass="gs-id-"+C._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();let it=d.engineClass||Bt.engineClass||C;if(this.engine=new it({column:this.getColumn(),float:d.float,maxRow:d.maxRow,onChange:kt=>{let Et=0;this.engine.nodes.forEach(ie=>{Et=Math.max(Et,ie.y+ie.h)}),kt.forEach(ie=>{let Le=ie.el;Le&&(ie._removeDOM?(Le&&Le.remove(),delete ie._removeDOM):this._writePosAttr(Le,ie))}),this._updateStyles(!1,Et)}}),this._updateStyles(!1,0),d.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(kt=>this._prepareElement(kt)),delete this.engine._loading,this.batchUpdate(!1)),d.children){let kt=d.children;delete d.children,kt.length&&this.load(kt)}this.setAnimation(),d.subGridDynamic&&!W.pauseDrag&&(W.pauseDrag=!0),d.draggable?.pause!==void 0&&(W.pauseDrag=d.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}addWidget(r,d){let y,v;if(typeof r=="string"){let Y=document.implementation.createHTMLDocument("");Y.body.innerHTML=r,y=Y.body.children[0]}else if(arguments.length===0||arguments.length===1&&((P=r).el!==void 0||P.x!==void 0||P.y!==void 0||P.w!==void 0||P.h!==void 0||P.content!==void 0))if(v=d=r,v?.el)y=v.el;else if(Bt.addRemoveCB)y=Bt.addRemoveCB(this.el,d,!0,!1);else{let Y=d?.content||"",nt=document.implementation.createHTMLDocument("");nt.body.innerHTML=`
${Y}
`,y=nt.body.children[0]}else y=r;var P;if(!y)return;if(v=y.gridstackNode,v&&y.parentElement===this.el&&this.engine.nodes.find(Y=>Y._id===v._id))return y;let F=this._readAttr(y);return d=f.cloneDeep(d)||{},f.defaults(d,F),v=this.engine.prepareNode(d),this._writeAttr(y,d),this.el.appendChild(y),this.makeWidget(y,d),y}makeSubGrid(r,d,y,v=!0){let P,F=r.gridstackNode;if(F||(F=this.makeWidget(r).gridstackNode),F.subGrid?.el)return F.subGrid;let Y,nt=this;for(;nt&&!P;)P=nt.opts?.subGridOpts,nt=nt.parentGridItem?.grid;d=f.cloneDeep({...P||{},children:void 0,...d||F.subGridOpts||{}}),F.subGridOpts=d,d.column==="auto"&&(Y=!0,d.column=Math.max(F.w||1,y?.w||1),delete d.columnOpts);let V,it,kt=F.el.querySelector(".grid-stack-item-content");if(v){if(this._removeDD(F.el),it={...F,x:0,y:0},f.removeInternalForSave(it),delete it.subGridOpts,F.content&&(it.content=F.content,delete F.content),Bt.addRemoveCB)V=Bt.addRemoveCB(this.el,it,!0,!1);else{let ie=document.implementation.createHTMLDocument("");ie.body.innerHTML='
',V=ie.body.children[0],V.appendChild(kt),ie.body.innerHTML='
',kt=ie.body.children[0],F.el.appendChild(kt)}this._prepareDragDropByNode(F)}if(y){let ie=Y?d.column:F.w,Le=F.h+y.h,ii=F.el.style;ii.transition="none",this.update(F.el,{w:ie,h:Le}),setTimeout(()=>ii.transition=null)}let Et=F.subGrid=Bt.addGrid(kt,d);return y?._moving&&(Et._isTemp=!0),Y&&(Et._autoColumn=!0),v&&Et.addWidget(V,it),y&&(y._moving?window.setTimeout(()=>f.simulateMouseEvent(y._event,"mouseenter",Et.el),0):Et.addWidget(F.el,F)),Et}removeAsSubGrid(r){let d=this.parentGridItem?.grid;d&&(d.batchUpdate(),d.removeWidget(this.parentGridItem.el,!0,!0),this.engine.nodes.forEach(y=>{y.x+=this.parentGridItem.x,y.y+=this.parentGridItem.y,d.addWidget(y.el,y)}),d.batchUpdate(!1),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,r&&window.setTimeout(()=>f.simulateMouseEvent(r._event,"mouseenter",d.el),0))}save(r=!0,d=!1,y=Bt.saveCB){let v=this.engine.save(r,y);if(v.forEach(P=>{if(r&&P.el&&!P.subGrid&&!y){let F=P.el.querySelector(".grid-stack-item-content");P.content=F?F.innerHTML:void 0,P.content||delete P.content}else if(r||y||delete P.content,P.subGrid?.el){let F=P.subGrid.save(r,d,y);P.subGridOpts=d?F:{children:F},delete P.subGrid}delete P.el}),d){let P=f.cloneDeep(this.opts);P.marginBottom===P.marginTop&&P.marginRight===P.marginLeft&&P.marginTop===P.marginRight&&(P.margin=P.marginTop,delete P.marginTop,delete P.marginRight,delete P.marginBottom,delete P.marginLeft),P.rtl===(this.el.style.direction==="rtl")&&(P.rtl="auto"),this._isAutoCellHeight&&(P.cellHeight="auto"),this._autoColumn&&(P.column="auto");let F=P._alwaysShowResizeHandle;return delete P._alwaysShowResizeHandle,F!==void 0?P.alwaysShowResizeHandle=F:delete P.alwaysShowResizeHandle,f.removeInternalAndSame(P,H),P.children=v,P}return v}load(r,d=Bt.addRemoveCB||!0){r=f.cloneDeep(r);let y=this.getColumn();r.forEach(V=>{V.w=V.w||1,V.h=V.h||1}),r=f.sort(r);let v=0;r.forEach(V=>{v=Math.max(v,(V.x||0)+V.w)}),v>y&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(r,v,!0));let P=Bt.addRemoveCB;typeof d=="function"&&(Bt.addRemoveCB=d);let F=[];this.batchUpdate();let Y=!this.engine.nodes.length;Y&&this.setAnimation(!1),!Y&&d&&[...this.engine.nodes].forEach(V=>{V.id&&(f.find(r,V.id)||(Bt.addRemoveCB&&Bt.addRemoveCB(this.el,V,!1,!1),F.push(V),this.removeWidget(V.el,!0,!1)))}),this.engine._loading=!0;let nt=[];return this.engine.nodes=this.engine.nodes.filter(V=>!f.find(r,V.id)||(nt.push(V),!1)),r.forEach(V=>{let it=f.find(nt,V.id);if(it){if(f.shouldSizeToContent(it)&&(V.h=it.h),this.engine.nodeBoundFix(V),(V.autoPosition||V.x===void 0||V.y===void 0)&&(V.w=V.w||it.w,V.h=V.h||it.h,this.engine.findEmptyPosition(V)),this.engine.nodes.push(it),f.samePos(it,V)&&this.moveNode(it,{...V,forceCollide:!0}),this.update(it.el,V),V.subGridOpts?.children){let kt=it.el.querySelector(".grid-stack");kt&&kt.gridstack&&kt.gridstack.load(V.subGridOpts.children)}}else d&&this.addWidget(V)}),delete this.engine._loading,this.engine.removedNodes=F,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,P?Bt.addRemoveCB=P:delete Bt.addRemoveCB,Y&&this.opts?.animate&&this.setAnimation(this.opts.animate,!0),this}batchUpdate(r=!0){return this.engine.batchUpdate(r),r||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(r=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!r||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;let d=this.el.querySelector("."+this.opts.itemClass);if(d){let v=f.toNumber(d.getAttribute("gs-h"))||1;return Math.round(d.offsetHeight/v)}let y=parseInt(this.el.getAttribute("gs-current-row"));return y?Math.round(this.el.getBoundingClientRect().height/y):this.opts.cellHeight}cellHeight(r,d=!0){if(d&&r!==void 0&&this._isAutoCellHeight!==(r==="auto")&&(this._isAutoCellHeight=r==="auto",this._updateResizeEvent()),r!=="initial"&&r!=="auto"||(r=void 0),r===void 0){let v=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;r=this.cellWidth()+v}let y=f.parseHeight(r);return this.opts.cellHeightUnit===y.unit&&this.opts.cellHeight===y.h||(this.opts.cellHeightUnit=y.unit,this.opts.cellHeight=y.h,this.resizeToContentCheck(),d&&this._updateStyles(!0)),this}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(r=!1){return r&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){let r=this.opts.columnOpts;if(!r||!r.columnWidth&&!r.breakpoints?.length)return!1;let d=this.getColumn(),y=d,v=this._widthOrContainer(!0);if(r.columnWidth)y=Math.min(Math.round(v/r.columnWidth)||1,r.columnMax);else{y=r.columnMax;let P=0;for(;PF.c===y);return this.column(y,P?.layout||r.layout),!0}return!1}compact(r="compact",d=!0){return this.engine.compact(r,d),this._triggerChangeEvent(),this}column(r,d="moveScale"){if(!r||r<1||this.opts.column===r)return this;let y=this.getColumn();return this.opts.column=r,this.engine?(this.engine.column=r,this.el.classList.remove("gs-"+y),this.el.classList.add("gs-"+r),this.engine.columnChanged(y,r,d),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):this}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(r=>r.matches("."+this.opts.itemClass)&&!r.matches("."+this.opts.placeholderClass))}destroy(r=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),r?this.el.parentNode.removeChild(this.el):(this.removeAll(r),this.el.classList.remove(this._styleSheetClass),this.el.removeAttribute("gs-current-row")),this._removeStylesheet(),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,delete this.opts,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(r){return this.opts.float!==r&&(this.opts.float=this.engine.float=r,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(r,d=!1){let y,v=this.el.getBoundingClientRect();y=d?{top:v.top+document.documentElement.scrollTop,left:v.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};let P=r.left-y.left,F=r.top-y.top,Y=v.width/this.getColumn(),nt=v.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(P/Y),y:Math.floor(F/nt)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(r,d,y,v){return this.engine.isAreaEmpty(r,d,y,v)}makeWidget(r,d){let y=Bt.getElement(r);this._prepareElement(y,!0,d);let v=y.gridstackNode;return this._updateContainerHeight(),v.subGridOpts&&this.makeSubGrid(y,v.subGridOpts,void 0,!1),this.opts.column===1&&(this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,y}on(r,d){if(r.indexOf(" ")!==-1)return r.split(" ").forEach(y=>this.on(y,d)),this;if(r==="change"||r==="added"||r==="removed"||r==="enable"||r==="disable"){let y=r==="enable"||r==="disable";this._gsEventHandler[r]=y?v=>d(v):v=>d(v,v.detail),this.el.addEventListener(r,this._gsEventHandler[r])}else r==="drag"||r==="dragstart"||r==="dragstop"||r==="resizestart"||r==="resize"||r==="resizestop"||r==="dropped"||r==="resizecontent"?this._gsEventHandler[r]=d:console.error("GridStack.on("+r+") event not supported");return this}off(r){return r.indexOf(" ")!==-1?(r.split(" ").forEach(d=>this.off(d)),this):(r!=="change"&&r!=="added"&&r!=="removed"&&r!=="enable"&&r!=="disable"||this._gsEventHandler[r]&&this.el.removeEventListener(r,this._gsEventHandler[r]),delete this._gsEventHandler[r],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(r=>this.off(r)),this}removeWidget(r,d=!0,y=!0){return Bt.getElements(r).forEach(v=>{if(v.parentElement&&v.parentElement!==this.el)return;let P=v.gridstackNode;P||(P=this.engine.nodes.find(F=>v===F.el)),P&&(d&&Bt.addRemoveCB&&Bt.addRemoveCB(this.el,P,!1,!1),delete v.gridstackNode,this._removeDD(v),this.engine.removeNode(P,d,y),d&&v.parentElement&&v.remove())}),y&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(r=!0,d=!0){return this.engine.nodes.forEach(y=>{r&&Bt.addRemoveCB&&Bt.addRemoveCB(this.el,y,!1,!1),delete y.el.gridstackNode,this.opts.staticGrid||this._removeDD(y.el)}),this.engine.removeAll(r,d),d&&this._triggerRemoveEvent(),this}setAnimation(r=this.opts.animate,d){return d?setTimeout(()=>{this.opts&&this.setAnimation(r)}):r?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(r,d=!0,y=!0){return!!this.opts.staticGrid===r||(r?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(v=>{this._prepareDragDropByNode(v),v.subGrid&&y&&v.subGrid.setStatic(r,d,y)}),d&&this._setStaticClass()),this}update(r,d){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");let y=arguments,v=1;return d={x:y[v++],y:y[v++],w:y[v++],h:y[v++]},this.update(r,d)}return Bt.getElements(r).forEach(y=>{let v=y?.gridstackNode;if(!v)return;let P=f.cloneDeep(d);this.engine.nodeBoundFix(P),delete P.autoPosition,delete P.id;let F,Y=["x","y","w","h"];if(Y.some(it=>P[it]!==void 0&&P[it]!==v[it])&&(F={},Y.forEach(it=>{F[it]=P[it]!==void 0?P[it]:v[it],delete P[it]})),!F&&(P.minW||P.minH||P.maxW||P.maxH)&&(F={}),P.content!==void 0){let it=y.querySelector(".grid-stack-item-content");it&&it.innerHTML!==P.content&&(it.innerHTML=P.content,v.subGrid?.el&&(it.appendChild(v.subGrid.el),v.subGrid.opts.styleInHead||v.subGrid._updateStyles(!0))),delete P.content}let nt=!1,V=!1;for(let it in P)it[0]!=="_"&&v[it]!==P[it]&&(v[it]=P[it],nt=!0,V=V||!this.opts.staticGrid&&(it==="noResize"||it==="noMove"||it==="locked"));if(f.sanitizeMinMax(v),F){let it=F.w!==void 0&&F.w!==v.w;this.moveNode(v,F),this.resizeToContentCheck(it,v),delete v._orig}(F||nt)&&this._writeAttr(y,v),V&&this._prepareDragDropByNode(v)}),this}moveNode(r,d){let y=r._updating;y||this.engine.cleanNodes().beginUpdate(r),this.engine.moveNode(r,d),this._updateContainerHeight(),y||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(r){if(!r||(r.classList.remove("size-to-content-max"),!r.clientHeight))return;let d=r.gridstackNode;if(!d)return;let y=d.grid;if(!y||r.parentElement!==y.el)return;let v=y.getCellHeight(!0);if(!v)return;let P,F=d.h?d.h*v:r.clientHeight;if(d.resizeToContentParent&&(P=r.querySelector(d.resizeToContentParent)),P||(P=r.querySelector(Bt.resizeToContentParent)),!P)return;let Y=r.clientHeight-P.clientHeight,nt=d.h?d.h*v-Y:P.clientHeight,V;if(d.subGrid)V=d.subGrid.getRow()*d.subGrid.getCellHeight(!0);else{if(d.subGridOpts?.children?.length)return;{let Et=P.firstElementChild;if(!Et)return void console.error(`Error: GridStack.resizeToContent() widget id:${d.id} '${Bt.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);V=Et.getBoundingClientRect().height||nt}}if(nt===V)return;F+=V-nt;let it=Math.ceil(F/v),kt=Number.isInteger(d.sizeToContent)?d.sizeToContent:0;kt&&it>kt&&(it=kt,r.classList.add("size-to-content-max")),d.minH&&itd.maxH&&(it=d.maxH),it!==d.h&&(y._ignoreLayoutsNodeChange=!0,y.moveNode(d,{h:it}),delete y._ignoreLayoutsNodeChange)}resizeToContentCBCheck(r){Bt.resizeToContentCB?Bt.resizeToContentCB(r):this.resizeToContent(r)}rotate(r,d){return Bt.getElements(r).forEach(y=>{let v=y.gridstackNode;if(!f.canBeRotated(v))return;let P={w:v.h,h:v.w,minH:v.minW,minW:v.minH,maxH:v.maxW,maxW:v.maxH};if(d){let Y=d.left>0?Math.floor(d.left/this.cellWidth()):0,nt=d.top>0?Math.floor(d.top/this.opts.cellHeight):0;P.x=v.x+Y-(v.h-(nt+1)),P.y=v.y+nt-Y}Object.keys(P).forEach(Y=>{P[Y]===void 0&&delete P[Y]});let F=v._orig;this.update(y,P),v._orig=F}),this}margin(r){if(!(typeof r=="string"&&r.split(" ").length>1)){let d=f.parseHeight(r);if(this.opts.marginUnit===d.unit&&this.opts.margin===d.h)return}return this.opts.margin=r,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this._updateStyles(!0),this}getMargin(){return this.opts.margin}willItFit(r){if(arguments.length>1){console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");let d=arguments,y=0,v={x:d[y++],y:d[y++],w:d[y++],h:d[y++],autoPosition:d[y++]};return this.willItFit(v)}return this.engine.willItFit(r)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let r=this.engine.getDirtyNodes(!0);return r&&r.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(r),this._triggerEvent("change",r)),this.engine.saveInitial(),this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(d=>{delete d._dirty});let r=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",r)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){let r=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",r)}return this}_triggerEvent(r,d){let y=d?new CustomEvent(r,{bubbles:!1,detail:d}):new Event(r);return this.el.dispatchEvent(y),this}_removeStylesheet(){if(this._styles){let r=this.opts.styleInHead?void 0:this.el.parentNode;f.removeStylesheet(this._styleSheetClass,r),delete this._styles}return this}_updateStyles(r=!1,d){if(r&&this._removeStylesheet(),d===void 0&&(d=this.getRow()),this._updateContainerHeight(),this.opts.cellHeight===0)return this;let y=this.opts.cellHeight,v=this.opts.cellHeightUnit,P=`.${this._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let F=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=f.createStylesheet(this._styleSheetClass,F,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,f.addCSSRule(this._styles,P,`height: ${y}${v}`);let Y=this.opts.marginTop+this.opts.marginUnit,nt=this.opts.marginBottom+this.opts.marginUnit,V=this.opts.marginRight+this.opts.marginUnit,it=this.opts.marginLeft+this.opts.marginUnit,kt=`${P} > .grid-stack-item-content`,Et=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;f.addCSSRule(this._styles,kt,`top: ${Y}; right: ${V}; bottom: ${nt}; left: ${it};`),f.addCSSRule(this._styles,Et,`top: ${Y}; right: ${V}; bottom: ${nt}; left: ${it};`),f.addCSSRule(this._styles,`${P} > .ui-resizable-n`,`top: ${Y};`),f.addCSSRule(this._styles,`${P} > .ui-resizable-s`,`bottom: ${nt}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-ne`,`right: ${V}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-e`,`right: ${V}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-se`,`right: ${V}; bottom: ${nt}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-nw`,`left: ${it}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-w`,`left: ${it}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-sw`,`left: ${it}; bottom: ${nt}`)}if((d=d||this._styles._max)>this._styles._max){let F=Y=>y*Y+v;for(let Y=this._styles._max+1;Y<=d;Y++)f.addCSSRule(this._styles,`${P}[gs-y="${Y}"]`,`top: ${F(Y)}`),f.addCSSRule(this._styles,`${P}[gs-h="${Y+1}"]`,`height: ${F(Y+1)}`);this._styles._max=d}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let r=this.parentGridItem,d=this.getRow()+this._extraDragRow,y=this.opts.cellHeight,v=this.opts.cellHeightUnit;if(!y)return this;if(!r){let P=f.parseHeight(getComputedStyle(this.el).minHeight);if(P.h>0&&P.unit===v){let F=Math.floor(P.h/y);d1?r.setAttribute("gs-w",String(d.w)):r.removeAttribute("gs-w"),d.h>1?r.setAttribute("gs-h",String(d.h)):r.removeAttribute("gs-h"),this}_writeAttr(r,d){if(!d)return this;this._writePosAttr(r,d);let y={autoPosition:"gs-auto-position",noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id"};for(let v in y)d[v]?r.setAttribute(y[v],String(d[v])):r.removeAttribute(y[v]);return this}_readAttr(r,d=!0){let y={};y.x=f.toNumber(r.getAttribute("gs-x")),y.y=f.toNumber(r.getAttribute("gs-y")),y.w=f.toNumber(r.getAttribute("gs-w")),y.h=f.toNumber(r.getAttribute("gs-h")),y.autoPosition=f.toBool(r.getAttribute("gs-auto-position")),y.noResize=f.toBool(r.getAttribute("gs-no-resize")),y.noMove=f.toBool(r.getAttribute("gs-no-move")),y.locked=f.toBool(r.getAttribute("gs-locked")),y.id=r.getAttribute("gs-id"),y.maxW=f.toNumber(r.getAttribute("gs-max-w")),y.minW=f.toNumber(r.getAttribute("gs-min-w")),y.maxH=f.toNumber(r.getAttribute("gs-max-h")),y.minH=f.toNumber(r.getAttribute("gs-min-h")),d&&(y.w===1&&r.removeAttribute("gs-w"),y.h===1&&r.removeAttribute("gs-h"),y.maxW&&r.removeAttribute("gs-max-w"),y.minW&&r.removeAttribute("gs-min-w"),y.maxH&&r.removeAttribute("gs-max-h"),y.minH&&r.removeAttribute("gs-min-h"));for(let v in y){if(!y.hasOwnProperty(v))return;y[v]||y[v]===0||delete y[v]}return y}_setStaticClass(){let r=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...r),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...r),this.el.removeAttribute("gs-static")),this}onResize(){if(!this.el?.clientWidth||this.prevWidth===this.el.clientWidth)return;this.prevWidth=this.el.clientWidth,this.batchUpdate();let r=!1;return this._autoColumn&&this.parentGridItem?this.opts.column!==this.parentGridItem.w&&(this.column(this.parentGridItem.w,"none"),r=!0):r=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(d=>{d.subGrid&&d.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(r),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(r=!1,d=void 0){if(this.engine){if(r&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,d),310);if(d)f.shouldSizeToContent(d)&&this.resizeToContentCBCheck(d.el);else if(this.engine.nodes.some(y=>f.shouldSizeToContent(y))){let y=[...this.engine.nodes];this.batchUpdate(),y.forEach(v=>{f.shouldSizeToContent(v)&&this.resizeToContentCBCheck(v.el)}),this.batchUpdate(!1)}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,d?[d]:this.engine.nodes)}}_updateResizeEvent(r=!1){let d=!this.parentGridItem&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(y=>y.sizeToContent));return r||!d||this.resizeObserver?!r&&d||!this.resizeObserver||(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle):(this._sizeThrottle=f.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0),this}static getElement(r=".grid-stack-item"){return f.getElement(r)}static getElements(r=".grid-stack-item"){return f.getElements(r)}static getGridElement(r){return Bt.getElement(r)}static getGridElements(r){return f.getElements(r)}_initMargin(){let r,d=0,y=[];return typeof this.opts.margin=="string"&&(y=this.opts.margin.split(" ")),y.length===2?(this.opts.marginTop=this.opts.marginBottom=y[0],this.opts.marginLeft=this.opts.marginRight=y[1]):y.length===4?(this.opts.marginTop=y[0],this.opts.marginRight=y[1],this.opts.marginBottom=y[2],this.opts.marginLeft=y[3]):(r=f.parseHeight(this.opts.margin),this.opts.marginUnit=r.unit,d=this.opts.margin=r.h),this.opts.marginTop===void 0?this.opts.marginTop=d:(r=f.parseHeight(this.opts.marginTop),this.opts.marginTop=r.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=d:(r=f.parseHeight(this.opts.marginBottom),this.opts.marginBottom=r.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=d:(r=f.parseHeight(this.opts.marginRight),this.opts.marginRight=r.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=d:(r=f.parseHeight(this.opts.marginLeft),this.opts.marginLeft=r.h,delete this.opts.margin),this.opts.marginUnit=r.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop),this}static getDD(){return se}static setupDragIn(r,d,y=document){d?.pause!==void 0&&(W.pauseDrag=d.pause),d={...X,...d||{}};let v=typeof r=="string"?f.getElements(r,y):r;v.length&&v?.forEach(P=>{se.isDraggable(P)||se.dragIn(P,d)})}movable(r,d){return this.opts.staticGrid||Bt.getElements(r).forEach(y=>{let v=y.gridstackNode;v&&(d?delete v.noMove:v.noMove=!0,this._prepareDragDropByNode(v))}),this}resizable(r,d){return this.opts.staticGrid||Bt.getElements(r).forEach(y=>{let v=y.gridstackNode;v&&(d?delete v.noResize:v.noResize=!0,this._prepareDragDropByNode(v))}),this}disable(r=!0){if(!this.opts.staticGrid)return this.enableMove(!1,r),this.enableResize(!1,r),this._triggerEvent("disable"),this}enable(r=!0){if(!this.opts.staticGrid)return this.enableMove(!0,r),this.enableResize(!0,r),this._triggerEvent("enable"),this}enableMove(r,d=!0){return this.opts.staticGrid||(r?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(y=>{this._prepareDragDropByNode(y),y.subGrid&&d&&y.subGrid.enableMove(r,d)})),this}enableResize(r,d=!0){return this.opts.staticGrid||(r?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(y=>{this._prepareDragDropByNode(y),y.subGrid&&d&&y.subGrid.enableResize(r,d)})),this}_removeDD(r){return se.draggable(r,"destroy").resizable(r,"destroy"),r.gridstackNode&&delete r.gridstackNode._initDD,delete r.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return se.droppable(this.el,"destroy"),this;let r,d,y=(v,P,F)=>{let Y=P.gridstackNode;if(!Y)return;if(F=F||P,!Y.grid?.el){F.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;let Et=F.getBoundingClientRect();F.style.left=Et.x+(this.dragTransform.xScale-1)*(v.clientX-Et.x)/this.dragTransform.xScale+"px",F.style.top=Et.y+(this.dragTransform.yScale-1)*(v.clientY-Et.y)/this.dragTransform.yScale+"px",F.style.transformOrigin="0px 0px"}let nt=this.el.getBoundingClientRect(),{top:V,left:it}=F.getBoundingClientRect();it-=nt.left,V-=nt.top;let kt={position:{top:V*this.dragTransform.xScale,left:it*this.dragTransform.yScale}};if(Y._temporaryRemoved){if(Y.x=Math.max(0,Math.round(it/d)),Y.y=Math.max(0,Math.round(V/r)),delete Y.autoPosition,this.engine.nodeBoundFix(Y),!this.engine.willItFit(Y)){if(Y.autoPosition=!0,!this.engine.willItFit(Y))return void se.off(P,"drag");Y._willFitPos&&(f.copyPos(Y,Y._willFitPos),delete Y._willFitPos)}this._onStartMoving(F,v,kt,Y,d,r)}else this._dragOrResize(F,v,kt,Y,d,r)};return se.droppable(this.el,{accept:v=>{let P=v.gridstackNode||this._readAttr(v,!1);if(P?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let F=!0;if(typeof this.opts.acceptWidgets=="function")F=this.opts.acceptWidgets(v);else{let Y=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;F=v.matches(Y)}if(F&&P&&this.opts.maxRow){let Y={w:P.w,h:P.h,minW:P.minW,minH:P.minH};F=this.engine.willItFit(Y)}return F}}).on(this.el,"dropover",(v,P,F)=>{let Y=P.gridstackNode;if(Y?.grid===this&&!Y._temporaryRemoved)return!1;Y?.grid&&Y.grid!==this&&!Y._temporaryRemoved&&Y.grid._leave(P,F),d=this.cellWidth(),r=this.getCellHeight(!0),Y||(Y=this._readAttr(P,!1)),Y.grid||(Y._isExternal=!0,P.gridstackNode=Y),F=F||P;let nt=Y.w||Math.round(F.offsetWidth/d)||1,V=Y.h||Math.round(F.offsetHeight/r)||1;return Y.grid&&Y.grid!==this?(P._gridstackNodeOrig||(P._gridstackNodeOrig=Y),P.gridstackNode=Y={...Y,w:nt,h:V,grid:this},delete Y.x,delete Y.y,this.engine.cleanupNode(Y).nodeBoundFix(Y),Y._initDD=Y._isExternal=Y._temporaryRemoved=!0):(Y.w=nt,Y.h=V,Y._temporaryRemoved=!0),Bt._itemRemoving(Y.el,!1),se.on(P,"drag",y),y(v,P,F),!1}).on(this.el,"dropout",(v,P,F)=>{let Y=P.gridstackNode;return!!Y&&(Y.grid&&Y.grid!==this||(this._leave(P,F),this._isTemp&&this.removeAsSubGrid(Y)),!1)}).on(this.el,"drop",(v,P,F)=>{let Y=P.gridstackNode;if(Y?.grid===this&&!Y._isExternal)return!1;let nt=!!this.placeholder.parentElement;this.placeholder.remove();let V=nt&&this.opts.animate;V&&this.setAnimation(!1);let it=P._gridstackNodeOrig;if(delete P._gridstackNodeOrig,nt&&it?.grid&&it.grid!==this){let Et=it.grid;Et.engine.removeNodeFromLayoutCache(it),Et.engine.removedNodes.push(it),Et._triggerRemoveEvent()._triggerChangeEvent(),Et.parentGridItem&&!Et.engine.nodes.length&&Et.opts.subGridDynamic&&Et.removeAsSubGrid()}if(!Y||(nt&&(this.engine.cleanupNode(Y),Y.grid=this),delete Y.grid?._isTemp,se.off(P,"drag"),F!==P?(F.remove(),P.gridstackNode=it,nt&&(P=P.cloneNode(!0))):(P.remove(),this._removeDD(P)),!nt))return!1;P.gridstackNode=Y,Y.el=P;let kt=Y.subGrid?.el?.gridstack;return f.copyPos(Y,this._readAttr(this.placeholder)),f.removePositioningStyles(P),this.el.appendChild(P),this._prepareElement(P,!0,Y),kt&&(kt.parentGridItem=Y,kt.opts.styleInHead||kt._updateStyles(!0)),this._updateContainerHeight(),this.engine.addedNodes.push(Y),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...v,type:"dropped"},it&&it.grid?it:void 0,Y),V&&this.setAnimation(this.opts.animate,!0),!1}),this}static _itemRemoving(r,d){let y=r?r.gridstackNode:void 0;y?.grid&&!r.classList.contains(y.grid.opts.removableOptions.decline)&&(d?y._isAboutToRemove=!0:delete y._isAboutToRemove,d?r.classList.add("grid-stack-item-removing"):r.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;let r=document.querySelector(this.opts.removable);return r?(this.opts.staticGrid||se.isDroppable(r)||se.droppable(r,this.opts.removableOptions).on(r,"dropover",(d,y)=>Bt._itemRemoving(y,!0)).on(r,"dropout",(d,y)=>Bt._itemRemoving(y,!1)),this):this}_prepareDragDropByNode(r){let d=r.el,y=r.noMove||this.opts.disableDrag,v=r.noResize||this.opts.disableResize;if(this.opts.staticGrid||y&&v)return r._initDD&&(this._removeDD(d),delete r._initDD),d.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!r._initDD){let P,F,Y=(it,kt)=>{this._gsEventHandler[it.type]&&this._gsEventHandler[it.type](it,it.target),P=this.cellWidth(),F=this.getCellHeight(!0),this._onStartMoving(d,it,kt,r,P,F)},nt=(it,kt)=>{this._dragOrResize(d,it,kt,r,P,F)},V=it=>{this.placeholder.remove(),delete r._moving,delete r._event,delete r._lastTried;let kt=r.w!==r._orig.w,Et=it.target;if(Et.gridstackNode&&Et.gridstackNode.grid===this){if(r.el=Et,r._isAboutToRemove){let ie=d.gridstackNode.grid;ie._gsEventHandler[it.type]&&ie._gsEventHandler[it.type](it,Et),ie.engine.nodes.push(r),ie.removeWidget(d,!0,!0)}else f.removePositioningStyles(Et),r._temporaryRemoved?(f.copyPos(r,r._orig),this._writePosAttr(Et,r),this.engine.addNode(r)):this._writePosAttr(Et,r),this._gsEventHandler[it.type]&&this._gsEventHandler[it.type](it,Et);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),it.type==="resizestop"&&(Number.isInteger(r.sizeToContent)&&(r.sizeToContent=r.h),this.resizeToContentCheck(kt,r))}};se.draggable(d,{start:Y,stop:V,drag:nt}).resizable(d,{start:Y,stop:V,resize:nt}),r._initDD=!0}return se.draggable(d,y?"disable":"enable").resizable(d,v?"disable":"enable"),this}_onStartMoving(r,d,y,v,P,F){if(this.engine.cleanNodes().beginUpdate(v),this._writePosAttr(this.placeholder,v),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=v,v.grid?.el)this.dragTransform=f.getValuesFromTransformedElement(r);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){let Y=this.placeholder.closest(".grid-stack");this.dragTransform=f.getValuesFromTransformedElement(Y)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(v.el=this.placeholder,v._lastUiPosition=y.position,v._prevYPix=y.position.top,v._moving=d.type==="dragstart",delete v._lastTried,d.type==="dropover"&&v._temporaryRemoved&&(this.engine.addNode(v),v._moving=!0),this.engine.cacheRects(P,F,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),d.type==="resizestart"){let Y=this.getColumn()-v.x,nt=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-v.y;se.resizable(r,"option","minWidth",P*Math.min(v.minW||1,Y)).resizable(r,"option","minHeight",F*Math.min(v.minH||1,nt)).resizable(r,"option","maxWidth",P*Math.min(v.maxW||Number.MAX_SAFE_INTEGER,Y)).resizable(r,"option","maxWidthMoveLeft",P*Math.min(v.maxW||Number.MAX_SAFE_INTEGER,v.x+v.w)).resizable(r,"option","maxHeight",F*Math.min(v.maxH||Number.MAX_SAFE_INTEGER,nt)).resizable(r,"option","maxHeightMoveUp",F*Math.min(v.maxH||Number.MAX_SAFE_INTEGER,v.y+v.h))}}_dragOrResize(r,d,y,v,P,F){let Y,nt={...v._orig},V=this.opts.marginLeft,it=this.opts.marginRight,kt=this.opts.marginTop,Et=this.opts.marginBottom,ie=Math.round(.1*F),Le=Math.round(.1*P);if(V=Math.min(V,Le),it=Math.min(it,Le),kt=Math.min(kt,ie),Et=Math.min(Et,ie),d.type==="drag"){if(v._temporaryRemoved)return;let Re=y.position.top-v._prevYPix;v._prevYPix=y.position.top,this.opts.draggable.scroll!==!1&&f.updateScrollPosition(r,y.position,Re);let We=y.position.left+(y.position.left>v._lastUiPosition.left?-it:V),Je=y.position.top+(y.position.top>v._lastUiPosition.top?-Et:kt);nt.x=Math.round(We/P),nt.y=Math.round(Je/F);let He=this._extraDragRow;if(this.engine.collide(v,nt)){let ti=this.getRow(),Ne=Math.max(0,nt.y+v.h-ti);this.opts.maxRow&&ti+Ne>this.opts.maxRow&&(Ne=Math.max(0,this.opts.maxRow-ti)),this._extraDragRow=Ne}else this._extraDragRow=0;if(this._extraDragRow!==He&&this._updateContainerHeight(),v.x===nt.x&&v.y===nt.y)return}else if(d.type==="resize"){if(nt.x<0||(f.updateScrollResize(d,r,F),nt.w=Math.round((y.size.width-V)/P),nt.h=Math.round((y.size.height-kt)/F),v.w===nt.w&&v.h===nt.h)||v._lastTried&&v._lastTried.w===nt.w&&v._lastTried.h===nt.h)return;let Re=y.position.left+V,We=y.position.top+kt;nt.x=Math.round(Re/P),nt.y=Math.round(We/F),Y=!0}v._event=d,v._lastTried=nt;let ii={x:y.position.left+V,y:y.position.top+kt,w:(y.size?y.size.width:v.w*P)-V-it,h:(y.size?y.size.height:v.h*F)-kt-Et};if(this.engine.moveNodeCheck(v,{...nt,cellWidth:P,cellHeight:F,rect:ii,resizing:Y})){v._lastUiPosition=y.position,this.engine.cacheRects(P,F,kt,it,Et,V),delete v._skipDown,Y&&v.subGrid&&v.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();let Re=d.target;this._writePosAttr(Re,v),this._gsEventHandler[d.type]&&this._gsEventHandler[d.type](d,Re)}}_leave(r,d){let y=r.gridstackNode;y&&((d=d||r).style.transform="scale(1)",se.off(r,"drag"),y._temporaryRemoved||(y._temporaryRemoved=!0,this.engine.removeNode(y),y.el=y._isExternal&&d?d:r,this.opts.removable===!0&&Bt._itemRemoving(r,!0),r._gridstackNodeOrig?(r.gridstackNode=r._gridstackNodeOrig,delete r._gridstackNodeOrig):y._isExternal&&(delete y.el,delete r.gridstackNode,this.engine.restoreInitial())))}commit(){return this.batchUpdate(!1).prototype,this}}return Bt.resizeToContentParent=".grid-stack-item-content",Bt.Utils=f,Bt.Engine=C,Bt.GDRev="10.3.1",h.GridStack})());(function(D,h,f,C){"use strict";function H(S,O,B){return setTimeout(Rt(S,B),O)}function X(S,O,B){return Array.isArray(S)?(W(S,B[O],B),!0):!1}function W(S,O,B){var c;if(S)if(S.forEach)S.forEach(O,B);else if(S.length!==C)for(c=0;c
`,y=v.body.children[0],r.appendChild(y)}return Bt.init(d,y)}static registerEngine(r){Bt.engineClass=r}get placeholder(){if(!this._placeholder){let r=document.createElement("div");r.className="placeholder-content",this.opts.placeholderText&&(r.innerHTML=this.opts.placeholderText),this._placeholder=document.createElement("div"),this._placeholder.classList.add(this.opts.placeholderClass,I.itemClass,this.opts.itemClass),this.placeholder.appendChild(r)}return this._placeholder}constructor(r,d={}){this.el=r,this.opts=d,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},r.gridstack=this,d=d||{},r.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),d.row&&(d.minRow=d.maxRow=d.row,delete d.row);let y=f.toNumber(r.getAttribute("gs-row"));d.column==="auto"&&delete d.column,d.alwaysShowResizeHandle!==void 0&&(d._alwaysShowResizeHandle=d.alwaysShowResizeHandle);let v=d.columnOpts?.breakpoints,P=d;if(P.oneColumnModeDomSort&&(delete P.oneColumnModeDomSort,console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")),P.oneColumnSize||P.disableOneColumnMode===!1){let kt=P.oneColumnSize||768;delete P.oneColumnSize,delete P.disableOneColumnMode,d.columnOpts=d.columnOpts||{},v=d.columnOpts.breakpoints=d.columnOpts.breakpoints||[];let Et=v.find(ie=>ie.c===1);Et?Et.w=kt:(Et={c:1,w:kt},v.push(Et,{c:12,w:kt+1}))}let F=d.columnOpts;F&&(F.columnWidth||F.breakpoints?.length?F.columnMax=F.columnMax||12:(delete d.columnOpts,v=void 0)),v?.length>1&&v.sort((kt,Et)=>(Et.w||0)-(kt.w||0));let Y={...f.cloneDeep(I),column:f.toNumber(r.getAttribute("gs-column"))||I.column,minRow:y||f.toNumber(r.getAttribute("gs-min-row"))||I.minRow,maxRow:y||f.toNumber(r.getAttribute("gs-max-row"))||I.maxRow,staticGrid:f.toBool(r.getAttribute("gs-static"))||I.staticGrid,draggable:{handle:(d.handleClass?"."+d.handleClass:d.handle?d.handle:"")||I.draggable.handle},removableOptions:{accept:d.itemClass||I.removableOptions.accept,decline:I.removableOptions.decline}};r.getAttribute("gs-animate")&&(Y.animate=f.toBool(r.getAttribute("gs-animate"))),d=f.defaults(d,Y),this._initMargin(),this.checkDynamicColumn(),this.el.classList.add("gs-"+d.column),d.rtl==="auto"&&(d.rtl=r.style.direction==="rtl"),d.rtl&&this.el.classList.add("grid-stack-rtl");let nt=this.el.parentElement?.parentElement,V=nt?.classList.contains(I.itemClass)?nt.gridstackNode:void 0;V&&(V.subGrid=this,this.parentGridItem=V,this.el.classList.add("grid-stack-nested"),V.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=d.cellHeight==="auto",this._isAutoCellHeight||d.cellHeight==="initial"?this.cellHeight(void 0,!1):(typeof d.cellHeight=="number"&&d.cellHeightUnit&&d.cellHeightUnit!==I.cellHeightUnit&&(d.cellHeight=d.cellHeight+d.cellHeightUnit,delete d.cellHeightUnit),this.cellHeight(d.cellHeight,!1)),d.alwaysShowResizeHandle==="mobile"&&(d.alwaysShowResizeHandle=at),this._styleSheetClass="gs-id-"+C._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();let it=d.engineClass||Bt.engineClass||C;if(this.engine=new it({column:this.getColumn(),float:d.float,maxRow:d.maxRow,onChange:kt=>{let Et=0;this.engine.nodes.forEach(ie=>{Et=Math.max(Et,ie.y+ie.h)}),kt.forEach(ie=>{let Le=ie.el;Le&&(ie._removeDOM?(Le&&Le.remove(),delete ie._removeDOM):this._writePosAttr(Le,ie))}),this._updateStyles(!1,Et)}}),this._updateStyles(!1,0),d.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(kt=>this._prepareElement(kt)),delete this.engine._loading,this.batchUpdate(!1)),d.children){let kt=d.children;delete d.children,kt.length&&this.load(kt)}this.setAnimation(),d.subGridDynamic&&!W.pauseDrag&&(W.pauseDrag=!0),d.draggable?.pause!==void 0&&(W.pauseDrag=d.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}addWidget(r,d){let y,v;if(typeof r=="string"){let Y=document.implementation.createHTMLDocument("");Y.body.innerHTML=r,y=Y.body.children[0]}else if(arguments.length===0||arguments.length===1&&((P=r).el!==void 0||P.x!==void 0||P.y!==void 0||P.w!==void 0||P.h!==void 0||P.content!==void 0))if(v=d=r,v?.el)y=v.el;else if(Bt.addRemoveCB)y=Bt.addRemoveCB(this.el,d,!0,!1);else{let Y=d?.content||"",nt=document.implementation.createHTMLDocument("");nt.body.innerHTML=`
${Y}
`,y=nt.body.children[0]}else y=r;var P;if(!y)return;if(v=y.gridstackNode,v&&y.parentElement===this.el&&this.engine.nodes.find(Y=>Y._id===v._id))return y;let F=this._readAttr(y);return d=f.cloneDeep(d)||{},f.defaults(d,F),v=this.engine.prepareNode(d),this._writeAttr(y,d),this.el.appendChild(y),this.makeWidget(y,d),y}makeSubGrid(r,d,y,v=!0){let P,F=r.gridstackNode;if(F||(F=this.makeWidget(r).gridstackNode),F.subGrid?.el)return F.subGrid;let Y,nt=this;for(;nt&&!P;)P=nt.opts?.subGridOpts,nt=nt.parentGridItem?.grid;d=f.cloneDeep({...P||{},children:void 0,...d||F.subGridOpts||{}}),F.subGridOpts=d,d.column==="auto"&&(Y=!0,d.column=Math.max(F.w||1,y?.w||1),delete d.columnOpts);let V,it,kt=F.el.querySelector(".grid-stack-item-content");if(v){if(this._removeDD(F.el),it={...F,x:0,y:0},f.removeInternalForSave(it),delete it.subGridOpts,F.content&&(it.content=F.content,delete F.content),Bt.addRemoveCB)V=Bt.addRemoveCB(this.el,it,!0,!1);else{let ie=document.implementation.createHTMLDocument("");ie.body.innerHTML='
',V=ie.body.children[0],V.appendChild(kt),ie.body.innerHTML='
',kt=ie.body.children[0],F.el.appendChild(kt)}this._prepareDragDropByNode(F)}if(y){let ie=Y?d.column:F.w,Le=F.h+y.h,ii=F.el.style;ii.transition="none",this.update(F.el,{w:ie,h:Le}),setTimeout(()=>ii.transition=null)}let Et=F.subGrid=Bt.addGrid(kt,d);return y?._moving&&(Et._isTemp=!0),Y&&(Et._autoColumn=!0),v&&Et.addWidget(V,it),y&&(y._moving?window.setTimeout(()=>f.simulateMouseEvent(y._event,"mouseenter",Et.el),0):Et.addWidget(F.el,F)),Et}removeAsSubGrid(r){let d=this.parentGridItem?.grid;d&&(d.batchUpdate(),d.removeWidget(this.parentGridItem.el,!0,!0),this.engine.nodes.forEach(y=>{y.x+=this.parentGridItem.x,y.y+=this.parentGridItem.y,d.addWidget(y.el,y)}),d.batchUpdate(!1),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,r&&window.setTimeout(()=>f.simulateMouseEvent(r._event,"mouseenter",d.el),0))}save(r=!0,d=!1,y=Bt.saveCB){let v=this.engine.save(r,y);if(v.forEach(P=>{if(r&&P.el&&!P.subGrid&&!y){let F=P.el.querySelector(".grid-stack-item-content");P.content=F?F.innerHTML:void 0,P.content||delete P.content}else if(r||y||delete P.content,P.subGrid?.el){let F=P.subGrid.save(r,d,y);P.subGridOpts=d?F:{children:F},delete P.subGrid}delete P.el}),d){let P=f.cloneDeep(this.opts);P.marginBottom===P.marginTop&&P.marginRight===P.marginLeft&&P.marginTop===P.marginRight&&(P.margin=P.marginTop,delete P.marginTop,delete P.marginRight,delete P.marginBottom,delete P.marginLeft),P.rtl===(this.el.style.direction==="rtl")&&(P.rtl="auto"),this._isAutoCellHeight&&(P.cellHeight="auto"),this._autoColumn&&(P.column="auto");let F=P._alwaysShowResizeHandle;return delete P._alwaysShowResizeHandle,F!==void 0?P.alwaysShowResizeHandle=F:delete P.alwaysShowResizeHandle,f.removeInternalAndSame(P,I),P.children=v,P}return v}load(r,d=Bt.addRemoveCB||!0){r=f.cloneDeep(r);let y=this.getColumn();r.forEach(V=>{V.w=V.w||1,V.h=V.h||1}),r=f.sort(r);let v=0;r.forEach(V=>{v=Math.max(v,(V.x||0)+V.w)}),v>y&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(r,v,!0));let P=Bt.addRemoveCB;typeof d=="function"&&(Bt.addRemoveCB=d);let F=[];this.batchUpdate();let Y=!this.engine.nodes.length;Y&&this.setAnimation(!1),!Y&&d&&[...this.engine.nodes].forEach(V=>{V.id&&(f.find(r,V.id)||(Bt.addRemoveCB&&Bt.addRemoveCB(this.el,V,!1,!1),F.push(V),this.removeWidget(V.el,!0,!1)))}),this.engine._loading=!0;let nt=[];return this.engine.nodes=this.engine.nodes.filter(V=>!f.find(r,V.id)||(nt.push(V),!1)),r.forEach(V=>{let it=f.find(nt,V.id);if(it){if(f.shouldSizeToContent(it)&&(V.h=it.h),this.engine.nodeBoundFix(V),(V.autoPosition||V.x===void 0||V.y===void 0)&&(V.w=V.w||it.w,V.h=V.h||it.h,this.engine.findEmptyPosition(V)),this.engine.nodes.push(it),f.samePos(it,V)&&this.moveNode(it,{...V,forceCollide:!0}),this.update(it.el,V),V.subGridOpts?.children){let kt=it.el.querySelector(".grid-stack");kt&&kt.gridstack&&kt.gridstack.load(V.subGridOpts.children)}}else d&&this.addWidget(V)}),delete this.engine._loading,this.engine.removedNodes=F,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,P?Bt.addRemoveCB=P:delete Bt.addRemoveCB,Y&&this.opts?.animate&&this.setAnimation(this.opts.animate,!0),this}batchUpdate(r=!0){return this.engine.batchUpdate(r),r||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(r=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!r||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;let d=this.el.querySelector("."+this.opts.itemClass);if(d){let v=f.toNumber(d.getAttribute("gs-h"))||1;return Math.round(d.offsetHeight/v)}let y=parseInt(this.el.getAttribute("gs-current-row"));return y?Math.round(this.el.getBoundingClientRect().height/y):this.opts.cellHeight}cellHeight(r,d=!0){if(d&&r!==void 0&&this._isAutoCellHeight!==(r==="auto")&&(this._isAutoCellHeight=r==="auto",this._updateResizeEvent()),r!=="initial"&&r!=="auto"||(r=void 0),r===void 0){let v=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;r=this.cellWidth()+v}let y=f.parseHeight(r);return this.opts.cellHeightUnit===y.unit&&this.opts.cellHeight===y.h||(this.opts.cellHeightUnit=y.unit,this.opts.cellHeight=y.h,this.resizeToContentCheck(),d&&this._updateStyles(!0)),this}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(r=!1){return r&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){let r=this.opts.columnOpts;if(!r||!r.columnWidth&&!r.breakpoints?.length)return!1;let d=this.getColumn(),y=d,v=this._widthOrContainer(!0);if(r.columnWidth)y=Math.min(Math.round(v/r.columnWidth)||1,r.columnMax);else{y=r.columnMax;let P=0;for(;PF.c===y);return this.column(y,P?.layout||r.layout),!0}return!1}compact(r="compact",d=!0){return this.engine.compact(r,d),this._triggerChangeEvent(),this}column(r,d="moveScale"){if(!r||r<1||this.opts.column===r)return this;let y=this.getColumn();return this.opts.column=r,this.engine?(this.engine.column=r,this.el.classList.remove("gs-"+y),this.el.classList.add("gs-"+r),this.engine.columnChanged(y,r,d),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):this}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(r=>r.matches("."+this.opts.itemClass)&&!r.matches("."+this.opts.placeholderClass))}destroy(r=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),r?this.el.parentNode.removeChild(this.el):(this.removeAll(r),this.el.classList.remove(this._styleSheetClass),this.el.removeAttribute("gs-current-row")),this._removeStylesheet(),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,delete this.opts,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(r){return this.opts.float!==r&&(this.opts.float=this.engine.float=r,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(r,d=!1){let y,v=this.el.getBoundingClientRect();y=d?{top:v.top+document.documentElement.scrollTop,left:v.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};let P=r.left-y.left,F=r.top-y.top,Y=v.width/this.getColumn(),nt=v.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(P/Y),y:Math.floor(F/nt)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(r,d,y,v){return this.engine.isAreaEmpty(r,d,y,v)}makeWidget(r,d){let y=Bt.getElement(r);this._prepareElement(y,!0,d);let v=y.gridstackNode;return this._updateContainerHeight(),v.subGridOpts&&this.makeSubGrid(y,v.subGridOpts,void 0,!1),this.opts.column===1&&(this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,y}on(r,d){if(r.indexOf(" ")!==-1)return r.split(" ").forEach(y=>this.on(y,d)),this;if(r==="change"||r==="added"||r==="removed"||r==="enable"||r==="disable"){let y=r==="enable"||r==="disable";this._gsEventHandler[r]=y?v=>d(v):v=>d(v,v.detail),this.el.addEventListener(r,this._gsEventHandler[r])}else r==="drag"||r==="dragstart"||r==="dragstop"||r==="resizestart"||r==="resize"||r==="resizestop"||r==="dropped"||r==="resizecontent"?this._gsEventHandler[r]=d:console.error("GridStack.on("+r+") event not supported");return this}off(r){return r.indexOf(" ")!==-1?(r.split(" ").forEach(d=>this.off(d)),this):(r!=="change"&&r!=="added"&&r!=="removed"&&r!=="enable"&&r!=="disable"||this._gsEventHandler[r]&&this.el.removeEventListener(r,this._gsEventHandler[r]),delete this._gsEventHandler[r],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(r=>this.off(r)),this}removeWidget(r,d=!0,y=!0){return Bt.getElements(r).forEach(v=>{if(v.parentElement&&v.parentElement!==this.el)return;let P=v.gridstackNode;P||(P=this.engine.nodes.find(F=>v===F.el)),P&&(d&&Bt.addRemoveCB&&Bt.addRemoveCB(this.el,P,!1,!1),delete v.gridstackNode,this._removeDD(v),this.engine.removeNode(P,d,y),d&&v.parentElement&&v.remove())}),y&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(r=!0,d=!0){return this.engine.nodes.forEach(y=>{r&&Bt.addRemoveCB&&Bt.addRemoveCB(this.el,y,!1,!1),delete y.el.gridstackNode,this.opts.staticGrid||this._removeDD(y.el)}),this.engine.removeAll(r,d),d&&this._triggerRemoveEvent(),this}setAnimation(r=this.opts.animate,d){return d?setTimeout(()=>{this.opts&&this.setAnimation(r)}):r?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(r,d=!0,y=!0){return!!this.opts.staticGrid===r||(r?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(v=>{this._prepareDragDropByNode(v),v.subGrid&&y&&v.subGrid.setStatic(r,d,y)}),d&&this._setStaticClass()),this}update(r,d){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");let y=arguments,v=1;return d={x:y[v++],y:y[v++],w:y[v++],h:y[v++]},this.update(r,d)}return Bt.getElements(r).forEach(y=>{let v=y?.gridstackNode;if(!v)return;let P=f.cloneDeep(d);this.engine.nodeBoundFix(P),delete P.autoPosition,delete P.id;let F,Y=["x","y","w","h"];if(Y.some(it=>P[it]!==void 0&&P[it]!==v[it])&&(F={},Y.forEach(it=>{F[it]=P[it]!==void 0?P[it]:v[it],delete P[it]})),!F&&(P.minW||P.minH||P.maxW||P.maxH)&&(F={}),P.content!==void 0){let it=y.querySelector(".grid-stack-item-content");it&&it.innerHTML!==P.content&&(it.innerHTML=P.content,v.subGrid?.el&&(it.appendChild(v.subGrid.el),v.subGrid.opts.styleInHead||v.subGrid._updateStyles(!0))),delete P.content}let nt=!1,V=!1;for(let it in P)it[0]!=="_"&&v[it]!==P[it]&&(v[it]=P[it],nt=!0,V=V||!this.opts.staticGrid&&(it==="noResize"||it==="noMove"||it==="locked"));if(f.sanitizeMinMax(v),F){let it=F.w!==void 0&&F.w!==v.w;this.moveNode(v,F),this.resizeToContentCheck(it,v),delete v._orig}(F||nt)&&this._writeAttr(y,v),V&&this._prepareDragDropByNode(v)}),this}moveNode(r,d){let y=r._updating;y||this.engine.cleanNodes().beginUpdate(r),this.engine.moveNode(r,d),this._updateContainerHeight(),y||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(r){if(!r||(r.classList.remove("size-to-content-max"),!r.clientHeight))return;let d=r.gridstackNode;if(!d)return;let y=d.grid;if(!y||r.parentElement!==y.el)return;let v=y.getCellHeight(!0);if(!v)return;let P,F=d.h?d.h*v:r.clientHeight;if(d.resizeToContentParent&&(P=r.querySelector(d.resizeToContentParent)),P||(P=r.querySelector(Bt.resizeToContentParent)),!P)return;let Y=r.clientHeight-P.clientHeight,nt=d.h?d.h*v-Y:P.clientHeight,V;if(d.subGrid)V=d.subGrid.getRow()*d.subGrid.getCellHeight(!0);else{if(d.subGridOpts?.children?.length)return;{let Et=P.firstElementChild;if(!Et)return void console.error(`Error: GridStack.resizeToContent() widget id:${d.id} '${Bt.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);V=Et.getBoundingClientRect().height||nt}}if(nt===V)return;F+=V-nt;let it=Math.ceil(F/v),kt=Number.isInteger(d.sizeToContent)?d.sizeToContent:0;kt&&it>kt&&(it=kt,r.classList.add("size-to-content-max")),d.minH&&itd.maxH&&(it=d.maxH),it!==d.h&&(y._ignoreLayoutsNodeChange=!0,y.moveNode(d,{h:it}),delete y._ignoreLayoutsNodeChange)}resizeToContentCBCheck(r){Bt.resizeToContentCB?Bt.resizeToContentCB(r):this.resizeToContent(r)}rotate(r,d){return Bt.getElements(r).forEach(y=>{let v=y.gridstackNode;if(!f.canBeRotated(v))return;let P={w:v.h,h:v.w,minH:v.minW,minW:v.minH,maxH:v.maxW,maxW:v.maxH};if(d){let Y=d.left>0?Math.floor(d.left/this.cellWidth()):0,nt=d.top>0?Math.floor(d.top/this.opts.cellHeight):0;P.x=v.x+Y-(v.h-(nt+1)),P.y=v.y+nt-Y}Object.keys(P).forEach(Y=>{P[Y]===void 0&&delete P[Y]});let F=v._orig;this.update(y,P),v._orig=F}),this}margin(r){if(!(typeof r=="string"&&r.split(" ").length>1)){let d=f.parseHeight(r);if(this.opts.marginUnit===d.unit&&this.opts.margin===d.h)return}return this.opts.margin=r,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this._updateStyles(!0),this}getMargin(){return this.opts.margin}willItFit(r){if(arguments.length>1){console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");let d=arguments,y=0,v={x:d[y++],y:d[y++],w:d[y++],h:d[y++],autoPosition:d[y++]};return this.willItFit(v)}return this.engine.willItFit(r)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let r=this.engine.getDirtyNodes(!0);return r&&r.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(r),this._triggerEvent("change",r)),this.engine.saveInitial(),this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(d=>{delete d._dirty});let r=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",r)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){let r=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",r)}return this}_triggerEvent(r,d){let y=d?new CustomEvent(r,{bubbles:!1,detail:d}):new Event(r);return this.el.dispatchEvent(y),this}_removeStylesheet(){if(this._styles){let r=this.opts.styleInHead?void 0:this.el.parentNode;f.removeStylesheet(this._styleSheetClass,r),delete this._styles}return this}_updateStyles(r=!1,d){if(r&&this._removeStylesheet(),d===void 0&&(d=this.getRow()),this._updateContainerHeight(),this.opts.cellHeight===0)return this;let y=this.opts.cellHeight,v=this.opts.cellHeightUnit,P=`.${this._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let F=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=f.createStylesheet(this._styleSheetClass,F,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,f.addCSSRule(this._styles,P,`height: ${y}${v}`);let Y=this.opts.marginTop+this.opts.marginUnit,nt=this.opts.marginBottom+this.opts.marginUnit,V=this.opts.marginRight+this.opts.marginUnit,it=this.opts.marginLeft+this.opts.marginUnit,kt=`${P} > .grid-stack-item-content`,Et=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;f.addCSSRule(this._styles,kt,`top: ${Y}; right: ${V}; bottom: ${nt}; left: ${it};`),f.addCSSRule(this._styles,Et,`top: ${Y}; right: ${V}; bottom: ${nt}; left: ${it};`),f.addCSSRule(this._styles,`${P} > .ui-resizable-n`,`top: ${Y};`),f.addCSSRule(this._styles,`${P} > .ui-resizable-s`,`bottom: ${nt}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-ne`,`right: ${V}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-e`,`right: ${V}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-se`,`right: ${V}; bottom: ${nt}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-nw`,`left: ${it}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-w`,`left: ${it}`),f.addCSSRule(this._styles,`${P} > .ui-resizable-sw`,`left: ${it}; bottom: ${nt}`)}if((d=d||this._styles._max)>this._styles._max){let F=Y=>y*Y+v;for(let Y=this._styles._max+1;Y<=d;Y++)f.addCSSRule(this._styles,`${P}[gs-y="${Y}"]`,`top: ${F(Y)}`),f.addCSSRule(this._styles,`${P}[gs-h="${Y+1}"]`,`height: ${F(Y+1)}`);this._styles._max=d}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let r=this.parentGridItem,d=this.getRow()+this._extraDragRow,y=this.opts.cellHeight,v=this.opts.cellHeightUnit;if(!y)return this;if(!r){let P=f.parseHeight(getComputedStyle(this.el).minHeight);if(P.h>0&&P.unit===v){let F=Math.floor(P.h/y);d1?r.setAttribute("gs-w",String(d.w)):r.removeAttribute("gs-w"),d.h>1?r.setAttribute("gs-h",String(d.h)):r.removeAttribute("gs-h"),this}_writeAttr(r,d){if(!d)return this;this._writePosAttr(r,d);let y={autoPosition:"gs-auto-position",noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id"};for(let v in y)d[v]?r.setAttribute(y[v],String(d[v])):r.removeAttribute(y[v]);return this}_readAttr(r,d=!0){let y={};y.x=f.toNumber(r.getAttribute("gs-x")),y.y=f.toNumber(r.getAttribute("gs-y")),y.w=f.toNumber(r.getAttribute("gs-w")),y.h=f.toNumber(r.getAttribute("gs-h")),y.autoPosition=f.toBool(r.getAttribute("gs-auto-position")),y.noResize=f.toBool(r.getAttribute("gs-no-resize")),y.noMove=f.toBool(r.getAttribute("gs-no-move")),y.locked=f.toBool(r.getAttribute("gs-locked")),y.id=r.getAttribute("gs-id"),y.maxW=f.toNumber(r.getAttribute("gs-max-w")),y.minW=f.toNumber(r.getAttribute("gs-min-w")),y.maxH=f.toNumber(r.getAttribute("gs-max-h")),y.minH=f.toNumber(r.getAttribute("gs-min-h")),d&&(y.w===1&&r.removeAttribute("gs-w"),y.h===1&&r.removeAttribute("gs-h"),y.maxW&&r.removeAttribute("gs-max-w"),y.minW&&r.removeAttribute("gs-min-w"),y.maxH&&r.removeAttribute("gs-max-h"),y.minH&&r.removeAttribute("gs-min-h"));for(let v in y){if(!y.hasOwnProperty(v))return;y[v]||y[v]===0||delete y[v]}return y}_setStaticClass(){let r=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...r),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...r),this.el.removeAttribute("gs-static")),this}onResize(){if(!this.el?.clientWidth||this.prevWidth===this.el.clientWidth)return;this.prevWidth=this.el.clientWidth,this.batchUpdate();let r=!1;return this._autoColumn&&this.parentGridItem?this.opts.column!==this.parentGridItem.w&&(this.column(this.parentGridItem.w,"none"),r=!0):r=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(d=>{d.subGrid&&d.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(r),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(r=!1,d=void 0){if(this.engine){if(r&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,d),310);if(d)f.shouldSizeToContent(d)&&this.resizeToContentCBCheck(d.el);else if(this.engine.nodes.some(y=>f.shouldSizeToContent(y))){let y=[...this.engine.nodes];this.batchUpdate(),y.forEach(v=>{f.shouldSizeToContent(v)&&this.resizeToContentCBCheck(v.el)}),this.batchUpdate(!1)}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,d?[d]:this.engine.nodes)}}_updateResizeEvent(r=!1){let d=!this.parentGridItem&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(y=>y.sizeToContent));return r||!d||this.resizeObserver?!r&&d||!this.resizeObserver||(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle):(this._sizeThrottle=f.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0),this}static getElement(r=".grid-stack-item"){return f.getElement(r)}static getElements(r=".grid-stack-item"){return f.getElements(r)}static getGridElement(r){return Bt.getElement(r)}static getGridElements(r){return f.getElements(r)}_initMargin(){let r,d=0,y=[];return typeof this.opts.margin=="string"&&(y=this.opts.margin.split(" ")),y.length===2?(this.opts.marginTop=this.opts.marginBottom=y[0],this.opts.marginLeft=this.opts.marginRight=y[1]):y.length===4?(this.opts.marginTop=y[0],this.opts.marginRight=y[1],this.opts.marginBottom=y[2],this.opts.marginLeft=y[3]):(r=f.parseHeight(this.opts.margin),this.opts.marginUnit=r.unit,d=this.opts.margin=r.h),this.opts.marginTop===void 0?this.opts.marginTop=d:(r=f.parseHeight(this.opts.marginTop),this.opts.marginTop=r.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=d:(r=f.parseHeight(this.opts.marginBottom),this.opts.marginBottom=r.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=d:(r=f.parseHeight(this.opts.marginRight),this.opts.marginRight=r.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=d:(r=f.parseHeight(this.opts.marginLeft),this.opts.marginLeft=r.h,delete this.opts.margin),this.opts.marginUnit=r.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop),this}static getDD(){return se}static setupDragIn(r,d,y=document){d?.pause!==void 0&&(W.pauseDrag=d.pause),d={...X,...d||{}};let v=typeof r=="string"?f.getElements(r,y):r;v.length&&v?.forEach(P=>{se.isDraggable(P)||se.dragIn(P,d)})}movable(r,d){return this.opts.staticGrid||Bt.getElements(r).forEach(y=>{let v=y.gridstackNode;v&&(d?delete v.noMove:v.noMove=!0,this._prepareDragDropByNode(v))}),this}resizable(r,d){return this.opts.staticGrid||Bt.getElements(r).forEach(y=>{let v=y.gridstackNode;v&&(d?delete v.noResize:v.noResize=!0,this._prepareDragDropByNode(v))}),this}disable(r=!0){if(!this.opts.staticGrid)return this.enableMove(!1,r),this.enableResize(!1,r),this._triggerEvent("disable"),this}enable(r=!0){if(!this.opts.staticGrid)return this.enableMove(!0,r),this.enableResize(!0,r),this._triggerEvent("enable"),this}enableMove(r,d=!0){return this.opts.staticGrid||(r?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(y=>{this._prepareDragDropByNode(y),y.subGrid&&d&&y.subGrid.enableMove(r,d)})),this}enableResize(r,d=!0){return this.opts.staticGrid||(r?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(y=>{this._prepareDragDropByNode(y),y.subGrid&&d&&y.subGrid.enableResize(r,d)})),this}_removeDD(r){return se.draggable(r,"destroy").resizable(r,"destroy"),r.gridstackNode&&delete r.gridstackNode._initDD,delete r.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return se.droppable(this.el,"destroy"),this;let r,d,y=(v,P,F)=>{let Y=P.gridstackNode;if(!Y)return;if(F=F||P,!Y.grid?.el){F.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;let Et=F.getBoundingClientRect();F.style.left=Et.x+(this.dragTransform.xScale-1)*(v.clientX-Et.x)/this.dragTransform.xScale+"px",F.style.top=Et.y+(this.dragTransform.yScale-1)*(v.clientY-Et.y)/this.dragTransform.yScale+"px",F.style.transformOrigin="0px 0px"}let nt=this.el.getBoundingClientRect(),{top:V,left:it}=F.getBoundingClientRect();it-=nt.left,V-=nt.top;let kt={position:{top:V*this.dragTransform.xScale,left:it*this.dragTransform.yScale}};if(Y._temporaryRemoved){if(Y.x=Math.max(0,Math.round(it/d)),Y.y=Math.max(0,Math.round(V/r)),delete Y.autoPosition,this.engine.nodeBoundFix(Y),!this.engine.willItFit(Y)){if(Y.autoPosition=!0,!this.engine.willItFit(Y))return void se.off(P,"drag");Y._willFitPos&&(f.copyPos(Y,Y._willFitPos),delete Y._willFitPos)}this._onStartMoving(F,v,kt,Y,d,r)}else this._dragOrResize(F,v,kt,Y,d,r)};return se.droppable(this.el,{accept:v=>{let P=v.gridstackNode||this._readAttr(v,!1);if(P?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let F=!0;if(typeof this.opts.acceptWidgets=="function")F=this.opts.acceptWidgets(v);else{let Y=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;F=v.matches(Y)}if(F&&P&&this.opts.maxRow){let Y={w:P.w,h:P.h,minW:P.minW,minH:P.minH};F=this.engine.willItFit(Y)}return F}}).on(this.el,"dropover",(v,P,F)=>{let Y=P.gridstackNode;if(Y?.grid===this&&!Y._temporaryRemoved)return!1;Y?.grid&&Y.grid!==this&&!Y._temporaryRemoved&&Y.grid._leave(P,F),d=this.cellWidth(),r=this.getCellHeight(!0),Y||(Y=this._readAttr(P,!1)),Y.grid||(Y._isExternal=!0,P.gridstackNode=Y),F=F||P;let nt=Y.w||Math.round(F.offsetWidth/d)||1,V=Y.h||Math.round(F.offsetHeight/r)||1;return Y.grid&&Y.grid!==this?(P._gridstackNodeOrig||(P._gridstackNodeOrig=Y),P.gridstackNode=Y={...Y,w:nt,h:V,grid:this},delete Y.x,delete Y.y,this.engine.cleanupNode(Y).nodeBoundFix(Y),Y._initDD=Y._isExternal=Y._temporaryRemoved=!0):(Y.w=nt,Y.h=V,Y._temporaryRemoved=!0),Bt._itemRemoving(Y.el,!1),se.on(P,"drag",y),y(v,P,F),!1}).on(this.el,"dropout",(v,P,F)=>{let Y=P.gridstackNode;return!!Y&&(Y.grid&&Y.grid!==this||(this._leave(P,F),this._isTemp&&this.removeAsSubGrid(Y)),!1)}).on(this.el,"drop",(v,P,F)=>{let Y=P.gridstackNode;if(Y?.grid===this&&!Y._isExternal)return!1;let nt=!!this.placeholder.parentElement;this.placeholder.remove();let V=nt&&this.opts.animate;V&&this.setAnimation(!1);let it=P._gridstackNodeOrig;if(delete P._gridstackNodeOrig,nt&&it?.grid&&it.grid!==this){let Et=it.grid;Et.engine.removeNodeFromLayoutCache(it),Et.engine.removedNodes.push(it),Et._triggerRemoveEvent()._triggerChangeEvent(),Et.parentGridItem&&!Et.engine.nodes.length&&Et.opts.subGridDynamic&&Et.removeAsSubGrid()}if(!Y||(nt&&(this.engine.cleanupNode(Y),Y.grid=this),delete Y.grid?._isTemp,se.off(P,"drag"),F!==P?(F.remove(),P.gridstackNode=it,nt&&(P=P.cloneNode(!0))):(P.remove(),this._removeDD(P)),!nt))return!1;P.gridstackNode=Y,Y.el=P;let kt=Y.subGrid?.el?.gridstack;return f.copyPos(Y,this._readAttr(this.placeholder)),f.removePositioningStyles(P),this.el.appendChild(P),this._prepareElement(P,!0,Y),kt&&(kt.parentGridItem=Y,kt.opts.styleInHead||kt._updateStyles(!0)),this._updateContainerHeight(),this.engine.addedNodes.push(Y),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...v,type:"dropped"},it&&it.grid?it:void 0,Y),V&&this.setAnimation(this.opts.animate,!0),!1}),this}static _itemRemoving(r,d){let y=r?r.gridstackNode:void 0;y?.grid&&!r.classList.contains(y.grid.opts.removableOptions.decline)&&(d?y._isAboutToRemove=!0:delete y._isAboutToRemove,d?r.classList.add("grid-stack-item-removing"):r.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;let r=document.querySelector(this.opts.removable);return r?(this.opts.staticGrid||se.isDroppable(r)||se.droppable(r,this.opts.removableOptions).on(r,"dropover",(d,y)=>Bt._itemRemoving(y,!0)).on(r,"dropout",(d,y)=>Bt._itemRemoving(y,!1)),this):this}_prepareDragDropByNode(r){let d=r.el,y=r.noMove||this.opts.disableDrag,v=r.noResize||this.opts.disableResize;if(this.opts.staticGrid||y&&v)return r._initDD&&(this._removeDD(d),delete r._initDD),d.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!r._initDD){let P,F,Y=(it,kt)=>{this._gsEventHandler[it.type]&&this._gsEventHandler[it.type](it,it.target),P=this.cellWidth(),F=this.getCellHeight(!0),this._onStartMoving(d,it,kt,r,P,F)},nt=(it,kt)=>{this._dragOrResize(d,it,kt,r,P,F)},V=it=>{this.placeholder.remove(),delete r._moving,delete r._event,delete r._lastTried;let kt=r.w!==r._orig.w,Et=it.target;if(Et.gridstackNode&&Et.gridstackNode.grid===this){if(r.el=Et,r._isAboutToRemove){let ie=d.gridstackNode.grid;ie._gsEventHandler[it.type]&&ie._gsEventHandler[it.type](it,Et),ie.engine.nodes.push(r),ie.removeWidget(d,!0,!0)}else f.removePositioningStyles(Et),r._temporaryRemoved?(f.copyPos(r,r._orig),this._writePosAttr(Et,r),this.engine.addNode(r)):this._writePosAttr(Et,r),this._gsEventHandler[it.type]&&this._gsEventHandler[it.type](it,Et);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),it.type==="resizestop"&&(Number.isInteger(r.sizeToContent)&&(r.sizeToContent=r.h),this.resizeToContentCheck(kt,r))}};se.draggable(d,{start:Y,stop:V,drag:nt}).resizable(d,{start:Y,stop:V,resize:nt}),r._initDD=!0}return se.draggable(d,y?"disable":"enable").resizable(d,v?"disable":"enable"),this}_onStartMoving(r,d,y,v,P,F){if(this.engine.cleanNodes().beginUpdate(v),this._writePosAttr(this.placeholder,v),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=v,v.grid?.el)this.dragTransform=f.getValuesFromTransformedElement(r);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){let Y=this.placeholder.closest(".grid-stack");this.dragTransform=f.getValuesFromTransformedElement(Y)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(v.el=this.placeholder,v._lastUiPosition=y.position,v._prevYPix=y.position.top,v._moving=d.type==="dragstart",delete v._lastTried,d.type==="dropover"&&v._temporaryRemoved&&(this.engine.addNode(v),v._moving=!0),this.engine.cacheRects(P,F,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),d.type==="resizestart"){let Y=this.getColumn()-v.x,nt=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-v.y;se.resizable(r,"option","minWidth",P*Math.min(v.minW||1,Y)).resizable(r,"option","minHeight",F*Math.min(v.minH||1,nt)).resizable(r,"option","maxWidth",P*Math.min(v.maxW||Number.MAX_SAFE_INTEGER,Y)).resizable(r,"option","maxWidthMoveLeft",P*Math.min(v.maxW||Number.MAX_SAFE_INTEGER,v.x+v.w)).resizable(r,"option","maxHeight",F*Math.min(v.maxH||Number.MAX_SAFE_INTEGER,nt)).resizable(r,"option","maxHeightMoveUp",F*Math.min(v.maxH||Number.MAX_SAFE_INTEGER,v.y+v.h))}}_dragOrResize(r,d,y,v,P,F){let Y,nt={...v._orig},V=this.opts.marginLeft,it=this.opts.marginRight,kt=this.opts.marginTop,Et=this.opts.marginBottom,ie=Math.round(.1*F),Le=Math.round(.1*P);if(V=Math.min(V,Le),it=Math.min(it,Le),kt=Math.min(kt,ie),Et=Math.min(Et,ie),d.type==="drag"){if(v._temporaryRemoved)return;let Re=y.position.top-v._prevYPix;v._prevYPix=y.position.top,this.opts.draggable.scroll!==!1&&f.updateScrollPosition(r,y.position,Re);let We=y.position.left+(y.position.left>v._lastUiPosition.left?-it:V),Je=y.position.top+(y.position.top>v._lastUiPosition.top?-Et:kt);nt.x=Math.round(We/P),nt.y=Math.round(Je/F);let Ie=this._extraDragRow;if(this.engine.collide(v,nt)){let ti=this.getRow(),Ne=Math.max(0,nt.y+v.h-ti);this.opts.maxRow&&ti+Ne>this.opts.maxRow&&(Ne=Math.max(0,this.opts.maxRow-ti)),this._extraDragRow=Ne}else this._extraDragRow=0;if(this._extraDragRow!==Ie&&this._updateContainerHeight(),v.x===nt.x&&v.y===nt.y)return}else if(d.type==="resize"){if(nt.x<0||(f.updateScrollResize(d,r,F),nt.w=Math.round((y.size.width-V)/P),nt.h=Math.round((y.size.height-kt)/F),v.w===nt.w&&v.h===nt.h)||v._lastTried&&v._lastTried.w===nt.w&&v._lastTried.h===nt.h)return;let Re=y.position.left+V,We=y.position.top+kt;nt.x=Math.round(Re/P),nt.y=Math.round(We/F),Y=!0}v._event=d,v._lastTried=nt;let ii={x:y.position.left+V,y:y.position.top+kt,w:(y.size?y.size.width:v.w*P)-V-it,h:(y.size?y.size.height:v.h*F)-kt-Et};if(this.engine.moveNodeCheck(v,{...nt,cellWidth:P,cellHeight:F,rect:ii,resizing:Y})){v._lastUiPosition=y.position,this.engine.cacheRects(P,F,kt,it,Et,V),delete v._skipDown,Y&&v.subGrid&&v.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();let Re=d.target;this._writePosAttr(Re,v),this._gsEventHandler[d.type]&&this._gsEventHandler[d.type](d,Re)}}_leave(r,d){let y=r.gridstackNode;y&&((d=d||r).style.transform="scale(1)",se.off(r,"drag"),y._temporaryRemoved||(y._temporaryRemoved=!0,this.engine.removeNode(y),y.el=y._isExternal&&d?d:r,this.opts.removable===!0&&Bt._itemRemoving(r,!0),r._gridstackNodeOrig?(r.gridstackNode=r._gridstackNodeOrig,delete r._gridstackNodeOrig):y._isExternal&&(delete y.el,delete r.gridstackNode,this.engine.restoreInitial())))}commit(){return this.batchUpdate(!1).prototype,this}}return Bt.resizeToContentParent=".grid-stack-item-content",Bt.Utils=f,Bt.Engine=C,Bt.GDRev="10.3.1",h.GridStack})());(function(D,h,f,C){"use strict";function I(S,O,B){return setTimeout(Rt(S,B),O)}function X(S,O,B){return Array.isArray(S)?(W(S,B[O],B),!0):!1}function W(S,O,B){var c;if(S)if(S.forEach)S.forEach(O,B);else if(S.length!==C)for(c=0;c\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",_=D.console&&(D.console.warn||D.console.log);return _&&_.call(D.console,c,m),S.apply(this,arguments)}}function q(S,O,B){var c,p=O.prototype;c=S.prototype=Object.create(p),c.constructor=S,c._super=p,B&&fe(c,B)}function Rt(S,O){return function(){return S.apply(O,arguments)}}function Ot(S,O){return typeof S==rs?S.apply(O&&O[0]||C,O):S}function ft(S,O){return S===C?O:S}function xt(S,O,B){W(Ae(O),function(c){S.addEventListener(c,B,!1)})}function jt(S,O,B){W(Ae(O),function(c){S.removeEventListener(c,B,!1)})}function te(S,O){for(;S;){if(S==O)return!0;S=S.parentNode}return!1}function ae(S,O){return S.indexOf(O)>-1}function Ae(S){return S.trim().split(/\s+/g)}function ue(S,O,B){if(S.indexOf&&!B)return S.indexOf(O);for(var c=0;cK[O]}):c.sort()),c}function Ee(S,O){for(var B,c,p=O[0].toUpperCase()+O.slice(1),m=0;m1&&!B.firstMultiple?B.firstMultiple=v(O):p===1&&(B.firstMultiple=!1);var m=B.firstInput,_=B.firstMultiple,L=_?_.center:m.center,K=O.center=P(c);O.timeStamp=Ki(),O.deltaTime=O.timeStamp-m.timeStamp,O.angle=V(L,K),O.distance=nt(L,K),d(B,O),O.offsetDirection=Y(O.deltaX,O.deltaY);var gt=F(O.deltaTime,O.deltaX,O.deltaY);O.overallVelocityX=gt.x,O.overallVelocityY=gt.y,O.overallVelocity=di(gt.x)>di(gt.y)?gt.x:gt.y,O.scale=_?kt(_.pointers,c):1,O.rotation=_?it(_.pointers,c):0,O.maxPointers=B.prevInput?O.pointers.length>B.prevInput.maxPointers?O.pointers.length:B.prevInput.maxPointers:O.pointers.length,y(B,O);var wt=S.element;te(O.srcEvent.target,wt)&&(wt=O.srcEvent.target),O.target=wt}function d(S,O){var B=O.center,c=S.offsetDelta||{},p=S.prevDelta||{},m=S.prevInput||{};O.eventType!==Ie&&m.eventType!==be||(p=S.prevDelta={x:m.deltaX||0,y:m.deltaY||0},c=S.offsetDelta={x:B.x,y:B.y}),O.deltaX=p.x+(B.x-c.x),O.deltaY=p.y+(B.y-c.y)}function y(S,O){var B,c,p,m,_=S.lastInterval||O,L=O.timeStamp-_.timeStamp;if(O.eventType!=Ye&&(L>Pi||_.velocity===C)){var K=O.deltaX-_.deltaX,gt=O.deltaY-_.deltaY,wt=F(L,K,gt);c=wt.x,p=wt.y,B=di(wt.x)>di(wt.y)?wt.x:wt.y,m=Y(K,gt),S.lastInterval=O}else B=_.velocity,c=_.velocityX,p=_.velocityY,m=_.direction;O.velocity=B,O.velocityX=c,O.velocityY=p,O.direction=m}function v(S){for(var O=[],B=0;Bp;)B+=S[p].clientX,c+=S[p].clientY,p++;return{x:ci(B/O),y:ci(c/O)}}function F(S,O,B){return{x:O/S||0,y:B/S||0}}function Y(S,O){return S===O?ts:di(S)>=di(O)?0>S?ki:mi:0>O?bi:Hi}function nt(S,O,B){B||(B=Ri);var c=O[B[0]]-S[B[0]],p=O[B[1]]-S[B[1]];return Math.sqrt(c*c+p*p)}function V(S,O,B){B||(B=Ri);var c=O[B[0]]-S[B[0]],p=O[B[1]]-S[B[1]];return 180*Math.atan2(p,c)/Math.PI}function it(S,O){return V(O[1],O[0],Oi)+V(S[1],S[0],Oi)}function kt(S,O){return nt(O[0],O[1],Oi)/nt(S[0],S[1],Oi)}function Et(){this.evEl=ge,this.evWin=Ue,this.pressed=!1,se.apply(this,arguments)}function ie(){this.evEl=es,this.evWin=E,se.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function Le(){this.evTarget=z,this.evWin=I,this.started=!1,se.apply(this,arguments)}function ii(S,O){var B=_e(S.touches),c=_e(S.changedTouches);return O&(be|Ye)&&(B=Oe(B.concat(c),"identifier",!0)),[B,c]}function Re(){this.evTarget=U,this.targetIds={},se.apply(this,arguments)}function We(S,O){var B=_e(S.touches),c=this.targetIds;if(O&(Ie|Ai)&&B.length===1)return c[B[0].identifier]=!0,[B,B];var p,m,_=_e(S.changedTouches),L=[],K=this.target;if(m=B.filter(function(gt){return te(gt.target,K)}),O===Ie)for(p=0;p-1&&c.splice(m,1)};setTimeout(p,G)}}function Ne(S){for(var O=S.srcEvent.clientX,B=S.srcEvent.clientY,c=0;c=m&&rt>=_)return!0}return!1}function si(S,O){this.manager=S,this.set(O)}function wi(S){if(ae(S,Lt))return Lt;var O=ae(S,It),B=ae(S,_t);return O&&B?Lt:O||B?O?It:_t:ae(S,vt)?vt:lt}function Di(){if(!st)return!1;var S={},O=D.CSS&&D.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(B){S[B]=O?D.CSS.supports("touch-action",B):!0}),S}function ve(S){this.options=fe({},this.defaults,S||{}),this.id=Ge(),this.manager=null,this.options.enable=ft(this.options.enable,!0),this.state=Dt,this.simultaneous={},this.requireFail=[]}function N(S){return S&le?"cancel":S&oe?"end":S&Qt?"move":S&Yt?"start":""}function J(S){return S==Hi?"down":S==bi?"up":S==ki?"left":S==mi?"right":""}function et(S,O){var B=O.manager;return B?B.get(S):S}function ot(){ve.apply(this,arguments)}function ut(){ot.apply(this,arguments),this.pX=null,this.pY=null}function dt(){ot.apply(this,arguments)}function yt(){ve.apply(this,arguments),this._timer=null,this._input=null}function Pt(){ot.apply(this,arguments)}function Tt(){ot.apply(this,arguments)}function Ut(){ve.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function zt(S,O){return O=O||{},O.recognizers=ft(O.recognizers,zt.defaults.preset),new ce(S,O)}function ce(S,O){this.options=fe({},zt.defaults,O||{}),this.options.inputTarget=this.options.inputTarget||S,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=S,this.input=Bt(this),this.touchAction=new si(this,this.options.touchAction),re(this,!0),W(this.options.recognizers,function(B){var c=this.add(new B[0](B[1]));B[2]&&c.recognizeWith(B[2]),B[3]&&c.requireFailure(B[3])},this)}function re(S,O){var B=S.element;if(B.style){var c;W(S.options.cssProps,function(p,m){c=Ee(B.style,m),O?(S.oldCssProps[c]=B.style[c],B.style[c]=p):B.style[c]=S.oldCssProps[c]||""}),O||(S.oldCssProps={})}}function Ce(S,O){var B=h.createEvent("Event");B.initEvent(S,!0,!0),B.gesture=O,O.target.dispatchEvent(B)}var fe,xe=["","webkit","Moz","MS","ms","o"],Te=h.createElement("div"),rs="function",ci=Math.round,di=Math.abs,Ki=Date.now;fe=typeof Object.assign!="function"?function(S){if(S===C||S===null)throw new TypeError("Cannot convert undefined or null to object");for(var O=Object(S),B=1;BL&&(O.push(S),L=O.length-1):p&(be|Ye)&&(B=!0),0>L||(O[L]=S,this.callback(this.manager,p,{pointers:O,changedPointers:[S],pointerType:m,srcEvent:S}),B&&O.splice(L,1))}});var M={touchstart:Ie,touchmove:Ai,touchend:be,touchcancel:Ye},z="touchstart",I="touchstart touchmove touchend touchcancel";q(Le,se,{handler:function(S){var O=M[S.type];if(O===Ie&&(this.started=!0),this.started){var B=ii.call(this,S,O);O&(be|Ye)&&B[0].length-B[1].length===0&&(this.started=!1),this.callback(this.manager,O,{pointers:B[0],changedPointers:B[1],pointerType:$e,srcEvent:S})}}});var j={touchstart:Ie,touchmove:Ai,touchend:be,touchcancel:Ye},U="touchstart touchmove touchend touchcancel";q(Re,se,{handler:function(S){var O=j[S.type],B=We.call(this,S,O);B&&this.callback(this.manager,O,{pointers:B[0],changedPointers:B[1],pointerType:$e,srcEvent:S})}});var G=2500,rt=25;q(Je,se,{handler:function(S,O,B){var c=B.pointerType==$e,p=B.pointerType==Ji;if(!(p&&B.sourceCapabilities&&B.sourceCapabilities.firesTouchEvents)){if(c)He.call(this,O,B);else if(p&&Ne.call(this,B))return;this.callback(S,O,B)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var ct=Ee(Te.style,"touchAction"),st=ct!==C,pt="compute",lt="auto",vt="manipulation",Lt="none",It="pan-x",_t="pan-y",bt=Di();si.prototype={set:function(S){S==pt&&(S=this.compute()),st&&this.manager.element.style&&bt[S]&&(this.manager.element.style[ct]=S),this.actions=S.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var S=[];return W(this.manager.recognizers,function(O){Ot(O.options.enable,[O])&&(S=S.concat(O.getTouchAction()))}),wi(S.join(" "))},preventDefaults:function(S){var O=S.srcEvent,B=S.offsetDirection;if(this.manager.session.prevented)return void O.preventDefault();var c=this.actions,p=ae(c,Lt)&&!bt[Lt],m=ae(c,_t)&&!bt[_t],_=ae(c,It)&&!bt[It];if(p){var L=S.pointers.length===1,K=S.distance<2,gt=S.deltaTime<250;if(L&&K&>)return}return _&&m?void 0:p||m&&B&pi||_&&B&yi?this.preventSrc(O):void 0},preventSrc:function(S){this.manager.session.prevented=!0,S.preventDefault()}};var Dt=1,Yt=2,Qt=4,oe=8,de=oe,le=16,Zt=32;ve.prototype={defaults:{},set:function(S){return fe(this.options,S),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(S){if(X(S,"recognizeWith",this))return this;var O=this.simultaneous;return S=et(S,this),O[S.id]||(O[S.id]=S,S.recognizeWith(this)),this},dropRecognizeWith:function(S){return X(S,"dropRecognizeWith",this)?this:(S=et(S,this),delete this.simultaneous[S.id],this)},requireFailure:function(S){if(X(S,"requireFailure",this))return this;var O=this.requireFail;return S=et(S,this),ue(O,S)===-1&&(O.push(S),S.requireFailure(this)),this},dropRequireFailure:function(S){if(X(S,"dropRequireFailure",this))return this;S=et(S,this);var O=ue(this.requireFail,S);return O>-1&&this.requireFail.splice(O,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(S){return!!this.simultaneous[S.id]},emit:function(S){function O(p){B.manager.emit(p,S)}var B=this,c=this.state;oe>c&&O(B.options.event+N(c)),O(B.options.event),S.additionalEvent&&O(S.additionalEvent),c>=oe&&O(B.options.event+N(c))},tryEmit:function(S){return this.canEmit()?this.emit(S):void(this.state=Zt)},canEmit:function(){for(var S=0;Sm?ki:mi,B=m!=this.pX,c=Math.abs(S.deltaX)):(p=_===0?ts:0>_?bi:Hi,B=_!=this.pY,c=Math.abs(S.deltaY))),S.direction=p,B&&c>O.threshold&&p&O.direction},attrTest:function(S){return ot.prototype.attrTest.call(this,S)&&(this.state&Yt||!(this.state&Yt)&&this.directionTest(S))},emit:function(S){this.pX=S.deltaX,this.pY=S.deltaY;var O=J(S.direction);O&&(S.additionalEvent=this.options.event+O),this._super.emit.call(this,S)}}),q(dt,ot,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Lt]},attrTest:function(S){return this._super.attrTest.call(this,S)&&(Math.abs(S.scale-1)>this.options.threshold||this.state&Yt)},emit:function(S){if(S.scale!==1){var O=S.scale<1?"in":"out";S.additionalEvent=this.options.event+O}this._super.emit.call(this,S)}}),q(yt,ve,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[lt]},process:function(S){var O=this.options,B=S.pointers.length===O.pointers,c=S.distanceO.time;if(this._input=S,!c||!B||S.eventType&(be|Ye)&&!p)this.reset();else if(S.eventType&Ie)this.reset(),this._timer=H(function(){this.state=de,this.tryEmit()},O.time,this);else if(S.eventType&be)return de;return Zt},reset:function(){clearTimeout(this._timer)},emit:function(S){this.state===de&&(S&&S.eventType&be?this.manager.emit(this.options.event+"up",S):(this._input.timeStamp=Ki(),this.manager.emit(this.options.event,this._input)))}}),q(Pt,ot,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Lt]},attrTest:function(S){return this._super.attrTest.call(this,S)&&(Math.abs(S.rotation)>this.options.threshold||this.state&Yt)}}),q(Tt,ot,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:pi|yi,pointers:1},getTouchAction:function(){return ut.prototype.getTouchAction.call(this)},attrTest:function(S){var O,B=this.options.direction;return B&(pi|yi)?O=S.overallVelocity:B&pi?O=S.overallVelocityX:B&yi&&(O=S.overallVelocityY),this._super.attrTest.call(this,S)&&B&S.offsetDirection&&S.distance>this.options.threshold&&S.maxPointers==this.options.pointers&&di(O)>this.options.velocity&&S.eventType&be},emit:function(S){var O=J(S.offsetDirection);O&&this.manager.emit(this.options.event+O,S),this.manager.emit(this.options.event,S)}}),q(Ut,ve,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[vt]},process:function(S){var O=this.options,B=S.pointers.length===O.pointers,c=S.distance{let i=0;return()=>i++})();function C(i){return i==null}function H(i){if(Array.isArray&&Array.isArray(i))return!0;let t=Object.prototype.toString.call(i);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function X(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function W(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function at(i,t){return W(i)?i:t}function q(i,t){return i===void 0?t:i}let Rt=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100:+i/t,Ot=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*t:+i;function ft(i,t,e){if(i&&typeof i.call=="function")return i.apply(e,t)}function xt(i,t,e,s){let n,o,a;if(H(i))if(o=i.length,s)for(n=o-1;n>=0;n--)t.call(e,i[n],n);else for(n=0;ni,x:i=>i.x,y:i=>i.y};function Ge(i){let t=i.split("."),e=[],s="";for(let n of t)s+=n,s.endsWith("\\")?s=s.slice(0,-1)+".":(e.push(s),s="");return e}function De(i,t){return(Ee[t]||(Ee[t]=function(s){let n=Ge(s);return o=>{for(let a of n){if(a==="")break;o=o&&o[a]}return o}}(t)))(i)}function se(i){return i.charAt(0).toUpperCase()+i.slice(1)}let Bt=i=>i!==void 0,St=i=>typeof i=="function",r=(i,t)=>{if(i.size!==t.size)return!1;for(let e of i)if(!t.has(e))return!1;return!0};function d(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}let y=Math.PI,v=2*y,P=v+y,F=Number.POSITIVE_INFINITY,Y=y/180,nt=y/2,V=y/4,it=2*y/3,kt=Math.log10,Et=Math.sign;function ie(i,t,e){return Math.abs(i-t)n-o).pop(),t}function Re(i){return!isNaN(parseFloat(i))&&isFinite(i)}function We(i,t){let e=Math.round(i);return e-t<=i&&e+t>=i}function Je(i,t,e){let s,n,o;for(s=0,n=i.length;su&&g=Math.min(t,e)-s&&i<=Math.max(t,e)+s}function ut(i,t,e){e=e||(a=>i[a]1;)s=o+n>>1,e(s)?o=s:n=s;return{lo:o,hi:n}}let dt=(i,t,e,s)=>ut(i,e,s?n=>{let o=i[n][t];return oi[n][t]ut(i,e,s=>i[s][t]>=e);function Pt(i,t,e){let s=0,n=i.length;for(;ss&&i[n-1]>e;)n--;return s>0||n{let s="_onData"+se(e),n=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,value(...o){let a=n.apply(this,o);return i._chartjs.listeners.forEach(l=>{typeof l[s]=="function"&&l[s](...o)}),a}})}))}function zt(i,t){let e=i._chartjs;if(!e)return;let s=e.listeners,n=s.indexOf(t);n!==-1&&s.splice(n,1),s.length>0||(Tt.forEach(o=>{delete i[o]}),delete i._chartjs)}function ce(i){let t=new Set(i);return t.size===i.length?i:Array.from(t)}let re=typeof window>"u"?function(i){return i()}:window.requestAnimationFrame;function Ce(i,t){let e=[],s=!1;return function(...n){e=n,s||(s=!0,re.call(window,()=>{s=!1,i.apply(t,e)}))}}function fe(i,t){let e;return function(...s){return t?(clearTimeout(e),e=setTimeout(i,t,s)):i.apply(this,s),t}}let xe=i=>i==="start"?"left":i==="end"?"right":"center",Te=(i,t,e)=>i==="start"?t:i==="end"?e:(t+e)/2,rs=(i,t,e,s)=>i===(s?"left":"right")?e:i==="center"?(t+e)/2:t;function ci(i,t,e){let s=t.length,n=0,o=s;if(i._sorted){let{iScale:a,_parsed:l}=i,u=a.axis,{min:g,max:x,minDefined:b,maxDefined:w}=a.getUserBounds();b&&(n=J(Math.min(dt(l,u,g).lo,e?s:dt(t,u,a.getPixelForValue(g)).lo),0,s-1)),o=w?J(Math.max(dt(l,a.axis,x,!0).hi+1,e?0:dt(t,u,a.getPixelForValue(x),!0).hi+1),n,s)-n:s-n}return{start:n,count:o}}function di(i){let{xScale:t,yScale:e,_scaleRanges:s}=i,n={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!s)return i._scaleRanges=n,!0;let o=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==e.min||s.ymax!==e.max;return Object.assign(s,n),o}class Ki{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,s,n){let o=e.listeners[n],a=e.duration;o.forEach(l=>l({chart:t,initial:e.initial,numSteps:a,currentStep:Math.min(s-e.start,a)}))}_refresh(){this._request||(this._running=!0,this._request=re.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((s,n)=>{if(!s.running||!s.items.length)return;let o=s.items,a,l=o.length-1,u=!1;for(;l>=0;--l)a=o[l],a._active?(a._total>s.duration&&(s.duration=a._total),a.tick(t),u=!0):(o[l]=o[o.length-1],o.pop());u&&(n.draw(),this._notify(n,s,t,"progress")),o.length||(s.running=!1,this._notify(n,s,t,"complete"),s.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){let e=this._charts,s=e.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,s)),s}listen(t,e,s){this._getAnims(t).listeners[e].push(s)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){let e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((s,n)=>Math.max(s,n._duration),0),this._refresh())}running(t){if(!this._running)return!1;let e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){let e=this._charts.get(t);if(!e||!e.items.length)return;let s=e.items,n=s.length-1;for(;n>=0;--n)s[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Be=new Ki;function Ii(i){return i+.5|0}let ni=(i,t,e)=>Math.max(Math.min(i,e),t);function _i(i){return ni(Ii(2.55*i),0,255)}function ui(i){return ni(Ii(255*i),0,255)}function gi(i){return ni(Ii(i/2.55)/100,0,1)}function Zi(i){return ni(Ii(100*i),0,100)}let $e={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Ui=[..."0123456789ABCDEF"],Ji=i=>Ui[15&i],ji=i=>Ui[(240&i)>>4]+Ui[15&i],Pi=i=>(240&i)>>4==(15&i);function Ie(i){var t=(e=>Pi(e.r)&&Pi(e.g)&&Pi(e.b)&&Pi(e.a))(i)?Ji:ji;return i?"#"+t(i.r)+t(i.g)+t(i.b)+((e,s)=>e<255?s(e):"")(i.a,t):void 0}let Ai=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function be(i,t,e){let s=t*Math.min(e,1-e),n=(o,a=(o+i/30)%12)=>e-s*Math.max(Math.min(a-3,9-a,1),-1);return[n(0),n(8),n(4)]}function Ye(i,t,e){let s=(n,o=(n+i/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[s(5),s(3),s(1)]}function ts(i,t,e){let s=be(i,1,.5),n;for(t+e>1&&(n=1/(t+e),t*=n,e*=n),n=0;n<3;n++)s[n]*=1-t-e,s[n]+=t;return s}function ki(i){let t=i.r/255,e=i.g/255,s=i.b/255,n=Math.max(t,e,s),o=Math.min(t,e,s),a=(n+o)/2,l,u,g;return n!==o&&(g=n-o,u=a>.5?g/(2-n-o):g/(n+o),l=function(x,b,w,k,A){return x===A?(b-w)/k+(b>16&255,l>>8&255,255&l]}return e}(),Ri.transparent=[0,0,0,0]);let t=Ri[i.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}let ds=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/,ge=i=>i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055,Ue=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function Ni(i,t,e){if(i){let s=ki(i);s[t]=Math.max(0,Math.min(s[t]+s[t]*e,t===0?360:1)),s=bi(s),i.r=s[0],i.g=s[1],i.b=s[2]}}function we(i,t){return i&&Object.assign(t||{},i)}function es(i){var t={r:0,g:0,b:0,a:255};return Array.isArray(i)?i.length>=3&&(t={r:i[0],g:i[1],b:i[2],a:255},i.length>3&&(t.a=ui(i[3]))):(t=we(i,{r:0,g:0,b:0,a:1})).a=ui(t.a),t}function E(i){return i.charAt(0)==="r"?function(t){let e=ds.exec(t),s,n,o,a=255;if(e){if(e[7]!==s){let l=+e[7];a=e[8]?_i(l):ni(255*l,0,255)}return s=+e[1],n=+e[3],o=+e[5],s=255&(e[2]?_i(s):ni(s,0,255)),n=255&(e[4]?_i(n):ni(n,0,255)),o=255&(e[6]?_i(o):ni(o,0,255)),{r:s,g:n,b:o,a}}}(i):pi(i)}class M{constructor(t){if(t instanceof M)return t;let e=typeof t,s;var n,o,a;e==="object"?s=es(t):e==="string"&&(a=(n=t).length,n[0]==="#"&&(a===4||a===5?o={r:255&17*$e[n[1]],g:255&17*$e[n[2]],b:255&17*$e[n[3]],a:a===5?17*$e[n[4]]:255}:a!==7&&a!==9||(o={r:$e[n[1]]<<4|$e[n[2]],g:$e[n[3]]<<4|$e[n[4]],b:$e[n[5]]<<4|$e[n[6]],a:a===9?$e[n[7]]<<4|$e[n[8]]:255})),s=o||Oi(t)||E(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=we(this._rgb);return t&&(t.a=gi(t.a)),t}set rgb(t){this._rgb=es(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${gi(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?Ie(this._rgb):void 0}hslString(){return this._valid?function(t){if(!t)return;let e=ki(t),s=e[0],n=Zi(e[1]),o=Zi(e[2]);return t.a<255?`hsla(${s}, ${n}%, ${o}%, ${gi(t.a)})`:`hsl(${s}, ${n}%, ${o}%)`}(this._rgb):void 0}mix(t,e){if(t){let s=this.rgb,n=t.rgb,o,a=e===o?.5:e,l=2*a-1,u=s.a-n.a,g=((l*u==-1?l:(l+u)/(1+l*u))+1)/2;o=1-g,s.r=255&g*s.r+o*n.r+.5,s.g=255&g*s.g+o*n.g+.5,s.b=255&g*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,this.rgb=s}return this}interpolate(t,e){return t&&(this._rgb=function(s,n,o){let a=Ue(gi(s.r)),l=Ue(gi(s.g)),u=Ue(gi(s.b));return{r:ui(ge(a+o*(Ue(gi(n.r))-a))),g:ui(ge(l+o*(Ue(gi(n.g))-l))),b:ui(ge(u+o*(Ue(gi(n.b))-u))),a:s.a+o*(n.a-s.a)}}(this._rgb,t._rgb,e)),this}clone(){return new M(this.rgb)}alpha(t){return this._rgb.a=ui(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){let t=this._rgb,e=Ii(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){let t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Ni(this._rgb,2,t),this}darken(t){return Ni(this._rgb,2,-t),this}saturate(t){return Ni(this._rgb,1,t),this}desaturate(t){return Ni(this._rgb,1,-t),this}rotate(t){return function(e,s){var n=ki(e);n[0]=Hi(n[0]+s),n=bi(n),e.r=n[0],e.g=n[1],e.b=n[2]}(this._rgb,t),this}}function z(i){if(i&&typeof i=="object"){let t=i.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function I(i){return z(i)?i:new M(i)}function j(i){return z(i)?i:new M(i).saturate(.5).darken(.1).hexString()}let U=["x","y","borderWidth","radius","tension"],G=["color","borderColor","backgroundColor"],rt=new Map;function ct(i,t,e){return function(s,n){n=n||{};let o=s+JSON.stringify(n),a=rt.get(o);return a||(a=new Intl.NumberFormat(s,n),rt.set(o,a)),a}(t,e).format(i)}let st={values:i=>H(i)?i:""+i,numeric(i,t,e){if(i===0)return"0";let s=this.chart.options.locale,n,o=i;if(e.length>1){let g=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(g<1e-4||g>1e15)&&(n="scientific"),o=function(x,b){let w=b.length>3?b[2].value-b[1].value:b[1].value-b[0].value;return Math.abs(w)>=1&&x!==Math.floor(x)&&(w=x-Math.floor(x)),w}(i,e)}let a=kt(Math.abs(o)),l=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),u={notation:n,minimumFractionDigits:l,maximumFractionDigits:l};return Object.assign(u,this.options.ticks.format),ct(i,s,u)},logarithmic(i,t,e){if(i===0)return"0";let s=e[t].significand||i/Math.pow(10,Math.floor(kt(i)));return[1,2,3,5,10,15].includes(s)||t>.8*e.length?st.numeric.call(this,i,t,e):""}};var pt={formatters:st};let lt=Object.create(null),vt=Object.create(null);function Lt(i,t){if(!t)return i;let e=t.split(".");for(let s=0,n=e.length;ss.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,n)=>j(n.backgroundColor),this.hoverBorderColor=(s,n)=>j(n.borderColor),this.hoverColor=(s,n)=>j(n.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return It(this,t,e)}get(t){return Lt(this,t)}describe(t,e){return It(vt,t,e)}override(t,e){return It(lt,t,e)}route(t,e,s,n){let o=Lt(this,t),a=Lt(this,s),l="_"+e;Object.defineProperties(o,{[l]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let u=this[l],g=a[n];return X(u)?Object.assign({},g,u):q(u,g)},set(u){this[l]=u}}})}apply(t){t.forEach(e=>e(this))}}var bt=new _t({_scriptable:i=>!i.startsWith("on"),_indexable:i=>i!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(i){i.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),i.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),i.set("animations",{colors:{type:"color",properties:G},numbers:{type:"number",properties:U}}),i.describe("animations",{_fallback:"animation"}),i.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(i){i.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(i){i.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:pt.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),i.route("scale.ticks","color","","color"),i.route("scale.grid","color","","borderColor"),i.route("scale.border","color","","borderColor"),i.route("scale.title","color","","color"),i.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),i.describe("scales",{_fallback:"scale"}),i.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}]);function Dt(){return typeof window<"u"&&typeof document<"u"}function Yt(i){let t=i.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function Qt(i,t,e){let s;return typeof i=="string"?(s=parseInt(i,10),i.indexOf("%")!==-1&&(s=s/100*t.parentNode[e])):s=i,s}let oe=i=>i.ownerDocument.defaultView.getComputedStyle(i,null);function de(i,t){return oe(i).getPropertyValue(t)}let le=["top","right","bottom","left"];function Zt(i,t,e){let s={};e=e?"-"+e:"";for(let n=0;n<4;n++){let o=le[n];s[o]=parseFloat(i[t+"-"+o+e])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}let Me=(i,t,e)=>(i>0||t>0)&&(!e||!e.shadowRoot);function me(i,t){if("native"in i)return i;let{canvas:e,currentDevicePixelRatio:s}=t,n=oe(e),o=n.boxSizing==="border-box",a=Zt(n,"padding"),l=Zt(n,"border","width"),{x:u,y:g,box:x}=function(T,R){let $=T.touches,tt=$&&$.length?$[0]:T,{offsetX:Z,offsetY:Q}=tt,ht,mt,Ct=!1;if(Me(Z,Q,T.target))ht=Z,mt=Q;else{let At=R.getBoundingClientRect();ht=tt.clientX-At.left,mt=tt.clientY-At.top,Ct=!0}return{x:ht,y:mt,box:Ct}}(i,e),b=a.left+(x&&l.left),w=a.top+(x&&l.top),{width:k,height:A}=t;return o&&(k-=a.width+l.width,A-=a.height+l.height),{x:Math.round((u-b)/k*e.width/s),y:Math.round((g-w)/A*e.height/s)}}let Pe=i=>Math.round(10*i)/10;function S(i,t,e,s){let n=oe(i),o=Zt(n,"margin"),a=Qt(n.maxWidth,i,"clientWidth")||F,l=Qt(n.maxHeight,i,"clientHeight")||F,u=function(b,w,k){let A,T;if(w===void 0||k===void 0){let R=Yt(b);if(R){let $=R.getBoundingClientRect(),tt=oe(R),Z=Zt(tt,"border","width"),Q=Zt(tt,"padding");w=$.width-Q.width-Z.width,k=$.height-Q.height-Z.height,A=Qt(tt.maxWidth,R,"clientWidth"),T=Qt(tt.maxHeight,R,"clientHeight")}else w=b.clientWidth,k=b.clientHeight}return{width:w,height:k,maxWidth:A||F,maxHeight:T||F}}(i,t,e),{width:g,height:x}=u;if(n.boxSizing==="content-box"){let b=Zt(n,"border","width"),w=Zt(n,"padding");g-=w.width+b.width,x-=w.height+b.height}return g=Math.max(0,g-o.width),x=Math.max(0,s?g/s:x-o.height),g=Pe(Math.min(g,a,u.maxWidth)),x=Pe(Math.min(x,l,u.maxHeight)),g&&!x&&(x=Pe(g/2)),(t!==void 0||e!==void 0)&&s&&u.height&&x>u.height&&(x=u.height,g=Pe(Math.floor(x*s))),{width:g,height:x}}function O(i,t,e){let s=t||1,n=Math.floor(i.height*s),o=Math.floor(i.width*s);i.height=Math.floor(i.height),i.width=Math.floor(i.width);let a=i.canvas;return a.style&&(e||!a.style.height&&!a.style.width)&&(a.style.height=`${i.height}px`,a.style.width=`${i.width}px`),(i.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(i.currentDevicePixelRatio=s,a.height=n,a.width=o,i.ctx.setTransform(s,0,0,s,0,0),!0)}let B=function(){let i=!1;try{let t={get passive(){return i=!0,!1}};Dt()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return i}();function c(i,t){let e=de(i,t),s=e&&e.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function p(i){return!i||C(i.size)||C(i.family)?null:(i.style?i.style+" ":"")+(i.weight?i.weight+" ":"")+i.size+"px "+i.family}function m(i,t,e,s,n){let o=t[n];return o||(o=t[n]=i.measureText(n).width,e.push(n)),o>s&&(s=o),s}function _(i,t,e,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==t&&(n=s.data={},o=s.garbageCollect=[],s.font=t),i.save(),i.font=t;let a=0,l=e.length,u,g,x,b,w;for(u=0;ue.length){for(u=0;u0&&i.stroke()}}function Mt(i,t,e){return e=e||.5,!t||i&&i.x>t.left-e&&i.xt.top-e&&i.y0&&o.strokeColor!=="",u,g;for(i.save(),i.font=n.string,function(x,b){b.translation&&x.translate(b.translation[0],b.translation[1]),C(b.rotation)||x.rotate(b.rotation),b.color&&(x.fillStyle=b.color),b.textAlign&&(x.textAlign=b.textAlign),b.textBaseline&&(x.textBaseline=b.textBaseline)}(i,o),u=0;ui[0]){let o=e||i;s===void 0&&(s=$s("_fallback",i));let a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:o,_fallback:s,_getTarget:n,override:l=>Ke([l,...i],t,o,s)};return new Proxy(a,{deleteProperty:(l,u)=>(delete l[u],delete l._keys,delete i[0][u],!0),get:(l,u)=>je(l,u,()=>function(g,x,b,w){let k;for(let A of x)if(k=$s(fi(A,g),b),k!==void 0)return vi(g,k)?_s(b,w,g,k):k}(u,t,i,l)),getOwnPropertyDescriptor:(l,u)=>Reflect.getOwnPropertyDescriptor(l._scopes[0],u),getPrototypeOf:()=>Reflect.getPrototypeOf(i[0]),has:(l,u)=>Os(l).includes(u),ownKeys:l=>Os(l),set(l,u,g){let x=l._storage||(l._storage=n());return l[u]=x[u]=g,delete l._keys,!0}})}function ri(i,t,e,s){let n={_cacheable:!1,_proxy:i,_context:t,_subProxy:e,_stack:new Set,_descriptors:ze(i,s),setContext:o=>ri(i,o,e,s),override:o=>ri(i.override(o),t,e,s)};return new Proxy(n,{deleteProperty:(o,a)=>(delete o[a],delete i[a],!0),get:(o,a,l)=>je(o,a,()=>function(u,g,x){let{_proxy:b,_context:w,_subProxy:k,_descriptors:A}=u,T=b[g];return St(T)&&A.isScriptable(g)&&(T=function(R,$,tt,Z){let{_proxy:Q,_context:ht,_subProxy:mt,_stack:Ct}=tt;if(Ct.has(R))throw new Error("Recursion detected: "+Array.from(Ct).join("->")+"->"+R);Ct.add(R);let At=$(ht,mt||Z);return Ct.delete(R),vi(R,At)&&(At=_s(Q._scopes,Q,R,At)),At}(g,T,u,x)),H(T)&&T.length&&(T=function(R,$,tt,Z){let{_proxy:Q,_context:ht,_subProxy:mt,_descriptors:Ct}=tt;if(ht.index!==void 0&&Z(R))return $[ht.index%$.length];if(X($[0])){let At=$,$t=Q._scopes.filter(Ht=>Ht!==At);$=[];for(let Ht of At){let Xt=_s($t,Q,R,Ht);$.push(ri(Xt,ht,mt&&mt[R],Ct))}}return $}(g,T,u,A.isIndexable)),vi(g,T)&&(T=ri(T,w,k&&k[g],A)),T}(o,a,l)),getOwnPropertyDescriptor:(o,a)=>o._descriptors.allKeys?Reflect.has(i,a)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(i,a),getPrototypeOf:()=>Reflect.getPrototypeOf(i),has:(o,a)=>Reflect.has(i,a),ownKeys:()=>Reflect.ownKeys(i),set:(o,a,l)=>(i[a]=l,delete o[a],!0)})}function ze(i,t={scriptable:!0,indexable:!0}){let{_scriptable:e=t.scriptable,_indexable:s=t.indexable,_allKeys:n=t.allKeys}=i;return{allKeys:n,scriptable:e,indexable:s,isScriptable:St(e)?e:()=>e,isIndexable:St(s)?s:()=>s}}let fi=(i,t)=>i?i+se(t):t,vi=(i,t)=>X(t)&&i!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function je(i,t,e){if(Object.prototype.hasOwnProperty.call(i,t))return i[t];let s=e();return i[t]=s,s}function $i(i,t,e){return St(i)?i(t,e):i}let is=(i,t)=>i===!0?t:typeof i=="string"?De(t,i):void 0;function ln(i,t,e,s,n){for(let o of t){let a=is(e,o);if(a){i.add(a);let l=$i(a._fallback,e,n);if(l!==void 0&&l!==e&&l!==s)return l}else if(a===!1&&s!==void 0&&e!==s)return null}return!1}function _s(i,t,e,s){let n=t._rootScopes,o=$i(t._fallback,e,s),a=[...i,...n],l=new Set;l.add(s);let u=ks(l,a,e,o||e,s);return u!==null&&(o===void 0||o===e||(u=ks(l,a,o,u,s),u!==null))&&Ke(Array.from(l),[""],n,o,()=>function(g,x,b){let w=g._getTarget();x in w||(w[x]={});let k=w[x];return H(k)&&X(b)?b:k||{}}(t,e,s))}function ks(i,t,e,s,n){for(;e;)e=ln(i,t,e,s,n);return e}function $s(i,t){for(let e of t){if(!e)continue;let s=e[i];if(s!==void 0)return s}}function Os(i){let t=i._keys;return t||(t=i._keys=function(e){let s=new Set;for(let n of e)for(let o of Object.keys(n).filter(a=>!a.startsWith("_")))s.add(o);return Array.from(s)}(i._scopes)),t}function zs(i,t,e,s){let{iScale:n}=i,{key:o="r"}=this._parsing,a=new Array(s),l,u,g,x;for(l=0,u=s;lti==="x"?"y":"x";function us(i,t,e,s){let n=i.skip?t:i,o=t,a=e.skip?t:e,l=wi(o,n),u=wi(a,o),g=l/(l+u),x=u/(l+u);g=isNaN(g)?0:g,x=isNaN(x)?0:x;let b=s*g,w=s*x;return{previous:{x:o.x-b*(a.x-n.x),y:o.y-b*(a.y-n.y)},next:{x:o.x+w*(a.x-n.x),y:o.y+w*(a.y-n.y)}}}function Ms(i,t="x"){let e=Ws(t),s=i.length,n=Array(s).fill(0),o=Array(s),a,l,u,g=Fi(i,0);for(a=0;a!g.skip)),t.cubicInterpolationMode==="monotone")Ms(i,n);else{let g=s?i[i.length-1]:i[0];for(o=0,a=i.length;oi===0||i===1,Wo=(i,t,e)=>-Math.pow(2,10*(i-=1))*Math.sin((i-t)*v/e),Bo=(i,t,e)=>Math.pow(2,-10*i)*Math.sin((i-t)*v/e)+1,Ls={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>-i*(i-2),easeInOutQuad:i=>(i/=.5)<1?.5*i*i:-.5*(--i*(i-2)-1),easeInCubic:i=>i*i*i,easeOutCubic:i=>(i-=1)*i*i+1,easeInOutCubic:i=>(i/=.5)<1?.5*i*i*i:.5*((i-=2)*i*i+2),easeInQuart:i=>i*i*i*i,easeOutQuart:i=>-((i-=1)*i*i*i-1),easeInOutQuart:i=>(i/=.5)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2),easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>(i-=1)*i*i*i*i+1,easeInOutQuint:i=>(i/=.5)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2),easeInSine:i=>1-Math.cos(i*nt),easeOutSine:i=>Math.sin(i*nt),easeInOutSine:i=>-.5*(Math.cos(y*i)-1),easeInExpo:i=>i===0?0:Math.pow(2,10*(i-1)),easeOutExpo:i=>i===1?1:1-Math.pow(2,-10*i),easeInOutExpo:i=>gs(i)?i:i<.5?.5*Math.pow(2,10*(2*i-1)):.5*(2-Math.pow(2,-10*(2*i-1))),easeInCirc:i=>i>=1?i:-(Math.sqrt(1-i*i)-1),easeOutCirc:i=>Math.sqrt(1-(i-=1)*i),easeInOutCirc:i=>(i/=.5)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1),easeInElastic:i=>gs(i)?i:Wo(i,.075,.3),easeOutElastic:i=>gs(i)?i:Bo(i,.075,.3),easeInOutElastic(i){return gs(i)?i:i<.5?.5*Wo(2*i,.1125,.45):.5+.5*Bo(2*i-1,.1125,.45)},easeInBack(i){return i*i*((1.70158+1)*i-1.70158)},easeOutBack(i){return(i-=1)*i*((1.70158+1)*i+1.70158)+1},easeInOutBack(i){let t=1.70158;return(i/=.5)<1?i*i*((1+(t*=1.525))*i-t)*.5:.5*((i-=2)*i*((1+(t*=1.525))*i+t)+2)},easeInBounce:i=>1-Ls.easeOutBounce(1-i),easeOutBounce(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},easeInOutBounce:i=>i<.5?.5*Ls.easeInBounce(2*i):.5*Ls.easeOutBounce(2*i-1)+.5};function ps(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:i.y+e*(t.y-i.y)}}function Uo(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:s==="middle"?e<.5?i.y:t.y:s==="after"?e<1?i.y:t.y:e>0?t.y:i.y}}function jo(i,t,e,s){let n={x:i.cp2x,y:i.cp2y},o={x:t.cp1x,y:t.cp1y},a=ps(i,n,e),l=ps(n,o,e),u=ps(o,t,e),g=ps(a,l,e),x=ps(l,u,e);return ps(g,x,e)}let hl=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,cl=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Vo(i,t){let e=(""+i).match(hl);if(!e||e[1]==="normal")return 1.2*t;switch(i=+e[2],e[3]){case"px":return i;case"%":i/=100}return t*i}let dl=i=>+i||0;function hn(i,t){let e={},s=X(t),n=s?Object.keys(t):t,o=X(i)?s?a=>q(i[a],i[t[a]]):a=>i[a]:()=>i;for(let a of n)e[a]=dl(o(a));return e}function eo(i){return hn(i,{top:"y",right:"x",bottom:"y",left:"x"})}function fs(i){return hn(i,["topLeft","topRight","bottomLeft","bottomRight"])}function ai(i){let t=eo(i);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function qe(i,t){i=i||{},t=t||bt.font;let e=q(i.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let s=q(i.style,t.style);s&&!(""+s).match(cl)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);let n={family:q(i.family,t.family),lineHeight:Vo(q(i.lineHeight,t.lineHeight),e),size:e,style:s,weight:q(i.weight,t.weight),string:""};return n.string=p(n),n}function Is(i,t,e,s){let n,o,a,l=!0;for(n=0,o=i.length;ne&&l===0?0:l+u;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function as(i,t){return Object.assign(Object.create(i),t)}function Ss(i,t,e){return i?function(s,n){return{x:o=>s+s+n-o,setWidth(o){n=o},textAlign:o=>o==="center"?o:o==="right"?"left":"right",xPlus:(o,a)=>o-a,leftForLtr:(o,a)=>o-a}}(t,e):{x:s=>s,setWidth(s){},textAlign:s=>s,xPlus:(s,n)=>s+n,leftForLtr:(s,n)=>s}}function io(i,t){let e,s;t!=="ltr"&&t!=="rtl"||(e=i.canvas.style,s=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),i.prevTextDirection=s)}function so(i,t){t!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",t[0],t[1]))}function qo(i){return i==="angle"?{between:N,compare:Di,normalize:ve}:{between:ot,compare:(t,e)=>t-e,normalize:t=>t}}function Xo({start:i,end:t,count:e,loop:s,style:n}){return{start:i%e,end:t%e,loop:s&&(t-i+1)%e==0,style:n}}function no(i,t,e){if(!e)return[i];let{property:s,start:n,end:o}=e,a=t.length,{compare:l,between:u,normalize:g}=qo(s),{start:x,end:b,loop:w,style:k}=function(mt,Ct,At){let{property:$t,start:Ht,end:Xt}=At,{between:Vt,normalize:Nt}=qo($t),Wt=Ct.length,Ft,ne,{start:Se,end:ye,loop:hi}=mt;if(hi){for(Se+=Wt,ye+=Wt,Ft=0,ne=Wt;Fttt||u(n,$,T)&&l(n,$)!==0,ht=()=>!tt||l(o,T)===0||u(o,$,T);for(let mt=x,Ct=x;mt<=b;++mt)R=t[mt%a],R.skip||(T=g(R[s]),T!==$&&(tt=u(T,n,o),Z===null&&Q()&&(Z=l(T,n)===0?mt:Ct),Z!==null&&ht()&&(A.push(Xo({start:Z,end:mt,loop:w,count:a,style:k})),Z=null),Ct=mt,$=T));return Z!==null&&A.push(Xo({start:Z,end:b,loop:w,count:a,style:k})),A}function oo(i,t){let e=[],s=i.segments;for(let n=0;nw&&u[k%g].skip;)k--;return k%=g,{start:w,end:k}}(e,n,o,s);return s===!0?Qo(i,[{start:a,end:l,loop:o}],e,t):Qo(i,function(u,g,x,b){let w=u.length,k=[],A,T=g,R=u[g];for(A=g+1;A<=x;++A){let $=u[A%w];$.skip||$.stop?R.skip||(b=!1,k.push({start:g%w,end:(A-1)%w,loop:b}),g=T=$.stop?A:null):(T=A,R.skip&&(g=A)),R=$}return T!==null&&k.push({start:g%w,end:T%w,loop:b}),k}(e,a,l{u[a](t[e],n)&&(o.push({element:u,datasetIndex:g,index:x}),l=l||u.inRange(t.x,t.y,n))}),s&&!l?[]:o}var Jo={evaluateInteractionItems:Bs,modes:{index(i,t,e,s){let n=me(t,i),o=e.axis||"x",a=e.includeInvisible||!1,l=e.intersect?ro(i,n,o,s,a):ao(i,n,o,!1,s,a),u=[];return l.length?(i.getSortedVisibleDatasetMetas().forEach(g=>{let x=l[0].index,b=g.data[x];b&&!b.skip&&u.push({element:b,datasetIndex:g.index,index:x})}),u):[]},dataset(i,t,e,s){let n=me(t,i),o=e.axis||"xy",a=e.includeInvisible||!1,l=e.intersect?ro(i,n,o,s,a):ao(i,n,o,!1,s,a);if(l.length>0){let u=l[0].datasetIndex,g=i.getDatasetMeta(u).data;l=[];for(let x=0;xro(i,me(t,i),e.axis||"xy",s,e.includeInvisible||!1),nearest(i,t,e,s){let n=me(t,i),o=e.axis||"xy",a=e.includeInvisible||!1;return ao(i,n,o,e.intersect,s,a)},x:(i,t,e,s)=>Zo(i,me(t,i),"x",e.intersect,s),y:(i,t,e,s)=>Zo(i,me(t,i),"y",e.intersect,s)}};let tr=["left","top","right","bottom"];function Us(i,t){return i.filter(e=>e.pos===t)}function er(i,t){return i.filter(e=>tr.indexOf(e.pos)===-1&&e.box.axis===t)}function js(i,t){return i.sort((e,s)=>{let n=t?s:e,o=t?e:s;return n.weight===o.weight?n.index-o.index:n.weight-o.weight})}function ml(i,t){let e=function(u){let g={};for(let x of u){let{stack:b,pos:w,stackWeight:k}=x;if(!b||!tr.includes(w))continue;let A=g[b]||(g[b]={count:0,placed:0,weight:0,size:0});A.count++,A.weight+=k}return g}(i),{vBoxMaxWidth:s,hBoxMaxHeight:n}=t,o,a,l;for(o=0,a=i.length;o{o[a]=Math.max(t[a],e[a])}),o}return s(i?["left","right"]:["top","bottom"])}function Vs(i,t,e,s){let n=[],o,a,l,u,g,x;for(o=0,a=i.length,g=0;oAt.box.fullSize),!0),tt=js(Us(R,"left"),!0),Z=js(Us(R,"right")),Q=js(Us(R,"top"),!0),ht=js(Us(R,"bottom")),mt=er(R,"x"),Ct=er(R,"y");return{fullSize:$,leftAndTop:tt.concat(Q),rightAndBottom:Z.concat(Ct).concat(ht).concat(mt),chartArea:Us(R,"chartArea"),vertical:tt.concat(Z).concat(Ct),horizontal:Q.concat(ht).concat(mt)}}(i.boxes),u=l.vertical,g=l.horizontal;xt(i.boxes,T=>{typeof T.beforeLayout=="function"&&T.beforeLayout()});let x=u.reduce((T,R)=>R.box.options&&R.box.options.display===!1?T:T+1,0)||1,b=Object.freeze({outerWidth:t,outerHeight:e,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/x,hBoxMaxHeight:a/2}),w=Object.assign({},n);sr(w,ai(s));let k=Object.assign({maxPadding:w,w:o,h:a,x:n.left,y:n.top},n),A=ml(u.concat(g),b);Vs(l.fullSize,k,b,A),Vs(u,k,b,A),Vs(g,k,b,A)&&Vs(u,k,b,A),function(T){let R=T.maxPadding;function $(tt){let Z=Math.max(R[tt]-T[tt],0);return T[tt]+=Z,Z}T.y+=$("top"),T.x+=$("left"),$("right"),$("bottom")}(k),nr(l.leftAndTop,k,b,A),k.x+=k.w,k.y+=k.h,nr(l.rightAndBottom,k,b,A),i.chartArea={left:k.left,top:k.top,right:k.left+k.w,bottom:k.top+k.h,height:k.h,width:k.w},xt(l.chartArea,T=>{let R=T.box;Object.assign(R,i.chartArea),R.update(k.w,k.h,{left:0,top:0,right:0,bottom:0})})}};class lo{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,s){}removeEventListener(t,e,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,s,n){return e=Math.max(0,e||t.width),s=s||t.height,{width:e,height:Math.max(0,n?Math.floor(e/n):s)}}isAttached(t){return!0}updateConfig(t){}}class or extends lo{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}let dn="$chartjs",xl={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},rr=i=>i===null||i==="",ar=!!B&&{passive:!0};function vl(i,t,e){i.canvas.removeEventListener(t,e,ar)}function un(i,t){for(let e of i)if(e===t||e.contains(t))return!0}function wl(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let l of o)a=a||un(l.addedNodes,s),a=a&&!un(l.removedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}function _l(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let l of o)a=a||un(l.removedNodes,s),a=a&&!un(l.addedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}let Ys=new Map,lr=0;function hr(){let i=window.devicePixelRatio;i!==lr&&(lr=i,Ys.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function kl(i,t,e){let s=i.canvas,n=s&&Yt(s);if(!n)return;let o=Ce((l,u)=>{let g=n.clientWidth;e(l,u),g{let u=l[0],g=u.contentRect.width,x=u.contentRect.height;g===0&&x===0||o(g,x)});return a.observe(n),function(l,u){Ys.size||window.addEventListener("resize",hr),Ys.set(l,u)}(i,o),a}function ho(i,t,e){e&&e.disconnect(),t==="resize"&&function(s){Ys.delete(s),Ys.size||window.removeEventListener("resize",hr)}(i)}function Ml(i,t,e){let s=i.canvas,n=Ce(o=>{i.ctx!==null&&e(function(a,l){let u=xl[a.type]||a.type,{x:g,y:x}=me(a,l);return{type:u,chart:l,native:a,x:g!==void 0?g:null,y:x!==void 0?x:null}}(o,i))},i);return function(o,a,l){o.addEventListener(a,l,ar)}(s,t,n),n}class cr extends lo{acquireContext(t,e){let s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?(function(n,o){let a=n.style,l=n.getAttribute("height"),u=n.getAttribute("width");if(n[dn]={initial:{height:l,width:u,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",a.boxSizing=a.boxSizing||"border-box",rr(u)){let g=c(n,"width");g!==void 0&&(n.width=g)}if(rr(l))if(n.style.height==="")n.height=n.width/(o||2);else{let g=c(n,"height");g!==void 0&&(n.height=g)}}(t,e),s):null}releaseContext(t){let e=t.canvas;if(!e[dn])return!1;let s=e[dn].initial;["height","width"].forEach(o=>{let a=s[o];C(a)?e.removeAttribute(o):e.setAttribute(o,a)});let n=s.style||{};return Object.keys(n).forEach(o=>{e.style[o]=n[o]}),e.width=e.width,delete e[dn],!0}addEventListener(t,e,s){this.removeEventListener(t,e);let n=t.$proxies||(t.$proxies={}),o={attach:wl,detach:_l,resize:kl}[e]||Ml;n[e]=o(t,e,s)}removeEventListener(t,e){let s=t.$proxies||(t.$proxies={}),n=s[e];n&&(({attach:ho,detach:ho,resize:ho}[e]||vl)(t,e,n),s[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,s,n){return S(t,e,s,n)}isAttached(t){let e=Yt(t);return!(!e||!e.isConnected)}}function dr(i){return!Dt()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?or:cr}var ur=Object.freeze({__proto__:null,BasePlatform:lo,BasicPlatform:or,DomPlatform:cr,_detectPlatform:dr});let gr="transparent",Sl={boolean:(i,t,e)=>e>.5?t:i,color(i,t,e){let s=I(i||gr),n=s.valid&&I(t||gr);return n&&n.valid?n.mix(s,e).hexString():t},number:(i,t,e)=>i+(t-i)*e};class pr{constructor(t,e,s,n){let o=e[s];n=Is([t.to,n,o,t.from]);let a=Is([t.from,o,n]);this._active=!0,this._fn=t.fn||Sl[t.type||typeof a],this._easing=Ls[t.easing]||Ls.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=s,this._from=a,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,s){if(this._active){this._notify(!1);let n=this._target[this._prop],o=s-this._start,a=this._duration-o;this._start=s,this._duration=Math.floor(Math.max(a,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Is([t.to,e,n,t.from]),this._from=Is([t.from,n,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let e=t-this._start,s=this._duration,n=this._prop,o=this._from,a=this._loop,l=this._to,u;if(this._active=o!==l&&(a||e1?2-u:u,u=this._easing(Math.min(1,Math.max(0,u))),this._target[n]=this._fn(o,l,u))}wait(){let t=this._promises||(this._promises=[]);return new Promise((e,s)=>{t.push({res:e,rej:s})})}_notify(t){let e=t?"res":"rej",s=this._promises||[];for(let n=0;n{let o=t[n];if(!X(o))return;let a={};for(let l of e)a[l]=o[l];(H(o.properties)&&o.properties||[n]).forEach(l=>{l!==n&&s.has(l)||s.set(l,a)})})}_animateOptions(t,e){let s=e.options,n=function(a,l){if(!l)return;let u=a.options;return u?(u.$shared&&(a.options=u=Object.assign({},u,{$shared:!1,$animations:{}})),u):void(a.options=l)}(t,s);if(!n)return[];let o=this._createAnimations(n,s);return s.$shared&&function(a,l){let u=[],g=Object.keys(l);for(let x=0;x{t.options=s},()=>{}),o}_createAnimations(t,e){let s=this._properties,n=[],o=t.$animations||(t.$animations={}),a=Object.keys(e),l=Date.now(),u;for(u=a.length-1;u>=0;--u){let g=a[u];if(g.charAt(0)==="$")continue;if(g==="options"){n.push(...this._animateOptions(t,e));continue}let x=e[g],b=o[g],w=s.get(g);if(b){if(w&&b.active()){b.update(w,x,l);continue}b.cancel()}w&&w.duration?(o[g]=b=new pr(w,t,g,x),n.push(b)):t[g]=x}return n}update(t,e){if(this._properties.size===0)return void Object.assign(t,e);let s=this._createAnimations(t,e);return s.length?(Be.add(this._chart,s),!0):void 0}}function fr(i,t){let e=i&&i.options||{},s=e.reverse,n=e.min===void 0?t:0,o=e.max===void 0?t:0;return{start:s?o:n,end:s?n:o}}function mr(i,t){let e=[],s=i._getSortedDatasetMetas(t),n,o;for(n=0,o=s.length;n0||!e&&o<0)return n.index}return null}function vr(i,t){let{chart:e,_cachedMeta:s}=i,n=e._stacks||(e._stacks={}),{iScale:o,vScale:a,index:l}=s,u=o.axis,g=a.axis,x=function(k,A,T){return`${k.id}.${A.id}.${T.stack||T.type}`}(o,a,s),b=t.length,w;for(let k=0;ke[s].axis===t).shift()}function qs(i,t){let e=i.controller.index,s=i.vScale&&i.vScale.axis;if(s){t=t||i._parsed;for(let n of t){let o=n._stacks;if(!o||o[s]===void 0||o[s][e]===void 0)return;delete o[s][e],o[s]._visualValues!==void 0&&o[s]._visualValues[e]!==void 0&&delete o[s]._visualValues[e]}}}let go=i=>i==="reset"||i==="none",wr=(i,t)=>t?i:Object.assign({},i);class ls{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=yr(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&qs(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,s=this.getDataset(),n=(b,w,k,A)=>b==="x"?w:b==="r"?A:k,o=e.xAxisID=q(s.xAxisID,uo(t,"x")),a=e.yAxisID=q(s.yAxisID,uo(t,"y")),l=e.rAxisID=q(s.rAxisID,uo(t,"r")),u=e.indexAxis,g=e.iAxisID=n(u,o,a,l),x=e.vAxisID=n(u,a,o,l);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(a),e.rScale=this.getScaleForId(l),e.iScale=this.getScaleForId(g),e.vScale=this.getScaleForId(x)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){let e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){let t=this._cachedMeta;this._data&&zt(this._data,this),t._stacked&&qs(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),s=this._data;if(X(e))this._data=function(n){let o=Object.keys(n),a=new Array(o.length),l,u,g;for(l=0,u=o.length;l0&&s._parsed[t-1];if(this._parsing===!1)s._parsed=n,s._sorted=!0,x=n;else{x=H(n[t])?this.parseArrayData(s,n,t,e):X(n[t])?this.parseObjectData(s,n,t,e):this.parsePrimitiveData(s,n,t,e);let k=()=>g[l]===null||w&&g[l]T&&!R.hidden&&R._stacked&&{keys:mr($,!0),values:null})(e,s,this.chart),g={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:x,max:b}=function(T){let{min:R,max:$,minDefined:tt,maxDefined:Z}=T.getUserBounds();return{min:tt?R:Number.NEGATIVE_INFINITY,max:Z?$:Number.POSITIVE_INFINITY}}(l),w,k;function A(){k=n[w];let T=k[l.axis];return!W(k[t.axis])||x>T||b=0;--w)if(!A()){this.updateRangeFromParsed(g,t,k,u);break}}return g}getAllParsedValues(t){let e=this._cachedMeta._parsed,s=[],n,o,a;for(n=0,o=e.length;n=0&&tthis.getContext(s,n,e),b);return A.$shared&&(A.$shared=u,o[a]=Object.freeze(wr(A,u))),A}_resolveAnimations(t,e,s){let n=this.chart,o=this._cachedDataOpts,a=`animation-${e}`,l=o[a];if(l)return l;let u;if(n.options.animation!==!1){let x=this.chart.config,b=x.datasetAnimationScopeKeys(this._type,e),w=x.getOptionScopes(this.getDataset(),b);u=x.createResolver(w,this.getContext(t,s,e))}let g=new co(n,u&&u.animations);return u&&u._cacheable&&(o[a]=Object.freeze(g)),g}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||go(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){let s=this.resolveDataElementOptions(t,e),n=this._sharedOptions,o=this.getSharedOptions(s),a=this.includeOptions(e,o)||o!==n;return this.updateSharedOptions(o,e,s),{sharedOptions:o,includeOptions:a}}updateElement(t,e,s,n){go(n)?Object.assign(t,s):this._resolveAnimations(e,n).update(t,s)}updateSharedOptions(t,e,s){t&&!go(e)&&this._resolveAnimations(void 0,e).update(t,s)}_setStyle(t,e,s,n){t.active=n;let o=this.getStyle(e,n);this._resolveAnimations(e,s,n).update(t,{options:!n&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,e,s){this._setStyle(t,s,"active",!0)}_removeDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){let e=this._data,s=this._cachedMeta.data;for(let[l,u,g]of this._syncList)this[l](u,g);this._syncList=[];let n=s.length,o=e.length,a=Math.min(o,n);a&&this.parse(0,a),o>n?this._insertElements(n,o-n,t):o{for(g.length+=e,l=g.length-1;l>=a;l--)g[l]=g[l-e]};for(u(o),l=t;l{n[o]=s[o]&&s[o].active()?s[o]._to:this[o]}),n}}function Tl(i,t){let e=i.options.ticks,s=function(b){let w=b.options.offset,k=b._tickSize(),A=b._length/k+(w?0:1),T=b._maxLength/k;return Math.floor(Math.min(A,T))}(i),n=Math.min(e.maxTicksLimit||s,s),o=e.major.enabled?function(b){let w=[],k,A;for(k=0,A=b.length;kn)return function(b,w,k,A){let T,R=0,$=k[0];for(A=Math.ceil(A),T=0;TT)return Z}return Math.max(T,1)}(o,t,n);if(a>0){let b,w,k=a>1?Math.round((u-l)/(a-1)):null;for(gn(t,g,x,C(k)?0:l-k,l),b=0,w=a-1;bt==="top"||t==="left"?i[t]+e:i[t]-e,kr=(i,t)=>Math.min(t||i,i);function Mr(i,t){let e=[],s=i.length/t,n=i.length,o=0;for(;oa+l)))return g}function Xs(i){return i.drawTicks?i.tickLength:0}function Sr(i,t){if(!i.display)return 0;let e=qe(i.font,t),s=ai(i.padding);return(H(i.text)?i.text.length:1)*e.lineHeight+s.height}function Dl(i,t,e){let s=xe(i);return(e&&t!=="right"||!e&&t==="right")&&(s=(n=>n==="left"?"right":n==="right"?"left":n)(s)),s}class ms extends ss{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:s,_suggestedMax:n}=this;return t=at(t,Number.POSITIVE_INFINITY),e=at(e,Number.NEGATIVE_INFINITY),s=at(s,Number.POSITIVE_INFINITY),n=at(n,Number.NEGATIVE_INFINITY),{min:at(t,s),max:at(e,n),minDefined:W(t),maxDefined:W(e)}}getMinMax(t){let e,{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();if(o&&a)return{min:s,max:n};let l=this.getMatchingVisibleMetas();for(let u=0,g=l.length;un?n:s,n=o&&s>n?s:n,{min:at(s,at(n,s)),max:at(n,at(s,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){ft(this.options.beforeUpdate,[this])}update(t,e,s){let{beginAtZero:n,grace:o,ticks:a}=this.options,l=a.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Yo(this,o,n),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let u=l=o||s<=1||!this.isHorizontal())return void(this.labelRotation=n);let x=this._getLabelSizes(),b=x.widest.width,w=x.highest.height,k=J(this.chart.width-b,0,this.maxWidth);a=t.offset?this.maxWidth/s:k/(s-1),b+6>a&&(a=k/(s-(t.offset?.5:1)),l=this.maxHeight-Xs(t.grid)-e.padding-Sr(t.title,this.chart.options.font),u=Math.sqrt(b*b+w*w),g=ti(Math.min(Math.asin(J((x.highest.height+6)/a,-1,1)),Math.asin(J(l/u,-1,1))-Math.asin(J(w/u,-1,1)))),g=Math.max(n,Math.min(o,g))),this.labelRotation=g}afterCalculateLabelRotation(){ft(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){ft(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:e,options:{ticks:s,title:n,grid:o}}=this,a=this._isVisible(),l=this.isHorizontal();if(a){let u=Sr(n,e.options.font);if(l?(t.width=this.maxWidth,t.height=Xs(o)+u):(t.height=this.maxHeight,t.width=Xs(o)+u),s.display&&this.ticks.length){let{first:g,last:x,widest:b,highest:w}=this._getLabelSizes(),k=2*s.padding,A=He(this.labelRotation),T=Math.cos(A),R=Math.sin(A);if(l){let $=s.mirror?0:R*b.width+T*w.height;t.height=Math.min(this.maxHeight,t.height+$+k)}else{let $=s.mirror?0:T*b.width+R*w.height;t.width=Math.min(this.maxWidth,t.width+$+k)}this._calculatePadding(g,x,R,T)}}this._handleMargins(),l?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,s,n){let{ticks:{align:o,padding:a},position:l}=this.options,u=this.labelRotation!==0,g=l!=="top"&&this.axis==="x";if(this.isHorizontal()){let x=this.getPixelForTick(0)-this.left,b=this.right-this.getPixelForTick(this.ticks.length-1),w=0,k=0;u?g?(w=n*t.width,k=s*e.height):(w=s*t.height,k=n*e.width):o==="start"?k=e.width:o==="end"?w=t.width:o!=="inner"&&(w=t.width/2,k=e.width/2),this.paddingLeft=Math.max((w-x+a)*this.width/(this.width-x),0),this.paddingRight=Math.max((k-b+a)*this.width/(this.width-b),0)}else{let x=e.height/2,b=t.height/2;o==="start"?(x=0,b=t.height):o==="end"&&(x=e.height,b=0),this.paddingTop=x+a,this.paddingBottom=b+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){ft(this.options.afterFit,[this])}isHorizontal(){let{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,s;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,s=t.length;e{let Vt=Xt.gc,Nt=Vt.length/2,Wt;if(Nt>Ht){for(Wt=0;Wt({width:a[$t]||0,height:l[$t]||0});return{first:At(0),last:At(e-1),widest:At(mt),highest:At(Ct),widths:a,heights:l}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);let e=this._startPixel+t*this._length;return et(this._alignToPixels?L(this.chart,e,0):e)}getDecimalForPixel(t){let e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){let e=this.ticks||[];if(t>=0&&tl*n?l/s:u/n:u*n0}_computeGridLineItems(t){let e=this.axis,s=this.chart,n=this.options,{grid:o,position:a,border:l}=n,u=o.offset,g=this.isHorizontal(),x=this.ticks.length+(u?1:0),b=Xs(o),w=[],k=l.setContext(this.getContext()),A=k.display?k.width:0,T=A/2,R=function(Ft){return L(s,Ft,A)},$,tt,Z,Q,ht,mt,Ct,At,$t,Ht,Xt,Vt;if(a==="top")$=R(this.bottom),mt=this.bottom-b,At=$-T,Ht=R(t.top)+T,Vt=t.bottom;else if(a==="bottom")$=R(this.top),Ht=t.top,Vt=R(t.bottom)-T,mt=$+T,At=this.top+b;else if(a==="left")$=R(this.right),ht=this.right-b,Ct=$-T,$t=R(t.left)+T,Xt=t.right;else if(a==="right")$=R(this.left),$t=t.left,Xt=R(t.right)-T,ht=$+T,Ct=this.left+b;else if(e==="x"){if(a==="center")$=R((t.top+t.bottom)/2+.5);else if(X(a)){let Ft=Object.keys(a)[0],ne=a[Ft];$=R(this.chart.scales[Ft].getPixelForValue(ne))}Ht=t.top,Vt=t.bottom,mt=$+T,At=mt+b}else if(e==="y"){if(a==="center")$=R((t.left+t.right)/2);else if(X(a)){let Ft=Object.keys(a)[0],ne=a[Ft];$=R(this.chart.scales[Ft].getPixelForValue(ne))}ht=$-T,Ct=ht-b,$t=t.left,Xt=t.right}let Nt=q(n.ticks.maxTicksLimit,x),Wt=Math.max(1,Math.ceil(x/Nt));for(tt=0;tt0&&(Qi-=Xi/2)}zi={left:Qi,top:Gi,width:Xi+Wi.width,height:qi+Wi.height,color:Ft.backdropColor}}R.push({label:Q,font:$t,textOffset:Vt,options:{rotation:T,color:Se,strokeColor:ye,strokeWidth:hi,textAlign:Li,textBaseline:Nt,translation:[ht,mt],backdrop:zi}})}return R}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-He(this.labelRotation))return t==="top"?"left":"right";let s="center";return e.align==="start"?s="left":e.align==="end"?s="right":e.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){let{position:e,ticks:{crossAlign:s,mirror:n,padding:o}}=this.options,a=t+o,l=this._getLabelSizes().widest.width,u,g;return e==="left"?n?(g=this.right+o,s==="near"?u="left":s==="center"?(u="center",g+=l/2):(u="right",g+=l)):(g=this.right-a,s==="near"?u="right":s==="center"?(u="center",g-=l/2):(u="left",g=this.left)):e==="right"?n?(g=this.left+o,s==="near"?u="right":s==="center"?(u="center",g-=l/2):(u="left",g-=l)):(g=this.left+a,s==="near"?u="left":s==="center"?(u="center",g+=l/2):(u="right",g=this.right)):u="right",{textAlign:u,x:g}}_computeLabelArea(){if(this.options.ticks.mirror)return;let t=this.chart,e=this.options.position;return e==="left"||e==="right"?{top:0,left:this.left,bottom:t.height,right:this.right}:e==="top"||e==="bottom"?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){let{ctx:t,options:{backgroundColor:e},left:s,top:n,width:o,height:a}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(s,n,o,a),t.restore())}getLineWidthForValue(t){let e=this.options.grid;if(!this._isVisible()||!e.display)return 0;let s=this.ticks.findIndex(n=>n.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){let e=this.options.grid,s=this.ctx,n=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,a,l=(u,g,x)=>{x.width&&x.color&&(s.save(),s.lineWidth=x.width,s.strokeStyle=x.color,s.setLineDash(x.borderDash||[]),s.lineDashOffset=x.borderDashOffset,s.beginPath(),s.moveTo(u.x,u.y),s.lineTo(g.x,g.y),s.stroke(),s.restore())};if(e.display)for(o=0,a=n.length;o{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:n,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]:[{z:e,draw:o=>{this.draw(o)}}]}getMatchingVisibleMetas(t){let e=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",n=[],o,a;for(o=0,a=e.length;o{let A=k.split("."),T=A.pop(),R=[b].concat(A).join("."),$=w[k].split("."),tt=$.pop(),Z=$.join(".");bt.route(R,T,Z,tt)})}(u,l.defaultRoutes),l.descriptors&&bt.describe(u,l.descriptors)}(t,a,s),this.override&&bt.override(t.id,t.overrides)),a}get(t){return this.items[t]}unregister(t){let e=this.items,s=t.id,n=this.scope;s in e&&delete e[s],n&&s in bt[n]&&(delete bt[n][s],this.override&&delete lt[s])}}class Pl{constructor(){this.controllers=new pn(ls,"datasets",!0),this.elements=new pn(ss,"elements"),this.plugins=new pn(Object,"plugins"),this.scales=new pn(ms,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,s){[...e].forEach(n=>{let o=s||this._getRegistryForType(n);s||o.isForType(n)||o===this.plugins&&n.id?this._exec(t,o,n):xt(n,a=>{let l=s||this._getRegistryForType(a);this._exec(t,l,a)})})}_exec(t,e,s){let n=se(t);ft(s["before"+n],[],s),e[t](s),ft(s["after"+n],[],s)}_getRegistryForType(t){for(let e=0;eo.filter(l=>!a.some(u=>l.plugin.id===u.plugin.id));this._notify(n(e,s),t,"stop"),this._notify(n(s,e),t,"start")}}function Rl(i,t){return t||i!==!1?i===!0?{}:i:null}function Ol(i,{plugin:t,local:e},s,n){let o=i.pluginScopeKeys(t),a=i.getOptionScopes(s,o);return e&&t.defaults&&a.push(t.defaults),i.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function po(i,t){let e=bt.datasets[i]||{};return((t.datasets||{})[i]||{}).indexAxis||t.indexAxis||e.indexAxis||"x"}function Cr(i){if(i==="x"||i==="y"||i==="r")return i}function fo(i,...t){if(Cr(i))return i;for(let s of t){let n=s.axis||((e=s.position)==="top"||e==="bottom"?"x":e==="left"||e==="right"?"y":void 0)||i.length>1&&Cr(i[0].toLowerCase());if(n)return n}var e;throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function Tr(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function zl(i,t){let e=lt[i.type]||{scales:{}},s=t.scales||{},n=po(i.type,t),o=Object.create(null);return Object.keys(s).forEach(a=>{let l=s[a];if(!X(l))return console.error(`Invalid scale configuration for scale: ${a}`);if(l._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${a}`);let u=fo(a,l,function(b,w){if(w.data&&w.data.datasets){let k=w.data.datasets.filter(A=>A.xAxisID===b||A.yAxisID===b);if(k.length)return Tr(b,"x",k[0])||Tr(b,"y",k[0])}return{}}(a,i),bt.scales[l.type]),g=function(b,w){return b===w?"_index_":"_value_"}(u,n),x=e.scales||{};o[a]=_e(Object.create(null),[{axis:u},l,x[u],x[g]])}),i.data.datasets.forEach(a=>{let l=a.type||i.type,u=a.indexAxis||po(l,t),g=(lt[l]||{}).scales||{};Object.keys(g).forEach(x=>{let b=function(k,A){let T=k;return k==="_index_"?T=A:k==="_value_"&&(T=A==="x"?"y":"x"),T}(x,u),w=a[b+"AxisID"]||b;o[w]=o[w]||Object.create(null),_e(o[w],[{axis:b},s[w],g[x]])})}),Object.keys(o).forEach(a=>{let l=o[a];_e(l,[bt.scales[l.type],bt.scale])}),o}function Er(i){let t=i.options||(i.options={});t.plugins=q(t.plugins,{}),t.scales=zl(i,t)}function Dr(i){return(i=i||{}).datasets=i.datasets||[],i.labels=i.labels||[],i}let Pr=new Map,Ar=new Set;function fn(i,t){let e=Pr.get(i);return e||(e=t(),Pr.set(i,e),Ar.add(e)),e}let Gs=(i,t,e)=>{let s=De(t,e);s!==void 0&&i.add(s)};class Ll{constructor(t){this._config=function(e){return(e=e||{}).data=Dr(e.data),Er(e),e}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Dr(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){let t=this._config;this.clearCache(),Er(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return fn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return fn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return fn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id;return fn(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){let s=this._scopeCache,n=s.get(t);return n&&!e||(n=new Map,s.set(t,n)),n}getOptionScopes(t,e,s){let{options:n,type:o}=this,a=this._cachedScopes(t,s),l=a.get(e);if(l)return l;let u=new Set;e.forEach(x=>{t&&(u.add(t),x.forEach(b=>Gs(u,t,b))),x.forEach(b=>Gs(u,n,b)),x.forEach(b=>Gs(u,lt[o]||{},b)),x.forEach(b=>Gs(u,bt,b)),x.forEach(b=>Gs(u,vt,b))});let g=Array.from(u);return g.length===0&&g.push(Object.create(null)),Ar.has(e)&&a.set(e,g),g}chartOptionScopes(){let{options:t,type:e}=this;return[t,lt[e]||{},bt.datasets[e]||{},{type:e},bt,vt]}resolveNamedOptions(t,e,s,n=[""]){let o={$shared:!0},{resolver:a,subPrefixes:l}=Rr(this._resolverCache,t,n),u=a;(function(g,x){let{isScriptable:b,isIndexable:w}=ze(g);for(let k of x){let A=b(k),T=w(k),R=(T||A)&&g[k];if(A&&(St(R)||Il(R))||T&&H(R))return!0}return!1})(a,e)&&(o.$shared=!1,u=ri(a,s=St(s)?s():s,this.createResolver(t,s,l)));for(let g of e)o[g]=u[g];return o}createResolver(t,e,s=[""],n){let{resolver:o}=Rr(this._resolverCache,t,s);return X(e)?ri(o,e,void 0,n):o}}function Rr(i,t,e){let s=i.get(t);s||(s=new Map,i.set(t,s));let n=e.join(),o=s.get(n);return o||(o={resolver:Ke(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},s.set(n,o)),o}let Il=i=>X(i)&&Object.getOwnPropertyNames(i).some(t=>St(i[t])),Hl=["top","bottom","left","right","chartArea"];function Or(i,t){return i==="top"||i==="bottom"||Hl.indexOf(i)===-1&&t==="x"}function zr(i,t){return function(e,s){return e[i]===s[i]?e[t]-s[t]:e[i]-s[i]}}function Lr(i){let t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),ft(e&&e.onComplete,[i],t)}function Nl(i){let t=i.chart,e=t.options.animation;ft(e&&e.onProgress,[i],t)}function Ir(i){return Dt()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}let mn={},Hr=i=>{let t=Ir(i);return Object.values(mn).filter(e=>e.canvas===t).pop()};function $l(i,t,e){let s=Object.keys(i);for(let n of s){let o=+n;if(o>=t){let a=i[n];delete i[n],(e>0||o>t)&&(i[o+e]=a)}}}function bn(i,t,e){return i.options.clip?i[e]:t[e]}class Ve{static defaults=bt;static instances=mn;static overrides=lt;static registry=Yi;static version="4.4.1";static getChart=Hr;static register(...t){Yi.add(...t),Nr()}static unregister(...t){Yi.remove(...t),Nr()}constructor(t,e){let s=this.config=new Ll(e),n=Ir(t),o=Hr(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");let a=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||dr(n)),this.platform.updateConfig(s);let l=this.platform.acquireContext(n,a.aspectRatio),u=l&&l.canvas,g=u&&u.height,x=u&&u.width;this.id=f(),this.ctx=l,this.canvas=u,this.width=x,this.height=g,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Al,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=fe(b=>this.update(b),a.resizeDelay||0),this._dataChanges=[],mn[this.id]=this,l&&u?(Be.listen(this,"complete",Lr),Be.listen(this,"progress",Nl),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:e},width:s,height:n,_aspectRatio:o}=this;return C(t)?e&&o?o:n?s/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Yi}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():O(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return K(this.canvas,this.ctx),this}stop(){return Be.stop(this),this}resize(t,e){Be.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){let s=this.options,n=this.canvas,o=s.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(n,t,e,o),l=s.devicePixelRatio||this.platform.getDevicePixelRatio(),u=this.width?"resize":"attach";this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,O(this,l,!0)&&(this.notifyPlugins("resize",{size:a}),ft(s.onResize,[this,a],this),this.attached&&this._doResize(u)&&this.render())}ensureScalesHaveIDs(){xt(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){let t=this.options,e=t.scales,s=this.scales,n=Object.keys(s).reduce((a,l)=>(a[l]=!1,a),{}),o=[];e&&(o=o.concat(Object.keys(e).map(a=>{let l=e[a],u=fo(a,l),g=u==="r",x=u==="x";return{options:l,dposition:g?"chartArea":x?"bottom":"left",dtype:g?"radialLinear":x?"category":"linear"}}))),xt(o,a=>{let l=a.options,u=l.id,g=fo(u,l),x=q(l.type,a.dtype);l.position!==void 0&&Or(l.position,g)===Or(a.dposition)||(l.position=a.dposition),n[u]=!0;let b=null;u in s&&s[u].type===x?b=s[u]:(b=new(Yi.getScale(x))({id:u,type:x,ctx:this.ctx,chart:this}),s[b.id]=b),b.init(l,t)}),xt(n,(a,l)=>{a||delete s[l]}),xt(s,a=>{li.configure(this,a,a.options),li.addBox(this,a)})}_updateMetasets(){let t=this._metasets,e=this.data.datasets.length,s=t.length;if(t.sort((n,o)=>n.index-o.index),s>e){for(let n=e;ne.length&&delete this._stacks,t.forEach((s,n)=>{e.filter(o=>o===s._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let t=[],e=this.data.datasets,s,n;for(this._removeUnreferencedMetasets(),s=0,n=e.length;s{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let e=this.config;e.update();let s=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),n=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;let o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let a=0;for(let g=0,x=this.data.datasets.length;g{g.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(zr("z","_idx"));let{_active:l,_lastEvent:u}=this;u?this._eventHandler(u,!0):l.length&&this._updateHoverStyles(l,l,!0),this.render()}_updateScales(){xt(this.scales,t=>{li.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,e=new Set(Object.keys(this._listeners)),s=new Set(t.events);r(e,s)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(let{method:s,start:n,count:o}of e)$l(t,n,s==="_removeElements"?-o:o)}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let e=this.data.datasets.length,s=o=>new Set(t.filter(a=>a[0]===o).map((a,l)=>l+","+a.splice(1).join(","))),n=s(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;li.update(this,this.width,this.height,t);let e=this.chartArea,s=e.width<=0||e.height<=0;this._layers=[],xt(this.boxes,n=>{s&&n.position==="chartArea"||(n.configure&&n.configure(),this._layers.push(...n._layers()))},this),this._layers.forEach((n,o)=>{n._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,s=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let e=this.ctx,s=t._clip,n=!s.disabled,o=function(l,u){let{xScale:g,yScale:x}=l;return g&&x?{left:bn(g,u,"left"),right:bn(g,u,"right"),top:bn(x,u,"top"),bottom:bn(x,u,"bottom")}:u}(t,this.chartArea),a={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",a)!==!1&&(n&&qt(e,{left:s.left===!1?0:o.left-s.left,right:s.right===!1?this.width:o.right+s.right,top:s.top===!1?0:o.top-s.top,bottom:s.bottom===!1?this.height:o.bottom+s.bottom}),t.controller.draw(),n&&Gt(e),a.cancelable=!1,this.notifyPlugins("afterDatasetDraw",a))}isPointInArea(t){return Mt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,s,n){let o=Jo.modes[e];return typeof o=="function"?o(this,t,s,n):[]}getDatasetMeta(t){let e=this.data.datasets[t],s=this._metasets,n=s.filter(o=>o&&o._dataset===e).pop();return n||(n={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},s.push(n)),n}getContext(){return this.$context||(this.$context=as(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let e=this.data.datasets[t];if(!e)return!1;let s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,s){let n=s?"show":"hide",o=this.getDatasetMeta(t),a=o.controller._resolveAnimations(void 0,n);Bt(e)?(o.data[e].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),a.update(o,{visible:s}),this.update(l=>l.datasetIndex===t?n:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){let e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),Be.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,a),t[o]=a},n=(o,a,l)=>{o.offsetX=a,o.offsetY=l,this._eventHandler(o)};xt(this.options.events,o=>s(o,n))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,s=(u,g)=>{e.addEventListener(this,u,g),t[u]=g},n=(u,g)=>{t[u]&&(e.removeEventListener(this,u,g),delete t[u])},o=(u,g)=>{this.canvas&&this.resize(u,g)},a,l=()=>{n("attach",l),this.attached=!0,this.resize(),s("resize",o),s("detach",a)};a=()=>{this.attached=!1,n("resize",o),this._stop(),this._resize(0,0),s("attach",l)},e.isAttached(this.canvas)?l():a()}unbindEvents(){xt(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},xt(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,s){let n=s?"set":"remove",o,a,l,u;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),l=0,u=t.length;l{let a=this.getDatasetMeta(n);if(!a)throw new Error("No dataset found at index "+n);return{datasetIndex:n,element:a.data[o],index:o}});!jt(s,e)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,e))}notifyPlugins(t,e,s){return this._plugins.notify(this,t,e,s)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,s){let n=this.options.hover,o=(u,g)=>u.filter(x=>!g.some(b=>x.datasetIndex===b.datasetIndex&&x.index===b.index)),a=o(e,t),l=s?t:o(t,e);a.length&&this.updateHoverStyle(a,n.mode,!1),l.length&&n.mode&&this.updateHoverStyle(l,n.mode,!0)}_eventHandler(t,e){let s={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},n=a=>(a.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,n)===!1)return;let o=this._handleEvent(t,e,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,n),(o||s.changed)&&this.render(),this}_handleEvent(t,e,s){let{_active:n=[],options:o}=this,a=e,l=this._getActiveElements(t,n,s,a),u=d(t),g=function(b,w,k,A){return k&&b.type!=="mouseout"?A?w:b:null}(t,this._lastEvent,s,u);s&&(this._lastEvent=null,ft(o.onHover,[t,l,this],this),u&&ft(o.onClick,[t,l,this],this));let x=!jt(l,n);return(x||e)&&(this._active=l,this._updateHoverStyles(l,n,e)),this._lastEvent=g,x}_getActiveElements(t,e,s,n){if(t.type==="mouseout")return[];if(!s)return e;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,n)}}function Nr(){return xt(Ve.instances,i=>i._plugins.invalidate())}function Cs(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class mo{static override(t){Object.assign(mo.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Cs()}parse(){return Cs()}format(){return Cs()}add(){return Cs()}diff(){return Cs()}startOf(){return Cs()}endOf(){return Cs()}}var $r={_date:mo};function Fl(i){let t=i.iScale,e=function(g,x){if(!g._cache.$bar){let b=g.getMatchingVisibleMetas(x),w=[];for(let k=0,A=b.length;kk-A))}return g._cache.$bar}(t,i.type),s,n,o,a,l=t._length,u=()=>{o!==32767&&o!==-32768&&(Bt(a)&&(l=Math.min(l,Math.abs(o-a)||l)),a=o)};for(s=0,n=e.length;sMath.abs(b)&&(w=b,k=x),o[a.axis]=k,o._custom={barStart:w,barEnd:k,start:u,end:g,min:x,max:b}}(i,t,e,s):t[e.axis]=e.parse(i,s),t}function Wr(i,t,e,s){let n=i.iScale,o=i.vScale,a=n.getLabels(),l=n===o,u=[],g,x,b,w;for(g=e,x=e+s;gb.x,k="left",A="right"):(w=b.baset!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data;if(e.labels.length&&e.datasets.length){let{labels:{pointStyle:s,color:n}}=t.legend.options;return e.labels.map((o,a)=>{let l=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:n,lineWidth:l.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){let s=this.getDataset().data,n=this._cachedMeta;if(this._parsing===!1)n._parsed=s;else{let o,a,l=u=>+s[u];if(X(s[t])){let{key:u="value"}=this._parsing;l=g=>+De(s[g],u)}for(o=t,a=t+e;oN(Xi,Vt,Nt,!0)?1:Math.max(Gi,Gi*Ct,Qi,Qi*Ct),hi=(Xi,Gi,Qi)=>N(Xi,Vt,Nt,!0)?-1:Math.min(Gi,Gi*Ct,Qi,Qi*Ct),zi=ye(0,Wt,ne),Li=ye(nt,Ft,Se),Wi=hi(y,Wt,ne),qi=hi(y+nt,Ft,Se);At=(zi-Wi)/2,$t=(Li-qi)/2,Ht=-(zi+Wi)/2,Xt=-(Li+qi)/2}return{ratioX:At,ratioY:$t,offsetX:Ht,offsetY:Xt}}(b,x,u),R=(s.width-a)/w,$=(s.height-a)/k,tt=Math.max(Math.min(R,$)/2,0),Z=Ot(this.options.radius,tt),Q=(Z-Math.max(Z*u,0))/this._getVisibleDatasetWeightTotal();this.offsetX=A*Z,this.offsetY=T*Z,n.total=this.calculateTotal(),this.outerRadius=Z-Q*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-Q*g,0),this.updateElements(o,0,o.length,t)}_circumference(t,e){let s=this.options,n=this._cachedMeta,o=this._getCircumference();return e&&s.animation.animateRotate||!this.chart.getDataVisibility(t)||n._parsed[t]===null||n.data[t].hidden?0:this.calculateCircumference(n._parsed[t]*o/v)}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,l=a.chartArea,u=a.options.animation,g=(l.left+l.right)/2,x=(l.top+l.bottom)/2,b=o&&u.animateScale,w=b?0:this.innerRadius,k=b?0:this.outerRadius,{sharedOptions:A,includeOptions:T}=this._getSharedOptions(e,n),R,$=this._getRotation();for(R=0;R0&&!isNaN(t)?v*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=ct(e._parsed[t],s.options.locale);return{label:n[t]||"",value:o}}getMaxBorderWidth(t){let e=0,s=this.chart,n,o,a,l,u;if(!t){for(n=0,o=s.data.datasets.length;n{let l=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:n,lineWidth:l.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=ct(e._parsed[t].r,s.options.locale);return{label:n[t]||"",value:o}}parseObjectData(t,e,s,n){return zs.bind(this)(t,e,s,n)}update(t){let e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){let t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((s,n)=>{let o=this.getParsed(n).r;!isNaN(o)&&this.chart.getDataVisibility(n)&&(oe.max&&(e.max=o))}),e}_updateRadius(){let t=this.chart,e=t.chartArea,s=t.options,n=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(n/2,0),a=(o-Math.max(s.cutoutPercentage?o/100*s.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,l=a.options.animation,u=this._cachedMeta.rScale,g=u.xCenter,x=u.yCenter,b=u.getIndexAngle(0)-.5*y,w,k=b,A=360/this.countVisibleElements();for(w=0;w{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++}),e}_computeAngle(t,e,s){return this.chart.getDataVisibility(t)?He(this.resolveDataElementOptions(t,e).angle||s):0}}var Vr=Object.freeze({__proto__:null,BarController:class extends ls{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(i,t,e,s){return Wr(i,t,e,s)}parseArrayData(i,t,e,s){return Wr(i,t,e,s)}parseObjectData(i,t,e,s){let{iScale:n,vScale:o}=i,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,u=n.axis==="x"?a:l,g=o.axis==="x"?a:l,x=[],b,w,k,A;for(b=e,w=e+s;bl.controller.options.grouped),n=e.options.stacked,o=[],a=l=>{let u=l.controller.getParsed(t),g=u&&u[l.vScale.axis];if(C(g)||isNaN(g))return!0};for(let l of s)if((t===void 0||!a(l))&&((n===!1||o.indexOf(l.stack)===-1||n===void 0&&l.stack===void 0)&&o.push(l.stack),l.index===i))break;return o.length||o.push(void 0),o}_getStackCount(i){return this._getStacks(void 0,i).length}_getStackIndex(i,t,e){let s=this._getStacks(i,e),n=t!==void 0?s.indexOf(t):-1;return n===-1?s.length-1:n}_getRuler(){let i=this.options,t=this._cachedMeta,e=t.iScale,s=[],n,o;for(n=0,o=t.data.length;n=Ct?1:-1)}(b,t,a)*o,w===a&&(R-=b/2);let $=t.getPixelForDecimal(0),tt=t.getPixelForDecimal(1),Z=Math.min($,tt),Q=Math.max($,tt);R=Math.max(Math.min(R,Q),Z),x=R+b,e&&!g&&(l._stacks[t.axis]._visualValues[s]=t.getValueForPixel(x)-t.getValueForPixel(R))}if(R===t.getPixelForValue(a)){let $=Et(b)*t.getLineWidthForValue(a)/2;R+=$,b-=$}return{size:b,base:R,head:x,center:x+b/2}}_calculateBarIndexPixels(i,t){let e=t.scale,s=this.options,n=s.skipNull,o=q(s.maxBarThickness,1/0),a,l;if(t.grouped){let u=n?this._getStackCount(i):t.stackCount,g=s.barThickness==="flex"?function(b,w,k,A){let T=w.pixels,R=T[b],$=b>0?T[b-1]:null,tt=b=0;--e)t=Math.max(t,i[e].size(this.resolveDataElementOptions(e))/2);return t>0&&t}getLabelAndValue(i){let t=this._cachedMeta,e=this.chart.data.labels||[],{xScale:s,yScale:n}=t,o=this.getParsed(i),a=s.getLabelForValue(o.x),l=n.getLabelForValue(o.y),u=o._custom;return{label:e[i]||"",value:"("+a+", "+l+(u?", "+u:"")+")"}}update(i){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,i)}updateElements(i,t,e,s){let n=s==="reset",{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:u}=this._getSharedOptions(t,s),g=o.axis,x=a.axis;for(let b=t;b0&&this.getParsed(t-1);for(let Q=0;Q=$){mt.skip=!0;continue}let Ct=this.getParsed(Q),At=C(Ct[w]),$t=mt[b]=o.getPixelForValue(Ct[b],Q),Ht=mt[w]=n||At?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,Ct,l):Ct[w],Q);mt.skip=isNaN($t)||isNaN(Ht)||At,mt.stop=Q>0&&Math.abs(Ct[b]-Z[b])>T,A&&(mt.parsed=Ct,mt.raw=u.data[Q]),x&&(mt.options=g||this.resolveDataElementOptions(Q,ht.active?"active":s)),R||this.updateElement(ht,Q,mt,s),Z=Ct}}getMaxOverflow(){let i=this._cachedMeta,t=i.dataset,e=t.options&&t.options.borderWidth||0,s=i.data||[];if(!s.length)return e;let n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(e,n,o)/2}draw(){let i=this._cachedMeta;i.dataset.updateControlPoints(this.chart.chartArea,i.iScale.axis),super.draw()}},PieController:class extends yo{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:jr,RadarController:class extends ls{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(i){let t=this._cachedMeta.vScale,e=this.getParsed(i);return{label:t.getLabels()[i],value:""+t.getLabelForValue(e[t.axis])}}parseObjectData(i,t,e,s){return zs.bind(this)(i,t,e,s)}update(i){let t=this._cachedMeta,e=t.dataset,s=t.data||[],n=t.iScale.getLabels();if(e.points=s,i!=="resize"){let o=this.resolveDatasetElementOptions(i);this.options.showLine||(o.borderWidth=0);let a={_loop:!0,_fullLoop:n.length===s.length,options:o};this.updateElement(e,void 0,a,i)}this.updateElements(s,0,s.length,i)}updateElements(i,t,e,s){let n=this._cachedMeta.rScale,o=s==="reset";for(let a=t;a0&&this.getParsed(t-1);for(let Z=t;Z0&&Math.abs(ht[w]-tt[w])>R,T&&(mt.parsed=ht,mt.raw=u.data[Z]),b&&(mt.options=x||this.resolveDataElementOptions(Z,Q.active?"active":s)),$||this.updateElement(Q,Z,mt,s),tt=ht}this.updateSharedOptions(x,s,g)}getMaxOverflow(){let i=this._cachedMeta,t=i.data||[];if(!this.options.showLine){let a=0;for(let l=t.length-1;l>=0;--l)a=Math.max(a,t[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let e=i.dataset,s=e.options&&e.options.borderWidth||0;if(!t.length)return s;let n=t[0].size(this.resolveDataElementOptions(0)),o=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(s,n,o)/2}}});function Ul(i,t,e,s){let n=hn(i.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]),o=(e-t)/2,a=Math.min(o,s*t/2),l=u=>{let g=(e-Math.min(o,u))*s/2;return J(u,0,Math.min(o,g))};return{outerStart:l(n.outerStart),outerEnd:l(n.outerEnd),innerStart:J(n.innerStart,0,a),innerEnd:J(n.innerEnd,0,a)}}function Hs(i,t,e,s){return{x:e+i*Math.cos(t),y:s+i*Math.sin(t)}}function yn(i,t,e,s,n,o){let{x:a,y:l,startAngle:u,pixelMargin:g,innerRadius:x}=t,b=Math.max(t.outerRadius+s+e-g,0),w=x>0?x+s+e+g:0,k=0,A=n-u;if(s){let Wt=((x>0?x-s:0)+(b>0?b-s:0))/2;k=(A-(Wt!==0?A*Wt/(Wt+s):A))/2}let T=(A-Math.max(.001,A*b-e/y)/b)/2,R=u+T+k,$=n-T-k,{outerStart:tt,outerEnd:Z,innerStart:Q,innerEnd:ht}=Ul(t,w,b,$-R),mt=b-tt,Ct=b-Z,At=R+tt/mt,$t=$-Z/Ct,Ht=w+Q,Xt=w+ht,Vt=R+Q/Ht,Nt=$-ht/Xt;if(i.beginPath(),o){let Wt=(At+$t)/2;if(i.arc(a,l,b,At,Wt),i.arc(a,l,b,Wt,$t),Z>0){let ye=Hs(Ct,$t,a,l);i.arc(ye.x,ye.y,Z,$t,$+nt)}let Ft=Hs(Xt,$,a,l);if(i.lineTo(Ft.x,Ft.y),ht>0){let ye=Hs(Xt,Nt,a,l);i.arc(ye.x,ye.y,ht,$+nt,Nt+Math.PI)}let ne=($-ht/w+(R+Q/w))/2;if(i.arc(a,l,w,$-ht/w,ne,!0),i.arc(a,l,w,ne,R+Q/w,!0),Q>0){let ye=Hs(Ht,Vt,a,l);i.arc(ye.x,ye.y,Q,Vt+Math.PI,R-nt)}let Se=Hs(mt,R,a,l);if(i.lineTo(Se.x,Se.y),tt>0){let ye=Hs(mt,At,a,l);i.arc(ye.x,ye.y,tt,R-nt,At)}}else{i.moveTo(a,l);let Wt=Math.cos(At)*b+a,Ft=Math.sin(At)*b+l;i.lineTo(Wt,Ft);let ne=Math.cos($t)*b+a,Se=Math.sin($t)*b+l;i.lineTo(ne,Se)}i.closePath()}function jl(i,t,e,s,n){let{fullCircles:o,startAngle:a,circumference:l,options:u}=t,{borderWidth:g,borderJoinStyle:x,borderDash:b,borderDashOffset:w}=u,k=u.borderAlign==="inner";if(!g)return;i.setLineDash(b||[]),i.lineDashOffset=w,k?(i.lineWidth=2*g,i.lineJoin=x||"round"):(i.lineWidth=g,i.lineJoin=x||"bevel");let A=t.endAngle;if(o){yn(i,t,e,s,A,n);for(let T=0;TZ?(At=Z/Ct,T.arc(Q,ht,Ct,$+At,tt-At,!0)):T.arc(Q,ht,Z,$+nt,tt-nt),T.closePath(),T.clip()}(i,t,A),o||(yn(i,t,e,s,A,n),i.stroke())}function Yr(i,t,e=t){i.lineCap=q(e.borderCapStyle,t.borderCapStyle),i.setLineDash(q(e.borderDash,t.borderDash)),i.lineDashOffset=q(e.borderDashOffset,t.borderDashOffset),i.lineJoin=q(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=q(e.borderWidth,t.borderWidth),i.strokeStyle=q(e.borderColor,t.borderColor)}function Vl(i,t,e){i.lineTo(e.x,e.y)}function qr(i,t,e={}){let s=i.length,{start:n=0,end:o=s-1}=e,{start:a,end:l}=t,u=Math.max(n,a),g=Math.min(o,l),x=nl&&o>l;return{count:s,start:u,loop:t.loop,ilen:g(a+(g?l-Q:Q))%o,Z=()=>{k!==A&&(i.lineTo(R,A),i.lineTo(R,k),i.lineTo(R,T))};for(u&&(b=n[tt(0)],i.moveTo(b.x,b.y)),x=0;x<=l;++x){if(b=n[tt(x)],b.skip)continue;let Q=b.x,ht=b.y,mt=0|Q;mt===w?(htA&&(A=ht),R=($*R+Q)/++$):(Z(),i.lineTo(Q,ht),w=mt,$=0,k=A=ht),T=ht}Z()}function xo(i){let t=i.options,e=t.borderDash&&t.borderDash.length;return i._decimated||i._loop||t.tension||t.cubicInterpolationMode==="monotone"||t.stepped||e?Yl:ql}let Xl=typeof Path2D=="function";function Gl(i,t,e,s){Xl&&!t.options.segment?function(n,o,a,l){let u=o._path;u||(u=o._path=new Path2D,o.path(u,a,l)&&u.closePath()),Yr(n,o.options),n.stroke(u)}(i,t,e,s):function(n,o,a,l){let{segments:u,options:g}=o,x=xo(o);for(let b of u)Yr(n,g,b.style),n.beginPath(),x(n,o,b,{start:a,end:a+l-1})&&n.closePath(),n.stroke()}(i,t,e,s)}class xn extends ss{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){let s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){let n=s.spanGaps?this._loop:this._fullLoop;Mi(this._points,s,t,n,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Go(this,this.options.segment))}first(){let t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){let t=this.segments,e=this.points,s=t.length;return s&&e[t[s-1].end]}interpolate(t,e){let s=this.options,n=t[e],o=this.points,a=oo(this,{property:e,start:n,end:n});if(!a.length)return;let l=[],u=function(b){return b.stepped?Uo:b.tension||b.cubicInterpolationMode==="monotone"?jo:ps}(s),g,x;for(g=0,x=a.length;gi!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(i){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,i&&Object.assign(this,i)}inRange(i,t,e){let s=this.getProps(["x","y"],e),{angle:n,distance:o}=si(s,{x:i,y:t}),{startAngle:a,endAngle:l,innerRadius:u,outerRadius:g,circumference:x}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],e),b=(this.options.spacing+this.options.borderWidth)/2,w=q(x,l-a)>=v||N(n,a,l),k=ot(o,u+b,g+b);return w&&k}getCenterPoint(i){let{x:t,y:e,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],i),{offset:l,spacing:u}=this.options,g=(s+n)/2,x=(o+a+u+l)/2;return{x:t+Math.cos(g)*x,y:e+Math.sin(g)*x}}tooltipPosition(i){return this.getCenterPoint(i)}draw(i){let{options:t,circumference:e}=this,s=(t.offset||0)/4,n=(t.spacing||0)/2,o=t.circular;if(this.pixelMargin=t.borderAlign==="inner"?.33:0,this.fullCircles=e>v?Math.floor(e/v):0,e===0||this.innerRadius<0||this.outerRadius<0)return;i.save();let a=(this.startAngle+this.endAngle)/2;i.translate(Math.cos(a)*s,Math.sin(a)*s);let l=s*(1-Math.sin(Math.min(y,e||0)));i.fillStyle=t.backgroundColor,i.strokeStyle=t.borderColor,function(u,g,x,b,w){let{fullCircles:k,startAngle:A,circumference:T}=g,R=g.endAngle;if(k){yn(u,g,x,b,R,w);for(let $=0;$(typeof a=="string"?(l=o.push(a)-1,u.unshift({index:l,label:a})):isNaN(a)&&(l=null),l))(i,t,e,s):n!==i.lastIndexOf(t)?e:n}function Qr(i){let t=this.getLabels();return i>=0&&in=e?n:u,l=u=>o=s?o:u;if(t){let u=Et(n),g=Et(o);u<0&&g<0?l(0):u>0&&g>0&&a(0)}if(n===o){let u=o===0?1:Math.abs(.05*o);l(o+u),t||a(n-u)}this.min=n,this.max=o}getTickLimit(){let t=this.options.ticks,e,{maxTicksLimit:s,stepSize:n}=t;return n?(e=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),s=s||11),s&&(e=Math.min(s,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,e=t.ticks,s=this.getTickLimit();s=Math.max(2,s);let n=function(o,a){let l=[],{bounds:u,step:g,min:x,max:b,precision:w,count:k,maxTicks:A,maxDigits:T,includeBounds:R}=o,$=g||1,tt=A-1,{min:Z,max:Q}=a,ht=!C(x),mt=!C(b),Ct=!C(k),At=(Q-Z)/(T+1),$t,Ht,Xt,Vt,Nt=Le((Q-Z)/tt/$)*$;if(Nt<1e-14&&!ht&&!mt)return[{value:Z},{value:Q}];Vt=Math.ceil(Q/Nt)-Math.floor(Z/Nt),Vt>tt&&(Nt=Le(Vt*Nt/tt/$)*$),C(w)||($t=Math.pow(10,w),Nt=Math.ceil(Nt*$t)/$t),u==="ticks"?(Ht=Math.floor(Z/Nt)*Nt,Xt=Math.ceil(Q/Nt)*Nt):(Ht=Z,Xt=Q),ht&&mt&&g&&We((b-x)/g,Nt/1e3)?(Vt=Math.round(Math.min((b-x)/Nt,A)),Nt=(b-x)/Vt,Ht=x,Xt=b):Ct?(Ht=ht?x:Ht,Xt=mt?b:Xt,Vt=k-1,Nt=(Xt-Ht)/Vt):(Vt=(Xt-Ht)/Nt,Vt=ie(Vt,Math.round(Vt),Nt/1e3)?Math.round(Vt):Math.ceil(Vt));let Wt=Math.max(Ne(Nt),Ne(Ht));$t=Math.pow(10,C(w)?Wt:w),Ht=Math.round(Ht*$t)/$t,Xt=Math.round(Xt*$t)/$t;let Ft=0;for(ht&&(R&&Ht!==x?(l.push({value:x}),Htb)break;l.push({value:ne})}return mt&&R&&Xt!==b?l.length&&ie(l[l.length-1].value,b,Kr(b,At,o))?l[l.length-1].value=b:l.push({value:b}):mt&&Xt!==b||l.push({value:Xt}),l}({maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},this._range||this);return t.bounds==="ticks"&&Je(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}configure(){let t=this.ticks,e=this.min,s=this.max;if(super.configure(),this.options.offset&&t.length){let n=(s-e)/Math.max(t.length-1,1)/2;e-=n,s+=n}this._startValue=e,this._endValue=s,this._valueRange=s-e}getLabelForValue(t){return ct(t,this.chart.options.locale,this.options.ticks.format)}}class Jl extends vn{static id="linear";static defaults={ticks:{callback:pt.formatters.numeric}};determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=W(t)?t:0,this.max=W(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,s=He(this.options.ticks.minRotation),n=(t?Math.sin(s):Math.cos(s))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/n))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}let Qs=i=>Math.floor(kt(i)),Ts=(i,t)=>Math.pow(10,Qs(i)+t);function Zr(i){return i/Math.pow(10,Qs(i))===1}function Jr(i,t,e){let s=Math.pow(10,e),n=Math.floor(i/s);return Math.ceil(t/s)-n}function th(i,{min:t,max:e}){t=at(i.min,t);let s=[],n=Qs(t),o=function(A,T){let R=Qs(T-A);for(;Jr(A,T,R)>10;)R++;for(;Jr(A,T,R)<10;)R--;return Math.min(R,Qs(A))}(t,e),a=o<0?Math.pow(10,Math.abs(o)):1,l=Math.pow(10,o),u=n>o?Math.pow(10,n):0,g=Math.round((t-u)*a)/a,x=Math.floor((t-u)/l/10)*l*10,b=Math.floor((g-x)/Math.pow(10,o)),w=at(i.min,Math.round((u+x+b*Math.pow(10,o))*a)/a);for(;w=10?b=b<15?15:20:b++,b>=20&&(o++,b=2,a=o>=0?1:a),w=Math.round((u+x+b*Math.pow(10,o))*a)/a;let k=at(i.max,w);return s.push({value:k,major:Zr(k),significand:b}),s}class eh extends ms{static id="logarithmic";static defaults={ticks:{callback:pt.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){let s=vn.prototype.parse.apply(this,[t,e]);if(s!==0)return W(s)&&s>0?s:null;this._zero=!0}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=W(t)?Math.max(0,t):null,this.max=W(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!W(this._userMin)&&(this.min=t===Ts(this.min,0)?Ts(this.min,-1):Ts(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),s=this.min,n=this.max,o=l=>s=t?s:l,a=l=>n=e?n:l;s===n&&(s<=0?(o(1),a(10)):(o(Ts(s,-1)),a(Ts(n,1)))),s<=0&&o(Ts(n,-1)),n<=0&&a(Ts(s,1)),this.min=s,this.max=n}buildTicks(){let t=this.options,e=th({min:this._userMin,max:this._userMax},this);return t.bounds==="ticks"&&Je(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return t===void 0?"0":ct(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=kt(t),this._valueRange=kt(this.max)-kt(t)}getPixelForValue(t){return t!==void 0&&t!==0||(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(kt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function ko(i){let t=i.ticks;if(t.display&&i.display){let e=ai(t.backdropPadding);return q(t.font&&t.font.size,bt.font.size)+e.height}return 0}function ta(i,t,e,s,n){return i===s||i===n?{start:t-e/2,end:t+e/2}:in?{start:t-e,end:t}:{start:t,end:t+e}}function ih(i){let t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),s=[],n=[],o=i._pointLabels.length,a=i.options.pointLabels,l=a.centerPointLabels?y/o:0;for(let b=0;bt.r&&(l=(s.end-t.r)/o,i.r=Math.max(i.r,t.r+l)),n.startt.b&&(u=(n.end-t.b)/a,i.b=Math.max(i.b,t.b+u))}function nh(i,t,e){let s=i.drawingArea,{extra:n,additionalAngle:o,padding:a,size:l}=e,u=i.getPointPosition(t,s+n+a,o),g=Math.round(ti(ve(u.angle+nt))),x=function(k,A,T){return T===90||T===270?k-=A/2:(T>270||T<90)&&(k-=A),k}(u.y,l.h,g),b=function(k){return k===0||k===180?"center":k<180?"left":"right"}(g),w=function(k,A,T){return T==="right"?k-=A:T==="center"&&(k-=A/2),k}(u.x,l.w,b);return{visible:!0,x:u.x,y:x,textAlign:b,left:w,top:x,right:w+l.w,bottom:x+l.h}}function oh(i,t){if(!t)return!0;let{left:e,top:s,right:n,bottom:o}=i;return!(Mt({x:e,y:s},t)||Mt({x:e,y:o},t)||Mt({x:n,y:s},t)||Mt({x:n,y:o},t))}function rh(i,t,e){let{left:s,top:n,right:o,bottom:a}=e,{backdropColor:l}=t;if(!C(l)){let u=fs(t.borderRadius),g=ai(t.backdropPadding);i.fillStyle=l;let x=s-g.left,b=n-g.top,w=o-s+g.width,k=a-n+g.height;Object.values(u).some(A=>A!==0)?(i.beginPath(),xi(i,{x,y:b,w,h:k,radius:u}),i.fill()):i.fillRect(x,b,w,k)}}function ea(i,t,e,s){let{ctx:n}=i;if(e)n.arc(i.xCenter,i.yCenter,t,0,v);else{let o=i.getPointPosition(0,t);n.moveTo(o.x,o.y);for(let a=1;at,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let t=this._padding=ai(ko(this.options)/2),e=this.width=this.maxWidth-t.width,s=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+s/2+t.top),this.drawingArea=Math.floor(Math.min(e,s)/2)}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!1);this.min=W(t)&&!isNaN(t)?t:0,this.max=W(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/ko(this.options))}generateTickLabels(t){vn.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,s)=>{let n=ft(this.options.pointLabels.callback,[e,s],this);return n||n===0?n:""}).filter((e,s)=>this.chart.getDataVisibility(s))}fit(){let t=this.options;t.display&&t.pointLabels.display?ih(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,s,n){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((s-n)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,s,n))}getIndexAngle(t){return ve(t*(v/(this._pointLabels.length||1))+He(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(C(t))return NaN;let e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(C(t))return NaN;let e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){let e=this._pointLabels||[];if(t>=0&&t=0;A--){let T=x._pointLabelItems[A];if(!T.visible)continue;let R=k.setContext(x.getPointLabelContext(A));rh(w,R,T);let $=qe(R.font),{x:tt,y:Z,textAlign:Q}=T;Qe(w,x._pointLabels[A],tt,Z+$.lineHeight/2,$,{color:R.color,textAlign:Q,textBaseline:"middle"})}}(this,a),n.display&&this.ticks.forEach((x,b)=>{if(b!==0){u=this.getDistanceFromCenterForValue(x.value);let w=this.getContext(b),k=n.setContext(w),A=o.setContext(w);(function(T,R,$,tt,Z){let Q=T.ctx,ht=R.circular,{color:mt,lineWidth:Ct}=R;!ht&&!tt||!mt||!Ct||$<0||(Q.save(),Q.strokeStyle=mt,Q.lineWidth=Ct,Q.setLineDash(Z.dash),Q.lineDashOffset=Z.dashOffset,Q.beginPath(),ea(T,$,ht,tt),Q.closePath(),Q.stroke(),Q.restore())})(this,k,u,a,A)}}),s.display){for(t.save(),l=a-1;l>=0;l--){let x=s.setContext(this.getPointLabelContext(l)),{color:b,lineWidth:w}=x;w&&b&&(t.lineWidth=w,t.strokeStyle=b,t.setLineDash(x.borderDash),t.lineDashOffset=x.borderDashOffset,u=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),g=this.getPointPosition(l,u),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(g.x,g.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){let t=this.ctx,e=this.options,s=e.ticks;if(!s.display)return;let n=this.getIndexAngle(0),o,a;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(n),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((l,u)=>{if(u===0&&!e.reverse)return;let g=s.setContext(this.getContext(u)),x=qe(g.font);if(o=this.getDistanceFromCenterForValue(this.ticks[u].value),g.showLabelBackdrop){t.font=x.string,a=t.measureText(l.label).width,t.fillStyle=g.backdropColor;let b=ai(g.backdropPadding);t.fillRect(-a/2-b.left,-o-x.size/2-b.top,a+b.width,x.size+b.height)}Qe(t,l.label,0,-o,x,{color:g.color,strokeColor:g.textStrokeColor,strokeWidth:g.textStrokeWidth})}),t.restore()}drawTitle(){}}let wn={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Si=Object.keys(wn);function ia(i,t){return i-t}function sa(i,t){if(C(t))return null;let e=i._adapter,{parser:s,round:n,isoWeekday:o}=i._parseOpts,a=t;return typeof s=="function"&&(a=s(a)),W(a)||(a=typeof s=="string"?e.parse(a,s):e.parse(a)),a===null?null:(n&&(a=n!=="week"||!Re(o)&&o!==!0?e.startOf(a,n):e.startOf(a,"isoWeek",o)),+a)}function na(i,t,e,s){let n=Si.length;for(let o=Si.indexOf(i);o=t?e[s]:e[n]]=!0}}else i[t]=!0}function ra(i,t,e){let s=[],n={},o=t.length,a,l;for(a=0;a=0&&(g[R].major=!0);return g}(i,s,n,e):s}class Mo extends ms{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){let s=t.time||(t.time={}),n=this._adapter=new $r._date(t.adapters.date);n.init(e),_e(s.displayFormats,n.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:sa(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,e=this._adapter,s=t.time.unit||"day",{min:n,max:o,minDefined:a,maxDefined:l}=this.getUserBounds();function u(g){a||isNaN(g.min)||(n=Math.min(n,g.min)),l||isNaN(g.max)||(o=Math.max(o,g.max))}a&&l||(u(this._getLabelBounds()),t.bounds==="ticks"&&t.ticks.source==="labels"||u(this.getMinMax(!1))),n=W(n)&&!isNaN(n)?n:+e.startOf(Date.now(),s),o=W(o)&&!isNaN(o)?o:+e.endOf(Date.now(),s)+1,this.min=Math.min(n,o-1),this.max=Math.max(n+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],s=t[t.length-1]),{min:e,max:s}}buildTicks(){let t=this.options,e=t.time,s=t.ticks,n=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&n.length&&(this.min=this._userMin||n[0],this.max=this._userMax||n[n.length-1]);let o=this.min,a=Pt(n,o,this.max);return this._unit=e.unit||(s.autoSkip?na(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):function(l,u,g,x,b){for(let w=Si.length-1;w>=Si.indexOf(g);w--){let k=Si[w];if(wn[k].common&&l._adapter.diff(b,x,k)>=u-1)return k}return Si[g?Si.indexOf(g):0]}(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=s.major.enabled&&this._unit!=="year"?function(l){for(let u=Si.indexOf(l)+1,g=Si.length;u+t.value))}initOffsets(t=[]){let e,s,n=0,o=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),n=t.length===1?1-e:(this.getDecimalForValue(t[1])-e)/2,s=this.getDecimalForValue(t[t.length-1]),o=t.length===1?s:(s-this.getDecimalForValue(t[t.length-2]))/2);let a=t.length<3?.5:.25;n=J(n,0,a),o=J(o,0,a),this._offsets={start:n,end:o,factor:1/(n+1+o)}}_generate(){let t=this._adapter,e=this.min,s=this.max,n=this.options,o=n.time,a=o.unit||na(o.minUnit,e,s,this._getLabelCapacity(e)),l=q(n.ticks.stepSize,1),u=a==="week"&&o.isoWeekday,g=Re(u)||u===!0,x={},b,w,k=e;if(g&&(k=+t.startOf(k,"isoWeek",u)),k=+t.startOf(k,g?"day":a),t.diff(s,e,a)>1e5*l)throw new Error(e+" and "+s+" are too far apart with stepSize of "+l+" "+a);let A=n.ticks.source==="data"&&this.getDataTimestamps();for(b=k,w=0;b+T)}getLabelForValue(t){let e=this._adapter,s=this.options.time;return s.tooltipFormat?e.format(t,s.tooltipFormat):e.format(t,s.displayFormats.datetime)}format(t,e){let s=this.options.time.displayFormats,n=this._unit,o=e||s[n];return this._adapter.format(t,o)}_tickFormatFunction(t,e,s,n){let o=this.options,a=o.ticks.callback;if(a)return ft(a,[t,e,s],this);let l=o.time.displayFormats,u=this._unit,g=this._majorUnit,x=u&&l[u],b=g&&l[g],w=s[e],k=g&&b&&w&&w.major;return this._adapter.format(t,n||(k?b:x))}generateTickLabels(t){let e,s,n;for(e=0,s=t.length;e0?l:1}getDataTimestamps(){let t,e,s=this._cache.data||[];if(s.length)return s;let n=this.getMatchingVisibleMetas();if(this._normalized&&n.length)return this._cache.data=n[0].controller.getAllParsedValues(this);for(t=0,e=n.length;t=i[l].pos&&t<=i[u].pos&&({lo:l,hi:u}=dt(i,"pos",t)),{pos:s,time:o}=i[l],{pos:n,time:a}=i[u]):(t>=i[l].time&&t<=i[u].time&&({lo:l,hi:u}=dt(i,"time",t)),{time:s,pos:o}=i[l],{time:n,pos:a}=i[u]);let g=n-s;return g?o+(a-o)*(t-s)/g:o}var aa=Object.freeze({__proto__:null,CategoryScale:class extends ms{static id="category";static defaults={ticks:{callback:Qr}};constructor(i){super(i),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(i){let t=this._addedLabels;if(t.length){let e=this.getLabels();for(let{index:s,label:n}of t)e[s]===n&&e.splice(s,1);this._addedLabels=[]}super.init(i)}parse(i,t){if(C(i))return null;let e=this.getLabels();return((s,n)=>s===null?null:J(Math.round(s),0,n))(t=isFinite(t)&&e[t]===i?t:Zl(e,i,q(t,i),this._addedLabels),e.length-1)}determineDataLimits(){let{minDefined:i,maxDefined:t}=this.getUserBounds(),{min:e,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(i||(e=0),t||(s=this.getLabels().length-1)),this.min=e,this.max=s}buildTicks(){let i=this.min,t=this.max,e=this.options.offset,s=[],n=this.getLabels();n=i===0&&t===n.length-1?n:n.slice(i,t+1),this._valueRange=Math.max(n.length-(e?0:1),1),this._startValue=this.min-(e?.5:0);for(let o=i;o<=t;o++)s.push({value:o});return s}getLabelForValue(i){return Qr.call(this,i)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(i){return typeof i!="number"&&(i=this.parse(i)),i===null?NaN:this.getPixelForDecimal((i-this._startValue)/this._valueRange)}getPixelForTick(i){let t=this.ticks;return i<0||i>t.length-1?null:this.getPixelForValue(t[i].value)}getValueForPixel(i){return Math.round(this._startValue+this.getDecimalForPixel(i)*this._valueRange)}getBasePixel(){return this.bottom}},LinearScale:Jl,LogarithmicScale:eh,RadialLinearScale:ah,TimeScale:Mo,TimeSeriesScale:class extends Mo{static id="timeseries";static defaults=Mo.defaults;constructor(i){super(i),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let i=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(i);this._minPos=_n(t,this.min),this._tableRange=_n(t,this.max)-this._minPos,super.initOffsets(i)}buildLookupTable(i){let{min:t,max:e}=this,s=[],n=[],o,a,l,u,g;for(o=0,a=i.length;o=t&&u<=e&&s.push(u);if(s.length<2)return[{time:t,pos:0},{time:e,pos:1}];for(o=0,a=s.length;os-n)}_getTimestampsForTable(){let i=this._cache.all||[];if(i.length)return i;let t=this.getDataTimestamps(),e=this.getLabelTimestamps();return i=t.length&&e.length?this.normalize(t.concat(e)):t.length?t:e,i=this._cache.all=i,i}getDecimalForValue(i){return(_n(this._table,i)-this._minPos)/this._tableRange}getValueForPixel(i){let t=this._offsets,e=this.getDecimalForPixel(i)/t.factor-t.end;return _n(this._table,e*this._tableRange+this._minPos,!0)}}});let So=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],la=So.map(i=>i.replace("rgb(","rgba(").replace(")",", 0.5)"));function ha(i){return So[i%So.length]}function ca(i){return la[i%la.length]}function lh(i){let t=0;return(e,s)=>{let n=i.getDatasetMeta(s).controller;n instanceof yo?t=function(o,a){return o.backgroundColor=o.data.map(()=>ha(a++)),a}(e,t):n instanceof jr?t=function(o,a){return o.backgroundColor=o.data.map(()=>ca(a++)),a}(e,t):n&&(t=function(o,a){return o.borderColor=ha(a),o.backgroundColor=ca(a),++a}(e,t))}}function da(i){let t;for(t in i)if(i[t].borderColor||i[t].backgroundColor)return!0;return!1}var hh={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(i,t,e){if(!e.enabled)return;let{data:{datasets:s},options:n}=i.config,{elements:o}=n;if(!e.forceOverride&&(da(s)||(a=n)&&(a.borderColor||a.backgroundColor)||o&&da(o)))return;var a;let l=lh(i);s.forEach(l)}};function ua(i){if(i._decimated){let t=i._data;delete i._decimated,delete i._data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function ga(i){i.data.datasets.forEach(t=>{ua(t)})}var ch={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled)return void ga(i);let s=i.width;i.data.datasets.forEach((n,o)=>{let{_data:a,indexAxis:l}=n,u=i.getDatasetMeta(o),g=a||n.data;if(Is([l,i.options.indexAxis])==="y"||!u.controller.supportsDecimation)return;let x=i.scales[u.xAxisID];if(x.type!=="linear"&&x.type!=="time"||i.options.parsing)return;let{start:b,count:w}=function(A,T){let R=T.length,$,tt=0,{iScale:Z}=A,{min:Q,max:ht,minDefined:mt,maxDefined:Ct}=Z.getUserBounds();return mt&&(tt=J(dt(T,Z.axis,Q).lo,0,R-1)),$=Ct?J(dt(T,Z.axis,ht).hi+1,tt,R)-tt:R-tt,{start:tt,count:$}}(u,g);if(w<=(e.threshold||4*s))return void ua(n);let k;switch(C(a)&&(n._data=g,delete n.data,Object.defineProperty(n,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(A){this._data=A}})),e.algorithm){case"lttb":k=function(A,T,R,$,tt){let Z=tt.samples||$;if(Z>=R)return A.slice(T,T+R);let Q=[],ht=(R-2)/(Z-2),mt=0,Ct=T+R-1,At,$t,Ht,Xt,Vt,Nt=T;for(Q[mt++]=A[Nt],At=0;AtHt&&(Ht=Xt,$t=A[Wt],Vt=Wt);Q[mt++]=$t,Nt=Vt}return Q[mt++]=A[Ct],Q}(g,b,w,s,e);break;case"min-max":k=function(A,T,R,$){let tt,Z,Q,ht,mt,Ct,At,$t,Ht,Xt,Vt=0,Nt=0,Wt=[],Ft=T+R-1,ne=A[T].x,Se=A[Ft].x-ne;for(tt=T;ttXt&&(Xt=ht,At=tt),Vt=(Nt*Vt+Z.x)/++Nt;else{let hi=tt-1;if(!C(Ct)&&!C(At)){let zi=Math.min(Ct,At),Li=Math.max(Ct,At);zi!==$t&&zi!==hi&&Wt.push({...A[zi],x:Vt}),Li!==$t&&Li!==hi&&Wt.push({...A[Li],x:Vt})}tt>0&&hi!==$t&&Wt.push(A[hi]),Wt.push(Z),mt=ye,Nt=0,Ht=Xt=ht,Ct=At=$t=tt}}return Wt}(g,b,w,s);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}n._decimated=k})},destroy(i){ga(i)}};function Co(i,t,e,s){if(s)return;let n=t[i],o=e[i];return i==="angle"&&(n=ve(n),o=ve(o)),{property:i,start:n,end:o}}function To(i,t,e){for(;t>i;t--){let s=e[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function pa(i,t,e,s){return i&&t?s(i[e],t[e]):i?i[e]:t?t[e]:0}function fa(i,t){let e=[],s=!1;return H(i)?(s=!0,e=i):e=function(n,o){let{x:a=null,y:l=null}=n||{},u=o.points,g=[];return o.segments.forEach(({start:x,end:b})=>{b=To(x,b,u);let w=u[x],k=u[b];l!==null?(g.push({x:w.x,y:l}),g.push({x:k.x,y:l})):a!==null&&(g.push({x:a,y:w.y}),g.push({x:a,y:k.y}))}),g}(i,t),e.length?new xn({points:e,options:{tension:0},_loop:s,_fullLoop:s}):null}function ma(i){return i&&i.fill!==!1}function dh(i,t,e){let s=i[t].fill,n=[t],o;if(!e)return s;for(;s!==!1&&n.indexOf(s)===-1;){if(!W(s))return s;if(o=i[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function uh(i,t,e){let s=function(o){let a=o.options,l=a.fill,u=q(l&&l.target,l);return u===void 0&&(u=!!a.backgroundColor),u===!1||u===null?!1:u===!0?"origin":u}(i);if(X(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return W(n)&&Math.floor(n)===n?function(o,a,l,u){return o!=="-"&&o!=="+"||(l=a+l),l===a||l<0||l>=u?!1:l}(s[0],t,n,e):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function gh(i,t,e){let s=[];for(let n=0;n=0;--a){let l=n[a].$filler;l&&(l.line.updateControlPoints(o,l.axis),s&&l.fill&&Eo(i.ctx,l,o))}},beforeDatasetsDraw(i,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;let s=i.getSortedVisibleDatasetMetas();for(let n=s.length-1;n>=0;--n){let o=s[n].$filler;ma(o)&&Eo(i.ctx,o,i.chartArea)}},beforeDatasetDraw(i,t,e){let s=t.meta.$filler;ma(s)&&e.drawTime==="beforeDatasetDraw"&&Eo(i.ctx,s,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};let wa=(i,t)=>{let{boxHeight:e=t,boxWidth:s=t}=i;return i.usePointStyle&&(e=Math.min(e,t),s=i.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:e,itemHeight:Math.max(t,e)}};class _a extends ss{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,s){this.maxWidth=t,this.maxHeight=e,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let t=this.options.labels||{},e=ft(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(s=>t.filter(s,this.chart.data))),t.sort&&(e=e.sort((s,n)=>t.sort(s,n,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){let{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);let s=t.labels,n=qe(s.font),o=n.size,a=this._computeTitleHeight(),{boxWidth:l,itemHeight:u}=wa(s,o),g,x;e.font=n.string,this.isHorizontal()?(g=this.maxWidth,x=this._fitRows(a,o,l,u)+10):(x=this.maxHeight,g=this._fitCols(a,n,l,u)+10),this.width=Math.min(g,t.maxWidth||this.maxWidth),this.height=Math.min(x,t.maxHeight||this.maxHeight)}_fitRows(t,e,s,n){let{ctx:o,maxWidth:a,options:{labels:{padding:l}}}=this,u=this.legendHitBoxes=[],g=this.lineWidths=[0],x=n+l,b=t;o.textAlign="left",o.textBaseline="middle";let w=-1,k=-x;return this.legendItems.forEach((A,T)=>{let R=s+e/2+o.measureText(A.text).width;(T===0||g[g.length-1]+R+2*l>a)&&(b+=x,g[g.length-(T>0?0:1)]=0,k+=x,w++),u[T]={left:0,top:k,row:w,width:R,height:n},g[g.length-1]+=R+l}),b}_fitCols(t,e,s,n){let{ctx:o,maxHeight:a,options:{labels:{padding:l}}}=this,u=this.legendHitBoxes=[],g=this.columnSizes=[],x=a-t,b=l,w=0,k=0,A=0,T=0;return this.legendItems.forEach((R,$)=>{let{itemWidth:tt,itemHeight:Z}=function(Q,ht,mt,Ct,At){let $t=function(Xt,Vt,Nt,Wt){let Ft=Xt.text;return Ft&&typeof Ft!="string"&&(Ft=Ft.reduce((ne,Se)=>ne.length>Se.length?ne:Se)),Vt+Nt.size/2+Wt.measureText(Ft).width}(Ct,Q,ht,mt),Ht=function(Xt,Vt,Nt){let Wt=Xt;return typeof Vt.text!="string"&&(Wt=ka(Vt,Nt)),Wt}(At,Ct,ht.lineHeight);return{itemWidth:$t,itemHeight:Ht}}(s,e,o,R,n);$>0&&k+Z+2*l>x&&(b+=w+l,g.push({width:w,height:k}),A+=w+l,T++,w=k=0),u[$]={left:A,top:k,col:T,width:tt,height:Z},w=Math.max(w,tt),k+=Z+l}),b+=w,g.push({width:w,height:k}),b}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:s,labels:{padding:n},rtl:o}}=this,a=Ss(o,this.left,this.width);if(this.isHorizontal()){let l=0,u=Te(s,this.left+n,this.right-this.lineWidths[l]);for(let g of e)l!==g.row&&(l=g.row,u=Te(s,this.left+n,this.right-this.lineWidths[l])),g.top+=this.top+t+n,g.left=a.leftForLtr(a.x(u),g.width),u+=g.width+n}else{let l=0,u=Te(s,this.top+t+n,this.bottom-this.columnSizes[l].height);for(let g of e)g.col!==l&&(l=g.col,u=Te(s,this.top+t+n,this.bottom-this.columnSizes[l].height)),g.top=u,g.left+=this.left+n,g.left=a.leftForLtr(a.x(g.left),g.width),u+=g.height+n}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;qt(t,this),this._draw(),Gt(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:s,ctx:n}=this,{align:o,labels:a}=t,l=bt.color,u=Ss(t.rtl,this.left,this.width),g=qe(a.font),{padding:x}=a,b=g.size,w=b/2,k;this.drawTitle(),n.textAlign=u.textAlign("left"),n.textBaseline="middle",n.lineWidth=.5,n.font=g.string;let{boxWidth:A,boxHeight:T,itemHeight:R}=wa(a,b),$=this.isHorizontal(),tt=this._computeTitleHeight();k=$?{x:Te(o,this.left+x,this.right-s[0]),y:this.top+x+tt,line:0}:{x:this.left+x,y:Te(o,this.top+tt+x,this.bottom-e[0].height),line:0},io(this.ctx,t.textDirection);let Z=R+x;this.legendItems.forEach((Q,ht)=>{n.strokeStyle=Q.fontColor,n.fillStyle=Q.fontColor;let mt=n.measureText(Q.text).width,Ct=u.textAlign(Q.textAlign||(Q.textAlign=a.textAlign)),At=A+w+mt,$t=k.x,Ht=k.y;if(u.setWidth(this.width),$?ht>0&&$t+At+x>this.right&&(Ht=k.y+=Z,k.line++,$t=k.x=Te(o,this.left+x,this.right-s[k.line])):ht>0&&Ht+Z>this.bottom&&($t=k.x=$t+e[k.line].width+x,k.line++,Ht=k.y=Te(o,this.top+tt+x,this.bottom-e[k.line].height)),function(Xt,Vt,Nt){if(isNaN(A)||A<=0||isNaN(T)||T<0)return;n.save();let Wt=q(Nt.lineWidth,1);if(n.fillStyle=q(Nt.fillStyle,l),n.lineCap=q(Nt.lineCap,"butt"),n.lineDashOffset=q(Nt.lineDashOffset,0),n.lineJoin=q(Nt.lineJoin,"miter"),n.lineWidth=Wt,n.strokeStyle=q(Nt.strokeStyle,l),n.setLineDash(q(Nt.lineDash,[])),a.usePointStyle){let Ft={radius:T*Math.SQRT2/2,pointStyle:Nt.pointStyle,rotation:Nt.rotation,borderWidth:Wt},ne=u.xPlus(Xt,A/2);wt(n,Ft,ne,Vt+w,a.pointStyleWidth&&A)}else{let Ft=Vt+Math.max((b-T)/2,0),ne=u.leftForLtr(Xt,A),Se=fs(Nt.borderRadius);n.beginPath(),Object.values(Se).some(ye=>ye!==0)?xi(n,{x:ne,y:Ft,w:A,h:T,radius:Se}):n.rect(ne,Ft,A,T),n.fill(),Wt!==0&&n.stroke()}n.restore()}(u.x($t),Ht,Q),$t=rs(Ct,$t+A+w,$?$t+At:this.right,t.rtl),function(Xt,Vt,Nt){Qe(n,Nt.text,Xt,Vt+R/2,g,{strikethrough:Nt.hidden,textAlign:u.textAlign(Nt.textAlign)})}(u.x($t),Ht,Q),$)k.x+=At+x;else if(typeof Q.text!="string"){let Xt=g.lineHeight;k.y+=ka(Q,Xt)+x}else k.y+=Z}),so(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,s=qe(e.font),n=ai(e.padding);if(!e.display)return;let o=Ss(t.rtl,this.left,this.width),a=this.ctx,l=e.position,u=s.size/2,g=n.top+u,x,b=this.left,w=this.width;if(this.isHorizontal())w=Math.max(...this.lineWidths),x=this.top+g,b=Te(t.align,b,this.right-w);else{let A=this.columnSizes.reduce((T,R)=>Math.max(T,R.height),0);x=g+Te(t.align,this.top,this.bottom-A-t.labels.padding-this._computeTitleHeight())}let k=Te(l,b,b+w);a.textAlign=o.textAlign(xe(l)),a.textBaseline="middle",a.strokeStyle=e.color,a.fillStyle=e.color,a.font=s.string,Qe(a,e.text,k,x,s)}_computeTitleHeight(){let t=this.options.title,e=qe(t.font),s=ai(t.padding);return t.display?e.lineHeight+s.height:0}_getLegendItemAt(t,e){let s,n,o;if(ot(t,this.left,this.right)&&ot(e,this.top,this.bottom)){for(o=this.legendHitBoxes,s=0;si.chart.options.color,boxWidth:40,padding:10,generateLabels(i){let t=i.data.datasets,{labels:{usePointStyle:e,pointStyle:s,textAlign:n,color:o,useBorderRadius:a,borderRadius:l}}=i.legend.options;return i._getSortedDatasetMetas().map(u=>{let g=u.controller.getStyle(e?0:void 0),x=ai(g.borderWidth);return{text:t[u.index].label,fillStyle:g.backgroundColor,fontColor:o,hidden:!u.visible,lineCap:g.borderCapStyle,lineDash:g.borderDash,lineDashOffset:g.borderDashOffset,lineJoin:g.borderJoinStyle,lineWidth:(x.width+x.height)/4,strokeStyle:g.borderColor,pointStyle:s||g.pointStyle,rotation:g.rotation,textAlign:n||g.textAlign,borderRadius:a&&(l||g.borderRadius),datasetIndex:u.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class Do extends ss{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){let s=this.options;if(this.left=0,this.top=0,!s.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;let n=H(s.text)?s.text.length:1;this._padding=ai(s.padding);let o=n*qe(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){let t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){let{top:e,left:s,bottom:n,right:o,options:a}=this,l=a.align,u,g,x,b=0;return this.isHorizontal()?(g=Te(l,s,o),x=e+t,u=o-s):(a.position==="left"?(g=s+t,x=Te(l,n,e),b=-.5*y):(g=o-t,x=Te(l,e,n),b=.5*y),u=n-e),{titleX:g,titleY:x,maxWidth:u,rotation:b}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let s=qe(e.font),n=s.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:l,rotation:u}=this._drawArgs(n);Qe(t,e.text,0,0,s,{color:e.color,maxWidth:l,rotation:u,textAlign:xe(e.align),textBaseline:"middle",translation:[o,a]})}}var xh={id:"title",_element:Do,start(i,t,e){(function(s,n){let o=new Do({ctx:s.ctx,options:n,chart:s});li.configure(s,o,n),li.addBox(s,o),s.titleBlock=o})(i,e)},stop(i){let t=i.titleBlock;li.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){let s=i.titleBlock;li.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let kn=new WeakMap;var vh={id:"subtitle",start(i,t,e){let s=new Do({ctx:i.ctx,options:e,chart:i});li.configure(i,s,e),li.addBox(i,s),kn.set(i,s)},stop(i){li.removeBox(i,kn.get(i)),kn.delete(i)},beforeUpdate(i,t,e){let s=kn.get(i);li.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let Ks={average(i){if(!i.length)return!1;let t,e,s=0,n=0,o=0;for(t=0,e=i.length;t\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",_=D.console&&(D.console.warn||D.console.log);return _&&_.call(D.console,c,m),S.apply(this,arguments)}}function q(S,O,B){var c,p=O.prototype;c=S.prototype=Object.create(p),c.constructor=S,c._super=p,B&&fe(c,B)}function Rt(S,O){return function(){return S.apply(O,arguments)}}function Ot(S,O){return typeof S==rs?S.apply(O&&O[0]||C,O):S}function ft(S,O){return S===C?O:S}function xt(S,O,B){W(Ae(O),function(c){S.addEventListener(c,B,!1)})}function jt(S,O,B){W(Ae(O),function(c){S.removeEventListener(c,B,!1)})}function te(S,O){for(;S;){if(S==O)return!0;S=S.parentNode}return!1}function ae(S,O){return S.indexOf(O)>-1}function Ae(S){return S.trim().split(/\s+/g)}function ue(S,O,B){if(S.indexOf&&!B)return S.indexOf(O);for(var c=0;cK[O]}):c.sort()),c}function Ee(S,O){for(var B,c,p=O[0].toUpperCase()+O.slice(1),m=0;m1&&!B.firstMultiple?B.firstMultiple=v(O):p===1&&(B.firstMultiple=!1);var m=B.firstInput,_=B.firstMultiple,L=_?_.center:m.center,K=O.center=P(c);O.timeStamp=Ki(),O.deltaTime=O.timeStamp-m.timeStamp,O.angle=V(L,K),O.distance=nt(L,K),d(B,O),O.offsetDirection=Y(O.deltaX,O.deltaY);var gt=F(O.deltaTime,O.deltaX,O.deltaY);O.overallVelocityX=gt.x,O.overallVelocityY=gt.y,O.overallVelocity=di(gt.x)>di(gt.y)?gt.x:gt.y,O.scale=_?kt(_.pointers,c):1,O.rotation=_?it(_.pointers,c):0,O.maxPointers=B.prevInput?O.pointers.length>B.prevInput.maxPointers?O.pointers.length:B.prevInput.maxPointers:O.pointers.length,y(B,O);var wt=S.element;te(O.srcEvent.target,wt)&&(wt=O.srcEvent.target),O.target=wt}function d(S,O){var B=O.center,c=S.offsetDelta||{},p=S.prevDelta||{},m=S.prevInput||{};O.eventType!==He&&m.eventType!==be||(p=S.prevDelta={x:m.deltaX||0,y:m.deltaY||0},c=S.offsetDelta={x:B.x,y:B.y}),O.deltaX=p.x+(B.x-c.x),O.deltaY=p.y+(B.y-c.y)}function y(S,O){var B,c,p,m,_=S.lastInterval||O,L=O.timeStamp-_.timeStamp;if(O.eventType!=Ye&&(L>Pi||_.velocity===C)){var K=O.deltaX-_.deltaX,gt=O.deltaY-_.deltaY,wt=F(L,K,gt);c=wt.x,p=wt.y,B=di(wt.x)>di(wt.y)?wt.x:wt.y,m=Y(K,gt),S.lastInterval=O}else B=_.velocity,c=_.velocityX,p=_.velocityY,m=_.direction;O.velocity=B,O.velocityX=c,O.velocityY=p,O.direction=m}function v(S){for(var O=[],B=0;Bp;)B+=S[p].clientX,c+=S[p].clientY,p++;return{x:ci(B/O),y:ci(c/O)}}function F(S,O,B){return{x:O/S||0,y:B/S||0}}function Y(S,O){return S===O?ts:di(S)>=di(O)?0>S?ki:mi:0>O?bi:Ii}function nt(S,O,B){B||(B=Ri);var c=O[B[0]]-S[B[0]],p=O[B[1]]-S[B[1]];return Math.sqrt(c*c+p*p)}function V(S,O,B){B||(B=Ri);var c=O[B[0]]-S[B[0]],p=O[B[1]]-S[B[1]];return 180*Math.atan2(p,c)/Math.PI}function it(S,O){return V(O[1],O[0],Oi)+V(S[1],S[0],Oi)}function kt(S,O){return nt(O[0],O[1],Oi)/nt(S[0],S[1],Oi)}function Et(){this.evEl=ge,this.evWin=Ue,this.pressed=!1,se.apply(this,arguments)}function ie(){this.evEl=es,this.evWin=E,se.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function Le(){this.evTarget=z,this.evWin=H,this.started=!1,se.apply(this,arguments)}function ii(S,O){var B=_e(S.touches),c=_e(S.changedTouches);return O&(be|Ye)&&(B=Oe(B.concat(c),"identifier",!0)),[B,c]}function Re(){this.evTarget=U,this.targetIds={},se.apply(this,arguments)}function We(S,O){var B=_e(S.touches),c=this.targetIds;if(O&(He|Ai)&&B.length===1)return c[B[0].identifier]=!0,[B,B];var p,m,_=_e(S.changedTouches),L=[],K=this.target;if(m=B.filter(function(gt){return te(gt.target,K)}),O===He)for(p=0;p-1&&c.splice(m,1)};setTimeout(p,G)}}function Ne(S){for(var O=S.srcEvent.clientX,B=S.srcEvent.clientY,c=0;c=m&&rt>=_)return!0}return!1}function si(S,O){this.manager=S,this.set(O)}function wi(S){if(ae(S,Lt))return Lt;var O=ae(S,Ht),B=ae(S,_t);return O&&B?Lt:O||B?O?Ht:_t:ae(S,vt)?vt:lt}function Di(){if(!st)return!1;var S={},O=D.CSS&&D.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(B){S[B]=O?D.CSS.supports("touch-action",B):!0}),S}function ve(S){this.options=fe({},this.defaults,S||{}),this.id=Ge(),this.manager=null,this.options.enable=ft(this.options.enable,!0),this.state=Dt,this.simultaneous={},this.requireFail=[]}function N(S){return S&le?"cancel":S&oe?"end":S&Qt?"move":S&Yt?"start":""}function J(S){return S==Ii?"down":S==bi?"up":S==ki?"left":S==mi?"right":""}function et(S,O){var B=O.manager;return B?B.get(S):S}function ot(){ve.apply(this,arguments)}function ut(){ot.apply(this,arguments),this.pX=null,this.pY=null}function dt(){ot.apply(this,arguments)}function yt(){ve.apply(this,arguments),this._timer=null,this._input=null}function Pt(){ot.apply(this,arguments)}function Tt(){ot.apply(this,arguments)}function Ut(){ve.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function zt(S,O){return O=O||{},O.recognizers=ft(O.recognizers,zt.defaults.preset),new ce(S,O)}function ce(S,O){this.options=fe({},zt.defaults,O||{}),this.options.inputTarget=this.options.inputTarget||S,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=S,this.input=Bt(this),this.touchAction=new si(this,this.options.touchAction),re(this,!0),W(this.options.recognizers,function(B){var c=this.add(new B[0](B[1]));B[2]&&c.recognizeWith(B[2]),B[3]&&c.requireFailure(B[3])},this)}function re(S,O){var B=S.element;if(B.style){var c;W(S.options.cssProps,function(p,m){c=Ee(B.style,m),O?(S.oldCssProps[c]=B.style[c],B.style[c]=p):B.style[c]=S.oldCssProps[c]||""}),O||(S.oldCssProps={})}}function Ce(S,O){var B=h.createEvent("Event");B.initEvent(S,!0,!0),B.gesture=O,O.target.dispatchEvent(B)}var fe,xe=["","webkit","Moz","MS","ms","o"],Te=h.createElement("div"),rs="function",ci=Math.round,di=Math.abs,Ki=Date.now;fe=typeof Object.assign!="function"?function(S){if(S===C||S===null)throw new TypeError("Cannot convert undefined or null to object");for(var O=Object(S),B=1;BL&&(O.push(S),L=O.length-1):p&(be|Ye)&&(B=!0),0>L||(O[L]=S,this.callback(this.manager,p,{pointers:O,changedPointers:[S],pointerType:m,srcEvent:S}),B&&O.splice(L,1))}});var M={touchstart:He,touchmove:Ai,touchend:be,touchcancel:Ye},z="touchstart",H="touchstart touchmove touchend touchcancel";q(Le,se,{handler:function(S){var O=M[S.type];if(O===He&&(this.started=!0),this.started){var B=ii.call(this,S,O);O&(be|Ye)&&B[0].length-B[1].length===0&&(this.started=!1),this.callback(this.manager,O,{pointers:B[0],changedPointers:B[1],pointerType:$e,srcEvent:S})}}});var j={touchstart:He,touchmove:Ai,touchend:be,touchcancel:Ye},U="touchstart touchmove touchend touchcancel";q(Re,se,{handler:function(S){var O=j[S.type],B=We.call(this,S,O);B&&this.callback(this.manager,O,{pointers:B[0],changedPointers:B[1],pointerType:$e,srcEvent:S})}});var G=2500,rt=25;q(Je,se,{handler:function(S,O,B){var c=B.pointerType==$e,p=B.pointerType==Ji;if(!(p&&B.sourceCapabilities&&B.sourceCapabilities.firesTouchEvents)){if(c)Ie.call(this,O,B);else if(p&&Ne.call(this,B))return;this.callback(S,O,B)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var ct=Ee(Te.style,"touchAction"),st=ct!==C,pt="compute",lt="auto",vt="manipulation",Lt="none",Ht="pan-x",_t="pan-y",bt=Di();si.prototype={set:function(S){S==pt&&(S=this.compute()),st&&this.manager.element.style&&bt[S]&&(this.manager.element.style[ct]=S),this.actions=S.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var S=[];return W(this.manager.recognizers,function(O){Ot(O.options.enable,[O])&&(S=S.concat(O.getTouchAction()))}),wi(S.join(" "))},preventDefaults:function(S){var O=S.srcEvent,B=S.offsetDirection;if(this.manager.session.prevented)return void O.preventDefault();var c=this.actions,p=ae(c,Lt)&&!bt[Lt],m=ae(c,_t)&&!bt[_t],_=ae(c,Ht)&&!bt[Ht];if(p){var L=S.pointers.length===1,K=S.distance<2,gt=S.deltaTime<250;if(L&&K&>)return}return _&&m?void 0:p||m&&B&pi||_&&B&yi?this.preventSrc(O):void 0},preventSrc:function(S){this.manager.session.prevented=!0,S.preventDefault()}};var Dt=1,Yt=2,Qt=4,oe=8,de=oe,le=16,Zt=32;ve.prototype={defaults:{},set:function(S){return fe(this.options,S),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(S){if(X(S,"recognizeWith",this))return this;var O=this.simultaneous;return S=et(S,this),O[S.id]||(O[S.id]=S,S.recognizeWith(this)),this},dropRecognizeWith:function(S){return X(S,"dropRecognizeWith",this)?this:(S=et(S,this),delete this.simultaneous[S.id],this)},requireFailure:function(S){if(X(S,"requireFailure",this))return this;var O=this.requireFail;return S=et(S,this),ue(O,S)===-1&&(O.push(S),S.requireFailure(this)),this},dropRequireFailure:function(S){if(X(S,"dropRequireFailure",this))return this;S=et(S,this);var O=ue(this.requireFail,S);return O>-1&&this.requireFail.splice(O,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(S){return!!this.simultaneous[S.id]},emit:function(S){function O(p){B.manager.emit(p,S)}var B=this,c=this.state;oe>c&&O(B.options.event+N(c)),O(B.options.event),S.additionalEvent&&O(S.additionalEvent),c>=oe&&O(B.options.event+N(c))},tryEmit:function(S){return this.canEmit()?this.emit(S):void(this.state=Zt)},canEmit:function(){for(var S=0;Sm?ki:mi,B=m!=this.pX,c=Math.abs(S.deltaX)):(p=_===0?ts:0>_?bi:Ii,B=_!=this.pY,c=Math.abs(S.deltaY))),S.direction=p,B&&c>O.threshold&&p&O.direction},attrTest:function(S){return ot.prototype.attrTest.call(this,S)&&(this.state&Yt||!(this.state&Yt)&&this.directionTest(S))},emit:function(S){this.pX=S.deltaX,this.pY=S.deltaY;var O=J(S.direction);O&&(S.additionalEvent=this.options.event+O),this._super.emit.call(this,S)}}),q(dt,ot,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Lt]},attrTest:function(S){return this._super.attrTest.call(this,S)&&(Math.abs(S.scale-1)>this.options.threshold||this.state&Yt)},emit:function(S){if(S.scale!==1){var O=S.scale<1?"in":"out";S.additionalEvent=this.options.event+O}this._super.emit.call(this,S)}}),q(yt,ve,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[lt]},process:function(S){var O=this.options,B=S.pointers.length===O.pointers,c=S.distanceO.time;if(this._input=S,!c||!B||S.eventType&(be|Ye)&&!p)this.reset();else if(S.eventType&He)this.reset(),this._timer=I(function(){this.state=de,this.tryEmit()},O.time,this);else if(S.eventType&be)return de;return Zt},reset:function(){clearTimeout(this._timer)},emit:function(S){this.state===de&&(S&&S.eventType&be?this.manager.emit(this.options.event+"up",S):(this._input.timeStamp=Ki(),this.manager.emit(this.options.event,this._input)))}}),q(Pt,ot,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Lt]},attrTest:function(S){return this._super.attrTest.call(this,S)&&(Math.abs(S.rotation)>this.options.threshold||this.state&Yt)}}),q(Tt,ot,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:pi|yi,pointers:1},getTouchAction:function(){return ut.prototype.getTouchAction.call(this)},attrTest:function(S){var O,B=this.options.direction;return B&(pi|yi)?O=S.overallVelocity:B&pi?O=S.overallVelocityX:B&yi&&(O=S.overallVelocityY),this._super.attrTest.call(this,S)&&B&S.offsetDirection&&S.distance>this.options.threshold&&S.maxPointers==this.options.pointers&&di(O)>this.options.velocity&&S.eventType&be},emit:function(S){var O=J(S.offsetDirection);O&&this.manager.emit(this.options.event+O,S),this.manager.emit(this.options.event,S)}}),q(Ut,ve,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[vt]},process:function(S){var O=this.options,B=S.pointers.length===O.pointers,c=S.distance{let i=0;return()=>i++})();function C(i){return i==null}function I(i){if(Array.isArray&&Array.isArray(i))return!0;let t=Object.prototype.toString.call(i);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function X(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function W(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function at(i,t){return W(i)?i:t}function q(i,t){return i===void 0?t:i}let Rt=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100:+i/t,Ot=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*t:+i;function ft(i,t,e){if(i&&typeof i.call=="function")return i.apply(e,t)}function xt(i,t,e,s){let n,o,a;if(I(i))if(o=i.length,s)for(n=o-1;n>=0;n--)t.call(e,i[n],n);else for(n=0;ni,x:i=>i.x,y:i=>i.y};function Ge(i){let t=i.split("."),e=[],s="";for(let n of t)s+=n,s.endsWith("\\")?s=s.slice(0,-1)+".":(e.push(s),s="");return e}function De(i,t){return(Ee[t]||(Ee[t]=function(s){let n=Ge(s);return o=>{for(let a of n){if(a==="")break;o=o&&o[a]}return o}}(t)))(i)}function se(i){return i.charAt(0).toUpperCase()+i.slice(1)}let Bt=i=>i!==void 0,St=i=>typeof i=="function",r=(i,t)=>{if(i.size!==t.size)return!1;for(let e of i)if(!t.has(e))return!1;return!0};function d(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}let y=Math.PI,v=2*y,P=v+y,F=Number.POSITIVE_INFINITY,Y=y/180,nt=y/2,V=y/4,it=2*y/3,kt=Math.log10,Et=Math.sign;function ie(i,t,e){return Math.abs(i-t)n-o).pop(),t}function Re(i){return!isNaN(parseFloat(i))&&isFinite(i)}function We(i,t){let e=Math.round(i);return e-t<=i&&e+t>=i}function Je(i,t,e){let s,n,o;for(s=0,n=i.length;su&&g=Math.min(t,e)-s&&i<=Math.max(t,e)+s}function ut(i,t,e){e=e||(a=>i[a]1;)s=o+n>>1,e(s)?o=s:n=s;return{lo:o,hi:n}}let dt=(i,t,e,s)=>ut(i,e,s?n=>{let o=i[n][t];return oi[n][t]ut(i,e,s=>i[s][t]>=e);function Pt(i,t,e){let s=0,n=i.length;for(;ss&&i[n-1]>e;)n--;return s>0||n{let s="_onData"+se(e),n=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,value(...o){let a=n.apply(this,o);return i._chartjs.listeners.forEach(l=>{typeof l[s]=="function"&&l[s](...o)}),a}})}))}function zt(i,t){let e=i._chartjs;if(!e)return;let s=e.listeners,n=s.indexOf(t);n!==-1&&s.splice(n,1),s.length>0||(Tt.forEach(o=>{delete i[o]}),delete i._chartjs)}function ce(i){let t=new Set(i);return t.size===i.length?i:Array.from(t)}let re=typeof window>"u"?function(i){return i()}:window.requestAnimationFrame;function Ce(i,t){let e=[],s=!1;return function(...n){e=n,s||(s=!0,re.call(window,()=>{s=!1,i.apply(t,e)}))}}function fe(i,t){let e;return function(...s){return t?(clearTimeout(e),e=setTimeout(i,t,s)):i.apply(this,s),t}}let xe=i=>i==="start"?"left":i==="end"?"right":"center",Te=(i,t,e)=>i==="start"?t:i==="end"?e:(t+e)/2,rs=(i,t,e,s)=>i===(s?"left":"right")?e:i==="center"?(t+e)/2:t;function ci(i,t,e){let s=t.length,n=0,o=s;if(i._sorted){let{iScale:a,_parsed:l}=i,u=a.axis,{min:g,max:x,minDefined:b,maxDefined:w}=a.getUserBounds();b&&(n=J(Math.min(dt(l,u,g).lo,e?s:dt(t,u,a.getPixelForValue(g)).lo),0,s-1)),o=w?J(Math.max(dt(l,a.axis,x,!0).hi+1,e?0:dt(t,u,a.getPixelForValue(x),!0).hi+1),n,s)-n:s-n}return{start:n,count:o}}function di(i){let{xScale:t,yScale:e,_scaleRanges:s}=i,n={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!s)return i._scaleRanges=n,!0;let o=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==e.min||s.ymax!==e.max;return Object.assign(s,n),o}class Ki{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,s,n){let o=e.listeners[n],a=e.duration;o.forEach(l=>l({chart:t,initial:e.initial,numSteps:a,currentStep:Math.min(s-e.start,a)}))}_refresh(){this._request||(this._running=!0,this._request=re.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((s,n)=>{if(!s.running||!s.items.length)return;let o=s.items,a,l=o.length-1,u=!1;for(;l>=0;--l)a=o[l],a._active?(a._total>s.duration&&(s.duration=a._total),a.tick(t),u=!0):(o[l]=o[o.length-1],o.pop());u&&(n.draw(),this._notify(n,s,t,"progress")),o.length||(s.running=!1,this._notify(n,s,t,"complete"),s.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){let e=this._charts,s=e.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,s)),s}listen(t,e,s){this._getAnims(t).listeners[e].push(s)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){let e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((s,n)=>Math.max(s,n._duration),0),this._refresh())}running(t){if(!this._running)return!1;let e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){let e=this._charts.get(t);if(!e||!e.items.length)return;let s=e.items,n=s.length-1;for(;n>=0;--n)s[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Be=new Ki;function Hi(i){return i+.5|0}let ni=(i,t,e)=>Math.max(Math.min(i,e),t);function _i(i){return ni(Hi(2.55*i),0,255)}function ui(i){return ni(Hi(255*i),0,255)}function gi(i){return ni(Hi(i/2.55)/100,0,1)}function Zi(i){return ni(Hi(100*i),0,100)}let $e={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Ui=[..."0123456789ABCDEF"],Ji=i=>Ui[15&i],ji=i=>Ui[(240&i)>>4]+Ui[15&i],Pi=i=>(240&i)>>4==(15&i);function He(i){var t=(e=>Pi(e.r)&&Pi(e.g)&&Pi(e.b)&&Pi(e.a))(i)?Ji:ji;return i?"#"+t(i.r)+t(i.g)+t(i.b)+((e,s)=>e<255?s(e):"")(i.a,t):void 0}let Ai=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function be(i,t,e){let s=t*Math.min(e,1-e),n=(o,a=(o+i/30)%12)=>e-s*Math.max(Math.min(a-3,9-a,1),-1);return[n(0),n(8),n(4)]}function Ye(i,t,e){let s=(n,o=(n+i/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[s(5),s(3),s(1)]}function ts(i,t,e){let s=be(i,1,.5),n;for(t+e>1&&(n=1/(t+e),t*=n,e*=n),n=0;n<3;n++)s[n]*=1-t-e,s[n]+=t;return s}function ki(i){let t=i.r/255,e=i.g/255,s=i.b/255,n=Math.max(t,e,s),o=Math.min(t,e,s),a=(n+o)/2,l,u,g;return n!==o&&(g=n-o,u=a>.5?g/(2-n-o):g/(n+o),l=function(x,b,w,k,A){return x===A?(b-w)/k+(b>16&255,l>>8&255,255&l]}return e}(),Ri.transparent=[0,0,0,0]);let t=Ri[i.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}let ds=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/,ge=i=>i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055,Ue=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function Ni(i,t,e){if(i){let s=ki(i);s[t]=Math.max(0,Math.min(s[t]+s[t]*e,t===0?360:1)),s=bi(s),i.r=s[0],i.g=s[1],i.b=s[2]}}function we(i,t){return i&&Object.assign(t||{},i)}function es(i){var t={r:0,g:0,b:0,a:255};return Array.isArray(i)?i.length>=3&&(t={r:i[0],g:i[1],b:i[2],a:255},i.length>3&&(t.a=ui(i[3]))):(t=we(i,{r:0,g:0,b:0,a:1})).a=ui(t.a),t}function E(i){return i.charAt(0)==="r"?function(t){let e=ds.exec(t),s,n,o,a=255;if(e){if(e[7]!==s){let l=+e[7];a=e[8]?_i(l):ni(255*l,0,255)}return s=+e[1],n=+e[3],o=+e[5],s=255&(e[2]?_i(s):ni(s,0,255)),n=255&(e[4]?_i(n):ni(n,0,255)),o=255&(e[6]?_i(o):ni(o,0,255)),{r:s,g:n,b:o,a}}}(i):pi(i)}class M{constructor(t){if(t instanceof M)return t;let e=typeof t,s;var n,o,a;e==="object"?s=es(t):e==="string"&&(a=(n=t).length,n[0]==="#"&&(a===4||a===5?o={r:255&17*$e[n[1]],g:255&17*$e[n[2]],b:255&17*$e[n[3]],a:a===5?17*$e[n[4]]:255}:a!==7&&a!==9||(o={r:$e[n[1]]<<4|$e[n[2]],g:$e[n[3]]<<4|$e[n[4]],b:$e[n[5]]<<4|$e[n[6]],a:a===9?$e[n[7]]<<4|$e[n[8]]:255})),s=o||Oi(t)||E(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=we(this._rgb);return t&&(t.a=gi(t.a)),t}set rgb(t){this._rgb=es(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${gi(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?He(this._rgb):void 0}hslString(){return this._valid?function(t){if(!t)return;let e=ki(t),s=e[0],n=Zi(e[1]),o=Zi(e[2]);return t.a<255?`hsla(${s}, ${n}%, ${o}%, ${gi(t.a)})`:`hsl(${s}, ${n}%, ${o}%)`}(this._rgb):void 0}mix(t,e){if(t){let s=this.rgb,n=t.rgb,o,a=e===o?.5:e,l=2*a-1,u=s.a-n.a,g=((l*u==-1?l:(l+u)/(1+l*u))+1)/2;o=1-g,s.r=255&g*s.r+o*n.r+.5,s.g=255&g*s.g+o*n.g+.5,s.b=255&g*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,this.rgb=s}return this}interpolate(t,e){return t&&(this._rgb=function(s,n,o){let a=Ue(gi(s.r)),l=Ue(gi(s.g)),u=Ue(gi(s.b));return{r:ui(ge(a+o*(Ue(gi(n.r))-a))),g:ui(ge(l+o*(Ue(gi(n.g))-l))),b:ui(ge(u+o*(Ue(gi(n.b))-u))),a:s.a+o*(n.a-s.a)}}(this._rgb,t._rgb,e)),this}clone(){return new M(this.rgb)}alpha(t){return this._rgb.a=ui(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){let t=this._rgb,e=Hi(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){let t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Ni(this._rgb,2,t),this}darken(t){return Ni(this._rgb,2,-t),this}saturate(t){return Ni(this._rgb,1,t),this}desaturate(t){return Ni(this._rgb,1,-t),this}rotate(t){return function(e,s){var n=ki(e);n[0]=Ii(n[0]+s),n=bi(n),e.r=n[0],e.g=n[1],e.b=n[2]}(this._rgb,t),this}}function z(i){if(i&&typeof i=="object"){let t=i.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function H(i){return z(i)?i:new M(i)}function j(i){return z(i)?i:new M(i).saturate(.5).darken(.1).hexString()}let U=["x","y","borderWidth","radius","tension"],G=["color","borderColor","backgroundColor"],rt=new Map;function ct(i,t,e){return function(s,n){n=n||{};let o=s+JSON.stringify(n),a=rt.get(o);return a||(a=new Intl.NumberFormat(s,n),rt.set(o,a)),a}(t,e).format(i)}let st={values:i=>I(i)?i:""+i,numeric(i,t,e){if(i===0)return"0";let s=this.chart.options.locale,n,o=i;if(e.length>1){let g=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(g<1e-4||g>1e15)&&(n="scientific"),o=function(x,b){let w=b.length>3?b[2].value-b[1].value:b[1].value-b[0].value;return Math.abs(w)>=1&&x!==Math.floor(x)&&(w=x-Math.floor(x)),w}(i,e)}let a=kt(Math.abs(o)),l=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),u={notation:n,minimumFractionDigits:l,maximumFractionDigits:l};return Object.assign(u,this.options.ticks.format),ct(i,s,u)},logarithmic(i,t,e){if(i===0)return"0";let s=e[t].significand||i/Math.pow(10,Math.floor(kt(i)));return[1,2,3,5,10,15].includes(s)||t>.8*e.length?st.numeric.call(this,i,t,e):""}};var pt={formatters:st};let lt=Object.create(null),vt=Object.create(null);function Lt(i,t){if(!t)return i;let e=t.split(".");for(let s=0,n=e.length;ss.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,n)=>j(n.backgroundColor),this.hoverBorderColor=(s,n)=>j(n.borderColor),this.hoverColor=(s,n)=>j(n.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return Ht(this,t,e)}get(t){return Lt(this,t)}describe(t,e){return Ht(vt,t,e)}override(t,e){return Ht(lt,t,e)}route(t,e,s,n){let o=Lt(this,t),a=Lt(this,s),l="_"+e;Object.defineProperties(o,{[l]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let u=this[l],g=a[n];return X(u)?Object.assign({},g,u):q(u,g)},set(u){this[l]=u}}})}apply(t){t.forEach(e=>e(this))}}var bt=new _t({_scriptable:i=>!i.startsWith("on"),_indexable:i=>i!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(i){i.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),i.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),i.set("animations",{colors:{type:"color",properties:G},numbers:{type:"number",properties:U}}),i.describe("animations",{_fallback:"animation"}),i.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(i){i.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(i){i.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:pt.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),i.route("scale.ticks","color","","color"),i.route("scale.grid","color","","borderColor"),i.route("scale.border","color","","borderColor"),i.route("scale.title","color","","color"),i.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),i.describe("scales",{_fallback:"scale"}),i.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}]);function Dt(){return typeof window<"u"&&typeof document<"u"}function Yt(i){let t=i.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function Qt(i,t,e){let s;return typeof i=="string"?(s=parseInt(i,10),i.indexOf("%")!==-1&&(s=s/100*t.parentNode[e])):s=i,s}let oe=i=>i.ownerDocument.defaultView.getComputedStyle(i,null);function de(i,t){return oe(i).getPropertyValue(t)}let le=["top","right","bottom","left"];function Zt(i,t,e){let s={};e=e?"-"+e:"";for(let n=0;n<4;n++){let o=le[n];s[o]=parseFloat(i[t+"-"+o+e])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}let Me=(i,t,e)=>(i>0||t>0)&&(!e||!e.shadowRoot);function me(i,t){if("native"in i)return i;let{canvas:e,currentDevicePixelRatio:s}=t,n=oe(e),o=n.boxSizing==="border-box",a=Zt(n,"padding"),l=Zt(n,"border","width"),{x:u,y:g,box:x}=function(T,R){let $=T.touches,tt=$&&$.length?$[0]:T,{offsetX:Z,offsetY:Q}=tt,ht,mt,Ct=!1;if(Me(Z,Q,T.target))ht=Z,mt=Q;else{let At=R.getBoundingClientRect();ht=tt.clientX-At.left,mt=tt.clientY-At.top,Ct=!0}return{x:ht,y:mt,box:Ct}}(i,e),b=a.left+(x&&l.left),w=a.top+(x&&l.top),{width:k,height:A}=t;return o&&(k-=a.width+l.width,A-=a.height+l.height),{x:Math.round((u-b)/k*e.width/s),y:Math.round((g-w)/A*e.height/s)}}let Pe=i=>Math.round(10*i)/10;function S(i,t,e,s){let n=oe(i),o=Zt(n,"margin"),a=Qt(n.maxWidth,i,"clientWidth")||F,l=Qt(n.maxHeight,i,"clientHeight")||F,u=function(b,w,k){let A,T;if(w===void 0||k===void 0){let R=Yt(b);if(R){let $=R.getBoundingClientRect(),tt=oe(R),Z=Zt(tt,"border","width"),Q=Zt(tt,"padding");w=$.width-Q.width-Z.width,k=$.height-Q.height-Z.height,A=Qt(tt.maxWidth,R,"clientWidth"),T=Qt(tt.maxHeight,R,"clientHeight")}else w=b.clientWidth,k=b.clientHeight}return{width:w,height:k,maxWidth:A||F,maxHeight:T||F}}(i,t,e),{width:g,height:x}=u;if(n.boxSizing==="content-box"){let b=Zt(n,"border","width"),w=Zt(n,"padding");g-=w.width+b.width,x-=w.height+b.height}return g=Math.max(0,g-o.width),x=Math.max(0,s?g/s:x-o.height),g=Pe(Math.min(g,a,u.maxWidth)),x=Pe(Math.min(x,l,u.maxHeight)),g&&!x&&(x=Pe(g/2)),(t!==void 0||e!==void 0)&&s&&u.height&&x>u.height&&(x=u.height,g=Pe(Math.floor(x*s))),{width:g,height:x}}function O(i,t,e){let s=t||1,n=Math.floor(i.height*s),o=Math.floor(i.width*s);i.height=Math.floor(i.height),i.width=Math.floor(i.width);let a=i.canvas;return a.style&&(e||!a.style.height&&!a.style.width)&&(a.style.height=`${i.height}px`,a.style.width=`${i.width}px`),(i.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(i.currentDevicePixelRatio=s,a.height=n,a.width=o,i.ctx.setTransform(s,0,0,s,0,0),!0)}let B=function(){let i=!1;try{let t={get passive(){return i=!0,!1}};Dt()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return i}();function c(i,t){let e=de(i,t),s=e&&e.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function p(i){return!i||C(i.size)||C(i.family)?null:(i.style?i.style+" ":"")+(i.weight?i.weight+" ":"")+i.size+"px "+i.family}function m(i,t,e,s,n){let o=t[n];return o||(o=t[n]=i.measureText(n).width,e.push(n)),o>s&&(s=o),s}function _(i,t,e,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==t&&(n=s.data={},o=s.garbageCollect=[],s.font=t),i.save(),i.font=t;let a=0,l=e.length,u,g,x,b,w;for(u=0;ue.length){for(u=0;u0&&i.stroke()}}function Mt(i,t,e){return e=e||.5,!t||i&&i.x>t.left-e&&i.xt.top-e&&i.y0&&o.strokeColor!=="",u,g;for(i.save(),i.font=n.string,function(x,b){b.translation&&x.translate(b.translation[0],b.translation[1]),C(b.rotation)||x.rotate(b.rotation),b.color&&(x.fillStyle=b.color),b.textAlign&&(x.textAlign=b.textAlign),b.textBaseline&&(x.textBaseline=b.textBaseline)}(i,o),u=0;ui[0]){let o=e||i;s===void 0&&(s=$s("_fallback",i));let a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:o,_fallback:s,_getTarget:n,override:l=>Ke([l,...i],t,o,s)};return new Proxy(a,{deleteProperty:(l,u)=>(delete l[u],delete l._keys,delete i[0][u],!0),get:(l,u)=>je(l,u,()=>function(g,x,b,w){let k;for(let A of x)if(k=$s(fi(A,g),b),k!==void 0)return vi(g,k)?_s(b,w,g,k):k}(u,t,i,l)),getOwnPropertyDescriptor:(l,u)=>Reflect.getOwnPropertyDescriptor(l._scopes[0],u),getPrototypeOf:()=>Reflect.getPrototypeOf(i[0]),has:(l,u)=>Os(l).includes(u),ownKeys:l=>Os(l),set(l,u,g){let x=l._storage||(l._storage=n());return l[u]=x[u]=g,delete l._keys,!0}})}function ri(i,t,e,s){let n={_cacheable:!1,_proxy:i,_context:t,_subProxy:e,_stack:new Set,_descriptors:ze(i,s),setContext:o=>ri(i,o,e,s),override:o=>ri(i.override(o),t,e,s)};return new Proxy(n,{deleteProperty:(o,a)=>(delete o[a],delete i[a],!0),get:(o,a,l)=>je(o,a,()=>function(u,g,x){let{_proxy:b,_context:w,_subProxy:k,_descriptors:A}=u,T=b[g];return St(T)&&A.isScriptable(g)&&(T=function(R,$,tt,Z){let{_proxy:Q,_context:ht,_subProxy:mt,_stack:Ct}=tt;if(Ct.has(R))throw new Error("Recursion detected: "+Array.from(Ct).join("->")+"->"+R);Ct.add(R);let At=$(ht,mt||Z);return Ct.delete(R),vi(R,At)&&(At=_s(Q._scopes,Q,R,At)),At}(g,T,u,x)),I(T)&&T.length&&(T=function(R,$,tt,Z){let{_proxy:Q,_context:ht,_subProxy:mt,_descriptors:Ct}=tt;if(ht.index!==void 0&&Z(R))return $[ht.index%$.length];if(X($[0])){let At=$,$t=Q._scopes.filter(It=>It!==At);$=[];for(let It of At){let Xt=_s($t,Q,R,It);$.push(ri(Xt,ht,mt&&mt[R],Ct))}}return $}(g,T,u,A.isIndexable)),vi(g,T)&&(T=ri(T,w,k&&k[g],A)),T}(o,a,l)),getOwnPropertyDescriptor:(o,a)=>o._descriptors.allKeys?Reflect.has(i,a)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(i,a),getPrototypeOf:()=>Reflect.getPrototypeOf(i),has:(o,a)=>Reflect.has(i,a),ownKeys:()=>Reflect.ownKeys(i),set:(o,a,l)=>(i[a]=l,delete o[a],!0)})}function ze(i,t={scriptable:!0,indexable:!0}){let{_scriptable:e=t.scriptable,_indexable:s=t.indexable,_allKeys:n=t.allKeys}=i;return{allKeys:n,scriptable:e,indexable:s,isScriptable:St(e)?e:()=>e,isIndexable:St(s)?s:()=>s}}let fi=(i,t)=>i?i+se(t):t,vi=(i,t)=>X(t)&&i!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function je(i,t,e){if(Object.prototype.hasOwnProperty.call(i,t))return i[t];let s=e();return i[t]=s,s}function $i(i,t,e){return St(i)?i(t,e):i}let is=(i,t)=>i===!0?t:typeof i=="string"?De(t,i):void 0;function ln(i,t,e,s,n){for(let o of t){let a=is(e,o);if(a){i.add(a);let l=$i(a._fallback,e,n);if(l!==void 0&&l!==e&&l!==s)return l}else if(a===!1&&s!==void 0&&e!==s)return null}return!1}function _s(i,t,e,s){let n=t._rootScopes,o=$i(t._fallback,e,s),a=[...i,...n],l=new Set;l.add(s);let u=ks(l,a,e,o||e,s);return u!==null&&(o===void 0||o===e||(u=ks(l,a,o,u,s),u!==null))&&Ke(Array.from(l),[""],n,o,()=>function(g,x,b){let w=g._getTarget();x in w||(w[x]={});let k=w[x];return I(k)&&X(b)?b:k||{}}(t,e,s))}function ks(i,t,e,s,n){for(;e;)e=ln(i,t,e,s,n);return e}function $s(i,t){for(let e of t){if(!e)continue;let s=e[i];if(s!==void 0)return s}}function Os(i){let t=i._keys;return t||(t=i._keys=function(e){let s=new Set;for(let n of e)for(let o of Object.keys(n).filter(a=>!a.startsWith("_")))s.add(o);return Array.from(s)}(i._scopes)),t}function zs(i,t,e,s){let{iScale:n}=i,{key:o="r"}=this._parsing,a=new Array(s),l,u,g,x;for(l=0,u=s;lti==="x"?"y":"x";function us(i,t,e,s){let n=i.skip?t:i,o=t,a=e.skip?t:e,l=wi(o,n),u=wi(a,o),g=l/(l+u),x=u/(l+u);g=isNaN(g)?0:g,x=isNaN(x)?0:x;let b=s*g,w=s*x;return{previous:{x:o.x-b*(a.x-n.x),y:o.y-b*(a.y-n.y)},next:{x:o.x+w*(a.x-n.x),y:o.y+w*(a.y-n.y)}}}function Ms(i,t="x"){let e=Ws(t),s=i.length,n=Array(s).fill(0),o=Array(s),a,l,u,g=Fi(i,0);for(a=0;a!g.skip)),t.cubicInterpolationMode==="monotone")Ms(i,n);else{let g=s?i[i.length-1]:i[0];for(o=0,a=i.length;oi===0||i===1,Wo=(i,t,e)=>-Math.pow(2,10*(i-=1))*Math.sin((i-t)*v/e),Bo=(i,t,e)=>Math.pow(2,-10*i)*Math.sin((i-t)*v/e)+1,Ls={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>-i*(i-2),easeInOutQuad:i=>(i/=.5)<1?.5*i*i:-.5*(--i*(i-2)-1),easeInCubic:i=>i*i*i,easeOutCubic:i=>(i-=1)*i*i+1,easeInOutCubic:i=>(i/=.5)<1?.5*i*i*i:.5*((i-=2)*i*i+2),easeInQuart:i=>i*i*i*i,easeOutQuart:i=>-((i-=1)*i*i*i-1),easeInOutQuart:i=>(i/=.5)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2),easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>(i-=1)*i*i*i*i+1,easeInOutQuint:i=>(i/=.5)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2),easeInSine:i=>1-Math.cos(i*nt),easeOutSine:i=>Math.sin(i*nt),easeInOutSine:i=>-.5*(Math.cos(y*i)-1),easeInExpo:i=>i===0?0:Math.pow(2,10*(i-1)),easeOutExpo:i=>i===1?1:1-Math.pow(2,-10*i),easeInOutExpo:i=>gs(i)?i:i<.5?.5*Math.pow(2,10*(2*i-1)):.5*(2-Math.pow(2,-10*(2*i-1))),easeInCirc:i=>i>=1?i:-(Math.sqrt(1-i*i)-1),easeOutCirc:i=>Math.sqrt(1-(i-=1)*i),easeInOutCirc:i=>(i/=.5)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1),easeInElastic:i=>gs(i)?i:Wo(i,.075,.3),easeOutElastic:i=>gs(i)?i:Bo(i,.075,.3),easeInOutElastic(i){return gs(i)?i:i<.5?.5*Wo(2*i,.1125,.45):.5+.5*Bo(2*i-1,.1125,.45)},easeInBack(i){return i*i*((1.70158+1)*i-1.70158)},easeOutBack(i){return(i-=1)*i*((1.70158+1)*i+1.70158)+1},easeInOutBack(i){let t=1.70158;return(i/=.5)<1?i*i*((1+(t*=1.525))*i-t)*.5:.5*((i-=2)*i*((1+(t*=1.525))*i+t)+2)},easeInBounce:i=>1-Ls.easeOutBounce(1-i),easeOutBounce(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},easeInOutBounce:i=>i<.5?.5*Ls.easeInBounce(2*i):.5*Ls.easeOutBounce(2*i-1)+.5};function ps(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:i.y+e*(t.y-i.y)}}function Uo(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:s==="middle"?e<.5?i.y:t.y:s==="after"?e<1?i.y:t.y:e>0?t.y:i.y}}function jo(i,t,e,s){let n={x:i.cp2x,y:i.cp2y},o={x:t.cp1x,y:t.cp1y},a=ps(i,n,e),l=ps(n,o,e),u=ps(o,t,e),g=ps(a,l,e),x=ps(l,u,e);return ps(g,x,e)}let hl=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,cl=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Vo(i,t){let e=(""+i).match(hl);if(!e||e[1]==="normal")return 1.2*t;switch(i=+e[2],e[3]){case"px":return i;case"%":i/=100}return t*i}let dl=i=>+i||0;function hn(i,t){let e={},s=X(t),n=s?Object.keys(t):t,o=X(i)?s?a=>q(i[a],i[t[a]]):a=>i[a]:()=>i;for(let a of n)e[a]=dl(o(a));return e}function eo(i){return hn(i,{top:"y",right:"x",bottom:"y",left:"x"})}function fs(i){return hn(i,["topLeft","topRight","bottomLeft","bottomRight"])}function ai(i){let t=eo(i);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function qe(i,t){i=i||{},t=t||bt.font;let e=q(i.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let s=q(i.style,t.style);s&&!(""+s).match(cl)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);let n={family:q(i.family,t.family),lineHeight:Vo(q(i.lineHeight,t.lineHeight),e),size:e,style:s,weight:q(i.weight,t.weight),string:""};return n.string=p(n),n}function Hs(i,t,e,s){let n,o,a,l=!0;for(n=0,o=i.length;ne&&l===0?0:l+u;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function as(i,t){return Object.assign(Object.create(i),t)}function Ss(i,t,e){return i?function(s,n){return{x:o=>s+s+n-o,setWidth(o){n=o},textAlign:o=>o==="center"?o:o==="right"?"left":"right",xPlus:(o,a)=>o-a,leftForLtr:(o,a)=>o-a}}(t,e):{x:s=>s,setWidth(s){},textAlign:s=>s,xPlus:(s,n)=>s+n,leftForLtr:(s,n)=>s}}function io(i,t){let e,s;t!=="ltr"&&t!=="rtl"||(e=i.canvas.style,s=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),i.prevTextDirection=s)}function so(i,t){t!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",t[0],t[1]))}function qo(i){return i==="angle"?{between:N,compare:Di,normalize:ve}:{between:ot,compare:(t,e)=>t-e,normalize:t=>t}}function Xo({start:i,end:t,count:e,loop:s,style:n}){return{start:i%e,end:t%e,loop:s&&(t-i+1)%e==0,style:n}}function no(i,t,e){if(!e)return[i];let{property:s,start:n,end:o}=e,a=t.length,{compare:l,between:u,normalize:g}=qo(s),{start:x,end:b,loop:w,style:k}=function(mt,Ct,At){let{property:$t,start:It,end:Xt}=At,{between:Vt,normalize:Nt}=qo($t),Wt=Ct.length,Ft,ne,{start:Se,end:ye,loop:hi}=mt;if(hi){for(Se+=Wt,ye+=Wt,Ft=0,ne=Wt;Fttt||u(n,$,T)&&l(n,$)!==0,ht=()=>!tt||l(o,T)===0||u(o,$,T);for(let mt=x,Ct=x;mt<=b;++mt)R=t[mt%a],R.skip||(T=g(R[s]),T!==$&&(tt=u(T,n,o),Z===null&&Q()&&(Z=l(T,n)===0?mt:Ct),Z!==null&&ht()&&(A.push(Xo({start:Z,end:mt,loop:w,count:a,style:k})),Z=null),Ct=mt,$=T));return Z!==null&&A.push(Xo({start:Z,end:b,loop:w,count:a,style:k})),A}function oo(i,t){let e=[],s=i.segments;for(let n=0;nw&&u[k%g].skip;)k--;return k%=g,{start:w,end:k}}(e,n,o,s);return s===!0?Qo(i,[{start:a,end:l,loop:o}],e,t):Qo(i,function(u,g,x,b){let w=u.length,k=[],A,T=g,R=u[g];for(A=g+1;A<=x;++A){let $=u[A%w];$.skip||$.stop?R.skip||(b=!1,k.push({start:g%w,end:(A-1)%w,loop:b}),g=T=$.stop?A:null):(T=A,R.skip&&(g=A)),R=$}return T!==null&&k.push({start:g%w,end:T%w,loop:b}),k}(e,a,l{u[a](t[e],n)&&(o.push({element:u,datasetIndex:g,index:x}),l=l||u.inRange(t.x,t.y,n))}),s&&!l?[]:o}var Jo={evaluateInteractionItems:Bs,modes:{index(i,t,e,s){let n=me(t,i),o=e.axis||"x",a=e.includeInvisible||!1,l=e.intersect?ro(i,n,o,s,a):ao(i,n,o,!1,s,a),u=[];return l.length?(i.getSortedVisibleDatasetMetas().forEach(g=>{let x=l[0].index,b=g.data[x];b&&!b.skip&&u.push({element:b,datasetIndex:g.index,index:x})}),u):[]},dataset(i,t,e,s){let n=me(t,i),o=e.axis||"xy",a=e.includeInvisible||!1,l=e.intersect?ro(i,n,o,s,a):ao(i,n,o,!1,s,a);if(l.length>0){let u=l[0].datasetIndex,g=i.getDatasetMeta(u).data;l=[];for(let x=0;xro(i,me(t,i),e.axis||"xy",s,e.includeInvisible||!1),nearest(i,t,e,s){let n=me(t,i),o=e.axis||"xy",a=e.includeInvisible||!1;return ao(i,n,o,e.intersect,s,a)},x:(i,t,e,s)=>Zo(i,me(t,i),"x",e.intersect,s),y:(i,t,e,s)=>Zo(i,me(t,i),"y",e.intersect,s)}};let tr=["left","top","right","bottom"];function Us(i,t){return i.filter(e=>e.pos===t)}function er(i,t){return i.filter(e=>tr.indexOf(e.pos)===-1&&e.box.axis===t)}function js(i,t){return i.sort((e,s)=>{let n=t?s:e,o=t?e:s;return n.weight===o.weight?n.index-o.index:n.weight-o.weight})}function ml(i,t){let e=function(u){let g={};for(let x of u){let{stack:b,pos:w,stackWeight:k}=x;if(!b||!tr.includes(w))continue;let A=g[b]||(g[b]={count:0,placed:0,weight:0,size:0});A.count++,A.weight+=k}return g}(i),{vBoxMaxWidth:s,hBoxMaxHeight:n}=t,o,a,l;for(o=0,a=i.length;o{o[a]=Math.max(t[a],e[a])}),o}return s(i?["left","right"]:["top","bottom"])}function Vs(i,t,e,s){let n=[],o,a,l,u,g,x;for(o=0,a=i.length,g=0;oAt.box.fullSize),!0),tt=js(Us(R,"left"),!0),Z=js(Us(R,"right")),Q=js(Us(R,"top"),!0),ht=js(Us(R,"bottom")),mt=er(R,"x"),Ct=er(R,"y");return{fullSize:$,leftAndTop:tt.concat(Q),rightAndBottom:Z.concat(Ct).concat(ht).concat(mt),chartArea:Us(R,"chartArea"),vertical:tt.concat(Z).concat(Ct),horizontal:Q.concat(ht).concat(mt)}}(i.boxes),u=l.vertical,g=l.horizontal;xt(i.boxes,T=>{typeof T.beforeLayout=="function"&&T.beforeLayout()});let x=u.reduce((T,R)=>R.box.options&&R.box.options.display===!1?T:T+1,0)||1,b=Object.freeze({outerWidth:t,outerHeight:e,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/x,hBoxMaxHeight:a/2}),w=Object.assign({},n);sr(w,ai(s));let k=Object.assign({maxPadding:w,w:o,h:a,x:n.left,y:n.top},n),A=ml(u.concat(g),b);Vs(l.fullSize,k,b,A),Vs(u,k,b,A),Vs(g,k,b,A)&&Vs(u,k,b,A),function(T){let R=T.maxPadding;function $(tt){let Z=Math.max(R[tt]-T[tt],0);return T[tt]+=Z,Z}T.y+=$("top"),T.x+=$("left"),$("right"),$("bottom")}(k),nr(l.leftAndTop,k,b,A),k.x+=k.w,k.y+=k.h,nr(l.rightAndBottom,k,b,A),i.chartArea={left:k.left,top:k.top,right:k.left+k.w,bottom:k.top+k.h,height:k.h,width:k.w},xt(l.chartArea,T=>{let R=T.box;Object.assign(R,i.chartArea),R.update(k.w,k.h,{left:0,top:0,right:0,bottom:0})})}};class lo{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,s){}removeEventListener(t,e,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,s,n){return e=Math.max(0,e||t.width),s=s||t.height,{width:e,height:Math.max(0,n?Math.floor(e/n):s)}}isAttached(t){return!0}updateConfig(t){}}class or extends lo{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}let dn="$chartjs",xl={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},rr=i=>i===null||i==="",ar=!!B&&{passive:!0};function vl(i,t,e){i.canvas.removeEventListener(t,e,ar)}function un(i,t){for(let e of i)if(e===t||e.contains(t))return!0}function wl(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let l of o)a=a||un(l.addedNodes,s),a=a&&!un(l.removedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}function _l(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let l of o)a=a||un(l.removedNodes,s),a=a&&!un(l.addedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}let Ys=new Map,lr=0;function hr(){let i=window.devicePixelRatio;i!==lr&&(lr=i,Ys.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function kl(i,t,e){let s=i.canvas,n=s&&Yt(s);if(!n)return;let o=Ce((l,u)=>{let g=n.clientWidth;e(l,u),g{let u=l[0],g=u.contentRect.width,x=u.contentRect.height;g===0&&x===0||o(g,x)});return a.observe(n),function(l,u){Ys.size||window.addEventListener("resize",hr),Ys.set(l,u)}(i,o),a}function ho(i,t,e){e&&e.disconnect(),t==="resize"&&function(s){Ys.delete(s),Ys.size||window.removeEventListener("resize",hr)}(i)}function Ml(i,t,e){let s=i.canvas,n=Ce(o=>{i.ctx!==null&&e(function(a,l){let u=xl[a.type]||a.type,{x:g,y:x}=me(a,l);return{type:u,chart:l,native:a,x:g!==void 0?g:null,y:x!==void 0?x:null}}(o,i))},i);return function(o,a,l){o.addEventListener(a,l,ar)}(s,t,n),n}class cr extends lo{acquireContext(t,e){let s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?(function(n,o){let a=n.style,l=n.getAttribute("height"),u=n.getAttribute("width");if(n[dn]={initial:{height:l,width:u,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",a.boxSizing=a.boxSizing||"border-box",rr(u)){let g=c(n,"width");g!==void 0&&(n.width=g)}if(rr(l))if(n.style.height==="")n.height=n.width/(o||2);else{let g=c(n,"height");g!==void 0&&(n.height=g)}}(t,e),s):null}releaseContext(t){let e=t.canvas;if(!e[dn])return!1;let s=e[dn].initial;["height","width"].forEach(o=>{let a=s[o];C(a)?e.removeAttribute(o):e.setAttribute(o,a)});let n=s.style||{};return Object.keys(n).forEach(o=>{e.style[o]=n[o]}),e.width=e.width,delete e[dn],!0}addEventListener(t,e,s){this.removeEventListener(t,e);let n=t.$proxies||(t.$proxies={}),o={attach:wl,detach:_l,resize:kl}[e]||Ml;n[e]=o(t,e,s)}removeEventListener(t,e){let s=t.$proxies||(t.$proxies={}),n=s[e];n&&(({attach:ho,detach:ho,resize:ho}[e]||vl)(t,e,n),s[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,s,n){return S(t,e,s,n)}isAttached(t){let e=Yt(t);return!(!e||!e.isConnected)}}function dr(i){return!Dt()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?or:cr}var ur=Object.freeze({__proto__:null,BasePlatform:lo,BasicPlatform:or,DomPlatform:cr,_detectPlatform:dr});let gr="transparent",Sl={boolean:(i,t,e)=>e>.5?t:i,color(i,t,e){let s=H(i||gr),n=s.valid&&H(t||gr);return n&&n.valid?n.mix(s,e).hexString():t},number:(i,t,e)=>i+(t-i)*e};class pr{constructor(t,e,s,n){let o=e[s];n=Hs([t.to,n,o,t.from]);let a=Hs([t.from,o,n]);this._active=!0,this._fn=t.fn||Sl[t.type||typeof a],this._easing=Ls[t.easing]||Ls.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=s,this._from=a,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,s){if(this._active){this._notify(!1);let n=this._target[this._prop],o=s-this._start,a=this._duration-o;this._start=s,this._duration=Math.floor(Math.max(a,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Hs([t.to,e,n,t.from]),this._from=Hs([t.from,n,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let e=t-this._start,s=this._duration,n=this._prop,o=this._from,a=this._loop,l=this._to,u;if(this._active=o!==l&&(a||e1?2-u:u,u=this._easing(Math.min(1,Math.max(0,u))),this._target[n]=this._fn(o,l,u))}wait(){let t=this._promises||(this._promises=[]);return new Promise((e,s)=>{t.push({res:e,rej:s})})}_notify(t){let e=t?"res":"rej",s=this._promises||[];for(let n=0;n{let o=t[n];if(!X(o))return;let a={};for(let l of e)a[l]=o[l];(I(o.properties)&&o.properties||[n]).forEach(l=>{l!==n&&s.has(l)||s.set(l,a)})})}_animateOptions(t,e){let s=e.options,n=function(a,l){if(!l)return;let u=a.options;return u?(u.$shared&&(a.options=u=Object.assign({},u,{$shared:!1,$animations:{}})),u):void(a.options=l)}(t,s);if(!n)return[];let o=this._createAnimations(n,s);return s.$shared&&function(a,l){let u=[],g=Object.keys(l);for(let x=0;x{t.options=s},()=>{}),o}_createAnimations(t,e){let s=this._properties,n=[],o=t.$animations||(t.$animations={}),a=Object.keys(e),l=Date.now(),u;for(u=a.length-1;u>=0;--u){let g=a[u];if(g.charAt(0)==="$")continue;if(g==="options"){n.push(...this._animateOptions(t,e));continue}let x=e[g],b=o[g],w=s.get(g);if(b){if(w&&b.active()){b.update(w,x,l);continue}b.cancel()}w&&w.duration?(o[g]=b=new pr(w,t,g,x),n.push(b)):t[g]=x}return n}update(t,e){if(this._properties.size===0)return void Object.assign(t,e);let s=this._createAnimations(t,e);return s.length?(Be.add(this._chart,s),!0):void 0}}function fr(i,t){let e=i&&i.options||{},s=e.reverse,n=e.min===void 0?t:0,o=e.max===void 0?t:0;return{start:s?o:n,end:s?n:o}}function mr(i,t){let e=[],s=i._getSortedDatasetMetas(t),n,o;for(n=0,o=s.length;n0||!e&&o<0)return n.index}return null}function vr(i,t){let{chart:e,_cachedMeta:s}=i,n=e._stacks||(e._stacks={}),{iScale:o,vScale:a,index:l}=s,u=o.axis,g=a.axis,x=function(k,A,T){return`${k.id}.${A.id}.${T.stack||T.type}`}(o,a,s),b=t.length,w;for(let k=0;ke[s].axis===t).shift()}function qs(i,t){let e=i.controller.index,s=i.vScale&&i.vScale.axis;if(s){t=t||i._parsed;for(let n of t){let o=n._stacks;if(!o||o[s]===void 0||o[s][e]===void 0)return;delete o[s][e],o[s]._visualValues!==void 0&&o[s]._visualValues[e]!==void 0&&delete o[s]._visualValues[e]}}}let go=i=>i==="reset"||i==="none",wr=(i,t)=>t?i:Object.assign({},i);class ls{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=yr(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&qs(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,s=this.getDataset(),n=(b,w,k,A)=>b==="x"?w:b==="r"?A:k,o=e.xAxisID=q(s.xAxisID,uo(t,"x")),a=e.yAxisID=q(s.yAxisID,uo(t,"y")),l=e.rAxisID=q(s.rAxisID,uo(t,"r")),u=e.indexAxis,g=e.iAxisID=n(u,o,a,l),x=e.vAxisID=n(u,a,o,l);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(a),e.rScale=this.getScaleForId(l),e.iScale=this.getScaleForId(g),e.vScale=this.getScaleForId(x)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){let e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){let t=this._cachedMeta;this._data&&zt(this._data,this),t._stacked&&qs(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),s=this._data;if(X(e))this._data=function(n){let o=Object.keys(n),a=new Array(o.length),l,u,g;for(l=0,u=o.length;l0&&s._parsed[t-1];if(this._parsing===!1)s._parsed=n,s._sorted=!0,x=n;else{x=I(n[t])?this.parseArrayData(s,n,t,e):X(n[t])?this.parseObjectData(s,n,t,e):this.parsePrimitiveData(s,n,t,e);let k=()=>g[l]===null||w&&g[l]T&&!R.hidden&&R._stacked&&{keys:mr($,!0),values:null})(e,s,this.chart),g={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:x,max:b}=function(T){let{min:R,max:$,minDefined:tt,maxDefined:Z}=T.getUserBounds();return{min:tt?R:Number.NEGATIVE_INFINITY,max:Z?$:Number.POSITIVE_INFINITY}}(l),w,k;function A(){k=n[w];let T=k[l.axis];return!W(k[t.axis])||x>T||b=0;--w)if(!A()){this.updateRangeFromParsed(g,t,k,u);break}}return g}getAllParsedValues(t){let e=this._cachedMeta._parsed,s=[],n,o,a;for(n=0,o=e.length;n=0&&tthis.getContext(s,n,e),b);return A.$shared&&(A.$shared=u,o[a]=Object.freeze(wr(A,u))),A}_resolveAnimations(t,e,s){let n=this.chart,o=this._cachedDataOpts,a=`animation-${e}`,l=o[a];if(l)return l;let u;if(n.options.animation!==!1){let x=this.chart.config,b=x.datasetAnimationScopeKeys(this._type,e),w=x.getOptionScopes(this.getDataset(),b);u=x.createResolver(w,this.getContext(t,s,e))}let g=new co(n,u&&u.animations);return u&&u._cacheable&&(o[a]=Object.freeze(g)),g}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||go(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){let s=this.resolveDataElementOptions(t,e),n=this._sharedOptions,o=this.getSharedOptions(s),a=this.includeOptions(e,o)||o!==n;return this.updateSharedOptions(o,e,s),{sharedOptions:o,includeOptions:a}}updateElement(t,e,s,n){go(n)?Object.assign(t,s):this._resolveAnimations(e,n).update(t,s)}updateSharedOptions(t,e,s){t&&!go(e)&&this._resolveAnimations(void 0,e).update(t,s)}_setStyle(t,e,s,n){t.active=n;let o=this.getStyle(e,n);this._resolveAnimations(e,s,n).update(t,{options:!n&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,e,s){this._setStyle(t,s,"active",!0)}_removeDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){let e=this._data,s=this._cachedMeta.data;for(let[l,u,g]of this._syncList)this[l](u,g);this._syncList=[];let n=s.length,o=e.length,a=Math.min(o,n);a&&this.parse(0,a),o>n?this._insertElements(n,o-n,t):o{for(g.length+=e,l=g.length-1;l>=a;l--)g[l]=g[l-e]};for(u(o),l=t;l{n[o]=s[o]&&s[o].active()?s[o]._to:this[o]}),n}}function Tl(i,t){let e=i.options.ticks,s=function(b){let w=b.options.offset,k=b._tickSize(),A=b._length/k+(w?0:1),T=b._maxLength/k;return Math.floor(Math.min(A,T))}(i),n=Math.min(e.maxTicksLimit||s,s),o=e.major.enabled?function(b){let w=[],k,A;for(k=0,A=b.length;kn)return function(b,w,k,A){let T,R=0,$=k[0];for(A=Math.ceil(A),T=0;TT)return Z}return Math.max(T,1)}(o,t,n);if(a>0){let b,w,k=a>1?Math.round((u-l)/(a-1)):null;for(gn(t,g,x,C(k)?0:l-k,l),b=0,w=a-1;bt==="top"||t==="left"?i[t]+e:i[t]-e,kr=(i,t)=>Math.min(t||i,i);function Mr(i,t){let e=[],s=i.length/t,n=i.length,o=0;for(;oa+l)))return g}function Xs(i){return i.drawTicks?i.tickLength:0}function Sr(i,t){if(!i.display)return 0;let e=qe(i.font,t),s=ai(i.padding);return(I(i.text)?i.text.length:1)*e.lineHeight+s.height}function Dl(i,t,e){let s=xe(i);return(e&&t!=="right"||!e&&t==="right")&&(s=(n=>n==="left"?"right":n==="right"?"left":n)(s)),s}class ms extends ss{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:s,_suggestedMax:n}=this;return t=at(t,Number.POSITIVE_INFINITY),e=at(e,Number.NEGATIVE_INFINITY),s=at(s,Number.POSITIVE_INFINITY),n=at(n,Number.NEGATIVE_INFINITY),{min:at(t,s),max:at(e,n),minDefined:W(t),maxDefined:W(e)}}getMinMax(t){let e,{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();if(o&&a)return{min:s,max:n};let l=this.getMatchingVisibleMetas();for(let u=0,g=l.length;un?n:s,n=o&&s>n?s:n,{min:at(s,at(n,s)),max:at(n,at(s,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){ft(this.options.beforeUpdate,[this])}update(t,e,s){let{beginAtZero:n,grace:o,ticks:a}=this.options,l=a.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Yo(this,o,n),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let u=l=o||s<=1||!this.isHorizontal())return void(this.labelRotation=n);let x=this._getLabelSizes(),b=x.widest.width,w=x.highest.height,k=J(this.chart.width-b,0,this.maxWidth);a=t.offset?this.maxWidth/s:k/(s-1),b+6>a&&(a=k/(s-(t.offset?.5:1)),l=this.maxHeight-Xs(t.grid)-e.padding-Sr(t.title,this.chart.options.font),u=Math.sqrt(b*b+w*w),g=ti(Math.min(Math.asin(J((x.highest.height+6)/a,-1,1)),Math.asin(J(l/u,-1,1))-Math.asin(J(w/u,-1,1)))),g=Math.max(n,Math.min(o,g))),this.labelRotation=g}afterCalculateLabelRotation(){ft(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){ft(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:e,options:{ticks:s,title:n,grid:o}}=this,a=this._isVisible(),l=this.isHorizontal();if(a){let u=Sr(n,e.options.font);if(l?(t.width=this.maxWidth,t.height=Xs(o)+u):(t.height=this.maxHeight,t.width=Xs(o)+u),s.display&&this.ticks.length){let{first:g,last:x,widest:b,highest:w}=this._getLabelSizes(),k=2*s.padding,A=Ie(this.labelRotation),T=Math.cos(A),R=Math.sin(A);if(l){let $=s.mirror?0:R*b.width+T*w.height;t.height=Math.min(this.maxHeight,t.height+$+k)}else{let $=s.mirror?0:T*b.width+R*w.height;t.width=Math.min(this.maxWidth,t.width+$+k)}this._calculatePadding(g,x,R,T)}}this._handleMargins(),l?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,s,n){let{ticks:{align:o,padding:a},position:l}=this.options,u=this.labelRotation!==0,g=l!=="top"&&this.axis==="x";if(this.isHorizontal()){let x=this.getPixelForTick(0)-this.left,b=this.right-this.getPixelForTick(this.ticks.length-1),w=0,k=0;u?g?(w=n*t.width,k=s*e.height):(w=s*t.height,k=n*e.width):o==="start"?k=e.width:o==="end"?w=t.width:o!=="inner"&&(w=t.width/2,k=e.width/2),this.paddingLeft=Math.max((w-x+a)*this.width/(this.width-x),0),this.paddingRight=Math.max((k-b+a)*this.width/(this.width-b),0)}else{let x=e.height/2,b=t.height/2;o==="start"?(x=0,b=t.height):o==="end"&&(x=e.height,b=0),this.paddingTop=x+a,this.paddingBottom=b+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){ft(this.options.afterFit,[this])}isHorizontal(){let{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,s;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,s=t.length;e{let Vt=Xt.gc,Nt=Vt.length/2,Wt;if(Nt>It){for(Wt=0;Wt({width:a[$t]||0,height:l[$t]||0});return{first:At(0),last:At(e-1),widest:At(mt),highest:At(Ct),widths:a,heights:l}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);let e=this._startPixel+t*this._length;return et(this._alignToPixels?L(this.chart,e,0):e)}getDecimalForPixel(t){let e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){let e=this.ticks||[];if(t>=0&&tl*n?l/s:u/n:u*n0}_computeGridLineItems(t){let e=this.axis,s=this.chart,n=this.options,{grid:o,position:a,border:l}=n,u=o.offset,g=this.isHorizontal(),x=this.ticks.length+(u?1:0),b=Xs(o),w=[],k=l.setContext(this.getContext()),A=k.display?k.width:0,T=A/2,R=function(Ft){return L(s,Ft,A)},$,tt,Z,Q,ht,mt,Ct,At,$t,It,Xt,Vt;if(a==="top")$=R(this.bottom),mt=this.bottom-b,At=$-T,It=R(t.top)+T,Vt=t.bottom;else if(a==="bottom")$=R(this.top),It=t.top,Vt=R(t.bottom)-T,mt=$+T,At=this.top+b;else if(a==="left")$=R(this.right),ht=this.right-b,Ct=$-T,$t=R(t.left)+T,Xt=t.right;else if(a==="right")$=R(this.left),$t=t.left,Xt=R(t.right)-T,ht=$+T,Ct=this.left+b;else if(e==="x"){if(a==="center")$=R((t.top+t.bottom)/2+.5);else if(X(a)){let Ft=Object.keys(a)[0],ne=a[Ft];$=R(this.chart.scales[Ft].getPixelForValue(ne))}It=t.top,Vt=t.bottom,mt=$+T,At=mt+b}else if(e==="y"){if(a==="center")$=R((t.left+t.right)/2);else if(X(a)){let Ft=Object.keys(a)[0],ne=a[Ft];$=R(this.chart.scales[Ft].getPixelForValue(ne))}ht=$-T,Ct=ht-b,$t=t.left,Xt=t.right}let Nt=q(n.ticks.maxTicksLimit,x),Wt=Math.max(1,Math.ceil(x/Nt));for(tt=0;tt0&&(Qi-=Xi/2)}zi={left:Qi,top:Gi,width:Xi+Wi.width,height:qi+Wi.height,color:Ft.backdropColor}}R.push({label:Q,font:$t,textOffset:Vt,options:{rotation:T,color:Se,strokeColor:ye,strokeWidth:hi,textAlign:Li,textBaseline:Nt,translation:[ht,mt],backdrop:zi}})}return R}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-Ie(this.labelRotation))return t==="top"?"left":"right";let s="center";return e.align==="start"?s="left":e.align==="end"?s="right":e.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){let{position:e,ticks:{crossAlign:s,mirror:n,padding:o}}=this.options,a=t+o,l=this._getLabelSizes().widest.width,u,g;return e==="left"?n?(g=this.right+o,s==="near"?u="left":s==="center"?(u="center",g+=l/2):(u="right",g+=l)):(g=this.right-a,s==="near"?u="right":s==="center"?(u="center",g-=l/2):(u="left",g=this.left)):e==="right"?n?(g=this.left+o,s==="near"?u="right":s==="center"?(u="center",g-=l/2):(u="left",g-=l)):(g=this.left+a,s==="near"?u="left":s==="center"?(u="center",g+=l/2):(u="right",g=this.right)):u="right",{textAlign:u,x:g}}_computeLabelArea(){if(this.options.ticks.mirror)return;let t=this.chart,e=this.options.position;return e==="left"||e==="right"?{top:0,left:this.left,bottom:t.height,right:this.right}:e==="top"||e==="bottom"?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){let{ctx:t,options:{backgroundColor:e},left:s,top:n,width:o,height:a}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(s,n,o,a),t.restore())}getLineWidthForValue(t){let e=this.options.grid;if(!this._isVisible()||!e.display)return 0;let s=this.ticks.findIndex(n=>n.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){let e=this.options.grid,s=this.ctx,n=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,a,l=(u,g,x)=>{x.width&&x.color&&(s.save(),s.lineWidth=x.width,s.strokeStyle=x.color,s.setLineDash(x.borderDash||[]),s.lineDashOffset=x.borderDashOffset,s.beginPath(),s.moveTo(u.x,u.y),s.lineTo(g.x,g.y),s.stroke(),s.restore())};if(e.display)for(o=0,a=n.length;o{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:n,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]:[{z:e,draw:o=>{this.draw(o)}}]}getMatchingVisibleMetas(t){let e=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",n=[],o,a;for(o=0,a=e.length;o{let A=k.split("."),T=A.pop(),R=[b].concat(A).join("."),$=w[k].split("."),tt=$.pop(),Z=$.join(".");bt.route(R,T,Z,tt)})}(u,l.defaultRoutes),l.descriptors&&bt.describe(u,l.descriptors)}(t,a,s),this.override&&bt.override(t.id,t.overrides)),a}get(t){return this.items[t]}unregister(t){let e=this.items,s=t.id,n=this.scope;s in e&&delete e[s],n&&s in bt[n]&&(delete bt[n][s],this.override&&delete lt[s])}}class Pl{constructor(){this.controllers=new pn(ls,"datasets",!0),this.elements=new pn(ss,"elements"),this.plugins=new pn(Object,"plugins"),this.scales=new pn(ms,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,s){[...e].forEach(n=>{let o=s||this._getRegistryForType(n);s||o.isForType(n)||o===this.plugins&&n.id?this._exec(t,o,n):xt(n,a=>{let l=s||this._getRegistryForType(a);this._exec(t,l,a)})})}_exec(t,e,s){let n=se(t);ft(s["before"+n],[],s),e[t](s),ft(s["after"+n],[],s)}_getRegistryForType(t){for(let e=0;eo.filter(l=>!a.some(u=>l.plugin.id===u.plugin.id));this._notify(n(e,s),t,"stop"),this._notify(n(s,e),t,"start")}}function Rl(i,t){return t||i!==!1?i===!0?{}:i:null}function Ol(i,{plugin:t,local:e},s,n){let o=i.pluginScopeKeys(t),a=i.getOptionScopes(s,o);return e&&t.defaults&&a.push(t.defaults),i.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function po(i,t){let e=bt.datasets[i]||{};return((t.datasets||{})[i]||{}).indexAxis||t.indexAxis||e.indexAxis||"x"}function Cr(i){if(i==="x"||i==="y"||i==="r")return i}function fo(i,...t){if(Cr(i))return i;for(let s of t){let n=s.axis||((e=s.position)==="top"||e==="bottom"?"x":e==="left"||e==="right"?"y":void 0)||i.length>1&&Cr(i[0].toLowerCase());if(n)return n}var e;throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function Tr(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function zl(i,t){let e=lt[i.type]||{scales:{}},s=t.scales||{},n=po(i.type,t),o=Object.create(null);return Object.keys(s).forEach(a=>{let l=s[a];if(!X(l))return console.error(`Invalid scale configuration for scale: ${a}`);if(l._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${a}`);let u=fo(a,l,function(b,w){if(w.data&&w.data.datasets){let k=w.data.datasets.filter(A=>A.xAxisID===b||A.yAxisID===b);if(k.length)return Tr(b,"x",k[0])||Tr(b,"y",k[0])}return{}}(a,i),bt.scales[l.type]),g=function(b,w){return b===w?"_index_":"_value_"}(u,n),x=e.scales||{};o[a]=_e(Object.create(null),[{axis:u},l,x[u],x[g]])}),i.data.datasets.forEach(a=>{let l=a.type||i.type,u=a.indexAxis||po(l,t),g=(lt[l]||{}).scales||{};Object.keys(g).forEach(x=>{let b=function(k,A){let T=k;return k==="_index_"?T=A:k==="_value_"&&(T=A==="x"?"y":"x"),T}(x,u),w=a[b+"AxisID"]||b;o[w]=o[w]||Object.create(null),_e(o[w],[{axis:b},s[w],g[x]])})}),Object.keys(o).forEach(a=>{let l=o[a];_e(l,[bt.scales[l.type],bt.scale])}),o}function Er(i){let t=i.options||(i.options={});t.plugins=q(t.plugins,{}),t.scales=zl(i,t)}function Dr(i){return(i=i||{}).datasets=i.datasets||[],i.labels=i.labels||[],i}let Pr=new Map,Ar=new Set;function fn(i,t){let e=Pr.get(i);return e||(e=t(),Pr.set(i,e),Ar.add(e)),e}let Gs=(i,t,e)=>{let s=De(t,e);s!==void 0&&i.add(s)};class Ll{constructor(t){this._config=function(e){return(e=e||{}).data=Dr(e.data),Er(e),e}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Dr(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){let t=this._config;this.clearCache(),Er(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return fn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return fn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return fn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id;return fn(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){let s=this._scopeCache,n=s.get(t);return n&&!e||(n=new Map,s.set(t,n)),n}getOptionScopes(t,e,s){let{options:n,type:o}=this,a=this._cachedScopes(t,s),l=a.get(e);if(l)return l;let u=new Set;e.forEach(x=>{t&&(u.add(t),x.forEach(b=>Gs(u,t,b))),x.forEach(b=>Gs(u,n,b)),x.forEach(b=>Gs(u,lt[o]||{},b)),x.forEach(b=>Gs(u,bt,b)),x.forEach(b=>Gs(u,vt,b))});let g=Array.from(u);return g.length===0&&g.push(Object.create(null)),Ar.has(e)&&a.set(e,g),g}chartOptionScopes(){let{options:t,type:e}=this;return[t,lt[e]||{},bt.datasets[e]||{},{type:e},bt,vt]}resolveNamedOptions(t,e,s,n=[""]){let o={$shared:!0},{resolver:a,subPrefixes:l}=Rr(this._resolverCache,t,n),u=a;(function(g,x){let{isScriptable:b,isIndexable:w}=ze(g);for(let k of x){let A=b(k),T=w(k),R=(T||A)&&g[k];if(A&&(St(R)||Hl(R))||T&&I(R))return!0}return!1})(a,e)&&(o.$shared=!1,u=ri(a,s=St(s)?s():s,this.createResolver(t,s,l)));for(let g of e)o[g]=u[g];return o}createResolver(t,e,s=[""],n){let{resolver:o}=Rr(this._resolverCache,t,s);return X(e)?ri(o,e,void 0,n):o}}function Rr(i,t,e){let s=i.get(t);s||(s=new Map,i.set(t,s));let n=e.join(),o=s.get(n);return o||(o={resolver:Ke(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},s.set(n,o)),o}let Hl=i=>X(i)&&Object.getOwnPropertyNames(i).some(t=>St(i[t])),Il=["top","bottom","left","right","chartArea"];function Or(i,t){return i==="top"||i==="bottom"||Il.indexOf(i)===-1&&t==="x"}function zr(i,t){return function(e,s){return e[i]===s[i]?e[t]-s[t]:e[i]-s[i]}}function Lr(i){let t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),ft(e&&e.onComplete,[i],t)}function Nl(i){let t=i.chart,e=t.options.animation;ft(e&&e.onProgress,[i],t)}function Hr(i){return Dt()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}let mn={},Ir=i=>{let t=Hr(i);return Object.values(mn).filter(e=>e.canvas===t).pop()};function $l(i,t,e){let s=Object.keys(i);for(let n of s){let o=+n;if(o>=t){let a=i[n];delete i[n],(e>0||o>t)&&(i[o+e]=a)}}}function bn(i,t,e){return i.options.clip?i[e]:t[e]}class Ve{static defaults=bt;static instances=mn;static overrides=lt;static registry=Yi;static version="4.4.1";static getChart=Ir;static register(...t){Yi.add(...t),Nr()}static unregister(...t){Yi.remove(...t),Nr()}constructor(t,e){let s=this.config=new Ll(e),n=Hr(t),o=Ir(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");let a=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||dr(n)),this.platform.updateConfig(s);let l=this.platform.acquireContext(n,a.aspectRatio),u=l&&l.canvas,g=u&&u.height,x=u&&u.width;this.id=f(),this.ctx=l,this.canvas=u,this.width=x,this.height=g,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Al,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=fe(b=>this.update(b),a.resizeDelay||0),this._dataChanges=[],mn[this.id]=this,l&&u?(Be.listen(this,"complete",Lr),Be.listen(this,"progress",Nl),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:e},width:s,height:n,_aspectRatio:o}=this;return C(t)?e&&o?o:n?s/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Yi}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():O(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return K(this.canvas,this.ctx),this}stop(){return Be.stop(this),this}resize(t,e){Be.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){let s=this.options,n=this.canvas,o=s.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(n,t,e,o),l=s.devicePixelRatio||this.platform.getDevicePixelRatio(),u=this.width?"resize":"attach";this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,O(this,l,!0)&&(this.notifyPlugins("resize",{size:a}),ft(s.onResize,[this,a],this),this.attached&&this._doResize(u)&&this.render())}ensureScalesHaveIDs(){xt(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){let t=this.options,e=t.scales,s=this.scales,n=Object.keys(s).reduce((a,l)=>(a[l]=!1,a),{}),o=[];e&&(o=o.concat(Object.keys(e).map(a=>{let l=e[a],u=fo(a,l),g=u==="r",x=u==="x";return{options:l,dposition:g?"chartArea":x?"bottom":"left",dtype:g?"radialLinear":x?"category":"linear"}}))),xt(o,a=>{let l=a.options,u=l.id,g=fo(u,l),x=q(l.type,a.dtype);l.position!==void 0&&Or(l.position,g)===Or(a.dposition)||(l.position=a.dposition),n[u]=!0;let b=null;u in s&&s[u].type===x?b=s[u]:(b=new(Yi.getScale(x))({id:u,type:x,ctx:this.ctx,chart:this}),s[b.id]=b),b.init(l,t)}),xt(n,(a,l)=>{a||delete s[l]}),xt(s,a=>{li.configure(this,a,a.options),li.addBox(this,a)})}_updateMetasets(){let t=this._metasets,e=this.data.datasets.length,s=t.length;if(t.sort((n,o)=>n.index-o.index),s>e){for(let n=e;ne.length&&delete this._stacks,t.forEach((s,n)=>{e.filter(o=>o===s._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let t=[],e=this.data.datasets,s,n;for(this._removeUnreferencedMetasets(),s=0,n=e.length;s{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let e=this.config;e.update();let s=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),n=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;let o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let a=0;for(let g=0,x=this.data.datasets.length;g{g.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(zr("z","_idx"));let{_active:l,_lastEvent:u}=this;u?this._eventHandler(u,!0):l.length&&this._updateHoverStyles(l,l,!0),this.render()}_updateScales(){xt(this.scales,t=>{li.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,e=new Set(Object.keys(this._listeners)),s=new Set(t.events);r(e,s)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(let{method:s,start:n,count:o}of e)$l(t,n,s==="_removeElements"?-o:o)}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let e=this.data.datasets.length,s=o=>new Set(t.filter(a=>a[0]===o).map((a,l)=>l+","+a.splice(1).join(","))),n=s(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;li.update(this,this.width,this.height,t);let e=this.chartArea,s=e.width<=0||e.height<=0;this._layers=[],xt(this.boxes,n=>{s&&n.position==="chartArea"||(n.configure&&n.configure(),this._layers.push(...n._layers()))},this),this._layers.forEach((n,o)=>{n._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,s=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let e=this.ctx,s=t._clip,n=!s.disabled,o=function(l,u){let{xScale:g,yScale:x}=l;return g&&x?{left:bn(g,u,"left"),right:bn(g,u,"right"),top:bn(x,u,"top"),bottom:bn(x,u,"bottom")}:u}(t,this.chartArea),a={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",a)!==!1&&(n&&qt(e,{left:s.left===!1?0:o.left-s.left,right:s.right===!1?this.width:o.right+s.right,top:s.top===!1?0:o.top-s.top,bottom:s.bottom===!1?this.height:o.bottom+s.bottom}),t.controller.draw(),n&&Gt(e),a.cancelable=!1,this.notifyPlugins("afterDatasetDraw",a))}isPointInArea(t){return Mt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,s,n){let o=Jo.modes[e];return typeof o=="function"?o(this,t,s,n):[]}getDatasetMeta(t){let e=this.data.datasets[t],s=this._metasets,n=s.filter(o=>o&&o._dataset===e).pop();return n||(n={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},s.push(n)),n}getContext(){return this.$context||(this.$context=as(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let e=this.data.datasets[t];if(!e)return!1;let s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,s){let n=s?"show":"hide",o=this.getDatasetMeta(t),a=o.controller._resolveAnimations(void 0,n);Bt(e)?(o.data[e].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),a.update(o,{visible:s}),this.update(l=>l.datasetIndex===t?n:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){let e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),Be.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,a),t[o]=a},n=(o,a,l)=>{o.offsetX=a,o.offsetY=l,this._eventHandler(o)};xt(this.options.events,o=>s(o,n))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,s=(u,g)=>{e.addEventListener(this,u,g),t[u]=g},n=(u,g)=>{t[u]&&(e.removeEventListener(this,u,g),delete t[u])},o=(u,g)=>{this.canvas&&this.resize(u,g)},a,l=()=>{n("attach",l),this.attached=!0,this.resize(),s("resize",o),s("detach",a)};a=()=>{this.attached=!1,n("resize",o),this._stop(),this._resize(0,0),s("attach",l)},e.isAttached(this.canvas)?l():a()}unbindEvents(){xt(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},xt(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,s){let n=s?"set":"remove",o,a,l,u;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),l=0,u=t.length;l{let a=this.getDatasetMeta(n);if(!a)throw new Error("No dataset found at index "+n);return{datasetIndex:n,element:a.data[o],index:o}});!jt(s,e)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,e))}notifyPlugins(t,e,s){return this._plugins.notify(this,t,e,s)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,s){let n=this.options.hover,o=(u,g)=>u.filter(x=>!g.some(b=>x.datasetIndex===b.datasetIndex&&x.index===b.index)),a=o(e,t),l=s?t:o(t,e);a.length&&this.updateHoverStyle(a,n.mode,!1),l.length&&n.mode&&this.updateHoverStyle(l,n.mode,!0)}_eventHandler(t,e){let s={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},n=a=>(a.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,n)===!1)return;let o=this._handleEvent(t,e,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,n),(o||s.changed)&&this.render(),this}_handleEvent(t,e,s){let{_active:n=[],options:o}=this,a=e,l=this._getActiveElements(t,n,s,a),u=d(t),g=function(b,w,k,A){return k&&b.type!=="mouseout"?A?w:b:null}(t,this._lastEvent,s,u);s&&(this._lastEvent=null,ft(o.onHover,[t,l,this],this),u&&ft(o.onClick,[t,l,this],this));let x=!jt(l,n);return(x||e)&&(this._active=l,this._updateHoverStyles(l,n,e)),this._lastEvent=g,x}_getActiveElements(t,e,s,n){if(t.type==="mouseout")return[];if(!s)return e;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,n)}}function Nr(){return xt(Ve.instances,i=>i._plugins.invalidate())}function Cs(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class mo{static override(t){Object.assign(mo.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Cs()}parse(){return Cs()}format(){return Cs()}add(){return Cs()}diff(){return Cs()}startOf(){return Cs()}endOf(){return Cs()}}var $r={_date:mo};function Fl(i){let t=i.iScale,e=function(g,x){if(!g._cache.$bar){let b=g.getMatchingVisibleMetas(x),w=[];for(let k=0,A=b.length;kk-A))}return g._cache.$bar}(t,i.type),s,n,o,a,l=t._length,u=()=>{o!==32767&&o!==-32768&&(Bt(a)&&(l=Math.min(l,Math.abs(o-a)||l)),a=o)};for(s=0,n=e.length;sMath.abs(b)&&(w=b,k=x),o[a.axis]=k,o._custom={barStart:w,barEnd:k,start:u,end:g,min:x,max:b}}(i,t,e,s):t[e.axis]=e.parse(i,s),t}function Wr(i,t,e,s){let n=i.iScale,o=i.vScale,a=n.getLabels(),l=n===o,u=[],g,x,b,w;for(g=e,x=e+s;gb.x,k="left",A="right"):(w=b.baset!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data;if(e.labels.length&&e.datasets.length){let{labels:{pointStyle:s,color:n}}=t.legend.options;return e.labels.map((o,a)=>{let l=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:n,lineWidth:l.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){let s=this.getDataset().data,n=this._cachedMeta;if(this._parsing===!1)n._parsed=s;else{let o,a,l=u=>+s[u];if(X(s[t])){let{key:u="value"}=this._parsing;l=g=>+De(s[g],u)}for(o=t,a=t+e;oN(Xi,Vt,Nt,!0)?1:Math.max(Gi,Gi*Ct,Qi,Qi*Ct),hi=(Xi,Gi,Qi)=>N(Xi,Vt,Nt,!0)?-1:Math.min(Gi,Gi*Ct,Qi,Qi*Ct),zi=ye(0,Wt,ne),Li=ye(nt,Ft,Se),Wi=hi(y,Wt,ne),qi=hi(y+nt,Ft,Se);At=(zi-Wi)/2,$t=(Li-qi)/2,It=-(zi+Wi)/2,Xt=-(Li+qi)/2}return{ratioX:At,ratioY:$t,offsetX:It,offsetY:Xt}}(b,x,u),R=(s.width-a)/w,$=(s.height-a)/k,tt=Math.max(Math.min(R,$)/2,0),Z=Ot(this.options.radius,tt),Q=(Z-Math.max(Z*u,0))/this._getVisibleDatasetWeightTotal();this.offsetX=A*Z,this.offsetY=T*Z,n.total=this.calculateTotal(),this.outerRadius=Z-Q*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-Q*g,0),this.updateElements(o,0,o.length,t)}_circumference(t,e){let s=this.options,n=this._cachedMeta,o=this._getCircumference();return e&&s.animation.animateRotate||!this.chart.getDataVisibility(t)||n._parsed[t]===null||n.data[t].hidden?0:this.calculateCircumference(n._parsed[t]*o/v)}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,l=a.chartArea,u=a.options.animation,g=(l.left+l.right)/2,x=(l.top+l.bottom)/2,b=o&&u.animateScale,w=b?0:this.innerRadius,k=b?0:this.outerRadius,{sharedOptions:A,includeOptions:T}=this._getSharedOptions(e,n),R,$=this._getRotation();for(R=0;R0&&!isNaN(t)?v*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=ct(e._parsed[t],s.options.locale);return{label:n[t]||"",value:o}}getMaxBorderWidth(t){let e=0,s=this.chart,n,o,a,l,u;if(!t){for(n=0,o=s.data.datasets.length;n{let l=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:n,lineWidth:l.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=ct(e._parsed[t].r,s.options.locale);return{label:n[t]||"",value:o}}parseObjectData(t,e,s,n){return zs.bind(this)(t,e,s,n)}update(t){let e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){let t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((s,n)=>{let o=this.getParsed(n).r;!isNaN(o)&&this.chart.getDataVisibility(n)&&(oe.max&&(e.max=o))}),e}_updateRadius(){let t=this.chart,e=t.chartArea,s=t.options,n=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(n/2,0),a=(o-Math.max(s.cutoutPercentage?o/100*s.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,l=a.options.animation,u=this._cachedMeta.rScale,g=u.xCenter,x=u.yCenter,b=u.getIndexAngle(0)-.5*y,w,k=b,A=360/this.countVisibleElements();for(w=0;w{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++}),e}_computeAngle(t,e,s){return this.chart.getDataVisibility(t)?Ie(this.resolveDataElementOptions(t,e).angle||s):0}}var Vr=Object.freeze({__proto__:null,BarController:class extends ls{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(i,t,e,s){return Wr(i,t,e,s)}parseArrayData(i,t,e,s){return Wr(i,t,e,s)}parseObjectData(i,t,e,s){let{iScale:n,vScale:o}=i,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,u=n.axis==="x"?a:l,g=o.axis==="x"?a:l,x=[],b,w,k,A;for(b=e,w=e+s;bl.controller.options.grouped),n=e.options.stacked,o=[],a=l=>{let u=l.controller.getParsed(t),g=u&&u[l.vScale.axis];if(C(g)||isNaN(g))return!0};for(let l of s)if((t===void 0||!a(l))&&((n===!1||o.indexOf(l.stack)===-1||n===void 0&&l.stack===void 0)&&o.push(l.stack),l.index===i))break;return o.length||o.push(void 0),o}_getStackCount(i){return this._getStacks(void 0,i).length}_getStackIndex(i,t,e){let s=this._getStacks(i,e),n=t!==void 0?s.indexOf(t):-1;return n===-1?s.length-1:n}_getRuler(){let i=this.options,t=this._cachedMeta,e=t.iScale,s=[],n,o;for(n=0,o=t.data.length;n=Ct?1:-1)}(b,t,a)*o,w===a&&(R-=b/2);let $=t.getPixelForDecimal(0),tt=t.getPixelForDecimal(1),Z=Math.min($,tt),Q=Math.max($,tt);R=Math.max(Math.min(R,Q),Z),x=R+b,e&&!g&&(l._stacks[t.axis]._visualValues[s]=t.getValueForPixel(x)-t.getValueForPixel(R))}if(R===t.getPixelForValue(a)){let $=Et(b)*t.getLineWidthForValue(a)/2;R+=$,b-=$}return{size:b,base:R,head:x,center:x+b/2}}_calculateBarIndexPixels(i,t){let e=t.scale,s=this.options,n=s.skipNull,o=q(s.maxBarThickness,1/0),a,l;if(t.grouped){let u=n?this._getStackCount(i):t.stackCount,g=s.barThickness==="flex"?function(b,w,k,A){let T=w.pixels,R=T[b],$=b>0?T[b-1]:null,tt=b=0;--e)t=Math.max(t,i[e].size(this.resolveDataElementOptions(e))/2);return t>0&&t}getLabelAndValue(i){let t=this._cachedMeta,e=this.chart.data.labels||[],{xScale:s,yScale:n}=t,o=this.getParsed(i),a=s.getLabelForValue(o.x),l=n.getLabelForValue(o.y),u=o._custom;return{label:e[i]||"",value:"("+a+", "+l+(u?", "+u:"")+")"}}update(i){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,i)}updateElements(i,t,e,s){let n=s==="reset",{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:u}=this._getSharedOptions(t,s),g=o.axis,x=a.axis;for(let b=t;b0&&this.getParsed(t-1);for(let Q=0;Q=$){mt.skip=!0;continue}let Ct=this.getParsed(Q),At=C(Ct[w]),$t=mt[b]=o.getPixelForValue(Ct[b],Q),It=mt[w]=n||At?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,Ct,l):Ct[w],Q);mt.skip=isNaN($t)||isNaN(It)||At,mt.stop=Q>0&&Math.abs(Ct[b]-Z[b])>T,A&&(mt.parsed=Ct,mt.raw=u.data[Q]),x&&(mt.options=g||this.resolveDataElementOptions(Q,ht.active?"active":s)),R||this.updateElement(ht,Q,mt,s),Z=Ct}}getMaxOverflow(){let i=this._cachedMeta,t=i.dataset,e=t.options&&t.options.borderWidth||0,s=i.data||[];if(!s.length)return e;let n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(e,n,o)/2}draw(){let i=this._cachedMeta;i.dataset.updateControlPoints(this.chart.chartArea,i.iScale.axis),super.draw()}},PieController:class extends yo{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:jr,RadarController:class extends ls{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(i){let t=this._cachedMeta.vScale,e=this.getParsed(i);return{label:t.getLabels()[i],value:""+t.getLabelForValue(e[t.axis])}}parseObjectData(i,t,e,s){return zs.bind(this)(i,t,e,s)}update(i){let t=this._cachedMeta,e=t.dataset,s=t.data||[],n=t.iScale.getLabels();if(e.points=s,i!=="resize"){let o=this.resolveDatasetElementOptions(i);this.options.showLine||(o.borderWidth=0);let a={_loop:!0,_fullLoop:n.length===s.length,options:o};this.updateElement(e,void 0,a,i)}this.updateElements(s,0,s.length,i)}updateElements(i,t,e,s){let n=this._cachedMeta.rScale,o=s==="reset";for(let a=t;a0&&this.getParsed(t-1);for(let Z=t;Z0&&Math.abs(ht[w]-tt[w])>R,T&&(mt.parsed=ht,mt.raw=u.data[Z]),b&&(mt.options=x||this.resolveDataElementOptions(Z,Q.active?"active":s)),$||this.updateElement(Q,Z,mt,s),tt=ht}this.updateSharedOptions(x,s,g)}getMaxOverflow(){let i=this._cachedMeta,t=i.data||[];if(!this.options.showLine){let a=0;for(let l=t.length-1;l>=0;--l)a=Math.max(a,t[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let e=i.dataset,s=e.options&&e.options.borderWidth||0;if(!t.length)return s;let n=t[0].size(this.resolveDataElementOptions(0)),o=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(s,n,o)/2}}});function Ul(i,t,e,s){let n=hn(i.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]),o=(e-t)/2,a=Math.min(o,s*t/2),l=u=>{let g=(e-Math.min(o,u))*s/2;return J(u,0,Math.min(o,g))};return{outerStart:l(n.outerStart),outerEnd:l(n.outerEnd),innerStart:J(n.innerStart,0,a),innerEnd:J(n.innerEnd,0,a)}}function Is(i,t,e,s){return{x:e+i*Math.cos(t),y:s+i*Math.sin(t)}}function yn(i,t,e,s,n,o){let{x:a,y:l,startAngle:u,pixelMargin:g,innerRadius:x}=t,b=Math.max(t.outerRadius+s+e-g,0),w=x>0?x+s+e+g:0,k=0,A=n-u;if(s){let Wt=((x>0?x-s:0)+(b>0?b-s:0))/2;k=(A-(Wt!==0?A*Wt/(Wt+s):A))/2}let T=(A-Math.max(.001,A*b-e/y)/b)/2,R=u+T+k,$=n-T-k,{outerStart:tt,outerEnd:Z,innerStart:Q,innerEnd:ht}=Ul(t,w,b,$-R),mt=b-tt,Ct=b-Z,At=R+tt/mt,$t=$-Z/Ct,It=w+Q,Xt=w+ht,Vt=R+Q/It,Nt=$-ht/Xt;if(i.beginPath(),o){let Wt=(At+$t)/2;if(i.arc(a,l,b,At,Wt),i.arc(a,l,b,Wt,$t),Z>0){let ye=Is(Ct,$t,a,l);i.arc(ye.x,ye.y,Z,$t,$+nt)}let Ft=Is(Xt,$,a,l);if(i.lineTo(Ft.x,Ft.y),ht>0){let ye=Is(Xt,Nt,a,l);i.arc(ye.x,ye.y,ht,$+nt,Nt+Math.PI)}let ne=($-ht/w+(R+Q/w))/2;if(i.arc(a,l,w,$-ht/w,ne,!0),i.arc(a,l,w,ne,R+Q/w,!0),Q>0){let ye=Is(It,Vt,a,l);i.arc(ye.x,ye.y,Q,Vt+Math.PI,R-nt)}let Se=Is(mt,R,a,l);if(i.lineTo(Se.x,Se.y),tt>0){let ye=Is(mt,At,a,l);i.arc(ye.x,ye.y,tt,R-nt,At)}}else{i.moveTo(a,l);let Wt=Math.cos(At)*b+a,Ft=Math.sin(At)*b+l;i.lineTo(Wt,Ft);let ne=Math.cos($t)*b+a,Se=Math.sin($t)*b+l;i.lineTo(ne,Se)}i.closePath()}function jl(i,t,e,s,n){let{fullCircles:o,startAngle:a,circumference:l,options:u}=t,{borderWidth:g,borderJoinStyle:x,borderDash:b,borderDashOffset:w}=u,k=u.borderAlign==="inner";if(!g)return;i.setLineDash(b||[]),i.lineDashOffset=w,k?(i.lineWidth=2*g,i.lineJoin=x||"round"):(i.lineWidth=g,i.lineJoin=x||"bevel");let A=t.endAngle;if(o){yn(i,t,e,s,A,n);for(let T=0;TZ?(At=Z/Ct,T.arc(Q,ht,Ct,$+At,tt-At,!0)):T.arc(Q,ht,Z,$+nt,tt-nt),T.closePath(),T.clip()}(i,t,A),o||(yn(i,t,e,s,A,n),i.stroke())}function Yr(i,t,e=t){i.lineCap=q(e.borderCapStyle,t.borderCapStyle),i.setLineDash(q(e.borderDash,t.borderDash)),i.lineDashOffset=q(e.borderDashOffset,t.borderDashOffset),i.lineJoin=q(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=q(e.borderWidth,t.borderWidth),i.strokeStyle=q(e.borderColor,t.borderColor)}function Vl(i,t,e){i.lineTo(e.x,e.y)}function qr(i,t,e={}){let s=i.length,{start:n=0,end:o=s-1}=e,{start:a,end:l}=t,u=Math.max(n,a),g=Math.min(o,l),x=nl&&o>l;return{count:s,start:u,loop:t.loop,ilen:g(a+(g?l-Q:Q))%o,Z=()=>{k!==A&&(i.lineTo(R,A),i.lineTo(R,k),i.lineTo(R,T))};for(u&&(b=n[tt(0)],i.moveTo(b.x,b.y)),x=0;x<=l;++x){if(b=n[tt(x)],b.skip)continue;let Q=b.x,ht=b.y,mt=0|Q;mt===w?(htA&&(A=ht),R=($*R+Q)/++$):(Z(),i.lineTo(Q,ht),w=mt,$=0,k=A=ht),T=ht}Z()}function xo(i){let t=i.options,e=t.borderDash&&t.borderDash.length;return i._decimated||i._loop||t.tension||t.cubicInterpolationMode==="monotone"||t.stepped||e?Yl:ql}let Xl=typeof Path2D=="function";function Gl(i,t,e,s){Xl&&!t.options.segment?function(n,o,a,l){let u=o._path;u||(u=o._path=new Path2D,o.path(u,a,l)&&u.closePath()),Yr(n,o.options),n.stroke(u)}(i,t,e,s):function(n,o,a,l){let{segments:u,options:g}=o,x=xo(o);for(let b of u)Yr(n,g,b.style),n.beginPath(),x(n,o,b,{start:a,end:a+l-1})&&n.closePath(),n.stroke()}(i,t,e,s)}class xn extends ss{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){let s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){let n=s.spanGaps?this._loop:this._fullLoop;Mi(this._points,s,t,n,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Go(this,this.options.segment))}first(){let t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){let t=this.segments,e=this.points,s=t.length;return s&&e[t[s-1].end]}interpolate(t,e){let s=this.options,n=t[e],o=this.points,a=oo(this,{property:e,start:n,end:n});if(!a.length)return;let l=[],u=function(b){return b.stepped?Uo:b.tension||b.cubicInterpolationMode==="monotone"?jo:ps}(s),g,x;for(g=0,x=a.length;gi!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(i){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,i&&Object.assign(this,i)}inRange(i,t,e){let s=this.getProps(["x","y"],e),{angle:n,distance:o}=si(s,{x:i,y:t}),{startAngle:a,endAngle:l,innerRadius:u,outerRadius:g,circumference:x}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],e),b=(this.options.spacing+this.options.borderWidth)/2,w=q(x,l-a)>=v||N(n,a,l),k=ot(o,u+b,g+b);return w&&k}getCenterPoint(i){let{x:t,y:e,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],i),{offset:l,spacing:u}=this.options,g=(s+n)/2,x=(o+a+u+l)/2;return{x:t+Math.cos(g)*x,y:e+Math.sin(g)*x}}tooltipPosition(i){return this.getCenterPoint(i)}draw(i){let{options:t,circumference:e}=this,s=(t.offset||0)/4,n=(t.spacing||0)/2,o=t.circular;if(this.pixelMargin=t.borderAlign==="inner"?.33:0,this.fullCircles=e>v?Math.floor(e/v):0,e===0||this.innerRadius<0||this.outerRadius<0)return;i.save();let a=(this.startAngle+this.endAngle)/2;i.translate(Math.cos(a)*s,Math.sin(a)*s);let l=s*(1-Math.sin(Math.min(y,e||0)));i.fillStyle=t.backgroundColor,i.strokeStyle=t.borderColor,function(u,g,x,b,w){let{fullCircles:k,startAngle:A,circumference:T}=g,R=g.endAngle;if(k){yn(u,g,x,b,R,w);for(let $=0;$(typeof a=="string"?(l=o.push(a)-1,u.unshift({index:l,label:a})):isNaN(a)&&(l=null),l))(i,t,e,s):n!==i.lastIndexOf(t)?e:n}function Qr(i){let t=this.getLabels();return i>=0&&in=e?n:u,l=u=>o=s?o:u;if(t){let u=Et(n),g=Et(o);u<0&&g<0?l(0):u>0&&g>0&&a(0)}if(n===o){let u=o===0?1:Math.abs(.05*o);l(o+u),t||a(n-u)}this.min=n,this.max=o}getTickLimit(){let t=this.options.ticks,e,{maxTicksLimit:s,stepSize:n}=t;return n?(e=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),s=s||11),s&&(e=Math.min(s,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,e=t.ticks,s=this.getTickLimit();s=Math.max(2,s);let n=function(o,a){let l=[],{bounds:u,step:g,min:x,max:b,precision:w,count:k,maxTicks:A,maxDigits:T,includeBounds:R}=o,$=g||1,tt=A-1,{min:Z,max:Q}=a,ht=!C(x),mt=!C(b),Ct=!C(k),At=(Q-Z)/(T+1),$t,It,Xt,Vt,Nt=Le((Q-Z)/tt/$)*$;if(Nt<1e-14&&!ht&&!mt)return[{value:Z},{value:Q}];Vt=Math.ceil(Q/Nt)-Math.floor(Z/Nt),Vt>tt&&(Nt=Le(Vt*Nt/tt/$)*$),C(w)||($t=Math.pow(10,w),Nt=Math.ceil(Nt*$t)/$t),u==="ticks"?(It=Math.floor(Z/Nt)*Nt,Xt=Math.ceil(Q/Nt)*Nt):(It=Z,Xt=Q),ht&&mt&&g&&We((b-x)/g,Nt/1e3)?(Vt=Math.round(Math.min((b-x)/Nt,A)),Nt=(b-x)/Vt,It=x,Xt=b):Ct?(It=ht?x:It,Xt=mt?b:Xt,Vt=k-1,Nt=(Xt-It)/Vt):(Vt=(Xt-It)/Nt,Vt=ie(Vt,Math.round(Vt),Nt/1e3)?Math.round(Vt):Math.ceil(Vt));let Wt=Math.max(Ne(Nt),Ne(It));$t=Math.pow(10,C(w)?Wt:w),It=Math.round(It*$t)/$t,Xt=Math.round(Xt*$t)/$t;let Ft=0;for(ht&&(R&&It!==x?(l.push({value:x}),Itb)break;l.push({value:ne})}return mt&&R&&Xt!==b?l.length&&ie(l[l.length-1].value,b,Kr(b,At,o))?l[l.length-1].value=b:l.push({value:b}):mt&&Xt!==b||l.push({value:Xt}),l}({maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},this._range||this);return t.bounds==="ticks"&&Je(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}configure(){let t=this.ticks,e=this.min,s=this.max;if(super.configure(),this.options.offset&&t.length){let n=(s-e)/Math.max(t.length-1,1)/2;e-=n,s+=n}this._startValue=e,this._endValue=s,this._valueRange=s-e}getLabelForValue(t){return ct(t,this.chart.options.locale,this.options.ticks.format)}}class Jl extends vn{static id="linear";static defaults={ticks:{callback:pt.formatters.numeric}};determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=W(t)?t:0,this.max=W(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,s=Ie(this.options.ticks.minRotation),n=(t?Math.sin(s):Math.cos(s))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/n))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}let Qs=i=>Math.floor(kt(i)),Ts=(i,t)=>Math.pow(10,Qs(i)+t);function Zr(i){return i/Math.pow(10,Qs(i))===1}function Jr(i,t,e){let s=Math.pow(10,e),n=Math.floor(i/s);return Math.ceil(t/s)-n}function th(i,{min:t,max:e}){t=at(i.min,t);let s=[],n=Qs(t),o=function(A,T){let R=Qs(T-A);for(;Jr(A,T,R)>10;)R++;for(;Jr(A,T,R)<10;)R--;return Math.min(R,Qs(A))}(t,e),a=o<0?Math.pow(10,Math.abs(o)):1,l=Math.pow(10,o),u=n>o?Math.pow(10,n):0,g=Math.round((t-u)*a)/a,x=Math.floor((t-u)/l/10)*l*10,b=Math.floor((g-x)/Math.pow(10,o)),w=at(i.min,Math.round((u+x+b*Math.pow(10,o))*a)/a);for(;w=10?b=b<15?15:20:b++,b>=20&&(o++,b=2,a=o>=0?1:a),w=Math.round((u+x+b*Math.pow(10,o))*a)/a;let k=at(i.max,w);return s.push({value:k,major:Zr(k),significand:b}),s}class eh extends ms{static id="logarithmic";static defaults={ticks:{callback:pt.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){let s=vn.prototype.parse.apply(this,[t,e]);if(s!==0)return W(s)&&s>0?s:null;this._zero=!0}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=W(t)?Math.max(0,t):null,this.max=W(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!W(this._userMin)&&(this.min=t===Ts(this.min,0)?Ts(this.min,-1):Ts(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),s=this.min,n=this.max,o=l=>s=t?s:l,a=l=>n=e?n:l;s===n&&(s<=0?(o(1),a(10)):(o(Ts(s,-1)),a(Ts(n,1)))),s<=0&&o(Ts(n,-1)),n<=0&&a(Ts(s,1)),this.min=s,this.max=n}buildTicks(){let t=this.options,e=th({min:this._userMin,max:this._userMax},this);return t.bounds==="ticks"&&Je(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return t===void 0?"0":ct(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=kt(t),this._valueRange=kt(this.max)-kt(t)}getPixelForValue(t){return t!==void 0&&t!==0||(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(kt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function ko(i){let t=i.ticks;if(t.display&&i.display){let e=ai(t.backdropPadding);return q(t.font&&t.font.size,bt.font.size)+e.height}return 0}function ta(i,t,e,s,n){return i===s||i===n?{start:t-e/2,end:t+e/2}:in?{start:t-e,end:t}:{start:t,end:t+e}}function ih(i){let t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),s=[],n=[],o=i._pointLabels.length,a=i.options.pointLabels,l=a.centerPointLabels?y/o:0;for(let b=0;bt.r&&(l=(s.end-t.r)/o,i.r=Math.max(i.r,t.r+l)),n.startt.b&&(u=(n.end-t.b)/a,i.b=Math.max(i.b,t.b+u))}function nh(i,t,e){let s=i.drawingArea,{extra:n,additionalAngle:o,padding:a,size:l}=e,u=i.getPointPosition(t,s+n+a,o),g=Math.round(ti(ve(u.angle+nt))),x=function(k,A,T){return T===90||T===270?k-=A/2:(T>270||T<90)&&(k-=A),k}(u.y,l.h,g),b=function(k){return k===0||k===180?"center":k<180?"left":"right"}(g),w=function(k,A,T){return T==="right"?k-=A:T==="center"&&(k-=A/2),k}(u.x,l.w,b);return{visible:!0,x:u.x,y:x,textAlign:b,left:w,top:x,right:w+l.w,bottom:x+l.h}}function oh(i,t){if(!t)return!0;let{left:e,top:s,right:n,bottom:o}=i;return!(Mt({x:e,y:s},t)||Mt({x:e,y:o},t)||Mt({x:n,y:s},t)||Mt({x:n,y:o},t))}function rh(i,t,e){let{left:s,top:n,right:o,bottom:a}=e,{backdropColor:l}=t;if(!C(l)){let u=fs(t.borderRadius),g=ai(t.backdropPadding);i.fillStyle=l;let x=s-g.left,b=n-g.top,w=o-s+g.width,k=a-n+g.height;Object.values(u).some(A=>A!==0)?(i.beginPath(),xi(i,{x,y:b,w,h:k,radius:u}),i.fill()):i.fillRect(x,b,w,k)}}function ea(i,t,e,s){let{ctx:n}=i;if(e)n.arc(i.xCenter,i.yCenter,t,0,v);else{let o=i.getPointPosition(0,t);n.moveTo(o.x,o.y);for(let a=1;at,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let t=this._padding=ai(ko(this.options)/2),e=this.width=this.maxWidth-t.width,s=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+s/2+t.top),this.drawingArea=Math.floor(Math.min(e,s)/2)}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!1);this.min=W(t)&&!isNaN(t)?t:0,this.max=W(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/ko(this.options))}generateTickLabels(t){vn.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,s)=>{let n=ft(this.options.pointLabels.callback,[e,s],this);return n||n===0?n:""}).filter((e,s)=>this.chart.getDataVisibility(s))}fit(){let t=this.options;t.display&&t.pointLabels.display?ih(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,s,n){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((s-n)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,s,n))}getIndexAngle(t){return ve(t*(v/(this._pointLabels.length||1))+Ie(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(C(t))return NaN;let e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(C(t))return NaN;let e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){let e=this._pointLabels||[];if(t>=0&&t=0;A--){let T=x._pointLabelItems[A];if(!T.visible)continue;let R=k.setContext(x.getPointLabelContext(A));rh(w,R,T);let $=qe(R.font),{x:tt,y:Z,textAlign:Q}=T;Qe(w,x._pointLabels[A],tt,Z+$.lineHeight/2,$,{color:R.color,textAlign:Q,textBaseline:"middle"})}}(this,a),n.display&&this.ticks.forEach((x,b)=>{if(b!==0){u=this.getDistanceFromCenterForValue(x.value);let w=this.getContext(b),k=n.setContext(w),A=o.setContext(w);(function(T,R,$,tt,Z){let Q=T.ctx,ht=R.circular,{color:mt,lineWidth:Ct}=R;!ht&&!tt||!mt||!Ct||$<0||(Q.save(),Q.strokeStyle=mt,Q.lineWidth=Ct,Q.setLineDash(Z.dash),Q.lineDashOffset=Z.dashOffset,Q.beginPath(),ea(T,$,ht,tt),Q.closePath(),Q.stroke(),Q.restore())})(this,k,u,a,A)}}),s.display){for(t.save(),l=a-1;l>=0;l--){let x=s.setContext(this.getPointLabelContext(l)),{color:b,lineWidth:w}=x;w&&b&&(t.lineWidth=w,t.strokeStyle=b,t.setLineDash(x.borderDash),t.lineDashOffset=x.borderDashOffset,u=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),g=this.getPointPosition(l,u),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(g.x,g.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){let t=this.ctx,e=this.options,s=e.ticks;if(!s.display)return;let n=this.getIndexAngle(0),o,a;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(n),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((l,u)=>{if(u===0&&!e.reverse)return;let g=s.setContext(this.getContext(u)),x=qe(g.font);if(o=this.getDistanceFromCenterForValue(this.ticks[u].value),g.showLabelBackdrop){t.font=x.string,a=t.measureText(l.label).width,t.fillStyle=g.backdropColor;let b=ai(g.backdropPadding);t.fillRect(-a/2-b.left,-o-x.size/2-b.top,a+b.width,x.size+b.height)}Qe(t,l.label,0,-o,x,{color:g.color,strokeColor:g.textStrokeColor,strokeWidth:g.textStrokeWidth})}),t.restore()}drawTitle(){}}let wn={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Si=Object.keys(wn);function ia(i,t){return i-t}function sa(i,t){if(C(t))return null;let e=i._adapter,{parser:s,round:n,isoWeekday:o}=i._parseOpts,a=t;return typeof s=="function"&&(a=s(a)),W(a)||(a=typeof s=="string"?e.parse(a,s):e.parse(a)),a===null?null:(n&&(a=n!=="week"||!Re(o)&&o!==!0?e.startOf(a,n):e.startOf(a,"isoWeek",o)),+a)}function na(i,t,e,s){let n=Si.length;for(let o=Si.indexOf(i);o=t?e[s]:e[n]]=!0}}else i[t]=!0}function ra(i,t,e){let s=[],n={},o=t.length,a,l;for(a=0;a=0&&(g[R].major=!0);return g}(i,s,n,e):s}class Mo extends ms{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){let s=t.time||(t.time={}),n=this._adapter=new $r._date(t.adapters.date);n.init(e),_e(s.displayFormats,n.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:sa(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,e=this._adapter,s=t.time.unit||"day",{min:n,max:o,minDefined:a,maxDefined:l}=this.getUserBounds();function u(g){a||isNaN(g.min)||(n=Math.min(n,g.min)),l||isNaN(g.max)||(o=Math.max(o,g.max))}a&&l||(u(this._getLabelBounds()),t.bounds==="ticks"&&t.ticks.source==="labels"||u(this.getMinMax(!1))),n=W(n)&&!isNaN(n)?n:+e.startOf(Date.now(),s),o=W(o)&&!isNaN(o)?o:+e.endOf(Date.now(),s)+1,this.min=Math.min(n,o-1),this.max=Math.max(n+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],s=t[t.length-1]),{min:e,max:s}}buildTicks(){let t=this.options,e=t.time,s=t.ticks,n=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&n.length&&(this.min=this._userMin||n[0],this.max=this._userMax||n[n.length-1]);let o=this.min,a=Pt(n,o,this.max);return this._unit=e.unit||(s.autoSkip?na(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):function(l,u,g,x,b){for(let w=Si.length-1;w>=Si.indexOf(g);w--){let k=Si[w];if(wn[k].common&&l._adapter.diff(b,x,k)>=u-1)return k}return Si[g?Si.indexOf(g):0]}(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=s.major.enabled&&this._unit!=="year"?function(l){for(let u=Si.indexOf(l)+1,g=Si.length;u+t.value))}initOffsets(t=[]){let e,s,n=0,o=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),n=t.length===1?1-e:(this.getDecimalForValue(t[1])-e)/2,s=this.getDecimalForValue(t[t.length-1]),o=t.length===1?s:(s-this.getDecimalForValue(t[t.length-2]))/2);let a=t.length<3?.5:.25;n=J(n,0,a),o=J(o,0,a),this._offsets={start:n,end:o,factor:1/(n+1+o)}}_generate(){let t=this._adapter,e=this.min,s=this.max,n=this.options,o=n.time,a=o.unit||na(o.minUnit,e,s,this._getLabelCapacity(e)),l=q(n.ticks.stepSize,1),u=a==="week"&&o.isoWeekday,g=Re(u)||u===!0,x={},b,w,k=e;if(g&&(k=+t.startOf(k,"isoWeek",u)),k=+t.startOf(k,g?"day":a),t.diff(s,e,a)>1e5*l)throw new Error(e+" and "+s+" are too far apart with stepSize of "+l+" "+a);let A=n.ticks.source==="data"&&this.getDataTimestamps();for(b=k,w=0;b+T)}getLabelForValue(t){let e=this._adapter,s=this.options.time;return s.tooltipFormat?e.format(t,s.tooltipFormat):e.format(t,s.displayFormats.datetime)}format(t,e){let s=this.options.time.displayFormats,n=this._unit,o=e||s[n];return this._adapter.format(t,o)}_tickFormatFunction(t,e,s,n){let o=this.options,a=o.ticks.callback;if(a)return ft(a,[t,e,s],this);let l=o.time.displayFormats,u=this._unit,g=this._majorUnit,x=u&&l[u],b=g&&l[g],w=s[e],k=g&&b&&w&&w.major;return this._adapter.format(t,n||(k?b:x))}generateTickLabels(t){let e,s,n;for(e=0,s=t.length;e0?l:1}getDataTimestamps(){let t,e,s=this._cache.data||[];if(s.length)return s;let n=this.getMatchingVisibleMetas();if(this._normalized&&n.length)return this._cache.data=n[0].controller.getAllParsedValues(this);for(t=0,e=n.length;t=i[l].pos&&t<=i[u].pos&&({lo:l,hi:u}=dt(i,"pos",t)),{pos:s,time:o}=i[l],{pos:n,time:a}=i[u]):(t>=i[l].time&&t<=i[u].time&&({lo:l,hi:u}=dt(i,"time",t)),{time:s,pos:o}=i[l],{time:n,pos:a}=i[u]);let g=n-s;return g?o+(a-o)*(t-s)/g:o}var aa=Object.freeze({__proto__:null,CategoryScale:class extends ms{static id="category";static defaults={ticks:{callback:Qr}};constructor(i){super(i),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(i){let t=this._addedLabels;if(t.length){let e=this.getLabels();for(let{index:s,label:n}of t)e[s]===n&&e.splice(s,1);this._addedLabels=[]}super.init(i)}parse(i,t){if(C(i))return null;let e=this.getLabels();return((s,n)=>s===null?null:J(Math.round(s),0,n))(t=isFinite(t)&&e[t]===i?t:Zl(e,i,q(t,i),this._addedLabels),e.length-1)}determineDataLimits(){let{minDefined:i,maxDefined:t}=this.getUserBounds(),{min:e,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(i||(e=0),t||(s=this.getLabels().length-1)),this.min=e,this.max=s}buildTicks(){let i=this.min,t=this.max,e=this.options.offset,s=[],n=this.getLabels();n=i===0&&t===n.length-1?n:n.slice(i,t+1),this._valueRange=Math.max(n.length-(e?0:1),1),this._startValue=this.min-(e?.5:0);for(let o=i;o<=t;o++)s.push({value:o});return s}getLabelForValue(i){return Qr.call(this,i)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(i){return typeof i!="number"&&(i=this.parse(i)),i===null?NaN:this.getPixelForDecimal((i-this._startValue)/this._valueRange)}getPixelForTick(i){let t=this.ticks;return i<0||i>t.length-1?null:this.getPixelForValue(t[i].value)}getValueForPixel(i){return Math.round(this._startValue+this.getDecimalForPixel(i)*this._valueRange)}getBasePixel(){return this.bottom}},LinearScale:Jl,LogarithmicScale:eh,RadialLinearScale:ah,TimeScale:Mo,TimeSeriesScale:class extends Mo{static id="timeseries";static defaults=Mo.defaults;constructor(i){super(i),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let i=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(i);this._minPos=_n(t,this.min),this._tableRange=_n(t,this.max)-this._minPos,super.initOffsets(i)}buildLookupTable(i){let{min:t,max:e}=this,s=[],n=[],o,a,l,u,g;for(o=0,a=i.length;o=t&&u<=e&&s.push(u);if(s.length<2)return[{time:t,pos:0},{time:e,pos:1}];for(o=0,a=s.length;os-n)}_getTimestampsForTable(){let i=this._cache.all||[];if(i.length)return i;let t=this.getDataTimestamps(),e=this.getLabelTimestamps();return i=t.length&&e.length?this.normalize(t.concat(e)):t.length?t:e,i=this._cache.all=i,i}getDecimalForValue(i){return(_n(this._table,i)-this._minPos)/this._tableRange}getValueForPixel(i){let t=this._offsets,e=this.getDecimalForPixel(i)/t.factor-t.end;return _n(this._table,e*this._tableRange+this._minPos,!0)}}});let So=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],la=So.map(i=>i.replace("rgb(","rgba(").replace(")",", 0.5)"));function ha(i){return So[i%So.length]}function ca(i){return la[i%la.length]}function lh(i){let t=0;return(e,s)=>{let n=i.getDatasetMeta(s).controller;n instanceof yo?t=function(o,a){return o.backgroundColor=o.data.map(()=>ha(a++)),a}(e,t):n instanceof jr?t=function(o,a){return o.backgroundColor=o.data.map(()=>ca(a++)),a}(e,t):n&&(t=function(o,a){return o.borderColor=ha(a),o.backgroundColor=ca(a),++a}(e,t))}}function da(i){let t;for(t in i)if(i[t].borderColor||i[t].backgroundColor)return!0;return!1}var hh={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(i,t,e){if(!e.enabled)return;let{data:{datasets:s},options:n}=i.config,{elements:o}=n;if(!e.forceOverride&&(da(s)||(a=n)&&(a.borderColor||a.backgroundColor)||o&&da(o)))return;var a;let l=lh(i);s.forEach(l)}};function ua(i){if(i._decimated){let t=i._data;delete i._decimated,delete i._data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function ga(i){i.data.datasets.forEach(t=>{ua(t)})}var ch={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled)return void ga(i);let s=i.width;i.data.datasets.forEach((n,o)=>{let{_data:a,indexAxis:l}=n,u=i.getDatasetMeta(o),g=a||n.data;if(Hs([l,i.options.indexAxis])==="y"||!u.controller.supportsDecimation)return;let x=i.scales[u.xAxisID];if(x.type!=="linear"&&x.type!=="time"||i.options.parsing)return;let{start:b,count:w}=function(A,T){let R=T.length,$,tt=0,{iScale:Z}=A,{min:Q,max:ht,minDefined:mt,maxDefined:Ct}=Z.getUserBounds();return mt&&(tt=J(dt(T,Z.axis,Q).lo,0,R-1)),$=Ct?J(dt(T,Z.axis,ht).hi+1,tt,R)-tt:R-tt,{start:tt,count:$}}(u,g);if(w<=(e.threshold||4*s))return void ua(n);let k;switch(C(a)&&(n._data=g,delete n.data,Object.defineProperty(n,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(A){this._data=A}})),e.algorithm){case"lttb":k=function(A,T,R,$,tt){let Z=tt.samples||$;if(Z>=R)return A.slice(T,T+R);let Q=[],ht=(R-2)/(Z-2),mt=0,Ct=T+R-1,At,$t,It,Xt,Vt,Nt=T;for(Q[mt++]=A[Nt],At=0;AtIt&&(It=Xt,$t=A[Wt],Vt=Wt);Q[mt++]=$t,Nt=Vt}return Q[mt++]=A[Ct],Q}(g,b,w,s,e);break;case"min-max":k=function(A,T,R,$){let tt,Z,Q,ht,mt,Ct,At,$t,It,Xt,Vt=0,Nt=0,Wt=[],Ft=T+R-1,ne=A[T].x,Se=A[Ft].x-ne;for(tt=T;ttXt&&(Xt=ht,At=tt),Vt=(Nt*Vt+Z.x)/++Nt;else{let hi=tt-1;if(!C(Ct)&&!C(At)){let zi=Math.min(Ct,At),Li=Math.max(Ct,At);zi!==$t&&zi!==hi&&Wt.push({...A[zi],x:Vt}),Li!==$t&&Li!==hi&&Wt.push({...A[Li],x:Vt})}tt>0&&hi!==$t&&Wt.push(A[hi]),Wt.push(Z),mt=ye,Nt=0,It=Xt=ht,Ct=At=$t=tt}}return Wt}(g,b,w,s);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}n._decimated=k})},destroy(i){ga(i)}};function Co(i,t,e,s){if(s)return;let n=t[i],o=e[i];return i==="angle"&&(n=ve(n),o=ve(o)),{property:i,start:n,end:o}}function To(i,t,e){for(;t>i;t--){let s=e[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function pa(i,t,e,s){return i&&t?s(i[e],t[e]):i?i[e]:t?t[e]:0}function fa(i,t){let e=[],s=!1;return I(i)?(s=!0,e=i):e=function(n,o){let{x:a=null,y:l=null}=n||{},u=o.points,g=[];return o.segments.forEach(({start:x,end:b})=>{b=To(x,b,u);let w=u[x],k=u[b];l!==null?(g.push({x:w.x,y:l}),g.push({x:k.x,y:l})):a!==null&&(g.push({x:a,y:w.y}),g.push({x:a,y:k.y}))}),g}(i,t),e.length?new xn({points:e,options:{tension:0},_loop:s,_fullLoop:s}):null}function ma(i){return i&&i.fill!==!1}function dh(i,t,e){let s=i[t].fill,n=[t],o;if(!e)return s;for(;s!==!1&&n.indexOf(s)===-1;){if(!W(s))return s;if(o=i[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function uh(i,t,e){let s=function(o){let a=o.options,l=a.fill,u=q(l&&l.target,l);return u===void 0&&(u=!!a.backgroundColor),u===!1||u===null?!1:u===!0?"origin":u}(i);if(X(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return W(n)&&Math.floor(n)===n?function(o,a,l,u){return o!=="-"&&o!=="+"||(l=a+l),l===a||l<0||l>=u?!1:l}(s[0],t,n,e):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function gh(i,t,e){let s=[];for(let n=0;n=0;--a){let l=n[a].$filler;l&&(l.line.updateControlPoints(o,l.axis),s&&l.fill&&Eo(i.ctx,l,o))}},beforeDatasetsDraw(i,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;let s=i.getSortedVisibleDatasetMetas();for(let n=s.length-1;n>=0;--n){let o=s[n].$filler;ma(o)&&Eo(i.ctx,o,i.chartArea)}},beforeDatasetDraw(i,t,e){let s=t.meta.$filler;ma(s)&&e.drawTime==="beforeDatasetDraw"&&Eo(i.ctx,s,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};let wa=(i,t)=>{let{boxHeight:e=t,boxWidth:s=t}=i;return i.usePointStyle&&(e=Math.min(e,t),s=i.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:e,itemHeight:Math.max(t,e)}};class _a extends ss{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,s){this.maxWidth=t,this.maxHeight=e,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let t=this.options.labels||{},e=ft(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(s=>t.filter(s,this.chart.data))),t.sort&&(e=e.sort((s,n)=>t.sort(s,n,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){let{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);let s=t.labels,n=qe(s.font),o=n.size,a=this._computeTitleHeight(),{boxWidth:l,itemHeight:u}=wa(s,o),g,x;e.font=n.string,this.isHorizontal()?(g=this.maxWidth,x=this._fitRows(a,o,l,u)+10):(x=this.maxHeight,g=this._fitCols(a,n,l,u)+10),this.width=Math.min(g,t.maxWidth||this.maxWidth),this.height=Math.min(x,t.maxHeight||this.maxHeight)}_fitRows(t,e,s,n){let{ctx:o,maxWidth:a,options:{labels:{padding:l}}}=this,u=this.legendHitBoxes=[],g=this.lineWidths=[0],x=n+l,b=t;o.textAlign="left",o.textBaseline="middle";let w=-1,k=-x;return this.legendItems.forEach((A,T)=>{let R=s+e/2+o.measureText(A.text).width;(T===0||g[g.length-1]+R+2*l>a)&&(b+=x,g[g.length-(T>0?0:1)]=0,k+=x,w++),u[T]={left:0,top:k,row:w,width:R,height:n},g[g.length-1]+=R+l}),b}_fitCols(t,e,s,n){let{ctx:o,maxHeight:a,options:{labels:{padding:l}}}=this,u=this.legendHitBoxes=[],g=this.columnSizes=[],x=a-t,b=l,w=0,k=0,A=0,T=0;return this.legendItems.forEach((R,$)=>{let{itemWidth:tt,itemHeight:Z}=function(Q,ht,mt,Ct,At){let $t=function(Xt,Vt,Nt,Wt){let Ft=Xt.text;return Ft&&typeof Ft!="string"&&(Ft=Ft.reduce((ne,Se)=>ne.length>Se.length?ne:Se)),Vt+Nt.size/2+Wt.measureText(Ft).width}(Ct,Q,ht,mt),It=function(Xt,Vt,Nt){let Wt=Xt;return typeof Vt.text!="string"&&(Wt=ka(Vt,Nt)),Wt}(At,Ct,ht.lineHeight);return{itemWidth:$t,itemHeight:It}}(s,e,o,R,n);$>0&&k+Z+2*l>x&&(b+=w+l,g.push({width:w,height:k}),A+=w+l,T++,w=k=0),u[$]={left:A,top:k,col:T,width:tt,height:Z},w=Math.max(w,tt),k+=Z+l}),b+=w,g.push({width:w,height:k}),b}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:s,labels:{padding:n},rtl:o}}=this,a=Ss(o,this.left,this.width);if(this.isHorizontal()){let l=0,u=Te(s,this.left+n,this.right-this.lineWidths[l]);for(let g of e)l!==g.row&&(l=g.row,u=Te(s,this.left+n,this.right-this.lineWidths[l])),g.top+=this.top+t+n,g.left=a.leftForLtr(a.x(u),g.width),u+=g.width+n}else{let l=0,u=Te(s,this.top+t+n,this.bottom-this.columnSizes[l].height);for(let g of e)g.col!==l&&(l=g.col,u=Te(s,this.top+t+n,this.bottom-this.columnSizes[l].height)),g.top=u,g.left+=this.left+n,g.left=a.leftForLtr(a.x(g.left),g.width),u+=g.height+n}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;qt(t,this),this._draw(),Gt(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:s,ctx:n}=this,{align:o,labels:a}=t,l=bt.color,u=Ss(t.rtl,this.left,this.width),g=qe(a.font),{padding:x}=a,b=g.size,w=b/2,k;this.drawTitle(),n.textAlign=u.textAlign("left"),n.textBaseline="middle",n.lineWidth=.5,n.font=g.string;let{boxWidth:A,boxHeight:T,itemHeight:R}=wa(a,b),$=this.isHorizontal(),tt=this._computeTitleHeight();k=$?{x:Te(o,this.left+x,this.right-s[0]),y:this.top+x+tt,line:0}:{x:this.left+x,y:Te(o,this.top+tt+x,this.bottom-e[0].height),line:0},io(this.ctx,t.textDirection);let Z=R+x;this.legendItems.forEach((Q,ht)=>{n.strokeStyle=Q.fontColor,n.fillStyle=Q.fontColor;let mt=n.measureText(Q.text).width,Ct=u.textAlign(Q.textAlign||(Q.textAlign=a.textAlign)),At=A+w+mt,$t=k.x,It=k.y;if(u.setWidth(this.width),$?ht>0&&$t+At+x>this.right&&(It=k.y+=Z,k.line++,$t=k.x=Te(o,this.left+x,this.right-s[k.line])):ht>0&&It+Z>this.bottom&&($t=k.x=$t+e[k.line].width+x,k.line++,It=k.y=Te(o,this.top+tt+x,this.bottom-e[k.line].height)),function(Xt,Vt,Nt){if(isNaN(A)||A<=0||isNaN(T)||T<0)return;n.save();let Wt=q(Nt.lineWidth,1);if(n.fillStyle=q(Nt.fillStyle,l),n.lineCap=q(Nt.lineCap,"butt"),n.lineDashOffset=q(Nt.lineDashOffset,0),n.lineJoin=q(Nt.lineJoin,"miter"),n.lineWidth=Wt,n.strokeStyle=q(Nt.strokeStyle,l),n.setLineDash(q(Nt.lineDash,[])),a.usePointStyle){let Ft={radius:T*Math.SQRT2/2,pointStyle:Nt.pointStyle,rotation:Nt.rotation,borderWidth:Wt},ne=u.xPlus(Xt,A/2);wt(n,Ft,ne,Vt+w,a.pointStyleWidth&&A)}else{let Ft=Vt+Math.max((b-T)/2,0),ne=u.leftForLtr(Xt,A),Se=fs(Nt.borderRadius);n.beginPath(),Object.values(Se).some(ye=>ye!==0)?xi(n,{x:ne,y:Ft,w:A,h:T,radius:Se}):n.rect(ne,Ft,A,T),n.fill(),Wt!==0&&n.stroke()}n.restore()}(u.x($t),It,Q),$t=rs(Ct,$t+A+w,$?$t+At:this.right,t.rtl),function(Xt,Vt,Nt){Qe(n,Nt.text,Xt,Vt+R/2,g,{strikethrough:Nt.hidden,textAlign:u.textAlign(Nt.textAlign)})}(u.x($t),It,Q),$)k.x+=At+x;else if(typeof Q.text!="string"){let Xt=g.lineHeight;k.y+=ka(Q,Xt)+x}else k.y+=Z}),so(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,s=qe(e.font),n=ai(e.padding);if(!e.display)return;let o=Ss(t.rtl,this.left,this.width),a=this.ctx,l=e.position,u=s.size/2,g=n.top+u,x,b=this.left,w=this.width;if(this.isHorizontal())w=Math.max(...this.lineWidths),x=this.top+g,b=Te(t.align,b,this.right-w);else{let A=this.columnSizes.reduce((T,R)=>Math.max(T,R.height),0);x=g+Te(t.align,this.top,this.bottom-A-t.labels.padding-this._computeTitleHeight())}let k=Te(l,b,b+w);a.textAlign=o.textAlign(xe(l)),a.textBaseline="middle",a.strokeStyle=e.color,a.fillStyle=e.color,a.font=s.string,Qe(a,e.text,k,x,s)}_computeTitleHeight(){let t=this.options.title,e=qe(t.font),s=ai(t.padding);return t.display?e.lineHeight+s.height:0}_getLegendItemAt(t,e){let s,n,o;if(ot(t,this.left,this.right)&&ot(e,this.top,this.bottom)){for(o=this.legendHitBoxes,s=0;si.chart.options.color,boxWidth:40,padding:10,generateLabels(i){let t=i.data.datasets,{labels:{usePointStyle:e,pointStyle:s,textAlign:n,color:o,useBorderRadius:a,borderRadius:l}}=i.legend.options;return i._getSortedDatasetMetas().map(u=>{let g=u.controller.getStyle(e?0:void 0),x=ai(g.borderWidth);return{text:t[u.index].label,fillStyle:g.backgroundColor,fontColor:o,hidden:!u.visible,lineCap:g.borderCapStyle,lineDash:g.borderDash,lineDashOffset:g.borderDashOffset,lineJoin:g.borderJoinStyle,lineWidth:(x.width+x.height)/4,strokeStyle:g.borderColor,pointStyle:s||g.pointStyle,rotation:g.rotation,textAlign:n||g.textAlign,borderRadius:a&&(l||g.borderRadius),datasetIndex:u.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class Do extends ss{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){let s=this.options;if(this.left=0,this.top=0,!s.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;let n=I(s.text)?s.text.length:1;this._padding=ai(s.padding);let o=n*qe(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){let t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){let{top:e,left:s,bottom:n,right:o,options:a}=this,l=a.align,u,g,x,b=0;return this.isHorizontal()?(g=Te(l,s,o),x=e+t,u=o-s):(a.position==="left"?(g=s+t,x=Te(l,n,e),b=-.5*y):(g=o-t,x=Te(l,e,n),b=.5*y),u=n-e),{titleX:g,titleY:x,maxWidth:u,rotation:b}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let s=qe(e.font),n=s.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:l,rotation:u}=this._drawArgs(n);Qe(t,e.text,0,0,s,{color:e.color,maxWidth:l,rotation:u,textAlign:xe(e.align),textBaseline:"middle",translation:[o,a]})}}var xh={id:"title",_element:Do,start(i,t,e){(function(s,n){let o=new Do({ctx:s.ctx,options:n,chart:s});li.configure(s,o,n),li.addBox(s,o),s.titleBlock=o})(i,e)},stop(i){let t=i.titleBlock;li.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){let s=i.titleBlock;li.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let kn=new WeakMap;var vh={id:"subtitle",start(i,t,e){let s=new Do({ctx:i.ctx,options:e,chart:i});li.configure(i,s,e),li.addBox(i,s),kn.set(i,s)},stop(i){li.removeBox(i,kn.get(i)),kn.delete(i)},beforeUpdate(i,t,e){let s=kn.get(i);li.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};let Ks={average(i){if(!i.length)return!1;let t,e,s=0,n=0,o=0;for(t=0,e=i.length;t-1?i.split(` -`):i}function wh(i,t){let{element:e,datasetIndex:s,index:n}=t,o=i.getDatasetMeta(s).controller,{label:a,value:l}=o.getLabelAndValue(n);return{chart:i,label:a,parsed:o.getParsed(n),raw:i.data.datasets[s].data[n],formattedValue:l,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:e}}function Ma(i,t){let e=i.chart.ctx,{body:s,footer:n,title:o}=i,{boxWidth:a,boxHeight:l}=t,u=qe(t.bodyFont),g=qe(t.titleFont),x=qe(t.footerFont),b=o.length,w=n.length,k=s.length,A=ai(t.padding),T=A.height,R=0,$=s.reduce((Q,ht)=>Q+ht.before.length+ht.lines.length+ht.after.length,0);$+=i.beforeBody.length+i.afterBody.length,b&&(T+=b*g.lineHeight+(b-1)*t.titleSpacing+t.titleMarginBottom),$&&(T+=k*(t.displayColors?Math.max(l,u.lineHeight):u.lineHeight)+($-k)*u.lineHeight+($-1)*t.bodySpacing),w&&(T+=t.footerMarginTop+w*x.lineHeight+(w-1)*t.footerSpacing);let tt=0,Z=function(Q){R=Math.max(R,e.measureText(Q).width+tt)};return e.save(),e.font=g.string,xt(i.title,Z),e.font=u.string,xt(i.beforeBody.concat(i.afterBody),Z),tt=t.displayColors?a+2+t.boxPadding:0,xt(s,Q=>{xt(Q.before,Z),xt(Q.lines,Z),xt(Q.after,Z)}),tt=0,e.font=x.string,xt(i.footer,Z),e.restore(),R+=A.width,{width:R,height:T}}function _h(i,t,e,s){let{x:n,width:o}=e,{width:a,chartArea:{left:l,right:u}}=i,g="center";return s==="center"?g=n<=(l+u)/2?"left":"right":n<=o/2?g="left":n>=a-o/2&&(g="right"),function(x,b,w,k){let{x:A,width:T}=k,R=w.caretSize+w.caretPadding;return x==="left"&&A+T+R>b.width||x==="right"&&A-T-R<0||void 0}(g,i,t,e)&&(g="center"),g}function Sa(i,t,e){let s=e.yAlign||t.yAlign||function(n,o){let{y:a,height:l}=o;return an.height-l/2?"bottom":"center"}(i,e);return{xAlign:e.xAlign||t.xAlign||_h(i,t,e,s),yAlign:s}}function Ca(i,t,e,s){let{caretSize:n,caretPadding:o,cornerRadius:a}=i,{xAlign:l,yAlign:u}=e,g=n+o,{topLeft:x,topRight:b,bottomLeft:w,bottomRight:k}=fs(a),A=function(R,$){let{x:tt,width:Z}=R;return $==="right"?tt-=Z:$==="center"&&(tt-=Z/2),tt}(t,l),T=function(R,$,tt){let{y:Z,height:Q}=R;return $==="top"?Z+=tt:Z-=$==="bottom"?Q+tt:Q/2,Z}(t,u,g);return u==="center"?l==="left"?A+=g:l==="right"&&(A-=g):l==="left"?A-=Math.max(x,w)+n:l==="right"&&(A+=Math.max(b,k)+n),{x:J(A,0,s.width-t.width),y:J(T,0,s.height-t.height)}}function Mn(i,t,e){let s=ai(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-s.right:i.x+s.left}function Ta(i){return ns([],hs(i))}function Ea(i,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}let Da={beforeTitle:h,title(i){if(i.length>0){let t=i[0],e=t.chart.data.labels,s=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex{let a={before:[],lines:[],after:[]},l=Ea(s,o);ns(a.before,hs(Ci(l,"beforeLabel",this,o))),ns(a.lines,Ci(l,"label",this,o)),ns(a.after,hs(Ci(l,"afterLabel",this,o))),n.push(a)}),n}getAfterBody(t,e){return Ta(Ci(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:s}=e,n=Ci(s,"beforeFooter",this,t),o=Ci(s,"footer",this,t),a=Ci(s,"afterFooter",this,t),l=[];return l=ns(l,hs(n)),l=ns(l,hs(o)),l=ns(l,hs(a)),l}_createItems(t){let e=this._active,s=this.chart.data,n=[],o=[],a=[],l,u,g=[];for(l=0,u=e.length;lt.filter(x,b,w,s))),t.itemSort&&(g=g.sort((x,b)=>t.itemSort(x,b,s))),xt(g,x=>{let b=Ea(t.callbacks,x);n.push(Ci(b,"labelColor",this,x)),o.push(Ci(b,"labelPointStyle",this,x)),a.push(Ci(b,"labelTextColor",this,x))}),this.labelColors=n,this.labelPointStyles=o,this.labelTextColors=a,this.dataPoints=g,g}update(t,e){let s=this.options.setContext(this.getContext()),n=this._active,o,a=[];if(n.length){let l=Ks[s.position].call(this,n,this._eventPosition);a=this._createItems(s),this.title=this.getTitle(a,s),this.beforeBody=this.getBeforeBody(a,s),this.body=this.getBody(a,s),this.afterBody=this.getAfterBody(a,s),this.footer=this.getFooter(a,s);let u=this._size=Ma(this,s),g=Object.assign({},l,u),x=Sa(this.chart,s,g),b=Ca(s,g,x,this.chart);this.xAlign=x.xAlign,this.yAlign=x.yAlign,o={opacity:1,x:b.x,y:b.y,width:u.width,height:u.height,caretX:l.x,caretY:l.y}}else this.opacity!==0&&(o={opacity:0});this._tooltipItems=a,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,s,n){let o=this.getCaretPosition(t,s,n);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,s){let{xAlign:n,yAlign:o}=this,{caretSize:a,cornerRadius:l}=s,{topLeft:u,topRight:g,bottomLeft:x,bottomRight:b}=fs(l),{x:w,y:k}=t,{width:A,height:T}=e,R,$,tt,Z,Q,ht;return o==="center"?(Q=k+T/2,n==="left"?(R=w,$=R-a,Z=Q+a,ht=Q-a):(R=w+A,$=R+a,Z=Q-a,ht=Q+a),tt=R):($=n==="left"?w+Math.max(u,x)+a:n==="right"?w+A-Math.max(g,b)-a:this.caretX,o==="top"?(Z=k,Q=Z-a,R=$-a,tt=$+a):(Z=k+T,Q=Z+a,R=$+a,tt=$-a),ht=Z),{x1:R,x2:$,x3:tt,y1:Z,y2:Q,y3:ht}}drawTitle(t,e,s){let n=this.title,o=n.length,a,l,u;if(o){let g=Ss(s.rtl,this.x,this.width);for(t.x=Mn(this,s.titleAlign,s),e.textAlign=g.textAlign(s.titleAlign),e.textBaseline="middle",a=qe(s.titleFont),l=s.titleSpacing,e.fillStyle=s.titleColor,e.font=a.string,u=0;utt!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,xi(t,{x:T,y:A,w:g,h:u,radius:$}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),xi(t,{x:R,y:A+1,w:g-2,h:u-2,radius:$}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(T,A,g,u),t.strokeRect(T,A,g,u),t.fillStyle=a.backgroundColor,t.fillRect(R,A+1,g-2,u-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,e,s){let{body:n}=this,{bodySpacing:o,bodyAlign:a,displayColors:l,boxHeight:u,boxWidth:g,boxPadding:x}=s,b=qe(s.bodyFont),w=b.lineHeight,k=0,A=Ss(s.rtl,this.x,this.width),T=function(At){e.fillText(At,A.x(t.x+k),t.y+w/2),t.y+=w+o},R=A.textAlign(a),$,tt,Z,Q,ht,mt,Ct;for(e.textAlign=a,e.textBaseline="middle",e.font=b.string,t.x=Mn(this,R,s),e.fillStyle=s.bodyColor,xt(this.beforeBody,T),k=l&&R!=="right"?a==="center"?g/2+x:g+2+x:0,Q=0,mt=n.length;Q0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,s=this.$animations,n=s&&s.x,o=s&&s.y;if(n||o){let a=Ks[t.position].call(this,this._active,this._eventPosition);if(!a)return;let l=this._size=Ma(this,t),u=Object.assign({},a,this._size),g=Sa(e,t,u),x=Ca(t,u,g,e);n._to===x.x&&o._to===x.y||(this.xAlign=g.xAlign,this.yAlign=g.yAlign,this.width=l.width,this.height=l.height,this.caretX=a.x,this.caretY=a.y,this._resolveAnimations().update(this,x))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),s=this.opacity;if(!s)return;this._updateAnimationTarget(e);let n={width:this.width,height:this.height},o={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;let a=ai(e.padding),l=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&l&&(t.save(),t.globalAlpha=s,this.drawBackground(o,t,n,e),io(t,e.textDirection),o.y+=a.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),so(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let s=this._active,n=t.map(({datasetIndex:l,index:u})=>{let g=this.chart.getDatasetMeta(l);if(!g)throw new Error("Cannot find a dataset at index "+l);return{datasetIndex:l,element:g.data[u],index:u}}),o=!jt(s,n),a=this._positionChanged(n,e);(o||a)&&(this._active=n,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,s=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let n=this.options,o=this._active||[],a=this._getActiveElements(t,o,e,s),l=this._positionChanged(a,t),u=e||!jt(a,o)||l;return u&&(this._active=a,(n.enabled||n.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),u}_getActiveElements(t,e,s,n){let o=this.options;if(t.type==="mouseout")return[];if(!n)return e.filter(l=>this.chart.data.datasets[l.datasetIndex]&&this.chart.getDatasetMeta(l.datasetIndex).controller.getParsed(l.index)!==void 0);let a=this.chart.getElementsAtEventForMode(t,o.mode,o,s);return o.reverse&&a.reverse(),a}_positionChanged(t,e){let{caretX:s,caretY:n,options:o}=this,a=Ks[o.position].call(this,t,e);return a!==!1&&(s!==a.x||n!==a.y)}}var kh={id:"tooltip",_element:Pa,positioners:Ks,afterInit(i,t,e){e&&(i.tooltip=new Pa({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){let t=i.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){let e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Da},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};return Ve.register(Vr,aa,_o,D),Ve.helpers={...gl},Ve._adapters=$r,Ve.Animation=pr,Ve.Animations=co,Ve.animator=Be,Ve.controllers=Yi.controllers.items,Ve.DatasetController=ls,Ve.Element=ss,Ve.elements=_o,Ve.Interaction=Jo,Ve.layouts=li,Ve.platforms=ur,Ve.Scale=ms,Ve.Ticks=pt,Object.assign(Ve,Vr,aa,_o,D,ur),Ve.Chart=Ve,typeof window<"u"&&(window.Chart=Ve),Ve});(function(D,h){typeof exports=="object"&&typeof module<"u"?h(ys("chart.js")):typeof define=="function"&&define.amd?define(["chart.js"],h):h((D=typeof globalThis<"u"?globalThis:D||self).Chart)})(void 0,function(D){"use strict";function h(c){if(c===null||c===!0||c===!1)return NaN;var p=Number(c);return isNaN(p)?p:p<0?Math.ceil(p):Math.floor(p)}function f(c,p){if(p.length1?"s":"")+" required, but only "+p.length+" present")}function C(c){f(1,arguments);var p=Object.prototype.toString.call(c);return c instanceof Date||typeof c=="object"&&p==="[object Date]"?new Date(c.getTime()):typeof c=="number"||p==="[object Number]"?new Date(c):(typeof c!="string"&&p!=="[object String]"||typeof console>"u"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function H(c,p){f(2,arguments);var m=C(c),_=h(p);return isNaN(_)?new Date(NaN):(_&&m.setDate(m.getDate()+_),m)}function X(c,p){f(2,arguments);var m=C(c),_=h(p);if(isNaN(_))return new Date(NaN);if(!_)return m;var L=m.getDate(),K=new Date(m.getTime());K.setMonth(m.getMonth()+_+1,0);var gt=K.getDate();return L>=gt?K:(m.setFullYear(K.getFullYear(),K.getMonth(),L),m)}function W(c,p){f(2,arguments);var m=C(c).getTime(),_=h(p);return new Date(m+_)}var at=36e5;function q(c,p){f(1,arguments);var m=p||{},_=m.locale,L=_&&_.options&&_.options.weekStartsOn,K=L==null?0:h(L),gt=m.weekStartsOn==null?K:h(m.weekStartsOn);if(!(gt>=0&><=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var wt=C(c),Mt=wt.getDay(),qt=(Mt0?1:L}function te(c){f(1,arguments);var p=C(c);return!isNaN(p)}function ae(c,p){f(2,arguments);var m=C(c),_=C(p),L=m.getFullYear()-_.getFullYear(),K=m.getMonth()-_.getMonth();return 12*L+K}function Ae(c,p){f(2,arguments);var m=C(c),_=C(p);return m.getFullYear()-_.getFullYear()}function ue(c,p){var m=c.getFullYear()-p.getFullYear()||c.getMonth()-p.getMonth()||c.getDate()-p.getDate()||c.getHours()-p.getHours()||c.getMinutes()-p.getMinutes()||c.getSeconds()-p.getSeconds()||c.getMilliseconds()-p.getMilliseconds();return m<0?-1:m>0?1:m}function _e(c,p){f(2,arguments);var m=C(c),_=C(p),L=ue(m,_),K=Math.abs(xt(m,_));m.setDate(m.getDate()-L*K);var gt=ue(m,_)===-L,wt=L*(K-gt);return wt===0?0:wt}function Oe(c,p){f(2,arguments);var m=C(c),_=C(p);return m.getTime()-_.getTime()}var Ee=36e5;function Ge(c){f(1,arguments);var p=C(c);return p.setHours(23,59,59,999),p}function De(c){f(1,arguments);var p=C(c),m=p.getMonth();return p.setFullYear(p.getFullYear(),m+1,0),p.setHours(23,59,59,999),p}function se(c){f(1,arguments);var p=C(c);return Ge(p).getTime()===De(p).getTime()}function Bt(c,p){f(2,arguments);var m,_=C(c),L=C(p),K=jt(_,L),gt=Math.abs(ae(_,L));if(gt<1)m=0;else{_.getMonth()===1&&_.getDate()>27&&_.setDate(30),_.setMonth(_.getMonth()-K*gt);var wt=jt(_,L)===-K;se(C(c))&>===1&&jt(c,L)===1&&(wt=!1),m=K*(gt-wt)}return m===0?0:m}var St={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function r(c){return function(p){var m=p||{},_=m.width?String(m.width):c.defaultWidth;return c.formats[_]||c.formats[c.defaultWidth]}}var d={date:r({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:r({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:r({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},y={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function v(c){return function(p,m){var _,L=m||{};if((L.context?String(L.context):"standalone")==="formatting"&&c.formattingValues){var K=c.defaultFormattingWidth||c.defaultWidth,gt=L.width?String(L.width):K;_=c.formattingValues[gt]||c.formattingValues[K]}else{var wt=c.defaultWidth,Mt=L.width?String(L.width):c.defaultWidth;_=c.values[Mt]||c.values[wt]}return _[c.argumentCallback?c.argumentCallback(p):p]}}function P(c){return function(p,m){var _=String(p),L=m||{},K=L.width,gt=K&&c.matchPatterns[K]||c.matchPatterns[c.defaultMatchWidth],wt=_.match(gt);if(!wt)return null;var Mt,qt=wt[0],Gt=K&&c.parsePatterns[K]||c.parsePatterns[c.defaultParseWidth];return Mt=Object.prototype.toString.call(Gt)==="[object Array]"?function(Jt,pe){for(var he=0;he0?"in "+_:_+" ago":_},formatLong:d,formatRelative:function(c,p,m,_){return y[c]},localize:{ordinalNumber:function(c,p){var m=Number(c),_=m%100;if(_>20||_<10)switch(_%10){case 1:return m+"st";case 2:return m+"nd";case 3:return m+"rd"}return m+"th"},era:v({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:v({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(c){return Number(c)-1}}),month:v({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:v({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:v({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(F={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(c){return parseInt(c,10)}},function(c,p){var m=String(c),_=p||{},L=m.match(F.matchPattern);if(!L)return null;var K=L[0],gt=m.match(F.parsePattern);if(!gt)return null;var wt=F.valueCallback?F.valueCallback(gt[0]):gt[0];return{value:wt=_.valueCallback?_.valueCallback(wt):wt,rest:m.slice(K.length)}}),era:P({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:P({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(c){return c+1}}),month:P({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:P({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:P({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function nt(c,p){f(2,arguments);var m=h(p);return W(c,-m)}function V(c,p){for(var m=c<0?"-":"",_=Math.abs(c).toString();_.length0?m:1-m;return V(p==="yy"?_%100:_,p.length)},M:function(c,p){var m=c.getUTCMonth();return p==="M"?String(m+1):V(m+1,2)},d:function(c,p){return V(c.getUTCDate(),p.length)},a:function(c,p){var m=c.getUTCHours()/12>=1?"pm":"am";switch(p){case"a":case"aa":return m.toUpperCase();case"aaa":return m;case"aaaaa":return m[0];default:return m==="am"?"a.m.":"p.m."}},h:function(c,p){return V(c.getUTCHours()%12||12,p.length)},H:function(c,p){return V(c.getUTCHours(),p.length)},m:function(c,p){return V(c.getUTCMinutes(),p.length)},s:function(c,p){return V(c.getUTCSeconds(),p.length)},S:function(c,p){var m=p.length,_=c.getUTCMilliseconds();return V(Math.floor(_*Math.pow(10,m-3)),p.length)}},kt=864e5;function Et(c){f(1,arguments);var p=1,m=C(c),_=m.getUTCDay(),L=(_=L.getTime()?m+1:p.getTime()>=gt.getTime()?m:m-1}function Le(c){f(1,arguments);var p=ie(c),m=new Date(0);m.setUTCFullYear(p,0,4),m.setUTCHours(0,0,0,0);var _=Et(m);return _}var ii=6048e5;function Re(c){f(1,arguments);var p=C(c),m=Et(p).getTime()-Le(p).getTime();return Math.round(m/ii)+1}function We(c,p){f(1,arguments);var m=p||{},_=m.locale,L=_&&_.options&&_.options.weekStartsOn,K=L==null?0:h(L),gt=m.weekStartsOn==null?K:h(m.weekStartsOn);if(!(gt>=0&><=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var wt=C(c),Mt=wt.getUTCDay(),qt=(Mt=1&&Mt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var qt=new Date(0);qt.setUTCFullYear(_+1,0,Mt),qt.setUTCHours(0,0,0,0);var Gt=We(qt,p),Jt=new Date(0);Jt.setUTCFullYear(_,0,Mt),Jt.setUTCHours(0,0,0,0);var pe=We(Jt,p);return m.getTime()>=Gt.getTime()?_+1:m.getTime()>=pe.getTime()?_:_-1}function He(c,p){f(1,arguments);var m=p||{},_=m.locale,L=_&&_.options&&_.options.firstWeekContainsDate,K=L==null?1:h(L),gt=m.firstWeekContainsDate==null?K:h(m.firstWeekContainsDate),wt=Je(c,p),Mt=new Date(0);Mt.setUTCFullYear(wt,0,gt),Mt.setUTCHours(0,0,0,0);var qt=We(Mt,p);return qt}var ti=6048e5;function Ne(c,p){f(1,arguments);var m=C(c),_=We(m,p).getTime()-He(m,p).getTime();return Math.round(_/ti)+1}var si="midnight",wi="noon",Di="morning",ve="afternoon",N="evening",J="night",et={G:function(c,p,m){var _=c.getUTCFullYear()>0?1:0;switch(p){case"G":case"GG":case"GGG":return m.era(_,{width:"abbreviated"});case"GGGGG":return m.era(_,{width:"narrow"});default:return m.era(_,{width:"wide"})}},y:function(c,p,m){if(p==="yo"){var _=c.getUTCFullYear(),L=_>0?_:1-_;return m.ordinalNumber(L,{unit:"year"})}return it.y(c,p)},Y:function(c,p,m,_){var L=Je(c,_),K=L>0?L:1-L;return p==="YY"?V(K%100,2):p==="Yo"?m.ordinalNumber(K,{unit:"year"}):V(K,p.length)},R:function(c,p){return V(ie(c),p.length)},u:function(c,p){return V(c.getUTCFullYear(),p.length)},Q:function(c,p,m){var _=Math.ceil((c.getUTCMonth()+1)/3);switch(p){case"Q":return String(_);case"QQ":return V(_,2);case"Qo":return m.ordinalNumber(_,{unit:"quarter"});case"QQQ":return m.quarter(_,{width:"abbreviated",context:"formatting"});case"QQQQQ":return m.quarter(_,{width:"narrow",context:"formatting"});default:return m.quarter(_,{width:"wide",context:"formatting"})}},q:function(c,p,m){var _=Math.ceil((c.getUTCMonth()+1)/3);switch(p){case"q":return String(_);case"qq":return V(_,2);case"qo":return m.ordinalNumber(_,{unit:"quarter"});case"qqq":return m.quarter(_,{width:"abbreviated",context:"standalone"});case"qqqqq":return m.quarter(_,{width:"narrow",context:"standalone"});default:return m.quarter(_,{width:"wide",context:"standalone"})}},M:function(c,p,m){var _=c.getUTCMonth();switch(p){case"M":case"MM":return it.M(c,p);case"Mo":return m.ordinalNumber(_+1,{unit:"month"});case"MMM":return m.month(_,{width:"abbreviated",context:"formatting"});case"MMMMM":return m.month(_,{width:"narrow",context:"formatting"});default:return m.month(_,{width:"wide",context:"formatting"})}},L:function(c,p,m){var _=c.getUTCMonth();switch(p){case"L":return String(_+1);case"LL":return V(_+1,2);case"Lo":return m.ordinalNumber(_+1,{unit:"month"});case"LLL":return m.month(_,{width:"abbreviated",context:"standalone"});case"LLLLL":return m.month(_,{width:"narrow",context:"standalone"});default:return m.month(_,{width:"wide",context:"standalone"})}},w:function(c,p,m,_){var L=Ne(c,_);return p==="wo"?m.ordinalNumber(L,{unit:"week"}):V(L,p.length)},I:function(c,p,m){var _=Re(c);return p==="Io"?m.ordinalNumber(_,{unit:"week"}):V(_,p.length)},d:function(c,p,m){return p==="do"?m.ordinalNumber(c.getUTCDate(),{unit:"date"}):it.d(c,p)},D:function(c,p,m){var _=function(L){f(1,arguments);var K=C(L),gt=K.getTime();K.setUTCMonth(0,1),K.setUTCHours(0,0,0,0);var wt=K.getTime(),Mt=gt-wt;return Math.floor(Mt/kt)+1}(c);return p==="Do"?m.ordinalNumber(_,{unit:"dayOfYear"}):V(_,p.length)},E:function(c,p,m){var _=c.getUTCDay();switch(p){case"E":case"EE":case"EEE":return m.day(_,{width:"abbreviated",context:"formatting"});case"EEEEE":return m.day(_,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(_,{width:"short",context:"formatting"});default:return m.day(_,{width:"wide",context:"formatting"})}},e:function(c,p,m,_){var L=c.getUTCDay(),K=(L-_.weekStartsOn+8)%7||7;switch(p){case"e":return String(K);case"ee":return V(K,2);case"eo":return m.ordinalNumber(K,{unit:"day"});case"eee":return m.day(L,{width:"abbreviated",context:"formatting"});case"eeeee":return m.day(L,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(L,{width:"short",context:"formatting"});default:return m.day(L,{width:"wide",context:"formatting"})}},c:function(c,p,m,_){var L=c.getUTCDay(),K=(L-_.weekStartsOn+8)%7||7;switch(p){case"c":return String(K);case"cc":return V(K,p.length);case"co":return m.ordinalNumber(K,{unit:"day"});case"ccc":return m.day(L,{width:"abbreviated",context:"standalone"});case"ccccc":return m.day(L,{width:"narrow",context:"standalone"});case"cccccc":return m.day(L,{width:"short",context:"standalone"});default:return m.day(L,{width:"wide",context:"standalone"})}},i:function(c,p,m){var _=c.getUTCDay(),L=_===0?7:_;switch(p){case"i":return String(L);case"ii":return V(L,p.length);case"io":return m.ordinalNumber(L,{unit:"day"});case"iii":return m.day(_,{width:"abbreviated",context:"formatting"});case"iiiii":return m.day(_,{width:"narrow",context:"formatting"});case"iiiiii":return m.day(_,{width:"short",context:"formatting"});default:return m.day(_,{width:"wide",context:"formatting"})}},a:function(c,p,m){var _=c.getUTCHours()/12>=1?"pm":"am";switch(p){case"a":case"aa":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"});case"aaa":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return m.dayPeriod(_,{width:"narrow",context:"formatting"});default:return m.dayPeriod(_,{width:"wide",context:"formatting"})}},b:function(c,p,m){var _,L=c.getUTCHours();switch(_=L===12?wi:L===0?si:L/12>=1?"pm":"am",p){case"b":case"bb":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"});case"bbb":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return m.dayPeriod(_,{width:"narrow",context:"formatting"});default:return m.dayPeriod(_,{width:"wide",context:"formatting"})}},B:function(c,p,m){var _,L=c.getUTCHours();switch(_=L>=17?N:L>=12?ve:L>=4?Di:J,p){case"B":case"BB":case"BBB":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"});case"BBBBB":return m.dayPeriod(_,{width:"narrow",context:"formatting"});default:return m.dayPeriod(_,{width:"wide",context:"formatting"})}},h:function(c,p,m){if(p==="ho"){var _=c.getUTCHours()%12;return _===0&&(_=12),m.ordinalNumber(_,{unit:"hour"})}return it.h(c,p)},H:function(c,p,m){return p==="Ho"?m.ordinalNumber(c.getUTCHours(),{unit:"hour"}):it.H(c,p)},K:function(c,p,m){var _=c.getUTCHours()%12;return p==="Ko"?m.ordinalNumber(_,{unit:"hour"}):V(_,p.length)},k:function(c,p,m){var _=c.getUTCHours();return _===0&&(_=24),p==="ko"?m.ordinalNumber(_,{unit:"hour"}):V(_,p.length)},m:function(c,p,m){return p==="mo"?m.ordinalNumber(c.getUTCMinutes(),{unit:"minute"}):it.m(c,p)},s:function(c,p,m){return p==="so"?m.ordinalNumber(c.getUTCSeconds(),{unit:"second"}):it.s(c,p)},S:function(c,p){return it.S(c,p)},X:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();if(L===0)return"Z";switch(p){case"X":return ut(L);case"XXXX":case"XX":return dt(L);default:return dt(L,":")}},x:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();switch(p){case"x":return ut(L);case"xxxx":case"xx":return dt(L);default:return dt(L,":")}},O:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();switch(p){case"O":case"OO":case"OOO":return"GMT"+ot(L,":");default:return"GMT"+dt(L,":")}},z:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();switch(p){case"z":case"zz":case"zzz":return"GMT"+ot(L,":");default:return"GMT"+dt(L,":")}},t:function(c,p,m,_){var L=_._originalDate||c;return V(Math.floor(L.getTime()/1e3),p.length)},T:function(c,p,m,_){return V((_._originalDate||c).getTime(),p.length)}};function ot(c,p){var m=c>0?"-":"+",_=Math.abs(c),L=Math.floor(_/60),K=_%60;if(K===0)return m+String(L);var gt=p||"";return m+String(L)+gt+V(K,2)}function ut(c,p){return c%60==0?(c>0?"-":"+")+V(Math.abs(c)/60,2):dt(c,p)}function dt(c,p){var m=p||"",_=c>0?"-":"+",L=Math.abs(c);return _+V(Math.floor(L/60),2)+m+V(L%60,2)}var yt=et;function Pt(c,p){switch(c){case"P":return p.date({width:"short"});case"PP":return p.date({width:"medium"});case"PPP":return p.date({width:"long"});default:return p.date({width:"full"})}}function Tt(c,p){switch(c){case"p":return p.time({width:"short"});case"pp":return p.time({width:"medium"});case"ppp":return p.time({width:"long"});default:return p.time({width:"full"})}}var Ut={p:Tt,P:function(c,p){var m,_=c.match(/(P+)(p+)?/),L=_[1],K=_[2];if(!K)return Pt(c,p);switch(L){case"P":m=p.dateTime({width:"short"});break;case"PP":m=p.dateTime({width:"medium"});break;case"PPP":m=p.dateTime({width:"long"});break;default:m=p.dateTime({width:"full"})}return m.replace("{{date}}",Pt(L,p)).replace("{{time}}",Tt(K,p))}},zt=Ut,ce=["D","DD"],re=["YY","YYYY"];function Ce(c){return ce.indexOf(c)!==-1}function fe(c){return re.indexOf(c)!==-1}function xe(c,p,m){if(c==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(p,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(c==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(p,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(c==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(p,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(c==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(p,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"))}var Te=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,rs=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ci=/^'([^]*?)'?$/,di=/''/g,Ki=/[a-zA-Z]/;function Be(c){return c.match(ci)[1].replace(di,"'")}function Ii(c,p){if(c==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var m in p=p||{})p.hasOwnProperty(m)&&(c[m]=p[m]);return c}function ni(c,p,m){f(2,arguments);var _=m||{},L=_.locale,K=L&&L.options&&L.options.weekStartsOn,gt=K==null?0:h(K),wt=_.weekStartsOn==null?gt:h(_.weekStartsOn);if(!(wt>=0&&wt<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Mt=C(c),qt=h(p),Gt=Mt.getUTCDay(),Jt=qt%7,pe=(Jt+7)%7,he=(pe0,L=_?p:1-p;if(L<=50)m=c||100;else{var K=L+50;m=c+100*Math.floor(K/100)-(c>=K%100?100:0)}return _?m:1-m}var z=[31,28,31,30,31,30,31,31,30,31,30,31],I=[31,29,31,30,31,30,31,31,30,31,30,31];function j(c){return c%400==0||c%4==0&&c%100!=0}var U={G:{priority:140,parse:function(c,p,m,_){switch(p){case"G":case"GG":case"GGG":return m.era(c,{width:"abbreviated"})||m.era(c,{width:"narrow"});case"GGGGG":return m.era(c,{width:"narrow"});default:return m.era(c,{width:"wide"})||m.era(c,{width:"abbreviated"})||m.era(c,{width:"narrow"})}},set:function(c,p,m,_){return p.era=m,c.setUTCFullYear(m,0,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["R","u","t","T"]},y:{priority:130,parse:function(c,p,m,_){var L=function(K){return{year:K,isTwoDigitYear:p==="yy"}};switch(p){case"y":return we(4,c,L);case"yo":return m.ordinalNumber(c,{unit:"year",valueCallback:L});default:return we(p.length,c,L)}},validate:function(c,p,m){return p.isTwoDigitYear||p.year>0},set:function(c,p,m,_){var L=c.getUTCFullYear();if(m.isTwoDigitYear){var K=M(m.year,L);return c.setUTCFullYear(K,0,1),c.setUTCHours(0,0,0,0),c}var gt="era"in p&&p.era!==1?1-m.year:m.year;return c.setUTCFullYear(gt,0,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","u","w","I","i","e","c","t","T"]},Y:{priority:130,parse:function(c,p,m,_){var L=function(K){return{year:K,isTwoDigitYear:p==="YY"}};switch(p){case"Y":return we(4,c,L);case"Yo":return m.ordinalNumber(c,{unit:"year",valueCallback:L});default:return we(p.length,c,L)}},validate:function(c,p,m){return p.isTwoDigitYear||p.year>0},set:function(c,p,m,_){var L=Je(c,_);if(m.isTwoDigitYear){var K=M(m.year,L);return c.setUTCFullYear(K,0,_.firstWeekContainsDate),c.setUTCHours(0,0,0,0),We(c,_)}var gt="era"in p&&p.era!==1?1-m.year:m.year;return c.setUTCFullYear(gt,0,_.firstWeekContainsDate),c.setUTCHours(0,0,0,0),We(c,_)},incompatibleTokens:["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:{priority:130,parse:function(c,p,m,_){return es(p==="R"?4:p.length,c)},set:function(c,p,m,_){var L=new Date(0);return L.setUTCFullYear(m,0,4),L.setUTCHours(0,0,0,0),Et(L)},incompatibleTokens:["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:{priority:130,parse:function(c,p,m,_){return es(p==="u"?4:p.length,c)},set:function(c,p,m,_){return c.setUTCFullYear(m,0,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["G","y","Y","R","w","I","i","e","c","t","T"]},Q:{priority:120,parse:function(c,p,m,_){switch(p){case"Q":case"QQ":return we(p.length,c);case"Qo":return m.ordinalNumber(c,{unit:"quarter"});case"QQQ":return m.quarter(c,{width:"abbreviated",context:"formatting"})||m.quarter(c,{width:"narrow",context:"formatting"});case"QQQQQ":return m.quarter(c,{width:"narrow",context:"formatting"});default:return m.quarter(c,{width:"wide",context:"formatting"})||m.quarter(c,{width:"abbreviated",context:"formatting"})||m.quarter(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=1&&p<=4},set:function(c,p,m,_){return c.setUTCMonth(3*(m-1),1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:{priority:120,parse:function(c,p,m,_){switch(p){case"q":case"qq":return we(p.length,c);case"qo":return m.ordinalNumber(c,{unit:"quarter"});case"qqq":return m.quarter(c,{width:"abbreviated",context:"standalone"})||m.quarter(c,{width:"narrow",context:"standalone"});case"qqqqq":return m.quarter(c,{width:"narrow",context:"standalone"});default:return m.quarter(c,{width:"wide",context:"standalone"})||m.quarter(c,{width:"abbreviated",context:"standalone"})||m.quarter(c,{width:"narrow",context:"standalone"})}},validate:function(c,p,m){return p>=1&&p<=4},set:function(c,p,m,_){return c.setUTCMonth(3*(m-1),1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:{priority:110,parse:function(c,p,m,_){var L=function(K){return K-1};switch(p){case"M":return ge(_i,c,L);case"MM":return we(2,c,L);case"Mo":return m.ordinalNumber(c,{unit:"month",valueCallback:L});case"MMM":return m.month(c,{width:"abbreviated",context:"formatting"})||m.month(c,{width:"narrow",context:"formatting"});case"MMMMM":return m.month(c,{width:"narrow",context:"formatting"});default:return m.month(c,{width:"wide",context:"formatting"})||m.month(c,{width:"abbreviated",context:"formatting"})||m.month(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=0&&p<=11},set:function(c,p,m,_){return c.setUTCMonth(m,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]},L:{priority:110,parse:function(c,p,m,_){var L=function(K){return K-1};switch(p){case"L":return ge(_i,c,L);case"LL":return we(2,c,L);case"Lo":return m.ordinalNumber(c,{unit:"month",valueCallback:L});case"LLL":return m.month(c,{width:"abbreviated",context:"standalone"})||m.month(c,{width:"narrow",context:"standalone"});case"LLLLL":return m.month(c,{width:"narrow",context:"standalone"});default:return m.month(c,{width:"wide",context:"standalone"})||m.month(c,{width:"abbreviated",context:"standalone"})||m.month(c,{width:"narrow",context:"standalone"})}},validate:function(c,p,m){return p>=0&&p<=11},set:function(c,p,m,_){return c.setUTCMonth(m,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:{priority:100,parse:function(c,p,m,_){switch(p){case"w":return ge(Zi,c);case"wo":return m.ordinalNumber(c,{unit:"week"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=1&&p<=53},set:function(c,p,m,_){return We(function(L,K,gt){f(2,arguments);var wt=C(L),Mt=h(K),qt=Ne(wt,gt)-Mt;return wt.setUTCDate(wt.getUTCDate()-7*qt),wt}(c,m,_),_)},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:{priority:100,parse:function(c,p,m,_){switch(p){case"I":return ge(Zi,c);case"Io":return m.ordinalNumber(c,{unit:"week"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=1&&p<=53},set:function(c,p,m,_){return Et(function(L,K){f(2,arguments);var gt=C(L),wt=h(K),Mt=Re(gt)-wt;return gt.setUTCDate(gt.getUTCDate()-7*Mt),gt}(c,m,_),_)},incompatibleTokens:["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:{priority:90,subPriority:1,parse:function(c,p,m,_){switch(p){case"d":return ge(ui,c);case"do":return m.ordinalNumber(c,{unit:"date"});default:return we(p.length,c)}},validate:function(c,p,m){var _=j(c.getUTCFullYear()),L=c.getUTCMonth();return _?p>=1&&p<=I[L]:p>=1&&p<=z[L]},set:function(c,p,m,_){return c.setUTCDate(m),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:{priority:90,subPriority:1,parse:function(c,p,m,_){switch(p){case"D":case"DD":return ge(gi,c);case"Do":return m.ordinalNumber(c,{unit:"date"});default:return we(p.length,c)}},validate:function(c,p,m){return j(c.getUTCFullYear())?p>=1&&p<=366:p>=1&&p<=365},set:function(c,p,m,_){return c.setUTCMonth(0,m),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:{priority:90,parse:function(c,p,m,_){switch(p){case"E":case"EE":case"EEE":return m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});case"EEEEE":return m.day(c,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});default:return m.day(c,{width:"wide",context:"formatting"})||m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=0&&p<=6},set:function(c,p,m,_){return(c=ni(c,m,_)).setUTCHours(0,0,0,0),c},incompatibleTokens:["D","i","e","c","t","T"]},e:{priority:90,parse:function(c,p,m,_){var L=function(K){var gt=7*Math.floor((K-1)/7);return(K+_.weekStartsOn+6)%7+gt};switch(p){case"e":case"ee":return we(p.length,c,L);case"eo":return m.ordinalNumber(c,{unit:"day",valueCallback:L});case"eee":return m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});case"eeeee":return m.day(c,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});default:return m.day(c,{width:"wide",context:"formatting"})||m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=0&&p<=6},set:function(c,p,m,_){return(c=ni(c,m,_)).setUTCHours(0,0,0,0),c},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:{priority:90,parse:function(c,p,m,_){var L=function(K){var gt=7*Math.floor((K-1)/7);return(K+_.weekStartsOn+6)%7+gt};switch(p){case"c":case"cc":return we(p.length,c,L);case"co":return m.ordinalNumber(c,{unit:"day",valueCallback:L});case"ccc":return m.day(c,{width:"abbreviated",context:"standalone"})||m.day(c,{width:"short",context:"standalone"})||m.day(c,{width:"narrow",context:"standalone"});case"ccccc":return m.day(c,{width:"narrow",context:"standalone"});case"cccccc":return m.day(c,{width:"short",context:"standalone"})||m.day(c,{width:"narrow",context:"standalone"});default:return m.day(c,{width:"wide",context:"standalone"})||m.day(c,{width:"abbreviated",context:"standalone"})||m.day(c,{width:"short",context:"standalone"})||m.day(c,{width:"narrow",context:"standalone"})}},validate:function(c,p,m){return p>=0&&p<=6},set:function(c,p,m,_){return(c=ni(c,m,_)).setUTCHours(0,0,0,0),c},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:{priority:90,parse:function(c,p,m,_){var L=function(K){return K===0?7:K};switch(p){case"i":case"ii":return we(p.length,c);case"io":return m.ordinalNumber(c,{unit:"day"});case"iii":return m.day(c,{width:"abbreviated",context:"formatting",valueCallback:L})||m.day(c,{width:"short",context:"formatting",valueCallback:L})||m.day(c,{width:"narrow",context:"formatting",valueCallback:L});case"iiiii":return m.day(c,{width:"narrow",context:"formatting",valueCallback:L});case"iiiiii":return m.day(c,{width:"short",context:"formatting",valueCallback:L})||m.day(c,{width:"narrow",context:"formatting",valueCallback:L});default:return m.day(c,{width:"wide",context:"formatting",valueCallback:L})||m.day(c,{width:"abbreviated",context:"formatting",valueCallback:L})||m.day(c,{width:"short",context:"formatting",valueCallback:L})||m.day(c,{width:"narrow",context:"formatting",valueCallback:L})}},validate:function(c,p,m){return p>=1&&p<=7},set:function(c,p,m,_){return c=function(L,K){f(2,arguments);var gt=h(K);gt%7==0&&(gt-=7);var wt=1,Mt=C(L),qt=Mt.getUTCDay(),Gt=((gt%7+7)%7=1&&p<=12},set:function(c,p,m,_){var L=c.getUTCHours()>=12;return L&&m<12?c.setUTCHours(m+12,0,0,0):L||m!==12?c.setUTCHours(m,0,0,0):c.setUTCHours(0,0,0,0),c},incompatibleTokens:["H","K","k","t","T"]},H:{priority:70,parse:function(c,p,m,_){switch(p){case"H":return ge($e,c);case"Ho":return m.ordinalNumber(c,{unit:"hour"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=23},set:function(c,p,m,_){return c.setUTCHours(m,0,0,0),c},incompatibleTokens:["a","b","h","K","k","t","T"]},K:{priority:70,parse:function(c,p,m,_){switch(p){case"K":return ge(Ji,c);case"Ko":return m.ordinalNumber(c,{unit:"hour"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=11},set:function(c,p,m,_){return c.getUTCHours()>=12&&m<12?c.setUTCHours(m+12,0,0,0):c.setUTCHours(m,0,0,0),c},incompatibleTokens:["a","b","h","H","k","t","T"]},k:{priority:70,parse:function(c,p,m,_){switch(p){case"k":return ge(Ui,c);case"ko":return m.ordinalNumber(c,{unit:"hour"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=1&&p<=24},set:function(c,p,m,_){var L=m<=24?m%24:m;return c.setUTCHours(L,0,0,0),c},incompatibleTokens:["a","b","h","H","K","t","T"]},m:{priority:60,parse:function(c,p,m,_){switch(p){case"m":return ge(Pi,c);case"mo":return m.ordinalNumber(c,{unit:"minute"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=59},set:function(c,p,m,_){return c.setUTCMinutes(m,0,0),c},incompatibleTokens:["t","T"]},s:{priority:50,parse:function(c,p,m,_){switch(p){case"s":return ge(Ie,c);case"so":return m.ordinalNumber(c,{unit:"second"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=59},set:function(c,p,m,_){return c.setUTCSeconds(m,0),c},incompatibleTokens:["t","T"]},S:{priority:30,parse:function(c,p,m,_){return we(p.length,c,function(L){return Math.floor(L*Math.pow(10,3-p.length))})},set:function(c,p,m,_){return c.setUTCMilliseconds(m),c},incompatibleTokens:["t","T"]},X:{priority:10,parse:function(c,p,m,_){switch(p){case"X":return Ue(yi,c);case"XX":return Ue(Vi,c);case"XXXX":return Ue(Ri,c);case"XXXXX":return Ue(ds,c);default:return Ue(Oi,c)}},set:function(c,p,m,_){return p.timestampIsSet?c:new Date(c.getTime()-m)},incompatibleTokens:["t","T","x"]},x:{priority:10,parse:function(c,p,m,_){switch(p){case"x":return Ue(yi,c);case"xx":return Ue(Vi,c);case"xxxx":return Ue(Ri,c);case"xxxxx":return Ue(ds,c);default:return Ue(Oi,c)}},set:function(c,p,m,_){return p.timestampIsSet?c:new Date(c.getTime()-m)},incompatibleTokens:["t","T","X"]},t:{priority:40,parse:function(c,p,m,_){return Ni(c)},set:function(c,p,m,_){return[new Date(1e3*m),{timestampIsSet:!0}]},incompatibleTokens:"*"},T:{priority:20,parse:function(c,p,m,_){return Ni(c)},set:function(c,p,m,_){return[new Date(m),{timestampIsSet:!0}]},incompatibleTokens:"*"}},G=U,rt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ct=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,st=/^'([^]*?)'?$/,pt=/''/g,lt=/\S/,vt=/[a-zA-Z]/;function Lt(c,p){if(p.timestampIsSet)return c;var m=new Date(0);return m.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),m.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),m}function It(c){return c.match(st)[1].replace(pt,"'")}var _t=36e5,bt={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Dt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Yt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Qt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function oe(c){var p,m={},_=c.split(bt.dateTimeDelimiter);if(_.length>2)return m;if(/:/.test(_[0])?(m.date=null,p=_[0]):(m.date=_[0],p=_[1],bt.timeZoneDelimiter.test(m.date)&&(m.date=c.split(bt.timeZoneDelimiter)[0],p=c.substr(m.date.length,c.length))),p){var L=bt.timezone.exec(p);L?(m.time=p.replace(L[1],""),m.timezone=L[1]):m.time=p}return m}function de(c,p){var m=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+p)+"})|(\\d{2}|[+-]\\d{"+(2+p)+"})$)"),_=c.match(m);if(!_)return{year:null};var L=_[1]&&parseInt(_[1]),K=_[2]&&parseInt(_[2]);return{year:K==null?L:100*K,restDateString:c.slice((_[1]||_[2]).length)}}function le(c,p){if(p===null)return null;var m=c.match(Dt);if(!m)return null;var _=!!m[4],L=Zt(m[1]),K=Zt(m[2])-1,gt=Zt(m[3]),wt=Zt(m[4]),Mt=Zt(m[5])-1;if(_)return function(Gt,Jt,pe){return Jt>=1&&Jt<=53&&pe>=0&&pe<=6}(0,wt,Mt)?function(Gt,Jt,pe){var he=new Date(0);he.setUTCFullYear(Gt,0,4);var oi=he.getUTCDay()||7,Qe=7*(Jt-1)+pe+1-oi;return he.setUTCDate(he.getUTCDate()+Qe),he}(p,wt,Mt):new Date(NaN);var qt=new Date(0);return function(Gt,Jt,pe){return Jt>=0&&Jt<=11&&pe>=1&&pe<=(S[Jt]||(O(Gt)?29:28))}(p,K,gt)&&function(Gt,Jt){return Jt>=1&&Jt<=(O(Gt)?366:365)}(p,L)?(qt.setUTCFullYear(p,K,Math.max(L,gt)),qt):new Date(NaN)}function Zt(c){return c?parseInt(c):1}function Me(c){var p=c.match(Yt);if(!p)return null;var m=me(p[1]),_=me(p[2]),L=me(p[3]);return function(K,gt,wt){return K===24?gt===0&&wt===0:wt>=0&&wt<60&>>=0&><60&&K>=0&&K<25}(m,_,L)?m*_t+6e4*_+1e3*L:NaN}function me(c){return c&&parseFloat(c.replace(",","."))||0}function Pe(c){if(c==="Z")return 0;var p=c.match(Qt);if(!p)return 0;var m=p[1]==="+"?-1:1,_=parseInt(p[2]),L=p[3]&&parseInt(p[3])||0;return function(K,gt){return gt>=0&><=59}(0,L)?m*(_*_t+6e4*L):NaN}var S=[31,null,31,30,31,30,31,31,30,31,30,31];function O(c){return c%400==0||c%4==0&&c%100}let B={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};D._adapters._date.override({_id:"date-fns",formats:function(){return B},parse:function(c,p){if(c==null)return null;let m=typeof c;return m==="number"||c instanceof Date?c=C(c):m==="string"&&(c=typeof p=="string"?function(_,L,K,gt){f(3,arguments);var wt=String(_),Mt=String(L),qt=gt||{},Gt=qt.locale||Y;if(!Gt.match)throw new RangeError("locale must contain match property");var Jt=Gt.options&&Gt.options.firstWeekContainsDate,pe=Jt==null?1:h(Jt),he=qt.firstWeekContainsDate==null?pe:h(qt.firstWeekContainsDate);if(!(he>=1&&he<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var oi=Gt.options&&Gt.options.weekStartsOn,Qe=oi==null?0:h(oi),xi=qt.weekStartsOn==null?Qe:h(qt.weekStartsOn);if(!(xi>=0&&xi<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(Mt==="")return wt===""?C(K):new Date(NaN);var Ke,ri={firstWeekContainsDate:he,weekStartsOn:xi,locale:Gt},ze=[{priority:10,subPriority:-1,set:Lt,index:0}],fi=Mt.match(ct).map(function(ei){var Mi=ei[0];return Mi==="p"||Mi==="P"?(0,zt[Mi])(ei,Gt.formatLong,ri):ei}).join("").match(rt),vi=[];for(Ke=0;Ke0&<.test(wt))return new Date(NaN);var zs=ze.map(function(ei){return ei.priority}).sort(function(ei,Mi){return Mi-ei}).filter(function(ei,Mi,gs){return gs.indexOf(ei)===Mi}).map(function(ei){return ze.filter(function(Mi){return Mi.priority===ei}).sort(function(Mi,gs){return gs.subPriority-Mi.subPriority})}).map(function(ei){return ei[0]}),Fs=C(K);if(isNaN(Fs))return new Date(NaN);var Fi=nt(Fs,Rt(Fs)),Ws={};for(Ke=0;Ke=1&&Gt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var Jt=wt.options&&wt.options.weekStartsOn,pe=Jt==null?0:h(Jt),he=gt.weekStartsOn==null?pe:h(gt.weekStartsOn);if(!(he>=0&&he<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!wt.localize)throw new RangeError("locale must contain localize property");if(!wt.formatLong)throw new RangeError("locale must contain formatLong property");var oi=C(m);if(!te(oi))throw new RangeError("Invalid time value");var Qe=Rt(oi),xi=nt(oi,Qe),Ke={firstWeekContainsDate:Gt,weekStartsOn:he,locale:wt,_originalDate:oi},ri=K.match(rs).map(function(ze){var fi=ze[0];return fi==="p"||fi==="P"?(0,zt[fi])(ze,wt.formatLong,Ke):ze}).join("").match(Te).map(function(ze){if(ze==="''")return"'";var fi=ze[0];if(fi==="'")return Be(ze);var vi=yt[fi];if(vi)return!gt.useAdditionalWeekYearTokens&&fe(ze)&&xe(ze,_,m),!gt.useAdditionalDayOfYearTokens&&Ce(ze)&&xe(ze,_,m),vi(xi,ze,wt.localize,Ke);if(fi.match(Ki))throw new RangeError("Format string contains an unescaped latin alphabet character `"+fi+"`");return ze}).join("");return ri}(c,p,this.options)},add:function(c,p,m){switch(m){case"millisecond":return W(c,p);case"second":return function(_,L){f(2,arguments);var K=h(L);return W(_,1e3*K)}(c,p);case"minute":return function(_,L){f(2,arguments);var K=h(L);return W(_,6e4*K)}(c,p);case"hour":return function(_,L){f(2,arguments);var K=h(L);return W(_,K*at)}(c,p);case"day":return H(c,p);case"week":return function(_,L){f(2,arguments);var K=h(L),gt=7*K;return H(_,gt)}(c,p);case"month":return X(c,p);case"quarter":return function(_,L){f(2,arguments);var K=h(L),gt=3*K;return X(_,gt)}(c,p);case"year":return function(_,L){f(2,arguments);var K=h(L);return X(_,12*K)}(c,p);default:return c}},diff:function(c,p,m){switch(m){case"millisecond":return Oe(c,p);case"second":return function(_,L){f(2,arguments);var K=Oe(_,L)/1e3;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"minute":return function(_,L){f(2,arguments);var K=Oe(_,L)/6e4;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"hour":return function(_,L){f(2,arguments);var K=Oe(_,L)/Ee;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"day":return _e(c,p);case"week":return function(_,L){f(2,arguments);var K=_e(_,L)/7;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"month":return Bt(c,p);case"quarter":return function(_,L){f(2,arguments);var K=Bt(_,L)/3;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"year":return function(_,L){f(2,arguments);var K=C(_),gt=C(L),wt=jt(K,gt),Mt=Math.abs(Ae(K,gt));K.setFullYear("1584"),gt.setFullYear("1584");var qt=jt(K,gt)===-wt,Gt=wt*(Mt-qt);return Gt===0?0:Gt}(c,p);default:return 0}},startOf:function(c,p,m){switch(p){case"second":return function(_){f(1,arguments);var L=C(_);return L.setMilliseconds(0),L}(c);case"minute":return function(_){f(1,arguments);var L=C(_);return L.setSeconds(0,0),L}(c);case"hour":return function(_){f(1,arguments);var L=C(_);return L.setMinutes(0,0,0),L}(c);case"day":return Ot(c);case"week":return q(c);case"isoWeek":return q(c,{weekStartsOn:+m});case"month":return function(_){f(1,arguments);var L=C(_);return L.setDate(1),L.setHours(0,0,0,0),L}(c);case"quarter":return function(_){f(1,arguments);var L=C(_),K=L.getMonth(),gt=K-K%3;return L.setMonth(gt,1),L.setHours(0,0,0,0),L}(c);case"year":return function(_){f(1,arguments);var L=C(_),K=new Date(0);return K.setFullYear(L.getFullYear(),0,1),K.setHours(0,0,0,0),K}(c);default:return c}},endOf:function(c,p){switch(p){case"second":return function(m){f(1,arguments);var _=C(m);return _.setMilliseconds(999),_}(c);case"minute":return function(m){f(1,arguments);var _=C(m);return _.setSeconds(59,999),_}(c);case"hour":return function(m){f(1,arguments);var _=C(m);return _.setMinutes(59,59,999),_}(c);case"day":return Ge(c);case"week":return function(m,_){f(1,arguments);var L=_||{},K=L.locale,gt=K&&K.options&&K.options.weekStartsOn,wt=gt==null?0:h(gt),Mt=L.weekStartsOn==null?wt:h(L.weekStartsOn);if(!(Mt>=0&&Mt<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var qt=C(m),Gt=qt.getDay(),Jt=6+(GtN&&N.enabled&&N.modifierKey,W=(N,J)=>N&&J[N+"Key"],at=(N,J)=>N&&!J[N+"Key"];function q(N,J,et){return N===void 0||(typeof N=="string"?N.indexOf(J)!==-1:typeof N=="function"&&N({chart:et}).indexOf(J)!==-1)}function Rt(N,J){return typeof N=="function"&&(N=N({chart:J})),typeof N=="string"?{x:N.indexOf("x")!==-1,y:N.indexOf("y")!==-1}:{x:!1,y:!1}}function Ot(N,J,et){let{mode:ot="xy",scaleMode:ut,overScaleMode:dt}=N||{},yt=function({x:zt,y:ce},re){let Ce=re.scales,fe=Object.keys(Ce);for(let xe=0;xe=Te.top&&ce<=Te.bottom&&zt>=Te.left&&zt<=Te.right)return Te}return null}(J,et),Pt=Rt(ot,et),Tt=Rt(ut,et);if(dt){let zt=Rt(dt,et);for(let ce of["x","y"])zt[ce]&&(Tt[ce]=Pt[ce],Pt[ce]=!1)}if(yt&&Tt[yt.axis])return[yt];let Ut=[];return f.each(et.scales,function(zt){Pt[zt.axis]&&Ut.push(zt)}),Ut}let ft=new WeakMap;function xt(N){let J=ft.get(N);return J||(J={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{}},ft.set(N,J)),J}function jt(N,J,et){let ot=N.max-N.min,ut=ot*(J-1),dt=N.isHorizontal()?et.x:et.y,yt=Math.max(0,Math.min(1,(N.getValueForPixel(dt)-N.min)/ot||0));return{min:ut*yt,max:ut*(1-yt)}}function te(N,J,et,ot,ut){let dt=et[ot];if(dt==="original"){let yt=N.originalScaleLimits[J.id][ot];dt=f.valueOrDefault(yt.options,yt.scale)}return f.valueOrDefault(dt,ut)}function ae(N,{min:J,max:et},ot,ut=!1){let dt=xt(N.chart),{id:yt,axis:Pt,options:Tt}=N,Ut=ot&&(ot[yt]||ot[Pt])||{},{minRange:zt=0}=Ut,ce=te(dt,N,Ut,"min",-1/0),re=te(dt,N,Ut,"max",1/0),Ce=ut?Math.max(et-J,zt):N.max-N.min,fe=(Ce-et+J)/2;return et+=fe,(J-=fe)re&&(et=re,J=Math.max(re-Ce,ce)),Tt.min=J,Tt.max=et,dt.updatedScaleLimits[N.id]={min:J,max:et},N.parse(J)!==N.min||N.parse(et)!==N.max}let Ae=N=>N===0||isNaN(N)?0:N<0?Math.min(Math.round(N),-1):Math.max(Math.round(N),1),ue={second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function _e(N,J,et,ot=!1){let{min:ut,max:dt,options:yt}=N,Pt=yt.time&&yt.time.round,Tt=ue[Pt]||0,Ut=N.getValueForPixel(N.getPixelForValue(ut+Tt)-J),zt=N.getValueForPixel(N.getPixelForValue(dt+Tt)-J),{min:ce=-1/0,max:re=1/0}=ot&&et&&et[N.axis]||{};return!!(isNaN(Ut)||isNaN(zt)||Utre)||ae(N,{min:Ut,max:zt},et,ot)}function Oe(N,J,et){return _e(N,J,et,!0)}let Ee={category:function(N,J,et,ot){let ut=jt(N,J,et);return N.min===N.max&&J<1&&function(dt){let yt=dt.getLabels().length-1;dt.min>0&&(dt.min-=1),dt.maxPt&&(ut=Math.max(0,ut-Tt),dt=yt===1?ut:ut+yt,Ut=ut===0),ae(N,{min:ut,max:dt},et)||Ut},default:_e,logarithmic:Oe,timeseries:Oe};function se(N,J){f.each(N,(et,ot)=>{J[ot]||delete N[ot]})}function Bt(N,J){let{scales:et}=N,{originalScaleLimits:ot,updatedScaleLimits:ut}=J;return f.each(et,function(dt){(function(yt,Pt,Tt){let{id:Ut,options:{min:zt,max:ce}}=yt;if(!Pt[Ut]||!Tt[Ut])return!0;let re=Tt[Ut];return re.min!==zt||re.max!==ce})(dt,ot,ut)&&(ot[dt.id]={min:{scale:dt.min,options:dt.options.min},max:{scale:dt.max,options:dt.options.max}})}),se(ot,et),se(ut,et),ot}function St(N,J,et,ot){let ut=Ee[N.type]||Ee.default;f.callback(ut,[N,J,et,ot])}function r(N,J,et,ot,ut){let dt=Ge[N.type]||Ge.default;f.callback(dt,[N,J,et,ot,ut])}function d(N){let J=N.chartArea;return{x:(J.left+J.right)/2,y:(J.top+J.bottom)/2}}function y(N,J,et="none"){let{x:ot=1,y:ut=1,focalPoint:dt=d(N)}=typeof J=="number"?{x:J,y:J}:J,yt=xt(N),{options:{limits:Pt,zoom:Tt}}=yt;Bt(N,yt);let Ut=ot!==1,zt=ut!==1,ce=Ot(Tt,dt,N);f.each(ce||N.scales,function(re){re.isHorizontal()&&Ut?St(re,ot,dt,Pt):!re.isHorizontal()&&zt&&St(re,ut,dt,Pt)}),N.update(et),f.callback(Tt.onZoom,[{chart:N}])}function v(N,J,et,ot="none"){let ut=xt(N),{options:{limits:dt,zoom:yt}}=ut,{mode:Pt="xy"}=yt;Bt(N,ut);let Tt=q(Pt,"x",N),Ut=q(Pt,"y",N);f.each(N.scales,function(zt){zt.isHorizontal()&&Tt?r(zt,J.x,et.x,dt):!zt.isHorizontal()&&Ut&&r(zt,J.y,et.y,dt)}),N.update(ot),f.callback(yt.onZoom,[{chart:N}])}function P(N){let J=xt(N),et=1,ot=1;return f.each(N.scales,function(ut){let dt=function(yt,Pt){let Tt=yt.originalScaleLimits[Pt];if(!Tt)return;let{min:Ut,max:zt}=Tt;return f.valueOrDefault(zt.options,zt.scale)-f.valueOrDefault(Ut.options,Ut.scale)}(J,ut.id);if(dt){let yt=Math.round(dt/(ut.max-ut.min)*100)/100;et=Math.min(et,yt),ot=Math.max(ot,yt)}}),et<1?et:ot}function F(N,J,et,ot){let{panDelta:ut}=ot,dt=ut[N.id]||0;f.sign(dt)===f.sign(J)&&(J+=dt);let yt=De[N.type]||De.default;f.callback(yt,[N,J,et])?ut[N.id]=0:ut[N.id]=J}function Y(N,J,et,ot="none"){let{x:ut=0,y:dt=0}=typeof J=="number"?{x:J,y:J}:J,yt=xt(N),{options:{pan:Pt,limits:Tt}}=yt,{onPan:Ut}=Pt||{};Bt(N,yt);let zt=ut!==0,ce=dt!==0;f.each(et||N.scales,function(re){re.isHorizontal()&&zt?F(re,ut,Tt,yt):!re.isHorizontal()&&ce&&F(re,dt,Tt,yt)}),N.update(ot),f.callback(Ut,[{chart:N}])}function nt(N){let J=xt(N);Bt(N,J);let et={};for(let ot of Object.keys(N.scales)){let{min:ut,max:dt}=J.originalScaleLimits[ot]||{min:{},max:{}};et[ot]={min:ut.scale,max:dt.scale}}return et}function V(N,J){let{handlers:et}=xt(N),ot=et[J];ot&&ot.target&&(ot.target.removeEventListener(J,ot),delete et[J])}function it(N,J,et,ot){let{handlers:ut,options:dt}=xt(N),yt=ut[et];yt&&yt.target===J||(V(N,et),ut[et]=Pt=>ot(N,Pt,dt),ut[et].target=J,J.addEventListener(et,ut[et]))}function kt(N,J){let et=xt(N);et.dragStart&&(et.dragging=!0,et.dragEnd=J,N.update("none"))}function Et(N,J){let et=xt(N);et.dragStart&&J.key==="Escape"&&(V(N,"keydown"),et.dragging=!1,et.dragStart=et.dragEnd=null,N.update("none"))}function ie(N,J,et){let{onZoomStart:ot,onZoomRejected:ut}=et;if(ot){let dt=f.getRelativePosition(J,N);if(f.callback(ot,[{chart:N,event:J,point:dt}])===!1)return f.callback(ut,[{chart:N,event:J}]),!1}}function Le(N,J){let et=xt(N),{pan:ot,zoom:ut={}}=et.options;if(J.button!==0||W(X(ot),J)||at(X(ut.drag),J))return f.callback(ut.onZoomRejected,[{chart:N,event:J}]);ie(N,J,ut)!==!1&&(et.dragStart=J,it(N,N.canvas,"mousemove",kt),it(N,window.document,"keydown",Et))}function ii(N,J,et,ot){let ut=q(J,"x",N),dt=q(J,"y",N),{top:yt,left:Pt,right:Tt,bottom:Ut,width:zt,height:ce}=N.chartArea,re=f.getRelativePosition(et,N),Ce=f.getRelativePosition(ot,N);ut&&(Pt=Math.min(re.x,Ce.x),Tt=Math.max(re.x,Ce.x)),dt&&(yt=Math.min(re.y,Ce.y),Ut=Math.max(re.y,Ce.y));let fe=Tt-Pt,xe=Ut-yt;return{left:Pt,top:yt,right:Tt,bottom:Ut,width:fe,height:xe,zoomX:ut&&fe?1+(zt-fe)/zt:1,zoomY:dt&&xe?1+(ce-xe)/ce:1}}function Re(N,J){let et=xt(N);if(!et.dragStart)return;V(N,"mousemove");let{mode:ot,onZoomComplete:ut,drag:{threshold:dt=0}}=et.options.zoom,yt=ii(N,ot,et.dragStart,J),Pt=q(ot,"x",N)?yt.width:0,Tt=q(ot,"y",N)?yt.height:0,Ut=Math.sqrt(Pt*Pt+Tt*Tt);if(et.dragStart=et.dragEnd=null,Ut<=dt)return et.dragging=!1,void N.update("none");v(N,{x:yt.left,y:yt.top},{x:yt.right,y:yt.bottom},"zoom"),setTimeout(()=>et.dragging=!1,500),f.callback(ut,[{chart:N}])}function We(N,J){let{handlers:{onZoomComplete:et},options:{zoom:ot}}=xt(N);if(!function(yt,Pt,Tt){if(at(X(Tt.wheel),Pt))f.callback(Tt.onZoomRejected,[{chart:yt,event:Pt}]);else if(ie(yt,Pt,Tt)!==!1&&(Pt.cancelable&&Pt.preventDefault(),Pt.deltaY!==void 0))return!0}(N,J,ot))return;let ut=J.target.getBoundingClientRect(),dt=1+(J.deltaY>=0?-ot.wheel.speed:ot.wheel.speed);y(N,{x:dt,y:dt,focalPoint:{x:J.clientX-ut.left,y:J.clientY-ut.top}}),et&&et()}function Je(N,J,et,ot){et&&(xt(N).handlers[J]=function(ut,dt){let yt;return function(){return clearTimeout(yt),yt=setTimeout(ut,dt),dt}}(()=>f.callback(et,[{chart:N}]),ot))}function He(N,J){return function(et,ot){let{pan:ut,zoom:dt={}}=J.options;if(!ut||!ut.enabled)return!1;let yt=ot&&ot.srcEvent;return!yt||!(!J.panning&&ot.pointerType==="mouse"&&(at(X(ut),yt)||W(X(dt.drag),yt)))||(f.callback(ut.onPanRejected,[{chart:N,event:ot}]),!1)}}function ti(N,J,et){if(J.scale){let{center:ot,pointers:ut}=et,dt=1/J.scale*et.scale,yt=et.target.getBoundingClientRect(),Pt=function(Ut,zt){let ce=Math.abs(Ut.clientX-zt.clientX),re=Math.abs(Ut.clientY-zt.clientY),Ce=ce/re,fe,xe;return Ce>.3&&Ce<1.7?fe=xe=!0:ce>re?fe=!0:xe=!0,{x:fe,y:xe}}(ut[0],ut[1]),Tt=J.options.zoom.mode;y(N,{x:Pt.x&&q(Tt,"x",N)?dt:1,y:Pt.y&&q(Tt,"y",N)?dt:1,focalPoint:{x:ot.x-yt.left,y:ot.y-yt.top}}),J.scale=et.scale}}function Ne(N,J,et){let ot=J.delta;ot&&(J.panning=!0,Y(N,{x:et.deltaX-ot.x,y:et.deltaY-ot.y},J.panScales),J.delta={x:et.deltaX,y:et.deltaY})}let si=new WeakMap;function wi(N,J){let et=xt(N),ot=N.canvas,{pan:ut,zoom:dt}=J,yt=new H.default.Manager(ot);dt&&dt.pinch.enabled&&(yt.add(new H.default.Pinch),yt.on("pinchstart",()=>function(Pt,Tt){Tt.options.zoom.pinch.enabled&&(Tt.scale=1)}(0,et)),yt.on("pinch",Pt=>ti(N,et,Pt)),yt.on("pinchend",Pt=>function(Tt,Ut,zt){Ut.scale&&(ti(Tt,Ut,zt),Ut.scale=null,f.callback(Ut.options.zoom.onZoomComplete,[{chart:Tt}]))}(N,et,Pt))),ut&&ut.enabled&&(yt.add(new H.default.Pan({threshold:ut.threshold,enable:He(N,et)})),yt.on("panstart",Pt=>function(Tt,Ut,zt){let{enabled:ce,onPanStart:re,onPanRejected:Ce}=Ut.options.pan;if(!ce)return;let fe=zt.target.getBoundingClientRect(),xe={x:zt.center.x-fe.left,y:zt.center.y-fe.top};if(f.callback(re,[{chart:Tt,event:zt,point:xe}])===!1)return f.callback(Ce,[{chart:Tt,event:zt}]);Ut.panScales=Ot(Ut.options.pan,xe,Tt),Ut.delta={x:0,y:0},clearTimeout(Ut.panEndTimeout),Ne(Tt,Ut,zt)}(N,et,Pt)),yt.on("panmove",Pt=>Ne(N,et,Pt)),yt.on("panend",()=>function(Pt,Tt){Tt.delta=null,Tt.panning&&(Tt.panEndTimeout=setTimeout(()=>Tt.panning=!1,500),f.callback(Tt.options.pan.onPanComplete,[{chart:Pt}]))}(N,et))),si.set(N,yt)}function Di(N,J,et){let ot=et.zoom.drag,{dragStart:ut,dragEnd:dt}=xt(N);if(ot.drawTime!==J||!dt)return;let{left:yt,top:Pt,width:Tt,height:Ut}=ii(N,et.zoom.mode,ut,dt),zt=N.ctx;zt.save(),zt.beginPath(),zt.fillStyle=ot.backgroundColor||"rgba(225,225,225,0.3)",zt.fillRect(yt,Pt,Tt,Ut),ot.borderWidth>0&&(zt.lineWidth=ot.borderWidth,zt.strokeStyle=ot.borderColor||"rgba(225,225,225)",zt.strokeRect(yt,Pt,Tt,Ut)),zt.restore()}var ve={id:"zoom",version:"2.0.1",defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(N,J,et){xt(N).options=et,Object.prototype.hasOwnProperty.call(et.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(et.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(et.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),H.default&&wi(N,et),N.pan=(ot,ut,dt)=>Y(N,ot,ut,dt),N.zoom=(ot,ut)=>y(N,ot,ut),N.zoomRect=(ot,ut,dt)=>v(N,ot,ut,dt),N.zoomScale=(ot,ut,dt)=>function(yt,Pt,Tt,Ut="none"){Bt(yt,xt(yt)),ae(yt.scales[Pt],Tt,void 0,!0),yt.update(Ut)}(N,ot,ut,dt),N.resetZoom=ot=>function(ut,dt="default"){let yt=xt(ut),Pt=Bt(ut,yt);f.each(ut.scales,function(Tt){let Ut=Tt.options;Pt[Tt.id]?(Ut.min=Pt[Tt.id].min.options,Ut.max=Pt[Tt.id].max.options):(delete Ut.min,delete Ut.max)}),ut.update(dt),f.callback(yt.options.zoom.onZoomComplete,[{chart:ut}])}(N,ot),N.getZoomLevel=()=>P(N),N.getInitialScaleBounds=()=>nt(N),N.isZoomedOrPanned=()=>function(ot){let ut=nt(ot);for(let dt of Object.keys(ot.scales)){let{min:yt,max:Pt}=ut[dt];if(yt!==void 0&&ot.scales[dt].min!==yt||Pt!==void 0&&ot.scales[dt].max!==Pt)return!0}return!1}(N)},beforeEvent(N){let J=xt(N);if(J.panning||J.dragging)return!1},beforeUpdate:function(N,J,et){xt(N).options=et,function(ot,ut){let dt=ot.canvas,{wheel:yt,drag:Pt,onZoomComplete:Tt}=ut.zoom;yt.enabled?(it(ot,dt,"wheel",We),Je(ot,"onZoomComplete",Tt,250)):V(ot,"wheel"),Pt.enabled?(it(ot,dt,"mousedown",Le),it(ot,dt.ownerDocument,"mouseup",Re)):(V(ot,"mousedown"),V(ot,"mousemove"),V(ot,"mouseup"),V(ot,"keydown"))}(N,et)},beforeDatasetsDraw(N,J,et){Di(N,"beforeDatasetsDraw",et)},afterDatasetsDraw(N,J,et){Di(N,"afterDatasetsDraw",et)},beforeDraw(N,J,et){Di(N,"beforeDraw",et)},afterDraw(N,J,et){Di(N,"afterDraw",et)},stop:function(N){(function(J){V(J,"mousedown"),V(J,"mousemove"),V(J,"mouseup"),V(J,"wheel"),V(J,"click"),V(J,"keydown")})(N),H.default&&function(J){let et=si.get(J);et&&(et.remove("pinchstart"),et.remove("pinch"),et.remove("pinchend"),et.remove("panstart"),et.remove("pan"),et.remove("panend"),et.destroy(),si.delete(J))}(N),function(J){ft.delete(J)}(N)},panFunctions:De,zoomFunctions:Ee,zoomRectFunctions:Ge};return D.Chart.register(ve),ve});(function(D,h){typeof exports=="object"&&typeof module<"u"?module.exports=h(ys("chart.js"),ys("chart.js/helpers")):typeof define=="function"&&define.amd?define(["chart.js","chart.js/helpers"],h):(D=typeof globalThis<"u"?globalThis:D||self)["chartjs-plugin-annotation"]=h(D.Chart,D.Chart.helpers)})(void 0,function(D,h){"use strict";let f={modes:{point:(E,M)=>H(E,M,{intersect:!0}),nearest:(E,M,z)=>function(I,j,U){let G=Number.POSITIVE_INFINITY;return H(I,j,U).reduce((rt,ct)=>{let st=ct.getCenterPoint(),pt=function(vt,Lt,It){return It==="x"?{x:vt.x,y:Lt.y}:It==="y"?{x:Lt.x,y:vt.y}:Lt}(j,st,U.axis),lt=h.distanceBetweenPoints(j,pt);return ltrt._index-ct._index).slice(0,1)}(E,M,z),x:(E,M,z)=>H(E,M,{intersect:z.intersect,axis:"x"}),y:(E,M,z)=>H(E,M,{intersect:z.intersect,axis:"y"})}};function C(E,M,z){return(f.modes[z.mode]||f.modes.nearest)(E,M,z)}function H(E,M,z){return E.visibleElements.filter(I=>z.intersect?I.inRange(M.x,M.y):function(j,U,G){return G!=="x"&&G!=="y"?j.inRange(U.x,U.y,"x",!0)||j.inRange(U.x,U.y,"y",!0):j.inRange(U.x,U.y,G,!0)}(I,M,z.axis))}let X=(E,M)=>M>E||E.length>M.length&&E.slice(0,M.length)===M,W=.001,at=(E,M,z)=>Math.min(z,Math.max(M,E));function q(E,M,z){for(let I of Object.keys(E))E[I]=at(E[I],M,z);return E}function Rt(E,{x:M,y:z,x2:I,y2:j},U,G){let rt=G/2,ct=E.x>=M-rt-W&&E.x<=I+rt+W,st=E.y>=z-rt-W&&E.y<=j+rt+W;return U==="x"?ct:(U==="y"||ct)&&st}function Ot(E,M){let{centerX:z,centerY:I}=E.getProps(["centerX","centerY"],M);return{x:z,y:I}}let ft=E=>typeof E=="string"&&E.endsWith("%"),xt=E=>parseFloat(E)/100,jt=E=>at(xt(E),0,1),te=(E,M)=>({x:E,y:M,x2:E,y2:M,width:0,height:0}),ae={box:E=>te(E.centerX,E.centerY),ellipse:E=>({centerX:E.centerX,centerY:E.centerX,radius:0,width:0,height:0}),label:E=>te(E.centerX,E.centerY),line:E=>te(E.x,E.y),point:E=>({centerX:E.centerX,centerY:E.centerY,radius:0,width:0,height:0}),polygon:E=>te(E.centerX,E.centerY)};function Ae(E,M){return M==="start"?0:M==="end"?E:ft(M)?jt(M)*E:E/2}function ue(E,M,z=!0){return typeof M=="number"?M:ft(M)?(z?jt(M):xt(M))*E:E}function _e(E,M="center"){return h.isObject(E)?{x:h.valueOrDefault(E.x,M),y:h.valueOrDefault(E.y,M)}:{x:E=h.valueOrDefault(E,M),y:E}}function Oe(E){return E&&(h.defined(E.xValue)||h.defined(E.yValue))}function Ee(E,M,z){let I=z.init;if(I)return I===!0?De(M,z):function(j,U,G){let rt=h.callback(G.init,[{chart:j,properties:U,options:G}]);if(rt===!0)return De(U,G);if(h.isObject(rt))return rt}(E,M,z)}function Ge(E,M,z){let I=!1;return M.forEach(j=>{h.isFunction(E[j])?(I=!0,z[j]=E[j]):h.defined(z[j])&&delete z[j]}),I}function De(E,M){let z=M.type||"line";return ae[z](E)}let se=new Map,Bt=E=>isNaN(E)||E<=0,St=E=>E.reduce(function(M,z){return M+=z.string},"");function r(E){if(E&&typeof E=="object"){let M=E.toString();return M==="[object HTMLImageElement]"||M==="[object HTMLCanvasElement]"}}function d(E,{x:M,y:z},I){I&&(E.translate(M,z),E.rotate(h.toRadians(I)),E.translate(-M,-z))}function y(E,M){if(M&&M.borderWidth)return E.lineCap=M.borderCapStyle,E.setLineDash(M.borderDash),E.lineDashOffset=M.borderDashOffset,E.lineJoin=M.borderJoinStyle,E.lineWidth=M.borderWidth,E.strokeStyle=M.borderColor,!0}function v(E,M){E.shadowColor=M.backgroundShadowColor,E.shadowBlur=M.shadowBlur,E.shadowOffsetX=M.shadowOffsetX,E.shadowOffsetY=M.shadowOffsetY}function P(E,M){let z=M.content;if(r(z))return{width:ue(z.width,M.width),height:ue(z.height,M.height)};let I=M.font,j=h.isArray(I)?I.map(ct=>h.toFont(ct)):[h.toFont(I)],U=M.textStrokeWidth,G=h.isArray(z)?z:[z],rt=G.join()+St(j)+U+(E._measureText?"-spriting":"");return se.has(rt)||se.set(rt,function(ct,st,pt,lt){ct.save();let vt=st.length,Lt=0,It=lt;for(let _t=0;_th.toFont(lt)):[h.toFont(U)],rt=z.color,ct=h.isArray(rt)?rt:[rt],st=function(lt,vt){let{x:Lt,width:It}=lt,_t=vt.textAlign;return _t==="center"?Lt+It/2:_t==="end"||_t==="right"?Lt+It:Lt}(M,z),pt=M.y+z.textStrokeWidth/2;E.save(),E.textBaseline="middle",E.textAlign=z.textAlign,function(lt,vt){if(vt.textStrokeWidth>0)return lt.lineJoin="round",lt.miterLimit=2,lt.lineWidth=vt.textStrokeWidth,lt.strokeStyle=vt.textStrokeColor,!0}(E,z)&&function(lt,{x:vt,y:Lt},It,_t){lt.beginPath();let bt=0;It.forEach(function(Dt,Yt){let Qt=_t[Math.min(Yt,_t.length-1)],oe=Qt.lineHeight;lt.font=Qt.string,lt.strokeText(Dt,vt,Lt+oe/2+bt),bt+=oe}),lt.stroke()}(E,{x:st,y:pt},j,G),function(lt,{x:vt,y:Lt},It,{fonts:_t,colors:bt}){let Dt=0;It.forEach(function(Yt,Qt){let oe=bt[Math.min(Qt,bt.length-1)],de=_t[Math.min(Qt,_t.length-1)],le=de.lineHeight;lt.beginPath(),lt.font=de.string,lt.fillStyle=oe,lt.fillText(Yt,vt,Lt+le/2+Dt),Dt+=le,lt.fill()})}(E,{x:st,y:pt},j,{fonts:G,colors:ct}),E.restore()}function nt(E,M,z,I){let{radius:j,options:U}=M,G=U.pointStyle,rt=U.rotation,ct=(rt||0)*h.RAD_PER_DEG;if(r(G))return E.save(),E.translate(z,I),E.rotate(ct),E.drawImage(G,-G.width/2,-G.height/2,G.width,G.height),void E.restore();Bt(j)||function(st,{x:pt,y:lt,radius:vt,rotation:Lt,style:It,rad:_t}){let bt,Dt,Yt,Qt;switch(st.beginPath(),It){default:st.arc(pt,lt,vt,0,h.TAU),st.closePath();break;case"triangle":st.moveTo(pt+Math.sin(_t)*vt,lt-Math.cos(_t)*vt),_t+=h.TWO_THIRDS_PI,st.lineTo(pt+Math.sin(_t)*vt,lt-Math.cos(_t)*vt),_t+=h.TWO_THIRDS_PI,st.lineTo(pt+Math.sin(_t)*vt,lt-Math.cos(_t)*vt),st.closePath();break;case"rectRounded":Qt=.516*vt,Yt=vt-Qt,bt=Math.cos(_t+h.QUARTER_PI)*Yt,Dt=Math.sin(_t+h.QUARTER_PI)*Yt,st.arc(pt-bt,lt-Dt,Qt,_t-h.PI,_t-h.HALF_PI),st.arc(pt+Dt,lt-bt,Qt,_t-h.HALF_PI,_t),st.arc(pt+bt,lt+Dt,Qt,_t,_t+h.HALF_PI),st.arc(pt-Dt,lt+bt,Qt,_t+h.HALF_PI,_t+h.PI),st.closePath();break;case"rect":if(!Lt){Yt=Math.SQRT1_2*vt,st.rect(pt-Yt,lt-Yt,2*Yt,2*Yt);break}_t+=h.QUARTER_PI;case"rectRot":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+Dt,lt-bt),st.lineTo(pt+bt,lt+Dt),st.lineTo(pt-Dt,lt+bt),st.closePath();break;case"crossRot":_t+=h.QUARTER_PI;case"cross":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt),st.moveTo(pt+Dt,lt-bt),st.lineTo(pt-Dt,lt+bt);break;case"star":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt),st.moveTo(pt+Dt,lt-bt),st.lineTo(pt-Dt,lt+bt),_t+=h.QUARTER_PI,bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt),st.moveTo(pt+Dt,lt-bt),st.lineTo(pt-Dt,lt+bt);break;case"line":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt);break;case"dash":st.moveTo(pt,lt),st.lineTo(pt+Math.cos(_t)*vt,lt+Math.sin(_t)*vt)}st.fill()}(E,{x:z,y:I,radius:j,rotation:rt,style:G,rad:ct})}let V={xScaleID:{min:"xMin",max:"xMax",start:"left",end:"right",startProp:"x",endProp:"x2"},yScaleID:{min:"yMin",max:"yMax",start:"bottom",end:"top",startProp:"y",endProp:"y2"}};function it(E,M,z){return M=typeof M=="number"?M:E.parse(M),h.isFinite(M)?E.getPixelForValue(M):z}function kt(E,M,z){let I=M[z];if(I||z==="scaleID")return I;let j=z.charAt(0),U=Object.values(E).filter(G=>G.axis&&G.axis===j);return U.length?U[0].id:j}function Et(E,M){if(E){let z=E.options.reverse;return{start:it(E,M.min,z?M.end:M.start),end:it(E,M.max,z?M.start:M.end)}}}function ie(E,M){let{chartArea:z,scales:I}=E,j=I[kt(I,M,"xScaleID")],U=I[kt(I,M,"yScaleID")],G=z.width/2,rt=z.height/2;return j&&(G=it(j,M.xValue,j.left+j.width/2)),U&&(rt=it(U,M.yValue,U.top+U.height/2)),{x:G,y:rt}}function Le(E,M){let z=E.scales,I=z[kt(z,M,"xScaleID")],j=z[kt(z,M,"yScaleID")];if(!I&&!j)return{};let{left:U,right:G}=I||E.chartArea,{top:rt,bottom:ct}=j||E.chartArea,st=Je(I,{min:M.xMin,max:M.xMax,start:U,end:G});U=st.start,G=st.end;let pt=Je(j,{min:M.yMin,max:M.yMax,start:ct,end:rt});return rt=pt.start,ct=pt.end,{x:U,y:rt,x2:G,y2:ct,width:G-U,height:ct-rt,centerX:U+(G-U)/2,centerY:rt+(ct-rt)/2}}function ii(E,M){if(!Oe(M)){let z=Le(E,M),I=M.radius;I&&!isNaN(I)||(I=Math.min(z.width,z.height)/2,M.radius=I);let j=2*I,U=z.centerX+M.xAdjust,G=z.centerY+M.yAdjust;return{x:U-I,y:G-I,x2:U+I,y2:G+I,centerX:U,centerY:G,width:j,height:j,radius:I}}return function(z,I){let j=ie(z,I),U=2*I.radius;return{x:j.x-I.radius+I.xAdjust,y:j.y-I.radius+I.yAdjust,x2:j.x+I.radius+I.xAdjust,y2:j.y+I.radius+I.yAdjust,centerX:j.x+I.xAdjust,centerY:j.y+I.yAdjust,radius:I.radius,width:U,height:U}}(E,M)}function Re(E,M){let{scales:z,chartArea:I}=E,j=z[M.scaleID],U={x:I.left,y:I.top,x2:I.right,y2:I.bottom};return j?function(G,rt,ct){let st=it(G,ct.value,NaN),pt=it(G,ct.endValue,st);G.isHorizontal()?(rt.x=st,rt.x2=pt):(rt.y=st,rt.y2=pt)}(j,U,M):function(G,rt,ct){for(let st of Object.keys(V)){let pt=G[kt(G,ct,st)];if(pt){let{min:lt,max:vt,start:Lt,end:It,startProp:_t,endProp:bt}=V[st],Dt=Et(pt,{min:ct[lt],max:ct[vt],start:pt[Lt],end:pt[It]});rt[_t]=Dt.start,rt[bt]=Dt.end}}}(z,U,M),U}function We(E,M){let z=Le(E,M);return z.initProperties=Ee(E,z,M),z.elements=[{type:"label",optionScope:"label",properties:ti(E,z,M),initProperties:z.initProperties}],z}function Je(E,M){let z=Et(E,M)||M;return{start:Math.min(z.start,z.end),end:Math.max(z.start,z.end)}}function He(E,M){let{start:z,end:I,borderWidth:j}=E,{position:U,padding:{start:G,end:rt},adjust:ct}=M;return z+j/2+ct+Ae(I-j-z-G-rt-M.size,U)}function ti(E,M,z){let I=z.label;I.backgroundColor="transparent",I.callout.display=!1;let j=_e(I.position),U=h.toPadding(I.padding),G=P(E.ctx,I),rt=function({properties:lt,options:vt},Lt,It,_t){let{x:bt,x2:Dt,width:Yt}=lt;return He({start:bt,end:Dt,size:Yt,borderWidth:vt.borderWidth},{position:It.x,padding:{start:_t.left,end:_t.right},adjust:vt.label.xAdjust,size:Lt.width})}({properties:M,options:z},G,j,U),ct=function({properties:lt,options:vt},Lt,It,_t){let{y:bt,y2:Dt,height:Yt}=lt;return He({start:bt,end:Dt,size:Yt,borderWidth:vt.borderWidth},{position:It.y,padding:{start:_t.top,end:_t.bottom},adjust:vt.label.yAdjust,size:Lt.height})}({properties:M,options:z},G,j,U),st=G.width+U.width,pt=G.height+U.height;return{x:rt,y:ct,x2:rt+st,y2:ct+pt,width:st,height:pt,centerX:rt+st/2,centerY:ct+pt/2,rotation:I.rotation}}function Ne(E,M,z){let I=Math.cos(z),j=Math.sin(z),U=M.x,G=M.y;return{x:U+I*(E.x-U)-j*(E.y-G),y:G+j*(E.x-U)+I*(E.y-G)}}let si=["enter","leave"],wi=si.concat("click");function Di(E,M,z){if(E.listened)switch(M.type){case"mousemove":case"mouseout":return function(I,j,U){if(!I.moveListened)return;let G;G=j.type==="mousemove"?C(I,j,U.interaction):[];let rt=I.hovered;I.hovered=G;let ct={state:I,event:j},st=ve(ct,"leave",rt,G);return ve(ct,"enter",G,rt)||st}(E,M,z);case"click":return function(I,j,U){let G=I.listeners,rt=C(I,j,U.interaction),ct;for(let st of rt)ct=N(st.options.click||G.click,st,j)||ct;return ct}(E,M,z)}}function ve({state:E,event:M},z,I,j){let U;for(let G of I)j.indexOf(G)<0&&(U=N(G.options[z]||E.listeners[z],G,M)||U);return U}function N(E,M,z){return h.callback(E,[M.$context,z])===!0}let J=["afterDraw","beforeDraw"];function et(E,M,z){if(E.hooked){let I=M.options[z]||E.hooks[z];return h.callback(I,[M.$context])}}function ot(E,M,z){let I=function(U,G,rt){let ct=G.axis,st=G.id,pt=ct+"ScaleID",lt={min:h.valueOrDefault(G.min,Number.NEGATIVE_INFINITY),max:h.valueOrDefault(G.max,Number.POSITIVE_INFINITY)};for(let vt of rt)vt.scaleID===st?Pt(vt,G,["value","endValue"],lt):kt(U,vt,pt)===st&&Pt(vt,G,[ct+"Min",ct+"Max",ct+"Value"],lt);return lt}(E.scales,M,z),j=ut(M,I,"min","suggestedMin");j=ut(M,I,"max","suggestedMax")||j,j&&h.isFunction(M.handleTickRangeOptions)&&M.handleTickRangeOptions()}function ut(E,M,z,I){if(h.isFinite(M[z])&&!function(j,U,G){return h.defined(j[U])||h.defined(j[G])}(E.options,z,I)){let j=E[z]!==M[z];return E[z]=M[z],j}}function dt(E,M){for(let z of["scaleID","xScaleID","yScaleID"]){let I=kt(M,E,z);I&&!M[I]&&yt(E,z)&&console.warn(`No scale found with id '${I}' for annotation '${E.id}'`)}}function yt(E,M){if(M==="scaleID")return!0;let z=M.charAt(0);for(let I of["Min","Max","Value"])if(h.defined(E[z+I]))return!0;return!1}function Pt(E,M,z,I){for(let j of z){let U=E[j];if(h.defined(U)){let G=M.parse(U);I.min=Math.min(I.min,G),I.max=Math.max(I.max,G)}}}class Tt extends D.Element{inRange(M,z,I,j){let{x:U,y:G}=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-this.options.rotation));return Rt({x:U,y:G},this.getProps(["x","y","x2","y2"],j),I,this.options.borderWidth)}getCenterPoint(M){return Ot(this,M)}draw(M){M.save(),d(M,this.getCenterPoint(),this.options.rotation),F(M,this,this.options),M.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(M,z){return We(M,z)}}Tt.id="boxAnnotation",Tt.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,label:{backgroundColor:"transparent",borderWidth:0,callout:{display:!1},color:"black",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,opacity:void 0,padding:6,position:"center",rotation:void 0,textAlign:"start",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Tt.defaultRoutes={borderColor:"color",backgroundColor:"color"},Tt.descriptors={label:{_fallback:!0}};let Ut=["left","bottom","top","right"];class zt extends D.Element{inRange(M,z,I,j){let{x:U,y:G}=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-this.rotation));return Rt({x:U,y:G},this.getProps(["x","y","x2","y2"],j),I,this.options.borderWidth)}getCenterPoint(M){return Ot(this,M)}draw(M){let z=this.options,I=!h.defined(this._visible)||this._visible;z.display&&z.content&&I&&(M.save(),d(M,this.getCenterPoint(),this.rotation),function(j,U){let{pointX:G,pointY:rt,options:ct}=U,st=ct.callout,pt=st&&st.display&&function(Dt,Yt){let Qt=Yt.position;return Ut.includes(Qt)?Qt:function(oe,de){let{x:le,y:Zt,x2:Me,y2:me,width:Pe,height:S,pointX:O,pointY:B,centerX:c,centerY:p,rotation:m}=oe,_={x:c,y:p},L=de.start,K=ue(Pe,L),gt=ue(S,L),wt=[le,le+K,le+K,Me],Mt=[Zt+gt,me,Zt,me],qt=[];for(let Gt=0;Gt<4;Gt++){let Jt=Ne({x:wt[Gt],y:Mt[Gt]},_,h.toRadians(m));qt.push({position:Ut[Gt],distance:h.distanceBetweenPoints(Jt,{x:O,y:B})})}return qt.sort((Gt,Jt)=>Gt.distance-Jt.distance)[0].position}(Dt,Yt)}(U,st);if(!pt||function(Dt,Yt,Qt){let{pointX:oe,pointY:de}=Dt,le=Yt.margin,Zt=oe,Me=de;return Qt==="left"?Zt+=le:Qt==="right"?Zt-=le:Qt==="top"?Me+=le:Qt==="bottom"&&(Me-=le),Dt.inRange(Zt,Me)}(U,st,pt))return;if(j.save(),j.beginPath(),!y(j,st))return j.restore();let{separatorStart:vt,separatorEnd:Lt}=function(Dt,Yt){let{x:Qt,y:oe,x2:de,y2:le}=Dt,Zt=function(Pe,S){let{width:O,height:B,options:c}=Pe,p=c.callout.margin+c.borderWidth/2;return S==="right"?O+p:S==="bottom"?B+p:-p}(Dt,Yt),Me,me;return Yt==="left"||Yt==="right"?(Me={x:Qt+Zt,y:oe},me={x:Me.x,y:le}):(Me={x:Qt,y:oe+Zt},me={x:de,y:Me.y}),{separatorStart:Me,separatorEnd:me}}(U,pt),{sideStart:It,sideEnd:_t}=function(Dt,Yt,Qt){let{y:oe,width:de,height:le,options:Zt}=Dt,Me=Zt.callout.start,me=function(O,B){let c=B.side;return O==="left"||O==="top"?-c:c}(Yt,Zt.callout),Pe,S;return Yt==="left"||Yt==="right"?(Pe={x:Qt.x,y:oe+ue(le,Me)},S={x:Pe.x+me,y:Pe.y}):(Pe={x:Qt.x+ue(de,Me),y:Qt.y},S={x:Pe.x,y:Pe.y+me}),{sideStart:Pe,sideEnd:S}}(U,pt,vt);(st.margin>0||ct.borderWidth===0)&&(j.moveTo(vt.x,vt.y),j.lineTo(Lt.x,Lt.y)),j.moveTo(It.x,It.y),j.lineTo(_t.x,_t.y);let bt=Ne({x:G,y:rt},U.getCenterPoint(),h.toRadians(-U.rotation));j.lineTo(bt.x,bt.y),j.stroke(),j.restore()}(M,this),F(M,this,z),Y(M,function({x:j,y:U,width:G,height:rt,options:ct}){let st=ct.borderWidth/2,pt=h.toPadding(ct.padding);return{x:j+pt.left+st,y:U+pt.top+st,width:G-pt.left-pt.right-ct.borderWidth,height:rt-pt.top-pt.bottom-ct.borderWidth}}(this),z),M.restore())}resolveElementProperties(M,z){let I;if(Oe(z))I=ie(M,z);else{let{centerX:G,centerY:rt}=Le(M,z);I={x:G,y:rt}}let j=h.toPadding(z.padding),U=function(G,rt,ct,st){let pt=rt.width+st.width+ct.borderWidth,lt=rt.height+st.height+ct.borderWidth,vt=_e(ct.position,"center"),Lt=ce(G.x,pt,ct.xAdjust,vt.x),It=ce(G.y,lt,ct.yAdjust,vt.y);return{x:Lt,y:It,x2:Lt+pt,y2:It+lt,width:pt,height:lt,centerX:Lt+pt/2,centerY:It+lt/2}}(I,P(M.ctx,z),z,j);return{initProperties:Ee(M,U,z),pointX:I.x,pointY:I.y,...U,rotation:z.rotation}}}function ce(E,M,z=0,I){return E-Ae(M,I)+z}zt.id="labelAnnotation",zt.defaults={adjustScaleRange:!0,backgroundColor:"transparent",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:0,callout:{borderCapStyle:"butt",borderColor:void 0,borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:1,display:!1,margin:5,position:"auto",side:5,start:"50%"},color:"black",content:null,display:!0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:void 0},height:void 0,init:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},zt.defaultRoutes={borderColor:"color"};let re=(E,M,z)=>({x:E.x+z*(M.x-E.x),y:E.y+z*(M.y-E.y)}),Ce=(E,M,z)=>re(M,z,Math.abs((E-M.y)/(z.y-M.y))).x,fe=(E,M,z)=>re(M,z,Math.abs((E-M.x)/(z.x-M.x))).y,xe=E=>E*E,Te=(E,M,{x:z,y:I,x2:j,y2:U},G)=>G==="y"?{start:Math.min(I,U),end:Math.max(I,U),value:M}:{start:Math.min(z,j),end:Math.max(z,j),value:E},rs=(E,M,z,I)=>(1-I)*(1-I)*E+2*(1-I)*I*M+I*I*z,ci=(E,M,z,I)=>({x:rs(E.x,M.x,z.x,I),y:rs(E.y,M.y,z.y,I)}),di=(E,M,z,I)=>2*(1-I)*(M-E)+2*I*(z-M),Ki=(E,M,z,I)=>-Math.atan2(di(E.x,M.x,z.x,I),di(E.y,M.y,z.y,I))+.5*h.PI;class Be extends D.Element{inRange(M,z,I,j){let U=this.options.borderWidth/2;if(I!=="x"&&I!=="y"){let G={mouseX:M,mouseY:z},{path:rt,ctx:ct}=this;if(rt){y(ct,this.options);let{chart:st}=this.$context,pt=M*st.currentDevicePixelRatio,lt=z*st.currentDevicePixelRatio,vt=ct.isPointInStroke(rt,pt,lt)||_i(this,G,j);return ct.restore(),vt}return function(st,{mouseX:pt,mouseY:lt},vt=W,Lt){let{x:It,y:_t,x2:bt,y2:Dt}=st.getProps(["x","y","x2","y2"],Lt),Yt=bt-It,Qt=Dt-_t,oe=xe(Yt)+xe(Qt),de=oe===0?-1:((pt-It)*Yt+(lt-_t)*Qt)/oe,le,Zt;return de<0?(le=It,Zt=_t):de>1?(le=bt,Zt=Dt):(le=It+de*Yt,Zt=_t+de*Qt),xe(pt-le)+xe(lt-Zt)<=vt}(this,G,xe(U),j)||_i(this,G,j)}return function(G,{mouseX:rt,mouseY:ct},st,{hBorderWidth:pt,useFinalPosition:lt}){let vt=Te(rt,ct,G.getProps(["x","y","x2","y2"],lt),st);return vt.value>=vt.start-pt&&vt.value<=vt.end+pt||_i(G,{mouseX:rt,mouseY:ct},lt,st)}(this,{mouseX:M,mouseY:z},I,{hBorderWidth:U,useFinalPosition:j})}getCenterPoint(M){return Ot(this,M)}draw(M){let{x:z,y:I,x2:j,y2:U,cp:G,options:rt}=this;if(M.save(),!y(M,rt))return M.restore();v(M,rt);let ct=Math.sqrt(Math.pow(j-z,2)+Math.pow(U-I,2));if(rt.curve&&G)return function(It,_t,bt,Dt){let{x:Yt,y:Qt,x2:oe,y2:de,options:le}=_t,{startOpts:Zt,endOpts:Me,startAdjust:me,endAdjust:Pe}=Zi(_t),S={x:Yt,y:Qt},O={x:oe,y:de},B=Ki(S,bt,O,0),c=Ki(S,bt,O,1)-h.PI,p=ci(S,bt,O,me/Dt),m=ci(S,bt,O,1-Pe/Dt),_=new Path2D;It.beginPath(),_.moveTo(p.x,p.y),_.quadraticCurveTo(bt.x,bt.y,m.x,m.y),It.shadowColor=le.borderShadowColor,It.stroke(_),_t.path=_,_t.ctx=It,Ji(It,p,{angle:B,adjust:me},Zt),Ji(It,m,{angle:c,adjust:Pe},Me)}(M,this,G,ct),M.restore();let{startOpts:st,endOpts:pt,startAdjust:lt,endAdjust:vt}=Zi(this),Lt=Math.atan2(U-I,j-z);M.translate(z,I),M.rotate(Lt),M.beginPath(),M.moveTo(0+lt,0),M.lineTo(ct-vt,0),M.shadowColor=rt.borderShadowColor,M.stroke(),Ui(M,0,lt,st),Ui(M,ct,-vt,pt),M.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(M,z){let I=Re(M,z),{x:j,y:U,x2:G,y2:rt}=I,ct=function({x:lt,y:vt,x2:Lt,y2:It},{top:_t,right:bt,bottom:Dt,left:Yt}){return!(ltbt&&Lt>bt||vt<_t&&It<_t||vt>Dt&&It>Dt)}(I,M.chartArea),st=ct?function(lt,vt,Lt){let{x:It,y:_t}=ni(lt,vt,Lt),{x:bt,y:Dt}=ni(vt,lt,Lt);return{x:It,y:_t,x2:bt,y2:Dt,width:Math.abs(bt-It),height:Math.abs(Dt-_t)}}({x:j,y:U},{x:G,y:rt},M.chartArea):{x:j,y:U,x2:G,y2:rt,width:Math.abs(G-j),height:Math.abs(rt-U)};if(st.centerX=(G+j)/2,st.centerY=(rt+U)/2,st.initProperties=Ee(M,st,z),z.curve){let lt={x:st.x,y:st.y},vt={x:st.x2,y:st.y2};st.cp=function(Lt,It,_t){let{x:bt,y:Dt,x2:Yt,y2:Qt,centerX:oe,centerY:de}=Lt,le=Math.atan2(Qt-Dt,Yt-bt),Zt=_e(It.controlPoint,0);return Ne({x:oe+ue(_t,Zt.x,!1),y:de+ue(_t,Zt.y,!1)},{x:oe,y:de},le)}(st,z,h.distanceBetweenPoints(lt,vt))}let pt=function(lt,vt,Lt){let It=Lt.borderWidth,_t=h.toPadding(Lt.padding),bt=P(lt.ctx,Lt),Dt=bt.width+_t.width+It,Yt=bt.height+_t.height+It;return function(Qt,oe,de,le){let{width:Zt,height:Me,padding:me}=de,{xAdjust:Pe,yAdjust:S}=oe,O={x:Qt.x,y:Qt.y},B={x:Qt.x2,y:Qt.y2},c=oe.rotation==="auto"?function(Mt){let{x:qt,y:Gt,x2:Jt,y2:pe}=Mt,he=Math.atan2(pe-Gt,Jt-qt);return he>h.PI/2?he-h.PI:hej&&(M=fe(j,{x:E,y:M},z),E=j),MU&&(E=Ce(U,{x:E,y:M},z),M=U),{x:E,y:M}}function _i(E,{mouseX:M,mouseY:z},I,j){let U=E.label;return U.options.display&&U.inRange(M,z,j,I)}function ui(E,M,z,I){let{labelSize:j,padding:U}=M,G=E.w*I.dx,rt=E.h*I.dy,ct=G>0&&(j.w/2+U.left-I.x)/G,st=rt>0&&(j.h/2+U.top-I.y)/rt;return at(Math.max(ct,st),0,.25)}function gi(E,M){let{size:z,min:I,max:j,padding:U}=M,G=z/2;return z>j-I?(j+I)/2:(I>=E-U-G&&(E=I+U+G),j<=E+U+G&&(E=j-U-G),E)}function Zi(E){let M=E.options,z=M.arrowHeads&&M.arrowHeads.start,I=M.arrowHeads&&M.arrowHeads.end;return{startOpts:z,endOpts:I,startAdjust:$e(E,z),endAdjust:$e(E,I)}}function $e(E,M){if(!M||!M.display)return 0;let{length:z,width:I}=M,j=E.options.borderWidth/2,U={x:z,y:I+j};return Math.abs(Ce(0,U,{x:0,y:j}))}function Ui(E,M,z,I){if(!I||!I.display)return;let{length:j,width:U,fill:G,backgroundColor:rt,borderColor:ct}=I,st=Math.abs(M-j)+z;E.beginPath(),v(E,I),y(E,I),E.moveTo(st,-U),E.lineTo(M+z,0),E.lineTo(st,U),G===!0?(E.fillStyle=rt||ct,E.closePath(),E.fill(),E.shadowColor="transparent"):E.shadowColor=I.borderShadowColor,E.stroke()}function Ji(E,{x:M,y:z},{angle:I,adjust:j},U){U&&U.display&&(E.save(),E.translate(M,z),E.rotate(I),Ui(E,0,-j,U),E.restore())}Be.defaults={adjustScaleRange:!0,arrowHeads:{display:!1,end:Object.assign({},Ii),fill:!1,length:12,start:Object.assign({},Ii),width:6},borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:2,curve:!1,controlPoint:{y:"-50%"},display:!0,endValue:void 0,init:void 0,label:{backgroundColor:"rgba(0,0,0,0.8)",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderColor:"black",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:6,borderShadowColor:"transparent",borderWidth:0,callout:Object.assign({},zt.defaults.callout),color:"#fff",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},scaleID:void 0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,value:void 0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Be.descriptors={arrowHeads:{start:{_fallback:!0},end:{_fallback:!0},_fallback:!0}},Be.defaultRoutes={borderColor:"color"};class ji extends D.Element{inRange(M,z,I,j){let U=this.options.rotation,G=this.options.borderWidth;if(I!=="x"&&I!=="y")return function(It,_t,bt,Dt){let{width:Yt,height:Qt,centerX:oe,centerY:de}=_t,le=Yt/2,Zt=Qt/2;if(le<=0||Zt<=0)return!1;let Me=h.toRadians(bt||0),me=Dt/2||0,Pe=Math.cos(Me),S=Math.sin(Me),O=Math.pow(Pe*(It.x-oe)+S*(It.y-de),2),B=Math.pow(S*(It.x-oe)-Pe*(It.y-de),2);return O/Math.pow(le+me,2)+B/Math.pow(Zt+me,2)<=1.0001}({x:M,y:z},this.getProps(["width","height","centerX","centerY"],j),U,G);let{x:rt,y:ct,x2:st,y2:pt}=this.getProps(["x","y","x2","y2"],j),lt=G/2,vt=I==="y"?{start:ct,end:pt}:{start:rt,end:st},Lt=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-U));return Lt[I]>=vt.start-lt-W&&Lt[I]<=vt.end+lt+W}getCenterPoint(M){return Ot(this,M)}draw(M){let{width:z,height:I,centerX:j,centerY:U,options:G}=this;M.save(),d(M,this.getCenterPoint(),G.rotation),v(M,this.options),M.beginPath(),M.fillStyle=G.backgroundColor;let rt=y(M,G);M.ellipse(j,U,I/2,z/2,h.PI/2,0,2*h.PI),M.fill(),rt&&(M.shadowColor=G.borderShadowColor,M.stroke()),M.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(M,z){return We(M,z)}}ji.id="ellipseAnnotation",ji.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,label:Object.assign({},Tt.defaults.label),rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},ji.defaultRoutes={borderColor:"color",backgroundColor:"color"},ji.descriptors={label:{_fallback:!0}};class Pi extends D.Element{inRange(M,z,I,j){let{x:U,y:G,x2:rt,y2:ct,width:st}=this.getProps(["x","y","x2","y2","width"],j),pt=this.options.borderWidth;if(I!=="x"&&I!=="y")return function(Lt,It,_t,bt){if(!Lt||!It||_t<=0)return!1;let Dt=bt/2;return Math.pow(Lt.x-It.x,2)+Math.pow(Lt.y-It.y,2)<=Math.pow(_t+Dt,2)}({x:M,y:z},this.getCenterPoint(j),st/2,pt);let lt=pt/2,vt=I==="y"?{start:G,end:ct,value:z}:{start:U,end:rt,value:M};return vt.value>=vt.start-lt&&vt.value<=vt.end+lt}getCenterPoint(M){return Ot(this,M)}draw(M){let z=this.options,I=z.borderWidth;if(z.radius<.1)return;M.save(),M.fillStyle=z.backgroundColor,v(M,z);let j=y(M,z);nt(M,this,this.centerX,this.centerY),j&&!r(z.pointStyle)&&(M.shadowColor=z.borderShadowColor,M.stroke()),M.restore(),z.borderWidth=I}resolveElementProperties(M,z){let I=ii(M,z);return I.initProperties=Ee(M,I,z),I}}Pi.id="pointAnnotation",Pi.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,pointStyle:"circle",radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},Pi.defaultRoutes={borderColor:"color",backgroundColor:"color"};class Ie extends D.Element{inRange(M,z,I,j){if(I!=="x"&&I!=="y")return this.options.radius>=.1&&this.elements.length>1&&function(st,pt,lt,vt){let Lt=!1,It=st[st.length-1].getProps(["bX","bY"],vt);for(let _t of st){let bt=_t.getProps(["bX","bY"],vt);bt.bY>lt!=It.bY>lt&&pt<(It.bX-bt.bX)*(lt-bt.bY)/(It.bY-bt.bY)+bt.bX&&(Lt=!Lt),It=bt}return Lt}(this.elements,M,z,j);let U=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-this.options.rotation)),G=this.elements.map(st=>I==="y"?st.bY:st.bX),rt=Math.min(...G),ct=Math.max(...G);return U[I]>=rt&&U[I]<=ct}getCenterPoint(M){return Ot(this,M)}draw(M){let{elements:z,options:I}=this;M.save(),M.beginPath(),M.fillStyle=I.backgroundColor,v(M,I);let j=y(M,I),U=!0;for(let G of z)U?(M.moveTo(G.x,G.y),U=!1):M.lineTo(G.x,G.y);M.closePath(),M.fill(),j&&(M.shadowColor=I.borderShadowColor,M.stroke()),M.restore()}resolveElementProperties(M,z){let I=ii(M,z),{sides:j,rotation:U}=z,G=[],rt=2*h.PI/j,ct=U*h.RAD_PER_DEG;for(let st=0;st{D.defaults.describe(`elements.${be[E].id}`,{_fallback:"plugins.annotation.common"})});let Ye={update:Object.assign},ts=wi.concat(J),ki=(E,M)=>h.isObject(M)?Oi(E,M):E,mi=E=>E==="color"||E==="font";function bi(E="line"){return be[E]?E:(console.warn(`Unknown annotation type: '${E}', defaulting to 'line'`),"line")}function Hi(E,M,z,I){let j=function(rt,ct,st){return st==="reset"||st==="none"||st==="resize"?Ye:new D.Animations(rt,ct)}(E,z.animations,I),U=M.annotations,G=function(rt,ct){let st=ct.length,pt=rt.length;if(ptst&&rt.splice(st,pt-st);return rt}(M.elements,U);for(let rt=0;rtki(G,j)):z[I]=ki(U,j)}return z}function ds(E,M,z){return M.$context||(M.$context=Object.assign(Object.create(E.getContext()),{element:M,id:z.id,type:"annotation"}))}let ge=new Map,Ue=wi.concat(J);var Ni={id:"annotation",version:"3.0.1",beforeRegister(){(function(E,M,z,I=!0){let j=z.split("."),U=0;for(let G of M.split(".")){let rt=j[U++];if(parseInt(G,10){let G=j[U];h.isObject(G)&&(G.id=U,I.push(G))}):h.isArray(j)&&I.push(...j),function(U,G){for(let rt of U)dt(rt,G)}(I,E.scales)},afterDataLimits(E,M){let z=ge.get(E);ot(E,M.scale,z.annotations.filter(I=>I.display&&I.adjustScaleRange))},afterUpdate(E,M,z){let I=ge.get(E);(function(j,U,G){U.listened=Ge(G,wi,U.listeners),U.moveListened=!1,U._getElements=C,si.forEach(rt=>{h.isFunction(G[rt])&&(U.moveListened=!0)}),U.listened&&U.moveListened||U.annotations.forEach(rt=>{!U.listened&&h.isFunction(rt.click)&&(U.listened=!0),U.moveListened||si.forEach(ct=>{h.isFunction(rt[ct])&&(U.listened=!0,U.moveListened=!0)})})})(0,I,z),Hi(E,I,z,M.mode),I.visibleElements=I.elements.filter(j=>!j.skip&&j.options.display),function(j,U,G){let rt=U.visibleElements;U.hooked=Ge(G,J,U.hooks),U.hooked||rt.forEach(ct=>{U.hooked||J.forEach(st=>{h.isFunction(ct.options[st])&&(U.hooked=!0)})})}(0,I,z)},beforeDatasetsDraw(E,M,z){we(E,"beforeDatasetsDraw",z.clip)},afterDatasetsDraw(E,M,z){we(E,"afterDatasetsDraw",z.clip)},beforeDraw(E,M,z){we(E,"beforeDraw",z.clip)},afterDraw(E,M,z){we(E,"afterDraw",z.clip)},beforeEvent(E,M,z){Di(ge.get(E),M.event,z)&&(M.changed=!0)},afterDestroy(E){ge.delete(E)},_getState:E=>ge.get(E),defaults:{animations:{numbers:{properties:["x","y","x2","y2","width","height","centerX","centerY","pointX","pointY","radius"],type:"number"}},clip:!0,interaction:{mode:void 0,axis:void 0,intersect:void 0},common:{drawTime:"afterDatasetsDraw",init:!1,label:{}}},descriptors:{_indexable:!1,_scriptable:E=>!Ue.includes(E)&&E!=="init",annotations:{_allKeys:!1,_fallback:(E,M)=>`elements.${be[bi(M.type)].id}`},interaction:{_fallback:!0},common:{label:{_indexable:mi,_fallback:!0},_indexable:mi}},additionalOptionScopes:[""]};function we(E,M,z){let{ctx:I,chartArea:j}=E,U=ge.get(E);z&&h.clipArea(I,j);let G=function(rt,ct){let st=[];for(let pt of rt)if(pt.options.drawTime===ct&&st.push({element:pt,main:!0}),pt.elements&&pt.elements.length)for(let lt of pt.elements)lt.options.display&<.options.drawTime===ct&&st.push({element:lt});return st}(U.visibleElements,M).sort((rt,ct)=>rt.element.options.z-ct.element.options.z);for(let rt of G)es(I,j,U,rt);z&&h.unclipArea(I)}function es(E,M,z,I){let j=I.element;I.main?(et(z,j,"beforeDraw"),j.draw(E,M),et(z,j,"afterDraw")):j.draw(E,M)}return D.Chart.register(Ni),Ni});(function(D,h){typeof exports=="object"&&typeof module<"u"?h(exports,ys("chart.js"),ys("chart.js/helpers")):typeof define=="function"&&define.amd?define(["exports","chart.js","chart.js/helpers"],h):h((D=typeof globalThis<"u"?globalThis:D||self).ChartGauge={},D.Chart,D.Chart.helpers)})(void 0,function(D,h,f){"use strict";let C={needle:{radius:"10%",width:"15%",length:"80%"},valueLabel:{display:!0,font:void 0,formatter:Math.round,color:()=>"#FFF",backgroundColor:h.Chart.defaults.backgroundColor,borderColor:h.Chart.defaults.borderColor,borderWidth:0,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},offsetX:0,offsetY:0},animation:{animateRotate:!0,animateScale:!1},cutout:"50%",rotation:-90,circumference:180,value:0,minValue:0};class H extends h.DoughnutController{constructor(W,at){super(W,at),this.center=new h.ArcElement({}),this.values=[],this.valuePercent=0,this.previous=0,this.current=0}_updateMeta(){let W=this._cachedMeta,at=W._parsed;if(this.values=[],this.valuePercent=0,at.length===0)return W;let q=this.options,{value:Rt=0,minValue:Ot=0}=q,ft=at.length>0?at[at.length-1]:Ot+1;at.reduce((jt,te)=>(this.values.push(te-jt),te),Ot);let xt=ft-Ot;return this.valuePercent=Rt/xt,W}_getTranslation(){let W=this._cachedMeta.data[0];return W==null?{dx:0,dy:0}:{dx:W.x,dy:W.y}}_getAngle(W){let at=this.options,{rotation:q,circumference:Rt}=at;return f.toRadians(q+Rt*W)}_getSize(W){return f.toPercentage(W,this.outerRadius)*this.outerRadius}drawNeedle(){let W=this.options,{ctx:at}=this.chart,{needle:q}=W,{radius:Rt,width:Ot,length:ft}=q,{color:xt}=q,jt=this._getSize(Rt),te=this._getSize(Ot),ae=this._getSize(ft),{dx:Ae,dy:ue}=this._getTranslation(),_e=this._getAngle(this.center.endAngle);at.save(),at.translate(Ae,ue),at.rotate(_e),at.fillStyle=xt,at.beginPath(),at.ellipse(0,0,jt,jt,0,0,2*Math.PI),at.fill(),at.beginPath(),at.moveTo(-te/2,0),at.lineTo(0,-ae),at.lineTo(te/2,0),at.fill(),at.restore()}drawValueLabel(){let W=this.options,{valueLabel:at}=W;if(!at.display)return;let{ctx:q}=this.chart,{color:Rt,formatter:Ot,backgroundColor:ft,borderColor:xt,borderWidth:jt,borderRadius:te,padding:ae,offsetX:Ae,offsetY:ue}=at,_e=f.toFont(at.font),{value:Oe}=W,Ee=(Ot?Ot(Oe):Oe).toString();q.save(),q.textBaseline="middle",q.textAlign="center",q.font=_e.string;let{width:Ge}=q.measureText(Ee),{lineHeight:De}=_e,se=1*De,Bt=-(ae.left+Ge/2)-jt,St=-(ae.top+se/2)-jt,r=ae.left+Ge+ae.right+2*jt,d=ae.top+se+ae.bottom+2*jt,{dx:y,dy:v}=this._getTranslation();y+=this._getSize(Ae),v+=this._getSize(ue),q.translate(y,v),q.fillStyle=ft,q.beginPath(),f.addRoundedRectPath(q,{x:Bt,y:St,w:r,h:d,radius:f.toTRBLCorners(te)}),q.closePath(),q.fill(),jt&&(q.strokeStyle=xt,q.lineWidth=jt,q.stroke()),f.renderText(q,Ee,0,.075*se,_e,{textAlign:"center",textBaseline:"middle",color:Rt}),q.restore()}update(W){let at=W==="reset",q=this._updateMeta();at?(this.previous=0,this.current=0):(this.previous=this.current||0,this.current=this.valuePercent);let Rt=q._parsed;q._parsed=this.values,super.update(W),q._parsed=Rt}updateElements(W,at,q,Rt){let Ot=this._cachedMeta,ft=Ot._parsed;if(Ot._parsed=this.values,super.updateElements(W,at,q,Rt),Ot._parsed=ft,W.length===0)return;let xt=W[0];super.updateElement(this.center,void 0,{x:xt.x,y:xt.y,startAngle:this.previous,endAngle:this.current,circumference:0,outerRadius:100,innerRadius:0,options:{}},Rt)}draw(){super.draw(),this.values.length!==0&&(this.drawNeedle(),this.drawValueLabel())}}H.id="gauge",H.version="3.0.0",H.defaults=C,H.descriptors={_scriptable:X=>X!=="formatter"},H.overrides={aspectRatio:!1,layout:{padding:{top:10,bottom:80}},plugins:{legend:{display:!1},tooltip:{enabled:!1}}},h.Chart.register(H),h.Chart.register(h.ArcElement),D.GaugeController=H,Object.defineProperty(D,"__esModule",{value:!0})});var Ze=class{static CACHE={};static accessToken(){return new URLSearchParams(window.location.search).get("access_token")}static async fetchGridLayout(h){try{let f=await fetch(new Request(`./grid-layout.json?name=${encodeURIComponent(h)}&access_token=${this.accessToken()}`),{cache:"no-store"});if(!f.ok)throw new Error(`DatastoreHelper.fetchGridLayout() - HTTP error, status = ${f.status}`);let C=await f.text(),H=JSON.parse(C);if(H.status===!1)throw new Error(`Dashboard "${h}" does not exist.`);return H}catch(f){console.error(f),alert(f.message)}}static async saveGridLayout(h,f){try{let C=await fetch(new Request(`./grid-layout.json?name=${encodeURIComponent(h)}&access_token=${this.accessToken()}`),{method:"PUT",body:JSON.stringify(f),cache:"no-store"});if(!C.ok)throw new Error(`DatastoreHelper.saveGridLayout() - HTTP error, status = ${C.status}`);let H=await C.text(),X=JSON.parse(H);if(X.status===!1)throw new Error(`Dashboard "${h}" does not exist.`);return alert(`Dashboard "${h}" successfully saved!`),X}catch(C){console.error(C),alert(C.message)}}static async fetchMonitoredDevices(){return this.fetchAndCache("monitored-devices.json")}static async fetchSupportedAttributes(){return this.fetchAndCache("supported-attributes.json")}static async fetchAndCache(h){return this.CACHE[h]!==void 0?this.CACHE[h]:(this.CACHE[h]=fetch(new Request(`./${h}?access_token=${this.accessToken()}`),{cache:"no-store"}).then(f=>{if(!f.ok)throw new Error(`DatastoreHelper.fetchAndCache(${h}) - HTTP error, status = ${f.status}`);return f.text()}).then(f=>JSON.parse(f)).catch(f=>{console.error(f),alert(f.message),reject(f)}),this.CACHE[h])}static async fetchDeviceData(h,f,C,H){let X={attr1:[],attr2:[]};try{let W=await fetch(new Request(this.buildCsvUrl(h,H)),{cache:"no-store"});if(W.status==404)return X;if(!W.ok)throw new Error(`DatastoreHelper.fetchDeviceData() - HTTP error, status = ${W.status}`);let at=(await W.text()).split(` -`),q=at.shift().split(","),Rt=f=q.indexOf(f),Ot=C==null?0:q.indexOf(C);return at.forEach(ft=>{let xt=ft.split(",");X.attr1.push({x:parseInt(xt[0]*1e3),y:parseInt(xt[Rt])}),Ot!==0&&X.attr2.push({x:parseInt(xt[0]*1e3),y:parseInt(xt[Ot])})}),X}catch(W){console.error(W),alert(W.message)}}static buildCsvUrl(h,f){return window.location.host!=="cloud.hubitat.com"?`/local/wt_${h}_${f}.csv`:`./watchtower.csv?device=${h}&precision=${f}&access_token=${this.accessToken()}`}static async fetchAttributeData(h,f,C){let H={};for(let X of f){let W=await this.fetchDeviceData(X,h,void 0,C);H[`dev_${X}`]=W.attr1}return H}static async fetchHubInfo(){try{let h=await fetch(new Request(`./hub-info.json?access_token=${this.accessToken()}`),{cache:"no-store"});if(!h.ok)throw new Error(`DatastoreHelper.fetchHubInfo() - HTTP error, status = ${h.status}`);let f=await h.text();return JSON.parse(f)}catch(h){console.error(h),alert(h.message)}}static async fetchHubData(){try{let h=await fetch(new Request("/hub2/hubData"),{cache:"no-store"});if(!h.ok)throw new Error(`DatastoreHelper.fetchHubData() - HTTP error, status = ${h.status}`);let f=await h.text();return JSON.parse(f)}catch(h){console.error(h),alert(h.message)}}};var Fn=class extends ke{static styles=Xe` +`):i}function wh(i,t){let{element:e,datasetIndex:s,index:n}=t,o=i.getDatasetMeta(s).controller,{label:a,value:l}=o.getLabelAndValue(n);return{chart:i,label:a,parsed:o.getParsed(n),raw:i.data.datasets[s].data[n],formattedValue:l,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:e}}function Ma(i,t){let e=i.chart.ctx,{body:s,footer:n,title:o}=i,{boxWidth:a,boxHeight:l}=t,u=qe(t.bodyFont),g=qe(t.titleFont),x=qe(t.footerFont),b=o.length,w=n.length,k=s.length,A=ai(t.padding),T=A.height,R=0,$=s.reduce((Q,ht)=>Q+ht.before.length+ht.lines.length+ht.after.length,0);$+=i.beforeBody.length+i.afterBody.length,b&&(T+=b*g.lineHeight+(b-1)*t.titleSpacing+t.titleMarginBottom),$&&(T+=k*(t.displayColors?Math.max(l,u.lineHeight):u.lineHeight)+($-k)*u.lineHeight+($-1)*t.bodySpacing),w&&(T+=t.footerMarginTop+w*x.lineHeight+(w-1)*t.footerSpacing);let tt=0,Z=function(Q){R=Math.max(R,e.measureText(Q).width+tt)};return e.save(),e.font=g.string,xt(i.title,Z),e.font=u.string,xt(i.beforeBody.concat(i.afterBody),Z),tt=t.displayColors?a+2+t.boxPadding:0,xt(s,Q=>{xt(Q.before,Z),xt(Q.lines,Z),xt(Q.after,Z)}),tt=0,e.font=x.string,xt(i.footer,Z),e.restore(),R+=A.width,{width:R,height:T}}function _h(i,t,e,s){let{x:n,width:o}=e,{width:a,chartArea:{left:l,right:u}}=i,g="center";return s==="center"?g=n<=(l+u)/2?"left":"right":n<=o/2?g="left":n>=a-o/2&&(g="right"),function(x,b,w,k){let{x:A,width:T}=k,R=w.caretSize+w.caretPadding;return x==="left"&&A+T+R>b.width||x==="right"&&A-T-R<0||void 0}(g,i,t,e)&&(g="center"),g}function Sa(i,t,e){let s=e.yAlign||t.yAlign||function(n,o){let{y:a,height:l}=o;return an.height-l/2?"bottom":"center"}(i,e);return{xAlign:e.xAlign||t.xAlign||_h(i,t,e,s),yAlign:s}}function Ca(i,t,e,s){let{caretSize:n,caretPadding:o,cornerRadius:a}=i,{xAlign:l,yAlign:u}=e,g=n+o,{topLeft:x,topRight:b,bottomLeft:w,bottomRight:k}=fs(a),A=function(R,$){let{x:tt,width:Z}=R;return $==="right"?tt-=Z:$==="center"&&(tt-=Z/2),tt}(t,l),T=function(R,$,tt){let{y:Z,height:Q}=R;return $==="top"?Z+=tt:Z-=$==="bottom"?Q+tt:Q/2,Z}(t,u,g);return u==="center"?l==="left"?A+=g:l==="right"&&(A-=g):l==="left"?A-=Math.max(x,w)+n:l==="right"&&(A+=Math.max(b,k)+n),{x:J(A,0,s.width-t.width),y:J(T,0,s.height-t.height)}}function Mn(i,t,e){let s=ai(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-s.right:i.x+s.left}function Ta(i){return ns([],hs(i))}function Ea(i,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}let Da={beforeTitle:h,title(i){if(i.length>0){let t=i[0],e=t.chart.data.labels,s=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex{let a={before:[],lines:[],after:[]},l=Ea(s,o);ns(a.before,hs(Ci(l,"beforeLabel",this,o))),ns(a.lines,Ci(l,"label",this,o)),ns(a.after,hs(Ci(l,"afterLabel",this,o))),n.push(a)}),n}getAfterBody(t,e){return Ta(Ci(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:s}=e,n=Ci(s,"beforeFooter",this,t),o=Ci(s,"footer",this,t),a=Ci(s,"afterFooter",this,t),l=[];return l=ns(l,hs(n)),l=ns(l,hs(o)),l=ns(l,hs(a)),l}_createItems(t){let e=this._active,s=this.chart.data,n=[],o=[],a=[],l,u,g=[];for(l=0,u=e.length;lt.filter(x,b,w,s))),t.itemSort&&(g=g.sort((x,b)=>t.itemSort(x,b,s))),xt(g,x=>{let b=Ea(t.callbacks,x);n.push(Ci(b,"labelColor",this,x)),o.push(Ci(b,"labelPointStyle",this,x)),a.push(Ci(b,"labelTextColor",this,x))}),this.labelColors=n,this.labelPointStyles=o,this.labelTextColors=a,this.dataPoints=g,g}update(t,e){let s=this.options.setContext(this.getContext()),n=this._active,o,a=[];if(n.length){let l=Ks[s.position].call(this,n,this._eventPosition);a=this._createItems(s),this.title=this.getTitle(a,s),this.beforeBody=this.getBeforeBody(a,s),this.body=this.getBody(a,s),this.afterBody=this.getAfterBody(a,s),this.footer=this.getFooter(a,s);let u=this._size=Ma(this,s),g=Object.assign({},l,u),x=Sa(this.chart,s,g),b=Ca(s,g,x,this.chart);this.xAlign=x.xAlign,this.yAlign=x.yAlign,o={opacity:1,x:b.x,y:b.y,width:u.width,height:u.height,caretX:l.x,caretY:l.y}}else this.opacity!==0&&(o={opacity:0});this._tooltipItems=a,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,s,n){let o=this.getCaretPosition(t,s,n);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,s){let{xAlign:n,yAlign:o}=this,{caretSize:a,cornerRadius:l}=s,{topLeft:u,topRight:g,bottomLeft:x,bottomRight:b}=fs(l),{x:w,y:k}=t,{width:A,height:T}=e,R,$,tt,Z,Q,ht;return o==="center"?(Q=k+T/2,n==="left"?(R=w,$=R-a,Z=Q+a,ht=Q-a):(R=w+A,$=R+a,Z=Q-a,ht=Q+a),tt=R):($=n==="left"?w+Math.max(u,x)+a:n==="right"?w+A-Math.max(g,b)-a:this.caretX,o==="top"?(Z=k,Q=Z-a,R=$-a,tt=$+a):(Z=k+T,Q=Z+a,R=$+a,tt=$-a),ht=Z),{x1:R,x2:$,x3:tt,y1:Z,y2:Q,y3:ht}}drawTitle(t,e,s){let n=this.title,o=n.length,a,l,u;if(o){let g=Ss(s.rtl,this.x,this.width);for(t.x=Mn(this,s.titleAlign,s),e.textAlign=g.textAlign(s.titleAlign),e.textBaseline="middle",a=qe(s.titleFont),l=s.titleSpacing,e.fillStyle=s.titleColor,e.font=a.string,u=0;utt!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,xi(t,{x:T,y:A,w:g,h:u,radius:$}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),xi(t,{x:R,y:A+1,w:g-2,h:u-2,radius:$}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(T,A,g,u),t.strokeRect(T,A,g,u),t.fillStyle=a.backgroundColor,t.fillRect(R,A+1,g-2,u-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,e,s){let{body:n}=this,{bodySpacing:o,bodyAlign:a,displayColors:l,boxHeight:u,boxWidth:g,boxPadding:x}=s,b=qe(s.bodyFont),w=b.lineHeight,k=0,A=Ss(s.rtl,this.x,this.width),T=function(At){e.fillText(At,A.x(t.x+k),t.y+w/2),t.y+=w+o},R=A.textAlign(a),$,tt,Z,Q,ht,mt,Ct;for(e.textAlign=a,e.textBaseline="middle",e.font=b.string,t.x=Mn(this,R,s),e.fillStyle=s.bodyColor,xt(this.beforeBody,T),k=l&&R!=="right"?a==="center"?g/2+x:g+2+x:0,Q=0,mt=n.length;Q0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,s=this.$animations,n=s&&s.x,o=s&&s.y;if(n||o){let a=Ks[t.position].call(this,this._active,this._eventPosition);if(!a)return;let l=this._size=Ma(this,t),u=Object.assign({},a,this._size),g=Sa(e,t,u),x=Ca(t,u,g,e);n._to===x.x&&o._to===x.y||(this.xAlign=g.xAlign,this.yAlign=g.yAlign,this.width=l.width,this.height=l.height,this.caretX=a.x,this.caretY=a.y,this._resolveAnimations().update(this,x))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),s=this.opacity;if(!s)return;this._updateAnimationTarget(e);let n={width:this.width,height:this.height},o={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;let a=ai(e.padding),l=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&l&&(t.save(),t.globalAlpha=s,this.drawBackground(o,t,n,e),io(t,e.textDirection),o.y+=a.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),so(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let s=this._active,n=t.map(({datasetIndex:l,index:u})=>{let g=this.chart.getDatasetMeta(l);if(!g)throw new Error("Cannot find a dataset at index "+l);return{datasetIndex:l,element:g.data[u],index:u}}),o=!jt(s,n),a=this._positionChanged(n,e);(o||a)&&(this._active=n,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,s=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let n=this.options,o=this._active||[],a=this._getActiveElements(t,o,e,s),l=this._positionChanged(a,t),u=e||!jt(a,o)||l;return u&&(this._active=a,(n.enabled||n.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),u}_getActiveElements(t,e,s,n){let o=this.options;if(t.type==="mouseout")return[];if(!n)return e.filter(l=>this.chart.data.datasets[l.datasetIndex]&&this.chart.getDatasetMeta(l.datasetIndex).controller.getParsed(l.index)!==void 0);let a=this.chart.getElementsAtEventForMode(t,o.mode,o,s);return o.reverse&&a.reverse(),a}_positionChanged(t,e){let{caretX:s,caretY:n,options:o}=this,a=Ks[o.position].call(this,t,e);return a!==!1&&(s!==a.x||n!==a.y)}}var kh={id:"tooltip",_element:Pa,positioners:Ks,afterInit(i,t,e){e&&(i.tooltip=new Pa({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){let t=i.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){let e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Da},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};return Ve.register(Vr,aa,_o,D),Ve.helpers={...gl},Ve._adapters=$r,Ve.Animation=pr,Ve.Animations=co,Ve.animator=Be,Ve.controllers=Yi.controllers.items,Ve.DatasetController=ls,Ve.Element=ss,Ve.elements=_o,Ve.Interaction=Jo,Ve.layouts=li,Ve.platforms=ur,Ve.Scale=ms,Ve.Ticks=pt,Object.assign(Ve,Vr,aa,_o,D,ur),Ve.Chart=Ve,typeof window<"u"&&(window.Chart=Ve),Ve});(function(D,h){typeof exports=="object"&&typeof module<"u"?h(ys("chart.js")):typeof define=="function"&&define.amd?define(["chart.js"],h):h((D=typeof globalThis<"u"?globalThis:D||self).Chart)})(void 0,function(D){"use strict";function h(c){if(c===null||c===!0||c===!1)return NaN;var p=Number(c);return isNaN(p)?p:p<0?Math.ceil(p):Math.floor(p)}function f(c,p){if(p.length1?"s":"")+" required, but only "+p.length+" present")}function C(c){f(1,arguments);var p=Object.prototype.toString.call(c);return c instanceof Date||typeof c=="object"&&p==="[object Date]"?new Date(c.getTime()):typeof c=="number"||p==="[object Number]"?new Date(c):(typeof c!="string"&&p!=="[object String]"||typeof console>"u"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function I(c,p){f(2,arguments);var m=C(c),_=h(p);return isNaN(_)?new Date(NaN):(_&&m.setDate(m.getDate()+_),m)}function X(c,p){f(2,arguments);var m=C(c),_=h(p);if(isNaN(_))return new Date(NaN);if(!_)return m;var L=m.getDate(),K=new Date(m.getTime());K.setMonth(m.getMonth()+_+1,0);var gt=K.getDate();return L>=gt?K:(m.setFullYear(K.getFullYear(),K.getMonth(),L),m)}function W(c,p){f(2,arguments);var m=C(c).getTime(),_=h(p);return new Date(m+_)}var at=36e5;function q(c,p){f(1,arguments);var m=p||{},_=m.locale,L=_&&_.options&&_.options.weekStartsOn,K=L==null?0:h(L),gt=m.weekStartsOn==null?K:h(m.weekStartsOn);if(!(gt>=0&><=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var wt=C(c),Mt=wt.getDay(),qt=(Mt0?1:L}function te(c){f(1,arguments);var p=C(c);return!isNaN(p)}function ae(c,p){f(2,arguments);var m=C(c),_=C(p),L=m.getFullYear()-_.getFullYear(),K=m.getMonth()-_.getMonth();return 12*L+K}function Ae(c,p){f(2,arguments);var m=C(c),_=C(p);return m.getFullYear()-_.getFullYear()}function ue(c,p){var m=c.getFullYear()-p.getFullYear()||c.getMonth()-p.getMonth()||c.getDate()-p.getDate()||c.getHours()-p.getHours()||c.getMinutes()-p.getMinutes()||c.getSeconds()-p.getSeconds()||c.getMilliseconds()-p.getMilliseconds();return m<0?-1:m>0?1:m}function _e(c,p){f(2,arguments);var m=C(c),_=C(p),L=ue(m,_),K=Math.abs(xt(m,_));m.setDate(m.getDate()-L*K);var gt=ue(m,_)===-L,wt=L*(K-gt);return wt===0?0:wt}function Oe(c,p){f(2,arguments);var m=C(c),_=C(p);return m.getTime()-_.getTime()}var Ee=36e5;function Ge(c){f(1,arguments);var p=C(c);return p.setHours(23,59,59,999),p}function De(c){f(1,arguments);var p=C(c),m=p.getMonth();return p.setFullYear(p.getFullYear(),m+1,0),p.setHours(23,59,59,999),p}function se(c){f(1,arguments);var p=C(c);return Ge(p).getTime()===De(p).getTime()}function Bt(c,p){f(2,arguments);var m,_=C(c),L=C(p),K=jt(_,L),gt=Math.abs(ae(_,L));if(gt<1)m=0;else{_.getMonth()===1&&_.getDate()>27&&_.setDate(30),_.setMonth(_.getMonth()-K*gt);var wt=jt(_,L)===-K;se(C(c))&>===1&&jt(c,L)===1&&(wt=!1),m=K*(gt-wt)}return m===0?0:m}var St={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function r(c){return function(p){var m=p||{},_=m.width?String(m.width):c.defaultWidth;return c.formats[_]||c.formats[c.defaultWidth]}}var d={date:r({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:r({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:r({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},y={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function v(c){return function(p,m){var _,L=m||{};if((L.context?String(L.context):"standalone")==="formatting"&&c.formattingValues){var K=c.defaultFormattingWidth||c.defaultWidth,gt=L.width?String(L.width):K;_=c.formattingValues[gt]||c.formattingValues[K]}else{var wt=c.defaultWidth,Mt=L.width?String(L.width):c.defaultWidth;_=c.values[Mt]||c.values[wt]}return _[c.argumentCallback?c.argumentCallback(p):p]}}function P(c){return function(p,m){var _=String(p),L=m||{},K=L.width,gt=K&&c.matchPatterns[K]||c.matchPatterns[c.defaultMatchWidth],wt=_.match(gt);if(!wt)return null;var Mt,qt=wt[0],Gt=K&&c.parsePatterns[K]||c.parsePatterns[c.defaultParseWidth];return Mt=Object.prototype.toString.call(Gt)==="[object Array]"?function(Jt,pe){for(var he=0;he0?"in "+_:_+" ago":_},formatLong:d,formatRelative:function(c,p,m,_){return y[c]},localize:{ordinalNumber:function(c,p){var m=Number(c),_=m%100;if(_>20||_<10)switch(_%10){case 1:return m+"st";case 2:return m+"nd";case 3:return m+"rd"}return m+"th"},era:v({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:v({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(c){return Number(c)-1}}),month:v({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:v({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:v({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(F={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(c){return parseInt(c,10)}},function(c,p){var m=String(c),_=p||{},L=m.match(F.matchPattern);if(!L)return null;var K=L[0],gt=m.match(F.parsePattern);if(!gt)return null;var wt=F.valueCallback?F.valueCallback(gt[0]):gt[0];return{value:wt=_.valueCallback?_.valueCallback(wt):wt,rest:m.slice(K.length)}}),era:P({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:P({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(c){return c+1}}),month:P({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:P({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:P({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function nt(c,p){f(2,arguments);var m=h(p);return W(c,-m)}function V(c,p){for(var m=c<0?"-":"",_=Math.abs(c).toString();_.length0?m:1-m;return V(p==="yy"?_%100:_,p.length)},M:function(c,p){var m=c.getUTCMonth();return p==="M"?String(m+1):V(m+1,2)},d:function(c,p){return V(c.getUTCDate(),p.length)},a:function(c,p){var m=c.getUTCHours()/12>=1?"pm":"am";switch(p){case"a":case"aa":return m.toUpperCase();case"aaa":return m;case"aaaaa":return m[0];default:return m==="am"?"a.m.":"p.m."}},h:function(c,p){return V(c.getUTCHours()%12||12,p.length)},H:function(c,p){return V(c.getUTCHours(),p.length)},m:function(c,p){return V(c.getUTCMinutes(),p.length)},s:function(c,p){return V(c.getUTCSeconds(),p.length)},S:function(c,p){var m=p.length,_=c.getUTCMilliseconds();return V(Math.floor(_*Math.pow(10,m-3)),p.length)}},kt=864e5;function Et(c){f(1,arguments);var p=1,m=C(c),_=m.getUTCDay(),L=(_=L.getTime()?m+1:p.getTime()>=gt.getTime()?m:m-1}function Le(c){f(1,arguments);var p=ie(c),m=new Date(0);m.setUTCFullYear(p,0,4),m.setUTCHours(0,0,0,0);var _=Et(m);return _}var ii=6048e5;function Re(c){f(1,arguments);var p=C(c),m=Et(p).getTime()-Le(p).getTime();return Math.round(m/ii)+1}function We(c,p){f(1,arguments);var m=p||{},_=m.locale,L=_&&_.options&&_.options.weekStartsOn,K=L==null?0:h(L),gt=m.weekStartsOn==null?K:h(m.weekStartsOn);if(!(gt>=0&><=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var wt=C(c),Mt=wt.getUTCDay(),qt=(Mt=1&&Mt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var qt=new Date(0);qt.setUTCFullYear(_+1,0,Mt),qt.setUTCHours(0,0,0,0);var Gt=We(qt,p),Jt=new Date(0);Jt.setUTCFullYear(_,0,Mt),Jt.setUTCHours(0,0,0,0);var pe=We(Jt,p);return m.getTime()>=Gt.getTime()?_+1:m.getTime()>=pe.getTime()?_:_-1}function Ie(c,p){f(1,arguments);var m=p||{},_=m.locale,L=_&&_.options&&_.options.firstWeekContainsDate,K=L==null?1:h(L),gt=m.firstWeekContainsDate==null?K:h(m.firstWeekContainsDate),wt=Je(c,p),Mt=new Date(0);Mt.setUTCFullYear(wt,0,gt),Mt.setUTCHours(0,0,0,0);var qt=We(Mt,p);return qt}var ti=6048e5;function Ne(c,p){f(1,arguments);var m=C(c),_=We(m,p).getTime()-Ie(m,p).getTime();return Math.round(_/ti)+1}var si="midnight",wi="noon",Di="morning",ve="afternoon",N="evening",J="night",et={G:function(c,p,m){var _=c.getUTCFullYear()>0?1:0;switch(p){case"G":case"GG":case"GGG":return m.era(_,{width:"abbreviated"});case"GGGGG":return m.era(_,{width:"narrow"});default:return m.era(_,{width:"wide"})}},y:function(c,p,m){if(p==="yo"){var _=c.getUTCFullYear(),L=_>0?_:1-_;return m.ordinalNumber(L,{unit:"year"})}return it.y(c,p)},Y:function(c,p,m,_){var L=Je(c,_),K=L>0?L:1-L;return p==="YY"?V(K%100,2):p==="Yo"?m.ordinalNumber(K,{unit:"year"}):V(K,p.length)},R:function(c,p){return V(ie(c),p.length)},u:function(c,p){return V(c.getUTCFullYear(),p.length)},Q:function(c,p,m){var _=Math.ceil((c.getUTCMonth()+1)/3);switch(p){case"Q":return String(_);case"QQ":return V(_,2);case"Qo":return m.ordinalNumber(_,{unit:"quarter"});case"QQQ":return m.quarter(_,{width:"abbreviated",context:"formatting"});case"QQQQQ":return m.quarter(_,{width:"narrow",context:"formatting"});default:return m.quarter(_,{width:"wide",context:"formatting"})}},q:function(c,p,m){var _=Math.ceil((c.getUTCMonth()+1)/3);switch(p){case"q":return String(_);case"qq":return V(_,2);case"qo":return m.ordinalNumber(_,{unit:"quarter"});case"qqq":return m.quarter(_,{width:"abbreviated",context:"standalone"});case"qqqqq":return m.quarter(_,{width:"narrow",context:"standalone"});default:return m.quarter(_,{width:"wide",context:"standalone"})}},M:function(c,p,m){var _=c.getUTCMonth();switch(p){case"M":case"MM":return it.M(c,p);case"Mo":return m.ordinalNumber(_+1,{unit:"month"});case"MMM":return m.month(_,{width:"abbreviated",context:"formatting"});case"MMMMM":return m.month(_,{width:"narrow",context:"formatting"});default:return m.month(_,{width:"wide",context:"formatting"})}},L:function(c,p,m){var _=c.getUTCMonth();switch(p){case"L":return String(_+1);case"LL":return V(_+1,2);case"Lo":return m.ordinalNumber(_+1,{unit:"month"});case"LLL":return m.month(_,{width:"abbreviated",context:"standalone"});case"LLLLL":return m.month(_,{width:"narrow",context:"standalone"});default:return m.month(_,{width:"wide",context:"standalone"})}},w:function(c,p,m,_){var L=Ne(c,_);return p==="wo"?m.ordinalNumber(L,{unit:"week"}):V(L,p.length)},I:function(c,p,m){var _=Re(c);return p==="Io"?m.ordinalNumber(_,{unit:"week"}):V(_,p.length)},d:function(c,p,m){return p==="do"?m.ordinalNumber(c.getUTCDate(),{unit:"date"}):it.d(c,p)},D:function(c,p,m){var _=function(L){f(1,arguments);var K=C(L),gt=K.getTime();K.setUTCMonth(0,1),K.setUTCHours(0,0,0,0);var wt=K.getTime(),Mt=gt-wt;return Math.floor(Mt/kt)+1}(c);return p==="Do"?m.ordinalNumber(_,{unit:"dayOfYear"}):V(_,p.length)},E:function(c,p,m){var _=c.getUTCDay();switch(p){case"E":case"EE":case"EEE":return m.day(_,{width:"abbreviated",context:"formatting"});case"EEEEE":return m.day(_,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(_,{width:"short",context:"formatting"});default:return m.day(_,{width:"wide",context:"formatting"})}},e:function(c,p,m,_){var L=c.getUTCDay(),K=(L-_.weekStartsOn+8)%7||7;switch(p){case"e":return String(K);case"ee":return V(K,2);case"eo":return m.ordinalNumber(K,{unit:"day"});case"eee":return m.day(L,{width:"abbreviated",context:"formatting"});case"eeeee":return m.day(L,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(L,{width:"short",context:"formatting"});default:return m.day(L,{width:"wide",context:"formatting"})}},c:function(c,p,m,_){var L=c.getUTCDay(),K=(L-_.weekStartsOn+8)%7||7;switch(p){case"c":return String(K);case"cc":return V(K,p.length);case"co":return m.ordinalNumber(K,{unit:"day"});case"ccc":return m.day(L,{width:"abbreviated",context:"standalone"});case"ccccc":return m.day(L,{width:"narrow",context:"standalone"});case"cccccc":return m.day(L,{width:"short",context:"standalone"});default:return m.day(L,{width:"wide",context:"standalone"})}},i:function(c,p,m){var _=c.getUTCDay(),L=_===0?7:_;switch(p){case"i":return String(L);case"ii":return V(L,p.length);case"io":return m.ordinalNumber(L,{unit:"day"});case"iii":return m.day(_,{width:"abbreviated",context:"formatting"});case"iiiii":return m.day(_,{width:"narrow",context:"formatting"});case"iiiiii":return m.day(_,{width:"short",context:"formatting"});default:return m.day(_,{width:"wide",context:"formatting"})}},a:function(c,p,m){var _=c.getUTCHours()/12>=1?"pm":"am";switch(p){case"a":case"aa":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"});case"aaa":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return m.dayPeriod(_,{width:"narrow",context:"formatting"});default:return m.dayPeriod(_,{width:"wide",context:"formatting"})}},b:function(c,p,m){var _,L=c.getUTCHours();switch(_=L===12?wi:L===0?si:L/12>=1?"pm":"am",p){case"b":case"bb":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"});case"bbb":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return m.dayPeriod(_,{width:"narrow",context:"formatting"});default:return m.dayPeriod(_,{width:"wide",context:"formatting"})}},B:function(c,p,m){var _,L=c.getUTCHours();switch(_=L>=17?N:L>=12?ve:L>=4?Di:J,p){case"B":case"BB":case"BBB":return m.dayPeriod(_,{width:"abbreviated",context:"formatting"});case"BBBBB":return m.dayPeriod(_,{width:"narrow",context:"formatting"});default:return m.dayPeriod(_,{width:"wide",context:"formatting"})}},h:function(c,p,m){if(p==="ho"){var _=c.getUTCHours()%12;return _===0&&(_=12),m.ordinalNumber(_,{unit:"hour"})}return it.h(c,p)},H:function(c,p,m){return p==="Ho"?m.ordinalNumber(c.getUTCHours(),{unit:"hour"}):it.H(c,p)},K:function(c,p,m){var _=c.getUTCHours()%12;return p==="Ko"?m.ordinalNumber(_,{unit:"hour"}):V(_,p.length)},k:function(c,p,m){var _=c.getUTCHours();return _===0&&(_=24),p==="ko"?m.ordinalNumber(_,{unit:"hour"}):V(_,p.length)},m:function(c,p,m){return p==="mo"?m.ordinalNumber(c.getUTCMinutes(),{unit:"minute"}):it.m(c,p)},s:function(c,p,m){return p==="so"?m.ordinalNumber(c.getUTCSeconds(),{unit:"second"}):it.s(c,p)},S:function(c,p){return it.S(c,p)},X:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();if(L===0)return"Z";switch(p){case"X":return ut(L);case"XXXX":case"XX":return dt(L);default:return dt(L,":")}},x:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();switch(p){case"x":return ut(L);case"xxxx":case"xx":return dt(L);default:return dt(L,":")}},O:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();switch(p){case"O":case"OO":case"OOO":return"GMT"+ot(L,":");default:return"GMT"+dt(L,":")}},z:function(c,p,m,_){var L=(_._originalDate||c).getTimezoneOffset();switch(p){case"z":case"zz":case"zzz":return"GMT"+ot(L,":");default:return"GMT"+dt(L,":")}},t:function(c,p,m,_){var L=_._originalDate||c;return V(Math.floor(L.getTime()/1e3),p.length)},T:function(c,p,m,_){return V((_._originalDate||c).getTime(),p.length)}};function ot(c,p){var m=c>0?"-":"+",_=Math.abs(c),L=Math.floor(_/60),K=_%60;if(K===0)return m+String(L);var gt=p||"";return m+String(L)+gt+V(K,2)}function ut(c,p){return c%60==0?(c>0?"-":"+")+V(Math.abs(c)/60,2):dt(c,p)}function dt(c,p){var m=p||"",_=c>0?"-":"+",L=Math.abs(c);return _+V(Math.floor(L/60),2)+m+V(L%60,2)}var yt=et;function Pt(c,p){switch(c){case"P":return p.date({width:"short"});case"PP":return p.date({width:"medium"});case"PPP":return p.date({width:"long"});default:return p.date({width:"full"})}}function Tt(c,p){switch(c){case"p":return p.time({width:"short"});case"pp":return p.time({width:"medium"});case"ppp":return p.time({width:"long"});default:return p.time({width:"full"})}}var Ut={p:Tt,P:function(c,p){var m,_=c.match(/(P+)(p+)?/),L=_[1],K=_[2];if(!K)return Pt(c,p);switch(L){case"P":m=p.dateTime({width:"short"});break;case"PP":m=p.dateTime({width:"medium"});break;case"PPP":m=p.dateTime({width:"long"});break;default:m=p.dateTime({width:"full"})}return m.replace("{{date}}",Pt(L,p)).replace("{{time}}",Tt(K,p))}},zt=Ut,ce=["D","DD"],re=["YY","YYYY"];function Ce(c){return ce.indexOf(c)!==-1}function fe(c){return re.indexOf(c)!==-1}function xe(c,p,m){if(c==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(p,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(c==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(p,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(c==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(p,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(c==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(p,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"))}var Te=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,rs=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ci=/^'([^]*?)'?$/,di=/''/g,Ki=/[a-zA-Z]/;function Be(c){return c.match(ci)[1].replace(di,"'")}function Hi(c,p){if(c==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var m in p=p||{})p.hasOwnProperty(m)&&(c[m]=p[m]);return c}function ni(c,p,m){f(2,arguments);var _=m||{},L=_.locale,K=L&&L.options&&L.options.weekStartsOn,gt=K==null?0:h(K),wt=_.weekStartsOn==null?gt:h(_.weekStartsOn);if(!(wt>=0&&wt<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Mt=C(c),qt=h(p),Gt=Mt.getUTCDay(),Jt=qt%7,pe=(Jt+7)%7,he=(pe0,L=_?p:1-p;if(L<=50)m=c||100;else{var K=L+50;m=c+100*Math.floor(K/100)-(c>=K%100?100:0)}return _?m:1-m}var z=[31,28,31,30,31,30,31,31,30,31,30,31],H=[31,29,31,30,31,30,31,31,30,31,30,31];function j(c){return c%400==0||c%4==0&&c%100!=0}var U={G:{priority:140,parse:function(c,p,m,_){switch(p){case"G":case"GG":case"GGG":return m.era(c,{width:"abbreviated"})||m.era(c,{width:"narrow"});case"GGGGG":return m.era(c,{width:"narrow"});default:return m.era(c,{width:"wide"})||m.era(c,{width:"abbreviated"})||m.era(c,{width:"narrow"})}},set:function(c,p,m,_){return p.era=m,c.setUTCFullYear(m,0,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["R","u","t","T"]},y:{priority:130,parse:function(c,p,m,_){var L=function(K){return{year:K,isTwoDigitYear:p==="yy"}};switch(p){case"y":return we(4,c,L);case"yo":return m.ordinalNumber(c,{unit:"year",valueCallback:L});default:return we(p.length,c,L)}},validate:function(c,p,m){return p.isTwoDigitYear||p.year>0},set:function(c,p,m,_){var L=c.getUTCFullYear();if(m.isTwoDigitYear){var K=M(m.year,L);return c.setUTCFullYear(K,0,1),c.setUTCHours(0,0,0,0),c}var gt="era"in p&&p.era!==1?1-m.year:m.year;return c.setUTCFullYear(gt,0,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","u","w","I","i","e","c","t","T"]},Y:{priority:130,parse:function(c,p,m,_){var L=function(K){return{year:K,isTwoDigitYear:p==="YY"}};switch(p){case"Y":return we(4,c,L);case"Yo":return m.ordinalNumber(c,{unit:"year",valueCallback:L});default:return we(p.length,c,L)}},validate:function(c,p,m){return p.isTwoDigitYear||p.year>0},set:function(c,p,m,_){var L=Je(c,_);if(m.isTwoDigitYear){var K=M(m.year,L);return c.setUTCFullYear(K,0,_.firstWeekContainsDate),c.setUTCHours(0,0,0,0),We(c,_)}var gt="era"in p&&p.era!==1?1-m.year:m.year;return c.setUTCFullYear(gt,0,_.firstWeekContainsDate),c.setUTCHours(0,0,0,0),We(c,_)},incompatibleTokens:["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:{priority:130,parse:function(c,p,m,_){return es(p==="R"?4:p.length,c)},set:function(c,p,m,_){var L=new Date(0);return L.setUTCFullYear(m,0,4),L.setUTCHours(0,0,0,0),Et(L)},incompatibleTokens:["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:{priority:130,parse:function(c,p,m,_){return es(p==="u"?4:p.length,c)},set:function(c,p,m,_){return c.setUTCFullYear(m,0,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["G","y","Y","R","w","I","i","e","c","t","T"]},Q:{priority:120,parse:function(c,p,m,_){switch(p){case"Q":case"QQ":return we(p.length,c);case"Qo":return m.ordinalNumber(c,{unit:"quarter"});case"QQQ":return m.quarter(c,{width:"abbreviated",context:"formatting"})||m.quarter(c,{width:"narrow",context:"formatting"});case"QQQQQ":return m.quarter(c,{width:"narrow",context:"formatting"});default:return m.quarter(c,{width:"wide",context:"formatting"})||m.quarter(c,{width:"abbreviated",context:"formatting"})||m.quarter(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=1&&p<=4},set:function(c,p,m,_){return c.setUTCMonth(3*(m-1),1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:{priority:120,parse:function(c,p,m,_){switch(p){case"q":case"qq":return we(p.length,c);case"qo":return m.ordinalNumber(c,{unit:"quarter"});case"qqq":return m.quarter(c,{width:"abbreviated",context:"standalone"})||m.quarter(c,{width:"narrow",context:"standalone"});case"qqqqq":return m.quarter(c,{width:"narrow",context:"standalone"});default:return m.quarter(c,{width:"wide",context:"standalone"})||m.quarter(c,{width:"abbreviated",context:"standalone"})||m.quarter(c,{width:"narrow",context:"standalone"})}},validate:function(c,p,m){return p>=1&&p<=4},set:function(c,p,m,_){return c.setUTCMonth(3*(m-1),1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:{priority:110,parse:function(c,p,m,_){var L=function(K){return K-1};switch(p){case"M":return ge(_i,c,L);case"MM":return we(2,c,L);case"Mo":return m.ordinalNumber(c,{unit:"month",valueCallback:L});case"MMM":return m.month(c,{width:"abbreviated",context:"formatting"})||m.month(c,{width:"narrow",context:"formatting"});case"MMMMM":return m.month(c,{width:"narrow",context:"formatting"});default:return m.month(c,{width:"wide",context:"formatting"})||m.month(c,{width:"abbreviated",context:"formatting"})||m.month(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=0&&p<=11},set:function(c,p,m,_){return c.setUTCMonth(m,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]},L:{priority:110,parse:function(c,p,m,_){var L=function(K){return K-1};switch(p){case"L":return ge(_i,c,L);case"LL":return we(2,c,L);case"Lo":return m.ordinalNumber(c,{unit:"month",valueCallback:L});case"LLL":return m.month(c,{width:"abbreviated",context:"standalone"})||m.month(c,{width:"narrow",context:"standalone"});case"LLLLL":return m.month(c,{width:"narrow",context:"standalone"});default:return m.month(c,{width:"wide",context:"standalone"})||m.month(c,{width:"abbreviated",context:"standalone"})||m.month(c,{width:"narrow",context:"standalone"})}},validate:function(c,p,m){return p>=0&&p<=11},set:function(c,p,m,_){return c.setUTCMonth(m,1),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:{priority:100,parse:function(c,p,m,_){switch(p){case"w":return ge(Zi,c);case"wo":return m.ordinalNumber(c,{unit:"week"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=1&&p<=53},set:function(c,p,m,_){return We(function(L,K,gt){f(2,arguments);var wt=C(L),Mt=h(K),qt=Ne(wt,gt)-Mt;return wt.setUTCDate(wt.getUTCDate()-7*qt),wt}(c,m,_),_)},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:{priority:100,parse:function(c,p,m,_){switch(p){case"I":return ge(Zi,c);case"Io":return m.ordinalNumber(c,{unit:"week"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=1&&p<=53},set:function(c,p,m,_){return Et(function(L,K){f(2,arguments);var gt=C(L),wt=h(K),Mt=Re(gt)-wt;return gt.setUTCDate(gt.getUTCDate()-7*Mt),gt}(c,m,_),_)},incompatibleTokens:["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:{priority:90,subPriority:1,parse:function(c,p,m,_){switch(p){case"d":return ge(ui,c);case"do":return m.ordinalNumber(c,{unit:"date"});default:return we(p.length,c)}},validate:function(c,p,m){var _=j(c.getUTCFullYear()),L=c.getUTCMonth();return _?p>=1&&p<=H[L]:p>=1&&p<=z[L]},set:function(c,p,m,_){return c.setUTCDate(m),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:{priority:90,subPriority:1,parse:function(c,p,m,_){switch(p){case"D":case"DD":return ge(gi,c);case"Do":return m.ordinalNumber(c,{unit:"date"});default:return we(p.length,c)}},validate:function(c,p,m){return j(c.getUTCFullYear())?p>=1&&p<=366:p>=1&&p<=365},set:function(c,p,m,_){return c.setUTCMonth(0,m),c.setUTCHours(0,0,0,0),c},incompatibleTokens:["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:{priority:90,parse:function(c,p,m,_){switch(p){case"E":case"EE":case"EEE":return m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});case"EEEEE":return m.day(c,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});default:return m.day(c,{width:"wide",context:"formatting"})||m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=0&&p<=6},set:function(c,p,m,_){return(c=ni(c,m,_)).setUTCHours(0,0,0,0),c},incompatibleTokens:["D","i","e","c","t","T"]},e:{priority:90,parse:function(c,p,m,_){var L=function(K){var gt=7*Math.floor((K-1)/7);return(K+_.weekStartsOn+6)%7+gt};switch(p){case"e":case"ee":return we(p.length,c,L);case"eo":return m.ordinalNumber(c,{unit:"day",valueCallback:L});case"eee":return m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});case"eeeee":return m.day(c,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"});default:return m.day(c,{width:"wide",context:"formatting"})||m.day(c,{width:"abbreviated",context:"formatting"})||m.day(c,{width:"short",context:"formatting"})||m.day(c,{width:"narrow",context:"formatting"})}},validate:function(c,p,m){return p>=0&&p<=6},set:function(c,p,m,_){return(c=ni(c,m,_)).setUTCHours(0,0,0,0),c},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:{priority:90,parse:function(c,p,m,_){var L=function(K){var gt=7*Math.floor((K-1)/7);return(K+_.weekStartsOn+6)%7+gt};switch(p){case"c":case"cc":return we(p.length,c,L);case"co":return m.ordinalNumber(c,{unit:"day",valueCallback:L});case"ccc":return m.day(c,{width:"abbreviated",context:"standalone"})||m.day(c,{width:"short",context:"standalone"})||m.day(c,{width:"narrow",context:"standalone"});case"ccccc":return m.day(c,{width:"narrow",context:"standalone"});case"cccccc":return m.day(c,{width:"short",context:"standalone"})||m.day(c,{width:"narrow",context:"standalone"});default:return m.day(c,{width:"wide",context:"standalone"})||m.day(c,{width:"abbreviated",context:"standalone"})||m.day(c,{width:"short",context:"standalone"})||m.day(c,{width:"narrow",context:"standalone"})}},validate:function(c,p,m){return p>=0&&p<=6},set:function(c,p,m,_){return(c=ni(c,m,_)).setUTCHours(0,0,0,0),c},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:{priority:90,parse:function(c,p,m,_){var L=function(K){return K===0?7:K};switch(p){case"i":case"ii":return we(p.length,c);case"io":return m.ordinalNumber(c,{unit:"day"});case"iii":return m.day(c,{width:"abbreviated",context:"formatting",valueCallback:L})||m.day(c,{width:"short",context:"formatting",valueCallback:L})||m.day(c,{width:"narrow",context:"formatting",valueCallback:L});case"iiiii":return m.day(c,{width:"narrow",context:"formatting",valueCallback:L});case"iiiiii":return m.day(c,{width:"short",context:"formatting",valueCallback:L})||m.day(c,{width:"narrow",context:"formatting",valueCallback:L});default:return m.day(c,{width:"wide",context:"formatting",valueCallback:L})||m.day(c,{width:"abbreviated",context:"formatting",valueCallback:L})||m.day(c,{width:"short",context:"formatting",valueCallback:L})||m.day(c,{width:"narrow",context:"formatting",valueCallback:L})}},validate:function(c,p,m){return p>=1&&p<=7},set:function(c,p,m,_){return c=function(L,K){f(2,arguments);var gt=h(K);gt%7==0&&(gt-=7);var wt=1,Mt=C(L),qt=Mt.getUTCDay(),Gt=((gt%7+7)%7=1&&p<=12},set:function(c,p,m,_){var L=c.getUTCHours()>=12;return L&&m<12?c.setUTCHours(m+12,0,0,0):L||m!==12?c.setUTCHours(m,0,0,0):c.setUTCHours(0,0,0,0),c},incompatibleTokens:["H","K","k","t","T"]},H:{priority:70,parse:function(c,p,m,_){switch(p){case"H":return ge($e,c);case"Ho":return m.ordinalNumber(c,{unit:"hour"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=23},set:function(c,p,m,_){return c.setUTCHours(m,0,0,0),c},incompatibleTokens:["a","b","h","K","k","t","T"]},K:{priority:70,parse:function(c,p,m,_){switch(p){case"K":return ge(Ji,c);case"Ko":return m.ordinalNumber(c,{unit:"hour"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=11},set:function(c,p,m,_){return c.getUTCHours()>=12&&m<12?c.setUTCHours(m+12,0,0,0):c.setUTCHours(m,0,0,0),c},incompatibleTokens:["a","b","h","H","k","t","T"]},k:{priority:70,parse:function(c,p,m,_){switch(p){case"k":return ge(Ui,c);case"ko":return m.ordinalNumber(c,{unit:"hour"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=1&&p<=24},set:function(c,p,m,_){var L=m<=24?m%24:m;return c.setUTCHours(L,0,0,0),c},incompatibleTokens:["a","b","h","H","K","t","T"]},m:{priority:60,parse:function(c,p,m,_){switch(p){case"m":return ge(Pi,c);case"mo":return m.ordinalNumber(c,{unit:"minute"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=59},set:function(c,p,m,_){return c.setUTCMinutes(m,0,0),c},incompatibleTokens:["t","T"]},s:{priority:50,parse:function(c,p,m,_){switch(p){case"s":return ge(He,c);case"so":return m.ordinalNumber(c,{unit:"second"});default:return we(p.length,c)}},validate:function(c,p,m){return p>=0&&p<=59},set:function(c,p,m,_){return c.setUTCSeconds(m,0),c},incompatibleTokens:["t","T"]},S:{priority:30,parse:function(c,p,m,_){return we(p.length,c,function(L){return Math.floor(L*Math.pow(10,3-p.length))})},set:function(c,p,m,_){return c.setUTCMilliseconds(m),c},incompatibleTokens:["t","T"]},X:{priority:10,parse:function(c,p,m,_){switch(p){case"X":return Ue(yi,c);case"XX":return Ue(Vi,c);case"XXXX":return Ue(Ri,c);case"XXXXX":return Ue(ds,c);default:return Ue(Oi,c)}},set:function(c,p,m,_){return p.timestampIsSet?c:new Date(c.getTime()-m)},incompatibleTokens:["t","T","x"]},x:{priority:10,parse:function(c,p,m,_){switch(p){case"x":return Ue(yi,c);case"xx":return Ue(Vi,c);case"xxxx":return Ue(Ri,c);case"xxxxx":return Ue(ds,c);default:return Ue(Oi,c)}},set:function(c,p,m,_){return p.timestampIsSet?c:new Date(c.getTime()-m)},incompatibleTokens:["t","T","X"]},t:{priority:40,parse:function(c,p,m,_){return Ni(c)},set:function(c,p,m,_){return[new Date(1e3*m),{timestampIsSet:!0}]},incompatibleTokens:"*"},T:{priority:20,parse:function(c,p,m,_){return Ni(c)},set:function(c,p,m,_){return[new Date(m),{timestampIsSet:!0}]},incompatibleTokens:"*"}},G=U,rt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ct=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,st=/^'([^]*?)'?$/,pt=/''/g,lt=/\S/,vt=/[a-zA-Z]/;function Lt(c,p){if(p.timestampIsSet)return c;var m=new Date(0);return m.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),m.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),m}function Ht(c){return c.match(st)[1].replace(pt,"'")}var _t=36e5,bt={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Dt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Yt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Qt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function oe(c){var p,m={},_=c.split(bt.dateTimeDelimiter);if(_.length>2)return m;if(/:/.test(_[0])?(m.date=null,p=_[0]):(m.date=_[0],p=_[1],bt.timeZoneDelimiter.test(m.date)&&(m.date=c.split(bt.timeZoneDelimiter)[0],p=c.substr(m.date.length,c.length))),p){var L=bt.timezone.exec(p);L?(m.time=p.replace(L[1],""),m.timezone=L[1]):m.time=p}return m}function de(c,p){var m=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+p)+"})|(\\d{2}|[+-]\\d{"+(2+p)+"})$)"),_=c.match(m);if(!_)return{year:null};var L=_[1]&&parseInt(_[1]),K=_[2]&&parseInt(_[2]);return{year:K==null?L:100*K,restDateString:c.slice((_[1]||_[2]).length)}}function le(c,p){if(p===null)return null;var m=c.match(Dt);if(!m)return null;var _=!!m[4],L=Zt(m[1]),K=Zt(m[2])-1,gt=Zt(m[3]),wt=Zt(m[4]),Mt=Zt(m[5])-1;if(_)return function(Gt,Jt,pe){return Jt>=1&&Jt<=53&&pe>=0&&pe<=6}(0,wt,Mt)?function(Gt,Jt,pe){var he=new Date(0);he.setUTCFullYear(Gt,0,4);var oi=he.getUTCDay()||7,Qe=7*(Jt-1)+pe+1-oi;return he.setUTCDate(he.getUTCDate()+Qe),he}(p,wt,Mt):new Date(NaN);var qt=new Date(0);return function(Gt,Jt,pe){return Jt>=0&&Jt<=11&&pe>=1&&pe<=(S[Jt]||(O(Gt)?29:28))}(p,K,gt)&&function(Gt,Jt){return Jt>=1&&Jt<=(O(Gt)?366:365)}(p,L)?(qt.setUTCFullYear(p,K,Math.max(L,gt)),qt):new Date(NaN)}function Zt(c){return c?parseInt(c):1}function Me(c){var p=c.match(Yt);if(!p)return null;var m=me(p[1]),_=me(p[2]),L=me(p[3]);return function(K,gt,wt){return K===24?gt===0&&wt===0:wt>=0&&wt<60&>>=0&><60&&K>=0&&K<25}(m,_,L)?m*_t+6e4*_+1e3*L:NaN}function me(c){return c&&parseFloat(c.replace(",","."))||0}function Pe(c){if(c==="Z")return 0;var p=c.match(Qt);if(!p)return 0;var m=p[1]==="+"?-1:1,_=parseInt(p[2]),L=p[3]&&parseInt(p[3])||0;return function(K,gt){return gt>=0&><=59}(0,L)?m*(_*_t+6e4*L):NaN}var S=[31,null,31,30,31,30,31,31,30,31,30,31];function O(c){return c%400==0||c%4==0&&c%100}let B={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};D._adapters._date.override({_id:"date-fns",formats:function(){return B},parse:function(c,p){if(c==null)return null;let m=typeof c;return m==="number"||c instanceof Date?c=C(c):m==="string"&&(c=typeof p=="string"?function(_,L,K,gt){f(3,arguments);var wt=String(_),Mt=String(L),qt=gt||{},Gt=qt.locale||Y;if(!Gt.match)throw new RangeError("locale must contain match property");var Jt=Gt.options&&Gt.options.firstWeekContainsDate,pe=Jt==null?1:h(Jt),he=qt.firstWeekContainsDate==null?pe:h(qt.firstWeekContainsDate);if(!(he>=1&&he<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var oi=Gt.options&&Gt.options.weekStartsOn,Qe=oi==null?0:h(oi),xi=qt.weekStartsOn==null?Qe:h(qt.weekStartsOn);if(!(xi>=0&&xi<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(Mt==="")return wt===""?C(K):new Date(NaN);var Ke,ri={firstWeekContainsDate:he,weekStartsOn:xi,locale:Gt},ze=[{priority:10,subPriority:-1,set:Lt,index:0}],fi=Mt.match(ct).map(function(ei){var Mi=ei[0];return Mi==="p"||Mi==="P"?(0,zt[Mi])(ei,Gt.formatLong,ri):ei}).join("").match(rt),vi=[];for(Ke=0;Ke0&<.test(wt))return new Date(NaN);var zs=ze.map(function(ei){return ei.priority}).sort(function(ei,Mi){return Mi-ei}).filter(function(ei,Mi,gs){return gs.indexOf(ei)===Mi}).map(function(ei){return ze.filter(function(Mi){return Mi.priority===ei}).sort(function(Mi,gs){return gs.subPriority-Mi.subPriority})}).map(function(ei){return ei[0]}),Fs=C(K);if(isNaN(Fs))return new Date(NaN);var Fi=nt(Fs,Rt(Fs)),Ws={};for(Ke=0;Ke=1&&Gt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var Jt=wt.options&&wt.options.weekStartsOn,pe=Jt==null?0:h(Jt),he=gt.weekStartsOn==null?pe:h(gt.weekStartsOn);if(!(he>=0&&he<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!wt.localize)throw new RangeError("locale must contain localize property");if(!wt.formatLong)throw new RangeError("locale must contain formatLong property");var oi=C(m);if(!te(oi))throw new RangeError("Invalid time value");var Qe=Rt(oi),xi=nt(oi,Qe),Ke={firstWeekContainsDate:Gt,weekStartsOn:he,locale:wt,_originalDate:oi},ri=K.match(rs).map(function(ze){var fi=ze[0];return fi==="p"||fi==="P"?(0,zt[fi])(ze,wt.formatLong,Ke):ze}).join("").match(Te).map(function(ze){if(ze==="''")return"'";var fi=ze[0];if(fi==="'")return Be(ze);var vi=yt[fi];if(vi)return!gt.useAdditionalWeekYearTokens&&fe(ze)&&xe(ze,_,m),!gt.useAdditionalDayOfYearTokens&&Ce(ze)&&xe(ze,_,m),vi(xi,ze,wt.localize,Ke);if(fi.match(Ki))throw new RangeError("Format string contains an unescaped latin alphabet character `"+fi+"`");return ze}).join("");return ri}(c,p,this.options)},add:function(c,p,m){switch(m){case"millisecond":return W(c,p);case"second":return function(_,L){f(2,arguments);var K=h(L);return W(_,1e3*K)}(c,p);case"minute":return function(_,L){f(2,arguments);var K=h(L);return W(_,6e4*K)}(c,p);case"hour":return function(_,L){f(2,arguments);var K=h(L);return W(_,K*at)}(c,p);case"day":return I(c,p);case"week":return function(_,L){f(2,arguments);var K=h(L),gt=7*K;return I(_,gt)}(c,p);case"month":return X(c,p);case"quarter":return function(_,L){f(2,arguments);var K=h(L),gt=3*K;return X(_,gt)}(c,p);case"year":return function(_,L){f(2,arguments);var K=h(L);return X(_,12*K)}(c,p);default:return c}},diff:function(c,p,m){switch(m){case"millisecond":return Oe(c,p);case"second":return function(_,L){f(2,arguments);var K=Oe(_,L)/1e3;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"minute":return function(_,L){f(2,arguments);var K=Oe(_,L)/6e4;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"hour":return function(_,L){f(2,arguments);var K=Oe(_,L)/Ee;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"day":return _e(c,p);case"week":return function(_,L){f(2,arguments);var K=_e(_,L)/7;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"month":return Bt(c,p);case"quarter":return function(_,L){f(2,arguments);var K=Bt(_,L)/3;return K>0?Math.floor(K):Math.ceil(K)}(c,p);case"year":return function(_,L){f(2,arguments);var K=C(_),gt=C(L),wt=jt(K,gt),Mt=Math.abs(Ae(K,gt));K.setFullYear("1584"),gt.setFullYear("1584");var qt=jt(K,gt)===-wt,Gt=wt*(Mt-qt);return Gt===0?0:Gt}(c,p);default:return 0}},startOf:function(c,p,m){switch(p){case"second":return function(_){f(1,arguments);var L=C(_);return L.setMilliseconds(0),L}(c);case"minute":return function(_){f(1,arguments);var L=C(_);return L.setSeconds(0,0),L}(c);case"hour":return function(_){f(1,arguments);var L=C(_);return L.setMinutes(0,0,0),L}(c);case"day":return Ot(c);case"week":return q(c);case"isoWeek":return q(c,{weekStartsOn:+m});case"month":return function(_){f(1,arguments);var L=C(_);return L.setDate(1),L.setHours(0,0,0,0),L}(c);case"quarter":return function(_){f(1,arguments);var L=C(_),K=L.getMonth(),gt=K-K%3;return L.setMonth(gt,1),L.setHours(0,0,0,0),L}(c);case"year":return function(_){f(1,arguments);var L=C(_),K=new Date(0);return K.setFullYear(L.getFullYear(),0,1),K.setHours(0,0,0,0),K}(c);default:return c}},endOf:function(c,p){switch(p){case"second":return function(m){f(1,arguments);var _=C(m);return _.setMilliseconds(999),_}(c);case"minute":return function(m){f(1,arguments);var _=C(m);return _.setSeconds(59,999),_}(c);case"hour":return function(m){f(1,arguments);var _=C(m);return _.setMinutes(59,59,999),_}(c);case"day":return Ge(c);case"week":return function(m,_){f(1,arguments);var L=_||{},K=L.locale,gt=K&&K.options&&K.options.weekStartsOn,wt=gt==null?0:h(gt),Mt=L.weekStartsOn==null?wt:h(L.weekStartsOn);if(!(Mt>=0&&Mt<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var qt=C(m),Gt=qt.getDay(),Jt=6+(GtN&&N.enabled&&N.modifierKey,W=(N,J)=>N&&J[N+"Key"],at=(N,J)=>N&&!J[N+"Key"];function q(N,J,et){return N===void 0||(typeof N=="string"?N.indexOf(J)!==-1:typeof N=="function"&&N({chart:et}).indexOf(J)!==-1)}function Rt(N,J){return typeof N=="function"&&(N=N({chart:J})),typeof N=="string"?{x:N.indexOf("x")!==-1,y:N.indexOf("y")!==-1}:{x:!1,y:!1}}function Ot(N,J,et){let{mode:ot="xy",scaleMode:ut,overScaleMode:dt}=N||{},yt=function({x:zt,y:ce},re){let Ce=re.scales,fe=Object.keys(Ce);for(let xe=0;xe=Te.top&&ce<=Te.bottom&&zt>=Te.left&&zt<=Te.right)return Te}return null}(J,et),Pt=Rt(ot,et),Tt=Rt(ut,et);if(dt){let zt=Rt(dt,et);for(let ce of["x","y"])zt[ce]&&(Tt[ce]=Pt[ce],Pt[ce]=!1)}if(yt&&Tt[yt.axis])return[yt];let Ut=[];return f.each(et.scales,function(zt){Pt[zt.axis]&&Ut.push(zt)}),Ut}let ft=new WeakMap;function xt(N){let J=ft.get(N);return J||(J={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{}},ft.set(N,J)),J}function jt(N,J,et){let ot=N.max-N.min,ut=ot*(J-1),dt=N.isHorizontal()?et.x:et.y,yt=Math.max(0,Math.min(1,(N.getValueForPixel(dt)-N.min)/ot||0));return{min:ut*yt,max:ut*(1-yt)}}function te(N,J,et,ot,ut){let dt=et[ot];if(dt==="original"){let yt=N.originalScaleLimits[J.id][ot];dt=f.valueOrDefault(yt.options,yt.scale)}return f.valueOrDefault(dt,ut)}function ae(N,{min:J,max:et},ot,ut=!1){let dt=xt(N.chart),{id:yt,axis:Pt,options:Tt}=N,Ut=ot&&(ot[yt]||ot[Pt])||{},{minRange:zt=0}=Ut,ce=te(dt,N,Ut,"min",-1/0),re=te(dt,N,Ut,"max",1/0),Ce=ut?Math.max(et-J,zt):N.max-N.min,fe=(Ce-et+J)/2;return et+=fe,(J-=fe)re&&(et=re,J=Math.max(re-Ce,ce)),Tt.min=J,Tt.max=et,dt.updatedScaleLimits[N.id]={min:J,max:et},N.parse(J)!==N.min||N.parse(et)!==N.max}let Ae=N=>N===0||isNaN(N)?0:N<0?Math.min(Math.round(N),-1):Math.max(Math.round(N),1),ue={second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function _e(N,J,et,ot=!1){let{min:ut,max:dt,options:yt}=N,Pt=yt.time&&yt.time.round,Tt=ue[Pt]||0,Ut=N.getValueForPixel(N.getPixelForValue(ut+Tt)-J),zt=N.getValueForPixel(N.getPixelForValue(dt+Tt)-J),{min:ce=-1/0,max:re=1/0}=ot&&et&&et[N.axis]||{};return!!(isNaN(Ut)||isNaN(zt)||Utre)||ae(N,{min:Ut,max:zt},et,ot)}function Oe(N,J,et){return _e(N,J,et,!0)}let Ee={category:function(N,J,et,ot){let ut=jt(N,J,et);return N.min===N.max&&J<1&&function(dt){let yt=dt.getLabels().length-1;dt.min>0&&(dt.min-=1),dt.maxPt&&(ut=Math.max(0,ut-Tt),dt=yt===1?ut:ut+yt,Ut=ut===0),ae(N,{min:ut,max:dt},et)||Ut},default:_e,logarithmic:Oe,timeseries:Oe};function se(N,J){f.each(N,(et,ot)=>{J[ot]||delete N[ot]})}function Bt(N,J){let{scales:et}=N,{originalScaleLimits:ot,updatedScaleLimits:ut}=J;return f.each(et,function(dt){(function(yt,Pt,Tt){let{id:Ut,options:{min:zt,max:ce}}=yt;if(!Pt[Ut]||!Tt[Ut])return!0;let re=Tt[Ut];return re.min!==zt||re.max!==ce})(dt,ot,ut)&&(ot[dt.id]={min:{scale:dt.min,options:dt.options.min},max:{scale:dt.max,options:dt.options.max}})}),se(ot,et),se(ut,et),ot}function St(N,J,et,ot){let ut=Ee[N.type]||Ee.default;f.callback(ut,[N,J,et,ot])}function r(N,J,et,ot,ut){let dt=Ge[N.type]||Ge.default;f.callback(dt,[N,J,et,ot,ut])}function d(N){let J=N.chartArea;return{x:(J.left+J.right)/2,y:(J.top+J.bottom)/2}}function y(N,J,et="none"){let{x:ot=1,y:ut=1,focalPoint:dt=d(N)}=typeof J=="number"?{x:J,y:J}:J,yt=xt(N),{options:{limits:Pt,zoom:Tt}}=yt;Bt(N,yt);let Ut=ot!==1,zt=ut!==1,ce=Ot(Tt,dt,N);f.each(ce||N.scales,function(re){re.isHorizontal()&&Ut?St(re,ot,dt,Pt):!re.isHorizontal()&&zt&&St(re,ut,dt,Pt)}),N.update(et),f.callback(Tt.onZoom,[{chart:N}])}function v(N,J,et,ot="none"){let ut=xt(N),{options:{limits:dt,zoom:yt}}=ut,{mode:Pt="xy"}=yt;Bt(N,ut);let Tt=q(Pt,"x",N),Ut=q(Pt,"y",N);f.each(N.scales,function(zt){zt.isHorizontal()&&Tt?r(zt,J.x,et.x,dt):!zt.isHorizontal()&&Ut&&r(zt,J.y,et.y,dt)}),N.update(ot),f.callback(yt.onZoom,[{chart:N}])}function P(N){let J=xt(N),et=1,ot=1;return f.each(N.scales,function(ut){let dt=function(yt,Pt){let Tt=yt.originalScaleLimits[Pt];if(!Tt)return;let{min:Ut,max:zt}=Tt;return f.valueOrDefault(zt.options,zt.scale)-f.valueOrDefault(Ut.options,Ut.scale)}(J,ut.id);if(dt){let yt=Math.round(dt/(ut.max-ut.min)*100)/100;et=Math.min(et,yt),ot=Math.max(ot,yt)}}),et<1?et:ot}function F(N,J,et,ot){let{panDelta:ut}=ot,dt=ut[N.id]||0;f.sign(dt)===f.sign(J)&&(J+=dt);let yt=De[N.type]||De.default;f.callback(yt,[N,J,et])?ut[N.id]=0:ut[N.id]=J}function Y(N,J,et,ot="none"){let{x:ut=0,y:dt=0}=typeof J=="number"?{x:J,y:J}:J,yt=xt(N),{options:{pan:Pt,limits:Tt}}=yt,{onPan:Ut}=Pt||{};Bt(N,yt);let zt=ut!==0,ce=dt!==0;f.each(et||N.scales,function(re){re.isHorizontal()&&zt?F(re,ut,Tt,yt):!re.isHorizontal()&&ce&&F(re,dt,Tt,yt)}),N.update(ot),f.callback(Ut,[{chart:N}])}function nt(N){let J=xt(N);Bt(N,J);let et={};for(let ot of Object.keys(N.scales)){let{min:ut,max:dt}=J.originalScaleLimits[ot]||{min:{},max:{}};et[ot]={min:ut.scale,max:dt.scale}}return et}function V(N,J){let{handlers:et}=xt(N),ot=et[J];ot&&ot.target&&(ot.target.removeEventListener(J,ot),delete et[J])}function it(N,J,et,ot){let{handlers:ut,options:dt}=xt(N),yt=ut[et];yt&&yt.target===J||(V(N,et),ut[et]=Pt=>ot(N,Pt,dt),ut[et].target=J,J.addEventListener(et,ut[et]))}function kt(N,J){let et=xt(N);et.dragStart&&(et.dragging=!0,et.dragEnd=J,N.update("none"))}function Et(N,J){let et=xt(N);et.dragStart&&J.key==="Escape"&&(V(N,"keydown"),et.dragging=!1,et.dragStart=et.dragEnd=null,N.update("none"))}function ie(N,J,et){let{onZoomStart:ot,onZoomRejected:ut}=et;if(ot){let dt=f.getRelativePosition(J,N);if(f.callback(ot,[{chart:N,event:J,point:dt}])===!1)return f.callback(ut,[{chart:N,event:J}]),!1}}function Le(N,J){let et=xt(N),{pan:ot,zoom:ut={}}=et.options;if(J.button!==0||W(X(ot),J)||at(X(ut.drag),J))return f.callback(ut.onZoomRejected,[{chart:N,event:J}]);ie(N,J,ut)!==!1&&(et.dragStart=J,it(N,N.canvas,"mousemove",kt),it(N,window.document,"keydown",Et))}function ii(N,J,et,ot){let ut=q(J,"x",N),dt=q(J,"y",N),{top:yt,left:Pt,right:Tt,bottom:Ut,width:zt,height:ce}=N.chartArea,re=f.getRelativePosition(et,N),Ce=f.getRelativePosition(ot,N);ut&&(Pt=Math.min(re.x,Ce.x),Tt=Math.max(re.x,Ce.x)),dt&&(yt=Math.min(re.y,Ce.y),Ut=Math.max(re.y,Ce.y));let fe=Tt-Pt,xe=Ut-yt;return{left:Pt,top:yt,right:Tt,bottom:Ut,width:fe,height:xe,zoomX:ut&&fe?1+(zt-fe)/zt:1,zoomY:dt&&xe?1+(ce-xe)/ce:1}}function Re(N,J){let et=xt(N);if(!et.dragStart)return;V(N,"mousemove");let{mode:ot,onZoomComplete:ut,drag:{threshold:dt=0}}=et.options.zoom,yt=ii(N,ot,et.dragStart,J),Pt=q(ot,"x",N)?yt.width:0,Tt=q(ot,"y",N)?yt.height:0,Ut=Math.sqrt(Pt*Pt+Tt*Tt);if(et.dragStart=et.dragEnd=null,Ut<=dt)return et.dragging=!1,void N.update("none");v(N,{x:yt.left,y:yt.top},{x:yt.right,y:yt.bottom},"zoom"),setTimeout(()=>et.dragging=!1,500),f.callback(ut,[{chart:N}])}function We(N,J){let{handlers:{onZoomComplete:et},options:{zoom:ot}}=xt(N);if(!function(yt,Pt,Tt){if(at(X(Tt.wheel),Pt))f.callback(Tt.onZoomRejected,[{chart:yt,event:Pt}]);else if(ie(yt,Pt,Tt)!==!1&&(Pt.cancelable&&Pt.preventDefault(),Pt.deltaY!==void 0))return!0}(N,J,ot))return;let ut=J.target.getBoundingClientRect(),dt=1+(J.deltaY>=0?-ot.wheel.speed:ot.wheel.speed);y(N,{x:dt,y:dt,focalPoint:{x:J.clientX-ut.left,y:J.clientY-ut.top}}),et&&et()}function Je(N,J,et,ot){et&&(xt(N).handlers[J]=function(ut,dt){let yt;return function(){return clearTimeout(yt),yt=setTimeout(ut,dt),dt}}(()=>f.callback(et,[{chart:N}]),ot))}function Ie(N,J){return function(et,ot){let{pan:ut,zoom:dt={}}=J.options;if(!ut||!ut.enabled)return!1;let yt=ot&&ot.srcEvent;return!yt||!(!J.panning&&ot.pointerType==="mouse"&&(at(X(ut),yt)||W(X(dt.drag),yt)))||(f.callback(ut.onPanRejected,[{chart:N,event:ot}]),!1)}}function ti(N,J,et){if(J.scale){let{center:ot,pointers:ut}=et,dt=1/J.scale*et.scale,yt=et.target.getBoundingClientRect(),Pt=function(Ut,zt){let ce=Math.abs(Ut.clientX-zt.clientX),re=Math.abs(Ut.clientY-zt.clientY),Ce=ce/re,fe,xe;return Ce>.3&&Ce<1.7?fe=xe=!0:ce>re?fe=!0:xe=!0,{x:fe,y:xe}}(ut[0],ut[1]),Tt=J.options.zoom.mode;y(N,{x:Pt.x&&q(Tt,"x",N)?dt:1,y:Pt.y&&q(Tt,"y",N)?dt:1,focalPoint:{x:ot.x-yt.left,y:ot.y-yt.top}}),J.scale=et.scale}}function Ne(N,J,et){let ot=J.delta;ot&&(J.panning=!0,Y(N,{x:et.deltaX-ot.x,y:et.deltaY-ot.y},J.panScales),J.delta={x:et.deltaX,y:et.deltaY})}let si=new WeakMap;function wi(N,J){let et=xt(N),ot=N.canvas,{pan:ut,zoom:dt}=J,yt=new I.default.Manager(ot);dt&&dt.pinch.enabled&&(yt.add(new I.default.Pinch),yt.on("pinchstart",()=>function(Pt,Tt){Tt.options.zoom.pinch.enabled&&(Tt.scale=1)}(0,et)),yt.on("pinch",Pt=>ti(N,et,Pt)),yt.on("pinchend",Pt=>function(Tt,Ut,zt){Ut.scale&&(ti(Tt,Ut,zt),Ut.scale=null,f.callback(Ut.options.zoom.onZoomComplete,[{chart:Tt}]))}(N,et,Pt))),ut&&ut.enabled&&(yt.add(new I.default.Pan({threshold:ut.threshold,enable:Ie(N,et)})),yt.on("panstart",Pt=>function(Tt,Ut,zt){let{enabled:ce,onPanStart:re,onPanRejected:Ce}=Ut.options.pan;if(!ce)return;let fe=zt.target.getBoundingClientRect(),xe={x:zt.center.x-fe.left,y:zt.center.y-fe.top};if(f.callback(re,[{chart:Tt,event:zt,point:xe}])===!1)return f.callback(Ce,[{chart:Tt,event:zt}]);Ut.panScales=Ot(Ut.options.pan,xe,Tt),Ut.delta={x:0,y:0},clearTimeout(Ut.panEndTimeout),Ne(Tt,Ut,zt)}(N,et,Pt)),yt.on("panmove",Pt=>Ne(N,et,Pt)),yt.on("panend",()=>function(Pt,Tt){Tt.delta=null,Tt.panning&&(Tt.panEndTimeout=setTimeout(()=>Tt.panning=!1,500),f.callback(Tt.options.pan.onPanComplete,[{chart:Pt}]))}(N,et))),si.set(N,yt)}function Di(N,J,et){let ot=et.zoom.drag,{dragStart:ut,dragEnd:dt}=xt(N);if(ot.drawTime!==J||!dt)return;let{left:yt,top:Pt,width:Tt,height:Ut}=ii(N,et.zoom.mode,ut,dt),zt=N.ctx;zt.save(),zt.beginPath(),zt.fillStyle=ot.backgroundColor||"rgba(225,225,225,0.3)",zt.fillRect(yt,Pt,Tt,Ut),ot.borderWidth>0&&(zt.lineWidth=ot.borderWidth,zt.strokeStyle=ot.borderColor||"rgba(225,225,225)",zt.strokeRect(yt,Pt,Tt,Ut)),zt.restore()}var ve={id:"zoom",version:"2.0.1",defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(N,J,et){xt(N).options=et,Object.prototype.hasOwnProperty.call(et.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(et.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(et.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),I.default&&wi(N,et),N.pan=(ot,ut,dt)=>Y(N,ot,ut,dt),N.zoom=(ot,ut)=>y(N,ot,ut),N.zoomRect=(ot,ut,dt)=>v(N,ot,ut,dt),N.zoomScale=(ot,ut,dt)=>function(yt,Pt,Tt,Ut="none"){Bt(yt,xt(yt)),ae(yt.scales[Pt],Tt,void 0,!0),yt.update(Ut)}(N,ot,ut,dt),N.resetZoom=ot=>function(ut,dt="default"){let yt=xt(ut),Pt=Bt(ut,yt);f.each(ut.scales,function(Tt){let Ut=Tt.options;Pt[Tt.id]?(Ut.min=Pt[Tt.id].min.options,Ut.max=Pt[Tt.id].max.options):(delete Ut.min,delete Ut.max)}),ut.update(dt),f.callback(yt.options.zoom.onZoomComplete,[{chart:ut}])}(N,ot),N.getZoomLevel=()=>P(N),N.getInitialScaleBounds=()=>nt(N),N.isZoomedOrPanned=()=>function(ot){let ut=nt(ot);for(let dt of Object.keys(ot.scales)){let{min:yt,max:Pt}=ut[dt];if(yt!==void 0&&ot.scales[dt].min!==yt||Pt!==void 0&&ot.scales[dt].max!==Pt)return!0}return!1}(N)},beforeEvent(N){let J=xt(N);if(J.panning||J.dragging)return!1},beforeUpdate:function(N,J,et){xt(N).options=et,function(ot,ut){let dt=ot.canvas,{wheel:yt,drag:Pt,onZoomComplete:Tt}=ut.zoom;yt.enabled?(it(ot,dt,"wheel",We),Je(ot,"onZoomComplete",Tt,250)):V(ot,"wheel"),Pt.enabled?(it(ot,dt,"mousedown",Le),it(ot,dt.ownerDocument,"mouseup",Re)):(V(ot,"mousedown"),V(ot,"mousemove"),V(ot,"mouseup"),V(ot,"keydown"))}(N,et)},beforeDatasetsDraw(N,J,et){Di(N,"beforeDatasetsDraw",et)},afterDatasetsDraw(N,J,et){Di(N,"afterDatasetsDraw",et)},beforeDraw(N,J,et){Di(N,"beforeDraw",et)},afterDraw(N,J,et){Di(N,"afterDraw",et)},stop:function(N){(function(J){V(J,"mousedown"),V(J,"mousemove"),V(J,"mouseup"),V(J,"wheel"),V(J,"click"),V(J,"keydown")})(N),I.default&&function(J){let et=si.get(J);et&&(et.remove("pinchstart"),et.remove("pinch"),et.remove("pinchend"),et.remove("panstart"),et.remove("pan"),et.remove("panend"),et.destroy(),si.delete(J))}(N),function(J){ft.delete(J)}(N)},panFunctions:De,zoomFunctions:Ee,zoomRectFunctions:Ge};return D.Chart.register(ve),ve});(function(D,h){typeof exports=="object"&&typeof module<"u"?module.exports=h(ys("chart.js"),ys("chart.js/helpers")):typeof define=="function"&&define.amd?define(["chart.js","chart.js/helpers"],h):(D=typeof globalThis<"u"?globalThis:D||self)["chartjs-plugin-annotation"]=h(D.Chart,D.Chart.helpers)})(void 0,function(D,h){"use strict";let f={modes:{point:(E,M)=>I(E,M,{intersect:!0}),nearest:(E,M,z)=>function(H,j,U){let G=Number.POSITIVE_INFINITY;return I(H,j,U).reduce((rt,ct)=>{let st=ct.getCenterPoint(),pt=function(vt,Lt,Ht){return Ht==="x"?{x:vt.x,y:Lt.y}:Ht==="y"?{x:Lt.x,y:vt.y}:Lt}(j,st,U.axis),lt=h.distanceBetweenPoints(j,pt);return ltrt._index-ct._index).slice(0,1)}(E,M,z),x:(E,M,z)=>I(E,M,{intersect:z.intersect,axis:"x"}),y:(E,M,z)=>I(E,M,{intersect:z.intersect,axis:"y"})}};function C(E,M,z){return(f.modes[z.mode]||f.modes.nearest)(E,M,z)}function I(E,M,z){return E.visibleElements.filter(H=>z.intersect?H.inRange(M.x,M.y):function(j,U,G){return G!=="x"&&G!=="y"?j.inRange(U.x,U.y,"x",!0)||j.inRange(U.x,U.y,"y",!0):j.inRange(U.x,U.y,G,!0)}(H,M,z.axis))}let X=(E,M)=>M>E||E.length>M.length&&E.slice(0,M.length)===M,W=.001,at=(E,M,z)=>Math.min(z,Math.max(M,E));function q(E,M,z){for(let H of Object.keys(E))E[H]=at(E[H],M,z);return E}function Rt(E,{x:M,y:z,x2:H,y2:j},U,G){let rt=G/2,ct=E.x>=M-rt-W&&E.x<=H+rt+W,st=E.y>=z-rt-W&&E.y<=j+rt+W;return U==="x"?ct:(U==="y"||ct)&&st}function Ot(E,M){let{centerX:z,centerY:H}=E.getProps(["centerX","centerY"],M);return{x:z,y:H}}let ft=E=>typeof E=="string"&&E.endsWith("%"),xt=E=>parseFloat(E)/100,jt=E=>at(xt(E),0,1),te=(E,M)=>({x:E,y:M,x2:E,y2:M,width:0,height:0}),ae={box:E=>te(E.centerX,E.centerY),ellipse:E=>({centerX:E.centerX,centerY:E.centerX,radius:0,width:0,height:0}),label:E=>te(E.centerX,E.centerY),line:E=>te(E.x,E.y),point:E=>({centerX:E.centerX,centerY:E.centerY,radius:0,width:0,height:0}),polygon:E=>te(E.centerX,E.centerY)};function Ae(E,M){return M==="start"?0:M==="end"?E:ft(M)?jt(M)*E:E/2}function ue(E,M,z=!0){return typeof M=="number"?M:ft(M)?(z?jt(M):xt(M))*E:E}function _e(E,M="center"){return h.isObject(E)?{x:h.valueOrDefault(E.x,M),y:h.valueOrDefault(E.y,M)}:{x:E=h.valueOrDefault(E,M),y:E}}function Oe(E){return E&&(h.defined(E.xValue)||h.defined(E.yValue))}function Ee(E,M,z){let H=z.init;if(H)return H===!0?De(M,z):function(j,U,G){let rt=h.callback(G.init,[{chart:j,properties:U,options:G}]);if(rt===!0)return De(U,G);if(h.isObject(rt))return rt}(E,M,z)}function Ge(E,M,z){let H=!1;return M.forEach(j=>{h.isFunction(E[j])?(H=!0,z[j]=E[j]):h.defined(z[j])&&delete z[j]}),H}function De(E,M){let z=M.type||"line";return ae[z](E)}let se=new Map,Bt=E=>isNaN(E)||E<=0,St=E=>E.reduce(function(M,z){return M+=z.string},"");function r(E){if(E&&typeof E=="object"){let M=E.toString();return M==="[object HTMLImageElement]"||M==="[object HTMLCanvasElement]"}}function d(E,{x:M,y:z},H){H&&(E.translate(M,z),E.rotate(h.toRadians(H)),E.translate(-M,-z))}function y(E,M){if(M&&M.borderWidth)return E.lineCap=M.borderCapStyle,E.setLineDash(M.borderDash),E.lineDashOffset=M.borderDashOffset,E.lineJoin=M.borderJoinStyle,E.lineWidth=M.borderWidth,E.strokeStyle=M.borderColor,!0}function v(E,M){E.shadowColor=M.backgroundShadowColor,E.shadowBlur=M.shadowBlur,E.shadowOffsetX=M.shadowOffsetX,E.shadowOffsetY=M.shadowOffsetY}function P(E,M){let z=M.content;if(r(z))return{width:ue(z.width,M.width),height:ue(z.height,M.height)};let H=M.font,j=h.isArray(H)?H.map(ct=>h.toFont(ct)):[h.toFont(H)],U=M.textStrokeWidth,G=h.isArray(z)?z:[z],rt=G.join()+St(j)+U+(E._measureText?"-spriting":"");return se.has(rt)||se.set(rt,function(ct,st,pt,lt){ct.save();let vt=st.length,Lt=0,Ht=lt;for(let _t=0;_th.toFont(lt)):[h.toFont(U)],rt=z.color,ct=h.isArray(rt)?rt:[rt],st=function(lt,vt){let{x:Lt,width:Ht}=lt,_t=vt.textAlign;return _t==="center"?Lt+Ht/2:_t==="end"||_t==="right"?Lt+Ht:Lt}(M,z),pt=M.y+z.textStrokeWidth/2;E.save(),E.textBaseline="middle",E.textAlign=z.textAlign,function(lt,vt){if(vt.textStrokeWidth>0)return lt.lineJoin="round",lt.miterLimit=2,lt.lineWidth=vt.textStrokeWidth,lt.strokeStyle=vt.textStrokeColor,!0}(E,z)&&function(lt,{x:vt,y:Lt},Ht,_t){lt.beginPath();let bt=0;Ht.forEach(function(Dt,Yt){let Qt=_t[Math.min(Yt,_t.length-1)],oe=Qt.lineHeight;lt.font=Qt.string,lt.strokeText(Dt,vt,Lt+oe/2+bt),bt+=oe}),lt.stroke()}(E,{x:st,y:pt},j,G),function(lt,{x:vt,y:Lt},Ht,{fonts:_t,colors:bt}){let Dt=0;Ht.forEach(function(Yt,Qt){let oe=bt[Math.min(Qt,bt.length-1)],de=_t[Math.min(Qt,_t.length-1)],le=de.lineHeight;lt.beginPath(),lt.font=de.string,lt.fillStyle=oe,lt.fillText(Yt,vt,Lt+le/2+Dt),Dt+=le,lt.fill()})}(E,{x:st,y:pt},j,{fonts:G,colors:ct}),E.restore()}function nt(E,M,z,H){let{radius:j,options:U}=M,G=U.pointStyle,rt=U.rotation,ct=(rt||0)*h.RAD_PER_DEG;if(r(G))return E.save(),E.translate(z,H),E.rotate(ct),E.drawImage(G,-G.width/2,-G.height/2,G.width,G.height),void E.restore();Bt(j)||function(st,{x:pt,y:lt,radius:vt,rotation:Lt,style:Ht,rad:_t}){let bt,Dt,Yt,Qt;switch(st.beginPath(),Ht){default:st.arc(pt,lt,vt,0,h.TAU),st.closePath();break;case"triangle":st.moveTo(pt+Math.sin(_t)*vt,lt-Math.cos(_t)*vt),_t+=h.TWO_THIRDS_PI,st.lineTo(pt+Math.sin(_t)*vt,lt-Math.cos(_t)*vt),_t+=h.TWO_THIRDS_PI,st.lineTo(pt+Math.sin(_t)*vt,lt-Math.cos(_t)*vt),st.closePath();break;case"rectRounded":Qt=.516*vt,Yt=vt-Qt,bt=Math.cos(_t+h.QUARTER_PI)*Yt,Dt=Math.sin(_t+h.QUARTER_PI)*Yt,st.arc(pt-bt,lt-Dt,Qt,_t-h.PI,_t-h.HALF_PI),st.arc(pt+Dt,lt-bt,Qt,_t-h.HALF_PI,_t),st.arc(pt+bt,lt+Dt,Qt,_t,_t+h.HALF_PI),st.arc(pt-Dt,lt+bt,Qt,_t+h.HALF_PI,_t+h.PI),st.closePath();break;case"rect":if(!Lt){Yt=Math.SQRT1_2*vt,st.rect(pt-Yt,lt-Yt,2*Yt,2*Yt);break}_t+=h.QUARTER_PI;case"rectRot":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+Dt,lt-bt),st.lineTo(pt+bt,lt+Dt),st.lineTo(pt-Dt,lt+bt),st.closePath();break;case"crossRot":_t+=h.QUARTER_PI;case"cross":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt),st.moveTo(pt+Dt,lt-bt),st.lineTo(pt-Dt,lt+bt);break;case"star":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt),st.moveTo(pt+Dt,lt-bt),st.lineTo(pt-Dt,lt+bt),_t+=h.QUARTER_PI,bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt),st.moveTo(pt+Dt,lt-bt),st.lineTo(pt-Dt,lt+bt);break;case"line":bt=Math.cos(_t)*vt,Dt=Math.sin(_t)*vt,st.moveTo(pt-bt,lt-Dt),st.lineTo(pt+bt,lt+Dt);break;case"dash":st.moveTo(pt,lt),st.lineTo(pt+Math.cos(_t)*vt,lt+Math.sin(_t)*vt)}st.fill()}(E,{x:z,y:H,radius:j,rotation:rt,style:G,rad:ct})}let V={xScaleID:{min:"xMin",max:"xMax",start:"left",end:"right",startProp:"x",endProp:"x2"},yScaleID:{min:"yMin",max:"yMax",start:"bottom",end:"top",startProp:"y",endProp:"y2"}};function it(E,M,z){return M=typeof M=="number"?M:E.parse(M),h.isFinite(M)?E.getPixelForValue(M):z}function kt(E,M,z){let H=M[z];if(H||z==="scaleID")return H;let j=z.charAt(0),U=Object.values(E).filter(G=>G.axis&&G.axis===j);return U.length?U[0].id:j}function Et(E,M){if(E){let z=E.options.reverse;return{start:it(E,M.min,z?M.end:M.start),end:it(E,M.max,z?M.start:M.end)}}}function ie(E,M){let{chartArea:z,scales:H}=E,j=H[kt(H,M,"xScaleID")],U=H[kt(H,M,"yScaleID")],G=z.width/2,rt=z.height/2;return j&&(G=it(j,M.xValue,j.left+j.width/2)),U&&(rt=it(U,M.yValue,U.top+U.height/2)),{x:G,y:rt}}function Le(E,M){let z=E.scales,H=z[kt(z,M,"xScaleID")],j=z[kt(z,M,"yScaleID")];if(!H&&!j)return{};let{left:U,right:G}=H||E.chartArea,{top:rt,bottom:ct}=j||E.chartArea,st=Je(H,{min:M.xMin,max:M.xMax,start:U,end:G});U=st.start,G=st.end;let pt=Je(j,{min:M.yMin,max:M.yMax,start:ct,end:rt});return rt=pt.start,ct=pt.end,{x:U,y:rt,x2:G,y2:ct,width:G-U,height:ct-rt,centerX:U+(G-U)/2,centerY:rt+(ct-rt)/2}}function ii(E,M){if(!Oe(M)){let z=Le(E,M),H=M.radius;H&&!isNaN(H)||(H=Math.min(z.width,z.height)/2,M.radius=H);let j=2*H,U=z.centerX+M.xAdjust,G=z.centerY+M.yAdjust;return{x:U-H,y:G-H,x2:U+H,y2:G+H,centerX:U,centerY:G,width:j,height:j,radius:H}}return function(z,H){let j=ie(z,H),U=2*H.radius;return{x:j.x-H.radius+H.xAdjust,y:j.y-H.radius+H.yAdjust,x2:j.x+H.radius+H.xAdjust,y2:j.y+H.radius+H.yAdjust,centerX:j.x+H.xAdjust,centerY:j.y+H.yAdjust,radius:H.radius,width:U,height:U}}(E,M)}function Re(E,M){let{scales:z,chartArea:H}=E,j=z[M.scaleID],U={x:H.left,y:H.top,x2:H.right,y2:H.bottom};return j?function(G,rt,ct){let st=it(G,ct.value,NaN),pt=it(G,ct.endValue,st);G.isHorizontal()?(rt.x=st,rt.x2=pt):(rt.y=st,rt.y2=pt)}(j,U,M):function(G,rt,ct){for(let st of Object.keys(V)){let pt=G[kt(G,ct,st)];if(pt){let{min:lt,max:vt,start:Lt,end:Ht,startProp:_t,endProp:bt}=V[st],Dt=Et(pt,{min:ct[lt],max:ct[vt],start:pt[Lt],end:pt[Ht]});rt[_t]=Dt.start,rt[bt]=Dt.end}}}(z,U,M),U}function We(E,M){let z=Le(E,M);return z.initProperties=Ee(E,z,M),z.elements=[{type:"label",optionScope:"label",properties:ti(E,z,M),initProperties:z.initProperties}],z}function Je(E,M){let z=Et(E,M)||M;return{start:Math.min(z.start,z.end),end:Math.max(z.start,z.end)}}function Ie(E,M){let{start:z,end:H,borderWidth:j}=E,{position:U,padding:{start:G,end:rt},adjust:ct}=M;return z+j/2+ct+Ae(H-j-z-G-rt-M.size,U)}function ti(E,M,z){let H=z.label;H.backgroundColor="transparent",H.callout.display=!1;let j=_e(H.position),U=h.toPadding(H.padding),G=P(E.ctx,H),rt=function({properties:lt,options:vt},Lt,Ht,_t){let{x:bt,x2:Dt,width:Yt}=lt;return Ie({start:bt,end:Dt,size:Yt,borderWidth:vt.borderWidth},{position:Ht.x,padding:{start:_t.left,end:_t.right},adjust:vt.label.xAdjust,size:Lt.width})}({properties:M,options:z},G,j,U),ct=function({properties:lt,options:vt},Lt,Ht,_t){let{y:bt,y2:Dt,height:Yt}=lt;return Ie({start:bt,end:Dt,size:Yt,borderWidth:vt.borderWidth},{position:Ht.y,padding:{start:_t.top,end:_t.bottom},adjust:vt.label.yAdjust,size:Lt.height})}({properties:M,options:z},G,j,U),st=G.width+U.width,pt=G.height+U.height;return{x:rt,y:ct,x2:rt+st,y2:ct+pt,width:st,height:pt,centerX:rt+st/2,centerY:ct+pt/2,rotation:H.rotation}}function Ne(E,M,z){let H=Math.cos(z),j=Math.sin(z),U=M.x,G=M.y;return{x:U+H*(E.x-U)-j*(E.y-G),y:G+j*(E.x-U)+H*(E.y-G)}}let si=["enter","leave"],wi=si.concat("click");function Di(E,M,z){if(E.listened)switch(M.type){case"mousemove":case"mouseout":return function(H,j,U){if(!H.moveListened)return;let G;G=j.type==="mousemove"?C(H,j,U.interaction):[];let rt=H.hovered;H.hovered=G;let ct={state:H,event:j},st=ve(ct,"leave",rt,G);return ve(ct,"enter",G,rt)||st}(E,M,z);case"click":return function(H,j,U){let G=H.listeners,rt=C(H,j,U.interaction),ct;for(let st of rt)ct=N(st.options.click||G.click,st,j)||ct;return ct}(E,M,z)}}function ve({state:E,event:M},z,H,j){let U;for(let G of H)j.indexOf(G)<0&&(U=N(G.options[z]||E.listeners[z],G,M)||U);return U}function N(E,M,z){return h.callback(E,[M.$context,z])===!0}let J=["afterDraw","beforeDraw"];function et(E,M,z){if(E.hooked){let H=M.options[z]||E.hooks[z];return h.callback(H,[M.$context])}}function ot(E,M,z){let H=function(U,G,rt){let ct=G.axis,st=G.id,pt=ct+"ScaleID",lt={min:h.valueOrDefault(G.min,Number.NEGATIVE_INFINITY),max:h.valueOrDefault(G.max,Number.POSITIVE_INFINITY)};for(let vt of rt)vt.scaleID===st?Pt(vt,G,["value","endValue"],lt):kt(U,vt,pt)===st&&Pt(vt,G,[ct+"Min",ct+"Max",ct+"Value"],lt);return lt}(E.scales,M,z),j=ut(M,H,"min","suggestedMin");j=ut(M,H,"max","suggestedMax")||j,j&&h.isFunction(M.handleTickRangeOptions)&&M.handleTickRangeOptions()}function ut(E,M,z,H){if(h.isFinite(M[z])&&!function(j,U,G){return h.defined(j[U])||h.defined(j[G])}(E.options,z,H)){let j=E[z]!==M[z];return E[z]=M[z],j}}function dt(E,M){for(let z of["scaleID","xScaleID","yScaleID"]){let H=kt(M,E,z);H&&!M[H]&&yt(E,z)&&console.warn(`No scale found with id '${H}' for annotation '${E.id}'`)}}function yt(E,M){if(M==="scaleID")return!0;let z=M.charAt(0);for(let H of["Min","Max","Value"])if(h.defined(E[z+H]))return!0;return!1}function Pt(E,M,z,H){for(let j of z){let U=E[j];if(h.defined(U)){let G=M.parse(U);H.min=Math.min(H.min,G),H.max=Math.max(H.max,G)}}}class Tt extends D.Element{inRange(M,z,H,j){let{x:U,y:G}=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-this.options.rotation));return Rt({x:U,y:G},this.getProps(["x","y","x2","y2"],j),H,this.options.borderWidth)}getCenterPoint(M){return Ot(this,M)}draw(M){M.save(),d(M,this.getCenterPoint(),this.options.rotation),F(M,this,this.options),M.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(M,z){return We(M,z)}}Tt.id="boxAnnotation",Tt.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,label:{backgroundColor:"transparent",borderWidth:0,callout:{display:!1},color:"black",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,opacity:void 0,padding:6,position:"center",rotation:void 0,textAlign:"start",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Tt.defaultRoutes={borderColor:"color",backgroundColor:"color"},Tt.descriptors={label:{_fallback:!0}};let Ut=["left","bottom","top","right"];class zt extends D.Element{inRange(M,z,H,j){let{x:U,y:G}=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-this.rotation));return Rt({x:U,y:G},this.getProps(["x","y","x2","y2"],j),H,this.options.borderWidth)}getCenterPoint(M){return Ot(this,M)}draw(M){let z=this.options,H=!h.defined(this._visible)||this._visible;z.display&&z.content&&H&&(M.save(),d(M,this.getCenterPoint(),this.rotation),function(j,U){let{pointX:G,pointY:rt,options:ct}=U,st=ct.callout,pt=st&&st.display&&function(Dt,Yt){let Qt=Yt.position;return Ut.includes(Qt)?Qt:function(oe,de){let{x:le,y:Zt,x2:Me,y2:me,width:Pe,height:S,pointX:O,pointY:B,centerX:c,centerY:p,rotation:m}=oe,_={x:c,y:p},L=de.start,K=ue(Pe,L),gt=ue(S,L),wt=[le,le+K,le+K,Me],Mt=[Zt+gt,me,Zt,me],qt=[];for(let Gt=0;Gt<4;Gt++){let Jt=Ne({x:wt[Gt],y:Mt[Gt]},_,h.toRadians(m));qt.push({position:Ut[Gt],distance:h.distanceBetweenPoints(Jt,{x:O,y:B})})}return qt.sort((Gt,Jt)=>Gt.distance-Jt.distance)[0].position}(Dt,Yt)}(U,st);if(!pt||function(Dt,Yt,Qt){let{pointX:oe,pointY:de}=Dt,le=Yt.margin,Zt=oe,Me=de;return Qt==="left"?Zt+=le:Qt==="right"?Zt-=le:Qt==="top"?Me+=le:Qt==="bottom"&&(Me-=le),Dt.inRange(Zt,Me)}(U,st,pt))return;if(j.save(),j.beginPath(),!y(j,st))return j.restore();let{separatorStart:vt,separatorEnd:Lt}=function(Dt,Yt){let{x:Qt,y:oe,x2:de,y2:le}=Dt,Zt=function(Pe,S){let{width:O,height:B,options:c}=Pe,p=c.callout.margin+c.borderWidth/2;return S==="right"?O+p:S==="bottom"?B+p:-p}(Dt,Yt),Me,me;return Yt==="left"||Yt==="right"?(Me={x:Qt+Zt,y:oe},me={x:Me.x,y:le}):(Me={x:Qt,y:oe+Zt},me={x:de,y:Me.y}),{separatorStart:Me,separatorEnd:me}}(U,pt),{sideStart:Ht,sideEnd:_t}=function(Dt,Yt,Qt){let{y:oe,width:de,height:le,options:Zt}=Dt,Me=Zt.callout.start,me=function(O,B){let c=B.side;return O==="left"||O==="top"?-c:c}(Yt,Zt.callout),Pe,S;return Yt==="left"||Yt==="right"?(Pe={x:Qt.x,y:oe+ue(le,Me)},S={x:Pe.x+me,y:Pe.y}):(Pe={x:Qt.x+ue(de,Me),y:Qt.y},S={x:Pe.x,y:Pe.y+me}),{sideStart:Pe,sideEnd:S}}(U,pt,vt);(st.margin>0||ct.borderWidth===0)&&(j.moveTo(vt.x,vt.y),j.lineTo(Lt.x,Lt.y)),j.moveTo(Ht.x,Ht.y),j.lineTo(_t.x,_t.y);let bt=Ne({x:G,y:rt},U.getCenterPoint(),h.toRadians(-U.rotation));j.lineTo(bt.x,bt.y),j.stroke(),j.restore()}(M,this),F(M,this,z),Y(M,function({x:j,y:U,width:G,height:rt,options:ct}){let st=ct.borderWidth/2,pt=h.toPadding(ct.padding);return{x:j+pt.left+st,y:U+pt.top+st,width:G-pt.left-pt.right-ct.borderWidth,height:rt-pt.top-pt.bottom-ct.borderWidth}}(this),z),M.restore())}resolveElementProperties(M,z){let H;if(Oe(z))H=ie(M,z);else{let{centerX:G,centerY:rt}=Le(M,z);H={x:G,y:rt}}let j=h.toPadding(z.padding),U=function(G,rt,ct,st){let pt=rt.width+st.width+ct.borderWidth,lt=rt.height+st.height+ct.borderWidth,vt=_e(ct.position,"center"),Lt=ce(G.x,pt,ct.xAdjust,vt.x),Ht=ce(G.y,lt,ct.yAdjust,vt.y);return{x:Lt,y:Ht,x2:Lt+pt,y2:Ht+lt,width:pt,height:lt,centerX:Lt+pt/2,centerY:Ht+lt/2}}(H,P(M.ctx,z),z,j);return{initProperties:Ee(M,U,z),pointX:H.x,pointY:H.y,...U,rotation:z.rotation}}}function ce(E,M,z=0,H){return E-Ae(M,H)+z}zt.id="labelAnnotation",zt.defaults={adjustScaleRange:!0,backgroundColor:"transparent",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:0,borderShadowColor:"transparent",borderWidth:0,callout:{borderCapStyle:"butt",borderColor:void 0,borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:1,display:!1,margin:5,position:"auto",side:5,start:"50%"},color:"black",content:null,display:!0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:void 0},height:void 0,init:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},zt.defaultRoutes={borderColor:"color"};let re=(E,M,z)=>({x:E.x+z*(M.x-E.x),y:E.y+z*(M.y-E.y)}),Ce=(E,M,z)=>re(M,z,Math.abs((E-M.y)/(z.y-M.y))).x,fe=(E,M,z)=>re(M,z,Math.abs((E-M.x)/(z.x-M.x))).y,xe=E=>E*E,Te=(E,M,{x:z,y:H,x2:j,y2:U},G)=>G==="y"?{start:Math.min(H,U),end:Math.max(H,U),value:M}:{start:Math.min(z,j),end:Math.max(z,j),value:E},rs=(E,M,z,H)=>(1-H)*(1-H)*E+2*(1-H)*H*M+H*H*z,ci=(E,M,z,H)=>({x:rs(E.x,M.x,z.x,H),y:rs(E.y,M.y,z.y,H)}),di=(E,M,z,H)=>2*(1-H)*(M-E)+2*H*(z-M),Ki=(E,M,z,H)=>-Math.atan2(di(E.x,M.x,z.x,H),di(E.y,M.y,z.y,H))+.5*h.PI;class Be extends D.Element{inRange(M,z,H,j){let U=this.options.borderWidth/2;if(H!=="x"&&H!=="y"){let G={mouseX:M,mouseY:z},{path:rt,ctx:ct}=this;if(rt){y(ct,this.options);let{chart:st}=this.$context,pt=M*st.currentDevicePixelRatio,lt=z*st.currentDevicePixelRatio,vt=ct.isPointInStroke(rt,pt,lt)||_i(this,G,j);return ct.restore(),vt}return function(st,{mouseX:pt,mouseY:lt},vt=W,Lt){let{x:Ht,y:_t,x2:bt,y2:Dt}=st.getProps(["x","y","x2","y2"],Lt),Yt=bt-Ht,Qt=Dt-_t,oe=xe(Yt)+xe(Qt),de=oe===0?-1:((pt-Ht)*Yt+(lt-_t)*Qt)/oe,le,Zt;return de<0?(le=Ht,Zt=_t):de>1?(le=bt,Zt=Dt):(le=Ht+de*Yt,Zt=_t+de*Qt),xe(pt-le)+xe(lt-Zt)<=vt}(this,G,xe(U),j)||_i(this,G,j)}return function(G,{mouseX:rt,mouseY:ct},st,{hBorderWidth:pt,useFinalPosition:lt}){let vt=Te(rt,ct,G.getProps(["x","y","x2","y2"],lt),st);return vt.value>=vt.start-pt&&vt.value<=vt.end+pt||_i(G,{mouseX:rt,mouseY:ct},lt,st)}(this,{mouseX:M,mouseY:z},H,{hBorderWidth:U,useFinalPosition:j})}getCenterPoint(M){return Ot(this,M)}draw(M){let{x:z,y:H,x2:j,y2:U,cp:G,options:rt}=this;if(M.save(),!y(M,rt))return M.restore();v(M,rt);let ct=Math.sqrt(Math.pow(j-z,2)+Math.pow(U-H,2));if(rt.curve&&G)return function(Ht,_t,bt,Dt){let{x:Yt,y:Qt,x2:oe,y2:de,options:le}=_t,{startOpts:Zt,endOpts:Me,startAdjust:me,endAdjust:Pe}=Zi(_t),S={x:Yt,y:Qt},O={x:oe,y:de},B=Ki(S,bt,O,0),c=Ki(S,bt,O,1)-h.PI,p=ci(S,bt,O,me/Dt),m=ci(S,bt,O,1-Pe/Dt),_=new Path2D;Ht.beginPath(),_.moveTo(p.x,p.y),_.quadraticCurveTo(bt.x,bt.y,m.x,m.y),Ht.shadowColor=le.borderShadowColor,Ht.stroke(_),_t.path=_,_t.ctx=Ht,Ji(Ht,p,{angle:B,adjust:me},Zt),Ji(Ht,m,{angle:c,adjust:Pe},Me)}(M,this,G,ct),M.restore();let{startOpts:st,endOpts:pt,startAdjust:lt,endAdjust:vt}=Zi(this),Lt=Math.atan2(U-H,j-z);M.translate(z,H),M.rotate(Lt),M.beginPath(),M.moveTo(0+lt,0),M.lineTo(ct-vt,0),M.shadowColor=rt.borderShadowColor,M.stroke(),Ui(M,0,lt,st),Ui(M,ct,-vt,pt),M.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(M,z){let H=Re(M,z),{x:j,y:U,x2:G,y2:rt}=H,ct=function({x:lt,y:vt,x2:Lt,y2:Ht},{top:_t,right:bt,bottom:Dt,left:Yt}){return!(ltbt&&Lt>bt||vt<_t&&Ht<_t||vt>Dt&&Ht>Dt)}(H,M.chartArea),st=ct?function(lt,vt,Lt){let{x:Ht,y:_t}=ni(lt,vt,Lt),{x:bt,y:Dt}=ni(vt,lt,Lt);return{x:Ht,y:_t,x2:bt,y2:Dt,width:Math.abs(bt-Ht),height:Math.abs(Dt-_t)}}({x:j,y:U},{x:G,y:rt},M.chartArea):{x:j,y:U,x2:G,y2:rt,width:Math.abs(G-j),height:Math.abs(rt-U)};if(st.centerX=(G+j)/2,st.centerY=(rt+U)/2,st.initProperties=Ee(M,st,z),z.curve){let lt={x:st.x,y:st.y},vt={x:st.x2,y:st.y2};st.cp=function(Lt,Ht,_t){let{x:bt,y:Dt,x2:Yt,y2:Qt,centerX:oe,centerY:de}=Lt,le=Math.atan2(Qt-Dt,Yt-bt),Zt=_e(Ht.controlPoint,0);return Ne({x:oe+ue(_t,Zt.x,!1),y:de+ue(_t,Zt.y,!1)},{x:oe,y:de},le)}(st,z,h.distanceBetweenPoints(lt,vt))}let pt=function(lt,vt,Lt){let Ht=Lt.borderWidth,_t=h.toPadding(Lt.padding),bt=P(lt.ctx,Lt),Dt=bt.width+_t.width+Ht,Yt=bt.height+_t.height+Ht;return function(Qt,oe,de,le){let{width:Zt,height:Me,padding:me}=de,{xAdjust:Pe,yAdjust:S}=oe,O={x:Qt.x,y:Qt.y},B={x:Qt.x2,y:Qt.y2},c=oe.rotation==="auto"?function(Mt){let{x:qt,y:Gt,x2:Jt,y2:pe}=Mt,he=Math.atan2(pe-Gt,Jt-qt);return he>h.PI/2?he-h.PI:hej&&(M=fe(j,{x:E,y:M},z),E=j),MU&&(E=Ce(U,{x:E,y:M},z),M=U),{x:E,y:M}}function _i(E,{mouseX:M,mouseY:z},H,j){let U=E.label;return U.options.display&&U.inRange(M,z,j,H)}function ui(E,M,z,H){let{labelSize:j,padding:U}=M,G=E.w*H.dx,rt=E.h*H.dy,ct=G>0&&(j.w/2+U.left-H.x)/G,st=rt>0&&(j.h/2+U.top-H.y)/rt;return at(Math.max(ct,st),0,.25)}function gi(E,M){let{size:z,min:H,max:j,padding:U}=M,G=z/2;return z>j-H?(j+H)/2:(H>=E-U-G&&(E=H+U+G),j<=E+U+G&&(E=j-U-G),E)}function Zi(E){let M=E.options,z=M.arrowHeads&&M.arrowHeads.start,H=M.arrowHeads&&M.arrowHeads.end;return{startOpts:z,endOpts:H,startAdjust:$e(E,z),endAdjust:$e(E,H)}}function $e(E,M){if(!M||!M.display)return 0;let{length:z,width:H}=M,j=E.options.borderWidth/2,U={x:z,y:H+j};return Math.abs(Ce(0,U,{x:0,y:j}))}function Ui(E,M,z,H){if(!H||!H.display)return;let{length:j,width:U,fill:G,backgroundColor:rt,borderColor:ct}=H,st=Math.abs(M-j)+z;E.beginPath(),v(E,H),y(E,H),E.moveTo(st,-U),E.lineTo(M+z,0),E.lineTo(st,U),G===!0?(E.fillStyle=rt||ct,E.closePath(),E.fill(),E.shadowColor="transparent"):E.shadowColor=H.borderShadowColor,E.stroke()}function Ji(E,{x:M,y:z},{angle:H,adjust:j},U){U&&U.display&&(E.save(),E.translate(M,z),E.rotate(H),Ui(E,0,-j,U),E.restore())}Be.defaults={adjustScaleRange:!0,arrowHeads:{display:!1,end:Object.assign({},Hi),fill:!1,length:12,start:Object.assign({},Hi),width:6},borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:2,curve:!1,controlPoint:{y:"-50%"},display:!0,endValue:void 0,init:void 0,label:{backgroundColor:"rgba(0,0,0,0.8)",backgroundShadowColor:"transparent",borderCapStyle:"butt",borderColor:"black",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderRadius:6,borderShadowColor:"transparent",borderWidth:0,callout:Object.assign({},zt.defaults.callout),color:"#fff",content:null,display:!1,drawTime:void 0,font:{family:void 0,lineHeight:void 0,size:void 0,style:void 0,weight:"bold"},height:void 0,opacity:void 0,padding:6,position:"center",rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,textAlign:"center",textStrokeColor:void 0,textStrokeWidth:0,width:void 0,xAdjust:0,yAdjust:0,z:void 0},scaleID:void 0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,value:void 0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},Be.descriptors={arrowHeads:{start:{_fallback:!0},end:{_fallback:!0},_fallback:!0}},Be.defaultRoutes={borderColor:"color"};class ji extends D.Element{inRange(M,z,H,j){let U=this.options.rotation,G=this.options.borderWidth;if(H!=="x"&&H!=="y")return function(Ht,_t,bt,Dt){let{width:Yt,height:Qt,centerX:oe,centerY:de}=_t,le=Yt/2,Zt=Qt/2;if(le<=0||Zt<=0)return!1;let Me=h.toRadians(bt||0),me=Dt/2||0,Pe=Math.cos(Me),S=Math.sin(Me),O=Math.pow(Pe*(Ht.x-oe)+S*(Ht.y-de),2),B=Math.pow(S*(Ht.x-oe)-Pe*(Ht.y-de),2);return O/Math.pow(le+me,2)+B/Math.pow(Zt+me,2)<=1.0001}({x:M,y:z},this.getProps(["width","height","centerX","centerY"],j),U,G);let{x:rt,y:ct,x2:st,y2:pt}=this.getProps(["x","y","x2","y2"],j),lt=G/2,vt=H==="y"?{start:ct,end:pt}:{start:rt,end:st},Lt=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-U));return Lt[H]>=vt.start-lt-W&&Lt[H]<=vt.end+lt+W}getCenterPoint(M){return Ot(this,M)}draw(M){let{width:z,height:H,centerX:j,centerY:U,options:G}=this;M.save(),d(M,this.getCenterPoint(),G.rotation),v(M,this.options),M.beginPath(),M.fillStyle=G.backgroundColor;let rt=y(M,G);M.ellipse(j,U,H/2,z/2,h.PI/2,0,2*h.PI),M.fill(),rt&&(M.shadowColor=G.borderShadowColor,M.stroke()),M.restore()}get label(){return this.elements&&this.elements[0]}resolveElementProperties(M,z){return We(M,z)}}ji.id="ellipseAnnotation",ji.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,label:Object.assign({},Tt.defaults.label),rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xMax:void 0,xMin:void 0,xScaleID:void 0,yMax:void 0,yMin:void 0,yScaleID:void 0,z:0},ji.defaultRoutes={borderColor:"color",backgroundColor:"color"},ji.descriptors={label:{_fallback:!0}};class Pi extends D.Element{inRange(M,z,H,j){let{x:U,y:G,x2:rt,y2:ct,width:st}=this.getProps(["x","y","x2","y2","width"],j),pt=this.options.borderWidth;if(H!=="x"&&H!=="y")return function(Lt,Ht,_t,bt){if(!Lt||!Ht||_t<=0)return!1;let Dt=bt/2;return Math.pow(Lt.x-Ht.x,2)+Math.pow(Lt.y-Ht.y,2)<=Math.pow(_t+Dt,2)}({x:M,y:z},this.getCenterPoint(j),st/2,pt);let lt=pt/2,vt=H==="y"?{start:G,end:ct,value:z}:{start:U,end:rt,value:M};return vt.value>=vt.start-lt&&vt.value<=vt.end+lt}getCenterPoint(M){return Ot(this,M)}draw(M){let z=this.options,H=z.borderWidth;if(z.radius<.1)return;M.save(),M.fillStyle=z.backgroundColor,v(M,z);let j=y(M,z);nt(M,this,this.centerX,this.centerY),j&&!r(z.pointStyle)&&(M.shadowColor=z.borderShadowColor,M.stroke()),M.restore(),z.borderWidth=H}resolveElementProperties(M,z){let H=ii(M,z);return H.initProperties=Ee(M,H,z),H}}Pi.id="pointAnnotation",Pi.defaults={adjustScaleRange:!0,backgroundShadowColor:"transparent",borderDash:[],borderDashOffset:0,borderShadowColor:"transparent",borderWidth:1,display:!0,init:void 0,pointStyle:"circle",radius:10,rotation:0,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,xAdjust:0,xMax:void 0,xMin:void 0,xScaleID:void 0,xValue:void 0,yAdjust:0,yMax:void 0,yMin:void 0,yScaleID:void 0,yValue:void 0,z:0},Pi.defaultRoutes={borderColor:"color",backgroundColor:"color"};class He extends D.Element{inRange(M,z,H,j){if(H!=="x"&&H!=="y")return this.options.radius>=.1&&this.elements.length>1&&function(st,pt,lt,vt){let Lt=!1,Ht=st[st.length-1].getProps(["bX","bY"],vt);for(let _t of st){let bt=_t.getProps(["bX","bY"],vt);bt.bY>lt!=Ht.bY>lt&&pt<(Ht.bX-bt.bX)*(lt-bt.bY)/(Ht.bY-bt.bY)+bt.bX&&(Lt=!Lt),Ht=bt}return Lt}(this.elements,M,z,j);let U=Ne({x:M,y:z},this.getCenterPoint(j),h.toRadians(-this.options.rotation)),G=this.elements.map(st=>H==="y"?st.bY:st.bX),rt=Math.min(...G),ct=Math.max(...G);return U[H]>=rt&&U[H]<=ct}getCenterPoint(M){return Ot(this,M)}draw(M){let{elements:z,options:H}=this;M.save(),M.beginPath(),M.fillStyle=H.backgroundColor,v(M,H);let j=y(M,H),U=!0;for(let G of z)U?(M.moveTo(G.x,G.y),U=!1):M.lineTo(G.x,G.y);M.closePath(),M.fill(),j&&(M.shadowColor=H.borderShadowColor,M.stroke()),M.restore()}resolveElementProperties(M,z){let H=ii(M,z),{sides:j,rotation:U}=z,G=[],rt=2*h.PI/j,ct=U*h.RAD_PER_DEG;for(let st=0;st{D.defaults.describe(`elements.${be[E].id}`,{_fallback:"plugins.annotation.common"})});let Ye={update:Object.assign},ts=wi.concat(J),ki=(E,M)=>h.isObject(M)?Oi(E,M):E,mi=E=>E==="color"||E==="font";function bi(E="line"){return be[E]?E:(console.warn(`Unknown annotation type: '${E}', defaulting to 'line'`),"line")}function Ii(E,M,z,H){let j=function(rt,ct,st){return st==="reset"||st==="none"||st==="resize"?Ye:new D.Animations(rt,ct)}(E,z.animations,H),U=M.annotations,G=function(rt,ct){let st=ct.length,pt=rt.length;if(ptst&&rt.splice(st,pt-st);return rt}(M.elements,U);for(let rt=0;rtki(G,j)):z[H]=ki(U,j)}return z}function ds(E,M,z){return M.$context||(M.$context=Object.assign(Object.create(E.getContext()),{element:M,id:z.id,type:"annotation"}))}let ge=new Map,Ue=wi.concat(J);var Ni={id:"annotation",version:"3.0.1",beforeRegister(){(function(E,M,z,H=!0){let j=z.split("."),U=0;for(let G of M.split(".")){let rt=j[U++];if(parseInt(G,10){let G=j[U];h.isObject(G)&&(G.id=U,H.push(G))}):h.isArray(j)&&H.push(...j),function(U,G){for(let rt of U)dt(rt,G)}(H,E.scales)},afterDataLimits(E,M){let z=ge.get(E);ot(E,M.scale,z.annotations.filter(H=>H.display&&H.adjustScaleRange))},afterUpdate(E,M,z){let H=ge.get(E);(function(j,U,G){U.listened=Ge(G,wi,U.listeners),U.moveListened=!1,U._getElements=C,si.forEach(rt=>{h.isFunction(G[rt])&&(U.moveListened=!0)}),U.listened&&U.moveListened||U.annotations.forEach(rt=>{!U.listened&&h.isFunction(rt.click)&&(U.listened=!0),U.moveListened||si.forEach(ct=>{h.isFunction(rt[ct])&&(U.listened=!0,U.moveListened=!0)})})})(0,H,z),Ii(E,H,z,M.mode),H.visibleElements=H.elements.filter(j=>!j.skip&&j.options.display),function(j,U,G){let rt=U.visibleElements;U.hooked=Ge(G,J,U.hooks),U.hooked||rt.forEach(ct=>{U.hooked||J.forEach(st=>{h.isFunction(ct.options[st])&&(U.hooked=!0)})})}(0,H,z)},beforeDatasetsDraw(E,M,z){we(E,"beforeDatasetsDraw",z.clip)},afterDatasetsDraw(E,M,z){we(E,"afterDatasetsDraw",z.clip)},beforeDraw(E,M,z){we(E,"beforeDraw",z.clip)},afterDraw(E,M,z){we(E,"afterDraw",z.clip)},beforeEvent(E,M,z){Di(ge.get(E),M.event,z)&&(M.changed=!0)},afterDestroy(E){ge.delete(E)},_getState:E=>ge.get(E),defaults:{animations:{numbers:{properties:["x","y","x2","y2","width","height","centerX","centerY","pointX","pointY","radius"],type:"number"}},clip:!0,interaction:{mode:void 0,axis:void 0,intersect:void 0},common:{drawTime:"afterDatasetsDraw",init:!1,label:{}}},descriptors:{_indexable:!1,_scriptable:E=>!Ue.includes(E)&&E!=="init",annotations:{_allKeys:!1,_fallback:(E,M)=>`elements.${be[bi(M.type)].id}`},interaction:{_fallback:!0},common:{label:{_indexable:mi,_fallback:!0},_indexable:mi}},additionalOptionScopes:[""]};function we(E,M,z){let{ctx:H,chartArea:j}=E,U=ge.get(E);z&&h.clipArea(H,j);let G=function(rt,ct){let st=[];for(let pt of rt)if(pt.options.drawTime===ct&&st.push({element:pt,main:!0}),pt.elements&&pt.elements.length)for(let lt of pt.elements)lt.options.display&<.options.drawTime===ct&&st.push({element:lt});return st}(U.visibleElements,M).sort((rt,ct)=>rt.element.options.z-ct.element.options.z);for(let rt of G)es(H,j,U,rt);z&&h.unclipArea(H)}function es(E,M,z,H){let j=H.element;H.main?(et(z,j,"beforeDraw"),j.draw(E,M),et(z,j,"afterDraw")):j.draw(E,M)}return D.Chart.register(Ni),Ni});(function(D,h){typeof exports=="object"&&typeof module<"u"?h(exports,ys("chart.js"),ys("chart.js/helpers")):typeof define=="function"&&define.amd?define(["exports","chart.js","chart.js/helpers"],h):h((D=typeof globalThis<"u"?globalThis:D||self).ChartGauge={},D.Chart,D.Chart.helpers)})(void 0,function(D,h,f){"use strict";let C={needle:{radius:"10%",width:"15%",length:"80%"},valueLabel:{display:!0,font:void 0,formatter:Math.round,color:()=>"#FFF",backgroundColor:h.Chart.defaults.backgroundColor,borderColor:h.Chart.defaults.borderColor,borderWidth:0,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},offsetX:0,offsetY:0},animation:{animateRotate:!0,animateScale:!1},cutout:"50%",rotation:-90,circumference:180,value:0,minValue:0};class I extends h.DoughnutController{constructor(W,at){super(W,at),this.center=new h.ArcElement({}),this.values=[],this.valuePercent=0,this.previous=0,this.current=0}_updateMeta(){let W=this._cachedMeta,at=W._parsed;if(this.values=[],this.valuePercent=0,at.length===0)return W;let q=this.options,{value:Rt=0,minValue:Ot=0}=q,ft=at.length>0?at[at.length-1]:Ot+1;at.reduce((jt,te)=>(this.values.push(te-jt),te),Ot);let xt=ft-Ot;return this.valuePercent=Rt/xt,W}_getTranslation(){let W=this._cachedMeta.data[0];return W==null?{dx:0,dy:0}:{dx:W.x,dy:W.y}}_getAngle(W){let at=this.options,{rotation:q,circumference:Rt}=at;return f.toRadians(q+Rt*W)}_getSize(W){return f.toPercentage(W,this.outerRadius)*this.outerRadius}drawNeedle(){let W=this.options,{ctx:at}=this.chart,{needle:q}=W,{radius:Rt,width:Ot,length:ft}=q,{color:xt}=q,jt=this._getSize(Rt),te=this._getSize(Ot),ae=this._getSize(ft),{dx:Ae,dy:ue}=this._getTranslation(),_e=this._getAngle(this.center.endAngle);at.save(),at.translate(Ae,ue),at.rotate(_e),at.fillStyle=xt,at.beginPath(),at.ellipse(0,0,jt,jt,0,0,2*Math.PI),at.fill(),at.beginPath(),at.moveTo(-te/2,0),at.lineTo(0,-ae),at.lineTo(te/2,0),at.fill(),at.restore()}drawValueLabel(){let W=this.options,{valueLabel:at}=W;if(!at.display)return;let{ctx:q}=this.chart,{color:Rt,formatter:Ot,backgroundColor:ft,borderColor:xt,borderWidth:jt,borderRadius:te,padding:ae,offsetX:Ae,offsetY:ue}=at,_e=f.toFont(at.font),{value:Oe}=W,Ee=(Ot?Ot(Oe):Oe).toString();q.save(),q.textBaseline="middle",q.textAlign="center",q.font=_e.string;let{width:Ge}=q.measureText(Ee),{lineHeight:De}=_e,se=1*De,Bt=-(ae.left+Ge/2)-jt,St=-(ae.top+se/2)-jt,r=ae.left+Ge+ae.right+2*jt,d=ae.top+se+ae.bottom+2*jt,{dx:y,dy:v}=this._getTranslation();y+=this._getSize(Ae),v+=this._getSize(ue),q.translate(y,v),q.fillStyle=ft,q.beginPath(),f.addRoundedRectPath(q,{x:Bt,y:St,w:r,h:d,radius:f.toTRBLCorners(te)}),q.closePath(),q.fill(),jt&&(q.strokeStyle=xt,q.lineWidth=jt,q.stroke()),f.renderText(q,Ee,0,.075*se,_e,{textAlign:"center",textBaseline:"middle",color:Rt}),q.restore()}update(W){let at=W==="reset",q=this._updateMeta();at?(this.previous=0,this.current=0):(this.previous=this.current||0,this.current=this.valuePercent);let Rt=q._parsed;q._parsed=this.values,super.update(W),q._parsed=Rt}updateElements(W,at,q,Rt){let Ot=this._cachedMeta,ft=Ot._parsed;if(Ot._parsed=this.values,super.updateElements(W,at,q,Rt),Ot._parsed=ft,W.length===0)return;let xt=W[0];super.updateElement(this.center,void 0,{x:xt.x,y:xt.y,startAngle:this.previous,endAngle:this.current,circumference:0,outerRadius:100,innerRadius:0,options:{}},Rt)}draw(){super.draw(),this.values.length!==0&&(this.drawNeedle(),this.drawValueLabel())}}I.id="gauge",I.version="3.0.0",I.defaults=C,I.descriptors={_scriptable:X=>X!=="formatter"},I.overrides={aspectRatio:!1,layout:{padding:{top:10,bottom:80}},plugins:{legend:{display:!1},tooltip:{enabled:!1}}},h.Chart.register(I),h.Chart.register(h.ArcElement),D.GaugeController=I,Object.defineProperty(D,"__esModule",{value:!0})});var Ze=class{static CACHE={};static accessToken(){return new URLSearchParams(window.location.search).get("access_token")}static async fetchGridLayout(h){try{let f=await fetch(new Request(`./grid-layout.json?name=${encodeURIComponent(h)}&access_token=${this.accessToken()}`),{cache:"no-store"});if(!f.ok)throw new Error(`DatastoreHelper.fetchGridLayout() - HTTP error, status = ${f.status}`);let C=await f.text(),I=JSON.parse(C);if(I.status===!1)throw new Error(`Dashboard "${h}" does not exist.`);return I}catch(f){console.error(f),alert(f.message)}}static async saveGridLayout(h,f){try{let C=await fetch(new Request(`./grid-layout.json?name=${encodeURIComponent(h)}&access_token=${this.accessToken()}`),{method:"PUT",body:JSON.stringify(f),cache:"no-store"});if(!C.ok)throw new Error(`DatastoreHelper.saveGridLayout() - HTTP error, status = ${C.status}`);let I=await C.text(),X=JSON.parse(I);if(X.status===!1)throw new Error(`Dashboard "${h}" does not exist.`);return alert(`Dashboard "${h}" successfully saved!`),X}catch(C){console.error(C),alert(C.message)}}static async fetchMonitoredDevices(){return this.fetchAndCache("monitored-devices.json")}static async fetchSupportedAttributes(){return this.fetchAndCache("supported-attributes.json")}static async fetchAndCache(h){return this.CACHE[h]!==void 0?this.CACHE[h]:(this.CACHE[h]=fetch(new Request(`./${h}?access_token=${this.accessToken()}`),{cache:"no-store"}).then(f=>{if(!f.ok)throw new Error(`DatastoreHelper.fetchAndCache(${h}) - HTTP error, status = ${f.status}`);return f.text()}).then(f=>JSON.parse(f)).catch(f=>{console.error(f),alert(f.message),reject(f)}),this.CACHE[h])}static async fetchDeviceData(h,f,C,I){let X={attr1:[],attr2:[]};try{let W=await fetch(new Request(this.buildCsvUrl(h,I)),{cache:"no-store"});if(W.status==404)return X;if(!W.ok)throw new Error(`DatastoreHelper.fetchDeviceData() - HTTP error, status = ${W.status}`);let at=(await W.text()).split(` +`),q=at.shift().split(","),Rt=f=q.indexOf(f),Ot=C==null?0:q.indexOf(C);return at.forEach(ft=>{let xt=ft.split(",");X.attr1.push({x:parseInt(xt[0]*1e3),y:parseInt(xt[Rt])}),Ot!==0&&X.attr2.push({x:parseInt(xt[0]*1e3),y:parseInt(xt[Ot])})}),X}catch(W){console.error(W),alert(W.message)}}static buildCsvUrl(h,f){return window.location.host!=="cloud.hubitat.com"?`/local/wt_${h}_${f}.csv`:`./watchtower.csv?device=${h}&precision=${f}&access_token=${this.accessToken()}`}static async fetchAttributeData(h,f,C){let I={};for(let X of f){let W=await this.fetchDeviceData(X,h,void 0,C);I[`dev_${X}`]=W.attr1}return I}static async fetchHubInfo(){try{let h=await fetch(new Request(`./hub-info.json?access_token=${this.accessToken()}`),{cache:"no-store"});if(!h.ok)throw new Error(`DatastoreHelper.fetchHubInfo() - HTTP error, status = ${h.status}`);let f=await h.text();return JSON.parse(f)}catch(h){console.error(h),alert(h.message)}}static async fetchHubData(){try{let h=await fetch(new Request("/hub2/hubData"),{cache:"no-store"});if(!h.ok)throw new Error(`DatastoreHelper.fetchHubData() - HTTP error, status = ${h.status}`);let f=await h.text();return JSON.parse(f)}catch(h){console.error(h),alert(h.message)}}};var Fn=class extends ke{static styles=Xe` :host { display: block; height: calc(100vh - 10px); @@ -18,20 +18,21 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the `} - `}connectedCallback(){super.connectedCallback(),document.body.classList.remove("spinner")}async firstUpdated(){this.menuElm=this.renderRoot.querySelector("dashboard-menu"),this.gridElm=this.renderRoot.querySelector("dashboard-grid"),this.dialogElm=this.renderRoot.querySelector("dashboard-add-dialog");let h=await Ze.fetchGridLayout(this.params.get("name")),f=h.refresh?parseInt(h.refresh):0,C=h.theme==="dark"?"dark":"light",H=h.yScale=="fixed"?"fixed":"auto";h.panels.length===0&&(this.menuElm.open=!0),await this.gridElm.updateComplete,this.gridElm.init(h.panels),this.gridElm.setRefreshInterval(f),this.gridElm.setYScale(H),this.menuElm.refreshInterval=f,this.menuElm.yScale=H,this.menuElm.setTheme(C),this.applyMobileView()}bailOut(h){alert(` + `}connectedCallback(){super.connectedCallback(),document.body.classList.remove("spinner")}async firstUpdated(){this.menuElm=this.renderRoot.querySelector("dashboard-menu"),this.gridElm=this.renderRoot.querySelector("dashboard-grid"),this.dialogElm=this.renderRoot.querySelector("dashboard-add-dialog");let h=await Ze.fetchGridLayout(this.params.get("name")),f=h.refresh?parseInt(h.refresh):0,C=h.theme==="dark"?"dark":"light",I=h.yScale=="fixed"?"fixed":"auto",X=h.cellHeight?parseInt(h.cellHeight):206;h.panels.length===0&&(this.menuElm.open=!0),await this.gridElm.updateComplete,this.gridElm.init(h.panels),this.gridElm.setRefreshInterval(f),this.gridElm.setYScale(I),this.gridElm.setCellHeight(X),this.menuElm.refreshInterval=f,this.menuElm.yScale=I,this.menuElm.cellHeight=X,this.menuElm.setTheme(C),this.applyMobileView()}bailOut(h){alert(` This file is part of the Watchtower application. To load or create a Watchtower dashboard, please got to: \u2022 Apps -> Watchtower -> Dashboards Error Code: #${h} - `)}applyMobileView(){this.gridElm.applyMobileView(this.mobileView),this.menuElm.applyMobileView(this.mobileView)}async saveDashboard(h){let f={...h.detail,panels:this.gridElm.getPanelsConfig()};console.info("Saving dashboard to Hubitat",this.name,f),await Ze.saveGridLayout(this.name,f)}showAddDialog(){this.dialogElm.setAttribute("open",!0)}compactPanels(){this.gridElm.compact()}addDashboardPanel(h){this.gridElm.addPanel(h.detail)}changeRefreshInterval(h){let f=parseInt(h.detail);this.gridElm.setRefreshInterval(f)}changeYScale(h){this.gridElm.setYScale(h.detail)}};var Wn=class extends ke{static styles=Xe` + `)}applyMobileView(){this.gridElm.applyMobileView(this.mobileView),this.menuElm.applyMobileView(this.mobileView)}async saveDashboard(h){let f={...h.detail,panels:this.gridElm.getPanelsConfig()};console.info("Saving dashboard to Hubitat",this.name,f),await Ze.saveGridLayout(this.name,f)}showAddDialog(){this.dialogElm.setAttribute("open",!0)}compactPanels(){this.gridElm.compact()}addDashboardPanel(h){this.gridElm.addPanel(h.detail)}applyRefreshInterval(h){let f=parseInt(h.detail);this.gridElm.setRefreshInterval(f)}applyYScale(h){this.gridElm.setYScale(h.detail)}applyCellHeight(h){this.gridElm.setCellHeight(h.detail)}};var Wn=class extends ke{static styles=Xe` :host { display: block; position: fixed; @@ -96,7 +97,7 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the display: block; width: 100%; margin-bottom: 5px; - padding: .5em; + height: 30px; background-color: var(--bg-color-darker); color: var(--text-color); border: 1px var(--border-color) solid; @@ -104,7 +105,7 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the } select:focus, button:focus { outline: 1px var(--Blue) solid; - border-color: var(--Blue) + border-color: var(--Blue); } aside { color: var(--text-color-darker); @@ -115,7 +116,50 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the user-select: none; font-size: .75rem; } - `;static properties={open:{type:Boolean,reflect:!0},refreshInterval:{type:String,state:!0},theme:{type:String,state:!0},yScale:{type:String,state:!0},mobileView:{type:Boolean,state:!0}};constructor(){super(),this.open=!1,this.refreshInterval="0",this.theme="light",this.yScale="auto"}render(){return Kt` + form { + border: 1px solid grey; + padding: 0; + background-color: var(--bg-color-darker); + color: var(--text-color); + border: 1px var(--border-color) solid; + border-radius: 5px; + position: relative; + display: block; + width: 100%; + } + form input[type="text"] { + box-sizing: border-box; + border: none; + color: var(--text-color); + background-color: transparent; + padding-right: 30px; + padding-left: 5px; + width: 100%; + height: 28px; + } + form input:focus { + outline: none; + } + form:focus-within { + border-color: var(--Blue); + outline: 1px solid var(--Blue); + } + form:invalid { + border-color: var(--Red); + outline: 1px solid var(--Red); + } + form input[type="submit"] { + border: none; + color: var(--text-color); + background-color: transparent; + position: absolute; + top: 50%; + right: 0px; + transform: translateY(-50%); + cursor: pointer; + width: 30px; + } + `;static properties={open:{type:Boolean,reflect:!0},refreshInterval:{type:String,state:!0},theme:{type:String,state:!0},yScale:{type:String,state:!0},cellHeight:{type:Number,state:!0},mobileView:{type:Boolean,state:!0}};constructor(){super(),this.open=!1,this.refreshInterval="0",this.theme="light",this.yScale="auto",this.cellHeight=206}render(){return Kt` - `}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",h=>h.key==="Escape"&&(this.open=!this.open)),window.addEventListener("touchstart",h=>this.touchStart(h)),window.addEventListener("touchend",h=>this.touchEnd(h))}applyMobileView(h){this.mobileView=h}addTile(){this.dispatchEvent(new CustomEvent("add"))}compactTiles(){this.dispatchEvent(new CustomEvent("compact"))}saveDashboard(){this.dispatchEvent(new CustomEvent("save",{detail:{theme:this.theme,refresh:this.refreshInterval,yScale:this.yScale}}))}changeRefreshInterval(h){this.refreshInterval=h.target.value,this.dispatchEvent(new CustomEvent("changeRefreshInterval",{detail:this.refreshInterval}))}changeTheme(h){this.setTheme(h.target.value)}changeYScale(h){this.yScale=h.target.value,this.dispatchEvent(new CustomEvent("changeYScale",{detail:this.yScale}))}setTheme(h){this.theme=h,this.dispatchEvent(new CustomEvent("changeTheme",{detail:this.theme})),document.documentElement.setAttribute("data-theme",this.theme);let f=new URLSearchParams(window.location.search);document.querySelector('meta[name="theme-color"]').setAttribute("content",h=="dark"?"#1b1b1b":"#eee8d5"),document.querySelector('link[rel="manifest"]').setAttribute("href",`./app.webmanifest?access_token=${f.get("access_token")}&name=${encodeURIComponent(f.get("name"))}&theme=${h}`)}touchStart(h){this.startX=h.changedTouches[0].clientX}touchEnd(h){if(this.startX==null)return;let f=h.changedTouches[0].clientX,C=f-this.startX;if(!this.open&&this.startX<30&&C>50){this.open=!0;return}this.open&&f<30&&C<-50&&(this.open=!1)}};var Bn=class D extends ke{static styles=Xe` + `}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",h=>h.key==="Escape"&&(this.open=!this.open)),window.addEventListener("touchstart",h=>this.touchStart(h)),window.addEventListener("touchend",h=>this.touchEnd(h))}applyMobileView(h){this.mobileView=h}addTile(){this.dispatchEvent(new CustomEvent("add"))}compactTiles(){this.dispatchEvent(new CustomEvent("compact"))}saveDashboard(){this.dispatchEvent(new CustomEvent("save",{detail:{theme:this.theme,refresh:this.refreshInterval,yScale:this.yScale,cellHeight:this.cellHeight}}))}changeRefreshInterval(h){this.refreshInterval=h.target.value,this.dispatchEvent(new CustomEvent("changeRefreshInterval",{detail:this.refreshInterval}))}changeTheme(h){this.setTheme(h.target.value)}changeYScale(h){this.yScale=h.target.value,this.dispatchEvent(new CustomEvent("changeYScale",{detail:this.yScale}))}changeCellHeight(h){h.preventDefault();let f=Object.fromEntries(new FormData(h.target));this.cellHeight=parseInt(f.cellHeight),this.dispatchEvent(new CustomEvent("changeCellHeight",{detail:this.cellHeight}))}setTheme(h){this.theme=h,this.dispatchEvent(new CustomEvent("changeTheme",{detail:this.theme})),document.documentElement.setAttribute("data-theme",this.theme);let f=new URLSearchParams(window.location.search);document.querySelector('meta[name="theme-color"]').setAttribute("content",h=="dark"?"#1b1b1b":"#eee8d5"),document.querySelector('link[rel="manifest"]').setAttribute("href",`./app.webmanifest?access_token=${f.get("access_token")}&name=${encodeURIComponent(f.get("name"))}&theme=${h}`)}touchStart(h){this.startX=h.changedTouches[0].clientX}touchEnd(h){if(this.startX==null)return;let f=h.changedTouches[0].clientX,C=f-this.startX;if(!this.open&&this.startX<30&&C>50){this.open=!0;return}this.open&&f<30&&C<-50&&(this.open=!1)}};var Bn=class D extends ke{static styles=Xe` :host { display: none; position: fixed; @@ -396,12 +448,12 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the
  • Remember to click the Save dashboard button when you're happy with the layout. For more information, refer to the official documentation. - `},2,2,1,0):(this.grid.batchUpdate(!0),h.forEach(f=>{this.addPanel(f.config,f.w,f.h,f.x,f.y)}),this.grid.batchUpdate(!1)),this.renderRoot.querySelector(".grid-stack").classList.remove("spinner")}applyMobileView(h){this.mobileView=h,this.renderRoot.querySelectorAll(".panel").forEach(f=>f.mobileView=this.mobileView),this.grid.enableResize(!this.mobileView),this.grid.enableMove(!this.mobileView),setTimeout(()=>this.grid.setAnimation(!this.mobileView),1e3)}setRefreshInterval(h){this.interval&&clearInterval(this.interval),h!=0&&(this.interval=setInterval(()=>{this.renderRoot.querySelectorAll(".panel").forEach(f=>f.refresh())},h*60*1e3),console.info(`Setting auto-refresh timer for ${h} minutes`))}setYScale(h){this.renderRoot.querySelectorAll("device-panel, attribute-panel").forEach(f=>f.setYScale(h))}addPanel(h,f=2,C=1,H=void 0,X=void 0){let W=` + `},2,2,1,0):(this.grid.batchUpdate(!0),h.forEach(f=>{this.addPanel(f.config,f.w,f.h,f.x,f.y)}),this.grid.batchUpdate(!1)),this.renderRoot.querySelector(".grid-stack").classList.remove("spinner")}applyMobileView(h){this.mobileView=h,this.renderRoot.querySelectorAll(".panel").forEach(f=>f.mobileView=this.mobileView),this.grid.enableResize(!this.mobileView),this.grid.enableMove(!this.mobileView),setTimeout(()=>this.grid.setAnimation(!this.mobileView),1e3)}setRefreshInterval(h){this.interval&&clearInterval(this.interval),h!=0&&(this.interval=setInterval(()=>{this.renderRoot.querySelectorAll(".panel").forEach(f=>f.refresh())},h*60*1e3),console.info(`Setting auto-refresh timer for ${h} minutes`))}setYScale(h){this.renderRoot.querySelectorAll("device-panel, attribute-panel").forEach(f=>f.setYScale(h))}setCellHeight(h){this.grid.cellHeight(h,!0)}addPanel(h,f=2,C=1,I=void 0,X=void 0){let W=`
    <${h.type} config='${JSON.stringify(h).replace(/'/g,"'")}' class="panel empty spinner">
    ${h.title||" "}
    - `;this.grid.addWidget({w:f,h:C,x:H,y:X,config:h,content:W,id:`${h.noBorder===!0?"tr-":""}${this.randomUUID()}`})}randomUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){var f=Math.random()*16|0,C=h=="x"?f:f&3|8;return C.toString(16)})}compact(){this.grid.compact()}getPanelsConfig(){return this.grid.engine.nodes.map(h=>{let f=h.el.querySelector(".panel");return{w:h.w,h:h.h,x:h.x,y:h.y,config:f.decorateConfig(h.config)}})}};var jn=class D extends ke{static styles=Xe` + `;this.grid.addWidget({w:f,h:C,x:I,y:X,config:h,content:W,id:`${h.noBorder===!0?"tr-":""}${this.randomUUID()}`})}randomUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){var f=Math.random()*16|0,C=h=="x"?f:f&3|8;return C.toString(16)})}compact(){this.grid.compact()}getPanelsConfig(){return this.grid.engine.nodes.map(h=>{let f=h.el.querySelector(".panel");return{w:h.w,h:h.h,x:h.x,y:h.y,config:f.decorateConfig(h.config)}})}};var jn=class D extends ke{static styles=Xe` ul { margin: 0; padding: 0; @@ -439,7 +491,7 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the - `}selectPrecision(h){this.precision=h.target.textContent,this.dispatchEvent(new CustomEvent("change",{detail:this.precision}))}};var os=class D{static colors(){let h=getComputedStyle(document.documentElement);return{BgColor:h.getPropertyValue("--bg-color"),BgColorDarker:h.getPropertyValue("--bg-color-darker"),TextColor:h.getPropertyValue("--text-color"),TextColorDarker:h.getPropertyValue("--text-color-darker"),BorderColor:h.getPropertyValue("--border-color"),Yellow:h.getPropertyValue("--Yellow"),Orange:h.getPropertyValue("--Orange"),Red:h.getPropertyValue("--Red"),Magenta:h.getPropertyValue("--Magenta"),Violet:h.getPropertyValue("--Violet"),Blue:h.getPropertyValue("--Blue"),Cyan:h.getPropertyValue("--Cyan"),Green:h.getPropertyValue("--Green"),Gray:h.getPropertyValue("--Gray")}}static{let h=getComputedStyle(document.documentElement);D.chartColors=[h.getPropertyValue("--Red"),h.getPropertyValue("--Blue")]}};var Ei=class D{static defaultConfig(h){let f=os.colors();return{type:"line",options:{parsing:!1,normalized:!0,responsive:!0,maintainAspectRatio:!1,onResize:C=>D.updateChartType(C),animation:{duration:0,onComplete:({initial:C,chart:H})=>C?D.updateChartType(H):void 0},layout:{padding:{top:25,bottom:4}},stacked:!1,pointStyle:!1,scales:{x:{type:"time",time:{minUnit:"minute",displayFormats:{minute:"d LLL HH:mm",hour:"d LLL HH:mm",day:"d LLL"},tooltipFormat:"d LLL HH:mm"},title:{display:!1},ticks:{color:f.TextColorDarker,maxRotation:0,autoSkipPadding:15},grid:{color:f.TextColorDarker+"44"}}},interaction:{mode:"nearest",axis:"x",intersect:!1},plugins:{legend:{display:!1},tooltip:{itemSort:(C,H)=>H.raw.y-C.raw.y,callbacks:{label:C=>` ${C.dataset.label}: ${C.parsed.y}${C.dataset.unit}`},backgroundColor:f.BgColorDarker,titleColor:f.TextColor,bodyColor:f.TextColorDarker,borderColor:f.BorderColor,borderWidth:1},decimation:{enabled:!0,algorithm:"lttb"},zoom:{pan:{enabled:h!==!0,mode:"x"},zoom:{wheel:{enabled:!0},pinch:{enabled:h!==!0},mode:"x",onZoomComplete:({chart:C})=>D.updateChartType(C)},limits:{x:{min:"original",max:"original"}}}}},plugins:[D.crosshairPlugin(),D.toggleScaleVisibilityPlugin()]}}static crosshairPlugin(){let h=os.colors();return{id:"crosshair",afterInit:f=>{f.crosshair={x:0,y:0}},afterEvent:(f,C)=>{let{inChartArea:H}=C,{type:X,x:W,y:at}=C.event;f.crosshair={x:W,y:at,draw:H},f.draw()},beforeDatasetsDraw:f=>{let{ctx:C}=f,{top:H,bottom:X,left:W,right:at}=f.chartArea,{x:q,y:Rt,draw:Ot}=f.crosshair;Ot&&(C.save(),C.beginPath(),C.lineWidth=1,C.strokeStyle=h.TextColor,C.setLineDash([2,2]),C.moveTo(q,X),C.lineTo(q,H),C.stroke(),C.restore())}}}static toggleScaleVisibilityPlugin(){return{id:"toggleScaleVisibility",afterEvent:(h,f)=>{let C=f.event;if(f.inChartArea===!0||C.type!=="click"||h.data.datasets.length===1)return;let{x:H,y:X}=C,W=Object.entries(h.scales).filter(([Ot,ft])=>Ot!=="y"&&ft.axis==="y"&&ft.topX&&ft.leftH).map(Ot=>Ot[0]);if(W.length===0)return;let at=h.data.datasets,q=W[0],Rt=at.findIndex(Ot=>Ot.yAxisID==q);h.getVisibleDatasetCount()===1?at.forEach((Ot,ft)=>h.setDatasetVisibility(ft,!0)):at.forEach((Ot,ft)=>h.setDatasetVisibility(ft,ft!==Rt)),h.update("none")}}}static updateChartType(h){if(h.scales.x===void 0||h.data.datasets[0]===void 0)return;let f=h.scales.x.min,C=h.scales.x.max,H=h.data.datasets[0].data,X=h.getZoomLevel()<=1?H.length:H.filter(at=>at.x>=f&&at.x<=C).length,W=h.width/X>30?"bar":"line";h.options.scales.x.offset=W=="bar",h.config.type!=W&&(h.config.type=W,h.update("none"))}static prettyName(h){return(h[0].toUpperCase()+h.slice(1)).replace(/([A-Z])(?=[A-Z][a-z])|([a-z])(?=[A-Z])/g,"$& ").replace("Hub ","")}};var Vn=class extends ke{static styles=Xe` + `}selectPrecision(h){this.precision=h.target.textContent,this.dispatchEvent(new CustomEvent("change",{detail:this.precision}))}};var os=class D{static colors(){let h=getComputedStyle(document.documentElement);return{BgColor:h.getPropertyValue("--bg-color"),BgColorDarker:h.getPropertyValue("--bg-color-darker"),TextColor:h.getPropertyValue("--text-color"),TextColorDarker:h.getPropertyValue("--text-color-darker"),BorderColor:h.getPropertyValue("--border-color"),Yellow:h.getPropertyValue("--Yellow"),Orange:h.getPropertyValue("--Orange"),Red:h.getPropertyValue("--Red"),Magenta:h.getPropertyValue("--Magenta"),Violet:h.getPropertyValue("--Violet"),Blue:h.getPropertyValue("--Blue"),Cyan:h.getPropertyValue("--Cyan"),Green:h.getPropertyValue("--Green"),Gray:h.getPropertyValue("--Gray")}}static{let h=getComputedStyle(document.documentElement);D.chartColors=[h.getPropertyValue("--Red"),h.getPropertyValue("--Blue")]}};var Ei=class D{static defaultConfig(h){let f=os.colors();return{type:"line",options:{parsing:!1,normalized:!0,responsive:!0,maintainAspectRatio:!1,onResize:C=>D.updateChartType(C),animation:{duration:0,onComplete:({initial:C,chart:I})=>C?D.updateChartType(I):void 0},layout:{padding:{top:25,bottom:4}},stacked:!1,pointStyle:!1,scales:{x:{type:"time",time:{minUnit:"minute",displayFormats:{minute:"d LLL HH:mm",hour:"d LLL HH:mm",day:"d LLL"},tooltipFormat:"d LLL HH:mm"},title:{display:!1},ticks:{color:f.TextColorDarker,maxRotation:0,autoSkipPadding:15},grid:{color:f.TextColorDarker+"44"}}},interaction:{mode:"nearest",axis:"x",intersect:!1},plugins:{legend:{display:!1},tooltip:{itemSort:(C,I)=>I.raw.y-C.raw.y,callbacks:{label:C=>` ${C.dataset.label}: ${C.parsed.y}${C.dataset.unit}`},backgroundColor:f.BgColorDarker,titleColor:f.TextColor,bodyColor:f.TextColorDarker,borderColor:f.BorderColor,borderWidth:1},decimation:{enabled:!0,algorithm:"lttb"},zoom:{pan:{enabled:h!==!0,mode:"x"},zoom:{wheel:{enabled:!0},pinch:{enabled:h!==!0},mode:"x",onZoomComplete:({chart:C})=>D.updateChartType(C)},limits:{x:{min:"original",max:"original"}}}}},plugins:[D.crosshairPlugin(),D.toggleScaleVisibilityPlugin()]}}static crosshairPlugin(){let h=os.colors();return{id:"crosshair",afterInit:f=>{f.crosshair={x:0,y:0}},afterEvent:(f,C)=>{let{inChartArea:I}=C,{type:X,x:W,y:at}=C.event;f.crosshair={x:W,y:at,draw:I},f.draw()},beforeDatasetsDraw:f=>{let{ctx:C}=f,{top:I,bottom:X,left:W,right:at}=f.chartArea,{x:q,y:Rt,draw:Ot}=f.crosshair;Ot&&(C.save(),C.beginPath(),C.lineWidth=1,C.strokeStyle=h.TextColor,C.setLineDash([2,2]),C.moveTo(q,X),C.lineTo(q,I),C.stroke(),C.restore())}}}static toggleScaleVisibilityPlugin(){return{id:"toggleScaleVisibility",afterEvent:(h,f)=>{let C=f.event;if(f.inChartArea===!0||C.type!=="click"||h.data.datasets.length===1)return;let{x:I,y:X}=C,W=Object.entries(h.scales).filter(([Ot,ft])=>Ot!=="y"&&ft.axis==="y"&&ft.topX&&ft.leftI).map(Ot=>Ot[0]);if(W.length===0)return;let at=h.data.datasets,q=W[0],Rt=at.findIndex(Ot=>Ot.yAxisID==q);h.getVisibleDatasetCount()===1?at.forEach((Ot,ft)=>h.setDatasetVisibility(ft,!0)):at.forEach((Ot,ft)=>h.setDatasetVisibility(ft,ft!==Rt)),h.update("none")}}}static updateChartType(h){if(h.scales.x===void 0||h.data.datasets[0]===void 0)return;let f=h.scales.x.min,C=h.scales.x.max,I=h.data.datasets[0].data,X=h.getZoomLevel()<=1?I.length:I.filter(at=>at.x>=f&&at.x<=C).length,W=h.width/X>30?"bar":"line";h.options.scales.x.offset=W=="bar",h.config.type!=W&&(h.config.type=W,h.update("none"))}static prettyName(h){return(h[0].toUpperCase()+h.slice(1)).replace(/([A-Z])(?=[A-Z][a-z])|([a-z])(?=[A-Z])/g,"$& ").replace("Hub ","")}};var Vn=class extends ke{static styles=Xe` :host { display: block; width: 100%; @@ -474,7 +526,7 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the ${this.nodata===!0?Kt``:ee} - `}updated(h){h.mobileView!=this.mobileView&&(this.chart.options.plugins.zoom.pan.enabled=!this.mobileView,this.chart.options.plugins.zoom.zoom.pinch.enabled=!this.mobileView)}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m");let h=await Ze.fetchSupportedAttributes(),f=await Ze.fetchDeviceData(this.config.dev,this.config.attr1,this.config.attr2,this.config.precision),C=os.colors();this.nodata=f.attr1.length==0;let H=[{label:Ei.prettyName(this.config.attr1),data:f.attr1,pointStyle:!1,backgroundColor:C.Green+"44",borderColor:C.Green,borderWidth:1.2,tension:.5,fill:"start",yAxisID:"attr1",unit:h[this.config.attr1].unit}];this.chart.options.scales.attr1={position:"left",display:!0,title:{display:!0,text:`${H[0].label} ${h[this.config.attr1].unit}`,color:C.Green},ticks:{color:C.TextColorDarker},grid:{color:C.TextColorDarker+"33"}},this.attr1Min=h[this.config.attr1].min,this.attr1Max=h[this.config.attr1].max,this.scale==="fixed"&&(this.attr1Min!==void 0&&(this.chart.options.scales.attr1.suggestedMin=this.attr1Min),this.attr1Max!==void 0&&(this.chart.options.scales.attr1.suggestedMax=this.attr1Max)),this.config.attr2!==void 0&&(H.push({label:Ei.prettyName(this.config.attr2),data:f.attr2,pointStyle:!1,backgroundColor:C.Blue+"44",borderColor:C.Blue,borderWidth:1.2,tension:.5,fill:"start",yAxisID:"attr2",unit:h[this.config.attr2].unit}),this.chart.options.scales.attr2={position:"right",display:!0,title:{display:!0,text:`${H[1].label} ${h[this.config.attr2].unit}`,color:C.Blue},ticks:{color:C.TextColorDarker},grid:{drawOnChartArea:!1}},this.attr2Min=h[this.config.attr2].min,this.attr2Max=h[this.config.attr2].max,this.scale==="fixed"&&(this.attr2Min!==void 0&&(this.chart.options.scales.attr2.suggestedMin=this.attr2Min),this.attr2Max!==void 0&&(this.chart.options.scales.attr2.suggestedMax=this.attr2Max))),this.chart.data={datasets:H},Ei.updateChartType(this.chart),this.chart.update("none"),setTimeout(()=>this.classList.remove("empty","spinner"),200)}firstUpdated(){this.chart=new Chart(this.renderRoot.querySelector("canvas"),Ei.defaultConfig(this.mobileView)),this.chart.canvas.style.touchAction="pan-y"}async changePrecision(h){this.config.precision=h.detail,await this.refresh(),this.chart.resetZoom()}async refresh(){this.classList.add("spinner");let h=await Ze.fetchDeviceData(this.config.dev,this.config.attr1,this.config.attr2,this.config.precision);console.log("refresh data",h),this.nodata=h.attr1.length==0,this.chart.data.datasets[0].data=h.attr1,this.config.attr2!==void 0&&(this.chart.data.datasets[1].data=h.attr2),this.chart.config.type=h.attr1.length<10?"bar":"line",this.chart.update("none"),Ei.updateChartType(this.chart),this.classList.remove("spinner")}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.scale=h,this.chart&&(h=="auto"?(delete this.chart.options.scales.attr1.suggestedMin,delete this.chart.options.scales.attr1.suggestedMax,this.config.attr2!==void 0&&(delete this.chart.options.scales.attr2.suggestedMin,delete this.chart.options.scales.attr2.suggestedMax)):(this.attr1Min!==void 0&&(this.chart.options.scales.attr1.suggestedMin=this.attr1Min),this.attr1Max!==void 0&&(this.chart.options.scales.attr1.suggestedMax=this.attr1Max),this.attr2Min!==void 0&&(this.chart.options.scales.attr2.suggestedMin=this.attr2Min),this.attr2Max!==void 0&&(this.chart.options.scales.attr2.suggestedMax=this.attr2Max)),this.chart.update())}},Yn=class extends ke{static properties={devices:{type:Object,state:!0},attributes:{type:Object,state:!0},device:{type:String,state:!0},attr1:{type:String,state:!0},attr2:{type:String,state:!0}};constructor(){super(),this.devices=void 0,this.attributes=void 0,this.dev=void 0,this.attr1=void 0,this.attr2=void 0}render(){return Kt` + `}updated(h){h.mobileView!=this.mobileView&&(this.chart.options.plugins.zoom.pan.enabled=!this.mobileView,this.chart.options.plugins.zoom.zoom.pinch.enabled=!this.mobileView)}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m");let h=await Ze.fetchSupportedAttributes(),f=await Ze.fetchDeviceData(this.config.dev,this.config.attr1,this.config.attr2,this.config.precision),C=os.colors();this.nodata=f.attr1.length==0;let I=[{label:Ei.prettyName(this.config.attr1),data:f.attr1,pointStyle:!1,backgroundColor:C.Green+"44",borderColor:C.Green,borderWidth:1.2,tension:.5,fill:"start",yAxisID:"attr1",unit:h[this.config.attr1].unit}];this.chart.options.scales.attr1={position:"left",display:!0,title:{display:!0,text:`${I[0].label} ${h[this.config.attr1].unit}`,color:C.Green},ticks:{color:C.TextColorDarker},grid:{color:C.TextColorDarker+"33"}},this.attr1Min=h[this.config.attr1].min,this.attr1Max=h[this.config.attr1].max,this.scale==="fixed"&&(this.attr1Min!==void 0&&(this.chart.options.scales.attr1.suggestedMin=this.attr1Min),this.attr1Max!==void 0&&(this.chart.options.scales.attr1.suggestedMax=this.attr1Max)),this.config.attr2!==void 0&&(I.push({label:Ei.prettyName(this.config.attr2),data:f.attr2,pointStyle:!1,backgroundColor:C.Blue+"44",borderColor:C.Blue,borderWidth:1.2,tension:.5,fill:"start",yAxisID:"attr2",unit:h[this.config.attr2].unit}),this.chart.options.scales.attr2={position:"right",display:!0,title:{display:!0,text:`${I[1].label} ${h[this.config.attr2].unit}`,color:C.Blue},ticks:{color:C.TextColorDarker},grid:{drawOnChartArea:!1}},this.attr2Min=h[this.config.attr2].min,this.attr2Max=h[this.config.attr2].max,this.scale==="fixed"&&(this.attr2Min!==void 0&&(this.chart.options.scales.attr2.suggestedMin=this.attr2Min),this.attr2Max!==void 0&&(this.chart.options.scales.attr2.suggestedMax=this.attr2Max))),this.chart.data={datasets:I},Ei.updateChartType(this.chart),this.chart.update("none"),setTimeout(()=>this.classList.remove("empty","spinner"),200)}firstUpdated(){this.chart=new Chart(this.renderRoot.querySelector("canvas"),Ei.defaultConfig(this.mobileView)),this.chart.canvas.style.touchAction="pan-y"}async changePrecision(h){this.config.precision=h.detail,await this.refresh(),this.chart.resetZoom()}async refresh(){this.classList.add("spinner");let h=await Ze.fetchDeviceData(this.config.dev,this.config.attr1,this.config.attr2,this.config.precision);console.log("refresh data",h),this.nodata=h.attr1.length==0,this.chart.data.datasets[0].data=h.attr1,this.config.attr2!==void 0&&(this.chart.data.datasets[1].data=h.attr2),this.chart.config.type=h.attr1.length<10?"bar":"line",this.chart.update("none"),Ei.updateChartType(this.chart),this.classList.remove("spinner")}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.scale=h,this.chart&&(h=="auto"?(delete this.chart.options.scales.attr1.suggestedMin,delete this.chart.options.scales.attr1.suggestedMax,this.config.attr2!==void 0&&(delete this.chart.options.scales.attr2.suggestedMin,delete this.chart.options.scales.attr2.suggestedMax)):(this.attr1Min!==void 0&&(this.chart.options.scales.attr1.suggestedMin=this.attr1Min),this.attr1Max!==void 0&&(this.chart.options.scales.attr1.suggestedMax=this.attr1Max),this.attr2Min!==void 0&&(this.chart.options.scales.attr2.suggestedMin=this.attr2Min),this.attr2Max!==void 0&&(this.chart.options.scales.attr2.suggestedMax=this.attr2Max)),this.chart.update())}},Yn=class extends ke{static properties={devices:{type:Object,state:!0},attributes:{type:Object,state:!0},device:{type:String,state:!0},attr1:{type:String,state:!0},attr2:{type:String,state:!0}};constructor(){super(),this.devices=void 0,this.attributes=void 0,this.dev=void 0,this.attr1=void 0,this.attr2=void 0}render(){return Kt` ${this.devices?this.renderDevicesSelect():Kt``} ${this.attributes?this.renderAttributesSelect():ee} @@ -543,11 +595,11 @@ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the ${this.nodata===!0?Kt``:ee} - `}updated(h){h.mobileView!=this.mobileView&&(this.chart.options.plugins.zoom.pan.enabled=!this.mobileView,this.chart.options.plugins.zoom.zoom.pinch.enabled=!this.mobileView)}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m");let h=await Ze.fetchSupportedAttributes(),f=await Ze.fetchMonitoredDevices(),C=await Ze.fetchAttributeData(this.config.attr,this.config.devs,this.config.precision),H=os.colors(),X=[];for(let at of this.config.devs)X.push({label:f.find(q=>q.id==at).name,data:C[`dev_${at}`],pointStyle:!1,borderWidth:1.2,tension:.5,unit:h[this.config.attr].unit,ref:`dev_${at}`});if(this.config.devs.length<=2)for(let at=0;atthis.classList.remove("empty","spinner"),200)}firstUpdated(){this.chart=new Chart(this.renderRoot.querySelector("canvas"),Ei.defaultConfig(this.mobileView)),this.chart.canvas.style.touchAction="pan-y"}async changePrecision(h){this.config.precision=h.detail,await this.refresh(),this.chart.resetZoom()}async refresh(){this.classList.add("spinner");let h=await Ze.fetchAttributeData(this.config.attr,this.config.devs,this.config.precision);this.chart.data.datasets.forEach(f=>f.data=h[f.ref]),this.chart.update("none"),Ei.updateChartType(this.chart),this.classList.remove("spinner")}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.scale=h,this.chart&&(h=="auto"?(delete this.chart.options.scales.y.suggestedMin,delete this.chart.options.scales.y.suggestedMax):(this.chart.options.scales.y.suggestedMin=this.attrMin,this.chart.options.scales.y.suggestedMax=this.attrMax),this.chart.update())}},Xn=class extends ke{static properties={devices:{type:Object,state:!0},attributes:{type:Object,state:!0},attr:{type:String,state:!0},devs:{type:Object,state:!0}};constructor(){super(),this.devices=void 0,this.attributes=void 0,this.attr=void 0,this.devs=[]}render(){return Kt` + `}updated(h){h.mobileView!=this.mobileView&&(this.chart.options.plugins.zoom.pan.enabled=!this.mobileView,this.chart.options.plugins.zoom.zoom.pinch.enabled=!this.mobileView)}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m");let h=await Ze.fetchSupportedAttributes(),f=await Ze.fetchMonitoredDevices(),C=await Ze.fetchAttributeData(this.config.attr,this.config.devs,this.config.precision),I=os.colors(),X=[];for(let at of this.config.devs)X.push({label:f.find(q=>q.id==at).name,data:C[`dev_${at}`],pointStyle:!1,borderWidth:1.2,tension:.5,unit:h[this.config.attr].unit,ref:`dev_${at}`});if(this.config.devs.length<=2)for(let at=0;atthis.classList.remove("empty","spinner"),200)}firstUpdated(){this.chart=new Chart(this.renderRoot.querySelector("canvas"),Ei.defaultConfig(this.mobileView)),this.chart.canvas.style.touchAction="pan-y"}async changePrecision(h){this.config.precision=h.detail,await this.refresh(),this.chart.resetZoom()}async refresh(){this.classList.add("spinner");let h=await Ze.fetchAttributeData(this.config.attr,this.config.devs,this.config.precision);this.chart.data.datasets.forEach(f=>f.data=h[f.ref]),this.chart.update("none"),Ei.updateChartType(this.chart),this.classList.remove("spinner")}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.scale=h,this.chart&&(h=="auto"?(delete this.chart.options.scales.y.suggestedMin,delete this.chart.options.scales.y.suggestedMax):(this.chart.options.scales.y.suggestedMin=this.attrMin,this.chart.options.scales.y.suggestedMax=this.attrMax),this.chart.update())}},Xn=class extends ke{static properties={devices:{type:Object,state:!0},attributes:{type:Object,state:!0},attr:{type:String,state:!0},devs:{type:Object,state:!0}};constructor(){super(),this.devices=void 0,this.attributes=void 0,this.attr=void 0,this.devs=[]}render(){return Kt` ${this.attributes?this.renderAttributesSelect():Kt``} ${this.attr?this.renderDevicesSelect():ee} - `}connectedCallback(){super.connectedCallback(),Ze.fetchMonitoredDevices().then(h=>{this.devices=h;let f=new Set;h.forEach(C=>C.attrs.forEach(H=>f.add(H))),this.attributes=[...f].sort()})}createRenderRoot(){return this}renderAttributesSelect(){return setTimeout(()=>this.renderRoot.querySelector("#attr").focus(),0),Kt` + `}connectedCallback(){super.connectedCallback(),Ze.fetchMonitoredDevices().then(h=>{this.devices=h;let f=new Set;h.forEach(C=>C.attrs.forEach(I=>f.add(I))),this.attributes=[...f].sort()})}createRenderRoot(){return this}renderAttributesSelect(){return setTimeout(()=>this.renderRoot.querySelector("#attr").focus(),0),Kt`