import { r as registerInstance, c as createEvent, h, H as Host } from './index-625e18f4.js';

const gascoCalendarCss = ":host(.gasco-calendar){position:relative;max-width:350px;width:100%}.native-calendar{max-width:inherit;width:100%}:host(.gasco-calendar) gasco-datetime{position:absolute;left:0;right:0;top:55px;box-shadow:0px 4px 4px var(--gasco-color-medium, #999999);border-radius:0 0 15px 15px;max-width:340px;margin-inline:5px;z-index:9999}";

const GascoCalendar = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.gascoChangeValue = createEvent(this, "gascoChangeValue", 7);
    this.gascoBlur = createEvent(this, "gascoBlur", 7);
    this.gascoFocus = createEvent(this, "gascoFocus", 7);
    this.fireFocusEvents = true;
    this.hasFocus = false;
    this.showCalendar = false;
    this.inputValue = '';
    this.onFocus = (ev) => {
      this.hasFocus = true;
      if (!this.showCalendar) {
        this.showCalendar = true;
      }
      if (this.fireFocusEvents) {
        this.gascoFocus.emit(ev);
      }
    };
    this.onBlur = (ev) => {
      this.hasFocus = false;
      if (this.showCalendar) {
        this.showCalendar = false;
      }
      if (this.fireFocusEvents) {
        this.gascoBlur.emit(ev);
      }
    };
  }
  handleDatetimeReady(ev) {
    const { month, day, year } = ev.detail;
    const value = `${day}/${month}/${year}`;
    this.inputValue = value;
    this.gascoChangeValue.emit({ value });
  }
  render() {
    const { onFocus, onBlur, showCalendar, inputValue } = this;
    return (h(Host, { onBlur: onBlur, onFocus: onFocus, class: {
        ['gasco-color']: true,
        ['gasco-calendar']: true,
        ['gasco-color-primary']: true,
        'has-focus': this.hasFocus,
      } }, h("div", { class: "native-calendar", part: "native" }, h("gasco-input", { class: "input-datetime", value: inputValue, readonly: true }, h("ion-icon", { name: "calendar-number-outline", slot: "end" })), showCalendar && h("gasco-datetime", { size: "cover" }))));
  }
};
GascoCalendar.style = gascoCalendarCss;

export { GascoCalendar as gasco_calendar };
