import type { CredentialsParams, RepoDesignation } from "../types/public";
export interface CommitDeletedEntry {
    operation: "delete";
    path: string;
}
export type ContentSource = Blob | URL;
export interface CommitFile {
    operation: "addOrUpdate";
    path: string;
    content: ContentSource;
}
/**
 * Opitmized when only the beginning or the end of the file is replaced
 *
 * todo: handle other cases
 */
export interface CommitEditFile {
    operation: "edit";
    path: string;
    /** Later, will be ContentSource. For now simpler to just handle blobs */
    originalContent: Blob;
    edits: Array<{
        /**
         * Later, will be ContentSource. For now simpler to just handle blobs
         *
         * originalContent from [start, end) will be replaced by this
         */
        content: Blob;
        /**
         * The start position of the edit in the original content
         */
        start: number;
        /**
         * The end position of the edit in the original content
         *
         * originalContent from [start, end) will be replaced by the edit
         */
        end: number;
    }>;
}
/**
 * Server-side copy of a file from a source repo/bucket to the destination repo.
 *
 * Only supported when the destination repo is a bucket. The source file must be xet-backed,
 * so the caller is responsible for resolving the source path to its {@link sourceXetHash}
 * (typically via {@link pathsInfo} or {@link listFiles}).
 *
 * For higher-level helpers that perform the resolution and handle non-xet source files,
 * see {@link copyFile}, {@link copyFiles} and {@link copyFolder}.
 */
export interface CommitCopyFile {
    operation: "copy";
    path: string;
    sourceXetHash: string;
    sourceRepo: RepoDesignation;
}
export type CommitOperation = CommitDeletedEntry | CommitFile | CommitEditFile | CommitCopyFile;
export type CommitParams = {
    title: string;
    description?: string;
    repo: RepoDesignation;
    operations: CommitOperation[];
    /** @default "main" */
    branch?: string;
    /**
     * Parent commit. Optional
     *
     * - When opening a PR: will use parentCommit as the parent commit
     * - When committing on a branch: Will make sure that there were no intermediate commits
     */
    parentCommit?: string;
    isPullRequest?: boolean;
    hubUrl?: string;
    /**
     * Whether to use web workers to compute SHA256 hashes.
     *
     * @default false
     */
    useWebWorkers?: boolean | {
        minSize?: number;
        poolSize?: number;
    };
    /**
     * Maximum depth of folders to upload. Files deeper than this will be ignored
     *
     * @default 5
     */
    maxFolderDepth?: number;
    /**
     * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
     */
    fetch?: typeof fetch;
    abortSignal?: AbortSignal;
    /**
     * @default true
     *
     * Use xet protocol: https://huggingface.co/blog/xet-on-the-hub to upload, rather than a basic S3 PUT
     */
    useXet?: boolean;
} & Partial<CredentialsParams>;
export interface CommitOutput {
    pullRequestUrl?: string;
    commit: {
        oid: string;
        url: string;
    };
    hookOutput: string;
}
export type CommitProgressEvent = {
    event: "phase";
    phase: "preuploading" | "uploadingLargeFiles" | "committing";
} | {
    event: "fileProgress";
    path: string;
    progress: number;
    state: "hashing" | "uploading" | "error";
};
/**
 * Internal function for now, used by commit.
 *
 * Can be exposed later to offer fine-tuned progress info
 *
 * CommitOutput is not present for bucket commits
 */
export declare function commitIter(params: CommitParams): AsyncGenerator<CommitProgressEvent, CommitOutput | undefined>;
export declare function commitIterBucket(params: CommitParams): AsyncGenerator<CommitProgressEvent>;
/**
 * @returns undefined for bucket uploads, CommitOutput otherwise
 */
export declare function commit(params: CommitParams): Promise<CommitOutput | undefined>;
//# sourceMappingURL=commit.d.ts.map