var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import '@iotize/tap/service/impl/device';
import { Tap } from '@iotize/tap';
import { FirmwareState } from '@iotize/tap/service/impl/firmware';
export function factoryReset() {
    return __awaiter(this, void 0, void 0, function* () {
        // check that IoTize FW is in Normal Mode
        const currentState = (yield this.service.firmware.getState()).body();
        if (currentState !== FirmwareState.NORMAL) {
            throw new Error('Cannot restore factory configuration during firmware update process.'
            // TODO proper error
            );
        }
        // ==================================================================
        // - Factory Reset ---------------------------------------------------
        (yield this.service.device.factoryReset()).successful();
    });
}
Tap.prototype.factoryReset = factoryReset;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS1yZXNldC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bpb3RpemUvdGFwL2V4dC9mYWN0b3J5LXJlc2V0LyIsInNvdXJjZXMiOlsibGliL2ZhY3RvcnktcmVzZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsT0FBTyxpQ0FBaUMsQ0FBQztBQUV6QyxPQUFPLEVBQUUsR0FBRyxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBQ2xDLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQVFsRSxNQUFNLFVBQWdCLFlBQVk7O1FBQzlCLHlDQUF5QztRQUN6QyxNQUFNLFlBQVksR0FBRyxDQUFDLE1BQU0sSUFBSSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNyRSxJQUFJLFlBQVksS0FBSyxhQUFhLENBQUMsTUFBTSxFQUFFO1lBQ3ZDLE1BQU0sSUFBSSxLQUFLLENBQ1gsc0VBQXNFO1lBQ3RFLG9CQUFvQjthQUN2QixDQUFDO1NBQ0w7UUFDRCxxRUFBcUU7UUFDckUsc0VBQXNFO1FBQ3RFLENBQUMsTUFBTSxJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxZQUFZLEVBQUUsQ0FBQyxDQUFDLFVBQVUsRUFBRSxDQUFDO0lBQzVELENBQUM7Q0FBQTtBQUVELEdBQUcsQ0FBQyxTQUFTLENBQUMsWUFBWSxHQUFHLFlBQVksQ0FBQyJ9