import { Build, h, } from "@stencil/core";
export class PopoverUser {
  constructor() {
    this.user = {};
  }
  onSuccess(event) {
    var _a, _b;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "findUser" && ((_b = event.detail) === null || _b === void 0 ? void 0 : _b.data)) {
      console.log(event.detail);
      this.user = { ...this.user, ...event.detail.data };
    }
  }
  componentDidLoad() {
    var _a;
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    this.fireenjinFetch.emit({
      endpoint: "findUser",
      params: {
        id: (_a = this.user) === null || _a === void 0 ? void 0 : _a.id,
        withFriends: false,
      },
    });
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
    return (h("ion-content", { style: {
        "--background": "var(--ion-color-base)",
      } }, h("ion-item-divider", null, h("div", { style: { width: "100%" } }, h("fireenjin-avatar", { src: (_a = this.user) === null || _a === void 0 ? void 0 : _a.photo, slot: "start", size: "35px", style: { marginRight: "15px", float: "left", marginTop: "15px" }, initials: `${((_b = this.user) === null || _b === void 0 ? void 0 : _b.firstName) ? this.user.firstName.charAt(0) : ""}${((_c = this.user) === null || _c === void 0 ? void 0 : _c.lastName) ? this.user.lastName.charAt(0) : ""}` }), h("h4", { style: { marginBottom: "0" } }, (_d = this.user) === null || _d === void 0 ? void 0 :
      _d.firstName, " ", (_e = this.user) === null || _e === void 0 ? void 0 :
      _e.lastName), h("ion-grid", null, h("ion-row", null, h("ion-col", null, ((_f = this.user) === null || _f === void 0 ? void 0 : _f.phone) && (h("ion-button", { href: `tel:${(_g = this.user) === null || _g === void 0 ? void 0 : _g.phone}`, fill: "clear", color: "primary", size: "small", expand: "full" }, h("ion-icon", { slot: "start", name: "call" }), "Call"))), h("ion-col", null, ((_h = this.user) === null || _h === void 0 ? void 0 : _h.address) && (h("ion-button", { href: `geo:0,0?q=${(_k = (_j = this.user) === null || _j === void 0 ? void 0 : _j.address) === null || _k === void 0 ? void 0 : _k.full}`, fill: "clear", color: "primary", size: "small", expand: "full" }, h("ion-icon", { slot: "start", name: "map" }), "Map"))))))), h("ion-list", null, ((_l = this.user) === null || _l === void 0 ? void 0 : _l.email) && (h("ion-item", null, h("ion-icon", { name: "mail", class: "mail", slot: "start" }), h("ion-label", { class: "ion-text-wrap" }, h("h5", null, "Email"), h("p", null, (_m = this.user) === null || _m === void 0 ? void 0 : _m.email)))), ((_o = this.user) === null || _o === void 0 ? void 0 : _o.slackHandle) && (h("ion-item", null, h("ion-icon", { name: "logo-slack", class: "slack", slot: "start" }), h("ion-label", { class: "ion-text-wrap" }, h("h5", null, "Slack Handle "), h("p", null, "@", this.user.slackHandle)))), ((_p = this.user) === null || _p === void 0 ? void 0 : _p.company) && (h("ion-item", null, h("ion-icon", { name: "business", class: "business", slot: "start" }), h("ion-label", { class: "ion-text-wrap" }, h("h5", null, "Company"), h("p", null, (_r = (_q = this.user) === null || _q === void 0 ? void 0 : _q.company) === null || _r === void 0 ? void 0 : _r.name)))), ((_s = this.user) === null || _s === void 0 ? void 0 : _s.location) && (h("ion-item", null, h("ion-icon", { name: "business", slot: "start" }), h("ion-label", { class: "ion-text-wrap" }, h("h5", null, "Location"), h("p", null, (_u = (_t = this.user) === null || _t === void 0 ? void 0 : _t.location) === null || _u === void 0 ? void 0 : _u.name)))), ((_v = this.user) === null || _v === void 0 ? void 0 : _v.rating) && (h("ion-item", null, h("ion-icon", { name: "star", class: "star", slot: "start" }), h("ion-label", { class: "ion-text-wrap" }, h("h5", null, "Rating"), h("p", null, (_w = this.user) === null || _w === void 0 ? void 0 :
      _w.rating, " Stars")))), ((_x = this.user) === null || _x === void 0 ? void 0 : _x.birthday) && (h("ion-item", null, h("ion-icon", { name: "ice-cream", class: "ice-cream", slot: "start" }), h("ion-label", { class: "ion-text-wrap" }, h("h5", null, "Birthday"), h("p", null, (_y = this.user) === null || _y === void 0 ? void 0 : _y.birthday)))), ((_z = this.user) === null || _z === void 0 ? void 0 : _z.referredBy) && (h("ion-item", null, h("ion-icon", { name: "ear", class: "ear", slot: "start" }), h("ion-label", { class: "ion-text-wrap" }, h("h5", null, "Referred By"), h("p", null, ((_1 = (_0 = this.user) === null || _0 === void 0 ? void 0 : _0.referredBy) === null || _1 === void 0 ? void 0 : _1.firstName)
      ? this.user.referredBy.firstName
      : "", " ", ((_3 = (_2 = this.user) === null || _2 === void 0 ? void 0 : _2.referredBy) === null || _3 === void 0 ? void 0 : _3.firstName)
      ? this.user.referredBy.firstName
      : "")))))));
  }
  static get is() { return "popover-user"; }
  static get originalStyleUrls() {
    return {
      "$": ["popover-user.css"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["popover-user.css"]
    };
  }
  static get properties() {
    return {
      "user": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "Partial<User>",
          "resolved": "{ __typename?: \"User\"; active?: boolean; address?: Address; billingAddress?: Address; birthday?: string; certifications?: Certification[]; company?: Company; createdAt?: string; createdBy?: User; email?: string; feed?: Feed[]; firstName?: string; floodbotId?: string; friends?: User[]; id?: string; isFranchise?: boolean; isFranchiseOwner?: boolean; isOnboarded?: boolean; isSearchable?: boolean; isSetup?: boolean; isStripeOAuth?: boolean; jobs?: Job[]; lastName?: string; lastNotifiedAt?: string; lastOnline?: string; location?: Location; online?: boolean; phone?: string; photo?: string; plaidAccessToken?: string; rating?: number; referredBy?: User; role?: string; slackHandle?: string; stripeId?: string; tags?: string[]; trade?: string; type?: string; updatedAt?: string; updatedBy?: User; vehicles?: Vehicle[]; }",
          "references": {
            "Partial": {
              "location": "global"
            },
            "User": {
              "location": "import",
              "path": "../../../sdk"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "defaultValue": "{}"
      }
    };
  }
  static get events() {
    return [{
        "method": "fireenjinFetch",
        "name": "fireenjinFetch",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        }
      }];
  }
  static get listeners() {
    return [{
        "name": "fireenjinSuccess",
        "method": "onSuccess",
        "target": "body",
        "capture": false,
        "passive": false
      }];
  }
}
