import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
import {
  SDK_INFO,
  getStringFromEnv,
  init_esm as init_esm3
} from "./chunk-SR4I5KET.js";
import {
  ATTR_SERVICE_NAME,
  ATTR_TELEMETRY_SDK_LANGUAGE,
  ATTR_TELEMETRY_SDK_NAME,
  ATTR_TELEMETRY_SDK_VERSION,
  init_esm as init_esm2
} from "./chunk-VQ2ZO7XJ.js";
import {
  diag,
  init_esm
} from "./chunk-LRULMAAA.js";
import {
  __esm
} from "./chunk-5H446C7X.js";

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/default-service-name.js
function defaultServiceName() {
  if (serviceName === void 0) {
    try {
      const argv0 = globalThis.process.argv0;
      serviceName = argv0 ? `unknown_service:${argv0}` : "unknown_service";
    } catch {
      serviceName = "unknown_service";
    }
  }
  return serviceName;
}
var serviceName;
var init_default_service_name = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/default-service-name.js"() {
    "use strict";
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/utils.js
var isPromiseLike;
var init_utils = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/utils.js"() {
    "use strict";
    isPromiseLike = (val) => {
      return val !== null && typeof val === "object" && typeof val.then === "function";
    };
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js
function resourceFromAttributes(attributes, options) {
  return ResourceImpl.FromAttributeList(Object.entries(attributes), options);
}
function resourceFromDetectedResource(detectedResource, options) {
  return new ResourceImpl(detectedResource, options);
}
function emptyResource() {
  return resourceFromAttributes({});
}
function defaultResource() {
  return resourceFromAttributes({
    [ATTR_SERVICE_NAME]: defaultServiceName(),
    [ATTR_TELEMETRY_SDK_LANGUAGE]: SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE],
    [ATTR_TELEMETRY_SDK_NAME]: SDK_INFO[ATTR_TELEMETRY_SDK_NAME],
    [ATTR_TELEMETRY_SDK_VERSION]: SDK_INFO[ATTR_TELEMETRY_SDK_VERSION]
  });
}
function guardedRawAttributes(attributes) {
  return attributes.map(([k, v]) => {
    if (isPromiseLike(v)) {
      return [
        k,
        v.catch((err) => {
          diag.debug("promise rejection for resource attribute: %s - %s", k, err);
          return void 0;
        })
      ];
    }
    return [k, v];
  });
}
function validateSchemaUrl(schemaUrl) {
  if (typeof schemaUrl === "string" || schemaUrl === void 0) {
    return schemaUrl;
  }
  diag.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.", schemaUrl);
  return void 0;
}
function mergeSchemaUrl(old, updating) {
  const oldSchemaUrl = old?.schemaUrl;
  const updatingSchemaUrl = updating?.schemaUrl;
  const isOldEmpty = oldSchemaUrl === void 0 || oldSchemaUrl === "";
  const isUpdatingEmpty = updatingSchemaUrl === void 0 || updatingSchemaUrl === "";
  if (isOldEmpty) {
    return updatingSchemaUrl;
  }
  if (isUpdatingEmpty) {
    return oldSchemaUrl;
  }
  if (oldSchemaUrl === updatingSchemaUrl) {
    return oldSchemaUrl;
  }
  diag.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.', oldSchemaUrl, updatingSchemaUrl);
  return void 0;
}
var ResourceImpl;
var init_ResourceImpl = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js"() {
    "use strict";
    init_esm();
    init_esm3();
    init_esm2();
    init_default_service_name();
    init_utils();
    ResourceImpl = class _ResourceImpl {
      _rawAttributes;
      _asyncAttributesPending = false;
      _schemaUrl;
      _memoizedAttributes;
      static FromAttributeList(attributes, options) {
        const res = new _ResourceImpl({}, options);
        res._rawAttributes = guardedRawAttributes(attributes);
        res._asyncAttributesPending = attributes.filter(([_, val]) => isPromiseLike(val)).length > 0;
        return res;
      }
      constructor(resource, options) {
        const attributes = resource.attributes ?? {};
        this._rawAttributes = Object.entries(attributes).map(([k, v]) => {
          if (isPromiseLike(v)) {
            this._asyncAttributesPending = true;
          }
          return [k, v];
        });
        this._rawAttributes = guardedRawAttributes(this._rawAttributes);
        this._schemaUrl = validateSchemaUrl(options?.schemaUrl);
      }
      get asyncAttributesPending() {
        return this._asyncAttributesPending;
      }
      async waitForAsyncAttributes() {
        if (!this.asyncAttributesPending) {
          return;
        }
        for (let i = 0; i < this._rawAttributes.length; i++) {
          const [k, v] = this._rawAttributes[i];
          this._rawAttributes[i] = [k, isPromiseLike(v) ? await v : v];
        }
        this._asyncAttributesPending = false;
      }
      get attributes() {
        if (this.asyncAttributesPending) {
          diag.error("Accessing resource attributes before async attributes settled");
        }
        if (this._memoizedAttributes) {
          return this._memoizedAttributes;
        }
        const attrs = {};
        for (const [k, v] of this._rawAttributes) {
          if (isPromiseLike(v)) {
            diag.debug(`Unsettled resource attribute ${k} skipped`);
            continue;
          }
          if (v != null) {
            attrs[k] ??= v;
          }
        }
        if (!this._asyncAttributesPending) {
          this._memoizedAttributes = attrs;
        }
        return attrs;
      }
      getRawAttributes() {
        return this._rawAttributes;
      }
      get schemaUrl() {
        return this._schemaUrl;
      }
      merge(resource) {
        if (resource == null)
          return this;
        const mergedSchemaUrl = mergeSchemaUrl(this, resource);
        const mergedOptions = mergedSchemaUrl ? { schemaUrl: mergedSchemaUrl } : void 0;
        return _ResourceImpl.FromAttributeList([...resource.getRawAttributes(), ...this.getRawAttributes()], mergedOptions);
      }
    };
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detect-resources.js
var detectResources;
var init_detect_resources = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detect-resources.js"() {
    "use strict";
    init_esm();
    init_ResourceImpl();
    detectResources = (config = {}) => {
      const resources = (config.detectors || []).map((d) => {
        try {
          const resource = resourceFromDetectedResource(d.detect(config));
          diag.debug(`${d.constructor.name} found resource.`, resource);
          return resource;
        } catch (e) {
          diag.debug(`${d.constructor.name} failed: ${e.message}`);
          return emptyResource();
        }
      });
      return resources.reduce((acc, resource) => acc.merge(resource), emptyResource());
    };
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/EnvDetector.js
var EnvDetector, envDetector;
var init_EnvDetector = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/EnvDetector.js"() {
    "use strict";
    init_esm();
    init_esm2();
    init_esm3();
    EnvDetector = class {
      // Type, attribute keys, and attribute values should not exceed 256 characters.
      _MAX_LENGTH = 255;
      // OTEL_RESOURCE_ATTRIBUTES is a comma-separated list of attributes.
      _COMMA_SEPARATOR = ",";
      // OTEL_RESOURCE_ATTRIBUTES contains key value pair separated by '='.
      _LABEL_KEY_VALUE_SPLITTER = "=";
      _ERROR_MESSAGE_INVALID_CHARS = "should be a ASCII string with a length greater than 0 and not exceed " + this._MAX_LENGTH + " characters.";
      _ERROR_MESSAGE_INVALID_VALUE = "should be a ASCII string with a length not exceed " + this._MAX_LENGTH + " characters.";
      /**
       * Returns a {@link Resource} populated with attributes from the
       * OTEL_RESOURCE_ATTRIBUTES environment variable. Note this is an async
       * function to conform to the Detector interface.
       *
       * @param config The resource detection config
       */
      detect(_config) {
        const attributes = {};
        const rawAttributes = getStringFromEnv("OTEL_RESOURCE_ATTRIBUTES");
        const serviceName2 = getStringFromEnv("OTEL_SERVICE_NAME");
        if (rawAttributes) {
          try {
            const parsedAttributes = this._parseResourceAttributes(rawAttributes);
            Object.assign(attributes, parsedAttributes);
          } catch (e) {
            diag.debug(`EnvDetector failed: ${e.message}`);
          }
        }
        if (serviceName2) {
          attributes[ATTR_SERVICE_NAME] = serviceName2;
        }
        return { attributes };
      }
      /**
       * Creates an attribute map from the OTEL_RESOURCE_ATTRIBUTES environment
       * variable.
       *
       * OTEL_RESOURCE_ATTRIBUTES: A comma-separated list of attributes describing
       * the source in more detail, e.g. “key1=val1,key2=val2”. Domain names and
       * paths are accepted as attribute keys. Values may be quoted or unquoted in
       * general. If a value contains whitespace, =, or " characters, it must
       * always be quoted.
       *
       * @param rawEnvAttributes The resource attributes as a comma-separated list
       * of key/value pairs.
       * @returns The sanitized resource attributes.
       */
      _parseResourceAttributes(rawEnvAttributes) {
        if (!rawEnvAttributes)
          return {};
        const attributes = {};
        const rawAttributes = rawEnvAttributes.split(this._COMMA_SEPARATOR, -1);
        for (const rawAttribute of rawAttributes) {
          const keyValuePair = rawAttribute.split(this._LABEL_KEY_VALUE_SPLITTER, -1);
          if (keyValuePair.length !== 2) {
            continue;
          }
          let [key, value] = keyValuePair;
          key = key.trim();
          value = value.trim().split(/^"|"$/).join("");
          if (!this._isValidAndNotEmpty(key)) {
            throw new Error(`Attribute key ${this._ERROR_MESSAGE_INVALID_CHARS}`);
          }
          if (!this._isValid(value)) {
            throw new Error(`Attribute value ${this._ERROR_MESSAGE_INVALID_VALUE}`);
          }
          attributes[key] = decodeURIComponent(value);
        }
        return attributes;
      }
      /**
       * Determines whether the given String is a valid printable ASCII string with
       * a length not exceed _MAX_LENGTH characters.
       *
       * @param str The String to be validated.
       * @returns Whether the String is valid.
       */
      _isValid(name) {
        return name.length <= this._MAX_LENGTH && this._isBaggageOctetString(name);
      }
      // https://www.w3.org/TR/baggage/#definition
      _isBaggageOctetString(str) {
        for (let i = 0; i < str.length; i++) {
          const ch = str.charCodeAt(i);
          if (ch < 33 || ch === 44 || ch === 59 || ch === 92 || ch > 126) {
            return false;
          }
        }
        return true;
      }
      /**
       * Determines whether the given String is a valid printable ASCII string with
       * a length greater than 0 and not exceed _MAX_LENGTH characters.
       *
       * @param str The String to be validated.
       * @returns Whether the String is valid and not empty.
       */
      _isValidAndNotEmpty(str) {
        return str.length > 0 && this._isValid(str);
      }
    };
    envDetector = new EnvDetector();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/semconv.js
var ATTR_HOST_ARCH, ATTR_HOST_ID, ATTR_HOST_NAME, ATTR_OS_TYPE, ATTR_OS_VERSION, ATTR_PROCESS_COMMAND, ATTR_PROCESS_COMMAND_ARGS, ATTR_PROCESS_EXECUTABLE_NAME, ATTR_PROCESS_EXECUTABLE_PATH, ATTR_PROCESS_OWNER, ATTR_PROCESS_PID, ATTR_PROCESS_RUNTIME_DESCRIPTION, ATTR_PROCESS_RUNTIME_NAME, ATTR_PROCESS_RUNTIME_VERSION, ATTR_SERVICE_INSTANCE_ID;
var init_semconv = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/semconv.js"() {
    "use strict";
    ATTR_HOST_ARCH = "host.arch";
    ATTR_HOST_ID = "host.id";
    ATTR_HOST_NAME = "host.name";
    ATTR_OS_TYPE = "os.type";
    ATTR_OS_VERSION = "os.version";
    ATTR_PROCESS_COMMAND = "process.command";
    ATTR_PROCESS_COMMAND_ARGS = "process.command_args";
    ATTR_PROCESS_EXECUTABLE_NAME = "process.executable.name";
    ATTR_PROCESS_EXECUTABLE_PATH = "process.executable.path";
    ATTR_PROCESS_OWNER = "process.owner";
    ATTR_PROCESS_PID = "process.pid";
    ATTR_PROCESS_RUNTIME_DESCRIPTION = "process.runtime.description";
    ATTR_PROCESS_RUNTIME_NAME = "process.runtime.name";
    ATTR_PROCESS_RUNTIME_VERSION = "process.runtime.version";
    ATTR_SERVICE_INSTANCE_ID = "service.instance.id";
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId.js
import * as process2 from "process";
async function getMachineId() {
  if (!getMachineIdImpl) {
    switch (process2.platform) {
      case "darwin":
        getMachineIdImpl = (await import("./getMachineId-darwin-4DP6CCJV.js")).getMachineId;
        break;
      case "linux":
        getMachineIdImpl = (await import("./getMachineId-linux-44LJ5UJB.js")).getMachineId;
        break;
      case "freebsd":
        getMachineIdImpl = (await import("./getMachineId-bsd-HSK5LZMG.js")).getMachineId;
        break;
      case "win32":
        getMachineIdImpl = (await import("./getMachineId-win-YZ36S7VA.js")).getMachineId;
        break;
      default:
        getMachineIdImpl = (await import("./getMachineId-unsupported-NVK6IATM.js")).getMachineId;
        break;
    }
  }
  return getMachineIdImpl();
}
var getMachineIdImpl;
var init_getMachineId = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId.js"() {
    "use strict";
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/utils.js
var normalizeArch, normalizeType;
var init_utils2 = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/utils.js"() {
    "use strict";
    normalizeArch = (nodeArchString) => {
      switch (nodeArchString) {
        case "arm":
          return "arm32";
        case "ppc":
          return "ppc32";
        case "x64":
          return "amd64";
        default:
          return nodeArchString;
      }
    };
    normalizeType = (nodePlatform) => {
      switch (nodePlatform) {
        case "sunos":
          return "solaris";
        case "win32":
          return "windows";
        default:
          return nodePlatform;
      }
    };
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/HostDetector.js
import { arch, hostname } from "os";
var HostDetector, hostDetector;
var init_HostDetector = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/HostDetector.js"() {
    "use strict";
    init_semconv();
    init_getMachineId();
    init_utils2();
    HostDetector = class {
      detect(_config) {
        const attributes = {
          [ATTR_HOST_NAME]: hostname(),
          [ATTR_HOST_ARCH]: normalizeArch(arch()),
          [ATTR_HOST_ID]: getMachineId()
        };
        return { attributes };
      }
    };
    hostDetector = new HostDetector();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/OSDetector.js
import { platform as platform2, release } from "os";
var OSDetector, osDetector;
var init_OSDetector = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/OSDetector.js"() {
    "use strict";
    init_semconv();
    init_utils2();
    OSDetector = class {
      detect(_config) {
        const attributes = {
          [ATTR_OS_TYPE]: normalizeType(platform2()),
          [ATTR_OS_VERSION]: release()
        };
        return { attributes };
      }
    };
    osDetector = new OSDetector();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/ProcessDetector.js
import * as os from "os";
var ProcessDetector, processDetector;
var init_ProcessDetector = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/ProcessDetector.js"() {
    "use strict";
    init_esm();
    init_semconv();
    ProcessDetector = class {
      detect(_config) {
        const attributes = {
          [ATTR_PROCESS_PID]: process.pid,
          [ATTR_PROCESS_EXECUTABLE_NAME]: process.title,
          [ATTR_PROCESS_EXECUTABLE_PATH]: process.execPath,
          [ATTR_PROCESS_COMMAND_ARGS]: [
            process.argv[0],
            ...process.execArgv,
            ...process.argv.slice(1)
          ],
          [ATTR_PROCESS_RUNTIME_VERSION]: process.versions.node,
          [ATTR_PROCESS_RUNTIME_NAME]: "nodejs",
          [ATTR_PROCESS_RUNTIME_DESCRIPTION]: "Node.js"
        };
        if (process.argv.length > 1) {
          attributes[ATTR_PROCESS_COMMAND] = process.argv[1];
        }
        try {
          const userInfo2 = os.userInfo();
          attributes[ATTR_PROCESS_OWNER] = userInfo2.username;
        } catch (e) {
          diag.debug(`error obtaining process owner: ${e}`);
        }
        return { attributes };
      }
    };
    processDetector = new ProcessDetector();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/ServiceInstanceIdDetector.js
import { randomUUID } from "crypto";
var ServiceInstanceIdDetector, serviceInstanceIdDetector;
var init_ServiceInstanceIdDetector = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/ServiceInstanceIdDetector.js"() {
    "use strict";
    init_semconv();
    ServiceInstanceIdDetector = class {
      detect(_config) {
        return {
          attributes: {
            [ATTR_SERVICE_INSTANCE_ID]: randomUUID()
          }
        };
      }
    };
    serviceInstanceIdDetector = new ServiceInstanceIdDetector();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/index.js
var init_node = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/index.js"() {
    "use strict";
    init_HostDetector();
    init_OSDetector();
    init_ProcessDetector();
    init_ServiceInstanceIdDetector();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/index.js
var init_platform = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/platform/index.js"() {
    "use strict";
    init_node();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/index.js
var init_detectors = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/detectors/index.js"() {
    "use strict";
    init_EnvDetector();
    init_platform();
  }
});

// ../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/index.js
var init_esm4 = __esm({
  "../../node_modules/.bun/@opentelemetry+resources@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/resources/build/esm/index.js"() {
    init_detect_resources();
    init_detectors();
    init_ResourceImpl();
    init_default_service_name();
  }
});

export {
  defaultServiceName,
  resourceFromAttributes,
  emptyResource,
  defaultResource,
  detectResources,
  envDetector,
  hostDetector,
  osDetector,
  processDetector,
  serviceInstanceIdDetector,
  init_esm4 as init_esm
};
//# sourceMappingURL=chunk-XOSNETAV.js.map