import { Arr, Strings, Type } from '@ephox/katamari';
const setData = (transfer, types, data) => {
    transfer.items.clear();
    Arr.each(types, (type) => {
        transfer.items.add(data, type);
    });
};
const getData = (transfer, type) => {
    const data = transfer.getData(type);
    // IE 11 will return null on drag/drop of files
    return Type.isNull(data) ? '' : data;
};
const setDragImage = (transfer, image, x, y) => {
    transfer.setDragImage(image, x, y);
};
const setDropEffect = (transfer, effect) => {
    transfer.dropEffect = effect;
};
const setEffectAllowed = (transfer, effect) => {
    transfer.effectAllowed = effect;
};
const getFiles = (transfer) => Arr.from(transfer.files);
// IE 11 and Edge doesn't seem to support effectAllow properly the drop event fires even if it shouldn't, so we need to manually check as well
const isValidDrop = (transfer) => {
    const effectAllowed = transfer.effectAllowed.toLowerCase();
    const dropEffect = transfer.dropEffect.toLowerCase();
    return effectAllowed === 'all' || effectAllowed === 'uninitialized' || Strings.contains(effectAllowed, dropEffect);
};
const getDataTransferFromEvent = (simulatedEvent) => {
    const rawEvent = simulatedEvent.event.raw;
    // TODO: Should this handle if dataTransfer is null?
    return rawEvent.dataTransfer;
};
const setDropEffectOnEvent = (simulatedEvent, dropEffect) => {
    setDropEffect(getDataTransferFromEvent(simulatedEvent), dropEffect);
};
export { setData, getData, setDragImage, setDropEffect, setEffectAllowed, getFiles, isValidDrop, getDataTransferFromEvent, setDropEffectOnEvent };
//# sourceMappingURL=DataTransfers.js.map