"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeDropListener = makeDropListener;
exports.listenDrop = listenDrop;
const _1 = require(".");
const pointer_1 = require("../pointer");
function makeDropListener(listener, _global = false) {
    return (component) => {
        return listenDrop(component, listener, _global);
    };
}
function listenDrop(component, listener, _global = false) {
    const { $element } = component;
    const dropListener = (_event) => {
        const { $context } = component;
        const { dataTransfer } = _event;
        const event = {
            ...(0, pointer_1.applyContextTransformToPointerEvent)($context, _event),
            dataTransfer: (0, _1.parseDataTransfer)(dataTransfer),
        };
        listener(event, _event);
    };
    $element.addEventListener('drop', dropListener, _global);
    return () => {
        $element.removeEventListener('drop', dropListener, _global);
    };
}
//# sourceMappingURL=drop.js.map