import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Pipe, EventEmitter, ContentChild, ViewChild, Output, Input, ChangeDetectionStrategy, Component } from '@angular/core';
import * as i2 from '@angular/forms';
import { NgForm, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import * as i5 from '@angular/material/chips';
import { MatChipsModule } from '@angular/material/chips';
import * as i6 from '@angular/material/datepicker';
import { MatDatepickerModule, MatCalendar } from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import * as i4 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 i7 from '@angular/material/menu';
import { MatMenuModule, MatMenuTrigger } from '@angular/material/menu';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTooltipModule } from '@angular/material/tooltip';
import { SdViewDefDirective, SdLabelDefDirective } from '@sd-angular/core/forms/directives';
import { SdFormControl } from '@sd-angular/core/forms/models';
import { DateUtilities } from '@sd-angular/core/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: "19.2.17", ngImport: i0, type: SdRemovableChipPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
    static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.17", ngImport: i0, type: SdRemovableChipPipe, isStandalone: true, name: "sdRemovableChip" });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdRemovableChipPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'sdRemovableChip'
                }]
        }], ctorParameters: () => [] });

class SdChipErrotStateMatcher {
    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;
    menuTrigger;
    calendar;
    autoId;
    set _autoId(val) {
        if (!val) {
            return;
        }
        this.autoId = `forms-chip-calendar-${val}`;
    }
    #name = uuid.v4();
    set _name(val) {
        if (val) {
            this.#name = val;
        }
    }
    appearance = 'outline';
    size = 'md';
    #form;
    set form(val) {
        if (val) {
            if (val instanceof NgForm) {
                this.#form = val.form;
            }
            else {
                this.#form = val;
            }
        }
    }
    label = '';
    placeholder;
    removable = true;
    set _removable(val) {
        this.removable = val === '' || val;
    }
    hideInlineError = false;
    set _hideInlineError(val) {
        this.hideInlineError = val === '' || !!val;
    }
    // Model
    set model(values) {
        if (!Array.isArray(values)) {
            values = [];
        }
        this.formControl.setValue(values);
    }
    // Validator
    required = false;
    set _required(val) {
        this.required = val === '' || !!val;
        this.#updateValidator();
    }
    min;
    set pMin(val) {
        this.min = +val || 0;
        this.#updateValidator();
    }
    max;
    set pMax(val) {
        this.max = +val || 0;
        this.#updateValidator();
    }
    modelChange = new EventEmitter();
    // Optional
    set disabled(val) {
        val = val === '' || val;
        if (val) {
            this.formControl.disable();
            this.inputControl.disable();
        }
        else {
            this.formControl.enable();
            this.inputControl.enable();
        }
    }
    sdChange = new EventEmitter();
    input;
    sdView;
    sdLabelDef;
    isBlurring = false;
    isFocused = false;
    inputControl = new FormControl();
    formControl = new SdFormControl();
    matcher = new SdChipErrotStateMatcher(this.formControl);
    #subscription = new Subscription();
    constructor(ref) {
        this.ref = ref;
    }
    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();
    };
    onClickChip = ($event, item) => {
        $event.stopPropagation();
        $event.stopImmediatePropagation();
        if (!this.formControl.disabled) {
            this.#focus();
        }
    };
    onRemove = (item) => {
        const values = this.formControl.value ?? [];
        if (typeof item === 'string') {
            this.formControl.setValue(values.filter(value => item !== value));
            this.modelChange.emit(this.formControl.value);
            this.sdChange.emit(this.formControl.value);
        }
        this.inputControl.setValue('');
        this.#focus();
    };
    onSelect = (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.modelChange.emit(this.formControl.value);
                    this.sdChange.emit(this.formControl.value);
                }
            }
            this.input.nativeElement.value = '';
            this.inputControl.setValue('', {
                emitEvent: false,
            });
        }
    };
    onClick = () => {
        if (this.sdView?.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);
    };
    onClear = ($event) => {
        $event?.stopPropagation();
        this.inputControl.setValue('');
        this.formControl.setValue([]);
        this.modelChange.emit(this.formControl.value);
        this.sdChange.emit(this.formControl.value);
        this.ref.detectChanges();
    };
    onSelectDate = (date) => {
        const value = DateUtilities.toFormat(date, 'yyyy/MM/dd');
        const values = this.formControl.value ?? [];
        if (value) {
            if (!values.includes(value)) {
                // Nếu chưa có thì add vào
                values.push(value);
                this.formControl.setValue(values);
                this.modelChange.emit(this.formControl.value);
                this.sdChange.emit(this.formControl.value);
            }
            else {
                // Nếu có rồi thì remove
                this.formControl.setValue(values.filter(date => value !== date));
                this.modelChange.emit(this.formControl.value);
                this.sdChange.emit(this.formControl.value);
            }
            this.calendar.updateTodaysDate();
            this.ref.markForCheck();
        }
    };
    onCloseCalendar() {
        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 '';
    };
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdChipCalendar, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdChipCalendar, isStandalone: true, selector: "sd-chip-calendar", inputs: { _autoId: ["autoId", "_autoId"], _name: ["name", "_name"], appearance: "appearance", size: "size", form: "form", label: "label", placeholder: "placeholder", _removable: ["removable", "_removable"], _hideInlineError: ["hideInlineError", "_hideInlineError"], model: "model", _required: ["required", "_required"], pMin: ["min", "pMin"], pMax: ["max", "pMax"], disabled: "disabled" }, outputs: { modelChange: "modelChange", sdChange: "sdChange" }, queries: [{ propertyName: "sdView", first: true, predicate: SdViewDefDirective, descendants: true }, { propertyName: "sdLabelDef", first: true, predicate: SdLabelDefDirective, descendants: true }], viewQueries: [{ propertyName: "menuTrigger", first: true, predicate: MatMenuTrigger, descendants: true }, { propertyName: "calendar", first: true, predicate: MatCalendar, descendants: true }, { propertyName: "input", first: true, predicate: ["input"], descendants: true }], ngImport: i0, template: "@let labelTemplate = sdLabelDef?.templateRef;\r\n@let viewTemplate = sdView?.templateRef;\r\n\r\n@if (!appearance && labelTemplate) {\r\n  <ng-container *ngTemplateOutlet=\"labelTemplate\"></ng-container>\r\n}\r\n@if (!appearance && label && !labelTemplate) {\r\n  <div class=\"d-block mb-0 T14M\">{{ label }} <span class=\"text-danger mb-2\" *ngIf=\"required\">*</span></div>\r\n}\r\n<div\r\n  class=\"d-flex align-items-center\"\r\n  [class.sd-view]=\"viewTemplate\"\r\n  [class.c-focused]=\"isFocused\"\r\n  [class.c-disabled]=\"formControl.disabled\"\r\n  (click)=\"onClick()\"\r\n  aria-hidden=\"true\">\r\n  @if (viewTemplate && !isFocused) {\r\n    <ng-container *ngTemplateOutlet=\"viewTemplate; context: { value: formControl.value }\"></ng-container>\r\n  } @else {\r\n    <mat-form-field [class.sd-md]=\"size === 'md'\" [class.sd-sm]=\"size === 'sm'\" [class.hide-inline-error]=\"hideInlineError\" [appearance]=\"appearance\">\r\n      @if (appearance && label) {\r\n        <mat-label>{{ label }}</mat-label>\r\n      }\r\n      <mat-chip-grid [formControl]=\"formControl\" #chipList>\r\n        @for (item of formControl.value; track item) {\r\n          @if (item) {\r\n            <mat-chip-row\r\n              [removable]=\"removable\"\r\n              (removed)=\"onRemove(item)\"\r\n              [disabled]=\"inputControl.disabled\"\r\n              (click)=\"onClickChip($event, item)\"\r\n              [value]=\"item\">\r\n              <span>{{ item | date: 'dd/MM/yyyy' }}</span>\r\n              @if (!inputControl.disabled && item | sdRemovableChip: removable) {\r\n                <mat-icon matChipRemove>cancel</mat-icon>\r\n              }\r\n            </mat-chip-row>\r\n          }\r\n        }\r\n        <input\r\n          [formControl]=\"inputControl\"\r\n          [placeholder]=\"placeholder || label\"\r\n          [matChipInputFor]=\"chipList\"\r\n          autocomplete=\"off\"\r\n          [errorStateMatcher]=\"matcher\"\r\n          [matMenuTriggerFor]=\"calendarMenu\"\r\n          [required]=\"required\"\r\n          matInput\r\n          [attr.data-autoId]=\"autoId\"\r\n          readonly\r\n          #input />\r\n      </mat-chip-grid>\r\n      <mat-menu #calendarMenu=\"matMenu\" overlapTrigger=\"false\" (closed)=\"onCloseCalendar()\">\r\n        <div style=\"width: 280px\" (click)=\"$event.stopPropagation()\" aria-hidden=\"true\">\r\n          <mat-calendar (selectedChange)=\"onSelectDate($event)\" [dateClass]=\"dateClass\"> </mat-calendar>\r\n        </div>\r\n      </mat-menu>\r\n      <!-- <mat-datepicker [dateClass]=\"dateClass\" (closed)=\"onPickerClosed()\" #picker></mat-datepicker> -->\r\n      @if (formControl.errors?.['required'] && !hideInlineError) {\r\n        <mat-error>{{ 'Vui l\u00F2ng nh\u1EADp th\u00F4ng tin' }}</mat-error>\r\n      }\r\n      @if (formControl.errors?.['minlength'] && !hideInlineError) {\r\n        <mat-error>{{ 'Vui l\u00F2ng nh\u1EADp \u00EDt nh\u1EA5t ' + min + ' gi\u00E1 tr\u1ECB' }} </mat-error>\r\n      }\r\n      @if (formControl.errors?.['maxlength'] && !hideInlineError) {\r\n        <mat-error>{{ 'Vui l\u00F2ng nh\u1EADp t\u1ED1i \u0111a ' + max + ' gi\u00E1 tr\u1ECB' }} </mat-error>\r\n      }\r\n    </mat-form-field>\r\n  }\r\n</div>\r\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{padding-top:5px;display:block}: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}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}:host{display:block}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.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.DatePipe, name: "date" }, { 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: "ngmodule", type: MatTooltipModule }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatAutocompleteModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "ngmodule", type: MatChipsModule }, { kind: "component", type: i5.MatChipGrid, selector: "mat-chip-grid", inputs: ["disabled", "placeholder", "required", "value", "errorStateMatcher"], outputs: ["change", "valueChange"] }, { kind: "directive", type: i5.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { kind: "directive", type: i5.MatChipRemove, selector: "[matChipRemove]" }, { kind: "component", type: i5.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: i6.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: MatMenuModule }, { kind: "component", type: i7.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: i7.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "pipe", type: SdRemovableChipPipe, name: "sdRemovableChip" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdChipCalendar, decorators: [{
            type: Component,
            args: [{ selector: 'sd-chip-calendar', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        MatInputModule,
                        MatTooltipModule,
                        MatFormFieldModule,
                        MatAutocompleteModule,
                        MatIconModule,
                        MatProgressSpinnerModule,
                        MatChipsModule,
                        MatDatepickerModule,
                        MatMenuModule,
                        SdRemovableChipPipe,
                    ], template: "@let labelTemplate = sdLabelDef?.templateRef;\r\n@let viewTemplate = sdView?.templateRef;\r\n\r\n@if (!appearance && labelTemplate) {\r\n  <ng-container *ngTemplateOutlet=\"labelTemplate\"></ng-container>\r\n}\r\n@if (!appearance && label && !labelTemplate) {\r\n  <div class=\"d-block mb-0 T14M\">{{ label }} <span class=\"text-danger mb-2\" *ngIf=\"required\">*</span></div>\r\n}\r\n<div\r\n  class=\"d-flex align-items-center\"\r\n  [class.sd-view]=\"viewTemplate\"\r\n  [class.c-focused]=\"isFocused\"\r\n  [class.c-disabled]=\"formControl.disabled\"\r\n  (click)=\"onClick()\"\r\n  aria-hidden=\"true\">\r\n  @if (viewTemplate && !isFocused) {\r\n    <ng-container *ngTemplateOutlet=\"viewTemplate; context: { value: formControl.value }\"></ng-container>\r\n  } @else {\r\n    <mat-form-field [class.sd-md]=\"size === 'md'\" [class.sd-sm]=\"size === 'sm'\" [class.hide-inline-error]=\"hideInlineError\" [appearance]=\"appearance\">\r\n      @if (appearance && label) {\r\n        <mat-label>{{ label }}</mat-label>\r\n      }\r\n      <mat-chip-grid [formControl]=\"formControl\" #chipList>\r\n        @for (item of formControl.value; track item) {\r\n          @if (item) {\r\n            <mat-chip-row\r\n              [removable]=\"removable\"\r\n              (removed)=\"onRemove(item)\"\r\n              [disabled]=\"inputControl.disabled\"\r\n              (click)=\"onClickChip($event, item)\"\r\n              [value]=\"item\">\r\n              <span>{{ item | date: 'dd/MM/yyyy' }}</span>\r\n              @if (!inputControl.disabled && item | sdRemovableChip: removable) {\r\n                <mat-icon matChipRemove>cancel</mat-icon>\r\n              }\r\n            </mat-chip-row>\r\n          }\r\n        }\r\n        <input\r\n          [formControl]=\"inputControl\"\r\n          [placeholder]=\"placeholder || label\"\r\n          [matChipInputFor]=\"chipList\"\r\n          autocomplete=\"off\"\r\n          [errorStateMatcher]=\"matcher\"\r\n          [matMenuTriggerFor]=\"calendarMenu\"\r\n          [required]=\"required\"\r\n          matInput\r\n          [attr.data-autoId]=\"autoId\"\r\n          readonly\r\n          #input />\r\n      </mat-chip-grid>\r\n      <mat-menu #calendarMenu=\"matMenu\" overlapTrigger=\"false\" (closed)=\"onCloseCalendar()\">\r\n        <div style=\"width: 280px\" (click)=\"$event.stopPropagation()\" aria-hidden=\"true\">\r\n          <mat-calendar (selectedChange)=\"onSelectDate($event)\" [dateClass]=\"dateClass\"> </mat-calendar>\r\n        </div>\r\n      </mat-menu>\r\n      <!-- <mat-datepicker [dateClass]=\"dateClass\" (closed)=\"onPickerClosed()\" #picker></mat-datepicker> -->\r\n      @if (formControl.errors?.['required'] && !hideInlineError) {\r\n        <mat-error>{{ 'Vui l\u00F2ng nh\u1EADp th\u00F4ng tin' }}</mat-error>\r\n      }\r\n      @if (formControl.errors?.['minlength'] && !hideInlineError) {\r\n        <mat-error>{{ 'Vui l\u00F2ng nh\u1EADp \u00EDt nh\u1EA5t ' + min + ' gi\u00E1 tr\u1ECB' }} </mat-error>\r\n      }\r\n      @if (formControl.errors?.['maxlength'] && !hideInlineError) {\r\n        <mat-error>{{ 'Vui l\u00F2ng nh\u1EADp t\u1ED1i \u0111a ' + max + ' gi\u00E1 tr\u1ECB' }} </mat-error>\r\n      }\r\n    </mat-form-field>\r\n  }\r\n</div>\r\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{padding-top:5px;display:block}: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}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}:host{display:block}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: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { menuTrigger: [{
                type: ViewChild,
                args: [MatMenuTrigger]
            }], calendar: [{
                type: ViewChild,
                args: [MatCalendar]
            }], _autoId: [{
                type: Input,
                args: ['autoId']
            }], _name: [{
                type: Input,
                args: ['name']
            }], appearance: [{
                type: Input
            }], size: [{
                type: Input
            }], form: [{
                type: Input
            }], label: [{
                type: Input
            }], placeholder: [{
                type: Input
            }], _removable: [{
                type: Input,
                args: ['removable']
            }], _hideInlineError: [{
                type: Input,
                args: ['hideInlineError']
            }], model: [{
                type: Input
            }], _required: [{
                type: Input,
                args: ['required']
            }], pMin: [{
                type: Input,
                args: ['min']
            }], pMax: [{
                type: Input,
                args: ['max']
            }], modelChange: [{
                type: Output
            }], disabled: [{
                type: Input
            }], sdChange: [{
                type: Output
            }], input: [{
                type: ViewChild,
                args: ['input']
            }], sdView: [{
                type: ContentChild,
                args: [SdViewDefDirective]
            }], sdLabelDef: [{
                type: ContentChild,
                args: [SdLabelDefDirective]
            }] } });

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

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