const require_get_object_tag = require('./get-object-tag.cjs');

//#region ../../node_modules/.pnpm/@stryke+convert@0.6.38/node_modules/@stryke/convert/dist/type-checks/src/is-plain-object.mjs
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @example
* ```typescript
* isObjectLike({})
* // => true
*
* isObjectLike([1, 2, 3])
* // => true
*
* isObjectLike(Function)
* // => false
*
* isObjectLike(null)
* // => false
* ```
*
* @param value - The value to check.
* @returns Returns `true` if `value` is object-like, else `false`.
*/
const isObjectLike = (obj) => {
	return typeof obj === "object" && obj !== null;
};
/**
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
*
* @example
* ```typescript
* function Foo() {
*   this.a = 1
* }
*
* isPlainObject(new Foo)
* // => false
*
* isPlainObject([1, 2, 3])
* // => false
*
* isPlainObject({ 'x': 0, 'y': 0 })
* // => true
*
* isPlainObject(Object.create(null))
* // => true
* ```
*
* @param obj - The value to check.
* @returns Returns `true` if `obj` is a plain object, else `false`.
*/
const isPlainObject = (obj) => {
	if (!isObjectLike(obj) || require_get_object_tag.getObjectTag(obj) !== "[object Object]") return false;
	if (Object.getPrototypeOf(obj) === null) return true;
	let proto = obj;
	while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
	return Object.getPrototypeOf(obj) === proto;
};

//#endregion
exports.isPlainObject = isPlainObject;