"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 react_native_1 = require("react-native");
const bindables = {
    TextInput: {
        handler: 'onChange',
        getValue: (e) => e.nativeEvent.text,
        defaultValue: '',
    },
    Switch: { handler: 'onValueChange', getValue: (e) => e, defaultValue: false },
};
const Components = {
    ActivityIndicator: react_native_1.ActivityIndicator,
    Button: react_native_1.Button,
    FlatList: react_native_1.FlatList,
    Image: react_native_1.Image,
    Pressable: react_native_1.Pressable,
    ScrollView: react_native_1.ScrollView,
    SectionList: react_native_1.SectionList,
    Switch: react_native_1.Switch,
    Text: react_native_1.Text,
    TextInput: react_native_1.TextInput,
    TouchableWithoutFeedback: react_native_1.TouchableWithoutFeedback,
    View: react_native_1.View,
};
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)(Components[p], propsOut);
            });
            target[p] = (0, react_1.reactive)(render, bindables[p] &&
                {
                    value: bindables[p],
                });
        }
        return target[p];
    },
});
//# sourceMappingURL=rn-components.jsx.map