import { tryExecute } from '../../../../core/resources/index.js';
import { DocumentService, PreviewService } from '../../../../core/backend-api/index.js';
import { UmbDeprecation } from '../../../../core/utils/index.js';
import { UmbRepositoryBase } from '../../../../core/repository/index.js';
/** @deprecated This has been deprecated, please use `UmbPreviewRepository` instead. To be removed in Umbraco 19. [LK] */
export class UmbDocumentPreviewRepository extends UmbRepositoryBase {
    constructor(host) {
        super(host);
    }
    /**
     * Gets the preview URL for a document.
     * @param {string} unique The unique identifier of the document.
     * @param {string} providerAlias The alias of the URL provider registered on the server.
     * @param {string | undefined} culture The culture to preview (undefined means invariant).
     * @param {string | undefined} segment The segment to preview (undefined means no specific segment).
     * @returns {DocumentUrlInfoModel} The preview URLs of the document.
     */
    async getPreviewUrl(unique, providerAlias, culture, segment) {
        new UmbDeprecation({
            removeInVersion: '19.0.0',
            deprecated: '`UmbDocumentPreviewRepository.getPreviewUrl()`',
            solution: 'Use `UmbPreviewRepository.getPreviewUrl()` instead',
        }).warn();
        const { data, error } = await tryExecute(this, DocumentService.getDocumentByIdPreviewUrl({
            path: { id: unique },
            query: { providerAlias, culture, segment },
        }));
        if (error) {
            throw new Error(error.message);
        }
        return data;
    }
    /**
     * Enters preview mode.
     * @returns {Promise<void>}
     * @memberof UmbDocumentPreviewRepository
     * @deprecated Replaced with the Document Preview URLs feature. This will be removed in v19. [LK]
     */
    async enter() {
        new UmbDeprecation({
            removeInVersion: '19.0.0',
            deprecated: '`UmbDocumentPreviewRepository.enter()`',
            solution: 'Use `UmbDocumentPreviewRepository.getPreviewUrl()` instead',
        }).warn();
        await tryExecute(this, PreviewService.postPreview(), { disableNotifications: true });
        return;
    }
    /**
     * Exits preview mode.
     * @returns {Promise<void>}
     * @memberof UmbDocumentPreviewRepository
     */
    async exit() {
        new UmbDeprecation({
            removeInVersion: '19.0.0',
            deprecated: '`UmbDocumentPreviewRepository.exit()`',
            solution: 'Use `UmbPreviewRepository.exit()` instead',
        }).warn();
        await tryExecute(this, PreviewService.deletePreview(), { disableNotifications: true });
        return;
    }
}
