'use strict';
import { subscriptionEventStrings, subscriptionEventTypes } from '../../meta/server/integration-platforms/integration-events.js';
import { apiBadRequestError } from '../../../fd-toolbox/server/web/errors.js';
import { parseJsonBodyFromRequest } from '../../../fd-toolbox/lib/utils.js';
import { metaErrorMessages } from '../../meta/constants/meta-error-messages-constants.js';
import { hasProperty } from '../../../fd-toolbox/objects/property-value.js';
import { isString } from '../../../fd-toolbox/types/ensure-type.js';
import { integrationSubscriptionProps } from '../../common/resources/props/integration-subscription-props.js';

var __defProp=Object['defineProperty'],__name=(_0x333788,_0x260d30)=>__defProp(_0x333788,'name',{'value':_0x260d30,'configurable':!![]});async function getIntegrationResourceData(_0xe1242e){const _0x4a9012=new URL(_0xe1242e['url']),_0x29d0d5=_0x4a9012['searchParams']['get'](integrationSubscriptionProps['resource']);if(!_0x29d0d5)throw apiBadRequestError(metaErrorMessages['resourceNotDefined']);const _0x302e50=await parseJsonBodyFromRequest(_0xe1242e);if(!_0x302e50)throw apiBadRequestError(metaErrorMessages['requestBodyEmpty']);if(!hasProperty(_0x302e50,integrationSubscriptionProps['hookUrl']))throw apiBadRequestError(metaErrorMessages['missingHookUrlInRequest']);if(!isString(_0x302e50['hookUrl']))throw apiBadRequestError(metaErrorMessages['unexpectedHookUrlType']);return {'hookUrl':_0x302e50['hookUrl'],'resource':_0x29d0d5};}__name(getIntegrationResourceData,'getIntegrationResourceData');const subscriptionEvents={'added':subscriptionEventStrings[subscriptionEventTypes['resourceAdded']],'edited':subscriptionEventStrings[subscriptionEventTypes['resourceEdited']],'removed':subscriptionEventStrings[subscriptionEventTypes['resourceRemoved']]};function getIntegrationResourceSubscriptionEvent(_0x325d0f){return subscriptionEvents[_0x325d0f['toLowerCase']()];}__name(getIntegrationResourceSubscriptionEvent,'getIntegrationResourceSubscriptionEvent');

export { getIntegrationResourceData, getIntegrationResourceSubscriptionEvent };
