import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { OwntracksClient } from './owntracks.classes.client.js';
import { OwntracksConfigFlow } from './owntracks.classes.configflow.js';
import { createOwntracksDiscoveryDescriptor } from './owntracks.discovery.js';
import type { IOwntracksConfig } from './owntracks.types.js';
import { owntracksDomain, owntracksProfile } from './owntracks.types.js';

export class OwntracksIntegration extends SimpleLocalIntegration<IOwntracksConfig> {
  public readonly domain = owntracksDomain;
  public readonly discoveryDescriptor = createOwntracksDiscoveryDescriptor();
  public readonly configFlow = new OwntracksConfigFlow();

  constructor() {
    super(owntracksProfile);
  }

  public override async setup(configArg: IOwntracksConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(owntracksProfile, new OwntracksClient(configArg));
  }
}

export class HomeAssistantOwntracksIntegration extends OwntracksIntegration {}
