// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/Evented dojo/_base/declare dojo/has dojo/_base/lang jimu/utils jimu/dijit/Message".split(" "),function(h,e,c,f,k,g){return e([h],{declaredClass:"readJSON",config:null,jsonFile:null,constructor:function(a){e.safeMixin(this,a)},checkFileReader:function(){this.supportHTML5()?(console.log("HTML 5 loader"),this._processFiles(this.jsonFile)):this.supportHTML5()||c("safari")||!this.isEnabledFlash()?console.log("no loader"):k.file.loadFileAPI().then(f.hitch(this,function(){console.log("loading FileAPI")}))},
_processFiles:function(a){0<a.length&&(a=a[0],-1!==a.name.indexOf(".json")?a&&this.handleJson(a):new g({message:"Not a json file"}))},handleJson:function(a){if(this.supportHTML5()){var b=new FileReader;b.onload=function(d){return function(){-1<b.result.indexOf("groups")?d.completePrompt(b.result):(new g({message:"json file is Invalid"}),d.errorPrompt("error"))}}(this);b.readAsText(a)}else window.FileAPI.readAsText(a,f.hitch(this,function(d){}))},supportHTML5:function(){return window.File&&window.FileReader&&
window.FileList&&window.Blob?!0:!1},supportFileAPI:function(){return c("safari")&&6>c("safari")?!1:window.FileAPI&&window.FileAPI.readAsDataURL?!0:!1},isEnabledFlash:function(){var a=null;if(document.all)try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(b){a=null}else navigator.plugins&&0<navigator.plugins.length&&(a=navigator.plugins["Shockwave Flash"]);return!!a},completePrompt:function(a){this.emit("complete",{UserSettings:a})},errorPrompt:function(){this.emit("error",{UserSettings:"error"})}})});