// 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/core/conversion/portalToEditorUtils/parsers/InfographicConverterPtoE",["dojo/_base/lang","../../ConversionUtil","esri/dijit/geoenrichment/ReportPlayer/core/infographics/InfographicTypes","esri/dijit/geoenrichment/ReportPlayer/core/sections/SectionTypes","../../../infographics/infographicUtils/InfographicJsonUtil"],function(p,d,g,k,q){return{portalToEditor:function(a,v,e){function r(){function g(a){return e.parsers.getParser("section").parseTable(a,e)}
var c=a.tags.slice(),b,h=[],m,n;(function(){1.1<=e.revisionVersion?c.forEach(function(a){switch(a.attributes.type){case k.INFOGRAPHIC_HEADER:b=a.tags[0];break;case k.INFOGRAPHIC_VARIABLE:h.push(a);break;case k.INFOGRAPHIC_BACKGROUND:m=a.tags;break;case k.INFOGRAPHIC_FOREGROUND:n=a.tags}}):h=c.filter(function(a){return"infographicHeader"===a.attributes.type?(b=a,!1):!0})})();var l;f={type:a.attributes.type,isDefault:a.attributes.isDefault,style:{width:d.ptToPx(a.attributes.width),height:d.ptToPx(a.attributes.height),
minWidth:d.ptToPx(a.attributes.minWidth)||void 0,minHeight:d.ptToPx(a.attributes.minHeight)||void 0,backgroundColor:a.attributes.backgroundColor},background:m?m.map(g):null,header:b&&g(b),variableTables:h.map(function(a){var f={style:d.ptToPxObj({left:a.attributes.left,top:a.attributes.top,width:a.attributes.width,height:a.attributes.height})},c;a.tags.forEach(function(a){if("dataDrillingPanels"===a.name)c=a;else{var b=a.attributes.type,d=g(a),e=d.data.data[0],h=d.data.columns[0].field;a={isContrastColor:a.attributes.isContrastColor,
isHighlighted:a.attributes.isHighlighted,style:p.mixin({width:d.data.columns[0].style.width,height:e.style.height,left:d.style.left,top:d.style.spaceBefore},e.style.fields[h])};"shape"===b&&(a.shapeJson=e.fieldInfos[h].shapeJson);"image"===b?a.imageJson=e.fieldInfos[h].imageJson:"variable"===b?a.fieldInfo=e.fieldInfos[h]:"description"===b&&(a.text=e[h]);f[b]=a}});if(c&&c.tags&&c.tags.length){a=function(a){l=l||{};l[f.variable.fieldInfo.templateName]=a};var b=c.tags[0];if(b.attributes&&b.attributes.isStandard)a("standard");
else{var h=b.tags&&b.tags[0];h&&"section"===h.name&&a({states:b.attributes&&b.attributes.states,sectionJson:e.parsers.getParser("section").parseSection(h,e)})}}return f}),foreground:n?n.map(g):null};f.dataDrilling=l}function t(){var g,c,b;a.tags.forEach(function(a){switch(a.name){case "header":g=a;break;case "attributes":c=a;break;case "notes":b=a}});f={type:a.attributes.type,showNotes:a.attributes.showNotes,showAttributes:a.attributes.showAttributes,attributesLayout:a.attributes.attributesLayout,
style:{width:d.ptToPx(a.attributes.width),height:d.ptToPx(a.attributes.height),backgroundColor:a.attributes.backgroundColor},header:e.parsers.getParser("section").parseTable(g.tags[0],e),attributesStyle:e.parsers.getParser("section").parseTableCellAttributes(c&&c.attributes||{},null,e),notesStyle:e.parsers.getParser("section").parseTableCellAttributes(b&&b.attributes||{},null,e)}}function u(){var k=a.attributes.name,c=e.templateJson.metadata.comparisonCalculatorsHash[k];f={type:g.fixTapestryNameToWidget(a.attributes.type),
title:a.attributes.title||"",variables:c&&c.variables,calcData:c&&{calculatorName:k,variableObjects:c.variableObjects},style:{width:d.ptToPx(a.attributes.width),height:d.ptToPx(a.attributes.height),backgroundColor:a.attributes.backgroundColor},showVerticalAxis:a.attributes.showVerticalAxis,dataCollectionID:a.attributes.dataCollectionID,variableID:a.attributes.variableID};c&&c.levels&&q.setLevels(f,c.levels);f.variables||(f.variables=f.dataCollectionID?[f.dataCollectionID+".*"]:[f.variableID]);delete f.dataCollectionID;
delete f.variableID}var f;switch(g.fixTapestryNameToWidget(a.attributes.type)){case g.STATIC:r();break;case g.ATTACHMENTS:f={type:a.attributes.type,useCircularMask:a.attributes.useCircularMask,alwaysShowCaptions:a.attributes.alwaysShowCaptions,scaleToCover:a.attributes.scaleToCover,style:{width:d.ptToPx(a.attributes.width),height:d.ptToPx(a.attributes.height),backgroundColor:a.attributes.backgroundColor}};break;case g.AREA_DETAILS:t();break;case g.INTERESTING_FACTS:f={type:a.attributes.type,style:{width:d.ptToPx(a.attributes.width),
height:d.ptToPx(a.attributes.height),backgroundColor:a.attributes.backgroundColor}};break;case g.AGE_PYRAMID:case g.TAPESTRY:case g.RELATED_VARS:case g.ONE_VAR:u();break;default:return null}return f}}});