(function(){"use strict";u8.Base.Widgets.FlowPanel=function(e,t){this.Panel(e,$.extend({},u8.Base.Widgets.FlowPanel.defaults,t));this.items=this.items||[];this._create()};u8.Base.Widgets.FlowPanel.makeClass({name:"FlowPanel",deriveFrom:u8.Base.Widgets.Panel});u8.Base.Widgets.FlowPanel.defaults={};$.extend(u8.Base.Widgets.FlowPanel.prototype,{update:function(){this._create()},setItemVisibility:function(e,t){var i=this.element.childNodes[e];if(!i){return}this.$(i).toggle(!!t);this.layout()},_create:function(){this.empty();var e=this.$(this.element).addClass("u8-flowpanel");for(var t=0;t<this.items.length;t++){var i=this.items[t];var r=i.css||{};if(!r.display){r.display=this.orientation=="h"?"inline-block":"block"}var a=this._createItemElement(i,{css:r});a.appendTo(e);this._createItemContent(a)}if(this.designer){e.addClass("u8-formflowpanel-designer")}},"Designer.getDropTargets":function(e){if(e.kind!="widget"){return undefined}var t=this.$(this.element);var i=e.item;var r=e.sourceItem;var a;if(!this.items||!this.items.length){a=t.offset();return[{rect:{left:a.left,top:a.top,width:t.outerWidth(),height:t.outerHeight()},arrayName:"items"}]}var s=[];var n=this.$(this.element).children();var h,l;var o=false;function f(e){switch(e&&$$(e).css("display")){case"block":case"table":case"list-item":return false;default:return true}}if(i){var d=i.getInstance(this.designer.formDesigner);if(d&&d.element){o=f(d.element)}}for(var m=0;m<this.items.length;m++){l=h;h=$$(n[m]);a=h.offset();var u=m;if(i&&i.parent==r.id){if(i.containingArrayIndex==u||i.containingArrayIndex+1==u){continue}if(u>i.containingArrayIndex){u--}}var c=f(h);var g=f(l);var p,y=false;if(l){if(o){p=c||g;y=!c&&g}else{p=c&&g}}else{p=o&&c}if(p){if(y){var v=l.offset();s.push({rect:{left:v.left+l.outerWidth()-5,top:v.top,width:10,height:l.height()},arrayName:"items",arrayIndex:u})}else{s.push({rect:{left:a.left-5,top:a.top,width:10,height:h.height()},arrayName:"items",arrayIndex:u})}}else{s.push({rect:{left:t.offset().left,top:a.top-5,width:t.width(),height:6},arrayName:"items",arrayIndex:u})}}if(!i||i.parent!=r.id||i.containingArrayIndex!=this.items.length-1){g=f(h);p=o&&g;if(p){s.push({rect:{left:a.left-5+h.outerWidth(),top:a.top,width:10,height:h.height()},arrayName:"items"})}else{var w=a.top-1+h.outerHeight();var I=t.offset().top+t.height()-w;s.push({rect:{left:t.offset().left,top:w,width:t.width(),height:I>=6?I:6},arrayName:"items"})}}return s},"Designer.removeItem":function(e){if(e.arrayName=="items"){return this.$(this.element).children(":eq("+e.arrayIndex+")")}},"Designer.insertItem":function(e){if(e.arrayName!="items"){return}var t=this.$(this.element);if(typeof e.arrayIndex!="number"||e.arrayIndex==this.items.length-1){t.append(e.element)}else{t.children(":eq("+e.arrayIndex+")").before(e.element)}}})})();