"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/image.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.Deleted = exports.ImageList = exports.Image = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
exports.protobufPackage = "io.restorecommerce.image";
function createBaseImage() {
    return {};
}
exports.Image = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.id !== undefined) {
            writer.uint32(10).string(message.id);
        }
        if (message.caption !== undefined) {
            writer.uint32(18).string(message.caption);
        }
        if (message.filename !== undefined) {
            writer.uint32(26).string(message.filename);
        }
        if (message.content_type !== undefined) {
            writer.uint32(34).string(message.content_type);
        }
        if (message.url !== undefined) {
            writer.uint32(42).string(message.url);
        }
        if (message.base64 !== undefined) {
            writer.uint32(50).string(message.base64);
        }
        if (message.blob !== undefined) {
            writer.uint32(58).bytes(message.blob);
        }
        if (message.width !== undefined) {
            writer.uint32(65).double(message.width);
        }
        if (message.height !== undefined) {
            writer.uint32(73).double(message.height);
        }
        if (message.length !== undefined) {
            writer.uint32(81).double(message.length);
        }
        if (message.tags !== undefined && message.tags.length !== 0) {
            for (const v of message.tags) {
                writer.uint32(90).string(v);
            }
        }
        if (message.index !== undefined) {
            writer.uint32(96).int64(message.index);
        }
        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 = createBaseImage();
        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.caption = reader.string();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.filename = reader.string();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.content_type = reader.string();
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.url = reader.string();
                    continue;
                }
                case 6: {
                    if (tag !== 50) {
                        break;
                    }
                    message.base64 = reader.string();
                    continue;
                }
                case 7: {
                    if (tag !== 58) {
                        break;
                    }
                    message.blob = Buffer.from(reader.bytes());
                    continue;
                }
                case 8: {
                    if (tag !== 65) {
                        break;
                    }
                    message.width = reader.double();
                    continue;
                }
                case 9: {
                    if (tag !== 73) {
                        break;
                    }
                    message.height = reader.double();
                    continue;
                }
                case 10: {
                    if (tag !== 81) {
                        break;
                    }
                    message.length = reader.double();
                    continue;
                }
                case 11: {
                    if (tag !== 90) {
                        break;
                    }
                    if (message.tags === undefined) {
                        message.tags = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.tags.push(el);
                    }
                    continue;
                }
                case 12: {
                    if (tag !== 96) {
                        break;
                    }
                    message.index = longToNumber(reader.int64());
                    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,
            caption: isSet(object.caption) ? globalThis.String(object.caption) : undefined,
            filename: isSet(object.filename) ? globalThis.String(object.filename) : undefined,
            content_type: isSet(object.contentType)
                ? globalThis.String(object.contentType)
                : isSet(object.content_type)
                    ? globalThis.String(object.content_type)
                    : undefined,
            url: isSet(object.url) ? globalThis.String(object.url) : undefined,
            base64: isSet(object.base64) ? globalThis.String(object.base64) : undefined,
            blob: isSet(object.blob) ? Buffer.from(bytesFromBase64(object.blob)) : undefined,
            width: isSet(object.width) ? globalThis.Number(object.width) : undefined,
            height: isSet(object.height) ? globalThis.Number(object.height) : undefined,
            length: isSet(object.length) ? globalThis.Number(object.length) : undefined,
            tags: globalThis.Array.isArray(object?.tags) ? object.tags.map((e) => globalThis.String(e)) : undefined,
            index: isSet(object.index) ? globalThis.Number(object.index) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        if (message.caption !== undefined) {
            obj.caption = message.caption;
        }
        if (message.filename !== undefined) {
            obj.filename = message.filename;
        }
        if (message.content_type !== undefined) {
            obj.contentType = message.content_type;
        }
        if (message.url !== undefined) {
            obj.url = message.url;
        }
        if (message.base64 !== undefined) {
            obj.base64 = message.base64;
        }
        if (message.blob !== undefined) {
            obj.blob = base64FromBytes(message.blob);
        }
        if (message.width !== undefined) {
            obj.width = message.width;
        }
        if (message.height !== undefined) {
            obj.height = message.height;
        }
        if (message.length !== undefined) {
            obj.length = message.length;
        }
        if (message.tags?.length) {
            obj.tags = message.tags;
        }
        if (message.index !== undefined) {
            obj.index = Math.round(message.index);
        }
        return obj;
    },
    create(base) {
        return exports.Image.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseImage();
        message.id = object.id ?? undefined;
        message.caption = object.caption ?? undefined;
        message.filename = object.filename ?? undefined;
        message.content_type = object.content_type ?? undefined;
        message.url = object.url ?? undefined;
        message.base64 = object.base64 ?? undefined;
        message.blob = object.blob ?? undefined;
        message.width = object.width ?? undefined;
        message.height = object.height ?? undefined;
        message.length = object.length ?? undefined;
        message.tags = object.tags?.map((e) => e) || undefined;
        message.index = object.index ?? undefined;
        return message;
    },
};
function createBaseImageList() {
    return {};
}
exports.ImageList = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.items !== undefined && message.items.length !== 0) {
            for (const v of message.items) {
                exports.Image.encode(v, writer.uint32(10).fork()).join();
            }
        }
        if (message.total_count !== undefined) {
            writer.uint32(16).uint32(message.total_count);
        }
        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 = createBaseImageList();
        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.Image.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.items.push(el);
                    }
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.total_count = 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.Image.fromJSON(e)) : undefined,
            total_count: isSet(object.totalCount)
                ? globalThis.Number(object.totalCount)
                : isSet(object.total_count)
                    ? globalThis.Number(object.total_count)
                    : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.items?.length) {
            obj.items = message.items.map((e) => exports.Image.toJSON(e));
        }
        if (message.total_count !== undefined) {
            obj.totalCount = Math.round(message.total_count);
        }
        return obj;
    },
    create(base) {
        return exports.ImageList.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseImageList();
        message.items = object.items?.map((e) => exports.Image.fromPartial(e)) || undefined;
        message.total_count = object.total_count ?? undefined;
        return message;
    },
};
function createBaseDeleted() {
    return {};
}
exports.Deleted = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.id !== undefined) {
            writer.uint32(10).string(message.id);
        }
        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 = createBaseDeleted();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.id = 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 };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        return obj;
    },
    create(base) {
        return exports.Deleted.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseDeleted();
        message.id = object.id ?? undefined;
        return message;
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/image.proto",
        "package": "io.restorecommerce.image",
        "dependency": [],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "Image",
                "field": [{
                        "name": "id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "caption",
                        "number": 2,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "caption",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "filename",
                        "number": 3,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 3,
                        "jsonName": "filename",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "content_type",
                        "number": 4,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 4,
                        "jsonName": "contentType",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "url",
                        "number": 5,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "url",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "base64",
                        "number": 6,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "base64",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "blob",
                        "number": 7,
                        "label": 1,
                        "type": 12,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "blob",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "width",
                        "number": 8,
                        "label": 1,
                        "type": 1,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 5,
                        "jsonName": "width",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "height",
                        "number": 9,
                        "label": 1,
                        "type": 1,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 6,
                        "jsonName": "height",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "length",
                        "number": 10,
                        "label": 1,
                        "type": 1,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 7,
                        "jsonName": "length",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "tags",
                        "number": 11,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "tags",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "index",
                        "number": 12,
                        "label": 1,
                        "type": 3,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 8,
                        "jsonName": "index",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [
                    { "name": "type", "options": undefined },
                    { "name": "_id", "options": undefined },
                    { "name": "_caption", "options": undefined },
                    { "name": "_filename", "options": undefined },
                    { "name": "_content_type", "options": undefined },
                    { "name": "_width", "options": undefined },
                    { "name": "_height", "options": undefined },
                    { "name": "_length", "options": undefined },
                    { "name": "_index", "options": undefined },
                ],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "ImageList",
                "field": [{
                        "name": "items",
                        "number": 1,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.image.Image",
                        "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,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_total_count", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "Deleted",
                "field": [{
                        "name": "id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_id", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": { "location": [] },
        "syntax": "proto3",
        "edition": 0,
    },
    references: {
        ".io.restorecommerce.image.Image": exports.Image,
        ".io.restorecommerce.image.ImageList": exports.ImageList,
        ".io.restorecommerce.image.Deleted": exports.Deleted,
    },
    dependencies: [],
};
function bytesFromBase64(b64) {
    return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
}
function base64FromBytes(arr) {
    return globalThis.Buffer.from(arr).toString("base64");
}
function longToNumber(int64) {
    const num = globalThis.Number(int64.toString());
    if (num > globalThis.Number.MAX_SAFE_INTEGER) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    if (num < globalThis.Number.MIN_SAFE_INTEGER) {
        throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
    }
    return num;
}
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=image.js.map