UNPKG

angular-material-datatransfer-lib

Version:

A HTML5 datatransfer UI for handling upload and download of multiple simultaneous files.

15 lines (13 loc) 63.4 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/material"),require("@angular/forms"),require("resumablejs"),require("crypto-browserify"),require("file-saver"),require("@angular/platform-browser"),require("@angular/platform-browser/animations"),require("@angular/flex-layout")):"function"==typeof define&&define.amd?define("angular-material-datatransfer-lib",["exports","@angular/core","@angular/material","@angular/forms","resumablejs","crypto-browserify","file-saver","@angular/platform-browser","@angular/platform-browser/animations","@angular/flex-layout"],e):e((t=t||self)["angular-material-datatransfer-lib"]={},t.ng.core,t.ng.material,t.ng.forms,t.Resumable,t.cryptoBrowserify,t.fileSaver,t.ng.platformBrowser,t.ng.platformBrowser.animations,t.ng["flex-layout"])}(this,(function(t,e,n,r,i,a,o,s,p,c){"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. ***************************************************************************** */var l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function d(t,e){function n(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}var h,m={UNKNOWN:0,CREATE:1,DOWNLOAD_ITEM:2,UPDATE_CONFIG:3,INIT:4,UPLOAD_COMPLETED:5,DOWNLOAD_COMPLETED:6,ITEM_ADDED:7,ITEM_REMOVED:8,ITEM_COMPLETED:9,ITEMS_CLEARED:10};m[m.UNKNOWN]="UNKNOWN",m[m.CREATE]="CREATE",m[m.DOWNLOAD_ITEM]="DOWNLOAD_ITEM",m[m.UPDATE_CONFIG]="UPDATE_CONFIG",m[m.INIT]="INIT",m[m.UPLOAD_COMPLETED]="UPLOAD_COMPLETED",m[m.DOWNLOAD_COMPLETED]="DOWNLOAD_COMPLETED",m[m.ITEM_ADDED]="ITEM_ADDED",m[m.ITEM_REMOVED]="ITEM_REMOVED",m[m.ITEM_COMPLETED]="ITEM_COMPLETED",m[m.ITEMS_CLEARED]="ITEMS_CLEARED",function(t){var e="github:niklr/angular-material-datatransfer.",n=e+"unknown",r=e+"create",i=e+"download-item",a=e+"update-config",o=e+"init",s=e+"upload-completed",p=e+"download-completed",c=e+"item-added",l=e+"item-removed",d=e+"item-completed",u=e+"items-cleared";t.toString=function(t){switch(t){case m.CREATE:return r;case m.DOWNLOAD_ITEM:return i;case m.UPDATE_CONFIG:return a;case m.INIT:return o;case m.UPLOAD_COMPLETED:return s;case m.DOWNLOAD_COMPLETED:return p;case m.ITEM_ADDED:return c;case m.ITEM_REMOVED:return l;case m.ITEM_COMPLETED:return d;case m.ITEMS_CLEARED:return u;default:return n}},t.toEnum=function(t){switch(t){case r:return m.CREATE;case i:return m.DOWNLOAD_ITEM;case a:return m.UPDATE_CONFIG;case o:return m.INIT;case s:return m.UPLOAD_COMPLETED;case p:return m.DOWNLOAD_COMPLETED;case c:return m.ITEM_ADDED;case l:return m.ITEM_REMOVED;case d:return m.ITEM_COMPLETED;case u:return m.ITEMS_CLEARED;default:return m.UNKNOWN}}}(h||(h={}));var f=function(){function t(t){this.viewContainerRef=t}return t.decorators=[{type:e.Directive,args:[{selector:"[amd-host]"}]}],t.ctorParameters=function(){return[{type:e.ViewContainerRef}]},t}();var g=function(){this.showUploadDropzone=!0,this.uploadBrowseElementId=void 0,this.uploadDropElementId=void 0,this.paginationRppOptions=[5,10,25],this.simultaneousDownloads=2,this.downloadMethod="GET",this.downloadHeaders={},this.downloadWithCredentials=!1,this.downloadXhrTimeout=0,this.preprocessHashEnabled=!1,this.preprocessHashChecked=!0,this.preprocessHashTarget="https://httpbin.org",this.preprocessHashMethod="GET",this.preprocessHashParameterName="hash",this.preprocessHashFileNameParameterName="filename",this.preprocessHashFunctionName="sha1",this.preprocessHashEncodingName="hex",this.preprocessHashInputEncodingName="latin1",this.preprocessHashTooltipContent="The preprocess option checks if the file is already on the system before uploading.",this.parseMessageCallback=function(t){return t},this.getTarget=function(t,e){var n;if("preprocessHash"===t&&this.preprocessHashChecked&&(n=this.preprocessHashTarget),"function"==typeof n)return n(e);if(n){var r=n.indexOf("?")<0?"?":"&";return n+r+e.join("&")}}};var y=function(){this.chunkSize=1048576,this.forceChunkSize=!1,this.simultaneousUploads=3,this.fileParameterName="file",this.chunkNumberParameterName="resumableChunkNumber",this.chunkSizeParameterName="resumableChunkSize",this.currentChunkSizeParameterName="resumableCurrentChunkSize",this.totalSizeParameterName="resumableTotalSize",this.typeParameterName="resumableType",this.identifierParameterName="resumableIdentifier",this.fileNameParameterName="resumableFilename",this.relativePathParameterName="resumableRelativePath",this.totalChunksParameterName="resumableTotalChunks",this.throttleProgressCallbacks=.5,this.query={},this.headers={},this.preprocess=null,this.preprocessFile=null,this.method="multipart",this.uploadMethod="POST",this.testMethod="GET",this.target="https://httpbin.org",this.testTarget=null,this.parameterNamespace="",this.testChunks=!0,this.generateUniqueIdentifier=null,this.getTarget=null,this.maxChunkRetries=100,this.chunkRetryInterval=void 0,this.permanentErrors=[400,404,405,415,501],this.maxFiles=void 0,this.withCredentials=!1,this.xhrTimeout=0,this.clearInput=!0,this.chunkFormat="blob",this.minFileSize=1,this.maxFileSize=void 0,this.fileType=[],this.maxFilesErrorCallback=function(t,e){alert("Please upload no more than "+this.maxFiles+" file"+(1===this.maxFiles?"":"s")+" at a time.")},this.minFileSizeErrorCallback=function(t,e){alert(t.fileName||t.name+" is too small; please upload files larger than "+this.minFileSize+".")},this.maxFileSizeErrorCallback=function(t,e){alert(t.fileName||t.name+" is too large; please upload files less than "+this.maxFileSize+".")},this.fileTypeErrorCallback=function(t,e){alert(t.fileName||t.name+" has type not allowed; please upload files of type "+this.fileType+".")}};var v=function(){this.production=!0,this.core=new g,this.resumablejs=new y};var b=function(){function t(){}return t.prototype.load=function(e){e&&(t.settings.production=e.production,e.core&&Object.keys(e.core).forEach((function(n){void 0!==e.core[n]&&(t.settings.core[n]=e.core[n])})),e.resumablejs&&Object.keys(e.resumablejs).forEach((function(n){void 0!==e.resumablejs[n]&&(t.settings.resumablejs[n]=e.resumablejs[n])})))},t.settings=new v,t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[]},t}();var I={Ready:0,Queued:1,Preprocessing:2,Uploading:3,Downloading:4,Finished:5,Failed:6};I[I.Ready]="Ready",I[I.Queued]="Queued",I[I.Preprocessing]="Preprocessing",I[I.Uploading]="Uploading",I[I.Downloading]="Downloading",I[I.Finished]="Finished",I[I.Failed]="Failed";var C={Upload:0,Download:1};C[C.Upload]="Upload",C[C.Download]="Download";var w=function(){function t(t,e){this.dialogRef=t,this.data=e,this.datatransferFacade=this.data.datatransferFacade}return t.prototype.ngAfterViewInit=function(){this.datatransferFacade.assignUploadBrowse(document.getElementById("amd-browse-files")),this.datatransferFacade.assignUploadBrowse(document.getElementById("amd-browse-folder"),!0)},t.prototype.close=function(){this.dialogRef.close()},t.prototype.onNoClick=function(){this.close()},t.decorators=[{type:e.Component,args:[{selector:"amd-browse-dialog",template:'<mat-dialog-content>Select specific files or a folder</mat-dialog-content>\r\n<mat-dialog-actions>\r\n <button mat-raised-button id="amd-browse-files" (click)="close()" tabindex="1">\r\n <mat-icon>insert_drive_file</mat-icon> Files</button>\r\n <button mat-raised-button id="amd-browse-folder" (click)="close()" tabindex="2">\r\n <mat-icon>folder_open</mat-icon> Folder</button>\r\n</mat-dialog-actions>'}]}],t.ctorParameters=function(){return[{type:n.MatDialogRef},{type:void 0,decorators:[{type:e.Inject,args:[n.MAT_DIALOG_DATA]}]}]},t}();var x=function(){function t(t,e){this.dialogRef=t,this.data=e,this.datatransferFacade=this.data.datatransferFacade,this.mode=this.data.mode,this.item=this.data.item,this.itemPath=this.item.path,this.itemName=this.item.name,this.editFormControl=new r.FormControl("",[])}return t.prototype.ngAfterViewInit=function(){},t.prototype.close=function(){this.dialogRef.close()},t.prototype.onNoClick=function(){this.close()},t.prototype.editPath=function(){try{this.datatransferFacade.editPath(this.item,this.item.path,this.itemPath),this.close()}catch(t){this.errorMessage=t}},t.prototype.editFilename=function(){try{this.datatransferFacade.editFilename(this.item,this.itemName),this.close()}catch(t){this.errorMessage=t}},t.decorators=[{type:e.Component,args:[{selector:"amd-edit-dialog",template:'<div *ngIf="mode === \'edit-path\'">\r\n <mat-dialog-content>\r\n <p>Enter a new path:</p>\r\n <form>\r\n <mat-form-field>\r\n <input matInput autocomplete="off" tabindex="1" [value]="itemPath"\r\n (input)="itemPath = $event.target.value; errorMessage = undefined;" [formControl]="editFormControl">\r\n </mat-form-field>\r\n <mat-error *ngIf="errorMessage">\r\n {{errorMessage}}\r\n </mat-error>\r\n </form>\r\n </mat-dialog-content>\r\n <mat-dialog-actions>\r\n <button mat-raised-button (click)="editPath()" tabindex="2">Ok</button>\r\n <button mat-raised-button (click)="close()" tabindex="-1">Cancel</button>\r\n </mat-dialog-actions>\r\n</div>\r\n<div *ngIf="mode === \'edit-filename\'">\r\n <mat-dialog-content>\r\n <p>Enter a new filename:</p>\r\n <form>\r\n <mat-form-field>\r\n <input matInput autocomplete="off" tabindex="1" [value]="itemName"\r\n (input)="itemName = $event.target.value; errorMessage = undefined;" [formControl]="editFormControl">\r\n </mat-form-field>\r\n <mat-error *ngIf="errorMessage">\r\n {{errorMessage}}\r\n </mat-error>\r\n </form>\r\n </mat-dialog-content>\r\n <mat-dialog-actions>\r\n <button mat-raised-button (click)="editFilename()" tabindex="2">Ok</button>\r\n <button mat-raised-button (click)="close()" tabindex="-1">Cancel</button>\r\n </mat-dialog-actions>\r\n</div>'}]}],t.ctorParameters=function(){return[{type:n.MatDialogRef},{type:void 0,decorators:[{type:e.Inject,args:[n.MAT_DIALOG_DATA]}]}]},t}();var S=function(){function t(t,e,n,r,i,a,o,s,p){this.logger=t,this.zone=e,this.store=n,this.dateUtil=r,this.paginationService=i,this.exportService=a,this.uploader=o,this.downloader=s,this.dialog=p,this.progressInterval=200,this.bitrateInterval=1e3,this.uploadProgress=this.store.uploadProgress,this.downloadProgress=this.store.downloadProgress,this.init(this.uploader,this.uploadProgress),this.init(this.downloader,this.downloadProgress)}return t.prototype.init=function(t,e){t.on("itemAdded",function(t){var e=this;e.zone.run((function(){e.addItem(t)}))}.bind(this)),t.on("zoneUpdated",function(t,e,n){this.zone.run((function(){}))}.bind(this)),t.on("itemStatusChanged",function(t,e,n){var r=this;r.zone.run((function(){r.changeItemStatus(t,e,n)}))}.bind(this)),t.on("itemProgressUpdated",function(t,e){var n=this;n.zone.run((function(){n.updateItemProgress(t,e)}))}.bind(this)),t.on("overallProgressUpdated",function(t,n){var r=this;r.zone.run((function(){r.updateOverallProgress(e,t,n)}))}.bind(this)),t.on("overallSizeUpdated",function(t){var n=this;n.zone.run((function(){n.updateOverallSize(e,t)}))}.bind(this))},t.prototype.assignUploadBrowse=function(t,e){void 0===e&&(e=!1),this.uploader.assignBrowse(t,e)},t.prototype.assignUploadDrop=function(t){this.uploader.assignDrop(t)},t.prototype.openBrowseDialog=function(){this.dialog.open(w,{data:{datatransferFacade:this}})},t.prototype.openEditPathDialog=function(t){this.dialog.open(x,{data:{datatransferFacade:this,mode:"edit-path",item:t}})},t.prototype.openEditFilenameDialog=function(t){this.dialog.open(x,{data:{datatransferFacade:this,mode:"edit-filename",item:t}})},t.prototype.toggleVisible=function(t){this.paginationService.paginatedItems.forEach((function(e,n){e.isSelected=t}))},t.prototype.startAll=function(){var t=this;this.store.getItems().forEach((function(e,n){var r=t;e.transferType===C.Upload&&e.status===I.Ready&&r.changeItemStatus(e,I.Queued)})),this.uploader.startAll()},t.prototype.pauseAll=function(){this.store.getItems().forEach((function(t,e){t.preprocessContainer.pause(!0)})),this.uploader.pauseAll(),this.downloader.pauseAll()},t.prototype.removeAll=function(){this.store.getItems().forEach((function(t,e){t.preprocessContainer.cancel(!0)})),this.uploader.removeAll(),this.downloader.removeAll(),this.store.clear(),this.uploadProgress.reset(0),this.paginationService.update(0),document.dispatchEvent(new CustomEvent(h.toString(m.ITEMS_CLEARED)))},t.prototype.retryAll=function(){var t=this;this.store.getByStatus(I.Failed).forEach((function(e,n){t.retryItem(e)}))},t.prototype.removeSelected=function(){var t=this;this.store.getSelected().slice().forEach((function(e,n){t.removeItem(e)}))},t.prototype.addItem=function(t){t&&(this.store.addItem(t),this.paginationService.update(this.store.count),document.dispatchEvent(new CustomEvent(h.toString(m.ITEM_ADDED),{detail:t})))},t.prototype.removeItem=function(t){if(t){switch(t.preprocessContainer.cancel(!0),t.transferType){case C.Upload:this.uploader.removeItem(t);break;case C.Download:this.downloader.removeItem(t)}this.store.removeById(t.id),this.paginationService.update(this.store.count),document.dispatchEvent(new CustomEvent(h.toString(m.ITEM_REMOVED),{detail:t}))}},t.prototype.retryItem=function(t){if(t)switch(t.preprocessContainer.cancel(!0),t.transferType){case C.Upload:this.uploader.retryItem(t);break;case C.Download:this.downloader.retryItem(t)}},t.prototype.changeItemStatus=function(t,e,n){t&&e&&t.status!==e&&(this.paginationService.setPageByItemId(t.id),t.status=e,n&&(t.message=n),this.store.updateFailedCount(),e===I.Finished&&document.dispatchEvent(new CustomEvent(h.toString(m.ITEM_COMPLETED),{detail:t})))},t.prototype.updateItemProgress=function(t,e){if(t){var n=this.dateUtil.now(),r=t.progressContainer.total*e;t.progressContainer.updateBitrate(n,r,this.bitrateInterval),t.progressContainer.updateProgress(n,r,this.progressInterval)}},t.prototype.updateOverallProgress=function(t,e,n){var r=this.dateUtil.now(),i=t.total*n;if(t.updateBitrate(r,i,this.bitrateInterval),t.updateProgress(r,i,this.progressInterval),t.total>0&&i>=t.total)switch(e){case C.Upload:document.dispatchEvent(new CustomEvent(h.toString(m.UPLOAD_COMPLETED)));break;case C.Download:document.dispatchEvent(new CustomEvent(h.toString(m.DOWNLOAD_COMPLETED)))}},t.prototype.updateOverallSize=function(t,e){t.reset(e)},t.prototype.download=function(t,e,n){this.downloader.download(t,e,n)},t.prototype.export=function(t){this.exportService.export(t)},t.prototype.getStatusClass=function(t){switch(t){case I.Ready:return"add_circle_outline";case I.Uploading:return"arrow_upward";case I.Downloading:return"arrow_downward";case I.Failed:return"error_outline";case I.Queued:case I.Preprocessing:return"schedule";case I.Finished:return"done_all";default:return""}},t.prototype.showStartButton=function(){return this.store.count>0&&!this.uploader.isWorking()&&!this.downloader.isWorking()},t.prototype.showPauseButton=function(){return this.uploader.isWorking()},t.prototype.showRemoveButton=function(){return this.store.count>0},t.prototype.showRetryButton=function(){return this.store.failedCount>0&&!this.uploader.isWorking()&&!this.downloader.isWorking()},t.prototype.showRetryButtonByItem=function(t){return t.status===I.Failed},t.prototype.showExportButton=function(){return this.store.count>0},t.prototype.showPreprocessingCheckbox=function(){return this.store.count>0&&b.settings.core.preprocessHashEnabled},t.prototype.showPreprocessingTooltip=function(){return this.showPreprocessingCheckbox()&&!!b.settings.core.preprocessHashTooltipContent},t.prototype.showSpinner=function(t){return t.preprocessContainer.percent>0&&t.status===I.Preprocessing},t.prototype.showProgressbar=function(t){return t.progressContainer.percent>0&&(t.status===I.Uploading||t.status===I.Downloading)},t.prototype.showPath=function(t,e){if(e>0&&t.length>e){var n=t[e].path;return t[e-1].path!==n}return!0},t.prototype.showEditDialog=function(t){var e=!1;if(t)switch(t.transferType){case C.Upload:t.status===I.Ready&&(e=!0)}return e},t.prototype.editPath=function(t,e,n){switch(t.transferType){case C.Upload:var r=n.replace(/\\/g,"/");(r=r.replace(/\/+/g,"/")).startsWith("/")&&(r=r.slice(1)),r&&!r.endsWith("/")&&(r+="/"),this.uploader.editPath(e,r)}},t.prototype.editFilename=function(t,e){switch(t.transferType){case C.Upload:this.uploader.editFilename(t,e)}},t.prototype.parseMessage=function(t){return b.settings.core.parseMessageCallback instanceof Function?b.settings.core.parseMessageCallback(t.message):void 0},t}();var E=function(){this.pages=[],this.page=1,this.rpp=5,this.total=0};var P=function(){function t(){}return t.prototype.now=function(){return Date.now?Date.now():(new Date).getTime()},t.prototype.format=function(t){var e=new Date(1e3*t);return isNaN(e.getTime())?void 0:("0"+e.getUTCHours()).slice(-2)+":"+("0"+e.getUTCMinutes()).slice(-2)+":"+("0"+e.getUTCSeconds()).slice(-2)},t.decorators=[{type:e.Injectable}],t}(),F={Byte:0,KB:1,MB:2,GB:3,TB:4,PB:5};F[F.Byte]="Byte",F[F.KB]="KB",F[F.MB]="MB",F[F.GB]="GB",F[F.TB]="TB",F[F.PB]="PB";var T=function(){function t(){}return t.getNamesAndValues=function(t){return this.getNames(t).map((function(e){return{name:e,value:t[e]}}))},t.getNames=function(t){return this.getObjValues(t).filter((function(t){return"string"==typeof t}))},t.getValues=function(t){return this.getObjValues(t).filter((function(t){return"number"==typeof t}))},t.getObjValues=function(t){return Object.keys(t).map((function(e){return t[e]}))},t}(),M=function(){function t(){this.C_KB=Math.pow(10,3),this.C_MB=Math.pow(10,6),this.C_GB=Math.pow(10,9),this.C_TB=Math.pow(10,12),this.C_PB=Math.pow(10,15),this.MAX=Number.MAX_VALUE,this.byteUnits=T.getNames(F)}return t.prototype.multiply=function(t,e){var n=this.MAX/e;return t>n?Number.MAX_VALUE:t<-n?Number.MIN_VALUE:t*e},t.prototype.convert=function(t,e,n){var r=this.toBytes(t,e);switch(n){case F.Byte:return r;case F.KB:return r/this.C_KB;case F.MB:return r/this.C_MB;case F.GB:return r/this.C_GB;case F.TB:return r/this.C_TB;case F.PB:return r/this.C_PB}return t},t.prototype.toBytes=function(t,e){switch(e){case F.Byte:return t;case F.KB:return this.multiply(t,this.C_KB);case F.MB:return this.multiply(t,this.C_MB);case F.GB:return this.multiply(t,this.C_GB);case F.TB:return this.multiply(t,this.C_TB);case F.PB:return this.multiply(t,this.C_PB)}return t},t.prototype.format=function(t,e){var n,r,i;i=[F.Byte,this.toBytes(t,e)];try{for(var a=u(this.byteUnits),o=a.next();!o.done;o=a.next()){var s=o.value;if(Math.abs(i[1])<1e3){i[0]=F[s];break}i[1]/=1e3}}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i[1]=Number(i[1].toFixed(2)),i},t.decorators=[{type:e.Injectable}],t}();var D=function(){function t(t){this.decimalByteUnit=F.MB,this.decimalByteUnitSize=0;var n=e.ReflectiveInjector.resolveAndCreate([M]);this.decimalByteUnitUtil=n.get(M),this.update(t)}return t.prototype.update=function(t){this.decimalByteUnitUtil&&t&&t.decimalByteUnitSize&&this.updateDecimal(t.decimalByteUnit,t.decimalByteUnitSize)},t.prototype.updateDecimal=function(t,e){var n=this.decimalByteUnitUtil.format(e,t);this.decimalByteUnit=n[0],this.decimalByteUnitSize=n[1],this.displayUnit=F[this.decimalByteUnit],this.displaySize=this.decimalByteUnitSize?this.decimalByteUnitSize:0},t}();var B=function(){function t(t){var n=e.ReflectiveInjector.resolveAndCreate([P]);this.dateUtil=n.get(P),this.bitrateSizeContainer=new D,this.loadedSizeContainer=new D,this.totalSizeContainer=new D,this.reset(t)}return t.prototype.reset=function(t){this.progressTimestamp=this.dateUtil.now(),this.bitrateTimestamp=this.dateUtil.now(),this.loaded=0,this.bitrate=0,this.percent=0,this.total=t,this.displayBitrate=void 0,this.displayTimeLeft=void 0,this.bitrateSizeContainer.updateDecimal(F.Byte,this.bitrate),this.loadedSizeContainer.updateDecimal(F.Byte,this.loaded),this.totalSizeContainer.updateDecimal(F.Byte,this.total)},t.prototype.updateProgress=function(t,e,n){var r=t-this.progressTimestamp;!this.percent||r>n?(this.percent=Number((e/this.total*100).toFixed(2)),this.loaded=e,this.loadedSizeContainer.updateDecimal(F.Byte,this.loaded),this.progressTimestamp=t,this.bitrate>0?this.displayTimeLeft=this.dateUtil.format(8*(this.total-this.loaded)/this.bitrate):this.displayTimeLeft=this.dateUtil.format(0)):e>=this.total&&(this.percent=100,this.loaded=this.total)},t.prototype.updateBitrate=function(t,e,n){var r=t-this.bitrateTimestamp;(!this.bitrate||r>n)&&(this.bitrate=(e-this.loaded)*(1e3/r)*8,this.bitrate!==Number.POSITIVE_INFINITY&&this.bitrate!==Number.NEGATIVE_INFINITY||(this.bitrate=0),this.bitrateSizeContainer.updateDecimal(F.Byte,this.bitrate/8),this.displayBitrate=this.bitrateSizeContainer.displaySize+" "+this.bitrateSizeContainer.displayUnit+"/s",this.bitrateTimestamp=t)},t}();var _=function(){function t(){this.items=[],this.count=0,this.failedCount=0,this.uploadProgress=new B(0),this.downloadProgress=new B(0)}return t.prototype.updateCount=function(){this.count=this.items.length},t.prototype.updateFailedCount=function(){this.failedCount=this.getByStatus(I.Failed).length},t.prototype.getItems=function(){return this.items},t.prototype.getSelected=function(){return this.items.filter((function(t){return!0===t.isSelected}))},t.prototype.getById=function(t){return this.items.find((function(e){return e.id===t}))},t.prototype.getIndexById=function(t){return this.items.findIndex((function(e){return e.id===t}))},t.prototype.clear=function(){this.items.length=0,this.updateCount(),this.updateFailedCount()},t.prototype.addItem=function(t){this.items.push(t),this.updateCount()},t.prototype.removeById=function(t){var e=this.getIndexById(t);e>-1&&(this.items.splice(e,1),this.updateCount())},t.prototype.getByStatus=function(t){return this.items.filter((function(e){return e.status===t}))},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[]},t}();var N=function(){function t(t){this.datatransferStore=t,this.paginatedItems=[],this.pagination=new E}return t.prototype.setRppOptions=function(t){this.pagination.rppOptions=t,this.setPaginationContainer()},t.prototype.update=function(t){t<=0&&(this.paginatedItems.length=0),this.pagination.total=t,this.setPaginationContainer()},t.prototype.setPaginationContainer=function(){var t=this.pageCount();if(this.pagination.pages.length>t)this.pagination.pages.splice(t);else for(var e=this.pagination.pages.length;e<t;e++)this.pagination.pages.push(e+1);this.pagination.pages.includes(this.pagination.page)||(this.pagination.page=1),this.pagination.rppOptions&&this.pagination.rppOptions.length>0&&!this.pagination.rppOptions.includes(this.pagination.rpp)&&(this.pagination.rpp=this.pagination.rppOptions[0]),this.onPaginationChange()},t.prototype.max=function(){return this.hasNext()?this.pagination.page*this.pagination.rpp:this.pagination.total},t.prototype.min=function(){return this.pagination.total>0?this.pagination.page*this.pagination.rpp-this.pagination.rpp+1:0},t.prototype.first=function(){this.pagination.page=1,this.onPaginationChange()},t.prototype.last=function(){this.pagination.page=this.pageCount(),this.onPaginationChange()},t.prototype.hasNext=function(){return this.pagination.page*this.pagination.rpp<this.pagination.total},t.prototype.hasPrevious=function(){return this.pagination.page>1},t.prototype.moveNext=function(){this.pagination.page++,this.onPaginationChange()},t.prototype.movePrevious=function(){this.pagination.page--,this.onPaginationChange()},t.prototype.setPage=function(t){this.pagination.page=t,this.onPageChange()},t.prototype.onPageChange=function(){this.setPaginationContainer(),this.onPaginationChange()},t.prototype.onRppChange=function(){this.setPaginationContainer(),this.pagination.page=1,this.onPaginationChange()},t.prototype.onPaginationChange=function(){var t=(this.pagination.page-1)*this.pagination.rpp,e=Math.min(t+this.pagination.rpp,this.pagination.total);this.paginatedItems=this.datatransferStore.getItems().slice(t,e)},t.prototype.pageCount=function(){return this.pagination.total>0?Math.ceil(this.pagination.total/(this.pagination.rpp>0?this.pagination.rpp:1)):1},t.prototype.getPageByItemId=function(t){var e=this.datatransferStore.getIndexById(t);if(e>-1)return Math.ceil((e+1)/this.pagination.rpp)},t.prototype.setPageByItemId=function(t){var e=this.getPageByItemId(t);this.pagination.page!==e&&this.setPage(e)},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:_}]},t}();var U=function(){function t(t,e){this.datatransferStore=t,this.paginationService=e,this.config=b.settings,this.uploadProgress=this.datatransferStore.uploadProgress,this.downloadProgress=this.datatransferStore.downloadProgress}return t.prototype.ngAfterViewInit=function(){this.init()},t.prototype.init=function(){if(this.config.core.showUploadDropzone){var t=document.getElementById("amd-dropzone-component");t&&(t.addEventListener("click",this.datatransferFacade.openBrowseDialog.bind(this.datatransferFacade),!1),this.datatransferFacade.assignUploadDrop(t))}else{if(void 0!==this.config.core.uploadBrowseElementId){var e=document.getElementById(this.config.core.uploadBrowseElementId);e&&e.addEventListener("click",this.datatransferFacade.openBrowseDialog.bind(this.datatransferFacade),!1)}if(void 0!==this.config.core.uploadDropElementId){var n=document.getElementById(this.config.core.uploadDropElementId);n&&this.datatransferFacade.assignUploadDrop(n)}}},t.decorators=[{type:e.Component,args:[{selector:"amd-main",template:'<div class="amd-font">\r\n <div *ngIf="config.core.showUploadDropzone">\r\n <amd-dropzone></amd-dropzone>\r\n </div>\r\n\r\n <div fxLayout="row" fxLayout.lt-sm="column" style="margin-bottom: 10px">\r\n <div fxFlex>\r\n <button class="amd-mr-1" mat-raised-button *ngIf="datatransferFacade.showStartButton()"\r\n (click)="datatransferFacade.startAll()">\r\n <mat-icon>play_arrow</mat-icon> Start\r\n </button>\r\n <button class="amd-mr-1" mat-raised-button *ngIf="datatransferFacade.showPauseButton()"\r\n (click)="datatransferFacade.pauseAll()">\r\n <mat-icon>pause</mat-icon> Pause\r\n </button>\r\n <button class="amd-mr-1" mat-raised-button *ngIf="datatransferFacade.showRemoveButton()"\r\n (click)="datatransferFacade.removeAll()">\r\n <mat-icon>close</mat-icon> Remove all\r\n </button>\r\n <button class="amd-mr-1" mat-raised-button *ngIf="datatransferFacade.showRetryButton()"\r\n (click)="datatransferFacade.retryAll()">\r\n <mat-icon>refresh</mat-icon> Retry ({{datatransferStore.failedCount}})\r\n </button>\r\n <mat-menu #exportMenu="matMenu">\r\n <button mat-menu-item (click)="datatransferFacade.export(\'CSV\')">\r\n <span>CSV</span>\r\n </button>\r\n <button mat-menu-item (click)="datatransferFacade.export(\'JSON\')">\r\n <span>JSON</span>\r\n </button>\r\n </mat-menu>\r\n <button mat-raised-button *ngIf="datatransferFacade.showExportButton()" [matMenuTriggerFor]="exportMenu">\r\n Export\r\n <mat-icon>expand_more</mat-icon>\r\n </button>\r\n <mat-checkbox *ngIf="datatransferFacade.showPreprocessingCheckbox()"\r\n [(ngModel)]="config.core.preprocessHashChecked" style="margin-left: 10px;">\r\n Preprocessing <span *ngIf="datatransferFacade.showPreprocessingTooltip()"\r\n class="amd-vertical-align-middle" [matTooltip]="config.core.preprocessHashTooltipContent"\r\n matTooltipPosition="right">\r\n <mat-icon>info_outline</mat-icon>\r\n </span>\r\n </mat-checkbox>\r\n </div>\r\n <div fxFlex="70px" fxFlex.lt-sm="0px">\r\n </div>\r\n <div fxFlex>\r\n <div *ngIf="uploadProgress.percent > 0">\r\n <amd-progress [progressContainer]="uploadProgress"></amd-progress>\r\n </div>\r\n <div *ngIf="downloadProgress.percent > 0">\r\n <amd-progress [progressContainer]="downloadProgress"></amd-progress>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class="amd-container">\r\n <div fxLayout="row" class="amd-container-header" style="align-items: center;">\r\n <div fxFlex="40px">\r\n <mat-checkbox (change)="datatransferFacade.toggleVisible($event.checked)"></mat-checkbox>\r\n </div>\r\n <div fxFlex="50%" fxFlex.lt-sm="100%">\r\n Filename\r\n </div>\r\n <div fxFlex="50%" style="padding-left: 40px;" fxHide.lt-sm>\r\n Progress\r\n </div>\r\n <div fxFlex="20px">\r\n <mat-menu #batchItemMenu="matMenu">\r\n <button mat-menu-item (click)="datatransferFacade.removeSelected()">\r\n <mat-icon>close</mat-icon>\r\n <span>Remove</span>\r\n </button>\r\n </mat-menu>\r\n <button mat-icon-button [matMenuTriggerFor]="batchItemMenu">\r\n <mat-icon>more_vert</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <ng-template ngFor let-item [ngForOf]="paginationService.paginatedItems" let-i="index">\r\n <div *ngIf="datatransferFacade.showPath(paginationService.paginatedItems, i)">\r\n <div fxLayout="row" class="amd-container-headline">\r\n <div fxFlex class="amd-container-headline-item">\r\n <div class="amd-container-headline-item-entry">\r\n <div fxFlex="40px">\r\n <mat-icon>folder_open</mat-icon>\r\n </div>\r\n <div fxFlex>\r\n <span>\r\n <b>{{item.displayPath}}</b>\r\n </span>\r\n <button mat-icon-button (click)="datatransferFacade.openEditPathDialog(item)"\r\n *ngIf="datatransferFacade.showEditDialog(item)">\r\n <mat-icon aria-label="Edit path">edit</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div fxLayout="row" fxLayout.lt-sm="column" class="amd-container-row"\r\n [ngClass]="{\'selected\': item.isSelected}">\r\n <div fxFlex class="amd-container-row-item">\r\n <div class="amd-container-row-item-entry">\r\n <div fxFlex="40px">\r\n <mat-checkbox [(ngModel)]="item.isSelected"></mat-checkbox>\r\n </div>\r\n <div fxFlex="100%">\r\n <div matTooltip="{{item.name}}" matTooltipPosition="above">\r\n <span>{{item.name}}</span>\r\n <button mat-icon-button (click)="datatransferFacade.openEditFilenameDialog(item)"\r\n *ngIf="datatransferFacade.showEditDialog(item)">\r\n <mat-icon aria-label="Edit filename">edit</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div fxFlex class="amd-container-row-item">\r\n <div class="amd-container-row-item-entry">\r\n <div fxFlex="40px" matTooltip="{{item.preprocessContainer.percent}}%"\r\n *ngIf="datatransferFacade.showSpinner(item); else showStatusClass">\r\n <mat-progress-spinner *ngIf="item.preprocessContainer.percent > 0" [diameter]="20"\r\n mode="determinate" [value]="item.preprocessContainer.percent"></mat-progress-spinner>\r\n </div>\r\n <ng-template #showStatusClass>\r\n <div fxFlex="40px">\r\n <mat-icon>{{datatransferFacade.getStatusClass(item.status)}}</mat-icon>\r\n </div>\r\n </ng-template>\r\n <div fxFlex="100%">\r\n <div *ngIf="datatransferFacade.showProgressbar(item); else showStatusBlock">\r\n <div class="amd-container-row-item-entry-stats">\r\n <div fxFlex="25%" fxFlex.lt-md="50%">\r\n {{item.progressContainer.displayBitrate}}\r\n </div>\r\n <div fxFlex="25%" fxHide.lt-md style="text-align: center">\r\n {{item.progressContainer.displayTimeLeft}}\r\n </div>\r\n <div fxFlex="25%" fxHide.lt-md style="text-align: center">\r\n {{item.progressContainer.percent}}%\r\n </div>\r\n <div fxFlex="25%" fxFlex.lt-md="50%" style="text-align: right">\r\n {{item.progressContainer.loadedSizeContainer.displaySize}} /\r\n {{item.sizeContainer.displaySize}}\r\n {{item.sizeContainer.displayUnit}}\r\n </div>\r\n </div>\r\n <mat-progress-bar *ngIf="item.progressContainer.total > 0" color="primary"\r\n mode="determinate" [value]="item.progressContainer.percent">\r\n </mat-progress-bar>\r\n </div>\r\n <ng-template #showStatusBlock>\r\n {{item.getStatusName()}} ({{item.sizeContainer.displaySize}}\r\n {{item.sizeContainer.displayUnit}})\r\n <div *ngIf="!!item.message">\r\n <small>{{datatransferFacade.parseMessage(item)}}</small>\r\n </div>\r\n </ng-template>\r\n </div>\r\n <div fxFlex="20px">\r\n <mat-menu #itemMenu="matMenu">\r\n <button mat-menu-item (click)="datatransferFacade.retryItem(item)"\r\n *ngIf="datatransferFacade.showRetryButtonByItem(item)">\r\n <mat-icon>refresh</mat-icon>\r\n <span>Retry</span>\r\n </button>\r\n <button mat-menu-item (click)="datatransferFacade.removeItem(item)">\r\n <mat-icon>close</mat-icon>\r\n <span>Remove</span>\r\n </button>\r\n </mat-menu>\r\n <button mat-icon-button [matMenuTriggerFor]="itemMenu">\r\n <mat-icon>more_vert</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </ng-template>\r\n </div>\r\n\r\n <div style="font-size: 12px; margin-top: 20px; text-align: right;">\r\n <amd-pagination [paginationService]="paginationService"></amd-pagination>\r\n </div>\r\n</div>'}]}],t.ctorParameters=function(){return[{type:_},{type:N}]},t.propDecorators={datatransferFacade:[{type:e.Input}]},t}();var O=function(){function t(){this.noop=function(){}}return Object.defineProperty(t.prototype,"enabled",{get:function(){return!b.settings.production},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this.enabled?console.debug.bind(console):this.noop},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"error",{get:function(){return this.enabled?console.error.bind(console):this.noop},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"log",{get:function(){return this.enabled?console.log.bind(console):this.noop},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"info",{get:function(){return this.enabled?console.info.bind(console):this.noop},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"warn",{get:function(){return this.enabled?console.warn.bind(console):this.noop},enumerable:!0,configurable:!0}),t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[]},t}();var z=function(){function t(t,e){this.logger=t,this.store=e}return t.prototype.download=function(t,e,n){var r=document.createElement("a");n=n||"application/octet-stream",navigator.msSaveBlob?navigator.msSaveBlob(new Blob([t],{type:n}),e):URL&&"download"in r?(r.href=URL.createObjectURL(new Blob([t],{type:n})),r.setAttribute("download",e),document.body.appendChild(r),r.click(),document.body.removeChild(r)):location.href="data:application/octet-stream,"+encodeURIComponent(t)},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:O},{type:_}]},t}();var A=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.logger=e,r.store=n,r}return d(n,t),n.prototype.export=function(){var t="name,path,status,size,message\n",e=this.store.getItems();e.forEach((function(n,r){var i=n.name+","+n.path+","+n.getStatusName()+","+n.sizeContainer.displaySize+" "+n.sizeContainer.displayUnit+","+n.message;t+=r<e.length?i+"\n":i})),this.download(t,"export.csv","text/csv;encoding:utf-8")},n.decorators=[{type:e.Injectable}],n.ctorParameters=function(){return[{type:O},{type:_}]},n}(z);var k=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.logger=e,r.store=n,r}return d(n,t),n.prototype.export=function(){var t=[];this.store.getItems().forEach((function(e,n){t.push({name:e.name,path:e.path,status:e.getStatusName(),size:e.sizeContainer.displaySize+" "+e.sizeContainer.displayUnit,message:e.message})})),this.download(JSON.stringify(t,null,"\t"),"export.json","text/json;encoding:utf-8")},n.decorators=[{type:e.Injectable}],n.ctorParameters=function(){return[{type:O},{type:_}]},n}(z);var R={CSV:0,JSON:1};R[R.CSV]="CSV",R[R.JSON]="JSON";var L=function(){function t(t,e){this.csvExporter=t,this.jsonExporter=e}return t.prototype.export=function(t){switch(R[t]){case R.CSV:this.csvExporter.export();break;case R.JSON:this.jsonExporter.export()}},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:A},{type:k}]},t}();var H=function(){function t(t){this.percent=0,this._isPaused=!1,this._isCancelled=!1,Object.assign(this,t)}return t.prototype.pause=function(t){this._isPaused=t},t.prototype.isPaused=function(){return this._isPaused},t.prototype.cancel=function(t){this._isCancelled=t},t.prototype.isCancelled=function(){return this._isCancelled},t.prototype.doWork=function(){},t.prototype.run=function(){this._isPaused=!1,this.doWork()},t}();var j={MD5:0,SHA1:1};j[j.MD5]="MD5",j[j.SHA1]="SHA1";var W,V={Internal:0,CryptoBrowserify:1};V[V.Internal]="Internal",V[V.CryptoBrowserify]="CryptoBrowserify",function(t){t.toString=function(t,e){switch(e){case j.MD5:return"md5";case j.SHA1:default:return"sha1"}},t.toEnum=function(t,e){switch(e){case"md5":return j.MD5;case"sha1":default:return j.SHA1}}}(W||(W={}));var q={Latin1:0,Hex:1,Base64:2,UTF8:3};q[q.Latin1]="Latin1",q[q.Hex]="Hex",q[q.Base64]="Base64",q[q.UTF8]="UTF8";var G,K={Internal:0,CryptoBrowserify:1};K[K.Internal]="Internal",K[K.CryptoBrowserify]="CryptoBrowserify",function(t){t.toString=function(t,e){switch(e){case q.Latin1:return"latin1";case q.Hex:return"hex";case q.Base64:return"base64";case q.UTF8:return"utf8";default:return"hex"}},t.toEnum=function(t,e){switch(e){case"latin1":return q.Latin1;case"hex":return q.Hex;case"base64":return q.Base64;case"utf8":return q.UTF8;default:return q.Hex}}}(G||(G={}));var Y=function(t){function e(e,n,r,i,a,o){var s=t.call(this)||this;return s.file=e,s.hashType=i,s.hashTypeString=W.toString(n,i),s.encodingType=a,s.encodingTypeString=G.toString(r,a),s.inputEncodingType=o,s.inputEncodingTypeString=G.toString(r,o),s.startDate=new Date,s.endDate=new Date,s.reader=new FileReader,s}return d(e,t),e}(H);var X=function(t){function e(e,n,r,i,a,o){var s=t.call(this,e,n,r,i,a,o)||this;return s.chunkSize=0,s.offset=0,s}return d(e,t),e.prototype.cancel=function(e){t.prototype.cancel.call(this,e),this.offset=0},e}(Y);var Q=function(){function t(t,e,n){this.logger=t,this.guidUtil=e,this.cryptoService=n,this.events=[],this._isWorking=!1}return t.prototype.on=function(t,e){this.events.push(t.toLowerCase(),e)},t.prototype.fire=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=t[0].toLowerCase(),r=0;r<=this.events.length;r+=2)this.events[r]===n&&this.events[r+1].apply(this,t.slice(1)),"catchall"===this.events[r]&&this.events[r+1].apply(null,t)},t.prototype.updateZone=function(){this.fire("zoneUpdated")},t.prototype.changeItemStatus=function(t,e,n){this.fire("itemStatusChanged",t,e,n)},t.prototype.updateItemProgress=function(t,e){this.fire("itemProgressUpdated",t,e)},t.prototype.updateOverallProgress=function(t,e){this.fire("overallProgressUpdated",t,e)},t.prototype.updateOverallSize=function(t){this.fire("overallSizeUpdated",t)},t.prototype.isWorking=function(){return this._isWorking},t.prototype.addItem=function(t){this.fire("itemAdded",t)},t.prototype.generateUniqueIdentifier=function(){return this.guidUtil.createGuid()},t.prototype.preprocessHash=function(t,e,n,r){var i=function(e){if(e.hashString){var i=new XMLHttpRequest,a=function(a){e.isCancelled()||(200===i.status?(t.message=i.responseText,r()):n())};i.addEventListener("load",a,!1),i.addEventListener("error",a,!1),i.addEventListener("timeout",a,!1);var o=[];o=o.concat([[b.settings.core.preprocessHashParameterName,e.hashString],[b.settings.core.preprocessHashFileNameParameterName,t.name]].map((function(t){return[t[0],encodeURIComponent(t[1])].join("=")}))),i.open(b.settings.core.preprocessHashMethod,b.settings.core.getTarget("preprocessHash",o)),i.send(null)}else n()}.bind(this);if(!t.preprocessContainer.isCancelled()&&t.preprocessContainer instanceof X);else{var a=W.toEnum(V.Internal,b.settings.core.preprocessHashFunctionName),o=G.toEnum(K.Internal,b.settings.core.preprocessHashEncodingName),s=G.toEnum(K.Internal,b.settings.core.preprocessHashInputEncodingName);t.preprocessContainer=this.cryptoService.createStreamHashContainer(e,a,o,s,i,(function(t,e){console.log(t),n()}))}setTimeout((function(){t.preprocessContainer.run()}),1e3)},t}();var Z=function(t){function e(e,n,r){var i=t.call(this,e,n,r)||this;return i.logger=e,i.guidUtil=n,i.cryptoService=r,i.filenameRegExp=new RegExp('[/\\\\*?"<>:|]'),i.pathRegExp=new RegExp('[*?"<>:|]'),i.transferType=C.Upload,i}return d(e,t),e.prototype.editPath=function(t,e){if(this.pathRegExp.test(e))throw new Error('A path cannot contain any of the following characters: * ? " < > : |')},e.prototype.editFilename=function(t,e){if(!t)throw new Error("Cannot edit the filename.");if(!e)throw new Error("Empty filename is not allowed.");if(this.filenameRegExp.test(e))throw new Error('A filename cannot contain any of the following characters: \\ / * ? " < > : |')},e}(Q);var J=function(){function t(){}return t.prototype.createGuid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},t.decorators=[{type:e.Injectable}],t}(),$=function(){function t(t){this.zone=t,this.STREAM_HASH_CHUNK_SIZE=4096e3,this.HASH_TYPE_IMPLEMENTATION=V.CryptoBrowserify,this.ENCODING_TYPE_IMPLEMENTATION=K.CryptoBrowserify}return t.prototype.createHashContainer=function(t,e,n,r){var i=new Y(t,this.HASH_TYPE_IMPLEMENTATION,this.ENCODING_TYPE_IMPLEMENTATION,e,n,r);return i.hash=a.createHash(i.hashTypeString),i.reader.onload=function(t){i.hashString=i.hash.update(t.target.result,i.inputEncodingTypeString).digest(i.encodingTypeString),i.endDate=new Date,i.percent=100}.bind(i),i.doWork=function(){i.reader.readAsBinaryString(i.file)},i},t.prototype.createStreamHashContainer=function(t,e,n,r,i,o){var s=new X(t,this.HASH_TYPE_IMPLEMENTATION,this.ENCODING_TYPE_IMPLEMENTATION,e,n,r);return s.chunkSize=this.STREAM_HASH_CHUNK_SIZE,s.offset=0,s.hash=a.createHash(s.hashTypeString),s.reader.onload=function(t){var e=t.target.result;s.offset+s.chunkSize>=s.file.size?s.hash.end(e,s.inputEncodingTypeString):s.hash.write(e,s.inputEncodingTypeString),s.offset+=s.chunkSize,s.doWork()}.bind(s),s.reader.onerror=function(t){o(t,s)},s.doWork=function(){if(!s.isCancelled()&&!s.isPaused()){if(s.offset>s.file.size)return s.hashString=s.hash.read().toString(s.encodingTypeString),s.endDate=new Date,s.percent=100,void i(s);var e=s.file.slice(s.offset,s.offset+s.chunkSize);s.reader.readAsBinaryString(e),s.percent=Math.round(s.offset/t.size*100)}},s},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:e.NgZone}]},t}();var tt=function(){function t(t){this.sizeContainer=new D,this.preprocessContainer=new H,this.progressContainer=new B(0),Object.assign(this,t)}return Object.defineProperty(t.prototype,"path",{get:function(){return this._path},set:function(t){this._path=t,this.displayPath=t,this.displayPath&&(this.displayPath.endsWith("/")&&(this.displayPath=this.displayPath.slice(0,-1)),this.displayPath=this.displayPath.replace(/\//g," > "))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"message",{get:function(){return this._message},set:function(t){this._message=t.toLowerCase().startsWith("<!doctype html")?void 0:t},enumerable:!0,configurable:!0}),t.prototype.getStatusName=function(){return I[this.status]},t.prototype.getTransferTypeName=function(){return C[this.transferType]},t}();var et=function(t){function n(e,n,r){var i=t.call(this,e,n,r)||this;return i.logger=e,i.guidUtil=n,i.cryptoService=r,i.r=void 0,i.preprocessFileFn=void 0,i.preprocessChunkFn=void 0,i.initResumable(),i}return d(n,t),n.prototype.initResumable=function(){b.settings.resumablejs.generateUniqueIdentifier=function(t,e){return this.generateUniqueIdentifier()}.bind(this),"function"==typeof b.settings.resumablejs.preprocess&&(this.preprocessChunkFn=b.settings.resumablejs.preprocess.bind({})),b.settings.resumablejs.preprocess=function(t){"function"==typeof this.preprocessChunkFn?this.preprocessChunkFn(t):t.preprocessFinished()}.bind(this),"function"==typeof b.settings.resumablejs.preprocessFile&&(this.preprocessFileFn=b.settings.resumablejs.preprocessFile.bind({})),b.settings.resumablejs.preprocessFile=function(t){var e=this;if("function"==typeof e.preprocessFileFn)e.changeItemStatus(t.internalItem,I.Preprocessing),e.preprocessFileFn(t);else if(b.settings.core.preprocessHashEnabled&&b.settings.core.preprocessHashChecked){e.changeItemStatus(t.internalItem,I.Preprocessing);e.preprocessHash(t.internalItem,t.file,(function(){t.preprocessFinished()}),(function(){t.cancel(),e.changeItemStatus(t.internalItem,I.Finished,t.internalItem.message),e.r.uploadNextChunk()}))}else t.preprocessFinished()}.bind(this),this.r=new i(b.settings.resumablejs),this.r.on("fileAdded",function(t,e){var n=new tt({id:t.uniqueIdentifier,name:t.fileName,path:t.relativePath.substr(0,t.relativePath.length-t.fileName.length),sizeContainer:new D({decimalByteUnit:F.Byte,decimalByteUnitSize:t.size}),progressContainer:new B(t.size),transferType:C.Upload,status:I.Ready,externalItem:t});t.internalItem=n,this.addItem(n)}.bind(this)),this.r.on("fileProgress",function(t,e){this.changeItemStatus(t.internalItem,I.Uploading),this.updateItemProgress(t.internalItem,t.progress()),this.updateOverallProgress(this.transferType,this.r.progress())}.bind(this)),this.r.on("fileSuccess",function(t,e){this.changeItemStatus(t.internalItem,I.Finished,e)}.bind(this)),this.r.on("fileError",function(t,e){this.changeItemStatus(t.internalItem,I.Failed,e)}.bind(this)),this.r.on("uploadStart",function(){this._isWorking=!0,this.updateZone(),this.updateOverallProgress(this.transferType,this.r.progress()),this.updateOverallSize(this.r.getSize())}.bin