// #region Imports
import { html } from '../../../../Dom/Html';
import { Icons } from '../../../../Resources/Icons';
import { classMap, ifDefined, live, repeat, when } from '../../../Directives/Directives';
import { ifNonEmpty } from '../../../Directives/IfNonEmpty';
import { Appearance } from '../../../Types/Appearance';
import { Size } from '../../../Types/Size';
import { Variant } from '../../../Types/Variant';
// #endregion
/**
 * The template of the `ChipBoxElement`.
 *
 * @public
 */
export function chipBoxElementTemplate(e) {
    return html `
        ${when(!e.disabled, () => html `
        <mosaik-focus-ring part="focusRing"
                           .variant="${e.invalid ? Variant.Danger : e.variant}"
                           .visible="${e.isFocused}"
                           .controlled="${'manual'}"
                           @connected="${(evt) => evt.target.attach(e)}"></mosaik-focus-ring>
        `)}
        <div part="prefix"
             ?hidden="${!e.hasSlotContent('prefix')}">
            <slot name="prefix"></slot>
        </div>
        <div part="inner" class="${classMap({ prefix: e.hasPrefix, suffix: e.hasSuffix })}">
            ${when(e.label, () => html `
            <label part="label"
                   for="input"
                   class="${classMap({ floating: e.value || e.isFocused || e.chips.length > 0 })}">${e.label}</label>
            `)}
            <div part="wrapper">
                ${repeat(e.chips, (x) => x, (x) => html `
                <mosaik-chip part="chip"
                             .value="${x}"
                             .label="${String(x)}"
                             .appearance="${e.appearance}"
                             .variant="${e.variant}"
                             ?closeable="${e.isEditable}"
                             ?disabled="${e.disabled}"
                             @closed="${() => e.onChipClosed(x)}"></mosaik-chip>
                `)}
                <input part="input"
                       .value="${live(e.value)}"
                       ?readonly="${e.readonly}"
                       ?disabled="${e.disabled || !e.isEditable}"
                       ?required="${e.required}"
                       ?autofocus="${e.autofocus}"
                       id="input"
                       name="${ifNonEmpty(e.name)}"
                       type="text"
                       pattern="${ifNonEmpty(e.pattern)}"
                       placeholder="${ifNonEmpty(e.isFocused || !e.label ? e.placeholder : '')}"
                       tabindex="${e.tabIndex}"
                       autocomplete="${ifDefined(e.autocomplete ? 'on' : 'off')}"
                       aria-invalid="${ifDefined(e.invalid)}"
                       ?hidden="${!e.isEditable || e.readonly}"
                       @change="${(x) => e.onChange(x)}"
                       @input="${(x) => e.onInput(x)}"
                       @focus="${(x) => e.onFocus(x)}"
                       @blur="${(x) => e.onBlur(x)}"
                       @keyup="${(x) => e.onKeyUp(x)}"
                       @keydown="${(x) => e.onKeyDown(x)}"
                       @paste="${(x) => e.onPaste(x)}" />
            </div>
        </div>
        ${when(!e.disabled && !e.readonly && e.value && e.isClearable, () => html `
        <mosaik-button part="clear"
                       .appearance="${Appearance.Plain}"
                       .icon="${Icons.clear}"
                       .size="${Size.Small}"
                       .iconSize="${Size.Medium}"
                       @click="${() => e.clear()}"></mosaik-button>
        `)}
        <div part="suffix"
             ?hidden="${!e.hasSlotContent('suffix')}">
            <slot name="suffix"></slot>
        </div>
    `;
}
//# sourceMappingURL=ChipBoxElementTemplate.js.map