@arcgis/core 5.0.0-next.8 → 5.0.0-next.9
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/02e7359162cf974b41b6.js +1 -0
- package/assets/esri/core/workers/chunks/0f735b0dec173142f3b6.js +2 -0
- package/assets/esri/core/workers/chunks/{a8f998b8ec8c56150479.js.LICENSE.txt → 0f735b0dec173142f3b6.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{b708792c84620b73c847.js → 21293b0c6405a10ec7b6.js} +1 -1
- package/assets/esri/core/workers/chunks/{a876d6159ca120c1567e.js → 28d1f2cf6aae547615c3.js} +1 -1
- package/assets/esri/core/workers/chunks/292daac70bb828e4923f.js +1 -0
- package/assets/esri/core/workers/chunks/31b6406960261da21dd4.js +1 -0
- package/assets/esri/core/workers/chunks/31dbe07047dc61303d7d.js +1 -0
- package/assets/esri/core/workers/chunks/{59d3cac32ad6dad941dc.js → 35c9b24e4430bd6c2b6b.js} +1 -1
- package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/4fb5f1c671892001a4fd.js +1 -0
- package/assets/esri/core/workers/chunks/{d88f2fe680b8d5603ef8.js → 5350d50b47b6a4e0e169.js} +1 -1
- package/assets/esri/core/workers/chunks/58e59ead33368ce38c8f.js +1 -0
- package/assets/esri/core/workers/chunks/{aff8e40a641c6822af1d.js → 5db37547963857295273.js} +1 -1
- package/assets/esri/core/workers/chunks/{3afb83f5de033dda89ec.js → 604777417722d4effe06.js} +1 -1
- package/assets/esri/core/workers/chunks/67f03d042455cd0f7009.js +1 -0
- package/assets/esri/core/workers/chunks/7565b382f6b3d2cb46a3.js +2 -0
- package/assets/esri/core/workers/chunks/{b96eb0ea506379182d62.js.LICENSE.txt → 7565b382f6b3d2cb46a3.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/7d641f2f5edd95b9bc18.js +1 -0
- package/assets/esri/core/workers/chunks/812f2ccc01f44e3cfd41.js +1 -0
- package/assets/esri/core/workers/chunks/826fa0dfb63df77bfd95.js +1 -0
- package/assets/esri/core/workers/chunks/87921f3fa9001f5801ed.js +1 -0
- package/assets/esri/core/workers/chunks/{2a8dff8521e1e6a10cf6.js → 89b748e064ca90b4f76a.js} +1 -1
- package/assets/esri/core/workers/chunks/{fef45bc59c71f88c60b5.js → 8d9d3797c6d62fdfff9d.js} +1 -1
- package/assets/esri/core/workers/chunks/{e5a06ce0ef6a9a90e100.js → 9f21436016ff7a899e79.js} +1 -1
- package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js → 9ff8ee6ed6b98c03ae7e.js} +2 -2
- package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js.LICENSE.txt → 9ff8ee6ed6b98c03ae7e.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/b05208d56a724a8f1661.js +1 -0
- package/assets/esri/core/workers/chunks/{b0365cbc3d2a41969e3b.js → b7eb486354994dc70855.js} +1 -1
- package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +1 -0
- package/assets/esri/core/workers/chunks/c715fd32f814a0f14f40.js +1 -0
- package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/cf971e7b1b98d9c502d3.js +1 -0
- package/assets/esri/core/workers/chunks/{20975513be0a3a1da286.js → d1ca7c3a32ce00ed8b81.js} +1 -1
- package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js → d391bfbaf0e790cd10d6.js} +2 -2
- package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js.LICENSE.txt → d391bfbaf0e790cd10d6.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/db678a6e352275e507a9.js +1 -0
- package/assets/esri/core/workers/chunks/de2ebd9cc3d9e68d435b.js +1 -0
- package/assets/esri/core/workers/chunks/e599125e746c27de106e.js +1 -0
- package/assets/esri/core/workers/chunks/{05429f9d292a7a714309.js → ebcc94234d9d4be1941f.js} +1 -1
- package/assets/esri/core/workers/chunks/ee5f0fd5384caa11c986.js +1 -0
- package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/f80f5dbf96c343ac4df6.js +1 -0
- package/assets/esri/core/workers/chunks/fccd931f95d81ecc57b2.js +1 -0
- package/assets/esri/themes/base/widgets/_NavigationToggle.scss +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -4
- package/assets/esri/themes/base/widgets/_Widget.scss +1 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/config.js +1 -1
- package/form/FormTemplate.js +1 -1
- package/form/elements/Element.js +1 -1
- package/form/elements/FieldElement.js +1 -1
- package/form/elements/GroupElement.js +1 -1
- package/interfaces.d.ts +25 -23
- package/kernel.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/knowledgeGraph/layerUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/rasterDatasets/pixelReader.js +1 -1
- package/layers/support/rasterFunctions/pixelTransformUtils.js +5 -0
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/package.json +2 -2
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/support/PromiseQueue.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/widgets/Editor/AddAssociationWorkflow.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflowData.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflowData.js +1 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/Editor/support/errors.js +5 -0
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
- package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +0 -1
- package/assets/esri/core/workers/chunks/1d15d1b20dc10fde6def.js +0 -1
- package/assets/esri/core/workers/chunks/28020063048e644f17a5.js +0 -1
- package/assets/esri/core/workers/chunks/36d067c8d03d7a894f5f.js +0 -1
- package/assets/esri/core/workers/chunks/38cc18fd93c18815ded0.js +0 -1
- package/assets/esri/core/workers/chunks/4eebd74ebc20579dade8.js +0 -1
- package/assets/esri/core/workers/chunks/5f402b3c00bc4afc77b2.js +0 -1
- package/assets/esri/core/workers/chunks/63a6f3e70d2b6ea57e40.js +0 -1
- package/assets/esri/core/workers/chunks/695cdef5057e5461078a.js +0 -1
- package/assets/esri/core/workers/chunks/6bb7dbc46787b8e34bd9.js +0 -1
- package/assets/esri/core/workers/chunks/6ee2f0f708494102a493.js +0 -1
- package/assets/esri/core/workers/chunks/78694ad8229347903f41.js +0 -1
- package/assets/esri/core/workers/chunks/90cbd627d4113db3b686.js +0 -1
- package/assets/esri/core/workers/chunks/a31635a6366347dcef0f.js +0 -1
- package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js +0 -2
- package/assets/esri/core/workers/chunks/afc13d5b842275db7dbc.js +0 -1
- package/assets/esri/core/workers/chunks/b548910e820d731ffe8a.js +0 -1
- package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +0 -2
- package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +0 -1
- package/assets/esri/core/workers/chunks/ce98416437cc1a89d8ea.js +0 -1
- package/assets/esri/core/workers/chunks/e0bbfbe1ed39c82f1bd4.js +0 -1
- package/assets/esri/core/workers/chunks/ebf23b46db56aaa88841.js +0 -1
package/widgets/Editor.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../intl.js";import{deprecatedFunction as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{destroyMaybe as s,abortMaybe as o,mappedFind as r}from"../core/maybe.js";import{createResolver as a}from"../core/promiseUtils.js";import{watch as n,on as l,when as c,initial as d}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../core/support/UpdatingHandles.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import g from"./Attachments.js";import _ from"./BatchAttributeForm.js";import w from"./FeatureForm.js";import v from"./FeatureTemplates.js";import f from"./Spinner.js";import y from"./Widget.js";import{VisibleElements as b}from"./BatchAttributeForm/VisibleElements.js";import{css as k}from"./Editor/css.js";import F from"./Editor/EditorViewModel.js";import{isModelUpload as A}from"./Editor/modelUploadUtils.js";import M from"./Editor/VisibleElements.js";import{isUpdateWorkflow as S,isUpdateRecordWorkflow as T,isBatchAttributeFormViewModel as C}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as L,CreateFeaturesPanelContent as E}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as W,FeatureList as P}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as I,FooterActions as j}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as U,Notice as V}from"./Editor/components/Notices.js";import{loadPanelContentComponents as D,PanelContent as x,PanelContentSection as B,PanelContentMessage as O}from"./Editor/components/PanelContent.js";import{PanelToolbar as N,loadPanelToolbarComponents as H}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as R,Prompt as G}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as z,UpdateFeaturePanelContent as q}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as K,UploadDetails as Z}from"./Editor/components/UploadDetails.js";import{CreateToolVisibilityMap as $}from"./Sketch/CreateToolVisibilityMap.js";import{SelectionToolVisibilityMap as J}from"./Sketch/SelectionToolVisibilityMap.js";import{VisibleElements as Q}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as X}from"./support/componentsUtils.js";import{globalCss as Y}from"./support/globalCss.js";import{incrementHeadingLevel as ee,Heading as te}from"./support/Heading.js";import{renderItem as ie}from"./support/ItemList.js";import{connectDelayedLoading as se}from"./support/loaderUtils.js";import oe from"./support/SelectionList.js";import re from"./support/SelectionToolbar.js";import"./support/widgetUtils.js";import{messageBundle as ae}from"./support/decorators/messageBundle.js";import{vmEvent as ne}from"./support/decorators/vmEvent.js";import{tsx as le}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";import ce from"./support/SelectionList/VisibleElements.js";import de from"./support/SelectionToolbar/VisibleElements.js";import{substitute as he}from"../intl/substitute.js";const me=Symbol("sketch-setup-handles");let pe=class extends y{constructor(e,t){super(e,t),this._batchAttributeForm=new _({visibleElements:new b({loadingIndicator:!1})}),this._featureForm=new w,this._sketchToolbar=null,this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new v({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?le("calcite-icon",{class:k.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new f,this._loading=!1,this._selectionList=new oe({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new ce({header:!1})}),this._selectionToolbar=new re({visibleElements:new de({chip:!1})}),this._updatingHandles=new p,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new F,this.visibleElements=new M,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?le("div",{class:k.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>le("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:i},...s)=>{const{visibleElements:o}=this;return le("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:i,onCalciteFlowItemBack:this._onBack},o.settingsMenu?le(N,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...s)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,i={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&A(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...i,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(i)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onSplit=()=>{const{activeWorkflow:e}=this.viewModel;if(S(e)){const t=e.activeWorkflow;if(T(t)){const i=t.data.edits.feature;i&&e.startSplittingFeature(i)}}},this._onDelete=()=>{const e=this.viewModel.activeFeatureCount,t=e>1?this.messages.multiFeature:this.messages.singleFeature;this._showPrompt({title:t.deleteWarningTitle,message:t.deleteWarningMessage,context:"danger",actions:{primary:{label:he(t.delete,{count:e}),action:()=>{this.deleteFeatures(),this._clearPrompt()}},secondary:{label:t.keep,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then(()=>e.back()))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then(()=>e.back()))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([n(()=>ee(this.headingLevel),e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e},d),l(()=>this.viewModel.activeWorkflow,"cancel-request",({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then(t=>t?e.allow():e.deny())}),c(()=>this.viewModel.formViewModel,e=>{C(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e},d),c(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel,e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))},d),c(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association,()=>{this._setUpAssociationSettings()}),n(()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel],([e,t,i,s,o,r])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=i,this._spinner.viewModel=s,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=r,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt},d),n(()=>this.view,(e,t)=>{const i=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,i),e?.ui.add(this._spinner,{key:i,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)},d),n(()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel],([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))},d),c(()=>this._attachments?.error,e=>this._onAttachmentsError(e)),c(()=>this._selectionListItemActionConfigs,()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs}),c(()=>this.viewModel?.failures,e=>{const{messages:t}=this,[{error:i,retry:s,cancel:o}]=e;this._showPrompt({title:t.errorWarningTitle,message:he(t.errorWarningMessageTemplate,{errorMessage:i.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{s(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{o(),this._clearPrompt()}}}})}),n(()=>this.viewModel?.state,e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}}),n(()=>this.viewModel.featureFormDisabled,e=>this._featureForm.disabled=e),n(()=>this.visibleElements.sketch,()=>this._setupSketch(),d),se({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=s(this._sketchToolbar),this._sketchImportAbortController=o(this._sketchImportAbortController)}loadDependencies(){return Promise.all([X({flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),L(),W(),I(),U(),D(),H(),R(),z(),K()])}get _hasInvalidBatchSelection(){return this._hasSelectionFromMultipleLayers||this._selectionCountExceedsMaximum||0===this._selectionList.visibleFeatureCount}get _hasSelectionFromMultipleLayers(){return this._selectionList.visibleLayerCount>1}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionCountExceedsMaximum(){const e=this._batchAttributeForm.maximumFeatureCount,{activeLayerItem:t,effectiveCount:i,filterText:s,visibleFeatureCount:o}=this._selectionList;return null!=s&&""!==s?o>e:t?t.total>e:i>e}get _selectionListItemActionConfigs(){const{messages:e}=this;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)},{label:e?.batchEditing?.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)}]}get _visibleSelectionCount(){const{activeLayerItem:e,effectiveCount:t,filterText:i,visibleFeatureCount:s}=this._selectionList;return null!=i&&""!==i?s:e?e.total:t}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}async startSplitFeatureWorkflow(e,t={}){await this.viewModel.startSplitFeatureWorkflow(e,t)}startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}async startUpdateWorkflowWithActiveSelection(){await this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return t(i.getLogger(this),"Editor.deleteFeatureFromWorkflow is deprecated. Use Editor.deleteFeatures instead.",{version:"4.33",replacement:"Editor.deleteFeatures",warnOnce:!0}),this.deleteFeatures()}async deleteFeatures(){await this.viewModel.deleteFeatures()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,i=this.classes(k.base,Y.widget,Y.panel);if(!t)return le("div",{class:i,key:"empty"});const{pageStack:s}=t,o=s.length-1,r=s.map((e,t)=>this._renderPage(e,t===o));return le("div",{class:i,key:"base"},e.flow?le("calcite-flow",{inert:!!this._prompt,key:"flow"},r):r,this._prompt?le(G,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const i={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(i);case"viewing-selection-list":return this._renderSelectionListPage(i);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(i);case"creating-features-upload-details":return this._renderUploadDetails(i);case"creating-features":return this._renderCreatingFeatures(i);case"editing-existing-feature":case"editing-features":case"editing-attributes":return this._renderUpdateFeature(i);case"awaiting-update-feature-candidate":return this._renderFeatureList(i);case"adding-attachment":return this._renderAttachmentAdding(i);case"editing-attachment":return this._renderAttachmentEditing(i);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(i);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(i);case"add-association-create-association":return this._renderAddAssociation(i);case"drawing-splitter-geometry":return this._renderDrawingSplitGeometry(i);case"reviewing-features":return this._renderReviewingSplitFeatures(i)}return le("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:i}=this;return le(t,{heading:i.selectTemplate,key:"templates-panel",...e},le(x,{key:"feature-templates"},le(B,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:i,messages:s}=this;if("create-features"!==i?.type)return null;const o=i.data.upload;return o?le(t,{heading:s.createFeatures,key:"upload-details-panel",...e},le(Z,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:i,messages:s,messagesCommon:o,headingLevel:r,viewModel:a}=this;if(!i)return null;const n="create-features"===i.type&&i.numPendingFeatures>0||"update"===i.type&&"create-features"===i?.activeWorkflow?.type&&i.activeWorkflow?.numPendingFeatures>0;return le(t,{heading:s.createFeatures,key:"create-features-panel",...e},n?le(q,{editorViewModel:a,headingLevel:r,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave,onSplit:this._onSplit}):le(E,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.activeFeatureCount>1?i.multiFeature.editPanelTitle:i.singleFeature.editPanelTitle;return le(t,{heading:a,key:"update-feature-panel",...e},le(q,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave,onSplit:this._onSplit}))}_renderDrawingSplitGeometry(e){const{EditorPanel:t}=this;return le(t,{heading:this.messages.splitFeature,key:"draw-split-geometry-panel",...e},le(E,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderReviewingSplitFeatures(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this;return le(t,{heading:i.splitFeature,key:"review-split-features-panel",...e},le(q,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:()=>{},onDeleteAssociation:()=>{},onSave:this._onSave,onSplit:this._onSplit}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;if(e.title)return e.title;const{messagesFeature:i}=this;switch(e.type){case"attachment":return i.associationsAttachments;case"connectivity":return i.associationsConnectivity;case"structure":return i.associationsStructure;case"content":return i.associationsContents;case"container":return i.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;const i=t.associations;switch(e.type){case"attachment":return i.addAttachment;case"connectivity":return i.addConnectivity;case"structure":return i.addStructure;case"content":return i.addContent;case"container":return i.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a);return le(t,{heading:n,key:"viewing-associated-layers-panel",...e},le(q,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave,onSplit:this._onSplit}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this,r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state||this.viewModel.featureFormDisabled;return t?le(i,{heading:a,key:"add-association-select-feature",...e},le(x,{key:"select-feature"},le(B,null,t.render())),le(j,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&(r?.reset(),s.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):le(i,{heading:a,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),i=e.utilityNetworkAssociationAddAssociationViewModel,s="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=s?s.activeWorkflow:null,r="add-association"===o?.type?o.sourceFeatureItem:null,a=i?.selectedFeature,n=i?.association,l=i?.utilityNetwork;r&&a&&n&&l&&(t.sourceFeature=r,t.targetFeature=a,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this;if(!t)return null;const r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state;return le(i,{heading:a,key:"add-association",...e},le(x,{key:"add-association-content"},le(B,null,t.render())),le(j,{buttons:[{label:o.add,disabled:n||!r.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:i}=this,s=r(e.group.items,e=>i.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0);return s?le(V,{kind:"warning",message:s}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:i,messages:s,messagesCommon:o}=this;return le(t,{heading:s.addAttachment,key:"attachment-adding-panel",...e},le(x,{key:"attachments"},this._renderAttachments()),le(j,{buttons:[{label:i.submitting?o.cancel:o.add,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_hasSelectionFromMultipleLayers:t,_hasInvalidBatchSelection:i,_selectionCountExceedsMaximum:s,_selectionList:o,_visibleSelectionCount:r,messages:a,EditorPanel:n}=this,{batchUpdateActions:l}=this.visibleElements,{maxVisibleFeatureCountPerLayer:c}=o;return le(n,{heading:a.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?le("div",{class:k.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,le(x,{key:"selection-list"},le(B,null,this._renderSelectionList())),le(j,{buttons:[l?{label:he(a.batchEditing.editCount,{count:r}),disabled:i,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:l&&t?{text:a.batchEditing.selectOneLayer,icon:"information"}:l&&s?{text:he(this.messages.multiFeature.formFailedToLoadTooManyFeatures,{num:c}),icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:i,activeWorkflow:s,messages:o,messagesCommon:r}=this;return s?le(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},le(x,{key:"attachments"},this._renderAttachments()),s.shouldAllowAttachmentEditing?le(j,{buttons:[{label:r.update,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:i.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:i,viewModel:s,visibleElements:o}=this,r=this._helpMessage;return le(t,{heading:i.widgetLabel,key:"landing-panel",...e},le(x,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?le(B,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?le(B,{key:"create-actions"},this._renderCreateActions()):null]:le(O,{key:"no-content"},i.noEditableLayers)),r?le("div",{class:k.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:i}=this,s=e?.helpMessage;return s?t["3d"===i?.type?"helpMessages3d":"helpMessages2d"]?.[s]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:i}=this,s={id:"select",label:t.select};return le("div",{class:k.updateActions,key:"update-actions"},le(te,{level:ee(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?le("div",{class:k.selectionToolbarContainer},this._renderSelectionToolbar()):le("calcite-list",{class:k.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},ie({disabled:!i.canUpdateVisible,grouped:!1,item:s,selectedItem:"awaiting-feature-to-update"===i.activeWorkflow?.stepId?s:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return le("div",{key:"create-actions"},le(te,{level:ee(this.headingLevel)},this.messages.createFeatures),le("div",{class:k.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:i}=this,{activeWorkflow:s}=i;if("update"!==s?.type)return null;const o=s.data.candidates,r=he(this.messages.multipleFeaturesTemplate,{total:o.length});return le(t,{heading:r,key:"feature-list",...e},le(P,{editorItems:i.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:s,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>i.selectFeature(e,t),onZoomTo:e=>i.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:i,noLabel:s}){const o=a(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:i,action:()=>o.resolve(!0)},secondary:{label:s,action:()=>o.resolve(!1)}}}),o.promise.finally(()=>{this._clearPrompt(),n&&r?.focus()})}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e){await this.viewModel.onSelectionListMenuItemSelect(e)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=s(this._sketchToolbar),void this.removeHandles(me);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new Q({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new $({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new J({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([n(()=>{const e=this.viewModel.activeLeafWorkflow;return e&&"availableCreateTools"in e?e.availableCreateTools:null},e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)},d),n(()=>this.visibleElements.undoRedoButtons,e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)},d),c(()=>this.viewModel?.sketchViewModel,e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)},d)],me)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([h()],pe.prototype,"_batchAttributeForm",void 0),e([h()],pe.prototype,"_featureForm",void 0),e([h()],pe.prototype,"_sketchToolbar",void 0),e([h()],pe.prototype,"_attachments",void 0),e([h()],pe.prototype,"_associationItemList",void 0),e([h()],pe.prototype,"_associationSettings",void 0),e([h()],pe.prototype,"_featureTemplates",void 0),e([h()],pe.prototype,"_filterText",void 0),e([h()],pe.prototype,"_hasInvalidBatchSelection",null),e([h()],pe.prototype,"_hasSelectionFromMultipleLayers",null),e([h()],pe.prototype,"_prompt",void 0),e([h()],pe.prototype,"_spinner",void 0),e([h()],pe.prototype,"_deleteButtonCommonInfo",null),e([h()],pe.prototype,"_loading",void 0),e([h()],pe.prototype,"_selectionCountExceedsMaximum",null),e([h()],pe.prototype,"_selectionList",void 0),e([h()],pe.prototype,"_selectionListItemActionConfigs",null),e([h()],pe.prototype,"_selectionToolbar",void 0),e([h()],pe.prototype,"_visibleSelectionCount",null),e([h({readOnly:!0})],pe.prototype,"activeWorkflow",null),e([h()],pe.prototype,"effectiveSelectionManager",null),e([h()],pe.prototype,"headingLevel",void 0),e([h()],pe.prototype,"hideTemplatesForInactiveLayers",null),e([h()],pe.prototype,"icon",null),e([h()],pe.prototype,"label",null),e([h()],pe.prototype,"labelOptions",null),e([h()],pe.prototype,"layerInfos",null),e([h(),ae("esri/widgets/Editor/t9n/Editor")],pe.prototype,"messages",void 0),e([h(),ae("esri/t9n/common")],pe.prototype,"messagesCommon",void 0),e([h(),ae("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],pe.prototype,"messagesTemplates",void 0),e([h(),ae("esri/widgets/Feature/t9n/Feature")],pe.prototype,"messagesFeature",void 0),e([h()],pe.prototype,"snappingOptions",null),e([h()],pe.prototype,"tooltipOptions",null),e([h()],pe.prototype,"supportingWidgetDefaults",void 0),e([h({type:u,nonNullable:!0})],pe.prototype,"valueOptions",null),e([h()],pe.prototype,"view",null),e([h(),ne(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],pe.prototype,"viewModel",void 0),e([h({type:M,nonNullable:!0})],pe.prototype,"visibleElements",void 0),e([h()],pe.prototype,"_helpMessage",null),pe=e([m("esri.widgets.Editor")],pe);const ue=pe;export{ue as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../intl.js";import{deprecatedFunction as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{destroyMaybe as s,abortMaybe as o,mappedFind as r}from"../core/maybe.js";import{createResolver as a}from"../core/promiseUtils.js";import{watch as n,on as l,when as c,initial as d}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../core/support/UpdatingHandles.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import g from"./Attachments.js";import _ from"./BatchAttributeForm.js";import w from"./FeatureForm.js";import v from"./FeatureTemplates.js";import f from"./Spinner.js";import y from"./Widget.js";import{VisibleElements as b}from"./BatchAttributeForm/VisibleElements.js";import{css as k}from"./Editor/css.js";import F from"./Editor/EditorViewModel.js";import{isModelUpload as A}from"./Editor/modelUploadUtils.js";import M from"./Editor/VisibleElements.js";import{isFeatureFormViewModel as S,isUpdateWorkflow as T,isUpdateRecordWorkflow as C,isBatchAttributeFormViewModel as L}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as E,CreateFeaturesPanelContent as W}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as P,FeatureList as I}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as j,FooterActions as U}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as V,Notice as D}from"./Editor/components/Notices.js";import{loadPanelContentComponents as x,PanelContent as B,PanelContentSection as O,PanelContentMessage as N}from"./Editor/components/PanelContent.js";import{PanelToolbar as H,loadPanelToolbarComponents as R}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as G,Prompt as z}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as q,UpdateFeaturePanelContent as K}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as Z,UploadDetails as $}from"./Editor/components/UploadDetails.js";import{CreateToolVisibilityMap as J}from"./Sketch/CreateToolVisibilityMap.js";import{SelectionToolVisibilityMap as Q}from"./Sketch/SelectionToolVisibilityMap.js";import{VisibleElements as X}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as Y}from"./support/componentsUtils.js";import{globalCss as ee}from"./support/globalCss.js";import{incrementHeadingLevel as te,Heading as ie}from"./support/Heading.js";import{renderItem as se}from"./support/ItemList.js";import{connectDelayedLoading as oe}from"./support/loaderUtils.js";import re from"./support/SelectionList.js";import ae from"./support/SelectionToolbar.js";import"./support/widgetUtils.js";import{messageBundle as ne}from"./support/decorators/messageBundle.js";import{vmEvent as le}from"./support/decorators/vmEvent.js";import{tsx as ce}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";import de from"./support/SelectionList/VisibleElements.js";import he from"./support/SelectionToolbar/VisibleElements.js";import{substitute as me}from"../intl/substitute.js";const pe=Symbol("sketch-setup-handles");let ue=class extends y{constructor(e,t){super(e,t),this._batchAttributeForm=new _({visibleElements:new b({loadingIndicator:!1})}),this._featureForm=new w,this._sketchToolbar=null,this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new v({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?ce("calcite-icon",{class:k.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new f,this._loading=!1,this._selectionList=new re({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new de({header:!1})}),this._selectionToolbar=new ae({visibleElements:new he({chip:!1})}),this._updatingHandles=new p,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new F,this.visibleElements=new M,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?ce("div",{class:k.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>ce("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:i},...s)=>{const{visibleElements:o}=this;return ce("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:i,onCalciteFlowItemBack:this._onBack},o.settingsMenu?ce(H,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...s)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,i={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&A(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&S(t.activeFormViewModel)&&t.activeFormViewModel.activeAssociation?this._showPromptAndWait({...i,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(i)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onSplit=()=>{const{activeWorkflow:e}=this.viewModel;if(T(e)){const t=e.activeWorkflow;if(C(t)){const i=t.data.edits.feature;i&&e.startSplittingFeature(i)}}},this._onDelete=()=>{const e=this.viewModel.activeFeatureCount,t=e>1?this.messages.multiFeature:this.messages.singleFeature;this._showPrompt({title:t.deleteWarningTitle,message:t.deleteWarningMessage,context:"danger",actions:{primary:{label:me(t.delete,{count:e}),action:()=>{this.deleteFeatures(),this._clearPrompt()}},secondary:{label:t.keep,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then(()=>e.back()))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then(()=>e.back()))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([n(()=>te(this.headingLevel),e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e},d),l(()=>this.viewModel.activeWorkflow,"cancel-request",({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then(t=>t?e.allow():e.deny())}),c(()=>this.viewModel.formViewModel,e=>{L(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e},d),c(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel,e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))},d),c(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association,()=>{this._setUpAssociationSettings()}),n(()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel],([e,t,i,s,o,r])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=i,this._spinner.viewModel=s,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=r,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt},d),n(()=>this.view,(e,t)=>{const i=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,i),e?.ui.add(this._spinner,{key:i,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)},d),n(()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel],([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))},d),c(()=>this._attachments?.error,e=>this._onAttachmentsError(e)),c(()=>this._selectionListItemActionConfigs,()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs}),c(()=>this.viewModel?.failures,e=>{const{messages:t}=this,[{error:i,retry:s,cancel:o}]=e;this._showPrompt({title:t.errorWarningTitle,message:me(t.errorWarningMessageTemplate,{errorMessage:i.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{s(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{o(),this._clearPrompt()}}}})}),n(()=>this.viewModel?.state,e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}}),n(()=>this.viewModel.featureFormDisabled,e=>this._featureForm.disabled=e),n(()=>this.visibleElements.sketch,()=>this._setupSketch(),d),oe({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=s(this._sketchToolbar),this._sketchImportAbortController=o(this._sketchImportAbortController)}loadDependencies(){return Promise.all([Y({flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),E(),P(),j(),V(),x(),R(),G(),q(),Z()])}get _hasInvalidBatchSelection(){return this._hasSelectionFromMultipleLayers||this._selectionCountExceedsMaximum||0===this._selectionList.visibleFeatureCount}get _hasSelectionFromMultipleLayers(){return this._selectionList.visibleLayerCount>1}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionCountExceedsMaximum(){const e=this._batchAttributeForm.maximumFeatureCount,{activeLayerItem:t,effectiveCount:i,filterText:s,visibleFeatureCount:o}=this._selectionList;return null!=s&&""!==s?o>e:t?t.total>e:i>e}get _selectionListItemActionConfigs(){const{messages:e}=this;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)},{label:e?.batchEditing?.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e)}]}get _visibleSelectionCount(){const{activeLayerItem:e,effectiveCount:t,filterText:i,visibleFeatureCount:s}=this._selectionList;return null!=i&&""!==i?s:e?e.total:t}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}async startSplitFeatureWorkflow(e,t={}){await this.viewModel.startSplitFeatureWorkflow(e,t)}startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}async startUpdateWorkflowWithActiveSelection(){await this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return t(i.getLogger(this),"Editor.deleteFeatureFromWorkflow is deprecated. Use Editor.deleteFeatures instead.",{version:"4.33",replacement:"Editor.deleteFeatures",warnOnce:!0}),this.deleteFeatures()}async deleteFeatures(){await this.viewModel.deleteFeatures()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,i=this.classes(k.base,ee.widget,ee.panel);if(!t)return ce("div",{class:i,key:"empty"});const{pageStack:s}=t,o=s.length-1,r=s.map((e,t)=>this._renderPage(e,t===o));return ce("div",{class:i,key:"base"},e.flow?ce("calcite-flow",{inert:!!this._prompt,key:"flow"},r):r,this._prompt?ce(z,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const i={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(i);case"viewing-selection-list":return this._renderSelectionListPage(i);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(i);case"creating-features-upload-details":return this._renderUploadDetails(i);case"creating-features":return this._renderCreatingFeatures(i);case"editing-existing-feature":case"editing-features":case"editing-attributes":return this._renderUpdateFeature(i);case"awaiting-update-feature-candidate":return this._renderFeatureList(i);case"adding-attachment":return this._renderAttachmentAdding(i);case"editing-attachment":return this._renderAttachmentEditing(i);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(i);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(i);case"add-association-create-association":return this._renderAddAssociation(i);case"drawing-splitter-geometry":return this._renderDrawingSplitGeometry(i);case"reviewing-features":return this._renderReviewingSplitFeatures(i)}return ce("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:i}=this;return ce(t,{heading:i.selectTemplate,key:"templates-panel",...e},ce(B,{key:"feature-templates"},ce(O,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:i,messages:s}=this;if("create-features"!==i?.type)return null;const o=i.data.upload;return o?ce(t,{heading:s.createFeatures,key:"upload-details-panel",...e},ce($,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:i,messages:s,messagesCommon:o,headingLevel:r,viewModel:a}=this;if(!i)return null;const n="create-features"===i.type&&i.numPendingFeatures>0||"update"===i.type&&"create-features"===i?.activeWorkflow?.type&&i.activeWorkflow?.numPendingFeatures>0;return ce(t,{heading:s.createFeatures,key:"create-features-panel",...e},n?ce(K,{editorViewModel:a,headingLevel:r,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave,onSplit:this._onSplit}):ce(W,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.activeFeatureCount>1?i.multiFeature.editPanelTitle:i.singleFeature.editPanelTitle;return ce(t,{heading:a,key:"update-feature-panel",...e},ce(K,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave,onSplit:this._onSplit}))}_renderDrawingSplitGeometry(e){const{EditorPanel:t}=this;return ce(t,{heading:this.messages.splitFeature,key:"draw-split-geometry-panel",...e},ce(W,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderReviewingSplitFeatures(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this;return ce(t,{heading:i.splitFeature,key:"review-split-features-panel",...e},ce(K,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:()=>{},onDeleteAssociation:()=>{},onSave:this._onSave,onSplit:this._onSplit}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;if(e.title)return e.title;const{messagesFeature:i}=this;switch(e.type){case"attachment":return i.associationsAttachments;case"connectivity":return i.associationsConnectivity;case"structure":return i.associationsStructure;case"content":return i.associationsContents;case"container":return i.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;const i=t.associations;switch(e.type){case"attachment":return i.addAttachment;case"connectivity":return i.addConnectivity;case"structure":return i.addStructure;case"content":return i.addContent;case"container":return i.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a);return ce(t,{heading:n,key:"viewing-associated-layers-panel",...e},ce(K,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave,onSplit:this._onSplit}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this,r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state||this.viewModel.featureFormDisabled;return t?ce(i,{heading:a,key:"add-association-select-feature",...e},ce(B,{key:"select-feature"},ce(O,null,t.render())),ce(U,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&(r?.reset(),s.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):ce(i,{heading:a,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),i=e.utilityNetworkAssociationAddAssociationViewModel,s="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=s?s.activeWorkflow:null,r="add-association"===o?.type?o.sourceFeatureItem:null,a=i?.selectedFeature,n=i?.association,l=i?.utilityNetwork;r&&a&&n&&l&&(t.sourceFeature=r,t.targetFeature=a,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this;if(!t)return null;const r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state;return ce(i,{heading:a,key:"add-association",...e},ce(B,{key:"add-association-content"},ce(O,null,t.render())),ce(U,{buttons:[{label:o.add,disabled:n||!r.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:i}=this,s=r(e.group.items,e=>i.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0);return s?ce(D,{kind:"warning",message:s}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:i,messages:s,messagesCommon:o}=this;return ce(t,{heading:s.addAttachment,key:"attachment-adding-panel",...e},ce(B,{key:"attachments"},this._renderAttachments()),ce(U,{buttons:[{label:i.submitting?o.cancel:o.add,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_hasSelectionFromMultipleLayers:t,_hasInvalidBatchSelection:i,_selectionCountExceedsMaximum:s,_selectionList:o,_visibleSelectionCount:r,messages:a,EditorPanel:n}=this,{batchUpdateActions:l}=this.visibleElements,{maxVisibleFeatureCountPerLayer:c}=o;return ce(n,{heading:a.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?ce("div",{class:k.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,ce(B,{key:"selection-list"},ce(O,null,this._renderSelectionList())),ce(U,{buttons:[l?{label:me(a.batchEditing.editCount,{count:r}),disabled:i,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:l&&t?{text:a.batchEditing.selectOneLayer,icon:"information"}:l&&s?{text:me(this.messages.multiFeature.formFailedToLoadTooManyFeatures,{num:c}),icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:i,activeWorkflow:s,messages:o,messagesCommon:r}=this;return s?ce(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},ce(B,{key:"attachments"},this._renderAttachments()),s.shouldAllowAttachmentEditing?ce(U,{buttons:[{label:r.update,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:i.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:i,viewModel:s,visibleElements:o}=this,r=this._helpMessage;return ce(t,{heading:i.widgetLabel,key:"landing-panel",...e},ce(B,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?ce(O,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?ce(O,{key:"create-actions"},this._renderCreateActions()):null]:ce(N,{key:"no-content"},i.noEditableLayers)),r?ce("div",{class:k.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:i}=this,s=e?.helpMessage;return s?t["3d"===i?.type?"helpMessages3d":"helpMessages2d"]?.[s]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:i}=this,s={id:"select",label:t.select};return ce("div",{class:k.updateActions,key:"update-actions"},ce(ie,{level:te(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?ce("div",{class:k.selectionToolbarContainer},this._renderSelectionToolbar()):ce("calcite-list",{class:k.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},se({disabled:!i.canUpdateVisible,grouped:!1,item:s,selectedItem:"awaiting-feature-to-update"===i.activeWorkflow?.stepId?s:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return ce("div",{key:"create-actions"},ce(ie,{level:te(this.headingLevel)},this.messages.createFeatures),ce("div",{class:k.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:i}=this,{activeWorkflow:s}=i;if("update"!==s?.type)return null;const o=s.data.candidates,r=me(this.messages.multipleFeaturesTemplate,{total:o.length});return ce(t,{heading:r,key:"feature-list",...e},ce(I,{editorItems:i.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:s,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>i.selectFeature(e,t),onZoomTo:e=>i.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:i,noLabel:s}){const o=a(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:i,action:()=>o.resolve(!0)},secondary:{label:s,action:()=>o.resolve(!1)}}}),o.promise.finally(()=>{this._clearPrompt(),n&&r?.focus()})}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e){await this.viewModel.onSelectionListMenuItemSelect(e)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=s(this._sketchToolbar),void this.removeHandles(pe);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new X({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new J({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new Q({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([n(()=>{const e=this.viewModel.activeLeafWorkflow;return e&&"availableCreateTools"in e?e.availableCreateTools:null},e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)},d),n(()=>this.visibleElements.undoRedoButtons,e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)},d),c(()=>this.viewModel?.sketchViewModel,e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)},d)],pe)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([h()],ue.prototype,"_batchAttributeForm",void 0),e([h()],ue.prototype,"_featureForm",void 0),e([h()],ue.prototype,"_sketchToolbar",void 0),e([h()],ue.prototype,"_attachments",void 0),e([h()],ue.prototype,"_associationItemList",void 0),e([h()],ue.prototype,"_associationSettings",void 0),e([h()],ue.prototype,"_featureTemplates",void 0),e([h()],ue.prototype,"_filterText",void 0),e([h()],ue.prototype,"_hasInvalidBatchSelection",null),e([h()],ue.prototype,"_hasSelectionFromMultipleLayers",null),e([h()],ue.prototype,"_prompt",void 0),e([h()],ue.prototype,"_spinner",void 0),e([h()],ue.prototype,"_deleteButtonCommonInfo",null),e([h()],ue.prototype,"_loading",void 0),e([h()],ue.prototype,"_selectionCountExceedsMaximum",null),e([h()],ue.prototype,"_selectionList",void 0),e([h()],ue.prototype,"_selectionListItemActionConfigs",null),e([h()],ue.prototype,"_selectionToolbar",void 0),e([h()],ue.prototype,"_visibleSelectionCount",null),e([h({readOnly:!0})],ue.prototype,"activeWorkflow",null),e([h()],ue.prototype,"effectiveSelectionManager",null),e([h()],ue.prototype,"headingLevel",void 0),e([h()],ue.prototype,"hideTemplatesForInactiveLayers",null),e([h()],ue.prototype,"icon",null),e([h()],ue.prototype,"label",null),e([h()],ue.prototype,"labelOptions",null),e([h()],ue.prototype,"layerInfos",null),e([h(),ne("esri/widgets/Editor/t9n/Editor")],ue.prototype,"messages",void 0),e([h(),ne("esri/t9n/common")],ue.prototype,"messagesCommon",void 0),e([h(),ne("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],ue.prototype,"messagesTemplates",void 0),e([h(),ne("esri/widgets/Feature/t9n/Feature")],ue.prototype,"messagesFeature",void 0),e([h()],ue.prototype,"snappingOptions",null),e([h()],ue.prototype,"tooltipOptions",null),e([h()],ue.prototype,"supportingWidgetDefaults",void 0),e([h({type:u,nonNullable:!0})],ue.prototype,"valueOptions",null),e([h()],ue.prototype,"view",null),e([h(),le(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],ue.prototype,"viewModel",void 0),e([h({type:M,nonNullable:!0})],ue.prototype,"visibleElements",void 0),e([h()],ue.prototype,"_helpMessage",null),ue=e([m("esri.widgets.Editor")],ue);const ge=ue;export{ge 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../intl.js";import i from"../../core/Accessor.js";import r from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=r.ofType(d),f=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CatalogLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.ParquetLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.catalog.CatalogFootprintLayer","esri.layers.catalog.CatalogDynamicGroupLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer","esri.layers.KnowledgeGraphLayer"]),u="view.basemapView.baseLayerViews",p="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",w=[u,p,"view.layerViews",v];let _=class extends i{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this._activeLayerInfosPromises=new WeakMap,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t(()=>this.view,()=>this._viewHandles(),s),c.view),this.addHandles(h(()=>this._refresh()))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get loading(){return this.activeLayerInfos.some(e=>e.loading)}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t(()=>this.state,()=>this._stateHandles(),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const i=this._activeLayerInfosByLayerViewId[e];i&&this._activeLayerInfosPromises.delete(i),delete this._activeLayerInfosByLayerViewId[e],i?.parent?.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:i}=e;i.length&&this._refresh(),this.addHandles(i.on("change",e=>this._allLayerViewsChangeHandle(e)),c.allLayerViews),this.addHandles(t(()=>[this.basemapLegendVisible,this.groundLegendVisible,this.hideLayersNotInCurrentView,this.keepCacheOnDestroy,this.layerInfos,this.respectLayerDefinitionExpression,this.respectLayerVisibility],()=>this._refresh()),c.legendProperties)}_allLayerViewsChangeHandle(e){if(e.added.length&&this._generateActiveLayerInfosForLayerViews(e.added),e.moved.length)return this._destroyViewActiveLayerInfos(),void this._refresh();if(e.removed.length){for(const{uid:i}of e.removed)this._destroyViewActiveLayerInfo(i);this._refresh()}}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.drain(e=>this._activeLayerInfosPromises.delete(e)),this._generateActiveLayerInfosForLayerViews(this._generateLayerViews())}_generateActiveLayerInfosForLayerViews(e){e.filter(this._filterBasemapLayerViews,this).filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this)}_filterBasemapLayerViews(e){if(!this.view?.basemapView)return!0;const{baseLayerViews:i,groundLayerViews:r,referenceLayerViews:t}=this.view.basemapView,s=!this.basemapLegendVisible&&(i?.includes(e)||t?.includes(e)),a=!this.groundLegendVisible&&r?.includes(e);return!s&&!a}_sortActiveLayerInfos(e){const i=this.view;if(e.length<2||!i)return;const r=[];e.forEach(i=>{if(!i.parent){const t=i.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(r.push(i),i.parent=a,a.children.add(i),this._sortActiveLayerInfos(a.children))}}),e.removeMany(r);const t={};i.allLayerViews.forEach((e,i)=>t[e.layer.uid]=i),e.sort((e,i)=>{const r=t[e.layer.uid]||0;return(t[i.layer.uid]||0)-r})}_generateLayerViews(){const e=[];return w.filter(this._filterLayerViews,this).map(e=>l(this,e)).filter(e=>null!=e).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===u||e===v),r=!this.groundLegendVisible&&e===p;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach(t=>{i.push(t),r(t[e])}),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some(i=>this._hasLayerInfo(i,e))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some(e=>this._isLayerUIDMatching(e,i))}_isLayerViewSupported(e){return!!f.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t(()=>[e.legendEnabled,e.layer?.legendEnabled],()=>this._layerActiveHandle(e)),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}async _buildActiveLayerInfo(e){const i=e.layer,r=e.uid,t=this._layerInfosByLayerViewId[r];let s=this._activeLayerInfosByLayerViewId[r];s||(s=new d({layer:i,layerView:e,view:this.view??void 0}),this._activeLayerInfosByLayerViewId[r]=s);const a=void 0!==t?.title&&t.layer.uid===i.uid;s.title=a?t.title:i.title,s.respectLayerDefinitionExpression=this.respectLayerDefinitionExpression,s.respectLayerVisibility=this.respectLayerVisibility,s.hideLayersNotInCurrentView=this.hideLayersNotInCurrentView,s.keepCacheOnDestroy=this.keepCacheOnDestroy,s.sublayerIds=t?.sublayerIds||[];const n=i.parent&&"uid"in i.parent?this._layerViewByLayerId[i.parent?.uid]:null;s.parent=this._activeLayerInfosByLayerViewId[n?.uid],this._addActiveLayerInfo(s),this._constructLegendElements(s),this._attachHandlesToActiveLayerInfo(s)}_attachHandlesToActiveLayerInfo(e){const{layer:i,layerView:r}=e,n=r.uid;this.removeHandles(n),this.addHandles([t(()=>i.title,i=>this._titleHandle(i,e)),t(()=>[i.opacity,"renderer"in i&&i.renderer,"pointSymbol"in i&&i.pointSymbol,"lineSymbol"in i&&i.lineSymbol,"polygonSymbol"in i&&i.polygonSymbol,"effect"in i&&i.effect,"featureReduction"in i&&y(i,r.view)],()=>this._constructLegendElements(e)),a(()=>!!this.view?.stationary,()=>this._scaleHandle(e)),a(()=>this.view?.timeZone,()=>this._constructLegendElements(e)),t(()=>e.loading,()=>this.notifyChange("loading"),s)],n),this.respectLayerVisibility&&this.addHandles([t(()=>i.legendEnabled,i=>this._legendEnabledHandle(i,e)),t(()=>r.legendEnabled,i=>{this.view?.suspended||this._legendEnabledHandle(i,e)})],n),this.respectLayerDefinitionExpression&&"definitionExpression"in i&&this.addHandles(t(()=>i.definitionExpression,()=>this._constructLegendElements(e)),n)}_titleHandle(e,i){i.title=e,this._constructLegendElements(i)}_legendEnabledHandle(e,i){e?this._addActiveLayerInfo(i):this._removeActiveLayerInfo(i)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:i,layer:r}=e;if(this._isLayerActive(i)&&!this.activeLayerInfos.includes(e)){const i=e.parent;if(i)i.children.includes(e)||i.children.push(e),this._sortActiveLayerInfos(i.children);else{const i=this.layerInfos?.some(e=>e.layer.uid===r.uid),t=r.parent;(t&&"uid"in t?this._layerViewByLayerId[t.uid]:null)&&!i?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach(i=>{const r=i.layer.parent,t=r&&"uid"in r?this._layerViewByLayerId[r?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(i),i.parent=s)}),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach(e=>this._addActiveLayerInfo(e)))}}}_removeActiveLayerInfo(e){const i=e.parent;i?i.children.remove(e):this.activeLayerInfos.remove(e)}async _getBuildLegendPromise(e){const{layer:i}=e;if("featureCollections"in i&&i.featureCollections)return e.buildLegendElementsForFeatureCollections(i.featureCollections);if("featureReduction"in i&&i.featureReduction&&"renderer"in i.featureReduction&&("binning"===i.featureReduction.type||"cluster"===i.featureReduction.type)&&(!this.view||i.featureReduction.maxScale<=this.view.scale))return e.buildLegendElementsForFeatureReduction(i.featureReduction);if("renderer"in i&&i.renderer&&!("sublayers"in i))return e.buildLegendElementsForRenderer(i.renderer);if("url"in i&&i.url&&"catalog"!==i.type&&"knowledge-graph"!==i.type)return e.buildLegendElementsForTools();const r=e.children.map(e=>this._constructLegendElements(e));return Promise.all(r).then(()=>{})}async _constructLegendElements(e){const i=this._activeLayerInfosPromises.get(e);i&&await i.catch(()=>{});const r=this._getBuildLegendPromise(e);this._activeLayerInfosPromises.set(e,r),r.finally(()=>{this._activeLayerInfosPromises.delete(e)})}};e([n({type:L})],_.prototype,"activeLayerInfos",void 0),e([n()],_.prototype,"basemapLegendVisible",void 0),e([n()],_.prototype,"groundLegendVisible",void 0),e([n()],_.prototype,"hideLayersNotInCurrentView",void 0),e([n()],_.prototype,"keepCacheOnDestroy",void 0),e([n({readOnly:!0})],_.prototype,"loading",null),e([n()],_.prototype,"respectLayerDefinitionExpression",void 0),e([n()],_.prototype,"respectLayerVisibility",void 0),e([n()],_.prototype,"layerInfos",void 0),e([n({readOnly:!0})],_.prototype,"state",null),e([n()],_.prototype,"view",void 0),_=e([o("esri.widgets.Legend.LegendViewModel")],_);export{_ as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../intl.js";import i from"../../core/Accessor.js";import r from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=r.ofType(d),f=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CatalogLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.ParquetLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.catalog.CatalogFootprintLayer","esri.layers.catalog.CatalogDynamicGroupLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer","esri.layers.KnowledgeGraphLayer"]),u="view.basemapView.baseLayerViews",p="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",w=[u,p,"view.layerViews",v];let _=class extends i{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this._activeLayerInfosPromises=new WeakMap,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t(()=>this.view,()=>this._viewHandles(),s),c.view),this.addHandles(h(()=>this._refresh()))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get loading(){return this.activeLayerInfos.some(e=>e.loading)}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t(()=>this.state,()=>this._stateHandles(),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const i=this._activeLayerInfosByLayerViewId[e];i&&this._activeLayerInfosPromises.delete(i),delete this._activeLayerInfosByLayerViewId[e],i?.parent?.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:i}=e;i.length&&this._refresh(),this.addHandles(i.on("change",e=>this._allLayerViewsChangeHandle(e)),c.allLayerViews),this.addHandles(t(()=>[this.basemapLegendVisible,this.groundLegendVisible,this.hideLayersNotInCurrentView,this.keepCacheOnDestroy,this.layerInfos,this.respectLayerDefinitionExpression,this.respectLayerVisibility],()=>this._refresh()),c.legendProperties)}_allLayerViewsChangeHandle(e){if(e.added.length&&this._generateActiveLayerInfosForLayerViews(e.added),e.moved.length)return this._destroyViewActiveLayerInfos(),void this._refresh();if(e.removed.length){for(const{uid:i}of e.removed)this._destroyViewActiveLayerInfo(i);this._refresh()}}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.drain(e=>this._activeLayerInfosPromises.delete(e)),this._generateActiveLayerInfosForLayerViews(this._generateLayerViews())}_generateActiveLayerInfosForLayerViews(e){e.filter(this._filterBasemapLayerViews,this).filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this)}_filterBasemapLayerViews(e){if(!this.view?.basemapView)return!0;const{baseLayerViews:i,groundLayerViews:r,referenceLayerViews:t}=this.view.basemapView,s=!this.basemapLegendVisible&&(i?.includes(e)||t?.includes(e)),a=!this.groundLegendVisible&&r?.includes(e);return!s&&!a}_sortActiveLayerInfos(e){const i=this.view;if(e.length<2||!i)return;const r=[];e.forEach(i=>{if(!i.parent){const t=i.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(r.push(i),i.parent=a,a.children.add(i),this._sortActiveLayerInfos(a.children))}}),e.removeMany(r);const t={};i.allLayerViews.forEach((e,i)=>t[e.layer.uid]=i),e.sort((e,i)=>{const r=t[e.layer.uid]||0;return(t[i.layer.uid]||0)-r})}_generateLayerViews(){const e=[];return w.filter(this._filterLayerViews,this).map(e=>l(this,e)).filter(e=>null!=e).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===u||e===v),r=!this.groundLegendVisible&&e===p;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach(t=>{i.push(t),r(t[e])}),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some(i=>this._hasLayerInfo(i,e))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some(e=>this._isLayerUIDMatching(e,i))}_isLayerViewSupported(e){return!!f.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t(()=>[e.legendEnabled,e.layer?.legendEnabled],()=>this._layerActiveHandle(e)),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}async _buildActiveLayerInfo(e){const i=e.layer,r=e.uid,t=this._layerInfosByLayerViewId[r];let s=this._activeLayerInfosByLayerViewId[r];s||(s=new d({layer:i,layerView:e,view:this.view??void 0}),this._activeLayerInfosByLayerViewId[r]=s);const a=void 0!==t?.title&&t.layer.uid===i.uid;s.title=a?t.title:i.title,s.respectLayerDefinitionExpression=this.respectLayerDefinitionExpression,s.respectLayerVisibility=this.respectLayerVisibility,s.hideLayersNotInCurrentView=this.hideLayersNotInCurrentView,s.keepCacheOnDestroy=this.keepCacheOnDestroy,s.sublayerIds=t?.sublayerIds||[];const n=i.parent&&"uid"in i.parent?this._layerViewByLayerId[i.parent?.uid]:null;s.parent=this._activeLayerInfosByLayerViewId[n?.uid],this._addActiveLayerInfo(s),this._constructLegendElements(s),this._attachHandlesToActiveLayerInfo(s)}_attachHandlesToActiveLayerInfo(e){const{layer:i,layerView:r}=e,n=r.uid;this.removeHandles(n),this.addHandles([t(()=>i.title,i=>this._titleHandle(i,e)),t(()=>[i.opacity,"renderer"in i&&i.renderer,"pointSymbol"in i&&i.pointSymbol,"lineSymbol"in i&&i.lineSymbol,"polygonSymbol"in i&&i.polygonSymbol,"effect"in i&&i.effect,"featureReduction"in i&&y(i,r.view),this.view?.timeZone],()=>this._constructLegendElements(e)),t(()=>"filter"in r&&r.filter,()=>{null!=y(r.layer,r.view)&&this._constructLegendElements(e)}),a(()=>!!this.view?.stationary,()=>this._scaleHandle(e)),t(()=>e.loading,()=>this.notifyChange("loading"),s)],n),this.respectLayerVisibility&&this.addHandles([t(()=>i.legendEnabled,i=>this._legendEnabledHandle(i,e)),t(()=>r.legendEnabled,i=>{this.view?.suspended||this._legendEnabledHandle(i,e)})],n),this.respectLayerDefinitionExpression&&"definitionExpression"in i&&this.addHandles(t(()=>i.definitionExpression,()=>this._constructLegendElements(e)),n)}_titleHandle(e,i){i.title=e,this._constructLegendElements(i)}_legendEnabledHandle(e,i){e?this._addActiveLayerInfo(i):this._removeActiveLayerInfo(i)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:i,layer:r}=e;if(this._isLayerActive(i)&&!this.activeLayerInfos.includes(e)){const i=e.parent;if(i)i.children.includes(e)||i.children.push(e),this._sortActiveLayerInfos(i.children);else{const i=this.layerInfos?.some(e=>e.layer.uid===r.uid),t=r.parent;(t&&"uid"in t?this._layerViewByLayerId[t.uid]:null)&&!i?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach(i=>{const r=i.layer.parent,t=r&&"uid"in r?this._layerViewByLayerId[r?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(i),i.parent=s)}),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach(e=>this._addActiveLayerInfo(e)))}}}_removeActiveLayerInfo(e){const i=e.parent;i?i.children.remove(e):this.activeLayerInfos.remove(e)}async _getBuildLegendPromise(e){const{layer:i}=e;if("featureCollections"in i&&i.featureCollections)return e.buildLegendElementsForFeatureCollections(i.featureCollections);if("featureReduction"in i&&i.featureReduction&&"renderer"in i.featureReduction&&("binning"===i.featureReduction.type||"cluster"===i.featureReduction.type)&&(!this.view||i.featureReduction.maxScale<=this.view.scale))return e.buildLegendElementsForFeatureReduction(i.featureReduction);if("renderer"in i&&i.renderer&&!("sublayers"in i))return e.buildLegendElementsForRenderer(i.renderer);if("url"in i&&i.url&&"catalog"!==i.type&&"knowledge-graph"!==i.type)return e.buildLegendElementsForTools();const r=e.children.map(e=>this._constructLegendElements(e));return Promise.all(r).then(()=>{})}async _constructLegendElements(e){const i=this._activeLayerInfosPromises.get(e);i&&await i.catch(()=>{});const r=this._getBuildLegendPromise(e);this._activeLayerInfosPromises.set(e,r),r.finally(()=>{this._activeLayerInfosPromises.delete(e)})}};e([n({type:L})],_.prototype,"activeLayerInfos",void 0),e([n()],_.prototype,"basemapLegendVisible",void 0),e([n()],_.prototype,"groundLegendVisible",void 0),e([n()],_.prototype,"hideLayersNotInCurrentView",void 0),e([n()],_.prototype,"keepCacheOnDestroy",void 0),e([n({readOnly:!0})],_.prototype,"loading",null),e([n()],_.prototype,"respectLayerDefinitionExpression",void 0),e([n()],_.prototype,"respectLayerVisibility",void 0),e([n()],_.prototype,"layerInfos",void 0),e([n({readOnly:!0})],_.prototype,"state",null),e([n()],_.prototype,"view",void 0),_=e([o("esri.widgets.Legend.LegendViewModel")],_);export{_ 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{addTokenParameter as i}from"../../../kernel.js";import s from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{clamp as u}from"../../../core/mathUtils.js";import{debounce as c,timeout as d}from"../../../core/promiseUtils.js";import{on as y,watch as h,initial as f,whenOnce as m}from"../../../core/reactiveUtils.js";import{px2pt as p}from"../../../core/screenUtils.js";import{parseWhereClause as g}from"../../../core/sql.js";import{addQueryParameters as b}from"../../../core/urlUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{EffectView as w}from"../../../layers/effects/EffectView.js";import{getEffectiveDisplayFilter as v}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{collectFields as E,collectArcadeFieldNames as F}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as C}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as V}from"../../../renderers/support/rendererConversion.js";import D from"../../../renderers/visualVariables/SizeVariable.js";import x from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as z}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import T from"../../../symbols/SimpleFillSymbol.js";import j from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as O}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as k}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as M,renderDotDensityPreviewHTML as P,renderPieChartPreviewHTML as U,renderPreviewHTML as A}from"../../../symbols/support/symbolUtils.js";import{getCSSFilterFromEffectList as B,isVolumetricSymbol as N}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as $}from"./clusterUtils.js";import{getColorFromPointCloudStops as H,getRampStopsForPointCloud as q,getStretchRampStops as W,getRampStops as G}from"./colorRampUtils.js";import{getHeatmapRampStops as J}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as Q,getRelationshipRampElement as Z}from"./relationshipRampUtils.js";import{getRampStops as K,realWorldMaxSize as X,realWorldMinSize as Y}from"./sizeRampUtils.js";import{specialCharsLessThan as ee,specialCharsGreaterThan as te,getAuthoringInfoVisualVariableByTheme as ie,getSymbolForFlowRenderer as se,mergeWhereClauses as le,getMedianColor as re,rgbImgSource as ne,getDateFormatOptions as ae}from"./utils.js";import{formatNumberLabel as oe}from"../../smartMapping/support/utils.js";const ue=16,ce="https://utility.arcgis.com/sharing/tools/legend",de="esri.layers.ImageryLayer",ye="esri.layers.ImageryTileLayer",he="esri.layers.WCSLayer",fe=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,me=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),pe=new j({size:6,outline:{color:[128,128,128,.5],width:.5}}),ge=new T({style:"solid"});function be(e){return"flow"===e.type}function _e(e){return"vector-field"===e.type}function Se(e){return"raster-colormap"===e.type}function we(e){return"raster-stretch"===e.type}function ve(e){return"raster-shaded-relief"===e.type}function Le(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Fe(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Ie(e){return Ve(e)||De(e)||xe(e)||Re(e)}function Re(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function ze(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Te(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function je(e,t){return Le(e)||Ee(e)||Fe(e)||Ce(e)||ze(e)||Te(e)?"2d"===t.type||V(e):we(e)||Se(e)||ve(e)||Ve(e)||De(e)||xe(e)||_e(e)||be(e)}function Oe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function ke(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Me(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Pe(e){return"esri.layers.WMSLayer"===e.declaredClass}function Ue(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ae(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Be(e){return"esri.layers.TileLayer"===e.declaredClass}function Ne(e){return e.declaredClass===de}function $e(e){return e.declaredClass===ye}function He(e){return e.declaredClass===he}function qe(e){return"stretch-ramp"===e.type}function We(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Ge(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Je(e){return"sublayers"in e}function Qe(e){return e&&"symbol"in e}function Ze(e,t){const{field:i,field2:s,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!i)return null;const a=!(!i&&!n||!s&&!l)?t?.toString().split(r||""):[t],o=i?{[i]:a?.[0]}:null;return o&&(s&&(o[s]=a?.[1]),l&&(o[l]=a?.[2])),o}const Ke=new j({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Xe={};const Ye=new WeakMap;let et=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._loading=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._clusterSizeVariable=null,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilter=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([y(()=>this.children,"change",t=>{const{added:i,removed:s}=t;i.forEach(t=>{const i=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(h(()=>t.ready,e,f),i)}),s.forEach(e=>this.removeHandles(e.layer.uid)),e()})]),this.keepCacheOnDestroy||(Xe={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Xe=null),this._layerDefinitionExpressionClause=null}get cssEffectFilter(){const{layer:e,scale:t}=this,i="effect"in e?e.effect:null;if(!i)return null;const s=new w({effect:i});return s.endTransition(),s.scale=t,B(s,!0)}get loading(){return this.children.length>0?this.children.some(e=>e.loading):this._loading}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,i=this.layer.parent,s=i&&"uid"in i?this._getParentLayerOpacity(i):null;return null!=t?t*e:null!=s?s*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Fe(e.renderer))||this._isRendererScaleDriven(e.renderer):this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){this._loading=!0;if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");const t=Array.from(e,e=>{if(C(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,i=t?.drawingInfo,s=i&&R(i.renderer),l=me.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null});try{const e=[],i=await Promise.allSettled(t);for(const t of i)if("fulfilled"===t.status)for(const i of t.value??[])e.push(i);this.legendElements=e}catch(i){o.getLogger(this).warn("error while building legend for layer!",i)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForRenderer(e){try{this._loading=!0;const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForFeatureReduction(e){try{this._loading=!0,await this._waitForLayerViewUpdate(this.layerView);const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForTools(){this._loading=!0;const e=this.layer;if(Me(e))await this._constructLegendElementsForVoxelLayer();else if(Ue(e))this._constructLegendElementsForWMTSlayer();else if(Pe(e))await this._constructLegendElementsForWMSSublayers();else if(Oe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ae(e)||Be(e)||ke(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Ne(e)){const i=e;t=(i?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if($e(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then(async t=>{this.legendElements=[];const i=t.map(async t=>{if(Ne(e)){const t=h(()=>[e.rasterFunction,e.bandIds],()=>c(async()=>{Xe.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()})());this.addHandles(t,"imageryLayers-watcher")}const i=this._generateSymbolTableElementForLegendLayer(t);i?.infos.length&&(Ne(e)&&(i.title=e.title),this.legendElements.push(i))});await Promise.allSettled(i)}).catch(e=>{o.getLogger(this).warn("Request to server for legend has failed!",e)})}this._loading=!1,this.notifyChange("ready")}async _isLayerInCurrentView(e){return this._checkFeatureCountForExpression(e,this.view.extent)}_getParentLayerOpacity(e){let t=1;const i=e.parent;return i&&"uid"in i&&(t=this._getParentLayerOpacity(i)),e.opacity*t}_isGroupActive(){return this.children.some(e=>e.ready)}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(fe.test(t))return!0;const i="visualVariables"in e?e.visualVariables:null;return!!i?.some(e=>this._isScaleDrivenSizeVariable(e))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some(e=>this._isScaleDrivenSymbol(e.symbol));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some(e=>this._isScaleDrivenSymbol(e.symbol))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:i,maxScale:s}=e.data,l=t?.some(e=>(e.valueExpressionInfo?.expression||"").includes("$view.scale"))??!1;return null!=i||null!=s||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,i=t.minSize,s=t.maxSize;return!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||(!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||fe.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&&Ae(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const i of t.sourceJSON.layers??[])if(i.id===e.source.mapLayerId&&(i.minScale>0||i.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(h(()=>e.currentVariableId,()=>this._constructLegendElementsForVoxelLayer()),"voxel-current-variable"),this.addHandles(h(()=>e.getVariableStyles(),()=>this._constructLegendElementsForVoxelLayer()),"voxel-style-watcher");const t=e.getVariableStyle(null),i=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach(t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new T({color:t.color,outline:null})})}),e.length&&i.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,l=e.toArray().reverse(),r=s.map((e,t)=>`${0===t?ee:te} ${oe(e)}`).reverse(),n=l.map(e=>({color:e.color,value:null,label:null}));n[0].label=r[0],n[n.length-1].label=r[1],i.push({type:"color-ramp",title:t.label,infos:n,preview:M(l.map(e=>e.color))})}await this._generatePreviewsForLegendElements(i,{opacity:e.opacity}),this.legendElements=i,this._loading=!1,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this._loading=!0,this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(h(()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer},()=>this._constructLegendElementsForWMTSlayer()),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find(({id:t})=>t===e.styleId)?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this._loading=!1,this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this._loading=!0,this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(h(()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers},()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this._loading=!1,this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const i=this.layer,s=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher");const l=this.sublayerIds?.map(e=>i.findSublayerById(e))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=h(()=>[r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForWMSSublayers());if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const i=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter(e=>e);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let i=e.legendUrl;if(!i)return;const l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(i=b(i,t));let r=null;const n=e.layer?.opacity;try{r=(await s(i,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:i,preview:r,opacity:n}),l}_getLegendLayers(e,t){const i=Xe&&Xe[e];return i?Promise.resolve(i):this._legendRequest(t).then(t=>{const i=t.layers;return Xe[e]=i,i})}_legendRequest(e){const t=this.layer;let i={f:"json",dynamicLayers:e};if(Ne(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(i.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(i.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:l}=t;i={raster:e,viewId:s,...i,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ce+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(l,{query:i}).then(e=>e.data)}async _constructLegendElementsForBuildingSceneLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(h(()=>e.sublayers,()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForBuildingSublayers(e,t){let i=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");const s=e.toArray();for(const l of s){const e=h(()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible],()=>this._constructLegendElementsForBuildingSceneLayer());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,s=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,s);e.infos.push(...t),i=[e,...i]}else if(l.renderer){i=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:s,sublayer:l}),...i]}}}return i.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _constructLegendElementsForSublayers(){this._loading=!0,this.removeHandles("sublayers-watcher");const e=this.layer;if(!(Ae(e)||Be(e)||ke(e))||this.hideLayersNotInCurrentView&&!await this._isLayerInCurrentView())return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");this.addHandles(h(()=>e.sublayers,()=>this._constructLegendElementsForSublayers),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForSublayers(e,t,i){const s=this.layer;let l=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForSublayers()),"sublayers-watcher");let n=e.toArray();!i&&this.sublayerIds&&this.sublayerIds.length&&(n=ke(s)?this.sublayerIds.map(e=>s.findSublayerForSubtypeCode(e)).filter(r):this.sublayerIds.map(e=>s.findSublayerById(e)).filter(r));for(const r of n){const e=h(()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForSublayers());this.addHandles(e,"sublayers-watcher");const s=r.createQuery().where,n=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView(s),a=!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r);if(n&&a){const e=null!=r?.opacity?r.opacity:null,s=null!=e?e*t:t,n=!Je(r)||r.originIdOf("renderer")>2&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}else if(Je(r)){const e=await this._generateSymbolTableElementForSublayer(r,s,i);e&&l.unshift(e)}}}return l.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _generateSymbolTableElementForSublayer(e,t,i){if(!i){i=new Map;const t=this.layer,s=e.source;let l=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});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach(e=>i.set(e.layerId,e))}const s=i.get(e.id);if((!s||s?.subLayerIds&&s.defaultVisibility)&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,i);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,i){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const s=t?.renderer;let l=t?.title||e.layerName;if(s&&(!t||t?.originIdOf("renderer")>2)){const e=t?.title||this._getRendererTitle(s,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach(s=>{const l={type:"symbol-table",title:s.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter(e=>e.groupId===s.id),e.layerId,s.heading||r.title||t?.title,i)};l.infos?.length>0&&r.infos.push(l)}):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,r.title||t?.title,i),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s,l){return e.map(e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(r.startsWith("http"))return null;r=i(`${this.layer.url}/${t}/images/${r}`)}let n=e.label;return"<all other values>"===n&&(n="others"),{previewAriaLabel:n||s,label:n,src:r,opacity:l??this.opacity,width:e.width,height:e.height}}).filter(r)}_isSublayerInScale(e){const t=e.minScale||0,i=e.maxScale||0;return!(t>0&&t<this.scale||i>this.scale)}_isLegendLayerInScale(e,t){const i=t||this.layer;let s=null,l=null,r=!0;return!i.minScale&&0!==i.minScale||!i.maxScale&&0!==i.maxScale?(0===e.minScale&&i.tileInfo&&(s=i.tileInfo.lods[0].scale),0===e.maxScale&&i.tileInfo&&(l=i.tileInfo.lods[i.tileInfo.lods.length-1].scale)):(s=Math.min(i.minScale,e.minScale)||i.minScale||e.minScale,l=Math.max(i.maxScale,e.maxScale)),(s>0&&s<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const i=t.renderer,s=e.some(e=>e.values);let l=0,r=null;return s&&e.some((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r)),i?"unique-value"===i.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===i.type&&(r&&e.splice(l,1),i.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!je(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Ie(e))return this._constructPointCloudRendererLegendElements(e,t);if(ze(e))return this._constructDotDensityRendererLegendElements(e);const i=await this._loadRenderer(e);return Te(i)?this._constructPieChartRendererLegendElements(i):this._constructRendererLegendElements(i,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t,{isFeatureReductionRenderer:!0}):[]}_getPointCloudRendererTitle(e){return(e.legendOptions?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const i=t.title,s=[];let l=null,r=null;if(Ve(e))l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach(e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(pe,e.color)})});else if(De(e)){const t=e.stops;let s=null;if(t?.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,i=t[t.length-1].value;if(null!=e&&null!=i){s=H(e+(i-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(pe,s||pe.color)}]};const n=q(e.stops??[])??[];r={type:"color-ramp",title:i||this._getPointCloudRendererTitle(e),infos:n,preview:M(n.map(e=>e.color))}}else xe(e)&&(l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach(e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(pe,e.color)})}));return l?.infos.length&&s.push(l),r?.infos.length&&s.push(r),await this._generatePreviewsForLegendElements(s,{opacity:this.opacity,symbolConfig:{applyColorModulation:!!e.colorModulation}}),s}async _getElementInfoForDotDensity(e,t){const{color:i,label:s,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.cssEffectFilter,u=a+"-"+i+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+o,c=this._dotDensityUrlCache,d=c.has(u)?c.get(u):P(e,i);c.set(u,d);const y={shape:{type:"image",x:0,y:0,width:d.width,height:d.height,src:d.src},fill:null,stroke:null,offset:[0,0]},h=k([[y]],[d.width,d.height],{cssEffectFilter:this.cssEffectFilter});return{opacity:1,src:d.src,preview:h,width:d.width,height:d.height,previewAriaLabel:s||l}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),i=e.legendOptions?.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:i||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,s.infos.push(t)}return[s]}async _constructPieChartRendererLegendElements(e){const t=[];let i=null;const s=e.outline;e.attributes.forEach(e=>{const i=new j({color:e.color,outline:s}),l=e.label||e.valueExpressionTitle||e.field;t.push({label:l,symbol:i})});const l=t.length?[...t]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const l=new j({color:e.othersCategory.color,outline:s});i=e.othersCategory.label||"Other",t.push({label:i,symbol:l})}if(e.defaultColor?.a){const i=new j({color:e.defaultColor,outline:s});t.push({label:e.defaultLabel,symbol:i})}const r=await this._getVisualVariableLegendElements(e,this.layer)||[];if(t.length){r.unshift({type:"symbol-table",title:null,infos:t});const n=l.filter(e=>e.label!==i).map(e=>e.symbol.color).filter(Boolean),a=U(n,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,cssEffectFilter:this.cssEffectFilter,outline:s});r.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:t,preview:a})}return await this._generatePreviewsForLegendElements(r,{opacity:this.layer.opacity,cssEffectFilter:this.cssEffectFilter}),r}async _getWhereClause(e,t,i){const s=await g(e,i),l=new Set,{field:r,field2:n,field3:a}=t;E(l,i,[r,n,a]),await F(l,i,null,t.valueExpression);const o=new Set(Array.from(l,e=>e.toLowerCase())),u=s?.fieldNames.map(e=>e.toLowerCase());return u?.some(e=>!o.has(e))?null:s}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const i=e.definitionExpression;i&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==i&&(this._layerDefinitionExpressionClause=await this._getWhereClause(i,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=i}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const i=e.displayFilterInfo?v(e.displayFilterInfo,this.view):null;return i?.where?this._layerDisplayFilter?.id!==i?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(i.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilter=i,i}async _constructRendererLegendElements(e,t={}){const{title:i,sublayer:s,isFeatureReductionRenderer:l}=t,r=s||this.layer,n=ie(e,"reference-size"),a=ie(e,"spike"),o=l&&"renderer"in r&&r.renderer?r.renderer:e;let u=null;Fe(o)&&(await this._processDefinitionExpression(r,o),u=await this._processDisplayFilter(r,o)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const c=await this._getVisualVariableLegendElements(e,r)||[],d={type:"symbol-table",title:i||this._getRendererTitle(e,r),infos:[]};let y=null,h=!1;const f=new Set;if(be(e)&&!this._hasSizeRamp){const t=await se(e);d.infos.push({label:null,symbol:t})}else if(We(e)){let t=i;const s=Ge(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=c.findIndex(e=>"color-ramp"===e.type),r=-1!==l?c.splice(l,1)[0]:null,n=c.findIndex(e=>"size-ramp"===e.type),a=-1!==n?c.splice(n,1)[0]:null,o=[];r&&(t=r.title,o.push(r)),a&&(t=a.title,o.push(a)),o.length>0&&c.push({type:s,title:t,infos:o})}else if(Ce(e)){const t=J(e);c.push({type:"heatmap-ramp",title:i||this._getRendererTitle(e,r),infos:t,preview:M(t.map(e=>e.color),{cssEffectFilter:this.cssEffectFilter})})}else if(Fe(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:i,field1:s,field2:l}=t,n=t.focus;if(i&&s&&l){const t=[s,l];let a=Q(n)||0;for(const e of t){const{field:t,normalizationField:i,label:s}=e,l=s||{field:this._getFieldAlias(t,r),normField:i&&this._getFieldAlias(i,r)},n=Ke.clone();n.angle=a,d.infos.push({label:l,symbol:n}),f.add(n),a+=90}const o=Z({focus:n,numClasses:i,infos:e.uniqueValueInfos??[]});c.unshift(o)}}else if(Ne(this.layer)||$e(this.layer)){const{uniqueValueInfos:t}=e;if(t)for(const e of t)e.symbol&&await this._checkClausesForUVR(o,e.value)&&d.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}else{const{field:t,field2:s,field3:l,fieldDelimiter:a,valueExpression:c,defaultSymbol:y}=e,f=!(!t&&!c||!s&&!l),m=u?u.title:null,p=[],{uniqueValueGroups:g}=e;if(g)for(const e of g){const i={type:"symbol-table",title:m||e.heading,infos:[]},{classes:u}=e;if(u)for(const e of u){const{symbol:u,values:d}=e;if(u){const y=[],h=[];for(const e of d??[]){const{value:i,value2:n,value3:o}=e,u=[],d=[];(t||c)&&(u.push(i),d.push(this._getDomainName(t,i,r))),s&&(u.push(n),d.push(this._getDomainName(s,n,r))),l&&(u.push(o),d.push(this._getDomainName(l,o,r))),y.push(f?u.join(a||""):u[0]),h.push(d.join(" - "))}const m=y.join(", ");let p=e.label;if(!p){const e=h.filter(Boolean);p=e.length?e.join(", "):m}let g=u;"cim"===g.type&&n&&(g=g.clone(),z(g,{innerDotSize:.5*ue,outerRingSize:ue}));let b=!1;for(const e of y)if(b=await this._checkClausesForUVR(o,e),b)break;b&&i.infos.push({label:p,value:m,symbol:g})}}i.infos.length&&p.push(i)}if(p.length){const t=p[0];if(1===p.length&&"title"in t&&!t.title){const e=t.infos?.filter(Qe)??[];d.infos.push(...e)}else y&&(p.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),h=!0),d.infos.push(...p);i||e.legendOptions?.title||e.valueExpressionTitle||(d.title=null)}}e.defaultSymbol&&!h&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}else if(Ee(e)){if(!n&&!a){y=this._isUnclassedRenderer(e);if(!y||!this._hasSizeRamp){const t=e.classBreakInfos.filter(({symbol:e})=>e),i="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:s,maxValue:l,symbol:n}of t){const t=e||(y?null:`${s} - ${l}`),a={previewAriaLabel:t||d.title||r.title,label:t,value:[s,l],symbol:n};i?d.infos.push(a):d.infos.unshift(a)}y&&(d.title=null),this._updateInfosForClassedSizeRenderer(e,d.infos)}e.defaultSymbol&&!y&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}}else if(we(e))if($e(this.layer)||He(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);qe(t)?c.push(t):d.infos=t}else{const t=this.layer;let i,s;e.customStatistics?.length&&({min:i,max:s}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;i=null!=i?i:r.statistics?r.statistics[l].min:n[0],s=null!=s?s:r.statistics?r.statistics[l].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].min:n[0],s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:i}=t;e.length>=r.bandCount?3===i?.length?(l=i.map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(Se(e))e.colormapInfos.forEach(e=>{d.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ge,e.color)})});else if(Le(e)){let i=e.symbol;switch(t.geometryType){case"point":i="pointSymbol"in r?r.pointSymbol:null;break;case"polyline":i="lineSymbol"in r?r.lineSymbol:null;break;case"polygon":i="polygonSymbol"in r?r.polygonSymbol:null}const s=this._clusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&s&&d.infos.push({previewAriaLabel:e.label||d.title||r.title,label:e.label,symbol:i})}else if(_e(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),d.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach(e=>{d.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})}):d.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else ve(e)&&c.push(await this._getStretchLegendElements(e,{min:0,max:255}));const m=e.defaultSymbol;!m||h||Le(e)||y&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||c.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:m}]}),d.infos.length&&c.unshift(d);const p=null==t.opacity?this.opacity:t.opacity,g=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),b=Ne(this.layer)||$e(this.layer);return await this._generatePreviewsForLegendElements(c,{opacity:p,symbolConfig:{isTall:g,isSquareFill:b},cssEffectFilter:this.cssEffectFilter},{arrowMarkerSymbols:f}),e=null,c}async _waitForLayerViewUpdate(e){const t=new AbortController,i=m(()=>!e.updating,t.signal);await d(i,5e3,t)}async _checkFeatureCountForExpression(e,t){const i=this.layerView;if(!(i&&"createQuery"in i&&"queryFeatureCount"in i))return!0;try{await this._waitForLayerViewUpdate(i);const s=i.createQuery();e&&(s.where=le(s.where,e)),t&&(s.geometry=t);return await i.queryFeatureCount(s)>0}catch{return!0}}async _checkClausesForUVR(e,t){const i=Ze(e,t);if(!i)return!0;return(!!!(!this._layerDefinitionExpressionClause&&this._layerDefinitionExpression&&this.respectLayerDefinitionExpression||!this._layerDisplayFilterClause&&this._layerDisplayFilter?.where)||await this._checkFeatureCountForExpression(`${e.field} = ${t}`))&&(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(i))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(i))}_getServerSideLegend(){setTimeout(()=>this.buildLegendElementsForTools(),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce((e,t)=>e.concat(this._getAllInfos(t)),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,i=t.symbolizer.rasterInfo??t.raster.rasterInfo;let s,l;const r=e?.customStatistics?.length?e.customStatistics:i?.statistics;if(r)({min:s,max:l}=r[0]);else{const e=I(i.pixelType);s=e[0],l=e[1]}if(t.hasStandardTime()&&(s=t.getStandardTimeValue(s),l=t.getStandardTimeValue(l)),1===i.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:s,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(i.bandCount,3)).keys())).map(e=>i.bandInfos[e].name);return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const i=e.colorRamp,s=W(i,t);return{type:"stretch-ramp",title:"",infos:s,preview:M(s.map(e=>e.color))}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,i=t&&"symbol"in t&&t.renderer;return i&&!0!==i?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t?t.symbol:null}async _getSizeLegendElement(e,t,i,s){return{type:"size-ramp",title:this._clusterSizeVariable?this._getClusterTitle(t):e,infos:await K(i,t,await re(i),this.scale,this.view,s,this._clusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],i=["red","green","blue"];return e.forEach((e,s)=>{t.push({label:{colorName:i[s],bandName:e},src:ne[s],opacity:this.opacity??1})}),t}_updateInfosForClassedSizeRenderer(e,t){const i=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some(e=>N(e.symbol));if(i&&s){const i=X,s=Y,l=e.classBreakInfos.length,r=(i-s)/(l>1?l-1:l);t.forEach((e,t)=>{e.size=i-r*t})}}_isTallSymbol(e){let t=!1,i=!1;if(e)for(let s=0;s<e.length&&(!t||!i);s++){const l=e[s];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(i=!0))}return t&&i}async _generatePreviewsForLegendElements(e,t,i){const s=[];for(const l of e)for(const e of l.infos??[])if("infos"in e&&e.infos&&s.push(this._generatePreviewsForLegendElements([e],t,i)),Qe(e)&&e.symbol&&!e.preview){let r=!0;if("cim"===e.symbol.type){const{minScale:t,maxScale:i}=e.symbol.data;(t&&t<this.scale||i&&i>this.scale)&&(r=!1)}r&&s.push(this._generateSymbolPreviewForInfo(e,{...t,clipBloomEffect:"theme"in l&&"spike"===l.theme,cssEffectFilter:i?.arrowMarkerSymbols?.has(e.symbol)?null:t.cssEffectFilter},i?{applyScaleDrivenSize:!i.arrowMarkerSymbols?.has(e.symbol)}:void 0))}await Promise.all(s)}async _getSize(e,t){let i=null==e.size&&this._hasSizeRamp?p(22):e.size;if(this._scaleDrivenSizeVariable&&t?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return i}_getPreviewCIMOptions(e){return{style:"legend",cimOptions:{allowScalingUp:this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!e?.applyScaleDrivenSize),viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null}}}async _generateSymbolPreviewForInfo(e,t={},i){const{symbol:s}=e;try{if(t.size=await this._getSize(e,i),t.scale=!1,"cim"===s.type){const e=this._getPreviewCIMOptions(i);t={...t,...e}}e.preview=await A(s,t)}catch{e.preview=null,o.getLogger(this).warn(`Generating symbol preview failed for symbol type: ${s?.type}`)}}_getClusterRenderer(e){this._clusterSizeVariable=null;const t="renderer"in this.layer?this.layer.renderer:null,i=e.renderer?.clone()||t?.clone(),s=$(e,this.layerView,this.view);if(s&&null!=i&&"visualVariables"in i){const t=i.visualVariables?.some(e=>"size"===e.type&&"outline"!==e.target&&!fe.test(e.valueExpression));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:i}=e;s.legendOptions=new x({showLegend:t!==i})}const t=i.visualVariables||[];i.visualVariables=t.concat([s]),this._clusterSizeVariable=s}}return i}async _loadRenderer(e){if(Ye.has(e))return Ye.get(e);const t=[],i=e.clone(),s=await re(i);if(Ee(i)||Fe(i)){const e=(i.classBreakInfos||i.uniqueValueInfos).map(e=>this._fetchSymbol(e.symbol,s).then(t=>{e.symbol=t}).catch(()=>{e.symbol=null}));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(i.symbol||i.defaultSymbol,i.defaultSymbol?null:s).then(e=>{this._applySymbolToRenderer(i,e,Le(i))}).catch(()=>{this._applySymbolToRenderer(i,null,Le(i))})),await Promise.allSettled(t),Ye.set(e,i),i}_applySymbolToRenderer(e,t,i){i?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const i=this._webStyleSymbolCache;try{const s=await e.fetchSymbol({cache:i});return this._getAppliedCloneSymbol(s,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,i){if(!e||!i)return e;const s=e.clone(),l=i&&i.toRgba();return s.type.includes("3d")?this._applyColorTo3dSymbol(s,l):"cim"===s.type?O(s,i):s.color&&(s.color=new t(l||s.color)),s}_applyColorTo3dSymbol(e,i){i&&e.symbolLayers.forEach(e=>{e&&(e.material||(e.material={}),e.material.color=new t(i))})}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||"vector-field"===e.type)return null;const i=e.visualVariables??[],s=[],l=[],n=[],a=ie(e,"reference-size")??ie(e,"spike");let o;const c=this._clusterSizeVariable;if(2===a?.sizeStops?.length&&(Ee(e)||Fe(e))){const[e,t]=a.sizeStops,i=c?c.minDataValue:e.value,s=c?c.maxDataValue:t.value;o=new D({field:a.field??void 0,normalizationField:a.normalizationField,minSize:u(e.size,10,100),maxSize:u(t.size,50,150),minDataValue:i,maxDataValue:s}),l.push(o)}for(const r of i)if("color"===r.type)s.push(r);else if("size"===r.type){if("cluster_count"===r.field&&o)continue;l.push(r)}else"opacity"===r.type&&n.push(r);const d=[...s,...l,...n];let y,h;if(0===s.length&&Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];y=t&&t.symbol}if(0===s.length&&Le(e)&&(y=e.symbol),y)if(y.type.includes("3d")){const e=y.symbolLayers.at(0);"water"===e.type?null!=e.color&&(h=e.color):null!=e.material?.color&&(h=e.material.color)}else y.url||(h=y.color);const f=this.cssEffectFilter;return(await Promise.all(d.map(async i=>{if(!i.legendOptions||!1!==i.legendOptions.showLegend){const s=be(e)?i.field:this._getRampTitle(i,t);let l=null;const r=ae(t,i,this.view.timeZone);if("color"===i.type){const e=await G(i,null,r)??[];l={type:"color-ramp",title:s,infos:e,preview:M(e.map(e=>e.color),{cssEffectFilter:f})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===i.type&&"outline"!==i.target)fe.test(i.valueExpression)?this._clusterSizeVariable||(this._scaleDrivenSizeVariable=i):(l=await this._getSizeLegendElement(s,i,e,r),o===i&&"spike"===a?.theme&&(l.theme=a.theme),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===i.type){const e=await G(i,h,r)??[];l={type:"opacity-ramp",title:s,infos:e,preview:M(e.map(e=>e.color),{cssEffectFilter:f})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}}))).filter(r)}_getDomainName(e,t,i){if(e&&"function"!=typeof e){const s="getField"in i&&i.getField?.(e),l=s&&"getFieldDomain"in i&&i.getFieldDomain?i.getFieldDomain(s.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,i=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,l=s&&s.fieldInfos;if(l)for(const t of l)if(t.fieldName===i)return"cluster_count"===i?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let i=e.field,s=e.normalizationField,l=!1,r=!1,n=!1,a=null;i="function"==typeof i?null:i,s="function"==typeof s?null:s;const o=e.legendOptions?.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo?.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const i=e[t];if("color"===i.type){if("ratio"===i.style){l=!0;break}if("percent"===i.style){r=!0;break}if("percent-of-total"===i.style){n=!0;break}}}}a={field:i&&this._getFieldAlias(i,t),normField:s&&this._getFieldAlias(s,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const i=e;if(i.legendOptions?.title)return i.legendOptions.title;if(i.valueExpressionTitle)return i.valueExpressionTitle;let s=i.field,l=null,r=null;if(Ee(i)&&(l=i.normalizationField,r="percent-of-total"===i.normalizationType),s="function"==typeof s?null:s,l="function"==typeof l?null:l,Fe(i)){const{field2:e,field3:l,fieldDelimiter:r}=i;let n=s&&this._getFieldAlias(s,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(s||l)&&(n={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const i="popupTemplate"in t?t.popupTemplate:null,s=i?.fieldInfos;let l=s?.find(t=>e===t.fieldName),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find(t=>e?.toLowerCase()===t.fieldName?.toLowerCase()):void 0,"fields"in a&&a.fields&&(n=a.fields.find(t=>t.name?.toLowerCase()===e?.toLowerCase())));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let i=!1;return Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(i=e.field?t.some(t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField)):!!t.length),i}};e([_()],et.prototype,"_loading",void 0),e([_()],et.prototype,"children",void 0),e([_({readOnly:!0})],et.prototype,"cssEffectFilter",null),e([_()],et.prototype,"layerView",void 0),e([_()],et.prototype,"layer",void 0),e([_()],et.prototype,"legendElements",void 0),e([_({readOnly:!0})],et.prototype,"loading",null),e([_({readOnly:!0})],et.prototype,"opacity",null),e([_()],et.prototype,"parent",void 0),e([_({readOnly:!0,dependsOn:[]})],et.prototype,"ready",null),e([_()],et.prototype,"hideLayersNotInCurrentView",void 0),e([_()],et.prototype,"keepCacheOnDestroy",void 0),e([_()],et.prototype,"respectLayerDefinitionExpression",void 0),e([_()],et.prototype,"respectLayerVisibility",void 0),e([_({readOnly:!0})],et.prototype,"scale",null),e([_()],et.prototype,"sublayerIds",void 0),e([_({readOnly:!0})],et.prototype,"isScaleDriven",null),e([_()],et.prototype,"title",void 0),e([_({readOnly:!0,dependsOn:["ready"],value:0})],et.prototype,"version",null),e([_()],et.prototype,"view",void 0),et=e([S("esri.widgets.Legend.support.ActiveLayerInfo")],et);export{et as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import{addTokenParameter as i}from"../../../kernel.js";import s from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{clamp as u}from"../../../core/mathUtils.js";import{debounce as c}from"../../../core/promiseUtils.js";import{on as d,watch as y,initial as h,whenOnce as f}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as g}from"../../../core/urlUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{EffectView as S}from"../../../layers/effects/EffectView.js";import{getEffectiveDisplayFilter as w}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as v}from"../../../layers/support/ExportImageParameters.js";import{collectFields as L,collectArcadeFieldNames as E}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as F}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as C}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as I}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as R}from"../../../renderers/support/rendererConversion.js";import V from"../../../renderers/visualVariables/SizeVariable.js";import D from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as x}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import z from"../../../symbols/SimpleFillSymbol.js";import T from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as j}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as O}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as k,renderDotDensityPreviewHTML as M,renderPieChartPreviewHTML as P,renderPreviewHTML as U}from"../../../symbols/support/symbolUtils.js";import{getCSSFilterFromEffectList as A,isVolumetricSymbol as B}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as N}from"./clusterUtils.js";import{getColorFromPointCloudStops as $,getRampStopsForPointCloud as H,getStretchRampStops as q,getRampStops as W}from"./colorRampUtils.js";import{getHeatmapRampStops as G}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as J,getRelationshipRampElement as Q}from"./relationshipRampUtils.js";import{getRampStops as Z,realWorldMaxSize as K,realWorldMinSize as X}from"./sizeRampUtils.js";import{specialCharsLessThan as Y,specialCharsGreaterThan as ee,getAuthoringInfoVisualVariableByTheme as te,getSymbolForFlowRenderer as ie,mergeWhereClauses as se,getMedianColor as le,rgbImgSource as re,getDateFormatOptions as ne}from"./utils.js";import{formatNumberLabel as ae}from"../../smartMapping/support/utils.js";const oe=16,ue="https://utility.arcgis.com/sharing/tools/legend",ce="esri.layers.ImageryLayer",de="esri.layers.ImageryTileLayer",ye="esri.layers.WCSLayer",he=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,fe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),me=new T({size:6,outline:{color:[128,128,128,.5],width:.5}}),pe=new z({style:"solid"});function ge(e){return"flow"===e.type}function be(e){return"vector-field"===e.type}function _e(e){return"raster-colormap"===e.type}function Se(e){return"raster-stretch"===e.type}function we(e){return"raster-shaded-relief"===e.type}function ve(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Le(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Fe(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Ce(e){return Re(e)||Ve(e)||De(e)||Ie(e)}function Ie(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Re(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function Ve(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function xe(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function ze(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Te(e,t){return ve(e)||Le(e)||Ee(e)||Fe(e)||xe(e)||ze(e)?"2d"===t.type||R(e):Se(e)||_e(e)||we(e)||Re(e)||Ve(e)||De(e)||be(e)||ge(e)}function je(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Oe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function ke(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Me(e){return"esri.layers.WMSLayer"===e.declaredClass}function Pe(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ue(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Ae(e){return"esri.layers.TileLayer"===e.declaredClass}function Be(e){return e.declaredClass===ce}function Ne(e){return e.declaredClass===de}function $e(e){return e.declaredClass===ye}function He(e){return"stretch-ramp"===e.type}function qe(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function We(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Ge(e){return"sublayers"in e}function Je(e){return e&&"symbol"in e}function Qe(e,t){const{field:i,field2:s,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!i)return null;const a=!(!i&&!n||!s&&!l)?t?.toString().split(r||""):[t],o=i?{[i]:a?.[0]}:null;return o&&(s&&(o[s]=a?.[1]),l&&(o[l]=a?.[2])),o}const Ze=new T({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Ke={};const Xe=new WeakMap;let Ye=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._loading=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._clusterSizeVariable=null,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilter=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([d(()=>this.children,"change",t=>{const{added:i,removed:s}=t;i.forEach(t=>{const i=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(y(()=>t.ready,e,h),i)}),s.forEach(e=>this.removeHandles(e.layer.uid)),e()})]),this.keepCacheOnDestroy||(Ke={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Ke=null),this._layerDefinitionExpressionClause=null}get cssEffectFilter(){const{layer:e,scale:t}=this,i="effect"in e?e.effect:null;if(!i)return null;const s=new S({effect:i});return s.endTransition(),s.scale=t,A(s,!0)}get loading(){return this.children.length>0?this.children.some(e=>e.loading):this._loading}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,i=this.layer.parent,s=i&&"uid"in i?this._getParentLayerOpacity(i):null;return null!=t?t*e:null!=s?s*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ee(e.renderer))||this._isRendererScaleDriven(e.renderer):this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){this._loading=!0;if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");const t=Array.from(e,e=>{if(F(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,i=t?.drawingInfo,s=i&&I(i.renderer),l=fe.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null});try{const e=[],i=await Promise.allSettled(t);for(const t of i)if("fulfilled"===t.status)for(const i of t.value??[])e.push(i);this.legendElements=e}catch(i){o.getLogger(this).warn("error while building legend for layer!",i)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForRenderer(e){try{this._loading=!0;const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForFeatureReduction(e){try{this._loading=!0,await this._waitForLayerViewUpdate(this.layerView);const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForTools(){this._loading=!0;const e=this.layer;if(ke(e))await this._constructLegendElementsForVoxelLayer();else if(Pe(e))this._constructLegendElementsForWMTSlayer();else if(Me(e))await this._constructLegendElementsForWMSSublayers();else if(je(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ue(e)||Ae(e)||Oe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Be(e)){const i=e;t=(i?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(Ne(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then(async t=>{this.legendElements=[];const i=t.map(async t=>{if(Be(e)){const t=y(()=>[e.rasterFunction,e.bandIds],()=>c(async()=>{Ke.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()})());this.addHandles(t,"imageryLayers-watcher")}const i=this._generateSymbolTableElementForLegendLayer(t);i?.infos.length&&(Be(e)&&(i.title=e.title),this.legendElements.push(i))});await Promise.allSettled(i)}).catch(e=>{o.getLogger(this).warn("Request to server for legend has failed!",e)})}this._loading=!1,this.notifyChange("ready")}async _isLayerInCurrentView(e){return this._checkFeatureCountForExpression(e,this.view.extent)}_getParentLayerOpacity(e){let t=1;const i=e.parent;return i&&"uid"in i&&(t=this._getParentLayerOpacity(i)),e.opacity*t}_isGroupActive(){return this.children.some(e=>e.ready)}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(he.test(t))return!0;const i="visualVariables"in e?e.visualVariables:null;return!!i?.some(e=>this._isScaleDrivenSizeVariable(e))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some(e=>this._isScaleDrivenSymbol(e.symbol));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some(e=>this._isScaleDrivenSymbol(e.symbol))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:i,maxScale:s}=e.data,l=t?.some(e=>(e.valueExpressionInfo?.expression||"").includes("$view.scale"))??!1;return null!=i||null!=s||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,i=t.minSize,s=t.maxSize;return!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||(!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||he.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&&Ue(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const i of t.sourceJSON.layers??[])if(i.id===e.source.mapLayerId&&(i.minScale>0||i.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(y(()=>e.currentVariableId,()=>this._constructLegendElementsForVoxelLayer()),"voxel-current-variable"),this.addHandles(y(()=>e.getVariableStyles(),()=>this._constructLegendElementsForVoxelLayer()),"voxel-style-watcher");const t=e.getVariableStyle(null),i=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach(t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new z({color:t.color,outline:null})})}),e.length&&i.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,l=e.toArray().reverse(),r=s.map((e,t)=>`${0===t?Y:ee} ${ae(e)}`).reverse(),n=l.map(e=>({color:e.color,value:null,label:null}));n[0].label=r[0],n[n.length-1].label=r[1],i.push({type:"color-ramp",title:t.label,infos:n,preview:k(l.map(e=>e.color))})}await this._generatePreviewsForLegendElements(i,{opacity:e.opacity}),this.legendElements=i,this._loading=!1,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this._loading=!0,this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(y(()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer},()=>this._constructLegendElementsForWMTSlayer()),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find(({id:t})=>t===e.styleId)?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this._loading=!1,this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this._loading=!0,this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(y(()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers},()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this._loading=!1,this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const i=this.layer,s=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher");const l=this.sublayerIds?.map(e=>i.findSublayerById(e))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=y(()=>[r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForWMSSublayers());if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const i=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter(e=>e);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let i=e.legendUrl;if(!i)return;const l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(i=g(i,t));let r=null;const n=e.layer?.opacity;try{r=(await s(i,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:i,preview:r,opacity:n}),l}_getLegendLayers(e,t){const i=Ke&&Ke[e];return i?Promise.resolve(i):this._legendRequest(t).then(t=>{const i=t.layers;return Ke[e]=i,i})}_legendRequest(e){const t=this.layer;let i={f:"json",dynamicLayers:e};if(Be(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(i.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(i.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:l}=t;i={raster:e,viewId:s,...i,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ue+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(l,{query:i}).then(e=>e.data)}async _constructLegendElementsForBuildingSceneLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForBuildingSublayers(e,t){let i=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");const s=e.toArray();for(const l of s){const e=y(()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible],()=>this._constructLegendElementsForBuildingSceneLayer());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,s=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,s);e.infos.push(...t),i=[e,...i]}else if(l.renderer){i=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:s,sublayer:l}),...i]}}}return i.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _constructLegendElementsForSublayers(){this._loading=!0,this.removeHandles("sublayers-watcher");const e=this.layer;if(!(Ue(e)||Ae(e)||Oe(e))||this.hideLayersNotInCurrentView&&!await this._isLayerInCurrentView())return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForSublayers),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForSublayers(e,t,i){const s=this.layer;let l=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForSublayers()),"sublayers-watcher");let n=e.toArray();!i&&this.sublayerIds&&this.sublayerIds.length&&(n=Oe(s)?this.sublayerIds.map(e=>s.findSublayerForSubtypeCode(e)).filter(r):this.sublayerIds.map(e=>s.findSublayerById(e)).filter(r));for(const r of n){const e=y(()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForSublayers());this.addHandles(e,"sublayers-watcher");const s=r.createQuery().where,n=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView(s),a=!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r);if(n&&a){const e=null!=r?.opacity?r.opacity:null,s=null!=e?e*t:t,n=!Ge(r)||r.originIdOf("renderer")>2&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}else if(Ge(r)){const e=await this._generateSymbolTableElementForSublayer(r,s,i);e&&l.unshift(e)}}}return l.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _generateSymbolTableElementForSublayer(e,t,i){if(!i){i=new Map;const t=this.layer,s=e.source;let l=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 v({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach(e=>i.set(e.layerId,e))}const s=i.get(e.id);if((!s||s?.subLayerIds&&s.defaultVisibility)&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,i);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,i){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const s=t?.renderer;let l=t?.title||e.layerName;if(s&&(!t||t?.originIdOf("renderer")>2)){const e=t?.title||this._getRendererTitle(s,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach(s=>{const l={type:"symbol-table",title:s.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter(e=>e.groupId===s.id),e.layerId,s.heading||r.title||t?.title,i)};l.infos?.length>0&&r.infos.push(l)}):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,r.title||t?.title,i),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s,l){return e.map(e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(r.startsWith("http"))return null;r=i(`${this.layer.url}/${t}/images/${r}`)}let n=e.label;return"<all other values>"===n&&(n="others"),{previewAriaLabel:n||s,label:n,src:r,opacity:l??this.opacity,width:e.width,height:e.height}}).filter(r)}_isSublayerInScale(e){const t=e.minScale||0,i=e.maxScale||0;return!(t>0&&t<this.scale||i>this.scale)}_isLegendLayerInScale(e,t){const i=t||this.layer;let s=null,l=null,r=!0;return!i.minScale&&0!==i.minScale||!i.maxScale&&0!==i.maxScale?(0===e.minScale&&i.tileInfo&&(s=i.tileInfo.lods[0].scale),0===e.maxScale&&i.tileInfo&&(l=i.tileInfo.lods[i.tileInfo.lods.length-1].scale)):(s=Math.min(i.minScale,e.minScale)||i.minScale||e.minScale,l=Math.max(i.maxScale,e.maxScale)),(s>0&&s<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const i=t.renderer,s=e.some(e=>e.values);let l=0,r=null;return s&&e.some((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r)),i?"unique-value"===i.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===i.type&&(r&&e.splice(l,1),i.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!Te(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Ce(e))return this._constructPointCloudRendererLegendElements(e,t);if(xe(e))return this._constructDotDensityRendererLegendElements(e);const i=await this._loadRenderer(e);return ze(i)?this._constructPieChartRendererLegendElements(i):this._constructRendererLegendElements(i,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t,{isFeatureReductionRenderer:!0}):[]}_getPointCloudRendererTitle(e){return(e.legendOptions?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const i=t.title,s=[];let l=null,r=null;if(Re(e))l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach(e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(me,e.color)})});else if(Ve(e)){const t=e.stops;let s=null;if(t?.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,i=t[t.length-1].value;if(null!=e&&null!=i){s=$(e+(i-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(me,s||me.color)}]};const n=H(e.stops??[])??[];r={type:"color-ramp",title:i||this._getPointCloudRendererTitle(e),infos:n,preview:k(n.map(e=>e.color))}}else De(e)&&(l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach(e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(me,e.color)})}));return l?.infos.length&&s.push(l),r?.infos.length&&s.push(r),await this._generatePreviewsForLegendElements(s,{opacity:this.opacity,symbolConfig:{applyColorModulation:!!e.colorModulation}}),s}async _getElementInfoForDotDensity(e,t){const{color:i,label:s,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.cssEffectFilter,u=a+"-"+i+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+o,c=this._dotDensityUrlCache,d=c.has(u)?c.get(u):M(e,i);c.set(u,d);const y={shape:{type:"image",x:0,y:0,width:d.width,height:d.height,src:d.src},fill:null,stroke:null,offset:[0,0]},h=O([[y]],[d.width,d.height],{cssEffectFilter:this.cssEffectFilter});return{opacity:1,src:d.src,preview:h,width:d.width,height:d.height,previewAriaLabel:s||l}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),i=e.legendOptions?.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:i||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,s.infos.push(t)}return[s]}async _constructPieChartRendererLegendElements(e){const t=[];let i=null;const s=e.outline;e.attributes.forEach(e=>{const i=new T({color:e.color,outline:s}),l=e.label||e.valueExpressionTitle||e.field;t.push({label:l,symbol:i})});const l=t.length?[...t]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const l=new T({color:e.othersCategory.color,outline:s});i=e.othersCategory.label||"Other",t.push({label:i,symbol:l})}if(e.defaultColor?.a){const i=new T({color:e.defaultColor,outline:s});t.push({label:e.defaultLabel,symbol:i})}const r=await this._getVisualVariableLegendElements(e,this.layer)||[];if(t.length){r.unshift({type:"symbol-table",title:null,infos:t});const n=l.filter(e=>e.label!==i).map(e=>e.symbol.color).filter(Boolean),a=P(n,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,cssEffectFilter:this.cssEffectFilter,outline:s});r.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:t,preview:a})}return await this._generatePreviewsForLegendElements(r,{opacity:this.layer.opacity,cssEffectFilter:this.cssEffectFilter}),r}async _getWhereClause(e,t,i){const s=await p(e,i),l=new Set,{field:r,field2:n,field3:a}=t;L(l,i,[r,n,a]),await E(l,i,null,t.valueExpression);const o=new Set(Array.from(l,e=>e.toLowerCase())),u=s?.fieldNames.map(e=>e.toLowerCase());return u?.some(e=>!o.has(e))?null:s}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const i=e.definitionExpression;i&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==i&&(this._layerDefinitionExpressionClause=await this._getWhereClause(i,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=i}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const i=e.displayFilterInfo?w(e.displayFilterInfo,this.view):null;return i?.where?this._layerDisplayFilter?.id!==i?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(i.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilter=i,i}async _constructRendererLegendElements(e,t={}){const{title:i,sublayer:s,isFeatureReductionRenderer:l}=t,r=s||this.layer,n=te(e,"reference-size"),a=te(e,"spike"),o=l&&"renderer"in r&&r.renderer?r.renderer:e;let u=null;Ee(o)&&(await this._processDefinitionExpression(r,o),u=await this._processDisplayFilter(r,o)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const c=await this._getVisualVariableLegendElements(e,r)||[],d={type:"symbol-table",title:i||this._getRendererTitle(e,r),infos:[]};let y=null,h=!1;const f=new Set;if(ge(e)&&!this._hasSizeRamp){const t=await ie(e);d.infos.push({label:null,symbol:t})}else if(qe(e)){let t=i;const s=We(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=c.findIndex(e=>"color-ramp"===e.type),r=-1!==l?c.splice(l,1)[0]:null,n=c.findIndex(e=>"size-ramp"===e.type),a=-1!==n?c.splice(n,1)[0]:null,o=[];r&&(t=r.title,o.push(r)),a&&(t=a.title,o.push(a)),o.length>0&&c.push({type:s,title:t,infos:o})}else if(Fe(e)){const t=G(e);c.push({type:"heatmap-ramp",title:i||this._getRendererTitle(e,r),infos:t,preview:k(t.map(e=>e.color),{cssEffectFilter:this.cssEffectFilter})})}else if(Ee(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:i,field1:s,field2:l}=t,n=t.focus;if(i&&s&&l){const t=[s,l];let a=J(n)||0;for(const e of t){const{field:t,normalizationField:i,label:s}=e,l=s||{field:this._getFieldAlias(t,r),normField:i&&this._getFieldAlias(i,r)},n=Ze.clone();n.angle=a,d.infos.push({label:l,symbol:n}),f.add(n),a+=90}const o=Q({focus:n,numClasses:i,infos:e.uniqueValueInfos??[]});c.unshift(o)}}else if(Be(this.layer)||Ne(this.layer)){const{uniqueValueInfos:t}=e;if(t)for(const e of t)e.symbol&&await this._checkClausesForUVR(o,e.value)&&d.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}else{const{field:t,field2:s,field3:l,fieldDelimiter:a,valueExpression:c,defaultSymbol:y}=e,f=!(!t&&!c||!s&&!l),m=u?u.title:null,p=[],{uniqueValueGroups:g}=e;if(g)for(const e of g){const i={type:"symbol-table",title:m||e.heading,infos:[]},{classes:u}=e;if(u)for(const e of u){const{symbol:u,values:d}=e;if(u){const y=[],h=[];for(const e of d??[]){const{value:i,value2:n,value3:o}=e,u=[],d=[];(t||c)&&(u.push(i),d.push(this._getDomainName(t,i,r))),s&&(u.push(n),d.push(this._getDomainName(s,n,r))),l&&(u.push(o),d.push(this._getDomainName(l,o,r))),y.push(f?u.join(a||""):u[0]),h.push(d.join(" - "))}const m=y.join(", ");let p=e.label;if(!p){const e=h.filter(Boolean);p=e.length?e.join(", "):m}let g=u;"cim"===g.type&&n&&(g=g.clone(),x(g,{innerDotSize:.5*oe,outerRingSize:oe}));let b=!1;for(const e of y)if(b=await this._checkClausesForUVR(o,e),b)break;b&&i.infos.push({label:p,value:m,symbol:g})}}i.infos.length&&p.push(i)}if(p.length){const t=p[0];if(1===p.length&&"title"in t&&!t.title){const e=t.infos?.filter(Je)??[];d.infos.push(...e)}else y&&(p.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),h=!0),d.infos.push(...p);i||e.legendOptions?.title||e.valueExpressionTitle||(d.title=null)}}e.defaultSymbol&&!h&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}else if(Le(e)){if(!n&&!a){y=this._isUnclassedRenderer(e);if(!y||!this._hasSizeRamp){const t=e.classBreakInfos.filter(({symbol:e})=>e),i="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:s,maxValue:l,symbol:n}of t){const t=e||(y?null:`${s} - ${l}`),a={previewAriaLabel:t||d.title||r.title,label:t,value:[s,l],symbol:n};i?d.infos.push(a):d.infos.unshift(a)}y&&(d.title=null),this._updateInfosForClassedSizeRenderer(e,d.infos)}e.defaultSymbol&&!y&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}}else if(Se(e))if(Ne(this.layer)||$e(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);He(t)?c.push(t):d.infos=t}else{const t=this.layer;let i,s;e.customStatistics?.length&&({min:i,max:s}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=C(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;i=null!=i?i:r.statistics?r.statistics[l].min:n[0],s=null!=s?s:r.statistics?r.statistics[l].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].min:n[0],s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:i}=t;e.length>=r.bandCount?3===i?.length?(l=i.map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(_e(e))e.colormapInfos.forEach(e=>{d.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(pe,e.color)})});else if(ve(e)){let i=e.symbol;switch(t.geometryType){case"point":i="pointSymbol"in r?r.pointSymbol:null;break;case"polyline":i="lineSymbol"in r?r.lineSymbol:null;break;case"polygon":i="polygonSymbol"in r?r.polygonSymbol:null}const s=this._clusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&s&&d.infos.push({previewAriaLabel:e.label||d.title||r.title,label:e.label,symbol:i})}else if(be(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),d.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach(e=>{d.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})}):d.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else we(e)&&c.push(await this._getStretchLegendElements(e,{min:0,max:255}));const m=e.defaultSymbol;!m||h||ve(e)||y&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||c.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:m}]}),d.infos.length&&c.unshift(d);const p=null==t.opacity?this.opacity:t.opacity,g=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),b=Be(this.layer)||Ne(this.layer);return await this._generatePreviewsForLegendElements(c,{opacity:p,symbolConfig:{isTall:g,isSquareFill:b},cssEffectFilter:this.cssEffectFilter},{arrowMarkerSymbols:f}),e=null,c}async _waitForLayerViewUpdate(e){await f(()=>!e.updating)}async _checkFeatureCountForExpression(e,t){const i=this.layerView;if(!(i&&"createQuery"in i&&"queryFeatureCount"in i))return!0;try{await this._waitForLayerViewUpdate(i);const s=i.createQuery();e&&(s.where=se(s.where,e)),t&&(s.geometry=t);return await i.queryFeatureCount(s)>0}catch{return!0}}async _checkClausesForUVR(e,t){const i=Qe(e,t);if(!i)return!0;return(!!!(!this._layerDefinitionExpressionClause&&this._layerDefinitionExpression&&this.respectLayerDefinitionExpression||!this._layerDisplayFilterClause&&this._layerDisplayFilter?.where)||await this._checkFeatureCountForExpression(`${e.field} = ${t}`))&&(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(i))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(i))}_getServerSideLegend(){setTimeout(()=>this.buildLegendElementsForTools(),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce((e,t)=>e.concat(this._getAllInfos(t)),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,i=t.symbolizer.rasterInfo??t.raster.rasterInfo;let s,l;const r=e?.customStatistics?.length?e.customStatistics:i?.statistics;if(r)({min:s,max:l}=r[0]);else{const e=C(i.pixelType);s=e[0],l=e[1]}if(t.hasStandardTime()&&(s=t.getStandardTimeValue(s),l=t.getStandardTimeValue(l)),1===i.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:s,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(i.bandCount,3)).keys())).map(e=>i.bandInfos[e].name);return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const i=e.colorRamp,s=q(i,t);return{type:"stretch-ramp",title:"",infos:s,preview:k(s.map(e=>e.color))}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,i=t&&"symbol"in t&&t.renderer;return i&&!0!==i?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t?t.symbol:null}async _getSizeLegendElement(e,t,i,s){return{type:"size-ramp",title:this._clusterSizeVariable?this._getClusterTitle(t):e,infos:await Z(i,t,await le(i),this.scale,this.view,s,this._clusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],i=["red","green","blue"];return e.forEach((e,s)=>{t.push({label:{colorName:i[s],bandName:e},src:re[s],opacity:this.opacity??1})}),t}_updateInfosForClassedSizeRenderer(e,t){const i=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some(e=>B(e.symbol));if(i&&s){const i=K,s=X,l=e.classBreakInfos.length,r=(i-s)/(l>1?l-1:l);t.forEach((e,t)=>{e.size=i-r*t})}}_isTallSymbol(e){let t=!1,i=!1;if(e)for(let s=0;s<e.length&&(!t||!i);s++){const l=e[s];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(i=!0))}return t&&i}async _generatePreviewsForLegendElements(e,t,i){const s=[];for(const l of e)for(const e of l.infos??[])if("infos"in e&&e.infos&&s.push(this._generatePreviewsForLegendElements([e],t,i)),Je(e)&&e.symbol&&!e.preview){let r=!0;if("cim"===e.symbol.type){const{minScale:t,maxScale:i}=e.symbol.data;(t&&t<this.scale||i&&i>this.scale)&&(r=!1)}r&&s.push(this._generateSymbolPreviewForInfo(e,{...t,clipBloomEffect:"theme"in l&&"spike"===l.theme,cssEffectFilter:i?.arrowMarkerSymbols?.has(e.symbol)?null:t.cssEffectFilter},i?{applyScaleDrivenSize:!i.arrowMarkerSymbols?.has(e.symbol)}:void 0))}await Promise.all(s)}async _getSize(e,t){let i=null==e.size&&this._hasSizeRamp?m(22):e.size;if(this._scaleDrivenSizeVariable&&t?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return i}_getPreviewCIMOptions(e){return{style:"legend",cimOptions:{allowScalingUp:this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!e?.applyScaleDrivenSize),viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null}}}async _generateSymbolPreviewForInfo(e,t={},i){const{symbol:s}=e;try{if(t.size=await this._getSize(e,i),t.scale=!1,"cim"===s.type){const e=this._getPreviewCIMOptions(i);t={...t,...e}}e.preview=await U(s,t)}catch{e.preview=null,o.getLogger(this).warn(`Generating symbol preview failed for symbol type: ${s?.type}`)}}_getClusterRenderer(e){this._clusterSizeVariable=null;const t="renderer"in this.layer?this.layer.renderer:null,i=e.renderer?.clone()||t?.clone(),s=N(e,this.layerView,this.view);if(s&&null!=i&&"visualVariables"in i){const t=i.visualVariables?.some(e=>"size"===e.type&&"outline"!==e.target&&!he.test(e.valueExpression));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:i}=e;s.legendOptions=new D({showLegend:t!==i})}const t=i.visualVariables||[];i.visualVariables=t.concat([s]),this._clusterSizeVariable=s}}return i}async _loadRenderer(e){if(Xe.has(e))return Xe.get(e);const t=[],i=e.clone(),s=await le(i);if(Le(i)||Ee(i)){const e=(i.classBreakInfos||i.uniqueValueInfos).map(e=>this._fetchSymbol(e.symbol,s).then(t=>{e.symbol=t}).catch(()=>{e.symbol=null}));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(i.symbol||i.defaultSymbol,i.defaultSymbol?null:s).then(e=>{this._applySymbolToRenderer(i,e,ve(i))}).catch(()=>{this._applySymbolToRenderer(i,null,ve(i))})),await Promise.allSettled(t),Xe.set(e,i),i}_applySymbolToRenderer(e,t,i){i?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const i=this._webStyleSymbolCache;try{const s=await e.fetchSymbol({cache:i});return this._getAppliedCloneSymbol(s,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,i){if(!e||!i)return e;const s=e.clone(),l=i&&i.toRgba();return s.type.includes("3d")?this._applyColorTo3dSymbol(s,l):"cim"===s.type?j(s,i):s.color&&(s.color=new t(l||s.color)),s}_applyColorTo3dSymbol(e,i){i&&e.symbolLayers.forEach(e=>{e&&(e.material||(e.material={}),e.material.color=new t(i))})}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||"vector-field"===e.type)return null;const i=e.visualVariables??[],s=[],l=[],n=[],a=te(e,"reference-size")??te(e,"spike");let o;const c=this._clusterSizeVariable;if(2===a?.sizeStops?.length&&(Le(e)||Ee(e))){const[e,t]=a.sizeStops,i=c?c.minDataValue:e.value,s=c?c.maxDataValue:t.value;o=new V({field:a.field??void 0,normalizationField:a.normalizationField,minSize:u(e.size,10,100),maxSize:u(t.size,50,150),minDataValue:i,maxDataValue:s}),l.push(o)}for(const r of i)if("color"===r.type)s.push(r);else if("size"===r.type){if("cluster_count"===r.field&&o)continue;l.push(r)}else"opacity"===r.type&&n.push(r);const d=[...s,...l,...n];let y,h;if(0===s.length&&Le(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];y=t&&t.symbol}if(0===s.length&&ve(e)&&(y=e.symbol),y)if(y.type.includes("3d")){const e=y.symbolLayers.at(0);"water"===e.type?null!=e.color&&(h=e.color):null!=e.material?.color&&(h=e.material.color)}else y.url||(h=y.color);const f=this.cssEffectFilter;return(await Promise.all(d.map(async i=>{if(!i.legendOptions||!1!==i.legendOptions.showLegend){const s=ge(e)?i.field:this._getRampTitle(i,t);let l=null;const r=ne(t,i,this.view.timeZone);if("color"===i.type){const e=await W(i,null,r)??[];l={type:"color-ramp",title:s,infos:e,preview:k(e.map(e=>e.color),{cssEffectFilter:f})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===i.type&&"outline"!==i.target)he.test(i.valueExpression)?this._clusterSizeVariable||(this._scaleDrivenSizeVariable=i):(l=await this._getSizeLegendElement(s,i,e,r),o===i&&"spike"===a?.theme&&(l.theme=a.theme),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===i.type){const e=await W(i,h,r)??[];l={type:"opacity-ramp",title:s,infos:e,preview:k(e.map(e=>e.color),{cssEffectFilter:f})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}}))).filter(r)}_getDomainName(e,t,i){if(e&&"function"!=typeof e){const s="getField"in i&&i.getField?.(e),l=s&&"getFieldDomain"in i&&i.getFieldDomain?i.getFieldDomain(s.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,i=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,l=s&&s.fieldInfos;if(l)for(const t of l)if(t.fieldName===i)return"cluster_count"===i?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let i=e.field,s=e.normalizationField,l=!1,r=!1,n=!1,a=null;i="function"==typeof i?null:i,s="function"==typeof s?null:s;const o=e.legendOptions?.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo?.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const i=e[t];if("color"===i.type){if("ratio"===i.style){l=!0;break}if("percent"===i.style){r=!0;break}if("percent-of-total"===i.style){n=!0;break}}}}a={field:i&&this._getFieldAlias(i,t),normField:s&&this._getFieldAlias(s,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const i=e;if(i.legendOptions?.title)return i.legendOptions.title;if(i.valueExpressionTitle)return i.valueExpressionTitle;let s=i.field,l=null,r=null;if(Le(i)&&(l=i.normalizationField,r="percent-of-total"===i.normalizationType),s="function"==typeof s?null:s,l="function"==typeof l?null:l,Ee(i)){const{field2:e,field3:l,fieldDelimiter:r}=i;let n=s&&this._getFieldAlias(s,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(s||l)&&(n={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const i="popupTemplate"in t?t.popupTemplate:null,s=i?.fieldInfos;let l=s?.find(t=>e===t.fieldName),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find(t=>e?.toLowerCase()===t.fieldName?.toLowerCase()):void 0,"fields"in a&&a.fields&&(n=a.fields.find(t=>t.name?.toLowerCase()===e?.toLowerCase())));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let i=!1;return Le(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(i=e.field?t.some(t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField)):!!t.length),i}};e([b()],Ye.prototype,"_loading",void 0),e([b()],Ye.prototype,"children",void 0),e([b({readOnly:!0})],Ye.prototype,"cssEffectFilter",null),e([b()],Ye.prototype,"layerView",void 0),e([b()],Ye.prototype,"layer",void 0),e([b()],Ye.prototype,"legendElements",void 0),e([b({readOnly:!0})],Ye.prototype,"loading",null),e([b({readOnly:!0})],Ye.prototype,"opacity",null),e([b()],Ye.prototype,"parent",void 0),e([b({readOnly:!0,dependsOn:[]})],Ye.prototype,"ready",null),e([b()],Ye.prototype,"hideLayersNotInCurrentView",void 0),e([b()],Ye.prototype,"keepCacheOnDestroy",void 0),e([b()],Ye.prototype,"respectLayerDefinitionExpression",void 0),e([b()],Ye.prototype,"respectLayerVisibility",void 0),e([b({readOnly:!0})],Ye.prototype,"scale",null),e([b()],Ye.prototype,"sublayerIds",void 0),e([b({readOnly:!0})],Ye.prototype,"isScaleDriven",null),e([b()],Ye.prototype,"title",void 0),e([b({readOnly:!0,dependsOn:["ready"],value:0})],Ye.prototype,"version",null),e([b()],Ye.prototype,"view",void 0),Ye=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],Ye);export{Ye 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{
|
|
5
|
+
import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}from"../../../../core/promiseUtils.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as o}from"../../../../layers/orientedImagery/transformations/utils.js";import{computeTriangulatedVector as c,computeTriangulatedAreaMeasurement as n,computeTriangulatedDistanceMeasurement as u}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as l}from"../../mixins/TriangulatedSketchHandlerMixin.js";let m=[],d=class extends(l(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if(this._preventLeftMouseDrag(),"distance"===t){const t=e.graphics[0].geometry;m=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;m=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?await this._updateTriangularMeasurements(m):await this.viewModel.processMeasurementVectors(m))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:i}=this.viewModel,o=a?.imageSize;if(!e||!t||!o)return;const n=e.map(e=>[e[0]-.5,-.5-e[1]]),u=i?.spatialReference,l=[];for(let c=0;c<n.length;c++){const e={x:n[c][0],y:n[c][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:o,mode:r});u&&!a.spatialReference.equals(u)&&(a=await s(a,u)),l.push(a)}return c(l,t)}async _updateTriangularMeasurements(e,t){const{measureType:r,mode:i,activeTriangulatedViewer:s,triangularMeasurementActive:c,currentBestFeatureMeasurementImage:l,updatingTriangularMeasurementState:m}=this.viewModel;if(!(c&&l&&m&&s?.imageSize&&2===this.viewModel.measurementVectors?.length))return;const[d,p]=s.imageSize;this.viewModel.measurementVectors.splice(-1);const g=await this._computeMeasurementVector(e,l);if(a(t),g&&this.viewModel.measurementVectors.push(g),2===this.viewModel.measurementVectors.length){switch(r){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await u(this.viewModel.measurementVectors),a(t);const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]}),s="default"===i?await this.viewModel.calculateAccuracy(e,"distance"):await this.viewModel.calculateAccuracyPanoramic(r,"distance");if(a(t),s&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(s/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:s,angleAccuracy:e}}break}case"area":if(l?.geometry.spatialReference){const r=await n(this.viewModel.measurementVectors,l.geometry.spatialReference);if(a(t),this.viewModel.triangulatedAreaMeasurement=r,"default"===i)this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracy(e,"area")??this.viewModel.triangulatedAreaAccuracy,a(t);else if("panoramic"===i){const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]});this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracyPanoramic(r,"area")??this.viewModel.triangulatedAreaAccuracy,a(t)}}}if(this.viewModel.updatingTriangularMeasurementState=!1,"panoramic"===this.viewModel.mode){this.viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}_preventLeftMouseDrag(){const{mode:e,activeTriangulatedViewer:t}=this.viewModel;if("panoramic"!==e||!t)return;let a=null;t.imageRenderer.on("pointer-down",e=>{a=e.button}),t.imageRenderer.on("drag",e=>{0===a&&e.stopPropagation()})}};e([r()],d.prototype,"type",void 0),d=e([i("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],d);const p=d;export{p 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{throwIfAborted as i,waitTick as r}from"../../../../core/promiseUtils.js";import o from"../../../../geometry/Mesh.js";import a from"../../../../geometry/Point.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{MeshVertexAttributes as n}from"../../../../geometry/support/MeshVertexAttributes.js";import{projectVertices as l,updateFrustum as c,createCoveragePolygon as m}from"../../../../layers/orientedImagery/core/coverageUtils.js";import{activeFrustumSymbol as u,additionalFrustumSymbol as p}from"../../symbols.js";class d{constructor(a){this.viewModel=a,this._updateBestFeatureFootprintElevation=!1,this.createFootprints=async r=>{const{coverageFrustums:a,currentBestFeature:c,isAdditionalCoverageVisible:m,view:d}=this.viewModel,f=a.filter(t);for(const t of f){let a=t.clone();if(!d.spatialReference.equals(a.spatialReference)){const{components:e,spatialReference:t,origin:c,vertexAttributes:m,vertexSpace:u}=a;if("local"===u.type){const e=await s(c,d.spatialReference,r);i(r),a.centerAt(e)}else{const s=m.position,c=Float64Array.from(await l([...s],t.clone(),d.spatialReference.clone(),r));i(r),a=new o({vertexAttributes:new n({position:c}),components:e,spatialReference:d.spatialReference.clone()})}}t.imageID===c.attributes.objectId?(this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:t.imageID},geometry:a,symbol:u.clone(),visible:!1}),this._updateBestFeatureFootprintElevation=!0):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:t.imageID},geometry:a,symbol:p.clone(),visible:m}))}},this.updateFootprint=async(r,o)=>{const{bestFeatureFootprint:a,currentBestFeature:n,activeViewer:l,footprintExtent:m,view:p}=this.viewModel,d=l?.imageSize;if(!(n&&a?.geometry&&d&&m))return void this.viewModel.updateCurrentCoveragePolygon(null);const{attributes:{cameraHeight:
|
|
5
|
+
import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{throwIfAborted as i,waitTick as r}from"../../../../core/promiseUtils.js";import o from"../../../../geometry/Mesh.js";import a from"../../../../geometry/Point.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{MeshVertexAttributes as n}from"../../../../geometry/support/MeshVertexAttributes.js";import{projectVertices as l,updateFrustum as c,createCoveragePolygon as m}from"../../../../layers/orientedImagery/core/coverageUtils.js";import{activeFrustumSymbol as u,additionalFrustumSymbol as p}from"../../symbols.js";class d{constructor(a){this.viewModel=a,this._updateBestFeatureFootprintElevation=!1,this.createFootprints=async r=>{const{coverageFrustums:a,currentBestFeature:c,isAdditionalCoverageVisible:m,view:d}=this.viewModel,f=a.filter(t);for(const t of f){let a=t.clone();if(!d.spatialReference.equals(a.spatialReference)){const{components:e,spatialReference:t,origin:c,vertexAttributes:m,vertexSpace:u}=a;if("local"===u.type){const e=await s(c,d.spatialReference,r);i(r),a.centerAt(e)}else{const s=m.position,c=Float64Array.from(await l([...s],t.clone(),d.spatialReference.clone(),r));i(r),a=new o({vertexAttributes:new n({position:c}),components:e,spatialReference:d.spatialReference.clone()})}}t.imageID===c.attributes.objectId?(this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:t.imageID},geometry:a,symbol:u.clone(),visible:!1}),this._updateBestFeatureFootprintElevation=!0):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:t.imageID},geometry:a,symbol:p.clone(),visible:m}))}},this.updateFootprint=async(r,o)=>{const{bestFeatureFootprint:a,currentBestFeature:n,activeViewer:l,footprintExtent:m,view:p}=this.viewModel,d=l?.imageSize;if(!(n&&a?.geometry&&d&&m))return void this.viewModel.updateCurrentCoveragePolygon(null);const{attributes:{cameraHeight:v,location:w,cameraPitch:g,horizontalFieldOfView:h,verticalFieldOfView:y,cameraRoll:b},elevationSample:F}=n;F&&this._updateBestFeatureFootprintElevation&&(this.updateGroundElevation([a],F),this._updateBestFeatureFootprintElevation=!1);const M=w.toArray(),{vertexAttributes:{position:R},spatialReference:V}=a.geometry,j=await f(R,V,w.spatialReference),A=await this.viewModel.getMapPoint(r,{feature:n,mode:"default",imageSize:d});i(o);let I=A.filter(t);if(!I.length)return;I[0].spatialReference.equals(w.spatialReference)||(I=await Promise.all(I.map(async e=>{const t=await s(e,w.spatialReference,o);return i(o),t})));const P=await c(r.map(({x:e,y:t})=>[e,t]),I.map(e=>e.toArray()),{cameraHeight:v,cameraLocation:M,cameraPitch:g,frustumVertices:j,horizontalFieldOfView:h,imageHeight:d[1],imageWidth:d[0],inSRS:{wkid:w.spatialReference.wkid},outSRS:{wkid:p.spatialReference.wkid},verticalFieldOfView:y,cameraRoll:b??0,options:o});this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:n.attributes.objectId},geometry:P,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible}))},this.updateFootprintPanorama=async(t,i)=>{await r(i);const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:s,yaw:n}=t,l=this.viewModel.currentBestFeature?.clone();if(!l)return;const{attributes:c}=l;c.orientedImageryType=null,c.cameraHeading=(n+c.cameraHeading)%360,c.cameraPitch=a,c.horizontalFieldOfView=o,c.verticalFieldOfView=s,c.cameraRoll=0;const{frustum:p}=m(c);p?this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:c.objectId},geometry:p,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible})):this.viewModel.updateCurrentCoveragePolygon(null)}}updateGroundElevation(e,t){const{geometry:i,attributes:{elevation:r}}=this.viewModel.currentBestFeature,o=r??t.queryElevation(i)?.z??0;e.forEach(e=>{const{geometry:t}=e;switch(t?.type){case"mesh":{const{vertexAttributes:{position:e}}=t,i=Math.floor(e.length/3);for(let t=0;t<i;t+=1)e[3*t+2]+=o;break}case"point":t.z=(t.z??0)+o}})}}async function f(e,t,i,r){return Float64Array.from((await Promise.all(e.reduce((e,t,i)=>{const r=Math.floor(i/3);return e[r]=e[r]??[],e[r].push(t),e},new Array).map(async e=>(await s(new a(e,t),i,r)).toArray()))).flat())}export{d 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{Loadable as r}from"../../../core/Loadable.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{RasterJobHandlerMixin as h}from"../../../layers/mixins/RasterJobHandlerMixin.js";let a=class extends(h(r)){constructor(t){super(t)}load(t){return this.addResolvingPromise(this._fetchPixels(t)),Promise.resolve(this)}destroy(){this._source=null}get height(){return this._get("height")}get width(){return this._get("width")}async _fetchPixels(t){const r=(await import("../../../layers/support/rasterDatasets/RasterFactory.js")).default,s=await r.open({url:this.url,ioConfig:{skipExtensions:["jgw","aux.xml"],skipMapInfo:!0},signal:t?.signal});if(i(t),null==s)throw new e("depth-image-service:open-error","Failed to open depth image raster.",{url:this.url});const{width:o,height:h}=s.rasterInfo;await this._initJobHandler(),i(t),s.rasterJobHandler=this._rasterJobHandler;const{pixelBlock:a}=await s.fetchPixels(s.rasterInfo.nativeExtent.clone(),o,h,{noClip:!1,signal:t?.signal});if(i(t),null==a)throw new e("depth-image-service:fetch-error","Failed to fetch depth image pixels.");this._set("width",a.width),this._set("height",a.height),this._source=a.pixels[0]}_getDepthValue(t,e){const r=Math.max(1,Math.min(this.width,t)),i=Math.max(1,Math.min(this.height,e));return this._source[(i-1)*this.width+(r-1)]}_interpolateDepth(t,e){const r=Math.floor(e),i=Math.ceil(e),s=Math.floor(t),o=Math.ceil(t),h=e-r,a=t-s;return(this._getDepthValue(r,s)*(1-h)+this._getDepthValue(i,s)*h)*(1-a)+(this._getDepthValue(r,o)*(1-h)+this._getDepthValue(i,o)*h)*a}depthAt(t,
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{Loadable as r}from"../../../core/Loadable.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{RasterJobHandlerMixin as h}from"../../../layers/mixins/RasterJobHandlerMixin.js";let a=class extends(h(r)){constructor(t){super(t)}load(t){return this.addResolvingPromise(this._fetchPixels(t)),Promise.resolve(this)}destroy(){this._source=null}get height(){return this._get("height")}get width(){return this._get("width")}async _fetchPixels(t){const r=(await import("../../../layers/support/rasterDatasets/RasterFactory.js")).default,s=await r.open({url:this.url,ioConfig:{skipExtensions:["jgw","aux.xml"],skipMapInfo:!0},signal:t?.signal});if(i(t),null==s)throw new e("depth-image-service:open-error","Failed to open depth image raster.",{url:this.url});const{width:o,height:h}=s.rasterInfo;await this._initJobHandler(),i(t),s.rasterJobHandler=this._rasterJobHandler;const{pixelBlock:a}=await s.fetchPixels(s.rasterInfo.nativeExtent.clone(),o,h,{noClip:!1,signal:t?.signal});if(i(t),null==a)throw new e("depth-image-service:fetch-error","Failed to fetch depth image pixels.");this._set("width",a.width),this._set("height",a.height),this._source=a.pixels[0]}_getDepthValue(t,e){const r=Math.max(1,Math.min(this.width,t)),i=Math.max(1,Math.min(this.height,e));return this._source[(i-1)*this.width+(r-1)]}_interpolateDepth(t,e){const r=Math.floor(e),i=Math.ceil(e),s=Math.floor(t),o=Math.ceil(t),h=e-r,a=t-s;return(this._getDepthValue(r,s)*(1-h)+this._getDepthValue(i,s)*h)*(1-a)+(this._getDepthValue(r,o)*(1-h)+this._getDepthValue(i,o)*h)*a}depthAt(t,e){if(!this.loaded||!this._source)throw new Error("DepthImageService must be loaded before sampling depth.");const r=t.x/e.width*this.width,i=t.y/e.height*this.height;return this._interpolateDepth(i,r)}};t([s({readOnly:!0,value:0})],a.prototype,"height",null),t([s()],a.prototype,"url",void 0),t([s({readOnly:!0,value:0})],a.prototype,"width",null),a=t([o("esri.widgets.OrientedImageryViewer.services.DepthImageService")],a);const l=a;export{l as default};
|