'use strict';
import { metaEnvSettingKeys } from '../../infra/meta-env-setting-keys.js';
import { getBooleanEnvSetting } from '../../../../fd-toolbox/infra/env-functions.js';
import { setToIntegrationCache } from './fd-integration-cache.js';
import { getIntegrationHookUrls } from './integration-db.js';
import { getResourceMetaIdServer } from '../services/resource-name-converter.js';
import { postBaseApi } from '../../../../fd-toolbox/api/base-api.js';
import { httpContentTypes } from '../../../../fd-toolbox/constants/header-names.js';

var __defProp=Object['defineProperty'],__name=(_0x3d425b,_0x24a224)=>__defProp(_0x3d425b,'name',{'value':_0x24a224,'configurable':!![]});const subscriptionEventTypes={'resourceAdded':0x0,'resourceEdited':0x1,'resourceRemoved':0x2};const subscriptionEventStrings={[subscriptionEventTypes['resourceAdded']]:'resourceAdded',[subscriptionEventTypes['resourceEdited']]:'resourceEdited',[subscriptionEventTypes['resourceRemoved']]:'resourceRemoved'};async function triggerIntegrationEvent(_0x387be2,_0xc86d0,_0x28f534){const _0x55550e=await getResourceMetaIdServer(_0xc86d0);if(getBooleanEnvSetting(metaEnvSettingKeys['integrationEnabled'])){if(_0x28f534)await setToIntegrationCache(_0x387be2,_0x55550e,_0x28f534);informIntegrationSubscribers(_0x387be2,_0x55550e);}}__name(triggerIntegrationEvent,'triggerIntegrationEvent');async function informIntegrationSubscribers(_0x544881,_0x3d55c0){const _0x3eef8c=await getIntegrationHookUrls(_0x544881,_0x3d55c0);_0x3eef8c['forEach'](_0x4dcca5=>{_0x4dcca5&&sendRequest(_0x4dcca5);});}__name(informIntegrationSubscribers,'informIntegrationSubscribers');function sendRequest(_0x277fa4){const _0xa9e93f=new Headers({[httpContentTypes['contentTypeDisposition']]:httpContentTypes['contentTypeApplicationJson']});postBaseApi(_0x277fa4,void(-0xc70+-0x1*-0x207+-0xd*-0xcd),_0xa9e93f);}__name(sendRequest,'sendRequest');

export { informIntegrationSubscribers, subscriptionEventStrings, subscriptionEventTypes, triggerIntegrationEvent };
