import { Build, Component, Event, h, Listen, State, } from "@stencil/core";
import getEventTypeOptions from "../../../helpers/getEventTypeOptions";
export class AppTrigger {
  constructor() {
    this.eventIconMap = {
      alert: "notifications",
      notion: "./assets/svg/notion.svg",
    };
    this.filters = [
      {
        name: "type",
        label: "Event Type",
        icon: "magnet",
        options: getEventTypeOptions(),
      },
    ];
  }
  onSearchInput(event) {
    this.query = event.target.value;
  }
  componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    // Get Data
  }
  render() {
    return [
      h("ion-content", { class: "ion-padding" },
        h("floodteam-title-bar", null,
          h("ion-router-link", { href: "/triggers" }, "Triggers"),
          h("ion-buttons", { slot: "end" },
            h("ion-button", { fill: "solid", color: "primary", href: "/triggers/new" }, "Add"))),
        h("div", { class: "ion-padding" },
          h("fireenjin-search-bar", { ref: (el) => (this.filterBarEl = el), paginationEl: this.paginationEl, filters: this.filters }),
          h("fireenjin-pagination", { ref: (el) => (this.paginationEl = el), resultsKey: "triggers", disableVirtualScroll: true, removeDuplicates: true, listEl: ({ result: trigger }) => {
              var _a, _b, _c, _d, _e, _f;
              return (h("ion-item", { href: `/triggers/${trigger.id}`, detail: true, lines: "full" },
                h("ion-toggle", { slot: "start", name: "active", onClick: (event) => {
                    event.preventDefault();
                    event.stopPropagation();
                  }, onIonChange: (event) => this.fireenjinSubmit.emit({
                    endpoint: "editTrigger",
                    id: trigger.id,
                    data: {
                      active: event.target.checked,
                    },
                  }), value: trigger === null || trigger === void 0 ? void 0 : trigger.id, checked: trigger === null || trigger === void 0 ? void 0 : trigger.active }),
                h("ion-grid", null,
                  h("ion-row", { class: "ion-align-items-center ion-justify-content-between" },
                    h("ion-col", null,
                      h("ion-label", null,
                        h("h2", null, trigger.name))),
                    h("ion-col", null, (trigger === null || trigger === void 0 ? void 0 : trigger.type) && (h("ion-chip", { outline: true, style: {
                        float: "right",
                        opacity: "0.6",
                      } },
                      h("ion-icon", { name: "magnet" }),
                      h("ion-label", null, trigger === null || trigger === void 0 ? void 0 :
                        trigger.type,
                        " \u00A0 => \u00A0",
                        " ", trigger === null || trigger === void 0 ? void 0 :
                        trigger.action),
                      h("ion-icon", { name: !((_c = (_b = (_a = this.eventIconMap) === null || _a === void 0 ? void 0 : _a[trigger === null || trigger === void 0 ? void 0 : trigger.action]) === null || _b === void 0 ? void 0 : _b.includes) === null || _c === void 0 ? void 0 : _c.call(_b, "/")) && this.eventIconMap[trigger === null || trigger === void 0 ? void 0 : trigger.action], src: ((_f = (_e = (_d = this.eventIconMap) === null || _d === void 0 ? void 0 : _d[trigger === null || trigger === void 0 ? void 0 : trigger.action]) === null || _e === void 0 ? void 0 : _e.includes) === null || _f === void 0 ? void 0 : _f.call(_e, "/")) && this.eventIconMap[trigger === null || trigger === void 0 ? void 0 : trigger.action] }))))))));
            }, display: "list", endpoint: "listTriggers", limit: 20, query: this.query }))),
      h("floodteam-navigation-footer", null),
    ];
  }
  static get is() { return "app-trigger-list"; }
  static get originalStyleUrls() { return {
    "$": ["app-trigger-list.css"]
  }; }
  static get styleUrls() { return {
    "$": ["app-trigger-list.css"]
  }; }
  static get states() { return {
    "query": {},
    "filters": {}
  }; }
  static get events() { return [{
      "method": "fireenjinSubmit",
      "name": "fireenjinSubmit",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "FireEnjinSubmitEvent",
        "resolved": "FireEnjinSubmitEvent",
        "references": {
          "FireEnjinSubmitEvent": {
            "location": "import",
            "path": "@fireenjin/sdk"
          }
        }
      }
    }]; }
  static get listeners() { return [{
      "name": "ionInput",
      "method": "onSearchInput",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
