@arcgis/core 4.33.0-next.20250401 → 4.33.0-next.20250403
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/applications/SceneViewer/sceneViewerUtils.d.ts +1 -0
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0cd5f15b8558b23e5fcd.js +1 -0
- package/assets/esri/core/workers/chunks/0cec53e6f1464c69448d.js +1 -0
- package/assets/esri/core/workers/chunks/48fbf887da6d19838bf0.js +1 -0
- package/assets/esri/core/workers/chunks/{ba4d91816f6a0bf0d812.js → 4dc135e0133d58a06d67.js} +1 -1
- package/assets/esri/core/workers/chunks/{322cb1b1871d03b69f0a.js → 5beb525b4adde1d98532.js} +33 -33
- package/assets/esri/core/workers/chunks/{3577909b8e84959d415b.js → 6a8cf1f51cc4adc268d3.js} +1 -1
- package/assets/esri/core/workers/chunks/6b0a6469673417563616.js +1 -0
- package/assets/esri/core/workers/chunks/{bdeac9196f28aff93e68.js → 93d06a1a0b700ddb3807.js} +1 -1
- package/assets/esri/core/workers/chunks/b28b699de6deb7e9fa53.js +1 -0
- package/assets/esri/core/workers/chunks/{1a5f96b1b892ecceb36a.js → b4a1f3f3a036226d6810.js} +1 -1
- package/assets/esri/core/workers/chunks/{738e4f46feb3758456e0.js → baa9fd23414f03ef90bc.js} +1 -1
- package/assets/esri/core/workers/chunks/c977a47cabc419610277.js +1 -0
- package/assets/esri/core/workers/chunks/{7e00122014d0a55363a8.js → ccb289911e7445b17763.js} +1 -1
- package/assets/esri/core/workers/chunks/{e2029267cddb8e2effab.js → d58fae2fc9d148e015ae.js} +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/typedArrayUtil.js +1 -1
- package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
- package/geometry/Polygon.js +1 -1
- package/geometry/support/buffer/BufferView.js +1 -1
- package/geometry/support/buffer/internals/Vec2.js +1 -1
- package/interfaces.d.ts +112 -27
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/support/VideoElement.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/ElevationInfo.js +1 -1
- package/undoredo/support/Services.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/CollisionJob.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolDeclutterer.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
- package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
- package/views/3d/environment/PrecipitationTechnique.js +1 -1
- package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
- package/views/3d/layers/DrapedSubView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/i3s/I3SBinaryReader.js +1 -1
- package/views/3d/layers/i3s/I3SQueryFeatureAdapter.js +1 -1
- package/views/3d/layers/i3s/I3SQueryFeatureStore.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/support/TemporalSceneLayerView.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/terrain/PatchGeometry.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/TerrainAttributes.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
- package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
- package/views/3d/webgl-engine/lib/ChangeSet.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
- package/views/3d/webgl-engine/lib/ITexture.js +1 -1
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
- package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
- package/views/3d/webgl-engine/lib/TextureUpdater.js +5 -0
- package/views/3d/webgl-engine/lib/rendererUtils.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
- package/views/interactive/snapping/FeatureSnappingSourceInfo.js +1 -1
- package/views/layers/PointCloudLayerView.d.ts +1 -1
- package/views/layers/PointCloudLayerView.js +5 -0
- package/views/webgl/renderState.js +1 -1
- package/views/webgl/testFloatBufferBlend.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/assets/esri/core/workers/chunks/093421648cc61afdeb3c.js +0 -1
- package/assets/esri/core/workers/chunks/4816cf647eca2f4cecc2.js +0 -1
- package/assets/esri/core/workers/chunks/8725580f6d2a495051b5.js +0 -1
- package/assets/esri/core/workers/chunks/a56da688088404259481.js +0 -1
- package/assets/esri/core/workers/chunks/e6469173c65531d6524a.js +0 -1
- package/assets/esri/core/workers/chunks/e9e517a2141e504eec64.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as h}from"../../core/string.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import y from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as g,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as x}from"../../form/support/formUtils.js";import E from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as N,isRelationshipInput as k,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as U}from"./featureFormUtils.js";import Z from"./FieldInput.js";import{FormExpressionsManager as H}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import G from"./UtilityNetworkAssociationInput.js";import{createFormExpressionArcadeExecutor as $}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const D=new t({attributes:{}}),z={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},J="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",B="#JSAPI_CONTINGENT_VALUE_ANY_HASH",K="#JSAPI_CONTINGENT_VALUE_NULL_HASH",Y="esri.widgets.FeatureForm.FeatureFormViewModel",q=()=>i.getLogger(Y);let Q=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=D.clone(),this._initialFeature=D.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._evaluateExpressions((e=>e.evaluateAll())))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId||e.activeCategory||e.showAllEnabled))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():D.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?N({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?N({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>{e.showAllEnabled=!1,e.activeCategory=null})),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),this._evaluateExpressions((t=>t.evaluateInvalidated([e])))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.notifyChange("submittable"),this.notifyChange("valid"),this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{feature:e,_featureClone:t}=this;e&&(t.geometry=e.geometry,this._evaluateExpressions((e=>e.evaluateInvalidatedByGeometry())))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _evaluateExpressions(e){const t=this._expressionsManager;null!=t&&await this._updatingHandles.addPromise(e(t).finally((()=>this._afterExpressionsEvaluated())))}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(X),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(k(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else g(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>X(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return q().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(T(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else k(o)?o.destroy():L(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[];for(const o of t){const e=n.feature?.getAttribute(o.name)??null,t=s.get(o)??new Z({field:o,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});i.push(t.set({...n,value:e})),s.delete(o)}for(const[o,r]of s.entries())s.delete(o),r.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?ee(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?te(e,t):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new Z({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._evaluateExpressions((e=>e.evaluateAsyncExpressions()))))),a}_makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new G({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=z[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return R(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=$(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new H({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),this._evaluateExpressions((e=>e.evaluateAll()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=S(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);e&&(this.feature&&(this.feature.sourceLayer=e),s.sourceLayer=e)}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&h(n,t)&&this.notifyChange("formTitle"),e&&h(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=S(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(B)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(B),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(B)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(B),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:h,rightIsRange:d}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new E({objectType:"null"});continue}if(r&&d||a&&h)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new E({objectType:"range",minValue:f,maxValue:m})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===B)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||U(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[J,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[B,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${K}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}get test(){return{featureClone:this._featureClone}}};function X(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(q().warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}function ee(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function te(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([d()],Q.prototype,"_expressionInfosLookup",null),e([d()],Q.prototype,"_featureClone",void 0),e([d()],Q.prototype,"_timeZone",void 0),e([d()],Q.prototype,"activeAssociation",void 0),e([d()],Q.prototype,"activeAssociationInput",null),e([d()],Q.prototype,"activeRelationshipInput",null),e([d()],Q.prototype,"_arcadeContextInfo",null),e([d()],Q.prototype,"associationId",null),e([d()],Q.prototype,"associatedLayer",null),e([d()],Q.prototype,"allAssociationInputs",null),e([d()],Q.prototype,"allFieldInputs",null),e([d()],Q.prototype,"allGroupInputs",null),e([d()],Q.prototype,"allRelationshipInputs",null),e([d()],Q.prototype,"_layerFieldsByName",null),e([d()],Q.prototype,"arcadeEditType",void 0),e([d()],Q.prototype,"contingencyConstraintViolations",void 0),e([d()],Q.prototype,"disabled",void 0),e([d()],Q.prototype,"feature",null),e([d()],Q.prototype,"fieldsWithContingentValues",null),e([d({type:y})],Q.prototype,"formTemplate",null),e([d()],Q.prototype,"formDescription",null),e([d()],Q.prototype,"formTitle",null),e([d()],Q.prototype,"formHeaderVisible",null),e([d()],Q.prototype,"highlightHelper",void 0),e([d()],Q.prototype,"inputs",void 0),e([d()],Q.prototype,"joinedContingentValues",null),e([d()],Q.prototype,"layer",null),e([d()],Q.prototype,"map",void 0),e([d()],Q.prototype,"callbacks",void 0),e([d()],Q.prototype,"relationshipId",null),e([d()],Q.prototype,"spatialReference",null),e([d()],Q.prototype,"state",null),e([d()],Q.prototype,"strict",void 0),e([d()],Q.prototype,"submittable",null),e([d()],Q.prototype,"timeZone",null),e([d()],Q.prototype,"updating",null),e([d()],Q.prototype,"valid",null),e([d()],Q.prototype,"pendingSubtypeChoice",void 0),e([d()],Q.prototype,"getValues",null),e([d()],Q.prototype,"submit",null),e([d()],Q.prototype,"test",null),Q=e([f(Y)],Q);const ne=Q;export{ne as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as h}from"../../core/string.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import y from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as g,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as x}from"../../form/support/formUtils.js";import E from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as k,isRelationshipInput as N,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as U}from"./featureFormUtils.js";import Z from"./FieldInput.js";import{FormExpressionsManager as H}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import{createFormExpressionArcadeExecutor as G}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const $=new t({attributes:{}}),D={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},z="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",J="#JSAPI_CONTINGENT_VALUE_ANY_HASH",B="#JSAPI_CONTINGENT_VALUE_NULL_HASH",K="esri.widgets.FeatureForm.FeatureFormViewModel",Y=()=>i.getLogger(K);let q=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=$.clone(),this._initialFeature=$.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._evaluateExpressions((e=>e.evaluateAll())))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId||e.activeCategory||e.showAllEnabled))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():$.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?k({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?k({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>{e.showAllEnabled=!1,e.activeCategory=null})),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),this._evaluateExpressions((t=>t.evaluateInvalidated([e])))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.notifyChange("submittable"),this.notifyChange("valid"),this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{feature:e,_featureClone:t}=this;e&&(t.geometry=e.geometry,this._evaluateExpressions((e=>e.evaluateInvalidatedByGeometry())))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _evaluateExpressions(e){const t=this._expressionsManager;null!=t&&await this._updatingHandles.addPromise(e(t).finally((()=>this._afterExpressionsEvaluated())))}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(Q),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):g(a)?await this._makeUtilityNetworkAssociationInputFromElement(a,s,i):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(N(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else g(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>Q(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return Y().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(T(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else N(o)?o.destroy():L(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[];for(const o of t){const e=n.feature?.getAttribute(o.name)??null,t=s.get(o)??new Z({field:o,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});i.push(t.set({...n,value:e})),s.delete(o)}for(const[o,r]of s.entries())s.delete(o),r.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?X(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?ee(e,t):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new Z({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._evaluateExpressions((e=>e.evaluateAsyncExpressions()))))),a}async _makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new(0,(await import("./UtilityNetworkAssociationInput.js")).default)({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=D[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return R(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=G(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new H({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),this._evaluateExpressions((e=>e.evaluateAll()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=S(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);e&&(this.feature&&(this.feature.sourceLayer=e),s.sourceLayer=e)}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&h(n,t)&&this.notifyChange("formTitle"),e&&h(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=S(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(J)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(J),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(J)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(J),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:h,rightIsRange:d}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new E({objectType:"null"});continue}if(r&&d||a&&h)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new E({objectType:"range",minValue:f,maxValue:m})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===J)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||U(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[z,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[J,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${B}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}get test(){return{featureClone:this._featureClone}}};function Q(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(Y().warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}function X(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function ee(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([d()],q.prototype,"_expressionInfosLookup",null),e([d()],q.prototype,"_featureClone",void 0),e([d()],q.prototype,"_timeZone",void 0),e([d()],q.prototype,"activeAssociation",void 0),e([d()],q.prototype,"activeAssociationInput",null),e([d()],q.prototype,"activeRelationshipInput",null),e([d()],q.prototype,"_arcadeContextInfo",null),e([d()],q.prototype,"associationId",null),e([d()],q.prototype,"associatedLayer",null),e([d()],q.prototype,"allAssociationInputs",null),e([d()],q.prototype,"allFieldInputs",null),e([d()],q.prototype,"allGroupInputs",null),e([d()],q.prototype,"allRelationshipInputs",null),e([d()],q.prototype,"_layerFieldsByName",null),e([d()],q.prototype,"arcadeEditType",void 0),e([d()],q.prototype,"contingencyConstraintViolations",void 0),e([d()],q.prototype,"disabled",void 0),e([d()],q.prototype,"feature",null),e([d()],q.prototype,"fieldsWithContingentValues",null),e([d({type:y})],q.prototype,"formTemplate",null),e([d()],q.prototype,"formDescription",null),e([d()],q.prototype,"formTitle",null),e([d()],q.prototype,"formHeaderVisible",null),e([d()],q.prototype,"highlightHelper",void 0),e([d()],q.prototype,"inputs",void 0),e([d()],q.prototype,"joinedContingentValues",null),e([d()],q.prototype,"layer",null),e([d()],q.prototype,"map",void 0),e([d()],q.prototype,"callbacks",void 0),e([d()],q.prototype,"relationshipId",null),e([d()],q.prototype,"spatialReference",null),e([d()],q.prototype,"state",null),e([d()],q.prototype,"strict",void 0),e([d()],q.prototype,"submittable",null),e([d()],q.prototype,"timeZone",null),e([d()],q.prototype,"updating",null),e([d()],q.prototype,"valid",null),e([d()],q.prototype,"pendingSubtypeChoice",void 0),e([d()],q.prototype,"getValues",null),e([d()],q.prototype,"submit",null),e([d()],q.prototype,"test",null),q=e([f(K)],q);const te=q;export{te as default};
|
package/widgets/FeatureForm.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{createResolver as s}from"../core/promiseUtils.js";import{watch as n,initial as a,whenOnce as r}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as c}from"../layers/support/fieldUtils.js";import{isSubtypeGroupLayer as u,getSubtypesFromLayer as p}from"../layers/support/layerUtils.js";import{isString as m}from"../support/guards.js";import h from"./Widget.js";import{Prompt as v}from"./Editor/components/Prompt.js";import _ from"./Feature/FeatureUtilityNetworkAssociations.js";import{isRelatableFeatureSupportedLayer as g}from"./Feature/support/featureUtils.js";import{css as b}from"./FeatureForm/css.js";import{isGroupInput as f,isFieldInput as y,isRelationshipInput as C,isTextElementInput as F,isUtilityNetworkAssociationInput as w,flattenInputs as R,isInputInGroupInput as k,isFieldElementWithInputType as I,getErrorMessageForFieldInput as O,getIconForFeature as N,isNumberFieldInput as M,subtypeChangeShouldPrompt as L}from"./FeatureForm/featureFormUtils.js";import T from"./FeatureForm/FeatureFormViewModel.js";import A from"./FeatureForm/VisibleElements.js";import x from"./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js";import{loadCalciteComponents as D}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as V,getIntlOptionsForField as S,numberingSystem as U,prepareISOFieldValueForDateComponents as E,prepareUnixFieldValueForDateComponents as j,normalizeTimeOnlyString as P,getISOFieldValueFromDateComponents as $,getUnixFieldValueFromDateComponents as H}from"./support/dateUtils.js";import{globalCss as Z}from"./support/globalCss.js";import{Heading as G,incrementHeadingLevel as W}from"./support/Heading.js";import{setFocus as B}from"./support/widgetUtils.js";import{messageBundle as K}from"./support/decorators/messageBundle.js";import{vmEvent as q}from"./support/decorators/vmEvent.js";import{tsx as z}from"./support/jsxFactory.js";import{substitute as J}from"../intl/substitute.js";import{formatNumber as Q}from"../intl/number.js";const X="data-field-name";let Y=class extends h{constructor(e,t){super(e,t),this._associationsWidgetsMap=new Map,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this._featureFormUNAssociationList=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new T,this.visibleElements=new A,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,callbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t,i)=>{const{feature:o,callbacks:s}=this;let n=i;if(o&&s?.addRelatedRecord){if(u(i)&&e.activeCategory){const t=e.activeCategory.value,o=i.findSublayerForSubtypeCode(t);o&&g(o)&&(n=o)}s.addRelatedRecord({parentFeature:o,relatedLayer:n,relationshipId:t})}},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),r((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>[this._featureFormUNAssociationList,this.visibleElements.associationDetails]),(([e,t])=>{e&&(e.visibleElements.associationDetails=t)}),a),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange())),n((()=>this.viewModel.activeAssociationInput),(e=>{e&&this._featureFormUNAssociationList&&(this._featureFormUNAssociationList.associationInput=e,this._featureFormUNAssociationList.viewModel=e.viewModel)}))])}loadDependencies(){return D({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const{callbacks:e}=this;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get _utilityNetworkAssociationsEnabled(){const{callbacks:e}=this;return!(!e?.viewAssociatedLayers||!e.viewAssociatedFeatures)}get _subtypes(){return p(this.layer)}get associationId(){return this.viewModel.associationId}set associationId(e){this.viewModel.associationId=e}get associatedLayer(){return this.viewModel.associatedLayer}set associatedLayer(e){this.viewModel.associatedLayer=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return z("div",{class:this.classes(b.base,Z.widget,Z.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return z("div",null,z("form",{class:b.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?z(v,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel,{formTitle:t,formDescription:i}=e;if(!e.formHeaderVisible)return;const o=null!=t&&z(G,{key:"title",level:this.headingLevel},t),s=null!=i&&z("p",{class:b.description,key:"description"},i);return z("div",{class:b.formHeader},o,s)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.activeAssociationInput?this._renderFeatureFormUtilityNetworkAssociationList():e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return f(e)?this._renderGroup(e):y(e)?this._renderLabeledField(e):C(e)?this._renderRelationshipInput(e):F(e)?this._renderTextElementInput(e):w(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderFeatureFormUtilityNetworkAssociationList(){return this._featureFormUNAssociationList?.render()}_selectAssociatedLayer(e){const{feature:t,callbacks:i}=this;t&&i?.viewAssociatedFeatures&&i.viewAssociatedFeatures({associatedLayer:e.layer})}async _selectAssociatedFeature(e){const{feature:t,callbacks:i}=this;t&&i?.selectAssociatedFeature&&await i.selectAssociatedFeature({parentFeature:t,...e})}_onAddAssociation(e){const{feature:t,callbacks:i}=this;t&&i?.addAssociation&&i.addAssociation(e)}_setUpUtilityNetworkAssociationList(){this._featureFormUNAssociationList||(this._featureFormUNAssociationList=new x({onSelectLayer:this._selectAssociatedLayer.bind(this),onSelectFeature:this._selectAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)}))}_renderUtilityNetworkAssociationsElementInput(e){if(this._utilityNetworkAssociationsEnabled)return this._setUpUtilityNetworkAssociationList(),o(this._associationsWidgetsMap,e,(()=>new _({onSelectAssociationType:({viewModel:t,listType:i})=>{t.activeAssociationType=i;const{feature:o,callbacks:s}=this;o&&s?.viewAssociatedLayers&&s.viewAssociatedLayers({associationId:e.uid})},viewModel:e.associationsViewModel}))).render()}_renderDescriptionOrEmpty(e,t){return null==e?null:z("div",{class:this.classes(b.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:s,id:n,inputs:a,label:r,open:l}=e,d=a.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),u=c?.group===e,p="sequential"===this.groupDisplay;return z("calcite-block",{class:this.classes(b.group,p?b.groupSequential:null,u?b.groupActive:null,t?b.inputDisabled:null),collapsible:!0,"data-group":e,description:s||void 0,disabled:t,heading:r??"",headingLevel:i?.title?W(o):o,id:n,key:n,open:l,onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=R(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(f(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let s;if(k(t)&&!t.group.open){const i=t.group.inputs.filter(y);s="forward"===e?i[i.length-1]:i[0]}else s=t;o=i.indexOf(s)+1}else o=0;for(let s=o;s<i.length;s++){const e=i[s];if(e.visible&&y(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:s,required:n}=e,a={"aria-label":n?J(this.messages.requiredFieldLabel,{name:o}):o,class:b.label,key:`${s.id}-${i.uid}-${e.name}`},r=[z("div",{class:b.labelTextContent,key:"labelTextContainer"},o,n?z("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?z("label",{...a},r):z("calcite-label",{...a},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:s}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(s,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),n):this._renderComboBoxComponent(e,t,n):this._renderSwitchComponent(e,n)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,n):"number"===t?this._renderNumberComponent(e,n):this._renderStringComponent(e,n)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?z("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)}):z("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.currentTarget)}):z("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderNumberComponent(e,t){const i=c(e.field),o=i&&""!==t.value?Math.round(parseFloat(t.value)).toString():t.value;return z("calcite-input-number",{...t,integer:i,loading:e.updating,type:"number",value:o,onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,V(i,t.value,{timeZone:this.timeZone,...S(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:s}=e,{class:n,key:a,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return z("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:n,"data-date-part":"date","data-field-name":t[X],key:`${a}-date-input`,max:m(l)?l:void 0,min:m(d)?d:void 0,numberingSystem:U,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=s?`${s}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:s,key:n,readOnly:a}=t;return z("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:s,"data-date-part":"time","data-field-name":t[X],key:`${n}-time-input`,numberingSystem:U,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:a,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:s,valid:n,value:a}=e,{class:r,key:l,readOnly:d}=t,{rawMax:c,rawMin:u}=o,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:U,overlayPositioning:"fixed",readOnly:d,[X]:i,onfocus:this._onComponentFocus},m=E(c,s),h=E(u,s),v=E(a,s);return z("div",{class:b.dateInputContainer,key:`${l}-date-time-container`},z("calcite-input-date-picker",{...p,class:r,"data-date-part":"date",key:`${l}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),z("calcite-input-time-picker",{...p,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),e.includeTimeOffset?z("calcite-input-time-zone",{...p,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:s,value:n}=e,{class:a,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!s,numberingSystem:U,overlayPositioning:"fixed",readOnly:c,[X]:o,onfocus:this._onComponentFocus},m=j(n,u),h=j(l,u),v=j(d,u);return z("div",{class:b.dateInputContainer,key:`${r}-date-time-container`},z("calcite-input-date-picker",{...p,class:a,"data-date-part":"date",key:`${r}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:m.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),i?z("calcite-input-time-picker",{...p,class:a,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:m.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return z("calcite-input",{...i,class:this.classes(b.fieldInput,b.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:s}=e,{viewModel:n,_inputsWithChanges:a}=this,r="INSERT"===n.arcadeEditType,l=a.has(s),d=null==o&&(!r||l),c=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return z("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:c,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:s,messagesTemplates:n,viewModel:a,_inputsWithChanges:r}=this,[l,d,c]=t.map((e=>e.map((({name:e,value:t})=>z("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(z("calcite-combobox-item-group",{key:"other",label:n.other},d)),c.length>0&&u.push(z("calcite-combobox-item-group",{key:"unsupported",label:s.subtypes.unsupportedDomainGroupTitle},c)),u.length>0?u.unshift(z("calcite-combobox-item-group",{key:"recommended",label:s.recommended},l)):u.push(...l);const p="INSERT"===a.arcadeEditType,m=r.has(o),h=null==i&&(!p||m);return e.showNoValueOptionEnabled&&u.unshift(z("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||s.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:s}=e,n=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===s,props:i})));if(e.showNoValueOptionEnabled){const t="",a=e.showNoValueLabel||this.messages.empty,r=s===t||null===s;n.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a,name:o,value:t,selected:r,props:i}))}return z("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:b.inputRadioGroup,"data-field-name":i[X],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},n)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!I(e.element,"switch")&&i===e.element.input.onValue;return z("calcite-switch",{...t,checked:o,class:b.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.currentTarget)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:s,props:n}){return z("calcite-label",{class:b.inputRadioLabel,key:e,layout:"inline"},z("calcite-radio-button",{...n,afterCreate:void 0,afterUpdate:void 0,checked:o,class:b.inputRadio,disabled:n.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveValueFromComponent(e)}}),s)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.submittable?O(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?z("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?z("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){if(!e.showAllActionVisible||!this.callbacks?.showAllRelatedRecords)return;const t=this.messages;return z("calcite-list-item",{description:J(t.totalCount,{count:e.featureCount}),key:"show-all-related-features",label:t.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(e.relationshipId)},z("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:s,callbacks:n}=this;if(t&&n?.addRelatedRecord&&o)return z("calcite-button",{alignment:"center",appearance:"outline-fill",class:b.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(e,i,o)},round:!0,scale:"s",width:"full"},e.relatedLayerIsTable?s.addRecord:s.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:s}=e,{feature:n,callbacks:a}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),a?.editRelatedRecord&&n&&a.editRelatedRecord({parentFeature:n,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,c=r?()=>r.remove(i):void 0;return z("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:s,onclick:l,onmouseenter:d,onmouseleave:c,value:s},z("calcite-icon",{icon:N(i),slot:"content-start"}),z("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{relationshipId:t,activeCategory:i}=e,o=i?null:this._renderDescriptionOrEmpty(e.description);return z("calcite-label",{class:this.classes(b.label,b.relatedRecordsLabel),key:`relationship-${t}-container`},z("div",null,this._renderRelatedRecordsHeaderContainer(e),o,this._renderRelationshipInputContent(e)),this._renderAddRelatedRecordButton(e))}_renderRelationshipInputContent(e){return e.featureCount>0?this._renderRelatedRecordsList(e):e.activeCategory&&0===e.featureCount?this._renderNoRelatedRecordsNotice():e.allCategories?.length?this._renderCategoryList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0}_renderCategoryList(e){return z("calcite-list",{displayMode:"flat",label:this.messages.relatedRecordsList,loading:e.updating},e.categories?.map((t=>this._renderCategory(e,t))),this._renderShowAllCategoriesListItem(e))}_renderCategory(e,t){const{count:i,name:o,value:s}=t,n=Q(i);return z("calcite-list-item",{key:`${o}-${s}`,label:o,onCalciteListItemSelect:()=>this._selectCategory(e,t)},z("calcite-chip",{label:n,scale:"s",slot:"content-end"},n),z("calcite-icon",{flipRtl:!0,icon:"chevron-left",scale:"s",slot:"content-end"}))}_selectCategory(e,t){this.relationshipId=e.relationshipId,e.activeCategory=t}_renderShowAllCategoriesListItem(e){if(!e.showAllCategoriesVisible)return;const t=this.messages;return z("calcite-list-item",{description:J(t.totalCount,{count:e.allCategories?.length??0}),key:"show-all-categories",label:t.showAll,value:!0,onCalciteListItemSelect:()=>e.showAllEnabled=!0},z("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return z("div",{class:b.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},z("span",null,e.label),t?z("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return z("calcite-list",{class:b.relatedRecordsList,label:this.messages?.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,s=this.viewModel.findField(o),n=e.layer?.fieldsIndex.get(o),a=s?.label||n?.alias||o,r=J(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return z("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},z("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return z("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},z("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return z("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:b.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return z("div",{class:b.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:s,maxLength:n,minLength:a,name:r,range:{max:l,min:d},required:c,valid:u,value:p}=e,m=this._inputsWithChanges.has(r),h=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(b.fieldInput,h?b.inputDisabled:null),status:m&&!u?"invalid":"idle",key:r,label:s,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:n>-1?n:void 0,minLength:a>-1?a:void 0,placeholder:o??void 0,readOnly:h,required:c,value:null==p?"":`${p}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[X]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(X))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value&&null!=t.value){const i=new ResizeObserver((()=>{switch(e.value=void 0,t.field.type){case"date":e.value=j(t.value,this.timeZone).date??"";break;case"timestamp-offset":e.value=E(t.value,this.timeZone).date??"";break;default:e.value=`${t.value}`}i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);M(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,k(i)&&(i.group.open=!0),B(e))}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null;"readOnly"in t&&t.readOnly||this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:s,range:n}=i,a=this._dateComponentMap.get(s);if(!a)return;let r=this.viewModel.getValue(s),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=P(r),l=P(e.value)):l="timestamp-offset"===o?null!=e.value?$({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?H({oldValue:r,dateComponent:a.date,timeComponent:a.time,timeZone:t,max:n.max,min:n.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(s,l):this._updateFieldValue(s,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&L(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:o}=e,{messages:n,viewModel:a,messagesCommon:r,_subtypes:l}=this;if(this._updateFieldValue(o,t),!l?.length)return;const d=l.find((e=>e.code===t)),c=l.find((e=>e.code===i))?.name??`${i}`;if(!d)return;const u=s();a.pendingSubtypeChoice=u;let p="update-fields";const m=[{label:n.subtypes.useDefaultValuesOption,value:"update-fields"},{label:n.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:n.subtypes.changeWarningTitle,message:J(n.subtypes.changeWarning,{originalType:c,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>p=e,actions:{primary:{label:r.apply,action:()=>u.resolve(p),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":a.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{a.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&k(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return I(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges,updateValue:this._saveValueFromComponent.bind(this)}}};e([l()],Y.prototype,"_listObserverNode",void 0),e([l()],Y.prototype,"_relatedRecordsEnabled",null),e([l()],Y.prototype,"_utilityNetworkAssociationsEnabled",null),e([l()],Y.prototype,"_prompt",void 0),e([l()],Y.prototype,"_subtypes",null),e([l()],Y.prototype,"associationId",null),e([l()],Y.prototype,"associatedLayer",null),e([l()],Y.prototype,"disabled",null),e([l()],Y.prototype,"feature",null),e([l()],Y.prototype,"_featureFormUNAssociationList",void 0),e([l()],Y.prototype,"formTemplate",null),e([l()],Y.prototype,"groupDisplay",void 0),e([l()],Y.prototype,"headingLevel",void 0),e([l()],Y.prototype,"icon",null),e([l()],Y.prototype,"label",null),e([l()],Y.prototype,"layer",null),e([l()],Y.prototype,"map",null),e([l(),K("esri/widgets/FeatureForm/t9n/FeatureForm")],Y.prototype,"messages",void 0),e([l(),K("esri/t9n/common")],Y.prototype,"messagesCommon",void 0),e([l(),K("esri/widgets/Feature/t9n/Feature")],Y.prototype,"messagesFeature",void 0),e([l(),K("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],Y.prototype,"messagesTemplates",void 0),e([l()],Y.prototype,"callbacks",null),e([l()],Y.prototype,"relationshipId",null),e([l()],Y.prototype,"spatialReference",null),e([l()],Y.prototype,"strict",null),e([l()],Y.prototype,"timeZone",null),e([l()],Y.prototype,"showPrompt",null),e([l()],Y.prototype,"clearPrompt",null),e([l(),q(["value-change","submit"])],Y.prototype,"viewModel",void 0),e([l({type:A,nonNullable:!0})],Y.prototype,"visibleElements",void 0),e([l()],Y.prototype,"test",null),Y=e([d("esri.widgets.FeatureForm")],Y);const ee=Y;export{ee as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{createResolver as o}from"../core/promiseUtils.js";import s from"../core/ReactiveMap.js";import{watch as n,initial as a,whenOnce as r}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as c}from"../layers/support/fieldUtils.js";import{isSubtypeGroupLayer as u,getSubtypesFromLayer as p}from"../layers/support/layerUtils.js";import{isString as m}from"../support/guards.js";import h from"./Widget.js";import{Prompt as v}from"./Editor/components/Prompt.js";import{isRelatableFeatureSupportedLayer as _}from"./Feature/support/featureUtils.js";import{css as g}from"./FeatureForm/css.js";import{isGroupInput as b,isFieldInput as f,isRelationshipInput as y,isTextElementInput as C,isUtilityNetworkAssociationInput as F,flattenInputs as w,isInputInGroupInput as R,isFieldElementWithInputType as k,getErrorMessageForFieldInput as I,getIconForFeature as O,isNumberFieldInput as N,subtypeChangeShouldPrompt as M}from"./FeatureForm/featureFormUtils.js";import L from"./FeatureForm/FeatureFormViewModel.js";import A from"./FeatureForm/VisibleElements.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as x,getIntlOptionsForField as D,numberingSystem as V,prepareISOFieldValueForDateComponents as S,prepareUnixFieldValueForDateComponents as U,normalizeTimeOnlyString as E,getISOFieldValueFromDateComponents as j,getUnixFieldValueFromDateComponents as P}from"./support/dateUtils.js";import{globalCss as $}from"./support/globalCss.js";import{Heading as H,incrementHeadingLevel as W}from"./support/Heading.js";import{setFocus as Z}from"./support/widgetUtils.js";import{messageBundle as G}from"./support/decorators/messageBundle.js";import{vmEvent as B}from"./support/decorators/vmEvent.js";import{tsx as K}from"./support/jsxFactory.js";import{substitute as q}from"../intl/substitute.js";import{formatNumber as z}from"../intl/number.js";const J="data-field-name";let Q=class extends h{constructor(e,t){super(e,t),this._associationsWidgetsMap=new s,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this._featureFormUNAssociationList=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new L,this.visibleElements=new A,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,callbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t,i)=>{const{feature:o,callbacks:s}=this;let n=i;if(o&&s?.addRelatedRecord){if(u(i)&&e.activeCategory){const t=e.activeCategory.value,o=i.findSublayerForSubtypeCode(t);o&&_(o)&&(n=o)}s.addRelatedRecord({parentFeature:o,relatedLayer:n,relationshipId:t})}},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),r((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>[this._featureFormUNAssociationList,this.visibleElements.associationDetails]),(([e,t])=>{e&&(e.visibleElements.associationDetails=t)}),a),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange())),n((()=>this.viewModel.activeAssociationInput),(e=>{e&&this._featureFormUNAssociationList&&(this._featureFormUNAssociationList.associationInput=e,this._featureFormUNAssociationList.viewModel=e.viewModel)})),n((()=>this.viewModel.inputs.filter(F)),(async e=>{this._featureFormUNAssociationList||await this._setUpUtilityNetworkAssociationList();for(const t of e)this._associationsWidgetsMap.has(t)||this._associationsWidgetsMap.set(t,await this._makeAssociationsWidget(t))}))])}loadDependencies(){return T({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const{callbacks:e}=this;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get _utilityNetworkAssociationsEnabled(){const{callbacks:e}=this;return!(!e?.viewAssociatedLayers||!e.viewAssociatedFeatures)}get _subtypes(){return p(this.layer)}get associationId(){return this.viewModel.associationId}set associationId(e){this.viewModel.associationId=e}get associatedLayer(){return this.viewModel.associatedLayer}set associatedLayer(e){this.viewModel.associatedLayer=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return K("div",{class:this.classes(g.base,$.widget,$.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return K("div",null,K("form",{class:g.form,inert:!!this._prompt,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?K(v,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel,{formTitle:t,formDescription:i}=e;if(!e.formHeaderVisible)return;const o=null!=t&&K(H,{key:"title",level:this.headingLevel},t),s=null!=i&&K("p",{class:g.description,key:"description"},i);return K("div",{class:g.formHeader},o,s)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.activeAssociationInput?this._renderFeatureFormUtilityNetworkAssociationList():e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return b(e)?this._renderGroup(e):f(e)?this._renderLabeledField(e):y(e)?this._renderRelationshipInput(e):C(e)?this._renderTextElementInput(e):F(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderFeatureFormUtilityNetworkAssociationList(){return this._featureFormUNAssociationList?.render()}_selectAssociatedLayer(e){const{feature:t,callbacks:i}=this;t&&i?.viewAssociatedFeatures&&i.viewAssociatedFeatures({associatedLayer:e.layer})}async _selectAssociatedFeature(e){const{feature:t,callbacks:i}=this;t&&i?.selectAssociatedFeature&&await i.selectAssociatedFeature({parentFeature:t,...e})}_onAddAssociation(e){const{feature:t,callbacks:i}=this;t&&i?.addAssociation&&i.addAssociation(e)}async _setUpUtilityNetworkAssociationList(){if(!this._featureFormUNAssociationList){const e=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js")).default;this._featureFormUNAssociationList=new e({onSelectLayer:this._selectAssociatedLayer.bind(this),onSelectFeature:this._selectAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)})}}async _makeAssociationsWidget(e){return new(0,(await import("./Feature/FeatureUtilityNetworkAssociations.js")).default)({onSelectAssociationType:({viewModel:t,listType:i})=>{t.activeAssociationType=i;const{feature:o,callbacks:s}=this;o&&s?.viewAssociatedLayers&&s.viewAssociatedLayers({associationId:e.uid})},viewModel:e.associationsViewModel})}_renderUtilityNetworkAssociationsElementInput(e){if(this._utilityNetworkAssociationsEnabled)return this._associationsWidgetsMap.get(e)?.render()}_renderDescriptionOrEmpty(e,t){return null==e?null:K("div",{class:this.classes(g.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:s,id:n,inputs:a,label:r,open:l}=e,d=a.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),u=c?.group===e,p="sequential"===this.groupDisplay;return K("calcite-block",{class:this.classes(g.group,p?g.groupSequential:null,u?g.groupActive:null,t?g.inputDisabled:null),collapsible:!0,"data-group":e,description:s||void 0,disabled:t,heading:r??"",headingLevel:i?.title?W(o):o,id:n,key:n,open:l,onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=w(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(b(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let s;if(R(t)&&!t.group.open){const i=t.group.inputs.filter(f);s="forward"===e?i[i.length-1]:i[0]}else s=t;o=i.indexOf(s)+1}else o=0;for(let s=o;s<i.length;s++){const e=i[s];if(e.visible&&f(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:s,required:n}=e,a={"aria-label":n?q(this.messages.requiredFieldLabel,{name:o}):o,class:g.label,key:`${s.id}-${i.uid}-${e.name}`},r=[K("div",{class:g.labelTextContent,key:"labelTextContainer"},o,n?K("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?K("label",{...a},r):K("calcite-label",{...a},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:s}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(s,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),n):this._renderComboBoxComponent(e,t,n):this._renderSwitchComponent(e,n)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,n):"number"===t?this._renderNumberComponent(e,n):this._renderStringComponent(e,n)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?K("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)}):K("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.currentTarget)}):K("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderNumberComponent(e,t){const i=c(e.field),o=i&&""!==t.value?Math.round(parseFloat(t.value)).toString():t.value;return K("calcite-input-number",{...t,integer:i,loading:e.updating,type:"number",value:o,onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,x(i,t.value,{timeZone:this.timeZone,...D(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:s}=e,{class:n,key:a,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return K("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:n,"data-date-part":"date","data-field-name":t[J],key:`${a}-date-input`,max:m(l)?l:void 0,min:m(d)?d:void 0,numberingSystem:V,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=s?`${s}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:s,key:n,readOnly:a}=t;return K("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:s,"data-date-part":"time","data-field-name":t[J],key:`${n}-time-input`,numberingSystem:V,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:a,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:s,valid:n,value:a}=e,{class:r,key:l,readOnly:d}=t,{rawMax:c,rawMin:u}=o,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:V,overlayPositioning:"fixed",readOnly:d,[J]:i,onfocus:this._onComponentFocus},m=S(c,s),h=S(u,s),v=S(a,s);return K("div",{class:g.dateInputContainer,key:`${l}-date-time-container`},K("calcite-input-date-picker",{...p,class:r,"data-date-part":"date",key:`${l}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),K("calcite-input-time-picker",{...p,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),e.includeTimeOffset?K("calcite-input-time-zone",{...p,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:s,value:n}=e,{class:a,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!s,numberingSystem:V,overlayPositioning:"fixed",readOnly:c,[J]:o,onfocus:this._onComponentFocus},m=U(n,u),h=U(l,u),v=U(d,u);return K("div",{class:g.dateInputContainer,key:`${r}-date-time-container`},K("calcite-input-date-picker",{...p,class:a,"data-date-part":"date",key:`${r}-date-input`,max:h?.date??void 0,min:v?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:m.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),i?K("calcite-input-time-picker",{...p,class:a,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:m.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return K("calcite-input",{...i,class:this.classes(g.fieldInput,g.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:s}=e,{viewModel:n,_inputsWithChanges:a}=this,r="INSERT"===n.arcadeEditType,l=a.has(s),d=null==o&&(!r||l),c=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return K("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:c,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:s,messagesTemplates:n,viewModel:a,_inputsWithChanges:r}=this,[l,d,c]=t.map((e=>e.map((({name:e,value:t})=>K("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(K("calcite-combobox-item-group",{key:"other",label:n.other},d)),c.length>0&&u.push(K("calcite-combobox-item-group",{key:"unsupported",label:s.subtypes.unsupportedDomainGroupTitle},c)),u.length>0?u.unshift(K("calcite-combobox-item-group",{key:"recommended",label:s.recommended},l)):u.push(...l);const p="INSERT"===a.arcadeEditType,m=r.has(o),h=null==i&&(!p||m);return e.showNoValueOptionEnabled&&u.unshift(K("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||s.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:s}=e,n=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===s,props:i})));if(e.showNoValueOptionEnabled){const t="",a=e.showNoValueLabel||this.messages.empty,r=s===t||null===s;n.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a,name:o,value:t,selected:r,props:i}))}return K("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:g.inputRadioGroup,"data-field-name":i[J],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},n)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!k(e.element,"switch")&&i===e.element.input.onValue;return K("calcite-switch",{...t,checked:o,class:g.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.currentTarget)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:s,props:n}){return K("calcite-label",{class:g.inputRadioLabel,key:e,layout:"inline"},K("calcite-radio-button",{...n,afterCreate:void 0,afterUpdate:void 0,checked:o,class:g.inputRadio,disabled:n.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveValueFromComponent(e)}}),s)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.submittable?I(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?K("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?K("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){if(!e.showAllActionVisible||!this.callbacks?.showAllRelatedRecords)return;const t=this.messages;return K("calcite-list-item",{description:q(t.totalCount,{count:e.featureCount}),key:"show-all-related-features",label:t.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(e.relationshipId)},K("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:s,callbacks:n}=this;if(t&&n?.addRelatedRecord&&o)return K("calcite-button",{alignment:"center",appearance:"outline-fill",class:g.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(e,i,o)},round:!0,scale:"s",width:"full"},e.relatedLayerIsTable?s.addRecord:s.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:s}=e,{feature:n,callbacks:a}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),a?.editRelatedRecord&&n&&a.editRelatedRecord({parentFeature:n,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,c=r?()=>r.remove(i):void 0;return K("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:s,onclick:l,onmouseenter:d,onmouseleave:c,value:s},K("calcite-icon",{icon:O(i),slot:"content-start"}),K("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{relationshipId:t,activeCategory:i}=e,o=i?null:this._renderDescriptionOrEmpty(e.description);return K("calcite-label",{class:this.classes(g.label,g.relatedRecordsLabel),key:`relationship-${t}-container`},K("div",null,this._renderRelatedRecordsHeaderContainer(e),o,this._renderRelationshipInputContent(e)),this._renderAddRelatedRecordButton(e))}_renderRelationshipInputContent(e){return e.featureCount>0?this._renderRelatedRecordsList(e):e.activeCategory&&0===e.featureCount?this._renderNoRelatedRecordsNotice():e.allCategories?.length?this._renderCategoryList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0}_renderCategoryList(e){return K("calcite-list",{displayMode:"flat",label:this.messages.relatedRecordsList,loading:e.updating},e.categories?.map((t=>this._renderCategory(e,t))),this._renderShowAllCategoriesListItem(e))}_renderCategory(e,t){const{count:i,name:o,value:s}=t,n=z(i);return K("calcite-list-item",{key:`${o}-${s}`,label:o,onCalciteListItemSelect:()=>this._selectCategory(e,t)},K("calcite-chip",{label:n,scale:"s",slot:"content-end"},n),K("calcite-icon",{flipRtl:!0,icon:"chevron-left",scale:"s",slot:"content-end"}))}_selectCategory(e,t){this.relationshipId=e.relationshipId,e.activeCategory=t}_renderShowAllCategoriesListItem(e){if(!e.showAllCategoriesVisible)return;const t=this.messages;return K("calcite-list-item",{description:q(t.totalCount,{count:e.allCategories?.length??0}),key:"show-all-categories",label:t.showAll,value:!0,onCalciteListItemSelect:()=>e.showAllEnabled=!0},K("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return K("div",{class:g.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},K("span",null,e.label),t?K("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return K("calcite-list",{class:g.relatedRecordsList,label:this.messages?.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,s=this.viewModel.findField(o),n=e.layer?.fieldsIndex.get(o),a=s?.label||n?.alias||o,r=q(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return K("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},K("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return K("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},K("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return K("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:g.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return K("div",{class:g.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:s,maxLength:n,minLength:a,name:r,range:{max:l,min:d},required:c,valid:u,value:p}=e,m=this._inputsWithChanges.has(r),h=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(g.fieldInput,h?g.inputDisabled:null),status:m&&!u?"invalid":"idle",key:r,label:s,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:n>-1?n:void 0,minLength:a>-1?a:void 0,placeholder:o??void 0,readOnly:h,required:c,value:null==p?"":`${p}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[J]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(J))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value&&null!=t.value){const i=new ResizeObserver((()=>{switch(e.value=void 0,t.field.type){case"date":e.value=U(t.value,this.timeZone).date??"";break;case"timestamp-offset":e.value=S(t.value,this.timeZone).date??"";break;default:e.value=`${t.value}`}i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);N(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,R(i)&&(i.group.open=!0),Z(e))}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null;"readOnly"in t&&t.readOnly||this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:s,range:n}=i,a=this._dateComponentMap.get(s);if(!a)return;let r=this.viewModel.getValue(s),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=E(r),l=E(e.value)):l="timestamp-offset"===o?null!=e.value?j({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?P({oldValue:r,dateComponent:a.date,timeComponent:a.time,timeZone:t,max:n.max,min:n.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(s,l):this._updateFieldValue(s,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&M(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:s}=e,{messages:n,viewModel:a,messagesCommon:r,_subtypes:l}=this;if(this._updateFieldValue(s,t),!l?.length)return;const d=l.find((e=>e.code===t)),c=l.find((e=>e.code===i))?.name??`${i}`;if(!d)return;const u=o();a.pendingSubtypeChoice=u;let p="update-fields";const m=[{label:n.subtypes.useDefaultValuesOption,value:"update-fields"},{label:n.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:n.subtypes.changeWarningTitle,message:q(n.subtypes.changeWarning,{originalType:c,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>p=e,actions:{primary:{label:r.apply,action:()=>u.resolve(p),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":a.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{a.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&R(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return k(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges,updateValue:this._saveValueFromComponent.bind(this)}}};e([l()],Q.prototype,"_listObserverNode",void 0),e([l()],Q.prototype,"_relatedRecordsEnabled",null),e([l()],Q.prototype,"_utilityNetworkAssociationsEnabled",null),e([l()],Q.prototype,"_prompt",void 0),e([l()],Q.prototype,"_subtypes",null),e([l()],Q.prototype,"associationId",null),e([l()],Q.prototype,"associatedLayer",null),e([l()],Q.prototype,"disabled",null),e([l()],Q.prototype,"feature",null),e([l()],Q.prototype,"_featureFormUNAssociationList",void 0),e([l()],Q.prototype,"formTemplate",null),e([l()],Q.prototype,"groupDisplay",void 0),e([l()],Q.prototype,"headingLevel",void 0),e([l()],Q.prototype,"icon",null),e([l()],Q.prototype,"label",null),e([l()],Q.prototype,"layer",null),e([l()],Q.prototype,"map",null),e([l(),G("esri/widgets/FeatureForm/t9n/FeatureForm")],Q.prototype,"messages",void 0),e([l(),G("esri/t9n/common")],Q.prototype,"messagesCommon",void 0),e([l(),G("esri/widgets/Feature/t9n/Feature")],Q.prototype,"messagesFeature",void 0),e([l(),G("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],Q.prototype,"messagesTemplates",void 0),e([l()],Q.prototype,"callbacks",null),e([l()],Q.prototype,"relationshipId",null),e([l()],Q.prototype,"spatialReference",null),e([l()],Q.prototype,"strict",null),e([l()],Q.prototype,"timeZone",null),e([l()],Q.prototype,"showPrompt",null),e([l()],Q.prototype,"clearPrompt",null),e([l(),B(["value-change","submit"])],Q.prototype,"viewModel",void 0),e([l({type:A,nonNullable:!0})],Q.prototype,"visibleElements",void 0),e([l()],Q.prototype,"test",null),Q=e([d("esri.widgets.FeatureForm")],Q);const X=Q;export{X as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import l from"../../core/Logger.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{isPoint as h,isMultipoint as u}from"../../geometry/support/jsonUtils.js";import{fetchMessageBundle as p}from"../../intl/messages.js";import d from"../../layers/FeatureLayer.js";import g from"../../layers/GraphicsLayer.js";import y from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as m,getOwningPortalUrl as f}from"../../layers/support/layerUtils.js";import w from"../../networks/UtilityNetwork.js";import{getFeaturesFromLayers as _}from"../../networks/support/utils.js";import b from"../../portal/Portal.js";import{hasUserTypeExtension as A}from"../../portal/support/utils.js";import{trace as v}from"../../rest/networks/trace.js";import k from"../../rest/networks/support/TraceLocation.js";import I from"../../rest/networks/support/TraceParameters.js";import{addUniqueLayer as G}from"../../views/draw/support/layerUtils.js";import{GeometryHandler as R}from"./support/GeometryHandler.js";import{GraphicHandler as F,barrierColor as L,startingPointColor as T}from"./support/GraphicHandler.js";import{ResultAreaHandler as H}from"./support/ResultAreaHandler.js";import{UtilityHelper as N}from"./support/UtilityHelper.js";const S=()=>p("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),P=()=>p("esri/core/t9n/Units"),U=`utility-network-trace-flags-${Date.now()}`,V=`utility-network-trace-results-${Date.now()}`,B=`utility-network-trace-sketch-${Date.now()}`;function C(e){return e instanceof y}function E(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function j(e){return"layer"in e}function D(e){return void 0!==e.layerViews}function O(e){return"graphics"===e.type}function M(e){return"feature"===e.type||"subtype-group"===e.type||"group"===e.type}async function x(e){const t=new d({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=await f(e.layerUrl),r=new b({url:t});await r.load();const s=r?.user?.username;return!!s&&A(r,s,"utilityNetwork")}return!0}let q=class extends a.EventedAccessor{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._flagId=0,this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._sketchViewModel=null,this._traceTimeout=6e5,this._utilityHelper=new N,this._validUNLayers=[],this._watchHandler=null,this.traces=[],this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){s(l.getLogger(this),"gdbVersion will be removed and the gdbVersion of the UtilityNetwork will be consumed directly.",{replacement:"UtilityNetwork.gdbVersion",version:"4.31"}),this._geometryHandler=new R,this.graphicHandler=new F,this._resultAreaHandler=new H;(async()=>{const[e,t]=await Promise.all([S(),P()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach((t=>{const r=t.resultArea?.show;t.resultArea={...this.defaultResultAreaProperties,...e},this.removeResultAreaFromMap(t),this.enableResultArea&&this.createResultAreaGraphic(t).then((s=>{if(s){t.resultAreaGraphic=s;const i=e?.show??r;t.resultArea&&(t.resultArea.show=i),i&&this.addResultAreaToMap(t,s)}}))}))}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new i("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e),this.utilityNetwork&&this.reset(),this.utilityNetwork=null,this.loadUtilityNetwork().then((e=>{e&&this.selectTracesOnLoad()}))}addFlagByHit(e,t){const r=!!this.view&&this.view.popupEnabled,s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise(((i,a)=>{r&&s(!1),this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",(l=>{if("complete"===l.state){const o=this._getGraphicLayer(B);o&&l.graphic&&o.remove(l.graphic),this.queryFlagByHitTest(l,e,t).then((r=>{this.emit("add-flag-complete",{type:e,symbol:t}),i(r)})).catch((r=>{this.emit("add-flag-error",{type:e,symbol:t}),a(r)})).finally((()=>{r&&s(!0),this._clickHandler?.remove()}))}})),this._sketchViewModel.create("point"),this.emit("add-flag",{type:e})}))}addNonspatialTraceLocation(e,t){const r=this._getDisplayField(e),s=this.utilityNetwork?.getTerminalConfiguration(e),i={terminalId:null,isFilterBarrier:!1,allTerminals:s,selectedTerminals:[s?s.terminals[0].id||null:1],displayValue:r};e.attributes={...e.attributes,...i};const a=e.attributes.hasOwnProperty("GLOBALID")?e.attributes.GLOBALID:e.attributes.globalid;if(!this._flags.some((e=>e.globalId===a&&e.type===t))){const r=this._createFlagProperty(e,t,null);this._flags.push(r),this.emit("add-flag-complete",{type:t})}this.emit("add-flag",{type:t})}async addFlagsOnLoad(){if(this._flags.length>0)return[];await o((()=>null!=this.view&&!this.view.updating));return(await Promise.all(this.flags.map((async e=>{if(!e.mapPoint)return null;const{type:t}=e,r=e.mapPoint.clone(),s="barrier"===t?L:T,i={graphic:this.graphicHandler.makeGraphic(r,s),state:"complete",tool:"point",toolEventInfo:null,type:"create"};try{return await this.queryFlagByHitTest(i,e.type,null),this.emit("add-flag-complete",{type:t}),null}catch(a){return this.emit("add-flag-error",{type:t}),"barrier"===t?"barrier":"starting-point"}})))).filter((e=>!e))}async addResultAreaToMap(e,t){if(this.view)if(e.resultArea.show=!0,t)this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t});else if(e.results){const t=await this.createResultAreaGraphic(e);t&&(e.resultAreaGraphic=t,this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s&&this.utilityNetwork)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(V)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))})),this._flags=r}async callTrace(){const e=this.traces.filter((e=>e.selected));return!!e.length&&(this.traceResults.length>0&&this.traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this.traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const r=e,s=new I({gdbVersion:this.utilityNetwork?.gdbVersion,moment:this.utilityNetwork?.historicMoment,namedTraceConfigurationGlobalId:r.globalId,outSpatialReference:null,resultTypes:null,traceType:r.traceType,traceLocations:this._flags,traceConfiguration:null});await this.executeTrace(r,this.utilityNetwork?.networkServiceUrl,s).then((e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea&&this.createResultAreaGraphic(r).then((e=>{e&&(r.resultAreaGraphic=e,r.resultArea?.show&&this.addResultAreaToMap(r,r.resultAreaGraphic))})))}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}cancelAddFlagByHit(){this._sketchViewModel.cancel()}changeResultAreaColor(e,t){if(!e.resultArea)return;e.resultArea.color=t;const r=this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map);e.resultAreaGraphic&&(e.resultAreaGraphic.symbol=r)}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach((r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)})),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]},t=this.traces.filter((e=>e.selected));t.length||(e.status=!1,e.issues.push("noTracesSelected"));this._flags.some((e=>"starting-point"===e.type))||(e.status=!1,e.issues.push("noStartingPoints"));return this._flags.filter((e=>null!==e.allTerminals)).some((e=>!e.selectedTerminals.length))&&(e.status=!1,e.issues.push("noTerminalSelected")),e}checkSelectionExist(){return this._highlightHandler.some((e=>e))}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter((t=>t.trace.globalId===e.globalId));r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if(s="convexhull"===this.resultAreaProperties?.type?1===t.length&&(h(t[0])||u(t[0])&&1===t[0].points.length)?this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0):this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0),!s)return;if(Array.isArray(s)){for(const t of s){const r=this.getResultAreaAttributes(e,t),s=this._resultAreaHandler?.createResultAreaGraphic(t,r,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);if(s)return s}return}const i=this.getResultAreaAttributes(e,s);return this._resultAreaHandler?.createResultAreaGraphic(s,i,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color)}async createResultAreaGraphic(e){if(e.results){const t=await this._createResultAreaInputGeometry(e.results);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance),s=this.createResultAreaGeometries(e,t,r);return this.emit("create-result-area",{graphic:s}),s}}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,v(t,r,{timeout:this._traceTimeout}).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}async getNonspatialTraceLocationInitialFeature(){return new Promise(((e,t)=>{this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",(async r=>{if("complete"!==r.state)return;const s=this._getGraphicLayer(B);s&&r.graphic&&s.remove(r.graphic);const i=this.view?.toScreen(r.graphic?.geometry);if(!i)return;const a=await(this.view?.hitTest(i));if(a?.results.length){const r=a.results.find((e=>"graphic"===e.type&&this.utilityNetwork?.isUtilityLayer(e.layer)));r?e(r):t(null)}})),this._sketchViewModel.create("point")}))}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));const l=this.utilityNetwork?this.utilityNetwork.gdbVersion:this.gdbVersion;return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:l??void 0,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:r?this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit):0}}getValidSources(){let e=[];const t=this.utilityNetwork?.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}groupResultsByNetworkSource(e){return 0===e.length?[]:this._groupBy(e,"networkSourceId")}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof w){try{const t=e.map;await t.loadAll()}finally{this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await x(r))throw new i("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll()}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)})),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])})),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return null;const s=this.utilityNetwork.getObjectIdsFromElements(e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter((e=>e?.parsedUrl?.path===s[0].layerUrl)).filter(m)??[];this._getUniqueMapLayerViews(t).filter((({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl)).forEach((({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)}));const l=(await Promise.all(a.map((async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await _(s,!1);return a})))).filter((({featureSet:e})=>e.features.length>0));return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then((e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach((e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter((e=>e.globalId===a)).length<=0){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(U)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}else if(null!==r.attributes.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(U)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}})),this._flags=s,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(V)?.graphics;e.graphicEnabled=!1;const s=r?.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId));s?.forEach((e=>{this._getGraphicLayer(V)?.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){if(e.resultArea){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach((r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}})),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}removeClickHandler(){this._clickHandler&&(this._sketchViewModel.cancel(),this._clickHandler.remove())}reset(){this._flags=[],this.traceResults=[];const e=[...this.traces];e.forEach((e=>{e.selected=!1})),this.traces=e,this.view&&(this._getGraphicLayer(B)?.removeAll(),this._getGraphicLayer(U)?.removeAll(),this._getGraphicLayer(V)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}),this.emit("reset"))}selectFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return;const r=this.utilityNetwork.getObjectIdsFromElements(e);this._getUniqueMapLayerViews(t).forEach((e=>{j(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&E(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this.groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this.traces];r.forEach((r=>{t===r.globalId&&(r.selected=e)})),this.traces=r}selectTracesOnLoad(){this.utilityNetwork?.hasOwnProperty("sharedNamedTraceConfigurations")&&(this.traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this.traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}async _createResultAreaInputGeometry(e){if(null!=e.aggregatedGeometry)return this._geometryHandler.mergeAggregatedToGeometries(e.aggregatedGeometry);const t=this.groupResultsByNetworkSource(e.elements),r=[];for(const s in t)r.push(this.queryFeaturesById(t[s]));try{const e=await Promise.all(r),t=[];for(const r of e)if(r)for(const e of r)for(const r of e.featureSet.features)r.geometry&&t.push(r.geometry);return t}catch{return[]}}_loadUNSupportItems(){if(!this.utilityNetwork)return;const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(B),this._createGraphicLayer(U),this._createGraphicLayer(V),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork),this._sketchViewModel=this.graphicHandler.initializeSketch(this.view,this._getGraphicLayer(B),this._validUNLayers)}_getUniqueMapLayerViews(e){const t=[],r=e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).toArray(),s=e=>{for(const r of e.layerViews)D(r)?s(r):t.push(r)};return r.forEach((e=>{switch(e.layer.type){case"group":D(e)&&s(e);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((r=>{const s=new k({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}));else{const r=new k({globalId:e.globalId,percentAlong:e.percentAlong,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.layer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach((e=>{e.code===t&&(r=e.name)}))}else if(null!=e.types&&e.types.length>0){const s=e.types.filter((e=>e.id===t));s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&C(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===r));e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}get _uniqueFlagId(){return this._flagId++}_groupBy(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})}async _lookupFlagByHit(e){const t=e.graphic?.geometry,r=[];if(t&&h(t)&&this.view){const s=this.view.toScreen(t);if(s){const t=await this.view.hitTest(s,{include:this._validUNLayers});if(t?.results.length){const s=t.results.find((e=>null!==e.layer));if(s.graphic?.geometry)if("polyline"===s.graphic.geometry.type){const t={terminalId:null,isFilterBarrier:!1,allTerminals:null,selectedTerminals:null,percentAlong:this._geometryHandler.getPercentageAlong(s.graphic.geometry,e.graphic?.geometry,s.graphic.geometry.spatialReference),displayValue:this._getDisplayField(s.graphic),mapPoint:s.mapPoint};s.graphic.attributes={...s.graphic.attributes,...t},r.push(s)}else if(("point"===s.graphic.geometry.type||"polygon"===s.graphic.geometry.type)&&this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(s.graphic),t=this._getDisplayField(s.graphic),i={terminalId:e?e.terminals[0].id||null:1,isFilterBarrier:!1,allTerminals:e??null,selectedTerminals:[e?e.terminals[0].id||null:1],percentAlong:null,displayValue:t,mapPoint:s.mapPoint};s.graphic.attributes={...s.graphic.attributes,...i},r.push(s)}}}}return r}_createFlagProperty(e,t,r){const s=new k;s.terminalId=e.attributes.terminalId,s.isFilterBarrier=e.attributes.isFilterBarrier,s.percentAlong=e.attributes.percentAlong,s.globalId=e.attributes.globalid||e.attributes.GLOBALID,s.type=t;const i=s;return i.details=e,i.mapGraphic=r,i.id=this._uniqueFlagId,i.allTerminals=e.attributes.allTerminals,i.selectedTerminals=e.attributes.selectedTerminals,i.displayValue=e.attributes.displayValue,i.mapPoint=e.attributes.mapPoint,i}async _populateOutfields(){if(!this.view)return;const{map:e}=this.view,t=this.getValidSources(),r=e=>{"group"===e.type?e.layers.forEach((e=>{M(e)&&r(e)})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])};for(const s of e.layers)M(s)&&r(s)}_removeGraphic(e){this._getGraphicLayer(U)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const t=new g({id:e,internal:!0,listMode:"hide",title:e});G(this.view,t)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&O(r))return r}return null}};e([n()],q.prototype,"_activeProgress",void 0),e([n()],q.prototype,"_flags",void 0),e([n()],q.prototype,"traces",void 0),e([n()],q.prototype,"defaultGraphicColor",void 0),e([n()],q.prototype,"enableResultArea",void 0),e([n()],q.prototype,"flags",void 0),e([n()],q.prototype,"gdbVersion",void 0),e([n()],q.prototype,"messages",void 0),e([n()],q.prototype,"messagesUnits",void 0),e([n()],q.prototype,"resultAreaProperties",null),e([n()],q.prototype,"selectedTraces",void 0),e([n()],q.prototype,"selectOnComplete",void 0),e([n()],q.prototype,"showGraphicsOnComplete",void 0),e([n()],q.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],q.prototype,"state",null),e([n()],q.prototype,"traceResults",void 0),e([n()],q.prototype,"utilityNetwork",void 0),e([n({value:null})],q.prototype,"view",null),q=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],q);const z=q;export{z as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{id as t}from"../../kernel.js";import r from"../../core/Collection.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import l from"../../core/Logger.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{isPoint as h,isMultipoint as u}from"../../geometry/support/jsonUtils.js";import{fetchMessageBundle as p}from"../../intl/messages.js";import d from"../../layers/FeatureLayer.js";import g from"../../layers/GraphicsLayer.js";import y from"../../layers/support/CodedValueDomain.js";import{isFeatureLayer as m,getOwningPortalUrl as f}from"../../layers/support/layerUtils.js";import w from"../../networks/UtilityNetwork.js";import{getFeaturesFromLayers as _}from"../../networks/support/utils.js";import b from"../../portal/Portal.js";import{hasUserTypeExtension as A}from"../../portal/support/utils.js";import{trace as v}from"../../rest/networks/trace.js";import k from"../../rest/networks/support/TraceLocation.js";import I from"../../rest/networks/support/TraceParameters.js";import{addUniqueLayer as G}from"../../views/draw/support/layerUtils.js";import{GeometryHandler as R}from"./support/GeometryHandler.js";import{GraphicHandler as F,barrierColor as L,startingPointColor as T}from"./support/GraphicHandler.js";import{ResultAreaHandler as H}from"./support/ResultAreaHandler.js";import{UtilityHelper as N}from"./support/UtilityHelper.js";const S=()=>p("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace"),P=()=>p("esri/core/t9n/Units"),U=`utility-network-trace-flags-${Date.now()}`,V=`utility-network-trace-results-${Date.now()}`,B=`utility-network-trace-sketch-${Date.now()}`;function C(e){return e instanceof y}function E(e){return"feature"===e.layer.type||"subtype-group"===e.layer.type}function j(e){return"layer"in e}function D(e){return void 0!==e.layerViews}function O(e){return"graphics"===e.type}function M(e){return"feature"===e.type||"subtype-group"===e.type||"group"===e.type}async function x(e){const t=new d({url:e.networkSystemLayers.dirtyAreasLayerUrl});await t.load();const r=t.version;if(Number(r)<=11.1){const t=await f(e.layerUrl),r=new b({url:t});await r.load();const s=r?.user?.username;return!!s&&A(r,s,"utilityNetwork")}return!0}let q=class extends a.EventedAccessor{constructor(e){super(e),this._activeProgress=!1,this._clickHandler=null,this._flags=[],this._flagId=0,this._geometryHandler=null,this._highlightHandler=[],this._resultAreaHandler=null,this._sketchViewModel=null,this._traceTimeout=6e5,this._utilityHelper=new N,this._validUNLayers=[],this._watchHandler=null,this.traces=[],this.graphicHandler=null,this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.enableResultArea=!1,this.flags=[],this.gdbVersion="sde.DEFAULT",this.messages=null,this.messagesUnits=null,this.defaultResultAreaProperties={type:"convexhull",distance:10,unit:"meters",areaUnit:"square-meters",color:{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},show:!1},this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.traceResults=[],this.utilityNetwork=null}initialize(){s(l.getLogger(this),"gdbVersion will be removed and the gdbVersion of the UtilityNetwork will be consumed directly.",{replacement:"UtilityNetwork.gdbVersion",version:"4.31"}),this._geometryHandler=new R,this.graphicHandler=new F,this._resultAreaHandler=new H;(async()=>{const[e,t]=await Promise.all([S(),P()]);this.set({messages:e,messagesUnits:t})})()}destroy(){this.view=null}get resultAreaProperties(){return this.defaultResultAreaProperties}set resultAreaProperties(e){this._set("resultAreaProperties",{...this.defaultResultAreaProperties,...e}),this.graphicHandler.addCustomColor(this.resultAreaProperties.color),this.traceResults.forEach((t=>{const r=t.resultArea?.show;t.resultArea={...this.defaultResultAreaProperties,...e},this.removeResultAreaFromMap(t),this.enableResultArea&&this.createResultAreaGraphic(t).then((s=>{if(s){t.resultAreaGraphic=s;const i=e?.show??r;t.resultArea&&(t.resultArea.show=i),i&&this.addResultAreaToMap(t,s)}}))}))}get state(){return this.view?.ready?"ready":"loading"}get view(){return this._get("view")}set view(e){e&&"2d"!==e.type&&l.getLogger(this).error(new i("view:invalid-view","SceneView is not supported",{view:e})),this._set("view",e),this.utilityNetwork&&this.reset(),this.utilityNetwork=null,this.loadUtilityNetwork().then((e=>{e&&this.selectTracesOnLoad()}))}addFlagByHit(e,t){const r=!!this.view&&this.view.popupEnabled,s=e=>{this.view?.popup&&(this.view.popupEnabled=e)};return new Promise(((i,a)=>{r&&s(!1),this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",(l=>{if("complete"===l.state){const o=this._getGraphicLayer(B);o&&l.graphic&&o.remove(l.graphic),this.queryFlagByHitTest(l,e,t).then((r=>{this.emit("add-flag-complete",{type:e,symbol:t}),i(r)})).catch((r=>{this.emit("add-flag-error",{type:e,symbol:t}),a(r)})).finally((()=>{r&&s(!0),this._clickHandler?.remove()}))}})),this._sketchViewModel.create("point"),this.emit("add-flag",{type:e})}))}addNonspatialTraceLocation(e,t){const r=this._getDisplayField(e),s=this.utilityNetwork?.getTerminalConfiguration(e),i={terminalId:null,isFilterBarrier:!1,allTerminals:s,selectedTerminals:[s?s.terminals[0].id||null:1],displayValue:r};e.attributes={...e.attributes,...i};const a=e.attributes.hasOwnProperty("GLOBALID")?e.attributes.GLOBALID:e.attributes.globalid;if(!this._flags.some((e=>e.globalId===a&&e.type===t))){const r=this._createFlagProperty(e,t,null);this._flags.push(r),this.emit("add-flag-complete",{type:t})}this.emit("add-flag",{type:t})}async addFlagsOnLoad(){if(this._flags.length>0)return[];await o((()=>null!=this.view&&!this.view.updating));return(await Promise.all(this.flags.map((async e=>{if(!e.mapPoint)return null;const{type:t}=e,r=e.mapPoint.clone(),s="barrier"===t?L:T,i={graphic:this.graphicHandler.makeGraphic(r,s),state:"complete",tool:"point",toolEventInfo:null,type:"create"};try{return await this.queryFlagByHitTest(i,e.type,null),this.emit("add-flag-complete",{type:t}),null}catch(a){return this.emit("add-flag-error",{type:t}),"barrier"===t?"barrier":"starting-point"}})))).filter((e=>!e))}async addResultAreaToMap(e,t){if(this.view)if(e.resultArea.show=!0,t)this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t});else if(e.results){const t=await this.createResultAreaGraphic(e);t&&(e.resultAreaGraphic=t,this._resultAreaHandler?.addResultAreaToMap(t,this.view.map),this.emit("add-result-area",{graphic:t}))}}async addResultGraphicToView(e,t){const{view:r}=this,{results:s}=e;if(r&&s&&this.utilityNetwork)for(const i in s.aggregatedGeometry)if("line,multipoint,polygon".includes(i)){const a=i,l=s.aggregatedGeometry[a];if(null!=l){l.spatialReference=this.utilityNetwork.spatialReference,e.graphicEnabled=!0;const s=await this._geometryHandler.projectGeometry(l,r.spatialReference),i={globalid:e.trace.globalId};if(null!==s){const e=this.graphicHandler.makeGraphic(s,t.color,i,r.spatialReference);this._getGraphicLayer(V)?.add(e)}}}}addTerminal(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&(t.selectedTerminals?.includes(parseInt(e,10))||r.selectedTerminals?.push(parseInt(e,10)))})),this._flags=r}async callTrace(){const e=this.traces.filter((e=>e.selected));return!!e.length&&(this.traceResults.length>0&&this.traceResults.forEach((e=>{this.removeResultGraphicFromView(e)})),this.traceResults=[],this.removeSelection(),await Promise.all(e.map((async(e,t)=>{const r=e,s=new I({gdbVersion:this.utilityNetwork?.gdbVersion,moment:this.utilityNetwork?.historicMoment,namedTraceConfigurationGlobalId:r.globalId,outSpatialReference:null,resultTypes:null,traceType:r.traceType,traceLocations:this._flags,traceConfiguration:null});await this.executeTrace(r,this.utilityNetwork?.networkServiceUrl,s).then((e=>{if(e.hasOwnProperty("results")){const r={...e};if(null!==r.results){r.resultArea={...this.resultAreaProperties};const e=[...r.results.elements];r.results.elements.length=0;const s=new Map;for(const t of e)s.has(t.globalId)||(s.set(t.globalId,!0),r.results.elements.push(t));const i=[...this.traceResults];i.splice(t,0,r),this.traceResults=i,null!==r.results&&(this.selectOnComplete&&this.mergeSelection(!0,r.trace),this.showGraphicsOnComplete&&this.addResultGraphicToView(r,r.graphicColor),this.enableResultArea&&this.createResultAreaGraphic(r).then((e=>{e&&(r.resultAreaGraphic=e,r.resultArea?.show&&this.addResultAreaToMap(r,r.resultAreaGraphic))})))}else{const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}this._activeProgress=!1}else{this._activeProgress=!1;const r=[...this.traceResults];r.splice(t,0,e),this.traceResults=r}})).catch((e=>{throw this._activeProgress=!1,e}))}))),!0)}cancelAddFlagByHit(){this._sketchViewModel.cancel()}changeResultAreaColor(e,t){if(!e.resultArea)return;e.resultArea.color=t;const r=this._resultAreaHandler?.changeResultAreaColor(e.trace.globalId,t,this.view.map);e.resultAreaGraphic&&(e.resultAreaGraphic.symbol=r)}changeResultGraphicColor(e,t){const r=[...this.traceResults];r.length>0&&r.forEach((r=>{r.trace.globalId===t.trace.globalId&&(r.graphicColor=e,r.graphicEnabled=!0)})),this.traceResults=r,this.removeResultGraphicFromView(t),this.addResultGraphicToView(t,e)}changeFlagSymbol(e,t){this._flags.length>0&&this._flags.forEach((r=>{r.type===e&&t&&r.mapGraphic&&(r.mapGraphic.symbol=t)}))}checkCanTrace(){const e={status:!0,issues:[]},t=this.traces.filter((e=>e.selected));t.length||(e.status=!1,e.issues.push("noTracesSelected"));this._flags.some((e=>"starting-point"===e.type))||(e.status=!1,e.issues.push("noStartingPoints"));return this._flags.filter((e=>null!==e.allTerminals)).some((e=>!e.selectedTerminals.length))&&(e.status=!1,e.issues.push("noTerminalSelected")),e}checkSelectionExist(){return this._highlightHandler.some((e=>e))}clearResult(e){if(!this.view)return;let t=this.traceResults;if(t.length>0){const r=t.filter((t=>t.trace.globalId===e.globalId));r.length>0&&(this.removeResultGraphicFromView(r[0]),this.removeResultAreaFromMap(r[0])),t=t.filter((t=>t.trace.globalId!==e.globalId))}this.traceResults=t,0===t.length?(this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]})):this.mergeSelection(!1,e)}createResultAreaGeometries(e,t,r){if(!this.view||!this.resultAreaProperties)return;let s;if(s="convexhull"===this.resultAreaProperties?.type?1===t.length&&(h(t[0])||u(t[0])&&1===t[0].points.length)?this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0):this._resultAreaHandler?.createConvexHull(t,e.resultArea?.distance,e.resultArea?.unit):this._resultAreaHandler?.createBuffer(t,r,e.resultArea?.unit,!0),!s)return;if(Array.isArray(s)){for(const t of s){const r=this.getResultAreaAttributes(e,t),s=this._resultAreaHandler?.createResultAreaGraphic(t,r,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color);if(s)return s}return}const i=this.getResultAreaAttributes(e,s);return this._resultAreaHandler?.createResultAreaGraphic(s,i,e.resultArea?.areaUnit,this.messages,this.messagesUnits,e.resultArea?.color)}async createResultAreaGraphic(e){if(e.results){const t=await this._createResultAreaInputGeometry(e.results);if(t.length>0){const r=Array(t.length).fill(e.resultArea?.distance),s=this.createResultAreaGeometries(e,t,r);return this.emit("create-result-area",{graphic:s}),s}}}executeTrace(e,t,r){const s=this._processFlags(r.traceLocations);return r.traceLocations=s,v(t,r,{timeout:this._traceTimeout}).then((t=>({trace:e,results:t,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:"success",date:new Date}))).catch((t=>({trace:e,results:null,selectionEnabled:!1,graphicEnabled:!1,graphicColor:this.defaultGraphicColor,status:t.message,date:new Date})))}async getNonspatialTraceLocationInitialFeature(){return new Promise(((e,t)=>{this._clickHandler?.remove(),this._clickHandler=this._sketchViewModel.on("create",(async r=>{if("complete"!==r.state)return;const s=this._getGraphicLayer(B);s&&r.graphic&&s.remove(r.graphic);const i=this.view?.toScreen(r.graphic?.geometry);if(!i)return;const a=await(this.view?.hitTest(i));if(a?.results.length){const r=a.results.find((e=>"graphic"===e.type&&this.utilityNetwork?.isUtilityLayer(e.layer)));r?e(r):t(null)}})),this._sketchViewModel.create("point")}))}getResultAreaAttributes(e,r){const{messages:s}=this,i=[],a=[];this._flags.forEach((e=>{const t=e.displayValue?.field+":"+e.displayValue?.value+";"+s.attributeStrings.globalid+":"+e.globalId+";"+s.attributeStrings.terminalid+":"+e.terminalId+";"+s.attributeStrings.x+":"+e.mapPoint?.x+";"+s.attributeStrings.y+":"+e.mapPoint?.y;"starting-point"===e.type?i.push(t):a.push(t)}));const l=this.utilityNetwork?this.utilityNetwork.gdbVersion:this.gdbVersion;return{traceId:e.trace.globalId,traceName:e.trace.title,traceDescription:e.trace.description??"",startingPoints:i.toString(),barriers:a.toString(),version:l??void 0,username:t.credentials[0].userId,date:e.date,elementCount:e.results?.elements.length,functionResult:JSON.stringify(e.results?.globalFunctionResults),areaStatistic:r?this._geometryHandler.calculateArea(r,e.resultArea?.areaUnit):0}}getValidSources(){let e=[];const t=this.utilityNetwork?.dataElement?.domainNetworks??[];for(const r of t)e=e.concat(r.junctionSources),e=e.concat(r.edgeSources);return e}groupResultsByNetworkSource(e){return 0===e.length?[]:this._groupBy(e,"networkSourceId")}async loadUtilityNetwork(){const{view:e}=this;if(!e)return null;if(await e.when(),this.utilityNetwork){if(this.utilityNetwork.loaded||await this.utilityNetwork.load(),this.utilityNetwork instanceof w){try{const t=e.map;await t.loadAll()}catch(s){if("layer:unsupported-layer-type"!==s.name)throw s}finally{this._loadUNSupportItems()}return this.utilityNetwork}return null}const t=e.map,r=t.utilityNetworks?.at(0);if(r){if(await r.load(),this.utilityNetwork=r,!await x(r))throw new i("utility-network:no-user-type-extension","User type extension not found");try{await t.loadAll()}catch(s){if("layer:unsupported-layer-type"!==s.name)throw s}finally{this._loadUNSupportItems()}return r}return null}manageFilterBarrier(e,t){const r=[...this._flags];r.forEach((r=>{r.globalId===t.globalId&&"barrier"===t.type&&r.id===t.id&&(r.isFilterBarrier=e)})),this._flags=r}mergeSelection(e,t){let r=[];const s=[...this.traceResults],i=t.globalId;s.forEach((t=>{i===t.trace.globalId&&(t.selectionEnabled=e),t.selectionEnabled&&null!==t.results?.elements&&(r=[...r,...t.results?.elements??[]])})),this.selectResults([...new Set(r)])}async queryFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return null;const s=this.utilityNetwork.getObjectIdsFromElements(e),i={layerUrl:s[0].layerUrl,objectIds:s[0].objectIds,outFields:["*"]},a=t.map?.allTables.toArray().filter((e=>e?.parsedUrl?.path===s[0].layerUrl)).filter(m)??[];this._getUniqueMapLayerViews(t).filter((({layer:e})=>e?.parsedUrl?.path===s[0].layerUrl)).forEach((({layer:e})=>{"feature"!==e.type&&"subtype-group"!==e.type||a.push(e)}));const l=(await Promise.all(a.map((async e=>{const s={layers:new r([e]),layerInfos:[i],returnGeometry:!0,outSpatialReference:t.spatialReference},[a]=await _(s,!1);return a})))).filter((({featureSet:e})=>e.features.length>0));return l.length>0?l:null}queryFlagByHitTest(e,t,r){return this._lookupFlagByHit(e).then((e=>{const{view:s}=this;if(!s)return!1;if(e.length>0){const s=[...this._flags],i=r;return e.forEach((e=>{const r=e.graphic,a=r.attributes.hasOwnProperty("GLOBALID")?r.attributes.GLOBALID:r.attributes.globalid;if(s.filter((e=>e.globalId===a)).length<=0){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(U)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}else if(null!==r.attributes.percentAlong){const e=this.graphicHandler.getFlagGraphic(r.attributes.mapPoint,t,r,i);this._getGraphicLayer(U)?.add(e);const a=this._createFlagProperty(r,t,e);s.push(a)}})),this._flags=s,!0}return!1}))}removeResultGraphicFromView(e){const{view:t}=this;if(!t)return;const r=this._getGraphicLayer(V)?.graphics;e.graphicEnabled=!1;const s=r?.filter((t=>t.attributes[t.attributes.hasOwnProperty("GLOBALID")?"GLOBALID":"globalid"]===e.trace.globalId));s?.forEach((e=>{this._getGraphicLayer(V)?.remove(e)}))}removeFlag(e){const t=this._flags.filter((t=>{if(t.id!==e.id)return t}));this._removeGraphic(e),this._flags=t}removeAllResultAreaGraphics(){this._resultAreaHandler?.removeAllResultAreaGraphics(this.view.map)}removeResultAreaFromMap(e){if(e.resultArea){e.resultArea.show=!1;const t=this._resultAreaHandler?.removeResultArea(e.trace.globalId,this.view?.map);t&&this.emit("remove-result-area",{graphic:t})}}removeSelection(){this._highlightHandler.forEach((e=>{e&&e.remove()})),this._highlightHandler=[]}removeTerminal(e,t){const r=[...this._flags];r.forEach((r=>{if(r.globalId===t.globalId&&t.selectedTerminals?.includes(parseInt(e,10))){const s=t.selectedTerminals.indexOf(parseInt(e,10));r.selectedTerminals?.splice(s,1)}})),this._flags=r}removeFlagsOnLoadWatcher(){this._watchHandler&&null!==this._watchHandler&&this._watchHandler.remove()}removeClickHandler(){this._clickHandler&&(this._sketchViewModel.cancel(),this._clickHandler.remove())}reset(){this._flags=[],this.traceResults=[];const e=[...this.traces];e.forEach((e=>{e.selected=!1})),this.traces=e,this.view&&(this._getGraphicLayer(B)?.removeAll(),this._getGraphicLayer(U)?.removeAll(),this._getGraphicLayer(V)?.removeAll(),this.removeAllResultAreaGraphics(),this.removeSelection(),this.emit("clear-selection",{resultSet:[]}),this.emit("reset"))}selectFeaturesById(e){const{view:t}=this;if(!t||!this.utilityNetwork)return;const r=this.utilityNetwork.getObjectIdsFromElements(e);this._getUniqueMapLayerViews(t).forEach((e=>{j(e)&&e.layer?.parsedUrl?.path===r[0].layerUrl&&E(e)&&this._highlightHandler.push(e.highlight(r[0].objectIds))}))}selectResults(e){if(e.length>0){this.removeSelection();const t=this.groupResultsByNetworkSource(e),r=[];for(const e in t)this.selectFeaturesById(t[e]),r.push(this.queryFeaturesById(t[e]));Promise.all(r).then((e=>{this.emit("select-features",{resultSet:e})}))}else this.removeSelection(),this.emit("clear-selection",{resultSet:[]})}selectTraces(e,t){const r=[...this.traces];r.forEach((r=>{t===r.globalId&&(r.selected=e)})),this.traces=r}selectTracesOnLoad(){this.utilityNetwork?.hasOwnProperty("sharedNamedTraceConfigurations")&&(this.traces=[...this.utilityNetwork.sharedNamedTraceConfigurations],this.traces.forEach((e=>{e.selected=!1,this.selectedTraces.includes(e.globalId)&&(e.selected=!0)})))}zoomToAsset(e){this.view?.goTo(e).catch((e=>console.error(e)))}async _createResultAreaInputGeometry(e){if(null!=e.aggregatedGeometry)return this._geometryHandler.mergeAggregatedToGeometries(e.aggregatedGeometry);const t=this.groupResultsByNetworkSource(e.elements),r=[];for(const s in t)r.push(this.queryFeaturesById(t[s]));try{const e=await Promise.all(r),t=[];for(const r of e)if(r)for(const e of r)for(const r of e.featureSet.features)r.geometry&&t.push(r.geometry);return t}catch{return[]}}_loadUNSupportItems(){if(!this.utilityNetwork)return;const{map:e}=this.view,{messages:t}=this;this._populateOutfields(),this._createGraphicLayer(B),this._createGraphicLayer(U),this._createGraphicLayer(V),this._resultAreaHandler?.createGraphicLayer(e,t?.alertsStrings.genericResultHeader),this._validUNLayers=this._utilityHelper.getValidUtilityNetworkLayers(e,this.utilityNetwork),this._sketchViewModel=this.graphicHandler.initializeSketch(this.view,this._getGraphicLayer(B),this._validUNLayers)}_getUniqueMapLayerViews(e){const t=[],r=e.layerViews.filter((({layer:{type:e}})=>"feature"===e||"group"===e||"subtype-group"===e)).toArray(),s=e=>{for(const r of e.layerViews)D(r)?s(r):t.push(r)};return r.forEach((e=>{switch(e.layer.type){case"group":D(e)&&s(e);break;case"subtype-group":t.push(e);break;default:t.some((t=>t.layer.id===e.layer.id))||t.push(e)}})),t}_processFlags(e){const t=[];return e.forEach((e=>{if(null!==e.selectedTerminals&&e.selectedTerminals.length>0)e.selectedTerminals.forEach((r=>{const s=new k({globalId:e.globalId,percentAlong:e.percentAlong,terminalId:r,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(s)}));else{const r=new k({globalId:e.globalId,percentAlong:e.percentAlong,type:e.type,isFilterBarrier:e.isFilterBarrier});t.push(r)}})),t}_getDisplayField(e){return"subtype-sublayer"===e?.layer?.type?this._getDisplayFieldBySublayer(e):this._getDisplayFieldByFeatureLayer(e)}_getDisplayFieldBySublayer(e){let t="",r="";const s=e.layer;t=this._checkParentForData(s,"displayField");for(const i in e.attributes){const a=i.toLowerCase();a===t?.toLowerCase()?(r=e.attributes[i],"assetgroup"===a||"assettype"===a?r=this._checkSubtype(s,s.subtypeCode):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))):(r=this._checkDomain(s.fields,i,r),"string"==typeof r&&(r=this._defaultDisplayField(r,s)))}return{field:t,value:r.toString()}}_getDisplayFieldByFeatureLayer(e){const t=e.layer;let r=t.displayField,s="";for(const i in e.attributes){const a=i.toLowerCase();if(a===r?.toLowerCase())if(s=e.attributes[i],"assetgroup"===a||"assettype"===a){let a=e.attributes[t.typeIdField.toUpperCase()];a||(a=e.attributes[t.typeIdField.toLowerCase()]),r=t.typeIdField,s=this._checkSubtype(t,a),""===r&&(t.templates&&t.templates.length>0?(r=t.templates[0]?.name,s=t.templates[0]?.name):(r=t.displayField,s=e.attributes[i]))}else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t));else s=this._checkDomain(t.fields,i,s),"string"==typeof s&&(s=this._defaultDisplayField(s,t))}return{field:r,value:s?s.toString():""}}_checkSubtype(e,t){let r=t;if("subtype-sublayer"===e.type){const s=this._checkParentForData(e,"subtypes");s?.length>0&&s.forEach((e=>{e.code===t&&(r=e.name)}))}else if(null!=e.types&&e.types.length>0){const s=e.types.filter((e=>e.id===t));s.length>0&&(r=s[0].name)}return r}_checkDomain(e,t,r){let s=r;const i=e.filter((e=>e.name.toLowerCase()===t.toLowerCase()));if(i.length>0&&C(i[0].domain)&&i[0].domain?.codedValues){const e=i[0].domain.codedValues.filter((({code:e})=>e===r));e.length>0&&(s=e[0].name)}return s}_checkParentForData(e,t){return e.parent?.[t]??null}_defaultDisplayField(e,t){return e.trim()?e:t.templates&&t.templates?.length>0?t.templates[0].name:t.title}get _uniqueFlagId(){return this._flagId++}_groupBy(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})}async _lookupFlagByHit(e){const t=e.graphic?.geometry,r=[];if(t&&h(t)&&this.view){const s=this.view.toScreen(t);if(s){const t=await this.view.hitTest(s,{include:this._validUNLayers});if(t?.results.length){const s=t.results.find((e=>null!==e.layer));if(s.graphic?.geometry)if("polyline"===s.graphic.geometry.type){const t={terminalId:null,isFilterBarrier:!1,allTerminals:null,selectedTerminals:null,percentAlong:this._geometryHandler.getPercentageAlong(s.graphic.geometry,e.graphic?.geometry,s.graphic.geometry.spatialReference),displayValue:this._getDisplayField(s.graphic),mapPoint:s.mapPoint};s.graphic.attributes={...s.graphic.attributes,...t},r.push(s)}else if(("point"===s.graphic.geometry.type||"polygon"===s.graphic.geometry.type)&&this.utilityNetwork){const e=this.utilityNetwork.getTerminalConfiguration(s.graphic),t=this._getDisplayField(s.graphic),i={terminalId:e?e.terminals[0].id||null:1,isFilterBarrier:!1,allTerminals:e??null,selectedTerminals:[e?e.terminals[0].id||null:1],percentAlong:null,displayValue:t,mapPoint:s.mapPoint};s.graphic.attributes={...s.graphic.attributes,...i},r.push(s)}}}}return r}_createFlagProperty(e,t,r){const s=new k;s.terminalId=e.attributes.terminalId,s.isFilterBarrier=e.attributes.isFilterBarrier,s.percentAlong=e.attributes.percentAlong,s.globalId=e.attributes.globalid||e.attributes.GLOBALID,s.type=t;const i=s;return i.details=e,i.mapGraphic=r,i.id=this._uniqueFlagId,i.allTerminals=e.attributes.allTerminals,i.selectedTerminals=e.attributes.selectedTerminals,i.displayValue=e.attributes.displayValue,i.mapPoint=e.attributes.mapPoint,i}async _populateOutfields(){if(!this.view)return;const{map:e}=this.view,t=this.getValidSources(),r=e=>{"group"===e.type?e.layers.forEach((e=>{M(e)&&r(e)})):t.some((t=>t.layerId===e.layerId))&&e.fields.some((e=>"assetgroup"===e.name.toLowerCase()))&&(e.outFields=["assetgroup","assettype","globalid","objectid"])};for(const s of e.layers)M(s)&&r(s)}_removeGraphic(e){this._getGraphicLayer(U)?.remove(e.mapGraphic)}_createGraphicLayer(e){const{map:t}=this.view;if(!t.findLayerById(e)){const t=new g({id:e,internal:!0,listMode:"hide",title:e});G(this.view,t)}}_getGraphicLayer(e){const{map:t}=this.view;if(t){const r=t.findLayerById(e);if(r&&O(r))return r}return null}};e([n()],q.prototype,"_activeProgress",void 0),e([n()],q.prototype,"_flags",void 0),e([n()],q.prototype,"traces",void 0),e([n()],q.prototype,"defaultGraphicColor",void 0),e([n()],q.prototype,"enableResultArea",void 0),e([n()],q.prototype,"flags",void 0),e([n()],q.prototype,"gdbVersion",void 0),e([n()],q.prototype,"messages",void 0),e([n()],q.prototype,"messagesUnits",void 0),e([n()],q.prototype,"resultAreaProperties",null),e([n()],q.prototype,"selectedTraces",void 0),e([n()],q.prototype,"selectOnComplete",void 0),e([n()],q.prototype,"showGraphicsOnComplete",void 0),e([n()],q.prototype,"showSelectionAttributes",void 0),e([n({readOnly:!0})],q.prototype,"state",null),e([n()],q.prototype,"traceResults",void 0),e([n()],q.prototype,"utilityNetwork",void 0),e([n({value:null})],q.prototype,"view",null),q=e([c("esri.widgets.UtilityNetworkTrace.UtilityNetworkTraceViewModel")],q);const z=q;export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Color.js";import i from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as n,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../geometry/Point.js";import{isLoadedOrLoadFor as d,project as m}from"../../../geometry/projection.js";import{getResolutionForScale as g}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as u}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as v}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as y}from"../../../properties/defaultUnit.js";import _ from"../../../symbols/SimpleLineSymbol.js";import w from"../../../symbols/SimpleMarkerSymbol.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as f}from"../../../views/2d/grid/constants.js";import{getScaleFactor as S,shouldUsePlanar as b,measureMetersPerUnitAtReferencePoint as P}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as T}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import j from"../../../views/interactive/snapping/SnappingOptions.js";import{gridPlacementGraphicSymbol as C}from"../../../views/interactive/snapping/snappingUtils.js";import x from"../../../views/overlay/CrosshairOverlayItem.js";import G from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as O}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as R,gridRotationToDegrees as I}from"./gridUtils.js";const L=Symbol("grid-interactivity");let M=class extends i.EventedAccessor{constructor(t){super(t),this._drawGraphicTool=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([n((()=>!this.displayEnabled),(()=>{this.interactivePlacementState=null})),a((()=>this.view?.viewpoint),(()=>{this._renderOverlays()})),a((()=>this.snappingOptions?.gridEnabled),(t=>{null!=t&&this.trySetDisplayEnabled(t)})),a((()=>this.view?.grid),((t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null}))])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=o(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=o(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){this._set("gridColor",t);const[e,i,r,s]=t.toArray();R(this.grid,[e,i,r,s/255])}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<f}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*S(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&b(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&d(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=m(this.grid.center,this.view.spatialReference);return P(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*g(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new u({units:t,center:e.center??new p,rotateWithMap:!0}),R(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new T({view:e,graphicProperties:{attributes:{[C]:C}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:U,activeLineSymbol:E,graphicSymbol:E});this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),this.addHandles([r.on("cursor-update",(t=>this._onCursorUpdate(t))),r.on("complete",(()=>this._onDrawComplete())),r.on("vertex-add",(e=>this._onVertexAdd(e,t)))],L)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(v(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new p({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:o}=e.center,[n,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(v(n,a,void 0,i.spatialReference),{pickClosestTarget:!0}),p=h&&i.toMap(h),d=c?c.x:r,m=c?c.y:o,g=d-(p?p.x:n),u=m-(p?p.y:a);if(0===g&&0===u)return;const y=Math.atan2(u,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:o}=this;if(!(t&&e&&i&&r&&o))return;r.sketchOptions.tooltips.enabled=!1;const n="interactive"===s?i.center:r.drawOperation.firstVertex;if(!n||!t)return;const a=e?.toScreen(n),c=a&&e.toMap(a),h=e?.toScreen(t),p=c??n,d=(h&&e.toMap(h))??t,m=Math.sqrt((p.x-d.x)**2+(p.y-d.y)**2),g=l(m*o,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${I(t.rotation)}${O}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new G({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new x({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(L),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=o(this._drawGraphicTool)}};t([c(y)],M.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],M.prototype,"displayEnabled",null),t([c()],M.prototype,"dynamicScaling",null),t([c()],M.prototype,"grid",null),t([c({type:e})],M.prototype,"gridColor",null),t([c({readOnly:!0})],M.prototype,"gridControlsEnabled",null),t([c()],M.prototype,"interactivePlacementState",null),t([c()],M.prototype,"majorLineInterval",null),t([c()],M.prototype,"rotateWithMap",null),t([c()],M.prototype,"rotation",null),t([c()],M.prototype,"snappingEnabled",null),t([c()],M.prototype,"snappingManager",void 0),t([c({type:j})],M.prototype,"snappingOptions",void 0),t([c()],M.prototype,"spacing",null),t([c()],M.prototype,"unit",null),t([c()],M.prototype,"view",void 0),t([c({readOnly:!0})],M.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],M.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],M.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],M.prototype,"placementDisabled",void 0),t([c()],M.prototype,"_metersPerSRUnit",null),t([c()],M.prototype,"_pixelsPerStride",null),t([c()],M.prototype,"_isPlacing",null),t([c()],M.prototype,"_isRotating",null),t([c()],M.prototype,"_isScaling",null),t([c()],M.prototype,"_mostRecentlyShownGrid",void 0),t([c()],M.prototype,"_sketchedVertexCount",void 0),M=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],M);const k=M,E=new _({width:0}),U=new w({color:e.fromArray([0,0,0,0]),outline:new _({color:e.fromArray([0,0,0,0])})});export{k as default};
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Color.js";import i from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as n,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import d from"../../../geometry/Point.js";import{isLoadedOrLoadFor as p,project as m}from"../../../geometry/projection.js";import{getResolutionForScale as g}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as u}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as v}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as y}from"../../../properties/defaultUnit.js";import _ from"../../../symbols/SimpleLineSymbol.js";import w from"../../../symbols/SimpleMarkerSymbol.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as f}from"../../../views/2d/grid/constants.js";import{getScaleFactor as S,shouldUsePlanar as b,measureMetersPerUnitAtReferencePoint as P}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as j}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import C from"../../../views/interactive/snapping/SnappingOptions.js";import{gridPlacementGraphicSymbol as T}from"../../../views/interactive/snapping/snappingUtils.js";import x from"../../../views/overlay/CrosshairOverlayItem.js";import G from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as O}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as R,gridRotationToDegrees as L}from"./gridUtils.js";const I=Symbol("grid-interactivity");let M=class extends i.EventedAccessor{constructor(t){super(t),this._drawGraphicTool=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([n((()=>!this.displayEnabled),(()=>{this.interactivePlacementState=null})),a((()=>this.view?.viewpoint),(()=>{this._renderOverlays()})),a((()=>this.snappingOptions?.gridEnabled),(t=>{null!=t&&this.trySetDisplayEnabled(t)})),a((()=>this.view?.grid),((t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null}))])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=o(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=o(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){if(t?.equals(this.grid?.majorLineColor))return;if(!t)return;const[e,i,r,s]=t.toArray();R(this.grid,[e,i,r,s/255])}get gridColor(){return this.grid?.majorLineColor}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<f}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*S(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&b(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&p(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=m(this.grid.center,this.view.spatialReference);return P(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*g(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new u({units:t,center:e.center??new d,rotateWithMap:!0}),R(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new j({view:e,graphicProperties:{attributes:{[T]:T}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:U,activeLineSymbol:E,graphicSymbol:E});this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),this.addHandles([r.on("cursor-update",(t=>this._onCursorUpdate(t))),r.on("complete",(()=>this._onDrawComplete())),r.on("vertex-add",(e=>this._onVertexAdd(e,t)))],I)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(v(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new d({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:o}=e.center,[n,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(v(n,a,void 0,i.spatialReference),{pickClosestTarget:!0}),d=h&&i.toMap(h),p=c?c.x:r,m=c?c.y:o,g=p-(d?d.x:n),u=m-(d?d.y:a);if(0===g&&0===u)return;const y=Math.atan2(u,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:o}=this;if(!(t&&e&&i&&r&&o))return;r.sketchOptions.tooltips.enabled=!1;const n="interactive"===s?i.center:r.drawOperation.firstVertex;if(!n||!t)return;const a=e?.toScreen(n),c=a&&e.toMap(a),h=e?.toScreen(t),d=c??n,p=(h&&e.toMap(h))??t,m=Math.sqrt((d.x-p.x)**2+(d.y-p.y)**2),g=l(m*o,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${L(t.rotation)}${O}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new G({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new x({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(I),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=o(this._drawGraphicTool)}};t([c(y)],M.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],M.prototype,"displayEnabled",null),t([c()],M.prototype,"dynamicScaling",null),t([c()],M.prototype,"grid",null),t([c()],M.prototype,"gridColor",null),t([c({readOnly:!0})],M.prototype,"gridControlsEnabled",null),t([c()],M.prototype,"interactivePlacementState",null),t([c()],M.prototype,"majorLineInterval",null),t([c()],M.prototype,"rotateWithMap",null),t([c()],M.prototype,"rotation",null),t([c()],M.prototype,"snappingEnabled",null),t([c()],M.prototype,"snappingManager",void 0),t([c({type:C})],M.prototype,"snappingOptions",void 0),t([c()],M.prototype,"spacing",null),t([c()],M.prototype,"unit",null),t([c()],M.prototype,"view",void 0),t([c({readOnly:!0})],M.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],M.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],M.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],M.prototype,"placementDisabled",void 0),t([c()],M.prototype,"_metersPerSRUnit",null),t([c()],M.prototype,"_pixelsPerStride",null),t([c()],M.prototype,"_isPlacing",null),t([c()],M.prototype,"_isRotating",null),t([c()],M.prototype,"_isScaling",null),t([c()],M.prototype,"_mostRecentlyShownGrid",void 0),t([c()],M.prototype,"_sketchedVertexCount",void 0),M=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],M);const k=M,E=new _({width:0}),U=new w({color:e.fromArray([0,0,0,0]),outline:new _({color:e.fromArray([0,0,0,0])})});export{k as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import"../../intl.js";import{watch as i,initial as n}from"../../core/reactiveUtils.js";import{formatDecimal as s}from"../../core/unitFormatUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Widget.js";import{loadCalciteComponents as a}from"./componentsUtils.js";import{globalCss as c}from"./globalCss.js";import{loadLabeledSwitchComponents as d,LabeledSwitch as p}from"./LabeledSwitch.js";import{classes as m}from"./widgetUtils.js";import{messageBundle as g}from"./decorators/messageBundle.js";import{tsx as u}from"./jsxFactory.js";import h from"./GridControls/GridControlsViewModel.js";import{gridRotationToDegrees as b,userInputToGridRotation as v}from"./GridControls/gridUtils.js";import w from"./GridControls/VisibleElements.js";import{substitute as _}from"../../intl/substitute.js";const f="esri-grid-controls",C={base:f,borderedSwitch:`${f}__switch--bordered`,container:`${f}__container`,numericInputsContainer:`${f}__numeric-inputs__container`,tilegroup:`${f}__tilegroup`,tile:`${f}__tile`,tileDisabled:`${f}__tile--disabled`,tileContent:`${f}__tile__content`,suffixedInputContainer:`${f}__input-with-suffix__container`,inputSuffix:`${f}__input-with-suffix__suffix-part`,inlineIcon:`${f}__inline-icon`},y={widgetIcon:"grid-unit",gridTheme:{light:"circle",dark:"circle-area",custom:"palette"},placementState:{interactive:"maximum-territory-distance",place:"move",rotate:"rotate"},warning:"exclamation-mark-triangle"},M=t.fromArray([115,115,115]),S=t.fromArray([200,200,200]),I=["interactive","place","rotate"];let T=class extends r{constructor(e,t){super(e,t),this.customColor=null,this.messages=null,this.messagesUnits=null,this.viewModel=new h,this.visibleElements=new w}initialize(){this.addHandles([i((()=>this.
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import"../../intl.js";import{watch as i,initial as n}from"../../core/reactiveUtils.js";import{formatDecimal as s}from"../../core/unitFormatUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Widget.js";import{loadCalciteComponents as a}from"./componentsUtils.js";import{globalCss as c}from"./globalCss.js";import{loadLabeledSwitchComponents as d,LabeledSwitch as p}from"./LabeledSwitch.js";import{classes as m}from"./widgetUtils.js";import{messageBundle as g}from"./decorators/messageBundle.js";import{tsx as u}from"./jsxFactory.js";import h from"./GridControls/GridControlsViewModel.js";import{gridRotationToDegrees as b,userInputToGridRotation as v}from"./GridControls/gridUtils.js";import w from"./GridControls/VisibleElements.js";import{substitute as _}from"../../intl/substitute.js";const f="esri-grid-controls",C={base:f,borderedSwitch:`${f}__switch--bordered`,container:`${f}__container`,numericInputsContainer:`${f}__numeric-inputs__container`,tilegroup:`${f}__tilegroup`,tile:`${f}__tile`,tileDisabled:`${f}__tile--disabled`,tileContent:`${f}__tile__content`,suffixedInputContainer:`${f}__input-with-suffix__container`,inputSuffix:`${f}__input-with-suffix__suffix-part`,inlineIcon:`${f}__inline-icon`},y={widgetIcon:"grid-unit",gridTheme:{light:"circle",dark:"circle-area",custom:"palette"},placementState:{interactive:"maximum-territory-distance",place:"move",rotate:"rotate"},warning:"exclamation-mark-triangle"},M=t.fromArray([115,115,115]),S=t.fromArray([200,200,200]),I=["interactive","place","rotate"];let T=class extends r{constructor(e,t){super(e,t),this.customColor=null,this.messages=null,this.messagesUnits=null,this.viewModel=new h,this.visibleElements=new w}initialize(){this.addHandles([i((()=>this.viewModel.gridColor),(e=>{!e||M.equals(e)||S.equals(e)||(this.customColor=e)}),n)])}loadDependencies(){return Promise.all([a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip"),"color-picker":()=>import("@esri/calcite-components/dist/components/calcite-color-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number")}),d()])}get icon(){return y.widgetIcon}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages.widgetLabel}set label(e){this._overrideIfSome("label",e)}get snappingManager(){return this.viewModel.snappingManager}set snappingManager(e){this.viewModel.snappingManager=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get theme(){const e=this.viewModel.gridColor;return e?M.equals(e)?"dark":S.equals(e)?"light":"custom":null}set theme(e){const{viewModel:t,customColor:i,view:n}=this;switch(e){case"light":t.gridColor=S;break;case"dark":t.gridColor=M;break;case"custom":t.gridColor=i??n?.effectiveTheme.accentColor??M}}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){return u("div",{"aria-label":this.label,class:this.classes(C.base,c.widget,c.panel)},u("div",{class:C.container},this._renderContent()))}_renderContent(){const{visibleElements:e}=this;return[e.gridEnabledToggle?this._renderEnabledToggle():null,e.placementButtons?this._renderGridPlacementButtons():null,e.numericInputs?this._renderNumericInputs():null,e.lineIntervalInput?this._renderIntervalInput():null,e.gridSnapEnabledToggle&&this.viewModel.snappingOptions?this._renderSnappingToggle():null,e.dynamicScaleToggle?this._renderDynamicScaleToggle():null,e.rotateWithMapToggle?this._renderRotateToggle():null,e.colorSelection?this._renderColorSelection():null]}_renderGridPlacementButtons(){const{interactivePlacementState:e,placementDisabled:t,gridControlsEnabled:i}=this.viewModel,n=t||!i;return u("calcite-label",{key:"grid-placement-buttons",scale:"s"},this.messages.placementOptions,u("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},I.map((t=>this._renderPlacementModeButton(t,n,e)))))}_renderPlacementModeButton(e,t,i){const n=this.messages.placementState[e],s=`__placement-action-${e}`;return u("div",null,u("calcite-action",{active:i===e,alignment:"center",disabled:t,icon:y.placementState[e],id:s,onclick:()=>this.viewModel.togglePlacementState(e),text:n}),u("calcite-tooltip",{overlayPositioning:"fixed",placement:"top",referenceElement:s},n))}_renderNumericInputs(){const{rotation:e,spacing:t,effectiveSpacingAfterDynamicScaling:i,numericSpacingInputShouldBeVisible:n,unit:o="meters"}=this.viewModel,l=this.messagesUnits.units[o].abbr,r=this.viewModel.gridControlsEnabled,a=null!=i&&i!==this.viewModel.spacing,c=`__spacing_input_scaled-${this.id}`;return u("div",{class:this.classes(C.numericInputsContainer)},[n?u("calcite-label",{key:"spacing-label",scale:"s"},u("span",null,this.messages.inputLabel.spacing,a?u("calcite-icon",{class:this.classes(C.inlineIcon),icon:y.warning,id:c,scale:"s",tabIndex:0}):void 0),u("div",{class:C.suffixedInputContainer},u("calcite-input-number",{disabled:!r,numberButtonType:"none",suffixText:l,value:`${t?.toFixed(2)}`,onCalciteInputNumberChange:({currentTarget:e})=>{const t=parseFloat(e.value);this.viewModel.spacing=t,t!==this.viewModel.spacing&&(e.value=`${this.viewModel.spacing}`)}}),a?u("calcite-tooltip",{overlayPositioning:"fixed",placement:"leading",referenceElement:c},_(this.messages.warnings.dynamicSpacing,{actualSpacingIncludingUnit:s(this.messagesUnits,i,o,2,"plural")})):void 0)):void 0,u("calcite-label",{key:"angle-label",scale:"s"},this.messages.inputLabel.angle,u("calcite-input-number",{disabled:!r,integer:!0,numberButtonType:"none",suffixText:this.messagesUnits.units.degrees.abbr,value:`${b(e)}`,onCalciteInputNumberChange:({currentTarget:e})=>this.viewModel.rotation=v(e.value)}))])}_renderIntervalInput(){const{majorLineInterval:e,gridControlsEnabled:t}=this.viewModel;return u("div",{class:this.classes(C.numericInputsContainer)},u("calcite-label",{scale:"s"},this.messages.inputLabel.interval,u("calcite-input-number",{disabled:!t,integer:!0,max:15,min:1,numberButtonType:"vertical",value:`${e}`,onCalciteInputNumberChange:({currentTarget:e})=>{const t=Number.parseInt(e.value,10);this.viewModel.majorLineInterval=t,t!==this.viewModel.majorLineInterval&&(e.value=`${this.viewModel.majorLineInterval}`)}})))}_renderSnappingToggle(){const{snappingOptions:e,gridControlsEnabled:t}=this.viewModel;return u(p,{checked:!!(e?.gridEnabled??!1),disabled:!(t&&!!e),key:"grid-snap-enabled-toggle",label:this.messages.switchLabel.snap,onChange:e=>this.viewModel.snappingOptions?.set("gridEnabled",e)})}_renderDynamicScaleToggle(){const{viewModel:e,messages:t}=this,i=this.visibleElements.outOfScaleWarning&&e.gridOutOfScale;return u(p,{checked:e.dynamicScaling,disabled:!e.gridControlsEnabled,hint:i?t.warnings.outOfScale:void 0,hintIcon:y.warning,hintKind:"warning",key:`grid-dynamic-scale-toggle-${this.id}`,label:t.switchLabel.scaling,onChange:t=>e.dynamicScaling=t})}_renderRotateToggle(){const{gridControlsEnabled:e,rotateWithMap:t}=this.viewModel;return u(p,{checked:t,disabled:!e,key:"grid-rotate-map-toggle",label:this.messages.switchLabel.rotateWithMap,onChange:e=>this.viewModel.rotateWithMap=e})}_renderEnabledToggle(){return u("div",{class:C.borderedSwitch},u(p,{checked:this.viewModel.displayEnabled,disabled:!!this.viewModel.interactivePlacementState,key:"grid-enabled-toggle",label:this.messages.switchLabel.display,onChange:e=>this.viewModel.trySetDisplayEnabled(e)}))}_renderColorSelection(){const{customColor:e}=this,i=`${this.id}--custom-grid-color-button`;return u("calcite-label",{scale:"s"},this.messages.inputLabel.theme,u("div",{class:C.tilegroup},[this._renderThemeTile({value:"dark"}),this._renderThemeTile({value:"light"}),this._renderThemeTile({value:"custom",id:i}),u("calcite-popover",{autoClose:!0,label:this.messages.gridLineColorPopoverLabel,overlayPositioning:"fixed",referenceElement:i},u("calcite-color-picker",{alphaChannel:!0,savedDisabled:!0,value:e?.toHex({digits:8})??"#000000ff",onCalciteColorPickerChange:e=>{const i=t.fromHex(e.currentTarget.value);i&&(this.customColor=i,this.theme="custom")}}))]))}_renderThemeTile(e){const{theme:t}=this,{value:i}=e,n=this.messages.gridTheme[i],s=`${this.id}--theme_tile_${i}`,o=`${s}__label`,l=y.gridTheme[i],r=this.viewModel.gridControlsEnabled;return u("div",{class:m({[C.tile]:!0,[C.tileDisabled]:!r}),id:e.id,role:"button"},u("input",{"aria-labelledby":o,checked:t===i,disabled:!r,id:s,name:`${this.id}--theme`,onchange:e=>{this.theme=i,e.target?.focus()},tabIndex:0,type:"radio"}),u("div",{class:C.tileContent},u("calcite-icon",{icon:l,scale:"l"}),u("calcite-label",{for:s,id:o},n)))}};e([o({type:t})],T.prototype,"customColor",void 0),e([o()],T.prototype,"icon",null),e([o()],T.prototype,"label",null),e([o(),g("esri/widgets/support/GridControls/t9n/GridControls")],T.prototype,"messages",void 0),e([o(),g("esri/core/t9n/Units")],T.prototype,"messagesUnits",void 0),e([o()],T.prototype,"snappingManager",null),e([o()],T.prototype,"snappingOptions",null),e([o()],T.prototype,"theme",null),e([o()],T.prototype,"view",null),e([o({type:h})],T.prototype,"viewModel",void 0),e([o({type:w,nonNullable:!0})],T.prototype,"visibleElements",void 0),T=e([l("esri.widgets.support.GridControls")],T);const j=T;export{j as default};
|