'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-fd2bbf0b.js');
const store = require('./store-953d336c.js');
const getStatusOptions = require('./getStatusOptions-64f3eefc.js');
require('./index-81aa1bcb.js');
require('./getCache-c039a6ae.js');
require('./_commonjsHelpers-a5111d61.js');
require('./logic-d8c34975.js');
require('./index-6307644b.js');

function getLocationOptions() {
  return ((store.state === null || store.state === void 0 ? void 0 : store.state.locations) || []).map((location) => ({
    label: (location === null || location === void 0 ? void 0 : location.name) || "Unknown Location",
    value: location === null || location === void 0 ? void 0 : location.id,
  }));
}

let SelectLocation = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = index.createEvent(this, "fireenjinSubmit", 7);
    this.name = "status";
    this.disabled = false;
  }
  onTrigger(event) {
    var _a, _b, _c, _d;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.name) !== "select" ||
      this.selectLocationEl !== ((_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.el))
      return;
    this.value = ((_d = (_c = event === null || event === void 0 ? void 0 : event.detail) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.value) || null;
    this.fireenjinSubmit.emit({
      endpoint: "editJob",
      id: this.jobId,
      data: {
        locationId: this.value,
      },
    });
  }
  render() {
    var _a;
    return (index.h("ion-chip", { onClick: (event) => {
        if (this.disabled)
          return;
        event.preventDefault();
        event.stopPropagation();
        this.fireenjinTrigger.emit({
          event,
          name: "filter",
          type: "location",
          el: this.selectLocationEl,
          payload: {
            control: {
              name: "location",
              label: "Location",
              icon: "business",
              options: getLocationOptions(),
              value: this.value,
            },
          },
        });
      } }, index.h("ion-icon", { name: "business", class: "ft-icon-style" }), index.h("ion-label", { class: "ion-text-capitalize" }, ((_a = ((store.state === null || store.state === void 0 ? void 0 : store.state.locations) || []).find((location) => (location === null || location === void 0 ? void 0 : location.id) === this.value)) === null || _a === void 0 ? void 0 : _a.name) || "No Location Set")));
  }
  get selectLocationEl() { return index.getElement(this); }
};

let SelectStatus = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = index.createEvent(this, "fireenjinSubmit", 7);
    this.name = "status";
    this.disabled = false;
  }
  onTrigger(event) {
    var _a, _b, _c, _d;
    if (((_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.name) !== "select" ||
      this.selectStatusEl !== ((_b = event === null || event === void 0 ? void 0 : event.detail) === null || _b === void 0 ? void 0 : _b.el))
      return;
    this.value = ((_d = (_c = event === null || event === void 0 ? void 0 : event.detail) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.value) || null;
    this.fireenjinSubmit.emit({
      endpoint: "editJob",
      id: this.jobId,
      data: {
        status: this.value,
      },
    });
  }
  render() {
    return (index.h("ion-chip", { onClick: (event) => {
        if (this.disabled)
          return;
        event.preventDefault();
        event.stopPropagation();
        this.fireenjinTrigger.emit({
          event,
          name: "filter",
          type: "status",
          el: this.selectStatusEl,
          payload: {
            control: {
              name: "status",
              label: "Status",
              icon: "help-circle",
              options: getStatusOptions.getStatusOptions(),
              value: this.value,
            },
          },
        });
      } }, index.h("ion-icon", { name: "help-circle", class: "ft-icon-style" }), index.h("ion-label", { class: "ion-text-capitalize" }, this.value || "No Status")));
  }
  get selectStatusEl() { return index.getElement(this); }
};

exports.floodteam_select_location = SelectLocation;
exports.floodteam_select_status = SelectStatus;

//# sourceMappingURL=floodteam-select-location_2.cjs.entry.js.map