'use strict';
import { resourceNames } from '../../../../fd-toolbox/resources/resource-names.js';
import { getDbSchema } from '../../../db/db-schema.js';
import { eq } from 'drizzle-orm';
import { getResourcesByName, createResourceDirectlyInDb } from '../db/db.js';
import { getQuery } from '../web/drizzle.js';
import { applyFilterToQuery, getTableColumn, runQuery } from '../../../db/drizzle-queries.js';
import { createResource } from '../resources/crud-resources.js';
import { dbInnerJoin } from '../../../db/db-connection.js';
import { schemaNames, columnNames } from '../../../db/constants/schema-names.js';

var __defProp=Object['defineProperty'],__name=(_0x3d1d87,_0x27650e)=>__defProp(_0x3d1d87,'name',{'value':_0x27650e,'configurable':!![]});async function getPermissionPackageToPermissions(){const _0x371778=await getResourcesByName(resourceNames['permissionPackageToPermission']);return _0x371778;}__name(getPermissionPackageToPermissions,'getPermissionPackageToPermissions');async function getPermissionPackageToPermissionsByPermissionPackageId(_0x3db1c1){const _0x30cbf4=getDbSchema(),_0x1d5598=_0x30cbf4[schemaNames['permissionPackageToPermissionSchema']],{query:_0x2ccaf9}=await getQuery(_0x1d5598);applyFilterToQuery(_0x2ccaf9,eq(getTableColumn(_0x1d5598,columnNames['permissionPackageId']),_0x3db1c1));const _0x23288f=await runQuery(_0x2ccaf9);return _0x23288f;}__name(getPermissionPackageToPermissionsByPermissionPackageId,'getPermissionPackageToPermissionsByPermissionPackageId');async function getPermissionPackageToPermissionsByPermissionType(_0x294ff0){const _0x4dfdaa=getDbSchema(),_0x3ccd7e=_0x4dfdaa[schemaNames['permissionPackageToPermissionSchema']],_0x22512d=_0x4dfdaa[schemaNames['permissionSchema']],{query:_0x183968}=await getQuery(_0x3ccd7e,{'fields':_0x3ccd7e});dbInnerJoin(_0x183968,_0x22512d,eq(getTableColumn(_0x3ccd7e,columnNames['permissionId']),getTableColumn(_0x22512d,columnNames['id']))),applyFilterToQuery(_0x183968,eq(getTableColumn(_0x22512d,columnNames['type']),_0x294ff0));const _0x1a641d=await runQuery(_0x183968),_0x5b2803=_0x1a641d['map'](_0xc90df8=>_0xc90df8['fields']);return _0x5b2803;}__name(getPermissionPackageToPermissionsByPermissionType,'getPermissionPackageToPermissionsByPermissionType');async function addPermissionPackageToPermission(_0x4c6428){const _0x5030c2=await createResource(_0x4c6428,resourceNames['permissionPackageToPermission']);return _0x5030c2;}__name(addPermissionPackageToPermission,'addPermissionPackageToPermission');async function addPermissionPackageToPermissionDirectlyInDb(_0x5c0cde){return createResourceDirectlyInDb(_0x5c0cde,resourceNames['permissionPackageToPermission']);}__name(addPermissionPackageToPermissionDirectlyInDb,'addPermissionPackageToPermissionDirectlyInDb');

export { addPermissionPackageToPermission, addPermissionPackageToPermissionDirectlyInDb, getPermissionPackageToPermissions, getPermissionPackageToPermissionsByPermissionPackageId, getPermissionPackageToPermissionsByPermissionType };
