class o {
  constructor(i, t) {
    this.learningRate = i, this.config = t, this.startLearningRate = i, t.step !== void 0 && (this.step = t.step);
  }
  step = 0;
  startLearningRate;
  serializeConfig() {
    return {
      ...this.config,
      step: this.step
    };
  }
  updateConfig(i, t) {
    this.config = { ...this.config, ...i }, t !== void 0 && (this.startLearningRate = t);
  }
  get lr() {
    return this.learningRate;
  }
  getNextLR() {
    const i = this.step;
    if (this.config.warmupSteps > 0 && i < this.config.warmupSteps) {
      const r = (i + 1) / this.config.warmupSteps, e = this.startLearningRate * r;
      return this.learningRate = e, this.step++, e;
    }
    const t = this.config.epochSteps * this.config.decayEpochs;
    if (i >= t || t <= this.config.warmupSteps)
      return this.learningRate = this.config.minLearningRate, this.step++, this.config.minLearningRate;
    const n = (i - this.config.warmupSteps) / (t - this.config.warmupSteps), a = 0.5 * (1 + Math.cos(Math.PI * n)), s = this.config.minLearningRate + a * (this.startLearningRate - this.config.minLearningRate);
    return this.learningRate = s, this.step++, s;
  }
}
export {
  o as default
};
