"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __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__, {
    aggregate: ()=>aggregate,
    camelToKebab: ()=>camelToKebab,
    containsVisualElement: ()=>containsVisualElement,
    defer: ()=>defer,
    elementHasAncestorTag: ()=>elementHasAncestorTag,
    getFocusedElement: ()=>getFocusedElement,
    getParent: ()=>getParent,
    getRandomArbitrary: ()=>getRandomArbitrary,
    isAncestorOf: ()=>isAncestorOf,
    isElementNode: ()=>isElementNode,
    isFocusingOut: ()=>isFocusingOut,
    isInDocument: ()=>isInDocument,
    isPropValuesEqual: ()=>isPropValuesEqual,
    isTextNode: ()=>isTextNode,
    isVisualNode: ()=>isVisualNode,
    kebabToCamel: ()=>kebabToCamel,
    once: ()=>once,
    parseHTML: ()=>parseHTML,
    parseXML: ()=>parseXML,
    randomID: ()=>randomID,
    sanitizeStyle: ()=>sanitizeStyle,
    snakeToCamel: ()=>snakeToCamel,
    sortByDocumentPosition: ()=>sortByDocumentPosition,
    spreadProperties: ()=>spreadProperties,
    titleToKebab: ()=>titleToKebab
});
const external_dompurify_namespaceObject = require("dompurify");
var external_dompurify_default = /*#__PURE__*/ __webpack_require__.n(external_dompurify_namespaceObject);
function once(fn) {
    let result;
    let callable = fn;
    return function(...args) {
        if (callable) {
            result = callable.apply(this, args);
            callable = null;
        }
        return result;
    };
}
function camelToKebab(value) {
    return value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
}
function kebabToCamel(value) {
    return value.replace(/-./g, (x)=>x[1].toUpperCase());
}
function snakeToCamel(value) {
    return value.toLowerCase().replace(/([_][a-z])/g, (group)=>group.toUpperCase().replace('_', ''));
}
function titleToKebab(value) {
    return value.replace(/\s/g, '-').toLowerCase();
}
function randomID(prepend, length = 5) {
    const randomStr = Math.random().toString(36).substring(2, 2 + length);
    if (!prepend) return randomStr;
    return prepend + randomStr;
}
function getRandomArbitrary(min, max) {
    return Math.random() * (max - min) + min;
}
function parseXML(string) {
    return new window.DOMParser().parseFromString(string, 'text/xml');
}
function parseHTML(string) {
    return new window.DOMParser().parseFromString(string, 'text/html');
}
function isElementNode(node) {
    return node.nodeType === Node.ELEMENT_NODE;
}
function isTextNode(node) {
    return node.nodeType === Node.TEXT_NODE;
}
function isVisualNode(node) {
    if (isElementNode(node)) return !(node instanceof HTMLStyleElement);
    if (isTextNode(node)) return !!node.textContent?.trim();
    return false;
}
function containsVisualElement(node) {
    for(let i = 0; i < node.childNodes.length; i++){
        const child = node.childNodes.item(i);
        if (isVisualNode(child)) return true;
    }
    return false;
}
function elementHasAncestorTag(el, tagName) {
    const parentElement = el.parentElement;
    if (!parentElement) return false;
    if (parentElement.tagName === tagName.toUpperCase()) return true;
    return elementHasAncestorTag(parentElement, tagName);
}
function sanitizeStyle(style) {
    const purifiedOuterHTML = external_dompurify_default().sanitize(`<style>${style}</style>`, {
        ALLOWED_TAGS: [
            'style'
        ],
        ALLOWED_ATTR: [],
        FORCE_BODY: true
    });
    const wrapperEl = document.createElement('div');
    wrapperEl.innerHTML = purifiedOuterHTML;
    return wrapperEl.querySelector('style')?.innerHTML;
}
function getFocusedElement(rootElement = document) {
    const activeElement = rootElement.activeElement;
    if (activeElement?.shadowRoot) return getFocusedElement(activeElement.shadowRoot) ?? activeElement;
    return activeElement;
}
function isFocusingOut(event) {
    return document.hasFocus() && (!(event.relatedTarget instanceof Node) || event.currentTarget instanceof Node && !event.currentTarget.contains(event.relatedTarget));
}
function isInDocument(element) {
    let currentElement = element;
    while(currentElement?.parentNode)if (currentElement.parentNode === document) return true;
    else currentElement = currentElement.parentNode instanceof ShadowRoot ? currentElement.parentNode.host : currentElement.parentNode;
    return false;
}
function isPropValuesEqual(subject, target, propNames) {
    return propNames.every((propName)=>subject[propName] === target[propName]);
}
function getParent(element) {
    if (element.parentNode) return element.parentNode;
    if (element instanceof ShadowRoot) return element.host;
    return null;
}
function isAncestorOf(ancestor, element) {
    if (element === ancestor) return true;
    if (element instanceof HTMLElement && element.assignedSlot && isAncestorOf(ancestor, element.assignedSlot)) return true;
    const parent = getParent(element);
    return null === parent ? false : isAncestorOf(ancestor, parent);
}
function aggregate(values, getKey) {
    return values.reduce((aggregatedValues, value, i)=>{
        const key = getKey(value, i);
        if (!(key in aggregatedValues)) aggregatedValues[key] = [];
        aggregatedValues[key].push(value);
        return aggregatedValues;
    }, {});
}
function spreadProperties(...objects) {
    const returnObject = {};
    for (const obj of objects)Object.defineProperties(returnObject, Object.getOwnPropertyDescriptors(obj));
    return returnObject;
}
const sortByDocumentPosition = (a, b)=>a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
async function defer() {
    return new Promise((resolve)=>setTimeout(resolve, 10));
}
exports.aggregate = __webpack_exports__.aggregate;
exports.camelToKebab = __webpack_exports__.camelToKebab;
exports.containsVisualElement = __webpack_exports__.containsVisualElement;
exports.defer = __webpack_exports__.defer;
exports.elementHasAncestorTag = __webpack_exports__.elementHasAncestorTag;
exports.getFocusedElement = __webpack_exports__.getFocusedElement;
exports.getParent = __webpack_exports__.getParent;
exports.getRandomArbitrary = __webpack_exports__.getRandomArbitrary;
exports.isAncestorOf = __webpack_exports__.isAncestorOf;
exports.isElementNode = __webpack_exports__.isElementNode;
exports.isFocusingOut = __webpack_exports__.isFocusingOut;
exports.isInDocument = __webpack_exports__.isInDocument;
exports.isPropValuesEqual = __webpack_exports__.isPropValuesEqual;
exports.isTextNode = __webpack_exports__.isTextNode;
exports.isVisualNode = __webpack_exports__.isVisualNode;
exports.kebabToCamel = __webpack_exports__.kebabToCamel;
exports.once = __webpack_exports__.once;
exports.parseHTML = __webpack_exports__.parseHTML;
exports.parseXML = __webpack_exports__.parseXML;
exports.randomID = __webpack_exports__.randomID;
exports.sanitizeStyle = __webpack_exports__.sanitizeStyle;
exports.snakeToCamel = __webpack_exports__.snakeToCamel;
exports.sortByDocumentPosition = __webpack_exports__.sortByDocumentPosition;
exports.spreadProperties = __webpack_exports__.spreadProperties;
exports.titleToKebab = __webpack_exports__.titleToKebab;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "aggregate",
    "camelToKebab",
    "containsVisualElement",
    "defer",
    "elementHasAncestorTag",
    "getFocusedElement",
    "getParent",
    "getRandomArbitrary",
    "isAncestorOf",
    "isElementNode",
    "isFocusingOut",
    "isInDocument",
    "isPropValuesEqual",
    "isTextNode",
    "isVisualNode",
    "kebabToCamel",
    "once",
    "parseHTML",
    "parseXML",
    "randomID",
    "sanitizeStyle",
    "snakeToCamel",
    "sortByDocumentPosition",
    "spreadProperties",
    "titleToKebab"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
