/**
 * @bobfrankston/mailx-settings
 * Settings management with shared/local split.
 *
 * Files (shared — on OneDrive or similar):
 *   accounts.jsonc    — IMAP/SMTP account configs
 *   preferences.jsonc — UI, sync, font settings
 *   allowlist.jsonc   — remote content allow-list
 *
 * Local overrides (~/.mailx/):
 *   config.jsonc      — pointer to shared dir + local-only settings (storePath, historyDays)
 *   accounts.jsonc    — cached copy, fallback when shared unavailable
 *   preferences.jsonc — local overrides merged on top of shared
 *   allowlist.jsonc   — cached copy
 *
 * The old settings.jsonc is still supported for backward compatibility.
 */
import type { MailxSettings, AccountConfig, AutocompleteSettings } from "@bobfrankston/mailx-types";
declare const LOCAL_DIR: string;
/** Subscribers notified whenever lastCloudError changes (push to UI immediately). */
type CloudErrorListener = (error: string | null, context?: {
    op: "read" | "write";
    filename: string;
}) => void;
export declare function onCloudError(cb: CloudErrorListener): () => void;
export declare function getLastCloudError(): string | null;
declare function getSharedDir(): string;
/** Read a file via cloud API (when filesystem mount not available) */
export declare function cloudRead(filename: string): Promise<string | null>;
/** Write a file via cloud API. Throws on failure with a descriptive error,
 *  and updates lastCloudError so UI banners pick it up via getStorageInfo()
 *  and the onCloudError listener. */
export declare function cloudWrite(filename: string, content: string): Promise<void>;
/** Whether cloud API fallback is active */
export declare function isCloudMode(): boolean;
/** Get storage provider info for display */
export declare function getStorageInfo(): {
    provider: string;
    mode: "mount" | "api" | "local";
    cloudPath?: string;
    cloudError?: string;
};
/** Fill in provider defaults for an account based on email domain.
 *  Exported so mailx-service's leanAccountsJsonc helper can reuse the same
 *  canonicalization rules that loadAccounts uses. */
export declare function normalizeAccount(acct: any, globalName?: string): AccountConfig;
declare const DEFAULT_PREFERENCES: {
    ui: {
        theme: "system" | "dark" | "light";
        editor: "quill" | "tiptap";
        folderWidth: number;
        listViewerSplit: number;
        fontSize: number;
    };
    sync: {
        intervalMinutes: number;
        historyDays: number;
        prefetch: boolean;
    };
    autocomplete: {
        enabled: boolean;
        provider: "ollama";
        ollamaUrl: string;
        ollamaModel: string;
        cloudApiKey: string;
        cloudModel: string;
        debounceMs: number;
        maxTokens: number;
    };
};
declare const DEFAULT_AUTOCOMPLETE: AutocompleteSettings;
declare const DEFAULT_ALLOWLIST: {
    senders: string[];
    domains: string[];
    recipients: string[];
    flaggedSenders: string[];
    flaggedDomains: string[];
};
/** Load account configs */
export declare function loadAccounts(): AccountConfig[];
/** Load accounts with cloud API fallback (async — use when cloud settings may not be mounted) */
export declare function loadAccountsAsync(): Promise<AccountConfig[]>;
/** Strip default-valued fields from a normalized AccountConfig so the
 *  serialized JSONC stays compact and human-editable. The previous version
 *  was round-tripping every defaulted field (port: 993, tls: true, auth:
 *  "password", enabled: true, etc.), which bloated a 10-line accounts.jsonc
 *  to 60+ lines and embedded unnecessary "knowledge" about defaults.
 *
 *  Rules:
 *  - Drop fields that match the provider default (host/port/tls/auth derived
 *    from email domain via PROVIDERS).
 *  - Drop `enabled: true` (default).
 *  - Drop `name` if equal to the file-level `globalName`.
 *  - Drop `imap.user` / `smtp.user` if they equal the email.
 *  - Drop `sig.html: false` (default; only keep when user enabled HTML sigs).
 *  - Keep field order: id → label → email → primary* → imap → smtp → defaultSend
 *    → relayDomains → deliveredToPrefix → identityDomains → syncContacts → sig.
 *    Curated for readability, not alphabetic. */
export declare function denormalizeAccount(acct: AccountConfig, globalName?: string): any;
/** Save account configs */
/** Save accounts — merges with cloud copy by email (multi-client safe).
 *  Writes the lean form via denormalizeAccount so accounts.jsonc stays
 *  compact and human-editable. */
export declare function saveAccounts(accounts: AccountConfig[]): Promise<void>;
/** Load preferences (shared + local overrides, with legacy fallback) */
export declare function loadPreferences(): typeof DEFAULT_PREFERENCES;
/** Save preferences */
export declare function savePreferences(prefs: any): void;
/** Load autocomplete settings */
export declare function loadAutocomplete(): AutocompleteSettings;
/** Save autocomplete settings */
export declare function saveAutocomplete(settings: AutocompleteSettings): void;
/** Load remote content allow-list */
export declare function loadAllowlist(): typeof DEFAULT_ALLOWLIST;
/** Save allow-list — merges with existing cloud copy (multi-client safe) */
export declare function saveAllowlist(list: typeof DEFAULT_ALLOWLIST): Promise<void>;
/** Load settings — unified view combining all files (backward compatible) */
export declare function loadSettings(): MailxSettings;
/** Save settings — writes to split files */
export declare function saveSettings(settings: MailxSettings): Promise<void>;
/** Get the local store base path */
export declare function getStorePath(): string;
/** Get the local data directory (DB, store, etc.) */
export declare function getConfigDir(): string;
/** Get the shared settings directory */
export { getSharedDir };
/** Initialize local config if it doesn't exist */
export declare function initLocalConfig(sharedDir?: string, storePath?: string): void;
/** Initialize config with Google Drive cloud storage.
 *  Finds or creates the app-owned "mailx" folder via Drive API and stores its ID.
 *  No mount scanning — API only. Existing settings at other paths (e.g., home/.mailx
 *  from Desktop sync) must be migrated manually or via config.jsonc importPath. */
export declare function initCloudConfig(provider?: "gdrive"): Promise<void>;
declare const DEFAULT_SETTINGS: MailxSettings;
/** Get historyDays for an account: per-account override > system override > shared default */
export declare function getHistoryDays(accountId?: string): number;
/** Get prefetch setting: download bodies during sync (default true) */
export declare function getPrefetch(): boolean;
export { DEFAULT_SETTINGS, DEFAULT_ALLOWLIST, DEFAULT_PREFERENCES, DEFAULT_AUTOCOMPLETE, LOCAL_DIR };
//# sourceMappingURL=index.d.ts.map