'use strict';

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

const index = require('./index-e0385008.js');

const itemUserCss = "floodteam-item-user h3,floodteam-item-user ion-text{display:block;text-indent:10px}floodteam-item-user ion-label{margin-top:5px;margin-bottom:0px;text-transform:capitalize}floodteam-item-user ion-grid ion-chip{padding:0px 15px;--background:transparent;--color:var(--ion-text-color);opacity:0.5}floodteam-item-user ion-chip ion-icon{height:15px;width:15px;color:var(--ion-text-color)}floodteam-item-user ion-grid,floodteam-item-user ion-grid ion-row,floodteam-item-user ion-grid ion-row ion-col{padding:0;margin:0}";

const ItemUser = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinSubmit = index.createEvent(this, "fireenjinSubmit", 7);
    this.user = undefined;
    this.jobId = undefined;
    this.role = undefined;
    this.disabled = false;
  }
  removeUserFromJob(user) {
    if (!confirm(`Are you sure you want to remove ${(user === null || user === void 0 ? void 0 : user.firstName) ? user.firstName : "this user"} from the job?`))
      return;
    this.fireenjinSubmit.emit({
      endpoint: "removeUserFromJob",
      data: {
        jobId: this.jobId,
        userId: user.id,
      },
    });
    if (this.slidingEl)
      this.slidingEl.close();
  }
  render() {
    var _a, _b, _c, _d, _e, _f;
    return (index.h(index.Host, null, index.h("ion-item-sliding", { ref: (el) => (this.slidingEl = el), disabled: this.disabled }, index.h("ion-item", { href: this.disabled ? null : `/users/${this.user.id}`, detail: true }, index.h("fireenjin-avatar", { style: {
        marginInlineEnd: "8px",
      }, src: this.user.photo, initials: `${((_a = this.user) === null || _a === void 0 ? void 0 : _a.firstName) ? this.user.firstName.charAt(0) : ""}${((_b = this.user) === null || _b === void 0 ? void 0 : _b.lastName) ? this.user.lastName.charAt(0) : ""}`, slot: "start" }), index.h("ion-label", null, index.h("h2", null, ((_c = this.user) === null || _c === void 0 ? void 0 : _c.firstName) || "", " ", ((_d = this.user) === null || _d === void 0 ? void 0 : _d.lastName) || ""), index.h("p", null, ((_e = this.user) === null || _e === void 0 ? void 0 : _e.email) || "")), index.h("floodteam-select-role", { jobId: this.jobId, userId: (_f = this.user) === null || _f === void 0 ? void 0 : _f.id, value: this.role, slot: "end" })), index.h("ion-item-options", null, index.h("ion-item-option", { color: "danger", onClick: () => this.removeUserFromJob(this.user) }, index.h("ion-icon", { slot: "end", name: "close-circle" }), "Remove")))));
  }
};
ItemUser.style = itemUserCss;

function getLostReasonOptions() {
  return [
    {
      label: "No Availability",
      value: "no-availability",
    },
    {
      label: "Wrong Type of Job",
      value: "wrong-type",
    },
    {
      label: "Insurance Recommendation",
      value: "insurance-recommendation",
    },
    {
      label: "Chose Competitor",
      value: "competitor",
    },
    {
      label: "No Coverage / Can't Afford",
      value: "no-coverage",
    },
    {
      label: "Too Expensive",
      value: "too-expensive",
    },
    {
      label: "Bad Lead",
      value: "bad-lead",
    },
  ];
}

const SelectLostReason = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.fireenjinTrigger = index.createEvent(this, "fireenjinTrigger", 7);
    this.fireenjinSubmit = index.createEvent(this, "fireenjinSubmit", 7);
    this.name = "lostReason";
    this.value = undefined;
    this.jobId = undefined;
    this.disabled = false;
  }
  onTrigger(event) {
    var _a, _b, _c, _d, _e;
    if (((_c = (_b = (_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.event) === null || _b === void 0 ? void 0 : _b.detail) === null || _c === void 0 ? void 0 : _c.type) !== this.name)
      return;
    this.value = ((_e = (_d = event === null || event === void 0 ? void 0 : event.detail) === null || _d === void 0 ? void 0 : _d.payload) === null || _e === void 0 ? void 0 : _e.value) || null;
    this.fireenjinSubmit.emit({
      endpoint: "editJob",
      id: this.jobId,
      data: {
        lostReason: this.value,
      },
    });
  }
  render() {
    var _a;
    const options = getLostReasonOptions();
    return (index.h("ion-chip", { onClick: (event) => {
        if (this.disabled)
          return;
        event.preventDefault();
        event.stopPropagation();
        this.fireenjinTrigger.emit({
          event,
          name: "filter",
          type: this.name,
          el: this.selectLocationEl,
          payload: {
            control: {
              name: this.name,
              label: "Lost Reason",
              icon: "info",
              options,
              value: this.value,
            },
          },
        });
      } }, index.h("ion-icon", { name: "help", class: "ft-icon-style" }), index.h("ion-label", { class: "ion-text-capitalize" }, ((_a = (options || []).find((option) => (option === null || option === void 0 ? void 0 : option.value) === this.value)) === null || _a === void 0 ? void 0 : _a.label) || "No Reason Set")));
  }
  get selectLocationEl() { return index.getElement(this); }
};

exports.floodteam_item_user = ItemUser;
exports.floodteam_select_lost_reason = SelectLostReason;
