import type { Asset, AssetKind } from "../types/editor";
import "./dialog.css";
import "./AssetManagerModal.css";
export interface AssetManagerModalProps {
open: boolean;
onClose: () => void;
/**
* When set, the modal opens in "resolve" mode for an unresolved
* `` placeholder: it goes straight to the source picker
* for that kind, and whatever asset the user picks/uploads/creates is bound to
* this placeholder (its ref is rewritten in the source) instead of copying an
* embed code.
*/
resolveTarget?: {
kind: AssetKind;
ref: string;
} | null;
/**
* When set, the modal opens in "replace" mode for an existing asset: it goes
* straight to the source picker, and whatever the user picks/uploads/creates
* takes over from this asset (handled by `onReplaceAsset`).
*/
replaceTarget?: Asset | null;
onLoadAssets?: () => Promise;
onLoadLibraryAssets?: () => Promise;
/** Associate a library asset with the current project. */
onAddFromLibrary?: (asset: Asset) => Promise | void;
/** Upload an image file; host returns the created asset. */
onUpload?: (file: File) => Promise;
/**
* Fetch an external URL on the user's behalf (server-side, to avoid CORS)
* and return the raw file bytes. Must not create a persisted asset — the
* returned file is then committed via `onUpload`, the same as a local
* file pick, so there is a single code path that creates project assets.
*/
onFetchUrl?: (url: string) => Promise;
/** Create a new Doenet activity; host returns the created asset. */
onCreateDoenet?: (name: string, ref: string) => Promise;
/** Remove an asset from the project. */
onRemoveAsset?: (asset: Asset) => void;
/**
* Duplicate an asset under a fresh ref (same behaviour as Duplicate in the
* asset editor). May be async; the row shows a busy state until it settles,
* then the manager closes as the editor opens on the new copy. When omitted,
* the Duplicate control is hidden.
*/
onDuplicateAsset?: (asset: Asset) => void | Promise;
/** Notify that an asset now exists in the project (optimistic pool add). */
onAssetAdded: (asset: Asset) => void;
/** Rewrite in-document `` placeholders to `newRef`. */
onResolveRef: (kind: AssetKind, oldRef: string, newRef: string) => void;
/**
* Replace `oldAsset` with the user's chosen `newAsset`. `fromLibrary` is true
* when `newAsset` is an existing library asset (so it keeps its own ref and
* the document is re-pointed), false when freshly created (so it adopts the
* old asset's ref).
*/
onReplaceAsset: (oldAsset: Asset, newAsset: Asset, fromLibrary: boolean) => void;
}
declare const AssetManagerModal: ({ open, onClose, resolveTarget, replaceTarget, onLoadAssets, onLoadLibraryAssets, onAddFromLibrary, onUpload, onFetchUrl, onCreateDoenet, onRemoveAsset, onDuplicateAsset, onAssetAdded, onResolveRef, onReplaceAsset, }: AssetManagerModalProps) => import("react").JSX.Element | null;
export default AssetManagerModal;