'use strict';
import { v4 } from 'uuid';
import { resourceIds } from '../../../fd-toolbox/constants/resource-id-constants.js';
import { toolboxUserConstants } from '../../meta/constants/toolbox-users.js';
import { createRoleToPermissionPackage } from '../../meta/server/models/roles/role-to-permission-package-db.js';
import { getRoleToPermissionsByRoleId, createRoleToPermission } from '../fd/fd-toolbox-asp-net/models/roles/role-to-permission-db.js';
import { addPermissionIds, getAllPermissionActions } from '../fd/fd-toolbox-web/permissions/fd-permission-master-data.js';
import { getResourceIds } from '../../meta/server/meta-core/constants/resource-ids.js';
import { getNow } from '../../../fd-toolbox/time/date-time.js';

var __defProp=Object['defineProperty'],__name=(_0x146858,_0x1bc80c)=>__defProp(_0x146858,'name',{'value':_0x1bc80c,'configurable':!![]});async function getAllResourceIds(){const _0x53c8a6=[];for(const _0x4a38c9 of await getResourceIds()){_0x53c8a6['push'](_0x4a38c9);}return _0x53c8a6;}__name(getAllResourceIds,'getAllResourceIds');async function createRoleToPackage(_0x587a79,_0xae518a){await createRoleToPermissionPackage({'id':v4(),'roleId':_0x587a79,'permissionPackageId':_0xae518a,'createdByUserId':toolboxUserConstants['workerBotId'],'modifiedByUserId':toolboxUserConstants['workerBotId'],'createdDate':getNow(),'modifiedDate':getNow()});}__name(createRoleToPackage,'createRoleToPackage');async function createRoleToPermissionIfNotExist(_0x4ff280,_0x5028a0){const _0x5af67e=await getRoleToPermissionsByRoleId(_0x4ff280);for(const _0x328a84 of _0x5028a0){!_0x5af67e['some'](_0x5cbe36=>_0x5cbe36['permissionId']===_0x328a84)&&await createRoleToPermission({'id':v4(),'roleId':_0x4ff280,'permissionId':_0x328a84,'createdByUserId':toolboxUserConstants['workerBotId'],'modifiedByUserId':toolboxUserConstants['workerBotId'],'createdDate':getNow(),'modifiedDate':getNow()});}}__name(createRoleToPermissionIfNotExist,'createRoleToPermissionIfNotExist');function addCommonPermissions(_0x570c31,_0x5e2fd1){const _0x5a7328=[resourceIds['workspace'],resourceIds['feature'],resourceIds['paymentPlanFeature'],resourceIds['paymentPlan'],resourceIds['subscription'],resourceIds['pricing']];addPermissionIds(_0x5a7328,getAllPermissionActions(),_0x570c31,_0x5e2fd1);}__name(addCommonPermissions,'addCommonPermissions');

export { addCommonPermissions, createRoleToPackage, createRoleToPermissionIfNotExist, getAllResourceIds };
