'use strict';

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

const index = require('./index-ee190ee0.js');
const store = require('./store-5a3b44dc.js');
require('./index-4901314f.js');
require('./getHandlebarsHelpers-8ef28401.js');
require('./_commonjsHelpers-a5111d61.js');
require('./index-ba857994.js');
require('./localforage-af1b8c0e.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;

const moistureMapCss = "floodteam-moisture-map .default{background:rgba(var(--ion-text-color-rgb), 0.1);border:2px dashed rgba(var(--ion-color-medium-rgb), 0.4);border-radius:var(--border-radius, 4px);display:flex;flex-direction:column;gap:0.6rem;margin:5px auto;padding:1rem}floodteam-moisture-map fireenjin-form{border-radius:60px;border:2px solid var(--ion-color-primary)}floodteam-moisture-map fireenjin-form fireejin-input ion-item{--padding-top:0}floodteam-moisture-map fireenjin-form fireejin-input ion-item ion-label{margin-top:-10px}";

const MoistureMap = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
    return (index.h(index.Host, { id: "moisture-map" }, !((_a = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _a === void 0 ? void 0 : _a.moistureMap) && !((_b = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _b === void 0 ? void 0 : _b.matterportModelId) && index.h("div", { class: "default" }, index.h("fireenjin-upload-button", { name: "moistureMap", placeholder: "Upload Drawing", value: (_c = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _c === void 0 ? void 0 : _c.moistureMap, endpoint: "editJob", documentId: (_d = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _d === void 0 ? void 0 : _d.id, autoSubmit: true }), index.h("h4", { class: "ion-text-center ion-no-margin" }, "- or -"), index.h("fireenjin-form", { endpoint: "editJob", documentId: (_e = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _e === void 0 ? void 0 : _e.id, hideControls: true, ref: (el) => (this.formEl = el) }, index.h("div", { style: {
        display: "flex",
        gap: "0.5rem",
        alignItems: "center",
      } }, index.h("ion-button", { shape: "round", size: "small", fill: "clear", href: "https://floodteam.notion.site/How-to-Add-a-Matterport-Model-to-a-Job-8f8e72b90fe04e72a293ff262b5ffd78", target: "_blank", color: "medium" }, index.h("ion-icon", { name: "information-circle", slot: "icon-only" })), index.h("fireenjin-input", { style: {
        width: "100%",
      }, lines: "none", labelPosition: "floating", name: "matterportModelId", label: "MatterPort Link", placeholder: "https://my.matterport.com/show?m=ABC123", required: true }), index.h("ion-button", { style: { height: "40px", width: "40px", marginRight: "8px" }, shape: "round", size: "small", href: "#", onClick: () => this.formEl.submit(), color: "primary" }, index.h("ion-icon", { name: "save", slot: "icon-only" }))))), ((_f = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _f === void 0 ? void 0 : _f.moistureMap) && !((_g = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _g === void 0 ? void 0 : _g.matterportModelId) && (index.h("div", { class: "drawing" }, index.h("img", { src: (_h = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _h === void 0 ? void 0 : _h.moistureMap, style: { width: "100%" } }))), ((_j = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _j === void 0 ? void 0 : _j.matterportModelId) && (index.h("div", { class: "matterport", style: { position: "relative" } }, index.h("iframe", { style: {
        maxWidth: "100%",
        maxHeight: "100%",
        display: "block",
      }, width: "853", height: "480", frameborder: "0", allowfullScreen: "true", allow: "xr-spatial-tracking", src: `https://my.matterport.com/show/?m=${(_k = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _k === void 0 ? void 0 : _k.matterportModelId}&brand=0&help=1` })))));
  }
};
MoistureMap.style = moistureMapCss;

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_moisture_map = MoistureMap;
exports.floodteam_select_lost_reason = SelectLostReason;
