import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LocalIpClient } from './local_ip.classes.client.js';
import { LocalIpConfigFlow } from './local_ip.classes.configflow.js';
import { createLocalIpDiscoveryDescriptor } from './local_ip.discovery.js';
import type { ILocalIpConfig } from './local_ip.types.js';
import { localIpDomain, localIpProfile } from './local_ip.types.js';

export class LocalIpIntegration extends SimpleLocalIntegration<ILocalIpConfig> {
  public readonly domain = localIpDomain;
  public readonly discoveryDescriptor = createLocalIpDiscoveryDescriptor();
  public readonly configFlow = new LocalIpConfigFlow();

  constructor() {
    super(localIpProfile);
  }

  public async setup(configArg: ILocalIpConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(localIpProfile, new LocalIpClient(configArg));
  }
}
