@arcgis/core 4.33.0-next.20250425 → 4.33.0-next.20250427
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WebLinkChart.js +1 -1
- package/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{d696abbb1b13ac1a689b.js → 345993291540433d3d92.js} +1 -1
- package/assets/esri/core/workers/chunks/{db5913824d5e5a2a8365.js → 360c8cff7c3b25d2b2d2.js} +1 -1
- package/assets/esri/core/workers/chunks/73f9c3a74a815baa239c.js +1 -0
- package/assets/esri/core/workers/chunks/76575d2c1c56e37c1315.js +319 -0
- package/assets/esri/core/workers/chunks/{f2cef954b58c6604642c.js → 87dcfbbcf290e0fa5c0f.js} +160 -167
- package/assets/esri/core/workers/chunks/91acd69dcf7dac109017.js +1 -0
- package/assets/esri/core/workers/chunks/{265f69d153b7b6f07e42.js → 92836e3a2c5226296fec.js} +1 -1
- package/assets/esri/core/workers/chunks/{75a04b073231da70c18d.js → d44e99b4bb1cec6a922b.js} +1 -1
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_Legend.scss +64 -0
- package/assets/esri/themes/base/widgets/_OrientedImageryViewerNavigationUI.scss +77 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
- package/chunks/boundedPlane.js +1 -1
- package/geometry/support/boundedPlane.js +1 -1
- package/interfaces.d.ts +328 -65
- package/layers/KnowledgeGraphLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/ogc/wfsUtils.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/package.json +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/support/spikeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/Slice/SliceController.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/FeatureProcessingContext.js +5 -0
- package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/Factory.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/SimpleFeatureRenderer.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/ViewSlice.js +5 -0
- package/views/3d/webgl-engine/core/shaderLibrary/shading/AnalyticalSkyModel.glsl.js +3 -6
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +15 -15
- package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js +0 -9
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/SliceHelper.js +1 -1
- package/views/3d/webgl-engine/shaders/BlackLevelLightSoftCompression.glsl.js +10 -0
- package/views/SceneView.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
- package/webscene/types.d.ts +5 -0
- package/webscene/types.js +5 -0
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/Legend/styles/card/SizeRamp.js +1 -1
- package/widgets/Legend/styles/classic/SizeRamp.js +1 -1
- package/widgets/Legend/styles/support/sizeRampUtils.js +5 -0
- package/widgets/Legend/styles/support/univariateUtils.js +1 -1
- package/widgets/Legend/styles/support/utils.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
- package/widgets/OrientedImageryViewer/components/NavigationNode.js +5 -0
- package/widgets/OrientedImageryViewer/components/NavigationUI.js +5 -0
- package/widgets/OrientedImageryViewer/components/NavigationUIViewModel.js +5 -0
- package/widgets/OrientedImageryViewer/components/imageNavigationUtils.js +5 -0
- package/widgets/OrientedImageryViewer/css.js +1 -1
- package/widgets/OrientedImageryViewer/utils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/ShadowCast/DiscreteOptions.d.ts +4 -0
- package/widgets/ShadowCast/DiscreteOptions.js +1 -1
- package/widgets/ShadowCast/DurationOptions.d.ts +4 -0
- package/widgets/ShadowCast/DurationOptions.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/ShadowCast/ThresholdOptions.d.ts +4 -0
- package/widgets/ShadowCast/ThresholdOptions.js +1 -1
- package/widgets/TimeZoneLabel.js +1 -1
- package/assets/esri/core/workers/chunks/7c7ff11246479382974c.js +0 -1
- package/assets/esri/core/workers/chunks/b53300b46646cfad2526.js +0 -319
- package/assets/esri/core/workers/chunks/bd0dbad694ce5531deab.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import r from"../../../Widget.js";import{css as o}from"./css.js";import{renderSpikeRamp as n}from"../support/sizeRampUtils.js";import{attachToNode as l}from"../../support/styleUtils.js";import"../../../support/widgetUtils.js";import{tsx as a}from"../../../support/jsxFactory.js";const c="#ddd",p=window.devicePixelRatio;function d(e){if(!e)return;if(e.type.includes("3d")){if(!e.symbolLayers?.length)return;const t=e.symbolLayers.at(-1),s=t.resource?.primitive;return"circle"===s||"cross"===s||"kite"===s||"sphere"===s||"cube"===s||"diamond"===s}const t=e.style;return"circle"===t||"diamond"===t||"cross"===t}function m(e){if(e){if(e.type.includes("3d")){if(!e.symbolLayers?.length)return;const t=e.symbolLayers.at(-1),s=t?.resource?.primitive;return"triangle"===s||"cone"===s||"tetrahedron"===s}return"triangle"===e.style}}let y=class extends r{constructor(e,t){super(e,t),this.hasIndicators=!1,this.legendElement=null,this.opacity=1}render(){if("spike"===this.legendElement.theme)return a("div",{styles:{display:"flex",flex:"1",justifyContent:"center"}},n(this.legendElement));const{legendElement:e,hasIndicators:t,opacity:s}=this,i=e.infos,r=i.at(0),c=i.at(-1);if(!r||!c)return null;const{label:p,...d}=r,{label:m,...y}=c;let u=d.preview,f=y.preview;const h={"flex-direction":t?"column":"row-reverse"};if(!u||!f)return null;u=u.cloneNode(!0),u.style.display="flex",f=f.cloneNode(!0),f.style.display="flex";const g={opacity:`${s??""}`};return a("div",{class:this.classes(o.layerRow,{[o.sizeRampRow]:t})},a("div",{class:o.rampLabel},t?p:m),a("div",{class:o.sizeRampContainer,styles:h},a("div",{afterCreate:l,bind:u,class:o.sizeRampPreview,styles:g}),this._renderSizeRampLines(e),a("div",{afterCreate:l,bind:f,class:o.sizeRampPreview,styles:g})),a("div",{class:o.rampLabel},t?m:p))}_renderSizeRampLines(e){const s=e.infos,i=s.at(0),r=s.at(-1);if(!i||!r)return null;const o=i.symbol,n=this.hasIndicators,y=i.size&&"number"==typeof i.size?i.size:0,u=r.size&&"number"==typeof r.size?r.size:0,f=i.outlineSize||0,h=r.outlineSize||0,g=t(y+f)*p,v=t(u+h)*p,b=n?g:g+50*p,x=n?g/2+50*p:g,z=m(o),j=d(o),w=document.createElement("canvas");w.width=b,w.height=x,w.style.width=w.width/p+"px",w.style.height=w.height/p+"px";const R=w.getContext("2d");if(n){R.beginPath();const e=0,t=0,s=b/2-v/2,i=x;R.moveTo(e,t),R.lineTo(s,i);const r=b,o=0,n=b/2+v/2,l=x;R.moveTo(r,o),R.lineTo(n,l)}else{R.beginPath();const e=0,t=x/2-v/2,s=b,i=0;R.moveTo(e,t),R.lineTo(s,i);const r=0,o=x/2+v/2,n=b,l=x;R.moveTo(r,o),R.lineTo(n,l)}return R.strokeStyle=c,R.stroke(),a("div",{afterCreate:l,bind:w,styles:n?{display:"flex",marginTop:`-${z?0:j?g/2:0}px`,marginBottom:`-${z?v:j?v/2:0}px`}:{display:"flex",marginRight:`-${z?0:j?g/2:0}px`,marginLeft:`-${z?0:j?v/2:0}px`}})}};e([s()],y.prototype,"hasIndicators",void 0),e([s()],y.prototype,"legendElement",void 0),e([s()],y.prototype,"messages",void 0),e([s()],y.prototype,"opacity",void 0),y=e([i("esri.widgets.Legend.styles.card.SizeRamp")],y);const u=y;export{u as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import o from"../../../Widget.js";import{css as t}from"./css.js";import{renderSpikeRamp as i}from"../support/sizeRampUtils.js";import{getTitle as l,attachToNode as p}from"../../support/styleUtils.js";import"../../../support/widgetUtils.js";import{tsx as m}from"../../../support/jsxFactory.js";let a=class extends o{constructor(e,s){super(e,s),this.legendElement=null}render(){const e=this.legendElement.infos.map((e=>this._renderRow(e))).filter(Boolean);return e.length?"spike"===this.legendElement.theme?i(this.legendElement):m("div",{class:t.layerBody},e):null}_renderRow(e){return e.preview?m("div",{class:t.layerRow,key:`${this.key}-${e.label}-row`},m("div",{class:this.classes(t.symbolContainer,t.sizeRamp)},m("div",{afterCreate:p,bind:e.preview,class:t.symbol})),m("div",{class:t.layerInfo},l(this.messages,e.label,!1)||"")):null}};e([s()],a.prototype,"legendElement",void 0),e([s()],a.prototype,"messages",void 0),a=e([r("esri.widgets.Legend.styles.classic.SizeRamp")],a);const n=a;export{n as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{pt2px as e}from"../../../../core/screenUtils.js";import{isWidthAndHeight as i}from"./utils.js";import{attachToNode as t}from"../../support/styleUtils.js";import"../../../support/widgetUtils.js";import{tsx as s}from"../../../support/jsxFactory.js";const n="#ddd",o=window.devicePixelRatio,a="esri-spike-ramp",p={spikeRampContainer:`${a}__container`,spikeRampPreviewContainer:`${a}__preview-container`,spikeRampPreview:`${a}__preview`,spikeRampSymbolPreview:`${a}__symbol-preview`,spikeRampLines:`${a}__lines`,spikeRampLabelsContainer:`${a}__labels-container`,spikeRampLabel:`${a}__label`};function r(e){return 5!==e.infos.length?null:s("div",{class:p.spikeRampContainer},s("div",{class:p.spikeRampPreviewContainer},l(e),m(e)),d(e))}function l(e){const[i,n,o]=h(e).map((({preview:e})=>{if(!e)return null;const i=e.cloneNode(!0);return i.classList.add(p.spikeRampSymbolPreview),i}));return i&&n&&o?s("div",{class:p.spikeRampPreview},s("div",{afterCreate:t,bind:o}),s("div",{afterCreate:t,bind:n}),s("div",{afterCreate:t,bind:i})):null}function m(a){const[{width:r,height:l},{width:m},{width:d,height:c}]=h(a).map((({size:t})=>i(t)?{width:e(t.width),height:e(t.height)}:{width:0,height:0})),v=10,b=r+m+d+3*v,u=l,w=document.createElement("canvas");w.width=(b+v)*o,w.height=u*o,w.style.width=w.width/o+"px",w.style.height=w.height/o+"px";const k=w.getContext("2d");k.beginPath();const f=b-(r/2+v),R=4,g=b,_=4;k.moveTo(f*o,R*o),k.lineTo(g*o,_*o);const y=b/2,C=(l-c)/2,L=b,x=(l-c)/2;k.moveTo(y*o,C*o),k.lineTo(L*o,x*o);const P=d/2,$=u-c,j=b,T=u-c;return k.moveTo(P*o,$*o),k.lineTo(j*o,T*o),k.strokeStyle=n,k.lineWidth=.5*o,k.stroke(),s("div",{afterCreate:t,bind:w,class:p.spikeRampLines})}function d(t){const[{label:n,height:o},{label:a},{label:r,height:l}]=h(t).map((({label:t,size:s})=>({label:t,height:i(s)?e(s.height):0}))),m=o-l,d={position:"absolute",top:"0"},c={position:"absolute",top:m/2+"px"},v={position:"absolute",top:`${m}px`};return s("div",{class:p.spikeRampLabelsContainer},s("div",{class:p.spikeRampLabel,styles:d},n),s("div",{class:p.spikeRampLabel,styles:c},a),s("div",{class:p.spikeRampLabel,styles:v},r))}function h(e){return e.infos.filter(((e,i)=>i%2==0))}export{r as renderSpikeRamp};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{pt2px as e}from"../../../../core/screenUtils.js";import"../../../../libs/maquette/projection.js";import{createProjector as t}from"../../../../libs/maquette/projector.js";import{
|
|
5
|
+
import{pt2px as e}from"../../../../core/screenUtils.js";import"../../../../libs/maquette/projection.js";import{createProjector as t}from"../../../../libs/maquette/projector.js";import{isNumber as i}from"../../../../support/guards.js";import{renderColorRampPreviewHTML as o}from"../../../../symbols/support/symbolUtils.js";import"../../../support/widgetUtils.js";import{tsx as l}from"../../../support/jsxFactory.js";const n=t(),r=10,s=20,a=10,c=20,f={univariateAboveAndBelowSymbol:"esri-univariate-above-and-below-ramp__symbol",colorRamp:"esri-legend__color-ramp"};function p(e="vertical"){const t="stroke:rgb(200, 200, 200);stroke-width:1";return"vertical"===e?l("svg",{height:"4",width:"10"},l("line",{style:t,x1:"0",x2:"10",y1:"2",y2:"2"})):l("svg",{height:"10",width:"10"},l("line",{style:t,x1:"5",x2:"5",y1:"0",y2:"10"}))}function m(e,t="vertical"){const i=document.createElement("div");return i.style.height=`${s}px`,i.className=f.univariateAboveAndBelowSymbol,null!=e&&(i.style.opacity=e.toString()),n.append(i,p.bind(null,t)),i}function u(t,o,l="vertical",n){t.infos.forEach(((t,r)=>{if(n&&2===r)t.preview=m(o,l);else{const o=(i(t.size)?e(t.size):0)+("horizontal"===l?c:a),n=t.preview,r="div"===n?.tagName.toLowerCase(),s=r?n:document.createElement("div");s.className=f.univariateAboveAndBelowSymbol,"horizontal"===l?s.style.width=`${o}px`:s.style.height=`${o}px`,!r&&n&&s.appendChild(n),t.preview=s}}))}function v(t,o="classic"){const l=t.infos,n=l.at(0),r=l.at(-1),s=i(n.size)?e(n.size):0,c=i(r.size)?e(r.size):0;return"classic"===o?(s+a)/2:(s-c)/2}function h(e,t){if(!e)return null;const i=e.infos.map((e=>e.color)),l=o("full"===t.type?i:"above"===t.type?i.slice(0,3):i.slice(2,5),{width:t.width,height:t.height,align:t.rampAlignment,effectList:t.effectList,ariaLabel:t.ariaLabel});return l.className=f.colorRamp,null!=t.opacity&&(l.style.opacity=t.opacity.toString()),l}function d(t,o,l,n="vertical"){let f=0;const p=t.infos,m=Math.floor(p.length/2),u="full"===o||"above"===o?0:m,v="full"===o||"below"===o?p.length-1:m;for(let h=u;h<=v;h++)if(l&&h===m)f+="horizontal"===n?r:s;else{const t=p[h].size;f+=(i(t)?e(t):0)+("horizontal"===n?c:a)}return Math.round(f)}function y(t,o,l,n="vertical"){const f=d(t,o,l,n),p=t.infos,m=Math.floor(p.length/2),u="full"===o||"above"===o?0:m,v="full"===o||"below"===o?p.length-1:m,h=i(p[u].size)?p[u].size:0,y=i(p[v].size)?p[v].size:0,b="full"===o?h+y:"above"===o?h:y,g=l?"vertical"===n?s:r:0,z="vertical"===n?a*("full"===o?2:1):c*("full"===o?2:1);return Math.round(f-(e(b)/2+g/2+z/2))}function b(e,t,i="vertical"){const o=e.infos;let l=o.find((({type:e})=>"size-ramp"===e)),n=o.find((({type:e})=>"color-ramp"===e));return l&&(l={...l},l.infos=[...l.infos],u(l,t,i,!0)),n&&(n={...n},n.infos=[...n.infos]),"horizontal"===i&&(l?.infos.reverse(),n?.infos.reverse()),{sizeRampElement:l,colorRampElement:n}}function g(e,t="vertical"){const i=e.infos;let o=i.find((({type:e})=>"size-ramp"===e)),l=i.find((({type:e})=>"color-ramp"===e));return o&&(o={...o},o.infos=[...o.infos],u(o,null,t,!1)),l&&(l={...l},l.infos=[...l.infos]),"horizontal"===t&&(o?.infos.reverse(),l?.infos.reverse()),{sizeRampElement:o,colorRampElement:l}}const z={marginLeft:"3px"},w={display:"table-cell",verticalAlign:"middle"},x={display:"flex",alignItems:"flex-start"};export{b as getUnivariateAboveAndBelowRampElements,v as getUnivariateColorRampMargin,h as getUnivariateColorRampPreview,y as getUnivariateColorRampSize,g as getUnivariateColorSizeRampElements,d as getUnivariateSizeRampSize,z as univariateColorRampContainerStyles,w as univariateColorRampStyles,x as univariateRampContainerStyles};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getStretchStopLabel as t,getTitle as e,isRendererTitle as r}from"../../support/styleUtils.js";function l(e,r,l){switch(r){case"heatmap-ramp":return l[e.label]||e.label;case"stretch-ramp":return t(e,l);default:return e.label}}function i(t,l){if(!t.title||"string"==typeof t.title)return t.title;const i="color-ramp"===t.type||"opacity-ramp"===t.type,
|
|
5
|
+
import{getStretchStopLabel as t,getTitle as e,isRendererTitle as r}from"../../support/styleUtils.js";function l(e,r,l){switch(r){case"heatmap-ramp":return l[e.label]||e.label;case"stretch-ramp":return t(e,l);default:return e.label}}function i(t,l){if(!t.title||"string"==typeof t.title)return t.title;const i="color-ramp"===t.type||"opacity-ramp"===t.type,n=t.title,o=e(l,n,i);return r(n,i)&&n.title?`${n.title} (${o})`:o}function n(t){return!(!t||"object"!=typeof t)}export{i as getLegendElementTitle,l as getRampStopLabel,n as isWidthAndHeight};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as s}from"../../../kernel.js";import i from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{debounce as u}from"../../../core/promiseUtils.js";import{on as c,watch as d,whenOnce as y,initial as h}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as f}from"../../../core/urlUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as S}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as _}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{getEffectiveDisplayFilter as v}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{getRendererFields as E}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as C}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as F}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as R}from"../../../renderers/support/rendererConversion.js";import V from"../../../renderers/visualVariables/SizeVariable.js";import D from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as x}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import{updateSpikeSymbol as z}from"../../../smartMapping/renderers/support/spikeUtils.js";import T from"../../../symbols/SimpleFillSymbol.js";import j from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as O}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as P}from"../../../symbols/support/previewUtils.js";import{renderSymbol as A}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as M,renderDotDensityPreviewHTML as U,renderPieChartPreviewHTML as k,renderPreviewHTML as B}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as N}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as q}from"./clusterUtils.js";import{getColorFromPointCloudStops as H,getRampStopsForPointCloud as $,getStretchRampStops as W,getRampStops as G}from"./colorRampUtils.js";import{getHeatmapRampStops as J}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as Q,getRelationshipRampElement as Z}from"./relationshipRampUtils.js";import{getRampStops as K,realWorldMaxSize as X,realWorldMinSize as Y}from"./sizeRampUtils.js";import{specialCharsLessThan as ee,specialCharsGreaterThan as te,getAuthoringInfoVisualVariableByTheme as se,getSymbolForFlowRenderer as ie,getMedianColor as le,rgbImgSource as re,getDateFormatOptions as ne}from"./utils.js";import{formatNumberLabel as ae}from"../../smartMapping/support/utils.js";import{fetchMessageBundle as oe}from"../../../intl/messages.js";import{substitute as ue}from"../../../intl/substitute.js";const ce=16,de="https://utility.arcgis.com/sharing/tools/legend",ye="esri.layers.ImageryLayer",he="esri.layers.ImageryTileLayer",me="esri.layers.WCSLayer",pe=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,fe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),ge=new j({size:6,outline:{color:[128,128,128,.5],width:.5}}),be=new T({style:"solid"});function Se(e){return"flow"===e.type}function _e(e){return"vector-field"===e.type}function we(e){return"raster-colormap"===e.type}function ve(e){return"raster-stretch"===e.type}function Le(e){return"raster-shaded-relief"===e.type}function Ee(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Fe(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Re(e){return De(e)||xe(e)||ze(e)||Ve(e)}function Ve(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function ze(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function Te(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function je(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Oe(e,t){return Ee(e)||Ce(e)||Ie(e)||Fe(e)||Te(e)||je(e)?"2d"===t.type||R(e):ve(e)||we(e)||Le(e)||De(e)||xe(e)||ze(e)||_e(e)||Se(e)}function Pe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Ae(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Me(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ue(e){return"esri.layers.WMSLayer"===e.declaredClass}function ke(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Be(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Ne(e){return"esri.layers.TileLayer"===e.declaredClass}function qe(e){return e.declaredClass===ye}function He(e){return e.declaredClass===he}function $e(e){return e.declaredClass===me}function We(e){return"stretch-ramp"===e.type}function Ge(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Je(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Qe(e){return"sublayers"in e}async function Ze(e,t){const s=await oe("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),ue(s[e],{label:t})}function Ke(e,t){const{field:s,field2:i,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!s)return null;const a=!(!s&&!n||!i&&!l)?t?.toString().split(r||""):[t],o=s?{[s]:a?.[0]}:null;return o&&(i&&(o[i]=a?.[1]),l&&(o[l]=a?.[2])),o}const Xe=new j({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Ye={},et=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilterId=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([c((()=>this.children),"change",(t=>{const{added:s,removed:i}=t;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(d((()=>t.ready),e,h),s)})),i.forEach((e=>this.removeHandles(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(Ye={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Ye=null),this._layerDefinitionExpressionClause=null}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new _,t.effect=e.effect,t.endTransition(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,i=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=i?i*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}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?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ie(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(C(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,s=t?.drawingInfo,i=s&&F(s.renderer),l=fe.read(t.geometryType);return i?this._getRendererLegendElements(i,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null}));try{const e=[],s=await Promise.allSettled(t);for(const t of s)if("fulfilled"===t.status)for(const s of t.value??[])e.push(s);this.legendElements=e,this.notifyChange("ready")}catch(s){o.getLogger(this).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).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).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Me(e))this._constructLegendElementsForVoxelLayer();else if(ke(e))this._constructLegendElementsForWMTSlayer();else if(Ue(e))await this._constructLegendElementsForWMSSublayers();else if(Pe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Be(e)||Ne(e)||Ae(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(qe(e)){const s=e;t=(s?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(He(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(qe(e)){const t=d((()=>[e.rasterFunction,e.bandIds]),(()=>u((async()=>{Ye.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this.addHandles(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s?.infos.length&&(qe(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await Promise.allSettled(s)})).catch((e=>{o.getLogger(this).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 y((()=>!t.updating));const i=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!i)return!0;i.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(i):"queryFeatureCount"in e&&await e.queryFeatureCount(i))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){return this.children.some((e=>e.ready))}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(pe.test(t))return!0;const s="visualVariables"in e?e.visualVariables:null;return!!s?.some((e=>this._isScaleDrivenSizeVariable(e)))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some((e=>this._isScaleDrivenSymbol(e.symbol)));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some((e=>this._isScaleDrivenSymbol(e.symbol)))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:s,maxScale:i}=e.data,l=t?.some((e=>/\$view\.scale/.test(e.valueExpressionInfo?.expression||"")))??!1;return null!=s||null!=i||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,i=t.maxSize;return!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||(!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||pe.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&&Be(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.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(d((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-current-variable"),this.addHandles(d((()=>e.getVariableStyles()),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-style-watcher");const t=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 T({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:i}=t.transferFunction,l=e.toArray().reverse(),r=i.map(((e,t)=>`${0===t?ee:te} ${ae(e)}`)).reverse(),n=l.map((e=>({color:e.color,value:null,label:null})));n[0].label=r[0],n[n.length-1].label=r[1],s.push({type:"color-ramp",title:t.label,infos:n,preview:M(l.map((e=>e.color)),{ariaLabel:await Ze("previewColorRampAriaLabel")})})}const i=e.opacity,l=s.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,i)));await Promise.allSettled(l),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(d((()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer}),(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find((({id:t})=>t===e.styleId))?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(d((()=>{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.layer,i=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const l=this.sublayerIds?.map((e=>s.findSublayerById(e)))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=d((()=>[r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForWMSSublayers()));if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&i.unshift(e)}}return i}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 l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(s=f(s,t));let r=null;const n=e.layer?.opacity;try{r=(await i(s,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:s,preview:r,opacity:n}),l}_getLegendLayers(e,t){const s=Ye&&Ye[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return Ye[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(qe(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(s.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:i,customParameters:l}=t;s={raster:e,viewId:i,...s,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=de+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return i(l,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(d((()=>e.sublayers),(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const i=e.toArray();for(const l of i){const e=d((()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,i=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,i);e.infos.push(...t),s=[e,...s]}else if(l.renderer){s=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:i,sublayer:l}),...s]}}}return s.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;if(Be(e)||Ne(e)||Ae(e)){this.addHandles(d((()=>e.sublayers),(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}}async _generateLegendElementsForSublayers(e,t,s){const i=this.layer;let l=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(n=Ae(i)?this.sublayerIds.map((e=>i.findSublayerForSubtypeCode(e))).filter(r):this.sublayerIds.map((e=>i.findSublayerById(e))).filter(r));for(const r of n){const e=d((()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForSublayers()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r)){const e=null!=r?.opacity?r.opacity:null,i=null!=e?e*t:t,n=!Qe(r)||r.originIdOf("renderer")>S.SERVICE&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:i,sublayer:r}),...l]}else if(Qe(r)){const e=await this._generateSymbolTableElementForSublayer(r,i,s);e&&l.unshift(e)}}}return l.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,i=e.source;let l=null;if(!(!i||"map-layer"===i.type&&i.mapLayerId===e.id&&(!i.gdbVersion||i.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>S.SERVICE||e.originIdOf("labelingInfo")>S.SERVICE||e.originIdOf("labelsVisible")>S.SERVICE){const e=new L({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach((e=>s.set(e.layerId,e)))}const i=s.get(e.id);if((!i||i?.subLayerIds&&i.defaultVisibility)&&e.sublayers){const i=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendLayer(i,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const i=t?.renderer;let l=t?.title||e.layerName;if(i&&(!t||t?.originIdOf("renderer")>S.SERVICE)){const e=t?.title||this._getRendererTitle(i,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach((t=>{const i={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};i.infos?.length>0&&r.infos.push(i)})):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,i){return e.map((e=>{let l=e.url;if(e.imageData&&e.imageData.length>0)l=`data:image/png;base64,${e.imageData}`;else{if(0===l.indexOf("http"))return null;l=s(`${this.layer.url}/${t}/images/${l}`)}return{label:e.label,src:l,opacity:i??this.opacity,width:e.width,height:e.height}})).filter(r)}_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 i=null,l=null,r=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(i=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(l=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(i=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,l=Math.max(s.maxScale,e.maxScale)),(i>0&&i<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const s=t.renderer,i=e.some((e=>e.values));let l=0,r=null;return i&&e.some(((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r))),s?"unique-value"===s.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===s.type&&(r&&e.splice(l,1),s.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!Oe(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Re(e))return this._constructPointCloudRendererLegendElements(e,t);if(Te(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return je(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?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const s=t.title,i=[];let l=null,r=null;if(De(e))l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ge,e.color)})}));else if(xe(e)){const t=e.stops;let i=null;if(t?.length&&(1===t.length&&(i=t[0].color),!i)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){i=H(e+(s-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ge,i||ge.color)}]};const n=$(e.stops??[])??[];r={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:M(n.map((e=>e.color)),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}else ze(e)&&(l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach((e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ge,e.color)})})));l?.infos.length&&i.push(l),r?.infos.length&&i.push(r);const n=i.reduce(((e,t)=>[...e,...t.infos??[]]),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return await Promise.allSettled(n),i}async _getElementInfoForDotDensity(e,t){const{color:s,label:i,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map((e=>e.toJSON())),c=w(u),d=await Ze("previewTemplateAriaLabel",i||l),y=a+"-"+s+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):U(e,s,{ariaLabel:d});h.set(y,m);const p={shape:{type:"image",x:0,y:0,width:m.width,height:m.height,src:m.src},fill:null,stroke:null,offset:[0,0]},f=A([[p]],[m.width,m.height],{effectView:this.effectList,ariaLabel:d});return{opacity:1,src:m.src,preview:f,width:m.width,height:m.height}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions?.unit,i={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,i.infos.push(t)}return[i]}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[];let i=null;const l=e.outline;e.attributes.forEach((e=>{const t=new j({color:e.color,outline:l}),i=e.label||e.valueExpressionTitle||e.field;s.push({label:i,symbol:t})}));const r=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new j({color:e.othersCategory.color,outline:l});i=e.othersCategory.label||"Other",s.push({label:i,symbol:t})}if(e.defaultColor?.a){const t=new j({color:e.defaultColor,outline:l});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=r.filter((e=>e.label!==i)).map((e=>e.symbol.color)).filter(Boolean),a=k(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:l,ariaLabel:await Ze("previewPieChartAriaLabel")});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await Promise.allSettled(a),n}async _getWhereClause(e,t,s){const i=await p(e,s),l=await E(t,s),r=new Set(l.map((e=>e.toLowerCase()))),n=i?.fieldNames.map((e=>e.toLowerCase()));return n?.some((e=>!r.has(e)))?null:i}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const s=e.definitionExpression;s&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==s&&(this._layerDefinitionExpressionClause=await this._getWhereClause(s,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=s}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const s=e.displayFilterInfo?v(e.displayFilterInfo,this.view):null;return s?.where?this._layerDisplayFilterId!==s?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(s.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilterId=s?.id,s}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:i}=t,l=i||this.layer,r=se(e,"reference-size"),n=se(e,"spike");let a=null;Ie(e)&&(await this._processDefinitionExpression(l,e),a=await this._processDisplayFilter(l,e)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const o=await this._getVisualVariableLegendElements(e,l)||[],u={type:"symbol-table",title:s||this._getRendererTitle(e,l),infos:[]};let c=null,d=!1;const y=new Set;if(Se(e)&&!this._hasSizeRamp){const t=await ie(e);u.infos.push({label:null,symbol:t})}else if(Ge(e)){let t=s;const i=Je(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=o.findIndex((e=>"color-ramp"===e.type)),r=-1!==l?o.splice(l,1)[0]:null,n=o.findIndex((e=>"size-ramp"===e.type)),a=-1!==n?o.splice(n,1)[0]:null,u=[];r&&(t=r.title,u.push(r)),a&&(t=a.title,u.push(a)),u.length>0&&o.push({type:i,title:t,infos:u})}else if(Fe(e)){const t=J(e);o.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,l),infos:t,preview:M(t.map((e=>e.color)),{effectList:this.effectList,ariaLabel:await Ze("previewColorRampAriaLabel")})})}else if(Ie(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:s,field1:i,field2:r}=t,n=t.focus;if(s&&i&&r){const t=[i,r];let a=Q(n)||0;for(const e of t){const{field:t,normalizationField:s,label:i}=e,r=i||{field:this._getFieldAlias(t,l),normField:s&&this._getFieldAlias(s,l)},n=Xe.clone();n.angle=a,u.infos.push({label:r,symbol:n}),y.add(n),a+=90}const c=Z({focus:n,numClasses:s,infos:e.uniqueValueInfos??[]});o.unshift(c)}}else if(qe(this.layer)||He(this.layer))e.uniqueValueInfos?.forEach((t=>{t.symbol&&this._checkClausesForUVR(e,t.value)&&u.infos.push({label:t.label||t.value,value:t.value,symbol:t.symbol})}));else{const{field:t,field2:i,field3:o,fieldDelimiter:c,valueExpression:y,defaultSymbol:h}=e,m=!(!t&&!y||!i&&!o),p=this._layerDisplayFilterClause?a?.title:null,f=[];if(e.uniqueValueGroups?.forEach((s=>{const a={type:"symbol-table",title:p||s.heading,infos:[]};s.classes?.forEach((s=>{const{symbol:u,values:d}=s;if(u){const h=[],p=[];for(const e of d??[]){const{value:s,value2:r,value3:n}=e,a=[],u=[];(t||y)&&(a.push(s),u.push(this._getDomainName(t,s,l))),i&&(a.push(r),u.push(this._getDomainName(i,r,l))),o&&(a.push(n),u.push(this._getDomainName(o,n,l))),h.push(m?a.join(c||""):a[0]),p.push(u.join(" - "))}const f=h.join(", ");let g=s.label;if(!g){const e=p.filter(Boolean);g=e.length?e.join(", "):f}const b=u.clone();"cim"===b.type&&r&&x(b,{innerDotSize:.5*ce,outerRingSize:ce}),"cim"===b.type&&n&&z(b,{height:50}),h.some((t=>this._checkClausesForUVR(e,t)))&&a.infos.push({label:g,value:f,symbol:b})}})),a.infos.length&&f.push(a)})),f.length){const t=f[0];1===f.length&&"title"in t&&!t.title?u.infos.push(...t.infos??[]):(h&&(f.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:h}]}),d=!0),u.infos.push(...f)),s||e.legendOptions?.title||e.valueExpressionTitle||(u.title=null)}}e.defaultSymbol&&!d&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}else if(Ce(e)){if(!r&&!n){c=this._isUnclassedRenderer(e);if(!c||!this._hasSizeRamp){const t=e.classBreakInfos.filter((({symbol:e})=>e)),s="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:i,maxValue:l,symbol:r}of t){const t={label:e||(c?null:`${i} - ${l}`),value:[i,l],symbol:r};s?u.infos.push(t):u.infos.unshift(t)}c&&(u.title=null),this._updateInfosForClassedSizeRenderer(e,u.infos)}e.defaultSymbol&&!c&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}}else if(ve(e))if(He(this.layer)||$e(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);We(t)?o.push(t):u.infos=t}else{const t=this.layer;let s,i;e.customStatistics?.length&&({min:s,max:i}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;s=null!=s?s:r.statistics?r.statistics[l].min:n[0],i=null!=i?i:r.statistics?r.statistics[l].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].min:n[0],i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:s}=t;e.length>=r.bandCount?3===s?.length?(l=s.map((t=>e[t].name)),u.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map((t=>e[t].name)),u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(we(e))e.colormapInfos.forEach((e=>{u.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(be,e.color)})}));else if(Ee(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in l?l.pointSymbol:null;break;case"polyline":s="lineSymbol"in l?l.lineSymbol:null;break;case"polygon":s="polygonSymbol"in l?l.polygonSymbol:null}const i=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&i&&u.infos.push({label:e.label,symbol:s})}else if(_e(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),u.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{u.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):u.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else Le(e)&&o.push(await this._getStretchLegendElements(e,{min:0,max:255}));const h=e.defaultSymbol;!h||d||Ee(e)||c&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||o.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:h}]}),u.infos.length&&o.unshift(u);const m=null==t.opacity?this.opacity:t.opacity,p=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),f=qe(this.layer)||He(this.layer),g=o.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).filter((e=>{if("cim"===e.symbol.type){const{minScale:t,maxScale:s}=e.symbol.data;if(t&&t<this.scale||s&&s>this.scale)return!1}return!0})).map((e=>this._getSymbolPreview(e,m,{isDefault:e.symbol===h,applyScaleDrivenSize:!y.has(e.symbol),symbolConfig:{isTall:p,isSquareFill:f},effectList:y.has(e.symbol)?null:this.effectList})));return e=null,await Promise.allSettled(g),o}_checkClausesForUVR(e,t){const s=Ke(e,t);return!s||(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(s))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(s))}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,s=t.symbolizer.rasterInfo??t.raster.rasterInfo;let i,l;const r=e?.customStatistics?.length?e.customStatistics:s?.statistics;if(r)({min:i,max:l}=r[0]);else{const e=I(s.pixelType);i=e[0],l=e[1]}if(t.hasStandardTime()&&(i=t.getStandardTimeValue(i),l=t.getStandardTimeValue(l)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:i,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.bandCount,3)).keys())).map((e=>s.bandInfos[e].name));return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const s=e.colorRamp,i=W(s,t);return{type:"stretch-ramp",title:"",infos:i,preview:M(i.map((e=>e.color)),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}_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:null}async _getSizeLegendElement(e,t,s,i){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await K(s,t,await le(s),this.scale,this.view,i,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,i)=>{t.push({label:{colorName:s[i],bandName:e},src:re[i],opacity:this.opacity??1})})),t}_updateInfosForClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,i=e.classBreakInfos.some((e=>N(e.symbol)));if(s&&i){const s=X,i=Y,l=e.classBreakInfos.length,r=(s-i)/(l>1?l-1:l);t.forEach(((e,t)=>{e.size=s-r*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let i=0;i<e.length&&(!t||!s);i++){const l=e[i];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let i=!s?.isDefault&&null==e.size&&this._hasSizeRamp?m(P.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const l=!s?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!s?.applyScaleDrivenSize);return B(e.symbol,{size:i,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList,style:"legend",cimOptions:{allowScalingUp:l,viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null},ariaLabel:e.label&&"string"!=typeof e.label?null:await Ze("previewTemplateAriaLabel",e.label)}).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:null,s=e.renderer?.clone()||t?.clone(),i=q(e,this.layerView,this.view);if(i&&null!=s&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!pe.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;i.legendOptions=new D({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([i]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),i=await le(s);if(Ce(s)||Ie(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,i).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:i).then((e=>{this._applySymbolToRenderer(s,e,Ee(s))})).catch((()=>{this._applySymbolToRenderer(s,null,Ee(s))}))),await Promise.allSettled(t),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 i=await e.fetchSymbol({cache:s});return this._getAppliedCloneSymbol(i,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const i=e.clone(),l=s&&s.toRgba();return i.type.includes("3d")?this._applyColorTo3dSymbol(i,l):"cim"===i.type?O(i,s):i.color&&(i.color=new t(l||i.color)),i}_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)||"vector-field"===e.type)return null;const s=e.visualVariables??[],i=[],l=[],n=[],a=se(e,"reference-size")??se(e,"spike");if(2===a?.sizeStops?.length&&(Ce(e)||Ie(e))){const[e,t]=a.sizeStops;l.push(new V({field:a.field??void 0,normalizationField:a.normalizationField,minSize:e.size,maxSize:t.size,minDataValue:e.value,maxDataValue:t.value}))}for(const r of s)"color"===r.type?i.push(r):"size"===r.type?l.push(r):"opacity"===r.type&&n.push(r);const o=[...i,...l,...n];let u,c;if(0===i.length&&Ce(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];u=t&&t.symbol}if(0===i.length&&Ee(e)&&(u=e.symbol),u)if(u.type.includes("3d")){const e=u.symbolLayers.at(0);"water"===e.type?null!=e.color&&(c=e.color):null!=e.material?.color&&(c=e.material.color)}else u.url||(c=u.color);const d=this.effectList;return(await Promise.all(o.map((async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const i=Se(e)?s.field:this._getRampTitle(s,t);let l=null;const r=ne(t,s,this.view.timeZone);if("color"===s.type){const e=await G(s,null,r)??[];l={type:"color-ramp",title:i,infos:e,preview:M(e.map((e=>e.color)),{effectList:d,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===s.type&&"outline"!==s.target)pe.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(l=await this._getSizeLegendElement(i,s,e,r),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===s.type){const e=await G(s,c,r)??[];l={type:"opacity-ramp",title:i,infos:e,preview:M(e.map((e=>e.color)),{effectList:d,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}})))).filter(r)}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const i="getField"in s&&s.getField?.(e),l=i&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(i.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.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,i="popupTemplate"in e&&e.popupTemplate,l=i&&i.fieldInfos;if(l)for(const t of l)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,i=e.normalizationField,l=!1,r=!1,n=!1,a=null;s="function"==typeof s?null:s,i="function"==typeof i?null:i;const o=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?.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){l=!0;break}if("percent"===s.style){r=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:i&&this._getFieldAlias(i,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions?.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let i=s.field,l=null,r=null;if(Ce(s)&&(l=s.normalizationField,r="percent-of-total"===s.normalizationType),i="function"==typeof i?null:i,l="function"==typeof l?null:l,Ie(s)){const{field2:e,field3:l,fieldDelimiter:r}=s;let n=i&&this._getFieldAlias(i,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(i||l)&&(n={field:i&&this._getFieldAlias(i,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const s="popupTemplate"in t?t.popupTemplate:null,i=s?.fieldInfos;let l=i?.find((t=>e===t.fieldName)),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find((t=>e?.toLowerCase()===t.fieldName?.toLowerCase())):void 0,"fields"in a&&a.fields&&(n=a.fields.find((t=>t.name?.toLowerCase()===e?.toLowerCase()))));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return Ce(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([g()],et.prototype,"children",void 0),e([g({readOnly:!0})],et.prototype,"effectList",null),e([g()],et.prototype,"layerView",void 0),e([g()],et.prototype,"layer",void 0),e([g()],et.prototype,"legendElements",void 0),e([g({readOnly:!0})],et.prototype,"opacity",null),e([g()],et.prototype,"parent",void 0),e([g({readOnly:!0,dependsOn:[]})],et.prototype,"ready",null),e([g()],et.prototype,"hideLayersNotInCurrentView",void 0),e([g()],et.prototype,"keepCacheOnDestroy",void 0),e([g()],et.prototype,"respectLayerDefinitionExpression",void 0),e([g()],et.prototype,"respectLayerVisibility",void 0),e([g({readOnly:!0})],et.prototype,"scale",null),e([g()],et.prototype,"sublayerIds",void 0),e([g({readOnly:!0})],et.prototype,"isScaleDriven",null),e([g()],et.prototype,"title",void 0),e([g({readOnly:!0,dependsOn:["ready"],value:0})],et.prototype,"version",null),e([g()],et.prototype,"view",void 0),et=e([b("esri.widgets.Legend.support.ActiveLayerInfo")],et);const tt=et;export{tt as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as s}from"../../../kernel.js";import i from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{clamp as u}from"../../../core/mathUtils.js";import{debounce as c}from"../../../core/promiseUtils.js";import{on as d,watch as y,whenOnce as h,initial as m}from"../../../core/reactiveUtils.js";import{px2pt as p}from"../../../core/screenUtils.js";import{parseWhereClause as f}from"../../../core/sql.js";import{addQueryParameters as g}from"../../../core/urlUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as _}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as w}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as v}from"../../../layers/effects/jsonUtils.js";import{getEffectiveDisplayFilter as L}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as E}from"../../../layers/support/ExportImageParameters.js";import{getRendererFields as C}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as I}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as F}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as V}from"../../../renderers/support/rendererConversion.js";import D from"../../../renderers/visualVariables/SizeVariable.js";import x from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as z}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import T from"../../../symbols/SimpleFillSymbol.js";import j from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as O}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as P}from"../../../symbols/support/previewUtils.js";import{renderSymbol as A}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as M,renderDotDensityPreviewHTML as U,renderPieChartPreviewHTML as k,renderPreviewHTML as B}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as N}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as q}from"./clusterUtils.js";import{getColorFromPointCloudStops as H,getRampStopsForPointCloud as $,getStretchRampStops as W,getRampStops as G}from"./colorRampUtils.js";import{getHeatmapRampStops as J}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as Q,getRelationshipRampElement as Z}from"./relationshipRampUtils.js";import{getRampStops as K,realWorldMaxSize as X,realWorldMinSize as Y}from"./sizeRampUtils.js";import{specialCharsLessThan as ee,specialCharsGreaterThan as te,getAuthoringInfoVisualVariableByTheme as se,getSymbolForFlowRenderer as ie,getMedianColor as le,rgbImgSource as re,getDateFormatOptions as ne}from"./utils.js";import{formatNumberLabel as ae}from"../../smartMapping/support/utils.js";import{fetchMessageBundle as oe}from"../../../intl/messages.js";import{substitute as ue}from"../../../intl/substitute.js";const ce=16,de="https://utility.arcgis.com/sharing/tools/legend",ye="esri.layers.ImageryLayer",he="esri.layers.ImageryTileLayer",me="esri.layers.WCSLayer",pe=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,fe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),ge=new j({size:6,outline:{color:[128,128,128,.5],width:.5}}),be=new T({style:"solid"});function Se(e){return"flow"===e.type}function _e(e){return"vector-field"===e.type}function we(e){return"raster-colormap"===e.type}function ve(e){return"raster-stretch"===e.type}function Le(e){return"raster-shaded-relief"===e.type}function Ee(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Fe(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Re(e){return De(e)||xe(e)||ze(e)||Ve(e)}function Ve(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function ze(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function Te(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function je(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Oe(e,t){return Ee(e)||Ce(e)||Ie(e)||Fe(e)||Te(e)||je(e)?"2d"===t.type||V(e):ve(e)||we(e)||Le(e)||De(e)||xe(e)||ze(e)||_e(e)||Se(e)}function Pe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Ae(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Me(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ue(e){return"esri.layers.WMSLayer"===e.declaredClass}function ke(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Be(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Ne(e){return"esri.layers.TileLayer"===e.declaredClass}function qe(e){return e.declaredClass===ye}function He(e){return e.declaredClass===he}function $e(e){return e.declaredClass===me}function We(e){return"stretch-ramp"===e.type}function Ge(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Je(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Qe(e){return"sublayers"in e}async function Ze(e,t){const s=await oe("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),ue(s[e],{label:t})}function Ke(e,t){const{field:s,field2:i,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!s)return null;const a=!(!s&&!n||!i&&!l)?t?.toString().split(r||""):[t],o=s?{[s]:a?.[0]}:null;return o&&(i&&(o[i]=a?.[1]),l&&(o[l]=a?.[2])),o}const Xe=new j({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Ye={},et=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilterId=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([d((()=>this.children),"change",(t=>{const{added:s,removed:i}=t;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(y((()=>t.ready),e,m),s)})),i.forEach((e=>this.removeHandles(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(Ye={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Ye=null),this._layerDefinitionExpressionClause=null}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new w,t.effect=e.effect,t.endTransition(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,i=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=i?i*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}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?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ie(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(I(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,s=t?.drawingInfo,i=s&&R(s.renderer),l=fe.read(t.geometryType);return i?this._getRendererLegendElements(i,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null}));try{const e=[],s=await Promise.allSettled(t);for(const t of s)if("fulfilled"===t.status)for(const s of t.value??[])e.push(s);this.legendElements=e,this.notifyChange("ready")}catch(s){o.getLogger(this).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).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).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Me(e))this._constructLegendElementsForVoxelLayer();else if(ke(e))this._constructLegendElementsForWMTSlayer();else if(Ue(e))await this._constructLegendElementsForWMSSublayers();else if(Pe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Be(e)||Ne(e)||Ae(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(qe(e)){const s=e;t=(s?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(He(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(qe(e)){const t=y((()=>[e.rasterFunction,e.bandIds]),(()=>c((async()=>{Ye.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this.addHandles(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s?.infos.length&&(qe(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await Promise.allSettled(s)})).catch((e=>{o.getLogger(this).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 h((()=>!t.updating));const i=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!i)return!0;i.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(i):"queryFeatureCount"in e&&await e.queryFeatureCount(i))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){return this.children.some((e=>e.ready))}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(pe.test(t))return!0;const s="visualVariables"in e?e.visualVariables:null;return!!s?.some((e=>this._isScaleDrivenSizeVariable(e)))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some((e=>this._isScaleDrivenSymbol(e.symbol)));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some((e=>this._isScaleDrivenSymbol(e.symbol)))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:s,maxScale:i}=e.data,l=t?.some((e=>/\$view\.scale/.test(e.valueExpressionInfo?.expression||"")))??!1;return null!=s||null!=i||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,i=t.maxSize;return!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||(!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||pe.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&&Be(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.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(y((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-current-variable"),this.addHandles(y((()=>e.getVariableStyles()),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-style-watcher");const t=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 T({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:i}=t.transferFunction,l=e.toArray().reverse(),r=i.map(((e,t)=>`${0===t?ee:te} ${ae(e)}`)).reverse(),n=l.map((e=>({color:e.color,value:null,label:null})));n[0].label=r[0],n[n.length-1].label=r[1],s.push({type:"color-ramp",title:t.label,infos:n,preview:M(l.map((e=>e.color)),{ariaLabel:await Ze("previewColorRampAriaLabel")})})}const i=e.opacity,l=s.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,i)));await Promise.allSettled(l),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(y((()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer}),(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find((({id:t})=>t===e.styleId))?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(y((()=>{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.layer,i=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const l=this.sublayerIds?.map((e=>s.findSublayerById(e)))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=y((()=>[r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForWMSSublayers()));if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&i.unshift(e)}}return i}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 l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(s=g(s,t));let r=null;const n=e.layer?.opacity;try{r=(await i(s,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:s,preview:r,opacity:n}),l}_getLegendLayers(e,t){const s=Ye&&Ye[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return Ye[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(qe(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(s.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:i,customParameters:l}=t;s={raster:e,viewId:i,...s,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=de+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return i(l,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(y((()=>e.sublayers),(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const i=e.toArray();for(const l of i){const e=y((()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,i=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,i);e.infos.push(...t),s=[e,...s]}else if(l.renderer){s=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:i,sublayer:l}),...s]}}}return s.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;if(Be(e)||Ne(e)||Ae(e)){this.addHandles(y((()=>e.sublayers),(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}}async _generateLegendElementsForSublayers(e,t,s){const i=this.layer;let l=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(n=Ae(i)?this.sublayerIds.map((e=>i.findSublayerForSubtypeCode(e))).filter(r):this.sublayerIds.map((e=>i.findSublayerById(e))).filter(r));for(const r of n){const e=y((()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForSublayers()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r)){const e=null!=r?.opacity?r.opacity:null,i=null!=e?e*t:t,n=!Qe(r)||r.originIdOf("renderer")>_.SERVICE&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:i,sublayer:r}),...l]}else if(Qe(r)){const e=await this._generateSymbolTableElementForSublayer(r,i,s);e&&l.unshift(e)}}}return l.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,i=e.source;let l=null;if(!(!i||"map-layer"===i.type&&i.mapLayerId===e.id&&(!i.gdbVersion||i.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>_.SERVICE||e.originIdOf("labelingInfo")>_.SERVICE||e.originIdOf("labelsVisible")>_.SERVICE){const e=new E({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach((e=>s.set(e.layerId,e)))}const i=s.get(e.id);if((!i||i?.subLayerIds&&i.defaultVisibility)&&e.sublayers){const i=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendLayer(i,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const i=t?.renderer;let l=t?.title||e.layerName;if(i&&(!t||t?.originIdOf("renderer")>_.SERVICE)){const e=t?.title||this._getRendererTitle(i,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach((t=>{const i={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};i.infos?.length>0&&r.infos.push(i)})):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,i){return e.map((e=>{let l=e.url;if(e.imageData&&e.imageData.length>0)l=`data:image/png;base64,${e.imageData}`;else{if(0===l.indexOf("http"))return null;l=s(`${this.layer.url}/${t}/images/${l}`)}return{label:e.label,src:l,opacity:i??this.opacity,width:e.width,height:e.height}})).filter(r)}_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 i=null,l=null,r=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(i=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(l=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(i=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,l=Math.max(s.maxScale,e.maxScale)),(i>0&&i<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const s=t.renderer,i=e.some((e=>e.values));let l=0,r=null;return i&&e.some(((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r))),s?"unique-value"===s.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===s.type&&(r&&e.splice(l,1),s.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!Oe(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Re(e))return this._constructPointCloudRendererLegendElements(e,t);if(Te(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return je(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?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const s=t.title,i=[];let l=null,r=null;if(De(e))l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ge,e.color)})}));else if(xe(e)){const t=e.stops;let i=null;if(t?.length&&(1===t.length&&(i=t[0].color),!i)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){i=H(e+(s-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ge,i||ge.color)}]};const n=$(e.stops??[])??[];r={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:M(n.map((e=>e.color)),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}else ze(e)&&(l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach((e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ge,e.color)})})));l?.infos.length&&i.push(l),r?.infos.length&&i.push(r);const n=i.reduce(((e,t)=>[...e,...t.infos??[]]),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return await Promise.allSettled(n),i}async _getElementInfoForDotDensity(e,t){const{color:s,label:i,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map((e=>e.toJSON())),c=v(u),d=await Ze("previewTemplateAriaLabel",i||l),y=a+"-"+s+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):U(e,s,{ariaLabel:d});h.set(y,m);const p={shape:{type:"image",x:0,y:0,width:m.width,height:m.height,src:m.src},fill:null,stroke:null,offset:[0,0]},f=A([[p]],[m.width,m.height],{effectView:this.effectList,ariaLabel:d});return{opacity:1,src:m.src,preview:f,width:m.width,height:m.height}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions?.unit,i={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,i.infos.push(t)}return[i]}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[];let i=null;const l=e.outline;e.attributes.forEach((e=>{const t=new j({color:e.color,outline:l}),i=e.label||e.valueExpressionTitle||e.field;s.push({label:i,symbol:t})}));const r=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new j({color:e.othersCategory.color,outline:l});i=e.othersCategory.label||"Other",s.push({label:i,symbol:t})}if(e.defaultColor?.a){const t=new j({color:e.defaultColor,outline:l});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=r.filter((e=>e.label!==i)).map((e=>e.symbol.color)).filter(Boolean),a=k(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:l,ariaLabel:await Ze("previewPieChartAriaLabel")});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await Promise.allSettled(a),n}async _getWhereClause(e,t,s){const i=await f(e,s),l=await C(t,s),r=new Set(l.map((e=>e.toLowerCase()))),n=i?.fieldNames.map((e=>e.toLowerCase()));return n?.some((e=>!r.has(e)))?null:i}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const s=e.definitionExpression;s&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==s&&(this._layerDefinitionExpressionClause=await this._getWhereClause(s,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=s}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const s=e.displayFilterInfo?L(e.displayFilterInfo,this.view):null;return s?.where?this._layerDisplayFilterId!==s?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(s.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilterId=s?.id,s}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:i}=t,l=i||this.layer,r=se(e,"reference-size"),n=se(e,"spike");let a=null;Ie(e)&&(await this._processDefinitionExpression(l,e),a=await this._processDisplayFilter(l,e)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const o=await this._getVisualVariableLegendElements(e,l)||[],u={type:"symbol-table",title:s||this._getRendererTitle(e,l),infos:[]};let c=null,d=!1;const y=new Set;if(Se(e)&&!this._hasSizeRamp){const t=await ie(e);u.infos.push({label:null,symbol:t})}else if(Ge(e)){let t=s;const i=Je(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=o.findIndex((e=>"color-ramp"===e.type)),r=-1!==l?o.splice(l,1)[0]:null,n=o.findIndex((e=>"size-ramp"===e.type)),a=-1!==n?o.splice(n,1)[0]:null,u=[];r&&(t=r.title,u.push(r)),a&&(t=a.title,u.push(a)),u.length>0&&o.push({type:i,title:t,infos:u})}else if(Fe(e)){const t=J(e);o.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,l),infos:t,preview:M(t.map((e=>e.color)),{effectList:this.effectList,ariaLabel:await Ze("previewColorRampAriaLabel")})})}else if(Ie(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:s,field1:i,field2:r}=t,n=t.focus;if(s&&i&&r){const t=[i,r];let a=Q(n)||0;for(const e of t){const{field:t,normalizationField:s,label:i}=e,r=i||{field:this._getFieldAlias(t,l),normField:s&&this._getFieldAlias(s,l)},n=Xe.clone();n.angle=a,u.infos.push({label:r,symbol:n}),y.add(n),a+=90}const c=Z({focus:n,numClasses:s,infos:e.uniqueValueInfos??[]});o.unshift(c)}}else if(qe(this.layer)||He(this.layer))e.uniqueValueInfos?.forEach((t=>{t.symbol&&this._checkClausesForUVR(e,t.value)&&u.infos.push({label:t.label||t.value,value:t.value,symbol:t.symbol})}));else{const{field:t,field2:i,field3:n,fieldDelimiter:o,valueExpression:c,defaultSymbol:y}=e,h=!(!t&&!c||!i&&!n),m=this._layerDisplayFilterClause?a?.title:null,p=[];if(e.uniqueValueGroups?.forEach((s=>{const a={type:"symbol-table",title:m||s.heading,infos:[]};s.classes?.forEach((s=>{const{symbol:u,values:d}=s;if(u){const y=[],m=[];for(const e of d??[]){const{value:s,value2:r,value3:a}=e,u=[],d=[];(t||c)&&(u.push(s),d.push(this._getDomainName(t,s,l))),i&&(u.push(r),d.push(this._getDomainName(i,r,l))),n&&(u.push(a),d.push(this._getDomainName(n,a,l))),y.push(h?u.join(o||""):u[0]),m.push(d.join(" - "))}const p=y.join(", ");let f=s.label;if(!f){const e=m.filter(Boolean);f=e.length?e.join(", "):p}const g=u.clone();"cim"===g.type&&r&&z(g,{innerDotSize:.5*ce,outerRingSize:ce}),y.some((t=>this._checkClausesForUVR(e,t)))&&a.infos.push({label:f,value:p,symbol:g})}})),a.infos.length&&p.push(a)})),p.length){const t=p[0];1===p.length&&"title"in t&&!t.title?u.infos.push(...t.infos??[]):(y&&(p.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),d=!0),u.infos.push(...p)),s||e.legendOptions?.title||e.valueExpressionTitle||(u.title=null)}}e.defaultSymbol&&!d&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}else if(Ce(e)){if(!r&&!n){c=this._isUnclassedRenderer(e);if(!c||!this._hasSizeRamp){const t=e.classBreakInfos.filter((({symbol:e})=>e)),s="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:i,maxValue:l,symbol:r}of t){const t={label:e||(c?null:`${i} - ${l}`),value:[i,l],symbol:r};s?u.infos.push(t):u.infos.unshift(t)}c&&(u.title=null),this._updateInfosForClassedSizeRenderer(e,u.infos)}e.defaultSymbol&&!c&&(u.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),d=!0)}}else if(ve(e))if(He(this.layer)||$e(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);We(t)?o.push(t):u.infos=t}else{const t=this.layer;let s,i;e.customStatistics?.length&&({min:s,max:i}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=F(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;s=null!=s?s:r.statistics?r.statistics[l].min:n[0],i=null!=i?i:r.statistics?r.statistics[l].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].min:n[0],i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].max:n[1],s||i?o.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:s}=t;e.length>=r.bandCount?3===s?.length?(l=s.map((t=>e[t].name)),u.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map((t=>e[t].name)),u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],u.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(we(e))e.colormapInfos.forEach((e=>{u.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(be,e.color)})}));else if(Ee(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in l?l.pointSymbol:null;break;case"polyline":s="lineSymbol"in l?l.lineSymbol:null;break;case"polygon":s="polygonSymbol"in l?l.polygonSymbol:null}const i=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&i&&u.infos.push({label:e.label,symbol:s})}else if(_e(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),u.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{u.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):u.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else Le(e)&&o.push(await this._getStretchLegendElements(e,{min:0,max:255}));const h=e.defaultSymbol;!h||d||Ee(e)||c&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||o.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:h}]}),u.infos.length&&o.unshift(u);const m=null==t.opacity?this.opacity:t.opacity,p=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),f=qe(this.layer)||He(this.layer),g=o.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).filter((e=>{if("cim"===e.symbol.type){const{minScale:t,maxScale:s}=e.symbol.data;if(t&&t<this.scale||s&&s>this.scale)return!1}return!0})).map((e=>this._getSymbolPreview(e,m,{isDefault:e.symbol===h,applyScaleDrivenSize:!y.has(e.symbol),symbolConfig:{isTall:p,isSquareFill:f},effectList:y.has(e.symbol)?null:this.effectList})));return e=null,await Promise.allSettled(g),o}_checkClausesForUVR(e,t){const s=Ke(e,t);return!s||(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(s))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(s))}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,s=t.symbolizer.rasterInfo??t.raster.rasterInfo;let i,l;const r=e?.customStatistics?.length?e.customStatistics:s?.statistics;if(r)({min:i,max:l}=r[0]);else{const e=F(s.pixelType);i=e[0],l=e[1]}if(t.hasStandardTime()&&(i=t.getStandardTimeValue(i),l=t.getStandardTimeValue(l)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:i,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.bandCount,3)).keys())).map((e=>s.bandInfos[e].name));return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const s=e.colorRamp,i=W(s,t);return{type:"stretch-ramp",title:"",infos:i,preview:M(i.map((e=>e.color)),{ariaLabel:await Ze("previewColorRampAriaLabel")})}}_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:null}async _getSizeLegendElement(e,t,s,i){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await K(s,t,await le(s),this.scale,this.view,i,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,i)=>{t.push({label:{colorName:s[i],bandName:e},src:re[i],opacity:this.opacity??1})})),t}_updateInfosForClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,i=e.classBreakInfos.some((e=>N(e.symbol)));if(s&&i){const s=X,i=Y,l=e.classBreakInfos.length,r=(s-i)/(l>1?l-1:l);t.forEach(((e,t)=>{e.size=s-r*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let i=0;i<e.length&&(!t||!s);i++){const l=e[i];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let i=!s?.isDefault&&null==e.size&&this._hasSizeRamp?p(P.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const l=!s?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!s?.applyScaleDrivenSize);return B(e.symbol,{size:i,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList,style:"legend",cimOptions:{allowScalingUp:l,viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null},ariaLabel:e.label&&"string"!=typeof e.label?null:await Ze("previewTemplateAriaLabel",e.label)}).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:null,s=e.renderer?.clone()||t?.clone(),i=q(e,this.layerView,this.view);if(i&&null!=s&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!pe.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;i.legendOptions=new x({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([i]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),i=await le(s);if(Ce(s)||Ie(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,i).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:i).then((e=>{this._applySymbolToRenderer(s,e,Ee(s))})).catch((()=>{this._applySymbolToRenderer(s,null,Ee(s))}))),await Promise.allSettled(t),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 i=await e.fetchSymbol({cache:s});return this._getAppliedCloneSymbol(i,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const i=e.clone(),l=s&&s.toRgba();return i.type.includes("3d")?this._applyColorTo3dSymbol(i,l):"cim"===i.type?O(i,s):i.color&&(i.color=new t(l||i.color)),i}_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)||"vector-field"===e.type)return null;const s=e.visualVariables??[],i=[],l=[],n=[],a=se(e,"reference-size")??se(e,"spike");let o;if(2===a?.sizeStops?.length&&(Ce(e)||Ie(e))){const[e,t]=a.sizeStops;o=new D({field:a.field??void 0,normalizationField:a.normalizationField,minSize:u(e.size,10,100),maxSize:u(t.size,50,150),minDataValue:e.value,maxDataValue:t.value}),l.push(o)}for(const r of s)"color"===r.type?i.push(r):"size"===r.type?l.push(r):"opacity"===r.type&&n.push(r);const c=[...i,...l,...n];let d,y;if(0===i.length&&Ce(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];d=t&&t.symbol}if(0===i.length&&Ee(e)&&(d=e.symbol),d)if(d.type.includes("3d")){const e=d.symbolLayers.at(0);"water"===e.type?null!=e.color&&(y=e.color):null!=e.material?.color&&(y=e.material.color)}else d.url||(y=d.color);const h=this.effectList;return(await Promise.all(c.map((async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const i=Se(e)?s.field:this._getRampTitle(s,t);let l=null;const r=ne(t,s,this.view.timeZone);if("color"===s.type){const e=await G(s,null,r)??[];l={type:"color-ramp",title:i,infos:e,preview:M(e.map((e=>e.color)),{effectList:h,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===s.type&&"outline"!==s.target)pe.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(l=await this._getSizeLegendElement(i,s,e,r),o===s&&"spike"===a?.theme&&(l.theme=a.theme),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===s.type){const e=await G(s,y,r)??[];l={type:"opacity-ramp",title:i,infos:e,preview:M(e.map((e=>e.color)),{effectList:h,ariaLabel:await Ze("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}})))).filter(r)}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const i="getField"in s&&s.getField?.(e),l=i&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(i.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.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,i="popupTemplate"in e&&e.popupTemplate,l=i&&i.fieldInfos;if(l)for(const t of l)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,i=e.normalizationField,l=!1,r=!1,n=!1,a=null;s="function"==typeof s?null:s,i="function"==typeof i?null:i;const o=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?.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){l=!0;break}if("percent"===s.style){r=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:i&&this._getFieldAlias(i,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions?.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let i=s.field,l=null,r=null;if(Ce(s)&&(l=s.normalizationField,r="percent-of-total"===s.normalizationType),i="function"==typeof i?null:i,l="function"==typeof l?null:l,Ie(s)){const{field2:e,field3:l,fieldDelimiter:r}=s;let n=i&&this._getFieldAlias(i,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(i||l)&&(n={field:i&&this._getFieldAlias(i,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const s="popupTemplate"in t?t.popupTemplate:null,i=s?.fieldInfos;let l=i?.find((t=>e===t.fieldName)),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find((t=>e?.toLowerCase()===t.fieldName?.toLowerCase())):void 0,"fields"in a&&a.fields&&(n=a.fields.find((t=>t.name?.toLowerCase()===e?.toLowerCase()))));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return Ce(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([b()],et.prototype,"children",void 0),e([b({readOnly:!0})],et.prototype,"effectList",null),e([b()],et.prototype,"layerView",void 0),e([b()],et.prototype,"layer",void 0),e([b()],et.prototype,"legendElements",void 0),e([b({readOnly:!0})],et.prototype,"opacity",null),e([b()],et.prototype,"parent",void 0),e([b({readOnly:!0,dependsOn:[]})],et.prototype,"ready",null),e([b()],et.prototype,"hideLayersNotInCurrentView",void 0),e([b()],et.prototype,"keepCacheOnDestroy",void 0),e([b()],et.prototype,"respectLayerDefinitionExpression",void 0),e([b()],et.prototype,"respectLayerVisibility",void 0),e([b({readOnly:!0})],et.prototype,"scale",null),e([b()],et.prototype,"sublayerIds",void 0),e([b({readOnly:!0})],et.prototype,"isScaleDriven",null),e([b()],et.prototype,"title",void 0),e([b({readOnly:!0,dependsOn:["ready"],value:0})],et.prototype,"version",null),e([b()],et.prototype,"view",void 0),et=e([S("esri.widgets.Legend.support.ActiveLayerInfo")],et);const tt=et;export{tt as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Color.js";import{round as l,numDigits as t,percentChange as n}from"../../../renderers/support/numberUtils.js";import{updateReferenceSizeSymbol as
|
|
5
|
+
import e from"../../../Color.js";import{round as l,numDigits as t,percentChange as n}from"../../../renderers/support/numberUtils.js";import{updateReferenceSizeSymbol as i}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import{updateSpikeSymbol as o}from"../../../smartMapping/renderers/support/spikeUtils.js";import s from"../../../symbols/SimpleLineSymbol.js";import r from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as a}from"../../../symbols/support/cimSymbolUtils.js";import{isSymbol3D as u}from"../../../symbols/support/typeUtils.js";import{isVolumetricSymbol as c,getSymbolOutlineSize as m}from"../../../symbols/support/utils.js";import{getAuthoringInfoVisualVariableByTheme as p,getSymbolForFlowRenderer as f,createStopLabel as y}from"./utils.js";import"../../support/widgetUtils.js";import{isDarkMode as b}from"../../../support/modeUtils.js";const h=30,d=12,g=24,w=15,S=[255,255,255],z=[200,200,200],v=[128,128,128],k=20,j=5;function V(e){return"esri.symbols.SimpleMarkerSymbol"===e.declaredClass}function x(e){return"esri.symbols.PictureMarkerSymbol"===e.declaredClass}function I(e){return"esri.symbols.SimpleLineSymbol"===e.declaredClass}function U(e){return"esri.symbols.TextSymbol"===e.declaredClass}function M(e,l){const t=e.length-1;return e.map(((e,n)=>y(e,n,t,l)))}async function D(e,t,n,i,o,s,r){const a=t.legendOptions,u=a?.customValues,f=r||await T(e,n),y=t.stops,b=!!f,h=!!u,d=null!=t.minSize&&null!=t.maxSize,S=y&&y.length>1,z=!!t.target;if(!b||!h&&!(d||S&&!z))return;const v=c(f);let k=!1,j=null,V=null;j=v&&!S?l([t.minDataValue,t.maxDataValue]):u??await W(t,f,i,o?.type);const x=e?.authoringInfo,I="univariate-color-size"===x?.type,U=I&&"above-and-below"===x?.univariateTheme,D=!!p(e,"reference-size"),C=!!p(e,"spike");if(!j&&S&&(j=y.map((e=>e.value)),k=y.some((e=>!!e.label)),"flow"===e.type&&(j=l(j)),k&&(V=y.map((e=>e.label)))),v&&null!=j&&j?.length>2&&!U&&(j=[j[0],j[j.length-1]]),!j)return null;I&&5!==j?.length&&(j=A({minSize:j[0],maxSize:j[j.length-1]}));const q=v?L(e,j):null,B=m(f),E=k?null:M(j,s);return(await Promise.all(j.map((async(l,n)=>{let s=v?q[n]:await F(t,f,l,i,o?.type),r=s;D&&(s*=g/t.maxSize||1,r=g),C&&(r={width:w,height:s});return{value:l,symbol:G(f,s,e,n),label:k?V[n]:E[n],size:r,outlineSize:B}})))).reverse()}function L(e,l){const t=e?.authoringInfo,n="univariate-color-size"===t?.type;let i=[d,h];if(n){const e=l[0],t=l[l.length-1],n=d,o=h;i=l.map((l=>n+(l-e)/(t-e)*(o-n)))}return n&&"below"===t?.univariateTheme&&i.reverse(),i}function C(l,t,n,o){const s="class-breaks"===l.type,r=s?l.classBreakInfos?.[0]?.symbol?.clone():l.uniqueValueInfos?.[0]?.symbol?.clone();return r&&"type"in r&&"cim"===r.type?(i(r,{color:o??(s?null:new e(z)),innerDotSize:t*(g/n)||1,outerRingSize:g}),r):null}function q(l,t,n){const i="class-breaks"===l.type,s=i?l.classBreakInfos?.[0]?.symbol?.clone():l.uniqueValueInfos?.[0]?.symbol?.clone();return s&&"type"in s&&"cim"===s.type?(o(s,{color:n??(i?null:new e(z)),height:t,baseWidth:w}),s):null}function B(e,l){const t=e.classBreakInfos,n=t.length,i=n<2||!(l>=2)?t[0].symbol.clone():t[n-1].symbol.clone(),o=e.visualVariables?.some((e=>"color"===e.type));return o&&(i.type.includes("3d")?R(i):P(i)),i}async function T(l,t){if("flow"===l.type)return f(l,t);if("pie-chart"===l.type)return new r({color:null,outline:l.outline?.width?l.outline:new s});let n=null,a=null;if("simple"===l.type)n=l.symbol;else if("class-breaks"===l.type){const e=l.classBreakInfos;n=e&&e[0]&&e[0].symbol,a=e.length>1}else if("unique-value"===l.type){const e=l.uniqueValueInfos;n=e?.[0]?.symbol,a=null!=e&&e.length>1}return!n||E(n)?null:(n=n.clone(),(t||a)&&(n.type.includes("3d")?R(n):p(l,"reference-size")&&"cim"===n.type?i(n,{color:t??("class-breaks"!==l.type?new e(z):null)}):p(l,"spike")&&"cim"===n.type?o(n,{color:t??("class-breaks"!==l.type?new e(z):null)}):P(n)),n)}function E(e){return u(e)?e.symbolLayers?.some((e=>"fill"===e?.type))??!1:e?.type.includes("fill")??!1}function R(e){"line-3d"===e.type?e.symbolLayers.forEach((e=>{e.material={color:v}})):e.symbolLayers.forEach((e=>{"icon"!==e.type||e.resource?.href?e.material={color:z}:(e.material={color:S},e.outline={color:v,size:1.5})}))}function P(l){const t=b();if("cim"===l.type)a(l,new e(z));else if(l.type.includes("line"))l.color=v;else if(l.color=t?v:S,"simple-marker"===l.type)if(l.outline){const e=l.outline?.color?.toHex();"#ffffff"===e&&(l.outline.color=v)}else l.outline={color:v,width:1.5}}async function W(e,t,n,i){const o=(await import("../../../renderers/visualVariables/support/visualVariableUtils.js")).getSizeRangeAtScale(e,n,i),s=o&&A(o);if(!o||!s)return;let r=s.map((l=>H(l,e,o)));r=l(r);for(let l=1;l<r.length-1;l++){const o=await O(e,t,r[l],r[l-1],n,i);o&&(r[l]=o[0],s[l]=o[1])}return r}function A(e){const l=e.minSize,t=e.maxSize,n=j,i=(t-l)/(n-1),o=[];for(let s=0;s<n;s++)o.push(l+i*s);return o}function H(e,l,t){const n=t.minSize,i=t.maxSize,o=l.minDataValue,s=l.maxDataValue;let r;if(e<=n)r=o;else if(e>=i)r=s;else{r=(e-n)/(i-n)*(s-o)+o}return r}async function O(e,i,o,s,r,a){const u=await F(e,i,o,r,a),c=await F(e,i,s,r,a),m=t(o),p=m.fractional,f=k;let y=m.integer,b=null,h=null;o>0&&o<1&&(b=10**p,y=t(o*=b).integer);for(let t=y-1;t>=0;t--){const s=10**t;let m=Math.floor(o/s)*s,p=Math.ceil(o/s)*s;null!=b&&(m/=b,p/=b);let y=(m+p)/2;[,y]=l([m,y,p],{indexes:[1]});const d=await F(e,i,m,r,a),g=await F(e,i,p,r,a),w=await F(e,i,y,r,a),S=n(u,d,c,null),z=n(u,g,c,null),v=n(u,w,c,null);let k=S.previous<=f,j=z.previous<=f;if(k&&j&&(S.previous<=z.previous?(k=!0,j=!1):(j=!0,k=!1)),k?h=[m,d]:j?h=[p,g]:v.previous<=f&&(h=[y,w]),h)break}return h}async function F(e,l,t,n,i){const{getSize:o}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");return o(e,t,{scale:n,view:i,shape:"simple-marker"===l.type?l.style:null})}function G(e,l,t,n){"univariate-color-size"===t?.authoringInfo?.type&&"above-and-below"===t?.authoringInfo?.univariateTheme&&"class-breaks"===t.type&&(e=B(t,n));const s=e.clone();if(u(s))c(s)||s.symbolLayers.forEach((e=>{"fill"!==e.type&&(e.size=l)}));else if(V(s))s.size=l;else if(x(s)){const e=s.width,t=s.height;s.height=l,s.width=l*(e/t)}else I(s)?s.width=l:U(s)?s.font&&(s.font.size=l):"cim"===s.type&&p(t,"reference-size")?i(s,{innerDotSize:l,outerRingSize:g}):"cim"===s.type&&p(t,"spike")&&o(s,{height:l,baseWidth:w});return s}export{D as getRampStops,C as getReferenceSizeSymbol,q as getSpikeSymbol,h as realWorldMaxSize,d as realWorldMinSize};
|