import { ignoreElements, catchError } from "rxjs/operators";
import { throwError } from "rxjs";
import { ManagerAppDepUninstallRequired } from "@ledgerhq/errors";
import ManagerAPI from "../manager/api";
export default function uninstallApp(transport, targetId, app) {
    return ManagerAPI.install(transport, "uninstall-app", {
        targetId,
        perso: app.perso,
        deleteKey: app.delete_key,
        firmware: app.delete,
        firmwareKey: app.delete_key,
        hash: app.hash,
    }, true).pipe(ignoreElements(), catchError((e) => {
        if (!e || !e.message)
            return throwError(() => e);
        const status = e.message.slice(e.message.length - 4);
        if (status === "6a83") {
            return throwError(() => new ManagerAppDepUninstallRequired("", {
                appName: app.name,
            }));
        }
        return throwError(() => e);
    }));
}
//# sourceMappingURL=uninstallApp.js.map