'use strict';

var config = require('@backstage/config');

function readFrequency(config$1, key) {
  const value = config$1.get(key);
  if (typeof value === "object" && value.cron) {
    return value;
  }
  if (typeof value === "object" && value.trigger === "manual") {
    return { trigger: "manual" };
  }
  return config.readDurationFromConfig(config$1, { key });
}
function readSchedulerServiceTaskScheduleDefinitionFromConfig(config$1) {
  const frequency = readFrequency(config$1, "frequency");
  const timeout = config.readDurationFromConfig(config$1, { key: "timeout" });
  const initialDelay = config$1.has("initialDelay") ? config.readDurationFromConfig(config$1, { key: "initialDelay" }) : void 0;
  const scope = config$1.getOptionalString("scope");
  if (scope && !["global", "local"].includes(scope)) {
    throw new Error(
      `Only "global" or "local" are allowed for TaskScheduleDefinition.scope, but got: ${scope}`
    );
  }
  return {
    frequency,
    timeout,
    initialDelay,
    scope
  };
}

exports.readSchedulerServiceTaskScheduleDefinitionFromConfig = readSchedulerServiceTaskScheduleDefinitionFromConfig;
//# sourceMappingURL=SchedulerService.cjs.js.map
