/**
 * Mirrors PublishGuard / classic-editor publish blocking — show review
 * notices only while this returns true.
 *
 * @param {{
 *   reviewMandatory?: boolean,
 *   isPublished?: boolean,
 *   review?: object|null,
 *   reviewerMeta?: number,
 * }} args
 */
export function isPublishBlocked( {
	reviewMandatory,
	isPublished,
	review,
	reviewerMeta = 0,
} ) {
	if ( ! reviewMandatory || isPublished ) {
		return false;
	}

	const fromReview = Number(
		review?.reviewer_id ?? review?.reviewer?.id ?? 0
	);
	const fromMeta = Number( reviewerMeta ?? 0 );
	const reviewerId = fromReview > 0 ? fromReview : fromMeta;

	return ! ( review?.status === 'approved' && reviewerId > 0 );
}
