import { ENTER, COMMA } from '@angular/cdk/keycodes';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Pipe, inject, ChangeDetectorRef, viewChild, input, computed, booleanAttribute, model, output, contentChild, effect, ChangeDetectionStrategy, Component } from '@angular/core';
import * as i2 from '@angular/forms';
import { NgForm, FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import * as i6 from '@angular/material/chips';
import { MatChipsModule } from '@angular/material/chips';
import { MatNativeDateModule } from '@angular/material/core';
import * as i7 from '@angular/material/datepicker';
import { MatCalendar, MatDatepickerModule } from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import * as i5 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import * as i3 from '@angular/material/input';
import { MatInputModule } from '@angular/material/input';
import * as i8 from '@angular/material/menu';
import { MatMenuTrigger, MatMenuModule } from '@angular/material/menu';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import * as i4 from '@angular/material/tooltip';
import { MatTooltipModule } from '@angular/material/tooltip';
import { SdView } from '@sdcorejs/angular/components/view';
import { SdViewDefDirective, SdLabelDefDirective } from '@sdcorejs/angular/forms/directives';
import { SdLabel } from '@sdcorejs/angular/forms/label';
import { sdFormControlState, sdViewedTransform, sdViewedInline, SdFormControl } from '@sdcorejs/angular/forms/models';
import { I18nService } from '@sdcorejs/angular/i18n';
import { sdIsEmpty, sdSerializeDataValue } from '@sdcorejs/angular/utilities/data-state';
import { DateUtilities } from '@sdcorejs/angular/utilities';
import { Subscription } from 'rxjs';
import * as uuid from 'uuid';

class SdRemovableChipPipe {
    constructor() { }
    transform(item, removable) {
        if (typeof (removable) === 'boolean') {
            return removable;
        }
        return removable(item);
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: SdRemovableChipPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
    static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.24", ngImport: i0, type: SdRemovableChipPipe, isStandalone: true, name: "sdRemovableChip" });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: SdRemovableChipPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'sdRemovableChip'
                }]
        }], ctorParameters: () => [] });

class SdChipCalendarErrorStateMatcher {
    formControl;
    constructor(formControl) {
        this.formControl = formControl;
    }
    isErrorState(control, form) {
        const isSubmitted = form && form.submitted;
        return !!(this.formControl?.invalid && (this.formControl?.dirty || this.formControl?.touched || isSubmitted));
    }
}
class SdChipCalendar {
    #ref = inject(ChangeDetectorRef);
    #i18n = inject(I18nService);
    #subscription = new Subscription();
    #name = uuid.v4();
    #isBlurring = false;
    menuTrigger = viewChild(MatMenuTrigger, ...(ngDevMode ? [{ debugName: "menuTrigger" }] : []));
    calendar = viewChild(MatCalendar, ...(ngDevMode ? [{ debugName: "calendar" }] : []));
    autoIdInput = input(undefined, ...(ngDevMode ? [{ debugName: "autoIdInput", alias: 'autoId',
            transform: (v) => v ?? undefined }] : [{
            alias: 'autoId',
            transform: (v) => v ?? undefined,
        }]));
    autoId = computed(() => (this.autoIdInput() ? `forms-chip-calendar-${this.autoIdInput()}` : undefined), ...(ngDevMode ? [{ debugName: "autoId" }] : []));
    #state = sdFormControlState(computed(() => this.formControl));
    dataDisabled = computed(() => (this.#state().disabled ? 'true' : 'false'), ...(ngDevMode ? [{ debugName: "dataDisabled" }] : []));
    dataEmpty = computed(() => (sdIsEmpty(this.#state().value) ? 'true' : 'false'), ...(ngDevMode ? [{ debugName: "dataEmpty" }] : []));
    dataValue = computed(() => sdSerializeDataValue(this.#state().value), ...(ngDevMode ? [{ debugName: "dataValue" }] : []));
    dataCount = computed(() => {
        const v = this.#state().value;
        return String(Array.isArray(v) ? v.length : 0);
    }, ...(ngDevMode ? [{ debugName: "dataCount" }] : []));
    dataRequired = computed(() => (this.required() ? 'true' : 'false'), ...(ngDevMode ? [{ debugName: "dataRequired" }] : []));
    dataErrorMessage = computed(() => {
        void this.#state();
        const msg = this.errorMessage();
        return msg && msg.length > 0 ? msg : null;
    }, ...(ngDevMode ? [{ debugName: "dataErrorMessage" }] : []));
    name = input(undefined, ...(ngDevMode ? [{ debugName: "name", transform: (v) => v ?? undefined }] : [{
            transform: (v) => v ?? undefined,
        }]));
    appearance = input('outline', ...(ngDevMode ? [{ debugName: "appearance", transform: (v) => v || 'outline' }] : [{
            transform: (v) => v || 'outline',
        }]));
    floatLabel = input('auto', ...(ngDevMode ? [{ debugName: "floatLabel", transform: (v) => v || 'auto' }] : [{
            transform: (v) => v || 'auto',
        }]));
    size = input('md', ...(ngDevMode ? [{ debugName: "size", transform: (v) => v || 'md' }] : [{
            transform: (v) => v || 'md',
        }]));
    // why: parent may bind NgForm (template-driven), FormGroup (reactive), or a wrapper with `.form`.
    // Transform once at the input boundary so the rest of the component only deals with FormGroup.
    form = input(undefined, ...(ngDevMode ? [{ debugName: "form", transform: (val) => {
                if (!val)
                    return undefined;
                if (val instanceof NgForm)
                    return val.form;
                if (val instanceof FormGroup)
                    return val;
                if (val?.form instanceof FormGroup)
                    return val.form;
                return undefined;
            } }] : [{
            transform: (val) => {
                if (!val)
                    return undefined;
                if (val instanceof NgForm)
                    return val.form;
                if (val instanceof FormGroup)
                    return val;
                if (val?.form instanceof FormGroup)
                    return val.form;
                return undefined;
            },
        }]));
    label = input('', ...(ngDevMode ? [{ debugName: "label", transform: (v) => v ?? '' }] : [{
            transform: (v) => v ?? '',
        }]));
    placeholder = input(undefined, ...(ngDevMode ? [{ debugName: "placeholder", transform: (v) => v ?? undefined }] : [{
            transform: (v) => v ?? undefined,
        }]));
    removable = input(true, ...(ngDevMode ? [{ debugName: "removable", transform: (v) => v ?? true }] : [{
            transform: (v) => v ?? true,
        }]));
    hideInlineError = input(false, ...(ngDevMode ? [{ debugName: "hideInlineError", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
    required = input(false, ...(ngDevMode ? [{ debugName: "required", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
    min = input(0, ...(ngDevMode ? [{ debugName: "min", transform: (v) => v ?? 0 }] : [{
            transform: (v) => v ?? 0,
        }]));
    max = input(0, ...(ngDevMode ? [{ debugName: "max", transform: (v) => v ?? 0 }] : [{
            transform: (v) => v ?? 0,
        }]));
    disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
    /** Display mode: `false` edit · `true` static view · `'inline'` interactive (disabled `'inline'` → static). */
    viewed = input(false, ...(ngDevMode ? [{ debugName: "viewed", transform: sdViewedTransform }] : [{ transform: sdViewedTransform }]));
    // why: tri-state viewed — `'inline'` keeps it interactive; disabled `'inline'` falls back to static.
    #viewedState = sdViewedInline(this.viewed, undefined, this.disabled);
    /** `true` when the static view should render (`viewed===true`, or disabled `'inline'`). */
    isViewed = this.#viewedState.isViewed;
    hyperlink = input(undefined, ...(ngDevMode ? [{ debugName: "hyperlink", transform: (v) => v ?? undefined }] : [{
            transform: (v) => v ?? undefined,
        }]));
    // Two-way model
    model = model(undefined, ...(ngDevMode ? [{ debugName: "model" }] : []));
    // Outputs (modelChange auto-generated by model() signal)
    sdChange = output();
    input = viewChild('input', ...(ngDevMode ? [{ debugName: "input" }] : []));
    sdViewDef = contentChild(SdViewDefDirective, ...(ngDevMode ? [{ debugName: "sdViewDef" }] : []));
    sdLabelDef = contentChild(SdLabelDefDirective, ...(ngDevMode ? [{ debugName: "sdLabelDef" }] : []));
    sdLabelTemplate = contentChild('sdLabel', ...(ngDevMode ? [{ debugName: "sdLabelTemplate" }] : []));
    sdValueTemplate = contentChild('sdValue', ...(ngDevMode ? [{ debugName: "sdValueTemplate" }] : []));
    isFocused = false;
    #inputControl = new FormControl();
    #formControl = new SdFormControl();
    #matcher;
    separatorKeysCodes = [ENTER, COMMA];
    constructor() {
        effect(() => {
            this.required();
            this.min();
            this.max();
            this.#updateValidator();
        });
        effect(() => {
            const values = this.model();
            if (Array.isArray(values)) {
                this.#formControl.setValue(values);
            }
        });
        effect(() => {
            const isDisabled = this.disabled();
            if (isDisabled) {
                this.#formControl.disable();
                this.#inputControl.disable();
            }
            else {
                this.#formControl.enable();
                this.#inputControl.enable();
            }
        });
        effect(() => {
            const nameVal = this.name();
            if (nameVal) {
                this.#name = nameVal;
            }
        });
        this.#matcher = new SdChipCalendarErrorStateMatcher(this.#formControl);
    }
    get formControl() {
        return this.#formControl;
    }
    get inputControl() {
        return this.#inputControl;
    }
    errorMessage = computed(() => {
        void this.#state();
        const errors = this.#formControl.errors;
        if (!errors)
            return undefined;
        if (errors['required'])
            return this.#i18n.t('core.form.chip-calendar.required');
        if (errors['minlength'])
            return this.#i18n.t('core.form.chip-calendar.minlength', { min: this.min() });
        if (errors['maxlength'])
            return this.#i18n.t('core.form.chip-calendar.maxlength', { max: this.max() });
        return undefined;
    }, ...(ngDevMode ? [{ debugName: "errorMessage" }] : []));
    get matcher() {
        return this.#matcher;
    }
    ngAfterViewInit() {
        this.#subscription.add(this.#formControl.sdChanges.subscribe(() => {
            this.#ref.markForCheck();
        }));
        this.form()?.addControl(this.#name, this.#formControl);
    }
    ngOnDestroy() {
        this.form()?.removeControl(this.#name);
        this.#subscription.unsubscribe();
    }
    #updateValidator = () => {
        this.#formControl.clearValidators();
        this.#formControl.clearAsyncValidators();
        const validators = [];
        const asyncValidators = [];
        if (this.required()) {
            validators.push(Validators.required);
        }
        if (this.min() > 0) {
            validators.push(Validators.minLength(this.min()));
        }
        if (this.max() > 0) {
            validators.push(Validators.maxLength(this.max()));
        }
        this.#formControl.setValidators(validators);
        this.#formControl.setAsyncValidators(asyncValidators);
        this.#formControl.updateValueAndValidity();
    };
    #clickChip = (event, item) => {
        event.stopPropagation();
        event.stopImmediatePropagation();
        if (!this.#formControl.disabled) {
            this.#focus();
        }
    };
    #remove = (item) => {
        const values = this.#formControl.value ?? [];
        if (typeof item === 'string') {
            this.#formControl.setValue(values.filter(value => item !== value));
            this.model.set(this.#formControl.value);
            this.sdChange.emit(this.#formControl.value);
        }
        this.#inputControl.setValue('');
        this.#focus();
    };
    #select = (event) => {
        const item = event.option.value;
        const values = this.#formControl.value ?? [];
        if (item) {
            if (typeof item === 'string' || typeof item === 'number') {
                if (!values.includes(item)) {
                    values.push(item);
                    this.#formControl.setValue(values);
                    this.model.set(this.#formControl.value);
                    this.sdChange.emit(this.#formControl.value);
                }
            }
            const inputEl = this.input();
            if (inputEl)
                inputEl.nativeElement.value = '';
            this.#inputControl.setValue('', {
                emitEvent: false,
            });
        }
    };
    #onClick = () => {
        if (this.sdViewDef()?.templateRef) {
            if (!this.#formControl.disabled && !this.isFocused) {
                this.#focus();
            }
        }
    };
    #focus = () => {
        this.isFocused = true;
        this.#isBlurring = false;
        setTimeout(() => {
            if (this.isFocused) {
                this.input()?.nativeElement?.focus();
            }
        }, 100);
    };
    #clear = (evt) => {
        evt?.stopPropagation();
        this.#inputControl.setValue('');
        this.#formControl.setValue([]);
        this.model.set(this.#formControl.value);
        this.sdChange.emit(this.#formControl.value);
        this.#ref.detectChanges();
    };
    #selectDate = (date) => {
        const value = DateUtilities.toFormat(date, 'yyyy/MM/dd');
        const values = this.#formControl.value ?? [];
        if (value) {
            if (!values.includes(value)) {
                values.push(value);
                this.#formControl.setValue(values);
                this.model.set(this.#formControl.value);
                this.sdChange.emit(this.#formControl.value);
            }
            else {
                this.#formControl.setValue(values.filter(date => value !== date));
                this.model.set(this.#formControl.value);
                this.sdChange.emit(this.#formControl.value);
            }
            this.calendar()?.updateTodaysDate();
            this.#ref.markForCheck();
        }
    };
    #closeCalendar = () => {
        this.isFocused = false;
        this.input()?.nativeElement?.blur();
    };
    #dateClass = (cellDate) => {
        const dates = this.#formControl.value || [];
        if (Array.isArray(dates)) {
            const selected = dates.some(date => date === DateUtilities.toFormat(cellDate, 'yyyy/MM/dd'));
            return selected ? 'sd-chip-calendar-selected-date' : '';
        }
        return '';
    };
    onClickChip = (event, item) => this.#clickChip(event, item);
    onRemove = (item) => this.#remove(item);
    onSelect = (event) => this.#select(event);
    onClick = () => this.#onClick();
    onClear = (evt) => this.#clear(evt);
    onSelectDate = (date) => this.#selectDate(date);
    onCloseCalendar = () => this.#closeCalendar();
    dateClass = (cellDate) => this.#dateClass(cellDate);
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: SdChipCalendar, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.24", type: SdChipCalendar, isStandalone: true, selector: "sd-chip-calendar", inputs: { autoIdInput: { classPropertyName: "autoIdInput", publicName: "autoId", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, floatLabel: { classPropertyName: "floatLabel", publicName: "floatLabel", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, removable: { classPropertyName: "removable", publicName: "removable", isSignal: true, isRequired: false, transformFunction: null }, hideInlineError: { classPropertyName: "hideInlineError", publicName: "hideInlineError", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, viewed: { classPropertyName: "viewed", publicName: "viewed", isSignal: true, isRequired: false, transformFunction: null }, hyperlink: { classPropertyName: "hyperlink", publicName: "hyperlink", isSignal: true, isRequired: false, transformFunction: null }, model: { classPropertyName: "model", publicName: "model", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { model: "modelChange", sdChange: "sdChange" }, host: { properties: { "class.sd-has-label": "!!label()", "class.sd-viewed": "isViewed()" } }, queries: [{ propertyName: "sdViewDef", first: true, predicate: SdViewDefDirective, descendants: true, isSignal: true }, { propertyName: "sdLabelDef", first: true, predicate: SdLabelDefDirective, descendants: true, isSignal: true }, { propertyName: "sdLabelTemplate", first: true, predicate: ["sdLabel"], descendants: true, isSignal: true }, { propertyName: "sdValueTemplate", first: true, predicate: ["sdValue"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "menuTrigger", first: true, predicate: MatMenuTrigger, descendants: true, isSignal: true }, { propertyName: "calendar", first: true, predicate: MatCalendar, descendants: true, isSignal: true }, { propertyName: "input", first: true, predicate: ["input"], descendants: true, isSignal: true }], ngImport: i0, template: "@let _lbl = label();\n@let _app = appearance();\n@let _req = required();\n@let _viewed = isViewed();\n@let _hideErr = hideInlineError();\n@let _viewDef = sdViewDef();\n@let _labelTemplate = (sdLabelTemplate() ?? sdLabelDef()?.templateRef) || undefined;\n@let _valueTemplate = (sdValueTemplate() ?? _viewDef?.templateRef) || undefined;\n@let _errMsg = errorMessage();\n@let _size = size();\n@let _removable = removable();\n\n@if (_viewed) {\n  <sd-view\n    [label]=\"_lbl\"\n    [labelTemplate]=\"_labelTemplate\"\n    [value]=\"formControl.value\"\n    [display]=\"formControl.value\"\n    [hyperlink]=\"hyperlink()\"\n    [valueTemplate]=\"_valueTemplate\">\n  </sd-view>\n} @else {\n  @if (!_app && _labelTemplate) {\n    <ng-container *ngTemplateOutlet=\"_labelTemplate\"></ng-container>\n  }\n  @if (!_app && _lbl && !_labelTemplate) {\n    <sd-label [label]=\"_lbl\" [required]=\"_req\"></sd-label>\n  }\n\n  <div\n    class=\"d-flex align-items-center\"\n    [class.sd-view]=\"!!_viewDef?.templateRef\"\n    [class.c-focused]=\"isFocused\"\n    [class.c-disabled]=\"formControl.disabled\"\n    (click)=\"onClick()\"\n    aria-hidden=\"true\">\n    @if (_viewDef?.templateRef && !isFocused) {\n      <ng-container *ngTemplateOutlet=\"_viewDef!.templateRef; context: { value: formControl.value }\"></ng-container>\n    } @else {\n      <mat-form-field\n        [class.sd-md]=\"_size === 'md'\"\n        [class.sd-sm]=\"_size === 'sm'\"\n        [class.hide-inline-error]=\"_hideErr\"\n        [appearance]=\"_app\"\n        [floatLabel]=\"floatLabel()\">\n        @if (_app && _lbl) {\n          <mat-label>{{ _lbl }}</mat-label>\n        }\n        <mat-chip-grid [formControl]=\"formControl\" #chipList [class.sd-md]=\"_size === 'md'\" [class.sd-sm]=\"_size === 'sm'\">\n          @for (item of formControl.value; track item) {\n            @if (item) {\n              <mat-chip-row\n                [class.sd-md]=\"_size === 'md'\"\n                [class.sd-sm]=\"_size === 'sm'\"\n                [removable]=\"_removable\"\n                (removed)=\"onRemove(item)\"\n                [disabled]=\"inputControl.disabled\"\n                (click)=\"onClickChip($event, item)\"\n                [value]=\"item\">\n                <span>{{ item | date: 'dd/MM/yyyy' }}</span>\n                @if (!inputControl.disabled && item | sdRemovableChip: _removable) {\n                  <mat-icon matChipRemove>cancel</mat-icon>\n                }\n              </mat-chip-row>\n            }\n          }\n\n          <input\n            class=\"sd-chip-input\"\n            [formControl]=\"inputControl\"\n            [placeholder]=\"placeholder() || _lbl\"\n            [matChipInputFor]=\"chipList\"\n            autocomplete=\"off\"\n            [errorStateMatcher]=\"matcher\"\n            [matMenuTriggerFor]=\"calendarMenu\"\n            [required]=\"_req\"\n            matInput\n            [attr.data-autoId]=\"autoId()\"\n            [attr.data-disabled]=\"dataDisabled()\"\n            [attr.data-empty]=\"dataEmpty()\"\n            [attr.data-value]=\"dataValue()\"\n            [attr.data-count]=\"dataCount()\"\n            [attr.data-required]=\"dataRequired()\"\n            [attr.data-error-message]=\"dataErrorMessage()\"\n            readonly\n            #input />\n        </mat-chip-grid>\n\n        <mat-menu #calendarMenu=\"matMenu\" overlapTrigger=\"false\" (closed)=\"onCloseCalendar()\">\n          <div style=\"width: 280px\" (click)=\"$event.stopPropagation()\" aria-hidden=\"true\">\n            <mat-calendar (selectedChange)=\"onSelectDate($event)\" [dateClass]=\"dateClass\"> </mat-calendar>\n          </div>\n        </mat-menu>\n        @if (_hideErr && _errMsg && formControl.touched) {\n          <mat-icon matSuffix class=\"sd-error-icon\" [matTooltip]=\"_errMsg\" matTooltipPosition=\"above\"> error </mat-icon>\n        }\n\n        @if (!_hideErr && _errMsg && formControl.touched) {\n          <mat-error>{{ _errMsg }}</mat-error>\n        }\n      </mat-form-field>\n    }\n  </div>\n}\n", styles: ["@charset \"UTF-8\";.text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host{display:block}:host(.sd-has-label){padding-top:4px}:host(.sd-viewed){padding-top:0}:host ::ng-deep .mat-mdc-form-field.no-padding-wrapper .mat-mdc-text-field-wrapper{padding-bottom:0}:host ::ng-deep mat-form-field.c-md .mat-mdc-standard-chip{padding:7px 10px;min-height:26px}:host ::ng-deep mat-form-field.c-md .mat-mdc-standard-chip .mat-mdc-chip-trailing-icon{padding:7px 7px 7px 10px}:host ::ng-deep .mat-mdc-chip-row.sd-sm{--mdc-chip-label-text-size: 12px;--mdc-chip-container-height: 20px}:host ::ng-deep .mat-mdc-chip-set.sd-md{margin-top:10px}:host ::ng-deep .mat-mdc-chip-set.sd-sm{margin-top:2px}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}mat-form-field{width:100%}mat-chip-listbox{display:flex;flex-wrap:wrap;gap:4px}::ng-deep .sd-chip-calendar-selected-date .mat-calendar-body-cell-content{background-color:var(--sd-primary-light)!important;color:var(--sd-primary)!important;border-radius:50%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatAutocompleteModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "ngmodule", type: MatChipsModule }, { kind: "component", type: i6.MatChipGrid, selector: "mat-chip-grid", inputs: ["disabled", "placeholder", "required", "value", "errorStateMatcher"], outputs: ["change", "valueChange"] }, { kind: "directive", type: i6.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled", "readonly", "matChipInputDisabledInteractive"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { kind: "directive", type: i6.MatChipRemove, selector: "[matChipRemove]" }, { kind: "component", type: i6.MatChipRow, selector: "mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]", inputs: ["editable"], outputs: ["edited"] }, { kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i7.MatCalendar, selector: "mat-calendar", inputs: ["headerComponent", "startAt", "startView", "selected", "minDate", "maxDate", "dateFilter", "dateClass", "comparisonStart", "comparisonEnd", "startDateAccessibleName", "endDateAccessibleName"], outputs: ["selectedChange", "yearSelected", "monthSelected", "viewChanged", "_userSelection", "_userDragDrop"], exportAs: ["matCalendar"] }, { kind: "ngmodule", type: MatNativeDateModule }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i8.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "directive", type: i8.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "component", type: SdLabel, selector: "sd-label", inputs: ["label", "description", "required", "helperText"] }, { kind: "component", type: SdView, selector: "sd-view", inputs: ["label", "value", "display", "hyperlink", "labelTemplate", "valueTemplate", "selectedItems"] }, { kind: "pipe", type: i1.DatePipe, name: "date" }, { kind: "pipe", type: SdRemovableChipPipe, name: "sdRemovableChip" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: SdChipCalendar, decorators: [{
            type: Component,
            args: [{ selector: 'sd-chip-calendar', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, host: { '[class.sd-has-label]': '!!label()', '[class.sd-viewed]': 'isViewed()' }, imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        MatInputModule,
                        MatTooltipModule,
                        MatFormFieldModule,
                        MatAutocompleteModule,
                        MatIconModule,
                        MatProgressSpinnerModule,
                        MatChipsModule,
                        MatDatepickerModule,
                        MatNativeDateModule,
                        MatMenuModule,
                        SdLabel,
                        SdView,
                        SdRemovableChipPipe,
                    ], template: "@let _lbl = label();\n@let _app = appearance();\n@let _req = required();\n@let _viewed = isViewed();\n@let _hideErr = hideInlineError();\n@let _viewDef = sdViewDef();\n@let _labelTemplate = (sdLabelTemplate() ?? sdLabelDef()?.templateRef) || undefined;\n@let _valueTemplate = (sdValueTemplate() ?? _viewDef?.templateRef) || undefined;\n@let _errMsg = errorMessage();\n@let _size = size();\n@let _removable = removable();\n\n@if (_viewed) {\n  <sd-view\n    [label]=\"_lbl\"\n    [labelTemplate]=\"_labelTemplate\"\n    [value]=\"formControl.value\"\n    [display]=\"formControl.value\"\n    [hyperlink]=\"hyperlink()\"\n    [valueTemplate]=\"_valueTemplate\">\n  </sd-view>\n} @else {\n  @if (!_app && _labelTemplate) {\n    <ng-container *ngTemplateOutlet=\"_labelTemplate\"></ng-container>\n  }\n  @if (!_app && _lbl && !_labelTemplate) {\n    <sd-label [label]=\"_lbl\" [required]=\"_req\"></sd-label>\n  }\n\n  <div\n    class=\"d-flex align-items-center\"\n    [class.sd-view]=\"!!_viewDef?.templateRef\"\n    [class.c-focused]=\"isFocused\"\n    [class.c-disabled]=\"formControl.disabled\"\n    (click)=\"onClick()\"\n    aria-hidden=\"true\">\n    @if (_viewDef?.templateRef && !isFocused) {\n      <ng-container *ngTemplateOutlet=\"_viewDef!.templateRef; context: { value: formControl.value }\"></ng-container>\n    } @else {\n      <mat-form-field\n        [class.sd-md]=\"_size === 'md'\"\n        [class.sd-sm]=\"_size === 'sm'\"\n        [class.hide-inline-error]=\"_hideErr\"\n        [appearance]=\"_app\"\n        [floatLabel]=\"floatLabel()\">\n        @if (_app && _lbl) {\n          <mat-label>{{ _lbl }}</mat-label>\n        }\n        <mat-chip-grid [formControl]=\"formControl\" #chipList [class.sd-md]=\"_size === 'md'\" [class.sd-sm]=\"_size === 'sm'\">\n          @for (item of formControl.value; track item) {\n            @if (item) {\n              <mat-chip-row\n                [class.sd-md]=\"_size === 'md'\"\n                [class.sd-sm]=\"_size === 'sm'\"\n                [removable]=\"_removable\"\n                (removed)=\"onRemove(item)\"\n                [disabled]=\"inputControl.disabled\"\n                (click)=\"onClickChip($event, item)\"\n                [value]=\"item\">\n                <span>{{ item | date: 'dd/MM/yyyy' }}</span>\n                @if (!inputControl.disabled && item | sdRemovableChip: _removable) {\n                  <mat-icon matChipRemove>cancel</mat-icon>\n                }\n              </mat-chip-row>\n            }\n          }\n\n          <input\n            class=\"sd-chip-input\"\n            [formControl]=\"inputControl\"\n            [placeholder]=\"placeholder() || _lbl\"\n            [matChipInputFor]=\"chipList\"\n            autocomplete=\"off\"\n            [errorStateMatcher]=\"matcher\"\n            [matMenuTriggerFor]=\"calendarMenu\"\n            [required]=\"_req\"\n            matInput\n            [attr.data-autoId]=\"autoId()\"\n            [attr.data-disabled]=\"dataDisabled()\"\n            [attr.data-empty]=\"dataEmpty()\"\n            [attr.data-value]=\"dataValue()\"\n            [attr.data-count]=\"dataCount()\"\n            [attr.data-required]=\"dataRequired()\"\n            [attr.data-error-message]=\"dataErrorMessage()\"\n            readonly\n            #input />\n        </mat-chip-grid>\n\n        <mat-menu #calendarMenu=\"matMenu\" overlapTrigger=\"false\" (closed)=\"onCloseCalendar()\">\n          <div style=\"width: 280px\" (click)=\"$event.stopPropagation()\" aria-hidden=\"true\">\n            <mat-calendar (selectedChange)=\"onSelectDate($event)\" [dateClass]=\"dateClass\"> </mat-calendar>\n          </div>\n        </mat-menu>\n        @if (_hideErr && _errMsg && formControl.touched) {\n          <mat-icon matSuffix class=\"sd-error-icon\" [matTooltip]=\"_errMsg\" matTooltipPosition=\"above\"> error </mat-icon>\n        }\n\n        @if (!_hideErr && _errMsg && formControl.touched) {\n          <mat-error>{{ _errMsg }}</mat-error>\n        }\n      </mat-form-field>\n    }\n  </div>\n}\n", styles: ["@charset \"UTF-8\";.text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host{display:block}:host(.sd-has-label){padding-top:4px}:host(.sd-viewed){padding-top:0}:host ::ng-deep .mat-mdc-form-field.no-padding-wrapper .mat-mdc-text-field-wrapper{padding-bottom:0}:host ::ng-deep mat-form-field.c-md .mat-mdc-standard-chip{padding:7px 10px;min-height:26px}:host ::ng-deep mat-form-field.c-md .mat-mdc-standard-chip .mat-mdc-chip-trailing-icon{padding:7px 7px 7px 10px}:host ::ng-deep .mat-mdc-chip-row.sd-sm{--mdc-chip-label-text-size: 12px;--mdc-chip-container-height: 20px}:host ::ng-deep .mat-mdc-chip-set.sd-md{margin-top:10px}:host ::ng-deep .mat-mdc-chip-set.sd-sm{margin-top:2px}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}mat-form-field{width:100%}mat-chip-listbox{display:flex;flex-wrap:wrap;gap:4px}::ng-deep .sd-chip-calendar-selected-date .mat-calendar-body-cell-content{background-color:var(--sd-primary-light)!important;color:var(--sd-primary)!important;border-radius:50%}\n"] }]
        }], ctorParameters: () => [], propDecorators: { menuTrigger: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MatMenuTrigger), { isSignal: true }] }], calendar: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MatCalendar), { isSignal: true }] }], autoIdInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoId", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], floatLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "floatLabel", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], removable: [{ type: i0.Input, args: [{ isSignal: true, alias: "removable", required: false }] }], hideInlineError: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideInlineError", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], viewed: [{ type: i0.Input, args: [{ isSignal: true, alias: "viewed", required: false }] }], hyperlink: [{ type: i0.Input, args: [{ isSignal: true, alias: "hyperlink", required: false }] }], model: [{ type: i0.Input, args: [{ isSignal: true, alias: "model", required: false }] }, { type: i0.Output, args: ["modelChange"] }], sdChange: [{ type: i0.Output, args: ["sdChange"] }], input: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }], sdViewDef: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SdViewDefDirective), { isSignal: true }] }], sdLabelDef: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SdLabelDefDirective), { isSignal: true }] }], sdLabelTemplate: [{ type: i0.ContentChild, args: ['sdLabel', { isSignal: true }] }], sdValueTemplate: [{ type: i0.ContentChild, args: ['sdValue', { isSignal: true }] }] } });

/**
 * Generated bundle index. Do not edit.
 */

export { SdChipCalendar };
//# sourceMappingURL=sdcorejs-angular-forms-chip-calendar.mjs.map
