"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 json_utils_exports = {};
__export(json_utils_exports, {
  fromJSONLight: () => fromJSONLight,
  toJSONLight: () => toJSONLight
});
module.exports = __toCommonJS(json_utils_exports);
const fromJSONLight = (object) => {
  const { version, createdTimestamp, updatedTimestamp } = object.metadata || {};
  const content = {
    nodes: object.nodes,
    metadata: {
      version,
      createdTimestamp: fromJsonTimestamp(createdTimestamp),
      updatedTimestamp: fromJsonTimestamp(updatedTimestamp)
    }
  };
  return content;
};
const toJSONLight = (content) => {
  const { version, createdTimestamp, updatedTimestamp } = content.metadata || {};
  const object = {
    nodes: content.nodes,
    metadata: {
      version,
      createdTimestamp: createdTimestamp?.toISOString(),
      updatedTimestamp: updatedTimestamp?.toISOString()
    }
  };
  return object;
};
const baseTimestamp = { seconds: 0, nanos: 0 };
const TimestampObj = {
  fromJSON(object) {
    const message = { ...baseTimestamp };
    if (object.seconds !== void 0 && object.seconds !== null) {
      message.seconds = Number(object.seconds);
    } else {
      message.seconds = 0;
    }
    if (object.nanos !== void 0 && object.nanos !== null) {
      message.nanos = Number(object.nanos);
    } else {
      message.nanos = 0;
    }
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.seconds !== void 0 && (obj.seconds = message.seconds);
    message.nanos !== void 0 && (obj.nanos = message.nanos);
    return obj;
  }
};
function fromTimestamp(t) {
  let millis = t.seconds * 1e3;
  millis += t.nanos / 1e6;
  return new Date(millis);
}
function fromJsonTimestamp(o) {
  if (o instanceof Date) {
    return o;
  } else if (typeof o === "string") {
    return new Date(o);
  } else {
    return fromTimestamp(TimestampObj.fromJSON(o));
  }
}
//# sourceMappingURL=json-utils.js.map
