export type PropsPlugin<TProps> = (props: TProps) => TProps;

export type ComponentPlugin<TInput, TProps = TInput> = (input: TInput) => TProps;

export type ComponentPluginFactory<
  TArgs extends unknown[] = [],
  TInput = unknown,
  TProps = TInput,
> = (...args: TArgs) => ComponentPlugin<TInput, TProps>;

export function plugins<TProps>(
  props: TProps,
  pluginList: ReadonlyArray<PropsPlugin<TProps>>,
): TProps {
  return pluginList.reduce((currentProps, plugin) => plugin(currentProps), props);
}
