import { generateActionEmitData } from '@dvn/core/components/views/dvn-card-view/action-util';
import { InvalidationAction, NotificationAction } from '@dvn/core/models/actions';
import { takvimAvailableTimePickerI18nDefault } from '@dvn/takvim/components/takvim-available-time-picker/i18n';
import { Component, Event, h, Host, Prop, State } from '@stencil/core';
export class DvnAppViewTakvimAvailableTimePickerView {
  async componentWillLoad() {
    this.strings = await this.apiSozluk.getContent(this.view.i18nEntryId, takvimAvailableTimePickerI18nDefault);
  }
  render() {
    const { createdMeeting, membership, user, userSettings, params: { viewedUserMembershipConfig, viewedUserMembership }, strings, view, } = this;
    return (h(Host, { class: "d-block" },
      h("takvim-available-time-picker", { apiTakvim: this.apiTakvim, userId: user._id, membershipConfigId: membership.config._id, userSettings: userSettings, viewedUserId: viewedUserMembership.user._id, viewedUserMembershipConfigId: viewedUserMembershipConfig._id, calendarConfigId: view.table._id, onCreateMeeting: (e) => {
          var _a, _b;
          if (view.successNavigationAction) {
            // show go to meeting page action confirmation dialog
            this.createdMeeting = e.detail;
          }
          (_b = (_a = view.events) === null || _a === void 0 ? void 0 : _a.success) === null || _b === void 0 ? void 0 : _b.forEach(eventToEmit => {
            if (eventToEmit instanceof InvalidationAction) {
              this.invalidation.emit(eventToEmit);
            }
            if (eventToEmit instanceof NotificationAction) {
              this.notification.emit(eventToEmit);
            }
          });
        }, strings: strings, weekStartDay: userSettings.weekStartDay }),
      h("dvn-dialog", { title: strings.meetingIsScheduled, shown: !!createdMeeting, onDismiss: () => this.createdMeeting = undefined },
        h("div", { slot: "actions" },
          h("dvn-button", { view: "flat", onClick: () => this.createdMeeting = undefined }, strings.stayOnPage),
          h("dvn-button", { tint: "primary", view: "flat", onClick: () => this.action.emit(generateActionEmitData({}, this.createdMeeting, this.view.successNavigationAction)) }, strings.goToMeetingPage)))));
  }
  static get is() { return "dvn-app-view-takvim-available-time-picker-view"; }
  static get properties() { return {
    "view": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "TakvimAvailableTimePickerViewConfig",
        "resolved": "TakvimAvailableTimePickerViewConfig",
        "references": {
          "TakvimAvailableTimePickerViewConfig": {
            "location": "import",
            "path": "@dvn/takvim/views/dvn-app-view-takvim-available-time-picker-view/takvim-available-time-picker-view-config"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "params": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "TakvimAvailableTimePickerViewParams",
        "resolved": "TakvimAvailableTimePickerViewParams",
        "references": {
          "TakvimAvailableTimePickerViewParams": {
            "location": "import",
            "path": "@dvn/takvim/views/dvn-app-view-takvim-available-time-picker-view/params"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "user": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "User",
        "resolved": "User",
        "references": {
          "User": {
            "location": "import",
            "path": "@dvn/kimlik/api/models"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "userSettings": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "UserSettings",
        "resolved": "UserSettings",
        "references": {
          "UserSettings": {
            "location": "import",
            "path": "@dvn/kimlik/api/models/UserSettings"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "membership": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Membership",
        "resolved": "Membership",
        "references": {
          "Membership": {
            "location": "import",
            "path": "@dvn/core/models/membership"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiSozluk": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "SozlukApi",
        "resolved": "SozlukApi",
        "references": {
          "SozlukApi": {
            "location": "import",
            "path": "@dvn/sozluk/api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiTakvim": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "TakvimApi",
        "resolved": "TakvimApi",
        "references": {
          "TakvimApi": {
            "location": "import",
            "path": "@dvn/takvim/api/takvimApi"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiUye": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "UyeApi",
        "resolved": "UyeApi",
        "references": {
          "UyeApi": {
            "location": "import",
            "path": "@dvn/uye/api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "createdMeeting": {},
    "strings": {}
  }; }
  static get events() { return [{
      "method": "invalidation",
      "name": "invalidation",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "notification",
      "name": "notification",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "action",
      "name": "action",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
}
