"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const is_online_1 = __importDefault(require("is-online"));
const p_wait_for_1 = __importDefault(require("p-wait-for"));
function showWaitDialog() {
    electron_1.dialog.showMessageBox({
        message: 'You appear to be offline. Caprine requires a working internet connection.',
        detail: 'Do you want to wait?',
        buttons: ['Wait', 'Quit'],
        defaultId: 0,
        cancelId: 1
    }, response => {
        if (response === 1) {
            electron_1.app.quit();
        }
    });
}
exports.default = async () => {
    if (!(await is_online_1.default())) {
        const connectivityTimeout = setTimeout(showWaitDialog, 15000);
        await p_wait_for_1.default(is_online_1.default, { interval: 1000 });
        clearTimeout(connectivityTimeout);
    }
};
//# sourceMappingURL=ensure-online.js.map