(()=>{var Ah=(_=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:(h,u)=>(typeof require<"u"?require:h)[u]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});var gn=globalThis,Io=gn.ShadowRoot&&(gn.ShadyCSS===void 0||gn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Bo=Symbol(),za=new WeakMap,pn=class{constructor(h,u,k){if(this._$cssResult$=!0,k!==Bo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=h,this.t=u}get styleSheet(){let h=this.i,u=this.t;if(Io&&h===void 0){let k=u!==void 0&&u.length===1;k&&(h=za.get(u)),h===void 0&&((this.i=h=new CSSStyleSheet).replaceSync(this.cssText),k&&za.set(u,h))}return h}toString(){return this.cssText}},Ph=_=>new pn(typeof _=="string"?_:_+"",void 0,Bo),Ft=(_,...h)=>{let u=_.length===1?_[0]:h.reduce((k,P,z)=>k+(L=>{if(L._$cssResult$===!0)return L.cssText;if(typeof L=="number")return L;throw Error("Value passed to 'css' function must be a 'css' function result: "+L+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(P)+_[z+1],_[0]);return new pn(u,_,Bo)},Rh=(_,h)=>{if(Io)_.adoptedStyleSheets=h.map(u=>u instanceof CSSStyleSheet?u:u.styleSheet);else for(let u of h){let k=document.createElement("style"),P=gn.litNonce;P!==void 0&&k.setAttribute("nonce",P),k.textContent=u.cssText,_.appendChild(k)}},$a=Io?_=>_:_=>_ instanceof CSSStyleSheet?(h=>{let u="";for(let k of h.cssRules)u+=k.cssText;return Ph(u)})(_):_,{is:Oh,defineProperty:Lh,getOwnPropertyDescriptor:zh,getOwnPropertyNames:$h,getOwnPropertySymbols:Hh,getPrototypeOf:Nh}=Object,Sn=globalThis,Ha=Sn.trustedTypes,Ih=Ha?Ha.emptyScript:"",Bh=Sn.reactiveElementPolyfillSupport,Ss=(_,h)=>_,$o={toAttribute(_,h){switch(h){case Boolean:_=_?Ih:null;break;case Object:case Array:_=_==null?_:JSON.stringify(_)}return _},fromAttribute(_,h){let u=_;switch(h){case Boolean:u=_!==null;break;case Number:u=_===null?null:Number(_);break;case Object:case Array:try{u=JSON.parse(_)}catch{u=null}}return u}},Qa=(_,h)=>!Oh(_,h),Na={attribute:!0,type:String,converter:$o,reflect:!1,hasChanged:Qa};Symbol.metadata??=Symbol("metadata"),Sn.litPropertyMetadata??=new WeakMap;var li=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,u=Na){if(u.state&&(u.attribute=!1),this.o(),this.elementProperties.set(h,u),!u.noAccessor){let k=Symbol(),P=this.getPropertyDescriptor(h,k,u);P!==void 0&&Lh(this.prototype,h,P)}}static getPropertyDescriptor(h,u,k){let{get:P,set:z}=zh(this.prototype,h)??{get(){return this[u]},set(L){this[u]=L}};return{get(){return P?.call(this)},set(L){let G=P?.call(this);z.call(this,L),this.requestUpdate(h,G,k)},configurable:!0,enumerable:!0}}static getPropertyOptions(h){return this.elementProperties.get(h)??Na}static o(){if(this.hasOwnProperty(Ss("elementProperties")))return;let h=Nh(this);h.finalize(),h.l!==void 0&&(this.l=[...h.l]),this.elementProperties=new Map(h.elementProperties)}static finalize(){if(this.hasOwnProperty(Ss("finalized")))return;if(this.finalized=!0,this.o(),this.hasOwnProperty(Ss("properties"))){let u=this.properties,k=[...$h(u),...Hh(u)];for(let P of k)this.createProperty(P,u[P])}let h=this[Symbol.metadata];if(h!==null){let u=litPropertyMetadata.get(h);if(u!==void 0)for(let[k,P]of u)this.elementProperties.set(k,P)}this.u=new Map;for(let[u,k]of this.elementProperties){let P=this.p(u,k);P!==void 0&&this.u.set(P,u)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(h){let u=[];if(Array.isArray(h)){let k=new Set(h.flat(1/0).reverse());for(let P of k)u.unshift($a(P))}else h!==void 0&&u.push($a(h));return u}static p(h,u){let k=u.attribute;return k===!1?void 0:typeof k=="string"?k: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,u=this.constructor.elementProperties;for(let k of u.keys())this.hasOwnProperty(k)&&(h.set(k,this[k]),delete this[k]);h.size>0&&(this.v=h)}createRenderRoot(){let h=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Rh(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,u,k){this._$AK(h,k)}C(h,u){let k=this.constructor.elementProperties.get(h),P=this.constructor.p(h,k);if(P!==void 0&&k.reflect===!0){let z=(k.converter?.toAttribute!==void 0?k.converter:$o).toAttribute(u,k.type);this.m=h,z==null?this.removeAttribute(P):this.setAttribute(P,z),this.m=null}}_$AK(h,u){let k=this.constructor,P=k.u.get(h);if(P!==void 0&&this.m!==P){let z=k.getPropertyOptions(P),L=typeof z.converter=="function"?{fromAttribute:z.converter}:z.converter?.fromAttribute!==void 0?z.converter:$o;this.m=P,this[P]=L.fromAttribute(u,z.type),this.m=null}}requestUpdate(h,u,k){if(h!==void 0){if(k??=this.constructor.getPropertyOptions(h),!(k.hasChanged??Qa)(this[h],u))return;this.T(h,u,k)}this.isUpdatePending===!1&&(this.S=this.A())}T(h,u,k){this._$AL.has(h)||this._$AL.set(h,u),k.reflect===!0&&this.m!==h&&(this.M??=new Set).add(h)}async A(){this.isUpdatePending=!0;try{await this.S}catch(u){Promise.reject(u)}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[P,z]of this.v)this[P]=z;this.v=void 0}let k=this.constructor.elementProperties;if(k.size>0)for(let[P,z]of k)z.wrapped!==!0||this._$AL.has(P)||this[P]===void 0||this.T(P,this[P],z)}let h=!1,u=this._$AL;try{h=this.shouldUpdate(u),h?(this.willUpdate(u),this.P?.forEach(k=>k.hostUpdate?.()),this.update(u)):this.k()}catch(k){throw h=!1,this.k(),k}h&&this._$AE(u)}willUpdate(h){}_$AE(h){this.P?.forEach(u=>u.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(u=>this.C(u,this[u])),this.k()}updated(h){}firstUpdated(h){}};li.elementStyles=[],li.shadowRootOptions={mode:"open"},li[Ss("elementProperties")]=new Map,li[Ss("finalized")]=new Map,Bh?.({ReactiveElement:li}),(Sn.reactiveElementVersions??=[]).push("2.0.4");var Fo=globalThis,fn=Fo.trustedTypes,Ia=fn?fn.createPolicy("lit-html",{createHTML:_=>_}):void 0,Uo="$lit$",Ze=`lit$${Math.random().toFixed(9).slice(2)}$`,Wo="?"+Ze,Fh=`<${Wo}>`,Si=document,Es=()=>Si.createComment(""),Ts=_=>_===null||typeof _!="object"&&typeof _!="function",Ja=Array.isArray,tl=_=>Ja(_)||typeof _?.[Symbol.iterator]=="function",Oo=`[ \f\r]`,Ms=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ba=/-->/g,Fa=/>/g,ki=RegExp(`>|${Oo}(?:([^\\s"'>=/]+)(${Oo}*=${Oo}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ua=/'/g,Wa=/"/g,el=/^(?:script|style|textarea|title)$/i,il=_=>(h,...u)=>({_$litType$:_,strings:h,values:u}),at=il(1),Uh=il(2),Bt=Symbol.for("lit-noChange"),Rt=Symbol.for("lit-nothing"),Va=new WeakMap,Mi=Si.createTreeWalker(Si,129);function sl(_,h){if(!Array.isArray(_)||!_.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ia!==void 0?Ia.createHTML(h):h}var nl=(_,h)=>{let u=_.length-1,k=[],P,z=h===2?"":"",L=Ms;for(let G=0;G"?(L=P??Ms,X=-1):ut[1]===void 0?X=-2:(X=L.lastIndex-ut[2].length,K=ut[1],L=ut[3]===void 0?ki:ut[3]==='"'?Wa:Ua):L===Wa||L===Ua?L=ki:L===Ba||L===Fa?L=Ms:(L=ki,P=void 0);let ft=L===ki&&_[G+1].startsWith("/>")?" ":"";z+=L===Ms?U+Fh:X>=0?(k.push(K),U.slice(0,X)+Uo+U.slice(X)+Ze+ft):U+Ze+(X===-2?G:ft)}return[sl(_,z+(_[u]||"")+(h===2?"":"")),k]},Ds=class _{constructor({strings:h,_$litType$:u},k){let P;this.parts=[];let z=0,L=0,G=h.length-1,U=this.parts,[K,ut]=nl(h,u);if(this.el=_.createElement(K,k),Mi.currentNode=this.el.content,u===2){let X=this.el.content.firstChild;X.replaceWith(...X.childNodes)}for(;(P=Mi.nextNode())!==null&&U.length0){P.textContent=fn?fn.emptyScript:"";for(let ft=0;ft2||k[0]!==""||k[1]!==""?(this._$AH=Array(k.length-1).fill(new String),this.strings=k):this._$AH=Rt}_$AI(h,u=this,k,P){let z=this.strings,L=!1;if(z===void 0)h=Ci(this,h,u,0),L=!Ts(h)||h!==this._$AH&&h!==Bt,L&&(this._$AH=h);else{let G=h,U,K;for(h=z[0],U=0;U{let k=u?.renderBefore??h,P=k._$litPart$;if(P===void 0){let z=u?.renderBefore??null;k._$litPart$=P=new Cn(h.insertBefore(Es(),z),z,void 0,u??{})}return P._$AI(_),P};var Ct=class extends li{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 u=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(h),this.ht=rl(u,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.ht?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.ht?.setConnected(!1)}render(){return Bt}};Ct._$litElement$=!0,Ct.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:Ct});var jh=globalThis.litElementPolyfillSupport;jh?.({LitElement:Ct});(globalThis.litElementVersions??=[]).push("4.0.6");var{Y:Yh}=Wh,Gh=_=>_===null||typeof _!="object"&&typeof _!="function";var ja=(_,h)=>h===void 0?_?._$litType$!==void 0:_?._$litType$===h,qh=_=>_?._$litType$?.h!=null;var al=_=>_.strings===void 0,Ya=()=>document.createComment(""),hi=(_,h,u)=>{let k=_._$AA.parentNode,P=h===void 0?_._$AB:h._$AA;if(u===void 0){let z=k.insertBefore(Ya(),P),L=k.insertBefore(Ya(),P);u=new Yh(z,L,_,_.options)}else{let z=u._$AB.nextSibling,L=u._$AM,G=L!==_;if(G){let U;u._$AQ?.(_),u._$AM=_,u._$AP!==void 0&&(U=_._$AU)!==L._$AU&&u._$AP(U)}if(z!==P||G){let U=u._$AA;for(;U!==z;){let K=U.nextSibling;k.insertBefore(U,P),U=K}}}return u},ai=(_,h,u=_)=>(_._$AI(h,u),_),Xh={},As=(_,h=Xh)=>_._$AH=h,Ho=_=>_._$AH,Lo=_=>{_._$AP?.(!1,!0);let h=_._$AA,u=_._$AB.nextSibling;for(;h!==u;){let k=h.nextSibling;h.remove(),h=k}},ll=_=>{_._$AR()};var pe=_=>(...h)=>({_$litDirective$:_,values:h}),Ee=class{constructor(h){}get _$AU(){return this._$AM._$AU}_$AT(h,u,k){this.nt=h,this._$AM=u,this.rt=k}_$AS(h,u){return this.update(h,u)}update(h,u){return this.render(...u)}};var Cs=(_,h)=>{let u=_._$AN;if(u===void 0)return!1;for(let k of u)k._$AO?.(h,!1),Cs(k,h);return!0},wn=_=>{let h,u;do{if((h=_._$AM)===void 0)break;u=h._$AN,u.delete(_),_=h}while(u?.size===0)},hl=_=>{for(let h;h=_._$AM;_=h){let u=h._$AN;if(u===void 0)h._$AN=u=new Set;else if(u.has(_))break;u.add(_),Qh(h)}};function Zh(_){this._$AN!==void 0?(wn(this),this._$AM=_,hl(this)):this._$AM=_}function Kh(_,h=!1,u=0){let k=this._$AH,P=this._$AN;if(P!==void 0&&P.size!==0)if(h)if(Array.isArray(k))for(let z=u;z{_.type==2&&(_._$AP??=Kh,_._$AQ??=Zh)},Ps=class extends Ee{constructor(){super(...arguments),this._$AN=void 0}_$AT(h,u,k){super._$AT(h,u,k),hl(this),this.isConnected=h._$AU}_$AO(h,u=!0){h!==this.isConnected&&(this.isConnected=h,h?this.reconnected?.():this.disconnected?.()),u&&(Cs(this,h),wn(this))}setValue(h){if(al(this.nt))this.nt._$AI(h,this);else{let u=[...this.nt._$AH];u[this.rt]=h,this.nt._$AI(u,this,0)}}disconnected(){}reconnected(){}};var _n=class{constructor(h){this.ct=h}disconnect(){this.ct=void 0}reconnect(h){this.ct=h}deref(){return this.ct}},kn=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 Mn=class extends Ps{constructor(){super(...arguments),this.dt=new _n(this),this.ft=new kn}render(h,u){return Bt}update(h,[u,k]){if(this.isConnected||this.disconnected(),u===this.vt)return Bt;this.vt=u;let P=0,{dt:z,ft:L}=this;return(async(G,U)=>{for await(let K of G)if(await U(K)===!1)return})(u,async G=>{for(;L.get();)await L.get();let U=z.deref();if(U!==void 0){if(U.vt!==u)return!1;k!==void 0&&(G=k(G,P)),U.commitValue(G,P),P++}return!0}),Bt}commitValue(h,u){this.setValue(h)}disconnected(){this.dt.disconnect(),this.ft.pause()}reconnected(){this.dt.reconnect(this),this.ft.resume()}},rc=pe(Mn),ac=pe(class extends Mn{constructor(_){if(super(_),_.type!==2)throw Error("asyncAppend can only be used in child expressions")}update(_,h){return this.ht=_,super.update(_,h)}commitValue(_,h){h===0&&ll(this.ht);let u=hi(this.ht);ai(u,_)}}),Ga=_=>qh(_)?_._$litType$.h:_.strings,lc=pe(class extends Ee{constructor(_){super(_),this.yt=new WeakMap}render(_){return[_]}update(_,[h]){let u=ja(this.bt)?Ga(this.bt):null,k=ja(h)?Ga(h):null;if(u!==null&&(k===null||u!==k)){let P=Ho(_).pop(),z=this.yt.get(u);if(z===void 0){let L=document.createDocumentFragment();z=rl(Rt,L),z.setConnected(!1),this.yt.set(u,z)}As(z,[P]),hi(z,void 0,P)}if(k!==null){if(u===null||u!==k){let P=this.yt.get(k);if(P!==void 0){let z=Ho(P).pop();ll(_),hi(_,void 0,z),As(_,[z])}}this.bt=h}else this.bt=void 0;return this.render(h)}});var hc=pe(class extends Ee{constructor(_){if(super(_),_.type!==1||_.name!=="class"||_.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(_){return" "+Object.keys(_).filter(h=>_[h]).join(" ")+" "}update(_,[h]){if(this.gt===void 0){this.gt=new Set,_.strings!==void 0&&(this.wt=new Set(_.strings.join(" ").split(/\s/).filter(k=>k!=="")));for(let k in h)h[k]&&!this.wt?.has(k)&&this.gt.add(k);return this.render(h)}let u=_.element.classList;for(let k of this.gt)k in h||(u.remove(k),this.gt.delete(k));for(let k in h){let P=!!h[k];P===this.gt.has(k)||this.wt?.has(k)||(P?(u.add(k),this.gt.add(k)):(u.remove(k),this.gt.delete(k)))}return Bt}}),Jh={},cc=pe(class extends Ee{constructor(){super(...arguments),this._t=Jh}render(_,h){return h()}update(_,[h,u]){if(Array.isArray(h)){if(Array.isArray(this._t)&&this._t.length===h.length&&h.every((k,P)=>k===this._t[P]))return Bt}else if(this._t===h)return Bt;return this._t=Array.isArray(h)?Array.from(h):h,this.render(h,u)}});var dc=pe(class extends Ee{constructor(){super(...arguments),this.key=Rt}render(_,h){return this.key=_,h}update(_,[h,u]){return h!==this.key&&(As(_),this.key=h),u}}),uc=pe(class extends Ee{constructor(_){if(super(_),_.type!==3&&_.type!==1&&_.type!==4)throw Error("The `live` directive is not allowed on child or event bindings");if(!al(_))throw Error("`live` bindings can only contain a single expression")}render(_){return _}update(_,[h]){if(h===Bt||h===Rt)return h;let u=_.element,k=_.name;if(_.type===3){if(h===u[k])return Bt}else if(_.type===4){if(!!h===u.hasAttribute(k))return Bt}else if(_.type===1&&u.getAttribute(k)===h+"")return Bt;return As(_),h}});var zo=new WeakMap,gc=pe(class extends Ps{render(_){return Rt}update(_,[h]){let u=h!==this.ct;return u&&this.ct!==void 0&&this.St(void 0),(u||this.$t!==this.Tt)&&(this.ct=h,this.xt=_.options?.host,this.St(this.Tt=_.element)),Rt}St(_){if(this.isConnected||(_=void 0),typeof this.ct=="function"){let h=this.xt??globalThis,u=zo.get(h);u===void 0&&(u=new WeakMap,zo.set(h,u)),u.get(this.ct)!==void 0&&this.ct.call(this.xt,void 0),u.set(this.ct,_),_!==void 0&&this.ct.call(this.xt,_)}else this.ct.value=_}get $t(){return typeof this.ct=="function"?zo.get(this.xt??globalThis)?.get(this.ct):this.ct?.value}disconnected(){this.$t===this.Tt&&this.St(void 0)}reconnected(){this.St(this.Tt)}}),qa=(_,h,u)=>{let k=new Map;for(let P=h;P<=u;P++)k.set(_[P],P);return k},pc=pe(class extends Ee{constructor(_){if(super(_),_.type!==2)throw Error("repeat() can only be used in text expressions")}Et(_,h,u){let k;u===void 0?u=h:h!==void 0&&(k=h);let P=[],z=[],L=0;for(let G of _)P[L]=k?k(G,L):L,z[L]=u(G,L),L++;return{values:z,keys:P}}render(_,h,u){return this.Et(_,h,u).values}update(_,[h,u,k]){let P=Ho(_),{values:z,keys:L}=this.Et(h,u,k);if(!Array.isArray(P))return this.Ct=L,z;let G=this.Ct??=[],U=[],K,ut,X=0,it=P.length-1,ft=0,bt=z.length-1;for(;X<=it&&ft<=bt;)if(P[X]===null)X++;else if(P[it]===null)it--;else if(G[X]===L[ft])U[ft]=ai(P[X],z[ft]),X++,ft++;else if(G[it]===L[bt])U[bt]=ai(P[it],z[bt]),it--,bt--;else if(G[X]===L[bt])U[bt]=ai(P[X],z[bt]),hi(_,U[bt+1],P[X]),X++,bt--;else if(G[it]===L[ft])U[ft]=ai(P[it],z[ft]),hi(_,P[X],P[it]),it--,ft++;else if(K===void 0&&(K=qa(L,ft,bt),ut=qa(G,X,it)),K.has(G[X]))if(K.has(G[it])){let Tt=ut.get(L[ft]),Dt=Tt!==void 0?P[Tt]:null;if(Dt===null){let kt=hi(_,P[X]);ai(kt,z[ft]),U[ft]=kt}else U[ft]=ai(Dt,z[ft]),hi(_,P[X],Dt),P[Tt]=null;ft++}else Lo(P[it]),it--;else Lo(P[X]),X++;for(;ft<=bt;){let Tt=hi(_,U[bt+1]);ai(Tt,z[ft]),U[ft++]=Tt}for(;X<=it;){let Tt=P[X++];Tt!==null&&Lo(Tt)}return this.Ct=L,As(_,U),Bt}}),cl="important",tc=" !"+cl,fc=pe(class extends Ee{constructor(_){if(super(_),_.type!==1||_.name!=="style"||_.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(_){return Object.keys(_).reduce((h,u)=>{let k=_[u];return k==null?h:h+`${u=u.includes("-")?u:u.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${k};`},"")}update(_,[h]){let{style:u}=_.element;if(this.Pt===void 0)return this.Pt=new Set(Object.keys(h)),this.render(h);for(let k of this.Pt)h[k]==null&&(this.Pt.delete(k),k.includes("-")?u.removeProperty(k):u[k]=null);for(let k in h){let P=h[k];if(P!=null){this.Pt.add(k);let z=typeof P=="string"&&P.endsWith(tc);k.includes("-")||z?u.setProperty(k,z?P.slice(0,-11):P,z?cl:""):u[k]=P}}return Bt}}),mc=pe(class extends Ee{constructor(_){if(super(_),_.type!==2)throw Error("templateContent can only be used in child bindings")}render(_){return this.At===_?Bt:(this.At=_,document.importNode(_.content,!0))}}),Vi=class extends Ee{constructor(h){if(super(h),this.bt=Rt,h.type!==2)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(h){if(h===Rt||h==null)return this.kt=void 0,this.bt=h;if(h===Bt)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 u=[h];return u.raw=u,this.kt={_$litType$:this.constructor.resultType,strings:u,values:[]}}};Vi.directiveName="unsafeHTML",Vi.resultType=1;var En=pe(Vi);var Rs=class extends Vi{};Rs.directiveName="unsafeSVG",Rs.resultType=2;var bc=pe(Rs),Xa=_=>!Gh(_)&&typeof _.then=="function",Za=1073741823;var No=class extends Ps{constructor(){super(...arguments),this.Mt=Za,this.Ut=[],this.dt=new _n(this),this.ft=new kn}render(...h){return h.find(u=>!Xa(u))??Bt}update(h,u){let k=this.Ut,P=k.length;this.Ut=u;let z=this.dt,L=this.ft;this.isConnected||this.disconnected();for(let G=0;Gthis.Mt);G++){let U=u[G];if(!Xa(U))return this.Mt=G,U;G{for(;L.get();)await L.get();let ut=z.deref();if(ut!==void 0){let X=ut.Ut.indexOf(U);X>-1&&X{if(_?.r===ec)return _?._$litStatic$};var Ka=new Map,dl=_=>(h,...u)=>{let k=u.length,P,z,L=[],G=[],U,K=0,ut=!1;for(;K(()=>{"use strict";var _={d:(J,r)=>{for(var c in r)_.o(r,c)&&!_.o(J,c)&&Object.defineProperty(J,c,{enumerable:!0,get:r[c]})},o:(J,r)=>Object.prototype.hasOwnProperty.call(J,r)},h={};_.d(h,{GridStack:()=>pt});class u{static getElements(r,c=document){if(typeof r=="string"){let b="getElementById"in c?c:void 0;if(b&&!isNaN(+r[0])){let E=b.getElementById(r);return E?[E]:[]}let w=c.querySelectorAll(r);return w.length||r[0]==="."||r[0]==="#"||(w=c.querySelectorAll("."+r),w.length||(w=c.querySelectorAll("#"+r))),Array.from(w)}return[r]}static getElement(r,c=document){if(typeof r=="string"){let b="getElementById"in c?c:void 0;if(!r.length)return null;if(b&&r[0]==="#")return b.getElementById(r.substring(1));if(r[0]==="#"||r[0]==="."||r[0]==="[")return c.querySelector(r);if(b&&!isNaN(+r[0]))return b.getElementById(r);let w=c.querySelector(r);return b&&!w&&(w=b.getElementById(r)),w||(w=c.querySelector("."+r)),w}return r}static shouldSizeToContent(r,c=!1){return r?.grid&&(c?r.sizeToContent===!0||r.grid.opts.sizeToContent===!0&&r.sizeToContent===void 0:!!r.sizeToContent||r.grid.opts.sizeToContent&&r.sizeToContent!==!1)}static isIntercepted(r,c){return!(r.y>=c.y+c.h||r.y+r.h<=c.y||r.x+r.w<=c.x||r.x>=c.x+c.w)}static isTouching(r,c){return u.isIntercepted(r,{x:c.x-.5,y:c.y-.5,w:c.w+1,h:c.h+1})}static areaIntercept(r,c){let b=r.x>c.x?r.x:c.x,w=r.x+r.wc.y?r.y:c.y,O=r.y+r.h{let O=c*((w.y??1e4)-(E.y??1e4));return O===0?c*((w.x??1e4)-(E.x??1e4)):O})}static find(r,c){return c?r.find(b=>b.id===c):void 0}static createStylesheet(r,c,b){let w=document.createElement("style"),E=b?.nonce;return E&&(w.nonce=E),w.setAttribute("type","text/css"),w.setAttribute("gs-style-id",r),w.styleSheet?w.styleSheet.cssText="":w.appendChild(document.createTextNode("")),c?c.insertBefore(w,c.firstChild):(c=document.getElementsByTagName("head")[0]).appendChild(w),w.sheet}static removeStylesheet(r,c){let b=(c||document).querySelector("STYLE[gs-style-id="+r+"]");b&&b.parentNode&&b.remove()}static addCSSRule(r,c,b){typeof r.addRule=="function"?r.addRule(c,b):typeof r.insertRule=="function"&&r.insertRule(`${c}{${b}}`)}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 c,b="px";if(typeof r=="string")if(r==="auto"||r==="")c=0;else{let w=r.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!w)throw new Error(`Invalid height val = ${r}`);b=w[2]||"px",c=parseFloat(w[1])}else c=r;return{h:c,unit:b}}static defaults(r,...c){return c.forEach(b=>{for(let w in b){if(!b.hasOwnProperty(w))return;r[w]===null||r[w]===void 0?r[w]=b[w]:typeof b[w]=="object"&&typeof r[w]=="object"&&this.defaults(r[w],b[w])}}),r}static same(r,c){if(typeof r!="object")return r==c;if(typeof r!=typeof c||Object.keys(r).length!==Object.keys(c).length)return!1;for(let b in r)if(r[b]!==c[b])return!1;return!0}static copyPos(r,c,b=!1){return c.x!==void 0&&(r.x=c.x),c.y!==void 0&&(r.y=c.y),c.w!==void 0&&(r.w=c.w),c.h!==void 0&&(r.h=c.h),b&&(c.minW&&(r.minW=c.minW),c.minH&&(r.minH=c.minH),c.maxW&&(r.maxW=c.maxW),c.maxH&&(r.maxH=c.maxH)),r}static samePos(r,c){return r&&c&&r.x===c.x&&r.y===c.y&&(r.w||1)===(c.w||1)&&(r.h||1)===(c.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,c){if(typeof r=="object"&&typeof c=="object")for(let b in r){let w=r[b],E=c[b];b[0]==="_"||w===E?delete r[b]:w&&typeof w=="object"&&E!==void 0&&(u.removeInternalAndSame(w,E),Object.keys(w).length||delete r[b])}}static removeInternalForSave(r,c=!0){for(let b in r)b[0]!=="_"&&r[b]!==null&&r[b]!==void 0||delete r[b];delete r.grid,c&&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,c){let b=!1;return(...w)=>{b||(b=!0,setTimeout(()=>{r(...w),b=!1},c))}}static removePositioningStyles(r){let c=r.style;c.position&&c.removeProperty("position"),c.left&&c.removeProperty("left"),c.top&&c.removeProperty("top"),c.width&&c.removeProperty("width"),c.height&&c.removeProperty("height")}static getScrollElement(r){if(!r)return document.scrollingElement||document.documentElement;let c=getComputedStyle(r);return/(auto|scroll)/.test(c.overflow+c.overflowY)?r:this.getScrollElement(r.parentElement)}static updateScrollPosition(r,c,b){let w=r.getBoundingClientRect(),E=window.innerHeight||document.documentElement.clientHeight;if(w.top<0||w.bottom>E){let O=w.bottom-E,$=w.top,V=this.getScrollElement(r);if(V!==null){let B=V.scrollTop;w.top<0&&b<0?r.offsetHeight>E?V.scrollTop+=b:V.scrollTop+=Math.abs($)>Math.abs(b)?b:$:b>0&&(r.offsetHeight>E?V.scrollTop+=b:V.scrollTop+=O>b?b:O),c.top+=V.scrollTop-B}}}static updateScrollResize(r,c,b){let w=this.getScrollElement(c),E=w.clientHeight,O=w===this.getScrollElement()?0:w.getBoundingClientRect().top,$=r.clientY-O,V=$>E-b;$E===w)&&(b[w]=u.cloneDeep(r[w]));return b}static cloneNode(r){let c=r.cloneNode(!0);return c.removeAttribute("id"),c}static appendTo(r,c){let b;b=typeof c=="string"?u.getElement(c):c,b&&b.appendChild(r)}static addElStyles(r,c){if(c instanceof Object)for(let b in c)c.hasOwnProperty(b)&&(Array.isArray(c[b])?c[b].forEach(w=>{r.style[b]=w}):r.style[b]=c[b])}static initEvent(r,c){let b={type:c.type},w={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:c.target?c.target:r.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(E=>b[E]=r[E]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(E=>b[E]=r[E]),{...b,...w}}static simulateMouseEvent(r,c,b){let w=document.createEvent("MouseEvents");w.initMouseEvent(c,!0,!0,window,1,r.screenX,r.screenY,r.clientX,r.clientY,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,0,r.target),(b||r.target).dispatchEvent(w)}static getValuesFromTransformedElement(r){let c=document.createElement("div");u.addElStyles(c,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),r.appendChild(c);let b=c.getBoundingClientRect();return r.removeChild(c),c.remove(),{xScale:1/b.width,yScale:1/b.height,xOffset:b.left,yOffset:b.top}}static swap(r,c,b){if(!r)return;let w=r[c];r[c]=r[b],r[b]=w}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 k{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,c=!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,c&&this._packNodes(),this._notify())),this}_useEntireRowArea(r,c){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!r._moving||r._skipDown||c.y<=r.y)}_fixCollisions(r,c=r,b,w={}){if(this.sortNodes(-1),!(b=b||this.collide(r,c)))return!1;if(r._moving&&!w.nested&&!this.float&&this.swap(r,b))return!0;let E=c;!this._loading&&this._useEntireRowArea(r,c)&&(E={x:0,w:this.column,y:c.y,h:c.h},b=this.collide(r,E,w.skip));let O=!1,$={nested:!0,pack:!1};for(;b=b||this.collide(r,E,w.skip);){let V;if(b.locked||this._loading||r._moving&&!r._skipDown&&c.y>r.y&&!this.float&&(!this.collide(b,{...b,y:r.y},r)||!this.collide(b,{...b,y:c.y-b.h},r))?(r._skipDown=r._skipDown||c.y>r.y,V=this.moveNode(r,{...c,y:b.y+b.h,...$}),(b.locked||this._loading)&&V?u.copyPos(c,r):!b.locked&&V&&w.pack&&(this._packNodes(),c.y=b.y+b.h,u.copyPos(r,c)),O=O||V):V=this.moveNode(b,{...b,y:c.y+c.h,skip:r,...$}),!V)return O;b=void 0}return O}collide(r,c=r,b){let w=r._id,E=b?._id;return this.nodes.find(O=>O._id!==w&&O._id!==E&&u.isIntercepted(O,c))}collideAll(r,c=r,b){let w=r._id,E=b?._id;return this.nodes.filter(O=>O._id!==w&&O._id!==E&&u.isIntercepted(O,c))}directionCollideCoverage(r,c,b){if(!c.rect||!r._rect)return;let w,E=r._rect,O={...c.rect};O.y>E.y?(O.h+=O.y-E.y,O.y=E.y):O.h+=E.y-O.y,O.x>E.x?(O.w+=O.x-E.x,O.x=E.x):O.w+=E.x-O.x;let $=.5;for(let V of b){if(V.locked||!V._rect)break;let B=V._rect,W=Number.MAX_VALUE,tt=Number.MAX_VALUE;E.yB.y+B.h&&(W=(B.y+B.h-O.y)/B.h),E.xB.x+B.w&&(tt=(B.x+B.w-O.x)/B.w);let ot=Math.min(tt,W);ot>$&&($=ot,w=V)}return c.collide=w,w}cacheRects(r,c,b,w,E,O){return this.nodes.forEach($=>$._rect={y:$.y*c+b,x:$.x*r+O,w:$.w*r-O-w,h:$.h*c-b-E}),this}swap(r,c){if(!c||c.locked||!r||r.locked)return!1;function b(){let E=c.x,O=c.y;return c.x=r.x,c.y=r.y,r.h!=c.h?(r.x=E,r.y=c.y+c.h):r.w!=c.w?(r.x=c.x+c.w,r.y=O):(r.x=E,r.y=O),r._dirty=c._dirty=!0,!0}let w;if(r.w===c.w&&r.h===c.h&&(r.x===c.x||r.y===c.y)&&(w=u.isTouching(r,c)))return b();if(w!==!1){if(r.w===c.w&&r.x===c.x&&(w||(w=u.isTouching(r,c)))){if(c.y{let B;O.locked||(O.autoPosition=!0,r==="list"&&$&&(B=V[$-1])),this.addNode(O,!1,B)}),w||delete this._inColumnResize,b||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=u.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 c=r.y;for(;c>r._orig.y;)--c,this.collide(r,{x:r.x,y:c,w:r.w,h:r.h})||(r._dirty=!0,r.y=c)}):this.nodes.forEach((r,c)=>{if(!r.locked)for(;r.y>0;){let b=c===0?0:r.y-1;if(c!==0&&this.collide(r,{x:r.x,y:b,w:r.w,h:r.h}))break;r._dirty=r.y!==b,r.y=b}})),this}prepareNode(r,c){r._id=r._id??k._idSeq++,r.x!==void 0&&r.y!==void 0&&r.x!==null&&r.y!==null||(r.autoPosition=!0);let b={x:0,y:0,w:1,h:1};return u.defaults(r,b),r.autoPosition||delete r.autoPosition,r.noResize||delete r.noResize,r.noMove||delete r.noMove,u.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=b.x,r.autoPosition=!0),isNaN(r.y)&&(r.y=b.y,r.autoPosition=!0),isNaN(r.w)&&(r.w=b.w),isNaN(r.h)&&(r.h=b.h),this.nodeBoundFix(r,c),r}nodeBoundFix(r,c){let b=r._orig||u.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 w={...r};w.autoPosition||w.x===void 0?(delete w.x,delete w.y):w.x=Math.min(11,w.x),w.w=Math.min(12,w.w||1),this.cacheOneLayout(w,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&&(c?r.w=this.column-r.x:r.x=this.column-r.w),this.maxRow&&r.y+r.h>this.maxRow&&(c?r.h=this.maxRow-r.y:r.y=this.maxRow-r.h),u.samePos(r,b)||(r._dirty=!0),this}getDirtyNodes(r){return r?this.nodes.filter(c=>c._dirty&&!u.samePos(c,c._orig)):this.nodes.filter(c=>c._dirty)}_notify(r){if(this.batchMode||!this.onChange)return this;let c=(r||[]).concat(this.getDirtyNodes());return this.onChange(c),this}cleanNodes(){return this.batchMode||this.nodes.forEach(r=>{delete r._dirty,delete r._lastTried}),this}saveInitial(){return this.nodes.forEach(r=>{r._orig=u.copyPos({},r),delete r._dirty}),this._hasLocked=this.nodes.some(r=>r.locked),this}restoreInitial(){return this.nodes.forEach(r=>{u.samePos(r,r._orig)||(u.copyPos(r,r._orig),r._dirty=!0)}),this._notify(),this}findEmptyPosition(r,c=this.nodes,b=this.column,w){let E=!1;for(let O=w?w.y*b+(w.x+w.w):0;!E;++O){let $=O%b,V=Math.floor(O/b);if($+r.w>b)continue;let B={x:$,y:V,w:r.w,h:r.h};c.find(W=>u.isIntercepted(B,W))||(r.x===$&&r.y===V||(r._dirty=!0),r.x=$,r.y=V,delete r.autoPosition,E=!0)}return E}addNode(r,c=!1,b){let w;return this.nodes.find(E=>E._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,b)&&(delete r.autoPosition,w=!0),this.nodes.push(r),c&&this.addedNodes.push(r),w||this._fixCollisions(r),this.batchMode||this._packNodes()._notify(),r)}removeNode(r,c=!0,b=!1){return this.nodes.find(w=>w._id===r._id)?(b&&this.removedNodes.push(r),c&&(r._removeDOM=!0),this.nodes=this.nodes.filter(w=>w._id!==r._id),r._isAboutToRemove||this._packNodes(),this._notify([r]),this):this}removeAll(r=!0,c=!0){if(delete this._layouts,!this.nodes.length)return this;r&&this.nodes.forEach(w=>w._removeDOM=!0);let b=this.nodes;return this.removedNodes=c?b:[],this.nodes=[],this._notify(b)}moveNodeCheck(r,c){if(!this.changedPosConstrain(r,c))return!1;if(c.pack=!0,!this.maxRow)return this.moveNode(r,c);let b,w=new k({column:this.column,float:this.float,nodes:this.nodes.map(O=>O._id===r._id?(b={...O},b):{...O})});if(!b)return!1;let E=w.moveNode(b,c)&&w.getRow()<=Math.max(this.getRow(),this.maxRow);if(!E&&!c.resizing&&c.collide){let O=c.collide.el.gridstackNode;if(this.swap(r,O))return this._notify(),!0}return!!E&&(w.nodes.filter(O=>O._dirty).forEach(O=>{let $=this.nodes.find(V=>V._id===O._id);$&&(u.copyPos($,O),$._dirty=!0)}),this._notify(),!0)}willItFit(r){if(delete r._willFitPos,!this.maxRow)return!0;let c=new k({column:this.column,float:this.float,nodes:this.nodes.map(w=>({...w}))}),b={...r};return this.cleanupNode(b),delete b.el,delete b._id,delete b.content,delete b.grid,c.addNode(b),c.getRow()<=this.maxRow&&(r._willFitPos=u.copyPos({},b),!0)}changedPosConstrain(r,c){return c.w=c.w||r.w,c.h=c.h||r.h,r.x!==c.x||r.y!==c.y||(r.maxW&&(c.w=Math.min(c.w,r.maxW)),r.maxH&&(c.h=Math.min(c.h,r.maxH)),r.minW&&(c.w=Math.max(c.w,r.minW)),r.minH&&(c.h=Math.max(c.h,r.minH)),r.w!==c.w||r.h!==c.h)}moveNode(r,c){if(!r||!c)return!1;let b;c.pack!==void 0||this.batchMode||(b=c.pack=!0),typeof c.x!="number"&&(c.x=r.x),typeof c.y!="number"&&(c.y=r.y),typeof c.w!="number"&&(c.w=r.w),typeof c.h!="number"&&(c.h=r.h);let w=r.w!==c.w||r.h!==c.h,E=u.copyPos({},r,!0);if(u.copyPos(E,c),this.nodeBoundFix(E,w),u.copyPos(c,E),!c.forceCollide&&u.samePos(r,c))return!1;let O=u.copyPos({},r),$=this.collideAll(r,E,c.skip),V=!0;if($.length){let B=r._moving&&!c.nested,W=B?this.directionCollideCoverage(r,c,$):$[0];if(B&&W&&r.grid?.opts?.subGridDynamic&&!r.grid._isTemp){let tt=u.areaIntercept(c.rect,W._rect),ot=u.area(c.rect),_t=u.area(W._rect);tt/(ot<_t?ot:_t)>.8&&(W.grid.makeSubGrid(W.el,void 0,r),W=void 0)}W?V=!this._fixCollisions(r,E,W,c):(V=!1,b&&delete c.pack)}return V&&(r._dirty=!0,u.copyPos(r,E)),c.pack&&this._packNodes()._notify(),!u.samePos(r,O)}getRow(){return this.nodes.reduce((r,c)=>Math.max(r,c.y+c.h),0)}beginUpdate(r){return r._updating||(r._updating=!0,delete r._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){let r=this.nodes.find(c=>c._updating);return r&&(delete r._updating,delete r._skipDown),this}save(r=!0,c){let b=this._layouts?.length,w=b&&this.column!==b-1?this._layouts[b-1]:null,E=[];return this.sortNodes(),this.nodes.forEach(O=>{let $=w?.find(B=>B._id===O._id),V={...O,...$||{}};u.removeInternalForSave(V,!r),c&&c(O,V),E.push(V)}),E}layoutsNodesChange(r){return!this._layouts||this._inColumnResize||this._layouts.forEach((c,b)=>{if(!c||b===this.column)return this;if(b{if(!E._orig)return;let O=c.find($=>$._id===E._id);O&&(O.y>=0&&E.y!==E._orig.y&&(O.y+=E.y-E._orig.y),E.x!==E._orig.x&&(O.x=Math.round(E.x*w)),E.w!==E._orig.w&&(O.w=Math.round(E.w*w)))})}}),this}columnChanged(r,c,b="moveScale"){if(!this.nodes.length||!c||r===c)return this;if(b==="none")return this;let w=b==="compact"||b==="list";w&&this.sortNodes(1),cr&&this._layouts){let $=this._layouts[c]||[],V=this._layouts.length-1;!$.length&&r!==V&&this._layouts[V]?.length&&(r=V,this._layouts[V].forEach(B=>{let W=O.find(tt=>tt._id===B._id);W&&(w||B.autoPosition||(W.x=B.x??W.x,W.y=B.y??W.y),W.w=B.w??W.w,B.x!=null&&B.y!==void 0||(W.autoPosition=!0))})),$.forEach(B=>{let W=O.findIndex(tt=>tt._id===B._id);if(W!==-1){let tt=O[W];if(w)return void(tt.w=B.w);(B.autoPosition||isNaN(B.x)||isNaN(B.y))&&this.findEmptyPosition(B,E),B.autoPosition||(tt.x=B.x??tt.x,tt.y=B.y??tt.y,tt.w=B.w??tt.w,E.push(tt)),O.splice(W,1)}})}if(w)this.compact(b,!1);else{if(O.length)if(typeof b=="function")b(c,r,E,O);else{let $=w?1:c/r,V=b==="move"||b==="moveScale",B=b==="scale"||b==="moveScale";O.forEach(W=>{W.x=c===1?0:V?Math.round(W.x*$):Math.min(W.x,c-1),W.w=c===1||r===1?1:B?Math.round(W.w*$)||1:Math.min(W.w,c),E.push(W)}),O=[]}E=u.sort(E,-1),this._inColumnResize=!0,this.nodes=[],E.forEach($=>{this.addNode($,!1),delete $._orig})}return this.nodes.forEach($=>delete $._orig),this.batchUpdate(!1,!w),delete this._inColumnResize,this}cacheLayout(r,c,b=!1){let w=[];return r.forEach((E,O)=>{if(E._id===void 0){let $=E.id?this.nodes.find(V=>V.id===E.id):void 0;E._id=$?._id??k._idSeq++}w[O]={x:E.x,y:E.y,w:E.w,_id:E._id}}),this._layouts=b?[]:this._layouts||[],this._layouts[c]=w,this}cacheOneLayout(r,c){r._id=r._id??k._idSeq++;let b={x:r.x,y:r.y,w:r.w,_id:r._id};(r.autoPosition||r.x===void 0)&&(delete b.x,delete b.y,r.autoPosition&&(b.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[c]=this._layouts[c]||[];let w=this.findCacheLayout(r,c);return w===-1?this._layouts[c].push(b):this._layouts[c][w]=b,this}findCacheLayout(r,c){return this._layouts?.[c]?.findIndex(b=>b._id===r._id)??-1}removeNodeFromLayoutCache(r){if(this._layouts)for(let c=0;c0||navigator.msMaxTouchPoints>0);class U{}function K(J,r){if(J.touches.length>1)return;J.cancelable&&J.preventDefault();let c=J.changedTouches[0],b=document.createEvent("MouseEvents");b.initMouseEvent(r,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),J.target.dispatchEvent(b)}function ut(J,r){J.cancelable&&J.preventDefault();let c=document.createEvent("MouseEvents");c.initMouseEvent(r,!0,!0,window,1,J.screenX,J.screenY,J.clientX,J.clientY,!1,!1,!1,!1,0,null),J.target.dispatchEvent(c)}function X(J){U.touchHandled||(U.touchHandled=!0,K(J,"mousedown"))}function it(J){U.touchHandled&&K(J,"mousemove")}function ft(J){if(!U.touchHandled)return;U.pointerLeaveTimeout&&(window.clearTimeout(U.pointerLeaveTimeout),delete U.pointerLeaveTimeout);let r=!!L.dragElement;K(J,"mouseup"),r||K(J,"click"),U.touchHandled=!1}function bt(J){J.pointerType!=="mouse"&&J.target.releasePointerCapture(J.pointerId)}function Tt(J){L.dragElement&&J.pointerType!=="mouse"&&ut(J,"mouseenter")}function Dt(J){L.dragElement&&J.pointerType!=="mouse"&&(U.pointerLeaveTimeout=window.setTimeout(()=>{delete U.pointerLeaveTimeout,ut(J,"mouseleave")},10))}class kt{constructor(r,c,b){this.host=r,this.dir=c,this.option=b,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(`${kt.prefix}${this.dir}`),r.style.zIndex="100",r.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),G&&(this.el.addEventListener("touchstart",X),this.el.addEventListener("pointerdown",bt)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),G&&(this.el.removeEventListener("touchstart",X),this.el.removeEventListener("pointerdown",bt)),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),G&&(this.el.addEventListener("touchmove",it),this.el.addEventListener("touchend",ft)),r.stopPropagation(),r.preventDefault()}_mouseMove(r){let c=this.mouseDownEvent;this.moving?this._triggerEvent("move",r):Math.abs(r.x-c.x)+Math.abs(r.y-c.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),G&&(this.el.removeEventListener("touchmove",it),this.el.removeEventListener("touchend",ft)),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,c){return this.option[r]&&this.option[r](c),this}}kt.prefix="ui-resizable-";class $t{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(r,c){this._eventRegister[r]=c}off(r){delete this._eventRegister[r]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(r,c){if(!this.disabled&&this._eventRegister&&this._eventRegister[r])return this._eventRegister[r](c)}}class zt extends $t{constructor(r,c={}){super(),this.el=r,this.option=c,this.rectScale={x:1,y:1},this._ui=()=>{let b=this.el.parentElement.getBoundingClientRect(),w={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},E=this.temporalRect||w;return{position:{left:(E.left-b.left)*this.rectScale.x,top:(E.top-b.top)*this.rectScale.y},size:{width:E.width*this.rectScale.x,height:E.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,c){super.on(r,c)}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 c=r.handles&&r.handles!==this.option.handles,b=r.autoHide&&r.autoHide!==this.option.autoHide;return Object.keys(r).forEach(w=>this.option[w]=r[w]),c&&(this._removeHandlers(),this._setupHandlers()),b&&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),L.overResizeElement===this&&delete L.overResizeElement),this}_mouseOver(r){L.overResizeElement||L.dragElement||(L.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(r){L.overResizeElement===this&&(delete L.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(r=>r.trim()).map(r=>new kt(this.el,r,{start:c=>{this._resizeStart(c)},stop:c=>{this._resizeStop(c)},move:c=>{this._resizing(c,r)}})),this}_resizeStart(r){this.sizeToContent=u.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=u.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=r,this._setupHelper(),this._applyChange();let c=u.initEvent(r,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(c,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",c),this}_resizing(r,c){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(r,c),this._applyChange();let b=u.initEvent(r,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(b,this._ui()),this.triggerEvent("resize",b),this}_resizeStop(r){let c=u.initEvent(r,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(c),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",c),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=zt._originStyleProp.map(b=>this.el.style[b]),this.parentOriginStylePosition=this.el.parentElement.style.position;let r=this.el.parentElement,c=u.getValuesFromTransformedElement(r);return this.rectScale={x:c.xScale,y:c.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 zt._originStyleProp.forEach((r,c)=>{this.el.style[r]=this.elOriginStyleVal[c]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(r,c){let b=this.startEvent,w={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},E=r.clientX-b.clientX,O=this.sizeToContent?0:r.clientY-b.clientY,$,V;c.indexOf("e")>-1?w.width+=E:c.indexOf("w")>-1&&(w.width-=E,w.left+=E,$=!0),c.indexOf("s")>-1?w.height+=O:c.indexOf("n")>-1&&(w.height-=O,w.top+=O,V=!0);let B=this._constrainSize(w.width,w.height,$,V);return Math.round(w.width)!==Math.round(B.width)&&(c.indexOf("w")>-1&&(w.left+=w.width-B.width),w.width=B.width),Math.round(w.height)!==Math.round(B.height)&&(c.indexOf("n")>-1&&(w.top+=w.height-B.height),w.height=B.height),w}_constrainSize(r,c,b,w){let E=this.option,O=(b?E.maxWidthMoveLeft:E.maxWidth)||Number.MAX_SAFE_INTEGER,$=E.minWidth/this.rectScale.x||r,V=(w?E.maxHeightMoveUp:E.maxHeight)||Number.MAX_SAFE_INTEGER,B=E.minHeight/this.rectScale.y||c;return{width:Math.min(O,Math.max($,r)),height:Math.min(V,Math.max(B,c))}}_applyChange(){let r={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){let c=this.el.parentElement,{left:b,top:w}=c.getBoundingClientRect();r={left:b,top:w,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(c=>{let b=this.temporalRect[c],w=c==="width"||c==="left"?this.rectScale.x:c==="height"||c==="top"?this.rectScale.y:1;this.el.style[c]=(b-r[c])*w+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(r=>r.destroy()),delete this.handlers,this}}zt._originStyleProp=["width","height","position","left","top","opacity","zIndex"];class te extends $t{constructor(r,c={}){super(),this.el=r,this.option=c,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};let b=c.handle.substring(1),w=r.gridstackNode;this.dragEls=r.classList.contains(b)?[r]:w?.subGrid?[r.querySelector(c.handle)||r]:Array.from(r.querySelectorAll(c.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,c){super.on(r,c)}off(r){super.off(r)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(r=>{r.addEventListener("mousedown",this._mouseDown),G&&(r.addEventListener("touchstart",X),r.addEventListener("pointerdown",bt))}),this.el.classList.remove("ui-draggable-disabled"))}disable(r=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(c=>{c.removeEventListener("mousedown",this._mouseDown),G&&(c.removeEventListener("touchstart",X),c.removeEventListener("pointerdown",bt))}),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(c=>this.option[c]=r[c]),this}_mouseDown(r){if(!L.mouseHandled)return r.button!==0||!this.dragEls.find(c=>c===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 L.dragElement,delete L.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),G&&(r.target.addEventListener("touchmove",it),r.target.addEventListener("touchend",ft)),r.preventDefault(),document.activeElement&&document.activeElement.blur(),L.mouseHandled=!0),!0}_callDrag(r){if(!this.dragging)return;let c=u.initEvent(r,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(c,this.ui()),this.triggerEvent("drag",c)}_mouseMove(r){let c=this.mouseDownEvent;if(this.lastDrag=r,this.dragging)if(this._dragFollow(r),L.pauseDrag){let b=Number.isInteger(L.pauseDrag)?L.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(r),b)}else this._callDrag(r);else if(Math.abs(r.x-c.x)+Math.abs(r.y-c.y)>3){this.dragging=!0,L.dragElement=this;let b=this.el.gridstackNode?.grid;b?L.dropElement=b.el.ddElement.ddDroppable:delete L.dropElement,this.helper=this._createHelper(r),this._setupHelperContainmentStyle(),this.dragTransform=u.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(r,this.el,this.helperContainment),this._setupHelperStyle(r);let w=u.initEvent(r,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(w,this.ui()),this.triggerEvent("dragstart",w),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(r){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),G&&(r.target.removeEventListener("touchmove",it,!0),r.target.removeEventListener("touchend",ft,!0)),this.dragging){delete this.dragging,delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),L.dropElement?.el===this.el.parentElement&&delete L.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper===this.el?this._removeHelperStyle():this.helper.remove();let c=u.initEvent(r,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(c),this.triggerEvent("dragstop",c),L.dropElement&&L.dropElement.drop(r)}delete this.helper,delete this.mouseDownEvent,delete L.dragElement,delete L.dropElement,delete L.mouseHandled,r.preventDefault()}_keyEvent(r){let c=this.el.gridstackNode;if(!c?.grid)return;let b=c.grid;if(r.key==="Escape")c._origRotate&&(c._orig=c._origRotate,delete c._origRotate),b.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent);else if(r.key==="r"||r.key==="R"){if(!u.canBeRotated(c))return;c._origRotate=c._origRotate||{...c._orig},delete c._moving,b.setAnimation(!1).rotate(c.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetLeft}).setAnimation(),c._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,c.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",u.swap(c._orig,"w","h"),delete c._rect,this._mouseMove(this.lastDrag)}}_createHelper(r){let c=this.el;return typeof this.option.helper=="function"?c=this.option.helper(r):this.option.helper==="clone"&&(c=u.cloneNode(this.el)),document.body.contains(c)||u.appendTo(c,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),c===this.el&&(this.dragElementOriginStyle=te.originStyleProp.map(b=>this.el.style[b])),c}_setupHelperStyle(r){this.helper.classList.add("ui-draggable-dragging");let c=this.helper.style;return c.pointerEvents="none",c.width=this.dragOffset.width+"px",c.height=this.dragOffset.height+"px",c.willChange="left, top",c.position="fixed",this._dragFollow(r),c.transition="none",setTimeout(()=>{this.helper&&(c.transition=null)},0),this}_removeHelperStyle(){if(this.helper.classList.remove("ui-draggable-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){let c=this.helper,b=this.dragElementOriginStyle.transition||null;c.style.transition=this.dragElementOriginStyle.transition="none",te.originStyleProp.forEach(w=>c.style[w]=this.dragElementOriginStyle[w]||null),setTimeout(()=>c.style.transition=b,50)}return delete this.dragElementOriginStyle,this}_dragFollow(r){let c=this.helper.style,b=this.dragOffset;c.left=(r.clientX+b.offsetLeft-0)*this.dragTransform.xScale+"px",c.top=(r.clientY+b.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,c,b){let w=0,E=0;b&&(w=this.dragTransform.xOffset,E=this.dragTransform.yOffset);let O=c.getBoundingClientRect();return{left:O.left,top:O.top,offsetLeft:-r.clientX+O.left-w,offsetTop:-r.clientY+O.top-E,width:O.width*this.dragTransform.xScale,height:O.height*this.dragTransform.yScale}}ui(){let r=this.el.parentElement.getBoundingClientRect(),c=this.helper.getBoundingClientRect();return{position:{top:(c.top-r.top)*this.dragTransform.yScale,left:(c.left-r.left)*this.dragTransform.xScale}}}}te.originStyleProp=["transition","pointerEvents","position","left","top","minWidth","willChange"];class De extends $t{constructor(r,c={}){super(),this.el=r,this.option=c,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(r,c){super.on(r,c)}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),G&&(this.el.addEventListener("pointerenter",Tt),this.el.addEventListener("pointerleave",Dt)))}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),G&&(this.el.removeEventListener("pointerenter",Tt),this.el.removeEventListener("pointerleave",Dt)))}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(c=>this.option[c]=r[c]),this._setupAccept(),this}_mouseEnter(r){if(!L.dragElement||!this._canDrop(L.dragElement.el))return;r.preventDefault(),r.stopPropagation(),L.dropElement&&L.dropElement!==this&&L.dropElement._mouseLeave(r,!0),L.dropElement=this;let c=u.initEvent(r,{target:this.el,type:"dropover"});this.option.over&&this.option.over(c,this._ui(L.dragElement)),this.triggerEvent("dropover",c),this.el.classList.add("ui-droppable-over")}_mouseLeave(r,c=!1){if(!L.dragElement||L.dropElement!==this)return;r.preventDefault(),r.stopPropagation();let b=u.initEvent(r,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(b,this._ui(L.dragElement)),this.triggerEvent("dropout",b),L.dropElement===this&&(delete L.dropElement,!c)){let w,E=this.el.parentElement;for(;!w&&E;)w=E.ddElement?.ddDroppable,E=E.parentElement;w&&w._mouseEnter(r)}}drop(r){r.preventDefault();let c=u.initEvent(r,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(c,this._ui(L.dragElement)),this.triggerEvent("drop",c)}_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 vt{static init(r){return r.ddElement||(r.ddElement=new vt(r)),r.ddElement}constructor(r){this.el=r}on(r,c){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(r)>-1?this.ddDraggable.on(r,c):this.ddDroppable&&["drop","dropover","dropout"].indexOf(r)>-1?this.ddDroppable.on(r,c):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(r)>-1&&this.ddResizable.on(r,c),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 te(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 zt(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 De(this.el,r),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}let At=new class{resizable(J,r,c,b){return this._getDDElements(J).forEach(w=>{if(r==="disable"||r==="enable")w.ddResizable&&w.ddResizable[r]();else if(r==="destroy")w.ddResizable&&w.cleanResizable();else if(r==="option")w.setupResizable({[c]:b});else{let E=w.el.gridstackNode.grid,O=w.el.getAttribute("gs-resize-handles")||E.opts.resizable.handles||"e,s,se";O==="all"&&(O="n,e,s,w,se,sw,ne,nw");let $=!E.opts.alwaysShowResizeHandle;w.setupResizable({...E.opts.resizable,handles:O,autoHide:$,start:r.start,stop:r.stop,resize:r.resize})}}),this}draggable(J,r,c,b){return this._getDDElements(J).forEach(w=>{if(r==="disable"||r==="enable")w.ddDraggable&&w.ddDraggable[r]();else if(r==="destroy")w.ddDraggable&&w.cleanDraggable();else if(r==="option")w.setupDraggable({[c]:b});else{let E=w.el.gridstackNode.grid;w.setupDraggable({...E.opts.draggable,start:r.start,stop:r.stop,drag:r.drag})}}),this}dragIn(J,r){return this._getDDElements(J).forEach(c=>c.setupDraggable(r)),this}droppable(J,r,c,b){return typeof r.accept!="function"||r._accept||(r._accept=r.accept,r.accept=w=>r._accept(w)),this._getDDElements(J).forEach(w=>{r==="disable"||r==="enable"?w.ddDroppable&&w.ddDroppable[r]():r==="destroy"?w.ddDroppable&&w.cleanDroppable():r==="option"?w.setupDroppable({[c]:b}):w.setupDroppable(r)}),this}isDroppable(J){return!(!(J&&J.ddElement&&J.ddElement.ddDroppable)||J.ddElement.ddDroppable.disabled)}isDraggable(J){return!(!(J&&J.ddElement&&J.ddElement.ddDraggable)||J.ddElement.ddDraggable.disabled)}isResizable(J){return!(!(J&&J.ddElement&&J.ddElement.ddResizable)||J.ddElement.ddResizable.disabled)}on(J,r,c){return this._getDDElements(J).forEach(b=>b.on(r,w=>{c(w,L.dragElement?L.dragElement.el:w.target,L.dragElement?L.dragElement.helper:null)})),this}off(J,r){return this._getDDElements(J).forEach(c=>c.off(r)),this}_getDDElements(J,r=!0){let c=u.getElements(J);if(!c.length)return[];let b=c.map(w=>w.ddElement||(r?vt.init(w):null));return r||b.filter(w=>w),b}};class pt{static init(r={},c=".grid-stack"){if(typeof document>"u")return null;let b=pt.getGridElement(c);return b?(b.gridstack||(b.gridstack=new pt(b,u.cloneDeep(r))),b.gridstack):(console.error(typeof c=="string"?'GridStack.initAll() no grid was found with selector "'+c+`" - 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={},c=".grid-stack"){let b=[];return typeof document>"u"||(pt.getGridElements(c).forEach(w=>{w.gridstack||(w.gridstack=new pt(w,u.cloneDeep(r))),b.push(w.gridstack)}),b.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+c+`" - element missing or wrong selector ? Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),b}static addGrid(r,c={}){if(!r)return null;let b=r;if(b.gridstack){let w=b.gridstack;return c&&(w.opts={...w.opts,...c}),c.children!==void 0&&w.load(c.children),w}if(!r.classList.contains("grid-stack")||pt.addRemoveCB)if(pt.addRemoveCB)b=pt.addRemoveCB(r,c,!0,!0);else{let w=document.implementation.createHTMLDocument("");w.body.innerHTML=`
`,b=w.body.children[0],r.appendChild(b)}return pt.init(c,b)}static registerEngine(r){pt.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,P.itemClass,this.opts.itemClass),this.placeholder.appendChild(r)}return this._placeholder}constructor(r,c={}){this.el=r,this.opts=c,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},r.gridstack=this,c=c||{},r.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),c.row&&(c.minRow=c.maxRow=c.row,delete c.row);let b=u.toNumber(r.getAttribute("gs-row"));c.column==="auto"&&delete c.column,c.alwaysShowResizeHandle!==void 0&&(c._alwaysShowResizeHandle=c.alwaysShowResizeHandle);let w=c.columnOpts?.breakpoints,E=c;if(E.oneColumnModeDomSort&&(delete E.oneColumnModeDomSort,console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")),E.oneColumnSize||E.disableOneColumnMode===!1){let tt=E.oneColumnSize||768;delete E.oneColumnSize,delete E.disableOneColumnMode,c.columnOpts=c.columnOpts||{},w=c.columnOpts.breakpoints=c.columnOpts.breakpoints||[];let ot=w.find(_t=>_t.c===1);ot?ot.w=tt:(ot={c:1,w:tt},w.push(ot,{c:12,w:tt+1}))}let O=c.columnOpts;O&&(O.columnWidth||O.breakpoints?.length?O.columnMax=O.columnMax||12:(delete c.columnOpts,w=void 0)),w?.length>1&&w.sort((tt,ot)=>(ot.w||0)-(tt.w||0));let $={...u.cloneDeep(P),column:u.toNumber(r.getAttribute("gs-column"))||P.column,minRow:b||u.toNumber(r.getAttribute("gs-min-row"))||P.minRow,maxRow:b||u.toNumber(r.getAttribute("gs-max-row"))||P.maxRow,staticGrid:u.toBool(r.getAttribute("gs-static"))||P.staticGrid,draggable:{handle:(c.handleClass?"."+c.handleClass:c.handle?c.handle:"")||P.draggable.handle},removableOptions:{accept:c.itemClass||P.removableOptions.accept,decline:P.removableOptions.decline}};r.getAttribute("gs-animate")&&($.animate=u.toBool(r.getAttribute("gs-animate"))),c=u.defaults(c,$),this._initMargin(),this.checkDynamicColumn(),this.el.classList.add("gs-"+c.column),c.rtl==="auto"&&(c.rtl=r.style.direction==="rtl"),c.rtl&&this.el.classList.add("grid-stack-rtl");let V=this.el.parentElement?.parentElement,B=V?.classList.contains(P.itemClass)?V.gridstackNode:void 0;B&&(B.subGrid=this,this.parentGridItem=B,this.el.classList.add("grid-stack-nested"),B.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=c.cellHeight==="auto",this._isAutoCellHeight||c.cellHeight==="initial"?this.cellHeight(void 0,!1):(typeof c.cellHeight=="number"&&c.cellHeightUnit&&c.cellHeightUnit!==P.cellHeightUnit&&(c.cellHeight=c.cellHeight+c.cellHeightUnit,delete c.cellHeightUnit),this.cellHeight(c.cellHeight,!1)),c.alwaysShowResizeHandle==="mobile"&&(c.alwaysShowResizeHandle=G),this._styleSheetClass="gs-id-"+k._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();let W=c.engineClass||pt.engineClass||k;if(this.engine=new W({column:this.getColumn(),float:c.float,maxRow:c.maxRow,onChange:tt=>{let ot=0;this.engine.nodes.forEach(_t=>{ot=Math.max(ot,_t.y+_t.h)}),tt.forEach(_t=>{let ne=_t.el;ne&&(_t._removeDOM?(ne&&ne.remove(),delete _t._removeDOM):this._writePosAttr(ne,_t))}),this._updateStyles(!1,ot)}}),this._updateStyles(!1,0),c.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(tt=>this._prepareElement(tt)),delete this.engine._loading,this.batchUpdate(!1)),c.children){let tt=c.children;delete c.children,tt.length&&this.load(tt)}this.setAnimation(),c.subGridDynamic&&!L.pauseDrag&&(L.pauseDrag=!0),c.draggable?.pause!==void 0&&(L.pauseDrag=c.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}addWidget(r,c){let b,w;if(typeof r=="string"){let $=document.implementation.createHTMLDocument("");$.body.innerHTML=r,b=$.body.children[0]}else if(arguments.length===0||arguments.length===1&&((E=r).el!==void 0||E.x!==void 0||E.y!==void 0||E.w!==void 0||E.h!==void 0||E.content!==void 0))if(w=c=r,w?.el)b=w.el;else if(pt.addRemoveCB)b=pt.addRemoveCB(this.el,c,!0,!1);else{let $=c?.content||"",V=document.implementation.createHTMLDocument("");V.body.innerHTML=`
${$}
`,b=V.body.children[0]}else b=r;var E;if(!b)return;if(w=b.gridstackNode,w&&b.parentElement===this.el&&this.engine.nodes.find($=>$._id===w._id))return b;let O=this._readAttr(b);return c=u.cloneDeep(c)||{},u.defaults(c,O),w=this.engine.prepareNode(c),this._writeAttr(b,c),this.el.appendChild(b),this.makeWidget(b,c),b}makeSubGrid(r,c,b,w=!0){let E,O=r.gridstackNode;if(O||(O=this.makeWidget(r).gridstackNode),O.subGrid?.el)return O.subGrid;let $,V=this;for(;V&&!E;)E=V.opts?.subGridOpts,V=V.parentGridItem?.grid;c=u.cloneDeep({...E||{},children:void 0,...c||O.subGridOpts||{}}),O.subGridOpts=c,c.column==="auto"&&($=!0,c.column=Math.max(O.w||1,b?.w||1),delete c.columnOpts);let B,W,tt=O.el.querySelector(".grid-stack-item-content");if(w){if(this._removeDD(O.el),W={...O,x:0,y:0},u.removeInternalForSave(W),delete W.subGridOpts,O.content&&(W.content=O.content,delete O.content),pt.addRemoveCB)B=pt.addRemoveCB(this.el,W,!0,!1);else{let _t=document.implementation.createHTMLDocument("");_t.body.innerHTML='
',B=_t.body.children[0],B.appendChild(tt),_t.body.innerHTML='
',tt=_t.body.children[0],O.el.appendChild(tt)}this._prepareDragDropByNode(O)}if(b){let _t=$?c.column:O.w,ne=O.h+b.h,Ue=O.el.style;Ue.transition="none",this.update(O.el,{w:_t,h:ne}),setTimeout(()=>Ue.transition=null)}let ot=O.subGrid=pt.addGrid(tt,c);return b?._moving&&(ot._isTemp=!0),$&&(ot._autoColumn=!0),w&&ot.addWidget(B,W),b&&(b._moving?window.setTimeout(()=>u.simulateMouseEvent(b._event,"mouseenter",ot.el),0):ot.addWidget(O.el,O)),ot}removeAsSubGrid(r){let c=this.parentGridItem?.grid;c&&(c.batchUpdate(),c.removeWidget(this.parentGridItem.el,!0,!0),this.engine.nodes.forEach(b=>{b.x+=this.parentGridItem.x,b.y+=this.parentGridItem.y,c.addWidget(b.el,b)}),c.batchUpdate(!1),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,r&&window.setTimeout(()=>u.simulateMouseEvent(r._event,"mouseenter",c.el),0))}save(r=!0,c=!1,b=pt.saveCB){let w=this.engine.save(r,b);if(w.forEach(E=>{if(r&&E.el&&!E.subGrid&&!b){let O=E.el.querySelector(".grid-stack-item-content");E.content=O?O.innerHTML:void 0,E.content||delete E.content}else if(r||b||delete E.content,E.subGrid?.el){let O=E.subGrid.save(r,c,b);E.subGridOpts=c?O:{children:O},delete E.subGrid}delete E.el}),c){let E=u.cloneDeep(this.opts);E.marginBottom===E.marginTop&&E.marginRight===E.marginLeft&&E.marginTop===E.marginRight&&(E.margin=E.marginTop,delete E.marginTop,delete E.marginRight,delete E.marginBottom,delete E.marginLeft),E.rtl===(this.el.style.direction==="rtl")&&(E.rtl="auto"),this._isAutoCellHeight&&(E.cellHeight="auto"),this._autoColumn&&(E.column="auto");let O=E._alwaysShowResizeHandle;return delete E._alwaysShowResizeHandle,O!==void 0?E.alwaysShowResizeHandle=O:delete E.alwaysShowResizeHandle,u.removeInternalAndSame(E,P),E.children=w,E}return w}load(r,c=pt.addRemoveCB||!0){r=u.cloneDeep(r);let b=this.getColumn();r.forEach(B=>{B.w=B.w||1,B.h=B.h||1}),r=u.sort(r);let w=0;r.forEach(B=>{w=Math.max(w,(B.x||0)+B.w)}),w>b&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(r,w,!0));let E=pt.addRemoveCB;typeof c=="function"&&(pt.addRemoveCB=c);let O=[];this.batchUpdate();let $=!this.engine.nodes.length;$&&this.setAnimation(!1),!$&&c&&[...this.engine.nodes].forEach(B=>{B.id&&(u.find(r,B.id)||(pt.addRemoveCB&&pt.addRemoveCB(this.el,B,!1,!1),O.push(B),this.removeWidget(B.el,!0,!1)))}),this.engine._loading=!0;let V=[];return this.engine.nodes=this.engine.nodes.filter(B=>!u.find(r,B.id)||(V.push(B),!1)),r.forEach(B=>{let W=u.find(V,B.id);if(W){if(u.shouldSizeToContent(W)&&(B.h=W.h),this.engine.nodeBoundFix(B),(B.autoPosition||B.x===void 0||B.y===void 0)&&(B.w=B.w||W.w,B.h=B.h||W.h,this.engine.findEmptyPosition(B)),this.engine.nodes.push(W),u.samePos(W,B)&&this.moveNode(W,{...B,forceCollide:!0}),this.update(W.el,B),B.subGridOpts?.children){let tt=W.el.querySelector(".grid-stack");tt&&tt.gridstack&&tt.gridstack.load(B.subGridOpts.children)}}else c&&this.addWidget(B)}),delete this.engine._loading,this.engine.removedNodes=O,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,E?pt.addRemoveCB=E:delete pt.addRemoveCB,$&&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 c=this.el.querySelector("."+this.opts.itemClass);if(c){let w=u.toNumber(c.getAttribute("gs-h"))||1;return Math.round(c.offsetHeight/w)}let b=parseInt(this.el.getAttribute("gs-current-row"));return b?Math.round(this.el.getBoundingClientRect().height/b):this.opts.cellHeight}cellHeight(r,c=!0){if(c&&r!==void 0&&this._isAutoCellHeight!==(r==="auto")&&(this._isAutoCellHeight=r==="auto",this._updateResizeEvent()),r!=="initial"&&r!=="auto"||(r=void 0),r===void 0){let w=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;r=this.cellWidth()+w}let b=u.parseHeight(r);return this.opts.cellHeightUnit===b.unit&&this.opts.cellHeight===b.h||(this.opts.cellHeightUnit=b.unit,this.opts.cellHeight=b.h,this.resizeToContentCheck(),c&&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 c=this.getColumn(),b=c,w=this._widthOrContainer(!0);if(r.columnWidth)b=Math.min(Math.round(w/r.columnWidth)||1,r.columnMax);else{b=r.columnMax;let E=0;for(;EO.c===b);return this.column(b,E?.layout||r.layout),!0}return!1}compact(r="compact",c=!0){return this.engine.compact(r,c),this._triggerChangeEvent(),this}column(r,c="moveScale"){if(!r||r<1||this.opts.column===r)return this;let b=this.getColumn();return this.opts.column=r,this.engine?(this.engine.column=r,this.el.classList.remove("gs-"+b),this.el.classList.add("gs-"+r),this.engine.columnChanged(b,r,c),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,c=!1){let b,w=this.el.getBoundingClientRect();b=c?{top:w.top+document.documentElement.scrollTop,left:w.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};let E=r.left-b.left,O=r.top-b.top,$=w.width/this.getColumn(),V=w.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(E/$),y:Math.floor(O/V)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(r,c,b,w){return this.engine.isAreaEmpty(r,c,b,w)}makeWidget(r,c){let b=pt.getElement(r);this._prepareElement(b,!0,c);let w=b.gridstackNode;return this._updateContainerHeight(),w.subGridOpts&&this.makeSubGrid(b,w.subGridOpts,void 0,!1),this.opts.column===1&&(this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,b}on(r,c){if(r.indexOf(" ")!==-1)return r.split(" ").forEach(b=>this.on(b,c)),this;if(r==="change"||r==="added"||r==="removed"||r==="enable"||r==="disable"){let b=r==="enable"||r==="disable";this._gsEventHandler[r]=b?w=>c(w):w=>c(w,w.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]=c:console.error("GridStack.on("+r+") event not supported");return this}off(r){return r.indexOf(" ")!==-1?(r.split(" ").forEach(c=>this.off(c)),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,c=!0,b=!0){return pt.getElements(r).forEach(w=>{if(w.parentElement&&w.parentElement!==this.el)return;let E=w.gridstackNode;E||(E=this.engine.nodes.find(O=>w===O.el)),E&&(c&&pt.addRemoveCB&&pt.addRemoveCB(this.el,E,!1,!1),delete w.gridstackNode,this._removeDD(w),this.engine.removeNode(E,c,b),c&&w.parentElement&&w.remove())}),b&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(r=!0,c=!0){return this.engine.nodes.forEach(b=>{r&&pt.addRemoveCB&&pt.addRemoveCB(this.el,b,!1,!1),delete b.el.gridstackNode,this.opts.staticGrid||this._removeDD(b.el)}),this.engine.removeAll(r,c),c&&this._triggerRemoveEvent(),this}setAnimation(r=this.opts.animate,c){return c?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,c=!0,b=!0){return!!this.opts.staticGrid===r||(r?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(w=>{this._prepareDragDropByNode(w),w.subGrid&&b&&w.subGrid.setStatic(r,c,b)}),c&&this._setStaticClass()),this}update(r,c){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 b=arguments,w=1;return c={x:b[w++],y:b[w++],w:b[w++],h:b[w++]},this.update(r,c)}return pt.getElements(r).forEach(b=>{let w=b?.gridstackNode;if(!w)return;let E=u.cloneDeep(c);this.engine.nodeBoundFix(E),delete E.autoPosition,delete E.id;let O,$=["x","y","w","h"];if($.some(W=>E[W]!==void 0&&E[W]!==w[W])&&(O={},$.forEach(W=>{O[W]=E[W]!==void 0?E[W]:w[W],delete E[W]})),!O&&(E.minW||E.minH||E.maxW||E.maxH)&&(O={}),E.content!==void 0){let W=b.querySelector(".grid-stack-item-content");W&&W.innerHTML!==E.content&&(W.innerHTML=E.content,w.subGrid?.el&&(W.appendChild(w.subGrid.el),w.subGrid.opts.styleInHead||w.subGrid._updateStyles(!0))),delete E.content}let V=!1,B=!1;for(let W in E)W[0]!=="_"&&w[W]!==E[W]&&(w[W]=E[W],V=!0,B=B||!this.opts.staticGrid&&(W==="noResize"||W==="noMove"||W==="locked"));if(u.sanitizeMinMax(w),O){let W=O.w!==void 0&&O.w!==w.w;this.moveNode(w,O),this.resizeToContentCheck(W,w),delete w._orig}(O||V)&&this._writeAttr(b,w),B&&this._prepareDragDropByNode(w)}),this}moveNode(r,c){let b=r._updating;b||this.engine.cleanNodes().beginUpdate(r),this.engine.moveNode(r,c),this._updateContainerHeight(),b||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(r){if(!r||(r.classList.remove("size-to-content-max"),!r.clientHeight))return;let c=r.gridstackNode;if(!c)return;let b=c.grid;if(!b||r.parentElement!==b.el)return;let w=b.getCellHeight(!0);if(!w)return;let E,O=c.h?c.h*w:r.clientHeight;if(c.resizeToContentParent&&(E=r.querySelector(c.resizeToContentParent)),E||(E=r.querySelector(pt.resizeToContentParent)),!E)return;let $=r.clientHeight-E.clientHeight,V=c.h?c.h*w-$:E.clientHeight,B;if(c.subGrid)B=c.subGrid.getRow()*c.subGrid.getCellHeight(!0);else{if(c.subGridOpts?.children?.length)return;{let ot=E.firstElementChild;if(!ot)return void console.error(`Error: GridStack.resizeToContent() widget id:${c.id} '${pt.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);B=ot.getBoundingClientRect().height||V}}if(V===B)return;O+=B-V;let W=Math.ceil(O/w),tt=Number.isInteger(c.sizeToContent)?c.sizeToContent:0;tt&&W>tt&&(W=tt,r.classList.add("size-to-content-max")),c.minH&&Wc.maxH&&(W=c.maxH),W!==c.h&&(b._ignoreLayoutsNodeChange=!0,b.moveNode(c,{h:W}),delete b._ignoreLayoutsNodeChange)}resizeToContentCBCheck(r){pt.resizeToContentCB?pt.resizeToContentCB(r):this.resizeToContent(r)}rotate(r,c){return pt.getElements(r).forEach(b=>{let w=b.gridstackNode;if(!u.canBeRotated(w))return;let E={w:w.h,h:w.w,minH:w.minW,minW:w.minH,maxH:w.maxW,maxW:w.maxH};if(c){let $=c.left>0?Math.floor(c.left/this.cellWidth()):0,V=c.top>0?Math.floor(c.top/this.opts.cellHeight):0;E.x=w.x+$-(w.h-(V+1)),E.y=w.y+V-$}Object.keys(E).forEach($=>{E[$]===void 0&&delete E[$]});let O=w._orig;this.update(b,E),w._orig=O}),this}margin(r){if(!(typeof r=="string"&&r.split(" ").length>1)){let c=u.parseHeight(r);if(this.opts.marginUnit===c.unit&&this.opts.margin===c.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 c=arguments,b=0,w={x:c[b++],y:c[b++],w:c[b++],h:c[b++],autoPosition:c[b++]};return this.willItFit(w)}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(c=>{delete c._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,c){let b=c?new CustomEvent(r,{bubbles:!1,detail:c}):new Event(r);return this.el.dispatchEvent(b),this}_removeStylesheet(){if(this._styles){let r=this.opts.styleInHead?void 0:this.el.parentNode;u.removeStylesheet(this._styleSheetClass,r),delete this._styles}return this}_updateStyles(r=!1,c){if(r&&this._removeStylesheet(),c===void 0&&(c=this.getRow()),this._updateContainerHeight(),this.opts.cellHeight===0)return this;let b=this.opts.cellHeight,w=this.opts.cellHeightUnit,E=`.${this._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let O=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=u.createStylesheet(this._styleSheetClass,O,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,u.addCSSRule(this._styles,E,`height: ${b}${w}`);let $=this.opts.marginTop+this.opts.marginUnit,V=this.opts.marginBottom+this.opts.marginUnit,B=this.opts.marginRight+this.opts.marginUnit,W=this.opts.marginLeft+this.opts.marginUnit,tt=`${E} > .grid-stack-item-content`,ot=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;u.addCSSRule(this._styles,tt,`top: ${$}; right: ${B}; bottom: ${V}; left: ${W};`),u.addCSSRule(this._styles,ot,`top: ${$}; right: ${B}; bottom: ${V}; left: ${W};`),u.addCSSRule(this._styles,`${E} > .ui-resizable-n`,`top: ${$};`),u.addCSSRule(this._styles,`${E} > .ui-resizable-s`,`bottom: ${V}`),u.addCSSRule(this._styles,`${E} > .ui-resizable-ne`,`right: ${B}`),u.addCSSRule(this._styles,`${E} > .ui-resizable-e`,`right: ${B}`),u.addCSSRule(this._styles,`${E} > .ui-resizable-se`,`right: ${B}; bottom: ${V}`),u.addCSSRule(this._styles,`${E} > .ui-resizable-nw`,`left: ${W}`),u.addCSSRule(this._styles,`${E} > .ui-resizable-w`,`left: ${W}`),u.addCSSRule(this._styles,`${E} > .ui-resizable-sw`,`left: ${W}; bottom: ${V}`)}if((c=c||this._styles._max)>this._styles._max){let O=$=>b*$+w;for(let $=this._styles._max+1;$<=c;$++)u.addCSSRule(this._styles,`${E}[gs-y="${$}"]`,`top: ${O($)}`),u.addCSSRule(this._styles,`${E}[gs-h="${$+1}"]`,`height: ${O($+1)}`);this._styles._max=c}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let r=this.parentGridItem,c=this.getRow()+this._extraDragRow,b=this.opts.cellHeight,w=this.opts.cellHeightUnit;if(!b)return this;if(!r){let E=u.parseHeight(getComputedStyle(this.el).minHeight);if(E.h>0&&E.unit===w){let O=Math.floor(E.h/b);c1?r.setAttribute("gs-w",String(c.w)):r.removeAttribute("gs-w"),c.h>1?r.setAttribute("gs-h",String(c.h)):r.removeAttribute("gs-h"),this}_writeAttr(r,c){if(!c)return this;this._writePosAttr(r,c);let b={autoPosition:"gs-auto-position",noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id"};for(let w in b)c[w]?r.setAttribute(b[w],String(c[w])):r.removeAttribute(b[w]);return this}_readAttr(r,c=!0){let b={};b.x=u.toNumber(r.getAttribute("gs-x")),b.y=u.toNumber(r.getAttribute("gs-y")),b.w=u.toNumber(r.getAttribute("gs-w")),b.h=u.toNumber(r.getAttribute("gs-h")),b.autoPosition=u.toBool(r.getAttribute("gs-auto-position")),b.noResize=u.toBool(r.getAttribute("gs-no-resize")),b.noMove=u.toBool(r.getAttribute("gs-no-move")),b.locked=u.toBool(r.getAttribute("gs-locked")),b.id=r.getAttribute("gs-id"),b.maxW=u.toNumber(r.getAttribute("gs-max-w")),b.minW=u.toNumber(r.getAttribute("gs-min-w")),b.maxH=u.toNumber(r.getAttribute("gs-max-h")),b.minH=u.toNumber(r.getAttribute("gs-min-h")),c&&(b.w===1&&r.removeAttribute("gs-w"),b.h===1&&r.removeAttribute("gs-h"),b.maxW&&r.removeAttribute("gs-max-w"),b.minW&&r.removeAttribute("gs-min-w"),b.maxH&&r.removeAttribute("gs-max-h"),b.minH&&r.removeAttribute("gs-min-h"));for(let w in b){if(!b.hasOwnProperty(w))return;b[w]||b[w]===0||delete b[w]}return b}_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(c=>{c.subGrid&&c.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(r),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(r=!1,c=void 0){if(this.engine){if(r&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,c),310);if(c)u.shouldSizeToContent(c)&&this.resizeToContentCBCheck(c.el);else if(this.engine.nodes.some(b=>u.shouldSizeToContent(b))){let b=[...this.engine.nodes];this.batchUpdate(),b.forEach(w=>{u.shouldSizeToContent(w)&&this.resizeToContentCBCheck(w.el)}),this.batchUpdate(!1)}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,c?[c]:this.engine.nodes)}}_updateResizeEvent(r=!1){let c=!this.parentGridItem&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(b=>b.sizeToContent));return r||!c||this.resizeObserver?!r&&c||!this.resizeObserver||(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle):(this._sizeThrottle=u.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 u.getElement(r)}static getElements(r=".grid-stack-item"){return u.getElements(r)}static getGridElement(r){return pt.getElement(r)}static getGridElements(r){return u.getElements(r)}_initMargin(){let r,c=0,b=[];return typeof this.opts.margin=="string"&&(b=this.opts.margin.split(" ")),b.length===2?(this.opts.marginTop=this.opts.marginBottom=b[0],this.opts.marginLeft=this.opts.marginRight=b[1]):b.length===4?(this.opts.marginTop=b[0],this.opts.marginRight=b[1],this.opts.marginBottom=b[2],this.opts.marginLeft=b[3]):(r=u.parseHeight(this.opts.margin),this.opts.marginUnit=r.unit,c=this.opts.margin=r.h),this.opts.marginTop===void 0?this.opts.marginTop=c:(r=u.parseHeight(this.opts.marginTop),this.opts.marginTop=r.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=c:(r=u.parseHeight(this.opts.marginBottom),this.opts.marginBottom=r.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=c:(r=u.parseHeight(this.opts.marginRight),this.opts.marginRight=r.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=c:(r=u.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 At}static setupDragIn(r,c,b=document){c?.pause!==void 0&&(L.pauseDrag=c.pause),c={...z,...c||{}};let w=typeof r=="string"?u.getElements(r,b):r;w.length&&w?.forEach(E=>{At.isDraggable(E)||At.dragIn(E,c)})}movable(r,c){return this.opts.staticGrid||pt.getElements(r).forEach(b=>{let w=b.gridstackNode;w&&(c?delete w.noMove:w.noMove=!0,this._prepareDragDropByNode(w))}),this}resizable(r,c){return this.opts.staticGrid||pt.getElements(r).forEach(b=>{let w=b.gridstackNode;w&&(c?delete w.noResize:w.noResize=!0,this._prepareDragDropByNode(w))}),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,c=!0){return this.opts.staticGrid||(r?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(b=>{this._prepareDragDropByNode(b),b.subGrid&&c&&b.subGrid.enableMove(r,c)})),this}enableResize(r,c=!0){return this.opts.staticGrid||(r?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(b=>{this._prepareDragDropByNode(b),b.subGrid&&c&&b.subGrid.enableResize(r,c)})),this}_removeDD(r){return At.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 At.droppable(this.el,"destroy"),this;let r,c,b=(w,E,O)=>{let $=E.gridstackNode;if(!$)return;if(O=O||E,!$.grid?.el){O.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;let ot=O.getBoundingClientRect();O.style.left=ot.x+(this.dragTransform.xScale-1)*(w.clientX-ot.x)/this.dragTransform.xScale+"px",O.style.top=ot.y+(this.dragTransform.yScale-1)*(w.clientY-ot.y)/this.dragTransform.yScale+"px",O.style.transformOrigin="0px 0px"}let V=this.el.getBoundingClientRect(),{top:B,left:W}=O.getBoundingClientRect();W-=V.left,B-=V.top;let tt={position:{top:B*this.dragTransform.xScale,left:W*this.dragTransform.yScale}};if($._temporaryRemoved){if($.x=Math.max(0,Math.round(W/c)),$.y=Math.max(0,Math.round(B/r)),delete $.autoPosition,this.engine.nodeBoundFix($),!this.engine.willItFit($)){if($.autoPosition=!0,!this.engine.willItFit($))return void At.off(E,"drag");$._willFitPos&&(u.copyPos($,$._willFitPos),delete $._willFitPos)}this._onStartMoving(O,w,tt,$,c,r)}else this._dragOrResize(O,w,tt,$,c,r)};return At.droppable(this.el,{accept:w=>{let E=w.gridstackNode||this._readAttr(w,!1);if(E?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let O=!0;if(typeof this.opts.acceptWidgets=="function")O=this.opts.acceptWidgets(w);else{let $=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;O=w.matches($)}if(O&&E&&this.opts.maxRow){let $={w:E.w,h:E.h,minW:E.minW,minH:E.minH};O=this.engine.willItFit($)}return O}}).on(this.el,"dropover",(w,E,O)=>{let $=E.gridstackNode;if($?.grid===this&&!$._temporaryRemoved)return!1;$?.grid&&$.grid!==this&&!$._temporaryRemoved&&$.grid._leave(E,O),c=this.cellWidth(),r=this.getCellHeight(!0),$||($=this._readAttr(E,!1)),$.grid||($._isExternal=!0,E.gridstackNode=$),O=O||E;let V=$.w||Math.round(O.offsetWidth/c)||1,B=$.h||Math.round(O.offsetHeight/r)||1;return $.grid&&$.grid!==this?(E._gridstackNodeOrig||(E._gridstackNodeOrig=$),E.gridstackNode=$={...$,w:V,h:B,grid:this},delete $.x,delete $.y,this.engine.cleanupNode($).nodeBoundFix($),$._initDD=$._isExternal=$._temporaryRemoved=!0):($.w=V,$.h=B,$._temporaryRemoved=!0),pt._itemRemoving($.el,!1),At.on(E,"drag",b),b(w,E,O),!1}).on(this.el,"dropout",(w,E,O)=>{let $=E.gridstackNode;return!!$&&($.grid&&$.grid!==this||(this._leave(E,O),this._isTemp&&this.removeAsSubGrid($)),!1)}).on(this.el,"drop",(w,E,O)=>{let $=E.gridstackNode;if($?.grid===this&&!$._isExternal)return!1;let V=!!this.placeholder.parentElement;this.placeholder.remove();let B=V&&this.opts.animate;B&&this.setAnimation(!1);let W=E._gridstackNodeOrig;if(delete E._gridstackNodeOrig,V&&W?.grid&&W.grid!==this){let ot=W.grid;ot.engine.removeNodeFromLayoutCache(W),ot.engine.removedNodes.push(W),ot._triggerRemoveEvent()._triggerChangeEvent(),ot.parentGridItem&&!ot.engine.nodes.length&&ot.opts.subGridDynamic&&ot.removeAsSubGrid()}if(!$||(V&&(this.engine.cleanupNode($),$.grid=this),delete $.grid?._isTemp,At.off(E,"drag"),O!==E?(O.remove(),E.gridstackNode=W,V&&(E=E.cloneNode(!0))):(E.remove(),this._removeDD(E)),!V))return!1;E.gridstackNode=$,$.el=E;let tt=$.subGrid?.el?.gridstack;return u.copyPos($,this._readAttr(this.placeholder)),u.removePositioningStyles(E),this.el.appendChild(E),this._prepareElement(E,!0,$),tt&&(tt.parentGridItem=$,tt.opts.styleInHead||tt._updateStyles(!0)),this._updateContainerHeight(),this.engine.addedNodes.push($),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...w,type:"dropped"},W&&W.grid?W:void 0,$),B&&this.setAnimation(this.opts.animate,!0),!1}),this}static _itemRemoving(r,c){let b=r?r.gridstackNode:void 0;b?.grid&&!r.classList.contains(b.grid.opts.removableOptions.decline)&&(c?b._isAboutToRemove=!0:delete b._isAboutToRemove,c?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||At.isDroppable(r)||At.droppable(r,this.opts.removableOptions).on(r,"dropover",(c,b)=>pt._itemRemoving(b,!0)).on(r,"dropout",(c,b)=>pt._itemRemoving(b,!1)),this):this}_prepareDragDropByNode(r){let c=r.el,b=r.noMove||this.opts.disableDrag,w=r.noResize||this.opts.disableResize;if(this.opts.staticGrid||b&&w)return r._initDD&&(this._removeDD(c),delete r._initDD),c.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!r._initDD){let E,O,$=(W,tt)=>{this._gsEventHandler[W.type]&&this._gsEventHandler[W.type](W,W.target),E=this.cellWidth(),O=this.getCellHeight(!0),this._onStartMoving(c,W,tt,r,E,O)},V=(W,tt)=>{this._dragOrResize(c,W,tt,r,E,O)},B=W=>{this.placeholder.remove(),delete r._moving,delete r._event,delete r._lastTried;let tt=r.w!==r._orig.w,ot=W.target;if(ot.gridstackNode&&ot.gridstackNode.grid===this){if(r.el=ot,r._isAboutToRemove){let _t=c.gridstackNode.grid;_t._gsEventHandler[W.type]&&_t._gsEventHandler[W.type](W,ot),_t.engine.nodes.push(r),_t.removeWidget(c,!0,!0)}else u.removePositioningStyles(ot),r._temporaryRemoved?(u.copyPos(r,r._orig),this._writePosAttr(ot,r),this.engine.addNode(r)):this._writePosAttr(ot,r),this._gsEventHandler[W.type]&&this._gsEventHandler[W.type](W,ot);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),W.type==="resizestop"&&(Number.isInteger(r.sizeToContent)&&(r.sizeToContent=r.h),this.resizeToContentCheck(tt,r))}};At.draggable(c,{start:$,stop:B,drag:V}).resizable(c,{start:$,stop:B,resize:V}),r._initDD=!0}return At.draggable(c,b?"disable":"enable").resizable(c,w?"disable":"enable"),this}_onStartMoving(r,c,b,w,E,O){if(this.engine.cleanNodes().beginUpdate(w),this._writePosAttr(this.placeholder,w),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=w,w.grid?.el)this.dragTransform=u.getValuesFromTransformedElement(r);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){let $=this.placeholder.closest(".grid-stack");this.dragTransform=u.getValuesFromTransformedElement($)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(w.el=this.placeholder,w._lastUiPosition=b.position,w._prevYPix=b.position.top,w._moving=c.type==="dragstart",delete w._lastTried,c.type==="dropover"&&w._temporaryRemoved&&(this.engine.addNode(w),w._moving=!0),this.engine.cacheRects(E,O,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),c.type==="resizestart"){let $=this.getColumn()-w.x,V=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-w.y;At.resizable(r,"option","minWidth",E*Math.min(w.minW||1,$)).resizable(r,"option","minHeight",O*Math.min(w.minH||1,V)).resizable(r,"option","maxWidth",E*Math.min(w.maxW||Number.MAX_SAFE_INTEGER,$)).resizable(r,"option","maxWidthMoveLeft",E*Math.min(w.maxW||Number.MAX_SAFE_INTEGER,w.x+w.w)).resizable(r,"option","maxHeight",O*Math.min(w.maxH||Number.MAX_SAFE_INTEGER,V)).resizable(r,"option","maxHeightMoveUp",O*Math.min(w.maxH||Number.MAX_SAFE_INTEGER,w.y+w.h))}}_dragOrResize(r,c,b,w,E,O){let $,V={...w._orig},B=this.opts.marginLeft,W=this.opts.marginRight,tt=this.opts.marginTop,ot=this.opts.marginBottom,_t=Math.round(.1*O),ne=Math.round(.1*E);if(B=Math.min(B,ne),W=Math.min(W,ne),tt=Math.min(tt,_t),ot=Math.min(ot,_t),c.type==="drag"){if(w._temporaryRemoved)return;let Xt=b.position.top-w._prevYPix;w._prevYPix=b.position.top,this.opts.draggable.scroll!==!1&&u.updateScrollPosition(r,b.position,Xt);let ae=b.position.left+(b.position.left>w._lastUiPosition.left?-W:B),We=b.position.top+(b.position.top>w._lastUiPosition.top?-ot:tt);V.x=Math.round(ae/E),V.y=Math.round(We/O);let ee=this._extraDragRow;if(this.engine.collide(w,V)){let $e=this.getRow(),He=Math.max(0,V.y+w.h-$e);this.opts.maxRow&&$e+He>this.opts.maxRow&&(He=Math.max(0,this.opts.maxRow-$e)),this._extraDragRow=He}else this._extraDragRow=0;if(this._extraDragRow!==ee&&this._updateContainerHeight(),w.x===V.x&&w.y===V.y)return}else if(c.type==="resize"){if(V.x<0||(u.updateScrollResize(c,r,O),V.w=Math.round((b.size.width-B)/E),V.h=Math.round((b.size.height-tt)/O),w.w===V.w&&w.h===V.h)||w._lastTried&&w._lastTried.w===V.w&&w._lastTried.h===V.h)return;let Xt=b.position.left+B,ae=b.position.top+tt;V.x=Math.round(Xt/E),V.y=Math.round(ae/O),$=!0}w._event=c,w._lastTried=V;let Ue={x:b.position.left+B,y:b.position.top+tt,w:(b.size?b.size.width:w.w*E)-B-W,h:(b.size?b.size.height:w.h*O)-tt-ot};if(this.engine.moveNodeCheck(w,{...V,cellWidth:E,cellHeight:O,rect:Ue,resizing:$})){w._lastUiPosition=b.position,this.engine.cacheRects(E,O,tt,W,ot,B),delete w._skipDown,$&&w.subGrid&&w.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();let Xt=c.target;this._writePosAttr(Xt,w),this._gsEventHandler[c.type]&&this._gsEventHandler[c.type](c,Xt)}}_leave(r,c){let b=r.gridstackNode;b&&((c=c||r).style.transform="scale(1)",At.off(r,"drag"),b._temporaryRemoved||(b._temporaryRemoved=!0,this.engine.removeNode(b),b.el=b._isExternal&&c?c:r,this.opts.removable===!0&&pt._itemRemoving(r,!0),r._gridstackNodeOrig?(r.gridstackNode=r._gridstackNodeOrig,delete r._gridstackNodeOrig):b._isExternal&&(delete b.el,delete r.gridstackNode,this.engine.restoreInitial())))}commit(){return this.batchUpdate(!1).prototype,this}}return pt.resizeToContentParent=".grid-stack-item-content",pt.Utils=u,pt.Engine=k,pt.GDRev="10.3.1",h.GridStack})());(function(_,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(_=typeof globalThis<"u"?globalThis:_||self).Chart=h()})(void 0,function(){"use strict";var _=Object.freeze({__proto__:null,get Colors(){return fh},get Decimation(){return mh},get Filler(){return kh},get Legend(){return Mh},get SubTitle(){return Ch},get Title(){return Sh},get Tooltip(){return Dh}});function h(){}let u=(()=>{let i=0;return()=>i++})();function k(i){return i==null}function P(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 z(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function L(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function G(i,t){return L(i)?i:t}function U(i,t){return i===void 0?t:i}let K=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100:+i/t,ut=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*t:+i;function X(i,t,e){if(i&&typeof i.call=="function")return i.apply(e,t)}function it(i,t,e,s){let n,o,a;if(P(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 De(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 vt(i,t){return(te[t]||(te[t]=function(s){let n=De(s);return o=>{for(let a of n){if(a==="")break;o=o&&o[a]}return o}}(t)))(i)}function At(i){return i.charAt(0).toUpperCase()+i.slice(1)}let pt=i=>i!==void 0,J=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 c(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}let b=Math.PI,w=2*b,E=w+b,O=Number.POSITIVE_INFINITY,$=b/180,V=b/2,B=b/4,W=2*b/3,tt=Math.log10,ot=Math.sign;function _t(i,t,e){return Math.abs(i-t)n-o).pop(),t}function Xt(i){return!isNaN(parseFloat(i))&&isFinite(i)}function ae(i,t){let e=Math.round(i);return e-t<=i&&e+t>=i}function We(i,t,e){let s,n,o;for(s=0,n=i.length;sd&&g=Math.min(t,e)-s&&i<=Math.max(t,e)+s}function ci(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 Yt=(i,t,e,s)=>ci(i,e,s?n=>{let o=i[n][t];return oi[n][t]ci(i,e,s=>i[s][t]>=e);function Yi(i,t,e){let s=0,n=i.length;for(;ss&&i[n-1]>e;)n--;return s>0||n{let s="_onData"+At(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 Di(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||(Gi.forEach(o=>{delete i[o]}),delete i._chartjs)}function qi(i){let t=new Set(i);return t.size===i.length?i:Array.from(t)}let Xi=typeof window>"u"?function(i){return i()}:window.requestAnimationFrame;function Ai(i,t){let e=[],s=!1;return function(...n){e=n,s||(s=!0,Xi.call(window,()=>{s=!1,i.apply(t,e)}))}}function Zi(i,t){let e;return function(...s){return t?(clearTimeout(e),e=setTimeout(i,t,s)):i.apply(this,s),t}}let Ve=i=>i==="start"?"left":i==="end"?"right":"center",jt=(i,t,e)=>i==="start"?t:i==="end"?e:(t+e)/2,Ns=(i,t,e,s)=>i===(s?"left":"right")?e:i==="center"?(t+e)/2:t;function Ki(i,t,e){let s=t.length,n=0,o=s;if(i._sorted){let{iScale:a,_parsed:l}=i,d=a.axis,{min:g,max:y,minDefined:f,maxDefined:v}=a.getUserBounds();f&&(n=Ut(Math.min(Yt(l,d,g).lo,e?s:Yt(t,d,a.getPixelForValue(g)).lo),0,s-1)),o=v?Ut(Math.max(Yt(l,a.axis,y,!0).hi+1,e?0:Yt(t,d,a.getPixelForValue(y),!0).hi+1),n,s)-n:s-n}return{start:n,count:o}}function Qi(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 Yn{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=Xi.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,d=!1;for(;l>=0;--l)a=o[l],a._active?(a._total>s.duration&&(s.duration=a._total),a.tick(t),d=!0):(o[l]=o[o.length-1],o.pop());d&&(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 ve=new Yn;function di(i){return i+.5|0}let we=(i,t,e)=>Math.max(Math.min(i,e),t);function Qe(i){return we(di(2.55*i),0,255)}function Ne(i){return we(di(255*i),0,255)}function Ae(i){return we(di(i/2.55)/100,0,1)}function Ji(i){return we(di(100*i),0,100)}let le={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},ts=[..."0123456789ABCDEF"],Gn=i=>ts[15&i],qn=i=>ts[(240&i)>>4]+ts[15&i],Pi=i=>(240&i)>>4==(15&i);function Xn(i){var t=(e=>Pi(e.r)&&Pi(e.g)&&Pi(e.b)&&Pi(e.a))(i)?Gn:qn;return i?"#"+t(i.r)+t(i.g)+t(i.b)+((e,s)=>e<255?s(e):"")(i.a,t):void 0}let Zn=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Is(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 Kn(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 Qn(i,t,e){let s=Is(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 es(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,d,g;return n!==o&&(g=n-o,d=a>.5?g/(2-n-o):g/(n+o),l=function(y,f,v,M,T){return y===T?(f-v)/M+(f>16&255,l>>8&255,255&l]}return e}(),ui.transparent=[0,0,0,0]);let t=ui[i.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}let Us=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/,Ot=i=>i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055,Zt=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function gi(i,t,e){if(i){let s=es(i);s[t]=Math.max(0,Math.min(s[t]+s[t]*e,t===0?360:1)),s=ss(s),i.r=s[0],i.g=s[1],i.b=s[2]}}function Ht(i,t){return i&&Object.assign(t||{},i)}function rs(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=Ne(i[3]))):(t=Ht(i,{r:0,g:0,b:0,a:1})).a=Ne(t.a),t}function as(i){return i.charAt(0)==="r"?function(t){let e=Us.exec(t),s,n,o,a=255;if(e){if(e[7]!==s){let l=+e[7];a=e[8]?Qe(l):we(255*l,0,255)}return s=+e[1],n=+e[3],o=+e[5],s=255&(e[2]?Qe(s):we(s,0,255)),n=255&(e[4]?Qe(n):we(n,0,255)),o=255&(e[6]?Qe(o):we(o,0,255)),{r:s,g:n,b:o,a}}}(i):Jn(i)}class Je{constructor(t){if(t instanceof Je)return t;let e=typeof t,s;var n,o,a;e==="object"?s=rs(t):e==="string"&&(a=(n=t).length,n[0]==="#"&&(a===4||a===5?o={r:255&17*le[n[1]],g:255&17*le[n[2]],b:255&17*le[n[3]],a:a===5?17*le[n[4]]:255}:a!==7&&a!==9||(o={r:le[n[1]]<<4|le[n[2]],g:le[n[3]]<<4|le[n[4]],b:le[n[5]]<<4|le[n[6]],a:a===9?le[n[7]]<<4|le[n[8]]:255})),s=o||Fs(t)||as(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=Ht(this._rgb);return t&&(t.a=Ae(t.a)),t}set rgb(t){this._rgb=rs(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${Ae(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?Xn(this._rgb):void 0}hslString(){return this._valid?function(t){if(!t)return;let e=es(t),s=e[0],n=Ji(e[1]),o=Ji(e[2]);return t.a<255?`hsla(${s}, ${n}%, ${o}%, ${Ae(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,d=s.a-n.a,g=((l*d==-1?l:(l+d)/(1+l*d))+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=Zt(Ae(s.r)),l=Zt(Ae(s.g)),d=Zt(Ae(s.b));return{r:Ne(Ot(a+o*(Zt(Ae(n.r))-a))),g:Ne(Ot(l+o*(Zt(Ae(n.g))-l))),b:Ne(Ot(d+o*(Zt(Ae(n.b))-d))),a:s.a+o*(n.a-s.a)}}(this._rgb,t._rgb,e)),this}clone(){return new Je(this.rgb)}alpha(t){return this._rgb.a=Ne(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){let t=this._rgb,e=di(.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 gi(this._rgb,2,t),this}darken(t){return gi(this._rgb,2,-t),this}saturate(t){return gi(this._rgb,1,t),this}desaturate(t){return gi(this._rgb,1,-t),this}rotate(t){return function(e,s){var n=es(e);n[0]=Bs(n[0]+s),n=ss(n),e.r=n[0],e.g=n[1],e.b=n[2]}(this._rgb,t),this}}function Ri(i){if(i&&typeof i=="object"){let t=i.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function ls(i){return Ri(i)?i:new Je(i)}function pi(i){return Ri(i)?i:new Je(i).saturate(.5).darken(.1).hexString()}let to=["x","y","borderWidth","radius","tension"],eo=["color","borderColor","backgroundColor"],Ws=new Map;function ti(i,t,e){return function(s,n){n=n||{};let o=s+JSON.stringify(n),a=Ws.get(o);return a||(a=new Intl.NumberFormat(s,n),Ws.set(o,a)),a}(t,e).format(i)}let Vs={values:i=>P(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(y,f){let v=f.length>3?f[2].value-f[1].value:f[1].value-f[0].value;return Math.abs(v)>=1&&y!==Math.floor(y)&&(v=y-Math.floor(y)),v}(i,e)}let a=tt(Math.abs(o)),l=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),d={notation:n,minimumFractionDigits:l,maximumFractionDigits:l};return Object.assign(d,this.options.ticks.format),ti(i,s,d)},logarithmic(i,t,e){if(i===0)return"0";let s=e[t].significand||i/Math.pow(10,Math.floor(tt(i)));return[1,2,3,5,10,15].includes(s)||t>.8*e.length?Vs.numeric.call(this,i,t,e):""}};var fi={formatters:Vs};let je=Object.create(null),hs=Object.create(null);function mi(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)=>pi(n.backgroundColor),this.hoverBorderColor=(s,n)=>pi(n.borderColor),this.hoverColor=(s,n)=>pi(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 cs(this,t,e)}get(t){return mi(this,t)}describe(t,e){return cs(hs,t,e)}override(t,e){return cs(je,t,e)}route(t,e,s,n){let o=mi(this,t),a=mi(this,s),l="_"+e;Object.defineProperties(o,{[l]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let d=this[l],g=a[n];return z(d)?Object.assign({},g,d):U(d,g)},set(d){this[l]=d}}})}apply(t){t.forEach(e=>e(this))}}var Lt=new js({_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:eo},numbers:{type:"number",properties:to}}),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:fi.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 Oi(){return typeof window<"u"&&typeof document<"u"}function Li(i){let t=i.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function zi(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 $i=i=>i.ownerDocument.defaultView.getComputedStyle(i,null);function Ys(i,t){return $i(i).getPropertyValue(t)}let io=["top","right","bottom","left"];function me(i,t,e){let s={};e=e?"-"+e:"";for(let n=0;n<4;n++){let o=io[n];s[o]=parseFloat(i[t+"-"+o+e])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}let so=(i,t,e)=>(i>0||t>0)&&(!e||!e.shadowRoot);function _e(i,t){if("native"in i)return i;let{canvas:e,currentDevicePixelRatio:s}=t,n=$i(e),o=n.boxSizing==="border-box",a=me(n,"padding"),l=me(n,"border","width"),{x:d,y:g,box:y}=function(C,D){let R=C.touches,I=R&&R.length?R[0]:C,{offsetX:N,offsetY:H}=I,j,Y,Z=!1;if(so(N,H,C.target))j=N,Y=H;else{let et=D.getBoundingClientRect();j=I.clientX-et.left,Y=I.clientY-et.top,Z=!0}return{x:j,y:Y,box:Z}}(i,e),f=a.left+(y&&l.left),v=a.top+(y&&l.top),{width:M,height:T}=t;return o&&(M-=a.width+l.width,T-=a.height+l.height),{x:Math.round((d-f)/M*e.width/s),y:Math.round((g-v)/T*e.height/s)}}let Hi=i=>Math.round(10*i)/10;function Gs(i,t,e,s){let n=$i(i),o=me(n,"margin"),a=zi(n.maxWidth,i,"clientWidth")||O,l=zi(n.maxHeight,i,"clientHeight")||O,d=function(f,v,M){let T,C;if(v===void 0||M===void 0){let D=Li(f);if(D){let R=D.getBoundingClientRect(),I=$i(D),N=me(I,"border","width"),H=me(I,"padding");v=R.width-H.width-N.width,M=R.height-H.height-N.height,T=zi(I.maxWidth,D,"clientWidth"),C=zi(I.maxHeight,D,"clientHeight")}else v=f.clientWidth,M=f.clientHeight}return{width:v,height:M,maxWidth:T||O,maxHeight:C||O}}(i,t,e),{width:g,height:y}=d;if(n.boxSizing==="content-box"){let f=me(n,"border","width"),v=me(n,"padding");g-=v.width+f.width,y-=v.height+f.height}return g=Math.max(0,g-o.width),y=Math.max(0,s?g/s:y-o.height),g=Hi(Math.min(g,a,d.maxWidth)),y=Hi(Math.min(y,l,d.maxHeight)),g&&!y&&(y=Hi(g/2)),(t!==void 0||e!==void 0)&&s&&d.height&&y>d.height&&(y=d.height,g=Hi(Math.floor(y*s))),{width:g,height:y}}function Ni(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 qs=function(){let i=!1;try{let t={get passive(){return i=!0,!1}};Oi()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return i}();function p(i,t){let e=Ys(i,t),s=e&&e.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function x(i){return!i||k(i.size)||k(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 S(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,d,g,y,f,v;for(d=0;de.length){for(d=0;d0&&i.stroke()}}function st(i,t,e){return e=e||.5,!t||i&&i.x>t.left-e&&i.xt.top-e&&i.y0&&o.strokeColor!=="",d,g;for(i.save(),i.font=n.string,function(y,f){f.translation&&y.translate(f.translation[0],f.translation[1]),k(f.rotation)||y.rotate(f.rotation),f.color&&(y.fillStyle=f.color),f.textAlign&&(y.textAlign=f.textAlign),f.textBaseline&&(y.textBaseline=f.textBaseline)}(i,o),d=0;di[0]){let o=e||i;s===void 0&&(s=ds("_fallback",i));let a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:o,_fallback:s,_getTarget:n,override:l=>se([l,...i],t,o,s)};return new Proxy(a,{deleteProperty:(l,d)=>(delete l[d],delete l._keys,delete i[0][d],!0),get:(l,d)=>Gt(l,d,()=>function(g,y,f,v){let M;for(let T of y)if(M=ds(be(T,g),f),M!==void 0)return Me(g,M)?bi(f,v,g,M):M}(d,t,i,l)),getOwnPropertyDescriptor:(l,d)=>Reflect.getOwnPropertyDescriptor(l._scopes[0],d),getPrototypeOf:()=>Reflect.getPrototypeOf(i[0]),has:(l,d)=>Ii(l).includes(d),ownKeys:l=>Ii(l),set(l,d,g){let y=l._storage||(l._storage=n());return l[d]=y[d]=g,delete l._keys,!0}})}function ce(i,t,e,s){let n={_cacheable:!1,_proxy:i,_context:t,_subProxy:e,_stack:new Set,_descriptors:It(i,s),setContext:o=>ce(i,o,e,s),override:o=>ce(i.override(o),t,e,s)};return new Proxy(n,{deleteProperty:(o,a)=>(delete o[a],delete i[a],!0),get:(o,a,l)=>Gt(o,a,()=>function(d,g,y){let{_proxy:f,_context:v,_subProxy:M,_descriptors:T}=d,C=f[g];return J(C)&&T.isScriptable(g)&&(C=function(D,R,I,N){let{_proxy:H,_context:j,_subProxy:Y,_stack:Z}=I;if(Z.has(D))throw new Error("Recursion detected: "+Array.from(Z).join("->")+"->"+D);Z.add(D);let et=R(j,Y||N);return Z.delete(D),Me(D,et)&&(et=bi(H._scopes,H,D,et)),et}(g,C,d,y)),P(C)&&C.length&&(C=function(D,R,I,N){let{_proxy:H,_context:j,_subProxy:Y,_descriptors:Z}=I;if(j.index!==void 0&&N(D))return R[j.index%R.length];if(z(R[0])){let et=R,lt=H._scopes.filter(nt=>nt!==et);R=[];for(let nt of et){let gt=bi(lt,H,D,nt);R.push(ce(gt,j,Y&&Y[D],Z))}}return R}(g,C,d,T.isIndexable)),Me(g,C)&&(C=ce(C,v,M&&M[g],T)),C}(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 It(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:J(e)?e:()=>e,isIndexable:J(s)?s:()=>s}}let be=(i,t)=>i?i+At(t):t,Me=(i,t)=>z(t)&&i!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function Gt(i,t,e){if(Object.prototype.hasOwnProperty.call(i,t))return i[t];let s=e();return i[t]=s,s}function Ye(i,t,e){return J(i)?i(t,e):i}let Ie=(i,t)=>i===!0?t:typeof i=="string"?vt(t,i):void 0;function Xs(i,t,e,s,n){for(let o of t){let a=Ie(e,o);if(a){i.add(a);let l=Ye(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 bi(i,t,e,s){let n=t._rootScopes,o=Ye(t._fallback,e,s),a=[...i,...n],l=new Set;l.add(s);let d=yi(l,a,e,o||e,s);return d!==null&&(o===void 0||o===e||(d=yi(l,a,o,d,s),d!==null))&&se(Array.from(l),[""],n,o,()=>function(g,y,f){let v=g._getTarget();y in v||(v[y]={});let M=v[y];return P(M)&&z(f)?f:M||{}}(t,e,s))}function yi(i,t,e,s,n){for(;e;)e=Xs(i,t,e,s,n);return e}function ds(i,t){for(let e of t){if(!e)continue;let s=e[i];if(s!==void 0)return s}}function Ii(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 Bi(i,t,e,s){let{iScale:n}=i,{key:o="r"}=this._parsing,a=new Array(s),l,d,g,y;for(l=0,d=s;lti==="x"?"y":"x";function ei(i,t,e,s){let n=i.skip?t:i,o=t,a=e.skip?t:e,l=Ti(o,n),d=Ti(a,o),g=l/(l+d),y=d/(l+d);g=isNaN(g)?0:g,y=isNaN(y)?0:y;let f=s*g,v=s*y;return{previous:{x:o.x-f*(a.x-n.x),y:o.y-f*(a.y-n.y)},next:{x:o.x+v*(a.x-n.x),y:o.y+v*(a.y-n.y)}}}function xi(i,t="x"){let e=gs(t),s=i.length,n=Array(s).fill(0),o=Array(s),a,l,d,g=Se(i,0);for(a=0;a!g.skip)),t.cubicInterpolationMode==="monotone")xi(i,n);else{let g=s?i[i.length-1]:i[0];for(o=0,a=i.length;oi===0||i===1,jo=(i,t,e)=>-Math.pow(2,10*(i-=1))*Math.sin((i-t)*w/e),Yo=(i,t,e)=>Math.pow(2,-10*i)*Math.sin((i-t)*w/e)+1,Fi={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*V),easeOutSine:i=>Math.sin(i*V),easeInOutSine:i=>-.5*(Math.cos(b*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=>ii(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=>ii(i)?i:jo(i,.075,.3),easeOutElastic:i=>ii(i)?i:Yo(i,.075,.3),easeInOutElastic(i){return ii(i)?i:i<.5?.5*jo(2*i,.1125,.45):.5+.5*Yo(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-Fi.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*Fi.easeInBounce(2*i):.5*Fi.easeOutBounce(2*i-1)+.5};function si(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:i.y+e*(t.y-i.y)}}function Go(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 qo(i,t,e,s){let n={x:i.cp2x,y:i.cp2y},o={x:t.cp1x,y:t.cp1y},a=si(i,n,e),l=si(n,o,e),d=si(o,t,e),g=si(a,l,e),y=si(l,d,e);return si(g,y,e)}let fl=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,ml=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Xo(i,t){let e=(""+i).match(fl);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 bl=i=>+i||0;function Zs(i,t){let e={},s=z(t),n=s?Object.keys(t):t,o=z(i)?s?a=>U(i[a],i[t[a]]):a=>i[a]:()=>i;for(let a of n)e[a]=bl(o(a));return e}function no(i){return Zs(i,{top:"y",right:"x",bottom:"y",left:"x"})}function ni(i){return Zs(i,["topLeft","topRight","bottomLeft","bottomRight"])}function Kt(i){let t=no(i);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function Vt(i,t){i=i||{},t=t||Lt.font;let e=U(i.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let s=U(i.style,t.style);s&&!(""+s).match(ml)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);let n={family:U(i.family,t.family),lineHeight:Xo(U(i.lineHeight,t.lineHeight),e),size:e,style:s,weight:U(i.weight,t.weight),string:""};return n.string=x(n),n}function Ui(i,t,e,s){let n,o,a,l=!0;for(n=0,o=i.length;ne&&l===0?0:l+d;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Ge(i,t){return Object.assign(Object.create(i),t)}function vi(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 oo(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 ro(i,t){t!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",t[0],t[1]))}function Ko(i){return i==="angle"?{between:Ke,compare:Ls,normalize:ie}:{between:fe,compare:(t,e)=>t-e,normalize:t=>t}}function Qo({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 ao(i,t,e){if(!e)return[i];let{property:s,start:n,end:o}=e,a=t.length,{compare:l,between:d,normalize:g}=Ko(s),{start:y,end:f,loop:v,style:M}=function(Y,Z,et){let{property:lt,start:nt,end:gt}=et,{between:dt,normalize:rt}=Ko(lt),ct=Z.length,ht,yt,{start:Et,end:St,loop:Jt}=Y;if(Jt){for(Et+=ct,St+=ct,ht=0,yt=ct;htI||d(n,R,C)&&l(n,R)!==0,j=()=>!I||l(o,C)===0||d(o,R,C);for(let Y=y,Z=y;Y<=f;++Y)D=t[Y%a],D.skip||(C=g(D[s]),C!==R&&(I=d(C,n,o),N===null&&H()&&(N=l(C,n)===0?Y:Z),N!==null&&j()&&(T.push(Qo({start:N,end:Y,loop:v,count:a,style:M})),N=null),Z=Y,R=C));return N!==null&&T.push(Qo({start:N,end:f,loop:v,count:a,style:M})),T}function lo(i,t){let e=[],s=i.segments;for(let n=0;nv&&d[M%g].skip;)M--;return M%=g,{start:v,end:M}}(e,n,o,s);return s===!0?tr(i,[{start:a,end:l,loop:o}],e,t):tr(i,function(d,g,y,f){let v=d.length,M=[],T,C=g,D=d[g];for(T=g+1;T<=y;++T){let R=d[T%v];R.skip||R.stop?D.skip||(f=!1,M.push({start:g%v,end:(T-1)%v,loop:f}),g=C=R.stop?T:null):(C=T,D.skip&&(g=T)),D=R}return C!==null&&M.push({start:g%v,end:C%v,loop:f}),M}(e,a,l{d[a](t[e],n)&&(o.push({element:d,datasetIndex:g,index:y}),l=l||d.inRange(t.x,t.y,n))}),s&&!l?[]:o}var sr={evaluateInteractionItems:ps,modes:{index(i,t,e,s){let n=_e(t,i),o=e.axis||"x",a=e.includeInvisible||!1,l=e.intersect?ho(i,n,o,s,a):co(i,n,o,!1,s,a),d=[];return l.length?(i.getSortedVisibleDatasetMetas().forEach(g=>{let y=l[0].index,f=g.data[y];f&&!f.skip&&d.push({element:f,datasetIndex:g.index,index:y})}),d):[]},dataset(i,t,e,s){let n=_e(t,i),o=e.axis||"xy",a=e.includeInvisible||!1,l=e.intersect?ho(i,n,o,s,a):co(i,n,o,!1,s,a);if(l.length>0){let d=l[0].datasetIndex,g=i.getDatasetMeta(d).data;l=[];for(let y=0;yho(i,_e(t,i),e.axis||"xy",s,e.includeInvisible||!1),nearest(i,t,e,s){let n=_e(t,i),o=e.axis||"xy",a=e.includeInvisible||!1;return co(i,n,o,e.intersect,s,a)},x:(i,t,e,s)=>ir(i,_e(t,i),"x",e.intersect,s),y:(i,t,e,s)=>ir(i,_e(t,i),"y",e.intersect,s)}};let nr=["left","top","right","bottom"];function fs(i,t){return i.filter(e=>e.pos===t)}function or(i,t){return i.filter(e=>nr.indexOf(e.pos)===-1&&e.box.axis===t)}function ms(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 _l(i,t){let e=function(d){let g={};for(let y of d){let{stack:f,pos:v,stackWeight:M}=y;if(!f||!nr.includes(v))continue;let T=g[f]||(g[f]={count:0,placed:0,weight:0,size:0});T.count++,T.weight+=M}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 bs(i,t,e,s){let n=[],o,a,l,d,g,y;for(o=0,a=i.length,g=0;oet.box.fullSize),!0),I=ms(fs(D,"left"),!0),N=ms(fs(D,"right")),H=ms(fs(D,"top"),!0),j=ms(fs(D,"bottom")),Y=or(D,"x"),Z=or(D,"y");return{fullSize:R,leftAndTop:I.concat(H),rightAndBottom:N.concat(Z).concat(j).concat(Y),chartArea:fs(D,"chartArea"),vertical:I.concat(N).concat(Z),horizontal:H.concat(j).concat(Y)}}(i.boxes),d=l.vertical,g=l.horizontal;it(i.boxes,C=>{typeof C.beforeLayout=="function"&&C.beforeLayout()});let y=d.reduce((C,D)=>D.box.options&&D.box.options.display===!1?C:C+1,0)||1,f=Object.freeze({outerWidth:t,outerHeight:e,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/y,hBoxMaxHeight:a/2}),v=Object.assign({},n);ar(v,Kt(s));let M=Object.assign({maxPadding:v,w:o,h:a,x:n.left,y:n.top},n),T=_l(d.concat(g),f);bs(l.fullSize,M,f,T),bs(d,M,f,T),bs(g,M,f,T)&&bs(d,M,f,T),function(C){let D=C.maxPadding;function R(I){let N=Math.max(D[I]-C[I],0);return C[I]+=N,N}C.y+=R("top"),C.x+=R("left"),R("right"),R("bottom")}(M),lr(l.leftAndTop,M,f,T),M.x+=M.w,M.y+=M.h,lr(l.rightAndBottom,M,f,T),i.chartArea={left:M.left,top:M.top,right:M.left+M.w,bottom:M.top+M.h,height:M.h,width:M.w},it(l.chartArea,C=>{let D=C.box;Object.assign(D,i.chartArea),D.update(M.w,M.h,{left:0,top:0,right:0,bottom:0})})}};class uo{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 hr extends uo{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}let Qs="$chartjs",Sl={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},cr=i=>i===null||i==="",dr=!!qs&&{passive:!0};function Cl(i,t,e){i.canvas.removeEventListener(t,e,dr)}function Js(i,t){for(let e of i)if(e===t||e.contains(t))return!0}function El(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let l of o)a=a||Js(l.addedNodes,s),a=a&&!Js(l.removedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}function Tl(i,t,e){let s=i.canvas,n=new MutationObserver(o=>{let a=!1;for(let l of o)a=a||Js(l.removedNodes,s),a=a&&!Js(l.addedNodes,s);a&&e()});return n.observe(document,{childList:!0,subtree:!0}),n}let ys=new Map,ur=0;function gr(){let i=window.devicePixelRatio;i!==ur&&(ur=i,ys.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function Dl(i,t,e){let s=i.canvas,n=s&&Li(s);if(!n)return;let o=Ai((l,d)=>{let g=n.clientWidth;e(l,d),g{let d=l[0],g=d.contentRect.width,y=d.contentRect.height;g===0&&y===0||o(g,y)});return a.observe(n),function(l,d){ys.size||window.addEventListener("resize",gr),ys.set(l,d)}(i,o),a}function go(i,t,e){e&&e.disconnect(),t==="resize"&&function(s){ys.delete(s),ys.size||window.removeEventListener("resize",gr)}(i)}function Al(i,t,e){let s=i.canvas,n=Ai(o=>{i.ctx!==null&&e(function(a,l){let d=Sl[a.type]||a.type,{x:g,y}=_e(a,l);return{type:d,chart:l,native:a,x:g!==void 0?g:null,y:y!==void 0?y:null}}(o,i))},i);return function(o,a,l){o.addEventListener(a,l,dr)}(s,t,n),n}class pr extends uo{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"),d=n.getAttribute("width");if(n[Qs]={initial:{height:l,width:d,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",a.boxSizing=a.boxSizing||"border-box",cr(d)){let g=p(n,"width");g!==void 0&&(n.width=g)}if(cr(l))if(n.style.height==="")n.height=n.width/(o||2);else{let g=p(n,"height");g!==void 0&&(n.height=g)}}(t,e),s):null}releaseContext(t){let e=t.canvas;if(!e[Qs])return!1;let s=e[Qs].initial;["height","width"].forEach(o=>{let a=s[o];k(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[Qs],!0}addEventListener(t,e,s){this.removeEventListener(t,e);let n=t.$proxies||(t.$proxies={}),o={attach:El,detach:Tl,resize:Dl}[e]||Al;n[e]=o(t,e,s)}removeEventListener(t,e){let s=t.$proxies||(t.$proxies={}),n=s[e];n&&(({attach:go,detach:go,resize:go}[e]||Cl)(t,e,n),s[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,s,n){return Gs(t,e,s,n)}isAttached(t){let e=Li(t);return!(!e||!e.isConnected)}}function fr(i){return!Oi()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?hr:pr}var mr=Object.freeze({__proto__:null,BasePlatform:uo,BasicPlatform:hr,DomPlatform:pr,_detectPlatform:fr});let br="transparent",Pl={boolean:(i,t,e)=>e>.5?t:i,color(i,t,e){let s=ls(i||br),n=s.valid&&ls(t||br);return n&&n.valid?n.mix(s,e).hexString():t},number:(i,t,e)=>i+(t-i)*e};class yr{constructor(t,e,s,n){let o=e[s];n=Ui([t.to,n,o,t.from]);let a=Ui([t.from,o,n]);this._active=!0,this._fn=t.fn||Pl[t.type||typeof a],this._easing=Fi[t.easing]||Fi.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=Ui([t.to,e,n,t.from]),this._from=Ui([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,d;if(this._active=o!==l&&(a||e1?2-d:d,d=this._easing(Math.min(1,Math.max(0,d))),this._target[n]=this._fn(o,l,d))}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(!z(o))return;let a={};for(let l of e)a[l]=o[l];(P(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 d=a.options;return d?(d.$shared&&(a.options=d=Object.assign({},d,{$shared:!1,$animations:{}})),d):void(a.options=l)}(t,s);if(!n)return[];let o=this._createAnimations(n,s);return s.$shared&&function(a,l){let d=[],g=Object.keys(l);for(let y=0;y{t.options=s},()=>{}),o}_createAnimations(t,e){let s=this._properties,n=[],o=t.$animations||(t.$animations={}),a=Object.keys(e),l=Date.now(),d;for(d=a.length-1;d>=0;--d){let g=a[d];if(g.charAt(0)==="$")continue;if(g==="options"){n.push(...this._animateOptions(t,e));continue}let y=e[g],f=o[g],v=s.get(g);if(f){if(v&&f.active()){f.update(v,y,l);continue}f.cancel()}v&&v.duration?(o[g]=f=new yr(v,t,g,y),n.push(f)):t[g]=y}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?(ve.add(this._chart,s),!0):void 0}}function xr(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 vr(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 Mr(i,t){let{chart:e,_cachedMeta:s}=i,n=e._stacks||(e._stacks={}),{iScale:o,vScale:a,index:l}=s,d=o.axis,g=a.axis,y=function(M,T,C){return`${M.id}.${T.id}.${C.stack||C.type}`}(o,a,s),f=t.length,v;for(let M=0;Me[s].axis===t).shift()}function xs(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 mo=i=>i==="reset"||i==="none",Sr=(i,t)=>t?i:Object.assign({},i);class qe{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=_r(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&&xs(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,s=this.getDataset(),n=(f,v,M,T)=>f==="x"?v:f==="r"?T:M,o=e.xAxisID=U(s.xAxisID,fo(t,"x")),a=e.yAxisID=U(s.yAxisID,fo(t,"y")),l=e.rAxisID=U(s.rAxisID,fo(t,"r")),d=e.indexAxis,g=e.iAxisID=n(d,o,a,l),y=e.vAxisID=n(d,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(y)}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&&Di(this._data,this),t._stacked&&xs(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),s=this._data;if(z(e))this._data=function(n){let o=Object.keys(n),a=new Array(o.length),l,d,g;for(l=0,d=o.length;l0&&s._parsed[t-1];if(this._parsing===!1)s._parsed=n,s._sorted=!0,y=n;else{y=P(n[t])?this.parseArrayData(s,n,t,e):z(n[t])?this.parseObjectData(s,n,t,e):this.parsePrimitiveData(s,n,t,e);let M=()=>g[l]===null||v&&g[l]C&&!D.hidden&&D._stacked&&{keys:vr(R,!0),values:null})(e,s,this.chart),g={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:y,max:f}=function(C){let{min:D,max:R,minDefined:I,maxDefined:N}=C.getUserBounds();return{min:I?D:Number.NEGATIVE_INFINITY,max:N?R:Number.POSITIVE_INFINITY}}(l),v,M;function T(){M=n[v];let C=M[l.axis];return!L(M[t.axis])||y>C||f=0;--v)if(!T()){this.updateRangeFromParsed(g,t,M,d);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),f);return T.$shared&&(T.$shared=d,o[a]=Object.freeze(Sr(T,d))),T}_resolveAnimations(t,e,s){let n=this.chart,o=this._cachedDataOpts,a=`animation-${e}`,l=o[a];if(l)return l;let d;if(n.options.animation!==!1){let y=this.chart.config,f=y.datasetAnimationScopeKeys(this._type,e),v=y.getOptionScopes(this.getDataset(),f);d=y.createResolver(v,this.getContext(t,s,e))}let g=new po(n,d&&d.animations);return d&&d._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||mo(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){mo(n)?Object.assign(t,s):this._resolveAnimations(e,n).update(t,s)}updateSharedOptions(t,e,s){t&&!mo(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,d,g]of this._syncList)this[l](d,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(d(o),l=t;l{n[o]=s[o]&&s[o].active()?s[o]._to:this[o]}),n}}function Ol(i,t){let e=i.options.ticks,s=function(f){let v=f.options.offset,M=f._tickSize(),T=f._length/M+(v?0:1),C=f._maxLength/M;return Math.floor(Math.min(T,C))}(i),n=Math.min(e.maxTicksLimit||s,s),o=e.major.enabled?function(f){let v=[],M,T;for(M=0,T=f.length;Mn)return function(f,v,M,T){let C,D=0,R=M[0];for(T=Math.ceil(T),C=0;CC)return N}return Math.max(C,1)}(o,t,n);if(a>0){let f,v,M=a>1?Math.round((d-l)/(a-1)):null;for(tn(t,g,y,k(M)?0:l-M,l),f=0,v=a-1;ft==="top"||t==="left"?i[t]+e:i[t]-e,Er=(i,t)=>Math.min(t||i,i);function Tr(i,t){let e=[],s=i.length/t,n=i.length,o=0;for(;oa+l)))return g}function vs(i){return i.drawTicks?i.tickLength:0}function Dr(i,t){if(!i.display)return 0;let e=Vt(i.font,t),s=Kt(i.padding);return(P(i.text)?i.text.length:1)*e.lineHeight+s.height}function zl(i,t,e){let s=Ve(i);return(e&&t!=="right"||!e&&t==="right")&&(s=(n=>n==="left"?"right":n==="right"?"left":n)(s)),s}class oi extends Be{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=G(t,Number.POSITIVE_INFINITY),e=G(e,Number.NEGATIVE_INFINITY),s=G(s,Number.POSITIVE_INFINITY),n=G(n,Number.NEGATIVE_INFINITY),{min:G(t,s),max:G(e,n),minDefined:L(t),maxDefined:L(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 d=0,g=l.length;dn?n:s,n=o&&s>n?s:n,{min:G(s,G(n,s)),max:G(n,G(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(){X(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=Zo(this,o,n),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let d=l=o||s<=1||!this.isHorizontal())return void(this.labelRotation=n);let y=this._getLabelSizes(),f=y.widest.width,v=y.highest.height,M=Ut(this.chart.width-f,0,this.maxWidth);a=t.offset?this.maxWidth/s:M/(s-1),f+6>a&&(a=M/(s-(t.offset?.5:1)),l=this.maxHeight-vs(t.grid)-e.padding-Dr(t.title,this.chart.options.font),d=Math.sqrt(f*f+v*v),g=$e(Math.min(Math.asin(Ut((y.highest.height+6)/a,-1,1)),Math.asin(Ut(l/d,-1,1))-Math.asin(Ut(v/d,-1,1)))),g=Math.max(n,Math.min(o,g))),this.labelRotation=g}afterCalculateLabelRotation(){X(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){X(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 d=Dr(n,e.options.font);if(l?(t.width=this.maxWidth,t.height=vs(o)+d):(t.height=this.maxHeight,t.width=vs(o)+d),s.display&&this.ticks.length){let{first:g,last:y,widest:f,highest:v}=this._getLabelSizes(),M=2*s.padding,T=ee(this.labelRotation),C=Math.cos(T),D=Math.sin(T);if(l){let R=s.mirror?0:D*f.width+C*v.height;t.height=Math.min(this.maxHeight,t.height+R+M)}else{let R=s.mirror?0:C*f.width+D*v.height;t.width=Math.min(this.maxWidth,t.width+R+M)}this._calculatePadding(g,y,D,C)}}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,d=this.labelRotation!==0,g=l!=="top"&&this.axis==="x";if(this.isHorizontal()){let y=this.getPixelForTick(0)-this.left,f=this.right-this.getPixelForTick(this.ticks.length-1),v=0,M=0;d?g?(v=n*t.width,M=s*e.height):(v=s*t.height,M=n*e.width):o==="start"?M=e.width:o==="end"?v=t.width:o!=="inner"&&(v=t.width/2,M=e.width/2),this.paddingLeft=Math.max((v-y+a)*this.width/(this.width-y),0),this.paddingRight=Math.max((M-f+a)*this.width/(this.width-f),0)}else{let y=e.height/2,f=t.height/2;o==="start"?(y=0,f=t.height):o==="end"&&(y=e.height,f=0),this.paddingTop=y+a,this.paddingBottom=f+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(){X(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 dt=gt.gc,rt=dt.length/2,ct;if(rt>nt){for(ct=0;ct({width:a[lt]||0,height:l[lt]||0});return{first:et(0),last:et(e-1),widest:et(Y),highest:et(Z),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 zs(this._alignToPixels?A(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:d/n:d*n0}_computeGridLineItems(t){let e=this.axis,s=this.chart,n=this.options,{grid:o,position:a,border:l}=n,d=o.offset,g=this.isHorizontal(),y=this.ticks.length+(d?1:0),f=vs(o),v=[],M=l.setContext(this.getContext()),T=M.display?M.width:0,C=T/2,D=function(ht){return A(s,ht,T)},R,I,N,H,j,Y,Z,et,lt,nt,gt,dt;if(a==="top")R=D(this.bottom),Y=this.bottom-f,et=R-C,nt=D(t.top)+C,dt=t.bottom;else if(a==="bottom")R=D(this.top),nt=t.top,dt=D(t.bottom)-C,Y=R+C,et=this.top+f;else if(a==="left")R=D(this.right),j=this.right-f,Z=R-C,lt=D(t.left)+C,gt=t.right;else if(a==="right")R=D(this.left),lt=t.left,gt=D(t.right)-C,j=R+C,Z=this.left+f;else if(e==="x"){if(a==="center")R=D((t.top+t.bottom)/2+.5);else if(z(a)){let ht=Object.keys(a)[0],yt=a[ht];R=D(this.chart.scales[ht].getPixelForValue(yt))}nt=t.top,dt=t.bottom,Y=R+C,et=Y+f}else if(e==="y"){if(a==="center")R=D((t.left+t.right)/2);else if(z(a)){let ht=Object.keys(a)[0],yt=a[ht];R=D(this.chart.scales[ht].getPixelForValue(yt))}j=R-C,Z=j-f,lt=t.left,gt=t.right}let rt=U(n.ticks.maxTicksLimit,y),ct=Math.max(1,Math.ceil(y/rt));for(I=0;I0&&(ze-=Oe/2)}ye={left:ze,top:Le,width:Oe+Ce.width,height:Re+Ce.height,color:ht.backdropColor}}D.push({label:H,font:lt,textOffset:dt,options:{rotation:C,color:Et,strokeColor:St,strokeWidth:Jt,textAlign:xe,textBaseline:rt,translation:[j,Y],backdrop:ye}})}return D}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-ee(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,d,g;return e==="left"?n?(g=this.right+o,s==="near"?d="left":s==="center"?(d="center",g+=l/2):(d="right",g+=l)):(g=this.right-a,s==="near"?d="right":s==="center"?(d="center",g-=l/2):(d="left",g=this.left)):e==="right"?n?(g=this.left+o,s==="near"?d="right":s==="center"?(d="center",g-=l/2):(d="left",g-=l)):(g=this.left+a,s==="near"?d="left":s==="center"?(d="center",g+=l/2):(d="right",g=this.right)):d="right",{textAlign:d,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=(d,g,y)=>{y.width&&y.color&&(s.save(),s.lineWidth=y.width,s.strokeStyle=y.color,s.setLineDash(y.borderDash||[]),s.lineDashOffset=y.borderDashOffset,s.beginPath(),s.moveTo(d.x,d.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 T=M.split("."),C=T.pop(),D=[f].concat(T).join("."),R=v[M].split("."),I=R.pop(),N=R.join(".");Lt.route(D,C,N,I)})}(d,l.defaultRoutes),l.descriptors&&Lt.describe(d,l.descriptors)}(t,a,s),this.override&&Lt.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 Lt[n]&&(delete Lt[n][s],this.override&&delete je[s])}}class $l{constructor(){this.controllers=new en(qe,"datasets",!0),this.elements=new en(Be,"elements"),this.plugins=new en(Object,"plugins"),this.scales=new en(oi,"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):it(n,a=>{let l=s||this._getRegistryForType(a);this._exec(t,l,a)})})}_exec(t,e,s){let n=At(t);X(s["before"+n],[],s),e[t](s),X(s["after"+n],[],s)}_getRegistryForType(t){for(let e=0;eo.filter(l=>!a.some(d=>l.plugin.id===d.plugin.id));this._notify(n(e,s),t,"stop"),this._notify(n(s,e),t,"start")}}function Nl(i,t){return t||i!==!1?i===!0?{}:i:null}function Il(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 bo(i,t){let e=Lt.datasets[i]||{};return((t.datasets||{})[i]||{}).indexAxis||t.indexAxis||e.indexAxis||"x"}function Ar(i){if(i==="x"||i==="y"||i==="r")return i}function yo(i,...t){if(Ar(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&&Ar(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 Pr(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function Bl(i,t){let e=je[i.type]||{scales:{}},s=t.scales||{},n=bo(i.type,t),o=Object.create(null);return Object.keys(s).forEach(a=>{let l=s[a];if(!z(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 d=yo(a,l,function(f,v){if(v.data&&v.data.datasets){let M=v.data.datasets.filter(T=>T.xAxisID===f||T.yAxisID===f);if(M.length)return Pr(f,"x",M[0])||Pr(f,"y",M[0])}return{}}(a,i),Lt.scales[l.type]),g=function(f,v){return f===v?"_index_":"_value_"}(d,n),y=e.scales||{};o[a]=$t(Object.create(null),[{axis:d},l,y[d],y[g]])}),i.data.datasets.forEach(a=>{let l=a.type||i.type,d=a.indexAxis||bo(l,t),g=(je[l]||{}).scales||{};Object.keys(g).forEach(y=>{let f=function(M,T){let C=M;return M==="_index_"?C=T:M==="_value_"&&(C=T==="x"?"y":"x"),C}(y,d),v=a[f+"AxisID"]||f;o[v]=o[v]||Object.create(null),$t(o[v],[{axis:f},s[v],g[y]])})}),Object.keys(o).forEach(a=>{let l=o[a];$t(l,[Lt.scales[l.type],Lt.scale])}),o}function Rr(i){let t=i.options||(i.options={});t.plugins=U(t.plugins,{}),t.scales=Bl(i,t)}function Or(i){return(i=i||{}).datasets=i.datasets||[],i.labels=i.labels||[],i}let Lr=new Map,zr=new Set;function sn(i,t){let e=Lr.get(i);return e||(e=t(),Lr.set(i,e),zr.add(e)),e}let ws=(i,t,e)=>{let s=vt(t,e);s!==void 0&&i.add(s)};class Fl{constructor(t){this._config=function(e){return(e=e||{}).data=Or(e.data),Rr(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=Or(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(),Rr(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return sn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return sn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return sn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id;return sn(`${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 d=new Set;e.forEach(y=>{t&&(d.add(t),y.forEach(f=>ws(d,t,f))),y.forEach(f=>ws(d,n,f)),y.forEach(f=>ws(d,je[o]||{},f)),y.forEach(f=>ws(d,Lt,f)),y.forEach(f=>ws(d,hs,f))});let g=Array.from(d);return g.length===0&&g.push(Object.create(null)),zr.has(e)&&a.set(e,g),g}chartOptionScopes(){let{options:t,type:e}=this;return[t,je[e]||{},Lt.datasets[e]||{},{type:e},Lt,hs]}resolveNamedOptions(t,e,s,n=[""]){let o={$shared:!0},{resolver:a,subPrefixes:l}=$r(this._resolverCache,t,n),d=a;(function(g,y){let{isScriptable:f,isIndexable:v}=It(g);for(let M of y){let T=f(M),C=v(M),D=(C||T)&&g[M];if(T&&(J(D)||Ul(D))||C&&P(D))return!0}return!1})(a,e)&&(o.$shared=!1,d=ce(a,s=J(s)?s():s,this.createResolver(t,s,l)));for(let g of e)o[g]=d[g];return o}createResolver(t,e,s=[""],n){let{resolver:o}=$r(this._resolverCache,t,s);return z(e)?ce(o,e,void 0,n):o}}function $r(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:se(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},s.set(n,o)),o}let Ul=i=>z(i)&&Object.getOwnPropertyNames(i).some(t=>J(i[t])),Wl=["top","bottom","left","right","chartArea"];function Hr(i,t){return i==="top"||i==="bottom"||Wl.indexOf(i)===-1&&t==="x"}function Nr(i,t){return function(e,s){return e[i]===s[i]?e[t]-s[t]:e[i]-s[i]}}function Ir(i){let t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),X(e&&e.onComplete,[i],t)}function Vl(i){let t=i.chart,e=t.options.animation;X(e&&e.onProgress,[i],t)}function Br(i){return Oi()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}let nn={},Fr=i=>{let t=Br(i);return Object.values(nn).filter(e=>e.canvas===t).pop()};function jl(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 on(i,t,e){return i.options.clip?i[e]:t[e]}class Wt{static defaults=Lt;static instances=nn;static overrides=je;static registry=Pe;static version="4.4.1";static getChart=Fr;static register(...t){Pe.add(...t),Ur()}static unregister(...t){Pe.remove(...t),Ur()}constructor(t,e){let s=this.config=new Fl(e),n=Br(t),o=Fr(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||fr(n)),this.platform.updateConfig(s);let l=this.platform.acquireContext(n,a.aspectRatio),d=l&&l.canvas,g=d&&d.height,y=d&&d.width;this.id=u(),this.ctx=l,this.canvas=d,this.width=y,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 Hl,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Zi(f=>this.update(f),a.resizeDelay||0),this._dataChanges=[],nn[this.id]=this,l&&d?(ve.listen(this,"complete",Ir),ve.listen(this,"progress",Vl),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 k(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 Pe}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Ni(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return F(this.canvas,this.ctx),this}stop(){return ve.stop(this),this}resize(t,e){ve.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(),d=this.width?"resize":"attach";this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,Ni(this,l,!0)&&(this.notifyPlugins("resize",{size:a}),X(s.onResize,[this,a],this),this.attached&&this._doResize(d)&&this.render())}ensureScalesHaveIDs(){it(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],d=yo(a,l),g=d==="r",y=d==="x";return{options:l,dposition:g?"chartArea":y?"bottom":"left",dtype:g?"radialLinear":y?"category":"linear"}}))),it(o,a=>{let l=a.options,d=l.id,g=yo(d,l),y=U(l.type,a.dtype);l.position!==void 0&&Hr(l.position,g)===Hr(a.dposition)||(l.position=a.dposition),n[d]=!0;let f=null;d in s&&s[d].type===y?f=s[d]:(f=new(Pe.getScale(y))({id:d,type:y,ctx:this.ctx,chart:this}),s[f.id]=f),f.init(l,t)}),it(n,(a,l)=>{a||delete s[l]}),it(s,a=>{Qt.configure(this,a,a.options),Qt.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,y=this.data.datasets.length;g{g.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Nr("z","_idx"));let{_active:l,_lastEvent:d}=this;d?this._eventHandler(d,!0):l.length&&this._updateHoverStyles(l,l,!0),this.render()}_updateScales(){it(this.scales,t=>{Qt.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)jl(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;Qt.update(this,this.width,this.height,t);let e=this.chartArea,s=e.width<=0||e.height<=0;this._layers=[],it(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,d){let{xScale:g,yScale:y}=l;return g&&y?{left:on(g,d,"left"),right:on(g,d,"right"),top:on(y,d,"top"),bottom:on(y,d,"bottom")}:d}(t,this.chartArea),a={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",a)!==!1&&(n&&mt(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&&xt(e),a.cancelable=!1,this.notifyPlugins("afterDatasetDraw",a))}isPointInArea(t){return st(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,s,n){let o=sr.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=Ge(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);pt(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(),ve.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)};it(this.options.events,o=>s(o,n))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,s=(d,g)=>{e.addEventListener(this,d,g),t[d]=g},n=(d,g)=>{t[d]&&(e.removeEventListener(this,d,g),delete t[d])},o=(d,g)=>{this.canvas&&this.resize(d,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(){it(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},it(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,d;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),l=0,d=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}});!ft(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=(d,g)=>d.filter(y=>!g.some(f=>y.datasetIndex===f.datasetIndex&&y.index===f.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),d=c(t),g=function(f,v,M,T){return M&&f.type!=="mouseout"?T?v:f:null}(t,this._lastEvent,s,d);s&&(this._lastEvent=null,X(o.onHover,[t,l,this],this),d&&X(o.onClick,[t,l,this],this));let y=!ft(l,n);return(y||e)&&(this._active=l,this._updateHoverStyles(l,n,e)),this._lastEvent=g,y}_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 Ur(){return it(Wt.instances,i=>i._plugins.invalidate())}function wi(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class xo{static override(t){Object.assign(xo.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return wi()}parse(){return wi()}format(){return wi()}add(){return wi()}diff(){return wi()}startOf(){return wi()}endOf(){return wi()}}var Wr={_date:xo};function Yl(i){let t=i.iScale,e=function(g,y){if(!g._cache.$bar){let f=g.getMatchingVisibleMetas(y),v=[];for(let M=0,T=f.length;MM-T))}return g._cache.$bar}(t,i.type),s,n,o,a,l=t._length,d=()=>{o!==32767&&o!==-32768&&(pt(a)&&(l=Math.min(l,Math.abs(o-a)||l)),a=o)};for(s=0,n=e.length;sMath.abs(f)&&(v=f,M=y),o[a.axis]=M,o._custom={barStart:v,barEnd:M,start:d,end:g,min:y,max:f}}(i,t,e,s):t[e.axis]=e.parse(i,s),t}function jr(i,t,e,s){let n=i.iScale,o=i.vScale,a=n.getLabels(),l=n===o,d=[],g,y,f,v;for(g=e,y=e+s;gf.x,M="left",T="right"):(v=f.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=d=>+s[d];if(z(s[t])){let{key:d="value"}=this._parsing;l=g=>+vt(s[g],d)}for(o=t,a=t+e;oKe(Oe,dt,rt,!0)?1:Math.max(Le,Le*Z,ze,ze*Z),Jt=(Oe,Le,ze)=>Ke(Oe,dt,rt,!0)?-1:Math.min(Le,Le*Z,ze,ze*Z),ye=St(0,ct,yt),xe=St(V,ht,Et),Ce=Jt(b,ct,yt),Re=Jt(b+V,ht,Et);et=(ye-Ce)/2,lt=(xe-Re)/2,nt=-(ye+Ce)/2,gt=-(xe+Re)/2}return{ratioX:et,ratioY:lt,offsetX:nt,offsetY:gt}}(f,y,d),D=(s.width-a)/v,R=(s.height-a)/M,I=Math.max(Math.min(D,R)/2,0),N=ut(this.options.radius,I),H=(N-Math.max(N*d,0))/this._getVisibleDatasetWeightTotal();this.offsetX=T*N,this.offsetY=C*N,n.total=this.calculateTotal(),this.outerRadius=N-H*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-H*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/w)}updateElements(t,e,s,n){let o=n==="reset",a=this.chart,l=a.chartArea,d=a.options.animation,g=(l.left+l.right)/2,y=(l.top+l.bottom)/2,f=o&&d.animateScale,v=f?0:this.innerRadius,M=f?0:this.outerRadius,{sharedOptions:T,includeOptions:C}=this._getSharedOptions(e,n),D,R=this._getRotation();for(D=0;D0&&!isNaN(t)?w*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,s=this.chart,n=s.data.labels||[],o=ti(e._parsed[t],s.options.locale);return{label:n[t]||"",value:o}}getMaxBorderWidth(t){let e=0,s=this.chart,n,o,a,l,d;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=ti(e._parsed[t].r,s.options.locale);return{label:n[t]||"",value:o}}parseObjectData(t,e,s,n){return Bi.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,d=this._cachedMeta.rScale,g=d.xCenter,y=d.yCenter,f=d.getIndexAngle(0)-.5*b,v,M=f,T=360/this.countVisibleElements();for(v=0;v{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&e++}),e}_computeAngle(t,e,s){return this.chart.getDataVisibility(t)?ee(this.resolveDataElementOptions(t,e).angle||s):0}}var Xr=Object.freeze({__proto__:null,BarController:class extends qe{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 jr(i,t,e,s)}parseArrayData(i,t,e,s){return jr(i,t,e,s)}parseObjectData(i,t,e,s){let{iScale:n,vScale:o}=i,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,d=n.axis==="x"?a:l,g=o.axis==="x"?a:l,y=[],f,v,M,T;for(f=e,v=e+s;fl.controller.options.grouped),n=e.options.stacked,o=[],a=l=>{let d=l.controller.getParsed(t),g=d&&d[l.vScale.axis];if(k(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=Z?1:-1)}(f,t,a)*o,v===a&&(D-=f/2);let R=t.getPixelForDecimal(0),I=t.getPixelForDecimal(1),N=Math.min(R,I),H=Math.max(R,I);D=Math.max(Math.min(D,H),N),y=D+f,e&&!g&&(l._stacks[t.axis]._visualValues[s]=t.getValueForPixel(y)-t.getValueForPixel(D))}if(D===t.getPixelForValue(a)){let R=ot(f)*t.getLineWidthForValue(a)/2;D+=R,f-=R}return{size:f,base:D,head:y,center:y+f/2}}_calculateBarIndexPixels(i,t){let e=t.scale,s=this.options,n=s.skipNull,o=U(s.maxBarThickness,1/0),a,l;if(t.grouped){let d=n?this._getStackCount(i):t.stackCount,g=s.barThickness==="flex"?function(f,v,M,T){let C=v.pixels,D=C[f],R=f>0?C[f-1]:null,I=f=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),d=o._custom;return{label:e[i]||"",value:"("+a+", "+l+(d?", "+d:"")+")"}}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:d}=this._getSharedOptions(t,s),g=o.axis,y=a.axis;for(let f=t;f0&&this.getParsed(t-1);for(let H=0;H=R){Y.skip=!0;continue}let Z=this.getParsed(H),et=k(Z[v]),lt=Y[f]=o.getPixelForValue(Z[f],H),nt=Y[v]=n||et?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,Z,l):Z[v],H);Y.skip=isNaN(lt)||isNaN(nt)||et,Y.stop=H>0&&Math.abs(Z[f]-N[f])>C,T&&(Y.parsed=Z,Y.raw=d.data[H]),y&&(Y.options=g||this.resolveDataElementOptions(H,j.active?"active":s)),D||this.updateElement(j,H,Y,s),N=Z}}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 wo{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:qr,RadarController:class extends qe{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 Bi.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 N=t;N0&&Math.abs(j[v]-I[v])>D,C&&(Y.parsed=j,Y.raw=d.data[N]),f&&(Y.options=y||this.resolveDataElementOptions(N,H.active?"active":s)),R||this.updateElement(H,N,Y,s),I=j}this.updateSharedOptions(y,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 Xl(i,t,e,s){let n=Zs(i.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]),o=(e-t)/2,a=Math.min(o,s*t/2),l=d=>{let g=(e-Math.min(o,d))*s/2;return Ut(d,0,Math.min(o,g))};return{outerStart:l(n.outerStart),outerEnd:l(n.outerEnd),innerStart:Ut(n.innerStart,0,a),innerEnd:Ut(n.innerEnd,0,a)}}function Wi(i,t,e,s){return{x:e+i*Math.cos(t),y:s+i*Math.sin(t)}}function rn(i,t,e,s,n,o){let{x:a,y:l,startAngle:d,pixelMargin:g,innerRadius:y}=t,f=Math.max(t.outerRadius+s+e-g,0),v=y>0?y+s+e+g:0,M=0,T=n-d;if(s){let ct=((y>0?y-s:0)+(f>0?f-s:0))/2;M=(T-(ct!==0?T*ct/(ct+s):T))/2}let C=(T-Math.max(.001,T*f-e/b)/f)/2,D=d+C+M,R=n-C-M,{outerStart:I,outerEnd:N,innerStart:H,innerEnd:j}=Xl(t,v,f,R-D),Y=f-I,Z=f-N,et=D+I/Y,lt=R-N/Z,nt=v+H,gt=v+j,dt=D+H/nt,rt=R-j/gt;if(i.beginPath(),o){let ct=(et+lt)/2;if(i.arc(a,l,f,et,ct),i.arc(a,l,f,ct,lt),N>0){let St=Wi(Z,lt,a,l);i.arc(St.x,St.y,N,lt,R+V)}let ht=Wi(gt,R,a,l);if(i.lineTo(ht.x,ht.y),j>0){let St=Wi(gt,rt,a,l);i.arc(St.x,St.y,j,R+V,rt+Math.PI)}let yt=(R-j/v+(D+H/v))/2;if(i.arc(a,l,v,R-j/v,yt,!0),i.arc(a,l,v,yt,D+H/v,!0),H>0){let St=Wi(nt,dt,a,l);i.arc(St.x,St.y,H,dt+Math.PI,D-V)}let Et=Wi(Y,D,a,l);if(i.lineTo(Et.x,Et.y),I>0){let St=Wi(Y,et,a,l);i.arc(St.x,St.y,I,D-V,et)}}else{i.moveTo(a,l);let ct=Math.cos(et)*f+a,ht=Math.sin(et)*f+l;i.lineTo(ct,ht);let yt=Math.cos(lt)*f+a,Et=Math.sin(lt)*f+l;i.lineTo(yt,Et)}i.closePath()}function Zl(i,t,e,s,n){let{fullCircles:o,startAngle:a,circumference:l,options:d}=t,{borderWidth:g,borderJoinStyle:y,borderDash:f,borderDashOffset:v}=d,M=d.borderAlign==="inner";if(!g)return;i.setLineDash(f||[]),i.lineDashOffset=v,M?(i.lineWidth=2*g,i.lineJoin=y||"round"):(i.lineWidth=g,i.lineJoin=y||"bevel");let T=t.endAngle;if(o){rn(i,t,e,s,T,n);for(let C=0;CN?(et=N/Z,C.arc(H,j,Z,R+et,I-et,!0)):C.arc(H,j,N,R+V,I-V),C.closePath(),C.clip()}(i,t,T),o||(rn(i,t,e,s,T,n),i.stroke())}function Zr(i,t,e=t){i.lineCap=U(e.borderCapStyle,t.borderCapStyle),i.setLineDash(U(e.borderDash,t.borderDash)),i.lineDashOffset=U(e.borderDashOffset,t.borderDashOffset),i.lineJoin=U(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=U(e.borderWidth,t.borderWidth),i.strokeStyle=U(e.borderColor,t.borderColor)}function Kl(i,t,e){i.lineTo(e.x,e.y)}function Kr(i,t,e={}){let s=i.length,{start:n=0,end:o=s-1}=e,{start:a,end:l}=t,d=Math.max(n,a),g=Math.min(o,l),y=nl&&o>l;return{count:s,start:d,loop:t.loop,ilen:g(a+(g?l-H:H))%o,N=()=>{M!==T&&(i.lineTo(D,T),i.lineTo(D,M),i.lineTo(D,C))};for(d&&(f=n[I(0)],i.moveTo(f.x,f.y)),y=0;y<=l;++y){if(f=n[I(y)],f.skip)continue;let H=f.x,j=f.y,Y=0|H;Y===v?(jT&&(T=j),D=(R*D+H)/++R):(N(),i.lineTo(H,j),v=Y,R=0,M=T=j),C=j}N()}function _o(i){let t=i.options,e=t.borderDash&&t.borderDash.length;return i._decimated||i._loop||t.tension||t.cubicInterpolationMode==="monotone"||t.stepped||e?Ql:Jl}let th=typeof Path2D=="function";function eh(i,t,e,s){th&&!t.options.segment?function(n,o,a,l){let d=o._path;d||(d=o._path=new Path2D,o.path(d,a,l)&&d.closePath()),Zr(n,o.options),n.stroke(d)}(i,t,e,s):function(n,o,a,l){let{segments:d,options:g}=o,y=_o(o);for(let f of d)Zr(n,g,f.style),n.beginPath(),y(n,o,f,{start:a,end:a+l-1})&&n.closePath(),n.stroke()}(i,t,e,s)}class an extends Be{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;de(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=Jo(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=lo(this,{property:e,start:n,end:n});if(!a.length)return;let l=[],d=function(f){return f.stepped?Go:f.tension||f.cubicInterpolationMode==="monotone"?qo:si}(s),g,y;for(g=0,y=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}=ji(s,{x:i,y:t}),{startAngle:a,endAngle:l,innerRadius:d,outerRadius:g,circumference:y}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],e),f=(this.options.spacing+this.options.borderWidth)/2,v=U(y,l-a)>=w||Ke(n,a,l),M=fe(o,d+f,g+f);return v&&M}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:d}=this.options,g=(s+n)/2,y=(o+a+d+l)/2;return{x:t+Math.cos(g)*y,y:e+Math.sin(g)*y}}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>w?Math.floor(e/w):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(b,e||0)));i.fillStyle=t.backgroundColor,i.strokeStyle=t.borderColor,function(d,g,y,f,v){let{fullCircles:M,startAngle:T,circumference:C}=g,D=g.endAngle;if(M){rn(d,g,y,f,D,v);for(let R=0;R(typeof a=="string"?(l=o.push(a)-1,d.unshift({index:l,label:a})):isNaN(a)&&(l=null),l))(i,t,e,s):n!==i.lastIndexOf(t)?e:n}function ta(i){let t=this.getLabels();return i>=0&&in=e?n:d,l=d=>o=s?o:d;if(t){let d=ot(n),g=ot(o);d<0&&g<0?l(0):d>0&&g>0&&a(0)}if(n===o){let d=o===0?1:Math.abs(.05*o);l(o+d),t||a(n-d)}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:d,step:g,min:y,max:f,precision:v,count:M,maxTicks:T,maxDigits:C,includeBounds:D}=o,R=g||1,I=T-1,{min:N,max:H}=a,j=!k(y),Y=!k(f),Z=!k(M),et=(H-N)/(C+1),lt,nt,gt,dt,rt=ne((H-N)/I/R)*R;if(rt<1e-14&&!j&&!Y)return[{value:N},{value:H}];dt=Math.ceil(H/rt)-Math.floor(N/rt),dt>I&&(rt=ne(dt*rt/I/R)*R),k(v)||(lt=Math.pow(10,v),rt=Math.ceil(rt*lt)/lt),d==="ticks"?(nt=Math.floor(N/rt)*rt,gt=Math.ceil(H/rt)*rt):(nt=N,gt=H),j&&Y&&g&&ae((f-y)/g,rt/1e3)?(dt=Math.round(Math.min((f-y)/rt,T)),rt=(f-y)/dt,nt=y,gt=f):Z?(nt=j?y:nt,gt=Y?f:gt,dt=M-1,rt=(gt-nt)/dt):(dt=(gt-nt)/rt,dt=_t(dt,Math.round(dt),rt/1e3)?Math.round(dt):Math.ceil(dt));let ct=Math.max(He(rt),He(nt));lt=Math.pow(10,k(v)?ct:v),nt=Math.round(nt*lt)/lt,gt=Math.round(gt*lt)/lt;let ht=0;for(j&&(D&&nt!==y?(l.push({value:y}),ntf)break;l.push({value:yt})}return Y&&D&>!==f?l.length&&_t(l[l.length-1].value,f,ea(f,et,o))?l[l.length-1].value=f:l.push({value:f}):Y&>!==f||l.push({value:gt}),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"&&We(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 ti(t,this.chart.options.locale,this.options.ticks.format)}}class oh extends ln{static id="linear";static defaults={ticks:{callback:fi.formatters.numeric}};determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=L(t)?t:0,this.max=L(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,s=ee(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 _s=i=>Math.floor(tt(i)),_i=(i,t)=>Math.pow(10,_s(i)+t);function ia(i){return i/Math.pow(10,_s(i))===1}function sa(i,t,e){let s=Math.pow(10,e),n=Math.floor(i/s);return Math.ceil(t/s)-n}function rh(i,{min:t,max:e}){t=G(i.min,t);let s=[],n=_s(t),o=function(T,C){let D=_s(C-T);for(;sa(T,C,D)>10;)D++;for(;sa(T,C,D)<10;)D--;return Math.min(D,_s(T))}(t,e),a=o<0?Math.pow(10,Math.abs(o)):1,l=Math.pow(10,o),d=n>o?Math.pow(10,n):0,g=Math.round((t-d)*a)/a,y=Math.floor((t-d)/l/10)*l*10,f=Math.floor((g-y)/Math.pow(10,o)),v=G(i.min,Math.round((d+y+f*Math.pow(10,o))*a)/a);for(;v=10?f=f<15?15:20:f++,f>=20&&(o++,f=2,a=o>=0?1:a),v=Math.round((d+y+f*Math.pow(10,o))*a)/a;let M=G(i.max,v);return s.push({value:M,major:ia(M),significand:f}),s}class ah extends oi{static id="logarithmic";static defaults={ticks:{callback:fi.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=ln.prototype.parse.apply(this,[t,e]);if(s!==0)return L(s)&&s>0?s:null;this._zero=!0}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=L(t)?Math.max(0,t):null,this.max=L(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!L(this._userMin)&&(this.min=t===_i(this.min,0)?_i(this.min,-1):_i(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(_i(s,-1)),a(_i(n,1)))),s<=0&&o(_i(n,-1)),n<=0&&a(_i(s,1)),this.min=s,this.max=n}buildTicks(){let t=this.options,e=rh({min:this._userMin,max:this._userMax},this);return t.bounds==="ticks"&&We(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":ti(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=tt(t),this._valueRange=tt(this.max)-tt(t)}getPixelForValue(t){return t!==void 0&&t!==0||(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(tt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function Co(i){let t=i.ticks;if(t.display&&i.display){let e=Kt(t.backdropPadding);return U(t.font&&t.font.size,Lt.font.size)+e.height}return 0}function na(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 lh(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?b/o:0;for(let f=0;ft.r&&(l=(s.end-t.r)/o,i.r=Math.max(i.r,t.r+l)),n.startt.b&&(d=(n.end-t.b)/a,i.b=Math.max(i.b,t.b+d))}function ch(i,t,e){let s=i.drawingArea,{extra:n,additionalAngle:o,padding:a,size:l}=e,d=i.getPointPosition(t,s+n+a,o),g=Math.round($e(ie(d.angle+V))),y=function(M,T,C){return C===90||C===270?M-=T/2:(C>270||C<90)&&(M-=T),M}(d.y,l.h,g),f=function(M){return M===0||M===180?"center":M<180?"left":"right"}(g),v=function(M,T,C){return C==="right"?M-=T:C==="center"&&(M-=T/2),M}(d.x,l.w,f);return{visible:!0,x:d.x,y,textAlign:f,left:v,top:y,right:v+l.w,bottom:y+l.h}}function dh(i,t){if(!t)return!0;let{left:e,top:s,right:n,bottom:o}=i;return!(st({x:e,y:s},t)||st({x:e,y:o},t)||st({x:n,y:s},t)||st({x:n,y:o},t))}function uh(i,t,e){let{left:s,top:n,right:o,bottom:a}=e,{backdropColor:l}=t;if(!k(l)){let d=ni(t.borderRadius),g=Kt(t.backdropPadding);i.fillStyle=l;let y=s-g.left,f=n-g.top,v=o-s+g.width,M=a-n+g.height;Object.values(d).some(T=>T!==0)?(i.beginPath(),ke(i,{x:y,y:f,w:v,h:M,radius:d}),i.fill()):i.fillRect(y,f,v,M)}}function oa(i,t,e,s){let{ctx:n}=i;if(e)n.arc(i.xCenter,i.yCenter,t,0,w);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=Kt(Co(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=L(t)&&!isNaN(t)?t:0,this.max=L(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Co(this.options))}generateTickLabels(t){ln.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,s)=>{let n=X(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?lh(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 ie(t*(w/(this._pointLabels.length||1))+ee(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(k(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(k(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;T--){let C=y._pointLabelItems[T];if(!C.visible)continue;let D=M.setContext(y.getPointLabelContext(T));uh(v,D,C);let R=Vt(D.font),{x:I,y:N,textAlign:H}=C;he(v,y._pointLabels[T],I,N+R.lineHeight/2,R,{color:D.color,textAlign:H,textBaseline:"middle"})}}(this,a),n.display&&this.ticks.forEach((y,f)=>{if(f!==0){d=this.getDistanceFromCenterForValue(y.value);let v=this.getContext(f),M=n.setContext(v),T=o.setContext(v);(function(C,D,R,I,N){let H=C.ctx,j=D.circular,{color:Y,lineWidth:Z}=D;!j&&!I||!Y||!Z||R<0||(H.save(),H.strokeStyle=Y,H.lineWidth=Z,H.setLineDash(N.dash),H.lineDashOffset=N.dashOffset,H.beginPath(),oa(C,R,j,I),H.closePath(),H.stroke(),H.restore())})(this,M,d,a,T)}}),s.display){for(t.save(),l=a-1;l>=0;l--){let y=s.setContext(this.getPointLabelContext(l)),{color:f,lineWidth:v}=y;v&&f&&(t.lineWidth=v,t.strokeStyle=f,t.setLineDash(y.borderDash),t.lineDashOffset=y.borderDashOffset,d=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),g=this.getPointPosition(l,d),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,d)=>{if(d===0&&!e.reverse)return;let g=s.setContext(this.getContext(d)),y=Vt(g.font);if(o=this.getDistanceFromCenterForValue(this.ticks[d].value),g.showLabelBackdrop){t.font=y.string,a=t.measureText(l.label).width,t.fillStyle=g.backdropColor;let f=Kt(g.backdropPadding);t.fillRect(-a/2-f.left,-o-y.size/2-f.top,a+f.width,y.size+f.height)}he(t,l.label,0,-o,y,{color:g.color,strokeColor:g.textStrokeColor,strokeWidth:g.textStrokeWidth})}),t.restore()}drawTitle(){}}let hn={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}},ue=Object.keys(hn);function ra(i,t){return i-t}function aa(i,t){if(k(t))return null;let e=i._adapter,{parser:s,round:n,isoWeekday:o}=i._parseOpts,a=t;return typeof s=="function"&&(a=s(a)),L(a)||(a=typeof s=="string"?e.parse(a,s):e.parse(a)),a===null?null:(n&&(a=n!=="week"||!Xt(o)&&o!==!0?e.startOf(a,n):e.startOf(a,"isoWeek",o)),+a)}function la(i,t,e,s){let n=ue.length;for(let o=ue.indexOf(i);o=t?e[s]:e[n]]=!0}}else i[t]=!0}function ca(i,t,e){let s=[],n={},o=t.length,a,l;for(a=0;a=0&&(g[D].major=!0);return g}(i,s,n,e):s}class Eo extends oi{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 Wr._date(t.adapters.date);n.init(e),$t(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:aa(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 d(g){a||isNaN(g.min)||(n=Math.min(n,g.min)),l||isNaN(g.max)||(o=Math.max(o,g.max))}a&&l||(d(this._getLabelBounds()),t.bounds==="ticks"&&t.ticks.source==="labels"||d(this.getMinMax(!1))),n=L(n)&&!isNaN(n)?n:+e.startOf(Date.now(),s),o=L(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=Yi(n,o,this.max);return this._unit=e.unit||(s.autoSkip?la(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):function(l,d,g,y,f){for(let v=ue.length-1;v>=ue.indexOf(g);v--){let M=ue[v];if(hn[M].common&&l._adapter.diff(f,y,M)>=d-1)return M}return ue[g?ue.indexOf(g):0]}(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=s.major.enabled&&this._unit!=="year"?function(l){for(let d=ue.indexOf(l)+1,g=ue.length;d+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=Ut(n,0,a),o=Ut(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||la(o.minUnit,e,s,this._getLabelCapacity(e)),l=U(n.ticks.stepSize,1),d=a==="week"&&o.isoWeekday,g=Xt(d)||d===!0,y={},f,v,M=e;if(g&&(M=+t.startOf(M,"isoWeek",d)),M=+t.startOf(M,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 T=n.ticks.source==="data"&&this.getDataTimestamps();for(f=M,v=0;f+C)}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 X(a,[t,e,s],this);let l=o.time.displayFormats,d=this._unit,g=this._majorUnit,y=d&&l[d],f=g&&l[g],v=s[e],M=g&&f&&v&&v.major;return this._adapter.format(t,n||(M?f:y))}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[d].pos&&({lo:l,hi:d}=Yt(i,"pos",t)),{pos:s,time:o}=i[l],{pos:n,time:a}=i[d]):(t>=i[l].time&&t<=i[d].time&&({lo:l,hi:d}=Yt(i,"time",t)),{time:s,pos:o}=i[l],{time:n,pos:a}=i[d]);let g=n-s;return g?o+(a-o)*(t-s)/g:o}var da=Object.freeze({__proto__:null,CategoryScale:class extends oi{static id="category";static defaults={ticks:{callback:ta}};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(k(i))return null;let e=this.getLabels();return((s,n)=>s===null?null:Ut(Math.round(s),0,n))(t=isFinite(t)&&e[t]===i?t:nh(e,i,U(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 ta.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:oh,LogarithmicScale:ah,RadialLinearScale:gh,TimeScale:Eo,TimeSeriesScale:class extends Eo{static id="timeseries";static defaults=Eo.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=cn(t,this.min),this._tableRange=cn(t,this.max)-this._minPos,super.initOffsets(i)}buildLookupTable(i){let{min:t,max:e}=this,s=[],n=[],o,a,l,d,g;for(o=0,a=i.length;o=t&&d<=e&&s.push(d);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(cn(this._table,i)-this._minPos)/this._tableRange}getValueForPixel(i){let t=this._offsets,e=this.getDecimalForPixel(i)/t.factor-t.end;return cn(this._table,e*this._tableRange+this._minPos,!0)}}});let To=["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)"],ua=To.map(i=>i.replace("rgb(","rgba(").replace(")",", 0.5)"));function ga(i){return To[i%To.length]}function pa(i){return ua[i%ua.length]}function ph(i){let t=0;return(e,s)=>{let n=i.getDatasetMeta(s).controller;n instanceof wo?t=function(o,a){return o.backgroundColor=o.data.map(()=>ga(a++)),a}(e,t):n instanceof qr?t=function(o,a){return o.backgroundColor=o.data.map(()=>pa(a++)),a}(e,t):n&&(t=function(o,a){return o.borderColor=ga(a),o.backgroundColor=pa(a),++a}(e,t))}}function fa(i){let t;for(t in i)if(i[t].borderColor||i[t].backgroundColor)return!0;return!1}var fh={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&&(fa(s)||(a=n)&&(a.borderColor||a.backgroundColor)||o&&fa(o)))return;var a;let l=ph(i);s.forEach(l)}};function ma(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 ba(i){i.data.datasets.forEach(t=>{ma(t)})}var mh={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled)return void ba(i);let s=i.width;i.data.datasets.forEach((n,o)=>{let{_data:a,indexAxis:l}=n,d=i.getDatasetMeta(o),g=a||n.data;if(Ui([l,i.options.indexAxis])==="y"||!d.controller.supportsDecimation)return;let y=i.scales[d.xAxisID];if(y.type!=="linear"&&y.type!=="time"||i.options.parsing)return;let{start:f,count:v}=function(T,C){let D=C.length,R,I=0,{iScale:N}=T,{min:H,max:j,minDefined:Y,maxDefined:Z}=N.getUserBounds();return Y&&(I=Ut(Yt(C,N.axis,H).lo,0,D-1)),R=Z?Ut(Yt(C,N.axis,j).hi+1,I,D)-I:D-I,{start:I,count:R}}(d,g);if(v<=(e.threshold||4*s))return void ma(n);let M;switch(k(a)&&(n._data=g,delete n.data,Object.defineProperty(n,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(T){this._data=T}})),e.algorithm){case"lttb":M=function(T,C,D,R,I){let N=I.samples||R;if(N>=D)return T.slice(C,C+D);let H=[],j=(D-2)/(N-2),Y=0,Z=C+D-1,et,lt,nt,gt,dt,rt=C;for(H[Y++]=T[rt],et=0;etnt&&(nt=gt,lt=T[ct],dt=ct);H[Y++]=lt,rt=dt}return H[Y++]=T[Z],H}(g,f,v,s,e);break;case"min-max":M=function(T,C,D,R){let I,N,H,j,Y,Z,et,lt,nt,gt,dt=0,rt=0,ct=[],ht=C+D-1,yt=T[C].x,Et=T[ht].x-yt;for(I=C;Igt&&(gt=j,et=I),dt=(rt*dt+N.x)/++rt;else{let Jt=I-1;if(!k(Z)&&!k(et)){let ye=Math.min(Z,et),xe=Math.max(Z,et);ye!==lt&&ye!==Jt&&ct.push({...T[ye],x:dt}),xe!==lt&&xe!==Jt&&ct.push({...T[xe],x:dt})}I>0&&Jt!==lt&&ct.push(T[Jt]),ct.push(N),Y=St,rt=0,nt=gt=j,Z=et=lt=I}}return ct}(g,f,v,s);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}n._decimated=M})},destroy(i){ba(i)}};function Do(i,t,e,s){if(s)return;let n=t[i],o=e[i];return i==="angle"&&(n=ie(n),o=ie(o)),{property:i,start:n,end:o}}function Ao(i,t,e){for(;t>i;t--){let s=e[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function ya(i,t,e,s){return i&&t?s(i[e],t[e]):i?i[e]:t?t[e]:0}function xa(i,t){let e=[],s=!1;return P(i)?(s=!0,e=i):e=function(n,o){let{x:a=null,y:l=null}=n||{},d=o.points,g=[];return o.segments.forEach(({start:y,end:f})=>{f=Ao(y,f,d);let v=d[y],M=d[f];l!==null?(g.push({x:v.x,y:l}),g.push({x:M.x,y:l})):a!==null&&(g.push({x:a,y:v.y}),g.push({x:a,y:M.y}))}),g}(i,t),e.length?new an({points:e,options:{tension:0},_loop:s,_fullLoop:s}):null}function va(i){return i&&i.fill!==!1}function bh(i,t,e){let s=i[t].fill,n=[t],o;if(!e)return s;for(;s!==!1&&n.indexOf(s)===-1;){if(!L(s))return s;if(o=i[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function yh(i,t,e){let s=function(o){let a=o.options,l=a.fill,d=U(l&&l.target,l);return d===void 0&&(d=!!a.backgroundColor),d===!1||d===null?!1:d===!0?"origin":d}(i);if(z(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return L(n)&&Math.floor(n)===n?function(o,a,l,d){return o!=="-"&&o!=="+"||(l=a+l),l===a||l<0||l>=d?!1:l}(s[0],t,n,e):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function xh(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&&Po(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;va(o)&&Po(i.ctx,o,i.chartArea)}},beforeDatasetDraw(i,t,e){let s=t.meta.$filler;va(s)&&e.drawTime==="beforeDatasetDraw"&&Po(i.ctx,s,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};let Sa=(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 Ca extends Be{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=X(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=Vt(s.font),o=n.size,a=this._computeTitleHeight(),{boxWidth:l,itemHeight:d}=Sa(s,o),g,y;e.font=n.string,this.isHorizontal()?(g=this.maxWidth,y=this._fitRows(a,o,l,d)+10):(y=this.maxHeight,g=this._fitCols(a,n,l,d)+10),this.width=Math.min(g,t.maxWidth||this.maxWidth),this.height=Math.min(y,t.maxHeight||this.maxHeight)}_fitRows(t,e,s,n){let{ctx:o,maxWidth:a,options:{labels:{padding:l}}}=this,d=this.legendHitBoxes=[],g=this.lineWidths=[0],y=n+l,f=t;o.textAlign="left",o.textBaseline="middle";let v=-1,M=-y;return this.legendItems.forEach((T,C)=>{let D=s+e/2+o.measureText(T.text).width;(C===0||g[g.length-1]+D+2*l>a)&&(f+=y,g[g.length-(C>0?0:1)]=0,M+=y,v++),d[C]={left:0,top:M,row:v,width:D,height:n},g[g.length-1]+=D+l}),f}_fitCols(t,e,s,n){let{ctx:o,maxHeight:a,options:{labels:{padding:l}}}=this,d=this.legendHitBoxes=[],g=this.columnSizes=[],y=a-t,f=l,v=0,M=0,T=0,C=0;return this.legendItems.forEach((D,R)=>{let{itemWidth:I,itemHeight:N}=function(H,j,Y,Z,et){let lt=function(gt,dt,rt,ct){let ht=gt.text;return ht&&typeof ht!="string"&&(ht=ht.reduce((yt,Et)=>yt.length>Et.length?yt:Et)),dt+rt.size/2+ct.measureText(ht).width}(Z,H,j,Y),nt=function(gt,dt,rt){let ct=gt;return typeof dt.text!="string"&&(ct=Ea(dt,rt)),ct}(et,Z,j.lineHeight);return{itemWidth:lt,itemHeight:nt}}(s,e,o,D,n);R>0&&M+N+2*l>y&&(f+=v+l,g.push({width:v,height:M}),T+=v+l,C++,v=M=0),d[R]={left:T,top:M,col:C,width:I,height:N},v=Math.max(v,I),M+=N+l}),f+=v,g.push({width:v,height:M}),f}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:s,labels:{padding:n},rtl:o}}=this,a=vi(o,this.left,this.width);if(this.isHorizontal()){let l=0,d=jt(s,this.left+n,this.right-this.lineWidths[l]);for(let g of e)l!==g.row&&(l=g.row,d=jt(s,this.left+n,this.right-this.lineWidths[l])),g.top+=this.top+t+n,g.left=a.leftForLtr(a.x(d),g.width),d+=g.width+n}else{let l=0,d=jt(s,this.top+t+n,this.bottom-this.columnSizes[l].height);for(let g of e)g.col!==l&&(l=g.col,d=jt(s,this.top+t+n,this.bottom-this.columnSizes[l].height)),g.top=d,g.left+=this.left+n,g.left=a.leftForLtr(a.x(g.left),g.width),d+=g.height+n}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;mt(t,this),this._draw(),xt(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:s,ctx:n}=this,{align:o,labels:a}=t,l=Lt.color,d=vi(t.rtl,this.left,this.width),g=Vt(a.font),{padding:y}=a,f=g.size,v=f/2,M;this.drawTitle(),n.textAlign=d.textAlign("left"),n.textBaseline="middle",n.lineWidth=.5,n.font=g.string;let{boxWidth:T,boxHeight:C,itemHeight:D}=Sa(a,f),R=this.isHorizontal(),I=this._computeTitleHeight();M=R?{x:jt(o,this.left+y,this.right-s[0]),y:this.top+y+I,line:0}:{x:this.left+y,y:jt(o,this.top+I+y,this.bottom-e[0].height),line:0},oo(this.ctx,t.textDirection);let N=D+y;this.legendItems.forEach((H,j)=>{n.strokeStyle=H.fontColor,n.fillStyle=H.fontColor;let Y=n.measureText(H.text).width,Z=d.textAlign(H.textAlign||(H.textAlign=a.textAlign)),et=T+v+Y,lt=M.x,nt=M.y;if(d.setWidth(this.width),R?j>0&<+et+y>this.right&&(nt=M.y+=N,M.line++,lt=M.x=jt(o,this.left+y,this.right-s[M.line])):j>0&&nt+N>this.bottom&&(lt=M.x=lt+e[M.line].width+y,M.line++,nt=M.y=jt(o,this.top+I+y,this.bottom-e[M.line].height)),function(gt,dt,rt){if(isNaN(T)||T<=0||isNaN(C)||C<0)return;n.save();let ct=U(rt.lineWidth,1);if(n.fillStyle=U(rt.fillStyle,l),n.lineCap=U(rt.lineCap,"butt"),n.lineDashOffset=U(rt.lineDashOffset,0),n.lineJoin=U(rt.lineJoin,"miter"),n.lineWidth=ct,n.strokeStyle=U(rt.strokeStyle,l),n.setLineDash(U(rt.lineDash,[])),a.usePointStyle){let ht={radius:C*Math.SQRT2/2,pointStyle:rt.pointStyle,rotation:rt.rotation,borderWidth:ct},yt=d.xPlus(gt,T/2);Q(n,ht,yt,dt+v,a.pointStyleWidth&&T)}else{let ht=dt+Math.max((f-C)/2,0),yt=d.leftForLtr(gt,T),Et=ni(rt.borderRadius);n.beginPath(),Object.values(Et).some(St=>St!==0)?ke(n,{x:yt,y:ht,w:T,h:C,radius:Et}):n.rect(yt,ht,T,C),n.fill(),ct!==0&&n.stroke()}n.restore()}(d.x(lt),nt,H),lt=Ns(Z,lt+T+v,R?lt+et:this.right,t.rtl),function(gt,dt,rt){he(n,rt.text,gt,dt+D/2,g,{strikethrough:rt.hidden,textAlign:d.textAlign(rt.textAlign)})}(d.x(lt),nt,H),R)M.x+=et+y;else if(typeof H.text!="string"){let gt=g.lineHeight;M.y+=Ea(H,gt)+y}else M.y+=N}),ro(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,s=Vt(e.font),n=Kt(e.padding);if(!e.display)return;let o=vi(t.rtl,this.left,this.width),a=this.ctx,l=e.position,d=s.size/2,g=n.top+d,y,f=this.left,v=this.width;if(this.isHorizontal())v=Math.max(...this.lineWidths),y=this.top+g,f=jt(t.align,f,this.right-v);else{let T=this.columnSizes.reduce((C,D)=>Math.max(C,D.height),0);y=g+jt(t.align,this.top,this.bottom-T-t.labels.padding-this._computeTitleHeight())}let M=jt(l,f,f+v);a.textAlign=o.textAlign(Ve(l)),a.textBaseline="middle",a.strokeStyle=e.color,a.fillStyle=e.color,a.font=s.string,he(a,e.text,M,y,s)}_computeTitleHeight(){let t=this.options.title,e=Vt(t.font),s=Kt(t.padding);return t.display?e.lineHeight+s.height:0}_getLegendItemAt(t,e){let s,n,o;if(fe(t,this.left,this.right)&&fe(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(d=>{let g=d.controller.getStyle(e?0:void 0),y=Kt(g.borderWidth);return{text:t[d.index].label,fillStyle:g.backgroundColor,fontColor:o,hidden:!d.visible,lineCap:g.borderCapStyle,lineDash:g.borderDash,lineDashOffset:g.borderDashOffset,lineJoin:g.borderJoinStyle,lineWidth:(y.width+y.height)/4,strokeStyle:g.borderColor,pointStyle:s||g.pointStyle,rotation:g.rotation,textAlign:n||g.textAlign,borderRadius:a&&(l||g.borderRadius),datasetIndex:d.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 Ro extends Be{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=P(s.text)?s.text.length:1;this._padding=Kt(s.padding);let o=n*Vt(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,d,g,y,f=0;return this.isHorizontal()?(g=jt(l,s,o),y=e+t,d=o-s):(a.position==="left"?(g=s+t,y=jt(l,n,e),f=-.5*b):(g=o-t,y=jt(l,e,n),f=.5*b),d=n-e),{titleX:g,titleY:y,maxWidth:d,rotation:f}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let s=Vt(e.font),n=s.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:l,rotation:d}=this._drawArgs(n);he(t,e.text,0,0,s,{color:e.color,maxWidth:l,rotation:d,textAlign:Ve(e.align),textBaseline:"middle",translation:[o,a]})}}var Sh={id:"title",_element:Ro,start(i,t,e){(function(s,n){let o=new Ro({ctx:s.ctx,options:n,chart:s});Qt.configure(s,o,n),Qt.addBox(s,o),s.titleBlock=o})(i,e)},stop(i){let t=i.titleBlock;Qt.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){let s=i.titleBlock;Qt.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 dn=new WeakMap;var Ch={id:"subtitle",start(i,t,e){let s=new Ro({ctx:i.ctx,options:e,chart:i});Qt.configure(i,s,e),Qt.addBox(i,s),dn.set(i,s)},stop(i){Qt.removeBox(i,dn.get(i)),dn.delete(i)},beforeUpdate(i,t,e){let s=dn.get(i);Qt.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 Eh(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 Ta(i,t){let e=i.chart.ctx,{body:s,footer:n,title:o}=i,{boxWidth:a,boxHeight:l}=t,d=Vt(t.bodyFont),g=Vt(t.titleFont),y=Vt(t.footerFont),f=o.length,v=n.length,M=s.length,T=Kt(t.padding),C=T.height,D=0,R=s.reduce((H,j)=>H+j.before.length+j.lines.length+j.after.length,0);R+=i.beforeBody.length+i.afterBody.length,f&&(C+=f*g.lineHeight+(f-1)*t.titleSpacing+t.titleMarginBottom),R&&(C+=M*(t.displayColors?Math.max(l,d.lineHeight):d.lineHeight)+(R-M)*d.lineHeight+(R-1)*t.bodySpacing),v&&(C+=t.footerMarginTop+v*y.lineHeight+(v-1)*t.footerSpacing);let I=0,N=function(H){D=Math.max(D,e.measureText(H).width+I)};return e.save(),e.font=g.string,it(i.title,N),e.font=d.string,it(i.beforeBody.concat(i.afterBody),N),I=t.displayColors?a+2+t.boxPadding:0,it(s,H=>{it(H.before,N),it(H.lines,N),it(H.after,N)}),I=0,e.font=y.string,it(i.footer,N),e.restore(),D+=T.width,{width:D,height:C}}function Th(i,t,e,s){let{x:n,width:o}=e,{width:a,chartArea:{left:l,right:d}}=i,g="center";return s==="center"?g=n<=(l+d)/2?"left":"right":n<=o/2?g="left":n>=a-o/2&&(g="right"),function(y,f,v,M){let{x:T,width:C}=M,D=v.caretSize+v.caretPadding;return y==="left"&&T+C+D>f.width||y==="right"&&T-C-D<0||void 0}(g,i,t,e)&&(g="center"),g}function Da(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||Th(i,t,e,s),yAlign:s}}function Aa(i,t,e,s){let{caretSize:n,caretPadding:o,cornerRadius:a}=i,{xAlign:l,yAlign:d}=e,g=n+o,{topLeft:y,topRight:f,bottomLeft:v,bottomRight:M}=ni(a),T=function(D,R){let{x:I,width:N}=D;return R==="right"?I-=N:R==="center"&&(I-=N/2),I}(t,l),C=function(D,R,I){let{y:N,height:H}=D;return R==="top"?N+=I:N-=R==="bottom"?H+I:H/2,N}(t,d,g);return d==="center"?l==="left"?T+=g:l==="right"&&(T-=g):l==="left"?T-=Math.max(y,v)+n:l==="right"&&(T+=Math.max(f,M)+n),{x:Ut(T,0,s.width-t.width),y:Ut(C,0,s.height-t.height)}}function un(i,t,e){let s=Kt(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-s.right:i.x+s.left}function Pa(i){return Fe([],Xe(i))}function Ra(i,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}let Oa={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=Ra(s,o);Fe(a.before,Xe(ge(l,"beforeLabel",this,o))),Fe(a.lines,ge(l,"label",this,o)),Fe(a.after,Xe(ge(l,"afterLabel",this,o))),n.push(a)}),n}getAfterBody(t,e){return Pa(ge(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:s}=e,n=ge(s,"beforeFooter",this,t),o=ge(s,"footer",this,t),a=ge(s,"afterFooter",this,t),l=[];return l=Fe(l,Xe(n)),l=Fe(l,Xe(o)),l=Fe(l,Xe(a)),l}_createItems(t){let e=this._active,s=this.chart.data,n=[],o=[],a=[],l,d,g=[];for(l=0,d=e.length;lt.filter(y,f,v,s))),t.itemSort&&(g=g.sort((y,f)=>t.itemSort(y,f,s))),it(g,y=>{let f=Ra(t.callbacks,y);n.push(ge(f,"labelColor",this,y)),o.push(ge(f,"labelPointStyle",this,y)),a.push(ge(f,"labelTextColor",this,y))}),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 d=this._size=Ta(this,s),g=Object.assign({},l,d),y=Da(this.chart,s,g),f=Aa(s,g,y,this.chart);this.xAlign=y.xAlign,this.yAlign=y.yAlign,o={opacity:1,x:f.x,y:f.y,width:d.width,height:d.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:d,topRight:g,bottomLeft:y,bottomRight:f}=ni(l),{x:v,y:M}=t,{width:T,height:C}=e,D,R,I,N,H,j;return o==="center"?(H=M+C/2,n==="left"?(D=v,R=D-a,N=H+a,j=H-a):(D=v+T,R=D+a,N=H-a,j=H+a),I=D):(R=n==="left"?v+Math.max(d,y)+a:n==="right"?v+T-Math.max(g,f)-a:this.caretX,o==="top"?(N=M,H=N-a,D=R-a,I=R+a):(N=M+C,H=N+a,D=R+a,I=R-a),j=N),{x1:D,x2:R,x3:I,y1:N,y2:H,y3:j}}drawTitle(t,e,s){let n=this.title,o=n.length,a,l,d;if(o){let g=vi(s.rtl,this.x,this.width);for(t.x=un(this,s.titleAlign,s),e.textAlign=g.textAlign(s.titleAlign),e.textBaseline="middle",a=Vt(s.titleFont),l=s.titleSpacing,e.fillStyle=s.titleColor,e.font=a.string,d=0;dI!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,ke(t,{x:C,y:T,w:g,h:d,radius:R}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),ke(t,{x:D,y:T+1,w:g-2,h:d-2,radius:R}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(C,T,g,d),t.strokeRect(C,T,g,d),t.fillStyle=a.backgroundColor,t.fillRect(D,T+1,g-2,d-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,e,s){let{body:n}=this,{bodySpacing:o,bodyAlign:a,displayColors:l,boxHeight:d,boxWidth:g,boxPadding:y}=s,f=Vt(s.bodyFont),v=f.lineHeight,M=0,T=vi(s.rtl,this.x,this.width),C=function(et){e.fillText(et,T.x(t.x+M),t.y+v/2),t.y+=v+o},D=T.textAlign(a),R,I,N,H,j,Y,Z;for(e.textAlign=a,e.textBaseline="middle",e.font=f.string,t.x=un(this,D,s),e.fillStyle=s.bodyColor,it(this.beforeBody,C),M=l&&D!=="right"?a==="center"?g/2+y:g+2+y:0,H=0,Y=n.length;H0&&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=Ta(this,t),d=Object.assign({},a,this._size),g=Da(e,t,d),y=Aa(t,d,g,e);n._to===y.x&&o._to===y.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,y))}}_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=Kt(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),oo(t,e.textDirection),o.y+=a.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),ro(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let s=this._active,n=t.map(({datasetIndex:l,index:d})=>{let g=this.chart.getDatasetMeta(l);if(!g)throw new Error("Cannot find a dataset at index "+l);return{datasetIndex:l,element:g.data[d],index:d}}),o=!ft(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),d=e||!ft(a,o)||l;return d&&(this._active=a,(n.enabled||n.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),d}_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 Dh={id:"tooltip",_element:La,positioners:ks,afterInit(i,t,e){e&&(i.tooltip=new La({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:Oa},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 Wt.register(Xr,da,So,_),Wt.helpers={...xl},Wt._adapters=Wr,Wt.Animation=yr,Wt.Animations=po,Wt.animator=ve,Wt.controllers=Pe.controllers.items,Wt.DatasetController=qe,Wt.Element=Be,Wt.elements=So,Wt.Interaction=sr,Wt.layouts=Qt,Wt.platforms=mr,Wt.Scale=oi,Wt.Ticks=fi,Object.assign(Wt,Xr,da,So,_,mr),Wt.Chart=Wt,typeof window<"u"&&(window.Chart=Wt),Wt});(function(_,h){typeof exports=="object"&&typeof module<"u"?h(Ah("chart.js")):typeof define=="function"&&define.amd?define(["chart.js"],h):h((_=typeof globalThis<"u"?globalThis:_||self).Chart)})(void 0,function(_){"use strict";function h(p){if(p===null||p===!0||p===!1)return NaN;var x=Number(p);return isNaN(x)?x:x<0?Math.ceil(x):Math.floor(x)}function u(p,x){if(x.length1?"s":"")+" required, but only "+x.length+" present")}function k(p){u(1,arguments);var x=Object.prototype.toString.call(p);return p instanceof Date||typeof p=="object"&&x==="[object Date]"?new Date(p.getTime()):typeof p=="number"||x==="[object Number]"?new Date(p):(typeof p!="string"&&x!=="[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 P(p,x){u(2,arguments);var m=k(p),S=h(x);return isNaN(S)?new Date(NaN):(S&&m.setDate(m.getDate()+S),m)}function z(p,x){u(2,arguments);var m=k(p),S=h(x);if(isNaN(S))return new Date(NaN);if(!S)return m;var A=m.getDate(),F=new Date(m.getTime());F.setMonth(m.getMonth()+S+1,0);var q=F.getDate();return A>=q?F:(m.setFullYear(F.getFullYear(),F.getMonth(),A),m)}function L(p,x){u(2,arguments);var m=k(p).getTime(),S=h(x);return new Date(m+S)}var G=36e5;function U(p,x){u(1,arguments);var m=x||{},S=m.locale,A=S&&S.options&&S.options.weekStartsOn,F=A==null?0:h(A),q=m.weekStartsOn==null?F:h(m.weekStartsOn);if(!(q>=0&&q<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=k(p),st=Q.getDay(),mt=(st0?1:A}function bt(p){u(1,arguments);var x=k(p);return!isNaN(x)}function Tt(p,x){u(2,arguments);var m=k(p),S=k(x),A=m.getFullYear()-S.getFullYear(),F=m.getMonth()-S.getMonth();return 12*A+F}function Dt(p,x){u(2,arguments);var m=k(p),S=k(x);return m.getFullYear()-S.getFullYear()}function kt(p,x){var m=p.getFullYear()-x.getFullYear()||p.getMonth()-x.getMonth()||p.getDate()-x.getDate()||p.getHours()-x.getHours()||p.getMinutes()-x.getMinutes()||p.getSeconds()-x.getSeconds()||p.getMilliseconds()-x.getMilliseconds();return m<0?-1:m>0?1:m}function $t(p,x){u(2,arguments);var m=k(p),S=k(x),A=kt(m,S),F=Math.abs(it(m,S));m.setDate(m.getDate()-A*F);var q=kt(m,S)===-A,Q=A*(F-q);return Q===0?0:Q}function zt(p,x){u(2,arguments);var m=k(p),S=k(x);return m.getTime()-S.getTime()}var te=36e5;function De(p){u(1,arguments);var x=k(p);return x.setHours(23,59,59,999),x}function vt(p){u(1,arguments);var x=k(p),m=x.getMonth();return x.setFullYear(x.getFullYear(),m+1,0),x.setHours(23,59,59,999),x}function At(p){u(1,arguments);var x=k(p);return De(x).getTime()===vt(x).getTime()}function pt(p,x){u(2,arguments);var m,S=k(p),A=k(x),F=ft(S,A),q=Math.abs(Tt(S,A));if(q<1)m=0;else{S.getMonth()===1&&S.getDate()>27&&S.setDate(30),S.setMonth(S.getMonth()-F*q);var Q=ft(S,A)===-F;At(k(p))&&q===1&&ft(p,A)===1&&(Q=!1),m=F*(q-Q)}return m===0?0:m}var J={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(p){return function(x){var m=x||{},S=m.width?String(m.width):p.defaultWidth;return p.formats[S]||p.formats[p.defaultWidth]}}var c={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"})},b={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function w(p){return function(x,m){var S,A=m||{};if((A.context?String(A.context):"standalone")==="formatting"&&p.formattingValues){var F=p.defaultFormattingWidth||p.defaultWidth,q=A.width?String(A.width):F;S=p.formattingValues[q]||p.formattingValues[F]}else{var Q=p.defaultWidth,st=A.width?String(A.width):p.defaultWidth;S=p.values[st]||p.values[Q]}return S[p.argumentCallback?p.argumentCallback(x):x]}}function E(p){return function(x,m){var S=String(x),A=m||{},F=A.width,q=F&&p.matchPatterns[F]||p.matchPatterns[p.defaultMatchWidth],Q=S.match(q);if(!Q)return null;var st,mt=Q[0],xt=F&&p.parsePatterns[F]||p.parsePatterns[p.defaultParseWidth];return st=Object.prototype.toString.call(xt)==="[object Array]"?function(wt,Pt){for(var Mt=0;Mt0?"in "+S:S+" ago":S},formatLong:c,formatRelative:function(p,x,m,S){return b[p]},localize:{ordinalNumber:function(p,x){var m=Number(p),S=m%100;if(S>20||S<10)switch(S%10){case 1:return m+"st";case 2:return m+"nd";case 3:return m+"rd"}return m+"th"},era:w({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:w({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(p){return Number(p)-1}}),month:w({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:w({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:w({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:(O={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(p){return parseInt(p,10)}},function(p,x){var m=String(p),S=x||{},A=m.match(O.matchPattern);if(!A)return null;var F=A[0],q=m.match(O.parsePattern);if(!q)return null;var Q=O.valueCallback?O.valueCallback(q[0]):q[0];return{value:Q=S.valueCallback?S.valueCallback(Q):Q,rest:m.slice(F.length)}}),era:E({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:E({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(p){return p+1}}),month:E({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:E({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:E({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 V(p,x){u(2,arguments);var m=h(x);return L(p,-m)}function B(p,x){for(var m=p<0?"-":"",S=Math.abs(p).toString();S.length0?m:1-m;return B(x==="yy"?S%100:S,x.length)},M:function(p,x){var m=p.getUTCMonth();return x==="M"?String(m+1):B(m+1,2)},d:function(p,x){return B(p.getUTCDate(),x.length)},a:function(p,x){var m=p.getUTCHours()/12>=1?"pm":"am";switch(x){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(p,x){return B(p.getUTCHours()%12||12,x.length)},H:function(p,x){return B(p.getUTCHours(),x.length)},m:function(p,x){return B(p.getUTCMinutes(),x.length)},s:function(p,x){return B(p.getUTCSeconds(),x.length)},S:function(p,x){var m=x.length,S=p.getUTCMilliseconds();return B(Math.floor(S*Math.pow(10,m-3)),x.length)}},tt=864e5;function ot(p){u(1,arguments);var x=1,m=k(p),S=m.getUTCDay(),A=(S=A.getTime()?m+1:x.getTime()>=q.getTime()?m:m-1}function ne(p){u(1,arguments);var x=_t(p),m=new Date(0);m.setUTCFullYear(x,0,4),m.setUTCHours(0,0,0,0);var S=ot(m);return S}var Ue=6048e5;function Xt(p){u(1,arguments);var x=k(p),m=ot(x).getTime()-ne(x).getTime();return Math.round(m/Ue)+1}function ae(p,x){u(1,arguments);var m=x||{},S=m.locale,A=S&&S.options&&S.options.weekStartsOn,F=A==null?0:h(A),q=m.weekStartsOn==null?F:h(m.weekStartsOn);if(!(q>=0&&q<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=k(p),st=Q.getUTCDay(),mt=(st=1&&st<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var mt=new Date(0);mt.setUTCFullYear(S+1,0,st),mt.setUTCHours(0,0,0,0);var xt=ae(mt,x),wt=new Date(0);wt.setUTCFullYear(S,0,st),wt.setUTCHours(0,0,0,0);var Pt=ae(wt,x);return m.getTime()>=xt.getTime()?S+1:m.getTime()>=Pt.getTime()?S:S-1}function ee(p,x){u(1,arguments);var m=x||{},S=m.locale,A=S&&S.options&&S.options.firstWeekContainsDate,F=A==null?1:h(A),q=m.firstWeekContainsDate==null?F:h(m.firstWeekContainsDate),Q=We(p,x),st=new Date(0);st.setUTCFullYear(Q,0,q),st.setUTCHours(0,0,0,0);var mt=ae(st,x);return mt}var $e=6048e5;function He(p,x){u(1,arguments);var m=k(p),S=ae(m,x).getTime()-ee(m,x).getTime();return Math.round(S/$e)+1}var ji="midnight",Ti="noon",Ls="morning",ie="afternoon",Ke="evening",Ut="night",zs={G:function(p,x,m){var S=p.getUTCFullYear()>0?1:0;switch(x){case"G":case"GG":case"GGG":return m.era(S,{width:"abbreviated"});case"GGGGG":return m.era(S,{width:"narrow"});default:return m.era(S,{width:"wide"})}},y:function(p,x,m){if(x==="yo"){var S=p.getUTCFullYear(),A=S>0?S:1-S;return m.ordinalNumber(A,{unit:"year"})}return W.y(p,x)},Y:function(p,x,m,S){var A=We(p,S),F=A>0?A:1-A;return x==="YY"?B(F%100,2):x==="Yo"?m.ordinalNumber(F,{unit:"year"}):B(F,x.length)},R:function(p,x){return B(_t(p),x.length)},u:function(p,x){return B(p.getUTCFullYear(),x.length)},Q:function(p,x,m){var S=Math.ceil((p.getUTCMonth()+1)/3);switch(x){case"Q":return String(S);case"QQ":return B(S,2);case"Qo":return m.ordinalNumber(S,{unit:"quarter"});case"QQQ":return m.quarter(S,{width:"abbreviated",context:"formatting"});case"QQQQQ":return m.quarter(S,{width:"narrow",context:"formatting"});default:return m.quarter(S,{width:"wide",context:"formatting"})}},q:function(p,x,m){var S=Math.ceil((p.getUTCMonth()+1)/3);switch(x){case"q":return String(S);case"qq":return B(S,2);case"qo":return m.ordinalNumber(S,{unit:"quarter"});case"qqq":return m.quarter(S,{width:"abbreviated",context:"standalone"});case"qqqqq":return m.quarter(S,{width:"narrow",context:"standalone"});default:return m.quarter(S,{width:"wide",context:"standalone"})}},M:function(p,x,m){var S=p.getUTCMonth();switch(x){case"M":case"MM":return W.M(p,x);case"Mo":return m.ordinalNumber(S+1,{unit:"month"});case"MMM":return m.month(S,{width:"abbreviated",context:"formatting"});case"MMMMM":return m.month(S,{width:"narrow",context:"formatting"});default:return m.month(S,{width:"wide",context:"formatting"})}},L:function(p,x,m){var S=p.getUTCMonth();switch(x){case"L":return String(S+1);case"LL":return B(S+1,2);case"Lo":return m.ordinalNumber(S+1,{unit:"month"});case"LLL":return m.month(S,{width:"abbreviated",context:"standalone"});case"LLLLL":return m.month(S,{width:"narrow",context:"standalone"});default:return m.month(S,{width:"wide",context:"standalone"})}},w:function(p,x,m,S){var A=He(p,S);return x==="wo"?m.ordinalNumber(A,{unit:"week"}):B(A,x.length)},I:function(p,x,m){var S=Xt(p);return x==="Io"?m.ordinalNumber(S,{unit:"week"}):B(S,x.length)},d:function(p,x,m){return x==="do"?m.ordinalNumber(p.getUTCDate(),{unit:"date"}):W.d(p,x)},D:function(p,x,m){var S=function(A){u(1,arguments);var F=k(A),q=F.getTime();F.setUTCMonth(0,1),F.setUTCHours(0,0,0,0);var Q=F.getTime(),st=q-Q;return Math.floor(st/tt)+1}(p);return x==="Do"?m.ordinalNumber(S,{unit:"dayOfYear"}):B(S,x.length)},E:function(p,x,m){var S=p.getUTCDay();switch(x){case"E":case"EE":case"EEE":return m.day(S,{width:"abbreviated",context:"formatting"});case"EEEEE":return m.day(S,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(S,{width:"short",context:"formatting"});default:return m.day(S,{width:"wide",context:"formatting"})}},e:function(p,x,m,S){var A=p.getUTCDay(),F=(A-S.weekStartsOn+8)%7||7;switch(x){case"e":return String(F);case"ee":return B(F,2);case"eo":return m.ordinalNumber(F,{unit:"day"});case"eee":return m.day(A,{width:"abbreviated",context:"formatting"});case"eeeee":return m.day(A,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(A,{width:"short",context:"formatting"});default:return m.day(A,{width:"wide",context:"formatting"})}},c:function(p,x,m,S){var A=p.getUTCDay(),F=(A-S.weekStartsOn+8)%7||7;switch(x){case"c":return String(F);case"cc":return B(F,x.length);case"co":return m.ordinalNumber(F,{unit:"day"});case"ccc":return m.day(A,{width:"abbreviated",context:"standalone"});case"ccccc":return m.day(A,{width:"narrow",context:"standalone"});case"cccccc":return m.day(A,{width:"short",context:"standalone"});default:return m.day(A,{width:"wide",context:"standalone"})}},i:function(p,x,m){var S=p.getUTCDay(),A=S===0?7:S;switch(x){case"i":return String(A);case"ii":return B(A,x.length);case"io":return m.ordinalNumber(A,{unit:"day"});case"iii":return m.day(S,{width:"abbreviated",context:"formatting"});case"iiiii":return m.day(S,{width:"narrow",context:"formatting"});case"iiiiii":return m.day(S,{width:"short",context:"formatting"});default:return m.day(S,{width:"wide",context:"formatting"})}},a:function(p,x,m){var S=p.getUTCHours()/12>=1?"pm":"am";switch(x){case"a":case"aa":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"aaa":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return m.dayPeriod(S,{width:"narrow",context:"formatting"});default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},b:function(p,x,m){var S,A=p.getUTCHours();switch(S=A===12?Ti:A===0?ji:A/12>=1?"pm":"am",x){case"b":case"bb":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"bbb":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return m.dayPeriod(S,{width:"narrow",context:"formatting"});default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},B:function(p,x,m){var S,A=p.getUTCHours();switch(S=A>=17?Ke:A>=12?ie:A>=4?Ls:Ut,x){case"B":case"BB":case"BBB":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"BBBBB":return m.dayPeriod(S,{width:"narrow",context:"formatting"});default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},h:function(p,x,m){if(x==="ho"){var S=p.getUTCHours()%12;return S===0&&(S=12),m.ordinalNumber(S,{unit:"hour"})}return W.h(p,x)},H:function(p,x,m){return x==="Ho"?m.ordinalNumber(p.getUTCHours(),{unit:"hour"}):W.H(p,x)},K:function(p,x,m){var S=p.getUTCHours()%12;return x==="Ko"?m.ordinalNumber(S,{unit:"hour"}):B(S,x.length)},k:function(p,x,m){var S=p.getUTCHours();return S===0&&(S=24),x==="ko"?m.ordinalNumber(S,{unit:"hour"}):B(S,x.length)},m:function(p,x,m){return x==="mo"?m.ordinalNumber(p.getUTCMinutes(),{unit:"minute"}):W.m(p,x)},s:function(p,x,m){return x==="so"?m.ordinalNumber(p.getUTCSeconds(),{unit:"second"}):W.s(p,x)},S:function(p,x){return W.S(p,x)},X:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();if(A===0)return"Z";switch(x){case"X":return ci(A);case"XXXX":case"XX":return Yt(A);default:return Yt(A,":")}},x:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();switch(x){case"x":return ci(A);case"xxxx":case"xx":return Yt(A);default:return Yt(A,":")}},O:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();switch(x){case"O":case"OO":case"OOO":return"GMT"+fe(A,":");default:return"GMT"+Yt(A,":")}},z:function(p,x,m,S){var A=(S._originalDate||p).getTimezoneOffset();switch(x){case"z":case"zz":case"zzz":return"GMT"+fe(A,":");default:return"GMT"+Yt(A,":")}},t:function(p,x,m,S){var A=S._originalDate||p;return B(Math.floor(A.getTime()/1e3),x.length)},T:function(p,x,m,S){return B((S._originalDate||p).getTime(),x.length)}};function fe(p,x){var m=p>0?"-":"+",S=Math.abs(p),A=Math.floor(S/60),F=S%60;if(F===0)return m+String(A);var q=x||"";return m+String(A)+q+B(F,2)}function ci(p,x){return p%60==0?(p>0?"-":"+")+B(Math.abs(p)/60,2):Yt(p,x)}function Yt(p,x){var m=x||"",S=p>0?"-":"+",A=Math.abs(p);return S+B(Math.floor(A/60),2)+m+B(A%60,2)}var $s=zs;function Yi(p,x){switch(p){case"P":return x.date({width:"short"});case"PP":return x.date({width:"medium"});case"PPP":return x.date({width:"long"});default:return x.date({width:"full"})}}function Gi(p,x){switch(p){case"p":return x.time({width:"short"});case"pp":return x.time({width:"medium"});case"ppp":return x.time({width:"long"});default:return x.time({width:"full"})}}var Hs={p:Gi,P:function(p,x){var m,S=p.match(/(P+)(p+)?/),A=S[1],F=S[2];if(!F)return Yi(p,x);switch(A){case"P":m=x.dateTime({width:"short"});break;case"PP":m=x.dateTime({width:"medium"});break;case"PPP":m=x.dateTime({width:"long"});break;default:m=x.dateTime({width:"full"})}return m.replace("{{date}}",Yi(A,x)).replace("{{time}}",Gi(F,x))}},Di=Hs,qi=["D","DD"],Xi=["YY","YYYY"];function Ai(p){return qi.indexOf(p)!==-1}function Zi(p){return Xi.indexOf(p)!==-1}function Ve(p,x,m){if(p==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(x,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(p==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(x,"`) for formatting years to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(p==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(x,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"));if(p==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(x,"`) for formatting days of the month to the input `").concat(m,"`; see: https://git.io/fxCyr"))}var jt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ns=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ki=/^'([^]*?)'?$/,Qi=/''/g,Yn=/[a-zA-Z]/;function ve(p){return p.match(Ki)[1].replace(Qi,"'")}function di(p,x){if(p==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var m in x=x||{})x.hasOwnProperty(m)&&(p[m]=x[m]);return p}function we(p,x,m){u(2,arguments);var S=m||{},A=S.locale,F=A&&A.options&&A.options.weekStartsOn,q=F==null?0:h(F),Q=S.weekStartsOn==null?q:h(S.weekStartsOn);if(!(Q>=0&&Q<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var st=k(p),mt=h(x),xt=st.getUTCDay(),wt=mt%7,Pt=(wt+7)%7,Mt=(Pt0,A=S?x:1-x;if(A<=50)m=p||100;else{var F=A+50;m=p+100*Math.floor(F/100)-(p>=F%100?100:0)}return S?m:1-m}var Ri=[31,28,31,30,31,30,31,31,30,31,30,31],ls=[31,29,31,30,31,30,31,31,30,31,30,31];function pi(p){return p%400==0||p%4==0&&p%100!=0}var to={G:{priority:140,parse:function(p,x,m,S){switch(x){case"G":case"GG":case"GGG":return m.era(p,{width:"abbreviated"})||m.era(p,{width:"narrow"});case"GGGGG":return m.era(p,{width:"narrow"});default:return m.era(p,{width:"wide"})||m.era(p,{width:"abbreviated"})||m.era(p,{width:"narrow"})}},set:function(p,x,m,S){return x.era=m,p.setUTCFullYear(m,0,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["R","u","t","T"]},y:{priority:130,parse:function(p,x,m,S){var A=function(F){return{year:F,isTwoDigitYear:x==="yy"}};switch(x){case"y":return Ht(4,p,A);case"yo":return m.ordinalNumber(p,{unit:"year",valueCallback:A});default:return Ht(x.length,p,A)}},validate:function(p,x,m){return x.isTwoDigitYear||x.year>0},set:function(p,x,m,S){var A=p.getUTCFullYear();if(m.isTwoDigitYear){var F=Je(m.year,A);return p.setUTCFullYear(F,0,1),p.setUTCHours(0,0,0,0),p}var q="era"in x&&x.era!==1?1-m.year:m.year;return p.setUTCFullYear(q,0,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","u","w","I","i","e","c","t","T"]},Y:{priority:130,parse:function(p,x,m,S){var A=function(F){return{year:F,isTwoDigitYear:x==="YY"}};switch(x){case"Y":return Ht(4,p,A);case"Yo":return m.ordinalNumber(p,{unit:"year",valueCallback:A});default:return Ht(x.length,p,A)}},validate:function(p,x,m){return x.isTwoDigitYear||x.year>0},set:function(p,x,m,S){var A=We(p,S);if(m.isTwoDigitYear){var F=Je(m.year,A);return p.setUTCFullYear(F,0,S.firstWeekContainsDate),p.setUTCHours(0,0,0,0),ae(p,S)}var q="era"in x&&x.era!==1?1-m.year:m.year;return p.setUTCFullYear(q,0,S.firstWeekContainsDate),p.setUTCHours(0,0,0,0),ae(p,S)},incompatibleTokens:["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R:{priority:130,parse:function(p,x,m,S){return rs(x==="R"?4:x.length,p)},set:function(p,x,m,S){var A=new Date(0);return A.setUTCFullYear(m,0,4),A.setUTCHours(0,0,0,0),ot(A)},incompatibleTokens:["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},u:{priority:130,parse:function(p,x,m,S){return rs(x==="u"?4:x.length,p)},set:function(p,x,m,S){return p.setUTCFullYear(m,0,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["G","y","Y","R","w","I","i","e","c","t","T"]},Q:{priority:120,parse:function(p,x,m,S){switch(x){case"Q":case"QQ":return Ht(x.length,p);case"Qo":return m.ordinalNumber(p,{unit:"quarter"});case"QQQ":return m.quarter(p,{width:"abbreviated",context:"formatting"})||m.quarter(p,{width:"narrow",context:"formatting"});case"QQQQQ":return m.quarter(p,{width:"narrow",context:"formatting"});default:return m.quarter(p,{width:"wide",context:"formatting"})||m.quarter(p,{width:"abbreviated",context:"formatting"})||m.quarter(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=1&&x<=4},set:function(p,x,m,S){return p.setUTCMonth(3*(m-1),1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},q:{priority:120,parse:function(p,x,m,S){switch(x){case"q":case"qq":return Ht(x.length,p);case"qo":return m.ordinalNumber(p,{unit:"quarter"});case"qqq":return m.quarter(p,{width:"abbreviated",context:"standalone"})||m.quarter(p,{width:"narrow",context:"standalone"});case"qqqqq":return m.quarter(p,{width:"narrow",context:"standalone"});default:return m.quarter(p,{width:"wide",context:"standalone"})||m.quarter(p,{width:"abbreviated",context:"standalone"})||m.quarter(p,{width:"narrow",context:"standalone"})}},validate:function(p,x,m){return x>=1&&x<=4},set:function(p,x,m,S){return p.setUTCMonth(3*(m-1),1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M:{priority:110,parse:function(p,x,m,S){var A=function(F){return F-1};switch(x){case"M":return Ot(Qe,p,A);case"MM":return Ht(2,p,A);case"Mo":return m.ordinalNumber(p,{unit:"month",valueCallback:A});case"MMM":return m.month(p,{width:"abbreviated",context:"formatting"})||m.month(p,{width:"narrow",context:"formatting"});case"MMMMM":return m.month(p,{width:"narrow",context:"formatting"});default:return m.month(p,{width:"wide",context:"formatting"})||m.month(p,{width:"abbreviated",context:"formatting"})||m.month(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=0&&x<=11},set:function(p,x,m,S){return p.setUTCMonth(m,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]},L:{priority:110,parse:function(p,x,m,S){var A=function(F){return F-1};switch(x){case"L":return Ot(Qe,p,A);case"LL":return Ht(2,p,A);case"Lo":return m.ordinalNumber(p,{unit:"month",valueCallback:A});case"LLL":return m.month(p,{width:"abbreviated",context:"standalone"})||m.month(p,{width:"narrow",context:"standalone"});case"LLLLL":return m.month(p,{width:"narrow",context:"standalone"});default:return m.month(p,{width:"wide",context:"standalone"})||m.month(p,{width:"abbreviated",context:"standalone"})||m.month(p,{width:"narrow",context:"standalone"})}},validate:function(p,x,m){return x>=0&&x<=11},set:function(p,x,m,S){return p.setUTCMonth(m,1),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},w:{priority:100,parse:function(p,x,m,S){switch(x){case"w":return Ot(Ji,p);case"wo":return m.ordinalNumber(p,{unit:"week"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=1&&x<=53},set:function(p,x,m,S){return ae(function(A,F,q){u(2,arguments);var Q=k(A),st=h(F),mt=He(Q,q)-st;return Q.setUTCDate(Q.getUTCDate()-7*mt),Q}(p,m,S),S)},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},I:{priority:100,parse:function(p,x,m,S){switch(x){case"I":return Ot(Ji,p);case"Io":return m.ordinalNumber(p,{unit:"week"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=1&&x<=53},set:function(p,x,m,S){return ot(function(A,F){u(2,arguments);var q=k(A),Q=h(F),st=Xt(q)-Q;return q.setUTCDate(q.getUTCDate()-7*st),q}(p,m,S),S)},incompatibleTokens:["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},d:{priority:90,subPriority:1,parse:function(p,x,m,S){switch(x){case"d":return Ot(Ne,p);case"do":return m.ordinalNumber(p,{unit:"date"});default:return Ht(x.length,p)}},validate:function(p,x,m){var S=pi(p.getUTCFullYear()),A=p.getUTCMonth();return S?x>=1&&x<=ls[A]:x>=1&&x<=Ri[A]},set:function(p,x,m,S){return p.setUTCDate(m),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","w","I","D","i","e","c","t","T"]},D:{priority:90,subPriority:1,parse:function(p,x,m,S){switch(x){case"D":case"DD":return Ot(Ae,p);case"Do":return m.ordinalNumber(p,{unit:"date"});default:return Ht(x.length,p)}},validate:function(p,x,m){return pi(p.getUTCFullYear())?x>=1&&x<=366:x>=1&&x<=365},set:function(p,x,m,S){return p.setUTCMonth(0,m),p.setUTCHours(0,0,0,0),p},incompatibleTokens:["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},E:{priority:90,parse:function(p,x,m,S){switch(x){case"E":case"EE":case"EEE":return m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});case"EEEEE":return m.day(p,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});default:return m.day(p,{width:"wide",context:"formatting"})||m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=0&&x<=6},set:function(p,x,m,S){return(p=we(p,m,S)).setUTCHours(0,0,0,0),p},incompatibleTokens:["D","i","e","c","t","T"]},e:{priority:90,parse:function(p,x,m,S){var A=function(F){var q=7*Math.floor((F-1)/7);return(F+S.weekStartsOn+6)%7+q};switch(x){case"e":case"ee":return Ht(x.length,p,A);case"eo":return m.ordinalNumber(p,{unit:"day",valueCallback:A});case"eee":return m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});case"eeeee":return m.day(p,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"});default:return m.day(p,{width:"wide",context:"formatting"})||m.day(p,{width:"abbreviated",context:"formatting"})||m.day(p,{width:"short",context:"formatting"})||m.day(p,{width:"narrow",context:"formatting"})}},validate:function(p,x,m){return x>=0&&x<=6},set:function(p,x,m,S){return(p=we(p,m,S)).setUTCHours(0,0,0,0),p},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},c:{priority:90,parse:function(p,x,m,S){var A=function(F){var q=7*Math.floor((F-1)/7);return(F+S.weekStartsOn+6)%7+q};switch(x){case"c":case"cc":return Ht(x.length,p,A);case"co":return m.ordinalNumber(p,{unit:"day",valueCallback:A});case"ccc":return m.day(p,{width:"abbreviated",context:"standalone"})||m.day(p,{width:"short",context:"standalone"})||m.day(p,{width:"narrow",context:"standalone"});case"ccccc":return m.day(p,{width:"narrow",context:"standalone"});case"cccccc":return m.day(p,{width:"short",context:"standalone"})||m.day(p,{width:"narrow",context:"standalone"});default:return m.day(p,{width:"wide",context:"standalone"})||m.day(p,{width:"abbreviated",context:"standalone"})||m.day(p,{width:"short",context:"standalone"})||m.day(p,{width:"narrow",context:"standalone"})}},validate:function(p,x,m){return x>=0&&x<=6},set:function(p,x,m,S){return(p=we(p,m,S)).setUTCHours(0,0,0,0),p},incompatibleTokens:["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},i:{priority:90,parse:function(p,x,m,S){var A=function(F){return F===0?7:F};switch(x){case"i":case"ii":return Ht(x.length,p);case"io":return m.ordinalNumber(p,{unit:"day"});case"iii":return m.day(p,{width:"abbreviated",context:"formatting",valueCallback:A})||m.day(p,{width:"short",context:"formatting",valueCallback:A})||m.day(p,{width:"narrow",context:"formatting",valueCallback:A});case"iiiii":return m.day(p,{width:"narrow",context:"formatting",valueCallback:A});case"iiiiii":return m.day(p,{width:"short",context:"formatting",valueCallback:A})||m.day(p,{width:"narrow",context:"formatting",valueCallback:A});default:return m.day(p,{width:"wide",context:"formatting",valueCallback:A})||m.day(p,{width:"abbreviated",context:"formatting",valueCallback:A})||m.day(p,{width:"short",context:"formatting",valueCallback:A})||m.day(p,{width:"narrow",context:"formatting",valueCallback:A})}},validate:function(p,x,m){return x>=1&&x<=7},set:function(p,x,m,S){return p=function(A,F){u(2,arguments);var q=h(F);q%7==0&&(q-=7);var Q=1,st=k(A),mt=st.getUTCDay(),xt=((q%7+7)%7=1&&x<=12},set:function(p,x,m,S){var A=p.getUTCHours()>=12;return A&&m<12?p.setUTCHours(m+12,0,0,0):A||m!==12?p.setUTCHours(m,0,0,0):p.setUTCHours(0,0,0,0),p},incompatibleTokens:["H","K","k","t","T"]},H:{priority:70,parse:function(p,x,m,S){switch(x){case"H":return Ot(le,p);case"Ho":return m.ordinalNumber(p,{unit:"hour"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=23},set:function(p,x,m,S){return p.setUTCHours(m,0,0,0),p},incompatibleTokens:["a","b","h","K","k","t","T"]},K:{priority:70,parse:function(p,x,m,S){switch(x){case"K":return Ot(Gn,p);case"Ko":return m.ordinalNumber(p,{unit:"hour"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=11},set:function(p,x,m,S){return p.getUTCHours()>=12&&m<12?p.setUTCHours(m+12,0,0,0):p.setUTCHours(m,0,0,0),p},incompatibleTokens:["a","b","h","H","k","t","T"]},k:{priority:70,parse:function(p,x,m,S){switch(x){case"k":return Ot(ts,p);case"ko":return m.ordinalNumber(p,{unit:"hour"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=1&&x<=24},set:function(p,x,m,S){var A=m<=24?m%24:m;return p.setUTCHours(A,0,0,0),p},incompatibleTokens:["a","b","h","H","K","t","T"]},m:{priority:60,parse:function(p,x,m,S){switch(x){case"m":return Ot(Pi,p);case"mo":return m.ordinalNumber(p,{unit:"minute"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=59},set:function(p,x,m,S){return p.setUTCMinutes(m,0,0),p},incompatibleTokens:["t","T"]},s:{priority:50,parse:function(p,x,m,S){switch(x){case"s":return Ot(Xn,p);case"so":return m.ordinalNumber(p,{unit:"second"});default:return Ht(x.length,p)}},validate:function(p,x,m){return x>=0&&x<=59},set:function(p,x,m,S){return p.setUTCSeconds(m,0),p},incompatibleTokens:["t","T"]},S:{priority:30,parse:function(p,x,m,S){return Ht(x.length,p,function(A){return Math.floor(A*Math.pow(10,3-x.length))})},set:function(p,x,m,S){return p.setUTCMilliseconds(m),p},incompatibleTokens:["t","T"]},X:{priority:10,parse:function(p,x,m,S){switch(x){case"X":return Zt(ns,p);case"XX":return Zt(os,p);case"XXXX":return Zt(ui,p);case"XXXXX":return Zt(Us,p);default:return Zt(Fs,p)}},set:function(p,x,m,S){return x.timestampIsSet?p:new Date(p.getTime()-m)},incompatibleTokens:["t","T","x"]},x:{priority:10,parse:function(p,x,m,S){switch(x){case"x":return Zt(ns,p);case"xx":return Zt(os,p);case"xxxx":return Zt(ui,p);case"xxxxx":return Zt(Us,p);default:return Zt(Fs,p)}},set:function(p,x,m,S){return x.timestampIsSet?p:new Date(p.getTime()-m)},incompatibleTokens:["t","T","X"]},t:{priority:40,parse:function(p,x,m,S){return gi(p)},set:function(p,x,m,S){return[new Date(1e3*m),{timestampIsSet:!0}]},incompatibleTokens:"*"},T:{priority:20,parse:function(p,x,m,S){return gi(p)},set:function(p,x,m,S){return[new Date(m),{timestampIsSet:!0}]},incompatibleTokens:"*"}},eo=to,Ws=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ti=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Vs=/^'([^]*?)'?$/,fi=/''/g,je=/\S/,hs=/[a-zA-Z]/;function mi(p,x){if(x.timestampIsSet)return p;var m=new Date(0);return m.setFullYear(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate()),m.setHours(p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds(),p.getUTCMilliseconds()),m}function cs(p){return p.match(Vs)[1].replace(fi,"'")}var js=36e5,Lt={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Oi=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Li=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,zi=/^([+-])(\d{2})(?::?(\d{2}))?$/;function $i(p){var x,m={},S=p.split(Lt.dateTimeDelimiter);if(S.length>2)return m;if(/:/.test(S[0])?(m.date=null,x=S[0]):(m.date=S[0],x=S[1],Lt.timeZoneDelimiter.test(m.date)&&(m.date=p.split(Lt.timeZoneDelimiter)[0],x=p.substr(m.date.length,p.length))),x){var A=Lt.timezone.exec(x);A?(m.time=x.replace(A[1],""),m.timezone=A[1]):m.time=x}return m}function Ys(p,x){var m=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+x)+"})|(\\d{2}|[+-]\\d{"+(2+x)+"})$)"),S=p.match(m);if(!S)return{year:null};var A=S[1]&&parseInt(S[1]),F=S[2]&&parseInt(S[2]);return{year:F==null?A:100*F,restDateString:p.slice((S[1]||S[2]).length)}}function io(p,x){if(x===null)return null;var m=p.match(Oi);if(!m)return null;var S=!!m[4],A=me(m[1]),F=me(m[2])-1,q=me(m[3]),Q=me(m[4]),st=me(m[5])-1;if(S)return function(xt,wt,Pt){return wt>=1&&wt<=53&&Pt>=0&&Pt<=6}(0,Q,st)?function(xt,wt,Pt){var Mt=new Date(0);Mt.setUTCFullYear(xt,0,4);var oe=Mt.getUTCDay()||7,he=7*(wt-1)+Pt+1-oe;return Mt.setUTCDate(Mt.getUTCDate()+he),Mt}(x,Q,st):new Date(NaN);var mt=new Date(0);return function(xt,wt,Pt){return wt>=0&&wt<=11&&Pt>=1&&Pt<=(Gs[wt]||(Ni(xt)?29:28))}(x,F,q)&&function(xt,wt){return wt>=1&&wt<=(Ni(xt)?366:365)}(x,A)?(mt.setUTCFullYear(x,F,Math.max(A,q)),mt):new Date(NaN)}function me(p){return p?parseInt(p):1}function so(p){var x=p.match(Li);if(!x)return null;var m=_e(x[1]),S=_e(x[2]),A=_e(x[3]);return function(F,q,Q){return F===24?q===0&&Q===0:Q>=0&&Q<60&&q>=0&&q<60&&F>=0&&F<25}(m,S,A)?m*js+6e4*S+1e3*A:NaN}function _e(p){return p&&parseFloat(p.replace(",","."))||0}function Hi(p){if(p==="Z")return 0;var x=p.match(zi);if(!x)return 0;var m=x[1]==="+"?-1:1,S=parseInt(x[2]),A=x[3]&&parseInt(x[3])||0;return function(F,q){return q>=0&&q<=59}(0,A)?m*(S*js+6e4*A):NaN}var Gs=[31,null,31,30,31,30,31,31,30,31,30,31];function Ni(p){return p%400==0||p%4==0&&p%100}let qs={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"};_._adapters._date.override({_id:"date-fns",formats:function(){return qs},parse:function(p,x){if(p==null)return null;let m=typeof p;return m==="number"||p instanceof Date?p=k(p):m==="string"&&(p=typeof x=="string"?function(S,A,F,q){u(3,arguments);var Q=String(S),st=String(A),mt=q||{},xt=mt.locale||$;if(!xt.match)throw new RangeError("locale must contain match property");var wt=xt.options&&xt.options.firstWeekContainsDate,Pt=wt==null?1:h(wt),Mt=mt.firstWeekContainsDate==null?Pt:h(mt.firstWeekContainsDate);if(!(Mt>=1&&Mt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var oe=xt.options&&xt.options.weekStartsOn,he=oe==null?0:h(oe),ke=mt.weekStartsOn==null?he:h(mt.weekStartsOn);if(!(ke>=0&&ke<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(st==="")return Q===""?k(F):new Date(NaN);var se,ce={firstWeekContainsDate:Mt,weekStartsOn:ke,locale:xt},It=[{priority:10,subPriority:-1,set:mi,index:0}],be=st.match(ti).map(function(qt){var de=qt[0];return de==="p"||de==="P"?(0,Di[de])(qt,xt.formatLong,ce):qt}).join("").match(Ws),Me=[];for(se=0;se0&&je.test(Q))return new Date(NaN);var Bi=It.map(function(qt){return qt.priority}).sort(function(qt,de){return de-qt}).filter(function(qt,de,ii){return ii.indexOf(qt)===de}).map(function(qt){return It.filter(function(de){return de.priority===qt}).sort(function(de,ii){return ii.subPriority-de.subPriority})}).map(function(qt){return qt[0]}),us=k(F);if(isNaN(us))return new Date(NaN);var Se=V(us,K(us)),gs={};for(se=0;se=1&&xt<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var wt=Q.options&&Q.options.weekStartsOn,Pt=wt==null?0:h(wt),Mt=q.weekStartsOn==null?Pt:h(q.weekStartsOn);if(!(Mt>=0&&Mt<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!Q.localize)throw new RangeError("locale must contain localize property");if(!Q.formatLong)throw new RangeError("locale must contain formatLong property");var oe=k(m);if(!bt(oe))throw new RangeError("Invalid time value");var he=K(oe),ke=V(oe,he),se={firstWeekContainsDate:xt,weekStartsOn:Mt,locale:Q,_originalDate:oe},ce=F.match(Ns).map(function(It){var be=It[0];return be==="p"||be==="P"?(0,Di[be])(It,Q.formatLong,se):It}).join("").match(jt).map(function(It){if(It==="''")return"'";var be=It[0];if(be==="'")return ve(It);var Me=$s[be];if(Me)return!q.useAdditionalWeekYearTokens&&Zi(It)&&Ve(It,S,m),!q.useAdditionalDayOfYearTokens&&Ai(It)&&Ve(It,S,m),Me(ke,It,Q.localize,se);if(be.match(Yn))throw new RangeError("Format string contains an unescaped latin alphabet character `"+be+"`");return It}).join("");return ce}(p,x,this.options)},add:function(p,x,m){switch(m){case"millisecond":return L(p,x);case"second":return function(S,A){u(2,arguments);var F=h(A);return L(S,1e3*F)}(p,x);case"minute":return function(S,A){u(2,arguments);var F=h(A);return L(S,6e4*F)}(p,x);case"hour":return function(S,A){u(2,arguments);var F=h(A);return L(S,F*G)}(p,x);case"day":return P(p,x);case"week":return function(S,A){u(2,arguments);var F=h(A),q=7*F;return P(S,q)}(p,x);case"month":return z(p,x);case"quarter":return function(S,A){u(2,arguments);var F=h(A),q=3*F;return z(S,q)}(p,x);case"year":return function(S,A){u(2,arguments);var F=h(A);return z(S,12*F)}(p,x);default:return p}},diff:function(p,x,m){switch(m){case"millisecond":return zt(p,x);case"second":return function(S,A){u(2,arguments);var F=zt(S,A)/1e3;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"minute":return function(S,A){u(2,arguments);var F=zt(S,A)/6e4;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"hour":return function(S,A){u(2,arguments);var F=zt(S,A)/te;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"day":return $t(p,x);case"week":return function(S,A){u(2,arguments);var F=$t(S,A)/7;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"month":return pt(p,x);case"quarter":return function(S,A){u(2,arguments);var F=pt(S,A)/3;return F>0?Math.floor(F):Math.ceil(F)}(p,x);case"year":return function(S,A){u(2,arguments);var F=k(S),q=k(A),Q=ft(F,q),st=Math.abs(Dt(F,q));F.setFullYear("1584"),q.setFullYear("1584");var mt=ft(F,q)===-Q,xt=Q*(st-mt);return xt===0?0:xt}(p,x);default:return 0}},startOf:function(p,x,m){switch(x){case"second":return function(S){u(1,arguments);var A=k(S);return A.setMilliseconds(0),A}(p);case"minute":return function(S){u(1,arguments);var A=k(S);return A.setSeconds(0,0),A}(p);case"hour":return function(S){u(1,arguments);var A=k(S);return A.setMinutes(0,0,0),A}(p);case"day":return ut(p);case"week":return U(p);case"isoWeek":return U(p,{weekStartsOn:+m});case"month":return function(S){u(1,arguments);var A=k(S);return A.setDate(1),A.setHours(0,0,0,0),A}(p);case"quarter":return function(S){u(1,arguments);var A=k(S),F=A.getMonth(),q=F-F%3;return A.setMonth(q,1),A.setHours(0,0,0,0),A}(p);case"year":return function(S){u(1,arguments);var A=k(S),F=new Date(0);return F.setFullYear(A.getFullYear(),0,1),F.setHours(0,0,0,0),F}(p);default:return p}},endOf:function(p,x){switch(x){case"second":return function(m){u(1,arguments);var S=k(m);return S.setMilliseconds(999),S}(p);case"minute":return function(m){u(1,arguments);var S=k(m);return S.setSeconds(59,999),S}(p);case"hour":return function(m){u(1,arguments);var S=k(m);return S.setMinutes(59,59,999),S}(p);case"day":return De(p);case"week":return function(m,S){u(1,arguments);var A=S||{},F=A.locale,q=F&&F.options&&F.options.weekStartsOn,Q=q==null?0:h(q),st=A.weekStartsOn==null?Q:h(A.weekStartsOn);if(!(st>=0&&st<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var mt=k(m),xt=mt.getDay(),wt=6+(xt{if(!u.ok)throw new Error(`DatastoreHelper.fetchAndCache(${h}) - HTTP error, status = ${u.status}`);return u.text()}).then(u=>JSON.parse(u)).catch(u=>{console.error(u),alert(u.message),reject(u)}),this.CACHE[h])}static async fetchDeviceData({dev:h,precision:u,attr1:k,attr2:P,mm1:z,mm2:L,z1:G,z2:U}){let K={attr1:[],attr2:[],min1:[],max1:[],min2:[],max2:[]};try{let ut=await fetch(new Request(this.buildCsvUrl(h,u)),{cache:"no-store"});if(ut.status==404)return K;if(!ut.ok)throw new Error(`DatastoreHelper.fetchDeviceData() - HTTP error, status = ${ut.status}`);let X=(await ut.text()).split(` `),it=X.shift().split(","),ft=it.indexOf(k),bt=P==null?-1:it.indexOf(P),Tt=it.indexOf(`${k}_min`),Dt=it.indexOf(`${k}_max`),kt=it.indexOf(`${P}_min`),$t=it.indexOf(`${P}_max`),zt=z===!0&&u!=="5m"&&Tt!==-1&&Dt!==-1,te=L===!0&&u!=="5m"&&kt!==-1&&$t!==-1;return X.forEach(De=>{let vt=De.split(","),At=parseInt(vt[0])*1e3;K.attr1.push({x:At,y:vt[ft]===""||vt[ft]==="-"?G===!0?0:null:parseFloat(vt[ft])}),bt!==-1&&K.attr2.push({x:At,y:vt[bt]===""||vt[bt]==="-"?U===!0?0:null:parseFloat(vt[bt])}),zt&&(K.min1.push({x:At,y:vt[Tt]===void 0||vt[Tt]===""||vt[Tt]==="-"?G===!0?0:null:parseFloat(vt[Tt])}),K.max1.push({x:At,y:vt[Dt]===void 0||vt[Dt]===""||vt[Dt]==="-"?G===!0?0:null:parseFloat(vt[Dt])})),te&&(K.min2.push({x:At,y:vt[kt]===void 0||vt[kt]===""||vt[kt]==="-"?U===!0?0:null:parseFloat(vt[kt])}),K.max2.push({x:At,y:vt[$t]===void 0||vt[$t]===""||vt[$t]==="-"?U===!0?0:null:parseFloat(vt[$t])}))}),K}catch(ut){console.error(ut),alert(ut.message)}}static buildCsvUrl(h,u){return window.location.host!=="cloud.hubitat.com"?`/local/wt_${h}_${u}.csv`:`./watchtower.csv?device=${h}&precision=${u}&access_token=${this.accessToken()}`}static async fetchAttributeData({attr:h,devs:u,precision:k,z:P}){let z={};for(let L of u){let G=await this.fetchDeviceData({dev:L,precision:k,attr1:h,z1:P});z[`dev_${L}`]=G.attr1}return z}static async fetchStatusmapData({ds:h,precision:u}){let k={},P={};h.forEach(L=>{k[L.dev]===void 0&&(k[L.dev]=new Set),k[L.dev].add(L.attr),P[`${L.dev}_${L.attr}`]=[]}),Object.keys(k).forEach(L=>k[L]=Array.from(k[L]));let z=L=>L===""||L==="-"?0:parseFloat(L);for(let[L,G]of Object.entries(k)){let U=G.length;try{let K=await fetch(new Request(this.buildCsvUrl(L,u)),{cache:"no-store"});if(K.status==404)continue;if(!K.ok)throw new Error(`DatastoreHelper.fetchStatusmapData() - HTTP error, status = ${K.status}`);let ut=(await K.text()).split(` `),X=ut.shift().split(","),it=G.map(Dt=>X.indexOf(Dt)),ft=ut.shift().split(","),bt=it.map(Dt=>({x:parseInt(ft[0])*1e3,v:z(ft[Dt])}));ut.forEach(Dt=>{let kt=Dt.split(","),$t=parseInt(kt[0])*1e3;for(let zt=0;zt{let $t=parseInt(Tt[0])*1e3,zt=z(Tt[Dt]);if($t==bt[kt].x)return;let te=G[kt];P[`${L}_${te}`].push({x:[bt[kt].x,$t],v:zt})})}catch(K){console.error(K),alert(K.message)}}return P}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 u=await h.text();return JSON.parse(u)}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 u=await h.text();return JSON.parse(u)}catch(h){console.error(h),alert(h.message)}}};var Tn=class extends Ct{static styles=Ft` :host { display: block; height: calc(100vh - 10px); } `;static properties={halt:{type:Boolean,state:!0},embedded:{type:Boolean,state:!0}};constructor(){if(super(),this.menuElm=void 0,this.gridElm=void 0,this.dialogElm=void 0,this.params=new URLSearchParams(window.location.search),this.name=this.params.get("name"),this.name===null)throw this.bailOut("0001"),new Error("Query parameter [name] is missing!");if(this.params.get("access_token")===null)throw this.bailOut("0002"),new Error("Query parameter [access_token] is missing!");this.mobileView=window.innerWidth<768,window.addEventListener("resize",()=>{let h=window.innerWidth<768;this.mobileView!=h&&(this.mobileView=h,this.applyMobileView())}),window.addEventListener("load",()=>{window.top!==window.self&&(document.body.classList.add("embedded"),this.embedded=!0)}),this.halt=!1}render(){return this.halt!==!1?"":at` ${this.embedded===!0?"":at` `} `}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",h=>this.onKeyDown(h)),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 Nt.fetchGridLayout(this.params.get("name")),u=h.refresh?parseInt(h.refresh):0,k=h.theme==="dark"?"dark":"light",P=h.yScale=="fixed"?"fixed":"auto",z=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(u),this.gridElm.setYScale(P),this.gridElm.setCellHeight(z),this.menuElm.refreshInterval=u,this.menuElm.yScale=P,this.menuElm.cellHeight=z,this.menuElm.setTheme(k),this.applyMobileView()}onKeyDown(h){if(h.key==="Escape"){if(this.dialogElm.open){this.dialogElm.open=!1;return}this.menuElm.open=!this.menuElm.open}}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 u={...h.detail,panels:this.gridElm.getPanelsConfig()};console.info("Saving dashboard to Hubitat",this.name,u),await Nt.saveGridLayout(this.name,u)}showAddDialog(){this.dialogElm.resetForm(),this.dialogElm.setAttribute("open",!0)}editPanel(h){this.dialogElm.config=JSON.parse(JSON.stringify(h.detail)),this.dialogElm.setAttribute("open",!0)}compactPanels(){this.gridElm.compact()}addDashboardPanel(h){this.gridElm.addPanel(h.detail)}applyRefreshInterval(h){let u=parseInt(h.detail);this.gridElm.setRefreshInterval(u)}applyYScale(h){this.gridElm.setYScale(h.detail)}applyCellHeight(h){this.gridElm.setCellHeight(h.detail)}};var Dn=class extends Ct{static styles=Ft` :host { display: block; position: fixed; top: 0; left: 0; height: 100%; } nav { box-sizing: border-box; position: absolute; top: 0; left: -15em; width: 15em; height: 100%; padding: 1em; background-color: var(--bg-color-darker); color: var(--text-color); border-right: 1px var(--border-color) solid; animation: hideme .3s; } :host([open]) nav { box-shadow: 0 0 1em var(--shadow-color); left: 0; animation: showme .3s; } @keyframes hideme { from { left: 0 } to { left: -15em } } @keyframes showme { from { left: -15em } to { left: 0px } } hr { border: 0; border-top: 1px var(--separator-color) solid; margin: 1em 0; } button { background-color: var(--bg-color); color: var(--text-color); border: 1px var(--border-color) solid; border-radius: 5px; margin-bottom: 5px; padding: .5em 1em; cursor: pointer; display: block; width: 100%; text-align: left; box-shadow: 0 0 0.3em var(--shadow-color); } button:hover { background-color: var(--Blue); color: var(--Base3); } label { display: block; margin: 1em 0 .5em 0; font-size: .85rem; } select { display: block; width: 100%; margin-bottom: 5px; height: 30px; background-color: var(--bg-color-darker); color: var(--text-color); border: 1px var(--border-color) solid; border-radius: 5px; } select:focus, button:focus { outline: 1px var(--Blue) solid; border-color: var(--Blue); } aside { color: var(--text-color-darker); position: absolute; bottom: .5em; left: 50%; transform: translateX(-50%); 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-darker); 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 at` `}connectedCallback(){super.connectedCallback(),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 u=Object.fromEntries(new FormData(h.target));this.cellHeight=parseInt(u.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 u=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=${u.get("access_token")}&name=${encodeURIComponent(u.get("name"))}&theme=${h}`)}touchStart(h){this.startX=h.changedTouches[0].clientX}touchEnd(h){if(this.startX==null)return;let u=h.changedTouches[0].clientX,k=u-this.startX;if(!this.open&&this.startX<60&&k>50){this.open=!0;return}this.open&&u<150&&k<-50&&(this.open=!1)}};var An=class _ extends Ct{static styles=Ft` :host { display: none; position: fixed; width: 100%; height: 100%; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.3); font-size: 0.84rem; } :host([open="true"]) { display: block; } .spinner:after { position: absolute; top: calc(50% - 0.5em); left: 0.5em; content: ' '; display: block; width: 1em; height: 1em; border-radius: 50%; border: 1px solid var(--text-color-darker); border-color: var(--text-color-darker) transparent var(--text-color-darker) transparent; animation: spinner 1.2s linear infinite; } @keyframes spinner { 0% { transform: rotate(0deg) } 100% { transform: rotate(360deg) } } article { box-sizing: border-box; display: block; position: absolute; top: -50%; left: 50%; transform: translate(-50%, -50%); min-width: 300px; background-color: var(--bg-color-darker); color: var(--text-color); border: 1px var(--border-color) solid; box-shadow: 0 0 1em var(--shadow-color); border-radius: 5px; padding: 0; } :host([open="true"]) article { animation: showme .5s; animation-fill-mode: forwards; } @keyframes showme { to { top: 50% } } header { text-align: center; font-weight: bold; padding: 1em; } section.modal-body { max-height: 70vh; overflow-y: auto; padding: 0 1em; } section.modal-body fieldset { border: 0; border-radius: 5px; background-color: var(--bg-color); padding: 10px; } section.modal-body fieldset:not(:last-child) { margin-bottom: 10px; } section.modal-body fieldset nav { text-align: right; border-top: 1px var(--border-color) solid; margin-top: 5px; padding-top: 5px; color: var(--border-color); } section.modal-body fieldset a { color: var(--Blue); text-decoration: none; } fieldset section:not(:last-child) { margin-bottom: 10px; } section.modal-body section > div { margin-top: .3em; } footer { padding: 1em; text-align: right; } button { padding: .5em 1em; cursor: pointer; background-color: var(--bg-color); color: var(--text-color); border: 1px var(--border-color) solid; border-radius: 5px; box-shadow: 0 0 0.3em var(--shadow-color); } button:not(:first-child) { margin-left: 10px; } button:hover { background-color: var(--Blue); color: var(--Base3); } label { display: block; user-select: none; margin-bottom: 5px } select { display: block; line-height: 32px } input, select { box-sizing: border-box; display: block; width: 100%; height: 32px; background-color: var(--bg-color-darker); color: var(--text-color); border: 1px var(--border-color) solid; border-radius: 5px; padding: 6px; margin: 0; } .checkbox:not(:last-child) { margin-bottom: 9px } .checkbox input { display: none } .checkbox label { align-items: center; cursor: pointer; display: flex; line-height: 15px; height: 15px; position: relative; magin-bottom: 0; } .checkbox label::before, .checkbox label::after { content: ''; display: block } .checkbox label::before { background-color: var(--Base00); border-radius: 500px; height: 15px; margin-right: 8px; width: 25px; } .checkbox input:user-invalid + label::before { background-color: var(--Red) } .checkbox label::after { background-color: #fff; border-radius: 13px; height: 13px; left: 1px; position: absolute; top: 1px; transition: transform 0.125s ease-out; width: 13px; } .checkbox input:checked + label::before { background-color: var(--Blue) } .checkbox input:checked + label::after { transform: translate3d(10px, 0, 0) } input:focus, select:focus, button:focus { outline: 1px var(--Blue) solid; border-color: var(--Blue) } input:user-invalid, select:user-invalid { border-color: var(--Red) !important; } aside { display: block; position: relative; background-color: var(--bg-color); color: var(--text-color-darker); border: 1px var(--border-color) solid; padding: .5em .5em .5em 2.3em; } `;static panels={"device-panel":"Device","attribute-panel":"Attribute","statusmap-panel":"Status Map","text-panel":"Text","iframe-panel":"Iframe","hub-info-panel":"Hub Info"};static properties={open:{type:Boolean,reflect:!0},config:{type:Object,state:!0}};constructor(){super(),this.open=!1,this.resetForm()}render(){return setTimeout(()=>this.renderRoot.querySelector(".panel-config")?.addEventListener("suggestTitle",h=>this.suggestTitle(h)),0),this.open?at`
${this.config.id?"Edit":"Add"} Dashboard Tile
`:Rt}renderPanelConfig(){return En(` <${this.config.type}-config class="panel-config" config='${JSON.stringify(this.config).replace(/'/g,"'")}'> `)}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",h=>h.key==="Escape"&&this.close(h))}onTileTypeChange(h){this.config={id:this.config.id,title:this.config.title,type:h.target.value}}suggestTitle(h){this.config.title==""&&(this.config.title=h.detail)}updated(h){h.size==0||h.open}resetForm(){this.config={title:""}}close(){this.resetForm(),this.open=!1}submit(h){h.preventDefault();let u=this.renderRoot.querySelector(".panel-config").decorateConfig({id:this.config.id,title:this.config.title,type:this.config.type});Object.keys(u).forEach(k=>u[k]===void 0&&delete u[k]),console.info("**** Adding panel with config",u),this.close(),this.resetForm(),this.dispatchEvent(new CustomEvent("done",{detail:u}))}};var Pn=class extends Ct{static styles=Ft` .grid-stack{position:relative}.grid-stack-rtl{direction:ltr}.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack-placeholder>.placeholder-content{background-color:rgba(0,0,0,.1);margin:0;position:absolute;width:auto;z-index:0!important}.grid-stack>.grid-stack-item{position:absolute;padding:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;width:auto;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item.size-to-content:not(.size-to-content-max)>.grid-stack-item-content{overflow-y:hidden}.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se,.grid-stack-item>.ui-resizable-sw{background-image:url('data:image/svg+xml;utf8,');background-repeat:no-repeat;background-position:center}.grid-stack-item>.ui-resizable-ne{transform:translate(0,10px) rotate(45deg)}.grid-stack-item>.ui-resizable-sw{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-nw{transform:translate(0,10px) rotate(-45deg)}.grid-stack-item>.ui-resizable-se{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;top:0}.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:0;left:25px;right:25px}.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;top:0}.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;top:15px;bottom:15px}.grid-stack-item>.ui-resizable-se{cursor:se-resize;width:20px;height:20px}.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:0;right:25px}.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px}.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;top:15px;bottom:15px}.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack-item.ui-draggable-dragging{will-change:left,top;cursor:move}.grid-stack-item.ui-resizable-resizing{will-change:width,height}.ui-draggable-dragging,.ui-resizable-resizing{z-index:10000}.ui-draggable-dragging>.grid-stack-item-content,.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack-animate,.grid-stack-animate .grid-stack-item{transition:left .3s,top .3s,height .3s,width .3s}.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack-animate .grid-stack-item.ui-resizable-resizing{transition:left 0s,top 0s,height 0s,width 0s}.grid-stack>.grid-stack-item[gs-y="0"]{top:0}.grid-stack>.grid-stack-item[gs-x="0"]{left:0}.gs-12>.grid-stack-item{width:8.333%}.gs-12>.grid-stack-item[gs-x="1"]{left:8.333%}.gs-12>.grid-stack-item[gs-w="2"]{width:16.667%}.gs-12>.grid-stack-item[gs-x="2"]{left:16.667%}.gs-12>.grid-stack-item[gs-w="3"]{width:25%}.gs-12>.grid-stack-item[gs-x="3"]{left:25%}.gs-12>.grid-stack-item[gs-w="4"]{width:33.333%}.gs-12>.grid-stack-item[gs-x="4"]{left:33.333%}.gs-12>.grid-stack-item[gs-w="5"]{width:41.667%}.gs-12>.grid-stack-item[gs-x="5"]{left:41.667%}.gs-12>.grid-stack-item[gs-w="6"]{width:50%}.gs-12>.grid-stack-item[gs-x="6"]{left:50%}.gs-12>.grid-stack-item[gs-w="7"]{width:58.333%}.gs-12>.grid-stack-item[gs-x="7"]{left:58.333%}.gs-12>.grid-stack-item[gs-w="8"]{width:66.667%}.gs-12>.grid-stack-item[gs-x="8"]{left:66.667%}.gs-12>.grid-stack-item[gs-w="9"]{width:75%}.gs-12>.grid-stack-item[gs-x="9"]{left:75%}.gs-12>.grid-stack-item[gs-w="10"]{width:83.333%}.gs-12>.grid-stack-item[gs-x="10"]{left:83.333%}.gs-12>.grid-stack-item[gs-w="11"]{width:91.667%}.gs-12>.grid-stack-item[gs-x="11"]{left:91.667%}.gs-12>.grid-stack-item[gs-w="12"]{width:100%}.gs-1>.grid-stack-item{width:100%} .gs-2>.grid-stack-item{width:50%}.gs-2>.grid-stack-item[gs-x="1"]{left:50%}.gs-2>.grid-stack-item[gs-w="2"]{width:100%}.gs-3>.grid-stack-item{width:33.333%}.gs-3>.grid-stack-item[gs-x="1"]{left:33.333%}.gs-3>.grid-stack-item[gs-w="2"]{width:66.667%}.gs-3>.grid-stack-item[gs-x="2"]{left:66.667%}.gs-3>.grid-stack-item[gs-w="3"]{width:100%}.gs-4>.grid-stack-item{width:25%}.gs-4>.grid-stack-item[gs-x="1"]{left:25%}.gs-4>.grid-stack-item[gs-w="2"]{width:50%}.gs-4>.grid-stack-item[gs-x="2"]{left:50%}.gs-4>.grid-stack-item[gs-w="3"]{width:75%}.gs-4>.grid-stack-item[gs-x="3"]{left:75%}.gs-4>.grid-stack-item[gs-w="4"]{width:100%}.gs-5>.grid-stack-item{width:20%}.gs-5>.grid-stack-item[gs-x="1"]{left:20%}.gs-5>.grid-stack-item[gs-w="2"]{width:40%}.gs-5>.grid-stack-item[gs-x="2"]{left:40%}.gs-5>.grid-stack-item[gs-w="3"]{width:60%}.gs-5>.grid-stack-item[gs-x="3"]{left:60%}.gs-5>.grid-stack-item[gs-w="4"]{width:80%}.gs-5>.grid-stack-item[gs-x="4"]{left:80%}.gs-5>.grid-stack-item[gs-w="5"]{width:100%}.gs-6>.grid-stack-item{width:16.667%}.gs-6>.grid-stack-item[gs-x="1"]{left:16.667%}.gs-6>.grid-stack-item[gs-w="2"]{width:33.333%}.gs-6>.grid-stack-item[gs-x="2"]{left:33.333%}.gs-6>.grid-stack-item[gs-w="3"]{width:50%}.gs-6>.grid-stack-item[gs-x="3"]{left:50%}.gs-6>.grid-stack-item[gs-w="4"]{width:66.667%}.gs-6>.grid-stack-item[gs-x="4"]{left:66.667%}.gs-6>.grid-stack-item[gs-w="5"]{width:83.333%}.gs-6>.grid-stack-item[gs-x="5"]{left:83.333%}.gs-6>.grid-stack-item[gs-w="6"]{width:100%}.gs-7>.grid-stack-item{width:14.286%}.gs-7>.grid-stack-item[gs-x="1"]{left:14.286%}.gs-7>.grid-stack-item[gs-w="2"]{width:28.571%}.gs-7>.grid-stack-item[gs-x="2"]{left:28.571%}.gs-7>.grid-stack-item[gs-w="3"]{width:42.857%}.gs-7>.grid-stack-item[gs-x="3"]{left:42.857%}.gs-7>.grid-stack-item[gs-w="4"]{width:57.143%}.gs-7>.grid-stack-item[gs-x="4"]{left:57.143%}.gs-7>.grid-stack-item[gs-w="5"]{width:71.429%}.gs-7>.grid-stack-item[gs-x="5"]{left:71.429%}.gs-7>.grid-stack-item[gs-w="6"]{width:85.714%}.gs-7>.grid-stack-item[gs-x="6"]{left:85.714%}.gs-7>.grid-stack-item[gs-w="7"]{width:100%}.gs-8>.grid-stack-item{width:12.5%}.gs-8>.grid-stack-item[gs-x="1"]{left:12.5%}.gs-8>.grid-stack-item[gs-w="2"]{width:25%}.gs-8>.grid-stack-item[gs-x="2"]{left:25%}.gs-8>.grid-stack-item[gs-w="3"]{width:37.5%}.gs-8>.grid-stack-item[gs-x="3"]{left:37.5%}.gs-8>.grid-stack-item[gs-w="4"]{width:50%}.gs-8>.grid-stack-item[gs-x="4"]{left:50%}.gs-8>.grid-stack-item[gs-w="5"]{width:62.5%}.gs-8>.grid-stack-item[gs-x="5"]{left:62.5%}.gs-8>.grid-stack-item[gs-w="6"]{width:75%}.gs-8>.grid-stack-item[gs-x="6"]{left:75%}.gs-8>.grid-stack-item[gs-w="7"]{width:87.5%}.gs-8>.grid-stack-item[gs-x="7"]{left:87.5%}.gs-8>.grid-stack-item[gs-w="8"]{width:100%}.gs-9>.grid-stack-item{width:11.111%}.gs-9>.grid-stack-item[gs-x="1"]{left:11.111%}.gs-9>.grid-stack-item[gs-w="2"]{width:22.222%}.gs-9>.grid-stack-item[gs-x="2"]{left:22.222%}.gs-9>.grid-stack-item[gs-w="3"]{width:33.333%}.gs-9>.grid-stack-item[gs-x="3"]{left:33.333%}.gs-9>.grid-stack-item[gs-w="4"]{width:44.444%}.gs-9>.grid-stack-item[gs-x="4"]{left:44.444%}.gs-9>.grid-stack-item[gs-w="5"]{width:55.556%}.gs-9>.grid-stack-item[gs-x="5"]{left:55.556%}.gs-9>.grid-stack-item[gs-w="6"]{width:66.667%}.gs-9>.grid-stack-item[gs-x="6"]{left:66.667%}.gs-9>.grid-stack-item[gs-w="7"]{width:77.778%}.gs-9>.grid-stack-item[gs-x="7"]{left:77.778%}.gs-9>.grid-stack-item[gs-w="8"]{width:88.889%}.gs-9>.grid-stack-item[gs-x="8"]{left:88.889%}.gs-9>.grid-stack-item[gs-w="9"]{width:100%}.gs-10>.grid-stack-item{width:10%}.gs-10>.grid-stack-item[gs-x="1"]{left:10%}.gs-10>.grid-stack-item[gs-w="2"]{width:20%}.gs-10>.grid-stack-item[gs-x="2"]{left:20%}.gs-10>.grid-stack-item[gs-w="3"]{width:30%}.gs-10>.grid-stack-item[gs-x="3"]{left:30%}.gs-10>.grid-stack-item[gs-w="4"]{width:40%}.gs-10>.grid-stack-item[gs-x="4"]{left:40%}.gs-10>.grid-stack-item[gs-w="5"]{width:50%}.gs-10>.grid-stack-item[gs-x="5"]{left:50%}.gs-10>.grid-stack-item[gs-w="6"]{width:60%}.gs-10>.grid-stack-item[gs-x="6"]{left:60%}.gs-10>.grid-stack-item[gs-w="7"]{width:70%}.gs-10>.grid-stack-item[gs-x="7"]{left:70%}.gs-10>.grid-stack-item[gs-w="8"]{width:80%}.gs-10>.grid-stack-item[gs-x="8"]{left:80%}.gs-10>.grid-stack-item[gs-w="9"]{width:90%}.gs-10>.grid-stack-item[gs-x="9"]{left:90%}.gs-10>.grid-stack-item[gs-w="10"]{width:100%}.gs-11>.grid-stack-item{width:9.091%}.gs-11>.grid-stack-item[gs-x="1"]{left:9.091%}.gs-11>.grid-stack-item[gs-w="2"]{width:18.182%}.gs-11>.grid-stack-item[gs-x="2"]{left:18.182%}.gs-11>.grid-stack-item[gs-w="3"]{width:27.273%}.gs-11>.grid-stack-item[gs-x="3"]{left:27.273%}.gs-11>.grid-stack-item[gs-w="4"]{width:36.364%}.gs-11>.grid-stack-item[gs-x="4"]{left:36.364%}.gs-11>.grid-stack-item[gs-w="5"]{width:45.455%}.gs-11>.grid-stack-item[gs-x="5"]{left:45.455%}.gs-11>.grid-stack-item[gs-w="6"]{width:54.545%}.gs-11>.grid-stack-item[gs-x="6"]{left:54.545%}.gs-11>.grid-stack-item[gs-w="7"]{width:63.636%}.gs-11>.grid-stack-item[gs-x="7"]{left:63.636%}.gs-11>.grid-stack-item[gs-w="8"]{width:72.727%}.gs-11>.grid-stack-item[gs-x="8"]{left:72.727%}.gs-11>.grid-stack-item[gs-w="9"]{width:81.818%}.gs-11>.grid-stack-item[gs-x="9"]{left:81.818%}.gs-11>.grid-stack-item[gs-w="10"]{width:90.909%}.gs-11>.grid-stack-item[gs-x="10"]{left:90.909%}.gs-11>.grid-stack-item[gs-w="11"]{width:100%} .grid-stack { min-height: 100% } .grid-stack-item-content { box-sizing: border-box; background-color: var(--bg-color-darker); color: var(--text-color); border: 1px transparent solid; border-radius: 5px; box-shadow: 0 0 4px rgba(0, 0, 0, 0.1); } .grid-stack-item-content:hover { border-color: var(--border-color); } .grid-stack-item[gs-id^="tr-"] .grid-stack-item-content { border: none; box-shadow: none; overflow: hidden; } .panel-container { width: 100%; height: 100%; position: relative; } .grid-stack-item[gs-id^="tr-"] .grid-stack-item-content { background-color: transparent; } .panel-title { position: absolute; top: 0; left: 50%; transform: translate(-50%, 0); background-color: transparent; color: var(--text-color-darker); text-align: center; padding: 0.2em 1em 0.2em 1em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; user-select: none; } .grid-stack:not([mobile-view]) .panel-container:hover .panel-title { cursor: move; background-color: var(--bg-color); color: var(--text-color); box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); border: 1px var(--border-color) solid; border-radius: 0 0 5px 5px; border-top: 0; } .grid-stack-item-removing .panel-container { background-color: rgba(255, 0, 0, 0.3); } .spinner:after { position: absolute; top: calc(50% - 32px); left: calc(50% - 32px); content: ' '; display: block; width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--text-color-darker); border-color: var(--text-color-darker) transparent var(--text-color-darker) transparent; animation: spinner 1.2s linear infinite; } @keyframes spinner { 0% { transform: rotate(0deg) } 100% { transform: rotate(360deg) } } `;static properties={name:{type:String,reflect:!0},mobileView:{type:Boolean,state:!0}};constructor(){super(),this.yScale=void 0}render(){return at`
`}firstUpdated(){this.grid=GridStack.init({sizeToContent:!1,margin:5,animate:!1,float:!0,cellHeight:206,column:8,columnOpts:{layout:"move",columnMax:8,breakpointForWindow:!0,breakpoints:[{w:420,c:1},{w:800,c:2},{w:1024,c:4},{w:1366,c:6}]},handle:".panel-title",removable:!0,alwaysShowResizeHandle:!1},this.renderRoot.querySelector(".grid-stack"))}async init(h){h.length===0?this.addPanel({type:"text-panel",title:"Quick Instructions",message:` \u{1F60E} Welcome to your new dashboard!
  • Press the ESC (Escape) key on your keyboard, or swipe from the left margin, to show or hide the left menu.
  • Click the Add dashboard tile button to add new tiles to your dashboard.
  • Rearrange tiles by dragging their titles. Resize tiles by dragging the bottom-right corner.
  • Remove tiles by dragging them outside the dashboard grid.
  • 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(u=>this.addPanel(u.config,u.w,u.h,u.x,u.y)),this.grid.batchUpdate(!1)),this.renderRoot.querySelector(".grid-stack").classList.remove("spinner")}applyMobileView(h){this.mobileView=h,this.renderRoot.querySelectorAll(".panel").forEach(u=>u.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(u=>u.refresh())},h*60*1e3),console.info(`Setting auto-refresh timer for ${h} minutes`))}setYScale(h){this.yScale=h,this.renderRoot.querySelectorAll("device-panel, attribute-panel").forEach(u=>u.setYScale(h))}setCellHeight(h){this.grid.cellHeight(h,!0)}addPanel(h,u=2,k=1,P=void 0,z=void 0){let L=u,G=k,U=P,K=z,ut=this.grid.engine.nodes.find(it=>it.config?.id==h.id);ut?(L=ut.w,G=ut.h,U=ut.x,K=ut.y,this.grid.removeWidget(ut.el)):h.id=this.randomUUID();let X=`
<${h.type} config='${JSON.stringify(h).replace(/'/g,"'")}' yScale="${this.yScale}" class="panel empty spinner">
${h.title||" "}
`;this.grid.addWidget({w:L,h:G,x:U,y:K,config:h,content:X,id:`${h.noBorder===!0?"tr-":""}${h.id}`})}editPanel(h){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:h.detail}))}randomUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){var u=Math.random()*16|0,k=h=="x"?u:u&3|8;return k.toString(16)})}compact(){this.grid.compact()}getPanelsConfig(){return this.grid.engine.nodes.map(h=>{let u=h.el.querySelector(".panel");return{w:h.w,h:h.h,x:h.x,y:h.y,config:u.decorateConfig(h.config)}})}};var On={"5m":{amount:5,unit:"minute",description:"View data with 5 minutes precision"},"1h":{amount:1,unit:"hour",description:"View data with 1 hour precision"},"1d":{amount:1,unit:"day",description:"View data with 1 day precision"},"1w":{amount:1,unit:"week",description:"View data with 1 week precision"}},Rn=class extends Ct{static styles=Ft` ul { margin: 0; padding: 0; list-style: none; background-color: var(--bg-color); color: var(--text-color); border: 1px var(--border-color) solid; border-bottom: 0; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); border-radius: 5px 5px 0 0; display: flex; user-select: none; } ul li { list-style-type: none; display: inline-block; margin: 0; padding: .4em 0; border-right: 1px var(--border-color) solid; cursor: pointer; width: 2.85em; text-align: center; } ul li:first-child { border-radius: 4px 0 0 0 } ul li:last-child { border: 0; border-radius: 0 4px 0 0 } ul li:hover { background-color: var(--bg-color-darker); } ul li[data-selected] { background-color: var(--Blue); color: var(--Base3); } .ui-resizable-handle { opacity:0 } `;static properties={precision:{type:Object,state:!0}};render(){return at` `}selectPrecision(h){this.precision=h.target.textContent,this.dispatchEvent(new CustomEvent("change",{detail:this.precision}))}};var Te=class _{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);_.chartColors=[h.getPropertyValue("--Magenta"),h.getPropertyValue("--Blue")]}};var ul={callbacks:{afterZoom:function(){}}},gl={id:"crosshair",afterInit:function(_){if(_.config.options.scales.x){var h=_.config.options.scales.x.type;h!=="linear"&&h!=="time"&&h!=="category"&&h!=="logarithmic"||(_.options.plugins.crosshair===void 0&&(_.options.plugins.crosshair=ul),_.crosshair={x:null,originalXRange:null,button:null,dragStarted:!1,dragStartX:null,dragEndX:null,ignoreNextEvents:0,canStartDrag:!1,timeout:null,resetZoom:()=>this.resetZoom(_),panZoom:u=>this.panZoom(_,u)},window.addEventListener("crosshair",u=>this.syncCrosshair(_,u.detail)))}},syncCrosshair(_,{id:h,time:u}){if(_.id===h)return;var k=this.getXScale(_);if(!k)return;if(u===null){if(_.crosshair.x===null)return;_.crosshair.x=null,_.draw();return}u=Math.min(Math.max(u,k.min),k.max);let P=Math.round(k.getPixelForValue(u));_.crosshair.x!=P&&(_.crosshair.x=P,_.draw())},panZoom:function(_,h){if(_.crosshair.originalXRange===null)return;let{min:u,max:k}=_.crosshair.originalXRange,P=_.options.scales.x.min,z=_.options.scales.x.max;if(P===u&&h==="left"||z===k&&h==="right")return;let L=z-P,G=L/10;h==="left"?(_.options.scales.x.min=Math.max(P-G,u),_.options.scales.x.max=_.options.scales.x.min+L):(_.options.scales.x.max=Math.min(z+G,k),_.options.scales.x.min=_.options.scales.x.max-L),_.update()},getOption:function(_,h,u){let k=_.options.plugins.crosshair[h]?_.options.plugins.crosshair[h][u]:void 0;return k!==void 0?k:ul[h][u]},getXScale:function(_){return _.data.datasets.length?_.scales[_.getDatasetMeta(0).xAxisID]:null},getYScale:function(_){return _.scales[_.getDatasetMeta(0).yAxisID]},afterEvent:function(_,h){if(_.config.options.scales.x.length==0)return!1;var u=this.getXScale(_);if(!u)return!1;if(_.crosshair.ignoreNextEvents>0)return _.crosshair.ignoreNextEvents-=1,!1;let k=u.getPixelForValue(u.min),P=u.getPixelForValue(u.max),z=h.event;z.x=Math.round(Math.min(Math.max(z.x,k),P));let L=Math.round(u.getValueForPixel(z.x));if(z.type==="click"){_.crosshair.canStartDrag=!0,_.crosshair.dragStarted=!1,clearTimeout(_.crosshair.timeout),_.crosshair.timeout=setTimeout(()=>_.crosshair.canStartDrag=!1,1e3);return}if(z.type==="mousedown"&&!_.crosshair.dragStarted){if(z.native.type==="mousedown"&&(_.crosshair.canStartDrag=!0),!_.crosshair.canStartDrag)return;_.crosshair.x=z.x,_.crosshair.dragStartX=z.x,_.crosshair.dragStarted=!0,_.draw();return}if(z.type==="mouseout"){_.crosshair.x=null,_.crosshair.canStartDrag=!1,_.crosshair.dragStarted=!1,_.draw(),window.dispatchEvent(new CustomEvent("crosshair",{detail:{id:_.id,time:null}}));return}if(_.crosshair.dragStarted&&z.type==="mouseup"){if(_.crosshair.dragStarted=!1,Math.abs(_.crosshair.dragStartX-z.x)<3)return _.draw(),!1;var G=u.getValueForPixel(_.crosshair.dragStartX);this.doZoom(_,G,L),z.native.ctrlKey&&Chart.helpers.each(Chart.instances,U=>{U.id!=_.id&&this.doZoom(U,G,L)});return}if(_.crosshair.x==z.x)return!1;_.crosshair.x=z.x,_.draw(),window.dispatchEvent(new CustomEvent("crosshair",{detail:{id:_.id,time:L}}))},afterDraw:function(_){return _.crosshair.x===null?!1:(_.crosshair.dragStarted?this.drawZoombox(_):this.drawTraceLine(_),!0)},resetZoom:function(_,h=!1){_.crosshair.originalXRange!==null&&(_.options.scales.x.min=_.crosshair.originalXRange.min,_.options.scales.x.max=_.crosshair.originalXRange.max,_.crosshair.button&&_.crosshair.button.parentNode&&(_.crosshair.button.parentNode.removeChild(_.crosshair.button),_.crosshair.button=null),_.update(),this.getOption(_,"callbacks","afterZoom")({chart:_}),h&&Chart.helpers.each(Chart.instances,u=>{u.id!=_.id&&this.resetZoom(u)}))},doZoom:function(_,h,u){if(_.crosshair.dragStarted=!1,h==u||(_.crosshair.originalXRange===null&&(_.crosshair.originalXRange={min:_.scales.x.min,max:_.scales.x.max}),h>u&&([h,u]=[u,h]),h=Math.max(h,_.crosshair.originalXRange.min),u=Math.min(u,_.crosshair.originalXRange.max),h>u))return!1;if(_.crosshair.button==null){var k=document.createElement("button"),P=document.createTextNode("\u25C0\u2022\u2022\u2022\u25B6");k.appendChild(P),k.className="reset-zoom",k.setAttribute("title","Reset Zoom"),k.addEventListener("click",z=>this.resetZoom(_,z.ctrlKey)),_.canvas.parentNode.appendChild(k),_.crosshair.button=k}_.options.scales.x.min=h,_.options.scales.x.max=u,_.update(),_.crosshair.ignoreNextEvents=2,this.getOption(_,"callbacks","afterZoom")(h,u)},drawZoombox:function(_){_.ctx.beginPath(),_.ctx.rect(_.crosshair.dragStartX,_.chartArea.top,_.crosshair.x-_.crosshair.dragStartX,_.chartArea.bottom-_.chartArea.top),_.ctx.lineWidth=1,_.ctx.strokeStyle="#48F",_.ctx.fillStyle="rgba(66,133,244,0.2)",_.ctx.fill(),_.ctx.fillStyle="",_.ctx.stroke(),_.ctx.closePath()},drawTraceLine:function(_){_.crosshair.x!=null&&(_.ctx.beginPath(),_.ctx.setLineDash([]),_.ctx.moveTo(_.crosshair.x,_.chartArea.top),_.ctx.lineWidth=1,_.ctx.strokeStyle="#dc322f",_.ctx.lineTo(_.crosshair.x,_.chartArea.bottom),_.ctx.stroke(),_.ctx.setLineDash([]))}};Chart.register(gl);var Vo=Chart.Tooltip.positioners;Vo.custom=function(_,h){let u=Vo.nearest(_,h);if(u===!1)return!1;let k=this.chart.chartArea;return u.yk.bottom-25&&(u.yAlign="bottom",u.xAlign=u.x<(k.left+k.right)/2?"left":"right"),u};Vo.mouse=function(_,h){if(!_?.length)return!1;let u=h,k=this.chart.chartArea;return u.yk.bottom-25&&(u.yAlign="bottom",u.xAlign=u.x<(k.left+k.right)/2?"left":"right"),u};var Os=Chart._adapters._date.prototype;function sc(_,h,u){return`${Os.format(Os.add(_,0-h.amount,h.unit),u[h.unit])} - ${Os.format(_,u[h.unit])}`}function nc(_,h,u){return`${Os.format(_[0],u[h.unit])} - ${Os.format(_[1],u[h.unit])}`}var re=class _{static lineConfig(){let h=Te.colors();return{type:"line",options:{events:["click","mousedown","mousemove","mouseup","mouseout","touchstart","touchmove","touchend"],parsing:!1,normalized:!0,responsive:!0,maintainAspectRatio:!1,onResize:u=>_.updateChartType(u),animation:{duration:500,onComplete:({initial:u,chart:k})=>u?_.updateChartType(k):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",week:"d LLL"}},title:{display:!1},ticks:{color:h.TextColorDarker,maxRotation:0,autoSkipPadding:15},grid:{color:h.TextColorDarker+"44"}}},interaction:{mode:"nearest",axis:"x",intersect:!1},plugins:{legend:{display:!1},tooltip:{itemSort:(u,k)=>k.raw.y-u.raw.y,callbacks:{title:u=>sc(u[0].parsed.x,On[u[0].chart.precision],u[0].chart.options.scales.x.time.displayFormats),label:u=>` ${u.dataset.label}: ${u.parsed.y}${u.dataset.unit}`},backgroundColor:h.BgColorDarker,titleColor:h.TextColor,bodyColor:h.TextColorDarker,borderColor:h.BorderColor,borderWidth:1,position:"custom",intersect:!1},crosshair:{line:{color:h.Red,width:1},zoom:{zoomButtonText:"\u25C0\u2022\u2022\u2022\u25B6"},callbacks:{afterZoom:u=>this.updateChartType(u.chart)}}}}}}static statusmapConfig(){let h=Te.colors();return{type:"bar",options:{events:["mousedown","mousemove","mouseup","mouseout","click","touchstart","touchmove","touchend"],barPercentage:1,categoryPercentage:.9,indexAxis:"y",maintainAspectRatio:!1,layout:{padding:{top:25,bottom:4,right:10}},scales:{x:{type:"time",time:{minUnit:"minute",displayFormats:{minute:"d LLL HH:mm",hour:"d LLL HH:mm",day:"d LLL",week:"d LLL"}},title:{display:!1},ticks:{color:h.TextColorDarker,maxRotation:0,autoSkipPadding:15},grid:{color:h.TextColorDarker+"44"}},y:{beginAtZero:!0,stacked:!0}},plugins:{legend:{display:!1},tooltip:{itemSort:(u,k)=>k.raw.y-u.raw.y,callbacks:{title:u=>nc(u[0].raw.x,On[u[0].chart.precision],u[0].chart.options.scales.x.time.displayFormats),label:u=>` ${u.dataset.label}: ${u.raw.v}${u.dataset.unit}`},backgroundColor:h.BgColorDarker,titleColor:h.TextColor,bodyColor:h.TextColorDarker,borderColor:h.BorderColor,borderWidth:1,position:"mouse",intersect:!0},crosshair:{callbacks:{afterZoom:u=>this.updatePointStyle(u.chart)}}}}}}static updateChartType(h){return this.updatePointStyle(h)}static updatePointStyle(h){if(h.scales.x===void 0||h.data.datasets[0]===void 0)return;let u=h.scales.x.min,k=h.scales.x.max,z=h.data.datasets[0].data.filter(G=>G.x>=u&&G.x<=k).length,L=h.width/z>30?"circle":!1;h.data.datasets[0].pointStyle!==L&&(h.data.datasets.forEach(G=>G.pointStyle=L),h.update())}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 Ln=class extends Ct{static styles=Ft` :host { display: block; width: 100%; height: 100%; } canvas { width: 100%; height: 100%; touch-action: pan-y; } :host(.empty) canvas { visibility: hidden } precision-selector { position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 0); visibility: hidden; } :host(:hover) precision-selector, :host(:hover) nav { visibility: visible; } aside { position: absolute; top: 50%; left: 0; transform: translate(0, -50%); display: block; color: var(--text-color-darker); width: 100%; text-align: center; } .reset-zoom { position: absolute; top: 0px; right: 0px; border: none; background-color: var(--Blue); color: var(--Base3); border-radius: 0 0 0 5px; padding: 5px 10px; line-height: 1rem; z-index: 100; cursor: pointer; letter-spacing: 1px; } nav { position: absolute; top: 0px; left: 2px; cursor: pointer; visibility: hidden; } `;static properties={config:{type:Object,reflect:!0},yScale:{type:String,reflect:!0},mobileView:{type:Boolean,state:!0},chart:{type:Object,state:!0},nodata:{type:Boolean,state:!0}};render(){return at` ${this.nodata===!0?at``:""} `}updated(h){h.mobileView!=this.mobileView}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m")}async firstUpdated(){await this.initChart()}onKeyDown(h){this.chart!==void 0&&(h.keyCode===37?this.chart.crosshair.panZoom("left"):h.keyCode===39&&this.chart.crosshair.panZoom("right"))}async initChart(){let h=re.lineConfig();this.classList.add("spinner");let u=await Nt.fetchSupportedAttributes(),k=Te.colors(),P=await Nt.fetchDeviceData(this.config);this.nodata=P.attr1.length==0;let z=re.prettyName(this.config.attr1),L=u[this.config.attr1].unit,G=[{label:z,data:P.attr1,pointStyle:!1,backgroundColor:k.Blue+"44",borderColor:k.Blue,borderWidth:1.2,tension:.5,fill:this.config.mm1!==!0&&this.config.mm2!==!0,yAxisID:"attr1",unit:L}];if(this.config.mm1&&(G.push({label:`${z} min`,data:P.min1,pointStyle:!1,backgroundColor:k.Blue+"22",borderColor:k.Blue,borderWidth:1.2,borderDash:[2,2],tension:.5,fill:"+1",yAxisID:"attr1",unit:L}),G.push({label:`${z} max`,data:P.max1,pointStyle:!1,borderColor:k.Blue,backgroundColor:k.Blue+"22",borderWidth:1.2,borderDash:[2,2],tension:.5,fill:!1,yAxisID:"attr1",unit:L})),h.options.scales.attr1={position:"left",display:!0,title:{display:!0,text:`${z} ${L}`,color:k.Blue},ticks:{color:k.TextColorDarker,precision:0},grid:{color:k.TextColorDarker+"33"}},this.attr1Min=u[this.config.attr1].min,this.attr1Max=u[this.config.attr1].max,this.yScale==="fixed"&&(this.attr1Min!==void 0&&(h.options.scales.attr1.suggestedMin=this.attr1Min),this.attr1Max!==void 0&&(h.options.scales.attr1.suggestedMax=this.attr1Max)),this.config.attr2!==void 0){let U=re.prettyName(this.config.attr2),K=u[this.config.attr2].unit;G.push({label:U,data:P.attr2,pointStyle:!1,backgroundColor:k.Green+"44",borderColor:k.Green,borderWidth:1.2,tension:.5,fill:this.config.mm1!==!0&&this.config.mm2!==!0,yAxisID:"attr2",unit:K}),this.config.mm2&&(G.push({label:`${U} min`,data:P.min2,pointStyle:!1,backgroundColor:k.Green+"22",borderColor:k.Green,borderWidth:1.2,borderDash:[2,2],tension:.5,fill:"+1",yAxisID:"attr2",unit:K}),G.push({label:`${U} max`,data:P.max2,pointStyle:!1,borderColor:k.Green,backgroundColor:k.Green+"22",borderWidth:1.2,borderDash:[2,2],tension:.5,fill:!1,yAxisID:"attr2",unit:K})),h.options.scales.attr2={position:"right",display:!0,title:{display:!0,text:`${U} ${K}`,color:k.Green},ticks:{color:k.TextColorDarker,precision:0},grid:{drawOnChartArea:!1}},this.attr2Min=u[this.config.attr2].min,this.attr2Max=u[this.config.attr2].max,this.yScale==="fixed"&&(this.attr2Min!==void 0&&(h.options.scales.attr2.suggestedMin=this.attr2Min),this.attr2Max!==void 0&&(h.options.scales.attr2.suggestedMax=this.attr2Max))}h.data={datasets:G},this.chart!==void 0&&this.chart.destroy(),this.chart=new Chart(this.renderRoot.querySelector("canvas"),h),this.chart.precision=this.config.precision,re.updateChartType(this.chart),setTimeout(()=>this.classList.remove("empty","spinner"),200)}async changePrecision(h){this.chart.crosshair.resetZoom(),this.config.precision=h.detail,await this.refresh()}async refresh(){await this.initChart()}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.yScale=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())}},zn=class extends Ct{static properties={config:{type:Object,reflect:!0},devices:{type:Object,state:!0},supportedAttributes:{type:Object,state:!0},attributes:{type:Object,state:!0}};constructor(){super(),this.config={},this.devices=void 0,this.supportedAttributes=void 0,this.attributes=void 0}render(){return at`
${this.devices&&this.supportedAttributes?this.renderDevicesSelect():at``} ${this.attributes?this.renderAttributesSelect():""}
${this.config.attr1!==void 0&&this.attributes.length>1?this.renderOptionalAttributesSelect():""} `}async connectedCallback(){if(super.connectedCallback(),await Nt.fetchMonitoredDevices().then(u=>{this.devices=u}),await Nt.fetchSupportedAttributes().then(u=>{this.supportedAttributes=u}),this.config.dev===void 0)return;let h=this.devices.find(u=>u.id==this.config.dev);this.attributes=h.attrs.sort()}createRenderRoot(){return this}renderDevicesSelect(){return at`
`}renderAttributesSelect(){return at`
${this.config.attr1?at`
${this.supportedAttributes[this.config.attr1].minMax==!0?at`
this.config.mm1=h.target.checked} >
`:""}
this.config.z1=h.target.checked} >
`:""}
`}renderOptionalAttributesSelect(){return at`
${this.config.attr2?at`
${this.supportedAttributes[this.config.attr2].minMax==!0?at`
this.config.mm2=h.target.checked} >
`:""}
this.config.z2=h.target.checked} >
`:""}
`}onDeviceSelect(h){let u=h.target.value!==""?h.target.value:void 0;if(u==this.config.dev)return;if(this.config={...this.config,dev:u,attr1:void 0,attr2:void 0,mm1:!1,mm2:!1,z1:!1,z2:!1},this.config.dev===void 0){this.attributes=void 0;return}let k=this.devices.find(P=>P.id==u);this.attributes=k.attrs.sort(),this.dispatchEvent(new CustomEvent("suggestTitle",{detail:k.name})),setTimeout(()=>{let P=this.renderRoot.querySelector("#attr1");P.scrollIntoView({behavior:"smooth",block:"center"}),P.focus({preventScroll:!0})},0)}onAttribute1Select(h){let u=h.target.value!==""?h.target.value:void 0;u!=this.config.attr1&&(this.config={...this.config,attr1:u,mm1:!1,z1:!1},setTimeout(()=>{let k=this.renderRoot.querySelector("#attr1");k.scrollIntoView({behavior:"smooth",block:"center"}),k.focus({preventScroll:!0})},0))}onAttribute2Select(h){let u=h.target.value!==""?h.target.value:void 0;u!=this.config.attr2&&(this.config={...this.config,attr2:u,mm2:!1,z2:!1},setTimeout(()=>{let k=this.renderRoot.querySelector("#attr2");k.scrollIntoView({behavior:"smooth",block:"center"}),k.focus({preventScroll:!0})},0))}decorateConfig(h){return{...h,dev:parseInt(this.config.dev),precision:"5m",attr1:this.config.attr1,attr2:this.config.attr2,mm1:this.config.mm1===!0?!0:void 0,mm2:this.config.mm2===!0?!0:void 0,z1:this.config.z1===!0?!0:void 0,z2:this.config.z2===!0?!0:void 0}}};var $n=class extends Ct{static styles=Ft` :host { display: block; width: 100%; height: 100%; } canvas { width: 100%; height: 100%; touch-action: pan-y; } :host(.empty) canvas { visibility: hidden } precision-selector { position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 0); visibility: hidden; } :host(:hover) precision-selector, :host(:hover) nav { visibility: visible; } aside { position: absolute; top: 50%; left: 0; transform: translate(0, -50%); display: block; color: var(--text-color-darker); width: 100%; text-align: center; } .reset-zoom { position: absolute; top: 0px; right: 0px; border: none; background-color: var(--Blue); color: var(--Base3); border-radius: 0 0 0 5px; padding: 5px 10px; line-height: 1rem; z-index: 100; cursor: pointer; letter-spacing: 1px; } aside { position: absolute; top: 0; right: 0; } nav { position: absolute; top: 0px; left: 2px; cursor: pointer; visibility: hidden; } `;static properties={config:{type:Object,reflect:!0},yScale:{type:String,reflect:!0},mobileView:{type:Boolean,state:!0},chart:{type:Object,state:!0},nodata:{type:Boolean,state:!0}};render(){return at` ${this.nodata===!0?at``:""} `}updated(h){h.mobileView!=this.mobileView}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m")}async firstUpdated(){await this.initChart()}onKeyDown(h){this.chart!==void 0&&(h.keyCode===37?this.chart.crosshair.panZoom("left"):h.keyCode===39&&this.chart.crosshair.panZoom("right"))}async initChart(){this.classList.add("spinner");let h=await Nt.fetchSupportedAttributes(),u=await Nt.fetchMonitoredDevices(),k=Te.colors(),P=await Nt.fetchAttributeData(this.config),z=re.lineConfig(),L=[];for(let U of this.config.devs)L.push({label:u.find(K=>K.id==U).name,data:P[`dev_${U}`],pointStyle:!1,borderWidth:1.2,tension:.5,unit:h[this.config.attr].unit,ref:`dev_${U}`});if(this.config.devs.length<=2)for(let U=0;Uthis.classList.remove("empty","spinner"),200)}async changePrecision(h){this.chart.crosshair.resetZoom(),this.config.precision=h.detail,this.config.precision=h.detail,await this.refresh()}async refresh(){await this.initChart()}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return{...h,...this.config}}setYScale(h){this.yScale=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())}},Hn=class extends Ct{static properties={config:{type:Object,reflect:!0},devices:{type:Object,state:!0},attributes:{type:Object,state:!0}};constructor(){super(),this.config={devs:[]},this.devices=void 0,this.attributes=void 0}render(){return at`
${this.attributes?this.renderAttributesSelect():at``}
${this.config.attr&&this.devices?this.renderDevicesSelect():""} `}async connectedCallback(){super.connectedCallback(),this.devices=await Nt.fetchMonitoredDevices();let h=new Set;this.devices.forEach(u=>u.attrs.forEach(k=>h.add(k))),this.attributes=[...h].sort()}createRenderRoot(){return this}renderAttributesSelect(){return at`
${this.config.attr?at`
this.config.z=h.target.checked} >
`:""}
`}renderDevicesSelect(){let h=this.devices.filter(u=>u.attrs.includes(this.config.attr));return at`
${h.map(u=>at`
`)}
`}onAttributeSelect(h){let u=h.target.value!==""?h.target.value:void 0;this.config={...this.config,attr:u,z:!1,devs:[]},u&&this.dispatchEvent(new CustomEvent("suggestTitle",{detail:re.prettyName(u)}))}onDeviceSelect(){this.config={...this.config,devs:[...this.renderRoot.querySelectorAll('#devlist input[type="checkbox"]:checked')].map(h=>h.value)}}decorateConfig(h){return{...h,attr:this.config.attr,devs:this.config.devs.map(u=>parseInt(u)),z:this.config.z===!0?!0:void 0}}};var Nn=class extends Ct{static styles=Ft` :host { display: block; width: 100%; height: 100%; } canvas { width: 100%; height: 100%; touch-action: pan-y; } :host(.empty) canvas { visibility: hidden } precision-selector { position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 0); visibility: hidden; } :host(:hover) precision-selector, :host(:hover) nav { visibility: visible; } aside { position: absolute; top: 50%; left: 0; transform: translate(0, -50%); display: block; color: var(--text-color-darker); width: 100%; text-align: center; } .reset-zoom { position: absolute; top: 0px; right: 0px; border: none; background-color: var(--Blue); color: var(--Base3); border-radius: 0 0 0 5px; padding: 5px 10px; line-height: 1rem; z-index: 100; cursor: pointer; letter-spacing: 1px; } nav { position: absolute; top: 0px; left: 2px; cursor: pointer; visibility: hidden; } `;static properties={config:{type:Object,reflect:!0},mobileView:{type:Boolean,state:!0},chart:{type:Object,state:!0},nodata:{type:Boolean,state:!0}};render(){return at` ${this.nodata===!0?at``:""} `}updated(h){h.mobileView!=this.mobileView}async connectedCallback(){super.connectedCallback(),this.config.precision===void 0&&(this.config.precision="5m")}async firstUpdated(){await this.initChart()}onKeyDown(h){this.chart!==void 0&&(h.keyCode===37?this.chart.crosshair.panZoom("left"):h.keyCode===39&&this.chart.crosshair.panZoom("right"))}async initChart(){this.classList.add("spinner");let h=await Nt.fetchSupportedAttributes(),u=await Nt.fetchMonitoredDevices(),k=Te.colors(),P=await Nt.fetchStatusmapData(this.config);if(this.nodata=Object.entries(P).find(ut=>ut[1]?.length>0)===void 0,this.nodata){this.chart!==void 0&&this.chart.destroy(),setTimeout(()=>this.classList.remove("empty","spinner"),200);return}let z=re.statusmapConfig(),L=[],G=[],U=1/0,K=0;this.config.ds.forEach(({dev:ut,attr:X})=>{let it=u.find(kt=>kt.id==ut).name,ft=h[X].unit,bt=re.prettyName(X),Tt=`${it}: ${bt}`;L.push(Tt);let Dt=P[`${ut}_${X}`].map(kt=>({...kt,y:Tt}));G.push({label:bt,unit:ft,backgroundColor:kt=>`rgba(133, 153, 0, ${Math.round(Math.min(100,Math.max(0,kt.raw?.v||0))*9)/1e3+.1})`,borderColor:k.Green,data:[...Dt]}),U=Math.min(U,Dt[0].x[0]),K=Math.max(K,Dt.pop().x[1])}),z.data={labels:L,datasets:G},z.options.scales.x.min=U,z.options.scales.x.max=K,this.chart!==void 0&&this.chart.destroy(),this.chart=new Chart(this.renderRoot.querySelector("canvas"),z),this.chart.precision=this.config.precision,setTimeout(()=>this.classList.remove("empty","spinner"),200)}async changePrecision(h){this.chart?.crosshair.resetZoom(),this.config.precision=h.detail,await this.refresh()}async refresh(){await this.initChart()}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return{...h,...this.config}}},In=class extends Ct{static properties={config:{type:Object,reflect:!0},devices:{type:Object,state:!0},supportedAttributes:{type:Object,state:!0},attributes:{type:Object,state:!0},dev:{type:Number,state:!0},add:{type:Boolean,state:!0}};constructor(){super(),this.config={ds:[]},this.devices=void 0,this.supportedAttributes=void 0,this.attributes=void 0,this.dev=void 0,this.add=!0}render(){return at` ${this.devices&&this.config.ds?.length?this.renderDatasets():""}
${this.add?at` ${this.devices&&this.supportedAttributes?this.renderDevicesSelect():at``} ${this.attributes?this.renderAttributesSelect():""} `:at` `}
`}async connectedCallback(){super.connectedCallback(),this.devices=await Nt.fetchMonitoredDevices(),this.supportedAttributes=await Nt.fetchSupportedAttributes(),this.config.ds===void 0&&(this.config={...this.config,ds:[]}),this.add=!this.config.ds.length}createRenderRoot(){return this}renderDatasets(){return this.config.ds.map((h,u)=>at`
${this.devices.find(k=>k.id==h.dev).name}: ${h.attr}
`)}renderDevicesSelect(){return at`
`}renderAttributesSelect(){return at`
`}addAnother(){this.add=!0,setTimeout(()=>{let h=this.renderRoot.querySelector("#dev");h.scrollIntoView({behavior:"smooth",block:"center"}),h.focus({preventScroll:!0})},0)}selectable(h){return!this.supportedAttributes[h].unit.startsWith("% ")}moveUp(h){let u=this.config.ds,k=u[h-1];u[h-1]=u[h],u[h]=k,this.config={...this.config,ds:u}}moveDown(h){let u=this.config.ds,k=u[h+1];u[h+1]=u[h],u[h]=k,this.config={...this.config,ds:u}}remove(h){this.config={...this.config,ds:this.config.ds.filter((u,k)=>k!==h)},this.config.ds?.length||this.addAnother()}onDeviceSelect(h){if(this.dev=h.target.value!==""?h.target.value:void 0,this.dev===void 0){this.attributes=void 0;return}let u=this.devices.find(k=>k.id==this.dev);this.attributes=u.attrs.sort(),setTimeout(()=>{let k=this.renderRoot.querySelector("#attr");k.scrollIntoView({behavior:"smooth",block:"center"}),k.focus({preventScroll:!0})},0)}onAttributeSelect(h){let u=h.target.value!==""?h.target.value:void 0;if(u===void 0)return;let k=this.config.ds||[];this.config={...this.config,ds:this.config.ds.concat({dev:parseInt(this.dev),attr:u})},this.dev=void 0,this.attributes=void 0,this.add=!1}decorateConfig(h){return{...h,precision:"5m",ds:this.config.ds}}};var Bn=class extends Ct{static styles=Ft` :host { display: block; width: 100%; height: 100%; } article { position: absolute; top: 50%; left: 50%; width: calc(100% - 2em); transform: translate(-50%, -50%); max-height: 100%; overflow-y: auto; scrollbar-width: thin; scrollbar-color: transparent transparent; } article:hover { scrollbar-color: initial; } article a { color: var(--Blue) } nav { position: absolute; top: 0px; left: 2px; cursor: pointer; visibility: hidden; } :host(:hover) nav { visibility: visible; } `;static properties={config:{type:Object,reflect:!0}};render(){return at`
${En(this.config.message)}
`}firstUpdated(){this.classList.remove("spinner")}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return h}refresh(){}},Fn=class extends Ct{static properties={config:{type:Object,reflect:!0}};constructor(){super(),this.config={message:""}}render(){return at`
this.config={message:h.target.value}} />
`}connectedCallback(){super.connectedCallback(),this.config?.message===void 0&&(this.config={...this.config,message:""})}createRenderRoot(){return this}firstUpdated(){setTimeout(()=>this.renderRoot.querySelector("#message").focus(),0)}decorateConfig(h){return{...h,message:this.config.message}}};var Un=class extends Ct{static styles=Ft` iframe { background-color: transparent; position: absolute; top: 0; left: 0; width: 100%; height: 100%; scrollbar-width: thin; scrollbar-color: transparent transparent; } iframe:hover { scrollbar-color: initial; } nav { position: absolute; top: 0px; left: 2px; cursor: pointer; visibility: hidden; } :host(:hover) nav { visibility: visible; } `;static properties={config:{type:Object,reflect:!0}};render(){return at` `}firstUpdated(){this.classList.remove("spinner")}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}decorateConfig(h){return h}refresh(){this.config.noRefresh!==!0&&(this.renderRoot.querySelector("iframe").src+="")}},Wn=class extends Ct{static properties={config:{type:Object,reflect:!0}};constructor(){super(),this.config={url:"",noBorder:!1,noRefresh:!0}}render(){return at`
this.config={...this.config,url:h.target.value}} />
this.config={...this.config,noBorder:h.target.checked}} >
this.config={...this.config,noRefresh:h.target.checked}} >
`}connectedCallback(){super.connectedCallback(),this.config?.url===void 0&&(this.config={...this.config,url:""})}createRenderRoot(){return this}firstUpdated(){setTimeout(()=>this.renderRoot.querySelector("#url").focus(),0)}decorateConfig(h){return{...h,url:this.config.url,noBorder:this.config.noBorder===!0?!0:void 0,noRefresh:this.config.noRefresh===!0?!0:void 0}}};var pl={a:{label:"Name",render:(_,h)=>at`${h.name}${h.alerts.runAlertsCounter-(h.alerts.platformUpdateAvailable?1:0)===0?"":at` 🚩`}`},b:{label:"Model",render:(_,h)=>at`${_.model}`},c:{label:"IP",render:(_,h)=>at`${h.ipAddress}`},d:{label:"Fw Ver",render:(_,h)=>at`${h.version}${h.alerts.platformUpdateAvailable===!1?"":at` 🚩`}`},e:{label:"CPU",render:(_,h)=>at`${_.cpu}`},f:{label:"RAM",render:(_,h)=>at`${_.ram}`},g:{label:"Temp",render:(_,h)=>at`${_.temp}`},h:{label:"DB Size",render:(_,h)=>at`${_.db}`},i:{label:"Reboot",render:(_,h)=>at`${_.reboot}`}},Vn=class extends Ct{static styles=Ft` :host { display: block; width: 100%; height: 100%; } table { width: 100%; height: 100%; border-collapse: collapse; color: var(--text-color-darker); table-layout: fixed; } table tr:first-child td { height: 20px; padding: 0; border: 0; } table td { border-top: 1px color-mix(in srgb, var(--text-color-darker), transparent 80%) solid; padding: 0 0.5em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } table tr td:first-child { text-align: right; font-weight: bold; } a { text-decoration: none; color: red; line-height: 1em; } nav { position: absolute; top: 0px; left: 2px; cursor: pointer; visibility: hidden; } :host(:hover) nav { visibility: visible; } `;static properties={config:{type:Object,reflect:!0},hubInfo:{type:Object,state:!0},hubData:{type:Object,state:!0},mobileView:{type:Boolean,state:!0}};render(){return this.hubInfo===void 0||this.hubData===void 0?"":at` ${Object.entries(pl).map(([h,u])=>this.config?.info?.includes(h)?at``:"")}
${u.label}${u.render(this.hubInfo,this.hubData)}
`}async connectedCallback(){super.connectedCallback(),this.refresh()}editPanel(){this.dispatchEvent(new CustomEvent("edit",{bubbles:!0,detail:this.config}))}async refresh(){this.hubInfo=await Nt.fetchHubInfo(),this.hubData=await Nt.fetchHubData();let h=new Chart._adapters._date({timeZone:"UTC"}),u=h.add(new Date,-this.hubInfo.uptime,"second");this.hubInfo.reboot=h.format(u,"Pp").replace(",",""),setTimeout(()=>this.classList.remove("empty","spinner"),100)}decorateConfig(h){return h}},jn=class extends Ct{static properties={config:{type:Object,reflect:!0}};constructor(){super(),this.config={info:[]}}render(){return at`
${Object.entries(pl).map(([h,u])=>at`
`)}
`}connectedCallback(){super.connectedCallback(),typeof this.config?.info=="string"&&(this.config={...this.config,info:this.config.info.split("")}),this.config?.info===void 0&&(this.config={...this.config,info:[]})}createRenderRoot(){return this}firstUpdated(){setTimeout(()=>this.dispatchEvent(new CustomEvent("suggestTitle",{detail:"Hub Information"})),200)}onFieldSelect(h){h.target.checked?this.config={info:this.config.info.concat([h.target.value])}:this.config={info:this.config.info.filter(u=>u!==h.target.value)}}decorateConfig(h){return{...h,info:this.config.info.join("")}}};customElements.define("watchtower-app",Tn);customElements.define("dashboard-menu",Dn);customElements.define("dashboard-add-dialog",An);customElements.define("dashboard-grid",Pn);customElements.define("precision-selector",Rn);customElements.define("device-panel",Ln);customElements.define("device-panel-config",zn);customElements.define("attribute-panel",$n);customElements.define("attribute-panel-config",Hn);customElements.define("statusmap-panel",Nn);customElements.define("statusmap-panel-config",In);customElements.define("text-panel",Bn);customElements.define("text-panel-config",Fn);customElements.define("iframe-panel",Un);customElements.define("iframe-panel-config",Wn);customElements.define("hub-info-panel",Vn);customElements.define("hub-info-panel-config",jn);})();