@prometa/sleek 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,4 +41,4 @@
41
41
  * https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
42
42
  * (c) 2016-2024 chartjs-plugin-zoom Contributors
43
43
  * Released under the MIT License
44
- */const Jn=n=>n&&n.enabled&&n.modifierKey,_h=(n,t)=>n&&t[n+"Key"],or=(n,t)=>n&&!t[n+"Key"];function Pe(n,t,e){return n===void 0?!0:typeof n=="string"?n.indexOf(t)!==-1:typeof n=="function"?n({chart:e}).indexOf(t)!==-1:!1}function qs(n,t){return typeof n=="function"&&(n=n({chart:t})),typeof n=="string"?{x:n.indexOf("x")!==-1,y:n.indexOf("y")!==-1}:{x:!1,y:!1}}function Lx(n,t){let e;return function(){return clearTimeout(e),e=setTimeout(n,t),t}}function Rx({x:n,y:t},e){const i=e.scales,s=Object.keys(i);for(let o=0;o<s.length;o++){const r=i[s[o]];if(t>=r.top&&t<=r.bottom&&n>=r.left&&n<=r.right)return r}return null}function wh(n,t,e){const{mode:i="xy",scaleMode:s,overScaleMode:o}=n||{},r=Rx(t,e),a=qs(i,e),l=qs(s,e);if(o){const h=qs(o,e);for(const u of["x","y"])h[u]&&(l[u]=a[u],a[u]=!1)}if(r&&l[r.axis])return[r];const c=[];return Y(e.scales,function(h){a[h.axis]&&c.push(h)}),c}const vo=new WeakMap;function nt(n){let t=vo.get(n);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},vo.set(n,t)),t}function Fx(n){vo.delete(n)}function vh(n,t,e,i){const s=Math.max(0,Math.min(1,(n-t)/e||0)),o=1-s;return{min:i*s,max:i*o}}function Mh(n,t){const e=n.isHorizontal()?t.x:t.y;return n.getValueForPixel(e)}function kh(n,t,e){const i=n.max-n.min,s=i*(t-1),o=Mh(n,e);return vh(o,n.min,i,s)}function Nx(n,t,e){const i=Mh(n,e);if(i===void 0)return{min:n.min,max:n.max};const s=Math.log10(n.min),o=Math.log10(n.max),r=Math.log10(i),a=o-s,l=a*(t-1),c=vh(r,s,a,l);return{min:Math.pow(10,s+c.min),max:Math.pow(10,o-c.max)}}function zx(n,t){return t&&(t[n.id]||t[n.axis])||{}}function vl(n,t,e,i,s){let o=e[i];if(o==="original"){const r=n.originalScaleLimits[t.id][i];o=R(r.options,r.scale)}return R(o,s)}function Wx(n,t,e){const i=n.getValueForPixel(t),s=n.getValueForPixel(e);return{min:Math.min(i,s),max:Math.max(i,s)}}function Hx(n,{min:t,max:e,minLimit:i,maxLimit:s},o){const r=(n-e+t)/2;t-=r,e+=r;const a=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=n/1e6;return We(t,a,c)&&(t=a),We(e,l,c)&&(e=l),t<i?(t=i,e=Math.min(i+n,s)):e>s&&(e=s,t=Math.max(s-n,i)),{min:t,max:e}}function Ge(n,{min:t,max:e},i,s=!1){const o=nt(n.chart),{options:r}=n,a=zx(n,i),{minRange:l=0}=a,c=vl(o,n,a,"min",-1/0),h=vl(o,n,a,"max",1/0);if(s==="pan"&&(t<c||e>h))return!0;const u=n.max-n.min,d=s?Math.max(e-t,l):u;if(s&&d===l&&u<=l)return!0;const g=Hx(d,{min:t,max:e,minLimit:c,maxLimit:h},o.originalScaleLimits[n.id]);return r.min=g.min,r.max=g.max,o.updatedScaleLimits[n.id]=g,n.parse(g.min)!==n.min||n.parse(g.max)!==n.max}function Yx(n,t,e,i){const s=kh(n,t,e),o={min:n.min+s.min,max:n.max-s.max};return Ge(n,o,i,!0)}function Bx(n,t,e,i){const s=Nx(n,t,e);return Ge(n,s,i,!0)}function Vx(n,t,e,i){Ge(n,Wx(n,t,e),i,!0)}const Ml=n=>n===0||isNaN(n)?0:n<0?Math.min(Math.round(n),-1):Math.max(Math.round(n),1);function jx(n){const e=n.getLabels().length-1;n.min>0&&(n.min-=1),n.max<e&&(n.max+=1)}function Xx(n,t,e,i){const s=kh(n,t,e);n.min===n.max&&t<1&&jx(n);const o={min:n.min+Ml(s.min),max:n.max-Ml(s.max)};return Ge(n,o,i,!0)}function Ux(n){return n.isHorizontal()?n.width:n.height}function qx(n,t,e){const s=n.getLabels().length-1;let{min:o,max:r}=n;const a=Math.max(r-o,1),l=Math.round(Ux(n)/Math.max(a,10)),c=Math.round(Math.abs(t/l));let h;return t<-l?(r=Math.min(r+c,s),o=a===1?r:r-a,h=r===s):t>l&&(o=Math.max(0,o-c),r=a===1?o:o+a,h=o===0),Ge(n,{min:o,max:r},e)||h}const $x={second:500,minute:30*1e3,hour:30*60*1e3,day:12*60*60*1e3,week:3.5*24*60*60*1e3,month:15*24*60*60*1e3,quarter:60*24*60*60*1e3,year:182*24*60*60*1e3};function Ph(n,t,e,i=!1){const{min:s,max:o,options:r}=n,a=r.time&&r.time.round,l=$x[a]||0,c=n.getValueForPixel(n.getPixelForValue(s+l)-t),h=n.getValueForPixel(n.getPixelForValue(o+l)-t);return isNaN(c)||isNaN(h)?!0:Ge(n,{min:c,max:h},e,i?"pan":!1)}function kl(n,t,e){return Ph(n,t,e,!0)}const Mo={category:Xx,default:Yx,logarithmic:Bx},ko={default:Vx},Po={category:qx,default:Ph,logarithmic:kl,timeseries:kl};function Gx(n,t,e){const{id:i,options:{min:s,max:o}}=n;if(!t[i]||!e[i])return!0;const r=e[i];return r.min!==s||r.max!==o}function Pl(n,t){Y(n,(e,i)=>{t[i]||delete n[i]})}function fn(n,t){const{scales:e}=n,{originalScaleLimits:i,updatedScaleLimits:s}=t;return Y(e,function(o){Gx(o,i,s)&&(i[o.id]={min:{scale:o.min,options:o.options.min},max:{scale:o.max,options:o.options.max}})}),Pl(i,e),Pl(s,e),i}function Tl(n,t,e,i){const s=Mo[n.type]||Mo.default;L(s,[n,t,e,i])}function Sl(n,t,e,i){const s=ko[n.type]||ko.default;L(s,[n,t,e,i])}function Qx(n){const t=n.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function rr(n,t,e="none",i="api"){const{x:s=1,y:o=1,focalPoint:r=Qx(n)}=typeof t=="number"?{x:t,y:t}:t,a=nt(n),{options:{limits:l,zoom:c}}=a;fn(n,a);const h=s!==1,u=o!==1,d=wh(c,r,n);Y(d||n.scales,function(g){g.isHorizontal()&&h?Tl(g,s,r,l):!g.isHorizontal()&&u&&Tl(g,o,r,l)}),n.update(e),L(c.onZoom,[{chart:n,trigger:i}])}function Th(n,t,e,i="none",s="api"){const o=nt(n),{options:{limits:r,zoom:a}}=o,{mode:l="xy"}=a;fn(n,o);const c=Pe(l,"x",n),h=Pe(l,"y",n);Y(n.scales,function(u){u.isHorizontal()&&c?Sl(u,t.x,e.x,r):!u.isHorizontal()&&h&&Sl(u,t.y,e.y,r)}),n.update(i),L(a.onZoom,[{chart:n,trigger:s}])}function Zx(n,t,e,i="none",s="api"){var a;const o=nt(n);fn(n,o);const r=n.scales[t];Ge(r,e,void 0,!0),n.update(i),L((a=o.options.zoom)==null?void 0:a.onZoom,[{chart:n,trigger:s}])}function Kx(n,t="default"){const e=nt(n),i=fn(n,e);Y(n.scales,function(s){const o=s.options;i[s.id]?(o.min=i[s.id].min.options,o.max=i[s.id].max.options):(delete o.min,delete o.max),delete e.updatedScaleLimits[s.id]}),n.update(t),L(e.options.zoom.onZoomComplete,[{chart:n}])}function Jx(n,t){const e=n.originalScaleLimits[t];if(!e)return;const{min:i,max:s}=e;return R(s.options,s.scale)-R(i.options,i.scale)}function t_(n){const t=nt(n);let e=1,i=1;return Y(n.scales,function(s){const o=Jx(t,s.id);if(o){const r=Math.round(o/(s.max-s.min)*100)/100;e=Math.min(e,r),i=Math.max(i,r)}}),e<1?e:i}function Dl(n,t,e,i){const{panDelta:s}=i,o=s[n.id]||0;zt(o)===zt(t)&&(t+=o);const r=Po[n.type]||Po.default;L(r,[n,t,e])?s[n.id]=0:s[n.id]=t}function Sh(n,t,e,i="none"){const{x:s=0,y:o=0}=typeof t=="number"?{x:t,y:t}:t,r=nt(n),{options:{pan:a,limits:l}}=r,{onPan:c}=a||{};fn(n,r);const h=s!==0,u=o!==0;Y(e||n.scales,function(d){d.isHorizontal()&&h?Dl(d,s,l,r):!d.isHorizontal()&&u&&Dl(d,o,l,r)}),n.update(i),L(c,[{chart:n}])}function Dh(n){const t=nt(n);fn(n,t);const e={};for(const i of Object.keys(n.scales)){const{min:s,max:o}=t.originalScaleLimits[i]||{min:{},max:{}};e[i]={min:s.scale,max:o.scale}}return e}function e_(n){const t=nt(n),e={};for(const i of Object.keys(n.scales))e[i]=t.updatedScaleLimits[i];return e}function n_(n){const t=Dh(n);for(const e of Object.keys(n.scales)){const{min:i,max:s}=t[e];if(i!==void 0&&n.scales[e].min!==i||s!==void 0&&n.scales[e].max!==s)return!0}return!1}function Ol(n){const t=nt(n);return t.panning||t.dragging}const Cl=(n,t,e)=>Math.min(e,Math.max(t,n));function Tt(n,t){const{handlers:e}=nt(n),i=e[t];i&&i.target&&(i.target.removeEventListener(t,i),delete e[t])}function Un(n,t,e,i){const{handlers:s,options:o}=nt(n),r=s[e];if(r&&r.target===t)return;Tt(n,e),s[e]=l=>i(n,l,o),s[e].target=t;const a=e==="wheel"?!1:void 0;t.addEventListener(e,s[e],{passive:a})}function i_(n,t){const e=nt(n);e.dragStart&&(e.dragging=!0,e.dragEnd=t,n.update("none"))}function s_(n,t){const e=nt(n);!e.dragStart||t.key!=="Escape"||(Tt(n,"keydown"),e.dragging=!1,e.dragStart=e.dragEnd=null,n.update("none"))}function To(n,t){if(n.target!==t.canvas){const e=t.canvas.getBoundingClientRect();return{x:n.clientX-e.left,y:n.clientY-e.top}}return qt(n,t)}function Oh(n,t,e){const{onZoomStart:i,onZoomRejected:s}=e;if(i){const o=To(t,n);if(L(i,[{chart:n,event:t,point:o}])===!1)return L(s,[{chart:n,event:t}]),!1}}function o_(n,t){if(n.legend){const o=qt(t,n);if(Qt(o,n.legend))return}const e=nt(n),{pan:i,zoom:s={}}=e.options;if(t.button!==0||_h(Jn(i),t)||or(Jn(s.drag),t))return L(s.onZoomRejected,[{chart:n,event:t}]);Oh(n,t,s)!==!1&&(e.dragStart=t,Un(n,n.canvas.ownerDocument,"mousemove",i_),Un(n,window.document,"keydown",s_))}function r_({begin:n,end:t},e){let i=t.x-n.x,s=t.y-n.y;const o=Math.abs(i/s);o>e?i=Math.sign(i)*Math.abs(s*e):o<e&&(s=Math.sign(s)*Math.abs(i/e)),t.x=n.x+i,t.y=n.y+s}function El(n,t,e,{min:i,max:s,prop:o}){n[i]=Cl(Math.min(e.begin[o],e.end[o]),t[i],t[s]),n[s]=Cl(Math.max(e.begin[o],e.end[o]),t[i],t[s])}function a_(n,t,e){const i={begin:To(t.dragStart,n),end:To(t.dragEnd,n)};if(e){const s=n.chartArea.width/n.chartArea.height;r_(i,s)}return i}function Ch(n,t,e,i){const s=Pe(t,"x",n),o=Pe(t,"y",n),{top:r,left:a,right:l,bottom:c,width:h,height:u}=n.chartArea,d={top:r,left:a,right:l,bottom:c},g=a_(n,e,i&&s&&o);s&&El(d,n.chartArea,g,{min:"left",max:"right",prop:"x"}),o&&El(d,n.chartArea,g,{min:"top",max:"bottom",prop:"y"});const p=d.right-d.left,b=d.bottom-d.top;return{...d,width:p,height:b,zoomX:s&&p?1+(h-p)/h:1,zoomY:o&&b?1+(u-b)/u:1}}function l_(n,t){const e=nt(n);if(!e.dragStart)return;Tt(n,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:r}}=e.options.zoom,a=Ch(n,i,{dragStart:e.dragStart,dragEnd:t},r),l=Pe(i,"x",n)?a.width:0,c=Pe(i,"y",n)?a.height:0,h=Math.sqrt(l*l+c*c);if(e.dragStart=e.dragEnd=null,h<=o){e.dragging=!1,n.update("none");return}Th(n,{x:a.left,y:a.top},{x:a.right,y:a.bottom},"zoom","drag"),e.dragging=!1,e.filterNextClick=!0,L(s,[{chart:n}])}function c_(n,t,e){if(or(Jn(e.wheel),t)){L(e.onZoomRejected,[{chart:n,event:t}]);return}if(Oh(n,t,e)!==!1&&(t.cancelable&&t.preventDefault(),t.deltaY!==void 0))return!0}function h_(n,t){const{handlers:{onZoomComplete:e},options:{zoom:i}}=nt(n);if(!c_(n,t,i))return;const s=t.target.getBoundingClientRect(),o=i.wheel.speed,r=t.deltaY>=0?2-1/(1-o):1+o,a={x:r,y:r,focalPoint:{x:t.clientX-s.left,y:t.clientY-s.top}};rr(n,a,"zoom","wheel"),L(e,[{chart:n}])}function u_(n,t,e,i){e&&(nt(n).handlers[t]=Lx(()=>L(e,[{chart:n}]),i))}function d_(n,t){const e=n.canvas,{wheel:i,drag:s,onZoomComplete:o}=t.zoom;i.enabled?(Un(n,e,"wheel",h_),u_(n,"onZoomComplete",o,250)):Tt(n,"wheel"),s.enabled?(Un(n,e,"mousedown",o_),Un(n,e.ownerDocument,"mouseup",l_)):(Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"keydown"))}function f_(n){Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"wheel"),Tt(n,"click"),Tt(n,"keydown")}function g_(n,t){return function(e,i){const{pan:s,zoom:o={}}=t.options;if(!s||!s.enabled)return!1;const r=i&&i.srcEvent;return r&&!t.panning&&i.pointerType==="mouse"&&(or(Jn(s),r)||_h(Jn(o.drag),r))?(L(s.onPanRejected,[{chart:n,event:i}]),!1):!0}}function m_(n,t){const e=Math.abs(n.clientX-t.clientX),i=Math.abs(n.clientY-t.clientY),s=e/i;let o,r;return s>.3&&s<1.7?o=r=!0:e>i?o=!0:r=!0,{x:o,y:r}}function Eh(n,t,e){if(t.scale){const{center:i,pointers:s}=e,o=1/t.scale*e.scale,r=e.target.getBoundingClientRect(),a=m_(s[0],s[1]),l=t.options.zoom.mode,c={x:a.x&&Pe(l,"x",n)?o:1,y:a.y&&Pe(l,"y",n)?o:1,focalPoint:{x:i.x-r.left,y:i.y-r.top}};rr(n,c,"zoom","pinch"),t.scale=e.scale}}function p_(n,t,e){if(t.options.zoom.pinch.enabled){const i=qt(e,n);L(t.options.zoom.onZoomStart,[{chart:n,event:e,point:i}])===!1?(t.scale=null,L(t.options.zoom.onZoomRejected,[{chart:n,event:e}])):t.scale=1}}function b_(n,t,e){t.scale&&(Eh(n,t,e),t.scale=null,L(t.options.zoom.onZoomComplete,[{chart:n}]))}function Ah(n,t,e){const i=t.delta;i&&(t.panning=!0,Sh(n,{x:e.deltaX-i.x,y:e.deltaY-i.y},t.panScales),t.delta={x:e.deltaX,y:e.deltaY})}function y_(n,t,e){const{enabled:i,onPanStart:s,onPanRejected:o}=t.options.pan;if(!i)return;const r=e.target.getBoundingClientRect(),a={x:e.center.x-r.left,y:e.center.y-r.top};if(L(s,[{chart:n,event:e,point:a}])===!1)return L(o,[{chart:n,event:e}]);t.panScales=wh(t.options.pan,a,n),t.delta={x:0,y:0},Ah(n,t,e)}function x_(n,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,L(t.options.pan.onPanComplete,[{chart:n}]))}const So=new WeakMap;function Al(n,t){const e=nt(n),i=n.canvas,{pan:s,zoom:o}=t,r=new Xn.Manager(i);o&&o.pinch.enabled&&(r.add(new Xn.Pinch),r.on("pinchstart",a=>p_(n,e,a)),r.on("pinch",a=>Eh(n,e,a)),r.on("pinchend",a=>b_(n,e,a))),s&&s.enabled&&(r.add(new Xn.Pan({threshold:s.threshold,enable:g_(n,e)})),r.on("panstart",a=>y_(n,e,a)),r.on("panmove",a=>Ah(n,e,a)),r.on("panend",()=>x_(n,e))),So.set(n,r)}function Il(n){const t=So.get(n);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),So.delete(n))}function __(n,t){var r,a,l,c;const{pan:e,zoom:i}=n,{pan:s,zoom:o}=t;return((a=(r=i==null?void 0:i.zoom)==null?void 0:r.pinch)==null?void 0:a.enabled)!==((c=(l=o==null?void 0:o.zoom)==null?void 0:l.pinch)==null?void 0:c.enabled)||(e==null?void 0:e.enabled)!==(s==null?void 0:s.enabled)||(e==null?void 0:e.threshold)!==(s==null?void 0:s.threshold)}var w_="2.2.0";function Fi(n,t,e){const i=e.zoom.drag,{dragStart:s,dragEnd:o}=nt(n);if(i.drawTime!==t||!o)return;const{left:r,top:a,width:l,height:c}=Ch(n,e.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),h=n.ctx;h.save(),h.beginPath(),h.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",h.fillRect(r,a,l,c),i.borderWidth>0&&(h.lineWidth=i.borderWidth,h.strokeStyle=i.borderColor||"rgba(225,225,225)",h.strokeRect(r,a,l,c)),h.restore()}var v_={id:"zoom",version:w_,defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(n,t,e){const i=nt(n);i.options=e,Object.prototype.hasOwnProperty.call(e.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(e.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(e.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),Xn&&Al(n,e),n.pan=(s,o,r)=>Sh(n,s,o,r),n.zoom=(s,o)=>rr(n,s,o),n.zoomRect=(s,o,r)=>Th(n,s,o,r),n.zoomScale=(s,o,r)=>Zx(n,s,o,r),n.resetZoom=s=>Kx(n,s),n.getZoomLevel=()=>t_(n),n.getInitialScaleBounds=()=>Dh(n),n.getZoomedScaleBounds=()=>e_(n),n.isZoomedOrPanned=()=>n_(n),n.isZoomingOrPanning=()=>Ol(n)},beforeEvent(n,{event:t}){if(Ol(n))return!1;if(t.type==="click"||t.type==="mouseup"){const e=nt(n);if(e.filterNextClick)return e.filterNextClick=!1,!1}},beforeUpdate:function(n,t,e){const i=nt(n),s=i.options;i.options=e,__(s,e)&&(Il(n),Al(n,e)),d_(n,e)},beforeDatasetsDraw(n,t,e){Fi(n,"beforeDatasetsDraw",e)},afterDatasetsDraw(n,t,e){Fi(n,"afterDatasetsDraw",e)},beforeDraw(n,t,e){Fi(n,"beforeDraw",e)},afterDraw(n,t,e){Fi(n,"afterDraw",e)},stop:function(n){f_(n),Xn&&Il(n),Fx(n)},panFunctions:Po,zoomFunctions:Mo,zoomRectFunctions:ko};Mt.register(i0,v_,Dx);Mt.defaults.maintainAspectRatio=!1;Mt.defaults.datasets.line.spanGaps=!0;var mt,nn;class Ih extends HTMLElement{constructor(){super(...arguments);wn(this,mt,null);wn(this,nn,!1)}connectedCallback(){this.style.display="block",this.style.width="100%",this.style.height="100%";const e=document.createElement("canvas");this.appendChild(e);const i=this.getAttributeNames().filter(s=>s.startsWith("plugins")||s.startsWith("interaction")||s.startsWith("scales")||s==="responsive").reduce((s,o)=>{const r=o.split("."),a=r.pop(),l=this.getAttribute(o),c=r.reduce((h,u)=>(u in h||(h[u]={}),h[u]),s);return c[a]=Ll.trySafeEval(l),s},{});ue(this,mt,new Mt(e,{type:this.getAttribute("type"),data:{datasets:[]},options:i}))}set data(e){gt(this,mt).data=e,this.update()}set options(e){gt(this,mt).options=e}addOrReplaceDataset(e,i){const s=gt(this,mt).data.datasets.findIndex(e);s===-1?gt(this,mt).data.datasets=[...gt(this,mt).data.datasets,i]:gt(this,mt).data.datasets.splice(s,1,i),this.update()}removeDataset(e){gt(this,mt).data.datasets=gt(this,mt).data.datasets.filter(i=>!e(i)),this.update()}addOrReplaceAnnotation(e,i){gt(this,mt).options.plugins||(gt(this,mt).options.plugins={}),gt(this,mt).options.plugins.annotation||(gt(this,mt).options.plugins.annotation={annotations:{}});const s=gt(this,mt).options.plugins.annotation.annotations,o=Object.values(s).findIndex(e);if(o===-1){const r=Object.keys(s).length;s[r]=i}else{const r=Object.keys(s)[o];s[r]=i}}removeAnnotation(e){}update(){gt(this,nn)||(ue(this,nn,!0),setTimeout(()=>{gt(this,mt).update("none"),ue(this,nn,!1)},100))}}mt=new WeakMap,nn=new WeakMap;customElements.define("chartjs-chart",Ih);var ze,ti;class Lh extends HTMLElement{constructor(){super(...arguments);wn(this,ze);wn(this,ti,null)}connectedCallback(){if(this.getAttribute("included")==="false")return;ue(this,ze,this.closest("chartjs-chart")),this.syncDataset(),new MutationObserver(()=>this.syncDataset()).observe(this,{attributes:!0}),this.getAttribute("data-from")&&new MutationObserver(o=>{this.syncDataset()}).observe(this.closest("chartjs-chart"),{childList:!0,attributes:!0,subtree:!0})}disconnectedCallback(){var e;(e=gt(this,ze))==null||e.removeDataset(i=>i.owner===this),ue(this,ze,null)}syncDataset(){var s;const e=this.getAttributeNames().filter(o=>!o.startsWith("data")&&!o.startsWith(":")).map(o=>[M_(Rh(o)),this.getAttribute(o)]).reduce((o,[r,a])=>(o[r]=Ll.trySafeEval(a),o),{}),i=this.data;(s=gt(this,ze))==null||s.addOrReplaceDataset(o=>o.owner===this,{...e,data:i,owner:this})}get data(){const e=this.getAttribute("data");if(e)return ue(this,ti,JSON.parse(e));const i=this.getAttribute("data-from");if(i){const s=this.closest("chartjs-chart").querySelector(`chartjs-dataset${i}`);if(s)return ue(this,ti,s.data)}}}ze=new WeakMap,ti=new WeakMap;customElements.define("chartjs-dataset",Lh);function M_(n){return n==="xAxisId"?"xAxisID":n==="yAxisId"?"yAxisID":n}function Rh(n){return n.replace(/([-_][a-z])/g,t=>t.toUpperCase().replace("-","").replace("_",""))}exports.ChartDataset=Lh;exports.ChartElement=Ih;exports.snakeToCamel=Rh;
44
+ */const Jn=n=>n&&n.enabled&&n.modifierKey,_h=(n,t)=>n&&t[n+"Key"],or=(n,t)=>n&&!t[n+"Key"];function Pe(n,t,e){return n===void 0?!0:typeof n=="string"?n.indexOf(t)!==-1:typeof n=="function"?n({chart:e}).indexOf(t)!==-1:!1}function qs(n,t){return typeof n=="function"&&(n=n({chart:t})),typeof n=="string"?{x:n.indexOf("x")!==-1,y:n.indexOf("y")!==-1}:{x:!1,y:!1}}function Lx(n,t){let e;return function(){return clearTimeout(e),e=setTimeout(n,t),t}}function Rx({x:n,y:t},e){const i=e.scales,s=Object.keys(i);for(let o=0;o<s.length;o++){const r=i[s[o]];if(t>=r.top&&t<=r.bottom&&n>=r.left&&n<=r.right)return r}return null}function wh(n,t,e){const{mode:i="xy",scaleMode:s,overScaleMode:o}=n||{},r=Rx(t,e),a=qs(i,e),l=qs(s,e);if(o){const h=qs(o,e);for(const u of["x","y"])h[u]&&(l[u]=a[u],a[u]=!1)}if(r&&l[r.axis])return[r];const c=[];return Y(e.scales,function(h){a[h.axis]&&c.push(h)}),c}const vo=new WeakMap;function nt(n){let t=vo.get(n);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},vo.set(n,t)),t}function Fx(n){vo.delete(n)}function vh(n,t,e,i){const s=Math.max(0,Math.min(1,(n-t)/e||0)),o=1-s;return{min:i*s,max:i*o}}function Mh(n,t){const e=n.isHorizontal()?t.x:t.y;return n.getValueForPixel(e)}function kh(n,t,e){const i=n.max-n.min,s=i*(t-1),o=Mh(n,e);return vh(o,n.min,i,s)}function Nx(n,t,e){const i=Mh(n,e);if(i===void 0)return{min:n.min,max:n.max};const s=Math.log10(n.min),o=Math.log10(n.max),r=Math.log10(i),a=o-s,l=a*(t-1),c=vh(r,s,a,l);return{min:Math.pow(10,s+c.min),max:Math.pow(10,o-c.max)}}function zx(n,t){return t&&(t[n.id]||t[n.axis])||{}}function vl(n,t,e,i,s){let o=e[i];if(o==="original"){const r=n.originalScaleLimits[t.id][i];o=R(r.options,r.scale)}return R(o,s)}function Wx(n,t,e){const i=n.getValueForPixel(t),s=n.getValueForPixel(e);return{min:Math.min(i,s),max:Math.max(i,s)}}function Hx(n,{min:t,max:e,minLimit:i,maxLimit:s},o){const r=(n-e+t)/2;t-=r,e+=r;const a=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=n/1e6;return We(t,a,c)&&(t=a),We(e,l,c)&&(e=l),t<i?(t=i,e=Math.min(i+n,s)):e>s&&(e=s,t=Math.max(s-n,i)),{min:t,max:e}}function Ge(n,{min:t,max:e},i,s=!1){const o=nt(n.chart),{options:r}=n,a=zx(n,i),{minRange:l=0}=a,c=vl(o,n,a,"min",-1/0),h=vl(o,n,a,"max",1/0);if(s==="pan"&&(t<c||e>h))return!0;const u=n.max-n.min,d=s?Math.max(e-t,l):u;if(s&&d===l&&u<=l)return!0;const g=Hx(d,{min:t,max:e,minLimit:c,maxLimit:h},o.originalScaleLimits[n.id]);return r.min=g.min,r.max=g.max,o.updatedScaleLimits[n.id]=g,n.parse(g.min)!==n.min||n.parse(g.max)!==n.max}function Yx(n,t,e,i){const s=kh(n,t,e),o={min:n.min+s.min,max:n.max-s.max};return Ge(n,o,i,!0)}function Bx(n,t,e,i){const s=Nx(n,t,e);return Ge(n,s,i,!0)}function Vx(n,t,e,i){Ge(n,Wx(n,t,e),i,!0)}const Ml=n=>n===0||isNaN(n)?0:n<0?Math.min(Math.round(n),-1):Math.max(Math.round(n),1);function jx(n){const e=n.getLabels().length-1;n.min>0&&(n.min-=1),n.max<e&&(n.max+=1)}function Xx(n,t,e,i){const s=kh(n,t,e);n.min===n.max&&t<1&&jx(n);const o={min:n.min+Ml(s.min),max:n.max-Ml(s.max)};return Ge(n,o,i,!0)}function Ux(n){return n.isHorizontal()?n.width:n.height}function qx(n,t,e){const s=n.getLabels().length-1;let{min:o,max:r}=n;const a=Math.max(r-o,1),l=Math.round(Ux(n)/Math.max(a,10)),c=Math.round(Math.abs(t/l));let h;return t<-l?(r=Math.min(r+c,s),o=a===1?r:r-a,h=r===s):t>l&&(o=Math.max(0,o-c),r=a===1?o:o+a,h=o===0),Ge(n,{min:o,max:r},e)||h}const $x={second:500,minute:30*1e3,hour:30*60*1e3,day:12*60*60*1e3,week:3.5*24*60*60*1e3,month:15*24*60*60*1e3,quarter:60*24*60*60*1e3,year:182*24*60*60*1e3};function Ph(n,t,e,i=!1){const{min:s,max:o,options:r}=n,a=r.time&&r.time.round,l=$x[a]||0,c=n.getValueForPixel(n.getPixelForValue(s+l)-t),h=n.getValueForPixel(n.getPixelForValue(o+l)-t);return isNaN(c)||isNaN(h)?!0:Ge(n,{min:c,max:h},e,i?"pan":!1)}function kl(n,t,e){return Ph(n,t,e,!0)}const Mo={category:Xx,default:Yx,logarithmic:Bx},ko={default:Vx},Po={category:qx,default:Ph,logarithmic:kl,timeseries:kl};function Gx(n,t,e){const{id:i,options:{min:s,max:o}}=n;if(!t[i]||!e[i])return!0;const r=e[i];return r.min!==s||r.max!==o}function Pl(n,t){Y(n,(e,i)=>{t[i]||delete n[i]})}function fn(n,t){const{scales:e}=n,{originalScaleLimits:i,updatedScaleLimits:s}=t;return Y(e,function(o){Gx(o,i,s)&&(i[o.id]={min:{scale:o.min,options:o.options.min},max:{scale:o.max,options:o.options.max}})}),Pl(i,e),Pl(s,e),i}function Tl(n,t,e,i){const s=Mo[n.type]||Mo.default;L(s,[n,t,e,i])}function Sl(n,t,e,i){const s=ko[n.type]||ko.default;L(s,[n,t,e,i])}function Qx(n){const t=n.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function rr(n,t,e="none",i="api"){const{x:s=1,y:o=1,focalPoint:r=Qx(n)}=typeof t=="number"?{x:t,y:t}:t,a=nt(n),{options:{limits:l,zoom:c}}=a;fn(n,a);const h=s!==1,u=o!==1,d=wh(c,r,n);Y(d||n.scales,function(g){g.isHorizontal()&&h?Tl(g,s,r,l):!g.isHorizontal()&&u&&Tl(g,o,r,l)}),n.update(e),L(c.onZoom,[{chart:n,trigger:i}])}function Th(n,t,e,i="none",s="api"){const o=nt(n),{options:{limits:r,zoom:a}}=o,{mode:l="xy"}=a;fn(n,o);const c=Pe(l,"x",n),h=Pe(l,"y",n);Y(n.scales,function(u){u.isHorizontal()&&c?Sl(u,t.x,e.x,r):!u.isHorizontal()&&h&&Sl(u,t.y,e.y,r)}),n.update(i),L(a.onZoom,[{chart:n,trigger:s}])}function Zx(n,t,e,i="none",s="api"){var a;const o=nt(n);fn(n,o);const r=n.scales[t];Ge(r,e,void 0,!0),n.update(i),L((a=o.options.zoom)==null?void 0:a.onZoom,[{chart:n,trigger:s}])}function Kx(n,t="default"){const e=nt(n),i=fn(n,e);Y(n.scales,function(s){const o=s.options;i[s.id]?(o.min=i[s.id].min.options,o.max=i[s.id].max.options):(delete o.min,delete o.max),delete e.updatedScaleLimits[s.id]}),n.update(t),L(e.options.zoom.onZoomComplete,[{chart:n}])}function Jx(n,t){const e=n.originalScaleLimits[t];if(!e)return;const{min:i,max:s}=e;return R(s.options,s.scale)-R(i.options,i.scale)}function t_(n){const t=nt(n);let e=1,i=1;return Y(n.scales,function(s){const o=Jx(t,s.id);if(o){const r=Math.round(o/(s.max-s.min)*100)/100;e=Math.min(e,r),i=Math.max(i,r)}}),e<1?e:i}function Dl(n,t,e,i){const{panDelta:s}=i,o=s[n.id]||0;zt(o)===zt(t)&&(t+=o);const r=Po[n.type]||Po.default;L(r,[n,t,e])?s[n.id]=0:s[n.id]=t}function Sh(n,t,e,i="none"){const{x:s=0,y:o=0}=typeof t=="number"?{x:t,y:t}:t,r=nt(n),{options:{pan:a,limits:l}}=r,{onPan:c}=a||{};fn(n,r);const h=s!==0,u=o!==0;Y(e||n.scales,function(d){d.isHorizontal()&&h?Dl(d,s,l,r):!d.isHorizontal()&&u&&Dl(d,o,l,r)}),n.update(i),L(c,[{chart:n}])}function Dh(n){const t=nt(n);fn(n,t);const e={};for(const i of Object.keys(n.scales)){const{min:s,max:o}=t.originalScaleLimits[i]||{min:{},max:{}};e[i]={min:s.scale,max:o.scale}}return e}function e_(n){const t=nt(n),e={};for(const i of Object.keys(n.scales))e[i]=t.updatedScaleLimits[i];return e}function n_(n){const t=Dh(n);for(const e of Object.keys(n.scales)){const{min:i,max:s}=t[e];if(i!==void 0&&n.scales[e].min!==i||s!==void 0&&n.scales[e].max!==s)return!0}return!1}function Ol(n){const t=nt(n);return t.panning||t.dragging}const Cl=(n,t,e)=>Math.min(e,Math.max(t,n));function Tt(n,t){const{handlers:e}=nt(n),i=e[t];i&&i.target&&(i.target.removeEventListener(t,i),delete e[t])}function Un(n,t,e,i){const{handlers:s,options:o}=nt(n),r=s[e];if(r&&r.target===t)return;Tt(n,e),s[e]=l=>i(n,l,o),s[e].target=t;const a=e==="wheel"?!1:void 0;t.addEventListener(e,s[e],{passive:a})}function i_(n,t){const e=nt(n);e.dragStart&&(e.dragging=!0,e.dragEnd=t,n.update("none"))}function s_(n,t){const e=nt(n);!e.dragStart||t.key!=="Escape"||(Tt(n,"keydown"),e.dragging=!1,e.dragStart=e.dragEnd=null,n.update("none"))}function To(n,t){if(n.target!==t.canvas){const e=t.canvas.getBoundingClientRect();return{x:n.clientX-e.left,y:n.clientY-e.top}}return qt(n,t)}function Oh(n,t,e){const{onZoomStart:i,onZoomRejected:s}=e;if(i){const o=To(t,n);if(L(i,[{chart:n,event:t,point:o}])===!1)return L(s,[{chart:n,event:t}]),!1}}function o_(n,t){if(n.legend){const o=qt(t,n);if(Qt(o,n.legend))return}const e=nt(n),{pan:i,zoom:s={}}=e.options;if(t.button!==0||_h(Jn(i),t)||or(Jn(s.drag),t))return L(s.onZoomRejected,[{chart:n,event:t}]);Oh(n,t,s)!==!1&&(e.dragStart=t,Un(n,n.canvas.ownerDocument,"mousemove",i_),Un(n,window.document,"keydown",s_))}function r_({begin:n,end:t},e){let i=t.x-n.x,s=t.y-n.y;const o=Math.abs(i/s);o>e?i=Math.sign(i)*Math.abs(s*e):o<e&&(s=Math.sign(s)*Math.abs(i/e)),t.x=n.x+i,t.y=n.y+s}function El(n,t,e,{min:i,max:s,prop:o}){n[i]=Cl(Math.min(e.begin[o],e.end[o]),t[i],t[s]),n[s]=Cl(Math.max(e.begin[o],e.end[o]),t[i],t[s])}function a_(n,t,e){const i={begin:To(t.dragStart,n),end:To(t.dragEnd,n)};if(e){const s=n.chartArea.width/n.chartArea.height;r_(i,s)}return i}function Ch(n,t,e,i){const s=Pe(t,"x",n),o=Pe(t,"y",n),{top:r,left:a,right:l,bottom:c,width:h,height:u}=n.chartArea,d={top:r,left:a,right:l,bottom:c},g=a_(n,e,i&&s&&o);s&&El(d,n.chartArea,g,{min:"left",max:"right",prop:"x"}),o&&El(d,n.chartArea,g,{min:"top",max:"bottom",prop:"y"});const p=d.right-d.left,b=d.bottom-d.top;return{...d,width:p,height:b,zoomX:s&&p?1+(h-p)/h:1,zoomY:o&&b?1+(u-b)/u:1}}function l_(n,t){const e=nt(n);if(!e.dragStart)return;Tt(n,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:r}}=e.options.zoom,a=Ch(n,i,{dragStart:e.dragStart,dragEnd:t},r),l=Pe(i,"x",n)?a.width:0,c=Pe(i,"y",n)?a.height:0,h=Math.sqrt(l*l+c*c);if(e.dragStart=e.dragEnd=null,h<=o){e.dragging=!1,n.update("none");return}Th(n,{x:a.left,y:a.top},{x:a.right,y:a.bottom},"zoom","drag"),e.dragging=!1,e.filterNextClick=!0,L(s,[{chart:n}])}function c_(n,t,e){if(or(Jn(e.wheel),t)){L(e.onZoomRejected,[{chart:n,event:t}]);return}if(Oh(n,t,e)!==!1&&(t.cancelable&&t.preventDefault(),t.deltaY!==void 0))return!0}function h_(n,t){const{handlers:{onZoomComplete:e},options:{zoom:i}}=nt(n);if(!c_(n,t,i))return;const s=t.target.getBoundingClientRect(),o=i.wheel.speed,r=t.deltaY>=0?2-1/(1-o):1+o,a={x:r,y:r,focalPoint:{x:t.clientX-s.left,y:t.clientY-s.top}};rr(n,a,"zoom","wheel"),L(e,[{chart:n}])}function u_(n,t,e,i){e&&(nt(n).handlers[t]=Lx(()=>L(e,[{chart:n}]),i))}function d_(n,t){const e=n.canvas,{wheel:i,drag:s,onZoomComplete:o}=t.zoom;i.enabled?(Un(n,e,"wheel",h_),u_(n,"onZoomComplete",o,250)):Tt(n,"wheel"),s.enabled?(Un(n,e,"mousedown",o_),Un(n,e.ownerDocument,"mouseup",l_)):(Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"keydown"))}function f_(n){Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"wheel"),Tt(n,"click"),Tt(n,"keydown")}function g_(n,t){return function(e,i){const{pan:s,zoom:o={}}=t.options;if(!s||!s.enabled)return!1;const r=i&&i.srcEvent;return r&&!t.panning&&i.pointerType==="mouse"&&(or(Jn(s),r)||_h(Jn(o.drag),r))?(L(s.onPanRejected,[{chart:n,event:i}]),!1):!0}}function m_(n,t){const e=Math.abs(n.clientX-t.clientX),i=Math.abs(n.clientY-t.clientY),s=e/i;let o,r;return s>.3&&s<1.7?o=r=!0:e>i?o=!0:r=!0,{x:o,y:r}}function Eh(n,t,e){if(t.scale){const{center:i,pointers:s}=e,o=1/t.scale*e.scale,r=e.target.getBoundingClientRect(),a=m_(s[0],s[1]),l=t.options.zoom.mode,c={x:a.x&&Pe(l,"x",n)?o:1,y:a.y&&Pe(l,"y",n)?o:1,focalPoint:{x:i.x-r.left,y:i.y-r.top}};rr(n,c,"zoom","pinch"),t.scale=e.scale}}function p_(n,t,e){if(t.options.zoom.pinch.enabled){const i=qt(e,n);L(t.options.zoom.onZoomStart,[{chart:n,event:e,point:i}])===!1?(t.scale=null,L(t.options.zoom.onZoomRejected,[{chart:n,event:e}])):t.scale=1}}function b_(n,t,e){t.scale&&(Eh(n,t,e),t.scale=null,L(t.options.zoom.onZoomComplete,[{chart:n}]))}function Ah(n,t,e){const i=t.delta;i&&(t.panning=!0,Sh(n,{x:e.deltaX-i.x,y:e.deltaY-i.y},t.panScales),t.delta={x:e.deltaX,y:e.deltaY})}function y_(n,t,e){const{enabled:i,onPanStart:s,onPanRejected:o}=t.options.pan;if(!i)return;const r=e.target.getBoundingClientRect(),a={x:e.center.x-r.left,y:e.center.y-r.top};if(L(s,[{chart:n,event:e,point:a}])===!1)return L(o,[{chart:n,event:e}]);t.panScales=wh(t.options.pan,a,n),t.delta={x:0,y:0},Ah(n,t,e)}function x_(n,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,L(t.options.pan.onPanComplete,[{chart:n}]))}const So=new WeakMap;function Al(n,t){const e=nt(n),i=n.canvas,{pan:s,zoom:o}=t,r=new Xn.Manager(i);o&&o.pinch.enabled&&(r.add(new Xn.Pinch),r.on("pinchstart",a=>p_(n,e,a)),r.on("pinch",a=>Eh(n,e,a)),r.on("pinchend",a=>b_(n,e,a))),s&&s.enabled&&(r.add(new Xn.Pan({threshold:s.threshold,enable:g_(n,e)})),r.on("panstart",a=>y_(n,e,a)),r.on("panmove",a=>Ah(n,e,a)),r.on("panend",()=>x_(n,e))),So.set(n,r)}function Il(n){const t=So.get(n);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),So.delete(n))}function __(n,t){var r,a,l,c;const{pan:e,zoom:i}=n,{pan:s,zoom:o}=t;return((a=(r=i==null?void 0:i.zoom)==null?void 0:r.pinch)==null?void 0:a.enabled)!==((c=(l=o==null?void 0:o.zoom)==null?void 0:l.pinch)==null?void 0:c.enabled)||(e==null?void 0:e.enabled)!==(s==null?void 0:s.enabled)||(e==null?void 0:e.threshold)!==(s==null?void 0:s.threshold)}var w_="2.2.0";function Fi(n,t,e){const i=e.zoom.drag,{dragStart:s,dragEnd:o}=nt(n);if(i.drawTime!==t||!o)return;const{left:r,top:a,width:l,height:c}=Ch(n,e.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),h=n.ctx;h.save(),h.beginPath(),h.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",h.fillRect(r,a,l,c),i.borderWidth>0&&(h.lineWidth=i.borderWidth,h.strokeStyle=i.borderColor||"rgba(225,225,225)",h.strokeRect(r,a,l,c)),h.restore()}var v_={id:"zoom",version:w_,defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(n,t,e){const i=nt(n);i.options=e,Object.prototype.hasOwnProperty.call(e.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(e.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(e.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),Xn&&Al(n,e),n.pan=(s,o,r)=>Sh(n,s,o,r),n.zoom=(s,o)=>rr(n,s,o),n.zoomRect=(s,o,r)=>Th(n,s,o,r),n.zoomScale=(s,o,r)=>Zx(n,s,o,r),n.resetZoom=s=>Kx(n,s),n.getZoomLevel=()=>t_(n),n.getInitialScaleBounds=()=>Dh(n),n.getZoomedScaleBounds=()=>e_(n),n.isZoomedOrPanned=()=>n_(n),n.isZoomingOrPanning=()=>Ol(n)},beforeEvent(n,{event:t}){if(Ol(n))return!1;if(t.type==="click"||t.type==="mouseup"){const e=nt(n);if(e.filterNextClick)return e.filterNextClick=!1,!1}},beforeUpdate:function(n,t,e){const i=nt(n),s=i.options;i.options=e,__(s,e)&&(Il(n),Al(n,e)),d_(n,e)},beforeDatasetsDraw(n,t,e){Fi(n,"beforeDatasetsDraw",e)},afterDatasetsDraw(n,t,e){Fi(n,"afterDatasetsDraw",e)},beforeDraw(n,t,e){Fi(n,"beforeDraw",e)},afterDraw(n,t,e){Fi(n,"afterDraw",e)},stop:function(n){f_(n),Xn&&Il(n),Fx(n)},panFunctions:Po,zoomFunctions:Mo,zoomRectFunctions:ko};Mt.register(i0,v_,Dx);Mt.defaults.maintainAspectRatio=!1;Mt.defaults.datasets.line.spanGaps=!0;var mt,nn;class Ih extends HTMLElement{constructor(){super(...arguments);wn(this,mt,null);wn(this,nn,!1)}connectedCallback(){this.style.display="block",this.style.width="100%",this.style.height="100%";const e=document.createElement("canvas");this.appendChild(e);const i=this.getAttributeNames().filter(s=>s.startsWith("plugins")||s.startsWith("interaction")||s.startsWith("scales")||s==="labels"||s==="responsive").reduce((s,o)=>{const r=o.split("."),a=r.pop(),l=this.getAttribute(o),c=r.reduce((h,u)=>(u in h||(h[u]={}),h[u]),s);return c[a]=Ll.trySafeEval(l),s},{});ue(this,mt,new Mt(e,{type:this.getAttribute("type"),data:{datasets:[],labels:this.labels},options:i}))}get labels(){const e=this.getAttribute("labels");return e?JSON.parse(e):[]}set data(e){gt(this,mt).data=e,this.update()}set options(e){gt(this,mt).options=e}addOrReplaceDataset(e,i){const s=gt(this,mt).data.datasets.findIndex(e);s===-1?gt(this,mt).data.datasets=[...gt(this,mt).data.datasets,i]:gt(this,mt).data.datasets.splice(s,1,i),this.update()}removeDataset(e){gt(this,mt).data.datasets=gt(this,mt).data.datasets.filter(i=>!e(i)),this.update()}addOrReplaceAnnotation(e,i){gt(this,mt).options.plugins||(gt(this,mt).options.plugins={}),gt(this,mt).options.plugins.annotation||(gt(this,mt).options.plugins.annotation={annotations:{}});const s=gt(this,mt).options.plugins.annotation.annotations,o=Object.values(s).findIndex(e);if(o===-1){const r=Object.keys(s).length;s[r]=i}else{const r=Object.keys(s)[o];s[r]=i}}removeAnnotation(e){}update(){gt(this,nn)||(ue(this,nn,!0),setTimeout(()=>{gt(this,mt).update("none"),ue(this,nn,!1)},100))}}mt=new WeakMap,nn=new WeakMap;customElements.define("chartjs-chart",Ih);var ze,ti;class Lh extends HTMLElement{constructor(){super(...arguments);wn(this,ze);wn(this,ti,null)}connectedCallback(){if(this.getAttribute("included")==="false")return;ue(this,ze,this.closest("chartjs-chart")),this.syncDataset(),new MutationObserver(()=>this.syncDataset()).observe(this,{attributes:!0}),this.getAttribute("data-from")&&new MutationObserver(o=>{this.syncDataset()}).observe(this.closest("chartjs-chart"),{childList:!0,attributes:!0,subtree:!0})}disconnectedCallback(){var e;(e=gt(this,ze))==null||e.removeDataset(i=>i.owner===this),ue(this,ze,null)}syncDataset(){var s;const e=this.getAttributeNames().filter(o=>!o.startsWith("data")&&!o.startsWith(":")).map(o=>[M_(Rh(o)),this.getAttribute(o)]).reduce((o,[r,a])=>(o[r]=Ll.trySafeEval(a),o),{}),i=this.data;(s=gt(this,ze))==null||s.addOrReplaceDataset(o=>o.owner===this,{...e,data:i,owner:this})}get data(){const e=this.getAttribute("data");if(e)return ue(this,ti,JSON.parse(e));const i=this.getAttribute("data-from");if(i){const s=this.closest("chartjs-chart").querySelector(`chartjs-dataset${i}`);if(s)return ue(this,ti,s.data)}}}ze=new WeakMap,ti=new WeakMap;customElements.define("chartjs-dataset",Lh);function M_(n){return n==="xAxisId"?"xAxisID":n==="yAxisId"?"yAxisID":n}function Rh(n){return n.replace(/([-_][a-z])/g,t=>t.toUpperCase().replace("-","").replace("_",""))}exports.ChartDataset=Lh;exports.ChartElement=Ih;exports.snakeToCamel=Rh;
@@ -15891,16 +15891,20 @@ class __ extends HTMLElement {
15891
15891
  this.style.display = "block", this.style.width = "100%", this.style.height = "100%";
15892
15892
  const e = document.createElement("canvas");
15893
15893
  this.appendChild(e);
15894
- const i = this.getAttributeNames().filter((s) => s.startsWith("plugins") || s.startsWith("interaction") || s.startsWith("scales") || s === "responsive").reduce((s, o) => {
15894
+ const i = this.getAttributeNames().filter((s) => s.startsWith("plugins") || s.startsWith("interaction") || s.startsWith("scales") || s === "labels" || s === "responsive").reduce((s, o) => {
15895
15895
  const r = o.split("."), a = r.pop(), l = this.getAttribute(o), c = r.reduce((h, u) => (u in h || (h[u] = {}), h[u]), s);
15896
15896
  return c[a] = Ll(l), s;
15897
15897
  }, {});
15898
15898
  ue(this, mt, new Mt(e, {
15899
15899
  type: this.getAttribute("type"),
15900
- data: { datasets: [] },
15900
+ data: { datasets: [], labels: this.labels },
15901
15901
  options: i
15902
15902
  }));
15903
15903
  }
15904
+ get labels() {
15905
+ const e = this.getAttribute("labels");
15906
+ return e ? JSON.parse(e) : [];
15907
+ }
15904
15908
  set data(e) {
15905
15909
  gt(this, mt).data = e, this.update();
15906
15910
  }
@@ -1,6 +1,7 @@
1
1
  export declare class ChartElement extends HTMLElement {
2
2
  #private;
3
3
  connectedCallback(): void;
4
+ get labels(): any;
4
5
  set data(data: any);
5
6
  set options(options: any);
6
7
  addOrReplaceDataset(predicate: any, dataset: any): void;
@@ -1 +1 @@
1
- {"version":3,"file":"chartjs-chart.d.ts","sourceRoot":"","sources":["../../src/components/chartjs-chart.ts"],"names":[],"mappings":"AAIA,OAAO,0BAA0B,CAAA;AAYjC,qBAAa,YAAa,SAAQ,WAAW;;IAG3C,iBAAiB;IAiCjB,IAAI,IAAI,CAAC,IAAI,KAAA,EAGZ;IAED,IAAI,OAAO,CAAC,OAAO,KAAA,EAElB;IAED,mBAAmB,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA;IAUtC,aAAa,CAAC,SAAS,KAAA;IAKvB,sBAAsB,CAAC,SAAS,KAAA,EAAE,UAAU,KAAA;IAkB5C,gBAAgB,CAAC,SAAS,KAAA;IAM1B;;;;;OAKG;IACH,MAAM;CAQP;AAGD,qBAAa,YAAa,SAAQ,WAAW;;IAI3C,iBAAiB;IAqBjB,oBAAoB;IAKpB,WAAW;IAcX,IAAI,IAAI,QAWP;CACF;AASD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,UAOvC"}
1
+ {"version":3,"file":"chartjs-chart.d.ts","sourceRoot":"","sources":["../../src/components/chartjs-chart.ts"],"names":[],"mappings":"AAIA,OAAO,0BAA0B,CAAA;AAYjC,qBAAa,YAAa,SAAQ,WAAW;;IAG3C,iBAAiB;IAkCjB,IAAI,MAAM,QAGT;IAED,IAAI,IAAI,CAAC,IAAI,KAAA,EAGZ;IAED,IAAI,OAAO,CAAC,OAAO,KAAA,EAElB;IAED,mBAAmB,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA;IAUtC,aAAa,CAAC,SAAS,KAAA;IAKvB,sBAAsB,CAAC,SAAS,KAAA,EAAE,UAAU,KAAA;IAkB5C,gBAAgB,CAAC,SAAS,KAAA;IAM1B;;;;;OAKG;IACH,MAAM;CAQP;AAGD,qBAAa,YAAa,SAAQ,WAAW;;IAI3C,iBAAiB;IAqBjB,oBAAoB;IAKpB,WAAW;IAcX,IAAI,IAAI,QAWP;CACF;AASD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,UAOvC"}
@@ -0,0 +1,4 @@
1
+ export declare class GoogleMapStatic extends HTMLElement {
2
+ connectedCallback(): void;
3
+ }
4
+ //# sourceMappingURL=google-map-static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-map-static.d.ts","sourceRoot":"","sources":["../../src/components/google-map-static.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,iBAAiB;CAWlB"}
@@ -0,0 +1,37 @@
1
+ type GoogleMapsLibrary = "maps" | "marker" | "places" | "geometry" | "drawing";
2
+ export declare function load<T extends GoogleMapsLibrary[]>(libraries?: T): Promise<Record<string, any>>;
3
+ export declare class GoogleMap extends HTMLElement {
4
+ #private;
5
+ private markers;
6
+ private bounds;
7
+ map: google.maps.Map;
8
+ constructor();
9
+ connectedCallback(): void;
10
+ setMarker(position: {
11
+ lat: number;
12
+ lng: number;
13
+ }, draggable?: boolean, pinOptions?: any): Promise<any>;
14
+ panTo(position: {
15
+ lat: number;
16
+ lng: number;
17
+ }, options?: {
18
+ keepZoom?: boolean;
19
+ }): void;
20
+ }
21
+ export declare class GoogleMapMarker extends HTMLElement {
22
+ #private;
23
+ static observedAttributes: string[];
24
+ private marker;
25
+ private infoWindow;
26
+ connectedCallback(): Promise<void>;
27
+ attributeChangedCallback(): void;
28
+ private updateMarker;
29
+ private getOrCreateMarker;
30
+ get position(): {
31
+ lat: number;
32
+ lng: number;
33
+ };
34
+ openInfoWindow(): void;
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=google-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-map.d.ts","sourceRoot":"","sources":["../../src/components/google-map.ts"],"names":[],"mappings":"AAEA,KAAK,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAI/E,wBAAsB,IAAI,CAAC,CAAC,SAAS,iBAAiB,EAAE,EACtD,SAAS,GAAE,CAAsB,gCAelC;AAED,qBAAa,SAAU,SAAQ,WAAW;;IACxC,OAAO,CAAC,OAAO,CAA6C;IAC5D,OAAO,CAAC,MAAM,CAAM;IACb,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAQ;;IAUnC,iBAAiB;IAsCX,SAAS,CAAC,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,SAAS,GAAE,OAAe,EAAE,UAAU,GAAE,GAAQ;IA2BxG,KAAK,CAAC,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO;CAKnF;AAGD,qBAAa,eAAgB,SAAQ,WAAW;;IAC9C,MAAM,CAAC,kBAAkB,WAAiC;IAE1D,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,UAAU,CAAa;IAIzB,iBAAiB;IAQvB,wBAAwB;YASV,YAAY;YAQZ,iBAAiB;IA6D/B,IAAI,QAAQ,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAK3C;IAED,cAAc;CAKf"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(){return Object.assign({"./chartjs-chart.ts":()=>Promise.resolve().then(()=>require("./chartjs-chart.cjs")),"./sleek-select.ts":()=>Promise.resolve().then(()=>require("./sleek-select.cjs"))})}exports.importCustomElements=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(){return Object.assign({"./chartjs-chart.ts":()=>Promise.resolve().then(()=>require("./chartjs-chart.cjs")),"./google-map-static.ts":()=>Promise.resolve().then(()=>require("./google-map-static.cjs")),"./google-map.ts":()=>Promise.resolve().then(()=>require("./google-map.cjs")),"./sleek-select.ts":()=>Promise.resolve().then(()=>require("./sleek-select.cjs"))})}exports.importCustomElements=e;
@@ -1,5 +1,5 @@
1
1
  function t() {
2
- return /* @__PURE__ */ Object.assign({ "./chartjs-chart.ts": () => import("./chartjs-chart.js"), "./sleek-select.ts": () => import("./sleek-select.js") });
2
+ return /* @__PURE__ */ Object.assign({ "./chartjs-chart.ts": () => import("./chartjs-chart.js"), "./google-map-static.ts": () => import("./google-map-static.js"), "./google-map.ts": () => import("./google-map.js"), "./sleek-select.ts": () => import("./sleek-select.js") });
3
3
  }
4
4
  export {
5
5
  t as importCustomElements
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o extends HTMLElement{connectedCallback(){const t=this.getAttribute("lat"),e=this.getAttribute("lng"),s=this.getAttribute("zoom")||"14",a=this.getAttribute("size")||"600x300",i=this.getAttribute("type")||"roadmap",l=window.SLEEK.maps.googleMapsApiKey,c=`https://maps.googleapis.com/maps/api/staticmap?center=${t},${e}&zoom=${s}&size=${a}&maptype=${i}&markers=color:red%7Clabel:S%7C${t},${e}&key=${l}`;this.style.display="block",this.innerHTML=`<img src="${c}" alt="Standortkarte" style="width: 100%; height: auto;">`}}customElements.define("google-map-static",o);exports.GoogleMapStatic=o;
@@ -0,0 +1,10 @@
1
+ class l extends HTMLElement {
2
+ connectedCallback() {
3
+ const t = this.getAttribute("lat"), e = this.getAttribute("lng"), s = this.getAttribute("zoom") || "14", o = this.getAttribute("size") || "600x300", a = this.getAttribute("type") || "roadmap", i = window.SLEEK.maps.googleMapsApiKey, c = `https://maps.googleapis.com/maps/api/staticmap?center=${t},${e}&zoom=${s}&size=${o}&maptype=${a}&markers=color:red%7Clabel:S%7C${t},${e}&key=${i}`;
4
+ this.style.display = "block", this.innerHTML = `<img src="${c}" alt="Standortkarte" style="width: 100%; height: auto;">`;
5
+ }
6
+ }
7
+ customElements.define("google-map-static", l);
8
+ export {
9
+ l as GoogleMapStatic
10
+ };
@@ -0,0 +1 @@
1
+ "use strict";var R=r=>{throw TypeError(r)};var T=(r,e,t)=>e.has(r)||R("Cannot "+t);var I=(r,e,t)=>(T(r,e,"read from private field"),t?t.call(r):e.get(r)),M=(r,e,t)=>e.has(r)?R("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),g=(r,e,t,i)=>(T(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function N(r,e,t,i){function s(n){return n instanceof t?n:new t(function(o){o(n)})}return new(t||(t=Promise))(function(n,o){function a(h){try{c(i.next(h))}catch(p){o(p)}}function l(h){try{c(i.throw(h))}catch(p){o(p)}}function c(h){h.done?n(h.value):s(h.value).then(a,l)}c((i=i.apply(r,[])).next())})}function U(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var O,K;function G(){return K||(K=1,O=function r(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var i,s,n;if(Array.isArray(e)){if(i=e.length,i!=t.length)return!1;for(s=i;s--!==0;)if(!r(e[s],t[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(n=Object.keys(e),i=n.length,i!==Object.keys(t).length)return!1;for(s=i;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,n[s]))return!1;for(s=i;s--!==0;){var o=n[s];if(!r(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}),O}var x=G(),W=U(x);const _="__googleMapsScriptId";var f;(function(r){r[r.INITIALIZED=0]="INITIALIZED",r[r.LOADING=1]="LOADING",r[r.SUCCESS=2]="SUCCESS",r[r.FAILURE=3]="FAILURE"})(f||(f={}));class d{constructor({apiKey:e,authReferrerPolicy:t,channel:i,client:s,id:n=_,language:o,libraries:a=[],mapIds:l,nonce:c,region:h,retries:p=3,url:b="https://maps.googleapis.com/maps/api/js",version:w}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=i,this.client=s,this.id=n||_,this.language=o,this.libraries=a,this.mapIds=l,this.nonce=c,this.region=h,this.retries=p,this.url=b,this.version=w,d.instance){if(!W(this.options,d.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(d.instance.options)}`);return d.instance}d.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?f.FAILURE:this.done?f.SUCCESS:this.loading?f.LOADING:f.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback&loading=async",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`&region=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(i=>{i?t(i.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id)){this.callback();return}const i={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(i).forEach(n=>!i[n]&&delete i[n]),!((t=(e=window==null?void 0:window.google)===null||e===void 0?void 0:e.maps)===null||t===void 0)&&t.importLibrary||(n=>{let o,a,l,c="The Google Maps JavaScript API",h="google",p="importLibrary",b="__ib__",w=document,y=window;y=y[h]||(y[h]={});const E=y.maps||(y.maps={}),j=new Set,k=new URLSearchParams,F=()=>o||(o=new Promise((v,A)=>N(this,void 0,void 0,function*(){var C;yield a=w.createElement("script"),a.id=this.id,k.set("libraries",[...j]+"");for(l in n)k.set(l.replace(/[A-Z]/g,$=>"_"+$[0].toLowerCase()),n[l]);k.set("callback",h+".maps."+b),a.src=this.url+"?"+k,E[b]=v,a.onerror=()=>o=A(Error(c+" could not load.")),a.nonce=this.nonce||((C=w.querySelector("script[nonce]"))===null||C===void 0?void 0:C.nonce)||"",w.head.append(a)})));E[p]?console.warn(c+" only loads once. Ignoring:",n):E[p]=(v,...A)=>j.add(v)&&F().then(()=>E[p](v,...A))})(i);const s=this.libraries.map(n=>this.importLibrary(n));s.length||s.push(this.importLibrary("core")),Promise.all(s).then(()=>this.callback(),n=>{const o=new ErrorEvent("error",{error:n});this.loadErrorCallback(o)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),!this.loading)if(this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader. This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading=!0,this.setScript()}}}let q=null;async function S(r=[]){if(!window.SLEEK||!window.SLEEK.maps||!window.SLEEK.maps.googleMapsApiKey)throw new Error("Google Maps API key is not configured. Please set window.SLEEK.maps.googleMapsApiKey.");return q??(q=new d({apiKey:window.SLEEK.maps.googleMapsApiKey})),(await Promise.all(r.map(t=>q.importLibrary(t)))).reduce((t,i)=>({...t,...i}),{})}var m;class D extends HTMLElement{constructor(){super();M(this,m);this.map=null,g(this,m,void 0),this.markers=[],this.bounds=null}connectedCallback(){const t=this.attachShadow({mode:"open"});this.querySelectorAll("style").forEach(a=>{t.appendChild(a)});const i=t.appendChild(document.createElement("main"));i.style.display="block",i.style.width="100%",i.style.height="100%";const s=parseFloat(this.getAttribute("init-lat"))||47.816,n=parseFloat(this.getAttribute("init-lng"))||16.25,o=parseInt(this.getAttribute("zoom"))||14;this.style.display="block",g(this,m,S(["maps"]).then(({Map:a})=>{this.map=new a(i,{center:{lat:s,lng:n},zoom:o,mapId:"location-map",streetViewControl:!1}),this.map.addListener("rightclick",l=>{this.dispatchEvent(new CustomEvent("right-click",{detail:{lat:l.latLng.lat(),lng:l.latLng.lng()}}))}),this.bounds=new google.maps.LatLngBounds}).catch(console.error))}async setMarker(t,i=!1,s={}){await I(this,m);const{AdvancedMarkerElement:n,PinElement:o}=await S(["marker"]),a=new o({...s}),l=new n({position:t,map:this.map,gmpDraggable:i,content:a.element});return l.pin=a,this.markers.push(l),this.bounds??(this.bounds=new google.maps.LatLngBounds),this.bounds.extend(t),this.markers.length>1&&this.map.fitBounds(this.bounds),this.markers.length===1&&this.map.setCenter(t),l}panTo(t,i={}){this.map&&(this.map.panTo(t),i.keepZoom||this.map.setZoom(20))}}m=new WeakMap;customElements.define("google-map",D);var u;const P=class P extends HTMLElement{constructor(){super(...arguments);M(this,u);this.marker=null,this.infoWindow=null,g(this,u,null)}async connectedCallback(){let t=this.closest("google-map");for(;!t;)await new Promise(i=>setTimeout(i,100)),t=this.closest("google-map")}attributeChangedCallback(){if(!this.parentElement)return;const t=this.position;isNaN(t.lat)||isNaN(t.lng)||this.updateMarker(t).catch(console.error)}async updateMarker(t){this.marker=await this.getOrCreateMarker(t);try{this.marker&&this.hasAttribute("pin-options")&&Object.assign(this.marker.pin,JSON.parse(this.getAttribute("pin-options")))}catch(i){console.error("invalid pin-options",i)}}async getOrCreateMarker(t){if(I(this,u)&&await I(this,u),!this.marker){const i=this.closest("google-map");if(!i)return;await g(this,u,i.setMarker(t,this.getAttribute("draggable")==="true").then(async s=>{const{InfoWindow:n}=await S(["maps"]),o=this.querySelector('slot[name="info-window"]');o&&(o.style.display="none");const a=this.querySelector('slot[name="info-window-title"]');a&&(a.style.display="none");const l=o==null?void 0:o.innerHTML,c=(a==null?void 0:a.innerHTML)||void 0;let h;return c&&(h=document.createElement("div"),h.innerHTML=c),l&&(this.infoWindow=new n({content:l,headerContent:h}),s.addListener("click",()=>{this.openInfoWindow()})),s.addListener("dragend",()=>{this.dispatchEvent(new CustomEvent("change",{detail:this.marker.position})),queueMicrotask(()=>this.marker.position=this.position)}),s}).then(s=>(this.marker=s,s)).finally(()=>g(this,u,null)))}return this.marker.position=t,this.marker}get position(){return{lat:parseFloat(this.getAttribute("lat")),lng:parseFloat(this.getAttribute("lng"))}}openInfoWindow(){this.infoWindow&&this.marker&&this.infoWindow.open(this.marker.map,this.marker)}};u=new WeakMap,P.observedAttributes=["lat","lng","pin-options"];let L=P;customElements.define("google-map-marker",L);exports.GoogleMap=D;exports.GoogleMapMarker=L;exports.load=S;
@@ -0,0 +1,356 @@
1
+ var j = (r) => {
2
+ throw TypeError(r);
3
+ };
4
+ var K = (r, t, e) => t.has(r) || j("Cannot " + e);
5
+ var I = (r, t, e) => (K(r, t, "read from private field"), e ? e.call(r) : t.get(r)), A = (r, t, e) => t.has(r) ? j("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), g = (r, t, e, i) => (K(r, t, "write to private field"), i ? i.call(r, e) : t.set(r, e), e);
6
+ function $(r, t, e, i) {
7
+ function s(n) {
8
+ return n instanceof e ? n : new e(function(o) {
9
+ o(n);
10
+ });
11
+ }
12
+ return new (e || (e = Promise))(function(n, o) {
13
+ function a(h) {
14
+ try {
15
+ c(i.next(h));
16
+ } catch (p) {
17
+ o(p);
18
+ }
19
+ }
20
+ function l(h) {
21
+ try {
22
+ c(i.throw(h));
23
+ } catch (p) {
24
+ o(p);
25
+ }
26
+ }
27
+ function c(h) {
28
+ h.done ? n(h.value) : s(h.value).then(a, l);
29
+ }
30
+ c((i = i.apply(r, [])).next());
31
+ });
32
+ }
33
+ function N(r) {
34
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
35
+ }
36
+ var C, T;
37
+ function U() {
38
+ return T || (T = 1, C = function r(t, e) {
39
+ if (t === e) return !0;
40
+ if (t && e && typeof t == "object" && typeof e == "object") {
41
+ if (t.constructor !== e.constructor) return !1;
42
+ var i, s, n;
43
+ if (Array.isArray(t)) {
44
+ if (i = t.length, i != e.length) return !1;
45
+ for (s = i; s-- !== 0; )
46
+ if (!r(t[s], e[s])) return !1;
47
+ return !0;
48
+ }
49
+ if (t.constructor === RegExp) return t.source === e.source && t.flags === e.flags;
50
+ if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === e.valueOf();
51
+ if (t.toString !== Object.prototype.toString) return t.toString() === e.toString();
52
+ if (n = Object.keys(t), i = n.length, i !== Object.keys(e).length) return !1;
53
+ for (s = i; s-- !== 0; )
54
+ if (!Object.prototype.hasOwnProperty.call(e, n[s])) return !1;
55
+ for (s = i; s-- !== 0; ) {
56
+ var o = n[s];
57
+ if (!r(t[o], e[o])) return !1;
58
+ }
59
+ return !0;
60
+ }
61
+ return t !== t && e !== e;
62
+ }), C;
63
+ }
64
+ var x = U(), G = /* @__PURE__ */ N(x);
65
+ const _ = "__googleMapsScriptId";
66
+ var f;
67
+ (function(r) {
68
+ r[r.INITIALIZED = 0] = "INITIALIZED", r[r.LOADING = 1] = "LOADING", r[r.SUCCESS = 2] = "SUCCESS", r[r.FAILURE = 3] = "FAILURE";
69
+ })(f || (f = {}));
70
+ class d {
71
+ /**
72
+ * Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
73
+ * using this library, instead the defaults are set by the Google Maps
74
+ * JavaScript API server.
75
+ *
76
+ * ```
77
+ * const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
78
+ * ```
79
+ */
80
+ constructor({ apiKey: t, authReferrerPolicy: e, channel: i, client: s, id: n = _, language: o, libraries: a = [], mapIds: l, nonce: c, region: h, retries: p = 3, url: E = "https://maps.googleapis.com/maps/api/js", version: w }) {
81
+ if (this.callbacks = [], this.done = !1, this.loading = !1, this.errors = [], this.apiKey = t, this.authReferrerPolicy = e, this.channel = i, this.client = s, this.id = n || _, this.language = o, this.libraries = a, this.mapIds = l, this.nonce = c, this.region = h, this.retries = p, this.url = E, this.version = w, d.instance) {
82
+ if (!G(this.options, d.instance.options))
83
+ throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(d.instance.options)}`);
84
+ return d.instance;
85
+ }
86
+ d.instance = this;
87
+ }
88
+ get options() {
89
+ return {
90
+ version: this.version,
91
+ apiKey: this.apiKey,
92
+ channel: this.channel,
93
+ client: this.client,
94
+ id: this.id,
95
+ libraries: this.libraries,
96
+ language: this.language,
97
+ region: this.region,
98
+ mapIds: this.mapIds,
99
+ nonce: this.nonce,
100
+ url: this.url,
101
+ authReferrerPolicy: this.authReferrerPolicy
102
+ };
103
+ }
104
+ get status() {
105
+ return this.errors.length ? f.FAILURE : this.done ? f.SUCCESS : this.loading ? f.LOADING : f.INITIALIZED;
106
+ }
107
+ get failed() {
108
+ return this.done && !this.loading && this.errors.length >= this.retries + 1;
109
+ }
110
+ /**
111
+ * CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
112
+ *
113
+ * @ignore
114
+ * @deprecated
115
+ */
116
+ createUrl() {
117
+ let t = this.url;
118
+ return t += "?callback=__googleMapsCallback&loading=async", this.apiKey && (t += `&key=${this.apiKey}`), this.channel && (t += `&channel=${this.channel}`), this.client && (t += `&client=${this.client}`), this.libraries.length > 0 && (t += `&libraries=${this.libraries.join(",")}`), this.language && (t += `&language=${this.language}`), this.region && (t += `&region=${this.region}`), this.version && (t += `&v=${this.version}`), this.mapIds && (t += `&map_ids=${this.mapIds.join(",")}`), this.authReferrerPolicy && (t += `&auth_referrer_policy=${this.authReferrerPolicy}`), t;
119
+ }
120
+ deleteScript() {
121
+ const t = document.getElementById(this.id);
122
+ t && t.remove();
123
+ }
124
+ /**
125
+ * Load the Google Maps JavaScript API script and return a Promise.
126
+ * @deprecated, use importLibrary() instead.
127
+ */
128
+ load() {
129
+ return this.loadPromise();
130
+ }
131
+ /**
132
+ * Load the Google Maps JavaScript API script and return a Promise.
133
+ *
134
+ * @ignore
135
+ * @deprecated, use importLibrary() instead.
136
+ */
137
+ loadPromise() {
138
+ return new Promise((t, e) => {
139
+ this.loadCallback((i) => {
140
+ i ? e(i.error) : t(window.google);
141
+ });
142
+ });
143
+ }
144
+ importLibrary(t) {
145
+ return this.execute(), google.maps.importLibrary(t);
146
+ }
147
+ /**
148
+ * Load the Google Maps JavaScript API script with a callback.
149
+ * @deprecated, use importLibrary() instead.
150
+ */
151
+ loadCallback(t) {
152
+ this.callbacks.push(t), this.execute();
153
+ }
154
+ /**
155
+ * Set the script on document.
156
+ */
157
+ setScript() {
158
+ var t, e;
159
+ if (document.getElementById(this.id)) {
160
+ this.callback();
161
+ return;
162
+ }
163
+ const i = {
164
+ key: this.apiKey,
165
+ channel: this.channel,
166
+ client: this.client,
167
+ libraries: this.libraries.length && this.libraries,
168
+ v: this.version,
169
+ mapIds: this.mapIds,
170
+ language: this.language,
171
+ region: this.region,
172
+ authReferrerPolicy: this.authReferrerPolicy
173
+ };
174
+ Object.keys(i).forEach(
175
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
+ (n) => !i[n] && delete i[n]
177
+ ), !((e = (t = window == null ? void 0 : window.google) === null || t === void 0 ? void 0 : t.maps) === null || e === void 0) && e.importLibrary || ((n) => {
178
+ let o, a, l, c = "The Google Maps JavaScript API", h = "google", p = "importLibrary", E = "__ib__", w = document, y = window;
179
+ y = y[h] || (y[h] = {});
180
+ const b = y.maps || (y.maps = {}), R = /* @__PURE__ */ new Set(), k = new URLSearchParams(), D = () => (
181
+ // @ts-ignore
182
+ o || (o = new Promise((v, S) => $(this, void 0, void 0, function* () {
183
+ var L;
184
+ yield a = w.createElement("script"), a.id = this.id, k.set("libraries", [...R] + "");
185
+ for (l in n)
186
+ k.set(l.replace(/[A-Z]/g, (F) => "_" + F[0].toLowerCase()), n[l]);
187
+ k.set("callback", h + ".maps." + E), a.src = this.url + "?" + k, b[E] = v, a.onerror = () => o = S(Error(c + " could not load.")), a.nonce = this.nonce || ((L = w.querySelector("script[nonce]")) === null || L === void 0 ? void 0 : L.nonce) || "", w.head.append(a);
188
+ })))
189
+ );
190
+ b[p] ? console.warn(c + " only loads once. Ignoring:", n) : b[p] = (v, ...S) => R.add(v) && D().then(() => b[p](v, ...S));
191
+ })(i);
192
+ const s = this.libraries.map((n) => this.importLibrary(n));
193
+ s.length || s.push(this.importLibrary("core")), Promise.all(s).then(() => this.callback(), (n) => {
194
+ const o = new ErrorEvent("error", { error: n });
195
+ this.loadErrorCallback(o);
196
+ });
197
+ }
198
+ /**
199
+ * Reset the loader state.
200
+ */
201
+ reset() {
202
+ this.deleteScript(), this.done = !1, this.loading = !1, this.errors = [], this.onerrorEvent = null;
203
+ }
204
+ resetIfRetryingFailed() {
205
+ this.failed && this.reset();
206
+ }
207
+ loadErrorCallback(t) {
208
+ if (this.errors.push(t), this.errors.length <= this.retries) {
209
+ const e = this.errors.length * Math.pow(2, this.errors.length);
210
+ console.error(`Failed to load Google Maps script, retrying in ${e} ms.`), setTimeout(() => {
211
+ this.deleteScript(), this.setScript();
212
+ }, e);
213
+ } else
214
+ this.onerrorEvent = t, this.callback();
215
+ }
216
+ callback() {
217
+ this.done = !0, this.loading = !1, this.callbacks.forEach((t) => {
218
+ t(this.onerrorEvent);
219
+ }), this.callbacks = [];
220
+ }
221
+ execute() {
222
+ if (this.resetIfRetryingFailed(), !this.loading)
223
+ if (this.done)
224
+ this.callback();
225
+ else {
226
+ if (window.google && window.google.maps && window.google.maps.version) {
227
+ console.warn("Google Maps already loaded outside @googlemaps/js-api-loader. This may result in undesirable behavior as options and script parameters may not match."), this.callback();
228
+ return;
229
+ }
230
+ this.loading = !0, this.setScript();
231
+ }
232
+ }
233
+ }
234
+ let q = null;
235
+ async function M(r = []) {
236
+ if (!window.SLEEK || !window.SLEEK.maps || !window.SLEEK.maps.googleMapsApiKey)
237
+ throw new Error("Google Maps API key is not configured. Please set window.SLEEK.maps.googleMapsApiKey.");
238
+ return q ?? (q = new d({
239
+ apiKey: window.SLEEK.maps.googleMapsApiKey
240
+ })), (await Promise.all(
241
+ r.map((e) => q.importLibrary(e))
242
+ )).reduce((e, i) => ({ ...e, ...i }), {});
243
+ }
244
+ var m;
245
+ class W extends HTMLElement {
246
+ constructor() {
247
+ super();
248
+ A(this, m);
249
+ this.map = null, g(this, m, void 0), this.markers = [], this.bounds = null;
250
+ }
251
+ connectedCallback() {
252
+ const e = this.attachShadow({ mode: "open" });
253
+ this.querySelectorAll("style").forEach((a) => {
254
+ e.appendChild(a);
255
+ });
256
+ const i = e.appendChild(document.createElement("main"));
257
+ i.style.display = "block", i.style.width = "100%", i.style.height = "100%";
258
+ const s = parseFloat(this.getAttribute("init-lat")) || 47.816, n = parseFloat(this.getAttribute("init-lng")) || 16.25, o = parseInt(this.getAttribute("zoom")) || 14;
259
+ this.style.display = "block", g(this, m, M(["maps"]).then(({ Map: a }) => {
260
+ this.map = new a(i, {
261
+ center: { lat: s, lng: n },
262
+ zoom: o,
263
+ mapId: "location-map",
264
+ streetViewControl: !1
265
+ }), this.map.addListener("rightclick", (l) => {
266
+ this.dispatchEvent(
267
+ new CustomEvent(
268
+ "right-click",
269
+ { detail: { lat: l.latLng.lat(), lng: l.latLng.lng() } }
270
+ )
271
+ );
272
+ }), this.bounds = new google.maps.LatLngBounds();
273
+ }).catch(console.error));
274
+ }
275
+ async setMarker(e, i = !1, s = {}) {
276
+ await I(this, m);
277
+ const { AdvancedMarkerElement: n, PinElement: o } = await M(["marker"]), a = new o({ ...s }), l = new n({
278
+ position: e,
279
+ map: this.map,
280
+ gmpDraggable: i,
281
+ content: a.element
282
+ });
283
+ return l.pin = a, this.markers.push(l), this.bounds ?? (this.bounds = new google.maps.LatLngBounds()), this.bounds.extend(e), this.markers.length > 1 && this.map.fitBounds(this.bounds), this.markers.length === 1 && this.map.setCenter(e), l;
284
+ }
285
+ panTo(e, i = {}) {
286
+ this.map && (this.map.panTo(e), i.keepZoom || this.map.setZoom(20));
287
+ }
288
+ }
289
+ m = new WeakMap();
290
+ customElements.define("google-map", W);
291
+ var u;
292
+ const P = class P extends HTMLElement {
293
+ constructor() {
294
+ super(...arguments);
295
+ A(this, u);
296
+ this.marker = null, this.infoWindow = null, g(this, u, null);
297
+ }
298
+ async connectedCallback() {
299
+ let e = this.closest("google-map");
300
+ for (; !e; )
301
+ await new Promise((i) => setTimeout(i, 100)), e = this.closest("google-map");
302
+ }
303
+ attributeChangedCallback() {
304
+ if (!this.parentElement) return;
305
+ const e = this.position;
306
+ isNaN(e.lat) || isNaN(e.lng) || this.updateMarker(e).catch(console.error);
307
+ }
308
+ async updateMarker(e) {
309
+ this.marker = await this.getOrCreateMarker(e);
310
+ try {
311
+ this.marker && this.hasAttribute("pin-options") && Object.assign(this.marker.pin, JSON.parse(this.getAttribute("pin-options")));
312
+ } catch (i) {
313
+ console.error("invalid pin-options", i);
314
+ }
315
+ }
316
+ async getOrCreateMarker(e) {
317
+ if (I(this, u) && await I(this, u), !this.marker) {
318
+ const i = this.closest("google-map");
319
+ if (!i) return;
320
+ await g(this, u, i.setMarker(e, this.getAttribute("draggable") === "true").then(async (s) => {
321
+ const { InfoWindow: n } = await M(["maps"]), o = this.querySelector('slot[name="info-window"]');
322
+ o && (o.style.display = "none");
323
+ const a = this.querySelector('slot[name="info-window-title"]');
324
+ a && (a.style.display = "none");
325
+ const l = o == null ? void 0 : o.innerHTML, c = (a == null ? void 0 : a.innerHTML) || void 0;
326
+ let h;
327
+ return c && (h = document.createElement("div"), h.innerHTML = c), l && (this.infoWindow = new n({
328
+ content: l,
329
+ headerContent: h
330
+ }), s.addListener("click", () => {
331
+ this.openInfoWindow();
332
+ })), s.addListener("dragend", () => {
333
+ this.dispatchEvent(new CustomEvent("change", { detail: this.marker.position })), queueMicrotask(() => this.marker.position = this.position);
334
+ }), s;
335
+ }).then((s) => (this.marker = s, s)).finally(() => g(this, u, null)));
336
+ }
337
+ return this.marker.position = e, this.marker;
338
+ }
339
+ get position() {
340
+ return {
341
+ lat: parseFloat(this.getAttribute("lat")),
342
+ lng: parseFloat(this.getAttribute("lng"))
343
+ };
344
+ }
345
+ openInfoWindow() {
346
+ this.infoWindow && this.marker && this.infoWindow.open(this.marker.map, this.marker);
347
+ }
348
+ };
349
+ u = new WeakMap(), P.observedAttributes = ["lat", "lng", "pin-options"];
350
+ let O = P;
351
+ customElements.define("google-map-marker", O);
352
+ export {
353
+ W as GoogleMap,
354
+ O as GoogleMapMarker,
355
+ M as load
356
+ };
package/dist/main.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export * from './utils.js';
2
+ export declare function setup({ maps }: {
3
+ maps: any;
4
+ }): void;
2
5
  export declare function loadCustomElements(mapping: CustomElementLoaderMapping, { resolveTagName, watch, }?: {
3
6
  resolveTagName?: (key: string) => string;
4
7
  watch?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAE1B,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,0BAA0B,EACnC,EACE,cAA6B,EAC7B,KAAY,GACb,GAAE;IAAE,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACpE,MAAM,CAmER;AAED,KAAK,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AACxE,KAAK,MAAM,GAAG;IACZ,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAA;IACjD,EAAE,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAA;IACnC,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAA;IACvD,GAAG,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAA;CACxC,CAAA"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAE1B,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,GAAG,CAAA;CAAE,QAG5C;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,0BAA0B,EACnC,EACE,cAA6B,EAC7B,KAAY,GACb,GAAE;IAAE,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACpE,MAAM,CAmER;AAED,KAAK,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AACxE,KAAK,MAAM,GAAG;IACZ,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAA;IACjD,EAAE,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAA;IACnC,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAA;IACvD,GAAG,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAA;CACxC,CAAA"}