"use strict";
/* Socket Lib - Built with esbuild */
"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 glob_exports = {};
__export(glob_exports, {
  canUseNodeFsGlob: () => canUseNodeFsGlob,
  glob: () => glob,
  globSync: () => globSync
});
module.exports = __toCommonJS(glob_exports);
var import_resolvers = require("../promises/resolvers");
var import_internal = require("./_internal");
function canUseNodeFsGlob(options) {
  if (!options) {
    return true;
  }
  for (const key of Object.keys(options)) {
    if (key !== "cwd" && key !== "ignore") {
      return false;
    }
  }
  return true;
}
// @__NO_SIDE_EFFECTS__
async function glob(patterns, options) {
  const normalizedIgnore = (0, import_internal.normalizeIgnorePatterns)(options?.ignore);
  if (canUseNodeFsGlob(options)) {
    const out2 = await (0, import_resolvers.fromAsync)(
      (0, import_internal.getFsPromises)().glob(patterns, {
        ...options?.cwd ? { cwd: options.cwd } : {},
        ...normalizedIgnore ? { exclude: normalizedIgnore } : {}
      })
    );
    return (0, import_internal.normalizeGlobResults)(out2);
  }
  const fastGlob = (0, import_internal.getFastGlob)();
  const out = await fastGlob.glob(patterns, {
    ...options,
    ...normalizedIgnore ? { ignore: normalizedIgnore } : {}
  });
  return (0, import_internal.normalizeGlobResults)(out);
}
// @__NO_SIDE_EFFECTS__
function globSync(patterns, options) {
  const normalizedIgnore = (0, import_internal.normalizeIgnorePatterns)(options?.ignore);
  if (canUseNodeFsGlob(options)) {
    return (0, import_internal.normalizeGlobResults)([
      ...(0, import_internal.getFs)().globSync(patterns, {
        ...options?.cwd ? { cwd: options.cwd } : {},
        ...normalizedIgnore ? { exclude: normalizedIgnore } : {}
      })
    ]);
  }
  const fastGlob = (0, import_internal.getFastGlob)();
  return (0, import_internal.normalizeGlobResults)(
    fastGlob.globSync(patterns, {
      ...options,
      ...normalizedIgnore ? { ignore: normalizedIgnore } : {}
    })
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  canUseNodeFsGlob,
  glob,
  globSync
});
