import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { toWords } from 'payload/shared';
import React from 'react';
/** @todo: improve this */ const transformWhereToNaturalLanguage = (where)=>{
    if (where.or && where.or.length > 0 && where.or[0].and && where.or[0].and.length > 0) {
        const orQuery = where.or[0];
        const andQuery = orQuery?.and?.[0];
        if (!andQuery || typeof andQuery !== 'object') {
            return 'No where query';
        }
        const key = Object.keys(andQuery)[0];
        if (!key || !andQuery[key] || typeof andQuery[key] !== 'object') {
            return 'No where query';
        }
        const operator = Object.keys(andQuery[key])[0];
        const value = andQuery[key][operator];
        if (typeof value === 'string') {
            return `${toWords(key)} ${operator} ${toWords(value)}`;
        } else if (Array.isArray(value)) {
            return `${toWords(key)} ${operator} ${value.map((val)=>toWords(val)).join(' or ')}`;
        }
    }
    return '';
};
export const QueryPresetsWhereCell = ({ cellData })=>{
    return /*#__PURE__*/ _jsxDEV("div", {
        children: cellData ? transformWhereToNaturalLanguage(cellData) : 'No where query'
    }, void 0, false, {
        fileName: "src/elements/QueryPresets/cells/WhereCell/index.tsx",
        lineNumber: 36,
        columnNumber: 10
    }, this);
};

//# sourceMappingURL=index.js.map