import type { IConfigFlow, IConfigFlowContext, IConfigFlowStep, IDiscoveryCandidate } from '../../core/types.js';
import type { IHueConfig } from './hue.types.js';

export class HueConfigFlow implements IConfigFlow<IHueConfig> {
  public async start(candidateArg: IDiscoveryCandidate, contextArg: IConfigFlowContext): Promise<IConfigFlowStep<IHueConfig>> {
    void contextArg;
    return {
      kind: 'form',
      title: 'Connect Philips Hue Bridge',
      description: 'Press the bridge button, then provide the generated app key or paste an existing key.',
      fields: [
        { name: 'appKey', label: 'Hue app key', type: 'password', required: true },
      ],
      submit: async (valuesArg) => ({
        kind: 'done',
        title: 'Hue bridge configured',
        config: {
          bridgeId: candidateArg.id || 'unknown-hue-bridge',
          host: candidateArg.host || 'localhost',
          port: candidateArg.port || 443,
          appKey: String(valuesArg.appKey || ''),
        },
      }),
    };
  }
}
