import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { ImmichClient } from './immich.classes.client.js';
import { ImmichConfigFlow } from './immich.classes.configflow.js';
import { createImmichDiscoveryDescriptor } from './immich.discovery.js';
import type { IImmichConfig } from './immich.types.js';
import { immichDomain, immichProfile } from './immich.types.js';

export class ImmichIntegration extends SimpleLocalIntegration<IImmichConfig> {
  public readonly domain = immichDomain;
  public readonly discoveryDescriptor = createImmichDiscoveryDescriptor();
  public readonly configFlow = new ImmichConfigFlow();

  constructor() {
    super(immichProfile);
  }

  public async setup(configArg: IImmichConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(immichProfile, new ImmichClient(configArg));
  }
}
