"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.8
//   protoc               v4.25.9
// source: io/restorecommerce/unit_code.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.UnitCodeServiceDefinition = exports.UnitCode = exports.UnitCodeResponse = exports.UnitCodeListResponse = exports.UnitCodeList = exports.Sector = exports.StatusCode = exports.protobufPackage = void 0;
exports.statusCodeFromJSON = statusCodeFromJSON;
exports.statusCodeToJSON = statusCodeToJSON;
exports.statusCodeToNumber = statusCodeToNumber;
exports.sectorFromJSON = sectorFromJSON;
exports.sectorToJSON = sectorToJSON;
exports.sectorToNumber = sectorToNumber;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
const auth_1 = require("./auth");
const meta_1 = require("./meta");
const options_1 = require("./options");
const resource_base_1 = require("./resource_base");
const status_1 = require("./status");
exports.protobufPackage = "io.restorecommerce.unit_code";
var StatusCode;
(function (StatusCode) {
    StatusCode["ADDED"] = "ADDED";
    StatusCode["CHANGED_NAME"] = "CHANGED_NAME";
    StatusCode["CHANGED_CHARACTERISTIC"] = "CHANGED_CHARACTERISTIC";
    StatusCode["DEPRECATED"] = "DEPRECATED";
    StatusCode["MARKED_AS_DELETED"] = "MARKED_AS_DELETED";
    StatusCode["REINSTATED"] = "REINSTATED";
    StatusCode["UNRECOGNIZED"] = "UNRECOGNIZED";
})(StatusCode || (exports.StatusCode = StatusCode = {}));
function statusCodeFromJSON(object) {
    switch (object) {
        case 0:
        case "ADDED":
            return StatusCode.ADDED;
        case 1:
        case "CHANGED_NAME":
            return StatusCode.CHANGED_NAME;
        case 2:
        case "CHANGED_CHARACTERISTIC":
            return StatusCode.CHANGED_CHARACTERISTIC;
        case 3:
        case "DEPRECATED":
            return StatusCode.DEPRECATED;
        case 4:
        case "MARKED_AS_DELETED":
            return StatusCode.MARKED_AS_DELETED;
        case 5:
        case "REINSTATED":
            return StatusCode.REINSTATED;
        case -1:
        case "UNRECOGNIZED":
        default:
            return StatusCode.UNRECOGNIZED;
    }
}
function statusCodeToJSON(object) {
    switch (object) {
        case StatusCode.ADDED:
            return "ADDED";
        case StatusCode.CHANGED_NAME:
            return "CHANGED_NAME";
        case StatusCode.CHANGED_CHARACTERISTIC:
            return "CHANGED_CHARACTERISTIC";
        case StatusCode.DEPRECATED:
            return "DEPRECATED";
        case StatusCode.MARKED_AS_DELETED:
            return "MARKED_AS_DELETED";
        case StatusCode.REINSTATED:
            return "REINSTATED";
        case StatusCode.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function statusCodeToNumber(object) {
    switch (object) {
        case StatusCode.ADDED:
            return 0;
        case StatusCode.CHANGED_NAME:
            return 1;
        case StatusCode.CHANGED_CHARACTERISTIC:
            return 2;
        case StatusCode.DEPRECATED:
            return 3;
        case StatusCode.MARKED_AS_DELETED:
            return 4;
        case StatusCode.REINSTATED:
            return 5;
        case StatusCode.UNRECOGNIZED:
        default:
            return -1;
    }
}
var Sector;
(function (Sector) {
    Sector["UNKNOWN"] = "UNKNOWN";
    Sector["ACOUSTICS"] = "ACOUSTICS";
    Sector["ATOMIC_AND_NUCLEAR_PHYSICS"] = "ATOMIC_AND_NUCLEAR_PHYSICS";
    Sector["CHARACTERISTIC_NUMBERS"] = "CHARACTERISTIC_NUMBERS";
    Sector["ELECTRICITY_AND_MAGNETISM"] = "ELECTRICITY_AND_MAGNETISM";
    Sector["HEAT"] = "HEAT";
    Sector["LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS"] = "LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS";
    Sector["MECHANICS"] = "MECHANICS";
    Sector["MISCELLANEOUS"] = "MISCELLANEOUS";
    Sector["NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS"] = "NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS";
    Sector["PERIODIC_AND_RELATED_PHASES"] = "PERIODIC_AND_RELATED_PHASES";
    Sector["PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS"] = "PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS";
    Sector["SOLID_STATE_PHYSICS"] = "SOLID_STATE_PHYSICS";
    Sector["SPACE_AND_TIME"] = "SPACE_AND_TIME";
    Sector["UNRECOGNIZED"] = "UNRECOGNIZED";
})(Sector || (exports.Sector = Sector = {}));
function sectorFromJSON(object) {
    switch (object) {
        case 0:
        case "UNKNOWN":
            return Sector.UNKNOWN;
        case 1:
        case "ACOUSTICS":
            return Sector.ACOUSTICS;
        case 2:
        case "ATOMIC_AND_NUCLEAR_PHYSICS":
            return Sector.ATOMIC_AND_NUCLEAR_PHYSICS;
        case 3:
        case "CHARACTERISTIC_NUMBERS":
            return Sector.CHARACTERISTIC_NUMBERS;
        case 4:
        case "ELECTRICITY_AND_MAGNETISM":
            return Sector.ELECTRICITY_AND_MAGNETISM;
        case 5:
        case "HEAT":
            return Sector.HEAT;
        case 6:
        case "LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS":
            return Sector.LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS;
        case 7:
        case "MECHANICS":
            return Sector.MECHANICS;
        case 8:
        case "MISCELLANEOUS":
            return Sector.MISCELLANEOUS;
        case 9:
        case "NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS":
            return Sector.NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS;
        case 10:
        case "PERIODIC_AND_RELATED_PHASES":
            return Sector.PERIODIC_AND_RELATED_PHASES;
        case 11:
        case "PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS":
            return Sector.PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS;
        case 12:
        case "SOLID_STATE_PHYSICS":
            return Sector.SOLID_STATE_PHYSICS;
        case 13:
        case "SPACE_AND_TIME":
            return Sector.SPACE_AND_TIME;
        case -1:
        case "UNRECOGNIZED":
        default:
            return Sector.UNRECOGNIZED;
    }
}
function sectorToJSON(object) {
    switch (object) {
        case Sector.UNKNOWN:
            return "UNKNOWN";
        case Sector.ACOUSTICS:
            return "ACOUSTICS";
        case Sector.ATOMIC_AND_NUCLEAR_PHYSICS:
            return "ATOMIC_AND_NUCLEAR_PHYSICS";
        case Sector.CHARACTERISTIC_NUMBERS:
            return "CHARACTERISTIC_NUMBERS";
        case Sector.ELECTRICITY_AND_MAGNETISM:
            return "ELECTRICITY_AND_MAGNETISM";
        case Sector.HEAT:
            return "HEAT";
        case Sector.LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS:
            return "LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS";
        case Sector.MECHANICS:
            return "MECHANICS";
        case Sector.MISCELLANEOUS:
            return "MISCELLANEOUS";
        case Sector.NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS:
            return "NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS";
        case Sector.PERIODIC_AND_RELATED_PHASES:
            return "PERIODIC_AND_RELATED_PHASES";
        case Sector.PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS:
            return "PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS";
        case Sector.SOLID_STATE_PHYSICS:
            return "SOLID_STATE_PHYSICS";
        case Sector.SPACE_AND_TIME:
            return "SPACE_AND_TIME";
        case Sector.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function sectorToNumber(object) {
    switch (object) {
        case Sector.UNKNOWN:
            return 0;
        case Sector.ACOUSTICS:
            return 1;
        case Sector.ATOMIC_AND_NUCLEAR_PHYSICS:
            return 2;
        case Sector.CHARACTERISTIC_NUMBERS:
            return 3;
        case Sector.ELECTRICITY_AND_MAGNETISM:
            return 4;
        case Sector.HEAT:
            return 5;
        case Sector.LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS:
            return 6;
        case Sector.MECHANICS:
            return 7;
        case Sector.MISCELLANEOUS:
            return 8;
        case Sector.NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS:
            return 9;
        case Sector.PERIODIC_AND_RELATED_PHASES:
            return 10;
        case Sector.PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS:
            return 11;
        case Sector.SOLID_STATE_PHYSICS:
            return 12;
        case Sector.SPACE_AND_TIME:
            return 13;
        case Sector.UNRECOGNIZED:
        default:
            return -1;
    }
}
function createBaseUnitCodeList() {
    return {};
}
exports.UnitCodeList = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.items !== undefined && message.items.length !== 0) {
            for (const v of message.items) {
                exports.UnitCode.encode(v, writer.uint32(10).fork()).join();
            }
        }
        if (message.total_count !== undefined) {
            writer.uint32(16).uint32(message.total_count);
        }
        if (message.subject !== undefined) {
            auth_1.Subject.encode(message.subject, writer.uint32(26).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseUnitCodeList();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    if (message.items === undefined) {
                        message.items = [];
                    }
                    const el = exports.UnitCode.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.items.push(el);
                    }
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.total_count = reader.uint32();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.subject = auth_1.Subject.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            items: globalThis.Array.isArray(object?.items) ? object.items.map((e) => exports.UnitCode.fromJSON(e)) : undefined,
            total_count: isSet(object.totalCount)
                ? globalThis.Number(object.totalCount)
                : isSet(object.total_count)
                    ? globalThis.Number(object.total_count)
                    : undefined,
            subject: isSet(object.subject) ? auth_1.Subject.fromJSON(object.subject) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.items?.length) {
            obj.items = message.items.map((e) => exports.UnitCode.toJSON(e));
        }
        if (message.total_count !== undefined) {
            obj.totalCount = Math.round(message.total_count);
        }
        if (message.subject !== undefined) {
            obj.subject = auth_1.Subject.toJSON(message.subject);
        }
        return obj;
    },
    create(base) {
        return exports.UnitCodeList.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseUnitCodeList();
        message.items = object.items?.map((e) => exports.UnitCode.fromPartial(e)) || undefined;
        message.total_count = object.total_count ?? undefined;
        message.subject = (object.subject !== undefined && object.subject !== null)
            ? auth_1.Subject.fromPartial(object.subject)
            : undefined;
        return message;
    },
};
function createBaseUnitCodeListResponse() {
    return {};
}
exports.UnitCodeListResponse = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.items !== undefined && message.items.length !== 0) {
            for (const v of message.items) {
                exports.UnitCodeResponse.encode(v, writer.uint32(10).fork()).join();
            }
        }
        if (message.total_count !== undefined) {
            writer.uint32(16).uint32(message.total_count);
        }
        if (message.operation_status !== undefined) {
            status_1.OperationStatus.encode(message.operation_status, writer.uint32(26).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseUnitCodeListResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    if (message.items === undefined) {
                        message.items = [];
                    }
                    const el = exports.UnitCodeResponse.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.items.push(el);
                    }
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.total_count = reader.uint32();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.operation_status = status_1.OperationStatus.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            items: globalThis.Array.isArray(object?.items)
                ? object.items.map((e) => exports.UnitCodeResponse.fromJSON(e))
                : undefined,
            total_count: isSet(object.totalCount)
                ? globalThis.Number(object.totalCount)
                : isSet(object.total_count)
                    ? globalThis.Number(object.total_count)
                    : undefined,
            operation_status: isSet(object.operationStatus)
                ? status_1.OperationStatus.fromJSON(object.operationStatus)
                : isSet(object.operation_status)
                    ? status_1.OperationStatus.fromJSON(object.operation_status)
                    : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.items?.length) {
            obj.items = message.items.map((e) => exports.UnitCodeResponse.toJSON(e));
        }
        if (message.total_count !== undefined) {
            obj.totalCount = Math.round(message.total_count);
        }
        if (message.operation_status !== undefined) {
            obj.operationStatus = status_1.OperationStatus.toJSON(message.operation_status);
        }
        return obj;
    },
    create(base) {
        return exports.UnitCodeListResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseUnitCodeListResponse();
        message.items = object.items?.map((e) => exports.UnitCodeResponse.fromPartial(e)) || undefined;
        message.total_count = object.total_count ?? undefined;
        message.operation_status = (object.operation_status !== undefined && object.operation_status !== null)
            ? status_1.OperationStatus.fromPartial(object.operation_status)
            : undefined;
        return message;
    },
};
function createBaseUnitCodeResponse() {
    return {};
}
exports.UnitCodeResponse = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.payload !== undefined) {
            exports.UnitCode.encode(message.payload, writer.uint32(10).fork()).join();
        }
        if (message.status !== undefined) {
            status_1.Status.encode(message.status, writer.uint32(18).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseUnitCodeResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.payload = exports.UnitCode.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.status = status_1.Status.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            payload: isSet(object.payload) ? exports.UnitCode.fromJSON(object.payload) : undefined,
            status: isSet(object.status) ? status_1.Status.fromJSON(object.status) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.payload !== undefined) {
            obj.payload = exports.UnitCode.toJSON(message.payload);
        }
        if (message.status !== undefined) {
            obj.status = status_1.Status.toJSON(message.status);
        }
        return obj;
    },
    create(base) {
        return exports.UnitCodeResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseUnitCodeResponse();
        message.payload = (object.payload !== undefined && object.payload !== null)
            ? exports.UnitCode.fromPartial(object.payload)
            : undefined;
        message.status = (object.status !== undefined && object.status !== null)
            ? status_1.Status.fromPartial(object.status)
            : undefined;
        return message;
    },
};
function createBaseUnitCode() {
    return {};
}
exports.UnitCode = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.id !== undefined) {
            writer.uint32(10).string(message.id);
        }
        if (message.meta !== undefined) {
            meta_1.Meta.encode(message.meta, writer.uint32(18).fork()).join();
        }
        if (message.status !== undefined) {
            writer.uint32(24).int32(statusCodeToNumber(message.status));
        }
        if (message.common_code !== undefined) {
            writer.uint32(34).string(message.common_code);
        }
        if (message.name !== undefined) {
            writer.uint32(42).string(message.name);
        }
        if (message.description !== undefined) {
            writer.uint32(50).string(message.description);
        }
        if (message.level_category !== undefined) {
            writer.uint32(58).string(message.level_category);
        }
        if (message.symbol !== undefined) {
            writer.uint32(66).string(message.symbol);
        }
        if (message.conversion_factor !== undefined) {
            writer.uint32(74).string(message.conversion_factor);
        }
        if (message.group_number !== undefined) {
            writer.uint32(82).string(message.group_number);
        }
        if (message.sector !== undefined) {
            writer.uint32(88).int32(sectorToNumber(message.sector));
        }
        if (message.group_id !== undefined) {
            writer.uint32(98).string(message.group_id);
        }
        if (message.quantity !== undefined) {
            writer.uint32(106).string(message.quantity);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseUnitCode();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.meta = meta_1.Meta.decode(reader, reader.uint32());
                    continue;
                }
                case 3: {
                    if (tag !== 24) {
                        break;
                    }
                    message.status = statusCodeFromJSON(reader.int32());
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.common_code = reader.string();
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                }
                case 6: {
                    if (tag !== 50) {
                        break;
                    }
                    message.description = reader.string();
                    continue;
                }
                case 7: {
                    if (tag !== 58) {
                        break;
                    }
                    message.level_category = reader.string();
                    continue;
                }
                case 8: {
                    if (tag !== 66) {
                        break;
                    }
                    message.symbol = reader.string();
                    continue;
                }
                case 9: {
                    if (tag !== 74) {
                        break;
                    }
                    message.conversion_factor = reader.string();
                    continue;
                }
                case 10: {
                    if (tag !== 82) {
                        break;
                    }
                    message.group_number = reader.string();
                    continue;
                }
                case 11: {
                    if (tag !== 88) {
                        break;
                    }
                    message.sector = sectorFromJSON(reader.int32());
                    continue;
                }
                case 12: {
                    if (tag !== 98) {
                        break;
                    }
                    message.group_id = reader.string();
                    continue;
                }
                case 13: {
                    if (tag !== 106) {
                        break;
                    }
                    message.quantity = reader.string();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : undefined,
            meta: isSet(object.meta) ? meta_1.Meta.fromJSON(object.meta) : undefined,
            status: isSet(object.status) ? statusCodeFromJSON(object.status) : undefined,
            common_code: isSet(object.commonCode)
                ? globalThis.String(object.commonCode)
                : isSet(object.common_code)
                    ? globalThis.String(object.common_code)
                    : undefined,
            name: isSet(object.name) ? globalThis.String(object.name) : undefined,
            description: isSet(object.description) ? globalThis.String(object.description) : undefined,
            level_category: isSet(object.levelCategory)
                ? globalThis.String(object.levelCategory)
                : isSet(object.level_category)
                    ? globalThis.String(object.level_category)
                    : undefined,
            symbol: isSet(object.symbol) ? globalThis.String(object.symbol) : undefined,
            conversion_factor: isSet(object.conversionFactor)
                ? globalThis.String(object.conversionFactor)
                : isSet(object.conversion_factor)
                    ? globalThis.String(object.conversion_factor)
                    : undefined,
            group_number: isSet(object.groupNumber)
                ? globalThis.String(object.groupNumber)
                : isSet(object.group_number)
                    ? globalThis.String(object.group_number)
                    : undefined,
            sector: isSet(object.sector) ? sectorFromJSON(object.sector) : undefined,
            group_id: isSet(object.groupId)
                ? globalThis.String(object.groupId)
                : isSet(object.group_id)
                    ? globalThis.String(object.group_id)
                    : undefined,
            quantity: isSet(object.quantity) ? globalThis.String(object.quantity) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        if (message.meta !== undefined) {
            obj.meta = meta_1.Meta.toJSON(message.meta);
        }
        if (message.status !== undefined) {
            obj.status = statusCodeToJSON(message.status);
        }
        if (message.common_code !== undefined) {
            obj.commonCode = message.common_code;
        }
        if (message.name !== undefined) {
            obj.name = message.name;
        }
        if (message.description !== undefined) {
            obj.description = message.description;
        }
        if (message.level_category !== undefined) {
            obj.levelCategory = message.level_category;
        }
        if (message.symbol !== undefined) {
            obj.symbol = message.symbol;
        }
        if (message.conversion_factor !== undefined) {
            obj.conversionFactor = message.conversion_factor;
        }
        if (message.group_number !== undefined) {
            obj.groupNumber = message.group_number;
        }
        if (message.sector !== undefined) {
            obj.sector = sectorToJSON(message.sector);
        }
        if (message.group_id !== undefined) {
            obj.groupId = message.group_id;
        }
        if (message.quantity !== undefined) {
            obj.quantity = message.quantity;
        }
        return obj;
    },
    create(base) {
        return exports.UnitCode.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseUnitCode();
        message.id = object.id ?? undefined;
        message.meta = (object.meta !== undefined && object.meta !== null) ? meta_1.Meta.fromPartial(object.meta) : undefined;
        message.status = object.status ?? undefined;
        message.common_code = object.common_code ?? undefined;
        message.name = object.name ?? undefined;
        message.description = object.description ?? undefined;
        message.level_category = object.level_category ?? undefined;
        message.symbol = object.symbol ?? undefined;
        message.conversion_factor = object.conversion_factor ?? undefined;
        message.group_number = object.group_number ?? undefined;
        message.sector = object.sector ?? undefined;
        message.group_id = object.group_id ?? undefined;
        message.quantity = object.quantity ?? undefined;
        return message;
    },
};
exports.UnitCodeServiceDefinition = {
    name: "UnitCodeService",
    fullName: "io.restorecommerce.unit_code.UnitCodeService",
    methods: {
        read: {
            name: "Read",
            requestType: resource_base_1.ReadRequest,
            requestStream: false,
            responseType: exports.UnitCodeListResponse,
            responseStream: false,
            options: { _unknownFields: { 248008: [Buffer.from([1])] } },
        },
        create: {
            name: "Create",
            requestType: exports.UnitCodeList,
            requestStream: false,
            responseType: exports.UnitCodeListResponse,
            responseStream: false,
            options: {},
        },
        delete: {
            name: "Delete",
            requestType: resource_base_1.DeleteRequest,
            requestStream: false,
            responseType: resource_base_1.DeleteResponse,
            responseStream: false,
            options: {},
        },
        update: {
            name: "Update",
            requestType: exports.UnitCodeList,
            requestStream: false,
            responseType: exports.UnitCodeListResponse,
            responseStream: false,
            options: {},
        },
        upsert: {
            name: "Upsert",
            requestType: exports.UnitCodeList,
            requestStream: false,
            responseType: exports.UnitCodeListResponse,
            responseStream: false,
            options: {},
        },
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/unit_code.proto",
        "package": "io.restorecommerce.unit_code",
        "dependency": [
            "io/restorecommerce/resource_base.proto",
            "io/restorecommerce/meta.proto",
            "io/restorecommerce/auth.proto",
            "io/restorecommerce/status.proto",
            "io/restorecommerce/options.proto",
        ],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "UnitCodeList",
                "field": [{
                        "name": "items",
                        "number": 1,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.unit_code.UnitCode",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "items",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "total_count",
                        "number": 2,
                        "label": 1,
                        "type": 13,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "totalCount",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "subject",
                        "number": 3,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.auth.Subject",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "subject",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_total_count", "options": undefined }, { "name": "_subject", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "UnitCodeListResponse",
                "field": [{
                        "name": "items",
                        "number": 1,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.unit_code.UnitCodeResponse",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "items",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "total_count",
                        "number": 2,
                        "label": 1,
                        "type": 13,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "totalCount",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "operation_status",
                        "number": 3,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.status.OperationStatus",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "operationStatus",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_total_count", "options": undefined }, {
                        "name": "_operation_status",
                        "options": undefined,
                    }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "UnitCodeResponse",
                "field": [{
                        "name": "payload",
                        "number": 1,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.unit_code.UnitCode",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "payload",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "status",
                        "number": 2,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.status.Status",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "status",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_payload", "options": undefined }, { "name": "_status", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "UnitCode",
                "field": [{
                        "name": "id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "meta",
                        "number": 2,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.meta.Meta",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "meta",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "status",
                        "number": 3,
                        "label": 1,
                        "type": 14,
                        "typeName": ".io.restorecommerce.unit_code.StatusCode",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "status",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "common_code",
                        "number": 4,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 3,
                        "jsonName": "commonCode",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "name",
                        "number": 5,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 4,
                        "jsonName": "name",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "description",
                        "number": 6,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 5,
                        "jsonName": "description",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "level_category",
                        "number": 7,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 6,
                        "jsonName": "levelCategory",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "symbol",
                        "number": 8,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 7,
                        "jsonName": "symbol",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "conversion_factor",
                        "number": 9,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 8,
                        "jsonName": "conversionFactor",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "group_number",
                        "number": 10,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 9,
                        "jsonName": "groupNumber",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "sector",
                        "number": 11,
                        "label": 1,
                        "type": 14,
                        "typeName": ".io.restorecommerce.unit_code.Sector",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 10,
                        "jsonName": "sector",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "group_id",
                        "number": 12,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 11,
                        "jsonName": "groupId",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "quantity",
                        "number": 13,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 12,
                        "jsonName": "quantity",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [
                    { "name": "_id", "options": undefined },
                    { "name": "_meta", "options": undefined },
                    { "name": "_status", "options": undefined },
                    { "name": "_common_code", "options": undefined },
                    { "name": "_name", "options": undefined },
                    { "name": "_description", "options": undefined },
                    { "name": "_level_category", "options": undefined },
                    { "name": "_symbol", "options": undefined },
                    { "name": "_conversion_factor", "options": undefined },
                    { "name": "_group_number", "options": undefined },
                    { "name": "_sector", "options": undefined },
                    { "name": "_group_id", "options": undefined },
                    { "name": "_quantity", "options": undefined },
                ],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [{
                "name": "StatusCode",
                "value": [
                    { "name": "ADDED", "number": 0, "options": undefined },
                    { "name": "CHANGED_NAME", "number": 1, "options": undefined },
                    { "name": "CHANGED_CHARACTERISTIC", "number": 2, "options": undefined },
                    { "name": "DEPRECATED", "number": 3, "options": undefined },
                    { "name": "MARKED_AS_DELETED", "number": 4, "options": undefined },
                    { "name": "REINSTATED", "number": 5, "options": undefined },
                ],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "Sector",
                "value": [
                    { "name": "UNKNOWN", "number": 0, "options": undefined },
                    { "name": "ACOUSTICS", "number": 1, "options": undefined },
                    { "name": "ATOMIC_AND_NUCLEAR_PHYSICS", "number": 2, "options": undefined },
                    { "name": "CHARACTERISTIC_NUMBERS", "number": 3, "options": undefined },
                    { "name": "ELECTRICITY_AND_MAGNETISM", "number": 4, "options": undefined },
                    { "name": "HEAT", "number": 5, "options": undefined },
                    { "name": "LIGHT_AND_RELATED_ELECTROMAGNETIC_RADIATIONS", "number": 6, "options": undefined },
                    { "name": "MECHANICS", "number": 7, "options": undefined },
                    { "name": "MISCELLANEOUS", "number": 8, "options": undefined },
                    { "name": "NUCLEAR_REACTIONS_AND_IONIZING_RADIATIONS", "number": 9, "options": undefined },
                    { "name": "PERIODIC_AND_RELATED_PHASES", "number": 10, "options": undefined },
                    { "name": "PHYSICAL_CHEMISTRY_AND_MOLECULAR_PHYSICS", "number": 11, "options": undefined },
                    { "name": "SOLID_STATE_PHYSICS", "number": 12, "options": undefined },
                    { "name": "SPACE_AND_TIME", "number": 13, "options": undefined },
                ],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "service": [{
                "name": "UnitCodeService",
                "method": [{
                        "name": "Read",
                        "inputType": ".io.restorecommerce.resourcebase.ReadRequest",
                        "outputType": ".io.restorecommerce.unit_code.UnitCodeListResponse",
                        "options": { "deprecated": false, "idempotencyLevel": 0, "features": undefined, "uninterpretedOption": [] },
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Create",
                        "inputType": ".io.restorecommerce.unit_code.UnitCodeList",
                        "outputType": ".io.restorecommerce.unit_code.UnitCodeListResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Delete",
                        "inputType": ".io.restorecommerce.resourcebase.DeleteRequest",
                        "outputType": ".io.restorecommerce.resourcebase.DeleteResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Update",
                        "inputType": ".io.restorecommerce.unit_code.UnitCodeList",
                        "outputType": ".io.restorecommerce.unit_code.UnitCodeListResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Upsert",
                        "inputType": ".io.restorecommerce.unit_code.UnitCodeList",
                        "outputType": ".io.restorecommerce.unit_code.UnitCodeListResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }],
                "options": undefined,
            }],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": { "location": [] },
        "syntax": "proto3",
        "edition": 0,
    },
    references: {
        ".io.restorecommerce.unit_code.StatusCode": StatusCode,
        ".io.restorecommerce.unit_code.Sector": Sector,
        ".io.restorecommerce.unit_code.UnitCodeList": exports.UnitCodeList,
        ".io.restorecommerce.unit_code.UnitCodeListResponse": exports.UnitCodeListResponse,
        ".io.restorecommerce.unit_code.UnitCodeResponse": exports.UnitCodeResponse,
        ".io.restorecommerce.unit_code.UnitCode": exports.UnitCode,
    },
    dependencies: [resource_base_1.protoMetadata, meta_1.protoMetadata, auth_1.protoMetadata, status_1.protoMetadata, options_1.protoMetadata],
    options: { services: { "UnitCodeService": { methods: { "Read": { "is_query": true } } } } },
};
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=unit_code.js.map