// 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/supportClasses/TableUtil",["dojo/_base/lang","./templateJsonUtils/fieldInfo/FieldInfoBuilder","esri/dijit/geoenrichment/ReportPlayer/core/sections/SectionTypes"],function(m,q,h){var g={createTable:function(a){var b=a.numColumns,d=a.numRows,c=a.widths,f=a.width,r=a.style,g=a.attributes&&a.attributes.fixedColumns,t=a.attributes&&a.attributes.dynamicColumns;if(f)for(var k=f/b,c=[],e=0;e<b;e++)c.push(k);if(c)f||isNaN(Number(c[0]))||(f=0,c.forEach(function(a){f+=
a}));else for(k=Number(100/b).toFixed(3)+"%",c=[],e=0;e<b;e++)c.push(k);k=[];for(e=0;e<b;e++)k.push({field:"field"+e,style:{width:c[e]}});for(var c=[],h=!0,u=a.height?a.height/d:15.07,l=0;l<d;l++){for(var n={style:{height:u,fields:{}},fieldInfos:{}},e=0;e<b;e++){var p="field"+e;!1!==a.useDefaultTheme&&(n.style.fields[p]={horizontalAlign:0===e?"left":"right",overrideStyle:0===l?1<d?"TableHeader":void 0:h?"AlternatingRow":"Default"});t&&e>=g&&0===l&&(n.fieldInfos[p]=q.createFieldInfoFromSpecialFieldName("AREA_DESC"))}c.push(n);
h=!h}b={id:"table",style:m.mixin({width:f||772.33},r),data:{columns:k,data:c}};a.attributes&&(b.attributes=a.attributes);return b},createSingleCellTable:function(a){var b=g.createTable({numColumns:1,numRows:1,attributes:a.attributes,useDefaultTheme:!1});g.modifyTableJson(b,0,0,a);return b},modifyTableJson:function(a,b,d,c){b=a.data.data[b];d=a.data.columns[d];var f=d.field;c.text&&(b[f]=c.text);c.fieldInfo&&(b.fieldInfos[f]=c.fieldInfo);c.cellStyle&&(b.style.fields[f]=c.cellStyle);c.columnSpan&&(b.columnSpans=
b.columnSpans||{},b.columnSpans[f]=c.columnSpan);c.rowSpan&&(b.rowSpans=b.rowSpans||{},b.rowSpans[f]=c.rowSpan);b.themeStyle=c.themeStyle;c.width&&(a.style.width=c.width,d.style.width=c.width);c.height&&(b.style.height=c.height);void 0!==c.left&&(a.style.left=c.left);void 0!==c.spaceBefore&&(a.style.spaceBefore=c.spaceBefore)},getTableWidth:function(a){return a.style.width},getTableHeight:function(a){var b=0;a.data.data.forEach(function(a){b+=a.style?a.style.height:0});return b},createDetailsSection:function(a){return{type:h.DETAILS,
stack:[g.createTable(a)]}},createDetailsSectionForFieldInfos:function(a,b){return{type:h.DETAILS,stack:[function(){var d=g.createTable(m.mixin({numColumns:2,numRows:a.length+1},b));d.data.data.forEach(function(c,b){if(0===b)c.field0=a[0].hasVariable?a[0].fieldCategory:"";else{var d=a[b-1];c.field0=d.script?d.script.alias:d.alias;c.fieldInfos.field1=d}});g.provideSpaceAfter(d);return d}()]}},createDetailsSectionForFieldInfoGroups:function(a,b){return{type:h.DETAILS,stack:[function(){var d=g.createTable(m.mixin({numColumns:a.length+
1,numRows:a[0].length+1},b));d.data.data.forEach(function(b,f){d.data.columns.forEach(function(c,d){if(0!==d)if(0===f)b[c.field]=a[d-1][0].fieldCategory||"";else{var g=a[d-1][f-1];b.field0=b.field0||(g.script?g.script.alias:g.alias);b.fieldInfos[c.field]=g}})});g.provideSpaceAfter(d);return d}()]}},provideSpaceAfter:function(a,b){a.style.spaceAfter=Math.max(b||0,90-15.07*a.data.data.length)},applyDefaultStyling:function(a){var b=!0;a.data.data.forEach(function(d,c){a.data.columns.forEach(function(a){d.style.fields[a.field].overrideStyle=
0===c?"TableHeader":b?"AlternatingRow":void 0});b=!b})},setTableHeaderStyle:function(a){if(a.style)for(var b in a.style.fields)(a.style.fields[b]=a.style.fields[b]||{}).overrideStyle="TableHeader"},DEFAULT_ROW_HEIGHT:15.07};return g});