// @configure_input@

const DomTerm = new Object(); //maybe use Terminal - FIXME

DomTerm.versionString = "@DOMTERM_VERSION@";
DomTerm.copyrightYear = "@DOMTERM_YEAR@";
DomTerm.inAtomFlag = false;
DomTerm._useXtermJs = "@WITH_XTERMJS@";

DomTerm.versions = {};
DomTerm.versions.domterm = DomTerm.versionString;

if (typeof process !== 'undefined' && process.versions
    && process.versions.electron)
    DomTerm.versions = Object.assign(DomTerm.versions, process.versions.electron);
if (typeof navigator !== 'undefined' && navigator.userAgent) {
    let m;
    if ((m = navigator.userAgent.match(/QtWebEngine[/]([^ ]+)/)))
        DomTerm.versions.qtwebengine = m[1];
    if ((m = navigator.userAgent.match(/Electron[/]([^ ]+)/)))
        DomTerm.versions.electron = m[1];
    if ((m = navigator.userAgent.match(/Chrome[/]([^ ]+)/)))
        DomTerm.versions.chrome = m[1];
    if ((m = navigator.userAgent.match(/Edg[/]([^ ]+)/)))
        DomTerm.versions.edge = m[1];
    if ((m = navigator.userAgent.match(/Firefox[/]([^ ]+)/)))
        DomTerm.versions.firefox = m[1];
    if ((m = navigator.userAgent.match(/Atom[/]([^ ]+)/)))
        DomTerm.versions.atom = m[1];
    if ((m = navigator.userAgent.match(/JavaFX[/]([^ ]+)/)))
        DomTerm.versions.javaFX = m[1];
    if (window.gtk_version)
        DomTerm.versions.gtk = window.gtk_version;
    if ((m = navigator.userAgent.match(/AppleWebKit[/]([^ ]+)/))
       && ! DomTerm.versions.chrome)
        DomTerm.versions.appleWebKit = m[1];
    if (window.wry_version) {
        DomTerm.versions.wry = window.wry_version;
        if (window.webview_version && DomTerm.versions.appleWebKit)
            DomTerm.versions.webkitgtk = window.webview_version;
    }
    DomTerm.versions.userAgent = navigator.userAgent;
}

DomTerm.isElectron = function() {
    return DomTerm.versions.electron;
}

DomTerm.isAtom = function() { return DomTerm.inAtomFlag; }

DomTerm.versionInfo = "version="+DomTerm.versionString;

DomTerm.isMac = typeof navigator != "undefined" ? /Mac/.test(navigator.platform)
    : typeof os != "undefined" ? os.platform() == "darwin" : false;

DomTerm.usingXtermJs = function() {
    // This works even if autoconf substitions haven't been made.
    return DomTerm._useXtermJs.charAt(0) === "1";
}
