const require_slash = require('./slash.cjs');

//#region ../../node_modules/.pnpm/@stryke+path@0.26.4/node_modules/@stryke/path/dist/is-parent-path.mjs
/**
* Check if a given path is a parent of another path.
*
* @example
* ```ts
* isParentPath("/home/user/project/src/index.ts", "/home/user/project/src");
* // returns true
* isParentPath("/home/user/project/src/index.ts", "/home/user/project");
* // returns true
* isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/other");
* // returns false
* isParentPath("/home/user/project/src/index.ts", "/home/user/other");
* // returns false
* isParentPath("/home/user/project/src/index.ts", "/home/user/project/src/index.ts");
* // returns false
* ```
*
* @param childPath - The path to check if it is a child of the parent path.
* @param parentPath - The path to check if it is a parent of the child path.
* @returns `true` if `childPath` is a child of `parentPath`, otherwise `false`.
*/
function isParentPath(childPath, parentPath) {
	const normalizedChild = require_slash.slash(childPath.replaceAll(/\\/g, "/").replace(/\/*$/, ""))?.toLowerCase();
	const normalizedParent = require_slash.slash(parentPath.replaceAll(/\\/g, "/").replace(/\/*$/, ""))?.toLowerCase();
	return childPath !== parentPath && normalizedChild !== normalizedParent && normalizedChild.startsWith(`${normalizedParent}/`);
}

//#endregion
exports.isParentPath = isParentPath;