export const parseRRuleConfig = (rawConfig: NCoreUIKit.GeneratedRRuleConfigsForReturn) => {
    const tokens: {
        [key: string]: RegExp;
    } = {
    };

    Object.keys(rawConfig.tokens).forEach((key) => {
        let pattern = rawConfig.tokens[key as keyof typeof rawConfig.tokens];
        let flags = "";

        if (pattern.endsWith("/i")) {
            pattern = pattern.slice(0, -2).replace(/^\^?/, "^");
            flags = "i";
        }

        if (pattern.startsWith("/") && pattern.endsWith("/")) {
            pattern = pattern.slice(1, -1);
        }

        tokens[key] = new RegExp(pattern, flags);
    });

    return {
        monthNames: rawConfig.monthNames,
        dayNames: rawConfig.dayNames,
        tokens: tokens
    };
};
