"use strict";
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());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerErrorLogBoardPosts = registerErrorLogBoardPosts;
var node_crypto_1 = require("node:crypto");
var client_js_1 = require("../db/client.js");
var board_service_js_1 = require("./board-service.js");
var error_log_service_js_1 = require("./error-log-service.js");
var plan_service_js_1 = require("./plan-service.js");
var DEFAULT_ERROR_LOG_PLAN_GROUP_LIMIT = 6;
var ERROR_LOG_BOARD_POST_MARKER_PREFIX = '<!-- error-log-plan-work-id:';
function normalizeDateBoundary(value) {
    if (!value) {
        return null;
    }
    var date = value instanceof Date ? value : new Date(String(value));
    return Number.isNaN(date.getTime()) ? null : date;
}
function formatIsoTimestamp(value) {
    var date = normalizeDateBoundary(value);
    return date ? date.toISOString() : String(value !== null && value !== void 0 ? value : '');
}
function normalizeRequestPathGroup(requestPath) {
    var normalized = String(requestPath !== null && requestPath !== void 0 ? requestPath : '')
        .trim()
        .toLowerCase()
        .replace(/\?.*$/u, '')
        .replace(/\/\d+(?=\/|$)/gu, '/:id')
        .replace(/[0-9a-f]{8,}(?=\/|$)/giu, ':id');
    if (!normalized) {
        return 'unknown';
    }
    var segments = normalized
        .split('/')
        .map(function (segment) { return segment.trim(); })
        .filter(Boolean)
        .slice(0, 3);
    return segments.length > 0 ? "/".concat(segments.join('/')) : normalized;
}
function buildErrorLogPlanFingerprint(log) {
    var _a, _b;
    return (0, node_crypto_1.createHash)('sha1')
        .update([
        String((_a = log.source) !== null && _a !== void 0 ? _a : '').trim().toLowerCase(),
        String((_b = log.errorType) !== null && _b !== void 0 ? _b : '').trim().toLowerCase(),
        log.statusCode == null ? '' : String(log.statusCode),
    ].join('||'))
        .digest('hex')
        .slice(0, 12);
}
function buildErrorLogPlanWorkId(log) {
    return "error-fix-".concat(buildErrorLogPlanFingerprint(log));
}
function buildErrorLogPlanCandidates(logs) {
    var _a, _b, _c, _d, _e, _f;
    var grouped = new Map();
    for (var _i = 0, logs_1 = logs; _i < logs_1.length; _i++) {
        var log = logs_1[_i];
        var fingerprint = (0, node_crypto_1.createHash)('sha1')
            .update([
            String((_a = log.source) !== null && _a !== void 0 ? _a : '').trim().toLowerCase(),
            String((_b = log.errorType) !== null && _b !== void 0 ? _b : '').trim().toLowerCase(),
            String((_c = log.errorName) !== null && _c !== void 0 ? _c : '').trim().toLowerCase(),
            log.statusCode == null ? '' : String(log.statusCode),
            normalizeRequestPathGroup(log.requestPath),
        ].join('||'))
            .digest('hex')
            .slice(0, 12);
        var createdAtMs = (_e = (_d = normalizeDateBoundary(log.createdAt)) === null || _d === void 0 ? void 0 : _d.getTime()) !== null && _e !== void 0 ? _e : 0;
        var existing = grouped.get(fingerprint);
        var requestPathGroup = normalizeRequestPathGroup(log.requestPath);
        var errorMessage = String((_f = log.errorMessage) !== null && _f !== void 0 ? _f : '').trim();
        if (!existing) {
            grouped.set(fingerprint, {
                sample: log,
                count: 1,
                firstCreatedAt: log.createdAt,
                firstTimeMs: createdAtMs,
                lastCreatedAt: log.createdAt,
                lastTimeMs: createdAtMs,
                requestPathGroup: requestPathGroup,
                requestPaths: log.requestPath ? new Set([String(log.requestPath).trim()]) : new Set(),
                errorMessages: errorMessage ? new Set([errorMessage]) : new Set(),
                errorNames: log.errorName ? new Set([String(log.errorName).trim()]) : new Set(),
                sampleLogIds: log.id != null ? [Number(log.id)] : [],
            });
            continue;
        }
        existing.count += 1;
        if (log.requestPath) {
            existing.requestPaths.add(String(log.requestPath).trim());
        }
        if (errorMessage) {
            existing.errorMessages.add(errorMessage);
        }
        if (log.errorName) {
            existing.errorNames.add(String(log.errorName).trim());
        }
        if (log.id != null && existing.sampleLogIds.length < 5) {
            existing.sampleLogIds.push(Number(log.id));
        }
        if (createdAtMs <= existing.firstTimeMs) {
            existing.firstCreatedAt = log.createdAt;
            existing.firstTimeMs = createdAtMs;
        }
        if (createdAtMs >= existing.lastTimeMs) {
            existing.sample = log;
            existing.lastCreatedAt = log.createdAt;
            existing.lastTimeMs = createdAtMs;
        }
    }
    return __spreadArray([], grouped.entries(), true).map(function (_a) {
        var _b, _c, _d;
        var fingerprint = _a[0], entry = _a[1];
        return ({
            fingerprint: fingerprint,
            workId: buildErrorLogPlanWorkId(entry.sample),
            source: String((_b = entry.sample.source) !== null && _b !== void 0 ? _b : ''),
            sourceLabel: entry.sample.sourceLabel ? String(entry.sample.sourceLabel) : null,
            errorType: String((_c = entry.sample.errorType) !== null && _c !== void 0 ? _c : ''),
            errorName: entry.sample.errorName ? String(entry.sample.errorName) : null,
            errorMessage: String((_d = entry.sample.errorMessage) !== null && _d !== void 0 ? _d : ''),
            requestPath: entry.sample.requestPath ? String(entry.sample.requestPath) : null,
            requestPathGroup: entry.requestPathGroup,
            requestPaths: __spreadArray([], entry.requestPaths, true).filter(Boolean).slice(0, 5),
            statusCode: entry.sample.statusCode == null ? null : Number(entry.sample.statusCode),
            count: entry.count,
            firstCreatedAt: entry.firstCreatedAt,
            lastCreatedAt: entry.lastCreatedAt,
            sampleLogId: entry.sample.id == null ? null : Number(entry.sample.id),
            sampleLogIds: entry.sampleLogIds,
            errorNames: __spreadArray([], entry.errorNames, true).filter(Boolean).slice(0, 5),
            representativeMessages: __spreadArray([], entry.errorMessages, true).filter(Boolean).slice(0, 5),
        });
    })
        .sort(function (left, right) {
        var _a, _b, _c, _d, _e, _f;
        if (right.count !== left.count) {
            return right.count - left.count;
        }
        var leftLastTime = (_b = (_a = normalizeDateBoundary(left.lastCreatedAt)) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0;
        var rightLastTime = (_d = (_c = normalizeDateBoundary(right.lastCreatedAt)) === null || _c === void 0 ? void 0 : _c.getTime()) !== null && _d !== void 0 ? _d : 0;
        if (rightLastTime !== leftLastTime) {
            return rightLastTime - leftLastTime;
        }
        return Number((_e = right.sampleLogId) !== null && _e !== void 0 ? _e : 0) - Number((_f = left.sampleLogId) !== null && _f !== void 0 ? _f : 0);
    });
}
function mergeErrorLogPlanCandidateBucket(bucket, bucketIndex) {
    var sortedBucket = __spreadArray([], bucket, true).sort(function (left, right) {
        var _a, _b;
        if (right.count !== left.count) {
            return right.count - left.count;
        }
        return String((_a = left.workId) !== null && _a !== void 0 ? _a : '').localeCompare(String((_b = right.workId) !== null && _b !== void 0 ? _b : ''));
    });
    var representative = sortedBucket[0];
    var uniqueFingerprints = __spreadArray([], new Set(sortedBucket.map(function (candidate) { return candidate.fingerprint; }).filter(Boolean)), true).sort();
    var mergedFingerprint = (0, node_crypto_1.createHash)('sha1')
        .update(uniqueFingerprints.join('||'))
        .digest('hex')
        .slice(0, 12);
    var firstCreatedAt = sortedBucket
        .map(function (candidate) { var _a, _b; return (_b = (_a = normalizeDateBoundary(candidate.firstCreatedAt)) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY; })
        .reduce(function (min, value) { return Math.min(min, value); }, Number.POSITIVE_INFINITY);
    var lastCreatedAt = sortedBucket
        .map(function (candidate) { var _a, _b; return (_b = (_a = normalizeDateBoundary(candidate.lastCreatedAt)) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0; })
        .reduce(function (max, value) { return Math.max(max, value); }, 0);
    var requestPaths = __spreadArray([], new Set(sortedBucket.flatMap(function (candidate) { var _a; return (_a = candidate.requestPaths) !== null && _a !== void 0 ? _a : []; }).filter(Boolean)), true).slice(0, 8);
    var representativeMessages = __spreadArray([], new Set(sortedBucket.flatMap(function (candidate) { var _a; return (_a = candidate.representativeMessages) !== null && _a !== void 0 ? _a : []; }).filter(Boolean)), true).slice(0, 8);
    var errorNames = __spreadArray([], new Set(sortedBucket.flatMap(function (candidate) { var _a; return (_a = candidate.errorNames) !== null && _a !== void 0 ? _a : []; }).filter(Boolean)), true).slice(0, 8);
    var groupedScopes = sortedBucket
        .slice(0, 8)
        .map(function (candidate) {
        var parts = [candidate.sourceLabel || candidate.source, candidate.errorType];
        if (candidate.requestPathGroup && candidate.requestPathGroup !== 'unknown') {
            parts.push(candidate.requestPathGroup);
        }
        return parts.filter(Boolean).join(' / ');
    })
        .filter(Boolean);
    return {
        fingerprint: mergedFingerprint,
        workId: "error-fix-bundle-".concat(mergedFingerprint),
        source: representative.source,
        sourceLabel: representative.sourceLabel,
        errorType: sortedBucket.length > 1 ? '다중 에러 묶음' : representative.errorType,
        errorName: representative.errorName,
        errorMessage: representative.errorMessage,
        requestPath: representative.requestPath,
        requestPathGroup: representative.requestPathGroup,
        requestPaths: requestPaths,
        statusCode: representative.statusCode,
        count: sortedBucket.reduce(function (sum, candidate) { var _a; return sum + Number((_a = candidate.count) !== null && _a !== void 0 ? _a : 0); }, 0),
        firstCreatedAt: Number.isFinite(firstCreatedAt) ? new Date(firstCreatedAt).toISOString() : representative.firstCreatedAt,
        lastCreatedAt: lastCreatedAt > 0 ? new Date(lastCreatedAt).toISOString() : representative.lastCreatedAt,
        sampleLogId: representative.sampleLogId,
        sampleLogIds: __spreadArray([], new Set(sortedBucket.flatMap(function (candidate) { var _a; return (_a = candidate.sampleLogIds) !== null && _a !== void 0 ? _a : []; }).filter(function (value) { return value != null; })), true).slice(0, 8),
        errorNames: errorNames,
        representativeMessages: representativeMessages,
        groupedScopes: groupedScopes,
        groupedCandidateCount: sortedBucket.length,
    };
}
function coalesceErrorLogPlanCandidates(candidates, maxGroups) {
    if (maxGroups === void 0) { maxGroups = DEFAULT_ERROR_LOG_PLAN_GROUP_LIMIT; }
    var sortedCandidates = __spreadArray([], candidates, true).sort(function (left, right) {
        var _a, _b;
        if (right.count !== left.count) {
            return right.count - left.count;
        }
        return String((_a = left.workId) !== null && _a !== void 0 ? _a : '').localeCompare(String((_b = right.workId) !== null && _b !== void 0 ? _b : ''));
    });
    if (sortedCandidates.length <= maxGroups) {
        return sortedCandidates;
    }
    var bucketSize = Math.ceil(sortedCandidates.length / maxGroups);
    var merged = [];
    for (var index = 0; index < sortedCandidates.length; index += bucketSize) {
        var bucket = sortedCandidates.slice(index, index + bucketSize);
        if (bucket.length === 0) {
            continue;
        }
        merged.push(mergeErrorLogPlanCandidateBucket(bucket, merged.length + 1));
    }
    return merged.slice(0, maxGroups);
}
function filterLogsWithinRange(logs, rangeStart, rangeEnd) {
    var startTime = rangeStart.getTime();
    var endTime = rangeEnd.getTime();
    return logs.filter(function (log) {
        var _a;
        var createdAtMs = (_a = normalizeDateBoundary(log.createdAt)) === null || _a === void 0 ? void 0 : _a.getTime();
        return createdAtMs != null && createdAtMs >= startTime && createdAtMs <= endTime;
    });
}
function formatErrorLogPlanNote(candidate, rangeStart, rangeEnd) {
    var _a;
    var lines = [
        "\uC870\uD68C \uAD6C\uAC04: ".concat(formatIsoTimestamp(rangeStart), " ~ ").concat(formatIsoTimestamp(rangeEnd)),
        "\uBC1C\uC0DD \uAC74\uC218: ".concat(candidate.count, "\uAC74"),
        "\uCD5C\uADFC \uBC1C\uC0DD: ".concat(formatIsoTimestamp(candidate.lastCreatedAt)),
        "\uCD5C\uCD08 \uBC1C\uC0DD: ".concat(formatIsoTimestamp(candidate.firstCreatedAt)),
        "\uC5D0\uB7EC \uC720\uD615: ".concat(candidate.errorType),
    ];
    if (candidate.errorName) {
        lines.push("\uC5D0\uB7EC \uC774\uB984: ".concat(candidate.errorName));
    }
    if (candidate.sourceLabel || candidate.source) {
        lines.push("\uBC1C\uC0DD \uC704\uCE58: ".concat(candidate.sourceLabel || candidate.source));
    }
    if (candidate.groupedCandidateCount && candidate.groupedCandidateCount > 1) {
        lines.push("\uBB36\uC778 \uC5D0\uB7EC \uADF8\uB8F9: ".concat(candidate.groupedCandidateCount, "\uAC1C"));
    }
    if (candidate.requestPathGroup && candidate.requestPathGroup !== 'unknown') {
        lines.push("\uC8FC\uC694 \uACBD\uB85C \uADF8\uB8F9: ".concat(candidate.requestPathGroup));
    }
    if (Array.isArray(candidate.requestPaths) && candidate.requestPaths.length > 0) {
        lines.push("\uB300\uD45C \uACBD\uB85C: ".concat(candidate.requestPaths.join(', ')));
    }
    if (candidate.statusCode != null) {
        lines.push("\uC0C1\uD0DC \uCF54\uB4DC: ".concat(candidate.statusCode));
    }
    if (Array.isArray(candidate.representativeMessages) && candidate.representativeMessages.length > 0) {
        lines.push('대표 메시지:');
        lines.push.apply(lines, candidate.representativeMessages.map(function (message, index) { return "".concat(index + 1, ". ").concat(message); }));
    }
    else {
        lines.push("\uB300\uD45C \uBA54\uC2DC\uC9C0: ".concat(String((_a = candidate.errorMessage) !== null && _a !== void 0 ? _a : '').trim()));
    }
    if (Array.isArray(candidate.sampleLogIds) && candidate.sampleLogIds.length > 0) {
        lines.push("\uB300\uD45C \uB85C\uADF8 ID: ".concat(candidate.sampleLogIds.join(', ')));
    }
    else {
        lines.push("\uB300\uD45C \uB85C\uADF8 ID: ".concat(candidate.sampleLogId));
    }
    if (Array.isArray(candidate.groupedScopes) && candidate.groupedScopes.length > 0) {
        lines.push('묶인 에러 범위:');
        lines.push.apply(lines, candidate.groupedScopes.map(function (scope, index) { return "".concat(index + 1, ". ").concat(scope); }));
    }
    lines.push('');
    lines.push('처리 요청:');
    lines.push('1. 재현 경로와 영향 범위를 확인합니다.');
    lines.push('2. 수정이 필요한 경우 별도 Plan으로 소스 작업을 진행합니다.');
    lines.push('3. 테스트와 재발 방지 필요 여부를 검토합니다.');
    return lines.join('\n');
}
function buildBoardPostMarker(workId) {
    return "".concat(ERROR_LOG_BOARD_POST_MARKER_PREFIX).concat(workId, " -->");
}
function buildErrorLogBoardPostTitle(candidate) {
    var scope = candidate.requestPathGroup && candidate.requestPathGroup !== 'unknown'
        ? " ".concat(candidate.requestPathGroup)
        : '';
    var title = "\uC5D0\uB7EC\uB85C\uADF8 \uC870\uCE58 \uACC4\uD68D: ".concat(candidate.errorType).concat(scope).replace(/\s+/g, ' ').trim();
    return title.length > 200 ? "".concat(title.slice(0, 197).trimEnd(), "...") : title;
}
function buildErrorLogBoardPostContent(candidate, rangeStart, rangeEnd) {
    var detailNote = formatErrorLogPlanNote(candidate, rangeStart, rangeEnd);
    return [
        buildBoardPostMarker(candidate.workId),
        "# ".concat(buildErrorLogBoardPostTitle(candidate)),
        '',
        detailNote,
    ].join('\n');
}
function registerErrorLogBoardPosts(args) {
    return __awaiter(this, void 0, void 0, function () {
        var rangeEnd, rangeStart, maxGroups, _a, errorLogs, existingBoardPosts, recentLogs, rawCandidates, candidates, createdPosts, skippedPosts, _loop_1, _i, candidates_1, candidate;
        var _b, _c, _d;
        return __generator(this, function (_e) {
            switch (_e.label) {
                case 0: return [4 /*yield*/, (0, plan_service_js_1.ensurePlanTable)()];
                case 1:
                    _e.sent();
                    rangeEnd = (_b = args === null || args === void 0 ? void 0 : args.rangeEnd) !== null && _b !== void 0 ? _b : new Date();
                    rangeStart = (_c = args === null || args === void 0 ? void 0 : args.rangeStart) !== null && _c !== void 0 ? _c : new Date(rangeEnd.getTime() - 24 * 60 * 60 * 1000);
                    maxGroups = (_d = args === null || args === void 0 ? void 0 : args.maxGroups) !== null && _d !== void 0 ? _d : DEFAULT_ERROR_LOG_PLAN_GROUP_LIMIT;
                    return [4 /*yield*/, Promise.all([
                            (0, error_log_service_js_1.listErrorLogs)(200),
                            (0, board_service_js_1.listBoardPosts)(),
                        ])];
                case 2:
                    _a = _e.sent(), errorLogs = _a[0], existingBoardPosts = _a[1];
                    recentLogs = filterLogsWithinRange(errorLogs, rangeStart, rangeEnd);
                    rawCandidates = buildErrorLogPlanCandidates(recentLogs);
                    candidates = coalesceErrorLogPlanCandidates(rawCandidates, maxGroups);
                    createdPosts = [];
                    skippedPosts = [];
                    _loop_1 = function (candidate) {
                        var marker, existingBoardPost, latestOpenPlan, createdPost;
                        return __generator(this, function (_f) {
                            switch (_f.label) {
                                case 0:
                                    marker = buildBoardPostMarker(candidate.workId);
                                    existingBoardPost = existingBoardPosts.find(function (post) { var _a; return String((_a = post.content) !== null && _a !== void 0 ? _a : '').includes(marker); });
                                    if (existingBoardPost) {
                                        skippedPosts.push({
                                            workId: candidate.workId,
                                            boardPostId: existingBoardPost.id,
                                            reason: "\uAE30\uC874 \uAC8C\uC2DC\uAE00 #".concat(existingBoardPost.id, "\uAC00 \uC788\uC2B5\uB2C8\uB2E4."),
                                        });
                                        return [2 /*return*/, "continue"];
                                    }
                                    return [4 /*yield*/, (0, client_js_1.db)(plan_service_js_1.PLAN_TABLE)
                                            .select(['id', 'status'])
                                            .where({ work_id: candidate.workId })
                                            .whereNot({ status: '완료' })
                                            .orderBy('id', 'desc')
                                            .first()];
                                case 1:
                                    latestOpenPlan = _f.sent();
                                    if (latestOpenPlan) {
                                        skippedPosts.push({
                                            workId: candidate.workId,
                                            planId: Number(latestOpenPlan.id),
                                            reason: "\uAE30\uC874 \uBBF8\uC644\uB8CC Plan #".concat(latestOpenPlan.id, "\uAC00 \uC788\uC2B5\uB2C8\uB2E4."),
                                        });
                                        return [2 /*return*/, "continue"];
                                    }
                                    return [4 /*yield*/, (0, board_service_js_1.createBoardPost)({
                                            title: buildErrorLogBoardPostTitle(candidate),
                                            content: buildErrorLogBoardPostContent(candidate, rangeStart, rangeEnd),
                                            attachments: [],
                                            automationType: 'none',
                                            automationContextIds: [],
                                            requestExecutionMode: 'all_at_once',
                                            requestItems: [],
                                        })];
                                case 2:
                                    createdPost = _f.sent();
                                    createdPosts.push({
                                        postId: createdPost.id,
                                        title: createdPost.title,
                                        workId: candidate.workId,
                                        count: candidate.count,
                                    });
                                    return [2 /*return*/];
                            }
                        });
                    };
                    _i = 0, candidates_1 = candidates;
                    _e.label = 3;
                case 3:
                    if (!(_i < candidates_1.length)) return [3 /*break*/, 6];
                    candidate = candidates_1[_i];
                    return [5 /*yield**/, _loop_1(candidate)];
                case 4:
                    _e.sent();
                    _e.label = 5;
                case 5:
                    _i++;
                    return [3 /*break*/, 3];
                case 6: return [2 /*return*/, {
                        rangeStart: rangeStart,
                        rangeEnd: rangeEnd,
                        recentLogs: recentLogs,
                        rawCandidates: rawCandidates,
                        candidates: candidates,
                        createdPosts: createdPosts,
                        skippedPosts: skippedPosts,
                    }];
            }
        });
    });
}
