/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { customElement, attachShadowTemplate, coerceBoolean, coreProperty, ensureInputElement } from '@tylertech/forge-core';
import { tylIconSearch } from '@tylertech/tyler-icons/standard';
import { AppBarSearchCore } from './app-bar-search-core';
import { AppBarSearchAdapter } from './app-bar-search-adapter';
import { APP_BAR_SEARCH_CONSTANTS } from './app-bar-search-constants';
import { FocusIndicatorComponent } from '../../focus-indicator';
import { IconComponent, IconRegistry } from '../../icon';
import { BaseComponent } from '../../core/base/base-component';
const template = '<template><div class=\"forge-app-bar-search\" part=\"root\"><slot name=\"start\"><forge-icon name=\"search\" class=\"icon\" part=\"icon\"></forge-icon></slot><slot name=\"input\"></slot><slot name=\"end\"></slot></div></template>';
const styles = ':host{display:block}:host([hidden]){display:none}.forge-app-bar-search{--_app-bar-search-color:var(--forge-app-bar-search-color, currentColor);--_app-bar-search-height:var(--forge-app-bar-search-height, 36px);--_app-bar-search-padding:var(--forge-app-bar-search-padding, 8px);--_app-bar-search-shape:var(--forge-app-bar-search-shape, var(--forge-shape-small, 2px));--_app-bar-search-gap:var(--forge-app-bar-search-gap, 4px);--_app-bar-search-input-placeholder-color:var(--forge-app-bar-search-input-placeholder-color, var(--_app-bar-search-color));--_app-bar-search-input-placeholder-opacity:var(--forge-app-bar-search-input-placeholder-opacity, 0.38);--_app-bar-search-background-color:var(--forge-app-bar-search-background-color, var(--_app-bar-search-color));--_app-bar-search-background-color-opacity:var(--forge-app-bar-search-background-color-opacity, 0.08);--_app-bar-search-border-color:var(--forge-app-bar-search-border-color, var(--_app-bar-search-color));--_app-bar-search-border-opacity:var(--forge-app-bar-search-border-opacity, 0.54);--_app-bar-search-border-hover-opacity:var(--forge-app-bar-search-border-hover-opacity, 0.87);--_app-bar-search-transition-duration:var(--forge-app-bar-search-transition-duration, var(--forge-animation-duration-short3, 150ms));--_app-bar-search-transition-timing-function:var(--forge-app-bar-search-transition-timing-function, var(--forge-animation-easing-standard, cubic-bezier(0.2, 0, 0, 1)))}.forge-app-bar-search{position:relative;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-flex:1;flex:1 1 auto;gap:var(--_app-bar-search-gap);height:var(--_app-bar-search-height);width:100%;padding-inline:var(--_app-bar-search-padding);-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:var(--_app-bar-search-shape)}.forge-app-bar-search:hover::after{opacity:var(--_app-bar-search-border-hover-opacity)}.forge-app-bar-search::before{content:\"\";position:absolute;inset:0;pointer-events:none;background-color:var(--_app-bar-search-background-color);opacity:var(--_app-bar-search-background-color-opacity)}.forge-app-bar-search::after{content:\"\";position:absolute;inset:0;pointer-events:none;opacity:var(--_app-bar-search-border-opacity);border-radius:var(--_app-bar-search-shape);outline:1px solid var(--_app-bar-search-border-color);-webkit-transition-property:opacity;transition-property:opacity;-webkit-transition-duration:var(--_app-bar-search-transition-duration);transition-duration:var(--_app-bar-search-transition-duration);-webkit-transition-timing-function:var(--_app-bar-search-transition-timing-function);transition-timing-function:var(--_app-bar-search-transition-timing-function)}:host([disabled]){cursor:not-allowed}:host([disabled]) .forge-app-bar-search{pointer-events:none;opacity:38%}:host([disabled]) ::slotted(input){pointer-events:none}forge-focus-indicator{--forge-focus-indicator-color:currentColor;--forge-focus-indicator-outward-offset:0px}::slotted(input){-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));font-size:var(--forge-typography-body2-font-size, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-body-font-size-scale, 1)));font-weight:var(--forge-typography-body2-font-weight,400);line-height:var(--forge-typography-body2-line-height, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-body-line-height-scale, 1.375)));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);display:block;overflow:hidden;background:0 0;color:currentColor;border:none;width:100%;margin:0;outline:0}::slotted(input)::-webkit-input-placeholder{color:currentColor;opacity:var(--_app-bar-search-input-placeholder-opacity)}::slotted(input)::-moz-placeholder{color:currentColor;opacity:var(--_app-bar-search-input-placeholder-opacity)}::slotted(input):-ms-input-placeholder{color:currentColor;opacity:var(--_app-bar-search-input-placeholder-opacity)}::slotted(input)::-ms-input-placeholder{color:currentColor;opacity:var(--_app-bar-search-input-placeholder-opacity)}::slotted(input)::placeholder{color:currentColor;opacity:var(--_app-bar-search-input-placeholder-opacity)}';
/**
 * @tag forge-app-bar-search
 *
 * @slot - The default (unnamed) slot is where child `<input>` elements will be placed.
 * @slot action - Places actions at the end of the input.
 *
 * @attribute {boolean} [disabled=false] - A boolean attribute that, if present, indicates that the input should be disabled.
 * @attribute {string} value - The value of the input.
 * @attribute {string} placeholder - The placeholder text of the input.
 *
 * @property {boolean} [disabled=false] - A boolean property that, if true, indicates that the input should be disabled.
 * @property {string} value - The value of the input.
 * @property {string} placeholder - The placeholder text of the input.
 *
 * @csspart root - The root element
 * @csspart container - The input container element.
 * @csspart icon-container - The icon container element.
 * @csspart icon - The <forge-icon> element.
 * @csspart context - The context container element.
 * @csspart context-divider - The context divider element.
 * @csspart context-button - The context button element.
 * @csspart context-button-text - The context button text element.
 * @csspart context-button-icon - The context button icon element.
 * @csspart global-icon-container - The global icon container element.
 * @csspart global-icon - The global icon <forge-icon> element.
 * @csspart actions-container - The action container element around the slot.
 *
 * @cssproperty --forge-theme-on-primary - Controls the border-color of the container outline, the font-color, and icon color.
 * @cssproperty --forge-theme-on-surface - Controls the font color of the buttons.
 * @cssproperty --forge-theme-text-medium - Controls the placeholder font color.
 * @cssproperty --forge-app-bar-search-theme-background - Controls the background-color of the container.
 * @cssproperty --forge-app-bar-search-theme-background-focused - Controls the focused background-color of the container.
 * @cssproperty --forge-app-bar-search-theme-hover-opacity - Controls the hover opacity of the outline.
 * @cssproperty --forge-app-bar-search-theme-disabled-opacity - Controls the disabled opacity of the component.
 *
 * @event {CustomEvent<IAppBarSearchInputEventData>} forge-app-bar-search-input - Emits when the users executes the search via pressing the Enter key while the `<input>` has focus.
 */
let AppBarSearchComponent = class AppBarSearchComponent extends BaseComponent {
    static get observedAttributes() {
        return [APP_BAR_SEARCH_CONSTANTS.attributes.DISABLED, APP_BAR_SEARCH_CONSTANTS.attributes.VALUE, APP_BAR_SEARCH_CONSTANTS.attributes.PLACEHOLDER];
    }
    constructor() {
        super();
        IconRegistry.define(tylIconSearch);
        attachShadowTemplate(this, template, styles);
        this._core = new AppBarSearchCore(new AppBarSearchAdapter(this));
    }
    connectedCallback() {
        if (this.querySelector(APP_BAR_SEARCH_CONSTANTS.selectors.INPUT)) {
            this._core.initialize();
        }
        else {
            ensureInputElement(this).then(() => this._core.initialize());
        }
    }
    disconnectedCallback() {
        this._core.destroy();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case APP_BAR_SEARCH_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                break;
            case APP_BAR_SEARCH_CONSTANTS.attributes.VALUE:
                this.value = newValue;
                break;
            case APP_BAR_SEARCH_CONSTANTS.attributes.PLACEHOLDER:
                this.placeholder = newValue;
                break;
        }
    }
};
__decorate([
    coreProperty()
], AppBarSearchComponent.prototype, "value", void 0);
__decorate([
    coreProperty()
], AppBarSearchComponent.prototype, "disabled", void 0);
__decorate([
    coreProperty()
], AppBarSearchComponent.prototype, "placeholder", void 0);
AppBarSearchComponent = __decorate([
    customElement({
        name: APP_BAR_SEARCH_CONSTANTS.elementName,
        dependencies: [IconComponent, FocusIndicatorComponent]
    })
], AppBarSearchComponent);
export { AppBarSearchComponent };
