import { createDynamicSlimmer } from 'vega-slimmer/core';
import { SubStateNotifySlimmerBase } from './sub-state-notify-slimmer-base';
/**
 * Create dynamic subState notify slimmer
 *
 * @param {ClassPrototype} mapFromClass - It represents the class that you want to map from.
 * @param {string} propName - The parent component prop name
 * @param {string} watchMethodName - The watch method name of prop change
 * @returns {SubStateNotifySlimmerBase} - SubState notify slimmer
 */
export function createSubStateNotifySlimmer(mapFromClass, propName, watchMethodName) {
  const methodsMap = [
    { mapFrom: 'connectedCallback', mapTo: 'connectedCallback' },
    { mapFrom: 'disconnectedCallback', mapTo: 'disconnectedCallback' },
  ];
  if (watchMethodName) {
    methodsMap.push({ mapFrom: watchMethodName, mapTo: 'subStateNotify' });
  }
  return createDynamicSlimmer(mapFromClass, SubStateNotifySlimmerBase, [
    { mapFrom: 'host', mapTo: 'host' },
    { mapFrom: propName, mapTo: 'propValue' },
  ], methodsMap, [
    {
      propName: propName,
    },
  ]);
}
