// #region Imports
import { html } from '../../../../Dom/Html';
import { Icons } from '../../../../Resources/Icons';
import { generateMaterialPalette } from '../../../../Theming/Utils.Material.2014.2';
import { classMap, ifDefined, live, repeat, when } from '../../../Directives/Directives';
import { ifNonEmpty } from '../../../Directives/IfNonEmpty';
import { Appearance } from '../../../Types/Appearance';
import { Placement } from '../../../Types/Placement';
import { Size } from '../../../Types/Size';
import { TabStripPlacement } from '../../../Types/TabStripPlacement';
import { Variant } from '../../../Types/Variant';
// #endregion
/**
 * The template of the {@link ColorBoxElement}.
 *
 * @public
 */
export function colorBoxElementTemplate(e) {
    const getColors = (color) => {
        const palette = generateMaterialPalette(color);
        return Object.keys(palette).map((key) => ({
            key,
            value: palette[key]
        }));
    };
    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.label}</label>
            `)}
            <input part="input"
                   .value="${live(e.value)}"
                   ?readonly="${e.readonly}"
                   ?disabled="${e.disabled}"
                   ?required="${e.required}"
                   ?autofocus="${e.autofocus}"
                   dir="${e.dir}"
                   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)}"
                   @change="${(x) => e.onChange(x)}"
                   @input="${(x) => e.onInput(x)}"
                   @focus="${(x) => e.onFocus(x)}"
                   @blur="${(x) => e.onBlur(x)}"/>
        </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>
        `)}
        <!-- <mosaik-color-swatch part="color"
                             .value="${e.value}"
                             .hasBackground="${true}"
                             @click="${() => e.toggle()}"></mosaik-color-swatch> -->
        <mosaik-color-picker part="color"
                             .value="${e.value}"
                             @changed="${(x) => e.onPick(x)}"></mosaik-color-picker>
        <div part="suffix"
             ?hidden="${!e.hasSlotContent('suffix')}">>
            <slot name="suffix"></slot>
        </div>

        <!-- <mosaik-floating part="popup"
                         .anchor="${e}"
                         .placement="${e.dropDownPlacement}"
                         .distance="${e.dropDownDistance}"
                         .skidding="${e.dropDownSkidding}"
                         .strategy="${e.dropDownStrategy}"
                         .sync="${'width'}"
                         .flipFallbackPlacements="${[Placement.Top, Placement.Bottom]}"
                         .flip="${true}"
                         .shift="${true}"
                         ?active="${e.isDropDownOpen}">
            <mosaik-tab .placement="${TabStripPlacement.Bottom}"
                        .variant="${e.variant}"
                        .appearance="${Appearance.Plain}">
                <mosaik-tab-item>
                    <mosaik-color-area></mosaik-color-area>
                </mosaik-tab-item>
                <mosaik-tab-item>
                    ${repeat(e.swatches, (x) => x, (x) => html `
                    <mosaik-stack>
                        ${repeat(getColors(x), (y) => y, (y) => html `
                        <div part="item" style="background: ${y.value}"></div>
                        `)}
                    </mosaik-stack>
                    `)}
                </mosaik-tab-item>
            </mosaik-tab>

        </mosaik-floating> -->
    `;
}
//# sourceMappingURL=ColorBoxElementTemplate.js.map