import { n as MsgContext } from "./templating-Pr1xaf5R.js";
import { i as NodmixConfig } from "./types.nodmix-B9QJSty6.js";
import { f as MediaUnderstandingConfig } from "./types.tools-CW8RpDYx.js";
import { c as MediaAttachment, d as MediaUnderstandingOutput, f as MediaUnderstandingProvider, l as MediaUnderstandingCapability$1, u as MediaUnderstandingDecision } from "./types-CINPEPGj.js";
import { a as buildOutboundMediaLoadOptions, i as OutboundMediaReadFile, n as OutboundMediaLoadOptions, o as resolveOutboundMediaAccess, r as OutboundMediaLoadParams, s as resolveOutboundMediaLocalRoots, t as OutboundMediaAccess } from "./load-options-CTuppEe4.js";
import { a as resolvePollMaxSelections, i as normalizePollInput, n as PollInput, r as normalizePollDurationHours, t as NormalizedPollInput } from "./polls-CfHkU59X.js";
import { t as OutboundSendDeps } from "./send-deps-BaEC80iY.js";
import { n as ChannelOutboundAdapter } from "./outbound.types-BFO6BpM-.js";
import { o as SsrFPolicy } from "./ssrf-skjEI_i5.js";
import { a as MediaKind, i as MAX_VIDEO_BYTES, n as MAX_DOCUMENT_BYTES, o as maxBytesForKind, r as MAX_IMAGE_BYTES, s as mediaKindFromMime, t as MAX_AUDIO_BYTES } from "./constants-Bjv4FoLj.js";
import { C as AudioContainerTranscodeOutcome, D as LocalMediaAccessErrorCode, E as LocalMediaAccessError, O as assertLocalMediaAllowed, S as runFfprobe, T as transcodeAudioBufferToOpus, _ as MediaExecOptions, a as ImageMetadata, b as resolveFfmpegBin, c as buildImageResizeSideGrid, d as hasAlphaChannel, f as isImageProcessorUnavailableError, g as resizeToPng, h as resizeToJpeg, i as IMAGE_REDUCE_QUALITY_STEPS, k as getDefaultLocalRoots, l as convertHeicToJpeg, m as optimizeImageToPng, n as parseFfprobeVideoDimensions, o as ImageProcessorUnavailableError, p as normalizeExifOrientation, r as probeVideoDimensions, s as MAX_IMAGE_INPUT_PIXELS, t as VideoDimensions, u as getImageMetadata, v as parseFfprobeCodecAndSampleRate, w as transcodeAudioBuffer, x as runFfmpeg, y as parseFfprobeCsvFields } from "./media-services-VQu0-ewV.js";
import { a as imageMimeFromFormat, c as kindFromMime, d as sliceMimeSniffBuffer, i as getFileExtension, l as mimeTypeFromFilePath, n as detectMime, o as isAudioFileName, r as extensionForMime, s as isGifMedia, t as FILE_TYPE_SNIFF_MAX_BYTES, u as normalizeMimeType } from "./mime-Ds6Fkh-A.js";
import { _ as isVoiceMessageCompatibleAudio, a as MediaFetchErrorCode, c as SaveResponseMediaOptions, d as readRemoteMediaBuffer, f as saveRemoteMedia, g as isVoiceCompatibleAudio, h as VOICE_MESSAGE_MIME_TYPES, i as MediaFetchError, l as SavedRemoteMedia, m as VOICE_MESSAGE_AUDIO_EXTENSIONS, n as FetchDispatcherAttempt, o as MediaFetchRetryOptions, p as saveResponseMedia, r as FetchLike, s as SaveRemoteMediaOptions, t as DEFAULT_FETCH_MEDIA_MAX_BYTES, u as fetchRemoteMedia } from "./fetch-6raxI7fB.js";
import { t as ActiveMediaModel } from "./active-model-CLwISfxh.js";
import { a as SavedMedia, c as ensureMediaDir, d as readMediaBuffer, f as resolveMediaBufferPath, g as setMediaStoreNetworkDepsForTest, h as saveMediaStream, i as SaveMediaSourceErrorCode, l as extractOriginalFilename, m as saveMediaSource, n as ReadMediaBufferResult, o as cleanOldMedia, p as saveMediaBuffer, r as SaveMediaSourceError, s as deleteMediaBuffer, t as MEDIA_MAX_BYTES, u as getMediaDir } from "./store-B1k6BLfV.js";
import { a as getAgentScopedMediaLocalRoots, i as buildMediaLocalRoots, n as buildAgentMediaPayload, o as getAgentScopedMediaLocalRootsForSources, r as appendLocalMediaParentRoots, s as getDefaultMediaLocalRoots, t as AgentMediaPayload } from "./agent-media-payload-DwvCIi8l.js";
import { i as normalizeInboundPathRoots, n as isValidInboundPathRootPattern, r as mergeInboundPathRoots, t as isInboundPathAllowed } from "./inbound-path-policy-C5kkOV4j.js";
import { a as readByteStreamWithLimit, i as ReadByteStreamWithLimitOptions, n as readResponseWithLimit, r as ByteStreamLimitOverflow, t as readResponseTextSnippet } from "./read-response-with-limit-C__UYM4_.js";
import { i as describeImagesWithModelPayloadTransform, n as describeImageWithModelPayloadTransform, r as describeImagesWithModel, t as describeImageWithModel } from "./image-runtime-B59l3HTd.js";
//#region src/media/base64.d.ts
declare function estimateBase64DecodedBytes(base64: string): number;
/**
 * Normalize and validate a base64 string.
 * Returns canonical base64 (no whitespace) or undefined when invalid.
 */
declare function canonicalizeBase64(base64: string): string | undefined;
//#endregion
//#region src/media/content-length.d.ts
declare function parseMediaContentLength(raw: string | null): number | null;
//#endregion
//#region src/media/ffmpeg-limits.d.ts
declare const MEDIA_FFMPEG_MAX_BUFFER_BYTES: number;
declare const MEDIA_FFPROBE_TIMEOUT_MS = 10000;
declare const MEDIA_FFMPEG_TIMEOUT_MS = 45000;
declare const MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS: number;
//#endregion
//#region src/media/outbound-attachment.d.ts
declare function resolveOutboundAttachmentFromUrl(mediaUrl: string, maxBytes: number, options?: {
  mediaAccess?: OutboundMediaAccess;
  localRoots?: readonly string[];
  readFile?: (filePath: string) => Promise<Buffer>;
}): Promise<{
  path: string;
  contentType?: string;
}>;
//#endregion
//#region src/media/png-encode.d.ts
/** Write a pixel to an RGBA buffer. Ignores out-of-bounds writes. */
declare function fillPixel(buf: Buffer, x: number, y: number, width: number, r: number, g: number, b: number, a?: number): void;
/** Encode an RGB buffer as a PNG image. */
declare function encodePngRgb(buffer: Buffer, width: number, height: number): Buffer;
/** Encode an RGBA buffer as a PNG image. */
declare function encodePngRgba(buffer: Buffer, width: number, height: number): Buffer;
//#endregion
//#region src/media/qr-image.d.ts
type QrPngRenderOptions = {
  scale?: number;
  marginModules?: number;
};
type QrPngTempFileOptions = QrPngRenderOptions & {
  tmpRoot: string;
  dirPrefix: string;
  fileName?: string;
};
type QrPngTempFile = {
  filePath: string;
  dirPath: string;
  mediaLocalRoots: string[];
};
declare function renderQrPngBase64(input: string, opts?: QrPngRenderOptions): Promise<string>;
declare function formatQrPngDataUrl(base64: string): string;
declare function renderQrPngDataUrl(input: string, opts?: QrPngRenderOptions): Promise<string>;
declare function writeQrPngTempFile(input: string, opts: QrPngTempFileOptions): Promise<QrPngTempFile>;
//#endregion
//#region src/media/qr-terminal.d.ts
declare function renderQrTerminal(input: string, opts?: {
  small?: boolean;
}): Promise<string>;
//#endregion
//#region src/media/temp-files.d.ts
declare function unlinkIfExists(filePath: string | null | undefined): Promise<void>;
//#endregion
//#region src/channels/plugins/media-limits.d.ts
declare function resolveChannelMediaMaxBytes(params: {
  cfg: NodmixConfig;
  resolveChannelLimitMb: (params: {
    cfg: NodmixConfig;
    accountId: string;
  }) => number | undefined;
  accountId?: string | null;
}): number | undefined;
//#endregion
//#region src/media-understanding/audio-preflight.d.ts
/**
 * Transcribes the first audio attachment BEFORE mention checking.
 * This allows voice notes to be processed in group chats with requireMention: true.
 * Returns the transcript or undefined if transcription fails or no audio is found.
 */
declare function transcribeFirstAudio(params: {
  ctx: MsgContext;
  cfg: NodmixConfig;
  agentDir?: string;
  providers?: Record<string, MediaUnderstandingProvider>;
  activeModel?: ActiveMediaModel;
}): Promise<string | undefined>;
//#endregion
//#region packages/media-understanding-common/src/types.d.ts
type MediaUnderstandingCapability = "image" | "audio" | "video";
//#endregion
//#region packages/media-understanding-common/src/defaults.d.ts
declare const DEFAULT_MAX_CHARS = 500;
declare const DEFAULT_MAX_CHARS_BY_CAPABILITY: Record<MediaUnderstandingCapability, number | undefined>;
declare const DEFAULT_MAX_BYTES: Record<MediaUnderstandingCapability, number>;
declare const DEFAULT_TIMEOUT_SECONDS: Record<MediaUnderstandingCapability, number>;
declare const DEFAULT_PROMPT: Record<MediaUnderstandingCapability, string>;
declare const DEFAULT_VIDEO_MAX_BASE64_BYTES: number;
declare const CLI_OUTPUT_MAX_BUFFER: number;
declare const DEFAULT_MEDIA_CONCURRENCY = 2;
declare const MIN_AUDIO_FILE_BYTES = 1024;
//#endregion
//#region src/media-understanding/defaults.d.ts
declare function resolveDefaultMediaModel(params: {
  providerId: string;
  capability: MediaUnderstandingCapability$1;
  cfg?: NodmixConfig;
  workspaceDir?: string;
  providerRegistry?: Map<string, MediaUnderstandingProvider>;
  includeConfiguredImageModels?: boolean;
}): string | undefined;
declare function resolveAutoMediaKeyProviders(params: {
  capability: MediaUnderstandingCapability$1;
  cfg?: NodmixConfig;
  workspaceDir?: string;
  providerRegistry?: Map<string, MediaUnderstandingProvider>;
}): string[];
declare function providerSupportsNativePdfDocument(params: {
  providerId: string;
  cfg?: NodmixConfig;
  workspaceDir?: string;
  providerRegistry?: Map<string, MediaUnderstandingProvider>;
}): boolean;
declare function resolveDocumentMediaModel(params: {
  providerId: string;
  document: "pdf";
  mode: "textExtraction" | "image";
  cfg?: NodmixConfig;
  workspaceDir?: string;
  providerRegistry?: Map<string, MediaUnderstandingProvider>;
}): string | false | undefined;
//#endregion
//#region src/media-understanding/attachments.cache.d.ts
type MediaBufferResult = {
  buffer: Buffer;
  mime?: string;
  fileName: string;
  size: number;
};
type MediaPathResult = {
  path: string;
  cleanup?: () => Promise<void> | void;
};
type MediaAttachmentCacheOptions = {
  localPathRoots?: readonly string[];
  includeDefaultLocalPathRoots?: boolean;
  ssrfPolicy?: SsrFPolicy;
  workspaceDir?: string;
};
declare class MediaAttachmentCache {
  private readonly entries;
  private readonly attachments;
  private readonly localPathRoots;
  private readonly ssrfPolicy;
  private readonly workspaceDir?;
  private canonicalLocalPathRoots?;
  constructor(attachments: MediaAttachment[], options?: MediaAttachmentCacheOptions);
  getBuffer(params: {
    attachmentIndex: number;
    maxBytes: number;
    timeoutMs: number;
  }): Promise<MediaBufferResult>;
  getPath(params: {
    attachmentIndex: number;
    maxBytes?: number;
    timeoutMs: number;
  }): Promise<MediaPathResult>;
  cleanup(): Promise<void>;
  private ensureEntry;
  private resolveLocalPath;
  private ensureLocalStat;
  private getCanonicalLocalPathRoots;
  private readLocalBuffer;
}
//#endregion
//#region src/media-understanding/runner.attachments.d.ts
declare function normalizeMediaAttachments(ctx: MsgContext): MediaAttachment[];
declare function createMediaAttachmentCache(attachments: MediaAttachment[], options?: MediaAttachmentCacheOptions): MediaAttachmentCache;
//#endregion
//#region src/media-understanding/runner.d.ts
type ProviderRegistry = Map<string, MediaUnderstandingProvider>;
type RunCapabilityResult = {
  outputs: MediaUnderstandingOutput[];
  decision: MediaUnderstandingDecision;
};
declare function buildProviderRegistry(overrides?: Record<string, MediaUnderstandingProvider>, cfg?: NodmixConfig): ProviderRegistry;
declare function resolveMediaAttachmentLocalRoots(params: {
  cfg: NodmixConfig;
  ctx: MsgContext;
  workspaceDir?: string;
}): readonly string[];
declare function clearMediaUnderstandingBinaryCacheForTests(): void;
declare function resolveAutoImageModel(params: {
  cfg: NodmixConfig;
  agentId?: string;
  agentDir?: string;
  workspaceDir?: string;
  activeModel?: ActiveMediaModel;
}): Promise<ActiveMediaModel | null>;
declare function runCapability(params: {
  capability: MediaUnderstandingCapability$1;
  cfg: NodmixConfig;
  ctx: MsgContext;
  attachments: MediaAttachmentCache;
  media: MediaAttachment[];
  agentId?: string;
  agentDir?: string;
  workspaceDir?: string;
  providerRegistry: ProviderRegistry;
  config?: MediaUnderstandingConfig;
  activeModel?: ActiveMediaModel;
}): Promise<RunCapabilityResult>;
//#endregion
//#region packages/media-understanding-common/src/provider-id.d.ts
declare function normalizeMediaProviderId(id: string): string;
//#endregion
//#region src/channels/plugins/outbound/direct-text-media.d.ts
type DirectSendOptions = {
  cfg: NodmixConfig;
  accountId?: string | null;
  replyToId?: string | null;
  mediaUrl?: string;
  mediaAccess?: OutboundMediaAccess;
  mediaLocalRoots?: readonly string[];
  mediaReadFile?: (filePath: string) => Promise<Buffer>;
  maxBytes?: number;
};
type DirectSendResult = {
  messageId: string;
  [key: string]: unknown;
};
type DirectSendFn<TOpts extends Record<string, unknown>, TResult extends DirectSendResult> = (to: string, text: string, opts: TOpts) => Promise<TResult>;
declare function resolveScopedChannelMediaMaxBytes(params: {
  cfg: NodmixConfig;
  accountId?: string | null;
  resolveChannelLimitMb: (params: {
    cfg: NodmixConfig;
    accountId: string;
  }) => number | undefined;
}): number | undefined;
declare function createScopedChannelMediaMaxBytesResolver(channel: string): (params: {
  cfg: NodmixConfig;
  accountId?: string | null;
}) => number | undefined;
declare function createDirectTextMediaOutbound<TOpts extends Record<string, unknown>, TResult extends DirectSendResult>(params: {
  channel: string;
  resolveSender: (deps: OutboundSendDeps | undefined) => DirectSendFn<TOpts, TResult>;
  resolveMaxBytes: (params: {
    cfg: NodmixConfig;
    accountId?: string | null;
  }) => number | undefined;
  buildTextOptions: (params: DirectSendOptions) => TOpts;
  buildMediaOptions: (params: DirectSendOptions) => TOpts;
}): ChannelOutboundAdapter;
//#endregion
export { type ActiveMediaModel, AgentMediaPayload, type AudioContainerTranscodeOutcome, ByteStreamLimitOverflow, CLI_OUTPUT_MAX_BUFFER, DEFAULT_FETCH_MEDIA_MAX_BYTES, DEFAULT_MAX_BYTES, DEFAULT_MAX_CHARS, DEFAULT_MAX_CHARS_BY_CAPABILITY, DEFAULT_MEDIA_CONCURRENCY, DEFAULT_PROMPT, DEFAULT_TIMEOUT_SECONDS, DEFAULT_VIDEO_MAX_BASE64_BYTES, FILE_TYPE_SNIFF_MAX_BYTES, FetchDispatcherAttempt, FetchLike, IMAGE_REDUCE_QUALITY_STEPS, type ImageMetadata, ImageProcessorUnavailableError, LocalMediaAccessError, LocalMediaAccessErrorCode, MAX_AUDIO_BYTES, MAX_DOCUMENT_BYTES, MAX_IMAGE_BYTES, MAX_IMAGE_INPUT_PIXELS, MAX_VIDEO_BYTES, MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, MEDIA_FFMPEG_MAX_BUFFER_BYTES, MEDIA_FFMPEG_TIMEOUT_MS, MEDIA_FFPROBE_TIMEOUT_MS, MEDIA_MAX_BYTES, MIN_AUDIO_FILE_BYTES, type MediaExecOptions, MediaFetchError, MediaFetchErrorCode, MediaFetchRetryOptions, MediaKind, NormalizedPollInput, OutboundMediaAccess, OutboundMediaLoadOptions, OutboundMediaLoadParams, OutboundMediaReadFile, PollInput, ReadByteStreamWithLimitOptions, ReadMediaBufferResult, RunCapabilityResult, SaveMediaSourceError, SaveMediaSourceErrorCode, SaveRemoteMediaOptions, SaveResponseMediaOptions, SavedMedia, SavedRemoteMedia, VOICE_MESSAGE_AUDIO_EXTENSIONS, VOICE_MESSAGE_MIME_TYPES, type VideoDimensions, appendLocalMediaParentRoots, assertLocalMediaAllowed, buildAgentMediaPayload, buildImageResizeSideGrid, buildMediaLocalRoots, buildOutboundMediaLoadOptions, buildProviderRegistry, canonicalizeBase64, cleanOldMedia, clearMediaUnderstandingBinaryCacheForTests, convertHeicToJpeg, createDirectTextMediaOutbound, createMediaAttachmentCache, createScopedChannelMediaMaxBytesResolver, deleteMediaBuffer, describeImageWithModel, describeImageWithModelPayloadTransform, describeImagesWithModel, describeImagesWithModelPayloadTransform, detectMime, encodePngRgb, encodePngRgba, ensureMediaDir, estimateBase64DecodedBytes, extensionForMime, extractOriginalFilename, fetchRemoteMedia, fillPixel, formatQrPngDataUrl, getAgentScopedMediaLocalRoots, getAgentScopedMediaLocalRootsForSources, getDefaultLocalRoots, getDefaultMediaLocalRoots, getFileExtension, getImageMetadata, getMediaDir, hasAlphaChannel, imageMimeFromFormat, isAudioFileName, isGifMedia, isImageProcessorUnavailableError, isInboundPathAllowed, isValidInboundPathRootPattern, isVoiceCompatibleAudio, isVoiceMessageCompatibleAudio, kindFromMime, maxBytesForKind, mediaKindFromMime, mergeInboundPathRoots, mimeTypeFromFilePath, normalizeExifOrientation, normalizeInboundPathRoots, normalizeMediaAttachments, normalizeMediaProviderId, normalizeMimeType, normalizePollDurationHours, normalizePollInput, optimizeImageToPng, parseFfprobeCodecAndSampleRate, parseFfprobeCsvFields, parseFfprobeVideoDimensions, parseMediaContentLength, probeVideoDimensions, providerSupportsNativePdfDocument, readByteStreamWithLimit, readMediaBuffer, readRemoteMediaBuffer, readResponseTextSnippet, readResponseWithLimit, renderQrPngBase64, renderQrPngDataUrl, renderQrTerminal, resizeToJpeg, resizeToPng, resolveAutoImageModel, resolveAutoMediaKeyProviders, resolveChannelMediaMaxBytes, resolveDefaultMediaModel, resolveDocumentMediaModel, resolveFfmpegBin, resolveMediaAttachmentLocalRoots, resolveMediaBufferPath, resolveOutboundAttachmentFromUrl, resolveOutboundMediaAccess, resolveOutboundMediaLocalRoots, resolvePollMaxSelections, resolveScopedChannelMediaMaxBytes, runCapability, runFfmpeg, runFfprobe, saveMediaBuffer, saveMediaSource, saveMediaStream, saveRemoteMedia, saveResponseMedia, setMediaStoreNetworkDepsForTest, sliceMimeSniffBuffer, transcodeAudioBuffer, transcodeAudioBufferToOpus, transcribeFirstAudio, unlinkIfExists, writeQrPngTempFile };