import { jsx, jsxs } from "react/jsx-runtime";
import { ChevronDown, Maximize2, Redo2, Sparkles, Undo2 } from "lucide-react";
function ExpressionField({ label, value, mode = 'expr', description, onModeChange }) {
    const expression = value ?? '';
    const activeMode = mode;
    return /*#__PURE__*/ jsxs("div", {
        className: "flex flex-col gap-2",
        children: [
            label && /*#__PURE__*/ jsxs("div", {
                className: "flex items-center justify-between",
                children: [
                    /*#__PURE__*/ jsx("span", {
                        className: "text-xs font-medium text-foreground-muted",
                        children: label
                    }),
                    /*#__PURE__*/ jsxs("div", {
                        className: "flex items-center gap-0.5",
                        children: [
                            /*#__PURE__*/ jsx("button", {
                                type: "button",
                                title: "AI assist",
                                "aria-label": "AI assist",
                                className: "grid size-7 place-items-center rounded-lg text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground",
                                children: /*#__PURE__*/ jsx(Sparkles, {
                                    size: 12
                                })
                            }),
                            /*#__PURE__*/ jsxs("button", {
                                type: "button",
                                title: "Insert variable",
                                "aria-label": "Insert variable",
                                className: "flex h-7 items-center gap-1 rounded-lg px-2 text-[11px] text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground",
                                children: [
                                    /*#__PURE__*/ jsx("span", {
                                        className: "font-mono text-[10px]",
                                        children: '{x}'
                                    }),
                                    /*#__PURE__*/ jsx("span", {
                                        children: "Insert"
                                    }),
                                    /*#__PURE__*/ jsx(ChevronDown, {
                                        size: 9
                                    })
                                ]
                            })
                        ]
                    })
                ]
            }),
            /*#__PURE__*/ jsxs("div", {
                className: "overflow-hidden rounded-xl border border-border-subtle bg-surface-raised",
                children: [
                    /*#__PURE__*/ jsxs("div", {
                        className: "flex items-center justify-between border-b border-border-subtle bg-surface px-3 py-2",
                        children: [
                            /*#__PURE__*/ jsx("span", {
                                className: "font-mono text-xs text-foreground-muted",
                                children: "result"
                            }),
                            /*#__PURE__*/ jsx("button", {
                                type: "button",
                                title: "Expand editor",
                                "aria-label": "Expand editor",
                                className: "grid size-6 place-items-center rounded text-foreground-subtle transition hover:text-foreground",
                                children: /*#__PURE__*/ jsx(Maximize2, {
                                    size: 11
                                })
                            })
                        ]
                    }),
                    /*#__PURE__*/ jsxs("div", {
                        className: "flex items-center gap-1 border-b border-border-subtle bg-surface px-2.5 py-1.5",
                        children: [
                            /*#__PURE__*/ jsx("button", {
                                type: "button",
                                title: "Undo",
                                "aria-label": "Undo",
                                className: "grid size-6 place-items-center rounded text-foreground-subtle transition hover:text-foreground",
                                children: /*#__PURE__*/ jsx(Undo2, {
                                    size: 12
                                })
                            }),
                            /*#__PURE__*/ jsx("button", {
                                type: "button",
                                title: "Redo",
                                "aria-label": "Redo",
                                className: "grid size-6 place-items-center rounded text-foreground-subtle transition hover:text-foreground",
                                children: /*#__PURE__*/ jsx(Redo2, {
                                    size: 12
                                })
                            }),
                            /*#__PURE__*/ jsx("div", {
                                className: "mx-1 h-3 w-px shrink-0 bg-border-subtle"
                            }),
                            /*#__PURE__*/ jsx("button", {
                                type: "button",
                                onClick: ()=>onModeChange?.('expr'),
                                "aria-pressed": 'expr' === activeMode,
                                className: "rounded px-2 py-0.5 text-[11px] transition",
                                style: {
                                    color: 'expr' === activeMode ? 'var(--foreground)' : 'var(--foreground-subtle)',
                                    fontWeight: 'expr' === activeMode ? 600 : 400
                                },
                                children: "expr"
                            }),
                            /*#__PURE__*/ jsx("button", {
                                type: "button",
                                onClick: ()=>onModeChange?.('json'),
                                "aria-pressed": 'json' === activeMode,
                                className: "rounded px-2 py-0.5 text-[11px] transition",
                                style: {
                                    color: 'json' === activeMode ? 'var(--foreground)' : 'var(--foreground-subtle)',
                                    fontWeight: 'json' === activeMode ? 600 : 400
                                },
                                children: "json"
                            })
                        ]
                    }),
                    /*#__PURE__*/ jsx("pre", {
                        className: "overflow-auto whitespace-pre-wrap bg-surface-raised p-3 text-xs font-mono leading-5 text-foreground",
                        children: expression || '// Enter expression…'
                    }),
                    /*#__PURE__*/ jsxs("div", {
                        className: "flex items-center justify-between border-t border-border-subtle bg-surface px-3 py-1.5",
                        children: [
                            /*#__PURE__*/ jsxs("div", {
                                className: "flex items-center gap-1.5",
                                children: [
                                    /*#__PURE__*/ jsx("span", {
                                        className: "size-1.5 shrink-0 rounded-full bg-[--success]"
                                    }),
                                    /*#__PURE__*/ jsx("span", {
                                        className: "text-[10px] text-foreground-subtle",
                                        children: "No errors"
                                    })
                                ]
                            }),
                            /*#__PURE__*/ jsx("span", {
                                className: "text-[10px] text-foreground-subtle",
                                children: "Ln 1, Col 1"
                            })
                        ]
                    })
                ]
            }),
            description && /*#__PURE__*/ jsx("span", {
                className: "block text-[11px] leading-4 text-foreground-subtle",
                children: description
            })
        ]
    });
}
export { ExpressionField };
