@arcgis/core 4.22.0-next.20211207 → 4.22.0
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{44ccee36f8c74f4f134e.js → 025df54bafc05c183182.js} +1 -1
- package/assets/esri/core/workers/chunks/{23af0b02208e20d5c07e.js → 22c0032451a4e1d43167.js} +1 -1
- package/assets/esri/core/workers/chunks/{fd874267d81bc0b2be50.js → 5915752b754997630665.js} +1 -1
- package/assets/esri/core/workers/chunks/{f3da8b797c8e1fcb1c21.js → 63161320a58a0b1702a2.js} +1 -1
- package/assets/esri/core/workers/chunks/{96a62dc1e07f3ef20a30.js → 67482a0c298e41ea47f5.js} +1 -1
- package/assets/esri/core/workers/chunks/{52aa3b44bddb10caa343.js → 753846665158c1c321ee.js} +1 -1
- package/assets/esri/core/workers/chunks/{8bc4ea821be16a752226.js → 764126387018aa548f58.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc0b85bc1e5116836ba4.js → 79ddc2e92f0f057f6be3.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1e7e0ee0fc8d3ba7c3c.js → 8150ec4b80adcf5fca86.js} +1 -1
- package/assets/esri/core/workers/chunks/{6210b23872c362f51b12.js → 89d1c5f6ed167515ad24.js} +1 -1
- package/assets/esri/core/workers/chunks/{4417dfcb2ba50ac9f199.js → 8ac288ac3ff8e61b98c4.js} +1 -1
- package/assets/esri/core/workers/chunks/95b085ff097005995ced.js +1 -0
- package/assets/esri/core/workers/chunks/{6e736a6717e09bf6c1fc.js → ab635e54fda321961683.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d66ca0feda89e902494.js → c32a849111ae061ae194.js} +1 -1
- package/assets/esri/core/workers/chunks/{6a1ce00bcb689ea95bcb.js → dab0bfa26073cf325e08.js} +1 -1
- package/chunks/Clouds.glsl.js +4 -4
- package/config.js +1 -1
- package/interfaces.d.ts +133 -6
- package/package.json +1 -1
- package/renderers/VectorFieldRenderer.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/MapViewConstraints.js +1 -1
- package/views/2d/constraints/ZoomConstraint.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/3d/environment/Clouds.glsl.js +1 -1
- package/views/3d/environment/CloudsGenerator.js +1 -1
- package/views/3d/environment/NoiseTextureAtlas.js +1 -1
- package/views/MapView.js +1 -1
- package/views/webgl/Program.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/26a4a4762a635109383f.js +0 -1
package/views/MapView.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.22/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import a from"../core/has.js";import{isIterable as n}from"../core/iteratorUtils.js";import o from"../core/Logger.js";import{isSome as h}from"../core/maybe.js";import{init as l}from"../core/watchUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{BreakpointsOwner as u}from"./BreakpointsOwner.js";import{DOMContainer as g}from"./DOMContainer.js";import m from"./MapViewBase.js";import w from"./2d/input/MapViewInputManager.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import a from"../core/has.js";import{isIterable as n}from"../core/iteratorUtils.js";import o from"../core/Logger.js";import{isSome as h}from"../core/maybe.js";import{init as l}from"../core/watchUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{BreakpointsOwner as u}from"./BreakpointsOwner.js";import{DOMContainer as g}from"./DOMContainer.js";import m from"./MapViewBase.js";import w from"./2d/input/MapViewInputManager.js";import y from"./2d/support/HighlightOptions.js";import f from"./support/createScreenshotPlan.js";import{getMaximumResolutionScale as v,getFormatAndQuality as V}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as b,createScreenPointFromSupportedEvent as _}from"./support/screenUtils.js";import{check as M}from"./support/WebGLRequirements.js";import j from"./ui/2d/DefaultUI2D.js";import L from"../webmap/background/ColorBackground.js";const O=o.getLogger("esri.views.MapView");let S,C,k,E,x,N;async function W(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,Stage:a}]=await Promise.all([import("./webgl.js"),import("./2d/mapViewDeps.js")]);C=e,k=t,E=i,x=r,N=s,S=a}let P=class extends(u(g(m))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>{var e,t;return[null==(e=this.basemapView)?void 0:e.baseLayerViews,this.layerViews,null==(t=this.basemapView)?void 0:t.referenceLayerViews]},getChildrenFunction:()=>null}),this.floors=new i,this.graphicsView=null,this.highlightOptions=new y,this.inputManager=new w({view:this}),this.mapViewNavigation=null,this.supersampleScreenshotsEnabled=!1,this.ui=new j,this.rendering=!1,p()}destroy(){this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get background(){return this.get("map.initialViewProperties.background")||null}set background(e){void 0===e?this._clearOverride("background"):this._override("background",e)}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}toMap(e){if(b(e)){const t=_(this,e);return super.toMap(t)}return super.toMap(e)}async hitTest(e,t){const i=b(e)?_(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let r=new Set,s=!1,a=null,n=null;null!=t&&t.include?q(t.include,U(this,(e=>r.add(e)),(e=>{a||(a=new Set),a.add(e)}),(e=>r.add(e)),(()=>s=!0))):(s=!0,r=new Set(this.allLayerViews)),null!=t&&t.exclude&&q(t.exclude,U(this,(e=>r.delete(e)),(e=>{n||(n=new Set),n.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&r.has(e))).reverse(),l=this.toMap(i);let p=(await Promise.all([s?this.graphicsView.hitTest(l):null,...o.map((e=>e.hitTest(l,i)))])).filter(h).flat();return a&&(p=p.filter((e=>a.has(G(e))))),n&&(p=p.filter((e=>!n.has(G(e))))),{screenPoint:i,results:p.map((e=>({mapPoint:l,graphic:e})))}}takeScreenshot(e){e=e||{};const t=this.supersampleScreenshotsEnabled?Math.min(4,v(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:r,quality:s}=V(e.format,e.quality),a=f(e,t,this.size,this.padding,r,s,i,e.rotation);return this._stage.takeScreenshot(a)}on(e,t,i,r){const s=this.inputManager&&this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}validate(){let e=M({checkMajorWebPerformanceCaveat:!1});return a("safari")&&a("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:a("safari")})),h(e)?(O.warn("#validate()",e.message),Promise.reject(e)):W()}_startup(){this.timeline.begin("MapView Startup"),super._startup(),this.graphics.owner=this;const e={disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},t=new S(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:e,renderingOptions:this.renderingOptions,timeline:this.timeline}),i=new C({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new k(this.featuresTilingScheme)}),r=new x({view:this,animationManager:this.animationManager}),s=new E({view:this});this._magnifierView=new N,this._magnifierView.magnifier=this.magnifier,this._stage=t,this.frameTask.graphicsView=i,this._set("graphicsView",i),this._set("mapViewNavigation",r),this._set("labelManager",s),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),t.on("post-render",(()=>this._set("rendering",t.renderRequested))),t.on("will-render",(()=>this._set("rendering",t.renderRequested))),t.on("webgl-error",(e=>this.fatalError=e.error)),l(this,"stationary",(e=>t.stationary=e),!0),l(this,"state.id",(()=>t.state=this.state),!0),l(this,"background",(e=>{t.background=e,this._magnifierView.background=e}),!0),l(this,"magnifier",(e=>this._magnifierView.magnifier=e),!0),l(this,"renderingOptions",(e=>t.renderingOptions=e),!0),l(this,"highlightOptions",(()=>t.highlightOptions=this.highlightOptions),!0)],"map-view"),t.state=this.state,this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup")}_teardown(){this.handles.remove("map-view"),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy();this.graphicsView.destroy(),this.mapViewNavigation.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,super._teardown()}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}};e([d({type:L})],P.prototype,"background",null),e([d()],P.prototype,"floors",void 0),e([d()],P.prototype,"graphicsView",void 0),e([d({type:y})],P.prototype,"highlightOptions",void 0),e([d({readOnly:!0})],P.prototype,"inputManager",void 0),e([d({readOnly:!0})],P.prototype,"resourceManager",null),e([d({readOnly:!0})],P.prototype,"textureManager",null),e([d({readOnly:!0})],P.prototype,"mapViewNavigation",void 0),e([d({type:Boolean})],P.prototype,"navigating",null),e([d({type:Boolean,constructOnly:!0})],P.prototype,"supersampleScreenshotsEnabled",void 0),e([d({type:j})],P.prototype,"ui",void 0),e([d({readOnly:!0})],P.prototype,"rendering",void 0),e([d({constructOnly:!0})],P.prototype,"renderCanvas",void 0),e([d({constructOnly:!0})],P.prototype,"deactivatedWebGLExtensions",void 0),e([d({constructOnly:!0})],P.prototype,"debugWebGLExtensions",void 0),P=e([c("esri.views.MapView")],P);const R=P;function G(e){const t=e.getObjectId();var i,r,s,a;return t?`${null!=(i=null!=(r=null==(s=e.layer)?void 0:s.uid)?r:null==(a=e.sourceLayer)?void 0:a.uid)?i:"MapView"}/${t}`:`"MapView/${e.uid}`}function U(e,i,r,s,a){return n=>{if(n instanceof t){if(n.layer===e)null==a||a();else{const t=e.allLayerViews.find((e=>e.layer===n.layer));t&&(null==s||s(t))}r(G(n))}else{const t=e.allLayerViews.find((e=>e.layer===n));t&&i(t)}}}function q(e,t){if(e)if(n(e))for(const i of e)if(n(i))for(const e of i)t(e);else t(i);else t(e)}export{R as default};
|
package/views/webgl/Program.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.22/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../core/has.js";import{isSome as t,isNone as o}from"../../core/maybe.js";import{webglValidateShadersEnabled as i}from"./checkWebGLError.js";import{ResourceType as r}from"./enums.js";import{transpileShader as
|
|
5
|
+
import"../../core/has.js";import{isSome as t,isNone as o}from"../../core/maybe.js";import{webglValidateShadersEnabled as i}from"./checkWebGLError.js";import{ResourceType as r}from"./enums.js";import{transpileShader as e}from"./ShaderTranspiler.js";class n{constructor(t,o,i,e){this._context=t,this._locations=e,this._nameToUniformLocation={},this._nameToUniform1={},this._nameToUniform1v={},this._nameToUniform2={},this._nameToUniform3={},this._nameToUniform4={},this._nameToUniformMatrix3={},this._nameToUniformMatrix4={},t||console.error("RenderingContext isn't initialized!"),0===o.length&&console.error("Shaders source should not be empty!"),this._vShader=m(this._context,35633,o),this._fShader=m(this._context,35632,i),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(r.VertexShader,this),this._context.instanceCounter.increment(r.FragmentShader,this)}get glName(){if(t(this._glName))return this._glName;if(o(this._vShader))return null;const e=this._context.gl,n=e.createProgram();return e.attachShader(n,this._vShader),e.attachShader(n,this._fShader),this._locations.forEach(((t,o)=>e.bindAttribLocation(n,t,o))),e.linkProgram(n),i()&&!e.getProgramParameter(n,e.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${e.getProgramParameter(n,e.VALIDATE_STATUS)}, gl error ${e.getError()}, vertex: ${e.getShaderParameter(this._vShader,e.COMPILE_STATUS)}, fragment: ${e.getShaderParameter(this._fShader,e.COMPILE_STATUS)}, info log: ${e.getProgramInfoLog(n)}`),this._glName=n,this._context.instanceCounter.increment(r.Program,this),n}dispose(){const t=this._context.gl;this._vShader&&(t.deleteShader(this._vShader),this._vShader=null,this._context.instanceCounter.decrement(r.VertexShader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null,this._context.instanceCounter.decrement(r.FragmentShader,this)),this._glName&&(t.deleteProgram(this._glName),this._glName=null,this._context.instanceCounter.decrement(r.Program,this))}_getUniformLocation(t){return void 0===this._nameToUniformLocation[t]&&(this._nameToUniformLocation[t]=this._context.gl.getUniformLocation(this.glName,t)),this._nameToUniformLocation[t]}hasUniform(t){return null!==this._getUniformLocation(t)}setUniform1i(t,o){const i=this._nameToUniform1[t];if(void 0===i||o!==i){this._context.useProgram(this);this._context.gl.uniform1i(this._getUniformLocation(t),o),this._nameToUniform1[t]=o}}setUniform1iv(t,o){const i=this._nameToUniform1v[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform1iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform1v[t]=Array.from(o):f(o,i)}}setUniform2iv(t,o){const i=this._nameToUniform2[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform2iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform2[t]=Array.from(o):f(o,i)}}setUniform3iv(t,o){const i=this._nameToUniform3[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform3iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform3[t]=Array.from(o):f(o,i)}}setUniform4iv(t,o){const i=this._nameToUniform4[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform4iv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform4[t]=Array.from(o):f(o,i)}}setUniform1f(t,o){const i=this._nameToUniform1[t];if(void 0===i||o!==i){this._context.useProgram(this);this._context.gl.uniform1f(this._getUniformLocation(t),o),this._nameToUniform1[t]=o}}setUniform1fv(t,o){const i=this._nameToUniform1v[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform1fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform1v[t]=Array.from(o):f(o,i)}}setUniform2f(t,o,i){const r=this._nameToUniform2[t];if(void 0===r||o!==r[0]||i!==r[1]){this._context.useProgram(this);this._context.gl.uniform2f(this._getUniformLocation(t),o,i),void 0===r?this._nameToUniform2[t]=[o,i]:(r[0]=o,r[1]=i)}}setUniform2fv(t,o){const i=this._nameToUniform2[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform2fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform2[t]=Array.from(o):f(o,i)}}setUniform3f(t,o,i,r){const e=this._nameToUniform3[t];if(void 0===e||o!==e[0]||i!==e[1]||r!==e[2]){this._context.useProgram(this);this._context.gl.uniform3f(this._getUniformLocation(t),o,i,r),void 0===e?this._nameToUniform3[t]=[o,i,r]:(e[0]=o,e[1]=i,e[2]=r)}}setUniform3fv(t,o){const i=this._nameToUniform3[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform3fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform3[t]=Array.from(o):f(o,i)}}setUniform4f(t,o,i,r,e){const n=this._nameToUniform4[t];if(void 0===n||o!==n[0]||i!==n[1]||r!==n[2]||e!==n[3]){this._context.useProgram(this);this._context.gl.uniform4f(this._getUniformLocation(t),o,i,r,e),void 0===n?this._nameToUniform4[t]=[o,i,r,e]:(n[0]=o,n[1]=i,n[2]=r,n[3]=e)}}setUniform4fv(t,o){const i=this._nameToUniform4[t];if(s(i,o)){this._context.useProgram(this);this._context.gl.uniform4fv(this._getUniformLocation(t),o),void 0===i?this._nameToUniform4[t]=Array.from(o):f(o,i)}}setUniformMatrix3fv(t,o,i=!1,r=!1){const e=this._nameToUniformMatrix3[t];if(r?e!==o:c(e,o)){this._context.useProgram(this);this._context.gl.uniformMatrix3fv(this._getUniformLocation(t),i,o),void 0===e?this._nameToUniformMatrix3[t]=Array.from(o):f(o,e)}}setUniformMatrix4fv(t,o,i=!1){const r=this._nameToUniformMatrix4[t];if(_(r,o)){this._context.useProgram(this);this._context.gl.uniformMatrix4fv(this._getUniformLocation(t),i,o),void 0===r?this._nameToUniformMatrix4[t]=Array.from(o):f(o,r)}}assertCompatibleVertexAttributeLocations(t){t.locations!==this._locations&&console.error("VertexAttributeLocations are incompatible")}stop(){}}function s(t,i){if(o(t)||t.length!==i.length)return!0;for(let o=0;o<t.length;++o)if(t[o]!==i[o])return!0;return!1}function m(t,o,r){const n="webgl2"===t.webglVersion?e(r,o):r,s=t.gl,m=s.createShader(o);return s.shaderSource(m,n),s.compileShader(m),i()&&!s.getShaderParameter(m,s.COMPILE_STATUS)&&(console.error("Compile error in ".concat(35633===o?"vertex":"fragment"," shader")),console.error(s.getShaderInfoLog(m)),console.error(a(n)),"webgl2"===t.webglVersion&&(console.log("Shader source before transpilation:"),console.log(r))),m}function a(t){let o=2;return t.replace(/\n/g,(()=>"\n"+h(o++)+":"))}function h(t){return t>=1e3?t.toString():(" "+t).slice(-3)}function f(t,o){for(let i=0;i<t.length;++i)o[i]=t[i]}function c(t,i){return!!o(t)||(9!==t.length?s(t,i):9!==t.length||t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||t[4]!==i[4]||t[5]!==i[5]||t[6]!==i[6]||t[7]!==i[7]||t[8]!==i[8])}function _(t,i){return!!o(t)||(16!==t.length?s(t,i):16!==t.length||t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||t[4]!==i[4]||t[5]!==i[5]||t[6]!==i[6]||t[7]!==i[7]||t[8]!==i[8]||t[9]!==i[9]||t[10]!==i[10]||t[11]!==i[11]||t[12]!==i[12]||t[13]!==i[13]||t[14]!==i[14]||t[15]!==i[15])}export{n as Program};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.22/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{addTokenParameter as l}from"../../../kernel.js";import s from"../../../request.js";import"../../../symbols.js";import r from"../../../core/Accessor.js";import i from"../../../core/Collection.js";import n from"../../../core/Handles.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{unwrap as u,isSome as c}from"../../../core/maybe.js";import{eachAlways as d,debounce as y}from"../../../core/promiseUtils.js";import{px2pt as h}from"../../../core/screenUtils.js";import{addQueryParameters as m}from"../../../core/urlUtils.js";import{on as p,init as f,whenFalseOnce as g,watch as b}from"../../../core/watchUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{isDateField as E}from"../../../layers/support/fieldUtils.js";import{fromJSON as I}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as C}from"../../../renderers/support/rendererConversion.js";import F from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as R}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as V}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as T,renderDotDensityPreviewHTML as z,renderPreviewHTML as x}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as j}from"../../../symbols/support/utils.js";import{getClusterSizeVariable as O}from"./clusterUtils.js";import{getColorFromPointCloudStops as M,getRampStopsForPointCloud as D,getStrectchRampStops as P,getRampStops as A}from"./colorRampUtils.js";import{getHeatmapRampStops as U}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as B,getRelationshipRampElement as k}from"./relationshipRampUtils.js";import{getRampStops as N,REAL_WORLD_MAX_SIZE as q,REAL_WORLD_MIN_SIZE as W}from"./sizeRampUtils.js";import{SPECIAL_CHARS_LESS_THAN as $,SPECIAL_CHARS_GREATER_THAN as G,RGB_IMG_SOURCE as J}from"./utils.js";import{formatNumberLabel as Q}from"../../smartMapping/support/utils.js";import H from"../../../symbols/SimpleMarkerSymbol.js";import X from"../../../symbols/SimpleFillSymbol.js";const K=o.getLogger("esri.widgets.Legend.support.ActiveLayerInfo"),Y="https://utility.arcgis.com/sharing/tools/legend",Z="esri.layers.ImageryLayer",ee="esri.layers.ImageryTileLayer",te="esri.layers.WCSLayer",le=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,se=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),re={u1:[0,1],u2:[0,3],u4:[0,15],u8:[0,255],s8:[-128,127],u16:[0,65535],s16:[-32768,32767],u32:[0,4294967295],s32:[-2147483648,2147483647],f32:[-34e38,34e38],f64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ie=new H({size:6,outline:{color:[128,128,128,.5],width:.5}}),ne=new X({style:"solid"});function ae(e){return"vector-field"===e.type}function oe(e){return"raster-colormap"===e.type}function ue(e){return"raster-stretch"===e.type}function ce(e){return"raster-shaded-relief"===e.type}function de(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function ye(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function he(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function me(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function pe(e){return ge(e)||be(e)||Se(e)||fe(e)}function fe(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function ge(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function be(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Se(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function _e(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function ve(e,t){return de(e)||ye(e)||he(e)||me(e)||_e(e)?"2d"===t.type||C(e):ue(e)||oe(e)||ce(e)||ge(e)||be(e)||Se(e)||ae(e)}function we(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Le(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ee(e){return"esri.layers.WMSLayer"===e.declaredClass}function Ie(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ce(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Fe(e){return"esri.layers.TileLayer"===e.declaredClass}function Re(e){return"esri.layers.FeatureLayer"===e.declaredClass}function Ve(e){return e.declaredClass===Z}function Te(e){return e.declaredClass===ee}function ze(e){return e.declaredClass===te}function xe(e){return"stretch-ramp"===e.type}function je(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)}function Oe(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)&&"above-and-below"===(null==t?void 0:t.univariateTheme)}const Me=new H({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let De={},Pe=class extends r{constructor(e){super(e),this._handles=new n,this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this.children=new i,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this._handles.add([p(this,"children","change",(t=>{const{added:l,removed:s}=t,r=this._handles;l.forEach((t=>{const l=`activeLayerInfo-ready-watcher-${t.layer.uid}`;r.add(f(t,"ready",e),l)})),s.forEach((e=>r.remove(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(De={})}destroy(){this._handles.destroy(),this._handles=null,this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(De=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new v,t.effect=e.effect,t.end(),t.scale=this.scale),t}get opacity(){var e;const t=this.layer.opacity,l=null==(e=this.parent)?void 0:e.opacity,s=this.layer.parent,r=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=l?l*t:null!=r?r*t:t}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view&&this.view.scale}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction&&"cluster"===e.featureReduction.type)return!0;if("renderer"in e&&e.renderer){if("dot-density"===e.renderer.type)return!0;const t=e.get("renderer.valueExpression");if(le.test(t))return!0;const l=e.get("renderer.visualVariables");if(l)return l.some((e=>this._isScaleDrivenSizeVariable(e)))}return 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(Re(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet&&e.featureSet.features.length){const t=e.layerDefinition,l=t&&t.drawingInfo,s=l&&I(l.renderer),r=se.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:r}):(K.warn("drawingInfo not available!"),null)}return null}));try{const e=[];await d(t).then((t=>{t.forEach((({value:t})=>t&&e.push(...t)))})),this.legendElements=e,this.notifyChange("ready")}catch(l){K.warn("error while building legend for layer!",l)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){K.warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Le(e))this._constructLegendElementsForVoxellayer();else if(Ie(e))this._constructLegendElementsForWMTSlayer();else if(Ee(e))await this._constructLegendElementsForWMSSublayers();else if(we(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ce(e)||Fe(e)||we(e))await this._constructLegendElementsForSublayers();else{this._handles.remove("imageryLayers-watcher");let s="default";if(Ve(e)){var t,l;const r=e;s=((null==r||null==(t=r.renderingRule)?void 0:t.functionName)||"default")+"_"+(null!=(l=e.bandIds)&&l.length?e.bandIds.join(""):"###")}await this._getLegendLayers(`${e.uid}-${s}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const l=t.map((async t=>{if(Ve(e)||Te(e)){const t=e.watch(["renderingRule","bandIds"],(()=>y((async()=>{De.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this._handles.add(t,"imageryLayers-watcher")}const l=this._generateSymbolTableElementForLegendLayer(t);l&&l.infos.length&&(Ve(e)&&(l.title=e.title),this.legendElements.push(l)),this.notifyChange("ready")}));await d(l)})).catch((e=>{K.warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,l=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!l&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await g(t,"updating");const s=l?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();s.geometry=this.view.extent;return 0!==(l?"queryFeatureCount"in t&&await t.queryFeatureCount(s):"queryFeatureCount"in e&&await e.queryFeatureCount(s))}_getParentLayerOpacity(e){let t=1;const l=e.parent;return l&&"uid"in l&&(t=this._getParentLayerOpacity(l)),e.opacity*t}_isGroupActive(){const e=this.children;return!!e.length&&e.some((e=>e.ready))}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,l=t.minSize,s=t.maxSize;return"object"==typeof l&&l?this._isScaleDrivenSizeVariable(l):"object"==typeof s&&s?this._isScaleDrivenSizeVariable(s):!!t.expression||le.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&&Ce(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const l of t.sourceJSON.layers)if(l.id===e.source.mapLayerId&&(l.minScale>0||l.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxellayer(){this.legendElements=[],this._handles.remove("voxel-style-watcher");const e=this.layer;this._handles.add(b(e,"style",(()=>this._constructLegendElementsForVoxellayer())),"voxel-style-watcher");const t=u(e.getVariableStyle(null)),l=[];var s;if(t)if(null!=(s=t.uniqueValues)&&s.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new X({color:t.color,outline:null})})})),e.length&&l.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,r=e.toArray().reverse(),i=s.map(((e,t)=>`${0===t?$:G} ${Q(e)}`)).reverse(),n=r.map((e=>({color:e.color,value:null,label:null})));n[0].label=i[0],n[n.length-1].label=i[1],l.push({type:"color-ramp",title:t.label,infos:n,preview:T(r.map((e=>e.color)))})}const r=e.opacity,i=l.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).map((e=>this._getSymbolPreview(e,r)));await d(i),this.legendElements=l,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this._handles.remove("wmts-activeLayer-watcher");const e=this.layer.activeLayer;if(this._handles.add(b(this.layer,"activeLayer",(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher"),e.styleId&&e.styles){let t=null;e.styles.some((l=>e.styleId===l.id&&(t=l.legendUrl,!0))),t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}])}this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this._handles.remove("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this._handles.add(b(this.layer,"sublayers",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["title","visible","legendEnabled"],(()=>this._constructLegendElementsForWMSSublayers()));if(this._handles.add(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e&&e.infos.length&&l.unshift(e)}}return l}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const l=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){var l;let r=e.legendUrl;if(!r)return;const i={type:"symbol-table",title:e.title||e.name||e.id&&e.id+"",infos:[]};t&&(r=m(r,t));let n=null;const a=null==(l=e.layer)?void 0:l.opacity;try{n=(await s(r,{responseType:"image"})).data,n&&(n.style.opacity=a)}catch{}return i.infos.push({src:r,preview:n,opacity:a}),i}_getLegendLayers(e,t){const l=De&&De[e];return l?Promise.resolve(l):this._legendRequest(t).then((t=>{const l=t.layers;return De[e]=l,l}))}_legendRequest(e){const t=this.layer;let l={f:"json",dynamicLayers:e};if(Ve(t)){const e=t.exportImageServiceParameters.renderingRule;if(e&&(l.renderingRule=JSON.stringify(e.toJSON())),t.bandIds&&(l.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:r}=t;l={raster:e,viewId:s,...l,...r}}}let r=t.url.replace(/(\/)+$/,"");if("version"in t&&t.version>=10.01){const e=r.indexOf("?");e>-1?r=r.substring(0,e)+"/legend"+r.substring(e):r+="/legend"}else{const e=r.toLowerCase().indexOf("/rest/"),t=r.substring(0,e)+r.substring(e+5,r.length);r=Y+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(r,{query:l}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["renderer","opacity","title","visible"],(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible){const e=r&&null!=r.opacity?r.opacity:null,s=null!=e?e*t:t;if("building-group"===r.type){const e={type:"symbol-table",title:r.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(r.sublayers,s);e.infos.push(...t),l=[e,...l]}else if(r.renderer){l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}}}return l.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForSublayers(e,t,l){const s=this.layer;let r=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let i=e.toArray();!l&&this.sublayerIds&&this.sublayerIds.length&&(i=this.sublayerIds.map((e=>s.findSublayerById(e))).filter(Boolean));for(const n of i){const e=n.watch("renderer, opacity, title, visible, legendEnabled",(()=>this._constructLegendElementsForSublayers()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||n.visible&&n.legendEnabled&&this._isSublayerInScale(n)){const e=n&&null!=n.opacity?n.opacity:null,s=null!=e?e*t:t;if(n.renderer&&!n.sublayers&&n.originIdOf("renderer")>2){await n.load();r=[...await this._getRendererLegendElements(n.renderer,{title:n.title,opacity:s,sublayer:n}),...r]}else{const e=await this._generateSymbolTableElementForSublayer(n,s,l);e&&r.unshift(e)}}}return r.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,l){if(!l){l=new Map;const t=this.layer,s=e.source;let r=null;if(!(!s||"map-layer"===s.type&&s.mapLayerId===e.id&&(!s.gdbVersion||s.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new L({layer:this.layer});r=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const i=r||`${t.uid}-default`;(await this._getLegendLayers(i,r)).forEach((e=>l.set(e.layerId,e)))}const s=l.get(e.id);if(!s&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,l);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,l){var s;if(!e||!e.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const r=null==t?void 0:t.renderer;let i=(null==t?void 0:t.title)||e.layerName;if(r&&(!t||(null==t?void 0:t.originIdOf("renderer"))>2)){const e=(null==t?void 0:t.title)||this._getRendererTitle(r,t);e&&(i&&"string"!=typeof e&&"title"in e&&(e.title=i),i=e)}const n={type:"symbol-table",title:i,legendType:e.legendType?e.legendType:null,infos:[]},a=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return(null==(s=e.legendGroups)?void 0:s.length)>0?e.legendGroups.forEach((t=>{var s;const r={type:"symbol-table",title:t.heading,legendType:e.legendType?e.legendType:null,infos:this._generateSymbolTableElementInfosForLegendLayer(a.filter((e=>e.groupId===t.id)),e.layerId,l)};(null==(s=r.infos)?void 0:s.length)>0&&n.infos.push(r)})):n.infos=this._generateSymbolTableElementInfosForLegendLayer(a,e.layerId,l),n.infos.length>0?n:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s){return e.map((e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(0===r.indexOf("http"))return null;r=l(`${this.layer.url}/${t}/images/${r}`)}return{label:e.label,src:r,opacity:null==s?this.opacity:s,width:e.width,height:e.height}})).filter((e=>!!e))}_isSublayerInScale(e){const t=e.minScale||0,l=e.maxScale||0;return!(t>0&&t<this.scale||l>this.scale)}_isLegendLayerInScale(e,t){const l=t||this.layer;let s=null,r=null,i=!0;return!l.minScale&&0!==l.minScale||!l.maxScale&&0!==l.maxScale?(0===e.minScale&&l.tileInfo&&(s=l.tileInfo.lods[0].scale),0===e.maxScale&&l.tileInfo&&(r=l.tileInfo.lods[l.tileInfo.lods.length-1].scale)):(s=Math.min(l.minScale,e.minScale)||l.minScale||e.minScale,r=Math.max(l.maxScale,e.maxScale)),(s>0&&s<this.scale||r>this.scale)&&(i=!1),i}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&this.layer.version<10.1||0===e.length)return e;const l=t.renderer,s=e.some((e=>e.values));let r=null,i=null;return s&&e.some(((e,t)=>(e.values||(r=t,i=e,i.label||(i.label="others")),null!=i))),l?"unique-value"===l.type?i&&(e.splice(r,1),e.push(i)):"class-breaks"===l.type&&(i&&e.splice(r,1),e.reverse(),i&&e.push(i)):i&&(e.splice(r,1),e.push(i)),e}async _getRendererLegendElements(e,t={}){return ve(e,this.view)?pe(e)?this._constructPointCloudRendererLegendElements(e,t):_e(e)?this._constructDotDensityRendererLegendElements(e):this._constructRendererLegendElements(e,t):(K.warn(`Renderer of type '${e.type}' not supported!`),[])}_getPointCloudRendererTitle(e){return e.legendOptions&&e.legendOptions.title||e.field}_constructPointCloudRendererLegendElements(e,t={}){const l=t.title,s=[];let r=null,i=null;if(ge(e))r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{r.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ie,e.color)})}));else if(be(e)){const t=e.stops;let s=null;if(t.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,l=t[t.length-1].value;if(null!=e&&null!=l){s=M(e+(l-e)/2,t)}}r={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ie,s||ie.color)}]};const n=D(e.stops);i={type:"color-ramp",title:l||this._getPointCloudRendererTitle(e),infos:n,preview:T(n.map((e=>e.color)))}}else Se(e)&&(r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos.forEach((e=>{r.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ie,e.color)})})));r&&r.infos.length&&s.push(r),i&&i.infos.length&&s.push(i);const n=s.reduce(((e,t)=>e.concat(t.infos)),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return d(n).then((()=>s))}_getElementInfoForDotDensity(e,t){const{backgroundColor:l,outline:s,dotSize:r}=e,i=this.effectList,n=null==i?void 0:i.effects.map((e=>e.toJSON())),a=w(n),o=r+"-"+t+"-"+l+"-"+(s&&JSON.stringify(s.toJSON()))+"-"+a,u=this._dotDensityUrlCache,c=u.has(o)?u.get(o):z(e,t);u.set(o,c);const d={shape:{type:"image",x:0,y:0,width:c.width,height:c.height,src:c.src},fill:null,stroke:null,offset:[0,0]},y=V([[d]],[c.width,c.height],{effectView:this.effectList});return{opacity:1,src:c.src,preview:y,width:c.width,height:c.height}}_constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),l=e.legendOptions&&e.legendOptions.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:l||""},infos:[]};return e.attributes.forEach((t=>{const l=this._getElementInfoForDotDensity(e,t.color);l.label=t.label||t.valueExpressionTitle||t.field,s.infos.push(l)})),Promise.resolve([s])}async _constructRendererLegendElements(e,t={}){const{title:l,sublayer:s}=t,r=s||this.layer;let i=await this._loadRenderer(e);this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const n=await this._getVisualVariableLegendElements(i,r)||[],a={type:"symbol-table",title:l||this._getRendererTitle(i,r),infos:[]};let o=null,c=!1;const y=new Set;if(je(i)){let e=l;const t=Oe(i)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",s=n.findIndex((e=>"color-ramp"===e.type)),r=-1!==s?n.splice(s,1)[0]:null,a=n.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?n.splice(a,1)[0]:null,u=[];r&&(e=r.title,u.push(r)),o&&(e=o.title,u.push(o)),u.length>0&&n.push({type:t,title:e,infos:u})}else if(me(i)){const e=U(i);n.push({type:"heatmap-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:this.effectList})})}else if(he(i)){const e=i&&i.authoringInfo;if(e&&"relationship"===e.type){const{focus:t,numClasses:l,field1:s,field2:o}=e;if(l&&s&&o){const e=[s,o];let u=B(t)||0;for(const t of e){const{field:e,normalizationField:l,label:s}=t,i=s||{field:this._getFieldAlias(e,r),normField:l&&this._getFieldAlias(l,r)},n=Me.clone();n.angle=u,a.infos.push({label:i,symbol:n}),y.add(n),u+=90}const c=k({focus:t,numClasses:l,infos:i.uniqueValueInfos});n.unshift(c)}}else{const e=i.field;i.uniqueValueInfos.forEach((t=>{t.symbol&&a.infos.push({label:t.label||this._getDomainName(e,t.value,r)||t.value,value:t.value,symbol:t.symbol})}))}i.defaultSymbol&&(a.infos.push({label:i.defaultLabel||"others",symbol:i.defaultSymbol}),c=!0)}else if(ye(i)){o=this._isUnclassedRenderer(i);(!o||!this._hasSizeRamp)&&(i.classBreakInfos.forEach((e=>{e.symbol&&a.infos.unshift({label:e.label||(o?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),o&&(a.title=null),this._updateInfosforClassedSizeRenderer(i,a.infos)),i.defaultSymbol&&!o&&(a.infos.push({label:i.defaultLabel||"others",symbol:i.defaultSymbol}),c=!0)}else if(ue(i))if(Te(this.layer)||ze(this.layer)){const e=this._constructTileImageryStretchRendererElements(i);xe(e)?n.push(e):a.infos=e}else{const e=this.layer;let t,l;var h,m;if(i.statistics&&i.statistics.length)t=null!=i.statistics[0].min?i.statistics[0].min:i.statistics[0][0],l=null!=i.statistics[0].max?i.statistics[0].max:i.statistics[0][1];else t=null==(h=i)?void 0:h.outputMin,l=null==(m=i)?void 0:m.outputMax;let s=[];const r=u(e.renderingRule?await e.generateRasterInfo(e.renderingRule):e.serviceRasterInfo),o=r.keyProperties.BandProperties;1===r.bandCount?(t=null!=t?t:r.statistics&&r.statistics[0].min,l=null!=l?l:r.statistics&&r.statistics[0].max,t||l?n.push(this._getStretchLegendElements(i,{min:t,max:l})):this._getServerSideLegend()):e.bandIds&&1===e.bandIds.length?(t=null!=t?t:r.statistics&&r.statistics[e.bandIds[0]].min,l=null!=l?l:r.statistics&&r.statistics[e.bandIds[0]].max,t||l?n.push(this._getStretchLegendElements(i,{min:t,max:l})):this._getServerSideLegend()):r.bandCount>=3?o&&o.length>=r.bandCount?e.bandIds&&3===e.bandIds.length?(s=e.bandIds.map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):"lerc"===e.format?(s=[0,1,2].map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():"lerc"===e.format?(s=["band1","band2","band3"],a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():this._getServerSideLegend()}else if(oe(i))i.colormapInfos.forEach((e=>{a.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ne,e.color)})}));else if(de(i)){let e=i.symbol;switch(t.geometryType){case"point":e="pointSymbol"in r&&r.pointSymbol;break;case"polyline":e="lineSymbol"in r&&r.lineSymbol;break;case"polygon":e="polygonSymbol"in r&&r.polygonSymbol}i.symbol&&!this._hasSizeRamp&&a.infos.push({label:i.label,symbol:e})}else if(ae(i)){i.outputUnit&&(this.title="("+i.toJSON().outputUnit+")"),a.title=i.attributeField;const e=i.getClassBreakInfos();null!=e&&e.length?e.forEach((e=>{a.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):a.infos.push({label:i.attributeField,symbol:i.getDefaultSymbol()})}else ce(i)&&n.push(this._getStretchLegendElements(i,{min:0,max:255}));const p=i.defaultSymbol;!p||c||de(i)||o&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||n.push({type:"symbol-table",infos:[{label:i.defaultLabel||"others",symbol:p}]}),a.infos.length&&n.unshift(a);const f=null==t.opacity?this.opacity:t.opacity,g=this._isTallSymbol("visualVariables"in i&&i.visualVariables),b=Ve(this.layer)||Te(this.layer),S=n.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).map((e=>this._getSymbolPreview(e,f,{isDefault:e.symbol===p,applyScaleDrivenSize:!y.has(e.symbol),symbolConfig:{isTall:g,isSquareFill:b},effectList:y.has(e.symbol)?null:this.effectList})));return i=null,await d(S),n}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=null==e?void 0:e.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}_constructTileImageryStretchRendererElements(e){var t,l;const s=this.layer,r=s.rasterInfo,i=r.bandCount||e.statistics.length;let n,a,o=[];const u=r.keyProperties&&r.keyProperties.BandProperties,c=null!=e&&null!=(t=e.statistics)&&t.length?e.statistics:null==r?void 0:r.statistics;if(c)n=void 0!==c[0].min?c[0].min:c[0][0],a=c[0].max||c[0][1];else{const e=re[s.rasterInfo.pixelType.toLowerCase()];n=e[0],a=e[1]}if(s.hasStandardTime()&&(n=s.getStandardTimeValue(n),a=s.getStandardTimeValue(a)),1===r.bandCount||1===(null==(l=s.bandIds)?void 0:l.length))return this._getStretchLegendElements(e,{min:n,max:a});function d(e){var t;const l=(null!=s&&null!=(t=s.bandIds)&&t.length?s.bandIds:Array.from(Array(Math.min(r.bandCount,3)).keys())).map((t=>e&&e[t]&&e[t].BandName||"band"+(t+1)));return l.length<3?l.push(l[1]):l.length>3&&l.splice(3),l}return o=u&&u.length>=i?d(u):d(),this._createSymbolTableElementMultiBand(o)}_getStretchLegendElements(e,t){const l=e.colorRamp,s=P(l,t);return{type:"stretch-ramp",title:"",infos:s,preview:T(s.map((e=>e.color)))}}_createSymbolTableElementMultiBand(e){const t=[],l=["red","green","blue"];return e.forEach(((e,s)=>{t.push({label:{colorName:l[s],bandName:e},src:J[s],opacity:1})})),t}_updateInfosforClassedSizeRenderer(e,t){const l=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some((e=>j(e.symbol)));if(l&&s){const l=q,s=W,r=e.classBreakInfos.length,i=(l-s)/(r>1?r-1:r);t.forEach(((e,t)=>{e.size=l-i*t}))}}_isTallSymbol(e){let t=!1,l=!1;if(e)for(let s=0;s<e.length&&(!t||!l);s++){const r=e[s];"size"===r.type&&("height"===r.axis&&(t=!0),"width-and-depth"===r.axis&&(l=!0))}return t&&l}async _getSymbolPreview(e,t,l){let s=null!=l&&l.isDefault||null!=e.size||!this._hasSizeRamp?e.size:h(22);if(this._scaleDrivenSizeVariable&&null!=l&&l.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");s=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return x(e.symbol,{size:s,opacity:t,scale:!1,symbolConfig:null==l?void 0:l.symbolConfig,effectView:null==l?void 0:l.effectList}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}async _loadRenderer(e){var t,l;const s=[],r=this.layer;e=e.clone(),this._hasClusterSizeVariable=!1;const i="visualVariables"in e&&(null==(t=e.visualVariables)?void 0:t.some((e=>"size"===e.type&&"outline"!==e.target&&!le.test(e.valueExpression))));if(e&&"visualVariables"in e&&!i&&"featureReduction"in r&&"cluster"===(null==(l=r.featureReduction)?void 0:l.type)){const t=this.layerView._effectiveRenderer,l=u(O(t,this.view));if(l){const t=r.featureReduction;if("clusterMinSize"in t&&"clusterMaxSize"in t){const{clusterMinSize:e,clusterMaxSize:s}=t;l.legendOptions=new F({showLegend:e!==s})}const s=e.visualVariables||[];e.visualVariables=s.concat([l]),this._hasClusterSizeVariable=!0}}const n=await this._getMedianColor(e);if(ye(e)||he(e)){const t=(e.classBreakInfos||e.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,n).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(s,t)}return s.push(this._fetchSymbol(e.symbol||e.defaultSymbol,e.defaultSymbol?null:n).then((t=>{this._applySymbolToRenderer(e,t,de(e))})).catch((()=>{this._applySymbolToRenderer(e,null,de(e))}))),d(s).then((()=>e))}_applySymbolToRenderer(e,t,l){l?e.symbol=t:e.defaultSymbol=t}async _getMedianColor(e){if(!("visualVariables"in e)||!e.visualVariables)return null;const t=e.visualVariables.find((e=>"color"===e.type));if(!t)return null;let l=null,s=null;if(t.stops){if(1===t.stops.length)return t.stops[0].color;l=t.stops[0].value,s=t.stops[t.stops.length-1].value}const r=l+(s-l)/2,{getColor:i}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");return i(t,r)}_fetchSymbol(e,t){if(!e)return Promise.reject();if("web-style"===e.type){const l=e.portal,s=l&&l.url,r=l&&l.user&&l.user.username,i=e.name+"-"+e.styleName+"-"+e.styleUrl+"-"+s+"-"+r,n=this._webStyleSymbolCache;return n.has(i)||("2d"===this.view.type?n.set(i,e.fetchCIMSymbol()):n.set(i,e.fetchSymbol())),n.get(i).then((e=>this._getAppliedCloneSymbol(e,t))).catch((()=>(K.warn("Fetching web-style failed!"),Promise.reject())))}return Promise.resolve(this._getAppliedCloneSymbol(e,t))}_getAppliedCloneSymbol(e,l){if(!e||!l)return e;const s=e.clone(),r=l&&l.toRgba();return s.type.indexOf("3d")>-1?this._applyColorTo3dSymbol(s,r):"cim"===s.type?R(s,l):s.color&&(s.color=new t(r||s.color)),s}_applyColorTo3dSymbol(e,l){l&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(l))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const l=e.visualVariables,s=[],r=[],i=[];for(const c of l)"color"===c.type?s.push(c):"size"===c.type?r.push(c):"opacity"===c.type&&i.push(c);const n=[...s,...r,...i];let a,o;if(0===s.length&&ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];a=t&&t.symbol}if(0===s.length&&de(e)&&(a=e.symbol),a)if(a.type.indexOf("3d")>-1){const e=a.symbolLayers.getItemAt(0);"water"===e.type?c(e.color)&&(o=e.color):c(e.material)&&c(e.material.color)&&(o=e.material.color)}else a.url||(o=a.color);const u=this.effectList;return(await Promise.all(n.map((async l=>{if(!l.legendOptions||!1!==l.legendOptions.showLegend){const s=this._getRampTitle(l,t);let r=null;const i="getField"in t&&t.getField&&t.getField(l.field),n=i&&E(i);if("color"===l.type){const e=await A(l,null,n);r={type:"color-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasColorRamp||(this._hasColorRamp=!(null==r.infos||!r.infos.length))}else if("size"===l.type&&"outline"!==l.target)le.test(l.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=l):(r={type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(l):s,infos:await N(e,l,await this._getMedianColor(e),this.scale,this.view.type,n)},this._hasSizeRamp||(this._hasSizeRamp=!(null==r.infos||!r.infos.length)));else if("opacity"===l.type){const e=await A(l,o,n);r={type:"opacity-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasOpacityRamp||(this._hasOpacityRamp=!(null==r.infos||!r.infos.length))}return r&&r.infos?r:null}})))).filter((e=>!!e))}_getDomainName(e,t,l){if(e&&"function"!=typeof e){const s="getField"in l&&l.getField&&l.getField(e),r=s&&"getFieldDomain"in l&&l.getFieldDomain?l.getFieldDomain(s.name):null;return r&&"coded-value"===r.type?r.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,l=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,r=s&&s.fieldInfos;if(r)for(const t of r)if(t.fieldName===l)return"cluster_count"===l?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let l=e.field,s=e.normalizationField,r=!1,i=!1,n=!1,a=null;l="function"==typeof l?null:l,s="function"==typeof s?null:s;const o=e.legendOptions&&e.legendOptions.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo&&t.renderer.authoringInfo.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const l=e[t];if("color"===l.type){if("ratio"===l.style){r=!0;break}if("percent"===l.style){i=!0;break}if("percent-of-total"===l.style){n=!0;break}}}}a={field:l&&this._getFieldAlias(l,t),normField:s&&this._getFieldAlias(s,t),ratio:r,ratioPercent:i,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const l=e;if(l.legendOptions&&l.legendOptions.title)return l.legendOptions.title;if(l.valueExpressionTitle)return l.valueExpressionTitle;let s=l.field,r=null,i=null;ye(l)&&(r=l.normalizationField,i="percent-of-total"===l.normalizationType),s="function"==typeof s?null:s,r="function"==typeof r?null:r;let n=null;return(s||r)&&(n={field:s&&this._getFieldAlias(s,t),normField:r&&this._getFieldAlias(r,t),normByPct:i}),n}_getFieldAlias(e,t){const l="popupTemplate"in t&&t.popupTemplate,s=l&&l.fieldInfos;let r=null;s&&s.some((t=>e===t.fieldName&&(r=t,!0)));let i=null;"getField"in t&&t.getField?i=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(i=t.fieldsIndex.get(e));const n=r||i;let a=null;return n&&(a=r&&r.label||i&&i.alias||"name"in n&&n.name||"fieldName"in n&&n.fieldName),a}_isUnclassedRenderer(e){const t=e.visualVariables;let l=!1;return ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(l=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),l}};e([S()],Pe.prototype,"children",void 0),e([S({readOnly:!0})],Pe.prototype,"effectList",null),e([S()],Pe.prototype,"layerView",void 0),e([S()],Pe.prototype,"layer",void 0),e([S()],Pe.prototype,"legendElements",void 0),e([S({readOnly:!0})],Pe.prototype,"opacity",null),e([S()],Pe.prototype,"parent",void 0),e([S({readOnly:!0,dependsOn:[]})],Pe.prototype,"ready",null),e([S()],Pe.prototype,"hideLayersNotInCurrentView",void 0),e([S()],Pe.prototype,"keepCacheOnDestroy",void 0),e([S()],Pe.prototype,"respectLayerVisibility",void 0),e([S({readOnly:!0})],Pe.prototype,"scale",null),e([S()],Pe.prototype,"sublayerIds",void 0),e([S({readOnly:!0})],Pe.prototype,"isScaleDriven",null),e([S()],Pe.prototype,"title",void 0),e([S({readOnly:!0,dependsOn:["ready"],value:0})],Pe.prototype,"version",null),e([S()],Pe.prototype,"view",void 0),Pe=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],Pe);const Ae=Pe;export{Ae as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{addTokenParameter as l}from"../../../kernel.js";import s from"../../../request.js";import"../../../symbols.js";import r from"../../../core/Accessor.js";import n from"../../../core/Collection.js";import i from"../../../core/Handles.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{unwrap as u,isSome as c}from"../../../core/maybe.js";import{eachAlways as d,debounce as y}from"../../../core/promiseUtils.js";import{px2pt as h}from"../../../core/screenUtils.js";import{addQueryParameters as m}from"../../../core/urlUtils.js";import{on as p,init as f,whenFalseOnce as g,watch as b}from"../../../core/watchUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{isDateField as E}from"../../../layers/support/fieldUtils.js";import{fromJSON as I}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as C}from"../../../renderers/support/rendererConversion.js";import F from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{applyCIMSymbolColor as R}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as V}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as T,renderDotDensityPreviewHTML as z,renderPreviewHTML as x}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as j}from"../../../symbols/support/utils.js";import{getClusterSizeVariable as O}from"./clusterUtils.js";import{getColorFromPointCloudStops as D,getRampStopsForPointCloud as M,getStrectchRampStops as P,getRampStops as A}from"./colorRampUtils.js";import{getHeatmapRampStops as U}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as B,getRelationshipRampElement as k}from"./relationshipRampUtils.js";import{getRampStops as N,REAL_WORLD_MAX_SIZE as q,REAL_WORLD_MIN_SIZE as W}from"./sizeRampUtils.js";import{SPECIAL_CHARS_LESS_THAN as $,SPECIAL_CHARS_GREATER_THAN as G,RGB_IMG_SOURCE as J}from"./utils.js";import{formatNumberLabel as Q}from"../../smartMapping/support/utils.js";import H from"../../../symbols/SimpleMarkerSymbol.js";import X from"../../../symbols/SimpleFillSymbol.js";const K=o.getLogger("esri.widgets.Legend.support.ActiveLayerInfo"),Y="https://utility.arcgis.com/sharing/tools/legend",Z="esri.layers.ImageryLayer",ee="esri.layers.ImageryTileLayer",te="esri.layers.WCSLayer",le=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,se=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),re={u1:[0,1],u2:[0,3],u4:[0,15],u8:[0,255],s8:[-128,127],u16:[0,65535],s16:[-32768,32767],u32:[0,4294967295],s32:[-2147483648,2147483647],f32:[-34e38,34e38],f64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ne=new H({size:6,outline:{color:[128,128,128,.5],width:.5}}),ie=new X({style:"solid"});function ae(e){return"vector-field"===e.type}function oe(e){return"raster-colormap"===e.type}function ue(e){return"raster-stretch"===e.type}function ce(e){return"raster-shaded-relief"===e.type}function de(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function ye(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function he(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function me(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function pe(e){return ge(e)||be(e)||Se(e)||fe(e)}function fe(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function ge(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function be(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Se(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function _e(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function ve(e,t){return de(e)||ye(e)||he(e)||me(e)||_e(e)?"2d"===t.type||C(e):ue(e)||oe(e)||ce(e)||ge(e)||be(e)||Se(e)||ae(e)}function we(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Le(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ee(e){return"esri.layers.WMSLayer"===e.declaredClass}function Ie(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ce(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Fe(e){return"esri.layers.TileLayer"===e.declaredClass}function Re(e){return"esri.layers.FeatureLayer"===e.declaredClass}function Ve(e){return e.declaredClass===Z}function Te(e){return e.declaredClass===ee}function ze(e){return e.declaredClass===te}function xe(e){return"stretch-ramp"===e.type}function je(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)}function Oe(e){const t="authoringInfo"in e&&(null==e?void 0:e.authoringInfo);return"univariate-color-size"===(null==t?void 0:t.type)&&"above-and-below"===(null==t?void 0:t.univariateTheme)}const De=new H({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Me={},Pe=class extends r{constructor(e){super(e),this._handles=new i,this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this._handles.add([p(this,"children","change",(t=>{const{added:l,removed:s}=t,r=this._handles;l.forEach((t=>{const l=`activeLayerInfo-ready-watcher-${t.layer.uid}`;r.add(f(t,"ready",e),l)})),s.forEach((e=>r.remove(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(Me={})}destroy(){this._handles.destroy(),this._handles=null,this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Me=null)}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new v,t.effect=e.effect,t.end(),t.scale=this.scale),t}get opacity(){var e;const t=this.layer.opacity,l=null==(e=this.parent)?void 0:e.opacity,s=this.layer.parent,r=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=l?l*t:null!=r?r*t:t}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view&&this.view.scale}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction&&"cluster"===e.featureReduction.type)return!0;if("renderer"in e&&e.renderer){if("dot-density"===e.renderer.type)return!0;const t=e.get("renderer.valueExpression");if(le.test(t))return!0;const l=e.get("renderer.visualVariables");if(l)return l.some((e=>this._isScaleDrivenSizeVariable(e)))}return 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(Re(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet&&e.featureSet.features.length){const t=e.layerDefinition,l=t&&t.drawingInfo,s=l&&I(l.renderer),r=se.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:r}):(K.warn("drawingInfo not available!"),null)}return null}));try{const e=[];await d(t).then((t=>{t.forEach((({value:t})=>t&&e.push(...t)))})),this.legendElements=e,this.notifyChange("ready")}catch(l){K.warn("error while building legend for layer!",l)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){K.warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Le(e))this._constructLegendElementsForVoxellayer();else if(Ie(e))this._constructLegendElementsForWMTSlayer();else if(Ee(e))await this._constructLegendElementsForWMSSublayers();else if(we(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ce(e)||Fe(e)||we(e))await this._constructLegendElementsForSublayers();else{this._handles.remove("imageryLayers-watcher");let s="default";if(Ve(e)){var t,l;const r=e;s=((null==r||null==(t=r.renderingRule)?void 0:t.functionName)||"default")+"_"+(null!=(l=e.bandIds)&&l.length?e.bandIds.join(""):"###")}await this._getLegendLayers(`${e.uid}-${s}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const l=t.map((async t=>{if(Ve(e)||Te(e)){const t=e.watch(["renderingRule","bandIds"],(()=>y((async()=>{Me.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this._handles.add(t,"imageryLayers-watcher")}const l=this._generateSymbolTableElementForLegendLayer(t);l&&l.infos.length&&(Ve(e)&&(l.title=e.title),this.legendElements.push(l)),this.notifyChange("ready")}));await d(l)})).catch((e=>{K.warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,l=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!l&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await g(t,"updating");const s=l?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();s.geometry=this.view.extent;return 0!==(l?"queryFeatureCount"in t&&await t.queryFeatureCount(s):"queryFeatureCount"in e&&await e.queryFeatureCount(s))}_getParentLayerOpacity(e){let t=1;const l=e.parent;return l&&"uid"in l&&(t=this._getParentLayerOpacity(l)),e.opacity*t}_isGroupActive(){const e=this.children;return!!e.length&&e.some((e=>e.ready))}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,l=t.minSize,s=t.maxSize;return"object"==typeof l&&l?this._isScaleDrivenSizeVariable(l):"object"==typeof s&&s?this._isScaleDrivenSizeVariable(s):!!t.expression||le.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&&Ce(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const l of t.sourceJSON.layers)if(l.id===e.source.mapLayerId&&(l.minScale>0||l.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxellayer(){this.legendElements=[],this._handles.remove("voxel-style-watcher");const e=this.layer;this._handles.add(b(e,"style",(()=>this._constructLegendElementsForVoxellayer())),"voxel-style-watcher");const t=u(e.getVariableStyle(null)),l=[];var s;if(t)if(null!=(s=t.uniqueValues)&&s.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new X({color:t.color,outline:null})})})),e.length&&l.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,r=e.toArray().reverse(),n=s.map(((e,t)=>`${0===t?$:G} ${Q(e)}`)).reverse(),i=r.map((e=>({color:e.color,value:null,label:null})));i[0].label=n[0],i[i.length-1].label=n[1],l.push({type:"color-ramp",title:t.label,infos:i,preview:T(r.map((e=>e.color)))})}const r=e.opacity,n=l.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).map((e=>this._getSymbolPreview(e,r)));await d(n),this.legendElements=l,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this._handles.remove("wmts-activeLayer-watcher");const e=this.layer.activeLayer;if(this._handles.add(b(this.layer,"activeLayer",(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher"),e.styleId&&e.styles){let t=null;e.styles.some((l=>e.styleId===l.id&&(t=l.legendUrl,!0))),t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}])}this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this._handles.remove("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this._handles.add(b(this.layer,"sublayers",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["title","visible","legendEnabled"],(()=>this._constructLegendElementsForWMSSublayers()));if(this._handles.add(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e&&e.infos.length&&l.unshift(e)}}return l}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const l=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:l}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){var l;let r=e.legendUrl;if(!r)return;const n={type:"symbol-table",title:e.title||e.name||e.id&&e.id+"",infos:[]};t&&(r=m(r,t));let i=null;const a=null==(l=e.layer)?void 0:l.opacity;try{i=(await s(r,{responseType:"image"})).data,i&&(i.style.opacity=a)}catch{}return n.infos.push({src:r,preview:i,opacity:a}),n}_getLegendLayers(e,t){const l=Me&&Me[e];return l?Promise.resolve(l):this._legendRequest(t).then((t=>{const l=t.layers;return Me[e]=l,l}))}_legendRequest(e){const t=this.layer;let l={f:"json",dynamicLayers:e};if(Ve(t)){const e=t.exportImageServiceParameters.renderingRule;if(e&&(l.renderingRule=JSON.stringify(e.toJSON())),t.bandIds&&(l.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:r}=t;l={raster:e,viewId:s,...l,...r}}}let r=t.url.replace(/(\/)+$/,"");if("version"in t&&t.version>=10.01){const e=r.indexOf("?");e>-1?r=r.substring(0,e)+"/legend"+r.substring(e):r+="/legend"}else{const e=r.toLowerCase().indexOf("/rest/"),t=r.substring(0,e)+r.substring(e+5,r.length);r=Y+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(r,{query:l}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let l=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const s=e.toArray();for(const r of s){const e=r.watch(["renderer","opacity","title","visible"],(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible){const e=r&&null!=r.opacity?r.opacity:null,s=null!=e?e*t:t;if("building-group"===r.type){const e={type:"symbol-table",title:r.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(r.sublayers,s);e.infos.push(...t),l=[e,...l]}else if(r.renderer){l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}}}return l.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this._handles.remove("sublayers-watcher");const e=this.layer;this._handles.add(b(e,"sublayers",(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){K.warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForSublayers(e,t,l){const s=this.layer;let r=[];this._handles.add(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!l&&this.sublayerIds&&this.sublayerIds.length&&(n=this.sublayerIds.map((e=>s.findSublayerById(e))).filter(Boolean));for(const i of n){const e=i.watch("renderer, opacity, title, visible, legendEnabled",(()=>this._constructLegendElementsForSublayers()));if(this._handles.add(e,"sublayers-watcher"),!this.respectLayerVisibility||i.visible&&i.legendEnabled&&this._isSublayerInScale(i)){const e=i&&null!=i.opacity?i.opacity:null,s=null!=e?e*t:t;if(i.renderer&&!i.sublayers&&i.originIdOf("renderer")>2){await i.load();r=[...await this._getRendererLegendElements(i.renderer,{title:i.title,opacity:s,sublayer:i}),...r]}else{const e=await this._generateSymbolTableElementForSublayer(i,s,l);e&&r.unshift(e)}}}return r.filter((e=>!!e&&(!("infos"in e)||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,l){if(!l){l=new Map;const t=this.layer,s=e.source;let r=null;if(!(!s||"map-layer"===s.type&&s.mapLayerId===e.id&&(!s.gdbVersion||s.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new L({layer:this.layer});r=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const n=r||`${t.uid}-default`;(await this._getLegendLayers(n,r)).forEach((e=>l.set(e.layerId,e)))}const s=l.get(e.id);if(!s&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,l);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,l){var s;if(!e||!e.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const r=null==t?void 0:t.renderer;let n=(null==t?void 0:t.title)||e.layerName;if(r&&(!t||(null==t?void 0:t.originIdOf("renderer"))>2)){const e=(null==t?void 0:t.title)||this._getRendererTitle(r,t);e&&(n&&"string"!=typeof e&&"title"in e&&(e.title=n),n=e)}const i={type:"symbol-table",title:n,legendType:e.legendType?e.legendType:null,infos:[]},a=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return(null==(s=e.legendGroups)?void 0:s.length)>0?e.legendGroups.forEach((t=>{var s;const r={type:"symbol-table",title:t.heading,legendType:e.legendType?e.legendType:null,infos:this._generateSymbolTableElementInfosForLegendLayer(a.filter((e=>e.groupId===t.id)),e.layerId,l)};(null==(s=r.infos)?void 0:s.length)>0&&i.infos.push(r)})):i.infos=this._generateSymbolTableElementInfosForLegendLayer(a,e.layerId,l),i.infos.length>0?i:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s){return e.map((e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(0===r.indexOf("http"))return null;r=l(`${this.layer.url}/${t}/images/${r}`)}return{label:e.label,src:r,opacity:null==s?this.opacity:s,width:e.width,height:e.height}})).filter((e=>!!e))}_isSublayerInScale(e){const t=e.minScale||0,l=e.maxScale||0;return!(t>0&&t<this.scale||l>this.scale)}_isLegendLayerInScale(e,t){const l=t||this.layer;let s=null,r=null,n=!0;return!l.minScale&&0!==l.minScale||!l.maxScale&&0!==l.maxScale?(0===e.minScale&&l.tileInfo&&(s=l.tileInfo.lods[0].scale),0===e.maxScale&&l.tileInfo&&(r=l.tileInfo.lods[l.tileInfo.lods.length-1].scale)):(s=Math.min(l.minScale,e.minScale)||l.minScale||e.minScale,r=Math.max(l.maxScale,e.maxScale)),(s>0&&s<this.scale||r>this.scale)&&(n=!1),n}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&this.layer.version<10.1||0===e.length)return e;const l=t.renderer,s=e.some((e=>e.values));let r=null,n=null;return s&&e.some(((e,t)=>(e.values||(r=t,n=e,n.label||(n.label="others")),null!=n))),l?"unique-value"===l.type?n&&(e.splice(r,1),e.push(n)):"class-breaks"===l.type&&(n&&e.splice(r,1),e.reverse(),n&&e.push(n)):n&&(e.splice(r,1),e.push(n)),e}async _getRendererLegendElements(e,t={}){return ve(e,this.view)?pe(e)?this._constructPointCloudRendererLegendElements(e,t):_e(e)?this._constructDotDensityRendererLegendElements(e):this._constructRendererLegendElements(e,t):(K.warn(`Renderer of type '${e.type}' not supported!`),[])}_getPointCloudRendererTitle(e){return e.legendOptions&&e.legendOptions.title||e.field}_constructPointCloudRendererLegendElements(e,t={}){const l=t.title,s=[];let r=null,n=null;if(ge(e))r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{r.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(ne,e.color)})}));else if(be(e)){const t=e.stops;let s=null;if(t.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,l=t[t.length-1].value;if(null!=e&&null!=l){s=D(e+(l-e)/2,t)}}r={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(ne,s||ne.color)}]};const i=M(e.stops);n={type:"color-ramp",title:l||this._getPointCloudRendererTitle(e),infos:i,preview:T(i.map((e=>e.color)))}}else Se(e)&&(r={type:"symbol-table",title:l||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos.forEach((e=>{r.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(ne,e.color)})})));r&&r.infos.length&&s.push(r),n&&n.infos.length&&s.push(n);const i=s.reduce(((e,t)=>e.concat(t.infos)),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return d(i).then((()=>s))}_getElementInfoForDotDensity(e,t){const{backgroundColor:l,outline:s,dotSize:r}=e,n=this.effectList,i=null==n?void 0:n.effects.map((e=>e.toJSON())),a=w(i),o=r+"-"+t+"-"+l+"-"+(s&&JSON.stringify(s.toJSON()))+"-"+a,u=this._dotDensityUrlCache,c=u.has(o)?u.get(o):z(e,t);u.set(o,c);const d={shape:{type:"image",x:0,y:0,width:c.width,height:c.height,src:c.src},fill:null,stroke:null,offset:[0,0]},y=V([[d]],[c.width,c.height],{effectView:this.effectList});return{opacity:1,src:c.src,preview:y,width:c.width,height:c.height}}_constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),l=e.legendOptions&&e.legendOptions.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:l||""},infos:[]};return e.attributes.forEach((t=>{const l=this._getElementInfoForDotDensity(e,t.color);l.label=t.label||t.valueExpressionTitle||t.field,s.infos.push(l)})),Promise.resolve([s])}async _constructRendererLegendElements(e,t={}){const{title:l,sublayer:s}=t,r=s||this.layer;let n=await this._loadRenderer(e);this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const i=await this._getVisualVariableLegendElements(n,r)||[],a={type:"symbol-table",title:l||this._getRendererTitle(n,r),infos:[]};let o=null,c=!1;const y=new Set;if(je(n)){let e=l;const t=Oe(n)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",s=i.findIndex((e=>"color-ramp"===e.type)),r=-1!==s?i.splice(s,1)[0]:null,a=i.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?i.splice(a,1)[0]:null,u=[];r&&(e=r.title,u.push(r)),o&&(e=o.title,u.push(o)),u.length>0&&i.push({type:t,title:e,infos:u})}else if(me(n)){const e=U(n);i.push({type:"heatmap-ramp",title:l,infos:e,preview:T(e.map((e=>e.color)),{effectList:this.effectList})})}else if(he(n)){const e=n&&n.authoringInfo;if(e&&"relationship"===e.type){const{focus:t,numClasses:l,field1:s,field2:o}=e;if(l&&s&&o){const e=[s,o];let u=B(t)||0;for(const t of e){const{field:e,normalizationField:l,label:s}=t,n=s||{field:this._getFieldAlias(e,r),normField:l&&this._getFieldAlias(l,r)},i=De.clone();i.angle=u,a.infos.push({label:n,symbol:i}),y.add(i),u+=90}const c=k({focus:t,numClasses:l,infos:n.uniqueValueInfos});i.unshift(c)}}else{const e=n.field;n.uniqueValueInfos.forEach((t=>{t.symbol&&a.infos.push({label:t.label||this._getDomainName(e,t.value,r)||t.value,value:t.value,symbol:t.symbol})}))}n.defaultSymbol&&(a.infos.push({label:n.defaultLabel||"others",symbol:n.defaultSymbol}),c=!0)}else if(ye(n)){o=this._isUnclassedRenderer(n);(!o||!this._hasSizeRamp)&&(n.classBreakInfos.forEach((e=>{e.symbol&&a.infos.unshift({label:e.label||(o?null:e.minValue+" - "+e.maxValue),value:[e.minValue,e.maxValue],symbol:e.symbol})})),o&&(a.title=null),this._updateInfosforClassedSizeRenderer(n,a.infos)),n.defaultSymbol&&!o&&(a.infos.push({label:n.defaultLabel||"others",symbol:n.defaultSymbol}),c=!0)}else if(ue(n))if(Te(this.layer)||ze(this.layer)){const e=this._constructTileImageryStretchRendererElements(n);xe(e)?i.push(e):a.infos=e}else{const e=this.layer;let t,l;n.statistics&&n.statistics.length&&(t=null!=n.statistics[0].min?n.statistics[0].min:n.statistics[0][0],l=null!=n.statistics[0].max?n.statistics[0].max:n.statistics[0][1]);let s=[];const r=u(e.renderingRule?await e.generateRasterInfo(e.renderingRule):e.serviceRasterInfo),o=r.keyProperties.BandProperties,c=re[e.rasterInfo.pixelType.toLowerCase()];1===r.bandCount||e.bandIds&&1===e.bandIds.length?(t=null!=t?t:r.statistics?r.statistics[e.bandIds[0]].min:c[0],l=null!=l?l:r.statistics?r.statistics[e.bandIds[0]].max:c[1],t||l?i.push(this._getStretchLegendElements(n,{min:t,max:l})):this._getServerSideLegend()):r.bandCount>=3?o&&o.length>=r.bandCount?e.bandIds&&3===e.bandIds.length?(s=e.bandIds.map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):"lerc"===e.format?(s=[0,1,2].map((e=>o[e].BandName)),a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():"lerc"===e.format?(s=["band1","band2","band3"],a.infos=this._createSymbolTableElementMultiBand(s)):this._getServerSideLegend():this._getServerSideLegend()}else if(oe(n))n.colormapInfos.forEach((e=>{a.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ie,e.color)})}));else if(de(n)){let e=n.symbol;switch(t.geometryType){case"point":e="pointSymbol"in r&&r.pointSymbol;break;case"polyline":e="lineSymbol"in r&&r.lineSymbol;break;case"polygon":e="polygonSymbol"in r&&r.polygonSymbol}n.symbol&&!this._hasSizeRamp&&a.infos.push({label:n.label,symbol:e})}else if(ae(n)){n.outputUnit&&(this.title="("+n.toJSON().outputUnit+")"),a.title=n.attributeField;const e=n.getClassBreakInfos();null!=e&&e.length?e.forEach((e=>{a.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):a.infos.push({label:n.attributeField,symbol:n.getDefaultSymbol()})}else ce(n)&&i.push(this._getStretchLegendElements(n,{min:0,max:255}));const h=n.defaultSymbol;!h||c||de(n)||o&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||i.push({type:"symbol-table",infos:[{label:n.defaultLabel||"others",symbol:h}]}),a.infos.length&&i.unshift(a);const m=null==t.opacity?this.opacity:t.opacity,p=this._isTallSymbol("visualVariables"in n&&n.visualVariables),f=Ve(this.layer)||Te(this.layer),g=i.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]).filter((e=>!(null==e||!e.symbol))).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 n=null,await d(g),i}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=null==e?void 0:e.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}_constructTileImageryStretchRendererElements(e){var t,l;const s=this.layer,r=s.rasterInfo,n=r.bandCount||e.statistics.length;let i,a,o=[];const u=r.keyProperties&&r.keyProperties.BandProperties,c=null!=e&&null!=(t=e.statistics)&&t.length?e.statistics:null==r?void 0:r.statistics;if(c)i=void 0!==c[0].min?c[0].min:c[0][0],a=c[0].max||c[0][1];else{const e=re[s.rasterInfo.pixelType.toLowerCase()];i=e[0],a=e[1]}if(s.hasStandardTime()&&(i=s.getStandardTimeValue(i),a=s.getStandardTimeValue(a)),1===r.bandCount||1===(null==(l=s.bandIds)?void 0:l.length))return this._getStretchLegendElements(e,{min:i,max:a});function d(e){var t;const l=(null!=s&&null!=(t=s.bandIds)&&t.length?s.bandIds:Array.from(Array(Math.min(r.bandCount,3)).keys())).map((t=>e&&e[t]&&e[t].BandName||"band"+(t+1)));return l.length<3?l.push(l[1]):l.length>3&&l.splice(3),l}return o=u&&u.length>=n?d(u):d(),this._createSymbolTableElementMultiBand(o)}_getStretchLegendElements(e,t){const l=e.colorRamp,s=P(l,t);return{type:"stretch-ramp",title:"",infos:s,preview:T(s.map((e=>e.color)))}}_createSymbolTableElementMultiBand(e){const t=[],l=["red","green","blue"];return e.forEach(((e,s)=>{t.push({label:{colorName:l[s],bandName:e},src:J[s],opacity:1})})),t}_updateInfosforClassedSizeRenderer(e,t){const l=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some((e=>j(e.symbol)));if(l&&s){const l=q,s=W,r=e.classBreakInfos.length,n=(l-s)/(r>1?r-1:r);t.forEach(((e,t)=>{e.size=l-n*t}))}}_isTallSymbol(e){let t=!1,l=!1;if(e)for(let s=0;s<e.length&&(!t||!l);s++){const r=e[s];"size"===r.type&&("height"===r.axis&&(t=!0),"width-and-depth"===r.axis&&(l=!0))}return t&&l}async _getSymbolPreview(e,t,l){let s=null!=l&&l.isDefault||null!=e.size||!this._hasSizeRamp?e.size:h(22);if(this._scaleDrivenSizeVariable&&null!=l&&l.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");s=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return x(e.symbol,{size:s,opacity:t,scale:!1,symbolConfig:null==l?void 0:l.symbolConfig,effectView:null==l?void 0:l.effectList}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}async _loadRenderer(e){var t,l;const s=[],r=this.layer;e=e.clone(),this._hasClusterSizeVariable=!1;const n="visualVariables"in e&&(null==(t=e.visualVariables)?void 0:t.some((e=>"size"===e.type&&"outline"!==e.target&&!le.test(e.valueExpression))));if(e&&"visualVariables"in e&&!n&&"featureReduction"in r&&"cluster"===(null==(l=r.featureReduction)?void 0:l.type)){const t=this.layerView._effectiveRenderer,l=u(O(t,this.view));if(l){const t=r.featureReduction;if("clusterMinSize"in t&&"clusterMaxSize"in t){const{clusterMinSize:e,clusterMaxSize:s}=t;l.legendOptions=new F({showLegend:e!==s})}const s=e.visualVariables||[];e.visualVariables=s.concat([l]),this._hasClusterSizeVariable=!0}}const i=await this._getMedianColor(e);if(ye(e)||he(e)){const t=(e.classBreakInfos||e.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,i).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(s,t)}return s.push(this._fetchSymbol(e.symbol||e.defaultSymbol,e.defaultSymbol?null:i).then((t=>{this._applySymbolToRenderer(e,t,de(e))})).catch((()=>{this._applySymbolToRenderer(e,null,de(e))}))),d(s).then((()=>e))}_applySymbolToRenderer(e,t,l){l?e.symbol=t:e.defaultSymbol=t}async _getMedianColor(e){if(!("visualVariables"in e)||!e.visualVariables)return null;const t=e.visualVariables.find((e=>"color"===e.type));if(!t)return null;let l=null,s=null;if(t.stops){if(1===t.stops.length)return t.stops[0].color;l=t.stops[0].value,s=t.stops[t.stops.length-1].value}const r=l+(s-l)/2,{getColor:n}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");return n(t,r)}_fetchSymbol(e,t){if(!e)return Promise.reject();if("web-style"===e.type){const l=e.portal,s=l&&l.url,r=l&&l.user&&l.user.username,n=e.name+"-"+e.styleName+"-"+e.styleUrl+"-"+s+"-"+r,i=this._webStyleSymbolCache;return i.has(n)||("2d"===this.view.type?i.set(n,e.fetchCIMSymbol()):i.set(n,e.fetchSymbol())),i.get(n).then((e=>this._getAppliedCloneSymbol(e,t))).catch((()=>(K.warn("Fetching web-style failed!"),Promise.reject())))}return Promise.resolve(this._getAppliedCloneSymbol(e,t))}_getAppliedCloneSymbol(e,l){if(!e||!l)return e;const s=e.clone(),r=l&&l.toRgba();return s.type.indexOf("3d")>-1?this._applyColorTo3dSymbol(s,r):"cim"===s.type?R(s,l):s.color&&(s.color=new t(r||s.color)),s}_applyColorTo3dSymbol(e,l){l&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(l))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||!e.visualVariables||"vector-field"===e.type)return null;const l=e.visualVariables,s=[],r=[],n=[];for(const c of l)"color"===c.type?s.push(c):"size"===c.type?r.push(c):"opacity"===c.type&&n.push(c);const i=[...s,...r,...n];let a,o;if(0===s.length&&ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];a=t&&t.symbol}if(0===s.length&&de(e)&&(a=e.symbol),a)if(a.type.indexOf("3d")>-1){const e=a.symbolLayers.getItemAt(0);"water"===e.type?c(e.color)&&(o=e.color):c(e.material)&&c(e.material.color)&&(o=e.material.color)}else a.url||(o=a.color);const u=this.effectList;return(await Promise.all(i.map((async l=>{if(!l.legendOptions||!1!==l.legendOptions.showLegend){const s=this._getRampTitle(l,t);let r=null;const n="getField"in t&&t.getField&&t.getField(l.field),i=n&&E(n);if("color"===l.type){const e=await A(l,null,i);r={type:"color-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasColorRamp||(this._hasColorRamp=!(null==r.infos||!r.infos.length))}else if("size"===l.type&&"outline"!==l.target)le.test(l.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=l):(r={type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(l):s,infos:await N(e,l,await this._getMedianColor(e),this.scale,this.view.type,i)},this._hasSizeRamp||(this._hasSizeRamp=!(null==r.infos||!r.infos.length)));else if("opacity"===l.type){const e=await A(l,o,i);r={type:"opacity-ramp",title:s,infos:e,preview:T(e.map((e=>e.color)),{effectList:u})},this._hasOpacityRamp||(this._hasOpacityRamp=!(null==r.infos||!r.infos.length))}return r&&r.infos?r:null}})))).filter((e=>!!e))}_getDomainName(e,t,l){if(e&&"function"!=typeof e){const s="getField"in l&&l.getField&&l.getField(e),r=s&&"getFieldDomain"in l&&l.getFieldDomain?l.getFieldDomain(s.name):null;return r&&"coded-value"===r.type?r.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,l=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,r=s&&s.fieldInfos;if(r)for(const t of r)if(t.fieldName===l)return"cluster_count"===l?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let l=e.field,s=e.normalizationField,r=!1,n=!1,i=!1,a=null;l="function"==typeof l?null:l,s="function"==typeof s?null:s;const o=e.legendOptions&&e.legendOptions.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo&&t.renderer.authoringInfo.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const l=e[t];if("color"===l.type){if("ratio"===l.style){r=!0;break}if("percent"===l.style){n=!0;break}if("percent-of-total"===l.style){i=!0;break}}}}a={field:l&&this._getFieldAlias(l,t),normField:s&&this._getFieldAlias(s,t),ratio:r,ratioPercent:n,ratioPercentTotal:i}}return a}_getRendererTitle(e,t){const l=e;if(l.legendOptions&&l.legendOptions.title)return l.legendOptions.title;if(l.valueExpressionTitle)return l.valueExpressionTitle;let s=l.field,r=null,n=null;ye(l)&&(r=l.normalizationField,n="percent-of-total"===l.normalizationType),s="function"==typeof s?null:s,r="function"==typeof r?null:r;let i=null;return(s||r)&&(i={field:s&&this._getFieldAlias(s,t),normField:r&&this._getFieldAlias(r,t),normByPct:n}),i}_getFieldAlias(e,t){const l="popupTemplate"in t&&t.popupTemplate,s=l&&l.fieldInfos;let r=null;s&&s.some((t=>e===t.fieldName&&(r=t,!0)));let n=null;"getField"in t&&t.getField?n=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(n=t.fieldsIndex.get(e));const i=r||n;let a=null;return i&&(a=r&&r.label||n&&n.alias||"name"in i&&i.name||"fieldName"in i&&i.fieldName),a}_isUnclassedRenderer(e){const t=e.visualVariables;let l=!1;return ye(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(l=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),l}};e([S()],Pe.prototype,"children",void 0),e([S({readOnly:!0})],Pe.prototype,"effectList",null),e([S()],Pe.prototype,"layerView",void 0),e([S()],Pe.prototype,"layer",void 0),e([S()],Pe.prototype,"legendElements",void 0),e([S({readOnly:!0})],Pe.prototype,"opacity",null),e([S()],Pe.prototype,"parent",void 0),e([S({readOnly:!0,dependsOn:[]})],Pe.prototype,"ready",null),e([S()],Pe.prototype,"hideLayersNotInCurrentView",void 0),e([S()],Pe.prototype,"keepCacheOnDestroy",void 0),e([S()],Pe.prototype,"respectLayerVisibility",void 0),e([S({readOnly:!0})],Pe.prototype,"scale",null),e([S()],Pe.prototype,"sublayerIds",void 0),e([S({readOnly:!0})],Pe.prototype,"isScaleDriven",null),e([S()],Pe.prototype,"title",void 0),e([S({readOnly:!0,dependsOn:["ready"],value:0})],Pe.prototype,"version",null),e([S()],Pe.prototype,"view",void 0),Pe=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],Pe);const Ae=Pe;export{Ae 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.22/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{whenFalse as s}from"../core/watchUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import{storeNode as a}from"./support/widgetUtils.js";import{messageBundle as n}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as c}from"./support/jsxFactory.js";import h from"./UtilityNetworkTrace/UtilityNetworkTraceViewModel.js";import{GraphicHandler as d}from"./UtilityNetworkTrace/support/GraphicHandler.js";const u={base:"esri-utility-trace-network",loaderContainer:"esri-utility-trace-network__loader-container",loader:"esri-utility-trace-network__loader",fadeIn:"esri-utility-trace-network--fade-in",addButtonContainer:"esri-utility-trace-network__add-button-container",noticeContainer:"esri-utility-trace-network__notice-container",listContainer:"esri-utility-trace-network__list-container",resultsContainer:"esri-utility-trace-network__results-container",flow:"esri-utility-trace-network__flow",esriWidget:"esri-widget",esriWidgetPanel:"esri-widget--panel",esriWidgetDisabled:"esri-widget--disabled",esriButton:"esri-button",esriButtonTertiary:"esri-button--tertiary",esriInput:"esri-input",esriMatchHeight:"esri-match-height",iconHandle:"esri-icon-handle-vertical",iconPlus:"esri-icon-plus",iconEdit:"esri-icon-edit",iconHandleHorizontal:"esri-icon-handle-horizontal",iconRefresh:"esri-icon-refresh",iconLink:"esri-icon-link",iconRemove:"esri-icon-erase",widgetIcon:"esri-icon-UtilityNetworkTrace",header:"esri-widget__heading",loading:"esri-icon-loading-indicator",rotating:"esri-rotating"},g="esri.widgets.UtilityNetworkTrace";function p(e){return{height:e+"px"}}function w(e){return{width:e+"px"}}function v(){return{textAlign:"center"}}let _=class extends(t(o)){constructor(e,t){super(e,t),this._tracesExists=!0,this._graphicHandler=null,this._selectToolActive=!1,this._activeTrace=null,this._activeSwatch="",this._traceHeaderForFlow="",this._assetGroupHeader="",this._assetTypeHeader="",this._traceResultsFunctions=[],this._traceResultsAssetGroup=[],this._traceResultsAssetType=[],this._traceResultsIndividual=[],this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1,this._activeTab="input",this._flagViewType="starting-point",this._alertRemoveModal=!1,this._warningNoFlag=!1,this._warningNoTraceSelected=!1,this._warningNoStartAssetFound=!1,this._warningNoBarrierAssetFound=!1,this._confirmReset=!1,this._showResultOptions=!1,this._resultDisplayField="assetid",this._resultSortField="assetid",this._resultSortOrder="desc",this._swatchNode=null,this._individualResultNode=null,this.disabled=!0,this.flags=[],this.gdbVersion="sde.DEFAULT",this.goToOverride=null,this.iconClass=u.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.view=null,this.viewModel=new h}initialize(){this._UtilityNetworkTraceInitialized(),this._graphicHandler=new d}async checkCanTrace(){this._confirmReset=!1;const e=this.viewModel.checkCanTrace();e.status?(this._warningNoFlag=!1,this._warningNoTraceSelected=!1,this._warningNoTraceSelected=!1,this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1,this.switchTab("result"),this.viewModel._activeProgress=!0,await this.viewModel.callTrace(),this.viewModel._activeProgress=!1):e.issues.forEach((e=>{"noStart"===e?this._warningNoFlag=!0:this._warningNoTraceSelected=!0})),this.scheduleRender()}confirmReset(){this._confirmReset=!0}render(){const{state:e}=this.viewModel,t="loading"===e?this.renderLoading():this.renderUtilityNetworkTrace();return c("div",{class:this.classes(u.base,u.esriWidget,u.esriWidgetPanel,{[u.esriWidgetDisabled]:this.disabled})},t)}switchTab(e){this._activeTab=e,this.scheduleRender()}switchToFunctions(e,t){this._traceResultsFunctions=e,this._showTraceResultFunctions=t,this.scheduleRender()}switchToAssetGroup(e,t,s){this._traceHeaderForFlow=t,this._traceResultsAssetGroup=e,this._showTraceResultAssetGroup=s,this.scheduleRender()}switchToAssetType(e,t,s){this._assetGroupHeader=t,this._traceResultsAssetType=e,this._showTraceResultAssetType=s,this.scheduleRender()}switchToIndividualRecords(e,t,s){this._assetTypeHeader=t,this._traceResultsIndividual=e,this._showIndividualRecords=s,this.scheduleRender()}renderLoading(){return c("div",{class:u.loaderContainer,key:"loader"},c("div",{class:u.loader}))}renderUtilityNetworkTrace(){const{messages:e}=this;let t=c("calcite-tabs",{position:"above",layout:"center",class:u.esriMatchHeight},c("calcite-tab-nav",{slot:"tab-nav"},c("calcite-tab-title",{active:"input"===this._activeTab,onclick:()=>{this.switchTab("input")}},e.inputsStrings.headerTabInputs),c("calcite-tab-title",{active:"result"===this._activeTab,onclick:()=>{this.switchTab("result")}},e.resultsStrings.headerTabResults)),c("calcite-tab",{active:"input"===this._activeTab,class:u.esriMatchHeight},this.renderInputPanel()),c("calcite-tab",{active:"result"===this._activeTab,class:u.esriMatchHeight},this.viewModel._activeProgress?c("calcite-loader",{active:!0,label:e.alertsStrings.traceExecuting,text:e.alertsStrings.traceExecuting,type:"indeterminate"}):this.viewModel._traceResults.length>0?this.renderResultPanel():this.renderWarningMessage("noTraceExecuted",!1),c("calcite-modal",{active:this._confirmReset,color:"blue",scale:"m",width:"s","intl-close":"Close",onCalciteModalClose:()=>{this._confirmReset=!1}},c("h3",{slot:"header"},e.resultsStrings.startOverButton),c("div",{slot:"content"},e.resultsStrings.startOverValidation),c("calcite-button",{slot:"secondary",width:"full",appearance:"outline",onclick:()=>{this._confirmReset=!1}},e.globalStrings.cancel),c("calcite-button",{slot:"primary",width:"full",onclick:()=>{this._confirmReset=!1,this.viewModel.reset(),this.switchTab("input")}},e.globalStrings.ok))));return this._tracesExists||(t=c("calcite-panel",null,this.renderWarningMessage("noTraceConfig",!1))),t}renderInputPanel(){const{messages:e}=this;return c("calcite-flow",{class:u.flow},c("calcite-panel",null,this._warningNoFlag?this.renderWarningMessage("flag",!0):null,this._warningNoTraceSelected?this.renderWarningMessage("trace",!0):null,this.renderTraceSelectorContainer(),this.renderStartFlagsContainer(),this.renderBarriersFlagsContainer(),this._warningNoFlag&&this._warningNoTraceSelected?c("div",{styles:p(10)}):null,c("calcite-button",{slot:"footer",scale:"m",color:"blue",width:"full",onclick:()=>{this.checkCanTrace()}},e.tracingStrings.runTrace)),this._selectToolActive?this.renderActiveTool():null)}renderResultPanel(){return c("div",{class:this.classes(u.esriMatchHeight,u.resultsContainer)},c("calcite-flow",null,this.renderTraceResults(),this._showTraceResultFunctions?this.renderTraceResultFunctions():null,this._showTraceResultAssetGroup?this.renderTraceResultByAssetGroup():null,this._showTraceResultAssetType?this.renderTraceResultByAssetType():null,this._showIndividualRecords?this.renderTraceResultIndividual():null))}renderStartFlagsContainer(){const{messages:e}=this,t=[];let s=[];return s=this.viewModel._flags.filter((e=>"starting-point"===e.type)),s.forEach((e=>{e.displayValue&&t.push(this.renderFlagRow(e,"start"))})),c("calcite-block",{heading:e.inputsStrings.headerStartingPoint+" ("+s.length+")",open:!0,collapsible:!0},c("div",{slot:"icon"},c("calcite-icon",{icon:"pin",scale:"s"})),c("div",null,e.inputsStrings.startingPointHint),c("div",{class:u.listContainer},t),this._warningNoStartAssetFound?this.renderWarningMessage("noStartAsset",!0):null,c("div",{styles:v()},c("calcite-button",{alignment:"center",appearance:"outline","icon-start":"plus",scale:"m",href:"",label:e.inputsStrings.addPointOption,onclick:()=>{this._flagViewType="starting-point",this._selectToolActive=!0,this._warningNoStartAssetFound=!1,this.viewModel.addFlagByHit("starting-point").then((e=>{e||(this._warningNoStartAssetFound=!0),this._selectToolActive=!1,this.scheduleRender()}))},round:!0})))}renderBarriersFlagsContainer(){const{messages:e}=this,t=[];let s=[];return s=this.viewModel._flags.filter((e=>"barrier"===e.type)),s.forEach((e=>{e.displayValue&&t.push(this.renderFlagRow(e,"barrier"))})),c("calcite-block",{heading:e.inputsStrings.headerBarrier+" ("+s.length+")",open:!1,collapsible:!0},c("div",{slot:"icon"},c("calcite-icon",{icon:"x-circle-f",scale:"s"})),c("div",null,e.inputsStrings.barrierPointHint),c("div",{class:u.listContainer},t),this._warningNoBarrierAssetFound?this.renderWarningMessage("noBarrierAsset",!0):null,c("div",{class:u.addButtonContainer},c("calcite-button",{alignment:"center",appearance:"outline",color:"blue","icon-start":"plus",scale:"m",href:"",round:!0,label:e.inputsStrings.addPointOption,onclick:()=>{this._flagViewType="barrier",this._selectToolActive=!0,this._warningNoBarrierAssetFound=!1,this.viewModel.addFlagByHit("barrier").then((e=>{e||(this._warningNoBarrierAssetFound=!0),this._selectToolActive=!1,this.scheduleRender()}))}})))}renderFlagRow(e,t){const{messages:s}=this,i=[];let l=!1;return null!==e.allTerminals&&void 0!==e.allTerminals&&e.allTerminals.terminals.length>0&&(l=!0,e.allTerminals.terminals.forEach((t=>{let s=!1;e.selectedTerminals.find((e=>e===t.id))&&(s=!0),i.push(c("calcite-combobox-item",{key:t.name,selected:s,value:t.id,"text-label":t.name,onclick:t=>{this.viewModel.addTerminal(t.target.value,e)}}))}))),c("calcite-block",{key:"pop"+e.globalId+e.type+e.id+t,heading:e.displayValue.value,collapsible:null!==e.allTerminals||"barrier"===e.type},c("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:s.globalStrings.remove,label:s.globalStrings.remove,onCalciteListItemChange:()=>{this.viewModel.removeFlag(e)},onclick:()=>{this.viewModel.removeFlag(e)},scale:"s",icon:"trash"}),c("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:s.globalStrings.zoomToFeature,label:s.globalStrings.zoomToFeature,onCalciteListItemChange:()=>{this.viewModel.zoomToAsset(e.details.geometry)},onclick:()=>{this.viewModel.zoomToAsset(e.details.geometry)},scale:"s",icon:"zoom-to-object"}),"barrier"===e.type?c("calcite-label",{scale:"s",layout:"inline"},c("calcite-checkbox",{checked:e.isFilterBarrier,scale:"s",onclick:()=>{this.viewModel.manageFilterBarrier(!e.isFilterBarrier,e)}}),s.inputsStrings.barrierFilter):null,l?c("calcite-combobox",{label:s.globalStrings.selectTerminalPlaceholder,placeholder:s.globalStrings.selectTerminalPlaceholder,"selection-mode":"multi",scale:"s",maxItems:0,onCalciteComboboxChipDismiss:t=>{this.viewModel.removeTerminal(t.target.value,e)}},i):null)}renderActiveTool(){const{messages:e}=this;return c("calcite-panel",{"height-scale":"s",onCalcitePanelBackClick:()=>{this.viewModel._clickHandler&&(this.viewModel._clickHandler.remove(),this.view.popup.autoOpenEnabled=!0),this._selectToolActive=!1},heading:e.inputsStrings.addPointOption},c("calcite-block",{open:!0,collapsible:!1,heading:""},c("div",{styles:v()},c("calcite-icon",{icon:"starting-point"===this._flagViewType?"pin":"x-circle-f",scale:"s"})),c("div",{styles:v()},e.inputsStrings.addPointHint)))}renderTraceSelectorContainer(){const{messages:e}=this,t=[];return this.viewModel._traces.length>0&&this.viewModel._traces.forEach((e=>{t.push(c("calcite-combobox-item",{key:e.globalId,selected:e.selected,value:e.globalId,"text-label":e.title,onCalciteComboboxItemChange:t=>{const s=t.target;this.viewModel.selectTraces(s.selected,e.globalId),this.viewModel._traces.length>0&&(this._warningNoTraceSelected=!1)}}))})),c("calcite-block",{heading:e.tracingStrings.traceOperation,open:!0,collapsible:!0},c("calcite-combobox",{label:e.inputsStrings.selectTraces,placeholder:e.inputsStrings.selectTraces,"selection-mode":"multi",scale:"s",maxItems:0,onCalciteComboboxChipDismiss:e=>{this.viewModel.selectTraces(!1,e.target.value),this.viewModel._traces.length>0&&(this._warningNoTraceSelected=!1)}},t))}renderStartOverContainer(){const{messages:e}=this;return c("calcite-button",{slot:"footer",scale:"m",color:"blue",width:"full",onclick:()=>{this.confirmReset()}},e.resultsStrings.startOverButton)}renderWarningMessage(e,t,s){const{messages:i}=this;let l=i.alertsStrings.NoRunAlertHeader,r=i.alertsStrings.noResultsInfo;switch(e){case"flag":l=i.alertsStrings.startingPointAlertHeader,r=i.alertsStrings.startingPointAlert;break;case"trace":l=i.alertsStrings.selectTraceAlertHeader,r=i.alertsStrings.selectTraceAlert;break;case"noTraceExecuted":l=i.alertsStrings.NoRunAlertHeader,r=i.alertsStrings.noResultsInfo;break;case"noBarrierAsset":case"noStartAsset":l=i.alertsStrings.noAssetsFoundHeader,r=i.alertsStrings.noAssetFound;break;case"noTraceConfig":l="",r=i.alertsStrings.noTraceSupported;break;default:l=i.alertsStrings.genericResultHeader,r=s||""}return c("div",{class:u.noticeContainer,key:e},c("calcite-notice",{open:!0,key:e,active:!0,dismissible:t,icon:!0,scale:"s",width:"auto",color:"red",onCalciteNoticeClose:()=>{switch(e){case"flag":this._warningNoFlag=!1;break;case"trace":this._warningNoTraceSelected=!1;break;case"noStartAsset":this._warningNoStartAssetFound=!1;break;case"noBarrierAsset":this._warningNoBarrierAssetFound=!1}}},c("div",{slot:"title"},l),c("div",{slot:"message"},r)))}renderRemoveTraceContainer(e){const{messages:t}=this;return c("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:t.globalStrings.clearResults,label:t.globalStrings.clearResults,onCalciteListItemChange:()=>{this._alertRemoveModal=!0,this._activeTrace=e.trace},onclick:()=>{this._alertRemoveModal=!0,this._activeTrace=e.trace},scale:"s",icon:"trash"})}renderHighlightColorPicker(e,t){const{messages:s}=this;return c("calcite-action-pad",{position:"start",layout:"grid",expandDisabled:!0},c("calcite-action-group",{layout:"grid",columns:4},c("calcite-action",{text:s.resultsStrings.graphicColor,label:s.resultsStrings.graphicColor,scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(0),t)}},c("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(0).hex,active:e.color===this._graphicHandler.getHighlightColor(0).color})),c("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(1),t)}},c("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(1).hex,active:e.color===this._graphicHandler.getHighlightColor(1).color})),c("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(2),t)}},c("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(2).hex,active:e.color===this._graphicHandler.getHighlightColor(2).color})),c("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(3),t)}},c("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(3).hex,active:e.color===this._graphicHandler.getHighlightColor(3).color})),c("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(4),t)}},c("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(4).hex,active:e.color===this._graphicHandler.getHighlightColor(4).color}))))}renderTraceResults(){const{messages:e}=this,t=this.viewModel._traceResults,s=[];return t.forEach(((t,i)=>{let l=[],r=[],o=!1,a=!1,n=!1;null!==t.results&&t.results.hasOwnProperty("elements")?(null!==t.results.aggregatedGeometry&&(a=!0),null!==t.results.globalFunctionResults&&t.results.globalFunctionResults.length>0&&(r=t.results.globalFunctionResults,r.length>0&&(n=!0)),t.results.elements.length>0&&(l=t.results.elements,l.length>0&&(o=!0)),s.push(c("calcite-block",{key:t.trace.title,heading:t.trace.title,summary:t.trace.description,collapsible:!1,open:!0,intlOptions:e.resultsStrings.ellipsesOptions},this.renderRemoveTraceContainer(t),c("calcite-list",null,n?c("calcite-list-item",{label:e.resultsStrings.functionHeader+" ("+r.length+")",onclick:()=>{this.switchToFunctions(r,!0)}},c("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"})):null,o&&this.viewModel.showSelectionAttributes?c("calcite-list-item",{label:e.resultsStrings.viewFeatures+" ("+l.length+")",onclick:()=>{this.switchToAssetGroup(this._groupResultsByAssetGroup(t),t.trace.title+" ("+l.length+")",!0)}},c("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"})):this.viewModel.showSelectionAttributes?c("calcite-label",{layout:"inline",scale:"s"},e.resultsStrings.noSelectionResults):null),c("div",{styles:p(10)}),o?c("calcite-label",{layout:"inline",scale:"s",onclick:e=>{e.preventDefault(),e.stopPropagation(),this.viewModel.mergeSelection(!t.selectionEnabled,t.trace)}},c("calcite-checkbox",{checked:t.selectionEnabled,scale:"m",onclick:e=>{e.preventDefault(),e.stopPropagation(),this.viewModel.mergeSelection(!t.selectionEnabled,t.trace)}}),this.viewModel.showSelectionAttributes?e.resultsStrings.selectFeatures:e.resultsStrings.selectFeatures+" ("+l.length+")"):null,a?c("calcite-block-section",{"toggle-display":"switch",text:e.resultsStrings.highlightTrace,open:t.graphicEnabled,onCalciteBlockSectionToggle:e=>{e.target.open?this.viewModel.changeResultGraphicColor(t.graphicColor,t):this.viewModel.removeResultGraphicFromView(t)}},c("calcite-popover-manager",{key:"aggGeom_"+t.trace.globalId,autoClose:!0},c("calcite-action",{text:e.resultsStrings.graphicColor,label:e.resultsStrings.graphicColor,scale:"s",onclick:e=>{const t=e.target;this._swatchNode=t,this._activeSwatch="aggGeom_"+i,this.scheduleRender()}},c("calcite-color-picker-swatch",{scale:"s",color:t.graphicColor.hex})),c("calcite-popover",{label:e.resultsStrings.graphicColor,text:e.resultsStrings.graphicColor,referenceElement:this._swatchNode,placement:"auto",offsetDistance:5,offsetSkidding:0,open:this._activeSwatch==="aggGeom_"+i,onCalcitePopoverClose:()=>{this._swatchNode=null,this._activeSwatch=null}},this.renderHighlightColorPicker(t.graphicColor,t)))):null))):s.push(c("calcite-block",{key:"error-"+i,heading:t.trace.title,collapsible:!1,open:!0},this.renderRemoveTraceContainer(t),this.renderWarningMessage("noController",!1,t.status)))})),c("calcite-panel",{key:"traceResults"},s,this.renderStartOverContainer(),c("calcite-modal",{active:this._alertRemoveModal,color:"blue",scale:"m",width:"s","intl-close":"Close",onCalciteModalClose:()=>{this._alertRemoveModal=!1,this.scheduleRender()}},c("h3",{slot:"header"},e.globalStrings.clearResults),c("div",{slot:"content"},e.alertsStrings.clearResultsAlert),c("calcite-button",{slot:"secondary",width:"full",appearance:"outline",onclick:()=>{this._alertRemoveModal=!1,this.scheduleRender()}},e.globalStrings.cancel),c("calcite-button",{slot:"primary",width:"full",onclick:()=>{this.viewModel.clearResult(this._activeTrace),this._alertRemoveModal=!1,0===this.viewModel._traceResults.length?this.switchTab("input"):(this._activeTrace=this.viewModel._traceResults[0].trace,this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1),this.scheduleRender()}},e.globalStrings.ok)))}renderTraceResultFunctions(){const{messages:e}=this,t=this._traceResultsFunctions,s=[];return t.forEach((e=>{s.push(this.renderResultRowFunctions(e))})),c("calcite-panel",{key:"functionResultMultiple",onCalcitePanelBackClick:()=>{this.switchToFunctions([],!1)},heading:e.resultsStrings.functionHeader},s,this.renderStartOverContainer())}renderTraceResultByAssetGroup(){const e=this._traceResultsAssetGroup,t=[];for(const s in e){const i=e[s];for(const e in i)t.push(this.renderResultRowAssetGroup(i[e]))}return c("calcite-panel",{key:"assetGroupResultMultiple",onCalcitePanelBackClick:()=>{this.switchToAssetGroup([],"",!1)},heading:this._traceHeaderForFlow},c("calcite-list",null,t),this.renderStartOverContainer())}renderTraceResultByAssetType(){const e=this._traceResultsAssetType,t=[];for(const s in e)e[s].length>0&&t.push(this.renderResultRowAssetType(e[s]));return c("calcite-panel",{key:"assetTypeResult",onCalcitePanelBackClick:()=>{this.switchToAssetType([],"",!1)},heading:this._assetGroupHeader},t,this.renderStartOverContainer())}renderTraceResultIndividual(){const{messages:e}=this,t=this._traceResultsIndividual;t.sort(this._compare(this._resultSortField,this._resultSortOrder));const s=[],i=[],l=[];return t.length>0&&(t[0].details.fields.forEach((e=>{i.push(c("calcite-option",{key:"display"+e.name,label:e.alias,value:e.name,selected:e.name===this._resultDisplayField})),l.push(c("calcite-option",{key:"sort"+e.name,label:e.alias,value:e.name,selected:e.name===this._resultSortField}))})),t.forEach((e=>{s.push(this.renderResultRowIndividual(e))}))),c("calcite-popover-manager",{class:u.esriMatchHeight,key:"popIndividualResult",autoClose:!0},c("calcite-panel",{key:"individualResult",onCalcitePanelBackClick:()=>{this._showResultOptions=!1,this.switchToIndividualRecords([],"",!1)},heading:this._assetTypeHeader},c("calcite-action",{"text-enabled":!0,slot:"header-actions-end",text:e.resultsStrings.displayAttribute,onCalciteListItemChange:()=>{this._showResultOptions=!0},onclick:()=>{this._showResultOptions=!0},scale:"s",icon:"gear",label:e.resultsStrings.displayAttribute,id:"field_options",afterCreate:a,bind:this,"data-node-ref":"_individualResultNode"}),s,this.renderStartOverContainer()),c("calcite-popover",{label:e.resultsStrings.displayAttribute,referenceElement:this._individualResultNode,placement:"auto",offsetDistance:5,offsetSkidding:0,open:this._showResultOptions,styles:w(.75*this.domNode.clientWidth)},c("calcite-block",{heading:e.resultsStrings.resultsListOptions,collapsible:!1,open:!0},c("calcite-label",{scale:"s"},e.resultsStrings.displayAttribute,c("calcite-select",{label:e.resultsStrings.displayAttribute,onCalciteSelectChange:e=>{const t=e.target;this._resultDisplayField=t.selectedOption.value,this._showResultOptions=!1}},i)),c("calcite-label",null,e.resultsStrings.sortBy,c("calcite-select",{label:e.resultsStrings.sortBy,onCalciteSelectChange:e=>{const s=e.target;this._resultSortField=s.selectedOption.value,t.sort(this._compare(this._resultSortField,this._resultSortOrder)),this._traceResultsIndividual=t,this._showResultOptions=!1}},l)))))}renderResultRow(e){let t=e[0].assetGroupCode;const s=this.viewModel.getValidSources().filter((t=>t.sourceId===e[0].networkSourceId));if(s.length>0){const i=s[0].assetGroups.filter((t=>t.assetGroupCode===e[0].assetGroupCode));i.length>0&&(t=i[0].assetGroupName)}return c("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.switchToAssetType(this._groupResultsByAssetType(e),t+" ("+e.length+")",!0)}},c("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}renderResultRowFunctions(e){return c("calcite-block",{heading:e.functionType+" = "+e.result,collapsible:!1})}renderResultRowAssetGroup(e){let t=e[0].assetGroupCode;const s=e[0].assetGroupCode,i=this.viewModel.getValidSources().filter((t=>t.sourceId===e[0].networkSourceId));if(i.length>0){const e=i[0].assetGroups.filter((e=>e.assetGroupCode===s));e.length>0&&(t=e[0].assetGroupName)}return c("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.switchToAssetType(this._groupResultsByAssetType(e),t+" ("+e.length+")",!0)}},c("calcite-icon",{slot:"content-end",icon:"chevron-right",scale:"s"}))}renderResultRowAssetType(e){let t=e[0].assetTypeCode;const s=e[0].assetGroupCode,i=this.viewModel.getValidSources().filter((t=>t.sourceId===e[0].networkSourceId));if(i.length>0){const l=i[0].assetGroups.filter((e=>e.assetGroupCode===s));if(l.length>0){const s=l[0].assetTypes.filter((t=>t.assetTypeCode===e[0].assetTypeCode));s.length>0&&(t=s[0].assetTypeName)}}return c("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.viewModel.queryFeaturesById(e).then((s=>{if(null!==s){const i=this._appendAttributes(e,s.featureSet,"objectId");this.switchToIndividualRecords(i,t+" ("+e.length+")",!0)}else this.switchToIndividualRecords(e,t+" ("+e.length+")",!0)}))}},c("calcite-icon",{slot:"content-end",icon:"chevron-right",scale:"s"}))}renderResultRowIndividual(e){const{messages:t}=this;let s=e.details.attributes[this._resultDisplayField];return s&&""!==s&&null!==s||(s=t.resultsStrings.noValue),c("calcite-list-item",{label:s,onclick:()=>{this.viewModel.zoomToAsset(e.details.geometry)}},c("calcite-icon",{icon:"zoom-to-object","text-label":t.globalStrings.zoomToFeature,scale:"s",slot:"content-end"}))}_UtilityNetworkTraceInitialized(){return this.viewModel.loadUtilityNetwork().then((e=>e?(this.viewModel.selectTracesOnLoad(),this.viewModel._traces.length<=0&&(this._tracesExists=!1),this.viewModel.flags.length>0?this.view.when().then((()=>{const e=s(this.view,"updating",(async()=>{this._warningNoFlag=!1,this._warningNoBarrierAssetFound=!1,this._warningNoStartAssetFound=!1;const t=await this.viewModel.addFlagsOnLoad();t.includes("barrier")&&(this._warningNoBarrierAssetFound=!0),t.includes("starting-point")&&(this._warningNoStartAssetFound=!0),this.disabled=!1,e.remove(),this.scheduleRender()}))})):this.view.when().then((()=>{const e=s(this.view,"updating",(()=>{this.disabled=!1,e.remove()}))}))):(this._tracesExists=!1,this.view.when().then((()=>{const e=s(this.view,"updating",(()=>{this.disabled=!1,e.remove()}))})))))}_groupResultsByAssetGroup(e){const t=[],s=e.results.elements,i=this._groupBy(s,"networkSourceId");for(const l in i)t.push(this._groupBy(i[l],"assetGroupCode"));return t}_groupResultsByAssetType(e){return this._groupBy(e,"assetTypeCode")}_appendAttributes(e,t,s){const i=[];return e.forEach((e=>{t.features.forEach((l=>{e[s]===l.attributes[s.toLowerCase()]&&(e.details=l,e.details.fields=t.fields,i.push(e))}))})),i}_compare(e,t){return(s,i)=>{let l=0,r=s.details.attributes[e],o=i.details.attributes[e];return isNaN(r)&&(r=r.toLowerCase()),isNaN(o)&&(o=o.toLowerCase()),"desc"===t?r>o?l=1:r<o&&(l=-1):r<o?l=1:r>o&&(l=-1),l}}_groupBy(e,t){return e.reduce((function(e,s){return(e[s[t]]=e[s[t]]||[]).push(s),e}),{})}};e([l()],_.prototype,"_confirmReset",void 0),e([l()],_.prototype,"disabled",void 0),e([i("viewModel.flags")],_.prototype,"flags",void 0),e([i("viewModel.gdbVersion")],_.prototype,"gdbVersion",void 0),e([i("viewModel.goToOverride")],_.prototype,"goToOverride",void 0),e([l()],_.prototype,"iconClass",void 0),e([l({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],_.prototype,"label",void 0),e([l(),n("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace")],_.prototype,"messages",void 0),e([l(),n("esri/t9n/common")],_.prototype,"messagesCommon",void 0),e([i("viewModel.selectedTraces")],_.prototype,"selectedTraces",void 0),e([i("viewModel.selectOnComplete")],_.prototype,"selectOnComplete",void 0),e([i("viewModel.showGraphicsOnComplete")],_.prototype,"showGraphicsOnComplete",void 0),e([i("viewModel.showSelectionAttributes")],_.prototype,"showSelectionAttributes",void 0),e([i("viewModel.view")],_.prototype,"view",void 0),e([l({type:h})],_.prototype,"viewModel",void 0),_=e([r(g)],_);const m=_;export{m as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{whenFalse as s}from"../core/watchUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import{storeNode as a}from"./support/widgetUtils.js";import{messageBundle as c}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as n}from"./support/jsxFactory.js";import h from"./UtilityNetworkTrace/UtilityNetworkTraceViewModel.js";import{GraphicHandler as d}from"./UtilityNetworkTrace/support/GraphicHandler.js";const u={base:"esri-utility-trace-network",loaderContainer:"esri-utility-trace-network__loader-container",loader:"esri-utility-trace-network__loader",fadeIn:"esri-utility-trace-network--fade-in",addButtonContainer:"esri-utility-trace-network__add-button-container",noticeContainer:"esri-utility-trace-network__notice-container",listContainer:"esri-utility-trace-network__list-container",resultsContainer:"esri-utility-trace-network__results-container",flow:"esri-utility-trace-network__flow",esriWidget:"esri-widget",esriWidgetPanel:"esri-widget--panel",esriWidgetDisabled:"esri-widget--disabled",esriButton:"esri-button",esriButtonTertiary:"esri-button--tertiary",esriInput:"esri-input",esriMatchHeight:"esri-match-height",iconHandle:"esri-icon-handle-vertical",iconPlus:"esri-icon-plus",iconEdit:"esri-icon-edit",iconHandleHorizontal:"esri-icon-handle-horizontal",iconRefresh:"esri-icon-refresh",iconLink:"esri-icon-link",iconRemove:"esri-icon-erase",widgetIcon:"esri-icon-UtilityNetworkTrace",header:"esri-widget__heading",loading:"esri-icon-loading-indicator",rotating:"esri-rotating"},p="esri.widgets.UtilityNetworkTrace";function g(e){return{height:e+"px"}}function m(e){return{width:e+"px"}}function w(){return{textAlign:"center"}}let v=class extends(t(r)){constructor(e,t){super(e,t),this._tracesExists=!0,this._graphicHandler=null,this._selectToolActive=!1,this._activeTrace=null,this._activeSwatch="",this._traceHeaderForFlow="",this._assetGroupHeader="",this._assetTypeHeader="",this._traceResultsFunctions=[],this._traceResultsAssetGroup=[],this._traceResultsAssetType=[],this._traceResultsIndividual=[],this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1,this._activeTab="input",this._flagViewType="starting-point",this._alertRemoveModal=!1,this._warningNoFlag=!1,this._warningNoTraceSelected=!1,this._warningNoStartAssetFound=!1,this._warningNoBarrierAssetFound=!1,this._confirmReset=!1,this._showResultOptions=!1,this._resultDisplayField="assetid",this._resultSortField="assetid",this._resultSortOrder="desc",this._swatchNode=null,this._individualResultNode=null,this.disabled=!0,this.flags=[],this.gdbVersion="sde.DEFAULT",this.goToOverride=null,this.iconClass=u.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.view=null,this.viewModel=new h}initialize(){this._UtilityNetworkTraceInitialized(),this._graphicHandler=new d}async checkCanTrace(){this._confirmReset=!1;const e=this.viewModel.checkCanTrace();e.status?(this._warningNoFlag=!1,this._warningNoTraceSelected=!1,this._warningNoTraceSelected=!1,this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1,this.switchTab("result"),this.viewModel._activeProgress=!0,await this.viewModel.callTrace(),this.viewModel._activeProgress=!1):e.issues.forEach((e=>{"noStart"===e?this._warningNoFlag=!0:this._warningNoTraceSelected=!0})),this.scheduleRender()}confirmReset(){this._confirmReset=!0}render(){const{state:e}=this.viewModel,t="loading"===e?this.renderLoading():this.renderUtilityNetworkTrace();return n("div",{class:this.classes(u.base,u.esriWidget,u.esriWidgetPanel,{[u.esriWidgetDisabled]:this.disabled})},t)}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-group.js"),import("@esri/calcite-components/dist/components/calcite-action-pad.js"),import("@esri/calcite-components/dist/components/calcite-checkbox.js"),import("@esri/calcite-components/dist/components/calcite-color-picker-swatch.js"),import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-block.js"),import("@esri/calcite-components/dist/components/calcite-block-section.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-label.js"),import("@esri/calcite-components/dist/components/calcite-list.js"),import("@esri/calcite-components/dist/components/calcite-list-item.js"),import("@esri/calcite-components/dist/components/calcite-modal.js"),import("@esri/calcite-components/dist/components/calcite-notice.js"),import("@esri/calcite-components/dist/components/calcite-option.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-select.js"),import("@esri/calcite-components/dist/components/calcite-tabs.js"),import("@esri/calcite-components/dist/components/calcite-tab.js"),import("@esri/calcite-components/dist/components/calcite-tab-nav.js"),import("@esri/calcite-components/dist/components/calcite-tab-title.js")])}switchTab(e){this._activeTab=e,this.scheduleRender()}switchToFunctions(e,t){this._traceResultsFunctions=e,this._showTraceResultFunctions=t,this.scheduleRender()}switchToAssetGroup(e,t,s){this._traceHeaderForFlow=t,this._traceResultsAssetGroup=e,this._showTraceResultAssetGroup=s,this.scheduleRender()}switchToAssetType(e,t,s){this._assetGroupHeader=t,this._traceResultsAssetType=e,this._showTraceResultAssetType=s,this.scheduleRender()}switchToIndividualRecords(e,t,s){this._assetTypeHeader=t,this._traceResultsIndividual=e,this._showIndividualRecords=s,this.scheduleRender()}renderLoading(){return n("div",{class:u.loaderContainer,key:"loader"},n("div",{class:u.loader}))}renderUtilityNetworkTrace(){const{messages:e}=this;let t=n("calcite-tabs",{position:"above",layout:"center",class:u.esriMatchHeight},n("calcite-tab-nav",{slot:"tab-nav"},n("calcite-tab-title",{active:"input"===this._activeTab,onclick:()=>{this.switchTab("input")}},e.inputsStrings.headerTabInputs),n("calcite-tab-title",{active:"result"===this._activeTab,onclick:()=>{this.switchTab("result")}},e.resultsStrings.headerTabResults)),n("calcite-tab",{active:"input"===this._activeTab,class:u.esriMatchHeight},this.renderInputPanel()),n("calcite-tab",{active:"result"===this._activeTab,class:u.esriMatchHeight},this.viewModel._activeProgress?n("calcite-loader",{active:!0,label:e.alertsStrings.traceExecuting,text:e.alertsStrings.traceExecuting,type:"indeterminate"}):this.viewModel._traceResults.length>0?this.renderResultPanel():this.renderWarningMessage("noTraceExecuted",!1),n("calcite-modal",{active:this._confirmReset,color:"blue",scale:"m",width:"s","intl-close":"Close",onCalciteModalClose:()=>{this._confirmReset=!1}},n("h3",{slot:"header"},e.resultsStrings.startOverButton),n("div",{slot:"content"},e.resultsStrings.startOverValidation),n("calcite-button",{slot:"secondary",width:"full",appearance:"outline",onclick:()=>{this._confirmReset=!1}},e.globalStrings.cancel),n("calcite-button",{slot:"primary",width:"full",onclick:()=>{this._confirmReset=!1,this.viewModel.reset(),this.switchTab("input")}},e.globalStrings.ok))));return this._tracesExists||(t=n("calcite-panel",null,this.renderWarningMessage("noTraceConfig",!1))),t}renderInputPanel(){const{messages:e}=this;return n("calcite-flow",{class:u.flow},n("calcite-panel",null,this._warningNoFlag?this.renderWarningMessage("flag",!0):null,this._warningNoTraceSelected?this.renderWarningMessage("trace",!0):null,this.renderTraceSelectorContainer(),this.renderStartFlagsContainer(),this.renderBarriersFlagsContainer(),this._warningNoFlag&&this._warningNoTraceSelected?n("div",{styles:g(10)}):null,n("calcite-button",{slot:"footer",scale:"m",color:"blue",width:"full",onclick:()=>{this.checkCanTrace()}},e.tracingStrings.runTrace)),this._selectToolActive?this.renderActiveTool():null)}renderResultPanel(){return n("div",{class:this.classes(u.esriMatchHeight,u.resultsContainer)},n("calcite-flow",null,this.renderTraceResults(),this._showTraceResultFunctions?this.renderTraceResultFunctions():null,this._showTraceResultAssetGroup?this.renderTraceResultByAssetGroup():null,this._showTraceResultAssetType?this.renderTraceResultByAssetType():null,this._showIndividualRecords?this.renderTraceResultIndividual():null))}renderStartFlagsContainer(){const{messages:e}=this,t=[];let s=[];return s=this.viewModel._flags.filter((e=>"starting-point"===e.type)),s.forEach((e=>{e.displayValue&&t.push(this.renderFlagRow(e,"start"))})),n("calcite-block",{heading:e.inputsStrings.headerStartingPoint+" ("+s.length+")",open:!0,collapsible:!0},n("div",{slot:"icon"},n("calcite-icon",{icon:"pin",scale:"s"})),n("div",null,e.inputsStrings.startingPointHint),n("div",{class:u.listContainer},t),this._warningNoStartAssetFound?this.renderWarningMessage("noStartAsset",!0):null,n("div",{class:u.addButtonContainer},n("calcite-button",{alignment:"center",appearance:"outline","icon-start":"plus",scale:"m",href:"",label:e.inputsStrings.addPointOption,onclick:()=>{this._flagViewType="starting-point",this._selectToolActive=!0,this._warningNoStartAssetFound=!1,this.viewModel.addFlagByHit("starting-point").then((e=>{e||(this._warningNoStartAssetFound=!0),this._selectToolActive=!1,this.scheduleRender()}))},round:!0})))}renderBarriersFlagsContainer(){const{messages:e}=this,t=[];let s=[];return s=this.viewModel._flags.filter((e=>"barrier"===e.type)),s.forEach((e=>{e.displayValue&&t.push(this.renderFlagRow(e,"barrier"))})),n("calcite-block",{heading:e.inputsStrings.headerBarrier+" ("+s.length+")",open:!1,collapsible:!0},n("div",{slot:"icon"},n("calcite-icon",{icon:"x-circle-f",scale:"s"})),n("div",null,e.inputsStrings.barrierPointHint),n("div",{class:u.listContainer},t),this._warningNoBarrierAssetFound?this.renderWarningMessage("noBarrierAsset",!0):null,n("div",{class:u.addButtonContainer},n("calcite-button",{alignment:"center",appearance:"outline",color:"blue","icon-start":"plus",scale:"m",href:"",round:!0,label:e.inputsStrings.addPointOption,onclick:()=>{this._flagViewType="barrier",this._selectToolActive=!0,this._warningNoBarrierAssetFound=!1,this.viewModel.addFlagByHit("barrier").then((e=>{e||(this._warningNoBarrierAssetFound=!0),this._selectToolActive=!1,this.scheduleRender()}))}})))}renderFlagRow(e,t){const{messages:s}=this,i=[];let l=!1;return null!==e.allTerminals&&void 0!==e.allTerminals&&e.allTerminals.terminals.length>0&&(l=!0,e.allTerminals.terminals.forEach((t=>{let s=!1;e.selectedTerminals.find((e=>e===t.id))&&(s=!0),i.push(n("calcite-combobox-item",{key:t.name,selected:s,value:t.id,"text-label":t.name,onclick:t=>{this.viewModel.addTerminal(t.target.value,e)}}))}))),n("calcite-block",{key:"pop"+e.globalId+e.type+e.id+t,heading:e.displayValue.value,collapsible:null!==e.allTerminals||"barrier"===e.type},n("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:s.globalStrings.remove,label:s.globalStrings.remove,onCalciteListItemChange:()=>{this.viewModel.removeFlag(e)},onclick:()=>{this.viewModel.removeFlag(e)},scale:"s",icon:"trash"}),n("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:s.globalStrings.zoomToFeature,label:s.globalStrings.zoomToFeature,onCalciteListItemChange:()=>{this.viewModel.zoomToAsset(e.details.geometry)},onclick:()=>{this.viewModel.zoomToAsset(e.details.geometry)},scale:"s",icon:"zoom-to-object"}),"barrier"===e.type?n("calcite-label",{scale:"s",layout:"inline"},n("calcite-checkbox",{checked:e.isFilterBarrier,scale:"s",onclick:()=>{this.viewModel.manageFilterBarrier(!e.isFilterBarrier,e)}}),s.inputsStrings.barrierFilter):null,l?n("calcite-combobox",{label:s.globalStrings.selectTerminalPlaceholder,placeholder:s.globalStrings.selectTerminalPlaceholder,"selection-mode":"multi",scale:"s",maxItems:0,onCalciteComboboxChipDismiss:t=>{this.viewModel.removeTerminal(t.target.value,e)}},i):null)}renderActiveTool(){const{messages:e}=this;return n("calcite-panel",{"height-scale":"s",onCalcitePanelBackClick:()=>{this.viewModel._clickHandler&&(this.viewModel._clickHandler.remove(),this.view.popup.autoOpenEnabled=!0),this._selectToolActive=!1},heading:e.inputsStrings.addPointOption},n("calcite-block",{open:!0,collapsible:!1,heading:""},n("div",{styles:w()},n("calcite-icon",{icon:"starting-point"===this._flagViewType?"pin":"x-circle-f",scale:"s"})),n("div",{styles:w()},e.inputsStrings.addPointHint)))}renderTraceSelectorContainer(){const{messages:e}=this,t=[];return this.viewModel._traces.length>0&&this.viewModel._traces.forEach((e=>{t.push(n("calcite-combobox-item",{key:e.globalId,selected:e.selected,value:e.globalId,"text-label":e.title,onCalciteComboboxItemChange:t=>{const s=t.target;this.viewModel.selectTraces(s.selected,e.globalId),this.viewModel._traces.length>0&&(this._warningNoTraceSelected=!1)}}))})),n("calcite-block",{heading:e.tracingStrings.traceOperation,open:!0,collapsible:!0},n("calcite-combobox",{label:e.inputsStrings.selectTraces,placeholder:e.inputsStrings.selectTraces,"selection-mode":"multi",scale:"s",maxItems:0,onCalciteComboboxChipDismiss:e=>{this.viewModel.selectTraces(!1,e.target.value),this.viewModel._traces.length>0&&(this._warningNoTraceSelected=!1)}},t))}renderStartOverContainer(){const{messages:e}=this;return n("calcite-button",{slot:"footer",scale:"m",color:"blue",width:"full",onclick:()=>{this.confirmReset()}},e.resultsStrings.startOverButton)}renderWarningMessage(e,t,s){const{messages:i}=this;let l=i.alertsStrings.NoRunAlertHeader,o=i.alertsStrings.noResultsInfo;switch(e){case"flag":l=i.alertsStrings.startingPointAlertHeader,o=i.alertsStrings.startingPointAlert;break;case"trace":l=i.alertsStrings.selectTraceAlertHeader,o=i.alertsStrings.selectTraceAlert;break;case"noTraceExecuted":l=i.alertsStrings.NoRunAlertHeader,o=i.alertsStrings.noResultsInfo;break;case"noBarrierAsset":case"noStartAsset":l=i.alertsStrings.noAssetsFoundHeader,o=i.alertsStrings.noAssetFound;break;case"noTraceConfig":l="",o=i.alertsStrings.noTraceSupported;break;default:l=i.alertsStrings.genericResultHeader,o=s||""}return n("div",{class:u.noticeContainer,key:e},n("calcite-notice",{open:!0,key:e,active:!0,dismissible:t,icon:!0,scale:"s",width:"auto",color:"red",onCalciteNoticeClose:()=>{switch(e){case"flag":this._warningNoFlag=!1;break;case"trace":this._warningNoTraceSelected=!1;break;case"noStartAsset":this._warningNoStartAssetFound=!1;break;case"noBarrierAsset":this._warningNoBarrierAssetFound=!1}}},n("div",{slot:"title"},l),n("div",{slot:"message"},o)))}renderRemoveTraceContainer(e){const{messages:t}=this;return n("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:t.globalStrings.clearResults,label:t.globalStrings.clearResults,onCalciteListItemChange:()=>{this._alertRemoveModal=!0,this._activeTrace=e.trace},onclick:()=>{this._alertRemoveModal=!0,this._activeTrace=e.trace},scale:"s",icon:"trash"})}renderHighlightColorPicker(e,t){const{messages:s}=this;return n("calcite-action-pad",{position:"start",layout:"grid",expandDisabled:!0},n("calcite-action-group",{layout:"grid",columns:4},n("calcite-action",{text:s.resultsStrings.graphicColor,label:s.resultsStrings.graphicColor,scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(0),t)}},n("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(0).hex,active:e.color===this._graphicHandler.getHighlightColor(0).color})),n("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(1),t)}},n("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(1).hex,active:e.color===this._graphicHandler.getHighlightColor(1).color})),n("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(2),t)}},n("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(2).hex,active:e.color===this._graphicHandler.getHighlightColor(2).color})),n("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(3),t)}},n("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(3).hex,active:e.color===this._graphicHandler.getHighlightColor(3).color})),n("calcite-action",{text:"",scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(4),t)}},n("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(4).hex,active:e.color===this._graphicHandler.getHighlightColor(4).color}))))}renderTraceResults(){const{messages:e}=this,t=this.viewModel._traceResults,s=[];return t.forEach(((t,i)=>{let l=[],o=[],r=!1,a=!1,c=!1;null!==t.results&&t.results.hasOwnProperty("elements")?(null!==t.results.aggregatedGeometry&&(a=!0),null!==t.results.globalFunctionResults&&t.results.globalFunctionResults.length>0&&(o=t.results.globalFunctionResults,o.length>0&&(c=!0)),t.results.elements.length>0&&(l=t.results.elements,l.length>0&&(r=!0)),s.push(n("calcite-block",{key:t.trace.title,heading:t.trace.title,summary:t.trace.description,collapsible:!1,open:!0,intlOptions:e.resultsStrings.ellipsesOptions},this.renderRemoveTraceContainer(t),n("calcite-list",null,c?n("calcite-list-item",{label:e.resultsStrings.functionHeader+" ("+o.length+")",onclick:()=>{this.switchToFunctions(o,!0)}},n("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"})):null,r&&this.viewModel.showSelectionAttributes?n("calcite-list-item",{label:e.resultsStrings.viewFeatures+" ("+l.length+")",onclick:()=>{this.switchToAssetGroup(this._groupResultsByAssetGroup(t),t.trace.title+" ("+l.length+")",!0)}},n("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"})):this.viewModel.showSelectionAttributes?n("calcite-label",{layout:"inline",scale:"s"},e.resultsStrings.noSelectionResults):null),n("div",{styles:g(10)}),r?n("calcite-label",{layout:"inline",scale:"s",onclick:e=>{e.preventDefault(),e.stopPropagation(),this.viewModel.mergeSelection(!t.selectionEnabled,t.trace)}},n("calcite-checkbox",{checked:t.selectionEnabled,scale:"m",onclick:e=>{e.preventDefault(),e.stopPropagation(),this.viewModel.mergeSelection(!t.selectionEnabled,t.trace)}}),this.viewModel.showSelectionAttributes?e.resultsStrings.selectFeatures:e.resultsStrings.selectFeatures+" ("+l.length+")"):null,a?n("calcite-block-section",{"toggle-display":"switch",text:e.resultsStrings.highlightTrace,open:t.graphicEnabled,onCalciteBlockSectionToggle:e=>{e.target.open?this.viewModel.changeResultGraphicColor(t.graphicColor,t):this.viewModel.removeResultGraphicFromView(t)}},n("calcite-popover-manager",{key:"aggGeom_"+t.trace.globalId,autoClose:!0},n("calcite-action",{text:e.resultsStrings.graphicColor,label:e.resultsStrings.graphicColor,scale:"s",onclick:e=>{const t=e.target;this._swatchNode=t,this._activeSwatch="aggGeom_"+i,this.scheduleRender()}},n("calcite-color-picker-swatch",{scale:"s",color:t.graphicColor.hex})),n("calcite-popover",{label:e.resultsStrings.graphicColor,text:e.resultsStrings.graphicColor,referenceElement:this._swatchNode,placement:"auto",offsetDistance:5,offsetSkidding:0,open:this._activeSwatch==="aggGeom_"+i,onCalcitePopoverClose:()=>{this._swatchNode=null,this._activeSwatch=null}},this.renderHighlightColorPicker(t.graphicColor,t)))):null))):s.push(n("calcite-block",{key:"error-"+i,heading:t.trace.title,collapsible:!1,open:!0},this.renderRemoveTraceContainer(t),this.renderWarningMessage("noController",!1,t.status)))})),n("calcite-panel",{key:"traceResults"},s,this.renderStartOverContainer(),n("calcite-modal",{active:this._alertRemoveModal,color:"blue",scale:"m",width:"s","intl-close":"Close",onCalciteModalClose:()=>{this._alertRemoveModal=!1,this.scheduleRender()}},n("h3",{slot:"header"},e.globalStrings.clearResults),n("div",{slot:"content"},e.alertsStrings.clearResultsAlert),n("calcite-button",{slot:"secondary",width:"full",appearance:"outline",onclick:()=>{this._alertRemoveModal=!1,this.scheduleRender()}},e.globalStrings.cancel),n("calcite-button",{slot:"primary",width:"full",onclick:()=>{this.viewModel.clearResult(this._activeTrace),this._alertRemoveModal=!1,0===this.viewModel._traceResults.length?this.switchTab("input"):(this._activeTrace=this.viewModel._traceResults[0].trace,this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1),this.scheduleRender()}},e.globalStrings.ok)))}renderTraceResultFunctions(){const{messages:e}=this,t=this._traceResultsFunctions,s=[];return t.forEach((e=>{s.push(this.renderResultRowFunctions(e))})),n("calcite-panel",{key:"functionResultMultiple",onCalcitePanelBackClick:()=>{this.switchToFunctions([],!1)},heading:e.resultsStrings.functionHeader},s,this.renderStartOverContainer())}renderTraceResultByAssetGroup(){const e=this._traceResultsAssetGroup,t=[];for(const s in e){const i=e[s];for(const e in i)t.push(this.renderResultRowAssetGroup(i[e]))}return n("calcite-panel",{key:"assetGroupResultMultiple",onCalcitePanelBackClick:()=>{this.switchToAssetGroup([],"",!1)},heading:this._traceHeaderForFlow},n("calcite-list",null,t),this.renderStartOverContainer())}renderTraceResultByAssetType(){const e=this._traceResultsAssetType,t=[];for(const s in e)e[s].length>0&&t.push(this.renderResultRowAssetType(e[s]));return n("calcite-panel",{key:"assetTypeResult",onCalcitePanelBackClick:()=>{this.switchToAssetType([],"",!1)},heading:this._assetGroupHeader},t,this.renderStartOverContainer())}renderTraceResultIndividual(){const{messages:e}=this,t=this._traceResultsIndividual;t.sort(this._compare(this._resultSortField,this._resultSortOrder));const s=[],i=[],l=[];return t.length>0&&(t[0].details.fields.forEach((e=>{i.push(n("calcite-option",{key:"display"+e.name,label:e.alias,value:e.name,selected:e.name===this._resultDisplayField})),l.push(n("calcite-option",{key:"sort"+e.name,label:e.alias,value:e.name,selected:e.name===this._resultSortField}))})),t.forEach((e=>{s.push(this.renderResultRowIndividual(e))}))),n("calcite-popover-manager",{class:u.esriMatchHeight,key:"popIndividualResult",autoClose:!0},n("calcite-panel",{key:"individualResult",onCalcitePanelBackClick:()=>{this._showResultOptions=!1,this.switchToIndividualRecords([],"",!1)},heading:this._assetTypeHeader},n("calcite-action",{"text-enabled":!0,slot:"header-actions-end",text:e.resultsStrings.displayAttribute,onCalciteListItemChange:()=>{this._showResultOptions=!0},onclick:()=>{this._showResultOptions=!0},scale:"s",icon:"gear",label:e.resultsStrings.displayAttribute,id:"field_options",afterCreate:a,bind:this,"data-node-ref":"_individualResultNode"}),s,this.renderStartOverContainer()),n("calcite-popover",{label:e.resultsStrings.displayAttribute,referenceElement:this._individualResultNode,placement:"auto",offsetDistance:5,offsetSkidding:0,open:this._showResultOptions,styles:m(.75*this.domNode.clientWidth)},n("calcite-block",{heading:e.resultsStrings.resultsListOptions,collapsible:!1,open:!0},n("calcite-label",{scale:"s"},e.resultsStrings.displayAttribute,n("calcite-select",{label:e.resultsStrings.displayAttribute,onCalciteSelectChange:e=>{const t=e.target;this._resultDisplayField=t.selectedOption.value,this._showResultOptions=!1}},i)),n("calcite-label",null,e.resultsStrings.sortBy,n("calcite-select",{label:e.resultsStrings.sortBy,onCalciteSelectChange:e=>{const s=e.target;this._resultSortField=s.selectedOption.value,t.sort(this._compare(this._resultSortField,this._resultSortOrder)),this._traceResultsIndividual=t,this._showResultOptions=!1}},l)))))}renderResultRow(e){let t=e[0].assetGroupCode;const s=this.viewModel.getValidSources().filter((t=>t.sourceId===e[0].networkSourceId));if(s.length>0){const i=s[0].assetGroups.filter((t=>t.assetGroupCode===e[0].assetGroupCode));i.length>0&&(t=i[0].assetGroupName)}return n("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.switchToAssetType(this._groupResultsByAssetType(e),t+" ("+e.length+")",!0)}},n("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}renderResultRowFunctions(e){return n("calcite-block",{heading:e.functionType+" = "+e.result,collapsible:!1})}renderResultRowAssetGroup(e){let t=e[0].assetGroupCode;const s=e[0].assetGroupCode,i=this.viewModel.getValidSources().filter((t=>t.sourceId===e[0].networkSourceId));if(i.length>0){const e=i[0].assetGroups.filter((e=>e.assetGroupCode===s));e.length>0&&(t=e[0].assetGroupName)}return n("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.switchToAssetType(this._groupResultsByAssetType(e),t+" ("+e.length+")",!0)}},n("calcite-icon",{slot:"content-end",icon:"chevron-right",scale:"s"}))}renderResultRowAssetType(e){let t=e[0].assetTypeCode;const s=e[0].assetGroupCode,i=this.viewModel.getValidSources().filter((t=>t.sourceId===e[0].networkSourceId));if(i.length>0){const l=i[0].assetGroups.filter((e=>e.assetGroupCode===s));if(l.length>0){const s=l[0].assetTypes.filter((t=>t.assetTypeCode===e[0].assetTypeCode));s.length>0&&(t=s[0].assetTypeName)}}return n("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.viewModel.queryFeaturesById(e).then((s=>{if(null!==s){const i=this._appendAttributes(e,s.featureSet,"objectId");this.switchToIndividualRecords(i,t+" ("+e.length+")",!0)}else this.switchToIndividualRecords(e,t+" ("+e.length+")",!0)}))}},n("calcite-icon",{slot:"content-end",icon:"chevron-right",scale:"s"}))}renderResultRowIndividual(e){const{messages:t}=this;let s=e.details.attributes[this._resultDisplayField];return s&&""!==s&&null!==s||(s=t.resultsStrings.noValue),n("calcite-list-item",{label:s,onclick:()=>{this.viewModel.zoomToAsset(e.details.geometry)}},n("calcite-icon",{icon:"zoom-to-object","text-label":t.globalStrings.zoomToFeature,scale:"s",slot:"content-end"}))}_UtilityNetworkTraceInitialized(){return this.viewModel.loadUtilityNetwork().then((e=>e?(this.viewModel.selectTracesOnLoad(),this.viewModel._traces.length<=0&&(this._tracesExists=!1),this.viewModel.flags.length>0?this.view.when().then((()=>{const e=s(this.view,"updating",(async()=>{this._warningNoFlag=!1,this._warningNoBarrierAssetFound=!1,this._warningNoStartAssetFound=!1;const t=await this.viewModel.addFlagsOnLoad();t.includes("barrier")&&(this._warningNoBarrierAssetFound=!0),t.includes("starting-point")&&(this._warningNoStartAssetFound=!0),this.disabled=!1,e.remove(),this.scheduleRender()}))})):this.view.when().then((()=>{const e=s(this.view,"updating",(()=>{this.disabled=!1,e.remove()}))}))):(this._tracesExists=!1,this.view.when().then((()=>{const e=s(this.view,"updating",(()=>{this.disabled=!1,e.remove()}))})))))}_groupResultsByAssetGroup(e){const t=[],s=e.results.elements,i=this._groupBy(s,"networkSourceId");for(const l in i)t.push(this._groupBy(i[l],"assetGroupCode"));return t}_groupResultsByAssetType(e){return this._groupBy(e,"assetTypeCode")}_appendAttributes(e,t,s){const i=[];return e.forEach((e=>{t.features.forEach((l=>{e[s]===l.attributes[s.toLowerCase()]&&(e.details=l,e.details.fields=t.fields,i.push(e))}))})),i}_compare(e,t){return(s,i)=>{let l=0,o=s.details.attributes[e],r=i.details.attributes[e];return isNaN(o)&&(o=o.toLowerCase()),isNaN(r)&&(r=r.toLowerCase()),"desc"===t?o>r?l=1:o<r&&(l=-1):o<r?l=1:o>r&&(l=-1),l}}_groupBy(e,t){return e.reduce((function(e,s){return(e[s[t]]=e[s[t]]||[]).push(s),e}),{})}};e([l()],v.prototype,"_confirmReset",void 0),e([l()],v.prototype,"disabled",void 0),e([i("viewModel.flags")],v.prototype,"flags",void 0),e([i("viewModel.gdbVersion")],v.prototype,"gdbVersion",void 0),e([i("viewModel.goToOverride")],v.prototype,"goToOverride",void 0),e([l()],v.prototype,"iconClass",void 0),e([l({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],v.prototype,"label",void 0),e([l(),c("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace")],v.prototype,"messages",void 0),e([l(),c("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([i("viewModel.selectedTraces")],v.prototype,"selectedTraces",void 0),e([i("viewModel.selectOnComplete")],v.prototype,"selectOnComplete",void 0),e([i("viewModel.showGraphicsOnComplete")],v.prototype,"showGraphicsOnComplete",void 0),e([i("viewModel.showSelectionAttributes")],v.prototype,"showSelectionAttributes",void 0),e([i("viewModel.view")],v.prototype,"view",void 0),e([l({type:h})],v.prototype,"viewModel",void 0),v=e([o(p)],v);const _=v;export{_ as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[102],{68773:(e,t,r)=>{r.d(t,{Z:()=>s}),r(80442);var n,o=r(78286),i=r(17202);const s={apiKey:void 0,applicationUrl:null==(n=globalThis.location)?void 0:n.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryService:null,geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&((0,o.RH)(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){const e="4.22.0";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}-next.${i.r}/assets`}s.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(s,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),s.request.corsEnabledServers=[],s.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0}},20102:(e,t,r)=>{r.d(t,{Z:()=>s});var n=r(22974),o=r(92604),i=r(58896);class s extends i.Z{constructor(e,t,r){if(super(e,t,r),!(this instanceof s))return new s(e,t,r)}toJSON(){if(null!=this.details)try{return{name:this.name,message:this.message,details:JSON.parse(JSON.stringify(this.details,((e,t)=>{if(t&&"object"==typeof t&&"function"==typeof t.toJSON)return t;try{return(0,n.d9)(t)}catch(e){return"[object]"}})))}}catch(e){throw o.Z.getLogger("esri.core.Error").error(e),e}return{name:this.name,message:this.message,details:this.details}}static fromJSON(e){return new s(e.name,e.message,e.details)}}s.prototype.type="error"},92604:(e,t,r)=>{r.d(t,{Z:()=>a});var n=r(68773),o=(r(80442),r(70586)),i=r(19153);const s={info:0,warn:1,error:2,none:3};class a{constructor(e){this.level=null,this._module="",this._parent=null,this.writer=null,this._loggedMessages={error:new Map,warn:new Map,info:new Map},null!=e.level&&(this.level=e.level),null!=e.writer&&(this.writer=e.writer),this._module=e.module,a._loggers[this.module]=this;const t=this.module.lastIndexOf(".");-1!==t&&(this._parent=a.getLogger(this.module.slice(0,t)))}get module(){return this._module}get parent(){return this._parent}error(...e){this._log("error","always",...e)}warn(...e){this._log("warn","always",...e)}info(...e){this._log("info","always",...e)}errorOnce(...e){this._log("error","once",...e)}warnOnce(...e){this._log("warn","once",...e)}infoOnce(...e){this._log("info","once",...e)}errorOncePerTick(...e){this._log("error","oncePerTick",...e)}warnOncePerTick(...e){this._log("warn","oncePerTick",...e)}infoOncePerTick(...e){this._log("info","oncePerTick",...e)}get test(){const e=this;return{loggedMessages:e._loggedMessages,clearLoggedWarnings:()=>e._loggedMessages.warn.clear()}}static get testSingleton(){return{resetLoggers(e={}){const t=a._loggers;return a._loggers=e,t},set throttlingDisabled(e){a._throttlingDisabled=e}}}static getLogger(e){let t=a._loggers[e];return t||(t=new a({module:e})),t}_log(e,t,...r){if(this._matchLevel(e)){if("always"!==t&&!a._throttlingDisabled){const n=this._argsToKey(r),o=this._loggedMessages[e].get(n);if("once"===t&&null!=o||"oncePerTick"===t&&o&&o>=a._tickCounter)return;this._loggedMessages[e].set(n,a._tickCounter),a._scheduleTickCounterIncrement()}for(const t of n.Z.log.interceptors)if(t(e,this.module,...r))return;this._inheritedWriter()(e,this.module,...r)}}_parentWithMember(e,t){let r=this;for(;(0,o.pC)(r);){const t=r[e];if((0,o.pC)(t))return t;r=r.parent}return t}_inheritedWriter(){return this._parentWithMember("writer",this._consoleWriter)}_consoleWriter(e,t,...r){console[e](`[${t}]`,...r)}_matchLevel(e){const t=n.Z.log.level?n.Z.log.level:"warn";return s[this._parentWithMember("level",t)]<=s[e]}_argsToKey(...e){return(0,i.hP)(JSON.stringify(e,((e,t)=>"object"!=typeof t||Array.isArray(t)?t:"[Object]")))}static _scheduleTickCounterIncrement(){a._tickCounterScheduled||(a._tickCounterScheduled=!0,Promise.resolve().then((()=>{a._tickCounter++,a._tickCounterScheduled=!1})))}}a._loggers={},a._tickCounter=0,a._tickCounterScheduled=!1,a._throttlingDisabled=!1},58896:(e,t,r)=>{r.d(t,{Z:()=>o});var n=r(78286);class o{constructor(e,t,r){this.name=e,this.details=r,this.message=void 0,this instanceof o&&(this.message=t&&function(e,t){return e.replace(/\$\{([^\s\:\}]*)(?:\:([^\s\:\}]+))?\}/g,(function(e,r){if(""===r)return"$";const o=(0,n.hS)(r,t),i=null==o?"":o;if(void 0===i)throw new Error(`could not find key "${r}" in template`);return i.toString()}))}(t,r)||"")}toString(){return"["+this.name+"]: "+this.message}}},77734:(e,t,r)=>{r.d(t,{Z:()=>n});class n{constructor(e=1){this._seed=e}set seed(e){this._seed=null==e?Math.random()*n._m:e}getInt(){return this._seed=(n._a*this._seed+n._c)%n._m,this._seed}getFloat(){return this.getInt()/(n._m-1)}getIntRange(e,t){return Math.round(this.getFloatRange(e,t))}getFloatRange(e,t){const r=t-e;return e+this.getInt()/n._m*r}}n._m=2147483647,n._a=48271,n._c=0},67676:(e,t,r)=>{r.d(t,{SO:()=>c,a9:()=>a,fS:()=>i,cq:()=>d,w6:()=>l,Od:()=>p,e$:()=>f,FY:()=>g});var n=r(70586),o=r(77734);function i(e,t,r){if((0,n.Wi)(e)&&(0,n.Wi)(t))return!0;if((0,n.Wi)(e)||(0,n.Wi)(t)||e.length!==t.length)return!1;if(r){for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1}else for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}const s=!!Array.prototype.fill;function a(e,t){if(s)return new Array(e).fill(t);const r=new Array(e);for(let n=0;n<e;n++)r[n]=t;return r}function l(e,t){void 0===t&&(t=e,e=0);const r=new Array(t-e);for(let n=e;n<t;n++)r[n-e]=n;return r}class c{constructor(){this.last=0}}const u=new c;function d(e,t,r,n){n=n||u;const o=Math.max(0,n.last-10);for(let i=o;i<r;++i)if(e[i]===t)return n.last=i,i;const i=Math.min(o,r);for(let r=0;r<i;++r)if(e[r]===t)return n.last=r,r;return-1}function f(e,t,r,n){const o=null==r?e.length:r,i=d(e,t,o,n);if(-1!==i)return e[i]=e[o-1],null==r&&e.pop(),t}const h=new Set;function g(e,t,r=e.length,n=t.length,o,i){if(0===n||0===r)return r;h.clear();for(let e=0;e<n;++e)h.add(t[e]);o=o||u;const s=Math.max(0,o.last-10);for(let t=s;t<r;++t)if(h.has(e[t])&&(i&&i.push(e[t]),h.delete(e[t]),e[t]=e[r-1],--r,--t,0===h.size||0===r))return h.clear(),r;for(let t=0;t<s;++t)if(h.has(e[t])&&(i&&i.push(e[t]),h.delete(e[t]),e[t]=e[r-1],--r,--t,0===h.size||0===r))return h.clear(),r;return h.clear(),r}function p(e,t){const r=e.indexOf(t);return-1!==r?(e.splice(r,1),t):null}new o.Z},80442:(e,t,r)=>{var n,o;let i;var s,a;function l(e){return"function"==typeof i[e]?i[e]=i[e](globalThis):i[e]}r.d(t,{Z:()=>l}),i=null!=(n=globalThis.dojoConfig)&&n.has||null!=(o=globalThis.esriConfig)&&o.has?{...null==(s=globalThis.dojoConfig)?void 0:s.has,...null==(a=globalThis.esriConfig)?void 0:a.has}:{},l.add=(e,t,r,n)=>((n||void 0===i[e])&&(i[e]=t),r&&l(e)),l.cache=i,l.add("esri-deprecation-warnings",!0),(()=>{var e;l.add("host-webworker",void 0!==globalThis.WorkerGlobalScope&&self instanceof globalThis.WorkerGlobalScope);const t="undefined"!=typeof window&&"undefined"!=typeof location&&"undefined"!=typeof document&&window.location===location&&window.document===document;if(l.add("host-browser",t),l.add("host-node","object"==typeof globalThis.process&&(null==(e=globalThis.process.versions)?void 0:e.node)&&globalThis.process.versions.v8),l.add("dom",t),l("host-browser")){const e=navigator,t=e.userAgent,r=e.appVersion,n=parseFloat(r);if(l.add("wp",parseFloat(t.split("Windows Phone")[1])||void 0),l.add("msapp",parseFloat(t.split("MSAppHost/")[1])||void 0),l.add("khtml",r.includes("Konqueror")?n:void 0),l.add("edge",parseFloat(t.split("Edge/")[1])||void 0),l.add("opr",parseFloat(t.split("OPR/")[1])||void 0),l.add("webkit",!l("wp")&&!l("edge")&&parseFloat(t.split("WebKit/")[1])||void 0),l.add("chrome",!l("edge")&&!l("opr")&&parseFloat(t.split("Chrome/")[1])||void 0),l.add("android",!l("wp")&&parseFloat(t.split("Android ")[1])||void 0),l.add("safari",!r.includes("Safari")||l("wp")||l("chrome")||l("android")||l("edge")||l("opr")?void 0:parseFloat(r.split("Version/")[1])),l.add("mac",r.includes("Macintosh")),!l("wp")&&t.match(/(iPhone|iPod|iPad)/)){const e=RegExp.$1.replace(/P/,"p"),r=t.match(/OS ([\d_]+)/)?RegExp.$1:"1",n=parseFloat(r.replace(/_/,".").replace(/_/g,""));l.add(e,n),l.add("ios",n)}l.add("trident",parseFloat(r.split("Trident/")[1])||void 0),l("webkit")||(!t.includes("Gecko")||l("wp")||l("khtml")||l("trident")||l("edge")||l.add("mozilla",n),l("mozilla")&&l.add("ff",parseFloat(t.split("Firefox/")[1]||t.split("Minefield/")[1])||void 0))}})(),(()=>{if(globalThis.navigator){const e=navigator.userAgent,t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|IEMobile/i.test(e),r=/iPhone/i.test(e);t&&l.add("esri-mobile",t),r&&l.add("esri-iPhone",r),l.add("esri-geolocation",!!navigator.geolocation)}l.add("esri-canvas-svg-support",!l("trident")),l.add("esri-wasm","WebAssembly"in globalThis),l.add("esri-shared-array-buffer",(()=>{const e="SharedArrayBuffer"in globalThis,t=!1===globalThis.crossOriginIsolated;return e&&!t})),l.add("esri-atomics","Atomics"in globalThis),l.add("esri-workers","Worker"in globalThis),l.add("esri-text-decoder","TextDecoder"in globalThis),l.add("esri-text-encoder","TextEncoder"in globalThis),l.add("web-feat:cache","caches"in globalThis),l.add("esri-workers-arraybuffer-transfer",!l("safari")||Number(l("safari"))>=12),l.add("featurelayer-simplify-thresholds",[.5,.5,.5,.5]),l.add("featurelayer-simplify-payload-size-factors",[1,1,4]),l.add("featurelayer-snapshot-enabled",!0),l.add("featurelayer-snapshot-point-min-threshold",8e4),l.add("featurelayer-snapshot-point-max-threshold",4e5),l.add("featurelayer-snapshot-point-coverage",.1),l.add("featurelayer-advanced-symbols",!1),l.add("featurelayer-pbf",!0),l.add("featurelayer-pbf-statistics",!1),l.add("feature-layers-workers",!0),l.add("mapview-transitions-duration",200),l.add("mapserver-pbf-enabled",!1),l.add("vectortilelayer-max-buffers",l("ff")?160:Number.POSITIVE_INFINITY),l("host-webworker")||l("host-browser")&&(l.add("esri-csp-restrictions",(()=>{try{new Function}catch{return!0}return!1})),l.add("esri-image-decode",(()=>{if("decode"in new Image){const e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>',void e.decode().then((()=>{l.add("esri-image-decode",!0,!0,!0)})).catch((()=>{l.add("esri-image-decode",!1,!0,!0)}))}return!1})),l.add("esri-url-encodes-apostrophe",(()=>{const e=window.document.createElement("a");return e.href="?'",e.href.includes("?%27")})))})()},22974:(e,t,r)=>{r.d(t,{d9:()=>i,fS:()=>s,yd:()=>o}),r(67676),r(80442);var n=r(1533);function o(e,t){let r;if(t)for(r in e)e.hasOwnProperty(r)&&(void 0===e[r]?delete e[r]:e[r]instanceof Object&&o(e[r],!0));else for(r in e)e.hasOwnProperty(r)&&void 0===e[r]&&delete e[r];return e}function i(e){if(!e||"object"!=typeof e||"function"==typeof e)return e;if((0,n.W0)(e)||(0,n.lq)(e)||(0,n.KZ)(e)||(0,n.z3)(e)||(0,n.Uc)(e)||(0,n.Hx)(e)||(0,n.ZY)(e)||(0,n.xZ)(e)||(0,n.fS)(e))return(0,n.tP)(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof ArrayBuffer)return e.slice(0,e.byteLength);if(e instanceof Map){const t=new Map;return e.forEach(((e,r)=>{t.set(r,i(e))})),t}if(e instanceof Set){const t=new Set;return e.forEach((e=>{t.add(i(e))})),t}let t;const r=e;if("function"==typeof r.clone)t=r.clone();else if("function"==typeof r.map&&"function"==typeof r.forEach)t=r.map(i);else if("function"==typeof r.notifyChange&&"function"==typeof r.watch)t=r.clone();else{t={};for(const r of Object.getOwnPropertyNames(e))t[r]=i(e[r])}return t}function s(e,t){return e===t||"number"==typeof e&&isNaN(e)&&"number"==typeof t&&isNaN(t)||"function"==typeof(e||{}).getTime&&"function"==typeof(t||{}).getTime&&e.getTime()===t.getTime()||!1}},70586:(e,t,r)=>{function n(e){return null!=e}function o(e){return null==e}function i(e){return void 0===e}function s(e,t){return n(e)?t(e):null}function a(e){return e}function l(e,t){if(o(e))throw new Error(t);return e}function c(e,t){return n(e)?e:"function"==typeof t?t():t}function u(e){return n(e)&&e.destroy(),null}function d(e){return n(e)&&e.dispose(),null}function f(e){return n(e)&&e.remove(),null}function h(e){return n(e)&&e.release(),null}function g(e){return null}function p(e,t){const r=new Array;for(const n of e)r.push(y(n,null,t));return r}function m(e,t){for(const r of e)y(r,null,t)}function y(e,t,r){return n(e)?r(e):t}function w(e,t){return n(e)?t(e):null}function b(e){return e.filter((e=>n(e)))}function v(e,...t){let r=e;for(let e=0;e<t.length&&r;++e)r=r[t[e]];return r}function _(e){return e}r.d(t,{Po:()=>w,yw:()=>s,j0:()=>_,SC:()=>u,O3:()=>d,lV:()=>b,JR:()=>m,U2:()=>v,Wi:()=>o,pC:()=>n,o8:()=>i,Fd:()=>p,R2:()=>y,Bd:()=>g,RY:()=>h,hw:()=>f,Wg:()=>a,Pt:()=>c,s3:()=>l})},78286:(e,t,r)=>{r.d(t,{RH:()=>o,hS:()=>i,RB:()=>s});var n=r(22974);function o(e,t,r=!1){return l(e,t,r)}function i(e,t){if(null!=t)return t[e]||a(e.split("."),!1,t)}function s(e,t,r){const n=e.split("."),o=n.pop(),i=a(n,!0,r);i&&o&&(i[o]=t)}function a(e,t,r){let n=r;for(const r of e){if(null==n)return;if(!(r in n)){if(!t)return;n[r]={}}n=n[r]}return n}function l(e,t,r){return t?Object.keys(t).reduce((function(e,o){let i=e[o],s=t[o];return i===s?e:void 0===i?(e[o]=(0,n.d9)(s),e):(Array.isArray(s)||Array.isArray(e)?(i=i?Array.isArray(i)?e[o]=i.concat():e[o]=[i]:e[o]=[],s&&(Array.isArray(s)||(s=[s]),r?s.forEach((e=>{-1===i.indexOf(e)&&i.push(e)})):e[o]=s.concat())):s&&"object"==typeof s?e[o]=l(i,s,r):e.hasOwnProperty(o)&&!t.hasOwnProperty(o)||(e[o]=s),e)}),e||{}):e}},19153:(e,t,r)=>{r.d(t,{Qs:()=>a,hP:()=>l,gx:()=>s,Cb:()=>c});var n=r(78286);const o=/\{([^\}]+)\}/g;function i(e){return null==e?"":e}function s(e,t){return e.replace(o,"object"==typeof t?(e,r)=>i((0,n.hS)(r,t)):(e,r)=>i(t(r)))}function a(e,t){return e.replace(/([\.$?*|{}\(\)\[\]\\\/\+\-^])/g,(e=>t&&-1!==t.indexOf(e)?e:`\\${e}`))}function l(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t}function c(e){return(new DOMParser).parseFromString(e||"","text/html").body.innerText||""}},1533:(e,t,r)=>{function n(e,t){if(e.forEach)e.forEach(t);else for(let r=0;r<e.length;r++)t(e[r],r,e)}function o(e,t,r){if(e.slice)return e.slice(t,r);void 0===t?t=0:(t<0&&(t+=e.length),t=Math.min(e.length,Math.max(0,t))),void 0===r?r=e.length:(r<0&&(r+=e.length),r=Math.min(e.length,Math.max(0,r)));const n=Math.max(0,r-t),o=new(0,e.constructor)(n);for(let r=0;r<n;r++)o[r]=e[t+r];return o}function i(e){return e instanceof ArrayBuffer||e&&e.constructor&&"ArrayBuffer"===e.constructor.name}function s(e){return e instanceof Int8Array||e&&e.constructor&&"Int8Array"===e.constructor.name}function a(e){return e instanceof Uint8Array||e&&e.constructor&&"Uint8Array"===e.constructor.name}function l(e){return e instanceof Uint8ClampedArray||e&&e.constructor&&"Uint8ClampedArray"===e.constructor.name}function c(e){return e instanceof Int16Array||e&&e.constructor&&"Int16Array"===e.constructor.name}function u(e){return e instanceof Uint16Array||e&&e.constructor&&"Uint16Array"===e.constructor.name}function d(e){return e instanceof Int32Array||e&&e.constructor&&"Int32Array"===e.constructor.name}function f(e){return e instanceof Uint32Array||e&&e.constructor&&"Uint32Array"===e.constructor.name}function h(e){return e instanceof Float32Array||e&&e.constructor&&"Float32Array"===e.constructor.name}function g(e){return e instanceof Float64Array||e&&e.constructor&&"Float64Array"===e.constructor.name}r.d(t,{Ed:()=>n,eP:()=>i,xZ:()=>h,fS:()=>g,z3:()=>c,Hx:()=>d,W0:()=>s,Uc:()=>u,ZY:()=>f,lq:()=>a,KZ:()=>l,tP:()=>o})},17202:(e,t,r)=>{r.d(t,{r:()=>n,$:()=>o});const n="20211207",o="8b8e75021131dcecb98391beb102899cecad2a32"}}]);
|