'use strict';
import { createDynamicSelect, dbWhere } from '../../../db/db-connection.js';
import { getTableColumn, runQuery } from '../../../db/drizzle-queries.js';
import { eq } from 'drizzle-orm';
import { getDbSchema } from '../../../db/db-schema.js';
import { getResource, getResourcesByName } from '../../../meta/server/db/db.js';
import { resourceNames } from '../../../../fd-toolbox/resources/resource-names.js';
import { paymentPlanNames } from '../../../common/subscription-plan/subscription-plan-constants.js';
import { pricingProps } from '../../../meta/core/resources/props/payment-plan-price-props.js';
import { singleOrUndefined, singleOrUndefinedWithWarning } from '../../../../fd-toolbox/server/collections/single-funcs.js';
import { toolboxUserConstants } from '../../../meta/constants/toolbox-users.js';
import { withIdProps } from '../../../../fd-toolbox-core/types/resource-with-id.js';
import { oDataOperators } from '../../../../fd-toolbox/enums/enums.js';
import { oDataComparisonTypes } from '../../../../fd-toolbox/odata/odata-enums.js';
import { getResources } from '../../../meta/server/services/resource-provider.js';
import { getODataBuilder } from '../../../../fd-toolbox/odata/odata-builder-funcs.js';
import { createResource } from '../../../meta/server/resources/crud-resources.js';
import { schemaNames, columnNames } from '../../../db/constants/schema-names.js';

var __defProp=Object['defineProperty'],__name=(_0x286bdf,_0x2113a8)=>__defProp(_0x286bdf,'name',{'value':_0x2113a8,'configurable':!![]});function getOnePaymentPlan(_0x472545){return getResource({'resourceName':resourceNames['paymentPlan'],'id':_0x472545});}__name(getOnePaymentPlan,'getOnePaymentPlan');function createPaymentPlan(_0x2f5faf){return createResource(_0x2f5faf,resourceNames['paymentPlan']);}__name(createPaymentPlan,'createPaymentPlan');async function getPaymentPlans(){const _0x952fbd=await getResourcesByName(resourceNames['paymentPlan']);return _0x952fbd;}__name(getPaymentPlans,'getPaymentPlans');async function getBasicPaymentPlanData(){const _0x22ce5c=getDbSchema(),_0x486a1d=_0x22ce5c[schemaNames['paymentPlanSchema']],_0x2cb805=createDynamicSelect(_0x486a1d);dbWhere(_0x2cb805,eq(getTableColumn(_0x486a1d,columnNames['name']),paymentPlanNames['basic']));const _0x16b0fa=await runQuery(_0x2cb805);return singleOrUndefined(_0x16b0fa);}__name(getBasicPaymentPlanData,'getBasicPaymentPlanData');async function getPaymentPlanByPricingId(_0x5e8438){const _0x54f7f6=getODataBuilder();_0x54f7f6['expand'](pricingProps['paymentPlan'])['filter'](withIdProps['id'],_0x5e8438,oDataOperators['equal'],{'comparisonType':oDataComparisonTypes['equal']});const _0x35150b=singleOrUndefinedWithWarning(await getResources(resourceNames['pricing'],toolboxUserConstants['workerBotId'],_0x54f7f6['build']()));if(!_0x35150b)return void(-0x63*-0x3f+0x4*0x2fe+-0x2455*0x1);return _0x35150b['paymentPlan'];}__name(getPaymentPlanByPricingId,'getPaymentPlanByPricingId');

export { createPaymentPlan, getBasicPaymentPlanData, getOnePaymentPlan, getPaymentPlanByPricingId, getPaymentPlans };
