//>>built
define("dojox/form/_SelectStackMixin",["dojo/_base/lang","dojo/_base/array","dijit/_base/manager","dojo/_base/connect","dojo/_base/declare"],function(g,f,h,d,i){return i("dojox.form._SelectStackMixin",null,{stackId:"",stackPrefix:"",_paneIdFromOption:function(a){return(this.stackPrefix||"")+a},_optionValFromPane:function(a){var b=this.stackPrefix;return b&&0===a.indexOf(b)?a.substring(b.length):a},_togglePane:function(a,b){if(!(void 0!=a._shown&&a._shown==b)){var c=f.filter(a.getDescendants(),"return item.name;");
if(b){var e=a._savedStates||{};f.forEach(c,function(a){var b=e[a.id];void 0==b&&(b=!1);a.set("disabled",b)});delete a._savedStates}else e={},f.forEach(c,function(a){e[a.id]=a.disabled;a.set("disabled",!0)}),a._savedStates=e;a._shown=b}},_connectTitle:function(a,b){var c=g.hitch(this,function(a){this.updateOption({value:b,label:a})});a._setTitleAttr?this.connect(a,"_setTitleAttr",c):this.connect(a,"attr",function(a,b){"title"==a&&1<arguments.length&&c(b)})},onAddChild:function(a){if(!this._panes[a.id]){this._panes[a.id]=
a;var b=this._optionValFromPane(a.id);this.addOption({value:b,label:a.title});this._connectTitle(a,b)}if(!a.onShow||!a.onHide||void 0==a._shown)a.onShow=g.hitch(this,"_togglePane",a,!0),a.onHide=g.hitch(this,"_togglePane",a,!1),a.onHide()},_setValueAttr:function(a){"_savedValue"in this||this.inherited(arguments)},attr:function(a,b){if("value"==a&&2==arguments.length&&"_savedValue"in this)this._savedValue=b;return this.inherited(arguments)},onRemoveChild:function(a){this._panes[a.id]&&(delete this._panes[a.id],
this.removeOption(this._optionValFromPane(a.id)))},onSelectChild:function(a){this._setValueAttr(this._optionValFromPane(a.id))},onStartup:function(a){var b=a.selected;this.addOption(f.filter(f.map(a.children,function(a){var c=this._optionValFromPane(a.id);this._connectTitle(a,c);var d=null;this._panes[a.id]||(this._panes[a.id]=a,d={value:c,label:a.title});if(!a.onShow||!a.onHide||void 0==a._shown)a.onShow=g.hitch(this,"_togglePane",a,!0),a.onHide=g.hitch(this,"_togglePane",a,!1),a.onHide();"_savedValue"in
this&&c===this._savedValue&&(b=a);return d},this),function(a){return a}));var c=this,e=function(){delete c._savedValue;c.onSelectChild(b);b._shown||c._togglePane(b,!0)};if(b!==a.selected)var d=this.connect(h.byId(this.stackId),"_showChild",function(){this.disconnect(d);e()});else e()},postMixInProperties:function(){this._savedValue=this.value;this.inherited(arguments);this.connect(this,"onChange","_handleSelfOnChange")},postCreate:function(){this.inherited(arguments);this._panes={};this._subscriptions=
[d.subscribe(this.stackId+"-startup",this,"onStartup"),d.subscribe(this.stackId+"-addChild",this,"onAddChild"),d.subscribe(this.stackId+"-removeChild",this,"onRemoveChild"),d.subscribe(this.stackId+"-selectChild",this,"onSelectChild")];var a=h.byId(this.stackId);if(a&&a._started)this.onStartup({children:a.getChildren(),selected:a.selectedChildWidget})},destroy:function(){f.forEach(this._subscriptions,d.unsubscribe);delete this._panes;this.inherited("destroy",arguments)},_handleSelfOnChange:function(a){if(a=
this._panes[this._paneIdFromOption(a)]){var b=h.byId(this.stackId);a==b.selectedChildWidget?b._transition(a):b.selectChild(a)}}})});