import { r as registerInstance, d as createEvent, h, e as getElement } from './index-33e43734.js';

const modalTemplateSettingsCss = "fireenjin-mx-modal-template-settings .head-input,fireenjin-mx-modal-template-settings .routes-input{display:block;width:100%}fireenjin-mx-modal-template-settings .head-input ion-label,fireenjin-mx-modal-template-settings .routes-input ion-label{font-size:16px !important;font-weight:bold !important;display:block;background:transparent;text-align:left;font-family:var(--ion-font-family);position:relative;font-size:inherit;text-align:inherit;padding:0 0 20px 25px}fireenjin-mx-modal-template-settings .head-input fireenjin-code-editor,fireenjin-mx-modal-template-settings .routes-input fireenjin-code-editor{min-height:300px !important}";

let ModalTemplateSettings = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.pageTitle = "Edit Template Info";
    this.template = {};
    this.partials = [];
    this.hideTemplateSelect = false;
    this.showAdvanced = false;
    this.tags = [];
    this.helpers = {
      formatUSD: (amount) => {
        const formatter = new Intl.NumberFormat("en-US", {
          style: "currency",
          currency: "USD",
          minimumFractionDigits: 2,
        });
        return formatter.format(amount ? amount : 0);
      },
    };
    this.types = [
      {
        label: "Component",
        value: "component",
      },
      {
        label: "Email",
        value: "email",
      },
      {
        label: "Contract",
        value: "contract",
      },
      {
        label: "Frame",
        value: "frame",
      },
      {
        label: "PDF",
        value: "pdf",
      },
      {
        label: "Feed Card",
        value: "feed",
      },
      {
        label: "Message",
        value: "message",
      },
      {
        label: "Web Page",
        value: "page",
      },
    ];
  }
  async onSubmit() {
    this.fireenjinTrigger.emit({ name: "closeModal" });
  }
  async onReset() {
    this.fireenjinTrigger.emit({ name: "closeModal" });
  }
  onCodeChange(event) {
    var _a;
    if (!((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.value))
      return;
    this.head = event.detail.value;
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    return [
      h("ion-header", null, h("ion-toolbar", null, h("ion-title", null, this.pageTitle), h("ion-buttons", { slot: "end" }, h("ion-button", { onClick: () => this.formEl.submit() }, h("ion-icon", { slot: "icon-only", name: "save" })), h("ion-button", { onClick: () => this.fireenjinTrigger.emit({
          name: "closeModal",
          el: this.modalEl,
          component: "mx-modal-send-email",
        }) }, h("ion-icon", { slot: "icon-only", name: "close-circle-outline" }))))),
      h("ion-content", null, h("fireenjin-form", { ref: (el) => (this.formEl = el), endpoint: this.templateId ? "editTemplate" : "addTemplate", documentId: this.templateId, hideControls: true, beforeSubmit: async (data) => {
          var _a;
          return ({
            ...data,
            head: this.head || ((_a = this.template) === null || _a === void 0 ? void 0 : _a.head),
            attachments: ((data === null || data === void 0 ? void 0 : data.attachments) || []).map((href) => ({
              href,
              filename: href.split("/").pop(),
            })),
          });
        } }, h("fireenjin-input", { labelPosition: "stacked", name: "subject", label: "Subject", value: (_a = this.template) === null || _a === void 0 ? void 0 : _a.subject }), h("fireenjin-input", { labelPosition: "stacked", name: "description", label: "Description", value: (_b = this.template) === null || _b === void 0 ? void 0 : _b.description }), h("fireenjin-input", { labelPosition: "stacked", label: "Text Only Version", name: "text", value: (_c = this.template) === null || _c === void 0 ? void 0 : _c.text }), h("fireenjin-select-tags", { labelPosition: "stacked", label: "Tags", lines: "full", options: this.tags, allowAdding: true, value: ((_d = this.template) === null || _d === void 0 ? void 0 : _d.tags) || [] }), h("ion-accordion-group", null, h("ion-accordion", null, h("ion-item", { slot: "header" }, h("ion-label", null, "Advanced")), h("ion-list", { slot: "content" }, h("fireenjin-input", { labelPosition: "stacked", name: "name", label: "Name", value: (_e = this.template) === null || _e === void 0 ? void 0 : _e.name }), h("fireenjin-select-tags", { labelPosition: "stacked", label: "Attachments", lines: "full", options: (((_f = this.template) === null || _f === void 0 ? void 0 : _f.attachments) || []).map((attachment) => ({
          label: attachment === null || attachment === void 0 ? void 0 : attachment.filename,
          value: attachment === null || attachment === void 0 ? void 0 : attachment.path,
        })), allowAdding: true, value: ((_g = this.template) === null || _g === void 0 ? void 0 : _g.attachments) || [] }), h("fireenjin-input", { labelPosition: "stacked", label: "AMP Version", name: "amp", value: (_h = this.template) === null || _h === void 0 ? void 0 : _h.amp })))))),
    ];
  }
  get modalEl() { return getElement(this); }
};
ModalTemplateSettings.style = modalTemplateSettingsCss;

export { ModalTemplateSettings as fireenjin_mx_modal_template_settings };

//# sourceMappingURL=fireenjin-mx-modal-template-settings.entry.js.map