// All material copyright ESRI, All Rights Reserved, unless otherwise specified.// See https://js.arcgis.com/4.6/esri/copyright.txt for details.//>>builtdefine("require dojo/Deferred ../core/Accessor ../core/Error ../core/Evented ../core/Identifiable ../core/Loadable ../core/urlUtils ../core/requireUtils ../core/promiseUtils ../core/Logger ../config ../kernel ../request ../geometry/SpatialReference ../geometry/Extent".split(" "),function(d,m,c,f,n,p,q,r,e,t,g,u,h,v,k,w){varx=0,l=g.getLogger("esri.layers.Layer");c=c.createSubclass([n,p,q],{declaredClass:"esri.layers.Layer",properties:{attributionDataUrl:null,credential:{value:null,readOnly:!0,dependsOn:["loaded","parsedUrl"],get:function(){vara=this.loaded&&this.parsedUrl&&h.id&&h.id.findCredential(this.parsedUrl.path)||null;a&&a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));returna}},fullExtent:neww(-180,-90,180,90,k.WGS84),hasAttributionData:{readOnly:!0,dependsOn:["attributionDataUrl"],get:function(){returnnull!=this.attributionDataUrl}},id:{get:function(){returnDate.now().toString(16)+"-layer-"+x++}},legendEnabled:!0,listMode:"show",opacity:{value:1,type:Number,cast:function(a){return0>a?0:1<a?1:a}},parsedUrl:{readOnly:!0,dependsOn:["url"],get:function(){vara=this._get("url");returna?r.urlToObject(a):null}},popupEnabled:!0,attributionVisible:!0,spatialReference:k.WGS84,title:null,token:{dependsOn:["credential.token"],get:function(){vara=this.get("parsedUrl.query.token"),b=this.get("credential.token");returna||b||null},set:function(a){a?this._override("token",a):this._clearOverride("token")}},type:{type:String,readOnly:!0,value:null,json:{read:!1}},url:{value:null},visible:!0},initialize:function(){this.when().catch(function(a){g.getLogger(this.declaredClass).error("#load()","Failed to load layer (title: '"+this.title+"', id: '"+this.id+"')",a)}.bind(this))},createLayerView:function(a){varb=this.viewModulePaths[a.type];returnb?e.when(d,b).then(function(b){b.default&&(b=b.default);returnnewb({layer:this,view:a})}.bind(this)):t.reject(newf("layerview:module-unavailable","No LayerView module available for layer '${layer.declaredClass}' and view type: '${view.type}'",{view:a,layer:this}))},destroyLayerView:function(a){a.destroy()},fetchAttributionData:function(){vara=this.attributionDataUrl;this.hasAttributionData&&a?a=v(a,{query:{f:"json"},responseType:"json"}).then(function(a){returna.data}):(a=newm,a.reject(newf("layer:no-attribution-data","Layer does not have attribution data")),a=a.promise);returna},refresh:function(){this.emit("refresh")}});c.fromArcGISServerUrl=function(a){"string"===typeofa&&(a={url:a});varb=e.when(d,"./support/arcgisLayers").then(function(b){returnb.fromUrl(a)});b.otherwise(function(b){l.error("#fromArcGISServerUrl({ url: '"+a.url+"'})","Failed to create layer from arcgis server url",b)});returnb};c.fromPortalItem=function(a){!a||a.portalItem||"object"!==typeofa||a.declaredClass&&"esri.portal.PortalItem"!==a.declaredClass||(a={portalItem:a});varb=e.when(d,"../portal/support/portalLayers").then(function(b){returnb.fromItem(a)});b.otherwise(function(b){varc=a&&a.portalItem;l.error("#fromPortalItem()","Failed to create layer from portal item (portal: '"+(c&&c.portal&&c.portal.url||u.portalUrl)+"', id: '"+(c&&c.id||"unset")+"')",b)});returnb};returnc});