"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.canUseQueryMapFeaturesV4 = exports.parseSiteVersion = exports.getSiteVersion = void 0;
/**
 * Gets the MapGuide site version from the runtime map response
 * @param map
 * @since 0.12
 */
function getSiteVersion(map) {
    return parseSiteVersion(map.SiteVersion);
}
exports.getSiteVersion = getSiteVersion;
/**
 * Parses the given version string
 *
 * @param ver The version string
 * @since 0.14.8
 */
function parseSiteVersion(ver) {
    var _a = ver.split("."), sMaj = _a[0], sMin = _a[1], sPatch = _a[2], sRev = _a[3];
    var vMaj = parseInt(sMaj, 10);
    var vMin = parseInt(sMin, 10);
    var vPatch = parseInt(sPatch, 10);
    var vRev = parseInt(sRev, 10);
    return [vMaj, vMin, vPatch, vRev];
}
exports.parseSiteVersion = parseSiteVersion;
/**
 * Tests if QUERYMAPFEATURES 4.0.0 API can be used with this version of MapGuide
 * @param version The site version
 * @since 0.12.1
 */
function canUseQueryMapFeaturesV4(version) {
    var vMaj = version[0], vMin = version[1], vPatch = version[2], vRev = version[3];
    if (vMaj >= 4) {
        //Allow a 4.0 trunk/branch build
        if (vMaj == 4 && vMin == 0 && vPatch == 0 && vRev == 0) {
            return true;
        }
        //Test for > 4.0 preview 1
        if (vMaj == 4 && vMin == 0 && vPatch == 0) {
            return vRev > 9592; //This is the rev of preview 1
        }
        return true;
    }
    return false;
}
exports.canUseQueryMapFeaturesV4 = canUseQueryMapFeaturesV4;
//# sourceMappingURL=site-version.js.map