"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 useGitBranch_exports = {};
__export(useGitBranch_exports, {
  useGitBranch: () => useGitBranch
});
module.exports = __toCommonJS(useGitBranch_exports);
var import_react = require("react");
var import_child_process = require("child_process");
function useGitBranch(cwd) {
  const [branchName, setBranchName] = (0, import_react.useState)(void 0);
  (0, import_react.useEffect)(() => {
    const workingDir = cwd || process.cwd();
    try {
      const result = (0, import_child_process.execSync)("git rev-parse --abbrev-ref HEAD", {
        cwd: workingDir,
        encoding: "utf-8",
        stdio: ["pipe", "pipe", "pipe"]
      });
      const branch = result.trim();
      setBranchName(branch || void 0);
    } catch {
      setBranchName(void 0);
    }
  }, [cwd]);
  return branchName;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useGitBranch
});
