import { r as registerInstance, e as createEvent, h } from './index-ee578edf.js';
import { S as StateOfReminder } from './utils-cc62d8e2.js';

const descriptionInputCss = ".description-container{display:flex;flex-direction:column;width:70%;height:147px;background-color:#E9EEF6;padding:20px;margin-top:3rem;margin-right:3rem;margin-bottom:1rem;border-radius:10px}.description-container-view{display:flex;flex-direction:column;width:70%;height:-webkit-min-content;height:-moz-min-content;height:min-content;background-color:white;margin-top:3rem;color:#4C4C4C;font-size:16px;font-weight:normal}.description-container:focus-within{background-color:#DFE6F1}.textarea-create{background-color:#E9EEF6;border:2px;border-radius:0;color:#4C4C4C;font-weight:bold;width:100%;height:120px;font-family:Karla, serif;white-space:nowrap;text-overflow:ellipsis;word-wrap:break-word;resize:none;overflow:hidden}.textarea-view{background-color:white;font-size:16px;border:0;border-radius:0;color:#4C4C4C;font-weight:normal;width:100%;height:auto;font-family:Karla, serif;white-space:nowrap;text-overflow:ellipsis;word-wrap:break-word;resize:none;overflow:hidden;pointer-events:none;min-height:120px}textarea:focus-within{background-color:#DFE6F1;font-weight:bold;font-family:Karla, serif}textarea:focus{outline:none !important;border-color:#839ECB}::-moz-placeholder{color:#839ECB}:-ms-input-placeholder{color:#839ECB}::placeholder{color:#839ECB}.title{color:#839ECB;font-family:Roboto, serif;font-weight:bold}.title:focus-within{color:#5D7FBA;font-weight:bold;font-family:Roboto, serif}";

const DescriptionInput = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.textEmitter = createEvent(this, "textEmitter", 7);
    this.text = '';
    this.selectionText = '';
  }
  componentWillRender() {
    this.status = this.state;
  }
  componentShouldUpdate() {
    this.status = this.state;
  }
  emitValueOfText(value) {
    if (value.inputType === 'deleteContentBackward') {
      if (this.selectionText) {
        this.textEmitter.emit({ inputType: 'deleteContentBackward', text: this.selectionText });
      }
      else {
        this.textEmitter.emit({ inputType: 'deleteContentBackward', text: '' });
      }
    }
    else {
      this.textEmitter.emit({ inputType: 'text', text: value.data });
    }
  }
  // checkForDelete(ev){
  //
  //     const key = ev.key; // const {key} = event; ES6+
  //     if (key === "Cancel" || key === "Delete") {
  //       console.log(this.text)
  //     }
  //
  // }
  render() {
    if (this.status === StateOfReminder.create) {
      return (h("div", { class: "description-container" }, h("div", { class: "title" }, "Descrizione"), h("textarea", { onInput: (value) => this.emitValueOfText(value), class: "textarea-create" })));
    }
    else if (this.status === StateOfReminder.view) {
      return (h("div", { class: "description-container-view" }, h("textarea", { class: "textarea-view" }, this.text)));
    }
    else {
      return (h("div", { class: "description-container" }, h("div", { class: "title" }, "Descrizione"), h("textarea", { id: "mytext", onInput: (value) => this.emitValueOfText(value), class: "textarea-create" }, this.text)));
    }
  }
  handleSelection() {
    if (window.getSelection) {
      this.selectionText = window.getSelection().toString();
    }
  }
};
DescriptionInput.style = descriptionInputCss;

export { DescriptionInput as description_input };
