import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { GpsdClient } from './gpsd.classes.client.js';
import { GpsdConfigFlow } from './gpsd.classes.configflow.js';
import { createGpsdDiscoveryDescriptor } from './gpsd.discovery.js';
import type { IGpsdConfig } from './gpsd.types.js';
import { gpsdDomain, gpsdProfile } from './gpsd.types.js';

export class GpsdIntegration extends SimpleLocalIntegration<IGpsdConfig> {
  public readonly domain = gpsdDomain;
  public readonly discoveryDescriptor = createGpsdDiscoveryDescriptor();
  public readonly configFlow = new GpsdConfigFlow();

  constructor() {
    super(gpsdProfile);
  }

  public async setup(configArg: IGpsdConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(gpsdProfile, new GpsdClient(configArg));
  }
}

export class HomeAssistantGpsdIntegration extends GpsdIntegration {}
