// 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/ReportPlayer/dataProviders/_SerializationSupport","dojo/_base/declare dojo/_base/lang dojo/Deferred dojo/when dojo/promise/all ./supportClasses/AnalysisAreaJsonUtil ./supportClasses/AreasPreprocessor ./supportClasses/ReportDataProcessor ./supportClasses/attachments/AttributesUtil ./supportClasses/attachments/NotesUtil ../core/supportClasses/templateJsonUtils/TemplateJsonSerializer ../core/conversion/PortalToEditorConverter ../core/themes/ThemeLibrary ../core/themes/ReportThemes ../core/infographics/dataDrilling/EnrichUtil ../core/infographics/infographicUtils/InfographicJsonUtil".split(" "),
function(u,l,v,e,d,m,y,z,n,p,q,A,B,C,w,r){var t={getAttachmentsStoreJson:function(a){return a?d([a.getAttachments(),a.getAttributes(),a.getNotes()]).then(function(a){var c=a[0]||[],b=a[1]||[],k=a[2]||[];return d(c.map(function(a){return d([a.getThumbnail(),a.getAttachmentUrl()]).then(function(c){a.__thumbnail=c[0];a.__url=c[1]})})).then(function(){return{attachments:c.map(function(a){var c=a.__thumbnail,b=a.__url;delete a.__thumbnail;delete a.__url;return{description:a.description,thumbnail:c,url:b}}),
attributes:b.map(function(a){return n.attributeToJson(a)}),notes:k.map(function(a){return p.noteToJson(a)})}})}):null},getAttachmentsStoreFromJson:function(a){if(!a)return null;var b=a.attributes||[],b=b.map(n.attributeFromJson),c=a.notes||[],c=c.map(p.noteFromJson);return{getAttachments:function(){return a.attachments?a.attachments.map(function(a){return{description:a.description,getThumbnail:function(){return a.thumbnail},getAttachmentUrl:function(){return a.url}}}):[]},getAttributes:function(){return b},
getNotes:function(){return c}}}};return u(null,{reportDataToJson:function(a,b){b=b||{};return e(b.allowDataDrilling&&this._serializeDataDrilling(a),function(){return e(t.getAttachmentsStoreJson(a.attachmentsStore),function(c){var d=l.mixin({},a.config);!1!==b.forceFixedDataMode&&(d.geoenrichmentUrl="");var k=a.isClassic,e=a.reportType,x=a.reportTitle,h=q.serialize(a.templateJson),f={},g;for(g in a.reportObject)a.reportObject[g]&&"object"!==typeof a.reportObject[g]&&(f[g]=a.reportObject[g]);c={isClassic:k,
reportType:e,reportTitle:x,templateJson:h,reportObject:f,fieldData:a.fieldData,analysisAreas:m.areasToJson(a.analysisAreas),infographicOptions:a.infographicOptions&&a.infographicOptions.toJson(),attachmentsStore:c,config:d,mapImageInfos:b.mapImageInfos};console.log("_SerializationSupport.js \x3d\x3e reportDataJson");console.log(c);return c})})},_serializeDataDrilling:function(a){var b=w.getEnrichInfosForTemplateJson(a.infographicOptions.countryID,a.templateJson),c=[];c.push(this.enrichFieldData(b,
l.mixin({analysisAreas:a.analysisAreas,fieldData:a.fieldData},a.config)));c.push(this._enrichInfographicVariables(a,b));return d(c)},_enrichInfographicVariables:function(a,b){var c=a.infographicOptions;return e(c.getOptions().getItems(c.countryID),function(){var e=[];b.forEach(function(b){b.isInfographic&&a.analysisAreas.forEach(function(a,d){c.setCurrentAnalysisAreaIndex(d);var h=new v,f=c.createGeoenrichment();f.onDone=function(){h.resolve()};f.country=c.countryID;f.setGeoLevels(r.getSubLevels(b),
r.getHighestLevel(b));f.setVariables(b.variables);f.setStudyArea(c.studyArea);e.push(h.promise)})});return d(e)})},reportDataFromJson:function(a){var b=a.fieldData;b.featureData&&(b.areaData=b.featureData.map(function(a){return{mainCalculator:{data:a}}}),delete b.featureData);return{isClassic:a.isClassic,reportType:a.reportType,reportTitle:a.reportTitle,templateJson:q.deserialize(a.templateJson),reportObject:a.reportObject,fieldData:b,analysisAreas:m.areasFromJson(a.analysisAreas),infographicOptions:a.infographicOptions&&
this._infographicOptionsProvider.getInfographicOptionsFromJson(a.infographicOptions),attachmentsStore:a.attachmentsStore&&t.getAttachmentsStoreFromJson(a.attachmentsStore),config:a.config,mapImageInfos:a.mapImageInfos}}})});