"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readDataTransferItemAsText = exports.parseDataTransferItems = exports.parseDataTransfer = void 0;
const parseDataTransfer = (dataTransfer) => {
    const { dropEffect, effectAllowed, files, items, types } = dataTransfer;
    return {
        dropEffect,
        effectAllowed,
        files,
        items: (0, exports.parseDataTransferItems)(items),
        types: [...types],
    };
};
exports.parseDataTransfer = parseDataTransfer;
const parseDataTransferItems = (items) => {
    const result = [];
    for (let i = 0; i < items.length; i++) {
        const item = items[i];
        const { kind, type } = item;
        result.push({ kind, type });
    }
    return result;
};
exports.parseDataTransferItems = parseDataTransferItems;
const readDataTransferItemAsText = (dataTransferItem) => {
    return new Promise((resolve, reject) => {
        if (dataTransferItem.kind === 'file') {
            const file = dataTransferItem.getAsFile();
            resolve(file.text());
            return;
        }
        else {
            dataTransferItem.getAsString(resolve);
        }
    });
};
exports.readDataTransferItemAsText = readDataTransferItemAsText;
//# sourceMappingURL=index.js.map