import { h } from "@stencil/core";
import state from "../../../store";
export class TemplateBlock {
  constructor() {
    this.templateId = undefined;
    this.template = undefined;
    this.partials = undefined;
    this.data = undefined;
    this.helpers = undefined;
    this.zoom = 1;
    this.resize = false;
    this.allowFullscreen = false;
    this.rawHtml = undefined;
    this.disablePosition = false;
    this.disableFrame = false;
  }
  componentDidLoad() {
    try {
      this.templateEl.shadowRoot.querySelector(".contract-header").remove();
      this.templateEl.shadowRoot.querySelector(".contract-footer").remove();
    }
    catch (e) {
      console.log(e);
    }
  }
  render() {
    var _a, _b;
    const template = this.template ||
      ((_b = (_a = 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.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, enableClicks: 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, disablePosition: this.disablePosition }));
  }
  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; fetch?: any; 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
      },
      "disablePosition": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "disable-position",
        "reflect": false,
        "defaultValue": "false"
      },
      "disableFrame": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "disable-frame",
        "reflect": false,
        "defaultValue": "false"
      }
    };
  }
}
