import { css } from '@microsoft/fast-element';
import { DI, Registration } from '@microsoft/fast-foundation';
import defaultLogoSrc from '../assets/genesis-logo-light.svg';
import defaultBackgroundSrc from '../assets/bg.jpg';
/**
 * @public
 */
export const defaultOrganisation = DEFAULT_ORGANISATION;
/**
 * @public
 */
export const defaultUser = DEFAULT_USER;
/**
 * @public
 */
export const defaultPassword = DEFAULT_PASSWORD;
/**
 * @public
 */
export const defaultApiHost = API_HOST;
/**
 * @public
 */
export const defaultSocketExt = SOCKET_EXT;
/**
 * @public
 */
export const hostEnv = location.host;
const wsProtocol = 'https:' === location.protocol ? 'wss:' : 'ws:';
const socketExt = SOCKET_EXT || 'gwf';
/**
 * @public
 */
export const hostUrl = API_HOST || `${wsProtocol}//${hostEnv}/${socketExt}/`;
/**
 * @public
 */
export const Routes = {
    login: 'login',
    'request-account': 'request-account',
    'reset-password': 'reset-password',
    'forgot-password': 'forgot-password',
    verify: 'verify',
    protected: 'protected',
    'not-found': 'not-found',
};
/**
 * A utility to check if a pathname is a route of this micro frontend.
 *
 * @param pathname - A pathname string to check, typically location.pathname, which is used when a value is omitted.
 *
 * @public
 * @privateRemarks
 * I've just put this util in for now given there's some app level direction code in place which needs review.
 */
export function isMFRoute(pathname = location.pathname) {
    const valueParts = pathname.split('/');
    const routeIdx = pathname.charAt(0) === '/' ? 1 : 0;
    const route = valueParts[routeIdx];
    return !!Routes[route];
}
/**
 * Default LoginConfig DI implementation.
 * @public
 */
export const defaultLoginConfig = {
    autoConnect: false,
    autoAuth: false,
    logo: css `
    content: url(${defaultLogoSrc});
  `,
    background: css `
    :host {
      background-image: url(${defaultBackgroundSrc});
    }
  `,
    omitRoutes: [],
    fields: {
        organisation: null,
        username: {
            label: 'Username',
            value: defaultUser,
        },
        email: {
            label: 'Email Address',
        },
        password: {
            label: 'Password',
            value: defaultPassword,
        },
    },
    showConnectionIndicator: false,
    defaultRedirectUrl: '/protected',
    omitRedirectUrls: ['/not-found', '/not-permitted'],
    sso: {
        identityProvidersPath: 'sso/list',
    },
};
/**
 * LoginConfig DI key.
 *
 * @internal
 * @privateRemarks
 * Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
 */
export const LoginConfig = DI.createInterface();
/**
 * Configure the login micro frontend settings.
 *
 * @remarks
 * This is primarily for general settings, rather than re-defining the element, static templating / style changes.
 *
 * @param container - DI container.
 * @param config - A partial LoginConfig.
 *
 * @example Configuring login on lazy load
 * ```ts
 * name: 'login',
 * path: 'login',
 * title: 'Login',
 * element: async () => {
 *   const { configure, define, defaultLoginConfig } = await import('@genesislcap/foundation-login');
 *   configure(this.container, {
 *     autoConnect: true,
 *     omitRoutes: ['request-account'],
 *     fields: {
 *       ...defaultLoginConfig.fields,
 *       organisation: {
 *         label: 'CompID',
 *       },
 *     },
 *     defaultRedirectUrl: 'dashboard',
 *     logo: loginLogo,
 *     background: loginBG,
 *   });
 *   // You can import and return `Login` directly here or re-define it completely via `define`.
 *   return define({
 *     name: `nexus-login`,
 *   });
 * },
 * layout: loginLayout,
 * settings: { public: true },
 * childRouters: true,
 * ```
 *
 * @public
 * @privateRemarks
 * We can tailor the spreading logic after we put it to use. Keeping it simple for now.
 */
export function configure(container, config) {
    container.register(Registration.instance(LoginConfig, Object.assign(Object.assign({}, defaultLoginConfig), config)));
}
//# sourceMappingURL=config.js.map