@arcgis/core 4.28.0-rc.2 → 4.28.0-rc.4

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.
Files changed (163) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/functions/featuresetbase.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{0e354096ad8817971eed.js → 02d235849ba93541d7ad.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0422c5160491fbcf01dc.js +1 -0
  6. package/assets/esri/core/workers/chunks/1da721608993783dc9cf.js +1 -0
  7. package/assets/esri/core/workers/chunks/224e79f6c172da444e0a.js +1 -0
  8. package/assets/esri/core/workers/chunks/{ca3d5803cdf035d7389d.js → 30776102fbab294bfe7b.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{61dec8399919b278b636.js → 3ac9001b19a90faf5573.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{fa6103e3d4e857b0035b.js → 3dcb2a82e1e4b520c9c9.js} +11 -8
  11. package/assets/esri/core/workers/chunks/41081c921037e543a22f.js +1 -0
  12. package/assets/esri/core/workers/chunks/4564a7885d045a850887.js +1 -0
  13. package/assets/esri/core/workers/chunks/4adf3a8c6b49c381a633.js +1 -0
  14. package/assets/esri/core/workers/chunks/{2721aa6b6941b28b9758.js → 63c8bf00120a4e67f5b0.js} +1 -1
  15. package/assets/esri/core/workers/chunks/6bc1f6f8a2408fa4bb6a.js +1 -0
  16. package/assets/esri/core/workers/chunks/74951370a341f02d3714.js +1 -0
  17. package/assets/esri/core/workers/chunks/78e49a70193e5adea17c.js +1 -0
  18. package/assets/esri/core/workers/chunks/7b8377b3a9f78f9d3613.js +1 -0
  19. package/assets/esri/core/workers/chunks/{fd28400141a6751327ae.js → 7cf7f2b991a7cbdad2ce.js} +1 -1
  20. package/assets/esri/core/workers/chunks/830d99e6c58a52a58973.js +1 -0
  21. package/assets/esri/core/workers/chunks/{1a723bb4a341f645e5fe.js → 83b8141f0c80e3448012.js} +1 -1
  22. package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +1 -0
  23. package/assets/esri/core/workers/chunks/934c32c49bb9e21482fd.js +1 -0
  24. package/assets/esri/core/workers/chunks/{a4341ec0fe89b865d849.js → a160576f21ada91995ac.js} +1 -1
  25. package/assets/esri/core/workers/chunks/a1e16c33f1843dbdce26.js +1 -0
  26. package/assets/esri/core/workers/chunks/{d07235ce2765a25b9be4.js → a50ec5b647a160199cb2.js} +1 -1
  27. package/assets/esri/core/workers/chunks/b6bd31674076e543d8b2.js +1 -0
  28. package/assets/esri/core/workers/chunks/{77923afde29ae1ff10ca.js → b6e86e179f99b5cf8dff.js} +1 -1
  29. package/assets/esri/core/workers/chunks/c3ddf5dbc34f118002df.js +1 -0
  30. package/assets/esri/core/workers/chunks/{562eafa5090827ebb7ec.js → c87e9280681c20d042b5.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{7b3d5f044c96e2c2af11.js → d191267d91a53db42956.js} +1 -1
  32. package/assets/esri/core/workers/chunks/ffa330a19a09679212fb.js +1 -0
  33. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +9 -13
  34. package/assets/esri/themes/base/widgets/_Features.scss +5 -0
  35. package/assets/esri/themes/base/widgets/_Legend.scss +1 -1
  36. package/assets/esri/themes/base/widgets/_Popup.scss +0 -1
  37. package/assets/esri/themes/base/widgets/_TimeZoneLabel.scss +3 -3
  38. package/assets/esri/themes/dark/main.css +1 -1
  39. package/assets/esri/themes/light/main.css +1 -1
  40. package/assets/esri/themes/light/view.css +1 -1
  41. package/geometry/support/meshUtils/georeference.js +1 -1
  42. package/interfaces.d.ts +1506 -314
  43. package/intl/date.js +1 -1
  44. package/kernel.js +1 -1
  45. package/layers/FeatureLayer.js +1 -1
  46. package/layers/GroupLayer.js +1 -1
  47. package/layers/OrientedImageryLayer.js +1 -1
  48. package/layers/SceneLayer.js +1 -1
  49. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  50. package/layers/graphics/data/QueryEngineResult.js +1 -1
  51. package/layers/graphics/data/queryValidationUtils.js +1 -1
  52. package/layers/mixins/ArcGISMapService.js +1 -1
  53. package/layers/save/groupLayerUtils.js +1 -1
  54. package/layers/save/utils.js +1 -1
  55. package/layers/support/ImageElement.js +1 -1
  56. package/layers/support/LayerContingentValuesCache.js +1 -1
  57. package/layers/support/Sublayer.js +1 -1
  58. package/layers/support/Subtype.d.ts +4 -0
  59. package/layers/support/Subtype.js +1 -1
  60. package/layers/support/imageryRendererUtils.js +1 -1
  61. package/networks/Network.js +1 -1
  62. package/package.json +1 -1
  63. package/portal/support/jsonContext.js +1 -1
  64. package/portal/support/layersLoader.js +1 -1
  65. package/rest/featureService/FeatureService.d.ts +4 -0
  66. package/rest/featureService/FeatureService.js +1 -1
  67. package/rest/featureService/utils.d.ts +4 -0
  68. package/rest/query/operations/query.js +1 -1
  69. package/smartMapping/support/utils.js +1 -1
  70. package/statistics/utils.js +1 -1
  71. package/support/basemapUtils.js +1 -1
  72. package/support/revision.js +1 -1
  73. package/versionManagement/VersionManagementService.d.ts +4 -0
  74. package/versionManagement/VersionManagementService.js +1 -1
  75. package/views/2d/engine/Container.js +1 -1
  76. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  77. package/views/2d/engine/webgl/Overlay.js +1 -1
  78. package/views/2d/input/handlers/KeyPan.js +1 -1
  79. package/views/2d/interactive/editingTools/manipulations/DragManipulation.js +1 -1
  80. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  81. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  82. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  83. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  84. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  85. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  86. package/views/3d/layers/I3SMeshView3D.js +1 -1
  87. package/views/3d/layers/MediaLayerView3D.js +1 -1
  88. package/views/3d/layers/SceneLayerWorker.js +1 -1
  89. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  90. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  91. package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
  92. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  93. package/views/3d/support/MemoryController.js +1 -1
  94. package/views/3d/support/PBFDecoder.js +1 -1
  95. package/views/3d/support/ResourceController.js +1 -1
  96. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  97. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  98. package/views/3d/webgl-engine/core/FBOPool.js +5 -0
  99. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -6
  100. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
  101. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  102. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  103. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  104. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  105. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  106. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  107. package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
  108. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  109. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  110. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  111. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +1 -1
  112. package/views/draw/DrawOperation.js +1 -1
  113. package/views/draw/support/Reshape.js +1 -1
  114. package/views/interactive/sketch/constraints.js +1 -1
  115. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  116. package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
  117. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  118. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  119. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  120. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  121. package/views/interactive/snapping/featureSources/queryEngineUtils.js +1 -1
  122. package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
  123. package/webdoc/support/writeUtils.js +1 -1
  124. package/widgets/BasemapGallery.js +1 -1
  125. package/widgets/DirectionalPad.js +1 -1
  126. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  127. package/widgets/Editor/EditorViewModel.js +1 -1
  128. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  129. package/widgets/Editor/UpdateWorkflow.js +1 -1
  130. package/widgets/Editor/VisibleElements.js +1 -1
  131. package/widgets/Editor/workflowUtils.js +1 -1
  132. package/widgets/Editor.js +1 -1
  133. package/widgets/FeatureForm/FieldInput.js +1 -1
  134. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  135. package/widgets/FeatureForm.js +1 -1
  136. package/widgets/Features.js +1 -1
  137. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.d.ts +4 -0
  138. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  139. package/widgets/OrientedImageryViewer.js +1 -1
  140. package/widgets/TimeSlider.js +1 -1
  141. package/widgets/TimeZoneLabel.js +1 -1
  142. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  143. package/widgets/UtilityNetworkTrace.js +1 -1
  144. package/widgets/support/dateUtils.js +1 -1
  145. package/assets/esri/core/workers/chunks/00da3c16741a9bc47f3a.js +0 -1
  146. package/assets/esri/core/workers/chunks/0e4646d14fa0775bf463.js +0 -1
  147. package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +0 -1
  148. package/assets/esri/core/workers/chunks/51b8913dff24e693bd25.js +0 -1
  149. package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +0 -1
  150. package/assets/esri/core/workers/chunks/7388fd97e7b1a2142744.js +0 -1
  151. package/assets/esri/core/workers/chunks/7648f3341b7dff2825c3.js +0 -1
  152. package/assets/esri/core/workers/chunks/92d8f75e616afa5c761e.js +0 -1
  153. package/assets/esri/core/workers/chunks/9c77d69a13ec22cdd760.js +0 -1
  154. package/assets/esri/core/workers/chunks/a821fa1870b83fed5d31.js +0 -1
  155. package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +0 -1
  156. package/assets/esri/core/workers/chunks/b251d8a856dc8b9406e0.js +0 -1
  157. package/assets/esri/core/workers/chunks/c416df0668f6c596095f.js +0 -1
  158. package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +0 -1
  159. package/assets/esri/core/workers/chunks/f0d342303fc20e266d27.js +0 -1
  160. package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +0 -1
  161. package/assets/esri/core/workers/chunks/fc95b1a36ed68b851400.js +0 -1
  162. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -4
  163. package/widgets/DirectionalPad.d.ts +0 -4
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as l}from"../../layers/support/CodedValue.js";import n from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,validateDomainValue as r}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as u,getLowerCaseEditTrackingFields as o,isNumericField as a,isStringField as p,isTimeOnlyField as d,getFieldRange as m,TypeValidationError as h,NumericRangeValidationError as y,validateFieldValue as f}from"../../layers/support/fieldUtils.js";import{isAnyDateField as c}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as g}from"../Feature/support/featureUtils.js";import b from"./EditableInput.js";import{parseFormTemplateString as v,getNormalizedFeatureTypeInfo as x,isFieldElementWithInputType as E,valueIsInvalidSwitchValue as _,isFieldElementWithTextInput as V,isFieldElementWithShowNoValueOptionInput as T,LengthValidationError as F}from"./featureFormUtils.js";import{timeResolutionToStepMap as I,valueIsInRange as D}from"../support/dateUtils.js";var O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(O||(O={}));const N="__internal-type-based-coded-value-domain__";let w=class extends b{constructor(e){super(e),this._storedValue=null,this._valueOriginIsExpression=!1,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&u(e,t)}get _isEditTrackingField(){return o(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return a(e)?O.Number:p(e)?O.Text:c(e)||d(e)?O.Date:O.Unsupported}get dateDataType(){if(this.dataType===O.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?v({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=x(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new n({name:N,codedValues:e.subtypes.map((({code:e,name:t})=>new l({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new n({name:N,codedValues:i.map((({code:e,name:t})=>new l({code:e,name:t})))});const{feature:s}=this,r=e?.getFieldDomain(this.name,{feature:s}),u=this.element?.domain;return null!=u&&this._isDomainCompatible(u)?u:r}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==O.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==O.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=E(e,"switch")?e.input:null;return!t||_(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return g(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?v({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=V(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=V(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:n}=e,r=null!=l&&A(l)?l.getTime():null,u=null!=n&&A(n)?n.getTime():null,o=s(t)||m(i);if(!o)return{max:r,min:u};const a=o.max===Number.MAX_VALUE?null:o.max,p=o.min===Number.MIN_VALUE?null:o.min;return{max:null!=r&&(null===a||null!=a&&r<a)?r:a,min:null!=u&&(null===p||null!=p&&u>p)?u:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!T(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return T(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?I.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return this._valueOriginIsExpression=!0,null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){this._valueOriginIsExpression=!0;const e=this.evaluatedValueExpression;if(this.dataType===O.Date){if(e instanceof Date)return e.getTime();if("number"!=typeof e)return parseInt(e,10)}return null!=e&&"object"==typeof e?e.toString():e}return this._valueOriginIsExpression=!1,this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get valueOriginIsExpression(){return this._valueOriginIsExpression}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&p(t)||"number"===i&&a(t))return!0}return!!("range"===e?.type&&a(t)||c(t)||d(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:s,required:u,valid:o,value:a}=this,p=u&&null==a,d=void 0!==o;return!p&&l.getAttribute(i.name)===a&&d?null:p?h.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof a&&a.length<n?F.TOO_SHORT:"date"===i.type&&null!=a&&s&&!D({value:a,max:s.max,min:s.min})?y.OUT_OF_RANGE:t?null!==a||u?r(t,a):null:f(i,a)}};e([t()],w.prototype,"_storedValue",void 0),e([t()],w.prototype,"_configAllowsEdits",null),e([t()],w.prototype,"_layerAndFieldAllowEdits",null),e([t()],w.prototype,"_isVisibleByDefault",null),e([t()],w.prototype,"_isEditTrackingField",null),e([t()],w.prototype,"_shouldUseValueExpression",null),e([t()],w.prototype,"_valueOriginIsExpression",void 0),e([t()],w.prototype,"_isSubtypeField",null),e([t()],w.prototype,"dataType",null),e([t()],w.prototype,"dateDataType",null),e([t()],w.prototype,"description",null),e([t()],w.prototype,"domain",null),e([t()],w.prototype,"editable",null),e([t({readOnly:!0})],w.prototype,"error",void 0),e([t({constructOnly:!0})],w.prototype,"preservesValueWhenHidden",void 0),e([t()],w.prototype,"evaluatedRequiredExpression",null),e([t()],w.prototype,"evaluatedValueExpression",null),e([t()],w.prototype,"field",void 0),e([t()],w.prototype,"group",void 0),e([t({readOnly:!0})],w.prototype,"hint",null),e([t()],w.prototype,"includeDate",null),e([t()],w.prototype,"includeTime",null),e([t()],w.prototype,"includeTimeOffset",null),e([t()],w.prototype,"initialFeature",null),e([t({readOnly:!0})],w.prototype,"inputType",null),e([t()],w.prototype,"hasInvalidSwitchValue",null),e([t()],w.prototype,"isRelationshipKeyField",null),e([t()],w.prototype,"label",null),e([t()],w.prototype,"maxLength",null),e([t()],w.prototype,"minLength",null),e([t({readOnly:!0})],w.prototype,"name",null),e([t()],w.prototype,"range",null),e([t()],w.prototype,"required",null),e([t()],w.prototype,"requiredExpressionExecutor",void 0),e([t()],w.prototype,"showNoValueOptionEnabled",null),e([t()],w.prototype,"submittable",null),e([t()],w.prototype,"timeResolution",null),e([t()],w.prototype,"timeStep",null),e([t({readOnly:!0})],w.prototype,"type",void 0),e([t()],w.prototype,"updating",null),e([t()],w.prototype,"valid",null),e([t({value:null})],w.prototype,"value",null),e([t()],w.prototype,"valueExpressionExecutor",void 0),e([t()],w.prototype,"valueOriginIsExpression",null),e([t()],w.prototype,"visible",null),w=e([i("esri.widgets.FeatureForm.FieldInput")],w);const A=e=>e&&!Number.isNaN(e.valueOf()),j=w;export{j as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,validateDomainValue as u}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as a,isNumericField as p,isStringField as d,isTimeOnlyField as m,getFieldRange as y,TypeValidationError as h,NumericRangeValidationError as f,validateFieldValue as c}from"../../layers/support/fieldUtils.js";import{isAnyDateField as g}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as b}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{parseFormTemplateString as E,getNormalizedFeatureTypeInfo as x,isFieldElementWithInputType as _,valueIsInvalidSwitchValue as V,isFieldElementWithTextInput as T,isFieldElementWithShowNoValueOptionInput as F,LengthValidationError as D}from"./featureFormUtils.js";import{timeResolutionToStepMap as w,isArcadeDate as N,arcadeDateToFieldValue as I,valueIsInRange as j}from"../support/dateUtils.js";var O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(O||(O={}));const A="__internal-type-based-coded-value-domain__";let L=class extends v{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return a(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return p(e)?O.Number:d(e)?O.Text:g(e)||m(e)?O.Date:O.Unsupported}get dateDataType(){if(this.dataType===O.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?E({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=x(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new r({name:A,codedValues:e.subtypes.map((({code:e,name:t})=>new n({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new r({name:A,codedValues:i.map((({code:e,name:t})=>new n({code:e,name:t})))});const{feature:l}=this,s=e?.getFieldDomain(this.name,{feature:l}),u=this.element?.domain;return null!=u&&this._isDomainCompatible(u)?u:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==O.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==O.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=_(e,"switch")?e.input:null;return!t||V(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return b(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?E({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:n}=e,r=null!=l&&S(l)?l.getTime():null,u=null!=n&&S(n)?n.getTime():null,o=s(t)||y(i);if(!o)return{max:r,min:u};const a=o.max===Number.MAX_VALUE?null:o.max,p=o.min===Number.MIN_VALUE?null:o.min;return{max:null!=r&&(null===a||null!=a&&r<a)?r:a,min:null!=u&&(null===p||null!=p&&u>p)?u:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!F(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return F(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?w.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===O.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(N(e))return I(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&d(t)||"number"===i&&p(t))return!0}return!!("range"===e?.type&&p(t)||g(t)||m(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:o,value:a}=this,p=s&&null==a,d=void 0!==o;return!p&&l.getAttribute(i.name)===a&&d?null:p?h.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof a&&a.length<n?D.TOO_SHORT:"date"===i.type&&null!=a&&r&&!j({value:a,max:r.max,min:r.min})?f.OUT_OF_RANGE:t?null!==a||s?u(t,a):null:c(i,a)}};e([i()],L.prototype,"_storedValue",void 0),e([i()],L.prototype,"_configAllowsEdits",null),e([i()],L.prototype,"_layerAndFieldAllowEdits",null),e([i()],L.prototype,"_isVisibleByDefault",null),e([i()],L.prototype,"_isEditTrackingField",null),e([i()],L.prototype,"_shouldUseValueExpression",null),e([i()],L.prototype,"_isSubtypeField",null),e([i()],L.prototype,"dataType",null),e([i()],L.prototype,"dateDataType",null),e([i()],L.prototype,"description",null),e([i()],L.prototype,"domain",null),e([i()],L.prototype,"editable",null),e([i({readOnly:!0})],L.prototype,"error",void 0),e([i({constructOnly:!0})],L.prototype,"preservesValueWhenHidden",void 0),e([i()],L.prototype,"evaluatedRequiredExpression",null),e([i()],L.prototype,"evaluatedValueExpression",null),e([i()],L.prototype,"field",void 0),e([i()],L.prototype,"group",void 0),e([i({readOnly:!0})],L.prototype,"hint",null),e([i()],L.prototype,"includeDate",null),e([i()],L.prototype,"includeTime",null),e([i()],L.prototype,"includeTimeOffset",null),e([i()],L.prototype,"initialFeature",null),e([i({readOnly:!0})],L.prototype,"inputType",null),e([i()],L.prototype,"hasInvalidSwitchValue",null),e([i()],L.prototype,"isRelationshipKeyField",null),e([i()],L.prototype,"label",null),e([i()],L.prototype,"maxLength",null),e([i()],L.prototype,"minLength",null),e([i({readOnly:!0})],L.prototype,"name",null),e([i()],L.prototype,"range",null),e([i()],L.prototype,"required",null),e([i()],L.prototype,"requiredExpressionExecutor",void 0),e([i()],L.prototype,"showNoValueOptionEnabled",null),e([i()],L.prototype,"submittable",null),e([i()],L.prototype,"timeResolution",null),e([i()],L.prototype,"timeStep",null),e([i({readOnly:!0})],L.prototype,"type",void 0),e([i()],L.prototype,"updating",null),e([i()],L.prototype,"valid",null),e([i({value:null})],L.prototype,"value",null),e([i()],L.prototype,"valueExpressionExecutor",void 0),e([i()],L.prototype,"visible",null),L=e([l("esri.widgets.FeatureForm.FieldInput")],L);const S=e=>e&&!Number.isNaN(e.valueOf()),R=L;export{R as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";const n="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let c=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this.preserveFieldValuesWhenHidden=!0,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}destroy(){this.resetExecutors()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:r,spatialReference:o,timeZone:a}=this.arcadeContextInfo,i="feature"===t?.type?t:"scene"===t?.type&&null!=t.associatedLayer?t.associatedLayer:void 0;return[{$originalfeature:r,$editcontext:{editType:e},$layer:i,$featureset:i,$datastore:t?.url,$map:s},{spatialReference:o??void 0,timeZone:a}]}set feature(e){this._latestFieldValues={...e?.attributes},this._set("feature",e)}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:r}=this,o=new Set;for(const a of e)if(s[a]=r.getAttribute(a),t.has(a))for(const e of t.get(a))o.add(e);return this._evaluate([...o])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(n))return this._evaluate([...this._fieldReferencesLookup.get(n)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:r,preserveFieldValuesWhenHidden:o}=this,a=new Map(this.fieldInputs.map((e=>[e.name,e]))),i=!1===o,l=new Map(r.map((e=>[e,new Array])));for(const c of r){for(const r of c.fieldsUsed){s(e,r,(()=>new Set)).add(c);const o=a.get(r);[o?.valueExpressionExecutor,o?.editableExpressionExecutor,i?o?.group?.visibilityExpressionExecutor:null,i?o?.visibilityExpressionExecutor:null].filter((e=>null!=e&&e!==c)).forEach((e=>{l.get(e).push(c);s(t,e,(()=>new Set)).add(o)}))}if(c.geometryUsed){s(e,n,(()=>new Set)).add(c)}}return l}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:o,_latestFieldValues:a}=this;for(const r of e)u(r,t,s);for(const[n,{resolver:l,dependencyPromises:c}]of t){Promise.all(c).then((async()=>{const[e,t]=this._makeContext(a);return n.executeAsync(e,t)})).then((()=>{if(o.has(n))for(const e of o.get(n))this._latestFieldValues[e.name]=e.value;l.resolve()}),(e=>{!e||r(e)||p(e)||n.markStale(),l.reject(e)}))}const i=(await Promise.allSettled(Array.from(t.values(),(({resolver:e})=>e.promise)))).filter((e=>"rejected"===e.status&&!(r(e.reason)||p(e.reason))));if(i.length>0)throw new AggregateError(i,"One or more expression executions failed")}_makeContext(e){const[t,s]=this._baseContext,r=this.feature.clone();return r.attributes=e,[{...t,$feature:r},s]}};e([a()],c.prototype,"_baseContext",null),e([a()],c.prototype,"feature",null),e([a({constructOnly:!0})],c.prototype,"preserveFieldValuesWhenHidden",void 0),e([a()],c.prototype,"executors",void 0),e([a()],c.prototype,"fieldInputs",void 0),e([a()],c.prototype,"arcadeContextInfo",void 0),c=e([i(l)],c);const u=(e,t,s)=>{if(t.has(e))return;const r=o();t.set(e,{resolver:r,dependencyPromises:[]}),e.abort();const a=s.get(e);for(const o of a)u(o,t,s),t.get(o).dependencyPromises.push(r.promise)},p=e=>e&&"object"==typeof e&&"message"in e&&"Cancelled"===e.message;export{c as FormExpressionsManager};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{isAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";const n="#JSAPI_FORM_EXPRESSIONS_MANAGER_GEOMETRY",l="esri.widgets.FeatureForm.FormExpressionsManager";let c=class extends t{constructor(e){super(e),this._fieldReferencesLookup=new Map,this._fieldsAffectedLookup=new Map,this.preserveFieldValuesWhenHidden=!0,this._latestFieldValues={...e.feature.attributes}}initialize(){this._dependencyGraph=this._buildDependencyGraph()}destroy(){this.resetExecutors()}get _baseContext(){const{editType:e,layer:t,map:s,originalFeature:r,spatialReference:o,timeZone:a}=this.arcadeContextInfo,i="feature"===t?.type?t:"scene"===t?.type&&null!=t.associatedLayer?t.associatedLayer:void 0;return[{$originalfeature:r,$editcontext:{editType:e},$layer:i,$featureset:i,$datastore:t?.url,$map:s},{rawOutput:!0,spatialReference:o??void 0,timeZone:a}]}set feature(e){this._latestFieldValues={...e?.attributes},this._set("feature",e)}evaluateAll(){return this._evaluate(this.executors)}evaluateExpressions(e){return this._evaluate(e)}evaluateInvalidated(e){const{_fieldReferencesLookup:t,_latestFieldValues:s,feature:r}=this,o=new Set;for(const a of e)if(s[a]=r.getAttribute(a),t.has(a))for(const e of t.get(a))o.add(e);return this._evaluate([...o])}async evaluateInvalidatedByGeometry(){if(this._fieldReferencesLookup.has(n))return this._evaluate([...this._fieldReferencesLookup.get(n)])}resetExecutors(){for(const e of this.executors)e.reset()}_buildDependencyGraph(){const{_fieldReferencesLookup:e,_fieldsAffectedLookup:t,executors:r,preserveFieldValuesWhenHidden:o}=this,a=new Map(this.fieldInputs.map((e=>[e.name,e]))),i=!1===o,l=new Map(r.map((e=>[e,new Array])));for(const c of r){for(const r of c.fieldsUsed){s(e,r,(()=>new Set)).add(c);const o=a.get(r);[o?.valueExpressionExecutor,o?.editableExpressionExecutor,i?o?.group?.visibilityExpressionExecutor:null,i?o?.visibilityExpressionExecutor:null].filter((e=>null!=e&&e!==c)).forEach((e=>{l.get(e).push(c);s(t,e,(()=>new Set)).add(o)}))}if(c.geometryUsed){s(e,n,(()=>new Set)).add(c)}}return l}async _evaluate(e){const t=new Map,{_dependencyGraph:s,_fieldsAffectedLookup:o,_latestFieldValues:a}=this;for(const r of e)u(r,t,s);for(const[n,{resolver:l,dependencyPromises:c}]of t){Promise.all(c).then((async()=>{const[e,t]=this._makeContext(a);return n.executeAsync(e,t)})).then((()=>{if(o.has(n))for(const e of o.get(n))this._latestFieldValues[e.name]=e.value;l.resolve()}),(e=>{!e||r(e)||p(e)||n.markStale(),l.reject(e)}))}const i=(await Promise.allSettled(Array.from(t.values(),(({resolver:e})=>e.promise)))).filter((e=>"rejected"===e.status&&!(r(e.reason)||p(e.reason))));if(i.length>0)throw new AggregateError(i,"One or more expression executions failed")}_makeContext(e){const[t,s]=this._baseContext,r=this.feature.clone();return r.attributes=e,[{...t,$feature:r},s]}};e([a()],c.prototype,"_baseContext",null),e([a()],c.prototype,"feature",null),e([a({constructOnly:!0})],c.prototype,"preserveFieldValuesWhenHidden",void 0),e([a()],c.prototype,"executors",void 0),e([a()],c.prototype,"fieldInputs",void 0),e([a()],c.prototype,"arcadeContextInfo",void 0),c=e([i(l)],c);const u=(e,t,s)=>{if(t.has(e))return;const r=o();t.set(e,{resolver:r,dependencyPromises:[]}),e.abort();const a=s.get(e);for(const o of a)u(o,t,s),t.get(o).dependencyPromises.push(r.promise)},p=e=>e&&"object"==typeof e&&"message"in e&&"Cancelled"===e.message;export{c as FormExpressionsManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as y,numberingSystem as F,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as w,getISOFieldValueFromDateComponents as O,getUnixFieldValueFromDateComponents as k}from"./support/dateUtils.js";import{globalCss as I}from"./support/globalCss.js";import{Heading as M,incrementHeadingLevel as D}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as V}from"./support/decorators/messageBundle.js";import{vmEvent as x}from"./support/decorators/vmEvent.js";import{tsx as N}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";const T="data-field-name",j="esri.widgets.FeatureForm",S=o.getLogger(j);let E=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return N("div",{class:this.classes(p.base,I.widget,I.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return N("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&N(M,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&N("p",{class:p.description,key:"description"},e.formDescription);return N("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:N("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return N("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?D(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?L(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[N("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?N("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?N("label",{...s},r):N("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n,updating:a}=e,s=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),s):this._renderComboBoxComponent(e,t,s):this._renderSwitchComponent(e,s)}if("datetime-picker"===o||"date"===t)return this._renderDateComponents(e,s);const r="number"===t?this._renderNumberComponent(e,s):this._renderStringComponent(e,s);return a?N("div",{class:p.fieldInputWrapper,key:`${s.key}-input-updating-wrapper`},r,N("div",{class:p.fieldInputLoader},N("calcite-progress",{type:"indeterminate"}))):r}_renderStringComponent(e,t){return N("calcite-input",{...t,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return N("calcite-input-number",{...t,integer:l(e.field),type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldCompnents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,y(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,max:a,min:s,key:r,readOnly:l}=t;return N("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"date","data-field-name":t[T],key:`${r}-date-input`,max:null!=a?`${a}`:void 0,min:null!=s?`${s}`:void 0,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:l,value:null!=o?`${o}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return N("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[T],key:`${a}-time-input`,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,l=null!=n?`${n}`:void 0,{dateAsString:d,time:c,timeZoneOffset:u}=R(l),m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,numberingSystem:F,overlayPositioning:"fixed",readOnly:r,[T]:i,onfocus:this._onComponentFocus};return N("div",{class:p.dateInputContainer,key:`${s}-date-time-container`},N("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${s}-date-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:d??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),N("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${s}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:c??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?N("calcite-input-time-zone",{...m,class:a,"data-date-part":"timeZone",key:`${s}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:u??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldCompnents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,max:r,min:l,key:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:F,overlayPositioning:"fixed",readOnly:c,[T]:o,onfocus:this._onComponentFocus},{dateAsString:h,time:v}=w(a,u),_=null!=r?w(r,u):void 0,g=null!=l?w(l,u):void 0;return N("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},N("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${d}-date-input`,max:_?.dateAsString??void 0,min:g?.dateAsString??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?N("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${d}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:v??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return N("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>N("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(N("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[N("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),N("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(N("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return N("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return N("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[T],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return N("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return N("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},N("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?N("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return N("calcite-list-item",{description:L(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},N("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return N("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return N("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},N("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),N("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return N("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},N("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return N("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},N("span",null,e.label),t?N("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return N("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=n?.label,s=L(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return N("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},N("div",{slot:"message"},s))}_renderNoRelatedRecordsNotice(){return N("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},N("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return N("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[T]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(T))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o}=t,n=this._dateComponentMap.get(o);if(!n)return;const a=this.viewModel.getValue(o);let s=null;s="date-only"===i||"time-only"===i?e.value:"timestamp-offset"===i?null!=e.value?O({dateComponent:n.date,timeComponent:n.time,timeZoneComponent:n.timeZone,oldValue:a}):null:null!=e.value?k({oldValue:a,dateComponent:n.date,timeComponent:n.time,timeZone:this.timeZone,max:t.range?.max,min:t.range?.min}):null,null!==s&&e.value?a!==s&&this._updateFieldValue(o,s):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:S.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],E.prototype,"_listObserverNode",void 0),e([s()],E.prototype,"_relatedRecordsEnabled",null),e([s()],E.prototype,"disabled",null),e([s()],E.prototype,"feature",null),e([s()],E.prototype,"formTemplate",null),e([s()],E.prototype,"groupDisplay",void 0),e([s()],E.prototype,"headingLevel",void 0),e([s()],E.prototype,"label",null),e([s()],E.prototype,"layer",null),e([s()],E.prototype,"map",null),e([s(),V("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"messages",void 0),e([s(),V("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([s(),V("esri/widgets/Feature/t9n/Feature")],E.prototype,"messagesFeature",void 0),e([s(),V("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],E.prototype,"messagesTemplates",void 0),e([s()],E.prototype,"relatedRecordCallbacks",null),e([s()],E.prototype,"relationshipId",null),e([s()],E.prototype,"spatialReference",null),e([s()],E.prototype,"strict",null),e([s()],E.prototype,"timeZone",null),e([s()],E.prototype,"view",null),e([s(),x(["value-change","submit"])],E.prototype,"viewModel",void 0),E=e([r(j)],E);const U=E;export{U as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as y,numberingSystem as F,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as O,getISOFieldValueFromDateComponents as k,getUnixFieldValueFromDateComponents as I}from"./support/dateUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as D,incrementHeadingLevel as x}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as V}from"./support/decorators/messageBundle.js";import{vmEvent as N}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as T}from"../intl/substitute.js";const j="data-field-name",S="esri.widgets.FeatureForm",E=o.getLogger(S);let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(p.base,M.widget,M.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(D,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:p.description,key:"description"},e.formDescription);return L("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return L("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?x(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?T(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[L("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?L("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?L("label",{...s},r):L("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n,updating:a}=e,s=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),s):this._renderComboBoxComponent(e,t,s):this._renderSwitchComponent(e,s)}if("datetime-picker"===o||"date"===t)return this._renderDateComponents(e,s);const r="number"===t?this._renderNumberComponent(e,s):this._renderStringComponent(e,s);return a?L("div",{class:p.fieldInputWrapper,key:`${s.key}-input-updating-wrapper`},r,L("div",{class:p.fieldInputLoader},L("calcite-progress",{type:"indeterminate"}))):r}_renderStringComponent(e,t){return L("calcite-input",{...t,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("calcite-input-number",{...t,integer:l(e.field),type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldCompnents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,y(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,max:a,min:s,key:r,readOnly:l}=t;return L("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"date","data-field-name":t[j],key:`${r}-date-input`,max:null!=a?`${a}`:void 0,min:null!=s?`${s}`:void 0,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:l,value:null!=o?`${o}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return L("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[j],key:`${a}-time-input`,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,l=null!=n?`${n}`:void 0,{dateAsString:d,time:c,timeZoneOffset:u}=R(l),m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,numberingSystem:F,overlayPositioning:"fixed",readOnly:r,[j]:i,onfocus:this._onComponentFocus};return L("div",{class:p.dateInputContainer,key:`${s}-date-time-container`},L("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${s}-date-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:d??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),L("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${s}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:c??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?L("calcite-input-time-zone",{...m,class:a,"data-date-part":"timeZone",key:`${s}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:u??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldCompnents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,max:r,min:l,key:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:F,overlayPositioning:"fixed",readOnly:c,[j]:o,onfocus:this._onComponentFocus},{dateAsString:h,time:v}=w(a,u),_=null!=r?w(r,u):void 0,g=null!=l?w(l,u):void 0;return L("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},L("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${d}-date-input`,max:_?.dateAsString??void 0,min:g?.dateAsString??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?L("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${d}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:v??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return L("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),L("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(L("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[j],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return L("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},L("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return L("calcite-list-item",{description:T(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return L("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},L("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),L("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return L("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=T(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[j]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(j))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o}=t,n=this._dateComponentMap.get(o);if(!n)return;let a=this.viewModel.getValue(o),s=null;"date-only"===i?s=e.value:"time-only"===i?(a=O(a),s=O(e.value)):s="timestamp-offset"===i?null!=e.value?k({dateComponent:n.date,timeComponent:n.time,timeZoneComponent:n.timeZone,oldValue:a}):null:null!=e.value?I({oldValue:a,dateComponent:n.date,timeComponent:n.time,timeZone:this.timeZone,max:t.range?.max,min:t.range?.min}):null,null!==s&&e.value?a!==s&&this._updateFieldValue(o,s):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:E.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),V("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),V("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),V("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),V("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),N(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r(S)],U);const $=U;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as s,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import w from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as _}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";import{formatNumber as x}from"../intl/number.js";const R="selected-index",j=0,N="features-spinner";let k=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusFeatureMenuFlowItem=!1,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._focusRootFlowItem=!1,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new _,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new w,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:r,disabled:n,indicator:a}=e;return e.visible?C("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this._focusRootFlowItem=!0,this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1},this._displaySpinnerThrottled=n((()=>this._displaySpinner()),j),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),s((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),this._rootFlowItemNode?.blur()}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{container:e}=this,{active:t}=this.viewModel;if(t||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),!e)return;const i=e.querySelectorAll("calcite-flow-item"),s=i[i?.length-1];this.scheduleRender(),requestAnimationFrame((()=>s?.setFocus()))}next(){return this.viewModel.next()}open(e){this.removeHandles(R);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return C("div",{class:this.classes(m.base,M.widget,M.panel)},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?C("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:C("div",{class:m.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return C("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:A(e.pageText,{index:x(o+1),total:x(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return C("calcite-action-bar",{class:m.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},C("calcite-action-group",{scale:"s"},C("calcite-action",{appearance:"solid",class:m.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),C("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return C("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},C("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const o=i.sourceLayer??i.layer,s=t.get(o)??[];t.set(o,[...s,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?C("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>C("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){return e.visible?C("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,scale:"m",slot:"header-actions-end",text:e.title||"",title:e.title||""}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return C("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",onkeydown:this._onMainKeydown,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?C(b,{class:this.classes(m.featuresHeading,M.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),C("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r,pendingPromisesCount:n}=e;return t?C("calcite-flow-item",{afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!s,description:A(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?C("calcite-loader",{class:m.loader,inline:!0,key:"feature-menu-loader",label:o.loading,scale:"m",slot:"header-actions-end"}):null,C("div",{class:m.container},this._renderFeatureMenu()),C("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:m.featureMenuObserver}),C("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},o.back)):null}_renderContentContainer(){const{content:e}=this.viewModel;return C("calcite-flow",{key:e??"content"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:o}=e;return o&&i?A(o,i):o??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=this._getActionImage(e),s={[m.icon]:!!t,[m.actionImage]:!!o};return t&&(s[t]=!0),o||t?C("span",{"aria-hidden":"true",class:this.classes(m.icon,s),key:"icon",styles:o?this._getIconStyles(o):{}}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?C("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},C("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?C("div",{class:h.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=f(i);this.open({features:[t],location:null!=o?o:void 0})}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFeatureMenuFlowItem&&(this._focusFeatureMenuFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuFlowItem=!0}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===s?A(n,{messages:t}):"remove-selected-feature"===s?A(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?A(n,{messages:t}):e.title;return a&&r?A(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,R)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this.featureMenuOpen=!1,this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:N,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,N),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],k.prototype,"_focusFeatureMenuFlowItem",void 0),e([a()],k.prototype,"_relatedRecordsFlowItems",void 0),e([a()],k.prototype,"_focusRootFlowItem",void 0),e([a()],k.prototype,"_hideActionText",null),e([a()],k.prototype,"_featureNavigationVisible",null),e([a()],k.prototype,"_isCollapsed",null),e([a()],k.prototype,"_collapseEnabled",null),e([a()],k.prototype,"collapsed",void 0),e([a()],k.prototype,"content",null),e([a()],k.prototype,"icon",void 0),e([a()],k.prototype,"featureMenuOpen",null),e([a()],k.prototype,"featureNavigationTop",void 0),e([a()],k.prototype,"features",null),e([a({type:_})],k.prototype,"headerActions",void 0),e([a()],k.prototype,"headingLevel",void 0),e([a()],k.prototype,"location",null),e([a()],k.prototype,"label",null),e([a(),y("esri/widgets/Features/t9n/Features")],k.prototype,"messages",void 0),e([a(),y("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([a()],k.prototype,"promises",null),e([a()],k.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],k.prototype,"selectedFeature",null),e([a()],k.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],k.prototype,"selectedFeatureWidget",null),e([a()],k.prototype,"title",null),e([a()],k.prototype,"updateLocationEnabled",null),e([a()],k.prototype,"view",null),e([a({type:g}),I(["triggerAction","trigger-action"])],k.prototype,"viewModel",void 0),e([a({type:w,nonNullable:!0})],k.prototype,"visibleElements",void 0),e([a()],k.prototype,"visible",null),k=e([l("esri.widgets.Features")],k);const E=k;export{E as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as s,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import w from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as _}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";import{formatNumber as x}from"../intl/number.js";const R="selected-index",j=0,N="features-spinner";let k=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusFeatureMenuFlowItem=!1,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._focusRootFlowItem=!1,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new _,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new w,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:r,disabled:n,indicator:a}=e;return e.visible?C("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this._focusRootFlowItem=!0,this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1},this._displaySpinnerThrottled=n((()=>this._displaySpinner()),j),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),s((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),this._rootFlowItemNode?.blur()}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{container:e}=this,{active:t}=this.viewModel;if(t||o.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),!e)return;const i=e.querySelectorAll("calcite-flow-item"),s=i[i?.length-1];this.scheduleRender(),requestAnimationFrame((()=>s?.setFocus()))}next(){return this.viewModel.next()}open(e){this.removeHandles(R);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return C("div",{class:this.classes(m.base,M.widget,M.panel)},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?C("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:C("div",{class:m.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return C("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:A(e.pageText,{index:x(o+1),total:x(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return C("calcite-action-bar",{class:m.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},C("calcite-action-group",{scale:"s"},C("calcite-action",{appearance:"solid",class:m.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),C("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return C("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},C("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const o=i.sourceLayer??i.layer,s=t.get(o)??[];t.set(o,[...s,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?C("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>C("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){return e.visible?C("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,scale:"m",slot:"header-actions-end",text:e.title||"",title:e.title||""}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return C("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",onkeydown:this._onMainKeydown,onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?C(b,{class:this.classes(m.featuresHeading,M.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:C("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r,pendingPromisesCount:n}=e;return t?C("calcite-flow-item",{afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!s,description:A(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?C("calcite-loader",{class:m.loader,inline:!0,key:"feature-menu-loader",label:o.loading,scale:"m",slot:"header-actions-end"}):null,C("div",{class:m.container},this._renderFeatureMenu()),C("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:m.featureMenuObserver}),C("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},o.back)):null}_renderContentContainer(){return C("calcite-flow",{key:"content-container"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:o}=e;return o&&i?A(o,i):o??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=this._getActionImage(e),s={[m.icon]:!!t,[m.actionImage]:!!o};return t&&(s[t]=!0),o||t?C("span",{"aria-hidden":"true",class:this.classes(m.icon,s),key:"icon",styles:o?this._getIconStyles(o):{}}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?C("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},C("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?C("div",{class:h.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=f(i);this.open({features:[t],location:null!=o?o:void 0})}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFeatureMenuFlowItem&&(this._focusFeatureMenuFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuFlowItem=!0}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===s?A(n,{messages:t}):"remove-selected-feature"===s?A(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?A(n,{messages:t}):e.title;return a&&r?A(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,R)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this.featureMenuOpen=!1,this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:N,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,N),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],k.prototype,"_focusFeatureMenuFlowItem",void 0),e([a()],k.prototype,"_relatedRecordsFlowItems",void 0),e([a()],k.prototype,"_focusRootFlowItem",void 0),e([a()],k.prototype,"_hideActionText",null),e([a()],k.prototype,"_featureNavigationVisible",null),e([a()],k.prototype,"_isCollapsed",null),e([a()],k.prototype,"_collapseEnabled",null),e([a()],k.prototype,"collapsed",void 0),e([a()],k.prototype,"content",null),e([a()],k.prototype,"icon",void 0),e([a()],k.prototype,"featureMenuOpen",null),e([a()],k.prototype,"featureNavigationTop",void 0),e([a()],k.prototype,"features",null),e([a({type:_})],k.prototype,"headerActions",void 0),e([a()],k.prototype,"headingLevel",void 0),e([a()],k.prototype,"location",null),e([a()],k.prototype,"label",null),e([a(),y("esri/widgets/Features/t9n/Features")],k.prototype,"messages",void 0),e([a(),y("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([a()],k.prototype,"promises",null),e([a()],k.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],k.prototype,"selectedFeature",null),e([a()],k.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],k.prototype,"selectedFeatureWidget",null),e([a()],k.prototype,"title",null),e([a()],k.prototype,"updateLocationEnabled",null),e([a()],k.prototype,"view",null),e([a({type:g}),I(["triggerAction","trigger-action"])],k.prototype,"viewModel",void 0),e([a({type:w,nonNullable:!0})],k.prototype,"visibleElements",void 0),e([a()],k.prototype,"visible",null),k=e([l("esri.widgets.Features")],k);const E=k;export{E as default};
@@ -0,0 +1,4 @@
1
+ import "../../interfaces";
2
+
3
+ import OrientedImageryViewerViewModel = __esri.OrientedImageryViewerViewModel;
4
+ export default OrientedImageryViewerViewModel;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import s from"../../core/Evented.js";import{isSerializable as o}from"../../core/JSONSupport.js";import a from"../../core/Logger.js";import{clamp as n}from"../../core/mathUtils.js";import{destroyMaybe as l}from"../../core/maybe.js";import{once as h,on as c,watch as g,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as m}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{ensureType as p}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Extent.js";import{geographicToWebMercator as v}from"../../geometry/support/webMercatorUtils.js";import f from"../../layers/GraphicsLayer.js";import P from"../../layers/ImageryTileLayer.js";import{searchImages as C}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as I}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as b,computePolygonForInspection as w,resizePolygon as F,checkIfPolygonContainsSelectedPoint as M}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as S,transformPoints as x}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as V}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import j from"../../layers/support/RasterFunction.js";import{convolutionKernel as A}from"../../layers/support/rasterFunctionConstants.js";import O from"../../layers/support/rasterDatasets/RasterFactory.js";import G from"../../rest/support/AttachmentQuery.js";import D from"../../views/MapView.js";import{getResolutionToScaleFactor as R}from"../../views/2d/viewpointUtils.js";import{projectWithEngineOrService as L}from"../../views/support/projectionUtils.js";import{sectorsInOrder as E,sectorsRadii as U}from"./constants.js";import{activePolygonSymbol as T,polygonSymbol as N,activeSourcePointSymbol as k,sourcePointSymbol as H,crossSymbol as J,diamondSymbol as z}from"./symbols.js";import{isTifOrMrf as $,isSceneView as q,isGraphic as B}from"./utils.js";import W from"../../geometry/Polygon.js";import Z from"../../geometry/SpatialReference.js";import Q from"../../geometry/Point.js";const K={click:"view-click",view:"view",viewLayers:"view-layers",mapLayers:"map-layers",layerViews:"layer-views",layerListMode:"layer-list-mode",children:"children",registerLayerSelection:"register-layer-selection",plotPointOnGround:"plot-point-on-ground"},X=e=>/^https?:/i.test(e),Y=e=>"FA"===e;let ee=class extends s.EventedAccessor{constructor(e){super(e),this.activeLayer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=new i,this.coveragePolygons=new i,this.currentCoverageVisible=!0,this.disabled=!1,this.displayMessage=null,this.pointSources=new i,this.previousFeatureAngle=0,this.selectedFeature=null,this.selectedFeatureAngle=0,this.selectedPoint=null,this.features=new i,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorSelectedFeature=null,this._additionalCoveragePolygons=new i,this._additionalFeatureGraphics=new i,this._currentCoveragePolygon=null,this._currentImage=null,this._fetchFeaturesController=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._overlays=null,this._plotPolygons=!1,this._initialPreviousCoveragePolygon=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this._panConstraint=null,this._scaleConstraint=null,this._suitabilities=null,this._transformController=new AbortController,this._updateCoverageController=null,this.handleSectorClick=this.handleSectorClick.bind(this),this.loadViewer=this.loadViewer.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){h((()=>this.view?.ready)).then((()=>{this._overlays=new f({listMode:"hide"}),this.view.map.layers.add(this._overlays)})),this.addHandles([c((()=>this.view),"click",(e=>{if(this.view.ready&&!this.disabled&&this.active&&(e.stopPropagation(),e.preventDefault(),"mouse"!==e.pointerType||0===e.button))if(this.mapImageConversionToolState)this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.selectedFeature,selectedLocation:e.mapPoint,options:{signal:this._transformController?.signal}});else{const{mapPoint:t}=e;this.displayMessage=null,this.selectedPoint=t.spatialReference.isGeographic?v(t):t.clone(),this.features.removeAll(),this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon=l(this._currentCoveragePolygon),this._overlays?.removeAll(),this.selectedFeature=null,this._fetchFeaturesWithController(e)}})),g((()=>this.view?.map?.allLayers?.length),(e=>{e&&this._overlays&&this.view.map.layers.reorder(this._overlays,e-1)}),{initial:!0}),g((()=>this.activeLayer?.visible??!1),(e=>{this._overlays&&(this._overlays.visible=e)}))],K.view)}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this._additionalCoveragePolygons.destroy(),this._additionalFeatureGraphics.destroy(),this._currentImage=l(this._currentImage),this._imageViewer=l(this._imageViewer),this._initialCurrentCoveragePolygon=l(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=l(this._currentCoveragePolygon),this._crossSymbol=l(this._crossSymbol),this._referencePointOnGround=l(this._referencePointOnGround),this._referencePointOnImage=l(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays=l(this._overlays)}get active(){return!0===this.view?.map?.allLayers.some((e=>"oriented-imagery"===e.type&&e.loaded))}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",n(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",n(e,-10,10))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return $(this.selectedFeature?.attributes.imagePath.trim())}get imageLoaded(){return this._currentImage?.loaded??!1}get updating(){return"loading"===this._currentImage?.loadStatus||!!this._fetchFeaturesController}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",n(e,0,1))}get sectorData(){const{_sectorData:e}=this;if(e)return E.map((t=>e[t]))}get state(){const{active:e,activeLayer:t}=this;return e||t?this._currentImage?.loadStatus?`image-${this._currentImage.loadStatus}`:"ready":"disabled"}get thumbnails(){const{features:e}=this;return e?new i(e.map((({attributes:{imagePath:e,objectId:t}})=>{const r=e.trim();return $(r)?{url:r,objectId:t}:null})).filter(r)):null}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[E[e]];t?.length&&this._updateSelectedFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateSelectedFeature(i.at(r))}loadViewer(e){const t=new Map,r={wkid:0};this._imageViewer=new D({container:e,map:t,spatialReferance:r,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),h((()=>!0===this._imageViewer?.stationary)).then((()=>{this.setMessage("onLoadMessage","info")})),this._imageViewer.addHandles([this._imageViewer.on("click",(async e=>{if(0===e.button&&this._currentImage&&this.mapImageConversionToolState&&this._currentImage?.fullExtent){const{xmin:t,xmax:r,ymin:i,ymax:s}=this._currentImage.fullExtent,{x:o,y:a}=e.mapPoint;if(t>o||r<o||s<a||i>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await V([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}})),g((()=>[this._imageViewer?.viewpoint,this._initialCurrentCoveragePolygon]),((e,t)=>{e?.[1]!==t?.[1]&&(this._initialPreviousCoveragePolygon=this._plotPolygons?null:t?.[1]),this._imageViewer?.viewpoint&&this._initialCurrentCoveragePolygon&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())})),g((()=>this.selectedFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),u),g((()=>this.selectedFeature),(async()=>{const{selectedFeature:e,selectedPoint:t}=this;if(!e&&this._currentImage&&(this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage=l(this._currentImage)),e&&t){this._initialCurrentCoverageUpdate=!0,this._updatePointsAndPolygons(),this._fetchFeaturesController??=new AbortController;const{signal:t}=this._fetchFeaturesController;await this.loadImage(e,{signal:t}).finally((()=>{this._fetchFeaturesController=null}))}}))])}resetImage(){this._currentImage=l(this._currentImage),this.setMessage("onLoadMessage","info"),this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const r=await C(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){const e=a.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while finding best image",r)}}setAdditionalCameraLocationsVisibility(e){this._additionalFeatureGraphics.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this._additionalCoveragePolygons.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=e),this._selectedFeatureGraphic&&(this._selectedFeatureGraphic.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){const{screenPoint:r}=e,i=this.activeLayer;if(i){const e={include:i},s=await this.view.hitTest(r,e);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:r}).finally((()=>{this._fetchFeaturesController=null}))}catch(i){const e=a.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,features:t}=this;if(!e||!t)return void(this._sectorData=null);this._sectorData={};for(const a of E)this._sectorData[a]=new i;const r=e.map(((e,t)=>({...e,featureIndex:t})));r.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const s=r.map((({distance:e})=>e)),o=Math.max(...s);r.forEach((e=>{const{distance:r,angle:i,featureIndex:s}=e;let a="FAR";const n=r/o*U[2];n<=U[0]?a="NEAR":n<=U[1]&&(a="");let l="NORTH";if(Math.abs(i)>=135?l="WEST":i<-45&&i>-135?l="SOUTH":i<=45&&(l="EAST"),!this._sectorData)return;const h=U[3]+n*Math.sin(i*Math.PI/180),c=U[3]+n*Math.cos(i*Math.PI/180);let g;const u=t.at(s),m=u===this.selectedFeature,d=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;if(m&&d)g=-90;else{const e=h-U[3],t=c-U[3],r=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(r)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),g=i}const p=""===a?l:`${a}_${l}`;m&&(g===this.selectedFeatureAngle?this.previousFeatureAngle=g:this.selectedFeatureAngle=g,this.navigatorSelectedFeature=d?null:{x:h,y:c,direction:l});const y=this._sectorData[p];y.add({angle:i,featureIndex:s,x:h,y:c,objectID:u.attributes.objectId,sector:p,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t){const{selectedPoint:r}=this;if(!r)return;if(!e)return;const i=e;if(!i)return;const{features:s}=i;if(!s.length)return this.setMessage("noImageError","error"),void(this.selectedFeature=null);const a=new Array;this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll(),s.forEach((e=>{let t;const{polygon:i,frustum:s}=b(e);if(t=i,e.attributes.isInspection&&(t=w(e.attributes)),e.layer.coveragePercent&&(t=F(t,e.layer.coveragePercent)),M(t,r)){a.push(e);const r=t.toJSON(),i=s?.toJSON(),{attributes:n}=e,{cameraHeight:l,cameraHeading:h,location:c,objectId:g}=n,u=o(c)?c.toJSON():c;r.imageID=u.imageID=g,i&&(i.imageID=g),u.z=l,this.pointSources?.push(u),this.coveragePolygons?.push(h>0?r:void 0),this.coverageFrustums?.push(h>0?i:void 0)}}));const n=this.coveragePolygons?.getItemAt(0);if(!a.length)return void this.setMessage("noImageError","error");if(a[0].attributes.elevationSource&&!r.z&&n){const e=await S([r],{feature:a[0],currentCoveragePolygon:new W(n),options:t});if(e[0]){const t=e[0];r.elevation=t.z}}this._suitabilities=I({features:a,selectedPoint:r,camera:q(this.view)?this.view.camera:null,currentImage:this.selectedFeature}),this._suitabilities?.sort(((e,t)=>e.suitability-t.suitability));const l=this._suitabilities?.map((e=>e.feature)),h=l[0];this._updateFeatures(l),this.selectedFeature=h,this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0,this._plotPolygons=!0}async _processHitTestResults(e,t,r){const{screenPoint:i,results:s}=t,o=this.view.toMap(i),a=s[0],n={layerInstanceOrURL:e,point:o,queryParams:{maximumDistance:e.maximumDistance,objectIds:this.shouldShowSelectedImage?[a.graphic.attributes.id]:void 0},queryFeatures:null};await this.searchBestImage(n,r)}_updateFeatures(e){e.length&&(this.features.removeAll(),this.features.addMany(e))}_updatePointsAndPolygons(){const{coveragePolygons:e,pointSources:r,selectedFeature:i,currentCoverageVisible:s,isAdditionalCoverageVisible:o,isAdditionalPointSourcesVisible:a}=this;if(e&&r&&i){this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const r of e)r?.imageID===i?.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:T,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:N,visible:o}));for(const e of r)e.imageID===i?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:k,visible:s}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:H,visible:a}))}}_updateSelectedFeature(e){if(!e)return;this.selectedFeature=this.features?.at(e.featureIndex);const t=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-U[3],i=e.y-U[3],s=i/Math.sqrt(t**2+i**2);let o=180*Math.acos(s)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(o*=-1),r=o}r===this.selectedFeatureAngle?this.previousFeatureAngle=r:this.selectedFeatureAngle=r,this.navigatorSelectedFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate)if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&this._currentCoveragePolygon.destroy(),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e),this.view){this._plotPolygons=!1;const e=this.selectedPoint?new t({geometry:this.selectedPoint.clone(),symbol:J,attributes:{imageID:this.selectedFeature?.attributes.objectId}}):null;this._overlays?.graphics.addMany([...this._additionalCoveragePolygons,...this._additionalFeatureGraphics,this._currentCoveragePolygon,this._selectedFeatureGraphic,e].filter(B))}else if(this._plotPolygons){this._plotPolygons=!1;const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}else{const e={currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),additionalPoint:this.pointSources.find((e=>e?.imageID===this._initialPreviousCoveragePolygon?.attributes.imageID)),currentPolygon:this._currentCoveragePolygon,additionalPolygon:this._initialPreviousCoveragePolygon};this.emit("update-selected-feature",{data:e})}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&(this._currentCoveragePolygon=e,this.emit("update-current-coverage",{graphic:e.toJSON()}))}async loadImage(e,t){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const{horizontalFieldOfView:r,isSpherical:i}=e.attributes;if(360===r||i)return void this.setMessage("unsupportedPanaromicImageryError","error");let s,o,n=e.attributes.imagePath;if(!X(n)&&!Y(n)){if(!this.localPort)return this.setMessage("noLocalPort","error"),void a.getLogger(this).error("oriented-imagery-viewer:missing-local-port","A value for local port is not set. Local port is needed to load local images.");n=`http://127.0.0.1:${this.localPort}/${n}`}this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const l={skipExtensions:["aux.xml","jgw"]};if(Y(n)){const r=new G({objectIds:[e.attributes.objectId]}),i=(await e.layer.queryAttachments(r,t))[`${e.attributes.objectId}`];if(!i[0]?.url)return void this.setMessage("noAttachment","error");if(s=i[0].contentType.split("/")[1]?.toUpperCase(),n=i[0]?.url,o=await O.open({ioConfig:l,url:n,datasetFormat:s,...t}).catch((e=>(this.setMessage("imageLoadError","error",e.message),null))),!o)return}this._currentImage=new P({ioConfig:l,url:n,raster:o,options:t}),this._imageViewer.map.layers.add(this._currentImage);try{const r=await this._currentImage.when();this._imageViewer.extent=r.fullExtent,r.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.rotation=(e.attributes.cameraRoll??0)+(e.attributes.imageRotation??0)),this._panConstraint&&this._imageViewer.constraints.customConstraints.remove(this._panConstraint),this._scaleConstraint&&this._imageViewer.constraints.customConstraints.remove(this._scaleConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:r,xmax:i,ymin:s,ymax:o}=this._currentImage.fullExtent,{extent:a,rotation:n}=this._imageViewer,l=n*Math.PI/180,h=Math.abs(Math.cos(l)*a.width+Math.sin(l)*a.height),c=Math.abs(Math.cos(l)*a.height+Math.sin(l)*a.width),{rasterInfo:g}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(r+Math.min(g.width,h)/2,e.targetGeometry.x),i-Math.min(g.width,h)/2),e.targetGeometry.y=Math.min(Math.max(s+Math.min(g.height,c)/2,e.targetGeometry.y),o-Math.min(g.height,c)/2),e},applyPanConstraint:e=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:t,xmax:r,ymin:i,ymax:s}=this._currentImage.fullExtent,{extent:o,rotation:a}=this._imageViewer,n=a*Math.PI/180,l=Math.abs(Math.cos(n)*o.width+Math.sin(n)*o.height),h=Math.abs(Math.cos(n)*o.height+Math.sin(n)*o.width),{rasterInfo:c}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(t+Math.min(c.width,l)/2,e.targetGeometry.x),r-Math.min(c.width,l)/2),e.targetGeometry.y=Math.min(Math.max(i+Math.min(c.height,h)/2,e.targetGeometry.y),s-Math.min(c.height,h)/2),e}},this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:r}=this._currentImage.rasterInfo,{width:i,height:s,rotation:o,zoom:a}=this._imageViewer,n=o*Math.PI/180,l=Math.abs(Math.cos(n)*t+Math.sin(n)*r),h=Math.abs(Math.cos(n)*r+Math.sin(n)*t);a<1&&(e.scale=Math.max(e.scale,R(this._imageViewer.spatialReference)*Math.max(l/i,h/s)/2**a))}return e}},this._imageViewer.constraints.customConstraints.addMany([this._panConstraint,this._scaleConstraint]),r.addHandles(g((()=>[this.brightness,this.contrast,this.sharpness]),(([e,t,i])=>{r.loaded&&(r.effect=`contrast(${10*(t+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(r,i))}),u)),await this.transformAndPlotSelectedLocation(t)}catch(h){a.getLogger(this).error("oriented-imagery-viewer:load-image",h),this.setMessage("imageLoadError","error",h.message)}}sharpenImage(e,t){const r=[0,-1*t,0,-1*t,5,-1*t,0,-1*t,0],i=new j({functionName:"Convolution",functionArguments:{type:A.userDefined,cols:3,rows:3,kernel:r,convolutionType:A.userDefined}});e.renderer=null,e.rasterFunction=i}async transformAndPlotSelectedLocation(e){const{_currentImage:r,selectedFeature:i,selectedPoint:s}=this;if(!s||!i||!r?.loaded)return;const{pixelSize:o}=r.rasterInfo,a=await x([s],{feature:i,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:e});if(!a.length)return;const n=a[0];if(!n)return;const l=p(_,await L(r.fullExtent,p(Z,this._imageViewer?.spatialReference),null,e?.signal));n.x=n.x*o.x+l.xmin,n.y=l.ymax-n.y*o.y,n.spatialReference=l.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:Q.fromJSON(n),symbol:J}),this._imageViewer?.graphics.add(this._crossSymbol)}async transformAndPlotReferencePointOnImage(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:r,selectedLocation:i,options:s}=e,{pixelSize:o,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await x([i],{feature:r,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:s});if(!l.length)return;let h=l[0];const c=await L(t.fullExtent,this._imageViewer.spatialReference,null,s?.signal);a?(h.x=h.x*o.x+c.xmin,h.y=c.ymax-h.y*o.y,h.spatialReference=c.spatialReference):h=n.forwardTransform(new Q(h)),this.plotReferencePointOnImage(h)}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:z}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}})}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",...o(e)?e.toJSON():e},symbol:z}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,r){this.displayMessage={key:e,type:t,data:r}}async updateCoverage(){const e=new AbortController,{signal:r}=e;this._updateCoverageController=e;const{_imageViewer:i}=this;if(this._currentImage?.loaded&&i){const{width:e,height:s}=this._currentImage.rasterInfo,{xmin:o,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,h=[[0,0],[Math.min(i.width,e),0],[Math.min(i.width,e),Math.min(i.height,s)],[0,Math.min(i.height,s)]].map((e=>i.toMap(m(e[0],e[1]))));h.forEach((e=>{e.x=o<=e.x&&e.x<=a?e.x:Math.abs(o-e.x)>Math.abs(a-e.x)?a:o,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const c=await V(h,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:r}});if(c&&!r.aborted){const e=[c.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const r=new W({hasZ:!0,rings:e,spatialReference:c[0].spatialReference});this.updateCurrentCoveragePolygon(new t({attributes:{imageID:this.selectedFeature?.attributes.objectId},geometry:r,symbol:T,visible:this.currentCoverageVisible}))}}}};e([d()],ee.prototype,"active",null),e([d()],ee.prototype,"activeLayer",void 0),e([d()],ee.prototype,"shouldShowSelectedImage",void 0),e([d({type:Number})],ee.prototype,"brightness",null),e([d({type:Number})],ee.prototype,"contrast",null),e([d()],ee.prototype,"coverageFrustums",void 0),e([d()],ee.prototype,"coveragePolygons",void 0),e([d()],ee.prototype,"currentCoverageVisible",void 0),e([d()],ee.prototype,"currentImageView",null),e([d()],ee.prototype,"disabled",void 0),e([d()],ee.prototype,"displayMessage",void 0),e([d()],ee.prototype,"pointSources",void 0),e([d()],ee.prototype,"previousFeatureAngle",void 0),e([d()],ee.prototype,"selectedFeature",void 0),e([d()],ee.prototype,"selectedFeatureAngle",void 0),e([d()],ee.prototype,"selectedPoint",void 0),e([d({readOnly:!0})],ee.prototype,"featureCount",null),e([d()],ee.prototype,"features",void 0),e([d()],ee.prototype,"imageGalleryEnabled",null),e([d()],ee.prototype,"imageLoaded",null),e([d()],ee.prototype,"isAdditionalCoverageVisible",void 0),e([d()],ee.prototype,"isAdditionalPointSourcesVisible",void 0),e([d({type:Number})],ee.prototype,"localPort",void 0),e([d()],ee.prototype,"mapImageConversionToolState",void 0),e([d()],ee.prototype,"navigatorSelectedFeature",void 0),e([d()],ee.prototype,"updating",null),e([d({type:Number})],ee.prototype,"sharpness",null),e([d()],ee.prototype,"sectorData",null),e([d()],ee.prototype,"state",null),e([d()],ee.prototype,"thumbnails",null),e([d()],ee.prototype,"view",null),e([d()],ee.prototype,"_additionalCoveragePolygons",void 0),e([d()],ee.prototype,"_additionalFeatureGraphics",void 0),e([d()],ee.prototype,"_currentCoveragePolygon",void 0),e([d()],ee.prototype,"_currentImage",void 0),e([d()],ee.prototype,"_fetchFeaturesController",void 0),e([d()],ee.prototype,"_imageViewer",void 0),e([d()],ee.prototype,"_initialCurrentCoveragePolygon",void 0),e([d()],ee.prototype,"_initialCurrentCoverageUpdate",void 0),e([d()],ee.prototype,"_overlays",void 0),e([d()],ee.prototype,"_plotPolygons",void 0),e([d()],ee.prototype,"_initialPreviousCoveragePolygon",void 0),e([d()],ee.prototype,"_referencePointOnGround",void 0),e([d()],ee.prototype,"_referencePointOnImage",void 0),e([d()],ee.prototype,"_selectedFeatureGraphic",void 0),e([d()],ee.prototype,"_sectorData",void 0),ee=e([y("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ee);const te=ee;export{te as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{isSerializable as a}from"../../core/JSONSupport.js";import n from"../../core/Logger.js";import{clamp as l}from"../../core/mathUtils.js";import{destroyMaybe as h}from"../../core/maybe.js";import{watch as c,once as g,initial as u}from"../../core/reactiveUtils.js";import{createScreenPoint as m}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{ensureType as p}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Extent.js";import{geographicToWebMercator as v}from"../../geometry/support/webMercatorUtils.js";import f from"../../layers/GraphicsLayer.js";import P from"../../layers/ImageryTileLayer.js";import{searchImages as C}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as I}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as b,computePolygonForInspection as w,resizePolygon as F,checkIfPolygonContainsSelectedPoint as M}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as S,transformPoints as x}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as V}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import j from"../../layers/support/RasterFunction.js";import{convolutionKernel as O}from"../../layers/support/rasterFunctionConstants.js";import A from"../../layers/support/rasterDatasets/RasterFactory.js";import G from"../../rest/support/AttachmentQuery.js";import D from"../../views/MapView.js";import{getResolutionToScaleFactor as R}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as L}from"../../views/input/InputManager.js";import{projectWithEngineOrService as E}from"../../views/support/projectionUtils.js";import{sectorsInOrder as T,sectorsRadii as U}from"./constants.js";import{activePolygonSymbol as k,polygonSymbol as N,activeSourcePointSymbol as H,sourcePointSymbol as J,crossSymbol as z,diamondSymbol as B}from"./symbols.js";import{isTifOrMrf as $,isSceneView as q,isGraphic as W}from"./utils.js";import Z from"../../geometry/Polygon.js";import Q from"../../geometry/SpatialReference.js";import K from"../../geometry/Point.js";const X={click:"view-click",imageClick:"image-click"},Y=e=>/^https?:/i.test(e),ee=e=>"FA"===e;let te=class extends s.EventedAccessor{constructor(e){super(e),this.layer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=new i,this.coveragePolygons=new i,this.currentCoverageVisible=!0,this.disabled=!1,this.displayMessage=null,this.pointSources=new i,this.previousFeatureAngle=0,this.selectedFeature=null,this.selectedFeatureAngle=0,this.selectedPoint=null,this.features=new i,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorSelectedFeature=null,this._additionalCoveragePolygons=new i,this._additionalFeatureGraphics=new i,this._currentCoveragePolygon=null,this._currentImage=null,this._fetchFeaturesController=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._overlays=new f({listMode:"hide",internal:!0}),this._plotPolygons=!1,this._initialPreviousCoveragePolygon=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this._panConstraint=null,this._scaleConstraint=null,this._suitabilities=null,this._transformController=new AbortController,this._updateCoverageController=null,this._imageClickHandler=async e=>{if(0===e.button&&this._currentImage&&this._currentImage?.fullExtent){const{xmin:t,xmax:r,ymin:i,ymax:o}=this._currentImage.fullExtent,{x:s,y:a}=e.mapPoint;if(t>s||r<s||o<a||i>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await V([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),this.loadBestImage(e.mapPoint))},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),this.plotMapPoint(e.mapPoint)},this.handleSectorClick=this.handleSectorClick.bind(this),this.loadViewer=this.loadViewer.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([c((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),u),c((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),u),c((()=>this.layer?.visible??!1),(e=>{this._overlays.visible=e}),u),c((()=>[this.state,this.mapImageConversionToolState]),(()=>{if(this.removeHandles(X.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,L.WIDGET),X.click)}),u),c((()=>this.mapImageConversionToolState),(()=>{this.removeHandles(X.imageClick),this.imageLoaded&&this.mapImageConversionToolState&&this.addHandles(this._imageViewer.on("click",this._imageClickHandler),X.imageClick)}))])}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this._additionalCoveragePolygons.destroy(),this._additionalFeatureGraphics.destroy(),this._currentImage=h(this._currentImage),this._imageViewer=h(this._imageViewer),this._initialCurrentCoveragePolygon=h(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=h(this._currentCoveragePolygon),this._crossSymbol=h(this._crossSymbol),this._referencePointOnGround=h(this._referencePointOnGround),this._referencePointOnImage=h(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return o(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(n.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",l(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",l(e,-10,10))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return $(this.selectedFeature?.attributes.imagePath.trim())}get imageLoaded(){return this._currentImage?.loaded??!1}get updating(){return"loading"===this._currentImage?.loadStatus||!!this._fetchFeaturesController}get referencePoint(){return this._referencePointOnGround?.geometry}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",l(e,0,1))}get sectorData(){const{_sectorData:e}=this;if(e)return T.map((t=>e[t]))}get state(){const{layer:e,view:t,_currentImage:r}=this;return this.disabled||!e||t&&!t.ready?"disabled":r?.loadStatus?`image-${r.loadStatus}`:"ready"}get thumbnails(){const{features:e}=this;return e?new i(e.map((({attributes:{imagePath:e,objectId:t}})=>{const r=e.trim();return $(r)?{url:r,objectId:t}:null})).filter(r)):null}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[T[e]];t?.length&&this._updateSelectedFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateSelectedFeature(i.at(r))}async loadBestImage(e){this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?v(e):e.clone(),this.features.removeAll(),this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon=h(this._currentCoveragePolygon),this._overlays?.removeAll(),this.selectedFeature=null,await this._fetchFeaturesWithController(e)}loadViewer(e){const t=new Map,r={wkid:0};this._imageViewer=new D({container:e,map:t,spatialReferance:r,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),g((()=>!0===this._imageViewer?.stationary)).then((()=>{this.setMessage("onLoadMessage","info")})),this._imageViewer.addHandles([c((()=>[this._imageViewer?.viewpoint,this._initialCurrentCoveragePolygon]),((e,t)=>{e?.[1]!==t?.[1]&&(this._initialPreviousCoveragePolygon=this._plotPolygons?null:t?.[1]),this._imageViewer?.viewpoint&&this._initialCurrentCoveragePolygon&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())})),c((()=>this.selectedFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),u),c((()=>this.selectedFeature),(async()=>{const{selectedFeature:e,selectedPoint:t}=this;if(!e&&this._currentImage&&(this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage=h(this._currentImage)),e&&t){this._initialCurrentCoverageUpdate=!0,this._updatePointsAndPolygons(),this._fetchFeaturesController??=new AbortController;const{signal:t}=this._fetchFeaturesController;await this.loadImage(e,{signal:t}).finally((()=>{this._fetchFeaturesController=null}))}}))])}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.selectedFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}resetImage(){this._currentImage=h(this._currentImage),this.setMessage("onLoadMessage","info"),this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const r=await C(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){const e=n.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while finding best image",r)}}setAdditionalCameraLocationsVisibility(e){this._additionalFeatureGraphics.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this._additionalCoveragePolygons.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=e),this._selectedFeatureGraphic&&(this._selectedFeatureGraphic.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){if(!this.view)return;const r=this.layer;if(r){const i={include:r},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,i);this._processHitTestResults(r,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:r}).finally((()=>{this._fetchFeaturesController=null}))}catch(i){const e=n.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,features:t}=this;if(!e||!t)return void(this._sectorData=null);this._sectorData={};for(const a of T)this._sectorData[a]=new i;const r=e.map(((e,t)=>({...e,featureIndex:t})));r.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const o=r.map((({distance:e})=>e)),s=Math.max(...o);r.forEach((e=>{const{distance:r,angle:i,featureIndex:o}=e;let a="FAR";const n=r/s*U[2];n<=U[0]?a="NEAR":n<=U[1]&&(a="");let l="NORTH";if(Math.abs(i)>=135?l="WEST":i<-45&&i>-135?l="SOUTH":i<=45&&(l="EAST"),!this._sectorData)return;const h=U[3]+n*Math.sin(i*Math.PI/180),c=U[3]+n*Math.cos(i*Math.PI/180);let g;const u=t.at(o),m=u===this.selectedFeature,d=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;if(m&&d)g=-90;else{const e=h-U[3],t=c-U[3],r=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(r)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),g=i}const p=""===a?l:`${a}_${l}`;m&&(g===this.selectedFeatureAngle?this.previousFeatureAngle=g:this.selectedFeatureAngle=g,this.navigatorSelectedFeature=d?null:{x:h,y:c,direction:l});const y=this._sectorData[p];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:u.attributes.objectId,sector:p,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t){const{selectedPoint:r}=this;if(!r)return;if(!e)return;const i=e;if(!i)return;const{features:o}=i;if(!o.length)return this.setMessage("noImageError","error"),void(this.selectedFeature=null);const s=new Array;this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll(),o.forEach((e=>{let t;const{polygon:i,frustum:o}=b(e);if(t=i,e.attributes.isInspection&&(t=w(e.attributes)),e.layer.coveragePercent&&(t=F(t,e.layer.coveragePercent)),M(t,r)){s.push(e);const r=t.toJSON(),i=o?.toJSON(),{attributes:n}=e,{cameraHeight:l,cameraHeading:h,location:c,objectId:g}=n,u=a(c)?c.toJSON():c;r.imageID=u.imageID=g,i&&(i.imageID=g),u.z=l,this.pointSources?.push(u),this.coveragePolygons?.push(h>0?r:void 0),this.coverageFrustums?.push(h>0?i:void 0)}}));const n=this.coveragePolygons?.getItemAt(0);if(!s.length)return void this.setMessage("noImageError","error");if(s[0].attributes.elevationSource&&!r.z&&n){const e=await S([r],{feature:s[0],currentCoveragePolygon:new Z(n),options:t});if(e[0]){const t=e[0];r.elevation=t.z}}this._suitabilities=I({features:s,selectedPoint:r,camera:q(this.view)?this.view.camera:null,currentImage:this.selectedFeature}),this._suitabilities?.sort(((e,t)=>e.suitability-t.suitability));const l=this._suitabilities?.map((e=>e.feature)),h=l[0];this._updateFeatures(l),this.selectedFeature=h,this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0,this._plotPolygons=!0}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a={layerInstanceOrURL:e,point:o?.mapPoint??this.view?.toMap(i),queryParams:{maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0},queryFeatures:null};await this.searchBestImage(a,r)}_updateFeatures(e){e.length&&(this.features.removeAll(),this.features.addMany(e))}_updatePointsAndPolygons(){const{coveragePolygons:e,pointSources:r,selectedFeature:i,currentCoverageVisible:o,isAdditionalCoverageVisible:s,isAdditionalPointSourcesVisible:a}=this;if(e&&r&&i){this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const r of e)r?.imageID===i?.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:k,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:N,visible:s}));for(const e of r)e.imageID===i?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:H,visible:o}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:J,visible:a}))}}_updateSelectedFeature(e){if(!e)return;this.selectedFeature=this.features?.at(e.featureIndex);const t=this.selectedFeature?.attributes.cameraPitch&&this.selectedFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-U[3],i=e.y-U[3],o=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(o)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),r=s}r===this.selectedFeatureAngle?this.previousFeatureAngle=r:this.selectedFeatureAngle=r,this.navigatorSelectedFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate)if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&this._currentCoveragePolygon.destroy(),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e),this.view){this._plotPolygons=!1;const e=this.selectedPoint?new t({geometry:this.selectedPoint.clone(),symbol:z,attributes:{imageID:this.selectedFeature?.attributes.objectId}}):null;this._overlays?.graphics.addMany([...this._additionalCoveragePolygons,...this._additionalFeatureGraphics,this._currentCoveragePolygon,this._selectedFeatureGraphic,e].filter(W))}else if(this._plotPolygons){this._plotPolygons=!1;const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}else{const e={currentPoint:this.pointSources.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId)),additionalPoint:this.pointSources.find((e=>e?.imageID===this._initialPreviousCoveragePolygon?.attributes.imageID)),currentPolygon:this._currentCoveragePolygon,additionalPolygon:this._initialPreviousCoveragePolygon};this.emit("update-selected-feature",{data:e})}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&(this._currentCoveragePolygon=e,this.emit("update-current-coverage",{graphic:e.toJSON()}))}async loadImage(e,t){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const{horizontalFieldOfView:r,isSpherical:i}=e.attributes;if(360===r||i)return void this.setMessage("unsupportedPanaromicImageryError","error");let o,s,a=e.attributes.imagePath;if(!Y(a)&&!ee(a)){if(!this.localPort)return this.setMessage("noLocalPort","error"),void n.getLogger(this).error("oriented-imagery-viewer:missing-local-port","A value for local port is not set. Local port is needed to load local images.");a=`http://127.0.0.1:${this.localPort}/${a}`}this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const l={skipExtensions:["aux.xml","jgw"]};if(ee(a)){const r=new G({objectIds:[e.attributes.objectId]}),i=(await e.layer.queryAttachments(r,t))[`${e.attributes.objectId}`];if(!i[0]?.url)return void this.setMessage("noAttachment","error");if(o=i[0].contentType.split("/")[1]?.toUpperCase(),a=i[0]?.url,s=await A.open({ioConfig:l,url:a,datasetFormat:o,...t}).catch((e=>(this.setMessage("imageLoadError","error",e.message),null))),!s)return}this._currentImage=new P({ioConfig:l,url:a,raster:s,options:t}),this._imageViewer.map.layers.add(this._currentImage);try{const r=await this._currentImage.when();this._imageViewer.extent=r.fullExtent,r.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.rotation=(e.attributes.cameraRoll??0)+(e.attributes.imageRotation??0)),this._panConstraint&&this._imageViewer.constraints.customConstraints.remove(this._panConstraint),this._scaleConstraint&&this._imageViewer.constraints.customConstraints.remove(this._scaleConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:r,xmax:i,ymin:o,ymax:s}=this._currentImage.fullExtent,{extent:a,rotation:n}=this._imageViewer,l=n*Math.PI/180,h=Math.abs(Math.cos(l)*a.width+Math.sin(l)*a.height),c=Math.abs(Math.cos(l)*a.height+Math.sin(l)*a.width),{rasterInfo:g}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(r+Math.min(g.width,h)/2,e.targetGeometry.x),i-Math.min(g.width,h)/2),e.targetGeometry.y=Math.min(Math.max(o+Math.min(g.height,c)/2,e.targetGeometry.y),s-Math.min(g.height,c)/2),e},applyPanConstraint:e=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:t,xmax:r,ymin:i,ymax:o}=this._currentImage.fullExtent,{extent:s,rotation:a}=this._imageViewer,n=a*Math.PI/180,l=Math.abs(Math.cos(n)*s.width+Math.sin(n)*s.height),h=Math.abs(Math.cos(n)*s.height+Math.sin(n)*s.width),{rasterInfo:c}=this._currentImage;return e.targetGeometry.x=Math.min(Math.max(t+Math.min(c.width,l)/2,e.targetGeometry.x),r-Math.min(c.width,l)/2),e.targetGeometry.y=Math.min(Math.max(i+Math.min(c.height,h)/2,e.targetGeometry.y),o-Math.min(c.height,h)/2),e}},this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:r}=this._currentImage.rasterInfo,{width:i,height:o,rotation:s,zoom:a}=this._imageViewer,n=s*Math.PI/180,l=Math.abs(Math.cos(n)*t+Math.sin(n)*r),h=Math.abs(Math.cos(n)*r+Math.sin(n)*t);a<1&&(e.scale=Math.max(e.scale,R(this._imageViewer.spatialReference)*Math.max(l/i,h/o)/2**a))}return e}},this._imageViewer.constraints.customConstraints.addMany([this._panConstraint,this._scaleConstraint]),r.addHandles(c((()=>[this.brightness,this.contrast,this.sharpness]),(([e,t,i])=>{r.loaded&&(r.effect=`contrast(${10*(t+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(r,i))}),u)),await this.transformAndPlotSelectedLocation(t)}catch(h){n.getLogger(this).error("oriented-imagery-viewer:load-image",h),this.setMessage("imageLoadError","error",h.message)}}sharpenImage(e,t){const r=[0,-1*t,0,-1*t,5,-1*t,0,-1*t,0],i=new j({functionName:"Convolution",functionArguments:{type:O.userDefined,cols:3,rows:3,kernel:r,convolutionType:O.userDefined}});e.renderer=null,e.rasterFunction=i}async transformAndPlotSelectedLocation(e){const{_currentImage:r,selectedFeature:i,selectedPoint:o}=this;if(!o||!i||!r?.loaded)return;const{pixelSize:s}=r.rasterInfo,a=await x([o],{feature:i,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:e});if(!a.length)return;const n=a[0];if(!n)return;const l=p(_,await E(r.fullExtent,p(Q,this._imageViewer?.spatialReference),null,e?.signal));n.x=n.x*s.x+l.xmin,n.y=l.ymax-n.y*s.y,n.spatialReference=l.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:K.fromJSON(n),symbol:z}),this._imageViewer?.graphics.add(this._crossSymbol)}async transformAndPlotReferencePointOnImage(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:r,selectedLocation:i,options:o}=e,{pixelSize:s,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await x([i],{feature:r,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:o});if(!l.length)return;let h=l[0];const c=await E(t.fullExtent,this._imageViewer.spatialReference,null,o?.signal);return a?(h.x=h.x*s.x+c.xmin,h.y=c.ymax-h.y*s.y,h.spatialReference=c.spatialReference):h=n.forwardTransform(new K(h)),this.plotReferencePointOnImage(h),{x:h.x,y:h.y}}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:B}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}})}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",...a(e)?e.toJSON():e},symbol:B}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,r){this.displayMessage={key:e,type:t,data:r}}async updateCoverage(){const e=new AbortController,{signal:r}=e;this._updateCoverageController=e;const{_imageViewer:i}=this;if(this._currentImage?.loaded&&i){const{width:e,height:o}=this._currentImage.rasterInfo,{xmin:s,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,h=[[0,0],[Math.min(i.width,e),0],[Math.min(i.width,e),Math.min(i.height,o)],[0,Math.min(i.height,o)]].map((e=>i.toMap(m(e[0],e[1]))));h.forEach((e=>{e.x=s<=e.x&&e.x<=a?e.x:Math.abs(s-e.x)>Math.abs(a-e.x)?a:s,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const c=await V(h,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:r}});if(c&&!r.aborted){const e=[c.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const r=new Z({hasZ:!0,rings:e,spatialReference:c[0].spatialReference});this.updateCurrentCoveragePolygon(new t({attributes:{imageID:this.selectedFeature?.attributes.objectId},geometry:r,symbol:k,visible:this.currentCoverageVisible}))}}}};e([d()],te.prototype,"activeLayer",null),e([d()],te.prototype,"layer",void 0),e([d()],te.prototype,"shouldShowSelectedImage",void 0),e([d({type:Number})],te.prototype,"brightness",null),e([d({type:Number})],te.prototype,"contrast",null),e([d()],te.prototype,"coverageFrustums",void 0),e([d()],te.prototype,"coveragePolygons",void 0),e([d()],te.prototype,"currentCoverageVisible",void 0),e([d({readOnly:!0})],te.prototype,"currentImageView",null),e([d()],te.prototype,"disabled",void 0),e([d()],te.prototype,"displayMessage",void 0),e([d()],te.prototype,"pointSources",void 0),e([d()],te.prototype,"previousFeatureAngle",void 0),e([d()],te.prototype,"selectedFeature",void 0),e([d()],te.prototype,"selectedFeatureAngle",void 0),e([d()],te.prototype,"selectedPoint",void 0),e([d({readOnly:!0})],te.prototype,"featureCount",null),e([d()],te.prototype,"features",void 0),e([d({readOnly:!0})],te.prototype,"imageGalleryEnabled",null),e([d({readOnly:!0})],te.prototype,"imageLoaded",null),e([d()],te.prototype,"isAdditionalCoverageVisible",void 0),e([d()],te.prototype,"isAdditionalPointSourcesVisible",void 0),e([d({type:Number})],te.prototype,"localPort",void 0),e([d()],te.prototype,"mapImageConversionToolState",void 0),e([d()],te.prototype,"navigatorSelectedFeature",void 0),e([d({readOnly:!0})],te.prototype,"updating",null),e([d()],te.prototype,"referencePoint",null),e([d({type:Number})],te.prototype,"sharpness",null),e([d({readOnly:!0})],te.prototype,"sectorData",null),e([d({readOnly:!0})],te.prototype,"state",null),e([d({readOnly:!0})],te.prototype,"thumbnails",null),e([d({value:null})],te.prototype,"view",null),e([d()],te.prototype,"_additionalCoveragePolygons",void 0),e([d()],te.prototype,"_additionalFeatureGraphics",void 0),e([d()],te.prototype,"_currentCoveragePolygon",void 0),e([d()],te.prototype,"_currentImage",void 0),e([d()],te.prototype,"_fetchFeaturesController",void 0),e([d()],te.prototype,"_imageViewer",void 0),e([d()],te.prototype,"_initialCurrentCoveragePolygon",void 0),e([d()],te.prototype,"_initialCurrentCoverageUpdate",void 0),e([d()],te.prototype,"_overlays",void 0),e([d()],te.prototype,"_plotPolygons",void 0),e([d()],te.prototype,"_initialPreviousCoveragePolygon",void 0),e([d()],te.prototype,"_referencePointOnGround",void 0),e([d()],te.prototype,"_referencePointOnImage",void 0),e([d()],te.prototype,"_selectedFeatureGraphic",void 0),e([d()],te.prototype,"_sectorData",void 0),te=e([y("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],te);const re=te;export{re as default};