import { M as Membership, b as MembershipConfig } from './membership-e92743d1.js';
import { U as User } from './User-1ef5a482.js';
import { U as UserSettings } from './UserSettings-27df01e6.js';
import { C as CookieStorage } from './cookie-1686830b.js';
import { r as routeParser } from './index-d3bd30bd.js';

const appRoute = '/:domain(/:page)(/:id)';
function getRouteParams(pathname) {
  // console.log(pathname, new Route(appRoute).match(pathname));
  return new routeParser(appRoute).match(pathname);
}

function getSessionDetails(groupId) {
  const { domain } = getRouteParams(location.pathname);
  const jwt = new CookieStorage().get('mt_at');
  const sessionToken = new CookieStorage().get('mt_st');
  const context = {
    organisationDomain: domain,
    organisationId: new CookieStorage().get('mt_oid'),
    userId: new CookieStorage().get('mt_uid'),
    role: new CookieStorage().get('mt_role'),
  };
  const headers = {
    Client: 'd2ViLWNsaWVu',
  };
  if (jwt) {
    headers['Authorization'] = `Bearer ${jwt}`;
    headers['Session-Token'] = sessionToken;
  }
  else {
    headers['Session-Token'] = `NTdiMzY3NjBlNjNiY2UxZWViMDAwMDA0`;
  }
  context.groupId = groupId;
  return { context, headers };
}
function getUserSettings(timeFormat, dateFormat, timeZone, language, isZoomAuthenticated, weekStartDay = 'monday') {
  const authPlatforms = [];
  if (isZoomAuthenticated) {
    authPlatforms.push({
      id: 'zoom',
      name: 'Zoom',
      scope: []
    });
  }
  return UserSettings.decode({ timeFormat, dateFormat, timeZone, language, authPlatforms, weekStartDay });
}
function generateMembershipForRole(role) {
  return Membership.decode({
    config: generateMembershipConfigForRole(role),
  });
}
function generateMembershipConfigForRole(role) {
  return MembershipConfig.decode({
    _id: role === 'mentor' ? 'mentors' : 'mentees',
    roleName: role
  });
}
function getUser(id) {
  return User.decode({ _id: id });
}

export { generateMembershipConfigForRole as a, getRouteParams as b, getUser as c, getUserSettings as d, generateMembershipForRole as e, getSessionDetails as g };
