import { TakvimAvailabilitySettingsViewConfig } from '@dvn/takvim/views/takvim-availability-settings-view-config';
import { Component, h, Prop, State } from '@stencil/core';
import { Host } from '@stencil/core/internal';
import { generateMentornitySessionContext } from '../../util/session';
// import { getFormParameters, getFormViewConfig } from './wrapper-util';
export class MentornityAvailabilitySettingsWrapper {
  componentWillLoad() {
    const { contextParams, extraProps } = this;
    const contextParamsToUse = Object.assign({}, contextParams);
    if (extraProps === null || extraProps === void 0 ? void 0 : extraProps.userIdToManageAvailabilitiesOf) {
      contextParamsToUse.userId = extraProps.userIdToManageAvailabilitiesOf;
    }
    // fetch the context async to unblock the component render
    generateMentornitySessionContext(contextParamsToUse, { fetchMentorship: true })
      .then((mentornitySessionContext) => {
      this.mentornitySessionContext = mentornitySessionContext;
      this.view = TakvimAvailabilitySettingsViewConfig.decode({
        i18nEntryId: 'availability-settings-view',
      });
    })
      .catch(error => this.error = error);
  }
  render() {
    const { error, mentornitySessionContext, view } = this;
    if (!!error) {
      return (h("dvn-card", { leanedSides: true, tint: "danger" }, "Failed to get data."));
    }
    if (!mentornitySessionContext) {
      return (h("div", { class: "d-flex justify-content-center pt-3" },
        h("dvn-progress", { indefinite: true })));
    }
    const { apiSozluk, mentornityBridgeApi, user, userSettings } = mentornitySessionContext;
    return (h(Host, { class: "d-flex flex-column flex-grow-1", style: { overflow: 'hidden', width: '100%' } },
      h("dvn-app-view-takvim-availability-settings-view", { apiSozluk: apiSozluk, apiTakvim: mentornityBridgeApi, view: view, user: user, userSettings: userSettings })));
  }
  static get is() { return "mentornity-availability-settings-wrapper"; }
  static get properties() { return {
    "contextParams": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "MentornityContextParams",
        "resolved": "MentornityContextParams",
        "references": {
          "MentornityContextParams": {
            "location": "import",
            "path": "../../util/session"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "extraProps": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "extra-props",
      "reflect": false
    }
  }; }
  static get states() { return {
    "error": {},
    "mentornitySessionContext": {},
    "view": {}
  }; }
}
