"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    MissingInterfaceParentError: ()=>MissingInterfaceParentError,
    fetchBindings: ()=>fetchBindings,
    initializeEventName: ()=>initializeEventName,
    waitForAtomicChildrenToBeDefined: ()=>waitForAtomicChildrenToBeDefined
});
const external_custom_element_tags_cjs_namespaceObject = require("./custom-element-tags.cjs");
const external_dom_utils_cjs_namespaceObject = require("./dom-utils.cjs");
const external_event_utils_cjs_namespaceObject = require("./event-utils.cjs");
const external_init_queue_cjs_namespaceObject = require("./init-queue.cjs");
function fetchBindings(element) {
    return new Promise((resolve, reject)=>{
        const event = (0, external_event_utils_cjs_namespaceObject.buildCustomEvent)(initializeEventName, (bindings)=>resolve(bindings));
        const parent = (0, external_dom_utils_cjs_namespaceObject.closest)(element, initializableElements.join(', '));
        if (!parent) return void reject(new MissingInterfaceParentError(element.nodeName.toLowerCase()));
        (0, external_init_queue_cjs_namespaceObject.enqueueOrDispatchInitializationEvent)(parent, event, element);
    });
}
class MissingInterfaceParentError extends Error {
    constructor(elementName){
        super(`The "${elementName}" element must be the child of the following elements: ${initializableElements.join(', ')}`);
    }
}
const initializableElements = [
    'atomic-recs-interface',
    'atomic-search-interface',
    'atomic-commerce-interface',
    'atomic-commerce-recommendation-interface',
    'atomic-relevance-inspector',
    'atomic-insight-interface',
    'atomic-external'
];
const initializeEventName = 'atomic/initializeComponent';
async function waitForAtomicChildrenToBeDefined(host) {
    await Promise.all(Array.from(host.querySelectorAll('*')).filter((el)=>external_custom_element_tags_cjs_namespaceObject.ATOMIC_CUSTOM_ELEMENT_TAGS.has(el.tagName.toLowerCase())).map((el)=>customElements.whenDefined(el.tagName.toLowerCase())));
}
exports.MissingInterfaceParentError = __webpack_exports__.MissingInterfaceParentError;
exports.fetchBindings = __webpack_exports__.fetchBindings;
exports.initializeEventName = __webpack_exports__.initializeEventName;
exports.waitForAtomicChildrenToBeDefined = __webpack_exports__.waitForAtomicChildrenToBeDefined;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "MissingInterfaceParentError",
    "fetchBindings",
    "initializeEventName",
    "waitForAtomicChildrenToBeDefined"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
