import { MediaTypeService } from '../../../../../core/backend-api/index.js';
import { tryExecute } from '../../../../../core/resources/index.js';
/**
 * Duplicate Document Server Data Source
 * @class UmbDuplicateMediaTypeServerDataSource
 */
export class UmbDuplicateMediaTypeServerDataSource {
    #host;
    /**
     * Creates an instance of UmbDuplicateMediaTypeServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbDuplicateMediaTypeServerDataSource
     */
    constructor(host) {
        this.#host = host;
    }
    /**
     * Duplicate an item for the given unique to the destination unique
     * @param {UmbDuplicateToRequestArgs} args
     * @returns {*}
     * @memberof UmbDuplicateMediaTypeServerDataSource
     */
    async duplicateTo(args) {
        if (!args.unique)
            throw new Error('Unique is missing');
        if (args.destination.unique === undefined)
            throw new Error('Destination unique is missing');
        return tryExecute(this.#host, MediaTypeService.postMediaTypeByIdCopy({
            path: { id: args.unique },
            body: {
                target: args.destination.unique ? { id: args.destination.unique } : null,
            },
        }));
    }
}
