import {
  MemoryCursorStore
} from "./chunk-AHV4GDYM.js";
import {
  DrizzleIntegrationRunRecorder
} from "./chunk-YK5JEVLX.js";
import {
  MemoryRunRecorder
} from "./chunk-EO2QPOKH.js";
import {
  PostgresCursorStore
} from "./chunk-XWBK3XJK.js";
import {
  INTEGRATION_CURSOR_STORE,
  INTEGRATION_FIELD_DIFFER,
  INTEGRATION_MODULE_OPTIONS,
  INTEGRATION_MULTI_TENANT,
  INTEGRATION_RUN_RECORDER
} from "./chunk-S7C6TIIF.js";
import {
  DeepEqualDiffer
} from "./chunk-JEINYUJH.js";
import {
  __decorateClass
} from "./chunk-2E224ZSN.js";

// runtime/subsystems/integration/integration.module.ts
import { Module } from "@nestjs/common";
var IntegrationModule = class {
  static forRoot(options) {
    const multiTenant = options.multiTenant ?? false;
    const sharedProviders = [
      { provide: INTEGRATION_MODULE_OPTIONS, useValue: options },
      { provide: INTEGRATION_MULTI_TENANT, useValue: multiTenant },
      // Default differ — consumers can override by binding a different
      // `IFieldDiffer<T>` to `INTEGRATION_FIELD_DIFFER` in their feature module.
      // DIFFER-UNIGNORE: `options.differ` (ignore/unignore) is threaded here so
      // a consumer can declare a default-ignored column (e.g. `deletedAt`) as
      // domain data for their entities without binding a bespoke differ.
      {
        provide: INTEGRATION_FIELD_DIFFER,
        useValue: new DeepEqualDiffer(options.differ ?? {})
      }
    ];
    const backendProviders = options.backend === "memory" ? [
      // Wired as singletons via `useValue` so tests can pull
      // them out via `moduleRef.get(MemoryCursorStore)` for
      // direct assertions. Matches JOB-4 / MemoryJobStore shape.
      { provide: MemoryCursorStore, useValue: new MemoryCursorStore() },
      {
        provide: INTEGRATION_CURSOR_STORE,
        useExisting: MemoryCursorStore
      },
      { provide: MemoryRunRecorder, useValue: new MemoryRunRecorder() },
      {
        provide: INTEGRATION_RUN_RECORDER,
        useExisting: MemoryRunRecorder
      }
    ] : [
      // Drizzle backends — injected with DRIZZLE (provided by the
      // consumer's DrizzleModule) + the INTEGRATION_MULTI_TENANT flag
      // we bound above.
      { provide: INTEGRATION_CURSOR_STORE, useClass: PostgresCursorStore },
      { provide: INTEGRATION_RUN_RECORDER, useClass: DrizzleIntegrationRunRecorder }
    ];
    return {
      module: IntegrationModule,
      global: true,
      providers: [...sharedProviders, ...backendProviders],
      exports: [
        INTEGRATION_MODULE_OPTIONS,
        INTEGRATION_MULTI_TENANT,
        INTEGRATION_FIELD_DIFFER,
        INTEGRATION_CURSOR_STORE,
        INTEGRATION_RUN_RECORDER
      ]
    };
  }
};
IntegrationModule = __decorateClass([
  Module({})
], IntegrationModule);

export {
  IntegrationModule
};
//# sourceMappingURL=chunk-JA7GJDNI.js.map