"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const element_1 = require("../../../../client/element");
const parentElement_1 = require("../../../../client/platform/web/parentElement");
const parser_1 = require("../../../../spec/parser");
const stringify_1 = require("../../../../spec/stringify");
const Component_1 = require("../app/Datum/Component");
class _Datum extends element_1.Element {
    constructor($props, $system) {
        super($props, $system);
        const { style, value = '' } = this.$props;
        const data = (0, parser_1.getTree)(value);
        const datum = new Component_1.default({
            style,
            data,
        }, this.$system);
        this._datum = datum;
        const $element = (0, parentElement_1.default)($system);
        this.$element = $element;
        this.$subComponent = {
            datum,
        };
        this.$unbundled = false;
        this.appendRoot(datum);
    }
    onPropChanged(prop, current) {
        if (prop === 'value') {
            if (current) {
                const _value = (0, stringify_1.stringify)(current);
                const data = (0, parser_1.getTree)(_value);
                this._datum.setProp('data', data);
            }
            else {
                this._datum.setProp('data', (0, parser_1.getTree)(''));
            }
        }
        else if (prop === 'style') {
            this._datum.setProp('style', current);
        }
    }
}
exports.default = _Datum;
//# sourceMappingURL=Component.js.map