@arcgis/core 5.2.0-next.145 → 5.2.0-next.147
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/arcade/featureSetUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/2062d46f638eabfc9499.js +1 -0
- package/assets/esri/core/workers/chunks/{8ba32d3a0df4a206ef1c.js → 392bcef780df52fb4cca.js} +1 -1
- package/assets/esri/core/workers/chunks/{d201fbf3ceff946d2bd6.js → 44d5508042cacdfcac47.js} +1 -1
- package/assets/esri/core/workers/chunks/{d4926545193414cf2f16.js → 4ed8655770a3e018e366.js} +1 -1
- package/assets/esri/core/workers/chunks/{cbe6c0f32608cb504695.js → 776ae25a34352d3468bc.js} +1 -1
- package/assets/esri/core/workers/chunks/{fccbb902fe08448f91de.js → 9c1e69ac82e2bf746191.js} +1 -1
- package/assets/esri/core/workers/chunks/{8b54589f173259c1ba55.js → b8054adc45bca069b948.js} +1 -1
- package/assets/esri/core/workers/chunks/{43fc42405167a5537039.js → f095cf98940e3f95d51e.js} +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +0 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/messages.en.json +1 -1
- package/chunks/GlobalIllumination.glsl.js +4 -2
- package/chunks/GlobalIlluminationBlur.glsl.js +3 -5
- package/chunks/GlobalIlluminationUpscale.glsl.js +1 -1
- package/config.js +1 -1
- package/core/colorUtils.js +1 -1
- package/form/elements/inputs/DynamicChoiceInput.d.ts +35 -5
- package/kernel.js +1 -1
- package/layers/ParquetLayer.d.ts +9 -8
- package/layers/ParquetLayer.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/raster/datasets/TIFFRaster.js +1 -1
- package/layers/support/ParquetPortalItemData.d.ts +2 -0
- package/layers/support/ParquetPortalItemData.js +1 -1
- package/layers/support/PortalItemData.d.ts +21 -0
- package/layers/support/parquetUtils.d.ts +1 -1
- package/layers/support/types.d.ts +1 -1
- package/package.json +2 -2
- package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationColorQuantization.glsl.js +2 -2
- package/views/interactive/options/SnappingOptions.d.ts +1 -0
- package/views/interactive/options/TooltipOptions.d.ts +1 -0
- package/views/interactive/options/ViewOptions.d.ts +1 -0
- package/views/interactive/support/Units.d.ts +1 -0
- package/views/layers/ParquetLayerView.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
- package/widgets/BatchAttributeForm/expressions/expressionUtils.js +1 -1
- package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +6 -0
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/FeatureForm.d.ts +2 -2
- package/assets/esri/core/workers/chunks/25e6013e2c095629b236.js +0 -1
|
@@ -645,7 +645,7 @@ export type ParquetGeometryEncodingUnion = GeometryEncodingWkb | GeometryEncodin
|
|
|
645
645
|
*
|
|
646
646
|
* @since 5.1
|
|
647
647
|
*/
|
|
648
|
-
export type ParquetDataUnion = ParquetFilesData | ParquetPortalItemData;
|
|
648
|
+
export type ParquetDataUnion = ParquetFilesData | ParquetPortalItemData | PortalItemData;
|
|
649
649
|
|
|
650
650
|
/**
|
|
651
651
|
* Supported GeospatialPDF data source types.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/core",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.147",
|
|
4
4
|
"description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ArcGIS",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@amcharts/amcharts5": "~5.20.8",
|
|
23
|
-
"@arcgis/toolkit": "5.2.0-next.
|
|
23
|
+
"@arcgis/toolkit": "5.2.0-next.147",
|
|
24
24
|
"@esri/arcgis-html-sanitizer": "~4.2.0-next.2",
|
|
25
25
|
"@esri/calcite-components": "^5.2.0-next.89",
|
|
26
26
|
"@vaadin/grid": "~25.3.2",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{watch as n,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{snapshotLineOfSightTargetState as o,restoreLineOfSightTargetState as s}from"./LineOfSightAuthoringUtils.js";import{LineOfSightItemManipulatedObject3D as c}from"./LineOfSightItemManipulatedObject3D.js";import{LineOfSightItemTool as l}from"./LineOfSightItemTool.js";import{discRadiusSmall as u}from"../../interactive/editingTools/manipulations/config.js";import{MoveTool3D as d}from"../../interactive/editingTools/move/MoveTool3D.js";import{bindViewToolOptions as f}from"../../../interactive/options/bindViewToolOptions.js";import p from"../../../interactive/options/InteractiveToolOptions.js";const
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{watch as n,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{snapshotLineOfSightTargetState as o,restoreLineOfSightTargetState as s}from"./LineOfSightAuthoringUtils.js";import{LineOfSightItemManipulatedObject3D as c}from"./LineOfSightItemManipulatedObject3D.js";import{LineOfSightItemTool as l}from"./LineOfSightItemTool.js";import{discRadiusSmall as u}from"../../interactive/editingTools/manipulations/config.js";import{MoveTool3D as d}from"../../interactive/editingTools/move/MoveTool3D.js";import{bindViewToolOptions as f}from"../../../interactive/options/bindViewToolOptions.js";import p from"../../../interactive/options/InteractiveToolOptions.js";import{makeTooltip as m}from"../../../interactive/tooltip/tooltipCommonUtils.js";const h=Symbol(`inactiveMoveManipulatorDisplay`);let g=class extends t{get visible(){return this._get(`visible`)??!0}set visible(e){this._set(`visible`,e),this._itemTool.visible=e,this._moveTool.visible=e}get manipulatorsInteractive(){return this._get(`manipulatorsInteractive`)??!0}set manipulatorsInteractive(e){this._set(`manipulatorsInteractive`,e),this._itemTool.manipulatorsInteractive=e}constructor(e){super(e),this._selectedItem=null,this._objectByItem=new Map,this._undoStack=[],this._redoStack=[];let t=new p;this._tooltip=m(()=>({view:e.view,options:t.tooltips})),this._moveTool=new d({enableVisualElements:!1,manipulatorRadius:u,snappingManager:e.snappingManager,toolOptions:t,tooltip:this._tooltip,view:e.view}),this._itemTool=new l({analysisViewData:e.analysisViewData,snappingManager:e.snappingManager,tooltip:this._tooltip,view:e.view})}initialize(){this.view.tools.add(this._itemTool),this.view.tools.add(this._moveTool),this._itemTool.visible=this.visible,this._moveTool.visible=this.visible,this._itemTool.manipulatorsInteractive=this.manipulatorsInteractive;let e=e=>{let t=e.at(0);t!=null&&this._itemTool.showInteractionVisuals(t)},t=()=>this._itemTool.hideInteractionVisuals();this.addHandles([f(this._moveTool.toolOptions,()=>this.view.options),n(()=>({observer:this.analysis.observer,targets:this.analysis.targets.toArray()}),({observer:e,targets:t})=>this._syncObjects(e,t),r),this._itemTool.events.on(`select-item`,({item:e})=>this._setSelectedItem(e)),this._itemTool.events.on(`selection-cleared`,()=>{if(this._moveTool.hasFocusedManipulators){let e=this._selectedItem==null?null:this._objectByItem.get(this._selectedItem);this._itemTool.selectObject(e)}else this._setSelectedItem(null)}),this._itemTool.events.on(`delete-item`,({target:e})=>this._deleteTarget(e)),this._itemTool.events.on(`record-undo`,({record:e})=>this._recordHistory(_([e]))),this._moveTool.events.on(`record-undo`,({updates:e})=>this._recordHistory(_(e))),this._moveTool.events.on(`hold`,({objects:t})=>e(t)),this._moveTool.events.on(`move-start`,({objects:t})=>{this._itemTool.endDrag(),e(t)}),this._moveTool.events.on(`move-stop`,t),n(()=>({sphereGrabbed:this._itemTool.hasGrabbedManipulators,manipulators:this._moveTool.manipulators.toArray()}),({sphereGrabbed:e})=>{let t=[];e&&this._moveTool.manipulators.forEach(({manipulator:e})=>{t.push(e.disableDisplay())}),this.removeHandles(h),this.addHandles(t,h)},r),n(()=>this._moveTool.firstGrabbedManipulator,e=>{e??t()})])}destroy(){this.removeHandles(h),this.stop(),this.view.tools.remove(this._itemTool),this.view.tools.remove(this._moveTool),this._itemTool.destroy(),this._moveTool.destroy(),this._tooltip.destroy();for(let e of this._objectByItem.values())this.removeHandles(e),e.destroy();this._objectByItem.clear(),this._undoStack.length=0,this._redoStack.length=0}get active(){return this._itemTool.active||this._moveTool.active}get canRedo(){return this._redoStack.length>0}get canUndo(){return this._undoStack.length>0}get hasSelection(){return this._selectedItem!=null}get selectedItem(){return this._selectedItem}get updating(){return this._itemTool.updating||this._moveTool.updating}get laserLineVisualElement(){return this._itemTool.laserLineVisualElement}get verticalLineVisualElement(){return this._itemTool.verticalLineVisualElement}selectItem(e){return this._objectByItem.has(e)?(this._setSelectedItem(e),!0):!1}clearSelection(){return this.hasSelection?(this._setSelectedItem(null),!0):!1}deleteSelectedItem(){let e=this._selectedItem;if(e==null)return!1;let t=this.analysis.targets.find(t=>t===e);return t!=null&&this._deleteTarget(t)}getObserverManipulator(){let e=this.analysis.observer,t=e==null?null:this._itemTool.getManipulator(e);return t!=null&&v(t)?t:null}getTargetManipulator(e){let t=this._itemTool.getManipulator(e);return t!=null&&y(t)?t:null}hasManipulatorAt(e,t){return this._itemTool.hasManipulatorAt(e,t)}redo(){let e=this._redoStack.pop();e!=null&&(e.redo()?(this._undoStack.push(e),this._notifyHistoryChanged()):this._redoStack.push(e))}setEditableFlag(e,t){this._itemTool.setEditableFlag(e,t),this._moveTool.setEditableFlag(e,t)}stop(){(this.view.activeTool===this._itemTool||this.view.activeTool===this._moveTool)&&(this.view.activeTool=null),this._itemTool.hideInteractionVisuals(),this.snappingManager.doneSnapping(),this.clearSelection()}undo(){let e=this._undoStack.pop();e!=null&&(e.undo(),this._redoStack.push(e),this._notifyHistoryChanged())}_syncObjects(e,t){let n=new Set(e==null?t:[e,...t]);for(let[e,t]of this._objectByItem)n.has(e)||(this._selectedItem===e&&this._setSelectedItem(null),this.removeHandles(t),this._itemTool.removeObject(t),this._objectByItem.delete(e),t.destroy());e!=null&&this._ensureObject(e);for(let e of t)this._ensureObject(e);this._setSelectedItem(this._selectedItem)}_ensureObject(e){if(this._objectByItem.has(e))return;let t=new c({analysisViewData:this.analysisViewData,intersector:this.intersector,item:e,view:this.view});this._objectByItem.set(e,t),this._itemTool.addObject(t),this.addHandles(t.on(`modified-externally`,()=>{this._selectedItem===e&&this._setSelectedItem(e)}),t)}_setSelectedItem(e){let t=e==null?null:this._objectByItem.get(e);this._selectedItem=t==null?null:e,this._itemTool.selectObject(t),this._moveTool.objects.removeAll(),t!=null&&this._moveTool.objects.add(t),this._itemTool.interacting=this._selectedItem!=null}_deleteTarget(e){if(this.analysis.targets.length<=1)return!1;let t=this.analysis.targets.indexOf(e);if(t<0)return!1;let n=o(e),r=this._selectedItem===e;return this.analysis.targets.remove(e),this._recordHistory({undo:()=>{s(n,e),this.analysis.targets.add(e,Math.min(t,this.analysis.targets.length)),r&&this._setSelectedItem(e)},redo:()=>this.analysis.targets.includes(e)&&this.analysis.targets.length<=1?!1:(this.analysis.targets.remove(e),this._selectedItem===e&&this._setSelectedItem(null),!0)}),!0}_recordHistory(e){this._undoStack.push(e),this._redoStack.length=0,this._notifyHistoryChanged()}_notifyHistoryChanged(){this.notifyChange(`canUndo`),this.notifyChange(`canRedo`)}get testInfo(){return{moveTooltip:this._tooltip}}};e([i({constructOnly:!0})],g.prototype,`analysisViewData`,void 0),e([i({constructOnly:!0})],g.prototype,`analysis`,void 0),e([i({constructOnly:!0})],g.prototype,`intersector`,void 0),e([i({constructOnly:!0})],g.prototype,`snappingManager`,void 0),e([i({constructOnly:!0})],g.prototype,`view`,void 0),e([i()],g.prototype,`visible`,null),e([i()],g.prototype,`manipulatorsInteractive`,null),e([i()],g.prototype,`_selectedItem`,void 0),e([i()],g.prototype,`active`,null),e([i()],g.prototype,`canRedo`,null),e([i()],g.prototype,`canUndo`,null),e([i()],g.prototype,`selectedItem`,null),e([i()],g.prototype,`updating`,null),g=e([a(`esri.views.3d.analysis.LineOfSight.LineOfSightEditTool`)],g);function _(e){return{undo:()=>{for(let t=e.length-1;t>=0;t--)e[t].undo(null)},redo:()=>{for(let t of e)t.redo(null);return!0}}}function v(e){return e.metadata.type===`observer`}function y(e){return e.metadata.type===`target`}export{g as LineOfSightEditTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{EventEmitter as t}from"../../../../core/Evented.js";import{handlesGroup as n}from"../../../../core/handleUtils.js";import{destroyMaybe as r,removeMaybe as i}from"../../../../core/maybe.js";import a from"../../../../core/ReactiveMap.js";import{initial as o,watch as s,syncAndInitial as c}from"../../../../core/reactiveUtils.js";import{property as l,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import{create as f,fromPoints as p}from"../../../../geometry/support/lineSegment.js";import{LineOfSightInteractionVisuals as m}from"./LineOfSightInteractionVisuals.js";import{LineOfSightObserverManipulator as h,LineOfSightTargetManipulator as g,LineOfSightTargetManipulatorState as _,getInteractiveLineOfSightTargetManipulatorState as v}from"./LineOfSightManipulators.js";import{SnappingVisualizer3D as y}from"../../interactive/SnappingVisualizer3D.js";import{screenToMapAtSceneSurface as b}from"../../interactive/editingTools/dragEventPipeline3D.js";import{connectTooltipToManipulatedObject as x}from"../../interactive/editingTools/tooltipUtils3D.js";import{mouseButtons as S}from"../../../input/mouseButtons.js";import{createManipulatorDragEventPipeline as C,dragAtLocation as w,sceneSnappingAtLocation as T,dragManipulatedObject as E}from"../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as D}from"../../../interactive/InteractiveToolBase.js";import{bindViewToolOptions as O}from"../../../interactive/options/bindViewToolOptions.js";import k from"../../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as A}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as j}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as M,enterInputModeIfAvailable as N}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as P}from"../../../interactive/tooltip/infos/MovePointTooltipInfo.js";const F=f(),I=Symbol(`inactiveManipulatorDisplay`);let L=class extends D{get _manipulatorsToHide(){let e=this._manipulatorByObject.values();return this.view.tools.some(e=>e.hasGrabbedManipulators)||e.some(e=>e.grabbing)?e.filter(e=>!e.grabbing).toArray():[]}constructor(e){super(e),this.events=new t,this.automaticManipulatorSelection=!1,this.removeIncompleteOnCancel=!1,this.interacting=!1,this.manipulatorsInteractive=!0,this._objectByItem=new Map,this._manipulatorByObject=new a,this._updatingHandles=new d,this._toolOptions=new k,this._interactionVisuals=null,this._grabbedManipulator=null,this._visualsManipulator=null,this._tooltipHandle=null,this._tooltipObject=null,this._tooltipUndoRecord=null,this._tooltipInfo=new P({toolOptions:this._toolOptions,viewType:`3d`})}initialize(){let{view:e}=this;this._tooltip=M(()=>({view:e,options:this._toolOptions.tooltips})),this._interactionVisuals=new m({view:e}),this.addHandles([O(this._toolOptions,()=>e.options),this._updatingHandles.add(()=>({analysisVisible:this.analysisViewData.visible,computations:this.analysisViewData.computations.toArray().map(e=>({isTargetVisible:e.computationResult.isTargetVisible,isValid:e.computationResult.isValid,target:e.target})),grabbedManipulator:this._grabbedManipulator,interacting:this.interacting,manipulatorsInteractive:this.manipulatorsInteractive,visible:this.visible}),()=>this._syncManipulators(),o),s(()=>this._manipulatorsToHide,e=>{let t=e.map(e=>e.disableDisplay());this.removeHandles(I),this.addHandles(t,I)},c),s(()=>this._tooltip.mode,e=>{e!==`input`&&this._grabbedManipulator==null&&this._disconnectTooltip()})]),this.finishToolCreation()}destroy(){this.removeHandles(I),this._disconnectTooltip(),this._tooltip=r(this._tooltip),this._interactionVisuals=r(this._interactionVisuals),this._updatingHandles.destroy(),this._objectByItem.clear(),this._manipulatorByObject.clear(),super.destroy()}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}get laserLineVisualElement(){return this._interactionVisuals?.laserLineVisualElement??null}get verticalLineVisualElement(){return this._interactionVisuals?.verticalLineVisualElement??null}showInteractionVisuals(e){this._visualsManipulator=this._manipulatorByObject.get(e),this._syncInteractionVisuals()}hideInteractionVisuals(){this._visualsManipulator=null,this._syncInteractionVisuals()}addObject(e){if(this._manipulatorByObject.has(e))return;let t=e.item.type===`observer`?new h(this.view,{deleting:!1,intersection:null,type:`observer`}):new g(this.view,{deleting:!1,target:e.item,type:`target`});t.cursor=`move`,this._objectByItem.set(e.item,e),this._manipulatorByObject.set(e,t),this.manipulators.add(t),this.addHandles(this._connectManipulator(e,t),e),this._syncManipulator(e,t)}removeObject(e){let t=this._manipulatorByObject.get(e);t!=null&&(this._grabbedManipulator===t&&(this._grabbedManipulator=null),this._tooltipObject===e&&this._disconnectTooltip(),this._visualsManipulator===t&&this.hideInteractionVisuals(),this.removeHandles(e),this.removeHandles(e),this._objectByItem.delete(e.item),this._manipulatorByObject.delete(e),this.manipulators.remove(t),t.destroy())}getManipulator(e){let t=this._objectByItem.get(e);return t==null?null:this._manipulatorByObject.get(t)}hasManipulatorAt(e,t){for(let n of this._manipulatorByObject.values())if(n.consumesClicks&&n.intersectionDistance(e,t)!=null)return!0;return!1}selectObject(e){this._tooltipObject!=null&&this._tooltipObject!==e&&this._disconnectTooltip();let t=!1;for(let[n,r]of this._manipulatorByObject){let i=n===e;r.selected=i,t||=i}return this._syncManipulators(),t}onInputEvent(e){e.type===`hold`&&this._grabbedManipulator!=null&&(this._visualsManipulator=this._grabbedManipulator,this._syncInteractionVisuals()),N(e,this._tooltip)}onManipulatorSelectionChanged(){[...this._manipulatorByObject.values()].some(e=>e.selected)||this.events.emit(`selection-cleared`)}_connectManipulator(e,t){let r=()=>this._syncManipulator(e,t);return n([e.on(`committed`,r),e.on(`modified-externally`,r),t.events.on(`immediate-click`,n=>{this.events.emit(`select-item`,{item:e.item}),n.button===S.Right&&t.metadata.type===`target`&&this.events.emit(`delete-item`,{target:t.metadata.target}),n.stopPropagation()}),t.events.on(`grab-changed`,({action:n})=>{n===`start`?(this.events.emit(`select-item`,{item:e.item}),this._grabbedManipulator=t,this._connectTooltip(e)):this._grabbedManipulator===t&&(this._grabbedManipulator=null,this.hideInteractionVisuals(),this._tooltip.mode!==`input`&&this._disconnectTooltip()),this._manipulatorByObject.set(e,t)}),t.events.on(`drag`,t=>{e.updateDragIntersection(t),t.action===`start`&&this.showInteractionVisuals(e)}),t.events.on(`location-update`,()=>this._syncInteractionVisuals()),this._createDragHandle(e,t)])}_createDragHandle(e,t){return C(t,(n,r,i,a)=>{let o=e.operations;if(o==null)return;let s=null,{cancelSnapping:c,snappingStep:l}=j({snappingContext:new A({editGeometryOperations:o,elevationInfo:e.elevationInfo,pointer:a,visualizer:new y}),snappingManager:this.snappingManager,updatingHandles:this._updatingHandles,useZ:!0});i.next(e=>(s?.undo(null),s=null,e)).next(c);let u=o.data.allVerticesUnordered.at(0);r.next(t=>(t.action===`start`&&(s=e.createUndoRecord()),{...t,snapOrigin:u?.pos})).next(w(this.view,t.elevationAlignedLocation)).next(b(this.view,o.data.geometry,e.elevationInfo,o.data.spatialReference)).next(T(this.view,e.elevationInfo)).next(...l).next(E(e)).next(e=>(e.action===`end`&&s!=null&&(this.events.emit(`record-undo`,{record:s}),s=null),e))})}_connectTooltip(e){this._disconnectTooltip(),this._tooltipObject=e,this._tooltipHandle=x(this._tooltip,e,()=>({activeTooltipInfo:this._tooltipInfo,onRecordUndo:e=>this.events.emit(`record-undo`,{record:e}),callbacks:{onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._tooltipUndoRecord=e.createUndoRecord()},onMove:()=>{},onMoveStop:()=>{this._tooltipUndoRecord!=null&&(this.events.emit(`record-undo`,{record:this._tooltipUndoRecord}),this._tooltipUndoRecord=null)},onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}},toolOptions:this._toolOptions}))}_disconnectTooltip(){this._tooltipHandle=i(this._tooltipHandle),this._tooltipObject=null,this._tooltipUndoRecord=null,this._tooltip.clear()}_syncManipulators(){for(let[e,t]of this._manipulatorByObject)this._syncManipulator(e,t);this._syncInteractionVisuals()}_syncManipulator(e,t){let n=e.origin;if(t.available=this.visible&&e.visible&&n!=null,t.interactive=this.manipulatorsInteractive&&(this._grabbedManipulator==null||this._grabbedManipulator===t),n!=null&&(t.elevationAlignedLocation=n),e.item.type!==`target`)return;let r=this.analysisViewData.computations.find(t=>t.target===e.item),i=r==null||!r.computationResult.isValid?_.undefined:r.computationResult.isTargetVisible?_.visible:_.occluded;t.state=this.interacting&&t.selected?v(i):i}_syncInteractionVisuals(){let e=this._interactionVisuals,t=this._visualsManipulator,n=this.visible&&this.analysisViewData.visible;if(e==null||t==null||!n){e?.hide();return}let r=[...this._manipulatorByObject.entries()].find(([e])=>e.item.type===`observer`)?.[1];if(r==null){e.hide();return}let i=t===r?null:p(r.renderLocation,t.renderLocation,F);e.update({target:t.renderLocation,lineVerticalPlaneSegment:i,visible:!0})}};e([l({constructOnly:!0})],L.prototype,`analysisViewData`,void 0),e([l({constructOnly:!0})],L.prototype,`snappingManager`,void 0),e([l({constructOnly:!0})],L.prototype,`view`,void 0),e([l()],L.prototype,`automaticManipulatorSelection`,void 0),e([l()],L.prototype,`removeIncompleteOnCancel`,void 0),e([l()],L.prototype,`interacting`,void 0),e([l()],L.prototype,`manipulatorsInteractive`,void 0),e([l()],L.prototype,`_grabbedManipulator`,void 0),e([l()],L.prototype,`_manipulatorsToHide`,null),e([l()],L.prototype,`updating`,null),L=e([u(`esri.views.3d.analysis.LineOfSight.LineOfSightItemTool`)],L);export{L as LineOfSightItemTool};
|
|
2
|
+
import{__decorate as e}from"tslib";import{EventEmitter as t}from"../../../../core/Evented.js";import{handlesGroup as n}from"../../../../core/handleUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import i from"../../../../core/ReactiveMap.js";import{initial as a,watch as o,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import{create as d,fromPoints as f}from"../../../../geometry/support/lineSegment.js";import{LineOfSightInteractionVisuals as p}from"./LineOfSightInteractionVisuals.js";import{LineOfSightObserverManipulator as m,LineOfSightTargetManipulator as h,LineOfSightTargetManipulatorState as g,getInteractiveLineOfSightTargetManipulatorState as _}from"./LineOfSightManipulators.js";import{SnappingVisualizer3D as v}from"../../interactive/SnappingVisualizer3D.js";import{screenToMapAtSceneSurface as y}from"../../interactive/editingTools/dragEventPipeline3D.js";import{mouseButtons as b}from"../../../input/mouseButtons.js";import{createManipulatorDragEventPipeline as x,dragAtLocation as S,sceneSnappingAtLocation as C,dragManipulatedObject as w}from"../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as T}from"../../../interactive/InteractiveToolBase.js";import{SnappingContext as E}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{enterInputModeIfAvailable as O}from"../../../interactive/tooltip/tooltipCommonUtils.js";const k=d(),A=Symbol(`inactiveManipulatorDisplay`);let j=class extends T{get _manipulatorsToHide(){let e=this._manipulatorByObject.values();return this.view.tools.some(e=>e.hasGrabbedManipulators)||e.some(e=>e.grabbing)?e.filter(e=>!e.grabbing).toArray():[]}constructor(e){super(e),this.events=new t,this.automaticManipulatorSelection=!1,this.removeIncompleteOnCancel=!1,this.interacting=!1,this.manipulatorsInteractive=!0,this._objectByItem=new Map,this._manipulatorByObject=new i,this._updatingHandles=new u,this._interactionVisuals=null,this._grabbedManipulator=null,this._visualsManipulator=null}initialize(){let{view:e}=this;this._interactionVisuals=new p({view:e}),this.addHandles([this._updatingHandles.add(()=>({analysisVisible:this.analysisViewData.visible,computations:this.analysisViewData.computations.toArray().map(e=>({isTargetVisible:e.computationResult.isTargetVisible,isValid:e.computationResult.isValid,target:e.target})),grabbedManipulator:this._grabbedManipulator,interacting:this.interacting,manipulatorsInteractive:this.manipulatorsInteractive,visible:this.visible}),()=>this._syncManipulators(),a),o(()=>this._manipulatorsToHide,e=>{let t=e.map(e=>e.disableDisplay());this.removeHandles(A),this.addHandles(t,A)},s)]),this.finishToolCreation()}destroy(){this.removeHandles(A),this._interactionVisuals=r(this._interactionVisuals),this._updatingHandles.destroy(),this._objectByItem.clear(),this._manipulatorByObject.clear(),super.destroy()}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}get laserLineVisualElement(){return this._interactionVisuals?.laserLineVisualElement??null}get verticalLineVisualElement(){return this._interactionVisuals?.verticalLineVisualElement??null}showInteractionVisuals(e){this._visualsManipulator=this._manipulatorByObject.get(e),this._syncInteractionVisuals()}hideInteractionVisuals(){this._visualsManipulator=null,this._syncInteractionVisuals()}addObject(e){if(this._manipulatorByObject.has(e))return;let t=e.item.type===`observer`?new m(this.view,{deleting:!1,intersection:null,type:`observer`}):new h(this.view,{deleting:!1,target:e.item,type:`target`});t.cursor=`move`,this._objectByItem.set(e.item,e),this._manipulatorByObject.set(e,t),this.manipulators.add(t),this.addHandles(this._connectManipulator(e,t),e),this._syncManipulator(e,t)}removeObject(e){let t=this._manipulatorByObject.get(e);t!=null&&(this._grabbedManipulator===t&&(this._grabbedManipulator=null),this._visualsManipulator===t&&this.hideInteractionVisuals(),this.removeHandles(e),this.removeHandles(e),this._objectByItem.delete(e.item),this._manipulatorByObject.delete(e),this.manipulators.remove(t),t.destroy())}getManipulator(e){let t=this._objectByItem.get(e);return t==null?null:this._manipulatorByObject.get(t)}hasManipulatorAt(e,t){for(let n of this._manipulatorByObject.values())if(n.consumesClicks&&n.intersectionDistance(e,t)!=null)return!0;return!1}selectObject(e){let t=!1;for(let[n,r]of this._manipulatorByObject){let i=n===e;r.selected=i,t||=i}return this._syncManipulators(),t}onInputEvent(e){e.type===`hold`&&this._grabbedManipulator!=null&&(this._visualsManipulator=this._grabbedManipulator,this._syncInteractionVisuals()),O(e,this.tooltip)}onManipulatorSelectionChanged(){[...this._manipulatorByObject.values()].some(e=>e.selected)||this.events.emit(`selection-cleared`)}_connectManipulator(e,t){let r=()=>this._syncManipulator(e,t);return n([e.on(`committed`,r),e.on(`modified-externally`,r),t.events.on(`immediate-click`,n=>{this.events.emit(`select-item`,{item:e.item}),n.button===b.Right&&t.metadata.type===`target`&&this.events.emit(`delete-item`,{target:t.metadata.target}),n.stopPropagation()}),t.events.on(`grab-changed`,({action:n})=>{n===`start`?(this.events.emit(`select-item`,{item:e.item}),this._grabbedManipulator=t):this._grabbedManipulator===t&&(this._grabbedManipulator=null,this.hideInteractionVisuals()),this._manipulatorByObject.set(e,t)}),t.events.on(`drag`,t=>{e.updateDragIntersection(t),t.action===`start`&&this.showInteractionVisuals(e)}),t.events.on(`location-update`,()=>this._syncInteractionVisuals()),this._createDragHandle(e,t)])}_createDragHandle(e,t){return x(t,(n,r,i,a)=>{let o=e.operations;if(o==null)return;let s=null,{cancelSnapping:c,snappingStep:l}=D({snappingContext:new E({editGeometryOperations:o,elevationInfo:e.elevationInfo,pointer:a,visualizer:new v}),snappingManager:this.snappingManager,updatingHandles:this._updatingHandles,useZ:!0});i.next(e=>(s?.undo(null),s=null,e)).next(c);let u=o.data.allVerticesUnordered.at(0);r.next(t=>(t.action===`start`&&(s=e.createUndoRecord()),{...t,snapOrigin:u?.pos})).next(S(this.view,t.elevationAlignedLocation)).next(y(this.view,o.data.geometry,e.elevationInfo,o.data.spatialReference)).next(C(this.view,e.elevationInfo)).next(...l).next(w(e)).next(e=>(e.action===`end`&&s!=null&&(this.events.emit(`record-undo`,{record:s}),s=null),e))})}_syncManipulators(){for(let[e,t]of this._manipulatorByObject)this._syncManipulator(e,t);this._syncInteractionVisuals()}_syncManipulator(e,t){let n=e.origin;if(t.available=this.visible&&e.visible&&n!=null,t.interactive=this.manipulatorsInteractive&&(this._grabbedManipulator==null||this._grabbedManipulator===t),n!=null&&(t.elevationAlignedLocation=n),e.item.type!==`target`)return;let r=this.analysisViewData.computations.find(t=>t.target===e.item),i=r==null||!r.computationResult.isValid?g.undefined:r.computationResult.isTargetVisible?g.visible:g.occluded;t.state=this.interacting&&t.selected?_(i):i}_syncInteractionVisuals(){let e=this._interactionVisuals,t=this._visualsManipulator,n=this.visible&&this.analysisViewData.visible;if(e==null||t==null||!n){e?.hide();return}let r=[...this._manipulatorByObject.entries()].find(([e])=>e.item.type===`observer`)?.[1];if(r==null){e.hide();return}let i=t===r?null:f(r.renderLocation,t.renderLocation,k);e.update({target:t.renderLocation,lineVerticalPlaneSegment:i,visible:!0})}};e([c({constructOnly:!0})],j.prototype,`analysisViewData`,void 0),e([c({constructOnly:!0})],j.prototype,`snappingManager`,void 0),e([c({constructOnly:!0})],j.prototype,`view`,void 0),e([c({constructOnly:!0})],j.prototype,`tooltip`,void 0),e([c()],j.prototype,`automaticManipulatorSelection`,void 0),e([c()],j.prototype,`removeIncompleteOnCancel`,void 0),e([c()],j.prototype,`interacting`,void 0),e([c()],j.prototype,`manipulatorsInteractive`,void 0),e([c()],j.prototype,`_grabbedManipulator`,void 0),e([c()],j.prototype,`_manipulatorsToHide`,null),e([c()],j.prototype,`updating`,null),j=e([l(`esri.views.3d.analysis.LineOfSight.LineOfSightItemTool`)],j);export{j as LineOfSightItemTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Collection.js";import{EventEmitter as r}from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{debounce as o}from"../../../../../core/promiseUtils.js";import{scale as s,zeroMeters as c}from"../../../../../core/quantity.js";import{watch as l,initial as u,syncAndInitial as d}from"../../../../../core/reactiveUtils.js";import{property as f,subclass as p}from"../../../../../core/accessorSupport/decorators.js";import{ensureType as m}from"../../../../../core/accessorSupport/ensureType.js";import{UpdatingHandles as ee}from"../../../../../core/support/UpdatingHandles.js";import te from"../../../../../geometry/Point.js";import{makeDehydratedPoint as h}from"../../../../../layers/graphics/dehydratedPoint.js";import{SnappingVisualizer3D as g}from"../../SnappingVisualizer3D.js";import{orientation as _}from"../geometryUtils.js";import{manipulatedObjectGeometry as v,supportsElevationMode as y}from"../manipulatedObjectUtils.js";import{canMoveZOperations as b}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as x}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as S}from"../tooltipUtils3D.js";import{createVisualElements as C}from"../visualElementUtils.js";import{discRadius as ne}from"../manipulations/config.js";import{MoveManipulation as w}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as T}from"../manipulations/moveUtils.js";import{MoveXYObjectManipulation as E}from"../manipulations/MoveXYObjectManipulation.js";import{isSupportedObject as D}from"./isSupportedObject.js";import{OutlineVisualElement as O}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as k}from"../../../support/elevationUpdateUtils.js";import{dragManipulatedObjectMany as A,resetManipulatedObjectMany as j}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as M}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as N}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import P from"../../../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as F}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as I}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as L,enterInputModeIfAvailable as R}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as z}from"../../../../interactive/tooltip/infos/MovePointTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{TranslateXYTooltipInfo as V}from"../../../../interactive/tooltip/infos/TranslateXYTooltipInfo.js";import{TranslateZTooltipInfo as H}from"../../../../interactive/tooltip/infos/TranslateZTooltipInfo.js";import{verticalSignedDistanceBetweenPoints as U}from"../../../../support/euclideanLengthMeasurementUtils.js";import{GeometryWorkerHandle as W}from"../../../../support/GeometryWorkerHandle.js";class G{constructor(e){this.objects=e,this.type=`move-start`}}class K{constructor(e,t,n){this.dx=e,this.dy=t,this.objects=n,this.type=`move`}}class q{constructor(e){this.objects=e,this.type=`move-stop`}}class J{constructor(e){this.objects=e,this.type=`hold`}}const Y=Symbol(`manipulators`),X=Symbol(`tooltips`),Z=Symbol(`move-manipulator-display`);let Q=class extends M{get _infos(){return Array.from(this._infosByType.values())}constructor(e){super(e),this._infosByType=new Map,this.events=new r,this.objects=new n,this.enableVisualElements=!0,this.enableZ=!0,this.manipulatorRadius=null,this.toolOptions=new P,this.type=`move-3d`,this._measurementWorker=new W({preloadGeodetic:!0}),this._latestTooltipInfo=null,this._translateTooltipInfo=null,this._translateXYTooltipInfo=null,this._translateZTooltipInfo=null,this._updatingHandles=new ee,this._moveManipulation=null,this._updateMoveTooltipDistanceDebounced=o(this._updateMoveTooltipDistanceAsync.bind(this))}initialize(){let{view:e}=this;this.tooltip=L(()=>({view:e,options:this.toolOptions.tooltips})),this.addHandles(this._updatingHandles.addOnCollectionChange(()=>this.objects,e=>{e.removed.forEach(e=>this.removeHandles(e)),this._updateObjectInfos(e),this._setupObjectUpdateHandles(e.added),this._refreshManipulators(),this._connectTooltips()}));let t=this.objects.toArray();this._updateObjectInfos({added:t,removed:[]}),this._setupObjectUpdateHandles(t),this._refreshManipulators(),this._connectTooltips(),this.finishToolCreation()}destroy(){this.tooltip=a(this.tooltip),this._moveManipulation=a(this._moveManipulation),this._set(`view`,null),this._updatingHandles.destroy(),this._measurementWorker.destroy()}onInputEvent(e){if(this.destroyed||R(e,this.tooltip))return;let t=this.firstGrabbedManipulator;if(e.type===`hold`&&t!=null){let e=this._getActiveObjectInfos(this._infos,t).map(({object:e})=>e);this.events.emit(`hold`,new J(e))}return super.onInputEvent(e)}get updating(){return this._updatingHandles.updating||!!this.snappingManager?.updating}get _shouldShowMovePointTooltip(){let{objects:e}=this;if(e.length!==1)return!1;let t=v(e.at(0))?.type;return t===`point`||t===`mesh`}get activeTooltipInfo(){return this._shouldShowMovePointTooltip?this._movePointTooltipInfo:this._latestTooltipInfo}reset(){}_updateObjectInfos({added:e,removed:t}){for(let t of e){if(D(t)!==0)continue;let e=new re(t);this._infosByType.set(t,e)}for(let e of t)this._infosByType.delete(e)}_setupObjectUpdateHandles(e){for(let t of e){let e=this._infosByType.get(t);this.addHandles(x(e.object),t),y(t)&&this.addHandles(l(()=>{let{mode:e,unit:n,offset:r}=t.elevationInfo;return[e,n,r]},()=>this._refreshManipulators()),t)}}_refreshManipulators(){if(this.removeHandles(Y),this.removeHandles(Z),this._moveManipulation=a(this._moveManipulation),this.manipulators.removeAll(),this._infosByType.size===0)return;let e=this._infos;this._createManipulators(e),this._createVisualElements(e),this._updateMoveManipulation(e)}_createManipulators(e){for(let t of e){let n=t.object;t.manipulationXY=new E({tool:this,view:this.view,object:n}),t.manipulationXY.forEachManipulator(e=>{this.addHandles([e.events.on(`immediate-click`,e=>{this.events.emit(`immediate-click`,{...e,object:n}),e.stopPropagation()}),e.events.on(`grab-changed`,({action:e})=>{e===`start`?this._showTooltip(0):this._hideTooltip(),this._updateMoveManipulatorDisplay()})],Y)}),this.addHandles(t.manipulationXY.createDragPipeline((t,n,r,i)=>this._buildDragEventPipeline(e,0,t,n,r,i)),Y)}this._createMoveManipulation(e)}_updateMoveManipulatorDisplay(){let e=this._infos.some(e=>e.manipulationXY?.grabbing);this._moveManipulation&&(this._moveManipulation.interactive=!e),this.removeHandles(Z),e&&this._moveManipulation&&this.addHandles(this._moveManipulation.hideManipulators(),Z)}_createMoveManipulation(e){let t=new w({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:this.manipulatorRadius??(e.length===1?w.radiusForSymbol(e[0].object.graphic?.symbol):ne)});this._moveManipulation=t,t.elevationInfo={mode:`absolute-height`,offset:0},t.forEachManipulator(e=>{this.addHandles(e.events.on(`immediate-click`,n=>{let r=this.objects.at(0);!t.zManipulation.hasManipulator(e)&&this.objects.length===1&&r&&this.events.emit(`immediate-click`,{...n,object:r}),n.stopPropagation()}),Y)});let n=e=>t=>{this.addHandles([t.events.on(`focus-changed`,({action:t})=>{t===`focus`?this._showTooltip(e):this._hideTooltip()}),t.events.on(`grab-changed`,()=>{this._latestTooltipInfo&&(this._latestTooltipInfo.distance=c)})],Y)};this._moveManipulation.xyManipulation.forEachManipulator(n(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(n(1)),this._moveManipulation.zManipulation.forEachManipulator(n(2));let r=()=>this._updateMoveManipulation(e);for(let t of e){this.addHandles([t.object.on(`committed`,r),this._updatingHandles.add(()=>t.object.visible,r)],Y);let n=Symbol();this.addHandles(this._updatingHandles.add(()=>t.object.isDraped,r=>{this._updateMoveManipulation(e),this.removeHandles(n),r&&this.addHandles(k({view:this.view,geometry:t.object.graphic?.geometry,elevationInfo:t.object.elevationInfo,onElevationChanges:()=>this._updateMoveManipulation(e)}),n)},u),Y),this.addHandles(i(()=>this.removeHandles(n)),Y)}let a=e[e.length-1];this.addHandles(a.object.on(`committed`,()=>this._updateMoveManipulationAngle(a)),Y);let{object:o}=a,{operations:s}=o;if(s){let n=o.graphic;this.addHandles(t.createDragPipeline((t,n,r,i,a)=>this._buildDragEventPipeline(e,t,n,r,i,a),o.elevationInfo,s.data.spatialReference,n),Y)}this._updateMoveManipulationAngle(a)}_createVisualElements(e){if(this.enableVisualElements)for(let t of e){let n=t.object,r=C({view:this.view,object:n,forEachManipulator:e=>{t.manipulationXY?.forEachManipulator(e),this._moveManipulation?.forEachManipulator(e)},onManipulatorsChanged:()=>i()});r!=null&&(t.geometryRepresentation=r.visualElement,t.geometryRepresentation instanceof O&&this.addHandles([t.geometryRepresentation.events.on(`attachment-origin-changed`,()=>{t.object.isDraped||this._updateMoveManipulation(e)}),this._updatingHandles.add(()=>t.object.isDraped,()=>this._updateMoveManipulation(e))],Y),this.addHandles(r,Y))}}_updateMoveManipulationAngle(e){this._moveManipulation&&(this._moveManipulation.angle=_(v(e.object)))}_updateMoveManipulation(e){let t=h(0,0,0,this.view.spatialReference),n=0,r=!1,i=this._moveManipulation;if(i){for(let i of e){if(!i.object.visible)continue;this.enableZ&&b(i.object.operations,i.object.elevationInfo)&&(r=!0);let e=i.geometryRepresentation instanceof O&&!i.object.isDraped?i.geometryRepresentation.attachmentOrigin:i.object.origin;if(e!=null){let{x:r,y:i,z:a}=e;t.x+=r,t.y+=i,a&&(t.z??=0,t.z+=a),n++}}n>0?(t.x/=n,t.y/=n,t.z??=0,t.z/=n,i.location=t,i.xyManipulation.available=!0,i.xyAxisManipulation.available=!0,i.zManipulation.available=r):i.available=!1}}_buildDragEventPipeline(e,t,n,r,i,a){let o=[],s=[],c=null,l=null,u=()=>{for(let e of o)e.dragging=!1;o.length=0,s.length=0,c=null,l=null,this._updateMoveManipulatorDisplay()};if(e.length===1&&t===0){let t=e[0].object;({steps:r,cancel:i}=this._buildSnappingPipelineSteps(t,t.elevationInfo,r,i,a))}return i=i.next(e=>l?.(e)).next(()=>(s.length&&this.events.emit(`move-stop`,new q(s)),this.destroyed||u(),null)),r=r.next(t=>{if(t.action===`start`){o.length=0,s.length=0;for(let t of this._getActiveObjectInfos(e,n))o.push(t),s.push(t.object),t.dragging=!0;if(s.length!==0&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),c=A(s),l=j(s),this._emitRecordUndo(),this.events.emit(`move-start`,new G(s)),this.destroyed))return null}return s.length===0?null:t}).next(e=>c?.(e)).next(e=>(this._updateMoveTooltip(t,e),e)).next(e=>{switch(e.action){case`start`:case`update`:if(e.translationX||e.translationY||e.translationZ){let t=this.view.toScreen(e.mapStart),n=this.view.toScreen(e.mapEnd);if(!t||!n)return null;let r=n.x-t.x,i=n.y-t.y;if(this.events.emit(`move`,new K(r,i,s)),this.destroyed)return null}break;case`end`:if(this.events.emit(`move-stop`,new q(s)),this.destroyed)return null;u()}return null}),{steps:r,cancel:i}}_getActiveObjectInfos(e,t){return e.filter(e=>!e.dragging&&(e.manipulationXY?.hasManipulator(t)||!e.manipulationXY?.grabbing))}_connectTooltips(){this.removeHandles(X);let e;if(this._shouldShowMovePointTooltip){let t=this.objects.at(0),{events:n}=this;this._movePointTooltipInfo??=new z({viewType:this.view.type,toolOptions:this.toolOptions});let r={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),n.emit(`move-start`,new G([t]))},onMove:()=>n.emit(`move`,new K(0,0,[t])),onMoveStop:()=>n.emit(`move-stop`,new q([t])),onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}};e=S(this.tooltip,t,()=>({toolOptions:this.toolOptions,activeTooltipInfo:this._movePointTooltipInfo,callbacks:r,onRecordUndo:e=>n.emit(`record-undo`,{updates:[e]})}))}else e=this._updatingHandles.add(()=>this.toolOptions.tooltips.effectiveEnabled?this._latestTooltipInfo:null,e=>{this.tooltip.info=e},d);this.addHandles(e,X)}_showTooltip(e){this._shouldShowMovePointTooltip||this._updateMoveTooltip(e)}_hideTooltip(){this._shouldShowMovePointTooltip||(this.tooltip?.clear(),this._latestTooltipInfo=null)}_updateMoveTooltip(e,t){if(this._shouldShowMovePointTooltip)return;let{toolOptions:n}=this;switch(e){case 0:this._latestTooltipInfo=this._translateTooltipInfo??=new B({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,(e,t)=>this._measurementWorker.autoDistance2DBetweenPoints($(e),$(t))));break;case 1:this._latestTooltipInfo=this._translateXYTooltipInfo??=new V({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,async(e,n)=>s(await this._measurementWorker.autoDistance2DBetweenPoints($(e),$(n)),T(t))));break;case 2:this._latestTooltipInfo=this._translateZTooltipInfo??=new H({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,U))}this._latestTooltipInfo.toolOptions=n}async _updateMoveTooltipDistanceAsync(e,t,n){if(t!=null&&t.action!==`end`){let{mapStart:r,mapEnd:i}=t;e.distance=await n(r,i)??c}else e.distance=c}_emitRecordUndo(){let e=this.objects.toArray().map(e=>e.createUndoRecord?.()).filter(t);e.length>0&&this.events.emit(`record-undo`,{updates:e})}_buildSnappingPipelineSteps(e,t,n,r,i){let a=v(e);if(a==null||a.type!==`point`&&a.type!==`mesh`)return{steps:n,cancel:r};let o=(a.type===`point`?a:a.origin).clone(),s=new F({elevationInfo:t,pointer:i,editGeometryOperations:N.fromGeometry(o,this.view.state.viewingMode),visualizer:new g,excludeFeature:e.graphic}),c=this.snappingManager,{snappingStep:l,cancelSnapping:u}=I({snappingContext:s,snappingManager:c,updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(u),n=n.next(e=>{let t=s.coordinateHelper.pointToVector(o);return{...e,snapOrigin:t}}).next(...l),{steps:n,cancel:r}}get test(){}};e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`view`,void 0),e([f()],Q.prototype,`objects`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableVisualElements`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableZ`,void 0),e([f({constructOnly:!0})],Q.prototype,`manipulatorRadius`,void 0),e([f({constructOnly:!0,type:P})],Q.prototype,`toolOptions`,void 0),e([f({constructOnly:!0})],Q.prototype,`snappingManager`,void 0),e([f()],Q.prototype,`type`,void 0),e([f()],Q.prototype,`updating`,null),e([f()],Q.prototype,`_latestTooltipInfo`,void 0),e([f()],Q.prototype,`_shouldShowMovePointTooltip`,null),e([f()],Q.prototype,`activeTooltipInfo`,null),Q=e([p(`esri.views.3d.interactive.editingTools.move.MoveTool3D`)],Q);const $=m(te);class re{constructor(e){this.object=e,this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1}}export{J as HoldEvent,K as MoveEvent,G as MoveStartEvent,q as MoveStopEvent,Q as MoveTool3D};
|
|
2
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Collection.js";import{EventEmitter as r}from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{debounce as o}from"../../../../../core/promiseUtils.js";import{scale as s,zeroMeters as c}from"../../../../../core/quantity.js";import{watch as l,initial as u,syncAndInitial as d}from"../../../../../core/reactiveUtils.js";import{property as f,subclass as p}from"../../../../../core/accessorSupport/decorators.js";import{ensureType as m}from"../../../../../core/accessorSupport/ensureType.js";import{UpdatingHandles as ee}from"../../../../../core/support/UpdatingHandles.js";import te from"../../../../../geometry/Point.js";import{makeDehydratedPoint as h}from"../../../../../layers/graphics/dehydratedPoint.js";import{SnappingVisualizer3D as g}from"../../SnappingVisualizer3D.js";import{orientation as _}from"../geometryUtils.js";import{manipulatedObjectGeometry as v,supportsElevationMode as y}from"../manipulatedObjectUtils.js";import{canMoveZOperations as b}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as x}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as S}from"../tooltipUtils3D.js";import{createVisualElements as C}from"../visualElementUtils.js";import{discRadius as ne}from"../manipulations/config.js";import{MoveManipulation as w}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as T}from"../manipulations/moveUtils.js";import{MoveXYObjectManipulation as E}from"../manipulations/MoveXYObjectManipulation.js";import{isSupportedObject as D}from"./isSupportedObject.js";import{OutlineVisualElement as O}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as k}from"../../../support/elevationUpdateUtils.js";import{dragManipulatedObjectMany as A,resetManipulatedObjectMany as j}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as M}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as N}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import P from"../../../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as F}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as I}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as L,enterInputModeIfAvailable as R}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as z}from"../../../../interactive/tooltip/infos/MovePointTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{TranslateXYTooltipInfo as V}from"../../../../interactive/tooltip/infos/TranslateXYTooltipInfo.js";import{TranslateZTooltipInfo as H}from"../../../../interactive/tooltip/infos/TranslateZTooltipInfo.js";import{verticalSignedDistanceBetweenPoints as U}from"../../../../support/euclideanLengthMeasurementUtils.js";import{GeometryWorkerHandle as W}from"../../../../support/GeometryWorkerHandle.js";class G{constructor(e){this.objects=e,this.type=`move-start`}}class K{constructor(e,t,n){this.dx=e,this.dy=t,this.objects=n,this.type=`move`}}class q{constructor(e){this.objects=e,this.type=`move-stop`}}class J{constructor(e){this.objects=e,this.type=`hold`}}const Y=Symbol(`manipulators`),X=Symbol(`tooltips`),Z=Symbol(`move-manipulator-display`);let Q=class extends M{get _infos(){return Array.from(this._infosByType.values())}constructor(e){super(e),this._infosByType=new Map,this.events=new r,this.objects=new n,this.enableVisualElements=!0,this.enableZ=!0,this.manipulatorRadius=null,this.toolOptions=new P,this.type=`move-3d`,this._measurementWorker=new W({preloadGeodetic:!0}),this._ownedTooltip=null,this._latestTooltipInfo=null,this._translateTooltipInfo=null,this._translateXYTooltipInfo=null,this._translateZTooltipInfo=null,this._updatingHandles=new ee,this._moveManipulation=null,this._updateMoveTooltipDistanceDebounced=o(this._updateMoveTooltipDistanceAsync.bind(this))}initialize(){let{view:e}=this;this.tooltip??=this._ownedTooltip=L(()=>({view:e,options:this.toolOptions.tooltips})),this.addHandles(this._updatingHandles.addOnCollectionChange(()=>this.objects,e=>{e.removed.forEach(e=>this.removeHandles(e)),this._updateObjectInfos(e),this._setupObjectUpdateHandles(e.added),this._refreshManipulators(),this._connectTooltips()}));let t=this.objects.toArray();this._updateObjectInfos({added:t,removed:[]}),this._setupObjectUpdateHandles(t),this._refreshManipulators(),this._connectTooltips(),this.finishToolCreation()}destroy(){this._ownedTooltip=a(this._ownedTooltip),this._moveManipulation=a(this._moveManipulation),this._set(`view`,null),this._updatingHandles.destroy(),this._measurementWorker.destroy()}onInputEvent(e){if(this.destroyed||R(e,this.tooltip))return;let t=this.firstGrabbedManipulator;if(e.type===`hold`&&t!=null){let e=this._getActiveObjectInfos(this._infos,t).map(({object:e})=>e);this.events.emit(`hold`,new J(e))}return super.onInputEvent(e)}get updating(){return this._updatingHandles.updating||!!this.snappingManager?.updating}get _shouldShowMovePointTooltip(){let{objects:e}=this;if(e.length!==1)return!1;let t=v(e.at(0))?.type;return t===`point`||t===`mesh`}get activeTooltipInfo(){return this._shouldShowMovePointTooltip?this._movePointTooltipInfo:this._latestTooltipInfo}reset(){}_updateObjectInfos({added:e,removed:t}){for(let t of e){if(D(t)!==0)continue;let e=new re(t);this._infosByType.set(t,e)}for(let e of t)this._infosByType.delete(e)}_setupObjectUpdateHandles(e){for(let t of e){let e=this._infosByType.get(t);this.addHandles(x(e.object),t),y(t)&&this.addHandles(l(()=>{let{mode:e,unit:n,offset:r}=t.elevationInfo;return[e,n,r]},()=>this._refreshManipulators()),t)}}_refreshManipulators(){if(this.removeHandles(Y),this.removeHandles(Z),this._moveManipulation=a(this._moveManipulation),this.manipulators.removeAll(),this._infosByType.size===0)return;let e=this._infos;this._createManipulators(e),this._createVisualElements(e),this._updateMoveManipulation(e)}_createManipulators(e){for(let t of e){let n=t.object;t.manipulationXY=new E({tool:this,view:this.view,object:n}),t.manipulationXY.forEachManipulator(e=>{this.addHandles([e.events.on(`immediate-click`,e=>{this.events.emit(`immediate-click`,{...e,object:n}),e.stopPropagation()}),e.events.on(`grab-changed`,({action:e})=>{e===`start`?this._showTooltip(0):this._hideTooltip(),this._updateMoveManipulatorDisplay()})],Y)}),this.addHandles(t.manipulationXY.createDragPipeline((t,n,r,i)=>this._buildDragEventPipeline(e,0,t,n,r,i)),Y)}this._createMoveManipulation(e)}_updateMoveManipulatorDisplay(){let e=this._infos.some(e=>e.manipulationXY?.grabbing);this._moveManipulation&&(this._moveManipulation.interactive=!e),this.removeHandles(Z),e&&this._moveManipulation&&this.addHandles(this._moveManipulation.hideManipulators(),Z)}_createMoveManipulation(e){let t=new w({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:this.manipulatorRadius??(e.length===1?w.radiusForSymbol(e[0].object.graphic?.symbol):ne)});this._moveManipulation=t,t.elevationInfo={mode:`absolute-height`,offset:0},t.forEachManipulator(e=>{this.addHandles(e.events.on(`immediate-click`,n=>{let r=this.objects.at(0);!t.zManipulation.hasManipulator(e)&&this.objects.length===1&&r&&this.events.emit(`immediate-click`,{...n,object:r}),n.stopPropagation()}),Y)});let n=e=>t=>{this.addHandles([t.events.on(`focus-changed`,({action:t})=>{t===`focus`?this._showTooltip(e):this._hideTooltip()}),t.events.on(`grab-changed`,()=>{this._latestTooltipInfo&&(this._latestTooltipInfo.distance=c)})],Y)};this._moveManipulation.xyManipulation.forEachManipulator(n(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(n(1)),this._moveManipulation.zManipulation.forEachManipulator(n(2));let r=()=>this._updateMoveManipulation(e);for(let t of e){this.addHandles([t.object.on(`committed`,r),this._updatingHandles.add(()=>t.object.visible,r)],Y);let n=Symbol();this.addHandles(this._updatingHandles.add(()=>t.object.isDraped,r=>{this._updateMoveManipulation(e),this.removeHandles(n),r&&this.addHandles(k({view:this.view,geometry:t.object.graphic?.geometry,elevationInfo:t.object.elevationInfo,onElevationChanges:()=>this._updateMoveManipulation(e)}),n)},u),Y),this.addHandles(i(()=>this.removeHandles(n)),Y)}let a=e[e.length-1];this.addHandles(a.object.on(`committed`,()=>this._updateMoveManipulationAngle(a)),Y);let{object:o}=a,{operations:s}=o;if(s){let n=o.graphic;this.addHandles(t.createDragPipeline((t,n,r,i,a)=>this._buildDragEventPipeline(e,t,n,r,i,a),o.elevationInfo,s.data.spatialReference,n),Y)}this._updateMoveManipulationAngle(a)}_createVisualElements(e){if(this.enableVisualElements)for(let t of e){let n=t.object,r=C({view:this.view,object:n,forEachManipulator:e=>{t.manipulationXY?.forEachManipulator(e),this._moveManipulation?.forEachManipulator(e)},onManipulatorsChanged:()=>i()});r!=null&&(t.geometryRepresentation=r.visualElement,t.geometryRepresentation instanceof O&&this.addHandles([t.geometryRepresentation.events.on(`attachment-origin-changed`,()=>{t.object.isDraped||this._updateMoveManipulation(e)}),this._updatingHandles.add(()=>t.object.isDraped,()=>this._updateMoveManipulation(e))],Y),this.addHandles(r,Y))}}_updateMoveManipulationAngle(e){this._moveManipulation&&(this._moveManipulation.angle=_(v(e.object)))}_updateMoveManipulation(e){let t=h(0,0,0,this.view.spatialReference),n=0,r=!1,i=this._moveManipulation;if(i){for(let i of e){if(!i.object.visible)continue;this.enableZ&&b(i.object.operations,i.object.elevationInfo)&&(r=!0);let e=i.geometryRepresentation instanceof O&&!i.object.isDraped?i.geometryRepresentation.attachmentOrigin:i.object.origin;if(e!=null){let{x:r,y:i,z:a}=e;t.x+=r,t.y+=i,a&&(t.z??=0,t.z+=a),n++}}n>0?(t.x/=n,t.y/=n,t.z??=0,t.z/=n,i.location=t,i.xyManipulation.available=!0,i.xyAxisManipulation.available=!0,i.zManipulation.available=r):i.available=!1}}_buildDragEventPipeline(e,t,n,r,i,a){let o=[],s=[],c=null,l=null,u=()=>{for(let e of o)e.dragging=!1;o.length=0,s.length=0,c=null,l=null,this._updateMoveManipulatorDisplay()};if(e.length===1&&t===0){let t=e[0].object;({steps:r,cancel:i}=this._buildSnappingPipelineSteps(t,t.elevationInfo,r,i,a))}return i=i.next(e=>l?.(e)).next(()=>(s.length&&this.events.emit(`move-stop`,new q(s)),this.destroyed||u(),null)),r=r.next(t=>{if(t.action===`start`){o.length=0,s.length=0;for(let t of this._getActiveObjectInfos(e,n))o.push(t),s.push(t.object),t.dragging=!0;if(s.length!==0&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),c=A(s),l=j(s),this._emitRecordUndo(),this.events.emit(`move-start`,new G(s)),this.destroyed))return null}return s.length===0?null:t}).next(e=>c?.(e)).next(e=>(this._updateMoveTooltip(t,e),e)).next(e=>{switch(e.action){case`start`:case`update`:if(e.translationX||e.translationY||e.translationZ){let t=this.view.toScreen(e.mapStart),n=this.view.toScreen(e.mapEnd);if(!t||!n)return null;let r=n.x-t.x,i=n.y-t.y;if(this.events.emit(`move`,new K(r,i,s)),this.destroyed)return null}break;case`end`:if(this.events.emit(`move-stop`,new q(s)),this.destroyed)return null;u()}return null}),{steps:r,cancel:i}}_getActiveObjectInfos(e,t){return e.filter(e=>!e.dragging&&(e.manipulationXY?.hasManipulator(t)||!e.manipulationXY?.grabbing))}_connectTooltips(){this.removeHandles(X);let e;if(this._shouldShowMovePointTooltip){let t=this.objects.at(0),{events:n}=this;this._movePointTooltipInfo??=new z({viewType:this.view.type,toolOptions:this.toolOptions});let r={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),n.emit(`move-start`,new G([t]))},onMove:()=>n.emit(`move`,new K(0,0,[t])),onMoveStop:()=>n.emit(`move-stop`,new q([t])),onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}};e=S(this.tooltip,t,()=>({toolOptions:this.toolOptions,activeTooltipInfo:this._movePointTooltipInfo,callbacks:r,onRecordUndo:e=>n.emit(`record-undo`,{updates:[e]})}))}else e=this._updatingHandles.add(()=>this.toolOptions.tooltips.effectiveEnabled?this._latestTooltipInfo:null,e=>{this.tooltip.info=e},d);this.addHandles(e,X)}_showTooltip(e){this._shouldShowMovePointTooltip||this._updateMoveTooltip(e)}_hideTooltip(){this._shouldShowMovePointTooltip||(this.tooltip?.clear(),this._latestTooltipInfo=null)}_updateMoveTooltip(e,t){if(this._shouldShowMovePointTooltip)return;let{toolOptions:n}=this;switch(e){case 0:this._latestTooltipInfo=this._translateTooltipInfo??=new B({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,(e,t)=>this._measurementWorker.autoDistance2DBetweenPoints($(e),$(t))));break;case 1:this._latestTooltipInfo=this._translateXYTooltipInfo??=new V({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,async(e,n)=>s(await this._measurementWorker.autoDistance2DBetweenPoints($(e),$(n)),T(t))));break;case 2:this._latestTooltipInfo=this._translateZTooltipInfo??=new H({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,U))}this._latestTooltipInfo.toolOptions=n}async _updateMoveTooltipDistanceAsync(e,t,n){if(t!=null&&t.action!==`end`){let{mapStart:r,mapEnd:i}=t;e.distance=await n(r,i)??c}else e.distance=c}_emitRecordUndo(){let e=this.objects.toArray().map(e=>e.createUndoRecord?.()).filter(t);e.length>0&&this.events.emit(`record-undo`,{updates:e})}_buildSnappingPipelineSteps(e,t,n,r,i){let a=v(e);if(a==null||a.type!==`point`&&a.type!==`mesh`)return{steps:n,cancel:r};let o=(a.type===`point`?a:a.origin).clone(),s=new F({elevationInfo:t,pointer:i,editGeometryOperations:N.fromGeometry(o,this.view.state.viewingMode),visualizer:new g,excludeFeature:e.graphic}),c=this.snappingManager,{snappingStep:l,cancelSnapping:u}=I({snappingContext:s,snappingManager:c,updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(u),n=n.next(e=>{let t=s.coordinateHelper.pointToVector(o);return{...e,snapOrigin:t}}).next(...l),{steps:n,cancel:r}}get test(){}};e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`view`,void 0),e([f()],Q.prototype,`objects`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableVisualElements`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableZ`,void 0),e([f({constructOnly:!0})],Q.prototype,`manipulatorRadius`,void 0),e([f({constructOnly:!0,type:P})],Q.prototype,`toolOptions`,void 0),e([f({constructOnly:!0})],Q.prototype,`snappingManager`,void 0),e([f()],Q.prototype,`type`,void 0),e([f()],Q.prototype,`updating`,null),e([f()],Q.prototype,`tooltip`,void 0),e([f()],Q.prototype,`_ownedTooltip`,void 0),e([f()],Q.prototype,`_latestTooltipInfo`,void 0),e([f()],Q.prototype,`_shouldShowMovePointTooltip`,null),e([f()],Q.prototype,`activeTooltipInfo`,null),Q=e([p(`esri.views.3d.interactive.editingTools.move.MoveTool3D`)],Q);const $=m(te);class re{constructor(e){this.object=e,this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1}}export{J as HoldEvent,K as MoveEvent,G as MoveStartEvent,q as MoveStopEvent,Q as MoveTool3D};
|
package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationColorQuantization.glsl.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import{glsl as e}from"../../core/shaderModules/glsl.js";function t(t){t.code.add(e`
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
vec4 quantizeGlobalIlluminationColor(vec4 color) {
|
|
4
|
+
vec4 clampedColor = clamp(color, vec4(0.0), vec4(1.0));
|
|
5
5
|
return floor(clampedColor * ${e.float(255)} + 0.5) * ${e.float(1/255)};
|
|
6
6
|
}
|
|
7
7
|
`)}export{t as GlobalIlluminationColorQuantization};
|
|
@@ -67,6 +67,7 @@ export interface SnappingOptionsProperties extends Partial<Pick<SnappingOptions,
|
|
|
67
67
|
* @see [Sketch](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/)
|
|
68
68
|
* @see [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/)
|
|
69
69
|
* @see [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/)
|
|
70
|
+
* @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
|
|
70
71
|
* @see [Sample - Sketch widget](https://developers.arcgis.com/javascript/latest/sample-code/sketch-geometries/)
|
|
71
72
|
* @see [Sample - Sketch in 3D](https://developers.arcgis.com/javascript/latest/sample-code/sketch-3d/)
|
|
72
73
|
* @see [Sample - Edit features in 3D with the Editor widget](https://developers.arcgis.com/javascript/latest/sample-code/editor-3d/)
|
|
@@ -93,6 +93,7 @@ export interface TooltipOptionsProperties extends Partial<Pick<TooltipOptions, "
|
|
|
93
93
|
* @since 5.2
|
|
94
94
|
* @see [LabelOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/LabelOptions/)
|
|
95
95
|
* @see [ValueOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ValueOptions/)
|
|
96
|
+
* @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
|
|
96
97
|
* @see [Sample - Sketch in 3D](https://developers.arcgis.com/javascript/latest/sample-code/sketch-3d/)
|
|
97
98
|
* @see [Sample - Edit features in 3D with the Editor widget](https://developers.arcgis.com/javascript/latest/sample-code/editor-3d/)
|
|
98
99
|
*/
|
|
@@ -124,6 +124,7 @@ export interface ViewOptionsProperties {
|
|
|
124
124
|
*
|
|
125
125
|
* @beta
|
|
126
126
|
* @since 5.2
|
|
127
|
+
* @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
|
|
127
128
|
*/
|
|
128
129
|
export default class ViewOptions extends Accessor {
|
|
129
130
|
/** @since 5.2 */
|
|
@@ -10,6 +10,7 @@ export interface UnitsProperties extends Partial<Pick<Units, "area" | "length" |
|
|
|
10
10
|
* Each quantity accepts a specific unit or measurement system (`"metric"` or `"imperial"`).
|
|
11
11
|
*
|
|
12
12
|
* @since 5.2
|
|
13
|
+
* @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
|
|
13
14
|
*/
|
|
14
15
|
export default class Units extends Accessor {
|
|
15
16
|
/** @since 5.2 */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"./FeatureLikeLayerView.js";class t extends e{constructor(){super(...arguments),this.layer=null}}export{t as default};
|
|
2
|
+
import e from"./FeatureLikeLayerView.js";class t extends e{constructor(){super(...arguments),this.layer=null}async _updateHasZM(){let e=this.layer.hasZ,t=this.layer.hasM;this.hasZ!==e&&this._set(`hasZ`,e),this.hasM!==t&&this._set(`hasM`,t)}}export{t as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{destroyMaybe as c,abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as u,whenOrAbort as ee,ignoreAbortErrors as d,isAbortError as f}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as te,sync as m,watch as h,syncAndInitial as g,initial as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as y,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as ne}from"../../core/support/UpdatingHandles.js";import x from"../../geometry/SpatialReference.js";import{getGraphicLayer as S}from"../../graphic/graphicOriginUtils.js";import{isSubtypeGroupLayer as C,isSubtypeSublayer as w,isFeatureLayer as re,getSubtypesFromLayer as ie}from"../../layers/support/layerUtils.js";import{system as T}from"../../time/constants.js";import{getAttachmentKey as E}from"./attachmentUtils.js";import{getLayerTimeZone as D,getEffectiveTimeZone as O,createReactiveGraphic as k,isAttributeFormSupportedLayerWithAttachments as A,layerSupportsAttachments as j,queryAttachmentsForElements as M}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as N}from"./ReactiveContingentValuesManager.js";import{parseFormTemplateString as P}from"./stringUtils.js";import{ValueChangeTransaction as F}from"./ValueChangeTransaction.js";import{ArcadeExecutorProvider as I}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as L}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as R}from"./expressions/ExpressionsModel.js";import z from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as B,mergeBatchFormInputsFromNewTemplate as V}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as H,isFieldInput as U}from"./inputs/support/inputUtils.js";import W from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as G}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as K,isGroupElementTemplate as q}from"./templates/support/templateUtils.js";import{ContingentValuesManager as J,isLayerWithContingentValues as Y}from"../support/ContingentValuesManager.js";import{isEmptyValue as X}from"../support/forms/formUtils.js";function ae(e,t){return e?.find(e=>e.layer===t)}let Z=class extends a{constructor(e){super(e),this._attachmentCache=new p,this.activeFeatureIndex=-1,this.attachmentsEnabled=!1,this.callbacks=null,this.disabled=!1,this.editType=`NA`,this.features=new r,this._hasAsyncArcadeExpressions=!1,this.highlightHelper=null,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.pageStack=[],this.readOnly=!1,this.pendingSubtypeChoice=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.view=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new I,this._activeAssociation=null,this._activeAssociationsInput=null,this._activeRelationshipInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new z({inputs:[]}),this._emptyFormTemplate=new W({elements:[]}),this._featureFormMap=new p,this._prepareTask=null,this._layerTemplateUpdateTask=null,this._syncAttachmentsTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new ne,this._submitTask=null,this._layerTemplateMap=new p,this._workingFeatures=new r,this._expressionsManager=new L({arcadeContext:{editType:`NA`,spatialReference:null,map:null,timeZone:T}}),this._getExternalErrorForFeature=(e,t)=>this._reactiveContingentValuesManager.getViolationTypeForField(e,t),this._getFieldValueOptionsForFeature=e=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(e),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||=this._ownContingentValuesManager=new J,this.addHandles([te(()=>this.features,`after-changes`,()=>{this.goHome(),this.notifyChange(`layers`),this._prepare()},m),h(()=>[this.attachmentsEnabled,this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),m),h(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},m),h(()=>this.activeFeature,()=>{this.goHome()},m),h(()=>this.page,e=>{let t=[...this.pageStack];if(!t.includes(e))t.push(e);else for(;t.length&&t.at(-1)!==e;)t.pop();this.pageStack=t},g),h(()=>this.contingentValuesManager,e=>{c(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new N({manager:e})},_)]),this._prepare()}destroy(){this._prepareTask=l(this._prepareTask),this.pendingSubtypeChoice?.reject(),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._syncAttachmentsTask=l(this._syncAttachmentsTask),this._workingFeatures.destroyAll(),c(this._expressionsManager),c(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=c(this._ownContingentValuesManager),this.highlightHelper?.removeAll()}get activeFeature(){let e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if(this.mode===`batch`)return this.sharedForm;let e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;let t=this._featureFormMap.get(e);if(t)return t;let n=this._makeBatchFormInputsForFeature(e);return n!==this._emptyForm&&this._featureFormMap.set(e,n),n}get activeLayer(){let{activeFeature:e}=this;return e?S(e)??null:null}get activeAssociation(){return this._activeAssociation}get activeAssociationsInput(){return this._activeAssociationsInput}get activeAssociationType(){return this.activeAssociationsInput?.activeAssociationType}get activeRelationshipInput(){return this._activeRelationshipInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get canGoBack(){return this.pageStack.length>1}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if(this.mode===`batch`)return!1;let{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){let e=this.contingentValuesManager;for(let t of this.layers)if(e.getFieldsWithContingentValues(t).size>0)return!0;return!1}get formDescription(){return this._computeFormHeaderField(this.activeForm?.description)}get formTitle(){return this._computeFormHeaderField(this.activeForm?.title)}get effectiveTimeZone(){let{activeLayer:e,timeZone:t}=this;if(!e)return t??`system`;let n=D(e);return O(t,n)}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(this.activeForm.inputs.length===0)return`noElements`;let e=new Set;for(let t of this.activeForm.inputs)switch(t.visibilityCode){case`hidden:not-in-all-layers`:case`hidden:no-domain-in-common`:e.add(`noElementsInCommon`);break;case`hidden:field-definition`:case`hidden:group-visibility-expression:all-features`:case`hidden:visibility-expression:all-features`:e.add(`allElementsHidden`);break;case`hidden:group-visibility-expression:some-features`:case`hidden:visibility-expression:some-features`:return`elementsHiddenInSome`}return e.has(`allElementsHidden`)?`allElementsHidden`:`noElementsInCommon`}get page(){return this.showingSelectedAttachmentReplacePage&&this.selectedAttachmentDetails?`replacing-attachment`:this.selectedAttachmentDetails?`viewing-attachment-details`:this.selectedAttachmentAddInput?`adding-attachments`:this.selectedAttachmentListInput?`viewing-attachments`:this.activeAssociationsInput?.associatedLayer?`viewing-associated-features`:this.activeAssociationsInput?`viewing-associated-layers`:this.activeRelationshipInput?.showAllRelatedRecords?`viewing-related-records`:this.activeRelationshipInput?.showAllCategories?`viewing-related-categories`:`default`}get subtypes(){let e=this.activeLayer;return C(e)||w(e)||re(e)?ie(e):[]}get status(){let e=this._prepareTask;return e==null?`not-loaded`:e.finished?e.error==null?`loaded`:`failed`:`loading`}get timeZone(){return this.view?.timeZone??null}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){return Array.from(this._layersSet)}get mode(){return this.activeFeatureIndex>-1?`single`:`batch`}submit(){if(this.submitHasBeenAttempted=!0,this.sharedForm.touchAll(),this._featureFormMap.forEach(e=>e.touchAll()),this.validateContingentValues(this._workingFeatures),!this._hasPendingAttachmentHydration)return this._emitSubmit(),Promise.resolve();if(this._submitTask)return this._submitTask.promise;let e=n(async()=>{await Promise.all(this._allAttachmentInputs.map(e=>e.waitForPendingAttachmentUpdateData())),this._emitSubmit()});return this._submitTask=e,e.promise.finally(()=>{this._submitTask===e&&(this._submitTask=null)}),e.promise}get selectedAttachment(){return this._get(`selectedAttachment`)??null}set selectedAttachment(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachment`,e),e!=null&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get(`selectedAttachmentAddElementId`)??null}set selectedAttachmentAddElementId(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachmentAddElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get(`selectedAttachmentListElementId`)??null}set selectedAttachmentListElementId(e){this._set(`selectedAttachmentListElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){let e=this.selectedAttachmentListElementId,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null;return n?.attachments.length?n:null}get showingSelectedAttachmentReplacePage(){return this._get(`showingSelectedAttachmentReplacePage`)??!1}set showingSelectedAttachmentReplacePage(e){this._set(`showingSelectedAttachmentReplacePage`,e&&this.selectedAttachmentDetails!=null)}get selectedAttachmentAddInput(){let e=this.selectedAttachmentAddElementId,t=this.activeForm;return!e||!t?null:t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null}get selectedAttachmentDetails(){let e=this.selectedAttachment,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e.elementId);if(!n)return null;let r=n.attachments.findIndex(t=>E(t)===e.attachmentKey);return r===-1?null:{attachment:n.attachments[r],input:n}}get _allAttachmentInputs(){let e=[...this.sharedForm.allAttachmentElementInputs];for(let t of this._featureFormMap.values())e.push(...t.allAttachmentElementInputs);return e}get _hasPendingAttachmentHydration(){return this._allAttachmentInputs.some(e=>e.hasPendingAttachmentUpdateData)}get _layersSet(){let e=new Set;for(let t of this._workingFeatures){let n=S(t.plainGraphic);n&&e.add(n)}return e}applyStashedAttachmentEdits(e){let t=this._allAttachmentInputs;for(let n of e){let e=t.find(e=>e.label===n.label&&e.attachmentKeyword===n.keywords);e&&e.applyStashedEdits(n)}}findFieldInput(e){if(e==null)return;let t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);let n=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);if(n!==void 0)return t.set(e,n),n}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(let e of this.visibleInputs){if(H(e)){let t=e.inputs.find(e=>U(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(U(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){let t=this._reactiveGraphicLookup.get(e);if(!t)throw new i(`feature-not-found`,`The given feature is not present in the BatchAttributeForm`);return{...t.attributes}}async goBack(){switch(this.page){case`replacing-attachment`:this.setShowingSelectedAttachmentReplacePage(!1);return;case`viewing-attachment-details`:this.setSelectedAttachment(null);return;case`adding-attachments`:this.setSelectedAttachmentAddElementId(null);return;case`viewing-attachments`:this.setSelectedAttachmentListElementId(null);return;case`viewing-associated-features`:this.setActiveAssociationsLayer(null);return;case`viewing-associated-layers`:this.setActiveAssociationsInput(null);return;case`viewing-related-categories`:case`viewing-related-records`:this.clearActiveRelationshipCategoryOrInput();return;default:return}}async goHome(){this.setShowingSelectedAttachmentReplacePage(!1),this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),this.setActiveAssociationsInput(null),this.clearAllRelationshipSettings()}notifyGeometriesChanged(e){let t=[];for(let n of e){let e=this._reactiveGraphicLookup.get(n);e&&(t.push(e),e.geometry=n.geometry)}this._updatingHandles.consumePromise(this._valueChangeTransaction(async e=>this._expressionsManager.runGeometryDependentExpressions(t,e),`user`))}async overrideOriginalFeature(e,t){await this._prepareTask?.promise;let n=this._reactiveGraphicLookup.get(e);n&&(n.original=t,this._updatingHandles.consumePromise(this._valueChangeTransaction(e=>this._expressionsManager.runOriginalFeatureDependentExpressions(n,e),`expression`)))}async setFieldInputValue(e,t){let{fieldName:n}=e;await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of e.features)r.setValue(i,n,t)},`user`,e))}async setFieldInputValuePerFeature(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t)n.setValue(r,e.fieldName,i);n.hasChanges&&(e.userHasChangedValue=!0)},`user`,e))}async setValueForFieldName(e,t,n){await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of n){let n=this._reactiveGraphicLookup.get(i);n&&r.setValue(n,e,t)}},`user`,e))}async setValuePerFeatureForFieldName(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t){let t=this._reactiveGraphicLookup.get(r);t&&n.setValue(t,e,i)}},`user`,e))}async setFieldValue(e,t){let n=this.activeForm.allFieldInputs.find(t=>t.fieldName===e);if(n==null)throw new i(`no-field-input-found`,`Cannot set the value of FieldInput with field name: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async setValue(e,t){let n=this.findFieldInput(e);if(n==null)throw new i(`no-FieldInput-found`,`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async applySubtypeDefaults(e){let{defaultValues:t}=e,{allFieldInputs:n}=this.activeForm;await this._updatingHandles.addPromise(this._valueChangeTransaction(async e=>{for(let r of n){let{fieldName:n}=r,i=t[n];if(i!=null)for(let t of r.features)e.setValue(t,n,i)}},`user`))}async handleSubtypeChanged(e){let t=this._workingFeatures.at(e);if(t)return this._updatingHandles.addPromise(this._handleSubtypeChanged(t))}async stageAddAttachments(e,t){if(t.length===0)return[];let n=this._findAttachmentInput(e);if(!n)return[];let r=await this._updatingHandles.addPromise(n.stageAddAttachments(t,this._expressionsManager.arcadeContext));return r.length===0?r:(this.userHasChangedValues=!0,this._emitAttachmentsChange(n),r)}stageDeleteAttachment(e,t){let n=this._findAttachmentInput(e);if(!n)return;let r=this._findAttachment(n,t);r&&(n.stageDeleteAttachment(r),this.userHasChangedValues=!0,this._emitAttachmentsChange(n))}async stageRenameAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return;let i=this._findAttachment(r,t);i&&(r.stageRenameAttachment(i,n.trim()),this.userHasChangedValues=!0,await r.ensureStagedUpdateData(i),this._emitAttachmentsChange(r))}async stageReplaceAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return!1;let i=this._findAttachment(r,t);return!i||!await this._updatingHandles.addPromise(r.stageReplaceAttachment(i,n,this._expressionsManager.arcadeContext))?!1:(this.userHasChangedValues=!0,this._emitAttachmentsChange(r),!0)}clearAttachmentChanges(e){let t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}setActiveAssociation(e){this._activeAssociation=e}setActiveAssociationsInput(e){this._activeAssociationsInput=e}setActiveAssociationsLayer(e){this._activeAssociationsInput?.setAssociatedLayer(e)}setActiveAssociationType(e){this._activeAssociationsInput?.setActiveAssociationType(e)}setActiveRelationshipInput(e){e||this._activeRelationshipInput?.setActiveCategory(null),this._activeRelationshipInput=e}setActiveRelationshipCategory(e,t){t.setActiveCategory(e),this.setActiveRelationshipInput(t)}clearAllRelationshipSettings(){let e=this.activeRelationshipInput;e&&(e.setActiveCategory(null),e.setShowAllCategories(!1),e.setShowAllRelatedRecords(!1),this._activeRelationshipInput=null)}clearActiveRelationshipCategoryOrInput(){let e=this.activeRelationshipInput;e&&(e.showAllRelatedRecords?e.showAllCategories?e.setActiveCategory(null):this.setActiveRelationshipInput(null):e.showAllCategories&&(e.setShowAllCategories(!1),this.setActiveRelationshipInput(null)))}resetAttachmentChanges(e,t){let n=this._findAttachmentInput(e);if(!n||!n.editable)return;let r=this._findAttachment(n,t);r&&(n.discardStagedEdits(r),this._emitAttachmentsChange(n))}setSelectedAttachment(e){this.selectedAttachment=e??null}setShowingSelectedAttachmentReplacePage(e){this.showingSelectedAttachmentReplacePage=e}setSelectedAttachmentAddElementId(e){this.selectedAttachmentAddElementId=e??null}setSelectedAttachmentListElementId(e){this.selectedAttachmentListElementId=e??null}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}validate(){return!1}validateContingentValues(e,t=!1){if(t&&!this.submitHasBeenAttempted)for(let t of e)this._reactiveContingentValuesManager.validateContingenciesForNonNullFields(t);else for(let t of e)this._reactiveContingentValuesManager.validateContingencyConstraints(t,{includeIncompleteViolations:!0})}_makeBatchFormInputsForFeature(e){let t=this._layerTemplateMap.get(e.layer);return t?B(t,{allFeatures:new r([e]),expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}async _ensureLayerTemplate(e,t){let{_layersSet:n,contingentValuesManager:r}=this,i=e.layer,a=!1;for(let e of this._layerTemplateMap.keys())n.has(e)||(this._layerTemplateMap.delete(e),this._expressionsManager.layerExpressionsModelMap.delete(e),r.resetOptionsForLayer(e),Y(e)&&r.resetViolationsForLayer(e),a=!0);this._layerTemplateMap.has(i)||(await this._prepareLayer(i,t),u(t),r.layers.add(i),a=!0),a&&(this._prepareSharedFormTemplate(),V(this.sharedForm,this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),this._recomputeHasAsyncArcadeExpressions(),await v(()=>!r.updating,t))}_recomputeHasAsyncArcadeExpressions(){this._hasAsyncArcadeExpressions=!1;for(let e of this._expressionsManager.layerExpressionsModelMap.values())for(let t of e.arcadeExecutorUses.keys())if(t.isAsync){this._hasAsyncArcadeExpressions=!0;return}}_computeFormHeaderField(e){let{activeFeature:t,activeLayer:n}=this;return!e||!n||!t?null:P({attributes:t?.attributes,label:e,layer:n,timeZone:this.effectiveTimeZone})}_makeSubmitResults(){let e=new Map;for(let[n,r]of this._reactiveGraphicLookup){let i=[],a=[],o=this._featureFormMap.get(r)?.allAttachmentElementInputs??[];for(let e of o)t(i,e.toSubmitEdits()),e.valid||a.push(e.template.elementId);e.set(n,{feature:n,values:{...r.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(let t of this.sharedForm.allFieldInputs)for(let n of t.invalidFeatures)e.get(n)?.invalidFields.push(t.fieldName);return Array.from(e.values())}async _handleSubtypeChanged(e){let t=e.layer;if(this.contingentValuesManager.resetOptionsForFeature(t,e.plainGraphic),Y(t)&&this.contingentValuesManager.resetViolationsForFeature(t,e.plainGraphic),!w(t))return;let r=t.parent?.findSublayerForFeature(e.plainGraphic);if(!r)return;this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask);let i=n(async t=>{u(t),e.source.sourceLayer=r,e.source.origin=r.graphicOrigin,await this._ensureLayerTemplate(e,t),u(t),this._featureFormMap.get(e)?.destroy(),this._featureFormMap.set(e,this._makeBatchFormInputsForFeature(e)),await ee(this._valueChangeTransaction(t=>this._expressionsManager.runAllExpressions([e],t),`user`),t),u(t)});this._layerTemplateUpdateTask=i,await d(this._updatingHandles.addPromise(i.promise))}_emitSubmit(){this.emit(`submit`,{name:`submit`,results:this._makeSubmitResults(),valid:this.valid})}_findAttachmentInput(e){let t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||o.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){let n=e.findAttachment(t);return n||o.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),n}_makeAttachmentEdits(e){let n=[];for(let r of e.allAttachmentElementInputs)t(n,r.toSubmitEdits());return n}_emitAttachmentsChange(e){let t=e.single.feature;if(!t)return;let n=this._featureFormMap.get(t);this.emit(`attachments-change`,{name:`attachments-change`,feature:t.source,attachmentEdits:this._makeAttachmentEdits(n??this.activeForm),valid:this.valid})}async _valueChangeTransaction(e,t,n){let r=typeof n==`string`?n:n?.fieldName,i=new F(this,t,r);if(await e(i),t===`user`&&await this._expressionsManager.runExpressionsDependentOnChangedFields(i),await i.close(),i.hasChanges&&n){let e=typeof n==`string`?this.activeForm.allFieldInputs.find(e=>e.fieldName===n):n;e&&(e.userHasChangedValue=!0)}}_prepare(){this.pendingSubtypeChoice?.reject(),this._hasAsyncArcadeExpressions=!1,this._prepareTask=l(this._prepareTask),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._layerTemplateMap.clear(),this._updateWorkingFeatures(),c(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new L({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??x.WebMercator,map:this.map,timeZone:this.timeZone||`system`}});let{layers:e}=this;if(e.length===0)return;let t=n(async t=>{try{u(t),this._updateWorkingFeatures(),this.contingentValuesManager.layers.addMany(e),await Promise.all(e.map(e=>e.load()));for(let n of e)await this._prepareLayer(n,t);if(this.hasTooManyComplexFeatures)throw new i(`too-many-features-with-complex-forms`,`There are too many features to load into the form with the configured complexity`);if(this.hasTooManyFeatures)throw new i(`too-many-features`,`There are too many features to load into the form.`);this._prepareSharedFormTemplate(),this.sharedForm=B(this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),await this._valueChangeTransaction(async e=>await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray(),e),`expression`),await v(()=>!this.contingentValuesManager.updating)}catch(e){throw f(e)||o.getLogger(this).error(`Failed preparing form`,e),e}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}async _prepareLayer(e,t){let n=ae(this.layerInfos,e),r=await G(e,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone,attachmentsEnabled:this.attachmentsEnabled},n?.formTemplate);u(t),this._layerTemplateMap.set(e,r);let i=r.getExpressionExecutorsForLayer(e);if(this._expressionsManager.layerExpressionsModelMap.set(e,new R({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:i,fieldsIndex:e.fieldsIndex})),!this._hasAsyncArcadeExpressions){for(let e of i.values())if(e&&(this._hasAsyncArcadeExpressions=(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync)===!0,this._hasAsyncArcadeExpressions))break}}_prepareSharedFormTemplate(){let e=new Map;for(let t of this._layerTemplateMap.values())for(let n of t.elements){if(K(n))continue;let t=n.clone();q(t)&&(t.elements=t.elements.filter(e=>!K(e)));let{elementId:r}=t;e.has(r)?e.get(r).foldIn(t):e.set(r,t)}this.sharedFormTemplate=new W({elements:Array.from(e.values())})}_updateWorkingFeatures(){this._workingFeatures.destroyAll(),this._reactiveContingentValuesManager.reset();for(let e of this._featureFormMap.values())e.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();let{features:e}=this;if(this._reactiveGraphicLookup=new p,e.length!==0){this._workingFeatures.addMany(e.map(k));for(let e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){let{activeFeature:e,activeLayer:t,activeForm:r}=this;if(!e||!r||!A(t)||!j(t))return;let i=e.getObjectId();if(i==null)return;let a=this._attachmentCache.get(t),o=r.allAttachmentElementInputs;if(!o.length)return;let c=n(async e=>{let n;if(a){let e=a.get(i);e&&(n=e)}n||(n=await M(t,i,o,e),s(this._attachmentCache,t,()=>new p).set(i,n));for(let e of o)e.applyFetchedAttachments(se(e,n))});this._syncAttachmentsTask=c,await d(c.promise)}get test(){return{expressionsManager:this._expressionsManager,reactiveGraphicLookup:this._reactiveGraphicLookup,syncAttachmentsTask:this._syncAttachmentsTask}}};e([y()],Z.prototype,`_attachmentCache`,void 0),e([y({readOnly:!0})],Z.prototype,`activeFeature`,null),e([y()],Z.prototype,`activeFeatureIndex`,void 0),e([y({readOnly:!0})],Z.prototype,`activeForm`,null),e([y({readOnly:!0})],Z.prototype,`activeLayer`,null),e([y()],Z.prototype,`activeAssociation`,null),e([y()],Z.prototype,`activeAssociationsInput`,null),e([y()],Z.prototype,`activeAssociationType`,null),e([y()],Z.prototype,`activeRelationshipInput`,null),e([y()],Z.prototype,`attachmentsEnabled`,void 0),e([y()],Z.prototype,`callbacks`,void 0),e([y()],Z.prototype,`disabled`,void 0),e([y()],Z.prototype,`calculating`,null),e([y()],Z.prototype,`canGoBack`,null),e([y()],Z.prototype,`contingentValuesManager`,void 0),e([y()],Z.prototype,`editType`,void 0),e([y()],Z.prototype,`features`,void 0),e([y()],Z.prototype,`expressionEvaluationFailed`,null),e([y()],Z.prototype,`hasNonActiveInvalidFeatures`,null),e([y()],Z.prototype,`hasAsyncArcadeExpressions`,null),e([y()],Z.prototype,`_hasAsyncArcadeExpressions`,void 0),e([y()],Z.prototype,`invalidFeatures`,null),e([y()],Z.prototype,`hasVisibleInputs`,null),e([y()],Z.prototype,`hasLayersWithContingentValues`,null),e([y()],Z.prototype,`formDescription`,null),e([y()],Z.prototype,`formTitle`,null),e([y()],Z.prototype,`effectiveTimeZone`,null),e([y()],Z.prototype,`highlightHelper`,void 0),e([y()],Z.prototype,`maximumFeatureCount`,void 0),e([y()],Z.prototype,`maximumFeatureCountWithComplexForms`,void 0),e([y()],Z.prototype,`visibleInputs`,null),e([y()],Z.prototype,`map`,null),e([y()],Z.prototype,`noVisibleElementsReason`,null),e([y()],Z.prototype,`page`,null),e([y()],Z.prototype,`pageStack`,void 0),e([y()],Z.prototype,`readOnly`,void 0),e([y()],Z.prototype,`pendingSubtypeChoice`,void 0),e([y()],Z.prototype,`subtypes`,null),e([y()],Z.prototype,`spatialReference`,void 0),e([y()],Z.prototype,`submitHasBeenAttempted`,void 0),e([y()],Z.prototype,`timeZone`,null),e([y()],Z.prototype,`view`,void 0),e([y()],Z.prototype,`updating`,null),e([y()],Z.prototype,`valid`,null),e([y()],Z.prototype,`layers`,null),e([y()],Z.prototype,`mode`,null),e([y()],Z.prototype,`sharedForm`,void 0),e([y()],Z.prototype,`sharedFormTemplate`,void 0),e([y()],Z.prototype,`selectedAttachment`,null),e([y()],Z.prototype,`selectedAttachmentAddElementId`,null),e([y()],Z.prototype,`selectedAttachmentListElementId`,null),e([y()],Z.prototype,`selectedAttachmentListInput`,null),e([y()],Z.prototype,`showingSelectedAttachmentReplacePage`,null),e([y()],Z.prototype,`selectedAttachmentAddInput`,null),e([y()],Z.prototype,`selectedAttachmentDetails`,null),e([y()],Z.prototype,`userHasChangedValues`,void 0),e([y()],Z.prototype,`layerInfos`,void 0),e([y()],Z.prototype,`_arcadeExecutorProvider`,void 0),e([y()],Z.prototype,`_activeAssociation`,void 0),e([y()],Z.prototype,`_activeAssociationsInput`,void 0),e([y()],Z.prototype,`_activeRelationshipInput`,void 0),e([y()],Z.prototype,`_prepareTask`,void 0),e([y()],Z.prototype,`_reactiveGraphicLookup`,void 0),e([y()],Z.prototype,`_allAttachmentInputs`,null),e([y()],Z.prototype,`_hasPendingAttachmentHydration`,null),e([y()],Z.prototype,`_layerTemplateMap`,void 0),e([y()],Z.prototype,`_layersSet`,null),e([y()],Z.prototype,`_workingFeatures`,void 0),e([y()],Z.prototype,`_expressionsManager`,void 0),Z=e([b(`esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel`)],Z);const oe=Z;function Q(e){return e!=null&&e.trim().length>0}function $(e,t){let n=e.keywords;return Q(n)&&n.toLowerCase()===t}function se(e,t){let n=e.input?.type===`attachment`?e.input.attachmentAssociationType:`exact`,r=e.attachmentKeyword;if(n===`any`)return t;if(n===`exactOrNone`){if(X(r))return t.filter(e=>!Q(e.keywords));let e=r.toLowerCase();return t.filter(t=>!Q(t.keywords)||$(t,e))}if(X(r))return t;let i=r.toLowerCase();return t.filter(e=>$(e,i))}export{oe as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{destroyMaybe as c,abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as u,whenOrAbort as ee,ignoreAbortErrors as d,isAbortError as f}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as te,sync as m,watch as h,syncAndInitial as g,initial as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as y,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as ne}from"../../core/support/UpdatingHandles.js";import x from"../../geometry/SpatialReference.js";import{getGraphicLayer as S}from"../../graphic/graphicOriginUtils.js";import{isSubtypeGroupLayer as C,isSubtypeSublayer as w,isFeatureLayer as re,getSubtypesFromLayer as ie}from"../../layers/support/layerUtils.js";import{system as T}from"../../time/constants.js";import{getAttachmentKey as E}from"./attachmentUtils.js";import{getLayerTimeZone as D,getEffectiveTimeZone as O,createReactiveGraphic as k,isAttributeFormSupportedLayerWithAttachments as A,layerSupportsAttachments as j,queryAttachmentsForElements as M}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as N}from"./ReactiveContingentValuesManager.js";import{parseFormTemplateString as P}from"./stringUtils.js";import{ValueChangeTransaction as F}from"./ValueChangeTransaction.js";import{ArcadeExecutorProvider as I}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as L}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as R}from"./expressions/ExpressionsModel.js";import z from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as B,mergeBatchFormInputsFromNewTemplate as V}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as H,isFieldInput as U}from"./inputs/support/inputUtils.js";import W from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as G}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as K,isGroupElementTemplate as q}from"./templates/support/templateUtils.js";import{ContingentValuesManager as J,isLayerWithContingentValues as Y}from"../support/ContingentValuesManager.js";import{isEmptyValue as X}from"../support/forms/formUtils.js";function ae(e,t){return e?.find(e=>e.layer===t)}let Z=class extends a{constructor(e){super(e),this._attachmentCache=new p,this.activeFeatureIndex=-1,this.attachmentsEnabled=!1,this.callbacks=null,this.disabled=!1,this.editType=`NA`,this.features=new r,this._hasAsyncArcadeExpressions=!1,this.highlightHelper=null,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.pageStack=[],this.readOnly=!1,this.pendingSubtypeChoice=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.view=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new I,this._activeAssociation=null,this._activeAssociationsInput=null,this._activeRelationshipInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new z({inputs:[]}),this._emptyFormTemplate=new W({elements:[]}),this._featureFormMap=new p,this._prepareTask=null,this._layerTemplateUpdateTask=null,this._syncAttachmentsTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new ne,this._submitTask=null,this._layerTemplateMap=new p,this._workingFeatures=new r,this._expressionsManager=new L({arcadeContext:{editType:`NA`,spatialReference:null,map:null,timeZone:T}}),this._getExternalErrorForFeature=(e,t)=>this._reactiveContingentValuesManager.getViolationTypeForField(e,t),this._getFieldValueOptionsForFeature=e=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(e),this._requestDeferredExpressionEvaluation=async({features:e,getExecutor:t})=>this._valueChangeTransaction(n=>this._expressionsManager.requestDeferredExecution(e,t,n),`user`),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||=this._ownContingentValuesManager=new J,this.addHandles([te(()=>this.features,`after-changes`,()=>{this.goHome(),this.notifyChange(`layers`),this._prepare()},m),h(()=>[this.attachmentsEnabled,this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),m),h(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},m),h(()=>this.activeFeature,()=>{this.goHome()},m),h(()=>this.page,e=>{let t=[...this.pageStack];if(!t.includes(e))t.push(e);else for(;t.length&&t.at(-1)!==e;)t.pop();this.pageStack=t},g),h(()=>this.contingentValuesManager,e=>{c(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new N({manager:e})},_)]),this._prepare()}destroy(){this._prepareTask=l(this._prepareTask),this.pendingSubtypeChoice?.reject(),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._syncAttachmentsTask=l(this._syncAttachmentsTask),this._workingFeatures.destroyAll(),c(this._expressionsManager),c(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=c(this._ownContingentValuesManager),this.highlightHelper?.removeAll()}get activeFeature(){let e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if(this.mode===`batch`)return this.sharedForm;let e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;let t=this._featureFormMap.get(e);if(t)return t;let n=this._makeBatchFormInputsForFeature(e);return n!==this._emptyForm&&this._featureFormMap.set(e,n),n}get activeLayer(){let{activeFeature:e}=this;return e?S(e)??null:null}get activeAssociation(){return this._activeAssociation}get activeAssociationsInput(){return this._activeAssociationsInput}get activeAssociationType(){return this.activeAssociationsInput?.activeAssociationType}get activeRelationshipInput(){return this._activeRelationshipInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get canGoBack(){return this.pageStack.length>1}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if(this.mode===`batch`)return!1;let{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){let e=this.contingentValuesManager;for(let t of this.layers)if(e.getFieldsWithContingentValues(t).size>0)return!0;return!1}get formDescription(){return this._computeFormHeaderField(this.activeForm?.description)}get formTitle(){return this._computeFormHeaderField(this.activeForm?.title)}get effectiveTimeZone(){let{activeLayer:e,timeZone:t}=this;if(!e)return t??`system`;let n=D(e);return O(t,n)}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(this.activeForm.inputs.length===0)return`noElements`;let e=new Set;for(let t of this.activeForm.inputs)switch(t.visibilityCode){case`hidden:not-in-all-layers`:case`hidden:no-domain-in-common`:e.add(`noElementsInCommon`);break;case`hidden:field-definition`:case`hidden:group-visibility-expression:all-features`:case`hidden:visibility-expression:all-features`:e.add(`allElementsHidden`);break;case`hidden:group-visibility-expression:some-features`:case`hidden:visibility-expression:some-features`:return`elementsHiddenInSome`}return e.has(`allElementsHidden`)?`allElementsHidden`:`noElementsInCommon`}get page(){return this.showingSelectedAttachmentReplacePage&&this.selectedAttachmentDetails?`replacing-attachment`:this.selectedAttachmentDetails?`viewing-attachment-details`:this.selectedAttachmentAddInput?`adding-attachments`:this.selectedAttachmentListInput?`viewing-attachments`:this.activeAssociationsInput?.associatedLayer?`viewing-associated-features`:this.activeAssociationsInput?`viewing-associated-layers`:this.activeRelationshipInput?.showAllRelatedRecords?`viewing-related-records`:this.activeRelationshipInput?.showAllCategories?`viewing-related-categories`:`default`}get subtypes(){let e=this.activeLayer;return C(e)||w(e)||re(e)?ie(e):[]}get status(){let e=this._prepareTask;return e==null?`not-loaded`:e.finished?e.error==null?`loaded`:`failed`:`loading`}get timeZone(){return this.view?.timeZone??null}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){return Array.from(this._layersSet)}get mode(){return this.activeFeatureIndex>-1?`single`:`batch`}submit(){if(this.submitHasBeenAttempted=!0,this.sharedForm.touchAll(),this._featureFormMap.forEach(e=>e.touchAll()),this.validateContingentValues(this._workingFeatures),!this._hasPendingAttachmentHydration)return this._emitSubmit(),Promise.resolve();if(this._submitTask)return this._submitTask.promise;let e=n(async()=>{await Promise.all(this._allAttachmentInputs.map(e=>e.waitForPendingAttachmentUpdateData())),this._emitSubmit()});return this._submitTask=e,e.promise.finally(()=>{this._submitTask===e&&(this._submitTask=null)}),e.promise}get selectedAttachment(){return this._get(`selectedAttachment`)??null}set selectedAttachment(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachment`,e),e!=null&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get(`selectedAttachmentAddElementId`)??null}set selectedAttachmentAddElementId(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachmentAddElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get(`selectedAttachmentListElementId`)??null}set selectedAttachmentListElementId(e){this._set(`selectedAttachmentListElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){let e=this.selectedAttachmentListElementId,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null;return n?.attachments.length?n:null}get showingSelectedAttachmentReplacePage(){return this._get(`showingSelectedAttachmentReplacePage`)??!1}set showingSelectedAttachmentReplacePage(e){this._set(`showingSelectedAttachmentReplacePage`,e&&this.selectedAttachmentDetails!=null)}get selectedAttachmentAddInput(){let e=this.selectedAttachmentAddElementId,t=this.activeForm;return!e||!t?null:t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null}get selectedAttachmentDetails(){let e=this.selectedAttachment,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e.elementId);if(!n)return null;let r=n.attachments.findIndex(t=>E(t)===e.attachmentKey);return r===-1?null:{attachment:n.attachments[r],input:n}}get _allAttachmentInputs(){let e=[...this.sharedForm.allAttachmentElementInputs];for(let t of this._featureFormMap.values())e.push(...t.allAttachmentElementInputs);return e}get _hasPendingAttachmentHydration(){return this._allAttachmentInputs.some(e=>e.hasPendingAttachmentUpdateData)}get _layersSet(){let e=new Set;for(let t of this._workingFeatures){let n=S(t.plainGraphic);n&&e.add(n)}return e}applyStashedAttachmentEdits(e){let t=this._allAttachmentInputs;for(let n of e){let e=t.find(e=>e.label===n.label&&e.attachmentKeyword===n.keywords);e&&e.applyStashedEdits(n)}}findFieldInput(e){if(e==null)return;let t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);let n=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);if(n!==void 0)return t.set(e,n),n}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(let e of this.visibleInputs){if(H(e)){let t=e.inputs.find(e=>U(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(U(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){let t=this._reactiveGraphicLookup.get(e);if(!t)throw new i(`feature-not-found`,`The given feature is not present in the BatchAttributeForm`);return{...t.attributes}}async goBack(){switch(this.page){case`replacing-attachment`:this.setShowingSelectedAttachmentReplacePage(!1);return;case`viewing-attachment-details`:this.setSelectedAttachment(null);return;case`adding-attachments`:this.setSelectedAttachmentAddElementId(null);return;case`viewing-attachments`:this.setSelectedAttachmentListElementId(null);return;case`viewing-associated-features`:this.setActiveAssociationsLayer(null);return;case`viewing-associated-layers`:this.setActiveAssociationsInput(null);return;case`viewing-related-categories`:case`viewing-related-records`:this.clearActiveRelationshipCategoryOrInput();return;default:return}}async goHome(){this.setShowingSelectedAttachmentReplacePage(!1),this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),this.setActiveAssociationsInput(null),this.clearAllRelationshipSettings()}notifyGeometriesChanged(e){let t=[];for(let n of e){let e=this._reactiveGraphicLookup.get(n);e&&(t.push(e),e.geometry=n.geometry)}this._updatingHandles.consumePromise(this._valueChangeTransaction(async e=>this._expressionsManager.runGeometryDependentExpressions(t,e),`user`))}async overrideOriginalFeature(e,t){await this._prepareTask?.promise;let n=this._reactiveGraphicLookup.get(e);n&&(n.original=t,this._updatingHandles.consumePromise(this._valueChangeTransaction(e=>this._expressionsManager.runOriginalFeatureDependentExpressions(n,e),`expression`)))}async setFieldInputValue(e,t){let{fieldName:n}=e;await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of e.features)r.setValue(i,n,t)},`user`,e))}async setFieldInputValuePerFeature(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t)n.setValue(r,e.fieldName,i);n.hasChanges&&(e.userHasChangedValue=!0)},`user`,e))}async setValueForFieldName(e,t,n){await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of n){let n=this._reactiveGraphicLookup.get(i);n&&r.setValue(n,e,t)}},`user`,e))}async setValuePerFeatureForFieldName(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t){let t=this._reactiveGraphicLookup.get(r);t&&n.setValue(t,e,i)}},`user`,e))}async setFieldValue(e,t){let n=this.activeForm.allFieldInputs.find(t=>t.fieldName===e);if(n==null)throw new i(`no-field-input-found`,`Cannot set the value of FieldInput with field name: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async setValue(e,t){let n=this.findFieldInput(e);if(n==null)throw new i(`no-FieldInput-found`,`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async applySubtypeDefaults(e){let{defaultValues:t}=e,{allFieldInputs:n}=this.activeForm;await this._updatingHandles.addPromise(this._valueChangeTransaction(async e=>{for(let r of n){let{fieldName:n}=r,i=t[n];if(i!=null)for(let t of r.features)e.setValue(t,n,i)}},`user`))}async handleSubtypeChanged(e){let t=this._workingFeatures.at(e);if(t)return this._updatingHandles.addPromise(this._handleSubtypeChanged(t))}async stageAddAttachments(e,t){if(t.length===0)return[];let n=this._findAttachmentInput(e);if(!n)return[];let r=await this._updatingHandles.addPromise(n.stageAddAttachments(t,this._expressionsManager.arcadeContext));return r.length===0?r:(this.userHasChangedValues=!0,this._emitAttachmentsChange(n),r)}stageDeleteAttachment(e,t){let n=this._findAttachmentInput(e);if(!n)return;let r=this._findAttachment(n,t);r&&(n.stageDeleteAttachment(r),this.userHasChangedValues=!0,this._emitAttachmentsChange(n))}async stageRenameAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return;let i=this._findAttachment(r,t);i&&(r.stageRenameAttachment(i,n.trim()),this.userHasChangedValues=!0,await r.ensureStagedUpdateData(i),this._emitAttachmentsChange(r))}async stageReplaceAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return!1;let i=this._findAttachment(r,t);return!i||!await this._updatingHandles.addPromise(r.stageReplaceAttachment(i,n,this._expressionsManager.arcadeContext))?!1:(this.userHasChangedValues=!0,this._emitAttachmentsChange(r),!0)}clearAttachmentChanges(e){let t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}setActiveAssociation(e){this._activeAssociation=e}setActiveAssociationsInput(e){this._activeAssociationsInput=e}setActiveAssociationsLayer(e){this._activeAssociationsInput?.setAssociatedLayer(e)}setActiveAssociationType(e){this._activeAssociationsInput?.setActiveAssociationType(e)}setActiveRelationshipInput(e){e||this._activeRelationshipInput?.setActiveCategory(null),this._activeRelationshipInput=e}setActiveRelationshipCategory(e,t){t.setActiveCategory(e),this.setActiveRelationshipInput(t)}clearAllRelationshipSettings(){let e=this.activeRelationshipInput;e&&(e.setActiveCategory(null),e.setShowAllCategories(!1),e.setShowAllRelatedRecords(!1),this._activeRelationshipInput=null)}clearActiveRelationshipCategoryOrInput(){let e=this.activeRelationshipInput;e&&(e.showAllRelatedRecords?e.showAllCategories?e.setActiveCategory(null):this.setActiveRelationshipInput(null):e.showAllCategories&&(e.setShowAllCategories(!1),this.setActiveRelationshipInput(null)))}resetAttachmentChanges(e,t){let n=this._findAttachmentInput(e);if(!n||!n.editable)return;let r=this._findAttachment(n,t);r&&(n.discardStagedEdits(r),this._emitAttachmentsChange(n))}setSelectedAttachment(e){this.selectedAttachment=e??null}setShowingSelectedAttachmentReplacePage(e){this.showingSelectedAttachmentReplacePage=e}setSelectedAttachmentAddElementId(e){this.selectedAttachmentAddElementId=e??null}setSelectedAttachmentListElementId(e){this.selectedAttachmentListElementId=e??null}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}validate(){return!1}validateContingentValues(e,t=!1){if(t&&!this.submitHasBeenAttempted)for(let t of e)this._reactiveContingentValuesManager.validateContingenciesForNonNullFields(t);else for(let t of e)this._reactiveContingentValuesManager.validateContingencyConstraints(t,{includeIncompleteViolations:!0})}_makeBatchFormInputsForFeature(e){let t=this._layerTemplateMap.get(e.layer);return t?B(t,{allFeatures:new r([e]),expressionsManager:this._expressionsManager,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}async _ensureLayerTemplate(e,t){let{_layersSet:n,contingentValuesManager:r}=this,i=e.layer,a=!1;for(let e of this._layerTemplateMap.keys())n.has(e)||(this._layerTemplateMap.delete(e),this._expressionsManager.layerExpressionsModelMap.delete(e),r.resetOptionsForLayer(e),Y(e)&&r.resetViolationsForLayer(e),a=!0);this._layerTemplateMap.has(i)||(await this._prepareLayer(i,t),u(t),r.layers.add(i),a=!0),a&&(this._prepareSharedFormTemplate(),V(this.sharedForm,this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,map:this.map}),this._recomputeHasAsyncArcadeExpressions(),await v(()=>!r.updating,t))}_recomputeHasAsyncArcadeExpressions(){this._hasAsyncArcadeExpressions=!1;for(let e of this._expressionsManager.layerExpressionsModelMap.values())for(let t of e.arcadeExecutorUses.keys())if(t.isAsync){this._hasAsyncArcadeExpressions=!0;return}}_computeFormHeaderField(e){let{activeFeature:t,activeLayer:n}=this;return!e||!n||!t?null:P({attributes:t?.attributes,label:e,layer:n,timeZone:this.effectiveTimeZone})}_makeSubmitResults(){let e=new Map;for(let[n,r]of this._reactiveGraphicLookup){let i=[],a=[],o=this._featureFormMap.get(r)?.allAttachmentElementInputs??[];for(let e of o)t(i,e.toSubmitEdits()),e.valid||a.push(e.template.elementId);e.set(n,{feature:n,values:{...r.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(let t of this.sharedForm.allFieldInputs)for(let n of t.invalidFeatures)e.get(n)?.invalidFields.push(t.fieldName);return Array.from(e.values())}async _handleSubtypeChanged(e){let t=e.layer;if(this.contingentValuesManager.resetOptionsForFeature(t,e.plainGraphic),Y(t)&&this.contingentValuesManager.resetViolationsForFeature(t,e.plainGraphic),!w(t))return;let r=t.parent?.findSublayerForFeature(e.plainGraphic);if(!r)return;this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask);let i=n(async t=>{u(t),e.source.sourceLayer=r,e.source.origin=r.graphicOrigin,await this._ensureLayerTemplate(e,t),u(t),this._featureFormMap.get(e)?.destroy(),this._featureFormMap.set(e,this._makeBatchFormInputsForFeature(e)),await ee(this._valueChangeTransaction(t=>this._expressionsManager.runAllExpressions([e],t),`user`),t),u(t)});this._layerTemplateUpdateTask=i,await d(this._updatingHandles.addPromise(i.promise))}_emitSubmit(){this.emit(`submit`,{name:`submit`,results:this._makeSubmitResults(),valid:this.valid})}_findAttachmentInput(e){let t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||o.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){let n=e.findAttachment(t);return n||o.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),n}_makeAttachmentEdits(e){let n=[];for(let r of e.allAttachmentElementInputs)t(n,r.toSubmitEdits());return n}_emitAttachmentsChange(e){let t=e.single.feature;if(!t)return;let n=this._featureFormMap.get(t);this.emit(`attachments-change`,{name:`attachments-change`,feature:t.source,attachmentEdits:this._makeAttachmentEdits(n??this.activeForm),valid:this.valid})}async _valueChangeTransaction(e,t,n){let r=typeof n==`string`?n:n?.fieldName,i=new F(this,t,r);if(await e(i),t===`user`&&await this._expressionsManager.runExpressionsDependentOnChangedFields(i),await i.close(),i.hasChanges&&n){let e=typeof n==`string`?this.activeForm.allFieldInputs.find(e=>e.fieldName===n):n;e&&(e.userHasChangedValue=!0)}}_prepare(){this.pendingSubtypeChoice?.reject(),this._hasAsyncArcadeExpressions=!1,this._prepareTask=l(this._prepareTask),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._layerTemplateMap.clear(),this._updateWorkingFeatures(),c(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new L({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??x.WebMercator,map:this.map,timeZone:this.timeZone||`system`}});let{layers:e}=this;if(e.length===0)return;let t=n(async t=>{try{u(t),this._updateWorkingFeatures(),this.contingentValuesManager.layers.addMany(e),await Promise.all(e.map(e=>e.load()));for(let n of e)await this._prepareLayer(n,t);if(this.hasTooManyComplexFeatures)throw new i(`too-many-features-with-complex-forms`,`There are too many features to load into the form with the configured complexity`);if(this.hasTooManyFeatures)throw new i(`too-many-features`,`There are too many features to load into the form.`);this._prepareSharedFormTemplate(),this.sharedForm=B(this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation}),await this._valueChangeTransaction(async e=>await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray(),e),`expression`),await v(()=>!this.contingentValuesManager.updating)}catch(e){throw f(e)||o.getLogger(this).error(`Failed preparing form`,e),e}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}async _prepareLayer(e,t){let n=ae(this.layerInfos,e),r=await G(e,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone,attachmentsEnabled:this.attachmentsEnabled},n?.formTemplate);u(t),this._layerTemplateMap.set(e,r);let i=r.getExpressionExecutorsForLayer(e);if(this._expressionsManager.layerExpressionsModelMap.set(e,new R({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:i,fieldsIndex:e.fieldsIndex})),!this._hasAsyncArcadeExpressions){for(let e of i.values())if(e&&(this._hasAsyncArcadeExpressions=(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync)===!0,this._hasAsyncArcadeExpressions))break}}_prepareSharedFormTemplate(){let e=new Map;for(let t of this._layerTemplateMap.values())for(let n of t.elements){if(K(n))continue;let t=n.clone();q(t)&&(t.elements=t.elements.filter(e=>!K(e)));let{elementId:r}=t;e.has(r)?e.get(r).foldIn(t):e.set(r,t)}this.sharedFormTemplate=new W({elements:Array.from(e.values())})}_updateWorkingFeatures(){this._workingFeatures.destroyAll(),this._reactiveContingentValuesManager.reset();for(let e of this._featureFormMap.values())e.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();let{features:e}=this;if(this._reactiveGraphicLookup=new p,e.length!==0){this._workingFeatures.addMany(e.map(k));for(let e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){let{activeFeature:e,activeLayer:t,activeForm:r}=this;if(!e||!r||!A(t)||!j(t))return;let i=e.getObjectId();if(i==null)return;let a=this._attachmentCache.get(t),o=r.allAttachmentElementInputs;if(!o.length)return;let c=n(async e=>{let n;if(a){let e=a.get(i);e&&(n=e)}n||(n=await M(t,i,o,e),s(this._attachmentCache,t,()=>new p).set(i,n));for(let e of o)e.applyFetchedAttachments(se(e,n))});this._syncAttachmentsTask=c,await d(c.promise)}get test(){return{expressionsManager:this._expressionsManager,reactiveGraphicLookup:this._reactiveGraphicLookup,syncAttachmentsTask:this._syncAttachmentsTask,arcadeExecutorProvider:this._arcadeExecutorProvider,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation}}};e([y()],Z.prototype,`_attachmentCache`,void 0),e([y({readOnly:!0})],Z.prototype,`activeFeature`,null),e([y()],Z.prototype,`activeFeatureIndex`,void 0),e([y({readOnly:!0})],Z.prototype,`activeForm`,null),e([y({readOnly:!0})],Z.prototype,`activeLayer`,null),e([y()],Z.prototype,`activeAssociation`,null),e([y()],Z.prototype,`activeAssociationsInput`,null),e([y()],Z.prototype,`activeAssociationType`,null),e([y()],Z.prototype,`activeRelationshipInput`,null),e([y()],Z.prototype,`attachmentsEnabled`,void 0),e([y()],Z.prototype,`callbacks`,void 0),e([y()],Z.prototype,`disabled`,void 0),e([y()],Z.prototype,`calculating`,null),e([y()],Z.prototype,`canGoBack`,null),e([y()],Z.prototype,`contingentValuesManager`,void 0),e([y()],Z.prototype,`editType`,void 0),e([y()],Z.prototype,`features`,void 0),e([y()],Z.prototype,`expressionEvaluationFailed`,null),e([y()],Z.prototype,`hasNonActiveInvalidFeatures`,null),e([y()],Z.prototype,`hasAsyncArcadeExpressions`,null),e([y()],Z.prototype,`_hasAsyncArcadeExpressions`,void 0),e([y()],Z.prototype,`invalidFeatures`,null),e([y()],Z.prototype,`hasVisibleInputs`,null),e([y()],Z.prototype,`hasLayersWithContingentValues`,null),e([y()],Z.prototype,`formDescription`,null),e([y()],Z.prototype,`formTitle`,null),e([y()],Z.prototype,`effectiveTimeZone`,null),e([y()],Z.prototype,`highlightHelper`,void 0),e([y()],Z.prototype,`maximumFeatureCount`,void 0),e([y()],Z.prototype,`maximumFeatureCountWithComplexForms`,void 0),e([y()],Z.prototype,`visibleInputs`,null),e([y()],Z.prototype,`map`,null),e([y()],Z.prototype,`noVisibleElementsReason`,null),e([y()],Z.prototype,`page`,null),e([y()],Z.prototype,`pageStack`,void 0),e([y()],Z.prototype,`readOnly`,void 0),e([y()],Z.prototype,`pendingSubtypeChoice`,void 0),e([y()],Z.prototype,`subtypes`,null),e([y()],Z.prototype,`spatialReference`,void 0),e([y()],Z.prototype,`submitHasBeenAttempted`,void 0),e([y()],Z.prototype,`timeZone`,null),e([y()],Z.prototype,`view`,void 0),e([y()],Z.prototype,`updating`,null),e([y()],Z.prototype,`valid`,null),e([y()],Z.prototype,`layers`,null),e([y()],Z.prototype,`mode`,null),e([y()],Z.prototype,`sharedForm`,void 0),e([y()],Z.prototype,`sharedFormTemplate`,void 0),e([y()],Z.prototype,`selectedAttachment`,null),e([y()],Z.prototype,`selectedAttachmentAddElementId`,null),e([y()],Z.prototype,`selectedAttachmentListElementId`,null),e([y()],Z.prototype,`selectedAttachmentListInput`,null),e([y()],Z.prototype,`showingSelectedAttachmentReplacePage`,null),e([y()],Z.prototype,`selectedAttachmentAddInput`,null),e([y()],Z.prototype,`selectedAttachmentDetails`,null),e([y()],Z.prototype,`userHasChangedValues`,void 0),e([y()],Z.prototype,`layerInfos`,void 0),e([y()],Z.prototype,`_arcadeExecutorProvider`,void 0),e([y()],Z.prototype,`_activeAssociation`,void 0),e([y()],Z.prototype,`_activeAssociationsInput`,void 0),e([y()],Z.prototype,`_activeRelationshipInput`,void 0),e([y()],Z.prototype,`_prepareTask`,void 0),e([y()],Z.prototype,`_reactiveGraphicLookup`,void 0),e([y()],Z.prototype,`_allAttachmentInputs`,null),e([y()],Z.prototype,`_hasPendingAttachmentHydration`,null),e([y()],Z.prototype,`_layerTemplateMap`,void 0),e([y()],Z.prototype,`_layersSet`,null),e([y()],Z.prototype,`_workingFeatures`,void 0),e([y()],Z.prototype,`_expressionsManager`,void 0),Z=e([b(`esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel`)],Z);const oe=Z;function Q(e){return e!=null&&e.trim().length>0}function $(e,t){let n=e.keywords;return Q(n)&&n.toLowerCase()===t}function se(e,t){let n=e.input?.type===`attachment`?e.input.attachmentAssociationType:`exact`,r=e.attachmentKeyword;if(n===`any`)return t;if(n===`exactOrNone`){if(X(r))return t.filter(e=>!Q(e.keywords));let e=r.toLowerCase();return t.filter(t=>!Q(t.keywords)||$(t,e))}if(X(r))return t;let i=r.toLowerCase();return t.filter(e=>$(e,i))}export{oe as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Error.js";import r from"../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../core/MapUtils.js";import{whenOrAbort as a,settleWithPromise as o}from"../../../core/promiseUtils.js";import s from"../../../core/ReactiveMap.js";import{addMany as c,first as l}from"../../../core/SetUtils.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import{makeArcadeContext as f,castArcadeValue as p}from"./expressionUtils.js";import{makeUseId as
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Error.js";import r from"../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../core/MapUtils.js";import{whenOrAbort as a,settleWithPromise as o}from"../../../core/promiseUtils.js";import s from"../../../core/ReactiveMap.js";import{addMany as c,first as l}from"../../../core/SetUtils.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import{makeArcadeContext as f,castArcadeValue as p,isDeferredExpressionType as m}from"./expressionUtils.js";import{makeUseId as h}from"../inputs/support/inputUtils.js";import{isFieldElementTemplate as g,isGroupElementTemplate as _}from"../templates/support/templateUtils.js";let v=null;const y=()=>r.getLogger(`esri.widgets.BatchAttributeForm.expressions.ExpressionsManager`);let b=class extends t{constructor(e){super(e),this.calculating=!1,this.arcadeContext=null,this._abortController=new AbortController,this.layerExpressionsModelMap=new Map,this.outcomes=new s,this.expressionEvaluationFailed=!1}destroy(){this.abort()}abort(){this._abortController.abort()}async runAllExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature(e,S,t)}async requestDeferredExecution(e,t,n){return this._evaluateSpecifiedExecutorsForEachFeature(e,(e,n)=>{let r=t(n);return r?[r]:[]},n,!0)}async runGeometryDependentExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature(e,C,t)}async runOriginalFeatureDependentExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature([e],w,t)}async runExpressionsDependentOnChangedFields(e){try{this.calculating=!0;let t=Array.from(e.changes).map(([t,n])=>this.runExpressionsDependentOnChangedFieldsForFeature([...n.keys()],t,e));O(await Promise.allSettled(t))}catch(e){y().error(e),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}async runExpressionsDependentOnChangedFieldsForFeature(e,t,n){if(this._abortController.signal.aborted)return;let r=this.layerExpressionsModelMap.get(t.layer);if(!r||r.components.length===0)return;let i=E(r,e);i.length!==0&&await this.evaluateAffectedExecutors([...i],t,r,n)}async evaluateAffectedExecutors(e,t,n,r,o=!1){let c=new Map,l=i(this.outcomes,t,()=>new s);for(let r of e){if(!o){let e=P(r,l,n);e&&(e.invalidated=!0)}let e=n.dependencyGraphComponents.get(r);e&&i(c,e,()=>this.createSccEvaluator({scc:e,feature:t,evaluatorMap:c,expressionModel:n}))}let u=[...c.values()],d={transaction:r,previousOutcomes:new s,isDeferred:o},f=u.map(e=>e.evaluate(d));O(await a(Promise.allSettled(f),this._abortController))}createSccEvaluator({scc:e,feature:t,evaluatorMap:n,expressionModel:r}){let a=i(this.outcomes,t,()=>new s),o=new x(e,t,this.arcadeContext,r,a,this._abortController);for(let a of e.adjacencyList)i(n,a,()=>this.createSccEvaluator({scc:a,feature:t,evaluatorMap:n,expressionModel:r})).dependencies.push(o);return o}async _evaluateSpecifiedExecutorsForEachFeature(e,t,n,r=!1){r||(this.calculating=!0);try{let i=[];for(let a of e){let{layer:e}=a,o=this.layerExpressionsModelMap.get(e);o&&o.components.length!==0&&i.push(this.evaluateAffectedExecutors(t(o,e),a,o,n,r))}O(await a(Promise.allSettled(i),this._abortController))}catch(e){y().error(e),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}};e([u()],b.prototype,`calculating`,void 0),e([u({constructOnly:!0})],b.prototype,`arcadeContext`,void 0),e([u()],b.prototype,`_abortController`,void 0),e([u()],b.prototype,`layerExpressionsModelMap`,void 0),e([u()],b.prototype,`outcomes`,void 0),e([u()],b.prototype,`expressionEvaluationFailed`,void 0),b=e([d(`esri.widgets.BatchAttributeForm.expressions.ExpressionsManager`)],b);class x{constructor(e,t,n,r,i,a){this.scc=e,this.feature=t,this.arcadeContextInfo=n,this.expressionsModel=r,this.outcomes=i,this._abortController=a,this._resolver=null,this.dependencies=[]}get baseContext(){return f(this.arcadeContextInfo,this.feature,this._abortController.signal)}evaluate(e){return this._resolver||(this._resolver=Promise.withResolvers(),o(this._resolver,this._evaluate(e))),this._resolver.promise}async _evaluate(e){v===null&&(v=await import(`../../../arcade/languageUtils.js`));let t=[],n=this.dependencies.map(t=>t.evaluate(e));O(await a(Promise.allSettled(n),this._abortController));let{executors:r}=this.scc;if(r.size===1?await this._evaluateSingleExecutorComponent({context:e,executor:l(r),errorsToReport:t}):await this._evaluateMultiExecutorComponent({context:e,errorsToReport:t}),t.length>0)throw D(t)}async _evaluateMultiExecutorComponent({context:e,errorsToReport:t}){let{transaction:n}=e,r=new Map,i=!0,a=0;for(;i&&a<3;){i=!1,a++;for(let a of this.scc.executors){let o=this._findOutcome(a)??{status:`not-run`,invalidated:!0};o.invalidated||=this._invalidatedSinceCheckpoint(a,n,r.get(a)),this._shouldEvaluate(a,o,e)&&(i=!0,r.set(a,n.currentCheckpoint),await this._performEvaluation({context:e,executor:a,errorsToReport:t}))}}}async _evaluateSingleExecutorComponent({context:e,executor:t,errorsToReport:n}){let r=this._findOutcome(t)??{status:`not-run`,invalidated:!0};r.invalidated||=this._invalidatedSinceCheckpoint(t,e.transaction),this._shouldEvaluate(t,r,e)&&await this._performEvaluation({context:e,executor:t,errorsToReport:n})}async _performEvaluation({context:e,executor:t,errorsToReport:r}){let{variables:i,executeContext:a}=this.baseContext,o=null,s=null;try{o=t.isAsync?await t.executeAsync(i,a):t.execute(i,a),s={result:o,status:`success`}}catch(e){s={error:e,status:`error`}}let{transaction:c,previousOutcomes:l}=e,{outcomes:u}=this,d=this.expressionsModel.arcadeExecutorUses.get(t)??[];for(let t of d){let n=h(t),r=u.get(n);r&&l.set(n,r),u.set(h(t),s);let i=this.expressionsModel.elementTemplateMap.get(t.elementId);switch(t.executorPurpose){case`editableExpression`:if(s.result===!1&&r?.result!==!1){let e=u.get(h({elementId:i.elementId,executorPurpose:`valueExpression`}));if(e){let{fieldName:t}=i,n=T(this.feature,t),r=p(e.result,n,this.arcadeContextInfo.timeZone,v);c.setValue(this.feature,t,r)}}break;case`valueExpression`:{if(s?.status===`error`)continue;let e=i.getExpressionExecutorsForLayer(this.feature.layer),t=!0;if(e?.editableExpression&&(t=u.get(h({elementId:i.elementId,executorPurpose:`editableExpression`}))?.result===!1),t){let e=i.fieldName,t=this.feature.getAttribute(e)??null;try{let n=T(this.feature,e),r=p(s.result,n,this.arcadeContextInfo.timeZone,v);r!==t&&c.setValue(this.feature,e,r)}catch(t){y().error(`Failed to set calculated value for field '${e}'`,t)}}}break;case`visibilityExpression`:!this.expressionsModel.preserveFieldValuesWhenHidden&&r?.result===!0&&s.result===!1&&c.originActor===`user`&&k(i,this.feature,u,e)}}if(s?.status===`error`){let e=new Set;for(let t of d){let n=this.expressionsModel.elementTemplateMap.get(t.elementId);if(n)switch(t.executorPurpose){case`editableExpression`:e.add(n.label+` - Editable expression`);break;case`requiredExpression`:e.add(n.label+` - Required expression`);break;case`valueExpression`:e.add(n.label+` - Value expression`);break;case`visibilityExpression`:e.add(n.label+` - Visibility expression`)}}r.push(e.size>0?new n(`expression-evaluation-failed`,`Arcade evaluation failed (`+[...e].join(`,`)+`)`):new n(`expression-evaluation-failed`,`Arcade evaluation failed `))}}_invalidatedSinceCheckpoint(e,t,n=-1){let r=t.changesForFeature(this.feature);return!r||r.size===0?!1:this.scc.getFieldsReferenced(e).values().some(e=>r.has(e)&&r.get(e)>n)}_shouldEvaluate(e,t,{isDeferred:n}){return this._abortController.signal.aborted||F(this.expressionsModel.arcadeExecutorUses.get(e))&&!n?!1:!!t.invalidated}_findOutcome(e){return P(e,this.outcomes,this.expressionsModel)}}function S(e){return Array.from(e.dependencyGraphComponents.keys())}function C(e){return Array.from(e.geometryReferences)}function w(e){return Array.from(e.originalFeatureReferences)}function T(e,t){let r=e.layer.fieldsIndex.get(t);if(!r)throw new n(`field-not-found`,`Field '${t}' not found on layer.`);return r}function E(e,t){let n=new Set;for(let r of t)c(n,e.fieldReferencesMap.get(r));return Array.from(n)}function D(e){return AggregateError(e,`One or more expression executions failed. First error message: ${e[0].message}`)}function O(e){let t=[],n=new Set;for(let r of e){if(r.status===`fulfilled`)continue;let e=r.reason instanceof AggregateError?r.reason.errors:[r.reason];for(let r of e)n.has(r)||(n.add(r),t.push(r))}if(t.length>0)throw D(t)}function k(e,t,n,r){g(e)?A(e,t,n,r):_(e)&&j(e,t,n,r)}function A(e,t,n,r){let{group:i}=e;(!i||N(i,n,r.previousOutcomes))&&M(t,e,r)}function j(e,t,n,r){for(let i of e.elements)g(i)&&N(i,n,r.previousOutcomes)&&M(t,i,r)}function M(e,{fieldName:t},n){n.transaction.setValue(e,t,null)}function N(e,t,n){let r=h({elementId:e.elementId,executorPurpose:`visibilityExpression`}),i=n.get(r)??t.get(r);return!i||!!i.result}function P(e,t,n){let r=n.arcadeExecutorUses.get(e);if(r)for(let e of r){let n=t.get(h(e));if(n)return n}}function F(e){return e?.every(e=>m(e.executorPurpose))??!1}export{b as ExpressionsManager};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../../core/Error.js";import{DateOnly as t}from"../../../core/sql/DateOnly.js";import{TimeOnly as n}from"../../../core/sql/TimeOnly.js";import{isDynamicChoiceInput as r}from"../../../form/elements/inputs/inputUtils.js";import{isFieldElement as i}from"../../../form/support/formUtils.js";async function a({element:e,expressionInfos:t,provider:n}){let a={};if(e.visibilityExpression){let r=t.get(e.visibilityExpression);a.visibilityExpression=r?await n.getArcadeExecutor(r.expression):void 0}if(`editableExpression`in e&&e.editableExpression){let r=t.get(e.editableExpression);a.editableExpression=r?await n.getArcadeExecutor(r.expression):void 0}if(`requiredExpression`in e&&e.requiredExpression){let r=t.get(e.requiredExpression);a.requiredExpression=r?await n.getArcadeExecutor(r.expression):void 0}if(`valueExpression`in e&&e.valueExpression){let r=t.get(e.valueExpression);a.valueExpression=r?await n.getArcadeExecutor(r.expression):void 0}let o=i(e)?e.input:void 0;if(o&&r(o)&&o.choiceExpression){let e=t.get(o.choiceExpression);a.choiceExpression=e?await n.getArcadeExecutor(e.expression):void 0}return a}function o(e){return new Map(e?.map(e=>[e.name,e]))}function s(r,i,a,o){if(r===null)return null;switch(i.type){case`big-integer`:case`integer`:case`long`:case`oid`:case`small-integer`:{let e=c(r,o);return e==null?null:Math.floor(e)}case`single`:case`double`:return c(r,o);case`global-id`:case`guid`:case`string`:return o.toString(r);case`date`:{let t=l(r,a,o);if(t)return t.getTime();let n=c(r,o);if(n!==null&&!Number.isNaN(n)&&Number.isInteger(n))return n;throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a date`)}case`date-only`:{if(o.isDateOnly(r))return r.toStorageFormat();let n=l(r,a,o);if(!n)throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a date-only string`);return t.fromDateTime(n.toDateTime()).toStorageFormat()}case`time-only`:{if(o.isTime(r))return r.toStorageString();if(o.isDate(r))return n.fromDateTime(r.toDateTime()).toStorageString();let t=n.fromString(o.toString(r));if(!t)throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a time-only string`);return t.toStorageString()}case`timestamp-offset`:{let t=l(r,a,o);if(!t)throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a timestamp-offset string`);return t.toISOString(!1)}}throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a value matching field type`)}function c(e,t){if(e===``)return null;let n=t.toNumber(e);return Number.isNaN(n)?null:n}function l(e,t,n){if(n.isDate(e))return e;if(n.isDateOnly(e))return e.toArcadeDate();let r=n.toString(e),i=n.toDate(r,t);return!i||!/\d{4}-\d{2}-\d{2}/.test(r)?null:i}function u(e,t,n){let{editType:r,map:i,spatialReference:a,timeZone:o}=e,s=t.layer,c=s?.type===`scene`&&s.associatedLayer!=null?s.associatedLayer:s;return{variables:{$originalfeature:t.original,$editcontext:{editType:r},$layer:c,$featureset:c,$datastore:c?.url,$feature:t.plainGraphic,$map:i},executeContext:{rawOutput:!0,spatialReference:a??void 0,timeZone:o,abortSignal:n}}}export{s as castArcadeValue,u as makeArcadeContext,a as makeExecutorSetForFormElement,o as makeExpressionInfosMap};
|
|
2
|
+
import e from"../../../core/Error.js";import{DateOnly as t}from"../../../core/sql/DateOnly.js";import{TimeOnly as n}from"../../../core/sql/TimeOnly.js";import{isDynamicChoiceInput as r}from"../../../form/elements/inputs/inputUtils.js";import{isFieldElement as i}from"../../../form/support/formUtils.js";async function a({element:e,expressionInfos:t,provider:n}){let a={};if(e.visibilityExpression){let r=t.get(e.visibilityExpression);a.visibilityExpression=r?await n.getArcadeExecutor(r.expression):void 0}if(`editableExpression`in e&&e.editableExpression){let r=t.get(e.editableExpression);a.editableExpression=r?await n.getArcadeExecutor(r.expression):void 0}if(`requiredExpression`in e&&e.requiredExpression){let r=t.get(e.requiredExpression);a.requiredExpression=r?await n.getArcadeExecutor(r.expression):void 0}if(`valueExpression`in e&&e.valueExpression){let r=t.get(e.valueExpression);a.valueExpression=r?await n.getArcadeExecutor(r.expression):void 0}let o=i(e)?e.input:void 0;if(o&&r(o)&&o.choiceExpression){let e=t.get(o.choiceExpression);a.choiceExpression=e?await n.getArcadeExecutor(e.expression):void 0}return a}function o(e){return new Map(e?.map(e=>[e.name,e]))}function s(r,i,a,o){if(r===null)return null;switch(i.type){case`big-integer`:case`integer`:case`long`:case`oid`:case`small-integer`:{let e=c(r,o);return e==null?null:Math.floor(e)}case`single`:case`double`:return c(r,o);case`global-id`:case`guid`:case`string`:return o.toString(r);case`date`:{let t=l(r,a,o);if(t)return t.getTime();let n=c(r,o);if(n!==null&&!Number.isNaN(n)&&Number.isInteger(n))return n;throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a date`)}case`date-only`:{if(o.isDateOnly(r))return r.toStorageFormat();let n=l(r,a,o);if(!n)throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a date-only string`);return t.fromDateTime(n.toDateTime()).toStorageFormat()}case`time-only`:{if(o.isTime(r))return r.toStorageString();if(o.isDate(r))return n.fromDateTime(r.toDateTime()).toStorageString();let t=n.fromString(o.toString(r));if(!t)throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a time-only string`);return t.toStorageString()}case`timestamp-offset`:{let t=l(r,a,o);if(!t)throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a timestamp-offset string`);return t.toISOString(!1)}}throw new e(`unsupported-value-type`,`Unable to convert value ${r} to a value matching field type`)}function c(e,t){if(e===``)return null;let n=t.toNumber(e);return Number.isNaN(n)?null:n}function l(e,t,n){if(n.isDate(e))return e;if(n.isDateOnly(e))return e.toArcadeDate();let r=n.toString(e),i=n.toDate(r,t);return!i||!/\d{4}-\d{2}-\d{2}/.test(r)?null:i}function u(e,t,n){let{editType:r,map:i,spatialReference:a,timeZone:o}=e,s=t.layer,c=s?.type===`scene`&&s.associatedLayer!=null?s.associatedLayer:s;return{variables:{$originalfeature:t.original,$editcontext:{editType:r},$layer:c,$featureset:c,$datastore:c?.url,$feature:t.plainGraphic,$map:i},executeContext:{rawOutput:!0,spatialReference:a??void 0,timeZone:o,abortSignal:n}}}function d(e){return e===`choiceExpression`}export{s as castArcadeValue,d as isDeferredExpressionType,u as makeArcadeContext,a as makeExecutorSetForFormElement,o as makeExpressionInfosMap};
|
|
@@ -23,6 +23,12 @@ export interface FieldInputProperties extends EditableInputProperties, Partial<P
|
|
|
23
23
|
* @see [BatchFormInputs](https://developers.arcgis.com/javascript/latest/references/core/widgets/BatchAttributeForm/inputs/BatchFormInputs/)
|
|
24
24
|
*/
|
|
25
25
|
export default class FieldInput extends EditableInput<any> {
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated
|
|
28
|
+
* since 5.2. This is a read-only class. Instances should be
|
|
29
|
+
* created and accessed via
|
|
30
|
+
* [BatchAttributeFormViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel/)
|
|
31
|
+
*/
|
|
26
32
|
constructor(properties: FieldInputProperties);
|
|
27
33
|
/**
|
|
28
34
|
* The type of data displayed by the field input. Possible values are listed below.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../../../core/arrayUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{isDynamicChoiceInput as a,isMultipleChoiceInput as o}from"../../../form/elements/inputs/inputUtils.js";import s from"../../../layers/support/CodedValue.js";import c from"../../../layers/support/CodedValueDomain.js";import{getDomainRange as l,validateDomainValue as u,dateTimeFieldValuesToNumericRange as d,isDomainValidForField as f}from"../../../layers/support/domainUtils.js";import{getFieldRange as p,isDateOnlyField as m,isTimeOnlyField as h,isTimestampOffsetField as g}from"../../../layers/support/fieldUtils.js";import{supportsFieldConfiguration as _}from"../../../layers/support/layerUtils.js";import v from"../../../layers/support/RangeDomain.js";import{isNumber as y}from"../../../support/guards.js";import b from"./EditableInput.js";import{isMultipleChoiceController as x}from"./support/controllerUtils.js";import S from"./support/DynamicChoiceController.js";import{MultiFeatureError as C,getFieldInputDataType as w,visibilityCodeToBoolean as T,isFieldInputWithShowNoValueOptionInput as E,isWarning as D,isContingentValuesError as O,FormValidationWarning as k,differentValuesString as A}from"./support/inputUtils.js";import j from"./support/MultipleChoiceController.js";import{otherChoiceCheckedPlaceholderValue as M}from"./support/multipleChoiceInputUtils.js";import{timeResolutionToStepMap as N}from"../../support/dateUtils.js";import{valuesAreEquivalent as P,getMaxLength as F,getMinLength as I,dateIsValid as L,validateFormValue as R}from"../../support/forms/formUtils.js";let z=class extends b{constructor(e){super(e),this.getExternalErrorForFeature=null,this.getFieldValueOptionsForFeature=null,this.group=null,this.inputController=null,this.touched=!1,this.type=`field`,this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}destroy(){this.inputController=n(this.inputController)}initialize(){this.input&&(a(this.input)&&(this.inputController=new S({fieldInput:this})),o(this.input)&&(this.inputController=new j({fieldInput:this})))}get compositeError(){if(this.valid)return null;let{errors:e}=this;if(e.length<this.features.length)return C.DIFFERENT_ERRORS;let t=e[0];for(let n of e)if(n.error!==t.error)return C.DIFFERENT_ERRORS;return t.error}get dataType(){return w(this.field)}get domain(){let e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];let e=new Set;for(let t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return this.field.editable?this._evaluatedEditableExpression??!0:!1}get label(){let{label:e}=this.template,t=this._computeStringLiteralText(e);if(t)return t;let{field:n,layers:r}=this;if(r.length===1){let e=r[0];if(_(e)){let t=e.getFieldAlias(n.name);if(t!=null&&t!==``)return t}}return n.alias||n.name}get effectiveVisible(){return T(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){let{visibilityCode:e}=this;if(e!==`visible`)return e;let{group:t}=this;if(t==null)return e;let n=t.visibilityCode;return n===`hidden:visibility-expression:all-features`?`hidden:group-visibility-expression:all-features`:n===`hidden:visibility-expression:some-features`?`hidden:group-visibility-expression:some-features`:e}get errors(){return this._validate()}get featuresHaveSameValue(){let{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every(n=>P(n.getAttribute(e),t))}get field(){return this.template.field}get fieldName(){return this.field.name}get input(){return this.template.input}get invalidFeatures(){return this.errors.map(e=>e.feature)}get isSubtypeField(){return this.layers.some(e=>{if(e&&`subtypeField`in e){let{subtypeField:t,fieldsIndex:n}=e;return(n.get(t)?.name??t)===this.fieldName}return!1})}get showNoValueOptionEnabled(){let{input:e}=this;return this.required?!1:!E(e)||e?.showNoValueOption===!0}get showNoValueLabel(){let{input:e}=this;return E(e)?e?.noValueOptionLabel:null}get includeTime(){let{template:e,field:t}=this;return this.dataType===`date`?t.type===`time-only`?!0:t.type===`date-only`?!1:e.input?.type!==`datetime-picker`||e.input.includeTime:!1}get includeTimeOffset(){if(this.field.type!==`timestamp-offset`)return!1;let{input:e}=this;return!e||e.type===`timestampoffset-picker`&&e.includeTimeOffset}get inputType(){return this.input?.type}get maxLength(){return F({dataType:this.dataType,field:this.field,input:this.input})}get minLength(){return I({dataType:this.dataType,field:this.field,input:this.input})}get multipleChoiceOtherChoiceCheckboxState(){return V(this.inputController)?.otherChoiceCheckboxState??{checked:!1,indeterminate:!1}}get placeholder(){return this.template.hint}get range(){if(this.dataType===`date`)return this._dateRange;let{domain:e,field:t}=this;if(e){let n=l(t,e);return{max:n?.max,min:n?.min}}let n=this._allDomains.toArray().every(e=>!e)?p(t):null;return{max:n?.max===Number.MAX_VALUE?null:n?.max??null,min:n?.min===-Number.MAX_VALUE?null:n?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;let e=this.visible&&this.group?.visible!==!1,t=this._evaluatedRequiredExpression;return e&&t!=null?t:!1}get status(){let{validationMessage:e}=this;return e?D(e)?`idle`:`invalid`:this.valid?`valid`:`idle`}get timeResolution(){let e=this.input;if(!(!e||e.type!==`timestampoffset-picker`&&e.type!==`time-picker`))return e.timeResolution??`minutes`}get timeStep(){return this.timeResolution==null?void 0:N.get(this.timeResolution)}get userInvalid(){return this.errors.some(({error:e})=>O(e))?!0:!this.valid&&this.touched}get valid(){return this.errors.length===0||!this.editable}get validationMessage(){return this.valueIsOutOfDomain&&this.touched?k.OUT_OF_SUBTYPE_DOMAIN:this.userInvalid?this.compositeError??void 0:void 0}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:A}get valueIsOutOfDomain(){let{domain:e,value:t,field:n}=this;return!e||t==null?!1:u(n,t,e)!==null}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&this.domain==null?`hidden:no-domain-in-common`:this._baseVisibilityCode:`hidden:field-definition`}get codedValueDomainOptions(){return this.domain?.type===`coded-value`?this.domain.codedValues.map(({name:e,code:t})=>({name:e,value:t})):[]}getExplicitMultipleChoiceOtherChoiceCheckedState(){return V(this.inputController)?.getExplicitOtherChoiceCheckedState()}getMultipleChoiceOtherChoiceRenderState(e){let t=V(this.inputController)?.otherChoiceRenderState;return t?{...t,label:t.label??e}:{fieldName:void 0,hint:``,label:e,shouldShow:!1,checkboxState:{checked:!1,indeterminate:!1},value:null,normalizedValue:null,maxLength:void 0,status:`idle`}}hasExplicitMultipleChoiceOtherChoiceCheckedState(){return V(this.inputController)?.hasExplicitOtherChoiceCheckedState()??!1}initializeExplicitMultipleChoiceOtherChoiceCheckedState(){V(this.inputController)?.initializeExplicitOtherChoiceCheckedState()}setExplicitMultipleChoiceOtherChoiceCheckedState(e){V(this.inputController)?.setExplicitOtherChoiceCheckedState(e)}get codedValueOptions(){let{getFieldValueOptionsForFeature:e}=this;if(this.features.length===1&&e){let t=this.features.at(0);return e({domain:this.domain??void 0,feature:t,fieldName:this.fieldName,layer:t.layer})}let t=this.codedValueDomainOptions,{value:n}=this;return{recommended:t,other:[],unsupported:n!=null&&n!==A&&!t.some(e=>e.value===n)?[{name:`${n}`,value:n}]:[],containsEmptyOption:!1}}get _evaluatedRequiredExpression(){let e=!1,t=!0,n=this.template;for(let r of this.features){if(n.getExpressionExecutorsForLayer(r.layer)?.requiredExpression==null)continue;t=!1;let i=this._lookupEvaluatedExpression(r,`requiredExpression`);if(i?.status!==`success`){e=!0;continue}e||=i.result===!0}return t?null:e}get _allDomains(){let e=this.template.domain;return this.features.map(t=>{let n=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return n?.type===`range`||e?.type===`range`?n??this.template.domain:n})}get _fieldShouldHaveDomain(){return this._hasIntersectionWithElementFieldDomain?!0:this._allDomains.some(t)}get _dateFormRange(){if(this.dataType!==`date`)return{};let{input:e}=this;if(!e)return{};let{type:t}=e,n={};if((t===`date-picker`||t===`time-picker`||t===`timestampoffset-picker`)&&(n=d(this.field,e.max,e.min)),t===`datetime-picker`){let{max:t,min:r}=e;n={max:t!=null&&L(t)?t.getTime():null,min:r!=null&&L(r)?r.getTime():null}}return{min:n.min,max:n.max,rawMax:n?.rawMax??null,rawMin:n?.rawMin??null}}get _dateRange(){let{_dateFormRange:e,template:t,field:n,domain:r}=this;if(this.dataType!==`date`)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;let i=l(n,r);if(!i)return e;let{max:a,min:o,rawMax:s,rawMin:c}=e,{type:u}=t.field;if(u===`date`){let{max:e,min:t}=i;return{max:y(a)&&(e===null||e!=null&&a<=e)?a:e??null,min:y(o)&&(t===null||t!=null&&o>=t)?o:t??null}}if(u===`date-only`||u===`time-only`||u===`timestamp-offset`){let{max:e,min:t,rawMax:n,rawMin:r}=i,l=y(a)&&s&&(e==null||a<e),u=y(o)&&c&&(t==null||o>t);return{max:l?a:e,min:u?o:t,rawMax:l?s:n,rawMin:u?c:r}}return{}}touch(){this.touched=!0}_validate(){let{dataType:e,fieldName:t,maxLength:n,minLength:r,range:i}=this,a=[],o=x(this.inputController)?this.inputController:void 0,s=o?.input;for(let c of this.features){let{layer:l}=c,u=l.getField(t)??this.field,d=l.getFieldDomain(t,{feature:c.plainGraphic}),f=this.calculateDomain([d]),p=!f||f.type===`coded-value`?null:f,m=this._requiredForFeature(c),h=c.getAttribute(t),g=R(h,{dataType:e,domain:p,field:u,maxLength:n,minLength:r,multipleChoice:s,range:i,required:m})??this.getExternalErrorForFeature?.(c,t);if(!g&&s&&o){let{otherChoice:e}=s,t=o.otherChoiceFieldName,n=o.shouldShowOtherChoice,r=o.otherChoiceEffectiveCheckboxState;if(n&&e&&t&&r.checked){let e=l.getField(t),n=c.getAttribute(t),r=n===M?null:n;if(e){let t=w(e);g=R(r,{dataType:t,domain:e.domain,field:e,maxLength:F({dataType:t,field:e,input:null}),minLength:I({dataType:t,field:e,input:null}),multipleChoice:null,range:{max:void 0,min:void 0},required:!0})}}}g&&a.push({error:g,feature:c.source})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression==null)return!0;let t=this._lookupEvaluatedExpression(e,`editableExpression`);return t?.status===`success`&&t.result===!0}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression==null)return!0;let t=this._lookupEvaluatedExpression(e,`visibilityExpression`);return t?.status===`success`&&t.result===!0}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;let t=this._effectiveVisibleFeature(e);if(this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression==null)return!1;let n=this._lookupEvaluatedExpression(e,`requiredExpression`);return n?.status===`success`?t&&n.result===!0:t}calculateDomain(e){let t=e.find(e=>e!=null),n=this.template.domain;if(!t)return n&&f(this.field,n)?n:null;switch(t.type){case`coded-value`:if(e.some(e=>!e)){if(!n)return null;e=e.filter(e=>e!==null)}break;case`range`:e=e.filter(e=>e!==null)}if(!e.every(e=>e?.type===t?.type))return null;let r=null;switch(t?.type){case`range`:r=this._intersectRangeDomains(e);break;case`coded-value`:r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;let t=new Map(e[0].codedValues.map(({code:e,name:t})=>[e,t])),n=this.template.domain?new Map(this.template.domain.codedValues.map(({code:e,name:t})=>[e,t])):null;for(let n of e)for(let[e,r]of t)if(!n.codedValues.some(t=>t.code===e&&t.name===r)){t.delete(e);continue}let r=t;if(n){r=new Map;for(let[e,i]of n)t.has(e)&&r.set(e,i)}let i=Array.from(r.entries()).map(([e,t])=>new s({code:e,name:t}));return i.length?new c({codedValues:i}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];for(let n=1;n<e.length;n++){if(!t)return null;t=this._findMinMaxValuesBetweenTwoDomains(t,e[n])}if(t&&!f(this.field,t))return null;let{domain:n}=this.template;if(t&&n&&n instanceof v){let e=this._findMinMaxValuesBetweenTwoDomains(t,n);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){let t=e.minValue,n=e.maxValue,{field:r}=this;return m(r)||h(r)||g(r)?d(r,n,t):{min:t!=null&&typeof t==`number`?t:null,max:n!=null&&typeof n==`number`?n:null}}_findMinMaxValuesBetweenTwoDomains(e,t){let n=new v,r=this._getMinMaxFromRangeDomain(e),i=this._getMinMaxFromRangeDomain(t),{field:a}=this,o=this._getValidRangeValue(r.min,-1/0),s=this._getValidRangeValue(r.max,1/0),c=this._getValidRangeValue(i.min,-1/0),l=this._getValidRangeValue(i.max,1/0);return n.minValue=Math.max(o,c),n.maxValue=Math.min(s,l),n.minValue===-1/0||n.maxValue===1/0||n.minValue>n.maxValue?null:((m(a)||h(a)||g(a))&&(n.minValue=Number(r.min)>Number(i.min)?r.rawMin:i.rawMin,n.maxValue=Number(r.max)<Number(i.max)?r.rawMax:i.rawMax),n.name=`intersection`,n)}_getValidRangeValue(e,t){return y(e)?e:t}};e([r()],z.prototype,`dataType`,null),e([r()],z.prototype,`domain`,null),e([r()],z.prototype,`distinctValues`,null),e([r()],z.prototype,`editable`,null),e([r()],z.prototype,`label`,null),e([r()],z.prototype,`effectiveVisible`,null),e([r()],z.prototype,`effectiveVisibilityCode`,null),e([r()],z.prototype,`errors`,null),e([r()],z.prototype,`featuresHaveSameValue`,null),e([r()],z.prototype,`field`,null),e([r()],z.prototype,`fieldName`,null),e([r()],z.prototype,`getExternalErrorForFeature`,void 0),e([r()],z.prototype,`getFieldValueOptionsForFeature`,void 0),e([r()],z.prototype,`group`,void 0),e([r()],z.prototype,`input`,null),e([r()],z.prototype,`inputController`,void 0),e([r()],z.prototype,`invalidFeatures`,null),e([r()],z.prototype,`isSubtypeField`,null),e([r()],z.prototype,`showNoValueOptionEnabled`,null),e([r()],z.prototype,`showNoValueLabel`,null),e([r()],z.prototype,`includeTime`,null),e([r()],z.prototype,`includeTimeOffset`,null),e([r({readOnly:!0})],z.prototype,`inputType`,null),e([r()],z.prototype,`maxLength`,null),e([r()],z.prototype,`minLength`,null),e([r()],z.prototype,`multipleChoiceOtherChoiceCheckboxState`,null),e([r()],z.prototype,`placeholder`,null),e([r()],z.prototype,`range`,null),e([r()],z.prototype,`required`,null),e([r()],z.prototype,`status`,null),e([r()],z.prototype,`timeResolution`,null),e([r()],z.prototype,`timeStep`,null),e([r()],z.prototype,`touched`,void 0),e([r({readOnly:!0})],z.prototype,`type`,void 0),e([r()],z.prototype,`userHasChangedValue`,void 0),e([r()],z.prototype,`userInvalid`,null),e([r()],z.prototype,`valid`,null),e([r()],z.prototype,`validationMessage`,null),e([r()],z.prototype,`value`,null),e([r()],z.prototype,`valueIsOutOfDomain`,null),e([r()],z.prototype,`visibilityCode`,null),e([r()],z.prototype,`codedValueDomainOptions`,null),e([r()],z.prototype,`codedValueOptions`,null),e([r()],z.prototype,`_evaluatedRequiredExpression`,null),e([r()],z.prototype,`_hasIntersectionWithElementFieldDomain`,void 0),e([r()],z.prototype,`_allDomains`,null),e([r()],z.prototype,`_fieldShouldHaveDomain`,null),e([r()],z.prototype,`_dateFormRange`,null),e([r()],z.prototype,`_dateRange`,null),z=e([i(`esri.widgets.BatchAttributeForm.inputs.FieldInput`)],z);const B=z;function V(e){return x(e)?e:null}export{B as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../../../core/arrayUtils.js";import n from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import{isDynamicChoiceInput as o,isMultipleChoiceInput as s}from"../../../form/elements/inputs/inputUtils.js";import c from"../../../layers/support/CodedValue.js";import l from"../../../layers/support/CodedValueDomain.js";import{getDomainRange as u,validateDomainValue as d,dateTimeFieldValuesToNumericRange as f,isDomainValidForField as p}from"../../../layers/support/domainUtils.js";import{getFieldRange as m,isDateOnlyField as h,isTimeOnlyField as g,isTimestampOffsetField as _}from"../../../layers/support/fieldUtils.js";import{supportsFieldConfiguration as v}from"../../../layers/support/layerUtils.js";import y from"../../../layers/support/RangeDomain.js";import{isNumber as b}from"../../../support/guards.js";import x from"./EditableInput.js";import{isMultipleChoiceController as S}from"./support/controllerUtils.js";import C from"./support/DynamicChoiceController.js";import{MultiFeatureError as w,getFieldInputDataType as T,visibilityCodeToBoolean as E,isFieldInputWithShowNoValueOptionInput as D,isWarning as O,isContingentValuesError as k,FormValidationWarning as A,differentValuesString as j}from"./support/inputUtils.js";import M from"./support/MultipleChoiceController.js";import{otherChoiceCheckedPlaceholderValue as N}from"./support/multipleChoiceInputUtils.js";import{timeResolutionToStepMap as P}from"../../support/dateUtils.js";import{valuesAreEquivalent as F,getMaxLength as I,getMinLength as L,dateIsValid as R,validateFormValue as z}from"../../support/forms/formUtils.js";let B=class extends x{constructor(e){super(e),this.getExternalErrorForFeature=null,this.getFieldValueOptionsForFeature=null,this.group=null,this.inputController=null,this.touched=!1,this.type=`field`,this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}destroy(){this.inputController=r(this.inputController)}initialize(){if(this.input){if(o(this.input)){let{requestDeferredExpressionEvaluation:e}=this;e?this.inputController=new C({fieldInput:this,requestDeferredExpressionEvaluation:e}):n.getLogger(this).error(`requestDeferredExpressionEvaluation callback is required for dynamic choice inputs.`)}s(this.input)&&(this.inputController=new M({fieldInput:this}))}}get compositeError(){if(this.valid)return null;let{errors:e}=this;if(e.length<this.features.length)return w.DIFFERENT_ERRORS;let t=e[0];for(let n of e)if(n.error!==t.error)return w.DIFFERENT_ERRORS;return t.error}get dataType(){return T(this.field)}get domain(){let e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];let e=new Set;for(let t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return this.field.editable?this._evaluatedEditableExpression??!0:!1}get label(){let{label:e}=this.template,t=this._computeStringLiteralText(e);if(t)return t;let{field:n,layers:r}=this;if(r.length===1){let e=r[0];if(v(e)){let t=e.getFieldAlias(n.name);if(t!=null&&t!==``)return t}}return n.alias||n.name}get effectiveVisible(){return E(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){let{visibilityCode:e}=this;if(e!==`visible`)return e;let{group:t}=this;if(t==null)return e;let n=t.visibilityCode;return n===`hidden:visibility-expression:all-features`?`hidden:group-visibility-expression:all-features`:n===`hidden:visibility-expression:some-features`?`hidden:group-visibility-expression:some-features`:e}get errors(){return this._validate()}get featuresHaveSameValue(){let{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every(n=>F(n.getAttribute(e),t))}get field(){return this.template.field}get fieldName(){return this.field.name}get input(){return this.template.input}get invalidFeatures(){return this.errors.map(e=>e.feature)}get isSubtypeField(){return this.layers.some(e=>{if(e&&`subtypeField`in e){let{subtypeField:t,fieldsIndex:n}=e;return(n.get(t)?.name??t)===this.fieldName}return!1})}get showNoValueOptionEnabled(){let{input:e}=this;return this.required?!1:!D(e)||e?.showNoValueOption===!0}get showNoValueLabel(){let{input:e}=this;return D(e)?e?.noValueOptionLabel:null}get includeTime(){let{template:e,field:t}=this;return this.dataType===`date`?t.type===`time-only`?!0:t.type===`date-only`?!1:e.input?.type!==`datetime-picker`||e.input.includeTime:!1}get includeTimeOffset(){if(this.field.type!==`timestamp-offset`)return!1;let{input:e}=this;return!e||e.type===`timestampoffset-picker`&&e.includeTimeOffset}get inputType(){return this.input?.type}get maxLength(){return I({dataType:this.dataType,field:this.field,input:this.input})}get minLength(){return L({dataType:this.dataType,field:this.field,input:this.input})}get multipleChoiceOtherChoiceCheckboxState(){return H(this.inputController)?.otherChoiceCheckboxState??{checked:!1,indeterminate:!1}}get placeholder(){return this.template.hint}get range(){if(this.dataType===`date`)return this._dateRange;let{domain:e,field:t}=this;if(e){let n=u(t,e);return{max:n?.max,min:n?.min}}let n=this._allDomains.toArray().every(e=>!e)?m(t):null;return{max:n?.max===Number.MAX_VALUE?null:n?.max??null,min:n?.min===-Number.MAX_VALUE?null:n?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;let e=this.visible&&this.group?.visible!==!1,t=this._evaluatedRequiredExpression;return e&&t!=null?t:!1}get status(){let{validationMessage:e}=this;return e?O(e)?`idle`:`invalid`:this.valid?`valid`:`idle`}get timeResolution(){let e=this.input;if(!(!e||e.type!==`timestampoffset-picker`&&e.type!==`time-picker`))return e.timeResolution??`minutes`}get timeStep(){return this.timeResolution==null?void 0:P.get(this.timeResolution)}get userInvalid(){return this.errors.some(({error:e})=>k(e))?!0:!this.valid&&this.touched}get valid(){return this.errors.length===0||!this.editable}get validationMessage(){return this.valueIsOutOfDomain&&this.touched?A.OUT_OF_SUBTYPE_DOMAIN:this.userInvalid?this.compositeError??void 0:void 0}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:j}get valueIsOutOfDomain(){let{domain:e,value:t,field:n}=this;return!e||t==null?!1:d(n,t,e)!==null}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&this.domain==null?`hidden:no-domain-in-common`:this._baseVisibilityCode:`hidden:field-definition`}get codedValueDomainOptions(){return this.domain?.type===`coded-value`?this.domain.codedValues.map(({name:e,code:t})=>({name:e,value:t})):[]}getExplicitMultipleChoiceOtherChoiceCheckedState(){return H(this.inputController)?.getExplicitOtherChoiceCheckedState()}getMultipleChoiceOtherChoiceRenderState(e){let t=H(this.inputController)?.otherChoiceRenderState;return t?{...t,label:t.label??e}:{fieldName:void 0,hint:``,label:e,shouldShow:!1,checkboxState:{checked:!1,indeterminate:!1},value:null,normalizedValue:null,maxLength:void 0,status:`idle`}}hasExplicitMultipleChoiceOtherChoiceCheckedState(){return H(this.inputController)?.hasExplicitOtherChoiceCheckedState()??!1}initializeExplicitMultipleChoiceOtherChoiceCheckedState(){H(this.inputController)?.initializeExplicitOtherChoiceCheckedState()}setExplicitMultipleChoiceOtherChoiceCheckedState(e){H(this.inputController)?.setExplicitOtherChoiceCheckedState(e)}get codedValueOptions(){let{getFieldValueOptionsForFeature:e}=this;if(this.features.length===1&&e){let t=this.features.at(0);return e({domain:this.domain??void 0,feature:t,fieldName:this.fieldName,layer:t.layer})}let t=this.codedValueDomainOptions,{value:n}=this;return{recommended:t,other:[],unsupported:n!=null&&n!==j&&!t.some(e=>e.value===n)?[{name:`${n}`,value:n}]:[],containsEmptyOption:!1}}get _evaluatedRequiredExpression(){let e=!1,t=!0,n=this.template;for(let r of this.features){if(n.getExpressionExecutorsForLayer(r.layer)?.requiredExpression==null)continue;t=!1;let i=this._lookupEvaluatedExpression(r,`requiredExpression`);if(i?.status!==`success`){e=!0;continue}e||=i.result===!0}return t?null:e}get _allDomains(){let e=this.template.domain;return this.features.map(t=>{let n=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return n?.type===`range`||e?.type===`range`?n??this.template.domain:n})}get _fieldShouldHaveDomain(){return this._hasIntersectionWithElementFieldDomain?!0:this._allDomains.some(t)}get _dateFormRange(){if(this.dataType!==`date`)return{};let{input:e}=this;if(!e)return{};let{type:t}=e,n={};if((t===`date-picker`||t===`time-picker`||t===`timestampoffset-picker`)&&(n=f(this.field,e.max,e.min)),t===`datetime-picker`){let{max:t,min:r}=e;n={max:t!=null&&R(t)?t.getTime():null,min:r!=null&&R(r)?r.getTime():null}}return{min:n.min,max:n.max,rawMax:n?.rawMax??null,rawMin:n?.rawMin??null}}get _dateRange(){let{_dateFormRange:e,template:t,field:n,domain:r}=this;if(this.dataType!==`date`)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;let i=u(n,r);if(!i)return e;let{max:a,min:o,rawMax:s,rawMin:c}=e,{type:l}=t.field;if(l===`date`){let{max:e,min:t}=i;return{max:b(a)&&(e===null||e!=null&&a<=e)?a:e??null,min:b(o)&&(t===null||t!=null&&o>=t)?o:t??null}}if(l===`date-only`||l===`time-only`||l===`timestamp-offset`){let{max:e,min:t,rawMax:n,rawMin:r}=i,l=b(a)&&s&&(e==null||a<e),u=b(o)&&c&&(t==null||o>t);return{max:l?a:e,min:u?o:t,rawMax:l?s:n,rawMin:u?c:r}}return{}}touch(){this.touched=!0}_validate(){let{dataType:e,fieldName:t,maxLength:n,minLength:r,range:i}=this,a=[],o=S(this.inputController)?this.inputController:void 0,s=o?.input;for(let c of this.features){let{layer:l}=c,u=l.getField(t)??this.field,d=l.getFieldDomain(t,{feature:c.plainGraphic}),f=this.calculateDomain([d]),p=!f||f.type===`coded-value`?null:f,m=this._requiredForFeature(c),h=c.getAttribute(t),g=z(h,{dataType:e,domain:p,field:u,maxLength:n,minLength:r,multipleChoice:s,range:i,required:m})??this.getExternalErrorForFeature?.(c,t);if(!g&&s&&o){let{otherChoice:e}=s,t=o.otherChoiceFieldName,n=o.shouldShowOtherChoice,r=o.otherChoiceEffectiveCheckboxState;if(n&&e&&t&&r.checked){let e=l.getField(t),n=c.getAttribute(t),r=n===N?null:n;if(e){let t=T(e);g=z(r,{dataType:t,domain:e.domain,field:e,maxLength:I({dataType:t,field:e,input:null}),minLength:L({dataType:t,field:e,input:null}),multipleChoice:null,range:{max:void 0,min:void 0},required:!0})}}}g&&a.push({error:g,feature:c.source})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression==null)return!0;let t=this._lookupEvaluatedExpression(e,`editableExpression`);return t?.status===`success`&&t.result===!0}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression==null)return!0;let t=this._lookupEvaluatedExpression(e,`visibilityExpression`);return t?.status===`success`&&t.result===!0}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;let t=this._effectiveVisibleFeature(e);if(this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression==null)return!1;let n=this._lookupEvaluatedExpression(e,`requiredExpression`);return n?.status===`success`?t&&n.result===!0:t}calculateDomain(e){let t=e.find(e=>e!=null),n=this.template.domain;if(!t)return n&&p(this.field,n)?n:null;switch(t.type){case`coded-value`:if(e.some(e=>!e)){if(!n)return null;e=e.filter(e=>e!==null)}break;case`range`:e=e.filter(e=>e!==null)}if(!e.every(e=>e?.type===t?.type))return null;let r=null;switch(t?.type){case`range`:r=this._intersectRangeDomains(e);break;case`coded-value`:r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;let t=new Map(e[0].codedValues.map(({code:e,name:t})=>[e,t])),n=this.template.domain?new Map(this.template.domain.codedValues.map(({code:e,name:t})=>[e,t])):null;for(let n of e)for(let[e,r]of t)if(!n.codedValues.some(t=>t.code===e&&t.name===r)){t.delete(e);continue}let r=t;if(n){r=new Map;for(let[e,i]of n)t.has(e)&&r.set(e,i)}let i=Array.from(r.entries()).map(([e,t])=>new c({code:e,name:t}));return i.length?new l({codedValues:i}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];for(let n=1;n<e.length;n++){if(!t)return null;t=this._findMinMaxValuesBetweenTwoDomains(t,e[n])}if(t&&!p(this.field,t))return null;let{domain:n}=this.template;if(t&&n&&n instanceof y){let e=this._findMinMaxValuesBetweenTwoDomains(t,n);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){let t=e.minValue,n=e.maxValue,{field:r}=this;return h(r)||g(r)||_(r)?f(r,n,t):{min:t!=null&&typeof t==`number`?t:null,max:n!=null&&typeof n==`number`?n:null}}_findMinMaxValuesBetweenTwoDomains(e,t){let n=new y,r=this._getMinMaxFromRangeDomain(e),i=this._getMinMaxFromRangeDomain(t),{field:a}=this,o=this._getValidRangeValue(r.min,-1/0),s=this._getValidRangeValue(r.max,1/0),c=this._getValidRangeValue(i.min,-1/0),l=this._getValidRangeValue(i.max,1/0);return n.minValue=Math.max(o,c),n.maxValue=Math.min(s,l),n.minValue===-1/0||n.maxValue===1/0||n.minValue>n.maxValue?null:((h(a)||g(a)||_(a))&&(n.minValue=Number(r.min)>Number(i.min)?r.rawMin:i.rawMin,n.maxValue=Number(r.max)<Number(i.max)?r.rawMax:i.rawMax),n.name=`intersection`,n)}_getValidRangeValue(e,t){return b(e)?e:t}};e([i()],B.prototype,`dataType`,null),e([i()],B.prototype,`domain`,null),e([i()],B.prototype,`distinctValues`,null),e([i()],B.prototype,`editable`,null),e([i()],B.prototype,`label`,null),e([i()],B.prototype,`effectiveVisible`,null),e([i()],B.prototype,`effectiveVisibilityCode`,null),e([i()],B.prototype,`errors`,null),e([i()],B.prototype,`featuresHaveSameValue`,null),e([i()],B.prototype,`field`,null),e([i()],B.prototype,`fieldName`,null),e([i()],B.prototype,`getExternalErrorForFeature`,void 0),e([i()],B.prototype,`getFieldValueOptionsForFeature`,void 0),e([i()],B.prototype,`group`,void 0),e([i()],B.prototype,`input`,null),e([i()],B.prototype,`inputController`,void 0),e([i()],B.prototype,`invalidFeatures`,null),e([i()],B.prototype,`isSubtypeField`,null),e([i()],B.prototype,`showNoValueOptionEnabled`,null),e([i()],B.prototype,`showNoValueLabel`,null),e([i()],B.prototype,`includeTime`,null),e([i()],B.prototype,`includeTimeOffset`,null),e([i({readOnly:!0})],B.prototype,`inputType`,null),e([i()],B.prototype,`maxLength`,null),e([i()],B.prototype,`minLength`,null),e([i()],B.prototype,`multipleChoiceOtherChoiceCheckboxState`,null),e([i()],B.prototype,`placeholder`,null),e([i()],B.prototype,`range`,null),e([i()],B.prototype,`requestDeferredExpressionEvaluation`,void 0),e([i()],B.prototype,`required`,null),e([i()],B.prototype,`status`,null),e([i()],B.prototype,`timeResolution`,null),e([i()],B.prototype,`timeStep`,null),e([i()],B.prototype,`touched`,void 0),e([i({readOnly:!0})],B.prototype,`type`,void 0),e([i()],B.prototype,`userHasChangedValue`,void 0),e([i()],B.prototype,`userInvalid`,null),e([i()],B.prototype,`valid`,null),e([i()],B.prototype,`validationMessage`,null),e([i()],B.prototype,`value`,null),e([i()],B.prototype,`valueIsOutOfDomain`,null),e([i()],B.prototype,`visibilityCode`,null),e([i()],B.prototype,`codedValueDomainOptions`,null),e([i()],B.prototype,`codedValueOptions`,null),e([i()],B.prototype,`_evaluatedRequiredExpression`,null),e([i()],B.prototype,`_hasIntersectionWithElementFieldDomain`,void 0),e([i()],B.prototype,`_allDomains`,null),e([i()],B.prototype,`_fieldShouldHaveDomain`,null),e([i()],B.prototype,`_dateFormRange`,null),e([i()],B.prototype,`_dateRange`,null),B=e([a(`esri.widgets.BatchAttributeForm.inputs.FieldInput`)],B);const V=B;function H(e){return S(e)?e:null}export{V as default};
|