import { h } from "@stencil/core";
import { setColor } from "../../utils/utils";
import { launch } from "@pine-ds/icons/icons";
/**
 * @part link - Link element styles.
 * @slot (default) - Text content placed between the opening and closing tags. If no text is provided, the **href** will be used as a fallback.
 */
export class PdsLink {
    constructor() {
        /**
         * Determines whether the link should open in a new tab.
         * @defaultValue false
         * @deprecated Consider using the `target` prop for more control. This prop will be maintained for backward compatibility.
         */
        this.external = false;
        /**
         * Sets the link variant styles.
         * @defaultValue inline
         */
        this.variant = 'inline';
        /**
         * The font size of the link's text.
         * @defaultValue lg
         */
        this.fontSize = 'lg';
    }
    classNames() {
        const classNames = ['pds-link'];
        if (this.fontSize) {
            classNames.push('pds-link--' + this.fontSize);
        }
        if (this.variant) {
            classNames.push('pds-link--' + this.variant);
        }
        return classNames.join(' ');
    }
    setLinkStyles() {
        if (!this.color)
            return;
        const linkColors = {
            secondary: 'var(--pine-color-text-primary)',
            accent: 'var(--pine-color-accent)',
            danger: 'var(--pine-color-danger)',
        };
        const linkStyles = setColor(this.color, linkColors);
        return linkStyles;
    }
    render() {
        const targetValue = this.target || (this.external ? '_blank' : undefined);
        const showExternalIcon = this.external;
        const relValue = targetValue === '_blank' ? 'noopener noreferrer' : undefined;
        return (h("a", { key: '8ab68ceb91a4c7b155a4ae54d2cb421af4d0eec1', class: this.classNames(), download: this.download, href: this.href, id: this.componentId, part: "link", target: targetValue, rel: relValue, style: this.setLinkStyles() }, h("slot", { key: 'b90dc967867a3b765d632c16458236e6e4ccf97e' }, this.href), showExternalIcon &&
            h("pds-icon", { key: 'ebffdba1a21f7b0f5730608ec5eb88519ee79d1b', icon: launch, size: this.fontSize })));
    }
    static get is() { return "pds-link"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["pds-link.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pds-link.css"]
        };
    }
    static get properties() {
        return {
            "color": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Sets the link color."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "color"
            },
            "download": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Prompts the user to save the linked URL instead of navigating to it.\nIt can be used without a value to download with the default filename,\nor with a string value to suggest a specific filename for the download."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "download"
            },
            "componentId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "A unique identifier used for the underlying component `id` attribute."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "component-id"
            },
            "external": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "false"
                        }, {
                            "name": "deprecated",
                            "text": "Consider using the `target` prop for more control. This prop will be maintained for backward compatibility."
                        }],
                    "text": "Determines whether the link should open in a new tab."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "external",
                "defaultValue": "false"
            },
            "target": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'_blank' | '_self' | '_parent' | '_top'",
                    "resolved": "\"_blank\" | \"_parent\" | \"_self\" | \"_top\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "undefined"
                        }, {
                            "name": "example",
                            "text": "<pds-link href=\"https://example.com\" target=\"_blank\">Opens in new tab</pds-link>"
                        }],
                    "text": "Specifies where to open the linked document."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "target"
            },
            "variant": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'inline' | 'plain'",
                    "resolved": "\"inline\" | \"plain\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "inline"
                        }],
                    "text": "Sets the link variant styles."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "variant",
                "defaultValue": "'inline'"
            },
            "fontSize": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'sm' | 'md' | 'lg'",
                    "resolved": "\"lg\" | \"md\" | \"sm\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "lg"
                        }],
                    "text": "The font size of the link's text."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "font-size",
                "defaultValue": "'lg'"
            },
            "href": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The hyperlink's destination URL. If no text is provided in the custom slot, the href will be used."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "href"
            }
        };
    }
}
//# sourceMappingURL=pds-link.js.map
