// 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/array dojo/_base/html dijit/_WidgetBase dijit/_Container ./a11y/BaseWidgetPanel ./dijit/LoadingIndicator ./BaseWidgetFrame ./utils".split(" "),function(e,g,d,h,m,n,p,k,q,r){e=e([m,n],{baseClass:"jimu-panel jimu-container",started:!1,state:"closed",windowState:"normal",moveTopOnActive:!0,openAnimation:null,closeAnimation:null,animationDuration:0,startup:function(){this.inherited(arguments);this.loadAllWidgetsInOrder();this.started=!0},loadAllWidgetsInOrder:function(){var a=
this.getAllWidgetConfigs();Array.isArray(this.config.widgets)?(a=this.config.widgets,1<a.length&&this._addTagToGroupPanel()):a=[this.config];d.forEach(a,function(b,c){if(!1!==b.visible){var t=new k;var f=this.createFrame(b);this._initFrameEvents(f,b,c);this.addChild(f);f.setLoading(t);this.widgetManager.loadWidget(b).then(g.hitch(this,function(l){f.setWidget(l);l.startup()}))}},this)},getAllWidgetConfigs:function(){var a=[];return a=Array.isArray(this.config.widgets)?this.config.widgets:[this.config]},
getWidgetById:function(a){for(var b=this.getChildren(),c=0;c<b.length;c++)if(b[c].getWidget()&&b[c].getWidget().id===a)return b[c].getWidget()},getWidgets:function(){return this.getChildren().map(function(a){return a.getWidget()})},createFrame:function(a){return new q},setPosition:function(a,b){this.position=a;var c=r.getPositionStyle(this.position);c.position="absolute";b||(b="map"===a.relativeTo?this.map.id:window.jimuConfig.layoutId);this.started?this.resize():this.openAnimation&&(c.display="none");
h.place(this.domNode,b);h.setStyle(this.domNode,c)},getPosition:function(){return this.position},setState:function(a){this.state=a},setWindowState:function(a){this.windowState=a},resize:function(){this.getChildren().forEach(function(a){a.resize()})},onPositionChange:function(a){this.setPosition(a)},onOpen:function(){d.forEach(this.getChildren(),function(a){a.getWidget()&&this.widgetManager.openWidget(a.getWidget())},this);this._onOpenAndFocus()},onClose:function(){d.forEach(this.getChildren(),function(a){a.getWidget()&&
this.widgetManager.closeWidget(a.getWidget())},this)},onMaximize:function(){d.forEach(this.getChildren(),function(a){a.getWidget()&&this.widgetManager.maximizeWidget(a.getWidget())},this)},onMinimize:function(){d.forEach(this.getChildren(),function(a){a.getWidget()&&this.widgetManager.minimizeWidget(a.getWidget())},this)},onNormalize:function(){d.forEach(this.getChildren(),function(a){a.getWidget()&&this.widgetManager.normalizeWidget(a.getWidget())},this)},onActive:function(){},onDeActive:function(){},
updateConfig:function(a){this._updateConfig(a)},reloadWidget:function(a){this.isWidgetInPanel(a)&&(this._updateConfig(a),this.getChildren().forEach(function(b){b.getWidget()&&b.getWidget().id===a.id&&(b.getWidget().destroy(),b.setLoading(new k),this.widgetManager.loadWidget(a).then(g.hitch(this,function(c){b.setWidget(c);c.startup();"closed"===this.state&&this.widgetManager.closeWidget(c)})))},this))},isWidgetInPanel:function(a){return d.some(this.getAllWidgetConfigs(),function(b){if(a.id===b.id)return!0})?
!0:!1},_updateConfig:function(a){if(Array.isArray(this.config.widgets)){for(var b=-1,c=0;c<this.config.widgets.length;c++)this.config.widgets[c].id===a.id&&(b=c);0<b&&(this.config.widgets[b]=a)}else this.config=a},destroy:function(){this.getChildren().forEach(function(a){try{a.domNode&&a.destroy()}catch(b){console.error("destroy widget frame error."+b.stack)}});this.inherited(arguments)}});e.extend(p);return e});