var __decorate=this&&this.__decorate||function(e,t,r,a){var o,i=arguments.length,l=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,r,a);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(l=(i<3?o(l):i>3?o(t,r,l):o(t,r))||l);return i>3&&l&&Object.defineProperty(t,r,l),l};import{html as e,LitElement as t,css as r}from"lit";import{customElement as a,property as o}from"lit/decorators.js";import{InputType as i}from"@openremote/or-mwc-components/or-mwc-input";import{OrRulesJsonRuleChangedEvent as l}from"../or-rule-json-viewer";import{i18next as n}from"@openremote/or-translate";let OrRuleFormAlarm=class extends t{constructor(){super(...arguments),this.users=[]}static get styles(){return r`
            or-mwc-input {
                margin-bottom: 20px;
                min-width: 420px;
                width: 100%;
            }
        `}render(){let t=this.action.alarm,r=this.users.filter(e=>"manager-keycloak"!==e.username).map(e=>({value:e.id,label:e.username}));return r.unshift({value:void 0,label:n.t("none")}),e`
            <form style="display:grid">
                <or-mwc-input value="${t&&t.title?t.title:""}" @or-mwc-input-changed="${e=>this.setActionAlarmName(e.detail.value,"title")}" .label="title" type="${i.TEXT}" required placeholder=" "></or-mwc-input>
                <or-mwc-input value="${t&&t.content?t.content:""}" @or-mwc-input-changed="${e=>this.setActionAlarmName(e.detail.value,"content")}" .label=content" type="${i.TEXTAREA}" required placeholder=" " ></or-mwc-input>
                <or-mwc-input .label="${n.t("alarm.assignee")}"
                              .type="${i.SELECT}"
                              .options="${r.map(e=>e.label)}"
                              .value="${this.action.assigneeId?r.filter(e=>e.value===this.action.assigneeId).map(e=>e.label)[0]:""}"
                              @or-mwc-input-changed="${e=>{this.action.assigneeId=r.filter(t=>t.label===e.detail.value).map(e=>e.value)[0],this.setActionAlarmName(e.detail.value,void 0)}}"
                ></or-mwc-input> 
            </form>
        `}setActionAlarmName(e,t){if(t&&this.action.alarm){let r=this.action.alarm;r[t]=e,this.action.alarm=Object.assign({},r)}t||(this.action.assigneeId=this.users.filter(t=>t.username===e).map(e=>e.id)[0]),this.dispatchEvent(new l),this.requestUpdate()}};__decorate([o({type:Object,attribute:!1})],OrRuleFormAlarm.prototype,"action",void 0),__decorate([o()],OrRuleFormAlarm.prototype,"users",void 0),OrRuleFormAlarm=__decorate([a("or-rule-form-alarm")],OrRuleFormAlarm);export{OrRuleFormAlarm};