import { r as registerInstance, d as createEvent, h, e as getElement } from './index-33e43734.js';
import { s as state } from './store-729235b6.js';
import { g as getStatusOptions } from './getStatusOptions-6f716ba9.js';
import './index-91eb4513.js';
import './getCache-f7c123d8.js';
import './_commonjsHelpers-cca61ea8.js';
import './logic-2eecfe1e.js';
import './index-964da72a.js';

function getLocationOptions() {
  return ((state === null || state === void 0 ? void 0 : 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) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = 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 (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,
            },
          },
        });
      } }, h("ion-icon", { name: "business", class: "ft-icon-style" }), h("ion-label", { class: "ion-text-capitalize" }, ((_a = ((state === null || state === void 0 ? void 0 : 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 getElement(this); }
};

let SelectStatus = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinTrigger = createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = 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 (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(),
              value: this.value,
            },
          },
        });
      } }, h("ion-icon", { name: "help-circle", class: "ft-icon-style" }), h("ion-label", { class: "ion-text-capitalize" }, this.value || "No Status")));
  }
  get selectStatusEl() { return getElement(this); }
};

export { SelectLocation as floodteam_select_location, SelectStatus as floodteam_select_status };

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