import {
  parseXrayFormat
} from "./chunk-LW2NMHDW.js";
import {
  RECALL_DISCLOSURE_LEVELS,
  isRecallDisclosure
} from "./chunk-43EKP2UK.js";

// src/recall-xray-cli.ts
function parseXrayDisclosureFlag(value) {
  if (value === void 0 || value === null) return void 0;
  if (typeof value !== "string" || !isRecallDisclosure(value)) {
    throw new Error(
      `--disclosure expects one of ${RECALL_DISCLOSURE_LEVELS.join(", ")}; got ${JSON.stringify(value)}`
    );
  }
  return value;
}
function parseXrayBudgetFlag(value) {
  if (value === void 0 || value === null) return void 0;
  const parsed = typeof value === "number" ? value : Number(value);
  if (!Number.isFinite(parsed) || parsed <= 0 || !Number.isInteger(parsed)) {
    throw new Error(
      `--budget expects a positive integer; got ${JSON.stringify(value)}`
    );
  }
  return parsed;
}
function parseXrayCliOptions(rawQuery, options) {
  if (typeof rawQuery !== "string" || rawQuery.trim().length === 0) {
    throw new Error("xray: <query> is required and must be non-empty");
  }
  const format = parseXrayFormat(options.format);
  const budget = parseXrayBudgetFlag(options.budget);
  const namespace = typeof options.namespace === "string" && options.namespace.trim().length > 0 ? options.namespace.trim() : void 0;
  const outPath = typeof options.out === "string" && options.out.trim().length > 0 ? options.out.trim() : void 0;
  const disclosure = parseXrayDisclosureFlag(options.disclosure);
  return {
    query: rawQuery,
    format,
    ...budget !== void 0 ? { budget } : {},
    ...namespace !== void 0 ? { namespace } : {},
    ...outPath !== void 0 ? { outPath } : {},
    ...disclosure !== void 0 ? { disclosure } : {}
  };
}

export {
  parseXrayDisclosureFlag,
  parseXrayBudgetFlag,
  parseXrayCliOptions
};
//# sourceMappingURL=chunk-SMA4IMHV.js.map