var __decorate=this&&this.__decorate||function(e,t,r,n){var o,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(s=(a<3?o(s):a>3?o(t,r,s):o(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s};import{html as e,LitElement as t}from"lit";import{customElement as r,property as n}from"lit/decorators.js";import{when as o}from"lit/directives/when.js";import{createMenuBarItem as a}from"@openremote/or-vaadin-components/or-vaadin-menu-bar";export function intervalToMillis(e){switch(e){case"OFF":default:return;case"ONE_MIN":return 6e4;case"FIVE_MIN":return 3e5;case"QUARTER":return 9e5;case"ONE_HOUR":return 36e5}}export class IntervalSelectEvent extends CustomEvent{constructor(e){super(IntervalSelectEvent.NAME,{bubbles:!0,composed:!0,detail:e})}}IntervalSelectEvent.NAME="interval-select";let DashboardRefreshControls=class extends t{constructor(){super(...arguments),this.interval="OFF",this.readonly=!0,this.intervalOptions=["OFF","ONE_MIN","FIVE_MIN","QUARTER","ONE_HOUR"]}willUpdate(e){super.willUpdate(e),e.has("interval")&&void 0!==this.interval&&this.dispatchEvent(new IntervalSelectEvent(this.interval))}render(){let t=this.getRefreshOptions(),r=[{component:a(o("OFF"===this.interval,()=>e`<or-icon icon="pause"></or-icon>`,()=>e`<or-translate value=${this.getIntervalString(this.interval)}></or-translate>`)),children:t.map(t=>({interval:t,component:a(e`<or-translate value=${t}></or-translate>`)}))}];return e`
            <or-vaadin-menu-bar .items=${r} ?disabled=${this.readonly}
                                @item-selected=${e=>this.onIntervalSelect(t,e.detail.value.interval)}
            ></or-vaadin-menu-bar>
        `}onIntervalSelect(e,t){this.interval=this.intervalOptions[e.indexOf(t)]}getIntervalString(e){return`dashboard.interval.${e.toLowerCase()}`}getRefreshOptions(){return this.intervalOptions.map(e=>this.getIntervalString(e))}};__decorate([n()],DashboardRefreshControls.prototype,"interval",void 0),__decorate([n()],DashboardRefreshControls.prototype,"readonly",void 0),DashboardRefreshControls=__decorate([r("dashboard-refresh-controls")],DashboardRefreshControls);export{DashboardRefreshControls};