import { r as registerInstance, d as createEvent, B as Build, h } from './index-31949dc5.js';
import { t as toastController } from './overlays-291bc7b7.js';
import { s as state } from './store-cca1abc6.js';
import './ionic-global-70d3ca26.js';
import './helpers-06537f39.js';
import './index-afdf7f54.js';
import './getHandlebarsHelpers-ae9bfed4.js';
import './_commonjsHelpers-44457d8d.js';
import './index-e6b3332e.js';
import './localforage-394b59fa.js';

const appUserCss = "app-user ion-card,app-user ion-card ion-list{overflow:visible !important;contain:none !important}";

const AppUser = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.floodteamOpenModal = createEvent(this, "floodteamOpenModal", 7);
    this.floodteamCloseModal = createEvent(this, "floodteamCloseModal", 7);
    this.fireenjinFetch = createEvent(this, "fireenjinFetch", 7);
    this.userId = undefined;
    this.query = undefined;
    this.paginationEl = undefined;
    this.jobs = [];
  }
  async onSuccess(event) {
    var _a, _b, _c, _d, _e, _f;
    if (event.detail.endpoint === "addUser") {
      const routerEl = document.querySelector("ion-router");
      if (!routerEl || !((_c = (_b = (_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.addUser) === null || _c === void 0 ? void 0 : _c.id))
        return;
      routerEl.push(`/users/${event.detail.data.addUser.id}`);
    }
    else if (event.detail.endpoint === "editUser") {
      this.presentToast();
    }
    else if (((_d = event === null || event === void 0 ? void 0 : event.detail) === null || _d === void 0 ? void 0 : _d.endpoint) === "findUser") {
      state.user = (_f = (_e = event === null || event === void 0 ? void 0 : event.detail) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.user;
    }
  }
  async presentToast() {
    const toast = await toastController.create({
      message: "The user has been updated.",
      duration: 2000,
    });
    toast.present();
  }
  componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    setTimeout(() => {
      state.feedFetchData = {
        ...((state === null || state === void 0 ? void 0 : state.feedFetchData) || {}),
        userId: this.userId,
        myFeed: null,
      };
    }, 2000);
  }
  render() {
    var _a;
    return [
      h("ion-content", { scrollEvents: true, class: "ion-padding" }, h("floodteam-title-bar", { pin: {
          icon: "person",
          href: `/users/${this.userId}`,
          name: ((_a = state === null || state === void 0 ? void 0 : state.user) === null || _a === void 0 ? void 0 : _a.firstName) || "User",
        } }, h("ion-router-link", { href: "/users" }, "Users")), h("ion-grid", null, h("ion-row", null, h("ion-col", null, h("ion-card", { class: "ion-padding" }, h("floodteam-form-user", { userId: this.userId, showPhoto: true }))), h("ion-col", null, h("fireenjin-pagination", { name: "user-jobs", ref: (el) => (this.paginationEl = el), disableVirtualScroll: true, listEl: ({ result: job }) => (h("floodteam-item-job", { job: job })), endpoint: "listJobs", limit: 4, fetchParams: {
          withPayables: true,
        }, fetchData: { userId: this.userId }, resultsKey: "jobs", query: this.query, removeDuplicates: true }))))),
      h("floodteam-navigation-footer", null),
    ];
  }
};
AppUser.style = appUserCss;

export { AppUser as app_user };
