import { Host, h } from "@stencil/core";
import { cls } from "../../utils/helpers";
export class XButton {
    constructor() {
        this.icon = undefined;
        this.iconAlign = 'left';
        this.color = 'default';
        this.type = 'button';
        this.href = undefined;
        this.loading = false;
        this.disabled = false;
        this.block = false;
        this.small = false;
        this.isFocused = undefined;
    }
    /**
     * This called on input field is unfocused
     */
    onBlurElement() {
        this.isFocused = false;
    }
    /**
     * This called on input field is focused
     */
    onFocusElement() {
        this.isFocused = true;
    }
    /**
     * Listen for keyboard events for confirmation
     */
    handleKeyDown(ev) {
        if ([' ', 'Enter'].includes(ev.key)) {
            this.el.querySelector('a, button').click();
        }
    }
    /**
     * Render element
     */
    render() {
        var _a;
        return h(Host, { key: '1ce8b2c545f032f3dc571be912b53c29b8381765', tabindex: "0", class: cls('fieldset-item', `button-${this.color}`, {
                'button-block': this.block,
                'button-disabled': this.disabled,
                'button-loading': this.loading,
                'button-focus': this.isFocused,
                'button-small': this.small,
            }) }, ((_a = this.href) === null || _a === void 0 ? void 0 : _a.length) ?
            h("a", { href: this.href, onBlur: () => this.onBlurElement(), onFocus: () => this.onFocusElement() }, h("slot", { name: "left" }), this.icon && this.iconAlign == 'left' && h("x-icon", { name: this.icon, size: "1.5em" }), h("div", { class: "button-slot" }, h("slot", null)), this.icon && this.iconAlign == 'right' && h("x-icon", { name: this.icon, size: "1.5em" }), h("slot", { name: "right" }), this.loading && h("x-animate", { name: "fade-in-left", autoPlay: true }, h("div", { class: "loading-indicator" }, h("i", { class: "loading-spinner" })))) :
            h("button", { type: this.type, disabled: this.disabled, onBlur: () => this.onBlurElement(), onFocus: () => this.onFocusElement() }, h("slot", { name: "left" }), this.icon && this.iconAlign == 'left' && h("x-icon", { name: this.icon, size: "1.5em" }), h("div", { class: "button-slot" }, h("slot", null)), this.icon && this.iconAlign == 'right' && h("x-icon", { name: this.icon, size: "1.5em" }), h("slot", { name: "right" }), this.loading && h("x-animate", { name: "fade-in-left", autoPlay: true }, h("div", { class: "loading-indicator" }, h("i", { class: "loading-spinner" })))));
    }
    static get is() { return "x-button"; }
    static get originalStyleUrls() {
        return {
            "$": ["./style.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["style.css"]
        };
    }
    static get properties() {
        return {
            "icon": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "IconType",
                    "resolved": "\"help\" | \"profile\" | \"watch\" | \"filter\" | \"map\" | \"info\" | \"error\" | \"document\" | \"data\" | \"label\" | \"link\" | \"menu\" | \"table\" | \"video\" | \"circle\" | \"image\" | \"marker\" | \"stop\" | \"download\" | \"sync\" | \"cursor\" | \"end\" | \"rotate\" | \"testing\" | \"copy\" | \"unknown\" | \"history\" | \"close\" | \"print\" | \"key\" | \"danger\" | \"tv\" | \"search\" | \"message\" | \"3ds-alt\" | \"3ds\" | \"abbreviation\" | \"activate\" | \"activity\" | \"allergies\" | \"answer\" | \"app-store\" | \"apple-pay\" | \"apple\" | \"ask-question\" | \"auth-capture\" | \"aws\" | \"back\" | \"backclear\" | \"badge-fingerprint\" | \"badge-package\" | \"badge-shield\" | \"bank-account\" | \"bank-cards\" | \"bank\" | \"barcode\" | \"basket\" | \"bin-card\" | \"bitcoin\" | \"bluetooth\" | \"bookmark\" | \"bot\" | \"bowl\" | \"brain\" | \"browser-chrome\" | \"browser-default\" | \"browser-edge\" | \"browser-firefox\" | \"browser-ie\" | \"browser-opera\" | \"browser-safari\" | \"bug\" | \"calendar-event\" | \"calendar\" | \"call-list\" | \"car\" | \"card-amex\" | \"card-banrural\" | \"card-diners_club\" | \"card-discover\" | \"card-jcb\" | \"card-mastercard\" | \"card-nfc\" | \"card-unionpay\" | \"card-visa\" | \"card-wallet\" | \"cash-register\" | \"certificate\" | \"chat\" | \"chatbot\" | \"chatgpt\" | \"check-circle\" | \"check\" | \"checkmark\" | \"chip-card\" | \"chip\" | \"clean\" | \"clipboard\" | \"clock\" | \"cloud-offline\" | \"cloud\" | \"coins\" | \"comment-3ds\" | \"comment-afs\" | \"comment-avs\" | \"comment-cavv\" | \"comment-cavvf\" | \"comment-cavvw\" | \"comment-cvn\" | \"comment-error\" | \"comment-info\" | \"comment-pos\" | \"comment-val\" | \"confectionery\" | \"configuration\" | \"connected\" | \"console\" | \"contactless-payment\" | \"credit-card\" | \"crop\" | \"crown\" | \"cube\" | \"cubes\" | \"currency-settings\" | \"cut-paper\" | \"cut\" | \"cutlery\" | \"dark-mode\" | \"dashboard\" | \"debit-card\" | \"decrease-decimal\" | \"delivered-mail\" | \"desktop\" | \"device-android\" | \"device-ios\" | \"device-linux\" | \"device-mac\" | \"device-other\" | \"device-ubuntu\" | \"device-windows\" | \"discount\" | \"divide\" | \"double-tick\" | \"down\" | \"download-report\" | \"drag-reorder\" | \"drop\" | \"dropdown\" | \"edit\" | \"estimate\" | \"eth\" | \"exchange-bitcoin\" | \"exchange-ethereum\" | \"exchange\" | \"external-link\" | \"face-id\" | \"facebook\" | \"file-archive\" | \"file-document\" | \"file-image\" | \"file-video\" | \"file\" | \"fill-color\" | \"fill-drip\" | \"filter-alt\" | \"finance-document\" | \"financial-changes\" | \"fingerprint\" | \"flag\" | \"format-blockquote\" | \"format-bold\" | \"format-code\" | \"format-header-1\" | \"format-header-2\" | \"format-header-3\" | \"format-header\" | \"format-icon\" | \"format-italic\" | \"format-line\" | \"format-paragraph\" | \"format-quote\" | \"format-redo\" | \"format-strikethrough\" | \"format-table\" | \"format-tip\" | \"format-underline\" | \"format-undo\" | \"forward\" | \"geo\" | \"giftcard\" | \"git\" | \"google-play\" | \"google\" | \"graph\" | \"hand\" | \"handcart\" | \"home-safety\" | \"home\" | \"hosted-checkout\" | \"hot-price\" | \"hourglass\" | \"idea\" | \"identification-documents\" | \"image-document\" | \"image-gallery\" | \"in-transit\" | \"inactive-state\" | \"increase-decimal\" | \"insert-money\" | \"instashop\" | \"invisible\" | \"invoice\" | \"job\" | \"js-squared\" | \"kitchen\" | \"lambda\" | \"lang-angular\" | \"lang-bash\" | \"lang-capacitor\" | \"lang-code\" | \"lang-cpp\" | \"lang-csharp\" | \"lang-css\" | \"lang-flutter\" | \"lang-go\" | \"lang-html\" | \"lang-ini\" | \"lang-ionic\" | \"lang-java\" | \"lang-js\" | \"lang-json\" | \"lang-kotlin\" | \"lang-laravel\" | \"lang-node-js\" | \"lang-objectivec\" | \"lang-php\" | \"lang-python\" | \"lang-react\" | \"lang-ruby\" | \"lang-sql\" | \"lang-swift\" | \"lang-typescript\" | \"lang-visual-basic\" | \"lang-vue\" | \"lang-xamarin\" | \"lang-xml\" | \"left\" | \"legal\" | \"licence\" | \"light-mode\" | \"list-bullet\" | \"list-numbered\" | \"list-todo\" | \"list\" | \"lock\" | \"love-fill\" | \"love\" | \"magic\" | \"mail-bulk\" | \"mail\" | \"mailbox-full\" | \"mailbox\" | \"mailing\" | \"mediaplayer\" | \"merchant-setting\" | \"merchant\" | \"mic\" | \"mindmap\" | \"minus-circle\" | \"minus\" | \"mobile\" | \"modules\" | \"money-time\" | \"mouse-scrolling\" | \"move\" | \"network-cable\" | \"network-group\" | \"network\" | \"nfc-checkpoint\" | \"nfc-tag\" | \"nfc\" | \"no-synchronize\" | \"node-js\" | \"notifications\" | \"october\" | \"offline\" | \"onboarding\" | \"online-shop\" | \"online-support\" | \"open-box\" | \"options\" | \"package-tag\" | \"package\" | \"paint-brush\" | \"palette\" | \"parking-meter\" | \"parking-prohibited\" | \"parking\" | \"pause\" | \"paycheque\" | \"pending\" | \"percentage\" | \"petition\" | \"phone\" | \"pie-chart-alt\" | \"pie-chart\" | \"pin\" | \"platform-edit\" | \"play\" | \"plus-circle\" | \"plus\" | \"power-off\" | \"prestashop\" | \"prize\" | \"qr\" | \"quickbooks\" | \"receipt-added\" | \"receipt-approved\" | \"receipt-declined\" | \"receipt-deleted\" | \"receipt-ticket\" | \"receipt\" | \"receive-cash\" | \"register\" | \"report\" | \"resend-mail\" | \"restaurant-menu\" | \"restaurant\" | \"rice-bowl\" | \"right\" | \"room-service\" | \"rotate-left\" | \"rotate-right\" | \"ruler\" | \"safe\" | \"sale\" | \"save-pdf\" | \"save\" | \"schedule\" | \"search-folder\" | \"select-circle\" | \"send\" | \"separate-document\" | \"settings-alt\" | \"settings\" | \"share\" | \"shield-lock\" | \"shield-warning\" | \"shield\" | \"ship\" | \"shipping-product\" | \"shopify\" | \"shopping-bag\" | \"shopping-cart\" | \"shopping\" | \"sim-card-sensor\" | \"sim-card\" | \"sound\" | \"sparkling\" | \"speaker\" | \"split\" | \"star-fill\" | \"star\" | \"stocks-growth\" | \"suspend\" | \"table-alt\" | \"tag\" | \"tags\" | \"test-tube\" | \"themes\" | \"three-ways\" | \"ticket\" | \"timer\" | \"toggle-off\" | \"toggle-on\" | \"toolkit\" | \"trash-disable\" | \"trash\" | \"truck\" | \"unavailable\" | \"unicorn\" | \"up-down-arrow\" | \"up\" | \"update\" | \"upload-cloud\" | \"upload\" | \"usb-stick\" | \"user-activity\" | \"user-admin\" | \"user-calendar\" | \"user-female\" | \"user-group\" | \"user-guide\" | \"user-male\" | \"user-permissions\" | \"user-tag\" | \"user\" | \"users-settings\" | \"vault\" | \"velocity\" | \"versions\" | \"visible\" | \"vtex\" | \"wallet\" | \"webhook\" | \"whatsapp\" | \"wi-fi\" | \"wired-network\" | \"withdraw\" | \"woocommerce\" | \"workflow\"",
                    "references": {
                        "IconType": {
                            "location": "import",
                            "path": "../../constants/icons",
                            "id": "src/constants/icons.ts::IconType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element icon name"
                },
                "attribute": "icon",
                "reflect": false
            },
            "iconAlign": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ButtonAlignType",
                    "resolved": "\"left\" | \"right\"",
                    "references": {
                        "ButtonAlignType": {
                            "location": "local",
                            "path": "/opt/atlassian/pipelines/agent/build/src/components/x-button/component.tsx",
                            "id": "src/components/x-button/component.tsx::ButtonAlignType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element icon aligment"
                },
                "attribute": "icon-align",
                "reflect": false,
                "defaultValue": "'left'"
            },
            "color": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ColorType",
                    "resolved": "\"accent\" | \"blue\" | \"brown\" | \"cyan\" | \"danger\" | \"default\" | \"green\" | \"indigo\" | \"info\" | \"orange\" | \"pink\" | \"primary\" | \"purple\" | \"red\" | \"stone\" | \"success\" | \"teal\" | \"warning\" | \"yellow\"",
                    "references": {
                        "ColorType": {
                            "location": "import",
                            "path": "../../constants/colors",
                            "id": "src/constants/colors.ts::ColorType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element color name"
                },
                "attribute": "color",
                "reflect": false,
                "defaultValue": "'default'"
            },
            "type": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ButtonType",
                    "resolved": "\"button\" | \"reset\" | \"submit\"",
                    "references": {
                        "ButtonType": {
                            "location": "local",
                            "path": "/opt/atlassian/pipelines/agent/build/src/components/x-button/component.tsx",
                            "id": "src/components/x-button/component.tsx::ButtonType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element button type"
                },
                "attribute": "type",
                "reflect": false,
                "defaultValue": "'button'"
            },
            "href": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element URL path for `<a>` type button"
                },
                "attribute": "href",
                "reflect": false
            },
            "loading": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element loading state"
                },
                "attribute": "loading",
                "reflect": false,
                "defaultValue": "false"
            },
            "disabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element disabled state"
                },
                "attribute": "disabled",
                "reflect": false,
                "defaultValue": "false"
            },
            "block": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element fullwidth block style"
                },
                "attribute": "block",
                "reflect": false,
                "defaultValue": "false"
            },
            "small": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element small size"
                },
                "attribute": "small",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "isFocused": {}
        };
    }
    static get elementRef() { return "el"; }
    static get listeners() {
        return [{
                "name": "keydown",
                "method": "handleKeyDown",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
