<html><head></head><body><dom-module id="ha-panel-history"><template><style include="iron-flex ha-style">.content{padding:0 16px 16px;}vaadin-date-picker{--vaadin-date-picker-clear-icon:{display:none;};margin-bottom:24px;margin-right:16px;max-width:200px;}paper-dropdown-menu{max-width:100px;}paper-item{cursor:pointer;}</style><ha-state-history-data hass="[[hass]]" filter-type="[[_filterType]]" start-time="[[_computeStartTime(_currentDate)]]" end-time="[[endTime]]" data="{{stateHistoryInput}}" is-loading="{{isLoadingData}}"></ha-state-history-data><app-header-layout has-scrolling-region=""><app-header slot="header" fixed=""><app-toolbar><ha-menu-button narrow="[[narrow]]" show-menu="[[showMenu]]"></ha-menu-button><div main-title="">[[localize('panel.history')]]</div></app-toolbar></app-header><div class="flex content"><div class="flex layout horizontal wrap"><vaadin-date-picker id="picker" value="{{_currentDate}}" label="[[localize('ui.panel.history.showing_entries')]]" disabled="[[isLoadingData]]"></vaadin-date-picker><paper-dropdown-menu label-float="" label="[[localize('ui.panel.history.period')]]" disabled="[[isLoadingData]]"><paper-listbox slot="dropdown-content" selected="{{_periodIndex}}"><paper-item>[[localize('ui.duration.day', 'count', 1)]]</paper-item><paper-item>[[localize('ui.duration.day', 'count', 3)]]</paper-item><paper-item>[[localize('ui.duration.week', 'count', 1)]]</paper-item></paper-listbox></paper-dropdown-menu></div><state-history-charts history-data="[[stateHistoryOutput]]" is-loading-data="[[isLoadingData]]" end-time="[[endTime]]"></state-history-charts></div></app-header-layout></template></dom-module><script>class HaPanelHistory extends(window.hassMixins.LocalizeMixin(Polymer.Element)){static get is(){return"ha-panel-history"}static get properties(){return{hass:{type:Object},narrow:{type:Boolean},showMenu:{type:Boolean,value:!1},stateHistoryInput:{type:Object,value:null,observer:"stateHistoryObserver"},stateHistoryOutput:{type:Object,value:null},_periodIndex:{type:Number,value:0},isLoadingData:{type:Boolean,value:!1},endTime:{type:Object,computed:"_computeEndTime(_currentDate, _periodIndex)"},_currentDate:{type:String,value:function(){var e=new Date;return new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())).toISOString().split("T")[0]}},_filterType:{type:String,value:"date"}}}datepickerFocus(){this.datePicker.adjustPosition()}connectedCallback(){super.connectedCallback();var e=new Date;this.$.picker.set("i18n.parseDate",function(){return e}),this.$.picker.set("i18n.formatDate",function(t){return e=t,window.hassUtil.formatDate(t)})}_computeStartTime(e){if(e){var t=e.split("-");return t[1]=parseInt(t[1])-1,new Date(t[0],t[1],t[2])}}_computeEndTime(e,t){var a=this._computeStartTime(e),r=new Date(a);return r.setDate(a.getDate()+this._computeFilterDays(t)),r}_computeFilterDays(e){switch(e){case 1:return 3;case 2:return 7;default:return 1}}stateHistoryObserver(e){setTimeout(()=>{e===this.stateHistoryInput&&(this.stateHistoryOutput=e)},1)}}customElements.define(HaPanelHistory.is,HaPanelHistory);</script></body></html>