// 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/layerUtils",["dojo/_base/lang","dojo/_base/array","dojo/_base/json","dojo/has","./kernel"],function(m,f,k,n,p){var l={_serializeLayerDefinitions:function(a,c){var b=[],e=/[:;]/;if(a&&(f.forEach(a,function(a,d){a&&(b.push([d,a]),!c&&e.test(a)&&(c=!0))}),0<b.length)){var d;c?(d={},f.forEach(b,function(a){d[a[0]]=a[1]}),d=k.toJson(d)):(d=[],f.forEach(b,function(a){d.push(a[0]+":"+a[1])}),d=d.join(";"));return d}return null},_serializeTimeOptions:function(a,c){if(a){var b=[];f.forEach(a,
function(a,d){if(a){var e=a.toJson();c&&-1!==f.indexOf(c,d)&&(e.useTime=!1);b.push('"'+d+'":'+k.toJson(e))}});if(b.length)return"{"+b.join(",")+"}"}},_getVisibleLayers:function(a,c){var b=[],e,d,g;if(!a)return b;if(c)for(b=c.concat(),g=0;g<a.length;g++)e=a[g],d=f.indexOf(a,e.id),e.subLayerIds&&-1<d&&(b.splice(d,1),b=b.concat(e.subLayerIds));else b=this._getDefaultVisibleLayers(a);return b},_getDefaultVisibleLayers:function(a){var c=[],b;if(!a)return c;for(b=0;b<a.length;b++)0<=a[b].parentLayerId&&
-1===f.indexOf(c,a[b].parentLayerId)&&f.some(a,function(c){return c.id===a[b].parentLayerId})||a[b].defaultVisibility&&c.push(a[b].id);return c},_getLayersForScale:function(a,c){var b=[];if(0<a&&c){var e;for(e=0;e<c.length;e++)if(!(0<=c[e].parentLayerId&&-1===f.indexOf(b,c[e].parentLayerId)&&f.some(c,function(a){return a.id===c[e].parentLayerId}))&&0<=c[e].id){var d=!0,g=c[e].maxScale,h=c[e].minScale;if(0<g||0<h)0<g&&0<h?d=g<=a&&a<=h:0<g?d=g<=a:0<h&&(d=a<=h);d&&b.push(c[e].id)}}return b}};n("extend-esri")&&
m.mixin(p,l);return l});