var C=Object.defineProperty;var S=(n,a,r)=>a in n?C(n,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[a]=r;var p=(n,a,r)=>(S(n,typeof a!="symbol"?a+"":a,r),r);import{C as y,j as x,L as k,P as w,l as D,h as L,p as V,f as N,n as I}from"./index-3f9b0c11.js";import{M as B,N as E,Z as T,r as W,c as j,o as F,a3 as f,l as M,S as P,J as u,O as m,Q as A,aa as g}from"./index-9b57d2d5.js";import{V as J}from"./VToolbar-dc629630.js";import{V as O}from"./index-7f073286.js";import"./VImg-601f5a2c.js";const Q={class:"v-full h-96 w-full justify-center p-4 bg-background"},H=B({__name:"Forecast",setup(n){const{t:a}=E(),r=T(),s=W(),i=["red","pink","purple","deep-purple","blue","light-blue","cyan","teal","green","light-green","lime","organe","deep-orange","brown","blue-grey"];class v{constructor(){p(this,"index",0)}getNextColor(){const l=i[this.index++];return this.index>=i.length&&(this.index=0),l}}function d(e){switch(e){case"pv":return r.current.value.colors.sun;case"pv_forecast":return r.current.value.colors.sun;case"consumption":return r.current.value.colors.grid;case"no_var_loads":return r.current.value.colors.grid;default:return null}}function c(e){switch(e){case"pv":return a("forecast.pv");case"pv_forecast":return a("forecast.pv_forecast");case"consumption":return a("forecast.consumption");case"no_var_loads":return g("forecast.no_var_loads");default:return f.getDeviceInfo(e).name}}function _(e){if(e&&e.series){let l=new v;return e.series.map(t=>{if(t.name=="pv"||t.name=="no_var_loads"){let o=d(t.name);return{label:c(t.name),data:t.data,fill:!1,backgroundColor:o,borderColor:o,borderDash:[5,5],borderWidth:2,pointStyle:!1}}else if(t.name=="pv_forecast"||t.name=="consumption"){let o=d(t.name);return{label:c(t.name),data:t.data,fill:!1,backgroundColor:o,borderColor:o,borderWidth:2,pointStyle:!1}}else{let o=l.getNextColor();return{label:c(t.name),data:t.data,fill:!1,backgroundColor:o,borderColor:o,stepped:!0,borderWidth:2,pointStyle:!1}}})}return[]}const b=j(()=>{var e;return{labels:(e=s.value)==null?void 0:e.time.map(l=>new Date(l).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})),datasets:_(s.value)}}),h={responsive:!0,maintainAspectRatio:!1,plugins:{datalabels:{display:!1}}};return y.register(x,k,w,D,L,V,N),F(async()=>{s.value=await f.getForecast()}),(e,l)=>(M(),P("div",null,[u(J,{color:"transparent",title:m(g)("app.forecast")},null,8,["title"]),u(O),A("div",Q,[u(m(I),{data:b.value,options:h},null,8,["data"])])]))}});export{H as default};
