/usr/share/javascript/angular.js/ng-file-upload.min.js is in libjs-angular-file-upload 12.0.4+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 | if(window.XMLHttpRequest&&!(window.FileAPI&&FileAPI.shouldLoad)){window.XMLHttpRequest.prototype.setRequestHeader=(function(a){return function(d,b){if(d==="__setXHR_"){var c=b(this);if(c instanceof Function){c(this)}}else{a.apply(this,arguments)}}})(window.XMLHttpRequest.prototype.setRequestHeader)}var ngFileUpload=angular.module("ngFileUpload",[]);ngFileUpload.version="12.0.4";ngFileUpload.service("UploadBase",["$http","$q","$timeout",function(g,b,d){var c=this;c.promisesCount=0;this.isResumeSupported=function(){return window.Blob&&window.Blob.prototype.slice};var a=this.isResumeSupported();function e(j){j.method=j.method||"POST";j.headers=j.headers||{};var h=j._deferred=j._deferred||b.defer();var m=h.promise;function l(n){if(h.notify){h.notify(n)}if(m.progressFunc){d(function(){m.progressFunc(n)})}}function i(o){if(j._start!=null&&a){return{loaded:o.loaded+j._start,total:(j._file&&j._file.size)||o.total,type:o.type,config:j,lengthComputable:true,target:o.target}}else{return o}}if(!j.disableProgress){j.headers.__setXHR_=function(){return function(n){if(!n||!n.upload||!n.upload.addEventListener){return}j.__XHR=n;if(j.xhrFn){j.xhrFn(n)}n.upload.addEventListener("progress",function(o){o.config=j;l(i(o))},false);n.upload.addEventListener("load",function(o){if(o.lengthComputable){o.config=j;l(i(o))}},false)}}}function k(){g(j).then(function(n){if(a&&j._chunkSize&&!j._finished&&j._file){l({loaded:j._end,total:j._file&&j._file.size,config:j,type:"progress"});c.upload(j,true)}else{if(j._finished){delete j._finished}h.resolve(n)}},function(n){h.reject(n)},function(o){h.notify(o)})}if(!a){k()}else{if(j._chunkSize&&j._end&&!j._finished){j._start=j._end;j._end+=j._chunkSize;k()}else{if(j.resumeSizeUrl){g.get(j.resumeSizeUrl).then(function(n){if(j.resumeSizeResponseReader){j._start=j.resumeSizeResponseReader(n.data)}else{j._start=parseInt((n.data.size==null?n.data:n.data.size).toString())}if(j._chunkSize){j._end=j._start+j._chunkSize}k()},function(n){throw n})}else{if(j.resumeSize){j.resumeSize().then(function(n){j._start=n;k()},function(n){throw n})}else{if(j._chunkSize){j._start=0;j._end=j._start+j._chunkSize}k()}}}}m.success=function(n){m.then(function(o){n(o.data,o.status,o.headers,j)});return m};m.error=function(n){m.then(null,function(o){n(o.data,o.status,o.headers,j)});return m};m.progress=function(n){m.progressFunc=n;m.then(null,null,function(o){n(o)});return m};m.abort=m.pause=function(){if(j.__XHR){d(function(){j.__XHR.abort()})}return m};m.xhr=function(n){j.xhrFn=(function(o){return function(){if(o){o.apply(m,arguments)}n.apply(m,arguments)}})(j.xhrFn);return m};c.promisesCount++;m["finally"](function(){c.promisesCount--});return m}this.isUploadInProgress=function(){return c.promisesCount>0};this.rename=function(i,h){i.ngfName=h;return i};this.jsonBlob=function(i){if(i!=null&&!angular.isString(i)){i=JSON.stringify(i)}var h=new window.Blob([i],{type:"application/json"});h._ngfBlob=true;return h};this.json=function(h){return angular.toJson(h)};function f(i){var j={};for(var h in i){if(i.hasOwnProperty(h)){j[h]=i[h]}}return j}this.isFile=function(h){return h!=null&&(h instanceof window.Blob||(h.flashId&&h.name&&h.size))};this.upload=function(i,h){function k(m,n){if(m._ngfBlob){return m}i._file=i._file||m;if(i._start!=null&&a){if(i._end&&i._end>=m.size){i._finished=true;i._end=m.size}var o=m.slice(i._start,i._end||m.size);o.name=m.name;o.ngfName=m.ngfName;if(i._chunkSize){n.append("_chunkSize",i._chunkSize);n.append("_currentChunkSize",i._end-i._start);n.append("_chunkNumber",Math.floor(i._start/i._chunkSize));n.append("_totalSize",i._file.size)}return o}return m}function j(r,s,q){if(s!==undefined){if(angular.isDate(s)){s=s.toISOString()}if(angular.isString(s)){r.append(q,s)}else{if(c.isFile(s)){var p=k(s,r);var o=q.split(",");if(o[1]){p.ngfName=o[1].replace(/^\s+|\s+$/g,"");q=o[0]}i._fileKey=i._fileKey||q;r.append(q,p,p.ngfName||p.name)}else{if(angular.isObject(s)){if(s.$$ngfCircularDetection){throw"ngFileUpload: Circular reference in config.data. Make sure specified data for Upload.upload() has no circular reference: "+q}s.$$ngfCircularDetection=true;try{for(var m in s){if(s.hasOwnProperty(m)&&m!=="$$ngfCircularDetection"){var n=i.objectKey==null?"[i]":i.objectKey;if(s.length&&parseInt(m)>-1){n=i.arrayKey==null?n:i.arrayKey}j(r,s[m],q+n.replace(/[ik]/g,m))}}}finally{delete s.$$ngfCircularDetection}}else{r.append(q,s)}}}}}function l(){i._chunkSize=c.translateScalars(i.resumeChunkSize);i._chunkSize=i._chunkSize?parseInt(i._chunkSize.toString()):null;i.headers=i.headers||{};i.headers["Content-Type"]=undefined;i.transformRequest=i.transformRequest?(angular.isArray(i.transformRequest)?i.transformRequest:[i.transformRequest]):[];i.transformRequest.push(function(n){var o=new window.FormData(),m;n=n||i.fields||{};if(i.file){n.file=i.file}for(m in n){if(n.hasOwnProperty(m)){var p=n[m];if(i.formDataAppender){i.formDataAppender(o,m,p)}else{j(o,p,m)}}}return o})}if(!h){i=f(i)}if(!i._isDigested){i._isDigested=true;l()}return e(i)};this.http=function(h){h=f(h);h.transformRequest=h.transformRequest||function(i){if((window.ArrayBuffer&&i instanceof window.ArrayBuffer)||i instanceof window.Blob){return i}return g.defaults.transformRequest[0].apply(this,arguments)};h._chunkSize=c.translateScalars(h.resumeChunkSize);h._chunkSize=h._chunkSize?parseInt(h._chunkSize.toString()):null;return e(h)};this.translateScalars=function(h){if(angular.isString(h)){if(h.search(/kb/i)===h.length-2){return parseFloat(h.substring(0,h.length-2)*1024)}else{if(h.search(/mb/i)===h.length-2){return parseFloat(h.substring(0,h.length-2)*1048576)}else{if(h.search(/gb/i)===h.length-2){return parseFloat(h.substring(0,h.length-2)*1073741824)}else{if(h.search(/b/i)===h.length-1){return parseFloat(h.substring(0,h.length-1))}else{if(h.search(/s/i)===h.length-1){return parseFloat(h.substring(0,h.length-1))}else{if(h.search(/m/i)===h.length-1){return parseFloat(h.substring(0,h.length-1)*60)}else{if(h.search(/h/i)===h.length-1){return parseFloat(h.substring(0,h.length-1)*3600)}}}}}}}}return h};this.urlToBlob=function(h){var i=b.defer();g({url:h,method:"get",responseType:"arraybuffer"}).then(function(m){var l=new Uint8Array(m.data);var k=m.headers("content-type")||"image/WebP";var j=new window.Blob([l],{type:k});i.resolve(j)},function(j){i.reject(j)});return i.promise};this.setDefaults=function(h){this.defaults=h||{}};this.defaults={};this.version=ngFileUpload.version}]);ngFileUpload.service("Upload",["$parse","$timeout","$compile","$q","UploadExif",function(d,c,f,h,e){var i=e;i.getAttrWithDefaults=function(j,k){if(j[k]!=null){return j[k]}var l=i.defaults[k];return(l==null?l:(angular.isString(l)?l:JSON.stringify(l)))};i.attrGetter=function(l,j,m,o){var k=this.getAttrWithDefaults(j,l);if(m){try{if(o){return d(k)(m,o)}else{return d(k)(m)}}catch(n){if(l.search(/min|max|pattern/i)){return k}else{throw n}}}else{return k}};i.shouldUpdateOn=function(l,j,k){var m=i.attrGetter("ngModelOptions",j,k);if(m&&m.updateOn){return m.updateOn.split(" ").indexOf(l)>-1}return true};i.emptyPromise=function(){var k=h.defer();var j=arguments;c(function(){k.resolve.apply(k,j)});return k.promise};i.rejectPromise=function(){var k=h.defer();var j=arguments;c(function(){k.reject.apply(k,j)});return k.promise};i.happyPromise=function(l,j){var k=h.defer();l.then(function(m){k.resolve(m)},function(m){c(function(){throw m});k.resolve(j)});return k.promise};function g(m,j,l){var k=[i.emptyPromise()];angular.forEach(m,function(o,n){if(o.type.indexOf("image/jpeg")===0&&i.attrGetter("ngfFixOrientation",j,l,{$file:o})){k.push(i.happyPromise(i.applyExifRotation(o),o).then(function(p){m.splice(n,1,p)}))}});return h.all(k)}function a(m,k,l){var j=i.attrGetter("ngfResize",k,l);if(!j||!i.isResizeSupported()||!m.length){return i.emptyPromise()}if(j instanceof Function){var n=h.defer();j(m).then(function(o){b(o,m,k,l).then(function(p){n.resolve(p)},function(p){n.reject(p)})},function(o){n.reject(o)})}else{return b(j,m,k,l)}}function b(p,o,j,n){var m=[i.emptyPromise()];function k(r,q){if(r.type.indexOf("image")===0){if(p.pattern&&!i.validatePattern(r,p.pattern)){return}var s=i.resize(r,p.width,p.height,p.quality,p.type,p.ratio,p.centerCrop,function(u,t){return i.attrGetter("ngfResizeIf",j,n,{$width:u,$height:t,$file:r})},p.restoreExif!==false);m.push(s);s.then(function(t){o.splice(q,1,t)},function(t){r.$error="resize";r.$errorParam=(t?(t.message?t.message:t)+": ":"")+(r&&r.name)})}}for(var l=0;l<o.length;l++){k(o[l],l)}return h.all(m)}i.updateModel=function(s,x,k,j,o,t,n){function p(J,M,K,L,H){x.$$ngfPrevValidFiles=J;x.$$ngfPrevInvalidFiles=M;var G=J&&J.length?J[0]:null;var F=M&&M.length?M[0]:null;if(s){i.applyModelValidation(s,J);s.$setViewValue(H?G:J)}if(j){d(j)(k,{$files:J,$file:G,$newFiles:K,$duplicateFiles:L,$invalidFiles:M,$invalidFile:F,$event:t})}var I=i.attrGetter("ngfModelInvalid",x);if(I){c(function(){d(I).assign(k,H?F:M)})}c(function(){})}var q,v=[],u,y,r=[],l=[];function D(){function H(I,J){return I.name===J.name&&(I.$ngfOrigSize||I.size)===(J.$ngfOrigSize||J.size)&&I.type===J.type}function F(J){var I;for(I=0;I<u.length;I++){if(H(J,u[I])){return true}}for(I=0;I<y.length;I++){if(H(J,y[I])){return true}}return false}if(o){q=[];v=[];for(var G=0;G<o.length;G++){if(F(o[G])){v.push(o[G])}else{q.push(o[G])}}}}function z(F){return angular.isArray(F)?F:[F]}function B(){l=[];r=[];angular.forEach(q,function(F){if(F.$error){r.push(F)}else{l.push(F)}})}function E(){function F(){c(function(){p(A?u.concat(l):l,A?y.concat(r):r,o,v,w)},m&&m.debounce?m.debounce.change||m.debounce:0)}a(C?q:l,x,k).then(function(){if(C){i.validate(q,u.length,s,x,k).then(function(){B();F()})}else{F()}},function(G){throw"Could not resize files "+G})}u=x.$$ngfPrevValidFiles||[];y=x.$$ngfPrevInvalidFiles||[];if(s&&s.$modelValue){u=z(s.$modelValue)}var A=i.attrGetter("ngfKeep",x,k);q=(o||[]).slice(0);if(A==="distinct"||i.attrGetter("ngfKeepDistinct",x,k)===true){D(x,k)}var w=!A&&!i.attrGetter("ngfMultiple",x,k)&&!i.attrGetter("multiple",x);if(A&&!q.length){return}i.attrGetter("ngfBeforeModelChange",x,k,{$files:o,$file:o&&o.length?o[0]:null,$newFiles:q,$duplicateFiles:v,$event:t});var C=i.attrGetter("ngfValidateAfterResize",x,k);var m=i.attrGetter("ngModelOptions",x,k);i.validate(q,u.length,s,x,k).then(function(){if(n){p(q,[],o,v,w)}else{if((!m||!m.allowInvalid)&&!C){B()}else{l=q}if(i.attrGetter("ngfFixOrientation",x,k)&&i.isExifSupported()){g(l,x,k).then(function(){E()})}else{E()}}})};return i}]);ngFileUpload.directive("ngfSelect",["$parse","$timeout","$compile","Upload",function(g,f,e,b){var d=[];function c(j){var h=j.match(/Android[^\d]*(\d+)\.(\d+)/);if(h&&h.length>2){var i=b.defaults.androidFixMinorVersion||4;return parseInt(h[1])<4||(parseInt(h[1])===i&&parseInt(h[2])<i)}return j.indexOf("Chrome")===-1&&/.*Windows.*Safari.*/.test(j)}function a(h,w,s,n,j,z,v,x){var k=function(C,D){return x.attrGetter(C,s,D)};function r(){return w[0].tagName.toLowerCase()==="input"&&s.type&&s.type.toLowerCase()==="file"}function A(){return k("ngfChange")||k("ngfSelect")}function i(C){if(x.shouldUpdateOn("change",s,h)){var D=C.__files_||(C.target&&C.target.files),F=[];for(var E=0;E<D.length;E++){F.push(D[E])}x.updateModel(n,s,h,A(),F.length?F:null,C)}}x.registerModelChangeValidator(n,s,h);var q=[];q.push(h.$watch(k("ngfMultiple"),function(){u.attr("multiple",k("ngfMultiple",h))}));q.push(h.$watch(k("ngfCapture"),function(){u.attr("capture",k("ngfCapture",h))}));q.push(h.$watch(k("ngfAccept"),function(){u.attr("accept",k("ngfAccept",h))}));s.$observe("accept",function(){u.attr("accept",k("accept"))});q.push(function(){if(s.$$observers){delete s.$$observers.accept}});function y(C){if(w!==C){for(var D=0;D<w[0].attributes.length;D++){var E=w[0].attributes[D];if(E.name!=="type"&&E.name!=="class"&&E.name!=="style"){if(E.value==null||E.value===""){if(E.name==="required"){E.value="required"}if(E.name==="multiple"){E.value="multiple"}}C.attr(E.name,E.name==="id"?"ngf-"+E.value:E.value)}}}}function l(){if(r()){return w}var C=angular.element('<input type="file">');y(C);var D=angular.element("<label>upload</label>");D.css("visibility","hidden").css("position","absolute").css("overflow","hidden").css("width","0px").css("height","0px").css("border","none").css("margin","0px").css("padding","0px").attr("tabindex","-1");d.push({el:w,ref:D});document.body.appendChild(D.append(C)[0]);return C}var o=0;function m(C){if(w.attr("disabled")){return false}if(k("ngfSelectDisabled",h)){return}var D=B(C);if(D!=null){return D}t(C);try{if(!r()&&!document.body.contains(u[0])){d.push({el:w,ref:u.parent()});document.body.appendChild(u.parent()[0]);u.bind("change",i)}}catch(E){}if(c(navigator.userAgent)){setTimeout(function(){u[0].click()},0)}else{u[0].click()}return false}function B(C){var E=C.changedTouches||(C.originalEvent&&C.originalEvent.changedTouches);if(C.type==="touchstart"){o=E?E[0].clientY:0;return true}else{C.stopPropagation();C.preventDefault();if(C.type==="touchend"){var D=E?E[0].clientY:0;if(Math.abs(D-o)>20){return false}}}}var u=w;function t(C){if(x.shouldUpdateOn("click",s,h)&&u.val()){u.val(null);x.updateModel(n,s,h,A(),null,C,true)}}if(!r()){u=l()}u.bind("change",i);if(!r()){w.bind("click touchstart touchend",m)}else{w.bind("click",t)}function p(C){if(u&&!u.attr("__ngf_ie10_Fix_")){if(!u[0].parentNode){u=null;return}C.preventDefault();C.stopPropagation();u.unbind("click");var D=u.clone();u.replaceWith(D);u=D;u.attr("__ngf_ie10_Fix_","true");u.bind("change",i);u.bind("click",p);u[0].click();return false}else{u.removeAttr("__ngf_ie10_Fix_")}}if(navigator.appVersion.indexOf("MSIE 10")!==-1){u.bind("click",p)}if(n){n.$formatters.push(function(C){if(C==null||C.length===0){if(u.val()){u.val(null)}}return C})}h.$on("$destroy",function(){if(!r()){u.parent().remove()}angular.forEach(q,function(C){C()})});z(function(){for(var C=0;C<d.length;C++){var D=d[C];if(!document.body.contains(D.el[0])){d.splice(C,1);D.ref.remove()}}});if(window.FileAPI&&window.FileAPI.ngfFixIE){window.FileAPI.ngfFixIE(w,u,i)}}return{restrict:"AEC",require:"?ngModel",link:function(i,j,h,k){a(i,j,h,k,g,f,e,b)}}}]);(function(){ngFileUpload.service("UploadDataUrl",["UploadBase","$timeout","$q",function(f,e,c){var d=f;d.base64DataUrl=function(g){if(angular.isArray(g)){var i=c.defer(),h=0;angular.forEach(g,function(j){d.dataUrl(j,true)["finally"](function(){h++;if(h===g.length){var k=[];angular.forEach(g,function(l){k.push(l.$ngfDataUrl)});i.resolve(k,g)}})});return i.promise}else{return d.dataUrl(g,true)}};d.dataUrl=function(h,i){if(!h){return d.emptyPromise(h,h)}if((i&&h.$ngfDataUrl!=null)||(!i&&h.$ngfBlobUrl!=null)){return d.emptyPromise(i?h.$ngfDataUrl:h.$ngfBlobUrl,h)}var j=i?h.$$ngfDataUrlPromise:h.$$ngfBlobUrlPromise;if(j){return j}var g=c.defer();e(function(){if(window.FileReader&&h&&(!window.FileAPI||navigator.userAgent.indexOf("MSIE 8")===-1||h.size<20000)&&(!window.FileAPI||navigator.userAgent.indexOf("MSIE 9")===-1||h.size<4000000)){var k=window.URL||window.webkitURL;if(k&&k.createObjectURL&&!i){var m;try{m=k.createObjectURL(h)}catch(n){e(function(){h.$ngfBlobUrl="";g.reject()});return}e(function(){h.$ngfBlobUrl=m;if(m){g.resolve(m,h);d.blobUrls=d.blobUrls||[];d.blobUrlsTotalSize=d.blobUrlsTotalSize||0;d.blobUrls.push({url:m,size:h.size});d.blobUrlsTotalSize+=h.size||0;var p=d.defaults.blobUrlsMaxMemory||268435456;var o=d.defaults.blobUrlsMaxQueueSize||200;while((d.blobUrlsTotalSize>p||d.blobUrls.length>o)&&d.blobUrls.length>1){var q=d.blobUrls.splice(0,1)[0];k.revokeObjectURL(q.url);d.blobUrlsTotalSize-=q.size}}})}else{var l=new FileReader();l.onload=function(o){e(function(){h.$ngfDataUrl=o.target.result;g.resolve(o.target.result,h);e(function(){delete h.$ngfDataUrl},1000)})};l.onerror=function(){e(function(){h.$ngfDataUrl="";g.reject()})};l.readAsDataURL(h)}}else{e(function(){h[i?"$ngfDataUrl":"$ngfBlobUrl"]="";g.reject()})}});if(i){j=h.$$ngfDataUrlPromise=g.promise}else{j=h.$$ngfBlobUrlPromise=g.promise}j["finally"](function(){delete h[i?"$$ngfDataUrlPromise":"$$ngfBlobUrlPromise"]});return j};return d}]);function b(c){if(c.tagName.toLowerCase()==="img"){return"image"}if(c.tagName.toLowerCase()==="audio"){return"audio"}if(c.tagName.toLowerCase()==="video"){return"video"}return/./}function a(e,c,k,d,h,f,g,i){function j(l){var m=e.attrGetter("ngfNoObjectUrl",h,k);e.dataUrl(l,m)["finally"](function(){c(function(){var n=(m?l.$ngfDataUrl:l.$ngfBlobUrl)||l.$ngfDataUrl;if(i){d.css("background-image","url('"+(n||"")+"')")}else{d.attr("src",n)}if(n){d.removeClass("ng-hide")}else{d.addClass("ng-hide")}})})}c(function(){var l=k.$watch(h[f],function(n){var m=g;if(f==="ngfThumbnail"){if(!m){m={width:d[0].clientWidth,height:d[0].clientHeight}}if(m.width===0&&window.getComputedStyle){var o=getComputedStyle(d[0]);m={width:parseInt(o.width.slice(0,-2)),height:parseInt(o.height.slice(0,-2))}}}if(angular.isString(n)){d.removeClass("ng-hide");if(i){return d.css("background-image","url('"+n+"')")}else{return d.attr("src",n)}}if(n&&n.type&&n.type.search(b(d[0]))===0&&(!i||n.type.indexOf("image")===0)){if(m&&e.isResizeSupported()){e.resize(n,m.width,m.height,m.quality).then(function(p){j(p)},function(p){throw p})}else{j(n)}}else{d.addClass("ng-hide")}});k.$on("$destroy",function(){l()})})}ngFileUpload.directive("ngfSrc",["Upload","$timeout",function(c,d){return{restrict:"AE",link:function(f,g,e){a(c,d,f,g,e,"ngfSrc",c.attrGetter("ngfResize",e,f),false)}}}]);ngFileUpload.directive("ngfBackground",["Upload","$timeout",function(c,d){return{restrict:"AE",link:function(f,g,e){a(c,d,f,g,e,"ngfBackground",c.attrGetter("ngfResize",e,f),true)}}}]);ngFileUpload.directive("ngfThumbnail",["Upload","$timeout",function(c,d){return{restrict:"AE",link:function(g,h,e){var f=c.attrGetter("ngfSize",e,g);a(c,d,g,h,e,"ngfThumbnail",f,c.attrGetter("ngfAsBackground",e,g))}}}]);ngFileUpload.config(["$compileProvider",function(c){if(c.imgSrcSanitizationWhitelist){c.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|local|file|data|blob):/)}if(c.aHrefSanitizationWhitelist){c.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|local|file|data|blob):/)}}]);ngFileUpload.filter("ngfDataUrl",["UploadDataUrl","$sce",function(d,c){return function(e,g,f){if(angular.isString(e)){return c.trustAsResourceUrl(e)}var h=e&&((g?e.$ngfDataUrl:e.$ngfBlobUrl)||e.$ngfDataUrl);if(e&&!h){if(!e.$ngfDataUrlFilterInProgress&&angular.isObject(e)){e.$ngfDataUrlFilterInProgress=true;d.dataUrl(e,g)}return""}if(e){delete e.$ngfDataUrlFilterInProgress}return(e&&h?(f?c.trustAsResourceUrl(h):h):e)||""}}])})();ngFileUpload.service("UploadValidate",["UploadDataUrl","$q","$timeout",function(f,a,c){var b=f;function e(l){var k="",m=[];if(l.length>2&&l[0]==="/"&&l[l.length-1]==="/"){k=l.substring(1,l.length-1)}else{var h=l.split(",");if(h.length>1){for(var g=0;g<h.length;g++){var j=e(h[g]);if(j.regexp){k+="("+j.regexp+")";if(g<h.length-1){k+="|"}}else{m=m.concat(j.excludes)}}}else{if(l.indexOf("!")===0){m.push("^((?!"+e(l.substring(1)).regexp+").)*$")}else{if(l.indexOf(".")===0){l="*"+l}k="^"+l.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&")+"$";k=k.replace(/\\\*/g,".*").replace(/\\\?/g,".")}}}return{regexp:k,excludes:m}}b.validatePattern=function(i,m){if(!m){return true}var l=e(m),j=true;if(l.regexp&&l.regexp.length){var k=new RegExp(l.regexp,"i");j=(i.type!=null&&k.test(i.type))||(i.name!=null&&k.test(i.name))}var g=l.excludes.length;while(g--){var h=new RegExp(l.excludes[g],"i");j=j&&(i.type==null||h.test(i.type))&&(i.name==null||h.test(i.name))}return j};b.ratioToFloat=function(i){var h=i.toString(),g=h.search(/[x:]/i);if(g>-1){h=parseFloat(h.substring(0,g))/parseFloat(h.substring(g+1))}else{h=parseFloat(h)}return h};b.registerModelChangeValidator=function(i,g,h){if(i){i.$formatters.push(function(j){if(i.$dirty){if(j&&!angular.isArray(j)){j=[j]}b.validate(j,0,i,g,h).then(function(){b.applyModelValidation(i,j)})}})}};function d(h,g){if(g!=null&&!h.$dirty){if(h.$setDirty){h.$setDirty()}else{h.$dirty=true}}}b.applyModelValidation=function(h,g){d(h,g);angular.forEach(h.$ngfValidations,function(i){h.$setValidity(i.name,i.valid)})};b.getValidationAttr=function(g,k,h,n,j){var l="ngf"+h[0].toUpperCase()+h.substr(1);var m=b.attrGetter(l,g,k,{$file:j});if(m==null){m=b.attrGetter("ngfValidate",g,k,{$file:j});if(m){var i=(n||h).split(".");m=m[i[0]];if(i.length>1){m=m&&m[i[1]]}}}return m};b.validate=function(g,k,i,l,q){i=i||{};i.$ngfValidations=i.$ngfValidations||[];angular.forEach(i.$ngfValidations,function(r){r.valid=true});var o=function(r,s){return b.attrGetter(r,l,q,s)};if(g==null||g.length===0){return b.emptyPromise(i)}g=g.length===undefined?[g]:g.slice(0);function j(r,x,u){if(g){var t=g.length,v=null;while(t--){var s=g[t];if(s){var w=b.getValidationAttr(l,q,r,x,s);if(w!=null){if(!u(s,w,t)){s.$error=r;(s.$errorMessages=(s.$errorMessages||{}))[r]=true;s.$errorParam=w;g.splice(t,1);v=false}}}}if(v!==null){i.$ngfValidations.push({name:r,valid:v})}}}j("maxFiles",null,function(s,t,r){return k+r<t});j("pattern",null,b.validatePattern);j("minSize","size.min",function(r,s){return r.size+0.1>=b.translateScalars(s)});j("maxSize","size.max",function(r,s){return r.size-0.1<=b.translateScalars(s)});var p=0;j("maxTotalSize",null,function(r,s){p+=r.size;if(p>b.translateScalars(s)){g.splice(0,g.length);return false}return true});j("validateFn",null,function(s,t){return t===true||t===null||t===""});if(!g.length){return b.emptyPromise(i,i.$ngfValidations)}function n(s,x,v,r,u){function w(A,y,z){if(z!=null){r(y,z).then(function(B){if(!u(B,z)){y.$error=s;(y.$errorMessages=(y.$errorMessages||{}))[s]=true;y.$errorParam=z;A.reject()}else{A.resolve()}},function(){if(o("ngfValidateForce",{$file:y})){y.$error=s;(y.$errorMessages=(y.$errorMessages||{}))[s]=true;y.$errorParam=z;A.reject()}else{A.resolve()}})}else{A.resolve()}}var t=[b.emptyPromise()];if(g){g=g.length===undefined?[g]:g;angular.forEach(g,function(y){var z=a.defer();t.push(z.promise);if(v&&(y.type==null||y.type.search(v)!==0)){z.resolve();return}if(s==="dimensions"&&b.attrGetter("ngfDimensions",l)!=null){b.imageDimensions(y).then(function(A){w(z,y,o("ngfDimensions",{$file:y,$width:A.width,$height:A.height}))},function(){z.reject()})}else{if(s==="duration"&&b.attrGetter("ngfDuration",l)!=null){b.mediaDuration(y).then(function(A){w(z,y,o("ngfDuration",{$file:y,$duration:A}))},function(){z.reject()})}else{w(z,y,b.getValidationAttr(l,q,s,x,y))}}});return a.all(t).then(function(){i.$ngfValidations.push({name:s,valid:true})},function(){i.$ngfValidations.push({name:s,valid:false})})}}var h=a.defer();var m=[];m.push(b.happyPromise(n("maxHeight","height.max",/image/,this.imageDimensions,function(s,r){return s.height<=r})));m.push(b.happyPromise(n("minHeight","height.min",/image/,this.imageDimensions,function(s,r){return s.height>=r})));m.push(b.happyPromise(n("maxWidth","width.max",/image/,this.imageDimensions,function(s,r){return s.width<=r})));m.push(b.happyPromise(n("minWidth","width.min",/image/,this.imageDimensions,function(s,r){return s.width>=r})));m.push(b.happyPromise(n("dimensions",null,/image/,function(r,s){return b.emptyPromise(s)},function(s){return s})));m.push(b.happyPromise(n("ratio",null,/image/,this.imageDimensions,function(v,u){var s=u.toString().split(","),t=false;for(var r=0;r<s.length;r++){if(Math.abs((v.width/v.height)-b.ratioToFloat(s[r]))<0.0001){t=true}}return t})));m.push(b.happyPromise(n("maxRatio","ratio.max",/image/,this.imageDimensions,function(s,r){return(s.width/s.height)-b.ratioToFloat(r)<0.0001})));m.push(b.happyPromise(n("minRatio","ratio.min",/image/,this.imageDimensions,function(s,r){return(s.width/s.height)-b.ratioToFloat(r)>-0.0001})));m.push(b.happyPromise(n("maxDuration","duration.max",/audio|video/,this.mediaDuration,function(s,r){return s<=b.translateScalars(r)})));m.push(b.happyPromise(n("minDuration","duration.min",/audio|video/,this.mediaDuration,function(s,r){return s>=b.translateScalars(r)})));m.push(b.happyPromise(n("duration",null,/audio|video/,function(r,s){return b.emptyPromise(s)},function(s){return s})));m.push(b.happyPromise(n("validateAsyncFn",null,null,function(r,s){return s},function(s){return s===true||s===null||s===""})));return a.all(m).then(function(){h.resolve(i,i.$ngfValidations)})};b.imageDimensions=function(h){if(h.$ngfWidth&&h.$ngfHeight){var i=a.defer();c(function(){i.resolve({width:h.$ngfWidth,height:h.$ngfHeight})});return i.promise}if(h.$ngfDimensionPromise){return h.$ngfDimensionPromise}var g=a.defer();c(function(){if(h.type.indexOf("image")!==0){g.reject("not image");return}b.dataUrl(h).then(function(n){var j=angular.element("<img>").attr("src",n).css("visibility","hidden").css("position","fixed").css("max-width","none !important").css("max-height","none !important");function o(){var q=j[0].clientWidth;var p=j[0].clientHeight;j.remove();h.$ngfWidth=q;h.$ngfHeight=p;g.resolve({width:q,height:p})}function k(){j.remove();g.reject("load error")}j.on("load",o);j.on("error",k);var m=0;function l(){c(function(){if(j[0].parentNode){if(j[0].clientWidth){o()}else{if(m>10){k()}else{l()}}}},1000)}l();angular.element(document.getElementsByTagName("body")[0]).append(j)},function(){g.reject("load error")})});h.$ngfDimensionPromise=g.promise;h.$ngfDimensionPromise["finally"](function(){delete h.$ngfDimensionPromise});return h.$ngfDimensionPromise};b.mediaDuration=function(h){if(h.$ngfDuration){var i=a.defer();c(function(){i.resolve(h.$ngfDuration)});return i.promise}if(h.$ngfDurationPromise){return h.$ngfDurationPromise}var g=a.defer();c(function(){if(h.type.indexOf("audio")!==0&&h.type.indexOf("video")!==0){g.reject("not media");return}b.dataUrl(h).then(function(n){var l=angular.element(h.type.indexOf("audio")===0?"<audio>":"<video>").attr("src",n).css("visibility","none").css("position","fixed");function o(){var p=l[0].duration;h.$ngfDuration=p;l.remove();g.resolve(p)}function j(){l.remove();g.reject("load error")}l.on("loadedmetadata",o);l.on("error",j);var m=0;function k(){c(function(){if(l[0].parentNode){if(l[0].duration){o()}else{if(m>10){j()}else{k()}}}},1000)}k();angular.element(document.body).append(l)},function(){g.reject("load error")})});h.$ngfDurationPromise=g.promise;h.$ngfDurationPromise["finally"](function(){delete h.$ngfDurationPromise});return h.$ngfDurationPromise};return b}]);ngFileUpload.service("UploadResize",["UploadValidate","$q",function(d,a){var c=d;var e=function(i,f,k,j,h){var g=h?Math.max(k/i,j/f):Math.min(k/i,j/f);return{width:i*g,height:f*g,marginX:i*g-k,marginY:f*g-j}};var b=function(n,f,o,m,k,h,g,j){var p=a.defer();var l=document.createElement("canvas");var i=document.createElement("img");i.onload=function(){if(j!=null&&j(i.width,i.height)===false){p.reject("resizeIf");return}try{if(h){var u=c.ratioToFloat(h);var q=i.width/i.height;if(q<u){f=i.width;o=f/u}else{o=i.height;f=o*u}}if(!f){f=i.width}if(!o){o=i.height}var s=e(i.width,i.height,f,o,g);l.width=Math.min(s.width,f);l.height=Math.min(s.height,o);var r=l.getContext("2d");r.drawImage(i,Math.min(0,-s.marginX/2),Math.min(0,-s.marginY/2),s.width,s.height);p.resolve(l.toDataURL(k||"image/WebP",m||0.934))}catch(t){p.reject(t)}};i.onerror=function(){p.reject()};i.src=n;return p.promise};c.dataUrltoBlob=function(m,h,k){var l=m.split(","),g=l[0].match(/:(.*?);/)[1],i=atob(l[1]),j=i.length,o=new Uint8Array(j);while(j--){o[j]=i.charCodeAt(j)}var f=new window.Blob([o],{type:g});f.name=h;f.$ngfOrigSize=k;return f};c.isResizeSupported=function(){var f=document.createElement("canvas");return window.atob&&f.getContext&&f.getContext("2d")&&window.Blob};if(c.isResizeSupported()){Object.defineProperty(window.Blob.prototype,"name",{get:function(){return this.$ngfName},set:function(f){this.$ngfName=f},configurable:true})}c.resize=function(h,f,n,m,l,j,i,k,g){if(h.type.indexOf("image")!==0){return c.emptyPromise(h)}var o=a.defer();c.dataUrl(h,true).then(function(p){b(p,f,n,m,l||h.type,j,i,k).then(function(s){if(h.type==="image/jpeg"&&g){try{s=c.restoreExif(p,s)}catch(r){setTimeout(function(){throw r},1)}}try{var q=c.dataUrltoBlob(s,h.name,h.size);o.resolve(q)}catch(r){o.reject(r)}},function(q){if(q==="resizeIf"){o.resolve(h)}o.reject(q)})},function(p){o.reject(p)});return o.promise};return c}]);(function(){ngFileUpload.directive("ngfDrop",["$parse","$timeout","$location","Upload","$http","$q",function(f,e,h,d,g,c){return{restrict:"AEC",require:"?ngModel",link:function(j,k,i,l){b(j,k,i,l,f,e,h,d,g,c)}}}]);ngFileUpload.directive("ngfNoFileDrop",function(){return function(c,d){if(a()){d.css("display","none")}}});ngFileUpload.directive("ngfDropAvailable",["$parse","$timeout","Upload",function(e,d,c){return function(h,i,f){if(a()){var g=e(c.attrGetter("ngfDropAvailable",f));d(function(){g(h);if(g.assign){g.assign(h,true)}})}}}]);function b(d,r,n,j,e,v,h,s,w,q){var m=a();var g=function(x,y,z){return s.attrGetter(x,n,y,z)};if(g("dropAvailable")){v(function(){if(d[g("dropAvailable")]){d[g("dropAvailable")].value=m}else{d[g("dropAvailable")]=m}})}if(!m){if(g("ngfHideOnDropNotAvailable",d)===true){r.css("display","none")}return}function k(){return r.attr("disabled")||g("ngfDropDisabled",d)}if(g("ngfSelect")==null){s.registerModelChangeValidator(j,n,d)}var u=null;var i=e(g("ngfStopPropagation"));var f=1;var p;r[0].addEventListener("dragover",function(y){if(k()||!s.shouldUpdateOn("drop",n,d)){return}y.preventDefault();if(i(d)){y.stopPropagation()}if(navigator.userAgent.indexOf("Chrome")>-1){var x=y.dataTransfer.effectAllowed;y.dataTransfer.dropEffect=("move"===x||"linkMove"===x)?"move":"copy"}v.cancel(u);if(!p){p="C";l(d,n,y,function(z){p=z;r.addClass(p);g("ngfDrag",d,{$isDragging:true,$class:p,$event:y})})}},false);r[0].addEventListener("dragenter",function(x){if(k()||!s.shouldUpdateOn("drop",n,d)){return}x.preventDefault();if(i(d)){x.stopPropagation()}},false);r[0].addEventListener("dragleave",function(x){if(k()||!s.shouldUpdateOn("drop",n,d)){return}x.preventDefault();if(i(d)){x.stopPropagation()}u=v(function(){if(p){r.removeClass(p)}p=null;g("ngfDrag",d,{$isDragging:false,$event:x})},f||100)},false);r[0].addEventListener("drop",function(x){if(k()||!s.shouldUpdateOn("drop",n,d)){return}x.preventDefault();if(i(d)){x.stopPropagation()}if(p){r.removeClass(p)}p=null;var y=x.dataTransfer.items;var z;try{z=x.dataTransfer&&x.dataTransfer.getData&&x.dataTransfer.getData("text/html")}catch(A){}t(y,x.dataTransfer.files,g("ngfAllowDir",d)!==false,g("multiple")||g("ngfMultiple",d)).then(function(B){if(B.length){c(B,x)}else{o("dropUrl",z).then(function(C){c(C,x)})}})},false);r[0].addEventListener("paste",function(x){if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&g("ngfEnableFirefoxPaste",d)){x.preventDefault()}if(k()||!s.shouldUpdateOn("paste",n,d)){return}var z=[];var A=x.clipboardData||x.originalEvent.clipboardData;if(A&&A.items){for(var y=0;y<A.items.length;y++){if(A.items[y].type.indexOf("image")!==-1){z.push(A.items[y].getAsFile())}}}if(z.length){c(z,x)}else{o("pasteUrl",A).then(function(B){c(B,x)})}},false);if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&g("ngfEnableFirefoxPaste",d)){r.attr("contenteditable",true);r.on("keypress",function(x){if(!x.metaKey&&!x.ctrlKey){x.preventDefault()}})}function c(y,x){s.updateModel(j,n,d,g("ngfChange")||g("ngfDrop"),y,x)}function o(A,y){if(!s.shouldUpdateOn(A,n,d)||!y){return s.rejectPromise([])}var B=[];y.replace(/<(img src|img [^>]* src) *=\"([^\"]*)\"/gi,function(D,F,E){B.push(E)});var x=[],z=[];if(B.length){angular.forEach(B,function(D){x.push(s.urlToBlob(D).then(function(E){z.push(E)}))});var C=q.defer();q.all(x).then(function(){C.resolve(z)},function(D){C.reject(D)});return C.promise}return s.emptyPromise()}function l(F,z,D,E){var x=g("ngfDragOverClass",F,{$event:D}),C="dragover";if(angular.isString(x)){C=x}else{if(x){if(x.delay){f=x.delay}if(x.accept||x.reject){var B=D.dataTransfer.items;if(B==null||!B.length){C=x.accept}else{var A=x.pattern||g("ngfPattern",F,{$event:D});var y=B.length;while(y--){if(!s.validatePattern(B[y],A)){C=x.reject;break}else{C=x.accept}}}}}}E(C)}function t(F,M,K,N){var L=s.getValidationAttr(n,d,"maxFiles")||Number.MAX_VALUE;var E=s.getValidationAttr(n,d,"maxTotalSize")||Number.MAX_VALUE;var G=g("ngfIncludeDir",d);var y=[],J=0;function C(T,U){var V=q.defer();if(T!=null){if(T.isDirectory){var S=[s.emptyPromise()];if(G){var R={type:"directory"};R.name=R.path=(U||"")+T.name+T.name;y.push(R)}var Q=T.createReader();var O=[];var P=function(){Q.readEntries(function(W){try{if(!W.length){angular.forEach(O.slice(0),function(Y){if(y.length<=L&&J<=E){S.push(C(Y,(U?U:"")+T.name+"/"))}});q.all(S).then(function(){V.resolve()},function(Y){V.reject(Y)})}else{O=O.concat(Array.prototype.slice.call(W||[],0));P()}}catch(X){V.reject(X)}},function(W){V.reject(W)})};P()}else{T.file(function(W){try{W.path=(U?U:"")+W.name;if(G){W=s.rename(W,W.path)}y.push(W);J+=W.size;V.resolve()}catch(X){V.reject(X)}},function(W){V.reject(W)})}}return V.promise}var H=[s.emptyPromise()];if(F&&F.length>0&&h.protocol()!=="file"){for(var B=0;B<F.length;B++){if(F[B].webkitGetAsEntry&&F[B].webkitGetAsEntry()&&F[B].webkitGetAsEntry().isDirectory){var I=F[B].webkitGetAsEntry();if(I.isDirectory&&!K){continue}if(I!=null){H.push(C(I))}}else{var D=F[B].getAsFile();if(D!=null){y.push(D);J+=D.size}}if(y.length>L||J>E||(!N&&y.length>0)){break}}}else{if(M!=null){for(var A=0;A<M.length;A++){var z=M.item(A);if(z.type||z.size>0){y.push(z);J+=z.size}if(y.length>L||J>E||(!N&&y.length>0)){break}}}}var x=q.defer();q.all(H).then(function(){if(!N&&!G&&y.length){var O=0;while(y[O]&&y[O].type==="directory"){O++}x.resolve([y[O]])}else{x.resolve(y)}},function(O){x.reject(O)});return x.promise}}function a(){var c=document.createElement("div");return("draggable" in c)&&("ondrop" in c)&&!/Edge\/12./i.test(navigator.userAgent)}})();ngFileUpload.service("UploadExif",["UploadResize","$q",function(e,c){var d=e;d.isExifSupported=function(){return window.FileReader&&new FileReader().readAsArrayBuffer&&d.isResizeSupported()};function b(g,h,i,f){switch(h){case 2:return g.transform(-1,0,0,1,i,0);case 3:return g.transform(-1,0,0,-1,i,f);case 4:return g.transform(1,0,0,-1,0,f);case 5:return g.transform(0,1,1,0,0,0);case 6:return g.transform(0,1,-1,0,f,0);case 7:return g.transform(0,-1,-1,0,f,i);case 8:return g.transform(0,-1,1,0,0,i)}}d.readOrientation=function(h){var i=c.defer();var f=new FileReader();var g=h.slice?h.slice(0,64*1024):h;f.readAsArrayBuffer(g);f.onerror=function(j){return i.reject(j)};f.onload=function(o){var s={orientation:1};var p=new DataView(this.result);if(p.getUint16(0,false)!==65496){return i.resolve(s)}var k=p.byteLength,l=2;while(l<k){var n=p.getUint16(l,false);l+=2;if(n===65505){if(p.getUint32(l+=2,false)!==1165519206){return i.resolve(s)}var r=p.getUint16(l+=6,false)===18761;l+=p.getUint32(l+4,r);var q=p.getUint16(l,r);l+=2;for(var m=0;m<q;m++){if(p.getUint16(l+(m*12),r)===274){var j=p.getUint16(l+(m*12)+8,r);if(j>=2&&j<=8){p.setUint16(l+(m*12)+8,1,r);s.fixedArrayBuffer=o.target.result}s.orientation=j;return i.resolve(s)}}}else{if((n&65280)!==65280){break}else{l+=p.getUint16(l,false)}}}return i.resolve(s)};return i.promise};function a(h){var k="";var g=new Uint8Array(h);var f=g.byteLength;for(var j=0;j<f;j++){k+=String.fromCharCode(g[j])}return window.btoa(k)}d.applyExifRotation=function(g){if(g.type.indexOf("image/jpeg")!==0){return d.emptyPromise(g)}var f=c.defer();d.readOrientation(g).then(function(h){if(h.orientation<2||h.orientation>8){return f.resolve(g)}d.dataUrl(g,true).then(function(k){var j=document.createElement("canvas");var i=document.createElement("img");i.onload=function(){try{j.width=h.orientation>4?i.height:i.width;j.height=h.orientation>4?i.width:i.height;var l=j.getContext("2d");b(l,h.orientation,i.width,i.height);l.drawImage(i,0,0);var o=j.toDataURL(g.type||"image/WebP",0.934);o=d.restoreExif(a(h.fixedArrayBuffer),o);var m=d.dataUrltoBlob(o,g.name);f.resolve(m)}catch(n){return f.reject(n)}};i.onerror=function(){f.reject()};i.src=k},function(i){f.reject(i)})},function(h){f.reject(h)});return f.promise};d.restoreExif=function(h,g){var f={};f.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";f.encode64=function(l){var j="",s,q,o="",r,p,n,m="",k=0;do{s=l[k++];q=l[k++];o=l[k++];r=s>>2;p=((s&3)<<4)|(q>>4);n=((q&15)<<2)|(o>>6);m=o&63;if(isNaN(q)){n=m=64}else{if(isNaN(o)){m=64}}j=j+this.KEY_STR.charAt(r)+this.KEY_STR.charAt(p)+this.KEY_STR.charAt(n)+this.KEY_STR.charAt(m);s=q=o="";r=p=n=m=""}while(k<l.length);return j};f.restore=function(i,m){if(i.match("data:image/jpeg;base64,")){i=i.replace("data:image/jpeg;base64,","")}var l=this.decode64(i);var j=this.slice2Segments(l);var k=this.exifManipulation(m,j);return"data:image/jpeg;base64,"+this.encode64(k)};f.exifManipulation=function(l,k){var i=this.getExifArray(k),j=this.insertExif(l,i);return new Uint8Array(j)};f.getExifArray=function(k){var j;for(var i=0;i<k.length;i++){j=k[i];if(j[0]===255&j[1]===225){return j}}return[]};f.insertExif=function(p,i){var o=p.replace("data:image/jpeg;base64,",""),k=this.decode64(o),j=k.indexOf(255,3),m=k.slice(0,j),l=k.slice(j),n=m;n=n.concat(i);n=n.concat(l);return n};f.slice2Segments=function(j){var m=0,k=[];while(1){if(j[m]===255&j[m+1]===218){break}if(j[m]===255&j[m+1]===216){m+=2}else{var n=j[m+2]*256+j[m+3],l=m+n+2,i=j.slice(m,l);k.push(i);m=l}if(m>j.length){break}}return k};f.decode64=function(m){var t,r,p="",s,q,o,n="",l=0,k=[];var j=/[^A-Za-z0-9\+\/\=]/g;if(j.exec(m)){console.log("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, , "/',and "="\nExpect errors in decoding.')}m=m.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{s=this.KEY_STR.indexOf(m.charAt(l++));q=this.KEY_STR.indexOf(m.charAt(l++));o=this.KEY_STR.indexOf(m.charAt(l++));n=this.KEY_STR.indexOf(m.charAt(l++));t=(s<<2)|(q>>4);r=((q&15)<<4)|(o>>2);p=((o&3)<<6)|n;k.push(t);if(o!==64){k.push(r)}if(n!==64){k.push(p)}t=r=p="";s=q=o=n=""}while(l<m.length);return k};return f.restore(h,g)};return d}]);
|