1 line
38 KiB
JavaScript
1 line
38 KiB
JavaScript
"use strict";var KimaiHeatmap=(()=>{var Wt=Object.defineProperty;var en=Object.getOwnPropertyDescriptor;var rn=Object.getOwnPropertyNames;var nn=Object.prototype.hasOwnProperty;var on=(t,e)=>{for(var r in e)Wt(t,r,{get:e[r],enumerable:!0})},an=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of rn(e))!nn.call(t,o)&&o!==r&&Wt(t,o,{get:()=>e[o],enumerable:!(n=en(e,o))||n.enumerable});return t};var un=t=>an(Wt({},"__esModule",{value:!0}),t);var za={};on(za,{calculateStats:()=>Br,calculateStreak:()=>Vr,init:()=>Ra,renderHeatmap:()=>ce});var St="http://www.w3.org/1999/xhtml",Pt={svg:"http://www.w3.org/2000/svg",xhtml:St,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Tt(t){var e=t+="",r=e.indexOf(":");return r>=0&&(e=t.slice(0,r))!=="xmlns"&&(t=t.slice(r+1)),Pt.hasOwnProperty(e)?{space:Pt[e],local:t}:t}function sn(t){return function(){var e=this.ownerDocument,r=this.namespaceURI;return r===St&&e.documentElement.namespaceURI===St?e.createElement(t):e.createElementNS(r,t)}}function ln(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Dt(t){var e=Tt(t);return(e.local?ln:sn)(e)}function fn(){}function Ct(t){return t==null?fn:function(){return this.querySelector(t)}}function pe(t){typeof t!="function"&&(t=Ct(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var a=e[o],i=a.length,u=n[o]=new Array(i),s,l,c=0;c<i;++c)(s=a[c])&&(l=t.call(s,s.__data__,c,a))&&("__data__"in s&&(l.__data__=s.__data__),u[c]=l);return new b(n,this._parents)}function It(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function cn(){return[]}function he(t){return t==null?cn:function(){return this.querySelectorAll(t)}}function mn(t){return function(){return It(t.apply(this,arguments))}}function de(t){typeof t=="function"?t=mn(t):t=he(t);for(var e=this._groups,r=e.length,n=[],o=[],a=0;a<r;++a)for(var i=e[a],u=i.length,s,l=0;l<u;++l)(s=i[l])&&(n.push(t.call(s,s.__data__,l,i)),o.push(s));return new b(n,o)}function ye(t){return function(){return this.matches(t)}}function bt(t){return function(e){return e.matches(t)}}var pn=Array.prototype.find;function hn(t){return function(){return pn.call(this.children,t)}}function dn(){return this.firstElementChild}function ge(t){return this.select(t==null?dn:hn(typeof t=="function"?t:bt(t)))}var yn=Array.prototype.filter;function gn(){return Array.from(this.children)}function xn(t){return function(){return yn.call(this.children,t)}}function xe(t){return this.selectAll(t==null?gn:xn(typeof t=="function"?t:bt(t)))}function ve(t){typeof t!="function"&&(t=ye(t));for(var e=this._groups,r=e.length,n=new Array(r),o=0;o<r;++o)for(var a=e[o],i=a.length,u=n[o]=[],s,l=0;l<i;++l)(s=a[l])&&t.call(s,s.__data__,l,a)&&u.push(s);return new b(n,this._parents)}function Ut(t){return new Array(t.length)}function Me(){return new b(this._enter||this._groups.map(Ut),this._parents)}function mt(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}mt.prototype={constructor:mt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function we(t){return function(){return t}}function vn(t,e,r,n,o,a){for(var i=0,u,s=e.length,l=a.length;i<l;++i)(u=e[i])?(u.__data__=a[i],n[i]=u):r[i]=new mt(t,a[i]);for(;i<s;++i)(u=e[i])&&(o[i]=u)}function Mn(t,e,r,n,o,a,i){var u,s,l=new Map,c=e.length,p=a.length,g=new Array(c),x;for(u=0;u<c;++u)(s=e[u])&&(g[u]=x=i.call(s,s.__data__,u,e)+"",l.has(x)?o[u]=s:l.set(x,s));for(u=0;u<p;++u)x=i.call(t,a[u],u,a)+"",(s=l.get(x))?(n[u]=s,s.__data__=a[u],l.delete(x)):r[u]=new mt(t,a[u]);for(u=0;u<c;++u)(s=e[u])&&l.get(g[u])===s&&(o[u]=s)}function wn(t){return t.__data__}function _e(t,e){if(!arguments.length)return Array.from(this,wn);var r=e?Mn:vn,n=this._parents,o=this._groups;typeof t!="function"&&(t=we(t));for(var a=o.length,i=new Array(a),u=new Array(a),s=new Array(a),l=0;l<a;++l){var c=n[l],p=o[l],g=p.length,x=_n(t.call(c,c&&c.__data__,l,n)),w=x.length,_=u[l]=new Array(w),W=i[l]=new Array(w),P=s[l]=new Array(g);r(c,p,_,W,P,x,e);for(var H=0,A=0,T,N;H<w;++H)if(T=_[H]){for(H>=A&&(A=H+1);!(N=W[A])&&++A<w;);T._next=N||null}}return i=new b(i,n),i._enter=u,i._exit=s,i}function _n(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Se(){return new b(this._exit||this._groups.map(Ut),this._parents)}function Te(t,e,r){var n=this.enter(),o=this,a=this.exit();return typeof t=="function"?(n=t(n),n&&(n=n.selection())):n=n.append(t+""),e!=null&&(o=e(o),o&&(o=o.selection())),r==null?a.remove():r(a),n&&o?n.merge(o).order():o}function De(t){for(var e=t.selection?t.selection():t,r=this._groups,n=e._groups,o=r.length,a=n.length,i=Math.min(o,a),u=new Array(o),s=0;s<i;++s)for(var l=r[s],c=n[s],p=l.length,g=u[s]=new Array(p),x,w=0;w<p;++w)(x=l[w]||c[w])&&(g[w]=x);for(;s<o;++s)u[s]=r[s];return new b(u,this._parents)}function Ce(){for(var t=this._groups,e=-1,r=t.length;++e<r;)for(var n=t[e],o=n.length-1,a=n[o],i;--o>=0;)(i=n[o])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function be(t){t||(t=Sn);function e(p,g){return p&&g?t(p.__data__,g.__data__):!p-!g}for(var r=this._groups,n=r.length,o=new Array(n),a=0;a<n;++a){for(var i=r[a],u=i.length,s=o[a]=new Array(u),l,c=0;c<u;++c)(l=i[c])&&(s[c]=l);s.sort(e)}return new b(o,this._parents).order()}function Sn(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Ue(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function ke(){return Array.from(this)}function Ae(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],o=0,a=n.length;o<a;++o){var i=n[o];if(i)return i}return null}function Fe(){let t=0;for(let e of this)++t;return t}function Ne(){return!this.node()}function Le(t){for(var e=this._groups,r=0,n=e.length;r<n;++r)for(var o=e[r],a=0,i=o.length,u;a<i;++a)(u=o[a])&&t.call(u,u.__data__,a,o);return this}function Tn(t){return function(){this.removeAttribute(t)}}function Dn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Cn(t,e){return function(){this.setAttribute(t,e)}}function bn(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Un(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttribute(t):this.setAttribute(t,r)}}function kn(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,r)}}function He(t,e){var r=Tt(t);if(arguments.length<2){var n=this.node();return r.local?n.getAttributeNS(r.space,r.local):n.getAttribute(r)}return this.each((e==null?r.local?Dn:Tn:typeof e=="function"?r.local?kn:Un:r.local?bn:Cn)(r,e))}function kt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function An(t){return function(){this.style.removeProperty(t)}}function Fn(t,e,r){return function(){this.style.setProperty(t,e,r)}}function Nn(t,e,r){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(t):this.style.setProperty(t,n,r)}}function Ye(t,e,r){return arguments.length>1?this.each((e==null?An:typeof e=="function"?Nn:Fn)(t,e,r??"")):Ln(this.node(),t)}function Ln(t,e){return t.style.getPropertyValue(e)||kt(t).getComputedStyle(t,null).getPropertyValue(e)}function Hn(t){return function(){delete this[t]}}function Yn(t,e){return function(){this[t]=e}}function En(t,e){return function(){var r=e.apply(this,arguments);r==null?delete this[t]:this[t]=r}}function Ee(t,e){return arguments.length>1?this.each((e==null?Hn:typeof e=="function"?En:Yn)(t,e)):this.node()[t]}function We(t){return t.trim().split(/^|\s+/)}function Ot(t){return t.classList||new Pe(t)}function Pe(t){this._node=t,this._names=We(t.getAttribute("class")||"")}Pe.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Ie(t,e){for(var r=Ot(t),n=-1,o=e.length;++n<o;)r.add(e[n])}function Oe(t,e){for(var r=Ot(t),n=-1,o=e.length;++n<o;)r.remove(e[n])}function Wn(t){return function(){Ie(this,t)}}function Pn(t){return function(){Oe(this,t)}}function In(t,e){return function(){(e.apply(this,arguments)?Ie:Oe)(this,t)}}function qe(t,e){var r=We(t+"");if(arguments.length<2){for(var n=Ot(this.node()),o=-1,a=r.length;++o<a;)if(!n.contains(r[o]))return!1;return!0}return this.each((typeof e=="function"?In:e?Wn:Pn)(r,e))}function On(){this.textContent=""}function qn(t){return function(){this.textContent=t}}function Rn(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Re(t){return arguments.length?this.each(t==null?On:(typeof t=="function"?Rn:qn)(t)):this.node().textContent}function zn(){this.innerHTML=""}function $n(t){return function(){this.innerHTML=t}}function Vn(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function ze(t){return arguments.length?this.each(t==null?zn:(typeof t=="function"?Vn:$n)(t)):this.node().innerHTML}function Bn(){this.nextSibling&&this.parentNode.appendChild(this)}function $e(){return this.each(Bn)}function Zn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ve(){return this.each(Zn)}function Be(t){var e=typeof t=="function"?t:Dt(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Qn(){return null}function Ze(t,e){var r=typeof t=="function"?t:Dt(t),n=e==null?Qn:typeof e=="function"?e:Ct(e);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function Xn(){var t=this.parentNode;t&&t.removeChild(this)}function Qe(){return this.each(Xn)}function Gn(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Jn(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Xe(t){return this.select(t?Jn:Gn)}function Ge(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Kn(t){return function(e){t.call(this,e,this.__data__)}}function jn(t){return t.trim().split(/^|\s+/).map(function(e){var r="",n=e.indexOf(".");return n>=0&&(r=e.slice(n+1),e=e.slice(0,n)),{type:e,name:r}})}function to(t){return function(){var e=this.__on;if(e){for(var r=0,n=-1,o=e.length,a;r<o;++r)a=e[r],(!t.type||a.type===t.type)&&a.name===t.name?this.removeEventListener(a.type,a.listener,a.options):e[++n]=a;++n?e.length=n:delete this.__on}}}function eo(t,e,r){return function(){var n=this.__on,o,a=Kn(e);if(n){for(var i=0,u=n.length;i<u;++i)if((o=n[i]).type===t.type&&o.name===t.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=a,o.options=r),o.value=e;return}}this.addEventListener(t.type,a,r),o={type:t.type,name:t.name,value:e,listener:a,options:r},n?n.push(o):this.__on=[o]}}function Je(t,e,r){var n=jn(t+""),o,a=n.length,i;if(arguments.length<2){var u=this.node().__on;if(u){for(var s=0,l=u.length,c;s<l;++s)for(o=0,c=u[s];o<a;++o)if((i=n[o]).type===c.type&&i.name===c.name)return c.value}return}for(u=e?eo:to,o=0;o<a;++o)this.each(u(n[o],e,r));return this}function Ke(t,e,r){var n=kt(t),o=n.CustomEvent;typeof o=="function"?o=new o(e,r):(o=n.document.createEvent("Event"),r?(o.initEvent(e,r.bubbles,r.cancelable),o.detail=r.detail):o.initEvent(e,!1,!1)),t.dispatchEvent(o)}function ro(t,e){return function(){return Ke(this,t,e)}}function no(t,e){return function(){return Ke(this,t,e.apply(this,arguments))}}function je(t,e){return this.each((typeof e=="function"?no:ro)(t,e))}function*tr(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],o=0,a=n.length,i;o<a;++o)(i=n[o])&&(yield i)}var qt=[null];function b(t,e){this._groups=t,this._parents=e}function oo(){return new b([[document.documentElement]],qt)}function ao(){return this}b.prototype=oo.prototype={constructor:b,select:pe,selectAll:de,selectChild:ge,selectChildren:xe,filter:ve,data:_e,enter:Me,exit:Se,join:Te,merge:De,selection:ao,order:Ce,sort:be,call:Ue,nodes:ke,node:Ae,size:Fe,empty:Ne,each:Le,attr:He,style:Ye,property:Ee,classed:qe,text:Re,html:ze,raise:$e,lower:Ve,append:Be,insert:Ze,remove:Qe,clone:Xe,datum:Ge,on:Je,dispatch:je,[Symbol.iterator]:tr};function Rt(t){return typeof t=="string"?new b([[document.querySelector(t)]],[document.documentElement]):new b([[t]],qt)}function tt(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function zt(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function At(t){let e,r,n;t.length!==2?(e=tt,r=(u,s)=>tt(t(u),s),n=(u,s)=>t(u)-s):(e=t===tt||t===zt?t:io,r=t,n=t);function o(u,s,l=0,c=u.length){if(l<c){if(e(s,s)!==0)return c;do{let p=l+c>>>1;r(u[p],s)<0?l=p+1:c=p}while(l<c)}return l}function a(u,s,l=0,c=u.length){if(l<c){if(e(s,s)!==0)return c;do{let p=l+c>>>1;r(u[p],s)<=0?l=p+1:c=p}while(l<c)}return l}function i(u,s,l=0,c=u.length){let p=o(u,s,l,c-1);return p>l&&n(u[p-1],s)>-n(u[p],s)?p-1:p}return{left:o,center:i,right:a}}function io(){return 0}function $t(t){return t===null?NaN:+t}var er=At(tt),rr=er.right,uo=er.left,so=At($t).center,Vt=rr;var lo=Math.sqrt(50),fo=Math.sqrt(10),co=Math.sqrt(2);function Ft(t,e,r){let n=(e-t)/Math.max(0,r),o=Math.floor(Math.log10(n)),a=n/Math.pow(10,o),i=a>=lo?10:a>=fo?5:a>=co?2:1,u,s,l;return o<0?(l=Math.pow(10,-o)/i,u=Math.round(t*l),s=Math.round(e*l),u/l<t&&++u,s/l>e&&--s,l=-l):(l=Math.pow(10,o)*i,u=Math.round(t/l),s=Math.round(e/l),u*l<t&&++u,s*l>e&&--s),s<u&&.5<=r&&r<2?Ft(t,e,r*2):[u,s,l]}function Nt(t,e,r){if(e=+e,t=+t,r=+r,!(r>0))return[];if(t===e)return[t];let n=e<t,[o,a,i]=n?Ft(e,t,r):Ft(t,e,r);if(!(a>=o))return[];let u=a-o+1,s=new Array(u);if(n)if(i<0)for(let l=0;l<u;++l)s[l]=(a-l)/-i;else for(let l=0;l<u;++l)s[l]=(a-l)*i;else if(i<0)for(let l=0;l<u;++l)s[l]=(o+l)/-i;else for(let l=0;l<u;++l)s[l]=(o+l)*i;return s}function pt(t,e,r){return e=+e,t=+t,r=+r,Ft(t,e,r)[2]}function Bt(t,e,r){e=+e,t=+t,r=+r;let n=e<t,o=n?pt(e,t,r):pt(t,e,r);return(n?-1:1)*(o<0?1/-o:o)}function ht(t,e){let r;if(e===void 0)for(let n of t)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let o of t)(o=e(o,++n,t))!=null&&(r<o||r===void 0&&o>=o)&&(r=o)}return r}function nr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function or(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function et(t,e){if(!isFinite(t)||t===0)return null;var r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function q(t){return t=et(Math.abs(t)),t?t[1]:NaN}function ar(t,e){return function(r,n){for(var o=r.length,a=[],i=0,u=t[0],s=0;o>0&&u>0&&(s+u+1>n&&(u=Math.max(1,n-s)),a.push(r.substring(o-=u,o+u)),!((s+=u+1)>n));)u=t[i=(i+1)%t.length];return a.reverse().join(e)}}function ir(t){return function(e){return e.replace(/[0-9]/g,function(r){return t[+r]})}}var mo=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Q(t){if(!(e=mo.exec(t)))throw new Error("invalid format: "+t);var e;return new Lt({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Q.prototype=Lt.prototype;function Lt(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Lt.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function ur(t){t:for(var e=t.length,r=1,n=-1,o;r<e;++r)switch(t[r]){case".":n=o=r;break;case"0":n===0&&(n=r),o=r;break;default:if(!+t[r])break t;n>0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(o+1):t}var dt;function sr(t,e){var r=et(t,e);if(!r)return dt=void 0,t.toPrecision(e);var n=r[0],o=r[1],a=o-(dt=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,i=n.length;return a===i?n:a>i?n+new Array(a-i+1).join("0"):a>0?n.slice(0,a)+"."+n.slice(a):"0."+new Array(1-a).join("0")+et(t,Math.max(0,e+a-1))[0]}function Zt(t,e){var r=et(t,e);if(!r)return t+"";var n=r[0],o=r[1];return o<0?"0."+new Array(-o).join("0")+n:n.length>o+1?n.slice(0,o+1)+"."+n.slice(o+1):n+new Array(o-n.length+2).join("0")}var Qt={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:or,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Zt(t*100,e),r:Zt,s:sr,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Xt(t){return t}var lr=Array.prototype.map,fr=["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];function cr(t){var e=t.grouping===void 0||t.thousands===void 0?Xt:ar(lr.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",o=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?Xt:ir(lr.call(t.numerals,String)),i=t.percent===void 0?"%":t.percent+"",u=t.minus===void 0?"\u2212":t.minus+"",s=t.nan===void 0?"NaN":t.nan+"";function l(p,g){p=Q(p);var x=p.fill,w=p.align,_=p.sign,W=p.symbol,P=p.zero,H=p.width,A=p.comma,T=p.precision,N=p.trim,D=p.type;D==="n"?(A=!0,D="g"):Qt[D]||(T===void 0&&(T=12),N=!0,D="g"),(P||x==="0"&&w==="=")&&(P=!0,x="0",w="=");var at=(g&&g.prefix!==void 0?g.prefix:"")+(W==="$"?r:W==="#"&&/[boxX]/.test(D)?"0"+D.toLowerCase():""),I=(W==="$"?n:/[%p]/.test(D)?i:"")+(g&&g.suffix!==void 0?g.suffix:""),B=Qt[D],it=/[defgprs%]/.test(D);T=T===void 0?6:/[gprs]/.test(D)?Math.max(1,Math.min(21,T)):Math.max(0,Math.min(20,T));function K(d){var U=at,h=I,C,ut,Z;if(D==="c")h=B(d)+h,d="";else{d=+d;var R=d<0||1/d<0;if(d=isNaN(d)?s:B(Math.abs(d),T),N&&(d=ur(d)),R&&+d==0&&_!=="+"&&(R=!1),U=(R?_==="("?_:u:_==="-"||_==="("?"":_)+U,h=(D==="s"&&!isNaN(d)&&dt!==void 0?fr[8+dt/3]:"")+h+(R&&_==="("?")":""),it){for(C=-1,ut=d.length;++C<ut;)if(Z=d.charCodeAt(C),48>Z||Z>57){h=(Z===46?o+d.slice(C+1):d.slice(C))+h,d=d.slice(0,C);break}}}A&&!P&&(d=e(d,1/0));var st=U.length+d.length+h.length,O=st<H?new Array(H-st+1).join(x):"";switch(A&&P&&(d=e(O+d,O.length?H-h.length:1/0),O=""),w){case"<":d=U+d+h+O;break;case"=":d=U+O+d+h;break;case"^":d=O.slice(0,st=O.length>>1)+U+d+h+O.slice(st);break;default:d=O+U+d+h;break}return a(d)}return K.toString=function(){return p+""},K}function c(p,g){var x=Math.max(-8,Math.min(8,Math.floor(q(g)/3)))*3,w=Math.pow(10,-x),_=l((p=Q(p),p.type="f",p),{suffix:fr[8+x/3]});return function(W){return _(w*W)}}return{format:l,formatPrefix:c}}var Ht,Yt,Et;Gt({thousands:",",grouping:[3],currency:["$",""]});function Gt(t){return Ht=cr(t),Yt=Ht.format,Et=Ht.formatPrefix,Ht}function Jt(t){return Math.max(0,-q(Math.abs(t)))}function Kt(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(q(e)/3)))*3-q(Math.abs(t)))}function jt(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,q(e)-q(t))+1}function te(t,e,r,n){var o=Bt(t,e,r),a;switch(n=Q(n??",f"),n.type){case"s":{var i=Math.max(Math.abs(t),Math.abs(e));return n.precision==null&&!isNaN(a=Kt(o,i))&&(n.precision=a),Et(n,i)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(a=jt(o,Math.max(Math.abs(t),Math.abs(e))))&&(n.precision=a-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(a=Jt(o))&&(n.precision=a-(n.type==="%")*2);break}}return Yt(n)}function mr(t){var e=t.domain;return t.ticks=function(r){var n=e();return Nt(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var o=e();return te(o[0],o[o.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=e(),o=0,a=n.length-1,i=n[o],u=n[a],s,l,c=10;for(u<i&&(l=i,i=u,u=l,l=o,o=a,a=l);c-- >0;){if(l=pt(i,u,r),l===s)return n[o]=i,n[a]=u,e(n);if(l>0)i=Math.floor(i/l)*l,u=Math.ceil(u/l)*l;else if(l<0)i=Math.ceil(i*l)/l,u=Math.floor(u*l)/l;else break;s=l}return t},t}function yt(){var t=0,e=1,r=1,n=[.5],o=[0,1],a;function i(s){return s!=null&&s<=s?o[Vt(n,s,0,r)]:a}function u(){var s=-1;for(n=new Array(r);++s<r;)n[s]=((s+1)*e-(s-r)*t)/(r+1);return i}return i.domain=function(s){return arguments.length?([t,e]=s,t=+t,e=+e,u()):[t,e]},i.range=function(s){return arguments.length?(r=(o=Array.from(s)).length-1,u()):o.slice()},i.invertExtent=function(s){var l=o.indexOf(s);return l<0?[NaN,NaN]:l<1?[t,n[0]]:l>=r?[n[r-1],e]:[n[l-1],n[l]]},i.unknown=function(s){return arguments.length&&(a=s),i},i.thresholds=function(){return n.slice()},i.copy=function(){return yt().domain([t,e]).range(o).unknown(a)},nr.apply(mr(i),arguments)}var ee=new Date,re=new Date;function F(t,e,r,n){function o(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return o.floor=a=>(t(a=new Date(+a)),a),o.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),o.round=a=>{let i=o(a),u=o.ceil(a);return a-i<u-a?i:u},o.offset=(a,i)=>(e(a=new Date(+a),i==null?1:Math.floor(i)),a),o.range=(a,i,u)=>{let s=[];if(a=o.ceil(a),u=u==null?1:Math.floor(u),!(a<i)||!(u>0))return s;let l;do s.push(l=new Date(+a)),e(a,u),t(a);while(l<a&&a<i);return s},o.filter=a=>F(i=>{if(i>=i)for(;t(i),!a(i);)i.setTime(i-1)},(i,u)=>{if(i>=i)if(u<0)for(;++u<=0;)for(;e(i,-1),!a(i););else for(;--u>=0;)for(;e(i,1),!a(i););}),r&&(o.count=(a,i)=>(ee.setTime(+a),re.setTime(+i),t(ee),t(re),Math.floor(r(ee,re))),o.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?o.filter(n?i=>n(i)%a===0:i=>o.count(0,i)%a===0):o)),o}var z=F(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5,t=>t.getDate()-1),ho=z.range,gt=F(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/864e5,t=>t.getUTCDate()-1),yo=gt.range,pr=F(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/864e5,t=>Math.floor(t/864e5)),go=pr.range;function rt(t){return F(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,r)=>{e.setDate(e.getDate()+r*7)},(e,r)=>(r-e-(r.getTimezoneOffset()-e.getTimezoneOffset())*6e4)/6048e5)}var nt=rt(0),X=rt(1),hr=rt(2),dr=rt(3),G=rt(4),yr=rt(5),gr=rt(6),xr=nt.range,vo=X.range,Mo=hr.range,wo=dr.range,_o=G.range,So=yr.range,To=gr.range;function ot(t){return F(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCDate(e.getUTCDate()+r*7)},(e,r)=>(r-e)/6048e5)}var xt=ot(0),lt=ot(1),vr=ot(2),Mr=ot(3),J=ot(4),wr=ot(5),_r=ot(6),Sr=xt.range,Do=lt.range,Co=vr.range,bo=Mr.range,Uo=J.range,ko=wr.range,Ao=_r.range;var vt=F(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth()),Fo=vt.range,Tr=F(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth()),No=Tr.range;var $=F(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());$.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:F(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,r)=>{e.setFullYear(e.getFullYear()+r*t)});var Lo=$.range,V=F(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());V.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:F(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCFullYear(e.getUTCFullYear()+r*t)});var Ho=V.range;function oe(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function ae(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Mt(t,e,r){return{y:t,m:e,d:r,H:0,M:0,S:0,L:0}}function ie(t){var e=t.dateTime,r=t.date,n=t.time,o=t.periods,a=t.days,i=t.shortDays,u=t.months,s=t.shortMonths,l=wt(o),c=_t(o),p=wt(a),g=_t(a),x=wt(i),w=_t(i),_=wt(u),W=_t(u),P=wt(s),H=_t(s),A={a:Z,A:R,b:st,B:O,c:null,d:Ar,e:Ar,f:na,g:pa,G:da,H:ta,I:ea,j:ra,L:Yr,m:oa,M:aa,p:Zr,q:Qr,Q:Lr,s:Hr,S:ia,u:ua,U:sa,V:la,w:fa,W:ca,x:null,X:null,y:ma,Y:ha,Z:ya,"%":Nr},T={a:Xr,A:Gr,b:Jr,B:Kr,c:null,d:Fr,e:Fr,f:Ma,g:Aa,G:Na,H:ga,I:xa,j:va,L:Wr,m:wa,M:_a,p:jr,q:tn,Q:Lr,s:Hr,S:Sa,u:Ta,U:Da,V:Ca,w:ba,W:Ua,x:null,X:null,y:ka,Y:Fa,Z:La,"%":Nr},N={a:it,A:K,b:d,B:U,c:h,d:Ur,e:Ur,f:Go,g:br,G:Cr,H:kr,I:kr,j:Bo,L:Xo,m:Vo,M:Zo,p:B,q:$o,Q:Ko,s:jo,S:Qo,u:Io,U:Oo,V:qo,w:Po,W:Ro,x:C,X:ut,y:br,Y:Cr,Z:zo,"%":Jo};A.x=D(r,A),A.X=D(n,A),A.c=D(e,A),T.x=D(r,T),T.X=D(n,T),T.c=D(e,T);function D(m,y){return function(v){var f=[],L=-1,S=0,Y=m.length,E,j,me;for(v instanceof Date||(v=new Date(+v));++L<Y;)m.charCodeAt(L)===37&&(f.push(m.slice(S,L)),(j=Dr[E=m.charAt(++L)])!=null?E=m.charAt(++L):j=E==="e"?" ":"0",(me=y[E])&&(E=me(v,j)),f.push(E),S=L+1);return f.push(m.slice(S,L)),f.join("")}}function at(m,y){return function(v){var f=Mt(1900,void 0,1),L=I(f,m,v+="",0),S,Y;if(L!=v.length)return null;if("Q"in f)return new Date(f.Q);if("s"in f)return new Date(f.s*1e3+("L"in f?f.L:0));if(y&&!("Z"in f)&&(f.Z=0),"p"in f&&(f.H=f.H%12+f.p*12),f.m===void 0&&(f.m="q"in f?f.q:0),"V"in f){if(f.V<1||f.V>53)return null;"w"in f||(f.w=1),"Z"in f?(S=ae(Mt(f.y,0,1)),Y=S.getUTCDay(),S=Y>4||Y===0?lt.ceil(S):lt(S),S=gt.offset(S,(f.V-1)*7),f.y=S.getUTCFullYear(),f.m=S.getUTCMonth(),f.d=S.getUTCDate()+(f.w+6)%7):(S=oe(Mt(f.y,0,1)),Y=S.getDay(),S=Y>4||Y===0?X.ceil(S):X(S),S=z.offset(S,(f.V-1)*7),f.y=S.getFullYear(),f.m=S.getMonth(),f.d=S.getDate()+(f.w+6)%7)}else("W"in f||"U"in f)&&("w"in f||(f.w="u"in f?f.u%7:"W"in f?1:0),Y="Z"in f?ae(Mt(f.y,0,1)).getUTCDay():oe(Mt(f.y,0,1)).getDay(),f.m=0,f.d="W"in f?(f.w+6)%7+f.W*7-(Y+5)%7:f.w+f.U*7-(Y+6)%7);return"Z"in f?(f.H+=f.Z/100|0,f.M+=f.Z%100,ae(f)):oe(f)}}function I(m,y,v,f){for(var L=0,S=y.length,Y=v.length,E,j;L<S;){if(f>=Y)return-1;if(E=y.charCodeAt(L++),E===37){if(E=y.charAt(L++),j=N[E in Dr?y.charAt(L++):E],!j||(f=j(m,v,f))<0)return-1}else if(E!=v.charCodeAt(f++))return-1}return f}function B(m,y,v){var f=l.exec(y.slice(v));return f?(m.p=c.get(f[0].toLowerCase()),v+f[0].length):-1}function it(m,y,v){var f=x.exec(y.slice(v));return f?(m.w=w.get(f[0].toLowerCase()),v+f[0].length):-1}function K(m,y,v){var f=p.exec(y.slice(v));return f?(m.w=g.get(f[0].toLowerCase()),v+f[0].length):-1}function d(m,y,v){var f=P.exec(y.slice(v));return f?(m.m=H.get(f[0].toLowerCase()),v+f[0].length):-1}function U(m,y,v){var f=_.exec(y.slice(v));return f?(m.m=W.get(f[0].toLowerCase()),v+f[0].length):-1}function h(m,y,v){return I(m,e,y,v)}function C(m,y,v){return I(m,r,y,v)}function ut(m,y,v){return I(m,n,y,v)}function Z(m){return i[m.getDay()]}function R(m){return a[m.getDay()]}function st(m){return s[m.getMonth()]}function O(m){return u[m.getMonth()]}function Zr(m){return o[+(m.getHours()>=12)]}function Qr(m){return 1+~~(m.getMonth()/3)}function Xr(m){return i[m.getUTCDay()]}function Gr(m){return a[m.getUTCDay()]}function Jr(m){return s[m.getUTCMonth()]}function Kr(m){return u[m.getUTCMonth()]}function jr(m){return o[+(m.getUTCHours()>=12)]}function tn(m){return 1+~~(m.getUTCMonth()/3)}return{format:function(m){var y=D(m+="",A);return y.toString=function(){return m},y},parse:function(m){var y=at(m+="",!1);return y.toString=function(){return m},y},utcFormat:function(m){var y=D(m+="",T);return y.toString=function(){return m},y},utcParse:function(m){var y=at(m+="",!0);return y.toString=function(){return m},y}}}var Dr={"-":"",_:" ",0:"0"},k=/^\s*\d+/,Yo=/^%/,Eo=/[\\^$*+?|[\]().{}]/g;function M(t,e,r){var n=t<0?"-":"",o=(n?-t:t)+"",a=o.length;return n+(a<r?new Array(r-a+1).join(e)+o:o)}function Wo(t){return t.replace(Eo,"\\$&")}function wt(t){return new RegExp("^(?:"+t.map(Wo).join("|")+")","i")}function _t(t){return new Map(t.map((e,r)=>[e.toLowerCase(),r]))}function Po(t,e,r){var n=k.exec(e.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function Io(t,e,r){var n=k.exec(e.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Oo(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function qo(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Ro(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function Cr(t,e,r){var n=k.exec(e.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function br(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function zo(t,e,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(r,r+6));return n?(t.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function $o(t,e,r){var n=k.exec(e.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Vo(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function Ur(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Bo(t,e,r){var n=k.exec(e.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function kr(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Zo(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Qo(t,e,r){var n=k.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Xo(t,e,r){var n=k.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Go(t,e,r){var n=k.exec(e.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Jo(t,e,r){var n=Yo.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function Ko(t,e,r){var n=k.exec(e.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function jo(t,e,r){var n=k.exec(e.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function Ar(t,e){return M(t.getDate(),e,2)}function ta(t,e){return M(t.getHours(),e,2)}function ea(t,e){return M(t.getHours()%12||12,e,2)}function ra(t,e){return M(1+z.count($(t),t),e,3)}function Yr(t,e){return M(t.getMilliseconds(),e,3)}function na(t,e){return Yr(t,e)+"000"}function oa(t,e){return M(t.getMonth()+1,e,2)}function aa(t,e){return M(t.getMinutes(),e,2)}function ia(t,e){return M(t.getSeconds(),e,2)}function ua(t){var e=t.getDay();return e===0?7:e}function sa(t,e){return M(nt.count($(t)-1,t),e,2)}function Er(t){var e=t.getDay();return e>=4||e===0?G(t):G.ceil(t)}function la(t,e){return t=Er(t),M(G.count($(t),t)+($(t).getDay()===4),e,2)}function fa(t){return t.getDay()}function ca(t,e){return M(X.count($(t)-1,t),e,2)}function ma(t,e){return M(t.getFullYear()%100,e,2)}function pa(t,e){return t=Er(t),M(t.getFullYear()%100,e,2)}function ha(t,e){return M(t.getFullYear()%1e4,e,4)}function da(t,e){var r=t.getDay();return t=r>=4||r===0?G(t):G.ceil(t),M(t.getFullYear()%1e4,e,4)}function ya(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+M(e/60|0,"0",2)+M(e%60,"0",2)}function Fr(t,e){return M(t.getUTCDate(),e,2)}function ga(t,e){return M(t.getUTCHours(),e,2)}function xa(t,e){return M(t.getUTCHours()%12||12,e,2)}function va(t,e){return M(1+gt.count(V(t),t),e,3)}function Wr(t,e){return M(t.getUTCMilliseconds(),e,3)}function Ma(t,e){return Wr(t,e)+"000"}function wa(t,e){return M(t.getUTCMonth()+1,e,2)}function _a(t,e){return M(t.getUTCMinutes(),e,2)}function Sa(t,e){return M(t.getUTCSeconds(),e,2)}function Ta(t){var e=t.getUTCDay();return e===0?7:e}function Da(t,e){return M(xt.count(V(t)-1,t),e,2)}function Pr(t){var e=t.getUTCDay();return e>=4||e===0?J(t):J.ceil(t)}function Ca(t,e){return t=Pr(t),M(J.count(V(t),t)+(V(t).getUTCDay()===4),e,2)}function ba(t){return t.getUTCDay()}function Ua(t,e){return M(lt.count(V(t)-1,t),e,2)}function ka(t,e){return M(t.getUTCFullYear()%100,e,2)}function Aa(t,e){return t=Pr(t),M(t.getUTCFullYear()%100,e,2)}function Fa(t,e){return M(t.getUTCFullYear()%1e4,e,4)}function Na(t,e){var r=t.getUTCDay();return t=r>=4||r===0?J(t):J.ceil(t),M(t.getUTCFullYear()%1e4,e,4)}function La(){return"+0000"}function Nr(){return"%"}function Lr(t){return+t}function Hr(t){return Math.floor(+t/1e3)}var ft,ct,Ir,Or,qr;ue({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function ue(t){return ft=ie(t),ct=ft.format,Ir=ft.parse,Or=ft.utcFormat,qr=ft.utcParse,ft}var le={cellSize:13,cellGap:2,marginTop:20,marginLeft:30,marginBottom:4},se=["#9be9a8","#40c463","#30a14e","#216e39"],Ha=["Mon","","Wed","","Fri","",""],Ya=["Sun","","Tue","","Thu","","Sat"];function Ea(t){return t==="sunday"?Ya:Ha}var Wa=ct("%b"),fe=ct("%Y-%m-%d"),zr=ct("%a, %b %-d, %Y");function Pa(t){try{return getComputedStyle(t).getPropertyValue("--tblr-bg-surface"),se}catch{return se}}function Ia(t){let e=new Map;for(let r of t)e.set(r.date,r);return e}function $r(t){return t==="sunday"?nt:X}function Oa(t,e,r,n="monday"){let o=$r(n),a=o.floor(t),i=[],u=new Date(t);for(;u<=e;){let s=fe(u),l=o.count(a,u),c=u.getDay(),p=n==="sunday"?c:(c+6)%7,g=c===0||c===6;i.push({date:new Date(u),dateStr:s,entry:r.get(s)||null,week:l,day:p,isWeekend:g}),u=z.offset(u,1)}return i}function qa(){let t=document.createElement("div");return t.className="heatmap-tooltip",t.style.display="none",t}function Vr(t){if(t.length===0)return 0;let e=new Set(t.filter(a=>a.hours>0).map(a=>a.date));if(e.size===0)return 0;let r=new Date;r.setHours(0,0,0,0);let n=new Date(r);e.has(fe(n))||(n=z.offset(n,-1));let o=0;for(;e.has(fe(n));)o++,n=z.offset(n,-1);return o}function Br(t){let e=t.filter(a=>a.hours>0);if(e.length===0)return{totalHours:0,avgHours:0,busiestDay:null};let r=Math.round(e.reduce((a,i)=>a+i.hours,0)*10)/10,n=Math.round(r/e.length*10)/10,o=e.reduce((a,i)=>i.hours>a.hours?i:a);return{totalHours:r,avgHours:n,busiestDay:{date:o.date,hours:o.hours}}}function Rr(t,e){let r=t.querySelector(".heatmap-stats");r&&r.remove();let n=Vr(e),o=Br(e),a=document.createElement("div");a.className="heatmap-stats";let i=[];if(i.push(`<span>\u{1F525} <span class="stat-value">${n}</span> days</span>`),i.push(`<span>Total: <span class="stat-value">${o.totalHours}h</span></span>`),i.push(`<span>Avg: <span class="stat-value">${o.avgHours}h/day</span></span>`),o.busiestDay){let u=new Date(o.busiestDay.date+"T00:00:00"),s=zr(u);i.push(`<span>Busiest: <span class="stat-value">${s} \u2014 ${o.busiestDay.hours.toFixed(1)}h</span></span>`)}a.innerHTML=i.join(""),t.appendChild(a)}function ce(t,e,r=le,n,o,a="monday"){if(t.innerHTML="",!e.days||e.days.length===0){let h=document.createElement("div");h.textContent=o||"No tracking data available",h.style.padding="1rem",h.style.color="var(--tblr-secondary, #6c757d)",t.appendChild(h);return}let i=Ia(e.days),u=new Date(e.range.begin),s=new Date(e.range.end),l=Oa(u,s,i,a),c=ht(e.days,h=>h.hours)||1,p=Pa(t),g=yt().domain([0,c]).range(p),{cellGap:x,marginTop:w,marginLeft:_,marginBottom:W}=r,P=(ht(l,h=>h.week)??0)+1,H=t.clientWidth||800,T=Math.min(18,Math.max(2,Math.floor((H-_)/P)-x)),N=T+x,D=_+P*N,at=w+7*N+W,I=document.createElement("div");I.style.maxWidth=`${D}px`,I.style.margin="0 auto",t.appendChild(I);let B=Rt(I).append("svg").attr("width",D).attr("height",at).attr("class","heatmap-svg"),it=$r(a),K=[],d=it.floor(u);vt.range(vt.ceil(u),s).forEach(h=>{K.push({date:h,week:it.count(d,h)})}),B.selectAll(".month-label").data(K).join("text").attr("class","heatmap-label month-label").attr("x",h=>_+h.week*N).attr("y",w-6).text(h=>Wa(h.date)),B.selectAll(".day-label").data(Ea(a)).join("text").attr("class","heatmap-label day-label").attr("x",_-6).attr("y",(h,C)=>w+C*N+T-2).attr("text-anchor","end").text(h=>h),document.querySelectorAll(".heatmap-tooltip").forEach(h=>h.remove());let U=qa();U.style.position="fixed",document.body.appendChild(U),B.selectAll(".heatmap-cell").data(l).join("rect").attr("class",h=>{let C="heatmap-cell";return h.entry||(C+=" heatmap-empty"),h.isWeekend&&(C+=" heatmap-weekend"),C}).attr("x",h=>_+h.week*N).attr("y",h=>w+h.day*N).attr("width",T).attr("height",T).attr("fill",h=>h.entry?g(h.entry.hours):"").on("mouseenter",function(h,C){let ut=C.entry?C.entry.hours.toFixed(1):"0.0",Z=C.entry?C.entry.count:0;U.innerHTML=`<strong>${zr(C.date)}</strong><br>${ut}h (${Z} entries)`,U.style.display="block";let R=h.target.getBoundingClientRect();U.style.left=`${R.left+T/2}px`,U.style.top=`${R.top-U.offsetHeight-8}px`}).on("mouseleave",function(){U.style.display="none"}).on("click",function(h,C){n&&n(C.dateStr)})}function Ra(t){let e=t.getAttribute("data-url");if(!e){console.error("KimaiHeatmap: missing data-url attribute");return}let r=t.getAttribute("data-timesheet-url")||"/en/timesheet/",n=t.getAttribute("data-week-start")||"monday",o=t.getAttribute("data-projects"),a=o?JSON.parse(o):[],i=null,u=c=>{let p=`${c} - ${c}`,g=`${r}?daterange=${encodeURIComponent(p)}`;i&&(g+=`&projects[]=${i}`),window.location.href=g};t.innerHTML="";let s=document.createElement("div");s.className="heatmap-wrapper";let l=document.createElement("div");if(l.className="heatmap-svg-area",s.appendChild(l),a.length>0){let c=document.createElement("div");c.className="heatmap-filter";let p=document.createElement("select");p.className="form-select form-select-sm",p.setAttribute("aria-label","Filter by project");let g=document.createElement("option");g.value="",g.textContent="All Projects",p.appendChild(g);for(let x of a){let w=document.createElement("option");w.value=String(x.id),w.textContent=x.name,p.appendChild(w)}p.addEventListener("change",()=>{let x=p.value;i=x?parseInt(x,10):null;let w=x?`${e}?project=${x}`:e;fetch(w).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.json()}).then(_=>{ce(l,_,le,u,"No tracking data for this project",n),Rr(s,_.days)}).catch(_=>{console.error("KimaiHeatmap: failed to load filtered data",_)})}),c.appendChild(p),s.appendChild(c)}t.appendChild(s),fetch(e).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{ce(l,c,le,u,void 0,n),Rr(s,c.days)}).catch(c=>{console.error("KimaiHeatmap: failed to load data",c),l.textContent="Failed to load heatmap data"})}return un(za);})();
|