'use strict';

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

const index = require('./index-9f0649b4.js');
const hardwareBackButton = require('./overlays-a2727821.js');
const store = require('./store-6aa30f89.js');
require('./ionic-global-838555f5.js');
require('./helpers-c2496722.js');
require('./index-bac05b73.js');
require('./getHandlebarsHelpers-93797155.js');
require('./_commonjsHelpers-a5111d61.js');
require('./index-ba857994.js');
require('./localforage-af1b8c0e.js');

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

const AppUser = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.floodteamOpenModal = index.createEvent(this, "floodteamOpenModal", 7);
    this.floodteamCloseModal = index.createEvent(this, "floodteamCloseModal", 7);
    this.fireenjinFetch = index.createEvent(this, "fireenjinFetch", 7);
    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") {
      store.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 hardwareBackButton.toastController.create({
      message: "The user has been updated.",
      duration: 2000,
    });
    toast.present();
  }
  componentDidLoad() {
    if (!(index.Build === null || index.Build === void 0 ? void 0 : index.Build.isBrowser))
      return;
    setTimeout(() => {
      store.state.feedFetchData = {
        ...((store.state === null || store.state === void 0 ? void 0 : store.state.feedFetchData) || {}),
        userId: this.userId,
        myFeed: null,
      };
    }, 2000);
  }
  render() {
    var _a;
    return [
      index.h("ion-content", { scrollEvents: true, class: "ion-padding" }, index.h("floodteam-title-bar", { pin: {
          icon: "person",
          href: `/users/${this.userId}`,
          name: ((_a = store.state === null || store.state === void 0 ? void 0 : store.state.user) === null || _a === void 0 ? void 0 : _a.firstName) || "User",
        } }, index.h("ion-router-link", { href: "/users" }, "Users")), index.h("ion-grid", null, index.h("ion-row", null, index.h("ion-col", null, index.h("ion-card", { class: "ion-padding" }, index.h("floodteam-form-user", { userId: this.userId, showPhoto: true }))), index.h("ion-col", null, index.h("fireenjin-pagination", { name: "user-jobs", ref: (el) => (this.paginationEl = el), disableVirtualScroll: true, listEl: ({ result: job }) => (index.h("floodteam-item-job", { job: job })), endpoint: "listJobs", limit: 4, fetchParams: {
          withPayables: true,
        }, fetchData: { userId: this.userId }, resultsKey: "jobs", query: this.query, removeDuplicates: true }))))),
      index.h("floodteam-navigation-footer", null),
    ];
  }
};
AppUser.style = appUserCss;

exports.app_user = AppUser;
