/*
 *
 * Copyright (c) 2025. Jeffery Hsu - Achievement Report Generator
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 *
 */

import { IGoal, IGoalWeight } from '@renderer/types'
import { AssessmentData } from '@renderer/models/Assessment'
import { BaseFactoryClass } from '@renderer/types/apidef'

export class GoalWeight implements IGoalWeight {
  private _stage: AssessmentData
  private _weight: number

  constructor(stage: AssessmentData, weight?: number) {
    this._stage = stage
    this._weight = weight ?? 0
  }

  get stage(): AssessmentData {
    return this._stage
  }

  set stage(value: AssessmentData) {
    this._stage = value
  }

  get weight(): number {
    return this._weight
  }

  set weight(value: number) {
    this._weight = value
  }
}

export class Goal implements IGoal, BaseFactoryClass {
  private _importance: 'H' | 'M' | 'L'
  private _indicator: string
  private _target: string
  private _weight: GoalWeight[]

  constructor(
    importance: 'H' | 'M' | 'L',
    indicator: string,
    target: string,
    weight: GoalWeight[]
  ) {
    this._importance = importance
    this._indicator = indicator
    this._target = target
    this._weight = weight
  }

  public static factory() {
    return new Goal('H', '', '', [])
  }

  public static factoryFromImpl(impl: IGoal): Goal {
    return new Goal(impl.importance, impl.indicator, impl.target, [])
  }

  public static factoryToImpl(): IGoal {
    return {
      importance: 'H',
      indicator: '',
      target: '',
      weight: []
    }
  }

  getCurrentImpl(): IGoal {
    return {
      importance: this._importance,
      indicator: this._indicator,
      target: this._target,
      weight: this._weight
    }
  }

  get importance(): 'H' | 'M' | 'L' {
    return this._importance
  }

  set importance(value: 'H' | 'M' | 'L') {
    this._importance = value
  }

  get indicator(): string {
    return this._indicator
  }

  set indicator(value: string) {
    this._indicator = value
  }

  get target(): string {
    return this._target
  }

  set target(value: string) {
    this._target = value
  }

  get weight(): GoalWeight[] {
    return this._weight
  }

  set weight(value: GoalWeight[]) {
    this._weight = value
  }
}
