'use strict';
import { Gitlab } from '@gitbeaker/rest';
import { getStringEnvSetting } from '../../../fd-toolbox/infra/env-functions.js';
import { toolboxEnvSettingKeys } from '../../../fd-toolbox/infra/toolbox-env-setting-keys.js';
import { environmentVariables } from '../../ci/constants/ci-constants.js';
import { singleOrUndefinedWithWarning } from '../../../fd-toolbox/server/collections/single-funcs.js';
import { gitLabHost } from '../../../base-repo/app-constants/internal-system-constants.js';

var __defProp=Object['defineProperty'],__name=(_0x589911,_0x537a0a)=>__defProp(_0x589911,'name',{'value':_0x537a0a,'configurable':!![]});const gitbreakerInstance=new Proxy(new Gitlab({}),{'get'(_0x23e783,_0x55bb09,_0x312935){const _0x2e5629=Reflect['get'](getGitbreakerInstance(),_0x55bb09,_0x312935);return _0x2e5629;}});let gitbreakerInstanceCache;async function getMergeRequestFromProject(_0x4f0dbe,_0x34fed0){const _0x3f2474=await gitbreakerInstance['MergeRequests']['all']({'projectId':_0x34fed0,'sourceBranch':_0x4f0dbe});return singleOrUndefinedWithWarning(_0x3f2474);}__name(getMergeRequestFromProject,'getMergeRequestFromProject');function normalizeEnvSetting(_0x3c5257){return _0x3c5257===''?void(0xbd4+0x967*0x2+-0x6*0x51b):_0x3c5257;}__name(normalizeEnvSetting,'normalizeEnvSetting');function getGitbreakerConfig(){const _0xd422e0=getStringEnvSetting(toolboxEnvSettingKeys['gitlabHost']),_0x2606cb=getStringEnvSetting(toolboxEnvSettingKeys['gitlabPrivateToken']),_0x2ef4bd=getStringEnvSetting(environmentVariables['ciBotToken']);return {'host':normalizeEnvSetting(_0xd422e0)??gitLabHost,'token':normalizeEnvSetting(_0x2606cb)??normalizeEnvSetting(_0x2ef4bd)};}__name(getGitbreakerConfig,'getGitbreakerConfig');function createGitbreakerInstance(){const _0x34ffd6=getGitbreakerConfig();return new Gitlab(_0x34ffd6);}__name(createGitbreakerInstance,'createGitbreakerInstance');function getGitbreakerInstance(){return gitbreakerInstanceCache??=createGitbreakerInstance(),gitbreakerInstanceCache;}__name(getGitbreakerInstance,'getGitbreakerInstance');

export { getMergeRequestFromProject, gitbreakerInstance };
