@arcgis/core 4.28.0-next.20230911 → 4.28.0-next.20230913

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 (136) hide show
  1. package/arcade/Feature.js +1 -1
  2. package/arcade/arcadeTimeUtils.js +1 -1
  3. package/arcade/executionError.js +1 -1
  4. package/arcade/featureSetUtils.js +1 -1
  5. package/arcade/featureset/actions/Adapted.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/support/FeatureSet.js +1 -1
  8. package/arcade/featureset/support/errorsupport.js +1 -1
  9. package/arcade/functions/featuresetbase.js +1 -1
  10. package/arcade/functions/featuresetstats.js +1 -1
  11. package/arcade/functions/string.js +1 -1
  12. package/arcade.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/0920312e3c7b63c2e253.js +1 -0
  15. package/assets/esri/core/workers/chunks/0cb007ab5db0a2a598ec.js +1 -0
  16. package/assets/esri/core/workers/chunks/0cc61f1b2c0473ded5c2.js +1 -0
  17. package/assets/esri/core/workers/chunks/0f804e3f888cb4998f46.js +1 -0
  18. package/assets/esri/core/workers/chunks/189dd81cf95bd8417ee3.js +1 -0
  19. package/assets/esri/core/workers/chunks/1a723bb4a341f645e5fe.js +1 -0
  20. package/assets/esri/core/workers/chunks/24c717492ea1b35310d8.js +1 -0
  21. package/assets/esri/core/workers/chunks/{3ce73dd4113dbc7d11de.js → 2eb58dc339b2bb03d9e3.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{38c07a8574352a7f2f6d.js → 2ff0dbd5eb7ca57bb7fc.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{768f3db2705fa9e57641.js → 49dfdc0463450491df9d.js} +1 -1
  24. package/assets/esri/core/workers/chunks/650a317b6dc245a7060f.js +1 -0
  25. package/assets/esri/core/workers/chunks/{56ed099745360888604e.js → 67f01c71280fa0759742.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{f62842807744bdfaced7.js → 67fab13f56b340076763.js} +1 -1
  27. package/assets/esri/core/workers/chunks/6d94b358e8d1cf79bba3.js +1 -0
  28. package/assets/esri/core/workers/chunks/718607d7a3b33fc33b0a.js +1 -0
  29. package/assets/esri/core/workers/chunks/{4c63d6b9460aa6ae9843.js → 860417f4138f53d315ba.js} +2 -2
  30. package/assets/esri/core/workers/chunks/8aa7e994b74f66522c37.js +1 -0
  31. package/assets/esri/core/workers/chunks/9fa485b04b997b0a5509.js +1 -0
  32. package/assets/esri/core/workers/chunks/a047fcf3c7307a69b63c.js +1 -0
  33. package/assets/esri/core/workers/chunks/a753d9874801cd448946.js +1 -0
  34. package/assets/esri/core/workers/chunks/c51233ad51823cb98c35.js +1 -0
  35. package/assets/esri/core/workers/chunks/c61f20d91a5c432b07dc.js +1 -0
  36. package/assets/esri/core/workers/chunks/d3d11242e5af57ba77f4.js +1 -0
  37. package/assets/esri/core/workers/chunks/dbf343d1fb746f99bb6e.js +1 -0
  38. package/assets/esri/core/workers/chunks/{271ec1d1666bf6dc3dda.js → dc74b4ec85e8e3de5b27.js} +1 -1
  39. package/assets/esri/core/workers/chunks/e8a8791d765ab6c450dd.js +1 -0
  40. package/assets/esri/core/workers/chunks/{5fe7b5665710ec6d3046.js → eb0d1c5c96f735c162d3.js} +1 -1
  41. package/assets/esri/themes/base/widgets/_Sketch.scss +0 -5
  42. package/assets/esri/themes/base/widgets/_SketchTooltipControls.scss +0 -5
  43. package/assets/esri/themes/dark/main.css +1 -1
  44. package/assets/esri/themes/light/main.css +1 -1
  45. package/assets/esri/themes/light/view.css +1 -1
  46. package/chunks/HUDMaterial.glsl.js +38 -45
  47. package/chunks/languageUtils.js +1 -1
  48. package/core/promiseUtils.js +1 -1
  49. package/core/sql/AggregateFunctions.js +1 -1
  50. package/core/sql/DateOnly.js +1 -1
  51. package/core/sql/SqlTimestampOffset.js +1 -1
  52. package/core/sql/TimeOnly.js +1 -1
  53. package/core/sql/WhereClause.js +1 -1
  54. package/core/sql/WhereGrammar.js +1 -1
  55. package/core/sql/sqlCompareUtils.js +1 -1
  56. package/geometry/GeometryCursor.js +1 -1
  57. package/geometry/Mesh.js +1 -1
  58. package/geometry/support/labelPoint.js +1 -1
  59. package/geometry/support/meshUtils/bounds.js +1 -1
  60. package/geometry/support/meshUtils/georeference.js +1 -1
  61. package/interfaces.d.ts +190 -144
  62. package/layers/ImageryLayer.js +1 -1
  63. package/layers/SceneLayer.js +1 -1
  64. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  65. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  66. package/layers/graphics/sources/csv/csv.js +1 -1
  67. package/layers/support/FetchAssociatedFeatureLayer.js +1 -1
  68. package/layers/support/TilemapCache.js +1 -1
  69. package/layers/support/fieldUtils.js +1 -1
  70. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  71. package/layers/support/wmsUtils.js +1 -1
  72. package/layers/video/VideoController.js +1 -1
  73. package/package.json +3 -3
  74. package/smartMapping/heuristics/sizeRange.js +1 -1
  75. package/smartMapping/labels/bins.js +1 -1
  76. package/smartMapping/labels/clusters.js +1 -1
  77. package/smartMapping/labels/support/utils.js +1 -1
  78. package/smartMapping/popup/support/clusterUtils.js +1 -1
  79. package/smartMapping/support/clusterUtils.js +1 -1
  80. package/support/revision.js +1 -1
  81. package/views/2d/engine/webgl/DisplayId.js +1 -1
  82. package/views/2d/engine/webgl/Utils.js +1 -1
  83. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  84. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  85. package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
  86. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  87. package/views/3d/analysis/Dimension/LengthDimensionVisualization.js +1 -1
  88. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  89. package/views/3d/analysis/Dimension/settings.js +1 -1
  90. package/views/3d/interactive/Manipulator3D.js +1 -1
  91. package/views/3d/interactive/editingTools/originGraphicVisualElementUtils.js +1 -1
  92. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  93. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  94. package/views/3d/layers/I3SMeshView3D.js +1 -1
  95. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  96. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  97. package/views/3d/layers/SceneLayerWorker.js +1 -1
  98. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  99. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  100. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  101. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  102. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  103. package/views/ToolViewManager.js +1 -1
  104. package/views/View.js +1 -1
  105. package/views/animation/easing.js +1 -1
  106. package/views/webgl/FramebufferObject.js +1 -1
  107. package/views/webgl/RenderingContext.js +1 -1
  108. package/views/webgl/enums.js +1 -1
  109. package/views/webgl/renderState.js +1 -1
  110. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  111. package/widgets/Feature/FeatureMedia.js +1 -1
  112. package/widgets/FeatureForm.js +1 -1
  113. package/widgets/Features.js +1 -1
  114. package/widgets/Search/SearchViewModel.js +1 -1
  115. package/widgets/support/SketchTooltipControls/SketchTooltipControlsViewModel.js +1 -1
  116. package/widgets/support/SketchTooltipControls.js +1 -1
  117. package/widgets/support/SnappingControls.js +1 -1
  118. package/assets/esri/core/workers/chunks/055575ed2ab78be0bdb2.js +0 -1
  119. package/assets/esri/core/workers/chunks/0ee90a0b4d09a56c0d48.js +0 -1
  120. package/assets/esri/core/workers/chunks/15056f91d87f11b00bcc.js +0 -1
  121. package/assets/esri/core/workers/chunks/344e40934c98d6fe66ae.js +0 -1
  122. package/assets/esri/core/workers/chunks/558049fcac3a82a093fc.js +0 -1
  123. package/assets/esri/core/workers/chunks/5c41eb67d19b8710118a.js +0 -1
  124. package/assets/esri/core/workers/chunks/5d183ac1a8b68ba9c656.js +0 -1
  125. package/assets/esri/core/workers/chunks/610d4a5d2511fa81460e.js +0 -1
  126. package/assets/esri/core/workers/chunks/6755bb1f2a6575a8e082.js +0 -1
  127. package/assets/esri/core/workers/chunks/84173936b309712ba9b3.js +0 -1
  128. package/assets/esri/core/workers/chunks/877302d6e39a0d530aab.js +0 -1
  129. package/assets/esri/core/workers/chunks/a07dc782e69111e2eeaf.js +0 -1
  130. package/assets/esri/core/workers/chunks/b825019841247d173072.js +0 -1
  131. package/assets/esri/core/workers/chunks/bed1bc13b168fae46404.js +0 -1
  132. package/assets/esri/core/workers/chunks/c8dd21a332559c99815c.js +0 -1
  133. package/assets/esri/core/workers/chunks/ccc3564e76c0ec5c0228.js +0 -1
  134. package/assets/esri/core/workers/chunks/d0a81c7ec8a84eeadd31.js +0 -1
  135. package/assets/esri/core/workers/chunks/e7a852b319c1d89eddc5.js +0 -1
  136. package/assets/esri/core/workers/chunks/ebde11fdccb437954ce7.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as s,whenOnce as n}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import{css as d}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as p,isRelationshipInput as u,isInputInGroupInput as m,isFieldElementWithInputType as h,getErrorMessageForFieldInput as b,getIconForFeature as v,isNumberFieldInput as _}from"./FeatureForm/featureFormUtils.js";import g from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as C,prepareFieldValueForDateComponents as y,numberingSystem as F,getFieldValueFromDateComponent as R,getFieldValueFromDateComponents as w,isCalciteDateComponent as I}from"./support/dateUtils.js";import{Heading as O,incrementHeadingLevel as k}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as x}from"./support/decorators/vmEvent.js";import{tsx as N}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";const D="data-field-name",j="esri.widgets.FeatureForm",V=o.getLogger(j);let T=class extends l{constructor(e,t){super(e,t),this._focusedNumberComponentInfo=null,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new g,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupClick=this._onGroupClick.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([s((()=>this.feature),(()=>{n((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),s((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return f({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get view(){return i(V,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(V,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return N("div",{class:this.classes(d.base,d.widget,d.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return N("form",{class:d.form,novalidate:!0,onsubmit:this._onFormSubmit,onkeydown:this._onFormKeyDown},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&N(O,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&N("p",{class:d.description,key:"description"},e.formDescription);return N("div",{class:d.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):p(e)?this._renderLabeledField(e):u(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:N("div",{class:this.classes(d.description),id:t},e)}_renderGroup(e,t){const{formTemplate:i,disabled:o}=this,{description:s,inputs:n,label:r,state:a}=e,l=n.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),m=!(!c||c.group!==e),h=`${this.id}_group_${t}`,b=`${this.id}_group-label_${t}`,v=`${this.id}_group-description_${t}`,_=this._renderDescriptionOrEmpty(s,v),g="sequential"===this.groupDisplay,f=g?m:"expanded"===a,C=f?d.collapseIcon:d.expandIcon;return N("fieldset",{"aria-expanded":f.toString(),"aria-labelledby":b,"aria-describedby":s?v:"",class:this.classes(d.group,g?d.groupSequential:null,f?null:d.groupCollapsed,m?d.groupActive:null,o?d.inputDisabled:null),disabled:o,"data-group":e,id:h,key:t,onclick:this._onGroupClick},N("button",{role:g?"presentation":void 0,class:d.groupHeader,type:"button",tabIndex:g?-1:0},N("div",{class:d.groupTitle},N(O,{class:d.groupLabel,id:b,level:null!=i&&i.title?k(this.headingLevel):this.headingLevel},r),_),g?null:N("span",{class:this.classes(C,d.groupToggleIcon)})),l.map((e=>p(e)?this._renderLabeledField(e):u(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let s;if(!t||u(t))s=0;else if(c(t)){const e=t.inputs.find(p);s=e?o.indexOf(e):0}else{let i;if(m(t)&&"collapsed"===t.group.state){const o=t.group.inputs.filter(p);i="forward"===e?o[o.length-1]:o[0]}else i=t;s=o.indexOf(i)+1}for(let n=s;n<o.length;n++){const e=o[n];if(e.visible&&p(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:s,required:n}=e,r={"aria-label":n?L(this.messages.requiredFieldLabel,{name:o}):o,class:d.label,key:`${s.id}-${i.uid}-${e.name}`},a=[N("div",{class:d.labelTextContent,key:"labelTextContainer"},o,n?N("span",{title:this.messagesCommon.required,"aria-hidden":!0},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return N("date"===t?"label":"calcite-label",{...r},a)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:s,updating:n}=e,r=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(s,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),r):this._renderComboBoxComponent(e,t,r):this._renderSwitchComponent(e,r)}if("datetime-picker"===o||"date"===t)return this._renderDateComponents(e,r);const a="number"===t?this._renderNumberComponent(e,r):this._renderStringComponent(e,r);return n?N("div",{key:`${r.key}-input-updating-wrapper`,class:d.fieldInputWrapper},a,N("div",{class:d.fieldInputLoader},N("calcite-progress",{type:"indeterminate"}))):a}_renderStringComponent(e,t){return N("calcite-input",{...t,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return N("calcite-input-number",{...t,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target),value:this._focusedNumberComponentInfo?.name===e.name?this._focusedNumberComponentInfo.value:t.value})}_renderDateComponents(e,t){const{dateDataType:i,includeTime:o,label:s,name:n,valid:r,value:a}=e,{class:l,max:c,min:p,key:u,readOnly:m,required:h}=t;if("string"===i)return this._renderReadOnlyComponent(e,C(e.field,t.value));const{date:b,time:v}=y(a),_=null!=c?y(c):void 0,g=null!=p?y(p):void 0,f=_?.date??void 0,R=g?.date??void 0,w={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!r,label:s,numberingSystem:F,overlayPositioning:"fixed",readOnly:m,required:h,tabIndex:t.tabIndex,[D]:n,onfocus:this._onComponentFocus};return N("div",{key:`${u}-date-time-container`,class:d.dateInputContainer},N("calcite-input-date-picker",{bind:this,...w,class:this.classes(l,d.inputDate),"data-date-part":"date",key:`${u}-date-input`,valueAsDate:b??void 0,maxAsDate:f,minAsDate:R,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target),onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)}}),o?N("calcite-input-time-picker",{bind:this,...w,class:this.classes(l,d.inputTime),"data-date-part":"time",key:`${u}-time-input`,value:v??void 0,step:1,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target),onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)}}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return N("calcite-input",{...i,class:this.classes(d.fieldInput,d.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:s}=e,{messages:n,messagesTemplates:r,viewModel:a,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>N("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[c,p]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&p.unshift(N("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=p.length>0?[N("calcite-combobox-item-group",{key:"recommended",label:n.recommended},c),N("calcite-combobox-item-group",{key:"other",label:r.other},p)]:c,m="INSERT"===a.arcadeEditType,h=l.has(s),b=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||n.empty;u.unshift(N("calcite-combobox-item",{value:t,textLabel:n.empty,selected:b,key:"empty-option"},i))}const v=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return N("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,clearDisabled:!0,overlayPositioning:"fixed",onblur:v,onCalciteComboboxChange:({target:e})=>{b&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:s}=e,n=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===s,props:i})));if(e.showNoValueOptionEnabled){const t="",r=e.showNoValueLabel||this.messages.empty,a=s===t||null===s;n.unshift(this._renderRadioButtonComponent({key:"empty-option",label:r,name:o,value:t,selected:a,props:i}))}return N("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:d.inputRadioGroup,"data-field-name":i[D],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},n)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!h(e.element,"switch")&&i===e.element.input.onValue;return N("calcite-switch",{...t,checked:o,class:d.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:s,props:n}){return N("calcite-label",{layout:"inline",key:e,class:d.inputRadioLabel},N("calcite-radio-button",{...n,afterCreate:void 0,afterUpdate:void 0,checked:o,class:d.inputRadio,disabled:n.readOnly,name:t,value:i,onblur:()=>{this._focusedFieldName=null},onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),s)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?b(e,this.messages):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?N("calcite-input-message",{status:"invalid",icon:!0},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:s}=this;if(!o||!s?.showAllRelatedRecords)return;const n=this.messages;return N("calcite-list-item",{description:L(n.totalCount,{count:t}),label:n.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},N("calcite-icon",{slot:"content-end",scale:"s",icon:"list"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{relatedRecordCallbacks:s}=this;if(t&&s?.addRelatedRecord&&o)return N("calcite-button",{alignment:"center",appearance:"outline-fill",class:d.centeredButton,disabled:e.updating,iconStart:"plus",key:`${i}-add-button`,round:!0,scale:"s",width:"half",onclick:()=>this._onAddRelatedRecordsClick(i,o)},this.messages.addRecord)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:s}=e,{feature:n,relatedRecordCallbacks:r}=this,a=()=>{r?.editRelatedRecord&&n&&r.editRelatedRecord({parentFeature:n,relationshipId:t,relatedFeature:i})};return N("calcite-list-item",{bind:this,description:o,label:s,key:`${t}-${i.uid}`,value:s,onclick:a},N("calcite-icon",{slot:"content-start",scale:"m",icon:v(i)}),N("calcite-icon",{slot:"content-end",scale:"s",icon:"chevron-right"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,s=o?null:this._renderDescriptionOrEmpty(e.description),n=t>0?this._renderRelatedRecordsList(e):e.loaded?this._renderNoRelatedRecordsNotice():void 0;return N("calcite-label",{class:this.classes(d.label,d.relationshipLabel),key:`relationship-${i}-container`},N("div",null,this._renderRelatedRecordsHeaderContainer(e),s,n),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return N("div",{class:d.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},N("span",null,e.label),t?N("calcite-loader",{label:this.messagesCommon?.loading,inline:!0,key:"loader",scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return N("calcite-list",{class:d.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoRelatedRecordsNotice(){return N("calcite-notice",{open:!0,scale:"s",kind:"brand",icon:"information",width:"full"},N("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return N("div",{key:"feature-observer",class:d.listObserver,bind:this,afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved})}getCommonInputProps(e){const{disabled:t,groupDisplay:i}=this,{editable:o,group:s,hint:n,label:r,maxLength:a,minLength:l,name:c,range:{max:p,min:u},required:m,valid:h,value:b}=e,v=this._inputsWithChanges.has(c),_=!o||t,g="all"===i&&null!=s&&"collapsed"===s.state;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":h?"false":"true",class:this.classes(d.fieldInput,_?d.inputDisabled:null,v&&!h?d.inputInvalid:null),key:c,label:r,max:null!=p?p:void 0,min:null!=u?u:void 0,maxlength:a>-1?`${a}`:"",minlength:l>-1?`${l}`:"",placeholder:n??void 0,readOnly:_,required:m,tabIndex:g?-1:0,value:null==b?"":`${b}`,onfocus:this._onComponentFocus,onblur:this._onComponentBlur,onkeydown:this._onComponentKeyDown,[D]:c}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(D))}_afterDateComponentCreateOrUpdate(e){const{name:t}=this._getFieldInputFromHTMLElement(e),i=this._dateComponentMap.get(t),o=I(e);null!=i?o?i.date=e:i.time=e:this._dateComponentMap.set(t,{[o?"date":"time"]:e}),this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);_(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,m(i)&&(i.group.state="expanded"),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name,_(i)&&(this._focusedNumberComponentInfo={name:i.name,node:t,value:t.value})}_onComponentBlur(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=null,_(i)&&this._focusedNumberComponentInfo&&(this._focusedNumberComponentInfo.node.value=`${i.value}`,this._focusedNumberComponentInfo=null),this._saveValueFromComponent(t)}_saveValueFromDateComponent(e,t=!1){const{name:i}=this._getFieldInputFromHTMLElement(e),o=this._dateComponentMap.get(i);if(!o||!o.date)return;const s=R(e),n=this._getFieldInputFromHTMLElement(o.date),r=w(n,o.date,o.time);this.viewModel.getValue(i)!==r&&(null!==s&&null!==r?this._updateFieldValue(i,r):t&&this._updateFieldValue(i,null))}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);_(t)&&this._focusedNumberComponentInfo&&(this._focusedNumberComponentInfo.value=e.value),this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown(e){const{key:t,altKey:i,ctrlKey:o,metaKey:s}=e,n=this._getFieldInputFromHTMLElement(e.target);if("Enter"===t)m(n)&&"collapsed"===n.group.state&&(n.group.state="expanded");else{const{type:r}=n.field,a="single"===r||"double"===r;if(("integer"===r||"small-integer"===r||a)&&(!i&&!o&&!s)&&1===t.length){const i=Number(t),o=["-","+"],s=["e","."],n=a?[...o,...s]:o;isNaN(i)&&!n.includes(t)&&e.preventDefault()}}}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return h(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:V.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,o="sequential"===this.groupDisplay,s=`.${d.groupHeader}`;if(!(i&&!e.target.closest(s))){if(this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,o){const o=e.target.closest(s);if(i&&!o)return;this.viewModel.inputs.forEach((e=>{c(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._attemptFocusOnNextRender=o,this.scheduleRender()}}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}async _onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;if(!e)return;const{showAllEnabled:t,updating:i}=e;this._listObserverNode&&!i&&t&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}};e([r()],T.prototype,"_listObserverNode",void 0),e([r()],T.prototype,"_relatedRecordsEnabled",null),e([r()],T.prototype,"disabled",null),e([r()],T.prototype,"feature",null),e([r()],T.prototype,"formTemplate",null),e([r()],T.prototype,"groupDisplay",void 0),e([r()],T.prototype,"headingLevel",void 0),e([r()],T.prototype,"label",null),e([r()],T.prototype,"layer",null),e([r()],T.prototype,"map",null),e([r(),M("esri/widgets/FeatureForm/t9n/FeatureForm")],T.prototype,"messages",void 0),e([r(),M("esri/t9n/common")],T.prototype,"messagesCommon",void 0),e([r(),M("esri/widgets/Feature/t9n/Feature")],T.prototype,"messagesFeature",void 0),e([r(),M("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],T.prototype,"messagesTemplates",void 0),e([r()],T.prototype,"relatedRecordCallbacks",null),e([r()],T.prototype,"relationshipId",null),e([r()],T.prototype,"spatialReference",null),e([r()],T.prototype,"strict",null),e([r()],T.prototype,"view",null),e([r(),x(["value-change","submit"])],T.prototype,"viewModel",void 0),T=e([a(j)],T);const E=T;export{E as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{watch as o,whenOnce as n}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as c}from"./FeatureForm/css.js";import{isGroupInput as p,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as b,getErrorMessageForFieldInput as v,getIconForFeature as _,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as y,prepareFieldValueForDateComponents as R,numberingSystem as F,getFieldValueFromDateComponent as w,getFieldValueFromDateComponents as I,isCalciteDateComponent as O}from"./support/dateUtils.js";import{Heading as k,incrementHeadingLevel as M}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as x}from"./support/decorators/messageBundle.js";import{vmEvent as N}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";const D="data-field-name",V="esri.widgets.FeatureForm",T=s.getLogger(V);let E=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:s}=this;i&&s?.addRelatedRecord&&s.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupClick=this._onGroupClick.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([o((()=>this.feature),(()=>{n((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),o((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get view(){return i(T,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(T,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(c.base,c.widget,c.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:c.form,novalidate:!0,onsubmit:this._onFormSubmit,onkeydown:this._onFormKeyDown},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(k,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:c.description,key:"description"},e.formDescription);return L("div",{class:c.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>p(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(c.description),id:t},e)}_renderGroup(e,t){const{formTemplate:i,disabled:s}=this,{description:o,inputs:n,label:r,state:a}=e,l=n.filter((e=>e.visible)),d=this.viewModel.findField(this._focusedFieldName),p=!(!d||d.group!==e),h=`${this.id}_group_${t}`,b=`${this.id}_group-label_${t}`,v=`${this.id}_group-description_${t}`,_=this._renderDescriptionOrEmpty(o,v),g="sequential"===this.groupDisplay,f=g?p:"expanded"===a,C=f?c.collapseIcon:c.expandIcon;return L("fieldset",{"aria-expanded":f.toString(),"aria-labelledby":b,"aria-describedby":o?v:"",class:this.classes(c.group,g?c.groupSequential:null,f?null:c.groupCollapsed,p?c.groupActive:null,s?c.inputDisabled:null),disabled:s,"data-group":e,id:h,key:t,onclick:this._onGroupClick},L("button",{role:g?"presentation":void 0,class:c.groupHeader,type:"button",tabIndex:g?-1:0},L("div",{class:c.groupTitle},L(k,{class:c.groupLabel,id:b,level:null!=i&&i.title?M(this.headingLevel):this.headingLevel},r),_),g?null:L("span",{class:this.classes(C,c.groupToggleIcon)})),l.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,s="forward"===e?i:i.slice().reverse();let o;if(!t||m(t))o=0;else if(p(t)){const e=t.inputs.find(u);o=e?s.indexOf(e):0}else{let i;if(h(t)&&"collapsed"===t.group.state){const s=t.group.inputs.filter(u);i="forward"===e?s[s.length-1]:s[0]}else i=t;o=s.indexOf(i)+1}for(let n=o;n<s.length;n++){const e=s[n];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:s,layer:o,required:n}=e,r={"aria-label":n?j(this.messages.requiredFieldLabel,{name:s}):s,class:c.label,key:`${o.id}-${i.uid}-${e.name}`},a=[L("div",{class:c.labelTextContent,key:"labelTextContainer"},s,n?L("span",{title:this.messagesCommon.required,"aria-hidden":!0},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return L("date"===t?"label":"calcite-label",{...r},a)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:s,name:o,updating:n}=e,r=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(o,this.messages.empty);return"switch"!==s||e.hasInvalidSwitchValue?"radio-buttons"===s?this._renderRadioButtonComponents(e,t.flat(),r):this._renderComboBoxComponent(e,t,r):this._renderSwitchComponent(e,r)}if("datetime-picker"===s||"date"===t)return this._renderDateComponents(e,r);const a="number"===t?this._renderNumberComponent(e,r):this._renderStringComponent(e,r);return n?L("div",{key:`${r.key}-input-updating-wrapper`,class:c.fieldInputWrapper},a,L("div",{class:c.fieldInputLoader},L("calcite-progress",{type:"indeterminate"}))):a}_renderStringComponent(e,t){return L("calcite-input",{...t,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("calcite-input-number",{...t,type:"number",integer:l(e.field),onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{dateDataType:i,includeTime:s,label:o,name:n,valid:r,value:a}=e,{class:l,max:d,min:p,key:u,readOnly:m,required:h}=t;if("string"===i)return this._renderReadOnlyComponent(e,y(e.field,t.value));const{date:b,time:v}=R(a),_=null!=d?R(d):void 0,g=null!=p?R(p):void 0,f=_?.date??void 0,C=g?.date??void 0,w={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!r,label:o,numberingSystem:F,overlayPositioning:"fixed",readOnly:m,required:h,tabIndex:t.tabIndex,[D]:n,onfocus:this._onComponentFocus};return L("div",{key:`${u}-date-time-container`,class:c.dateInputContainer},L("calcite-input-date-picker",{bind:this,...w,class:this.classes(l,c.inputDate),"data-date-part":"date",key:`${u}-date-input`,valueAsDate:b??void 0,maxAsDate:f,minAsDate:C,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target),onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)}}),s?L("calcite-input-time-picker",{bind:this,...w,class:this.classes(l,c.inputTime),"data-date-part":"time",key:`${u}-time-input`,value:v??void 0,step:1,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target),onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target,!0)}}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return L("calcite-input",{...i,class:this.classes(c.fieldInput,c.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:s,name:o}=e,{messages:n,messagesTemplates:r,viewModel:a,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:s===t,textLabel:e,value:`${t}`}))))),[c,p]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&p.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=p.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:n.recommended},c),L("calcite-combobox-item-group",{key:"other",label:r.other},p)]:c,m="INSERT"===a.arcadeEditType,h=l.has(o),b=null==s&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||n.empty;u.unshift(L("calcite-combobox-item",{value:t,textLabel:n.empty,selected:b,key:"empty-option"},i))}const v=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,clearDisabled:!0,overlayPositioning:"fixed",onblur:v,onCalciteComboboxChange:({target:e})=>{b&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:s,value:o}=e,n=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:s,value:t,selected:t===o,props:i})));if(e.showNoValueOptionEnabled){const t="",r=e.showNoValueLabel||this.messages.empty,a=o===t||null===o;n.unshift(this._renderRadioButtonComponent({key:"empty-option",label:r,name:s,value:t,selected:a,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:c.inputRadioGroup,"data-field-name":i[D],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},n)}_renderSwitchComponent(e,t){const{value:i}=e,s=!!b(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:s,class:c.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:s,label:o,props:n}){return L("calcite-label",{layout:"inline",key:e,class:c.inputRadioLabel},L("calcite-radio-button",{...n,afterCreate:void 0,afterUpdate:void 0,checked:s,class:c.inputRadio,disabled:n.readOnly,name:t,value:i,onblur:()=>{this._focusedFieldName=null},onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),o)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?v(e,this.messages):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{status:"invalid",icon:!0},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:s}=e,{relatedRecordCallbacks:o}=this;if(!s||!o?.showAllRelatedRecords)return;const n=this.messages;return L("calcite-list-item",{description:j(n.totalCount,{count:t}),label:n.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{slot:"content-end",scale:"s",icon:"list"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:s}=e,{relatedRecordCallbacks:o}=this;if(t&&o?.addRelatedRecord&&s)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:c.centeredButton,disabled:e.updating,iconStart:"plus",key:`${i}-add-button`,round:!0,scale:"s",width:"half",onclick:()=>this._onAddRelatedRecordsClick(i,s)},this.messages.addRecord)}_renderRelatedRecordListItem(e,t){const{feature:i,description:s,title:o}=e,{feature:n,relatedRecordCallbacks:r}=this,a=()=>{r?.editRelatedRecord&&n&&r.editRelatedRecord({parentFeature:n,relationshipId:t,relatedFeature:i})};return L("calcite-list-item",{bind:this,description:s,label:o,key:`${t}-${i.uid}`,value:o,onclick:a},L("calcite-icon",{slot:"content-start",scale:"m",icon:_(i)}),L("calcite-icon",{slot:"content-end",scale:"s",icon:"chevron-right"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:s}=e,o=s?null:this._renderDescriptionOrEmpty(e.description),n=t>0?this._renderRelatedRecordsList(e):e.loaded?this._renderNoRelatedRecordsNotice():void 0;return L("calcite-label",{class:this.classes(c.label,c.relationshipLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),o,n),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:c.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{label:this.messagesCommon?.loading,inline:!0,key:"loader",scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:c.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{open:!0,scale:"s",kind:"brand",icon:"information",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{key:"feature-observer",class:c.listObserver,bind:this,afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved})}getCommonInputProps(e){const{disabled:t,groupDisplay:i}=this,{editable:s,group:o,hint:n,label:r,maxLength:a,minLength:l,name:d,range:{max:p,min:u},required:m,valid:h,value:b}=e,v=this._inputsWithChanges.has(d),_=!s||t,g="all"===i&&null!=o&&"collapsed"===o.state;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":h?"false":"true",class:this.classes(c.fieldInput,_?c.inputDisabled:null,v&&!h?c.inputInvalid:null),key:d,label:r,max:null!=p?p:void 0,min:null!=u?u:void 0,maxlength:a>-1?`${a}`:"",minlength:l>-1?`${l}`:"",placeholder:n??void 0,readOnly:_,required:m,tabIndex:g?-1:0,value:null==b?"":`${b}`,onfocus:this._onComponentFocus,onblur:this._onComponentBlur,onkeydown:this._onComponentKeyDown,[D]:d}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(D))}_afterDateComponentCreateOrUpdate(e){const{name:t}=this._getFieldInputFromHTMLElement(e),i=this._dateComponentMap.get(t),s=O(e);null!=i?s?i.date=e:i.time=e:this._dateComponentMap.set(t,{[s?"date":"time"]:e}),this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);g(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),s=t||i;s&&this._afterComponentCreateOrUpdate(s)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),s=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&s===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.state="expanded"),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e,t=!1){const{name:i}=this._getFieldInputFromHTMLElement(e),s=this._dateComponentMap.get(i);if(!s||!s.date)return;const o=w(e),n=this._getFieldInputFromHTMLElement(s.date),r=I(n,s.date,s.time);this.viewModel.getValue(i)!==r&&(null!==o&&null!==r?this._updateFieldValue(i,r):t&&this._updateFieldValue(i,null))}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&"collapsed"===i.group.state&&(i.group.state="expanded")}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return b(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:T.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,s="sequential"===this.groupDisplay,o=`.${c.groupHeader}`;if(!(i&&!e.target.closest(o))){if(this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,s){const s=e.target.closest(o);if(i&&!s)return;this.viewModel.inputs.forEach((e=>{p(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._attemptFocusOnNextRender=s,this.scheduleRender()}}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;if(!e)return;const{showAllEnabled:t,updating:i}=e;this._listObserverNode&&!i&&t&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}};e([r()],E.prototype,"_listObserverNode",void 0),e([r()],E.prototype,"_relatedRecordsEnabled",null),e([r()],E.prototype,"disabled",null),e([r()],E.prototype,"feature",null),e([r()],E.prototype,"formTemplate",null),e([r()],E.prototype,"groupDisplay",void 0),e([r()],E.prototype,"headingLevel",void 0),e([r()],E.prototype,"label",null),e([r()],E.prototype,"layer",null),e([r()],E.prototype,"map",null),e([r(),x("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"messages",void 0),e([r(),x("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([r(),x("esri/widgets/Feature/t9n/Feature")],E.prototype,"messagesFeature",void 0),e([r(),x("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],E.prototype,"messagesTemplates",void 0),e([r()],E.prototype,"relatedRecordCallbacks",null),e([r()],E.prototype,"relationshipId",null),e([r()],E.prototype,"spatialReference",null),e([r()],E.prototype,"strict",null),e([r()],E.prototype,"view",null),e([r(),N(["value-change","submit"])],E.prototype,"viewModel",void 0),E=e([a(V)],E);const U=E;export{U as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import s from"../core/Logger.js";import{watch as o,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import w from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as _}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{Heading as M}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{vmEvent as y}from"./support/decorators/vmEvent.js";import{tsx as I}from"./support/jsxFactory.js";import{substitute as C}from"../intl/substitute.js";import{formatNumber as A}from"../intl/number.js";const x="selected-index",R=0,j="features-spinner";let k=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusFeatureMenuFlowItem=!1,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._focusRootFlowItem=!1,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new _,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new w,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:s,active:o,uid:r,disabled:n,indicator:a}=e;return e.visible?I("calcite-action",{appearance:"solid",bind:this,icon:this._getActionIcon(e),onclick:this._triggerAction,"data-action-uid":r,disabled:n,indicator:a,loading:o,title:this._hideActionText?i:void 0,active:"toggle"===s&&e.value,key:`action-${t}`,text:i,scale:"s"},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this._focusRootFlowItem=!0,this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1},this._displaySpinnerThrottled=n((()=>this._displaySpinner()),R),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,o((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),o((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),o((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),o((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),o((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),o((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),o((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),o((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),o((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:s}=this.viewModel,o={title:!1};return s?(e?(e.viewModel=s,e.visibleElements=o):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:s,visibleElements:o}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||s.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),this._rootFlowItemNode?.blur()}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{container:e}=this,{active:t}=this.viewModel;if(t||s.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),!e)return;const i=e.querySelectorAll("calcite-flow-item"),o=i[i?.length-1];this.scheduleRender(),requestAnimationFrame((()=>o?.setFocus()))}next(){return this.viewModel.next()}open(e){this.removeHandles(x);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return I("div",{class:this.classes(m.base,m.esriWidget,m.esriWidgetPanel)},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?I("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:I("div",{slot:"footer",class:m.footer,key:"footer-actions"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:s,pendingPromisesCount:o}=t;return I("calcite-action",{loading:o>0,appearance:"solid",key:"feature-menu-button",bind:this,textEnabled:!0,label:e.selectFeature,text:C(e.pageText,{index:A(s+1),total:A(i)}),title:e.selectFeature,onclick:this._openFeatureMenu,icon:"list",scale:"s"})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return I("calcite-action-bar",{layout:"horizontal",key:"pagination-action-bar",expandDisabled:!0,class:m.paginationActionBar,scale:"s",overflowActionsDisabled:!0},I("calcite-action-group",{scale:"s"},I("calcite-action",{appearance:"solid",class:m.paginationPrevious,label:e,title:e,text:e,iconFlipRtl:!0,icon:"chevron-left",onclick:this._previousFeature,scale:"s"}),I("calcite-action",{appearance:"solid",label:t,text:t,title:t,iconFlipRtl:!0,icon:"chevron-right",onclick:this._nextFeature,scale:"s"})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,s=e===t,o=i.indexOf(e);return I("calcite-list-item",{bind:this,key:`feature-menu-item-${e.uid}`,selected:s,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseover:this._setActiveFeature,onmouseleave:this._removeActiveFeature,"data-feature-index":o,onCalciteListItemSelect:this._selectFeature},I("span",{slot:"content",innerHTML:e.title||this.messagesCommon.untitled}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const s=i.layer,o=t.get(s)??[];t.set(s,[...o,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?I("calcite-list",{selectionMode:"single",selectionAppearance:"icon"},Array.from(t.keys()).map((e=>I("calcite-list-item-group",{key:e?.uid||"untitled",heading:e?.title??this.messagesCommon.untitled},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderCollapseAction(){const{messagesCommon:e,_collapseEnabled:t,_isCollapsed:i,featureNavigationTop:s}=this,o=i?e.expand:e.collapse,r=["chevron-up","chevron-down"];return s&&r.reverse(),t?I("calcite-action",{bind:this,class:m.actionCollapse,"aria-expanded":(!i).toString(),key:"collapse-button",icon:i?r[0]:r[1],slot:"header-actions-end",onclick:this._toggleCollapsed,text:e.collapse,title:o,scale:"m"}):null}_renderHeaderAction(e,t){return e.visible?I("calcite-action",{appearance:"solid",bind:this,slot:"header-actions-end",icon:e.icon||"",onclick:this._triggerHeaderAction,"data-action-uid":e.uid,disabled:e.disabled,indicator:e.indicator,loading:e.active,active:"toggle"===e.type&&e.value,key:`header-action-${t}`,text:e.title||"",title:e.title||"",scale:"m"}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t}=this,{title:i,active:s}=this.viewModel,o=t.heading&&i?i:"";return I("calcite-flow-item",{bind:this,closed:!s,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:this._isCollapsed}),closable:t.closeButton,headingLevel:e,onCalciteFlowItemClose:this.close,afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,key:"root-flow-item",onkeydown:this._onMainKeydown},o?I(M,{class:this.classes(m.featuresHeading,m.heading),level:this.headingLevel,key:"header-content",slot:"header-content",innerHTML:o}):null,this._renderCollapseAction(),this._renderHeaderActions(),this._renderActionBar(),this._isCollapsed?null:I("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:s}=this,{active:o,featureViewModels:r,pendingPromisesCount:n}=e;return t?I("calcite-flow-item",{bind:this,closable:!1,closed:!o,afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,loading:e.waitingForContents,heading:i.selectFeature,description:C(i.total,{total:r.length}),key:"feature-menu",onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?I("calcite-loader",{inline:!0,class:m.loader,key:"feature-menu-loader",scale:"m",label:s.loading,slot:"header-actions-end"}):null,I("div",{class:m.container},this._renderFeatureMenu()),I("div",{class:m.featureMenuObserver,bind:this,afterCreate:this._featureMenuIntersectionObserverCreated}),I("calcite-button",{onclick:this._handleFeatureMenuBack,slot:"footer-actions",appearance:"transparent",width:"full"},s.back)):null}_renderContentContainer(){const{content:e}=this.viewModel;return I("calcite-flow",{key:e??"content"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:s}=e;return s&&i?C(s,i):s??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s=this._getActionImage(e),o={[m.icon]:!!t,[m.actionImage]:!!s};return t&&(o[t]=!0),s||t?I("span",{key:"icon","aria-hidden":"true",class:this.classes(m.icon,o),styles:s&&this._getIconStyles(s)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?I("calcite-action-bar",{key:"header-action-bar",expanded:!this._hideActionText,expandDisabled:!0,slot:"action-bar",scale:"s"},I("calcite-action-group",{scale:"s",overlayPositioning:"fixed"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?I("div",{class:h.contentNode,key:e,innerHTML:e}):this.renderNodeContent(e):null}_toggleCollapsed(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const s=f(i);this.open({features:[t],location:null!=s?s:void 0})}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFeatureMenuFlowItem&&(this._focusFeatureMenuFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuFlowItem=!0}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:s}=this,{id:o}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===o?C(n,{messages:t}):"remove-selected-feature"===o?C(n,{messages:s}):"zoom-to-clustered-features"===o||"browse-clustered-features"===o?C(n,{messages:t}):e.title;return a&&r?C(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=o((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,x)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this.featureMenuOpen=!1,this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,s=this.headerActions.find((({uid:e})=>e===i));s&&!s.disabled&&("toggle"===s?.type&&(s.value=!s.value),this.emit("trigger-header-action",{action:s}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:s}=this.viewModel,o=s.findIndex((e=>e.uid===i)),r=s.at(o);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(o)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],k.prototype,"_focusFeatureMenuFlowItem",void 0),e([a()],k.prototype,"_relatedRecordsFlowItems",void 0),e([a()],k.prototype,"_focusRootFlowItem",void 0),e([a()],k.prototype,"_hideActionText",null),e([a()],k.prototype,"_featureNavigationVisible",null),e([a()],k.prototype,"_isCollapsed",null),e([a()],k.prototype,"_collapseEnabled",null),e([a()],k.prototype,"collapsed",void 0),e([a()],k.prototype,"content",null),e([a()],k.prototype,"icon",void 0),e([a()],k.prototype,"featureMenuOpen",null),e([a()],k.prototype,"featureNavigationTop",void 0),e([a()],k.prototype,"features",null),e([a({type:_})],k.prototype,"headerActions",void 0),e([a()],k.prototype,"headingLevel",void 0),e([a()],k.prototype,"location",null),e([a()],k.prototype,"label",null),e([a(),b("esri/widgets/Features/t9n/Features")],k.prototype,"messages",void 0),e([a(),b("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([a()],k.prototype,"promises",null),e([a()],k.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],k.prototype,"selectedFeature",null),e([a()],k.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],k.prototype,"selectedFeatureWidget",null),e([a()],k.prototype,"title",null),e([a()],k.prototype,"updateLocationEnabled",null),e([a()],k.prototype,"view",null),e([a({type:g}),y(["triggerAction","trigger-action"])],k.prototype,"viewModel",void 0),e([a({type:w,nonNullable:!0})],k.prototype,"visibleElements",void 0),e([a()],k.prototype,"visible",null),k=e([l("esri.widgets.Features")],k);const N=k;export{N as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import s from"../core/Logger.js";import{watch as o,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import g from"./Features/FeaturesViewModel.js";import w from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as _}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{Heading as M}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{vmEvent as y}from"./support/decorators/vmEvent.js";import{tsx as I}from"./support/jsxFactory.js";import{substitute as C}from"../intl/substitute.js";import{formatNumber as A}from"../intl/number.js";const x="selected-index",R=0,j="features-spinner";let k=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusFeatureMenuFlowItem=!1,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._focusRootFlowItem=!1,this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new _,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new g,this.visibleElements=new w,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:s,active:o,uid:r,disabled:n,indicator:a}=e;return e.visible?I("calcite-action",{appearance:"solid",bind:this,icon:this._getActionIcon(e),onclick:this._triggerAction,"data-action-uid":r,disabled:n,indicator:a,loading:o,title:this._hideActionText?i:void 0,active:"toggle"===s&&e.value,key:`action-${t}`,text:i,scale:"s"},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this._focusRootFlowItem=!0,this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1},this._displaySpinnerThrottled=n((()=>this._displaySpinner()),R),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,o((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),o((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),o((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),o((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),o((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),o((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),o((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),o((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),o((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),o((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:s}=this.viewModel,o={title:!1};return s?(e?(e.viewModel=s,e.visibleElements=o):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:s,visibleElements:o}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||s.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),this._rootFlowItemNode?.blur()}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{container:e}=this,{active:t}=this.viewModel;if(t||s.getLogger(this.declaredClass).warn("Features can only be blurred when currently active."),!e)return;const i=e.querySelectorAll("calcite-flow-item"),o=i[i?.length-1];this.scheduleRender(),requestAnimationFrame((()=>o?.setFocus()))}next(){return this.viewModel.next()}open(e){this.removeHandles(x);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return I("div",{class:this.classes(m.base,m.esriWidget,m.esriWidgetPanel)},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?I("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:I("div",{slot:"footer",class:m.footer,key:"footer-actions"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:s,pendingPromisesCount:o}=t;return I("calcite-action",{loading:o>0,appearance:"solid",key:"feature-menu-button",bind:this,textEnabled:!0,label:e.selectFeature,text:C(e.pageText,{index:A(s+1),total:A(i)}),title:e.selectFeature,onclick:this._openFeatureMenu,icon:"list",scale:"s"})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return I("calcite-action-bar",{layout:"horizontal",key:"pagination-action-bar",expandDisabled:!0,class:m.paginationActionBar,scale:"s",overflowActionsDisabled:!0},I("calcite-action-group",{scale:"s"},I("calcite-action",{appearance:"solid",class:m.paginationPrevious,label:e,title:e,text:e,iconFlipRtl:!0,icon:"chevron-left",onclick:this._previousFeature,scale:"s"}),I("calcite-action",{appearance:"solid",label:t,text:t,title:t,iconFlipRtl:!0,icon:"chevron-right",onclick:this._nextFeature,scale:"s"})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,s=e===t,o=i.indexOf(e);return I("calcite-list-item",{bind:this,key:`feature-menu-item-${e.uid}`,selected:s,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseover:this._setActiveFeature,onmouseleave:this._removeActiveFeature,"data-feature-index":o,onCalciteListItemSelect:this._selectFeature},I("span",{slot:"content",innerHTML:e.title||this.messagesCommon.untitled}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const s=i.sourceLayer??i.layer,o=t.get(s)??[];t.set(s,[...o,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?I("calcite-list",{selectionMode:"single",selectionAppearance:"icon"},Array.from(t.keys()).map((e=>I("calcite-list-item-group",{key:e?.uid||"untitled",heading:e?.title??this.messagesCommon.untitled},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderCollapseAction(){const{messagesCommon:e,_collapseEnabled:t,_isCollapsed:i,featureNavigationTop:s}=this,o=i?e.expand:e.collapse,r=["chevron-up","chevron-down"];return s&&r.reverse(),t?I("calcite-action",{bind:this,class:m.actionCollapse,"aria-expanded":(!i).toString(),key:"collapse-button",icon:i?r[0]:r[1],slot:"header-actions-end",onclick:this._toggleCollapsed,text:e.collapse,title:o,scale:"m"}):null}_renderHeaderAction(e,t){return e.visible?I("calcite-action",{appearance:"solid",bind:this,slot:"header-actions-end",icon:e.icon||"",onclick:this._triggerHeaderAction,"data-action-uid":e.uid,disabled:e.disabled,indicator:e.indicator,loading:e.active,active:"toggle"===e.type&&e.value,key:`header-action-${t}`,text:e.title||"",title:e.title||"",scale:"m"}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t}=this,{title:i,active:s}=this.viewModel,o=t.heading&&i?i:"";return I("calcite-flow-item",{bind:this,closed:!s,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:this._isCollapsed}),closable:t.closeButton,headingLevel:e,onCalciteFlowItemClose:this.close,afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,key:"root-flow-item",onkeydown:this._onMainKeydown},o?I(M,{class:this.classes(m.featuresHeading,m.heading),level:this.headingLevel,key:"header-content",slot:"header-content",innerHTML:o}):null,this._renderCollapseAction(),this._renderHeaderActions(),this._renderActionBar(),this._isCollapsed?null:I("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:s}=this,{active:o,featureViewModels:r,pendingPromisesCount:n}=e;return t?I("calcite-flow-item",{bind:this,closable:!1,closed:!o,afterCreate:this._focusFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,loading:e.waitingForContents,heading:i.selectFeature,description:C(i.total,{total:r.length}),key:"feature-menu",onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?I("calcite-loader",{inline:!0,class:m.loader,key:"feature-menu-loader",scale:"m",label:s.loading,slot:"header-actions-end"}):null,I("div",{class:m.container},this._renderFeatureMenu()),I("div",{class:m.featureMenuObserver,bind:this,afterCreate:this._featureMenuIntersectionObserverCreated}),I("calcite-button",{onclick:this._handleFeatureMenuBack,slot:"footer-actions",appearance:"transparent",width:"full"},s.back)):null}_renderContentContainer(){const{content:e}=this.viewModel;return I("calcite-flow",{key:e??"content"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:s}=e;return s&&i?C(s,i):s??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s=this._getActionImage(e),o={[m.icon]:!!t,[m.actionImage]:!!s};return t&&(o[t]=!0),s||t?I("span",{key:"icon","aria-hidden":"true",class:this.classes(m.icon,o),styles:s&&this._getIconStyles(s)}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?I("calcite-action-bar",{key:"header-action-bar",expanded:!this._hideActionText,expandDisabled:!0,slot:"action-bar",scale:"s"},I("calcite-action-group",{scale:"s",overlayPositioning:"fixed"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?I("div",{class:h.contentNode,key:e,innerHTML:e}):this.renderNodeContent(e):null}_toggleCollapsed(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const s=f(i);this.open({features:[t],location:null!=s?s:void 0})}_focusRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFeatureMenuFlowItem&&(this._focusFeatureMenuFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this.featureMenuOpen=!1,this._focusFeatureMenuFlowItem=!0}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:s}=this,{id:o}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===o?C(n,{messages:t}):"remove-selected-feature"===o?C(n,{messages:s}):"zoom-to-clustered-features"===o||"browse-clustered-features"===o?C(n,{messages:t}):e.title;return a&&r?C(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=o((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,x)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this.featureMenuOpen=!1,this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,s=this.headerActions.find((({uid:e})=>e===i));s&&!s.disabled&&("toggle"===s?.type&&(s.value=!s.value),this.emit("trigger-header-action",{action:s}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:s}=this.viewModel,o=s.findIndex((e=>e.uid===i)),r=s.at(o);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(o)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:j,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,j),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],k.prototype,"_focusFeatureMenuFlowItem",void 0),e([a()],k.prototype,"_relatedRecordsFlowItems",void 0),e([a()],k.prototype,"_focusRootFlowItem",void 0),e([a()],k.prototype,"_hideActionText",null),e([a()],k.prototype,"_featureNavigationVisible",null),e([a()],k.prototype,"_isCollapsed",null),e([a()],k.prototype,"_collapseEnabled",null),e([a()],k.prototype,"collapsed",void 0),e([a()],k.prototype,"content",null),e([a()],k.prototype,"icon",void 0),e([a()],k.prototype,"featureMenuOpen",null),e([a()],k.prototype,"featureNavigationTop",void 0),e([a()],k.prototype,"features",null),e([a({type:_})],k.prototype,"headerActions",void 0),e([a()],k.prototype,"headingLevel",void 0),e([a()],k.prototype,"location",null),e([a()],k.prototype,"label",null),e([a(),b("esri/widgets/Features/t9n/Features")],k.prototype,"messages",void 0),e([a(),b("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([a()],k.prototype,"promises",null),e([a()],k.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],k.prototype,"selectedFeature",null),e([a()],k.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],k.prototype,"selectedFeatureWidget",null),e([a()],k.prototype,"title",null),e([a()],k.prototype,"updateLocationEnabled",null),e([a()],k.prototype,"view",null),e([a({type:g}),y(["triggerAction","trigger-action"])],k.prototype,"viewModel",void 0),e([a({type:w,nonNullable:!0})],k.prototype,"visibleElements",void 0),e([a()],k.prototype,"visible",null),k=e([l("esri.widgets.Features")],k);const N=k;export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import s from"../../config.js";import r from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import{isSome as l}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Logger.js";import{eachAlways as h,after as p}from"../../core/promiseUtils.js";import{watch as g,whenOnce as d,initial as m}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import S from"../../geometry/Point.js";import _ from"../../geometry/SpatialReference.js";import{onLocaleChange as v}from"../../intl/locale.js";import{fetchMessageBundle as w}from"../../intl/messages.js";import b from"../../portal/Portal.js";import{highlightsSupported as x}from"../../views/support/layerViewUtils.js";import I from"./LayerSearchSource.js";import L from"./LocatorSearchSource.js";import T from"./SearchSource.js";import{getPointFromGeometry as R,getPointWithElevation as E}from"./support/geometryUtils.js";import{isArcGISWorldGeocoder as F,meteredArcGISLocatorUrl as j,isProxiedArcGISWorldGeocoder as P,isMeteredArcGISWorldGeocoder as C}from"./support/locatorUtils.js";import{supported as G,getCurrentPosition as O,positionToPoint as A}from"../support/geolocationUtils.js";import{GoToMixin as N}from"../support/GoTo.js";import D from"../../symbols/PictureMarkerSymbol.js";import M from"../../symbols/SimpleLineSymbol.js";import V from"../../symbols/SimpleFillSymbol.js";import k from"../../symbols/TextSymbol.js";function J(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const H=()=>w("esri/widgets/Search/t9n/Search"),U="esri.widgets.Search.SearchViewModel",B=c.getLogger(U),Q="highlight",Z=a.ofType({key:e=>e.layer?"layer":"locator",base:T,typeMap:{layer:I,locator:L}}),q=_.WGS84,z="esri/images/search/search-symbol-32.png",K=/<(?:.|\s)*?>/g,W=-1;let X=class extends(N(u.EventedMixin(i))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Z,this.defaultSymbols={point:new D({url:t(z),size:24,width:24,height:24}),polyline:new M({color:[130,130,130,1],width:2}),polygon:new V({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=b.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Z,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await H();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([g((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),m),v(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:W}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new Z;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||G()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=G();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});B.error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===W)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replace(K,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw B.error(e),e}const t=(async()=>{try{const t=await O(),s=await A({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw B.error(t),t}const{view:t}=this,s=J(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});throw B.error(e),e}const i=o instanceof I?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=J(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=J(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,c=(J(o,"popupEnabled")?o.popupEnabled:this.popupEnabled)?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:p}=e;if(!p){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:p});throw B.error(e),e}const{attributes:g,geometry:d,layer:m,sourceLayer:y}=p,f=R(d),S={layerViewQuery:this._getLayerView(p),elevationQuery:t&&null!=f?E(f,t).catch((()=>f)):Promise.resolve(f)},_=await h(S),v=_.layerViewQuery.value,w=_.elevationQuery.value;l instanceof k&&(l.text=e.name);const b=t&&u?e.target||e.extent:null,L=null!=b?this._goToSearchResult(b):Promise.resolve();await L;const T=v?p:new r({geometry:d,symbol:l,attributes:g,layer:m,sourceLayer:y,popupTemplate:c}),F=t?.popup,j=F&&T.getEffectivePopupTemplate(F.defaultPopupTemplateEnabled);return j&&await t.openPopup({features:[T],location:w}),v&&x(v)&&!j&&this._highlightFeature({graphic:T,layerView:v}),!v&&a&&t&&t.graphics.push(T),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",T),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await d((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=h([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}await d((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=s.apiKey&&F(e.url)?{url:j}:null,r=L.fromJSON({...e,...t}),o=r.url;if(F(o)||P(o)||C(o)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0})).filter(l)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map((e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=I.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map((e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=I.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find((e=>e.id===t.subLayer));if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return B.error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const s="selectedFeature"in e,r=s?e.selectedFeature:null;s&&(r&&r===t)&&e.close()}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return p(s,null,t&&t.signal)}_createLocationForSearch(e){return e instanceof r?R(e.geometry):e instanceof S?e:Array.isArray(e)&&2===e.length?new S({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&J(e,"key")&&J(e,"text")&&J(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){let t=null;return e&&e.some((e=>{const{results:s}=e,r=s?.[0],o=!!r;return o&&(t=r),o})),t}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),B.error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===W){const r=s&&J(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach(((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&J(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:s});throw B.error(e),e}return r===W?s.forEach(((s,r)=>{o.push(this._getResultsFromSource(e,r,t))})):o.push(this._getResultsFromSource(e,r,t)),h(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw B.error(e),e}return r===W?s.forEach(((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))})):o.push(this._getSuggestionsFromSource(e,r,t)),h(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference||q,l=J(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof I&&J(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=J(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=J(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||q,i=J(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof I&&J(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return J(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){const t=this.results;if(!t)return null;let s=null;return t.some((t=>t.results.some((r=>r===e&&(s=t.sourceIndex,!0))))),s}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(Q)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:s}=e;return s?(await t.when(),t.whenLayerView(s)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o}=t,{objectIdField:i}=o,l=(i&&r?.[i])??null,a=s.highlight(l??t);this.addHandles(a,Q)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};X.ALL_INDEX=W,e([y()],X.prototype,"_searching",void 0),e([y()],X.prototype,"_updatingPromise",void 0),e([y({readOnly:!0,value:null})],X.prototype,"activeSource",null),e([y()],X.prototype,"activeSourceIndex",null),e([y()],X.prototype,"allPlaceholder",null),e([y({readOnly:!0})],X.prototype,"allSources",null),e([y()],X.prototype,"autoNavigate",void 0),e([y()],X.prototype,"autoSelect",void 0),e([y()],X.prototype,"defaultPopupTemplate",void 0),e([y({readOnly:!0})],X.prototype,"defaultSources",void 0),e([y()],X.prototype,"defaultSymbols",void 0),e([y()],X.prototype,"includeDefaultSources",void 0),e([y()],X.prototype,"locationEnabled",null),e([y()],X.prototype,"maxInputLength",void 0),e([y()],X.prototype,"maxResults",void 0),e([y()],X.prototype,"maxSuggestions",void 0),e([y()],X.prototype,"messages",void 0),e([y()],X.prototype,"minSuggestCharacters",void 0),e([y({readOnly:!0})],X.prototype,"placeholder",null),e([y()],X.prototype,"popupEnabled",void 0),e([y({type:o})],X.prototype,"popupTemplate",void 0),e([y({type:b})],X.prototype,"portal",void 0),e([y()],X.prototype,"resultCount",void 0),e([y()],X.prototype,"resultGraphicEnabled",void 0),e([y({readOnly:!0})],X.prototype,"resultGraphic",void 0),e([y({readOnly:!0})],X.prototype,"results",void 0),e([y({readOnly:!0})],X.prototype,"selectedSuggestion",void 0),e([y()],X.prototype,"searchAllEnabled",void 0),e([y({readOnly:!0})],X.prototype,"selectedResult",void 0),e([y()],X.prototype,"searchTerm",null),e([y({type:Z})],X.prototype,"sources",void 0),e([y({readOnly:!0})],X.prototype,"state",null),e([y()],X.prototype,"suggestionDelay",void 0),e([y()],X.prototype,"suggestionCount",void 0),e([y({readOnly:!0})],X.prototype,"suggestions",void 0),e([y()],X.prototype,"suggestionsEnabled",void 0),e([y({readOnly:!0})],X.prototype,"updating",null),e([y()],X.prototype,"view",void 0),e([y()],X.prototype,"clear",null),X=e([f(U)],X);const Y=X;export{Y as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import s from"../../config.js";import r from"../../Graphic.js";import o from"../../PopupTemplate.js";import"../../symbols.js";import i from"../../core/Accessor.js";import{isSome as l}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Logger.js";import{eachAlways as h,after as p}from"../../core/promiseUtils.js";import{watch as g,whenOnce as d,initial as m}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import S from"../../geometry/Point.js";import _ from"../../geometry/SpatialReference.js";import{onLocaleChange as v}from"../../intl/locale.js";import{fetchMessageBundle as w}from"../../intl/messages.js";import b from"../../portal/Portal.js";import{highlightsSupported as x}from"../../views/support/layerViewUtils.js";import I from"./LayerSearchSource.js";import L from"./LocatorSearchSource.js";import T from"./SearchSource.js";import{getPointFromGeometry as R,getPointWithElevation as E}from"./support/geometryUtils.js";import{isArcGISWorldGeocoder as F,meteredArcGISLocatorUrl as j,isProxiedArcGISWorldGeocoder as P,isMeteredArcGISWorldGeocoder as C}from"./support/locatorUtils.js";import{supported as G,getCurrentPosition as O,positionToPoint as A}from"../support/geolocationUtils.js";import{GoToMixin as N}from"../support/GoTo.js";import D from"../../symbols/PictureMarkerSymbol.js";import M from"../../symbols/SimpleLineSymbol.js";import V from"../../symbols/SimpleFillSymbol.js";import k from"../../symbols/TextSymbol.js";function J(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const H=()=>w("esri/widgets/Search/t9n/Search"),U="esri.widgets.Search.SearchViewModel",B=c.getLogger(U),Q="highlight",Z=a.ofType({key:e=>e.layer?"layer":"locator",base:T,typeMap:{layer:I,locator:L}}),q=_.WGS84,z="esri/images/search/search-symbol-32.png",K=/<[\s\S]*?>/g,W=-1;let X=class extends(N(u.EventedMixin(i))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Z,this.defaultSymbols={point:new D({url:t(z),size:24,width:24,height:24}),polyline:new M({color:[130,130,130,1],width:2}),polygon:new V({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=b.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Z,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await H();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([g((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),m),v(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:W}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:s}=this,r="function"==typeof s?s.call(null,{sources:e,defaultSources:t}):s?t.concat(e):e,o=this._get("allSources")||new Z;return o.removeAll(),o.addMany(r.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||G()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=G();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});B.error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:s}=this;if(t===W)return s??"";const r=e.at(t);return r?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const s=this._createSuggestionForSearch(e),r=(async()=>{try{await this.when();const e=await this._getResultsFromSources(s,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:s.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(r,e,s);const o=this._getFirstResult(r.results),i=s.location&&o?o.name:s.text,l=i?.replace(K,"");return this._set("searchTerm",l),(s.key&&"number"==typeof s.sourceIndex||s.location)&&this._set("selectedSuggestion",s),this._set("results",r.results),this._set("resultCount",r.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",r),await this._selectFirstResult(o),r}finally{this._clearSearching()}})();return this._searching=r,r}async searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw B.error(e),e}const t=(async()=>{try{const t=await O(),s=await A({position:t,view:this.view},e);return await this.search(s,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw B.error(t),t}const{view:t}=this,s=J(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});throw B.error(e),e}const i=o instanceof I?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=J(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=J(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,c=(J(o,"popupEnabled")?o.popupEnabled:this.popupEnabled)?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:p}=e;if(!p){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:p});throw B.error(e),e}const{attributes:g,geometry:d,layer:m,sourceLayer:y}=p,f=R(d),S={layerViewQuery:this._getLayerView(p),elevationQuery:t&&null!=f?E(f,t).catch((()=>f)):Promise.resolve(f)},_=await h(S),v=_.layerViewQuery.value,w=_.elevationQuery.value;l instanceof k&&(l.text=e.name);const b=t&&u?e.target||e.extent:null,L=null!=b?this._goToSearchResult(b):Promise.resolve();await L;const T=v?p:new r({geometry:d,symbol:l,attributes:g,layer:m,sourceLayer:y,popupTemplate:c}),F=t?.popup,j=F&&T.getEffectivePopupTemplate(F.defaultPopupTemplateEnabled);return j&&await t.openPopup({features:[T],location:w}),v&&x(v)&&!j&&this._highlightFeature({graphic:T,layerView:v}),!v&&a&&t&&t.graphics.push(T),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",T),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,s){const r=e||this.searchTerm;this.emit("suggest-start",{searchTerm:r}),await this._suggestTimer(t,s);const o=await this._suggestImmediate(r,s);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await d((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const s=this._updatingPromise=h([e?.load(),t?.when()]);if(this.destroyed)return;if(await s,s!==this._updatingPromise)return}await d((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=s.apiKey&&F(e.url)?{url:j}:null,r=L.fromJSON({...e,...t}),o=r.url;if(F(o)||P(o)||C(o)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0})).filter(l)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const s=this.view?.map;return e.map((e=>{const r=s.findLayerById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=I.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_getTableSources(e,t){const s=this.view?.map;return e.map((e=>{if(!e.id)return;const r=s.findTableById(e.id);if(!r)return;const o=this._getLayerJSON(e),i=I.fromJSON(o);return i.placeholder=t,this._getLayer(r,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:s,hintText:r,layers:o,tables:i}=t;if(!s)return[];return[...this._getLayerSources(o,r),...this._getTableSources(i,r)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const s=e.allSublayers.find((e=>e.id===t.subLayer));if(!s)throw new Error;const r=await(s.createFeatureLayer?.());if(!r)throw new Error;return this._createdFeatureLayers.push(r),r}async _getBuildingSubLayer(e,t){await e.load();const s=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==s?.type)throw new Error;if(await s.load(),null==s.associatedLayer)throw new Error;return await s.associatedLayer.load(),s}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(s){const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return B.error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const s="selectedFeature"in e,r=s?e.selectedFeature:null;s&&(r&&r===t)&&e.close()}_suggestTimer(e,t){const s=null!=e?e:this.suggestionDelay;return p(s,null,t&&t.signal)}_createLocationForSearch(e){return e instanceof r?R(e.geometry):e instanceof S?e:Array.isArray(e)&&2===e.length?new S({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&J(e,"key")&&J(e,"text")&&J(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),s="string"==typeof e?e:this.searchTerm,{selectedSuggestion:r,selectedResult:o}=this,i=!e&&r&&o,l=i&&r.key===o.key&&r.sourceIndex===o.sourceIndex,a=i&&r.location;return l||a?r:{location:t,text:t?"":s,sourceIndex:null,key:null}}_getFirstResult(e){let t=null;return e&&e.some((e=>{const{results:s}=e,r=s?.[0],o=!!r;return o&&(t=r),o})),t}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const s=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const r={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(r,s),r}_formatSourceResponse(e,t,s){const r=t?.value||[],o=t?.error,i=this.allSources.at(s);if(o){const t={sourceIndex:s,source:i,error:o};e.errors.push(t),B.error(o),e.numErrors++}else{const t={sourceIndex:s,source:i,results:r};e.results.push(t),e.numResults+=r.length}}_formatResponse(e,t,s){if(t)if(e.activeSourceIndex===W){const r=s&&J(s,"sourceIndex")&&-1!==s.sourceIndex?s.sourceIndex:void 0;t.forEach(((t,s)=>{const o=void 0!==r?r:s;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:s}=this,r=!e.location&&J(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!s.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:s});throw B.error(e),e}return r===W?s.forEach(((s,r)=>{o.push(this._getResultsFromSource(e,r,t))})):o.push(this._getResultsFromSource(e,r,t)),h(o)}async _getSuggestionsFromSources(e,t){const{allSources:s,activeSourceIndex:r}=this,o=[];if(!s.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:s});throw B.error(e),e}return r===W?s.forEach(((s,r)=>{o.push(this._getSuggestionsFromSource(e,r,t))})):o.push(this._getSuggestionsFromSource(e,r,t)),h(o)}async _getResultsFromSource(e,t,s){const r=null!=t?this.allSources.at(t):null;if(!r)return null;const{location:o=null}=e,i=this.view?.spatialReference||q,l=J(r,"maxResults")?r.maxResults:this.maxResults,a=!!(r instanceof I&&J(r,"exactMatch"))&&r.exactMatch,{view:n}=this;return r.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},s)}async _getSuggestionsFromSource(e,t,s){const r=this.allSources.at(t);if(!r)return null;e??="";const o=J(r,"suggestionsEnabled")?r.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=J(r,"minSuggestCharacters")?r.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||q,i=J(r,"maxSuggestions")?r.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(r instanceof I&&J(r,"exactMatch"))&&r.exactMatch;return r.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},s)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return J(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){const t=this.results;if(!t)return null;let s=null;return t.some((t=>t.results.some((r=>r===e&&(s=t.sourceIndex,!0))))),s}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const s={target:{target:e},options:{signal:t.signal}};e||(s.options.animate=!1),await this.callGoTo(s),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,s=e.feature?.geometry;if(null==s)return null;switch(s.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(Q)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:s}=e;return s?(await t.when(),t.whenLayerView(s)):null}_highlightFeature(e){const{graphic:t,layerView:s}=e,{attributes:r,layer:o}=t,{objectIdField:i}=o,l=(i&&r?.[i])??null,a=s.highlight(l??t);this.addHandles(a,Q)}_setResultFloor(e){const{view:t}=this,s=e.feature?.attributes,r=e.feature?.sourceLayer;if(r&&"floorInfo"in r&&r?.floorInfo?.floorField&&s){const e=s[r.floorInfo.floorField];t?.emit("select-result-floor",e)}}};X.ALL_INDEX=W,e([y()],X.prototype,"_searching",void 0),e([y()],X.prototype,"_updatingPromise",void 0),e([y({readOnly:!0,value:null})],X.prototype,"activeSource",null),e([y()],X.prototype,"activeSourceIndex",null),e([y()],X.prototype,"allPlaceholder",null),e([y({readOnly:!0})],X.prototype,"allSources",null),e([y()],X.prototype,"autoNavigate",void 0),e([y()],X.prototype,"autoSelect",void 0),e([y()],X.prototype,"defaultPopupTemplate",void 0),e([y({readOnly:!0})],X.prototype,"defaultSources",void 0),e([y()],X.prototype,"defaultSymbols",void 0),e([y()],X.prototype,"includeDefaultSources",void 0),e([y()],X.prototype,"locationEnabled",null),e([y()],X.prototype,"maxInputLength",void 0),e([y()],X.prototype,"maxResults",void 0),e([y()],X.prototype,"maxSuggestions",void 0),e([y()],X.prototype,"messages",void 0),e([y()],X.prototype,"minSuggestCharacters",void 0),e([y({readOnly:!0})],X.prototype,"placeholder",null),e([y()],X.prototype,"popupEnabled",void 0),e([y({type:o})],X.prototype,"popupTemplate",void 0),e([y({type:b})],X.prototype,"portal",void 0),e([y()],X.prototype,"resultCount",void 0),e([y()],X.prototype,"resultGraphicEnabled",void 0),e([y({readOnly:!0})],X.prototype,"resultGraphic",void 0),e([y({readOnly:!0})],X.prototype,"results",void 0),e([y({readOnly:!0})],X.prototype,"selectedSuggestion",void 0),e([y()],X.prototype,"searchAllEnabled",void 0),e([y({readOnly:!0})],X.prototype,"selectedResult",void 0),e([y()],X.prototype,"searchTerm",null),e([y({type:Z})],X.prototype,"sources",void 0),e([y({readOnly:!0})],X.prototype,"state",null),e([y()],X.prototype,"suggestionDelay",void 0),e([y()],X.prototype,"suggestionCount",void 0),e([y({readOnly:!0})],X.prototype,"suggestions",void 0),e([y()],X.prototype,"suggestionsEnabled",void 0),e([y({readOnly:!0})],X.prototype,"updating",null),e([y()],X.prototype,"view",void 0),e([y()],X.prototype,"clear",null),X=e([f(U)],X);const Y=X;export{Y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";const e="esri.widgets.support.SketchTooltipControls.SketchTooltipControlsViewModel";let p=class extends r{constructor(o){super(o)}};o([s()],p.prototype,"labelOptions",void 0),o([s()],p.prototype,"tooltipOptions",void 0),p=o([t(e)],p);const c=p;export{c as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../../views/interactive/sketch/SketchLabelOptions.js";import p from"../../../views/interactive/sketch/SketchTooltipOptions.js";const i="esri.widgets.support.SketchTooltipControls.SketchTooltipControlsViewModel";let c=class extends t{constructor(o){super(o),this.labelOptions=new r,this.tooltipOptions=new p}};o([s({type:r,nonNullable:!0})],c.prototype,"labelOptions",void 0),o([s({type:p,nonNullable:!0})],c.prototype,"tooltipOptions",void 0),c=o([e(i)],c);const l=c;export{l as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{destroyMaybe as t}from"../../core/maybe.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{loadCalciteComponents as i}from"./componentsUtils.js";import{loadLabeledSwitchComponents as n,LabeledSwitch as r}from"./LabeledSwitch.js";import"./widgetUtils.js";import{messageBundle as p}from"./decorators/messageBundle.js";import{tsx as a}from"./jsxFactory.js";import c from"./SketchTooltipControls/SketchTooltipControlsViewModel.js";import d from"./SketchTooltipControls/VisibleElements.js";const h="esri-sketch-tooltip-controls",b={base:h,panel:`${h}__panel`,block:`${h}__block`,blockContent:`${h}__block-content`,hintIcon:`${h}__hint-icon`,widgetIcon:"esri-icon-gear",esriWidget:"esri-widget"};let g=class extends s{constructor(e,t){super(e,t),this._defaultViewModel=null,this.icon=null,this.iconClass=b.widgetIcon,this.visibleElements=new d,this.viewType=void 0,this._onTooltipsEnabledChange=e=>{this.tooltipOptions.enabled=e},this._onLabelsEnabledChange=e=>{this.labelOptions.enabled=e};const{tooltipOptions:o,labelOptions:l,viewModel:s}=e;this.viewModel=s??(this._defaultViewModel=new c({tooltipOptions:o,labelOptions:l}))}loadDependencies(){return Promise.all([i({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js")}),n()])}render(){const{label:e,visibleElements:t}=this;return a("div",{"aria-label":e,cass:this.classes(b.base,b.esriWidget)},t.header?this._renderHeader():this._renderContent())}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}set viewModel(e){e!==this._get("viewModel")&&(null!=this._defaultViewModel&&this._defaultViewModel===e||(this._defaultViewModel=t(this._defaultViewModel)),this._set("viewModel",e))}_renderContent(){const{messages:e,tooltipOptions:t,labelOptions:o,visibleElements:l}=this,s=[];return l.tooltipsToggle&&s.push(a(r,{checked:t.enabled,hint:e.tooltipsToggleHint,key:`${this.id}__tooltips`,label:e.tooltipsToggle,onChange:this._onTooltipsEnabledChange})),l.labelsToggle&&"3d"===this.viewType&&s.push(a(r,{checked:o.enabled,hint:e.labelsToggleHint,key:`${this.id}__labels`,label:e.labelsToggle,onChange:this._onLabelsEnabledChange})),0===s.length?null:a("calcite-block",{class:b.block,heading:"",open:!0,key:"content-block"},a("div",{key:"content",class:b.blockContent},l.tooltipsToggle&&a(r,{checked:t.enabled,hint:e.tooltipsToggleHint,key:`${this.id}__tooltips`,label:e.tooltipsToggle,onChange:this._onTooltipsEnabledChange}),l.labelsToggle&&"3d"===this.viewType&&a(r,{checked:o.enabled,hint:e.labelsToggleHint,key:`${this.id}__labels`,label:e.labelsToggle,onChange:this._onLabelsEnabledChange})))}_renderHeader(){return a("calcite-panel",{heading:this.label,class:b.panel},this._renderContent())}};e([o()],g.prototype,"icon",void 0),e([o()],g.prototype,"iconClass",void 0),e([o()],g.prototype,"label",null),e([o()],g.prototype,"labelOptions",null),e([o()],g.prototype,"tooltipOptions",null),e([o()],g.prototype,"viewModel",null),e([o({type:d,nonNullable:!0})],g.prototype,"visibleElements",void 0),e([o(),p("esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls")],g.prototype,"messages",void 0),e([o({type:String,nonNullable:!0})],g.prototype,"viewType",void 0),g=e([l("esri.widgets.support.SketchTooltipControls")],g);const m=g;export{m as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import i from"../Widget.js";import{loadCalciteComponents as n}from"./componentsUtils.js";import{loadLabeledSwitchComponents as r,LabeledSwitch as p}from"./LabeledSwitch.js";import"./widgetUtils.js";import{messageBundle as a}from"./decorators/messageBundle.js";import{tsx as c}from"./jsxFactory.js";import d from"./SketchTooltipControls/SketchTooltipControlsViewModel.js";import h from"./SketchTooltipControls/VisibleElements.js";const b="esri-sketch-tooltip-controls",g={base:b,block:`${b}__block`,blockContent:`${b}__block-content`,hintIcon:`${b}__hint-icon`,widgetIcon:"esri-icon-gear",esriWidget:"esri-widget"};let m=class extends i{constructor(e,t){super(e,t),this._defaultViewModel=null,this.icon=null,this.iconClass=g.widgetIcon,this.visibleElements=new h,this.viewType=void 0,this._onTooltipsEnabledChange=e=>{this.tooltipOptions.enabled=e},this._onLabelsEnabledChange=e=>{this.labelOptions.enabled=e};const{tooltipOptions:o,labelOptions:s,viewModel:l}=e;this.viewModel=l??(this._defaultViewModel=new d({tooltipOptions:o,labelOptions:s}))}loadDependencies(){return Promise.all([n({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js")}),r()])}render(){const{label:e,visibleElements:t}=this,o=this._renderContent();return c("div",{"aria-label":e,cass:this.classes(g.base,g.esriWidget)},o?c("calcite-block",{class:g.block,heading:t.header?this.label:"",key:"content-block",open:!0},c("div",{key:"content",class:g.blockContent},o)):void 0)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}set viewModel(e){e!==this._get("viewModel")&&(null!=this._defaultViewModel&&this._defaultViewModel===e||(this._defaultViewModel=o(this._defaultViewModel)),this._set("viewModel",e))}_renderContent(){const{visibleElements:e,viewType:o}=this,s=[e.tooltipsToggle?this._renderTooltipsToggle():null,e.labelsToggle&&"2d"!==o?this._renderLabelsToggle():null].filter(t);return 0===s.length?null:s}_renderTooltipsToggle(){const{messages:e,tooltipOptions:t}=this;return c(p,{checked:t.enabled,hint:e.tooltipsToggleHint,key:`${this.id}__tooltips`,label:e.tooltipsToggle,onChange:this._onTooltipsEnabledChange})}_renderLabelsToggle(){const{messages:e,labelOptions:t}=this;return c(p,{checked:t.enabled,hint:e.labelsToggleHint,key:`${this.id}__labels`,label:e.labelsToggle,onChange:this._onLabelsEnabledChange})}};e([s()],m.prototype,"icon",void 0),e([s()],m.prototype,"iconClass",void 0),e([s()],m.prototype,"label",null),e([s()],m.prototype,"labelOptions",null),e([s()],m.prototype,"tooltipOptions",null),e([s()],m.prototype,"viewModel",null),e([s({type:h,nonNullable:!0})],m.prototype,"visibleElements",void 0),e([s(),a("esri/widgets/support/SketchTooltipControls/t9n/SketchTooltipControls")],m.prototype,"messages",void 0),e([s({type:String})],m.prototype,"viewType",void 0),m=e([l("esri.widgets.support.SketchTooltipControls")],m);const u=m;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import{destroyMaybe as i}from"../../core/maybe.js";import{generateUID as s}from"../../core/uid.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import a from"../Widget.js";import{loadCalciteComponents as o}from"./componentsUtils.js";import{loadLabeledSwitchComponents as r,LabeledSwitch as c}from"./LabeledSwitch.js";import"./widgetUtils.js";import{messageBundle as d}from"./decorators/messageBundle.js";import{tsx as p}from"./jsxFactory.js";import g from"./SnappingControls/SnappingControlsViewModel.js";import h from"./SnappingControls/VisibleElements.js";const m="esri-snapping-controls",u={base:m,container:`${m}__container`,panel:`${m}__panel`,item:`${m}__item`,toggleBlock:`${m}__toggle-block`,layerListBlock:`${m}__layer-list-block`,layerList:`${m}__layer-list`,layerListFilter:`${m}__layer-list__filter`,layerListButton:`${m}__layer-list__button`,layerListItem:`${m}__layer-list__item`,layerListGroup:`${m}__layer-list__group`,nestedContainer:`${m}__nested-container`,disabled:"esri-disabled",esriWidget:"esri-widget",widgetIcon:"esri-icon-vertex-gps"},b={checked:"check-square-f",unchecked:"square",indeterminate:"minus-square"};let y=class extends a{constructor(e,t){super(e,t),this._defaultViewModel=null,this._layerListFilter=null,this.iconClass=u.widgetIcon,this.icon=null,this.layerListOpen=!0,this.messages=null,this.visibleElements=new h,this._enableSnappingSwitchChange=e=>{this.snappingOptions.enabled=e},this._featureEnabledSwitchChange=e=>{this.snappingOptions.featureEnabled=e},this._selfEnabledSwitchChange=e=>{this.snappingOptions.selfEnabled=e},this._onToggleLayersButtonClick=e=>{this.viewModel.toggleSnappingForAllLayers(!this.viewModel.allLayersEnabled),requestAnimationFrame((()=>e.target.setFocus()))};const{snappingOptions:i,view:s,viewModel:l}=e;this.viewModel=l??(this._defaultViewModel=new g({snappingOptions:i,view:s}))}normalizeCtorArgs(e){const{snappingOptions:t,view:i,viewModel:s,...l}=e;return l}destroy(){this.viewModel!==this._defaultViewModel&&(this._defaultViewModel=i(this._defaultViewModel))}loadDependencies(){return Promise.all([o({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js")}),r()])}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){e!==this._get("viewModel")&&(null!=this._defaultViewModel&&this._defaultViewModel===e||(this._defaultViewModel=i(this._defaultViewModel)),this._set("viewModel",e))}render(){const{label:e,visibleElements:t}=this;return p("div",{"aria-label":e,class:this.classes(u.base,u.esriWidget)},p("div",{class:u.container},t.header?this._renderHeader():this._renderContent()))}_renderHeader(){return p("calcite-panel",{heading:this.label,class:u.panel},this._renderContent())}_renderContent(){return[this._renderToggles(),this._renderLayerList()]}_renderToggles(){const{visibleElements:{enabledToggle:e,selfEnabledToggle:t,featureEnabledToggle:i}}=this;return e||t||i?p("calcite-block",{class:u.toggleBlock,key:"toggle-block",heading:"",open:!0},this._renderEnabledToggle(),p("div",{class:u.nestedContainer},this._renderSelfEnabledToggle(),this._renderFeatureEnabledToggle())):null}_renderEnabledToggle(){if(!this.visibleElements.enabledToggle)return null;const{messages:{enableSnapping:e},viewModel:{snappingOptions:{enabled:t,enabledToggled:i}}}=this;return p(c,{checked:t,disabled:i,key:`${this.id}__enabled-toggle`,label:e,onChange:this._enableSnappingSwitchChange})}_renderSelfEnabledToggle(){if(!this.visibleElements.selfEnabledToggle)return null;const{messages:{geometryGuides:e},viewModel:{snappingOptions:{enabled:t,selfEnabled:i,enabledToggled:s}}}=this;return p(c,{checked:i,disabled:s||!t,key:`${this.id}__self-enabled-toggle`,label:e,onChange:this._selfEnabledSwitchChange})}_renderFeatureEnabledToggle(){if(!this.visibleElements.featureEnabledToggle)return null;const{messages:{featureToFeature:e},viewModel:{snappingOptions:{enabled:t,featureEnabled:i,enabledToggled:s}}}=this;return p(c,{checked:i,disabled:s||!t,key:`${this.id}__feature-enabled-toggle`,label:e,onChange:this._featureEnabledSwitchChange})}_renderLayerList(){if(!this.visibleElements.layerList)return null;const{messages:e,viewModel:t}=this,{snappingOptions:{enabled:i,enabledToggled:s}}=t,l=({target:{value:e}})=>this._layerListFilter=""===e?null:new RegExp(e,"i"),n=t.layerListViewModel.operationalItems.length>9?p("calcite-input",{class:u.layerListFilter,clearable:!0,placeholder:e?.searchLayers,onCalciteInputInput:l}):null,a=s||!i,o=this.layerListOpen&&!a;return p("calcite-block",{key:"list-block",heading:e.snappingLayers,disabled:a,class:u.layerListBlock,collapsible:!0,open:o,onCalciteBlockToggle:e=>this.layerListOpen=e.target.open},n,this._renderToggleLayersButton(),p("calcite-list",{class:u.layerList},this._renderLayerListItemCollection(t.layerListViewModel.operationalItems,this._layerListFilter)))}_renderLayerListItemCollection(e,i){return e.map((e=>{if(!i||this._itemTitleMatchesFilter(e,i))return e.children.length>0?this._renderLayerListItemGroup(e):this._renderLayerListItem(e);const t=e.children.filter((e=>this._itemTitleMatchesFilter(e,i)));return t.length>0?this._renderLayerListItemGroup(e,t):null})).toArray().filter(t)}_renderToggleLayersButton(){if(!this.visibleElements.layerListToggleLayersButton)return null;const{viewModel:{allLayersEnabled:e},messages:t}=this,i=e?t.disableAllLayers:t.enableAllLayers;return p("calcite-button",{appearance:"transparent",class:u.layerListButton,label:i,name:"layer-toggle",scale:"m",onclick:this._onToggleLayersButtonClick},i)}_renderLayerListItem(e){const{messages:{untitledLayer:t}}=this,i=e.title||t,s=e.enabled,l=()=>{this._handleLayerListItemChange({checked:!s,value:e.layer.id})};return p("calcite-list-item",{class:u.layerListItem,label:i,key:`${this.id}-list-item-${e.uid}`,onCalciteListItemSelect:l},p("calcite-icon",{icon:s?b.checked:b.unchecked,slot:"content-start",scale:"s"}))}_renderLayerListItemGroup(e,t){const{allChildrenEnabled:i,children:l,hasChildrenEnabled:n,title:a}=e,o=this.messages,r=a||o.untitledLayer,c=a&&""!==a?a:s(),d=!!t,g=t??l,h=i?b.checked:n?b.indeterminate:b.unchecked,m=i?o.disableAllLayers:o.enableAllLayers,y=()=>{this.viewModel.toggleSnappingForLayers(e.childLayerIds,!i)};return p("calcite-list-item",{class:u.layerListItem,key:c},p("calcite-accordion",{class:u.layerListGroup,appearance:"transparent"},p("calcite-accordion-item",{expanded:d,heading:r,key:e.uid},p("calcite-action",{scale:"m",slot:"actions-start",text:m,textEnabled:!1,onclick:y},p("calcite-icon",{icon:h,scale:"s"})),p("calcite-list",null,[...this._renderLayerListItemCollection(g)]))))}_itemTitleMatchesFilter(e,t){return null!=t&&t.test(e.title)}async _handleLayerListItemChange(e){e.checked?this.viewModel.enableSnappingForLayer(e.value):this.viewModel.disableSnappingForLayer(e.value)}};e([l()],y.prototype,"_defaultViewModel",void 0),e([l()],y.prototype,"_layerListFilter",void 0),e([l()],y.prototype,"iconClass",void 0),e([l()],y.prototype,"icon",void 0),e([l()],y.prototype,"label",null),e([l({type:Boolean,nonNullable:!0})],y.prototype,"layerListOpen",void 0),e([l(),d("esri/widgets/support/SnappingControls/t9n/SnappingControls")],y.prototype,"messages",void 0),e([l()],y.prototype,"snappingOptions",null),e([l()],y.prototype,"view",null),e([l()],y.prototype,"viewModel",null),e([l({type:h,nonNullable:!0})],y.prototype,"visibleElements",void 0),y=e([n("esri.widgets.support.SnappingControls")],y);const _=y;export{_ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import{destroyMaybe as i}from"../../core/maybe.js";import{generateUID as s}from"../../core/uid.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Widget.js";import{loadCalciteComponents as a}from"./componentsUtils.js";import{loadLabeledSwitchComponents as r,LabeledSwitch as c}from"./LabeledSwitch.js";import"./widgetUtils.js";import{messageBundle as d}from"./decorators/messageBundle.js";import{tsx as p}from"./jsxFactory.js";import g from"./SnappingControls/SnappingControlsViewModel.js";import h from"./SnappingControls/VisibleElements.js";const m="esri-snapping-controls",u={base:m,container:`${m}__container`,item:`${m}__item`,toggleBlock:`${m}__toggle-block`,layerListBlock:`${m}__layer-list-block`,layerList:`${m}__layer-list`,layerListFilter:`${m}__layer-list__filter`,layerListButton:`${m}__layer-list__button`,layerListItem:`${m}__layer-list__item`,layerListGroup:`${m}__layer-list__group`,nestedContainer:`${m}__nested-container`,disabled:"esri-disabled",esriWidget:"esri-widget",widgetIcon:"esri-icon-vertex-gps"},y={checked:"check-square-f",unchecked:"square",indeterminate:"minus-square"};let b=class extends o{constructor(e,t){super(e,t),this._defaultViewModel=null,this._layerListFilter=null,this.iconClass=u.widgetIcon,this.icon=null,this.layerListOpen=!0,this.messages=null,this.visibleElements=new h,this._enableSnappingSwitchChange=e=>{this.snappingOptions.enabled=e},this._featureEnabledSwitchChange=e=>{this.snappingOptions.featureEnabled=e},this._selfEnabledSwitchChange=e=>{this.snappingOptions.selfEnabled=e},this._onToggleLayersButtonClick=e=>{this.viewModel.toggleSnappingForAllLayers(!this.viewModel.allLayersEnabled),requestAnimationFrame((()=>e.target.setFocus()))};const{snappingOptions:i,view:s,viewModel:l}=e;this.viewModel=l??(this._defaultViewModel=new g({snappingOptions:i,view:s}))}normalizeCtorArgs(e){const{snappingOptions:t,view:i,viewModel:s,...l}=e;return l}destroy(){this.viewModel!==this._defaultViewModel&&(this._defaultViewModel=i(this._defaultViewModel))}loadDependencies(){return Promise.all([a({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js")}),r()])}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){e!==this._get("viewModel")&&(null!=this._defaultViewModel&&this._defaultViewModel===e||(this._defaultViewModel=i(this._defaultViewModel)),this._set("viewModel",e))}render(){const{label:e}=this;return p("div",{"aria-label":e,class:this.classes(u.base,u.esriWidget)},p("div",{class:u.container},this._renderContent()))}_renderContent(){return[this._renderToggles(),this._renderLayerList()]}_renderToggles(){const{visibleElements:e}=this,i=[e.selfEnabledToggle?this._renderSelfEnabledToggle():null,e.featureEnabledToggle?this._renderFeatureEnabledToggle():null].filter(t),s=[e.enabledToggle?this._renderEnabledToggle():null,i.length>0?p("div",{class:u.nestedContainer},i):null].filter(t);return 0===s.length?null:p("calcite-block",{class:u.toggleBlock,heading:e.header?this.label:"",key:"toggle-block",open:!0},s)}_renderEnabledToggle(){const{messages:e,viewModel:t}=this,{snappingOptions:i}=t;return p(c,{checked:i.enabled,disabled:i.enabledToggled,key:`${this.id}__enabled-toggle`,label:e.enableSnapping,onChange:this._enableSnappingSwitchChange})}_renderSelfEnabledToggle(){const{messages:e,viewModel:t}=this,{snappingOptions:i}=t;return p(c,{checked:i.enabled&&i.selfEnabled,disabled:i.enabledToggled||!i.enabled,key:`${this.id}__self-enabled-toggle`,label:e.geometryGuides,onChange:this._selfEnabledSwitchChange})}_renderFeatureEnabledToggle(){const{messages:e,viewModel:t}=this,{snappingOptions:i}=t;return p(c,{checked:i.enabled&&i.featureEnabled,disabled:i.enabledToggled||!i.enabled,key:`${this.id}__feature-enabled-toggle`,label:e.featureToFeature,onChange:this._featureEnabledSwitchChange})}_renderLayerList(){if(!this.visibleElements.layerList)return null;const{messages:e,viewModel:t}=this,{snappingOptions:{enabled:i,enabledToggled:s}}=t,l=({target:{value:e}})=>{this._layerListFilter=""===e?null:new RegExp(e,"i")},n=t.layerListViewModel.operationalItems.length>9?p("calcite-input",{class:u.layerListFilter,clearable:!0,placeholder:e?.searchLayers,onCalciteInputInput:l}):null,o=s||!i,a=this.layerListOpen&&!o;return p("calcite-block",{key:"list-block",heading:e.snappingLayers,disabled:o,class:u.layerListBlock,collapsible:!0,open:a,onCalciteBlockToggle:e=>this.layerListOpen=e.target.open},n,this._renderToggleLayersButton(),p("calcite-list",{class:u.layerList},this._renderLayerListItemCollection(t.layerListViewModel.operationalItems,this._layerListFilter)))}_renderLayerListItemCollection(e,i){return e.map((e=>{if(!i||this._itemTitleMatchesFilter(e,i))return e.children.length>0?this._renderLayerListItemGroup(e):this._renderLayerListItem(e);const t=e.children.filter((e=>this._itemTitleMatchesFilter(e,i)));return t.length>0?this._renderLayerListItemGroup(e,t):null})).toArray().filter(t)}_renderToggleLayersButton(){if(!this.visibleElements.layerListToggleLayersButton)return null;const{viewModel:{allLayersEnabled:e},messages:t}=this,i=e?t.disableAllLayers:t.enableAllLayers;return p("calcite-button",{appearance:"transparent",class:u.layerListButton,label:i,name:"layer-toggle",scale:"m",onclick:this._onToggleLayersButtonClick},i)}_renderLayerListItem(e){const{messages:{untitledLayer:t}}=this,i=e.title||t,s=e.enabled,l=()=>{this._handleLayerListItemChange({checked:!s,value:e.layer.id})};return p("calcite-list-item",{class:u.layerListItem,label:i,key:`${this.id}-list-item-${e.uid}`,onCalciteListItemSelect:l},p("calcite-icon",{icon:s?y.checked:y.unchecked,slot:"content-start",scale:"s"}))}_renderLayerListItemGroup(e,t){const{allChildrenEnabled:i,children:l,hasChildrenEnabled:n,title:o}=e,a=this.messages,r=o||a.untitledLayer,c=o&&""!==o?o:s(),d=!!t,g=t??l,h=i?y.checked:n?y.indeterminate:y.unchecked,m=i?a.disableAllLayers:a.enableAllLayers,b=()=>{this.viewModel.toggleSnappingForLayers(e.childLayerIds,!i)};return p("calcite-list-item",{class:u.layerListItem,key:c},p("calcite-accordion",{class:u.layerListGroup,appearance:"transparent"},p("calcite-accordion-item",{expanded:d,heading:r,key:e.uid},p("calcite-action",{scale:"m",slot:"actions-start",text:m,textEnabled:!1,onclick:b},p("calcite-icon",{icon:h,scale:"s"})),p("calcite-list",null,this._renderLayerListItemCollection(g)))))}_itemTitleMatchesFilter(e,t){return null!=t&&t.test(e.title)}async _handleLayerListItemChange(e){e.checked?this.viewModel.enableSnappingForLayer(e.value):this.viewModel.disableSnappingForLayer(e.value)}};e([l()],b.prototype,"_defaultViewModel",void 0),e([l()],b.prototype,"_layerListFilter",void 0),e([l()],b.prototype,"iconClass",void 0),e([l()],b.prototype,"icon",void 0),e([l()],b.prototype,"label",null),e([l({type:Boolean,nonNullable:!0})],b.prototype,"layerListOpen",void 0),e([l(),d("esri/widgets/support/SnappingControls/t9n/SnappingControls")],b.prototype,"messages",void 0),e([l()],b.prototype,"snappingOptions",null),e([l()],b.prototype,"view",null),e([l()],b.prototype,"viewModel",null),e([l({type:h,nonNullable:!0})],b.prototype,"visibleElements",void 0),b=e([n("esri.widgets.support.SnappingControls")],b);const _=b;export{_ as default};