"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const transpile_1 = require("../../transpile");
const utils_1 = require("../utils");
const capitalize = (str) => {
    return str ? str.split('-')
        .map(s => s.charAt(0).toUpperCase() + s.substring(1))
        .join('') : str;
};
exports.default = {
    pre: (element, context) => {
        const widgetname = capitalize(element.getAttribute('widgetname'));
        Object.keys(element.attributes)
            .map(name => {
            if (name.startsWith('prop-')) {
                const value = element.getAttribute(name);
                if (value) {
                    element.setAttribute(name.substring('prop-'.length), value);
                }
            }
        });
        return `<Wm${widgetname} ${(0, transpile_1.transformAttrs)(element, context, utils_1.inferTypeAndParseProperty)}  themeToUse={fragment.theme} parentWatcher={fragment.watcher}>`;
    },
    post: (element, context) => {
        const widgetname = capitalize(element.getAttribute('widgetname'));
        return `</Wm${widgetname}>`;
    },
    imports: (element, context) => {
        const widgetname = element.getAttribute('widgetname');
        const imports = [{ name: '* as ReactNative', from: 'react-native' }];
        imports.push({ name: 'Wm' + capitalize(widgetname), from: `../../custom-widgets/${widgetname}/${widgetname}.component` });
        return imports;
    },
    createComponent: (element, context) => (0, transpile_1.createComponent)(element, context),
    customWidgets: (element, context) => [element.getAttribute('widgetname')]
};
//# sourceMappingURL=customwidget.transformer.js.map