import semver from "semver";
import { mustUpgrade } from "../apps";
import { getAppsCatalogForDevice } from "../device/use-cases/getAppsCatalogForDevice";
const isUpdateAvailable = async (deviceInfo, appAndVersion, checkMustUpdate = true) => {
    const applicationsByDevice = await getAppsCatalogForDevice(deviceInfo);
    const appAvailableInProvider = applicationsByDevice.find(({ versionName: name }) => appAndVersion.name === name);
    if (!appAvailableInProvider)
        return false;
    if (!checkMustUpdate) {
        return semver.gt(appAvailableInProvider.version, appAndVersion.version);
    }
    return (!!appAvailableInProvider &&
        !mustUpgrade(appAvailableInProvider.versionName, appAvailableInProvider.version));
};
export default isUpdateAvailable;
//# sourceMappingURL=isUpdateAvailable.js.map