import { Component, h, Host, Prop, State } from '@stencil/core';
import { mentornityAnnouncementsWidgetI18nDefault, MentornityAnnouncementsWidgetI18nKey } from './i18n';
export class MentornityAnnouncementsWidget {
  constructor() {
    this.showAnnouncementDetailsDialog = false;
    this.expandAnnouncementsList = false;
  }
  async componentWillLoad() {
    this.strings = await this.apiSozluk.getContent(MentornityAnnouncementsWidgetI18nKey, mentornityAnnouncementsWidgetI18nDefault);
  }
  render() {
    var _a, _b;
    const { announcements, expandAnnouncementsList, isPending, strings } = this;
    const announcementsLength = announcements === null || announcements === void 0 ? void 0 : announcements.length;
    const hasAnnouncements = announcementsLength > 0;
    if (isPending) {
      return (h(Host, null,
        h("b", { class: "pl-3", style: { fontSize: '1.1rem' } }, strings.announcements),
        h("dvn-card", { elevation: 1 },
          h("div", { class: "d-flex justify-content-center" },
            h("dvn-progress", { indefinite: true, tint: "primary" })))));
    }
    return (h(Host, null,
      h("b", { class: "pl-3", style: { fontSize: '1.1rem' } }, strings.announcements),
      h("dvn-card", { elevation: 1 },
        announcements.map((announcement, i) => {
          if (i >= 5 && !expandAnnouncementsList)
            return;
          return (h("div", null,
            h("div", { class: "announcement-content", onClick: () => {
                this.selectedAnnouncement = announcement;
                this.showAnnouncementDetailsDialog = true;
              } },
              h("h4", { class: "announcement-title" },
                " ",
                announcement.title,
                " "),
              h("dvn-icon", { "icon-name": "uil uil-angle-right-b", size: 35 })),
            announcementsLength - 1 !== i &&
              h("hr", { class: "break-line" })));
        }),
        announcementsLength > 5 && !expandAnnouncementsList &&
          h("dvn-card-footer", { class: "mt-3", slot: "footer", alignRight: true },
            h("dvn-button", { leaned: true, view: "flat", onClick: () => {
                this.expandAnnouncementsList = true;
              } }, strings.seeAll)),
        !hasAnnouncements &&
          h("div", { class: "col-md-12" },
            h("p", { class: "m-0" },
              " ",
              strings.emptyMessage,
              " ")),
        h("dvn-dialog", { title: (_a = this.selectedAnnouncement) === null || _a === void 0 ? void 0 : _a.title, shown: this.showAnnouncementDetailsDialog, onDismiss: () => this.showAnnouncementDetailsDialog = false, separateHeader: true },
          h("dvn-markdown", { content: (_b = this.selectedAnnouncement) === null || _b === void 0 ? void 0 : _b.content })))));
  }
  static get is() { return "mentornity-announcements-widget"; }
  static get originalStyleUrls() { return {
    "$": ["mentornity-announcements-widget.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["mentornity-announcements-widget.css"]
  }; }
  static get properties() { return {
    "language": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "language",
      "reflect": false
    },
    "isPending": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "is-pending",
      "reflect": false
    },
    "announcements": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "announcements",
      "reflect": false
    },
    "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": ""
      }
    }
  }; }
  static get states() { return {
    "showAnnouncementDetailsDialog": {},
    "expandAnnouncementsList": {},
    "strings": {},
    "selectedAnnouncement": {}
  }; }
}
