import { Component, h, Prop } from "@stencil/core";
import state from "../../../store";
export class TemplateBlock {
  constructor() {
    this.zoom = 1;
    this.resize = false;
    this.allowFullscreen = false;
    this.disablePositioning = false;
  }
  componentDidLoad() {
    if (!this.disablePositioning)
      return;
    const renderWrapperEl = this.templateEl.shadowRoot.querySelector(".render-wrapper");
    if (renderWrapperEl)
      renderWrapperEl.style.position = "relative";
  }
  render() {
    var _a, _b;
    const template = this.template ||
      ((_b = (_a = state === null || state === void 0 ? void 0 : state.templates) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, (template) => (template === null || template === void 0 ? void 0 : template.id) === this.templateId));
    const helpers = this.helpers || (state === null || state === void 0 ? void 0 : state.helpers) || {};
    const partials = (this.partials || (state === null || state === void 0 ? void 0 : state.templates) || [])
      .filter((template) => !!(template === null || template === void 0 ? void 0 : template.partial))
      .map((partial) => ({
      html: (partial === null || partial === void 0 ? void 0 : partial.html) || "",
      id: (partial === null || partial === void 0 ? void 0 : partial.id) || null,
    }));
    return (h("fireenjin-render-template", { ref: (el) => (this.templateEl = el), disableFrame: true, template: template, templateId: this.templateId, data: this.data, helpers: helpers, partials: partials, zoom: this.zoom, allowFullscreen: this.allowFullscreen, resize: this.resize, rawHtml: this.rawHtml }));
  }
  static get is() { return "floodteam-template"; }
  static get properties() { return {
    "templateId": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "template-id",
      "reflect": false
    },
    "template": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Template",
        "resolved": "{ __typename?: \"Template\"; amp?: string; attachments?: Attachment[]; createdAt?: string; createdBy?: User; description?: string; editor?: Editor; footer?: Template; frame?: Template; head?: string; header?: Template; html?: string; id?: string; name?: string; partial?: boolean; routes?: any; sampleData?: any; subject?: string; tags?: string[]; text?: string; type?: string; updatedAt?: string; updatedBy?: User; }",
        "references": {
          "Template": {
            "location": "import",
            "path": "../../../sdk"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "partials": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Template[]",
        "resolved": "Template[]",
        "references": {
          "Template": {
            "location": "import",
            "path": "../../../sdk"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "data": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "data",
      "reflect": false
    },
    "helpers": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "helpers",
      "reflect": false
    },
    "zoom": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "zoom",
      "reflect": false,
      "defaultValue": "1"
    },
    "resize": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "resize",
      "reflect": false,
      "defaultValue": "false"
    },
    "allowFullscreen": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "allow-fullscreen",
      "reflect": false,
      "defaultValue": "false"
    },
    "rawHtml": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "raw-html",
      "reflect": false
    },
    "disablePositioning": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "disable-positioning",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
}
//# sourceMappingURL=template.js.map