import { Component, h, Prop } from "@stencil/core";
import { getProps } from "../../utils/utils";
import { LinkButtonView } from "./sqm-link-button-view";
/**
 * @uiName Link Button
 * @validParents ["sqm-portal-container","div","sqm-divided-layout","template","sqm-tab","sqb-program-section","sqb-conditional-section"]
 * @exampleGroup Common Components
 * @example Link Button - <sqm-link-button link="https://www.example.com" open-in-new-tab="true">Click here</sqm-link-button>
 */
export class LinkButton {
  constructor() {
    /**
     * @uiName Open link in new tab
     */
    this.openInNewTab = false;
    /**
     * @uiName Button text
     * @uiType string
     */
    this.buttonText = "Click here";
  }
  render() {
    const onClick = () => {
      const url = this.link;
      const target = this.openInNewTab ? "_blank" : "_parent";
      window.open(url, target);
    };
    return (h(LinkButtonView, Object.assign({}, { ...getProps(this), onClick })));
  }
  static get is() { return "sqm-link-button"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "link": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": undefined,
            "name": "required"
          }, {
            "text": "Link",
            "name": "uiName"
          }],
        "text": "Enter the URL where you want your participants redirected. Example: https://www.example.com"
      },
      "attribute": "link",
      "reflect": false
    },
    "openInNewTab": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Open link in new tab",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "open-in-new-tab",
      "reflect": false,
      "defaultValue": "false"
    },
    "buttonText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": "Button text",
            "name": "uiName"
          }, {
            "text": "string",
            "name": "uiType"
          }],
        "text": ""
      },
      "attribute": "button-text",
      "reflect": false,
      "defaultValue": "\"Click here\""
    }
  }; }
}
//TODO: Write a hook to resolve ICU strings
