export class DrupalNode {
    componentDidLoad() {
        this.postRender();
    }
    componentDidUpdate() {
        this.postRender();
    }
    postRender() {
        let bodyField = this.el.querySelector('.field--name-body');
        if (this.data.attributes.body) {
            bodyField.innerHTML = this.data.attributes.body.value;
        }
        else {
            bodyField.innerHTML = '';
        }
    }
    parseNode(node) {
        let type = node.type.split('--')[1];
        switch (type) {
            case 'page':
                break;
            case 'app':
                break;
            case 'iframe':
                break;
            default:
        }
        return node;
    }
    render() {
        let data;
        if (this.dataJson) {
            data = this.data = this.parseNode(JSON.parse(this.dataJson).data);
        }
        return (h("article", { id: 'node-' + data.attributes.nid, class: 'node node--type-' + data.type.split('--')[1] + ' node--view-mode-full clearfix' },
            h("header", null,
                h("h2", { class: "title node__title" }, data.attributes.title)),
            h("div", { class: "node__content clearfix" },
                h("div", { class: "field field--name-body" }),
                data.attributes.field_iframe &&
                    h("div", { class: "field field--name-iframe" },
                        h("ema-iframe", { src: data.attributes.field_iframe.uri, width: data.attributes.field_width, height: data.attributes.field_height })))));
    }
    static get is() { return "ema-drupal-node"; }
    static get properties() { return {
        "data": {
            "state": true
        },
        "dataJson": {
            "type": String,
            "attr": "data-json"
        },
        "el": {
            "elementRef": true
        }
    }; }
    static get style() { return "/**style-placeholder:ema-drupal-node:**/"; }
}
