import type { PropsPlugin } from '../../../../types/component-plugin';
import type { MultiProgressUIProps } from '../types';

export function createMultiProgressMetaPlugin(meta: string): PropsPlugin<MultiProgressUIProps> {
  return (props) => ({
    ...props,
    meta,
  });
}

export function createMultiProgressSortPlugin(): PropsPlugin<MultiProgressUIProps> {
  return (props) => ({
    ...props,
    data: [...props.data].sort((left, right) => right.percent - left.percent),
  });
}
