//#region src/compliance.d.ts
type ComplianceRegion = 'US' | 'EU' | 'IL' | (string & {});
type SenderLegalDeclaration = {
  spf: boolean;
  dkim: boolean;
  dmarc: boolean;
  physicalPostalAddress: string;
  advertisingLabel: string;
};
type CampaignLegalContext = {
  region?: ComplianceRegion;
  legal: SenderLegalDeclaration;
  /** HTTPS one-click unsubscribe URL (RFC 8058). */
  oneClickUnsubscribeUrl: string;
};
type CompliantRecipientMessage = {
  email: string;
  subject: string;
  html: string;
  text?: string;
  headers: Record<string, string>;
};
type SendCampaignRefusal = {
  email: string;
  code: string;
  reason: string;
};
type CompliantSendResult = {
  sent: string[];
  refused: SendCampaignRefusal[];
};
/** Host-owned suppression + consent store (self-managed: authoritative; ESP: mirror for defense-in-depth). */
interface ComplianceStore {
  isSuppressed(email: string): Promise<boolean>;
  getConsent(email: string): Promise<ConsentRecord | null>;
  setConsent(record: ConsentRecord): Promise<void>;
  addSuppression(entry: SuppressionEntry): Promise<void>;
  /** Full suppression list — backs the `syncSuppression` LCD verb; store MUST be enumerable. */
  listSuppressed(): Promise<SuppressionEntry[]>;
}
declare class ComplianceError extends Error {
  readonly code: string;
  readonly name = "ComplianceError";
  constructor(message: string, code: string);
}
/** Default-on IL/EU — records confirmed double-opt-in consent. */
declare function confirmDoubleOptIn(store: ComplianceStore, email: string, region?: ComplianceRegion, now?: () => string): Promise<ConsentRecord>;
declare function recordTrackingConsent(store: ComplianceStore, email: string, now?: () => string): Promise<ConsentRecord>;
/** Pre-send legal gate — blocks campaigns missing required sender declarations. */
declare function validatePreSendLegalGate(ctx: CampaignLegalContext): void;
/** RFC 8058 one-click unsubscribe headers — injected on every compliant send. */
declare function buildRfc8058Headers(oneClickUnsubscribeUrl: string): Record<string, string>;
type TrackingOpts = {
  campaignId: string;
  email: string;
  trackingBaseUrl: string;
  hasTrackingConsent: boolean;
};
/** Tracking pixel + click redirect emitted ONLY when per-contact tracking consent is recorded. */
declare function applyTracking(html: string, opts: TrackingOpts): string;
declare function assertRecipientEligible(email: string, consent: ConsentRecord | null, suppressed: boolean, region?: ComplianceRegion): SendCampaignRefusal | null;
type CompliantSendInput = {
  campaignId: string;
  campaign: Campaign;
  legal: CampaignLegalContext;
  recipients: string[];
  trackingBaseUrl: string;
};
/**
 * Compliance-wrapped per-recipient send — suppression + consent gate, legal pre-check,
 * tracking-off-by-default, RFC 8058 header injection.
 */
declare function executeCompliantSend(store: ComplianceStore, input: CompliantSendInput, sendOne: (message: CompliantRecipientMessage) => Promise<void>): Promise<CompliantSendResult>;
/** In-memory ComplianceStore for tests and self-managed hosts without a wired DB yet. */
declare function createMemoryComplianceStore(initial?: {
  suppressed?: SuppressionEntry[];
  consents?: ConsentRecord[];
}): ComplianceStore & {
  suppressed: SuppressionEntry[];
  consents: Map<string, ConsentRecord>;
};
//#endregion
//#region src/index.d.ts
type MarketingSupports = {
  segments: boolean;
  scheduling: boolean;
  automation: boolean;
};
type MarketingContact = {
  email: string;
  attributes?: Record<string, string>;
  tags?: string[];
};
type MarketingList = {
  id: string;
  name: string;
};
type Campaign = {
  id: string;
  name: string;
  subject: string;
  html: string;
  text?: string;
  listIds: string[];
  region?: 'US' | 'EU' | 'IL' | (string & {});
};
type CampaignStats = {
  opens: number;
  clicks: number;
  bounces: number;
  unsubs: number;
};
type SuppressionEntry = {
  email: string;
  reason: 'unsubscribe' | 'bounce' | 'complaint' | 'manual';
  suppressedAt: string;
};
type ConsentRecord = {
  email: string;
  doubleOptInConfirmed: boolean;
  confirmedAt?: string;
  trackingConsent: boolean;
  trackingConsentAt?: string;
  region?: string;
};
type SendCampaignOpts = {
  trackingBaseUrl: string;
  legal: CampaignLegalContext;
};
type SendCampaignResult = CompliantSendResult;
interface MarketingAdapter {
  readonly name: string;
  readonly supports: MarketingSupports;
  upsertContact(contact: MarketingContact, listId?: string): Promise<void>;
  removeContact(email: string, listId?: string): Promise<void>;
  tagContact(email: string, tag: string): Promise<void>;
  createList(name: string): Promise<MarketingList>;
  lists(): Promise<MarketingList[]>;
  createCampaign(campaign: Omit<Campaign, 'id'>): Promise<Campaign>;
  sendCampaign(campaignId: string, opts: SendCampaignOpts): Promise<SendCampaignResult>;
  campaignStats(campaignId: string): Promise<CampaignStats>;
  syncSuppression(): Promise<SuppressionEntry[]>;
}
declare class MarketingError extends Error {}
declare class UnsupportedOperation extends MarketingError {
  readonly capability: 'segments' | 'scheduling' | 'automation';
  readonly name = "UnsupportedOperation";
  constructor(capability: 'segments' | 'scheduling' | 'automation', message?: string);
}
declare class MarketingProviderError extends MarketingError {
  readonly provider: string;
  readonly retryable: boolean;
  readonly cause?: unknown | undefined;
  readonly name = "MarketingProviderError";
  constructor(message: string, provider: string, retryable?: boolean, cause?: unknown | undefined);
}
type MarketingAdapterName = 'self-managed' | 'brevo';
type MarketingAdapterFactory = (creds: unknown, deps?: MarketingAdapterDeps) => MarketingAdapter;
type MarketingAdapterDeps = {
  complianceStore?: ComplianceStore;
};
declare function registerMarketingAdapter(name: MarketingAdapterName, factory: MarketingAdapterFactory): void;
declare function getAdapter(name: string, creds: unknown, deps?: MarketingAdapterDeps): MarketingAdapter;
declare function requireCapability(adapter: MarketingAdapter, capability: keyof MarketingSupports): void;
/** Shared compliant send orchestration — adapters call this; never bypass. */
declare function sendCampaignThroughCompliance(store: ComplianceStore, input: CompliantSendInput, sendOne: Parameters<typeof executeCompliantSend>[2]): Promise<CompliantSendResult>;
//#endregion
export { TrackingOpts as A, ComplianceRegion as C, CompliantSendResult as D, CompliantSendInput as E, createMemoryComplianceStore as F, executeCompliantSend as I, recordTrackingConsent as L, assertRecipientEligible as M, buildRfc8058Headers as N, SendCampaignRefusal as O, confirmDoubleOptIn as P, validatePreSendLegalGate as R, ComplianceError as S, CompliantRecipientMessage as T, getAdapter as _, MarketingAdapterDeps as a, sendCampaignThroughCompliance as b, MarketingContact as c, MarketingProviderError as d, MarketingSupports as f, UnsupportedOperation as g, SuppressionEntry as h, MarketingAdapter as i, applyTracking as j, SenderLegalDeclaration as k, MarketingError as l, SendCampaignResult as m, CampaignStats as n, MarketingAdapterFactory as o, SendCampaignOpts as p, ConsentRecord as r, MarketingAdapterName as s, Campaign as t, MarketingList as u, registerMarketingAdapter as v, ComplianceStore as w, CampaignLegalContext as x, requireCapability as y };