kimai-plugin-heatmap/Resources/public/heatmap.js
Christopher Mühl 57cc31827b
fix: responsive heatmap sizing with max cell size and centering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:45:09 +02:00

1 line
35 KiB
JavaScript

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