"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__, {
    createRipple: ()=>createRipple
});
const external_event_utils_cjs_namespaceObject = require("./event-utils.cjs");
const RIPPLE = 'ripple';
function getAnimationDurationInMilliseconds(radiusPixels) {
    return 129.21 * Math.cbrt(radiusPixels);
}
function setPositionRelativeIfStatic(element) {
    if ('static' === getComputedStyle(element).position) element.classList.add('ripple-relative');
}
async function createRipple(event, options) {
    const button = options.parent ?? event.currentTarget;
    const existingRipple = button.getElementsByClassName(RIPPLE)[0];
    existingRipple?.remove();
    button.classList.add('ripple-parent');
    setPositionRelativeIfStatic(button);
    Array.from(button.children).forEach(setPositionRelativeIfStatic);
    const ripple = document.createElement('span');
    ripple.classList.add(RIPPLE);
    ripple.style.backgroundColor = `var(--atomic-${options.color})`;
    ripple.setAttribute('part', RIPPLE);
    const diameter = Math.max(button.clientWidth, button.clientHeight);
    const radius = diameter / 2;
    const animationDuration = getAnimationDurationInMilliseconds(radius);
    const { top, left } = button.getBoundingClientRect();
    ripple.style.width = ripple.style.height = `${diameter}px`;
    ripple.style.left = `${event.clientX - (left + radius)}px`;
    ripple.style.top = `${event.clientY - (top + radius)}px`;
    ripple.style.setProperty('--animation-duration', `${animationDuration}ms`);
    button.prepend(ripple);
    await cleanupAnimationOnFinish(ripple, animationDuration);
}
async function cleanupAnimationOnFinish(ripple, animationDuration) {
    (0, external_event_utils_cjs_namespaceObject.listenOnce)(ripple, 'animationend', ()=>{
        ripple?.remove();
    });
    setTimeout(()=>ripple?.remove(), animationDuration + 0.1 * animationDuration);
}
exports.createRipple = __webpack_exports__.createRipple;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "createRipple"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
