// 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/requests/FileContent",["dojo/_base/declare","esri/dijit/geoenrichment/utils/DataUtil"],function(h,d){function f(b){return b?/^image\//.test(b)?"base64":/^text\//.test(b)?"text":/application\/json/.test(b)?"json":"bin":"bin"}var c=h(null,{data:null,filename:null,contentType:"application/octet-stream",contentTransferEncoding:"binary",constructor:function(b,a,c){this.data=b;a&&(this.contentType=a);c&&(this.contentTransferEncoding=c)},getBase64Data:function(){return this.data?
"base64"==this.contentTransferEncoding?this.data:d.base64FromByteSource(this.data):null},toString:function(){return this.filename||"\x3cunknown\x3e"}});c.fromArrayBuffer=function(b,a){return new c(d.binaryStringFromByteSource(b),a)};c.fromBlob=function(b){return d.arrayBufferFromBlob(b).then(function(a){return new c(d.binaryStringFromByteSource(a),b.type)})};c.fromFileData=function(b,a,e){e=e||d.getContentType(b);if("object"==typeof a&&window.ArrayBuffer&&(a instanceof ArrayBuffer||a.buffer instanceof
ArrayBuffer))a=d.binaryStringFromByteSource(a.buffer||a);else{var g=f(e);"json"==g&&"object"==typeof a&&(a=JSON.stringify(a));if("string"!=typeof a)throw Error("Wrong file data.");switch(g){case "base64":a=atob(a);break;case "text":case "json":a=unescape(encodeURIComponent(a))}}a=new c(a,e);a.filename=b;return a};c.getContentConversionType=f;return c});