// 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/FlowList","dojo/_base/declare dojo/_base/lang dojo/dom-construct dojo/dom-class dojo/sniff ./utils/onClickTouch ./utils/TooltipUtil ./FlowListDefaultItemRenderer dijit/_WidgetBase dijit/_TemplatedMixin".split(" "),function(d,h,k,f,l,e,m,g,n,p){var q=l("touch");d=d([n,p],{templateString:"\x3cdiv data-dojo-attach-point\x3d'listDiv' class\x3d'esriGEFlowList esriGENonSelectable'\x3e\x3c/div\x3e",idProperty:"value",labelProperty:"label",selectedIndex:-1,selectedItem:null,
items:null,store:null,defaultItemRendererClass:g,itemRenderer:null,itemClass:null,itemClassSelected:null,keepScrollPosition:!1,allowRepetitiveSelection:!0,selectOnMouseDown:!1,selectionValidator:null,allowManualSelection:!0,stopMouseEventPropagation:!0,hasSelectableItems:!0,_addedWrappers:null,_clickHandlers:null,_valueOnCreation:null,_isCreated:!1,postCreate:function(){this.inherited(arguments);this._clearHandlers();this._setUpItemRenderer();m.autoTooltip(this.domNode);this._isCreated=!0;this._valueOnCreation?
this._setValueAttr(this._valueOnCreation):this.refresh()},_setUpItemRenderer:function(){this.itemRenderer||(this.itemRenderer=new this.defaultItemRendererClass);this.itemClass&&(this.itemRenderer.itemClass=this.itemClass);this.itemClassSelected&&(this.itemRenderer.itemClassSelected=this.itemClassSelected)},_getValueAttr:function(){return this.selectedItem&&this.selectedItem[this.idProperty]},_setValueAttr:function(a){var b=this;if(this._isCreated){var c=this.items||this.store&&this.store.data;c&&
c.some(function(c){if(c[b.idProperty]==a)return b.setSelectedItem(c),!0})}else this._valueOnCreation=a},_scrollTopMemo:0,_memoScroll:function(){this._scrollTopMemo=this.listDiv.scrollTop},_applyScrollFromMemo:function(){this.listDiv.scrollTop=this._scrollTopMemo||0},_setItemsAttr:function(a){this.setItems(a)},setItems:function(a,b){this.keepScrollPosition&&this._memoScroll();this.clear();this.items=a;b||(this.items&&this._isCreated?(this._addItems(a),this._checkIfStillSelected(),this.keepScrollPosition&&
this._applyScrollFromMemo()):this._checkIfStillSelected())},_checkIfStillSelected:function(){if(-1!=this.selectedIndex||this.selectedItem){var a=this;this._addedWrappers&&this._addedWrappers.some(function(b,c){return a.__isSelectedFunction(b,c)})||(this.selectedIndex=-1,this.selectedItem=null)}},refresh:function(){this.store?this.setStore(this.store,this.isOnDemandMode):this.setItems(this.items)},setSelectedItem:function(a,b){this.selectedItem=a;this.selectedIndex=-1;this.refresh();b&&this._dispatchChangeEvent()},
setSelectedIndex:function(a,b){this.selectedIndex=a;this.selectedItem=null;this.refresh();b&&this._dispatchChangeEvent()},getItemNode:function(a){var b;this._addedWrappers&&this._addedWrappers.some(function(c){if(c.itemRef===a)return b=c.__itemPresentation,!0});return b},getItemByNode:function(a){var b;this._addedWrappers&&this._addedWrappers.some(function(c){if(c.__itemPresentation===a)return b=c.itemRef,!0});return b},__selectedPresentation:null,_addItems:function(a){this._addedWrappers=this._addedWrappers||
[];var b=this;a.forEach(function(a){var c=h.mixin({},a);c.itemRef=a;b.__addWrapper(c)})},__addWrapper:function(a){var b=this._addedWrappers.length,c=this.itemRenderer.createPresentation(a.itemRef,this.__isSelectedFunction(a,b),this.listDiv,this,a);c&&(c.index=b,c.item=a.itemRef,a.__itemPresentation=c,this.__isSelectedFunction(a,b)&&(this.selectedItem=a.itemRef,this.selectedIndex=b,this.__selectedPresentation=c),this._addClickHandler(c),this._addedWrappers.push(a),a=this._addedWrappers.length-1,f.add(c,
"listItem_"+a),f.add(c,"listItem_"+(0==a%2?"even":"odd")))},__isSelectedFunction:function(a,b){if(!this.hasSelectableItems)return!1;if(b==this.selectedIndex||a.itemRef===this.selectedItem)return!0;if(a.itemRef&&this.selectedItem){var c=a.itemRef[this.idProperty],r=this.selectedItem[this.idProperty];return void 0!==c&&c===r}return!1},_selectionValidatorDefault:function(a){return!!a&&!a.isSeparator&&!1!==a.enabled},_addClickHandler:function(a){var b=this;this.allowManualSelection&&(this._clickHandlers.push(e(a,
"touchmove",function(a){b.isMoving=!0})),this._clickHandlers.push(e(a,this.selectOnMouseDown?"mousedown, touchend":"clickend",function(c){b.stopMouseEventPropagation&&c.stopPropagation();if(q&&b.isMoving&&"touchend"===c.type)b.isMoving=!1;else if(b.allowRepetitiveSelection||b.__selectedPresentation!=a)if(b.selectionValidator?!1!==b.selectionValidator(a.item):b._selectionValidatorDefault(a.item))b.__selectedPresentation&&b.itemRenderer.selectPresentation&&b.itemRenderer.selectPresentation(b.__selectedPresentation,
!1),b.itemRenderer.selectPresentation&&b.itemRenderer.selectPresentation(a,b.hasSelectableItems),b.__selectedPresentation=a,b.selectedIndex=a.index,b.selectedItem=a.item,b._dispatchChangeEvent()})))},_dispatchChangeEvent:function(){this.onChange({type:"change",selectedIndex:this.selectedIndex,selectedItem:this.selectedItem,value:this.selectedItem&&this.selectedItem[this.idProperty]})},clear:function(){this.__selectedPresentation=null;this._addedWrappers=this._addedWrappers||[],this._addedWrappers.forEach(function(a){a.destroyPresentation&&
a.destroyPresentation()});this._addedWrappers.length=0;this.listDiv&&k.empty(this.listDiv);this._clearHandlers()},_clearHandlers:function(){this._clickHandlers=this._clickHandlers||[];this._clickHandlers.forEach(function(a){a.remove()});this._clickHandlers.length=0},scrollToItem:function(a){if(a=this.getItemNode(a))this.listDiv.scrollTop=a.offsetTop},store:null,isOnDemandMode:!1,onDemandModeLoadStep:1E3,onDemandPopulateLimit:1E4,onDemandPopulatePeriod:200,_setStoreAttr:function(a){this.setStore(a,
this.isOnDemandMode)},setStore:function(a,b){this.keepScrollPosition&&this._memoScroll();this.clear();this.idProperty=(this.store=a)&&a.idProperty;if(this.store&&this._isCreated){this.isOnDemandMode=b;this._loadNextPart();this._checkIfStillSelected();this.keepScrollPosition&&this._applyScrollFromMemo();var c=this;this.own(e(this.listDiv,"scroll",function(){var a=c._addedWrappers[c._addedWrappers.length-30];(a=a?a.__itemPresentation:null)&&a.offsetTop<c.listDiv.scrollTop&&c._loadNextPart()}))}else this._checkIfStillSelected()},
_loadNextPart:function(){if(this.store&&this.store.query().length!=this._addedWrappers.length){var a=this.store.query(null,{start:this._addedWrappers.length,count:this.onDemandModeLoadStep});delete a.total;this._addItems(a);a.length&&this._addedWrappers.length<this.onDemandPopulateLimit&&(a=this._loadNextPart.bind(this),setTimeout(a,this.onDemandPopulatePeriod))}},onChange:function(a){},destroy:function(){this.clear();this.inherited(arguments)}});d.itemRenderers={DefaultItemRenderer:g};return d});