import { Component, h, Prop } from "@stencil/core";
import { intl } from "../../../global/global";
export class RewardTableSourceCell {
  constructor() {
    this.locale = "en";
  }
  render() {
    intl.locale = this.locale;
    const RewardSource = ({ reward }) => {
      var _a;
      return (h("span", null, intl.formatMessage({
        id: "rewardSourceText",
        defaultMessage: this.rewardSourceText,
      }, {
        rewardSource: reward.rewardSource,
        programName: (_a = reward === null || reward === void 0 ? void 0 : reward.program) === null || _a === void 0 ? void 0 : _a.name,
      })));
    };
    const SOURCE_COLUMN_LENGTH = 21;
    const RewardExchangeBadge = ({ reward }) => {
      var _a;
      const rewardExchange = (h("div", null,
        h("span", { style: {
            fontSize: "var(--sl-font-size-small)",
            color: "var(--sqm-text-subdued)",
          } }, this.rewardExchangeText),
        h("br", null), (_a = reward.exchangedRewardRedemptionTransaction) === null || _a === void 0 ? void 0 :
        _a.prettyRedeemedCredit,
        " → ",
        reward.prettyValue));
      return reward.exchangedRewardRedemptionTransaction.prettyRedeemedCredit
        .length +
        reward.prettyValue.length <
        SOURCE_COLUMN_LENGTH ? (rewardExchange) : (h("div", { style: {
          display: "inline-block",
          verticalAlign: "top",
        } }, rewardExchange));
    };
    const getFullName = (user) => {
      if (!user)
        return this.deletedUserText;
      if (!user.firstName && !user.lastName)
        return this.anonymousUserText;
      if (!user.firstName)
        return `${user.lastName}`;
      if (!user.lastName)
        return `${user.firstName}`;
      return `${user.firstName} ${user.lastName}`;
    };
    const Source = () => this.reward.rewardSource === "FRIEND_SIGNUP" ||
      this.reward.rewardSource === "REFERRED" ? (this.reward.referral === null ? (h("p", { style: {
        color: "var(--sqm-text-subdued)",
      } }, this.deletedReferralText)) : (h("div", null,
      h("div", { style: {
          fontSize: "var(--sl-font-size-small)",
          color: "var(--sqm-text-subdued)",
        } }, intl.formatMessage({
        id: "referralText",
        defaultMessage: this.referralText,
      }, {
        rewardSource: this.reward.rewardSource,
      })),
      h("div", null, this.reward.rewardSource == "FRIEND_SIGNUP"
        ? getFullName(this.reward.referral.referredUser)
        : getFullName(this.reward.referral.referrerUser))))) : this.reward.exchangedRewardRedemptionTransaction ? (h(RewardExchangeBadge, { reward: this.reward })) : (h(RewardSource, { reward: this.reward }));
    return h(Source, null);
  }
  static get is() { return "sqm-rewards-table-source-cell"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "reward": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Reward",
        "resolved": "Reward",
        "references": {
          "Reward": {
            "location": "import",
            "path": "../../../saasquatch"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "deletedUserText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "deleted-user-text",
      "reflect": false
    },
    "deletedReferralText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "deleted-referral-text",
      "reflect": false
    },
    "anonymousUserText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "anonymous-user-text",
      "reflect": false
    },
    "rewardExchangeText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "reward-exchange-text",
      "reflect": false
    },
    "referralText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "referral-text",
      "reflect": false
    },
    "rewardSourceText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "reward-source-text",
      "reflect": false
    },
    "locale": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "locale",
      "reflect": false,
      "defaultValue": "\"en\""
    }
  }; }
}
