UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 41.9 kB
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{addTokenParameter as s}from"../../../kernel.js";import l from"../../../request.js";import"../../../symbols.js";import r from"../../../core/Accessor.js";import i from"../../../core/Collection.js";import n from"../../../core/Handles.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{unwrap as u,isSome as c}from"../../../core/maybe.js";import{eachAlways as d,debounce as y}from"../../../core/promiseUtils.js";import{on as h,watch as m,whenOnce as f,initial as p}from"../../../core/reactiveUtils.js";import{px2pt as g}from"../../../core/screenUtils.js";import{addQueryParameters as b}from"../../../core/urlUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as L}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as v}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as E}from"../../../layers/support/ExportImageParameters.js";import{isDateField as C}from"../../../layers/support/fieldUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as F}from"../../../renderers/support/rendererConversion.js";import V from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as T}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as z}from"../../../symbols/support/previewUtils.js";import{renderSymbol as x}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as j,renderDotDensityPreviewHTML as D,renderPieChartPreviewHTML as O,renderPreviewHTML as P}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as M}from"../../../symbols/support/utils.js";import{getClusterSizeVariable as A}from"./clusterUtils.js";import{getColorFromPointCloudStops as B,getRampStopsForPointCloud as k,getStrectchRampStops as U,getRampStops as N}from"./colorRampUtils.js";import{getHeatmapRampStops as q}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as $,getRelationshipRampElement as W}from"./relationshipRampUtils.js";import{getRampStops as G,REAL_WORLD_MAX_SIZE as J,REAL_WORLD_MIN_SIZE as Q}from"./sizeRampUtils.js";import{SPECIAL_CHARS_LESS_THAN as H,SPECIAL_CHARS_GREATER_THAN as K,getSymbolForFlowRenderer as X,getMedianColor as Y,RGB_IMG_SOURCE as Z}from"./utils.js";import{formatNumberLabel as ee}from"../../smartMapping/support/utils.js";import te from"../../../symbols/SimpleMarkerSymbol.js";import se from"../../../symbols/SimpleFillSymbol.js";const le="https://utility.arcgis.com/sharing/tools/legend",re="esri.layers.ImageryLayer",ie="esri.layers.ImageryTileLayer",ne="esri.layers.WCSLayer",ae=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,oe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),ue=new te({size:6,outline:{color:[128,128,128,.5],width:.5}}),ce=new se({style:"solid"});function de(e){return"flow"===e.type}function ye(e){return"vector-field"===e.type}function he(e){return"raster-colormap"===e.type}function me(e){return"raster-stretch"===e.type}function fe(e){return"raster-shaded-relief"===e.type}function pe(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function ge(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function be(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Se(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function _e(e){return ve(e)||we(e)||Ee(e)||Le(e)}function Le(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function we(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Re(e,t){return pe(e)||ge(e)||be(e)||Se(e)||Ce(e)||Ie(e)?"2d"===t.type||F(e):me(e)||he(e)||fe(e)||ve(e)||we(e)||Ee(e)||ye(e)||de(e)}function Fe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Ve(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Te(e){return"esri.layers.VoxelLayer"===e.declaredClass}function ze(e){return"esri.layers.WMSLayer"===e.declaredClass}function xe(e){return"esri.layers.WMTSLayer"===e.declaredClass}function je(e){return"esri.layers.MapImageLayer"===e.declaredClass}function De(e){return"esri.layers.TileLayer"===e.declaredClass}function Oe(e){return"esri.layers.FeatureLayer"===e.declaredClass}function Pe(e){return e.declaredClass===re}function Me(e){return e.declaredClass===ie}function Ae(e){return e.declaredClass===ne}function Be(e){return"stretch-ramp"===e.type}function ke(e){return"univariate-color-size"===("authoringInfo"in e&&e?.authoringInfo)?.type}function Ue(e){const t="authoringInfo"in e&&e?.authoringInfo;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}const Ne=new te({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let qe={},$e=class extends r{constructor(e){super(e),this._handles=new n,this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this.children=new i,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this._handles.add([h((()=>this.children),"change",(t=>{const{added:s,removed:l}=t,r=this._handles;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;r.add(m((()=>t.ready),e,p),s)})),l.forEach((e=>r.remove(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(qe={})}destroy(){this._handles.destroy(),this._handles=null,this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(qe=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new v,t.effect=e.effect,t.endTransitions(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,l=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=l?l*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view&&this.view.scale}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?this._isRendererScaleDriven(e.renderer):this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],void this.notifyChange("ready");const t=Array.from(e,(e=>{if(Oe(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet&&e.featureSet.features.length){const t=e.layerDefinition,s=t&&t.drawingInfo,l=s&&R(s.renderer),r=oe.read(t.geometryType);return l?this._getRendererLegendElements(l,{title:e.name,geometryType:r}):(o.getLogger(this.declaredClass).warn("drawingInfo not available!"),null)}return null}));try{const e=[];await d(t).then((t=>{t.forEach((({value:t})=>t&&e.push(...t)))})),this.legendElements=e,this.notifyChange("ready")}catch(s){o.getLogger(this.declaredClass).warn("error while building legend for layer!",s)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("error while building legend for layer!",t)}}async buildLegendElementsForFeatureReduction(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Te(e))this._constructLegendElementsForVoxellayer();else if(xe(e))this._constructLegendElementsForWMTSlayer();else if(ze(e))await this._constructLegendElementsForWMSSublayers();else if(Fe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(je(e)||De(e)||Ve(e))await this._constructLegendElementsForSublayers();else{this._handles.remove("imageryLayers-watcher");let t="default";if(Pe(e)){t=(e?.renderingRule?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(Pe(e)||Me(e)){const t=m((()=>["renderingRule"in e&&e.renderingRule,e.bandIds]),(()=>y((async()=>{qe.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this._handles.add(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s&&s.infos.length&&(Pe(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await d(s)})).catch((e=>{o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,s=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!s&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await f((()=>!t.updating));const l=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();l.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(l):"queryFeatureCount"in e&&await e.queryFeatureCount(l))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){const e=this.children;return!!e.length&&e.some((e=>e.ready))}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e&&e.valueExpression;if(ae.test(t))return!0;const s="visualVariables"in e&&e.visualVariables;return!!s&&s.some((e=>this._isScaleDrivenSizeVariable(e)))}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,l=t.maxSize;return"object"==typeof s&&s?this._isScaleDrivenSizeVariable(s):"object"==typeof l&&l?this._isScaleDrivenSizeVariable(l):!!t.expression||ae.test(t.valueExpression)}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some((e=>this._isLayerScaleDriven(e)));const t=e.parent;if(!1===e.loaded&&t&&je(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const s of t.sourceJSON.layers)if(s.id===e.source.mapLayerId&&(s.minScale>0||s.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxellayer(){this.legendElements=[],this._handles.remove("voxel-style-watcher"),this._handles.remove("voxel-current-variable");const e=this.layer;this._handles.add(m((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxellayer())),"voxel-current-variable"),this._handles.add(m((()=>e.getVariableStyles()),(()=>this._constructLegendElementsForVoxellayer())),"voxel-style-watcher");const t=u(e.getVariableStyle(null)),s=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new se({color:t.color,outline:null})})})),e.length&&s.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:l}=t.transferFunction,r=e.toArray().reverse(),i=l.map(((e,t)=>`${0===t?H:K} ${ee(e)}`)).reverse(),n=r.map((e=>({color:e.color,value:null,label:null})));n[0].label=i[0],n[n.length-1].label=i[1],s.push({type:"color-ramp",title:t.label,infos:n,preview:j(r.map((e=>e.color)))})}const l=e.opacity,r=s.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,l)));await d(r),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this._handles.remove("wmts-activeLayer-watcher");const e=this.layer.activeLayer;if(this._handles.add(m((()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer}),(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher"),e.styleId&&e.styles){let t=null;e.styles.some((s=>e.styleId===s.id&&(t=s.legendUrl,!0))),t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}])}this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this._handles.remove("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this._handles.add(m((()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers}),(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const s=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const l=e.toArray();for(const r of l){const e=m((()=>[r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForWMSSublayers()));if(this._handles.add(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e&&e.infos.length&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const s=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let s=e.legendUrl;if(!s)return;const r={type:"symbol-table",title:e.title||e.name||e.id&&e.id+"",infos:[]};t&&(s=b(s,t));let i=null;const n=e.layer?.opacity;try{i=(await l(s,{responseType:"image"})).data,i&&(i.style.opacity=n)}catch{}return r.infos.push({src:s,preview:i,opacity:n}),r}_getLegendLayers(e,t){const s=qe&&qe[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return qe[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Pe(t)){const e=t.exportImageServiceParameters.renderingRule;if(e&&(s.renderingRule=JSON.stringify(e.rasterFunctionDefinition||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:l,customParameters:r}=t;s={raster:e,viewId:l,...s,...r}}}let r=t.url.replace(/(\/)+$/,"");if("version"in t&&t.version>=10.01){const e=r.indexOf("?");e>-1?r=r.substring(0,e)+"/legend"+r.substring(e):r+="/legend"}else{const e=r.toLowerCase().indexOf("/rest/"),t=r.substring(0,e)+r.substring(e+5,r.length);r=le+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return l(r,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(m((()=>e.sublayers),(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const l=e.toArray();for(const r of l){const e=m((()=>["renderer"in r&&r.renderer,r.opacity,r.title,r.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible){const e=r&&null!=r.opacity?r.opacity:null,l=null!=e?e*t:t;if("building-group"===r.type){const e={type:"symbol-table",title:r.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(r.sublayers,l);e.infos.push(...t),s=[e,...s]}else if(r.renderer){s=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:l,sublayer:r}),...s]}}}return s.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(m((()=>e.sublayers),(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this.declaredClass).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForSublayers(e,t,s){const l=this.layer;let r=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let i=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(i=this.sublayerIds.map((e=>l.findSublayerById(e))).filter(Boolean));for(const n of i){const e=m((()=>[n.renderer,n.opacity,n.title,n.visible,n.legendEnabled]),(()=>this._constructLegendElementsForSublayers()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||n.visible&&n.legendEnabled&&this._isSublayerInScale(n)){const e=n&&null!=n.opacity?n.opacity:null,i=null!=e?e*t:t,a=!!Ve(l)||n.originIdOf("renderer")>L.SERVICE;if(n.renderer&&!n.sublayers&&a){await n.load();r=[...await this._getRendererLegendElements(n.renderer,{title:n.title,opacity:i,sublayer:n}),...r]}else{const e=await this._generateSymbolTableElementForSublayer(n,i,s);e&&r.unshift(e)}}}return r.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,l=e.source;let r=null;if(!(!l||"map-layer"===l.type&&l.mapLayerId===e.id&&(!l.gdbVersion||l.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>L.SERVICE||e.originIdOf("labelingInfo")>L.SERVICE||e.originIdOf("labelsVisible")>L.SERVICE){const e=new E({layer:this.layer});r=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const i=r||`${t.uid}-default`;(await this._getLegendLayers(i,r)).forEach((e=>s.set(e.layerId,e)))}const l=s.get(e.id);if((!l||l?.subLayerIds&&l.defaultVisibility)&&e.sublayers){const l=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendLayer(l,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e||!e.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const l=t?.renderer;let r=t?.title||e.layerName;if(l&&(!t||t?.originIdOf("renderer")>L.SERVICE)){const e=t?.title||this._getRendererTitle(l,t);e&&(r&&"string"!=typeof e&&"title"in e&&(e.title=r),r=e)}const i={type:"symbol-table",title:r,legendType:e.legendType?e.legendType:null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups?.length>0?e.legendGroups.forEach((t=>{const l={type:"symbol-table",title:t.heading,legendType:e.legendType?e.legendType:null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};l.infos?.length>0&&i.infos.push(l)})):i.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),i.infos.length>0?i:null}_generateSymbolTableElementInfosForLegendLayer(e,t,l){return e.map((e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(0===r.indexOf("http"))return null;r=s(`${this.layer.url}/${t}/images/${r}`)}return{label:e.label,src:r,opacity:l??this.opacity,width:e.width,height:e.height}})).filter((e=>!!e))}_isSublayerInScale(e){const t=e.minScale||0,s=e.maxScale||0;return!(t>0&&t<this.scale||s>this.scale)}_isLegendLayerInScale(e,t){const s=t||this.layer;let l=null,r=null,i=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(l=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(r=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(l=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,r=Math.max(s.maxScale,e.maxScale)),(l>0&&l<this.scale||r>this.scale)&&(i=!1),i}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&this.layer.version<10.1||0===e.length)return e;const s=t.renderer,l=e.some((e=>e.values));let r=null,i=null;return l&&e.some(((e,t)=>(e.values||(r=t,i=e,i.label||(i.label="others")),null!=i))),s?"unique-value"===s.type?i&&(e.splice(r,1),e.push(i)):"class-breaks"===s.type&&(i&&e.splice(r,1),e.reverse(),i&&e.push(i)):i&&(e.splice(r,1),e.push(i)),e}async _getRendererLegendElements(e,t={}){if(!Re(e,this.view))return o.getLogger(this.declaredClass).warn(`Renderer of type '${e.type}' not supported!`),[];if(_e(e))return this._constructPointCloudRendererLegendElements(e,t);if(Ce(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Ie(s)?this._constructPieChartRendererLegendElements(s):this._constructRendererLegendElements(s,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t):[]}_getPointCloudRendererTitle(e){return e.legendOptions&&e.legendOptions.title||e.field}_constructPointCloudRendererLegendElements(e,t={}){const s=t.title,l=[];let r=null,i=null;if(ve(e))r={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{r.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ue,e.color)})}));else if(we(e)){const t=e.stops;let l=null;if(t.length&&(1===t.length&&(l=t[0].color),!l)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){l=B(e+(s-e)/2,t)}}r={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ue,l||ue.color)}]};const n=k(e.stops);i={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:j(n.map((e=>e.color)))}}else Ee(e)&&(r={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos.forEach((e=>{r.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ue,e.color)})})));r&&r.infos.length&&l.push(r),i&&i.infos.length&&l.push(i);const n=l.reduce(((e,t)=>e.concat(t.infos)),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return d(n).then((()=>l))}_getElementInfoForDotDensity(e,t){const{backgroundColor:s,outline:l,dotSize:r}=e,i=this.effectList?.effects.map((e=>e.toJSON())),n=w(i),a=r+"-"+t+"-"+s+"-"+(l&&JSON.stringify(l.toJSON()))+"-"+n,o=this._dotDensityUrlCache,u=o.has(a)?o.get(a):D(e,t);o.set(a,u);const c={shape:{type:"image",x:0,y:0,width:u.width,height:u.height,src:u.src},fill:null,stroke:null,offset:[0,0]},d=x([[c]],[u.width,u.height],{effectView:this.effectList});return{opacity:1,src:u.src,preview:d,width:u.width,height:u.height}}_constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions&&e.legendOptions.unit,l={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};return e.attributes.forEach((t=>{const s=this._getElementInfoForDotDensity(e,t.color);s.label=t.label||t.valueExpressionTitle||t.field,l.infos.push(s)})),Promise.resolve([l])}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[];let l=null;const r=e.outline;e.attributes.forEach((e=>{const t=new te({color:e.color,outline:r}),l=e.label||e.valueExpressionTitle||e.field;s.push({label:l,symbol:t})}));const i=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new te({color:e.othersCategory.color,outline:r});l=e.othersCategory.label||"Other",s.push({label:l,symbol:t})}if(e.defaultColor?.a){const t=new te({color:e.defaultColor,outline:r});s.push({label:e.defaultLabel,symbol:t})}const n=await this._getVisualVariableLegendElements(e,this.layer)||[];if(s.length){n.unshift({type:"symbol-table",title:null,infos:s});const t=i.filter((e=>e.label!==l)).map((e=>e.symbol.color)).filter(Boolean),a=O(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:r});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await d(a),n}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:l}=t,r=l||this.layer;this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const i=await this._getVisualVariableLegendElements(e,r)||[],n={type:"symbol-table",title:s||this._getRendererTitle(e,r),infos:[]};let a=null,o=!1;const c=new Set;if(de(e)&&!this._hasSizeRamp){const t=await X(e);n.infos.push({label:null,symbol:t})}else if(ke(e)){let t=s;const l=Ue(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",r=i.findIndex((e=>"color-ramp"===e.type)),n=-1!==r?i.splice(r,1)[0]:null,a=i.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?i.splice(a,1)[0]:null,u=[];n&&(t=n.title,u.push(n)),o&&(t=o.title,u.push(o)),u.length>0&&i.push({type:l,title:t,infos:u})}else if(Se(e)){const t=q(e);i.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,r),infos:t,preview:j(t.map((e=>e.color)),{effectList:this.effectList})})}else if(be(e)){const t=e&&e.authoringInfo;if(t&&"relationship"===t.type){const{focus:s,numClasses:l,field1:a,field2:o}=t;if(l&&a&&o){const t=[a,o];let u=$(s)||0;for(const e of t){const{field:t,normalizationField:s,label:l}=e,i=l||{field:this._getFieldAlias(t,r),normField:s&&this._getFieldAlias(s,r)},a=Ne.clone();a.angle=u,n.infos.push({label:i,symbol:a}),c.add(a),u+=90}const d=W({focus:s,numClasses:l,infos:e.uniqueValueInfos});i.unshift(d)}}else if(Pe(this.layer)||Me(this.layer))e.uniqueValueInfos.forEach((e=>{e.symbol&&n.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}));else{const{field:t,field2:l,field3:i,fieldDelimiter:a,valueExpression:u,defaultSymbol:c}=e,d=!(!t&&!u||!l&&!i),y=[];if(e.uniqueValueGroups.forEach((e=>{const s={type:"symbol-table",title:e.heading,infos:[]};e.classes.forEach((e=>{const{symbol:n,values:o}=e;if(n){const c=[],y=[];for(const e of o){const{value:s,value2:n,value3:o}=e,h=[],m=[];(t||u)&&(h.push(s),m.push(this._getDomainName(t,s,r))),l&&(h.push(n),m.push(this._getDomainName(l,n,r))),i&&(h.push(o),m.push(this._getDomainName(i,o,r))),c.push(d?h.join(a||""):h[0]),y.push(m.join(" - "))}const h=c.join(", ");let m=e.label;if(!m){const e=y.filter(Boolean);m=e.length?e.join(", "):h}s.infos.push({label:m,value:h,symbol:n})}})),s.infos.length&&y.push(s)})),y.length){const t=y[0];1===y.length&&"title"in t&&!t.title?n.infos.push(...t.infos):(c&&(y.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:c}]}),o=!0),n.infos.push(...y)),s||e.legendOptions&&e.legendOptions.title||e.valueExpressionTitle||(n.title=null)}}e.defaultSymbol&&!o&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(ge(e)){a=this._isUnclassedRenderer(e);(!a||!this._hasSizeRamp)&&(e.classBreakInfos.forEach((e=>{e.symbol&&n.infos.unshift({label:e.label||(a?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),a&&(n.title=null),this._updateInfosforClassedSizeRenderer(e,n.infos)),e.defaultSymbol&&!a&&(n.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),o=!0)}else if(me(e))if(Me(this.layer)||Ae(this.layer)){const t=this._constructTileImageryStretchRendererElements(e);Be(t)?i.push(t):n.infos=t}else{const t=this.layer;let s,l;e.statistics&&e.statistics.length&&(s=null!=e.statistics[0].min?e.statistics[0].min:e.statistics[0][0],l=null!=e.statistics[0].max?e.statistics[0].max:e.statistics[0][1]);let r=[];const a=u(t.renderingRule?await t.generateRasterInfo(t.renderingRule):t.serviceRasterInfo),o=a.keyProperties.BandProperties,c=I(a.pixelType);if(1===a.bandCount){const r=t.bandIds?.[0]||0;s=null!=s?s:a.statistics?a.statistics[r].min:c[0],l=null!=l?l:a.statistics?a.statistics[r].max:c[1],s||l?i.push(this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()}else t.bandIds&&1===t.bandIds.length?(s=null!=s?s:a.statistics?a.statistics[t.bandIds[0]].min:c[0],l=null!=l?l:a.statistics?a.statistics[t.bandIds[0]].max:c[1],s||l?i.push(this._getStretchLegendElements(e,{min:s,max:l})):this._getServerSideLegend()):a.bandCount>=3?o&&o.length>=a.bandCount?t.bandIds&&3===t.bandIds.length?(r=t.bandIds.map((e=>o[e].BandName)),n.infos=this._createSymbolTableElementMultiBand(r)):"lerc"===t.format?(r=[0,1,2].map((e=>o[e].BandName)),n.infos=this._createSymbolTableElementMultiBand(r)):this._getServerSideLegend():"lerc"===t.format?(r=["band1","band2","band3"],n.infos=this._createSymbolTableElementMultiBand(r)):this._getServerSideLegend():this._getServerSideLegend()}else if(he(e))e.colormapInfos.forEach((e=>{n.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ce,e.color)})}));else if(pe(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in r&&r.pointSymbol;break;case"polyline":s="lineSymbol"in r&&r.lineSymbol;break;case"polygon":s="polygonSymbol"in r&&r.polygonSymbol}const l=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&l&&n.infos.push({label:e.label,symbol:s})}else if(ye(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),n.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{n.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):n.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else fe(e)&&i.push(this._getStretchLegendElements(e,{min:0,max:255}));const y=e.defaultSymbol;!y||o||pe(e)||a&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||i.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),n.infos.length&&i.unshift(n);const h=null==t.opacity?this.opacity:t.opacity,m=this._isTallSymbol("visualVariables"in e&&e.visualVariables),f=Pe(this.layer)||Me(this.layer),p=i.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,h,{isDefault:e.symbol===y,applyScaleDrivenSize:!c.has(e.symbol),symbolConfig:{isTall:m,isSquareFill:f},effectList:c.has(e.symbol)?null:this.effectList})));return e=null,await d(p),i}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}_constructTileImageryStretchRendererElements(e){const t=this.layer,{rasterInfo:s}=t.raster,l=s.bandCount||e.statistics.length;let r,i,n=[];const a=s.keyProperties&&s.keyProperties.BandProperties,o=e?.statistics?.length?e.statistics:s?.statistics;if(o)r=void 0!==o[0].min?o[0].min:o[0][0],i=o[0].max||o[0][1];else{const e=I(s.pixelType);r=e[0],i=e[1]}if(t.hasStandardTime()&&(r=t.getStandardTimeValue(r),i=t.getStandardTimeValue(i)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:r,max:i});function u(e){const l=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.bandCount,3)).keys())).map((t=>e&&e[t]&&e[t].BandName||"band"+(t+1)));return l.length<3?l.push(l[1]):l.length>3&&l.splice(3),l}return n=a&&a.length>=l?u(a):u(),this._createSymbolTableElementMultiBand(n)}_getStretchLegendElements(e,t){const s=e.colorRamp,l=U(s,t);return{type:"stretch-ramp",title:"",infos:l,preview:j(l.map((e=>e.color)))}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,s=t&&"symbol"in t&&t.renderer;return s&&!0!==s?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t&&t.symbol}async _getSizeLegendElement(e,t,s,l){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await G(s,t,await Y(s),this.scale,this.view.type,l,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,l)=>{t.push({label:{colorName:s[l],bandName:e},src:Z[l],opacity:this.opacity??1})})),t}_updateInfosforClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,l=e.classBreakInfos.some((e=>M(e.symbol)));if(s&&l){const s=J,l=Q,r=e.classBreakInfos.length,i=(s-l)/(r>1?r-1:r);t.forEach(((e,t)=>{e.size=s-i*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let l=0;l<e.length&&(!t||!s);l++){const r=e[l];"size"===r.type&&("height"===r.axis&&(t=!0),"width-and-depth"===r.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let l=!s?.isDefault&&null==e.size&&this._hasSizeRamp?g(z.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");l=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return P(e.symbol,{size:l,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer&&this.layer.renderer,s=e.renderer?.clone()||t?.clone(),l=u(A(this.layerView._effectiveRenderer,this.view));if(l&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!ae.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;l.legendOptions=new V({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([l]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),l=await Y(s);if(ge(s)||be(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,l).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(s.symbol||s.defaultSymbol,s.defaultSymbol?null:l).then((e=>{this._applySymbolToRenderer(s,e,pe(s))})).catch((()=>{this._applySymbolToRenderer(s,null,pe(s))}))),d(t).then((()=>s))}_applySymbolToRenderer(e,t,s){s?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const s=this._webStyleSymbolCache;try{const l=await("2d"===this.view.type?e.fetchCIMSymbol({cache:s}):e.fetchSymbol({cache:s}));return this._getAppliedCloneSymbol(l,t)}catch{throw o.getLogger(this.declaredClass).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const l=e.clone(),r=s&&s.toRgba();return l.type.includes("3d")?this._applyColorTo3dSymbol(l,r):"cim"===l.type?T(l,s):l.color&&(l.color=new t(r||l.color)),l}_applyColorTo3dSymbol(e,s){s&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(s))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const s=e.visualVariables,l=[],r=[],i=[];for(const c of s)"color"===c.type?l.push(c):"size"===c.type?r.push(c):"opacity"===c.type&&i.push(c);const n=[...l,...r,...i];let a,o;if(0===l.length&&ge(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];a=t&&t.symbol}if(0===l.length&&pe(e)&&(a=e.symbol),a)if(a.type.includes("3d")){const e=a.symbolLayers.getItemAt(0);"water"===e.type?c(e.color)&&(o=e.color):c(e.material)&&c(e.material.color)&&(o=e.material.color)}else a.url||(o=a.color);const u=this.effectList;return(await Promise.all(n.map((async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const l=de(e)?s.field:this._getRampTitle(s,t);let r=null;const i="getField"in t&&t.getField&&t.getField(s.field),n=i&&C(i);if("color"===s.type){const e=await N(s,null,n);r={type:"color-ramp",title:l,infos:e,preview:j(e.map((e=>e.color)),{effectList:u})},this._hasColorRamp||(this._hasColorRamp=!(null==r.infos||!r.infos.length))}else if("size"===s.type&&"outline"!==s.target)ae.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(r=await this._getSizeLegendElement(l,s,e,n),this._hasSizeRamp||(this._hasSizeRamp=!(null==r.infos||!r.infos.length)));else if("opacity"===s.type){const e=await N(s,o,n);r={type:"opacity-ramp",title:l,infos:e,preview:j(e.map((e=>e.color)),{effectList:u})},this._hasOpacityRamp||(this._hasOpacityRamp=!(null==r.infos||!r.infos.length))}return r&&r.infos?r:null}})))).filter((e=>!!e))}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const l="getField"in s&&s.getField&&s.getField(e),r=l&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(l.name):null;return r&&"coded-value"===r.type?r.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,s=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,l="popupTemplate"in e&&e.popupTemplate,r=l&&l.fieldInfos;if(r)for(const t of r)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,l=e.normalizationField,r=!1,i=!1,n=!1,a=null;s="function"==typeof s?null:s,l="function"==typeof l?null:l;const o=e.legendOptions&&e.legendOptions.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo&&t.renderer.authoringInfo.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const s=e[t];if("color"===s.type){if("ratio"===s.style){r=!0;break}if("percent"===s.style){i=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),ratio:r,ratioPercent:i,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions&&s.legendOptions.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let l=s.field,r=null,i=null;if(ge(s)&&(r=s.normalizationField,i="percent-of-total"===s.normalizationType),l="function"==typeof l?null:l,r="function"==typeof r?null:r,be(s)){const{field2:e,field3:r,fieldDelimiter:i}=s;let n=l&&this._getFieldAlias(l,t);return e&&(n=`<${n}>${i}<${this._getFieldAlias(e,t)}>`,r&&(n=`${n}${i}<${this._getFieldAlias(r,t)}>`)),n}let n=null;return(l||r)&&(n={field:l&&this._getFieldAlias(l,t),normField:r&&this._getFieldAlias(r,t),normByPct:i}),n}_getFieldAlias(e,t){const s="popupTemplate"in t&&t.popupTemplate,l=s&&s.fieldInfos;let r=null;l&&l.some((t=>e===t.fieldName&&(r=t,!0)));let i=null;"getField"in t&&t.getField?i=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(i=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(!r&&"popupTemplate"in a&&a.popupTemplate&&a.popupTemplate.fieldInfos&&a.popupTemplate.fieldInfos.some((t=>e?.toLowerCase()===t.fieldName?.toLowerCase()&&(r=t,!0))),"fields"in a&&a.fields&&(n=a.fields.find((t=>t.name?.toLowerCase()===e?.toLowerCase()))));const o=r||i||n;let u=null;return o&&(u=r?.label||i?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return ge(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(s=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),s}};e([S()],$e.prototype,"children",void 0),e([S({readOnly:!0})],$e.prototype,"effectList",null),e([S()],$e.prototype,"layerView",void 0),e([S()],$e.prototype,"layer",void 0),e([S()],$e.prototype,"legendElements",void 0),e([S({readOnly:!0})],$e.prototype,"opacity",null),e([S()],$e.prototype,"parent",void 0),e([S({readOnly:!0,dependsOn:[]})],$e.prototype,"ready",null),e([S()],$e.prototype,"hideLayersNotInCurrentView",void 0),e([S()],$e.prototype,"keepCacheOnDestroy",void 0),e([S()],$e.prototype,"respectLayerVisibility",void 0),e([S({readOnly:!0})],$e.prototype,"scale",null),e([S()],$e.prototype,"sublayerIds",void 0),e([S({readOnly:!0})],$e.prototype,"isScaleDriven",null),e([S()],$e.prototype,"title",void 0),e([S({readOnly:!0,dependsOn:["ready"],value:0})],$e.prototype,"version",null),e([S()],$e.prototype,"view",void 0),$e=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],$e);const We=$e;export{We as default};