'use strict';
import { apiOkResponse } from '../../../meta/server/web/responses.js';
import { resourceNames } from '../../../../fd-toolbox/resources/resource-names.js';
import { cancelPaidSubscription } from '../../payments/subscriptions/subscriptions.js';
import { checkResourceAccessPermission } from '../../utils/check-resource-access-permission.js';
import { getUserId } from '../../../meta/server/auth/users/current-user-id-provider.js';
import { getCurrentWorkspaceId } from '../../../meta/server/providers/current-workspace-id-provider.js';
import { parseJsonBodyFromRequest } from '../../../../fd-toolbox/lib/utils.js';
import { crudActions } from '../../../../fd-toolbox/enums/enums.js';

var __defProp=Object['defineProperty'],__name=(_0xae98b5,_0x462e62)=>__defProp(_0xae98b5,'name',{'value':_0x462e62,'configurable':!![]});async function subscriptionCancelPostRoute(_0x149506){const _0x5d12fa=await getUserId(),_0x3da10a=await getCurrentWorkspaceId(),{id:_0x5f2781}=await parseJsonBodyFromRequest(_0x149506);await checkResourceAccessPermission(_0x5d12fa,resourceNames['subscription'],crudActions['update']);const _0x21b9ad=await cancelPaidSubscription(_0x5f2781,_0x3da10a);return apiOkResponse(_0x21b9ad);}__name(subscriptionCancelPostRoute,'subscriptionCancelPostRoute');

export { subscriptionCancelPostRoute };
