import { r as registerInstance, h, g as getElement } from './chunk-82a2445c.js';
var Post = /** @class */ (function () {
    function Post(hostRef) {
        registerInstance(this, hostRef);
    }
    Post.prototype.componentDidLoad = function () {
        this.postRender();
    };
    Post.prototype.componentDidUpdate = function () {
        this.postRender();
    };
    Post.prototype.postRender = function () {
        var titleField = this.el.querySelector('.field--name-title');
        var 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 = '';
        }
    };
    Post.prototype.parsePost = function (post) {
        //console.log(post);
        // let type = post.type.split('--')[1];
        // switch (type) {
        //     case 'app':
        //         // this.postData = JSON.parse(post.field_json[0].value);
        //         break;
        //     case 'iframe':
        //         // code block
        //         break;
        //     case 'page':
        //         // code block
        //         break;
        //     default:
        //     // code block
        // }
        return post;
    };
    Post.prototype.render = function () {
        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 })))));
    };
    Object.defineProperty(Post.prototype, "el", {
        get: function () { return getElement(this); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Post, "style", {
        get: function () { return ":root{--ema-color:#343a40;--ema-primary:#007bff;--ema-secondary:#6c757d;--ema-success:#28a745;--ema-info:#17a2b8;--ema-warning:#ffc107;--ema-danger:#dc3545;--ema-light:#f8f9fa;--ema-dark:#343a40;--ema-background:#fff;--ema-background-diap:rgba(29,29,29,0.97);--ema-border-color:#c5c9cd;--ema-border:1px solid #c5c9cd;--ema-border-radius:3px 3px 3px 3px;--ema-box-shadow:1px 1px 10px 1px #ccc;--ema-margin:0.25rem;--ema-margin-sm:0.5rem;--ema-margin-md:1rem;--ema-margin-lg:1.5rem;--ema-margin-xl:2rem;--ema-padding:0.25rem;--ema-padding-sm:0.5rem;--ema-padding-md:1rem;--ema-padding-lg:1.5rem;--ema-padding-xl:2rem;--ema-gray-100:#f8f9fa;--ema-gray-200:#e9ecef;--ema-gray-300:#dee2e6;--ema-gray-400:#ced4da;--ema-gray-500:#adb5bd;--ema-gray-600:#868e96;--ema-gray-700:#495057;--ema-gray-800:#343a40;--ema-gray-900:#212529}ema-post .node .field{margin-bottom:var(--ema-padding-md,1rem)}"; },
        enumerable: true,
        configurable: true
    });
    return Post;
}());
export { Post as ema_post };
