{"ast":null,"code":"import * as i0 from '@angular/core';\nimport { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChildren, ViewChild, NgModule } from '@angular/core';\nimport * as i7 from '@angular/common';\nimport { CommonModule } from '@angular/common';\nimport * as i4 from 'primeng/button';\nimport { ButtonModule } from 'primeng/button';\nimport * as i6 from 'primeng/messages';\nimport { MessagesModule } from 'primeng/messages';\nimport * as i5 from 'primeng/progressbar';\nimport { ProgressBarModule } from 'primeng/progressbar';\nimport { DomHandler } from 'primeng/dom';\nimport * as i3 from 'primeng/api';\nimport { TranslationKeys, PrimeTemplate, SharedModule } from 'primeng/api';\nimport * as i8 from 'primeng/ripple';\nimport { RippleModule } from 'primeng/ripple';\nimport * as i2 from '@angular/common/http';\nimport { HttpEventType } from '@angular/common/http';\nimport * as i1 from '@angular/platform-browser';\nconst _c0 = [\"advancedfileinput\"];\nconst _c1 = [\"basicfileinput\"];\nconst _c2 = [\"content\"];\n\nfunction FileUpload_div_0_p_button_8_Template(rf, ctx) {\n if (rf & 1) {\n const _r11 = i0.ɵɵgetCurrentView();\n\n i0.ɵɵelementStart(0, \"p-button\", 17);\n i0.ɵɵlistener(\"onClick\", function FileUpload_div_0_p_button_8_Template_p_button_onClick_0_listener() {\n i0.ɵɵrestoreView(_r11);\n const ctx_r10 = i0.ɵɵnextContext(2);\n return ctx_r10.upload();\n });\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r3 = i0.ɵɵnextContext(2);\n i0.ɵɵproperty(\"label\", ctx_r3.uploadButtonLabel)(\"icon\", ctx_r3.uploadIcon)(\"disabled\", !ctx_r3.hasFiles() || ctx_r3.isFileLimitExceeded());\n }\n}\n\nfunction FileUpload_div_0_p_button_9_Template(rf, ctx) {\n if (rf & 1) {\n const _r13 = i0.ɵɵgetCurrentView();\n\n i0.ɵɵelementStart(0, \"p-button\", 17);\n i0.ɵɵlistener(\"onClick\", function FileUpload_div_0_p_button_9_Template_p_button_onClick_0_listener() {\n i0.ɵɵrestoreView(_r13);\n const ctx_r12 = i0.ɵɵnextContext(2);\n return ctx_r12.clear();\n });\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r4 = i0.ɵɵnextContext(2);\n i0.ɵɵproperty(\"label\", ctx_r4.cancelButtonLabel)(\"icon\", ctx_r4.cancelIcon)(\"disabled\", !ctx_r4.hasFiles() || ctx_r4.uploading);\n }\n}\n\nfunction FileUpload_div_0_ng_container_10_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementContainer(0);\n }\n}\n\nfunction FileUpload_div_0_p_progressBar_13_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelement(0, \"p-progressBar\", 18);\n }\n\n if (rf & 2) {\n const ctx_r7 = i0.ɵɵnextContext(2);\n i0.ɵɵproperty(\"value\", ctx_r7.progress)(\"showValue\", false);\n }\n}\n\nfunction FileUpload_div_0_div_15_div_1_div_1_img_2_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelement(0, \"img\", 26);\n }\n\n if (rf & 2) {\n const file_r17 = i0.ɵɵnextContext().$implicit;\n const ctx_r19 = i0.ɵɵnextContext(4);\n i0.ɵɵproperty(\"src\", file_r17.objectURL, i0.ɵɵsanitizeUrl)(\"width\", ctx_r19.previewWidth);\n }\n}\n\nfunction FileUpload_div_0_div_15_div_1_div_1_Template(rf, ctx) {\n if (rf & 1) {\n const _r22 = i0.ɵɵgetCurrentView();\n\n i0.ɵɵelementStart(0, \"div\", 22);\n i0.ɵɵelementStart(1, \"div\");\n i0.ɵɵtemplate(2, FileUpload_div_0_div_15_div_1_div_1_img_2_Template, 1, 2, \"img\", 23);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(3, \"div\", 24);\n i0.ɵɵtext(4);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(5, \"div\");\n i0.ɵɵtext(6);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(7, \"div\");\n i0.ɵɵelementStart(8, \"button\", 25);\n i0.ɵɵlistener(\"click\", function FileUpload_div_0_div_15_div_1_div_1_Template_button_click_8_listener($event) {\n const restoredCtx = i0.ɵɵrestoreView(_r22);\n const i_r18 = restoredCtx.index;\n const ctx_r21 = i0.ɵɵnextContext(4);\n return ctx_r21.remove($event, i_r18);\n });\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const file_r17 = ctx.$implicit;\n const ctx_r16 = i0.ɵɵnextContext(4);\n i0.ɵɵadvance(2);\n i0.ɵɵproperty(\"ngIf\", ctx_r16.isImage(file_r17));\n i0.ɵɵadvance(2);\n i0.ɵɵtextInterpolate(file_r17.name);\n i0.ɵɵadvance(2);\n i0.ɵɵtextInterpolate(ctx_r16.formatSize(file_r17.size));\n i0.ɵɵadvance(2);\n i0.ɵɵproperty(\"disabled\", ctx_r16.uploading);\n }\n}\n\nfunction FileUpload_div_0_div_15_div_1_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"div\");\n i0.ɵɵtemplate(1, FileUpload_div_0_div_15_div_1_div_1_Template, 9, 4, \"div\", 21);\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r14 = i0.ɵɵnextContext(3);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngForOf\", ctx_r14.files);\n }\n}\n\nfunction FileUpload_div_0_div_15_div_2_ng_template_1_Template(rf, ctx) {}\n\nfunction FileUpload_div_0_div_15_div_2_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"div\");\n i0.ɵɵtemplate(1, FileUpload_div_0_div_15_div_2_ng_template_1_Template, 0, 0, \"ng-template\", 27);\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r15 = i0.ɵɵnextContext(3);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngForOf\", ctx_r15.files)(\"ngForTemplate\", ctx_r15.fileTemplate);\n }\n}\n\nfunction FileUpload_div_0_div_15_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"div\", 19);\n i0.ɵɵtemplate(1, FileUpload_div_0_div_15_div_1_Template, 2, 1, \"div\", 20);\n i0.ɵɵtemplate(2, FileUpload_div_0_div_15_div_2_Template, 2, 2, \"div\", 20);\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r8 = i0.ɵɵnextContext(2);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", !ctx_r8.fileTemplate);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", ctx_r8.fileTemplate);\n }\n}\n\nfunction FileUpload_div_0_ng_container_16_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementContainer(0);\n }\n}\n\nconst _c3 = function (a0, a1) {\n return {\n \"p-focus\": a0,\n \"p-disabled\": a1\n };\n};\n\nconst _c4 = function (a0) {\n return {\n $implicit: a0\n };\n};\n\nfunction FileUpload_div_0_Template(rf, ctx) {\n if (rf & 1) {\n const _r25 = i0.ɵɵgetCurrentView();\n\n i0.ɵɵelementStart(0, \"div\", 2);\n i0.ɵɵelementStart(1, \"div\", 3);\n i0.ɵɵelementStart(2, \"span\", 4);\n i0.ɵɵlistener(\"focus\", function FileUpload_div_0_Template_span_focus_2_listener() {\n i0.ɵɵrestoreView(_r25);\n const ctx_r24 = i0.ɵɵnextContext();\n return ctx_r24.onFocus();\n })(\"blur\", function FileUpload_div_0_Template_span_blur_2_listener() {\n i0.ɵɵrestoreView(_r25);\n const ctx_r26 = i0.ɵɵnextContext();\n return ctx_r26.onBlur();\n })(\"click\", function FileUpload_div_0_Template_span_click_2_listener() {\n i0.ɵɵrestoreView(_r25);\n const ctx_r27 = i0.ɵɵnextContext();\n return ctx_r27.choose();\n })(\"keydown.enter\", function FileUpload_div_0_Template_span_keydown_enter_2_listener() {\n i0.ɵɵrestoreView(_r25);\n const ctx_r28 = i0.ɵɵnextContext();\n return ctx_r28.choose();\n });\n i0.ɵɵelementStart(3, \"input\", 5, 6);\n i0.ɵɵlistener(\"change\", function FileUpload_div_0_Template_input_change_3_listener($event) {\n i0.ɵɵrestoreView(_r25);\n const ctx_r29 = i0.ɵɵnextContext();\n return ctx_r29.onFileSelect($event);\n });\n i0.ɵɵelementEnd();\n i0.ɵɵelement(5, \"span\", 7);\n i0.ɵɵelementStart(6, \"span\", 8);\n i0.ɵɵtext(7);\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n i0.ɵɵtemplate(8, FileUpload_div_0_p_button_8_Template, 1, 3, \"p-button\", 9);\n i0.ɵɵtemplate(9, FileUpload_div_0_p_button_9_Template, 1, 3, \"p-button\", 9);\n i0.ɵɵtemplate(10, FileUpload_div_0_ng_container_10_Template, 1, 0, \"ng-container\", 10);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(11, \"div\", 11, 12);\n i0.ɵɵlistener(\"dragenter\", function FileUpload_div_0_Template_div_dragenter_11_listener($event) {\n i0.ɵɵrestoreView(_r25);\n const ctx_r30 = i0.ɵɵnextContext();\n return ctx_r30.onDragEnter($event);\n })(\"dragleave\", function FileUpload_div_0_Template_div_dragleave_11_listener($event) {\n i0.ɵɵrestoreView(_r25);\n const ctx_r31 = i0.ɵɵnextContext();\n return ctx_r31.onDragLeave($event);\n })(\"drop\", function FileUpload_div_0_Template_div_drop_11_listener($event) {\n i0.ɵɵrestoreView(_r25);\n const ctx_r32 = i0.ɵɵnextContext();\n return ctx_r32.onDrop($event);\n });\n i0.ɵɵtemplate(13, FileUpload_div_0_p_progressBar_13_Template, 1, 2, \"p-progressBar\", 13);\n i0.ɵɵelement(14, \"p-messages\", 14);\n i0.ɵɵtemplate(15, FileUpload_div_0_div_15_Template, 3, 2, \"div\", 15);\n i0.ɵɵtemplate(16, FileUpload_div_0_ng_container_16_Template, 1, 0, \"ng-container\", 16);\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r0 = i0.ɵɵnextContext();\n i0.ɵɵclassMap(ctx_r0.styleClass);\n i0.ɵɵproperty(\"ngClass\", \"p-fileupload p-fileupload-advanced p-component\")(\"ngStyle\", ctx_r0.style);\n i0.ɵɵadvance(2);\n i0.ɵɵproperty(\"ngClass\", i0.ɵɵpureFunction2(22, _c3, ctx_r0.focus, ctx_r0.disabled || ctx_r0.isChooseDisabled()));\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"multiple\", ctx_r0.multiple)(\"accept\", ctx_r0.accept)(\"disabled\", ctx_r0.disabled || ctx_r0.isChooseDisabled());\n i0.ɵɵattribute(\"title\", \"\");\n i0.ɵɵadvance(2);\n i0.ɵɵclassMap(ctx_r0.chooseIcon);\n i0.ɵɵproperty(\"ngClass\", \"p-button-icon p-button-icon-left\");\n i0.ɵɵadvance(2);\n i0.ɵɵtextInterpolate(ctx_r0.chooseButtonLabel);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", !ctx_r0.auto && ctx_r0.showUploadButton);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", !ctx_r0.auto && ctx_r0.showCancelButton);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngTemplateOutlet\", ctx_r0.toolbarTemplate);\n i0.ɵɵadvance(3);\n i0.ɵɵproperty(\"ngIf\", ctx_r0.hasFiles());\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"value\", ctx_r0.msgs)(\"enableService\", false);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", ctx_r0.hasFiles());\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngTemplateOutlet\", ctx_r0.contentTemplate)(\"ngTemplateOutletContext\", i0.ɵɵpureFunction1(25, _c4, ctx_r0.files));\n }\n}\n\nfunction FileUpload_div_1_input_6_Template(rf, ctx) {\n if (rf & 1) {\n const _r36 = i0.ɵɵgetCurrentView();\n\n i0.ɵɵelementStart(0, \"input\", 32, 33);\n i0.ɵɵlistener(\"change\", function FileUpload_div_1_input_6_Template_input_change_0_listener($event) {\n i0.ɵɵrestoreView(_r36);\n const ctx_r35 = i0.ɵɵnextContext(2);\n return ctx_r35.onFileSelect($event);\n })(\"focus\", function FileUpload_div_1_input_6_Template_input_focus_0_listener() {\n i0.ɵɵrestoreView(_r36);\n const ctx_r37 = i0.ɵɵnextContext(2);\n return ctx_r37.onFocus();\n })(\"blur\", function FileUpload_div_1_input_6_Template_input_blur_0_listener() {\n i0.ɵɵrestoreView(_r36);\n const ctx_r38 = i0.ɵɵnextContext(2);\n return ctx_r38.onBlur();\n });\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r33 = i0.ɵɵnextContext(2);\n i0.ɵɵproperty(\"accept\", ctx_r33.accept)(\"multiple\", ctx_r33.multiple)(\"disabled\", ctx_r33.disabled);\n }\n}\n\nconst _c5 = function (a1, a2, a3, a4) {\n return {\n \"p-button p-component p-fileupload-choose\": true,\n \"p-button-icon-only\": a1,\n \"p-fileupload-choose-selected\": a2,\n \"p-focus\": a3,\n \"p-disabled\": a4\n };\n};\n\nfunction FileUpload_div_1_Template(rf, ctx) {\n if (rf & 1) {\n const _r40 = i0.ɵɵgetCurrentView();\n\n i0.ɵɵelementStart(0, \"div\", 28);\n i0.ɵɵelement(1, \"p-messages\", 14);\n i0.ɵɵelementStart(2, \"span\", 29);\n i0.ɵɵlistener(\"mouseup\", function FileUpload_div_1_Template_span_mouseup_2_listener() {\n i0.ɵɵrestoreView(_r40);\n const ctx_r39 = i0.ɵɵnextContext();\n return ctx_r39.onBasicUploaderClick();\n })(\"keydown\", function FileUpload_div_1_Template_span_keydown_2_listener() {\n i0.ɵɵrestoreView(_r40);\n const ctx_r41 = i0.ɵɵnextContext();\n return ctx_r41.onBasicUploaderClick();\n });\n i0.ɵɵelement(3, \"span\", 30);\n i0.ɵɵelementStart(4, \"span\", 8);\n i0.ɵɵtext(5);\n i0.ɵɵelementEnd();\n i0.ɵɵtemplate(6, FileUpload_div_1_input_6_Template, 2, 3, \"input\", 31);\n i0.ɵɵelementEnd();\n i0.ɵɵelementEnd();\n }\n\n if (rf & 2) {\n const ctx_r1 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"value\", ctx_r1.msgs)(\"enableService\", false);\n i0.ɵɵadvance(1);\n i0.ɵɵclassMap(ctx_r1.styleClass);\n i0.ɵɵproperty(\"ngClass\", i0.ɵɵpureFunction4(9, _c5, !ctx_r1.chooseLabel, ctx_r1.hasFiles(), ctx_r1.focus, ctx_r1.disabled))(\"ngStyle\", ctx_r1.style);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngClass\", ctx_r1.hasFiles() && !ctx_r1.auto ? ctx_r1.uploadIcon : ctx_r1.chooseIcon);\n i0.ɵɵadvance(2);\n i0.ɵɵtextInterpolate(ctx_r1.auto ? ctx_r1.chooseLabel : ctx_r1.hasFiles() ? ctx_r1.files[0].name : ctx_r1.chooseLabel);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", !ctx_r1.hasFiles());\n }\n}\n\nclass FileUpload {\n constructor(el, sanitizer, zone, http, cd, config) {\n this.el = el;\n this.sanitizer = sanitizer;\n this.zone = zone;\n this.http = http;\n this.cd = cd;\n this.config = config;\n this.method = 'post';\n this.invalidFileSizeMessageSummary = '{0}: Invalid file size, ';\n this.invalidFileSizeMessageDetail = 'maximum upload size is {0}.';\n this.invalidFileTypeMessageSummary = '{0}: Invalid file type, ';\n this.invalidFileTypeMessageDetail = 'allowed file types: {0}.';\n this.invalidFileLimitMessageDetail = 'limit is {0} at most.';\n this.invalidFileLimitMessageSummary = 'Maximum number of files exceeded, ';\n this.previewWidth = 50;\n this.chooseIcon = 'pi pi-plus';\n this.uploadIcon = 'pi pi-upload';\n this.cancelIcon = 'pi pi-times';\n this.showUploadButton = true;\n this.showCancelButton = true;\n this.mode = 'advanced';\n this.onBeforeUpload = new EventEmitter();\n this.onSend = new EventEmitter();\n this.onUpload = new EventEmitter();\n this.onError = new EventEmitter();\n this.onClear = new EventEmitter();\n this.onRemove = new EventEmitter();\n this.onSelect = new EventEmitter();\n this.onProgress = new EventEmitter();\n this.uploadHandler = new EventEmitter();\n this._files = [];\n this.progress = 0;\n this.uploadedFileCount = 0;\n }\n\n set files(files) {\n this._files = [];\n\n for (let i = 0; i < files.length; i++) {\n let file = files[i];\n\n if (this.validate(file)) {\n if (this.isImage(file)) {\n file.objectURL = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(files[i]));\n }\n\n this._files.push(files[i]);\n }\n }\n }\n\n get files() {\n return this._files;\n }\n\n ngAfterContentInit() {\n this.templates.forEach(item => {\n switch (item.getType()) {\n case 'file':\n this.fileTemplate = item.template;\n break;\n\n case 'content':\n this.contentTemplate = item.template;\n break;\n\n case 'toolbar':\n this.toolbarTemplate = item.template;\n break;\n\n default:\n this.fileTemplate = item.template;\n break;\n }\n });\n }\n\n ngOnInit() {\n this.translationSubscription = this.config.translationObserver.subscribe(() => {\n this.cd.markForCheck();\n });\n }\n\n ngAfterViewInit() {\n if (this.mode === 'advanced') {\n this.zone.runOutsideAngular(() => {\n if (this.content) this.content.nativeElement.addEventListener('dragover', this.onDragOver.bind(this));\n });\n }\n }\n\n choose() {\n this.advancedFileInput.nativeElement.click();\n }\n\n onFileSelect(event) {\n if (event.type !== 'drop' && this.isIE11() && this.duplicateIEEvent) {\n this.duplicateIEEvent = false;\n return;\n }\n\n this.msgs = [];\n\n if (!this.multiple) {\n this.files = [];\n }\n\n let files = event.dataTransfer ? event.dataTransfer.files : event.target.files;\n\n for (let i = 0; i < files.length; i++) {\n let file = files[i];\n\n if (!this.isFileSelected(file)) {\n if (this.validate(file)) {\n if (this.isImage(file)) {\n file.objectURL = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(files[i]));\n }\n\n this.files.push(files[i]);\n }\n }\n }\n\n this.onSelect.emit({\n originalEvent: event,\n files: files,\n currentFiles: this.files\n });\n\n if (this.fileLimit && this.mode == \"advanced\") {\n this.checkFileLimit();\n }\n\n if (this.hasFiles() && this.auto && (!(this.mode === \"advanced\") || !this.isFileLimitExceeded())) {\n this.upload();\n }\n\n if (event.type !== 'drop' && this.isIE11()) {\n this.clearIEInput();\n } else {\n this.clearInputElement();\n }\n }\n\n isFileSelected(file) {\n for (let sFile of this.files) {\n if (sFile.name + sFile.type + sFile.size === file.name + file.type + file.size) {\n return true;\n }\n }\n\n return false;\n }\n\n isIE11() {\n return !!window['MSInputMethodContext'] && !!document['documentMode'];\n }\n\n validate(file) {\n if (this.accept && !this.isFileTypeValid(file)) {\n this.msgs.push({\n severity: 'error',\n summary: this.invalidFileTypeMessageSummary.replace('{0}', file.name),\n detail: this.invalidFileTypeMessageDetail.replace('{0}', this.accept)\n });\n return false;\n }\n\n if (this.maxFileSize && file.size > this.maxFileSize) {\n this.msgs.push({\n severity: 'error',\n summary: this.invalidFileSizeMessageSummary.replace('{0}', file.name),\n detail: this.invalidFileSizeMessageDetail.replace('{0}', this.formatSize(this.maxFileSize))\n });\n return false;\n }\n\n return true;\n }\n\n isFileTypeValid(file) {\n let acceptableTypes = this.accept.split(',').map(type => type.trim());\n\n for (let type of acceptableTypes) {\n let acceptable = this.isWildcard(type) ? this.getTypeClass(file.type) === this.getTypeClass(type) : file.type == type || this.getFileExtension(file).toLowerCase() === type.toLowerCase();\n\n if (acceptable) {\n return true;\n }\n }\n\n return false;\n }\n\n getTypeClass(fileType) {\n return fileType.substring(0, fileType.indexOf('/'));\n }\n\n isWildcard(fileType) {\n return fileType.indexOf('*') !== -1;\n }\n\n getFileExtension(file) {\n return '.' + file.name.split('.').pop();\n }\n\n isImage(file) {\n return /^image\\//.test(file.type);\n }\n\n onImageLoad(img) {\n window.URL.revokeObjectURL(img.src);\n }\n\n upload() {\n if (this.customUpload) {\n if (this.fileLimit) {\n this.uploadedFileCount += this.files.length;\n }\n\n this.uploadHandler.emit({\n files: this.files\n });\n this.cd.markForCheck();\n } else {\n this.uploading = true;\n this.msgs = [];\n let formData = new FormData();\n this.onBeforeUpload.emit({\n 'formData': formData\n });\n\n for (let i = 0; i < this.files.length; i++) {\n formData.append(this.name, this.files[i], this.files[i].name);\n }\n\n this.http[this.method](this.url, formData, {\n headers: this.headers,\n reportProgress: true,\n observe: 'events',\n withCredentials: this.withCredentials\n }).subscribe(event => {\n switch (event.type) {\n case HttpEventType.Sent:\n this.onSend.emit({\n originalEvent: event,\n 'formData': formData\n });\n break;\n\n case HttpEventType.Response:\n this.uploading = false;\n this.progress = 0;\n\n if (event['status'] >= 200 && event['status'] < 300) {\n if (this.fileLimit) {\n this.uploadedFileCount += this.files.length;\n }\n\n this.onUpload.emit({\n originalEvent: event,\n files: this.files\n });\n } else {\n this.onError.emit({\n files: this.files\n });\n }\n\n this.clear();\n break;\n\n case HttpEventType.UploadProgress:\n {\n if (event['loaded']) {\n this.progress = Math.round(event['loaded'] * 100 / event['total']);\n }\n\n this.onProgress.emit({\n originalEvent: event,\n progress: this.progress\n });\n break;\n }\n }\n\n this.cd.markForCheck();\n }, error => {\n this.uploading = false;\n this.onError.emit({\n files: this.files,\n error: error\n });\n });\n }\n }\n\n clear() {\n this.files = [];\n this.onClear.emit();\n this.clearInputElement();\n this.cd.markForCheck();\n }\n\n remove(event, index) {\n this.clearInputElement();\n this.onRemove.emit({\n originalEvent: event,\n file: this.files[index]\n });\n this.files.splice(index, 1);\n }\n\n isFileLimitExceeded() {\n if (this.fileLimit && this.fileLimit <= this.files.length + this.uploadedFileCount && this.focus) {\n this.focus = false;\n }\n\n return this.fileLimit && this.fileLimit < this.files.length + this.uploadedFileCount;\n }\n\n isChooseDisabled() {\n return this.fileLimit && this.fileLimit <= this.files.length + this.uploadedFileCount;\n }\n\n checkFileLimit() {\n if (this.isFileLimitExceeded()) {\n this.msgs.push({\n severity: 'error',\n summary: this.invalidFileLimitMessageSummary.replace('{0}', this.fileLimit.toString()),\n detail: this.invalidFileLimitMessageDetail.replace('{0}', this.fileLimit.toString())\n });\n }\n }\n\n clearInputElement() {\n if (this.advancedFileInput && this.advancedFileInput.nativeElement) {\n this.advancedFileInput.nativeElement.value = '';\n }\n\n if (this.basicFileInput && this.basicFileInput.nativeElement) {\n this.basicFileInput.nativeElement.value = '';\n }\n }\n\n clearIEInput() {\n if (this.advancedFileInput && this.advancedFileInput.nativeElement) {\n this.duplicateIEEvent = true; //IE11 fix to prevent onFileChange trigger again\n\n this.advancedFileInput.nativeElement.value = '';\n }\n }\n\n hasFiles() {\n return this.files && this.files.length > 0;\n }\n\n onDragEnter(e) {\n if (!this.disabled) {\n e.stopPropagation();\n e.preventDefault();\n }\n }\n\n onDragOver(e) {\n if (!this.disabled) {\n DomHandler.addClass(this.content.nativeElement, 'p-fileupload-highlight');\n this.dragHighlight = true;\n e.stopPropagation();\n e.preventDefault();\n }\n }\n\n onDragLeave(event) {\n if (!this.disabled) {\n DomHandler.removeClass(this.content.nativeElement, 'p-fileupload-highlight');\n }\n }\n\n onDrop(event) {\n if (!this.disabled) {\n DomHandler.removeClass(this.content.nativeElement, 'p-fileupload-highlight');\n event.stopPropagation();\n event.preventDefault();\n let files = event.dataTransfer ? event.dataTransfer.files : event.target.files;\n let allowDrop = this.multiple || files && files.length === 1;\n\n if (allowDrop) {\n this.onFileSelect(event);\n }\n }\n }\n\n onFocus() {\n this.focus = true;\n }\n\n onBlur() {\n this.focus = false;\n }\n\n formatSize(bytes) {\n if (bytes == 0) {\n return '0 B';\n }\n\n let k = 1000,\n dm = 3,\n sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],\n i = Math.floor(Math.log(bytes) / Math.log(k));\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n }\n\n onBasicUploaderClick() {\n if (this.hasFiles()) this.upload();else this.basicFileInput.nativeElement.click();\n }\n\n getBlockableElement() {\n return this.el.nativeElement.children[0];\n }\n\n get chooseButtonLabel() {\n return this.chooseLabel || this.config.getTranslation(TranslationKeys.CHOOSE);\n }\n\n get uploadButtonLabel() {\n return this.uploadLabel || this.config.getTranslation(TranslationKeys.UPLOAD);\n }\n\n get cancelButtonLabel() {\n return this.cancelLabel || this.config.getTranslation(TranslationKeys.CANCEL);\n }\n\n ngOnDestroy() {\n if (this.content && this.content.nativeElement) {\n this.content.nativeElement.removeEventListener('dragover', this.onDragOver);\n }\n\n if (this.translationSubscription) {\n this.translationSubscription.unsubscribe();\n }\n }\n\n}\n\nFileUpload.ɵfac = function FileUpload_Factory(t) {\n return new (t || FileUpload)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i1.DomSanitizer), i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(i2.HttpClient), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i3.PrimeNGConfig));\n};\n\nFileUpload.ɵcmp = /* @__PURE__ */i0.ɵɵdefineComponent({\n type: FileUpload,\n selectors: [[\"p-fileUpload\"]],\n contentQueries: function FileUpload_ContentQueries(rf, ctx, dirIndex) {\n if (rf & 1) {\n i0.ɵɵcontentQuery(dirIndex, PrimeTemplate, 4);\n }\n\n if (rf & 2) {\n let _t;\n\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.templates = _t);\n }\n },\n viewQuery: function FileUpload_Query(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵviewQuery(_c0, 5);\n i0.ɵɵviewQuery(_c1, 5);\n i0.ɵɵviewQuery(_c2, 5);\n }\n\n if (rf & 2) {\n let _t;\n\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.advancedFileInput = _t.first);\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.basicFileInput = _t.first);\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.content = _t.first);\n }\n },\n hostAttrs: [1, \"p-element\"],\n inputs: {\n name: \"name\",\n url: \"url\",\n method: \"method\",\n multiple: \"multiple\",\n accept: \"accept\",\n disabled: \"disabled\",\n auto: \"auto\",\n withCredentials: \"withCredentials\",\n maxFileSize: \"maxFileSize\",\n invalidFileSizeMessageSummary: \"invalidFileSizeMessageSummary\",\n invalidFileSizeMessageDetail: \"invalidFileSizeMessageDetail\",\n invalidFileTypeMessageSummary: \"invalidFileTypeMessageSummary\",\n invalidFileTypeMessageDetail: \"invalidFileTypeMessageDetail\",\n invalidFileLimitMessageDetail: \"invalidFileLimitMessageDetail\",\n invalidFileLimitMessageSummary: \"invalidFileLimitMessageSummary\",\n style: \"style\",\n styleClass: \"styleClass\",\n previewWidth: \"previewWidth\",\n chooseLabel: \"chooseLabel\",\n uploadLabel: \"uploadLabel\",\n cancelLabel: \"cancelLabel\",\n chooseIcon: \"chooseIcon\",\n uploadIcon: \"uploadIcon\",\n cancelIcon: \"cancelIcon\",\n showUploadButton: \"showUploadButton\",\n showCancelButton: \"showCancelButton\",\n mode: \"mode\",\n headers: \"headers\",\n customUpload: \"customUpload\",\n fileLimit: \"fileLimit\",\n files: \"files\"\n },\n outputs: {\n onBeforeUpload: \"onBeforeUpload\",\n onSend: \"onSend\",\n onUpload: \"onUpload\",\n onError: \"onError\",\n onClear: \"onClear\",\n onRemove: \"onRemove\",\n onSelect: \"onSelect\",\n onProgress: \"onProgress\",\n uploadHandler: \"uploadHandler\"\n },\n decls: 2,\n vars: 2,\n consts: [[3, \"ngClass\", \"ngStyle\", \"class\", 4, \"ngIf\"], [\"class\", \"p-fileupload p-fileupload-basic p-component\", 4, \"ngIf\"], [3, \"ngClass\", \"ngStyle\"], [1, \"p-fileupload-buttonbar\"], [\"pRipple\", \"\", \"tabindex\", \"0\", 1, \"p-button\", \"p-component\", \"p-fileupload-choose\", 3, \"ngClass\", \"focus\", \"blur\", \"click\", \"keydown.enter\"], [\"type\", \"file\", 3, \"multiple\", \"accept\", \"disabled\", \"change\"], [\"advancedfileinput\", \"\"], [3, \"ngClass\"], [1, \"p-button-label\"], [\"type\", \"button\", 3, \"label\", \"icon\", \"disabled\", \"onClick\", 4, \"ngIf\"], [4, \"ngTemplateOutlet\"], [1, \"p-fileupload-content\", 3, \"dragenter\", \"dragleave\", \"drop\"], [\"content\", \"\"], [3, \"value\", \"showValue\", 4, \"ngIf\"], [3, \"value\", \"enableService\"], [\"class\", \"p-fileupload-files\", 4, \"ngIf\"], [4, \"ngTemplateOutlet\", \"ngTemplateOutletContext\"], [\"type\", \"button\", 3, \"label\", \"icon\", \"disabled\", \"onClick\"], [3, \"value\", \"showValue\"], [1, \"p-fileupload-files\"], [4, \"ngIf\"], [\"class\", \"p-fileupload-row\", 4, \"ngFor\", \"ngForOf\"], [1, \"p-fileupload-row\"], [3, \"src\", \"width\", 4, \"ngIf\"], [1, \"p-fileupload-filename\"], [\"type\", \"button\", \"icon\", \"pi pi-times\", \"pButton\", \"\", 3, \"disabled\", \"click\"], [3, \"src\", \"width\"], [\"ngFor\", \"\", 3, \"ngForOf\", \"ngForTemplate\"], [1, \"p-fileupload\", \"p-fileupload-basic\", \"p-component\"], [\"tabindex\", \"0\", \"pRipple\", \"\", 3, \"ngClass\", \"ngStyle\", \"mouseup\", \"keydown\"], [1, \"p-button-icon\", \"p-button-icon-left\", \"pi\", 3, \"ngClass\"], [\"type\", \"file\", 3, \"accept\", \"multiple\", \"disabled\", \"change\", \"focus\", \"blur\", 4, \"ngIf\"], [\"type\", \"file\", 3, \"accept\", \"multiple\", \"disabled\", \"change\", \"focus\", \"blur\"], [\"basicfileinput\", \"\"]],\n template: function FileUpload_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵtemplate(0, FileUpload_div_0_Template, 17, 27, \"div\", 0);\n i0.ɵɵtemplate(1, FileUpload_div_1_Template, 7, 14, \"div\", 1);\n }\n\n if (rf & 2) {\n i0.ɵɵproperty(\"ngIf\", ctx.mode === \"advanced\");\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", ctx.mode === \"basic\");\n }\n },\n directives: [i7.NgIf, i7.NgClass, i7.NgStyle, i8.Ripple, i7.NgTemplateOutlet, i6.Messages, i4.Button, i5.ProgressBar, i7.NgForOf, i4.ButtonDirective],\n styles: [\".p-fileupload-content{position:relative}.p-fileupload-row{display:flex;align-items:center}.p-fileupload-row>div{flex:1 1 auto;width:25%}.p-fileupload-row>div:last-child{text-align:right}.p-fileupload-content .p-progressbar{width:100%;position:absolute;top:0;left:0}.p-button.p-fileupload-choose{position:relative;overflow:hidden}.p-button.p-fileupload-choose input[type=file],.p-fileupload-choose.p-fileupload-choose-selected input[type=file]{display:none}.p-fluid .p-fileupload .p-button{width:auto}.p-fileupload-filename{word-break:break-all}\\n\"],\n encapsulation: 2,\n changeDetection: 0\n});\n\n(function () {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && i0.ɵsetClassMetadata(FileUpload, [{\n type: Component,\n args: [{\n selector: 'p-fileUpload',\n template: `\n