'use strict';

const index$1 = require('./index-16c91445.js');
require('./data-model-f9df493f.js');
const appConfig = require('./app-config-9060e777.js');
const FieldModelGenerator = require('./FieldModelGenerator-61c1111e.js');
const date = require('./date-8e8ca89a.js');
const index$2 = require('./index-21b225d5.js');
const membershipConfig = require('./membership-config-79450727.js');
const User = require('./User-ed078a17.js');
const membership = require('./membership-aabb47fb.js');
const kimlikApi = require('./kimlikApi-6a581864.js');
const dataTransferField = require('./data-transfer-field-025bce2f.js');
const filter = require('./filter-52876f3c.js');
const dataApi$1 = require('./dataApi-5225d8e2.js');
const index = require('./index-6e5eb542.js');
const models = require('./models-5557deb9.js');
const index$3 = require('./index-5df9f17d.js');
const ValidatorLength = require('./ValidatorLength-06e5c6f8.js');
const formViewConfig = require('./form-view-config-ab8d951a.js');
const viewConfig$g = require('./view-config-1ef57be5.js');
const actions = require('./actions-d7eabd95.js');
const listFetchState = require('./list-fetch-state-4917b40d.js');
const attachment = require('./attachment-c2bc9126.js');
const instance = require('./instance-fbedf46d.js');
const utils = require('./utils-8a41ac3c.js');
const spaces = require('./spaces-ad9dfe8b.js');
const detailViewConfig = require('./detail-view-config-6940447f.js');
require('./index-6923d308.js');
const tableListViewConfig = require('./table-list-view-config-0f44c9af.js');
const nested = require('./nested-14baa4ef.js');

class KimlikApiMentornity {
  constructor(endpoint, headers) {
    this.api = new kimlikApi.APIBase(endpoint, headers);
  }
  activateUser(_email, _firstName, _lastName, _password) {
    return Promise.reject(utils.notImplemented('KimlikApiMentornity.activateUser'));
  }
  addAuthInterceptor(token) {
    console.log('addAuthInterceptor', token);
  }
  login(email, password) {
    return new Promise(async (resolve) => {
      const response = await this.api.post('login', { email, password });
      resolve({ userId: response.user._id, jwt: response.accessToken });
    });
  }
  logout() {
    return Promise.resolve({});
  }
  register(_email, _firstName, _lastName, _password) {
    return Promise.reject(utils.notImplemented('KimlikApiMentornity.register'));
  }
  getSession() {
    return new Promise(async (resolve) => {
      const user = await this.api.get(`users/${index.getSessionData().uid}`);
      resolve({ user: User.User.decode(user) });
    });
  }
}

const mentornityApiEndpoint = 'https://api.mentornity.com';
// export const mentornityApiEndpoint = 'http://localhost:1707';
const dataApiEndpoint = 'https://data.api.mentornity.com/prod/mentornity/';
// export const dataApiEndpoint = 'http://localhost:1003/mentornity/';

const membershipConfigs = {
  // mentees table
  'system-admins': membershipConfig.MembershipConfig.decode({
    _id: 'system-admins',
    _created: new Date(),
    _updated: new Date(),
    agreements: [],
    base: 'mentornity',
    fields: [
      {
        type: 'reference',
        id: 'user',
        otherCollection: 'users',
        isSingle: true,
        fields: [
          {
            type: 'text',
            id: 'firstName'
          },
          {
            type: 'text',
            id: 'lastName'
          },
        ]
      },
    ],
    name: 'system-admins',
    roleName: 'System Admin',
    space: spaces.spaces['mentornity'],
  }),
};

class ChangeOrganisationDomainFormHandler {
  constructor() {
    const { jwt, sessionId } = index.getCookieStorage().getAll();
    this.api = instance.createMentornityApiInstance(mentornityApiEndpoint, {
      'Authorization': `Bearer ${jwt}`,
      'Client': 'd2ViLWFkbWlu',
      'Session-Token': sessionId,
    });
  }
  onSubmit(event) {
    const { values: { domain, organisationId } } = event.detail;
    return new Promise((resolve, reject) => {
      this.api.changeOrganisationDomain({ domain, organisationId }).then(() => {
        resolve({
          events: [
            new actions.InvalidationAction(ID, ID$1),
            new actions.InvalidationAction(ID, ID$f),
            new actions.InvalidationAction(ID, ID$g),
          ],
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch(error => {
        if (error.data && error.data.message === 'domain-already-exists') {
          reject(['Domain is already used by another program.']);
          return;
        }
        reject(['Unexpected error']);
      });
    });
  }
}

const ID = 'form-view-organisation-change-domain';
const viewConfig = formViewConfig.FormViewConfig.decode({
  _id: ID,
  base: 'mentornity',
  title: 'Change Organisation Domain',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['organisations'],
  type: viewConfig$g.AppViewType.FormView,
  handler: new ChangeOrganisationDomainFormHandler(),
  ui: {
    fields: [
      // this field is passed by the parameters. this is a data holder field to pass the data to form handler
      {
        field: new dataTransferField.DataTransferField('organisationId'),
      },
      {
        field: new index$1.TextField('domain', 'New domain').addInterceptor('onSubmit', new tableListViewConfig.ValidatorRegex('[a-z0-9\-]'))
          .addInterceptor('onSubmit', new ValidatorLength.ValidatorLength(2, 100))
          .addInterceptor('onSubmit', new formViewConfig.ModifierTrimmer())
          .require(),
      },
    ],
  },
});

const ID$1 = 'detail-view-organisation';
const viewConfig$1 = detailViewConfig.DetailViewConfig.decode({
  _id: ID$1,
  base: 'mentornity',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['organisations'],
  title: 'Organisation',
  ui: {
    cardConfig: {
      header: {
        actions: [{
            ui: {
              name: 'change-domain',
              buttonType: 'button',
              label: 'Change Domain',
              scale: 'medium',
              view: 'solid'
            },
            data: {
              type: 'navigation',
              viewId: ID,
              direction: 'forward',
              placement: appConfig.ViewPlacement.Dialog,
              params: {
                conversionConfig: {
                  'item._id': 'organisationId',
                  'item.domain': 'domain',
                }
              }
            }
          }],
        cover: {
          fieldId: 'coverUrl',
          size: 256,
        },
        image: {
          fieldId: 'logoUrl',
          shape: 'rounded',
          size: 96,
          position: models.ImagePosition.Center,
        },
        title: {
          fieldId: 'title',
        },
      },
      body: {
        fields: [
          {
            fieldId: 'domain',
          },
          {
            fieldId: 'status',
          },
          {
            fieldId: 'model',
          },
          {
            fieldId: 'description',
            lines: 0,
          },
          {
            fieldId: 'createdAt',
          },
          {
            fieldId: 'webSiteUrl',
          },
          {
            fieldId: 'facebookUrl',
          },
          {
            fieldId: 'twitterUrl',
          },
          {
            fieldId: 'linkedInUrl',
          },
        ]
      },
    }
  },
  type: viewConfig$g.AppViewType.DetailView,
  params: {
    itemId: {
      required: true,
    },
  },
});

const ID$2 = 'detail-view-form-response';
const viewConfig$2 = detailViewConfig.DetailViewConfig.decode({
  _id: ID$2,
  base: 'mentornity',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['formResponses'],
  title: 'Form Response',
  ui: {
    cardConfig: {
      body: {
        fields: [
          {
            fieldId: 'createdAt',
          },
          {
            fieldDisplay: new index$1.TextField('data.phone', 'Phone'),
          },
          {
            fieldDisplay: new index$1.TextField('data.email', 'Email'),
          },
          {
            fieldDisplay: new index$1.TextField('data.fullName', 'Name'),
          },
          {
            fieldDisplay: new index$1.TextField('data.message', 'Message'),
            lines: 0,
          },
        ]
      },
    }
  },
  type: viewConfig$g.AppViewType.DetailView,
  params: {
    itemId: {
      required: true,
    },
  },
});

const ID$3 = 'detail-view-user-auth';
const viewConfig$3 = detailViewConfig.DetailViewConfig.decode({
  _id: ID$3,
  base: 'mentornity',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['auth'],
  title: 'User Auth',
  ui: {
    cardConfig: {
      body: {
        fields: [
          {
            fieldId: 'createdAt',
          },
          {
            fieldId: 'google',
          },
          {
            fieldId: 'microsoft',
          },
          {
            fieldId: 'zoom',
          },
        ]
      },
    }
  },
  query: {
    filter: {
      comparison: filter.Comparison.Eq,
      id: 'user._id',
      value: '$userId',
    },
  },
  type: viewConfig$g.AppViewType.DetailView,
  params: {
    userId: {
      required: true,
    },
  },
});

const ID$4 = 'detail-view-scheduled-job-send-email';
const viewConfig$4 = detailViewConfig.DetailViewConfig.decode({
  _id: ID$4,
  base: 'mentornity',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['scheduledjobs'],
  title: 'Send Email Job',
  ui: {
    cardConfig: {
      body: {
        fields: [
          {
            fieldId: 'name',
          },
          {
            fieldId: 'createdAt',
          },
          {
            fieldId: 'status',
          },
          {
            fieldDisplay: new date.DateField('metadata.sent', 'Sent On').setDateFormat('DD MMM YYYY, HH:mm'),
          },
          {
            fieldDisplay: new date.DateField('metadata.delivered', 'Delivered On').setDateFormat('DD MMM YYYY, HH:mm'),
          },
          {
            fieldDisplay: new date.DateField('metadata.opened', 'Opened On').setDateFormat('DD MMM YYYY, HH:mm'),
          },
          {
            fieldDisplay: new date.DateField('metadata.clicked', 'Clicked On').setDateFormat('DD MMM YYYY, HH:mm'),
          },
          {
            fieldId: 'output',
          },
          {
            fieldId: 'parameters',
          },
        ]
      },
    }
  },
  type: viewConfig$g.AppViewType.DetailView,
  params: {
    itemId: {
      required: true,
    },
  },
});

class AddOrganisationAdminFormHandler {
  constructor() {
    const { jwt, sessionId } = index.getCookieStorage().getAll();
    this.api = instance.createMentornityApiInstance(mentornityApiEndpoint, {
      'Authorization': `Bearer ${jwt}`,
      'Client': 'd2ViLWFkbWlu',
      'Session-Token': sessionId,
    });
  }
  onSubmit(event) {
    const { values: { organisationId, admin: email } } = event.detail;
    return new Promise((resolve, reject) => {
      this.api.importUser(organisationId, 'admins', {
        email,
        firstName: '',
        lastName: '',
        metadata: {},
      }).then(() => {
        resolve({
          events: [
            new actions.InvalidationAction(ID$7, ID$e),
          ],
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch(() => {
        reject(['Unexpected error']);
      });
    });
  }
}

function buildQuery(query, quickFilter) {
  let queryFilter = query ? query.filter : undefined;
  if (quickFilter) {
    if (query && query.filter) {
      queryFilter = {
        operator: 'and',
        filters: [query.filter, quickFilter]
      };
    }
    else {
      queryFilter = quickFilter;
    }
  }
  return queryFilter;
}
function generateQuickSearchFilters(quickSearch, filter$1) {
  if (!quickSearch || !filter$1) {
    return undefined;
  }
  return {
    operator: 'or',
    filters: quickSearch.fields.map(field => ({
      comparison: filter.Comparison.Contain,
      id: field.fieldId,
      value: filter$1,
    }))
  };
}
class DvnDataProvider {
  constructor(dataApi, collection, query, initialData, quickSearch) {
    this.didQuickSearchChangeAfterLastFetch = false;
    this.list = listFetchState.ListFetchState.init();
    this.collection = collection;
    this.query = query;
    this.initialData = initialData;
    this.quickSearch = quickSearch;
    this.api = dataApi;
  }
  getInitialData() {
    return this.initialData;
  }
  getData() {
    const { api, collection, query, quickSearchText } = this;
    const self = this;
    return new Promise(((resolve, reject) => {
      if (self.list.data && !this.didQuickSearchChangeAfterLastFetch) {
        // return already fetched data
        resolve(self.list.data);
        return;
      }
      const queryFilter = buildQuery(query, generateQuickSearchFilters(this.quickSearch, quickSearchText));
      api.query(collection, {
        fields: query.fields,
        filter: queryFilter,
        limit: 50,
        skip: 0,
        sort: query.sort,
      }).then(response => {
        self.list = listFetchState.ListFetchState.init().afterFetch(response);
        this.didQuickSearchChangeAfterLastFetch = false;
        resolve(self.list.data);
      }, error => {
        self.list = listFetchState.ListFetchState.init().afterFetchError(error);
        reject(error);
      });
    }));
  }
  setInitialData(initialData) {
    this.initialData = initialData;
  }
  setQuickSearchText(text) {
    this.quickSearchText = text;
    this.didQuickSearchChangeAfterLastFetch = true;
  }
  getQuickSearchText() {
    return this.quickSearchText;
  }
  isQuickSearchEnabled() {
    return !!this.quickSearch;
  }
}

const userDataProvider = (dataApi) => new DvnDataProvider(dataApi, 'users', {
  fields: [
    new index$1.TextField('email', ''),
    new index$1.TextField('firstName', ''),
    new index$1.TextField('lastName', ''),
    new index$1.TextField('status', ''),
  ],
  filter: {
    filters: [
      {
        comparison: filter.Comparison.Eq,
        id: 'status',
        value: 'active',
      },
      {
        comparison: filter.Comparison.Ne,
        id: 'lastName',
        value: '   ',
      },
      {
        comparison: filter.Comparison.Ne,
        id: 'lastName',
        value: '   ',
      },
    ],
    operator: 'and'
  },
  sort: [{ id: 'firstName', order: 1 }]
}, undefined, {
  fields: [
    { fieldId: 'email' },
    { fieldId: 'firstName' },
    { fieldId: 'lastName' },
  ]
});

const ID$5 = 'form-view-organisation-admin-add';
const config = (dataApi) => formViewConfig.FormViewConfig.decode({
  _id: ID$5,
  base: 'mentornity',
  title: 'Add New Admin',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['users'],
  type: viewConfig$g.AppViewType.FormView,
  handler: new AddOrganisationAdminFormHandler(),
  ui: {
    fields: [
      // this field is passed by the parameters. this is a data holder field to pass the data to form handler
      {
        field: new dataTransferField.DataTransferField('organisationId'),
      },
      {
        field: new index$2.SingleChoiceField('admin', '', undefined, '', 'select').setDataProvider(userDataProvider(dataApi))
          .setDataAdapter(new tableListViewConfig.DvnDataAdapter('firstName+lastName', 'email'))
          .require(),
      },
    ],
  },
  params: {
    organisationId: {
      required: true,
    },
  },
});

class RemoveOrganisationAdminFormHandler {
  constructor() {
    const { jwt, sessionId } = index.getCookieStorage().getAll();
    this.api = instance.createMentornityApiInstance(mentornityApiEndpoint, {
      'Authorization': `Bearer ${jwt}`,
      'Client': 'd2ViLWFkbWlu',
      'Session-Token': sessionId,
    });
  }
  onSubmit(event) {
    const { values: { admin: userId, organisationDomain } } = event.detail;
    return new Promise((resolve, reject) => {
      this.api.removeOrganisationAdmin(userId, {
        _roles: [`admin@${organisationDomain}`]
      }).then(() => {
        resolve({
          events: [
            new actions.InvalidationAction(ID$7, ID$e),
          ],
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch(() => {
        reject(['Unexpected error']);
      });
    });
  }
}

const ID$6 = 'form-view-organisation-admin-remove';
const config$1 = (_dataApi) => formViewConfig.FormViewConfig.decode({
  _id: ID$6,
  base: 'mentornity',
  title: 'Remove Admin',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['users'],
  type: viewConfig$g.AppViewType.FormView,
  handler: new RemoveOrganisationAdminFormHandler(),
  ui: {
    fields: [
      // this field is passed by the parameters. this is a data holder field to pass the data to form handler
      {
        field: new dataTransferField.DataTransferField('organisationDomain'),
      },
      {
        field: new index$2.SingleChoiceField('admin', '', undefined, '', 'select').setDataProvider(new DvnDataProvider(undefined, 'users', {})).setDataAdapter(new tableListViewConfig.DvnDataAdapter('firstName+lastName', '_id'))
          .disable()
          .require(),
      },
    ],
  },
  params: {
    admin: {
      required: true,
    },
    organisationDomain: {
      required: true,
    },
  },
});

const zoneConfig = [
  {
    group: 'US (Common)',
    zones: [
      { value: 'America/Puerto_Rico', name: 'Puerto Rico (Atlantic)' },
      { value: 'America/New_York', name: 'New York (Eastern)' },
      { value: 'America/Chicago', name: 'Chicago (Central)' },
      { value: 'America/Denver', name: 'Denver (Mountain)' },
      { value: 'America/Phoenix', name: 'Phoenix (MST)' },
      { value: 'America/Los_Angeles', name: 'Los Angeles (Pacific)' },
      { value: 'America/Anchorage', name: 'Anchorage (Alaska)' },
      { value: 'Pacific/Honolulu', name: 'Honolulu (Hawaii)' },
    ],
  },
  {
    group: 'America',
    zones: [
      { value: 'America/Adak', name: 'Adak' },
      { value: 'America/Anchorage', name: 'Anchorage' },
      { value: 'America/Anguilla', name: 'Anguilla' },
      { value: 'America/Antigua', name: 'Antigua' },
      { value: 'America/Araguaina', name: 'Araguaina' },
      { value: 'America/Argentina/Buenos_Aires', name: 'Argentina - Buenos Aires' },
      { value: 'America/Argentina/Catamarca', name: 'Argentina - Catamarca' },
      { value: 'America/Argentina/ComodRivadavia', name: 'Argentina - ComodRivadavia' },
      { value: 'America/Argentina/Cordoba', name: 'Argentina - Cordoba' },
      { value: 'America/Argentina/Jujuy', name: 'Argentina - Jujuy' },
      { value: 'America/Argentina/La_Rioja', name: 'Argentina - La Rioja' },
      { value: 'America/Argentina/Mendoza', name: 'Argentina - Mendoza' },
      { value: 'America/Argentina/Rio_Gallegos', name: 'Argentina - Rio Gallegos' },
      { value: 'America/Argentina/Salta', name: 'Argentina - Salta' },
      { value: 'America/Argentina/San_Juan', name: 'Argentina - San Juan' },
      { value: 'America/Argentina/San_Luis', name: 'Argentina - San Luis' },
      { value: 'America/Argentina/Tucuman', name: 'Argentina - Tucuman' },
      { value: 'America/Argentina/Ushuaia', name: 'Argentina - Ushuaia' },
      { value: 'America/Aruba', name: 'Aruba' },
      { value: 'America/Asuncion', name: 'Asuncion' },
      { value: 'America/Atikokan', name: 'Atikokan' },
      { value: 'America/Atka', name: 'Atka' },
      { value: 'America/Bahia', name: 'Bahia' },
      { value: 'America/Barbados', name: 'Barbados' },
      { value: 'America/Belem', name: 'Belem' },
      { value: 'America/Belize', name: 'Belize' },
      { value: 'America/Blanc-Sablon', name: 'Blanc-Sablon' },
      { value: 'America/Boa_Vista', name: 'Boa Vista' },
      { value: 'America/Bogota', name: 'Bogota' },
      { value: 'America/Boise', name: 'Boise' },
      { value: 'America/Buenos_Aires', name: 'Buenos Aires' },
      { value: 'America/Cambridge_Bay', name: 'Cambridge Bay' },
      { value: 'America/Campo_Grande', name: 'Campo Grande' },
      { value: 'America/Cancun', name: 'Cancun' },
      { value: 'America/Caracas', name: 'Caracas' },
      { value: 'America/Catamarca', name: 'Catamarca' },
      { value: 'America/Cayenne', name: 'Cayenne' },
      { value: 'America/Cayman', name: 'Cayman' },
      { value: 'America/Chicago', name: 'Chicago' },
      { value: 'America/Chihuahua', name: 'Chihuahua' },
      { value: 'America/Coral_Harbour', name: 'Coral Harbour' },
      { value: 'America/Cordoba', name: 'Cordoba' },
      { value: 'America/Costa_Rica', name: 'Costa Rica' },
      { value: 'America/Cuiaba', name: 'Cuiaba' },
      { value: 'America/Curacao', name: 'Curacao' },
      { value: 'America/Danmarkshavn', name: 'Danmarkshavn' },
      { value: 'America/Dawson', name: 'Dawson' },
      { value: 'America/Dawson_Creek', name: 'Dawson Creek' },
      { value: 'America/Denver', name: 'Denver' },
      { value: 'America/Detroit', name: 'Detroit' },
      { value: 'America/Dominica', name: 'Dominica' },
      { value: 'America/Edmonton', name: 'Edmonton' },
      { value: 'America/Eirunepe', name: 'Eirunepe' },
      { value: 'America/El_Salvador', name: 'El Salvador' },
      { value: 'America/Ensenada', name: 'Ensenada' },
      { value: 'America/Fortaleza', name: 'Fortaleza' },
      { value: 'America/Fort_Wayne', name: 'Fort Wayne' },
      { value: 'America/Glace_Bay', name: 'Glace Bay' },
      { value: 'America/Godthab', name: 'Godthab' },
      { value: 'America/Goose_Bay', name: 'Goose Bay' },
      { value: 'America/Grand_Turk', name: 'Grand Turk' },
      { value: 'America/Grenada', name: 'Grenada' },
      { value: 'America/Guadeloupe', name: 'Guadeloupe' },
      { value: 'America/Guatemala', name: 'Guatemala' },
      { value: 'America/Guayaquil', name: 'Guayaquil' },
      { value: 'America/Guyana', name: 'Guyana' },
      { value: 'America/Halifax', name: 'Halifax' },
      { value: 'America/Havana', name: 'Havana' },
      { value: 'America/Hermosillo', name: 'Hermosillo' },
      { value: 'America/Indiana/Indianapolis', name: 'Indiana - Indianapolis' },
      { value: 'America/Indiana/Knox', name: 'Indiana - Knox' },
      { value: 'America/Indiana/Marengo', name: 'Indiana - Marengo' },
      { value: 'America/Indiana/Petersburg', name: 'Indiana - Petersburg' },
      { value: 'America/Indiana/Tell_City', name: 'Indiana - Tell City' },
      { value: 'America/Indiana/Vevay', name: 'Indiana - Vevay' },
      { value: 'America/Indiana/Vincennes', name: 'Indiana - Vincennes' },
      { value: 'America/Indiana/Winamac', name: 'Indiana - Winamac' },
      { value: 'America/Indianapolis', name: 'Indianapolis' },
      { value: 'America/Inuvik', name: 'Inuvik' },
      { value: 'America/Iqaluit', name: 'Iqaluit' },
      { value: 'America/Jamaica', name: 'Jamaica' },
      { value: 'America/Jujuy', name: 'Jujuy' },
      { value: 'America/Juneau', name: 'Juneau' },
      { value: 'America/Kentucky/Louisville', name: 'Kentucky - Louisville' },
      { value: 'America/Kentucky/Monticello', name: 'Kentucky - Monticello' },
      { value: 'America/Knox_IN', name: 'Knox IN' },
      { value: 'America/La_Paz', name: 'La Paz' },
      { value: 'America/Lima', name: 'Lima' },
      { value: 'America/Los_Angeles', name: 'Los Angeles' },
      { value: 'America/Louisville', name: 'Louisville' },
      { value: 'America/Maceio', name: 'Maceio' },
      { value: 'America/Managua', name: 'Managua' },
      { value: 'America/Manaus', name: 'Manaus' },
      { value: 'America/Marigot', name: 'Marigot' },
      { value: 'America/Martinique', name: 'Martinique' },
      { value: 'America/Matamoros', name: 'Matamoros' },
      { value: 'America/Mazatlan', name: 'Mazatlan' },
      { value: 'America/Mendoza', name: 'Mendoza' },
      { value: 'America/Menominee', name: 'Menominee' },
      { value: 'America/Merida', name: 'Merida' },
      { value: 'America/Mexico_City', name: 'Mexico City' },
      { value: 'America/Miquelon', name: 'Miquelon' },
      { value: 'America/Moncton', name: 'Moncton' },
      { value: 'America/Monterrey', name: 'Monterrey' },
      { value: 'America/Montevideo', name: 'Montevideo' },
      { value: 'America/Montreal', name: 'Montreal' },
      { value: 'America/Montserrat', name: 'Montserrat' },
      { value: 'America/Nassau', name: 'Nassau' },
      { value: 'America/New_York', name: 'New York' },
      { value: 'America/Nipigon', name: 'Nipigon' },
      { value: 'America/Nome', name: 'Nome' },
      { value: 'America/Noronha', name: 'Noronha' },
      { value: 'America/North_Dakota/Center', name: 'North Dakota - Center' },
      { value: 'America/North_Dakota/New_Salem', name: 'North Dakota - New Salem' },
      { value: 'America/Ojinaga', name: 'Ojinaga' },
      { value: 'America/Panama', name: 'Panama' },
      { value: 'America/Pangnirtung', name: 'Pangnirtung' },
      { value: 'America/Paramaribo', name: 'Paramaribo' },
      { value: 'America/Phoenix', name: 'Phoenix' },
      { value: 'America/Port-au-Prince', name: 'Port-au-Prince' },
      { value: 'America/Porto_Acre', name: 'Porto Acre' },
      { value: 'America/Port_of_Spain', name: 'Port of Spain' },
      { value: 'America/Porto_Velho', name: 'Porto Velho' },
      { value: 'America/Puerto_Rico', name: 'Puerto Rico' },
      { value: 'America/Rainy_River', name: 'Rainy River' },
      { value: 'America/Rankin_Inlet', name: 'Rankin Inlet' },
      { value: 'America/Recife', name: 'Recife' },
      { value: 'America/Regina', name: 'Regina' },
      { value: 'America/Resolute', name: 'Resolute' },
      { value: 'America/Rio_Branco', name: 'Rio Branco' },
      { value: 'America/Rosario', name: 'Rosario' },
      { value: 'America/Santa_Isabel', name: 'Santa Isabel' },
      { value: 'America/Santarem', name: 'Santarem' },
      { value: 'America/Santiago', name: 'Santiago' },
      { value: 'America/Santo_Domingo', name: 'Santo Domingo' },
      { value: 'America/Sao_Paulo', name: 'Sao Paulo' },
      { value: 'America/Scoresbysund', name: 'Scoresbysund' },
      { value: 'America/Shiprock', name: 'Shiprock' },
      { value: 'America/St_Barthelemy', name: 'St Barthelemy' },
      { value: 'America/St_Johns', name: 'St Johns' },
      { value: 'America/St_Kitts', name: 'St Kitts' },
      { value: 'America/St_Lucia', name: 'St Lucia' },
      { value: 'America/St_Thomas', name: 'St Thomas' },
      { value: 'America/St_Vincent', name: 'St Vincent' },
      { value: 'America/Swift_Current', name: 'Swift Current' },
      { value: 'America/Tegucigalpa', name: 'Tegucigalpa' },
      { value: 'America/Thule', name: 'Thule' },
      { value: 'America/Thunder_Bay', name: 'Thunder Bay' },
      { value: 'America/Tijuana', name: 'Tijuana' },
      { value: 'America/Toronto', name: 'Toronto' },
      { value: 'America/Tortola', name: 'Tortola' },
      { value: 'America/Vancouver', name: 'Vancouver' },
      { value: 'America/Virgin', name: 'Virgin' },
      { value: 'America/Whitehorse', name: 'Whitehorse' },
      { value: 'America/Winnipeg', name: 'Winnipeg' },
      { value: 'America/Yakutat', name: 'Yakutat' },
      { value: 'America/Yellowknife', name: 'Yellowknife' },
    ],
  },
  {
    group: 'Europe',
    zones: [
      { value: 'Europe/Amsterdam', name: 'Amsterdam' },
      { value: 'Europe/Andorra', name: 'Andorra' },
      { value: 'Europe/Athens', name: 'Athens' },
      { value: 'Europe/Belfast', name: 'Belfast' },
      { value: 'Europe/Belgrade', name: 'Belgrade' },
      { value: 'Europe/Berlin', name: 'Berlin' },
      { value: 'Europe/Bratislava', name: 'Bratislava' },
      { value: 'Europe/Brussels', name: 'Brussels' },
      { value: 'Europe/Bucharest', name: 'Bucharest' },
      { value: 'Europe/Budapest', name: 'Budapest' },
      { value: 'Europe/Chisinau', name: 'Chisinau' },
      { value: 'Europe/Copenhagen', name: 'Copenhagen' },
      { value: 'Europe/Dublin', name: 'Dublin' },
      { value: 'Europe/Gibraltar', name: 'Gibraltar' },
      { value: 'Europe/Guernsey', name: 'Guernsey' },
      { value: 'Europe/Helsinki', name: 'Helsinki' },
      { value: 'Europe/Isle_of_Man', name: 'Isle of Man' },
      { value: 'Europe/Istanbul', name: 'Istanbul' },
      { value: 'Europe/Jersey', name: 'Jersey' },
      { value: 'Europe/Kaliningrad', name: 'Kaliningrad' },
      { value: 'Europe/Kiev', name: 'Kiev' },
      { value: 'Europe/Lisbon', name: 'Lisbon' },
      { value: 'Europe/Ljubljana', name: 'Ljubljana' },
      { value: 'Europe/London', name: 'London' },
      { value: 'Europe/Luxembourg', name: 'Luxembourg' },
      { value: 'Europe/Madrid', name: 'Madrid' },
      { value: 'Europe/Malta', name: 'Malta' },
      { value: 'Europe/Mariehamn', name: 'Mariehamn' },
      { value: 'Europe/Minsk', name: 'Minsk' },
      { value: 'Europe/Monaco', name: 'Monaco' },
      { value: 'Europe/Moscow', name: 'Moscow' },
      { value: 'Europe/Nicosia', name: 'Nicosia' },
      { value: 'Europe/Oslo', name: 'Oslo' },
      { value: 'Europe/Paris', name: 'Paris' },
      { value: 'Europe/Podgorica', name: 'Podgorica' },
      { value: 'Europe/Prague', name: 'Prague' },
      { value: 'Europe/Riga', name: 'Riga' },
      { value: 'Europe/Rome', name: 'Rome' },
      { value: 'Europe/Samara', name: 'Samara' },
      { value: 'Europe/San_Marino', name: 'San Marino' },
      { value: 'Europe/Sarajevo', name: 'Sarajevo' },
      { value: 'Europe/Simferopol', name: 'Simferopol' },
      { value: 'Europe/Skopje', name: 'Skopje' },
      { value: 'Europe/Sofia', name: 'Sofia' },
      { value: 'Europe/Stockholm', name: 'Stockholm' },
      { value: 'Europe/Tallinn', name: 'Tallinn' },
      { value: 'Europe/Tirane', name: 'Tirane' },
      { value: 'Europe/Tiraspol', name: 'Tiraspol' },
      { value: 'Europe/Uzhgorod', name: 'Uzhgorod' },
      { value: 'Europe/Vaduz', name: 'Vaduz' },
      { value: 'Europe/Vatican', name: 'Vatican' },
      { value: 'Europe/Vienna', name: 'Vienna' },
      { value: 'Europe/Vilnius', name: 'Vilnius' },
      { value: 'Europe/Volgograd', name: 'Volgograd' },
      { value: 'Europe/Warsaw', name: 'Warsaw' },
      { value: 'Europe/Zagreb', name: 'Zagreb' },
      { value: 'Europe/Zaporozhye', name: 'Zaporozhye' },
      { value: 'Europe/Zurich', name: 'Zurich' },
    ],
  },
  {
    group: 'Asia',
    zones: [
      { value: 'Asia/Aden', name: 'Aden' },
      { value: 'Asia/Almaty', name: 'Almaty' },
      { value: 'Asia/Amman', name: 'Amman' },
      { value: 'Asia/Anadyr', name: 'Anadyr' },
      { value: 'Asia/Aqtau', name: 'Aqtau' },
      { value: 'Asia/Aqtobe', name: 'Aqtobe' },
      { value: 'Asia/Ashgabat', name: 'Ashgabat' },
      { value: 'Asia/Ashkhabad', name: 'Ashkhabad' },
      { value: 'Asia/Baghdad', name: 'Baghdad' },
      { value: 'Asia/Bahrain', name: 'Bahrain' },
      { value: 'Asia/Baku', name: 'Baku' },
      { value: 'Asia/Bangkok', name: 'Bangkok' },
      { value: 'Asia/Beirut', name: 'Beirut' },
      { value: 'Asia/Bishkek', name: 'Bishkek' },
      { value: 'Asia/Brunei', name: 'Brunei' },
      { value: 'Asia/Calcutta', name: 'Calcutta' },
      { value: 'Asia/Choibalsan', name: 'Choibalsan' },
      { value: 'Asia/Chongqing', name: 'Chongqing' },
      { value: 'Asia/Chungking', name: 'Chungking' },
      { value: 'Asia/Colombo', name: 'Colombo' },
      { value: 'Asia/Dacca', name: 'Dacca' },
      { value: 'Asia/Damascus', name: 'Damascus' },
      { value: 'Asia/Dhaka', name: 'Dhaka' },
      { value: 'Asia/Dili', name: 'Dili' },
      { value: 'Asia/Dubai', name: 'Dubai' },
      { value: 'Asia/Dushanbe', name: 'Dushanbe' },
      { value: 'Asia/Gaza', name: 'Gaza' },
      { value: 'Asia/Harbin', name: 'Harbin' },
      { value: 'Asia/Ho_Chi_Minh', name: 'Ho Chi Minh' },
      { value: 'Asia/Hong_Kong', name: 'Hong Kong' },
      { value: 'Asia/Hovd', name: 'Hovd' },
      { value: 'Asia/Irkutsk', name: 'Irkutsk' },
      { value: 'Asia/Istanbul', name: 'Istanbul' },
      { value: 'Asia/Jakarta', name: 'Jakarta' },
      { value: 'Asia/Jayapura', name: 'Jayapura' },
      { value: 'Asia/Jerusalem', name: 'Jerusalem' },
      { value: 'Asia/Kabul', name: 'Kabul' },
      { value: 'Asia/Kamchatka', name: 'Kamchatka' },
      { value: 'Asia/Karachi', name: 'Karachi' },
      { value: 'Asia/Kashgar', name: 'Kashgar' },
      { value: 'Asia/Kathmandu', name: 'Kathmandu' },
      { value: 'Asia/Katmandu', name: 'Katmandu' },
      { value: 'Asia/Kolkata', name: 'Kolkata' },
      { value: 'Asia/Krasnoyarsk', name: 'Krasnoyarsk' },
      { value: 'Asia/Kuala_Lumpur', name: 'Kuala Lumpur' },
      { value: 'Asia/Kuching', name: 'Kuching' },
      { value: 'Asia/Kuwait', name: 'Kuwait' },
      { value: 'Asia/Macao', name: 'Macao' },
      { value: 'Asia/Macau', name: 'Macau' },
      { value: 'Asia/Magadan', name: 'Magadan' },
      { value: 'Asia/Makassar', name: 'Makassar' },
      { value: 'Asia/Manila', name: 'Manila' },
      { value: 'Asia/Muscat', name: 'Muscat' },
      { value: 'Asia/Nicosia', name: 'Nicosia' },
      { value: 'Asia/Novokuznetsk', name: 'Novokuznetsk' },
      { value: 'Asia/Novosibirsk', name: 'Novosibirsk' },
      { value: 'Asia/Omsk', name: 'Omsk' },
      { value: 'Asia/Oral', name: 'Oral' },
      { value: 'Asia/Phnom_Penh', name: 'Phnom Penh' },
      { value: 'Asia/Pontianak', name: 'Pontianak' },
      { value: 'Asia/Pyongyang', name: 'Pyongyang' },
      { value: 'Asia/Qatar', name: 'Qatar' },
      { value: 'Asia/Qyzylorda', name: 'Qyzylorda' },
      { value: 'Asia/Rangoon', name: 'Rangoon' },
      { value: 'Asia/Riyadh', name: 'Riyadh' },
      { value: 'Asia/Saigon', name: 'Saigon' },
      { value: 'Asia/Sakhalin', name: 'Sakhalin' },
      { value: 'Asia/Samarkand', name: 'Samarkand' },
      { value: 'Asia/Seoul', name: 'Seoul' },
      { value: 'Asia/Shanghai', name: 'Shanghai' },
      { value: 'Asia/Singapore', name: 'Singapore' },
      { value: 'Asia/Taipei', name: 'Taipei' },
      { value: 'Asia/Tashkent', name: 'Tashkent' },
      { value: 'Asia/Tbilisi', name: 'Tbilisi' },
      { value: 'Asia/Tehran', name: 'Tehran' },
      { value: 'Asia/Tel_Aviv', name: 'Tel Aviv' },
      { value: 'Asia/Thimbu', name: 'Thimbu' },
      { value: 'Asia/Thimphu', name: 'Thimphu' },
      { value: 'Asia/Tokyo', name: 'Tokyo' },
      { value: 'Asia/Ujung_Pandang', name: 'Ujung Pandang' },
      { value: 'Asia/Ulaanbaatar', name: 'Ulaanbaatar' },
      { value: 'Asia/Ulan_Bator', name: 'Ulan Bator' },
      { value: 'Asia/Urumqi', name: 'Urumqi' },
      { value: 'Asia/Vientiane', name: 'Vientiane' },
      { value: 'Asia/Vladivostok', name: 'Vladivostok' },
      { value: 'Asia/Yakutsk', name: 'Yakutsk' },
      { value: 'Asia/Yekaterinburg', name: 'Yekaterinburg' },
      { value: 'Asia/Yerevan', name: 'Yerevan' },
    ],
  },
  {
    group: 'Africa',
    zones: [
      { value: 'Africa/Abidjan', name: 'Abidjan' },
      { value: 'Africa/Accra', name: 'Accra' },
      { value: 'Africa/Addis_Ababa', name: 'Addis Ababa' },
      { value: 'Africa/Algiers', name: 'Algiers' },
      { value: 'Africa/Asmara', name: 'Asmara' },
      { value: 'Africa/Asmera', name: 'Asmera' },
      { value: 'Africa/Bamako', name: 'Bamako' },
      { value: 'Africa/Bangui', name: 'Bangui' },
      { value: 'Africa/Banjul', name: 'Banjul' },
      { value: 'Africa/Bissau', name: 'Bissau' },
      { value: 'Africa/Blantyre', name: 'Blantyre' },
      { value: 'Africa/Brazzaville', name: 'Brazzaville' },
      { value: 'Africa/Bujumbura', name: 'Bujumbura' },
      { value: 'Africa/Cairo', name: 'Cairo' },
      { value: 'Africa/Casablanca', name: 'Casablanca' },
      { value: 'Africa/Ceuta', name: 'Ceuta' },
      { value: 'Africa/Conakry', name: 'Conakry' },
      { value: 'Africa/Dakar', name: 'Dakar' },
      { value: 'Africa/Dar_es_Salaam', name: 'Dar es Salaam' },
      { value: 'Africa/Djibouti', name: 'Djibouti' },
      { value: 'Africa/Douala', name: 'Douala' },
      { value: 'Africa/El_Aaiun', name: 'El Aaiun' },
      { value: 'Africa/Freetown', name: 'Freetown' },
      { value: 'Africa/Gaborone', name: 'Gaborone' },
      { value: 'Africa/Harare', name: 'Harare' },
      { value: 'Africa/Johannesburg', name: 'Johannesburg' },
      { value: 'Africa/Kampala', name: 'Kampala' },
      { value: 'Africa/Khartoum', name: 'Khartoum' },
      { value: 'Africa/Kigali', name: 'Kigali' },
      { value: 'Africa/Kinshasa', name: 'Kinshasa' },
      { value: 'Africa/Lagos', name: 'Lagos' },
      { value: 'Africa/Libreville', name: 'Libreville' },
      { value: 'Africa/Lome', name: 'Lome' },
      { value: 'Africa/Luanda', name: 'Luanda' },
      { value: 'Africa/Lubumbashi', name: 'Lubumbashi' },
      { value: 'Africa/Lusaka', name: 'Lusaka' },
      { value: 'Africa/Malabo', name: 'Malabo' },
      { value: 'Africa/Maputo', name: 'Maputo' },
      { value: 'Africa/Maseru', name: 'Maseru' },
      { value: 'Africa/Mbabane', name: 'Mbabane' },
      { value: 'Africa/Mogadishu', name: 'Mogadishu' },
      { value: 'Africa/Monrovia', name: 'Monrovia' },
      { value: 'Africa/Nairobi', name: 'Nairobi' },
      { value: 'Africa/Ndjamena', name: 'Ndjamena' },
      { value: 'Africa/Niamey', name: 'Niamey' },
      { value: 'Africa/Nouakchott', name: 'Nouakchott' },
      { value: 'Africa/Ouagadougou', name: 'Ouagadougou' },
      { value: 'Africa/Porto-Novo', name: 'Porto-Novo' },
      { value: 'Africa/Sao_Tome', name: 'Sao Tome' },
      { value: 'Africa/Timbuktu', name: 'Timbuktu' },
      { value: 'Africa/Tripoli', name: 'Tripoli' },
      { value: 'Africa/Tunis', name: 'Tunis' },
      { value: 'Africa/Windhoek', name: 'Windhoek' },
    ],
  },
  {
    group: 'Australia',
    zones: [
      { value: 'Australia/ACT', name: 'ACT' },
      { value: 'Australia/Adelaide', name: 'Adelaide' },
      { value: 'Australia/Brisbane', name: 'Brisbane' },
      { value: 'Australia/Broken_Hill', name: 'Broken Hill' },
      { value: 'Australia/Canberra', name: 'Canberra' },
      { value: 'Australia/Currie', name: 'Currie' },
      { value: 'Australia/Darwin', name: 'Darwin' },
      { value: 'Australia/Eucla', name: 'Eucla' },
      { value: 'Australia/Hobart', name: 'Hobart' },
      { value: 'Australia/LHI', name: 'LHI' },
      { value: 'Australia/Lindeman', name: 'Lindeman' },
      { value: 'Australia/Lord_Howe', name: 'Lord Howe' },
      { value: 'Australia/Melbourne', name: 'Melbourne' },
      { value: 'Australia/North', name: 'North' },
      { value: 'Australia/NSW', name: 'NSW' },
      { value: 'Australia/Perth', name: 'Perth' },
      { value: 'Australia/Queensland', name: 'Queensland' },
      { value: 'Australia/South', name: 'South' },
      { value: 'Australia/Sydney', name: 'Sydney' },
      { value: 'Australia/Tasmania', name: 'Tasmania' },
      { value: 'Australia/Victoria', name: 'Victoria' },
      { value: 'Australia/West', name: 'West' },
      { value: 'Australia/Yancowinna', name: 'Yancowinna' },
    ],
  },
  {
    group: 'Indian',
    zones: [
      { value: 'Indian/Antananarivo', name: 'Antananarivo' },
      { value: 'Indian/Chagos', name: 'Chagos' },
      { value: 'Indian/Christmas', name: 'Christmas' },
      { value: 'Indian/Cocos', name: 'Cocos' },
      { value: 'Indian/Comoro', name: 'Comoro' },
      { value: 'Indian/Kerguelen', name: 'Kerguelen' },
      { value: 'Indian/Mahe', name: 'Mahe' },
      { value: 'Indian/Maldives', name: 'Maldives' },
      { value: 'Indian/Mauritius', name: 'Mauritius' },
      { value: 'Indian/Mayotte', name: 'Mayotte' },
      { value: 'Indian/Reunion', name: 'Reunion' },
    ],
  },
  {
    group: 'Atlantic',
    zones: [
      { value: 'Atlantic/Azores', name: 'Azores' },
      { value: 'Atlantic/Bermuda', name: 'Bermuda' },
      { value: 'Atlantic/Canary', name: 'Canary' },
      { value: 'Atlantic/Cape_Verde', name: 'Cape Verde' },
      { value: 'Atlantic/Faeroe', name: 'Faeroe' },
      { value: 'Atlantic/Faroe', name: 'Faroe' },
      { value: 'Atlantic/Jan_Mayen', name: 'Jan Mayen' },
      { value: 'Atlantic/Madeira', name: 'Madeira' },
      { value: 'Atlantic/Reykjavik', name: 'Reykjavik' },
      { value: 'Atlantic/South_Georgia', name: 'South Georgia' },
      { value: 'Atlantic/Stanley', name: 'Stanley' },
      { value: 'Atlantic/St_Helena', name: 'St Helena' },
    ],
  },
  {
    group: 'Pacific',
    zones: [
      { value: 'Pacific/Apia', name: 'Apia' },
      { value: 'Pacific/Auckland', name: 'Auckland' },
      { value: 'Pacific/Chatham', name: 'Chatham' },
      { value: 'Pacific/Easter', name: 'Easter' },
      { value: 'Pacific/Efate', name: 'Efate' },
      { value: 'Pacific/Enderbury', name: 'Enderbury' },
      { value: 'Pacific/Fakaofo', name: 'Fakaofo' },
      { value: 'Pacific/Fiji', name: 'Fiji' },
      { value: 'Pacific/Funafuti', name: 'Funafuti' },
      { value: 'Pacific/Galapagos', name: 'Galapagos' },
      { value: 'Pacific/Gambier', name: 'Gambier' },
      { value: 'Pacific/Guadalcanal', name: 'Guadalcanal' },
      { value: 'Pacific/Guam', name: 'Guam' },
      { value: 'Pacific/Honolulu', name: 'Honolulu' },
      { value: 'Pacific/Johnston', name: 'Johnston' },
      { value: 'Pacific/Kiritimati', name: 'Kiritimati' },
      { value: 'Pacific/Kosrae', name: 'Kosrae' },
      { value: 'Pacific/Kwajalein', name: 'Kwajalein' },
      { value: 'Pacific/Majuro', name: 'Majuro' },
      { value: 'Pacific/Marquesas', name: 'Marquesas' },
      { value: 'Pacific/Midway', name: 'Midway' },
      { value: 'Pacific/Nauru', name: 'Nauru' },
      { value: 'Pacific/Niue', name: 'Niue' },
      { value: 'Pacific/Norfolk', name: 'Norfolk' },
      { value: 'Pacific/Noumea', name: 'Noumea' },
      { value: 'Pacific/Pago_Pago', name: 'Pago Pago' },
      { value: 'Pacific/Palau', name: 'Palau' },
      { value: 'Pacific/Pitcairn', name: 'Pitcairn' },
      { value: 'Pacific/Ponape', name: 'Ponape' },
      { value: 'Pacific/Port_Moresby', name: 'Port Moresby' },
      { value: 'Pacific/Rarotonga', name: 'Rarotonga' },
      { value: 'Pacific/Saipan', name: 'Saipan' },
      { value: 'Pacific/Samoa', name: 'Samoa' },
      { value: 'Pacific/Tahiti', name: 'Tahiti' },
      { value: 'Pacific/Tarawa', name: 'Tarawa' },
      { value: 'Pacific/Tongatapu', name: 'Tongatapu' },
      { value: 'Pacific/Truk', name: 'Truk' },
      { value: 'Pacific/Wake', name: 'Wake' },
      { value: 'Pacific/Wallis', name: 'Wallis' },
      { value: 'Pacific/Yap', name: 'Yap' },
    ],
  },
  {
    group: 'Antarctica',
    zones: [
      { value: 'Antarctica/Casey', name: 'Casey' },
      { value: 'Antarctica/Davis', name: 'Davis' },
      { value: 'Antarctica/DumontDUrville', name: 'DumontDUrville' },
      { value: 'Antarctica/Macquarie', name: 'Macquarie' },
      { value: 'Antarctica/Mawson', name: 'Mawson' },
      { value: 'Antarctica/McMurdo', name: 'McMurdo' },
      { value: 'Antarctica/Palmer', name: 'Palmer' },
      { value: 'Antarctica/Rothera', name: 'Rothera' },
      { value: 'Antarctica/South_Pole', name: 'South Pole' },
      { value: 'Antarctica/Syowa', name: 'Syowa' },
      { value: 'Antarctica/Vostok', name: 'Vostok' },
    ],
  },
  {
    group: 'Arctic',
    zones: [
      { value: 'Arctic/Longyearbyen', name: 'Longyearbyen' },
    ],
  },
];

class DvnDataProviderTimeZone extends DvnDataProvider {
  constructor() {
    super(undefined, undefined, undefined);
    this.options = [];
    this.filteredOptions = [];
    this.searchText = '';
    zoneConfig.forEach(group => {
      group.zones.forEach(zone => {
        this.options.push({
          label: `${zone.name} (${zone.value})`,
          value: zone.value,
        });
      });
    });
    this.filteredOptions = this.options;
  }
  getInitialData() {
    return this.options;
  }
  getData() {
    return Promise.resolve(this.filteredOptions);
  }
  setQuickSearchText(text) {
    this.searchText = text;
    if (text) {
      this.filteredOptions = this.options.filter(option => (option.label.toLocaleLowerCase().includes(text.toLocaleLowerCase())));
    }
    else {
      this.filteredOptions = this.options;
    }
  }
  getQuickSearchText() {
    return this.searchText;
  }
  isQuickSearchEnabled() {
    return true;
  }
}

class CreateOrganisationFormHandler {
  constructor() {
    const { jwt, sessionId } = index.getCookieStorage().getAll();
    this.api = instance.createMentornityApiInstance(mentornityApiEndpoint, {
      'Authorization': `Bearer ${jwt}`,
      'Client': 'd2ViLWFkbWlu',
      'Session-Token': sessionId,
    });
  }
  onSubmit(event) {
    const { values: { admin, sourceOrganisationId, newOrganisationDomain, newOrganisationTitle, timeZone, } } = event.detail;
    return new Promise((resolve, reject) => {
      this.api.cloneOrganisation({
        sourceOrganisationId,
        newOrganisationDomain,
        newOrganisationTitle,
        adminIds: [admin],
        timeZone,
      }).then(() => {
        resolve({
          events: [
            new actions.InvalidationAction(ID$7, ID$f),
            new actions.InvalidationAction(ID$7, ID$g),
          ],
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch(error => {
        if (error.data && error.data.message === 'domain-already-exists') {
          reject(['Domain is already used by another program.']);
          return;
        }
        reject(['Unexpected error']);
      });
    });
  }
}

const ID$7 = 'form-view-organisation-create';
const config$2 = (dataApi) => formViewConfig.FormViewConfig.decode({
  _id: ID$7,
  base: 'mentornity',
  title: 'Create Organisation',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['organisations'],
  type: viewConfig$g.AppViewType.FormView,
  handler: new CreateOrganisationFormHandler(),
  ui: {
    fields: [
      {
        field: new index$2.SingleChoiceField('sourceOrganisationId', 'Program to clone', undefined, 'Search for a template or another program to clone.', 'select').setDataProvider(new DvnDataProvider(dataApi, 'organisations', {
          fields: [
            new index$1.TextField('domain', 'Domain'),
            new index$1.TextField('title', 'Title'),
          ],
          sort: [{ id: 'title', order: 1 }]
        }, undefined, {
          fields: [
            { fieldId: 'domain' },
            { fieldId: 'title' },
          ]
        })).setDataAdapter(new tableListViewConfig.DvnDataAdapter('title', '_id'))
          .require(),
      },
      {
        field: new index$2.SingleChoiceField('admin', 'Admin', undefined, 'Search and select admins.', 'select').setDataProvider(userDataProvider(dataApi))
          .setDataAdapter(new tableListViewConfig.DvnDataAdapter('firstName+lastName', '_id'))
          .require(),
      },
      {
        field: new index$2.SingleChoiceField('timeZone', 'Time Zone', undefined, 'Time zone of the program. Original program\'s time zone is used if empty.', 'select').setDataProvider(new DvnDataProviderTimeZone())
          .setDataAdapter(new tableListViewConfig.DvnDataAdapter('label', 'value')),
      },
      {
        field: new index$1.TextField('newOrganisationTitle', 'Program name', '', 'Shown to users in the UI, emails and notifications.').addInterceptor('onBlur', new ValidatorLength.ValidatorLength(2, 100))
          .addInterceptor('onSubmit', new formViewConfig.ModifierTrimmer())
          .require(),
      },
      {
        field: new index$1.TextField('newOrganisationDomain', 'Program domain', '', 'Used in the url and visible in browser address bar.').addInterceptor('onBlur', new tableListViewConfig.ValidatorRegex('[a-z0-9\-]'))
          .addInterceptor('onBlur', new ValidatorLength.ValidatorLength(2, 100))
          .addInterceptor('onSubmit', new formViewConfig.ModifierTrimmer())
          .require(),
      },
    ],
  }
});

class EditOrganisationConfigFormHandler {
  constructor() {
    const { jwt, sessionId } = index.getCookieStorage().getAll();
    this.api = instance.createMentornityApiInstance(mentornityApiEndpoint, {
      'Authorization': `Bearer ${jwt}`,
      'Client': 'd2ViLWFkbWlu',
      'Session-Token': sessionId,
    });
  }
  onSubmit(event) {
    const { values } = event.detail;
    const { item, membershipForm, pairOverviewAndDetail } = values;
    return new Promise((resolve, reject) => {
      this.api.update('configs', item._id, {
        webAppConfiguration: {
          membershipForm, pairOverviewAndDetail
        }
      }).then(() => {
        resolve({
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch(() => {
        reject(['Unexpected error']);
      });
    });
  }
}

const ID$8 = 'form-view-organisation-config-edit';
const viewConfig$5 = formViewConfig.FormViewConfig.decode({
  _id: ID$8,
  base: 'mentornity',
  title: 'Edit Configuration',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['configs'],
  type: viewConfig$g.AppViewType.FormView,
  handler: new EditOrganisationConfigFormHandler(),
  ui: {
    fields: [
      // this field is passed by the parameters. this is a data holder field to pass the data to form handler
      {
        field: new dataTransferField.DataTransferField('item'),
      },
      {
        field: new index$3.BooleanField('membershipForm', 'Membership Form', `Shows "My Info" item on the left menu which opens a form page for editing profile, metadata and mentorship in a single form.`),
      },
      {
        field: new index$3.BooleanField('pairOverviewAndDetail', 'Pair Overview and Detail', 'Shows new mentors/mentees and mentor selection page.'),
      },
    ],
  },
  query: {
    fields: [
      new dataTransferField.DataTransferField('webAppConfiguration'),
    ],
    filter: {
      comparison: filter.Comparison.Eq,
      id: 'organisation._id',
      value: '$itemId',
    },
  },
  conversionConfig: {
    'item.webAppConfiguration.membershipForm': 'membershipForm',
    'item.webAppConfiguration.pairOverviewAndDetail': 'pairOverviewAndDetail'
  },
  params: {
    itemId: {
      required: true,
    },
  },
});

const ID$9 = 'table-list-view-form-response-contact';
const formTableListViewUIConfig = tableListViewConfig.TableListViewConfig.decode({
  main: {
    actions: [{
        ui: {
          name: 'expand',
          buttonType: 'icon-button',
          iconName: 'uil uil-expand-alt',
          view: 'flat'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.SideModal,
          viewId: ID$2,
          params: {
            conversionConfig: {
              'item._id': 'itemId',
            }
          }
        }
      }],
    fields: [
      {
        fieldId: 'createdAt',
        fieldDisplay: new date.DateField('createdAt', 'Date').setDateFormat('DD MMM HH:mm').setDataType(date.DateDataType.Unix),
      },
      {
        fieldId: 'data.phone',
        fieldDisplay: new nested.NestedField('data.phone', new index$1.TextField('phone', 'Phone')),
      },
      {
        fieldId: 'data.email',
        fieldDisplay: new nested.NestedField('data.email', new index$1.TextField('email', 'Email')),
      },
      {
        fieldId: 'data.fullName',
        fieldDisplay: new nested.NestedField('data.fullName', new index$1.TextField('fullName', 'Name')),
      },
      {
        fieldId: 'data.message',
        fieldDisplay: new nested.NestedField('data.message', new index$1.TextField('message', 'Message')),
      },
    ],
    columns: {
      createdAt: {
        width: 150,
      },
      'data.phone': {
        width: 200,
      },
      'data.email': {
        width: 200,
      },
      'data.fullName': {
        width: 200,
      },
      'data.message': {
        weight: 1,
      },
    },
  },
  quickSearch: {
    fields: [
      { field: new index$1.TextField('data.fullName', 'Name') },
      { field: new index$1.TextField('data.email', 'Email') },
      { field: new index$1.TextField('data.message', 'Message') },
    ]
  },
});
const viewConfig$6 = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$9,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Contact Forms',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['formResponses'],
  query: {
    fields: [
      new date.DateField('createdAt', 'Created At'),
      new index$1.TextField('data', 'Data'),
      new index$1.TextField('type', 'type'),
    ],
    filter: {
      filters: [
        {
          comparison: filter.Comparison.Eq,
          id: 'type',
          value: 'contact',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: formTableListViewUIConfig,
});

const ID$a = 'table-list-view-form-response-help';
const viewConfig$7 = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$a,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Help Forms',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['formResponses'],
  query: {
    fields: [
      new date.DateField('createdAt', 'Created At'),
      new index$1.TextField('data', 'Data'),
      new index$1.TextField('type', 'type'),
    ],
    filter: {
      filters: [
        {
          comparison: filter.Comparison.Eq,
          id: 'type',
          value: 'help',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: formTableListViewUIConfig,
});

const ID$b = 'table-list-view-scheduled-job-sync-events-google';
const config$3 = (dataApi) => tableListViewConfig.TableListViewConfig.decode({
  _id: ID$b,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Sync Google Events Jobs',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['scheduledjobs'],
  query: {
    fields: [
      new index$1.TextField('name', 'Name'),
      new index$1.TextField('status', 'Status'),
      new date.DateField('scheduledAt', 'Created At'),
      new date.DateField('createdAt', 'Created At'),
      new dataTransferField.DataTransferField('parameters'),
      new dataTransferField.DataTransferField('metadata'),
    ],
    filter: {
      filters: [
        {
          comparison: filter.Comparison.Eq,
          id: 'name',
          value: 'CreateEventInGoogle',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: tableListViewConfig.TableListViewConfig.decode({
    main: {
      actions: [{
          ui: {
            name: 'expand',
            buttonType: 'icon-button',
            iconName: 'uil uil-expand-alt',
            view: 'flat'
          },
          data: {
            type: 'navigation',
            direction: 'forward',
            placement: appConfig.ViewPlacement.SideModal,
            viewId: ID$4,
            params: {
              conversionConfig: {
                'item._id': 'itemId',
              }
            }
          }
        }],
      fields: [
        {
          fieldId: 'createdAt',
          fieldDisplay: new date.DateField('createdAt', 'Date').setDateFormat('DD MMM YYYY').setDataType(date.DateDataType.Unix),
        },
        {
          fieldId: 'createdAt',
          fieldDisplay: new date.DateField('createdAt', 'Hour').setDateFormat('HH:mm').setDataType(date.DateDataType.Unix),
        },
        {
          fieldId: 'parameters.googleEvent.summary',
          fieldDisplay: new nested.NestedField('parameters.googleEvent.summary', new index$1.TextField('summary', 'Summary')),
        },
        {
          fieldId: 'parameters.googleEvent.start.dateTime',
          fieldDisplay: new nested.NestedField('parameters.googleEvent.start.dateTime', new date.DateField('meetingStart', 'Meeting Start').setDateFormat('DD MMM HH:mm')),
        },
        {
          fieldId: 'parameters.googleEvent.end.dateTime',
          fieldDisplay: new nested.NestedField('parameters.googleEvent.end.dateTime', new date.DateField('meetingEnd', 'Meeting End').setDateFormat('DD MMM HH:mm')),
        },
        {
          fieldId: 'status',
        },
      ],
      columns: {
        createdAt: {
          width: 120,
        },
        'parameters.googleEvent.start.dateTime': {
          width: 150,
        },
        'parameters.googleEvent.end.dateTime': {
          width: 150,
        },
        status: {
          width: 100,
        },
      },
    },
    quickSearch: {
      fields: [
        {
          field: new index$2.SingleChoiceField('parameters.userId', 'Search user', undefined, 'Search and select admins.', 'select').setDataProvider(userDataProvider(dataApi))
            .setDataAdapter(new tableListViewConfig.DvnDataAdapter('firstName+lastName', '_id')),
        },
        {
          field: new index$2.SingleChoiceField('status', 'Status', [
            new index$2.SingleChoiceFieldOption('Done', 'done'),
            new index$2.SingleChoiceFieldOption('Failed', 'failed'),
          ]),
        }
      ],
      ui: {
        'parameters.userId': {
          width: '256px',
        }
      },
      requireFilters: false,
    },
  }),
});

const ID$c = 'table-list-view-scheduled-job-sync-events-microsoft';
const config$4 = (dataApi) => tableListViewConfig.TableListViewConfig.decode({
  _id: ID$c,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Sync Microsoft Events Jobs',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['scheduledjobs'],
  query: {
    fields: [
      new index$1.TextField('_id', 'ID'),
      new index$1.TextField('name', 'Name'),
      new index$1.TextField('status', 'Status'),
      new date.DateField('scheduledAt', 'Created At'),
      new date.DateField('createdAt', 'Created At'),
      new dataTransferField.DataTransferField('parameters'),
      new dataTransferField.DataTransferField('metadata'),
    ],
    filter: {
      filters: [
        {
          comparison: filter.Comparison.Eq,
          id: 'name',
          value: 'CreateEventInMicrosoft',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: tableListViewConfig.TableListViewConfig.decode({
    main: {
      actions: [{
          ui: {
            name: 'expand',
            buttonType: 'icon-button',
            iconName: 'uil uil-expand-alt',
            view: 'flat'
          },
          data: {
            type: 'navigation',
            direction: 'forward',
            placement: appConfig.ViewPlacement.SideModal,
            viewId: ID$4,
            params: {
              conversionConfig: {
                'item._id': 'itemId',
              }
            }
          }
        }],
      fields: [
        {
          fieldId: 'createdAt',
          fieldDisplay: new date.DateField('createdAt', 'Date').setDateFormat('DD MMM YYYY').setDataType(date.DateDataType.Unix),
        },
        {
          fieldId: 'createdAt',
          fieldDisplay: new date.DateField('createdAt', 'Hour').setDateFormat('HH:mm').setDataType(date.DateDataType.Unix),
        },
        {
          fieldId: 'parameters.microsoftEvent.subject',
          fieldDisplay: new nested.NestedField('parameters.microsoftEvent.subject', new index$1.TextField('summary', 'Subject')),
        },
        {
          fieldId: 'parameters.microsoftEvent.start.dateTime',
          fieldDisplay: new nested.NestedField('parameters.microsoftEvent.start.dateTime', new date.DateField('meetingStart', 'Meeting Start').setDateFormat('DD MMM HH:mm')),
        },
        {
          fieldId: 'parameters.microsoftEvent.end.dateTime',
          fieldDisplay: new nested.NestedField('parameters.microsoftEvent.end.dateTime', new date.DateField('meetingEnd', 'Meeting End').setDateFormat('DD MMM HH:mm')),
        },
        {
          fieldId: 'status',
        },
      ],
      columns: {
        createdAt: {
          width: 120,
        },
        'parameters.microsoftEvent.start.dateTime': {
          width: 150,
        },
        'parameters.microsoftEvent.end.dateTime': {
          width: 150,
        },
        status: {
          width: 100,
        },
      },
    },
    quickSearch: {
      fields: [
        {
          field: new index$2.SingleChoiceField('parameters.userId', 'Search user', undefined, 'Search and select admins.', 'select').setDataProvider(userDataProvider(dataApi))
            .setDataAdapter(new tableListViewConfig.DvnDataAdapter('firstName+lastName', '_id'))
        },
        {
          field: new index$2.SingleChoiceField('status', 'Status', [
            new index$2.SingleChoiceFieldOption('Done', 'done'),
            new index$2.SingleChoiceFieldOption('Failed', 'failed'),
          ]),
        }
      ],
      ui: {
        'parameters.userId': {
          width: '256px',
        }
      },
      requireFilters: false,
    },
  }),
});

const ID$d = 'table-list-view-scheduled-job-send-email';
const tableListViewUIConfigScheduledJobs = tableListViewConfig.TableListViewConfig.decode({
  main: {
    actions: [{
        ui: {
          name: 'expand',
          buttonType: 'icon-button',
          iconName: 'uil uil-expand-alt',
          view: 'flat'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.SideModal,
          viewId: ID$4,
          params: {
            conversionConfig: {
              'item._id': 'itemId',
            }
          }
        }
      }],
    fields: [
      {
        fieldId: 'parameters.templateAndSubjectName',
        fieldDisplay: new nested.NestedField('parameters.templateAndSubjectName', new index$1.TextField('templateAndSubjectName', 'Type')),
      },
      {
        fieldId: 'createdAt',
        fieldDisplay: new date.DateField('createdAt', 'Date').setDateFormat('DD MMM YYYY').setDataType(date.DateDataType.Unix),
      },
      {
        fieldId: 'createdAt',
        fieldDisplay: new date.DateField('createdAt', 'Hour').setDateFormat('HH:mm').setDataType(date.DateDataType.Unix),
      },
      {
        fieldId: 'parameters.senderName',
        fieldDisplay: new nested.NestedField('parameters.senderName', new index$1.TextField('senderName', 'Sender')),
      },
      {
        fieldId: 'parameters.recipientEmail',
        fieldDisplay: new nested.NestedField('parameters.recipientEmail', new index$1.TextField('recipientEmail', 'Recipient')),
      },
      {
        fieldId: 'metadata.sent',
        fieldDisplay: new nested.NestedField('metadata.sent', new date.DateField('sentOn', 'Sent On').setDateFormat('DD MMM HH:mm')),
      },
      {
        fieldId: 'metadata.delivered',
        fieldDisplay: new nested.NestedField('metadata.delivered', new date.DateField('deliveredOn', 'Delivered On').setDateFormat('DD MMM HH:mm')),
      },
      {
        fieldId: 'status',
      },
    ],
    columns: {
      createdAt: {
        width: 100,
      },
      status: {
        width: 100,
      },
    },
  },
  quickSearch: {
    fields: [
      { field: new index$1.TextField('parameters.recipientEmail', 'Recipient') },
      {
        field: new index$2.SingleChoiceField('parameters.templateAndSubjectName', 'Type', [
          new index$2.SingleChoiceFieldOption('Announcement', 'Announcement'),
          new index$2.SingleChoiceFieldOption('Accept Pair Request', 'AcceptSubscription'),
          new index$2.SingleChoiceFieldOption('Reject Pair Request', 'RejectSubscription'),
          new index$2.SingleChoiceFieldOption('New Pair', 'CreateSubscription'),
          new index$2.SingleChoiceFieldOption('New Availability', 'CreateAvailability'),
          new index$2.SingleChoiceFieldOption('Cancel Meeting', 'CancelEvent'),
          new index$2.SingleChoiceFieldOption('New Meeting', 'CreateEvent'),
          new index$2.SingleChoiceFieldOption('New Meeting for Goal', 'CreateEventForMeetingGoal'),
          new index$2.SingleChoiceFieldOption('Update Meeting', 'UpdateEvent'),
          new index$2.SingleChoiceFieldOption('Invitation', 'Invitation'),
          new index$2.SingleChoiceFieldOption('New Form Assignment', 'FormAssignment'),
          new index$2.SingleChoiceFieldOption('New Group Member', 'NewGroupMember'),
          new index$2.SingleChoiceFieldOption('New Message', 'NewMessage'),
          new index$2.SingleChoiceFieldOption('Reset Password Link', 'ResetPasswordLink'),
        ]),
      }
    ],
    ui: {
      'parameters.templateAndSubjectName': {
        width: '240px',
      }
    },
    requireFilters: true,
  },
});
const viewConfig$8 = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$d,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Send Email Jobs',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['scheduledjobs'],
  query: {
    fields: [
      new index$1.TextField('name', 'Name'),
      new index$1.TextField('status', 'Status'),
      new date.DateField('scheduledAt', 'Created At'),
      new date.DateField('createdAt', 'Created At'),
      new dataTransferField.DataTransferField('parameters'),
      new dataTransferField.DataTransferField('metadata'),
    ],
    filter: {
      filters: [
        {
          comparison: filter.Comparison.Eq,
          id: 'name',
          value: 'SendEmail',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: tableListViewUIConfigScheduledJobs,
});

const ID$e = 'table-list-view-organisation-admins';
const organisationTableListViewUIConfig = tableListViewConfig.TableListViewConfig.decode({
  header: {
    actions: [{
        ui: {
          name: 'add-admin',
          buttonType: 'button',
          label: 'Add New'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.Dialog,
          viewId: ID$5,
          params: {
            conversionConfig: {
              'organisationId': 'organisationId',
              'organisationDomain': 'organisationDomain',
            }
          }
        }
      }],
  },
  leanedHorizontally: false,
  main: {
    actions: [
      {
        ui: {
          name: 'remove-admins',
          buttonType: 'icon-button',
          iconName: 'uil uil-trash-alt',
          tint: 'danger',
          view: 'flat'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.Dialog,
          viewId: ID$6,
          params: {
            conversionConfig: {
              'item': 'admin',
              'organisationDomain': 'organisationDomain',
            }
          }
        }
      },
    ],
    fields: [
      { fieldId: 'imageUrl' },
      { fieldId: 'firstName' },
      { fieldId: 'lastName' },
      { fieldId: 'email' },
    ],
    columns: {
      firstName: {
        width: 150,
      },
      imageUrl: {
        width: 50,
      },
      lastName: {
        width: 150,
      },
    },
  },
});
const viewConfig$9 = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$e,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Admins',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['users'],
  query: {
    fields: [
      new dataTransferField.DataTransferField('imageUrl'),
      new dataTransferField.DataTransferField('firstName'),
      new dataTransferField.DataTransferField('lastName'),
      new dataTransferField.DataTransferField('email'),
    ],
    filter: {
      comparison: filter.Comparison.Eq,
      id: '_roles',
      value: 'admin@+$organisationDomain',
    },
    sort: [{ id: 'firstName', order: 1 }]
  },
  ui: organisationTableListViewUIConfig,
  params: {
    organisationDomain: {
      required: true,
    },
    organisationId: {
      required: true,
    },
  },
});

const ID$f = 'table-list-view-organisation';
const organisationTableListViewUIConfig$1 = tableListViewConfig.TableListViewConfig.decode({
  header: {
    actions: [{
        ui: {
          name: 'new-organisation',
          buttonType: 'button',
          label: 'Create New'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.Dialog,
          viewId: ID$7,
        }
      }],
  },
  main: {
    actions: [
      {
        ui: {
          name: 'manage-admins',
          buttonType: 'icon-button',
          iconName: 'uil uil-users-alt',
          view: 'flat'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.SideModal,
          viewId: ID$e,
          params: {
            conversionConfig: {
              'item._id': 'organisationId',
              'item.domain': 'organisationDomain',
            }
          }
        }
      },
      {
        ui: {
          name: 'expand',
          buttonType: 'icon-button',
          iconName: 'uil uil-expand-alt',
          view: 'flat'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.SideModal,
          viewId: ID$1,
          params: {
            conversionConfig: {
              'item._id': 'itemId',
            }
          }
        }
      },
      {
        ui: {
          name: 'expand',
          buttonType: 'icon-button',
          iconName: 'uil uil-transaction',
          view: 'flat'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.Dialog,
          viewId: ID$8,
          params: {
            conversionConfig: {
              'item._id': 'itemId',
            }
          }
        }
      },
    ],
    fields: [
      { fieldId: 'logoUrl' },
      { fieldId: 'status', isEditable: true },
      { fieldId: 'model', isEditable: true },
      { fieldId: 'title' },
      {
        fieldDisplay: new date.DateField('createdAt', 'Creation Date')
          .setDateFormat('DD MMM YYYY')
          .setDataType(date.DateDataType.Unix),
      },
      {
        fieldDisplay: new index$1.TextField('summary.metrics.mentorCount', 'Mentors'),
      },
      {
        fieldDisplay: new index$1.TextField('summary.metrics.menteeCount', 'Mentees'),
      },
    ],
    columns: {
      title: {
        weight: 1,
      },
      status: {
        width: 100,
      },
      model: {
        width: 200,
      },
      logoUrl: {
        width: 50,
      },
      createdAt: {
        width: 150,
      },
      'summary.metrics.mentorCount': {
        width: 100,
      },
      'summary.metrics.menteeCount': {
        width: 100,
      },
    },
  },
  quickSearch: {
    fields: [
      { fieldId: 'domain' },
      { fieldId: 'title' },
      { fieldId: 'status' },
      { fieldId: 'model' },
    ],
    ui: {
      model: {
        width: '200px'
      }
    }
  },
});
const viewConfig$a = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$f,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Organisations',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['organisations'],
  query: {
    fields: [
      new dataTransferField.DataTransferField('status'),
      new dataTransferField.DataTransferField('model'),
      new dataTransferField.DataTransferField('logoUrl'),
      new dataTransferField.DataTransferField('domain'),
      new dataTransferField.DataTransferField('title'),
      new dataTransferField.DataTransferField('description'),
      new dataTransferField.DataTransferField('createdAt'),
      {
        type: 'reverse-reference',
        id: 'summary',
        otherCollection: 'organisationSummaries',
        nameInOtherCollection: 'organisation',
        isSingle: true,
        fields: [{ id: 'metrics' }]
      }
    ],
    sort: [{ id: 'title', order: 1 }]
  },
  ui: organisationTableListViewUIConfig$1,
});

const ID$g = 'table-list-view-organisation-newest';
const viewConfig$b = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$g,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Newest Organisations',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['organisations'],
  query: {
    fields: [
      new dataTransferField.DataTransferField('status'),
      new dataTransferField.DataTransferField('model'),
      new dataTransferField.DataTransferField('logoUrl'),
      new dataTransferField.DataTransferField('domain'),
      new dataTransferField.DataTransferField('title'),
      new dataTransferField.DataTransferField('description'),
      new dataTransferField.DataTransferField('createdAt'),
      {
        type: 'reverse-reference',
        id: 'summary',
        otherCollection: 'organisationSummaries',
        nameInOtherCollection: 'organisation',
        isSingle: true,
        fields: [{ id: 'metrics' }]
      }
    ],
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: organisationTableListViewUIConfig$1,
});

const ID$h = 'table-list-view-scheduled-job-next-day-summary';
const tableListViewUIConfigScheduledJobsNextDaySummary = tableListViewConfig.TableListViewConfig.decode({
  main: {
    fields: [
      {
        fieldId: 'createdAt',
        fieldDisplay: new date.DateField('createdAt', 'Creation Date').setDateFormat('DD MMM YYYY HH:mm').setDataType(date.DateDataType.Unix),
      },
      {
        fieldId: 'scheduledAt',
        fieldDisplay: new date.DateField('scheduledAt', 'Scheduled Date').setDateFormat('DD MMM YYYY HH:mm'),
      },
      {
        fieldId: 'status',
      },
    ],
    columns: {
      createdAt: {
        width: 250,
      },
      scheduledAt: {
        width: 250,
      },
      'status': {
        width: 200,
      },
    },
  },
});
const viewConfig$c = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$h,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Next Day Events Summary Jobs',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['scheduledjobs'],
  query: {
    fields: [
      new index$1.TextField('name', 'Name'),
      new index$1.TextField('status', 'Status'),
      new date.DateField('scheduledAt', 'Created At'),
      new date.DateField('createdAt', 'Created At'),
    ],
    filter: {
      filters: [
        {
          comparison: filter.Comparison.Eq,
          id: 'name',
          value: 'NotificationNextDayEventsSummary',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: tableListViewUIConfigScheduledJobsNextDaySummary,
});

const ID$i = 'table-list-view-scheduled-job-daily-summary';
const viewConfig$d = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$i,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Daily Events Summary Jobs',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['scheduledjobs'],
  query: {
    fields: [
      new index$1.TextField('name', 'Name'),
      new index$1.TextField('status', 'Status'),
      new date.DateField('scheduledAt', 'Created At'),
      new date.DateField('createdAt', 'Created At'),
    ],
    filter: {
      filters: [
        {
          comparison: filter.Comparison.Eq,
          id: 'name',
          value: 'NotificationDailyEventSummary',
        },
      ],
      operator: 'or'
    },
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: tableListViewUIConfigScheduledJobsNextDaySummary,
});

const ID$j = 'table-list-view-session';
const config$5 = (dataApi) => tableListViewConfig.TableListViewConfig.decode({
  _id: ID$j,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'User Sessions',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['sessions'],
  query: {
    fields: [
      new dataTransferField.DataTransferField('client'),
      new dataTransferField.DataTransferField('createdAt'),
      new dataTransferField.DataTransferField('updatedAt'),
      new dataTransferField.DataTransferField('failureReason'),
      new dataTransferField.DataTransferField('status'),
      new FieldModelGenerator.ReferenceField('user', 'User', 'firstName', 'imageUrl', 'users', [
        new attachment.AttachmentField('imageUrl', ''),
        new index$1.TextField('email', 'Email'),
        new index$1.TextField('firstName', 'First Name'),
        new index$1.TextField('lastName', 'Last Name'),
      ], true),
    ],
    sort: [{ id: 'updatedAt', order: -1 }]
  },
  ui: tableListViewConfig.TableListViewConfig.decode({
    header: {
      actions: [],
    },
    main: {
      actions: [],
      fields: [
        {
          fieldId: 'user.imageUrl',
          fieldDisplay: new nested.NestedField('user.imageUrl', new attachment.AttachmentField('imageUrl', '').setShape('circle'))
        },
        {
          fieldId: 'user.firstName',
          fieldDisplay: new nested.NestedField('user.firstName', new index$1.TextField('firstName', 'First Name'))
        },
        {
          fieldId: 'user.lastName',
          fieldDisplay: new nested.NestedField('user.lastName', new index$1.TextField('lastName', 'Last Name'))
        },
        {
          fieldId: 'user.email',
          fieldDisplay: new nested.NestedField('user.email', new index$1.TextField('email', 'Email'))
        },
        { fieldId: 'createdAt' },
        { fieldId: 'updatedAt' },
        { fieldId: 'client' },
        { fieldId: 'status' },
        { fieldId: 'failureReason' },
      ],
      columns: {
        'user.imageUrl': {
          width: 50,
        },
        'user.firstName': {
          width: 120,
        },
        'user.lastName': {
          width: 120,
        },
        'user.email': {
          width: 240,
        },
        createdAt: {
          width: 150,
        },
        updatedAt: {
          width: 150,
        },
        status: {
          width: 150,
        },
        client: {
          width: 120,
        },
      },
    },
    quickSearch: {
      fields: [
        {
          field: new index$2.SingleChoiceField('user._id', 'Search user', undefined, '', 'select').setDataProvider(userDataProvider(dataApi))
            .setDataAdapter(new tableListViewConfig.DvnDataAdapter('firstName+lastName', '_id')),
        },
        {
          field: new index$2.SingleChoiceField('status', 'Status', [
            new index$2.SingleChoiceFieldOption('Successful', 'successful'),
            new index$2.SingleChoiceFieldOption('Failed', 'failed'),
            new index$2.SingleChoiceFieldOption('Logged Out', 'loggedOut'),
          ]),
        }
      ],
      ui: {
        'user._id': {
          width: '240px',
        },
        status: {
          width: '150px',
        },
      },
    },
  }),
});

const ID$k = 'table-list-view-user';
const listViewUIConfig = tableListViewConfig.TableListViewConfig.decode({
  header: {
    actions: [],
  },
  main: {
    actions: [
      {
        ui: {
          name: 'expand',
          buttonType: 'icon-button',
          iconName: 'uil uil-key-skeleton',
          view: 'flat'
        },
        data: {
          type: 'navigation',
          direction: 'forward',
          placement: appConfig.ViewPlacement.SideModal,
          viewId: ID$3,
          params: {
            conversionConfig: {
              'item._id': 'userId',
            }
          }
        }
      },
    ],
    fields: [
      { fieldId: 'imageUrl' },
      { fieldId: 'firstName' },
      { fieldId: 'lastName' },
      { fieldId: 'email' },
      { fieldId: 'status' },
      { fieldId: 'createdAt' },
      {
        fieldId: 'lastSession.updatedAt',
        fieldDisplay: new nested.NestedField('lastSession.updatedAt', new date.DateField('updatedAt', 'Last Session')
          .setDataType(date.DateDataType.Unix)
          .setDateFormat('DD MMM YYYY HH:mm')),
      },
      { fieldId: 'memberships' },
    ],
    columns: {
      createdAt: {
        width: 120,
      },
      email: {
        width: 240,
      },
      firstName: {
        width: 150,
      },
      imageUrl: {
        width: 50,
      },
      lastName: {
        width: 150,
      },
      'lastSession.updatedAt': {
        width: 150,
      },
      status: {
        width: 100,
      },
      memberships: {
        weight: 1,
      },
    },
  },
  quickSearch: {
    fields: [
      { fieldId: 'email' },
      { fieldId: 'firstName' },
      { fieldId: 'lastName' },
      { fieldId: 'status' },
    ]
  },
});
const viewConfig$e = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$k,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'Users',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['users'],
  query: {
    fields: [
      new date.DateField('createdAt', 'Created At').setDataType(date.DateDataType.Unix).setDateFormat('DD MMM YYYY'),
      new attachment.AttachmentField('imageUrl', ''),
      new index$1.TextField('email', 'Email'),
      new index$1.TextField('firstName', 'First Name'),
      new index$1.TextField('lastName', 'Last Name'),
      new index$1.TextField('status', 'Status'),
      new tableListViewConfig.RelationReferenceField('memberships', 'Programs', 'title', 'logoUrl', 'memberships', 'user', 'organisations', 'organisation', [
        new index$1.TextField('status', '')
      ], [
        new index$1.TextField('logoUrl', ''),
        new index$1.TextField('title', ''),
      ]),
      {
        type: 'reverse-reference',
        id: 'lastSession',
        otherCollection: 'sessions',
        nameInOtherCollection: 'user',
        isSingle: true,
        fields: [{ id: 'updatedAt' }, { id: 'createdAt' }],
        limit: 1,
        sort: {
          order: -1,
          id: 'updatedAt'
        }
      }
    ],
    sort: [{ id: 'createdAt', order: -1 }]
  },
  ui: listViewUIConfig,
});

const ID$l = 'table-list-view-white-label';
const viewConfig$f = tableListViewConfig.TableListViewConfig.decode({
  _id: ID$l,
  type: viewConfig$g.AppViewType.ListViewTable,
  base: 'mentornity',
  title: 'White Labels',
  space: spaces.spaces['mentornity'],
  table: tableListViewConfig.dataConfigs['whiteLabels'],
  query: {
    fields: [
      new dataTransferField.DataTransferField('title'),
      new dataTransferField.DataTransferField('domain'),
      new dataTransferField.DataTransferField('createdAt'),
    ],
    sort: [{ id: 'title', order: 1 }]
  },
  ui: tableListViewConfig.TableListViewConfig.decode({
    main: {
      fields: [
        { fieldId: 'title' },
        { fieldId: 'domain' },
        {
          fieldId: 'createdAt',
          fieldDisplay: new date.DateField('createdAt', 'Date').setDateFormat('DD MMM YYYY').setDataType(date.DateDataType.Unix),
        },
      ],
      columns: {
        domain: {
          weight: 1,
        },
        title: {
          weight: 1,
        },
        createdAt: {
          width: 150,
        },
      },
    },
  }),
});

const dataApi = new dataApi$1.DataApiImpl(dataApiEndpoint, { Authorization: `Bearer ${index.getSessionData().token}` });
const appConfigs = {
  // app for system admins
  'app-configs-system-admin': appConfig.AppConfig.decode({
    _id: 'app-configs-system-admin',
    _created: new Date(),
    _updated: new Date(),
    mainNavigation: {
      items: [
        {
          ui: {
            icon: 'uil-building',
            title: 'Newest',
            parent: 'Organisations',
          },
          viewId: ID$g,
        },
        {
          ui: {
            icon: 'uil-building',
            title: 'All',
            parent: 'Organisations',
          },
          viewId: ID$f,
        },
        {
          ui: {
            icon: 'uil-clock',
            parent: 'Scheduled Jobs',
            title: 'Send Email'
          },
          viewId: ID$d,
        },
        {
          ui: {
            icon: 'uil-clock',
            parent: 'Scheduled Jobs',
            title: 'Sync Google'
          },
          viewId: ID$b,
        },
        {
          ui: {
            icon: 'uil-clock',
            parent: 'Scheduled Jobs',
            title: 'Sync Microsoft'
          },
          viewId: ID$c,
        },
        {
          ui: {
            icon: 'uil-clock',
            parent: 'Scheduled Jobs',
            title: 'Next Day Summary'
          },
          viewId: ID$h,
        },
        {
          ui: {
            icon: 'uil-clock',
            parent: 'Scheduled Jobs',
            title: 'Daily Summary'
          },
          viewId: ID$i,
        },
        {
          ui: {
            icon: 'uil-signin',
            title: 'Sessions'
          },
          viewId: ID$j,
        },
        {
          ui: {
            icon: 'uil-file-alt',
            title: 'Help',
            parent: 'Support Forms',
          },
          viewId: ID$a,
        },
        {
          ui: {
            icon: 'uil-file-alt',
            title: 'Contact',
            parent: 'Support Forms',
          },
          viewId: ID$9,
        },
        {
          ui: {
            icon: 'uil-user',
            title: 'Users'
          },
          viewId: ID$k,
        },
        {
          ui: {
            icon: 'uil-university',
            title: 'White Labels'
          },
          viewId: ID$l,
        },
      ],
      aligned: 'left',
      centered: false,
    },
    membership: membershipConfigs['system-admins'],
    space: spaces.spaces['mentornity'],
    views: [
      viewConfig$2,
      viewConfig$1,
      viewConfig$3,
      viewConfig$4,
      viewConfig,
      viewConfig$5,
      config$2(dataApi),
      config(dataApi),
      config$1(),
      viewConfig$6,
      viewConfig$7,
      viewConfig$a,
      viewConfig$9,
      viewConfig$b,
      viewConfig$d,
      viewConfig$c,
      viewConfig$8,
      config$3(dataApi),
      config$4(dataApi),
      config$5(dataApi),
      viewConfig$e,
      viewConfig$f,
    ],
  }),
};

class UyeApiMentornity {
  constructor(endpoint, headers) {
    this.headers = headers;
    this.endpoint = endpoint;
  }
  getAppConfigOfMembership(_id) {
    return Promise.resolve(appConfigs['app-configs-system-admin']);
  }
  addAuthInterceptor(token) {
    console.log('addAuthInterceptor', token);
  }
  consentAgreement(_id) {
    return Promise.reject(utils.notImplemented('UyeApiMentornity.consentAgreement'));
  }
  getAgreement(_id) {
    return Promise.reject(utils.notImplemented('UyeApiMentornity.getAgreement'));
  }
  activateMembership(_membershipConfigId, _membershipId) {
    return Promise.reject(utils.notImplemented('UyeApiMentornity.activateMembership'));
  }
  getMembership(_membershipConfigId, _membershipId) {
    return Promise.reject(utils.notImplemented('UyeApiMentornity.getMembership'));
  }
  getMembershipsOfUser(userId) {
    return Promise.resolve({
      results: [
        membership.Membership.decode({
          _id: `system-admin-membership-for-${userId}`,
          _created: new Date(),
          _updated: new Date(),
          config: membershipConfigs['system-admins'].toObject(),
          consents: [],
          status: 'active',
          user: User.User.decode({ _id: userId }),
        })
      ]
    });
  }
  // getMembershipConfig(_id: string): Promise<MembershipConfig> {
  //   return Promise.reject(notImplemented('UyeApiMentornity.getMembershipConfig'));
  // }
  getMembershipConfigWithName(_name) {
    return Promise.reject(utils.notImplemented('UyeApiMentornity.getMembershipConfigWithName'));
  }
  updateMembership(_membershipConfigId, _membershipId, _data) {
    return Promise.reject(utils.notImplemented('UyeApiMentornity.updateMembership'));
  }
}

exports.KimlikApiMentornity = KimlikApiMentornity;
exports.UyeApiMentornity = UyeApiMentornity;
exports.dataApiEndpoint = dataApiEndpoint;
exports.mentornityApiEndpoint = mentornityApiEndpoint;
