// 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/infographics/infographicUtils/InfographicLayoutResizer",["dojo/_base/lang","../../supportClasses/TableUtil","esri/dijit/geoenrichment/utils/ObjectUtil"],function(k,n,p){function q(a){var b=k.mixin({},r);a.style.minWidth&&(b.minW=a.style.minWidth);a.style.minHeight&&(b.minH=a.style.minHeight);return b}function l(a){var b={left:1E6,top:1E6,w:0,h:0};a.forEach(function(a){b.left=Math.min(b.left,a.left);b.top=Math.min(b.top,a.top);b.w=Math.max(b.w,a.left+
a.width);b.h=Math.max(b.h,a.top+a.height)});b.w-=b.left;b.h-=b.top;return b}function t(a){var b=[];m.forEach(function(d){a[d]&&b.push(a[d].style)});return b}function u(a,b,d,f){f=f||{};m.forEach(function(e){var c=a[e]&&a[e].style;if(c){var g=a[e].themeStyle;if(f.preserveContentSizes)e=c.left+c.width/2,g=c.top+c.height/2,e*=b,g*=d,c.left=e-c.width/2,c.top=g-c.height/2;else{var h=c.fontSize||g&&g.fontSize?(c.fontSize||g&&g.fontSize)/c.height:1;c.left*=b;c.width*=b;c.top*=d;c.height*=d;f.updateFontSize&&
("description"===e||"variable"===e)&&(c.fontSize||g&&g.fontSize)&&(c.fontSize=p.roundNumber(h*c.height,2))}}})}var h={},r={minW:320,maxW:1E6,minH:175,maxH:250};h.getContentDim=function(a){var b=a.header?n.getTableHeight(a.header)+(a.header.style.spaceBefore||0):5,d={w:a.style.width,h:a.style.height-b,top:b},f=q(a),e=k.mixin({},d);e.w=Math.max(f.minW,Math.min(f.maxW,e.w));e.h=Math.max(f.minH,Math.min(f.maxH,e.h));e.left=Math.max(0,(d.w-e.w)/2);e.top=Math.max(0,(d.h-e.h)/2);d.prettyfiedBox=e;a.variableTables&&
(d.innerBox=l(a.variableTables.map(function(a){return a.style})),d.innerBox.top-=b);return d};h.resizeLayout=function(a,b,d){d=d||{};var f=void 0!==d.usePrettyBox?d.usePrettyBox:!0,e=!f&&h.getContentDim(a);a.style.width=b.w;a.style.height=b.h;a.header&&(a.header.style.width=a.style.width,a.header.data.columns[0].style.width="100%");if(a.variableTables){b=function(b,c){a.variableTables.forEach(function(a){a.style.left*=b;a.style.top=(a.style.top-g)*c+g;h.resizeVariableTable(a,a.style.width*b,a.style.height*
c,{preserveContentSizes:void 0!==d.preserveContentSizes?d.preserveContentSizes:!0,updateFontSize:d.updateFontSize})})};var c=h.getContentDim(a),g=c.top;if(f){f=c.prettyfiedBox.w/c.innerBox.w;e=c.prettyfiedBox.h/c.innerBox.h;b(f,e);var c=h.getContentDim(a),k=c.prettyfiedBox.left-c.innerBox.left,l=c.prettyfiedBox.top-c.innerBox.top;a.variableTables.forEach(function(a){a.style.left+=k;a.style.top+=l})}else f=c.w/e.w,e=c.h/e.h,b(f,e)}};var m=["shape","image","variable","description"];h.getVariableTableContentDim=
function(a){return l(t(a))};h.resizeVariableTable=function(a,b,d,f){b=b||a.style.width;d=d||a.style.height;var e=b/a.style.width||1,c=d/a.style.height||1;a.style.width=b;a.style.height=d;u(a,e,c,f)};return h});