"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataTransferType = void 0;
exports.isFilesOnly = isFilesOnly;
exports.isFilesFromHtml = isFilesFromHtml;
exports.isImageFile = isImageFile;
exports.isVSCode = isVSCode;
exports.tryParseVSCodeData = tryParseVSCodeData;
exports.shouldSkipHtmlConversion = shouldSkipHtmlConversion;
/** Сontains all data formats known to us */
var DataTransferType;
(function (DataTransferType) {
    DataTransferType["Text"] = "text/plain";
    DataTransferType["Html"] = "text/html";
    DataTransferType["Yfm"] = "text/yfm";
    DataTransferType["Rtf"] = "text/rtf";
    DataTransferType["UriList"] = "text/uri-list";
    DataTransferType["VSCodeData"] = "vscode-editor-data";
    DataTransferType["Files"] = "Files";
})(DataTransferType || (exports.DataTransferType = DataTransferType = {}));
function isFilesOnly({ types }) {
    return types.length === 1 && types[0] === DataTransferType.Files;
}
function isFilesFromHtml({ types }) {
    return (types.length === 2 &&
        types.includes(DataTransferType.Files) &&
        types.includes(DataTransferType.Html));
}
function isImageFile(file) {
    return file.type.startsWith('image/');
}
function isVSCode(data) {
    return data.types.includes(DataTransferType.VSCodeData);
}
function tryParseVSCodeData(data) {
    try {
        return JSON.parse(data.getData(DataTransferType.VSCodeData));
    }
    catch (e) {
        console.error(e);
        return undefined;
    }
}
/**
 * Checks if HTML conversion should be skipped based on clipboard contents.
 */
function shouldSkipHtmlConversion(clipboardData) {
    const hasHtml = clipboardData.types.includes(DataTransferType.Html);
    // If there's no HTML content, skip conversion
    if (!hasHtml)
        return true;
    // Check for standard HTML clipboard (text/plain + text/html)
    if (clipboardData.types.length === 2)
        return false;
    // Check for WebStorm/Safari case (includes RTF)
    if (clipboardData.types.length === 3) {
        const rtf = clipboardData.getData(DataTransferType.Rtf);
        return rtf.indexOf('\fmodern JetBrains') > 0;
    }
    // Skip conversion for any other cases
    return true;
}
//# sourceMappingURL=clipboard.js.map
