/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","../geometry","../request","../core/Error","../core/Evented","../core/Identifiable","../core/Loadable","../core/Logger","../core/promiseUtils","../core/urlUtils","../core/accessorSupport/decorators/property","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/subclass","./support/fromPortalItem","../geometry/Extent","../geometry/SpatialReference"],(function(e,t,r,o,a,n,i,l,p,s,y,c,u,d,b,_,f,h,v,g){"use strict";let m=0,L=function(r){function o(){var e;return(e=r.apply(this,arguments)||this).attributionDataUrl=null,e.fullExtent=new v(-180,-90,180,90,g.WGS84),e.id=Date.now().toString(16)+"-layer-"+m++,e.legendEnabled=!0,e.listMode="show",e.opacity=1,e.parent=null,e.popupEnabled=!0,e.attributionVisible=!0,e.spatialReference=g.WGS84,e.title=null,e.type=null,e.url=null,e.visible=!0,e}t._inheritsLoose(o,r),o.fromArcGISServerUrl=function(){var r=t._asyncToGenerator((function*(t){const r="string"==typeof t?{url:t}:t;return(yield new Promise(((t,r)=>e(["./support/arcgisLayers"],t,r)))).fromUrl(r)}));function o(e){return r.apply(this,arguments)}return o}(),o.fromPortalItem=function(e){return h.fromPortalItem(e)};var i=o.prototype;return i.initialize=function(){this.when().catch((e=>{var t,r;y.isAbortError(e)||s.getLogger(this.declaredClass).error("#load()",`Failed to load layer (title: '${null!=(t=this.title)?t:"no title"}', id: '${null!=(r=this.id)?r:"no id"}')`,{error:e})}))},i.destroy=function(){if(this.parent){const e=this,t=this.parent;"layers"in t&&t.layers.includes(e)?t.layers.remove(e):"tables"in t&&t.tables.includes(e)?t.tables.remove(e):"baseLayers"in t&&t.baseLayers.includes(e)?t.baseLayers.remove(e):"baseLayers"in t&&t.referenceLayers.includes(e)&&t.referenceLayers.remove(e)}},i.fetchAttributionData=function(){var e=t._asyncToGenerator((function*(){const e=this.attributionDataUrl;if(this.hasAttributionData&&e){return(yield a(e,{query:{f:"json"},responseType:"json"})).data}throw new n("layer:no-attribution-data","Layer does not have attribution data")}));function r(){return e.apply(this,arguments)}return r}(),t._createClass(o,[{key:"hasAttributionData",get:function(){return null!=this.attributionDataUrl}},{key:"parsedUrl",get:function(){const e=this.url;return e?c.urlToObject(e):null}}]),o}(i.EventedMixin(l.IdentifiableMixin(p)));r.__decorate([u.property({type:String})],L.prototype,"attributionDataUrl",void 0),r.__decorate([u.property({type:v})],L.prototype,"fullExtent",void 0),r.__decorate([u.property({readOnly:!0})],L.prototype,"hasAttributionData",null),r.__decorate([u.property({type:String,clonable:!1})],L.prototype,"id",void 0),r.__decorate([u.property({type:Boolean,nonNullable:!0})],L.prototype,"legendEnabled",void 0),r.__decorate([u.property({type:["show","hide","hide-children"]})],L.prototype,"listMode",void 0),r.__decorate([u.property({type:Number,range:{min:0,max:1},nonNullable:!0})],L.prototype,"opacity",void 0),r.__decorate([u.property({clonable:!1})],L.prototype,"parent",void 0),r.__decorate([u.property({readOnly:!0})],L.prototype,"parsedUrl",null),r.__decorate([u.property({type:Boolean})],L.prototype,"popupEnabled",void 0),r.__decorate([u.property({type:Boolean})],L.prototype,"attributionVisible",void 0),r.__decorate([u.property({type:g})],L.prototype,"spatialReference",void 0),r.__decorate([u.property({type:String})],L.prototype,"title",void 0),r.__decorate([u.property({readOnly:!0,json:{read:!1}})],L.prototype,"type",void 0),r.__decorate([u.property()],L.prototype,"url",void 0),r.__decorate([u.property({type:Boolean,nonNullable:!0})],L.prototype,"visible",void 0),L=r.__decorate([f.subclass("esri.layers.Layer")],L);return L}));
