// @generated by protobuf-ts 2.9.6
// @generated from protobuf file "item.proto" (package "api", syntax proto3)
// tslint:disable
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } from "@protobuf-ts/runtime";
import { WireType } from "@protobuf-ts/runtime";
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
import type { IBinaryReader } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { AttachmentSummary } from "./shared";
import { ItemStatusStruct } from "./repositoryShared";
import { LogisticVariant } from "./repositoryShared";
import { TradeItemDescriptions } from "./repositoryShared";
import { ExpiryConstraint } from "./repositoryShared";
import { MetadataElement } from "./shared";
import { EntityID } from "./shared";
import { EventHeader } from "./shared";
/**
 *
 * Aggregation object message
 *
 * @generated from protobuf message api.Item
 */
export interface Item {
    /**
     * @generated from protobuf field: api.EventHeader LastEventHeader = 1 [json_name = "LastEventHeader"];
     */
    lastEventHeader?: EventHeader;
    /**
     * @generated from protobuf field: api.EntityID ID = 2 [json_name = "ID"];
     */
    iD?: EntityID;
    /**
     * @generated from protobuf field: api.ItemPayload Payload = 3 [json_name = "Payload"];
     */
    payload?: ItemPayload;
}
/**
 * @generated from protobuf message api.ItemPayload
 */
export interface ItemPayload {
    /**
     * Metadata are characteristics specific to the project. They can be of several data form (string, integer, float, boolean or timestamp)
     *
     * @generated from protobuf field: repeated api.MetadataElement MetaData = 1 [json_name = "MetaData"];
     */
    metaData: MetadataElement[];
    /**
     * Item components
     *
     * @generated from protobuf field: api.ExpiryConstraint ExpiryConstraint = 6 [json_name = "ExpiryConstraint"];
     */
    expiryConstraint?: ExpiryConstraint;
    /**
     * @generated from protobuf field: string PhotoURI = 7 [json_name = "PhotoURI"];
     */
    photoURI: string;
    /**
     * @generated from protobuf field: repeated api.TradeItemDescriptions DescriptionsByLanguage = 3 [json_name = "DescriptionsByLanguage"];
     */
    descriptionsByLanguage: TradeItemDescriptions[]; // @option language
    /**
     * @generated from protobuf field: repeated api.LogisticVariant LogisticVariants = 4 [json_name = "LogisticVariants"];
     */
    logisticVariants: LogisticVariant[];
    /**
     * @generated from protobuf field: api.ItemStatusStruct Status = 5 [json_name = "Status"];
     */
    status?: ItemStatusStruct; // Status field is not accessible from APIs
    /**
     * @generated from protobuf field: repeated api.AttachmentSummary Attachments = 8 [json_name = "Attachments"];
     */
    attachments: AttachmentSummary[];
    /**
     * @generated from protobuf field: int32 AttachmentNumber = 9 [json_name = "AttachmentNumber"];
     */
    attachmentNumber: number;
    /**
     * @generated from protobuf field: repeated string RemovedLogisticVariantIDs = 10 [json_name = "RemovedLogisticVariantIDs"];
     */
    removedLogisticVariantIDs: string[];
}
/**
 * @generated from protobuf message api.ItemTriplet
 */
export interface ItemTriplet {
    /**
     * @generated from protobuf field: api.Item Current = 1 [json_name = "Current"];
     */
    current?: Item;
    /**
     * @generated from protobuf field: api.Item Previous = 2 [json_name = "Previous"];
     */
    previous?: Item;
    /**
     * @generated from protobuf field: api.Item LastEvent = 3 [json_name = "LastEvent"];
     */
    lastEvent?: Item;
}
// @generated message type with reflection information, may provide speed optimized methods
class Item$Type extends MessageType<Item> {
    constructor() {
        super("api.Item", [
            { no: 1, name: "LastEventHeader", kind: "message", jsonName: "LastEventHeader", T: () => EventHeader },
            { no: 2, name: "ID", kind: "message", jsonName: "ID", T: () => EntityID },
            { no: 3, name: "Payload", kind: "message", jsonName: "Payload", T: () => ItemPayload }
        ], { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema": { jsonSchema: { description: "Aggregation object message" } } });
    }
    create(value?: PartialMessage<Item>): Item {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<Item>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Item): Item {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.EventHeader LastEventHeader = 1 [json_name = "LastEventHeader"];*/ 1:
                    message.lastEventHeader = EventHeader.internalBinaryRead(reader, reader.uint32(), options, message.lastEventHeader);
                    break;
                case /* api.EntityID ID = 2 [json_name = "ID"];*/ 2:
                    message.iD = EntityID.internalBinaryRead(reader, reader.uint32(), options, message.iD);
                    break;
                case /* api.ItemPayload Payload = 3 [json_name = "Payload"];*/ 3:
                    message.payload = ItemPayload.internalBinaryRead(reader, reader.uint32(), options, message.payload);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: Item, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.EventHeader LastEventHeader = 1 [json_name = "LastEventHeader"]; */
        if (message.lastEventHeader)
            EventHeader.internalBinaryWrite(message.lastEventHeader, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.EntityID ID = 2 [json_name = "ID"]; */
        if (message.iD)
            EntityID.internalBinaryWrite(message.iD, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* api.ItemPayload Payload = 3 [json_name = "Payload"]; */
        if (message.payload)
            ItemPayload.internalBinaryWrite(message.payload, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.Item
 */
export const Item = new Item$Type();
// @generated message type with reflection information, may provide speed optimized methods
class ItemPayload$Type extends MessageType<ItemPayload> {
    constructor() {
        super("api.ItemPayload", [
            { no: 1, name: "MetaData", kind: "message", jsonName: "MetaData", repeat: 1 /*RepeatType.PACKED*/, T: () => MetadataElement, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Metadata are characteristics specific to the project. They can be of several data form (string, integer, float, boolean or timestamp)" }, "api.metadata": true, "api.aggKey": "Key", "api.kpiExclude": { Items: [{ Context: "Order", Group: "order" }] }, "api.parentEntity": "Item", "api.aggAppend": "MetaDataUpdated" } },
            { no: 6, name: "ExpiryConstraint", kind: "message", jsonName: "ExpiryConstraint", T: () => ExpiryConstraint, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Item components" } } },
            { no: 7, name: "PhotoURI", kind: "scalar", jsonName: "PhotoURI", T: 9 /*ScalarType.STRING*/, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { example: "\"https://reflex-visibility-forever.jpg\"" }, "api.kpiItems": { Items: [{ Context: "Item", Group: "item", Queryable: true }, { Context: "Executionflow", Group: "executionflow", Queryable: true }, { Context: "Stock", Group: "stock", Queryable: true }, { Context: "Stock", Group: "stock_extended", Queryable: true, CustomType: "SimpleAggregateFunction(anyLast,String)" }] }, "api.viewType": { Types: [{ Context: "*", Type: "image" }] } } },
            { no: 3, name: "DescriptionsByLanguage", kind: "message", jsonName: "DescriptionsByLanguage", repeat: 1 /*RepeatType.PACKED*/, T: () => TradeItemDescriptions, options: { "api.language": true, "api.aggKey": "LanguageCodeISO6391", "api.aggAppend": "DescriptionUpdated", "api.kpiItems": { Items: [{ Context: "Item", Group: "item" }, { Context: "Executionflow", Group: "executionflow" }, { Context: "Stock", Group: "stock" }, { Context: "Stock", Group: "stock_extended", CustomType: "SimpleAggregateFunction(anyLast,String)" }] } } },
            { no: 4, name: "LogisticVariants", kind: "message", jsonName: "LogisticVariants", repeat: 1 /*RepeatType.PACKED*/, T: () => LogisticVariant, options: { "validate.rules": { repeated: { uniqueBaseLV: true, knownRefLV: true } }, "api.aggKey": "LVID", "api.kpiExclude": { Items: [{ Context: "Stock", Group: "stock_extended" }, { Context: "Item", Group: "item" }] }, "api.aggAppend": "LogisticVariantUpdated" } },
            { no: 5, name: "Status", kind: "message", jsonName: "Status", T: () => ItemStatusStruct, options: { "validate.rules": { message: { unauthorized: true } }, "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { readOnly: true }, "api.kpiExclude": { Items: [{ Context: "Movement", Group: "movement" }] }, "api.enrichmentClear": "Handlingunit,Order,Executionflow,Stock" } },
            { no: 8, name: "Attachments", kind: "message", jsonName: "Attachments", repeat: 1 /*RepeatType.PACKED*/, T: () => AttachmentSummary, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Number of attachments per type" }, "api.aggSkip": "AttachmentAdded,AttachmentRemoved", "api.enrichmentClear": "Handlingunit,Order,Executionflow,Stock" } },
            { no: 9, name: "AttachmentNumber", kind: "scalar", jsonName: "AttachmentNumber", T: 5 /*ScalarType.INT32*/, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Total number of attachments" }, "api.enrichmentClear": "Handlingunit,Order,Executionflow,Stock" } },
            { no: 10, name: "RemovedLogisticVariantIDs", kind: "scalar", jsonName: "RemovedLogisticVariantIDs", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/, options: { "api.indexationType": { Types: [{ Context: "*", Type: "generatedText,keyword" }] }, "api.viewType": { Types: [{ Context: "*", Type: "shortKeyword" }] } } }
        ]);
    }
    create(value?: PartialMessage<ItemPayload>): ItemPayload {
        const message = globalThis.Object.create((this.messagePrototype!));
        message.metaData = [];
        message.photoURI = "";
        message.descriptionsByLanguage = [];
        message.logisticVariants = [];
        message.attachments = [];
        message.attachmentNumber = 0;
        message.removedLogisticVariantIDs = [];
        if (value !== undefined)
            reflectionMergePartial<ItemPayload>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ItemPayload): ItemPayload {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* repeated api.MetadataElement MetaData = 1 [json_name = "MetaData"];*/ 1:
                    message.metaData.push(MetadataElement.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                case /* api.ExpiryConstraint ExpiryConstraint = 6 [json_name = "ExpiryConstraint"];*/ 6:
                    message.expiryConstraint = ExpiryConstraint.internalBinaryRead(reader, reader.uint32(), options, message.expiryConstraint);
                    break;
                case /* string PhotoURI = 7 [json_name = "PhotoURI"];*/ 7:
                    message.photoURI = reader.string();
                    break;
                case /* repeated api.TradeItemDescriptions DescriptionsByLanguage = 3 [json_name = "DescriptionsByLanguage"];*/ 3:
                    message.descriptionsByLanguage.push(TradeItemDescriptions.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                case /* repeated api.LogisticVariant LogisticVariants = 4 [json_name = "LogisticVariants"];*/ 4:
                    message.logisticVariants.push(LogisticVariant.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                case /* api.ItemStatusStruct Status = 5 [json_name = "Status"];*/ 5:
                    message.status = ItemStatusStruct.internalBinaryRead(reader, reader.uint32(), options, message.status);
                    break;
                case /* repeated api.AttachmentSummary Attachments = 8 [json_name = "Attachments"];*/ 8:
                    message.attachments.push(AttachmentSummary.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                case /* int32 AttachmentNumber = 9 [json_name = "AttachmentNumber"];*/ 9:
                    message.attachmentNumber = reader.int32();
                    break;
                case /* repeated string RemovedLogisticVariantIDs = 10 [json_name = "RemovedLogisticVariantIDs"];*/ 10:
                    message.removedLogisticVariantIDs.push(reader.string());
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: ItemPayload, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* repeated api.MetadataElement MetaData = 1 [json_name = "MetaData"]; */
        for (let i = 0; i < message.metaData.length; i++)
            MetadataElement.internalBinaryWrite(message.metaData[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.ExpiryConstraint ExpiryConstraint = 6 [json_name = "ExpiryConstraint"]; */
        if (message.expiryConstraint)
            ExpiryConstraint.internalBinaryWrite(message.expiryConstraint, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
        /* string PhotoURI = 7 [json_name = "PhotoURI"]; */
        if (message.photoURI !== "")
            writer.tag(7, WireType.LengthDelimited).string(message.photoURI);
        /* repeated api.TradeItemDescriptions DescriptionsByLanguage = 3 [json_name = "DescriptionsByLanguage"]; */
        for (let i = 0; i < message.descriptionsByLanguage.length; i++)
            TradeItemDescriptions.internalBinaryWrite(message.descriptionsByLanguage[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        /* repeated api.LogisticVariant LogisticVariants = 4 [json_name = "LogisticVariants"]; */
        for (let i = 0; i < message.logisticVariants.length; i++)
            LogisticVariant.internalBinaryWrite(message.logisticVariants[i], writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        /* api.ItemStatusStruct Status = 5 [json_name = "Status"]; */
        if (message.status)
            ItemStatusStruct.internalBinaryWrite(message.status, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
        /* repeated api.AttachmentSummary Attachments = 8 [json_name = "Attachments"]; */
        for (let i = 0; i < message.attachments.length; i++)
            AttachmentSummary.internalBinaryWrite(message.attachments[i], writer.tag(8, WireType.LengthDelimited).fork(), options).join();
        /* int32 AttachmentNumber = 9 [json_name = "AttachmentNumber"]; */
        if (message.attachmentNumber !== 0)
            writer.tag(9, WireType.Varint).int32(message.attachmentNumber);
        /* repeated string RemovedLogisticVariantIDs = 10 [json_name = "RemovedLogisticVariantIDs"]; */
        for (let i = 0; i < message.removedLogisticVariantIDs.length; i++)
            writer.tag(10, WireType.LengthDelimited).string(message.removedLogisticVariantIDs[i]);
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.ItemPayload
 */
export const ItemPayload = new ItemPayload$Type();
// @generated message type with reflection information, may provide speed optimized methods
class ItemTriplet$Type extends MessageType<ItemTriplet> {
    constructor() {
        super("api.ItemTriplet", [
            { no: 1, name: "Current", kind: "message", jsonName: "Current", T: () => Item },
            { no: 2, name: "Previous", kind: "message", jsonName: "Previous", T: () => Item },
            { no: 3, name: "LastEvent", kind: "message", jsonName: "LastEvent", T: () => Item }
        ]);
    }
    create(value?: PartialMessage<ItemTriplet>): ItemTriplet {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<ItemTriplet>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ItemTriplet): ItemTriplet {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.Item Current = 1 [json_name = "Current"];*/ 1:
                    message.current = Item.internalBinaryRead(reader, reader.uint32(), options, message.current);
                    break;
                case /* api.Item Previous = 2 [json_name = "Previous"];*/ 2:
                    message.previous = Item.internalBinaryRead(reader, reader.uint32(), options, message.previous);
                    break;
                case /* api.Item LastEvent = 3 [json_name = "LastEvent"];*/ 3:
                    message.lastEvent = Item.internalBinaryRead(reader, reader.uint32(), options, message.lastEvent);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: ItemTriplet, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.Item Current = 1 [json_name = "Current"]; */
        if (message.current)
            Item.internalBinaryWrite(message.current, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.Item Previous = 2 [json_name = "Previous"]; */
        if (message.previous)
            Item.internalBinaryWrite(message.previous, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* api.Item LastEvent = 3 [json_name = "LastEvent"]; */
        if (message.lastEvent)
            Item.internalBinaryWrite(message.lastEvent, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.ItemTriplet
 */
export const ItemTriplet = new ItemTriplet$Type();
