import { SfError } from "@salesforce/core";
import c from "chalk";
import { getCurrentGitBranch, uxLog } from "../utils/index.js";
import { GitProvider } from "../gitProvider/index.js";
export class TicketProviderRoot {
    isActive = false;
    token;
    getLabel() {
        throw new SfError("getLabel should be implemented on this call");
    }
    async collectTicketsInfo(tickets) {
        uxLog("warning", this, c.yellow("collectTicketsInfo is not implemented on " + this.getLabel()));
        return tickets;
    }
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    async postDeploymentComments(tickets, _org, _pullRequestInfo) {
        uxLog("warning", this, c.yellow("postDeploymentComments is not implemented on " + this.getLabel()));
        return tickets;
    }
    async getDeploymentTag() {
        const currentGitBranch = await getCurrentGitBranch() || "";
        let tag = currentGitBranch.toUpperCase() + "_DEPLOYED";
        if (GitProvider.isDeployBeforeMerge()) {
            const prInfo = await GitProvider.getPullRequestInfo({ useCache: true });
            const targetBranch = prInfo?.targetBranch || process.env.FORCE_TARGET_BRANCH;
            if (targetBranch) {
                tag = targetBranch.toUpperCase() + "_DEPLOYED";
            }
        }
        if (process.env?.DEPLOYED_TAG_TEMPLATE && !(process.env?.DEPLOYED_TAG_TEMPLATE || "").includes("$(")) {
            const branchToUse = tag.replace("_DEPLOYED", "");
            tag = process.env?.DEPLOYED_TAG_TEMPLATE.replace("{BRANCH}", branchToUse);
        }
        return tag;
    }
}
//# sourceMappingURL=ticketProviderRoot.js.map