'use strict';

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

const index = require('./index-fd2bbf0b.js');
const hardwareBackButton = require('./overlays-de05dc6a.js');
const store = require('./store-953d336c.js');
require('./ionic-global-1340f737.js');
require('./helpers-c2496722.js');
require('./index-81aa1bcb.js');
require('./getCache-c039a6ae.js');
require('./_commonjsHelpers-a5111d61.js');
require('./logic-d8c34975.js');
require('./index-6307644b.js');

const appLocationCss = "";

let AppLocation = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  async onSuccess(event) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
    if (event.detail.endpoint === "addLocation") {
      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.addLocation) === null || _c === void 0 ? void 0 : _c.id))
        return;
      routerEl.push(`/locations/${event.detail.data.addLocation.id}`);
    }
    else if (event.detail.endpoint === "editLocation") {
      this.presentToast();
    }
    else if (((_d = event === null || event === void 0 ? void 0 : event.detail) === null || _d === void 0 ? void 0 : _d.endpoint) === "findLocation") {
      this.location = ((_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.location) || null;
    }
    else if (((_g = event === null || event === void 0 ? void 0 : event.detail) === null || _g === void 0 ? void 0 : _g.endpoint) === "upload") {
      this.location[(_h = event === null || event === void 0 ? void 0 : event.detail) === null || _h === void 0 ? void 0 : _h.name] =
        ((_l = (_k = (_j = event === null || event === void 0 ? void 0 : event.detail) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.upload) === null || _l === void 0 ? void 0 : _l.url) || null;
      this.location = { ...this.location };
    }
  }
  async presentToast() {
    const toast = await hardwareBackButton.toastController.create({
      message: "The location has been updated.",
      duration: 2000,
    });
    toast.present();
  }
  render() {
    var _a, _b, _c, _d, _e;
    return [
      index.h("ion-content", { scrollEvents: true, class: "ion-padding" }, index.h("floodteam-title-bar", null, index.h("ion-router-link", { href: "/locations" }, "Locations")), index.h("ion-card", { class: "ion-padding" }, index.h("fireenjin-form", { fetch: this.locationId === "new" ? false : "findLocation", fetchKey: "location", endpoint: this.locationId === "new" ? "addLocation" : "editLocation", documentId: this.locationId === "new" ? null : this.locationId, filterData: [
          "name",
          "phone",
          "email",
          "address",
          "ownerId",
          "defaultPayModelId",
          "website",
          "googleTagManagerId",
          "tags",
          "bannerPhoto",
          "photo",
          "teamPhoto",
          "taxId",
        ], beforeSubmit: (data) => ({ ...this.location, ...data }), resetButton: null }, index.h("ion-list", null, index.h("ion-grid", null, index.h("ion-row", null, index.h("ion-col", null, index.h("ion-card", null, index.h("fireenjin-input-photo", { name: "photo", value: (_a = this.location) === null || _a === void 0 ? void 0 : _a.photo, type: "location" }), index.h("ion-item", null, index.h("ion-label", { class: "ion-text-center" }, "Photo")))), index.h("ion-col", null, index.h("ion-card", null, index.h("fireenjin-input-photo", { name: "bannerPhoto", value: (_b = this.location) === null || _b === void 0 ? void 0 : _b.bannerPhoto }), index.h("ion-item", null, index.h("ion-label", { class: "ion-text-center" }, "Banner")))), index.h("ion-col", null, index.h("ion-card", null, index.h("fireenjin-input-photo", { name: "teamPhoto", value: (_c = this.location) === null || _c === void 0 ? void 0 : _c.teamPhoto }), index.h("ion-item", null, index.h("ion-label", { class: "ion-text-center" }, "Team")))))), index.h("fireenjin-input", { "data-fill": true, name: "name", label: "Location Name", labelPosition: "stacked" }), index.h("fireenjin-input", { "data-fill": true, name: "email", type: "email", label: "E-Mail", labelPosition: "stacked" }), index.h("fireenjin-input", { "data-fill": true, name: "website", label: "Website", labelPosition: "stacked" }), index.h("fireenjin-input", { "data-fill": true, name: "phone", type: "phone", label: "Phone Number", labelPosition: "stacked" }), index.h("fireenjin-input-address", { "data-fill": true, name: "address", label: "Address", labelPosition: "stacked", googleMapsKey: (_e = (_d = store.state === null || store.state === void 0 ? void 0 : store.state.config) === null || _d === void 0 ? void 0 : _d.firebase) === null || _e === void 0 ? void 0 : _e.apiKey }), index.h("fireenjin-input-search-user", { "data-fill": true, label: "Owner", labelPosition: "stacked", name: "ownerId", autofocus: true, placeholder: "Search Users", mode: "popover", required: true }), index.h("fireenjin-input", { "data-fill": true, name: "taxId", label: "Location EIN (Tax ID)", labelPosition: "stacked" }), index.h("fireenjin-select", { "data-fill": true, name: "defaultPayModelId", label: "Default Pay Model", endpoint: "listPayModels", limit: 100, dataPropsMap: {
          payModels: "results",
        } }), index.h("fireenjin-select-tags", { "data-fill": true, name: "tags", label: "Tags", labelPosition: "stacked", allowAdding: true, options: [] }), index.h("fireenjin-input", { "data-fill": true, name: "googleTagManagerId", label: "Google Tag Manager ID", labelPosition: "stacked" }), index.h("fireenjin-input", { "data-fill": true, name: "googleTagManagerCampaignId", label: "Google Tag Manager Campaign ID", labelPosition: "stacked" }))))),
      index.h("floodteam-navigation-footer", null),
    ];
  }
};
AppLocation.style = appLocationCss;

exports.app_location = AppLocation;

//# sourceMappingURL=app-location.cjs.entry.js.map