/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { Mapper as M } from "@vertexvis/utils";
import { fromPbBoolValue, fromPbBoundingBox3f, fromPbInstant, fromPbMatrix4f, fromPbStringValue, fromPbUuid2l, mapCursor, } from "../mappers";
import { fromPbMaterialOverride } from "../mappers/colorMaterial";
const mapPropertyKey = M.defineMapper(M.read(M.requiredProp('name'), M.requiredProp('category')), ([name, category]) => ({ name, category }));
const mapGetStringValue = M.defineMapper(M.read(M.getProp('value')), ([value]) => ({
    type: 'string',
    value,
}));
const mapStringValue = M.mapProp('string', M.ifDefined(mapGetStringValue));
const mapGetLongValue = M.defineMapper(M.read(M.getProp('value')), ([value]) => ({
    type: 'long',
    value,
}));
const mapLongValue = M.mapProp('pb_long', M.ifDefined(mapGetLongValue));
const mapGetDoubleValue = M.defineMapper(M.read(M.getProp('value')), ([value]) => ({
    type: 'double',
    value,
}));
const mapDoubleValue = M.mapProp('pb_double', M.ifDefined(mapGetDoubleValue));
const mapGetTimestampValue = M.defineMapper(M.read(M.requiredProp('value')), ([value]) => ({
    type: 'timestamp',
    value: value,
}));
const mapTimestampValue = M.mapProp('date', M.ifDefined(mapGetTimestampValue));
const mapPropertyValue = M.compose(M.pickFirst(mapStringValue, mapLongValue, mapDoubleValue, mapTimestampValue), M.required('value'));
const mapEntriesList = M.defineMapper(M.read(M.requiredProp('id'), M.mapProp('key', M.ifDefined(mapPropertyKey)), M.mapProp('value', M.ifDefined(mapPropertyValue))), ([id, key, value]) => ({ id, key, value }));
const mapListSceneItemMetadataResponse = M.defineMapper(M.read(M.mapProp('cursor', mapCursor), M.mapRequiredProp('entriesList', M.mapArray(mapEntriesList))), ([cursor, entries]) => ({
    paging: {
        next: cursor,
    },
    entries,
}));
export const mapListSceneItemMetadataResponseOrThrow = M.ifInvalidThrow(mapListSceneItemMetadataResponse);
const mapSceneViewItemOverride = M.defineMapper(M.read(M.mapRequiredProp('id', fromPbUuid2l), M.mapRequiredProp('createdAt', fromPbInstant), M.mapProp('materialOverride', M.ifDefined(fromPbMaterialOverride)), M.mapProp('transform', M.ifDefined(fromPbMatrix4f)), M.mapProp('isVisible', M.ifDefined(fromPbBoolValue)), M.mapProp('isSelected', M.ifDefined(fromPbBoolValue)), M.mapProp('isPhantom', M.ifDefined(fromPbBoolValue)), M.mapProp('endItem', M.ifDefined(fromPbBoolValue))), ([id, createdAt, materialOverride, transform, isVisible, isSelected, isPhantom, endItem,]) => ({
    id,
    createdAt,
    materialOverride,
    transform,
    isVisible,
    isSelected,
    isPhantom,
    endItem,
}));
export const mapSceneViewItem = M.defineMapper(M.read(M.mapRequiredProp('id', fromPbUuid2l), M.mapRequiredProp('createdAt', fromPbInstant), M.mapRequiredProp('name', fromPbStringValue), M.mapProp('parentId', M.ifDefined(fromPbUuid2l)), M.mapProp('suppliedId', M.ifDefined(fromPbStringValue)), M.mapProp('boundingBox', M.ifDefined(fromPbBoundingBox3f)), M.mapProp('worldTransform', M.ifDefined(fromPbMatrix4f)), M.mapProp('override', M.ifDefined(mapSceneViewItemOverride))), ([id, createdAt, name, parentId, suppliedId, boundingBox, worldTransform, override,]) => ({
    id,
    createdAt,
    name,
    parentId: parentId !== null && parentId !== void 0 ? parentId : undefined,
    suppliedId,
    boundingBox,
    worldTransform,
    override,
}));
export const mapGetSceneViewItemResponseOrThrow = M.ifInvalidThrow(M.defineMapper(M.read(M.mapProp('item', M.ifDefined(mapSceneViewItem))), ([item]) => item !== null && item !== void 0 ? item : undefined));
//# sourceMappingURL=mapper.js.map
