// 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/_base/declare","dojo/_base/lang","dojo/_base/html","dijit/_WidgetBase"],function(h,g,e,k){return h([k],{baseClass:"jimu-tile-container",declaredClass:"jimu.dijit.TileLayoutContainer",constructor:function(){this.items=[];this.vmargin=this.hmargin=15},startup:function(){this.inherited(arguments);this.items.forEach(g.hitch(this,function(a){this._placeItem(a)}));this.resize()},_placeItem:function(a){a.domNode?e.place(a.domNode,this.domNode):e.place(a,this.domNode)},addItem:function(a){this.items.push(a);
this._placeItem(a);this.resize()},addItems:function(a){this.items=this.items.concat(a);this.items.forEach(g.hitch(this,function(b){this._placeItem(b)}));this.resize()},removeItem:function(a){var b;for(b=0;b<this.items.length;b++)if(this.items[b].label===a){this.items[b].domNode?this.items[b].destroy():e.destroy(this.items[b]);this.items.splice(b,1);this.resize();break}},empty:function(){var a;for(a=0;a<this.items.length;a++)this.items[a].domNode?this.items[a].destroy():e.destroy(this.items[a]);this.items=
[]},resize:function(){var a=e.getMarginBox(this.domNode);var b=this.getItemSize(a);var c=Math.floor((a.w+this.hmargin)/(b.width+this.hmargin));this.items.forEach(g.hitch(this,function(d,f){this.setItemPosition(d,f,b,c)}))},getItemSize:function(a){var b={},c;if("fixWidth"===this.strategy)b.width=this.itemSize.width,b.height=this.itemSize.height;else if("breakWidth"===this.strategy)for(c=0;c<this.itemSize.length;c++){if(a.w<=this.itemSize[c].screenWidth){b.width=this.itemSize[c].width;b.height=this.itemSize[c].height;
break}}else"fixCols"===this.strategy&&(b.width=(a.w-this.hmargin*(this.maxCols-1))/this.maxCols,b.height="number"===typeof this.itemSize.height?this.itemSize.height:b.width*parseFloat(this.itemSize.height.substring(0,this.itemSize.height.length-1))/100);return b},setItemPosition:function(a,b,c,d){b++;var f=b%d;b=Math.ceil(b/d);0===f&&(f=d);d={position:"absolute",top:(this.vmargin+c.height)*(b-1)+"px"};d[window.isRTL?"right":"left"]=(this.hmargin+c.width)*(f-1)+"px";0<=c.width&&(d.width=c.width+"px");
0<=c.height&&(d.height=c.height+"px");e.setStyle(a.domNode?a.domNode:a,d)}})});