import { FastClick } from "./lib/fastclick"
import { ComposerEntryPage } from "./view/composerEntryPage"
import { browserHashService } from "./service/browserHashService"
import * as Settings from "./settings"
import { FileChangeNotificationService } from "./service/fileChangeNotificationService"
import { TestResourceMaintainer } from "./service/testResourceMaintainer"
export class Application {
    constructor() {
    }
    public fileChangeNotificationService
    public testResourceMaintainer
    initialize() {
        // Solve mobile problem
        FastClick.attach(document.body);
        let hash = window.location.hash
        browserHashService.syncFromHash(hash)
        let widget: string

        let path = `${window.location.protocol}//${window.location.host}`
        path = path.replace("http", "ws")
        this.fileChangeNotificationService = new FileChangeNotificationService(path)
        this.testResourceMaintainer = new TestResourceMaintainer()
        let composerEntryPage: ComposerEntryPage
        if (browserHashService.has("path")) {
            widget = browserHashService.get("path")
            composerEntryPage = new ComposerEntryPage(widget)
            // composerEntryPage.preview(widget)
        } else {
            composerEntryPage = new ComposerEntryPage()
        }
        composerEntryPage.appendTo(document.body)

    }
}

export const App = new Application()
