// 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/ReportPlayer/playerSupports/_ReportContainersSwitcher","dojo/_base/declare dojo/when dojo/dom-attr dojo/dom-class dojo/dom-construct esri/dijit/geoenrichment/utils/DomUtil esri/dijit/geoenrichment/ReportPlayer/core/supportClasses/ViewModes".split(" "),function(h,l,m,k,n,p,q){var r={createContainer:function(a,b,c){function f(){return g.layoutBuilder.createElement("classic"===a?"reportContainer":"reportContainerGrid",{viewModel:g,parentWidget:c,isSourceContainer:!0,
onPendingDataApplied:function(){c._emitResizedEvent()},renderOptions:{center:!0,minTop:10}},c.reportContainerDiv)}function d(){return g.layoutBuilder.createElement("reportContainerPagination",{viewModel:g,parentWidget:c,onResized:function(a){c._emitResizedEvent(a)},onPendingDataApplied:function(){c._emitResizedEvent()}},c.reportContainerDiv)}var g=c._viewModel,e=c._containerDict.getContainer(a,b);e||(e="pagination"===a?d():f(),e.isCurrentContainer=function(){return c.getCurrentReportContainer()===
e},c.own(e));c._containerDict.setContainer(e,a,b);return e}},t=h(null,{_containersHash:null,constructor:function(){this._containersHash={}},_getInfo:function(a,b,c,f){a=this._containersHash[a]=this._containersHash[a]||[];var d=a[b];!d&&f&&(d=a[b]={container:f,loaded:!1});return c?d&&d[c]:d},getContainer:function(a,b){return this._getInfo(a,b,"container")},getContainers:function(a){return(this._containersHash[a]=this._containersHash[a]||[]).map(function(a){return a.container})},getContainerIndex:function(a,
b){return this.getContainers(b).indexOf(a)},setContainer:function(a,b,c){m.set(a.domNode,"area-index",c);this._getInfo(b,c,null,a)},isLoaded:function(a,b){return this._getInfo(a,b,"loaded")},setLoaded:function(a,b){var c=this._getInfo(a,b);c&&(c.loaded=!0)},resetAllLoaded:function(){for(var a in this._containersHash)this._containersHash[a].forEach(function(a){a.loaded=!1})}});return h(null,{_containerDict:null,postCreate:function(){this._containerDict=new t;this.inherited(arguments)},getCurrentReportContainer:function(){return this._currentReportContainer},
getAllReportContainers:function(){var a=this._getCurrentViewType();return this._containerDict.getContainers(a)},_getCurrentViewType:function(){return this.isSlidesView?"pagination":this._reportData.isClassic?"classic":"graphic"},_setReportContainer:function(a){var b=this;a?this._resetLoadedFlags():this._rememberCurrentContainerVisuals();this._switchToCurrentReportContainer();return!a&&this._isCurrentContainerLoaded()?l(this._resize({isPaginating:!0}),function(){b._applyCurrentContainerVisuals();return!1}):
!0},_switchToCurrentReportContainer:function(){this._currentReportContainer&&this._hideContainer(this._currentReportContainer);var a=this._getCurrentViewType();this._currentReportContainer=r.createContainer(a,this.getCurrentAnalysisAreaIndex(),this);k["pagination"===a?"add":"remove"](this.domNode,"esriGEReportPlayerPaginationView");k["pagination"===a?"remove":"add"](this.domNode,"esriGEReportPlayerFullView");this._showContainer(this._currentReportContainer);this._currentReportContainer.setViewMode&&
this._currentReportContainer.setViewMode(q.PREVIEW_VALUES);this._connectZoomToCurrentContainer();this.notifyShown()},_hideContainer:function(a){var b=this._getCurrentViewType();a.__undoHideContainerHandle=p.hideNodeInBackground(a.domNode,"reportContainer_"+this._containerDict.getContainerIndex(a,b))},_showContainer:function(a){a.__undoHideContainerHandle&&(a.__undoHideContainerHandle.undo(),delete a.__undoHideContainerHandle)},_showAllContainers:function(){var a=this;this.getAllReportContainers().forEach(function(b){a._showContainer(b);
a.reportContainerDiv.removeChild(b.domNode);n.place(b.domNode,a.reportContainerDiv)});return{undo:function(){a.getAllReportContainers().forEach(function(b){a._hideContainer(b)});a._switchToCurrentReportContainer()}}},_resetLoadedFlags:function(){this._lastVisuals=null;this._containerDict.resetAllLoaded()},_isCurrentContainerLoaded:function(){return this._containerDict.isLoaded(this._getCurrentViewType(),this.getCurrentAnalysisAreaIndex())},_setCurrentContainerLoaded:function(){this._applyCurrentContainerVisuals();
this._containerDict.setLoaded(this._getCurrentViewType(),this.getCurrentAnalysisAreaIndex())},_lastVisuals:null,_rememberCurrentContainerVisuals:function(){if(this._currentReportContainer){var a=this._currentReportContainer;this._lastVisuals={type:this._getCurrentViewType(),scrollTop:a.getScrollableContainer&&a.getScrollableContainer().scrollTop||0,pageIndex:a.getCurrentPageIndex&&a.getCurrentPageIndex()||0,slideIndex:a.getCurrentSlideIndex&&a.getCurrentSlideIndex()||0,zoomInfo:a.getZoomInfo&&a.getZoomInfo()}}else this._lastVisuals=
null},_applyCurrentContainerVisuals:function(){if(this._lastVisuals)if(this._lastVisuals.type!==this._getCurrentViewType())this._lastVisuals=null;else{var a=this._currentReportContainer;a.getScrollableContainer&&(a.getScrollableContainer().scrollTop=this._lastVisuals.scrollTop||0);a.showSlideAt&&a.showSlideAt(this._lastVisuals.slideIndex||0);a.showPageAt&&a.showPageAt(this._lastVisuals.pageIndex||0);a.setZoomInfo&&a.setZoomInfo(this._lastVisuals.zoomInfo)}}})});