/**
 * Fluent builder for constructing MCP elicitation requests.
 *
 * @example
 * ```ts
 * const request = new ElicitationBuilder('Confirm deployment')
 *   .addText('name', 'Service name', { required: true })
 *   .addEnum('env', 'Target environment', ['staging', 'production'])
 *   .addBoolean('notify', 'Notify on Slack?')
 *   .build();
 * ```
 */
export class ElicitationBuilder {
    title;
    fields = [];
    description;
    constructor(title) {
        this.title = title;
    }
    /** Set an optional description displayed below the title. */
    withDescription(description) {
        this.description = description;
        return this;
    }
    /** Add a free-text input field. */
    addText(key, label, options = {}) {
        const field = {
            type: 'text',
            key,
            label,
            ...(options.required !== undefined && { required: options.required }),
            ...(options.maxLength !== undefined && { maxLength: options.maxLength }),
            ...(options.placeholder !== undefined && { placeholder: options.placeholder }),
            ...(options.defaultValue !== undefined && { defaultValue: options.defaultValue }),
        };
        this.fields.push(field);
        return this;
    }
    /** Add a numeric input field with optional min/max bounds. */
    addNumber(key, label, options = {}) {
        const field = {
            type: 'number',
            key,
            label,
            ...(options.required !== undefined && { required: options.required }),
            ...(options.min !== undefined && { min: options.min }),
            ...(options.max !== undefined && { max: options.max }),
            ...(options.defaultValue !== undefined && { defaultValue: options.defaultValue }),
        };
        this.fields.push(field);
        return this;
    }
    /** Add a boolean toggle / checkbox field. */
    addBoolean(key, label, options = {}) {
        const field = {
            type: 'boolean',
            key,
            label,
            ...(options.required !== undefined && { required: options.required }),
            ...(options.defaultValue !== undefined && { defaultValue: options.defaultValue }),
        };
        this.fields.push(field);
        return this;
    }
    /** Add a single-select enum field constrained to the given options list. */
    addEnum(key, label, options, fieldOptions = {}) {
        if (options.length === 0) {
            throw new Error(`ElicitationBuilder.addEnum: field "${key}" must have at least one option`);
        }
        const field = {
            type: 'enum',
            key,
            label,
            options,
            ...(fieldOptions.required !== undefined && { required: fieldOptions.required }),
            ...(fieldOptions.defaultValue !== undefined && { defaultValue: fieldOptions.defaultValue }),
        };
        this.fields.push(field);
        return this;
    }
    /** Add a multi-select field allowing zero or more items from the options list. */
    addMultiSelect(key, label, options, fieldOptions = {}) {
        if (options.length === 0) {
            throw new Error(`ElicitationBuilder.addMultiSelect: field "${key}" must have at least one option`);
        }
        const field = {
            type: 'multi-select',
            key,
            label,
            options,
            ...(fieldOptions.required !== undefined && { required: fieldOptions.required }),
            ...(fieldOptions.defaultValue !== undefined && { defaultValue: fieldOptions.defaultValue }),
        };
        this.fields.push(field);
        return this;
    }
    /**
     * Build the final ElicitationRequest.
     * @throws {Error} when no fields have been added.
     */
    build() {
        if (this.fields.length === 0) {
            throw new Error('ElicitationBuilder.build: at least one field is required');
        }
        const request = {
            title: this.title,
            fields: [...this.fields],
        };
        if (this.description !== undefined) {
            request.description = this.description;
        }
        return request;
    }
}
//# sourceMappingURL=builder.js.map