diff --git a/main.js b/main.js index 2793701..9f952eb 100644 --- a/main.js +++ b/main.js @@ -1,17 +1,17 @@ -"use strict";var Kl=Object.create;var bs=Object.defineProperty;var Yl=Object.getOwnPropertyDescriptor;var Gl=Object.getOwnPropertyNames;var ql=Object.getPrototypeOf,Xl=Object.prototype.hasOwnProperty;var Ql=(s,t,e)=>t in s?bs(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var si=(s,t)=>()=>(s&&(t=s(s=0)),t);var Zl=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Eo=(s,t)=>{for(var e in t)bs(s,e,{get:t[e],enumerable:!0})},wo=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gl(t))!Xl.call(s,i)&&i!==e&&bs(s,i,{get:()=>t[i],enumerable:!(n=Yl(t,i))||n.enumerable});return s};var Xs=(s,t,e)=>(e=s!=null?Kl(ql(s)):{},wo(t||!s||!s.__esModule?bs(e,"default",{value:s,enumerable:!0}):e,s)),Jl=s=>wo(bs({},"__esModule",{value:!0}),s);var W=(s,t,e)=>(Ql(s,typeof t!="symbol"?t+"":t,e),e);var vs=Zl((ni,ii)=>{((s,t)=>{typeof define=="function"&&define.amd?define([],t):typeof ii=="object"&&typeof ni!="undefined"?ii.exports=t():s.Papa=t()})(ni,function s(){var t=typeof self!="undefined"?self:typeof window!="undefined"?window:t!==void 0?t:{},e,n=!t.document&&!!t.postMessage,i=t.IS_PAPA_WORKER||!1,o={},r=0,a={};function l(v){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(y){var C=_(y);C.chunkSize=parseInt(C.chunkSize),y.step||y.chunk||(C.chunkSize=null),this._handle=new f(C),(this._handle.streamer=this)._config=C}.call(this,v),this.parseChunk=function(y,C){var D=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),i)t.postMessage({results:M,workerId:a.WORKER_ID,finished:D});else if(S(this._config.chunk)&&!C){if(this._config.chunk(M,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=M=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(M.data),this._completeResults.errors=this._completeResults.errors.concat(M.errors),this._completeResults.meta=M.meta),this._completed||!D||!S(this._config.complete)||M&&M.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),D||M&&M.meta.paused||this._nextChunk(),M}this._halted=!0},this._sendError=function(y){S(this._config.error)?this._config.error(y):i&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:y,finished:!1})}}function c(v){var y;(v=v||{}).chunkSize||(v.chunkSize=a.RemoteChunkSize),l.call(this,v),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(C){this._input=C,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(y=new XMLHttpRequest,this._config.withCredentials&&(y.withCredentials=this._config.withCredentials),n||(y.onload=E(this._chunkLoaded,this),y.onerror=E(this._chunkError,this)),y.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var C,D=this._config.downloadRequestHeaders;for(C in D)y.setRequestHeader(C,D[C])}var M;this._config.chunkSize&&(M=this._start+this._config.chunkSize-1,y.setRequestHeader("Range","bytes="+this._start+"-"+M));try{y.send(this._config.downloadRequestBody)}catch(w){this._chunkError(w.message)}n&&y.status===0&&this._chunkError()}},this._chunkLoaded=function(){y.readyState===4&&(y.status<200||400<=y.status?this._chunkError():(this._start+=this._config.chunkSize||y.responseText.length,this._finished=!this._config.chunkSize||this._start>=(C=>(C=C.getResponseHeader("Content-Range"))!==null?parseInt(C.substring(C.lastIndexOf("/")+1)):-1)(y),this.parseChunk(y.responseText)))},this._chunkError=function(C){C=y.statusText||C,this._sendError(new Error(C))}}function d(v){(v=v||{}).chunkSize||(v.chunkSize=a.LocalChunkSize),l.call(this,v);var y,C,D=typeof FileReader!="undefined";this.stream=function(M){this._input=M,C=M.slice||M.webkitSlice||M.mozSlice,D?((y=new FileReader).onload=E(this._chunkLoaded,this),y.onerror=E(this._chunkError,this)):y=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(M.target.result)},this._chunkError=function(){this._sendError(y.error)}}function h(v){var y;l.call(this,v=v||{}),this.stream=function(C){return y=C,this._nextChunk()},this._nextChunk=function(){var C,D;if(!this._finished)return C=this._config.chunkSize,y=C?(D=y.substring(0,C),y.substring(C)):(D=y,""),this._finished=!y,this.parseChunk(D)}}function u(v){l.call(this,v=v||{});var y=[],C=!0,D=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(M){this._input=M,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){D&&y.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),y.length?this.parseChunk(y.shift()):C=!0},this._streamData=E(function(M){try{y.push(typeof M=="string"?M:M.toString(this._config.encoding)),C&&(C=!1,this._checkIsFinished(),this.parseChunk(y.shift()))}catch(w){this._streamError(w)}},this),this._streamError=E(function(M){this._streamCleanUp(),this._sendError(M)},this),this._streamEnd=E(function(){this._streamCleanUp(),D=!0,this._streamData("")},this),this._streamCleanUp=E(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function f(v){var y,C,D,M,w=Math.pow(2,53),L=-w,k=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,A=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,P=this,I=0,z=0,R=!1,V=!1,T=[],O={data:[],errors:[],meta:{}};function j(N){return v.skipEmptyLines==="greedy"?N.join("").trim()==="":N.length===1&&N[0].length===0}function U(){if(O&&D&&($("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),D=!1),v.skipEmptyLines&&(O.data=O.data.filter(function(G){return!j(G)})),K()){let G=function(Y,Z){S(v.transformHeader)&&(Y=v.transformHeader(Y,Z)),T.push(Y)};var F=G;if(O)if(Array.isArray(O.data[0])){for(var N=0;K()&&N(at=>(v.dynamicTypingFunction&&v.dynamicTyping[at]===void 0&&(v.dynamicTyping[at]=v.dynamicTypingFunction(at)),(v.dynamicTyping[at]||v.dynamicTyping)===!0))(J)?st==="true"||st==="TRUE"||st!=="false"&&st!=="FALSE"&&((at=>{if(k.test(at)&&(at=parseFloat(at),L=T.length?"__parsed_extra":T[X]:q,ut=v.transform?v.transform(ut,q):ut);q==="__parsed_extra"?(Z[q]=Z[q]||[],Z[q].push(ut)):Z[q]=ut}return v.header&&(X>T.length?$("FieldMismatch","TooManyFields","Too many fields: expected "+T.length+" fields but parsed "+X,z+Y):Xv.preview?C.abort():(O.data=O.data[0],M(O,P))))}),this.parse=function(N,B,H){var F=v.quoteChar||'"',F=(v.newline||(v.newline=this.guessLineEndings(N,F)),D=!1,v.delimiter?S(v.delimiter)&&(v.delimiter=v.delimiter(N),O.meta.delimiter=v.delimiter):((F=((G,Y,Z,X,q)=>{var ut,J,st,at;q=q||[","," ","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var Rt=0;Rt=H.length/2?`\r -`:"\r"}}function p(v){return v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(v){var y=(v=v||{}).delimiter,C=v.newline,D=v.comments,M=v.step,w=v.preview,L=v.fastMode,k=null,A=!1,P=v.quoteChar==null?'"':v.quoteChar,I=P;if(v.escapeChar!==void 0&&(I=v.escapeChar),(typeof y!="string"||-1t in s?bs(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var si=(s,t)=>()=>(s&&(t=s(s=0)),t);var Zl=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Eo=(s,t)=>{for(var e in t)bs(s,e,{get:t[e],enumerable:!0})},wo=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gl(t))!Xl.call(s,i)&&i!==e&&bs(s,i,{get:()=>t[i],enumerable:!(n=Yl(t,i))||n.enumerable});return s};var Xs=(s,t,e)=>(e=s!=null?Kl(ql(s)):{},wo(t||!s||!s.__esModule?bs(e,"default",{value:s,enumerable:!0}):e,s)),Jl=s=>wo(bs({},"__esModule",{value:!0}),s);var $=(s,t,e)=>(Ql(s,typeof t!="symbol"?t+"":t,e),e);var vs=Zl((ni,ii)=>{((s,t)=>{typeof define=="function"&&define.amd?define([],t):typeof ii=="object"&&typeof ni!="undefined"?ii.exports=t():s.Papa=t()})(ni,function s(){var t=typeof self!="undefined"?self:typeof window!="undefined"?window:t!==void 0?t:{},e,n=!t.document&&!!t.postMessage,i=t.IS_PAPA_WORKER||!1,o={},r=0,a={};function l(y){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(v){var C=_(v);C.chunkSize=parseInt(C.chunkSize),v.step||v.chunk||(C.chunkSize=null),this._handle=new f(C),(this._handle.streamer=this)._config=C}.call(this,y),this.parseChunk=function(v,C){var M=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),i)t.postMessage({results:D,workerId:a.WORKER_ID,finished:M});else if(S(this._config.chunk)&&!C){if(this._config.chunk(D,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=D=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(D.data),this._completeResults.errors=this._completeResults.errors.concat(D.errors),this._completeResults.meta=D.meta),this._completed||!M||!S(this._config.complete)||D&&D.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),M||D&&D.meta.paused||this._nextChunk(),D}this._halted=!0},this._sendError=function(v){S(this._config.error)?this._config.error(v):i&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:v,finished:!1})}}function c(y){var v;(y=y||{}).chunkSize||(y.chunkSize=a.RemoteChunkSize),l.call(this,y),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(C){this._input=C,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(v=new XMLHttpRequest,this._config.withCredentials&&(v.withCredentials=this._config.withCredentials),n||(v.onload=w(this._chunkLoaded,this),v.onerror=w(this._chunkError,this)),v.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var C,M=this._config.downloadRequestHeaders;for(C in M)v.setRequestHeader(C,M[C])}var D;this._config.chunkSize&&(D=this._start+this._config.chunkSize-1,v.setRequestHeader("Range","bytes="+this._start+"-"+D));try{v.send(this._config.downloadRequestBody)}catch(E){this._chunkError(E.message)}n&&v.status===0&&this._chunkError()}},this._chunkLoaded=function(){v.readyState===4&&(v.status<200||400<=v.status?this._chunkError():(this._start+=this._config.chunkSize||v.responseText.length,this._finished=!this._config.chunkSize||this._start>=(C=>(C=C.getResponseHeader("Content-Range"))!==null?parseInt(C.substring(C.lastIndexOf("/")+1)):-1)(v),this.parseChunk(v.responseText)))},this._chunkError=function(C){C=v.statusText||C,this._sendError(new Error(C))}}function d(y){(y=y||{}).chunkSize||(y.chunkSize=a.LocalChunkSize),l.call(this,y);var v,C,M=typeof FileReader!="undefined";this.stream=function(D){this._input=D,C=D.slice||D.webkitSlice||D.mozSlice,M?((v=new FileReader).onload=w(this._chunkLoaded,this),v.onerror=w(this._chunkError,this)):v=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(D.target.result)},this._chunkError=function(){this._sendError(v.error)}}function h(y){var v;l.call(this,y=y||{}),this.stream=function(C){return v=C,this._nextChunk()},this._nextChunk=function(){var C,M;if(!this._finished)return C=this._config.chunkSize,v=C?(M=v.substring(0,C),v.substring(C)):(M=v,""),this._finished=!v,this.parseChunk(M)}}function u(y){l.call(this,y=y||{});var v=[],C=!0,M=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(D){this._input=D,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){M&&v.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),v.length?this.parseChunk(v.shift()):C=!0},this._streamData=w(function(D){try{v.push(typeof D=="string"?D:D.toString(this._config.encoding)),C&&(C=!1,this._checkIsFinished(),this.parseChunk(v.shift()))}catch(E){this._streamError(E)}},this),this._streamError=w(function(D){this._streamCleanUp(),this._sendError(D)},this),this._streamEnd=w(function(){this._streamCleanUp(),M=!0,this._streamData("")},this),this._streamCleanUp=w(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function f(y){var v,C,M,D,E=Math.pow(2,53),L=-E,k=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,A=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,P=this,I=0,z=0,F=!1,N=!1,H=[],T={data:[],errors:[],meta:{}};function j(V){return y.skipEmptyLines==="greedy"?V.join("").trim()==="":V.length===1&&V[0].length===0}function U(){if(T&&M&&(O("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),M=!1),y.skipEmptyLines&&(T.data=T.data.filter(function(K){return!j(K)})),G()){let K=function(Y,q){S(y.transformHeader)&&(Y=y.transformHeader(Y,q)),H.push(Y)};var B=K;if(T)if(Array.isArray(T.data[0])){for(var V=0;G()&&V(at=>(y.dynamicTypingFunction&&y.dynamicTyping[at]===void 0&&(y.dynamicTyping[at]=y.dynamicTypingFunction(at)),(y.dynamicTyping[at]||y.dynamicTyping)===!0))(J)?st==="true"||st==="TRUE"||st!=="false"&&st!=="FALSE"&&((at=>{if(k.test(at)&&(at=parseFloat(at),L=H.length?"__parsed_extra":H[Q]:X,ut=y.transform?y.transform(ut,X):ut);X==="__parsed_extra"?(q[X]=q[X]||[],q[X].push(ut)):q[X]=ut}return y.header&&(Q>H.length?O("FieldMismatch","TooManyFields","Too many fields: expected "+H.length+" fields but parsed "+Q,z+Y):Qy.preview?C.abort():(T.data=T.data[0],D(T,P))))}),this.parse=function(V,W,R){var B=y.quoteChar||'"',B=(y.newline||(y.newline=this.guessLineEndings(V,B)),M=!1,y.delimiter?S(y.delimiter)&&(y.delimiter=y.delimiter(V),T.meta.delimiter=y.delimiter):((B=((K,Y,q,Q,X)=>{var ut,J,st,at;X=X||[","," ","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var Rt=0;Rt=R.length/2?`\r +`:"\r"}}function p(y){return y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(y){var v=(y=y||{}).delimiter,C=y.newline,M=y.comments,D=y.step,E=y.preview,L=y.fastMode,k=null,A=!1,P=y.quoteChar==null?'"':y.quoteChar,I=P;if(y.escapeChar!==void 0&&(I=y.escapeChar),(typeof v!="string"||-1=w)return ft(!0);break}H.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:B.length,index:z}),J++}}else if(D&&F.length===0&&V.substring(z,z+$)===D){if(q===-1)return ft();z=q+K,q=V.indexOf(C,z),X=V.indexOf(y,z)}else if(X!==-1&&(X=w)return ft(!0)}return ot();function at(yt){B.push(yt),G=z}function Rt(yt){var wt=0;return wt=yt!==-1&&(yt=V.substring(J+1,yt))&&yt.trim()===""?yt.length:wt}function ot(yt){return O||(yt===void 0&&(yt=V.substring(z)),F.push(yt),z=j,at(F),N&&Kt()),ft()}function gt(yt){z=yt,at(F),F=[],q=V.indexOf(C,z)}function ft(yt){if(v.header&&!T&&B.length&&!A){var wt=B[0],ne=Object.create(null),ei=new Set(wt);let Co=!1;for(let $e=0;$eD.charCodeAt(0)!==65279?D:D.slice(1))(v),C=new(y.download?c:h)(y)):v.readable===!0&&S(v.read)&&S(v.on)?C=new u(y):(t.File&&v instanceof File||v instanceof Object)&&(C=new d(y)),C.stream(v);(C=(()=>{var D;return!!a.WORKERS_SUPPORTED&&(D=(()=>{var M=t.URL||t.webkitURL||null,w=s.toString();return a.BLOB_URL||(a.BLOB_URL=M.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",w,")();"],{type:"text/javascript"})))})(),(D=new t.Worker(D)).onmessage=m,D.id=r++,o[D.id]=D)})()).userStep=y.step,C.userChunk=y.chunk,C.userComplete=y.complete,C.userError=y.error,y.step=S(y.step),y.chunk=S(y.chunk),y.complete=S(y.complete),y.error=S(y.error),delete y.worker,C.postMessage({input:v,config:y,workerId:C.id})},a.unparse=function(v,y){var C=!1,D=!0,M=",",w=`\r -`,L='"',k=L+L,A=!1,P=null,I=!1,z=((()=>{if(typeof y=="object"){if(typeof y.delimiter!="string"||a.BAD_DELIMITERS.filter(function(T){return y.delimiter.indexOf(T)!==-1}).length||(M=y.delimiter),typeof y.quotes!="boolean"&&typeof y.quotes!="function"&&!Array.isArray(y.quotes)||(C=y.quotes),typeof y.skipEmptyLines!="boolean"&&typeof y.skipEmptyLines!="string"||(A=y.skipEmptyLines),typeof y.newline=="string"&&(w=y.newline),typeof y.quoteChar=="string"&&(L=y.quoteChar),typeof y.header=="boolean"&&(D=y.header),Array.isArray(y.columns)){if(y.columns.length===0)throw new Error("Option columns is empty");P=y.columns}y.escapeChar!==void 0&&(k=y.escapeChar+L),y.escapeFormulae instanceof RegExp?I=y.escapeFormulae:typeof y.escapeFormulae=="boolean"&&y.escapeFormulae&&(I=/^[=+\-@\t\r].*$/)}})(),new RegExp(p(L),"g"));if(typeof v=="string"&&(v=JSON.parse(v)),Array.isArray(v)){if(!v.length||Array.isArray(v[0]))return R(null,v,A);if(typeof v[0]=="object")return R(P||Object.keys(v[0]),v,A)}else if(typeof v=="object")return typeof v.data=="string"&&(v.data=JSON.parse(v.data)),Array.isArray(v.data)&&(v.fields||(v.fields=v.meta&&v.meta.fields||P),v.fields||(v.fields=Array.isArray(v.data[0])?v.fields:typeof v.data[0]=="object"?Object.keys(v.data[0]):[]),Array.isArray(v.data[0])||typeof v.data[0]=="object"||(v.data=[v.data])),R(v.fields||[],v.data||[],A);throw new Error("Unable to serialize unrecognized input");function R(T,O,j){var U="",K=(typeof T=="string"&&(T=JSON.parse(T)),typeof O=="string"&&(O=JSON.parse(O)),Array.isArray(T)&&0{for(var N=0;N<$.length;N++)if(-1e-n*Math.max(Math.min(r-3,9-r,1),-1);return[i(0),i(8),i(4)]}function Wc(s,t,e){let n=(i,o=(i+s/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[n(5),n(3),n(1)]}function jc(s,t,e){let n=gr(s,1,.5),i;for(t+e>1&&(i=1/(t+e),t*=i,e*=i),i=0;i<3;i++)n[i]*=1-t-e,n[i]+=t;return n}function Uc(s,t,e,n,i){return s===i?(t-e)/n+(t.5?d/(2-o-r):d/(o+r),l=Uc(e,n,i,d,o),l=l*60+.5),[l|0,c||0,a]}function vi(s,t,e,n){return(Array.isArray(t)?s(t[0],t[1],t[2]):s(t,e,n)).map(fe)}function yi(s,t,e){return vi(gr,s,t,e)}function Kc(s,t,e){return vi(jc,s,t,e)}function Yc(s,t,e){return vi(Wc,s,t,e)}function mr(s){return(s%360+360)%360}function Gc(s){let t=$c.exec(s),e=255,n;if(!t)return;t[5]!==n&&(e=t[6]?Ms(+t[5]):fe(+t[5]));let i=mr(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?n=Kc(i,o,r):t[1]==="hsv"?n=Yc(i,o,r):n=yi(i,o,r),{r:n[0],g:n[1],b:n[2],a:e}}function qc(s,t){var e=bi(s);e[0]=mr(e[0]+t),e=yi(e),s.r=e[0],s.g=e[1],s.b=e[2]}function Xc(s){if(!s)return;let t=bi(s),e=t[0],n=hr(t[1]),i=hr(t[2]);return s.a<255?`hsla(${e}, ${n}%, ${i}%, ${ie(s.a)})`:`hsl(${e}, ${n}%, ${i}%)`}function Qc(){let s={},t=Object.keys(fr),e=Object.keys(ur),n,i,o,r,a;for(n=0;n>16&255,o>>8&255,o&255]}return s}function Zc(s){bn||(bn=Qc(),bn.transparent=[0,0,0,0]);let t=bn[s.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}function td(s){let t=Jc.exec(s),e=255,n,i,o;if(t){if(t[7]!==n){let r=+t[7];e=t[8]?Ms(r):ue(r*255,0,255)}return n=+t[1],i=+t[3],o=+t[5],n=255&(t[2]?Ms(n):ue(n,0,255)),i=255&(t[4]?Ms(i):ue(i,0,255)),o=255&(t[6]?Ms(o):ue(o,0,255)),{r:n,g:i,b:o,a:e}}}function ed(s){return s&&(s.a<255?`rgba(${s.r}, ${s.g}, ${s.b}, ${ie(s.a)})`:`rgb(${s.r}, ${s.g}, ${s.b})`)}function sd(s,t,e){let n=qe(ie(s.r)),i=qe(ie(s.g)),o=qe(ie(s.b));return{r:fe(gi(n+e*(qe(ie(t.r))-n))),g:fe(gi(i+e*(qe(ie(t.g))-i))),b:fe(gi(o+e*(qe(ie(t.b))-o))),a:s.a+e*(t.a-s.a)}}function vn(s,t,e){if(s){let n=bi(s);n[t]=Math.max(0,Math.min(n[t]+n[t]*e,t===0?360:1)),n=yi(n),s.r=n[0],s.g=n[1],s.b=n[2]}}function br(s,t){return s&&Object.assign(t||{},s)}function pr(s){var t={r:0,g:0,b:0,a:255};return Array.isArray(s)?s.length>=3&&(t={r:s[0],g:s[1],b:s[2],a:255},s.length>3&&(t.a=fe(s[3]))):(t=br(s,{r:0,g:0,b:0,a:1}),t.a=fe(t.a)),t}function nd(s){return s.charAt(0)==="r"?td(s):Gc(s)}var ue,zt,mi,Ic,Vc,mn,Nc,zc,$c,ur,fr,bn,Jc,gi,qe,Ds,vr=si(()=>{ue=(s,t,e)=>Math.max(Math.min(s,e),t);zt={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},mi=[..."0123456789ABCDEF"],Ic=s=>mi[s&15],Vc=s=>mi[(s&240)>>4]+mi[s&15],mn=s=>(s&240)>>4===(s&15),Nc=s=>mn(s.r)&&mn(s.g)&&mn(s.b)&&mn(s.a);zc=(s,t)=>s<255?t(s):"";$c=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;ur={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},fr={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};Jc=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;gi=s=>s<=.0031308?s*12.92:Math.pow(s,1/2.4)*1.055-.055,qe=s=>s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4);Ds=class s{constructor(t){if(t instanceof s)return t;let e=typeof t,n;e==="object"?n=pr(t):e==="string"&&(n=Bc(t)||Zc(t)||nd(t)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var t=br(this._rgb);return t&&(t.a=ie(t.a)),t}set rgb(t){this._rgb=pr(t)}rgbString(){return this._valid?ed(this._rgb):void 0}hexString(){return this._valid?Hc(this._rgb):void 0}hslString(){return this._valid?Xc(this._rgb):void 0}mix(t,e){if(t){let n=this.rgb,i=t.rgb,o,r=e===o?.5:e,a=2*r-1,l=n.a-i.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,n.r=255&c*n.r+o*i.r+.5,n.g=255&c*n.g+o*i.g+.5,n.b=255&c*n.b+o*i.b+.5,n.a=r*n.a+(1-r)*i.a,this.rgb=n}return this}interpolate(t,e){return t&&(this._rgb=sd(this._rgb,t._rgb,e)),this}clone(){return new s(this.rgb)}alpha(t){return this._rgb.a=fe(t),this}clearer(t){let e=this._rgb;return e.a*=1-t,this}greyscale(){let t=this._rgb,e=Ts(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=e,this}opaquer(t){let e=this._rgb;return e.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 vn(this._rgb,2,t),this}darken(t){return vn(this._rgb,2,-t),this}saturate(t){return vn(this._rgb,1,t),this}desaturate(t){return vn(this._rgb,1,-t),this}rotate(t){return qc(this._rgb,t),this}}});function Qt(){}function tt(s){return s==null}function ct(s){if(Array.isArray&&Array.isArray(s))return!0;let t=Object.prototype.toString.call(s);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function et(s){return s!==null&&Object.prototype.toString.call(s)==="[object Object]"}function pt(s){return(typeof s=="number"||s instanceof Number)&&isFinite(+s)}function Mt(s,t){return pt(s)?s:t}function Q(s,t){return typeof s=="undefined"?t:s}function lt(s,t,e){if(s&&typeof s.call=="function")return s.apply(e,t)}function rt(s,t,e,n){let i,o,r;if(ct(s))if(o=s.length,n)for(i=o-1;i>=0;i--)t.call(e,s[i],i);else for(i=0;i{for(let n of t){if(n==="")break;e=e&&e[n]}return e}}function ae(s,t){return(yr[t]||(yr[t]=ad(t)))(s)}function kn(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Pr(s){return s.type==="mouseup"||s.type==="click"||s.type==="contextmenu"}function es(s,t,e){return Math.abs(s-t)i-o).pop(),t}function dd(s){return typeof s=="symbol"||typeof s=="object"&&s!==null&&!(Symbol.toPrimitive in s||"toString"in s||"valueOf"in s)}function Ae(s){return!dd(s)&&!isNaN(parseFloat(s))&&isFinite(s)}function Or(s,t){let e=Math.round(s);return e-t<=s&&e+t>=s}function ki(s,t,e){let n,i,o;for(n=0,i=s.length;nl&&c=Math.min(t,e)-n&&s<=Math.max(t,e)+n}function Dn(s,t,e){e=e||(r=>s[r]1;)o=i+n>>1,e(o)?i=o:n=o;return{lo:i,hi:n}}function Vr(s,t,e){let n=0,i=s.length;for(;nn&&s[i-1]>e;)i--;return n>0||i{let n="_onData"+kn(e),i=s[e];Object.defineProperty(s,e,{configurable:!0,enumerable:!1,value(...o){let r=i.apply(this,o);return s._chartjs.listeners.forEach(a=>{typeof a[n]=="function"&&a[n](...o)}),r}})})}function Ti(s,t){let e=s._chartjs;if(!e)return;let n=e.listeners,i=n.indexOf(t);i!==-1&&n.splice(i,1),!(n.length>0)&&(Nr.forEach(o=>{delete s[o]}),delete s._chartjs)}function Li(s){let t=new Set(s);return t.size===s.length?s:Array.from(t)}function Pi(s,t){let e=[],n=!1;return function(...i){e=i,n||(n=!0,Ai.call(window,()=>{n=!1,s.apply(t,e)}))}}function zr(s,t){let e;return function(...n){return t?(clearTimeout(e),e=setTimeout(s,t,n)):s.apply(this,n),t}}function Ri(s,t,e){let n=t.length,i=0,o=n;if(s._sorted){let{iScale:r,vScale:a,_parsed:l}=s,c=s.dataset&&s.dataset.options?s.dataset.options.spanGaps:null,d=r.axis,{min:h,max:u,minDefined:f,maxDefined:p}=r.getUserBounds();if(f){if(i=Math.min(qt(l,d,h).lo,e?n:qt(t,d,r.getPixelForValue(h)).lo),c){let g=l.slice(0,i+1).reverse().findIndex(m=>!tt(m[a.axis]));i-=Math.max(0,g)}i=vt(i,0,n-1)}if(p){let g=Math.max(qt(l,r.axis,u,!0).hi+1,e?0:qt(t,d,r.getPixelForValue(u),!0).hi+1);if(c){let m=l.slice(g-1).findIndex(b=>!tt(b[a.axis]));g+=Math.max(0,m)}o=vt(g,i,n)-i}else o=n-i}return{start:i,count:o}}function Oi(s){let{xScale:t,yScale:e,_scaleRanges:n}=s,i={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!n)return s._scaleRanges=i,!0;let o=n.xmin!==t.min||n.xmax!==t.max||n.ymin!==e.min||n.ymax!==e.max;return Object.assign(n,i),o}function Fi(s){if(s&&typeof s=="object"){let t=s.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Ii(s){return Fi(s)?s:new Ds(s)}function xi(s){return Fi(s)?s:new Ds(s).saturate(.5).darken(.1).hexString()}function pd(s){s.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),s.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),s.set("animations",{colors:{type:"color",properties:fd},numbers:{type:"number",properties:ud}}),s.describe("animations",{_fallback:"animation"}),s.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=>t|0}}}})}function gd(s){s.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}function md(s,t){t=t||{};let e=s+JSON.stringify(t),n=Sr.get(e);return n||(n=new Intl.NumberFormat(s,t),Sr.set(e,n)),n}function ns(s,t,e){return md(t,e).format(s)}function bd(s,t){let e=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(e)>=1&&s!==Math.floor(s)&&(e=s-Math.floor(s)),e}function vd(s){s.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:is.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),s.route("scale.ticks","color","","color"),s.route("scale.grid","color","","borderColor"),s.route("scale.border","color","","borderColor"),s.route("scale.title","color","","color"),s.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),s.describe("scales",{_fallback:"scale"}),s.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}function Ls(s,t){if(!t)return s;let e=t.split(".");for(let n=0,i=e.length;nn&&(n=o),n}function Wr(s,t,e,n){n=n||{};let i=n.data=n.data||{},o=n.garbageCollect=n.garbageCollect||[];n.font!==t&&(i=n.data={},o=n.garbageCollect=[],n.font=t),s.save(),s.font=t;let r=0,a=e.length,l,c,d,h,u;for(l=0;le.length){for(l=0;l0&&s.stroke()}}function Xt(s,t,e){return e=e||.5,!t||s&&s.x>t.left-e&&s.xt.top-e&&s.y0&&o.strokeColor!=="",l,c;for(s.save(),s.font=i.string,xd(s,o),l=0;lQ(s[r],s[t[r]]):r=>s[r]:()=>s;for(let r of i)e[r]=kd(o(r));return e}function Bi(s){return Pn(s,{top:"y",right:"x",bottom:"y",left:"x"})}function ye(s){return Pn(s,["topLeft","topRight","bottomLeft","bottomRight"])}function Ct(s){let t=Bi(s);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function bt(s,t){s=s||{},t=t||ht.font;let e=Q(s.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let n=Q(s.style,t.style);n&&!(""+n).match(Ed)&&(console.warn('Invalid font style specified: "'+n+'"'),n=void 0);let i={family:Q(s.family,t.family),lineHeight:wd(Q(s.lineHeight,t.lineHeight),e),size:e,style:n,weight:Q(s.weight,t.weight),string:""};return i.string=yd(i),i}function rs(s,t,e,n){let i=!0,o,r,a;for(o=0,r=s.length;oe&&a===0?0:a+l;return{min:r(n,-Math.abs(o)),max:r(i,o)}}function le(s,t){return Object.assign(Object.create(s),t)}function Rn(s,t=[""],e,n,i=()=>s[0]){let o=e||s;typeof n=="undefined"&&(n=qr("_fallback",s));let r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:s,_rootScopes:o,_fallback:n,_getTarget:i,override:a=>Rn([a,...s],t,o,n)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete s[0][l],!0},get(a,l){return Yr(a,l,()=>Od(l,t,s,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(s[0])},has(a,l){return wr(a).includes(l)},ownKeys(a){return wr(a)},set(a,l,c){let d=a._storage||(a._storage=i());return a[l]=d[l]=c,delete a._keys,!0}})}function Le(s,t,e,n){let i={_cacheable:!1,_proxy:s,_context:t,_subProxy:e,_stack:new Set,_descriptors:zi(s,n),setContext:o=>Le(s,o,e,n),override:o=>Le(s.override(o),t,e,n)};return new Proxy(i,{deleteProperty(o,r){return delete o[r],delete s[r],!0},get(o,r,a){return Yr(o,r,()=>Dd(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(s,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(s,r)},getPrototypeOf(){return Reflect.getPrototypeOf(s)},has(o,r){return Reflect.has(s,r)},ownKeys(){return Reflect.ownKeys(s)},set(o,r,a){return s[r]=a,delete o[r],!0}})}function zi(s,t={scriptable:!0,indexable:!0}){let{_scriptable:e=t.scriptable,_indexable:n=t.indexable,_allKeys:i=t.allKeys}=s;return{allKeys:i,scriptable:e,indexable:n,isScriptable:oe(e)?e:()=>e,isIndexable:oe(n)?n:()=>n}}function Yr(s,t,e){if(Object.prototype.hasOwnProperty.call(s,t)||t==="constructor")return s[t];let n=e();return s[t]=n,n}function Dd(s,t,e){let{_proxy:n,_context:i,_subProxy:o,_descriptors:r}=s,a=n[t];return oe(a)&&r.isScriptable(t)&&(a=Td(t,a,s,e)),ct(a)&&a.length&&(a=Ld(t,a,s,r.isIndexable)),Hi(t,a)&&(a=Le(a,i,o&&o[t],r)),a}function Td(s,t,e,n){let{_proxy:i,_context:o,_subProxy:r,_stack:a}=e;if(a.has(s))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+s);a.add(s);let l=t(o,r||n);return a.delete(s),Hi(s,l)&&(l=$i(i._scopes,i,s,l)),l}function Ld(s,t,e,n){let{_proxy:i,_context:o,_subProxy:r,_descriptors:a}=e;if(typeof o.index!="undefined"&&n(s))return t[o.index%t.length];if(et(t[0])){let l=t,c=i._scopes.filter(d=>d!==l);t=[];for(let d of l){let h=$i(c,i,s,d);t.push(Le(h,o,r&&r[s],a))}}return t}function Gr(s,t,e){return oe(s)?s(t,e):s}function Pd(s,t,e,n,i){for(let o of t){let r=Ad(e,o);if(r){s.add(r);let a=Gr(r._fallback,e,i);if(typeof a!="undefined"&&a!==e&&a!==n)return a}else if(r===!1&&typeof n!="undefined"&&e!==n)return null}return!1}function $i(s,t,e,n){let i=t._rootScopes,o=Gr(t._fallback,e,n),r=[...s,...i],a=new Set;a.add(n);let l=Er(a,r,e,o||e,n);return l===null||typeof o!="undefined"&&o!==e&&(l=Er(a,r,o,l,n),l===null)?!1:Rn(Array.from(a),[""],i,o,()=>Rd(t,e,n))}function Er(s,t,e,n,i){for(;e;)e=Pd(s,t,e,n,i);return e}function Rd(s,t,e){let n=s._getTarget();t in n||(n[t]={});let i=n[t];return ct(i)&&et(e)?e:i||{}}function Od(s,t,e,n){let i;for(let o of t)if(i=qr(Md(o,s),e),typeof i!="undefined")return Hi(s,i)?$i(e,n,s,i):i}function qr(s,t){for(let e of t){if(!e)continue;let n=e[s];if(typeof n!="undefined")return n}}function wr(s){let t=s._keys;return t||(t=s._keys=Fd(s._scopes)),t}function Fd(s){let t=new Set;for(let e of s)for(let n of Object.keys(e).filter(i=>!i.startsWith("_")))t.add(n);return Array.from(t)}function Wi(s,t,e,n){let{iScale:i}=s,{key:o="r"}=this._parsing,r=new Array(n),a,l,c,d;for(a=0,l=n;a!c.skip)),t.cubicInterpolationMode==="monotone")zd(s,i);else{let c=n?s[s.length-1]:s[0];for(o=0,r=s.length;ol.height&&(d=l.height,c=ge(Math.floor(d*n))),{width:c,height:d}}function ji(s,t,e){let n=t||1,i=ge(s.height*n),o=ge(s.width*n);s.height=ge(s.height),s.width=ge(s.width);let r=s.canvas;return r.style&&(e||!r.style.height&&!r.style.width)&&(r.style.height=`${s.height}px`,r.style.width=`${s.width}px`),s.currentDevicePixelRatio!==n||r.height!==i||r.width!==o?(s.currentDevicePixelRatio=n,r.height=i,r.width=o,s.ctx.setTransform(n,0,0,n,0,0),!0):!1}function Ui(s,t){let e=$d(s,t),n=e&&e.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}function pe(s,t,e,n){return{x:s.x+e*(t.x-s.x),y:s.y+e*(t.y-s.y)}}function ta(s,t,e,n){return{x:s.x+e*(t.x-s.x),y:n==="middle"?e<.5?s.y:t.y:n==="after"?e<1?s.y:t.y:e>0?t.y:s.y}}function ea(s,t,e,n){let i={x:s.cp2x,y:s.cp2y},o={x:t.cp1x,y:t.cp1y},r=pe(s,i,e),a=pe(i,o,e),l=pe(o,t,e),c=pe(r,a,e),d=pe(a,l,e);return pe(c,d,e)}function Pe(s,t,e){return s?Yd(t,e):Gd()}function Ki(s,t){let e,n;(t==="ltr"||t==="rtl")&&(e=s.canvas.style,n=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),s.prevTextDirection=n)}function Yi(s,t){t!==void 0&&(delete s.prevTextDirection,s.canvas.style.setProperty("direction",t[0],t[1]))}function sa(s){return s==="angle"?{between:ss,compare:hd,normalize:xt}:{between:Zt,compare:(t,e)=>t-e,normalize:t=>t}}function kr({start:s,end:t,count:e,loop:n,style:i}){return{start:s%e,end:t%e,loop:n&&(t-s+1)%e===0,style:i}}function qd(s,t,e){let{property:n,start:i,end:o}=e,{between:r,normalize:a}=sa(n),l=t.length,{start:c,end:d,loop:h}=s,u,f;if(h){for(c+=l,d+=l,u=0,f=l;ul(i,_,b)&&a(i,_)!==0,S=()=>a(o,b)===0||l(o,_,b),v=()=>g||E(),y=()=>!g||S();for(let C=d,D=d;C<=h;++C)x=t[C%r],!x.skip&&(b=c(x[n]),b!==_&&(g=l(b,i,o),m===null&&v()&&(m=a(b,i)===0?C:D),m!==null&&y()&&(p.push(kr({start:m,end:C,loop:u,count:r,style:f})),m=null),D=C,_=b));return m!==null&&p.push(kr({start:m,end:h,loop:u,count:r,style:f})),p}function qi(s,t){let e=[],n=s.segments;for(let i=0;ii&&s[o%t].skip;)o--;return o%=t,{start:i,end:o}}function Qd(s,t,e,n){let i=s.length,o=[],r=t,a=s[t],l;for(l=t+1;l<=e;++l){let c=s[l%i];c.skip||c.stop?a.skip||(n=!1,o.push({start:t%i,end:(l-1)%i,loop:n}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%i,end:r%i,loop:n}),o}function na(s,t){let e=s.points,n=s.options.spanGaps,i=e.length;if(!i)return[];let o=!!s._loop,{start:r,end:a}=Xd(e,i,o,n);if(n===!0)return Mr(s,[{start:r,end:a,loop:o}],e,t);let l=a{vr();Tr=(()=>{let s=0;return()=>s++})();Lr=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100:+s/t,Si=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100*t:+s;yr={"":s=>s,x:s=>s.x,y:s=>s.y};ts=s=>typeof s!="undefined",oe=s=>typeof s=="function",Ei=(s,t)=>{if(s.size!==t.size)return!1;for(let e of s)if(!t.has(e))return!1;return!0};nt=Math.PI,dt=2*nt,ld=dt+nt,Sn=Number.POSITIVE_INFINITY,cd=nt/180,mt=nt/2,De=nt/4,xr=nt*2/3,re=Math.log10,Wt=Math.sign;qt=(s,t,e,n)=>Dn(s,e,n?i=>{let o=s[i][t];return os[i][t]Dn(s,e,n=>s[n][t]>=e);Nr=["push","pop","shift","splice","unshift"];Ai=function(){return typeof window=="undefined"?function(s){return s()}:window.requestAnimationFrame}();Tn=s=>s==="start"?"left":s==="end"?"right":"center",_t=(s,t,e)=>s==="start"?t:s==="end"?e:(t+e)/2,Hr=(s,t,e,n)=>s===(n?"left":"right")?e:s==="center"?(t+e)/2:t;yn=s=>s===0||s===1,_r=(s,t,e)=>-(Math.pow(2,10*(s-=1))*Math.sin((s-t)*dt/e)),Cr=(s,t,e)=>Math.pow(2,-10*s)*Math.sin((s-t)*dt/e)+1,Xe={linear:s=>s,easeInQuad:s=>s*s,easeOutQuad:s=>-s*(s-2),easeInOutQuad:s=>(s/=.5)<1?.5*s*s:-.5*(--s*(s-2)-1),easeInCubic:s=>s*s*s,easeOutCubic:s=>(s-=1)*s*s+1,easeInOutCubic:s=>(s/=.5)<1?.5*s*s*s:.5*((s-=2)*s*s+2),easeInQuart:s=>s*s*s*s,easeOutQuart:s=>-((s-=1)*s*s*s-1),easeInOutQuart:s=>(s/=.5)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2),easeInQuint:s=>s*s*s*s*s,easeOutQuint:s=>(s-=1)*s*s*s*s+1,easeInOutQuint:s=>(s/=.5)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2),easeInSine:s=>-Math.cos(s*mt)+1,easeOutSine:s=>Math.sin(s*mt),easeInOutSine:s=>-.5*(Math.cos(nt*s)-1),easeInExpo:s=>s===0?0:Math.pow(2,10*(s-1)),easeOutExpo:s=>s===1?1:-Math.pow(2,-10*s)+1,easeInOutExpo:s=>yn(s)?s:s<.5?.5*Math.pow(2,10*(s*2-1)):.5*(-Math.pow(2,-10*(s*2-1))+2),easeInCirc:s=>s>=1?s:-(Math.sqrt(1-s*s)-1),easeOutCirc:s=>Math.sqrt(1-(s-=1)*s),easeInOutCirc:s=>(s/=.5)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1),easeInElastic:s=>yn(s)?s:_r(s,.075,.3),easeOutElastic:s=>yn(s)?s:Cr(s,.075,.3),easeInOutElastic(s){return yn(s)?s:s<.5?.5*_r(s*2,.1125,.45):.5+.5*Cr(s*2-1,.1125,.45)},easeInBack(s){return s*s*((1.70158+1)*s-1.70158)},easeOutBack(s){return(s-=1)*s*((1.70158+1)*s+1.70158)+1},easeInOutBack(s){let t=1.70158;return(s/=.5)<1?.5*(s*s*(((t*=1.525)+1)*s-t)):.5*((s-=2)*s*(((t*=1.525)+1)*s+t)+2)},easeInBounce:s=>1-Xe.easeOutBounce(1-s),easeOutBounce(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},easeInOutBounce:s=>s<.5?Xe.easeInBounce(s*2)*.5:Xe.easeOutBounce(s*2-1)*.5+.5};ud=["x","y","borderWidth","radius","tension"],fd=["color","borderColor","backgroundColor"];Sr=new Map;$r={values(s){return ct(s)?s:""+s},numeric(s,t,e){if(s===0)return"0";let n=this.chart.options.locale,i,o=s;if(e.length>1){let c=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(c<1e-4||c>1e15)&&(i="scientific"),o=bd(s,e)}let r=re(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:i,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),ns(s,n,l)},logarithmic(s,t,e){if(s===0)return"0";let n=e[t].significand||s/Math.pow(10,Math.floor(re(s)));return[1,2,3,5,10,15].includes(n)||t>.8*e.length?$r.numeric.call(this,s,t,e):""}};is={formatters:$r};me=Object.create(null),Ln=Object.create(null);Ci=class{constructor(t,e){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=n=>n.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=(n,i)=>xi(i.backgroundColor),this.hoverBorderColor=(n,i)=>xi(i.borderColor),this.hoverColor=(n,i)=>xi(i.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 _i(this,t,e)}get(t){return Ls(this,t)}describe(t,e){return _i(Ln,t,e)}override(t,e){return _i(me,t,e)}route(t,e,n,i){let o=Ls(this,t),r=Ls(this,n),a="_"+e;Object.defineProperties(o,{[a]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let l=this[a],c=r[i];return et(l)?Object.assign({},c,l):Q(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(e=>e(this))}},ht=new Ci({_scriptable:s=>!s.startsWith("on"),_indexable:s=>s!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[pd,gd,vd]);Sd=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Ed=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;kd=s=>+s||0;Md=(s,t)=>s?s+kn(t):t,Hi=(s,t)=>et(t)&&s!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);Ad=(s,t)=>s===!0?t:typeof s=="string"?ae(t,s):void 0;Id=Number.EPSILON||1e-14,Ze=(s,t)=>ts==="x"?"y":"x";In=s=>s.ownerDocument.defaultView.getComputedStyle(s,null);Wd=["top","right","bottom","left"];jd=(s,t,e)=>(s>0||t>0)&&(!e||!e.shadowRoot);ge=s=>Math.round(s*10)/10;Jr=function(){let s=!1;try{let t={get passive(){return s=!0,!1}};On()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch(t){}return s}();Yd=function(s,t){return{x(e){return s+s+t-e},setWidth(e){t=e},textAlign(e){return e==="center"?e:e==="right"?"left":"right"},xPlus(e,n){return e-n},leftForLtr(e,n){return e-n}}},Gd=function(){return{x(s){return s},setWidth(s){},textAlign(s){return s},xPlus(s,t){return s+t},leftForLtr(s,t){return s}}}});var Nl={};Eo(Nl,{Animation:()=>Un,Animations:()=>Ws,ArcElement:()=>_e,BarController:()=>Fe,BarElement:()=>He,BasePlatform:()=>js,BasicPlatform:()=>Kn,BubbleController:()=>Ie,CategoryScale:()=>ds,Chart:()=>ee,Colors:()=>El,DatasetController:()=>Tt,Decimation:()=>kl,DomPlatform:()=>Gn,DoughnutController:()=>se,Element:()=>At,Filler:()=>Dl,Interaction:()=>ll,Legend:()=>Ll,LineController:()=>Ve,LineElement:()=>Ut,LinearScale:()=>hs,LogarithmicScale:()=>us,PieController:()=>ls,PointElement:()=>ze,PolarAreaController:()=>Se,RadarController:()=>Ne,RadialLinearScale:()=>Ce,Scale:()=>ke,ScatterController:()=>Be,SubTitle:()=>Pl,Ticks:()=>is,TimeScale:()=>we,TimeSeriesScale:()=>fs,Title:()=>Al,Tooltip:()=>Ol,_adapters:()=>al,_detectPlatform:()=>fl,animator:()=>te,controllers:()=>rl,defaults:()=>ht,elements:()=>_l,layouts:()=>St,plugins:()=>Fl,registerables:()=>ep,registry:()=>jt,scales:()=>Vl});function sh(s,t){let e=[],n=Object.keys(t);for(let i=0;i0||!e&&o<0)return i.index}return null}function ca(s,t){let{chart:e,_cachedMeta:n}=s,i=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=n,l=o.axis,c=r.axis,d=ah(o,r,n),h=t.length,u;for(let f=0;fe[n].axis===t).shift()}function dh(s,t){return le(s,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function hh(s,t,e){return le(s,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Fs(s,t){let e=s.controller.index,n=s.vScale&&s.vScale.axis;if(n){t=t||s._parsed;for(let i of t){let o=i._stacks;if(!o||o[n]===void 0||o[n][e]===void 0)return;delete o[n][e],o[n]._visualValues!==void 0&&o[n]._visualValues[e]!==void 0&&delete o[n]._visualValues[e]}}}function fh(s,t){if(!s._cache.$bar){let e=s.getMatchingVisibleMetas(t),n=[];for(let i=0,o=e.length;ii-o))}return s._cache.$bar}function ph(s){let t=s.iScale,e=fh(t,s.type),n=t._length,i,o,r,a,l=()=>{r===32767||r===-32768||(ts(a)&&(n=Math.min(n,Math.abs(r-a)||n)),a=r)};for(i=0,o=e.length;i0?i[s-1]:null,a=sMath.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:i,end:o,min:r,max:a}}function ol(s,t,e,n){return ct(s)?bh(s,t,e,n):t[e.axis]=e.parse(s,n),t}function ha(s,t,e,n){let i=s.iScale,o=s.vScale,r=i.getLabels(),a=i===o,l=[],c,d,h,u;for(c=e,d=e+n;c=e?1:-1)}function yh(s){let t,e,n,i,o;return s.horizontal?(t=s.base>s.x,e="left",n="right"):(t=s.basess(_,a,l,!0)?1:Math.max(E,E*e,S,S*e),p=(_,E,S)=>ss(_,a,l,!0)?-1:Math.min(E,E*e,S,S*e),g=f(0,c,h),m=f(mt,d,u),b=p(nt,c,h),x=p(nt+mt,d,u);n=(g-b)/2,i=(m-x)/2,o=-(g+b)/2,r=-(m+x)/2}return{ratioX:n,ratioY:i,offsetX:o,offsetY:r}}function Re(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}function Eh(s,t,e,n){let{controller:i,data:o,_sorted:r}=s,a=i._cachedMeta.iScale,l=s.dataset&&s.dataset.options?s.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){let c=a._reversePixels?Ir:qt;if(n){if(i._sharedOptions){let d=o[0],h=typeof d.getRange=="function"&&d.getRange(t);if(h){let u=c(o,t,e-h),f=c(o,t,e+h);return{lo:u.lo,hi:f.hi}}}}else{let d=c(o,t,e);if(l){let{vScale:h}=i._cachedMeta,{_parsed:u}=s,f=u.slice(0,d.lo+1).reverse().findIndex(g=>!tt(g[h.axis]));d.lo-=Math.max(0,f);let p=u.slice(d.hi).findIndex(g=>!tt(g[h.axis]));d.hi+=Math.max(0,p)}return d}}return{lo:0,hi:o.length-1}}function Gs(s,t,e,n,i){let o=s.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a{l[r]&&l[r](t[e],i)&&(o.push({element:l,datasetIndex:c,index:d}),a=a||l.inRange(t.x,t.y,i))}),n&&!a?[]:o}function Is(s,t){return s.filter(e=>e.pos===t)}function ga(s,t){return s.filter(e=>cl.indexOf(e.pos)===-1&&e.box.axis===t)}function Vs(s,t){return s.sort((e,n)=>{let i=t?n:e,o=t?e:n;return i.weight===o.weight?i.index-o.index:i.weight-o.weight})}function Dh(s){let t=[],e,n,i,o,r,a;for(e=0,n=(s||[]).length;ec.box.fullSize),!0),n=Vs(Is(t,"left"),!0),i=Vs(Is(t,"right")),o=Vs(Is(t,"top"),!0),r=Vs(Is(t,"bottom")),a=ga(t,"x"),l=ga(t,"y");return{fullSize:e,leftAndTop:n.concat(o),rightAndBottom:i.concat(l).concat(r).concat(a),chartArea:Is(t,"chartArea"),vertical:n.concat(i).concat(l),horizontal:o.concat(r).concat(a)}}function ma(s,t,e,n){return Math.max(s[e],t[e])+Math.max(s[n],t[n])}function dl(s,t){s.top=Math.max(s.top,t.top),s.left=Math.max(s.left,t.left),s.bottom=Math.max(s.bottom,t.bottom),s.right=Math.max(s.right,t.right)}function Ph(s,t,e,n){let{pos:i,box:o}=e,r=s.maxPadding;if(!et(i)){e.size&&(s[i]-=e.size);let h=n[e.stack]||{size:0,count:1};h.size=Math.max(h.size,e.horizontal?o.height:o.width),e.size=h.size/h.count,s[i]+=e.size}o.getPadding&&dl(r,o.getPadding());let a=Math.max(0,t.outerWidth-ma(r,s,"left","right")),l=Math.max(0,t.outerHeight-ma(r,s,"top","bottom")),c=a!==s.w,d=l!==s.h;return s.w=a,s.h=l,e.horizontal?{same:c,other:d}:{same:d,other:c}}function Rh(s){let t=s.maxPadding;function e(n){let i=Math.max(t[n]-s[n],0);return s[n]+=i,i}s.y+=e("top"),s.x+=e("left"),e("right"),e("bottom")}function Oh(s,t){let e=t.maxPadding;function n(i){let o={left:0,top:0,right:0,bottom:0};return i.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return n(s?["left","right"]:["top","bottom"])}function zs(s,t,e,n){let i=[],o,r,a,l,c,d;for(o=0,r=s.length,c=0;o{let r=!1;for(let a of o)r=r||Yn(a.addedNodes,n),r=r&&!Yn(a.removedNodes,n);r&&e()});return i.observe(document,{childList:!0,subtree:!0}),i}function Hh(s,t,e){let n=s.canvas,i=new MutationObserver(o=>{let r=!1;for(let a of o)r=r||Yn(a.removedNodes,n),r=r&&!Yn(a.addedNodes,n);r&&e()});return i.observe(document,{childList:!0,subtree:!0}),i}function ul(){let s=window.devicePixelRatio;s!==ya&&(ya=s,Us.forEach((t,e)=>{e.currentDevicePixelRatio!==s&&t()}))}function $h(s,t){Us.size||window.addEventListener("resize",ul),Us.set(s,t)}function Wh(s){Us.delete(s),Us.size||window.removeEventListener("resize",ul)}function jh(s,t,e){let n=s.canvas,i=n&&Fn(n);if(!i)return;let o=Pi((a,l)=>{let c=i.clientWidth;e(a,l),c{let l=a[0],c=l.contentRect.width,d=l.contentRect.height;c===0&&d===0||o(c,d)});return r.observe(i),$h(s,o),r}function no(s,t,e){e&&e.disconnect(),t==="resize"&&Wh(s)}function Uh(s,t,e){let n=s.canvas,i=Pi(o=>{s.ctx!==null&&e(Bh(o,s))},s);return Vh(n,t,i),i}function fl(s){return!On()||typeof OffscreenCanvas!="undefined"&&s instanceof OffscreenCanvas?Kn:Gn}function Kh(s,t){let e=s.options.ticks,n=Yh(s),i=Math.min(e.maxTicksLimit||n,n),o=e.major.enabled?qh(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>i)return Xh(t,c,o,r/i),c;let d=Gh(o,t,i);if(r>0){let h,u,f=r>1?Math.round((l-a)/(r-1)):null;for(Nn(t,c,d,tt(f)?0:a-f,a),h=0,u=r-1;hi)return l}return Math.max(i,1)}function qh(s){let t=[],e,n;for(e=0,n=s.length;er+a)))return l}function tu(s,t){rt(s,e=>{let n=e.gc,i=n.length/2,o;if(i>t){for(o=0;o{let n=e.split("."),i=n.pop(),o=[s].concat(n).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");ht.route(o,i,l,a)})}function au(s){return"id"in s&&"defaults"in s}function lu(s){let t={},e=[],n=Object.keys(jt.plugins.items);for(let o=0;o1&&Ea(s[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${s}' axis. Please provide 'axis' or 'position' option.`)}function wa(s,t,e){if(e[t+"AxisID"]===s)return{axis:t}}function gu(s,t){if(t.data&&t.data.datasets){let e=t.data.datasets.filter(n=>n.xAxisID===s||n.yAxisID===s);if(e.length)return wa(s,"x",e[0])||wa(s,"y",e[0])}return{}}function mu(s,t){let e=me[s.type]||{scales:{}},n=t.scales||{},i=fo(s.type,t),o=Object.create(null);return Object.keys(n).forEach(r=>{let a=n[r];if(!et(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);let l=po(r,a,gu(r,s),ht.scales[a.type]),c=fu(l,i),d=e.scales||{};o[r]=Je(Object.create(null),[{axis:l},a,d[l],d[c]])}),s.data.datasets.forEach(r=>{let a=r.type||s.type,l=r.indexAxis||fo(a,t),d=(me[a]||{}).scales||{};Object.keys(d).forEach(h=>{let u=uu(h,l),f=r[u+"AxisID"]||u;o[f]=o[f]||Object.create(null),Je(o[f],[{axis:u},n[f],d[h]])})}),Object.keys(o).forEach(r=>{let a=o[r];Je(a,[ht.scales[a.type],ht.scale])}),o}function pl(s){let t=s.options||(s.options={});t.plugins=Q(t.plugins,{}),t.scales=mu(s,t)}function gl(s){return s=s||{},s.datasets=s.datasets||[],s.labels=s.labels||[],s}function bu(s){return s=s||{},s.data=gl(s.data),pl(s),s}function Bn(s,t){let e=ka.get(s);return e||(e=t(),ka.set(s,e),ml.add(e)),e}function Ma(s,t,e){let n=s.get(t);n||(n=new Map,s.set(t,n));let i=e.join(),o=n.get(i);return o||(o={resolver:Rn(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},n.set(i,o)),o}function yu(s,t){let{isScriptable:e,isIndexable:n}=zi(s);for(let i of t){let o=e(i),r=n(i),a=(r||o)&&s[i];if(o&&(oe(a)||vu(a))||r&&ct(a))return!0}return!1}function Da(s,t){return s==="top"||s==="bottom"||_u.indexOf(s)===-1&&t==="x"}function Ta(s,t){return function(e,n){return e[s]===n[s]?e[t]-n[t]:e[s]-n[s]}}function La(s){let t=s.chart,e=t.options.animation;t.notifyPlugins("afterRender"),lt(e&&e.onComplete,[s],t)}function Cu(s){let t=s.chart,e=t.options.animation;lt(e&&e.onProgress,[s],t)}function bl(s){return On()&&typeof s=="string"?s=document.getElementById(s):s&&s.length&&(s=s[0]),s&&s.canvas&&(s=s.canvas),s}function Su(s,t,e){let n=Object.keys(s);for(let i of n){let o=+i;if(o>=t){let r=s[i];delete s[i],(e>0||o>t)&&(s[o+e]=r)}}}function Eu(s,t,e,n){return!e||s.type==="mouseout"?null:n?t:s}function Pa(){return rt(ee.instances,s=>s._plugins.invalidate())}function wu(s,t,e){let{startAngle:n,x:i,y:o,outerRadius:r,innerRadius:a,options:l}=t,{borderWidth:c,borderJoinStyle:d}=l,h=Math.min(c/r,xt(n-e));if(s.beginPath(),s.arc(i,o,r-c/2,n+h/2,e-h/2),a>0){let u=Math.min(c/a,xt(n-e));s.arc(i,o,a+c/2,e-u/2,n+u/2,!0)}else{let u=Math.min(c/2,r*xt(n-e));if(d==="round")s.arc(i,o,u,e-nt/2,n+nt/2,!0);else if(d==="bevel"){let f=2*u*u,p=-f*Math.cos(e+nt/2)+i,g=-f*Math.sin(e+nt/2)+o,m=f*Math.cos(n+nt/2)+i,b=f*Math.sin(n+nt/2)+o;s.lineTo(p,g),s.lineTo(m,b)}}s.closePath(),s.moveTo(0,0),s.rect(0,0,s.canvas.width,s.canvas.height),s.clip("evenodd")}function ku(s,t,e){let{startAngle:n,pixelMargin:i,x:o,y:r,outerRadius:a,innerRadius:l}=t,c=i/a;s.beginPath(),s.arc(o,r,a,n-c,e+c),l>i?(c=i/l,s.arc(o,r,l,e+c,n-c,!0)):s.arc(o,r,i,e+mt,n-mt),s.closePath(),s.clip()}function Mu(s){return Pn(s,["outerStart","outerEnd","innerStart","innerEnd"])}function Du(s,t,e,n){let i=Mu(s.options.borderRadius),o=(e-t)/2,r=Math.min(o,n*t/2),a=l=>{let c=(e-Math.min(o,l))*n/2;return vt(l,0,Math.min(o,c))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:vt(i.innerStart,0,r),innerEnd:vt(i.innerEnd,0,r)}}function as(s,t,e,n){return{x:e+s*Math.cos(t),y:n+s*Math.sin(t)}}function qn(s,t,e,n,i,o){let{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:d}=t,h=Math.max(t.outerRadius+n+e-c,0),u=d>0?d+n+e+c:0,f=0,p=i-l;if(n){let P=d>0?d-n:0,I=h>0?h-n:0,z=(P+I)/2,R=z!==0?p*z/(z+n):p;f=(p-R)/2}let g=Math.max(.001,p*h-e/nt)/h,m=(p-g)/2,b=l+m+f,x=i-m-f,{outerStart:_,outerEnd:E,innerStart:S,innerEnd:v}=Du(t,u,h,x-b),y=h-_,C=h-E,D=b+_/y,M=x-E/C,w=u+S,L=u+v,k=b+S/w,A=x-v/L;if(s.beginPath(),o){let P=(D+M)/2;if(s.arc(r,a,h,D,P),s.arc(r,a,h,P,M),E>0){let V=as(C,M,r,a);s.arc(V.x,V.y,E,M,x+mt)}let I=as(L,x,r,a);if(s.lineTo(I.x,I.y),v>0){let V=as(L,A,r,a);s.arc(V.x,V.y,v,x+mt,A+Math.PI)}let z=(x-v/u+(b+S/u))/2;if(s.arc(r,a,u,x-v/u,z,!0),s.arc(r,a,u,z,b+S/u,!0),S>0){let V=as(w,k,r,a);s.arc(V.x,V.y,S,k+Math.PI,b-mt)}let R=as(y,b,r,a);if(s.lineTo(R.x,R.y),_>0){let V=as(y,D,r,a);s.arc(V.x,V.y,_,b-mt,D)}}else{s.moveTo(r,a);let P=Math.cos(D)*h+r,I=Math.sin(D)*h+a;s.lineTo(P,I);let z=Math.cos(M)*h+r,R=Math.sin(M)*h+a;s.lineTo(z,R)}s.closePath()}function Tu(s,t,e,n,i){let{fullCircles:o,startAngle:r,circumference:a}=t,l=t.endAngle;if(o){qn(s,t,e,n,l,i);for(let c=0;c=nt&&f===0&&d!=="miter"&&wu(s,t,g),o||(qn(s,t,e,n,g,i),s.stroke())}function vl(s,t,e=t){s.lineCap=Q(e.borderCapStyle,t.borderCapStyle),s.setLineDash(Q(e.borderDash,t.borderDash)),s.lineDashOffset=Q(e.borderDashOffset,t.borderDashOffset),s.lineJoin=Q(e.borderJoinStyle,t.borderJoinStyle),s.lineWidth=Q(e.borderWidth,t.borderWidth),s.strokeStyle=Q(e.borderColor,t.borderColor)}function Au(s,t,e){s.lineTo(e.x,e.y)}function Pu(s){return s.stepped?jr:s.tension||s.cubicInterpolationMode==="monotone"?Ur:Au}function yl(s,t,e={}){let n=s.length,{start:i=0,end:o=n-1}=e,{start:r,end:a}=t,l=Math.max(i,r),c=Math.min(o,a),d=ia&&o>a;return{count:n,start:l,loop:t.loop,ilen:c(r+(c?a-E:E))%o,_=()=>{g!==m&&(s.lineTo(d,m),s.lineTo(d,g),s.lineTo(d,b))};for(l&&(f=i[x(0)],s.moveTo(f.x,f.y)),u=0;u<=a;++u){if(f=i[x(u)],f.skip)continue;let E=f.x,S=f.y,v=E|0;v===p?(Sm&&(m=S),d=(h*d+E)/++h):(_(),s.lineTo(E,S),p=v,h=0,g=m=S),b=S}_()}function mo(s){let t=s.options,e=t.borderDash&&t.borderDash.length;return!s._decimated&&!s._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?Ou:Ru}function Fu(s){return s.stepped?ta:s.tension||s.cubicInterpolationMode==="monotone"?ea:pe}function Iu(s,t,e,n){let i=t._path;i||(i=t._path=new Path2D,t.path(i,e,n)&&i.closePath()),vl(s,t.options),s.stroke(i)}function Vu(s,t,e,n){let{segments:i,options:o}=t,r=mo(t);for(let a of i)vl(s,o,a.style),s.beginPath(),r(s,t,a,{start:e,end:e+n-1})&&s.closePath(),s.stroke()}function Bu(s,t,e,n){Nu&&!t.options.segment?Iu(s,t,e,n):Vu(s,t,e,n)}function Ra(s,t,e,n){let i=s.options,{[e]:o}=s.getProps([e],n);return Math.abs(t-o)Cl(t++)),t}function Yu(s,t){return s.backgroundColor=s.data.map(()=>Sl(t++)),t}function Gu(s){let t=0;return(e,n)=>{let i=s.getDatasetMeta(n).controller;i instanceof se?t=Ku(e,t):i instanceof Se?t=Yu(e,t):i&&(t=Uu(e,t))}}function Fa(s){let t;for(t in s)if(s[t].borderColor||s[t].backgroundColor)return!0;return!1}function qu(s){return s&&(s.borderColor||s.backgroundColor)}function Xu(){return ht.borderColor!=="rgba(0,0,0,0.1)"||ht.backgroundColor!=="rgba(0,0,0,0.1)"}function Qu(s,t,e,n,i){let o=i.samples||n;if(o>=e)return s.slice(t,t+e);let r=[],a=(e-2)/(o-2),l=0,c=t+e-1,d=t,h,u,f,p,g;for(r[l++]=s[d],h=0;hf&&(f=p,u=s[x],g=x);r[l++]=u,d=g}return r[l++]=s[c],r}function Zu(s,t,e,n){let i=0,o=0,r,a,l,c,d,h,u,f,p,g,m=[],b=t+e-1,x=s[t].x,E=s[b].x-x;for(r=t;rg&&(g=c,u=r),i=(o*i+a.x)/++o;else{let v=r-1;if(!tt(h)&&!tt(u)){let y=Math.min(h,u),C=Math.max(h,u);y!==f&&y!==v&&m.push({...s[y],x:i}),C!==f&&C!==v&&m.push({...s[C],x:i})}r>0&&v!==f&&m.push(s[v]),m.push(a),d=S,o=0,p=g=c,h=u=f=r}}return m}function wl(s){if(s._decimated){let t=s._data;delete s._decimated,delete s._data,Object.defineProperty(s,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Ia(s){s.data.datasets.forEach(t=>{wl(t)})}function Ju(s,t){let e=t.length,n=0,i,{iScale:o}=s,{min:r,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(n=vt(qt(t,o.axis,r).lo,0,e-1)),c?i=vt(qt(t,o.axis,a).hi+1,n,e)-n:i=e-n,{start:n,count:i}}function tf(s,t,e){let n=s.segments,i=s.points,o=t.points,r=[];for(let a of n){let{start:l,end:c}=a;c=Zn(l,c,i);let d=vo(e,i[l],i[c],a.loop);if(!t.segments){r.push({source:a,target:d,start:i[l],end:i[c]});continue}let h=qi(t,d);for(let u of h){let f=vo(e,o[u.start],o[u.end],u.loop),p=Gi(a,i,f);for(let g of p)r.push({source:g,target:u,start:{[e]:Va(d,f,"start",Math.max)},end:{[e]:Va(d,f,"end",Math.min)}})}}return r}function vo(s,t,e,n){if(n)return;let i=t[s],o=e[s];return s==="angle"&&(i=xt(i),o=xt(o)),{property:s,start:i,end:o}}function ef(s,t){let{x:e=null,y:n=null}=s||{},i=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Zn(r,a,i);let l=i[r],c=i[a];n!==null?(o.push({x:l.x,y:n}),o.push({x:c.x,y:n})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function Zn(s,t,e){for(;t>s;t--){let n=e[t];if(!isNaN(n.x)&&!isNaN(n.y))break}return t}function Va(s,t,e,n){return s&&t?n(s[e],t[e]):s?s[e]:t?t[e]:0}function Ml(s,t){let e=[],n=!1;return ct(s)?(n=!0,e=s):e=ef(s,t),e.length?new Ut({points:e,options:{tension:0},_loop:n,_fullLoop:n}):null}function Na(s){return s&&s.fill!==!1}function sf(s,t,e){let i=s[t].fill,o=[t],r;if(!e)return i;for(;i!==!1&&o.indexOf(i)===-1;){if(!pt(i))return i;if(r=s[i],!r)return!1;if(r.visible)return i;o.push(i),i=r.fill}return!1}function nf(s,t,e){let n=lf(s);if(et(n))return isNaN(n.value)?!1:n;let i=parseFloat(n);return pt(i)&&Math.floor(i)===i?of(n[0],t,i,e):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function of(s,t,e,n){return(s==="-"||s==="+")&&(e=t+e),e===t||e<0||e>=n?!1:e}function rf(s,t){let e=null;return s==="start"?e=t.bottom:s==="end"?e=t.top:et(s)?e=t.getPixelForValue(s.value):t.getBasePixel&&(e=t.getBasePixel()),e}function af(s,t,e){let n;return s==="start"?n=e:s==="end"?n=t.options.reverse?t.min:t.max:et(s)?n=s.value:n=t.getBaseValue(),n}function lf(s){let t=s.options,e=t.fill,n=Q(e&&e.target,e);return n===void 0&&(n=!!t.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function cf(s){let{scale:t,index:e,line:n}=s,i=[],o=n.segments,r=n.points,a=df(t,e);a.push(Ml({x:null,y:t.bottom},n));for(let l=0;lo.length>r.length?o:r)),t+e.size/2+n.measureText(i).width}function Sf(s,t,e){let n=s;return typeof t.text!="string"&&(n=Tl(t,e)),n}function Tl(s,t){let e=s.text?s.text.length:0;return t*e}function Ef(s,t){return!!((s==="mousemove"||s==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(s==="click"||s==="mouseup"))}function wf(s,t){let e=new Ks({ctx:s.ctx,options:t,chart:s});St.configure(s,e,t),St.addBox(s,e),s.titleBlock=e}function Jt(s,t){return t&&(ct(t)?Array.prototype.push.apply(s,t):s.push(t)),s}function ce(s){return(typeof s=="string"||s instanceof String)&&s.indexOf(` +`);var z=0,F=!1;this.parse=function(N,H,T){if(typeof N!="string")throw new Error("Input must be a string");var j=N.length,U=v.length,G=C.length,O=M.length,V=S(D),W=[],R=[],B=[],K=z=0;if(!N)return ft();if(L||L!==!1&&N.indexOf(P)===-1){for(var Y=N.split(C),q=0;q=E)return ft(!0);break}R.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:W.length,index:z}),J++}}else if(M&&B.length===0&&N.substring(z,z+O)===M){if(X===-1)return ft();z=X+G,X=N.indexOf(C,z),Q=N.indexOf(v,z)}else if(Q!==-1&&(Q=E)return ft(!0)}return ot();function at(yt){W.push(yt),K=z}function Rt(yt){var wt=0;return wt=yt!==-1&&(yt=N.substring(J+1,yt))&&yt.trim()===""?yt.length:wt}function ot(yt){return T||(yt===void 0&&(yt=N.substring(z)),B.push(yt),z=j,at(B),V&&Kt()),ft()}function gt(yt){z=yt,at(B),B=[],X=N.indexOf(C,z)}function ft(yt){if(y.header&&!H&&W.length&&!A){var wt=W[0],ne=Object.create(null),ei=new Set(wt);let Co=!1;for(let $e=0;$eM.charCodeAt(0)!==65279?M:M.slice(1))(y),C=new(v.download?c:h)(v)):y.readable===!0&&S(y.read)&&S(y.on)?C=new u(v):(t.File&&y instanceof File||y instanceof Object)&&(C=new d(v)),C.stream(y);(C=(()=>{var M;return!!a.WORKERS_SUPPORTED&&(M=(()=>{var D=t.URL||t.webkitURL||null,E=s.toString();return a.BLOB_URL||(a.BLOB_URL=D.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",E,")();"],{type:"text/javascript"})))})(),(M=new t.Worker(M)).onmessage=b,M.id=r++,o[M.id]=M)})()).userStep=v.step,C.userChunk=v.chunk,C.userComplete=v.complete,C.userError=v.error,v.step=S(v.step),v.chunk=S(v.chunk),v.complete=S(v.complete),v.error=S(v.error),delete v.worker,C.postMessage({input:y,config:v,workerId:C.id})},a.unparse=function(y,v){var C=!1,M=!0,D=",",E=`\r +`,L='"',k=L+L,A=!1,P=null,I=!1,z=((()=>{if(typeof v=="object"){if(typeof v.delimiter!="string"||a.BAD_DELIMITERS.filter(function(H){return v.delimiter.indexOf(H)!==-1}).length||(D=v.delimiter),typeof v.quotes!="boolean"&&typeof v.quotes!="function"&&!Array.isArray(v.quotes)||(C=v.quotes),typeof v.skipEmptyLines!="boolean"&&typeof v.skipEmptyLines!="string"||(A=v.skipEmptyLines),typeof v.newline=="string"&&(E=v.newline),typeof v.quoteChar=="string"&&(L=v.quoteChar),typeof v.header=="boolean"&&(M=v.header),Array.isArray(v.columns)){if(v.columns.length===0)throw new Error("Option columns is empty");P=v.columns}v.escapeChar!==void 0&&(k=v.escapeChar+L),v.escapeFormulae instanceof RegExp?I=v.escapeFormulae:typeof v.escapeFormulae=="boolean"&&v.escapeFormulae&&(I=/^[=+\-@\t\r].*$/)}})(),new RegExp(p(L),"g"));if(typeof y=="string"&&(y=JSON.parse(y)),Array.isArray(y)){if(!y.length||Array.isArray(y[0]))return F(null,y,A);if(typeof y[0]=="object")return F(P||Object.keys(y[0]),y,A)}else if(typeof y=="object")return typeof y.data=="string"&&(y.data=JSON.parse(y.data)),Array.isArray(y.data)&&(y.fields||(y.fields=y.meta&&y.meta.fields||P),y.fields||(y.fields=Array.isArray(y.data[0])?y.fields:typeof y.data[0]=="object"?Object.keys(y.data[0]):[]),Array.isArray(y.data[0])||typeof y.data[0]=="object"||(y.data=[y.data])),F(y.fields||[],y.data||[],A);throw new Error("Unable to serialize unrecognized input");function F(H,T,j){var U="",G=(typeof H=="string"&&(H=JSON.parse(H)),typeof T=="string"&&(T=JSON.parse(T)),Array.isArray(H)&&0{for(var V=0;Ve-n*Math.max(Math.min(r-3,9-r,1),-1);return[i(0),i(8),i(4)]}function Wc(s,t,e){let n=(i,o=(i+s/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[n(5),n(3),n(1)]}function jc(s,t,e){let n=gr(s,1,.5),i;for(t+e>1&&(i=1/(t+e),t*=i,e*=i),i=0;i<3;i++)n[i]*=1-t-e,n[i]+=t;return n}function Uc(s,t,e,n,i){return s===i?(t-e)/n+(t.5?d/(2-o-r):d/(o+r),l=Uc(e,n,i,d,o),l=l*60+.5),[l|0,c||0,a]}function vi(s,t,e,n){return(Array.isArray(t)?s(t[0],t[1],t[2]):s(t,e,n)).map(fe)}function yi(s,t,e){return vi(gr,s,t,e)}function Kc(s,t,e){return vi(jc,s,t,e)}function Yc(s,t,e){return vi(Wc,s,t,e)}function mr(s){return(s%360+360)%360}function Gc(s){let t=$c.exec(s),e=255,n;if(!t)return;t[5]!==n&&(e=t[6]?Ms(+t[5]):fe(+t[5]));let i=mr(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?n=Kc(i,o,r):t[1]==="hsv"?n=Yc(i,o,r):n=yi(i,o,r),{r:n[0],g:n[1],b:n[2],a:e}}function qc(s,t){var e=bi(s);e[0]=mr(e[0]+t),e=yi(e),s.r=e[0],s.g=e[1],s.b=e[2]}function Xc(s){if(!s)return;let t=bi(s),e=t[0],n=hr(t[1]),i=hr(t[2]);return s.a<255?`hsla(${e}, ${n}%, ${i}%, ${ie(s.a)})`:`hsl(${e}, ${n}%, ${i}%)`}function Qc(){let s={},t=Object.keys(fr),e=Object.keys(ur),n,i,o,r,a;for(n=0;n>16&255,o>>8&255,o&255]}return s}function Zc(s){bn||(bn=Qc(),bn.transparent=[0,0,0,0]);let t=bn[s.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}function td(s){let t=Jc.exec(s),e=255,n,i,o;if(t){if(t[7]!==n){let r=+t[7];e=t[8]?Ms(r):ue(r*255,0,255)}return n=+t[1],i=+t[3],o=+t[5],n=255&(t[2]?Ms(n):ue(n,0,255)),i=255&(t[4]?Ms(i):ue(i,0,255)),o=255&(t[6]?Ms(o):ue(o,0,255)),{r:n,g:i,b:o,a:e}}}function ed(s){return s&&(s.a<255?`rgba(${s.r}, ${s.g}, ${s.b}, ${ie(s.a)})`:`rgb(${s.r}, ${s.g}, ${s.b})`)}function sd(s,t,e){let n=qe(ie(s.r)),i=qe(ie(s.g)),o=qe(ie(s.b));return{r:fe(gi(n+e*(qe(ie(t.r))-n))),g:fe(gi(i+e*(qe(ie(t.g))-i))),b:fe(gi(o+e*(qe(ie(t.b))-o))),a:s.a+e*(t.a-s.a)}}function vn(s,t,e){if(s){let n=bi(s);n[t]=Math.max(0,Math.min(n[t]+n[t]*e,t===0?360:1)),n=yi(n),s.r=n[0],s.g=n[1],s.b=n[2]}}function br(s,t){return s&&Object.assign(t||{},s)}function pr(s){var t={r:0,g:0,b:0,a:255};return Array.isArray(s)?s.length>=3&&(t={r:s[0],g:s[1],b:s[2],a:255},s.length>3&&(t.a=fe(s[3]))):(t=br(s,{r:0,g:0,b:0,a:1}),t.a=fe(t.a)),t}function nd(s){return s.charAt(0)==="r"?td(s):Gc(s)}var ue,zt,mi,Ic,Vc,mn,Nc,zc,$c,ur,fr,bn,Jc,gi,qe,Ds,vr=si(()=>{ue=(s,t,e)=>Math.max(Math.min(s,e),t);zt={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},mi=[..."0123456789ABCDEF"],Ic=s=>mi[s&15],Vc=s=>mi[(s&240)>>4]+mi[s&15],mn=s=>(s&240)>>4===(s&15),Nc=s=>mn(s.r)&&mn(s.g)&&mn(s.b)&&mn(s.a);zc=(s,t)=>s<255?t(s):"";$c=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;ur={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},fr={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};Jc=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;gi=s=>s<=.0031308?s*12.92:Math.pow(s,1/2.4)*1.055-.055,qe=s=>s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4);Ds=class s{constructor(t){if(t instanceof s)return t;let e=typeof t,n;e==="object"?n=pr(t):e==="string"&&(n=Bc(t)||Zc(t)||nd(t)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var t=br(this._rgb);return t&&(t.a=ie(t.a)),t}set rgb(t){this._rgb=pr(t)}rgbString(){return this._valid?ed(this._rgb):void 0}hexString(){return this._valid?Hc(this._rgb):void 0}hslString(){return this._valid?Xc(this._rgb):void 0}mix(t,e){if(t){let n=this.rgb,i=t.rgb,o,r=e===o?.5:e,a=2*r-1,l=n.a-i.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,n.r=255&c*n.r+o*i.r+.5,n.g=255&c*n.g+o*i.g+.5,n.b=255&c*n.b+o*i.b+.5,n.a=r*n.a+(1-r)*i.a,this.rgb=n}return this}interpolate(t,e){return t&&(this._rgb=sd(this._rgb,t._rgb,e)),this}clone(){return new s(this.rgb)}alpha(t){return this._rgb.a=fe(t),this}clearer(t){let e=this._rgb;return e.a*=1-t,this}greyscale(){let t=this._rgb,e=Ts(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=e,this}opaquer(t){let e=this._rgb;return e.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 vn(this._rgb,2,t),this}darken(t){return vn(this._rgb,2,-t),this}saturate(t){return vn(this._rgb,1,t),this}desaturate(t){return vn(this._rgb,1,-t),this}rotate(t){return qc(this._rgb,t),this}}});function Qt(){}function tt(s){return s==null}function ct(s){if(Array.isArray&&Array.isArray(s))return!0;let t=Object.prototype.toString.call(s);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function et(s){return s!==null&&Object.prototype.toString.call(s)==="[object Object]"}function pt(s){return(typeof s=="number"||s instanceof Number)&&isFinite(+s)}function Mt(s,t){return pt(s)?s:t}function Z(s,t){return typeof s=="undefined"?t:s}function lt(s,t,e){if(s&&typeof s.call=="function")return s.apply(e,t)}function rt(s,t,e,n){let i,o,r;if(ct(s))if(o=s.length,n)for(i=o-1;i>=0;i--)t.call(e,s[i],i);else for(i=0;i{for(let n of t){if(n==="")break;e=e&&e[n]}return e}}function ae(s,t){return(yr[t]||(yr[t]=ad(t)))(s)}function kn(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Pr(s){return s.type==="mouseup"||s.type==="click"||s.type==="contextmenu"}function es(s,t,e){return Math.abs(s-t)i-o).pop(),t}function dd(s){return typeof s=="symbol"||typeof s=="object"&&s!==null&&!(Symbol.toPrimitive in s||"toString"in s||"valueOf"in s)}function Ae(s){return!dd(s)&&!isNaN(parseFloat(s))&&isFinite(s)}function Or(s,t){let e=Math.round(s);return e-t<=s&&e+t>=s}function ki(s,t,e){let n,i,o;for(n=0,i=s.length;nl&&c=Math.min(t,e)-n&&s<=Math.max(t,e)+n}function Dn(s,t,e){e=e||(r=>s[r]1;)o=i+n>>1,e(o)?i=o:n=o;return{lo:i,hi:n}}function Vr(s,t,e){let n=0,i=s.length;for(;nn&&s[i-1]>e;)i--;return n>0||i{let n="_onData"+kn(e),i=s[e];Object.defineProperty(s,e,{configurable:!0,enumerable:!1,value(...o){let r=i.apply(this,o);return s._chartjs.listeners.forEach(a=>{typeof a[n]=="function"&&a[n](...o)}),r}})})}function Ti(s,t){let e=s._chartjs;if(!e)return;let n=e.listeners,i=n.indexOf(t);i!==-1&&n.splice(i,1),!(n.length>0)&&(Nr.forEach(o=>{delete s[o]}),delete s._chartjs)}function Li(s){let t=new Set(s);return t.size===s.length?s:Array.from(t)}function Pi(s,t){let e=[],n=!1;return function(...i){e=i,n||(n=!0,Ai.call(window,()=>{n=!1,s.apply(t,e)}))}}function zr(s,t){let e;return function(...n){return t?(clearTimeout(e),e=setTimeout(s,t,n)):s.apply(this,n),t}}function Ri(s,t,e){let n=t.length,i=0,o=n;if(s._sorted){let{iScale:r,vScale:a,_parsed:l}=s,c=s.dataset&&s.dataset.options?s.dataset.options.spanGaps:null,d=r.axis,{min:h,max:u,minDefined:f,maxDefined:p}=r.getUserBounds();if(f){if(i=Math.min(qt(l,d,h).lo,e?n:qt(t,d,r.getPixelForValue(h)).lo),c){let g=l.slice(0,i+1).reverse().findIndex(b=>!tt(b[a.axis]));i-=Math.max(0,g)}i=vt(i,0,n-1)}if(p){let g=Math.max(qt(l,r.axis,u,!0).hi+1,e?0:qt(t,d,r.getPixelForValue(u),!0).hi+1);if(c){let b=l.slice(g-1).findIndex(m=>!tt(m[a.axis]));g+=Math.max(0,b)}o=vt(g,i,n)-i}else o=n-i}return{start:i,count:o}}function Oi(s){let{xScale:t,yScale:e,_scaleRanges:n}=s,i={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!n)return s._scaleRanges=i,!0;let o=n.xmin!==t.min||n.xmax!==t.max||n.ymin!==e.min||n.ymax!==e.max;return Object.assign(n,i),o}function Fi(s){if(s&&typeof s=="object"){let t=s.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Ii(s){return Fi(s)?s:new Ds(s)}function xi(s){return Fi(s)?s:new Ds(s).saturate(.5).darken(.1).hexString()}function pd(s){s.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),s.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),s.set("animations",{colors:{type:"color",properties:fd},numbers:{type:"number",properties:ud}}),s.describe("animations",{_fallback:"animation"}),s.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=>t|0}}}})}function gd(s){s.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}function md(s,t){t=t||{};let e=s+JSON.stringify(t),n=Sr.get(e);return n||(n=new Intl.NumberFormat(s,t),Sr.set(e,n)),n}function ns(s,t,e){return md(t,e).format(s)}function bd(s,t){let e=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(e)>=1&&s!==Math.floor(s)&&(e=s-Math.floor(s)),e}function vd(s){s.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:is.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),s.route("scale.ticks","color","","color"),s.route("scale.grid","color","","borderColor"),s.route("scale.border","color","","borderColor"),s.route("scale.title","color","","color"),s.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),s.describe("scales",{_fallback:"scale"}),s.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}function Ls(s,t){if(!t)return s;let e=t.split(".");for(let n=0,i=e.length;nn&&(n=o),n}function Wr(s,t,e,n){n=n||{};let i=n.data=n.data||{},o=n.garbageCollect=n.garbageCollect||[];n.font!==t&&(i=n.data={},o=n.garbageCollect=[],n.font=t),s.save(),s.font=t;let r=0,a=e.length,l,c,d,h,u;for(l=0;le.length){for(l=0;l0&&s.stroke()}}function Xt(s,t,e){return e=e||.5,!t||s&&s.x>t.left-e&&s.xt.top-e&&s.y0&&o.strokeColor!=="",l,c;for(s.save(),s.font=i.string,xd(s,o),l=0;lZ(s[r],s[t[r]]):r=>s[r]:()=>s;for(let r of i)e[r]=kd(o(r));return e}function Bi(s){return Pn(s,{top:"y",right:"x",bottom:"y",left:"x"})}function ye(s){return Pn(s,["topLeft","topRight","bottomLeft","bottomRight"])}function Ct(s){let t=Bi(s);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function bt(s,t){s=s||{},t=t||ht.font;let e=Z(s.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let n=Z(s.style,t.style);n&&!(""+n).match(Ed)&&(console.warn('Invalid font style specified: "'+n+'"'),n=void 0);let i={family:Z(s.family,t.family),lineHeight:wd(Z(s.lineHeight,t.lineHeight),e),size:e,style:n,weight:Z(s.weight,t.weight),string:""};return i.string=yd(i),i}function rs(s,t,e,n){let i=!0,o,r,a;for(o=0,r=s.length;oe&&a===0?0:a+l;return{min:r(n,-Math.abs(o)),max:r(i,o)}}function le(s,t){return Object.assign(Object.create(s),t)}function Rn(s,t=[""],e,n,i=()=>s[0]){let o=e||s;typeof n=="undefined"&&(n=qr("_fallback",s));let r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:s,_rootScopes:o,_fallback:n,_getTarget:i,override:a=>Rn([a,...s],t,o,n)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete s[0][l],!0},get(a,l){return Yr(a,l,()=>Od(l,t,s,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(s[0])},has(a,l){return wr(a).includes(l)},ownKeys(a){return wr(a)},set(a,l,c){let d=a._storage||(a._storage=i());return a[l]=d[l]=c,delete a._keys,!0}})}function Le(s,t,e,n){let i={_cacheable:!1,_proxy:s,_context:t,_subProxy:e,_stack:new Set,_descriptors:zi(s,n),setContext:o=>Le(s,o,e,n),override:o=>Le(s.override(o),t,e,n)};return new Proxy(i,{deleteProperty(o,r){return delete o[r],delete s[r],!0},get(o,r,a){return Yr(o,r,()=>Dd(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(s,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(s,r)},getPrototypeOf(){return Reflect.getPrototypeOf(s)},has(o,r){return Reflect.has(s,r)},ownKeys(){return Reflect.ownKeys(s)},set(o,r,a){return s[r]=a,delete o[r],!0}})}function zi(s,t={scriptable:!0,indexable:!0}){let{_scriptable:e=t.scriptable,_indexable:n=t.indexable,_allKeys:i=t.allKeys}=s;return{allKeys:i,scriptable:e,indexable:n,isScriptable:oe(e)?e:()=>e,isIndexable:oe(n)?n:()=>n}}function Yr(s,t,e){if(Object.prototype.hasOwnProperty.call(s,t)||t==="constructor")return s[t];let n=e();return s[t]=n,n}function Dd(s,t,e){let{_proxy:n,_context:i,_subProxy:o,_descriptors:r}=s,a=n[t];return oe(a)&&r.isScriptable(t)&&(a=Td(t,a,s,e)),ct(a)&&a.length&&(a=Ld(t,a,s,r.isIndexable)),Hi(t,a)&&(a=Le(a,i,o&&o[t],r)),a}function Td(s,t,e,n){let{_proxy:i,_context:o,_subProxy:r,_stack:a}=e;if(a.has(s))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+s);a.add(s);let l=t(o,r||n);return a.delete(s),Hi(s,l)&&(l=$i(i._scopes,i,s,l)),l}function Ld(s,t,e,n){let{_proxy:i,_context:o,_subProxy:r,_descriptors:a}=e;if(typeof o.index!="undefined"&&n(s))return t[o.index%t.length];if(et(t[0])){let l=t,c=i._scopes.filter(d=>d!==l);t=[];for(let d of l){let h=$i(c,i,s,d);t.push(Le(h,o,r&&r[s],a))}}return t}function Gr(s,t,e){return oe(s)?s(t,e):s}function Pd(s,t,e,n,i){for(let o of t){let r=Ad(e,o);if(r){s.add(r);let a=Gr(r._fallback,e,i);if(typeof a!="undefined"&&a!==e&&a!==n)return a}else if(r===!1&&typeof n!="undefined"&&e!==n)return null}return!1}function $i(s,t,e,n){let i=t._rootScopes,o=Gr(t._fallback,e,n),r=[...s,...i],a=new Set;a.add(n);let l=Er(a,r,e,o||e,n);return l===null||typeof o!="undefined"&&o!==e&&(l=Er(a,r,o,l,n),l===null)?!1:Rn(Array.from(a),[""],i,o,()=>Rd(t,e,n))}function Er(s,t,e,n,i){for(;e;)e=Pd(s,t,e,n,i);return e}function Rd(s,t,e){let n=s._getTarget();t in n||(n[t]={});let i=n[t];return ct(i)&&et(e)?e:i||{}}function Od(s,t,e,n){let i;for(let o of t)if(i=qr(Md(o,s),e),typeof i!="undefined")return Hi(s,i)?$i(e,n,s,i):i}function qr(s,t){for(let e of t){if(!e)continue;let n=e[s];if(typeof n!="undefined")return n}}function wr(s){let t=s._keys;return t||(t=s._keys=Fd(s._scopes)),t}function Fd(s){let t=new Set;for(let e of s)for(let n of Object.keys(e).filter(i=>!i.startsWith("_")))t.add(n);return Array.from(t)}function Wi(s,t,e,n){let{iScale:i}=s,{key:o="r"}=this._parsing,r=new Array(n),a,l,c,d;for(a=0,l=n;a!c.skip)),t.cubicInterpolationMode==="monotone")zd(s,i);else{let c=n?s[s.length-1]:s[0];for(o=0,r=s.length;ol.height&&(d=l.height,c=ge(Math.floor(d*n))),{width:c,height:d}}function ji(s,t,e){let n=t||1,i=ge(s.height*n),o=ge(s.width*n);s.height=ge(s.height),s.width=ge(s.width);let r=s.canvas;return r.style&&(e||!r.style.height&&!r.style.width)&&(r.style.height=`${s.height}px`,r.style.width=`${s.width}px`),s.currentDevicePixelRatio!==n||r.height!==i||r.width!==o?(s.currentDevicePixelRatio=n,r.height=i,r.width=o,s.ctx.setTransform(n,0,0,n,0,0),!0):!1}function Ui(s,t){let e=$d(s,t),n=e&&e.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}function pe(s,t,e,n){return{x:s.x+e*(t.x-s.x),y:s.y+e*(t.y-s.y)}}function ta(s,t,e,n){return{x:s.x+e*(t.x-s.x),y:n==="middle"?e<.5?s.y:t.y:n==="after"?e<1?s.y:t.y:e>0?t.y:s.y}}function ea(s,t,e,n){let i={x:s.cp2x,y:s.cp2y},o={x:t.cp1x,y:t.cp1y},r=pe(s,i,e),a=pe(i,o,e),l=pe(o,t,e),c=pe(r,a,e),d=pe(a,l,e);return pe(c,d,e)}function Pe(s,t,e){return s?Yd(t,e):Gd()}function Ki(s,t){let e,n;(t==="ltr"||t==="rtl")&&(e=s.canvas.style,n=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),s.prevTextDirection=n)}function Yi(s,t){t!==void 0&&(delete s.prevTextDirection,s.canvas.style.setProperty("direction",t[0],t[1]))}function sa(s){return s==="angle"?{between:ss,compare:hd,normalize:xt}:{between:Zt,compare:(t,e)=>t-e,normalize:t=>t}}function kr({start:s,end:t,count:e,loop:n,style:i}){return{start:s%e,end:t%e,loop:n&&(t-s+1)%e===0,style:i}}function qd(s,t,e){let{property:n,start:i,end:o}=e,{between:r,normalize:a}=sa(n),l=t.length,{start:c,end:d,loop:h}=s,u,f;if(h){for(c+=l,d+=l,u=0,f=l;ul(i,_,m)&&a(i,_)!==0,S=()=>a(o,m)===0||l(o,_,m),y=()=>g||w(),v=()=>!g||S();for(let C=d,M=d;C<=h;++C)x=t[C%r],!x.skip&&(m=c(x[n]),m!==_&&(g=l(m,i,o),b===null&&y()&&(b=a(m,i)===0?C:M),b!==null&&v()&&(p.push(kr({start:b,end:C,loop:u,count:r,style:f})),b=null),M=C,_=m));return b!==null&&p.push(kr({start:b,end:h,loop:u,count:r,style:f})),p}function qi(s,t){let e=[],n=s.segments;for(let i=0;ii&&s[o%t].skip;)o--;return o%=t,{start:i,end:o}}function Qd(s,t,e,n){let i=s.length,o=[],r=t,a=s[t],l;for(l=t+1;l<=e;++l){let c=s[l%i];c.skip||c.stop?a.skip||(n=!1,o.push({start:t%i,end:(l-1)%i,loop:n}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%i,end:r%i,loop:n}),o}function na(s,t){let e=s.points,n=s.options.spanGaps,i=e.length;if(!i)return[];let o=!!s._loop,{start:r,end:a}=Xd(e,i,o,n);if(n===!0)return Mr(s,[{start:r,end:a,loop:o}],e,t);let l=a{vr();Tr=(()=>{let s=0;return()=>s++})();Lr=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100:+s/t,Si=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100*t:+s;yr={"":s=>s,x:s=>s.x,y:s=>s.y};ts=s=>typeof s!="undefined",oe=s=>typeof s=="function",Ei=(s,t)=>{if(s.size!==t.size)return!1;for(let e of s)if(!t.has(e))return!1;return!0};nt=Math.PI,dt=2*nt,ld=dt+nt,Sn=Number.POSITIVE_INFINITY,cd=nt/180,mt=nt/2,De=nt/4,xr=nt*2/3,re=Math.log10,Wt=Math.sign;qt=(s,t,e,n)=>Dn(s,e,n?i=>{let o=s[i][t];return os[i][t]Dn(s,e,n=>s[n][t]>=e);Nr=["push","pop","shift","splice","unshift"];Ai=function(){return typeof window=="undefined"?function(s){return s()}:window.requestAnimationFrame}();Tn=s=>s==="start"?"left":s==="end"?"right":"center",_t=(s,t,e)=>s==="start"?t:s==="end"?e:(t+e)/2,Hr=(s,t,e,n)=>s===(n?"left":"right")?e:s==="center"?(t+e)/2:t;yn=s=>s===0||s===1,_r=(s,t,e)=>-(Math.pow(2,10*(s-=1))*Math.sin((s-t)*dt/e)),Cr=(s,t,e)=>Math.pow(2,-10*s)*Math.sin((s-t)*dt/e)+1,Xe={linear:s=>s,easeInQuad:s=>s*s,easeOutQuad:s=>-s*(s-2),easeInOutQuad:s=>(s/=.5)<1?.5*s*s:-.5*(--s*(s-2)-1),easeInCubic:s=>s*s*s,easeOutCubic:s=>(s-=1)*s*s+1,easeInOutCubic:s=>(s/=.5)<1?.5*s*s*s:.5*((s-=2)*s*s+2),easeInQuart:s=>s*s*s*s,easeOutQuart:s=>-((s-=1)*s*s*s-1),easeInOutQuart:s=>(s/=.5)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2),easeInQuint:s=>s*s*s*s*s,easeOutQuint:s=>(s-=1)*s*s*s*s+1,easeInOutQuint:s=>(s/=.5)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2),easeInSine:s=>-Math.cos(s*mt)+1,easeOutSine:s=>Math.sin(s*mt),easeInOutSine:s=>-.5*(Math.cos(nt*s)-1),easeInExpo:s=>s===0?0:Math.pow(2,10*(s-1)),easeOutExpo:s=>s===1?1:-Math.pow(2,-10*s)+1,easeInOutExpo:s=>yn(s)?s:s<.5?.5*Math.pow(2,10*(s*2-1)):.5*(-Math.pow(2,-10*(s*2-1))+2),easeInCirc:s=>s>=1?s:-(Math.sqrt(1-s*s)-1),easeOutCirc:s=>Math.sqrt(1-(s-=1)*s),easeInOutCirc:s=>(s/=.5)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1),easeInElastic:s=>yn(s)?s:_r(s,.075,.3),easeOutElastic:s=>yn(s)?s:Cr(s,.075,.3),easeInOutElastic(s){return yn(s)?s:s<.5?.5*_r(s*2,.1125,.45):.5+.5*Cr(s*2-1,.1125,.45)},easeInBack(s){return s*s*((1.70158+1)*s-1.70158)},easeOutBack(s){return(s-=1)*s*((1.70158+1)*s+1.70158)+1},easeInOutBack(s){let t=1.70158;return(s/=.5)<1?.5*(s*s*(((t*=1.525)+1)*s-t)):.5*((s-=2)*s*(((t*=1.525)+1)*s+t)+2)},easeInBounce:s=>1-Xe.easeOutBounce(1-s),easeOutBounce(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},easeInOutBounce:s=>s<.5?Xe.easeInBounce(s*2)*.5:Xe.easeOutBounce(s*2-1)*.5+.5};ud=["x","y","borderWidth","radius","tension"],fd=["color","borderColor","backgroundColor"];Sr=new Map;$r={values(s){return ct(s)?s:""+s},numeric(s,t,e){if(s===0)return"0";let n=this.chart.options.locale,i,o=s;if(e.length>1){let c=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(c<1e-4||c>1e15)&&(i="scientific"),o=bd(s,e)}let r=re(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:i,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),ns(s,n,l)},logarithmic(s,t,e){if(s===0)return"0";let n=e[t].significand||s/Math.pow(10,Math.floor(re(s)));return[1,2,3,5,10,15].includes(n)||t>.8*e.length?$r.numeric.call(this,s,t,e):""}};is={formatters:$r};me=Object.create(null),Ln=Object.create(null);Ci=class{constructor(t,e){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=n=>n.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=(n,i)=>xi(i.backgroundColor),this.hoverBorderColor=(n,i)=>xi(i.borderColor),this.hoverColor=(n,i)=>xi(i.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 _i(this,t,e)}get(t){return Ls(this,t)}describe(t,e){return _i(Ln,t,e)}override(t,e){return _i(me,t,e)}route(t,e,n,i){let o=Ls(this,t),r=Ls(this,n),a="_"+e;Object.defineProperties(o,{[a]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let l=this[a],c=r[i];return et(l)?Object.assign({},c,l):Z(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(e=>e(this))}},ht=new Ci({_scriptable:s=>!s.startsWith("on"),_indexable:s=>s!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[pd,gd,vd]);Sd=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Ed=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;kd=s=>+s||0;Md=(s,t)=>s?s+kn(t):t,Hi=(s,t)=>et(t)&&s!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);Ad=(s,t)=>s===!0?t:typeof s=="string"?ae(t,s):void 0;Id=Number.EPSILON||1e-14,Ze=(s,t)=>ts==="x"?"y":"x";In=s=>s.ownerDocument.defaultView.getComputedStyle(s,null);Wd=["top","right","bottom","left"];jd=(s,t,e)=>(s>0||t>0)&&(!e||!e.shadowRoot);ge=s=>Math.round(s*10)/10;Jr=function(){let s=!1;try{let t={get passive(){return s=!0,!1}};On()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch(t){}return s}();Yd=function(s,t){return{x(e){return s+s+t-e},setWidth(e){t=e},textAlign(e){return e==="center"?e:e==="right"?"left":"right"},xPlus(e,n){return e-n},leftForLtr(e,n){return e-n}}},Gd=function(){return{x(s){return s},setWidth(s){},textAlign(s){return s},xPlus(s,t){return s+t},leftForLtr(s,t){return s}}}});var Nl={};Eo(Nl,{Animation:()=>Un,Animations:()=>Ws,ArcElement:()=>_e,BarController:()=>Fe,BarElement:()=>He,BasePlatform:()=>js,BasicPlatform:()=>Kn,BubbleController:()=>Ie,CategoryScale:()=>ds,Chart:()=>ee,Colors:()=>El,DatasetController:()=>Tt,Decimation:()=>kl,DomPlatform:()=>Gn,DoughnutController:()=>se,Element:()=>At,Filler:()=>Dl,Interaction:()=>ll,Legend:()=>Ll,LineController:()=>Ve,LineElement:()=>Ut,LinearScale:()=>hs,LogarithmicScale:()=>us,PieController:()=>ls,PointElement:()=>ze,PolarAreaController:()=>Se,RadarController:()=>Ne,RadialLinearScale:()=>Ce,Scale:()=>ke,ScatterController:()=>Be,SubTitle:()=>Pl,Ticks:()=>is,TimeScale:()=>we,TimeSeriesScale:()=>fs,Title:()=>Al,Tooltip:()=>Ol,_adapters:()=>al,_detectPlatform:()=>fl,animator:()=>te,controllers:()=>rl,defaults:()=>ht,elements:()=>_l,layouts:()=>St,plugins:()=>Fl,registerables:()=>ep,registry:()=>jt,scales:()=>Vl});function sh(s,t){let e=[],n=Object.keys(t);for(let i=0;i0||!e&&o<0)return i.index}return null}function ca(s,t){let{chart:e,_cachedMeta:n}=s,i=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=n,l=o.axis,c=r.axis,d=ah(o,r,n),h=t.length,u;for(let f=0;fe[n].axis===t).shift()}function dh(s,t){return le(s,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function hh(s,t,e){return le(s,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Fs(s,t){let e=s.controller.index,n=s.vScale&&s.vScale.axis;if(n){t=t||s._parsed;for(let i of t){let o=i._stacks;if(!o||o[n]===void 0||o[n][e]===void 0)return;delete o[n][e],o[n]._visualValues!==void 0&&o[n]._visualValues[e]!==void 0&&delete o[n]._visualValues[e]}}}function fh(s,t){if(!s._cache.$bar){let e=s.getMatchingVisibleMetas(t),n=[];for(let i=0,o=e.length;ii-o))}return s._cache.$bar}function ph(s){let t=s.iScale,e=fh(t,s.type),n=t._length,i,o,r,a,l=()=>{r===32767||r===-32768||(ts(a)&&(n=Math.min(n,Math.abs(r-a)||n)),a=r)};for(i=0,o=e.length;i0?i[s-1]:null,a=sMath.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:i,end:o,min:r,max:a}}function ol(s,t,e,n){return ct(s)?bh(s,t,e,n):t[e.axis]=e.parse(s,n),t}function ha(s,t,e,n){let i=s.iScale,o=s.vScale,r=i.getLabels(),a=i===o,l=[],c,d,h,u;for(c=e,d=e+n;c=e?1:-1)}function yh(s){let t,e,n,i,o;return s.horizontal?(t=s.base>s.x,e="left",n="right"):(t=s.basess(_,a,l,!0)?1:Math.max(w,w*e,S,S*e),p=(_,w,S)=>ss(_,a,l,!0)?-1:Math.min(w,w*e,S,S*e),g=f(0,c,h),b=f(mt,d,u),m=p(nt,c,h),x=p(nt+mt,d,u);n=(g-m)/2,i=(b-x)/2,o=-(g+m)/2,r=-(b+x)/2}return{ratioX:n,ratioY:i,offsetX:o,offsetY:r}}function Re(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}function Eh(s,t,e,n){let{controller:i,data:o,_sorted:r}=s,a=i._cachedMeta.iScale,l=s.dataset&&s.dataset.options?s.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){let c=a._reversePixels?Ir:qt;if(n){if(i._sharedOptions){let d=o[0],h=typeof d.getRange=="function"&&d.getRange(t);if(h){let u=c(o,t,e-h),f=c(o,t,e+h);return{lo:u.lo,hi:f.hi}}}}else{let d=c(o,t,e);if(l){let{vScale:h}=i._cachedMeta,{_parsed:u}=s,f=u.slice(0,d.lo+1).reverse().findIndex(g=>!tt(g[h.axis]));d.lo-=Math.max(0,f);let p=u.slice(d.hi).findIndex(g=>!tt(g[h.axis]));d.hi+=Math.max(0,p)}return d}}return{lo:0,hi:o.length-1}}function Gs(s,t,e,n,i){let o=s.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a{l[r]&&l[r](t[e],i)&&(o.push({element:l,datasetIndex:c,index:d}),a=a||l.inRange(t.x,t.y,i))}),n&&!a?[]:o}function Is(s,t){return s.filter(e=>e.pos===t)}function ga(s,t){return s.filter(e=>cl.indexOf(e.pos)===-1&&e.box.axis===t)}function Vs(s,t){return s.sort((e,n)=>{let i=t?n:e,o=t?e:n;return i.weight===o.weight?i.index-o.index:i.weight-o.weight})}function Dh(s){let t=[],e,n,i,o,r,a;for(e=0,n=(s||[]).length;ec.box.fullSize),!0),n=Vs(Is(t,"left"),!0),i=Vs(Is(t,"right")),o=Vs(Is(t,"top"),!0),r=Vs(Is(t,"bottom")),a=ga(t,"x"),l=ga(t,"y");return{fullSize:e,leftAndTop:n.concat(o),rightAndBottom:i.concat(l).concat(r).concat(a),chartArea:Is(t,"chartArea"),vertical:n.concat(i).concat(l),horizontal:o.concat(r).concat(a)}}function ma(s,t,e,n){return Math.max(s[e],t[e])+Math.max(s[n],t[n])}function dl(s,t){s.top=Math.max(s.top,t.top),s.left=Math.max(s.left,t.left),s.bottom=Math.max(s.bottom,t.bottom),s.right=Math.max(s.right,t.right)}function Ph(s,t,e,n){let{pos:i,box:o}=e,r=s.maxPadding;if(!et(i)){e.size&&(s[i]-=e.size);let h=n[e.stack]||{size:0,count:1};h.size=Math.max(h.size,e.horizontal?o.height:o.width),e.size=h.size/h.count,s[i]+=e.size}o.getPadding&&dl(r,o.getPadding());let a=Math.max(0,t.outerWidth-ma(r,s,"left","right")),l=Math.max(0,t.outerHeight-ma(r,s,"top","bottom")),c=a!==s.w,d=l!==s.h;return s.w=a,s.h=l,e.horizontal?{same:c,other:d}:{same:d,other:c}}function Rh(s){let t=s.maxPadding;function e(n){let i=Math.max(t[n]-s[n],0);return s[n]+=i,i}s.y+=e("top"),s.x+=e("left"),e("right"),e("bottom")}function Oh(s,t){let e=t.maxPadding;function n(i){let o={left:0,top:0,right:0,bottom:0};return i.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return n(s?["left","right"]:["top","bottom"])}function zs(s,t,e,n){let i=[],o,r,a,l,c,d;for(o=0,r=s.length,c=0;o{let r=!1;for(let a of o)r=r||Yn(a.addedNodes,n),r=r&&!Yn(a.removedNodes,n);r&&e()});return i.observe(document,{childList:!0,subtree:!0}),i}function Hh(s,t,e){let n=s.canvas,i=new MutationObserver(o=>{let r=!1;for(let a of o)r=r||Yn(a.removedNodes,n),r=r&&!Yn(a.addedNodes,n);r&&e()});return i.observe(document,{childList:!0,subtree:!0}),i}function ul(){let s=window.devicePixelRatio;s!==ya&&(ya=s,Us.forEach((t,e)=>{e.currentDevicePixelRatio!==s&&t()}))}function $h(s,t){Us.size||window.addEventListener("resize",ul),Us.set(s,t)}function Wh(s){Us.delete(s),Us.size||window.removeEventListener("resize",ul)}function jh(s,t,e){let n=s.canvas,i=n&&Fn(n);if(!i)return;let o=Pi((a,l)=>{let c=i.clientWidth;e(a,l),c{let l=a[0],c=l.contentRect.width,d=l.contentRect.height;c===0&&d===0||o(c,d)});return r.observe(i),$h(s,o),r}function no(s,t,e){e&&e.disconnect(),t==="resize"&&Wh(s)}function Uh(s,t,e){let n=s.canvas,i=Pi(o=>{s.ctx!==null&&e(Bh(o,s))},s);return Vh(n,t,i),i}function fl(s){return!On()||typeof OffscreenCanvas!="undefined"&&s instanceof OffscreenCanvas?Kn:Gn}function Kh(s,t){let e=s.options.ticks,n=Yh(s),i=Math.min(e.maxTicksLimit||n,n),o=e.major.enabled?qh(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>i)return Xh(t,c,o,r/i),c;let d=Gh(o,t,i);if(r>0){let h,u,f=r>1?Math.round((l-a)/(r-1)):null;for(Nn(t,c,d,tt(f)?0:a-f,a),h=0,u=r-1;hi)return l}return Math.max(i,1)}function qh(s){let t=[],e,n;for(e=0,n=s.length;er+a)))return l}function tu(s,t){rt(s,e=>{let n=e.gc,i=n.length/2,o;if(i>t){for(o=0;o{let n=e.split("."),i=n.pop(),o=[s].concat(n).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");ht.route(o,i,l,a)})}function au(s){return"id"in s&&"defaults"in s}function lu(s){let t={},e=[],n=Object.keys(jt.plugins.items);for(let o=0;o1&&Ea(s[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${s}' axis. Please provide 'axis' or 'position' option.`)}function wa(s,t,e){if(e[t+"AxisID"]===s)return{axis:t}}function gu(s,t){if(t.data&&t.data.datasets){let e=t.data.datasets.filter(n=>n.xAxisID===s||n.yAxisID===s);if(e.length)return wa(s,"x",e[0])||wa(s,"y",e[0])}return{}}function mu(s,t){let e=me[s.type]||{scales:{}},n=t.scales||{},i=fo(s.type,t),o=Object.create(null);return Object.keys(n).forEach(r=>{let a=n[r];if(!et(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);let l=po(r,a,gu(r,s),ht.scales[a.type]),c=fu(l,i),d=e.scales||{};o[r]=Je(Object.create(null),[{axis:l},a,d[l],d[c]])}),s.data.datasets.forEach(r=>{let a=r.type||s.type,l=r.indexAxis||fo(a,t),d=(me[a]||{}).scales||{};Object.keys(d).forEach(h=>{let u=uu(h,l),f=r[u+"AxisID"]||u;o[f]=o[f]||Object.create(null),Je(o[f],[{axis:u},n[f],d[h]])})}),Object.keys(o).forEach(r=>{let a=o[r];Je(a,[ht.scales[a.type],ht.scale])}),o}function pl(s){let t=s.options||(s.options={});t.plugins=Z(t.plugins,{}),t.scales=mu(s,t)}function gl(s){return s=s||{},s.datasets=s.datasets||[],s.labels=s.labels||[],s}function bu(s){return s=s||{},s.data=gl(s.data),pl(s),s}function Bn(s,t){let e=ka.get(s);return e||(e=t(),ka.set(s,e),ml.add(e)),e}function Ma(s,t,e){let n=s.get(t);n||(n=new Map,s.set(t,n));let i=e.join(),o=n.get(i);return o||(o={resolver:Rn(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},n.set(i,o)),o}function yu(s,t){let{isScriptable:e,isIndexable:n}=zi(s);for(let i of t){let o=e(i),r=n(i),a=(r||o)&&s[i];if(o&&(oe(a)||vu(a))||r&&ct(a))return!0}return!1}function Da(s,t){return s==="top"||s==="bottom"||_u.indexOf(s)===-1&&t==="x"}function Ta(s,t){return function(e,n){return e[s]===n[s]?e[t]-n[t]:e[s]-n[s]}}function La(s){let t=s.chart,e=t.options.animation;t.notifyPlugins("afterRender"),lt(e&&e.onComplete,[s],t)}function Cu(s){let t=s.chart,e=t.options.animation;lt(e&&e.onProgress,[s],t)}function bl(s){return On()&&typeof s=="string"?s=document.getElementById(s):s&&s.length&&(s=s[0]),s&&s.canvas&&(s=s.canvas),s}function Su(s,t,e){let n=Object.keys(s);for(let i of n){let o=+i;if(o>=t){let r=s[i];delete s[i],(e>0||o>t)&&(s[o+e]=r)}}}function Eu(s,t,e,n){return!e||s.type==="mouseout"?null:n?t:s}function Pa(){return rt(ee.instances,s=>s._plugins.invalidate())}function wu(s,t,e){let{startAngle:n,x:i,y:o,outerRadius:r,innerRadius:a,options:l}=t,{borderWidth:c,borderJoinStyle:d}=l,h=Math.min(c/r,xt(n-e));if(s.beginPath(),s.arc(i,o,r-c/2,n+h/2,e-h/2),a>0){let u=Math.min(c/a,xt(n-e));s.arc(i,o,a+c/2,e-u/2,n+u/2,!0)}else{let u=Math.min(c/2,r*xt(n-e));if(d==="round")s.arc(i,o,u,e-nt/2,n+nt/2,!0);else if(d==="bevel"){let f=2*u*u,p=-f*Math.cos(e+nt/2)+i,g=-f*Math.sin(e+nt/2)+o,b=f*Math.cos(n+nt/2)+i,m=f*Math.sin(n+nt/2)+o;s.lineTo(p,g),s.lineTo(b,m)}}s.closePath(),s.moveTo(0,0),s.rect(0,0,s.canvas.width,s.canvas.height),s.clip("evenodd")}function ku(s,t,e){let{startAngle:n,pixelMargin:i,x:o,y:r,outerRadius:a,innerRadius:l}=t,c=i/a;s.beginPath(),s.arc(o,r,a,n-c,e+c),l>i?(c=i/l,s.arc(o,r,l,e+c,n-c,!0)):s.arc(o,r,i,e+mt,n-mt),s.closePath(),s.clip()}function Mu(s){return Pn(s,["outerStart","outerEnd","innerStart","innerEnd"])}function Du(s,t,e,n){let i=Mu(s.options.borderRadius),o=(e-t)/2,r=Math.min(o,n*t/2),a=l=>{let c=(e-Math.min(o,l))*n/2;return vt(l,0,Math.min(o,c))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:vt(i.innerStart,0,r),innerEnd:vt(i.innerEnd,0,r)}}function as(s,t,e,n){return{x:e+s*Math.cos(t),y:n+s*Math.sin(t)}}function qn(s,t,e,n,i,o){let{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:d}=t,h=Math.max(t.outerRadius+n+e-c,0),u=d>0?d+n+e+c:0,f=0,p=i-l;if(n){let P=d>0?d-n:0,I=h>0?h-n:0,z=(P+I)/2,F=z!==0?p*z/(z+n):p;f=(p-F)/2}let g=Math.max(.001,p*h-e/nt)/h,b=(p-g)/2,m=l+b+f,x=i-b-f,{outerStart:_,outerEnd:w,innerStart:S,innerEnd:y}=Du(t,u,h,x-m),v=h-_,C=h-w,M=m+_/v,D=x-w/C,E=u+S,L=u+y,k=m+S/E,A=x-y/L;if(s.beginPath(),o){let P=(M+D)/2;if(s.arc(r,a,h,M,P),s.arc(r,a,h,P,D),w>0){let N=as(C,D,r,a);s.arc(N.x,N.y,w,D,x+mt)}let I=as(L,x,r,a);if(s.lineTo(I.x,I.y),y>0){let N=as(L,A,r,a);s.arc(N.x,N.y,y,x+mt,A+Math.PI)}let z=(x-y/u+(m+S/u))/2;if(s.arc(r,a,u,x-y/u,z,!0),s.arc(r,a,u,z,m+S/u,!0),S>0){let N=as(E,k,r,a);s.arc(N.x,N.y,S,k+Math.PI,m-mt)}let F=as(v,m,r,a);if(s.lineTo(F.x,F.y),_>0){let N=as(v,M,r,a);s.arc(N.x,N.y,_,m-mt,M)}}else{s.moveTo(r,a);let P=Math.cos(M)*h+r,I=Math.sin(M)*h+a;s.lineTo(P,I);let z=Math.cos(D)*h+r,F=Math.sin(D)*h+a;s.lineTo(z,F)}s.closePath()}function Tu(s,t,e,n,i){let{fullCircles:o,startAngle:r,circumference:a}=t,l=t.endAngle;if(o){qn(s,t,e,n,l,i);for(let c=0;c=nt&&f===0&&d!=="miter"&&wu(s,t,g),o||(qn(s,t,e,n,g,i),s.stroke())}function vl(s,t,e=t){s.lineCap=Z(e.borderCapStyle,t.borderCapStyle),s.setLineDash(Z(e.borderDash,t.borderDash)),s.lineDashOffset=Z(e.borderDashOffset,t.borderDashOffset),s.lineJoin=Z(e.borderJoinStyle,t.borderJoinStyle),s.lineWidth=Z(e.borderWidth,t.borderWidth),s.strokeStyle=Z(e.borderColor,t.borderColor)}function Au(s,t,e){s.lineTo(e.x,e.y)}function Pu(s){return s.stepped?jr:s.tension||s.cubicInterpolationMode==="monotone"?Ur:Au}function yl(s,t,e={}){let n=s.length,{start:i=0,end:o=n-1}=e,{start:r,end:a}=t,l=Math.max(i,r),c=Math.min(o,a),d=ia&&o>a;return{count:n,start:l,loop:t.loop,ilen:c(r+(c?a-w:w))%o,_=()=>{g!==b&&(s.lineTo(d,b),s.lineTo(d,g),s.lineTo(d,m))};for(l&&(f=i[x(0)],s.moveTo(f.x,f.y)),u=0;u<=a;++u){if(f=i[x(u)],f.skip)continue;let w=f.x,S=f.y,y=w|0;y===p?(Sb&&(b=S),d=(h*d+w)/++h):(_(),s.lineTo(w,S),p=y,h=0,g=b=S),m=S}_()}function mo(s){let t=s.options,e=t.borderDash&&t.borderDash.length;return!s._decimated&&!s._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?Ou:Ru}function Fu(s){return s.stepped?ta:s.tension||s.cubicInterpolationMode==="monotone"?ea:pe}function Iu(s,t,e,n){let i=t._path;i||(i=t._path=new Path2D,t.path(i,e,n)&&i.closePath()),vl(s,t.options),s.stroke(i)}function Vu(s,t,e,n){let{segments:i,options:o}=t,r=mo(t);for(let a of i)vl(s,o,a.style),s.beginPath(),r(s,t,a,{start:e,end:e+n-1})&&s.closePath(),s.stroke()}function Bu(s,t,e,n){Nu&&!t.options.segment?Iu(s,t,e,n):Vu(s,t,e,n)}function Ra(s,t,e,n){let i=s.options,{[e]:o}=s.getProps([e],n);return Math.abs(t-o)Cl(t++)),t}function Yu(s,t){return s.backgroundColor=s.data.map(()=>Sl(t++)),t}function Gu(s){let t=0;return(e,n)=>{let i=s.getDatasetMeta(n).controller;i instanceof se?t=Ku(e,t):i instanceof Se?t=Yu(e,t):i&&(t=Uu(e,t))}}function Fa(s){let t;for(t in s)if(s[t].borderColor||s[t].backgroundColor)return!0;return!1}function qu(s){return s&&(s.borderColor||s.backgroundColor)}function Xu(){return ht.borderColor!=="rgba(0,0,0,0.1)"||ht.backgroundColor!=="rgba(0,0,0,0.1)"}function Qu(s,t,e,n,i){let o=i.samples||n;if(o>=e)return s.slice(t,t+e);let r=[],a=(e-2)/(o-2),l=0,c=t+e-1,d=t,h,u,f,p,g;for(r[l++]=s[d],h=0;hf&&(f=p,u=s[x],g=x);r[l++]=u,d=g}return r[l++]=s[c],r}function Zu(s,t,e,n){let i=0,o=0,r,a,l,c,d,h,u,f,p,g,b=[],m=t+e-1,x=s[t].x,w=s[m].x-x;for(r=t;rg&&(g=c,u=r),i=(o*i+a.x)/++o;else{let y=r-1;if(!tt(h)&&!tt(u)){let v=Math.min(h,u),C=Math.max(h,u);v!==f&&v!==y&&b.push({...s[v],x:i}),C!==f&&C!==y&&b.push({...s[C],x:i})}r>0&&y!==f&&b.push(s[y]),b.push(a),d=S,o=0,p=g=c,h=u=f=r}}return b}function wl(s){if(s._decimated){let t=s._data;delete s._decimated,delete s._data,Object.defineProperty(s,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Ia(s){s.data.datasets.forEach(t=>{wl(t)})}function Ju(s,t){let e=t.length,n=0,i,{iScale:o}=s,{min:r,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(n=vt(qt(t,o.axis,r).lo,0,e-1)),c?i=vt(qt(t,o.axis,a).hi+1,n,e)-n:i=e-n,{start:n,count:i}}function tf(s,t,e){let n=s.segments,i=s.points,o=t.points,r=[];for(let a of n){let{start:l,end:c}=a;c=Zn(l,c,i);let d=vo(e,i[l],i[c],a.loop);if(!t.segments){r.push({source:a,target:d,start:i[l],end:i[c]});continue}let h=qi(t,d);for(let u of h){let f=vo(e,o[u.start],o[u.end],u.loop),p=Gi(a,i,f);for(let g of p)r.push({source:g,target:u,start:{[e]:Va(d,f,"start",Math.max)},end:{[e]:Va(d,f,"end",Math.min)}})}}return r}function vo(s,t,e,n){if(n)return;let i=t[s],o=e[s];return s==="angle"&&(i=xt(i),o=xt(o)),{property:s,start:i,end:o}}function ef(s,t){let{x:e=null,y:n=null}=s||{},i=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Zn(r,a,i);let l=i[r],c=i[a];n!==null?(o.push({x:l.x,y:n}),o.push({x:c.x,y:n})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function Zn(s,t,e){for(;t>s;t--){let n=e[t];if(!isNaN(n.x)&&!isNaN(n.y))break}return t}function Va(s,t,e,n){return s&&t?n(s[e],t[e]):s?s[e]:t?t[e]:0}function Ml(s,t){let e=[],n=!1;return ct(s)?(n=!0,e=s):e=ef(s,t),e.length?new Ut({points:e,options:{tension:0},_loop:n,_fullLoop:n}):null}function Na(s){return s&&s.fill!==!1}function sf(s,t,e){let i=s[t].fill,o=[t],r;if(!e)return i;for(;i!==!1&&o.indexOf(i)===-1;){if(!pt(i))return i;if(r=s[i],!r)return!1;if(r.visible)return i;o.push(i),i=r.fill}return!1}function nf(s,t,e){let n=lf(s);if(et(n))return isNaN(n.value)?!1:n;let i=parseFloat(n);return pt(i)&&Math.floor(i)===i?of(n[0],t,i,e):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function of(s,t,e,n){return(s==="-"||s==="+")&&(e=t+e),e===t||e<0||e>=n?!1:e}function rf(s,t){let e=null;return s==="start"?e=t.bottom:s==="end"?e=t.top:et(s)?e=t.getPixelForValue(s.value):t.getBasePixel&&(e=t.getBasePixel()),e}function af(s,t,e){let n;return s==="start"?n=e:s==="end"?n=t.options.reverse?t.min:t.max:et(s)?n=s.value:n=t.getBaseValue(),n}function lf(s){let t=s.options,e=t.fill,n=Z(e&&e.target,e);return n===void 0&&(n=!!t.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function cf(s){let{scale:t,index:e,line:n}=s,i=[],o=n.segments,r=n.points,a=df(t,e);a.push(Ml({x:null,y:t.bottom},n));for(let l=0;lo.length>r.length?o:r)),t+e.size/2+n.measureText(i).width}function Sf(s,t,e){let n=s;return typeof t.text!="string"&&(n=Tl(t,e)),n}function Tl(s,t){let e=s.text?s.text.length:0;return t*e}function Ef(s,t){return!!((s==="mousemove"||s==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(s==="click"||s==="mouseup"))}function wf(s,t){let e=new Ks({ctx:s.ctx,options:t,chart:s});St.configure(s,e,t),St.addBox(s,e),s.titleBlock=e}function Jt(s,t){return t&&(ct(t)?Array.prototype.push.apply(s,t):s.push(t)),s}function ce(s){return(typeof s=="string"||s instanceof String)&&s.indexOf(` `)>-1?s.split(` -`):s}function kf(s,t){let{element:e,datasetIndex:n,index:i}=t,o=s.getDatasetMeta(n).controller,{label:r,value:a}=o.getLabelAndValue(i);return{chart:s,label:r,parsed:o.getParsed(i),raw:s.data.datasets[n].data[i],formattedValue:a,dataset:o.getDataset(),dataIndex:i,datasetIndex:n,element:e}}function Wa(s,t){let e=s.chart.ctx,{body:n,footer:i,title:o}=s,{boxWidth:r,boxHeight:a}=t,l=bt(t.bodyFont),c=bt(t.titleFont),d=bt(t.footerFont),h=o.length,u=i.length,f=n.length,p=Ct(t.padding),g=p.height,m=0,b=n.reduce((E,S)=>E+S.before.length+S.lines.length+S.after.length,0);if(b+=s.beforeBody.length+s.afterBody.length,h&&(g+=h*c.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),b){let E=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;g+=f*E+(b-f)*l.lineHeight+(b-1)*t.bodySpacing}u&&(g+=t.footerMarginTop+u*d.lineHeight+(u-1)*t.footerSpacing);let x=0,_=function(E){m=Math.max(m,e.measureText(E).width+x)};return e.save(),e.font=c.string,rt(s.title,_),e.font=l.string,rt(s.beforeBody.concat(s.afterBody),_),x=t.displayColors?r+2+t.boxPadding:0,rt(n,E=>{rt(E.before,_),rt(E.lines,_),rt(E.after,_)}),x=0,e.font=d.string,rt(s.footer,_),e.restore(),m+=p.width,{width:m,height:g}}function Mf(s,t){let{y:e,height:n}=t;return es.height-n/2?"bottom":"center"}function Df(s,t,e,n){let{x:i,width:o}=n,r=e.caretSize+e.caretPadding;if(s==="left"&&i+o+r>t.width||s==="right"&&i-o-r<0)return!0}function Tf(s,t,e,n){let{x:i,width:o}=e,{width:r,chartArea:{left:a,right:l}}=s,c="center";return n==="center"?c=i<=(a+l)/2?"left":"right":i<=o/2?c="left":i>=r-o/2&&(c="right"),Df(c,s,t,e)&&(c="center"),c}function ja(s,t,e){let n=e.yAlign||t.yAlign||Mf(s,e);return{xAlign:e.xAlign||t.xAlign||Tf(s,t,e,n),yAlign:n}}function Lf(s,t){let{x:e,width:n}=s;return t==="right"?e-=n:t==="center"&&(e-=n/2),e}function Af(s,t,e){let{y:n,height:i}=s;return t==="top"?n+=e:t==="bottom"?n-=i+e:n-=i/2,n}function Ua(s,t,e,n){let{caretSize:i,caretPadding:o,cornerRadius:r}=s,{xAlign:a,yAlign:l}=e,c=i+o,{topLeft:d,topRight:h,bottomLeft:u,bottomRight:f}=ye(r),p=Lf(t,a),g=Af(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(d,u)+i:a==="right"&&(p+=Math.max(h,f)+i),{x:vt(p,0,n.width-t.width),y:vt(g,0,n.height-t.height)}}function Hn(s,t,e){let n=Ct(e.padding);return t==="center"?s.x+s.width/2:t==="right"?s.x+s.width-n.right:s.x+n.left}function Ka(s){return Jt([],ce(s))}function Pf(s,t,e){return le(s,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Ya(s,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?s.override(e):s}function Dt(s,t,e,n){let i=s[t].call(e,n);return typeof i=="undefined"?Rl[t].call(e,n):i}function Of(s,t,e,n){let i=s.indexOf(t);if(i===-1)return Rf(s,t,e,n);let o=s.lastIndexOf(t);return i!==o?e:i}function Ga(s){let t=this.getLabels();return s>=0&&sp&&(S=wi(D*S/p/f)*f),tt(l)||(v=Math.pow(10,l),S=Math.ceil(S*v)/v),i==="ticks"?(y=Math.floor(g/S)*S,C=Math.ceil(m/S)*S):(y=g,C=m),b&&x&&o&&Or((a-r)/o,S/1e3)?(D=Math.round(Math.min((a-r)/S,d)),S=(a-r)/D,y=r,C=a):_?(y=b?r:y,C=x?a:C,D=c-1,S=(C-y)/D):(D=(C-y)/S,es(D,Math.round(D),S/1e3)?D=Math.round(D):D=Math.ceil(D));let M=Math.max(Mi(S),Mi(y));v=Math.pow(10,tt(l)?M:l),y=Math.round(y*v)/v,C=Math.round(C*v)/v;let w=0;for(b&&(u&&y!==r?(e.push({value:r}),ya)break;e.push({value:L})}return x&&u&&C!==a?e.length&&es(e[e.length-1].value,a,qa(a,E,s))?e[e.length-1].value=a:e.push({value:a}):(!x||C===a)&&e.push({value:C}),e}function qa(s,t,{horizontal:e,minRotation:n}){let i=Ht(n),o=(e?Math.sin(i):Math.cos(i))||.001,r=.75*t*(""+s).length;return Math.min(t/o,r)}function Xa(s){return s/Math.pow(10,Ys(s))===1}function Qa(s,t,e){let n=Math.pow(10,e),i=Math.floor(s/n);return Math.ceil(t/n)-i}function Vf(s,t){let e=t-s,n=Ys(e);for(;Qa(s,t,n)>10;)n++;for(;Qa(s,t,n)<10;)n--;return Math.min(n,Ys(s))}function Nf(s,{min:t,max:e}){t=Mt(s.min,t);let n=[],i=Ys(t),o=Vf(t,e),r=o<0?Math.pow(10,Math.abs(o)):1,a=Math.pow(10,o),l=i>o?Math.pow(10,i):0,c=Math.round((t-l)*r)/r,d=Math.floor((t-l)/a/10)*a*10,h=Math.floor((c-d)/Math.pow(10,o)),u=Mt(s.min,Math.round((l+d+h*Math.pow(10,o))*r)/r);for(;u=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),u=Math.round((l+d+h*Math.pow(10,o))*r)/r;let f=Mt(s.max,u);return n.push({value:f,major:Xa(f),significand:h}),n}function yo(s){let t=s.ticks;if(t.display&&s.display){let e=Ct(t.backdropPadding);return Q(t.font&&t.font.size,ht.font.size)+e.height}return 0}function Bf(s,t,e){return e=ct(e)?e:[e],{w:Wr(s,t.string,e),h:e.length*t.lineHeight}}function Za(s,t,e,n,i){return s===n||s===i?{start:t-e/2,end:t+e/2}:si?{start:t-e,end:t}:{start:t,end:t+e}}function zf(s){let t={l:s.left+s._padding.left,r:s.right-s._padding.right,t:s.top+s._padding.top,b:s.bottom-s._padding.bottom},e=Object.assign({},t),n=[],i=[],o=s._pointLabels.length,r=s.options.pointLabels,a=r.centerPointLabels?nt/o:0;for(let l=0;lt.r&&(a=(n.end-t.r)/o,s.r=Math.max(s.r,t.r+a)),i.startt.b&&(l=(i.end-t.b)/r,s.b=Math.max(s.b,t.b+l))}function $f(s,t,e){let n=s.drawingArea,{extra:i,additionalAngle:o,padding:r,size:a}=e,l=s.getPointPosition(t,n+i+r,o),c=Math.round(Mn(xt(l.angle+mt))),d=Yf(l.y,a.h,c),h=Uf(c),u=Kf(l.x,a.w,h);return{visible:!0,x:l.x,y:d,textAlign:h,left:u,top:d,right:u+a.w,bottom:d+a.h}}function Wf(s,t){if(!t)return!0;let{left:e,top:n,right:i,bottom:o}=s;return!(Xt({x:e,y:n},t)||Xt({x:e,y:o},t)||Xt({x:i,y:n},t)||Xt({x:i,y:o},t))}function jf(s,t,e){let n=[],i=s._pointLabels.length,o=s.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:yo(o)/2,additionalAngle:r?nt/i:0},c;for(let d=0;d270||e<90)&&(s-=t),s}function Gf(s,t,e){let{left:n,top:i,right:o,bottom:r}=e,{backdropColor:a}=t;if(!tt(a)){let l=ye(t.borderRadius),c=Ct(t.backdropPadding);s.fillStyle=a;let d=n-c.left,h=i-c.top,u=o-n+c.width,f=r-i+c.height;Object.values(l).some(p=>p!==0)?(s.beginPath(),os(s,{x:d,y:h,w:u,h:f,radius:l}),s.fill()):s.fillRect(d,h,u,f)}}function qf(s,t){let{ctx:e,options:{pointLabels:n}}=s;for(let i=t-1;i>=0;i--){let o=s._pointLabelItems[i];if(!o.visible)continue;let r=n.setContext(s.getPointLabelContext(i));Gf(e,r,o);let a=bt(r.font),{x:l,y:c,textAlign:d}=o;ve(e,s._pointLabels[i],l,c+a.lineHeight/2,a,{color:r.color,textAlign:d,textBaseline:"middle"})}}function Il(s,t,e,n){let{ctx:i}=s;if(e)i.arc(s.xCenter,s.yCenter,t,0,dt);else{let o=s.getPointPosition(0,t);i.moveTo(o.x,o.y);for(let r=1;r=Lt.indexOf(e);o--){let r=Lt[o];if(Jn[r].common&&s._adapter.diff(i,n,r)>=t-1)return r}return Lt[e?Lt.indexOf(e):0]}function Jf(s){for(let t=Lt.indexOf(s)+1,e=Lt.length;t=t?e[n]:e[i];s[o]=!0}}function tp(s,t,e,n){let i=s._adapter,o=+i.startOf(t[0].value,n),r=t[t.length-1].value,a,l;for(a=o;a<=r;a=+i.add(a,1,n))l=e[a],l>=0&&(t[l].major=!0);return t}function nl(s,t,e){let n=[],i={},o=t.length,r,a;for(r=0;r=s[n].pos&&t<=s[i].pos&&({lo:n,hi:i}=qt(s,"pos",t)),{pos:o,time:a}=s[n],{pos:r,time:l}=s[i]):(t>=s[n].time&&t<=s[i].time&&({lo:n,hi:i}=qt(s,"time",t)),{time:o,pos:a}=s[n],{time:r,pos:l}=s[i]);let c=r-o;return c?a+(l-a)*(t-o)/c:a}var lo,te,oa,eh,Un,Ws,Ji,da,uh,Tt,Fe,Ie,se,Ve,Se,ls,Ne,Be,rl,co,al,ll,cl,St,js,Kn,Wn,Fh,va,hl,Us,ya,Gn,At,Zh,xa,_a,ke,cs,ho,jt,uo,ka,ml,Bs,go,vu,xu,_u,jn,Aa,ee,_e,Nu,Ut,ze,He,_l,bo,Oa,El,kl,Xn,Dl,$a,xf,Qn,Ll,Ks,Al,zn,Pl,Hs,Rl,$s,Ol,Fl,Rf,Ff,ds,ps,hs,Ys,Oe,us,Ce,Jn,Lt,we,fs,Vl,ep,Bl=si(()=>{ia();lo=class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,n,i){let o=e.listeners[i],r=e.duration;o.forEach(a=>a({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(n-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Ai.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((n,i)=>{if(!n.running||!n.items.length)return;let o=n.items,r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>n.duration&&(n.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(i.draw(),this._notify(i,n,t,"progress")),o.length||(n.running=!1,this._notify(i,n,t,"complete"),n.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){let e=this._charts,n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}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((n,i)=>Math.max(n,i._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 n=e.items,i=n.length-1;for(;i>=0;--i)n[i].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}},te=new lo,oa="transparent",eh={boolean(s,t,e){return e>.5?t:s},color(s,t,e){let n=Ii(s||oa),i=n.valid&&Ii(t||oa);return i&&i.valid?i.mix(n,e).hexString():t},number(s,t,e){return s+(t-s)*e}},Un=class{constructor(t,e,n,i){let o=e[n];i=rs([t.to,i,o,t.from]);let r=rs([t.from,o,i]);this._active=!0,this._fn=t.fn||eh[t.type||typeof r],this._easing=Xe[t.easing]||Xe.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=n,this._from=r,this._to=i,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);let i=this._target[this._prop],o=n-this._start,r=this._duration-o;this._start=n,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=rs([t.to,e,i,t.from]),this._from=rs([t.from,i,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let e=t-this._start,n=this._duration,i=this._prop,o=this._from,r=this._loop,a=this._to,l;if(this._active=o!==a&&(r||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[i]=this._fn(o,a,l)}wait(){let t=this._promises||(this._promises=[]);return new Promise((e,n)=>{t.push({res:e,rej:n})})}_notify(t){let e=t?"res":"rej",n=this._promises||[];for(let i=0;i{let o=t[i];if(!et(o))return;let r={};for(let a of e)r[a]=o[a];(ct(o.properties)&&o.properties||[i]).forEach(a=>{(a===i||!n.has(a))&&n.set(a,r)})})}_animateOptions(t,e){let n=e.options,i=nh(t,n);if(!i)return[];let o=this._createAnimations(i,n);return n.$shared&&sh(t.options.$animations,n).then(()=>{t.options=n},()=>{}),o}_createAnimations(t,e){let n=this._properties,i=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now(),l;for(l=r.length-1;l>=0;--l){let c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){i.push(...this._animateOptions(t,e));continue}let d=e[c],h=o[c],u=n.get(c);if(h)if(u&&h.active()){h.update(u,d,a);continue}else h.cancel();if(!u||!u.duration){t[c]=d;continue}o[c]=h=new Un(u,t,c,d),i.push(h)}return i}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}let n=this._createAnimations(t,e);if(n.length)return te.add(this._chart,n),!0}};Ji=s=>s==="reset"||s==="none",da=(s,t)=>t?s:Object.assign({},s),uh=(s,t,e)=>s&&!t.hidden&&t._stacked&&{keys:il(e,!0),values:null},Tt=class{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=Qi(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&&Fs(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,n=this.getDataset(),i=(h,u,f,p)=>h==="x"?u:h==="r"?p:f,o=e.xAxisID=Q(n.xAxisID,Zi(t,"x")),r=e.yAxisID=Q(n.yAxisID,Zi(t,"y")),a=e.rAxisID=Q(n.rAxisID,Zi(t,"r")),l=e.indexAxis,c=e.iAxisID=i(l,o,r,a),d=e.vAxisID=i(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(d)}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&&Ti(this._data,this),t._stacked&&Fs(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if(et(e)){let i=this._cachedMeta;this._data=rh(e,i)}else if(n!==e){if(n){Ti(n,this);let i=this._cachedMeta;Fs(i),i._parsed=[]}e&&Object.isExtensible(e)&&Br(e,this),this._syncList=[],this._data=e}}addElements(){let t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){let e=this._cachedMeta,n=this.getDataset(),i=!1;this._dataCheck();let o=e._stacked;e._stacked=Qi(e.vScale,e),e.stack!==n.stack&&(i=!0,Fs(e),e.stack=n.stack),this._resyncElements(t),(i||o!==e._stacked)&&(ca(this,e._parsed),e._stacked=Qi(e.vScale,e))}configure(){let t=this.chart.config,e=t.datasetScopeKeys(this._type),n=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){let{_cachedMeta:n,_data:i}=this,{iScale:o,_stacked:r}=n,a=o.axis,l=t===0&&e===i.length?!0:n._sorted,c=t>0&&n._parsed[t-1],d,h,u;if(this._parsing===!1)n._parsed=i,n._sorted=!0,u=i;else{ct(i[t])?u=this.parseArrayData(n,i,t,e):et(i[t])?u=this.parseObjectData(n,i,t,e):u=this.parsePrimitiveData(n,i,t,e);let f=()=>h[a]===null||c&&h[a]g||h=0;--u)if(!p()){this.updateRangeFromParsed(c,t,f,l);break}}return c}getAllParsedValues(t){let e=this._cachedMeta._parsed,n=[],i,o,r;for(i=0,o=e.length;i=0&&tthis.getContext(n,i,e),g=c.resolveNamedOptions(u,f,p,h);return g.$shared&&(g.$shared=l,o[r]=Object.freeze(da(g,l))),g}_resolveAnimations(t,e,n){let i=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(i.options.animation!==!1){let d=this.chart.config,h=d.datasetAnimationScopeKeys(this._type,e),u=d.getOptionScopes(this.getDataset(),h);l=d.createResolver(u,this.getContext(t,n,e))}let c=new Ws(i,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ji(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){let n=this.resolveDataElementOptions(t,e),i=this._sharedOptions,o=this.getSharedOptions(n),r=this.includeOptions(e,o)||o!==i;return this.updateSharedOptions(o,e,n),{sharedOptions:o,includeOptions:r}}updateElement(t,e,n,i){Ji(i)?Object.assign(t,n):this._resolveAnimations(e,i).update(t,n)}updateSharedOptions(t,e,n){t&&!Ji(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,i){t.active=i;let o=this.getStyle(e,i);this._resolveAnimations(e,n,i).update(t,{options:!i&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"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,n=this._cachedMeta.data;for(let[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];let i=n.length,o=e.length,r=Math.min(o,i);r&&this.parse(0,r),o>i?this._insertElements(i,o-i,t):o{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;ad.controller.options.grouped),o=n.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(e),l=a&&a[n.axis],c=d=>{let h=d._parsed.find(f=>f[n.axis]===l),u=h&&h[d.vScale.axis];if(tt(u)||isNaN(u))return!0};for(let d of i)if(!(e!==void 0&&c(d))&&((o===!1||r.indexOf(d.stack)===-1||o===void 0&&d.stack===void 0)&&r.push(d.stack),d.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter(n=>t[n].axis===e).shift()}_getAxis(){let t={},e=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)t[Q(this.chart.options.indexAxis==="x"?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){let i=this._getStacks(t,n),o=e!==void 0?i.indexOf(e):-1;return o===-1?i.length-1:o}_getRuler(){let t=this.options,e=this._cachedMeta,n=e.iScale,i=[],o,r;for(o=0,r=e.data.length;o=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:i,yScale:o}=e,r=this.getParsed(t),a=i.getLabelForValue(r.x),l=o.getLabelForValue(r.y),c=r._custom;return{label:n[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){let e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,n,i){let o=i==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(e,i),d=r.axis,h=a.axis;for(let u=e;u+n[l];if(et(n[t])){let{key:l="value"}=this._parsing;o=c=>+ae(n[c],l)}let r,a;for(r=t,a=t+e;r0&&!isNaN(t)?dt*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart,i=n.data.labels||[],o=ns(e._parsed[t],n.options.locale);return{label:i[t]||"",value:o}}getMaxBorderWidth(t){let e=0,n=this.chart,i,o,r,a,l;if(!t){for(i=0,o=n.data.datasets.length;it!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),W(se,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data,{labels:{pointStyle:n,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map((l,c)=>{let h=t.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:h.backgroundColor,fontColor:o,hidden:!t.getDataVisibility(c),lineDash:h.borderDash,lineDashOffset:h.borderDashOffset,lineJoin:h.borderJoinStyle,lineWidth:h.borderWidth,strokeStyle:h.borderColor,textAlign:i,pointStyle:n,borderRadius:r&&(a||h.borderRadius),index:c}}):[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}}});Ve=class extends Tt{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){let e=this._cachedMeta,{dataset:n,data:i=[],_dataset:o}=e,r=this.chart._animationsDisabled,{start:a,count:l}=Ri(e,i,r);this._drawStart=a,this._drawCount=l,Oi(e)&&(a=0,l=i.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=i;let c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!r,options:c},t),this.updateElements(i,a,l,t)}updateElements(t,e,n,i){let o=i==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:d,includeOptions:h}=this._getSharedOptions(e,i),u=r.axis,f=a.axis,{spanGaps:p,segment:g}=this.options,m=Ae(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||i==="none",x=e+n,_=t.length,E=e>0&&this.getParsed(e-1);for(let S=0;S<_;++S){let v=t[S],y=b?v:{};if(S=x){y.skip=!0;continue}let C=this.getParsed(S),D=tt(C[f]),M=y[u]=r.getPixelForValue(C[u],S),w=y[f]=o||D?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,C,l):C[f],S);y.skip=isNaN(M)||isNaN(w)||D,y.stop=S>0&&Math.abs(C[u]-E[u])>m,g&&(y.parsed=C,y.raw=c.data[S]),h&&(y.options=d||this.resolveDataElementOptions(S,v.active?"active":i)),b||this.updateElement(v,S,y,i),E=C}}getMaxOverflow(){let t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,i=t.data||[];if(!i.length)return n;let o=i[0].size(this.resolveDataElementOptions(0)),r=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(n,o,r)/2}draw(){let t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}};W(Ve,"id","line"),W(Ve,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),W(Ve,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});Se=class extends Tt{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart,i=n.data.labels||[],o=ns(e._parsed[t].r,n.options.locale);return{label:i[t]||"",value:o}}parseObjectData(t,e,n,i){return Wi.bind(this)(t,e,n,i)}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((n,i)=>{let o=this.getParsed(i).r;!isNaN(o)&&this.chart.getDataVisibility(i)&&(oe.max&&(e.max=o))}),e}_updateRadius(){let t=this.chart,e=t.chartArea,n=t.options,i=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(i/2,0),r=Math.max(n.cutoutPercentage?o/100*n.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,n,i){let o=i==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,d=c.xCenter,h=c.yCenter,u=c.getIndexAngle(0)-.5*nt,f=u,p,g=360/this.countVisibleElements();for(p=0;p{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++}),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?Ht(this.resolveDataElementOptions(t,e).angle||n):0}};W(Se,"id","polarArea"),W(Se,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),W(Se,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data;if(e.labels.length&&e.datasets.length){let{labels:{pointStyle:n,color:i}}=t.legend.options;return e.labels.map((o,r)=>{let l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:i,lineWidth:l.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});ls=class extends se{};W(ls,"id","pie"),W(ls,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});Ne=class extends Tt{getLabelAndValue(t){let e=this._cachedMeta.vScale,n=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(n[e.axis])}}parseObjectData(t,e,n,i){return Wi.bind(this)(t,e,n,i)}update(t){let e=this._cachedMeta,n=e.dataset,i=e.data||[],o=e.iScale.getLabels();if(n.points=i,t!=="resize"){let r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);let a={_loop:!0,_fullLoop:o.length===i.length,options:r};this.updateElement(n,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,e,n,i){let o=this._cachedMeta.rScale,r=i==="reset";for(let a=e;a0&&this.getParsed(e-1);for(let E=e;E0&&Math.abs(v[f]-_[f])>b,m&&(y.parsed=v,y.raw=c.data[E]),u&&(y.options=h||this.resolveDataElementOptions(E,S.active?"active":i)),x||this.updateElement(S,E,y,i),_=v}this.updateSharedOptions(h,i,d)}getMaxOverflow(){let t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let a=0;for(let l=e.length-1;l>=0;--l)a=Math.max(a,e[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let n=t.dataset,i=n.options&&n.options.borderWidth||0;if(!e.length)return i;let o=e[0].size(this.resolveDataElementOptions(0)),r=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(i,o,r)/2}};W(Be,"id","scatter"),W(Be,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),W(Be,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});rl=Object.freeze({__proto__:null,BarController:Fe,BubbleController:Ie,DoughnutController:se,LineController:Ve,PieController:ls,PolarAreaController:Se,RadarController:Ne,ScatterController:Be});co=class s{constructor(t){W(this,"options");this.options=t||{}}static override(t){Object.assign(s.prototype,t)}init(){}formats(){return Re()}parse(){return Re()}format(){return Re()}add(){return Re()}diff(){return Re()}startOf(){return Re()}endOf(){return Re()}},al={_date:co};ll={evaluateInteractionItems:Gs,modes:{index(s,t,e,n){let i=xe(t,s),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?eo(s,i,o,n,r):so(s,i,o,!1,n,r),l=[];return a.length?(s.getSortedVisibleDatasetMetas().forEach(c=>{let d=a[0].index,h=c.data[d];h&&!h.skip&&l.push({element:h,datasetIndex:c.index,index:d})}),l):[]},dataset(s,t,e,n){let i=xe(t,s),o=e.axis||"xy",r=e.includeInvisible||!1,a=e.intersect?eo(s,i,o,n,r):so(s,i,o,!1,n,r);if(a.length>0){let l=a[0].datasetIndex,c=s.getDatasetMeta(l).data;a=[];for(let d=0;d{typeof g.beforeLayout=="function"&&g.beforeLayout()});let d=l.reduce((g,m)=>m.box.options&&m.box.options.display===!1?g:g+1,0)||1,h=Object.freeze({outerWidth:t,outerHeight:e,padding:i,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/d,hBoxMaxHeight:r/2}),u=Object.assign({},i);dl(u,Ct(n));let f=Object.assign({maxPadding:u,w:o,h:r,x:i.left,y:i.top},i),p=Lh(l.concat(c),h);zs(a.fullSize,f,h,p),zs(l,f,h,p),zs(c,f,h,p)&&zs(l,f,h,p),Rh(f),ba(a.leftAndTop,f,h,p),f.x+=f.w,f.y+=f.h,ba(a.rightAndBottom,f,h,p),s.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},rt(a.chartArea,g=>{let m=g.box;Object.assign(m,s.chartArea),m.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}},js=class{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,i){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,i?Math.floor(e/i):n)}}isAttached(t){return!0}updateConfig(t){}},Kn=class extends js{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}},Wn="$chartjs",Fh={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},va=s=>s===null||s==="";hl=Jr?{passive:!0}:!1;Us=new Map,ya=0;Gn=class extends js{acquireContext(t,e){let n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(Ih(t,e),n):null}releaseContext(t){let e=t.canvas;if(!e[Wn])return!1;let n=e[Wn].initial;["height","width"].forEach(o=>{let r=n[o];tt(r)?e.removeAttribute(o):e.setAttribute(o,r)});let i=n.style||{};return Object.keys(i).forEach(o=>{e.style[o]=i[o]}),e.width=e.width,delete e[Wn],!0}addEventListener(t,e,n){this.removeEventListener(t,e);let i=t.$proxies||(t.$proxies={}),r={attach:zh,detach:Hh,resize:jh}[e]||Uh;i[e]=r(t,e,n)}removeEventListener(t,e){let n=t.$proxies||(t.$proxies={}),i=n[e];if(!i)return;({attach:no,detach:no,resize:no}[e]||Nh)(t,e,i),n[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,i){return Zr(t,e,n,i)}isAttached(t){let e=t&&Fn(t);return!!(e&&e.isConnected)}};At=class{constructor(){W(this,"x");W(this,"y");W(this,"active",!1);W(this,"options");W(this,"$animations")}tooltipPosition(t){let{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return Ae(this.x)&&Ae(this.y)}getProps(t,e){let n=this.$animations;if(!e||!n)return this;let i={};return t.forEach(o=>{i[o]=n[o]&&n[o].active()?n[o]._to:this[o]}),i}};W(At,"defaults",{}),W(At,"defaultRoutes");Zh=s=>s==="left"?"right":s==="right"?"left":s,xa=(s,t,e)=>t==="top"||t==="left"?s[t]+e:s[t]-e,_a=(s,t)=>Math.min(t||s,s);ke=class s extends At{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:n,_suggestedMax:i}=this;return t=Mt(t,Number.POSITIVE_INFINITY),e=Mt(e,Number.NEGATIVE_INFINITY),n=Mt(n,Number.POSITIVE_INFINITY),i=Mt(i,Number.NEGATIVE_INFINITY),{min:Mt(t,n),max:Mt(e,i),minDefined:pt(t),maxDefined:pt(e)}}getMinMax(t){let{min:e,max:n,minDefined:i,maxDefined:o}=this.getUserBounds(),r;if(i&&o)return{min:e,max:n};let a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;ln?n:e,n=i&&e>n?e:n,{min:Mt(e,Mt(n,e)),max:Mt(n,Mt(e,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(){lt(this.options.beforeUpdate,[this])}update(t,e,n){let{beginAtZero:i,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Kr(this,o,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=a=o||n<=1||!this.isHorizontal()){this.labelRotation=i;return}let d=this._getLabelSizes(),h=d.widest.width,u=d.highest.height,f=vt(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/n:f/(n-1),h+6>a&&(a=f/(n-(t.offset?.5:1)),l=this.maxHeight-Ns(t.grid)-e.padding-Sa(t.title,this.chart.options.font),c=Math.sqrt(h*h+u*u),r=Mn(Math.min(Math.asin(vt((d.highest.height+6)/a,-1,1)),Math.asin(vt(l/c,-1,1))-Math.asin(vt(u/c,-1,1)))),r=Math.max(i,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){lt(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){lt(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:e,options:{ticks:n,title:i,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){let l=Sa(i,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ns(o)+l):(t.height=this.maxHeight,t.width=Ns(o)+l),n.display&&this.ticks.length){let{first:c,last:d,widest:h,highest:u}=this._getLabelSizes(),f=n.padding*2,p=Ht(this.labelRotation),g=Math.cos(p),m=Math.sin(p);if(a){let b=n.mirror?0:m*h.width+g*u.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{let b=n.mirror?0:g*h.width+m*u.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(c,d,m,g)}}this._handleMargins(),a?(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,n,i){let{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){let d=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1),u=0,f=0;l?c?(u=i*t.width,f=n*e.height):(u=n*t.height,f=i*e.width):o==="start"?f=e.width:o==="end"?u=t.width:o!=="inner"&&(u=t.width/2,f=e.width/2),this.paddingLeft=Math.max((u-d+r)*this.width/(this.width-d),0),this.paddingRight=Math.max((f-h+r)*this.width/(this.width-h),0)}else{let d=e.height/2,h=t.height/2;o==="start"?(d=0,h=t.height):o==="end"&&(d=e.height,h=0),this.paddingTop=d+r,this.paddingBottom=h+r}}_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(){lt(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){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,n;for(e=0,n=t.length;e({width:r[D]||0,height:a[D]||0});return{first:C(0),last:C(e-1),widest:C(v),highest:C(y),widths:r,heights:a}}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 Fr(this._alignToPixels?be(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&&ta*i?a/n:l/i:l*i0}_computeGridLineItems(t){let e=this.axis,n=this.chart,i=this.options,{grid:o,position:r,border:a}=i,l=o.offset,c=this.isHorizontal(),h=this.ticks.length+(l?1:0),u=Ns(o),f=[],p=a.setContext(this.getContext()),g=p.display?p.width:0,m=g/2,b=function(I){return be(n,I,g)},x,_,E,S,v,y,C,D,M,w,L,k;if(r==="top")x=b(this.bottom),y=this.bottom-u,D=x-m,w=b(t.top)+m,k=t.bottom;else if(r==="bottom")x=b(this.top),w=t.top,k=b(t.bottom)-m,y=x+m,D=this.top+u;else if(r==="left")x=b(this.right),v=this.right-u,C=x-m,M=b(t.left)+m,L=t.right;else if(r==="right")x=b(this.left),M=t.left,L=b(t.right)-m,v=x+m,C=this.left+u;else if(e==="x"){if(r==="center")x=b((t.top+t.bottom)/2+.5);else if(et(r)){let I=Object.keys(r)[0],z=r[I];x=b(this.chart.scales[I].getPixelForValue(z))}w=t.top,k=t.bottom,y=x+m,D=y+u}else if(e==="y"){if(r==="center")x=b((t.left+t.right)/2);else if(et(r)){let I=Object.keys(r)[0],z=r[I];x=b(this.chart.scales[I].getPixelForValue(z))}v=x-m,C=v-u,M=t.left,L=t.right}let A=Q(i.ticks.maxTicksLimit,h),P=Math.max(1,Math.ceil(h/A));for(_=0;_0&&(N-=K/2);break}O={left:N,top:$,width:K+j.width,height:U+j.height,color:P.backdropColor}}m.push({label:E,font:D,textOffset:L,options:{rotation:g,color:z,strokeColor:R,strokeWidth:V,textAlign:T,textBaseline:k,translation:[S,v],backdrop:O}})}return m}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-Ht(this.labelRotation))return t==="top"?"left":"right";let i="center";return e.align==="start"?i="left":e.align==="end"?i="right":e.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){let{position:e,ticks:{crossAlign:n,mirror:i,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width,c,d;return e==="left"?i?(d=this.right+o,n==="near"?c="left":n==="center"?(c="center",d+=l/2):(c="right",d+=l)):(d=this.right-a,n==="near"?c="right":n==="center"?(c="center",d-=l/2):(c="left",d=this.left)):e==="right"?i?(d=this.left+o,n==="near"?c="right":n==="center"?(c="center",d-=l/2):(c="left",d-=l)):(d=this.left+a,n==="near"?c="left":n==="center"?(c="center",d+=l/2):(c="right",d=this.right)):c="right",{textAlign:c,x:d}}_computeLabelArea(){if(this.options.ticks.mirror)return;let t=this.chart,e=this.options.position;if(e==="left"||e==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(e==="top"||e==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){let{ctx:t,options:{backgroundColor:e},left:n,top:i,width:o,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,i,o,r),t.restore())}getLineWidthForValue(t){let e=this.options.grid;if(!this._isVisible()||!e.display)return 0;let i=this.ticks.findIndex(o=>o.value===t);return i>=0?e.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){let e=this.options.grid,n=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,r,a=(l,c,d)=>{!d.width||!d.color||(n.save(),n.lineWidth=d.width,n.strokeStyle=d.color,n.setLineDash(d.borderDash||[]),n.lineDashOffset=d.borderDashOffset,n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(c.x,c.y),n.stroke(),n.restore())};if(e.display)for(o=0,r=i.length;o{this.draw(o)}}]:[{z:n,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){let e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",i=[],o,r;for(o=0,r=e.length;o{let o=n||this._getRegistryForType(i);n||o.isForType(i)||o===this.plugins&&i.id?this._exec(t,o,i):rt(i,r=>{let a=n||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,n){let i=kn(t);lt(n["before"+i],[],n),e[t](n),lt(n["after"+i],[],n)}_getRegistryForType(t){for(let e=0;eo.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(i(e,n),t,"stop"),this._notify(i(n,e),t,"start")}};ka=new Map,ml=new Set;Bs=(s,t,e)=>{let n=ae(t,e);n!==void 0&&s.add(n)},go=class{constructor(t){this._config=bu(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=gl(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(),pl(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Bn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Bn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Bn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id,n=this.type;return Bn(`${n}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){let n=this._scopeCache,i=n.get(t);return(!i||e)&&(i=new Map,n.set(t,i)),i}getOptionScopes(t,e,n){let{options:i,type:o}=this,r=this._cachedScopes(t,n),a=r.get(e);if(a)return a;let l=new Set;e.forEach(d=>{t&&(l.add(t),d.forEach(h=>Bs(l,t,h))),d.forEach(h=>Bs(l,i,h)),d.forEach(h=>Bs(l,me[o]||{},h)),d.forEach(h=>Bs(l,ht,h)),d.forEach(h=>Bs(l,Ln,h))});let c=Array.from(l);return c.length===0&&c.push(Object.create(null)),ml.has(e)&&r.set(e,c),c}chartOptionScopes(){let{options:t,type:e}=this;return[t,me[e]||{},ht.datasets[e]||{},{type:e},ht,Ln]}resolveNamedOptions(t,e,n,i=[""]){let o={$shared:!0},{resolver:r,subPrefixes:a}=Ma(this._resolverCache,t,i),l=r;if(yu(r,e)){o.$shared=!1,n=oe(n)?n():n;let c=this.createResolver(t,n,a);l=Le(r,n,c)}for(let c of e)o[c]=l[c];return o}createResolver(t,e,n=[""],i){let{resolver:o}=Ma(this._resolverCache,t,n);return et(e)?Le(o,e,void 0,i):o}};vu=s=>et(s)&&Object.getOwnPropertyNames(s).some(t=>oe(s[t]));xu="4.5.1",_u=["top","bottom","left","right","chartArea"];jn={},Aa=s=>{let t=bl(s);return Object.values(jn).filter(e=>e.canvas===t).pop()};ee=class{static register(...t){jt.add(...t),Pa()}static unregister(...t){jt.remove(...t),Pa()}constructor(t,e){let n=this.config=new go(e),i=bl(t),o=Aa(i);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 r=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||fl(i)),this.platform.updateConfig(n);let a=this.platform.acquireContext(i,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,d=l&&l.width;if(this.id=Tr(),this.ctx=a,this.canvas=l,this.width=d,this.height=c,this._options=r,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 uo,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=zr(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],jn[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}te.listen(this,"complete",La),te.listen(this,"progress",Cu),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:e},width:n,height:i,_aspectRatio:o}=this;return tt(t)?e&&o?o:i?n/i: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 jt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ji(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Vi(this.canvas,this.ctx),this}stop(){return te.stop(this),this}resize(t,e){te.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){let n=this.options,i=this.canvas,o=n.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(i,t,e,o),a=n.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,ji(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),lt(n.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){let e=this.options.scales||{};rt(e,(n,i)=>{n.id=i})}buildOrUpdateScales(){let t=this.options,e=t.scales,n=this.scales,i=Object.keys(n).reduce((r,a)=>(r[a]=!1,r),{}),o=[];e&&(o=o.concat(Object.keys(e).map(r=>{let a=e[r],l=po(r,a),c=l==="r",d=l==="x";return{options:a,dposition:c?"chartArea":d?"bottom":"left",dtype:c?"radialLinear":d?"category":"linear"}}))),rt(o,r=>{let a=r.options,l=a.id,c=po(l,a),d=Q(a.type,r.dtype);(a.position===void 0||Da(a.position,c)!==Da(r.dposition))&&(a.position=r.dposition),i[l]=!0;let h=null;if(l in n&&n[l].type===d)h=n[l];else{let u=jt.getScale(d);h=new u({id:l,type:d,ctx:this.ctx,chart:this}),n[h.id]=h}h.init(a,t)}),rt(i,(r,a)=>{r||delete n[a]}),rt(n,r=>{St.configure(this,r,r.options),St.addBox(this,r)})}_updateMetasets(){let t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort((i,o)=>i.index-o.index),n>e){for(let i=e;ie.length&&delete this._stacks,t.forEach((n,i)=>{e.filter(o=>o===n._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){let t=[],e=this.data.datasets,n,i;for(this._removeUnreferencedMetasets(),n=0,i=e.length;n{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let e=this.config;e.update();let n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!n.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 r=0;for(let c=0,d=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Ta("z","_idx"));let{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){rt(this.scales,t=>{St.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);(!Ei(e,n)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(let{method:n,start:i,count:o}of e){let r=n==="_removeElements"?-o:o;Su(t,i,r)}}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let e=this.data.datasets.length,n=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),i=n(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;St.update(this,this.width,this.height,t);let e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],rt(this.boxes,i=>{n&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,o)=>{i._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,n=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let e=this.ctx,n={meta:t,index:t.index,cancelable:!0},i=Xi(this,t);this.notifyPlugins("beforeDatasetDraw",n)!==!1&&(i&&Rs(e,i),t.controller.draw(),i&&Os(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return Xt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,i){let o=ll.modes[e];return typeof o=="function"?o(this,t,n,i):[]}getDatasetMeta(t){let e=this.data.datasets[t],n=this._metasets,i=n.filter(o=>o&&o._dataset===e).pop();return i||(i={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},n.push(i)),i}getContext(){return this.$context||(this.$context=le(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let e=this.data.datasets[t];if(!e)return!1;let n=this.getDatasetMeta(t);return typeof n.hidden=="boolean"?!n.hidden:!e.hidden}setDatasetVisibility(t,e){let n=this.getDatasetMeta(t);n.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,n){let i=n?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,i);ts(e)?(o.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),r.update(o,{visible:n}),this.update(a=>a.datasetIndex===t?i: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(),te.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,r),t[o]=r},i=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};rt(this.options.events,o=>n(o,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,n=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},i=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)},r,a=()=>{i("attach",a),this.attached=!0,this.resize(),n("resize",o),n("detach",r)};r=()=>{this.attached=!1,i("resize",o),this._stop(),this._resize(0,0),n("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){rt(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},rt(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){let i=n?"set":"remove",o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+i+"DatasetHoverStyle"]()),a=0,l=t.length;a{let a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Ps(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,n){let i=this.options.hover,o=(l,c)=>l.filter(d=>!c.some(h=>d.datasetIndex===h.datasetIndex&&d.index===h.index)),r=o(e,t),a=n?t:o(t,e);r.length&&this.updateHoverStyle(r,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,e){let n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},i=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",n,i)===!1)return;let o=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,i),(o||n.changed)&&this.render(),this}_handleEvent(t,e,n){let{_active:i=[],options:o}=this,r=e,a=this._getActiveElements(t,i,n,r),l=Pr(t),c=Eu(t,this._lastEvent,n,l);n&&(this._lastEvent=null,lt(o.onHover,[t,a,this],this),l&<(o.onClick,[t,a,this],this));let d=!Ps(a,i);return(d||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=c,d}_getActiveElements(t,e,n,i){if(t.type==="mouseout")return[];if(!n)return e;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,i)}};W(ee,"defaults",ht),W(ee,"instances",jn),W(ee,"overrides",me),W(ee,"registry",jt),W(ee,"version",xu),W(ee,"getChart",Aa);_e=class extends At{constructor(e){super();W(this,"circumference");W(this,"endAngle");W(this,"fullCircles");W(this,"innerRadius");W(this,"outerRadius");W(this,"pixelMargin");W(this,"startAngle");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,e&&Object.assign(this,e)}inRange(e,n,i){let o=this.getProps(["x","y"],i),{angle:r,distance:a}=Di(o,{x:e,y:n}),{startAngle:l,endAngle:c,innerRadius:d,outerRadius:h,circumference:u}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),f=(this.options.spacing+this.options.borderWidth)/2,p=Q(u,c-l),g=ss(r,l,c)&&l!==c,m=p>=dt||g,b=Zt(a,d+f,h+f);return m&&b}getCenterPoint(e){let{x:n,y:i,startAngle:o,endAngle:r,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:c,spacing:d}=this.options,h=(o+r)/2,u=(a+l+d+c)/2;return{x:n+Math.cos(h)*u,y:i+Math.sin(h)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:n,circumference:i}=this,o=(n.offset||0)/4,r=(n.spacing||0)/2,a=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=i>dt?Math.floor(i/dt):0,i===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let l=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(l)*o,Math.sin(l)*o);let c=1-Math.sin(Math.min(nt,i||0)),d=o*c;e.fillStyle=n.backgroundColor,e.strokeStyle=n.borderColor,Tu(e,this,d,r,a),Lu(e,this,d,r,a),e.restore()}};W(_e,"id","arc"),W(_e,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1}),W(_e,"defaultRoutes",{backgroundColor:"backgroundColor"}),W(_e,"descriptors",{_scriptable:!0,_indexable:e=>e!=="borderDash"});Nu=typeof Path2D=="function";Ut=class extends At{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 n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){let i=n.spanGaps?this._loop:this._fullLoop;Qr(this._points,n,t,i,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=na(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,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){let n=this.options,i=t[e],o=this.points,r=qi(this,{property:e,start:i,end:i});if(!r.length)return;let a=[],l=Fu(n),c,d;for(c=0,d=r.length;ct!=="borderDash"&&t!=="fill"});ze=class extends At{constructor(e){super();W(this,"parsed");W(this,"skip");W(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,e&&Object.assign(this,e)}inRange(e,n,i){let o=this.options,{x:r,y:a}=this.getProps(["x","y"],i);return Math.pow(e-r,2)+Math.pow(n-a,2)s.replace("rgb(","rgba(").replace(")",", 0.5)"));El={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(s,t,e){if(!e.enabled)return;let{data:{datasets:n},options:i}=s.config,{elements:o}=i,r=Fa(n)||qu(i)||o&&Fa(o)||Xu();if(!e.forceOverride&&r)return;let a=Gu(s);n.forEach(a)}};kl={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(s,t,e)=>{if(!e.enabled){Ia(s);return}let n=s.width;s.data.datasets.forEach((i,o)=>{let{_data:r,indexAxis:a}=i,l=s.getDatasetMeta(o),c=r||i.data;if(rs([a,s.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let d=s.scales[l.xAxisID];if(d.type!=="linear"&&d.type!=="time"||s.options.parsing)return;let{start:h,count:u}=Ju(l,c),f=e.threshold||4*n;if(u<=f){wl(i);return}tt(r)&&(i._data=c,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(g){this._data=g}}));let p;switch(e.algorithm){case"lttb":p=Qu(c,h,u,n,e);break;case"min-max":p=Zu(c,h,u,n);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}i._decimated=p})},destroy(s){Ia(s)}};Xn=class{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,n){let{x:i,y:o,radius:r}=this;return e=e||{start:0,end:dt},t.arc(i,o,r,e.end,e.start,!0),!n.bounds}interpolate(t){let{x:e,y:n,radius:i}=this,o=t.angle;return{x:e+Math.cos(o)*i,y:n+Math.sin(o)*i,angle:o}}};Dl={id:"filler",afterDatasetsUpdate(s,t,e){let n=(s.data.datasets||[]).length,i=[],o,r,a,l;for(r=0;r=0;--r){let a=i[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),n&&a.fill&&ro(s.ctx,a,o))}},beforeDatasetsDraw(s,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;let n=s.getSortedVisibleDatasetMetas();for(let i=n.length-1;i>=0;--i){let o=n[i].$filler;Na(o)&&ro(s.ctx,o,s.chartArea)}},beforeDatasetDraw(s,t,e){let n=t.meta.$filler;!Na(n)||e.drawTime!=="beforeDatasetDraw"||ro(s.ctx,n,s.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}},$a=(s,t)=>{let{boxHeight:e=t,boxWidth:n=t}=s;return s.usePointStyle&&(e=Math.min(e,t),n=s.pointStyleWidth||Math.min(n,t)),{boxWidth:n,boxHeight:e,itemHeight:Math.max(t,e)}},xf=(s,t)=>s!==null&&t!==null&&s.datasetIndex===t.datasetIndex&&s.index===t.index,Qn=class extends At{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,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,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=lt(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(n=>t.filter(n,this.chart.data))),t.sort&&(e=e.sort((n,i)=>t.sort(n,i,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){let{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}let n=t.labels,i=bt(n.font),o=i.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=$a(n,o),c,d;e.font=i.string,this.isHorizontal()?(c=this.maxWidth,d=this._fitRows(r,o,a,l)+10):(d=this.maxHeight,c=this._fitCols(r,i,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(d,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,i){let{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],d=i+a,h=t;o.textAlign="left",o.textBaseline="middle";let u=-1,f=-d;return this.legendItems.forEach((p,g)=>{let m=n+e/2+o.measureText(p.text).width;(g===0||c[c.length-1]+m+2*a>r)&&(h+=d,c[c.length-(g>0?0:1)]=0,f+=d,u++),l[g]={left:0,top:f,row:u,width:m,height:i},c[c.length-1]+=m+a}),h}_fitCols(t,e,n,i){let{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],d=r-t,h=a,u=0,f=0,p=0,g=0;return this.legendItems.forEach((m,b)=>{let{itemWidth:x,itemHeight:_}=_f(n,e,o,m,i);b>0&&f+_+2*a>d&&(h+=u+a,c.push({width:u,height:f}),p+=u+a,g++,u=f=0),l[b]={left:p,top:f,col:g,width:x,height:_},u=Math.max(u,x),f+=_+a}),h+=u,c.push({width:u,height:f}),h}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:i},rtl:o}}=this,r=Pe(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=_t(n,this.left+i,this.right-this.lineWidths[a]);for(let c of e)a!==c.row&&(a=c.row,l=_t(n,this.left+i,this.right-this.lineWidths[a])),c.top+=this.top+t+i,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+i}else{let a=0,l=_t(n,this.top+t+i,this.bottom-this.columnSizes[a].height);for(let c of e)c.col!==a&&(a=c.col,l=_t(n,this.top+t+i,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+i,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;Rs(t,this),this._draw(),Os(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:n,ctx:i}=this,{align:o,labels:r}=t,a=ht.color,l=Pe(t.rtl,this.left,this.width),c=bt(r.font),{padding:d}=r,h=c.size,u=h/2,f;this.drawTitle(),i.textAlign=l.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=c.string;let{boxWidth:p,boxHeight:g,itemHeight:m}=$a(r,h),b=function(v,y,C){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;i.save();let D=Q(C.lineWidth,1);if(i.fillStyle=Q(C.fillStyle,a),i.lineCap=Q(C.lineCap,"butt"),i.lineDashOffset=Q(C.lineDashOffset,0),i.lineJoin=Q(C.lineJoin,"miter"),i.lineWidth=D,i.strokeStyle=Q(C.strokeStyle,a),i.setLineDash(Q(C.lineDash,[])),r.usePointStyle){let M={radius:g*Math.SQRT2/2,pointStyle:C.pointStyle,rotation:C.rotation,borderWidth:D},w=l.xPlus(v,p/2),L=y+u;Ni(i,M,w,L,r.pointStyleWidth&&p)}else{let M=y+Math.max((h-g)/2,0),w=l.leftForLtr(v,p),L=ye(C.borderRadius);i.beginPath(),Object.values(L).some(k=>k!==0)?os(i,{x:w,y:M,w:p,h:g,radius:L}):i.rect(w,M,p,g),i.fill(),D!==0&&i.stroke()}i.restore()},x=function(v,y,C){ve(i,C.text,v,y+m/2,c,{strikethrough:C.hidden,textAlign:l.textAlign(C.textAlign)})},_=this.isHorizontal(),E=this._computeTitleHeight();_?f={x:_t(o,this.left+d,this.right-n[0]),y:this.top+d+E,line:0}:f={x:this.left+d,y:_t(o,this.top+E+d,this.bottom-e[0].height),line:0},Ki(this.ctx,t.textDirection);let S=m+d;this.legendItems.forEach((v,y)=>{i.strokeStyle=v.fontColor,i.fillStyle=v.fontColor;let C=i.measureText(v.text).width,D=l.textAlign(v.textAlign||(v.textAlign=r.textAlign)),M=p+u+C,w=f.x,L=f.y;l.setWidth(this.width),_?y>0&&w+M+d>this.right&&(L=f.y+=S,f.line++,w=f.x=_t(o,this.left+d,this.right-n[f.line])):y>0&&L+S>this.bottom&&(w=f.x=w+e[f.line].width+d,f.line++,L=f.y=_t(o,this.top+E+d,this.bottom-e[f.line].height));let k=l.x(w);if(b(k,L,v),w=Hr(D,w+p+u,_?w+M:this.right,t.rtl),x(l.x(w),L,v),_)f.x+=M+d;else if(typeof v.text!="string"){let A=c.lineHeight;f.y+=Tl(v,A)+d}else f.y+=S}),Yi(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,n=bt(e.font),i=Ct(e.padding);if(!e.display)return;let o=Pe(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=n.size/2,c=i.top+l,d,h=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),d=this.top+c,h=_t(t.align,h,this.right-u);else{let p=this.columnSizes.reduce((g,m)=>Math.max(g,m.height),0);d=c+_t(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}let f=_t(a,h,h+u);r.textAlign=o.textAlign(Tn(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=n.string,ve(r,e.text,f,d,n)}_computeTitleHeight(){let t=this.options.title,e=bt(t.font),n=Ct(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,i,o;if(Zt(t,this.left,this.right)&&Zt(e,this.top,this.bottom)){for(o=this.legendHitBoxes,n=0;ns.chart.options.color,boxWidth:40,padding:10,generateLabels(s){let t=s.data.datasets,{labels:{usePointStyle:e,pointStyle:n,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=s.legend.options;return s._getSortedDatasetMetas().map(l=>{let c=l.controller.getStyle(e?0:void 0),d=Ct(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(d.width+d.height)/4,strokeStyle:c.borderColor,pointStyle:n||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:s=>s.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:s=>!s.startsWith("on"),labels:{_scriptable:s=>!["generateLabels","filter","sort"].includes(s)}}},Ks=class extends At{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 n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;let i=ct(n.text)?n.text.length:1;this._padding=Ct(n.padding);let o=i*bt(n.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:n,bottom:i,right:o,options:r}=this,a=r.align,l=0,c,d,h;return this.isHorizontal()?(d=_t(a,n,o),h=e+t,c=o-n):(r.position==="left"?(d=n+t,h=_t(a,i,e),l=nt*-.5):(d=o-t,h=_t(a,e,i),l=nt*.5),c=i-e),{titleX:d,titleY:h,maxWidth:c,rotation:l}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let n=bt(e.font),o=n.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);ve(t,e.text,0,0,n,{color:e.color,maxWidth:l,rotation:c,textAlign:Tn(e.align),textBaseline:"middle",translation:[r,a]})}};Al={id:"title",_element:Ks,start(s,t,e){wf(s,e)},stop(s){let t=s.titleBlock;St.removeBox(s,t),delete s.titleBlock},beforeUpdate(s,t,e){let n=s.titleBlock;St.configure(s,n,e),n.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}},zn=new WeakMap,Pl={id:"subtitle",start(s,t,e){let n=new Ks({ctx:s.ctx,options:e,chart:s});St.configure(s,n,e),St.addBox(s,n),zn.set(s,n)},stop(s){St.removeBox(s,zn.get(s)),zn.delete(s)},beforeUpdate(s,t,e){let n=zn.get(s);St.configure(s,n,e),n.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}},Hs={average(s){if(!s.length)return!1;let t,e,n=new Set,i=0,o=0;for(t=0,e=s.length;ta+l)/n.size,y:i/o}},nearest(s,t){if(!s.length)return!1;let e=t.x,n=t.y,i=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=s.length;o0){let t=s[0],e=t.chart.data.labels,n=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(n>0&&t.dataIndex{let r={before:[],lines:[],after:[]},a=Ya(n,o);Jt(r.before,ce(Dt(a,"beforeLabel",this,o))),Jt(r.lines,Dt(a,"label",this,o)),Jt(r.after,ce(Dt(a,"afterLabel",this,o))),i.push(r)}),i}getAfterBody(t,e){return Ka(Dt(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:n}=e,i=Dt(n,"beforeFooter",this,t),o=Dt(n,"footer",this,t),r=Dt(n,"afterFooter",this,t),a=[];return a=Jt(a,ce(i)),a=Jt(a,ce(o)),a=Jt(a,ce(r)),a}_createItems(t){let e=this._active,n=this.chart.data,i=[],o=[],r=[],a=[],l,c;for(l=0,c=e.length;lt.filter(d,h,u,n))),t.itemSort&&(a=a.sort((d,h)=>t.itemSort(d,h,n))),rt(a,d=>{let h=Ya(t.callbacks,d);i.push(Dt(h,"labelColor",this,d)),o.push(Dt(h,"labelPointStyle",this,d)),r.push(Dt(h,"labelTextColor",this,d))}),this.labelColors=i,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){let n=this.options.setContext(this.getContext()),i=this._active,o,r=[];if(!i.length)this.opacity!==0&&(o={opacity:0});else{let a=Hs[n.position].call(this,i,this._eventPosition);r=this._createItems(n),this.title=this.getTitle(r,n),this.beforeBody=this.getBeforeBody(r,n),this.body=this.getBody(r,n),this.afterBody=this.getAfterBody(r,n),this.footer=this.getFooter(r,n);let l=this._size=Wa(this,n),c=Object.assign({},a,l),d=ja(this.chart,n,c),h=Ua(n,c,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,o={opacity:1,x:h.x,y:h.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,i){let o=this.getCaretPosition(t,n,i);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,n){let{xAlign:i,yAlign:o}=this,{caretSize:r,cornerRadius:a}=n,{topLeft:l,topRight:c,bottomLeft:d,bottomRight:h}=ye(a),{x:u,y:f}=t,{width:p,height:g}=e,m,b,x,_,E,S;return o==="center"?(E=f+g/2,i==="left"?(m=u,b=m-r,_=E+r,S=E-r):(m=u+p,b=m+r,_=E-r,S=E+r),x=m):(i==="left"?b=u+Math.max(l,d)+r:i==="right"?b=u+p-Math.max(c,h)-r:b=this.caretX,o==="top"?(_=f,E=_-r,m=b-r,x=b+r):(_=f+g,E=_+r,m=b+r,x=b-r),S=_),{x1:m,x2:b,x3:x,y1:_,y2:E,y3:S}}drawTitle(t,e,n){let i=this.title,o=i.length,r,a,l;if(o){let c=Pe(n.rtl,this.x,this.width);for(t.x=Hn(this,n.titleAlign,n),e.textAlign=c.textAlign(n.titleAlign),e.textBaseline="middle",r=bt(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=r.string,l=0;lx!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,os(t,{x:g,y:p,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),os(t,{x:m,y:p+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,c,l),t.strokeRect(g,p,c,l),t.fillStyle=r.backgroundColor,t.fillRect(m,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){let{body:i}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:d}=n,h=bt(n.bodyFont),u=h.lineHeight,f=0,p=Pe(n.rtl,this.x,this.width),g=function(C){e.fillText(C,p.x(t.x+f),t.y+u/2),t.y+=u+o},m=p.textAlign(r),b,x,_,E,S,v,y;for(e.textAlign=r,e.textBaseline="middle",e.font=h.string,t.x=Hn(this,m,n),e.fillStyle=n.bodyColor,rt(this.beforeBody,g),f=a&&m!=="right"?r==="center"?c/2+d:c+2+d:0,E=0,v=i.length;E0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,n=this.$animations,i=n&&n.x,o=n&&n.y;if(i||o){let r=Hs[t.position].call(this,this._active,this._eventPosition);if(!r)return;let a=this._size=Wa(this,t),l=Object.assign({},r,this._size),c=ja(e,t,l),d=Ua(t,l,c,e);(i._to!==d.x||o._to!==d.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,d))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(e);let i={width:this.width,height:this.height},o={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let r=Ct(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=n,this.drawBackground(o,t,i,e),Ki(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Yi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let n=this._active,i=t.map(({datasetIndex:a,index:l})=>{let c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Ps(n,i),r=this._positionChanged(i,e);(o||r)&&(this._active=i,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let i=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,n),a=this._positionChanged(r,t),l=e||!Ps(r,o)||a;return l&&(this._active=r,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,n,i){let o=this.options;if(t.type==="mouseout")return[];if(!i)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);let r=this.chart.getElementsAtEventForMode(t,o.mode,o,n);return o.reverse&&r.reverse(),r}_positionChanged(t,e){let{caretX:n,caretY:i,options:o}=this,r=Hs[o.position].call(this,t,e);return r!==!1&&(n!==r.x||i!==r.y)}};W($s,"positioners",Hs);Ol={id:"tooltip",_element:$s,positioners:Hs,afterInit(s,t,e){e&&(s.tooltip=new $s({chart:s,options:e}))},beforeUpdate(s,t,e){s.tooltip&&s.tooltip.initialize(e)},reset(s,t,e){s.tooltip&&s.tooltip.initialize(e)},afterDraw(s){let t=s.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(s.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(s.ctx),s.notifyPlugins("afterTooltipDraw",e)}},afterEvent(s,t){if(s.tooltip){let e=t.replay;s.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:(s,t)=>t.bodyFont.size,boxWidth:(s,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:Rl},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:s=>s!=="filter"&&s!=="itemSort"&&s!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Fl=Object.freeze({__proto__:null,Colors:El,Decimation:kl,Filler:Dl,Legend:Ll,SubTitle:Pl,Title:Al,Tooltip:Ol}),Rf=(s,t,e,n)=>(typeof t=="string"?(e=s.push(t)-1,n.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);Ff=(s,t)=>s===null?null:vt(Math.round(s),0,t);ds=class extends ke{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){let e=this._addedLabels;if(e.length){let n=this.getLabels();for(let{index:i,label:o}of e)n[i]===o&&n.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(tt(t))return null;let n=this.getLabels();return e=isFinite(e)&&n[e]===t?e:Of(n,t,Q(e,t),this._addedLabels),Ff(e,n.length-1)}determineDataLimits(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),{min:n,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(n=0),e||(i=this.getLabels().length-1)),this.min=n,this.max=i}buildTicks(){let t=this.min,e=this.max,n=this.options.offset,i=[],o=this.getLabels();o=t===0&&e===o.length-1?o:o.slice(t,e+1),this._valueRange=Math.max(o.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let r=t;r<=e;r++)i.push({value:r});return i}getLabelForValue(t){return Ga.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}};W(ds,"id","category"),W(ds,"defaults",{ticks:{callback:Ga}});ps=class extends ke{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return tt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){let{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds(),{min:i,max:o}=this,r=l=>i=e?i:l,a=l=>o=n?o:l;if(t){let l=Wt(i),c=Wt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(i===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(i-l)}this.min=i,this.max=o}getTickLimit(){let t=this.options.ticks,{maxTicksLimit:e,stepSize:n}=t,i;return n?(i=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),e=e||11),e&&(i=Math.min(e,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,e=t.ticks,n=this.getTickLimit();n=Math.max(2,n);let i={maxTicks:n,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},o=this._range||this,r=If(i,o);return t.bounds==="ticks"&&ki(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let t=this.ticks,e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){let i=(n-e)/Math.max(t.length-1,1)/2;e-=i,n+=i}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return ns(t,this.chart.options.locale,this.options.ticks.format)}},hs=class extends ps{determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?t:0,this.max=pt(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,n=Ht(this.options.ticks.minRotation),i=(t?Math.sin(n):Math.cos(n))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}};W(hs,"id","linear"),W(hs,"defaults",{ticks:{callback:is.formatters.numeric}});Ys=s=>Math.floor(re(s)),Oe=(s,t)=>Math.pow(10,Ys(s)+t);us=class extends ke{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){let n=ps.prototype.parse.apply(this,[t,e]);if(n===0){this._zero=!0;return}return pt(n)&&n>0?n:null}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?Math.max(0,t):null,this.max=pt(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!pt(this._userMin)&&(this.min=t===Oe(this.min,0)?Oe(this.min,-1):Oe(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),n=this.min,i=this.max,o=a=>n=t?n:a,r=a=>i=e?i:a;n===i&&(n<=0?(o(1),r(10)):(o(Oe(n,-1)),r(Oe(i,1)))),n<=0&&o(Oe(i,-1)),i<=0&&r(Oe(n,1)),this.min=n,this.max=i}buildTicks(){let t=this.options,e={min:this._userMin,max:this._userMax},n=Nf(e,this);return t.bounds==="ticks"&&ki(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(t){return t===void 0?"0":ns(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=re(t),this._valueRange=re(this.max)-re(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(re(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}};W(us,"id","logarithmic"),W(us,"defaults",{ticks:{callback:is.formatters.logarithmic,major:{enabled:!0}}});Ce=class extends ps{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=Ct(yo(this.options)/2),e=this.width=this.maxWidth-t.width,n=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+n/2+t.top),this.drawingArea=Math.floor(Math.min(e,n)/2)}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!1);this.min=pt(t)&&!isNaN(t)?t:0,this.max=pt(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/yo(this.options))}generateTickLabels(t){ps.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,n)=>{let i=lt(this.options.pointLabels.callback,[e,n],this);return i||i===0?i:""}).filter((e,n)=>this.chart.getDataVisibility(n))}fit(){let t=this.options;t.display&&t.pointLabels.display?zf(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,i){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,i))}getIndexAngle(t){let e=dt/(this._pointLabels.length||1),n=this.options.startAngle||0;return xt(t*e+Ht(n))}getDistanceFromCenterForValue(t){if(tt(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(tt(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{if(h!==0||h===0&&this.min<0){l=this.getDistanceFromCenterForValue(d.value);let u=this.getContext(h),f=i.setContext(u),p=o.setContext(u);Xf(this,f,l,r,p)}}),n.display){for(t.save(),a=r-1;a>=0;a--){let d=n.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:u}=d;!u||!h||(t.lineWidth=u,t.strokeStyle=h,t.setLineDash(d.borderDash),t.lineDashOffset=d.borderDashOffset,l=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){let t=this.ctx,e=this.options,n=e.ticks;if(!n.display)return;let i=this.getIndexAngle(0),o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;let c=n.setContext(this.getContext(l)),d=bt(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=d.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;let h=Ct(c.backdropPadding);t.fillRect(-r/2-h.left,-o-d.size/2-h.top,r+h.width,d.size+h.height)}ve(t,a.label,0,-o,d,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}};W(Ce,"id","radialLinear"),W(Ce,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:is.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),W(Ce,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),W(Ce,"descriptors",{angleLines:{_fallback:"grid"}});Jn={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}},Lt=Object.keys(Jn);we=class extends ke{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 n=t.time||(t.time={}),i=this._adapter=new al._date(t.adapters.date);i.init(e),Je(n.displayFormats,i.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:tl(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,e=this._adapter,n=t.time.unit||"day",{min:i,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(i=Math.min(i,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=pt(i)&&!isNaN(i)?i:+e.startOf(Date.now(),n),o=pt(o)&&!isNaN(o)?o:+e.endOf(Date.now(),n)+1,this.min=Math.min(i,o-1),this.max=Math.max(i+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],n=t[t.length-1]),{min:e,max:n}}buildTicks(){let t=this.options,e=t.time,n=t.ticks,i=n.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);let o=this.min,r=this.max,a=Vr(i,o,r);return this._unit=e.unit||(n.autoSkip?el(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):Zf(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit==="year"?void 0:Jf(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),nl(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let e=0,n=0,i,o;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?e=1-i:e=(this.getDecimalForValue(t[1])-i)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?n=o:n=(o-this.getDecimalForValue(t[t.length-2]))/2);let r=t.length<3?.5:.25;e=vt(e,0,r),n=vt(n,0,r),this._offsets={start:e,end:n,factor:1/(e+1+n)}}_generate(){let t=this._adapter,e=this.min,n=this.max,i=this.options,o=i.time,r=o.unit||el(o.minUnit,e,n,this._getLabelCapacity(e)),a=Q(i.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Ae(l)||l===!0,d={},h=e,u,f;if(c&&(h=+t.startOf(h,"isoWeek",l)),h=+t.startOf(h,c?"day":r),t.diff(n,e,r)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+r);let p=i.ticks.source==="data"&&this.getDataTimestamps();for(u=h,f=0;u+g)}getLabelForValue(t){let e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){let i=this.options.time.displayFormats,o=this._unit,r=e||i[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,n,i){let o=this.options,r=o.ticks.callback;if(r)return lt(r,[t,e,n],this);let a=o.time.displayFormats,l=this._unit,c=this._majorUnit,d=l&&a[l],h=c&&a[c],u=n[e],f=c&&h&&u&&u.major;return this._adapter.format(t,i||(f?h:d))}generateTickLabels(t){let e,n,i;for(e=0,n=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,n;if(t.length)return t;let i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(e=0,n=i.length;e=e&&c<=n&&i.push(c);if(i.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(r=0,a=i.length;ri-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;let e=this.getDataTimestamps(),n=this.getLabelTimestamps();return e.length&&n.length?t=this.normalize(e.concat(n)):t=e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return($n(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){let e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return $n(this._table,n*this._tableRange+this._minPos,!0)}};W(fs,"id","timeseries"),W(fs,"defaults",we.defaults);Vl=Object.freeze({__proto__:null,CategoryScale:ds,LinearScale:hs,LogarithmicScale:us,RadialLinearScale:Ce,TimeScale:we,TimeSeriesScale:fs}),ep=[rl,_l,Fl,Vl]});var ap={};Eo(ap,{CardView:()=>gs,default:()=>ti});module.exports=Jl(ap);var it=require("obsidian"),Ul=Xs(vs());var tc=["AT","BE","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IT","LV","LI","LT","LU","MT","NL","NO","PL","PT","SK","SI","ES","SE","CH"],ec=[{label:"\u{1F1EA}\u{1F1FA} Schengen 90/180 (example)",scope:{countries:tc},window:{type:"rolling",days:180},threshold:90,note:"Example rule \u2014 add your own in Settings \u2192 CSV Card View."}],oi={defaultMode:"kanban-genre",notesColumns:["notes","note","Notes","Note","description","Description","review","Review"],statusColumn:"status",categoryColumn:"category",notesSubfolder:"Notes",columnWidths:{},selectColumns:["Category","Type","Rating","Status","rating","type","category","status","Score /5"],fileConfigs:{},residencyRules:ec,showResidency:!0},Qs="xlsx-card-view";var ko=Xs(vs()),Mo=require("obsidian"),Zs=["Image","image","Cover","cover","Poster","poster","Thumbnail","thumbnail","Thumb","thumb","Photo","photo","Picture","picture","Img","img"];function Js(s,t,e){let n=(t!=null?t:"").trim();if(!n)return null;if(/^(https?:|data:)/i.test(n))return n;let i=n.match(/!?\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/);if(i)n=i[1].trim();else{let r=n.match(/!\[[^\]]*\]\(([^)]+)\)/);r&&(n=r[1].trim())}if(/^(https?:|data:)/i.test(n))return n;let o=s.metadataCache.getFirstLinkpathDest(n,e);return o instanceof Mo.TFile?s.vault.getResourcePath(o):null}var sc=15;function ys(s){return s>=1&&s<=sc}var nc=["0","1","true","false","yes","no",""];function tn(s){return s.length>0&&s.every(t=>nc.includes(t))}function xs(s){return s.replace(/[\\/:*?"<>|#^[\]]/g,"").replace(/\s+/g," ").trim().slice(0,100)}function Do(s){return s.toLowerCase().replace(/[^\p{L}\p{N}/_-]+/gu,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Gt(s){var i,o;if(!s||!s.trim())return{headers:[],rows:[]};let t=ko.default.parse(s,{header:!0,skipEmptyLines:!0}),e=((i=t.meta.fields)!=null?i:[]).map(String),n=((o=t.data)!=null?o:[]).map(r=>{let a={};return e.forEach(l=>{a[l]=r[l]!=null?String(r[l]):""}),a});return{headers:e,rows:n}}function We(s,t){if(!s)return s;let e=s.startsWith("./")||s.startsWith("../")||s==="."||s==="..";if(!e&&s.includes("/"))return s;if(!e)return t?`${t}/${s}`:s;let n=t?t.split("/").filter(Boolean):[];for(let i of s.split("/"))if(!(i===""||i===".")){if(i===".."){n.pop();continue}n.push(i)}return n.join("/")}function To(s,t,e){let n=e==="asc"?1:-1;return[...s].sort((i,o)=>{var u,f;let r=((u=i[t])!=null?u:"").trim(),a=((f=o[t])!=null?f:"").trim();if(!r&&!a)return 0;if(!r)return 1;if(!a)return-1;let l=parseFloat(r),c=parseFloat(a);return(!isNaN(l)&&!isNaN(c)&&/^-?[\d.]/.test(r)&&/^-?[\d.]/.test(a)?l-c:r.localeCompare(a,void 0,{numeric:!0,sensitivity:"base"}))*n})}function kt(s){return s.split(/[\s_-]+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}function Lo(s,t){let e=(s!=null?s:"").trim();if(!e||e.toLowerCase()==="unrated"||e==="\u2014"||e==="-")return"";if(/[★⭐☆]/.test(e))return e;if(/^\d+$/.test(e)){let o=parseInt(e,10);if(o>=1&&o<=5)return"\u2605".repeat(o)}let i=ic(e,t);return i&&i!==e&&i!=="\u2014"?i:""}function ic(s,t){var o;let e=t.toLowerCase();if(!["rating","score","score /5"].includes(e))return s;let n=s.toLowerCase().trim();return(o={excellent:"\u2605\u2605\u2605\u2605\u2605",great:"\u2605\u2605\u2605\u2605\u2605",good:"\u2605\u2605\u2605\u2605\u2606",fair:"\u2605\u2605\u2605\u2606\u2606",poor:"\u2605\u2605\u2606\u2606\u2606",bad:"\u2605\u2606\u2606\u2606\u2606",5:"\u2605\u2605\u2605\u2605\u2605",4:"\u2605\u2605\u2605\u2605\u2606",3:"\u2605\u2605\u2605\u2606\u2606",2:"\u2605\u2605\u2606\u2606\u2606",1:"\u2605\u2606\u2606\u2606\u2606",0:"\u2606\u2606\u2606\u2606\u2606",unrated:"\u2014","":"\u2014"}[n])!=null?o:s}function Ao(s,t){if(/^(year|released|decade)$/i.test((s!=null?s:"").trim()))return!0;let e=t.map(i=>(i!=null?i:"").trim()).filter(Boolean);return e.length<3?!1:e.filter(i=>/^(1[89]|20)\d{2}$/.test(i)).length/e.length>=.8}function Po(s){let t=(s!=null?s:"").match(/\b(1[89]\d{2}|20\d{2})\b/);return t?`${Math.floor(parseInt(t[1],10)/10)*10}s`:null}function Ro(s,t,e){var r;if(!t.length)return null;let n=Math.max(12,t.length/3),i=null,o=1/0;for(let a of s){if(e.has(a))continue;let l=new Set;for(let d of t)((r=d[a])!=null?r:"").split(",").forEach(h=>{let u=h.trim();u&&l.add(u)});if(l.size<2||l.size>n)continue;let c=Math.abs(Math.log(l.size/8));cw.remove());let r=document.body.createDiv({cls:"csv-select-picker"});r.style.position="fixed",r.style.zIndex="9999";let a=()=>{let w=s.getBoundingClientRect(),L=r.offsetHeight||280,k=w.bottom+4+L>window.innerHeight&&w.top-4-L>0;r.style.left=w.left+"px",r.style.top=k?w.top-4-L+"px":w.bottom+4+"px"};a();let l=w=>{!r.contains(w.target)&&w.target!==s&&d()},c=w=>{r.contains(w.target)||d()},d=()=>{r.remove(),document.removeEventListener("mousedown",l),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",d)},h=r.createEl("input",{cls:"csv-picker-search",type:"text",placeholder:"Search or add\u2026"});h.focus();let u=r.createDiv({cls:"csv-picker-list"}),f=!!(o!=null&&o.multi),p=w=>w.split(",").map(L=>L.trim()).filter(Boolean),g=new Set(f?p(t):[]),m=()=>n([...g].join(", ")),b=f?Array.from(new Set(e.flatMap(p))):Array.from(new Set(e.filter(Boolean))),x=[],_=0,E=()=>{u.querySelectorAll(".csv-picker-item").forEach((w,L)=>{w.toggleClass("csv-picker-item--hover",L===_),L===_&&w.scrollIntoView({block:"nearest"})})},S=w=>{if(!f){n(w.isClear?"":w.value),d();return}w.isClear?g.clear():(g.has(w.value)?g.delete(w.value):g.add(w.value),w.isAdd&&!b.includes(w.value)&&b.push(w.value)),m(),w.isAdd?(h.value="",C("")):C(h.value)},v=w=>f?g.has(w):w===t,y=()=>f?g.size>0:!!t,C=w=>{u.empty(),x=[];let L=w?b.filter(k=>k.toLowerCase().includes(w.toLowerCase())):b;if(y()){x.push({value:"",isClear:!0});let k=u.createDiv({cls:"csv-picker-item csv-picker-clear"});k.setText(f?"\u2715 Clear all":"\u2715 Clear"),k.addEventListener("mousedown",A=>{A.preventDefault(),S({value:"",isClear:!0})})}if(L.forEach(k=>{x.push({value:k});let A=u.createDiv({cls:`csv-picker-item ${v(k)?"active":""}`});A.setText(f?`${g.has(k)?"\u2713 ":""}${k}`:k),A.addEventListener("mousedown",P=>{P.preventDefault(),S({value:k})})}),w&&!b.some(k=>k.toLowerCase()===w.toLowerCase())){x.push({value:w,isAdd:!0});let k=u.createDiv({cls:"csv-picker-item csv-picker-add"});k.setText(`+ Add "${w}"`),k.addEventListener("mousedown",A=>{A.preventDefault(),S({value:w,isAdd:!0})})}!L.length&&!w&&u.createDiv({cls:"csv-picker-empty",text:"No options yet. Type to add."}),_=Math.min(_,Math.max(x.length-1,0)),E()};f&&r.createEl("button",{cls:"csv-picker-done",text:"Done"}).addEventListener("mousedown",w=>{w.preventDefault(),d()}),C(""),a(),h.addEventListener("input",()=>{_=0,C(h.value),a()});let D=typeof window!="undefined"&&((M=window.matchMedia)==null?void 0:M.call(window,"(pointer: coarse)").matches);setTimeout(()=>{document.addEventListener("mousedown",l),D||(window.addEventListener("scroll",c,!0),window.addEventListener("resize",d))},0),h.addEventListener("keydown",w=>{if(w.key==="Escape"){d();return}if(w.key==="ArrowDown"){w.preventDefault(),x.length&&(_=(_+1)%x.length,E());return}if(w.key==="ArrowUp"){w.preventDefault(),x.length&&(_=(_-1+x.length)%x.length,E());return}if(w.key==="Enter")if(w.preventDefault(),x[_])S(x[_]);else{let L=h.value.trim();L&&(n(L),d())}})}function Oo(s,t,e){return!s[t]||t===e||(s[e]||(s[e]=s[t]),delete s[t]),s}var Vt=require("obsidian");var oc={source:["confirmed","inferred","conflict"],resolved:["yes","no"]};function Fo(s){var t;return(t=oc[s.trim().toLowerCase()])!=null?t:null}function en(s){return/(^|[_\s-])(date|due|deadline)([_\s-]|$)/i.test(s.trim())}var Io=/^\d{4}-\d{2}-\d{2}$/;function on(s,t,e,n){let i=en(t)&&(e===""||Io.test(e)),o=s.createEl("input",{cls:n,type:i?"date":"text",value:e});i||(o.placeholder=t);let r=Fo(t);if(r){let a=`csv-dl-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${Math.random().toString(36).slice(2,7)}`,l=s.createEl("datalist");l.id=a,r.forEach(c=>l.createEl("option",{value:c})),o.setAttr("list",a)}return o}var je=class extends Vt.Modal{constructor(t,e,n,i,o,r,a={},l=()=>!1){super(t),this.headers=e,this.isNotesCol=n,this.isSelectCol=i,this.getColumnValues=o,this.onSubmit=r,this.optionPresets=a,this.isBooleanCol=l}onOpen(){let{contentEl:t}=this;t.empty(),t.addClass("csv-add-modal"),t.createEl("h2",{text:"Add new entry",cls:"csv-modal-title"});let e=t.createDiv({cls:"csv-modal-form"}),n={};this.headers.forEach(d=>n[d]="");let i=this.headers.find(d=>["title","name"].includes(d.toLowerCase())),o=new Map;i&&this.getColumnValues(i).forEach(d=>{let h=d.trim().toLowerCase();h&&!o.has(h)&&o.set(h,d.trim())}),this.headers.forEach(d=>{var g;let h=e.createDiv({cls:"csv-modal-row"});h.createEl("label",{text:kt(d),cls:"csv-modal-label"});let u=(g=this.optionPresets[d])!=null?g:[],f=!this.isSelectCol(d)&&!It(d)&&!en(d)&&ys(this.getColumnValues(d).length),p=!this.isNotesCol(d)&&(u.length>0||this.isSelectCol(d)&&!It(d)||f);if(this.isBooleanCol(d)){n[d]="0";let m=h.createDiv({cls:"csv-toggle"});m.createDiv({cls:"csv-toggle-knob"}),m.addEventListener("click",()=>{let b=!m.hasClass("is-on");m.toggleClass("is-on",b),n[d]=b?"1":"0"})}else if(this.isNotesCol(d)){let m=h.createEl("textarea",{cls:"csv-modal-textarea",placeholder:"Markdown supported\u2026"});m.addEventListener("input",()=>{n[d]=m.value})}else if(p){let m="__custom__",b=[];[...u,...this.getColumnValues(d)].forEach(E=>{let S=(E!=null?E:"").trim();S&&!b.some(v=>v.toLowerCase()===S.toLowerCase())&&b.push(S)});let x=h.createEl("select",{cls:"csv-modal-select"});x.createEl("option",{text:"\u2014",value:""}),b.forEach(E=>x.createEl("option",{text:E,value:E})),x.createEl("option",{text:"+ Custom\u2026",value:m});let _=h.createEl("input",{cls:"csv-modal-input csv-modal-custom",type:"text",placeholder:`Custom ${kt(d).toLowerCase()}`});_.hide(),_.addEventListener("input",()=>{n[d]=_.value}),_.addEventListener("keydown",E=>{E.key==="Enter"&&c()}),x.addEventListener("change",()=>{x.value===m?(_.show(),_.focus(),n[d]=_.value):(_.hide(),n[d]=x.value)})}else if(this.isSelectCol(d)){let b=h.createDiv({cls:"csv-modal-select-wrap"}).createDiv({cls:"csv-select-chip empty"});b.setText("\u2014 click to select \u2014"),b.addEventListener("click",x=>{x.stopPropagation(),Ot(b,n[d],this.getColumnValues(d),_=>{n[d]=_,b.setText(_||"\u2014 click to select \u2014"),b.toggleClass("empty",!_)},t,{multi:It(d)})})}else{let m=on(h,d,"","csv-modal-input");if(m.addEventListener("input",()=>{n[d]=m.value}),m.addEventListener("keydown",b=>{b.key==="Enter"&&c()}),d===i&&o.size){let b=h.createDiv({cls:"csv-modal-dup-hint"});b.hide(),m.addEventListener("input",()=>{let x=o.get(m.value.trim().toLowerCase());x?(b.setText(`\u26A0 \u201C${x}\u201D is already in this file`),b.show()):b.hide()})}}});let r=t.createDiv({cls:"csv-modal-btns"});r.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),r.createEl("button",{text:"Add entry",cls:"csv-modal-submit"}).addEventListener("click",()=>c());let c=()=>{if(!Object.values(n).some(h=>h.trim())){new Vt.Notice("Fill in at least one field.");return}this.onSubmit(n),this.close()}}onClose(){this.contentEl.empty()}},Ue=class extends Vt.Modal{constructor(e,n,i,o,r,a,l,c,d,h){super(e);this.vvHandler=null;this.row={...n},this.notesCol=i,this.headers=o,this.filePath=r,this.renderComponent=new Vt.Component,this.isNotesCol=a,this.isSelectCol=l,this.getColumnValues=c,this.onSave=d,this.onDelete=h,this.modalEl.addClass("csv-note-expander-modal")}onOpen(){var p,g,m,b,x;this.renderComponent.load();let{contentEl:e}=this;e.empty(),e.addClass("csv-note-expander");let n=window.visualViewport;if(n){let _=()=>{this.modalEl.style.setProperty("--csv-modal-vh",`${n.height}px`)};_(),n.addEventListener("resize",_),n.addEventListener("scroll",_),this.vvHandler=_}let i=e.createDiv({cls:"csv-expander-header"});i.createDiv({cls:"csv-expander-title",text:(g=this.row[(p=this.headers.find(_=>["title","name","Title","Name"].includes(_)))!=null?p:this.headers[0]])!=null?g:"\u2014"});let o=i.createDiv({cls:"csv-expander-header-btns"}),r=e.createDiv({cls:"csv-expander-fields"}),a=this.headers.find(_=>["title","name","Title","Name"].includes(_)),l=this.headers.find(_=>["author","Author","director","Director","artist","Artist","creator","Creator"].includes(_));this.headers.forEach(_=>{if(this.isNotesCol(_))return;let E=r.createDiv({cls:"csv-expander-field-row"});if(E.createDiv({cls:"csv-expander-field-label",text:kt(_)}),this.isSelectCol(_)||!It(_)&&!en(_)&&ys(this.getColumnValues(_).length)){let v=E.createDiv({cls:`csv-select-chip ${this.row[_]?"":"empty"}`});v.setText(this.row[_]||"\u2014"),v.addEventListener("click",y=>{y.stopPropagation(),Ot(v,this.row[_],this.getColumnValues(_),C=>{this.row[_]=C,v.setText(C||"\u2014"),v.toggleClass("empty",!C)},e,{multi:It(_)})})}else{let v=E.createDiv({cls:"csv-expander-field-value",text:this.row[_]||"\u2014"});v.addEventListener("click",()=>{var D;v.empty();let y=on(v,_,(D=this.row[_])!=null?D:"","csv-inline-input");y.focus(),y.type==="text"&&y.select();let C=()=>{this.row[_]=y.value,v.empty(),v.setText(y.value||"\u2014")};y.addEventListener("blur",C),y.addEventListener("keydown",M=>{M.key==="Enter"&&y.blur(),M.key==="Escape"&&(v.empty(),v.setText(this.row[_]||"\u2014"))})})}});let c=!1,d=this.notesCol&&(m=this.row[this.notesCol])!=null?m:"",h=null;if(this.notesCol){e.createDiv({cls:"csv-expander-divider"}).createDiv({cls:"csv-expander-notes-label",text:this.notesCol});let E=e.createDiv({cls:"csv-expander-rendered markdown-rendered"});E.title="Click to edit";let S=e.createDiv({cls:"csv-expander-editor"});S.style.display="none";let v=()=>{E.empty(),d.trim()?Vt.MarkdownRenderer.render(this.app,d,E,this.filePath,this.renderComponent):E.createDiv({cls:"csv-notes-empty",text:"+ Add note"})};v(),h=S.createEl("textarea",{cls:"csv-expander-textarea"}),h.value=d,h.addEventListener("input",()=>{d=h.value});let y=()=>{c||(c=!0,E.style.display="none",S.style.display="flex",h.value=d,h.focus())},C=()=>{c&&(c=!1,S.style.display="none",E.style.display="",d=h.value,v())};E.addEventListener("click",D=>{if(D.target.closest("a, button, input, textarea, [contenteditable]"))return;let w=window.getSelection();w&&w.toString().length>0||y()}),h.addEventListener("keydown",D=>{D.key==="Escape"&&(D.preventDefault(),h.blur())}),h.addEventListener("blur",C)}let u=e.createDiv({cls:"csv-expander-footer"});if(this.onDelete){let _=String((x=this.row[(b=this.headers.find(E=>["title","name","Title","Name"].includes(E)))!=null?b:this.headers[0]])!=null?x:"").trim();u.createEl("button",{cls:"csv-expander-delete-btn",text:"Delete"}).addEventListener("click",()=>{let E=_||"this entry";window.confirm(`Delete "${E}"? This can't be undone.`)&&(this.onDelete(),this.close())})}let f=u.createDiv({cls:"csv-expander-footer-right"});f.createEl("button",{cls:"csv-modal-cancel",text:"Cancel"}).addEventListener("click",()=>this.close()),f.createEl("button",{cls:"csv-expander-save-btn",text:"Save & close"}).addEventListener("click",()=>{this.notesCol&&(c&&h&&(d=h.value),this.row[this.notesCol]=d),this.onSave(this.row),this.close()})}onClose(){let e=window.visualViewport;e&&this.vvHandler&&(e.removeEventListener("resize",this.vvHandler),e.removeEventListener("scroll",this.vvHandler)),this.vvHandler=null,this.renderComponent.unload(),this.contentEl.empty()}};var sn=class extends Vt.Modal{constructor(t,e,n,i,o,r,a,l,c,d,h){super(t),this.headers=e,this.filePath=n,this.current={...i,habitColumns:i.habitColumns?[...i.habitColumns]:void 0},this.autoDetectedHabits=o,this.availableModes=r,this.onSave=a,this.getHeaders=l,this.getFileCfg=c,this.onAddColumn=d,this.onRemoveColumn=h}onOpen(){var P,I,z;let{contentEl:t}=this;t.empty(),t.addClass("csv-add-modal"),t.createEl("h2",{text:"View settings for this file",cls:"csv-modal-title"}),t.createEl("p",{text:"These settings apply only to this file and override the global defaults.",cls:"csv-modal-desc"});let e=t.createDiv({cls:"csv-modal-form"}),n="\u2014 use global default \u2014",i=[n,...this.headers],o=()=>{this.headers=this.getHeaders();let R=this.getFileCfg();this.current={...R,habitColumns:R.habitColumns?[...R.habitColumns]:void 0},this.onOpen()},r=e.createDiv({cls:"csv-modal-row"});r.createEl("label",{text:"Columns",cls:"csv-modal-label"});let a=r.createDiv({cls:"csv-modal-column-list"});this.headers.forEach(R=>{let V=a.createDiv({cls:"csv-modal-column-chip"});V.createSpan({text:R});let T=V.createEl("button",{cls:"csv-modal-column-remove",text:"\u2715",attr:{title:`Remove "${R}" \u2014 deletes this column's data from every row`}});T.addEventListener("click",()=>{if(T.hasClass("confirm")){this.onRemoveColumn(R),o();return}a.querySelectorAll(".csv-modal-column-remove.confirm").forEach(O=>{O.removeClass("confirm"),O.setText("\u2715")}),T.addClass("confirm"),T.setText("Confirm?"),window.setTimeout(()=>{T.isConnected&&(T.removeClass("confirm"),T.setText("\u2715"))},3e3)})});let l=r.createDiv({cls:"csv-modal-add-column"}),c=l.createEl("input",{cls:"csv-modal-input",type:"text",placeholder:"New column name"}),d=l.createEl("button",{cls:"csv-modal-cancel",text:"+ Add column"}),h=()=>{let R=this.onAddColumn(c.value);if(R){new Vt.Notice(R);return}o()};d.addEventListener("click",h),c.addEventListener("keydown",R=>{R.key==="Enter"&&(R.preventDefault(),h())});let u=(R,V,T)=>{let O=e.createDiv({cls:"csv-modal-row"});O.createEl("label",{text:R,cls:"csv-modal-label"});let j=O.createEl("select",{cls:"csv-modal-select"});i.forEach(U=>{let K=j.createEl("option",{text:U,value:U});(V!=null?V:n)===U&&(K.selected=!0)}),j.addEventListener("change",()=>T(j.value===n?void 0:j.value))};u("Category column (kanban grouping)",this.current.categoryColumn,R=>{this.current.categoryColumn=R}),u("Status column (row subgroups)",this.current.statusColumn,R=>{this.current.statusColumn=R}),u("Notes column",this.current.notesColumn,R=>{this.current.notesColumn=R});let f=e.createDiv({cls:"csv-modal-row"});f.createEl("label",{text:"Habit columns (dashboard)",cls:"csv-modal-label"});let p=f.createEl("p",{cls:"csv-modal-hint",text:"Select columns to track as habits. Auto-detected columns with binary values (0/1) are pre-selected."}),g=f.createDiv({cls:"csv-modal-checkbox-grid"}),m=new Set((P=this.current.habitColumns)!=null?P:this.autoDetectedHabits);this.headers.forEach(R=>{let V=g.createEl("label",{cls:"csv-modal-checkbox-label"}),T=V.createEl("input",{type:"checkbox"});T.checked=m.has(R),this.autoDetectedHabits.includes(R)&&!this.current.habitColumns&&V.addClass("auto-detected"),V.createSpan({text:R}),T.addEventListener("change",()=>{this.current.habitColumns||(this.current.habitColumns=[...this.autoDetectedHabits]),T.checked?this.current.habitColumns.includes(R)||this.current.habitColumns.push(R):this.current.habitColumns=this.current.habitColumns.filter(O=>O!==R)})});let b=e.createDiv({cls:"csv-modal-row"});b.createEl("label",{text:"Card fields (Library / Kanban)",cls:"csv-modal-label"}),b.createEl("p",{cls:"csv-modal-hint",text:"Columns shown under each card title. Rating renders as stars, theme/tag columns as pills. Leave all unchecked for title-only cards."});let x=b.createDiv({cls:"csv-modal-checkbox-grid"}),_=R=>this.headers.find(V=>R.some(T=>T.toLowerCase()===V.toLowerCase())),E=[_(["Author","Authors","Director","Artist","Creator","By"]),_(["Year","Date","Released"]),_(["Rating","Score","Score /5","Stars"]),_(["Theme","Tags","Tag","Mood"])].filter(R=>!!R),S=new Set((I=this.current.cardFields)!=null?I:E),v=!!this.current.cardFields;this.headers.forEach(R=>{let V=x.createEl("label",{cls:"csv-modal-checkbox-label"}),T=V.createEl("input",{type:"checkbox"});T.checked=S.has(R),E.includes(R)&&!v&&V.addClass("auto-detected"),V.createSpan({text:R}),T.addEventListener("change",()=>{this.current.cardFields||(this.current.cardFields=[...E]),T.checked?this.current.cardFields.includes(R)||this.current.cardFields.push(R):this.current.cardFields=this.current.cardFields.filter(O=>O!==R)})});let y="\u2014 title / primary field \u2014",C=e.createDiv({cls:"csv-modal-row"});C.createEl("label",{text:"Anki card front",cls:"csv-modal-label"}),C.createEl("p",{cls:"csv-modal-hint",text:"Column used as the front of each card when syncing to Anki. Other columns become the back."});let D=C.createEl("select",{cls:"csv-modal-select"});[y,...this.headers].forEach(R=>{var T;let V=D.createEl("option",{text:R,value:R});((T=this.current.ankiFrontCol)!=null?T:y)===R&&(V.selected=!0)}),D.addEventListener("change",()=>{this.current.ankiFrontCol=D.value===y?void 0:D.value});let M=e.createDiv({cls:"csv-modal-row"});M.createEl("label",{text:"Default view",cls:"csv-modal-label"});let w=M.createEl("select",{cls:"csv-modal-select"}),L=[["\u2014 use global default \u2014",""],...this.availableModes.map(R=>[R.label,R.id])],k=(z=this.current.defaultMode)!=null?z:"";k&&!this.availableModes.some(R=>R.id===k)&&L.push([`${k} (no longer available)`,k]),L.forEach(([R,V])=>{let T=w.createEl("option",{text:R,value:V});k===V&&(T.selected=!0)}),w.addEventListener("change",()=>{this.current.defaultMode=w.value?w.value:void 0});let A=t.createDiv({cls:"csv-modal-btns"});A.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),A.createEl("button",{text:"Save",cls:"csv-modal-submit"}).addEventListener("click",()=>{this.onSave(this.current),this.close()})}onClose(){this.contentEl.empty()}},nn=class extends Vt.Modal{constructor(e,n,i,o,r){super(e);this.title=n;this.initial=i;this.placeholder=o;this.onSubmit=r}onOpen(){let{contentEl:e}=this;e.empty(),e.addClass("csv-add-modal"),e.createEl("h2",{text:this.title,cls:"csv-modal-title"});let n=e.createEl("input",{cls:"csv-modal-field",type:"text"});n.value=this.initial,n.placeholder=this.placeholder,window.setTimeout(()=>{n.focus(),n.select()},0);let i=()=>{let r=n.value.trim();r&&(this.onSubmit(r),this.close())};n.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),i())});let o=e.createDiv({cls:"csv-modal-btns"});o.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),o.createEl("button",{text:"Create",cls:"csv-modal-submit"}).addEventListener("click",i)}onClose(){this.contentEl.empty()}};var ri=195,rc={AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AD:"Andorra",AO:"Angola",AR:"Argentina",AM:"Armenia",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BD:"Bangladesh",BY:"Belarus",BE:"Belgium",BO:"Bolivia",BA:"Bosnia",BW:"Botswana",BR:"Brazil",BG:"Bulgaria",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CL:"Chile",CN:"China",CO:"Colombia",HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:"Czechia",DK:"Denmark",DO:"Dominican Rep.",EC:"Ecuador",EG:"Egypt",ET:"Ethiopia",FI:"Finland",FR:"France",GE:"Georgia",DE:"Germany",GH:"Ghana",GR:"Greece",GT:"Guatemala",GY:"Guyana",HT:"Haiti",HN:"Honduras",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran",IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KP:"N. Korea",KR:"S. Korea",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Laos",LV:"Latvia",LB:"Lebanon",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MY:"Malaysia",ML:"Mali",MT:"Malta",MR:"Mauritania",MX:"Mexico",MD:"Moldova",MN:"Mongolia",ME:"Montenegro",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NP:"Nepal",NL:"Netherlands",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NO:"Norway",OM:"Oman",PK:"Pakistan",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PL:"Poland",PT:"Portugal",QA:"Qatar",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SO:"Somalia",ZA:"South Africa",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SE:"Sweden",CH:"Switzerland",SY:"Syria",TJ:"Tajikistan",TZ:"Tanzania",TH:"Thailand",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",UG:"Uganda",UA:"Ukraine",AE:"UAE",GB:"United Kingdom",US:"United States",UY:"Uruguay",UZ:"Uzbekistan",VN:"Vietnam",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",MC:"Monaco",BZ:"Belize"},ac={AF:["DZ","AO","BJ","BW","BF","BI","CM","CV","CF","TD","KM","CD","CG","CI","DJ","EG","GQ","ER","ET","GA","GM","GH","GN","GW","KE","LS","LR","LY","MG","MW","ML","MR","MU","MA","MZ","NA","NE","NG","RE","RW","ST","SN","SC","SL","SO","ZA","SS","SD","TZ","TG","TN","UG","ZM","ZW"],AN:["AQ"],AS:["AF","AM","AZ","BH","BD","BT","BN","KH","CN","CY","GE","IN","ID","IR","IQ","IL","JP","JO","KZ","KW","KG","LA","LB","MY","MV","MN","MM","NP","KP","OM","PK","PS","PH","QA","RU","SA","SG","KR","LK","SY","TW","TJ","TH","TL","TR","TM","AE","UZ","VN","YE"],EU:["AL","AD","AT","BY","BE","BA","BG","HR","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IE","IT","XK","LV","LI","LT","LU","MT","MD","MC","ME","NL","MK","NO","PL","PT","RO","RU","SM","RS","SK","SI","ES","SE","CH","UA","GB","VA"],NA:["AG","BS","BB","BZ","CA","CR","CU","DM","DO","SV","GD","GT","HT","HN","JM","MX","NI","PA","KN","LC","VC","TT","US"],OC:["AU","FJ","KI","MH","FM","NR","NZ","PW","PG","WS","SB","TO","TV","VU"],SA:["AR","BO","BR","CL","CO","EC","GY","PY","PE","SR","UY","VE"]},Vo={AF:"Africa",AN:"Antarctica",AS:"Asia",EU:"Europe",NA:"N. America",OC:"Oceania",SA:"S. America"},No={};for(let[s,t]of Object.entries(ac))for(let e of t)No[e]=s;function Et(s){return rc[s]||s}function $t(s){return!s||s.length!==2?"":String.fromCodePoint(...s.toUpperCase().split("").map(t=>t.charCodeAt(0)+127397))}function Nt(s){if(!s||s.indexOf("?")!==-1)return null;let t=new Date(s+"T12:00:00Z");return isNaN(t.getTime())?null:t}function _s(s){let t=Nt(s.date_entered),e=Nt(s.date_left);return!t||!e?0:Math.max(Math.round((e.getTime()-t.getTime())/864e5),1)}function Bo(s,t=new Date){let e=t.getTime(),n=null,i=-1/0;for(let o of s){let r=Nt(o.date_entered);if(!(!r||r.getTime()>e)){if(o.date_left.trim()!==""){let a=Nt(o.date_left);if(!a||a.getTime()i&&(n=o,i=r.getTime())}}return n}function zo(s){let t=b=>{var x,_,E,S,v,y,C,D;return{date_entered:(x=b.date_entered)!=null?x:"",date_left:(_=b.date_left)!=null?_:"",country:((E=b.country)!=null?E:"").trim().toUpperCase(),city:(S=b.city)!=null?S:"",visa_status:(v=b.visa_status)!=null?v:"",notes:(y=b.notes)!=null?y:"",source:((C=b.source)!=null?C:"").trim().toLowerCase(),resolved:(D=b.resolved)!=null?D:"",_src:b}},e=s.map(t).filter(b=>b.country),n=e.filter(b=>b.source==="confirmed"),i=e.filter(b=>b.source==="inferred"),o=e.filter(b=>b.source==="conflict"),r=[];for(let b of n){let x=Nt(b.date_entered),_=Nt(b.date_left);x&&_&&r.push([x.getTime(),_.getTime()])}let a=b=>{let x=Nt(b.date_entered),_=Nt(b.date_left);if(!x||!_)return!1;let E=x.getTime(),S=_.getTime();return r.some(([v,y])=>E<=y&&S>=v)},l=i.filter(b=>Nt(b.date_entered)&&Nt(b.date_left)&&!a(b)),c=new Set(n.map(b=>b.country)),d=new Set(i.map(b=>b.country)),h=new Set([...d].filter(b=>!c.has(b))),u=new Set([...c,...d]),f=new Map;for(let b of n)f.set(b.country,(f.get(b.country)||0)+_s(b));let p=[...f.entries()].map(([b,x])=>({iso:b,days:x})).sort((b,x)=>x.days-b.days||Et(b.iso).localeCompare(Et(x.iso))),g=p.reduce((b,x)=>b+x.days,0),m=new Set;for(let b of c){let x=No[b];x&&m.add(x)}return{confirmed:n,inferred:i,conflicts:o,inferredVisible:l,confRanges:r,confirmedCountries:c,inferredOnlyCountries:h,allCountries:u,countryDays:p,totalConfirmedDays:g,visitedContinents:m,worldPct:Math.round(c.size/ri*100)}}var ai=864e5;function Ho(s){if(!s||s.indexOf("?")!==-1)return null;let t=Date.parse(s+"T00:00:00Z");return isNaN(t)?null:t}function lc(s,t,e,n){let i=Math.max(s,e),o=Math.min(t,n);return o<=i?0:Math.round((o-i)/ai)}function cc(s,t){var i;let e=s.window;if(e.type==="all-time")return{start:-1/0,end:1/0,label:"all time"};if(e.type==="calendar-year"){let o=new Date(t).getUTCFullYear();return{start:Date.UTC(o,0,1),end:Date.UTC(o+1,0,1),label:`in ${o}`}}let n=(i=e.days)!=null?i:180;return{start:t-n*ai,end:t+ai,label:`in last ${n} days`}}function $o(s,t,e=Date.now()){var d,h,u;let n=(d=s.scope.countries)!=null?d:s.scope.country?[s.scope.country]:[],i=new Set(n.map(f=>f.toUpperCase())),o=new Set(((u=(h=s.exempt)==null?void 0:h.visa_status)!=null?u:[]).map(f=>f.toLowerCase().trim())),r=cc(s,e),a=0;for(let f of t){if(!i.has((f.country||"").toUpperCase())||o.has((f.visa_status||"").toLowerCase().trim()))continue;let p=Ho(f.date_entered),g=Ho(f.date_left);p===null||g===null||(a+=lc(p,g,r.start,r.end))}let l=s.threshold-a,c=a>=s.threshold?"over":a/s.threshold>=.8?"warn":"ok";return{rule:s,used:a,threshold:s.threshold,remaining:l,windowLabel:r.label,status:c}}var Wo=["#c9a96e","#4a6fa5","#5ba06e","#a05b8a","#6ea0a0","#a0855b","#7a6ea0","#a06e6e","#6e8fa0","#a09e5b"],dc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function hc(){let s=new Map,t=0;return e=>(s.has(e)||s.set(e,Wo[t++%Wo.length]),s.get(e))}function uc(s){let t=document.body.createDiv({cls:"csv-tv-tooltip"}),e=null,n=(r,a)=>{let c=r+14,d=a+16,h=t.offsetWidth,u=t.offsetHeight;c+h+8>window.innerWidth&&(c=r-h-14),d+u+8>window.innerHeight&&(d=a-u-16),t.style.left=`${Math.max(8,c)}px`,t.style.top=`${Math.max(8,d)}px`},i=r=>{var c,d;let a=(d=(c=r.target)==null?void 0:c.closest("[data-tip]"))!=null?d:null,l=(a==null?void 0:a.getAttribute("data-tip"))||"";if(!a||!l){e&&(e=null,t.removeClass("is-on"));return}a!==e&&(e=a,t.setText(l),t.addClass("is-on")),n(r.clientX,r.clientY)},o=()=>{e=null,t.removeClass("is-on")};return s.addEventListener("pointermove",i),s.addEventListener("pointerleave",o),()=>{s.removeEventListener("pointermove",i),s.removeEventListener("pointerleave",o),t.remove()}}function li(s){let t=_s(s);return t?`${t}d`:"\u2014"}function Ke(s){return s||"\u2014"}function Ss(s){return s.createDiv({cls:"csv-tv-table-wrap"}).createEl("table",{cls:"csv-tv-table"})}function Cs(s,t,e,n){s.addClass("csv-tv-editable"),s.title="Click to edit";let i=()=>{s.empty(),s.setText(t[e]?t[e]:"\u2014")};i(),s.addEventListener("click",()=>{var r;if(s.querySelector("input"))return;s.empty();let o=on(s,e,(r=t[e])!=null?r:"","csv-inline-input");o.focus(),o.type==="text"&&o.select(),o.addEventListener("blur",()=>{t[e]=o.value,n(),i()}),o.addEventListener("keydown",a=>{var l;a.key==="Enter"&&o.blur(),a.key==="Escape"&&(o.value=(l=t[e])!=null?l:"",o.blur())})})}async function jo(s,t,e,n=()=>{},i=null,o=()=>{}){let r=zo(t),a=s.createDiv({cls:"csv-tv"});if(!r.confirmed.length&&!r.inferred.length){a.createDiv({cls:"csv-empty-state",text:"No travel rows found. Expected columns: country, date_entered, date_left, source."});return}o(uc(a));let l=null,c=()=>{a.querySelectorAll(".country-path").forEach(f=>{let p=(f.getAttribute("data-iso")||"").toUpperCase();f.classList.toggle("cp-selected",!!l&&p===l)}),a.querySelectorAll(".csv-tv-seg").forEach(f=>{f.classList.toggle("is-dim",!!l&&f.getAttribute("data-iso")!==l)}),a.querySelectorAll("tr[data-iso]").forEach(f=>{f.classList.toggle("is-selected",!!l&&f.getAttribute("data-iso")===l)}),u.empty(),l&&(gc(u,r,l,()=>d(null)),u.scrollIntoView({behavior:"smooth",block:"nearest"}))},d=f=>{l=f&&f!==l?f:null,c()};fc(a,r);let h=a.createDiv({cls:"csv-tv-mapwrap"});h.createDiv({cls:"csv-tv-map-loading",text:"Loading map\u2026"});let u=a.createDiv({cls:"csv-tv-detailwrap"});i&&i.length&&mc(a,r.confirmed,i),bc(a,r,d),vc(a,r,d),yc(a,r,n);try{let f=await e();h.empty(),f?pc(h,f,r,d):h.createDiv({cls:"csv-tv-map-loading",text:"World map asset not found (world-map.svg)."})}catch(f){h.empty(),h.createDiv({cls:"csv-tv-map-loading",text:"Couldn't load world map."})}}function fc(s,t){let e=s.createDiv({cls:"csv-tv-stats"}),n=(c,d,h="")=>{let u=e.createDiv({cls:"csv-tv-stat"});u.createDiv({cls:"csv-tv-stat-label",text:c}),u.createDiv({cls:"csv-tv-stat-value",text:d}),h&&u.createDiv({cls:"csv-tv-stat-sub",text:h})},i=Math.round(t.allCountries.size/ri*100);n("Countries",String(t.confirmedCountries.size),`${t.worldPct}% of world`),n("Incl. photos",String(t.allCountries.size),`${i}% of world`),n("Continents",`${t.visitedContinents.size} / 7`,[...t.visitedContinents].map(c=>Vo[c]||c).sort().join(", ")),n("Confirmed trips",String(t.confirmed.length)),n("Confirmed days",String(t.totalConfirmedDays));let o=new Set(t.confirmed.map(c=>c.city.trim().toLowerCase()).filter(Boolean));o.size&&n("Cities",String(o.size));let r=null,a=0;for(let c of t.confirmed){let d=_s(c);d>a&&(a=d,r=c)}if(r){let c=r.date_entered.slice(0,4);n("Longest trip",`${a}d`,`${$t(r.country)} ${Et(r.country)}${c?` \xB7 ${c}`:""}`)}let l=Bo(t.confirmed);if(l){let c=Nt(l.date_entered),d=Math.max(1,Math.round((Date.now()-c.getTime())/864e5)+1),h=s.createDiv({cls:"csv-tv-now"});h.createSpan({cls:"csv-tv-now-loc",text:`\u{1F4CD} Currently in ${$t(l.country)} ${Et(l.country)}`}),h.createSpan({cls:"csv-tv-now-sub",text:` \u2014 since ${l.date_entered} (day ${d})${l.city?` \xB7 ${l.city}`:""}`})}}function pc(s,t,e,n){let i=s.createDiv({cls:"csv-tv-map"});i.innerHTML=t,i.querySelectorAll(".country-path").forEach(r=>{let a=(r.getAttribute("data-iso")||"").toUpperCase();if(r.classList.remove("cp-unvisited","cp-confirmed","cp-inferred"),a&&e.confirmedCountries.has(a)){r.classList.add("cp-confirmed");let l=e.countryDays.find(c=>c.iso===a);r.setAttr("aria-label",`${Et(a)} \u2014 ${l&&l.days?l.days+"d confirmed":"confirmed"}`),r.setAttr("data-tip",`${Et(a)}${l&&l.days?" \xB7 "+l.days+"d":""} \xB7 click for trips`)}else a&&e.inferredOnlyCountries.has(a)?(r.classList.add("cp-inferred"),r.setAttr("aria-label",`${Et(a)} \u2014 photo evidence`),r.setAttr("data-tip",`${Et(a)} \xB7 photo evidence \xB7 click for trips`)):a?(r.classList.add("cp-unvisited"),r.setAttr("data-tip",Et(a))):r.classList.add("cp-unvisited");a&&r.addEventListener("click",()=>{e.allCountries.has(a)?n(a):n(null)})}),i.querySelectorAll(".country-path").forEach(r=>{try{let a=r.getBoundingClientRect();a.width&&a.height&&Math.max(a.width,a.height)<12&&r.classList.add("cp-tiny")}catch(a){}});let o=s.createDiv({cls:"csv-tv-map-legend"});o.createSpan({cls:"csv-tv-leg"}).innerHTML=' Confirmed',o.createSpan({cls:"csv-tv-leg"}).innerHTML=' Photo evidence'}function gc(s,t,e,n){var m,b;let i=s.createDiv({cls:"csv-tv-detail"}),o=i.createDiv({cls:"csv-tv-detail-head"});o.createSpan({cls:"csv-tv-detail-flag",text:$t(e)});let r=o.createDiv({cls:"csv-tv-detail-titles"});r.createDiv({cls:"csv-tv-detail-name",text:Et(e)});let a=t.confirmed.filter(x=>x.country===e),l=t.inferred.filter(x=>x.country===e),c=(b=(m=t.countryDays.find(x=>x.iso===e))==null?void 0:m.days)!=null?b:0,d=new Set([...a,...l].map(x=>x.city.trim()).filter(Boolean)),h=[];a.length&&h.push(`${a.length} confirmed trip${a.length===1?"":"s"}`),c&&h.push(`${c}d total`),l.length&&h.push(`${l.length} photo-inferred`),d.size&&h.push(`${d.size} cit${d.size===1?"y":"ies"}`),r.createDiv({cls:"csv-tv-detail-sub",text:h.join(" \xB7 ")}),o.createEl("button",{cls:"csv-tv-detail-close",text:"\u2715",title:"Close"}).addEventListener("click",n);let u=rn([...a.map(x=>({r:x,inf:!1,date_entered:x.date_entered})),...l.map(x=>({r:x,inf:!0,date_entered:x.date_entered}))]);if(!u.length)return;let f=Ss(i),p=f.createEl("thead").createEl("tr");["","Entered","Left","Days","City","Visa"].forEach(x=>p.createEl("th",{text:x}));let g=f.createEl("tbody");for(let{r:x,inf:_}of u){let E=g.createEl("tr");E.createEl("td",{text:_?"\u{1F4F7}":"",cls:"csv-tv-flag",attr:_?{"data-tip":"Photo-inferred"}:{}}),E.createEl("td",{text:Ke(x.date_entered)}),E.createEl("td",{text:Ke(x.date_left)}),E.createEl("td",{text:li(x)}),E.createEl("td",{text:x.city}),E.createEl("td",{text:x.visa_status})}}function mc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Residency counters"});let n=s.createDiv({cls:"csv-tv-res-grid"});for(let i of e){let o=$o(i,t),r=n.createDiv({cls:`csv-tv-res-card csv-tv-res-${o.status}`});r.createDiv({cls:"csv-tv-res-label",text:i.label});let a=r.createDiv({cls:"csv-tv-res-nums"});a.createSpan({cls:"csv-tv-res-used",text:String(o.used)}),a.createSpan({cls:"csv-tv-res-thresh",text:` / ${o.threshold}`}),a.createSpan({cls:"csv-tv-res-window",text:` ${o.windowLabel}`});let l=r.createDiv({cls:"csv-tv-res-bar"});l.createDiv({cls:"csv-tv-res-fill"}).style.width=`${Math.min(100,Math.round(o.used/o.threshold*100))}%`;let c=o.status==="over"?i.onExceed?`Over \u2014 ${i.onExceed}`:"Limit reached":`${o.remaining} day${o.remaining===1?"":"s"} left`;r.createDiv({cls:"csv-tv-res-status",text:c}),i.note&&r.createDiv({cls:"csv-tv-res-note",text:i.note})}s.createDiv({cls:"csv-tv-res-disclaimer",text:"Indicators only \u2014 not legal or tax advice. Based on confirmed trips."})}function bc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Countries visited"});let n=Ss(s),i=n.createEl("thead").createEl("tr");["","Country","Total days"].forEach(r=>i.createEl("th",{text:r}));let o=n.createEl("tbody");for(let{iso:r,days:a}of t.countryDays){let l=o.createEl("tr",{cls:"csv-tv-row-click",attr:{"data-iso":r}});l.createEl("td",{text:$t(r),cls:"csv-tv-flag"}),l.createEl("td",{text:Et(r)}),l.createEl("td",{text:a?`${a}d`:"\u2014"}),l.addEventListener("click",()=>e(r))}if(t.inferredOnlyCountries.size){let r=s.createDiv({cls:"csv-tv-photo-only"});r.createSpan({text:"\u{1F4F7} Photo evidence only: "}),r.createSpan({text:[...t.inferredOnlyCountries].sort().map($t).join(" ")})}}function vc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Timeline"});let n=hc(),i=[...t.confirmed.map(c=>({...c,_inf:!1})),...t.inferredVisible.map(c=>({...c,_inf:!0}))].filter(c=>c.date_entered&&c.date_left&&c.date_entered.indexOf("?")===-1),o=new Map;for(let c of i){let d=parseInt(c.date_entered.slice(0,4)),h=parseInt(c.date_left.slice(0,4));if(!(isNaN(d)||isNaN(h)))for(let u=d;u<=h;u++)o.has(u)||o.set(u,[]),o.get(u).push(c)}let r=[...o.keys()].sort((c,d)=>d-c),a=s.createDiv({cls:"csv-tv-timeline"});for(let c of r){let d=new Date(`${c}-01-01T12:00:00Z`).getTime(),h=new Date(`${c}-12-31T12:00:00Z`).getTime(),u=h-d,f=a.createDiv({cls:"csv-tv-tl-year"}),p=0,g=new Set;for(let _ of o.get(c)){if(g.add(_.country),_._inf)continue;let E=Math.max(new Date(_.date_entered+"T12:00:00Z").getTime(),d),S=Math.min(new Date(_.date_left+"T12:00:00Z").getTime(),h);E<=S&&(p+=Math.max(Math.round((S-E)/864e5)+1,1))}let m=f.createDiv({cls:"csv-tv-tl-label"});m.createSpan({text:String(c)}),m.createSpan({cls:"csv-tv-tl-sub",text:`${p?`${p}d \xB7 `:""}${g.size} ${g.size===1?"country":"countries"}`});let b=f.createDiv({cls:"csv-tv-month-row"});dc.forEach(_=>b.createDiv({cls:"csv-tv-month-tick",text:_}));let x=f.createDiv({cls:"csv-tv-track"});for(let _ of o.get(c)){let E=Math.max(new Date(_.date_entered+"T12:00:00Z").getTime(),d),S=Math.min(new Date(_.date_left+"T12:00:00Z").getTime(),h);if(E>S)continue;let v=(E-d)/u*100,y=Math.max((S-E+864e5)/u*100,.5),C=n(_.country),D=x.createDiv({cls:`csv-tv-seg${_._inf?" csv-tv-seg-inf":""}`});D.style.left=`${v}%`,D.style.width=`${y}%`,_._inf?(D.style.borderColor=C,D.style.background=C+"22",D.style.color=C):D.style.background=C,D.setAttr("data-iso",_.country),D.setAttr("data-tip",`${Et(_.country)} ${_.date_entered} \u2192 ${_.date_left} (${_s(_)}d)${_.visa_status?" ["+_.visa_status+"]":""}${_._inf?" [photo]":""}`),D.addEventListener("click",()=>e(_.country)),y>4?D.createSpan({cls:"csv-tv-seg-lbl",text:`${$t(_.country)} ${_.country}`}):y>2&&D.createSpan({cls:"csv-tv-seg-lbl",text:$t(_.country)})}}a.createDiv({cls:"csv-tv-tl-legend"}).setText("Confirmed (solid) \xB7 Photo inferred (outlined)")}function rn(s){return[...s].sort((t,e)=>!t.date_entered&&!e.date_entered?0:t.date_entered?e.date_entered?e.date_entered.localeCompare(t.date_entered):-1:1)}function yc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Confirmed trips"}),s.createDiv({cls:"csv-tv-edit-hint",text:"Dates, city, visa and notes are editable \u2014 click a cell. Edit country in Table view."});let n=Ss(s),i=n.createEl("thead").createEl("tr");["","Country","Entered","Left","Duration","City","Visa","Notes"].forEach(r=>i.createEl("th",{text:r}));let o=n.createEl("tbody");for(let r of rn(t.confirmed)){let a=o.createEl("tr");a.createEl("td",{text:$t(r.country),cls:"csv-tv-flag"}),a.createEl("td",{text:Et(r.country)}),Cs(a.createEl("td"),r._src,"date_entered",e),Cs(a.createEl("td"),r._src,"date_left",e),a.createEl("td",{text:li(r)}),Cs(a.createEl("td"),r._src,"city",e),Cs(a.createEl("td"),r._src,"visa_status",e),Cs(a.createEl("td"),r._src,"notes",e)}if(t.inferred.length){let r=s.createEl("details",{cls:"csv-tv-details"});r.createEl("summary",{text:`\u{1F4F7} Photo inferred trips (${t.inferred.length})`});let a=Ss(r),l=a.createEl("thead").createEl("tr");["","Country","Entered","Left","Days","City"].forEach(d=>l.createEl("th",{text:d}));let c=a.createEl("tbody");for(let d of rn(t.inferred)){let h=c.createEl("tr");h.createEl("td",{text:$t(d.country),cls:"csv-tv-flag"}),h.createEl("td",{text:Et(d.country)}),h.createEl("td",{text:Ke(d.date_entered)}),h.createEl("td",{text:Ke(d.date_left)}),h.createEl("td",{text:li(d)}),h.createEl("td",{text:d.city})}}if(t.conflicts.length){let r=s.createEl("details",{cls:"csv-tv-details csv-tv-details-warn"});r.createEl("summary",{text:`\u26A0 ${t.conflicts.length} conflict(s) \u2014 photo evidence contradicts a confirmed entry`});let a=Ss(r),l=a.createEl("thead").createEl("tr");["","Country (photos)","Dates","Detail"].forEach(d=>l.createEl("th",{text:d}));let c=a.createEl("tbody");for(let d of rn(t.conflicts)){let h=c.createEl("tr");h.createEl("td",{text:$t(d.country),cls:"csv-tv-flag"}),h.createEl("td",{text:d.country}),h.createEl("td",{text:`${Ke(d.date_entered)} \u2192 ${Ke(d.date_left)}`}),h.createEl("td",{text:d.notes})}}}var Ft=require("obsidian"),an=class extends Ft.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e}display(){let{containerEl:t}=this;t.empty(),t.createEl("h2",{text:"XLSX Card View"}),new Ft.Setting(t).setName("Default view mode").addDropdown(n=>n.addOption("kanban-genre","Kanban").addOption("table","Table").setValue(this.plugin.settings.defaultMode).onChange(async i=>{this.plugin.settings.defaultMode=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Status column name").addText(n=>n.setValue(this.plugin.settings.statusColumn).onChange(async i=>{this.plugin.settings.statusColumn=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Category/Genre column name").addText(n=>n.setValue(this.plugin.settings.categoryColumn).onChange(async i=>{this.plugin.settings.categoryColumn=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Notes column names").setDesc("Comma-separated.").addText(n=>n.setValue(this.plugin.settings.notesColumns.join(", ")).onChange(async i=>{this.plugin.settings.notesColumns=i.split(",").map(o=>o.trim()),await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Select/dropdown columns").setDesc("Comma-separated column names that use a dropdown picker.").addText(n=>n.setValue(this.plugin.settings.selectColumns.join(", ")).onChange(async i=>{this.plugin.settings.selectColumns=i.split(",").map(o=>o.trim()),await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Notes subfolder").addText(n=>n.setPlaceholder("Notes").setValue(this.plugin.settings.notesSubfolder).onChange(async i=>{this.plugin.settings.notesSubfolder=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Reset column widths").addButton(n=>n.setButtonText("Reset").onClick(async()=>{this.plugin.settings.columnWidths={},await this.plugin.saveSettings(),new Ft.Notice("Column widths reset.")})),new Ft.Setting(t).setName("Residency counters (travel view)").setDesc("Show residency / tax day-gauges in the travel view.").addToggle(n=>n.setValue(this.plugin.settings.showResidency!==!1).onChange(async i=>{this.plugin.settings.showResidency=i,await this.plugin.saveSettings()})),t.createEl("h3",{text:"Residency rules"}),t.createEl("p",{cls:"setting-item-description",text:"Each rule counts days in the listed countries within the window, minus exempt visa rows, against the threshold. Counts confirmed trips only. Indicators, not legal/tax advice."});let e=t.createDiv({cls:"csv-rr-wrap"});this.renderResidencyRules(e)}renderResidencyRules(t){var o;t.empty();let e=(o=this.plugin.settings.residencyRules)!=null?o:this.plugin.settings.residencyRules=[],n=()=>void this.plugin.saveSettings();e.forEach((r,a)=>{var b,x,_,E,S,v;let l=t.createDiv({cls:"csv-rr-card"}),c=l.createDiv({cls:"csv-rr-head"}),d=c.createEl("input",{cls:"csv-rr-label",type:"text",value:r.label});d.placeholder="Label (e.g. \u{1F1EA}\u{1F1FA} Schengen 90/180)",d.addEventListener("input",()=>{r.label=d.value,n()});let h=c.createEl("button",{cls:"csv-rr-del",text:"\u2715"});h.setAttr("aria-label","Remove rule"),h.addEventListener("click",async()=>{e.splice(a,1),await this.plugin.saveSettings(),this.renderResidencyRules(t)});let u=l.createDiv({cls:"csv-rr-grid"}),f=(y,C,D,M="")=>{let w=u.createDiv({cls:"csv-rr-field"});w.createEl("label",{text:y});let L=w.createEl("input",{type:"text",value:C});M&&(L.placeholder=M),L.addEventListener("input",()=>{D(L.value),n()})},p=(b=r.scope.countries)!=null?b:r.scope.country?[r.scope.country]:[];f("Countries (ISO-2, comma)",p.join(", "),y=>{r.scope={countries:y.split(",").map(C=>C.trim().toUpperCase()).filter(Boolean)}},"US, GB");let g=u.createDiv({cls:"csv-rr-field"});g.createEl("label",{text:"Window"});let m=g.createEl("select");[["calendar-year","Calendar year"],["rolling","Rolling N days"],["all-time","All time"]].forEach(([y,C])=>{let D=m.createEl("option",{text:C,value:y});r.window.type===y&&(D.selected=!0)}),m.addEventListener("change",()=>{r.window={type:m.value,days:r.window.days},n(),this.renderResidencyRules(t)}),r.window.type==="rolling"&&f("Rolling days",String((x=r.window.days)!=null?x:180),y=>{let C=parseInt(y,10);r.window.days=isNaN(C)?void 0:C},"180"),f("Threshold (days)",String(r.threshold),y=>{let C=parseInt(y,10);r.threshold=isNaN(C)?0:C},"183"),f("Exempt visas (comma)",((E=(_=r.exempt)==null?void 0:_.visa_status)!=null?E:[]).join(", "),y=>{let C=y.split(",").map(D=>D.trim()).filter(Boolean);r.exempt=C.length?{visa_status:C}:void 0},"F-1, J-1"),f("On-exceed label",(S=r.onExceed)!=null?S:"",y=>{r.onExceed=y||void 0},"tax resident"),f("Note",(v=r.note)!=null?v:"",y=>{r.note=y||void 0},"optional caveat")}),t.createDiv({cls:"csv-rr-btns"}).createEl("button",{cls:"csv-rr-add",text:"+ Add rule"}).addEventListener("click",async()=>{e.push({label:"New rule",scope:{countries:[]},window:{type:"calendar-year"},threshold:183}),await this.plugin.saveSettings(),this.renderResidencyRules(t)})}};var de=require("obsidian"),Uo=Xs(vs());async function Ko(s,t,e,n){var R,V;let i=t.split(` -`).map(T=>T.trim()).filter(Boolean),o="";for(let T of i)if(T.startsWith("file:")){o=T.replace("file:","").trim();break}if(!o){e.createEl("p",{text:"Error: No file specified. Use: file: yourfile.csv",cls:"csv-add-error"});return}let r=s.vault.getAbstractFileByPath(n.sourcePath),a=(V=(R=r==null?void 0:r.parent)==null?void 0:R.path)!=null?V:"",l=We(o,a),c=s.vault.getAbstractFileByPath(l);if(!c||!(c instanceof de.TFile)){e.createEl("p",{text:`Error: File not found: ${l}`,cls:"csv-add-error"});return}let d=[],h=[];try{let T=await s.vault.read(c),O=Gt(T);d=O.headers,h=O.rows}catch(T){e.createEl("p",{text:`Error reading file: ${T}`,cls:"csv-add-error"});return}if(!d.length){e.createEl("p",{text:"Error: No columns found in file",cls:"csv-add-error"});return}let u=["0","1","true","false","yes","no",""],f=T=>{let O=h.map(j=>{var U;return((U=j[T])!=null?U:"").toLowerCase().trim()});return O.length>0&&O.every(j=>u.includes(j))},p=T=>{let O=T.toLowerCase();if(["date","day","datum"].includes(O))return!0;let j=h.slice(0,5).map(U=>{var K;return(K=U[T])!=null?K:""});return j.length>0&&j.every(U=>/^\d{4}-\d{2}-\d{2}$/.test(U))},g=T=>{let O=T.toLowerCase();return["notes","note","comments","description","journal"].includes(O)},m=d.filter(T=>f(T)&&!p(T)),b=d.filter(T=>p(T)),x=d.filter(T=>g(T)),_=d.filter(T=>!m.includes(T)&&!b.includes(T)&&!x.includes(T)),E=e.createDiv({cls:"csv-add-form csv-add-compact"}),S=E.createEl("button",{cls:"csv-add-trigger",text:"+ New entry"});S.style.display="none";let v=E.createDiv({cls:"csv-add-card"}),y=v.createDiv({cls:"csv-add-card-header"});y.createEl("span",{cls:"csv-add-card-title",text:"New entry"});let C=y.createEl("button",{cls:"csv-add-card-close",text:"\xD7"}),D=v.createDiv({cls:"csv-add-rows"}),M={},w={},L=(T,O)=>{let j=D.createDiv({cls:`csv-add-row csv-add-row-${O}`});return j.createEl("span",{cls:"csv-add-row-label",text:kt(T)}),j};b.forEach(T=>{let j=L(T,"date").createEl("input",{cls:"csv-add-row-control",type:"date"});j.value=new Date().toISOString().split("T")[0],M[T]=j}),m.forEach(T=>{w[T]=!1;let j=L(T,"toggle").createEl("label",{cls:"csv-add-switch"}),U=j.createEl("input",{type:"checkbox",cls:"csv-add-switch-input"});j.createEl("span",{cls:"csv-add-switch-track"}),U.addEventListener("change",()=>{w[T]=U.checked}),M[T]=U}),_.forEach(T=>{let O=L(T,"field"),j=new Set(h.map(U=>{var K;return((K=U[T])!=null?K:"").trim()}).filter(Boolean));if(ys(j.size)){let U=O.createEl("select",{cls:"csv-add-row-control"});U.createEl("option",{text:"\u2014",value:""}),Array.from(j).sort().forEach(N=>U.createEl("option",{text:N,value:N})),U.createEl("option",{text:"+ Custom",value:"__custom__"});let K=D.createDiv({cls:"csv-add-row csv-add-row-custom"});K.style.display="none";let $=K.createEl("input",{cls:"csv-add-row-control",type:"text",placeholder:`Custom ${kt(T).toLowerCase()}`});D.insertBefore(K,O.nextSibling),U.addEventListener("change",()=>{K.style.display=U.value==="__custom__"?"flex":"none",U.value==="__custom__"&&$.focus()}),M[T]=U,M[`${T}__custom`]=$}else M[T]=O.createEl("input",{cls:"csv-add-row-control",type:"text",placeholder:kt(T)})}),x.forEach(T=>{let O=D.createDiv({cls:"csv-add-row csv-add-row-notes"});O.createEl("span",{cls:"csv-add-row-label",text:kt(T)}),M[T]=O.createEl("textarea",{cls:"csv-add-row-textarea",placeholder:"Optional notes\u2026"})});let k=v.createEl("button",{text:"Add",cls:"csv-add-submit"}),A=y.querySelector(".csv-add-card-title"),P=()=>{if(!b.length)return;let T=M[b[0]];if(!T)return;let O=T.value,j=h.find(U=>U[b[0]]===O);A&&A.setText(j?`Updating ${O}`:"New entry"),v.classList.toggle("is-updating",!!j),k.setText(j?"Update":"Add"),m.forEach(U=>{var B;let K=M[U];if(!K)return;let $=((B=j==null?void 0:j[U])!=null?B:"").toLowerCase().trim(),N=$==="1"||$==="true"||$==="yes";K.checked=N,w[U]=N}),[..._,...x].forEach(U=>{var N,B;let K=M[U];if(!K)return;let $=(N=j==null?void 0:j[U])!=null?N:"";if(K instanceof HTMLSelectElement)if(Array.from(K.options).find(F=>F.value===$)){K.value=$;let F=(B=M[`${U}__custom`])==null?void 0:B.closest(".csv-add-row-custom");F&&(F.style.display="none")}else K.value="";else K instanceof HTMLTextAreaElement,K.value=$})};if(P(),b.length){let T=M[b[0]];T==null||T.addEventListener("change",P)}let I=()=>{v.style.display="block",S.style.display="none";let T=v.querySelector(".csv-add-row-control");T==null||T.focus()},z=()=>{v.style.display="none",S.style.display=""};S.addEventListener("click",I),C.addEventListener("click",z),k.addEventListener("click",async()=>{let T={};d.forEach(B=>{var H,F,G,Y;m.includes(B)?T[B]=w[B]?"1":"0":M[B]instanceof HTMLSelectElement&&M[B].value==="__custom__"?T[B]=(F=(H=M[`${B}__custom`])==null?void 0:H.value)!=null?F:"":M[B]instanceof HTMLTextAreaElement?T[B]=M[B].value:T[B]=(Y=(G=M[B])==null?void 0:G.value)!=null?Y:""});let O=b.length>0&&b.some(B=>{var H;return((H=T[B])!=null?H:"").trim()}),j=[..._,...x].some(B=>{var H;return((H=T[B])!=null?H:"").trim()}),U=m.some(B=>w[B]);if(!O&&!j&&!U){new de.Notice("Please fill at least one field");return}let K=[];try{let B=await s.vault.read(c);K=Gt(B).rows}catch(B){new de.Notice(`Error reading file: ${B}`);return}let $=!1,N=-1;if(b.length>0){let B=b[0],H=T[B];if(N=K.findIndex(F=>F[B]===H),N>=0){$=!0;let F=K[N];d.forEach(G=>{var Y;(m.includes(G)||((Y=T[G])!=null?Y:"").trim())&&(F[G]=T[G])})}else K.push(T)}else K.push(T);try{let B=Uo.default.unparse(K,{columns:d});await s.vault.modify(c,B),new de.Notice($?`Updated entry for ${T[b[0]]||""}`:`Added entry to ${c.basename}`),h.length=0,h.push(...K),b.length>0?P():(m.forEach(H=>{w[H]=!1;let F=M[H];F&&(F.checked=!1)}),[..._,...x].forEach(H=>{let F=M[H];F instanceof HTMLSelectElement?F.selectedIndex=0:(F instanceof HTMLTextAreaElement||F)&&(F.value="");let G=M[`${H}__custom`];if(G){G.value="";let Y=G.closest(".csv-add-row-custom");Y&&(Y.style.display="none")}})),setTimeout(async()=>{let H=s.vault.getAbstractFileByPath(n.sourcePath);if(H instanceof de.TFile){let F=s.workspace.activeLeaf;F&&await F.openFile(H,{state:{mode:"preview"}})}},300)}catch(B){new de.Notice(`Error saving: ${B}`)}})}function ln(s,t){let e=s.getFilteredRows();s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${e.length} of ${s.rows.length} entries`});let i=t.createDiv({cls:"csv-table-wrapper"}).createEl("table",{cls:"csv-table"}),o=i.createEl("thead").createEl("tr");s.headers.forEach(l=>{let c=o.createEl("th");c.setText(l),c.addClass("csv-th-sortable"),s.tableSortCol===l&&c.createSpan({cls:"csv-th-sort-indicator",text:s.tableSortDir==="asc"?" \u25B2":" \u25BC"}),c.title="Click to sort",c.addEventListener("click",p=>{p.target.closest(".csv-col-resize-handle")||(s.tableSortCol!==l?(s.tableSortCol=l,s.tableSortDir="asc"):s.tableSortDir==="asc"?s.tableSortDir="desc":s.tableSortCol=null,s.renderView())});let d=s.settings.columnWidths[l];d&&(c.style.width=d+"px");let h=c.createDiv({cls:"csv-col-resize-handle"}),u=0,f=0;h.addEventListener("pointerdown",p=>{p.preventDefault(),p.stopPropagation(),h.setPointerCapture(p.pointerId),u=p.clientX,f=c.offsetWidth;let g=b=>{c.style.width=Math.max(60,f+b.clientX-u)+"px"},m=b=>{s.settings.columnWidths[l]=Math.max(60,f+b.clientX-u),h.removeEventListener("pointermove",g),h.removeEventListener("pointerup",m),s.persistSettings()};h.addEventListener("pointermove",g),h.addEventListener("pointerup",m)})}),o.createEl("th",{text:""});let r=matchMedia("(pointer: coarse)").matches,a=i.createEl("tbody");e.forEach(l=>{let c=a.createEl("tr");c.addEventListener("contextmenu",u=>s.openRowContextMenu(l,u)),s.headers.forEach(u=>{var p,g;let f=c.createEl("td");if(s.isNotesCol(u)){f.addClass("csv-table-notes-cell");let m=((p=l[u])!=null?p:"").replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").split(` -`).filter(_=>_.trim()).slice(0,3).join(" \xB7 "),b=m?m.slice(0,200)+(m.length>200?"\u2026":""):"+ Add note",x=f.createSpan({text:b});m||x.addClass("csv-table-notes-empty"),f.title="Click to open note",f.addEventListener("click",_=>{_.stopPropagation(),s.openNoteExpander(l,u)})}else if(s.isSelectCol(u))s.renderSelectField(f,l,u);else{let m=(g=l[u])!=null?g:"";f.setText(m),m.length>80&&(f.title=m),xc(s,f,l,u)}});let d=c.createEl("td",{cls:"csv-table-action"}),h=s.notesFileExists(l);d.createEl("button",{cls:`csv-table-notes-btn ${h?"exists":""}`,text:h?"\u{1F4C4}":"\u271A",title:h?"Open notes":"Create notes"}).addEventListener("click",()=>s.openOrCreateNotes(l)),d.createEl("button",{cls:"csv-table-del-btn",text:"\u2715",title:"Delete row (Undo available)"}).addEventListener("click",()=>s.deleteWithUndo(l))}),r||requestAnimationFrame(()=>{a.querySelectorAll("td:not(.csv-table-notes-cell):not(.csv-table-action)").forEach(l=>{l.scrollHeight>l.clientHeight+1&&l.addClass("csv-cell--clipped")})})}function xc(s,t,e,n){t.addEventListener("click",()=>{var o;t.empty();let i=t.createEl("input",{cls:"csv-inline-input",value:(o=e[n])!=null?o:"",type:"text"});i.focus(),i.select(),i.addEventListener("blur",()=>{e[n]=i.value,s.scheduleSave(),t.empty(),t.setText(i.value||"\u2014")}),i.addEventListener("keydown",r=>{r.key==="Enter"&&i.blur(),r.key==="Escape"&&(t.empty(),t.setText(e[n]||"\u2014"))})})}function cn(s){return!!(s.getCategoryCol()||s.getStatusCol()||Yo(s)||s.authorKey())}function Yo(s){return s.resolveCol(["Rating","rating","Score","score","Score /5","Stars","stars"])}function ks(s){var i;let t=(s!=null?s:"").trim();if(!t)return null;let e=((i=t.match(/★/g))!=null?i:[]).length;if(e>0)return e;let n=parseFloat(t);return isNaN(n)||n<=0?null:Math.min(5,n)}var Go=["watched","read","finished","completed","done","yes","seen"],qo=["watching","reading","in progress","in-progress"],_c=["dropped","abandoned","dnf"];function Cc(s){let t=s.toLowerCase();return Go.includes(t)?"is-done":qo.includes(t)?"is-progress":_c.includes(t)?"is-dropped":""}function Es(s,t){let e=new Map;return s.forEach(n=>t(n).forEach(i=>{var o;return e.set(i,((o=e.get(i))!=null?o:0)+1)})),e}function ws(s,t,e,n){if(!e.length)return;let i=s.createDiv({cls:"csv-stats-section"});i.createDiv({cls:"csv-stats-section-title",text:t});let o=Math.max(...e.map(r=>r.count));e.forEach(r=>{var h;let a=i.createDiv({cls:"csv-stats-bar-row"});a.createDiv({cls:"csv-stats-bar-label",text:r.label,attr:{title:r.label}});let c=a.createDiv({cls:"csv-stats-bar-track"}).createDiv({cls:`csv-stats-bar-fill ${(h=r.cls)!=null?h:""}`});c.style.width=`${Math.max(2,Math.round(r.count/o*100))}%`;let d=n>0?Math.round(r.count/n*100):0;a.createDiv({cls:"csv-stats-bar-count",text:`${r.count} \xB7 ${d}%`}),r.onClick&&(a.addClass("is-clickable"),a.title=`Show "${r.label}" in the library`,a.addEventListener("click",r.onClick))})}function Xo(s,t){let e=s.getFilteredRows();if(s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Stats over ${e.length} of ${s.rows.length} entries`}),!e.length){t.createEl("p",{text:"No entries to chart.",cls:"csv-empty-state"});return}let n=t.createDiv({cls:"csv-stats-wrap"}),i=s.getStatusCol(),o=s.getCategoryCol(),r=Yo(s),a=s.authorKey(),l=s.resolveCol(["Year","year"]),c=n.createDiv({cls:"csv-stats-overview"}),d=(u,f)=>{let p=c.createDiv({cls:"csv-stats-chip"});p.createDiv({cls:"csv-stats-chip-value",text:u}),p.createDiv({cls:"csv-stats-chip-label",text:f})};if(d(String(e.length),"entries"),i){let u=e.filter(p=>{var g;return Go.includes(((g=p[i])!=null?g:"").toLowerCase().trim())}).length;u>0&&d(`${u} \xB7 ${Math.round(u/e.length*100)}%`,"done");let f=e.filter(p=>{var g;return qo.includes(((g=p[i])!=null?g:"").toLowerCase().trim())}).length;f>0&&d(String(f),"in progress")}if(o){let u=Es(e,f=>{var p;return((p=f[o])!=null?p:"").split(",").map(g=>g.trim()).filter(Boolean)});u.size>0&&d(String(u.size),o.toLowerCase()==="genre"||o.toLowerCase()==="genres"?"genres":"categories")}if(r){let u=e.map(f=>ks(f[r])).filter(f=>f!==null);if(u.length){let f=u.reduce((p,g)=>p+g,0)/u.length;d(`\u2605 ${f.toFixed(1)}`,`avg of ${u.length} rated`)}}let h=(u,f)=>{s.libraryStatusFilter=u!=null?u:"all",s.libraryGenreFilter=f!=null?f:"all",s.mode="library",s.renderView()};if(i){let u=Es(e,p=>{var m;let g=((m=p[i])!=null?m:"").trim();return g?[g]:[]}),f=Array.from(u.entries()).sort((p,g)=>g[1]-p[1]).map(([p,g])=>({label:p,count:g,cls:Cc(p),onClick:o?()=>h(p,null):void 0}));ws(n,`By ${i.toLowerCase()}`,f,e.length)}if(o){let u=Es(e,p=>{var g;return((g=p[o])!=null?g:"").split(",").map(m=>m.trim()).filter(Boolean)}),f=Array.from(u.entries()).sort((p,g)=>g[1]-p[1]||p[0].localeCompare(g[0])).slice(0,12).map(([p,g])=>({label:p,count:g,onClick:()=>h(null,p)}));ws(n,`By ${o.toLowerCase()}`,f,e.length)}if(r){let u=new Map,f=0;if(e.forEach(p=>{var b;let g=ks(p[r]);if(g===null)return;let m=Math.min(5,Math.max(1,Math.round(g)));u.set(m,((b=u.get(m))!=null?b:0)+1),f++}),f>0){let p=[5,4,3,2,1].filter(g=>{var m;return((m=u.get(g))!=null?m:0)>0}).map(g=>({label:"\u2605".repeat(g),count:u.get(g),cls:"is-rating"}));ws(n,"Ratings",p,f)}}if(l){let u=Es(e,f=>{var g;let p=((g=f[l])!=null?g:"").match(/\d{4}/);return p?[p[0]]:[]});if(u.size>1){let f=Array.from(u.entries()).sort((p,g)=>p[0].localeCompare(g[0])).map(([p,g])=>({label:p,count:g}));ws(n,"By year",f,e.length)}}if(a){let u=Es(e,p=>{var m;let g=((m=p[a])!=null?m:"").trim();return g?[g]:[]}),f=Array.from(u.entries()).filter(([,p])=>p>1);if(f.length>=2){let p=f.sort((g,m)=>m[1]-g[1]||g[0].localeCompare(m[0])).slice(0,8).map(([g,m])=>({label:g,count:m}));ws(n,`Top ${a.toLowerCase()}s`,p,e.length)}}}function Bt(s){let t=s.fileCfg.kanbanGroupCol;if(t&&s.headers.includes(t))return t;let e=s.getCategoryCol();if(e)return e;let n=new Set;s.headers.forEach(r=>{s.isNotesCol(r)&&n.add(r)});let i=s.getDateCol();i&&n.add(i);let o=s.titleKey();return o&&n.add(o),Ro(s.headers,s.rows,n)}function dn(s,t){let e=Bt(s);if(!e){t.createEl("p",{text:"No groupable column found.",cls:"csv-empty-state"});return}let n=s.getCategoryCol(),i=s.getStatusCol(),o=i===e?null:i,r=s.getFilteredRows();s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${r.length} of ${s.rows.length} entries`});let a=t.createDiv({cls:"csv-kanban-groupbar"});a.createSpan({cls:"csv-kanban-groupbar-label",text:"Group by"});let l=a.createEl("select",{cls:"csv-library-filter-select"});s.headers.filter(m=>!s.isNotesCol(m)).forEach(m=>{let b=l.createEl("option",{text:m===n?`${m} (default)`:m,value:m});m===e&&(b.selected=!0)}),l.addEventListener("change",()=>{let m=s.fileCfg;m.kanbanGroupCol=l.value===n?void 0:l.value,s.saveFileCfg(m),s.renderView(!0)});let c=Ao(e,r.map(m=>{var b;return(b=m[e])!=null?b:""})),d=m=>{var _;let b=(_=m[e])!=null?_:"",x;if(c){let E=Po(b);x=E?[E]:[]}else x=b.split(",").map(E=>E.trim()).filter(Boolean);return x.length||(x=["\u2014"]),x},h=new Set;r.forEach(m=>d(m).forEach(b=>h.add(b)));let u=Array.from(h).sort();if(!u.length){let m=t.createDiv({cls:"csv-empty-state"});m.createEl("p",{text:s.searchQuery?"No matching entries found.":`No "${e}" values found.`}),s.searchQuery&&m.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear search"}).addEventListener("click",()=>{s.searchQuery="",s.renderView()});return}let f=["In progress","Finished","Not started"],p=o?Array.from(new Set([...f,...r.map(m=>{var b;return(b=m[o])!=null?b:""}).filter(Boolean)])).filter(m=>r.some(b=>{var x;return((x=b[o])!=null?x:"")==m})):[],g=t.createDiv({cls:"csv-kanban-board"});u.forEach(m=>{let b=r.filter(S=>d(S).includes(m));if(!b.length)return;let x=g.createDiv({cls:"csv-kanban-col"}),_=x.createDiv({cls:"csv-kanban-col-header"});_.createDiv({cls:"csv-kanban-col-title",text:m}),_.createDiv({cls:"csv-kanban-col-count",text:String(b.length)});let E=x.createDiv({cls:"csv-kanban-col-body"});if(o&&p.length){p.forEach(v=>{let y=b.filter(D=>{var M;return((M=D[o])!=null?M:"")===v});if(!y.length)return;let C=E.createDiv({cls:"csv-kanban-status-group"});C.createDiv({cls:`csv-kanban-status-label status-${v.toLowerCase().replace(/\s+/g,"-")}`,text:v}),y.forEach(D=>ci(s,C,D,o,e))});let S=new Set(p);b.filter(v=>{var y;return!S.has((y=v[o])!=null?y:"")}).forEach(v=>ci(s,E,v,o,e))}else b.forEach(S=>ci(s,E,S,o,e))})}function ci(s,t,e,n,i){var y,C,D,M,w,L;let o=t.createDiv({cls:"csv-kanban-card"}),r=s.getNotesCol(),a=(C=(y=s.getImageCol)==null?void 0:y.call(s))!=null?C:null;if(a){let k=Js(s.app,(D=e[a])!=null?D:"",(w=(M=s.file)==null?void 0:M.path)!=null?w:"");if(k){let A=o.createEl("img",{cls:"csv-kanban-card-img",attr:{src:k,loading:"lazy",alt:""}});A.addEventListener("error",()=>A.remove())}}let l=o.createDiv({cls:"csv-kanban-card-title-row"});l.createDiv({cls:"csv-kanban-card-title",text:s.getTitle(e)}).addEventListener("click",k=>{k.stopPropagation(),s.openNoteExpander(e,r!=null?r:"")});let d=s.notesFileExists(e);l.createEl("button",{cls:`csv-kanban-notes-icon ${d?"exists":""}`,text:d?"\u{1F4C4}":"+",title:d?"Open notes file":"Create notes file"}).addEventListener("click",k=>{k.stopPropagation(),s.openOrCreateNotes(e)});let u=s.getSubtitle(e);u&&o.createDiv({cls:"csv-kanban-card-sub",text:u});let f=s.titleKey(),p=s.authorKey(),g=new Set([n,f,p,i].filter(Boolean)),m=o.createDiv({cls:"csv-kanban-card-meta"});s.headers.forEach(k=>{if(g.has(k)||s.isNotesCol(k))return;let A=m.createDiv({cls:"csv-kanban-chip"});if(A.createSpan({cls:"csv-chip-label",text:k+": "}),s.isSelectCol(k)){let P=A.createSpan({cls:`csv-chip-value csv-chip-select${e[k]?"":" csv-chip-value--empty"}`,text:e[k]||"\u2014"});P.addEventListener("click",I=>{I.stopPropagation(),Ot(P,e[k],s.getColumnValues(k),z=>{e[k]=z,P.setText(z||"\u2014"),P.classList.toggle("csv-chip-value--empty",!z),s.scheduleSave()},s.contentEl,{multi:It(k)})})}else{let P=e[k]?e[k].length>40?e[k].slice(0,38)+"\u2026":e[k]:"\u2014",I=A.createSpan({cls:`csv-chip-value${e[k]?"":" csv-chip-value--empty"}`,text:P});e[k]&&e[k].length>40&&(I.title=e[k])}});let b=s.getNotesCol(),x=!!(b&&((L=e[b])!=null&&L.trim())),_=o.createDiv({cls:"csv-kanban-notes-preview"});if(x&&b){let k=e[b].replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").replace(/\n+/g," ").trim();_.setText(k.slice(0,120)+(k.length>120?"\u2026":"")),_.title="Click to edit"}else _.addClass("csv-kanban-notes-preview--empty"),b&&_.setText("+ Add note");let E=o.createDiv({cls:"csv-kanban-notes-editor"});E.style.display="none";let S=()=>{var z,R,V;let k=s.contentEl.querySelector(".csv-content-area"),A=(z=k==null?void 0:k.scrollLeft)!=null?z:0,P=(R=k==null?void 0:k.scrollTop)!=null?R:0;_.style.display="none",E.style.display="block",E.empty();let I=E.createEl("textarea",{cls:"csv-notes-textarea"});I.value=(V=b?e[b]:"")!=null?V:"",I.addEventListener("click",T=>T.stopPropagation()),I.addEventListener("mousedown",T=>T.stopPropagation()),I.addEventListener("input",()=>{I.style.height="auto",I.style.height=I.scrollHeight+"px"}),I.addEventListener("keydown",T=>{T.key==="Escape"&&v(I.value,k,A,P)}),I.addEventListener("blur",()=>v(I.value,k,A,P)),I.focus({preventScroll:!0}),I.setSelectionRange(0,0),I.scrollTop=0,requestAnimationFrame(()=>{I.style.height="auto",I.style.height=Math.max(120,I.scrollHeight)+"px"})},v=(k,A,P,I)=>{if(b&&(e[b]=k,s.scheduleSave()),E.style.display="none",_.style.display="",k.trim()){let z=k.replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").replace(/\n+/g," ").trim();_.setText(z.slice(0,120)+(z.length>120?"\u2026":"")),_.removeClass("csv-kanban-notes-preview--empty"),_.title="Click to edit"}else _.addClass("csv-kanban-notes-preview--empty"),_.setText(b?"+ Add note":""),_.removeAttribute("title");A&&(A.scrollLeft=P,A.scrollTop=I,requestAnimationFrame(()=>{A.scrollLeft=P,A.scrollTop=I,requestAnimationFrame(()=>{A.scrollLeft=P,A.scrollTop=I})}),setTimeout(()=>{A.scrollLeft=P,A.scrollTop=I},50))};_.addEventListener("click",k=>{if(k.stopPropagation(),b&&matchMedia("(pointer: coarse)").matches){s.openNoteExpander(e,b);return}S()}),o.addEventListener("contextmenu",k=>s.openRowContextMenu(e,k))}function hn(s,t){var D,M;let e=Bt(s),n=s.getStatusCol(),i=(D=s.titleKey())!=null?D:s.headers[0],o=s.authorKey();if(!e){t.createEl("p",{text:"No groupable column found.",cls:"csv-empty-state"});return}let r=new Set;s.rows.forEach(w=>{var k;((k=w[e])!=null?k:"").split(",").map(A=>A.trim()).filter(Boolean).forEach(A=>r.add(A))});let a=new Set;n&&s.rows.forEach(w=>{var k;let L=((k=w[n])!=null?k:"").trim();L&&a.add(L)});let l=t.createDiv({cls:"csv-library-filters"}),c=l.createEl("select",{cls:"csv-library-filter-select"});c.createEl("option",{text:"All",value:"all"});let d=["watched","read","finished","completed","done","yes","seen"],h=["watching","reading","in progress","in-progress"],u=Array.from(a).some(w=>d.includes(w.toLowerCase())),f=Array.from(a).some(w=>h.includes(w.toLowerCase()));(u||f)&&(c.createEl("option",{text:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500",value:"",attr:{disabled:"true"}}),u&&c.createEl("option",{text:"\u2713 Done",value:"__done__"}),f&&c.createEl("option",{text:"\u25D0 In Progress",value:"__inprogress__"}),c.createEl("option",{text:"\u25CB Not Started",value:"__notstarted__"})),a.size>0&&(c.createEl("option",{text:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500",value:"",attr:{disabled:"true"}}),Array.from(a).sort().forEach(w=>{c.createEl("option",{text:w,value:w})})),c.value=s.libraryStatusFilter;let p=l.createEl("select",{cls:"csv-library-filter-select"});p.createEl("option",{text:"All genres",value:"all"}),Array.from(r).sort().forEach(w=>{p.createEl("option",{text:w,value:w})}),p.value=s.libraryGenreFilter;let g=s.resolveCol(["Year","year","Date","date"]),m=s.resolveCol(["Rating","rating","Score","score","Score /5","Stars","stars"]),b=s.resolveCol(["Theme","theme","Tags","tags","Tag","tag","Mood","mood"]),x=(M=s.fileCfg.librarySort)!=null?M:"status",_=l.createEl("select",{cls:"csv-library-filter-select"}),E=[["status","Sort: Status"],["title","Sort: Title"]];m&&E.push(["rating","Sort: Rating"]),g&&E.push(["year","Sort: Year"]),E.forEach(([w,L])=>{let k=_.createEl("option",{text:L,value:w});w===x&&(k.selected=!0)}),_.addEventListener("change",()=>{let w=s.fileCfg;w.librarySort=_.value==="status"?void 0:_.value,s.saveFileCfg(w),s.renderView(!0)});let S=()=>{s.libraryStatusFilter=c.value,s.libraryGenreFilter=p.value,s.renderView(!0)};c.addEventListener("change",S),p.addEventListener("change",S);let v=s.rows.filter(w=>{var L,k;if(s.libraryStatusFilter!=="all"&&n){let A=((L=w[n])!=null?L:"").toLowerCase();if(s.libraryStatusFilter==="__done__"){if(!d.includes(A))return!1}else if(s.libraryStatusFilter==="__inprogress__"){if(!h.includes(A))return!1}else if(s.libraryStatusFilter==="__notstarted__"){if(d.includes(A)||h.includes(A))return!1}else if(A!==s.libraryStatusFilter.toLowerCase())return!1}if(s.libraryGenreFilter!=="all"&&!((k=w[e])!=null?k:"").split(",").map(P=>P.trim().toLowerCase()).includes(s.libraryGenreFilter.toLowerCase()))return!1;if(s.searchQuery.trim()){let A=s.searchQuery.toLowerCase().trim();if(!s.headers.some(P=>{var I;return((I=w[P])!=null?I:"").toLowerCase().includes(A)}))return!1}return!0});(s.libraryStatusFilter!=="all"||s.libraryGenreFilter!=="all"||s.searchQuery.trim())&&t.createDiv({cls:"csv-library-result-count",text:`Showing ${v.length} of ${s.rows.length} entries`});let y={};v.forEach(w=>{var k;let L=s.libraryGenreFilter!=="all"?[s.libraryGenreFilter]:((k=w[e])!=null?k:"Uncategorized").split(",").map(A=>A.trim()).filter(Boolean);L.length===0&&L.push("Uncategorized"),L.forEach(A=>{y[A]||(y[A]=[]),y[A].push(w)})});let C=t.createDiv({cls:"csv-library-sections"});if(Object.keys(y).sort().forEach(w=>{var U,K,$,N,B;let L=y[w],k=C.createEl("details",{cls:"csv-library-section"}),A=w.toLowerCase(),P=((U=s.fileCfg.collapsedGroups)!=null?U:[]).map(H=>H.toLowerCase());k.open=!((K=s.collapsedGroups)!=null&&K.has(A)||P.includes(A)),k.addEventListener("toggle",()=>{var Z;let H=s.fileCfg,F=((Z=H.collapsedGroups)!=null?Z:[]).map(X=>X.toLowerCase()),G=new Set(F);k.open?G.delete(A):G.add(A);let Y=Array.from(G);Y.length===F.length&&Y.every(X=>F.includes(X))||(H.collapsedGroups=Y,s.saveFileCfg(H))});let I=k.createEl("summary",{cls:"csv-library-section-header"});I.innerHTML=`\u25B6 ${w} ${L.length}`;let z=k.createDiv({cls:"csv-library-grid"}),R=(H,F)=>{var G,Y;return((G=H[i])!=null?G:"").localeCompare((Y=F[i])!=null?Y:"")},V=(H,F)=>H===null&&F===null?0:H===null?1:F===null?-1:F-H;L.sort((H,F)=>{var G,Y,Z,X;if(x==="title")return R(H,F);if(x==="rating"&&m)return V(ks((G=H[m])!=null?G:""),ks((Y=F[m])!=null?Y:""))||R(H,F);if(x==="year"&&g){let q=ut=>{var st;let J=((st=ut[g])!=null?st:"").match(/\d{4}/);return J?parseInt(J[0],10):null};return V(q(H),q(F))||R(H,F)}if(n){let q=((Z=H[n])!=null?Z:"").toLowerCase(),ut=((X=F[n])!=null?X:"").toLowerCase(),J=d.includes(q),st=d.includes(ut);if(J!==st)return J?-1:1;let at=h.includes(q),Rt=h.includes(ut);if(at!==Rt)return at?-1:1}return R(H,F)});let T=[o,g,m,b].filter(H=>!!H),O=($=s.fileCfg.cardFields)!=null?$:T,j=(B=(N=s.getImageCol)==null?void 0:N.call(s))!=null?B:null;L.forEach(H=>{var X,q,ut,J,st,at,Rt;let F=z.createDiv({cls:"csv-library-card"});if(j){let ot=Js(s.app,(X=H[j])!=null?X:"",(ut=(q=s.file)==null?void 0:q.path)!=null?ut:"");if(ot){let gt=F.createEl("img",{cls:"csv-library-card-img",attr:{src:ot,loading:"lazy",alt:""}});gt.addEventListener("error",()=>gt.remove())}}let G=F.createDiv({cls:"csv-library-card-title"});if(n){let ot=((J=H[n])!=null?J:"").toLowerCase();d.includes(ot)&&G.createSpan({cls:"csv-library-done-dot"})}G.createSpan({text:(st=H[i])!=null?st:"Untitled"});let Y=[],Z=[];for(let ot of O){if(!ot)continue;let gt=String((at=H[ot])!=null?at:"").trim();if(gt)if(ot===m){let ft=Lo(gt,ot);ft&&F.createDiv({cls:"csv-library-card-rating",text:ft})}else if(ot===b)Z.push(...gt.split(",").map(ft=>ft.trim()).filter(Boolean));else if(ot===g){let ft=gt.match(/\d{4}/);Y.push(ft?ft[0]:gt)}else Y.push(gt)}if(Y.length&&F.createDiv({cls:"csv-library-card-meta",text:Y.join(" \xB7 ")}),s.libraryGenreFilter!=="all"){let ot=((Rt=H[e])!=null?Rt:"").split(",").map(gt=>gt.trim()).filter(gt=>gt&>.toLowerCase()!==s.libraryGenreFilter.toLowerCase());Z.push(...ot)}if(Z.length){let ot=F.createDiv({cls:"csv-library-card-tags"});Z.slice(0,3).forEach(gt=>{ot.createSpan({cls:"csv-library-card-tag",text:gt})})}F.addEventListener("click",()=>{var ot;s.openNoteExpander(H,(ot=s.getNotesCol())!=null?ot:"")}),F.addEventListener("contextmenu",ot=>s.openRowContextMenu(H,ot))})}),Object.keys(y).length===0){let w=C.createDiv({cls:"csv-empty-state"});w.createEl("p",{text:"No entries match your filters."}),w.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear filters"}).addEventListener("click",()=>{s.libraryStatusFilter="all",s.libraryGenreFilter="all",s.searchQuery="",s.renderView()})}}var gn=require("obsidian");var Me=require("obsidian");var di=`--- +`):s}function kf(s,t){let{element:e,datasetIndex:n,index:i}=t,o=s.getDatasetMeta(n).controller,{label:r,value:a}=o.getLabelAndValue(i);return{chart:s,label:r,parsed:o.getParsed(i),raw:s.data.datasets[n].data[i],formattedValue:a,dataset:o.getDataset(),dataIndex:i,datasetIndex:n,element:e}}function Wa(s,t){let e=s.chart.ctx,{body:n,footer:i,title:o}=s,{boxWidth:r,boxHeight:a}=t,l=bt(t.bodyFont),c=bt(t.titleFont),d=bt(t.footerFont),h=o.length,u=i.length,f=n.length,p=Ct(t.padding),g=p.height,b=0,m=n.reduce((w,S)=>w+S.before.length+S.lines.length+S.after.length,0);if(m+=s.beforeBody.length+s.afterBody.length,h&&(g+=h*c.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),m){let w=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;g+=f*w+(m-f)*l.lineHeight+(m-1)*t.bodySpacing}u&&(g+=t.footerMarginTop+u*d.lineHeight+(u-1)*t.footerSpacing);let x=0,_=function(w){b=Math.max(b,e.measureText(w).width+x)};return e.save(),e.font=c.string,rt(s.title,_),e.font=l.string,rt(s.beforeBody.concat(s.afterBody),_),x=t.displayColors?r+2+t.boxPadding:0,rt(n,w=>{rt(w.before,_),rt(w.lines,_),rt(w.after,_)}),x=0,e.font=d.string,rt(s.footer,_),e.restore(),b+=p.width,{width:b,height:g}}function Mf(s,t){let{y:e,height:n}=t;return es.height-n/2?"bottom":"center"}function Df(s,t,e,n){let{x:i,width:o}=n,r=e.caretSize+e.caretPadding;if(s==="left"&&i+o+r>t.width||s==="right"&&i-o-r<0)return!0}function Tf(s,t,e,n){let{x:i,width:o}=e,{width:r,chartArea:{left:a,right:l}}=s,c="center";return n==="center"?c=i<=(a+l)/2?"left":"right":i<=o/2?c="left":i>=r-o/2&&(c="right"),Df(c,s,t,e)&&(c="center"),c}function ja(s,t,e){let n=e.yAlign||t.yAlign||Mf(s,e);return{xAlign:e.xAlign||t.xAlign||Tf(s,t,e,n),yAlign:n}}function Lf(s,t){let{x:e,width:n}=s;return t==="right"?e-=n:t==="center"&&(e-=n/2),e}function Af(s,t,e){let{y:n,height:i}=s;return t==="top"?n+=e:t==="bottom"?n-=i+e:n-=i/2,n}function Ua(s,t,e,n){let{caretSize:i,caretPadding:o,cornerRadius:r}=s,{xAlign:a,yAlign:l}=e,c=i+o,{topLeft:d,topRight:h,bottomLeft:u,bottomRight:f}=ye(r),p=Lf(t,a),g=Af(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(d,u)+i:a==="right"&&(p+=Math.max(h,f)+i),{x:vt(p,0,n.width-t.width),y:vt(g,0,n.height-t.height)}}function Hn(s,t,e){let n=Ct(e.padding);return t==="center"?s.x+s.width/2:t==="right"?s.x+s.width-n.right:s.x+n.left}function Ka(s){return Jt([],ce(s))}function Pf(s,t,e){return le(s,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Ya(s,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?s.override(e):s}function Dt(s,t,e,n){let i=s[t].call(e,n);return typeof i=="undefined"?Rl[t].call(e,n):i}function Of(s,t,e,n){let i=s.indexOf(t);if(i===-1)return Rf(s,t,e,n);let o=s.lastIndexOf(t);return i!==o?e:i}function Ga(s){let t=this.getLabels();return s>=0&&sp&&(S=wi(M*S/p/f)*f),tt(l)||(y=Math.pow(10,l),S=Math.ceil(S*y)/y),i==="ticks"?(v=Math.floor(g/S)*S,C=Math.ceil(b/S)*S):(v=g,C=b),m&&x&&o&&Or((a-r)/o,S/1e3)?(M=Math.round(Math.min((a-r)/S,d)),S=(a-r)/M,v=r,C=a):_?(v=m?r:v,C=x?a:C,M=c-1,S=(C-v)/M):(M=(C-v)/S,es(M,Math.round(M),S/1e3)?M=Math.round(M):M=Math.ceil(M));let D=Math.max(Mi(S),Mi(v));y=Math.pow(10,tt(l)?D:l),v=Math.round(v*y)/y,C=Math.round(C*y)/y;let E=0;for(m&&(u&&v!==r?(e.push({value:r}),va)break;e.push({value:L})}return x&&u&&C!==a?e.length&&es(e[e.length-1].value,a,qa(a,w,s))?e[e.length-1].value=a:e.push({value:a}):(!x||C===a)&&e.push({value:C}),e}function qa(s,t,{horizontal:e,minRotation:n}){let i=Ht(n),o=(e?Math.sin(i):Math.cos(i))||.001,r=.75*t*(""+s).length;return Math.min(t/o,r)}function Xa(s){return s/Math.pow(10,Ys(s))===1}function Qa(s,t,e){let n=Math.pow(10,e),i=Math.floor(s/n);return Math.ceil(t/n)-i}function Vf(s,t){let e=t-s,n=Ys(e);for(;Qa(s,t,n)>10;)n++;for(;Qa(s,t,n)<10;)n--;return Math.min(n,Ys(s))}function Nf(s,{min:t,max:e}){t=Mt(s.min,t);let n=[],i=Ys(t),o=Vf(t,e),r=o<0?Math.pow(10,Math.abs(o)):1,a=Math.pow(10,o),l=i>o?Math.pow(10,i):0,c=Math.round((t-l)*r)/r,d=Math.floor((t-l)/a/10)*a*10,h=Math.floor((c-d)/Math.pow(10,o)),u=Mt(s.min,Math.round((l+d+h*Math.pow(10,o))*r)/r);for(;u=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),u=Math.round((l+d+h*Math.pow(10,o))*r)/r;let f=Mt(s.max,u);return n.push({value:f,major:Xa(f),significand:h}),n}function yo(s){let t=s.ticks;if(t.display&&s.display){let e=Ct(t.backdropPadding);return Z(t.font&&t.font.size,ht.font.size)+e.height}return 0}function Bf(s,t,e){return e=ct(e)?e:[e],{w:Wr(s,t.string,e),h:e.length*t.lineHeight}}function Za(s,t,e,n,i){return s===n||s===i?{start:t-e/2,end:t+e/2}:si?{start:t-e,end:t}:{start:t,end:t+e}}function zf(s){let t={l:s.left+s._padding.left,r:s.right-s._padding.right,t:s.top+s._padding.top,b:s.bottom-s._padding.bottom},e=Object.assign({},t),n=[],i=[],o=s._pointLabels.length,r=s.options.pointLabels,a=r.centerPointLabels?nt/o:0;for(let l=0;lt.r&&(a=(n.end-t.r)/o,s.r=Math.max(s.r,t.r+a)),i.startt.b&&(l=(i.end-t.b)/r,s.b=Math.max(s.b,t.b+l))}function $f(s,t,e){let n=s.drawingArea,{extra:i,additionalAngle:o,padding:r,size:a}=e,l=s.getPointPosition(t,n+i+r,o),c=Math.round(Mn(xt(l.angle+mt))),d=Yf(l.y,a.h,c),h=Uf(c),u=Kf(l.x,a.w,h);return{visible:!0,x:l.x,y:d,textAlign:h,left:u,top:d,right:u+a.w,bottom:d+a.h}}function Wf(s,t){if(!t)return!0;let{left:e,top:n,right:i,bottom:o}=s;return!(Xt({x:e,y:n},t)||Xt({x:e,y:o},t)||Xt({x:i,y:n},t)||Xt({x:i,y:o},t))}function jf(s,t,e){let n=[],i=s._pointLabels.length,o=s.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:yo(o)/2,additionalAngle:r?nt/i:0},c;for(let d=0;d270||e<90)&&(s-=t),s}function Gf(s,t,e){let{left:n,top:i,right:o,bottom:r}=e,{backdropColor:a}=t;if(!tt(a)){let l=ye(t.borderRadius),c=Ct(t.backdropPadding);s.fillStyle=a;let d=n-c.left,h=i-c.top,u=o-n+c.width,f=r-i+c.height;Object.values(l).some(p=>p!==0)?(s.beginPath(),os(s,{x:d,y:h,w:u,h:f,radius:l}),s.fill()):s.fillRect(d,h,u,f)}}function qf(s,t){let{ctx:e,options:{pointLabels:n}}=s;for(let i=t-1;i>=0;i--){let o=s._pointLabelItems[i];if(!o.visible)continue;let r=n.setContext(s.getPointLabelContext(i));Gf(e,r,o);let a=bt(r.font),{x:l,y:c,textAlign:d}=o;ve(e,s._pointLabels[i],l,c+a.lineHeight/2,a,{color:r.color,textAlign:d,textBaseline:"middle"})}}function Il(s,t,e,n){let{ctx:i}=s;if(e)i.arc(s.xCenter,s.yCenter,t,0,dt);else{let o=s.getPointPosition(0,t);i.moveTo(o.x,o.y);for(let r=1;r=Lt.indexOf(e);o--){let r=Lt[o];if(Jn[r].common&&s._adapter.diff(i,n,r)>=t-1)return r}return Lt[e?Lt.indexOf(e):0]}function Jf(s){for(let t=Lt.indexOf(s)+1,e=Lt.length;t=t?e[n]:e[i];s[o]=!0}}function tp(s,t,e,n){let i=s._adapter,o=+i.startOf(t[0].value,n),r=t[t.length-1].value,a,l;for(a=o;a<=r;a=+i.add(a,1,n))l=e[a],l>=0&&(t[l].major=!0);return t}function nl(s,t,e){let n=[],i={},o=t.length,r,a;for(r=0;r=s[n].pos&&t<=s[i].pos&&({lo:n,hi:i}=qt(s,"pos",t)),{pos:o,time:a}=s[n],{pos:r,time:l}=s[i]):(t>=s[n].time&&t<=s[i].time&&({lo:n,hi:i}=qt(s,"time",t)),{time:o,pos:a}=s[n],{time:r,pos:l}=s[i]);let c=r-o;return c?a+(l-a)*(t-o)/c:a}var lo,te,oa,eh,Un,Ws,Ji,da,uh,Tt,Fe,Ie,se,Ve,Se,ls,Ne,Be,rl,co,al,ll,cl,St,js,Kn,Wn,Fh,va,hl,Us,ya,Gn,At,Zh,xa,_a,ke,cs,ho,jt,uo,ka,ml,Bs,go,vu,xu,_u,jn,Aa,ee,_e,Nu,Ut,ze,He,_l,bo,Oa,El,kl,Xn,Dl,$a,xf,Qn,Ll,Ks,Al,zn,Pl,Hs,Rl,$s,Ol,Fl,Rf,Ff,ds,ps,hs,Ys,Oe,us,Ce,Jn,Lt,we,fs,Vl,ep,Bl=si(()=>{ia();lo=class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,n,i){let o=e.listeners[i],r=e.duration;o.forEach(a=>a({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(n-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Ai.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((n,i)=>{if(!n.running||!n.items.length)return;let o=n.items,r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>n.duration&&(n.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(i.draw(),this._notify(i,n,t,"progress")),o.length||(n.running=!1,this._notify(i,n,t,"complete"),n.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){let e=this._charts,n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}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((n,i)=>Math.max(n,i._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 n=e.items,i=n.length-1;for(;i>=0;--i)n[i].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}},te=new lo,oa="transparent",eh={boolean(s,t,e){return e>.5?t:s},color(s,t,e){let n=Ii(s||oa),i=n.valid&&Ii(t||oa);return i&&i.valid?i.mix(n,e).hexString():t},number(s,t,e){return s+(t-s)*e}},Un=class{constructor(t,e,n,i){let o=e[n];i=rs([t.to,i,o,t.from]);let r=rs([t.from,o,i]);this._active=!0,this._fn=t.fn||eh[t.type||typeof r],this._easing=Xe[t.easing]||Xe.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=n,this._from=r,this._to=i,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);let i=this._target[this._prop],o=n-this._start,r=this._duration-o;this._start=n,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=rs([t.to,e,i,t.from]),this._from=rs([t.from,i,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let e=t-this._start,n=this._duration,i=this._prop,o=this._from,r=this._loop,a=this._to,l;if(this._active=o!==a&&(r||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[i]=this._fn(o,a,l)}wait(){let t=this._promises||(this._promises=[]);return new Promise((e,n)=>{t.push({res:e,rej:n})})}_notify(t){let e=t?"res":"rej",n=this._promises||[];for(let i=0;i{let o=t[i];if(!et(o))return;let r={};for(let a of e)r[a]=o[a];(ct(o.properties)&&o.properties||[i]).forEach(a=>{(a===i||!n.has(a))&&n.set(a,r)})})}_animateOptions(t,e){let n=e.options,i=nh(t,n);if(!i)return[];let o=this._createAnimations(i,n);return n.$shared&&sh(t.options.$animations,n).then(()=>{t.options=n},()=>{}),o}_createAnimations(t,e){let n=this._properties,i=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now(),l;for(l=r.length-1;l>=0;--l){let c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){i.push(...this._animateOptions(t,e));continue}let d=e[c],h=o[c],u=n.get(c);if(h)if(u&&h.active()){h.update(u,d,a);continue}else h.cancel();if(!u||!u.duration){t[c]=d;continue}o[c]=h=new Un(u,t,c,d),i.push(h)}return i}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}let n=this._createAnimations(t,e);if(n.length)return te.add(this._chart,n),!0}};Ji=s=>s==="reset"||s==="none",da=(s,t)=>t?s:Object.assign({},s),uh=(s,t,e)=>s&&!t.hidden&&t._stacked&&{keys:il(e,!0),values:null},Tt=class{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=Qi(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&&Fs(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,n=this.getDataset(),i=(h,u,f,p)=>h==="x"?u:h==="r"?p:f,o=e.xAxisID=Z(n.xAxisID,Zi(t,"x")),r=e.yAxisID=Z(n.yAxisID,Zi(t,"y")),a=e.rAxisID=Z(n.rAxisID,Zi(t,"r")),l=e.indexAxis,c=e.iAxisID=i(l,o,r,a),d=e.vAxisID=i(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(d)}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&&Ti(this._data,this),t._stacked&&Fs(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if(et(e)){let i=this._cachedMeta;this._data=rh(e,i)}else if(n!==e){if(n){Ti(n,this);let i=this._cachedMeta;Fs(i),i._parsed=[]}e&&Object.isExtensible(e)&&Br(e,this),this._syncList=[],this._data=e}}addElements(){let t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){let e=this._cachedMeta,n=this.getDataset(),i=!1;this._dataCheck();let o=e._stacked;e._stacked=Qi(e.vScale,e),e.stack!==n.stack&&(i=!0,Fs(e),e.stack=n.stack),this._resyncElements(t),(i||o!==e._stacked)&&(ca(this,e._parsed),e._stacked=Qi(e.vScale,e))}configure(){let t=this.chart.config,e=t.datasetScopeKeys(this._type),n=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){let{_cachedMeta:n,_data:i}=this,{iScale:o,_stacked:r}=n,a=o.axis,l=t===0&&e===i.length?!0:n._sorted,c=t>0&&n._parsed[t-1],d,h,u;if(this._parsing===!1)n._parsed=i,n._sorted=!0,u=i;else{ct(i[t])?u=this.parseArrayData(n,i,t,e):et(i[t])?u=this.parseObjectData(n,i,t,e):u=this.parsePrimitiveData(n,i,t,e);let f=()=>h[a]===null||c&&h[a]g||h=0;--u)if(!p()){this.updateRangeFromParsed(c,t,f,l);break}}return c}getAllParsedValues(t){let e=this._cachedMeta._parsed,n=[],i,o,r;for(i=0,o=e.length;i=0&&tthis.getContext(n,i,e),g=c.resolveNamedOptions(u,f,p,h);return g.$shared&&(g.$shared=l,o[r]=Object.freeze(da(g,l))),g}_resolveAnimations(t,e,n){let i=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(i.options.animation!==!1){let d=this.chart.config,h=d.datasetAnimationScopeKeys(this._type,e),u=d.getOptionScopes(this.getDataset(),h);l=d.createResolver(u,this.getContext(t,n,e))}let c=new Ws(i,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ji(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){let n=this.resolveDataElementOptions(t,e),i=this._sharedOptions,o=this.getSharedOptions(n),r=this.includeOptions(e,o)||o!==i;return this.updateSharedOptions(o,e,n),{sharedOptions:o,includeOptions:r}}updateElement(t,e,n,i){Ji(i)?Object.assign(t,n):this._resolveAnimations(e,i).update(t,n)}updateSharedOptions(t,e,n){t&&!Ji(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,i){t.active=i;let o=this.getStyle(e,i);this._resolveAnimations(e,n,i).update(t,{options:!i&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"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,n=this._cachedMeta.data;for(let[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];let i=n.length,o=e.length,r=Math.min(o,i);r&&this.parse(0,r),o>i?this._insertElements(i,o-i,t):o{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;ad.controller.options.grouped),o=n.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(e),l=a&&a[n.axis],c=d=>{let h=d._parsed.find(f=>f[n.axis]===l),u=h&&h[d.vScale.axis];if(tt(u)||isNaN(u))return!0};for(let d of i)if(!(e!==void 0&&c(d))&&((o===!1||r.indexOf(d.stack)===-1||o===void 0&&d.stack===void 0)&&r.push(d.stack),d.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter(n=>t[n].axis===e).shift()}_getAxis(){let t={},e=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)t[Z(this.chart.options.indexAxis==="x"?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){let i=this._getStacks(t,n),o=e!==void 0?i.indexOf(e):-1;return o===-1?i.length-1:o}_getRuler(){let t=this.options,e=this._cachedMeta,n=e.iScale,i=[],o,r;for(o=0,r=e.data.length;o=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:i,yScale:o}=e,r=this.getParsed(t),a=i.getLabelForValue(r.x),l=o.getLabelForValue(r.y),c=r._custom;return{label:n[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){let e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,n,i){let o=i==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(e,i),d=r.axis,h=a.axis;for(let u=e;u+n[l];if(et(n[t])){let{key:l="value"}=this._parsing;o=c=>+ae(n[c],l)}let r,a;for(r=t,a=t+e;r0&&!isNaN(t)?dt*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart,i=n.data.labels||[],o=ns(e._parsed[t],n.options.locale);return{label:i[t]||"",value:o}}getMaxBorderWidth(t){let e=0,n=this.chart,i,o,r,a,l;if(!t){for(i=0,o=n.data.datasets.length;it!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),$(se,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data,{labels:{pointStyle:n,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map((l,c)=>{let h=t.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:h.backgroundColor,fontColor:o,hidden:!t.getDataVisibility(c),lineDash:h.borderDash,lineDashOffset:h.borderDashOffset,lineJoin:h.borderJoinStyle,lineWidth:h.borderWidth,strokeStyle:h.borderColor,textAlign:i,pointStyle:n,borderRadius:r&&(a||h.borderRadius),index:c}}):[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}}});Ve=class extends Tt{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){let e=this._cachedMeta,{dataset:n,data:i=[],_dataset:o}=e,r=this.chart._animationsDisabled,{start:a,count:l}=Ri(e,i,r);this._drawStart=a,this._drawCount=l,Oi(e)&&(a=0,l=i.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=i;let c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!r,options:c},t),this.updateElements(i,a,l,t)}updateElements(t,e,n,i){let o=i==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:d,includeOptions:h}=this._getSharedOptions(e,i),u=r.axis,f=a.axis,{spanGaps:p,segment:g}=this.options,b=Ae(p)?p:Number.POSITIVE_INFINITY,m=this.chart._animationsDisabled||o||i==="none",x=e+n,_=t.length,w=e>0&&this.getParsed(e-1);for(let S=0;S<_;++S){let y=t[S],v=m?y:{};if(S=x){v.skip=!0;continue}let C=this.getParsed(S),M=tt(C[f]),D=v[u]=r.getPixelForValue(C[u],S),E=v[f]=o||M?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,C,l):C[f],S);v.skip=isNaN(D)||isNaN(E)||M,v.stop=S>0&&Math.abs(C[u]-w[u])>b,g&&(v.parsed=C,v.raw=c.data[S]),h&&(v.options=d||this.resolveDataElementOptions(S,y.active?"active":i)),m||this.updateElement(y,S,v,i),w=C}}getMaxOverflow(){let t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,i=t.data||[];if(!i.length)return n;let o=i[0].size(this.resolveDataElementOptions(0)),r=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(n,o,r)/2}draw(){let t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}};$(Ve,"id","line"),$(Ve,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),$(Ve,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});Se=class extends Tt{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart,i=n.data.labels||[],o=ns(e._parsed[t].r,n.options.locale);return{label:i[t]||"",value:o}}parseObjectData(t,e,n,i){return Wi.bind(this)(t,e,n,i)}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((n,i)=>{let o=this.getParsed(i).r;!isNaN(o)&&this.chart.getDataVisibility(i)&&(oe.max&&(e.max=o))}),e}_updateRadius(){let t=this.chart,e=t.chartArea,n=t.options,i=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(i/2,0),r=Math.max(n.cutoutPercentage?o/100*n.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,n,i){let o=i==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,d=c.xCenter,h=c.yCenter,u=c.getIndexAngle(0)-.5*nt,f=u,p,g=360/this.countVisibleElements();for(p=0;p{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++}),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?Ht(this.resolveDataElementOptions(t,e).angle||n):0}};$(Se,"id","polarArea"),$(Se,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),$(Se,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data;if(e.labels.length&&e.datasets.length){let{labels:{pointStyle:n,color:i}}=t.legend.options;return e.labels.map((o,r)=>{let l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:i,lineWidth:l.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});ls=class extends se{};$(ls,"id","pie"),$(ls,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});Ne=class extends Tt{getLabelAndValue(t){let e=this._cachedMeta.vScale,n=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(n[e.axis])}}parseObjectData(t,e,n,i){return Wi.bind(this)(t,e,n,i)}update(t){let e=this._cachedMeta,n=e.dataset,i=e.data||[],o=e.iScale.getLabels();if(n.points=i,t!=="resize"){let r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);let a={_loop:!0,_fullLoop:o.length===i.length,options:r};this.updateElement(n,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,e,n,i){let o=this._cachedMeta.rScale,r=i==="reset";for(let a=e;a0&&this.getParsed(e-1);for(let w=e;w0&&Math.abs(y[f]-_[f])>m,b&&(v.parsed=y,v.raw=c.data[w]),u&&(v.options=h||this.resolveDataElementOptions(w,S.active?"active":i)),x||this.updateElement(S,w,v,i),_=y}this.updateSharedOptions(h,i,d)}getMaxOverflow(){let t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let a=0;for(let l=e.length-1;l>=0;--l)a=Math.max(a,e[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let n=t.dataset,i=n.options&&n.options.borderWidth||0;if(!e.length)return i;let o=e[0].size(this.resolveDataElementOptions(0)),r=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(i,o,r)/2}};$(Be,"id","scatter"),$(Be,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),$(Be,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});rl=Object.freeze({__proto__:null,BarController:Fe,BubbleController:Ie,DoughnutController:se,LineController:Ve,PieController:ls,PolarAreaController:Se,RadarController:Ne,ScatterController:Be});co=class s{constructor(t){$(this,"options");this.options=t||{}}static override(t){Object.assign(s.prototype,t)}init(){}formats(){return Re()}parse(){return Re()}format(){return Re()}add(){return Re()}diff(){return Re()}startOf(){return Re()}endOf(){return Re()}},al={_date:co};ll={evaluateInteractionItems:Gs,modes:{index(s,t,e,n){let i=xe(t,s),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?eo(s,i,o,n,r):so(s,i,o,!1,n,r),l=[];return a.length?(s.getSortedVisibleDatasetMetas().forEach(c=>{let d=a[0].index,h=c.data[d];h&&!h.skip&&l.push({element:h,datasetIndex:c.index,index:d})}),l):[]},dataset(s,t,e,n){let i=xe(t,s),o=e.axis||"xy",r=e.includeInvisible||!1,a=e.intersect?eo(s,i,o,n,r):so(s,i,o,!1,n,r);if(a.length>0){let l=a[0].datasetIndex,c=s.getDatasetMeta(l).data;a=[];for(let d=0;d{typeof g.beforeLayout=="function"&&g.beforeLayout()});let d=l.reduce((g,b)=>b.box.options&&b.box.options.display===!1?g:g+1,0)||1,h=Object.freeze({outerWidth:t,outerHeight:e,padding:i,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/d,hBoxMaxHeight:r/2}),u=Object.assign({},i);dl(u,Ct(n));let f=Object.assign({maxPadding:u,w:o,h:r,x:i.left,y:i.top},i),p=Lh(l.concat(c),h);zs(a.fullSize,f,h,p),zs(l,f,h,p),zs(c,f,h,p)&&zs(l,f,h,p),Rh(f),ba(a.leftAndTop,f,h,p),f.x+=f.w,f.y+=f.h,ba(a.rightAndBottom,f,h,p),s.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},rt(a.chartArea,g=>{let b=g.box;Object.assign(b,s.chartArea),b.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}},js=class{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,i){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,i?Math.floor(e/i):n)}}isAttached(t){return!0}updateConfig(t){}},Kn=class extends js{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}},Wn="$chartjs",Fh={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},va=s=>s===null||s==="";hl=Jr?{passive:!0}:!1;Us=new Map,ya=0;Gn=class extends js{acquireContext(t,e){let n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(Ih(t,e),n):null}releaseContext(t){let e=t.canvas;if(!e[Wn])return!1;let n=e[Wn].initial;["height","width"].forEach(o=>{let r=n[o];tt(r)?e.removeAttribute(o):e.setAttribute(o,r)});let i=n.style||{};return Object.keys(i).forEach(o=>{e.style[o]=i[o]}),e.width=e.width,delete e[Wn],!0}addEventListener(t,e,n){this.removeEventListener(t,e);let i=t.$proxies||(t.$proxies={}),r={attach:zh,detach:Hh,resize:jh}[e]||Uh;i[e]=r(t,e,n)}removeEventListener(t,e){let n=t.$proxies||(t.$proxies={}),i=n[e];if(!i)return;({attach:no,detach:no,resize:no}[e]||Nh)(t,e,i),n[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,i){return Zr(t,e,n,i)}isAttached(t){let e=t&&Fn(t);return!!(e&&e.isConnected)}};At=class{constructor(){$(this,"x");$(this,"y");$(this,"active",!1);$(this,"options");$(this,"$animations")}tooltipPosition(t){let{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return Ae(this.x)&&Ae(this.y)}getProps(t,e){let n=this.$animations;if(!e||!n)return this;let i={};return t.forEach(o=>{i[o]=n[o]&&n[o].active()?n[o]._to:this[o]}),i}};$(At,"defaults",{}),$(At,"defaultRoutes");Zh=s=>s==="left"?"right":s==="right"?"left":s,xa=(s,t,e)=>t==="top"||t==="left"?s[t]+e:s[t]-e,_a=(s,t)=>Math.min(t||s,s);ke=class s extends At{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:n,_suggestedMax:i}=this;return t=Mt(t,Number.POSITIVE_INFINITY),e=Mt(e,Number.NEGATIVE_INFINITY),n=Mt(n,Number.POSITIVE_INFINITY),i=Mt(i,Number.NEGATIVE_INFINITY),{min:Mt(t,n),max:Mt(e,i),minDefined:pt(t),maxDefined:pt(e)}}getMinMax(t){let{min:e,max:n,minDefined:i,maxDefined:o}=this.getUserBounds(),r;if(i&&o)return{min:e,max:n};let a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;ln?n:e,n=i&&e>n?e:n,{min:Mt(e,Mt(n,e)),max:Mt(n,Mt(e,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(){lt(this.options.beforeUpdate,[this])}update(t,e,n){let{beginAtZero:i,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Kr(this,o,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=a=o||n<=1||!this.isHorizontal()){this.labelRotation=i;return}let d=this._getLabelSizes(),h=d.widest.width,u=d.highest.height,f=vt(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/n:f/(n-1),h+6>a&&(a=f/(n-(t.offset?.5:1)),l=this.maxHeight-Ns(t.grid)-e.padding-Sa(t.title,this.chart.options.font),c=Math.sqrt(h*h+u*u),r=Mn(Math.min(Math.asin(vt((d.highest.height+6)/a,-1,1)),Math.asin(vt(l/c,-1,1))-Math.asin(vt(u/c,-1,1)))),r=Math.max(i,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){lt(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){lt(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:e,options:{ticks:n,title:i,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){let l=Sa(i,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ns(o)+l):(t.height=this.maxHeight,t.width=Ns(o)+l),n.display&&this.ticks.length){let{first:c,last:d,widest:h,highest:u}=this._getLabelSizes(),f=n.padding*2,p=Ht(this.labelRotation),g=Math.cos(p),b=Math.sin(p);if(a){let m=n.mirror?0:b*h.width+g*u.height;t.height=Math.min(this.maxHeight,t.height+m+f)}else{let m=n.mirror?0:g*h.width+b*u.height;t.width=Math.min(this.maxWidth,t.width+m+f)}this._calculatePadding(c,d,b,g)}}this._handleMargins(),a?(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,n,i){let{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){let d=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1),u=0,f=0;l?c?(u=i*t.width,f=n*e.height):(u=n*t.height,f=i*e.width):o==="start"?f=e.width:o==="end"?u=t.width:o!=="inner"&&(u=t.width/2,f=e.width/2),this.paddingLeft=Math.max((u-d+r)*this.width/(this.width-d),0),this.paddingRight=Math.max((f-h+r)*this.width/(this.width-h),0)}else{let d=e.height/2,h=t.height/2;o==="start"?(d=0,h=t.height):o==="end"&&(d=e.height,h=0),this.paddingTop=d+r,this.paddingBottom=h+r}}_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(){lt(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){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,n;for(e=0,n=t.length;e({width:r[M]||0,height:a[M]||0});return{first:C(0),last:C(e-1),widest:C(y),highest:C(v),widths:r,heights:a}}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 Fr(this._alignToPixels?be(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&&ta*i?a/n:l/i:l*i0}_computeGridLineItems(t){let e=this.axis,n=this.chart,i=this.options,{grid:o,position:r,border:a}=i,l=o.offset,c=this.isHorizontal(),h=this.ticks.length+(l?1:0),u=Ns(o),f=[],p=a.setContext(this.getContext()),g=p.display?p.width:0,b=g/2,m=function(I){return be(n,I,g)},x,_,w,S,y,v,C,M,D,E,L,k;if(r==="top")x=m(this.bottom),v=this.bottom-u,M=x-b,E=m(t.top)+b,k=t.bottom;else if(r==="bottom")x=m(this.top),E=t.top,k=m(t.bottom)-b,v=x+b,M=this.top+u;else if(r==="left")x=m(this.right),y=this.right-u,C=x-b,D=m(t.left)+b,L=t.right;else if(r==="right")x=m(this.left),D=t.left,L=m(t.right)-b,y=x+b,C=this.left+u;else if(e==="x"){if(r==="center")x=m((t.top+t.bottom)/2+.5);else if(et(r)){let I=Object.keys(r)[0],z=r[I];x=m(this.chart.scales[I].getPixelForValue(z))}E=t.top,k=t.bottom,v=x+b,M=v+u}else if(e==="y"){if(r==="center")x=m((t.left+t.right)/2);else if(et(r)){let I=Object.keys(r)[0],z=r[I];x=m(this.chart.scales[I].getPixelForValue(z))}y=x-b,C=y-u,D=t.left,L=t.right}let A=Z(i.ticks.maxTicksLimit,h),P=Math.max(1,Math.ceil(h/A));for(_=0;_0&&(V-=G/2);break}T={left:V,top:O,width:G+j.width,height:U+j.height,color:P.backdropColor}}b.push({label:w,font:M,textOffset:L,options:{rotation:g,color:z,strokeColor:F,strokeWidth:N,textAlign:H,textBaseline:k,translation:[S,y],backdrop:T}})}return b}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-Ht(this.labelRotation))return t==="top"?"left":"right";let i="center";return e.align==="start"?i="left":e.align==="end"?i="right":e.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){let{position:e,ticks:{crossAlign:n,mirror:i,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width,c,d;return e==="left"?i?(d=this.right+o,n==="near"?c="left":n==="center"?(c="center",d+=l/2):(c="right",d+=l)):(d=this.right-a,n==="near"?c="right":n==="center"?(c="center",d-=l/2):(c="left",d=this.left)):e==="right"?i?(d=this.left+o,n==="near"?c="right":n==="center"?(c="center",d-=l/2):(c="left",d-=l)):(d=this.left+a,n==="near"?c="left":n==="center"?(c="center",d+=l/2):(c="right",d=this.right)):c="right",{textAlign:c,x:d}}_computeLabelArea(){if(this.options.ticks.mirror)return;let t=this.chart,e=this.options.position;if(e==="left"||e==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(e==="top"||e==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){let{ctx:t,options:{backgroundColor:e},left:n,top:i,width:o,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,i,o,r),t.restore())}getLineWidthForValue(t){let e=this.options.grid;if(!this._isVisible()||!e.display)return 0;let i=this.ticks.findIndex(o=>o.value===t);return i>=0?e.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){let e=this.options.grid,n=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,r,a=(l,c,d)=>{!d.width||!d.color||(n.save(),n.lineWidth=d.width,n.strokeStyle=d.color,n.setLineDash(d.borderDash||[]),n.lineDashOffset=d.borderDashOffset,n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(c.x,c.y),n.stroke(),n.restore())};if(e.display)for(o=0,r=i.length;o{this.draw(o)}}]:[{z:n,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){let e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",i=[],o,r;for(o=0,r=e.length;o{let o=n||this._getRegistryForType(i);n||o.isForType(i)||o===this.plugins&&i.id?this._exec(t,o,i):rt(i,r=>{let a=n||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,n){let i=kn(t);lt(n["before"+i],[],n),e[t](n),lt(n["after"+i],[],n)}_getRegistryForType(t){for(let e=0;eo.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(i(e,n),t,"stop"),this._notify(i(n,e),t,"start")}};ka=new Map,ml=new Set;Bs=(s,t,e)=>{let n=ae(t,e);n!==void 0&&s.add(n)},go=class{constructor(t){this._config=bu(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=gl(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(),pl(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Bn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Bn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Bn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id,n=this.type;return Bn(`${n}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){let n=this._scopeCache,i=n.get(t);return(!i||e)&&(i=new Map,n.set(t,i)),i}getOptionScopes(t,e,n){let{options:i,type:o}=this,r=this._cachedScopes(t,n),a=r.get(e);if(a)return a;let l=new Set;e.forEach(d=>{t&&(l.add(t),d.forEach(h=>Bs(l,t,h))),d.forEach(h=>Bs(l,i,h)),d.forEach(h=>Bs(l,me[o]||{},h)),d.forEach(h=>Bs(l,ht,h)),d.forEach(h=>Bs(l,Ln,h))});let c=Array.from(l);return c.length===0&&c.push(Object.create(null)),ml.has(e)&&r.set(e,c),c}chartOptionScopes(){let{options:t,type:e}=this;return[t,me[e]||{},ht.datasets[e]||{},{type:e},ht,Ln]}resolveNamedOptions(t,e,n,i=[""]){let o={$shared:!0},{resolver:r,subPrefixes:a}=Ma(this._resolverCache,t,i),l=r;if(yu(r,e)){o.$shared=!1,n=oe(n)?n():n;let c=this.createResolver(t,n,a);l=Le(r,n,c)}for(let c of e)o[c]=l[c];return o}createResolver(t,e,n=[""],i){let{resolver:o}=Ma(this._resolverCache,t,n);return et(e)?Le(o,e,void 0,i):o}};vu=s=>et(s)&&Object.getOwnPropertyNames(s).some(t=>oe(s[t]));xu="4.5.1",_u=["top","bottom","left","right","chartArea"];jn={},Aa=s=>{let t=bl(s);return Object.values(jn).filter(e=>e.canvas===t).pop()};ee=class{static register(...t){jt.add(...t),Pa()}static unregister(...t){jt.remove(...t),Pa()}constructor(t,e){let n=this.config=new go(e),i=bl(t),o=Aa(i);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 r=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||fl(i)),this.platform.updateConfig(n);let a=this.platform.acquireContext(i,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,d=l&&l.width;if(this.id=Tr(),this.ctx=a,this.canvas=l,this.width=d,this.height=c,this._options=r,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 uo,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=zr(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],jn[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}te.listen(this,"complete",La),te.listen(this,"progress",Cu),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:e},width:n,height:i,_aspectRatio:o}=this;return tt(t)?e&&o?o:i?n/i: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 jt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ji(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Vi(this.canvas,this.ctx),this}stop(){return te.stop(this),this}resize(t,e){te.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){let n=this.options,i=this.canvas,o=n.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(i,t,e,o),a=n.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,ji(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),lt(n.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){let e=this.options.scales||{};rt(e,(n,i)=>{n.id=i})}buildOrUpdateScales(){let t=this.options,e=t.scales,n=this.scales,i=Object.keys(n).reduce((r,a)=>(r[a]=!1,r),{}),o=[];e&&(o=o.concat(Object.keys(e).map(r=>{let a=e[r],l=po(r,a),c=l==="r",d=l==="x";return{options:a,dposition:c?"chartArea":d?"bottom":"left",dtype:c?"radialLinear":d?"category":"linear"}}))),rt(o,r=>{let a=r.options,l=a.id,c=po(l,a),d=Z(a.type,r.dtype);(a.position===void 0||Da(a.position,c)!==Da(r.dposition))&&(a.position=r.dposition),i[l]=!0;let h=null;if(l in n&&n[l].type===d)h=n[l];else{let u=jt.getScale(d);h=new u({id:l,type:d,ctx:this.ctx,chart:this}),n[h.id]=h}h.init(a,t)}),rt(i,(r,a)=>{r||delete n[a]}),rt(n,r=>{St.configure(this,r,r.options),St.addBox(this,r)})}_updateMetasets(){let t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort((i,o)=>i.index-o.index),n>e){for(let i=e;ie.length&&delete this._stacks,t.forEach((n,i)=>{e.filter(o=>o===n._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){let t=[],e=this.data.datasets,n,i;for(this._removeUnreferencedMetasets(),n=0,i=e.length;n{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let e=this.config;e.update();let n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!n.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 r=0;for(let c=0,d=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Ta("z","_idx"));let{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){rt(this.scales,t=>{St.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);(!Ei(e,n)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(let{method:n,start:i,count:o}of e){let r=n==="_removeElements"?-o:o;Su(t,i,r)}}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let e=this.data.datasets.length,n=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),i=n(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;St.update(this,this.width,this.height,t);let e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],rt(this.boxes,i=>{n&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,o)=>{i._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,n=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let e=this.ctx,n={meta:t,index:t.index,cancelable:!0},i=Xi(this,t);this.notifyPlugins("beforeDatasetDraw",n)!==!1&&(i&&Rs(e,i),t.controller.draw(),i&&Os(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return Xt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,i){let o=ll.modes[e];return typeof o=="function"?o(this,t,n,i):[]}getDatasetMeta(t){let e=this.data.datasets[t],n=this._metasets,i=n.filter(o=>o&&o._dataset===e).pop();return i||(i={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},n.push(i)),i}getContext(){return this.$context||(this.$context=le(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let e=this.data.datasets[t];if(!e)return!1;let n=this.getDatasetMeta(t);return typeof n.hidden=="boolean"?!n.hidden:!e.hidden}setDatasetVisibility(t,e){let n=this.getDatasetMeta(t);n.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,n){let i=n?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,i);ts(e)?(o.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),r.update(o,{visible:n}),this.update(a=>a.datasetIndex===t?i: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(),te.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,r),t[o]=r},i=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};rt(this.options.events,o=>n(o,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,n=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},i=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)},r,a=()=>{i("attach",a),this.attached=!0,this.resize(),n("resize",o),n("detach",r)};r=()=>{this.attached=!1,i("resize",o),this._stop(),this._resize(0,0),n("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){rt(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},rt(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){let i=n?"set":"remove",o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+i+"DatasetHoverStyle"]()),a=0,l=t.length;a{let a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Ps(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,n){let i=this.options.hover,o=(l,c)=>l.filter(d=>!c.some(h=>d.datasetIndex===h.datasetIndex&&d.index===h.index)),r=o(e,t),a=n?t:o(t,e);r.length&&this.updateHoverStyle(r,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,e){let n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},i=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",n,i)===!1)return;let o=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,i),(o||n.changed)&&this.render(),this}_handleEvent(t,e,n){let{_active:i=[],options:o}=this,r=e,a=this._getActiveElements(t,i,n,r),l=Pr(t),c=Eu(t,this._lastEvent,n,l);n&&(this._lastEvent=null,lt(o.onHover,[t,a,this],this),l&<(o.onClick,[t,a,this],this));let d=!Ps(a,i);return(d||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=c,d}_getActiveElements(t,e,n,i){if(t.type==="mouseout")return[];if(!n)return e;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,i)}};$(ee,"defaults",ht),$(ee,"instances",jn),$(ee,"overrides",me),$(ee,"registry",jt),$(ee,"version",xu),$(ee,"getChart",Aa);_e=class extends At{constructor(e){super();$(this,"circumference");$(this,"endAngle");$(this,"fullCircles");$(this,"innerRadius");$(this,"outerRadius");$(this,"pixelMargin");$(this,"startAngle");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,e&&Object.assign(this,e)}inRange(e,n,i){let o=this.getProps(["x","y"],i),{angle:r,distance:a}=Di(o,{x:e,y:n}),{startAngle:l,endAngle:c,innerRadius:d,outerRadius:h,circumference:u}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),f=(this.options.spacing+this.options.borderWidth)/2,p=Z(u,c-l),g=ss(r,l,c)&&l!==c,b=p>=dt||g,m=Zt(a,d+f,h+f);return b&&m}getCenterPoint(e){let{x:n,y:i,startAngle:o,endAngle:r,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:c,spacing:d}=this.options,h=(o+r)/2,u=(a+l+d+c)/2;return{x:n+Math.cos(h)*u,y:i+Math.sin(h)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:n,circumference:i}=this,o=(n.offset||0)/4,r=(n.spacing||0)/2,a=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=i>dt?Math.floor(i/dt):0,i===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let l=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(l)*o,Math.sin(l)*o);let c=1-Math.sin(Math.min(nt,i||0)),d=o*c;e.fillStyle=n.backgroundColor,e.strokeStyle=n.borderColor,Tu(e,this,d,r,a),Lu(e,this,d,r,a),e.restore()}};$(_e,"id","arc"),$(_e,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1}),$(_e,"defaultRoutes",{backgroundColor:"backgroundColor"}),$(_e,"descriptors",{_scriptable:!0,_indexable:e=>e!=="borderDash"});Nu=typeof Path2D=="function";Ut=class extends At{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 n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){let i=n.spanGaps?this._loop:this._fullLoop;Qr(this._points,n,t,i,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=na(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,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){let n=this.options,i=t[e],o=this.points,r=qi(this,{property:e,start:i,end:i});if(!r.length)return;let a=[],l=Fu(n),c,d;for(c=0,d=r.length;ct!=="borderDash"&&t!=="fill"});ze=class extends At{constructor(e){super();$(this,"parsed");$(this,"skip");$(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,e&&Object.assign(this,e)}inRange(e,n,i){let o=this.options,{x:r,y:a}=this.getProps(["x","y"],i);return Math.pow(e-r,2)+Math.pow(n-a,2)s.replace("rgb(","rgba(").replace(")",", 0.5)"));El={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(s,t,e){if(!e.enabled)return;let{data:{datasets:n},options:i}=s.config,{elements:o}=i,r=Fa(n)||qu(i)||o&&Fa(o)||Xu();if(!e.forceOverride&&r)return;let a=Gu(s);n.forEach(a)}};kl={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(s,t,e)=>{if(!e.enabled){Ia(s);return}let n=s.width;s.data.datasets.forEach((i,o)=>{let{_data:r,indexAxis:a}=i,l=s.getDatasetMeta(o),c=r||i.data;if(rs([a,s.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let d=s.scales[l.xAxisID];if(d.type!=="linear"&&d.type!=="time"||s.options.parsing)return;let{start:h,count:u}=Ju(l,c),f=e.threshold||4*n;if(u<=f){wl(i);return}tt(r)&&(i._data=c,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(g){this._data=g}}));let p;switch(e.algorithm){case"lttb":p=Qu(c,h,u,n,e);break;case"min-max":p=Zu(c,h,u,n);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}i._decimated=p})},destroy(s){Ia(s)}};Xn=class{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,n){let{x:i,y:o,radius:r}=this;return e=e||{start:0,end:dt},t.arc(i,o,r,e.end,e.start,!0),!n.bounds}interpolate(t){let{x:e,y:n,radius:i}=this,o=t.angle;return{x:e+Math.cos(o)*i,y:n+Math.sin(o)*i,angle:o}}};Dl={id:"filler",afterDatasetsUpdate(s,t,e){let n=(s.data.datasets||[]).length,i=[],o,r,a,l;for(r=0;r=0;--r){let a=i[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),n&&a.fill&&ro(s.ctx,a,o))}},beforeDatasetsDraw(s,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;let n=s.getSortedVisibleDatasetMetas();for(let i=n.length-1;i>=0;--i){let o=n[i].$filler;Na(o)&&ro(s.ctx,o,s.chartArea)}},beforeDatasetDraw(s,t,e){let n=t.meta.$filler;!Na(n)||e.drawTime!=="beforeDatasetDraw"||ro(s.ctx,n,s.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}},$a=(s,t)=>{let{boxHeight:e=t,boxWidth:n=t}=s;return s.usePointStyle&&(e=Math.min(e,t),n=s.pointStyleWidth||Math.min(n,t)),{boxWidth:n,boxHeight:e,itemHeight:Math.max(t,e)}},xf=(s,t)=>s!==null&&t!==null&&s.datasetIndex===t.datasetIndex&&s.index===t.index,Qn=class extends At{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,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,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=lt(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(n=>t.filter(n,this.chart.data))),t.sort&&(e=e.sort((n,i)=>t.sort(n,i,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){let{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}let n=t.labels,i=bt(n.font),o=i.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=$a(n,o),c,d;e.font=i.string,this.isHorizontal()?(c=this.maxWidth,d=this._fitRows(r,o,a,l)+10):(d=this.maxHeight,c=this._fitCols(r,i,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(d,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,i){let{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],d=i+a,h=t;o.textAlign="left",o.textBaseline="middle";let u=-1,f=-d;return this.legendItems.forEach((p,g)=>{let b=n+e/2+o.measureText(p.text).width;(g===0||c[c.length-1]+b+2*a>r)&&(h+=d,c[c.length-(g>0?0:1)]=0,f+=d,u++),l[g]={left:0,top:f,row:u,width:b,height:i},c[c.length-1]+=b+a}),h}_fitCols(t,e,n,i){let{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],d=r-t,h=a,u=0,f=0,p=0,g=0;return this.legendItems.forEach((b,m)=>{let{itemWidth:x,itemHeight:_}=_f(n,e,o,b,i);m>0&&f+_+2*a>d&&(h+=u+a,c.push({width:u,height:f}),p+=u+a,g++,u=f=0),l[m]={left:p,top:f,col:g,width:x,height:_},u=Math.max(u,x),f+=_+a}),h+=u,c.push({width:u,height:f}),h}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:i},rtl:o}}=this,r=Pe(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=_t(n,this.left+i,this.right-this.lineWidths[a]);for(let c of e)a!==c.row&&(a=c.row,l=_t(n,this.left+i,this.right-this.lineWidths[a])),c.top+=this.top+t+i,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+i}else{let a=0,l=_t(n,this.top+t+i,this.bottom-this.columnSizes[a].height);for(let c of e)c.col!==a&&(a=c.col,l=_t(n,this.top+t+i,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+i,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;Rs(t,this),this._draw(),Os(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:n,ctx:i}=this,{align:o,labels:r}=t,a=ht.color,l=Pe(t.rtl,this.left,this.width),c=bt(r.font),{padding:d}=r,h=c.size,u=h/2,f;this.drawTitle(),i.textAlign=l.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=c.string;let{boxWidth:p,boxHeight:g,itemHeight:b}=$a(r,h),m=function(y,v,C){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;i.save();let M=Z(C.lineWidth,1);if(i.fillStyle=Z(C.fillStyle,a),i.lineCap=Z(C.lineCap,"butt"),i.lineDashOffset=Z(C.lineDashOffset,0),i.lineJoin=Z(C.lineJoin,"miter"),i.lineWidth=M,i.strokeStyle=Z(C.strokeStyle,a),i.setLineDash(Z(C.lineDash,[])),r.usePointStyle){let D={radius:g*Math.SQRT2/2,pointStyle:C.pointStyle,rotation:C.rotation,borderWidth:M},E=l.xPlus(y,p/2),L=v+u;Ni(i,D,E,L,r.pointStyleWidth&&p)}else{let D=v+Math.max((h-g)/2,0),E=l.leftForLtr(y,p),L=ye(C.borderRadius);i.beginPath(),Object.values(L).some(k=>k!==0)?os(i,{x:E,y:D,w:p,h:g,radius:L}):i.rect(E,D,p,g),i.fill(),M!==0&&i.stroke()}i.restore()},x=function(y,v,C){ve(i,C.text,y,v+b/2,c,{strikethrough:C.hidden,textAlign:l.textAlign(C.textAlign)})},_=this.isHorizontal(),w=this._computeTitleHeight();_?f={x:_t(o,this.left+d,this.right-n[0]),y:this.top+d+w,line:0}:f={x:this.left+d,y:_t(o,this.top+w+d,this.bottom-e[0].height),line:0},Ki(this.ctx,t.textDirection);let S=b+d;this.legendItems.forEach((y,v)=>{i.strokeStyle=y.fontColor,i.fillStyle=y.fontColor;let C=i.measureText(y.text).width,M=l.textAlign(y.textAlign||(y.textAlign=r.textAlign)),D=p+u+C,E=f.x,L=f.y;l.setWidth(this.width),_?v>0&&E+D+d>this.right&&(L=f.y+=S,f.line++,E=f.x=_t(o,this.left+d,this.right-n[f.line])):v>0&&L+S>this.bottom&&(E=f.x=E+e[f.line].width+d,f.line++,L=f.y=_t(o,this.top+w+d,this.bottom-e[f.line].height));let k=l.x(E);if(m(k,L,y),E=Hr(M,E+p+u,_?E+D:this.right,t.rtl),x(l.x(E),L,y),_)f.x+=D+d;else if(typeof y.text!="string"){let A=c.lineHeight;f.y+=Tl(y,A)+d}else f.y+=S}),Yi(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,n=bt(e.font),i=Ct(e.padding);if(!e.display)return;let o=Pe(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=n.size/2,c=i.top+l,d,h=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),d=this.top+c,h=_t(t.align,h,this.right-u);else{let p=this.columnSizes.reduce((g,b)=>Math.max(g,b.height),0);d=c+_t(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}let f=_t(a,h,h+u);r.textAlign=o.textAlign(Tn(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=n.string,ve(r,e.text,f,d,n)}_computeTitleHeight(){let t=this.options.title,e=bt(t.font),n=Ct(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,i,o;if(Zt(t,this.left,this.right)&&Zt(e,this.top,this.bottom)){for(o=this.legendHitBoxes,n=0;ns.chart.options.color,boxWidth:40,padding:10,generateLabels(s){let t=s.data.datasets,{labels:{usePointStyle:e,pointStyle:n,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=s.legend.options;return s._getSortedDatasetMetas().map(l=>{let c=l.controller.getStyle(e?0:void 0),d=Ct(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(d.width+d.height)/4,strokeStyle:c.borderColor,pointStyle:n||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:s=>s.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:s=>!s.startsWith("on"),labels:{_scriptable:s=>!["generateLabels","filter","sort"].includes(s)}}},Ks=class extends At{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 n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;let i=ct(n.text)?n.text.length:1;this._padding=Ct(n.padding);let o=i*bt(n.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:n,bottom:i,right:o,options:r}=this,a=r.align,l=0,c,d,h;return this.isHorizontal()?(d=_t(a,n,o),h=e+t,c=o-n):(r.position==="left"?(d=n+t,h=_t(a,i,e),l=nt*-.5):(d=o-t,h=_t(a,e,i),l=nt*.5),c=i-e),{titleX:d,titleY:h,maxWidth:c,rotation:l}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let n=bt(e.font),o=n.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);ve(t,e.text,0,0,n,{color:e.color,maxWidth:l,rotation:c,textAlign:Tn(e.align),textBaseline:"middle",translation:[r,a]})}};Al={id:"title",_element:Ks,start(s,t,e){wf(s,e)},stop(s){let t=s.titleBlock;St.removeBox(s,t),delete s.titleBlock},beforeUpdate(s,t,e){let n=s.titleBlock;St.configure(s,n,e),n.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}},zn=new WeakMap,Pl={id:"subtitle",start(s,t,e){let n=new Ks({ctx:s.ctx,options:e,chart:s});St.configure(s,n,e),St.addBox(s,n),zn.set(s,n)},stop(s){St.removeBox(s,zn.get(s)),zn.delete(s)},beforeUpdate(s,t,e){let n=zn.get(s);St.configure(s,n,e),n.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}},Hs={average(s){if(!s.length)return!1;let t,e,n=new Set,i=0,o=0;for(t=0,e=s.length;ta+l)/n.size,y:i/o}},nearest(s,t){if(!s.length)return!1;let e=t.x,n=t.y,i=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=s.length;o0){let t=s[0],e=t.chart.data.labels,n=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(n>0&&t.dataIndex{let r={before:[],lines:[],after:[]},a=Ya(n,o);Jt(r.before,ce(Dt(a,"beforeLabel",this,o))),Jt(r.lines,Dt(a,"label",this,o)),Jt(r.after,ce(Dt(a,"afterLabel",this,o))),i.push(r)}),i}getAfterBody(t,e){return Ka(Dt(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:n}=e,i=Dt(n,"beforeFooter",this,t),o=Dt(n,"footer",this,t),r=Dt(n,"afterFooter",this,t),a=[];return a=Jt(a,ce(i)),a=Jt(a,ce(o)),a=Jt(a,ce(r)),a}_createItems(t){let e=this._active,n=this.chart.data,i=[],o=[],r=[],a=[],l,c;for(l=0,c=e.length;lt.filter(d,h,u,n))),t.itemSort&&(a=a.sort((d,h)=>t.itemSort(d,h,n))),rt(a,d=>{let h=Ya(t.callbacks,d);i.push(Dt(h,"labelColor",this,d)),o.push(Dt(h,"labelPointStyle",this,d)),r.push(Dt(h,"labelTextColor",this,d))}),this.labelColors=i,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){let n=this.options.setContext(this.getContext()),i=this._active,o,r=[];if(!i.length)this.opacity!==0&&(o={opacity:0});else{let a=Hs[n.position].call(this,i,this._eventPosition);r=this._createItems(n),this.title=this.getTitle(r,n),this.beforeBody=this.getBeforeBody(r,n),this.body=this.getBody(r,n),this.afterBody=this.getAfterBody(r,n),this.footer=this.getFooter(r,n);let l=this._size=Wa(this,n),c=Object.assign({},a,l),d=ja(this.chart,n,c),h=Ua(n,c,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,o={opacity:1,x:h.x,y:h.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,i){let o=this.getCaretPosition(t,n,i);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,n){let{xAlign:i,yAlign:o}=this,{caretSize:r,cornerRadius:a}=n,{topLeft:l,topRight:c,bottomLeft:d,bottomRight:h}=ye(a),{x:u,y:f}=t,{width:p,height:g}=e,b,m,x,_,w,S;return o==="center"?(w=f+g/2,i==="left"?(b=u,m=b-r,_=w+r,S=w-r):(b=u+p,m=b+r,_=w-r,S=w+r),x=b):(i==="left"?m=u+Math.max(l,d)+r:i==="right"?m=u+p-Math.max(c,h)-r:m=this.caretX,o==="top"?(_=f,w=_-r,b=m-r,x=m+r):(_=f+g,w=_+r,b=m+r,x=m-r),S=_),{x1:b,x2:m,x3:x,y1:_,y2:w,y3:S}}drawTitle(t,e,n){let i=this.title,o=i.length,r,a,l;if(o){let c=Pe(n.rtl,this.x,this.width);for(t.x=Hn(this,n.titleAlign,n),e.textAlign=c.textAlign(n.titleAlign),e.textBaseline="middle",r=bt(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=r.string,l=0;lx!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,os(t,{x:g,y:p,w:c,h:l,radius:m}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),os(t,{x:b,y:p+1,w:c-2,h:l-2,radius:m}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,c,l),t.strokeRect(g,p,c,l),t.fillStyle=r.backgroundColor,t.fillRect(b,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){let{body:i}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:d}=n,h=bt(n.bodyFont),u=h.lineHeight,f=0,p=Pe(n.rtl,this.x,this.width),g=function(C){e.fillText(C,p.x(t.x+f),t.y+u/2),t.y+=u+o},b=p.textAlign(r),m,x,_,w,S,y,v;for(e.textAlign=r,e.textBaseline="middle",e.font=h.string,t.x=Hn(this,b,n),e.fillStyle=n.bodyColor,rt(this.beforeBody,g),f=a&&b!=="right"?r==="center"?c/2+d:c+2+d:0,w=0,y=i.length;w0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,n=this.$animations,i=n&&n.x,o=n&&n.y;if(i||o){let r=Hs[t.position].call(this,this._active,this._eventPosition);if(!r)return;let a=this._size=Wa(this,t),l=Object.assign({},r,this._size),c=ja(e,t,l),d=Ua(t,l,c,e);(i._to!==d.x||o._to!==d.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,d))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(e);let i={width:this.width,height:this.height},o={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let r=Ct(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=n,this.drawBackground(o,t,i,e),Ki(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Yi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let n=this._active,i=t.map(({datasetIndex:a,index:l})=>{let c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Ps(n,i),r=this._positionChanged(i,e);(o||r)&&(this._active=i,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let i=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,n),a=this._positionChanged(r,t),l=e||!Ps(r,o)||a;return l&&(this._active=r,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,n,i){let o=this.options;if(t.type==="mouseout")return[];if(!i)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);let r=this.chart.getElementsAtEventForMode(t,o.mode,o,n);return o.reverse&&r.reverse(),r}_positionChanged(t,e){let{caretX:n,caretY:i,options:o}=this,r=Hs[o.position].call(this,t,e);return r!==!1&&(n!==r.x||i!==r.y)}};$($s,"positioners",Hs);Ol={id:"tooltip",_element:$s,positioners:Hs,afterInit(s,t,e){e&&(s.tooltip=new $s({chart:s,options:e}))},beforeUpdate(s,t,e){s.tooltip&&s.tooltip.initialize(e)},reset(s,t,e){s.tooltip&&s.tooltip.initialize(e)},afterDraw(s){let t=s.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(s.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(s.ctx),s.notifyPlugins("afterTooltipDraw",e)}},afterEvent(s,t){if(s.tooltip){let e=t.replay;s.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:(s,t)=>t.bodyFont.size,boxWidth:(s,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:Rl},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:s=>s!=="filter"&&s!=="itemSort"&&s!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Fl=Object.freeze({__proto__:null,Colors:El,Decimation:kl,Filler:Dl,Legend:Ll,SubTitle:Pl,Title:Al,Tooltip:Ol}),Rf=(s,t,e,n)=>(typeof t=="string"?(e=s.push(t)-1,n.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);Ff=(s,t)=>s===null?null:vt(Math.round(s),0,t);ds=class extends ke{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){let e=this._addedLabels;if(e.length){let n=this.getLabels();for(let{index:i,label:o}of e)n[i]===o&&n.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(tt(t))return null;let n=this.getLabels();return e=isFinite(e)&&n[e]===t?e:Of(n,t,Z(e,t),this._addedLabels),Ff(e,n.length-1)}determineDataLimits(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),{min:n,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(n=0),e||(i=this.getLabels().length-1)),this.min=n,this.max=i}buildTicks(){let t=this.min,e=this.max,n=this.options.offset,i=[],o=this.getLabels();o=t===0&&e===o.length-1?o:o.slice(t,e+1),this._valueRange=Math.max(o.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let r=t;r<=e;r++)i.push({value:r});return i}getLabelForValue(t){return Ga.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}};$(ds,"id","category"),$(ds,"defaults",{ticks:{callback:Ga}});ps=class extends ke{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return tt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){let{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds(),{min:i,max:o}=this,r=l=>i=e?i:l,a=l=>o=n?o:l;if(t){let l=Wt(i),c=Wt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(i===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(i-l)}this.min=i,this.max=o}getTickLimit(){let t=this.options.ticks,{maxTicksLimit:e,stepSize:n}=t,i;return n?(i=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),e=e||11),e&&(i=Math.min(e,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,e=t.ticks,n=this.getTickLimit();n=Math.max(2,n);let i={maxTicks:n,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},o=this._range||this,r=If(i,o);return t.bounds==="ticks"&&ki(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let t=this.ticks,e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){let i=(n-e)/Math.max(t.length-1,1)/2;e-=i,n+=i}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return ns(t,this.chart.options.locale,this.options.ticks.format)}},hs=class extends ps{determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?t:0,this.max=pt(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,n=Ht(this.options.ticks.minRotation),i=(t?Math.sin(n):Math.cos(n))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}};$(hs,"id","linear"),$(hs,"defaults",{ticks:{callback:is.formatters.numeric}});Ys=s=>Math.floor(re(s)),Oe=(s,t)=>Math.pow(10,Ys(s)+t);us=class extends ke{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){let n=ps.prototype.parse.apply(this,[t,e]);if(n===0){this._zero=!0;return}return pt(n)&&n>0?n:null}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?Math.max(0,t):null,this.max=pt(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!pt(this._userMin)&&(this.min=t===Oe(this.min,0)?Oe(this.min,-1):Oe(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),n=this.min,i=this.max,o=a=>n=t?n:a,r=a=>i=e?i:a;n===i&&(n<=0?(o(1),r(10)):(o(Oe(n,-1)),r(Oe(i,1)))),n<=0&&o(Oe(i,-1)),i<=0&&r(Oe(n,1)),this.min=n,this.max=i}buildTicks(){let t=this.options,e={min:this._userMin,max:this._userMax},n=Nf(e,this);return t.bounds==="ticks"&&ki(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(t){return t===void 0?"0":ns(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=re(t),this._valueRange=re(this.max)-re(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(re(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}};$(us,"id","logarithmic"),$(us,"defaults",{ticks:{callback:is.formatters.logarithmic,major:{enabled:!0}}});Ce=class extends ps{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=Ct(yo(this.options)/2),e=this.width=this.maxWidth-t.width,n=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+n/2+t.top),this.drawingArea=Math.floor(Math.min(e,n)/2)}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!1);this.min=pt(t)&&!isNaN(t)?t:0,this.max=pt(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/yo(this.options))}generateTickLabels(t){ps.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,n)=>{let i=lt(this.options.pointLabels.callback,[e,n],this);return i||i===0?i:""}).filter((e,n)=>this.chart.getDataVisibility(n))}fit(){let t=this.options;t.display&&t.pointLabels.display?zf(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,i){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,i))}getIndexAngle(t){let e=dt/(this._pointLabels.length||1),n=this.options.startAngle||0;return xt(t*e+Ht(n))}getDistanceFromCenterForValue(t){if(tt(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(tt(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{if(h!==0||h===0&&this.min<0){l=this.getDistanceFromCenterForValue(d.value);let u=this.getContext(h),f=i.setContext(u),p=o.setContext(u);Xf(this,f,l,r,p)}}),n.display){for(t.save(),a=r-1;a>=0;a--){let d=n.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:u}=d;!u||!h||(t.lineWidth=u,t.strokeStyle=h,t.setLineDash(d.borderDash),t.lineDashOffset=d.borderDashOffset,l=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){let t=this.ctx,e=this.options,n=e.ticks;if(!n.display)return;let i=this.getIndexAngle(0),o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;let c=n.setContext(this.getContext(l)),d=bt(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=d.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;let h=Ct(c.backdropPadding);t.fillRect(-r/2-h.left,-o-d.size/2-h.top,r+h.width,d.size+h.height)}ve(t,a.label,0,-o,d,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}};$(Ce,"id","radialLinear"),$(Ce,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:is.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),$(Ce,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),$(Ce,"descriptors",{angleLines:{_fallback:"grid"}});Jn={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}},Lt=Object.keys(Jn);we=class extends ke{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 n=t.time||(t.time={}),i=this._adapter=new al._date(t.adapters.date);i.init(e),Je(n.displayFormats,i.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:tl(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,e=this._adapter,n=t.time.unit||"day",{min:i,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(i=Math.min(i,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=pt(i)&&!isNaN(i)?i:+e.startOf(Date.now(),n),o=pt(o)&&!isNaN(o)?o:+e.endOf(Date.now(),n)+1,this.min=Math.min(i,o-1),this.max=Math.max(i+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],n=t[t.length-1]),{min:e,max:n}}buildTicks(){let t=this.options,e=t.time,n=t.ticks,i=n.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);let o=this.min,r=this.max,a=Vr(i,o,r);return this._unit=e.unit||(n.autoSkip?el(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):Zf(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit==="year"?void 0:Jf(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),nl(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let e=0,n=0,i,o;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?e=1-i:e=(this.getDecimalForValue(t[1])-i)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?n=o:n=(o-this.getDecimalForValue(t[t.length-2]))/2);let r=t.length<3?.5:.25;e=vt(e,0,r),n=vt(n,0,r),this._offsets={start:e,end:n,factor:1/(e+1+n)}}_generate(){let t=this._adapter,e=this.min,n=this.max,i=this.options,o=i.time,r=o.unit||el(o.minUnit,e,n,this._getLabelCapacity(e)),a=Z(i.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Ae(l)||l===!0,d={},h=e,u,f;if(c&&(h=+t.startOf(h,"isoWeek",l)),h=+t.startOf(h,c?"day":r),t.diff(n,e,r)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+r);let p=i.ticks.source==="data"&&this.getDataTimestamps();for(u=h,f=0;u+g)}getLabelForValue(t){let e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){let i=this.options.time.displayFormats,o=this._unit,r=e||i[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,n,i){let o=this.options,r=o.ticks.callback;if(r)return lt(r,[t,e,n],this);let a=o.time.displayFormats,l=this._unit,c=this._majorUnit,d=l&&a[l],h=c&&a[c],u=n[e],f=c&&h&&u&&u.major;return this._adapter.format(t,i||(f?h:d))}generateTickLabels(t){let e,n,i;for(e=0,n=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,n;if(t.length)return t;let i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(e=0,n=i.length;e=e&&c<=n&&i.push(c);if(i.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(r=0,a=i.length;ri-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;let e=this.getDataTimestamps(),n=this.getLabelTimestamps();return e.length&&n.length?t=this.normalize(e.concat(n)):t=e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return($n(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){let e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return $n(this._table,n*this._tableRange+this._minPos,!0)}};$(fs,"id","timeseries"),$(fs,"defaults",we.defaults);Vl=Object.freeze({__proto__:null,CategoryScale:ds,LinearScale:hs,LogarithmicScale:us,RadialLinearScale:Ce,TimeScale:we,TimeSeriesScale:fs}),ep=[rl,_l,Fl,Vl]});var ap={};Eo(ap,{CardView:()=>gs,default:()=>ti});module.exports=Jl(ap);var it=require("obsidian"),Ul=Xs(vs());var tc=["AT","BE","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IT","LV","LI","LT","LU","MT","NL","NO","PL","PT","SK","SI","ES","SE","CH"],ec=[{label:"\u{1F1EA}\u{1F1FA} Schengen 90/180 (example)",scope:{countries:tc},window:{type:"rolling",days:180},threshold:90,note:"Example rule \u2014 add your own in Settings \u2192 CSV Card View."}],oi={defaultMode:"kanban-genre",notesColumns:["notes","note","Notes","Note","description","Description","review","Review"],statusColumn:"status",categoryColumn:"category",notesSubfolder:"Notes",columnWidths:{},selectColumns:["Category","Type","Rating","Status","rating","type","category","status","Score /5"],fileConfigs:{},residencyRules:ec,showResidency:!0},Qs="xlsx-card-view";var ko=Xs(vs()),Mo=require("obsidian"),Zs=["Image","image","Cover","cover","Poster","poster","Thumbnail","thumbnail","Thumb","thumb","Photo","photo","Picture","picture","Img","img"];function Js(s,t,e){let n=(t!=null?t:"").trim();if(!n)return null;if(/^(https?:|data:)/i.test(n))return n;let i=n.match(/!?\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/);if(i)n=i[1].trim();else{let r=n.match(/!\[[^\]]*\]\(([^)]+)\)/);r&&(n=r[1].trim())}if(/^(https?:|data:)/i.test(n))return n;let o=s.metadataCache.getFirstLinkpathDest(n,e);return o instanceof Mo.TFile?s.vault.getResourcePath(o):null}var sc=15;function ys(s){return s>=1&&s<=sc}var nc=["0","1","true","false","yes","no",""];function tn(s){return s.length>0&&s.every(t=>nc.includes(t))}function xs(s){return s.replace(/[\\/:*?"<>|#^[\]]/g,"").replace(/\s+/g," ").trim().slice(0,100)}function Do(s){return s.toLowerCase().replace(/[^\p{L}\p{N}/_-]+/gu,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Gt(s){var i,o;if(!s||!s.trim())return{headers:[],rows:[]};let t=ko.default.parse(s,{header:!0,skipEmptyLines:!0}),e=((i=t.meta.fields)!=null?i:[]).map(String),n=((o=t.data)!=null?o:[]).map(r=>{let a={};return e.forEach(l=>{a[l]=r[l]!=null?String(r[l]):""}),a});return{headers:e,rows:n}}function We(s,t){if(!s)return s;let e=s.startsWith("./")||s.startsWith("../")||s==="."||s==="..";if(!e&&s.includes("/"))return s;if(!e)return t?`${t}/${s}`:s;let n=t?t.split("/").filter(Boolean):[];for(let i of s.split("/"))if(!(i===""||i===".")){if(i===".."){n.pop();continue}n.push(i)}return n.join("/")}function To(s,t,e){let n=e==="asc"?1:-1;return[...s].sort((i,o)=>{var u,f;let r=((u=i[t])!=null?u:"").trim(),a=((f=o[t])!=null?f:"").trim();if(!r&&!a)return 0;if(!r)return 1;if(!a)return-1;let l=parseFloat(r),c=parseFloat(a);return(!isNaN(l)&&!isNaN(c)&&/^-?[\d.]/.test(r)&&/^-?[\d.]/.test(a)?l-c:r.localeCompare(a,void 0,{numeric:!0,sensitivity:"base"}))*n})}function kt(s){return s.split(/[\s_-]+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}function Lo(s,t){let e=(s!=null?s:"").trim();if(!e||e.toLowerCase()==="unrated"||e==="\u2014"||e==="-")return"";if(/[★⭐☆]/.test(e))return e;if(/^\d+$/.test(e)){let o=parseInt(e,10);if(o>=1&&o<=5)return"\u2605".repeat(o)}let i=ic(e,t);return i&&i!==e&&i!=="\u2014"?i:""}function ic(s,t){var o;let e=t.toLowerCase();if(!["rating","score","score /5"].includes(e))return s;let n=s.toLowerCase().trim();return(o={excellent:"\u2605\u2605\u2605\u2605\u2605",great:"\u2605\u2605\u2605\u2605\u2605",good:"\u2605\u2605\u2605\u2605\u2606",fair:"\u2605\u2605\u2605\u2606\u2606",poor:"\u2605\u2605\u2606\u2606\u2606",bad:"\u2605\u2606\u2606\u2606\u2606",5:"\u2605\u2605\u2605\u2605\u2605",4:"\u2605\u2605\u2605\u2605\u2606",3:"\u2605\u2605\u2605\u2606\u2606",2:"\u2605\u2605\u2606\u2606\u2606",1:"\u2605\u2606\u2606\u2606\u2606",0:"\u2606\u2606\u2606\u2606\u2606",unrated:"\u2014","":"\u2014"}[n])!=null?o:s}function Ao(s,t){if(/^(year|released|decade)$/i.test((s!=null?s:"").trim()))return!0;let e=t.map(i=>(i!=null?i:"").trim()).filter(Boolean);return e.length<3?!1:e.filter(i=>/^(1[89]|20)\d{2}$/.test(i)).length/e.length>=.8}function Po(s){let t=(s!=null?s:"").match(/\b(1[89]\d{2}|20\d{2})\b/);return t?`${Math.floor(parseInt(t[1],10)/10)*10}s`:null}function Ro(s,t,e){var r;if(!t.length)return null;let n=Math.max(12,t.length/3),i=null,o=1/0;for(let a of s){if(e.has(a))continue;let l=new Set;for(let d of t)((r=d[a])!=null?r:"").split(",").forEach(h=>{let u=h.trim();u&&l.add(u)});if(l.size<2||l.size>n)continue;let c=Math.abs(Math.log(l.size/8));cE.remove());let r=document.body.createDiv({cls:"csv-select-picker"});r.style.position="fixed",r.style.zIndex="9999";let a=()=>{let E=s.getBoundingClientRect(),L=r.offsetHeight||280,k=E.bottom+4+L>window.innerHeight&&E.top-4-L>0;r.style.left=E.left+"px",r.style.top=k?E.top-4-L+"px":E.bottom+4+"px"};a();let l=E=>{!r.contains(E.target)&&E.target!==s&&d()},c=E=>{r.contains(E.target)||d()},d=()=>{r.remove(),document.removeEventListener("mousedown",l),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",d)},h=r.createEl("input",{cls:"csv-picker-search",type:"text",placeholder:"Search or add\u2026"});h.focus();let u=r.createDiv({cls:"csv-picker-list"}),f=!!(o!=null&&o.multi),p=E=>E.split(",").map(L=>L.trim()).filter(Boolean),g=new Set(f?p(t):[]),b=()=>n([...g].join(", ")),m=f?Array.from(new Set(e.flatMap(p))):Array.from(new Set(e.filter(Boolean))),x=[],_=0,w=()=>{u.querySelectorAll(".csv-picker-item").forEach((E,L)=>{E.toggleClass("csv-picker-item--hover",L===_),L===_&&E.scrollIntoView({block:"nearest"})})},S=E=>{if(!f){n(E.isClear?"":E.value),d();return}E.isClear?g.clear():(g.has(E.value)?g.delete(E.value):g.add(E.value),E.isAdd&&!m.includes(E.value)&&m.push(E.value)),b(),E.isAdd?(h.value="",C("")):C(h.value)},y=E=>f?g.has(E):E===t,v=()=>f?g.size>0:!!t,C=E=>{u.empty(),x=[];let L=E?m.filter(k=>k.toLowerCase().includes(E.toLowerCase())):m;if(v()){x.push({value:"",isClear:!0});let k=u.createDiv({cls:"csv-picker-item csv-picker-clear"});k.setText(f?"\u2715 Clear all":"\u2715 Clear"),k.addEventListener("mousedown",A=>{A.preventDefault(),S({value:"",isClear:!0})})}if(L.forEach(k=>{x.push({value:k});let A=u.createDiv({cls:`csv-picker-item ${y(k)?"active":""}`});A.setText(f?`${g.has(k)?"\u2713 ":""}${k}`:k),A.addEventListener("mousedown",P=>{P.preventDefault(),S({value:k})})}),E&&!m.some(k=>k.toLowerCase()===E.toLowerCase())){x.push({value:E,isAdd:!0});let k=u.createDiv({cls:"csv-picker-item csv-picker-add"});k.setText(`+ Add "${E}"`),k.addEventListener("mousedown",A=>{A.preventDefault(),S({value:E,isAdd:!0})})}!L.length&&!E&&u.createDiv({cls:"csv-picker-empty",text:"No options yet. Type to add."}),_=Math.min(_,Math.max(x.length-1,0)),w()};f&&r.createEl("button",{cls:"csv-picker-done",text:"Done"}).addEventListener("mousedown",E=>{E.preventDefault(),d()}),C(""),a(),h.addEventListener("input",()=>{_=0,C(h.value),a()});let M=typeof window!="undefined"&&((D=window.matchMedia)==null?void 0:D.call(window,"(pointer: coarse)").matches);setTimeout(()=>{document.addEventListener("mousedown",l),M||(window.addEventListener("scroll",c,!0),window.addEventListener("resize",d))},0),h.addEventListener("keydown",E=>{if(E.key==="Escape"){d();return}if(E.key==="ArrowDown"){E.preventDefault(),x.length&&(_=(_+1)%x.length,w());return}if(E.key==="ArrowUp"){E.preventDefault(),x.length&&(_=(_-1+x.length)%x.length,w());return}if(E.key==="Enter")if(E.preventDefault(),x[_])S(x[_]);else{let L=h.value.trim();L&&(n(L),d())}})}function Oo(s,t,e){return!s[t]||t===e||(s[e]||(s[e]=s[t]),delete s[t]),s}var Vt=require("obsidian");var oc={source:["confirmed","inferred","conflict"],resolved:["yes","no"]};function Fo(s){var t;return(t=oc[s.trim().toLowerCase()])!=null?t:null}function en(s){return/(^|[_\s-])(date|due|deadline)([_\s-]|$)/i.test(s.trim())}var Io=/^\d{4}-\d{2}-\d{2}$/;function on(s,t,e,n){let i=en(t)&&(e===""||Io.test(e)),o=s.createEl("input",{cls:n,type:i?"date":"text",value:e});i||(o.placeholder=t);let r=Fo(t);if(r){let a=`csv-dl-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${Math.random().toString(36).slice(2,7)}`,l=s.createEl("datalist");l.id=a,r.forEach(c=>l.createEl("option",{value:c})),o.setAttr("list",a)}return o}var je=class extends Vt.Modal{constructor(t,e,n,i,o,r,a={},l=()=>!1){super(t),this.headers=e,this.isNotesCol=n,this.isSelectCol=i,this.getColumnValues=o,this.onSubmit=r,this.optionPresets=a,this.isBooleanCol=l}onOpen(){let{contentEl:t}=this;t.empty(),t.addClass("csv-add-modal"),t.createEl("h2",{text:"Add new entry",cls:"csv-modal-title"});let e=t.createDiv({cls:"csv-modal-form"}),n={};this.headers.forEach(d=>n[d]="");let i=this.headers.find(d=>["title","name"].includes(d.toLowerCase())),o=new Map;i&&this.getColumnValues(i).forEach(d=>{let h=d.trim().toLowerCase();h&&!o.has(h)&&o.set(h,d.trim())}),this.headers.forEach(d=>{var b;let h=e.createDiv({cls:"csv-modal-row"});h.createEl("label",{text:kt(d),cls:"csv-modal-label"});let u=(b=this.optionPresets[d])!=null?b:[],f=d===i,p=!f&&!this.isSelectCol(d)&&!It(d)&&!en(d)&&ys(this.getColumnValues(d).length),g=!f&&!this.isNotesCol(d)&&(u.length>0||this.isSelectCol(d)&&!It(d)||p);if(this.isBooleanCol(d)){n[d]="0";let m=h.createDiv({cls:"csv-toggle"});m.createDiv({cls:"csv-toggle-knob"}),m.addEventListener("click",()=>{let x=!m.hasClass("is-on");m.toggleClass("is-on",x),n[d]=x?"1":"0"})}else if(this.isNotesCol(d)){let m=h.createEl("textarea",{cls:"csv-modal-textarea",placeholder:"Markdown supported\u2026"});m.addEventListener("input",()=>{n[d]=m.value})}else if(g){let m="__custom__",x=[];[...u,...this.getColumnValues(d)].forEach(S=>{let y=(S!=null?S:"").trim();y&&!x.some(v=>v.toLowerCase()===y.toLowerCase())&&x.push(y)});let _=h.createEl("select",{cls:"csv-modal-select"});_.createEl("option",{text:"\u2014",value:""}),x.forEach(S=>_.createEl("option",{text:S,value:S})),_.createEl("option",{text:"+ Custom\u2026",value:m});let w=h.createEl("input",{cls:"csv-modal-input csv-modal-custom",type:"text",placeholder:`Custom ${kt(d).toLowerCase()}`});w.hide(),w.addEventListener("input",()=>{n[d]=w.value}),w.addEventListener("keydown",S=>{S.key==="Enter"&&c()}),_.addEventListener("change",()=>{_.value===m?(w.show(),w.focus(),n[d]=w.value):(w.hide(),n[d]=_.value)})}else if(!f&&this.isSelectCol(d)){let x=h.createDiv({cls:"csv-modal-select-wrap"}).createDiv({cls:"csv-select-chip empty"});x.setText("\u2014 click to select \u2014"),x.addEventListener("click",_=>{_.stopPropagation(),Ot(x,n[d],this.getColumnValues(d),w=>{n[d]=w,x.setText(w||"\u2014 click to select \u2014"),x.toggleClass("empty",!w)},t,{multi:It(d)})})}else{let m=on(h,d,"","csv-modal-input");if(m.addEventListener("input",()=>{n[d]=m.value}),m.addEventListener("keydown",x=>{x.key==="Enter"&&c()}),d===i&&o.size){let x=h.createDiv({cls:"csv-modal-dup-hint"});x.hide(),m.addEventListener("input",()=>{let _=o.get(m.value.trim().toLowerCase());_?(x.setText(`\u26A0 \u201C${_}\u201D is already in this file`),x.show()):x.hide()})}}});let r=t.createDiv({cls:"csv-modal-btns"});r.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),r.createEl("button",{text:"Add entry",cls:"csv-modal-submit"}).addEventListener("click",()=>c());let c=()=>{if(!Object.values(n).some(h=>h.trim())){new Vt.Notice("Fill in at least one field.");return}this.onSubmit(n),this.close()}}onClose(){this.contentEl.empty()}},Ue=class extends Vt.Modal{constructor(e,n,i,o,r,a,l,c,d,h){super(e);this.vvHandler=null;this.row={...n},this.notesCol=i,this.headers=o,this.filePath=r,this.renderComponent=new Vt.Component,this.isNotesCol=a,this.isSelectCol=l,this.getColumnValues=c,this.onSave=d,this.onDelete=h,this.modalEl.addClass("csv-note-expander-modal")}onOpen(){var p,g,b,m,x;this.renderComponent.load();let{contentEl:e}=this;e.empty(),e.addClass("csv-note-expander");let n=window.visualViewport;if(n){let _=()=>{this.modalEl.style.setProperty("--csv-modal-vh",`${n.height}px`)};_(),n.addEventListener("resize",_),n.addEventListener("scroll",_),this.vvHandler=_}let i=e.createDiv({cls:"csv-expander-header"});i.createDiv({cls:"csv-expander-title",text:(g=this.row[(p=this.headers.find(_=>["title","name","Title","Name"].includes(_)))!=null?p:this.headers[0]])!=null?g:"\u2014"});let o=i.createDiv({cls:"csv-expander-header-btns"}),r=e.createDiv({cls:"csv-expander-fields"}),a=this.headers.find(_=>["title","name","Title","Name"].includes(_)),l=this.headers.find(_=>["author","Author","director","Director","artist","Artist","creator","Creator"].includes(_));this.headers.forEach(_=>{if(this.isNotesCol(_))return;let w=r.createDiv({cls:"csv-expander-field-row"});if(w.createDiv({cls:"csv-expander-field-label",text:kt(_)}),_!==a&&(this.isSelectCol(_)||!It(_)&&!en(_)&&ys(this.getColumnValues(_).length))){let y=w.createDiv({cls:`csv-select-chip ${this.row[_]?"":"empty"}`});y.setText(this.row[_]||"\u2014"),y.addEventListener("click",v=>{v.stopPropagation(),Ot(y,this.row[_],this.getColumnValues(_),C=>{this.row[_]=C,y.setText(C||"\u2014"),y.toggleClass("empty",!C)},e,{multi:It(_)})})}else{let y=w.createDiv({cls:"csv-expander-field-value",text:this.row[_]||"\u2014"});y.addEventListener("click",()=>{var M;y.empty();let v=on(y,_,(M=this.row[_])!=null?M:"","csv-inline-input");v.focus(),v.type==="text"&&v.select();let C=()=>{this.row[_]=v.value,y.empty(),y.setText(v.value||"\u2014")};v.addEventListener("blur",C),v.addEventListener("keydown",D=>{D.key==="Enter"&&v.blur(),D.key==="Escape"&&(y.empty(),y.setText(this.row[_]||"\u2014"))})})}});let c=!1,d=this.notesCol&&(b=this.row[this.notesCol])!=null?b:"",h=null;if(this.notesCol){e.createDiv({cls:"csv-expander-divider"}).createDiv({cls:"csv-expander-notes-label",text:this.notesCol});let w=e.createDiv({cls:"csv-expander-rendered markdown-rendered"});w.title="Click to edit";let S=e.createDiv({cls:"csv-expander-editor"});S.style.display="none";let y=()=>{w.empty(),d.trim()?Vt.MarkdownRenderer.render(this.app,d,w,this.filePath,this.renderComponent):w.createDiv({cls:"csv-notes-empty",text:"+ Add note"})};y(),h=S.createEl("textarea",{cls:"csv-expander-textarea"}),h.value=d,h.addEventListener("input",()=>{d=h.value});let v=()=>{c||(c=!0,w.style.display="none",S.style.display="flex",h.value=d,h.focus())},C=()=>{c&&(c=!1,S.style.display="none",w.style.display="",d=h.value,y())};w.addEventListener("click",M=>{if(M.target.closest("a, button, input, textarea, [contenteditable]"))return;let E=window.getSelection();E&&E.toString().length>0||v()}),h.addEventListener("keydown",M=>{M.key==="Escape"&&(M.preventDefault(),h.blur())}),h.addEventListener("blur",C)}let u=e.createDiv({cls:"csv-expander-footer"});if(this.onDelete){let _=String((x=this.row[(m=this.headers.find(w=>["title","name","Title","Name"].includes(w)))!=null?m:this.headers[0]])!=null?x:"").trim();u.createEl("button",{cls:"csv-expander-delete-btn",text:"Delete"}).addEventListener("click",()=>{let w=_||"this entry";window.confirm(`Delete "${w}"? This can't be undone.`)&&(this.onDelete(),this.close())})}let f=u.createDiv({cls:"csv-expander-footer-right"});f.createEl("button",{cls:"csv-modal-cancel",text:"Cancel"}).addEventListener("click",()=>this.close()),f.createEl("button",{cls:"csv-expander-save-btn",text:"Save & close"}).addEventListener("click",()=>{this.notesCol&&(c&&h&&(d=h.value),this.row[this.notesCol]=d),this.onSave(this.row),this.close()})}onClose(){let e=window.visualViewport;e&&this.vvHandler&&(e.removeEventListener("resize",this.vvHandler),e.removeEventListener("scroll",this.vvHandler)),this.vvHandler=null,this.renderComponent.unload(),this.contentEl.empty()}};var sn=class extends Vt.Modal{constructor(t,e,n,i,o,r,a,l,c,d,h){super(t),this.headers=e,this.filePath=n,this.current={...i,habitColumns:i.habitColumns?[...i.habitColumns]:void 0},this.autoDetectedHabits=o,this.availableModes=r,this.onSave=a,this.getHeaders=l,this.getFileCfg=c,this.onAddColumn=d,this.onRemoveColumn=h}onOpen(){var P,I,z;let{contentEl:t}=this;t.empty(),t.addClass("csv-add-modal"),t.createEl("h2",{text:"View settings for this file",cls:"csv-modal-title"}),t.createEl("p",{text:"These settings apply only to this file and override the global defaults.",cls:"csv-modal-desc"});let e=t.createDiv({cls:"csv-modal-form"}),n="\u2014 use global default \u2014",i=[n,...this.headers],o=()=>{this.headers=this.getHeaders();let F=this.getFileCfg();this.current={...F,habitColumns:F.habitColumns?[...F.habitColumns]:void 0},this.onOpen()},r=e.createDiv({cls:"csv-modal-row"});r.createEl("label",{text:"Columns",cls:"csv-modal-label"});let a=r.createDiv({cls:"csv-modal-column-list"});this.headers.forEach(F=>{let N=a.createDiv({cls:"csv-modal-column-chip"});N.createSpan({text:F});let H=N.createEl("button",{cls:"csv-modal-column-remove",text:"\u2715",attr:{title:`Remove "${F}" \u2014 deletes this column's data from every row`}});H.addEventListener("click",()=>{if(H.hasClass("confirm")){this.onRemoveColumn(F),o();return}a.querySelectorAll(".csv-modal-column-remove.confirm").forEach(T=>{T.removeClass("confirm"),T.setText("\u2715")}),H.addClass("confirm"),H.setText("Confirm?"),window.setTimeout(()=>{H.isConnected&&(H.removeClass("confirm"),H.setText("\u2715"))},3e3)})});let l=r.createDiv({cls:"csv-modal-add-column"}),c=l.createEl("input",{cls:"csv-modal-input",type:"text",placeholder:"New column name"}),d=l.createEl("button",{cls:"csv-modal-cancel",text:"+ Add column"}),h=()=>{let F=this.onAddColumn(c.value);if(F){new Vt.Notice(F);return}o()};d.addEventListener("click",h),c.addEventListener("keydown",F=>{F.key==="Enter"&&(F.preventDefault(),h())});let u=(F,N,H)=>{let T=e.createDiv({cls:"csv-modal-row"});T.createEl("label",{text:F,cls:"csv-modal-label"});let j=T.createEl("select",{cls:"csv-modal-select"});i.forEach(U=>{let G=j.createEl("option",{text:U,value:U});(N!=null?N:n)===U&&(G.selected=!0)}),j.addEventListener("change",()=>H(j.value===n?void 0:j.value))};u("Category column (kanban grouping)",this.current.categoryColumn,F=>{this.current.categoryColumn=F}),u("Status column (row subgroups)",this.current.statusColumn,F=>{this.current.statusColumn=F}),u("Notes column",this.current.notesColumn,F=>{this.current.notesColumn=F});let f=e.createDiv({cls:"csv-modal-row"});f.createEl("label",{text:"Habit columns (dashboard)",cls:"csv-modal-label"});let p=f.createEl("p",{cls:"csv-modal-hint",text:"Select columns to track as habits. Auto-detected columns with binary values (0/1) are pre-selected."}),g=f.createDiv({cls:"csv-modal-checkbox-grid"}),b=new Set((P=this.current.habitColumns)!=null?P:this.autoDetectedHabits);this.headers.forEach(F=>{let N=g.createEl("label",{cls:"csv-modal-checkbox-label"}),H=N.createEl("input",{type:"checkbox"});H.checked=b.has(F),this.autoDetectedHabits.includes(F)&&!this.current.habitColumns&&N.addClass("auto-detected"),N.createSpan({text:F}),H.addEventListener("change",()=>{this.current.habitColumns||(this.current.habitColumns=[...this.autoDetectedHabits]),H.checked?this.current.habitColumns.includes(F)||this.current.habitColumns.push(F):this.current.habitColumns=this.current.habitColumns.filter(T=>T!==F)})});let m=e.createDiv({cls:"csv-modal-row"});m.createEl("label",{text:"Card fields (Library / Kanban)",cls:"csv-modal-label"}),m.createEl("p",{cls:"csv-modal-hint",text:"Columns shown under each card title. Rating renders as stars, theme/tag columns as pills. Leave all unchecked for title-only cards."});let x=m.createDiv({cls:"csv-modal-checkbox-grid"}),_=F=>this.headers.find(N=>F.some(H=>H.toLowerCase()===N.toLowerCase())),w=[_(["Author","Authors","Director","Artist","Creator","By"]),_(["Year","Date","Released"]),_(["Rating","Score","Score /5","Stars"]),_(["Theme","Tags","Tag","Mood"])].filter(F=>!!F),S=new Set((I=this.current.cardFields)!=null?I:w),y=!!this.current.cardFields;this.headers.forEach(F=>{let N=x.createEl("label",{cls:"csv-modal-checkbox-label"}),H=N.createEl("input",{type:"checkbox"});H.checked=S.has(F),w.includes(F)&&!y&&N.addClass("auto-detected"),N.createSpan({text:F}),H.addEventListener("change",()=>{this.current.cardFields||(this.current.cardFields=[...w]),H.checked?this.current.cardFields.includes(F)||this.current.cardFields.push(F):this.current.cardFields=this.current.cardFields.filter(T=>T!==F)})});let v="\u2014 title / primary field \u2014",C=e.createDiv({cls:"csv-modal-row"});C.createEl("label",{text:"Anki card front",cls:"csv-modal-label"}),C.createEl("p",{cls:"csv-modal-hint",text:"Column used as the front of each card when syncing to Anki. Other columns become the back."});let M=C.createEl("select",{cls:"csv-modal-select"});[v,...this.headers].forEach(F=>{var H;let N=M.createEl("option",{text:F,value:F});((H=this.current.ankiFrontCol)!=null?H:v)===F&&(N.selected=!0)}),M.addEventListener("change",()=>{this.current.ankiFrontCol=M.value===v?void 0:M.value});let D=e.createDiv({cls:"csv-modal-row"});D.createEl("label",{text:"Default view",cls:"csv-modal-label"});let E=D.createEl("select",{cls:"csv-modal-select"}),L=[["\u2014 use global default \u2014",""],...this.availableModes.map(F=>[F.label,F.id])],k=(z=this.current.defaultMode)!=null?z:"";k&&!this.availableModes.some(F=>F.id===k)&&L.push([`${k} (no longer available)`,k]),L.forEach(([F,N])=>{let H=E.createEl("option",{text:F,value:N});k===N&&(H.selected=!0)}),E.addEventListener("change",()=>{this.current.defaultMode=E.value?E.value:void 0});let A=t.createDiv({cls:"csv-modal-btns"});A.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),A.createEl("button",{text:"Save",cls:"csv-modal-submit"}).addEventListener("click",()=>{this.onSave(this.current),this.close()})}onClose(){this.contentEl.empty()}},nn=class extends Vt.Modal{constructor(e,n,i,o,r){super(e);this.title=n;this.initial=i;this.placeholder=o;this.onSubmit=r}onOpen(){let{contentEl:e}=this;e.empty(),e.addClass("csv-add-modal"),e.createEl("h2",{text:this.title,cls:"csv-modal-title"});let n=e.createEl("input",{cls:"csv-modal-field",type:"text"});n.value=this.initial,n.placeholder=this.placeholder,window.setTimeout(()=>{n.focus(),n.select()},0);let i=()=>{let r=n.value.trim();r&&(this.onSubmit(r),this.close())};n.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),i())});let o=e.createDiv({cls:"csv-modal-btns"});o.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),o.createEl("button",{text:"Create",cls:"csv-modal-submit"}).addEventListener("click",i)}onClose(){this.contentEl.empty()}};var ri=195,rc={AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AD:"Andorra",AO:"Angola",AR:"Argentina",AM:"Armenia",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BD:"Bangladesh",BY:"Belarus",BE:"Belgium",BO:"Bolivia",BA:"Bosnia",BW:"Botswana",BR:"Brazil",BG:"Bulgaria",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CL:"Chile",CN:"China",CO:"Colombia",HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:"Czechia",DK:"Denmark",DO:"Dominican Rep.",EC:"Ecuador",EG:"Egypt",ET:"Ethiopia",FI:"Finland",FR:"France",GE:"Georgia",DE:"Germany",GH:"Ghana",GR:"Greece",GT:"Guatemala",GY:"Guyana",HT:"Haiti",HN:"Honduras",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran",IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KP:"N. Korea",KR:"S. Korea",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Laos",LV:"Latvia",LB:"Lebanon",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MY:"Malaysia",ML:"Mali",MT:"Malta",MR:"Mauritania",MX:"Mexico",MD:"Moldova",MN:"Mongolia",ME:"Montenegro",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NP:"Nepal",NL:"Netherlands",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NO:"Norway",OM:"Oman",PK:"Pakistan",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PL:"Poland",PT:"Portugal",QA:"Qatar",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SO:"Somalia",ZA:"South Africa",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SE:"Sweden",CH:"Switzerland",SY:"Syria",TJ:"Tajikistan",TZ:"Tanzania",TH:"Thailand",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",UG:"Uganda",UA:"Ukraine",AE:"UAE",GB:"United Kingdom",US:"United States",UY:"Uruguay",UZ:"Uzbekistan",VN:"Vietnam",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",MC:"Monaco",BZ:"Belize"},ac={AF:["DZ","AO","BJ","BW","BF","BI","CM","CV","CF","TD","KM","CD","CG","CI","DJ","EG","GQ","ER","ET","GA","GM","GH","GN","GW","KE","LS","LR","LY","MG","MW","ML","MR","MU","MA","MZ","NA","NE","NG","RE","RW","ST","SN","SC","SL","SO","ZA","SS","SD","TZ","TG","TN","UG","ZM","ZW"],AN:["AQ"],AS:["AF","AM","AZ","BH","BD","BT","BN","KH","CN","CY","GE","IN","ID","IR","IQ","IL","JP","JO","KZ","KW","KG","LA","LB","MY","MV","MN","MM","NP","KP","OM","PK","PS","PH","QA","RU","SA","SG","KR","LK","SY","TW","TJ","TH","TL","TR","TM","AE","UZ","VN","YE"],EU:["AL","AD","AT","BY","BE","BA","BG","HR","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IE","IT","XK","LV","LI","LT","LU","MT","MD","MC","ME","NL","MK","NO","PL","PT","RO","RU","SM","RS","SK","SI","ES","SE","CH","UA","GB","VA"],NA:["AG","BS","BB","BZ","CA","CR","CU","DM","DO","SV","GD","GT","HT","HN","JM","MX","NI","PA","KN","LC","VC","TT","US"],OC:["AU","FJ","KI","MH","FM","NR","NZ","PW","PG","WS","SB","TO","TV","VU"],SA:["AR","BO","BR","CL","CO","EC","GY","PY","PE","SR","UY","VE"]},Vo={AF:"Africa",AN:"Antarctica",AS:"Asia",EU:"Europe",NA:"N. America",OC:"Oceania",SA:"S. America"},No={};for(let[s,t]of Object.entries(ac))for(let e of t)No[e]=s;function Et(s){return rc[s]||s}function $t(s){return!s||s.length!==2?"":String.fromCodePoint(...s.toUpperCase().split("").map(t=>t.charCodeAt(0)+127397))}function Nt(s){if(!s||s.indexOf("?")!==-1)return null;let t=new Date(s+"T12:00:00Z");return isNaN(t.getTime())?null:t}function _s(s){let t=Nt(s.date_entered),e=Nt(s.date_left);return!t||!e?0:Math.max(Math.round((e.getTime()-t.getTime())/864e5),1)}function Bo(s,t=new Date){let e=t.getTime(),n=null,i=-1/0;for(let o of s){let r=Nt(o.date_entered);if(!(!r||r.getTime()>e)){if(o.date_left.trim()!==""){let a=Nt(o.date_left);if(!a||a.getTime()i&&(n=o,i=r.getTime())}}return n}function zo(s){let t=m=>{var x,_,w,S,y,v,C,M;return{date_entered:(x=m.date_entered)!=null?x:"",date_left:(_=m.date_left)!=null?_:"",country:((w=m.country)!=null?w:"").trim().toUpperCase(),city:(S=m.city)!=null?S:"",visa_status:(y=m.visa_status)!=null?y:"",notes:(v=m.notes)!=null?v:"",source:((C=m.source)!=null?C:"").trim().toLowerCase(),resolved:(M=m.resolved)!=null?M:"",_src:m}},e=s.map(t).filter(m=>m.country),n=e.filter(m=>m.source==="confirmed"),i=e.filter(m=>m.source==="inferred"),o=e.filter(m=>m.source==="conflict"),r=[];for(let m of n){let x=Nt(m.date_entered),_=Nt(m.date_left);x&&_&&r.push([x.getTime(),_.getTime()])}let a=m=>{let x=Nt(m.date_entered),_=Nt(m.date_left);if(!x||!_)return!1;let w=x.getTime(),S=_.getTime();return r.some(([y,v])=>w<=v&&S>=y)},l=i.filter(m=>Nt(m.date_entered)&&Nt(m.date_left)&&!a(m)),c=new Set(n.map(m=>m.country)),d=new Set(i.map(m=>m.country)),h=new Set([...d].filter(m=>!c.has(m))),u=new Set([...c,...d]),f=new Map;for(let m of n)f.set(m.country,(f.get(m.country)||0)+_s(m));let p=[...f.entries()].map(([m,x])=>({iso:m,days:x})).sort((m,x)=>x.days-m.days||Et(m.iso).localeCompare(Et(x.iso))),g=p.reduce((m,x)=>m+x.days,0),b=new Set;for(let m of c){let x=No[m];x&&b.add(x)}return{confirmed:n,inferred:i,conflicts:o,inferredVisible:l,confRanges:r,confirmedCountries:c,inferredOnlyCountries:h,allCountries:u,countryDays:p,totalConfirmedDays:g,visitedContinents:b,worldPct:Math.round(c.size/ri*100)}}var ai=864e5;function Ho(s){if(!s||s.indexOf("?")!==-1)return null;let t=Date.parse(s+"T00:00:00Z");return isNaN(t)?null:t}function lc(s,t,e,n){let i=Math.max(s,e),o=Math.min(t,n);return o<=i?0:Math.round((o-i)/ai)}function cc(s,t){var i;let e=s.window;if(e.type==="all-time")return{start:-1/0,end:1/0,label:"all time"};if(e.type==="calendar-year"){let o=new Date(t).getUTCFullYear();return{start:Date.UTC(o,0,1),end:Date.UTC(o+1,0,1),label:`in ${o}`}}let n=(i=e.days)!=null?i:180;return{start:t-n*ai,end:t+ai,label:`in last ${n} days`}}function $o(s,t,e=Date.now()){var d,h,u;let n=(d=s.scope.countries)!=null?d:s.scope.country?[s.scope.country]:[],i=new Set(n.map(f=>f.toUpperCase())),o=new Set(((u=(h=s.exempt)==null?void 0:h.visa_status)!=null?u:[]).map(f=>f.toLowerCase().trim())),r=cc(s,e),a=0;for(let f of t){if(!i.has((f.country||"").toUpperCase())||o.has((f.visa_status||"").toLowerCase().trim()))continue;let p=Ho(f.date_entered),g=Ho(f.date_left);p===null||g===null||(a+=lc(p,g,r.start,r.end))}let l=s.threshold-a,c=a>=s.threshold?"over":a/s.threshold>=.8?"warn":"ok";return{rule:s,used:a,threshold:s.threshold,remaining:l,windowLabel:r.label,status:c}}var Wo=["#c9a96e","#4a6fa5","#5ba06e","#a05b8a","#6ea0a0","#a0855b","#7a6ea0","#a06e6e","#6e8fa0","#a09e5b"],dc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function hc(){let s=new Map,t=0;return e=>(s.has(e)||s.set(e,Wo[t++%Wo.length]),s.get(e))}function uc(s){let t=document.body.createDiv({cls:"csv-tv-tooltip"}),e=null,n=(r,a)=>{let c=r+14,d=a+16,h=t.offsetWidth,u=t.offsetHeight;c+h+8>window.innerWidth&&(c=r-h-14),d+u+8>window.innerHeight&&(d=a-u-16),t.style.left=`${Math.max(8,c)}px`,t.style.top=`${Math.max(8,d)}px`},i=r=>{var c,d;let a=(d=(c=r.target)==null?void 0:c.closest("[data-tip]"))!=null?d:null,l=(a==null?void 0:a.getAttribute("data-tip"))||"";if(!a||!l){e&&(e=null,t.removeClass("is-on"));return}a!==e&&(e=a,t.setText(l),t.addClass("is-on")),n(r.clientX,r.clientY)},o=()=>{e=null,t.removeClass("is-on")};return s.addEventListener("pointermove",i),s.addEventListener("pointerleave",o),()=>{s.removeEventListener("pointermove",i),s.removeEventListener("pointerleave",o),t.remove()}}function li(s){let t=_s(s);return t?`${t}d`:"\u2014"}function Ke(s){return s||"\u2014"}function Ss(s){return s.createDiv({cls:"csv-tv-table-wrap"}).createEl("table",{cls:"csv-tv-table"})}function Cs(s,t,e,n){s.addClass("csv-tv-editable"),s.title="Click to edit";let i=()=>{s.empty(),s.setText(t[e]?t[e]:"\u2014")};i(),s.addEventListener("click",()=>{var r;if(s.querySelector("input"))return;s.empty();let o=on(s,e,(r=t[e])!=null?r:"","csv-inline-input");o.focus(),o.type==="text"&&o.select(),o.addEventListener("blur",()=>{t[e]=o.value,n(),i()}),o.addEventListener("keydown",a=>{var l;a.key==="Enter"&&o.blur(),a.key==="Escape"&&(o.value=(l=t[e])!=null?l:"",o.blur())})})}async function jo(s,t,e,n=()=>{},i=null,o=()=>{}){let r=zo(t),a=s.createDiv({cls:"csv-tv"});if(!r.confirmed.length&&!r.inferred.length){a.createDiv({cls:"csv-empty-state",text:"No travel rows found. Expected columns: country, date_entered, date_left, source."});return}o(uc(a));let l=null,c=()=>{a.querySelectorAll(".country-path").forEach(f=>{let p=(f.getAttribute("data-iso")||"").toUpperCase();f.classList.toggle("cp-selected",!!l&&p===l)}),a.querySelectorAll(".csv-tv-seg").forEach(f=>{f.classList.toggle("is-dim",!!l&&f.getAttribute("data-iso")!==l)}),a.querySelectorAll("tr[data-iso]").forEach(f=>{f.classList.toggle("is-selected",!!l&&f.getAttribute("data-iso")===l)}),u.empty(),l&&(gc(u,r,l,()=>d(null)),u.scrollIntoView({behavior:"smooth",block:"nearest"}))},d=f=>{l=f&&f!==l?f:null,c()};fc(a,r);let h=a.createDiv({cls:"csv-tv-mapwrap"});h.createDiv({cls:"csv-tv-map-loading",text:"Loading map\u2026"});let u=a.createDiv({cls:"csv-tv-detailwrap"});i&&i.length&&mc(a,r.confirmed,i),bc(a,r,d),vc(a,r,d),yc(a,r,n);try{let f=await e();h.empty(),f?pc(h,f,r,d):h.createDiv({cls:"csv-tv-map-loading",text:"World map asset not found (world-map.svg)."})}catch(f){h.empty(),h.createDiv({cls:"csv-tv-map-loading",text:"Couldn't load world map."})}}function fc(s,t){let e=s.createDiv({cls:"csv-tv-stats"}),n=(c,d,h="")=>{let u=e.createDiv({cls:"csv-tv-stat"});u.createDiv({cls:"csv-tv-stat-label",text:c}),u.createDiv({cls:"csv-tv-stat-value",text:d}),h&&u.createDiv({cls:"csv-tv-stat-sub",text:h})},i=Math.round(t.allCountries.size/ri*100);n("Countries",String(t.confirmedCountries.size),`${t.worldPct}% of world`),n("Incl. photos",String(t.allCountries.size),`${i}% of world`),n("Continents",`${t.visitedContinents.size} / 7`,[...t.visitedContinents].map(c=>Vo[c]||c).sort().join(", ")),n("Confirmed trips",String(t.confirmed.length)),n("Confirmed days",String(t.totalConfirmedDays));let o=new Set(t.confirmed.map(c=>c.city.trim().toLowerCase()).filter(Boolean));o.size&&n("Cities",String(o.size));let r=null,a=0;for(let c of t.confirmed){let d=_s(c);d>a&&(a=d,r=c)}if(r){let c=r.date_entered.slice(0,4);n("Longest trip",`${a}d`,`${$t(r.country)} ${Et(r.country)}${c?` \xB7 ${c}`:""}`)}let l=Bo(t.confirmed);if(l){let c=Nt(l.date_entered),d=Math.max(1,Math.round((Date.now()-c.getTime())/864e5)+1),h=s.createDiv({cls:"csv-tv-now"});h.createSpan({cls:"csv-tv-now-loc",text:`\u{1F4CD} Currently in ${$t(l.country)} ${Et(l.country)}`}),h.createSpan({cls:"csv-tv-now-sub",text:` \u2014 since ${l.date_entered} (day ${d})${l.city?` \xB7 ${l.city}`:""}`})}}function pc(s,t,e,n){let i=s.createDiv({cls:"csv-tv-map"});i.innerHTML=t,i.querySelectorAll(".country-path").forEach(r=>{let a=(r.getAttribute("data-iso")||"").toUpperCase();if(r.classList.remove("cp-unvisited","cp-confirmed","cp-inferred"),a&&e.confirmedCountries.has(a)){r.classList.add("cp-confirmed");let l=e.countryDays.find(c=>c.iso===a);r.setAttr("aria-label",`${Et(a)} \u2014 ${l&&l.days?l.days+"d confirmed":"confirmed"}`),r.setAttr("data-tip",`${Et(a)}${l&&l.days?" \xB7 "+l.days+"d":""} \xB7 click for trips`)}else a&&e.inferredOnlyCountries.has(a)?(r.classList.add("cp-inferred"),r.setAttr("aria-label",`${Et(a)} \u2014 photo evidence`),r.setAttr("data-tip",`${Et(a)} \xB7 photo evidence \xB7 click for trips`)):a?(r.classList.add("cp-unvisited"),r.setAttr("data-tip",Et(a))):r.classList.add("cp-unvisited");a&&r.addEventListener("click",()=>{e.allCountries.has(a)?n(a):n(null)})}),i.querySelectorAll(".country-path").forEach(r=>{try{let a=r.getBoundingClientRect();a.width&&a.height&&Math.max(a.width,a.height)<12&&r.classList.add("cp-tiny")}catch(a){}});let o=s.createDiv({cls:"csv-tv-map-legend"});o.createSpan({cls:"csv-tv-leg"}).innerHTML=' Confirmed',o.createSpan({cls:"csv-tv-leg"}).innerHTML=' Photo evidence'}function gc(s,t,e,n){var b,m;let i=s.createDiv({cls:"csv-tv-detail"}),o=i.createDiv({cls:"csv-tv-detail-head"});o.createSpan({cls:"csv-tv-detail-flag",text:$t(e)});let r=o.createDiv({cls:"csv-tv-detail-titles"});r.createDiv({cls:"csv-tv-detail-name",text:Et(e)});let a=t.confirmed.filter(x=>x.country===e),l=t.inferred.filter(x=>x.country===e),c=(m=(b=t.countryDays.find(x=>x.iso===e))==null?void 0:b.days)!=null?m:0,d=new Set([...a,...l].map(x=>x.city.trim()).filter(Boolean)),h=[];a.length&&h.push(`${a.length} confirmed trip${a.length===1?"":"s"}`),c&&h.push(`${c}d total`),l.length&&h.push(`${l.length} photo-inferred`),d.size&&h.push(`${d.size} cit${d.size===1?"y":"ies"}`),r.createDiv({cls:"csv-tv-detail-sub",text:h.join(" \xB7 ")}),o.createEl("button",{cls:"csv-tv-detail-close",text:"\u2715",title:"Close"}).addEventListener("click",n);let u=rn([...a.map(x=>({r:x,inf:!1,date_entered:x.date_entered})),...l.map(x=>({r:x,inf:!0,date_entered:x.date_entered}))]);if(!u.length)return;let f=Ss(i),p=f.createEl("thead").createEl("tr");["","Entered","Left","Days","City","Visa"].forEach(x=>p.createEl("th",{text:x}));let g=f.createEl("tbody");for(let{r:x,inf:_}of u){let w=g.createEl("tr");w.createEl("td",{text:_?"\u{1F4F7}":"",cls:"csv-tv-flag",attr:_?{"data-tip":"Photo-inferred"}:{}}),w.createEl("td",{text:Ke(x.date_entered)}),w.createEl("td",{text:Ke(x.date_left)}),w.createEl("td",{text:li(x)}),w.createEl("td",{text:x.city}),w.createEl("td",{text:x.visa_status})}}function mc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Residency counters"});let n=s.createDiv({cls:"csv-tv-res-grid"});for(let i of e){let o=$o(i,t),r=n.createDiv({cls:`csv-tv-res-card csv-tv-res-${o.status}`});r.createDiv({cls:"csv-tv-res-label",text:i.label});let a=r.createDiv({cls:"csv-tv-res-nums"});a.createSpan({cls:"csv-tv-res-used",text:String(o.used)}),a.createSpan({cls:"csv-tv-res-thresh",text:` / ${o.threshold}`}),a.createSpan({cls:"csv-tv-res-window",text:` ${o.windowLabel}`});let l=r.createDiv({cls:"csv-tv-res-bar"});l.createDiv({cls:"csv-tv-res-fill"}).style.width=`${Math.min(100,Math.round(o.used/o.threshold*100))}%`;let c=o.status==="over"?i.onExceed?`Over \u2014 ${i.onExceed}`:"Limit reached":`${o.remaining} day${o.remaining===1?"":"s"} left`;r.createDiv({cls:"csv-tv-res-status",text:c}),i.note&&r.createDiv({cls:"csv-tv-res-note",text:i.note})}s.createDiv({cls:"csv-tv-res-disclaimer",text:"Indicators only \u2014 not legal or tax advice. Based on confirmed trips."})}function bc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Countries visited"});let n=Ss(s),i=n.createEl("thead").createEl("tr");["","Country","Total days"].forEach(r=>i.createEl("th",{text:r}));let o=n.createEl("tbody");for(let{iso:r,days:a}of t.countryDays){let l=o.createEl("tr",{cls:"csv-tv-row-click",attr:{"data-iso":r}});l.createEl("td",{text:$t(r),cls:"csv-tv-flag"}),l.createEl("td",{text:Et(r)}),l.createEl("td",{text:a?`${a}d`:"\u2014"}),l.addEventListener("click",()=>e(r))}if(t.inferredOnlyCountries.size){let r=s.createDiv({cls:"csv-tv-photo-only"});r.createSpan({text:"\u{1F4F7} Photo evidence only: "}),r.createSpan({text:[...t.inferredOnlyCountries].sort().map($t).join(" ")})}}function vc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Timeline"});let n=hc(),i=[...t.confirmed.map(c=>({...c,_inf:!1})),...t.inferredVisible.map(c=>({...c,_inf:!0}))].filter(c=>c.date_entered&&c.date_left&&c.date_entered.indexOf("?")===-1),o=new Map;for(let c of i){let d=parseInt(c.date_entered.slice(0,4)),h=parseInt(c.date_left.slice(0,4));if(!(isNaN(d)||isNaN(h)))for(let u=d;u<=h;u++)o.has(u)||o.set(u,[]),o.get(u).push(c)}let r=[...o.keys()].sort((c,d)=>d-c),a=s.createDiv({cls:"csv-tv-timeline"});for(let c of r){let d=new Date(`${c}-01-01T12:00:00Z`).getTime(),h=new Date(`${c}-12-31T12:00:00Z`).getTime(),u=h-d,f=a.createDiv({cls:"csv-tv-tl-year"}),p=0,g=new Set;for(let _ of o.get(c)){if(g.add(_.country),_._inf)continue;let w=Math.max(new Date(_.date_entered+"T12:00:00Z").getTime(),d),S=Math.min(new Date(_.date_left+"T12:00:00Z").getTime(),h);w<=S&&(p+=Math.max(Math.round((S-w)/864e5)+1,1))}let b=f.createDiv({cls:"csv-tv-tl-label"});b.createSpan({text:String(c)}),b.createSpan({cls:"csv-tv-tl-sub",text:`${p?`${p}d \xB7 `:""}${g.size} ${g.size===1?"country":"countries"}`});let m=f.createDiv({cls:"csv-tv-month-row"});dc.forEach(_=>m.createDiv({cls:"csv-tv-month-tick",text:_}));let x=f.createDiv({cls:"csv-tv-track"});for(let _ of o.get(c)){let w=Math.max(new Date(_.date_entered+"T12:00:00Z").getTime(),d),S=Math.min(new Date(_.date_left+"T12:00:00Z").getTime(),h);if(w>S)continue;let y=(w-d)/u*100,v=Math.max((S-w+864e5)/u*100,.5),C=n(_.country),M=x.createDiv({cls:`csv-tv-seg${_._inf?" csv-tv-seg-inf":""}`});M.style.left=`${y}%`,M.style.width=`${v}%`,_._inf?(M.style.borderColor=C,M.style.background=C+"22",M.style.color=C):M.style.background=C,M.setAttr("data-iso",_.country),M.setAttr("data-tip",`${Et(_.country)} ${_.date_entered} \u2192 ${_.date_left} (${_s(_)}d)${_.visa_status?" ["+_.visa_status+"]":""}${_._inf?" [photo]":""}`),M.addEventListener("click",()=>e(_.country)),v>4?M.createSpan({cls:"csv-tv-seg-lbl",text:`${$t(_.country)} ${_.country}`}):v>2&&M.createSpan({cls:"csv-tv-seg-lbl",text:$t(_.country)})}}a.createDiv({cls:"csv-tv-tl-legend"}).setText("Confirmed (solid) \xB7 Photo inferred (outlined)")}function rn(s){return[...s].sort((t,e)=>!t.date_entered&&!e.date_entered?0:t.date_entered?e.date_entered?e.date_entered.localeCompare(t.date_entered):-1:1)}function yc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Confirmed trips"}),s.createDiv({cls:"csv-tv-edit-hint",text:"Dates, city, visa and notes are editable \u2014 click a cell. Edit country in Table view."});let n=Ss(s),i=n.createEl("thead").createEl("tr");["","Country","Entered","Left","Duration","City","Visa","Notes"].forEach(r=>i.createEl("th",{text:r}));let o=n.createEl("tbody");for(let r of rn(t.confirmed)){let a=o.createEl("tr");a.createEl("td",{text:$t(r.country),cls:"csv-tv-flag"}),a.createEl("td",{text:Et(r.country)}),Cs(a.createEl("td"),r._src,"date_entered",e),Cs(a.createEl("td"),r._src,"date_left",e),a.createEl("td",{text:li(r)}),Cs(a.createEl("td"),r._src,"city",e),Cs(a.createEl("td"),r._src,"visa_status",e),Cs(a.createEl("td"),r._src,"notes",e)}if(t.inferred.length){let r=s.createEl("details",{cls:"csv-tv-details"});r.createEl("summary",{text:`\u{1F4F7} Photo inferred trips (${t.inferred.length})`});let a=Ss(r),l=a.createEl("thead").createEl("tr");["","Country","Entered","Left","Days","City"].forEach(d=>l.createEl("th",{text:d}));let c=a.createEl("tbody");for(let d of rn(t.inferred)){let h=c.createEl("tr");h.createEl("td",{text:$t(d.country),cls:"csv-tv-flag"}),h.createEl("td",{text:Et(d.country)}),h.createEl("td",{text:Ke(d.date_entered)}),h.createEl("td",{text:Ke(d.date_left)}),h.createEl("td",{text:li(d)}),h.createEl("td",{text:d.city})}}if(t.conflicts.length){let r=s.createEl("details",{cls:"csv-tv-details csv-tv-details-warn"});r.createEl("summary",{text:`\u26A0 ${t.conflicts.length} conflict(s) \u2014 photo evidence contradicts a confirmed entry`});let a=Ss(r),l=a.createEl("thead").createEl("tr");["","Country (photos)","Dates","Detail"].forEach(d=>l.createEl("th",{text:d}));let c=a.createEl("tbody");for(let d of rn(t.conflicts)){let h=c.createEl("tr");h.createEl("td",{text:$t(d.country),cls:"csv-tv-flag"}),h.createEl("td",{text:d.country}),h.createEl("td",{text:`${Ke(d.date_entered)} \u2192 ${Ke(d.date_left)}`}),h.createEl("td",{text:d.notes})}}}var Ft=require("obsidian"),an=class extends Ft.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e}display(){let{containerEl:t}=this;t.empty(),t.createEl("h2",{text:"XLSX Card View"}),new Ft.Setting(t).setName("Default view mode").addDropdown(n=>n.addOption("kanban-genre","Kanban").addOption("table","Table").setValue(this.plugin.settings.defaultMode).onChange(async i=>{this.plugin.settings.defaultMode=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Status column name").addText(n=>n.setValue(this.plugin.settings.statusColumn).onChange(async i=>{this.plugin.settings.statusColumn=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Category/Genre column name").addText(n=>n.setValue(this.plugin.settings.categoryColumn).onChange(async i=>{this.plugin.settings.categoryColumn=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Notes column names").setDesc("Comma-separated.").addText(n=>n.setValue(this.plugin.settings.notesColumns.join(", ")).onChange(async i=>{this.plugin.settings.notesColumns=i.split(",").map(o=>o.trim()),await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Select/dropdown columns").setDesc("Comma-separated column names that use a dropdown picker.").addText(n=>n.setValue(this.plugin.settings.selectColumns.join(", ")).onChange(async i=>{this.plugin.settings.selectColumns=i.split(",").map(o=>o.trim()),await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Notes subfolder").addText(n=>n.setPlaceholder("Notes").setValue(this.plugin.settings.notesSubfolder).onChange(async i=>{this.plugin.settings.notesSubfolder=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Reset column widths").addButton(n=>n.setButtonText("Reset").onClick(async()=>{this.plugin.settings.columnWidths={},await this.plugin.saveSettings(),new Ft.Notice("Column widths reset.")})),new Ft.Setting(t).setName("Residency counters (travel view)").setDesc("Show residency / tax day-gauges in the travel view.").addToggle(n=>n.setValue(this.plugin.settings.showResidency!==!1).onChange(async i=>{this.plugin.settings.showResidency=i,await this.plugin.saveSettings()})),t.createEl("h3",{text:"Residency rules"}),t.createEl("p",{cls:"setting-item-description",text:"Each rule counts days in the listed countries within the window, minus exempt visa rows, against the threshold. Counts confirmed trips only. Indicators, not legal/tax advice."});let e=t.createDiv({cls:"csv-rr-wrap"});this.renderResidencyRules(e)}renderResidencyRules(t){var o;t.empty();let e=(o=this.plugin.settings.residencyRules)!=null?o:this.plugin.settings.residencyRules=[],n=()=>void this.plugin.saveSettings();e.forEach((r,a)=>{var m,x,_,w,S,y;let l=t.createDiv({cls:"csv-rr-card"}),c=l.createDiv({cls:"csv-rr-head"}),d=c.createEl("input",{cls:"csv-rr-label",type:"text",value:r.label});d.placeholder="Label (e.g. \u{1F1EA}\u{1F1FA} Schengen 90/180)",d.addEventListener("input",()=>{r.label=d.value,n()});let h=c.createEl("button",{cls:"csv-rr-del",text:"\u2715"});h.setAttr("aria-label","Remove rule"),h.addEventListener("click",async()=>{e.splice(a,1),await this.plugin.saveSettings(),this.renderResidencyRules(t)});let u=l.createDiv({cls:"csv-rr-grid"}),f=(v,C,M,D="")=>{let E=u.createDiv({cls:"csv-rr-field"});E.createEl("label",{text:v});let L=E.createEl("input",{type:"text",value:C});D&&(L.placeholder=D),L.addEventListener("input",()=>{M(L.value),n()})},p=(m=r.scope.countries)!=null?m:r.scope.country?[r.scope.country]:[];f("Countries (ISO-2, comma)",p.join(", "),v=>{r.scope={countries:v.split(",").map(C=>C.trim().toUpperCase()).filter(Boolean)}},"US, GB");let g=u.createDiv({cls:"csv-rr-field"});g.createEl("label",{text:"Window"});let b=g.createEl("select");[["calendar-year","Calendar year"],["rolling","Rolling N days"],["all-time","All time"]].forEach(([v,C])=>{let M=b.createEl("option",{text:C,value:v});r.window.type===v&&(M.selected=!0)}),b.addEventListener("change",()=>{r.window={type:b.value,days:r.window.days},n(),this.renderResidencyRules(t)}),r.window.type==="rolling"&&f("Rolling days",String((x=r.window.days)!=null?x:180),v=>{let C=parseInt(v,10);r.window.days=isNaN(C)?void 0:C},"180"),f("Threshold (days)",String(r.threshold),v=>{let C=parseInt(v,10);r.threshold=isNaN(C)?0:C},"183"),f("Exempt visas (comma)",((w=(_=r.exempt)==null?void 0:_.visa_status)!=null?w:[]).join(", "),v=>{let C=v.split(",").map(M=>M.trim()).filter(Boolean);r.exempt=C.length?{visa_status:C}:void 0},"F-1, J-1"),f("On-exceed label",(S=r.onExceed)!=null?S:"",v=>{r.onExceed=v||void 0},"tax resident"),f("Note",(y=r.note)!=null?y:"",v=>{r.note=v||void 0},"optional caveat")}),t.createDiv({cls:"csv-rr-btns"}).createEl("button",{cls:"csv-rr-add",text:"+ Add rule"}).addEventListener("click",async()=>{e.push({label:"New rule",scope:{countries:[]},window:{type:"calendar-year"},threshold:183}),await this.plugin.saveSettings(),this.renderResidencyRules(t)})}};var de=require("obsidian"),Uo=Xs(vs());async function Ko(s,t,e,n){var N,H;let i=t.split(` +`).map(T=>T.trim()).filter(Boolean),o="";for(let T of i)if(T.startsWith("file:")){o=T.replace("file:","").trim();break}if(!o){e.createEl("p",{text:"Error: No file specified. Use: file: yourfile.csv",cls:"csv-add-error"});return}let r=s.vault.getAbstractFileByPath(n.sourcePath),a=(H=(N=r==null?void 0:r.parent)==null?void 0:N.path)!=null?H:"",l=We(o,a),c=s.vault.getAbstractFileByPath(l);if(!c||!(c instanceof de.TFile)){e.createEl("p",{text:`Error: File not found: ${l}`,cls:"csv-add-error"});return}let d=[],h=[];try{let T=await s.vault.read(c),j=Gt(T);d=j.headers,h=j.rows}catch(T){e.createEl("p",{text:`Error reading file: ${T}`,cls:"csv-add-error"});return}if(!d.length){e.createEl("p",{text:"Error: No columns found in file",cls:"csv-add-error"});return}let u=["0","1","true","false","yes","no",""],f=T=>{let j=h.map(U=>{var G;return((G=U[T])!=null?G:"").toLowerCase().trim()});return j.length>0&&j.every(U=>u.includes(U))},p=T=>{let j=T.toLowerCase();if(["date","day","datum"].includes(j))return!0;let U=h.slice(0,5).map(G=>{var O;return(O=G[T])!=null?O:""});return U.length>0&&U.every(G=>/^\d{4}-\d{2}-\d{2}$/.test(G))},g=T=>{let j=T.toLowerCase();return["notes","note","comments","description","journal"].includes(j)},b=d.filter(T=>f(T)&&!p(T)),m=d.filter(T=>p(T)),x=d.filter(T=>g(T)),_=d.filter(T=>!b.includes(T)&&!m.includes(T)&&!x.includes(T)),w=d.find(T=>["title","name"].includes(T.toLowerCase())),S=e.createDiv({cls:"csv-add-form csv-add-compact"}),y=S.createEl("button",{cls:"csv-add-trigger",text:"+ New entry"});y.style.display="none";let v=S.createDiv({cls:"csv-add-card"}),C=v.createDiv({cls:"csv-add-card-header"});C.createEl("span",{cls:"csv-add-card-title",text:"New entry"});let M=C.createEl("button",{cls:"csv-add-card-close",text:"\xD7"}),D=v.createDiv({cls:"csv-add-rows"}),E={},L={},k=(T,j)=>{let U=D.createDiv({cls:`csv-add-row csv-add-row-${j}`});return U.createEl("span",{cls:"csv-add-row-label",text:kt(T)}),U};m.forEach(T=>{let U=k(T,"date").createEl("input",{cls:"csv-add-row-control",type:"date"});U.value=new Date().toISOString().split("T")[0],E[T]=U}),b.forEach(T=>{L[T]=!1;let U=k(T,"toggle").createEl("label",{cls:"csv-add-switch"}),G=U.createEl("input",{type:"checkbox",cls:"csv-add-switch-input"});U.createEl("span",{cls:"csv-add-switch-track"}),G.addEventListener("change",()=>{L[T]=G.checked}),E[T]=G}),_.forEach(T=>{let j=k(T,"field"),U=new Set(h.map(G=>{var O;return((O=G[T])!=null?O:"").trim()}).filter(Boolean));if(T!==w&&ys(U.size)){let G=j.createEl("select",{cls:"csv-add-row-control"});G.createEl("option",{text:"\u2014",value:""}),Array.from(U).sort().forEach(W=>G.createEl("option",{text:W,value:W})),G.createEl("option",{text:"+ Custom",value:"__custom__"});let O=D.createDiv({cls:"csv-add-row csv-add-row-custom"});O.style.display="none";let V=O.createEl("input",{cls:"csv-add-row-control",type:"text",placeholder:`Custom ${kt(T).toLowerCase()}`});D.insertBefore(O,j.nextSibling),G.addEventListener("change",()=>{O.style.display=G.value==="__custom__"?"flex":"none",G.value==="__custom__"&&V.focus()}),E[T]=G,E[`${T}__custom`]=V}else E[T]=j.createEl("input",{cls:"csv-add-row-control",type:"text",placeholder:kt(T)})}),x.forEach(T=>{let j=D.createDiv({cls:"csv-add-row csv-add-row-notes"});j.createEl("span",{cls:"csv-add-row-label",text:kt(T)}),E[T]=j.createEl("textarea",{cls:"csv-add-row-textarea",placeholder:"Optional notes\u2026"})});let A=v.createEl("button",{text:"Add",cls:"csv-add-submit"}),P=C.querySelector(".csv-add-card-title"),I=()=>{if(!m.length)return;let T=E[m[0]];if(!T)return;let j=T.value,U=h.find(G=>G[m[0]]===j);P&&P.setText(U?`Updating ${j}`:"New entry"),v.classList.toggle("is-updating",!!U),A.setText(U?"Update":"Add"),b.forEach(G=>{var R;let O=E[G];if(!O)return;let V=((R=U==null?void 0:U[G])!=null?R:"").toLowerCase().trim(),W=V==="1"||V==="true"||V==="yes";O.checked=W,L[G]=W}),[..._,...x].forEach(G=>{var W,R;let O=E[G];if(!O)return;let V=(W=U==null?void 0:U[G])!=null?W:"";if(O instanceof HTMLSelectElement)if(Array.from(O.options).find(K=>K.value===V)){O.value=V;let K=(R=E[`${G}__custom`])==null?void 0:R.closest(".csv-add-row-custom");K&&(K.style.display="none")}else O.value="";else O instanceof HTMLTextAreaElement,O.value=V})};if(I(),m.length){let T=E[m[0]];T==null||T.addEventListener("change",I)}let z=()=>{v.style.display="block",y.style.display="none";let T=v.querySelector(".csv-add-row-control");T==null||T.focus()},F=()=>{v.style.display="none",y.style.display=""};y.addEventListener("click",z),M.addEventListener("click",F),A.addEventListener("click",async()=>{let T={};d.forEach(R=>{var B,K,Y,q;b.includes(R)?T[R]=L[R]?"1":"0":E[R]instanceof HTMLSelectElement&&E[R].value==="__custom__"?T[R]=(K=(B=E[`${R}__custom`])==null?void 0:B.value)!=null?K:"":E[R]instanceof HTMLTextAreaElement?T[R]=E[R].value:T[R]=(q=(Y=E[R])==null?void 0:Y.value)!=null?q:""});let j=m.length>0&&m.some(R=>{var B;return((B=T[R])!=null?B:"").trim()}),U=[..._,...x].some(R=>{var B;return((B=T[R])!=null?B:"").trim()}),G=b.some(R=>L[R]);if(!j&&!U&&!G){new de.Notice("Please fill at least one field");return}let O=[];try{let R=await s.vault.read(c);O=Gt(R).rows}catch(R){new de.Notice(`Error reading file: ${R}`);return}let V=!1,W=-1;if(m.length>0){let R=m[0],B=T[R];if(W=O.findIndex(K=>K[R]===B),W>=0){V=!0;let K=O[W];d.forEach(Y=>{var q;(b.includes(Y)||((q=T[Y])!=null?q:"").trim())&&(K[Y]=T[Y])})}else O.push(T)}else O.push(T);try{let R=Uo.default.unparse(O,{columns:d});await s.vault.modify(c,R),new de.Notice(V?`Updated entry for ${T[m[0]]||""}`:`Added entry to ${c.basename}`),h.length=0,h.push(...O),m.length>0?I():(b.forEach(B=>{L[B]=!1;let K=E[B];K&&(K.checked=!1)}),[..._,...x].forEach(B=>{let K=E[B];K instanceof HTMLSelectElement?K.selectedIndex=0:(K instanceof HTMLTextAreaElement||K)&&(K.value="");let Y=E[`${B}__custom`];if(Y){Y.value="";let q=Y.closest(".csv-add-row-custom");q&&(q.style.display="none")}})),setTimeout(async()=>{let B=s.vault.getAbstractFileByPath(n.sourcePath);if(B instanceof de.TFile){let K=s.workspace.activeLeaf;K&&await K.openFile(B,{state:{mode:"preview"}})}},300)}catch(R){new de.Notice(`Error saving: ${R}`)}})}function ln(s,t){let e=s.getFilteredRows();s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${e.length} of ${s.rows.length} entries`});let i=t.createDiv({cls:"csv-table-wrapper"}).createEl("table",{cls:"csv-table"}),o=i.createEl("thead").createEl("tr");s.headers.forEach(l=>{let c=o.createEl("th");c.setText(l),c.addClass("csv-th-sortable"),s.tableSortCol===l&&c.createSpan({cls:"csv-th-sort-indicator",text:s.tableSortDir==="asc"?" \u25B2":" \u25BC"}),c.title="Click to sort",c.addEventListener("click",p=>{p.target.closest(".csv-col-resize-handle")||(s.tableSortCol!==l?(s.tableSortCol=l,s.tableSortDir="asc"):s.tableSortDir==="asc"?s.tableSortDir="desc":s.tableSortCol=null,s.renderView())});let d=s.settings.columnWidths[l];d&&(c.style.width=d+"px");let h=c.createDiv({cls:"csv-col-resize-handle"}),u=0,f=0;h.addEventListener("pointerdown",p=>{p.preventDefault(),p.stopPropagation(),h.setPointerCapture(p.pointerId),u=p.clientX,f=c.offsetWidth;let g=m=>{c.style.width=Math.max(60,f+m.clientX-u)+"px"},b=m=>{s.settings.columnWidths[l]=Math.max(60,f+m.clientX-u),h.removeEventListener("pointermove",g),h.removeEventListener("pointerup",b),s.persistSettings()};h.addEventListener("pointermove",g),h.addEventListener("pointerup",b)})}),o.createEl("th",{text:""});let r=matchMedia("(pointer: coarse)").matches,a=i.createEl("tbody");e.forEach(l=>{let c=a.createEl("tr");c.addEventListener("contextmenu",u=>s.openRowContextMenu(l,u)),s.headers.forEach(u=>{var p,g;let f=c.createEl("td");if(s.isNotesCol(u)){f.addClass("csv-table-notes-cell");let b=((p=l[u])!=null?p:"").replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").split(` +`).filter(_=>_.trim()).slice(0,3).join(" \xB7 "),m=b?b.slice(0,200)+(b.length>200?"\u2026":""):"+ Add note",x=f.createSpan({text:m});b||x.addClass("csv-table-notes-empty"),f.title="Click to open note",f.addEventListener("click",_=>{_.stopPropagation(),s.openNoteExpander(l,u)})}else if(s.isSelectCol(u))s.renderSelectField(f,l,u);else{let b=(g=l[u])!=null?g:"";f.setText(b),b.length>80&&(f.title=b),xc(s,f,l,u)}});let d=c.createEl("td",{cls:"csv-table-action"}),h=s.notesFileExists(l);d.createEl("button",{cls:`csv-table-notes-btn ${h?"exists":""}`,text:h?"\u{1F4C4}":"\u271A",title:h?"Open notes":"Create notes"}).addEventListener("click",()=>s.openOrCreateNotes(l)),d.createEl("button",{cls:"csv-table-del-btn",text:"\u2715",title:"Delete row (Undo available)"}).addEventListener("click",()=>s.deleteWithUndo(l))}),r||requestAnimationFrame(()=>{a.querySelectorAll("td:not(.csv-table-notes-cell):not(.csv-table-action)").forEach(l=>{l.scrollHeight>l.clientHeight+1&&l.addClass("csv-cell--clipped")})})}function xc(s,t,e,n){t.addEventListener("click",()=>{var o;t.empty();let i=t.createEl("input",{cls:"csv-inline-input",value:(o=e[n])!=null?o:"",type:"text"});i.focus(),i.select(),i.addEventListener("blur",()=>{e[n]=i.value,s.scheduleSave(),t.empty(),t.setText(i.value||"\u2014")}),i.addEventListener("keydown",r=>{r.key==="Enter"&&i.blur(),r.key==="Escape"&&(t.empty(),t.setText(e[n]||"\u2014"))})})}function cn(s){return!!(s.getCategoryCol()||s.getStatusCol()||Yo(s)||s.authorKey())}function Yo(s){return s.resolveCol(["Rating","rating","Score","score","Score /5","Stars","stars"])}function ks(s){var i;let t=(s!=null?s:"").trim();if(!t)return null;let e=((i=t.match(/★/g))!=null?i:[]).length;if(e>0)return e;let n=parseFloat(t);return isNaN(n)||n<=0?null:Math.min(5,n)}var Go=["watched","read","finished","completed","done","yes","seen"],qo=["watching","reading","in progress","in-progress"],_c=["dropped","abandoned","dnf"];function Cc(s){let t=s.toLowerCase();return Go.includes(t)?"is-done":qo.includes(t)?"is-progress":_c.includes(t)?"is-dropped":""}function Es(s,t){let e=new Map;return s.forEach(n=>t(n).forEach(i=>{var o;return e.set(i,((o=e.get(i))!=null?o:0)+1)})),e}function ws(s,t,e,n){if(!e.length)return;let i=s.createDiv({cls:"csv-stats-section"});i.createDiv({cls:"csv-stats-section-title",text:t});let o=Math.max(...e.map(r=>r.count));e.forEach(r=>{var h;let a=i.createDiv({cls:"csv-stats-bar-row"});a.createDiv({cls:"csv-stats-bar-label",text:r.label,attr:{title:r.label}});let c=a.createDiv({cls:"csv-stats-bar-track"}).createDiv({cls:`csv-stats-bar-fill ${(h=r.cls)!=null?h:""}`});c.style.width=`${Math.max(2,Math.round(r.count/o*100))}%`;let d=n>0?Math.round(r.count/n*100):0;a.createDiv({cls:"csv-stats-bar-count",text:`${r.count} \xB7 ${d}%`}),r.onClick&&(a.addClass("is-clickable"),a.title=`Show "${r.label}" in the library`,a.addEventListener("click",r.onClick))})}function Xo(s,t){let e=s.getFilteredRows();if(s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Stats over ${e.length} of ${s.rows.length} entries`}),!e.length){t.createEl("p",{text:"No entries to chart.",cls:"csv-empty-state"});return}let n=t.createDiv({cls:"csv-stats-wrap"}),i=s.getStatusCol(),o=s.getCategoryCol(),r=Yo(s),a=s.authorKey(),l=s.resolveCol(["Year","year"]),c=n.createDiv({cls:"csv-stats-overview"}),d=(u,f)=>{let p=c.createDiv({cls:"csv-stats-chip"});p.createDiv({cls:"csv-stats-chip-value",text:u}),p.createDiv({cls:"csv-stats-chip-label",text:f})};if(d(String(e.length),"entries"),i){let u=e.filter(p=>{var g;return Go.includes(((g=p[i])!=null?g:"").toLowerCase().trim())}).length;u>0&&d(`${u} \xB7 ${Math.round(u/e.length*100)}%`,"done");let f=e.filter(p=>{var g;return qo.includes(((g=p[i])!=null?g:"").toLowerCase().trim())}).length;f>0&&d(String(f),"in progress")}if(o){let u=Es(e,f=>{var p;return((p=f[o])!=null?p:"").split(",").map(g=>g.trim()).filter(Boolean)});u.size>0&&d(String(u.size),o.toLowerCase()==="genre"||o.toLowerCase()==="genres"?"genres":"categories")}if(r){let u=e.map(f=>ks(f[r])).filter(f=>f!==null);if(u.length){let f=u.reduce((p,g)=>p+g,0)/u.length;d(`\u2605 ${f.toFixed(1)}`,`avg of ${u.length} rated`)}}let h=(u,f)=>{s.libraryStatusFilter=u!=null?u:"all",s.libraryGenreFilter=f!=null?f:"all",s.mode="library",s.renderView()};if(i){let u=Es(e,p=>{var b;let g=((b=p[i])!=null?b:"").trim();return g?[g]:[]}),f=Array.from(u.entries()).sort((p,g)=>g[1]-p[1]).map(([p,g])=>({label:p,count:g,cls:Cc(p),onClick:o?()=>h(p,null):void 0}));ws(n,`By ${i.toLowerCase()}`,f,e.length)}if(o){let u=Es(e,p=>{var g;return((g=p[o])!=null?g:"").split(",").map(b=>b.trim()).filter(Boolean)}),f=Array.from(u.entries()).sort((p,g)=>g[1]-p[1]||p[0].localeCompare(g[0])).slice(0,12).map(([p,g])=>({label:p,count:g,onClick:()=>h(null,p)}));ws(n,`By ${o.toLowerCase()}`,f,e.length)}if(r){let u=new Map,f=0;if(e.forEach(p=>{var m;let g=ks(p[r]);if(g===null)return;let b=Math.min(5,Math.max(1,Math.round(g)));u.set(b,((m=u.get(b))!=null?m:0)+1),f++}),f>0){let p=[5,4,3,2,1].filter(g=>{var b;return((b=u.get(g))!=null?b:0)>0}).map(g=>({label:"\u2605".repeat(g),count:u.get(g),cls:"is-rating"}));ws(n,"Ratings",p,f)}}if(l){let u=Es(e,f=>{var g;let p=((g=f[l])!=null?g:"").match(/\d{4}/);return p?[p[0]]:[]});if(u.size>1){let f=Array.from(u.entries()).sort((p,g)=>p[0].localeCompare(g[0])).map(([p,g])=>({label:p,count:g}));ws(n,"By year",f,e.length)}}if(a){let u=Es(e,p=>{var b;let g=((b=p[a])!=null?b:"").trim();return g?[g]:[]}),f=Array.from(u.entries()).filter(([,p])=>p>1);if(f.length>=2){let p=f.sort((g,b)=>b[1]-g[1]||g[0].localeCompare(b[0])).slice(0,8).map(([g,b])=>({label:g,count:b}));ws(n,`Top ${a.toLowerCase()}s`,p,e.length)}}}function Bt(s){let t=s.fileCfg.kanbanGroupCol;if(t&&s.headers.includes(t))return t;let e=s.getCategoryCol();if(e)return e;let n=new Set;s.headers.forEach(r=>{s.isNotesCol(r)&&n.add(r)});let i=s.getDateCol();i&&n.add(i);let o=s.titleKey();return o&&n.add(o),Ro(s.headers,s.rows,n)}function dn(s,t){let e=Bt(s);if(!e){t.createEl("p",{text:"No groupable column found.",cls:"csv-empty-state"});return}let n=s.getCategoryCol(),i=s.getStatusCol(),o=i===e?null:i,r=s.getFilteredRows();s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${r.length} of ${s.rows.length} entries`});let a=t.createDiv({cls:"csv-kanban-groupbar"});a.createSpan({cls:"csv-kanban-groupbar-label",text:"Group by"});let l=a.createEl("select",{cls:"csv-library-filter-select"});s.headers.filter(b=>!s.isNotesCol(b)).forEach(b=>{let m=l.createEl("option",{text:b===n?`${b} (default)`:b,value:b});b===e&&(m.selected=!0)}),l.addEventListener("change",()=>{let b=s.fileCfg;b.kanbanGroupCol=l.value===n?void 0:l.value,s.saveFileCfg(b),s.renderView(!0)});let c=Ao(e,r.map(b=>{var m;return(m=b[e])!=null?m:""})),d=b=>{var _;let m=(_=b[e])!=null?_:"",x;if(c){let w=Po(m);x=w?[w]:[]}else x=m.split(",").map(w=>w.trim()).filter(Boolean);return x.length||(x=["\u2014"]),x},h=new Set;r.forEach(b=>d(b).forEach(m=>h.add(m)));let u=Array.from(h).sort();if(!u.length){let b=t.createDiv({cls:"csv-empty-state"});b.createEl("p",{text:s.searchQuery?"No matching entries found.":`No "${e}" values found.`}),s.searchQuery&&b.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear search"}).addEventListener("click",()=>{s.searchQuery="",s.renderView()});return}let f=["In progress","Finished","Not started"],p=o?Array.from(new Set([...f,...r.map(b=>{var m;return(m=b[o])!=null?m:""}).filter(Boolean)])).filter(b=>r.some(m=>{var x;return((x=m[o])!=null?x:"")==b})):[],g=t.createDiv({cls:"csv-kanban-board"});u.forEach(b=>{let m=r.filter(S=>d(S).includes(b));if(!m.length)return;let x=g.createDiv({cls:"csv-kanban-col"}),_=x.createDiv({cls:"csv-kanban-col-header"});_.createDiv({cls:"csv-kanban-col-title",text:b}),_.createDiv({cls:"csv-kanban-col-count",text:String(m.length)});let w=x.createDiv({cls:"csv-kanban-col-body"});if(o&&p.length){p.forEach(y=>{let v=m.filter(M=>{var D;return((D=M[o])!=null?D:"")===y});if(!v.length)return;let C=w.createDiv({cls:"csv-kanban-status-group"});C.createDiv({cls:`csv-kanban-status-label status-${y.toLowerCase().replace(/\s+/g,"-")}`,text:y}),v.forEach(M=>ci(s,C,M,o,e))});let S=new Set(p);m.filter(y=>{var v;return!S.has((v=y[o])!=null?v:"")}).forEach(y=>ci(s,w,y,o,e))}else m.forEach(S=>ci(s,w,S,o,e))})}function ci(s,t,e,n,i){var v,C,M,D,E,L;let o=t.createDiv({cls:"csv-kanban-card"}),r=s.getNotesCol(),a=(C=(v=s.getImageCol)==null?void 0:v.call(s))!=null?C:null;if(a){let k=Js(s.app,(M=e[a])!=null?M:"",(E=(D=s.file)==null?void 0:D.path)!=null?E:"");if(k){let A=o.createEl("img",{cls:"csv-kanban-card-img",attr:{src:k,loading:"lazy",alt:""}});A.addEventListener("error",()=>A.remove())}}let l=o.createDiv({cls:"csv-kanban-card-title-row"});l.createDiv({cls:"csv-kanban-card-title",text:s.getTitle(e)}).addEventListener("click",k=>{k.stopPropagation(),s.openNoteExpander(e,r!=null?r:"")});let d=s.notesFileExists(e);l.createEl("button",{cls:`csv-kanban-notes-icon ${d?"exists":""}`,text:d?"\u{1F4C4}":"+",title:d?"Open notes file":"Create notes file"}).addEventListener("click",k=>{k.stopPropagation(),s.openOrCreateNotes(e)});let u=s.getSubtitle(e);u&&o.createDiv({cls:"csv-kanban-card-sub",text:u});let f=s.titleKey(),p=s.authorKey(),g=new Set([n,f,p,i].filter(Boolean)),b=o.createDiv({cls:"csv-kanban-card-meta"});s.headers.forEach(k=>{if(g.has(k)||s.isNotesCol(k))return;let A=b.createDiv({cls:"csv-kanban-chip"});if(A.createSpan({cls:"csv-chip-label",text:k+": "}),s.isSelectCol(k)){let P=A.createSpan({cls:`csv-chip-value csv-chip-select${e[k]?"":" csv-chip-value--empty"}`,text:e[k]||"\u2014"});P.addEventListener("click",I=>{I.stopPropagation(),Ot(P,e[k],s.getColumnValues(k),z=>{e[k]=z,P.setText(z||"\u2014"),P.classList.toggle("csv-chip-value--empty",!z),s.scheduleSave()},s.contentEl,{multi:It(k)})})}else{let P=e[k]?e[k].length>40?e[k].slice(0,38)+"\u2026":e[k]:"\u2014",I=A.createSpan({cls:`csv-chip-value${e[k]?"":" csv-chip-value--empty"}`,text:P});e[k]&&e[k].length>40&&(I.title=e[k])}});let m=s.getNotesCol(),x=!!(m&&((L=e[m])!=null&&L.trim())),_=o.createDiv({cls:"csv-kanban-notes-preview"});if(x&&m){let k=e[m].replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").replace(/\n+/g," ").trim();_.setText(k.slice(0,120)+(k.length>120?"\u2026":"")),_.title="Click to edit"}else _.addClass("csv-kanban-notes-preview--empty"),m&&_.setText("+ Add note");let w=o.createDiv({cls:"csv-kanban-notes-editor"});w.style.display="none";let S=()=>{var z,F,N;let k=s.contentEl.querySelector(".csv-content-area"),A=(z=k==null?void 0:k.scrollLeft)!=null?z:0,P=(F=k==null?void 0:k.scrollTop)!=null?F:0;_.style.display="none",w.style.display="block",w.empty();let I=w.createEl("textarea",{cls:"csv-notes-textarea"});I.value=(N=m?e[m]:"")!=null?N:"",I.addEventListener("click",H=>H.stopPropagation()),I.addEventListener("mousedown",H=>H.stopPropagation()),I.addEventListener("input",()=>{I.style.height="auto",I.style.height=I.scrollHeight+"px"}),I.addEventListener("keydown",H=>{H.key==="Escape"&&y(I.value,k,A,P)}),I.addEventListener("blur",()=>y(I.value,k,A,P)),I.focus({preventScroll:!0}),I.setSelectionRange(0,0),I.scrollTop=0,requestAnimationFrame(()=>{I.style.height="auto",I.style.height=Math.max(120,I.scrollHeight)+"px"})},y=(k,A,P,I)=>{if(m&&(e[m]=k,s.scheduleSave()),w.style.display="none",_.style.display="",k.trim()){let z=k.replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").replace(/\n+/g," ").trim();_.setText(z.slice(0,120)+(z.length>120?"\u2026":"")),_.removeClass("csv-kanban-notes-preview--empty"),_.title="Click to edit"}else _.addClass("csv-kanban-notes-preview--empty"),_.setText(m?"+ Add note":""),_.removeAttribute("title");A&&(A.scrollLeft=P,A.scrollTop=I,requestAnimationFrame(()=>{A.scrollLeft=P,A.scrollTop=I,requestAnimationFrame(()=>{A.scrollLeft=P,A.scrollTop=I})}),setTimeout(()=>{A.scrollLeft=P,A.scrollTop=I},50))};_.addEventListener("click",k=>{if(k.stopPropagation(),m&&matchMedia("(pointer: coarse)").matches){s.openNoteExpander(e,m);return}S()}),o.addEventListener("contextmenu",k=>s.openRowContextMenu(e,k))}function hn(s,t){var M,D;let e=Bt(s),n=s.getStatusCol(),i=(M=s.titleKey())!=null?M:s.headers[0],o=s.authorKey();if(!e){t.createEl("p",{text:"No groupable column found.",cls:"csv-empty-state"});return}let r=new Set;s.rows.forEach(E=>{var k;((k=E[e])!=null?k:"").split(",").map(A=>A.trim()).filter(Boolean).forEach(A=>r.add(A))});let a=new Set;n&&s.rows.forEach(E=>{var k;let L=((k=E[n])!=null?k:"").trim();L&&a.add(L)});let l=t.createDiv({cls:"csv-library-filters"}),c=l.createEl("select",{cls:"csv-library-filter-select"});c.createEl("option",{text:"All",value:"all"});let d=["watched","read","finished","completed","done","yes","seen"],h=["watching","reading","in progress","in-progress"],u=Array.from(a).some(E=>d.includes(E.toLowerCase())),f=Array.from(a).some(E=>h.includes(E.toLowerCase()));(u||f)&&(c.createEl("option",{text:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500",value:"",attr:{disabled:"true"}}),u&&c.createEl("option",{text:"\u2713 Done",value:"__done__"}),f&&c.createEl("option",{text:"\u25D0 In Progress",value:"__inprogress__"}),c.createEl("option",{text:"\u25CB Not Started",value:"__notstarted__"})),a.size>0&&(c.createEl("option",{text:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500",value:"",attr:{disabled:"true"}}),Array.from(a).sort().forEach(E=>{c.createEl("option",{text:E,value:E})})),c.value=s.libraryStatusFilter;let p=l.createEl("select",{cls:"csv-library-filter-select"});p.createEl("option",{text:"All genres",value:"all"}),Array.from(r).sort().forEach(E=>{p.createEl("option",{text:E,value:E})}),p.value=s.libraryGenreFilter;let g=s.resolveCol(["Year","year","Date","date"]),b=s.resolveCol(["Rating","rating","Score","score","Score /5","Stars","stars"]),m=s.resolveCol(["Theme","theme","Tags","tags","Tag","tag","Mood","mood"]),x=(D=s.fileCfg.librarySort)!=null?D:"status",_=l.createEl("select",{cls:"csv-library-filter-select"}),w=[["status","Sort: Status"],["title","Sort: Title"]];b&&w.push(["rating","Sort: Rating"]),g&&w.push(["year","Sort: Year"]),w.forEach(([E,L])=>{let k=_.createEl("option",{text:L,value:E});E===x&&(k.selected=!0)}),_.addEventListener("change",()=>{let E=s.fileCfg;E.librarySort=_.value==="status"?void 0:_.value,s.saveFileCfg(E),s.renderView(!0)});let S=()=>{s.libraryStatusFilter=c.value,s.libraryGenreFilter=p.value,s.renderView(!0)};c.addEventListener("change",S),p.addEventListener("change",S);let y=s.rows.filter(E=>{var L,k;if(s.libraryStatusFilter!=="all"&&n){let A=((L=E[n])!=null?L:"").toLowerCase();if(s.libraryStatusFilter==="__done__"){if(!d.includes(A))return!1}else if(s.libraryStatusFilter==="__inprogress__"){if(!h.includes(A))return!1}else if(s.libraryStatusFilter==="__notstarted__"){if(d.includes(A)||h.includes(A))return!1}else if(A!==s.libraryStatusFilter.toLowerCase())return!1}if(s.libraryGenreFilter!=="all"&&!((k=E[e])!=null?k:"").split(",").map(P=>P.trim().toLowerCase()).includes(s.libraryGenreFilter.toLowerCase()))return!1;if(s.searchQuery.trim()){let A=s.searchQuery.toLowerCase().trim();if(!s.headers.some(P=>{var I;return((I=E[P])!=null?I:"").toLowerCase().includes(A)}))return!1}return!0});(s.libraryStatusFilter!=="all"||s.libraryGenreFilter!=="all"||s.searchQuery.trim())&&t.createDiv({cls:"csv-library-result-count",text:`Showing ${y.length} of ${s.rows.length} entries`});let v={};y.forEach(E=>{var k;let L=s.libraryGenreFilter!=="all"?[s.libraryGenreFilter]:((k=E[e])!=null?k:"Uncategorized").split(",").map(A=>A.trim()).filter(Boolean);L.length===0&&L.push("Uncategorized"),L.forEach(A=>{v[A]||(v[A]=[]),v[A].push(E)})});let C=t.createDiv({cls:"csv-library-sections"});if(Object.keys(v).sort().forEach(E=>{var U,G,O,V,W;let L=v[E],k=C.createEl("details",{cls:"csv-library-section"}),A=E.toLowerCase(),P=((U=s.fileCfg.collapsedGroups)!=null?U:[]).map(R=>R.toLowerCase());k.open=!((G=s.collapsedGroups)!=null&&G.has(A)||P.includes(A)),k.addEventListener("toggle",()=>{var q;let R=s.fileCfg,B=((q=R.collapsedGroups)!=null?q:[]).map(Q=>Q.toLowerCase()),K=new Set(B);k.open?K.delete(A):K.add(A);let Y=Array.from(K);Y.length===B.length&&Y.every(Q=>B.includes(Q))||(R.collapsedGroups=Y,s.saveFileCfg(R))});let I=k.createEl("summary",{cls:"csv-library-section-header"});I.innerHTML=`\u25B6 ${E} ${L.length}`;let z=k.createDiv({cls:"csv-library-grid"}),F=(R,B)=>{var K,Y;return((K=R[i])!=null?K:"").localeCompare((Y=B[i])!=null?Y:"")},N=(R,B)=>R===null&&B===null?0:R===null?1:B===null?-1:B-R;L.sort((R,B)=>{var K,Y,q,Q;if(x==="title")return F(R,B);if(x==="rating"&&b)return N(ks((K=R[b])!=null?K:""),ks((Y=B[b])!=null?Y:""))||F(R,B);if(x==="year"&&g){let X=ut=>{var st;let J=((st=ut[g])!=null?st:"").match(/\d{4}/);return J?parseInt(J[0],10):null};return N(X(R),X(B))||F(R,B)}if(n){let X=((q=R[n])!=null?q:"").toLowerCase(),ut=((Q=B[n])!=null?Q:"").toLowerCase(),J=d.includes(X),st=d.includes(ut);if(J!==st)return J?-1:1;let at=h.includes(X),Rt=h.includes(ut);if(at!==Rt)return at?-1:1}return F(R,B)});let H=[o,g,b,m].filter(R=>!!R),T=(O=s.fileCfg.cardFields)!=null?O:H,j=(W=(V=s.getImageCol)==null?void 0:V.call(s))!=null?W:null;L.forEach(R=>{var Q,X,ut,J,st,at,Rt;let B=z.createDiv({cls:"csv-library-card"});if(j){let ot=Js(s.app,(Q=R[j])!=null?Q:"",(ut=(X=s.file)==null?void 0:X.path)!=null?ut:"");if(ot){let gt=B.createEl("img",{cls:"csv-library-card-img",attr:{src:ot,loading:"lazy",alt:""}});gt.addEventListener("error",()=>gt.remove())}}let K=B.createDiv({cls:"csv-library-card-title"});if(n){let ot=((J=R[n])!=null?J:"").toLowerCase();d.includes(ot)&&K.createSpan({cls:"csv-library-done-dot"})}K.createSpan({text:(st=R[i])!=null?st:"Untitled"});let Y=[],q=[];for(let ot of T){if(!ot)continue;let gt=String((at=R[ot])!=null?at:"").trim();if(gt)if(ot===b){let ft=Lo(gt,ot);ft&&B.createDiv({cls:"csv-library-card-rating",text:ft})}else if(ot===m)q.push(...gt.split(",").map(ft=>ft.trim()).filter(Boolean));else if(ot===g){let ft=gt.match(/\d{4}/);Y.push(ft?ft[0]:gt)}else Y.push(gt)}if(Y.length&&B.createDiv({cls:"csv-library-card-meta",text:Y.join(" \xB7 ")}),s.libraryGenreFilter!=="all"){let ot=((Rt=R[e])!=null?Rt:"").split(",").map(gt=>gt.trim()).filter(gt=>gt&>.toLowerCase()!==s.libraryGenreFilter.toLowerCase());q.push(...ot)}if(q.length){let ot=B.createDiv({cls:"csv-library-card-tags"});q.slice(0,3).forEach(gt=>{ot.createSpan({cls:"csv-library-card-tag",text:gt})})}B.addEventListener("click",()=>{var ot;s.openNoteExpander(R,(ot=s.getNotesCol())!=null?ot:"")}),B.addEventListener("contextmenu",ot=>s.openRowContextMenu(R,ot))})}),Object.keys(v).length===0){let E=C.createDiv({cls:"csv-empty-state"});E.createEl("p",{text:"No entries match your filters."}),E.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear filters"}).addEventListener("click",()=>{s.libraryStatusFilter="all",s.libraryGenreFilter="all",s.searchQuery="",s.renderView()})}}var gn=require("obsidian");var Me=require("obsidian");var di=`--- obsidianUIMode: preview obsidianEditingMode: source --- @@ -365,11 +365,11 @@ if (!csvData || !csvData.length) { } } \`\`\` -${hi}`}async function tr(s){var c,d,h,u,f,p,g,m,b,x;if(!s.file)return;let t=(d=(c=s.file.parent)==null?void 0:c.path)!=null?d:"",e=t?`${t}/Mobile`:"Mobile";await s.app.vault.adapter.exists(e)||await s.app.vault.adapter.mkdir(e);let n=`${e}/${s.file.basename}.md`,i=s.file.path,o=s.getDateCol(),r=s.getCategoryCol(),a="../"+s.file.name,l;if(o){let _=s.getBooleanColumns();l=Qo({filePath:a,csvPath:i,habitCols:_,labels:_.map(kt),dateCol:o})}else if(r){let _=(f=(u=(h=s.titleKey())!=null?h:s.resolveCol(["Quote","quote","Headline","headline","Phrase","phrase"]))!=null?u:s.headers[0])!=null?f:"Title";l=Zo({filePath:a,csvPath:i,titleKey:_,categoryCol:r,statusCol:(p=s.getStatusCol())!=null?p:"Status",authorKey:(g=s.authorKey())!=null?g:"",yearCol:(m=s.resolveCol(["Year","year","Released","released"]))!=null?m:"",ratingCol:(b=s.resolveCol(["Rating","rating","Score","score","Stars","stars"]))!=null?b:"",themeCol:(x=s.resolveCol(["Theme","theme","Subgenre","subgenre","Mood","mood"]))!=null?x:"",compactGrid:s.titleKey()!==null})}else l=Jo({filePath:a,csvPath:i,headers:s.headers});try{let _=s.app.vault.getAbstractFileByPath(n);_&&_ instanceof Me.TFile?(await s.app.vault.modify(_,l),new Me.Notice(`Updated: ${n}`)):(await s.app.vault.create(n,l),new Me.Notice(`Created: ${n}`))}catch(_){let E=s.app.vault.getAbstractFileByPath(n);E instanceof Me.TFile&&(await s.app.vault.modify(E,l),new Me.Notice(`Updated: ${n}`))}}var he=require("obsidian"),Sc="http://127.0.0.1:8765",Ec=6;async function er(s,t){let e;try{e=await(0,he.requestUrl)({url:Sc,method:"POST",contentType:"application/json",body:JSON.stringify({action:s,version:Ec,params:t}),throw:!1})}catch(i){throw new Error("Couldn't reach Anki. Is the desktop app open with the AnkiConnect add-on installed?")}let n=e.json;if(n.error)throw new Error(n.error);return n.result}function wc(s){var e,n,i;let t=s.fileCfg.ankiFrontCol;return t&&s.headers.includes(t)?t:(i=(n=(e=s.titleKey())!=null?e:s.resolveCol(["Quote","Headline","Phrase","Term","Word","Question","Front","Name","Title"]))!=null?n:s.headers[0])!=null?i:null}function ui(s){return s.replace(/&/g,"&").replace(//g,">")}function kc(s,t,e){return s.headers.filter(n=>{var i;return n!==e&&((i=t[n])!=null?i:"").trim()}).map(n=>`${ui(n)}: ${ui(t[n].trim())}`).join("
")}async function sr(s){if(!s.file)return;let t=wc(s);if(!t){new he.Notice("No column to use as the Anki card front.",6e3);return}let e=s.file.basename,n=s.rows.filter(o=>{var r;return((r=o[t])!=null?r:"").trim()});if(!n.length){new he.Notice(`Nothing to sync \u2014 no rows with a "${t}" value.`,6e3);return}let i=new he.Notice(`Syncing ${n.length} cards to Anki deck \u201C${e}\u201D\u2026`,0);try{await er("createDeck",{deck:e});let o=n.map(c=>({deckName:e,modelName:"Basic",fields:{Front:ui(c[t].trim()),Back:kc(s,c,t)},options:{allowDuplicate:!1,duplicateScope:"deck"},tags:["datadeck"]})),r=await er("addNotes",{notes:o}),a=r.filter(c=>c!=null).length,l=r.length-a;i.hide(),new he.Notice(`Anki sync: ${a} added${l?`, ${l} already present`:""} (deck \u201C${e}\u201D).`,6e3)}catch(o){i.hide(),new he.Notice(`Anki sync failed: ${o instanceof Error?o.message:String(o)}`,8e3)}}function un(s){return s.resolveCol(["Type","type","Kind","kind","Item","item"])}function pi(s){var t;return(t=s.resolveCol(["Project","project","Projects","projects","Area","area"]))!=null?t:Bt(s)}function rr(s){return s.resolveCol(["Due","due","Deadline","deadline","Due Date","Due date","due date"])}function fn(s){return s.resolveCol(["Priority","priority","Prio","prio","Importance","importance"])}var Mc=["task","todo","to-do","action",""],Dc=["task","todo","to-do","action","note","idea","reference","ref"],ar=["done","complete","completed","finished","closed","resolved","yes","x","\u2713","true"],Tc={high:0,med:1,medium:1,normal:1,low:2};function Ge(s){if(rr(s)||fn(s))return!0;let t=un(s);return t?s.rows.some(e=>{var n;return Dc.includes(((n=e[t])!=null?n:"").trim().toLowerCase())}):!1}function Lc(s,t,e){var n;return e?Mc.includes(((n=t[e])!=null?n:"").trim().toLowerCase()):!0}function Ac(s,t,e){if(Lc(s,t,e))return"task";let n=(e?t[e]:"").trim().toLowerCase();return n==="idea"||n==="ideas"?"idea":"note"}function Ye(s,t,e){var n;return e?ar.includes(((n=t[e])!=null?n:"").trim().toLowerCase()):!1}function nr(s){let t=Tc[(s!=null?s:"").trim().toLowerCase()];return t===void 0?3:t}function ir(s){return(s!=null?s:"").trim()?0:1}function Pc(){return new Date().toISOString().slice(0,10)}function Rc(s,t){let e=new Map;s.rows.forEach(o=>{var a,l;let r=((a=o[t])!=null?a:"").trim();r&&ar.includes(r.toLowerCase())&&e.set(r,((l=e.get(r))!=null?l:0)+1)});let n="done",i=0;return e.forEach((o,r)=>{o>i&&(n=r,i=o)}),n}function lr(s,t){var D;let e=pi(s),n=un(s),i=s.getStatusCol(),o=rr(s),r=fn(s),a=(D=s.titleKey())!=null?D:s.headers[0],l=t.createDiv({cls:"csv-library-filters"}),c=new Set;e&&s.rows.forEach(M=>{var w;((w=M[e])!=null?w:"").split(",").map(L=>L.trim()).filter(Boolean).forEach(L=>c.add(L))});let d=l.createEl("select",{cls:"csv-library-filter-select"});d.createEl("option",{text:e?"All projects":"All",value:"all"}),Array.from(c).sort().forEach(M=>d.createEl("option",{text:M,value:M})),d.value=s.taskProjectFilter;let h=new Set;n&&s.rows.forEach(M=>{var L;let w=((L=M[n])!=null?L:"").trim();w&&h.add(w)});let u=null;h.size>0&&(u=l.createEl("select",{cls:"csv-library-filter-select"}),u.createEl("option",{text:"All types",value:"all"}),Array.from(h).sort().forEach(M=>u.createEl("option",{text:M,value:M})),u.value=s.taskTypeFilter);let f=()=>{s.taskProjectFilter=d.value,u&&(s.taskTypeFilter=u.value),s.renderView(!0)};d.addEventListener("change",f),u==null||u.addEventListener("change",f);let p=s.searchQuery.toLowerCase().trim(),g=s.rows.filter(M=>{var w,L;return!(s.taskProjectFilter!=="all"&&e&&!((w=M[e])!=null?w:"").split(",").map(A=>A.trim().toLowerCase()).includes(s.taskProjectFilter.toLowerCase())||s.taskTypeFilter!=="all"&&n&&((L=M[n])!=null?L:"").trim().toLowerCase()!==s.taskTypeFilter.toLowerCase()||p&&!s.headers.some(k=>{var A;return((A=M[k])!=null?A:"").toLowerCase().includes(p)}))});(s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all"||p)&&t.createDiv({cls:"csv-library-result-count",text:`Showing ${g.length} of ${s.rows.length} entries`});let m={},b={},x={},_={task:m,note:b,idea:x},E=M=>{var L;return e&&((L=M[e])!=null?L:"").split(",").map(k=>k.trim()).filter(Boolean)[0]||"\u2014"};g.forEach(M=>{var k;let w=_[Ac(s,M,n)],L=E(M);((k=w[L])!=null?k:w[L]=[]).push(M)});let S=t.createDiv({cls:"csv-tasks"}),v=Pc(),y=i?Rc(s,i):"done";fi(S,"Tasks",m,(M,w)=>{w.sort((L,k)=>{var I,z,R,V,T,O;let A=Ye(s,L,i),P=Ye(s,k,i);if(A!==P)return A?1:-1;if(r){let j=nr((I=L[r])!=null?I:"")-nr((z=k[r])!=null?z:"");if(j)return j}if(o){let j=ir((R=L[o])!=null?R:"")-ir((V=k[o])!=null?V:"");if(j)return j;let U=((T=L[o])!=null?T:"").localeCompare((O=k[o])!=null?O:"");if(U)return U}return s.getTitle(L).localeCompare(s.getTitle(k))}),w.forEach(L=>{var V;let k=Ye(s,L,i),A=M.createEl("tr"),P=A.createEl("td",{cls:"csv-tasks-check-cell"});if(i){let T=P.createEl("span",{cls:`csv-tasks-check ${k?"is-done":""}`,text:k?"\u2713":""});T.setAttr("title",k?"Mark not done":"Mark done"),T.addEventListener("click",O=>{O.stopPropagation(),L[i]=k?"":y,s.scheduleSave(),s.renderView(!0)})}or(s,A,L,a,k);let I=A.createEl("td",{cls:"csv-tasks-due"}),z=o?((V=L[o])!=null?V:"").slice(0,10):"";I.setText(z||"\u2014"),z&&!k&&z{var j;T.stopPropagation();let O=Array.from(new Set([...s.getColumnValues(r),"high","medium","low"]));Ot(R,(j=L[r])!=null?j:"",O,U=>{L[r]=U,s.scheduleSave(),s.renderView(!0)},s.contentEl)})),A.addEventListener("contextmenu",T=>s.openRowContextMenu(L,T))})},["","Name","Due","Priority"]);let C=(M,w)=>{w.sort((L,k)=>{let A=Ye(s,L,i),P=Ye(s,k,i);return A!==P?A?1:-1:s.getTitle(L).localeCompare(s.getTitle(k))}),w.forEach(L=>{let k=Ye(s,L,i),A=M.createEl("tr"),P=A.createEl("td",{cls:"csv-tasks-check-cell"});if(i){let R=P.createEl("span",{cls:`csv-tasks-check ${k?"is-done":""}`,text:k?"\u2713":""});R.setAttr("title",k?"Mark not done":"Mark done"),R.addEventListener("click",V=>{V.stopPropagation(),L[i]=k?"":y,s.scheduleSave(),s.renderView(!0)})}let I=n&&L[n]||"",z=A.createEl("td",{cls:"csv-tasks-type-cell"});I&&z.createSpan({cls:"csv-tasks-type-pill",text:I}),or(s,A,L,a,k),A.addEventListener("contextmenu",R=>s.openRowContextMenu(L,R))})};if(fi(S,"Notes",b,C,["","Type","Name"]),fi(S,"Ideas",x,C,["","Type","Name"]),Object.keys(m).length===0&&Object.keys(b).length===0&&Object.keys(x).length===0){let M=S.createDiv({cls:"csv-empty-state"});M.createEl("p",{text:p||s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all"?"No entries match your filters.":"No tasks yet."}),(p||s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all")&&M.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear filters"}).addEventListener("click",()=>{s.taskProjectFilter="all",s.taskTypeFilter="all",s.searchQuery="",s.renderView()})}}function fi(s,t,e,n,i){if(Object.keys(e).length===0)return;s.createDiv({cls:"csv-tasks-section-header",text:t});let o=s.createDiv({cls:"csv-tasks-section"});Object.keys(e).sort().forEach(r=>{let a=e[r],l=o.createEl("details",{cls:"csv-tasks-group"});l.open=!0;let c=l.createEl("summary",{cls:"csv-tasks-group-header"});c.innerHTML=`\u25B6 ${r} ${a.length}`;let d=l.createEl("table",{cls:"csv-tasks-table"}),u=d.createEl("thead").createEl("tr");i.forEach(p=>u.createEl("th",{text:p}));let f=d.createEl("tbody");n(f,a)})}function or(s,t,e,n,i){let o=t.createEl("td",{cls:"csv-tasks-name-cell"}),r=o.createSpan({cls:`csv-tasks-link ${i?"csv-tasks-done":""}`,text:e[n]||"Untitled"}),a=s.getNotesCol();r.addEventListener("click",()=>{a?s.openNoteExpander(e,a):s.openOrCreateNotes(e)});let l=s.notesFileExists(e),c=o.createEl("button",{cls:`csv-tasks-page-icon ${l?"exists":""}`,text:l?"\u{1F4C4}":"+"});c.setAttr("title",l?"Open page":"Create page"),c.addEventListener("click",d=>{d.stopPropagation(),s.openOrCreateNotes(e)})}function pn(s){let t=[];return s.isTravelFile()&&t.push({id:"travel",label:"Travel"}),s.hasDateColumn()&&t.push({id:"dashboard",label:"Dashboard"}),Ge(s)&&t.push({id:"tasks",label:"Tasks"}),Bt(s)&&(t.push({id:"library",label:"Cards"}),t.push({id:"kanban-genre",label:"Kanban"})),t.push({id:"table",label:"Table"}),s.rows.length>0&&t.push({id:"focus",label:"Focus"}),cn(s)&&t.push({id:"stats",label:"Stats"}),t}function cr(s,t){var f,p,g;let e=t.createDiv({cls:"csv-toolbar"});e.createDiv({cls:"csv-toolbar-title",text:(p=(f=s.file)==null?void 0:f.basename)!=null?p:""});let n=e.createDiv({cls:"csv-toolbar-controls"});n.createDiv({cls:"csv-row-count",text:`${s.rows.length} entries`});let i=n.createDiv({cls:"csv-mode-group"}),o=pn(s),r=i.createEl("select",{cls:"csv-mode-select",attr:{"aria-label":"View mode"}});if(o.forEach(({id:m,label:b})=>{let x=r.createEl("option",{text:b,value:m});s.mode===m&&(x.selected=!0)}),r.addEventListener("change",()=>{s.mode=r.value,s.renderView()}),s.mode!=="dashboard"){let m=n.createEl("button",{cls:"csv-cfg-btn csv-search-toggle",text:"\u{1F50D}",title:"Search"}),b=n.createDiv({cls:"csv-search-wrap"}),x=b.createDiv({cls:"csv-search-input-wrap"}),_=x.createEl("input",{cls:"csv-search-input",type:"text",placeholder:"Search...",value:s.searchQuery,attr:{inputmode:"search",enterkeyhint:"search",autocomplete:"off"}}),E=x.createEl("button",{cls:"csv-search-clear",text:"\xD7",title:"Clear search"});E.toggleClass("is-hidden",!s.searchQuery),b.createEl("button",{cls:"csv-search-done",text:"Done",title:"Dismiss keyboard"}).addEventListener("click",y=>{if(y.preventDefault(),!_.value){e.removeClass("csv-toolbar--search-expanded"),m.removeClass("has-query"),s.searchQuery="",s.renderView(!0);return}_.blur()});let v=null;_.addEventListener("input",y=>{s.searchQuery=y.target.value,E.toggleClass("is-hidden",!s.searchQuery),m.toggleClass("has-query",!!s.searchQuery),v!==null&&window.clearTimeout(v),v=window.setTimeout(()=>{v=null,s.renderView(!0)},120)}),_.addEventListener("keydown",y=>{y.key==="Enter"&&(y.preventDefault(),_.blur())}),E.addEventListener("click",()=>{s.searchQuery="",_.value="",E.addClass("is-hidden"),m.removeClass("has-query"),_.focus({preventScroll:!0}),s.renderView(!0)}),s.searchQuery&&m.addClass("has-query"),m.addEventListener("click",()=>{e.addClass("csv-toolbar--search-expanded"),_.focus({preventScroll:!0})})}if(s.mode==="table"&&s.hasDateColumn()){let m=(g=s.fileCfg.sortNewestFirst)!=null?g:!0;n.createEl("button",{cls:`csv-cfg-btn ${m?"active":""}`,text:m?"\u2193 Newest":"\u2191 Oldest",title:"Toggle sort order"}).addEventListener("click",()=>{var _;let x=s.fileCfg;x.sortNewestFirst=!((_=x.sortNewestFirst)==null||_),s.saveFileCfg(x),s.tableSortCol=null,s.renderViewPreservingScroll()})}let a=()=>{var m,b;new sn(s.app,s.headers,(b=(m=s.file)==null?void 0:m.path)!=null?b:"",s.fileCfg,s.autoDetectBooleanColumns(),pn(s),x=>{s.saveFileCfg(x),x.defaultMode&&(s.mode=x.defaultMode),s.renderView()},()=>s.headers,()=>s.fileCfg,x=>s.addColumn(x),x=>s.removeColumn(x)).open()},l=()=>tr(s),c=()=>s.backupToArchive(),d=()=>sr(s);n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u2699 Columns",title:"Configure columns for this file"}).addEventListener("click",a),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F4F1} Mobile",title:"Generate mobile dashboard with add form"}).addEventListener("click",l),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F4BE} Backup",title:"Copy this file to Archive/ with today's date"}).addEventListener("click",c),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F3B4} Anki",title:"Sync rows to Anki (needs Anki desktop + AnkiConnect)"}).addEventListener("click",d),n.createEl("button",{cls:"csv-add-btn",text:"+ Add"}).addEventListener("click",()=>s.openAddModal()),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-overflow",text:"\u22EF",title:"More actions"}).addEventListener("click",m=>{let b=new gn.Menu;b.addItem(x=>x.setTitle("Columns").setIcon("settings").onClick(a)),b.addItem(x=>x.setTitle("Mobile dashboard").setIcon("smartphone").onClick(l)),b.addItem(x=>x.setTitle("Backup").setIcon("save").onClick(c)),b.addItem(x=>x.setTitle("Sync to Anki").setIcon("layers").onClick(d)),b.addSeparator(),b.addItem(x=>x.setTitle("Built 2026-07-06 07:14").setIcon("info").setDisabled(!0)),b.showAtMouseEvent(m)}),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary csv-info-btn",text:"\u24D8",title:"Built 2026-07-06 07:14 \u2014 click to confirm"}).addEventListener("click",()=>new gn.Notice("datadeck \u2014 built 2026-07-06 07:14",4e3))}function Oc(s){return s&&typeof s=="object"&&"basename"in s?s:null}var Fc=["Author","author","By","by","Source","source","Speaker","speaker","Artist","artist","Director","director"];async function dr(s,t,e,n){var x,_,E;let i=t.split(` -`).map(S=>S.trim()).filter(Boolean),o=S=>{var v,y;return(y=(v=i.find(C=>C.startsWith(S+":")))==null?void 0:v.slice(S.length+1).trim())!=null?y:""},r=o("file");if(!r){e.createEl("p",{text:"Error: No file specified. Use: file: yourfile.csv",cls:"csv-add-error"});return}let a=s.vault.getAbstractFileByPath(n.sourcePath),l=(_=(x=a==null?void 0:a.parent)==null?void 0:x.path)!=null?_:"",c=We(r,l),d=Oc(s.vault.getAbstractFileByPath(c));if(!d){e.createEl("p",{text:`Error: File not found: ${c}`,cls:"csv-add-error"});return}let h=[],u=[];try{let S=Gt(await s.vault.read(d));h=S.headers,u=S.rows}catch(S){e.createEl("p",{text:`Error reading file: ${S}`,cls:"csv-add-error"});return}if(!u.length){e.createEl("p",{text:"No entries in file.",cls:"csv-add-error"});return}let f=o("field"),p=(E=h.find(S=>S.toLowerCase()===f.toLowerCase()))!=null?E:h[0],g=Fc.map(S=>h.find(v=>v===S)).find(Boolean),m=e.createDiv({cls:"csv-random-card"}),b=()=>{var w;m.empty();let S=u.filter(L=>{var k;return((k=L[p])!=null?k:"").trim()}),v=S.length?S:u,y=v[Math.floor(Math.random()*v.length)];m.createDiv({cls:"csv-random-text",text:y[p]||"\u2014"});let C=g?((w=y[g])!=null?w:"").trim():"";C&&m.createDiv({cls:"csv-random-sub",text:`\u2014 ${C}`});let D=m.createDiv({cls:"csv-random-foot"});D.createSpan({cls:"csv-random-src",text:d.basename}),D.createEl("button",{cls:"csv-random-btn",text:"\u21BB",title:"Another one"}).addEventListener("click",b)};b()}var xo=null;async function sp(){if(xo)return xo;let s=await Promise.resolve().then(()=>(Bl(),Nl));return s.Chart.register(s.LineController,s.LineElement,s.PointElement,s.LinearScale,s.CategoryScale,s.Filler,s.Tooltip),xo=s,s}async function zl(s,t){var j,U,K;let e=s.getDateCol();if(!e){t.createEl("p",{text:"No date column detected.",cls:"csv-empty-state"});return}let n=s.getBooleanColumns(),i=s.getNotesCol(),o=s.formatDate(new Date),r=[...s.rows].sort(($,N)=>{var B,H;return((B=$[e])!=null?B:"").localeCompare((H=N[e])!=null?H:"")});s.selectedDate||(s.selectedDate=o);let a=r.find($=>$[e]===s.selectedDate),l=s.selectedDate===o;t.addClass("csv-dashboard");let c=[...new Set([...r.map($=>$[e]),o])].filter(Boolean).sort(),d=t.createDiv({cls:"csv-dash-nav"});d.createEl("button",{cls:"csv-dash-nav-btn csv-dash-back-btn",text:"\u25C0"}).addEventListener("click",()=>{let $=c.indexOf(s.selectedDate);if($>0)s.selectedDate=c[$-1],s.renderView();else if($===-1&&c.length>0){let N=c.filter(B=>B0&&(s.selectedDate=N[N.length-1],s.renderView())}});let u=d.createDiv({cls:"csv-dash-date"});l&&u.createSpan({cls:"csv-dash-today-dot"});let f=u.createEl("select",{cls:"csv-dash-date-select"});if(c.forEach($=>{let N=f.createEl("option",{text:$,value:$});$===s.selectedDate&&(N.selected=!0)}),f.addEventListener("change",()=>{s.selectedDate=f.value,s.renderView()}),d.createEl("button",{cls:"csv-dash-nav-btn",text:"\u25B6"}).addEventListener("click",()=>{let $=c.indexOf(s.selectedDate);if($>=0&&$B>s.selectedDate);N.length>0&&(s.selectedDate=N[0],s.renderView())}}),l||d.createEl("button",{cls:"csv-dash-today-btn",text:"Today"}).addEventListener("click",()=>{s.selectedDate=o,s.renderView()}),!a){let $=t.createDiv({cls:"csv-dash-add-section"});$.createEl("p",{text:`No entry for ${s.selectedDate}`}),$.createEl("button",{cls:"csv-dash-add-btn",text:`+ Add entry for ${s.selectedDate}`}).addEventListener("click",()=>{let B={};s.headers.forEach(H=>B[H]=""),B[e]=s.selectedDate,s.rows.push(B),s.scheduleSave(),s.renderView()})}if(a){let $=t.createDiv({cls:"csv-dash-habits"});$.createEl("h3",{text:s.selectedDate===o?"Today":s.selectedDate,cls:"csv-dash-section-title"});let N=$.createDiv({cls:"csv-dash-habits-grid"});n.forEach(H=>{let F=s.isTruthy(a[H]),G=N.createDiv({cls:`csv-dash-habit ${F?"checked":""}`}),Y=G.createEl("button",{cls:"csv-dash-habit-check",text:F?"\u25CF":"\u25CB"});G.createSpan({cls:"csv-dash-habit-label",text:H}),Y.addEventListener("click",()=>{a[H]=F?"0":"1",s.scheduleSave(),s.renderViewPreservingScroll()})});let B=n.filter(H=>s.isTruthy(a[H])).length;if($.createDiv({cls:"csv-dash-habits-count",text:`${B} of ${n.length} complete`}),i&&((j=a[i])!=null&&j.trim())){let H=$.createDiv({cls:"csv-dash-notes-preview"});H.createEl("strong",{text:"Notes: "}),H.createSpan({text:a[i].slice(0,200)+(a[i].length>200?"\u2026":"")})}}let g=t.createDiv({cls:"csv-dash-chart-section"});g.createEl("h3",{text:"Progress",cls:"csv-dash-section-title"});let b=g.createDiv({cls:"csv-dash-chart-wrap"}).createEl("canvas",{cls:"csv-dash-chart"}),x=r.map($=>{var B;return((B=$[e])!=null?B:"").slice(5)}),_=r.map($=>n.filter(N=>s.isTruthy($[N])).length);s.chartInstance&&(s.chartInstance.destroy(),s.chartInstance=null);let{Chart:E}=await sp();if(!b.isConnected)return;s.chartInstance=new E(b,{type:"line",data:{labels:x,datasets:[{label:"Habits done",data:_,borderColor:"#378ADD",backgroundColor:"rgba(55,138,221,0.08)",borderWidth:1.5,pointRadius:3,tension:.3,fill:!0}]},options:{responsive:!0,maintainAspectRatio:!1,scales:{y:{min:0,max:n.length||8,ticks:{stepSize:1}}},plugins:{tooltip:{enabled:!0}}}});let S=t.createDiv({cls:"csv-dash-stats-section"});S.createEl("h3",{text:"Stats",cls:"csv-dash-section-title"});let v=r.length,y=r.reduce(($,N)=>$+n.filter(B=>s.isTruthy(N[B])).length,0),C=v>0?(y/v).toFixed(1):"0",D=r.filter($=>n.every(N=>s.isTruthy($[N]))).length,M=0,w=0,L=null;for(let $ of r){let N=n.filter(F=>s.isTruthy($[F])).length,B=s.parseDate((U=$[e])!=null?U:""),H=!0;L&&B&&Math.round((B.getTime()-L.getTime())/864e5)!==1&&(H=!1),N>=1&&(H||L===null)?(w++,w>M&&(M=w)):N>=1?(w=1,w>M&&(M=w)):w=0,L=B}let k=0,A=new Date;A.setHours(0,0,0,0);let P=A;for(let $=r.length-1;$>=0;$--){let N=s.parseDate((K=r[$][e])!=null?K:"");if(!N)break;let B=Math.round((P.getTime()-N.getTime())/(1e3*60*60*24));if(k===0&&B>1||k>0&&B!==1)break;if(n.filter(F=>s.isTruthy(r[$][F])).length>=1)k++,P=N;else break}let I=S.createDiv({cls:"csv-dash-stats-bar"});I.innerHTML=`${v} days logged \xB7 ${C} avg/day \xB7 ${D} perfect days \xB7 current streak ${k}d \xB7 best streak ${M}d`;let R=t.createDiv({cls:"csv-dash-cards-section"}).createDiv({cls:"csv-dash-cards-grid"}),V=new Date().getFullYear(),T={language:"\u25CB",read:"\u2261",gym:"\u229E",vitamins:"\u2299",cardio:"\u2191",meditate:"\u25CE",challenge:"\u273F",journal:"\u270E",exercise:"\u229E",water:"\u{1F4A7}",sleep:"\u{1F319}",study:"\u{1F4DA}"};n.map($=>{let N=r.filter(Y=>s.isTruthy(Y[$])),B=N.length>0?N[N.length-1][e]:null,H=new Set;N.forEach(Y=>{var X;let Z=s.parseDate((X=Y[e])!=null?X:"");Z&&H.add(Z.getFullYear())});let F=r.filter(Y=>{var X;let Z=s.parseDate((X=Y[e])!=null?X:"");return Z&&Z.getFullYear()===V}),G=F.filter(Y=>s.isTruthy(Y[$])).length;return{habit:$,doneCount:N.length,doneThisYear:G,totalThisYear:F.length,lastDone:B,years:Array.from(H).sort()}}).sort(($,N)=>!$.lastDone&&!N.lastDone?0:$.lastDone?N.lastDone?N.lastDone.localeCompare($.lastDone):-1:1).forEach(({habit:$,doneCount:N,doneThisYear:B,totalThisYear:H,lastDone:F,years:G})=>{var st;let Y=R.createDiv({cls:"csv-dash-habit-card"}),Z=(st=T[$.toLowerCase()])!=null?st:"\u25CB",X=Y.createDiv({cls:"csv-dash-habit-card-header"});if(X.createSpan({cls:"csv-dash-habit-icon",text:Z}),X.createSpan({cls:"csv-dash-habit-card-name",text:kt($)}),G.length>0&&Y.createDiv({cls:"csv-dash-habit-years"}).setText(G.join(" \xB7 ")),Y.createDiv({cls:"csv-dash-habit-card-thisyear",text:`${B} of ${H} complete this year`}),Y.createDiv({cls:"csv-dash-habit-card-alltime",text:`${N} of ${v} all time`}),F){let at=s.parseDate(F),Rt=at?at.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):F;Y.createDiv({cls:"csv-dash-habit-card-last",text:`Last logged: ${Rt}`})}else Y.createDiv({cls:"csv-dash-habit-card-last",text:"Never logged"});let q=v>0?N/v*100:0,J=Y.createDiv({cls:"csv-dash-habit-progress"}).createDiv({cls:"csv-dash-habit-progress-bar"});J.style.width=`${q}%`,Y.addEventListener("click",()=>{s.selectedHabit=s.selectedHabit===$?null:$,s.renderViewPreservingScroll()}),s.selectedHabit===$&&Y.addClass("selected")}),s.selectedHabit&&n.includes(s.selectedHabit)&&np(s,t,r,e,s.selectedHabit)}function np(s,t,e,n,i){var M,w,L;let o=t.createDiv({cls:"csv-dash-timeline-section"}),r=o.createDiv({cls:"csv-dash-timeline-header"});r.createEl("h3",{text:`${kt(i)} Timeline`,cls:"csv-dash-section-title"});let a=r.createEl("select",{cls:"csv-dash-year-select"}),l=new Set;e.forEach(k=>{var P;let A=s.parseDate((P=k[n])!=null?P:"");A&&l.add(A.getFullYear())}),l.add(new Date().getFullYear()),Array.from(l).sort().reverse().forEach(k=>{let A=a.createEl("option",{text:String(k),value:String(k)});k===s.timelineYear&&(A.selected=!0)}),a.addEventListener("change",()=>{s.timelineYear=parseInt(a.value),s.renderViewPreservingScroll()}),r.createEl("button",{cls:"csv-dash-timeline-close",text:"\u2715"}).addEventListener("click",()=>{s.selectedHabit=null,s.renderViewPreservingScroll()});let d=new Map;e.forEach(k=>{var A;d.set((A=k[n])!=null?A:"",s.isTruthy(k[i]))});let h=o.createDiv({cls:"csv-dash-timeline-grid-wrap"}),u=h.createDiv({cls:"csv-dash-timeline-months"});["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].forEach(k=>u.createSpan({cls:"csv-dash-timeline-month-label",text:k}));let p=h.createDiv({cls:"csv-dash-timeline-calendar"}),g=p.createDiv({cls:"csv-dash-timeline-day-labels"});for(let k=1;k<=31;k++)g.createDiv({cls:"csv-dash-timeline-day-label",text:k%5===0||k===1?String(k):""});for(let k=0;k<12;k++){let A=p.createDiv({cls:"csv-dash-timeline-month-col"}),P=new Date(s.timelineYear,k+1,0).getDate();for(let I=1;I<=31;I++){if(I>P){A.createDiv({cls:"csv-dash-timeline-cell empty"});continue}let z=`${s.timelineYear}-${String(k+1).padStart(2,"0")}-${String(I).padStart(2,"0")}`,R=(M=d.get(z))!=null?M:!1,V=d.has(z),T=new Date(s.timelineYear,k,I)>new Date,O=A.createDiv({cls:`csv-dash-timeline-cell ${T?"future":""} ${R?"done":""} ${V&&!R?"missed":""} ${!V&&!T?"no-entry":""}`});O.title=`${z}: ${T?"Future":R?"\u2713 Done":V?"\u2717 Missed":"No entry"}`}}let m=e.filter(k=>{var P;let A=s.parseDate((P=k[n])!=null?P:"");return A&&A.getFullYear()===s.timelineYear}),b=m.filter(k=>s.isTruthy(k[i])).length,x=m.length,_=0,E=0,S=0,v=null;for(let k of e){let A=s.isTruthy(k[i]),P=s.parseDate((w=k[n])!=null?w:""),I=!0;v&&P&&Math.round((P.getTime()-v.getTime())/864e5)!==1&&(I=!1),A&&(I||v===null)?(S++,S>E&&(E=S)):A?S=1:S=0,v=P}let y=new Date;y.setHours(0,0,0,0);let C=y;for(let k=e.length-1;k>=0;k--){let A=s.parseDate((L=e[k][n])!=null?L:"");if(!A)break;let P=Math.round((C.getTime()-A.getTime())/(1e3*60*60*24));if(_===0&&P>1||_>0&&P!==1)break;if(s.isTruthy(e[k][i]))_++,C=A;else break}let D=o.createDiv({cls:"csv-dash-timeline-stats"});D.innerHTML=`${b} of ${x} in ${s.timelineYear} \xB7 current streak ${_}d \xB7 best streak ${E}d`}function Hl(s,t){var x,_;let e=s.getFilteredRows();if(s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${e.length} of ${s.rows.length} entries`}),!e.length){let E=t.createDiv({cls:"csv-empty-state"});E.createEl("p",{text:s.searchQuery?"No matching entries found.":"No entries yet."}),s.searchQuery&&E.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear search"}).addEventListener("click",()=>{s.searchQuery="",s.renderView()});return}s.focusIndex>=e.length&&(s.focusIndex=e.length-1),s.focusIndex<0&&(s.focusIndex=0);let n=e[s.focusIndex],i=(x=s.titleKey())!=null?x:s.headers[0],o=s.getNotesCol(),r=s.authorKey(),a=t.createDiv({cls:"csv-focus-wrap",attr:{tabindex:"0"}}),l=E=>{s.focusIndex=(E%e.length+e.length)%e.length,s.focusNavPending=!0,s.renderView(!0)},c=a.createDiv({cls:"csv-focus-card"});c.createDiv({cls:"csv-focus-position",text:`${s.focusIndex+1} / ${e.length}`});let d=c.createDiv({cls:"csv-focus-title",text:s.getTitle(n)});o&&(d.addClass("is-clickable"),d.title="Open entry",d.addEventListener("click",()=>s.openNoteExpander(n,o)));let h=s.getSubtitle(n);if(h&&c.createDiv({cls:"csv-focus-sub",text:h}),o&&o!==i&&((_=n[o])!=null&&_.trim())){let E=c.createDiv({cls:"csv-focus-notes"});s.renderMarkdownInto(E,n[o])}let u=new Set([i,o,r].filter(Boolean)),f=s.headers.filter(E=>{var S;return!u.has(E)&&((S=n[E])!=null?S:"").trim()});if(f.length){let E=c.createDiv({cls:"csv-focus-meta"});f.forEach(S=>{let v=E.createDiv({cls:"csv-kanban-chip"});if(v.createSpan({cls:"csv-chip-label",text:S+": "}),s.isSelectCol(S)){let y=v.createSpan({cls:"csv-chip-value csv-chip-select",text:n[S]});y.addEventListener("click",C=>{C.stopPropagation(),Ot(y,n[S],s.getColumnValues(S),D=>{n[S]=D,y.setText(D||"\u2014"),s.scheduleSave()},s.contentEl,{multi:It(S)})})}else v.createSpan({cls:"csv-chip-value",text:n[S]})})}c.addEventListener("contextmenu",E=>s.openRowContextMenu(n,E));let p=a.createDiv({cls:"csv-focus-nav"}),g=p.createEl("button",{cls:"csv-focus-nav-btn",text:"\u2039",title:"Previous (\u2190)"}),m=p.createEl("button",{cls:"csv-focus-nav-btn csv-focus-nav-rand",text:"\u{1F500}",title:"Random entry"}),b=p.createEl("button",{cls:"csv-focus-nav-btn",text:"\u203A",title:"Next (\u2192)"});g.addEventListener("click",()=>l(s.focusIndex-1)),b.addEventListener("click",()=>l(s.focusIndex+1)),m.addEventListener("click",()=>{if(e.length<2)return;let E=s.focusIndex;for(;E===s.focusIndex;)E=Math.floor(Math.random()*e.length);l(E)}),a.addEventListener("keydown",E=>{E.key==="ArrowLeft"?(E.preventDefault(),l(s.focusIndex-1)):E.key==="ArrowRight"&&(E.preventDefault(),l(s.focusIndex+1))}),(s.focusNavPending||document.activeElement===document.body)&&(s.focusNavPending=!1,a.focus({preventScroll:!0}))}var Pt=require("obsidian"),Wl=Xs(vs());var ip=[{id:"table",label:"Table"},{id:"library",label:"Cards"},{id:"kanban-genre",label:"Kanban"}];function $l(s){return s&&typeof s=="object"&&"basename"in s?s:null}function op(s){let t=s.split(` +${hi}`}async function tr(s){var c,d,h,u,f,p,g,b,m,x;if(!s.file)return;let t=(d=(c=s.file.parent)==null?void 0:c.path)!=null?d:"",e=t?`${t}/Mobile`:"Mobile";await s.app.vault.adapter.exists(e)||await s.app.vault.adapter.mkdir(e);let n=`${e}/${s.file.basename}.md`,i=s.file.path,o=s.getDateCol(),r=s.getCategoryCol(),a="../"+s.file.name,l;if(o){let _=s.getBooleanColumns();l=Qo({filePath:a,csvPath:i,habitCols:_,labels:_.map(kt),dateCol:o})}else if(r){let _=(f=(u=(h=s.titleKey())!=null?h:s.resolveCol(["Quote","quote","Headline","headline","Phrase","phrase"]))!=null?u:s.headers[0])!=null?f:"Title";l=Zo({filePath:a,csvPath:i,titleKey:_,categoryCol:r,statusCol:(p=s.getStatusCol())!=null?p:"Status",authorKey:(g=s.authorKey())!=null?g:"",yearCol:(b=s.resolveCol(["Year","year","Released","released"]))!=null?b:"",ratingCol:(m=s.resolveCol(["Rating","rating","Score","score","Stars","stars"]))!=null?m:"",themeCol:(x=s.resolveCol(["Theme","theme","Subgenre","subgenre","Mood","mood"]))!=null?x:"",compactGrid:s.titleKey()!==null})}else l=Jo({filePath:a,csvPath:i,headers:s.headers});try{let _=s.app.vault.getAbstractFileByPath(n);_&&_ instanceof Me.TFile?(await s.app.vault.modify(_,l),new Me.Notice(`Updated: ${n}`)):(await s.app.vault.create(n,l),new Me.Notice(`Created: ${n}`))}catch(_){let w=s.app.vault.getAbstractFileByPath(n);w instanceof Me.TFile&&(await s.app.vault.modify(w,l),new Me.Notice(`Updated: ${n}`))}}var he=require("obsidian"),Sc="http://127.0.0.1:8765",Ec=6;async function er(s,t){let e;try{e=await(0,he.requestUrl)({url:Sc,method:"POST",contentType:"application/json",body:JSON.stringify({action:s,version:Ec,params:t}),throw:!1})}catch(i){throw new Error("Couldn't reach Anki. Is the desktop app open with the AnkiConnect add-on installed?")}let n=e.json;if(n.error)throw new Error(n.error);return n.result}function wc(s){var e,n,i;let t=s.fileCfg.ankiFrontCol;return t&&s.headers.includes(t)?t:(i=(n=(e=s.titleKey())!=null?e:s.resolveCol(["Quote","Headline","Phrase","Term","Word","Question","Front","Name","Title"]))!=null?n:s.headers[0])!=null?i:null}function ui(s){return s.replace(/&/g,"&").replace(//g,">")}function kc(s,t,e){return s.headers.filter(n=>{var i;return n!==e&&((i=t[n])!=null?i:"").trim()}).map(n=>`${ui(n)}: ${ui(t[n].trim())}`).join("
")}async function sr(s){if(!s.file)return;let t=wc(s);if(!t){new he.Notice("No column to use as the Anki card front.",6e3);return}let e=s.file.basename,n=s.rows.filter(o=>{var r;return((r=o[t])!=null?r:"").trim()});if(!n.length){new he.Notice(`Nothing to sync \u2014 no rows with a "${t}" value.`,6e3);return}let i=new he.Notice(`Syncing ${n.length} cards to Anki deck \u201C${e}\u201D\u2026`,0);try{await er("createDeck",{deck:e});let o=n.map(c=>({deckName:e,modelName:"Basic",fields:{Front:ui(c[t].trim()),Back:kc(s,c,t)},options:{allowDuplicate:!1,duplicateScope:"deck"},tags:["datadeck"]})),r=await er("addNotes",{notes:o}),a=r.filter(c=>c!=null).length,l=r.length-a;i.hide(),new he.Notice(`Anki sync: ${a} added${l?`, ${l} already present`:""} (deck \u201C${e}\u201D).`,6e3)}catch(o){i.hide(),new he.Notice(`Anki sync failed: ${o instanceof Error?o.message:String(o)}`,8e3)}}function un(s){return s.resolveCol(["Type","type","Kind","kind","Item","item"])}function pi(s){var t;return(t=s.resolveCol(["Project","project","Projects","projects","Area","area"]))!=null?t:Bt(s)}function rr(s){return s.resolveCol(["Due","due","Deadline","deadline","Due Date","Due date","due date"])}function fn(s){return s.resolveCol(["Priority","priority","Prio","prio","Importance","importance"])}var Mc=["task","todo","to-do","action",""],Dc=["task","todo","to-do","action","note","idea","reference","ref"],ar=["done","complete","completed","finished","closed","resolved","yes","x","\u2713","true"],Tc={high:0,med:1,medium:1,normal:1,low:2};function Ge(s){if(rr(s)||fn(s))return!0;let t=un(s);return t?s.rows.some(e=>{var n;return Dc.includes(((n=e[t])!=null?n:"").trim().toLowerCase())}):!1}function Lc(s,t,e){var n;return e?Mc.includes(((n=t[e])!=null?n:"").trim().toLowerCase()):!0}function Ac(s,t,e){if(Lc(s,t,e))return"task";let n=(e?t[e]:"").trim().toLowerCase();return n==="idea"||n==="ideas"?"idea":"note"}function Ye(s,t,e){var n;return e?ar.includes(((n=t[e])!=null?n:"").trim().toLowerCase()):!1}function nr(s){let t=Tc[(s!=null?s:"").trim().toLowerCase()];return t===void 0?3:t}function ir(s){return(s!=null?s:"").trim()?0:1}function Pc(){return new Date().toISOString().slice(0,10)}function Rc(s,t){let e=new Map;s.rows.forEach(o=>{var a,l;let r=((a=o[t])!=null?a:"").trim();r&&ar.includes(r.toLowerCase())&&e.set(r,((l=e.get(r))!=null?l:0)+1)});let n="done",i=0;return e.forEach((o,r)=>{o>i&&(n=r,i=o)}),n}function lr(s,t){var M;let e=pi(s),n=un(s),i=s.getStatusCol(),o=rr(s),r=fn(s),a=(M=s.titleKey())!=null?M:s.headers[0],l=t.createDiv({cls:"csv-library-filters"}),c=new Set;e&&s.rows.forEach(D=>{var E;((E=D[e])!=null?E:"").split(",").map(L=>L.trim()).filter(Boolean).forEach(L=>c.add(L))});let d=l.createEl("select",{cls:"csv-library-filter-select"});d.createEl("option",{text:e?"All projects":"All",value:"all"}),Array.from(c).sort().forEach(D=>d.createEl("option",{text:D,value:D})),d.value=s.taskProjectFilter;let h=new Set;n&&s.rows.forEach(D=>{var L;let E=((L=D[n])!=null?L:"").trim();E&&h.add(E)});let u=null;h.size>0&&(u=l.createEl("select",{cls:"csv-library-filter-select"}),u.createEl("option",{text:"All types",value:"all"}),Array.from(h).sort().forEach(D=>u.createEl("option",{text:D,value:D})),u.value=s.taskTypeFilter);let f=()=>{s.taskProjectFilter=d.value,u&&(s.taskTypeFilter=u.value),s.renderView(!0)};d.addEventListener("change",f),u==null||u.addEventListener("change",f);let p=s.searchQuery.toLowerCase().trim(),g=s.rows.filter(D=>{var E,L;return!(s.taskProjectFilter!=="all"&&e&&!((E=D[e])!=null?E:"").split(",").map(A=>A.trim().toLowerCase()).includes(s.taskProjectFilter.toLowerCase())||s.taskTypeFilter!=="all"&&n&&((L=D[n])!=null?L:"").trim().toLowerCase()!==s.taskTypeFilter.toLowerCase()||p&&!s.headers.some(k=>{var A;return((A=D[k])!=null?A:"").toLowerCase().includes(p)}))});(s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all"||p)&&t.createDiv({cls:"csv-library-result-count",text:`Showing ${g.length} of ${s.rows.length} entries`});let b={},m={},x={},_={task:b,note:m,idea:x},w=D=>{var L;return e&&((L=D[e])!=null?L:"").split(",").map(k=>k.trim()).filter(Boolean)[0]||"\u2014"};g.forEach(D=>{var k;let E=_[Ac(s,D,n)],L=w(D);((k=E[L])!=null?k:E[L]=[]).push(D)});let S=t.createDiv({cls:"csv-tasks"}),y=Pc(),v=i?Rc(s,i):"done";fi(S,"Tasks",b,(D,E)=>{E.sort((L,k)=>{var I,z,F,N,H,T;let A=Ye(s,L,i),P=Ye(s,k,i);if(A!==P)return A?1:-1;if(r){let j=nr((I=L[r])!=null?I:"")-nr((z=k[r])!=null?z:"");if(j)return j}if(o){let j=ir((F=L[o])!=null?F:"")-ir((N=k[o])!=null?N:"");if(j)return j;let U=((H=L[o])!=null?H:"").localeCompare((T=k[o])!=null?T:"");if(U)return U}return s.getTitle(L).localeCompare(s.getTitle(k))}),E.forEach(L=>{var N;let k=Ye(s,L,i),A=D.createEl("tr"),P=A.createEl("td",{cls:"csv-tasks-check-cell"});if(i){let H=P.createEl("span",{cls:`csv-tasks-check ${k?"is-done":""}`,text:k?"\u2713":""});H.setAttr("title",k?"Mark not done":"Mark done"),H.addEventListener("click",T=>{T.stopPropagation(),L[i]=k?"":v,s.scheduleSave(),s.renderView(!0)})}or(s,A,L,a,k);let I=A.createEl("td",{cls:"csv-tasks-due"}),z=o?((N=L[o])!=null?N:"").slice(0,10):"";I.setText(z||"\u2014"),z&&!k&&z{var j;H.stopPropagation();let T=Array.from(new Set([...s.getColumnValues(r),"high","medium","low"]));Ot(F,(j=L[r])!=null?j:"",T,U=>{L[r]=U,s.scheduleSave(),s.renderView(!0)},s.contentEl)})),A.addEventListener("contextmenu",H=>s.openRowContextMenu(L,H))})},["","Name","Due","Priority"]);let C=(D,E)=>{E.sort((L,k)=>{let A=Ye(s,L,i),P=Ye(s,k,i);return A!==P?A?1:-1:s.getTitle(L).localeCompare(s.getTitle(k))}),E.forEach(L=>{let k=Ye(s,L,i),A=D.createEl("tr"),P=A.createEl("td",{cls:"csv-tasks-check-cell"});if(i){let F=P.createEl("span",{cls:`csv-tasks-check ${k?"is-done":""}`,text:k?"\u2713":""});F.setAttr("title",k?"Mark not done":"Mark done"),F.addEventListener("click",N=>{N.stopPropagation(),L[i]=k?"":v,s.scheduleSave(),s.renderView(!0)})}let I=n&&L[n]||"",z=A.createEl("td",{cls:"csv-tasks-type-cell"});I&&z.createSpan({cls:"csv-tasks-type-pill",text:I}),or(s,A,L,a,k),A.addEventListener("contextmenu",F=>s.openRowContextMenu(L,F))})};if(fi(S,"Notes",m,C,["","Type","Name"]),fi(S,"Ideas",x,C,["","Type","Name"]),Object.keys(b).length===0&&Object.keys(m).length===0&&Object.keys(x).length===0){let D=S.createDiv({cls:"csv-empty-state"});D.createEl("p",{text:p||s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all"?"No entries match your filters.":"No tasks yet."}),(p||s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all")&&D.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear filters"}).addEventListener("click",()=>{s.taskProjectFilter="all",s.taskTypeFilter="all",s.searchQuery="",s.renderView()})}}function fi(s,t,e,n,i){if(Object.keys(e).length===0)return;s.createDiv({cls:"csv-tasks-section-header",text:t});let o=s.createDiv({cls:"csv-tasks-section"});Object.keys(e).sort().forEach(r=>{let a=e[r],l=o.createEl("details",{cls:"csv-tasks-group"});l.open=!0;let c=l.createEl("summary",{cls:"csv-tasks-group-header"});c.innerHTML=`\u25B6 ${r} ${a.length}`;let d=l.createEl("table",{cls:"csv-tasks-table"}),u=d.createEl("thead").createEl("tr");i.forEach(p=>u.createEl("th",{text:p}));let f=d.createEl("tbody");n(f,a)})}function or(s,t,e,n,i){let o=t.createEl("td",{cls:"csv-tasks-name-cell"}),r=o.createSpan({cls:`csv-tasks-link ${i?"csv-tasks-done":""}`,text:e[n]||"Untitled"}),a=s.getNotesCol();r.addEventListener("click",()=>{a?s.openNoteExpander(e,a):s.openOrCreateNotes(e)});let l=s.notesFileExists(e),c=o.createEl("button",{cls:`csv-tasks-page-icon ${l?"exists":""}`,text:l?"\u{1F4C4}":"+"});c.setAttr("title",l?"Open page":"Create page"),c.addEventListener("click",d=>{d.stopPropagation(),s.openOrCreateNotes(e)})}function pn(s){let t=[];return s.isTravelFile()&&t.push({id:"travel",label:"Travel"}),s.hasDateColumn()&&t.push({id:"dashboard",label:"Dashboard"}),Ge(s)&&t.push({id:"tasks",label:"Tasks"}),Bt(s)&&(t.push({id:"library",label:"Cards"}),t.push({id:"kanban-genre",label:"Kanban"})),t.push({id:"table",label:"Table"}),s.rows.length>0&&t.push({id:"focus",label:"Focus"}),cn(s)&&t.push({id:"stats",label:"Stats"}),t}function cr(s,t){var f,p,g;let e=t.createDiv({cls:"csv-toolbar"});e.createDiv({cls:"csv-toolbar-title",text:(p=(f=s.file)==null?void 0:f.basename)!=null?p:""});let n=e.createDiv({cls:"csv-toolbar-controls"});n.createDiv({cls:"csv-row-count",text:`${s.rows.length} entries`});let i=n.createDiv({cls:"csv-mode-group"}),o=pn(s),r=i.createEl("select",{cls:"csv-mode-select",attr:{"aria-label":"View mode"}});if(o.forEach(({id:b,label:m})=>{let x=r.createEl("option",{text:m,value:b});s.mode===b&&(x.selected=!0)}),r.addEventListener("change",()=>{s.mode=r.value,s.renderView()}),s.mode!=="dashboard"){let b=n.createEl("button",{cls:"csv-cfg-btn csv-search-toggle",text:"\u{1F50D}",title:"Search"}),m=n.createDiv({cls:"csv-search-wrap"}),x=m.createDiv({cls:"csv-search-input-wrap"}),_=x.createEl("input",{cls:"csv-search-input",type:"text",placeholder:"Search...",value:s.searchQuery,attr:{inputmode:"search",enterkeyhint:"search",autocomplete:"off"}}),w=x.createEl("button",{cls:"csv-search-clear",text:"\xD7",title:"Clear search"});w.toggleClass("is-hidden",!s.searchQuery),m.createEl("button",{cls:"csv-search-done",text:"Done",title:"Dismiss keyboard"}).addEventListener("click",v=>{if(v.preventDefault(),!_.value){e.removeClass("csv-toolbar--search-expanded"),b.removeClass("has-query"),s.searchQuery="",s.renderView(!0);return}_.blur()});let y=null;_.addEventListener("input",v=>{s.searchQuery=v.target.value,w.toggleClass("is-hidden",!s.searchQuery),b.toggleClass("has-query",!!s.searchQuery),y!==null&&window.clearTimeout(y),y=window.setTimeout(()=>{y=null,s.renderView(!0)},120)}),_.addEventListener("keydown",v=>{v.key==="Enter"&&(v.preventDefault(),_.blur())}),w.addEventListener("click",()=>{s.searchQuery="",_.value="",w.addClass("is-hidden"),b.removeClass("has-query"),_.focus({preventScroll:!0}),s.renderView(!0)}),s.searchQuery&&b.addClass("has-query"),b.addEventListener("click",()=>{e.addClass("csv-toolbar--search-expanded"),_.focus({preventScroll:!0})})}if(s.mode==="table"&&s.hasDateColumn()){let b=(g=s.fileCfg.sortNewestFirst)!=null?g:!0;n.createEl("button",{cls:`csv-cfg-btn ${b?"active":""}`,text:b?"\u2193 Newest":"\u2191 Oldest",title:"Toggle sort order"}).addEventListener("click",()=>{var _;let x=s.fileCfg;x.sortNewestFirst=!((_=x.sortNewestFirst)==null||_),s.saveFileCfg(x),s.tableSortCol=null,s.renderViewPreservingScroll()})}let a=()=>{var b,m;new sn(s.app,s.headers,(m=(b=s.file)==null?void 0:b.path)!=null?m:"",s.fileCfg,s.autoDetectBooleanColumns(),pn(s),x=>{s.saveFileCfg(x),x.defaultMode&&(s.mode=x.defaultMode),s.renderView()},()=>s.headers,()=>s.fileCfg,x=>s.addColumn(x),x=>s.removeColumn(x)).open()},l=()=>tr(s),c=()=>s.backupToArchive(),d=()=>sr(s);n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u2699 Columns",title:"Configure columns for this file"}).addEventListener("click",a),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F4F1} Mobile",title:"Generate mobile dashboard with add form"}).addEventListener("click",l),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F4BE} Backup",title:"Copy this file to Archive/ with today's date"}).addEventListener("click",c),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F3B4} Anki",title:"Sync rows to Anki (needs Anki desktop + AnkiConnect)"}).addEventListener("click",d),n.createEl("button",{cls:"csv-add-btn",text:"+ Add"}).addEventListener("click",()=>s.openAddModal()),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-overflow",text:"\u22EF",title:"More actions"}).addEventListener("click",b=>{let m=new gn.Menu;m.addItem(x=>x.setTitle("Columns").setIcon("settings").onClick(a)),m.addItem(x=>x.setTitle("Mobile dashboard").setIcon("smartphone").onClick(l)),m.addItem(x=>x.setTitle("Backup").setIcon("save").onClick(c)),m.addItem(x=>x.setTitle("Sync to Anki").setIcon("layers").onClick(d)),m.addSeparator(),m.addItem(x=>x.setTitle("Built 2026-07-06 07:19").setIcon("info").setDisabled(!0)),m.showAtMouseEvent(b)}),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary csv-info-btn",text:"\u24D8",title:"Built 2026-07-06 07:19 \u2014 click to confirm"}).addEventListener("click",()=>new gn.Notice("datadeck \u2014 built 2026-07-06 07:19",4e3))}function Oc(s){return s&&typeof s=="object"&&"basename"in s?s:null}var Fc=["Author","author","By","by","Source","source","Speaker","speaker","Artist","artist","Director","director"];async function dr(s,t,e,n){var x,_,w;let i=t.split(` +`).map(S=>S.trim()).filter(Boolean),o=S=>{var y,v;return(v=(y=i.find(C=>C.startsWith(S+":")))==null?void 0:y.slice(S.length+1).trim())!=null?v:""},r=o("file");if(!r){e.createEl("p",{text:"Error: No file specified. Use: file: yourfile.csv",cls:"csv-add-error"});return}let a=s.vault.getAbstractFileByPath(n.sourcePath),l=(_=(x=a==null?void 0:a.parent)==null?void 0:x.path)!=null?_:"",c=We(r,l),d=Oc(s.vault.getAbstractFileByPath(c));if(!d){e.createEl("p",{text:`Error: File not found: ${c}`,cls:"csv-add-error"});return}let h=[],u=[];try{let S=Gt(await s.vault.read(d));h=S.headers,u=S.rows}catch(S){e.createEl("p",{text:`Error reading file: ${S}`,cls:"csv-add-error"});return}if(!u.length){e.createEl("p",{text:"No entries in file.",cls:"csv-add-error"});return}let f=o("field"),p=(w=h.find(S=>S.toLowerCase()===f.toLowerCase()))!=null?w:h[0],g=Fc.map(S=>h.find(y=>y===S)).find(Boolean),b=e.createDiv({cls:"csv-random-card"}),m=()=>{var E;b.empty();let S=u.filter(L=>{var k;return((k=L[p])!=null?k:"").trim()}),y=S.length?S:u,v=y[Math.floor(Math.random()*y.length)];b.createDiv({cls:"csv-random-text",text:v[p]||"\u2014"});let C=g?((E=v[g])!=null?E:"").trim():"";C&&b.createDiv({cls:"csv-random-sub",text:`\u2014 ${C}`});let M=b.createDiv({cls:"csv-random-foot"});M.createSpan({cls:"csv-random-src",text:d.basename}),M.createEl("button",{cls:"csv-random-btn",text:"\u21BB",title:"Another one"}).addEventListener("click",m)};m()}var xo=null;async function sp(){if(xo)return xo;let s=await Promise.resolve().then(()=>(Bl(),Nl));return s.Chart.register(s.LineController,s.LineElement,s.PointElement,s.LinearScale,s.CategoryScale,s.Filler,s.Tooltip),xo=s,s}async function zl(s,t){var j,U,G;let e=s.getDateCol();if(!e){t.createEl("p",{text:"No date column detected.",cls:"csv-empty-state"});return}let n=s.getBooleanColumns(),i=s.getNotesCol(),o=s.formatDate(new Date),r=[...s.rows].sort((O,V)=>{var W,R;return((W=O[e])!=null?W:"").localeCompare((R=V[e])!=null?R:"")});s.selectedDate||(s.selectedDate=o);let a=r.find(O=>O[e]===s.selectedDate),l=s.selectedDate===o;t.addClass("csv-dashboard");let c=[...new Set([...r.map(O=>O[e]),o])].filter(Boolean).sort(),d=t.createDiv({cls:"csv-dash-nav"});d.createEl("button",{cls:"csv-dash-nav-btn csv-dash-back-btn",text:"\u25C0"}).addEventListener("click",()=>{let O=c.indexOf(s.selectedDate);if(O>0)s.selectedDate=c[O-1],s.renderView();else if(O===-1&&c.length>0){let V=c.filter(W=>W0&&(s.selectedDate=V[V.length-1],s.renderView())}});let u=d.createDiv({cls:"csv-dash-date"});l&&u.createSpan({cls:"csv-dash-today-dot"});let f=u.createEl("select",{cls:"csv-dash-date-select"});if(c.forEach(O=>{let V=f.createEl("option",{text:O,value:O});O===s.selectedDate&&(V.selected=!0)}),f.addEventListener("change",()=>{s.selectedDate=f.value,s.renderView()}),d.createEl("button",{cls:"csv-dash-nav-btn",text:"\u25B6"}).addEventListener("click",()=>{let O=c.indexOf(s.selectedDate);if(O>=0&&OW>s.selectedDate);V.length>0&&(s.selectedDate=V[0],s.renderView())}}),l||d.createEl("button",{cls:"csv-dash-today-btn",text:"Today"}).addEventListener("click",()=>{s.selectedDate=o,s.renderView()}),!a){let O=t.createDiv({cls:"csv-dash-add-section"});O.createEl("p",{text:`No entry for ${s.selectedDate}`}),O.createEl("button",{cls:"csv-dash-add-btn",text:`+ Add entry for ${s.selectedDate}`}).addEventListener("click",()=>{let W={};s.headers.forEach(R=>W[R]=""),W[e]=s.selectedDate,s.rows.push(W),s.scheduleSave(),s.renderView()})}if(a){let O=t.createDiv({cls:"csv-dash-habits"});O.createEl("h3",{text:s.selectedDate===o?"Today":s.selectedDate,cls:"csv-dash-section-title"});let V=O.createDiv({cls:"csv-dash-habits-grid"});n.forEach(R=>{let B=s.isTruthy(a[R]),K=V.createDiv({cls:`csv-dash-habit ${B?"checked":""}`}),Y=K.createEl("button",{cls:"csv-dash-habit-check",text:B?"\u25CF":"\u25CB"});K.createSpan({cls:"csv-dash-habit-label",text:R}),Y.addEventListener("click",()=>{a[R]=B?"0":"1",s.scheduleSave(),s.renderViewPreservingScroll()})});let W=n.filter(R=>s.isTruthy(a[R])).length;if(O.createDiv({cls:"csv-dash-habits-count",text:`${W} of ${n.length} complete`}),i&&((j=a[i])!=null&&j.trim())){let R=O.createDiv({cls:"csv-dash-notes-preview"});R.createEl("strong",{text:"Notes: "}),R.createSpan({text:a[i].slice(0,200)+(a[i].length>200?"\u2026":"")})}}let g=t.createDiv({cls:"csv-dash-chart-section"});g.createEl("h3",{text:"Progress",cls:"csv-dash-section-title"});let m=g.createDiv({cls:"csv-dash-chart-wrap"}).createEl("canvas",{cls:"csv-dash-chart"}),x=r.map(O=>{var W;return((W=O[e])!=null?W:"").slice(5)}),_=r.map(O=>n.filter(V=>s.isTruthy(O[V])).length);s.chartInstance&&(s.chartInstance.destroy(),s.chartInstance=null);let{Chart:w}=await sp();if(!m.isConnected)return;s.chartInstance=new w(m,{type:"line",data:{labels:x,datasets:[{label:"Habits done",data:_,borderColor:"#378ADD",backgroundColor:"rgba(55,138,221,0.08)",borderWidth:1.5,pointRadius:3,tension:.3,fill:!0}]},options:{responsive:!0,maintainAspectRatio:!1,scales:{y:{min:0,max:n.length||8,ticks:{stepSize:1}}},plugins:{tooltip:{enabled:!0}}}});let S=t.createDiv({cls:"csv-dash-stats-section"});S.createEl("h3",{text:"Stats",cls:"csv-dash-section-title"});let y=r.length,v=r.reduce((O,V)=>O+n.filter(W=>s.isTruthy(V[W])).length,0),C=y>0?(v/y).toFixed(1):"0",M=r.filter(O=>n.every(V=>s.isTruthy(O[V]))).length,D=0,E=0,L=null;for(let O of r){let V=n.filter(B=>s.isTruthy(O[B])).length,W=s.parseDate((U=O[e])!=null?U:""),R=!0;L&&W&&Math.round((W.getTime()-L.getTime())/864e5)!==1&&(R=!1),V>=1&&(R||L===null)?(E++,E>D&&(D=E)):V>=1?(E=1,E>D&&(D=E)):E=0,L=W}let k=0,A=new Date;A.setHours(0,0,0,0);let P=A;for(let O=r.length-1;O>=0;O--){let V=s.parseDate((G=r[O][e])!=null?G:"");if(!V)break;let W=Math.round((P.getTime()-V.getTime())/(1e3*60*60*24));if(k===0&&W>1||k>0&&W!==1)break;if(n.filter(B=>s.isTruthy(r[O][B])).length>=1)k++,P=V;else break}let I=S.createDiv({cls:"csv-dash-stats-bar"});I.innerHTML=`${y} days logged \xB7 ${C} avg/day \xB7 ${M} perfect days \xB7 current streak ${k}d \xB7 best streak ${D}d`;let F=t.createDiv({cls:"csv-dash-cards-section"}).createDiv({cls:"csv-dash-cards-grid"}),N=new Date().getFullYear(),H={language:"\u25CB",read:"\u2261",gym:"\u229E",vitamins:"\u2299",cardio:"\u2191",meditate:"\u25CE",challenge:"\u273F",journal:"\u270E",exercise:"\u229E",water:"\u{1F4A7}",sleep:"\u{1F319}",study:"\u{1F4DA}"};n.map(O=>{let V=r.filter(Y=>s.isTruthy(Y[O])),W=V.length>0?V[V.length-1][e]:null,R=new Set;V.forEach(Y=>{var Q;let q=s.parseDate((Q=Y[e])!=null?Q:"");q&&R.add(q.getFullYear())});let B=r.filter(Y=>{var Q;let q=s.parseDate((Q=Y[e])!=null?Q:"");return q&&q.getFullYear()===N}),K=B.filter(Y=>s.isTruthy(Y[O])).length;return{habit:O,doneCount:V.length,doneThisYear:K,totalThisYear:B.length,lastDone:W,years:Array.from(R).sort()}}).sort((O,V)=>!O.lastDone&&!V.lastDone?0:O.lastDone?V.lastDone?V.lastDone.localeCompare(O.lastDone):-1:1).forEach(({habit:O,doneCount:V,doneThisYear:W,totalThisYear:R,lastDone:B,years:K})=>{var st;let Y=F.createDiv({cls:"csv-dash-habit-card"}),q=(st=H[O.toLowerCase()])!=null?st:"\u25CB",Q=Y.createDiv({cls:"csv-dash-habit-card-header"});if(Q.createSpan({cls:"csv-dash-habit-icon",text:q}),Q.createSpan({cls:"csv-dash-habit-card-name",text:kt(O)}),K.length>0&&Y.createDiv({cls:"csv-dash-habit-years"}).setText(K.join(" \xB7 ")),Y.createDiv({cls:"csv-dash-habit-card-thisyear",text:`${W} of ${R} complete this year`}),Y.createDiv({cls:"csv-dash-habit-card-alltime",text:`${V} of ${y} all time`}),B){let at=s.parseDate(B),Rt=at?at.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):B;Y.createDiv({cls:"csv-dash-habit-card-last",text:`Last logged: ${Rt}`})}else Y.createDiv({cls:"csv-dash-habit-card-last",text:"Never logged"});let X=y>0?V/y*100:0,J=Y.createDiv({cls:"csv-dash-habit-progress"}).createDiv({cls:"csv-dash-habit-progress-bar"});J.style.width=`${X}%`,Y.addEventListener("click",()=>{s.selectedHabit=s.selectedHabit===O?null:O,s.renderViewPreservingScroll()}),s.selectedHabit===O&&Y.addClass("selected")}),s.selectedHabit&&n.includes(s.selectedHabit)&&np(s,t,r,e,s.selectedHabit)}function np(s,t,e,n,i){var D,E,L;let o=t.createDiv({cls:"csv-dash-timeline-section"}),r=o.createDiv({cls:"csv-dash-timeline-header"});r.createEl("h3",{text:`${kt(i)} Timeline`,cls:"csv-dash-section-title"});let a=r.createEl("select",{cls:"csv-dash-year-select"}),l=new Set;e.forEach(k=>{var P;let A=s.parseDate((P=k[n])!=null?P:"");A&&l.add(A.getFullYear())}),l.add(new Date().getFullYear()),Array.from(l).sort().reverse().forEach(k=>{let A=a.createEl("option",{text:String(k),value:String(k)});k===s.timelineYear&&(A.selected=!0)}),a.addEventListener("change",()=>{s.timelineYear=parseInt(a.value),s.renderViewPreservingScroll()}),r.createEl("button",{cls:"csv-dash-timeline-close",text:"\u2715"}).addEventListener("click",()=>{s.selectedHabit=null,s.renderViewPreservingScroll()});let d=new Map;e.forEach(k=>{var A;d.set((A=k[n])!=null?A:"",s.isTruthy(k[i]))});let h=o.createDiv({cls:"csv-dash-timeline-grid-wrap"}),u=h.createDiv({cls:"csv-dash-timeline-months"});["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].forEach(k=>u.createSpan({cls:"csv-dash-timeline-month-label",text:k}));let p=h.createDiv({cls:"csv-dash-timeline-calendar"}),g=p.createDiv({cls:"csv-dash-timeline-day-labels"});for(let k=1;k<=31;k++)g.createDiv({cls:"csv-dash-timeline-day-label",text:k%5===0||k===1?String(k):""});for(let k=0;k<12;k++){let A=p.createDiv({cls:"csv-dash-timeline-month-col"}),P=new Date(s.timelineYear,k+1,0).getDate();for(let I=1;I<=31;I++){if(I>P){A.createDiv({cls:"csv-dash-timeline-cell empty"});continue}let z=`${s.timelineYear}-${String(k+1).padStart(2,"0")}-${String(I).padStart(2,"0")}`,F=(D=d.get(z))!=null?D:!1,N=d.has(z),H=new Date(s.timelineYear,k,I)>new Date,T=A.createDiv({cls:`csv-dash-timeline-cell ${H?"future":""} ${F?"done":""} ${N&&!F?"missed":""} ${!N&&!H?"no-entry":""}`});T.title=`${z}: ${H?"Future":F?"\u2713 Done":N?"\u2717 Missed":"No entry"}`}}let b=e.filter(k=>{var P;let A=s.parseDate((P=k[n])!=null?P:"");return A&&A.getFullYear()===s.timelineYear}),m=b.filter(k=>s.isTruthy(k[i])).length,x=b.length,_=0,w=0,S=0,y=null;for(let k of e){let A=s.isTruthy(k[i]),P=s.parseDate((E=k[n])!=null?E:""),I=!0;y&&P&&Math.round((P.getTime()-y.getTime())/864e5)!==1&&(I=!1),A&&(I||y===null)?(S++,S>w&&(w=S)):A?S=1:S=0,y=P}let v=new Date;v.setHours(0,0,0,0);let C=v;for(let k=e.length-1;k>=0;k--){let A=s.parseDate((L=e[k][n])!=null?L:"");if(!A)break;let P=Math.round((C.getTime()-A.getTime())/(1e3*60*60*24));if(_===0&&P>1||_>0&&P!==1)break;if(s.isTruthy(e[k][i]))_++,C=A;else break}let M=o.createDiv({cls:"csv-dash-timeline-stats"});M.innerHTML=`${m} of ${x} in ${s.timelineYear} \xB7 current streak ${_}d \xB7 best streak ${w}d`}function Hl(s,t){var x,_;let e=s.getFilteredRows();if(s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${e.length} of ${s.rows.length} entries`}),!e.length){let w=t.createDiv({cls:"csv-empty-state"});w.createEl("p",{text:s.searchQuery?"No matching entries found.":"No entries yet."}),s.searchQuery&&w.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear search"}).addEventListener("click",()=>{s.searchQuery="",s.renderView()});return}s.focusIndex>=e.length&&(s.focusIndex=e.length-1),s.focusIndex<0&&(s.focusIndex=0);let n=e[s.focusIndex],i=(x=s.titleKey())!=null?x:s.headers[0],o=s.getNotesCol(),r=s.authorKey(),a=t.createDiv({cls:"csv-focus-wrap",attr:{tabindex:"0"}}),l=w=>{s.focusIndex=(w%e.length+e.length)%e.length,s.focusNavPending=!0,s.renderView(!0)},c=a.createDiv({cls:"csv-focus-card"});c.createDiv({cls:"csv-focus-position",text:`${s.focusIndex+1} / ${e.length}`});let d=c.createDiv({cls:"csv-focus-title",text:s.getTitle(n)});o&&(d.addClass("is-clickable"),d.title="Open entry",d.addEventListener("click",()=>s.openNoteExpander(n,o)));let h=s.getSubtitle(n);if(h&&c.createDiv({cls:"csv-focus-sub",text:h}),o&&o!==i&&((_=n[o])!=null&&_.trim())){let w=c.createDiv({cls:"csv-focus-notes"});s.renderMarkdownInto(w,n[o])}let u=new Set([i,o,r].filter(Boolean)),f=s.headers.filter(w=>{var S;return!u.has(w)&&((S=n[w])!=null?S:"").trim()});if(f.length){let w=c.createDiv({cls:"csv-focus-meta"});f.forEach(S=>{let y=w.createDiv({cls:"csv-kanban-chip"});if(y.createSpan({cls:"csv-chip-label",text:S+": "}),s.isSelectCol(S)){let v=y.createSpan({cls:"csv-chip-value csv-chip-select",text:n[S]});v.addEventListener("click",C=>{C.stopPropagation(),Ot(v,n[S],s.getColumnValues(S),M=>{n[S]=M,v.setText(M||"\u2014"),s.scheduleSave()},s.contentEl,{multi:It(S)})})}else y.createSpan({cls:"csv-chip-value",text:n[S]})})}c.addEventListener("contextmenu",w=>s.openRowContextMenu(n,w));let p=a.createDiv({cls:"csv-focus-nav"}),g=p.createEl("button",{cls:"csv-focus-nav-btn",text:"\u2039",title:"Previous (\u2190)"}),b=p.createEl("button",{cls:"csv-focus-nav-btn csv-focus-nav-rand",text:"\u{1F500}",title:"Random entry"}),m=p.createEl("button",{cls:"csv-focus-nav-btn",text:"\u203A",title:"Next (\u2192)"});g.addEventListener("click",()=>l(s.focusIndex-1)),m.addEventListener("click",()=>l(s.focusIndex+1)),b.addEventListener("click",()=>{if(e.length<2)return;let w=s.focusIndex;for(;w===s.focusIndex;)w=Math.floor(Math.random()*e.length);l(w)}),a.addEventListener("keydown",w=>{w.key==="ArrowLeft"?(w.preventDefault(),l(s.focusIndex-1)):w.key==="ArrowRight"&&(w.preventDefault(),l(s.focusIndex+1))}),(s.focusNavPending||document.activeElement===document.body)&&(s.focusNavPending=!1,a.focus({preventScroll:!0}))}var Pt=require("obsidian"),Wl=Xs(vs());var ip=[{id:"table",label:"Table"},{id:"library",label:"Cards"},{id:"kanban-genre",label:"Kanban"}];function $l(s){return s&&typeof s=="object"&&"basename"in s?s:null}function op(s){let t=s.split(` `).map(r=>r.trim()).filter(Boolean),e=r=>{var a,l;return(l=(a=t.find(c=>c.toLowerCase().startsWith(r+":")))==null?void 0:a.slice(r.length+1).trim())!=null?l:""},n=e("mode").toLowerCase(),i=n==="kanban"||n==="kanban-genre"?"kanban-genre":n==="cards"||n==="card"||n==="library"?"library":"table",o=parseInt(e("height"),10);return{file:e("file"),mode:i,height:Number.isFinite(o)&&o>0?o:null,collapse:e("collapse").split(",").map(r=>r.trim()).filter(Boolean)}}var _o=class extends Pt.MarkdownRenderChild{constructor(e,n,i,o,r){super(e);this.file=null;this.headers=[];this.rows=[];this.searchQuery="";this.tableSortCol=null;this.tableSortDir="asc";this.libraryStatusFilter="all";this.libraryGenreFilter="all";this.collapsedGroups=new Set;this.saveTimer=null;this.lastWritten=null;this.contentArea=null;this.app=n,this.settings=i,this.persistSettings=o,this.opts=r,this.mode=r.mode,this.collapsedGroups=new Set(r.collapse.map(a=>a.toLowerCase()))}get renderComponent(){return this}get contentEl(){return this.containerEl}get asView(){return this}async onload(){if(this.containerEl.addClass("csv-inline-view"),!this.opts.file){this.renderError("No file specified. Use: file: yourfile.csv");return}await this.reload()&&(this.renderView(),this.registerEvent(this.app.vault.on("modify",async e=>{if(!this.file||e.path!==this.file.path)return;let n=await this.app.vault.read(this.file);if(n===this.lastWritten)return;let i=Gt(n);this.headers=i.headers,this.rows=i.rows,this.renderView()})),this.registerEvent(this.app.vault.on("rename",(e,n)=>{this.file&&n===this.file.path&&(this.file=$l(e))})))}onunload(){this.saveTimer&&window.clearTimeout(this.saveTimer)}async reload(){let e=$l(this.app.vault.getAbstractFileByPath(this.opts.file));if(!e)return this.renderError(`File not found: ${this.opts.file}`),!1;this.file=e;try{let n=Gt(await this.app.vault.read(e));this.headers=n.headers,this.rows=n.rows}catch(n){return this.renderError(`Error reading file: ${n instanceof Error?n.message:String(n)}`),!1}return!0}renderError(e){this.containerEl.empty(),this.containerEl.createEl("p",{text:`csv-view: ${e}`,cls:"csv-add-error"})}scheduleSave(){this.saveTimer&&window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>void this.doSave(),600)}async doSave(){if(this.file)try{let e=Wl.default.unparse(this.rows,{columns:this.headers});this.lastWritten=e,await this.app.vault.modify(this.file,e)}catch(e){new Pt.Notice(`Couldn't save ${this.file.name}: ${e instanceof Error?e.message:String(e)}`,8e3)}}get fileCfg(){var e;return this.file?(e=this.settings.fileConfigs[this.file.path])!=null?e:{}:{}}saveFileCfg(e){this.file&&(this.settings.fileConfigs[this.file.path]=e,this.persistSettings())}resolveCol(e){for(let n of e){let i=this.headers.find(o=>o.toLowerCase()===n.toLowerCase());if(i)return i}return null}getNotesCol(){return this.fileCfg.notesColumn?this.fileCfg.notesColumn:this.resolveCol(["Notes","notes","Note","note","Summary","summary","Review","review","Quote","quote","Quotes","quotes","Comment","comment","Comments","comments","Description","description","Annotation","annotation"])}isNotesCol(e){let n=this.getNotesCol();return n?e===n:this.settings.notesColumns.some(i=>i.toLowerCase()===e.toLowerCase())}isSelectCol(e){return this.settings.selectColumns.some(n=>n.toLowerCase()===e.toLowerCase())}getStatusCol(){var e;return this.fileCfg.statusColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.statusColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Status","status","State","state","Progress","progress","Stage","stage","Read","read","Watched","watched","Seen","seen","Done","done","Completed","completed"])}getCategoryCol(){var e;return this.fileCfg.categoryColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.categoryColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Category","category","Categories","categories","Genre","genre","Genres","genres","Type","type","Types","types","Tag","tag","Tags","tags","Topic","topic","Topics","topics","Subject","subject","Section","section"])}titleKey(){var e;return(e=this.resolveCol(["Title","title","Name","name"]))!=null?e:void 0}authorKey(){var e;return(e=this.resolveCol(["Author","author","Authors","authors","Director","director","Artist","artist","Creator","creator","By","by"]))!=null?e:void 0}getTitle(e){var i;let n=this.titleKey();return(i=n?e[n]:e[this.headers[0]])!=null?i:"\u2014"}getSubtitle(e){var i;let n=this.authorKey();return n&&(i=e[n])!=null?i:""}getColumnValues(e){return Array.from(new Set(this.rows.map(n=>{var i;return(i=n[e])!=null?i:""}).filter(Boolean))).sort()}getImageCol(){var e;return this.fileCfg.imageColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.imageColumn.toLowerCase()))!=null?e:null:this.resolveCol(Zs)}getBooleanColumns(){var e;return(e=this.fileCfg.habitColumns)!=null&&e.length?this.fileCfg.habitColumns.filter(n=>this.headers.includes(n)):this.headers.filter(n=>{if(n===this.getDateCol()||this.isNotesCol(n))return!1;let i=this.rows.map(o=>{var r;return((r=o[n])!=null?r:"").toLowerCase().trim()});return tn(i)})}getDateCol(){if(this.headers.length===0)return null;let e=this.headers[0];if(["date","day","datum"].includes(e.toLowerCase()))return e;let n=/^\d{4}-\d{2}-\d{2}$/,i=this.rows.slice(0,5);return i.length>0&&i.every(o=>{var r;return n.test((r=o[e])!=null?r:"")})?e:null}getFilteredRows(){var i;let e=this.rows;if(this.searchQuery.trim()){let o=this.searchQuery.toLowerCase().trim();e=e.filter(r=>this.headers.some(a=>{var l;return((l=r[a])!=null?l:"").toLowerCase().includes(o)}))}if(this.mode==="table"&&this.tableSortCol&&this.headers.includes(this.tableSortCol)){let o=this.tableSortCol,r=this.tableSortDir;return[...e].sort((a,l)=>{var d,h;let c=((d=a[o])!=null?d:"").localeCompare((h=l[o])!=null?h:"",void 0,{numeric:!0});return r==="asc"?c:-c})}let n=this.getDateCol();if(this.mode==="table"&&n){let o=(i=this.fileCfg.sortNewestFirst)!=null?i:!0;e=[...e].sort((r,a)=>{var c,d;let l=((c=r[n])!=null?c:"").localeCompare((d=a[n])!=null?d:"");return o?-l:l})}return e}notesFilePath(e){var a,l,c;let n=xs(this.getTitle(e)),i=(c=(l=(a=this.file)==null?void 0:a.parent)==null?void 0:l.path)!=null?c:"",o=this.settings.notesSubfolder.trim(),r=o?i?`${i}/${o}`:o:i;return(0,Pt.normalizePath)(`${r}/${n}.md`)}notesFileExists(e){return!!this.app.vault.getAbstractFileByPath(this.notesFilePath(e))}async openOrCreateNotes(e){var o;let n=this.notesFilePath(e),i=this.app.vault.getAbstractFileByPath(n);if(!i){let a=["---",...this.headers.filter(h=>!this.isNotesCol(h)&&e[h]).map(h=>`${h}: "${e[h].replace(/"/g,'\\"')}"`),"---","",`# ${this.getTitle(e)}`,"",""].join(` `),l=this.headers.find(h=>this.isNotesCol(h)),c=a+(l&&((o=e[l])!=null&&o.trim())?e[l]:""),d=n.substring(0,n.lastIndexOf("/"));d&&!this.app.vault.getAbstractFileByPath(d)&&await this.app.vault.createFolder(d),i=await this.app.vault.create(n,c),new Pt.Notice(`Created: ${i.name}`)}await this.app.workspace.getLeaf("tab").openFile(i)}deleteWithUndo(e){let n=this.rows.indexOf(e);if(n<0)return;this.rows.splice(n,1),this.scheduleSave(),this.renderView();let i=this.getTitle(e)||"entry",o=document.createDocumentFragment();o.createSpan({text:`Deleted \u201C${i}\u201D. `});let r=o.createEl("button",{text:"Undo",cls:"csv-notice-undo"}),a=new Pt.Notice(o,6e3);r.addEventListener("click",()=>{r.hasAttribute("disabled")||(r.setAttribute("disabled","true"),this.rows.splice(Math.min(n,this.rows.length),0,e),this.scheduleSave(),this.renderView(),a.hide(),new Pt.Notice(`Restored \u201C${i}\u201D`,2500))})}openRowContextMenu(e,n){let i=new Pt.Menu;i.addItem(r=>r.setTitle("Open / Create Notes file").setIcon("file-text").onClick(()=>void this.openOrCreateNotes(e))),i.addItem(r=>r.setTitle("Open entry").setIcon("maximize").onClick(()=>{var a;return this.openNoteExpander(e,(a=this.getNotesCol())!=null?a:"")}));let o=this.getStatusCol();if(o){let r=this.getColumnValues(o);r.length&&(i.addSeparator(),r.forEach(a=>{a!==e[o]&&i.addItem(l=>l.setTitle(`Mark as: ${a}`).onClick(()=>{e[o]=a,this.scheduleSave(),this.renderView()}))}))}i.addSeparator(),i.addItem(r=>r.setTitle("Delete").setIcon("trash").onClick(()=>this.deleteWithUndo(e))),i.showAtMouseEvent(n)}openNoteExpander(e,n){var i,o;new Ue(this.app,e,n,this.headers,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),r=>{Object.assign(e,r),this.scheduleSave(),this.renderView()},()=>this.deleteWithUndo(e)).open()}openAddModal(){new je(this.app,this.headers,this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),e=>{this.rows.push(e),this.scheduleSave(),this.renderView(),new Pt.Notice(`Added: ${this.getTitle(e)}`)},{},e=>this.getBooleanColumns().includes(e)).open()}renderSelectField(e,n,i){var a;let o=(a=n[i])!=null?a:"",r=e.createDiv({cls:`csv-select-chip ${o?"":"empty"}`});return r.setText(o||"\u2014"),i.toLowerCase()==="status"&&o&&r.addClass(`status-chip-${o.toLowerCase().replace(/\s+/g,"-")}`),r.addEventListener("click",l=>{var c;l.stopPropagation(),Ot(r,(c=n[i])!=null?c:"",this.getColumnValues(i),d=>{n[i]=d,r.setText(d||"\u2014"),this.scheduleSave()},this.contentEl)}),r}renderMarkdownInto(e,n){var i,o;Pt.MarkdownRenderer.render(this.app,n,e,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.renderComponent)}renderViewPreservingScroll(){this.renderView()}renderView(e=!1){let n=this.containerEl;e?this.contentArea&&this.contentArea.empty():(n.empty(),this.renderToolbar(n),this.contentArea=n.createDiv({cls:"csv-content-area"}),this.opts.height&&(this.contentArea.style.maxHeight=this.opts.height+"px"));let i=this.contentArea;if(i){if(i.toggleClass("csv-content-area--no-yscroll",this.mode==="kanban-genre"||this.mode==="table"),!this.headers.length){i.createDiv({cls:"csv-empty-state"}).createEl("p",{text:"This file is empty."});return}if(this.rows.length===0){let o=i.createDiv({cls:"csv-empty-state"});o.createEl("p",{text:"No entries yet."}),o.createEl("button",{cls:"csv-empty-state-action",text:"+ Add the first entry"}).addEventListener("click",()=>this.openAddModal());return}(this.mode==="library"||this.mode==="kanban-genre")&&!Bt(this.asView)&&(this.mode="table"),this.mode==="library"?hn(this.asView,i):this.mode==="kanban-genre"?dn(this.asView,i):ln(this.asView,i)}}renderToolbar(e){var c,d;let n=e.createDiv({cls:"csv-toolbar csv-inline-toolbar"});n.createDiv({cls:"csv-toolbar-title",text:(d=(c=this.file)==null?void 0:c.basename)!=null?d:""}).addEventListener("click",()=>{this.file&&this.app.workspace.getLeaf("tab").openFile(this.file)});let i=n.createDiv({cls:"csv-toolbar-controls"});i.createDiv({cls:"csv-row-count",text:`${this.rows.length} entries`});let o=!!Bt(this.asView),r=i.createDiv({cls:"csv-mode-group"});ip.forEach(({id:h,label:u})=>{if((h==="library"||h==="kanban-genre")&&!o)return;r.createEl("button",{cls:`csv-mode-btn ${this.mode===h?"active":""}`,text:u}).addEventListener("click",()=>{this.mode=h,this.renderView()})});let a=i.createEl("input",{cls:"csv-search-input",type:"text",placeholder:"Search\u2026",value:this.searchQuery,attr:{inputmode:"search",enterkeyhint:"search",autocomplete:"off"}}),l=null;a.addEventListener("input",h=>{this.searchQuery=h.target.value,l!==null&&window.clearTimeout(l),l=window.setTimeout(()=>{l=null,this.renderView(!0)},120)}),i.createEl("button",{cls:"csv-add-btn",text:"+ Add"}).addEventListener("click",()=>this.openAddModal())}};function jl(s,t,e,n){n("csv-view",(i,o,r)=>{var h,u,f;let a=op(i),l=(f=(u=(h=s.vault.getAbstractFileByPath(r.sourcePath))==null?void 0:h.parent)==null?void 0:u.path)!=null?f:"",c=a.file?We(a.file,l):a.file,d=new _o(o,s,t,e,{...a,file:c});r.addChild(d)})}var qs,gs=class extends it.FileView{constructor(e,n,i){super(e);this.headers=[];this.rows=[];this.saveTimer=null;this.searchQuery="";this.contentArea=null;this.selectedDate=null;this.selectedHabit=null;this.chartInstance=null;this.timelineYear=new Date().getFullYear();this.libraryStatusFilter="all";this.libraryGenreFilter="all";this.collapsedGroups=new Set;this.taskProjectFilter="all";this.taskTypeFilter="all";this.focusIndex=0;this.focusNavPending=!1;this.tableSortCol=null;this.tableSortDir="asc";this.settings=n,this.persistSettings=i,this.mode=n.defaultMode,this.renderComponent=new it.Component,this.renderComponent.load()}getViewType(){return Qs}getDisplayText(){var e,n;return(n=(e=this.file)==null?void 0:e.basename)!=null?n:"Card View"}getIcon(){return"table"}async onLoadFile(e){var o;try{let r=await this.app.vault.read(e),a=Gt(r);this.headers=a.headers,this.rows=a.rows}catch(r){console.error("CardView load error",r),this.headers=[],this.rows=[],new it.Notice(`Couldn't read ${e.name}: ${r instanceof Error?r.message:String(r)}`,8e3)}this.file&&((o=this.settings.fileConfigs[this.file.path])!=null&&o.defaultMode)?this.mode=this.settings.fileConfigs[this.file.path].defaultMode:this.isTravelFile()?this.mode="travel":this.hasDateColumn()?this.mode="dashboard":this.mode=this.settings.defaultMode;let n=this.mode==="kanban-genre"||this.mode==="library",i=this.mode==="dashboard";(n&&!Bt(this)||i&&!this.hasDateColumn()||this.mode==="travel"&&!this.isTravelFile()||this.mode==="stats"&&!cn(this)||this.mode==="tasks"&&!Ge(this))&&(this.mode="table"),this.selectedDate=null,this.focusIndex=0,this.tableSortCol=null,this.renderView()}async onUnloadFile(e){this.chartInstance&&(this.chartInstance.destroy(),this.chartInstance=null),this.headers=[],this.rows=[],this.contentEl.empty()}scheduleSave(){this.saveTimer&&window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>this.doSave(),600)}async doSave(){if(this.file)try{let e=Ul.default.unparse(this.rows,{columns:this.headers});await this.app.vault.modify(this.file,e)}catch(e){console.error("CardView save error",e),new it.Notice(`Couldn't save ${this.file.name}: ${e instanceof Error?e.message:String(e)}`,8e3)}}get fileCfg(){var e;return this.file?(e=this.settings.fileConfigs[this.file.path])!=null?e:{}:{}}saveFileCfg(e){this.file&&(this.settings.fileConfigs[this.file.path]=e,this.persistSettings())}addColumn(e){let n=e.trim();return n?this.headers.some(i=>i.toLowerCase()===n.toLowerCase())?`"${n}" already exists.`:(this.headers.push(n),this.rows.forEach(i=>{i[n]=""}),this.scheduleSave(),this.renderViewPreservingScroll(),null):"Column name can't be empty."}removeColumn(e){this.headers=this.headers.filter(i=>i!==e),this.rows.forEach(i=>{delete i[e]});let n=this.fileCfg;n.categoryColumn===e&&(n.categoryColumn=void 0),n.statusColumn===e&&(n.statusColumn=void 0),n.notesColumn===e&&(n.notesColumn=void 0),n.ankiFrontCol===e&&(n.ankiFrontCol=void 0),n.kanbanGroupCol===e&&(n.kanbanGroupCol=void 0),n.habitColumns&&(n.habitColumns=n.habitColumns.filter(i=>i!==e)),n.cardFields&&(n.cardFields=n.cardFields.filter(i=>i!==e)),this.saveFileCfg(n),this.scheduleSave(),this.renderViewPreservingScroll()}resolveCol(e){for(let n of e){let i=this.headers.find(o=>o.toLowerCase()===n.toLowerCase());if(i)return i}return null}getNotesCol(){return this.fileCfg.notesColumn?this.fileCfg.notesColumn:this.resolveCol(["Notes","notes","Note","note","Summary","summary","Review","review","Quote","quote","Quotes","quotes","Comment","comment","Comments","comments","Description","description","Annotation","annotation"])}isNotesCol(e){let n=this.getNotesCol();return n?e===n:this.settings.notesColumns.some(i=>i.toLowerCase()===e.toLowerCase())}isSelectCol(e){return this.settings.selectColumns.some(n=>n.toLowerCase()===e.toLowerCase())}getStatusCol(){var e;return this.fileCfg.statusColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.statusColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Status","status","State","state","Progress","progress","Stage","stage","Read","read","Watched","watched","Seen","seen","Done","done","Completed","completed"])}getCategoryCol(){var e;return this.fileCfg.categoryColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.categoryColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Category","category","Categories","categories","Genre","genre","Genres","genres","Type","type","Types","types","Tag","tag","Tags","tags","Topic","topic","Topics","topics","Subject","subject","Section","section"])}titleKey(){var e;return(e=this.resolveCol(["Title","title","Name","name"]))!=null?e:void 0}authorKey(){var e;return(e=this.resolveCol(["Author","author","Authors","authors","Director","director","Artist","artist","Creator","creator","By","by"]))!=null?e:void 0}getTitle(e){var i;let n=this.titleKey();return(i=n?e[n]:e[this.headers[0]])!=null?i:"\u2014"}getSubtitle(e){var i;let n=this.authorKey();return n&&(i=e[n])!=null?i:""}getColumnValues(e){return Array.from(new Set(this.rows.map(n=>{var i;return(i=n[e])!=null?i:""}).filter(Boolean))).sort()}getImageCol(){var e;return this.fileCfg.imageColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.imageColumn.toLowerCase()))!=null?e:null:this.resolveCol(Zs)}notesFilePath(e){var a,l,c;let n=xs(this.getTitle(e)),i=(c=(l=(a=this.file)==null?void 0:a.parent)==null?void 0:l.path)!=null?c:"",o=this.settings.notesSubfolder.trim(),r=o?i?`${i}/${o}`:o:i;return(0,it.normalizePath)(`${r}/${n}.md`)}notesFileExists(e){return!!this.app.vault.getAbstractFileByPath(this.notesFilePath(e))}deleteWithUndo(e){let n=this.rows.indexOf(e);if(n<0)return;this.rows.splice(n,1),this.scheduleSave(),this.renderViewPreservingScroll();let i=this.getTitle(e)||"entry",o=document.createDocumentFragment();o.createSpan({text:`Deleted \u201C${i}\u201D. `});let r=o.createEl("button",{text:"Undo",cls:"csv-notice-undo"}),a=new it.Notice(o,6e3);r.addEventListener("click",()=>{if(r.hasAttribute("disabled"))return;r.setAttribute("disabled","true");let l=Math.min(n,this.rows.length);this.rows.splice(l,0,e),this.scheduleSave(),this.renderViewPreservingScroll(),a.hide(),new it.Notice(`Restored \u201C${i}\u201D`,2500)})}openRowContextMenu(e,n){let i=new it.Menu;i.addItem(r=>r.setTitle("Open / Create Notes file").setIcon("file-text").onClick(()=>this.openOrCreateNotes(e))),i.addItem(r=>r.setTitle("Open entry").setIcon("maximize").onClick(()=>{var a;return this.openNoteExpander(e,(a=this.getNotesCol())!=null?a:"")}));let o=this.getStatusCol();if(o){let r=this.getColumnValues(o);r.length&&(i.addSeparator(),r.forEach(a=>{a!==e[o]&&i.addItem(l=>l.setTitle(`Mark as: ${a}`).onClick(()=>{e[o]=a,this.scheduleSave(),this.renderViewPreservingScroll()}))}))}i.addSeparator(),i.addItem(r=>r.setTitle("Delete").setIcon("trash").onClick(()=>this.deleteWithUndo(e))),i.showAtMouseEvent(n)}async openOrCreateNotes(e){var o,r;let n=this.notesFilePath(e),i=this.app.vault.getAbstractFileByPath(n);if(!i){let a={},l=Ge(this)?pi(this):null,c=l?((o=e[l])!=null?o:"").split(",").map(p=>Do(p.trim())).filter(Boolean).map(p=>`project-${p}`):[];c.length&&(a.tags=c);for(let p of this.headers)!this.isNotesCol(p)&&e[p]&&(a[p]=e[p]);this.file&&!Object.keys(a).some(p=>p.toLowerCase()==="source")&&(a.source=`[[${this.file.path}]]`);let d=["---",(0,it.stringifyYaml)(a).trimEnd(),"---","",`# ${this.getTitle(e)}`,"",""].join(` -`),h=this.headers.find(p=>this.isNotesCol(p)),u=d+(h&&((r=e[h])!=null&&r.trim())?e[h]:""),f=n.substring(0,n.lastIndexOf("/"));f&&!this.app.vault.getAbstractFileByPath(f)&&await this.app.vault.createFolder(f),i=await this.app.vault.create(n,u),new it.Notice(`Created: ${i.name}`)}await this.app.workspace.getLeaf("tab").openFile(i)}openNoteExpander(e,n){var i,o;new Ue(this.app,e,n,this.headers,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),r=>{Object.assign(e,r),this.scheduleSave(),this.renderViewPreservingScroll()},()=>this.deleteWithUndo(e)).open()}renderViewPreservingScroll(){var l,c,d,h,u;let e=this.contentEl,n=e.querySelector(".csv-content-area"),i=e.querySelector(".csv-table-wrapper"),o=e.querySelector(".csv-kanban-board"),r={contentTop:(l=n==null?void 0:n.scrollTop)!=null?l:0,contentLeft:(c=n==null?void 0:n.scrollLeft)!=null?c:0,tableLeft:(d=i==null?void 0:i.scrollLeft)!=null?d:0,tableTop:(h=i==null?void 0:i.scrollTop)!=null?h:0,boardLeft:(u=o==null?void 0:o.scrollLeft)!=null?u:0,cols:new Map};e.querySelectorAll(".csv-kanban-col").forEach(f=>{var m,b;let p=(b=(m=f.querySelector(".csv-kanban-col-title"))==null?void 0:m.textContent)!=null?b:"",g=f.querySelector(".csv-kanban-col-body");p&&g&&r.cols.set(p,g.scrollTop)}),this.renderView();let a=()=>{let f=this.contentEl.querySelector(".csv-content-area"),p=this.contentEl.querySelector(".csv-table-wrapper"),g=this.contentEl.querySelector(".csv-kanban-board");f&&(f.scrollTop=r.contentTop,f.scrollLeft=r.contentLeft),p&&(p.scrollLeft=r.tableLeft,p.scrollTop=r.tableTop),g&&(g.scrollLeft=r.boardLeft),this.contentEl.querySelectorAll(".csv-kanban-col").forEach(m=>{var E,S;let b=(S=(E=m.querySelector(".csv-kanban-col-title"))==null?void 0:E.textContent)!=null?S:"",x=m.querySelector(".csv-kanban-col-body"),_=r.cols.get(b);x&&_!=null&&(x.scrollTop=_)})};a(),requestAnimationFrame(()=>{a(),requestAnimationFrame(a)}),setTimeout(a,50)}openAddModal(){let e={};if(Ge(this)){let n=un(this);n&&(e[n]=["Task","Note","Idea"]);let i=fn(this);i&&(e[i]=["Low","Medium","High"])}new je(this.app,this.headers,this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),n=>{this.rows.push(n),this.scheduleSave(),this.renderViewPreservingScroll(),new it.Notice(`Added: ${this.getTitle(n)}`)},e,n=>this.getBooleanColumns().includes(n)).open()}renderSelectField(e,n,i){var a;let o=(a=n[i])!=null?a:"",r=e.createDiv({cls:`csv-select-chip ${o?"":"empty"}`});return r.setText(o||"\u2014"),i.toLowerCase()==="status"&&o&&r.addClass(`status-chip-${o.toLowerCase().replace(/\s+/g,"-")}`),r.addEventListener("click",l=>{var c;l.stopPropagation(),Ot(r,(c=n[i])!=null?c:"",this.getColumnValues(i),d=>{n[i]=d,r.setText(d||"\u2014"),r.className=`csv-select-chip ${d?"":"empty"}`,i.toLowerCase()==="status"&&d&&r.addClass(`status-chip-${d.toLowerCase().replace(/\s+/g,"-")}`),this.scheduleSave()},this.contentEl,{multi:It(i)})}),r}renderView(e=!1){var o;let n=this.contentEl;e?this.contentArea&&this.contentArea.empty():(n.empty(),n.addClass("datadeck-root"),this.renderComponent.unload(),this.renderComponent=new it.Component,this.renderComponent.load(),cr(this,n),this.contentArea=n.createDiv({cls:"csv-content-area"}),this.installTouchScrollGuard(this.contentArea));let i=this.contentArea;if(i){if(i.toggleClass("csv-content-area--no-yscroll",this.mode==="kanban-genre"||this.mode==="table"),!this.headers.length){let r=i.createDiv({cls:"csv-empty-state csv-empty-state--big"});r.createEl("h3",{text:"This file is empty"}),r.createEl("p",{text:"Add a header row in your spreadsheet app, then come back \u2014 or click + Add in the toolbar to start fresh."});return}if(this.rows.length===0){let r=i.createDiv({cls:"csv-empty-state csv-empty-state--big"});r.createEl("h3",{text:"No entries yet"}),r.createEl("button",{cls:"csv-empty-state-action",text:"+ Add the first entry"}).addEventListener("click",()=>this.openAddModal()),r.createEl("p",{cls:"csv-empty-state-hint",text:`${this.headers.length} column${this.headers.length===1?"":"s"} detected: ${this.headers.slice(0,5).join(", ")}${this.headers.length>5?"\u2026":""}`});return}this.mode==="travel"?jo(i,this.rows,()=>this.loadMapSvg(),()=>this.scheduleSave(),this.settings.showResidency===!1?null:(o=this.settings.residencyRules)!=null?o:null,r=>this.renderComponent.register(r)):this.mode==="dashboard"?zl(this,i):this.mode==="library"?hn(this,i):this.mode==="kanban-genre"?dn(this,i):this.mode==="stats"?Xo(this,i):this.mode==="focus"?Hl(this,i):this.mode==="tasks"?lr(this,i):ln(this,i)}}installTouchScrollGuard(e){if(!matchMedia("(pointer: coarse)").matches)return;let n=0,i=0,o=!1;e.addEventListener("touchstart",r=>{r.touches.length===1&&(n=r.touches[0].clientX,i=r.touches[0].clientY,o=!1)},{capture:!0,passive:!0}),e.addEventListener("touchmove",r=>{if(r.touches.length!==1||o)return;let a=Math.abs(r.touches[0].clientX-n),l=Math.abs(r.touches[0].clientY-i);(a>10||l>10)&&(o=!0)},{capture:!0,passive:!0}),e.addEventListener("click",r=>{o&&(r.preventDefault(),r.stopImmediatePropagation())},!0)}async backupToArchive(){var a,l;if(!this.file)return;let e=(l=(a=this.file.parent)==null?void 0:a.path)!=null?l:"",n=e?`${e}/Archive`:"Archive";await this.app.vault.adapter.exists(n)||await this.app.vault.adapter.mkdir(n);let i=new Date().toISOString().slice(0,10),o=`${n}/${this.file.basename}_${i}.${this.file.extension}`;if(await this.app.vault.adapter.exists(o)){new it.Notice(`Backup already exists for today: ${o}`);return}let r=await this.app.vault.readBinary(this.file);await this.app.vault.adapter.writeBinary(o,r),new it.Notice(`Backed up to ${o}`)}hasDateColumn(){return this.getDateCol()!==null}isTravelFile(){let e=new Set(this.headers.map(n=>n.toLowerCase()));return e.has("country")&&e.has("date_entered")&&e.has("date_left")&&e.has("source")}async loadMapSvg(){if(qs!==void 0)return qs;let e=(0,it.normalizePath)(`${this.app.vault.configDir}/plugins/datadeck/world-map.svg`);try{qs=await this.app.vault.adapter.read(e)}catch(n){qs=null}return qs}getFilteredRows(){var i;let e=this.rows;if(this.searchQuery.trim()){let o=this.searchQuery.toLowerCase().trim();e=e.filter(r=>this.headers.some(a=>{var c;return((c=r[a])!=null?c:"").toLowerCase().includes(o)}))}if(this.mode==="table"&&this.tableSortCol&&this.headers.includes(this.tableSortCol))return To(e,this.tableSortCol,this.tableSortDir);let n=this.getDateCol();if(this.mode==="table"&&n){let o=(i=this.fileCfg.sortNewestFirst)!=null?i:!0;e=[...e].sort((r,a)=>{var h,u;let l=(h=r[n])!=null?h:"",c=(u=a[n])!=null?u:"",d=l.localeCompare(c);return o?-d:d})}return e}getDateCol(){if(this.headers.length===0)return null;let e=this.headers[0],n=e.toLowerCase();if(["date","day","datum"].includes(n))return e;let i=this.rows.slice(0,5),o=/^\d{4}-\d{2}-\d{2}$/;return i.length>0&&i.every(a=>{var l;return o.test((l=a[e])!=null?l:"")})?e:null}getBooleanColumns(){return this.fileCfg.habitColumns&&this.fileCfg.habitColumns.length>0?this.fileCfg.habitColumns.filter(e=>this.headers.includes(e)):this.autoDetectBooleanColumns()}autoDetectBooleanColumns(){return this.headers.filter(e=>{if(e===this.getDateCol()||this.isNotesCol(e))return!1;let n=this.rows.map(i=>{var o;return((o=i[e])!=null?o:"").toLowerCase().trim()});return tn(n)})}parseDate(e){let n=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);return n?new Date(parseInt(n[1]),parseInt(n[2])-1,parseInt(n[3])):null}formatDate(e){let n=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${n}-${i}-${o}`}isTruthy(e){let n=(e!=null?e:"").toLowerCase().trim();return n==="1"||n==="true"||n==="yes"}renderMarkdownInto(e,n){var i,o;it.MarkdownRenderer.render(this.app,n,e,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.renderComponent)}cycleMode(){let e=pn(this);if(e.length<2)return;let n=e.findIndex(i=>i.id===this.mode);this.mode=e[(n+1)%e.length].id,this.renderView()}onunload(){this.renderComponent.unload(),this.saveTimer&&window.clearTimeout(this.saveTimer)}},rp=[{id:"tasks",command:"Create tasks file",defaultName:"Tasks",headers:["Title","Type","Project","Status","Priority","Due","Notes"],mode:"tasks"},{id:"travel",command:"Create travel file",defaultName:"Travel",headers:["Country","date_entered","date_left","source","Notes"],mode:"travel"},{id:"habits",command:"Create habit tracker file",defaultName:"Habits",headers:["Date","Exercise","Meditate","Read","Notes"],mode:"dashboard"}],ti=class extends it.Plugin{constructor(){super(...arguments);this.settings=oi}async onload(){await this.loadSettings(),this.registerView(Qs,e=>new gs(e,this.settings,()=>this.saveSettings())),this.registerExtensions(["csv"],Qs),this.addSettingTab(new an(this.app,this)),this.registerMarkdownCodeBlockProcessor("csv-add",async(e,n,i)=>{await Ko(this.app,e.trim(),n,i)}),this.registerMarkdownCodeBlockProcessor("csv-random",async(e,n,i)=>{await dr(this.app,e.trim(),n,i)}),jl(this.app,this.settings,()=>this.saveSettings(),(e,n)=>this.registerMarkdownCodeBlockProcessor(e,n)),this.addCommand({id:"add-entry",name:"Add entry to current CSV",checkCallback:e=>{let n=this.app.workspace.getActiveViewOfType(gs);return n?(e||n.openAddModal(),!0):!1}}),this.addCommand({id:"cycle-view-mode",name:"Cycle view mode",checkCallback:e=>{let n=this.app.workspace.getActiveViewOfType(gs);return n?(e||n.cycleMode(),!0):!1}});for(let e of rp)this.addCommand({id:`create-${e.id}`,name:e.command,callback:()=>this.createTemplateFile(e)});this.registerEvent(this.app.vault.on("rename",async(e,n)=>{e instanceof it.TFile&&e.extension==="csv"&&this.settings.fileConfigs[n]&&(Oo(this.settings.fileConfigs,n,e.path),await this.saveSettings())})),this.registerEvent(this.app.vault.on("delete",async e=>{e instanceof it.TFile&&this.settings.fileConfigs[e.path]&&(delete this.settings.fileConfigs[e.path],await this.saveSettings())})),this.registerMarkdownCodeBlockProcessor("csv-refresh",(e,n,i)=>{let o=n.createEl("button",{cls:"csv-refresh-btn"});o.innerHTML="\u21BB refresh",o.addEventListener("click",async()=>{let r=i.sourcePath,a=this.app.vault.getAbstractFileByPath(r);if(a instanceof it.TFile){let l=this.app.workspace.activeLeaf;l&&await l.openFile(a,{state:{mode:"preview"}})}})})}async createTemplateFile(e){new nn(this.app,e.command,e.defaultName,"File name (without .csv)",async n=>{let i=this.app.workspace.getActiveFile(),o=i!=null&&i.parent&&i.parent.path!=="/"?`${i.parent.path}/`:"",r=xs(n),a=(0,it.normalizePath)(`${o}${r}.csv`);for(let c=2;this.app.vault.getAbstractFileByPath(a);c++)a=(0,it.normalizePath)(`${o}${r} ${c}.csv`);let l=await this.app.vault.create(a,e.headers.join(",")+` +`),h=this.headers.find(p=>this.isNotesCol(p)),u=d+(h&&((r=e[h])!=null&&r.trim())?e[h]:""),f=n.substring(0,n.lastIndexOf("/"));f&&!this.app.vault.getAbstractFileByPath(f)&&await this.app.vault.createFolder(f),i=await this.app.vault.create(n,u),new it.Notice(`Created: ${i.name}`)}await this.app.workspace.getLeaf("tab").openFile(i)}openNoteExpander(e,n){var i,o;new Ue(this.app,e,n,this.headers,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),r=>{Object.assign(e,r),this.scheduleSave(),this.renderViewPreservingScroll()},()=>this.deleteWithUndo(e)).open()}renderViewPreservingScroll(){var l,c,d,h,u;let e=this.contentEl,n=e.querySelector(".csv-content-area"),i=e.querySelector(".csv-table-wrapper"),o=e.querySelector(".csv-kanban-board"),r={contentTop:(l=n==null?void 0:n.scrollTop)!=null?l:0,contentLeft:(c=n==null?void 0:n.scrollLeft)!=null?c:0,tableLeft:(d=i==null?void 0:i.scrollLeft)!=null?d:0,tableTop:(h=i==null?void 0:i.scrollTop)!=null?h:0,boardLeft:(u=o==null?void 0:o.scrollLeft)!=null?u:0,cols:new Map};e.querySelectorAll(".csv-kanban-col").forEach(f=>{var b,m;let p=(m=(b=f.querySelector(".csv-kanban-col-title"))==null?void 0:b.textContent)!=null?m:"",g=f.querySelector(".csv-kanban-col-body");p&&g&&r.cols.set(p,g.scrollTop)}),this.renderView();let a=()=>{let f=this.contentEl.querySelector(".csv-content-area"),p=this.contentEl.querySelector(".csv-table-wrapper"),g=this.contentEl.querySelector(".csv-kanban-board");f&&(f.scrollTop=r.contentTop,f.scrollLeft=r.contentLeft),p&&(p.scrollLeft=r.tableLeft,p.scrollTop=r.tableTop),g&&(g.scrollLeft=r.boardLeft),this.contentEl.querySelectorAll(".csv-kanban-col").forEach(b=>{var w,S;let m=(S=(w=b.querySelector(".csv-kanban-col-title"))==null?void 0:w.textContent)!=null?S:"",x=b.querySelector(".csv-kanban-col-body"),_=r.cols.get(m);x&&_!=null&&(x.scrollTop=_)})};a(),requestAnimationFrame(()=>{a(),requestAnimationFrame(a)}),setTimeout(a,50)}openAddModal(){let e={};if(Ge(this)){let n=un(this);n&&(e[n]=["Task","Note","Idea"]);let i=fn(this);i&&(e[i]=["Low","Medium","High"])}new je(this.app,this.headers,this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),n=>{this.rows.push(n),this.scheduleSave(),this.renderViewPreservingScroll(),new it.Notice(`Added: ${this.getTitle(n)}`)},e,n=>this.getBooleanColumns().includes(n)).open()}renderSelectField(e,n,i){var a;let o=(a=n[i])!=null?a:"",r=e.createDiv({cls:`csv-select-chip ${o?"":"empty"}`});return r.setText(o||"\u2014"),i.toLowerCase()==="status"&&o&&r.addClass(`status-chip-${o.toLowerCase().replace(/\s+/g,"-")}`),r.addEventListener("click",l=>{var c;l.stopPropagation(),Ot(r,(c=n[i])!=null?c:"",this.getColumnValues(i),d=>{n[i]=d,r.setText(d||"\u2014"),r.className=`csv-select-chip ${d?"":"empty"}`,i.toLowerCase()==="status"&&d&&r.addClass(`status-chip-${d.toLowerCase().replace(/\s+/g,"-")}`),this.scheduleSave()},this.contentEl,{multi:It(i)})}),r}renderView(e=!1){var o;let n=this.contentEl;e?this.contentArea&&this.contentArea.empty():(n.empty(),n.addClass("datadeck-root"),this.renderComponent.unload(),this.renderComponent=new it.Component,this.renderComponent.load(),cr(this,n),this.contentArea=n.createDiv({cls:"csv-content-area"}),this.installTouchScrollGuard(this.contentArea));let i=this.contentArea;if(i){if(i.toggleClass("csv-content-area--no-yscroll",this.mode==="kanban-genre"||this.mode==="table"),!this.headers.length){let r=i.createDiv({cls:"csv-empty-state csv-empty-state--big"});r.createEl("h3",{text:"This file is empty"}),r.createEl("p",{text:"Add a header row in your spreadsheet app, then come back \u2014 or click + Add in the toolbar to start fresh."});return}if(this.rows.length===0){let r=i.createDiv({cls:"csv-empty-state csv-empty-state--big"});r.createEl("h3",{text:"No entries yet"}),r.createEl("button",{cls:"csv-empty-state-action",text:"+ Add the first entry"}).addEventListener("click",()=>this.openAddModal()),r.createEl("p",{cls:"csv-empty-state-hint",text:`${this.headers.length} column${this.headers.length===1?"":"s"} detected: ${this.headers.slice(0,5).join(", ")}${this.headers.length>5?"\u2026":""}`});return}this.mode==="travel"?jo(i,this.rows,()=>this.loadMapSvg(),()=>this.scheduleSave(),this.settings.showResidency===!1?null:(o=this.settings.residencyRules)!=null?o:null,r=>this.renderComponent.register(r)):this.mode==="dashboard"?zl(this,i):this.mode==="library"?hn(this,i):this.mode==="kanban-genre"?dn(this,i):this.mode==="stats"?Xo(this,i):this.mode==="focus"?Hl(this,i):this.mode==="tasks"?lr(this,i):ln(this,i)}}installTouchScrollGuard(e){if(!matchMedia("(pointer: coarse)").matches)return;let n=0,i=0,o=!1;e.addEventListener("touchstart",r=>{r.touches.length===1&&(n=r.touches[0].clientX,i=r.touches[0].clientY,o=!1)},{capture:!0,passive:!0}),e.addEventListener("touchmove",r=>{if(r.touches.length!==1||o)return;let a=Math.abs(r.touches[0].clientX-n),l=Math.abs(r.touches[0].clientY-i);(a>10||l>10)&&(o=!0)},{capture:!0,passive:!0}),e.addEventListener("click",r=>{o&&(r.preventDefault(),r.stopImmediatePropagation())},!0)}async backupToArchive(){var a,l;if(!this.file)return;let e=(l=(a=this.file.parent)==null?void 0:a.path)!=null?l:"",n=e?`${e}/Archive`:"Archive";await this.app.vault.adapter.exists(n)||await this.app.vault.adapter.mkdir(n);let i=new Date().toISOString().slice(0,10),o=`${n}/${this.file.basename}_${i}.${this.file.extension}`;if(await this.app.vault.adapter.exists(o)){new it.Notice(`Backup already exists for today: ${o}`);return}let r=await this.app.vault.readBinary(this.file);await this.app.vault.adapter.writeBinary(o,r),new it.Notice(`Backed up to ${o}`)}hasDateColumn(){return this.getDateCol()!==null}isTravelFile(){let e=new Set(this.headers.map(n=>n.toLowerCase()));return e.has("country")&&e.has("date_entered")&&e.has("date_left")&&e.has("source")}async loadMapSvg(){if(qs!==void 0)return qs;let e=(0,it.normalizePath)(`${this.app.vault.configDir}/plugins/datadeck/world-map.svg`);try{qs=await this.app.vault.adapter.read(e)}catch(n){qs=null}return qs}getFilteredRows(){var i;let e=this.rows;if(this.searchQuery.trim()){let o=this.searchQuery.toLowerCase().trim();e=e.filter(r=>this.headers.some(a=>{var c;return((c=r[a])!=null?c:"").toLowerCase().includes(o)}))}if(this.mode==="table"&&this.tableSortCol&&this.headers.includes(this.tableSortCol))return To(e,this.tableSortCol,this.tableSortDir);let n=this.getDateCol();if(this.mode==="table"&&n){let o=(i=this.fileCfg.sortNewestFirst)!=null?i:!0;e=[...e].sort((r,a)=>{var h,u;let l=(h=r[n])!=null?h:"",c=(u=a[n])!=null?u:"",d=l.localeCompare(c);return o?-d:d})}return e}getDateCol(){if(this.headers.length===0)return null;let e=this.headers[0],n=e.toLowerCase();if(["date","day","datum"].includes(n))return e;let i=this.rows.slice(0,5),o=/^\d{4}-\d{2}-\d{2}$/;return i.length>0&&i.every(a=>{var l;return o.test((l=a[e])!=null?l:"")})?e:null}getBooleanColumns(){return this.fileCfg.habitColumns&&this.fileCfg.habitColumns.length>0?this.fileCfg.habitColumns.filter(e=>this.headers.includes(e)):this.autoDetectBooleanColumns()}autoDetectBooleanColumns(){return this.headers.filter(e=>{if(e===this.getDateCol()||this.isNotesCol(e))return!1;let n=this.rows.map(i=>{var o;return((o=i[e])!=null?o:"").toLowerCase().trim()});return tn(n)})}parseDate(e){let n=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);return n?new Date(parseInt(n[1]),parseInt(n[2])-1,parseInt(n[3])):null}formatDate(e){let n=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${n}-${i}-${o}`}isTruthy(e){let n=(e!=null?e:"").toLowerCase().trim();return n==="1"||n==="true"||n==="yes"}renderMarkdownInto(e,n){var i,o;it.MarkdownRenderer.render(this.app,n,e,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.renderComponent)}cycleMode(){let e=pn(this);if(e.length<2)return;let n=e.findIndex(i=>i.id===this.mode);this.mode=e[(n+1)%e.length].id,this.renderView()}onunload(){this.renderComponent.unload(),this.saveTimer&&window.clearTimeout(this.saveTimer)}},rp=[{id:"tasks",command:"Create tasks file",defaultName:"Tasks",headers:["Title","Type","Project","Status","Priority","Due","Notes"],mode:"tasks"},{id:"travel",command:"Create travel file",defaultName:"Travel",headers:["Country","date_entered","date_left","source","Notes"],mode:"travel"},{id:"habits",command:"Create habit tracker file",defaultName:"Habits",headers:["Date","Exercise","Meditate","Read","Notes"],mode:"dashboard"}],ti=class extends it.Plugin{constructor(){super(...arguments);this.settings=oi}async onload(){await this.loadSettings(),this.registerView(Qs,e=>new gs(e,this.settings,()=>this.saveSettings())),this.registerExtensions(["csv"],Qs),this.addSettingTab(new an(this.app,this)),this.registerMarkdownCodeBlockProcessor("csv-add",async(e,n,i)=>{await Ko(this.app,e.trim(),n,i)}),this.registerMarkdownCodeBlockProcessor("csv-random",async(e,n,i)=>{await dr(this.app,e.trim(),n,i)}),jl(this.app,this.settings,()=>this.saveSettings(),(e,n)=>this.registerMarkdownCodeBlockProcessor(e,n)),this.addCommand({id:"add-entry",name:"Add entry to current CSV",checkCallback:e=>{let n=this.app.workspace.getActiveViewOfType(gs);return n?(e||n.openAddModal(),!0):!1}}),this.addCommand({id:"cycle-view-mode",name:"Cycle view mode",checkCallback:e=>{let n=this.app.workspace.getActiveViewOfType(gs);return n?(e||n.cycleMode(),!0):!1}});for(let e of rp)this.addCommand({id:`create-${e.id}`,name:e.command,callback:()=>this.createTemplateFile(e)});this.registerEvent(this.app.vault.on("rename",async(e,n)=>{e instanceof it.TFile&&e.extension==="csv"&&this.settings.fileConfigs[n]&&(Oo(this.settings.fileConfigs,n,e.path),await this.saveSettings())})),this.registerEvent(this.app.vault.on("delete",async e=>{e instanceof it.TFile&&this.settings.fileConfigs[e.path]&&(delete this.settings.fileConfigs[e.path],await this.saveSettings())})),this.registerMarkdownCodeBlockProcessor("csv-refresh",(e,n,i)=>{let o=n.createEl("button",{cls:"csv-refresh-btn"});o.innerHTML="\u21BB refresh",o.addEventListener("click",async()=>{let r=i.sourcePath,a=this.app.vault.getAbstractFileByPath(r);if(a instanceof it.TFile){let l=this.app.workspace.activeLeaf;l&&await l.openFile(a,{state:{mode:"preview"}})}})})}async createTemplateFile(e){new nn(this.app,e.command,e.defaultName,"File name (without .csv)",async n=>{let i=this.app.workspace.getActiveFile(),o=i!=null&&i.parent&&i.parent.path!=="/"?`${i.parent.path}/`:"",r=xs(n),a=(0,it.normalizePath)(`${o}${r}.csv`);for(let c=2;this.app.vault.getAbstractFileByPath(a);c++)a=(0,it.normalizePath)(`${o}${r} ${c}.csv`);let l=await this.app.vault.create(a,e.headers.join(",")+` `);this.settings.fileConfigs[l.path]={...this.settings.fileConfigs[l.path],defaultMode:e.mode},await this.saveSettings(),await this.app.workspace.getLeaf("tab").openFile(l),new it.Notice(`Created: ${l.name}`)}).open()}async loadSettings(){var e;this.settings=Object.assign({},oi,await this.loadData()),this.settings.residencyRules=JSON.parse(JSON.stringify((e=this.settings.residencyRules)!=null?e:[]))}async saveSettings(){await this.saveData(this.settings)}}; /*! Bundled license information: diff --git a/src/add-entry-form.ts b/src/add-entry-form.ts index d6d0b03..eb80b64 100644 --- a/src/add-entry-form.ts +++ b/src/add-entry-form.ts @@ -82,6 +82,9 @@ export async function renderAddEntryForm(app: App, source: string, el: HTMLEleme const dateCols = headers.filter(h => isDateCol(h)); const notesCols = headers.filter(h => isNotesCol(h)); const otherCols = headers.filter(h => !binaryCols.includes(h) && !dateCols.includes(h) && !notesCols.includes(h)); + // The title/index column is a free-text identifier — never a categorical + // dropdown, even if it happens to have few distinct existing values. + const titleCol = headers.find(h => ["title", "name"].includes(h.toLowerCase())); // Render as one collapsible "menu" (Apple-style grouped card): // - Default state: a single discreet "+ New entry" pill. @@ -137,7 +140,7 @@ export async function renderAddEntryForm(app: App, source: string, el: HTMLEleme otherCols.forEach(h => { const row = makeRow(h, "field"); const uniqueVals = new Set(rows.map(r => (r[h] ?? "").trim()).filter(Boolean)); - if (looksCategorical(uniqueVals.size)) { + if (h !== titleCol && looksCategorical(uniqueVals.size)) { const select = row.createEl("select", { cls: "csv-add-row-control" }); select.createEl("option", { text: "—", value: "" }); Array.from(uniqueVals).sort().forEach(v => select.createEl("option", { text: v, value: v })); diff --git a/src/modals.ts b/src/modals.ts index d441035..6436d1e 100644 --- a/src/modals.ts +++ b/src/modals.ts @@ -107,6 +107,12 @@ export class AddEntryModal extends Modal { row.createEl("label", { text: titleCase(h), cls: "csv-modal-label" }); const presets = this.optionPresets[h] ?? []; + // The title/index column is always a free-text identifier — never a + // dropdown, whether that's inferred (few distinct values / presets) or + // configured (settings.selectColumns / a future per-file categorical + // list). It's excluded up front so none of the branches below can + // route it into a select. + const isTitleCol = h === titleCol; // Single-value option columns (preset-backed or configured select) render // as a native "); +}); + +await test("add-entry: title column stays text even when configured as a select column", async () => { + const headers = ["Title", "Type"]; + const rows = [{ Title: "Alpha", Type: "Task" }]; + const modal = openAddModal(headers, rows, { isSelectCol: (h) => h === "Title" }); + const titleRow = fieldRowFor(modal, "Title"); + assert(titleRow.querySelector("input.csv-modal-input"), "title stays text even if explicitly marked a select column"); + assert(!titleRow.querySelector("select"), "no dropdown for title"); +}); + +await test("add-entry: a genuinely categorical non-title column still gets a dropdown", async () => { + const headers = ["Title", "Type"]; + const rows = [{ Title: "Alpha", Type: "Task" }, { Title: "Beta", Type: "Idea" }]; + const modal = openAddModal(headers, rows); + const typeRow = fieldRowFor(modal, "Type"); + assert(typeRow.querySelector("select"), "non-title low-cardinality column still auto-categorizes"); +}); + +function openExpander(row, headers, overrides = {}) { + const isNotesCol = overrides.isNotesCol ?? (() => false); + const isSelectCol = overrides.isSelectCol ?? (() => false); + const getColumnValues = overrides.getColumnValues ?? (() => []); + const modal = new NoteExpanderModal( + new StubApp(), row, overrides.notesCol ?? "", headers, "test.csv", + isNotesCol, isSelectCol, getColumnValues, () => {}, undefined, + ); + modal.contentEl = document.body.createDiv(); + modal.onOpen(); + return modal; +} + +await test("note-expander: title column is never rendered as a select chip", async () => { + const headers = ["Title", "Type"]; + const row = { Title: "Alpha", Type: "Task" }; + const modal = openExpander(row, headers, { + isSelectCol: (h) => h === "Title", + getColumnValues: () => ["Alpha", "Beta"], + }); + const fieldRows = Array.from(modal.contentEl.querySelectorAll(".csv-expander-field-row")); + const titleRow = fieldRows.find(r => r.querySelector(".csv-expander-field-label")?.textContent === "Title"); + assert(titleRow, "title field row exists"); + assert(!titleRow.querySelector(".csv-select-chip"), "title never renders as a select chip"); + assert(titleRow.querySelector(".csv-expander-field-value"), "title renders as a plain value field"); +}); + // ── Multi-select picker ────────────────────────────────────────────────────── const { showSelectPicker, isMultiValueColName } = await load("./src/utils.ts");