import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MealieClient } from './mealie.classes.client.js';
import { MealieConfigFlow } from './mealie.classes.configflow.js';
import { createMealieDiscoveryDescriptor } from './mealie.discovery.js';
import type { IMealieConfig } from './mealie.types.js';
import { mealieDomain, mealieProfile } from './mealie.types.js';

export class MealieIntegration extends SimpleLocalIntegration<IMealieConfig> {
  public readonly domain = mealieDomain;
  public readonly discoveryDescriptor = createMealieDiscoveryDescriptor();
  public readonly configFlow = new MealieConfigFlow();

  constructor() {
    super(mealieProfile);
  }

  public async setup(configArg: IMealieConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(mealieProfile, new MealieClient(configArg));
  }
}
