import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { DocServer } from '../client/DocServer';
import { Docs } from '../client/documents/Documents';
import { CurrentUserUtils } from '../client/util/CurrentUserUtils';
import { AssignAllExtensions } from '../extensions/Extensions';
import { MobileInterface } from './MobileInterface';

AssignAllExtensions();

(async () => {
    const info = await CurrentUserUtils.loadCurrentUser();
    DocServer.init(window.location.protocol, window.location.hostname, 4321, info.email + ' (mobile)');
    await Docs.Prototypes.initialize();
    await CurrentUserUtils.loadUserDocument(info);
    document.getElementById('root')!.addEventListener(
        'wheel',
        event => {
            if (event.ctrlKey) {
                event.preventDefault();
            }
        },
        true
    );
    ReactDOM.render(<MobileInterface />, document.getElementById('root'));
})();
