import { __name } from './chunk-IBAHCH6O.js';

// ../../node_modules/.bun/@sindresorhus+is@7.2.0/node_modules/@sindresorhus/is/distribution/utilities.js
function keysOf(value) {
  return Object.keys(value);
}
__name(keysOf, "keysOf");

// ../../node_modules/.bun/@sindresorhus+is@7.2.0/node_modules/@sindresorhus/is/distribution/index.js
var typedArrayTypeNames = [
  "Int8Array",
  "Uint8Array",
  "Uint8ClampedArray",
  "Int16Array",
  "Uint16Array",
  "Int32Array",
  "Uint32Array",
  "Float32Array",
  "Float64Array",
  "BigInt64Array",
  "BigUint64Array"
];
function isTypedArrayName(name) {
  return typedArrayTypeNames.includes(name);
}
__name(isTypedArrayName, "isTypedArrayName");
var objectTypeNames = [
  "Function",
  "Generator",
  "AsyncGenerator",
  "GeneratorFunction",
  "AsyncGeneratorFunction",
  "AsyncFunction",
  "Observable",
  "Array",
  "Buffer",
  "Blob",
  "Object",
  "RegExp",
  "Date",
  "Error",
  "Map",
  "Set",
  "WeakMap",
  "WeakSet",
  "WeakRef",
  "ArrayBuffer",
  "SharedArrayBuffer",
  "DataView",
  "Promise",
  "URL",
  "FormData",
  "URLSearchParams",
  "HTMLElement",
  "NaN",
  ...typedArrayTypeNames
];
function isObjectTypeName(name) {
  return objectTypeNames.includes(name);
}
__name(isObjectTypeName, "isObjectTypeName");
var primitiveTypeNames = [
  "null",
  "undefined",
  "string",
  "number",
  "bigint",
  "boolean",
  "symbol"
];
function isPrimitiveTypeName(name) {
  return primitiveTypeNames.includes(name);
}
__name(isPrimitiveTypeName, "isPrimitiveTypeName");
var getObjectType = /* @__PURE__ */ __name((value) => {
  const objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
  if (/HTML\w+Element/.test(objectTypeName) && isHtmlElement(value)) {
    return "HTMLElement";
  }
  if (isObjectTypeName(objectTypeName)) {
    return objectTypeName;
  }
  return void 0;
}, "getObjectType");
function detect(value) {
  if (value === null) {
    return "null";
  }
  switch (typeof value) {
    case "undefined": {
      return "undefined";
    }
    case "string": {
      return "string";
    }
    case "number": {
      return Number.isNaN(value) ? "NaN" : "number";
    }
    case "boolean": {
      return "boolean";
    }
    case "function": {
      return "Function";
    }
    case "bigint": {
      return "bigint";
    }
    case "symbol": {
      return "symbol";
    }
  }
  if (isObservable(value)) {
    return "Observable";
  }
  if (isArray(value)) {
    return "Array";
  }
  if (isBuffer(value)) {
    return "Buffer";
  }
  const tagType = getObjectType(value);
  if (tagType && tagType !== "Object") {
    return tagType;
  }
  if (hasPromiseApi(value)) {
    return "Promise";
  }
  if (value instanceof String || value instanceof Boolean || value instanceof Number) {
    throw new TypeError("Please don't use object wrappers for primitive types");
  }
  return "Object";
}
__name(detect, "detect");
function hasPromiseApi(value) {
  return isFunction(value?.then) && isFunction(value?.catch);
}
__name(hasPromiseApi, "hasPromiseApi");
Object.assign(detect, {
  all: isAll,
  any: isAny,
  array: isArray,
  arrayBuffer: isArrayBuffer,
  arrayLike: isArrayLike,
  asyncFunction: isAsyncFunction,
  asyncGenerator: isAsyncGenerator,
  asyncGeneratorFunction: isAsyncGeneratorFunction,
  asyncIterable: isAsyncIterable,
  bigint: isBigint,
  bigInt64Array: isBigInt64Array,
  bigUint64Array: isBigUint64Array,
  blob: isBlob,
  boolean: isBoolean,
  boundFunction: isBoundFunction,
  buffer: isBuffer,
  class: isClass,
  dataView: isDataView,
  date: isDate,
  detect,
  directInstanceOf: isDirectInstanceOf,
  emptyArray: isEmptyArray,
  emptyMap: isEmptyMap,
  emptyObject: isEmptyObject,
  emptySet: isEmptySet,
  emptyString: isEmptyString,
  emptyStringOrWhitespace: isEmptyStringOrWhitespace,
  enumCase: isEnumCase,
  error: isError,
  evenInteger: isEvenInteger,
  falsy: isFalsy,
  float32Array: isFloat32Array,
  float64Array: isFloat64Array,
  formData: isFormData,
  function: isFunction,
  generator: isGenerator,
  generatorFunction: isGeneratorFunction,
  htmlElement: isHtmlElement,
  infinite: isInfinite,
  inRange: isInRange,
  int16Array: isInt16Array,
  int32Array: isInt32Array,
  int8Array: isInt8Array,
  integer: isInteger,
  iterable: isIterable,
  map: isMap,
  nan: isNan,
  nativePromise: isNativePromise,
  negativeNumber: isNegativeNumber,
  nodeStream: isNodeStream,
  nonEmptyArray: isNonEmptyArray,
  nonEmptyMap: isNonEmptyMap,
  nonEmptyObject: isNonEmptyObject,
  nonEmptySet: isNonEmptySet,
  nonEmptyString: isNonEmptyString,
  nonEmptyStringAndNotWhitespace: isNonEmptyStringAndNotWhitespace,
  null: isNull,
  nullOrUndefined: isNullOrUndefined,
  number: isNumber,
  numericString: isNumericString,
  object: isObject,
  observable: isObservable,
  oddInteger: isOddInteger,
  plainObject: isPlainObject,
  positiveNumber: isPositiveNumber,
  primitive: isPrimitive,
  promise: isPromise,
  propertyKey: isPropertyKey,
  regExp: isRegExp,
  safeInteger: isSafeInteger,
  set: isSet,
  sharedArrayBuffer: isSharedArrayBuffer,
  string: isString,
  symbol: isSymbol,
  truthy: isTruthy,
  tupleLike: isTupleLike,
  typedArray: isTypedArray,
  uint16Array: isUint16Array,
  uint32Array: isUint32Array,
  uint8Array: isUint8Array,
  uint8ClampedArray: isUint8ClampedArray,
  undefined: isUndefined,
  urlInstance: isUrlInstance,
  urlSearchParams: isUrlSearchParams,
  urlString: isUrlString,
  optional: isOptional,
  validDate: isValidDate,
  validLength: isValidLength,
  weakMap: isWeakMap,
  weakRef: isWeakRef,
  weakSet: isWeakSet,
  whitespaceString: isWhitespaceString
});
function isAbsoluteModule2(remainder) {
  return (value) => isInteger(value) && Math.abs(value % 2) === remainder;
}
__name(isAbsoluteModule2, "isAbsoluteModule2");
function validatePredicateArray(predicateArray, allowEmpty) {
  if (predicateArray.length === 0) {
    if (allowEmpty) ; else {
      throw new TypeError("Invalid predicate array");
    }
    return;
  }
  for (const predicate of predicateArray) {
    if (!isFunction(predicate)) {
      throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
    }
  }
}
__name(validatePredicateArray, "validatePredicateArray");
function isAll(predicate, ...values) {
  if (Array.isArray(predicate)) {
    const predicateArray = predicate;
    validatePredicateArray(predicateArray, values.length === 0);
    const combinedPredicate = /* @__PURE__ */ __name((value) => predicateArray.every((singlePredicate) => singlePredicate(value)), "combinedPredicate");
    if (values.length === 0) {
      return combinedPredicate;
    }
    return predicateOnArray(Array.prototype.every, combinedPredicate, values);
  }
  return predicateOnArray(Array.prototype.every, predicate, values);
}
__name(isAll, "isAll");
function isAny(predicate, ...values) {
  if (Array.isArray(predicate)) {
    const predicateArray = predicate;
    validatePredicateArray(predicateArray, values.length === 0);
    const combinedPredicate = /* @__PURE__ */ __name((value) => predicateArray.some((singlePredicate) => singlePredicate(value)), "combinedPredicate");
    if (values.length === 0) {
      return combinedPredicate;
    }
    return predicateOnArray(Array.prototype.some, combinedPredicate, values);
  }
  return predicateOnArray(Array.prototype.some, predicate, values);
}
__name(isAny, "isAny");
function isOptional(value, predicate) {
  return isUndefined(value) || predicate(value);
}
__name(isOptional, "isOptional");
function isArray(value, assertion) {
  if (!Array.isArray(value)) {
    return false;
  }
  if (!isFunction(assertion)) {
    return true;
  }
  return value.every((element) => assertion(element));
}
__name(isArray, "isArray");
function isArrayBuffer(value) {
  return getObjectType(value) === "ArrayBuffer";
}
__name(isArrayBuffer, "isArrayBuffer");
function isArrayLike(value) {
  return !isNullOrUndefined(value) && !isFunction(value) && isValidLength(value.length);
}
__name(isArrayLike, "isArrayLike");
function isAsyncFunction(value) {
  return getObjectType(value) === "AsyncFunction";
}
__name(isAsyncFunction, "isAsyncFunction");
function isAsyncGenerator(value) {
  return isAsyncIterable(value) && isFunction(value.next) && isFunction(value.throw);
}
__name(isAsyncGenerator, "isAsyncGenerator");
function isAsyncGeneratorFunction(value) {
  return getObjectType(value) === "AsyncGeneratorFunction";
}
__name(isAsyncGeneratorFunction, "isAsyncGeneratorFunction");
function isAsyncIterable(value) {
  return isFunction(value?.[Symbol.asyncIterator]);
}
__name(isAsyncIterable, "isAsyncIterable");
function isBigint(value) {
  return typeof value === "bigint";
}
__name(isBigint, "isBigint");
function isBigInt64Array(value) {
  return getObjectType(value) === "BigInt64Array";
}
__name(isBigInt64Array, "isBigInt64Array");
function isBigUint64Array(value) {
  return getObjectType(value) === "BigUint64Array";
}
__name(isBigUint64Array, "isBigUint64Array");
function isBlob(value) {
  return getObjectType(value) === "Blob";
}
__name(isBlob, "isBlob");
function isBoolean(value) {
  return value === true || value === false;
}
__name(isBoolean, "isBoolean");
function isBoundFunction(value) {
  return isFunction(value) && !Object.hasOwn(value, "prototype");
}
__name(isBoundFunction, "isBoundFunction");
function isBuffer(value) {
  return value?.constructor?.isBuffer?.(value) ?? false;
}
__name(isBuffer, "isBuffer");
function isClass(value) {
  return isFunction(value) && /^class(\s+|{)/.test(value.toString());
}
__name(isClass, "isClass");
function isDataView(value) {
  return getObjectType(value) === "DataView";
}
__name(isDataView, "isDataView");
function isDate(value) {
  return getObjectType(value) === "Date";
}
__name(isDate, "isDate");
function isDirectInstanceOf(instance, class_) {
  if (instance === void 0 || instance === null) {
    return false;
  }
  return Object.getPrototypeOf(instance) === class_.prototype;
}
__name(isDirectInstanceOf, "isDirectInstanceOf");
function isEmptyArray(value) {
  return isArray(value) && value.length === 0;
}
__name(isEmptyArray, "isEmptyArray");
function isEmptyMap(value) {
  return isMap(value) && value.size === 0;
}
__name(isEmptyMap, "isEmptyMap");
function isEmptyObject(value) {
  return isObject(value) && !isMap(value) && !isSet(value) && Object.keys(value).length === 0;
}
__name(isEmptyObject, "isEmptyObject");
function isEmptySet(value) {
  return isSet(value) && value.size === 0;
}
__name(isEmptySet, "isEmptySet");
function isEmptyString(value) {
  return isString(value) && value.length === 0;
}
__name(isEmptyString, "isEmptyString");
function isEmptyStringOrWhitespace(value) {
  return isEmptyString(value) || isWhitespaceString(value);
}
__name(isEmptyStringOrWhitespace, "isEmptyStringOrWhitespace");
function isEnumCase(value, targetEnum) {
  return Object.values(targetEnum).includes(value);
}
__name(isEnumCase, "isEnumCase");
function isError(value) {
  return getObjectType(value) === "Error";
}
__name(isError, "isError");
function isEvenInteger(value) {
  return isAbsoluteModule2(0)(value);
}
__name(isEvenInteger, "isEvenInteger");
function isFalsy(value) {
  return !value;
}
__name(isFalsy, "isFalsy");
function isFloat32Array(value) {
  return getObjectType(value) === "Float32Array";
}
__name(isFloat32Array, "isFloat32Array");
function isFloat64Array(value) {
  return getObjectType(value) === "Float64Array";
}
__name(isFloat64Array, "isFloat64Array");
function isFormData(value) {
  return getObjectType(value) === "FormData";
}
__name(isFormData, "isFormData");
function isFunction(value) {
  return typeof value === "function";
}
__name(isFunction, "isFunction");
function isGenerator(value) {
  return isIterable(value) && isFunction(value?.next) && isFunction(value?.throw);
}
__name(isGenerator, "isGenerator");
function isGeneratorFunction(value) {
  return getObjectType(value) === "GeneratorFunction";
}
__name(isGeneratorFunction, "isGeneratorFunction");
var NODE_TYPE_ELEMENT = 1;
var DOM_PROPERTIES_TO_CHECK = [
  "innerHTML",
  "ownerDocument",
  "style",
  "attributes",
  "nodeValue"
];
function isHtmlElement(value) {
  return isObject(value) && value.nodeType === NODE_TYPE_ELEMENT && isString(value.nodeName) && !isPlainObject(value) && DOM_PROPERTIES_TO_CHECK.every((property) => property in value);
}
__name(isHtmlElement, "isHtmlElement");
function isInfinite(value) {
  return value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY;
}
__name(isInfinite, "isInfinite");
function isInRange(value, range) {
  if (isNumber(range)) {
    return value >= Math.min(0, range) && value <= Math.max(range, 0);
  }
  if (isArray(range) && range.length === 2) {
    return value >= Math.min(...range) && value <= Math.max(...range);
  }
  throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
}
__name(isInRange, "isInRange");
function isInt16Array(value) {
  return getObjectType(value) === "Int16Array";
}
__name(isInt16Array, "isInt16Array");
function isInt32Array(value) {
  return getObjectType(value) === "Int32Array";
}
__name(isInt32Array, "isInt32Array");
function isInt8Array(value) {
  return getObjectType(value) === "Int8Array";
}
__name(isInt8Array, "isInt8Array");
function isInteger(value) {
  return Number.isInteger(value);
}
__name(isInteger, "isInteger");
function isIterable(value) {
  return isFunction(value?.[Symbol.iterator]);
}
__name(isIterable, "isIterable");
function isMap(value) {
  return getObjectType(value) === "Map";
}
__name(isMap, "isMap");
function isNan(value) {
  return Number.isNaN(value);
}
__name(isNan, "isNan");
function isNativePromise(value) {
  return getObjectType(value) === "Promise";
}
__name(isNativePromise, "isNativePromise");
function isNegativeNumber(value) {
  return isNumber(value) && value < 0;
}
__name(isNegativeNumber, "isNegativeNumber");
function isNodeStream(value) {
  return isObject(value) && isFunction(value.pipe) && !isObservable(value);
}
__name(isNodeStream, "isNodeStream");
function isNonEmptyArray(value) {
  return isArray(value) && value.length > 0;
}
__name(isNonEmptyArray, "isNonEmptyArray");
function isNonEmptyMap(value) {
  return isMap(value) && value.size > 0;
}
__name(isNonEmptyMap, "isNonEmptyMap");
function isNonEmptyObject(value) {
  return isObject(value) && !isMap(value) && !isSet(value) && Object.keys(value).length > 0;
}
__name(isNonEmptyObject, "isNonEmptyObject");
function isNonEmptySet(value) {
  return isSet(value) && value.size > 0;
}
__name(isNonEmptySet, "isNonEmptySet");
function isNonEmptyString(value) {
  return isString(value) && value.length > 0;
}
__name(isNonEmptyString, "isNonEmptyString");
function isNonEmptyStringAndNotWhitespace(value) {
  return isString(value) && !isEmptyStringOrWhitespace(value);
}
__name(isNonEmptyStringAndNotWhitespace, "isNonEmptyStringAndNotWhitespace");
function isNull(value) {
  return value === null;
}
__name(isNull, "isNull");
function isNullOrUndefined(value) {
  return isNull(value) || isUndefined(value);
}
__name(isNullOrUndefined, "isNullOrUndefined");
function isNumber(value) {
  return typeof value === "number" && !Number.isNaN(value);
}
__name(isNumber, "isNumber");
function isNumericString(value) {
  return isString(value) && !isEmptyStringOrWhitespace(value) && !Number.isNaN(Number(value));
}
__name(isNumericString, "isNumericString");
function isObject(value) {
  return !isNull(value) && (typeof value === "object" || isFunction(value));
}
__name(isObject, "isObject");
function isObservable(value) {
  if (!value) {
    return false;
  }
  if (Symbol.observable !== void 0 && value === value[Symbol.observable]?.()) {
    return true;
  }
  if (value === value["@@observable"]?.()) {
    return true;
  }
  return false;
}
__name(isObservable, "isObservable");
function isOddInteger(value) {
  return isAbsoluteModule2(1)(value);
}
__name(isOddInteger, "isOddInteger");
function isPlainObject(value) {
  if (typeof value !== "object" || value === null) {
    return false;
  }
  const prototype = Object.getPrototypeOf(value);
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
}
__name(isPlainObject, "isPlainObject");
function isPositiveNumber(value) {
  return isNumber(value) && value > 0;
}
__name(isPositiveNumber, "isPositiveNumber");
function isPrimitive(value) {
  return isNull(value) || isPrimitiveTypeName(typeof value);
}
__name(isPrimitive, "isPrimitive");
function isPromise(value) {
  return isNativePromise(value) || hasPromiseApi(value);
}
__name(isPromise, "isPromise");
function isPropertyKey(value) {
  return isAny([isString, isNumber, isSymbol], value);
}
__name(isPropertyKey, "isPropertyKey");
function isRegExp(value) {
  return getObjectType(value) === "RegExp";
}
__name(isRegExp, "isRegExp");
function isSafeInteger(value) {
  return Number.isSafeInteger(value);
}
__name(isSafeInteger, "isSafeInteger");
function isSet(value) {
  return getObjectType(value) === "Set";
}
__name(isSet, "isSet");
function isSharedArrayBuffer(value) {
  return getObjectType(value) === "SharedArrayBuffer";
}
__name(isSharedArrayBuffer, "isSharedArrayBuffer");
function isString(value) {
  return typeof value === "string";
}
__name(isString, "isString");
function isSymbol(value) {
  return typeof value === "symbol";
}
__name(isSymbol, "isSymbol");
function isTruthy(value) {
  return Boolean(value);
}
__name(isTruthy, "isTruthy");
function isTupleLike(value, guards) {
  if (isArray(guards) && isArray(value) && guards.length === value.length) {
    return guards.every((guard, index) => guard(value[index]));
  }
  return false;
}
__name(isTupleLike, "isTupleLike");
function isTypedArray(value) {
  return isTypedArrayName(getObjectType(value));
}
__name(isTypedArray, "isTypedArray");
function isUint16Array(value) {
  return getObjectType(value) === "Uint16Array";
}
__name(isUint16Array, "isUint16Array");
function isUint32Array(value) {
  return getObjectType(value) === "Uint32Array";
}
__name(isUint32Array, "isUint32Array");
function isUint8Array(value) {
  return getObjectType(value) === "Uint8Array";
}
__name(isUint8Array, "isUint8Array");
function isUint8ClampedArray(value) {
  return getObjectType(value) === "Uint8ClampedArray";
}
__name(isUint8ClampedArray, "isUint8ClampedArray");
function isUndefined(value) {
  return value === void 0;
}
__name(isUndefined, "isUndefined");
function isUrlInstance(value) {
  return getObjectType(value) === "URL";
}
__name(isUrlInstance, "isUrlInstance");
function isUrlSearchParams(value) {
  return getObjectType(value) === "URLSearchParams";
}
__name(isUrlSearchParams, "isUrlSearchParams");
function isUrlString(value) {
  if (!isString(value)) {
    return false;
  }
  try {
    new URL(value);
    return true;
  } catch {
    return false;
  }
}
__name(isUrlString, "isUrlString");
function isValidDate(value) {
  return isDate(value) && !isNan(Number(value));
}
__name(isValidDate, "isValidDate");
function isValidLength(value) {
  return isSafeInteger(value) && value >= 0;
}
__name(isValidLength, "isValidLength");
function isWeakMap(value) {
  return getObjectType(value) === "WeakMap";
}
__name(isWeakMap, "isWeakMap");
function isWeakRef(value) {
  return getObjectType(value) === "WeakRef";
}
__name(isWeakRef, "isWeakRef");
function isWeakSet(value) {
  return getObjectType(value) === "WeakSet";
}
__name(isWeakSet, "isWeakSet");
function isWhitespaceString(value) {
  return isString(value) && /^\s+$/.test(value);
}
__name(isWhitespaceString, "isWhitespaceString");
function predicateOnArray(method, predicate, values) {
  if (!isFunction(predicate)) {
    throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
  }
  if (values.length === 0) {
    throw new TypeError("Invalid number of values");
  }
  return method.call(values, predicate);
}
__name(predicateOnArray, "predicateOnArray");

// ../utils/src/my-dash.ts
function keyBy(array, key) {
  return (array || []).reduce((r, x) => ({ ...r, [String(x[key])]: x }), {});
}
__name(keyBy, "keyBy");
function sortBy(array, compareBy) {
  if (typeof compareBy === "function") {
    const compareMap = /* @__PURE__ */ new Map();
    array.forEach((item) => {
      compareMap.set(item, compareBy(item));
    });
    return array.concat().sort(
      (a, b) => compareMap.get(a) - compareMap.get(b)
    );
  } else {
    return array.concat().sort(
      (a, b) => {
        if (a[compareBy] > b[compareBy]) return 1;
        return b[compareBy] > a[compareBy] ? -1 : 0;
      }
    );
  }
}
__name(sortBy, "sortBy");
function compact(array) {
  return array.filter((item) => item !== void 0 && item !== false && item !== null);
}
__name(compact, "compact");
function filter(array, fn) {
  return array.filter(fn);
}
__name(filter, "filter");
function each(array, fn) {
  if (Array.isArray(array)) {
    array.forEach((item, index) => fn(item, String(index)));
  } else {
    Object.entries(array).forEach(([key, value]) => fn(value, key));
  }
}
__name(each, "each");
function castArray(value) {
  return Array.isArray(value) ? value : [value];
}
__name(castArray, "castArray");
function mapValues(obj, fn) {
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, fn(value)]));
}
__name(mapValues, "mapValues");
function times(count, fn) {
  return Array.from({ length: count }, (_2, i) => fn(i));
}
__name(times, "times");
function map(array, fn) {
  return array.map(fn);
}
__name(map, "map");
function flatMap(array, fn) {
  return array.flatMap(fn);
}
__name(flatMap, "flatMap");
function intersection(...arrays) {
  return arrays.reduce((a, b) => a.filter((value) => b.includes(value)));
}
__name(intersection, "intersection");
function pick(obj, keys) {
  return Object.fromEntries(Object.entries(obj).filter(([key]) => keys.includes(key)));
}
__name(pick, "pick");
function uniq(array) {
  return Array.from(new Set(array));
}
__name(uniq, "uniq");
function fromPairs(pairs) {
  return Object.fromEntries(pairs);
}
__name(fromPairs, "fromPairs");
var _ = {
  keyBy,
  sortBy,
  compact,
  keys: Object.keys,
  values: Object.values,
  some: /* @__PURE__ */ __name((a, fn) => a.some(fn), "some"),
  filter,
  each,
  castArray,
  mapValues,
  times,
  map,
  flatMap,
  intersection,
  pick,
  uniq,
  fromPairs,
  // type checks
  isString,
  isBoolean,
  isError,
  isPromise,
  isFunction,
  isNan,
  isNumber,
  isPlainObject,
  isArray,
  isInteger
};
var my_dash_default = _;

// src/env-graph/lib/errors.ts
var VarlockError = class extends Error {
  constructor(errOrMessage, more) {
    super(my_dash_default.isError(errOrMessage) ? errOrMessage.message : errOrMessage);
    this.more = more;
    if (my_dash_default.isError(errOrMessage)) {
      this.originalError = errOrMessage;
      this.icon = "\u{1F4A5}";
    } else {
      this.originalError = more?.err;
    }
    if (my_dash_default.isArray(more?.tip)) more.tip = more.tip.join("\n");
    this.name = this.constructor.name;
    if (more?.severity) {
      this.severity = more.severity;
    } else if (more?.isWarning) {
      this.severity = "warning";
    }
    this.icon ||= this.constructor.defaultIcon;
  }
  more;
  static {
    __name(this, "VarlockError");
  }
  originalError;
  get isUnexpected() {
    return !!this.originalError;
  }
  get type() {
    return this.name;
  }
  static defaultIcon = "\u274C";
  icon;
  _severity = "error";
  get tip() {
    if (!this.more?.tip) return void 0;
    if (my_dash_default.isArray(this.more.tip)) return this.more.tip.join("\n");
    return this.more.tip;
  }
  get location() {
    return this.more?.location;
  }
  get code() {
    return this.more?.code;
  }
  get extraMetadata() {
    return this.more?.extraMetadata;
  }
  get severity() {
    return this._severity;
  }
  set severity(s) {
    this._severity = s;
    if (s === "warning") this.icon = "\u{1F9D0}";
  }
  get isWarning() {
    return this._severity === "warning";
  }
  set isWarning(w) {
    this.severity = w ? "warning" : "error";
  }
  get isFatal() {
    return this._severity === "fatal";
  }
  toJSON() {
    return {
      icon: this.icon,
      type: this.type,
      name: this.name,
      message: this.message,
      severity: this.severity,
      isUnexpected: this.isUnexpected,
      ...this.tip && { tip: this.tip },
      ...this.isWarning && { isWarning: true }
    };
  }
};
var ConfigLoadError = class extends VarlockError {
  static {
    __name(this, "ConfigLoadError");
  }
  cleanedStack;
  constructor(err) {
    super(err);
    let stackLines = (err.stack?.split("\n") || []).slice(1);
    stackLines = stackLines.filter((l) => {
      if (l.includes(" at ViteNodeRunner.")) return false;
      if (l.includes("core/src/config-loader/config-loader.ts")) return false;
      return true;
    });
    this.message = `${err.name}: ${err.message}`;
    this.cleanedStack = stackLines || [];
  }
  toJSON() {
    return {
      ...super.toJSON(),
      cleanedStack: this.cleanedStack
    };
  }
};
var LoadingError = class extends VarlockError {
  static {
    __name(this, "LoadingError");
  }
  static defaultIcon = "\u{1F4C2}";
};
var ParseError = class extends VarlockError {
  static {
    __name(this, "ParseError");
  }
  static defaultIcon = "\u{1F635}\u200D\u{1F4AB}";
};
var SchemaError = class extends VarlockError {
  static {
    __name(this, "SchemaError");
  }
  static defaultIcon = "\u{1F9F0}";
};
var ValidationError = class extends VarlockError {
  static {
    __name(this, "ValidationError");
  }
  static defaultIcon = "\u274C";
};
var CoercionError = class extends VarlockError {
  static {
    __name(this, "CoercionError");
  }
  static defaultIcon = "\u{1F6D1}";
};
var ResolutionError = class _ResolutionError extends VarlockError {
  static {
    __name(this, "ResolutionError");
  }
  static defaultIcon = "\u26D4";
  _retryable = false;
  set retryable(val) {
    this._retryable = val;
  }
  get retryable() {
    if (this._retryable) return true;
    if (this.originalError instanceof _ResolutionError) return this.originalError.retryable;
    return false;
  }
};
var EmptyRequiredValueError = class extends ValidationError {
  static {
    __name(this, "EmptyRequiredValueError");
  }
  icon = "\u2753";
  constructor(_val) {
    super("Value is required but is currently empty");
  }
};

// src/plugin-context.ts
var ctx = { active: void 0 };
function activatePlugin(p) {
  ctx.active = p;
}
__name(activatePlugin, "activatePlugin");
function deactivatePlugin() {
  ctx.active = void 0;
}
__name(deactivatePlugin, "deactivatePlugin");
var pluginProxy = new Proxy({}, {
  get(_2, key) {
    if (!ctx.active) throw new Error("[varlock] No active plugin context \u2014 are you importing plugin-lib outside of a plugin module?");
    const val = ctx.active[key];
    return typeof val === "function" ? val.bind(ctx.active) : val;
  },
  set(_2, key, value) {
    if (!ctx.active) throw new Error("[varlock] No active plugin context");
    ctx.active[key] = value;
    return true;
  }
});
//! these are probably not relevant anymore, or needs to move to a plugin layer?

export { CoercionError, ConfigLoadError, EmptyRequiredValueError, LoadingError, ParseError, ResolutionError, SchemaError, ValidationError, VarlockError, activatePlugin, deactivatePlugin, my_dash_default, pluginProxy };
//# sourceMappingURL=chunk-DRL5U3PK.js.map
//# sourceMappingURL=chunk-DRL5U3PK.js.map