import React, { useEffect } from "react";
import { Text, Input, Box } from "@chakra-ui/react";
import { useQueryString } from "@strata-foundation/react";
import { useVariablesContext } from "../../theme/Root/variables";
export function QueryStringSetter({ name, label, conv = (v) => v, }) {
    const [passedValue, setPassedValue] = useQueryString(name, "");
    const { setVariables, variables } = useVariablesContext();
    useEffect(() => {
        setVariables((vars) => {
            try {
                return {
                    ...vars,
                    [name]: conv(passedValue),
                    [name + "Raw"]: passedValue,
                };
            }
            catch (e) {
                console.error(e);
            }
        });
    }, [passedValue, setVariables]);
    return (React.createElement(Box, { p: 1 },
        React.createElement(Text, { fontWeight: "bold" }, label),
        React.createElement(Input, { onChange: (e) => setPassedValue(e.target.value), value: passedValue })));
}
//# sourceMappingURL=index.js.map