import { withHooks } from "@saasquatch/stencil-hooks";
import { Component, h, Host, Method, Prop } from "@stencil/core";
import { useRequestRerender } from "../../../tables/re-render";
/**
 * @uiName Referral Table Status Column
 * @validParents ["sqm-referral-table"]
 * @exampleGroup Referrals
 * @example Referral Table Status Column - <sqm-referral-table-status-column column-title="Status" converted-status-text="Converted" in-progress-status-text="In Progress" pending-review-status-text="Pending" denied-status-text="Denied" pending-review-status-sub-text="Awaiting review" denied-status-sub-text="Detected self-referral"></sqm-referral-table-status-column>
 */
export class ReferralTableStatusColumn {
  constructor() {
    /**
     * @uiName Column title
     */
    this.columnTitle = "Status";
    /**
     * @uiName Converted status text
     */
    this.convertedStatusText = "Converted";
    /**
     * @uiName In progress status text
     */
    this.inProgressStatusText = "In Progress";
    /**
     * @uiName Pending review status text
     */
    this.pendingReviewStatusText = "Pending";
    /**
     * @uiName Denied status text
     */
    this.deniedStatusText = "Denied";
    /**
     * @uiName Pending review status sub-text
     */
    this.pendingReviewStatusSubText = "Awaiting review";
    /**
     * @uiName Denied status sub-text
     */
    this.deniedStatusSubText = "Detected self-referral";
    withHooks(this);
  }
  disconnectedCallback() { }
  async renderCell(data) {
    var _a;
    // TODO: Make ICU and more complete
    let statusText;
    let statusSubText;
    const fraudStatus = (_a = data === null || data === void 0 ? void 0 : data.fraudData) === null || _a === void 0 ? void 0 : _a.moderationStatus;
    if (fraudStatus === "DENIED") {
      statusText = this.deniedStatusText;
      statusSubText = this.deniedStatusSubText;
    }
    else if (fraudStatus === "PENDING") {
      statusText = this.pendingReviewStatusText;
      statusSubText = this.pendingReviewStatusSubText;
    }
    else {
      statusText = data.dateConverted
        ? this.convertedStatusText
        : this.inProgressStatusText;
    }
    return (h("sqm-referral-table-status-cell", { "status-text": statusText, "status-sub-text": statusSubText, "fraud-status": fraudStatus, converted: data.dateConverted ? true : false }));
  }
  async renderLabel() {
    return this.columnTitle;
  }
  async renderReferrerCell(data) {
    // TODO: Make ICU and more complete
    const statusText = data.dateConverted
      ? this.convertedStatusText
      : this.inProgressStatusText;
    return (h("sqm-referral-table-status-cell", { "status-text": statusText, converted: data.dateConverted ? true : false }));
  }
  render() {
    useRequestRerender([
      this.columnTitle,
      this.convertedStatusText,
      this.inProgressStatusText,
    ]);
    return h(Host, { style: { display: "none" } });
  }
  static get is() { return "sqm-referral-table-status-column"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "columnTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Column title",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "column-title",
      "reflect": false,
      "defaultValue": "\"Status\""
    },
    "convertedStatusText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Converted status text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "converted-status-text",
      "reflect": false,
      "defaultValue": "\"Converted\""
    },
    "inProgressStatusText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "In progress status text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "in-progress-status-text",
      "reflect": false,
      "defaultValue": "\"In Progress\""
    },
    "pendingReviewStatusText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Pending review status text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "pending-review-status-text",
      "reflect": false,
      "defaultValue": "\"Pending\""
    },
    "deniedStatusText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Denied status text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "denied-status-text",
      "reflect": false,
      "defaultValue": "\"Denied\""
    },
    "pendingReviewStatusSubText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Pending review status sub-text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "pending-review-status-sub-text",
      "reflect": false,
      "defaultValue": "\"Awaiting review\""
    },
    "deniedStatusSubText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Denied status sub-text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "denied-status-sub-text",
      "reflect": false,
      "defaultValue": "\"Detected self-referral\""
    }
  }; }
  static get methods() { return {
    "renderCell": {
      "complexType": {
        "signature": "(data: Referral) => Promise<any>",
        "parameters": [{
            "tags": [],
            "text": ""
          }],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Referral": {
            "location": "import",
            "path": "../../../saasquatch"
          },
          "FraudStatus": {
            "location": "import",
            "path": "../../../saasquatch"
          }
        },
        "return": "Promise<any>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    },
    "renderLabel": {
      "complexType": {
        "signature": "() => Promise<string>",
        "parameters": [],
        "references": {
          "Promise": {
            "location": "global"
          }
        },
        "return": "Promise<string>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    },
    "renderReferrerCell": {
      "complexType": {
        "signature": "(data: Referrer) => Promise<any>",
        "parameters": [{
            "tags": [],
            "text": ""
          }],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Referrer": {
            "location": "import",
            "path": "../../../saasquatch"
          }
        },
        "return": "Promise<any>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    }
  }; }
}
