import { EventTypes } from './EventTypes.js';
export default {
    /**
     * Dispatches a domain rename event. Called when a domain element is renamed.
     *
     * @param key The key of the domain element that was renamed.
     * @param namespace The domain namespace key.
     * @param kind The domain element kind.
     * @param name The new name.
     * @param target Event dispatch target.
     */
    rename: (key, namespace, kind, name, target = document.body) => {
        const detail = {
            key,
            label: name,
            namespace,
            kind,
        };
        const e = new CustomEvent(EventTypes.Domain.rename, {
            bubbles: true,
            composed: true,
            cancelable: true,
            detail,
        });
        target.dispatchEvent(e);
    },
    Browse: {
        /**
         * Dispatches an event to request recent items from the data domain.
         * @param domain The key of the data domain to request items for.
         * @param allowed Optional list of allowed items to filter the results for.
         * @param target The event target.
         */
        recent: async (domain, allowed, target = document.body) => {
            const e = new CustomEvent(EventTypes.Domain.Browse.recent, {
                bubbles: true,
                composed: true,
                detail: {
                    domain,
                    allowed,
                },
            });
            target.dispatchEvent(e);
            const result = await e.detail.result;
            return result;
        },
        /**
         * Dispatches an event to open the domain browser.
         * @param init The domain browse initialization data.
         * @param target The event target.
         * @returns The domain browse result, or undefined if the event was not handled.
         */
        browse: async (init, target = document.body) => {
            const e = new CustomEvent(EventTypes.Domain.Browse.browse, {
                bubbles: true,
                composed: true,
                detail: init,
            });
            target.dispatchEvent(e);
            const result = await e.detail.result;
            return result;
        },
    },
};
//# sourceMappingURL=DomainEvents.js.map