"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var struct_exports = {};
__export(struct_exports, {
  ListValue: () => ListValue,
  Struct: () => Struct,
  Struct_FieldsEntry: () => Struct_FieldsEntry,
  Value: () => Value,
  nullValueFromJSON: () => nullValueFromJSON,
  nullValueToJSON: () => nullValueToJSON
});
module.exports = __toCommonJS(struct_exports);
var import_struct_enums = require("./struct.enums.js");
function nullValueFromJSON(object) {
  switch (object) {
    case 0:
    case "NULL_VALUE":
      return import_struct_enums.NullValue.NULL_VALUE;
    case -1:
    case "UNRECOGNIZED":
    default:
      return import_struct_enums.NullValue.UNRECOGNIZED;
  }
}
function nullValueToJSON(object) {
  switch (object) {
    case import_struct_enums.NullValue.NULL_VALUE:
      return "NULL_VALUE";
    default:
      return "UNKNOWN";
  }
}
const baseStruct = {};
const Struct = {
  fromJSON(object) {
    const message = { ...baseStruct };
    message.fields = Object.entries(object.fields ?? {}).reduce((acc, [key, value]) => {
      acc[key] = Value.fromJSON(value);
      return acc;
    }, {});
    return message;
  },
  toJSON(message) {
    const obj = {};
    obj.fields = {};
    if (message.fields) {
      Object.entries(message.fields).forEach(([k, v]) => {
        obj.fields[k] = Value.toJSON(v);
      });
    }
    return obj;
  }
};
const baseStruct_FieldsEntry = { key: "" };
const Struct_FieldsEntry = {
  fromJSON(object) {
    const message = { ...baseStruct_FieldsEntry };
    message.key = object.key !== void 0 && object.key !== null ? String(object.key) : "";
    message.value = object.value !== void 0 && object.value !== null ? Value.fromJSON(object.value) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.key !== void 0 && (obj.key = message.key);
    message.value !== void 0 && (obj.value = message.value ? Value.toJSON(message.value) : void 0);
    return obj;
  }
};
const baseValue = {};
const Value = {
  fromJSON(object) {
    const message = { ...baseValue };
    message.nullValue = object.nullValue !== void 0 && object.nullValue !== null ? nullValueFromJSON(object.nullValue) : void 0;
    message.numberValue = object.numberValue !== void 0 && object.numberValue !== null ? Number(object.numberValue) : void 0;
    message.stringValue = object.stringValue !== void 0 && object.stringValue !== null ? String(object.stringValue) : void 0;
    message.boolValue = object.boolValue !== void 0 && object.boolValue !== null ? Boolean(object.boolValue) : void 0;
    message.structValue = object.structValue !== void 0 && object.structValue !== null ? Struct.fromJSON(object.structValue) : void 0;
    message.listValue = object.listValue !== void 0 && object.listValue !== null ? ListValue.fromJSON(object.listValue) : void 0;
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.nullValue !== void 0 && (obj.nullValue = message.nullValue !== void 0 ? nullValueToJSON(message.nullValue) : void 0);
    message.numberValue !== void 0 && (obj.numberValue = message.numberValue);
    message.stringValue !== void 0 && (obj.stringValue = message.stringValue);
    message.boolValue !== void 0 && (obj.boolValue = message.boolValue);
    message.structValue !== void 0 && (obj.structValue = message.structValue ? Struct.toJSON(message.structValue) : void 0);
    message.listValue !== void 0 && (obj.listValue = message.listValue ? ListValue.toJSON(message.listValue) : void 0);
    return obj;
  }
};
const baseListValue = {};
const ListValue = {
  fromJSON(object) {
    const message = { ...baseListValue };
    message.values = (object.values ?? []).map((e) => Value.fromJSON(e));
    return message;
  },
  toJSON(message) {
    const obj = {};
    if (message.values) {
      obj.values = message.values.map((e) => e ? Value.toJSON(e) : void 0);
    } else {
      obj.values = [];
    }
    return obj;
  }
};
//# sourceMappingURL=struct.js.map
