// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
// Based on "crates/store/re_sdk_types/definitions/rerun/blueprint/archetypes/panel_blueprint.fbs".

#include "panel_blueprint.hpp"

#include "../../collection_adapter_builtins.hpp"

namespace rerun::blueprint::archetypes {
    PanelBlueprint PanelBlueprint::clear_fields() {
        auto archetype = PanelBlueprint();
        archetype.state =
            ComponentBatch::empty<rerun::blueprint::components::PanelState>(Descriptor_state)
                .value_or_throw();
        return archetype;
    }

    Collection<ComponentColumn> PanelBlueprint::columns(const Collection<uint32_t>& lengths_) {
        std::vector<ComponentColumn> columns;
        columns.reserve(1);
        if (state.has_value()) {
            columns.push_back(state.value().partitioned(lengths_).value_or_throw());
        }
        return columns;
    }

    Collection<ComponentColumn> PanelBlueprint::columns() {
        if (state.has_value()) {
            return columns(std::vector<uint32_t>(state.value().length(), 1));
        }
        return Collection<ComponentColumn>();
    }
} // namespace rerun::blueprint::archetypes

namespace rerun {

    Result<Collection<ComponentBatch>>
        AsComponents<blueprint::archetypes::PanelBlueprint>::as_batches(
            const blueprint::archetypes::PanelBlueprint& archetype
        ) {
        using namespace blueprint::archetypes;
        std::vector<ComponentBatch> cells;
        cells.reserve(1);

        if (archetype.state.has_value()) {
            cells.push_back(archetype.state.value());
        }

        return rerun::take_ownership(std::move(cells));
    }
} // namespace rerun
