import { r as ux } from "./cli-B86kvKcR.mjs";
import { i as updateIssue } from "./issues-Db9BW4-6.mjs";
import process from "node:process";
import { defineCommand } from "citty";
//#region src/commands/issue/update.ts
async function runIssueUpdateCommand(options) {
	try {
		const issue = await ux.running("Updating issue", async () => await updateIssue(options.selector, options));
		ux.log.success(`Updated ${issue.hqId ?? issue.id}.`);
		if (options.json) {
			process.stdout.write(`${JSON.stringify(issue, null, 2)}\n`);
			return;
		}
		console.log(issue.hqId ?? issue.id);
		console.log(issue.id);
		if (issue.url) console.log(issue.url);
	} catch (error) {
		ux.handleError(error);
	}
}
var update_default = defineCommand({
	meta: {
		name: "update",
		description: "Update or normalize an HQ Rhythm issue"
	},
	args: {
		issue: {
			type: "positional",
			required: true,
			description: "Issue selector such as ISS-7 or a Notion page id"
		},
		affected: {
			type: "string",
			description: "Comma-separated affected workspaces"
		},
		artifacts: {
			type: "string",
			description: "Comma-separated artifacts"
		},
		blockers: {
			type: "string",
			description: "Comma-separated blocking issue selectors"
		},
		condition: {
			type: "string",
			description: "Issue condition"
		},
		constraints: {
			type: "string",
			description: "Issue constraints section"
		},
		instance: {
			type: "string",
			description: "Instance relation name"
		},
		intent: {
			type: "string",
			description: "Issue intent section"
		},
		json: {
			type: "boolean",
			description: "Output machine-readable JSON"
		},
		kind: {
			type: "string",
			description: "Issue kind"
		},
		level: {
			type: "string",
			description: "Issue level"
		},
		origin: {
			type: "string",
			description: "Origin workspace name"
		},
		owner: {
			type: "string",
			description: "Owner"
		},
		parent: {
			type: "string",
			description: "Parent issue selector"
		},
		problem: {
			type: "string",
			description: "Issue problem section"
		},
		progress: {
			type: "string",
			description: "Progress status"
		},
		ref: {
			type: "string",
			description: "External or session reference"
		},
		related: {
			type: "string",
			description: "Comma-separated related issue selectors"
		},
		reporter: {
			type: "string",
			description: "Reporter class"
		},
		scope: {
			type: "string",
			description: "Issue scope section"
		},
		stage: {
			type: "string",
			description: "Issue stage or Level/Stage value"
		},
		success: {
			type: "string",
			description: "Issue success section"
		},
		title: {
			type: "string",
			description: "Issue title"
		},
		url: {
			type: "string",
			description: "External URL"
		},
		workspace: {
			type: "string",
			description: "Owning workspace name"
		}
	},
	async run({ args }) {
		await runIssueUpdateCommand({
			selector: args.issue,
			affected: splitCsv(args.affected),
			artifacts: splitCsv(args.artifacts),
			blockers: splitCsv(args.blockers),
			condition: args.condition,
			constraints: args.constraints,
			instance: args.instance,
			intent: args.intent,
			json: args.json,
			kind: args.kind,
			level: args.level,
			origin: args.origin,
			owner: args.owner,
			parent: args.parent,
			problem: args.problem,
			progress: args.progress,
			ref: args.ref,
			related: splitCsv(args.related),
			reporter: args.reporter,
			scope: args.scope,
			stage: args.stage,
			success: args.success,
			title: args.title,
			url: args.url,
			workspace: args.workspace
		});
		if (!process.exitCode) process.exit(0);
	}
});
function splitCsv(value) {
	return value ? value.split(",").map((item) => item.trim()).filter(Boolean) : void 0;
}
//#endregion
export { update_default as default };

//# sourceMappingURL=update-CauAYDw5.mjs.map