// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/utils/DataUtil",["dojo/Deferred","dojo/when"],function(l,q){function m(a){return"string"==typeof a?{source:a,getLength:function(){return this.source.length},getByte:function(a){return this.source.charCodeAt(a)&255}}:window.ArrayBuffer&&a instanceof ArrayBuffer?{source:new Uint8Array(a),getLength:function(){return this.source.byteLength},getByte:function(a){return this.source[a]}}:a}function n(a){for(var b=a.length,c=new Uint8Array(a.length),d=0;d<b;d++)c[d]=a.charCodeAt(d);
return c}function p(a,b){var c=new Uint8Array(a);b=Math.min(b,c.byteLength);for(var d="",e=0;e<b;e++)d+=String.fromCharCode(c[e]);return d}var g={arrayBufferFromBlob:function(a){var b=new l,c=new FileReader;c.onloadend=function(){c.error?b.reject(c.error):b.resolve(c.result)};c.readAsArrayBuffer(a);return b.promise},arrayBuffersToBlob:function(a,b){return new Blob(a,{type:b||"application/octet-stream"})},binaryStringFromByteSource:function(a){if("string"==typeof a)return a;a=m(a);for(var b=a.getLength(),
c=b%4,b=b-c,d="",e=0,g,f,k,h;e<b;)g=a.getByte(e++),f=a.getByte(e++),k=a.getByte(e++),h=a.getByte(e++),d+=String.fromCharCode(g,f,k,h);1==c?d+=String.fromCharCode(a.getByte(e)):2==c?d+=String.fromCharCode(a.getByte(e),a.getByte(e+1)):3==c&&(d+=String.fromCharCode(a.getByte(e),a.getByte(e+1),a.getByte(e+2)));return d},base64FromByteSource:function(a){a=m(a);for(var b=a.getLength(),c=b%3,b=b-c,d,e,g,f,k="",h=0;h<b;h+=3)f=a.getByte(h)<<16|a.getByte(h+1)<<8|a.getByte(h+2),d=f>>18&63,e=f>>12&63,g=f>>6&
63,f&=63,k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f];1==c?(f=a.getByte(h),k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f>>2&63]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f<<4&63]+"\x3d\x3d"):2==c&&(f=a.getByte(h)<<
8|a.getByte(h+1),k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f>>10&63]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f>>4&63]+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f<<2&63]+"\x3d");return k}};g.binaryStringToByteArray=n;g.base64ToByteArray=function(a){return n(atob(a))};g.getFirstBytes=function(a,b){var c;if("string"==typeof a)c=a.substr(0,b);else if(window.ArrayBuffer&&a instanceof ArrayBuffer)c=p(a,b);else if(window.Blob&&
a instanceof Blob){c=new l;var d=new FileReader;d.onloadend=function(){d.error?c.resolve(""):c.resolve(p(d.result,b))};d.readAsArrayBuffer(a.slice(0,b))}return q(c||"")};g.isBase64=function(a){return a&&0==a.length%4&&/^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/]+$/.test(a.replace(/={0,2}$/,""))};g.getContentType=function(a){var b=a.lastIndexOf(".")+1;if(!b)return null;switch(a.substr(b).toLowerCase()){case "png":return"image/png";case "jpg":case "jpeg":return"image/jpeg";
case "gif":return"image/gif";case "json":return"application/json";case "txt":return"text/plain";case "xml":return"text/xml";default:return null}};return g});