import { baseEmailCapabilities } from "./email-capabilities.js";
import { hasChannelAdapter, registerChannelAdapter } from "./adapter-registry-singleton.js";
const TEST_SEED_PROVIDER_KEY = "__test_seed__";
const TEST_CHANNEL_SEEDING_ENV = "OM_ENABLE_TEST_CHANNEL_SEEDING";
function isTestChannelSeedingEnabled() {
  const raw = process.env[TEST_CHANNEL_SEEDING_ENV];
  if (typeof raw !== "string") return false;
  return ["1", "true", "yes", "on"].includes(raw.trim().toLowerCase());
}
const testSeedCapabilities = {
  ...baseEmailCapabilities,
  conversationHistory: false,
  realtimePush: false
};
class TestSeedChannelAdapter {
  constructor() {
    this.providerKey = TEST_SEED_PROVIDER_KEY;
    this.channelType = "email";
    this.capabilities = testSeedCapabilities;
  }
  async sendMessage(input) {
    const externalMessageId = `test-seed-${Date.now()}-${Math.random().toString(16).slice(2, 10)}@test-seed.local`;
    return {
      externalMessageId,
      conversationId: input.conversationId,
      status: "sent",
      metadata: { testSeed: true }
    };
  }
  async verifyWebhook(_input) {
    return { raw: {}, eventType: "other", metadata: { reason: "test-seed-no-webhook" } };
  }
  async getStatus(_input) {
    return { status: "sent" };
  }
  async convertOutbound(input) {
    return {
      content: {
        text: input.body,
        bodyFormat: input.bodyFormat
      },
      metadata: input.channelMetadata ?? {}
    };
  }
  async normalizeInbound(_raw) {
    throw new Error("[internal] TestSeedChannelAdapter.normalizeInbound is not used by the seed harness");
  }
  async validateCredentials(_input) {
    return { ok: true };
  }
}
let cachedTestSeedAdapter = null;
function getTestSeedChannelAdapter() {
  if (!cachedTestSeedAdapter) cachedTestSeedAdapter = new TestSeedChannelAdapter();
  return cachedTestSeedAdapter;
}
function ensureTestSeedAdapterRegistered() {
  if (!isTestChannelSeedingEnabled()) return;
  if (hasChannelAdapter(TEST_SEED_PROVIDER_KEY)) return;
  registerChannelAdapter(getTestSeedChannelAdapter());
}
export {
  TEST_CHANNEL_SEEDING_ENV,
  TEST_SEED_PROVIDER_KEY,
  ensureTestSeedAdapterRegistered,
  isTestChannelSeedingEnabled
};
//# sourceMappingURL=test-seed.js.map
