export class Post {
    componentDidLoad() {
        this.postRender();
    }
    componentDidUpdate() {
        this.postRender();
    }
    postRender() {
        let titleField = this.el.querySelector('.field--name-title');
        let bodyField = this.el.querySelector('.field--name-content');
        if (this.data.title)
            titleField.innerHTML = this.data.title.rendered;
        if (this.data.content) {
            bodyField.innerHTML = this.data.content.rendered;
        }
        else {
            bodyField.innerHTML = '';
        }
    }
    parsePost(post) {
        return post;
    }
    render() {
        if (this.dataJson) {
            var post = this.parsePost(JSON.parse(this.dataJson));
            this.data = post;
        }
        return (h("article", { class: 'post post-type-' + post.type + ' clearfix', id: 'post-' + post.id },
            h("header", null,
                h("h2", { class: "field field--name-title" })),
            h("div", { class: "content clearfix" },
                h("div", { class: "field field--name-content" }),
                post.type == 'iframe' && post.url &&
                    h("div", { class: "field field--name-url" },
                        h("ema-iframe", { src: post.url, width: post.width, height: post.height })))));
    }
    static get is() { return "ema-post"; }
    static get properties() { return {
        "data": {
            "state": true
        },
        "dataJson": {
            "type": String,
            "attr": "data-json"
        },
        "el": {
            "elementRef": true
        }
    }; }
    static get style() { return "/**style-placeholder:ema-post:**/"; }
}
