"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compareIssuesDeterministically = compareIssuesDeterministically;
exports.resolveSingleServiceAssignee = resolveSingleServiceAssignee;
const issue_id_1 = require("../../../issues/issue-id");
function compareIssuesDeterministically(left, right) {
    const leftNumeric = (0, issue_id_1.parseNumericIssueId)(left.id);
    const rightNumeric = (0, issue_id_1.parseNumericIssueId)(right.id);
    if (leftNumeric !== null &&
        rightNumeric !== null &&
        leftNumeric !== rightNumeric) {
        return leftNumeric - rightNumeric;
    }
    return left.id.localeCompare(right.id);
}
async function resolveSingleServiceAssignee(currentUserLogin, ticketTracker) {
    const assignee = currentUserLogin?.trim() ||
        (await ticketTracker.getAuthenticatedUserLogin()).trim();
    if (assignee.length === 0) {
        throw new Error("Child issue publication requires a single service assignee.");
    }
    return assignee;
}
