import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-ecdfb761.js';
import { a as getEmbeddedTranslation } from './mentorinty-bridge-api-5ca2d652.js';
import { g as getAvailableTimePickerViewConfig } from './wrapper-util-04b47818.js';
import './apiBase-6015f41f.js';
import './data-transfer-field-2f305919.js';
import './BaseField-0b01dc2c.js';
import './filter-cbaa3d7d.js';
import './FieldModelGenerator-378c8613.js';
import './reference-field-a5b414d1.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 './index-e66e8eca.js';
import './attachment-961dd228.js';
import './data-model-88af49fc.js';
import './membership-b6639471.js';
import './table-config-d73a72ab.js';
import './string-3065a411.js';
import './User-72c4643a.js';
import './CalendarConfig-412d1b0f.js';
import './card-list-view-config-5e6591e6.js';
import './view-config-1ed8c59f.js';
import './detail-view-config-23af2b0d.js';
import './takvim-available-time-picker-view-config-816c103b.js';
import './common-wrapper-util-e4afa19b.js';
import './models-3a85e626.js';

const mentornityScheduleMeetingButtonOnCardCss = "mentornity-schedule-meeting-button-on-card{height:326px;background:var(--color-background-secondary);padding:calc(2 * var(--spacing-unit)) 0 0 calc(3 * var(--spacing-unit));border-bottom-left-radius:var(--card-corner-radius);border-bottom-right-radius:var(--card-corner-radius)}mentornity-schedule-meeting-button-on-card .title{font-size:var(--font-size-small);margin-left:calc(1 * var(--spacing-unit));color:var(--color-text-secondary)}mentornity-schedule-meeting-button-on-card takvim-available-time-picker>dvn-card{--color-elevated-item-background:var(--color-background-secondary)}mentornity-schedule-meeting-button-on-card takvim-available-time-picker>dvn-date-picker>.calendar-container{--color-elevated-item-background:var(--color-background-secondary)}mentornity-schedule-meeting-button-on-card takvim-available-time-picker-selected-day>dvn-card{--color-elevated-item-background:var(--color-background-secondary)}";

const MentornityScheduleMeetingButtonOnCard = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.action = createEvent(this, "action", 7);
    this.shouldShow = false;
  }
  componentWillLoad() {
    this.shouldShow = isInViewport(this.el);
    // check if the component is visible periodically
    this.currentTimePositionUpdater = setInterval(() => {
      if (this.shouldShow) {
        // no need to hide already loaded component
        return;
      }
      this.shouldShow = isInViewport(this.el);
    }, 1000);
  }
  disconnectedCallback() {
    clearInterval(this.currentTimePositionUpdater);
  }
  render() {
    var _a;
    if (!this.shouldShow) {
      return (h(Host, { class: "d-flex flex-grow-1 align-items-center justify-content-center" }, h("dvn-progress", { indefinite: true, tint: "primary" })));
    }
    const { item } = this;
    const language = ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.language) || 'en';
    const { mentornityBridgeApi, apiSozluk, guestToPassToAvailableTimePickerAsCurrentUser, userSettings, membership, } = this.meta || {};
    return (h(Host, { class: "d-flex flex-column flex-grow-1" }, h("div", { class: "title" }, getEmbeddedTranslation(language, 'getMeeting').toLocaleUpperCase()), h("dvn-app-view-takvim-available-time-picker-view", { apiData: mentornityBridgeApi, apiSozluk: apiSozluk, apiTakvim: mentornityBridgeApi, apiUye: mentornityBridgeApi, user: guestToPassToAvailableTimePickerAsCurrentUser, userSettings: userSettings, membership: membership, params: {
        viewedUserMembership: item,
      }, view: getAvailableTimePickerViewConfig(mentornityBridgeApi.organisationConfig) })));
  }
  get el() { return getElement(this); }
};
function isInViewport(element) {
  const rect = element.getBoundingClientRect();
  return (rect.top >= 0 &&
    rect.left >= 0 &&
    rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
    rect.right <= (window.innerWidth || document.documentElement.clientWidth));
}
MentornityScheduleMeetingButtonOnCard.style = mentornityScheduleMeetingButtonOnCardCss;

export { MentornityScheduleMeetingButtonOnCard as mentornity_schedule_meeting_button_on_card };
