import { nanoid } from "nanoid";
const regex = /@\[[^*]+?]\(([^*]+?)\)/gim;
export const filtrexToFormula = (filtrexString) => {
    const formulaInnerString = filtrexString.replaceAll(regex, (match, id) => `{{${id}}}`);
    return formulaInnerString.startsWith("=")
        ? `Filtrex(${JSON.stringify(formulaInnerString.slice(1))})`
        : `"${formulaInnerString}"`;
};
export const showConditionToConditionGroup = (condition) => Array.isArray(condition)
    ? {
        type: "all",
        conditions: condition.map((condition) => ({
            id: nanoid(),
            formula: `(${filtrexToFormula(condition.value)}) == (${filtrexToFormula(condition.equals)})`,
        })),
    }
    : condition;
//# sourceMappingURL=filtrexToFormula.js.map