var __decorate=this&&this.__decorate||function(e,o,t,r){var l,i=arguments.length,a=i<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,o,t,r);else for(var n=e.length-1;n>=0;n--)(l=e[n])&&(a=(i<3?l(a):i>3?l(o,t,a):l(o,t))||a);return i>3&&a&&Object.defineProperty(o,t,a),a};import{InputType as e}from"@openremote/or-mwc-components/or-mwc-input";import{i18next as o}from"@openremote/or-translate";import{html as t,LitElement as r}from"lit";import{customElement as l,property as i}from"lit/decorators.js";let OrRuleWebhookModal=class extends r{constructor(){super(),this.title=o.t("message")}firstUpdated(e){e.has("action")&&this.renderDialogHTML(this.action)}renderDialogHTML(e){let o=this.shadowRoot.getElementById("webhook-modal");if(!this.shadowRoot)return;let r=this.shadowRoot.querySelector(".webhook-form-slot");if(o&&r){let e=document.createElement("div");r.assignedNodes({flatten:!0}).forEach(o=>{o instanceof HTMLElement&&e.appendChild(o)}),o.content=t`${e}`,o.dismissAction=null,this.requestUpdate()}}closeForm(e){this.shadowRoot.host.close()}render(){if(!this.action)return t`${o.t("errorOccurred")}`;let r=[{actionName:"",content:t`
                    <or-mwc-input .type="${e.BUTTON}" label="ok"
                                  @or-mwc-input-changed="${this.closeForm}"></or-mwc-input>`}],l=()=>{let e=this.shadowRoot.getElementById("webhook-modal");e&&e.open()};return t`
            <or-mwc-input type="${e.BUTTON}" label="message"
                          @or-mwc-input-changed="${l}"></or-mwc-input>
            <or-mwc-dialog id="webhook-modal" heading="${this.title}" .actions="${r}"></or-mwc-dialog>
            <slot class="webhook-form-slot"></slot>
        `}};__decorate([i({type:Object})],OrRuleWebhookModal.prototype,"action",void 0),__decorate([i({type:String})],OrRuleWebhookModal.prototype,"title",void 0),OrRuleWebhookModal=__decorate([l("or-rule-webhook-modal")],OrRuleWebhookModal);export{OrRuleWebhookModal};