"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_paths_normalize = require('../paths/normalize.js');
const require_primordials_array = require('../primordials/array.js');
const require_node_path = require('../node/path.js');
const require_git_repo = require('./repo.js');
const require_git__internal = require('./_internal.js');

//#region src/git/unstaged.ts
/**
* @file "Edited but not yet staged" helpers — `git diff` over the working tree
*   only. Excludes index-staged changes and untracked paths; use `changed.ts`
*   for the broader view or `staged.ts` for the index.
*/
/**
* Get unstaged modified files (changes not yet staged for commit).
*
* Uses `git diff --name-only` which returns only unstaged modifications to
* tracked files. Does NOT include: - Untracked files (new files not added to
* git) - Staged changes (files added with `git add`)
*
* This is a focused check for uncommitted changes to existing tracked files.
* Useful for detecting work-in-progress modifications before staging.
*
* @example
*   ;```typescript
*   // Get unstaged files
*   const files = await getUnstagedFiles()
*   // => ['src/foo.ts', 'src/bar.ts']
*
*   // After staging some files
*   await spawn('git', ['add', 'src/foo.ts'])
*   const files = await getUnstagedFiles()
*   // => ['src/bar.ts'] (foo.ts no longer included)
*
*   // Get absolute paths
*   const files = await getUnstagedFiles({ absolute: true })
*   // => ['/path/to/repo/src/bar.ts']
*   ```
*
* @param options - Options controlling path format and filtering.
*
* @returns Promise resolving to array of unstaged file paths.
*/
async function getUnstagedFiles(options) {
	const args = require_git__internal.getGitDiffSpawnArgs(options?.cwd).unstaged;
	return await require_git__internal.innerDiff(args, options);
}
/**
* Get unstaged modified files (changes not yet staged for commit).
*
* Synchronous version of `getUnstagedFiles()`. Uses `git diff --name-only`
* which returns only unstaged modifications to tracked files. Does NOT include:
* - Untracked files (new files not added to git) - Staged changes (files added
* with `git add`)
*
* This is a focused check for uncommitted changes to existing tracked files.
* Useful for detecting work-in-progress modifications before staging.
*
* @example
*   ;```typescript
*   // Get unstaged files
*   const files = getUnstagedFilesSync()
*   // => ['src/foo.ts', 'src/bar.ts']
*
*   // After staging some files
*   spawnSync('git', ['add', 'src/foo.ts'])
*   const files = getUnstagedFilesSync()
*   // => ['src/bar.ts'] (foo.ts no longer included)
*
*   // Get absolute paths
*   const files = getUnstagedFilesSync({ absolute: true })
*   // => ['/path/to/repo/src/bar.ts']
*   ```
*
* @param options - Options controlling path format and filtering.
*
* @returns Array of unstaged file paths.
*/
function getUnstagedFilesSync(options) {
	const args = require_git__internal.getGitDiffSpawnArgs(options?.cwd).unstaged;
	return require_git__internal.innerDiffSync(args, options);
}
/**
* Check if a file or directory has unstaged changes.
*
* Checks if the given pathname has modifications that are not yet staged for
* commit (changes not added with `git add`). Does NOT include: - Staged changes
* (already added with `git add`) - Untracked files (new files not in git)
*
* For directories, returns `true` if ANY file within the directory has unstaged
* changes.
*
* Symlinks in the pathname and cwd are automatically resolved using
* `fs.realpathSync()` before comparison.
*
* @example
*   ;```typescript
*   // Check if file has unstaged changes
*   const unstaged = await isUnstaged('src/foo.ts')
*   // => true
*
*   // After staging the file
*   await spawn('git', ['add', 'src/foo.ts'])
*   const unstaged = await isUnstaged('src/foo.ts')
*   // => false
*
*   // Check directory
*   const unstaged = await isUnstaged('src/')
*   // => true (if any file in src/ has unstaged changes)
*   ```
*
* @param pathname - File or directory path to check.
* @param options - Options for the git diff check.
*
* @returns Promise resolving to `true` if path has unstaged changes, `false`
*   otherwise.
*/
async function isUnstaged(pathname, options) {
	const files = await getUnstagedFiles({
		__proto__: null,
		...options,
		absolute: false
	});
	const path = /* @__PURE__ */ require_node_path.getNodePath();
	const resolvedPathname = require_git_repo.getCachedRealpath(pathname);
	/* c8 ignore start */
	const baseCwd = options?.cwd ? require_git_repo.getCachedRealpath(options["cwd"]) : require_git_repo.getCwd();
	return require_primordials_array.ArrayPrototypeIncludes(files, /* @__PURE__ */ require_paths_normalize.normalizePath(path.relative(baseCwd, resolvedPathname)));
}
/**
* Check if a file or directory has unstaged changes.
*
* Synchronous version of `isUnstaged()`. Checks if the given pathname has
* modifications that are not yet staged for commit (changes not added with `git
* add`). Does NOT include: - Staged changes (already added with `git add`) -
* Untracked files (new files not in git)
*
* For directories, returns `true` if ANY file within the directory has unstaged
* changes.
*
* Symlinks in the pathname and cwd are automatically resolved using
* `fs.realpathSync()` before comparison.
*
* @example
*   ;```typescript
*   // Check if file has unstaged changes
*   const unstaged = isUnstagedSync('src/foo.ts')
*   // => true
*
*   // After staging the file
*   spawnSync('git', ['add', 'src/foo.ts'])
*   const unstaged = isUnstagedSync('src/foo.ts')
*   // => false
*
*   // Check directory
*   const unstaged = isUnstagedSync('src/')
*   // => true (if any file in src/ has unstaged changes)
*   ```
*
* @param pathname - File or directory path to check.
* @param options - Options for the git diff check.
*
* @returns `true` if path has unstaged changes, `false` otherwise.
*/
function isUnstagedSync(pathname, options) {
	const files = getUnstagedFilesSync({
		__proto__: null,
		...options,
		absolute: false
	});
	const path = /* @__PURE__ */ require_node_path.getNodePath();
	const resolvedPathname = require_git_repo.getCachedRealpath(pathname);
	/* c8 ignore start */
	const baseCwd = options?.cwd ? require_git_repo.getCachedRealpath(options["cwd"]) : require_git_repo.getCwd();
	return require_primordials_array.ArrayPrototypeIncludes(files, /* @__PURE__ */ require_paths_normalize.normalizePath(path.relative(baseCwd, resolvedPathname)));
}

//#endregion
exports.getUnstagedFiles = getUnstagedFiles;
exports.getUnstagedFilesSync = getUnstagedFilesSync;
exports.isUnstaged = isUnstaged;
exports.isUnstagedSync = isUnstagedSync;