import { r as registerInstance, h, H as Host } from './index-ecdfb761.js';
import { T as TakvimAvailableTimePickerViewConfig } from './takvim-available-time-picker-view-config-816c103b.js';
import { T as TableConfig } from './table-config-d73a72ab.js';
import { D as DvnAppViewConfig } from './view-config-1ed8c59f.js';
import { g as generateCalendarConfig } from './mentorinty-bridge-api-5ca2d652.js';
import { b as generateMentornitySessionContext, d as generateMembershipForRole } from './session-2a491341.js';
import './FieldModelGenerator-378c8613.js';
import './reference-field-a5b414d1.js';
import './BaseField-0b01dc2c.js';
import './index-61dcd269.js';
import './FieldGenerator-3ae403b2.js';
import './date-1bc489bd.js';
import './index-4e451db4.js';
import './index-23baeeef.js';
import './index-09efdc01.js';
import './index-150b6a59.js';
import './data-model-88af49fc.js';
import './apiBase-6015f41f.js';
import './data-transfer-field-2f305919.js';
import './filter-cbaa3d7d.js';
import './index-e66e8eca.js';
import './attachment-961dd228.js';
import './membership-b6639471.js';
import './string-3065a411.js';
import './User-72c4643a.js';
import './CalendarConfig-412d1b0f.js';
import './UserSettings-7e4170a7.js';
import './cookie-5d9f5819.js';
import './kimlik-api-fddeac81.js';
import './_commonjsHelpers-27f122dd.js';
import './index-d3bd30bd.js';
import './index-3bf9b308.js';
import './sozluk-entries-1e8f5234.js';
import './i18n-09a07b97.js';
import './i18n-0e757ca5.js';
import './calendar-470c802a.js';
import './index-a3ca021c.js';
import './moment-65eca6b3.js';

class TakvimDailyCalendarViewConfig extends DvnAppViewConfig {
  static decode(json) {
    const model = Object.assign(Object.create(TakvimDailyCalendarViewConfig.prototype), json);
    model.table = TableConfig.decode(model.table);
    return model;
  }
}

const MentornityHomeMessageWrapper = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    // fetch the context async to unblock the component render
    generateMentornitySessionContext(this.contextParams, { fetchConfig: true })
      .then((mentornitySessionContext) => {
      this.mentornitySessionContext = mentornitySessionContext;
      this.view = generateView(mentornitySessionContext);
      this.membership = generateMembershipForRole('admin');
    })
      .catch(error => this.error = error);
  }
  onViewMeeting(event) {
    window.dispatchEvent(new CustomEvent('dvn.mentornity-admin-calendar-view.open-meeting-page', {
      detail: {
        meetingId: event.detail._id,
      }
    }));
  }
  onAction(event) {
    const action = event.detail;
    switch (action.name) {
      case 'open-meeting-detail-after-creation':
        // dispatch event for Mentornity web-client to handle the action
        window.dispatchEvent(new CustomEvent('dvn.mentornity-admin-calendar-view.open-meeting-page', {
          detail: {
            meetingId: action.params.meetingId,
          }
        }));
        break;
    }
  }
  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 })));
    }
    return (h(Host, { class: "d-flex flex-grow-1", style: { overflow: 'hidden', background: 'var(--color-background-primary)' } }, h("mentornity-root-wrapper", null, h("dvn-app-view-takvim-daily-calendar-view", { apiData: this.mentornitySessionContext.mentornityBridgeApi, apiSozluk: this.mentornitySessionContext.apiSozluk, apiTakvim: this.mentornitySessionContext.mentornityBridgeApi, user: this.mentornitySessionContext.user, userSettings: this.mentornitySessionContext.userSettings, membership: this.membership, view: view }))));
  }
};
function generateView(mentornitySessionContext) {
  // this value can be changed to 'mentees' or 'groups' to show them in the list on the left
  const membershipConfigIdToGroupMeetings = 'mentors';
  let membershipConfigIdToViewOnMeetings = 'mentees';
  if (mentornitySessionContext.organisationConfig.menteeType === 'group') {
    membershipConfigIdToViewOnMeetings = 'groups';
  }
  return TakvimDailyCalendarViewConfig.decode({
    i18nEntryId: 'dailyCalendarView',
    table: generateCalendarConfig(mentornitySessionContext.organisationConfig),
    membershipConfigIdToGroupMeetings,
    membershipConfigIdToViewOnMeetings,
    availableTimePickerConfig: TakvimAvailableTimePickerViewConfig.decode({
      _id: 'admin-calendar-page-available-time-picker-view-wrapper',
      i18nEntryId: 'user-card-list-page-available-time-picker-view',
      table: generateCalendarConfig(mentornitySessionContext.organisationConfig),
      successNavigationAction: {
        type: 'navigation',
        direction: 'forward',
        name: 'open-meeting-detail-after-creation',
        params: {
          conversionConfig: {
            'item._id': 'meetingId',
          }
        }
      },
    }),
  });
}

export { MentornityHomeMessageWrapper as mentornity_admin_calendar_view };
