import { Component, Fragment, h, Prop } from '@stencil/core';
import { __ } from '@wordpress/i18n';
export class ScSubscriptionStatusBadge {
  constructor() {
    /** The tag's size. */
    this.size = 'medium';
    /** Draws a pill-style tag with rounded edges. */
    this.pill = false;
    /** Makes the tag clearable. */
    this.clearable = false;
  }
  getType() {
    var _a, _b;
    if ((_a = this.subscription) === null || _a === void 0 ? void 0 : _a.cancel_at_period_end) {
      return 'info';
    }
    switch (this.status || ((_b = this.subscription) === null || _b === void 0 ? void 0 : _b.status)) {
      case 'incomplete':
        return 'warning';
      case 'trialing':
        return 'info';
      case 'active':
        return 'success';
      case 'completed':
        return 'success';
      case 'past_due':
        return 'warning';
      case 'canceled':
        return 'danger';
      case 'unpaid':
        return 'warning';
    }
  }
  getText() {
    var _a, _b, _c;
    if (((_a = this.subscription) === null || _a === void 0 ? void 0 : _a.cancel_at_period_end) && this.subscription.current_period_end_at) {
      return (h(Fragment, null,
        __('Cancels', 'surecart'),
        " ",
        h("sc-format-date", { type: "timestamp", date: this.subscription.current_period_end_at, month: "short", day: "numeric" })));
    }
    switch (this.status || ((_b = this.subscription) === null || _b === void 0 ? void 0 : _b.status)) {
      case 'incomplete':
        return __('Incomplete', 'surecart');
      case 'trialing':
        return __('Trialing', 'surecart');
      case 'active':
        if (Number.isInteger((_c = this.subscription) === null || _c === void 0 ? void 0 : _c.remaining_period_count)) {
          return __('Payment Plan', 'surecart');
        }
        return __('Active', 'surecart');
      case 'past_due':
        return __('Past Due', 'surecart');
      case 'canceled':
        return __('Canceled', 'surecart');
      case 'completed':
        return __('Completed', 'surecart');
      case 'unpaid':
        return __('Unpaid', 'surecart');
    }
  }
  render() {
    return h("sc-tag", { type: this.getType() }, this.getText());
  }
  static get is() { return "sc-subscription-status-badge"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["sc-subscription-status-badge.css"]
  }; }
  static get styleUrls() { return {
    "$": ["sc-subscription-status-badge.css"]
  }; }
  static get properties() { return {
    "status": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "SubscriptionStatus",
        "resolved": "\"active\" | \"canceled\" | \"completed\" | \"incomplete\" | \"past_due\" | \"trialing\" | \"unpaid\"",
        "references": {
          "SubscriptionStatus": {
            "location": "import",
            "path": "../../../types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Subscription status"
      },
      "attribute": "status",
      "reflect": false
    },
    "subscription": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Subscription",
        "resolved": "Subscription",
        "references": {
          "Subscription": {
            "location": "import",
            "path": "../../../types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "The tag's status type."
      }
    },
    "size": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'small' | 'medium' | 'large'",
        "resolved": "\"large\" | \"medium\" | \"small\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "The tag's size."
      },
      "attribute": "size",
      "reflect": true,
      "defaultValue": "'medium'"
    },
    "pill": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Draws a pill-style tag with rounded edges."
      },
      "attribute": "pill",
      "reflect": true,
      "defaultValue": "false"
    },
    "clearable": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Makes the tag clearable."
      },
      "attribute": "clearable",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
}
