@arcgis/core 6.0.0-next.6 → 6.0.0-next.7

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 (122) hide show
  1. package/arcade/functions/knowledgegraph.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f09c9d9a554c33a753b4.js → 02253bdffbd580af22d8.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{83589144eeeb08f45557.js → 2aeb5cc32284dd3e4d22.js} +1 -1
  5. package/assets/esri/core/workers/chunks/3ffda5bf0b91700dc308.js +1 -0
  6. package/assets/esri/core/workers/chunks/{1317ecdfd0cfa683a493.js → 42323093827adffe56d3.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{f46a0d7cf588ba1b4157.js → 518e8883b6ed613bf451.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{67ac6b326bf80fc3d33d.js → 53be85d04cd2da4f391d.js} +1 -1
  9. package/assets/esri/core/workers/chunks/54778dec1598818d93cb.js +1 -0
  10. package/assets/esri/core/workers/chunks/{3ac9dcbb0571a2580236.js → 62c8c9ad09e0166207fd.js} +1 -1
  11. package/assets/esri/core/workers/chunks/6588725275c75fae0d9c.js +1 -0
  12. package/assets/esri/core/workers/chunks/6ebe73f69ae822053b70.js +1 -0
  13. package/assets/esri/core/workers/chunks/7038ead1fa1674416ab3.js +1 -0
  14. package/assets/esri/core/workers/chunks/70cc2d79653d66e85b58.js +1 -0
  15. package/assets/esri/core/workers/chunks/{8ba32d3a0df4a206ef1c.js → 7165d6f6a5078768bebb.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{cbe6c0f32608cb504695.js → 776ae25a34352d3468bc.js} +1 -1
  17. package/assets/esri/core/workers/chunks/801e9e66edb4961461eb.js +1 -0
  18. package/assets/esri/core/workers/chunks/9ce91a909eccc4dfe388.js +1 -0
  19. package/assets/esri/core/workers/chunks/ad76f7ab2f3e6d5a5b3c.js +1 -0
  20. package/assets/esri/core/workers/chunks/{250d3be6d3849d71fed8.js → c29c474c4b1049352d3e.js} +1 -1
  21. package/assets/esri/core/workers/chunks/ddf0671976648f621269.js +1 -0
  22. package/assets/esri/core/workers/chunks/ecaac39dde7ec4213264.js +1 -0
  23. package/assets/esri/core/workers/chunks/fb444954be74c1962ced.js +1 -0
  24. package/assets/esri/core/workers/chunks/{fccbb902fe08448f91de.js → fd0a5c243f3426f2a0b5.js} +1 -1
  25. package/assets/esri/core/workers/chunks/fecaf0bc28aeea4d15db.js +1 -0
  26. package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationSettings.scss +1 -1
  27. package/assets/esri/themes/base/widgets/_Features.scss +1 -1
  28. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +5 -9
  29. package/assets/esri/themes/base/widgets/_SelectionToolbar.scss +2 -4
  30. package/assets/esri/themes/base/widgets/_Tooltip.scss +1 -1
  31. package/assets/esri/themes/dark/main.css +1 -1
  32. package/assets/esri/themes/light/main.css +1 -1
  33. package/assets/esri/themes/light/view.css +1 -1
  34. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.en.json +1 -1
  35. package/chunks/GlobalIllumination.glsl.js +4 -2
  36. package/chunks/GlobalIlluminationBlur.glsl.js +3 -5
  37. package/chunks/GlobalIlluminationUpscale.glsl.js +1 -1
  38. package/config.js +1 -1
  39. package/core/colorUtils.js +1 -1
  40. package/core/has.js +1 -1
  41. package/core/workers/workerFactory.js +1 -1
  42. package/geometry/projectionUtils.js +1 -1
  43. package/kernel.js +1 -1
  44. package/layers/graphics/data/FeatureStore.js +1 -1
  45. package/layers/graphics/data/QueryEngineResult.js +1 -1
  46. package/layers/graphics/data/geometryUtils.js +1 -1
  47. package/layers/graphics/data/projectionSupport.js +1 -1
  48. package/layers/knowledgeGraph/layerUtils.js +1 -1
  49. package/layers/knowledgeGraph/nodeMovementUtils.js +1 -1
  50. package/layers/raster/datasets/TIFFRaster.js +1 -1
  51. package/package.json +2 -2
  52. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  53. package/views/2d/layers/features/FeatureSourceEventLog.js +1 -1
  54. package/views/2d/layers/features/sources/strategies/AFeatureTileLoadStrategy.js +1 -1
  55. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  56. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  57. package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
  58. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  59. package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
  60. package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
  61. package/views/3d/support/elevationUpdateUtils.js +1 -1
  62. package/views/3d/terrain/TerrainRenderer.js +1 -1
  63. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationColorQuantization.glsl.js +2 -2
  64. package/views/draw/Draw.d.ts +1 -1
  65. package/views/draw/support/InteractiveHandle.js +1 -1
  66. package/views/interactive/options/SnappingOptions.d.ts +1 -0
  67. package/views/interactive/options/TooltipOptions.d.ts +1 -0
  68. package/views/interactive/options/ViewOptions.d.ts +1 -0
  69. package/views/interactive/support/Units.d.ts +1 -0
  70. package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
  71. package/views/interactive/tooltip/components/ElevationModeSelect.js +1 -1
  72. package/views/support/projectionUtils.js +1 -1
  73. package/widgets/BasemapLayerList.js +1 -1
  74. package/widgets/BatchAttributeForm.js +1 -1
  75. package/widgets/DirectionalPad.js +1 -1
  76. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  77. package/widgets/Expand.js +1 -1
  78. package/widgets/FeatureForm.js +1 -1
  79. package/widgets/FeatureTable/FieldColumn.js +1 -1
  80. package/widgets/FeatureTable.js +1 -1
  81. package/widgets/Features/FeaturesDrillIn.js +1 -1
  82. package/widgets/Features.js +1 -1
  83. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  84. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  85. package/widgets/OrientedImageryViewer/components/SequentialNavigationUI.js +1 -1
  86. package/widgets/OrientedImageryViewer/components/SketchTools.js +1 -1
  87. package/widgets/PanoramicVideoViewer.js +1 -1
  88. package/widgets/Print.js +1 -1
  89. package/widgets/ScaleRangeSlider.js +1 -1
  90. package/widgets/Search/SearchResultRenderer.js +1 -1
  91. package/widgets/Sketch/SketchViewModel.d.ts +1 -1
  92. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  93. package/widgets/Sketch.d.ts +1 -1
  94. package/widgets/Track/TrackViewModel.d.ts +1 -1
  95. package/widgets/UtilityNetworkAssociations.js +1 -1
  96. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  97. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeaturesDrillIn.js +1 -1
  98. package/widgets/UtilityNetworkTrace/types.d.ts +2 -2
  99. package/widgets/UtilityNetworkTrace.js +1 -1
  100. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  101. package/widgets/ValuePicker.js +1 -1
  102. package/widgets/VideoPlayer/components/PlayerActionsGroup.js +1 -1
  103. package/widgets/VideoPlayer/components/PlayerControlsGroup.js +1 -1
  104. package/widgets/support/GridControls.js +1 -1
  105. package/widgets/support/PluginSettingsControls.js +1 -1
  106. package/widgets/support/SelectionToolbar.js +1 -1
  107. package/widgets/support/SnappingControls.js +1 -1
  108. package/widgets/support/componentsUtils.js +1 -1
  109. package/assets/esri/core/workers/chunks/02d4f91652a79d2b637e.js +0 -1
  110. package/assets/esri/core/workers/chunks/107b025dc5b09465a78f.js +0 -1
  111. package/assets/esri/core/workers/chunks/1f43e06dcfe56229bb0f.js +0 -1
  112. package/assets/esri/core/workers/chunks/2a570ce6b99dac6ee996.js +0 -1
  113. package/assets/esri/core/workers/chunks/3880d2c7fb14955d7f93.js +0 -1
  114. package/assets/esri/core/workers/chunks/56851011276de0b3e318.js +0 -1
  115. package/assets/esri/core/workers/chunks/5f3ab77a79c408423fde.js +0 -1
  116. package/assets/esri/core/workers/chunks/65654e481cce9ae40e54.js +0 -1
  117. package/assets/esri/core/workers/chunks/8b54589f173259c1ba55.js +0 -1
  118. package/assets/esri/core/workers/chunks/bff767ec5bb4c0d6b324.js +0 -1
  119. package/assets/esri/core/workers/chunks/c906f984b2b6e7578c06.js +0 -1
  120. package/assets/esri/core/workers/chunks/de02a6a1f4810f99e9bb.js +0 -1
  121. package/assets/esri/core/workers/chunks/e5943f3a4bbc12c06c4d.js +0 -1
  122. package/assets/esri/core/workers/chunks/f0aaa646b17ffdbdcefa.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{memoize as r}from"../../../core/memoize.js";import{ignoreAbortErrors as i}from"../../../core/promiseUtils.js";import{valueInUnit as a}from"../../../core/quantity.js";import{createScreenPoint as o}from"../../../core/screenUtils.js";import{property as s,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromArray as l,create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as d}from"../../../core/libs/gl-matrix-2/math/vec2.js";import f from"../../../geometry/Point.js";import{pointEquals as p}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{makeDehydratedPoint as m}from"../../../layers/graphics/dehydratedPoint.js";import{getZFromVertexSnappingCandidates as h}from"./drawUtils.js";import{getPolylineOrPolygonConstraint as g,getPointConstraint as _,pointToConstraintSpace as v,constraintSpaceToPoint as y}from"../../interactive/sketch/constraintUtils.js";import{SnappingContext as b}from"../../interactive/snapping/SnappingContext.js";import{SnappingOperation as x}from"../../interactive/snapping/SnappingOperation.js";let S=class extends t{constructor(e){super(e),this._snappingOperation=null,this.role=`primary`,this.captureMode=`capture-always`,this.defaultCaptureMode=`capture-always`,this.snappingEnabled=!0,this.selfSnappingEnabled=!0,this.editSession=null,this.outputMapPositionOfDragStart=null,this.selectedSnappingResult=null,this.screenPosition=null,this.inputMapPosition=null,this.drawToolDragging=!1,this.manipulatorDragging=!1,this.activePointerId=null,this.activePointerType=null,this._getSnappingContext=r((e,t,n,r,i,a)=>n?new b({elevationInfo:r,pointer:e,vertexHandle:t,editGeometryOperations:n,visualizer:i,suppressSelfSnapping:!a}):null)}get grabbable(){return this.captureMode===`grabbable-object`}get following(){let{captureMode:e}=this;return e===`capture-always`||e===`capture-when-engaged`}get outputMapPosition(){return this._get(`outputMapPosition`)}set outputMapPosition(e){let t=this._get(`outputMapPosition`);e&&t&&p(e,t)||this._set(`outputMapPosition`,e)}get dragging(){return this.drawToolDragging||this.manipulatorDragging}get firstPointZ(){let e=this.editSession?.lastPointAddedBySession;if(!e)return null;let t=this.editSession?.getInformationAboutPoint(0,e.partIndex);return t?.point.hasZ?t.point.z:null}async moveTo(e,t){let{snappingManager:n,skipSnapping:r,surfaceManager:a,pointerType:o,editGeometryOperations:s,snappingVisualizer:c}=t;this.notePointerActivity(t.pointerId,o);let l=this._getSnappingContext(o??`mouse`,this.editSession?.endVertex,s,a?.elevationInfo,c,this.selfSnappingEnabled),u=this._ensureSnappingOperation(t);e&&(this.screenPosition=e);let d=this.screenPosition;if(!d)return null;let h=this.firstPointZ,g=a?.screenToMap(d,{firstPointZ:h});if(this.inputMapPosition=g,this.selectedSnappingResult=null,!n||!g||!l||r||!this.snappingEnabled)return this.selectedSnappingResult=void 0,this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,g,t);let _=m(g.x,g.y,g.z,g?.spatialReference),v=a?.screenToScene?.(d,{firstPointZ:h}),y=u.snap({point:_,scenePoint:v},n,l),b=()=>{let e=u.stagedPoint;return p(this.selectedSnappingResult,e)||(this.selectedSnappingResult=e==null?null:new f({...e})),this.outputMapPosition=this._finalizeSnappingAndConstraintResult(this.selectedSnappingResult,g,t)};return b(),i(y.then(b))}async moveDeltaRelativeToScreen(e,t,n){let{inputMapPosition:r,screenPosition:i,firstPointZ:a}=this;if(!r)return null;let s=n.surfaceManager?n.surfaceManager.mapToScreen(r,{firstPointZ:a}):i;if(!s)return null;let c=o(s.x+e,s.y+t);return this.moveTo(c,n)}async noteDragStart(e,t){if(this.notePointerDown(t.pointerId,t.pointerType),this.drawToolDragging=!0,t.skipSnapping||!this.snappingEnabled)return null;let{snappingManager:r,surfaceManager:a,pointerType:o,editGeometryOperations:s,snappingVisualizer:c}=t,l=this._getSnappingContext(o??`mouse`,this.editSession?.endVertex,s,a?.elevationInfo,c,this.selfSnappingEnabled),u=this._ensureSnappingOperation(t),d=this.firstPointZ,p=a?.screenToMap(e,{firstPointZ:d});if(this.outputMapPositionOfDragStart=null,r&&l&&p){let o=u.snap({point:m(p.x,p.y,p.z,p?.spatialReference),scenePoint:a?.screenToScene?.(e,{firstPointZ:d})},r,l);return i(o.then(()=>{let e=u.stagedPoint?new f({...u.stagedPoint}):null;return this.outputMapPositionOfDragStart=this._finalizeSnappingAndConstraintResult(e,p,t)})).catch(e=>(n.getLogger(this).error(`drawtool:handle:snapping-failed`,e),null))}return this.outputMapPositionOfDragStart=p,null}async noteDragEnd(e,t){return this.moveTo(e,t).finally(()=>{this.drawToolDragging=!1,this.notePointerUp(t.pointerId,t.pointerType)})}notePointerActivity(e=null,t=null){t&&(this.activePointerType=t),e!=null&&this.dragging&&(this.activePointerId=e)}notePointerDown(e=null,t=null){e!=null&&(this.activePointerId=e),t&&(this.activePointerType=t)}notePointerUp(e=null,t=null){(e==null||this.activePointerId==null||this.activePointerId===e)&&(this.activePointerId=null),t&&this.activePointerType===t&&(this.activePointerType=null)}async moveDeltaRelativeToSketchSegment(e,t){let n=this.editSession?.endVertex?.leftSegment?.leftVertex?.pos,{firstPointZ:r}=this,i=this.inputMapPosition?t.surfaceManager?.mapToScreen(this.inputMapPosition,{firstPointZ:r})??this.screenPosition:this.screenPosition;if(!n||!i)return null;let a=t.editGeometryOperations?.data?.coordinateHelper.vectorToPoint(n);if(!a)return null;let o=t.surfaceManager?.mapToScreen(a,{firstPointZ:r});if(!o)return null;let s=[i.x-o.x,i.y-o.y],c=d(u(),l(s)),[f,p]=[c[0]*e,c[1]*e];return this.moveDeltaRelativeToScreen(f,p,t)}refreshConstraint(e){let t=this.outputMapPosition??this.inputMapPosition;return this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,t,e)}_finalizeSnappingAndConstraintResult(e,t,n){let r=e??t;r&&(r.z=h(n.snappingManager)??r.z);let i=(r?n.surfaceManager?.constrainZToEffectiveSurface?.(r):null)??r;return this._ensureZ(this._applyTooltipConstraints(i,n),n)}_applyTooltipConstraints(e,t){let n=e,r=t.tooltipManager?.getConstraints(this);if(!r&&!t.interactiveHandleManager?.customConstraints||!n)return n;let i=t.interactiveHandleManager?.customConstraints,o=t.editGeometryOperations?.data?.coordinateHelper;if(!o)return n;if(i&&this.editSession&&n){let e={handle:this,editSession:this.editSession,toScreen:e=>t.surfaceManager?.mapToScreen(e,{firstPointZ:this.firstPointZ})??null};for(let t of i)n=t(n,e)||n}let s=(this.editSession?.endVertex)?.leftSegment?.leftVertex,c=s?.leftSegment?.leftVertex,l=s&&o.vectorToPoint(s.pos),u=c&&o.vectorToPoint(c.pos);if(!r)return n;let d=(l||u)&&this.role===`primary`?g(l,u,r):_(r);if(!n||!r||!d)return n;let{context:p}=r,m=v(n,p),h=m?d.closestTo(m):void 0;if(!h)return n;let b=y(h,n,p),x=t.surfaceManager?.view?.type===`2d`||p.elevationInfo.mode!==`absolute-height`,S=r.elevation,{hasZ:C,metersPerVerticalUnit:w}=t.surfaceManager??{};return b!=null&&x&&S!=null&&C&&w&&(b.z=a(S,`meters`)/w),b?new f({x:b.x,y:b.y,z:b.z,hasM:b.hasM,hasZ:b.hasZ,m:b.m,spatialReference:b.spatialReference}):null}_ensureZ(e,t){return!e||!t.hasZ||(e.z==null||!e.hasZ)&&(e.z=t.defaultZ??0,e.hasZ=!0),e}_ensureSnappingOperation({view:e}){return this._snappingOperation??=new x({view:e})}};e([s()],S.prototype,`_snappingOperation`,void 0),e([s()],S.prototype,`role`,void 0),e([s()],S.prototype,`name`,void 0),e([s()],S.prototype,`captureMode`,void 0),e([s()],S.prototype,`defaultCaptureMode`,void 0),e([s()],S.prototype,`grabbable`,null),e([s()],S.prototype,`following`,null),e([s()],S.prototype,`snappingEnabled`,void 0),e([s()],S.prototype,`selfSnappingEnabled`,void 0),e([s()],S.prototype,`editSession`,void 0),e([s()],S.prototype,`outputMapPosition`,null),e([s()],S.prototype,`outputMapPositionOfDragStart`,void 0),e([s()],S.prototype,`selectedSnappingResult`,void 0),e([s()],S.prototype,`screenPosition`,void 0),e([s()],S.prototype,`inputMapPosition`,void 0),e([s()],S.prototype,`dragging`,null),e([s()],S.prototype,`drawToolDragging`,void 0),e([s()],S.prototype,`manipulatorDragging`,void 0),e([s()],S.prototype,`activePointerId`,void 0),e([s()],S.prototype,`activePointerType`,void 0),e([s({readOnly:!0})],S.prototype,`firstPointZ`,null),S=e([c(`esri.views.draw.support.InteractiveHandle`)],S);export{S as InteractiveHandle};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{memoize as r}from"../../../core/memoize.js";import{ignoreAbortErrors as i}from"../../../core/promiseUtils.js";import{valueInUnit as a}from"../../../core/quantity.js";import{createScreenPoint as o}from"../../../core/screenUtils.js";import{property as s,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromArray as l,create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as d}from"../../../core/libs/gl-matrix-2/math/vec2.js";import f from"../../../geometry/Point.js";import{pointEquals as p}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{makeDehydratedPoint as m}from"../../../layers/graphics/dehydratedPoint.js";import{getZFromVertexSnappingCandidates as h}from"./drawUtils.js";import{getPolylineOrPolygonConstraint as g,getPointConstraint as _,pointToConstraintSpace as v,constraintSpaceToPoint as y}from"../../interactive/sketch/constraintUtils.js";import{SnappingContext as b}from"../../interactive/snapping/SnappingContext.js";import{SnappingOperation as x}from"../../interactive/snapping/SnappingOperation.js";let S=class extends t{constructor(e){super(e),this._snappingOperation=null,this.role=`primary`,this.captureMode=`capture-always`,this.defaultCaptureMode=`capture-always`,this.snappingEnabled=!0,this.selfSnappingEnabled=!0,this.editSession=null,this.outputMapPositionOfDragStart=null,this.selectedSnappingResult=null,this.screenPosition=null,this.inputMapPosition=null,this.drawToolDragging=!1,this.manipulatorDragging=!1,this.activePointerId=null,this.activePointerType=null,this._getSnappingContext=r((e,t,n,r,i,a)=>n?new b({elevationInfo:r,pointer:e,vertexHandle:t,editGeometryOperations:n,visualizer:i,suppressSelfSnapping:!a}):null)}get grabbable(){return this.captureMode===`grabbable-object`}get following(){let{captureMode:e}=this;return e===`capture-always`||e===`capture-when-engaged`}get outputMapPosition(){return this._get(`outputMapPosition`)}set outputMapPosition(e){let t=this._get(`outputMapPosition`);e&&t&&p(e,t)||this._set(`outputMapPosition`,e)}get dragging(){return this.drawToolDragging||this.manipulatorDragging}get firstPointZ(){let e=this.editSession?.lastPointAddedBySession;if(!e)return null;let t=this.editSession?.getInformationAboutPoint(0,e.partIndex);return t?.point.hasZ?t.point.z:null}async moveTo(e,t){let{snappingManager:n,skipSnapping:r,surfaceManager:a,pointerType:o,editGeometryOperations:s,snappingVisualizer:c}=t;this.notePointerActivity(t.pointerId,o);let l=this._getSnappingContext(o??`mouse`,this.editSession?.endVertex,s,a?.elevationInfo,c,this.selfSnappingEnabled),u=this._ensureSnappingOperation(t);e&&(this.screenPosition=e);let d=this.screenPosition;if(!d)return null;let h=this.firstPointZ,g=a?.screenToMap(d,{firstPointZ:h});if(this.inputMapPosition=g,this.selectedSnappingResult=null,!n||!g||!l||r||!this.snappingEnabled)return this.selectedSnappingResult=void 0,this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,g,t);let _=m(g.x,g.y,g.z,g?.spatialReference),v=a?.screenToScene?.(d,{firstPointZ:h}),y=u.snap({point:_,scenePoint:v},n,l),b=()=>{let e=u.stagedPoint;return p(this.selectedSnappingResult,e)||(this.selectedSnappingResult=e==null?null:new f({...e})),this.outputMapPosition=this._finalizeSnappingAndConstraintResult(this.selectedSnappingResult,g,t)};return b(),i(y.then(b))}async moveDeltaRelativeToScreen(e,t,n){let{inputMapPosition:r,screenPosition:i,firstPointZ:a}=this;if(!r)return null;let s=n.surfaceManager?n.surfaceManager.mapToScreen(r,{firstPointZ:a}):i;if(!s)return null;let c=o(s.x+e,s.y+t);return this.moveTo(c,n)}async noteDragStart(e,t){if(this.notePointerDown(t.pointerId,t.pointerType),this.drawToolDragging=!0,t.skipSnapping||!this.snappingEnabled)return null;let{snappingManager:r,surfaceManager:a,pointerType:o,editGeometryOperations:s,snappingVisualizer:c}=t,l=this._getSnappingContext(o??`mouse`,this.editSession?.endVertex,s,a?.elevationInfo,c,this.selfSnappingEnabled),u=this._ensureSnappingOperation(t),d=this.firstPointZ,p=a?.screenToMap(e,{firstPointZ:d});if(this.outputMapPositionOfDragStart=null,r&&l&&p){let o=u.snap({point:m(p.x,p.y,p.z,p?.spatialReference),scenePoint:a?.screenToScene?.(e,{firstPointZ:d})},r,l);return i(o.then(()=>{let e=u.stagedPoint?new f({...u.stagedPoint}):null;return this.outputMapPositionOfDragStart=this._finalizeSnappingAndConstraintResult(e,p,t)})).catch(e=>(n.getLogger(this).error(`drawtool:handle:snapping-failed`,e),null))}return this.outputMapPositionOfDragStart=p,null}async noteDragEnd(e,t){return this.moveTo(e,t).finally(()=>{this.drawToolDragging=!1,this.notePointerUp(t.pointerId,t.pointerType)})}notePointerActivity(e=null,t=null){t&&(this.activePointerType=t),e!=null&&this.dragging&&(this.activePointerId=e)}notePointerDown(e=null,t=null){e!=null&&(this.activePointerId=e),t&&(this.activePointerType=t)}notePointerUp(e=null,t=null){(e==null||this.activePointerId==null||this.activePointerId===e)&&(this.activePointerId=null),t&&this.activePointerType===t&&(this.activePointerType=null)}async moveDeltaRelativeToSketchSegment(e,t){let n=this.editSession?.endVertex?.leftSegment?.leftVertex?.pos,{firstPointZ:r}=this,i=this.inputMapPosition?t.surfaceManager?.mapToScreen(this.inputMapPosition,{firstPointZ:r})??this.screenPosition:this.screenPosition;if(!n||!i)return null;let a=t.editGeometryOperations?.data?.coordinateHelper.vectorToPoint(n);if(!a)return null;let o=t.surfaceManager?.mapToScreen(a,{firstPointZ:r});if(!o)return null;let s=[i.x-o.x,i.y-o.y],c=d(u(),l(s)),[f,p]=[c[0]*e,c[1]*e];return this.moveDeltaRelativeToScreen(f,p,t)}refreshConstraint(e){let t=this.outputMapPosition??this.inputMapPosition;return this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,t,e)}_finalizeSnappingAndConstraintResult(e,t,n){let r=e??t;r&&n.view.type===`2d`&&(r.z=h(n.snappingManager)??r.z);let i=(r?n.surfaceManager?.constrainZToEffectiveSurface?.(r):null)??r;return this._ensureZ(this._applyTooltipConstraints(i,n),n)}_applyTooltipConstraints(e,t){let n=e,r=t.tooltipManager?.getConstraints(this);if(!r&&!t.interactiveHandleManager?.customConstraints||!n)return n;let i=t.interactiveHandleManager?.customConstraints,o=t.editGeometryOperations?.data?.coordinateHelper;if(!o)return n;if(i&&this.editSession&&n){let e={handle:this,editSession:this.editSession,toScreen:e=>t.surfaceManager?.mapToScreen(e,{firstPointZ:this.firstPointZ})??null};for(let t of i)n=t(n,e)||n}let s=(this.editSession?.endVertex)?.leftSegment?.leftVertex,c=s?.leftSegment?.leftVertex,l=s&&o.vectorToPoint(s.pos),u=c&&o.vectorToPoint(c.pos);if(!r)return n;let d=(l||u)&&this.role===`primary`?g(l,u,r):_(r);if(!n||!r||!d)return n;let{context:p}=r,m=v(n,p),h=m?d.closestTo(m):void 0;if(!h)return n;let b=y(h,n,p),x=t.surfaceManager?.view?.type===`2d`||p.elevationInfo.mode!==`absolute-height`,S=r.elevation,{hasZ:C,metersPerVerticalUnit:w}=t.surfaceManager??{};return b!=null&&x&&S!=null&&C&&w&&(b.z=a(S,`meters`)/w),b?new f({x:b.x,y:b.y,z:b.z,hasM:b.hasM,hasZ:b.hasZ,m:b.m,spatialReference:b.spatialReference}):null}_ensureZ(e,t){return!e||!t.hasZ||(e.z==null||!e.hasZ)&&(e.z=t.defaultZ??0,e.hasZ=!0),e}_ensureSnappingOperation({view:e}){return this._snappingOperation??=new x({view:e})}};e([s()],S.prototype,`_snappingOperation`,void 0),e([s()],S.prototype,`role`,void 0),e([s()],S.prototype,`name`,void 0),e([s()],S.prototype,`captureMode`,void 0),e([s()],S.prototype,`defaultCaptureMode`,void 0),e([s()],S.prototype,`grabbable`,null),e([s()],S.prototype,`following`,null),e([s()],S.prototype,`snappingEnabled`,void 0),e([s()],S.prototype,`selfSnappingEnabled`,void 0),e([s()],S.prototype,`editSession`,void 0),e([s()],S.prototype,`outputMapPosition`,null),e([s()],S.prototype,`outputMapPositionOfDragStart`,void 0),e([s()],S.prototype,`selectedSnappingResult`,void 0),e([s()],S.prototype,`screenPosition`,void 0),e([s()],S.prototype,`inputMapPosition`,void 0),e([s()],S.prototype,`dragging`,null),e([s()],S.prototype,`drawToolDragging`,void 0),e([s()],S.prototype,`manipulatorDragging`,void 0),e([s()],S.prototype,`activePointerId`,void 0),e([s()],S.prototype,`activePointerType`,void 0),e([s({readOnly:!0})],S.prototype,`firstPointZ`,null),S=e([c(`esri.views.draw.support.InteractiveHandle`)],S);export{S as InteractiveHandle};
@@ -67,6 +67,7 @@ export interface SnappingOptionsProperties extends Partial<Pick<SnappingOptions,
67
67
  * @see [Sketch](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/)
68
68
  * @see [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/)
69
69
  * @see [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/)
70
+ * @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
70
71
  * @see [Sample - Sketch widget](https://developers.arcgis.com/javascript/latest/sample-code/sketch-geometries/)
71
72
  * @see [Sample - Sketch in 3D](https://developers.arcgis.com/javascript/latest/sample-code/sketch-3d/)
72
73
  * @see [Sample - Edit features in 3D with the Editor widget](https://developers.arcgis.com/javascript/latest/sample-code/editor-3d/)
@@ -93,6 +93,7 @@ export interface TooltipOptionsProperties extends Partial<Pick<TooltipOptions, "
93
93
  * @since 5.2
94
94
  * @see [LabelOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/LabelOptions/)
95
95
  * @see [ValueOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ValueOptions/)
96
+ * @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
96
97
  * @see [Sample - Sketch in 3D](https://developers.arcgis.com/javascript/latest/sample-code/sketch-3d/)
97
98
  * @see [Sample - Edit features in 3D with the Editor widget](https://developers.arcgis.com/javascript/latest/sample-code/editor-3d/)
98
99
  */
@@ -124,6 +124,7 @@ export interface ViewOptionsProperties {
124
124
  *
125
125
  * @beta
126
126
  * @since 5.2
127
+ * @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
127
128
  */
128
129
  export default class ViewOptions extends Accessor {
129
130
  /** @since 5.2 */
@@ -10,6 +10,7 @@ export interface UnitsProperties extends Partial<Pick<Units, "area" | "length" |
10
10
  * Each quantity accepts a specific unit or measurement system (`"metric"` or `"imperial"`).
11
11
  *
12
12
  * @since 5.2
13
+ * @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/)
13
14
  */
14
15
  export default class Units extends Accessor {
15
16
  /** @since 5.2 */
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{drawContentHeaderActions as r}from"../css.js";import{directionModeIcons as i}from"./directionModeIcons.js";import a from"../../../../widgets/Widget.js";import{loadCalciteComponents as o}from"../../../../widgets/support/componentsUtils.js";import{tsx as s,messageBundle as c}from"../../../../widgets/support/widget.js";let l=class extends a{constructor(e){super(e),this.visibleElements={}}render(){return s(`div`,{class:r},this._isElementVisible(`direction`)?s(u,{messages:this.messages,toolOptions:this.toolOptions,topLayerDisabled:this.topLayerDisabled}):null)}loadDependencies(){return o({button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`)})}_isElementVisible(e){return this.visibleElements?.[e]??this.toolOptions.tooltips.visibleElements[e]}};e([c(`esri/views/interactive/tooltip/t9n/Tooltip`),t()],l.prototype,`messages`,void 0),e([t()],l.prototype,`toolOptions`,void 0),e([t()],l.prototype,`visibleElements`,void 0),l=e([n(`esri.views.interactive.tooltip.components.DrawHeaderActions`)],l);function u(e){let{directionMode:t}=e.toolOptions.values,n=e.messages?.sketch,r=n?.directionModeSelect?.title,a=`absolute`,o=`relative`;return s(`calcite-dropdown`,{key:`direction-mode`,placement:`bottom-end`,scale:`s`,topLayerDisabled:e.topLayerDisabled,onCalciteDropdownSelect:t=>{let n=t.currentTarget.selectedItems?.[0]?.getAttribute(`data-mode`);e.toolOptions.values.directionMode=n??`absolute`}},s(`calcite-button`,{alignment:`end`,appearance:`transparent`,iconStart:i[t],kind:`neutral`,label:r,scale:`s`,slot:`trigger`,title:r}),s(`calcite-dropdown-group`,{selectionMode:`single`},s(`calcite-dropdown-item`,{"data-mode":o,"data-testid":`tooltip-direction-mode-relative`,iconStart:i.relative,key:`relative`,selected:t===o},n?.directionModeSelect?.relative),s(`calcite-dropdown-item`,{"data-mode":a,"data-testid":`tooltip-direction-mode-absolute`,iconStart:i.absolute,key:`absolute`,selected:t===a},n?.directionModeSelect?.absolute)))}export{l as DrawHeaderActions};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{drawContentHeaderActions as r}from"../css.js";import{directionModeIcons as i}from"./directionModeIcons.js";import a from"../../../../widgets/Widget.js";import{createDropdownReference as o,loadCalciteComponents as s}from"../../../../widgets/support/componentsUtils.js";import{tsx as c,messageBundle as l}from"../../../../widgets/support/widget.js";let u=class extends a{constructor(e){super(e),this.visibleElements={},this._directionModeDropdownReference=o()}destroy(){this._directionModeDropdownReference.destroy()}render(){return c(`div`,{class:r},this._isElementVisible(`direction`)?c(d,{messages:this.messages,reference:this._directionModeDropdownReference,toolOptions:this.toolOptions,topLayerDisabled:this.topLayerDisabled}):null)}loadDependencies(){return s({button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`)})}_isElementVisible(e){return this.visibleElements?.[e]??this.toolOptions.tooltips.visibleElements[e]}};e([l(`esri/views/interactive/tooltip/t9n/Tooltip`),t()],u.prototype,`messages`,void 0),e([t()],u.prototype,`toolOptions`,void 0),e([t()],u.prototype,`visibleElements`,void 0),u=e([n(`esri.views.interactive.tooltip.components.DrawHeaderActions`)],u);function d(e){let{directionMode:t}=e.toolOptions.values,n=e.messages?.sketch,r=n?.directionModeSelect?.title,{storeTrigger:a,destroy:o,referenceTrigger:s}=e.reference,l=`absolute`,u=`relative`;return c(`div`,{key:`direction-mode`,style:`display: inline-flex;`},c(`calcite-button`,{afterCreate:a,afterRemoved:o,afterUpdate:a,alignment:`end`,appearance:`transparent`,iconStart:i[t],kind:`neutral`,label:r,scale:`s`,title:r}),c(`calcite-dropdown`,{afterCreate:s,afterUpdate:s,placement:`bottom-end`,scale:`s`,topLayerDisabled:e.topLayerDisabled,onCalciteDropdownSelect:t=>{let n=t.currentTarget.selectedItems?.[0]?.getAttribute(`data-mode`);e.toolOptions.values.directionMode=n??`absolute`}},c(`calcite-dropdown-group`,{selectionMode:`single`},c(`calcite-dropdown-item`,{"data-mode":u,"data-testid":`tooltip-direction-mode-relative`,iconStart:i.relative,key:`relative`,selected:t===u},n?.directionModeSelect?.relative),c(`calcite-dropdown-item`,{"data-mode":l,"data-testid":`tooltip-direction-mode-absolute`,iconStart:i.absolute,key:`absolute`,selected:t===l},n?.directionModeSelect?.absolute))))}export{u as DrawHeaderActions};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{base as r}from"../css.js";import i from"../../../../widgets/Widget.js";import{loadCalciteComponents as a}from"../../../../widgets/support/componentsUtils.js";import{tsx as o}from"../../../../widgets/support/widget.js";const s=[`absolute-height`,`on-the-ground`,`relative-to-ground`,`relative-to-scene`],c={"absolute-height":`absolute-elevation`,"on-the-ground":`on-the-ground-elevation`,"relative-to-ground":`relative-to-ground-elevation`,"relative-to-scene":`relative-to-scene-elevation`};let l=class extends i{constructor(){super(...arguments),this._dropdown=null,this._onSelect=e=>{let t=e.currentTarget.selectedItems[0]?.getAttribute(`data-mode`),n=s.find(e=>e===t),r=this.context.elevationModeContext;try{n&&!r.disabled&&n!==r.mode&&r.onChange(n)}finally{for(let t of e.currentTarget.querySelectorAll(`calcite-dropdown-item`))t.selected=t.getAttribute(`data-mode`)===r.mode}},this._onDropdownCreate=e=>{this._dropdown=e,e.addEventListener(`keydown`,this._onDropdownKeyDown,!0)},this._onDropdownRemove=e=>{e.removeEventListener(`keydown`,this._onDropdownKeyDown,!0),this._dropdown=null},this._onDropdownKeyDown=e=>{e.key===`Escape`&&this._dropdown?.open&&(e.preventDefault(),e.stopPropagation(),this._dropdown.open=!1,this._dropdown.querySelector(`calcite-button`)?.setFocus())}}render(){let{context:e,mode:t}=this,n=e.elevationModeContext,i=e.messages.sketch.elevationModeSelect,a=n.mode,l=`${i.title}: ${i[a]}`;return o(`div`,null,t===`feedback`?o(`span`,{"aria-label":l,class:`${r}-elevation-mode__feedback`,"data-testid":`tooltip-elevation-mode-feedback`,key:`feedback`,role:`img`,title:l},o(`calcite-icon`,{icon:c[a],scale:`s`})):o(`calcite-dropdown`,{afterCreate:this._onDropdownCreate,afterRemoved:this._onDropdownRemove,class:`${r}-elevation-mode__dropdown`,"data-testid":`tooltip-elevation-mode`,key:`input`,placement:`bottom-end`,scale:`s`,topLayerDisabled:e.topLayerDisabled,onCalciteDropdownSelect:this._onSelect},o(`calcite-button`,{appearance:`transparent`,"data-field-name":`elevation`,"data-testid":`tooltip-elevation-mode-trigger`,"data-tooltip-inline-control":``,disabled:n.disabled,iconStart:c[a],kind:`neutral`,label:l,scale:`s`,slot:`trigger`,title:l}),o(`calcite-dropdown-group`,{selectionMode:`single`},s.map(e=>o(`calcite-dropdown-item`,{"data-mode":e,"data-testid":`tooltip-elevation-mode-${e}`,iconStart:c[e],key:e,selected:e===a},i[e])))))}loadDependencies(){return a({button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`)})}};e([t()],l.prototype,`context`,void 0),e([t()],l.prototype,`mode`,void 0),l=e([n(`esri.views.interactive.tooltip.components.ElevationModeSelect`)],l);export{l as ElevationModeSelect};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{base as r}from"../css.js";import i from"../../../../widgets/Widget.js";import{loadCalciteComponents as a}from"../../../../widgets/support/componentsUtils.js";import{tsx as o}from"../../../../widgets/support/widget.js";const s=[`absolute-height`,`on-the-ground`,`relative-to-ground`,`relative-to-scene`],c={"absolute-height":`absolute-elevation`,"on-the-ground":`on-the-ground-elevation`,"relative-to-ground":`relative-to-ground-elevation`,"relative-to-scene":`relative-to-scene-elevation`};let l=class extends i{constructor(){super(...arguments),this._dropdown=null,this._trigger=null,this._onSelect=e=>{let t=e.currentTarget.selectedItems[0]?.getAttribute(`data-mode`),n=s.find(e=>e===t),r=this.context.elevationModeContext;try{n&&!r.disabled&&n!==r.mode&&r.onChange(n)}finally{for(let t of e.currentTarget.querySelectorAll(`calcite-dropdown-item`))t.selected=t.getAttribute(`data-mode`)===r.mode}},this._onDropdownCreate=e=>{this._dropdown=e,e.referenceElement=this._trigger,e.addEventListener(`keydown`,this._onDropdownKeyDown,!0)},this._onTriggerCreate=e=>{this._trigger=e,e.addEventListener(`keydown`,this._onDropdownKeyDown,!0)},this._onTriggerRemove=e=>{e.removeEventListener(`keydown`,this._onDropdownKeyDown,!0),this._trigger===e&&(this._trigger=null)},this._onDropdownRemove=e=>{e.removeEventListener(`keydown`,this._onDropdownKeyDown,!0),this._dropdown=null},this._onDropdownKeyDown=e=>{e.key===`Escape`&&this._dropdown?.open&&(e.preventDefault(),e.stopPropagation(),this._dropdown.open=!1,this._trigger?.setFocus())}}render(){let{context:e,mode:t}=this,n=e.elevationModeContext,i=e.messages.sketch.elevationModeSelect,a=n.mode,l=`${i.title}: ${i[a]}`;return o(`div`,null,t===`feedback`?o(`span`,{"aria-label":l,class:`${r}-elevation-mode__feedback`,"data-testid":`tooltip-elevation-mode-feedback`,key:`feedback`,role:`img`,title:l},o(`calcite-icon`,{icon:c[a],scale:`s`})):o(`div`,{class:`${r}-elevation-mode__dropdown`,key:`input`,style:`display: inline-flex;`},o(`calcite-button`,{afterCreate:this._onTriggerCreate,afterRemoved:this._onTriggerRemove,afterUpdate:this._onTriggerCreate,appearance:`transparent`,"data-field-name":`elevation`,"data-testid":`tooltip-elevation-mode-trigger`,"data-tooltip-inline-control":``,disabled:n.disabled,iconStart:c[a],kind:`neutral`,label:l,scale:`s`,title:l}),o(`calcite-dropdown`,{afterCreate:this._onDropdownCreate,afterRemoved:this._onDropdownRemove,"data-testid":`tooltip-elevation-mode`,placement:`bottom-end`,scale:`s`,topLayerDisabled:e.topLayerDisabled,onCalciteDropdownSelect:this._onSelect},o(`calcite-dropdown-group`,{selectionMode:`single`},s.map(e=>o(`calcite-dropdown-item`,{"data-mode":e,"data-testid":`tooltip-elevation-mode-${e}`,iconStart:c[e],key:e,selected:e===a},i[e]))))))}loadDependencies(){return a({button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`)})}};e([t()],l.prototype,`context`,void 0),e([t()],l.prototype,`mode`,void 0),l=e([n(`esri.views.interactive.tooltip.components.ElevationModeSelect`)],l);export{l as ElevationModeSelect};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{throwIfAborted as e}from"../../core/promiseUtils.js";import{isLoaded as t,canProjectWithoutEngine as n,project as r,load as i}from"../../geometry/projectionUtils.js";let a=null,o;async function s(t){a||=import(`../../portal/support/geometryServiceUtils.js`).then(e=>o=e),await a,e(t)}async function c(e,a,l,u){if(!e)return null;let d=e.spatialReference;return t()||n(d,a)?r(e,a):o?o.projectGeometry(e,a,l,u):(await Promise.race([s(u),i(u)]),c(e,a,l,u))}export{c as projectWithEngineOrService};
2
+ import{throwIfAborted as e}from"../../core/promiseUtils.js";import{isLoaded as t,canProjectWithoutEngine as n,project as r,load as i}from"../../geometry/projectionUtils.js";import{fromJSON as a}from"../../geometry/support/jsonUtils.js";let o=null,s;async function c(t){o||=import(`../../portal/support/geometryServiceUtils.js`).then(e=>s=e),await o,e(t)}async function l(e,o,u,d){if(!e)return null;let f=e.spatialReference;return t()||n(f,o)?r(e,o):s?s.projectGeometry(a(e),o,u,d):(await Promise.race([c(d),i(d)]),l(e,o,u,d))}export{l as projectWithEngineOrService};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../core/Collection.js";import{deprecateWidget as n}from"../core/deprecate.js";import{IdentifiableMixin as r}from"../core/Identifiable.js";import i from"../core/Logger.js";import a from"../core/ReactiveMap.js";import{on as o,initial as s,watch as c,syncAndInitial as l}from"../core/reactiveUtils.js";import{property as u,subclass as d}from"../core/accessorSupport/decorators.js";import f from"./Widget.js";import p from"./BasemapLayerList/BasemapLayerListViewModel.js";import m from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as h}from"./BasemapLayerList/css.js";import g from"./LayerList/LayerListItem.js";import _ from"./LayerList/ListItem.js";import{minFilterItems as v,getItem as y,getLayerType as b,removeDestroyedListItems as x,setFilterPredicate as S,sortLayersToIds as C,sortChildLayersToIds as w}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import{globalCss as E}from"./support/globalCss.js";import{incrementHeadingLevel as D}from"./support/Heading.js";import{calciteListFilterProps as O}from"./support/listUtils.js";import{tsx as k,messageBundle as A,vmEvent as j}from"./support/widget.js";import{setFocus as M}from"./support/widgetUtils.js";const N=t.ofType(_),P=`nested`,F=`data-basemap-layer-type`;let I=class extends r(f){constructor(e,r){super(e,r),this._baseListEl=null,this._referenceListEl=null,this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._focusEditingFlowItem=!1,this._layerListMap=new a,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder=``,this.baseFilterPredicate=null,this.baseFilterText=``,this.referenceFilterPredicate=null,this.referenceFilterText=``,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t([`knowledge-graph`]),this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minFilterItems=v,this.openedLayers=new t,this.openedLayerLists=new t,this.tableList=null,this.selectedItems=new N,this.selectionMode=`none`,this.tileOptions=null,this.viewModel=new p({suppressDeprecationWarning:!0}),this.visibilityAppearance=`default`,this.visibleElements=new m,this._canMove=({dragEl:e,fromEl:t,toEl:n},r)=>{let i=r===`pull`?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,a=y(e);if(!a?.sortable)return!1;let o=y(t),s=b(t),c=y(n),l=b(n),u=!!s&&!!l&&s===l,d={selected:a,from:o,to:c},f=t.group,p=n.group,m=o?.layer?.type??``,h=c?.layer?.type??``,g=new Set([`map-image`,`catalog`,`knowledge-graph`]);return f&&p&&typeof i==`function`?i.call(null,d):u&&!g.has(m)&&!g.has(h)&&a?.layer?.type!==`sublayer`},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if(this.visibilityAppearance!=="default")return;let t=Array.from(e.composedPath()).find(e=>e.classList?.contains(h.item));this._activeItem=y(t)},this._onCalciteListOrderChange=e=>{let{_lastDragDetail:t}=this,{toEl:n,fromEl:r,dragEl:i,newIndex:a}=e,o=t?.newIndex===a&&t?.dragEl===i&&t?.toEl===n&&t?.fromEl===r;if(!r||!n||o)return;this._lastDragDetail=e,this._selectedDragItemLayerUid=i.value;let s=r,c=n;if(s===c){let e=Array.from(r.children).filter(e=>e?.matches(`calcite-list-item`)).map(e=>e.value);this._sortLayers(s,e)}else a!=null&&this._moveLayerFromChildList({toEl:c,fromEl:s,dragEl:i,newIndex:a})},this.announceDeprecation=()=>{n(i.getLogger(this),`Basemap Layer List (Next)`,`arcgis-basemap-layer-list-next`,{version:`5.0`})}}initialize(){this.addHandles([o(()=>this.openedLayers,`change`,()=>this._handleOpenedLayersChange(),s),c(()=>[this.viewModel.referenceItems.toArray(),this.viewModel.baseItems.toArray()],()=>x(this.selectedItems),l),c(()=>[this.baseFilterPredicate,this._baseListEl],()=>S(this._baseListEl,this.baseFilterPredicate)),c(()=>[this.referenceFilterPredicate,this._referenceListEl],()=>S(this._referenceListEl,this.referenceFilterPredicate))])}loadDependencies(){return T({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),flow:()=>import(`@esri/calcite-components/dist/components/calcite-flow`),"flow-item":()=>import(`@esri/calcite-components/dist/components/calcite-flow-item`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),tooltip:()=>import(`@esri/calcite-components/dist/components/calcite-tooltip`)})}destroy(){this._tooltipReferenceMap.clear(),this._destroyOpenedLayerLists()}get _visibleBaseItems(){return this.baseItems?.filter(e=>!e.hidden&&(this.visibleElements.errors||!e.error))}get _visibleReferenceItems(){return this.referenceItems?.filter(e=>!e.hidden&&(this.visibleElements.errors||!e.error))}get _openedPanelItems(){return this._visibleReferenceItems.concat(this._visibleBaseItems).flatten(e=>e.children).filter(({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)}get _totalBaseItems(){return this.viewModel.baseItems.flatten(e=>e.children.filter(e=>e.layer?.type!==`catalog-dynamic-group`)).length}get _totalReferenceItems(){return this.viewModel.referenceItems.flatten(e=>e.children.filter(e=>e.layer?.type!==`catalog-dynamic-group`)).length}get _baseFilterEnabled(){return this._totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this._totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){let{openedLayers:e}=this;return e.toArray().map((t,n)=>this._renderLayerFlowItem(t,n===e.length-1))}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get icon(){return`layers`}set icon(e){this._overrideIfSome(`icon`,e)}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){let{state:e}=this.viewModel,t={[E.hidden]:e===`loading`,[E.disabled]:e===`disabled`};return k(`div`,{class:this.classes(h.base,E.widget,E.panel,t)},this._renderItems())}async _createCatalogLayerList(e){let{default:t}=await import(`./CatalogLayerList.js`),{headingLevel:n,catalogOptions:r,view:i,filterPlaceholder:a,minFilterItems:o,selectionMode:s,visibilityAppearance:c,_onCatalogOpen:l,_onTablesOpen:u,layerTablesEnabled:d}=this;return new t({headingLevel:n,view:i,filterPlaceholder:a,minFilterItems:o,selectionMode:s,visibilityAppearance:c,...r,catalogLayer:e,layerTablesEnabled:d,onCatalogOpen:l,onTablesOpen:u,suppressDeprecationWarning:!0})}_getTableListParams(e){switch(e.type){case`knowledge-graph`:return{...this.knowledgeGraphOptions,tables:e.tables};case`map-image`:return{...this.mapImageOptions,tables:e.subtables};case`tile`:return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){let{default:t}=await import(`./TableList.js`),{headingLevel:n,selectionMode:r,dragEnabled:i}=this;return new t({headingLevel:n,selectionMode:r,dragEnabled:i,...this._getTableListParams(e)})}async _createFlowList(e,t){let{_layerListMap:n}=this,r=n.get(e);if(r)return r;let i=e.type===`catalog`?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||n.set(e,i),i}async _handleOpenedLayersChange(){let{_layerListMap:e,openedLayers:t,openedLayerLists:n}=this;this._openedLayersController?.abort();let r=new AbortController,{signal:i}=r;this._openedLayersController=r,e.forEach((n,r)=>{t.includes(r)||(n.destroy(),e.delete(r))});let a=await Promise.all(t.map(e=>this._createFlowList(e,i)));if(i.aborted)return;n.removeAll(),n.addMany(a);let o=n.at(-1);o?`catalogLayer`in o?(this._set(`catalogLayerList`,o),this._set(`tableList`,null)):(this._set(`catalogLayerList`,null),this._set(`tableList`,o)):(this._set(`catalogLayerList`,null),this._set(`tableList`,null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){return e?k(`calcite-tooltip`,{key:`tooltip-${e.layer?.uid}`,overlayPositioning:`fixed`,referenceElement:this._tooltipReferenceMap.get(e.layer?.uid),topLayerDisabled:this.topLayerDisabled},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter(e=>!e.hidden).toArray().map(e=>this._renderItemTooltipNodes(e))}_renderItemTooltips(){return this._visibleReferenceItems.concat(this._visibleBaseItems)?.toArray().map(e=>this._renderItemTooltipNodes(e))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,M(e))}_renderPanelFlowItems(){let{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map(({title:n,panel:r},i)=>{let a=()=>this._handlePanelFlowItemBack(r);return k(`calcite-flow-item`,{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:n,heading:r.title,headingLevel:this.headingLevel,key:`flow-panel-${r.uid}`,selected:!t.length&&i===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),a()}},r.render(),k(`calcite-button`,{appearance:`transparent`,slot:`footer-start`,width:`full`,onclick:a},this.messagesCommon.back))})}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,M(e))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,M(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,M(e))}_renderItem(e,t,n,r){return k(g,{activeItem:this._activeItem,canMove:this._canMove,css:h,displayMode:P,dragDisabled:t,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:n,parentTitles:r,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:n,newIndex:r}){let i=y(n),a=y(e),o=y(t),s=L(t),c=L(e);s&&c&&this.viewModel.moveListItem({targetItem:i,fromParentItem:o,toParentItem:a,newIndex:r,from:s,to:c})}_handleCalciteListDragEnd({fromEl:e,dragEl:t,oldIndex:n}){n!=null&&e.insertBefore(t,e.children[n])}_sortLayers(e,t){if(e){if(e===this._referenceListEl||e===this._baseListEl){let n=e===this._referenceListEl?`reference`:`base`,r=n===`base`?this.view?.map?.basemap?.baseLayers:n===`reference`?this.view?.map?.basemap?.referenceLayers:null;C(r,t)}else{let n=y(e);if(!n)return;w(n,t)}}}_handleCalciteListChange(e){let{selectionMode:t,selectedItems:n}=this;if(t===`none`)return;let r=e.target.selectedItems.map(e=>y(e)).filter(Boolean);n.removeAll(),n.addMany(r)}_renderEditingInput(){let{messages:e}=this,{basemapTitle:t}=this.viewModel;return k(`div`,{class:h.editing},k(`calcite-label`,null,e.basemapTitle,k(`calcite-input`,{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:`basemaptitle`,pattern:`.*\\S+.*`,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:`text`,value:t??void 0})))}_renderCancelButton(){let{messagesCommon:{cancel:e}}=this;return k(`calcite-button`,{appearance:`outline`,bind:this,label:e,slot:`footer`,title:e,width:`full`,onclick:this._toggleEditingTitle},e)}_renderSubmitButton(){let{messagesCommon:e}=this;return k(`calcite-button`,{label:e.form.submit,slot:`footer`,title:e.form.submit,type:`submit`,width:`full`},e.form.ok)}_renderEditingFlowItem(){return this.editingTitle?k(`calcite-flow-item`,{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,selected:this.openedLayers.length===0&&this._openedPanelItems.length===0,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton()):null}_renderEditTitleButton(){let{editingTitle:e,visibleElements:t,messagesCommon:n}=this,r=n.edit;return t.editTitleButton&&!e?k(`calcite-action`,{bind:this,icon:`pencil`,slot:`header-actions-end`,text:r,title:r,onclick:this._toggleEditingTitle}):null}_renderNoLayersInfoMessage(e){return k(`div`,{slot:`message`},e)}_renderNoLayersInfo(e,t){return k(`div`,{class:h.itemMessage},k(`calcite-notice`,{icon:`information`,key:t,kind:`info`,open:!0,width:`full`},this._renderNoLayersInfoMessage(e)))}_renderItems(){let{collapsed:e,visible:t,visibleElements:{closeButton:n,collapseButton:r,heading:i,flow:a},messages:o,viewModel:s}=this,c=[k(`calcite-flow-item`,{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:n,closed:!t,collapsed:e,collapsible:r,heading:i?s.basemapTitle??o.widgetLabel:void 0,headingLevel:this.headingLevel,key:`root-flow-item`,selected:!this.editingTitle&&this.openedLayers.length===0&&this._openedPanelItems.length===0,onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(),this._renderBaseSection()),this._renderEditingFlowItem(),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems],l=a?k(`calcite-flow`,{key:`root-flow`},c):c;return t?[this.editingTitle?k(`form`,{bind:this,class:h.editingForm,onsubmit:this._formSubmit},l):l,this._renderItemTooltips()]:null}_renderLayerFlowItem(e,t){let{messages:n,openedLayers:r}=this,i=e.title||this.messages.untitledLayer;return k(`calcite-flow-item`,{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:i,heading:n[e.type===`catalog`?`catalogLayers`:`tables`],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),r.pop();let t=r.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderList(e,t,n){let{messages:r,dragEnabled:i,selectionMode:a,filterPlaceholder:o,baseFilterText:s,referenceFilterText:c,_baseFilterEnabled:l,_referenceFilterEnabled:u,_rootGroupUid:d}=this,f=t===`reference`?r.noReferenceLayers:r.noBaseLayers,p=t===`reference`?u:l;return k(`calcite-block`,{class:h.section,collapsible:!0,expanded:!0,heading:t===`reference`?r.referenceHeading:r.baseHeading,headingLevel:D(this.headingLevel),key:`block-${t}`},e?.length?null:this._renderNoLayersInfo(f,t),k(`calcite-list`,{afterCreate:e=>{t===`reference`?this._referenceListEl=e:this._baseListEl=e,e.addEventListener(`focusin`,this._setActiveItem),e.addEventListener(`focusout`,this._clearActiveItem)},afterRemoved:e=>{t===`reference`?this._referenceListEl=null:this._baseListEl=null,e.removeEventListener(`focusin`,this._setActiveItem),e.removeEventListener(`focusout`,this._clearActiveItem)},canPull:e=>this._canMove(e,`pull`),canPut:e=>this._canMove(e,`put`),displayMode:P,filterProps:O,[F]:t,"data-layer-type":d,dragEnabled:i,filterEnabled:p,filterPlaceholder:o,filterText:p?t===`reference`?c:s:``,group:d,key:`list-${t}`,label:r.widgetLabel,selectionAppearance:`border`,selectionMode:a,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this[t===`reference`?`referenceFilterText`:`baseFilterText`]=e.currentTarget?.filterText??``,onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail),onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem},e?.toArray().map(e=>this._renderItem(e,n)),p?k(`div`,{class:h.filterNoResults,slot:`filter-no-results`},k(`calcite-notice`,{kind:`info`,open:!0,width:`full`},this._renderNoLayersInfoMessage(f))):null))}_renderBaseSection(){let{_visibleBaseItems:e}=this;return this.visibleElements.baseLayers?this._renderList(e,`base`,e?.length===1):null}_renderReferenceSection(){return this.visibleElements.referenceLayers?this._renderList(this._visibleReferenceItems,`reference`,!1):null}_toggleEditingTitle(){let{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();let t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};e([u()],I.prototype,`_baseListEl`,void 0),e([u()],I.prototype,`_referenceListEl`,void 0),e([u()],I.prototype,`_activeItem`,void 0),e([u()],I.prototype,`_tooltipReferenceMap`,void 0),e([u()],I.prototype,`_focusRootFlowItem`,void 0),e([u()],I.prototype,`_focusPanelFlowItem`,void 0),e([u()],I.prototype,`_focusLayerFlowItem`,void 0),e([u()],I.prototype,`_focusEditingFlowItem`,void 0),e([u()],I.prototype,`_layerListMap`,void 0),e([u()],I.prototype,`_visibleBaseItems`,null),e([u()],I.prototype,`_visibleReferenceItems`,null),e([u()],I.prototype,`_openedPanelItems`,null),e([u()],I.prototype,`_totalBaseItems`,null),e([u()],I.prototype,`_totalReferenceItems`,null),e([u()],I.prototype,`_baseFilterEnabled`,null),e([u()],I.prototype,`_referenceFilterEnabled`,null),e([u()],I.prototype,`_renderedOpenLayerFlowItems`,null),e([u()],I.prototype,`basemapTitle`,null),e([u({readOnly:!0})],I.prototype,`catalogLayerList`,void 0),e([u()],I.prototype,`catalogOptions`,void 0),e([u()],I.prototype,`collapsed`,void 0),e([u()],I.prototype,`dragEnabled`,void 0),e([u()],I.prototype,`editingTitle`,void 0),e([u()],I.prototype,`filterPlaceholder`,void 0),e([u()],I.prototype,`baseFilterPredicate`,void 0),e([u()],I.prototype,`baseFilterText`,void 0),e([u()],I.prototype,`referenceFilterPredicate`,void 0),e([u()],I.prototype,`referenceFilterText`,void 0),e([u()],I.prototype,`listItemCanGiveFunction`,void 0),e([u()],I.prototype,`listItemCanReceiveFunction`,void 0),e([u()],I.prototype,`baseListItemCreatedFunction`,null),e([u()],I.prototype,`headingLevel`,void 0),e([u()],I.prototype,`icon`,null),e([u()],I.prototype,`knowledgeGraphOptions`,void 0),e([u()],I.prototype,`label`,null),e([u()],I.prototype,`layerTablesEnabled`,void 0),e([u()],I.prototype,`mapImageOptions`,void 0),e([u(),A(`esri/widgets/BasemapLayerList/t9n/BasemapLayerList`)],I.prototype,`messages`,void 0),e([u(),A(`esri/t9n/common`)],I.prototype,`messagesCommon`,void 0),e([u()],I.prototype,`minFilterItems`,void 0),e([u({readOnly:!0})],I.prototype,`openedLayers`,void 0),e([u({readOnly:!0})],I.prototype,`openedLayerLists`,void 0),e([u()],I.prototype,`referenceListItemCreatedFunction`,null),e([u({readOnly:!0})],I.prototype,`tableList`,void 0),e([u({readOnly:!0})],I.prototype,`baseItems`,null),e([u({readOnly:!0})],I.prototype,`referenceItems`,null),e([u({type:N})],I.prototype,`selectedItems`,void 0),e([u()],I.prototype,`selectionMode`,void 0),e([u()],I.prototype,`tileOptions`,void 0),e([u()],I.prototype,`view`,null),e([j(`trigger-action`),u({type:p})],I.prototype,`viewModel`,void 0),e([u()],I.prototype,`visibilityAppearance`,void 0),e([u({type:m,nonNullable:!0})],I.prototype,`visibleElements`,void 0),I=e([d(`esri.widgets.BasemapLayerList`)],I);function L(e){return e?.closest(`[${F}]`)?.getAttribute(F)}const R=I;export{R as default};
2
+ import{__decorate as e}from"tslib";import t from"../core/Collection.js";import{deprecateWidget as n}from"../core/deprecate.js";import{IdentifiableMixin as r}from"../core/Identifiable.js";import i from"../core/Logger.js";import a from"../core/ReactiveMap.js";import{on as o,initial as s,watch as c,syncAndInitial as l}from"../core/reactiveUtils.js";import{property as u,subclass as d}from"../core/accessorSupport/decorators.js";import f from"./Widget.js";import p from"./BasemapLayerList/BasemapLayerListViewModel.js";import m from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as h}from"./BasemapLayerList/css.js";import g from"./LayerList/LayerListItem.js";import _ from"./LayerList/ListItem.js";import{minFilterItems as v,getItem as y,getLayerType as b,removeDestroyedListItems as x,setFilterPredicate as S,sortLayersToIds as C,sortChildLayersToIds as w}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import{globalCss as E}from"./support/globalCss.js";import{incrementHeadingLevel as D}from"./support/Heading.js";import{calciteListFilterProps as O}from"./support/listUtils.js";import{tsx as k,messageBundle as A,vmEvent as j}from"./support/widget.js";import{setFocus as M}from"./support/widgetUtils.js";const N=t.ofType(_),P=`nested`,F=`data-basemap-layer-type`;let I=class extends r(f){constructor(e,r){super(e,r),this._baseListEl=null,this._referenceListEl=null,this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._focusEditingFlowItem=!1,this._layerListMap=new a,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder=``,this.baseFilterPredicate=null,this.baseFilterText=``,this.referenceFilterPredicate=null,this.referenceFilterText=``,this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t([`knowledge-graph`]),this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minFilterItems=v,this.openedLayers=new t,this.openedLayerLists=new t,this.tableList=null,this.selectedItems=new N,this.selectionMode=`none`,this.tileOptions=null,this.viewModel=new p({suppressDeprecationWarning:!0}),this.visibilityAppearance=`default`,this.visibleElements=new m,this._canMove=({dragEl:e,fromEl:t,toEl:n},r)=>{let i=r===`pull`?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,a=y(e);if(!a?.sortable)return!1;let o=y(t),s=b(t),c=y(n),l=b(n),u=!!s&&!!l&&s===l,d={selected:a,from:o,to:c},f=t.group,p=n.group,m=o?.layer?.type??``,h=c?.layer?.type??``,g=new Set([`map-image`,`catalog`,`knowledge-graph`]);return f&&p&&typeof i==`function`?i.call(null,d):u&&!g.has(m)&&!g.has(h)&&a?.layer?.type!==`sublayer`},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if(this.visibilityAppearance!=="default")return;let t=Array.from(e.composedPath()).find(e=>e.classList?.contains(h.item));this._activeItem=y(t)},this._onCalciteListOrderChange=e=>{let{_lastDragDetail:t}=this,{toEl:n,fromEl:r,dragEl:i,newIndex:a}=e,o=t?.newIndex===a&&t?.dragEl===i&&t?.toEl===n&&t?.fromEl===r;if(!r||!n||o)return;this._lastDragDetail=e,this._selectedDragItemLayerUid=i.value;let s=r,c=n;if(s===c){let e=Array.from(r.children).filter(e=>e?.matches(`calcite-list-item`)).map(e=>e.value);this._sortLayers(s,e)}else a!=null&&this._moveLayerFromChildList({toEl:c,fromEl:s,dragEl:i,newIndex:a})},this.announceDeprecation=()=>{n(i.getLogger(this),`Basemap Layer List (Next)`,`arcgis-basemap-layer-list-next`,{version:`5.0`})}}initialize(){this.addHandles([o(()=>this.openedLayers,`change`,()=>this._handleOpenedLayersChange(),s),c(()=>[this.viewModel.referenceItems.toArray(),this.viewModel.baseItems.toArray()],()=>x(this.selectedItems),l),c(()=>[this.baseFilterPredicate,this._baseListEl],()=>S(this._baseListEl,this.baseFilterPredicate)),c(()=>[this.referenceFilterPredicate,this._referenceListEl],()=>S(this._referenceListEl,this.referenceFilterPredicate))])}loadDependencies(){return T({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),flow:()=>import(`@esri/calcite-components/dist/components/calcite-flow`),"flow-item":()=>import(`@esri/calcite-components/dist/components/calcite-flow-item`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),tooltip:()=>import(`@esri/calcite-components/dist/components/calcite-tooltip`)})}destroy(){this._tooltipReferenceMap.clear(),this._destroyOpenedLayerLists()}get _visibleBaseItems(){return this.baseItems?.filter(e=>!e.hidden&&(this.visibleElements.errors||!e.error))}get _visibleReferenceItems(){return this.referenceItems?.filter(e=>!e.hidden&&(this.visibleElements.errors||!e.error))}get _openedPanelItems(){return this._visibleReferenceItems.concat(this._visibleBaseItems).flatten(e=>e.children).filter(({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)}get _totalBaseItems(){return this.viewModel.baseItems.flatten(e=>e.children.filter(e=>e.layer?.type!==`catalog-dynamic-group`)).length}get _totalReferenceItems(){return this.viewModel.referenceItems.flatten(e=>e.children.filter(e=>e.layer?.type!==`catalog-dynamic-group`)).length}get _baseFilterEnabled(){return this._totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this._totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){let{openedLayers:e}=this;return e.toArray().map((t,n)=>this._renderLayerFlowItem(t,n===e.length-1))}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get icon(){return`layers`}set icon(e){this._overrideIfSome(`icon`,e)}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){let{state:e}=this.viewModel,t={[E.hidden]:e===`loading`,[E.disabled]:e===`disabled`};return k(`div`,{class:this.classes(h.base,E.widget,E.panel,t)},this._renderItems())}async _createCatalogLayerList(e){let{default:t}=await import(`./CatalogLayerList.js`),{headingLevel:n,catalogOptions:r,view:i,filterPlaceholder:a,minFilterItems:o,selectionMode:s,visibilityAppearance:c,_onCatalogOpen:l,_onTablesOpen:u,layerTablesEnabled:d}=this;return new t({headingLevel:n,view:i,filterPlaceholder:a,minFilterItems:o,selectionMode:s,visibilityAppearance:c,...r,catalogLayer:e,layerTablesEnabled:d,onCatalogOpen:l,onTablesOpen:u,suppressDeprecationWarning:!0})}_getTableListParams(e){switch(e.type){case`knowledge-graph`:return{...this.knowledgeGraphOptions,tables:e.tables};case`map-image`:return{...this.mapImageOptions,tables:e.subtables};case`tile`:return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){let{default:t}=await import(`./TableList.js`),{headingLevel:n,selectionMode:r,dragEnabled:i}=this;return new t({headingLevel:n,selectionMode:r,dragEnabled:i,...this._getTableListParams(e)})}async _createFlowList(e,t){let{_layerListMap:n}=this,r=n.get(e);if(r)return r;let i=e.type===`catalog`?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||n.set(e,i),i}async _handleOpenedLayersChange(){let{_layerListMap:e,openedLayers:t,openedLayerLists:n}=this;this._openedLayersController?.abort();let r=new AbortController,{signal:i}=r;this._openedLayersController=r,e.forEach((n,r)=>{t.includes(r)||(n.destroy(),e.delete(r))});let a=await Promise.all(t.map(e=>this._createFlowList(e,i)));if(i.aborted)return;n.removeAll(),n.addMany(a);let o=n.at(-1);o?`catalogLayer`in o?(this._set(`catalogLayerList`,o),this._set(`tableList`,null)):(this._set(`catalogLayerList`,null),this._set(`tableList`,o)):(this._set(`catalogLayerList`,null),this._set(`tableList`,null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){return e?k(`calcite-tooltip`,{key:`tooltip-${e.layer?.uid}`,overlayPositioning:`fixed`,referenceElement:this._tooltipReferenceMap.get(e.layer?.uid),topLayerDisabled:this.topLayerDisabled},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter(e=>!e.hidden).toArray().map(e=>this._renderItemTooltipNodes(e))}_renderItemTooltips(){return this._visibleReferenceItems.concat(this._visibleBaseItems)?.toArray().map(e=>this._renderItemTooltipNodes(e))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,M(e))}_renderPanelFlowItems(){let{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map(({title:n,panel:r},i)=>{let a=()=>this._handlePanelFlowItemBack(r);return k(`calcite-flow-item`,{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:n,heading:r.title,headingLevel:this.headingLevel,key:`flow-panel-${r.uid}`,selected:!t.length&&i===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),a()}},r.render(),k(`calcite-button`,{appearance:`transparent`,slot:`footer-start`,width:`full`,onclick:a},this.messagesCommon.back))})}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,M(e))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,M(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,M(e))}_renderItem(e,t,n,r){return k(g,{activeItem:this._activeItem,canMove:this._canMove,css:h,displayMode:P,dragDisabled:t,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:n,parentTitles:r,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:n,newIndex:r}){let i=y(n),a=y(e),o=y(t),s=L(t),c=L(e);s&&c&&this.viewModel.moveListItem({targetItem:i,fromParentItem:o,toParentItem:a,newIndex:r,from:s,to:c})}_handleCalciteListDragEnd({fromEl:e,dragEl:t,oldIndex:n}){n!=null&&e.insertBefore(t,e.children[n])}_sortLayers(e,t){if(e){if(e===this._referenceListEl||e===this._baseListEl){let n=e===this._referenceListEl?`reference`:`base`,r=n===`base`?this.view?.map?.basemap?.baseLayers:n===`reference`?this.view?.map?.basemap?.referenceLayers:null;C(r,t)}else{let n=y(e);if(!n)return;w(n,t)}}}_handleCalciteListChange(e){let{selectionMode:t,selectedItems:n}=this;if(t===`none`)return;let r=e.target.selectedItems.map(e=>y(e)).filter(Boolean);n.removeAll(),n.addMany(r)}_renderEditingInput(){let{messages:e}=this,{basemapTitle:t}=this.viewModel;return k(`div`,{class:h.editing},k(`calcite-label`,null,e.basemapTitle,k(`calcite-input`,{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:`basemaptitle`,pattern:`.*\\S+.*`,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:`text`,value:t??void 0})))}_renderCancelButton(){let{messagesCommon:{cancel:e}}=this;return k(`calcite-button`,{appearance:`outline`,bind:this,label:e,slot:`footer`,title:e,width:`full`,onclick:this._toggleEditingTitle},e)}_renderSubmitButton(){let{messagesCommon:e}=this;return k(`calcite-button`,{label:e.form.submit,slot:`footer`,title:e.form.submit,type:`submit`,width:`full`},e.form.ok)}_renderEditingFlowItem(){return this.editingTitle?k(`calcite-flow-item`,{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,selected:this.openedLayers.length===0&&this._openedPanelItems.length===0,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton()):null}_renderEditTitleButton(){let{editingTitle:e,visibleElements:t,messagesCommon:n}=this,r=n.edit;return t.editTitleButton&&!e?k(`calcite-action`,{bind:this,icon:`pencil`,slot:`header-actions-end`,text:r,title:r,onclick:this._toggleEditingTitle}):null}_renderNoLayersInfoMessage(e){return k(`div`,{slot:`message`},e)}_renderNoLayersInfo(e,t){return k(`div`,{class:h.itemMessage},k(`calcite-notice`,{icon:`information`,key:t,kind:`info`,open:!0,width:`full`},this._renderNoLayersInfoMessage(e)))}_renderItems(){let{collapsed:e,visible:t,visibleElements:{closeButton:n,collapseButton:r,heading:i,flow:a},messages:o,viewModel:s}=this,c=[k(`calcite-flow-item`,{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:n,closed:!t,collapsed:e,collapsible:r,heading:i?s.basemapTitle??o.widgetLabel:void 0,headingLevel:this.headingLevel,key:`root-flow-item`,selected:!this.editingTitle&&this.openedLayers.length===0&&this._openedPanelItems.length===0,onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(),this._renderBaseSection()),this._renderEditingFlowItem(),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems],l=a?k(`calcite-flow`,{key:`root-flow`},c):c;return t?[this.editingTitle?k(`form`,{bind:this,class:h.editingForm,onsubmit:this._formSubmit},l):l,this._renderItemTooltips()]:null}_renderLayerFlowItem(e,t){let{messages:n,openedLayers:r}=this,i=e.title||this.messages.untitledLayer;return k(`calcite-flow-item`,{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:i,heading:n[e.type===`catalog`?`catalogLayers`:`tables`],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),r.pop();let t=r.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderList(e,t,n){let{messages:r,dragEnabled:i,selectionMode:a,filterPlaceholder:o,baseFilterText:s,referenceFilterText:c,_baseFilterEnabled:l,_referenceFilterEnabled:u,_rootGroupUid:d}=this,f=t===`reference`?r.noReferenceLayers:r.noBaseLayers,p=t===`reference`?u:l;return k(`calcite-block`,{class:h.section,expandable:!0,expanded:!0,heading:t===`reference`?r.referenceHeading:r.baseHeading,headingLevel:D(this.headingLevel),key:`block-${t}`},e?.length?null:this._renderNoLayersInfo(f,t),k(`calcite-list`,{afterCreate:e=>{t===`reference`?this._referenceListEl=e:this._baseListEl=e,e.addEventListener(`focusin`,this._setActiveItem),e.addEventListener(`focusout`,this._clearActiveItem)},afterRemoved:e=>{t===`reference`?this._referenceListEl=null:this._baseListEl=null,e.removeEventListener(`focusin`,this._setActiveItem),e.removeEventListener(`focusout`,this._clearActiveItem)},canPull:e=>this._canMove(e,`pull`),canPut:e=>this._canMove(e,`put`),displayMode:P,filterProps:O,[F]:t,"data-layer-type":d,dragEnabled:i,filterEnabled:p,filterPlaceholder:o,filterText:p?t===`reference`?c:s:``,group:d,key:`list-${t}`,label:r.widgetLabel,selectionAppearance:`border`,selectionMode:a,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this[t===`reference`?`referenceFilterText`:`baseFilterText`]=e.currentTarget?.filterText??``,onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail),onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem},e?.toArray().map(e=>this._renderItem(e,n)),p?k(`div`,{class:h.filterNoResults,slot:`filter-no-results`},k(`calcite-notice`,{kind:`info`,open:!0,width:`full`},this._renderNoLayersInfoMessage(f))):null))}_renderBaseSection(){let{_visibleBaseItems:e}=this;return this.visibleElements.baseLayers?this._renderList(e,`base`,e?.length===1):null}_renderReferenceSection(){return this.visibleElements.referenceLayers?this._renderList(this._visibleReferenceItems,`reference`,!1):null}_toggleEditingTitle(){let{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();let t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};e([u()],I.prototype,`_baseListEl`,void 0),e([u()],I.prototype,`_referenceListEl`,void 0),e([u()],I.prototype,`_activeItem`,void 0),e([u()],I.prototype,`_tooltipReferenceMap`,void 0),e([u()],I.prototype,`_focusRootFlowItem`,void 0),e([u()],I.prototype,`_focusPanelFlowItem`,void 0),e([u()],I.prototype,`_focusLayerFlowItem`,void 0),e([u()],I.prototype,`_focusEditingFlowItem`,void 0),e([u()],I.prototype,`_layerListMap`,void 0),e([u()],I.prototype,`_visibleBaseItems`,null),e([u()],I.prototype,`_visibleReferenceItems`,null),e([u()],I.prototype,`_openedPanelItems`,null),e([u()],I.prototype,`_totalBaseItems`,null),e([u()],I.prototype,`_totalReferenceItems`,null),e([u()],I.prototype,`_baseFilterEnabled`,null),e([u()],I.prototype,`_referenceFilterEnabled`,null),e([u()],I.prototype,`_renderedOpenLayerFlowItems`,null),e([u()],I.prototype,`basemapTitle`,null),e([u({readOnly:!0})],I.prototype,`catalogLayerList`,void 0),e([u()],I.prototype,`catalogOptions`,void 0),e([u()],I.prototype,`collapsed`,void 0),e([u()],I.prototype,`dragEnabled`,void 0),e([u()],I.prototype,`editingTitle`,void 0),e([u()],I.prototype,`filterPlaceholder`,void 0),e([u()],I.prototype,`baseFilterPredicate`,void 0),e([u()],I.prototype,`baseFilterText`,void 0),e([u()],I.prototype,`referenceFilterPredicate`,void 0),e([u()],I.prototype,`referenceFilterText`,void 0),e([u()],I.prototype,`listItemCanGiveFunction`,void 0),e([u()],I.prototype,`listItemCanReceiveFunction`,void 0),e([u()],I.prototype,`baseListItemCreatedFunction`,null),e([u()],I.prototype,`headingLevel`,void 0),e([u()],I.prototype,`icon`,null),e([u()],I.prototype,`knowledgeGraphOptions`,void 0),e([u()],I.prototype,`label`,null),e([u()],I.prototype,`layerTablesEnabled`,void 0),e([u()],I.prototype,`mapImageOptions`,void 0),e([u(),A(`esri/widgets/BasemapLayerList/t9n/BasemapLayerList`)],I.prototype,`messages`,void 0),e([u(),A(`esri/t9n/common`)],I.prototype,`messagesCommon`,void 0),e([u()],I.prototype,`minFilterItems`,void 0),e([u({readOnly:!0})],I.prototype,`openedLayers`,void 0),e([u({readOnly:!0})],I.prototype,`openedLayerLists`,void 0),e([u()],I.prototype,`referenceListItemCreatedFunction`,null),e([u({readOnly:!0})],I.prototype,`tableList`,void 0),e([u({readOnly:!0})],I.prototype,`baseItems`,null),e([u({readOnly:!0})],I.prototype,`referenceItems`,null),e([u({type:N})],I.prototype,`selectedItems`,void 0),e([u()],I.prototype,`selectionMode`,void 0),e([u()],I.prototype,`tileOptions`,void 0),e([u()],I.prototype,`view`,null),e([j(`trigger-action`),u({type:p})],I.prototype,`viewModel`,void 0),e([u()],I.prototype,`visibilityAppearance`,void 0),e([u({type:m,nonNullable:!0})],I.prototype,`visibleElements`,void 0),I=e([d(`esri.widgets.BasemapLayerList`)],I);function L(e){return e?.closest(`[${F}]`)?.getAttribute(F)}const R=I;export{R as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{destroyMaybe as a}from"../core/maybe.js";import o from"../core/ReactiveMap.js";import{watch as s,when as c,on as l,sync as u}from"../core/reactiveUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import ee from"./Widget.js";import{getAttachmentTypeCategory as te,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as v,isImageAttachment as y,getAttachmentFilenameParts as b}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as ne,getMessageString as x,isElementTemplateWithInputType as S,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import C from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as w}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as ae,makeViewingAttachmentFooterButtons as oe,makeCancelFooterButton as T,makeDefaultFooterButtons as E}from"./BatchAttributeForm/interfaceUtils.js";import D from"./BatchAttributeForm/VisibleElements.js";import{isDynamicChoiceController as O,isMultipleChoiceController as k}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as A,isFieldInput as j,isTextElementInput as se,isRelationshipElementInput as ce,isAttachmentElementInput as le,isUtilityNetworkAssociationsElementInput as M,differentValuesString as N,getNormalizedFieldName as P,isGroupedInput as F}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as I,otherChoiceCheckedPlaceholderValue as L,canRestoreMultipleChoiceOtherChoiceDraftValue as R}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as z,RelationshipDetails as B}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as V}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as H}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as U}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as ue,getIntlOptionsForField as de,prepareISOFieldValueForDateComponents as W,prepareUnixFieldValueForDateComponents as G,normalizeTimeOnlyString as K,getISOFieldValueFromDateComponents as fe,getUnixFieldValueFromDateComponents as pe}from"./support/dateUtils.js";import{globalCss as q}from"./support/globalCss.js";import{Heading as me}from"./support/Heading.js";import{calciteListFilterProps as he}from"./support/listUtils.js";import{messageBundle as J,vmEvent as ge,tsx as Y}from"./support/widget.js";import{setFocus as _e}from"./support/widgetUtils.js";import{isEmptyValue as X}from"./support/forms/formUtils.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ee{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new C,this.visibleElements=new D,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new o,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._dynamicChoiceItemSelections=new WeakSet,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText=``,this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{let e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=v(e.attachment);this.viewModel.stageRenameAttachment(n,r,t)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{n(r.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([s(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),I(this.viewModel,{includeDraftValues:!0})}),s(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),I(this.viewModel),this._setFocusableInput()}),s(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),c(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),s(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),s(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),l(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),s(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),u),s(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),s(()=>this.groupDisplay,()=>this._syncGroupInputStates())])}loadDependencies(){return Promise.all([U({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),checkbox:()=>import(`@esri/calcite-components/dist/components/calcite-checkbox`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),combobox:()=>import(`@esri/calcite-components/dist/components/calcite-combobox`),"combobox-item":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item`),"combobox-item-group":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item-group`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-message":()=>import(`@esri/calcite-components/dist/components/calcite-input-message`),"input-number":()=>import(`@esri/calcite-components/dist/components/calcite-input-number`),"input-time-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-picker`),"input-time-zone":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-zone`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),"list-item":()=>import(`@esri/calcite-components/dist/components/calcite-list-item`),loader:()=>import(`@esri/calcite-components/dist/components/calcite-loader`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),"text-area":()=>import(`@esri/calcite-components/dist/components/calcite-text-area`),"radio-button":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button`),"radio-button-group":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button-group`)}),z()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=a(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:``:``}get effectiveDisabled(){return this.disabledOrReadOnly||this.viewModel.updating}get disabledOrReadOnly(){return this.disabled||this.readOnly}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?ae({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):oe({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?T({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?T({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:E({disabled:r||!this.valid,formId:this._formId,messages:e,callback:()=>this.submit()})}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return`edit-attributes`}set icon(e){this._overrideIfSome(`icon`,e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return Y(`div`,{class:this.classes(w.base,q.widget,q.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?Y(V,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice}}_setDateTimeTimeZoneMap(e){let{datePart:t,elementId:n}=e.dataset,r=i(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:n}=this,{status:r}=n;if(r===`failed`)return n.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:n.maximumFeatureCountWithComplexForms})):n.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:n.maximumFeatureCount})):e.formFailedToLoad;if(n.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(r===`loading`&&this.visibleElements.loadingIndicator)return Y(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return Y(`calcite-notice`,{class:w.noticeError,icon:!0,kind:t,open:!0},Y(`div`,{slot:`message`},e))}_renderForm(){return Y(`form`,{class:w.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case`adding-attachments`:return this._renderAttachmentAddPage();case`viewing-attachment-details`:case`replacing-attachment`:return this._renderAttachmentDetailPage();case`viewing-attachments`:return this._renderAttachmentListPage();case`viewing-associated-layers`:case`viewing-associated-features`:return this._renderViewingAssociationsPage();case`viewing-related-categories`:case`viewing-related-records`:return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=ne(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return Y(`calcite-notice`,{class:w.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?Y(me,{key:`title`,level:this.headingLevel},e):void 0,r=t?Y(`p`,{class:w.description,key:`description`},t):void 0;return Y(`div`,{class:w.formHeader},n,r)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){if(A(e))return this._renderGroupInput(e);if(j(e))return this._renderLabeledField(e);if(se(e))return this._renderTextComponent(e);if(ce(e))return this._renderRelationshipElementInput(e);if(le(e))return this._renderAttachmentElementInput(e);if(M(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return Y(`calcite-block`,{class:this.classes(w.group,s?w.groupSequential:null,o?w.groupActive:null,this.disabled?w.inputDisabled:null),collapsible:!0,description:e.description??void 0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0},onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:n}=e.template,{label:r,required:i,dataType:a}=e,o=i?t(this.messages.requiredFieldLabel,{name:r}):r;return Y(`calcite-label`,{"aria-label":o,class:w.label,key:`field--${n}`},Y(`div`,{class:w.labelTextContent,key:`labelTextContainer`},r,i?Y(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),a===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return O(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):k(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=x(e,e.validationMessage,this.messages);return n?Y(`calcite-input-message`,{icon:!0,status:e.status},n):t?Y(`calcite-input-message`,{class:w.description,icon:!1,status:e.status},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=e.showNoValueLabel||this.messages.empty,a=n.evaluated&&!n.evaluating&&!n.choices.length&&Y(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,scale:`s`,slot:`content-bottom`,width:`full`},Y(`div`,{slot:`message`},e.showNoValueOptionEnabled?this.messages.noDynamicChoicesWithNoValue:this.messages.noDynamicChoices)),o=t=>{this._saveInput(e,t)},s=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}o(t)},c=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&o(null)},l=e.showNoValueOptionEnabled?Y(`calcite-autocomplete-item`,{heading:i,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,u=t=>{t.inputValue=e.value===N?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue};return Y(`calcite-autocomplete`,{...t,afterCreate:u,disabled:t.readOnly||t.disabled,placeholder:e.value==null?i:t.placeholder,value:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:c},n.evaluating?Y(`calcite-loader`,{key:`dynamic-choice-loader`,label:this.messagesCommon.loading,scale:`s`,slot:`content-top`}):[a,l,...r.map(t=>Y(`calcite-autocomplete-item`,{heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}))])}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return Y(`div`,{class:w.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return Y(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:w.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return Y(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return Y(`div`,{class:this.classes(w.multipleChoiceOtherChoice,t?w.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},Y(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?Y(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:w.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===N?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===N?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){e.touch();let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=P(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),e.touch(),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=P(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!X(e))continue;let t=r.getOtherChoiceDraftValue(i),n=R(t)?t:L;a.set(i,n)}else e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===N||e.value===N)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:N,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return Y(`calcite-switch`,{...t,checked:S(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:w.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return Y(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},Y(`calcite-button`,{...r},e===N?this.messages.differentValuesPlaceholder:e),Y(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>Y(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`&&e.showNoValueOptionEnabled&&!e.touched?()=>{}:n.onblur,i={...n,onblur:r};return Y(`calcite-combobox`,{...i,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?N:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==N&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=X(e.value)?this.messages.empty:e.name;return Y(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(Y(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(Y(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(Y(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&X(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(Y(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(Y(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:N,selected:!0,value:N})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=X(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return Y(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:w.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?Y(`calcite-label`,{class:w.placeholderRadio,key:n.label,layout:`inline`},Y(`calcite-radio-button`,{checked:!0,class:w.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return Y(`calcite-label`,{class:w.inputRadioLabel,key:r.label,layout:`inline`},Y(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:w.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?Y(`calcite-text-area`,{...t,class:this.classes(w.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):Y(`calcite-input`,{...t,class:this.classes(w.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return Y(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return Y(`calcite-input`,{...n,class:this.classes(w.fieldInput,w.inputDisabled,w.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,ue(n,t.value,{timeZone:e.effectiveTimeZone,...de(e.template.field)}))}return e.value===N?[r,Y(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return Y(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===N?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return Y(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===N?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=W(c,u),f=W(l,u),p=W(e.value===N?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return Y(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},Y(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),Y(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?Y(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===N||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=G(e.value===N?``:e.value,c),u=G(s,c),d=G(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return Y(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},Y(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?Y(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?Y(B,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return Y(`div`,{class:w.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?Y(`div`,{class:w.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?Y(`div`,{class:w.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):Y(`div`,{class:w.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return Y(`div`,{class:w.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return Y(`calcite-list`,{class:w.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?he:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=v(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return Y(`calcite-list-item`,{class:w.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},Y(`div`,{class:w.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?Y(`span`,{class:w.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[Y(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,v(t))})]:u?Y(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):Y(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,n){let{elementId:r}=e.template,{viewAll:i}=this.messages.attachments;return Y(`calcite-list-item`,{class:w.attachmentElementListItem,description:t(this.messages.attachments.count,{count:n}),key:`attachment-item-view-all-${r}`,label:i,onCalciteListItemSelect:()=>this._setAttachmentListElementId(r)},Y(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return Y(`div`,{class:w.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?Y(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?Y(`div`,{class:w.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?Y(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return Y(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ve(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||e.touched}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return Y(`div`,{class:w.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},Y(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:w.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),Y(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},Y(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),Y(`div`,{class:w.attachmentElementAddDropzoneHeading},a.addFile),Y(`div`,{class:w.attachmentElementAddDropzoneDetail,title:o},o),Y(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return Y(`calcite-notice`,{class:w.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},Y(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=v(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return Y(`div`,{class:w.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},Y(`div`,{class:w.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),Y(`div`,{class:w.attachmentElementDetailActions},y(t)?Y(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,Y(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),Y(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),Y(`div`,{class:w.attachmentElementDetailMetadata},Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.size),Y(`span`,{class:w.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.type),Y(`span`,{class:w.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return Y(`span`,{class:w.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=b(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[Y(`div`,{class:w.attachmentElementDetailFileNameRow,key:`file-name-row`},Y(`calcite-input`,{class:w.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),Y(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?Y(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return Y(`div`,{class:w.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${v(t)}`},Y(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:w.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),Y(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},Y(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),Y(`div`,{class:w.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),Y(`div`,{class:w.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),Y(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),Y(`div`,{class:w.attachmentElementDetailMetadata},Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),Y(`span`,{class:w.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return Y(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},Y(`div`,{class:w.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){t?.touch(),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),t.selectedAttachmentAddInput?.touch(),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),t.selectedAttachmentListInput?.touch(),this.hideAttachmentDialog()}_getAttachmentLabel(e,n,r,i){return i!==!1&&g(e.name)&&e.name.length>0?e.name:r===this.messagesCommon.notApplicable?t(this.messages.attachments.attachmentNumberedLabel,{index:n+1}):r}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?Y(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,n,r){let i=`__count__`,[a,o]=t(e,{count:i}).split(i);return Y(`span`,{key:r},a,Y(`span`,{class:w.attachmentElementEmptyActionHintValue},n),o)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:Y(`div`,{class:w.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>Y(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:n}){let r=[],i=e.validationCriterionStates,a=this.messages.attachments,o=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&r.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of o)e.type===`document`&&e.maxFileSize!=null&&r.push({key:`maximum-file-size`,message:t(a.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:i.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&r.push({key:`maximum-audio-length`,message:t(a.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&r.push({key:`maximum-video-length`,message:t(a.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&r.push({key:`maximum-image-size`,message:t(a.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:i.get(`maximum-image-size`)??`info`});return n&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&r.push({key:`minimum-number-of-files`,message:t(a.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:i.get(`minimum-number-of-files`)??`info`}),n&&e.maxAttachmentCount!=null&&r.push({key:`maximum-number-of-files`,message:t(a.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:i.get(`maximum-number-of-files`)??`info`}),r}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:d(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return d(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=te(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&y(e)?Y(`img`,{alt:t,class:w.attachmentElementListItemThumb,src:r}):Y(`calcite-icon`,{class:w.attachmentElementListItemIcon,icon:_(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&y(e)?Y(`img`,{alt:r,class:w.attachmentElementDetailPreviewImage,src:n,title:r}):[Y(`calcite-icon`,{class:w.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await H(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,v(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=v(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return Y(`div`,{class:w.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return Y(`div`,{class:w.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,status:l,range:{max:u,min:d}}=e,f=!c||this.readOnly,p=this.disabled||this.viewModel.updating,m=t.hint??void 0,h=!1;return r===N&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(w.fieldInput,f?w.inputDisabled:null),status:l,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:u??void 0,min:d??void 0,disabled:p,readOnly:f,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,_e(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||n.touch(),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(S(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return k(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:a}=this;if(S(e.template,`switch`)&&a.mode!==`single`){let t=i(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(e.touch(),!e.isSubtypeField||a.mode===`batch`||!re(a.activeLayer,r,t)?a.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,n){let{value:r,template:i}=e,{elementId:a}=i,{messages:o,viewModel:s,messagesCommon:c}=this,{subtypes:l,activeFeatureIndex:u}=s;if(await s.setValue(a,n),!l?.length)return;let d=l.find(e=>e.code===n),f=l.find(e=>e.code===r)?.name??`${r}`;if(!d)return;let p=Promise.withResolvers();s.pendingSubtypeChoice=p;let m=`update-fields`,h=[{label:o.subtypes.useDefaultValuesOption,value:`update-fields`},{label:o.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:o.subtypes.changeWarningTitle,message:t(o.subtypes.changeWarning,{originalType:f,newType:d.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:c.apply,action:()=>p.resolve(m),type:`positive`},secondary:{label:c.cancel,type:`neutral`,action:()=>p.resolve(`undo`)}},cancel:()=>p.reject()};try{switch(this.showPrompt(g),await p.promise){case`update-fields`:await s.applySubtypeDefaults(d),await s.handleSubtypeChanged(u);break;case`keep-existing`:await s.handleSubtypeChanged(u);break;case`undo`:await this.viewModel.setValue(a,r)}}finally{s.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===N?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=K(o),s=K(t.value)):s=r===`timestamp-offset`?t.value==null?null:fe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:pe({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===N?void 0:i.time}),o!==s&&(e.touch(),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let e=(await import(`./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js`)).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){let t=(await import(`./Feature/FeatureUtilityNetworkAssociations.js`)).default;return new t({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>a(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&j(e)?e:this._findFocusableInput(e);this._syncGroupInputStates(),this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(A(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=F(e)&&!e.group.open?e.group.inputs.filter(j)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e];if(t.visible&&j(t)){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t),this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(e=>{e!==t&&(e.open=!1)})):t.open=!1,this.scheduleRender()}_syncGroupInputStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([f()],$.prototype,`activeFeatureIndex`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`callbacks`,null),e([f()],$.prototype,`disabled`,null),e([f()],$.prototype,`effectiveTitle`,null),e([f()],$.prototype,`effectiveDisabled`,null),e([f()],$.prototype,`disabledOrReadOnly`,null),e([f()],$.prototype,`features`,null),e([f()],$.prototype,`footerButtonInfos`,null),e([f()],$.prototype,`map`,null),e([f()],$.prototype,`maximumFeatureCount`,null),e([f()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([f()],$.prototype,`spatialReference`,null),e([f()],$.prototype,`layerInfos`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`headingLevel`,void 0),e([f()],$.prototype,`icon`,null),e([f(),J(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([f(),J(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([f(),J(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([f(),J(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([f(),J(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([f()],$.prototype,`page`,null),e([f()],$.prototype,`readOnly`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`selectedAttachment`,null),e([f()],$.prototype,`selectedAttachmentDetails`,null),e([f()],$.prototype,`valid`,null),e([f({type:C}),ge([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([f({type:D,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f()],$.prototype,`groupDisplay`,void 0),e([f()],$.prototype,`_formHeaderVisible`,null),e([f()],$.prototype,`_associationsEnabled`,null),e([f()],$.prototype,`_associationsList`,void 0),e([f()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([f()],$.prototype,`_formId`,null),e([f()],$.prototype,`_focusedFieldInput`,void 0),e([f()],$.prototype,`_pendingSubtypeChoice`,void 0),e([f()],$.prototype,`_relatedRecordsEnabled`,null),e([f()],$.prototype,`_listObserverNode`,void 0),e([f()],$.prototype,`_attachmentDialogInfo`,void 0),e([f()],$.prototype,`_attachmentListFilterText`,void 0),e([f()],$.prototype,`_prompt`,void 0),e([f()],$.prototype,`test`,null),$=e([p(`esri.widgets.BatchAttributeForm`)],$);function ve(e){switch(e){case`audio`:return _(`audio/mpeg`);case`video`:return _(`video/mp4`);case`image`:return _(`image/png`);default:return`camera`}}const ye=$;export{ye as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{destroyMaybe as a}from"../core/maybe.js";import o from"../core/ReactiveMap.js";import{watch as s,when as c,on as l,sync as u}from"../core/reactiveUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import ee from"./Widget.js";import{getAttachmentTypeCategory as te,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as v,isImageAttachment as y,getAttachmentFilenameParts as b}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as ne,getMessageString as x,isElementTemplateWithInputType as S,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import C from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as w}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as ae,makeViewingAttachmentFooterButtons as oe,makeCancelFooterButton as T,makeDefaultFooterButtons as E}from"./BatchAttributeForm/interfaceUtils.js";import D from"./BatchAttributeForm/VisibleElements.js";import{isDynamicChoiceController as O,isMultipleChoiceController as k}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as A,isFieldInput as j,isTextElementInput as se,isRelationshipElementInput as ce,isAttachmentElementInput as le,isUtilityNetworkAssociationsElementInput as ue,differentValuesString as M,getNormalizedFieldName as N,isGroupedInput as P}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as F,otherChoiceCheckedPlaceholderValue as I,canRestoreMultipleChoiceOtherChoiceDraftValue as L}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as R,RelationshipDetails as z}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as B}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as V}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as de,getIntlOptionsForField as fe,prepareISOFieldValueForDateComponents as U,prepareUnixFieldValueForDateComponents as W,normalizeTimeOnlyString as G,getISOFieldValueFromDateComponents as pe,getUnixFieldValueFromDateComponents as me}from"./support/dateUtils.js";import{globalCss as K}from"./support/globalCss.js";import{Heading as he}from"./support/Heading.js";import{calciteListFilterProps as ge}from"./support/listUtils.js";import{messageBundle as q,vmEvent as _e,tsx as J}from"./support/widget.js";import{setFocus as ve}from"./support/widgetUtils.js";import{isEmptyValue as Y,ContingentValuesValidationError as X}from"./support/forms/formUtils.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ee{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new C,this.visibleElements=new D,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new o,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._dynamicChoiceItemSelections=new WeakSet,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText=``,this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{let e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=v(e.attachment);this.viewModel.stageRenameAttachment(n,r,t)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{n(r.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([s(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),F(this.viewModel,{includeDraftValues:!0})}),s(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),F(this.viewModel),this._setFocusableInput()}),s(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),c(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),s(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),s(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),l(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),s(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),u),s(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),s(()=>this.groupDisplay,()=>this._syncGroupInputStates())])}loadDependencies(){return Promise.all([H({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),checkbox:()=>import(`@esri/calcite-components/dist/components/calcite-checkbox`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),combobox:()=>import(`@esri/calcite-components/dist/components/calcite-combobox`),"combobox-item":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item`),"combobox-item-group":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item-group`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-message":()=>import(`@esri/calcite-components/dist/components/calcite-input-message`),"input-number":()=>import(`@esri/calcite-components/dist/components/calcite-input-number`),"input-time-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-picker`),"input-time-zone":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-zone`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),"list-item":()=>import(`@esri/calcite-components/dist/components/calcite-list-item`),loader:()=>import(`@esri/calcite-components/dist/components/calcite-loader`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),"text-area":()=>import(`@esri/calcite-components/dist/components/calcite-text-area`),"radio-button":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button`),"radio-button-group":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button-group`)}),R()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=a(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:``:``}get effectiveDisabled(){return this.disabledOrReadOnly||this.viewModel.updating}get disabledOrReadOnly(){return this.disabled||this.readOnly}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?ae({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):oe({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?T({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?T({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:E({disabled:r||!this.valid,formId:this._formId,messages:e,callback:()=>this.submit()})}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return`edit-attributes`}set icon(e){this._overrideIfSome(`icon`,e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return J(`div`,{class:this.classes(w.base,K.widget,K.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?J(B,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice,touchedInputs:this._touchedInputs}}_setDateTimeTimeZoneMap(e){let{datePart:t,elementId:n}=e.dataset,r=i(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:n}=this,{status:r}=n;if(r===`failed`)return n.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:n.maximumFeatureCountWithComplexForms})):n.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:n.maximumFeatureCount})):e.formFailedToLoad;if(n.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(r===`loading`&&this.visibleElements.loadingIndicator)return J(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return J(`calcite-notice`,{class:w.noticeError,icon:!0,kind:t,open:!0},J(`div`,{slot:`message`},e))}_renderForm(){return J(`form`,{class:w.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case`adding-attachments`:return this._renderAttachmentAddPage();case`viewing-attachment-details`:case`replacing-attachment`:return this._renderAttachmentDetailPage();case`viewing-attachments`:return this._renderAttachmentListPage();case`viewing-associated-layers`:case`viewing-associated-features`:return this._renderViewingAssociationsPage();case`viewing-related-categories`:case`viewing-related-records`:return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=ne(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return J(`calcite-notice`,{class:w.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?J(he,{key:`title`,level:this.headingLevel},e):void 0,r=t?J(`p`,{class:w.description,key:`description`},t):void 0;return J(`div`,{class:w.formHeader},n,r)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){if(A(e))return this._renderGroupInput(e);if(j(e))return this._renderLabeledField(e);if(se(e))return this._renderTextComponent(e);if(ce(e))return this._renderRelationshipElementInput(e);if(le(e))return this._renderAttachmentElementInput(e);if(ue(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return J(`calcite-block`,{class:this.classes(w.group,s?w.groupSequential:null,o?w.groupActive:null,this.disabled?w.inputDisabled:null),description:e.description??void 0,expandable:!0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0},onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:n}=e.template,{label:r,required:i,dataType:a}=e,o=i?t(this.messages.requiredFieldLabel,{name:r}):r;return J(`calcite-label`,{"aria-label":o,class:w.label,key:`field--${n}`},J(`div`,{class:w.labelTextContent,key:`labelTextContainer`},r,i?J(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),a===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return O(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):k(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=this._getErrorToDisplay(e),r=n?x(e,n,this.messages):null;return r?J(`calcite-input-message`,{icon:!0,status:`invalid`},r):e.valueIsOutOfDomain&&(this._touchedInputs.has(e.template.elementId)||this.viewModel.submitHasBeenAttempted)?J(`calcite-input-message`,{icon:!0,status:`idle`},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):t?J(`calcite-input-message`,{class:w.description,icon:!1,status:`idle`},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=e.showNoValueLabel||this.messages.empty,a=n.evaluated&&!n.evaluating&&!n.choices.length&&J(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,scale:`s`,slot:`content-bottom`,width:`full`},J(`div`,{slot:`message`},e.showNoValueOptionEnabled?this.messages.noDynamicChoicesWithNoValue:this.messages.noDynamicChoices)),o=t=>{this._saveInput(e,t)},s=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}o(t)},c=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&o(null)},l=e.showNoValueOptionEnabled?J(`calcite-autocomplete-item`,{heading:i,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,u=t=>{t.inputValue=e.value===M?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue};return J(`calcite-autocomplete`,{...t,afterCreate:u,disabled:t.readOnly||t.disabled,placeholder:e.value==null?i:t.placeholder,value:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:c},n.evaluating?J(`calcite-loader`,{key:`dynamic-choice-loader`,label:this.messagesCommon.loading,scale:`s`,slot:`content-top`}):[a,l,...r.map(t=>J(`calcite-autocomplete-item`,{heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}))])}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return J(`div`,{class:w.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return J(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:w.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return J(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return J(`div`,{class:this.classes(w.multipleChoiceOtherChoice,t?w.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},J(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?J(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:w.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===M?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===M?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){this._markInputTouched(e);let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=N(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),this._markInputTouched(e),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=N(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!Y(e))continue;let t=r.getOtherChoiceDraftValue(i),n=L(t)?t:I;a.set(i,n)}else e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===M||e.value===M)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:M,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return J(`calcite-switch`,{...t,checked:S(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:w.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return J(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},J(`calcite-button`,{...r},e===M?this.messages.differentValuesPlaceholder:e),J(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>J(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`,i=this._touchedInputs.has(e?.template.elementId),a=r&&e.showNoValueOptionEnabled&&!i?()=>{}:n.onblur,o={...n,onblur:a};return J(`calcite-combobox`,{...o,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?M:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==M&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=Y(e.value)?this.messages.empty:e.name;return J(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(J(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(J(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(J(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&Y(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(J(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(J(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:M,selected:!0,value:M})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=Y(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return J(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:w.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?J(`calcite-label`,{class:w.placeholderRadio,key:n.label,layout:`inline`},J(`calcite-radio-button`,{checked:!0,class:w.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return J(`calcite-label`,{class:w.inputRadioLabel,key:r.label,layout:`inline`},J(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:w.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?J(`calcite-text-area`,{...t,class:this.classes(w.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):J(`calcite-input`,{...t,class:this.classes(w.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return J(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return J(`calcite-input`,{...n,class:this.classes(w.fieldInput,w.inputDisabled,w.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,de(n,t.value,{timeZone:e.effectiveTimeZone,...fe(e.template.field)}))}return e.value===M?[r,J(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return J(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===M?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return J(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===M?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=U(c,u),f=U(l,u),p=U(e.value===M?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return J(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},J(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),J(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?J(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===M||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=W(e.value===M?``:e.value,c),u=W(s,c),d=W(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return J(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},J(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?J(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?J(z,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return J(`div`,{class:w.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?J(`div`,{class:w.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?J(`div`,{class:w.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):J(`div`,{class:w.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return J(`div`,{class:w.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return J(`calcite-list`,{class:w.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?ge:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=v(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return J(`calcite-list-item`,{class:w.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},J(`div`,{class:w.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?J(`span`,{class:w.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[J(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,v(t))})]:u?J(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):J(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,n){let{elementId:r}=e.template,{viewAll:i}=this.messages.attachments;return J(`calcite-list-item`,{class:w.attachmentElementListItem,description:t(this.messages.attachments.count,{count:n}),key:`attachment-item-view-all-${r}`,label:i,onCalciteListItemSelect:()=>this._setAttachmentListElementId(r)},J(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return J(`div`,{class:w.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?J(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?J(`div`,{class:w.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?J(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return J(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ye(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId)}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return J(`div`,{class:w.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},J(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:w.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),J(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},J(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),J(`div`,{class:w.attachmentElementAddDropzoneHeading},a.addFile),J(`div`,{class:w.attachmentElementAddDropzoneDetail,title:o},o),J(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return J(`calcite-notice`,{class:w.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},J(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=v(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return J(`div`,{class:w.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},J(`div`,{class:w.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),J(`div`,{class:w.attachmentElementDetailActions},y(t)?J(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,J(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),J(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),J(`div`,{class:w.attachmentElementDetailMetadata},J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.size),J(`span`,{class:w.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.type),J(`span`,{class:w.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return J(`span`,{class:w.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=b(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[J(`div`,{class:w.attachmentElementDetailFileNameRow,key:`file-name-row`},J(`calcite-input`,{class:w.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),J(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?J(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return J(`div`,{class:w.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${v(t)}`},J(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:w.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),J(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},J(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),J(`div`,{class:w.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),J(`div`,{class:w.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),J(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),J(`div`,{class:w.attachmentElementDetailMetadata},J(`div`,{class:w.attachmentElementDetailMetadataGroup},J(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),J(`span`,{class:w.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return J(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},J(`div`,{class:w.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){this._markInputTouched(t),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),this._markInputTouched(t.selectedAttachmentAddInput),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),this._markInputTouched(t.selectedAttachmentListInput),this.hideAttachmentDialog()}_getAttachmentLabel(e,n,r,i){return i!==!1&&g(e.name)&&e.name.length>0?e.name:r===this.messagesCommon.notApplicable?t(this.messages.attachments.attachmentNumberedLabel,{index:n+1}):r}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?J(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,n,r){let i=`__count__`,[a,o]=t(e,{count:i}).split(i);return J(`span`,{key:r},a,J(`span`,{class:w.attachmentElementEmptyActionHintValue},n),o)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:J(`div`,{class:w.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>J(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},J(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:n}){let r=[],i=e.validationCriterionStates,a=this.messages.attachments,o=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&r.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of o)e.type===`document`&&e.maxFileSize!=null&&r.push({key:`maximum-file-size`,message:t(a.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:i.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&r.push({key:`maximum-audio-length`,message:t(a.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&r.push({key:`maximum-video-length`,message:t(a.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&r.push({key:`maximum-image-size`,message:t(a.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:i.get(`maximum-image-size`)??`info`});return n&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&r.push({key:`minimum-number-of-files`,message:t(a.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:i.get(`minimum-number-of-files`)??`info`}),n&&e.maxAttachmentCount!=null&&r.push({key:`maximum-number-of-files`,message:t(a.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:i.get(`maximum-number-of-files`)??`info`}),r}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:d(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return d(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=te(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&y(e)?J(`img`,{alt:t,class:w.attachmentElementListItemThumb,src:r}):J(`calcite-icon`,{class:w.attachmentElementListItemIcon,icon:_(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&y(e)?J(`img`,{alt:r,class:w.attachmentElementDetailPreviewImage,src:n,title:r}):[J(`calcite-icon`,{class:w.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await V(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,v(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=v(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return J(`div`,{class:w.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return J(`div`,{class:w.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,range:{max:l,min:u}}=e,d=!c||this.readOnly,f=this.disabled||this.viewModel.updating,p=this._getErrorToDisplay(e)?`invalid`:`idle`,m=t.hint??void 0,h=!1;return r===M&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(w.fieldInput,d?w.inputDisabled:null),status:p,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:l??void 0,min:u??void 0,disabled:f,readOnly:d,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_markInputTouched(e){e&&this._touchedInputs.add(e.template.elementId)}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,ve(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||this._markInputTouched(n),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(S(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return k(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:a}=this;if(S(e.template,`switch`)&&a.mode!==`single`){let t=i(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(this._markInputTouched(e),!e.isSubtypeField||a.mode===`batch`||!re(a.activeLayer,r,t)?a.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,n){let{value:r,template:i}=e,{elementId:a}=i,{messages:o,viewModel:s,messagesCommon:c}=this,{subtypes:l,activeFeatureIndex:u}=s;if(await s.setValue(a,n),!l?.length)return;let d=l.find(e=>e.code===n),f=l.find(e=>e.code===r)?.name??`${r}`;if(!d)return;let p=Promise.withResolvers();s.pendingSubtypeChoice=p;let m=`update-fields`,h=[{label:o.subtypes.useDefaultValuesOption,value:`update-fields`},{label:o.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:o.subtypes.changeWarningTitle,message:t(o.subtypes.changeWarning,{originalType:f,newType:d.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:c.apply,action:()=>p.resolve(m),type:`positive`},secondary:{label:c.cancel,type:`neutral`,action:()=>p.resolve(`undo`)}},cancel:()=>p.reject()};try{switch(this.showPrompt(g),await p.promise){case`update-fields`:await s.applySubtypeDefaults(d),await s.handleSubtypeChanged(u);break;case`keep-existing`:await s.handleSubtypeChanged(u);break;case`undo`:await this.viewModel.setValue(a,r)}}finally{s.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===M?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=G(o),s=G(t.value)):s=r===`timestamp-offset`?t.value==null?null:pe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:me({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===M?void 0:i.time}),o!==s&&(this._markInputTouched(e),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_getErrorToDisplay(e){let t=e.compositeError;return e.valid||!t?null:t===X.CONTINGENCY_VIOLATION_ERROR||t===X.CONTINGENCY_VIOLATION_WARNING?t:!this._touchedInputs.has(e.template.elementId)&&!this.viewModel.submitHasBeenAttempted?null:t}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let e=(await import(`./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js`)).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){let t=(await import(`./Feature/FeatureUtilityNetworkAssociations.js`)).default;return new t({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>a(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&j(e)?e:this._findFocusableInput(e);this._syncGroupInputStates(),this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(A(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=P(e)&&!e.group.open?e.group.inputs.filter(j)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e];if(t.visible&&j(t)){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t),this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(e=>{e!==t&&(e.open=!1)})):t.open=!1,this.scheduleRender()}_syncGroupInputStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([f()],$.prototype,`activeFeatureIndex`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`callbacks`,null),e([f()],$.prototype,`disabled`,null),e([f()],$.prototype,`effectiveTitle`,null),e([f()],$.prototype,`effectiveDisabled`,null),e([f()],$.prototype,`disabledOrReadOnly`,null),e([f()],$.prototype,`features`,null),e([f()],$.prototype,`footerButtonInfos`,null),e([f()],$.prototype,`map`,null),e([f()],$.prototype,`maximumFeatureCount`,null),e([f()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([f()],$.prototype,`spatialReference`,null),e([f()],$.prototype,`layerInfos`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`headingLevel`,void 0),e([f()],$.prototype,`icon`,null),e([f(),q(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([f(),q(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([f(),q(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([f(),q(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([f(),q(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([f()],$.prototype,`page`,null),e([f()],$.prototype,`readOnly`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`selectedAttachment`,null),e([f()],$.prototype,`selectedAttachmentDetails`,null),e([f()],$.prototype,`valid`,null),e([f({type:C}),_e([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([f({type:D,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f()],$.prototype,`groupDisplay`,void 0),e([f()],$.prototype,`_formHeaderVisible`,null),e([f()],$.prototype,`_associationsEnabled`,null),e([f()],$.prototype,`_associationsList`,void 0),e([f()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([f()],$.prototype,`_formId`,null),e([f()],$.prototype,`_focusedFieldInput`,void 0),e([f()],$.prototype,`_pendingSubtypeChoice`,void 0),e([f()],$.prototype,`_relatedRecordsEnabled`,null),e([f()],$.prototype,`_listObserverNode`,void 0),e([f()],$.prototype,`_attachmentDialogInfo`,void 0),e([f()],$.prototype,`_attachmentListFilterText`,void 0),e([f()],$.prototype,`_prompt`,void 0),e([f()],$.prototype,`test`,null),$=e([p(`esri.widgets.BatchAttributeForm`)],$);function ye(e){switch(e){case`audio`:return _(`audio/mpeg`);case`video`:return _(`video/mp4`);case`image`:return _(`image/png`);default:return`camera`}}const be=$;export{be as default};