UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 25.3 kB
export const __rspack_esm_id=19260;export const __rspack_esm_ids=[19260];export const __webpack_modules__={44439(t,e,i){i.a(t,async function(t,e){try{i(74423),i(44114),i(18111),i(81148),i(22489),i(20116),i(7588),i(61701),i(18237),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var o=i(62826),s=i(88696),a=i(35211),r=i(6116),n=i(5124),l=i(22441),h=i(6412),d=i(89784),c=i(44537),p=i(90433),g=i(32172),m=i(1087),u=i(71769),y=i(12587),_=i(22792),x=i(41570),v=(i(34296),i(26300)),f=i(29961),b=i(34218),w=i(57243),C=t([v,f]);[v,f]=C.then?(await C)():C;const P="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z",k="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",L="M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z",A="M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z",D="M12,4C14.1,4 16.1,4.8 17.6,6.3C20.7,9.4 20.7,14.5 17.6,17.6C15.8,19.5 13.3,20.2 10.9,19.9L11.4,17.9C13.1,18.1 14.9,17.5 16.2,16.2C18.5,13.9 18.5,10.1 16.2,7.7C15.1,6.6 13.5,6 12,6V10.6L7,5.6L12,0.6V4M6.3,17.6C3.7,15 3.3,11 5.1,7.9L6.6,9.4C5.5,11.6 5.9,14.4 7.8,16.2C8.3,16.7 8.9,17.1 9.6,17.4L9,19.4C8,19 7.1,18.4 6.3,17.6Z",T=10,Z=6,S=300,z=t=>t,M=t=>{const{formatter:e,...i}=t,o={...i};return"function"==typeof e?o.formatter=z((0,w.V)(e)):void 0!==e&&(o.formatter=e),o},V=t=>t.tooltip&&"function"==typeof t.tooltip.formatter?{...t,tooltip:M(t.tooltip)}:t;class $ extends n.WF{disconnectedCallback(){for(super.disconnectedCallback(),this._legendPointerCancel(),this._pendingSetup=!1;this._listeners.length;)this._listeners.pop()();this.chart?.dispose(),this.chart=void 0,this._originalZrFlush=void 0}connectedCallback(){if(super.connectedCallback(),this.hasUpdated&&(this._pendingSetup=!0,(0,y.m)(()=>{this.isConnected&&this._pendingSetup&&(this._pendingSetup=!1,this._setupChart())})),this._listeners.push((0,u.m)("(prefers-reduced-motion)",t=>{this._reducedMotion!==t&&(this._reducedMotion=t,this._setChartOptions({animation:!this._reducedMotion}))})),!this.options?.dataZoom){const t=t=>{!this._modifierPressed&&(x.c&&"Meta"===t.key||!x.c&&"Control"===t.key)&&(this._modifierPressed=!0,this.options?.dataZoom||this._setChartOptions({dataZoom:this._getDataZoomConfig()}),this._updateSankeyRoam(),this.chart?.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!0}))},e=t=>{this._modifierPressed&&(x.c&&"Meta"===t.key||!x.c&&"Control"===t.key)&&(this._modifierPressed=!1,this.options?.dataZoom||this._setChartOptions({dataZoom:this._getDataZoomConfig()}),this._updateSankeyRoam(),this.chart?.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!1}))};window.addEventListener("keydown",t),window.addEventListener("keyup",e),this._listeners.push(()=>window.removeEventListener("keydown",t),()=>window.removeEventListener("keyup",e))}const t=t=>{const e=t;this._layoutTransitionActive=Boolean(e.detail?.active),this.toggleAttribute("layout-transition-active",this._layoutTransitionActive),this._suspendResize=this._layoutTransitionActive,this._suspendResize||this._resizeChartIfNeeded()};window.addEventListener("hass-layout-transition",t),this._listeners.push(()=>window.removeEventListener("hass-layout-transition",t))}firstUpdated(){this.isConnected&&this._setupChart()}willUpdate(t){if(!this.chart)return;if(t.has("_themes")&&this.hasUpdated)return void this._setupChart();let e={};t.has("options")&&this._updateHiddenStatsFromOptions(this.options),(t.has("data")||t.has("_hiddenDatasets"))&&(e.series=this._getSeries()),t.has("options")?(e={...e,...this._createOptions()},this._compareCustomLegendOptions(t.get("options"),this.options)&&(this._shouldResizeChart=!0,this._resizeAnimationDuration=250)):this._isTouchDevice&&t.has("_isZoomed")&&(e.dataZoom=this._getDataZoomConfig()),Object.keys(e).length>0&&(this._setChartOptions(e),e.series&&this._updateSankeyRoam())}render(){return n.qy` <div class="container ${(0,h.H)({"has-height":!!this.height})}" style="${(0,d.W)({height:this.height})}"> <div class="chart-container" style="${(0,d.W)({height:this.height?void 0:`${this._getDefaultHeight()}px`})}"> <div class="chart"></div> </div> ${this._renderLegend()} <div class="top-controls ${(0,h.H)({small:this.smallControls})}"> <slot name="search"></slot> <div class="chart-controls ${(0,h.H)({small:this.smallControls})}"> ${this._isZoomed&&!this.hideResetButton?n.qy`<ha-icon-button class="zoom-reset" .path="${D}" @click="${this._handleZoomReset}" title="${this.hass.localize("ui.components.history_charts.zoom_reset")}"></ha-icon-button>`:n.s6} <slot name="button"></slot> </div> </div> </div> `}_getLegendItems(){if(!this.options?.legend||!this.data)return;const t=(0,c.e)(this.options.legend).find(t=>t.show&&"custom"===t.type);if(!t)return;const e=(0,c.e)(this.data);return t.data||e.filter(t=>t.data?.length&&(t.id||t.name)).map(t=>({id:t.id,name:t.name}))}_renderLegend(){const t=this._getLegendItems();if(!t)return n.s6;const e=(0,c.e)(this.data),i=window.matchMedia("all and (max-width: 450px), all and (max-height: 500px)").matches?Z:T;return n.qy`<div class="${(0,h.H)({"chart-legend":!0,"multiple-items":t.length>1})}"> <ul> ${t.map((t,o)=>{if(!this.expandLegend&&o>=i)return n.s6;let s={},a="",r="",l=!1;const c="string"==typeof t?t:t.name??"";"string"==typeof t?a=t:(a=t.id??c,r=t.value??"",s=t.itemStyle??{},l=t.noLabelClick??!1);const p=this.clickLabelForMoreInfo&&!l,g=e.find(t=>t.id===a)??e.find(t=>t.name===a);s={color:g?.color,...g?.itemStyle,...s};const m=s?.color;return n.qy`<li .id="${a}" @pointerdown="${this._legendPointerDown}" @pointerup="${this._legendPointerCancel}" @pointerleave="${this._legendPointerCancel}" @pointercancel="${this._legendPointerCancel}" @contextmenu="${this._legendContextMenu}" class="${(0,h.H)({hidden:this._hiddenDatasets.has(a)})}"> <button type="button" class="legend-toggle" data-id="${a}" aria-pressed="${!this._hiddenDatasets.has(a)}" .title="${this.hass.localize("ui.components.history_charts.toggle_visibility")}" @click="${this._toggleDataset}"> <ha-svg-icon .path="${this._hiddenDatasets.has(a)?A:P}" style="${(0,d.W)({color:this._hiddenDatasets.has(a)?void 0:m})}"></ha-svg-icon> </button> <button type="button" class="${(0,h.H)({label:!0,clickable:p})}" data-id="${a}" .title="${c}" @click="${this._labelClick}"> ${c} </button> ${r?n.qy`<div class="value">${r}</div>`:n.s6} </li>`})} ${t.length>i?n.qy`<li> <ha-assist-chip @click="${this._toggleExpandedLegend}" filled label="${this.expandLegend?this.hass.localize("ui.components.history_charts.collapse_legend"):`${this.hass.localize("ui.components.history_charts.expand_legend")} (${t.length-i})`}"> <ha-svg-icon slot="trailing-icon" .path="${this.expandLegend?L:k}"></ha-svg-icon> </ha-assist-chip> </li>`:n.s6} </ul> </div>`}async _setupChart(){if(!this._loading){this._loading=!0;try{this.chart&&this.chart.dispose();const t=(await Promise.all([i.e(4801),i.e(37552),i.e(77072),i.e(53771),i.e(1872),i.e(9970),i.e(24060),i.e(18140)]).then(i.bind(i,79144))).default;this.extraComponents?.length&&t.use(this.extraComponents);const e=getComputedStyle(this);if(t.registerTheme("custom",this._createTheme(e)),this.chart=t.init(this._chartContainer,"custom"),this.chart.on("datazoom",t=>{this._handleDataZoomEvent(t)}),this.chart.on("click",t=>{(0,m.r)(this,"chart-click",t)}),this.chart.on("sankeyroam",()=>{const t=this.chart.getOption().series,e=t?.find(t=>"sankey"===t.type),i=1!==e.zoom;this._isZoomed=i,i||this.chart.setOption({series:[{id:e.id,center:null}]}),(0,m.r)(this,"chart-sankeyroam",{zoom:e.zoom}),this.chart.dispatchAction({type:"downplay"})}),this.options?.dataZoom||this.chart.getZr().on("dblclick",this._handleClickZoom),this.chart.on("finished",this._handleChartRenderFinished),this._isTouchDevice){this.chart.getZr().on("click",t=>{t.zrByTouch&&(this._lastTapTime&&Date.now()-this._lastTapTime<S?this._handleClickZoom(t):this._lastTapTime=Date.now())});let t,i,o=!1;this.chart.on("showTip",o=>{t=o.x,i=o.y,this.chart?.setOption({xAxis:(0,c.e)(this.chart?.getOption().xAxis??[]).map(t=>t.show?{...t,axisPointer:{...t.axisPointer,status:"show",handle:{color:e.getPropertyValue("--primary-color"),margin:0,size:20,...t.axisPointer?.handle,show:!0},label:{show:!1}}}:t)})}),this.chart.on("hideTip",e=>{if(e.from){if(o)return void(o=!1);this.chart?.setOption({xAxis:(0,c.e)(this.chart?.getOption().xAxis??[]).map(t=>t.show?{...t,axisPointer:{...t.axisPointer,handle:{...t.axisPointer?.handle,show:!1},status:"hide"}}:t)}),this.chart?.dispatchAction({type:"downplay"})}else null!=t&&null!=i&&(o=!0,this.chart?.dispatchAction({type:"showTip",x:t,y:i}))})}this._updateHiddenStatsFromOptions(this.options),this.chart.setOption({...this._createOptions(),series:this._getSeries()}),this._updateSankeyRoam()}finally{this._loading=!1}}}_getAllIdsFromLegend(t,e){if(!t)return[e];const i=(0,c.e)(this.options?.legend||[])[0];let o;return"custom"===i?.type&&(o=i.data?.find(t=>"object"==typeof t&&t.id===e)),[e,...o?.secondaryIds||[]]}_updateHiddenStatsFromOptions(t){if(!t)return;const e=(0,c.e)(this.options?.legend||[])[0];Object.entries(e?.selected||{}).forEach(([e,i])=>{!1===i&&this._getAllIdsFromLegend(t,e).forEach(t=>this._hiddenDatasets.add(t))}),this.requestUpdate("_hiddenDatasets")}_getDataZoomConfig(){const t=this.options?.xAxis?.[0]??this.options?.xAxis,e=this.options?.yAxis?.[0]??this.options?.yAxis;if("value"!==t?.type||"category"!==e?.type)return{id:"dataZoom",type:"inside",orient:"horizontal",filterMode:this._getDataZoomFilterMode(),xAxisIndex:0,moveOnMouseMove:!this._isTouchDevice||this._isZoomed,preventDefaultMouseMove:!this._isTouchDevice||this._isZoomed,zoomLock:!this._isTouchDevice&&!this._modifierPressed}}_getDataZoomFilterMode(){const t=(0,c.e)(this.data);return t.every(t=>"line"===t.type)?"boundaryFilter":t.some(t=>"bar"===t.type)?"filter":"weakFilter"}_createOptions(){let t=this.options?.xAxis;t&&(t=Array.isArray(t)?t:[t],t=t.map(t=>{if("time"!==t.type||!1===t.show)return t;t.min&&(this._minutesDifference=(0,r.o)(t.max||new Date,t.min));const e=this._minutesDifference/60/24;let i;return e&&(i=e>=89?24192e5:e>2?864e5:void 0),{axisLine:{show:!1},splitLine:{show:!0},...t,axisLabel:{formatter:this._formatTimeLabel,rich:{bold:{fontWeight:"bold"}},hideOverlap:!0,...t.axisLabel},minInterval:t.minInterval??i}}));let e=this.options?.legend;e&&(e=(0,c.e)(e).map(t=>"custom"===t.type?{show:!1}:t));const i={animation:!this._reducedMotion,animationDuration:500,darkMode:this._themes.darkMode??!1,aria:{show:!0},dataZoom:this._getDataZoomConfig(),toolbox:{top:Number.MAX_SAFE_INTEGER,left:Number.MAX_SAFE_INTEGER,feature:{dataZoom:{show:!0,yAxisIndex:!1,filterMode:"none",showTitle:!1}},iconStyle:{opacity:0}},...this.options,legend:e,xAxis:t};if(i.tooltip){const t=window.matchMedia("all and (max-width: 450px), all and (max-height: 500px)").matches,e=e=>{const i=M(e);return t&&(i.confine=!0,i.appendTo=void 0,i.triggerOn="click"),i},o=i.tooltip,s=Array.isArray(o)?o.map(e):e(o);return{...i,tooltip:s}}return i}_createTheme(t){const e=t.getPropertyValue("--ha-card-background")||t.getPropertyValue("--card-background-color");return{color:(0,p.ux)(t),backgroundColor:"transparent",textStyle:{color:t.getPropertyValue("--primary-text-color"),fontFamily:"Roboto, Noto, sans-serif"},title:{textStyle:{color:t.getPropertyValue("--primary-text-color")},subtextStyle:{color:t.getPropertyValue("--secondary-text-color")}},line:{lineStyle:{width:1.5},symbolSize:1,symbol:"circle",smooth:!1},bar:{itemStyle:{barBorderWidth:1.5}},graph:{label:{color:t.getPropertyValue("--primary-text-color"),textBorderColor:e,textBorderWidth:2}},pie:{label:{color:t.getPropertyValue("--primary-text-color"),textBorderColor:e,textBorderWidth:2}},sankey:{label:{color:t.getPropertyValue("--primary-text-color"),textBorderColor:e,textBorderWidth:2}},categoryAxis:{axisLine:{show:!1},axisTick:{show:!1},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!1,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},valueAxis:{axisLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},logAxis:{axisLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},legend:{textStyle:{color:t.getPropertyValue("--primary-text-color")},inactiveColor:t.getPropertyValue("--disabled-text-color"),pageIconColor:t.getPropertyValue("--primary-text-color"),pageIconInactiveColor:t.getPropertyValue("--disabled-text-color"),pageTextStyle:{color:t.getPropertyValue("--secondary-text-color")}},tooltip:{backgroundColor:t.getPropertyValue("--card-background-color"),borderColor:t.getPropertyValue("--divider-color"),textStyle:{color:t.getPropertyValue("--primary-text-color"),fontSize:12},axisPointer:{lineStyle:{color:t.getPropertyValue("--info-color")},crossStyle:{color:t.getPropertyValue("--info-color")}},extraCssText:"direction:"+t.getPropertyValue("--direction")+";margin-inline-start:3px;margin-inline-end:8px;"},timeline:{}}}_getSeries(){const t=this.options?.xAxis?.[0]??this.options?.xAxis;return(0,c.e)(this.data).map(e=>{const i=this._hiddenDatasets.has(String(e.id??e.name))?void 0:e.data;let o={...e,data:i};if(i&&"line"===e.type&&"minmax"===e.sampling){const e=t?.min?t.min instanceof Date?t.min.getTime():"number"==typeof t.min?t.min:void 0:void 0,s=t?.max?t.max instanceof Date?t.max.getTime():"number"==typeof t.max?t.max:void 0:void 0;o={...o,sampling:void 0,data:(0,b.P)(i,this.clientWidth*window.devicePixelRatio,e,s)}}return V(o)})}_getDefaultHeight(){return Math.max(this.clientWidth/2,200)}_setChartOptions(t){if(!this.chart)return;if(!this._originalZrFlush){if((0,c.e)(this.data).reduce((t,e)=>t+(e.data||[]).length,0)>1e4){const t=this.chart.getZr();this._originalZrFlush=t.flush,t.flush=()=>{setTimeout(()=>{this._originalZrFlush?.call(t)},5)}}}const e=t.series?["series"]:[];this.chart.setOption(t,{replaceMerge:e})}zoom(t,e,i=!1){this.chart?.dispatchAction({type:"dataZoom",start:t,end:e,silent:i})}_handleZoomReset(){this.chart?.dispatchAction({type:"dataZoom",start:0,end:100});const t=this.chart?.getOption(),e=t?.series?.filter(t=>"sankey"===t.type);e?.length&&(this.chart?.setOption({series:e.map(t=>({id:t.id,zoom:1,center:null}))}),this._isZoomed=!1,(0,m.r)(this,"chart-sankeyroam",{zoom:1}))}_updateSankeyRoam(){const t=this.chart?.getOption(),e=t?.series?.filter(t=>null!=t&&"sankey"===t.type);e?.length&&this.chart?.setOption({series:e.map(t=>({id:t.id,roam:!(!this._modifierPressed&&!this._isTouchDevice)||"move"}))})}_handleDataZoomEvent(t){const e=t.batch?.[0]??t;let i="number"==typeof e.start?e.start:0,o="number"==typeof e.end?e.end:100;if(0===i&&100===o&&void 0!==e.startValue&&void 0!==e.endValue){const t=this.chart.getOption(),s=t.xAxis?.[0]??t.xAxis;if(s?.min&&s?.max){const t=new Date(s.min).getTime(),a=new Date(s.max).getTime()-t;i=Math.max(0,Math.min(100,(e.startValue-t)/a*100)),o=Math.max(0,Math.min(100,(e.endValue-t)/a*100))}}this._isZoomed=0!==i||100!==o,this._zoomRatio=(o-i)/100,this._isTouchDevice&&this.chart?.dispatchAction({type:"hideTip",from:"datazoom"}),(0,m.r)(this,"chart-zoom",{start:i,end:o})}_legendPointerDown(t){if("mouse"===t.pointerType)return;const e=t.currentTarget?.id;e&&(this._longPressTriggered=!1,this._longPressTimer=setTimeout(()=>{this._longPressTriggered=!0,this._longPressTimer=void 0,this._soloLegend(e)},500))}_legendPointerCancel(){this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=void 0)}_legendContextMenu(t){(this._longPressTimer||this._longPressTriggered)&&t.preventDefault()}_toggleDataset(t){if(t.stopPropagation(),!this.chart)return;if(this._longPressTriggered)return void(this._longPressTriggered=!1);const e=t.currentTarget.dataset.id;if(!e)return;(x.c?t.metaKey:t.ctrlKey)?this._soloLegend(e):this._handleDatasetToggle(e)}_labelClick(t){if(t.stopPropagation(),!this.chart)return;if(this._longPressTriggered)return void(this._longPressTriggered=!1);const e=t.currentTarget,i=e.dataset.id;if(!i)return;(x.c?t.metaKey:t.ctrlKey)?this._soloLegend(i):e.classList.contains("clickable")?(0,m.r)(this,"legend-label-click",{id:i}):this._handleDatasetToggle(i)}_handleDatasetToggle(t){this._hiddenDatasets.has(t)?(this._getAllIdsFromLegend(this.options,t).forEach(t=>this._hiddenDatasets.delete(t)),(0,m.r)(this,"dataset-unhidden",{id:t})):(this._getAllIdsFromLegend(this.options,t).forEach(t=>this._hiddenDatasets.add(t)),(0,m.r)(this,"dataset-hidden",{id:t})),this.requestUpdate("_hiddenDatasets")}_soloLegend(t){const e=this._getAllLegendIds(),i=this._getAllIdsFromLegend(this.options,t),o=e.filter(t=>!i.includes(t));if(i.every(t=>!this._hiddenDatasets.has(t))&&o.every(t=>this._hiddenDatasets.has(t)))for(const t of[...this._hiddenDatasets])this._hiddenDatasets.delete(t),(0,m.r)(this,"dataset-unhidden",{id:t});else{for(const t of o)this._hiddenDatasets.has(t)||(this._hiddenDatasets.add(t),(0,m.r)(this,"dataset-hidden",{id:t}));for(const t of i)this._hiddenDatasets.has(t)&&(this._hiddenDatasets.delete(t),(0,m.r)(this,"dataset-unhidden",{id:t}))}this.requestUpdate("_hiddenDatasets")}_getAllLegendIds(){const t=this._getLegendItems();if(!t)return[];const e=new Set;for(const i of t){const t="string"==typeof i?i:i.id??i.name??"";for(const i of this._getAllIdsFromLegend(this.options,t))e.add(i)}return[...e]}_toggleExpandedLegend(){this.expandLegend=!this.expandLegend,setTimeout(()=>{this.chart?.resize()})}_resizeChartIfNeeded(){this.chart&&this._shouldResizeChart&&(this._suspendResize||this.chart.getZr().animation.isFinished()&&(this.chart.resize({animation:this._reducedMotion||"number"!=typeof this._resizeAnimationDuration?void 0:{duration:this._resizeAnimationDuration}}),this._shouldResizeChart=!1,this._resizeAnimationDuration=void 0))}_compareCustomLegendOptions(t,e){const i=(0,c.e)(t?.legend||[]),o=(0,c.e)(e?.legend||[]);return i.some(t=>t.show&&"custom"===t.type)!==o.some(t=>t.show&&"custom"===t.type)}constructor(...t){super(...t),this.data=[],this.clickLabelForMoreInfo=!1,this._isZoomed=!1,this._zoomRatio=1,this._minutesDifference=1440,this._hiddenDatasets=new Set,this._modifierPressed=!1,this._isTouchDevice="ontouchstart"in window,this._longPressTriggered=!1,this._shouldResizeChart=!1,this._suspendResize=!1,this._layoutTransitionActive=!1,this._resizeController=new s.P(this,{callback:()=>{if(this.chart){if(this._suspendResize)return void(this._shouldResizeChart=!0);this.chart.getZr().animation.isFinished()?this.chart.resize():this._shouldResizeChart=!0}}}),this._loading=!1,this._reducedMotion=!1,this._listeners=[],this._pendingSetup=!1,this._formatTimeLabel=t=>(0,f.n)(t,this.hass.locale,this.hass.config,this._minutesDifference*this._zoomRatio),this._handleClickZoom=t=>{if(!this.chart)return;const e=this.chart.getOption().series,i=e?.filter(t=>"sankey"===t.type);if(i?.length&&(this._isZoomed?this._handleZoomReset():(this.chart.setOption({series:i.map(t=>({id:t.id,zoom:2}))}),this._isZoomed=!0),i.length===e?.length))return;const o=this._isZoomed?[0,100]:[t.offsetX/this.chart.getWidth()*100-15,t.offsetX/this.chart.getWidth()*100+15];this.chart.dispatchAction({type:"dataZoom",start:o[0],end:o[1]})},this._handleChartRenderFinished=()=>{this._resizeChartIfNeeded()}}}$.styles=n.AH`:host{display:block;position:relative;letter-spacing:normal;overflow:visible}:host([layout-transition-active]),:host([layout-transition-active]) .chart-container,:host([layout-transition-active]) .container{overflow:hidden}.container{display:flex;flex-direction:column;position:relative;overflow:visible}.container.has-height{max-height:var(--chart-max-height,350px)}.chart-container{width:100%;max-height:var(--chart-max-height,350px);overflow:visible}.has-height .chart-container{flex:1}.chart{height:100%;width:100%}.top-controls{position:absolute;top:var(--ha-space-4);inset-inline-start:var(--ha-space-4);inset-inline-end:var(--ha-space-1);display:flex;align-items:flex-start;gap:var(--ha-space-2);z-index:1;pointer-events:none}::slotted([slot=search]){flex:1 1 250px;min-width:0;max-width:250px;pointer-events:auto}.chart-controls{display:flex;flex-direction:column;gap:var(--ha-space-1);margin-inline-start:auto;flex-shrink:0;pointer-events:auto}.top-controls.small{top:0}.chart-controls.small{flex-direction:row}.chart-controls ::slotted(ha-icon-button),.chart-controls ha-icon-button{background:var(--card-background-color);border-radius:var(--ha-border-radius-sm);--ha-icon-button-size:32px;color:var(--primary-color);border:1px solid var(--divider-color)}.chart-controls.small ::slotted(ha-icon-button),.chart-controls.small ha-icon-button{--ha-icon-button-size:22px;--mdc-icon-size:16px}.chart-controls ::slotted(ha-icon-button.inactive),.chart-controls ha-icon-button.inactive{color:var(--state-inactive-color)}.chart-legend{max-height:60%;overflow-y:auto;padding:12px 0 0;font-size:var(--ha-font-size-s);color:var(--primary-text-color)}.chart-legend ul{margin:0;padding:0;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:var(--ha-space-2)}.chart-legend li{height:24px;display:inline-flex;align-items:center;padding:0 2px;box-sizing:border-box;overflow:hidden}.chart-legend.multiple-items li{max-width:220px}.chart-legend.multiple-items li:has(.value){max-width:300px}.chart-legend .hidden{color:var(--secondary-text-color)}.chart-legend .label{background:0 0;border:none;padding:0;margin:0;font:inherit;color:inherit;cursor:pointer;text-align:start;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;line-height:1}@media (hover:hover){.chart-legend .label.clickable:hover{text-decoration:underline}.chart-legend .legend-toggle:hover{opacity:.5}}.chart-legend .value{color:var(--secondary-text-color);margin-inline-start:var(--ha-space-1);flex-shrink:0;white-space:nowrap;line-height:1}.chart-legend .legend-toggle{background:0 0;border:none;color:inherit;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;padding:4px;margin:-4px;margin-inline-end:0}.chart-legend .label:focus-visible,.chart-legend .legend-toggle:focus-visible{outline:2px solid var(--primary-color);outline-offset:2px;border-radius:var(--ha-border-radius-small,4px)}.chart-legend .legend-toggle ha-svg-icon{--mdc-icon-size:18px}@media (pointer:coarse){.chart-legend ul{row-gap:0}.chart-legend li:has(.legend-toggle){height:40px;padding:0}.chart-legend .legend-toggle{padding:11px;padding-inline-end:4px;margin:0}}ha-assist-chip{height:100%;--_label-text-weight:500;--_leading-space:8px;--_trailing-space:8px;--_icon-label-space:4px}`,(0,o.Cg)([(0,l.MZ)({attribute:!1})],$.prototype,"hass",void 0),(0,o.Cg)([(0,l.MZ)({attribute:!1})],$.prototype,"data",void 0),(0,o.Cg)([(0,l.MZ)({attribute:!1})],$.prototype,"options",void 0),(0,o.Cg)([(0,l.MZ)({type:String})],$.prototype,"height",void 0),(0,o.Cg)([(0,l.MZ)({attribute:"expand-legend",type:Boolean})],$.prototype,"expandLegend",void 0),(0,o.Cg)([(0,l.MZ)({attribute:"small-controls",type:Boolean})],$.prototype,"smallControls",void 0),(0,o.Cg)([(0,l.MZ)({attribute:"hide-reset-button",type:Boolean})],$.prototype,"hideResetButton",void 0),(0,o.Cg)([(0,l.wk)(),(0,a.Fg)({context:_.EK,subscribe:!0}),(0,g.p)({transformer:({themes:t})=>t})],$.prototype,"_themes",void 0),(0,o.Cg)([(0,l.MZ)({attribute:"click-label-for-more-info",type:Boolean})],$.prototype,"clickLabelForMoreInfo",void 0),(0,o.Cg)([(0,l.wk)()],$.prototype,"_isZoomed",void 0),(0,o.Cg)([(0,l.wk)()],$.prototype,"_zoomRatio",void 0),(0,o.Cg)([(0,l.wk)()],$.prototype,"_minutesDifference",void 0),(0,o.Cg)([(0,l.wk)()],$.prototype,"_hiddenDatasets",void 0),(0,o.Cg)([(0,l.P)(".chart")],$.prototype,"_chartContainer",void 0),$=(0,o.Cg)([(0,l.EM)("ha-chart-base")],$),e()}catch(t){e(t)}})},57243(t,e,i){i.d(e,{V:()=>a});i(88454),i(29452);var o=i(5124);const s=new WeakMap,a=t=>{const e=s.get(t);if(e)return e;const i=document.createElement("div");i.style.display="contents";const a=(e,s)=>{const a=t(e,s);return null==a||a===o.s6?null:((0,o.XX)(a,i),i)};return s.set(t,a),s.set(a,a),a}},41570(t,e,i){i.d(e,{c:()=>o});const o=/Mac/i.test(navigator.userAgent)}};