"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Legend = void 0;
const state_1 = require("@legendapp/state");
const react_1 = require("@legendapp/state/react");
const react_2 = require("react");
const bindables = new Set(['input', 'textarea', 'select']);
const bindInfo = { value: { handler: 'onChange', getValue: (e) => e.target.value, defaultValue: '' } };
const bindInfoInput = Object.assign({ checked: { handler: 'onChange', getValue: (e) => e.target.checked } }, bindInfo);
exports.Legend = new Proxy({}, {
    get(target, p) {
        if (!target[p]) {
            // Create a wrapper around createElement with the string so we can proxy it
            // eslint-disable-next-line react/display-name
            const render = (0, react_2.forwardRef)((props, ref) => {
                const propsOut = { ...props };
                if (ref && ((0, state_1.isFunction)(ref) || !(0, state_1.isEmpty)(ref))) {
                    propsOut.ref = ref;
                }
                return (0, react_2.createElement)(p, propsOut);
            });
            target[p] = (0, react_1.reactive)(render, bindables.has(p) ? (p === 'input' ? bindInfoInput : bindInfo) : undefined);
        }
        return target[p];
    },
});
//# sourceMappingURL=react-components.jsx.map