import { isCurrentUserAnAdmin } from '../../utils/index.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type {
	UmbConditionConfigBase,
	UmbConditionControllerArguments,
	UmbExtensionCondition,
} from '@umbraco-cms/backoffice/extension-api';
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry';

export class UmbContentHasPropertiesWorkspaceCondition
	extends UmbConditionBase<UmbConditionConfigBase>
	implements UmbExtensionCondition
{
	constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<UmbConditionConfigBase>) {
		super(host, args);
		isCurrentUserAnAdmin(host).then((isAdmin) => (this.permitted = isAdmin));
	}
}

export { UmbContentHasPropertiesWorkspaceCondition as api };
