(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/keycodes'), require('@angular/common/http'), require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('ng-zorro-antd/core'), require('@angular/animations'), require('@angular/cdk/platform'), require('@angular/common'), require('ng-zorro-antd/tooltip'), require('ng-zorro-antd/icon'), require('ng-zorro-antd/progress'), require('ng-zorro-antd/i18n'), require('@angular/forms')) :
    typeof define === 'function' && define.amd ? define('ng-zorro-antd/upload', ['exports', '@angular/cdk/keycodes', '@angular/common/http', '@angular/core', 'rxjs', 'rxjs/operators', 'ng-zorro-antd/core', '@angular/animations', '@angular/cdk/platform', '@angular/common', 'ng-zorro-antd/tooltip', 'ng-zorro-antd/icon', 'ng-zorro-antd/progress', 'ng-zorro-antd/i18n', '@angular/forms'], factory) :
    (global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].upload = {}), global.ng.cdk.keycodes, global.ng.common.http, global.ng.core, global.rxjs, global.rxjs.operators, global['ng-zorro-antd'].core, global.ng.animations, global.ng.cdk.platform, global.ng.common, global['ng-zorro-antd'].tooltip, global['ng-zorro-antd'].icon, global['ng-zorro-antd'].progress, global['ng-zorro-antd'].i18n, global.ng.forms));
}(this, (function (exports, keycodes, http, core, rxjs, operators, core$1, animations, platform, common, tooltip, icon, progress, i18n, forms) { 'use strict';

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of the
    License at http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
    WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
    MERCHANTABLITY OR NON-INFRINGEMENT.

    See the Apache Version 2.0 License for specific language governing permissions
    and limitations under the License.
    ***************************************************************************** */
    /* global Reflect, Promise */

    var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };

    function __extends(d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }

    var __assign = function() {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };

    function __rest(s, e) {
        var t = {};
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
            t[p] = s[p];
        if (s != null && typeof Object.getOwnPropertySymbols === "function")
            for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
                if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                    t[p[i]] = s[p[i]];
            }
        return t;
    }

    function __decorate(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;
    }

    function __param(paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); }
    }

    function __metadata(metadataKey, metadataValue) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
    }

    function __awaiter(thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    }

    function __generator(thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    }

    function __exportStar(m, exports) {
        for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
    }

    function __values(o) {
        var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
        if (m) return m.call(o);
        if (o && typeof o.length === "number") return {
            next: function () {
                if (o && i >= o.length) o = void 0;
                return { value: o && o[i++], done: !o };
            }
        };
        throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
    }

    function __read(o, n) {
        var m = typeof Symbol === "function" && o[Symbol.iterator];
        if (!m) return o;
        var i = m.call(o), r, ar = [], e;
        try {
            while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
        }
        catch (error) { e = { error: error }; }
        finally {
            try {
                if (r && !r.done && (m = i["return"])) m.call(i);
            }
            finally { if (e) throw e.error; }
        }
        return ar;
    }

    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }

    function __spreadArrays() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    };

    function __await(v) {
        return this instanceof __await ? (this.v = v, this) : new __await(v);
    }

    function __asyncGenerator(thisArg, _arguments, generator) {
        if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
        var g = generator.apply(thisArg, _arguments || []), i, q = [];
        return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
        function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
        function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
        function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
        function fulfill(value) { resume("next", value); }
        function reject(value) { resume("throw", value); }
        function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
    }

    function __asyncDelegator(o) {
        var i, p;
        return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
        function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
    }

    function __asyncValues(o) {
        if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
        var m = o[Symbol.asyncIterator], i;
        return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
        function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
        function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
    }

    function __makeTemplateObject(cooked, raw) {
        if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
        return cooked;
    };

    function __importStar(mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
        result.default = mod;
        return result;
    }

    function __importDefault(mod) {
        return (mod && mod.__esModule) ? mod : { default: mod };
    }

    function __classPrivateFieldGet(receiver, privateMap) {
        if (!privateMap.has(receiver)) {
            throw new TypeError("attempted to get private field on non-instance");
        }
        return privateMap.get(receiver);
    }

    function __classPrivateFieldSet(receiver, privateMap, value) {
        if (!privateMap.has(receiver)) {
            throw new TypeError("attempted to set private field on non-instance");
        }
        privateMap.set(receiver, value);
        return value;
    }

    var _c0 = ["file"];
    var _c1 = ["nz-upload-btn", ""];
    var _c2 = ["*"];
    var NzUploadBtnComponent = /** @class */ (function () {
        // #endregion
        function NzUploadBtnComponent(http, el, updateHostClassService) {
            this.http = http;
            this.el = el;
            this.updateHostClassService = updateHostClassService;
            this.reqs = {};
            this.inited = false;
            this.destroy = false;
            // #region fields
            this.classes = {};
            // #region styles
            this.prefixCls = 'ant-upload';
            if (!http) {
                throw new Error("Not found 'HttpClient', You can import 'HttpClientModule' in your root module.");
            }
        }
        // #endregion
        NzUploadBtnComponent.prototype.onClick = function () {
            if (this.options.disabled || !this.options.openFileDialogOnClick) {
                return;
            }
            this.file.nativeElement.click();
        };
        NzUploadBtnComponent.prototype.onKeyDown = function (e) {
            if (this.options.disabled) {
                return;
            }
            if (e.key === 'Enter' || e.keyCode === keycodes.ENTER) {
                this.onClick();
            }
        };
        // skip safari bug
        NzUploadBtnComponent.prototype.onFileDrop = function (e) {
            var _this = this;
            if (this.options.disabled || e.type === 'dragover') {
                e.preventDefault();
                return;
            }
            if (this.options.directory) {
                this.traverseFileTree(e.dataTransfer.items);
            }
            else {
                var files = Array.prototype.slice
                    .call(e.dataTransfer.files)
                    .filter(function (file) { return _this.attrAccept(file, _this.options.accept); });
                if (files.length) {
                    this.uploadFiles(files);
                }
            }
            e.preventDefault();
        };
        NzUploadBtnComponent.prototype.onChange = function (e) {
            if (this.options.disabled) {
                return;
            }
            var hie = e.target;
            this.uploadFiles(hie.files);
            hie.value = '';
        };
        NzUploadBtnComponent.prototype.traverseFileTree = function (files) {
            var e_1, _a;
            var _this = this;
            // tslint:disable-next-line:no-any
            var _traverseFileTree = function (item, path) {
                if (item.isFile) {
                    item.file(function (file) {
                        if (_this.attrAccept(file, _this.options.accept)) {
                            _this.uploadFiles([file]);
                        }
                    });
                }
                else if (item.isDirectory) {
                    var dirReader = item.createReader();
                    // tslint:disable-next-line:no-any
                    dirReader.readEntries(function (entries) {
                        var e_2, _a;
                        try {
                            for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
                                var entrieItem = entries_1_1.value;
                                _traverseFileTree(entrieItem, "" + path + item.name + "/");
                            }
                        }
                        catch (e_2_1) { e_2 = { error: e_2_1 }; }
                        finally {
                            try {
                                if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
                            }
                            finally { if (e_2) throw e_2.error; }
                        }
                    });
                }
            };
            try {
                // tslint:disable-next-line:no-any
                for (var _b = __values(files), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var file = _c.value;
                    _traverseFileTree(file.webkitGetAsEntry(), '');
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_1) throw e_1.error; }
            }
        };
        NzUploadBtnComponent.prototype.attrAccept = function (file, acceptedFiles) {
            if (file && acceptedFiles) {
                var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
                var fileName_1 = '' + file.name;
                var mimeType_1 = '' + file.type;
                var baseMimeType_1 = mimeType_1.replace(/\/.*$/, '');
                return acceptedFilesArray.some(function (type) {
                    var validType = type.trim();
                    if (validType.charAt(0) === '.') {
                        return (fileName_1.toLowerCase().indexOf(validType.toLowerCase(), fileName_1.toLowerCase().length - validType.toLowerCase().length) !== -1);
                    }
                    else if (/\/\*$/.test(validType)) {
                        // This is something like a image/* mime type
                        return baseMimeType_1 === validType.replace(/\/.*$/, '');
                    }
                    return mimeType_1 === validType;
                });
            }
            return true;
        };
        NzUploadBtnComponent.prototype.attachUid = function (file) {
            if (!file.uid) {
                file.uid = Math.random()
                    .toString(36)
                    .substring(2);
            }
            return file;
        };
        NzUploadBtnComponent.prototype.uploadFiles = function (fileList) {
            var _this = this;
            var filters$ = rxjs.of(Array.prototype.slice.call(fileList));
            if (this.options.filters) {
                this.options.filters.forEach(function (f) {
                    filters$ = filters$.pipe(operators.switchMap(function (list) {
                        var fnRes = f.fn(list);
                        return fnRes instanceof rxjs.Observable ? fnRes : rxjs.of(fnRes);
                    }));
                });
            }
            filters$.subscribe(function (list) {
                list.forEach(function (file) {
                    _this.attachUid(file);
                    _this.upload(file, list);
                });
            }, function (e) {
                core$1.warn("Unhandled upload filter error", e);
            });
        };
        NzUploadBtnComponent.prototype.upload = function (file, fileList) {
            var _this = this;
            if (!this.options.beforeUpload) {
                return this.post(file);
            }
            var before = this.options.beforeUpload(file, fileList);
            if (before instanceof rxjs.Observable) {
                before.subscribe(function (processedFile) {
                    var processedFileType = Object.prototype.toString.call(processedFile);
                    if (processedFileType === '[object File]' || processedFileType === '[object Blob]') {
                        _this.attachUid(processedFile);
                        _this.post(processedFile);
                    }
                    else if (typeof processedFile === 'boolean' && processedFile !== false) {
                        _this.post(file);
                    }
                }, function (e) {
                    core$1.warn("Unhandled upload beforeUpload error", e);
                });
            }
            else if (before !== false) {
                return this.post(file);
            }
        };
        NzUploadBtnComponent.prototype.post = function (file) {
            var _this = this;
            if (this.destroy) {
                return;
            }
            var process$ = rxjs.of(file);
            var opt = this.options;
            var uid = file.uid;
            var action = opt.action, data = opt.data, headers = opt.headers, transformFile = opt.transformFile;
            var args = {
                action: typeof action === 'string' ? action : '',
                name: opt.name,
                headers: headers,
                file: file,
                postFile: file,
                data: data,
                withCredentials: opt.withCredentials,
                onProgress: opt.onProgress
                    ? function (e) {
                        opt.onProgress(e, file);
                    }
                    : undefined,
                onSuccess: function (ret, xhr) {
                    _this.clean(uid);
                    opt.onSuccess(ret, file, xhr);
                },
                onError: function (xhr) {
                    _this.clean(uid);
                    opt.onError(xhr, file);
                }
            };
            if (typeof action === 'function') {
                var actionResult_1 = action(file);
                if (actionResult_1 instanceof rxjs.Observable) {
                    process$ = process$.pipe(operators.switchMap(function () { return actionResult_1; }), operators.map(function (res) {
                        args.action = res;
                        return file;
                    }));
                }
                else {
                    args.action = actionResult_1;
                }
            }
            if (typeof transformFile === 'function') {
                var transformResult_1 = transformFile(file);
                process$ = process$.pipe(operators.switchMap(function () { return (transformResult_1 instanceof rxjs.Observable ? transformResult_1 : rxjs.of(transformResult_1)); }));
            }
            if (typeof data === 'function') {
                var dataResult_1 = data(file);
                if (dataResult_1 instanceof rxjs.Observable) {
                    process$ = process$.pipe(operators.switchMap(function () { return dataResult_1; }), operators.map(function (res) {
                        args.data = res;
                        return file;
                    }));
                }
                else {
                    args.data = dataResult_1;
                }
            }
            if (typeof headers === 'function') {
                var headersResult_1 = headers(file);
                if (headersResult_1 instanceof rxjs.Observable) {
                    process$ = process$.pipe(operators.switchMap(function () { return headersResult_1; }), operators.map(function (res) {
                        args.headers = res;
                        return file;
                    }));
                }
                else {
                    args.headers = headersResult_1;
                }
            }
            process$.subscribe(function (newFile) {
                args.postFile = newFile;
                var req$ = (opt.customRequest || _this.xhr).call(_this, args);
                if (!(req$ instanceof rxjs.Subscription)) {
                    core$1.warn("Must return Subscription type in '[nzCustomRequest]' property");
                }
                _this.reqs[uid] = req$;
                opt.onStart(file);
            });
        };
        NzUploadBtnComponent.prototype.xhr = function (args) {
            var _this = this;
            var formData = new FormData();
            if (args.data) {
                Object.keys(args.data).map(function (key) {
                    formData.append(key, args.data[key]);
                });
            }
            // tslint:disable-next-line:no-any
            formData.append(args.name, args.postFile);
            if (!args.headers) {
                args.headers = {};
            }
            if (args.headers['X-Requested-With'] !== null) {
                args.headers['X-Requested-With'] = "XMLHttpRequest";
            }
            else {
                delete args.headers['X-Requested-With'];
            }
            var req = new http.HttpRequest('POST', args.action, formData, {
                reportProgress: true,
                withCredentials: args.withCredentials,
                headers: new http.HttpHeaders(args.headers)
            });
            return this.http.request(req).subscribe(
            // tslint:disable-next-line no-any
            function (event) {
                if (event.type === http.HttpEventType.UploadProgress) {
                    if (event.total > 0) {
                        // tslint:disable-next-line:no-any
                        event.percent = (event.loaded / event.total) * 100;
                    }
                    args.onProgress(event, args.file);
                }
                else if (event instanceof http.HttpResponse) {
                    args.onSuccess(event.body, args.file, event);
                }
            }, function (err) {
                _this.abort(args.file);
                args.onError(err, args.file);
            });
        };
        NzUploadBtnComponent.prototype.clean = function (uid) {
            var req$ = this.reqs[uid];
            if (req$ instanceof rxjs.Subscription) {
                req$.unsubscribe();
            }
            delete this.reqs[uid];
        };
        NzUploadBtnComponent.prototype.abort = function (file) {
            var _this = this;
            if (file) {
                this.clean(file && file.uid);
            }
            else {
                Object.keys(this.reqs).forEach(function (uid) { return _this.clean(uid); });
            }
        };
        NzUploadBtnComponent.prototype.setClassMap = function () {
            var _a;
            var classMap = __assign((_a = {}, _a[this.prefixCls] = true, _a[this.prefixCls + "-disabled"] = this.options.disabled, _a), this.classes);
            this.updateHostClassService.updateHostClass(this.el.nativeElement, classMap);
        };
        NzUploadBtnComponent.prototype.ngOnInit = function () {
            this.inited = true;
            this.setClassMap();
        };
        NzUploadBtnComponent.prototype.ngOnChanges = function () {
            if (this.inited) {
                this.setClassMap();
            }
        };
        NzUploadBtnComponent.prototype.ngOnDestroy = function () {
            this.destroy = true;
            this.abort();
        };
        /** @nocollapse */ NzUploadBtnComponent.ɵfac = function NzUploadBtnComponent_Factory(t) { return new (t || NzUploadBtnComponent)(core["ɵɵdirectiveInject"](http.HttpClient, 8), core["ɵɵdirectiveInject"](core.ElementRef), core["ɵɵdirectiveInject"](core$1.NzUpdateHostClassService)); };
        /** @nocollapse */ NzUploadBtnComponent.ɵcmp = core["ɵɵdefineComponent"]({ type: NzUploadBtnComponent, selectors: [["", "nz-upload-btn", ""]], viewQuery: function NzUploadBtnComponent_Query(rf, ctx) { if (rf & 1) {
                core["ɵɵviewQuery"](_c0, true);
            } if (rf & 2) {
                var _t;
                core["ɵɵqueryRefresh"](_t = core["ɵɵloadQuery"]()) && (ctx.file = _t.first);
            } }, hostVars: 2, hostBindings: function NzUploadBtnComponent_HostBindings(rf, ctx) { if (rf & 1) {
                core["ɵɵlistener"]("click", function NzUploadBtnComponent_click_HostBindingHandler() { return ctx.onClick(); })("keydown", function NzUploadBtnComponent_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); })("drop", function NzUploadBtnComponent_drop_HostBindingHandler($event) { return ctx.onFileDrop($event); })("dragover", function NzUploadBtnComponent_dragover_HostBindingHandler($event) { return ctx.onFileDrop($event); });
            } if (rf & 2) {
                core["ɵɵattribute"]("tabindex", "0")("role", "button");
            } }, inputs: { classes: "classes", options: "options" }, exportAs: ["nzUploadBtn"], features: [core["ɵɵProvidersFeature"]([core$1.NzUpdateHostClassService]), core["ɵɵNgOnChangesFeature"]], attrs: _c1, ngContentSelectors: _c2, decls: 3, vars: 4, consts: [["type", "file", 2, "display", "none", 3, "multiple", "change"], ["file", ""]], template: function NzUploadBtnComponent_Template(rf, ctx) { if (rf & 1) {
                core["ɵɵprojectionDef"]();
                core["ɵɵelementStart"](0, "input", 0, 1);
                core["ɵɵlistener"]("change", function NzUploadBtnComponent_Template_input_change_0_listener($event) { return ctx.onChange($event); });
                core["ɵɵelementEnd"]();
                core["ɵɵprojection"](2);
            } if (rf & 2) {
                core["ɵɵproperty"]("multiple", ctx.options.multiple);
                core["ɵɵattribute"]("accept", ctx.options.accept)("directory", ctx.options.directory ? "directory" : null)("webkitdirectory", ctx.options.directory ? "webkitdirectory" : null);
            } }, encapsulation: 2 });
        return NzUploadBtnComponent;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzUploadBtnComponent, [{
            type: core.Component,
            args: [{
                    selector: '[nz-upload-btn]',
                    exportAs: 'nzUploadBtn',
                    templateUrl: './upload-btn.component.html',
                    host: {
                        '[attr.tabindex]': '"0"',
                        '[attr.role]': '"button"'
                    },
                    providers: [core$1.NzUpdateHostClassService],
                    preserveWhitespaces: false,
                    encapsulation: core.ViewEncapsulation.None
                }]
        }], function () { return [{ type: http.HttpClient, decorators: [{
                    type: core.Optional
                }] }, { type: core.ElementRef }, { type: core$1.NzUpdateHostClassService }]; }, { file: [{
                type: core.ViewChild,
                args: ['file', { static: false }]
            }], classes: [{
                type: core.Input
            }], options: [{
                type: core.Input
            }], onClick: [{
                type: core.HostListener,
                args: ['click']
            }], onKeyDown: [{
                type: core.HostListener,
                args: ['keydown', ['$event']]
            }], onFileDrop: [{
                type: core.HostListener,
                args: ['drop', ['$event']]
            }, {
                type: core.HostListener,
                args: ['dragover', ['$event']]
            }] }); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    function NzUploadListComponent_div_0_ng_template_1_div_1_ng_template_1_Template(rf, ctx) { }
    var _c0$1 = function (a0) { return { $implicit: a0 }; };
    function NzUploadListComponent_div_0_ng_template_1_div_1_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "div", 17);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_1_div_1_ng_template_1_Template, 0, 0, "ng-template", 18);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](2).$implicit;
        var _r2500 = core["ɵɵreference"](4);
        core["ɵɵclassProp"]("ant-upload-list-item-file", !file_r2497.isUploading);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2500)("ngTemplateOutletContext", core["ɵɵpureFunction1"](4, _c0$1, file_r2497));
    } }
    function NzUploadListComponent_div_0_ng_template_1_a_2_img_1_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelement"](0, "img", 21);
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](3).$implicit;
        core["ɵɵproperty"]("src", file_r2497.thumbUrl || file_r2497.url, core["ɵɵsanitizeUrl"]);
        core["ɵɵattribute"]("alt", file_r2497.name);
    } }
    function NzUploadListComponent_div_0_ng_template_1_a_2_Template(rf, ctx) { if (rf & 1) {
        var _r2525 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementStart"](0, "a", 19);
        core["ɵɵlistener"]("click", function NzUploadListComponent_div_0_ng_template_1_a_2_Template_a_click_0_listener($event) { core["ɵɵrestoreView"](_r2525); var file_r2497 = core["ɵɵnextContext"](2).$implicit; var ctx_r2523 = core["ɵɵnextContext"](); return ctx_r2523.handlePreview(file_r2497, $event); });
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_1_a_2_img_1_Template, 1, 2, "img", 20);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        core["ɵɵnextContext"]();
        var _r2517 = core["ɵɵreference"](5);
        var file_r2497 = core["ɵɵnextContext"]().$implicit;
        core["ɵɵclassProp"]("ant-upload-list-item-file", !file_r2497.isImageUrl);
        core["ɵɵproperty"]("href", file_r2497.url || file_r2497.thumbUrl, core["ɵɵsanitizeUrl"]);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", file_r2497.isImageUrl)("ngIfElse", _r2517);
    } }
    function NzUploadListComponent_div_0_ng_template_1_span_3_ng_template_1_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_ng_template_1_span_3_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "span", 22);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_1_span_3_ng_template_1_Template, 0, 0, "ng-template", 18);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](2).$implicit;
        var _r2500 = core["ɵɵreference"](4);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2500)("ngTemplateOutletContext", core["ɵɵpureFunction1"](2, _c0$1, file_r2497));
    } }
    function NzUploadListComponent_div_0_ng_template_1_ng_template_4_ng_template_0_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_ng_template_1_ng_template_4_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadListComponent_div_0_ng_template_1_ng_template_4_ng_template_0_Template, 0, 0, "ng-template", 18);
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](2).$implicit;
        var _r2500 = core["ɵɵreference"](4);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2500)("ngTemplateOutletContext", core["ɵɵpureFunction1"](2, _c0$1, file_r2497));
    } }
    function NzUploadListComponent_div_0_ng_template_1_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementContainerStart"](0, 12);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_1_div_1_Template, 2, 6, "div", 13);
        core["ɵɵtemplate"](2, NzUploadListComponent_div_0_ng_template_1_a_2_Template, 2, 5, "a", 14);
        core["ɵɵtemplate"](3, NzUploadListComponent_div_0_ng_template_1_span_3_Template, 2, 4, "span", 15);
        core["ɵɵelementContainerEnd"]();
        core["ɵɵtemplate"](4, NzUploadListComponent_div_0_ng_template_1_ng_template_4_Template, 1, 4, "ng-template", null, 16, core["ɵɵtemplateRefExtractor"]);
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"]().$implicit;
        core["ɵɵproperty"]("ngSwitch", file_r2497.iconType);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngSwitchCase", "uploading");
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngSwitchCase", "thumbnail");
    } }
    function NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementContainerStart"](0);
        core["ɵɵelement"](1, "i", 27);
        core["ɵɵelementContainerEnd"]();
    } }
    function NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementContainerStart"](0);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_2_ng_container_1_Template, 2, 0, "ng-container", 23);
        core["ɵɵelementContainerEnd"]();
    } if (rf & 2) {
        var file_r2532 = core["ɵɵnextContext"](2).$implicit;
        var _r2534 = core["ɵɵreference"](2);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", file_r2532.isUploading)("ngIfElse", _r2534);
    } }
    function NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementContainerStart"](0);
        core["ɵɵtext"](1);
        core["ɵɵelementContainerEnd"]();
    } if (rf & 2) {
        var ctx_r2541 = core["ɵɵnextContext"](5);
        core["ɵɵadvance"](1);
        core["ɵɵtextInterpolate"](ctx_r2541.locale.uploading);
    } }
    function NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementContainerStart"](0);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_3_ng_container_1_Template, 2, 1, "ng-container", 23);
        core["ɵɵelementContainerEnd"]();
    } if (rf & 2) {
        var file_r2532 = core["ɵɵnextContext"](2).$implicit;
        var _r2534 = core["ɵɵreference"](2);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", file_r2532.isUploading)("ngIfElse", _r2534);
    } }
    function NzUploadListComponent_div_0_ng_template_3_ng_container_0_i_4_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelement"](0, "i", 28);
    } if (rf & 2) {
        var file_r2532 = core["ɵɵnextContext"](2).$implicit;
        core["ɵɵproperty"]("nzType", file_r2532.isUploading ? "loading" : "paper-clip");
    } }
    function NzUploadListComponent_div_0_ng_template_3_ng_container_0_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementContainerStart"](0);
        core["ɵɵelementContainerStart"](1, 12);
        core["ɵɵtemplate"](2, NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_2_Template, 2, 2, "ng-container", 25);
        core["ɵɵtemplate"](3, NzUploadListComponent_div_0_ng_template_3_ng_container_0_ng_container_3_Template, 2, 2, "ng-container", 25);
        core["ɵɵtemplate"](4, NzUploadListComponent_div_0_ng_template_3_ng_container_0_i_4_Template, 1, 1, "i", 26);
        core["ɵɵelementContainerEnd"]();
        core["ɵɵelementContainerEnd"]();
    } if (rf & 2) {
        var ctx_r2533 = core["ɵɵnextContext"](3);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngSwitch", ctx_r2533.listType);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngSwitchCase", "picture");
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngSwitchCase", "picture-card");
    } }
    function NzUploadListComponent_div_0_ng_template_3_ng_template_1_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelement"](0, "i", 29);
    } if (rf & 2) {
        var file_r2532 = core["ɵɵnextContext"]().$implicit;
        core["ɵɵproperty"]("nzType", file_r2532.isImageUrl ? "picture" : "file");
    } }
    function NzUploadListComponent_div_0_ng_template_3_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadListComponent_div_0_ng_template_3_ng_container_0_Template, 5, 3, "ng-container", 23);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_3_ng_template_1_Template, 1, 1, "ng-template", null, 24, core["ɵɵtemplateRefExtractor"]);
    } if (rf & 2) {
        var ctx_r2501 = core["ɵɵnextContext"](2);
        core["ɵɵproperty"]("ngIf", !ctx_r2501.iconRender)("ngIfElse", ctx_r2501.iconRender);
    } }
    function NzUploadListComponent_div_0_ng_template_5_span_0_a_1_ng_template_1_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_ng_template_5_span_0_a_1_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "a", 32);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_5_span_0_a_1_ng_template_1_Template, 0, 0, "ng-template", 9);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        core["ɵɵnextContext"](3);
        var _r2508 = core["ɵɵreference"](12);
        var ctx_r2546 = core["ɵɵnextContext"]();
        core["ɵɵpropertyInterpolate"]("title", ctx_r2546.locale.downloadFile);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2508);
    } }
    function NzUploadListComponent_div_0_ng_template_5_span_0_a_2_ng_template_1_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_ng_template_5_span_0_a_2_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "a", 32);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_5_span_0_a_2_ng_template_1_Template, 0, 0, "ng-template", 9);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        core["ɵɵnextContext"](3);
        var _r2506 = core["ɵɵreference"](10);
        var ctx_r2547 = core["ɵɵnextContext"]();
        core["ɵɵpropertyInterpolate"]("title", ctx_r2547.locale.removeFile);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2506);
    } }
    function NzUploadListComponent_div_0_ng_template_5_span_0_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "span");
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_5_span_0_a_1_Template, 2, 2, "a", 31);
        core["ɵɵtemplate"](2, NzUploadListComponent_div_0_ng_template_5_span_0_a_2_Template, 2, 2, "a", 31);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](2).$implicit;
        var ctx_r2545 = core["ɵɵnextContext"]();
        core["ɵɵclassMapInterpolate1"]("ant-upload-list-item-card-actions ", ctx_r2545.listType === "picture" ? "picture" : "", "");
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", file_r2497.showDownload);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", ctx_r2545.icons.showRemoveIcon);
    } }
    function NzUploadListComponent_div_0_ng_template_5_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadListComponent_div_0_ng_template_5_span_0_Template, 3, 5, "span", 30);
    } if (rf & 2) {
        var ctx_r2503 = core["ɵɵnextContext"](2);
        core["ɵɵproperty"]("ngIf", ctx_r2503.listType !== "picture-card");
    } }
    function NzUploadListComponent_div_0_ng_template_7_a_0_Template(rf, ctx) { if (rf & 1) {
        var _r2556 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementStart"](0, "a", 35);
        core["ɵɵlistener"]("click", function NzUploadListComponent_div_0_ng_template_7_a_0_Template_a_click_0_listener($event) { core["ɵɵrestoreView"](_r2556); var file_r2497 = core["ɵɵnextContext"](2).$implicit; var ctx_r2554 = core["ɵɵnextContext"](); return ctx_r2554.handlePreview(file_r2497, $event); });
        core["ɵɵtext"](1);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](2).$implicit;
        core["ɵɵpropertyInterpolate"]("title", file_r2497.name);
        core["ɵɵproperty"]("ngClass", file_r2497.listItemNameCls)("href", file_r2497.url, core["ɵɵsanitizeUrl"]);
        core["ɵɵattribute"]("download", file_r2497.linkProps && file_r2497.linkProps.download);
        core["ɵɵadvance"](1);
        core["ɵɵtextInterpolate"](file_r2497.name);
    } }
    function NzUploadListComponent_div_0_ng_template_7_span_1_Template(rf, ctx) { if (rf & 1) {
        var _r2560 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementStart"](0, "span", 36);
        core["ɵɵlistener"]("click", function NzUploadListComponent_div_0_ng_template_7_span_1_Template_span_click_0_listener($event) { core["ɵɵrestoreView"](_r2560); var file_r2497 = core["ɵɵnextContext"](2).$implicit; var ctx_r2558 = core["ɵɵnextContext"](); return ctx_r2558.handlePreview(file_r2497, $event); });
        core["ɵɵtext"](1);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](2).$implicit;
        core["ɵɵpropertyInterpolate"]("title", file_r2497.name);
        core["ɵɵproperty"]("ngClass", file_r2497.listItemNameCls);
        core["ɵɵadvance"](1);
        core["ɵɵtextInterpolate"](file_r2497.name);
    } }
    function NzUploadListComponent_div_0_ng_template_7_ng_template_2_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_ng_template_7_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadListComponent_div_0_ng_template_7_a_0_Template, 2, 5, "a", 33);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_7_span_1_Template, 2, 3, "span", 34);
        core["ɵɵtemplate"](2, NzUploadListComponent_div_0_ng_template_7_ng_template_2_Template, 0, 0, "ng-template", 9);
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"]().$implicit;
        var _r2502 = core["ɵɵreference"](6);
        core["ɵɵproperty"]("ngIf", file_r2497.url);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", !file_r2497.url);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2502);
    } }
    function NzUploadListComponent_div_0_ng_template_9_i_0_Template(rf, ctx) { if (rf & 1) {
        var _r2566 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementStart"](0, "i", 38);
        core["ɵɵlistener"]("click", function NzUploadListComponent_div_0_ng_template_9_i_0_Template_i_click_0_listener($event) { core["ɵɵrestoreView"](_r2566); var file_r2497 = core["ɵɵnextContext"](2).$implicit; var ctx_r2564 = core["ɵɵnextContext"](); return ctx_r2564.handleRemove(file_r2497, $event); });
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var ctx_r2563 = core["ɵɵnextContext"](3);
        core["ɵɵpropertyInterpolate"]("title", ctx_r2563.locale.removeFile);
    } }
    function NzUploadListComponent_div_0_ng_template_9_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadListComponent_div_0_ng_template_9_i_0_Template, 1, 1, "i", 37);
    } if (rf & 2) {
        var ctx_r2507 = core["ɵɵnextContext"](2);
        core["ɵɵproperty"]("ngIf", ctx_r2507.icons.showRemoveIcon);
    } }
    function NzUploadListComponent_div_0_ng_template_11_i_0_Template(rf, ctx) { if (rf & 1) {
        var _r2570 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementStart"](0, "i", 40);
        core["ɵɵlistener"]("click", function NzUploadListComponent_div_0_ng_template_11_i_0_Template_i_click_0_listener() { core["ɵɵrestoreView"](_r2570); var file_r2497 = core["ɵɵnextContext"](2).$implicit; var ctx_r2568 = core["ɵɵnextContext"](); return ctx_r2568.handleDownload(file_r2497); });
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var ctx_r2567 = core["ɵɵnextContext"](3);
        core["ɵɵpropertyInterpolate"]("title", ctx_r2567.locale.downloadFile);
    } }
    function NzUploadListComponent_div_0_ng_template_11_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadListComponent_div_0_ng_template_11_i_0_Template, 1, 1, "i", 39);
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"]().$implicit;
        core["ɵɵproperty"]("ngIf", file_r2497.showDownload);
    } }
    function NzUploadListComponent_div_0_ng_template_15_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_ng_template_16_Template(rf, ctx) { }
    var _c1$1 = function () { return { opacity: 0.5, "pointer-events": "none" }; };
    function NzUploadListComponent_div_0_span_17_a_1_Template(rf, ctx) { if (rf & 1) {
        var _r2577 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementStart"](0, "a", 43);
        core["ɵɵlistener"]("click", function NzUploadListComponent_div_0_span_17_a_1_Template_a_click_0_listener($event) { core["ɵɵrestoreView"](_r2577); var file_r2497 = core["ɵɵnextContext"](2).$implicit; var ctx_r2575 = core["ɵɵnextContext"](); return ctx_r2575.handlePreview(file_r2497, $event); });
        core["ɵɵelement"](1, "i", 44);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"](2).$implicit;
        var ctx_r2572 = core["ɵɵnextContext"]();
        core["ɵɵpropertyInterpolate"]("title", ctx_r2572.locale.previewFile);
        core["ɵɵproperty"]("href", file_r2497.url || file_r2497.thumbUrl, core["ɵɵsanitizeUrl"])("ngStyle", !(file_r2497.url || file_r2497.thumbUrl) && core["ɵɵpureFunction0"](3, _c1$1));
    } }
    function NzUploadListComponent_div_0_span_17_ng_template_2_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_span_17_ng_template_3_Template(rf, ctx) { }
    function NzUploadListComponent_div_0_span_17_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "span", 41);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_span_17_a_1_Template, 2, 4, "a", 42);
        core["ɵɵtemplate"](2, NzUploadListComponent_div_0_span_17_ng_template_2_Template, 0, 0, "ng-template", 9);
        core["ɵɵtemplate"](3, NzUploadListComponent_div_0_span_17_ng_template_3_Template, 0, 0, "ng-template", 9);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        core["ɵɵnextContext"]();
        var _r2508 = core["ɵɵreference"](12);
        var _r2506 = core["ɵɵreference"](10);
        var ctx_r2512 = core["ɵɵnextContext"]();
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", ctx_r2512.icons.showPreviewIcon);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2508);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2506);
    } }
    function NzUploadListComponent_div_0_div_18_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "div", 45);
        core["ɵɵelement"](1, "nz-progress", 46);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = core["ɵɵnextContext"]().$implicit;
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("nzPercent", file_r2497.percent)("nzShowInfo", false)("nzStrokeWidth", 2);
    } }
    function NzUploadListComponent_div_0_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "div", 1);
        core["ɵɵtemplate"](1, NzUploadListComponent_div_0_ng_template_1_Template, 6, 3, "ng-template", null, 2, core["ɵɵtemplateRefExtractor"]);
        core["ɵɵtemplate"](3, NzUploadListComponent_div_0_ng_template_3_Template, 3, 2, "ng-template", null, 3, core["ɵɵtemplateRefExtractor"]);
        core["ɵɵtemplate"](5, NzUploadListComponent_div_0_ng_template_5_Template, 1, 1, "ng-template", null, 4, core["ɵɵtemplateRefExtractor"]);
        core["ɵɵtemplate"](7, NzUploadListComponent_div_0_ng_template_7_Template, 3, 3, "ng-template", null, 5, core["ɵɵtemplateRefExtractor"]);
        core["ɵɵtemplate"](9, NzUploadListComponent_div_0_ng_template_9_Template, 1, 1, "ng-template", null, 6, core["ɵɵtemplateRefExtractor"]);
        core["ɵɵtemplate"](11, NzUploadListComponent_div_0_ng_template_11_Template, 1, 1, "ng-template", null, 7, core["ɵɵtemplateRefExtractor"]);
        core["ɵɵelementStart"](13, "div", 8);
        core["ɵɵelementStart"](14, "span");
        core["ɵɵtemplate"](15, NzUploadListComponent_div_0_ng_template_15_Template, 0, 0, "ng-template", 9);
        core["ɵɵtemplate"](16, NzUploadListComponent_div_0_ng_template_16_Template, 0, 0, "ng-template", 9);
        core["ɵɵelementEnd"]();
        core["ɵɵelementEnd"]();
        core["ɵɵtemplate"](17, NzUploadListComponent_div_0_span_17_Template, 4, 3, "span", 10);
        core["ɵɵtemplate"](18, NzUploadListComponent_div_0_div_18_Template, 2, 3, "div", 11);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var file_r2497 = ctx.$implicit;
        var _r2498 = core["ɵɵreference"](2);
        var _r2504 = core["ɵɵreference"](8);
        var ctx_r2496 = core["ɵɵnextContext"]();
        core["ɵɵclassMapInterpolate2"]("ant-upload-list-item ant-upload-list-item-", file_r2497.status, " ant-upload-list-item-list-type-", ctx_r2496.listType, "");
        core["ɵɵproperty"]("@itemState", undefined)("nzTooltipTitle", file_r2497.status === "error" ? file_r2497.message : null);
        core["ɵɵattribute"]("data-key", file_r2497.key);
        core["ɵɵadvance"](15);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2498);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2504);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", ctx_r2496.listType === "picture-card" && !file_r2497.isUploading);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngIf", file_r2497.isUploading);
    } }
    var isImageFileType = function (type) { return !!type && type.indexOf('image/') === 0; };
    var MEASURE_SIZE = 200;
    var NzUploadListComponent = /** @class */ (function () {
        // #endregion
        function NzUploadListComponent(el, cdr, updateHostClassService, doc, // tslint:disable-line no-any
        ngZone, platform) {
            this.el = el;
            this.cdr = cdr;
            this.updateHostClassService = updateHostClassService;
            this.doc = doc;
            this.ngZone = ngZone;
            this.platform = platform;
            // #region fields
            // tslint:disable-next-line:no-any
            this.locale = {};
            // #endregion
            // #region styles
            this.prefixCls = 'ant-upload-list';
        }
        Object.defineProperty(NzUploadListComponent.prototype, "showPic", {
            get: function () {
                return this.listType === 'picture' || this.listType === 'picture-card';
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NzUploadListComponent.prototype, "items", {
            set: function (list) {
                this.list = list;
            },
            enumerable: true,
            configurable: true
        });
        NzUploadListComponent.prototype.setClassMap = function () {
            var _a;
            var classMap = (_a = {},
                _a[this.prefixCls] = true,
                _a[this.prefixCls + "-" + this.listType] = true,
                _a);
            this.updateHostClassService.updateHostClass(this.el.nativeElement, classMap);
            return this;
        };
        // #endregion
        // #region render
        NzUploadListComponent.prototype.genErr = function (file) {
            if (file.response && typeof file.response === 'string') {
                return file.response;
            }
            return (file.error && file.error.statusText) || this.locale.uploadError;
        };
        NzUploadListComponent.prototype.extname = function (url) {
            var temp = url.split('/');
            var filename = temp[temp.length - 1];
            var filenameWithoutSuffix = filename.split(/#|\?/)[0];
            return (/\.[^./\\]*$/.exec(filenameWithoutSuffix) || [''])[0];
        };
        NzUploadListComponent.prototype.isImageUrl = function (file) {
            if (isImageFileType(file.type)) {
                return true;
            }
            var url = (file.thumbUrl || file.url || '');
            if (!url) {
                return false;
            }
            var extension = this.extname(url);
            if (/^data:image\//.test(url) || /(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg)$/i.test(extension)) {
                return true;
            }
            else if (/^data:/.test(url)) {
                // other file types of base64
                return false;
            }
            else if (extension) {
                // other file types which have extension
                return false;
            }
            return true;
        };
        NzUploadListComponent.prototype.getIconType = function (file) {
            if (!this.showPic) {
                return '';
            }
            if (file.isUploading || (!file.thumbUrl && !file.url)) {
                return 'uploading';
            }
            else {
                return 'thumbnail';
            }
        };
        NzUploadListComponent.prototype.previewImage = function (file) {
            var _this = this;
            return new Promise(function (resolve) {
                if (!isImageFileType(file.type)) {
                    resolve('');
                    return;
                }
                _this.ngZone.runOutsideAngular(function () {
                    var canvas = _this.doc.createElement('canvas');
                    canvas.width = MEASURE_SIZE;
                    canvas.height = MEASURE_SIZE;
                    canvas.style.cssText = "position: fixed; left: 0; top: 0; width: " + MEASURE_SIZE + "px; height: " + MEASURE_SIZE + "px; z-index: 9999; display: none;";
                    _this.doc.body.appendChild(canvas);
                    var ctx = canvas.getContext('2d');
                    var img = new Image();
                    img.onload = function () {
                        var width = img.width, height = img.height;
                        var drawWidth = MEASURE_SIZE;
                        var drawHeight = MEASURE_SIZE;
                        var offsetX = 0;
                        var offsetY = 0;
                        if (width < height) {
                            drawHeight = height * (MEASURE_SIZE / width);
                            offsetY = -(drawHeight - drawWidth) / 2;
                        }
                        else {
                            drawWidth = width * (MEASURE_SIZE / height);
                            offsetX = -(drawWidth - drawHeight) / 2;
                        }
                        try {
                            ctx.drawImage(img, offsetX, offsetY, drawWidth, drawHeight);
                        }
                        catch (_a) { }
                        var dataURL = canvas.toDataURL();
                        _this.doc.body.removeChild(canvas);
                        resolve(dataURL);
                    };
                    img.src = window.URL.createObjectURL(file);
                });
            });
        };
        NzUploadListComponent.prototype.genThumb = function () {
            var _this = this;
            if (!this.platform.isBrowser) {
                return;
            }
            // tslint:disable-next-line:no-any
            var win = window;
            if (!this.showPic || typeof document === 'undefined' || typeof win === 'undefined' || !win.FileReader || !win.File) {
                return;
            }
            this.list
                .filter(function (file) { return file.originFileObj instanceof File && file.thumbUrl === undefined; })
                .forEach(function (file) {
                file.thumbUrl = '';
                (_this.previewFile ? _this.previewFile(file).toPromise() : _this.previewImage(file.originFileObj)).then(function (dataUrl) {
                    file.thumbUrl = dataUrl;
                    _this.detectChanges();
                });
            });
        };
        NzUploadListComponent.prototype.listItemNameCls = function (file) {
            var _a;
            var count = [this.showDownload(file), this.icons.showRemoveIcon].filter(function (x) { return x; }).length;
            return _a = {},
                _a[this.prefixCls + "-item-name"] = true,
                _a[this.prefixCls + "-item-name-icon-count-" + count] = true,
                _a;
        };
        NzUploadListComponent.prototype.showDownload = function (file) {
            return this.icons.showDownloadIcon && file.status === 'done' ? true : false;
        };
        NzUploadListComponent.prototype.fixData = function () {
            var _this = this;
            this.list.forEach(function (file) {
                file.message = _this.genErr(file);
                file.linkProps = typeof file.linkProps === 'string' ? JSON.parse(file.linkProps) : file.linkProps;
                file.isImageUrl = _this.isImageUrl(file);
                file.iconType = _this.getIconType(file);
                file.isUploading = file.status === 'uploading';
                file.listItemNameCls = _this.listItemNameCls(file);
                file.showDownload = _this.showDownload(file);
            });
            return this;
        };
        NzUploadListComponent.prototype.handlePreview = function (file, e) {
            if (!this.onPreview) {
                return;
            }
            e.preventDefault();
            return this.onPreview(file);
        };
        NzUploadListComponent.prototype.handleRemove = function (file, e) {
            e.preventDefault();
            if (this.onRemove) {
                this.onRemove(file);
            }
            return;
        };
        NzUploadListComponent.prototype.handleDownload = function (file) {
            if (typeof this.onDownload === 'function') {
                this.onDownload(file);
            }
            else if (file.url) {
                window.open(file.url);
            }
        };
        NzUploadListComponent.prototype.detectChanges = function () {
            this.fixData();
            this.cdr.detectChanges();
        };
        NzUploadListComponent.prototype.ngOnChanges = function () {
            this.fixData()
                .setClassMap()
                .genThumb();
        };
        /** @nocollapse */ NzUploadListComponent.ɵfac = function NzUploadListComponent_Factory(t) { return new (t || NzUploadListComponent)(core["ɵɵdirectiveInject"](core.ElementRef), core["ɵɵdirectiveInject"](core.ChangeDetectorRef), core["ɵɵdirectiveInject"](core$1.NzUpdateHostClassService), core["ɵɵdirectiveInject"](common.DOCUMENT), core["ɵɵdirectiveInject"](core.NgZone), core["ɵɵdirectiveInject"](platform.Platform)); };
        /** @nocollapse */ NzUploadListComponent.ɵcmp = core["ɵɵdefineComponent"]({ type: NzUploadListComponent, selectors: [["nz-upload-list"]], inputs: { locale: "locale", listType: "listType", items: "items", icons: "icons", onPreview: "onPreview", onRemove: "onRemove", onDownload: "onDownload", previewFile: "previewFile", iconRender: "iconRender" }, exportAs: ["nzUploadList"], features: [core["ɵɵProvidersFeature"]([core$1.NzUpdateHostClassService]), core["ɵɵNgOnChangesFeature"]], decls: 1, vars: 1, consts: [["nz-tooltip", "", 3, "class", "nzTooltipTitle", 4, "ngFor", "ngForOf"], ["nz-tooltip", "", 3, "nzTooltipTitle"], ["icon", ""], ["iconNode", ""], ["downloadOrDelete", ""], ["preview", ""], ["removeIcon", ""], ["downloadIcon", ""], [1, "ant-upload-list-item-info"], [3, "ngTemplateOutlet"], ["class", "ant-upload-list-item-actions", 4, "ngIf"], ["class", "ant-upload-list-item-progress", 4, "ngIf"], [3, "ngSwitch"], ["class", "ant-upload-list-item-thumbnail", 3, "ant-upload-list-item-file", 4, "ngSwitchCase"], ["class", "ant-upload-list-item-thumbnail", "target", "_blank", "rel", "noopener noreferrer", 3, "ant-upload-list-item-file", "href", "click", 4, "ngSwitchCase"], ["class", "ant-upload-text-icon", 4, "ngSwitchDefault"], ["noImageThumbTpl", ""], [1, "ant-upload-list-item-thumbnail"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], ["target", "_blank", "rel", "noopener noreferrer", 1, "ant-upload-list-item-thumbnail", 3, "href", "click"], ["class", "ant-upload-list-item-image", 3, "src", 4, "ngIf", "ngIfElse"], [1, "ant-upload-list-item-image", 3, "src"], [1, "ant-upload-text-icon"], [4, "ngIf", "ngIfElse"], ["iconNodeFileIcon", ""], [4, "ngSwitchCase"], ["nz-icon", "", 3, "nzType", 4, "ngSwitchDefault"], ["nz-icon", "", "nzType", "loading"], ["nz-icon", "", 3, "nzType"], ["nz-icon", "", "nzTheme", "twotone", 3, "nzType"], [3, "class", 4, "ngIf"], [3, "title", 4, "ngIf"], [3, "title"], ["target", "_blank", "rel", "noopener noreferrer", 3, "ngClass", "title", "href", "click", 4, "ngIf"], [3, "ngClass", "title", "click", 4, "ngIf"], ["target", "_blank", "rel", "noopener noreferrer", 3, "ngClass", "title", "href", "click"], [3, "ngClass", "title", "click"], ["nz-icon", "", "nzType", "delete", 3, "title", "click", 4, "ngIf"], ["nz-icon", "", "nzType", "delete", 3, "title", "click"], ["nz-icon", "", "nzType", "download", 3, "title", "click", 4, "ngIf"], ["nz-icon", "", "nzType", "download", 3, "title", "click"], [1, "ant-upload-list-item-actions"], ["target", "_blank", "rel", "noopener noreferrer", 3, "href", "title", "ngStyle", "click", 4, "ngIf"], ["target", "_blank", "rel", "noopener noreferrer", 3, "href", "title", "ngStyle", "click"], ["nz-icon", "", "nzType", "eye"], [1, "ant-upload-list-item-progress"], ["nzType", "line", 3, "nzPercent", "nzShowInfo", "nzStrokeWidth"]], template: function NzUploadListComponent_Template(rf, ctx) { if (rf & 1) {
                core["ɵɵtemplate"](0, NzUploadListComponent_div_0_Template, 19, 11, "div", 0);
            } if (rf & 2) {
                core["ɵɵproperty"]("ngForOf", ctx.list);
            } }, directives: [common.NgForOf, tooltip.NzTooltipDirective, common.NgTemplateOutlet, common.NgIf, common.NgSwitch, common.NgSwitchCase, common.NgSwitchDefault, icon.NzIconDirective, common.NgClass, common.NgStyle, progress.NzProgressComponent], encapsulation: 2, data: { animation: [
                    animations.trigger('itemState', [
                        animations.transition(':enter', [animations.style({ height: '0', width: '0', opacity: 0 }), animations.animate(150, animations.style({ height: '*', width: '*', opacity: 1 }))]),
                        animations.transition(':leave', [animations.animate(150, animations.style({ height: '0', width: '0', opacity: 0 }))])
                    ])
                ] }, changeDetection: 0 });
        return NzUploadListComponent;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzUploadListComponent, [{
            type: core.Component,
            args: [{
                    selector: 'nz-upload-list',
                    exportAs: 'nzUploadList',
                    templateUrl: './upload-list.component.html',
                    providers: [core$1.NzUpdateHostClassService],
                    animations: [
                        animations.trigger('itemState', [
                            animations.transition(':enter', [animations.style({ height: '0', width: '0', opacity: 0 }), animations.animate(150, animations.style({ height: '*', width: '*', opacity: 1 }))]),
                            animations.transition(':leave', [animations.animate(150, animations.style({ height: '0', width: '0', opacity: 0 }))])
                        ])
                    ],
                    preserveWhitespaces: false,
                    encapsulation: core.ViewEncapsulation.None,
                    changeDetection: core.ChangeDetectionStrategy.OnPush
                }]
        }], function () { return [{ type: core.ElementRef }, { type: core.ChangeDetectorRef }, { type: core$1.NzUpdateHostClassService }, { type: undefined, decorators: [{
                    type: core.Inject,
                    args: [common.DOCUMENT]
                }] }, { type: core.NgZone }, { type: platform.Platform }]; }, { locale: [{
                type: core.Input
            }], listType: [{
                type: core.Input
            }], items: [{
                type: core.Input
            }], icons: [{
                type: core.Input
            }], onPreview: [{
                type: core.Input
            }], onRemove: [{
                type: core.Input
            }], onDownload: [{
                type: core.Input
            }], previewFile: [{
                type: core.Input
            }], iconRender: [{
                type: core.Input
            }] }); })();

    var _c0$2 = ["uploadComp"];
    var _c1$2 = ["listComp"];
    var _c2$1 = function () { return []; };
    function NzUploadComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelement"](0, "nz-upload-list", 6, 7);
    } if (rf & 2) {
        var ctx_r2581 = core["ɵɵnextContext"]();
        core["ɵɵstyleProp"]("display", ctx_r2581.nzShowUploadList ? "" : "none");
        core["ɵɵproperty"]("locale", ctx_r2581.locale)("listType", ctx_r2581.nzListType)("items", ctx_r2581.nzFileList || core["ɵɵpureFunction0"](11, _c2$1))("icons", ctx_r2581.nzShowUploadList)("iconRender", ctx_r2581.nzIconRender)("previewFile", ctx_r2581.nzPreviewFile)("onPreview", ctx_r2581.nzPreview)("onRemove", ctx_r2581.onRemove)("onDownload", ctx_r2581.nzDownload);
    } }
    function NzUploadComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵprojection"](0);
    } }
    function NzUploadComponent_ng_template_4_ng_template_3_Template(rf, ctx) { }
    function NzUploadComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementStart"](0, "div", 8);
        core["ɵɵelementStart"](1, "div", 9, 10);
        core["ɵɵtemplate"](3, NzUploadComponent_ng_template_4_ng_template_3_Template, 0, 0, "ng-template", 11);
        core["ɵɵelementEnd"]();
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var ctx_r2585 = core["ɵɵnextContext"]();
        var _r2582 = core["ɵɵreference"](3);
        core["ɵɵstyleProp"]("display", ctx_r2585.nzShowButton ? "" : "none");
        core["ɵɵproperty"]("ngClass", ctx_r2585.classList);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("options", ctx_r2585._btnOptions);
        core["ɵɵadvance"](2);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2582);
    } }
    function NzUploadComponent_ng_container_6_ng_template_5_Template(rf, ctx) { }
    function NzUploadComponent_ng_container_6_ng_template_6_Template(rf, ctx) { }
    var _c3 = function () { return { "ant-upload-btn": true }; };
    function NzUploadComponent_ng_container_6_Template(rf, ctx) { if (rf & 1) {
        var _r2598 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementContainerStart"](0);
        core["ɵɵelementStart"](1, "div", 12);
        core["ɵɵlistener"]("drop", function NzUploadComponent_ng_container_6_Template_div_drop_1_listener($event) { core["ɵɵrestoreView"](_r2598); var ctx_r2597 = core["ɵɵnextContext"](); return ctx_r2597.fileDrop($event); })("dragover", function NzUploadComponent_ng_container_6_Template_div_dragover_1_listener($event) { core["ɵɵrestoreView"](_r2598); var ctx_r2599 = core["ɵɵnextContext"](); return ctx_r2599.fileDrop($event); })("dragleave", function NzUploadComponent_ng_container_6_Template_div_dragleave_1_listener($event) { core["ɵɵrestoreView"](_r2598); var ctx_r2600 = core["ɵɵnextContext"](); return ctx_r2600.fileDrop($event); });
        core["ɵɵelementStart"](2, "div", 13, 10);
        core["ɵɵelementStart"](4, "div", 14);
        core["ɵɵtemplate"](5, NzUploadComponent_ng_container_6_ng_template_5_Template, 0, 0, "ng-template", 11);
        core["ɵɵelementEnd"]();
        core["ɵɵelementEnd"]();
        core["ɵɵelementEnd"]();
        core["ɵɵtemplate"](6, NzUploadComponent_ng_container_6_ng_template_6_Template, 0, 0, "ng-template", 11);
        core["ɵɵelementContainerEnd"]();
    } if (rf & 2) {
        var ctx_r2586 = core["ɵɵnextContext"]();
        var _r2582 = core["ɵɵreference"](3);
        var _r2580 = core["ɵɵreference"](1);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngClass", ctx_r2586.classList);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("options", ctx_r2586._btnOptions)("classes", core["ɵɵpureFunction0"](5, _c3));
        core["ɵɵadvance"](3);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2582);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2580);
    } }
    function NzUploadComponent_ng_template_7_ng_container_0_ng_template_1_Template(rf, ctx) { }
    function NzUploadComponent_ng_template_7_ng_container_0_ng_template_2_Template(rf, ctx) { }
    function NzUploadComponent_ng_template_7_ng_container_0_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵelementContainerStart"](0);
        core["ɵɵtemplate"](1, NzUploadComponent_ng_template_7_ng_container_0_ng_template_1_Template, 0, 0, "ng-template", 11);
        core["ɵɵtemplate"](2, NzUploadComponent_ng_template_7_ng_container_0_ng_template_2_Template, 0, 0, "ng-template", 11);
        core["ɵɵelementContainerEnd"]();
    } if (rf & 2) {
        core["ɵɵnextContext"](2);
        var _r2580 = core["ɵɵreference"](1);
        var _r2584 = core["ɵɵreference"](5);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2580);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2584);
    } }
    function NzUploadComponent_ng_template_7_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadComponent_ng_template_7_ng_container_0_Template, 3, 2, "ng-container", 3);
    } if (rf & 2) {
        var ctx_r2588 = core["ɵɵnextContext"]();
        var _r2589 = core["ɵɵreference"](10);
        core["ɵɵproperty"]("ngIf", ctx_r2588.nzListType === "picture-card")("ngIfElse", _r2589);
    } }
    function NzUploadComponent_ng_template_9_ng_template_0_Template(rf, ctx) { }
    function NzUploadComponent_ng_template_9_ng_template_1_Template(rf, ctx) { }
    function NzUploadComponent_ng_template_9_Template(rf, ctx) { if (rf & 1) {
        core["ɵɵtemplate"](0, NzUploadComponent_ng_template_9_ng_template_0_Template, 0, 0, "ng-template", 11);
        core["ɵɵtemplate"](1, NzUploadComponent_ng_template_9_ng_template_1_Template, 0, 0, "ng-template", 11);
    } if (rf & 2) {
        core["ɵɵnextContext"]();
        var _r2584 = core["ɵɵreference"](5);
        var _r2580 = core["ɵɵreference"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2584);
        core["ɵɵadvance"](1);
        core["ɵɵproperty"]("ngTemplateOutlet", _r2580);
    } }
    var _c4 = ["*"];
    var NzUploadComponent = /** @class */ (function () {
        // #endregion
        function NzUploadComponent(cdr, i18n) {
            var _this = this;
            this.cdr = cdr;
            this.i18n = i18n;
            // tslint:disable-next-line:no-any
            this.locale = {};
            // #region fields
            this.nzType = 'select';
            this.nzLimit = 0;
            this.nzSize = 0;
            this.nzDirectory = false;
            this.nzOpenFileDialogOnClick = true;
            this.nzFilter = [];
            this.nzFileList = [];
            this.nzDisabled = false;
            this.nzListType = 'text';
            this.nzMultiple = false;
            this.nzName = 'file';
            this._showUploadList = true;
            this.nzShowButton = true;
            this.nzWithCredentials = false;
            this.nzChange = new core.EventEmitter();
            this.nzFileListChange = new core.EventEmitter();
            this.onStart = function (file) {
                if (!_this.nzFileList) {
                    _this.nzFileList = [];
                }
                var targetItem = _this.fileToObject(file);
                targetItem.status = 'uploading';
                _this.nzFileList = _this.nzFileList.concat(targetItem);
                _this.nzFileListChange.emit(_this.nzFileList);
                _this.nzChange.emit({ file: targetItem, fileList: _this.nzFileList, type: 'start' });
                _this.detectChangesList();
            };
            this.onProgress = function (e, file) {
                var fileList = _this.nzFileList;
                var targetItem = _this.getFileItem(file, fileList);
                targetItem.percent = e.percent;
                _this.nzChange.emit({
                    event: e,
                    file: __assign({}, targetItem),
                    fileList: _this.nzFileList,
                    type: 'progress'
                });
                _this.detectChangesList();
            };
            this.onSuccess = function (res, file) {
                var fileList = _this.nzFileList;
                var targetItem = _this.getFileItem(file, fileList);
                targetItem.status = 'done';
                targetItem.response = res;
                _this.nzChange.emit({
                    file: __assign({}, targetItem),
                    fileList: fileList,
                    type: 'success'
                });
                _this.detectChangesList();
            };
            this.onError = function (err, file) {
                var fileList = _this.nzFileList;
                var targetItem = _this.getFileItem(file, fileList);
                targetItem.error = err;
                targetItem.status = 'error';
                _this.nzChange.emit({
                    file: __assign({}, targetItem),
                    fileList: fileList,
                    type: 'error'
                });
                _this.detectChangesList();
            };
            this.onRemove = function (file) {
                _this.uploadComp.abort(file);
                file.status = 'removed';
                var fnRes = typeof _this.nzRemove === 'function' ? _this.nzRemove(file) : _this.nzRemove == null ? true : _this.nzRemove;
                (fnRes instanceof rxjs.Observable ? fnRes : rxjs.of(fnRes)).pipe(operators.filter(function (res) { return res; })).subscribe(function () {
                    _this.nzFileList = _this.removeFileItem(file, _this.nzFileList);
                    _this.nzChange.emit({
                        file: file,
                        fileList: _this.nzFileList,
                        type: 'removed'
                    });
                    _this.nzFileListChange.emit(_this.nzFileList);
                    _this.cdr.detectChanges();
                });
            };
            // #endregion
            // #region styles
            this.prefixCls = 'ant-upload';
            this.classList = [];
        }
        Object.defineProperty(NzUploadComponent.prototype, "nzShowUploadList", {
            get: function () {
                return this._showUploadList;
            },
            set: function (value) {
                this._showUploadList = typeof value === 'boolean' ? core$1.toBoolean(value) : value;
            },
            enumerable: true,
            configurable: true
        });
        NzUploadComponent.prototype.zipOptions = function () {
            var _this = this;
            if (typeof this.nzShowUploadList === 'boolean' && this.nzShowUploadList) {
                this.nzShowUploadList = {
                    showPreviewIcon: true,
                    showRemoveIcon: true,
                    showDownloadIcon: true
                };
            }
            // filters
            var filters = this.nzFilter.slice();
            if (this.nzMultiple && this.nzLimit > 0 && filters.findIndex(function (w) { return w.name === 'limit'; }) === -1) {
                filters.push({
                    name: 'limit',
                    fn: function (fileList) { return fileList.slice(-_this.nzLimit); }
                });
            }
            if (this.nzSize > 0 && filters.findIndex(function (w) { return w.name === 'size'; }) === -1) {
                filters.push({
                    name: 'size',
                    fn: function (fileList) { return fileList.filter(function (w) { return w.size / 1024 <= _this.nzSize; }); }
                });
            }
            if (this.nzFileType && this.nzFileType.length > 0 && filters.findIndex(function (w) { return w.name === 'type'; }) === -1) {
                var types_1 = this.nzFileType.split(',');
                filters.push({
                    name: 'type',
                    fn: function (fileList) { return fileList.filter(function (w) { return ~types_1.indexOf(w.type); }); }
                });
            }
            this._btnOptions = {
                disabled: this.nzDisabled,
                accept: this.nzAccept,
                action: this.nzAction,
                directory: this.nzDirectory,
                openFileDialogOnClick: this.nzOpenFileDialogOnClick,
                beforeUpload: this.nzBeforeUpload,
                customRequest: this.nzCustomRequest,
                data: this.nzData,
                headers: this.nzHeaders,
                name: this.nzName,
                multiple: this.nzMultiple,
                withCredentials: this.nzWithCredentials,
                filters: filters,
                transformFile: this.nzTransformFile,
                onStart: this.onStart,
                onProgress: this.onProgress,
                onSuccess: this.onSuccess,
                onError: this.onError
            };
            return this;
        };
        // #region upload
        NzUploadComponent.prototype.fileToObject = function (file) {
            return {
                lastModified: file.lastModified,
                lastModifiedDate: file.lastModifiedDate,
                name: file.filename || file.name,
                size: file.size,
                type: file.type,
                uid: file.uid,
                response: file.response,
                error: file.error,
                percent: 0,
                // tslint:disable-next-line:no-any
                originFileObj: file
            };
        };
        NzUploadComponent.prototype.getFileItem = function (file, fileList) {
            return fileList.filter(function (item) { return item.uid === file.uid; })[0];
        };
        NzUploadComponent.prototype.removeFileItem = function (file, fileList) {
            return fileList.filter(function (item) { return item.uid !== file.uid; });
        };
        // skip safari bug
        NzUploadComponent.prototype.fileDrop = function (e) {
            if (e.type === this.dragState) {
                return;
            }
            this.dragState = e.type;
            this.setClassMap();
        };
        // #endregion
        // #region list
        NzUploadComponent.prototype.detectChangesList = function () {
            this.cdr.detectChanges();
            this.listComp.detectChanges();
        };
        NzUploadComponent.prototype.setClassMap = function () {
            var subCls = [];
            if (this.nzType === 'drag') {
                if (this.nzFileList.some(function (file) { return file.status === 'uploading'; })) {
                    subCls.push(this.prefixCls + "-drag-uploading");
                }
                if (this.dragState === 'dragover') {
                    subCls.push(this.prefixCls + "-drag-hover");
                }
            }
            else {
                subCls = [this.prefixCls + "-select-" + this.nzListType];
            }
            this.classList = __spread([
                this.prefixCls,
                this.prefixCls + "-" + this.nzType
            ], subCls, [
                (this.nzDisabled && this.prefixCls + "-disabled") || ''
            ]).filter(function (item) { return !!item; });
            this.cdr.detectChanges();
        };
        // #endregion
        NzUploadComponent.prototype.ngOnInit = function () {
            var _this = this;
            this.i18n$ = this.i18n.localeChange.subscribe(function () {
                _this.locale = _this.i18n.getLocaleData('Upload');
                _this.detectChangesList();
            });
        };
        NzUploadComponent.prototype.ngOnChanges = function () {
            this.zipOptions().setClassMap();
        };
        NzUploadComponent.prototype.ngOnDestroy = function () {
            this.i18n$.unsubscribe();
        };
        /** @nocollapse */ NzUploadComponent.ɵfac = function NzUploadComponent_Factory(t) { return new (t || NzUploadComponent)(core["ɵɵdirectiveInject"](core.ChangeDetectorRef), core["ɵɵdirectiveInject"](i18n.NzI18nService)); };
        /** @nocollapse */ NzUploadComponent.ɵcmp = core["ɵɵdefineComponent"]({ type: NzUploadComponent, selectors: [["nz-upload"]], viewQuery: function NzUploadComponent_Query(rf, ctx) { if (rf & 1) {
                core["ɵɵviewQuery"](_c0$2, true);
                core["ɵɵviewQuery"](_c1$2, true);
            } if (rf & 2) {
                var _t;
                core["ɵɵqueryRefresh"](_t = core["ɵɵloadQuery"]()) && (ctx.uploadComp = _t.first);
                core["ɵɵqueryRefresh"](_t = core["ɵɵloadQuery"]()) && (ctx.listComp = _t.first);
            } }, hostVars: 2, hostBindings: function NzUploadComponent_HostBindings(rf, ctx) { if (rf & 2) {
                core["ɵɵclassProp"]("ant-upload-picture-card-wrapper", ctx.nzListType === "picture-card");
            } }, inputs: { nzType: "nzType", nzLimit: "nzLimit", nzSize: "nzSize", nzFileType: "nzFileType", nzAccept: "nzAccept", nzAction: "nzAction", nzDirectory: "nzDirectory", nzOpenFileDialogOnClick: "nzOpenFileDialogOnClick", nzBeforeUpload: "nzBeforeUpload", nzCustomRequest: "nzCustomRequest", nzData: "nzData", nzFilter: "nzFilter", nzFileList: "nzFileList", nzDisabled: "nzDisabled", nzHeaders: "nzHeaders", nzListType: "nzListType", nzMultiple: "nzMultiple", nzName: "nzName", nzShowUploadList: "nzShowUploadList", nzShowButton: "nzShowButton", nzWithCredentials: "nzWithCredentials", nzRemove: "nzRemove", nzPreview: "nzPreview", nzPreviewFile: "nzPreviewFile", nzTransformFile: "nzTransformFile", nzDownload: "nzDownload", nzIconRender: "nzIconRender" }, outputs: { nzChange: "nzChange", nzFileListChange: "nzFileListChange" }, exportAs: ["nzUpload"], features: [core["ɵɵNgOnChangesFeature"]], ngContentSelectors: _c4, decls: 11, vars: 2, consts: [["list", ""], ["con", ""], ["btn", ""], [4, "ngIf", "ngIfElse"], ["select", ""], ["pic", ""], [3, "locale", "listType", "items", "icons", "iconRender", "previewFile", "onPreview", "onRemove", "onDownload"], ["listComp", ""], [3, "ngClass"], ["nz-upload-btn", "", 3, "options"], ["uploadComp", ""], [3, "ngTemplateOutlet"], [3, "ngClass", "drop", "dragover", "dragleave"], ["nz-upload-btn", "", 3, "options", "classes"], [1, "ant-upload-drag-container"]], template: function NzUploadComponent_Template(rf, ctx) { if (rf & 1) {
                core["ɵɵprojectionDef"]();
                core["ɵɵtemplate"](0, NzUploadComponent_ng_template_0_Template, 2, 12, "ng-template", null, 0, core["ɵɵtemplateRefExtractor"]);
                core["ɵɵtemplate"](2, NzUploadComponent_ng_template_2_Template, 1, 0, "ng-template", null, 1, core["ɵɵtemplateRefExtractor"]);
                core["ɵɵtemplate"](4, NzUploadComponent_ng_template_4_Template, 4, 5, "ng-template", null, 2, core["ɵɵtemplateRefExtractor"]);
                core["ɵɵtemplate"](6, NzUploadComponent_ng_container_6_Template, 7, 6, "ng-container", 3);
                core["ɵɵtemplate"](7, NzUploadComponent_ng_template_7_Template, 1, 2, "ng-template", null, 4, core["ɵɵtemplateRefExtractor"]);
                core["ɵɵtemplate"](9, NzUploadComponent_ng_template_9_Template, 2, 2, "ng-template", null, 5, core["ɵɵtemplateRefExtractor"]);
            } if (rf & 2) {
                var _r2587 = core["ɵɵreference"](8);
                core["ɵɵadvance"](6);
                core["ɵɵproperty"]("ngIf", ctx.nzType === "drag")("ngIfElse", _r2587);
            } }, directives: [common.NgIf, NzUploadListComponent, common.NgClass, NzUploadBtnComponent, common.NgTemplateOutlet], encapsulation: 2, changeDetection: 0 });
        __decorate([
            core$1.InputNumber(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzLimit", void 0);
        __decorate([
            core$1.InputNumber(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzSize", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzDirectory", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzOpenFileDialogOnClick", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzDisabled", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzMultiple", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzShowButton", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzUploadComponent.prototype, "nzWithCredentials", void 0);
        return NzUploadComponent;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzUploadComponent, [{
            type: core.Component,
            args: [{
                    selector: 'nz-upload',
                    exportAs: 'nzUpload',
                    templateUrl: './upload.component.html',
                    preserveWhitespaces: false,
                    encapsulation: core.ViewEncapsulation.None,
                    changeDetection: core.ChangeDetectionStrategy.OnPush,
                    host: {
                        '[class.ant-upload-picture-card-wrapper]': 'nzListType === "picture-card"'
                    }
                }]
        }], function () { return [{ type: core.ChangeDetectorRef }, { type: i18n.NzI18nService }]; }, { uploadComp: [{
                type: core.ViewChild,
                args: ['uploadComp', { static: false }]
            }], listComp: [{
                type: core.ViewChild,
                args: ['listComp', { static: false }]
            }], nzType: [{
                type: core.Input
            }], nzLimit: [{
                type: core.Input
            }], nzSize: [{
                type: core.Input
            }], nzFileType: [{
                type: core.Input
            }], nzAccept: [{
                type: core.Input
            }], nzAction: [{
                type: core.Input
            }], nzDirectory: [{
                type: core.Input
            }], nzOpenFileDialogOnClick: [{
                type: core.Input
            }], nzBeforeUpload: [{
                type: core.Input
            }], nzCustomRequest: [{
                type: core.Input
            }], nzData: [{
                type: core.Input
            }], nzFilter: [{
                type: core.Input
            }], nzFileList: [{
                type: core.Input
            }], nzDisabled: [{
                type: core.Input
            }], nzHeaders: [{
                type: core.Input
            }], nzListType: [{
                type: core.Input
            }], nzMultiple: [{
                type: core.Input
            }], nzName: [{
                type: core.Input
            }], nzShowUploadList: [{
                type: core.Input
            }], nzShowButton: [{
                type: core.Input
            }], nzWithCredentials: [{
                type: core.Input
            }], nzRemove: [{
                type: core.Input
            }], nzPreview: [{
                type: core.Input
            }], nzPreviewFile: [{
                type: core.Input
            }], nzTransformFile: [{
                type: core.Input
            }], nzDownload: [{
                type: core.Input
            }], nzIconRender: [{
                type: core.Input
            }], nzChange: [{
                type: core.Output
            }], nzFileListChange: [{
                type: core.Output
            }] }); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    var NzUploadModule = /** @class */ (function () {
        function NzUploadModule() {
        }
        /** @nocollapse */ NzUploadModule.ɵmod = core["ɵɵdefineNgModule"]({ type: NzUploadModule });
        /** @nocollapse */ NzUploadModule.ɵinj = core["ɵɵdefineInjector"]({ factory: function NzUploadModule_Factory(t) { return new (t || NzUploadModule)(); }, imports: [[common.CommonModule, forms.FormsModule, platform.PlatformModule, tooltip.NzToolTipModule, progress.NzProgressModule, i18n.NzI18nModule, icon.NzIconModule]] });
        return NzUploadModule;
    }());
    (function () { (typeof ngJitMode === "undefined" || ngJitMode) && core["ɵɵsetNgModuleScope"](NzUploadModule, { declarations: [NzUploadComponent, NzUploadBtnComponent, NzUploadListComponent], imports: [common.CommonModule, forms.FormsModule, platform.PlatformModule, tooltip.NzToolTipModule, progress.NzProgressModule, i18n.NzI18nModule, icon.NzIconModule], exports: [NzUploadComponent] }); })();
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzUploadModule, [{
            type: core.NgModule,
            args: [{
                    imports: [common.CommonModule, forms.FormsModule, platform.PlatformModule, tooltip.NzToolTipModule, progress.NzProgressModule, i18n.NzI18nModule, icon.NzIconModule],
                    declarations: [NzUploadComponent, NzUploadBtnComponent, NzUploadListComponent],
                    exports: [NzUploadComponent]
                }]
        }], null, null); })();

    exports.NzUploadBtnComponent = NzUploadBtnComponent;
    exports.NzUploadComponent = NzUploadComponent;
    exports.NzUploadListComponent = NzUploadListComponent;
    exports.NzUploadModule = NzUploadModule;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=ng-zorro-antd-upload.umd.js.map
