import { clone } from '../../../utils/utils.js';
/**
 * Builder class for creating static controller
 */
class StaticControllerBuilder {
    _state;
    _kind;
    _initialState;
    withState(state) {
        this._state = clone(state);
        return this;
    }
    withKind(kind) {
        this._kind = kind;
        return this;
    }
    withInitialState(initialState) {
        this._initialState = clone(initialState);
        return this;
    }
    /**
     * Builds and returns the static controller state object
     */
    build() {
        const result = {
            state: this._state,
        };
        if (this._kind) {
            result._kind = this._kind;
        }
        if (this._initialState) {
            result.initialState = this._initialState;
        }
        return result;
    }
}
export function createStaticControllerBuilder(controller) {
    const builder = new StaticControllerBuilder().withState(controller.state);
    if ('_kind' in controller) {
        builder.withKind(controller._kind);
    }
    if ('initialState' in controller) {
        builder.withInitialState(controller.initialState);
    }
    return builder;
}
