var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var resource_exports = {};
__export(resource_exports, {
  Resource: () => Resource,
  protobufPackage: () => protobufPackage
});
module.exports = __toCommonJS(resource_exports);
var import_global_this = __toESM(require("@babel/runtime-corejs3/core-js/global-this"));
var import_map = __toESM(require("@babel/runtime-corejs3/core-js/instance/map"));
var import_bind = __toESM(require("@babel/runtime-corejs3/core-js/instance/bind"));
var import_minimal = __toESM(require("protobufjs/minimal.js"));
var import_common = require("../../common/v1/common.js");
const protobufPackage = "opentelemetry.proto.resource.v1";
function createBaseResource() {
  return {
    attributes: [],
    droppedAttributesCount: 0
  };
}
const Resource = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.attributes) {
      import_common.KeyValue.encode(v, writer.uint32(10).fork()).ldelim();
    }
    if (message.droppedAttributesCount !== 0) {
      writer.uint32(16).uint32(message.droppedAttributesCount);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseResource();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.attributes.push(import_common.KeyValue.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }
          message.droppedAttributesCount = reader.uint32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context;
    return {
      attributes: import_global_this.default.Array.isArray(object?.attributes) ? (0, import_map.default)(_context = object.attributes).call(_context, (e) => import_common.KeyValue.fromJSON(e)) : [],
      droppedAttributesCount: isSet(object.droppedAttributesCount) ? import_global_this.default.Number(object.droppedAttributesCount) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.attributes?.length) {
      var _context2;
      obj.attributes = (0, import_map.default)(_context2 = message.attributes).call(_context2, (e) => import_common.KeyValue.toJSON(e));
    }
    if (message.droppedAttributesCount !== 0) {
      obj.droppedAttributesCount = Math.round(message.droppedAttributesCount);
    }
    return obj;
  },
  create(base) {
    return Resource.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context3, _context4;
    const message = createBaseResource();
    message.attributes = ((_context3 = object.attributes) == null ? void 0 : (0, import_bind.default)(_context4 = Function.call).call(_context4, (0, import_map.default)(_context3), _context3))?.((e) => import_common.KeyValue.fromPartial(e)) || [];
    message.droppedAttributesCount = object.droppedAttributesCount ?? 0;
    return message;
  }
};
function isSet(value) {
  return value !== null && value !== void 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Resource,
  protobufPackage
});
//# sourceMappingURL=resource.js.map
