import { __decorate } from "tslib";
import { nothing } from 'lit';
import { LitElement, html } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import styles from './nile-loader.css';
import { classMap } from 'lit/directives/class-map.js';
let NileLoader = class NileLoader extends LitElement {
    constructor() {
        super(...arguments);
        this.propHeight = '';
        this.propWidth = '';
        this.label = '';
        this.size = 'lg';
        this.margin = '';
        this.variant = 'v1';
        this.color = 'var(--nile-colors-primary-600,var(--ng-colors-fg-brand-primary-600))';
    }
    connectedCallback() {
        super.connectedCallback();
        this.setSvgDimensions();
        if (this.variant == "v1" && this.color == "var(--nile-colors-primary-600,var(--ng-colors-fg-brand-primary-600))") {
            this.color = "var(--nile-colors-blue-500,var(--ng-colors-fg-brand-primary-600))";
        }
    }
    /**
     * Sets circular loader's dimension.
     * If either height or width is absent the dimensions defaults to dimension based on size variant
     */
    setSvgDimensions() {
        if (!parseInt(this.propHeight) || !parseInt(this.propWidth)) {
            switch (this.size) {
                case 'sm':
                    this.height = '32';
                    this.width = '32';
                    break;
                case 'md':
                    this.height = '48';
                    this.width = '48';
                    break;
                case 'lg':
                    this.height = '56';
                    this.width = '56';
                    break;
                default:
                    this.height = '64';
                    this.width = '64';
                    break;
            }
        }
        else {
            this.height = this.propHeight;
            this.width = this.propWidth;
        }
    }
    render() {
        return html `
    <div class="loader__container" part="loader-container" class=${classMap({
            "loader__container": true,
            "loader__container--sm": this.size == 'sm',
            "loader__container--md": this.size == 'md',
            "loader__container--lg": this.size == 'lg',
            "loader__container--xl": this.size == 'xl'
        })}>
      <div part="svg-container" class=${classMap({ "svg__container": this.variant !== 'v1' })}>${this.getVariant()}</div>
      ${!this.label ? nothing :
            html `<div part="loader-label" class="loader__label">${this.label}</div>`}
    </div>
    `;
    }
    getVariant() {
        switch (this.variant) {
            case 'v1':
                return this.renderV1();
            case 'v2':
                return this.renderV2();
            case 'v3':
                return this.renderV3();
            default:
                return this.renderV1();
        }
    }
    renderV1() {
        return html `
      <div
        style="width: ${this.width}px; 
          height: ${this.height}px; 
          background-size: ${this.width}px; 
          color: ${this.color};
          margin: ${this.margin}"
        class="nile-loader__v1"
      ></div>
    `;
    }
    renderV2() {
        return html `
      <svg
        class="nile-loader__v2"
        width="${this.width}"
        height="${this.height}"
        viewBox="0 0 32 32"
        fill="none"
        xmlns="http://www.w3.org/2000/svg"
      >
        <g id="Loading circle">
          <path
            id="Background"
            d="M30 16C30 17.8385 29.6379 19.659 28.9343 21.3576C28.2308 23.0561 27.1995 24.5995 25.8995 25.8995C24.5995 27.1995 23.0561 28.2307 21.3576 28.9343C19.659 29.6379 17.8385 30 16 30C14.1615 30 12.341 29.6379 10.6424 28.9343C8.94387 28.2307 7.40052 27.1995 6.1005 25.8995C4.80048 24.5995 3.76925 23.0561 3.06569 21.3576C2.36212 19.659 2 17.8385 2 16C2 14.1615 2.36212 12.341 3.06569 10.6424C3.76926 8.94387 4.80049 7.40052 6.10051 6.1005C7.40053 4.80048 8.94388 3.76925 10.6424 3.06568C12.341 2.36212 14.1615 2 16 2C17.8385 2 19.659 2.36212 21.3576 3.06569C23.0561 3.76926 24.5995 4.80049 25.8995 6.10051C27.1995 7.40053 28.2308 8.94388 28.9343 10.6424C29.6379 12.341 30 14.1615 30 16Z"
            stroke="var(--nile-colors-dark-200, var(--ng-colors-bg-tertiary))"
            stroke-width="4"
            stroke-linecap="round"
            stroke-linejoin="round"
          />
          <path
            id="Line"
            d="M16 2C17.8385 2 19.659 2.36212 21.3576 3.06569C23.0561 3.76925 24.5995 4.80049 25.8995 6.10051C27.1995 7.40053 28.2308 8.94388 28.9343 10.6424C29.6379 12.341 30 14.1615 30 16"
            stroke="${this.color}"
            stroke-width="4"
            stroke-linecap="round"
            stroke-linejoin="round"
          />
        </g>
      </svg>
    `;
    }
    renderV3() {
        return html `
      <svg
        class="nile-loader__v3"
        width="${this.width}"
        height="${this.height}"
        viewBox="0 0 32 32"
        fill="none"
        xmlns="http://www.w3.org/2000/svg"
      >
        <g id="Loading circle">
          <path
            id="Background"
            d="M30 16C30 17.8385 29.6379 19.659 28.9343 21.3576C28.2308 23.0561 27.1995 24.5995 25.8995 25.8995C24.5995 27.1995 23.0561 28.2307 21.3576 28.9343C19.659 29.6379 17.8385 30 16 30C14.1615 30 12.341 29.6379 10.6424 28.9343C8.94387 28.2307 7.40052 27.1995 6.1005 25.8995C4.80048 24.5995 3.76925 23.0561 3.06569 21.3576C2.36212 19.659 2 17.8385 2 16C2 14.1615 2.36212 12.341 3.06569 10.6424C3.76926 8.94387 4.80049 7.40052 6.10051 6.1005C7.40053 4.80048 8.94388 3.76925 10.6424 3.06568C12.341 2.36212 14.1615 2 16 2C17.8385 2 19.659 2.36212 21.3576 3.06569C23.0561 3.76926 24.5995 4.80049 25.8995 6.10051C27.1995 7.40053 28.2308 8.94388 28.9343 10.6424C29.6379 12.341 30 14.1615 30 16L30 16Z"
            stroke="white"
            stroke-width="4"
            stroke-linecap="round"
            stroke-linejoin="round"
          />
          <path
            id="Line"
            d="M6.10051 6.1005C7.66275 4.53826 9.57255 3.36793 11.6738 2.68521C13.775 2.00248 16.0079 1.82675 18.1901 2.17236C20.3722 2.51798 22.4416 3.37514 24.229 4.67376C26.0164 5.97238 27.4711 7.67559 28.4741 9.64414C29.4771 11.6127 30 13.7907 30 16C30 18.2093 29.4771 20.3873 28.4741 22.3559C27.4711 24.3244 26.0164 26.0276 24.229 27.3262C22.4416 28.6249 20.3722 29.482 18.1901 29.8276"
            stroke="${this.color}"
            stroke-width="4"
            stroke-linecap="round"
            stroke-linejoin="round"
          />
        </g>
      </svg>
    `;
    }
};
NileLoader.styles = styles;
__decorate([
    property({ type: String, attribute: 'height' })
], NileLoader.prototype, "propHeight", void 0);
__decorate([
    property({ type: String, attribute: 'width' })
], NileLoader.prototype, "propWidth", void 0);
__decorate([
    property({ type: String })
], NileLoader.prototype, "label", void 0);
__decorate([
    property({ type: String })
], NileLoader.prototype, "size", void 0);
__decorate([
    property({ type: String })
], NileLoader.prototype, "margin", void 0);
__decorate([
    property({ type: String })
], NileLoader.prototype, "variant", void 0);
__decorate([
    property({ type: String })
], NileLoader.prototype, "color", void 0);
NileLoader = __decorate([
    customElement('nile-loader')
], NileLoader);
export { NileLoader };
//# sourceMappingURL=nile-loader.js.map