"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__, {
    mapAttributesToProp: ()=>mapAttributesToProp,
    mapProperty: ()=>mapProperty
});
const external_utils_cjs_namespaceObject = require("./utils.cjs");
function mapProperty(options) {
    return (proto, propertyKey)=>{
        const ctor = proto.constructor;
        ctor.createProperty(propertyKey, {
            type: Object
        });
        ctor.addInitializer((instance)=>{
            const props = {};
            const prefix = options?.attributePrefix || (0, external_utils_cjs_namespaceObject.camelToKebab)(propertyKey.toString());
            mapAttributesToProp(prefix, props, Array.from(instance.attributes), options?.splitValues ?? false);
            instance[propertyKey] = props;
        });
    };
}
function splitAttributeValueOnCommas(attributeValue) {
    const splitButIgnoreEscapeSymbolsExpression = /(?:\\.|[^,])+/g;
    const [...valuesWithEscapeSymbols] = attributeValue.matchAll(splitButIgnoreEscapeSymbolsExpression) ?? [];
    const removeEscapeSymbolsExpression = /\\(.)/g;
    return valuesWithEscapeSymbols.map(([valuesWithEscapeSymbols])=>valuesWithEscapeSymbols.replace(removeEscapeSymbolsExpression, '$1'));
}
function mapAttributesToProp(prefix, mapVariable, attributes, splitValues) {
    const map = attributesToStringMap(prefix, attributes);
    Object.assign(mapVariable, splitValues ? stringMapToStringArrayMap(map) : map);
}
function stringMapToStringArrayMap(map) {
    return Object.entries(map).reduce((acc, [key, value])=>({
            ...acc,
            [key]: splitAttributeValueOnCommas(value).map((subValue)=>subValue.trim())
        }), {});
}
function attributesToStringMap(prefix, attributes) {
    const mapVariable = {};
    const kebabPrefix = `${(0, external_utils_cjs_namespaceObject.camelToKebab)(prefix)}-`;
    for(let i = 0; i < attributes.length; i++){
        const attribute = attributes[i];
        if (0 !== attribute.name.indexOf(kebabPrefix)) continue;
        const property = (0, external_utils_cjs_namespaceObject.kebabToCamel)(attribute.name.replace(kebabPrefix, ''));
        mapVariable[property] = `${attribute.value}`;
    }
    return mapVariable;
}
exports.mapAttributesToProp = __webpack_exports__.mapAttributesToProp;
exports.mapProperty = __webpack_exports__.mapProperty;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "mapAttributesToProp",
    "mapProperty"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
