"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
postscriptum.plugin('ps-log', (processor, options) => {
    const { util } = postscriptum;
    const { logger } = util;
    if (options.logEvents)
        options.logEvents.forEach((eventName) => {
            processor.on(eventName, function (...args) {
                if (args.length)
                    logger.debug(eventName, args.join(','));
                else
                    logger.debug(eventName);
            });
        });
    if (options.logBreakPoints) {
        const paths = [];
        processor.on('page-end', function ({ page }) {
            const path = [];
            path.push(this.currentBreakPoint.offset);
            if (this.currentBreakPoint.container == page.body)
                [path];
            let current = this.currentBreakPoint.container.parentNode;
            while (current && page.body.contains(current)) {
                path.push(Array.prototype.indexOf.call(current.parentNode.childNodes, current));
                current = current.parentNode;
            }
            paths.push(path.reverse().join('/'));
        });
        processor.on('end', function () {
            logger.debug(paths.join(', '));
        });
    }
}, {
    logEvents: [
        'start', 'end', 'pagination-start', 'pagination-end', 'sequence-start', 'sequence-end',
        'page-start', 'page-end', 'overflow-detected', 'no-overflow', 'break-point-invalid',
        'valid-break-point', 'new-break-point-to-valid'
    ],
    logBreakPoints: false
});
