/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, attachShadowTemplate, FoundationProperty, coerceBoolean } from '@tylertech/forge-core';
import { ListItemAdapter } from './list-item-adapter';
import { ListItemFoundation } from './list-item-foundation';
import { LIST_ITEM_CONSTANTS } from './list-item-constants';
import { StateLayerComponent } from '../../state-layer';
import { FocusIndicatorComponent } from '../../focus-indicator';
import { WithElementInternals } from '../../core/mixins/internals/with-element-internals';
import { WithDefaultAria } from '../../core/mixins/internals/with-default-aria';
import { BaseComponent } from '../../core/base/base-component';
const template = '<template><div class=\"forge-list-item\" part=\"root\"><slot name=\"leading\"></slot><div class=\"text-container\" part=\"text-container\"><slot></slot><slot name=\"secondary-text\"></slot><slot name=\"tertiary-text\"></slot></div><slot name=\"trailing\"></slot></div></template>';
const styles = ':host{--_list-item-indent:var(--forge-list-item-indent, var(--forge-spacing-xxlarge, 48px));--_list-item-dense-indent:var(--forge-list-item-dense-indent, var(--forge-spacing-xxlarge, 48px));--_list-item-disabled-cursor:var(--forge-list-item-disabled-cursor, not-allowed)}:host{display:block;outline:0}:host([hidden]){display:none}.forge-list-item{--_list-item-background:var(--forge-list-item-background, transparent);--_list-item-shape:var(--forge-list-item-shape, 0);--_list-item-padding:var(--forge-list-item-padding, 0 var(--forge-spacing-medium, 16px));--_list-item-margin:var(--forge-list-item-margin, 0);--_list-item-height:var(--forge-list-item-height, 48px);--_list-item-dense-height:var(--forge-list-item-dense-height, 32px);--_list-item-cursor:var(--forge-list-item-cursor, pointer);--_list-item-gap:var(--forge-list-item-gap, var(--forge-spacing-large, 24px));--_list-item-text-color:var(--forge-list-item-text-color, var(--forge-theme-text-medium, rgba(0, 0, 0, 0.6)));--_list-item-text-font-size:var(--forge-list-item-text-font-size, var(--forge-typography-body2-font-size, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-body-font-size-scale, 1))));--_list-item-text-font-weight:var(--forge-list-item-text-font-weight, var(--forge-typography-body2-font-weight, 400));--_list-item-text-line-height:var(--forge-list-item-text-line-height, 1.5rem);--_list-item-selected-color:var(--forge-list-item-selected-color, var(--forge-theme-primary, #3f51b5));--_list-item-selected-opacity:var(--forge-list-item-selected-opacity, 0.08);--_list-item-selected-leading-color:var(--forge-list-item-selected-leading-color, var(--_list-item-selected-color));--_list-item-selected-trailing-color:var(--forge-list-item-selected-trailing-color, var(--_list-item-selected-color));--_list-item-selected-text-color:var(--forge-list-item-selected-text-color, var(--forge-theme-text-medium, rgba(0, 0, 0, 0.6)));--_list-item-disabled-opacity:var(--forge-list-item-disabled-opacity, 0.38);--_list-item-one-line-height:var(--forge-list-item-one-line-height, var(--_list-item-height));--_list-item-two-line-height:var(--forge-list-item-two-line-height, var(--forge-list-item-height, 72px));--_list-item-three-line-height:var(--forge-list-item-three-line-height, var(--forge-list-item-height, 88px));--_list-item-dense-one-line-height:var(--forge-list-item-dense-one-line-height, var(--_list-item-dense-height));--_list-item-dense-two-line-height:var(--forge-list-item-dense-two-line-height, var(--forge-list-item-dense-height, 56px));--_list-item-dense-three-line-height:var(--forge-list-item-dense-three-line-height, var(--forge-list-item-dense-height, 72px));--_list-item-dense-font-size:var(--forge-list-item-dense-font-size, 0.875rem);--_list-item-dense-gap:var(--forge-list-item-dense-gap, var(--forge-spacing-xsmall, 8px));--_list-item-leading-selected-color:var(--forge-list-item-leading-selected-color, var(--_list-item-selected-color));--_list-item-trailing-selected-color:var(--forge-list-item-trailing-selected-color, var(--_list-item-selected-color));--_list-item-wrap-padding:var(--forge-list-item-wrap-padding, var(--forge-spacing-xsmall, 8px) var(--forge-spacing-medium, 16px))}.forge-list-item{position:relative;display:-webkit-box;display:flex;gap:var(--_list-item-gap);-webkit-box-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;outline:0;text-decoration:none;border-radius:var(--_list-item-shape);-webkit-tap-highlight-color:transparent;background-color:var(--_list-item-background);height:var(--_list-item-height);min-height:var(--_list-item-height);padding:var(--_list-item-padding);margin:var(--_list-item-margin)}.forge-list-item.interactive{cursor:var(--_list-item-cursor)}.forge-list-item.disabled{cursor:var(--_list-item-disabled-cursor);opacity:var(--_list-item-disabled-opacity)}.forge-list-item.disabled ::slotted(button){cursor:var(--_list-item-disabled-cursor)}.anchor{position:absolute;inset:0}:host([two-line]) .forge-list-item{height:var(--_list-item-two-line-height);min-height:var(--_list-item-two-line-height)}:host([three-line]) .forge-list-item{height:var(--_list-item-three-line-height);min-height:var(--_list-item-three-line-height)}:host([dense]) .forge-list-item{--_list-item-gap:var(--_list-item-dense-gap);height:var(--_list-item-dense-one-line-height);min-height:var(--_list-item-dense-one-line-height)}:host([dense]) .text-container{font-size:var(--_list-item-dense-font-size)}:host([dense][indented]){-webkit-margin-start:var(--_list-item-dense-indent);margin-inline-start:var(--_list-item-dense-indent)}:host([dense][two-line]) .forge-list-item{height:var(--_list-item-dense-two-line-height);min-height:var(--_list-item-dense-two-line-height)}:host([dense][three-line]) .forge-list-item{height:var(--_list-item-dense-three-line-height);min-height:var(--_list-item-dense-three-line-height)}:host([selected]) .forge-list-item{color:var(--_list-item-selected-color)}:host([selected]) .forge-list-item::before{content:\"\";position:absolute;inset:0;border-radius:inherit;opacity:var(--_list-item-selected-opacity);background-color:var(--_list-item-selected-color)}:host([selected]) .forge-list-item ::slotted([slot=leading]),:host([selected]) .forge-list-item ::slotted([slot=trailing]){color:var(--_list-item-selected-color)}:host([selected]) .forge-list-item ::slotted([slot=leading]){color:var(--_list-item-leading-selected-color)}:host([selected]) .forge-list-item ::slotted([slot=trailing]){color:var(--_list-item-trailing-selected-color)}:host([selected]) .text-container{color:var(--_list-item-selected-color)}:host([selected]) forge-state-layer{--forge-state-layer-color:var(--_list-item-selected-color)}:host([indented]){-webkit-margin-start:var(--_list-item-indent);margin-inline-start:var(--_list-item-indent)}.text-container{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--forge-typography-body2-font-family, var(--forge-typography-font-family, \"Roboto\", sans-serif));letter-spacing:var(--forge-typography-body2-letter-spacing, .015625em);text-transform:var(--forge-typography-body2-text-transform,inherit);-webkit-text-decoration:var(--forge-typography-body2-text-decoration,inherit);text-decoration:var(--forge-typography-body2-text-decoration,inherit);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;-webkit-box-sizing:border-box;box-sizing:border-box;font-size:var(--_list-item-text-font-size);font-weight:var(--_list-item-text-font-weight);line-height:var(--_list-item-text-line-height);-webkit-box-flex:1;flex:1}slot[name=secondary-text]::slotted(*),slot[name=tertiary-text]::slotted(*){-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--forge-typography-body1-font-family, var(--forge-typography-font-family, \"Roboto\", sans-serif));font-size:var(--forge-typography-body1-font-size, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-body-font-size-scale, .875)));font-weight:var(--forge-typography-body1-font-weight,400);line-height:var(--forge-typography-body1-line-height, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-body-line-height-scale, 1.125)));letter-spacing:var(--forge-typography-body1-letter-spacing, .0357142857em);text-transform:var(--forge-typography-body1-text-transform,inherit);-webkit-text-decoration:var(--forge-typography-body1-text-decoration,inherit);text-decoration:var(--forge-typography-body1-text-decoration,inherit);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--_list-item-text-color);display:block}:host([selected]) slot[name=secondary-text]::slotted(*),:host([selected]) slot[name=tertiary-text]::slotted(*){color:var(--_list-item-selected-text-color)}::slotted(:is(button,[role=button][tabindex],[forge-list-item-button])){-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:var(--_list-item-cursor);border:none;padding-block:0;padding-inline:0;margin:0;-webkit-box-sizing:border-box;box-sizing:border-box;background:0 0;color:inherit;outline:0;font:inherit;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;text-align:inherit;letter-spacing:inherit;word-spacing:inherit;display:inline}::slotted(a){outline:0;color:inherit!important;text-decoration:none!important}::slotted([slot=leading]),::slotted([slot=trailing]){color:var(--_list-item-text-color);display:-webkit-inline-box;display:inline-flex;flex-shrink:0;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;fill:currentColor}:host(:not([noninteractive])) ::slotted(:is(forge-checkbox,forge-radio,forge-switch):is([slot=leading],[slot=trailing]):not([forge-ignore])){--forge-focus-indicator-display:none;--forge-state-layer-display:none}:host([selected]) ::slotted([slot=leading]){color:var(--_list-item-leading-selected-color)}:host([selected]) ::slotted([slot=trailing]){color:var(--_list-item-trailing-selected-color)}:host([wrap]) .forge-list-item{--_list-item-padding:var(--_list-item-wrap-padding);height:auto}:host([wrap]) .text-container{white-space:normal;overflow:visible;text-overflow:clip;line-height:normal}:host([wrap]) slot[name=secondary-text]::slotted(*),:host([wrap]) slot[name=tertiary-text]::slotted(*){white-space:normal;overflow:visible;text-overflow:clip;line-height:normal}forge-focus-indicator{z-index:1;--forge-focus-indicator-shape:var(--forge-shape-medium, 4px)}forge-state-layer{border-radius:inherit}';
const BaseClass = WithElementInternals(WithDefaultAria(BaseComponent));
/**
 * @tag forge-list-item
 *
 * @summary List items are individual rows of content inside of a list.
 *
 * @property {boolean} selected - Applies the selected state to the list item.
 * @property {boolean} active - Applies the active state to the list item by emulating its focused state.
 * @property {unknown} value - The unique value of the list item.
 * @property {boolean} dense - Applies the dense state to the list item.
 * @property {boolean} indented - Applies the indented state by adding margin to the start of the list item.
 * @property {boolean} twoLine - Sets the list item height to support at least two lines of text.
 * @property {boolean} threeLine - Sets the list item height to support at least three lines of text.
 * @property {boolean} wrap - Sets the list item to wrap its text content.
 * @property {boolean} noninteractive - Controls whether the list item will automatically attach itself to interactive slotted elements or not.
 *
 * @attribute {boolean} selected - Applies the selected state to the list item.
 * @attribute {boolean} active - Applies the active state to the list item by emulating its focused state.
 * @attribute {unknown} value - The unique value of the list item.
 * @attribute {boolean} dense - Applies the dense state to the list item.
 * @attribute {boolean} indented - Applies the indented state by adding margin to the start of the list item.
 * @attribute {boolean} two-line - Sets the list item height to support at least two lines of text.
 * @attribute {boolean} three-line - Sets the list item height to support at least three lines of text.
 * @attribute {boolean} wrap - Sets the list item to wrap its text content.
 * @attribute {boolean} noninteractive - Controls whether the list item will automatically attach itself to interactive slotted elements or not.
 *
 * @event {CustomEvent<IListItemSelectEventData>} forge-list-item-select - Fires when the list item is selected.
 *
 * @slot - The primary text.
 * @slot primary-text - The primary text. A named alias for the default slot.
 * @slot secondary-text - The secondary text.
 * @slot tertiary-text - The tertiary text.
 * @slot title - The title element. An alias for the primary-text slot for backwards compatibility.
 * @slot subtitle - The subtitle element. An alias for the secondary-text slot for backwards compatibility.
 * @slot tertiary-title - The tertiary title element. An alias for the tertiary-text slot for backwards compatibility.
 * @slot leading - The leading content.
 * @slot trailing - The trailing element.
 * @slot avatar - The avatar content.
 *
 * @csspart root - The root container element.
 * @csspart text-container - The container for the text content.
 * @csspart focus-indicator - The forwarded focus indicator's internal indicator element.
 * @csspart state-layer - The forwarded state layer's internal surface element.
 *
 * @cssproperty --forge-list-item-background - The background color.
 * @cssproperty --forge-list-item-shape - The shape of the list item.
 * @cssproperty --forge-list-item-padding - The padding inside of the container element.
 * @cssproperty --forge-list-item-wrap-padding - The padding inside of the container element when `wrap` is enabled.
 * @cssproperty --forge-list-item-margin - The margin around the host element.
 * @cssproperty --forge-list-item-height - The height of the container.
 * @cssproperty --forge-list-item-dense-height - The height when in the dense state.
 * @cssproperty --forge-list-item-indent - The margin inline state when in the indented state.
 * @cssproperty --forge-list-item-cursor - The cursor when interactive.
 * @cssproperty --forge-list-item-gap - The gap between the slotted content.
 * @cssproperty --forge-list-item-text-color - The text color of the text.
 * @cssproperty --forge-list-item-text-font-size - The font size of the text.
 * @cssproperty --forge-list-item-text-font-weight - The font weight of the text.
 * @cssproperty --forge-list-item-text-line-height - The line height of the text.
 * @cssproperty --forge-list-item-selected-color - The color when in the selected state.
 * @cssproperty --forge-list-item-opacity - The opacity of the background color when in the disabled state.
 * @cssproperty --forge-list-item-selected-leading-color - The color of the leading content when in the selected state.
 * @cssproperty --forge-list-item-selected-trailing-color - The color of the trailing content when in the selected state.
 * @cssproperty --forge-list-item-selected-text-color - The color of the text when in the selected state.
 * @cssproperty --forge-list-item-disabled-opacity - The opacity of the element when in the disabled state.
 * @cssproperty --forge-list-item-disabled-cursor - The cursor when in the disabled state.
 * @cssproperty --forge-list-item-one-line-height - The line height when in the one/single line state.
 * @cssproperty --forge-list-item-two-line-height - The line height when in the two line state.
 * @cssproperty --forge-list-item-three-line-height - The line height when in the three line state.
 * @cssproperty --forge-list-item-dense-one-line-height - The line height when in the dense one/single line state.
 * @cssproperty --forge-list-item-dense-two-line-height - The line height when in the dense two line state.
 * @cssproperty --forge-list-item-dense-three-line-height - The line height when in the dense three line state.
 * @cssproperty --forge-list-item-dense-font-size - The font size when in the dense state.
 * @cssproperty --forge-list-item-dense-indent - The margin inline state when in the dense indented state.
 * @cssproperty --forge-list-item-dense-gap - The gap between the slotted content when in the dense state.
 * @cssproperty --forge-list-item-leading-selected-color - The color of the leading content when in the selected state.
 * @cssproperty --forge-list-item-trailing-selected-color - The color of the trailing content when in the selected state.
 * @cssproperty --forge-list-item-avatar-background-color - The background color of the avatar container.
 * @cssproperty --forge-list-item-avatar-color - The foreground color of the avatar container.
 * @cssproperty --forge-list-item-avatar-shape - The shape of the avatar container.
 * @cssproperty --forge-list-item-avatar-size - The height & width of the avatar container.
 */
let ListItemComponent = class ListItemComponent extends BaseClass {
    static get observedAttributes() {
        return Object.values(LIST_ITEM_CONSTANTS.observedAttributes);
    }
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._adapter = new ListItemAdapter(this);
        this._foundation = new ListItemFoundation(this._adapter);
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case LIST_ITEM_CONSTANTS.observedAttributes.SELECTED:
                this.selected = coerceBoolean(newValue);
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.ACTIVE:
                this.active = coerceBoolean(newValue);
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.VALUE:
                this.value = newValue;
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.DENSE:
                this.dense = coerceBoolean(newValue);
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.INDENTED:
                this.indented = coerceBoolean(newValue);
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.TWO_LINE:
                this.twoLine = coerceBoolean(newValue);
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.THREE_LINE:
                this.threeLine = coerceBoolean(newValue);
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.WRAP:
                this.wrap = coerceBoolean(newValue);
                break;
            case LIST_ITEM_CONSTANTS.observedAttributes.NONINTERACTIVE:
                this.noninteractive = coerceBoolean(newValue);
                break;
        }
    }
};
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "selected", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "active", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "value", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "dense", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "indented", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "twoLine", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "threeLine", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "wrap", void 0);
__decorate([
    FoundationProperty()
], ListItemComponent.prototype, "noninteractive", void 0);
ListItemComponent = __decorate([
    CustomElement({
        name: LIST_ITEM_CONSTANTS.elementName,
        dependencies: [
            StateLayerComponent,
            FocusIndicatorComponent
        ]
    })
], ListItemComponent);
export { ListItemComponent };
