"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScreenshotAction = void 0;
const index_js_1 = require("../model/index.js");
class ScreenshotAction extends index_js_1.Action {
    constructor() {
        super(...arguments);
        this.fullPage = false;
        this.isPublic = true;
        this.minWidth = 0;
        this.maxWidth = 5000;
        this.minHeight = 0;
        this.maxHeight = 10000;
        this.scrollToTop = true;
        this.quality = 50;
    }
    async exec() {
        if (this.scrollToTop) {
            await this.$page.evaluate(() => {
                window.scrollTo(0, 0);
            });
        }
        await this.$reporter.sendScreenshot('info', {
            label: this.label,
            isPublic: this.isPublic,
            fullPage: this.fullPage,
            minHeight: this.minHeight,
            maxHeight: this.maxHeight,
            minWidth: this.minWidth,
            maxWidth: this.maxWidth,
            quality: this.quality,
        });
    }
}
ScreenshotAction.$type = 'Page.screenshot';
ScreenshotAction.$icon = 'fas fa-camera';
ScreenshotAction.$help = `
Captures the screenshot and sends it to the Job.

### Parameters

- full page: emulate viewport to match content width and content height of current webpage,
  which generally results in full page screenshot
  (unless the page uses scrollable containers with fixed width or height)
- public: mark screenshots as public
- min width: minimum width for full page emulation
- max width: maximum width for full page emulation
- min height: minimum height for full page emulation
- max height: maximum height for full page emulation
- scroll to top: scroll the page to the top before taking a screenshot
- quality: compression quality from range [0..100] (jpeg only)

### Use For

- taking debug screenshots
- sending public screenshots
`;
__decorate([
    index_js_1.params.Boolean(),
    __metadata("design:type", Boolean)
], ScreenshotAction.prototype, "fullPage", void 0);
__decorate([
    index_js_1.params.Boolean(),
    __metadata("design:type", Boolean)
], ScreenshotAction.prototype, "isPublic", void 0);
__decorate([
    index_js_1.params.Number({ min: 0 }),
    __metadata("design:type", Number)
], ScreenshotAction.prototype, "minWidth", void 0);
__decorate([
    index_js_1.params.Number({ min: 0 }),
    __metadata("design:type", Number)
], ScreenshotAction.prototype, "maxWidth", void 0);
__decorate([
    index_js_1.params.Number({ min: 0 }),
    __metadata("design:type", Number)
], ScreenshotAction.prototype, "minHeight", void 0);
__decorate([
    index_js_1.params.Number({ min: 0 }),
    __metadata("design:type", Number)
], ScreenshotAction.prototype, "maxHeight", void 0);
__decorate([
    index_js_1.params.Boolean(),
    __metadata("design:type", Boolean)
], ScreenshotAction.prototype, "scrollToTop", void 0);
__decorate([
    index_js_1.params.Number({ min: 0, max: 100 }),
    __metadata("design:type", Number)
], ScreenshotAction.prototype, "quality", void 0);
exports.ScreenshotAction = ScreenshotAction;
//# sourceMappingURL=Page.screenshot.js.map