var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { css, html } from 'lit';
import { customElement, query } from 'lit/decorators.js';
import { EmbedBlockElement } from '../_common/embed-block-helper/index.js';
let EmbedHtmlBlock = class EmbedHtmlBlock extends EmbedBlockElement {
    constructor() {
        super(...arguments);
        this.updateWH = () => {
            const [, , w, h] = JSON.parse(this.model.xywh);
            this.iframe.style.width = `${w}px`;
            this.iframe.style.height = `${h}px`;
        };
    }
    connectedCallback() {
        super.connectedCallback();
        this.disposables.add(this.model.propsUpdated.on(this.updateWH));
    }
    firstUpdated(_changedProperties) {
        super.firstUpdated(_changedProperties);
        this.updateWH();
    }
    render() {
        return this.renderEmbed(() => {
            if (!this.model.html) {
                return html ` <div class="affine-html-empty">Empty</div>`;
            }
            return html `<iframe
        class="embed-html-block-iframe"
        sandbox="allow-scripts"
        scrolling="false"
        .srcdoc="${this.model.html}"
      ></iframe>`;
        });
    }
};
EmbedHtmlBlock.styles = css `
    //affine-html {
    //  display: block;
    //}
    //
    .embed-html-block-iframe {
      border: none;
      width: 100%;
    }
  `;
__decorate([
    query('.embed-html-block-iframe')
], EmbedHtmlBlock.prototype, "iframe", void 0);
EmbedHtmlBlock = __decorate([
    customElement('affine-embed-html-block')
], EmbedHtmlBlock);
export { EmbedHtmlBlock };
//# sourceMappingURL=embed-html-block.js.map