import { animation, animate, keyframes, style } from '@angular/animations';
import { Platform, PlatformModule } from '@angular/cdk/platform';
import { InjectionToken, inject, LOCALE_ID, Optional, Inject, Injectable, NgModule, EventEmitter, ElementRef, Renderer2, Input, Output, Directive, Pipe, Component, ViewEncapsulation, Attribute, ChangeDetectorRef } from '@angular/core';
import { Subject, fromEvent, merge, of } from 'rxjs';
import { filter, tap, takeUntil, map, catchError } from 'rxjs/operators';
import { CommonModule } from '@angular/common';
import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
import { HttpRequest, HttpEventType } from '@angular/common/http';

function transformAxis(name, axis, letter) {
    return axis === 'x'
        ? `${name}(${letter}, 0, 0)`
        : `${name}(0, ${letter}, 0)`;
}
function translate3d(axis, letter) {
    return transformAxis('translate3d', axis, letter);
}
const DEFAULT_TIMING = .5;

function fade(options) {
    return animation(animate(`${options.timing || DEFAULT_TIMING}s ${options.delay || 0}s ${options.timingFunction || 'ease'}`, keyframes([
        style({ opacity: `${options.fromOpacity}`, transform: translate3d(options.axis, options.steps.a), offset: 0 }),
        style({ opacity: `${options.toOpacity}`, transform: translate3d(options.axis, options.steps.b), offset: 1 }),
    ])));
}
function fadeInDirection(axis, steps, timing, delay) {
    return fade({ fromOpacity: 0, toOpacity: 1, axis, steps, timing, delay });
}
function fadeInX(steps, timing, delay) {
    return fadeInDirection('x', steps, timing, delay);
}
function fadeInY(steps, timing, delay) {
    return fadeInDirection('y', steps, timing, delay);
}
function fadeIn(timing, delay) {
    return fadeInX({ a: 0, b: 0 }, timing, delay);
}
function fadeInDown(timing, delay) {
    return fadeInY({ a: '-100%', b: 0 }, timing, delay);
}
function fadeInUp(timing, delay) {
    return fadeInY({ a: '100%', b: 0 }, timing, delay);
}
function fadeInLeft(timing, delay) {
    return fadeInX({ a: '-100%', b: 0 }, timing, delay);
}
function fadeInRight(timing, delay) {
    return fadeInX({ a: '100%', b: 0 }, timing, delay);
}
function fadeOutDirection(axis, steps, timing, delay) {
    return fade({ fromOpacity: 1, toOpacity: 0, axis, steps, timing, delay });
}
function fadeOutX(steps, timing, delay) {
    return fadeOutDirection('x', steps, timing, delay);
}
function fadeOutY(steps, timing, delay) {
    return fadeOutDirection('y', steps, timing, delay);
}
function fadeOut(timing, delay) {
    return fadeOutX({ a: 0, b: 0 }, timing, delay);
}
function fadeOutDown(timing, delay) {
    return fadeOutY({ a: '-100%', b: 0 }, timing, delay);
}
function fadeOutUp(timing, delay) {
    return fadeOutY({ a: '100%', b: 0 }, timing, delay);
}
function fadeOutLeft(timing, delay) {
    return fadeOutX({ a: '-100%', b: 0 }, timing, delay);
}
function fadeOutRight(timing, delay) {
    return fadeOutX({ a: '100%', b: 0 }, timing, delay);
}
function slideDirection(axis, steps, timing, delay) {
    return fade({ fromOpacity: 1, toOpacity: 1, axis, steps, timing, delay });
}
function slideX(steps, timing, delay) {
    return slideDirection('x', steps, timing, delay);
}
function slideY(steps, timing, delay) {
    return slideDirection('y', steps, timing, delay);
}
function slideInDown(timing, delay) {
    return slideY({ a: '100%', b: 0 }, timing, delay);
}
function slideInUp(timing, delay) {
    return slideY({ a: '-100%', b: 0 }, timing, delay);
}
function slideInLeft(timing, delay) {
    return slideX({ a: '-100%', b: 0 }, timing, delay);
}
function slideInRight(timing, delay) {
    return slideX({ a: '100%', b: 0 }, timing, delay);
}
function slideOutUp(timing, delay) {
    return slideY({ a: 0, b: '-100%' }, timing, delay);
}
function slideOutDown(timing, delay) {
    return slideY({ a: 0, b: '100%' }, timing, delay);
}
function slideOutLeft(timing, delay) {
    return slideX({ a: 0, b: '-100%' }, timing, delay);
}
function slideOutRight(timing, delay) {
    return slideX({ a: 0, b: '100%' }, timing, delay);
}

const NT_DATE_LOCALE = new InjectionToken('nt-date-locale', {
    providedIn: 'root',
    factory: NT_DATE_LOCALE_FACTORY
});
function NT_DATE_LOCALE_FACTORY() {
    return inject(LOCALE_ID);
}
class DateAdapter {
    constructor() {
        this._localeChanges = new Subject();
    }
    get localeChanges() { return this._localeChanges; }
    deserialize(value) {
        if (value == null || this.isDateInstance(value) && this.isValid(value)) {
            return value;
        }
        return this.invalid();
    }
    setLocale(locale) {
        this.locale = locale;
        this._localeChanges.next();
    }
    compareDate(first, second) {
        return this.getYear(first) - this.getYear(second) ||
            this.getMonth(first) - this.getMonth(second) ||
            this.getDate(first) - this.getDate(second);
    }
    sameDate(first, second) {
        if (first && second) {
            let firstValid = this.isValid(first);
            let secondValid = this.isValid(second);
            if (firstValid && secondValid) {
                return !this.compareDate(first, second);
            }
            return firstValid === secondValid;
        }
        return first === second;
    }
    clampDate(date, min, max) {
        if (min && this.compareDate(date, min) < 0) {
            return min;
        }
        if (max && this.compareDate(date, max) > 0) {
            return max;
        }
        return date;
    }
}

const NT_DATE_FORMATS = new InjectionToken('nt-date-formats');

var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
const SUPPORTS_INTL_API = typeof Intl !== 'undefined';
const DEFAULT_MONTH_NAMES = {
    'long': [
        '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月',
        '十月', '十一月', '十二月'
    ],
    'short': ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
    'narrow': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
};
const DEFAULT_DAY_OF_WEEK_NAMES = {
    'long': ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
    'short': ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
    'narrow': ['日', '一', '二', '三', '四', '五', '六']
};
const ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;
const LIKE_ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:(?:\+|-)\d{4})?)?$/;
function range(length, valueFunction) {
    const valuesArray = Array(length);
    for (let i = 0; i < length; i++) {
        valuesArray[i] = valueFunction(i);
    }
    return valuesArray;
}
let NativeDateAdapter = class NativeDateAdapter extends DateAdapter {
    constructor(ntDateLocale, platform) {
        super();
        this.useUtcForDisplay = true;
        super.setLocale(ntDateLocale);
        this.useUtcForDisplay = !platform.TRIDENT;
        this._clampDate = platform.TRIDENT || platform.EDGE;
    }
    getYear(date) {
        return date.getFullYear();
    }
    getMonth(date) {
        return date.getMonth();
    }
    getDate(date) {
        return date.getDate();
    }
    getMilliseconds(date) {
        return date.getTime();
    }
    getDayOfWeek(date) {
        return date.getDay();
    }
    getMonthNames(style, locale = this.locale) {
        if (SUPPORTS_INTL_API) {
            const dtf = new Intl.DateTimeFormat(locale, { month: style, timeZone: 'utc' });
            return range(12, i => this._stripDirectionalityCharacters(this._format(dtf, new Date(2017, i, 1))));
        }
        return DEFAULT_MONTH_NAMES[style];
    }
    getDateNames(locale = 'en-US') {
        if (SUPPORTS_INTL_API) {
            const dtf = new Intl.DateTimeFormat(locale, { day: 'numeric', timeZone: 'utc' });
            return range(31, i => this._stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
        }
        return range(31, i => String(i + 1));
    }
    getDayOfWeekNames(style, locale = this.locale) {
        if (SUPPORTS_INTL_API) {
            const dtf = new Intl.DateTimeFormat(locale, { weekday: style, timeZone: 'utc' });
            return range(7, i => this._stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
        }
        return DEFAULT_DAY_OF_WEEK_NAMES[style];
    }
    getYearName(date, locale = this.locale) {
        if (SUPPORTS_INTL_API) {
            const dtf = new Intl.DateTimeFormat(locale, { year: 'numeric', timeZone: 'utc' });
            return this._stripDirectionalityCharacters(this._format(dtf, date));
        }
        return String(this.getYear(date));
    }
    getFirstDayOfWeek() {
        return 0;
    }
    getNumDaysInMonth(date) {
        return this.getDate(this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + 1, 0));
    }
    clone(date) {
        return this.createDate(this.getYear(date), this.getMonth(date), this.getDate(date));
    }
    createDate(year, month, date) {
        if (month < 0 || month > 11) {
            throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
        }
        if (date < 1) {
            throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
        }
        let result = this._createDateWithOverflow(year, month, date);
        if (result.getMonth() !== month) {
            throw Error(`Invalid date "${date}" for month with index "${month}".`);
        }
        return result;
    }
    today() {
        return new Date();
    }
    parse(value) {
        if (typeof value === 'number') {
            return new Date(value);
        }
        return value ? new Date(Date.parse(value)) : null;
    }
    format(date, displayFormat, locale = this.locale) {
        if (!this.isValid(date)) {
            throw Error('NativeDateAdapter: Cannot format invalid date.');
        }
        if (SUPPORTS_INTL_API) {
            if (this._clampDate && (date.getFullYear() < 1 || date.getFullYear() > 9999)) {
                date = this.clone(date);
                date.setFullYear(Math.max(1, Math.min(9999, date.getFullYear())));
            }
            displayFormat = Object.assign(Object.assign({}, displayFormat), { timeZone: 'utc' });
            const dtf = new Intl.DateTimeFormat(locale, displayFormat);
            return this._stripDirectionalityCharacters(this._format(dtf, date));
        }
        return this._stripDirectionalityCharacters(date.toDateString());
    }
    addCalendarYears(date, years) {
        return this.addCalendarMonths(date, years * 12);
    }
    addCalendarMonths(date, months) {
        let newDate = this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + months, this.getDate(date));
        if (this.getMonth(newDate) !== ((this.getMonth(date) + months) % 12 + 12) % 12) {
            newDate = this._createDateWithOverflow(this.getYear(newDate), this.getMonth(newDate), 0);
        }
        return newDate;
    }
    addCalendarDays(date, days) {
        return this._createDateWithOverflow(this.getYear(date), this.getMonth(date), this.getDate(date) + days);
    }
    toIso8601(date) {
        return [
            date.getUTCFullYear(),
            this._2digit(date.getUTCMonth() + 1),
            this._2digit(date.getUTCDate())
        ].join('-');
    }
    deserialize(value) {
        if (typeof value === 'string') {
            if (!value) {
                return null;
            }
            if (LIKE_ISO_8601_REGEX.test(value)) {
                value = `${value.slice(0, value.length - 2)}:${value.slice(value.length - 2)}`;
            }
            if (ISO_8601_REGEX.test(value)) {
                let date = new Date(value);
                if (this.isValid(date)) {
                    return date;
                }
            }
        }
        return super.deserialize(value);
    }
    isDateInstance(obj) {
        return obj instanceof Date;
    }
    isValid(date) {
        return !isNaN(date.getTime());
    }
    invalid() {
        return new Date(NaN);
    }
    _createDateWithOverflow(year, month, date) {
        const result = new Date(year, month, date);
        if (year >= 0 && year < 100) {
            result.setFullYear(this.getYear(result) - 1900);
        }
        return result;
    }
    _2digit(n) {
        return ('00' + n).slice(-2);
    }
    _stripDirectionalityCharacters(str) {
        return str.replace(/[\u200e\u200f]/g, '');
    }
    _format(dtf, date) {
        const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
        return dtf.format(d);
    }
};
NativeDateAdapter.ctorParameters = () => [
    { type: String, decorators: [{ type: Optional }, { type: Inject, args: [NT_DATE_LOCALE,] }] },
    { type: Platform }
];
NativeDateAdapter = __decorate([
    Injectable(),
    __param(0, Optional()), __param(0, Inject(NT_DATE_LOCALE))
], NativeDateAdapter);

const NT_NATIVE_DATE_FORMATS = {
    parse: {
        dateInput: null,
    },
    display: {
        dateInput: { year: 'numeric', month: 'numeric', day: 'numeric' },
        monthYearLabel: { year: 'numeric', month: 'short' },
        monthLabel: { month: 'short' }
    }
};

var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let NativeDateModule = class NativeDateModule {
};
NativeDateModule = __decorate$1([
    NgModule({
        imports: [PlatformModule],
        providers: [
            { provide: DateAdapter, useClass: NativeDateAdapter }
        ],
    })
], NativeDateModule);
const ɵ0 = NT_NATIVE_DATE_FORMATS;
let NtNativeDateModule = class NtNativeDateModule {
};
NtNativeDateModule = __decorate$1([
    NgModule({
        imports: [NativeDateModule],
        providers: [
            { provide: NT_DATE_FORMATS, useValue: ɵ0 }
        ],
    })
], NtNativeDateModule);

function fromOutsideElementClick(children, container = document.body) {
    const isMatchElement = (target, parent) => {
        let matched = target === parent;
        while (!matched
            && target.parentElement
            && target.parentElement !== container) {
            matched = parent === (target = target.parentElement);
        }
        return matched;
    };
    return fromEvent(container, 'click').pipe(filter((event) => !children.some(element => isMatchElement(event.target, element))));
}
function fromOutsideElementTouch(children, container = document.body) {
    const isMatchElement = (target, parent) => {
        let matched = target === parent;
        while (!matched
            && target.parentElement
            && target.parentElement !== container) {
            matched = parent === (target = target.parentElement);
        }
        return matched;
    };
    return merge(fromEvent(container, 'touchstart').pipe(tap(e => e.preventDefault())), fromEvent(container, 'mousedown')).pipe(filter((event) => !children.some(element => isMatchElement(event.target, element))));
}
function fromOutsideClick(zones, container = document.body) {
    const isClickZone = (event, zone) => {
        const rect = zone.getBoundingClientRect();
        const clickX = event.clientX, clickY = event.clientY, x1 = rect.left, y1 = rect.top, x2 = rect.right, y2 = rect.bottom;
        return clickX >= x1 && clickX <= x2 && clickY >= y1 && clickY <= y2;
    };
    return fromEvent(container, 'click').pipe(filter((event) => !zones.some(element => isClickZone(event, element))));
}
function fromOutsideTouch(zones, container = document.body) {
    const isTouchZone = (event, zone) => {
        var _a, _b;
        const rect = zone.getBoundingClientRect();
        let touchX, touchY, x1 = rect.left, y1 = rect.top, x2 = rect.right, y2 = rect.bottom;
        if (event instanceof TouchEvent) {
            touchX = ((_a = event.touches.item(0)) === null || _a === void 0 ? void 0 : _a.clientX) || -1;
            touchY = ((_b = event.touches.item(0)) === null || _b === void 0 ? void 0 : _b.clientY) || -1;
        }
        else {
            touchX = event.clientX;
            touchY = event.clientY;
        }
        return touchX >= x1 && touchX <= x2 && touchY >= y1 && touchY <= y2;
    };
    return merge(fromEvent(container, 'touchstart').pipe(tap(e => e.preventDefault())), fromEvent(container, 'mousedown')).pipe(filter((event) => !zones.some(element => isTouchZone(event, element))));
}

class NtFileTypeError {
    constructor(file, type) {
        this.file = file;
        this.type = type;
    }
}
class NtFileSizeError {
    constructor(file, limitSize, limitSizeString) {
        this.file = file;
        this.limitSize = limitSize;
        this.limitSizeString = limitSizeString;
    }
}

var __decorate$2 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let NtFileSelectDirective = class NtFileSelectDirective {
    constructor(_elementRef, _renderer) {
        this._elementRef = _elementRef;
        this._renderer = _renderer;
        this._destroy = new Subject();
        this._accept = '*';
        this._limitSize = Number.MAX_VALUE;
        this._multiple = false;
        this._disabled = false;
        this.select = new EventEmitter();
        this.errors = new EventEmitter();
    }
    get accept() { return this._accept; }
    set accept(value) {
        if (typeof value === 'string') {
            this._accept = value.replace(' ', '');
        }
        else {
            this._accept = value.join(',');
        }
    }
    get limitSize() { return this._limitSize; }
    set limitSize(value) { this._limitSize = coerceNumberProperty(value, 5); }
    get multiple() { return this._multiple; }
    set multiple(value) {
        this._multiple = coerceBooleanProperty(value);
    }
    get disabled() { return this._disabled; }
    set disabled(value) {
        this._disabled = coerceBooleanProperty(value);
    }
    ngOnChanges(changes) {
        const change = changes.accept || changes.maxSize || changes.multiple;
        if (change && !change.firstChange) {
            this._updateProperty();
        }
    }
    ngOnInit() {
        this._input = this._renderer.createElement('input');
        this._renderer.setStyle(this._input, 'visibility', 'hidden');
        this._renderer.setStyle(this._input, 'width', 0);
        this._renderer.setStyle(this._input, 'height', 0);
        this._renderer.setStyle(this._input, 'margin', 0);
        this._renderer.setProperty(this._input, 'type', 'file');
        this._updateProperty();
        fromEvent(this._input, 'change')
            .pipe(takeUntil(this._destroy))
            .subscribe(event => this._change(event));
    }
    trigger(event) {
        if (!this.disabled) {
            this._input.click();
        }
        event.preventDefault();
    }
    _updateProperty() {
        this._renderer.setProperty(this._input, 'accept', this._accept);
        this._renderer.setProperty(this._input, 'disabled', this.disabled);
        this._renderer.setProperty(this._input, 'multiple', this.multiple ? 'multiple' : null);
    }
    _change(_) {
        const errors = [];
        const files = Array.from(this._input.files || []).filter(file => {
            let valid = true;
            if (!(valid = this._fileSizeValid(file))) {
                errors.push(new NtFileSizeError(file, this.limitSize));
            }
            else if (!(valid = this._fileTypeValid(file))) {
                errors.push(new NtFileTypeError(file, file.type));
            }
            return valid;
        });
        if (errors.length > 0) {
            this.errors.next(errors);
        }
        if (files.length > 0) {
            this.select.next(files);
        }
        this._input.value = '';
    }
    _fileTypeValid(file) {
        return this.accept.indexOf(file.type) > -1 || this.accept.indexOf('*') > -1;
    }
    _fileSizeValid(file) {
        return file.size <= this.limitSize * 1024 * 1024;
    }
    ngOnDestroy() {
        if (this._input) {
            this._destroy.next();
        }
    }
};
NtFileSelectDirective.ctorParameters = () => [
    { type: ElementRef },
    { type: Renderer2 }
];
__decorate$2([
    Input()
], NtFileSelectDirective.prototype, "accept", null);
__decorate$2([
    Input()
], NtFileSelectDirective.prototype, "limitSize", null);
__decorate$2([
    Input()
], NtFileSelectDirective.prototype, "multiple", null);
__decorate$2([
    Input()
], NtFileSelectDirective.prototype, "disabled", null);
__decorate$2([
    Output()
], NtFileSelectDirective.prototype, "select", void 0);
__decorate$2([
    Output()
], NtFileSelectDirective.prototype, "errors", void 0);
NtFileSelectDirective = __decorate$2([
    Directive({
        selector: '[ntFileSelect]',
        host: {
            '(click)': 'trigger($event)'
        }
    })
], NtFileSelectDirective);

const si = { radix: 1e3, unit: ['b', 'kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'] };
const iec = { radix: 1024, unit: ['b', 'Kib', 'Mib', 'Gib', 'Tib', 'Pib', 'Eib', 'Zib', 'Yib'] };
const jedec = { radix: 1024, unit: ['b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'] };
const SPECS = { si, iec, jedec, };
function byteStringify(bytes, fixed = 2, spec = 'jedec') {
    bytes = Math.abs(bytes);
    const { radix, unit } = SPECS[spec];
    let loop = 0;
    while (bytes >= radix) {
        bytes /= radix;
        ++loop;
    }
    return `${bytes.toFixed(fixed)} ${unit[loop]}`;
}

var __decorate$3 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let NtFileSizePipe = class NtFileSizePipe {
    transform(bytes = 0, precision = 2) {
        if (isNaN(parseFloat(String(bytes))) || !isFinite(bytes)) {
            return '?';
        }
        return byteStringify(bytes, precision);
    }
};
NtFileSizePipe = __decorate$3([
    Pipe({ name: 'filesize' })
], NtFileSizePipe);

const FILE_EXTENSIONS_MAP = {
    'rar': 'archive',
    'zip': 'archive',
    'cab': 'archive',
    'iso': 'archive',
    'jar': 'archive',
    '7z': 'archive',
    'tar': 'archive',
    'gz': 'archive',
    'bz2': 'archive',
    'z': 'archive',
    'jpg': 'image',
    'bmp': 'image',
    'eps': 'image',
    'gif': 'image',
    'mif': 'image',
    'miff': 'image',
    'png': 'image',
    'tif': 'image',
    'tiff': 'image',
    'svg': 'image',
    'wmf': 'image',
    'jpe': 'image',
    'jpeg': 'image',
    'dib': 'image',
    'ico': 'image',
    'tga': 'image',
    'cut': 'image',
    'pic': 'image',
    'wma': 'audio',
    'ra': 'audio',
    'ogg': 'audio',
    'mpc': 'audio',
    'm4a': 'audio',
    'aac': 'audio',
    'mpa': 'audio',
    'mp2': 'audio',
    'm1a': 'audio',
    'm2a': 'audio',
    'mp3': 'audio',
    'mid': 'audio',
    'midi': 'audio',
    'rmi': 'audio',
    'mka': 'audio',
    'ac3': 'audio',
    'dts': 'audio',
    'cda': 'audio',
    'au': 'audio',
    'snd': 'audio',
    'aif': 'audio',
    'aifc': 'audio',
    'aiff': 'audio',
    'mp4': 'video',
    'avi': 'video',
    'wav': 'video',
    'wmv': 'video',
    'rmvb': 'video',
    'rm': 'video',
    'flv': 'video',
    'mkv': 'video',
    'mpg': 'video',
    'mpeg': 'video',
    'mov': 'video',
    '3gp': 'video',
    'doc': 'word',
    'docx': 'word',
    'xls': 'excel',
    'xlsx': 'excel',
    'ppt': 'ppt',
    'pptx': 'ppt'
};
const FILE_MIME_TYPES_MAP = {
    'application/x-bzip': 'archive',
    'application/x-bzip2': 'archive',
    'application/msword': 'word',
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'word',
    'application/vnd.ms-fontobject': 'font',
    'application/epub+zip': 'archive',
    'application/gzip': 'archive',
    'application/java-archive': 'archive',
    'application/json': 'code',
    'application/pdf': 'pdf',
    'application/php': 'code',
    'application/vnd.ms-powerpoint': 'ppt',
    'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'ppt',
    'application/x-rar-compressed': 'archive',
    'application/x-sh': 'code',
    'application/x-tar': 'archive',
    'application/xhtml+xml': 'code',
    'application/vnd.ms-excel': 'excel',
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'excel',
    'application/xml': 'code',
    'application/vnd.mozilla.xul+xml': 'code',
    'application/zip': 'archive',
    'application/x-7z-compressed': 'archive',
    'text/css': 'code',
    'text/csv': 'code',
    'text/html': 'code',
    'text/calendar': 'code',
    'text/javascript': 'code',
    'text/xml': 'code',
    'font/otf': 'font',
    'font/ttf': 'font',
    'font/woff': 'font',
    'font/woff2': 'font',
    'image/bmp': 'image',
    'image/gif': 'image',
    'image/vnd.microsoft.icon': 'image',
    'image/jpeg': 'image',
    'image/png': 'image',
    'image/svg+xml': 'image',
    'image/tiff': 'image',
    'image/webp': 'image',
    'video/x-msvideo': 'video',
    'video/mpeg': 'video',
    'video/ogg': 'video',
    'video/mp2t': 'video',
    'video/webm': 'video',
    'video/3gpp': 'video',
    'video/3gpp2': 'video',
    'audio/aac': 'audio',
    'audio/midi audio/x-midi': 'audio',
    'audio/mpeg': 'audio',
    'audio/ogg': 'audio',
    'audio/opus': 'audio',
    'audio/wav': 'audio',
    'audio/webm': 'audio',
    'audio/3gpp': 'audio',
    'audio/3gpp2': 'audio',
};
const NT_FILE_CATEGORIES = Object.assign(Object.assign({}, FILE_EXTENSIONS_MAP), FILE_MIME_TYPES_MAP);
function findCategoryByFile(file) {
    const type = file.type || file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length);
    return NT_FILE_CATEGORIES[type] || '';
}
function findCategoryByExtensions(extension) {
    return FILE_EXTENSIONS_MAP[extension] || '';
}
function findCategoryByMimeType(type) {
    return FILE_MIME_TYPES_MAP[type] || '';
}

var __decorate$4 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let NtFileModule = class NtFileModule {
};
NtFileModule = __decorate$4([
    NgModule({
        imports: [CommonModule],
        exports: [
            NtFileSizePipe,
            NtFileSelectDirective
        ],
        declarations: [
            NtFileSizePipe,
            NtFileSelectDirective
        ]
    })
], NtFileModule);

var __decorate$5 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let NtPseudoCaretComponent = class NtPseudoCaretComponent {
};
NtPseudoCaretComponent = __decorate$5([
    Component({
        selector: 'nt-pseudo-caret',
        template: '<ng-content></ng-content>',
        encapsulation: ViewEncapsulation.None,
        host: {
            'class': 'nt-pseudo-caret'
        }
    })
], NtPseudoCaretComponent);

var __decorate$6 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param$1 = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
let NtPseudoInputComponent = class NtPseudoInputComponent {
    constructor(_elementRef, tabIndex) {
        this._elementRef = _elementRef;
        this._disabled = false;
        this.tabIndex = parseInt(tabIndex) || 0;
    }
    get value() { return this._value; }
    set value(value) { this._value = value; }
    get placeholder() { return this._placeholder; }
    set placeholder(value) { this._placeholder = value; }
    set disabled(value) { this._disabled = coerceBooleanProperty(value); }
    get disabled() { return this._disabled; }
    ngOnInit() { }
};
NtPseudoInputComponent.ctorParameters = () => [
    { type: ElementRef },
    { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] }
];
__decorate$6([
    Input()
], NtPseudoInputComponent.prototype, "value", null);
__decorate$6([
    Input()
], NtPseudoInputComponent.prototype, "placeholder", null);
__decorate$6([
    Input()
], NtPseudoInputComponent.prototype, "disabled", null);
NtPseudoInputComponent = __decorate$6([
    Component({
        selector: 'nt-pseudo-input',
        template: `
    <div class="nt-pseudo-value" *ngIf="value">{{ value }}</div>
    <div class="nt-pseudo-placeholder" *ngIf="!value">{{ placeholder }}</div>
    <ng-content select="nt-pseudo-caret"></ng-content>
  `,
        encapsulation: ViewEncapsulation.None,
        host: {
            'class': 'nt-pseudo-input',
            '[class.disabled]': 'disabled',
            '[tabindex]': 'tabIndex'
        }
    }),
    __param$1(1, Attribute('tabindex'))
], NtPseudoInputComponent);

var __decorate$7 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let NtPseudoInputModule = class NtPseudoInputModule {
};
NtPseudoInputModule = __decorate$7([
    NgModule({
        imports: [CommonModule],
        declarations: [
            NtPseudoInputComponent,
            NtPseudoCaretComponent
        ],
        exports: [
            NtPseudoInputComponent,
            NtPseudoCaretComponent
        ]
    })
], NtPseudoInputModule);

var __decorate$8 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param$2 = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
class NtOptionSelectionChange {
    constructor(source, isUserInput = false) {
        this.source = source;
        this.isUserInput = isUserInput;
    }
}
const NT_OPTION_PARENT_COMPONENT = new InjectionToken('nt-option-parent-component');
let NtOptionComponent = class NtOptionComponent {
    constructor(_element, _changeDetectorRef, _parent) {
        this._element = _element;
        this._changeDetectorRef = _changeDetectorRef;
        this._parent = _parent;
        this._selected = false;
        this._disabled = false;
        this._label = '';
        this._hidden = false;
        this._mostRecentViewValue = '';
        this._isActive = false;
        this.stateChanges = new Subject();
        this.selectionChange = new EventEmitter();
    }
    set label(value) { this._label = value; }
    get label() {
        if (!this._label.trim()) {
            return (this._element.nativeElement.textContent || '').trim();
        }
        return this._label.trim();
    }
    get multiple() { return this._parent && this._parent.multiple; }
    set value(value) { this._value = value; }
    get value() { return this._value; }
    get disabled() { return this._disabled || this.hidden; }
    set disabled(value) {
        this._disabled = coerceBooleanProperty(value);
    }
    set hidden(value) {
        this._hidden = coerceBooleanProperty(value);
    }
    get hidden() { return this._hidden; }
    get selected() { return this._selected; }
    ngAfterViewChecked() {
        if (this._selected) {
            const viewValue = this.label;
            if (viewValue !== this._mostRecentViewValue) {
                this._mostRecentViewValue = viewValue;
                this.stateChanges.next();
            }
        }
    }
    focus() {
        const element = this._element.nativeElement;
        if (typeof element.focus === 'function') {
            element.focus();
        }
    }
    select() {
        this._selected = true;
        this._changeDetectorRef.markForCheck();
        this._emitSelectionChangeEvent();
    }
    deselect() {
        this._selected = false;
        this._changeDetectorRef.markForCheck();
        this._emitSelectionChangeEvent();
    }
    selectViaInteraction() {
        if (!this.disabled) {
            this._selected = this.multiple ? !this._selected : true;
            this._emitSelectionChangeEvent(true);
        }
    }
    setActiveStyles() {
        this._isActive = true;
    }
    setInactiveStyles() {
        this._isActive = false;
    }
    getLabel() {
        return this.label;
    }
    getOffsetTop() {
        return this._element.nativeElement.offsetTop;
    }
    getOffsetHeight() {
        return this._element.nativeElement.offsetHeight;
    }
    _emitSelectionChangeEvent(isUserInput = false) {
        this.selectionChange.emit(new NtOptionSelectionChange(this, isUserInput));
    }
};
NtOptionComponent.ctorParameters = () => [
    { type: ElementRef },
    { type: ChangeDetectorRef },
    { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [NT_OPTION_PARENT_COMPONENT,] }] }
];
__decorate$8([
    Input()
], NtOptionComponent.prototype, "label", null);
__decorate$8([
    Input()
], NtOptionComponent.prototype, "value", null);
__decorate$8([
    Input()
], NtOptionComponent.prototype, "disabled", null);
__decorate$8([
    Output()
], NtOptionComponent.prototype, "selectionChange", void 0);
NtOptionComponent = __decorate$8([
    Component({
        selector: 'nt-option',
        template: `<ng-content></ng-content>`,
        encapsulation: ViewEncapsulation.None,
        host: {
            'class': 'nt-option',
            '[class.nt-option-selected]': 'selected',
            '[class.nt-option-disabled]': 'disabled',
            '[class.nt-option-active]': '_isActive',
            '[class.nt-option-hidden]': 'hidden',
            '(click)': 'selectViaInteraction()'
        }
    }),
    __param$2(2, Optional()), __param$2(2, Inject(NT_OPTION_PARENT_COMPONENT))
], NtOptionComponent);

var __decorate$9 = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let NtOptionModule = class NtOptionModule {
};
NtOptionModule = __decorate$9([
    NgModule({
        imports: [CommonModule],
        exports: [NtOptionComponent],
        declarations: [NtOptionComponent]
    })
], NtOptionModule);

var NtUploadStatus;
(function (NtUploadStatus) {
    NtUploadStatus[NtUploadStatus["BEGIN"] = 0] = "BEGIN";
    NtUploadStatus[NtUploadStatus["SENDING"] = 1] = "SENDING";
    NtUploadStatus[NtUploadStatus["SUCCESS"] = 2] = "SUCCESS";
    NtUploadStatus[NtUploadStatus["ERROR"] = 3] = "ERROR";
    NtUploadStatus[NtUploadStatus["UPLOADED"] = 4] = "UPLOADED";
})(NtUploadStatus || (NtUploadStatus = {}));
class NtUploadRef {
    constructor(file, name, size) {
        this.file = file;
        this.name = name;
        this.size = size;
    }
}

class NtUploadResponse {
    constructor(data) {
        this.data = data;
    }
}
class NtUploadError {
    constructor(file, error) {
        this.file = file;
        this.error = error;
    }
}

const REQUEST_PROGRESS = { reportProgress: true };
class NtUploadHandler {
    constructor(_http) {
        this._http = _http;
    }
    upload(url, uploadRef) {
        const data = this.getRequestData(uploadRef.file);
        return this._http.request(new HttpRequest('POST', url, data, REQUEST_PROGRESS))
            .pipe(map(event => this._progress(event, uploadRef)), filter(event => event.type === HttpEventType.Response), map((event) => new NtUploadResponse(this.getResponseData(event.body))), catchError((error) => of(new NtUploadError(uploadRef.file, this.getErrorMessage(error)))));
    }
    _progress(event, uploadRef) {
        if (event.type === HttpEventType.Sent) {
            uploadRef.status = NtUploadStatus.BEGIN;
        }
        else if (event.type === HttpEventType.UploadProgress && (event.total && event.total > 0)) {
            uploadRef.progress = Math.round(event.loaded / event.total * 100);
        }
        else if (event.type === HttpEventType.Response) {
            uploadRef.status = NtUploadStatus.UPLOADED;
        }
        return event;
    }
}

export { DEFAULT_TIMING, DateAdapter, FILE_EXTENSIONS_MAP, FILE_MIME_TYPES_MAP, NT_DATE_FORMATS, NT_DATE_LOCALE, NT_DATE_LOCALE_FACTORY, NT_FILE_CATEGORIES, NT_NATIVE_DATE_FORMATS, NT_OPTION_PARENT_COMPONENT, NativeDateAdapter, NativeDateModule, NtFileModule, NtFileSelectDirective, NtFileSizeError, NtFileSizePipe, NtFileTypeError, NtNativeDateModule, NtOptionComponent, NtOptionModule, NtOptionSelectionChange, NtPseudoCaretComponent, NtPseudoInputComponent, NtPseudoInputModule, NtUploadError, NtUploadHandler, NtUploadRef, NtUploadResponse, NtUploadStatus, SPECS, byteStringify, fade, fadeIn, fadeInDirection, fadeInDown, fadeInLeft, fadeInRight, fadeInUp, fadeInX, fadeInY, fadeOut, fadeOutDirection, fadeOutDown, fadeOutLeft, fadeOutRight, fadeOutUp, fadeOutX, fadeOutY, findCategoryByExtensions, findCategoryByFile, findCategoryByMimeType, fromOutsideClick, fromOutsideElementClick, fromOutsideElementTouch, fromOutsideTouch, slideDirection, slideInDown, slideInLeft, slideInRight, slideInUp, slideOutDown, slideOutLeft, slideOutRight, slideOutUp, slideX, slideY, transformAxis, translate3d, ɵ0 };
//# sourceMappingURL=core.js.map
