/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, FoundationProperty, attachShadowTemplate, coerceBoolean } from '@tylertech/forge-core';
import { BaseComponent } from '../core';
import { LabelAdapter } from './label-adapter';
import { LABEL_CONSTANTS } from './label-constants';
import { LabelFoundation } from './label-foundation';
const template = '<template><slot></slot></template>';
const style = ':host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--forge-typography-label1-font-family, var(--forge-typography-font-family, \"Roboto\", sans-serif));font-size:var(--forge-typography-label1-font-size, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-label-font-size-scale, .75)));font-weight:var(--forge-typography-label1-font-weight,400);line-height:var(--forge-typography-label1-line-height, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-label-line-height-scale, 1.25)));letter-spacing:var(--forge-typography-label1-letter-spacing, .0357142857em);text-transform:var(--forge-typography-label1-text-transform,inherit);-webkit-text-decoration:var(--forge-typography-label1-text-decoration,inherit);text-decoration:var(--forge-typography-label1-text-decoration,inherit);display:inline-block;cursor:default}:host([hidden]){display:none}';
/**
 * @tag forge-label
 *
 * @summary The Forge Label component is used to associate a text label with a compatible Forge
 * component.
 *
 * @property {string | null | undefined} for - The id of the associated element.
 * @property {HTMLElement | null | undefined} forElement - The associated element.
 * @property {HTMLElement | null | undefined} clickTarget - The element that a click should be simulated on. If not defined clicks act on the associated element.
 * @property {boolean} dynamic - Propagates changes in the label's text content to the associated element.
 * @property {boolean} nonInteractive - Removes click handling from the label.
 * @property {boolean} legend - Whether or not the label should be associated with an ancestor element.
 *
 * @attribute {string} for - The id of the associated form component.
 * @attribute {boolean} dynamic - Propagates changes in the label's text content to the associated element.
 * @attribute {boolean} non-interactive - Removes click handling from the label.
 * @attribute {boolean} legend - Whether or not the label should be associated with an ancestor element.
 *
 * @method update - Updates the targetted element with the label's current text content.
 *
 * @csspart label - Styles the label's root element.
 */
let LabelComponent = class LabelComponent extends BaseComponent {
    static get observedAttributes() {
        return Object.values(LABEL_CONSTANTS.observedAttributes);
    }
    constructor() {
        super();
        attachShadowTemplate(this, template, style);
        this._foundation = new LabelFoundation(new LabelAdapter(this));
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case LABEL_CONSTANTS.attributes.FOR:
                this.for = newValue;
                break;
            case LABEL_CONSTANTS.attributes.DYNAMIC:
                this.dynamic = coerceBoolean(newValue);
                break;
            case LABEL_CONSTANTS.attributes.NON_INTERACTIVE:
                this.nonInteractive = coerceBoolean(newValue);
                break;
            case LABEL_CONSTANTS.attributes.LEGEND:
                this.legend = coerceBoolean(newValue);
                break;
        }
    }
    /**
     * Updates the targetted element with the label's current text content.
     */
    update() {
        this._foundation.update();
    }
};
__decorate([
    FoundationProperty()
], LabelComponent.prototype, "for", void 0);
__decorate([
    FoundationProperty()
], LabelComponent.prototype, "forElement", void 0);
__decorate([
    FoundationProperty()
], LabelComponent.prototype, "clickTarget", void 0);
__decorate([
    FoundationProperty()
], LabelComponent.prototype, "dynamic", void 0);
__decorate([
    FoundationProperty()
], LabelComponent.prototype, "nonInteractive", void 0);
__decorate([
    FoundationProperty()
], LabelComponent.prototype, "legend", void 0);
LabelComponent = __decorate([
    CustomElement({
        name: LABEL_CONSTANTS.elementName
    })
], LabelComponent);
export { LabelComponent };
