import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LocalCalendarClient } from './local_calendar.classes.client.js';
import { LocalCalendarConfigFlow } from './local_calendar.classes.configflow.js';
import { createLocalCalendarDiscoveryDescriptor } from './local_calendar.discovery.js';
import type { ILocalCalendarConfig } from './local_calendar.types.js';
import { localCalendarDomain, localCalendarProfile } from './local_calendar.types.js';

export class LocalCalendarIntegration extends SimpleLocalIntegration<ILocalCalendarConfig> {
  public readonly domain = localCalendarDomain;
  public readonly discoveryDescriptor = createLocalCalendarDiscoveryDescriptor();
  public readonly configFlow = new LocalCalendarConfigFlow();

  constructor() {
    super(localCalendarProfile);
  }

  public async setup(configArg: ILocalCalendarConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(localCalendarProfile, new LocalCalendarClient(configArg));
  }
}
