// 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","dijit/_WidgetBase","dojo/_base/array","dojo/_base/lang"],function(l,m,f,g){return l([m],{map:null,postCreate:function(){},getLayerDetailsFromMap:function(h,e,d){var b={},k;this.map&&this.map.webMapResponse&&this.map.webMapResponse.itemInfo&&this.map.webMapResponse.itemInfo.itemData&&this.map.webMapResponse.itemInfo.itemData.operationalLayers&&f.forEach(this.map.webMapResponse.itemInfo.itemData.operationalLayers,g.hitch(this,function(a){a.layerObject&&("ArcGISMapServiceLayer"===
a.layerType||"ArcGISTiledMapServiceLayer"===a.layerType?(k=d&&d.substring(0,d.lastIndexOf("_")),k&&a.id!==k||(b.isMapServer=!0,b.id=a.id+"_"+e,h.substring(0,h.length-1)===a.url&&(f.forEach(a.resourceInfo.layers,g.hitch(this,function(c){c.id===parseInt(e,10)&&(b.title=c.name)})),f.forEach(a.layers,g.hitch(this,function(c){c.id===parseInt(e,10)&&(c.name&&(b.title=c.name),b.popupInfo=c.popupInfo,c.layerDefinition&&(c.layerDefinition.definitionExpression&&(b.definitionExpression=c.layerDefinition.definitionExpression),
c.layerDefinition.drawingInfo&&c.layerDefinition.drawingInfo.renderer&&(b.renderer=c.layerDefinition.drawingInfo.renderer)))}))))):d&&a.id!==d||!a.url||a.url.replace(/.*?:\/\//g,"")!==(h+e).replace(/.*?:\/\//g,"")||(b.isMapServer=!1,b.title=a.title,b.popupInfo=a.popupInfo,b.id=a.id,a.layerDefinition&&(a.layerDefinition.definitionExpression&&(b.definitionExpression=a.layerDefinition.definitionExpression),a.layerDefinition.drawingInfo&&a.layerDefinition.drawingInfo.renderer&&(b.renderer=a.layerDefinition.drawingInfo.renderer))))}));
return b}})});