// 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/FileUtil",["dojo/sniff"],function(l){function v(){return!l("safari")||7<=l("safari")}var f={},p=p||"undefined"!==typeof navigator&&navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator)||function(a){if("undefined"===typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var f=a.document||document,h=f.createElementNS("http://www.w3.org/1999/xhtml","a"),l="download"in h,p=function(c){var e=f.createEvent("MouseEvents");e.initMouseEvent("click",
!0,!1,a,0,0,0,0,0,!1,!1,!1,!1,0,null);c.dispatchEvent(e)},r=a.webkitRequestFileSystem,w=a.requestFileSystem||r||a.mozRequestFileSystem,A=function(c){(a.setImmediate||a.setTimeout)(function(){throw c;},0)},x=0,t=function(c){var e=function(){"string"===typeof c?(a.URL||a.webkitURL||a).revokeObjectURL(c):c.remove()};a.chrome?e():setTimeout(e,10)},u=function(a,e,d){e=[].concat(e);for(var c=e.length;c--;){var b=a["on"+e[c]];if("function"===typeof b)try{b.call(a,d||a)}catch(g){A(g)}}},n=function(c,e){var d=
this,b=c.type,f=!1,g,q,n=function(){u(d,["writestart","progress","write","writeend"])},k=function(){if(f||!g)g=(a.URL||a.webkitURL||a).createObjectURL(c);q?q.location.href=g:void 0===a.open(g,"_blank")&&"undefined"!==typeof safari&&(a.location.href=g);d.readyState=d.DONE;n();t(g)},m=function(a){return function(){if(d.readyState!==d.DONE)return a.apply(this,arguments)}},y={create:!0,exclusive:!1},z;if(v())if(d.readyState=d.INIT,e||(e="download"),l)g=(a.URL||a.webkitURL||a).createObjectURL(c),h.href=
g,h.download=e,h.target="_blank",p(h),d.readyState=d.DONE,n(),t(g);else{a.chrome&&b&&"application/octet-stream"!==b&&(z=c.slice||c.webkitSlice,c=z.call(c,0,c.size,"application/octet-stream"),f=!0);r&&"download"!==e&&(e+=".download");if("application/octet-stream"===b||r)q=a;w?(x+=c.size,w(a.TEMPORARY,x,m(function(a){a.root.getDirectory("saved",y,m(function(a){var b=function(){a.getFile(e,y,m(function(a){a.createWriter(m(function(b){b.onwriteend=function(b){q.location.href=a.toURL();d.readyState=d.DONE;
u(d,"writeend",b);t(a)};b.onerror=function(){var a=b.error;a.code!==a.ABORT_ERR&&k()};["writestart","progress","write","abort"].forEach(function(a){b["on"+a]=d["on"+a]});b.write(c);d.abort=function(){b.abort();d.readyState=d.DONE};d.readyState=d.WRITING}),k)}),k)};a.getFile(e,{create:!1},m(function(a){a.remove();b()}),m(function(a){a.code===a.NOT_FOUND_ERR?b():k()}))}),k)}),k)):k()}else alert("The File APIs are not fully supported in this browser.")},b=n.prototype;b.abort=function(){this.readyState=
this.DONE;u(this,"abort")};b.readyState=b.INIT=0;b.WRITING=1;b.DONE=2;b.error=b.onwritestart=b.onprogress=b.onwrite=b.onabort=b.onerror=b.onwriteend=null;return function(a,b){return new n(a,b)}}}(window);f.saveAs=p;f.savingSupported=v;f.saveTextFile=function(a,l,h){f.saveAs(new Blob([a],{type:h||"text/plain"}),l||"text.txt")};return f});