/** The `LegendInputProcessor` class processes chart options and previous layout results to generate a legend input object for a line chart. */
export class LegendInputProcessor {
  /**
   * This function takes in chart options and previous layout results, and returns a legend input object with data, colors, position, width, and height properties.
   *
   *  @param {ChartOptions<LineChartDataType>} input - The input parameter is an object of type ChartOptions that contains the data and
   * configuration options for a line chart.
   * @param {LayoutProcessResultType} previousOutput - `previousOutput` is an optional parameter of
   * type `LayoutProcessResultType` that represents the output of the previous layout process. It is
   * used to retrieve the width and height of the chart, which are needed to properly position the
   * legend. If no previous output is provided, the width and height will
   * @returns {LegendInputType} an object of type `LegendInputType`. The object contains the following properties:
   * - `data`: an array of legend items
   * - `colors`: an array of colors used in the chart
   * - `position`: an object with `x` and `y` properties representing the position of the legend
   * - `width`: the width of the chart
   * - `height`: the
   */
  process(input, previousOutput) {
    const { colors, legends = [] } = input;
    const { width, height } = previousOutput;
    return {
      data: legends,
      colors,
      position: { x: 10, y: 10 },
      width,
      height,
    };
  }
}
