'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1ee80297.js');
const index$1 = require('./index-b2910095.js');
const kimlikApi = require('./kimlikApi-1cd43caf.js');
const dataModel = require('./data-model-c51de090.js');
const utils = require('./utils-23fe6104.js');
const User = require('./User-286a0714.js');
const UserSettings = require('./UserSettings-016122e8.js');
const dateUtils = require('./date-utils-86cd43eb.js');
const membership = require('./membership-14c44e7c.js');
const pairConfig = require('./pair-config-aa66e586.js');
const tableConfig = require('./table-config-be88299b.js');
const BaseField = require('./BaseField-d019ade6.js');
const membershipConfig = require('./membership-config-6ba394cc.js');
const CalendarConfig = require('./CalendarConfig-fed039db.js');
const appConfig = require('./app-config-e62f5843.js');
const cardListViewConfig = require('./card-list-view-config-29981c18.js');
const viewConfig = require('./view-config-c409ff28.js');
const atamaMemberPairDetailViewConfig = require('./atama-member-pair-detail-view-config-411a60c9.js');
const atamaMemberPairsOverviewViewConfig = require('./atama-member-pairs-overview-view-config-1507cd0c.js');
const Availability = require('./Availability-bea8045d.js');
require('./index-42baafa9.js');
require('./index-521d07b9.js');
require('./index-9e7c4ca0.js');
require('./index-a77c3004.js');
require('./data-transfer-field-0ce05c1a.js');
require('./filter-d5040f65.js');
require('./FieldModelGenerator-2c39c8e9.js');
require('./date-25b104f6.js');
require('./string-de672b69.js');

class Event extends dataModel.DataModel {
  static decode(json) {
    return Object.assign(Object.create(Event.prototype), json);
  }
}

class InstanceStorage {
  constructor(prefix, logger) {
    this.data = {};
    // private getData = () => JSON.parse(window.sessionStorage.getItem(this.prefix) || '{}');
    this.getData = () => this.data;
    // private setData = (data: any) => window.sessionStorage.setItem(this.prefix, JSON.stringify(data));
    this.setData = (data) => this.data = data;
    this.prefix = prefix;
    this.logger = logger.new('InstanceStorage').setColor('sun');
  }
  save(key, value) {
    this.logger.debugGroup('save', { key, value, data: this.getData() });
    const data = this.getData();
    data[key] = value;
    this.setData(data);
  }
  get(key) {
    this.logger.debugGroup('get', { key, value: this.getData()[key], data: this.getData() });
    return this.getData()[key];
  }
  remove(key) {
    this.logger.debugGroup('remove', { key, data: this.getData() });
    const data = this.getData();
    delete data[key];
    this.setData(data);
  }
  clear() {
    this.logger.debugGroup('clear', { data: this.getData() });
    this.setData({});
  }
  getAll() {
    this.logger.debugGroup('getAll', { data: this.getData() });
    return this.getData();
  }
}

class AtamaApiDemo {
  constructor(database, logger) {
    this.logger = logger.new('AtamaApiDemo').setColor('carrot');
    this.database = database;
  }
  addAuthInterceptor(token) {
    this.logger.debugGroup('addAuthInterceptor', token);
  }
  getPairsOfUser(base, collection, userRefFieldId, userRefFieldValue) {
    this.logger.debugGroup('getPairsOfUser', { base, collection, userRefFieldId, userRefFieldValue });
    const table = this.database[collection];
    if (!table) {
      this.logger.warnGroup('getPairsOfUser: table not found', { base, collection, userRefFieldId, userRefFieldValue });
      return Promise.reject(`AtamaApiDemo.getPairsOfUser: Table "${collection}" not found`);
    }
    const results = Object.keys(table).map(id => table[id]).filter(m => m[userRefFieldId][0]._id === userRefFieldValue);
    return Promise.resolve({
      results,
      meta: { total: results.length, base }
    });
  }
  // TODO make this function use the actual parameters to return this demo data
  getSelectionList(base, collection, pairConfigId, userRefFieldId, memberToViewRefFieldId) {
    this.logger.debugGroup('getSelectionList', { base, collection, pairConfigId, userRefFieldId, memberToViewRefFieldId });
    // return all mentees directly
    return Promise.resolve({
      results: Object.keys(this.database.uyeMembershipsMentors).map(id => this.database.uyeMembershipsMentors[id]),
      meta: { total: 2, base, query: {} }
    });
  }
  // TODO make this function use the actual parameters to return this demo data
  getSentRequests(base, collection, userRefFieldValue) {
    this.logger.debugGroup('getSentRequests', { base, collection, userRefFieldValue });
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          results: Object.keys(this.database.uyeMembershipsMentors)
            .map(id => this.database.uyeMembershipsMentors[id])
            .map((m, i) => dataModel.DataModel.decode({
            status: i % 2 == 0 ? 'pending' : 'rejected',
            sentTo: User.User.decode(m.user),
          })),
          meta: { total: 2 }
        });
      }, 200);
    });
  }
  // TODO make this function use the actual parameters to return this demo data
  getReceivedRequests(base, collection) {
    this.logger.debugGroup('getReceivedRequests', { base, collection });
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          results: Object.keys(this.database.uyeMembershipsMentors)
            .map(id => this.database.uyeMembershipsMentors[id])
            .map((m, i) => dataModel.DataModel.decode({
            status: i % 2 == 0 ? 'pending' : 'rejected',
            sentTo: User.User.decode(m.user),
          })),
          meta: { total: 2 }
        });
      }, 200);
    });
  }
  getMeetingsOfUser(base, collection, structureId, userRefFieldValue) {
    this.logger.debugGroup('getMeetingsOfUser', { base, collection, structureId, userRefFieldValue });
    return Promise.reject(utils.notImplemented('getMeetingsOfUser'));
  }
  endPair(base, collection, pairId) {
    // console.log(base, collection, userRefFieldId, userRefFieldValue);
    this.logger.debugGroup('endPair', { base, collection, pairId });
    return Promise.reject(utils.notImplemented('endPair'));
  }
  sendPairRequest(base, collection, userRefFieldId, userRefFieldValue, memberToViewRefFieldId, memberToViewData) {
    this.logger.debugGroup('sendPairRequest', { base, collection, userRefFieldId, userRefFieldValue, memberToViewRefFieldId, memberToViewData });
    return Promise.reject(utils.notImplemented('sendPairRequest'));
  }
  acceptPairRequest(base, collection, requestId) {
    this.logger.debugGroup('acceptPairRequest', { base, collection, requestId });
    return Promise.reject(utils.notImplemented('acceptPairRequest'));
  }
  rejectPairRequest(base, collection, requestId) {
    this.logger.debugGroup('rejectPairRequest', { base, collection, requestId });
    return Promise.reject(utils.notImplemented('rejectPairRequest'));
  }
}

class DataApiDemo {
  constructor(database, logger) {
    this.get = (collection, id, query) => {
      this.logger.debugGroup('get', { collection, id, query });
      const table = this.database[collection];
      if (!table) {
        this.logger.warnGroup('get: table not found', { collection, id, query });
        return Promise.reject(`DataApiDemo.query: Table "${collection}" not found`);
      }
      const item = table[id];
      if (!item) {
        this.logger.warnGroup('get: item not found', { collection, id, query });
        return Promise.reject(`DataApiDemo.query: Item "${item}" in "${collection}" not found`);
      }
      return Promise.resolve(item);
    };
    this.logger = logger.new('DataApiDemo').setColor('river');
    this.database = database;
  }
  addAuthInterceptor(token) {
    this.logger.debugGroup('addAuthInterceptor', token);
  }
  query(collection, query) {
    this.logger.debugGroup('query', { collection, query });
    const table = this.database[collection];
    if (!table) {
      this.logger.warnGroup('query: table not found', { collection, query });
      return Promise.reject(`DataApiDemo.query: Table "${collection}" not found`);
    }
    return Promise.resolve({
      results: Object.keys(table).map(id => table[id]).filter(m => m.config.name === collection),
      meta: { total: 2, query }
    });
  }
  update(_collection, _id, _body) {
    return Promise.reject({ status: 418 });
  }
}

function findUserWithEmail(database, email) {
  const userId = Object.keys(database.kimlikUsers).find(id => database.kimlikUsers[id].email === email);
  return database.kimlikUsers[userId];
}
class KimlikApiDemo {
  constructor(database, storage, logger) {
    this.logger = logger.new('KimlikApiDemo').setColor('emerald');
    this.storage = storage;
    this.database = database;
  }
  activateUser(email, firstName, lastName, password) {
    this.logger.debugGroup('activateUser', { email, firstName, lastName, password });
    const user = findUserWithEmail(this.database, email);
    user.status = 'active';
    user.firstName = firstName;
    user.lastName = lastName;
    // update user in database
    this.database.kimlikUsers[user._id] = user;
    this.storage.save(kimlikApi.STORAGE_KEY_KIMLIK_USER_ID, user._id);
    this.storage.save(kimlikApi.STORAGE_KEY_KIMLIK_TOKEN, `${user._id}-token`);
    return Promise.resolve({
      userId: user._id,
      jwt: `${user._id}-token`
    });
  }
  addAuthInterceptor(_token) {
    this.logger.debugGroup('addAuthInterceptor');
  }
  login(email, password) {
    if (password !== 'asdasd') {
      this.logger.errorGroup('login: password mismatch', { email, password });
      return Promise.reject(utils.unauthorized());
    }
    const user = findUserWithEmail(this.database, email);
    if (user) {
      this.storage.save(kimlikApi.STORAGE_KEY_KIMLIK_USER_ID, user._id);
      this.storage.save(kimlikApi.STORAGE_KEY_KIMLIK_TOKEN, `${user._id}-token`);
      return Promise.resolve({
        userId: user._id,
        jwt: `${user._id}-token`
      });
    }
    this.logger.warnGroup('login: user not found', { email, password });
    return Promise.reject(utils.unauthorized());
  }
  logout() {
    this.logger.debug('logout');
    this.storage.clear();
    return Promise.resolve({});
  }
  register(email, firstName, lastName, password) {
    this.logger.debugGroup('register', { email, firstName, lastName, password });
    return Promise.reject(utils.notImplemented('register'));
  }
  getSession() {
    const token = this.storage.get(kimlikApi.STORAGE_KEY_KIMLIK_TOKEN);
    this.logger.debugGroup('getSession', { token, storage: this.storage.getAll() });
    const userId = token.split('-')[0];
    const user = this.database.kimlikUsers[userId];
    if (user) {
      return Promise.resolve({ user, settings: UserSettings.UserSettings.decode({}) });
    }
    this.logger.errorGroup('getSession: user not found', { token, user });
    return Promise.reject(utils.unauthorized());
  }
}

class TakvimApiDemo {
  constructor(database, storage, logger) {
    this.logger = logger.new('TakvimApiDemo').setColor('asphalt');
    this.storage = storage;
    this.database = database;
  }
  getCalendarConfig(id) {
    const item = this.database.takvimCalendarConfigs[id];
    if (!item) {
      this.logger.warnGroup('getCalendarConfig: calendar config not found', { id });
      return Promise.reject(`TakvimApiDemo.getCalendarConfig: Calendar config "${id}" not found`);
    }
    return new Promise((resolve => {
      setTimeout(() => resolve(item), 1000);
    }));
  }
  getAvailabilities(calendarConfigId) {
    const userId = this.storage.get(kimlikApi.STORAGE_KEY_KIMLIK_USER_ID);
    const user = this.database.kimlikUsers[userId];
    if (!user) {
      this.logger.warnGroup('getAvailabilities: user not found', { userId, calendarConfigId });
      return Promise.reject(utils.notFound());
    }
    const table = this.database[calendarConfigId];
    if (!table) {
      this.logger.warnGroup('getAvailabilities: table not found', { calendarConfigId });
      return Promise.reject(`TakvimApiDemo.getAvailabilities: Table "${calendarConfigId}" not found`);
    }
    const items = Object.keys(table).map(id => table[id]);
    const results = items.filter(item => item.user._id === userId);
    this.logger.debugGroup('getAvailabilities', { calendarConfigId, results });
    return Promise.resolve({ results });
  }
  getAvailabilitiesOfUser(calendarConfigId, userId) {
    const user = this.database.kimlikUsers[userId];
    if (!user) {
      this.logger.warnGroup('getAvailabilities: user not found', { userId, calendarConfigId });
      return Promise.reject(utils.notFound());
    }
    const table = this.database.takvimAvailabilities;
    if (!table) {
      this.logger.warnGroup('getAvailabilities: table "takvimAvailabilities" not found', { calendarConfigId });
      return Promise.reject(`TakvimApiDemo.getAvailabilities: Table "takvimAvailabilities" not found`);
    }
    const items = Object.keys(table).map(id => table[id]);
    const results = items.filter(item => item.user._id === userId);
    this.logger.debugGroup('getAvailabilitiesOfUser', { calendarConfigId, results, userId });
    return Promise.resolve({ results });
  }
  getUnavailabilitiesOfUser(_calendarConfigId, userId, startTime, _endTime) {
    console.log('userId', userId);
    if (userId === 'kimlikUsers1') {
      return new Promise((resolve => {
        setTimeout(() => resolve({
          results: [
            {
              startDate: '2021-05-02T12:00:00Z',
              endDate: '2021-05-02T13:30:00Z',
              reason: {
                source: 'google-calendar',
                name: 'Family Lunch'
              }
            }
          ]
        }), 200);
      }));
    }
    const morningStart = new Date(startTime);
    morningStart.setHours(7);
    morningStart.setMinutes(0);
    const morningEnd = dateUtils.iterateMinutes(morningStart, 120);
    const noonStart = new Date(startTime);
    noonStart.setHours(12);
    noonStart.setMinutes(0);
    const noonEnd = dateUtils.iterateMinutes(noonStart, 60);
    const eveningStart = new Date(startTime);
    eveningStart.setHours(18);
    eveningStart.setMinutes(0);
    const eveningEnd = dateUtils.iterateMinutes(eveningStart, 60);
    return new Promise((resolve => {
      setTimeout(() => resolve({
        results: [
          {
            startDate: morningStart.toISOString(),
            endDate: morningEnd.toISOString(),
          },
          {
            startDate: noonStart.toISOString(),
            endDate: noonEnd.toISOString(),
          },
          {
            startDate: eveningStart.toISOString(),
            endDate: eveningEnd.toISOString(),
          },
        ]
      }), 300);
    }));
  }
  getMeetingsOfUser(calendarConfigId, guestIDs) {
    const [userId, otherGuestId] = guestIDs;
    const table = this.database.takvimEvents;
    if (!table) {
      this.logger.warnGroup('getMeetingsOfUser: table not found', { calendarConfigId, userId, otherGuestId });
      return Promise.reject(`TakvimApiDemo.getMeetingsOfUser: Table "takvimEvents" not found`);
    }
    const items = Object.keys(table).map(id => table[id]);
    const results = items.filter(item => {
      const hasUser = item.guests.some(guest => guest._id == userId);
      if (!hasUser)
        return false;
      if (!otherGuestId)
        return hasUser;
      const hasOtherUser = item.guests.some(guest => guest._id == userId);
      return hasUser && hasOtherUser;
    });
    this.logger.debugGroup('getMeetingsOfUser', { calendarConfigId, userId, otherGuestId, results });
    return Promise.resolve({ results });
  }
  createMeeting(meeting) {
    this.logger.warnGroup('createMeeting - NOT IMPLEMENTED', { meeting });
    return Promise.resolve({});
  }
}

class AgreementConsent extends dataModel.DataModel {
  static decode(json) {
    return Object.assign(Object.create(AgreementConsent.prototype), json);
  }
}

class UyeApiDemo {
  constructor(database, storage, logger) {
    this.logger = logger.new('UyeApiDemo').setColor('river');
    this.database = database;
    this.storage = storage;
  }
  getAppConfigOfMembership(id) {
    this.logger.debugGroup('getAppConfigOfMembership', id);
    for (let i = 0; i < Object.keys(this.database.dvnAppConfigs).length; i++) {
      const key = Object.keys(this.database.dvnAppConfigs)[i];
      if (this.database.dvnAppConfigs[key].membership._id === id) {
        return Promise.resolve(this.database.dvnAppConfigs[key]);
      }
    }
    this.logger.warn('getAppConfigOfMembership', 'not-found');
    return Promise.reject({ status: 404 });
  }
  addAuthInterceptor(_token) {
    this.logger.debug('addAuthInterceptor');
  }
  consentAgreement(agreementId) {
    const userId = this.storage.get(kimlikApi.STORAGE_KEY_KIMLIK_USER_ID);
    const user = this.database.kimlikUsers[userId];
    if (!user) {
      this.logger.warnGroup('consentAgreement: user not found', { userId, agreementId });
      return Promise.reject(utils.notFound());
    }
    const agreement = this.database.onayAgreements[agreementId];
    if (!agreement) {
      this.logger.warnGroup('consentAgreement: agreement not found', { userId, agreementId });
      return Promise.reject(utils.notFound());
    }
    const totalConsents = Object.keys(this.database.onayConsents).length;
    const newConsentId = `onayConsents${totalConsents + 1}`;
    const consent = AgreementConsent.decode({
      _id: newConsentId,
      _created: new Date(),
      _updated: new Date(),
      agreement,
      user,
    });
    this.database.onayConsents[newConsentId] = consent;
    return Promise.resolve(consent);
  }
  getAgreement(id) {
    return Promise.resolve(this.database.onayAgreements[id]);
  }
  activateMembership(membershipConfigId, membershipId) {
    const membershipConfig = this.database.uyeMembershipConfigs[membershipConfigId];
    if (!membershipConfig) {
      this.logger.warnGroup('getMembership: config not found', { membershipConfigId, membershipId });
      return Promise.reject(`UyeApiDemo.getMembership: Membership config "${membershipConfigId}" not found`);
    }
    const membershipsTable = this.database[membershipConfig.name];
    if (!membershipsTable) {
      this.logger.warnGroup('getMembership: table not found', { membershipConfigId, membershipId });
      return Promise.reject(`UyeApiDemo.getMembership: Memberships table "${membershipsTable}" not found`);
    }
    const keys = Object.keys(membershipsTable);
    for (let i = 0; i < keys.length; i++) {
      const key = keys[i];
      if (membershipsTable[key]._id === membershipId) {
        this.logger.debugGroup('activateMembership', {
          membership: membershipsTable[key],
          membershipConfigId,
          membershipId,
        });
        membershipsTable[key].status = 'active';
        return Promise.resolve(membershipsTable[key]);
      }
    }
    this.logger.warnGroup('getMembership: membership not found', { membershipConfigId, membershipId });
    return Promise.reject(utils.notFound());
  }
  getMembership(membershipConfigId, membershipId) {
    this.logger.debug('getMembership');
    const membershipConfig = this.database.uyeMembershipConfigs[membershipConfigId];
    if (!membershipConfig) {
      this.logger.warnGroup('getMembership: config not found', { membershipConfigId, membershipId });
      return Promise.reject(`UyeApiDemo.getMembership: Membership config "${membershipConfigId}" not found`);
    }
    const membershipsTable = this.database[membershipConfig.name];
    if (!membershipsTable) {
      this.logger.warnGroup('getMembership: table not found', { membershipConfigId, membershipId });
      return Promise.reject(`UyeApiDemo.getMembership: Memberships table "${membershipsTable}" not found`);
    }
    const keys = Object.keys(membershipsTable);
    for (let i = 0; i < keys.length; i++) {
      const key = keys[i];
      if (membershipsTable[key]._id === membershipId) {
        this.logger.debugGroup('getMembership', {
          membership: membershipsTable[key],
          membershipConfigId,
          membershipId,
        });
        return Promise.resolve(membership.Membership.decode(membershipsTable[key]));
      }
    }
    this.logger.warnGroup('getMembership: membership not found', { membershipConfigId, membershipId });
    return Promise.reject(utils.notFound());
  }
  getMembershipsOfUser(userId) {
    this.logger.debugGroup('getMembershipsOfUser', { userId });
    const ms = [];
    for (let membershipConfigId in this.database.uyeMembershipConfigs) {
      const membershipsTable = this.database[this.database.uyeMembershipConfigs[membershipConfigId].name];
      if (!membershipsTable) {
        return Promise.reject(`UyeApiDemo.getMembership: Memberships table "${membershipsTable}" not found`);
      }
      for (let membershipId in membershipsTable) {
        if (membershipsTable[membershipId].user._id === userId) {
          ms.push(membershipsTable[membershipId]);
        }
      }
    }
    return Promise.resolve({ results: ms });
  }
  getMembershipConfig(membershipConfigId) {
    const membershipConfig = this.database[membershipConfigId];
    if (!membershipConfig) {
      return Promise.reject(`UyeApiDemo.getMembership: Membership config "${membershipConfigId}" not found`);
    }
    return Promise.resolve(membershipConfig);
  }
  getMembershipConfigWithName(name) {
    const membershipConfigIds = Object.keys(this.database.uyeMembershipConfigs);
    for (let i = 0; i < membershipConfigIds.length; i++) {
      const membershipConfigId = membershipConfigIds[i];
      const membershipConfig = this.database.uyeMembershipConfigs[membershipConfigId];
      if (membershipConfig.name === name) {
        this.logger.debugGroup('getMembershipConfigWithName', { name, membershipConfig });
        return Promise.resolve(membershipConfig);
      }
    }
    this.logger.errorGroup('getMembershipConfigWithName: membership not found', { name });
    return Promise.reject(utils.notFound());
  }
  updateMembership(membershipConfigId, membershipId, data) {
    this.logger.debug('updateMembership');
    const membershipConfig = this.database.uyeMembershipConfigs[membershipConfigId];
    if (!membershipConfig) {
      this.logger.warnGroup('updateMembership: config not found', { membershipConfigId, membershipId });
      return Promise.reject(utils.notFound());
    }
    const membershipsTable = this.database[membershipConfig.name];
    if (!membershipsTable) {
      this.logger.warnGroup('updateMembership: table not found', { membershipConfigId, membershipId });
      return Promise.reject(utils.notFound());
    }
    const keys = Object.keys(membershipsTable);
    for (let i = 0; i < keys.length; i++) {
      const key = keys[i];
      if (membershipsTable[key]._id === membershipId) {
        const membership$1 = membershipsTable[key];
        this.logger.debugGroup('updateMembership', {
          membership: membership$1,
          membershipConfigId,
          membershipId,
        });
        membershipsTable[key] = membership.Membership.decode(Object.assign(Object.assign({}, membership$1), data));
        return Promise.resolve(membershipsTable[key]);
      }
    }
    this.logger.warnGroup('getMembership: membership not found', { membershipConfigId, membershipId });
    return Promise.reject(utils.notFound());
  }
}

const dvnSpaces = (config) => ({
  dvnSpaces1: tableConfig.Space.decode({
    _id: 'dvnSpaces1',
    _created: new Date(),
    _updated: new Date(),
    name: 'Hexadrop Mentorship',
    logoUrl: `${config.assetsPath}/img/spaces/hexadrop.png`,
  }),
});

const atamaMeetingStructureConfigs = (config) => ({
  atamaMeetingStructureConfigs1: pairConfig.MeetingStructureConfig.decode({
    _id: 'atamaMeetingStructureConfigs1',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    meetingConfigs: [
      {
        id: '8nn549d7c589nm3358ng',
        name: 'Introduction Meeting',
        meetingCount: 1,
      },
      {
        id: 'ca43340lann8ng',
        name: 'Career Planning',
        meetingCount: 1,
      },
      {
        id: 's3558ngac589n853ms',
        name: 'Setting Action Items',
        meetingCount: 1,
      },
      {
        id: '3val7a589n',
        name: 'Evaluation',
        meetingCount: 1,
      },
    ],
    name: 'mentoring-structure',
    space: dvnSpaces(config).dvnSpaces1,
  }),
});

const takvimCalendarConfigs = (config) => ({
  takvimCalendarConfigsBasic: CalendarConfig.CalendarConfig.decode({
    _id: 'takvimCalendarConfigsBasic',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    space: dvnSpaces(config).dvnSpaces1,
    name: 'takvimCalendarConfigsBasic',
    membershipPreferences: [
      {
        membershipConfig: membershipConfig.MembershipConfig.decode({ _id: 'mentors' }),
        canCreateAvailableTime: true,
        eligibleMembershipsForCustomTime: [
          membershipConfig.MembershipConfig.decode({ _id: 'mentees' }),
        ]
      },
      {
        membershipConfig: membershipConfig.MembershipConfig.decode({ _id: 'mentees' }),
        canCreateAvailableTime: true,
      },
    ]
  }),
});

const atamaPairConfigs = (config) => ({
  // simple pair config
  atamaPairConfigs1: pairConfig.PairConfig.decode({
    _id: 'atamaPairConfigs1',
    _created: new Date(),
    _updated: new Date(),
    actionPermissions: {
      leader: {
        completePair: true,
      }
    },
    base: 'khanguru',
    fields: [
      {
        type: 'reference',
        id: 'leader',
        otherCollection: 'uyeMembershipsMentors',
        fields: [],
        title: 'Leader',
      },
      {
        type: 'reference',
        id: 'follower',
        otherCollection: 'uyeMembershipsMentees',
        fields: [],
        title: 'Follower',
      },
      {
        id: 'status',
        title: 'Status',
        type: 'text',
      },
    ],
    name: 'atamaPairsSimplePairs',
    space: dvnSpaces(config).dvnSpaces1,
    calendarConfig: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toDBRef('takvimCalendarConfigs'),
    structure: atamaMeetingStructureConfigs(config).atamaMeetingStructureConfigs1,
  }),
  // simple pair config with selection
  atamaPairConfigs2: pairConfig.PairConfig.decode({
    _id: 'atamaPairConfigs2',
    _created: new Date(),
    _updated: new Date(),
    actionPermissions: {
      leader: {
        completePair: true,
      }
    },
    base: 'khanguru',
    fields: [
      {
        type: 'reference',
        id: 'leader',
        otherCollection: 'uyeMembershipsMentors',
        fields: [],
        title: 'Leader',
      },
      {
        type: 'reference',
        id: 'follower',
        otherCollection: 'uyeMembershipsMentees',
        fields: [],
        title: 'Follower',
      },
      {
        id: 'status',
        title: 'Status',
        type: 'text',
      },
    ],
    name: 'atamaPairsSimplePairs',
    selection: {
      follower: {
        pairLimit: 2,
        selectionLimit: 5,
        rules: [
          new pairConfig.Rule([
            {
              firstField: BaseField.BaseField.decode({ id: 'city', type: 'text' }),
              comparison: pairConfig.Comparison.eq,
              secondField: BaseField.BaseField.decode({ id: 'city', type: 'text' }),
            }
          ], pairConfig.RuleType.comparison),
        ],
        status: 'active',
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    // structure: atamaMeetingStructureConfigs(config).atamaMeetingStructureConfigs1,
  }),
  // structured pair config with selection
  atamaPairConfigs3: pairConfig.PairConfig.decode({
    _id: 'atamaPairConfigs3',
    _created: new Date(),
    _updated: new Date(),
    actionPermissions: {
      leader: {
        completePair: true,
      }
    },
    base: 'khanguru',
    fields: [
      {
        type: 'reference',
        id: 'leader',
        otherCollection: 'uyeMembershipsMentors',
        fields: [],
        title: 'Leader',
      },
      {
        type: 'reference',
        id: 'follower',
        otherCollection: 'uyeMembershipsMentees',
        fields: [],
        title: 'Follower',
      },
      {
        id: 'status',
        title: 'Status',
        type: 'text',
      },
    ],
    name: 'atamaPairsSimplePairs',
    selection: {
      follower: {
        pairLimit: 2,
        selectionLimit: 5,
        rules: [
          new pairConfig.Rule([
            {
              firstField: BaseField.BaseField.decode({ id: 'city', type: 'text' }),
              comparison: pairConfig.Comparison.eq,
              secondField: BaseField.BaseField.decode({ id: 'city', type: 'text' }),
            }
          ], pairConfig.RuleType.comparison),
        ],
        status: 'active',
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    structure: atamaMeetingStructureConfigs(config).atamaMeetingStructureConfigs1,
  }),
});

const kimlikUsers = (config) => ({
  kimlikUsers1: User.User.decode({
    _id: 'kimlikUsers1',
    _created: new Date(),
    _updated: new Date(),
    firstName: 'Emir',
    lastName: 'Turan',
    email: 'emir.turan@acme.com',
    imageUrl: `${config.assetsPath}/img/people/man-1.jpg`,
    status: 'active',
  }),
  kimlikUsers2: User.User.decode({
    _id: 'kimlikUsers2',
    _created: new Date(),
    _updated: new Date(),
    firstName: 'Ege',
    lastName: 'Can',
    email: 'user-2@khanguru.com',
    imageUrl: `${config.assetsPath}/img/people/man-2.jpg`,
    status: 'active',
  }),
  kimlikUsers3: User.User.decode({
    _id: 'kimlikUsers3',
    _created: new Date(),
    _updated: new Date(),
    firstName: 'Ellie',
    lastName: 'Max',
    email: 'ellie.max@acme.com',
    imageUrl: `${config.assetsPath}/img/people/woman-1.jpg`,
    status: 'inactive',
  }),
  kimlikUsers4: User.User.decode({
    _id: 'kimlikUsers4',
    _created: new Date(),
    _updated: new Date(),
    firstName: 'John',
    lastName: 'Alone',
    email: 'user-4@khanguru.com',
    status: 'active',
  }),
  kimlikUsers5: User.User.decode({
    _id: 'kimlikUsers5',
    _created: new Date(),
    _updated: new Date(),
    firstName: 'Sema',
    lastName: 'Melek',
    email: 'user-5@khanguru.com',
    status: 'active',
  }),
  kimlikUsers6: User.User.decode({
    _id: 'kimlikUsers6',
    _created: new Date(),
    _updated: new Date(),
    firstName: 'Christoph',
    lastName: 'Portman',
    email: 'user-6@khanguru.com',
    imageUrl: `${config.assetsPath}/img/people/man-3.jpg`,
    status: 'active',
  }),
});

class Agreement extends dataModel.DataModel {
  static decode(json) {
    return Object.assign(Object.create(Agreement.prototype), json);
  }
}

const onayAgreements = (_config) => ({
  onayAgreements1: Agreement.decode({
    _id: 'onayAgreements1',
    _created: new Date(),
    _updated: new Date(),
    content: 'Content of the **agreement 1**',
    title: 'Agreement for All Members',
  }),
  onayAgreements2: Agreement.decode({
    _id: 'onayAgreements2',
    _created: new Date(),
    _updated: new Date(),
    content: 'Content of the **agreement 2**',
    title: 'Agreement for Mentors',
  }),
  onayAgreements3: Agreement.decode({
    _id: 'onayAgreements3',
    _created: new Date(),
    _updated: new Date(),
    content: 'Content of the **agreement 3**',
    title: 'Agreement for Mentees',
  }),
});

const onayConsents = (config) => ({
  onayConsents1: AgreementConsent.decode({
    _id: 'onayConsents1',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements1.toObject(),
    user: kimlikUsers(config).kimlikUsers4.toObject(),
  }),
  onayConsents2: AgreementConsent.decode({
    _id: 'onayConsents2',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements3.toObject(),
    user: kimlikUsers(config).kimlikUsers4.toObject(),
  }),
  onayConsents3: AgreementConsent.decode({
    _id: 'onayConsents3',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements1.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
  }),
  onayConsents4: AgreementConsent.decode({
    _id: 'onayConsents4',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements2.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
  }),
  onayConsents5: AgreementConsent.decode({
    _id: 'onayConsents5',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements1.toObject(),
    user: kimlikUsers(config).kimlikUsers6.toObject(),
  }),
  onayConsents6: AgreementConsent.decode({
    _id: 'onayConsents6',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements2.toObject(),
    user: kimlikUsers(config).kimlikUsers6.toObject(),
  }),
  onayConsents7: AgreementConsent.decode({
    _id: 'onayConsents7',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements1.toObject(),
    user: kimlikUsers(config).kimlikUsers5.toObject(),
  }),
  onayConsents8: AgreementConsent.decode({
    _id: 'onayConsents8',
    _created: new Date(),
    _updated: new Date(),
    agreement: onayAgreements().onayAgreements3.toObject(),
    user: kimlikUsers(config).kimlikUsers5.toObject(),
  }),
});

// import { onayAgreements } from './onay-agreements';
const uyeMembershipConfigs = (config) => ({
  // mentees table
  uyeMembershipConfigs1: membershipConfig.MembershipConfig.decode({
    _id: 'uyeMembershipConfigs1',
    _created: new Date(),
    _updated: new Date(),
    agreements: [
    // onayAgreements(config).onayAgreements1.toObject(),
    // onayAgreements(config).onayAgreements3.toObject(),
    ],
    base: 'khanguru',
    enforceRequiredInfo: false,
    fields: [
      {
        type: 'reference',
        id: 'user',
        otherCollection: 'users',
        isSingle: true,
        fields: [
          {
            type: 'text',
            id: 'firstName'
          },
          {
            type: 'text',
            id: 'lastName'
          },
        ]
      },
      {
        id: 'city',
        required: false,
        title: 'City',
        type: 'text',
      },
      {
        id: 'bio',
        lines: 5,
        linesMax: 25,
        title: 'Bio',
        type: 'text',
      },
    ],
    name: 'uyeMembershipsMentees',
    roleName: 'mentee',
    space: dvnSpaces(config).dvnSpaces1,
  }),
  // mentors table
  uyeMembershipConfigs2: membershipConfig.MembershipConfig.decode({
    _id: 'uyeMembershipConfigs2',
    _created: new Date(),
    _updated: new Date(),
    agreements: [
    // onayAgreements(config).onayAgreements1.toObject(),
    // onayAgreements(config).onayAgreements2.toObject(),
    ],
    base: 'khanguru',
    fields: [
      {
        type: 'reference',
        id: 'user',
        otherCollection: 'users',
        isSingle: true,
        fields: [
          {
            type: 'text',
            id: 'firstName'
          },
          {
            type: 'text',
            id: 'lastName'
          },
          {
            type: 'text',
            id: 'imageUrl'
          },
        ]
      },
      {
        id: 'city',
        required: true,
        title: 'City',
        type: 'text',
      },
      {
        id: 'company',
        title: 'Company',
        type: 'text',
      },
      {
        id: 'title',
        title: 'Title',
        type: 'text',
      },
      {
        id: 'bio',
        title: 'Bio',
        type: 'text',
      },
    ],
    name: 'uyeMembershipsMentors',
    roleName: 'mentor',
    space: dvnSpaces(config).dvnSpaces1,
  }),
});

const uyeMembershipsMentees = (config) => ({
  uyeMembershipsMentees1: membership.Membership.decode({
    _id: 'uyeMembershipsMentees1',
    _created: new Date(),
    _updated: new Date(),
    config: uyeMembershipConfigs(config).uyeMembershipConfigs1.toObject(),
    consents: [],
    status: 'active',
    user: kimlikUsers(config).kimlikUsers1.toObject(),
  }),
  uyeMembershipsMentees2: membership.Membership.decode({
    _id: 'uyeMembershipsMentees2',
    _created: new Date(),
    _updated: new Date(),
    bio: 'Teeths are just coming',
    city: 'Van',
    config: uyeMembershipConfigs(config).uyeMembershipConfigs1.toObject(),
    consents: [],
    status: 'inactive',
    user: kimlikUsers(config).kimlikUsers2.toObject(),
  }),
  uyeMembershipsMentees3: membership.Membership.decode({
    _id: 'uyeMembershipsMentees3',
    _created: new Date(),
    _updated: new Date(),
    city: 'Berlin',
    config: uyeMembershipConfigs(config).uyeMembershipConfigs1.toObject(),
    consents: [],
    status: 'active',
    user: kimlikUsers(config).kimlikUsers6.toObject(),
  }),
  uyeMembershipsMentees4: membership.Membership.decode({
    _id: 'uyeMembershipsMentees4',
    _created: new Date(),
    _updated: new Date(),
    city: 'London',
    config: uyeMembershipConfigs(config).uyeMembershipConfigs1.toObject(),
    consents: [
      onayConsents(config).onayConsents1.toObject(),
      onayConsents(config).onayConsents2.toObject(),
    ],
    status: 'active',
    user: kimlikUsers(config).kimlikUsers4.toObject(),
  }),
  uyeMembershipsMentees6: membership.Membership.decode({
    _id: 'uyeMembershipsMentees6',
    _created: new Date(),
    _updated: new Date(),
    bio: 'Lived happy for a while',
    city: 'Los Angeles',
    config: uyeMembershipConfigs(config).uyeMembershipConfigs1.toObject(),
    consents: [
      onayConsents(config).onayConsents1.toObject(),
      onayConsents(config).onayConsents2.toObject(),
    ],
    status: 'active',
    user: kimlikUsers(config).kimlikUsers5.toObject(),
  }),
});

const uyeMembershipsMentors = (config) => ({
  uyeMembershipsMentors1: membership.Membership.decode({
    _id: 'uyeMembershipsMentors1',
    _created: new Date(),
    _updated: new Date(),
    city: 'Istanbul',
    company: 'Peak Games',
    title: 'Chief Design Officer',
    bio: 'Worked in different teams and companies to build beatiful and easy-to-use user interfaces.',
    config: uyeMembershipConfigs(config).uyeMembershipConfigs2.toObject(),
    consents: [
    // onayConsents(config).onayConsents3.toObject(),
    // onayConsents(config).onayConsents4.toObject(),
    ],
    status: 'inactive',
    user: kimlikUsers(config).kimlikUsers3.toObject(),
  }),
  uyeMembershipsMentors2: membership.Membership.decode({
    _id: 'uyeMembershipsMentors2',
    _created: new Date(),
    _updated: new Date(),
    company: 'GoEuro',
    title: 'Senior Software Architect',
    bio: 'Open Source enthusiast, Go geek and camper. Born and raised in Switzerland, now living in Berlin.',
    city: 'Berlin',
    config: uyeMembershipConfigs(config).uyeMembershipConfigs2.toObject(),
    consents: [
      onayConsents(config).onayConsents3.toObject(),
      onayConsents(config).onayConsents4.toObject(),
    ],
    status: 'active',
    user: kimlikUsers(config).kimlikUsers6.toObject(),
  }),
});

const atamaPairsSimplePairs = (config) => ({
  atamaPairsSimplePairs1: dataModel.DataModel.decode({
    _id: 'atamaPairsSimplePairs1',
    _created: new Date(),
    _updated: new Date(),
    follower: [
      uyeMembershipsMentees(config).uyeMembershipsMentees1.toObject()
    ],
    leader: [
      uyeMembershipsMentors(config).uyeMembershipsMentors1.toObject()
    ],
    status: 'active',
  }),
  atamaPairsSimplePairss: dataModel.DataModel.decode({
    _id: 'atamaPairsSimplePairs2',
    _created: new Date(),
    _updated: new Date(),
    follower: [
      uyeMembershipsMentees(config).uyeMembershipsMentees1.toObject()
    ],
    leader: [
      uyeMembershipsMentors(config).uyeMembershipsMentors2.toObject()
    ],
    status: 'active',
  }),
});

class TakvimAvailabilitySettingsViewConfig extends viewConfig.DvnAppViewConfig {
  static decode(json) {
    const model = Object.assign(Object.create(TakvimAvailabilitySettingsViewConfig.prototype), json);
    model.table = pairConfig.PairConfig.decode(model.table);
    return model;
  }
}

function decodeViewConfig(json) {
  if (json.type === viewConfig.AppViewType.ListViewCard) {
    return cardListViewConfig.CardListViewConfig.decode(json);
  }
  else if (json.type === viewConfig.AppViewType.PairListViewCard) {
    return cardListViewConfig.CardListViewConfig.decode(json);
  }
  else if (json.type === viewConfig.AppViewType.PairListViewCard) {
    return cardListViewConfig.CardListViewConfig.decode(json);
  }
  else if (json.type === viewConfig.AppViewType.AtamaMemberPairDetailView) {
    return atamaMemberPairDetailViewConfig.AtamaMemberPairDetailViewConfig.decode(json);
  }
  else if (json.type === viewConfig.AppViewType.AtamaMemberPairsOverviewView) {
    return atamaMemberPairsOverviewViewConfig.AtamaMemberPairsOverviewViewConfig.decode(json);
  }
  else if (json.type === viewConfig.AppViewType.TakvimAvailabilitySettingsView) {
    return TakvimAvailabilitySettingsViewConfig.decode(json);
  }
  return viewConfig.DvnAppViewConfig.decode(json);
}

const dvnViewConfigs = (config) => ({
  // all mentees card list view
  dvnViewConfigs1: decodeViewConfig({
    _id: 'dvnViewConfigs1',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {
      main: {
        cardViewConfig: {
          header: {
            title: {
              fieldId: 'user.firstName',
            },
          },
          body: {
            fields: [
              { fieldId: 'city' },
              { fieldId: 'bio' },
            ]
          }
        },
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    title: 'Mentees',
    type: 'list-view-card',
    table: uyeMembershipConfigs(config).uyeMembershipConfigs1.toObject(),
    query: {
      fields: [
        { fieldId: 'bio' },
        { fieldId: 'city' },
      ]
    },
  }),
  // all mentors card list view
  dvnViewConfigs2: decodeViewConfig({
    _id: 'dvnViewConfigs2',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {
      main: {
        cardViewConfig: {
          header: {
            title: {
              fieldId: 'user.firstName',
            },
          },
          body: {
            fields: [
              { fieldId: 'bio' },
              { fieldId: 'city' },
              { fieldId: 'company' },
              { fieldId: 'title' },
            ]
          }
        },
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    title: 'Mentors',
    type: 'list-view-card',
    table: uyeMembershipConfigs(config).uyeMembershipConfigs2.toObject(),
    query: {
      fields: [
        { fieldId: 'bio' },
        { fieldId: 'city' },
        { fieldId: 'company' },
        { fieldId: 'title' },
        { fieldId: 'user' },
      ]
    }
  }),
  // pair card list view for mentors to view mentees in simple-pairs table
  dvnViewConfigs3: decodeViewConfig({
    _id: 'dvnViewConfigs3',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {
      main: {
        cardViewConfig: {
          header: {
            title: {
              fieldId: 'user.firstName',
            },
          },
          body: {
            fields: [
              { fieldId: 'city' },
              { fieldId: 'bio' },
            ]
          },
          footer: {
            actions: [
              {
                data: {
                  type: 'navigation',
                  direction: 'forward',
                  placement: 'view',
                  viewId: 'dvnViewConfigs5',
                  params: {
                    conversionConfig: {
                      'item._id': 'memberToViewRefFieldValue',
                      'item.pairId': 'pairId',
                    }
                  }
                },
                ui: {
                  label: 'View Detail',
                  name: 'open-pair-detail-view',
                  view: 'flat'
                }
              }
            ]
          }
        },
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    title: 'My Mentees',
    type: 'atama-member-pairs-overview-view',
    table: atamaPairConfigs(config).atamaPairConfigs1.toObject(),
    params: {
      userRefFieldId: {
        required: true,
        value: 'leader'
      },
      memberToViewRefFieldId: {
        required: true,
        value: 'follower',
      }
    },
  }),
  // pair card list view for mentees to view mentors in simple-pairs table
  dvnViewConfigs4: decodeViewConfig({
    _id: 'dvnViewConfigs4',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {
      main: {
        cardViewConfig: {
          header: {
            cover: {
              //   aspectRatio: 16 / 9,
              //   fieldId: 'imageUrl',
              size: 100,
            },
            image: {
              fieldId: 'user.imageUrl',
              size: 72,
            },
            title: {
              fieldId: 'name',
            },
          },
          body: {
            fields: [
              { fieldId: 'company' },
              { fieldId: 'title', lines: 1 },
              { fieldId: 'city' },
            ]
          },
          footer: {
            actions: [
              {
                data: {
                  type: 'navigation',
                  direction: 'forward',
                  placement: 'view',
                  viewId: 'dvnViewConfigs9',
                  params: {
                    conversionConfig: {
                      'item._id': 'memberToViewRefFieldValue',
                      'item.pairId': 'pairId',
                    }
                  }
                },
                ui: {
                  label: 'View User & Meet',
                  name: 'open-pair-detail-view',
                  view: 'ghost',
                }
              }
            ]
          }
        },
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    title: 'My Mentors',
    type: 'atama-member-pairs-overview-view',
    table: atamaPairConfigs(config).atamaPairConfigs1.toObject(),
    params: {
      userRefFieldId: {
        required: true,
        value: 'follower'
      },
      memberToViewRefFieldId: {
        required: true,
        value: 'leader',
      },
      viewIdToNavigateToSelectPair: {
        required: true,
        value: 'dvnViewConfigs6',
      },
    },
  }),
  // pair detail view for mentors to view the mentee and the other details (sessions, etc)
  dvnViewConfigs5: decodeViewConfig({
    _id: 'dvnViewConfigs5',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {
      main: {
        infoSummaryCardViewConfig: {
          header: {},
          body: {
            fields: [
              { fieldId: 'city' },
            ],
          },
          footer: {}
        },
        infoDetailCardViewConfig: {
          header: {},
          body: {
            fields: [
              { fieldId: 'city' },
              { fieldId: 'bio' },
            ],
          },
          footer: {}
        },
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    title: 'Pair Details',
    type: 'atama-member-pair-detail-view',
    table: atamaPairConfigs(config).atamaPairConfigs1.toObject(),
    params: {
      userRefFieldId: {
        required: true,
        value: 'leader'
      },
      memberToViewRefFieldId: {
        required: true,
        value: 'follower',
      },
      memberToViewRefFieldValue: {
        required: true,
      },
      pairId: {
        required: true,
      },
      viewIdToNavigateOnEndPair: {
        required: true,
        value: 'dvnViewConfigs3',
      }
    },
  }),
  // selection view for mentees to select mentors in simple-pairs table
  dvnViewConfigs6: decodeViewConfig({
    _id: 'dvnViewConfigs6',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {
      main: {
        cardViewConfig: {
          header: {
            title: {
              fieldId: 'user.firstName',
            },
          },
          body: {
            fields: [
              { fieldId: 'company' },
              { fieldId: 'title' },
            ]
          },
        },
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    title: 'Select Mentors',
    type: 'atama-member-pair-selection-view',
    table: atamaPairConfigs(config).atamaPairConfigs1.toObject(),
    params: {
      userRefFieldId: {
        required: true,
        value: 'follower'
      },
      memberToViewRefFieldId: {
        required: true,
        value: 'leader',
      },
      viewIdToNavigateOnSelectionDone: {
        required: true,
        value: 'dvnViewConfigs4',
      },
    },
  }),
  // availability settings
  dvnViewConfigs7: decodeViewConfig({
    _id: 'dvnViewConfigs7',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {},
    space: dvnSpaces(config).dvnSpaces1,
    title: 'My Available Times',
    type: 'takvim-availability-settings-view',
    table: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
  }),
  // edit membership info form for mentees
  dvnViewConfigs8: decodeViewConfig({
    _id: 'dvnViewConfigs8',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {},
    space: dvnSpaces(config).dvnSpaces1,
    title: 'My Info',
    type: 'member-info-form-view',
    table: uyeMembershipConfigs(config).uyeMembershipConfigs1.toObject(),
  }),
  // pair detail view for mentees to view the mentor and the other details (sessions, etc)
  dvnViewConfigs9: decodeViewConfig({
    _id: 'dvnViewConfigs9',
    _created: new Date(),
    _updated: new Date(),
    base: 'khanguru',
    ui: {
      main: {
        infoSummaryCardViewConfig: {
          header: {},
          body: {
            fields: [
              { fieldId: 'company' },
              { fieldId: 'title' },
              { fieldId: 'city' },
            ],
          },
          footer: {}
        },
        infoDetailCardViewConfig: {
          header: {},
          body: {
            fields: [
              { fieldId: 'company' },
              { fieldId: 'title' },
              { fieldId: 'city' },
              { fieldId: 'bio' },
            ],
          },
          footer: {}
        },
      },
    },
    space: dvnSpaces(config).dvnSpaces1,
    title: 'Pair Details',
    type: 'atama-member-pair-detail-view',
    table: atamaPairConfigs(config).atamaPairConfigs1.toObject(),
    params: {
      userRefFieldId: {
        required: true,
        value: 'follower'
      },
      memberToViewRefFieldId: {
        required: true,
        value: 'leader',
      },
      memberToViewRefFieldValue: {
        required: true,
      },
      pairId: {
        required: true,
      },
      viewIdToNavigateOnEndPair: {
        required: true,
        value: 'dvnViewConfigs3',
      }
    },
  }),
});

const dvnAppConfigs = (config) => ({
  // app for mentors
  dvnAppConfigs1: appConfig.AppConfig.decode({
    _id: 'dvnAppConfigs1',
    _created: new Date(),
    _updated: new Date(),
    mainContent: {
      centered: true,
    },
    mainNavigation: {
      items: [
        {
          ui: {
            title: 'My Mentees'
          },
          viewId: 'dvnViewConfigs3', // simple pair list to view its mentees
        },
        {
          ui: {
            title: 'Mentees'
          },
          viewId: 'dvnViewConfigs1', // mentees card view list
        },
        {
          ui: {
            title: 'Mentors'
          },
          viewId: 'dvnViewConfigs2', // mentors card view list
        },
        {
          ui: {
            title: 'My Available Times'
          },
          viewId: 'dvnViewConfigs7',
        },
      ],
      centered: true
    },
    space: dvnSpaces(config).dvnSpaces1,
    membership: uyeMembershipConfigs(config).uyeMembershipConfigs2,
    views: [
      dvnViewConfigs(config).dvnViewConfigs1,
      dvnViewConfigs(config).dvnViewConfigs2,
      dvnViewConfigs(config).dvnViewConfigs3,
      dvnViewConfigs(config).dvnViewConfigs5,
      dvnViewConfigs(config).dvnViewConfigs7, // availability settings
    ],
  }),
  // app for mentees
  dvnAppConfigs2: appConfig.AppConfig.decode({
    _id: 'dvnAppConfigs2',
    _created: new Date(),
    _updated: new Date(),
    mainContent: {
      centered: true,
    },
    mainNavigation: {
      items: [
        {
          ui: {
            title: 'My Mentors'
          },
          viewId: 'dvnViewConfigs4', // simple pair list to view its mentors
        },
        {
          ui: {
            title: 'All Mentees'
          },
          viewId: 'dvnViewConfigs1', // mentees card view list
        },
        {
          ui: {
            title: 'My Info'
          },
          viewId: 'dvnViewConfigs8',
        },
      ],
      centered: true
    },
    space: dvnSpaces(config).dvnSpaces1,
    membership: uyeMembershipConfigs(config).uyeMembershipConfigs1,
    views: [
      dvnViewConfigs(config).dvnViewConfigs1,
      dvnViewConfigs(config).dvnViewConfigs4,
      dvnViewConfigs(config).dvnViewConfigs6,
      dvnViewConfigs(config).dvnViewConfigs8,
      dvnViewConfigs(config).dvnViewConfigs9, // mentor detail page
    ],
  }),
});

const takvimAvailabilities = (config) => ({
  // single day
  takvimAvailabilities1: Availability.Availability.decode({
    _id: 'takvimAvailabilities1',
    _created: new Date(),
    _updated: new Date(),
    config: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
    startDate: '2021-05-21T10:00:00Z',
    endDate: '2021-05-21T12:00:00Z',
    meetingDuration: 60,
    breakDuration: 15,
    recurrence: 'once',
  }),
  // single day
  takvimAvailabilities12: Availability.Availability.decode({
    _id: 'takvimAvailabilities1',
    _created: new Date(),
    _updated: new Date(),
    config: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
    startDate: '2021-05-02T07:00:00Z',
    endDate: '2021-05-02T20:00:00Z',
    meetingDuration: 90,
    recurrence: 'once',
  }),
  // recurring on tuesdays
  // takvimAvailabilities2: Availability.decode({
  //   _id: 'takvimAvailabilities2',
  //   _created: new Date(),
  //   _updated: new Date(),
  //   config: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
  //   user: kimlikUsers(config).kimlikUsers3.toObject(),
  //   startDate:'2021-04-01T10:00:00Z',
  //   endDate:'2021-04-01T18:00:00Z',
  //   meetingDuration: 60,
  //   recurrence: 'weekly',
  // }),
  // recurring on wednesdays
  takvimAvailabilities3: Availability.Availability.decode({
    _id: 'takvimAvailabilities3',
    _created: new Date(),
    _updated: new Date(),
    config: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
    startDate: '2021-04-02T10:00:00Z',
    endDate: '2021-04-02T12:00:00Z',
    meetingDuration: 30,
    recurrence: 'weekly',
  }),
  // recurring on wednesdays
  takvimAvailabilities4: Availability.Availability.decode({
    _id: 'takvimAvailabilities4',
    _created: new Date(),
    _updated: new Date(),
    config: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
    startDate: '2021-04-02T14:00:00Z',
    endDate: '2021-04-02T18:00:00Z',
    meetingDuration: 60,
    recurrence: 'weekly',
  }),
});

const takvimEvents = (config) => ({
  takvimEvents1: Event.decode({
    _id: 'takvimEvents1',
    _created: new Date(),
    _updated: new Date(),
    config: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
    startDate: '2021-05-21T10:00:00Z',
    endDate: '2021-05-21T12:00:00Z',
    meetingType: '8nn549d7c589nm3358ng',
    guests: [
      kimlikUsers(config).kimlikUsers1.toDBRef('kimlikUsers'),
      kimlikUsers(config).kimlikUsers3.toDBRef('kimlikUsers'),
    ],
  }),
  takvimEvents2: Event.decode({
    _id: 'takvimEvents2',
    _created: new Date(),
    _updated: new Date(),
    config: takvimCalendarConfigs(config).takvimCalendarConfigsBasic.toObject(),
    user: kimlikUsers(config).kimlikUsers3.toObject(),
    startDate: '2021-05-22T10:00:00Z',
    endDate: '2021-05-22T12:00:00Z',
    meetingType: 'ca43340lann8ng',
    guests: [
      kimlikUsers(config).kimlikUsers1.toDBRef('kimlikUsers'),
      kimlikUsers(config).kimlikUsers3.toDBRef('kimlikUsers'),
    ],
  }),
});

const demoDB = (config) => ({
  atamaMeetingStructureConfigs: atamaMeetingStructureConfigs(config),
  atamaPairConfigs: atamaPairConfigs(config),
  atamaPairsSimplePairs: atamaPairsSimplePairs(config),
  dvnAppConfigs: dvnAppConfigs(config),
  dvnSpaces: dvnSpaces(config),
  dvnViewConfigs: dvnViewConfigs(config),
  kimlikUsers: kimlikUsers(config),
  onayAgreements: onayAgreements(),
  onayConsents: onayConsents(config),
  takvimCalendarConfigs: takvimCalendarConfigs(config),
  takvimAvailabilities: takvimAvailabilities(config),
  takvimEvents: takvimEvents(config),
  uyeMembershipConfigs: uyeMembershipConfigs(config),
  uyeMembershipsMentees: uyeMembershipsMentees(config),
  uyeMembershipsMentors: uyeMembershipsMentors(config),
});

const logLevel = 'debug';
let KhanguruDemoMentorshipSpace = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.path = '/';
    this.navigate = (config) => {
      this.logger.debugGroup('navigate', {
        from: this.path,
        to: config.path,
      });
      this.path = config.path;
    };
  }
  componentWillLoad() {
    const assetsPath = index.getAssetPath(`./assets`);
    const database = JSON.parse(JSON.stringify(demoDB({ assetsPath })));
    this.logger = new index$1.Logger('KhanguruDemoMentorshipSpace').setLevel(logLevel);
    this.logger.infoGroup('componentWillLoad', { storageKey: this.storageKey });
    this.storage = new InstanceStorage(this.storageKey, this.logger);
    this.storage.save(kimlikApi.STORAGE_KEY_KIMLIK_TOKEN, 'kimlikUsers1-jwt');
    this.apiAtama = new AtamaApiDemo(database, this.logger);
    this.apiData = new DataApiDemo(database, this.logger);
    this.apiKimlik = new KimlikApiDemo(database, this.storage, this.logger);
    this.apiTakvim = new TakvimApiDemo(database, this.storage, this.logger);
    this.apiUye = new UyeApiDemo(database, this.storage, this.logger);
    this.path = this.initialPath || location.pathname;
    this.apiSozluk = new index$1.SozlukApi();
  }
  render() {
    return (index.h(index.Host, null, index.h("dvn-app-root", { apiAtama: this.apiAtama, apiData: this.apiData, apiKimlik: this.apiKimlik, apiSozluk: this.apiSozluk, apiTakvim: this.apiTakvim, apiUye: this.apiUye, navigate: this.navigate, path: this.path, logger: this.logger, storage: this.storage })));
  }
  static get assetsDirs() { return ["assets"]; }
};

exports.khanguru_demo_mentorship_space = KhanguruDemoMentorshipSpace;
