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-f70621dd.js';
import { g as getAvailableTimePickerViewConfig } from './wrapper-util-2baa8a90.js';
import './apiBase-648a161d.js';
import './data-transfer-field-2f305919.js';
import './BaseField-0b01dc2c.js';
import './filter-cbaa3d7d.js';
import './FieldModelGenerator-03c7516c.js';
import './reference-field-a5b414d1.js';
import './index-61dcd269.js';
import './FieldGenerator-3ae403b2.js';
import './date-1bc489bd.js';
import './index-4e451db4.js';
import './index-32d8b974.js';
import './index-23baeeef.js';
import './index-09efdc01.js';
import './index-150b6a59.js';
import './index-5f14b4fc.js';
import './attachment-d13ad547.js';
import './data-model-f7ccf826.js';
import './membership-24db029a.js';
import './table-config-3820fb34.js';
import './string-3065a411.js';
import './User-9f1f4513.js';
import './CalendarConfig-f8d4a70d.js';
import './card-list-view-config-56edd30b.js';
import './view-config-2fc2ba10.js';
import './detail-view-config-47244869.js';
import './takvim-available-time-picker-view-config-051fa55b.js';
import './common-wrapper-util-62bbacf2.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 };
