"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const os_family_1 = __importDefault(require("os-family")); const find_window_1 = __importDefault(require("./find-window")); const exec_1 = require("../utils/exec"); const binaries_1 = __importDefault(require("../binaries")); function getBoundsFromString(boundsString) { return boundsString.split('\n'); } async function getWindowBounds(processId, windowId) { var boundsString = await exec_1.execFile(binaries_1.default.getWindowBounds, [processId, windowId]); return getBoundsFromString(boundsString); } async function getWindowMaxBounds(processId, windowId) { var windowBounds = await getWindowBounds(processId, windowId); var maxBoundsString = await exec_1.execFile(binaries_1.default.getWindowMaxBounds, windowBounds); return getBoundsFromString(maxBoundsString); } async function maximizeWindowMac(windowDescription) { var { processId, windowId } = windowDescription; var windowBounds = await getWindowMaxBounds(processId, windowId); await exec_1.execFile(binaries_1.default.setWindowBounds, [processId, windowId].concat(windowBounds)); } /** * Maximizes the specified browser window. * @function * @async * @name maximize * @param {string | object} windowDescriptor - The title of the web page opened in the window or a descriptor returned by findWindow. **/ async function default_1(windowDescriptor) { var windowDescription = typeof windowDescriptor === 'string' ? await find_window_1.default(windowDescriptor) : windowDescriptor; if (!windowDescription) return; var commandArguments = void 0; if (os_family_1.default.win) commandArguments = [windowDescription.hwnd]; else if (os_family_1.default.linux) commandArguments = [windowDescription.windowId]; else if (os_family_1.default.mac) { await maximizeWindowMac(windowDescription); return; } else return; await exec_1.execFile(binaries_1.default.maximize, commandArguments); } exports.default = default_1; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF4aW1pemUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXBpL21heGltaXplLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsMERBQTJCO0FBQzNCLGdFQUF1QztBQUN2Qyx3Q0FBeUM7QUFDekMsMkRBQW1DO0FBRW5DLFNBQ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