@arcgis/core 5.1.0-next.112 → 5.1.0-next.113

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 (96) hide show
  1. package/arcade.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{0e6a388d51d9dbae46ba.js → 02c0640005b09007bb70.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{beff5b4e15edee12bd4c.js → 271e42b7cd3c3441839e.js} +3 -3
  5. package/assets/esri/core/workers/chunks/32f128a1615d71bbe899.js +2 -0
  6. package/assets/esri/core/workers/chunks/40df608337d562553ce1.js +2 -0
  7. package/assets/esri/core/workers/chunks/{711d1873c760313e287f.js → 52a91c314afec70199bc.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{fe8334352d256d691a95.js → 5c6742728fa705d2e16e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{481dc7503587972a6bd2.js → 701125f6cdd91ff3655f.js} +2 -2
  10. package/assets/esri/core/workers/chunks/7995e6983456c779adf9.js +1 -0
  11. package/assets/esri/core/workers/chunks/860465c4f44c373d0a1c.js +1 -0
  12. package/assets/esri/core/workers/chunks/{08efd64acdfe46985293.js → 9a11ff75009fef45b8c1.js} +1 -1
  13. package/assets/esri/core/workers/chunks/a70fa35b2d19460637e9.js +2 -0
  14. package/assets/esri/core/workers/chunks/ae74f722fb385e45fcf1.js +1 -0
  15. package/assets/esri/core/workers/chunks/{b02a68bbab07557cf02d.js → b4badbcf1bdb7823d825.js} +1 -1
  16. package/assets/esri/core/workers/chunks/b78fb24b47d9f31f18c6.js +1 -0
  17. package/assets/esri/core/workers/chunks/e95ce76b5b816256a519.js +1 -0
  18. package/assets/esri/core/workers/chunks/fbcf09526dc1bbe94b91.js +2 -0
  19. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +22 -6
  20. package/assets/esri/themes/dark/main.css +1 -1
  21. package/assets/esri/themes/light/main.css +1 -1
  22. package/assets/esri/themes/light/view.css +1 -1
  23. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm.json +1 -1
  24. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_en.json +1 -1
  25. package/assets/esri/widgets/Features/t9n/Features_en.json +1 -1
  26. package/chunks/GaussianSplatShadow.glsl.js +11 -9
  27. package/chunks/ShadowCastVisualize.glsl.js +26 -18
  28. package/config.js +1 -1
  29. package/kernel.js +1 -1
  30. package/layers/KnowledgeGraphLayer.d.ts +6 -4
  31. package/layers/KnowledgeGraphLayer.js +1 -1
  32. package/layers/LinkChartLayer.js +1 -1
  33. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  34. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  35. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  36. package/layers/support/featureLayerUtils.js +1 -1
  37. package/linkChart/LinkChartProperties.js +1 -1
  38. package/linkChart/utils.js +1 -1
  39. package/package.json +1 -1
  40. package/support/revision.js +1 -1
  41. package/symbols/cim/types.d.ts +45 -1
  42. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  43. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
  44. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
  45. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
  46. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  47. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  48. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  49. package/views/3d/analysis/Viewshed/ViewshedDrawToolRenderer.js +1 -1
  50. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  51. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  52. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  53. package/views/3d/analysis/Viewshed/viewshedToolManipulatorUtils.js +1 -1
  54. package/views/3d/environment/EnvironmentManager.js +1 -1
  55. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  56. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +3 -3
  57. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  58. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  59. package/views/3d/webgl-engine/shaders/GaussianSplatShadow.glsl.js +1 -1
  60. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
  61. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.d.ts +17 -3
  62. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  63. package/widgets/BatchAttributeForm/css.js +1 -1
  64. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.d.ts +25 -1
  65. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  66. package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.d.ts +46 -1
  67. package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.js +1 -1
  68. package/widgets/BatchAttributeForm/inputs/UtilityNetworkAssociationsElementInput.js +1 -1
  69. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  70. package/widgets/BatchAttributeForm/interfaceUtils.js +1 -1
  71. package/widgets/BatchAttributeForm/types.d.ts +1 -1
  72. package/widgets/BatchAttributeForm.d.ts +2 -1
  73. package/widgets/BatchAttributeForm.js +1 -1
  74. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  75. package/widgets/Editor/UpdateWorkflow.js +1 -1
  76. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  77. package/widgets/FeatureForm/RelationshipInput.d.ts +3 -3
  78. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  79. package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
  80. package/widgets/Sketch/SketchViewModel.js +1 -1
  81. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.d.ts +66 -6
  82. package/widgets/support/SelectionToolbar/types.d.ts +20 -1
  83. package/assets/esri/core/workers/chunks/03babc21d1781142a974.js +0 -1
  84. package/assets/esri/core/workers/chunks/340c68d09d2e8bef6727.js +0 -2
  85. package/assets/esri/core/workers/chunks/8a1751187a20b6578875.js +0 -1
  86. package/assets/esri/core/workers/chunks/9ebc461529d5286fa2c2.js +0 -2
  87. package/assets/esri/core/workers/chunks/aca9591d3467a24f8329.js +0 -1
  88. package/assets/esri/core/workers/chunks/d00b9c1fd0865bf8f317.js +0 -1
  89. package/assets/esri/core/workers/chunks/d02aa7438f46c1c2167a.js +0 -2
  90. package/assets/esri/core/workers/chunks/deab352545c34cac148c.js +0 -1
  91. package/assets/esri/core/workers/chunks/e5854a3f69dffaf9464d.js +0 -2
  92. /package/assets/esri/core/workers/chunks/{e5854a3f69dffaf9464d.js.LICENSE.txt → 32f128a1615d71bbe899.js.LICENSE.txt} +0 -0
  93. /package/assets/esri/core/workers/chunks/{340c68d09d2e8bef6727.js.LICENSE.txt → 40df608337d562553ce1.js.LICENSE.txt} +0 -0
  94. /package/assets/esri/core/workers/chunks/{481dc7503587972a6bd2.js.LICENSE.txt → 701125f6cdd91ff3655f.js.LICENSE.txt} +0 -0
  95. /package/assets/esri/core/workers/chunks/{d02aa7438f46c1c2167a.js.LICENSE.txt → a70fa35b2d19460637e9.js.LICENSE.txt} +0 -0
  96. /package/assets/esri/core/workers/chunks/{9ebc461529d5286fa2c2.js.LICENSE.txt → fbcf09526dc1bbe94b91.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as a}from"../core/deprecate.js";import i from"../core/Logger.js";import{getOrCreateMapValue as n}from"../core/MapUtils.js";import{watch as l,when as s,on as o}from"../core/reactiveUtils.js";import{formatFileSize as r}from"../core/unitFormatUtils.js";import{property as c,subclass as d}from"../core/accessorSupport/decorators.js";import{isIntegerField as m}from"../layers/support/fieldUtils.js";import{isString as u}from"../support/guards.js";import p from"./Widget.js";import{getAttachmentTypeCategory as h,getCalciteIconForAttachment as v}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as g,isImageAttachment as f}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as b,getVisibleFieldInputValidationErrorMessage as C,isElementTemplateWithInputType as _}from"./BatchAttributeForm/batchAttributeFormUtils.js";import y from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as I}from"./BatchAttributeForm/css.js";import{makeAddAttachmentFooterButtons as F,makeViewingAttachmentFooterButtons as A,makeDefaultFooterButtons as w}from"./BatchAttributeForm/interfaceUtils.js";import k from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as x,isFieldInput as M,isTextElementInput as D,isRelationshipElementInput as E,isAttachmentElementInput as V,isUtilityNetworkAssociationsElementInput as O,differentValuesString as T}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as S,getMultipleChoiceCheckboxState as L,otherChoiceCheckedPlaceholderValue as U,getUpdatedMultipleChoiceValueForFeature as P,getMultipleChoiceSelectAllState as N,splitMultipleChoiceValue as $,canRestoreMultipleChoiceOtherChoiceDraftValue as B}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{downloadAttachmentInfo as R}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as j}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as z,getIntlOptionsForField as Z,prepareISOFieldValueForDateComponents as H,prepareUnixFieldValueForDateComponents as q,normalizeTimeOnlyString as W,getISOFieldValueFromDateComponents as G,getUnixFieldValueFromDateComponents as K}from"./support/dateUtils.js";import{globalCss as J}from"./support/globalCss.js";import{calciteListFilterProps as Q}from"./support/listUtils.js";import{messageBundle as X,vmEvent as Y,tsx as ee}from"./support/widget.js";import{setFocus as te}from"./support/widgetUtils.js";import{isEmptyValue as ae}from"./support/forms/formUtils.js";const ie="data-element-id",ne="esri_BatchAttributeForm_select_all",le="esri_BatchAttributeForm_other_choice";let se=class extends p{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.messagesUnits=null,this.viewModel=new y,this.visibleElements=new k,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._attachmentDialogInfo=null,this._attachmentListFilterText="",this._attachmentFileInputMap=new Map,this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{a(i.getLogger(this),"Editor","arcgis-editor",{version:"5.0"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...a}=e;return a}initialize(){this.addHandles([l(()=>this.features,()=>{this._dateComponentMap.clear(),this._resetTransientFormState(),S(this.viewModel,{includeDraftValues:!0})}),l(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),S(this.viewModel)}),l(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),s(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),l(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=""}),o(()=>this.viewModel,"submit",()=>{this.valid||this.goToFirstError()})])}loadDependencies(){return j({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){const{features:e,messages:t,page:a}=this;return"viewing-attachment-details"===a?t.titles.editAttachment:"adding-attachments"===a?t.titles.addAttachments:"viewing-attachments"===a?t.titles.attachments:1===e.length||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:""}get effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length)return[];const{page:e,messages:t}=this,a=this.viewModel.selectedAttachmentAddElementId;return"adding-attachments"===e&&a?F({messages:t,onclick:()=>this._attachmentFileInputMap.get(a)?.click()}):"viewing-attachment-details"===e?A({messages:t}):"viewing-attachments"===e?[]:w({formId:this._formId,callback:this.submit,messages:t})}get footerNoticeInfos(){if(!this.features.length)return[];const{messages:{footerNotices:e}}=this;return[]}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formId(){return`${this.id}-form`}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){return ee("div",{class:this.classes(I.base,J.widget,J.panel)},this._renderContent(),this._renderAttachmentDialog())}submit(){this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:a}=e.dataset,i=n(this._dateComponentMap,`${a}`,()=>({}));switch(t){case"date":i.date=e;break;case"time":i.time=e;break;case"timeZone":i.timeZone=e}}_renderContent(){const{messages:e,viewModel:a}=this,{status:i}=a;return"failed"===i?a.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:a.maximumFeatureCountWithComplexForms})):a.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:a.maximumFeatureCount})):e.formFailedToLoad:a.expressionEvaluationFailed?this._renderErrorNotice(e.expressionEvaluationFailed):a.hasLayersWithContingentValues&&this.viewModel.features.length>1?this._renderErrorNotice(e.unsupportedContingentValues):"loading"===i&&this.visibleElements.loadingIndicator?ee("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):0!==this.features.length?this._renderForm():void 0}_renderErrorNotice(e,t="warning"){return ee("calcite-notice",{class:I.noticeError,icon:!0,kind:t,open:!0},ee("div",{slot:"message"},e))}_renderForm(){return ee("form",{class:I.form,id:this._formId,onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case"adding-attachments":return this._renderAttachmentAddPage();case"viewing-attachments":return this._renderAttachmentListPage();case"viewing-attachment-details":return this._renderAttachmentDetailPage();default:return this._renderFormContent()}}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:a}=e;let i;if(!e.submitHasBeenAttempted)return null;if(a.invalidHiddenInputs.length>0)if(i=b(a,e.mode,this.messages),"batch"===this.viewModel.mode){const e=a.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?i+=` (${e.map(e=>e.label).join(", ")})`:i=null}else i+=` (${a.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return i?this._renderErrorNotice(i,"danger"):null}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){return x(e)?this._renderGroupInput(e):M(e)?this._renderLabeledField(e):D(e)?this._renderTextComponent(e):E(e)?this._renderRelationshipElementInput(e):V(e)?this._renderAttachmentElementInput(e):O(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderGroupInput(e){const{inputs:t,template:a,open:i}=e,n=t.filter(e=>e.visible),l=a.label??"";return ee("calcite-block",{class:this.classes(I.group,"sequential"===this.groupDisplay?I.groupSequential:null,this.disabled?I.inputDisabled:null),collapsible:!0,description:a.description??void 0,disabled:this.effectiveDisabled,expanded:i,heading:l,headingLevel:this.headingLevel,key:`{${a.elementId}-key}`,label:l,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{elementId:a}=e.template,{label:i,required:n,dataType:l}=e,s=n?t(this.messages.requiredFieldLabel,{name:i}):i;return ee("calcite-label",{"aria-label":s,class:I.label,key:`field--${a}`},ee("div",{class:I.labelTextContent,key:"labelTextContainer"},i,n?ee("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==l?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:a}=e;return"date"===a?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):null!==e.multipleChoiceChoices?this._renderMultipleChoiceComponent({input:e,props:t}):"number"===a?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:a,submittable:i}=e,n=!i&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?C(e,t,this.messages):null;return n?ee("calcite-input-message",{icon:!0,status:"invalid"},n):a?ee("calcite-input-message",{class:I.description,icon:!1,status:"idle"},a):null}_renderCodedInputs({input:e,props:t}){const a=e.input?.type??null,i=e.codedValueOptions;switch(a){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:i,props:t});default:return this._renderComboBoxComponent({options:i,props:t,input:e})}}_renderMultipleChoiceComponent({input:e,props:t}){const{messages:a}=this,{multipleChoiceChoices:i,multipleChoiceInput:n,multipleChoiceValues:l}=e;if(!n||!i||!l)return null;const s=!0===n.includeSelectAllChoices,o=new Map;let r=l.length>0,c=!1;for(const f of l){const t=L({input:e,choiceValue:f});o.set(f,t),(t.checked||t.indeterminate)&&(c=!0),t.checked||(r=!1)}const d={checked:r,indeterminate:!r&&c},m=d.checked?a.deselectAllLabel:a.selectAllLabel,u=e.getMultipleChoiceOtherChoiceRenderState(this.messages.otherOptionLabel),p=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})},h=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})},v=t=>{const{fieldName:a}=u;a&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:a})},g=t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:u.fieldName})};return ee("div",{class:I.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},s?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:d,selectAllLabel:m,handleSelectAllCheckboxChange:p}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:h}),u.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:s,otherChoiceRenderState:u,handleOtherChoiceCheckboxChange:v,handleOtherChoiceInputChange:g,differentValuesPlaceholder:a.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:a,handleSelectAllCheckboxChange:i}){return ee("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:t.checked,class:I.multipleChoiceSelectAll,"data-element-id":e[ie],disabled:e.readOnly,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:a,labelText:a,value:ne,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>i(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:a,handleChoiceCheckboxChange:i}){const{multipleChoiceChoices:n}=e;return n?n.map(e=>{const n=a.get(e.value)??{checked:!1,indeterminate:!1};return ee("calcite-checkbox",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t["aria-invalid"],checked:n.checked,class:t.class,"data-element-id":t[ie],disabled:t.readOnly,indeterminate:n.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,required:t.required,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>i(e),onfocus:t.onfocus})}):[]}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:a,handleOtherChoiceCheckboxChange:i,handleOtherChoiceInputChange:n,differentValuesPlaceholder:l}){return ee("div",{class:this.classes(I.multipleChoiceOtherChoice,t?I.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},ee("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:a.checkboxState.checked,class:e.class,"data-element-id":e[ie],disabled:e.readOnly,indeterminate:a.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:a.label,labelText:a.label,value:le,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>i(e),onfocus:e.onfocus}),a.checkboxState.checked?ee("calcite-input",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],"aria-label":a.label,class:I.textElementInput,"data-element-id":e[ie],disabled:e.readOnly,key:`${e.key}-other-choice-input`,maxLength:a.maxLength,placeholder:a.value===T?l:a.hint,required:e.required,type:"text",value:a.normalizedValue===T?"":a.normalizedValue?String(a.normalizedValue):"",onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>n(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:a=!1}){if(e.multipleChoiceInput&&!a&&"batch"===this.viewModel.mode)return void await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});const i=e.value,n=this._parseValue(t,e,a);n!==i&&await this.viewModel.setValue(e.template.elementId,n)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:a}){if(!a)return;const i=t.value,n=null==i||""===i?null:i;e.initializeExplicitMultipleChoiceOtherChoiceCheckedState(),e.stashMultipleChoiceOtherChoiceDraftValueForFeatures(e.features,n);const l=e.features.toArray().filter(e=>e.getAttribute(a)!==n);if(0!==l.length){for(const e of l)e.setAttribute(a,n);this.viewModel.userHasChangedValues=!0,await e.expressionsManager.valueChanged(a,l),this.viewModel.emit("value-change",{features:l.map(e=>e.source),fieldName:a,name:"value-change",value:n})}}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:a}){e.setExplicitMultipleChoiceOtherChoiceCheckedState(t),t||e.setMultipleChoiceOtherChoiceDraftValuesFromFeatures(e.features.toArray());const i=e.features.toArray().filter(i=>{const n=i.getAttribute(a);if(t){if(!ae(n))return!1;const t=e.getMultipleChoiceOtherChoiceDraftValue(i),l=B(t)?t:U;return i.setAttribute(a,l),!0}return null!=n&&(i.setAttribute(a,null),!0)});0!==i.length&&(this.viewModel.userHasChangedValues=!0,await e.expressionsManager.valueChanged(a,i),this.viewModel.emit("value-change",{features:i.map(e=>e.source),fieldName:a,name:"value-change",value:this._getFieldValueByFieldNameForInput(e,a)}))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){if(!e.multipleChoiceInput||!e.multipleChoiceValues)return;const a=e.features.toArray().filter(a=>{const i=a.getAttribute(e.fieldName),n=P({input:e,choiceValue:t.value,currentValue:i,isChecked:t.checked});return i!==n&&(a.setAttribute(e.fieldName,n),!0)});0!==a.length&&(this.viewModel.userHasChangedValues=!0,await e.expressionsManager.valueChanged(e.fieldName,a),this.viewModel.emit("value-change",{features:a.map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:this._getFieldValueByFieldNameForInput(e,e.fieldName)}))}_getFieldValueByFieldNameForInput(e,t){const a=e.features.toArray().map(e=>e.getAttribute(t));if(0===a.length)return null;const[i]=a;return a.every(e=>e===i)?i:T}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===T||e.value===T)&&"batch"===this.viewModel.mode){const a={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[ie]:t[ie]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:a,options:[{name:this.messages.differentValuesPlaceholder,value:T,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return ee("calcite-switch",{...t,checked:!!_(e.template,"switch")&&e.value===e.template.input.onValue,class:I.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:a}){const{trigger:i,dropdown:n,group:l}=a;return ee("calcite-dropdown",{...n,topLayerDisabled:this.topLayerDisabled,onblur:()=>{this._focusedFieldInput=null},onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e),onfocus:this._onComponentFocus},ee("calcite-button",{...i},e===T?this.messages.differentValuesPlaceholder:e),ee("calcite-dropdown-group",{selectionMode:l.mode},t.map(t=>ee("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:a}){const i="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),l=i&&e.showNoValueOptionEnabled&&!n?()=>{}:a.onblur,s={...a,onblur:l};return ee("calcite-combobox",{...s,selectionMode:"single",topLayerDisabled:this.topLayerDisabled,value:a.placeholder===this.messages.differentValuesPlaceholder?T:String(a.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==T&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:a}))}renderComboboxOptionsList({input:e,options:t,props:a}){const i=e=>e.map(e=>{const{value:t}=e,i=ae(e.value)?this.messages.empty:e.name;return ee("calcite-combobox-item",{heading:i,key:`#${t}`,selected:a.value===t,value:`${t}`})});let n=[];const{messages:l}=this;t.other.length>0&&n.push(ee("calcite-combobox-item-group",{key:"other",label:l.other},i(t.other))),t.unsupported.length>0&&n.push(ee("calcite-combobox-item-group",{key:"unsupported",label:l.unsupported},i(t.unsupported)));const s=i(t.recommended);n.length>0?n.unshift(ee("calcite-combobox-item-group",{key:"recommended",label:l.recommended},s)):n=s;const o=a.placeholder===this.messages.differentValuesPlaceholder,r=!o&&ae(a.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&n.unshift(ee("calcite-combobox-item",{heading:e.showNoValueLabel||this.messages.empty,key:"empty-option",selected:r,value:""})),o&&n.unshift(ee("calcite-combobox-item",{heading:this.messages.differentValuesPlaceholder,key:T,selected:!0,value:T})),n}_renderRadioButtonGroupComponent({input:e,options:t,props:a}){const i=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:i})=>this._renderRadioButtons({label:t,value:i,selected:i===e.value,props:a}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){const t="",n=e.showNoValueLabel||this.messages.empty,l=ae(e.value);i.unshift(this._renderRadioButtons({label:n,value:t,selected:l,props:a}))}return ee("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:I.inputRadioGroup,disabled:a.readOnly,key:`${a.key}-radio-group`,layout:"vertical",name:a.name,required:a.required},i,a.placeholder===this.messages.differentValuesPlaceholder?ee("calcite-label",{class:I.placeholderRadio,key:a.label,layout:"inline"},ee("calcite-radio-button",{checked:!0,class:I.inputRadio,disabled:!0,name:a.placeholder,value:a.placeholder}),a.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:a,props:i}){return ee("calcite-label",{class:I.inputRadioLabel,key:i.label,layout:"inline"},ee("calcite-radio-button",{...i,afterCreate:void 0,afterUpdate:void 0,checked:t,class:I.inputRadio,disabled:i.readOnly,name:i.label,value:e,onblur:()=>{this._focusedFieldInput=null},onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),a)}_renderStringComponent(e,t){const{template:a}=e;return!a.field.editable||this.readOnly?this._renderReadOnlyComponent(e):"text-area"===a.input?.type?ee("calcite-text-area",{...t,class:this.classes(I.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):ee("calcite-input",{...t,class:this.classes(I.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const a=m(e.field);return ee("calcite-input-number",{...t,integer:a,type:"number",value:a&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const a=this.getCommonInputProps(e);return ee("calcite-input",{...a,class:this.classes(I.fieldInput,I.inputDisabled,I.individualElement),readOnly:!0,type:"text",value:String(t??a.value??"")})}_renderDateComponents(e,t){const{field:a}=e;let i;switch(a.type){case"date":i=this._renderDateFieldComponents(e,t);break;case"date-only":i=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":i=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":i=this._renderTimestampOffsetFieldComponents(e,t);break;default:i=this._renderReadOnlyComponent(e,z(a,t.value,{timeZone:e.effectiveTimeZone,...Z(e.template.field)}))}return e.value===T?[i,ee("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:i}_renderDateOnlyFieldComponent(e,t){const{class:a,key:i,readOnly:n}=t,{rawMax:l,rawMin:s}=e.range;return ee("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:a,"data-date-part":"date","data-element-id":t[ie],key:`${i}-date-input`,max:u(l)?l:void 0,min:u(s)?s:void 0,overlayPositioning:"fixed",readOnly:n,topLayerDisabled:this.topLayerDisabled,value:e.value===T?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimeOnlyFieldComponent(e,t){const{class:a,key:i,readOnly:n}=t;return ee("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:a,"data-date-part":"time","data-element-id":t[ie],key:`${i}-time-input`,overlayPositioning:"fixed",readOnly:n,value:e.value===T?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimestampOffsetFieldComponents(e,t){const{class:a,key:i,readOnly:n}=t,{rawMax:l,rawMin:s}=e.range,o=H(l),r=H(s),c=H(e.value===T?"":e.value),d=e.includeTimeOffset,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[ie]:t[ie],onfocus:this._onComponentFocus};return ee("div",{class:I.dateInputContainer,key:`${i}-date-time-container`},ee("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${i}-date-input`,max:o?.date??void 0,min:r?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:c.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),ee("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${i}-time-input`,value:c.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),d?ee("calcite-input-time-zone",{...m,class:a,clearable:e.value===T||null==e.value,"data-date-part":"timeZone",key:`${i}-timezone-input`,value:c.timeZoneOffset||"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:a,key:i,readOnly:n,min:l,max:s}=t,o=e.effectiveTimeZone,r=q(e.value===T?"":e.value,o),c=q(s,o),d=q(l,o),m=e.includeTime,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[ie]:t[ie],onfocus:this._onComponentFocus};return ee("div",{class:I.dateInputContainer,key:`${i}-date-time-container`},ee("calcite-input-date-picker",{...u,class:a,"data-date-part":"date",key:`${i}-date-input`,max:c?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:r.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?ee("calcite-input-time-picker",{...u,"data-date-part":"time",key:`${i}-time-input`,step:1,value:r.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){const{elementId:t}=e.template;return ee("div",{class:I.relationshipElementInput,"data-testid":`relationship-element-${t}`,key:`relationship-element-${t}`})}_renderAttachmentElementInput(e){const{allAttachmentsVisibleOnDefaultPage:t,attachments:a,defaultPageAttachments:i,template:{description:n,elementId:l,label:s}}=e,o=t?a:i;return ee("div",{class:I.attachmentElementInput,"data-testid":`attachment-element-${l}`,key:`attachment-element-${l}`},s?ee("div",{class:I.attachmentElementLabel,key:`attachment-element-label-${l}`},s):null,n?ee("div",{class:I.description,key:`attachment-element-description-${l}`},n):null,a.length?this._renderAttachmentList(e,o,{label:s||this.messagesCommon.details,viewAllCount:t?null:a.length}):ee("div",{class:I.attachmentElementEmptyState,key:`attachment-element-empty-state-${l}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){const e=this.viewModel.selectedAttachmentListInput;if(e)return ee("div",{class:I.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,a){const{filterEnabled:i,label:n,viewAllCount:l}=a;return ee("calcite-list",{class:I.attachmentElementList,filterEnabled:i,filterPlaceholder:i?this.messages.attachments.searchAttachments:void 0,filterProps:i?Q:void 0,filterText:i?this._attachmentListFilterText:void 0,label:n,selectionAppearance:"border",selectionMode:"none",onCalciteListFilter:i?e=>{this._attachmentListFilterText=e.currentTarget.filterText??""}:void 0},this._renderAttachmentListItems(e,t),null!=l?this._renderViewAllAttachmentsItem(e,l):null)}_renderAttachmentListItems(e,t){const{elementId:a}=e.template;return t.map((t,i)=>{const n=this._formatAttachmentSize(t.size),l=this._getAttachmentLabel(t,i,n,e.displayFilename),s=l===n?void 0:n,o=g(t),r=e.isStagedAttachmentAddition(t);return ee("calcite-list-item",{class:I.attachmentElementListItem,description:s,key:`attachment-item-${o}`,label:l,onCalciteListItemSelect:r?void 0:()=>this._setSelectedAttachment({attachmentKey:o,elementId:a})},ee("div",{class:I.attachmentElementListItemStart,slot:"content-start"},this._renderAttachmentPreviewThumbnail(t,l,e)),r?[ee("span",{class:I.attachmentElementListItemStagedIndicator,slot:"content-end"}),ee("calcite-action",{disabled:this.effectiveDisabled,icon:"x",scale:"s",slot:"actions-end",text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(a,t.globalId)})]:ee("calcite-action",{icon:"chevron-right",scale:"s",slot:"actions-end",text:l,title:l}))})}_renderViewAllAttachmentsItem(e,a){const{elementId:i}=e.template,{viewAll:n}=this.messages.attachments;return ee("calcite-list-item",{class:I.attachmentElementListItem,description:t(this.messages.attachments.count,{count:a}),key:`attachment-item-view-all-${i}`,label:n,onCalciteListItemSelect:()=>this._setAttachmentListElementId(i)},ee("calcite-action",{icon:"chevron-right",scale:"s",slot:"actions-end",text:n,title:n}))}_renderAttachmentAddAction(e){const{elementId:t}=e.template,a=this.effectiveDisabled||e.addDisabled;return ee("div",{class:I.attachmentElementEmptyAction,key:`attachment-element-empty-action-${t}`},ee("calcite-button",{appearance:"outline",disabled:a,iconStart:"attachment",kind:"neutral",round:!0,scale:"s",onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach))}_renderAttachmentAddPage(){const e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){const{maxAttachmentCount:t}=e,{elementId:a}=e.template,i=null==t||t-e.attachments.length>1,n=this.effectiveDisabled||e.addDisabled,l=this.messages.attachments,s=l.dragAndDropFile,o="upload",r=e=>{this._attachmentFileInputMap.set(a,e)};return ee("div",{class:I.attachmentElementAddPanel,key:`attachment-element-add-panel-${a}`},ee("input",{accept:e.accept,afterCreate:r,afterRemoved:()=>{this._attachmentFileInputMap.delete(a)},afterUpdate:r,class:I.attachmentElementFileInput,"data-element-id":a,disabled:n,multiple:i,type:"file",onchange:e=>{const t=e.currentTarget,i=t.files?Array.from(t.files):[];this._stageAttachmentFiles(a,i),t.value=""}}),ee("div",{class:I.attachmentElementAddDropzone,"data-disabled":n?"true":"false",ondragover:e=>{e.preventDefault()},ondrop:e=>{if(e.preventDefault(),n)return;const t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(a,t)}},ee("calcite-icon",{class:I.attachmentElementAddDropzoneIcon,icon:o,scale:"l"}),ee("div",{class:I.attachmentElementAddDropzoneHeading},l.addFile),ee("div",{class:I.attachmentElementAddDropzoneDetail,title:s},s),ee("calcite-button",{appearance:"outline-fill",disabled:n,iconStart:"folder-open",scale:"s",type:"button",onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(a,n)}},l.selectFile)))}async _stageAttachmentFiles(e,t){if(0!==t.length)try{await this.viewModel.stageAddAttachments(e,t)}finally{this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){const e=this.selectedAttachmentDetails;if(!e)return;const{attachment:t,input:a}=e,i=g(t),n=!!a.getAttachmentPreviewUrl(t);return ee("div",{class:I.attachmentElementDetail,key:`attachment-detail-panel-${a.template.elementId}-${i}`},ee("div",{class:I.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,a)),ee("div",{class:I.attachmentElementDetailActions},ee("calcite-button",{appearance:"outline",disabled:!n,iconStart:"download-to",kind:"neutral",scale:"s",onclick:()=>{this._downloadAttachment(t)}},this.messages.attachments.download),f(t)?ee("calcite-button",{appearance:"outline",disabled:!n,iconStart:"expand",kind:"neutral",scale:"s",onclick:this._maximizeSelectedAttachment},this.messages.attachments.maximize):null,ee("calcite-button",{appearance:"outline",disabled:!0,iconStart:"refresh",kind:"neutral",scale:"s"},this.messages.attachments.replace)),ee("div",{class:I.attachmentElementDetailMetadata},ee("span",{class:I.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),ee("span",{class:I.attachmentElementDetailMetadataValue},t.name),ee("span",{class:I.attachmentElementDetailMetadataLabel},this.messages.attachments.size),ee("span",{class:I.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size)),ee("span",{class:I.attachmentElementDetailMetadataLabel},this.messages.attachments.type),ee("span",{class:I.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t))))}_renderAttachmentDialog(){const e=this._attachmentDialogInfo;if(!e)return null;const{attachment:t,input:a}=e;return ee("calcite-dialog",{heading:t.name||this.messagesCommon.details,key:"attachment-preview-dialog",modal:!0,open:!0,placement:"cover",width:"l",onCalciteDialogClose:this._closeAttachmentDialog},ee("div",{class:I.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,a)))}_setSelectedAttachment(e){this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){this.viewModel.setSelectedAttachmentAddElementId(e),this.hideAttachmentDialog()}_setAttachmentListElementId(e){this.viewModel.setSelectedAttachmentListElementId(e),this.hideAttachmentDialog()}_getAttachmentLabel(e,a,i,n){return!1!==n&&u(e.name)&&e.name.length>0?e.name:i!==this.messagesCommon.notApplicable?i:t(this.messages.attachments.attachmentNumberedLabel,{index:a+1})}_formatAttachmentSize(e){return null==e||Number.isNaN(e)?this.messagesCommon.notApplicable:r(this.messagesUnits,e)}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;const t=this.messages.attachments.attachmentTypes,a=h(e);return t?.[a]||e}_renderAttachmentPreviewThumbnail(e,t,a){const i=a.getAttachmentPreviewUrl(e,64);return i&&f(e)?ee("img",{alt:t,class:I.attachmentElementListItemThumb,src:i}):ee("calcite-icon",{class:I.attachmentElementListItemIcon,icon:v(e.contentType),scale:"s"})}_renderAttachmentPreviewImageForInput(e,t){const a=t.getAttachmentPreviewUrl(e),i=e.name||this.messagesCommon.details;return a&&f(e)?ee("img",{alt:i,class:I.attachmentElementDetailPreviewImage,src:a,title:i}):[ee("calcite-icon",{class:I.attachmentElementDetailPreviewIcon,icon:v(e.contentType),scale:"l",textLabel:i,title:i}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await R(e)}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){const{elementId:t}=e.template;return ee("div",{class:I.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){const{elementId:t}=e.template;return ee("div",{class:I.utilityNetworkAssociationsElementInput,"data-testid":t,key:t})}getCommonInputProps(e){const{template:t,valid:a,value:i,minLength:n,maxLength:l,required:s,fieldName:o,editable:r,userHasChangedValue:c,range:{max:d,min:m}}=e,u=!r||this.readOnly,p=!u&&this.effectiveDisabled;let h=t.hint??void 0,v=!1;return i===T&&(h=this.messages.differentValuesPlaceholder,v=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":a?"false":"true",class:this.classes(I.fieldInput,u?I.inputDisabled:null),status:!c&&!this.viewModel.submitHasBeenAttempted||a?"idle":"invalid",maxLength:l&&l>-1?l:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:o,name:o,max:null!=d?d:void 0,min:null!=m?m:void 0,disabled:p,readOnly:u,onblur:this._onComponentBlur,required:s,placeholder:h,value:v?"":i??"",[ie]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(ie))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,a=e.querySelector("calcite-radio-button"),i=t||a;i&&this._afterComponentCreateOrUpdate(i)}_onComponentFocus(e){const t=e.target,a=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(a.template.elementId),this._focusedFieldInput=a}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),a=this._focusedFieldInput;this._attemptFocusOnNextRender&&a===t&&(this._attemptFocusOnNextRender=!1,te(e))}_onComponentBlur(){this._focusedFieldInput=null}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._attachmentListFilterText="",this._attachmentFileInputMap.clear()}_parseValue(e,t,a=!1){const i=t.multipleChoiceInput,n=t.multipleChoiceValues;if(i&&n){const l=i.choiceDelimiter,s=e;if(a){return N({input:t}).checked?null:n.length>0?n.join(l):null}const o=$(t.value,l).filter(e=>e!==T),r=new Set(o);s.checked?r.add(s.value):r.delete(s.value);const c=n.filter(e=>r.has(e));return c.length?c.join(l):null}if(_(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const a of t.domain.codedValues)if(a.name===e.selectedItems[0].textContent)return a.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const l=e.value;return null==l||""===l?null:"number"===t.dataType?"-0"===l||"-0."===l||"-0,"===l?l:parseFloat(l):"date"===t.field.type?parseFloat(l):l}_saveInput(e){const t=this._getFieldInputFromHTMLElement(e),{elementId:a}=t.template;if(!t)return;const i=t?.value;if(_(t.template,"switch")&&"single"!==this.viewModel.mode){const e=n(this._batchSwitchInputInitialValues,t,()=>t.value);this._batchSwitchInputInitialValues.set(t,null===e?i:e)}const l=this._parseValue(e,t);l!==i&&this.viewModel.setValue(a,l)}_afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:a}=e.template,i=e.field.type,n=this._dateComponentMap.get(`${a}`);if(!n)return;const l=e.effectiveTimeZone;let s=e.value===T?void 0:e.value,o=null;"date-only"===i?o=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===i?(s=W(s),o=W(t.value)):o="timestamp-offset"===i?null!=t.value?G({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:l}):null:null!=t.value?K({oldValue:s,dateComponent:n.date,timeZone:l,timeComponent:n.time?.value===T?void 0:n.time}):null,s!==o&&(null!==o&&t.value?this.viewModel.setValue(`${a}`,o):this.viewModel.setValue(`${a}`,null))}};e([c()],se.prototype,"activeFeatureIndex",null),e([c()],se.prototype,"disabled",null),e([c()],se.prototype,"effectiveTitle",null),e([c()],se.prototype,"effectiveDisabled",null),e([c()],se.prototype,"features",null),e([c()],se.prototype,"footerButtonInfos",null),e([c()],se.prototype,"footerNoticeInfos",null),e([c()],se.prototype,"map",null),e([c()],se.prototype,"maximumFeatureCount",null),e([c()],se.prototype,"maximumFeatureCountWithComplexForms",null),e([c()],se.prototype,"spatialReference",null),e([c()],se.prototype,"layerInfos",null),e([c()],se.prototype,"timeZone",null),e([c()],se.prototype,"headingLevel",void 0),e([c()],se.prototype,"icon",null),e([c(),X("esri/t9n/common")],se.prototype,"messagesCommon",void 0),e([c(),X("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],se.prototype,"messages",void 0),e([c(),X("esri/core/t9n/Units")],se.prototype,"messagesUnits",void 0),e([c()],se.prototype,"page",null),e([c()],se.prototype,"readOnly",null),e([c()],se.prototype,"selectedAttachment",null),e([c()],se.prototype,"selectedAttachmentDetails",null),e([c()],se.prototype,"valid",null),e([c({type:y}),Y(["value-change","submit"])],se.prototype,"viewModel",void 0),e([c({type:k,nonNullable:!0})],se.prototype,"visibleElements",void 0),e([c()],se.prototype,"groupDisplay",void 0),e([c()],se.prototype,"_attemptFocusOnNextRender",void 0),e([c()],se.prototype,"_formId",null),e([c()],se.prototype,"_focusedFieldInput",void 0),e([c()],se.prototype,"_attachmentDialogInfo",void 0),e([c()],se.prototype,"_attachmentListFilterText",void 0),se=e([d("esri.widgets.BatchAttributeForm")],se);const oe=se;export{oe as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as a}from"../core/deprecate.js";import i from"../core/Logger.js";import{getOrCreateMapValue as n}from"../core/MapUtils.js";import{watch as l,when as s,on as o}from"../core/reactiveUtils.js";import{formatFileSize as r}from"../core/unitFormatUtils.js";import{property as c,subclass as d}from"../core/accessorSupport/decorators.js";import{isIntegerField as m}from"../layers/support/fieldUtils.js";import{isString as h}from"../support/guards.js";import u from"./Widget.js";import{getAttachmentTypeCategory as p,getCalciteIconForAttachment as g}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as v,isImageAttachment as f}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as b,getVisibleFieldInputValidationErrorMessage as C,isElementTemplateWithInputType as _}from"./BatchAttributeForm/batchAttributeFormUtils.js";import A from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as y}from"./BatchAttributeForm/css.js";import{makeAddAttachmentFooterButtons as I,makeDiscardAttachmentFooterButtons as F,makeReplaceAttachmentFooterButtons as w,makeViewingAttachmentFooterButtons as k,makeDefaultFooterButtons as x}from"./BatchAttributeForm/interfaceUtils.js";import D from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as M,isFieldInput as S,isTextElementInput as E,isRelationshipElementInput as O,isAttachmentElementInput as V,isUtilityNetworkAssociationsElementInput as T,differentValuesString as L}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as R,getMultipleChoiceCheckboxState as P,otherChoiceCheckedPlaceholderValue as U,getUpdatedMultipleChoiceValueForFeature as N,getMultipleChoiceSelectAllState as $,splitMultipleChoiceValue as B,canRestoreMultipleChoiceOtherChoiceDraftValue as j}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{downloadAttachmentInfo as z}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as Z,getIntlOptionsForField as q,prepareISOFieldValueForDateComponents as G,prepareUnixFieldValueForDateComponents as W,normalizeTimeOnlyString as K,getISOFieldValueFromDateComponents as J,getUnixFieldValueFromDateComponents as Q}from"./support/dateUtils.js";import{globalCss as X}from"./support/globalCss.js";import{calciteListFilterProps as Y}from"./support/listUtils.js";import{messageBundle as ee,vmEvent as te,tsx as ae}from"./support/widget.js";import{setFocus as ie}from"./support/widgetUtils.js";import{isEmptyValue as ne}from"./support/forms/formUtils.js";const le="data-element-id",se="esri_BatchAttributeForm_select_all",oe="esri_BatchAttributeForm_other_choice";let re=class extends u{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.messagesUnits=null,this.viewModel=new A,this.visibleElements=new D,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._attachmentDialogInfo=null,this._attachmentListFilterText="",this._attachmentFileInputMap=new Map,this._selectedAttachmentReplaceFileInput=null,this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{this.readOnly||this.effectiveDisabled||!this.selectedAttachmentDetails||this.viewModel.setShowingSelectedAttachmentReplacePage(!0)},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this.readOnly||this.effectiveDisabled||this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{const e=this.selectedAttachmentDetails,t=e?.attachment.globalId,a=e?e.input.getAttachmentEditState(e.attachment).initialName:null;e&&t&&null!=a&&this.viewModel.stageRenameAttachment(e.input.template.elementId,t,a)},this._resetSelectedAttachmentChanges=()=>{const e=this.selectedAttachmentDetails,t=e?.attachment.globalId;e&&t&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,t)},this._deleteSelectedAttachment=()=>{const e=this.selectedAttachmentDetails,t=e?.attachment.globalId;e&&t&&!this._isSelectedAttachmentDeleteDisabled()&&(this.viewModel.stageDeleteAttachment(e.input.template.elementId,t),this._setSelectedAttachment(null))},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{a(i.getLogger(this),"Editor","arcgis-editor",{version:"5.0"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...a}=e;return a}initialize(){this.addHandles([l(()=>this.features,()=>{this._dateComponentMap.clear(),this._resetTransientFormState(),R(this.viewModel,{includeDraftValues:!0})}),l(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),R(this.viewModel)}),l(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),s(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),l(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=""}),o(()=>this.viewModel,"submit",()=>{this.valid||this.goToFirstError()})])}loadDependencies(){return H({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){const{features:e,messages:t,page:a}=this;return"replacing-attachment"===a?t.titles.replaceAttachment:"viewing-attachment-details"===a?t.titles.editAttachment:"adding-attachments"===a?t.titles.addAttachments:"viewing-attachments"===a?t.titles.attachments:1===e.length||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:""}get effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length)return[];const{page:e,messages:t}=this,a=this.viewModel.selectedAttachmentAddElementId,i=this.selectedAttachmentDetails,n=i?i.input.getAttachmentEditState(i.attachment):null;if("adding-attachments"===e&&a)return I({messages:t,onclick:()=>this._attachmentFileInputMap.get(a)?.click()});return!!i&&"replacing-attachment"!==e&&!!n?.isReplaced?F({message:this.messagesCommon.remove,onclick:this._resetSelectedAttachmentChanges}):"replacing-attachment"===e?w({disabled:this.readOnly||this.effectiveDisabled,messages:t,onclick:this._openSelectedAttachmentReplaceFilePicker}):"viewing-attachment-details"===e?k({deleteDisabled:this._isSelectedAttachmentDeleteDisabled(),deleteOnclick:this._deleteSelectedAttachment,doneOnclick:()=>this._setSelectedAttachment(null),messages:t.footerButtons}):"viewing-attachments"===e?[]:x({formId:this._formId,callback:this.submit,messages:t})}get footerNoticeInfos(){if(!this.features.length)return[];const{messages:{footerNotices:e}}=this;return this._isSelectedAttachmentDeleteDisabled()?[{icon:"information",message:e.deleteDisabledMinimumAttachments}]:[]}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _associationsEnabled(){const{callbacks:e}=this;return!(!e?.addAssociation||!e.selectAssociatedFeature)}get _formId(){return`${this.id}-form`}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){return ae("div",{class:this.classes(y.base,X.widget,X.panel)},this._renderContent(),this._renderAttachmentDialog())}submit(){return this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:a}=e.dataset,i=n(this._dateComponentMap,`${a}`,()=>({}));switch(t){case"date":i.date=e;break;case"time":i.time=e;break;case"timeZone":i.timeZone=e}}_renderContent(){const{messages:e,viewModel:a}=this,{status:i}=a;return"failed"===i?a.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:a.maximumFeatureCountWithComplexForms})):a.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:a.maximumFeatureCount})):e.formFailedToLoad:a.expressionEvaluationFailed?this._renderErrorNotice(e.expressionEvaluationFailed):a.hasLayersWithContingentValues&&this.viewModel.features.length>1?this._renderErrorNotice(e.unsupportedContingentValues):"loading"===i&&this.visibleElements.loadingIndicator?ae("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):0!==this.features.length?this._renderForm():void 0}_renderErrorNotice(e,t="warning"){return ae("calcite-notice",{class:y.noticeError,icon:!0,kind:t,open:!0},ae("div",{slot:"message"},e))}_renderForm(){return ae("form",{class:y.form,id:this._formId,onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case"adding-attachments":return this._renderAttachmentAddPage();case"replacing-attachment":case"viewing-attachments":return this._renderAttachmentListPage();case"viewing-attachment-details":return this._renderAttachmentDetailPage();default:return this._renderFormContent()}}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:a}=e;let i;if(!e.submitHasBeenAttempted)return null;if(a.invalidHiddenInputs.length>0)if(i=b(a,e.mode,this.messages),"batch"===this.viewModel.mode){const e=a.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?i+=` (${e.map(e=>e.label).join(", ")})`:i=null}else i+=` (${a.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return i?this._renderErrorNotice(i,"danger"):null}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){return M(e)?this._renderGroupInput(e):S(e)?this._renderLabeledField(e):E(e)?this._renderTextComponent(e):O(e)?this._renderRelationshipElementInput(e):V(e)?this._renderAttachmentElementInput(e):T(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderGroupInput(e){const{inputs:t,template:a,open:i}=e,n=t.filter(e=>e.visible),l=a.label??"";return ae("calcite-block",{class:this.classes(y.group,"sequential"===this.groupDisplay?y.groupSequential:null,this.disabled?y.inputDisabled:null),collapsible:!0,description:a.description??void 0,disabled:this.effectiveDisabled,expanded:i,heading:l,headingLevel:this.headingLevel,key:`{${a.elementId}-key}`,label:l,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{elementId:a}=e.template,{label:i,required:n,dataType:l}=e,s=n?t(this.messages.requiredFieldLabel,{name:i}):i;return ae("calcite-label",{"aria-label":s,class:y.label,key:`field--${a}`},ae("div",{class:y.labelTextContent,key:"labelTextContainer"},i,n?ae("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==l?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:a}=e;return"date"===a?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):null!==e.multipleChoiceChoices?this._renderMultipleChoiceComponent({input:e,props:t}):"number"===a?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:a,submittable:i}=e,n=!i&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?C(e,t,this.messages):null;return n?ae("calcite-input-message",{icon:!0,status:"invalid"},n):a?ae("calcite-input-message",{class:y.description,icon:!1,status:"idle"},a):null}_renderCodedInputs({input:e,props:t}){const a=e.input?.type??null,i=e.codedValueOptions;switch(a){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:i,props:t});default:return this._renderComboBoxComponent({options:i,props:t,input:e})}}_renderMultipleChoiceComponent({input:e,props:t}){const{messages:a}=this,{multipleChoiceChoices:i,multipleChoiceInput:n,multipleChoiceValues:l}=e;if(!n||!i||!l)return null;const s=!0===n.includeSelectAllChoices,o=new Map;let r=l.length>0,c=!1;for(const f of l){const t=P({input:e,choiceValue:f});o.set(f,t),(t.checked||t.indeterminate)&&(c=!0),t.checked||(r=!1)}const d={checked:r,indeterminate:!r&&c},m=d.checked?a.deselectAllLabel:a.selectAllLabel,h=e.getMultipleChoiceOtherChoiceRenderState(this.messages.otherOptionLabel),u=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})},p=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})},g=t=>{const{fieldName:a}=h;a&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:a})},v=t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:h.fieldName})};return ae("div",{class:y.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},s?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:d,selectAllLabel:m,handleSelectAllCheckboxChange:u}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:p}),h.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:s,otherChoiceRenderState:h,handleOtherChoiceCheckboxChange:g,handleOtherChoiceInputChange:v,differentValuesPlaceholder:a.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:a,handleSelectAllCheckboxChange:i}){return ae("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:t.checked,class:y.multipleChoiceSelectAll,"data-element-id":e[le],disabled:e.readOnly,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:a,labelText:a,value:se,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>i(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:a,handleChoiceCheckboxChange:i}){const{multipleChoiceChoices:n}=e;return n?n.map(e=>{const n=a.get(e.value)??{checked:!1,indeterminate:!1};return ae("calcite-checkbox",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t["aria-invalid"],checked:n.checked,class:t.class,"data-element-id":t[le],disabled:t.readOnly,indeterminate:n.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,required:t.required,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>i(e),onfocus:t.onfocus})}):[]}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:a,handleOtherChoiceCheckboxChange:i,handleOtherChoiceInputChange:n,differentValuesPlaceholder:l}){return ae("div",{class:this.classes(y.multipleChoiceOtherChoice,t?y.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},ae("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:a.checkboxState.checked,class:e.class,"data-element-id":e[le],disabled:e.readOnly,indeterminate:a.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:a.label,labelText:a.label,value:oe,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>i(e),onfocus:e.onfocus}),a.checkboxState.checked?ae("calcite-input",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],"aria-label":a.label,class:y.textElementInput,"data-element-id":e[le],disabled:e.readOnly,key:`${e.key}-other-choice-input`,maxLength:a.maxLength,placeholder:a.value===L?l:a.hint,required:e.required,type:"text",value:a.normalizedValue===L?"":a.normalizedValue?String(a.normalizedValue):"",onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>n(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:a=!1}){if(e.multipleChoiceInput&&!a&&"batch"===this.viewModel.mode)return void await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});const i=e.value,n=this._parseValue(t,e,a);n!==i&&await this.viewModel.setValue(e.template.elementId,n)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:a}){if(!a)return;const i=t.value,n=null==i||""===i?null:i;e.initializeExplicitMultipleChoiceOtherChoiceCheckedState(),e.stashMultipleChoiceOtherChoiceDraftValueForFeatures(e.features,n);const l=e.features.toArray().filter(e=>e.getAttribute(a)!==n);if(0!==l.length){for(const e of l)e.setAttribute(a,n);this.viewModel.userHasChangedValues=!0,await e.expressionsManager.valueChanged(a,l),this.viewModel.emit("value-change",{features:l.map(e=>e.source),fieldName:a,name:"value-change",value:n})}}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:a}){e.setExplicitMultipleChoiceOtherChoiceCheckedState(t),t||e.setMultipleChoiceOtherChoiceDraftValuesFromFeatures(e.features.toArray());const i=e.features.toArray().filter(i=>{const n=i.getAttribute(a);if(t){if(!ne(n))return!1;const t=e.getMultipleChoiceOtherChoiceDraftValue(i),l=j(t)?t:U;return i.setAttribute(a,l),!0}return null!=n&&(i.setAttribute(a,null),!0)});0!==i.length&&(this.viewModel.userHasChangedValues=!0,await e.expressionsManager.valueChanged(a,i),this.viewModel.emit("value-change",{features:i.map(e=>e.source),fieldName:a,name:"value-change",value:this._getFieldValueByFieldNameForInput(e,a)}))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){if(!e.multipleChoiceInput||!e.multipleChoiceValues)return;const a=e.features.toArray().filter(a=>{const i=a.getAttribute(e.fieldName),n=N({input:e,choiceValue:t.value,currentValue:i,isChecked:t.checked});return i!==n&&(a.setAttribute(e.fieldName,n),!0)});0!==a.length&&(this.viewModel.userHasChangedValues=!0,await e.expressionsManager.valueChanged(e.fieldName,a),this.viewModel.emit("value-change",{features:a.map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:this._getFieldValueByFieldNameForInput(e,e.fieldName)}))}_getFieldValueByFieldNameForInput(e,t){const a=e.features.toArray().map(e=>e.getAttribute(t));if(0===a.length)return null;const[i]=a;return a.every(e=>e===i)?i:L}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===L||e.value===L)&&"batch"===this.viewModel.mode){const a={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[le]:t[le]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:a,options:[{name:this.messages.differentValuesPlaceholder,value:L,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return ae("calcite-switch",{...t,checked:!!_(e.template,"switch")&&e.value===e.template.input.onValue,class:y.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:a}){const{trigger:i,dropdown:n,group:l}=a;return ae("calcite-dropdown",{...n,topLayerDisabled:this.topLayerDisabled,onblur:()=>{this._focusedFieldInput=null},onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e),onfocus:this._onComponentFocus},ae("calcite-button",{...i},e===L?this.messages.differentValuesPlaceholder:e),ae("calcite-dropdown-group",{selectionMode:l.mode},t.map(t=>ae("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:a}){const i="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),l=i&&e.showNoValueOptionEnabled&&!n?()=>{}:a.onblur,s={...a,onblur:l};return ae("calcite-combobox",{...s,selectionMode:"single",topLayerDisabled:this.topLayerDisabled,value:a.placeholder===this.messages.differentValuesPlaceholder?L:String(a.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==L&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:a}))}renderComboboxOptionsList({input:e,options:t,props:a}){const i=e=>e.map(e=>{const{value:t}=e,i=ne(e.value)?this.messages.empty:e.name;return ae("calcite-combobox-item",{heading:i,key:`#${t}`,selected:a.value===t,value:`${t}`})});let n=[];const{messages:l}=this;t.other.length>0&&n.push(ae("calcite-combobox-item-group",{key:"other",label:l.other},i(t.other))),t.unsupported.length>0&&n.push(ae("calcite-combobox-item-group",{key:"unsupported",label:l.unsupported},i(t.unsupported)));const s=i(t.recommended);n.length>0?n.unshift(ae("calcite-combobox-item-group",{key:"recommended",label:l.recommended},s)):n=s;const o=a.placeholder===this.messages.differentValuesPlaceholder,r=!o&&ne(a.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&n.unshift(ae("calcite-combobox-item",{heading:e.showNoValueLabel||this.messages.empty,key:"empty-option",selected:r,value:""})),o&&n.unshift(ae("calcite-combobox-item",{heading:this.messages.differentValuesPlaceholder,key:L,selected:!0,value:L})),n}_renderRadioButtonGroupComponent({input:e,options:t,props:a}){const i=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:i})=>this._renderRadioButtons({label:t,value:i,selected:i===e.value,props:a}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){const t="",n=e.showNoValueLabel||this.messages.empty,l=ne(e.value);i.unshift(this._renderRadioButtons({label:n,value:t,selected:l,props:a}))}return ae("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:y.inputRadioGroup,disabled:a.readOnly,key:`${a.key}-radio-group`,layout:"vertical",name:a.name,required:a.required},i,a.placeholder===this.messages.differentValuesPlaceholder?ae("calcite-label",{class:y.placeholderRadio,key:a.label,layout:"inline"},ae("calcite-radio-button",{checked:!0,class:y.inputRadio,disabled:!0,name:a.placeholder,value:a.placeholder}),a.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:a,props:i}){return ae("calcite-label",{class:y.inputRadioLabel,key:i.label,layout:"inline"},ae("calcite-radio-button",{...i,afterCreate:void 0,afterUpdate:void 0,checked:t,class:y.inputRadio,disabled:i.readOnly,name:i.label,value:e,onblur:()=>{this._focusedFieldInput=null},onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),a)}_renderStringComponent(e,t){const{template:a}=e;return!a.field.editable||this.readOnly?this._renderReadOnlyComponent(e):"text-area"===a.input?.type?ae("calcite-text-area",{...t,class:this.classes(y.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):ae("calcite-input",{...t,class:this.classes(y.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const a=m(e.field);return ae("calcite-input-number",{...t,integer:a,type:"number",value:a&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const a=this.getCommonInputProps(e);return ae("calcite-input",{...a,class:this.classes(y.fieldInput,y.inputDisabled,y.individualElement),readOnly:!0,type:"text",value:String(t??a.value??"")})}_renderDateComponents(e,t){const{field:a}=e;let i;switch(a.type){case"date":i=this._renderDateFieldComponents(e,t);break;case"date-only":i=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":i=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":i=this._renderTimestampOffsetFieldComponents(e,t);break;default:i=this._renderReadOnlyComponent(e,Z(a,t.value,{timeZone:e.effectiveTimeZone,...q(e.template.field)}))}return e.value===L?[i,ae("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:i}_renderDateOnlyFieldComponent(e,t){const{class:a,key:i,readOnly:n}=t,{rawMax:l,rawMin:s}=e.range;return ae("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:a,"data-date-part":"date","data-element-id":t[le],key:`${i}-date-input`,max:h(l)?l:void 0,min:h(s)?s:void 0,overlayPositioning:"fixed",readOnly:n,topLayerDisabled:this.topLayerDisabled,value:e.value===L?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimeOnlyFieldComponent(e,t){const{class:a,key:i,readOnly:n}=t;return ae("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:a,"data-date-part":"time","data-element-id":t[le],key:`${i}-time-input`,overlayPositioning:"fixed",readOnly:n,value:e.value===L?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimestampOffsetFieldComponents(e,t){const{class:a,key:i,readOnly:n}=t,{rawMax:l,rawMin:s}=e.range,o=G(l),r=G(s),c=G(e.value===L?"":e.value),d=e.includeTimeOffset,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[le]:t[le],onfocus:this._onComponentFocus};return ae("div",{class:y.dateInputContainer,key:`${i}-date-time-container`},ae("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${i}-date-input`,max:o?.date??void 0,min:r?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:c.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),ae("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${i}-time-input`,value:c.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),d?ae("calcite-input-time-zone",{...m,class:a,clearable:e.value===L||null==e.value,"data-date-part":"timeZone",key:`${i}-timezone-input`,value:c.timeZoneOffset||"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:a,key:i,readOnly:n,min:l,max:s}=t,o=e.effectiveTimeZone,r=W(e.value===L?"":e.value,o),c=W(s,o),d=W(l,o),m=e.includeTime,h={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[le]:t[le],onfocus:this._onComponentFocus};return ae("div",{class:y.dateInputContainer,key:`${i}-date-time-container`},ae("calcite-input-date-picker",{...h,class:a,"data-date-part":"date",key:`${i}-date-input`,max:c?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:r.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?ae("calcite-input-time-picker",{...h,"data-date-part":"time",key:`${i}-time-input`,step:1,value:r.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){const{elementId:t}=e.template;return ae("div",{class:y.relationshipElementInput,"data-testid":`relationship-element-${t}`,key:`relationship-element-${t}`})}_renderAttachmentElementInput(e){const{allAttachmentsVisibleOnDefaultPage:t,attachments:a,defaultPageAttachments:i,template:{description:n,elementId:l,label:s}}=e,o=t?a:i;return ae("div",{class:y.attachmentElementInput,"data-testid":`attachment-element-${l}`,key:`attachment-element-${l}`},s?ae("div",{class:y.attachmentElementLabel,key:`attachment-element-label-${l}`},s):null,n?ae("div",{class:y.description,key:`attachment-element-description-${l}`},n):null,a.length?this._renderAttachmentList(e,o,{label:s||this.messagesCommon.details,viewAllCount:t?null:a.length}):ae("div",{class:y.attachmentElementEmptyState,key:`attachment-element-empty-state-${l}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){const e=this.viewModel.selectedAttachmentListInput;if(e)return ae("div",{class:y.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,a){const{filterEnabled:i,label:n,viewAllCount:l}=a;return ae("calcite-list",{class:y.attachmentElementList,filterEnabled:i,filterPlaceholder:i?this.messages.attachments.searchAttachments:void 0,filterProps:i?Y:void 0,filterText:i?this._attachmentListFilterText:void 0,label:n,selectionAppearance:"border",selectionMode:"none",onCalciteListFilter:i?e=>{this._attachmentListFilterText=e.currentTarget.filterText??""}:void 0},this._renderAttachmentListItems(e,t),null!=l?this._renderViewAllAttachmentsItem(e,l):null)}_renderAttachmentListItems(e,t){const{elementId:a}=e.template;return t.map((t,i)=>{const n=this._formatAttachmentSize(t.size),l=this._getAttachmentLabel(t,i,n,e.displayFilename),s=l===n?void 0:n,o=v(t),r=e.isStagedAttachmentAddition(t),c=e.getAttachmentEditState(t),d=r||c.isRenamed||c.isReplaced;return ae("calcite-list-item",{class:y.attachmentElementListItem,description:s,key:`attachment-item-${o}`,label:l,onCalciteListItemSelect:r?void 0:()=>this._setSelectedAttachment({attachmentKey:o,elementId:a})},ae("div",{class:y.attachmentElementListItemStart,slot:"content-start"},this._renderAttachmentPreviewThumbnail(t,l,e)),d?ae("span",{class:y.attachmentElementListItemStagedIndicator,slot:"content-end"}):null,r?[ae("calcite-action",{disabled:this.effectiveDisabled,icon:"x",scale:"s",slot:"actions-end",text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(a,t.globalId)})]:ae("calcite-action",{icon:"chevron-right",scale:"s",slot:"actions-end",text:l,title:l}))})}_renderViewAllAttachmentsItem(e,a){const{elementId:i}=e.template,{viewAll:n}=this.messages.attachments;return ae("calcite-list-item",{class:y.attachmentElementListItem,description:t(this.messages.attachments.count,{count:a}),key:`attachment-item-view-all-${i}`,label:n,onCalciteListItemSelect:()=>this._setAttachmentListElementId(i)},ae("calcite-action",{icon:"chevron-right",scale:"s",slot:"actions-end",text:n,title:n}))}_renderAttachmentAddAction(e){const{elementId:t}=e.template,a=this.effectiveDisabled||e.addDisabled;return ae("div",{class:y.attachmentElementEmptyAction,key:`attachment-element-empty-action-${t}`},ae("calcite-button",{appearance:"outline",disabled:a,iconStart:"attachment",kind:"neutral",round:!0,scale:"s",onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach))}_renderAttachmentAddPage(){const e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){const{maxAttachmentCount:t}=e,{elementId:a}=e.template,i=null==t||t-e.attachments.length>1,n=this.effectiveDisabled||e.addDisabled,l=this.messages.attachments,s=l.dragAndDropFile,o="upload",r=e=>{this._attachmentFileInputMap.set(a,e)};return ae("div",{class:y.attachmentElementAddPanel,key:`attachment-element-add-panel-${a}`},ae("input",{accept:e.accept,afterCreate:r,afterRemoved:()=>{this._attachmentFileInputMap.delete(a)},afterUpdate:r,class:y.attachmentElementFileInput,"data-element-id":a,disabled:n,multiple:i,type:"file",onchange:e=>{const t=e.currentTarget,i=t.files?Array.from(t.files):[];this._stageAttachmentFiles(a,i),t.value=""}}),ae("div",{class:y.attachmentElementAddDropzone,"data-disabled":n?"true":"false",ondragover:e=>{e.preventDefault()},ondrop:e=>{if(e.preventDefault(),n)return;const t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(a,t)}},ae("calcite-icon",{class:y.attachmentElementAddDropzoneIcon,icon:o,scale:"l"}),ae("div",{class:y.attachmentElementAddDropzoneHeading},l.addFile),ae("div",{class:y.attachmentElementAddDropzoneDetail,title:s},s),ae("calcite-button",{appearance:"outline-fill",disabled:n,iconStart:"folder-open",scale:"s",type:"button",onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(a,n)}},l.selectFile)))}async _stageAttachmentFiles(e,t){if(0!==t.length)try{await this.viewModel.stageAddAttachments(e,t)}finally{this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){const e=this.selectedAttachmentDetails;if(!e)return;if("replacing-attachment"===this.page)return this._renderAttachmentReplacePanel(e);const{attachment:t,input:a}=e,i=v(t),n=!!a.getAttachmentPreviewUrl(t),l=a.getAttachmentEditState(t),s=!this.readOnly&&!this.effectiveDisabled;return ae("div",{class:y.attachmentElementDetail,key:`attachment-detail-panel-${a.template.elementId}-${i}`},ae("div",{class:y.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,a)),ae("div",{class:y.attachmentElementDetailActions},ae("calcite-button",{appearance:"outline",disabled:!n,iconStart:"download-to",kind:"neutral",scale:"s",onclick:()=>{this._downloadAttachment(t)}},this.messages.attachments.download),f(t)?ae("calcite-button",{appearance:"outline",disabled:!n,iconStart:"expand",kind:"neutral",label:this.messages.attachments.maximize,scale:"m",title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,ae("calcite-button",{appearance:"outline",disabled:!n,iconStart:"download",kind:"neutral",label:this.messages.attachments.download,scale:"m",title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),ae("calcite-button",{appearance:"outline",disabled:!s,iconStart:"upload-to",kind:"neutral",label:this.messages.attachments.replace,scale:"m",title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),ae("div",{class:y.attachmentElementDetailMetadata},ae("div",{class:y.attachmentElementDetailMetadataGroup},ae("span",{class:y.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),a.allowUserRename?ae("div",{class:y.attachmentElementDetailFileNameRow},ae("calcite-input",{class:y.attachmentElementDetailFileNameInput,disabled:!s,scale:"m",value:t.name||"",onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),ae("calcite-button",{appearance:"transparent",disabled:!s||null==l.initialName||!l.isRenamed,iconStart:"reset",kind:"neutral",scale:"m",title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})):ae("span",{class:y.attachmentElementDetailMetadataValue},t.name)),ae("div",{class:y.attachmentElementDetailMetadataGroup},ae("span",{class:y.attachmentElementDetailMetadataLabel},this.messages.attachments.size),ae("span",{class:y.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),ae("div",{class:y.attachmentElementDetailMetadataGroup},ae("span",{class:y.attachmentElementDetailMetadataLabel},this.messages.attachments.type),ae("span",{class:y.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderAttachmentReplacePanel(e){const{attachment:t,input:a}=e,i=this.readOnly||this.effectiveDisabled,n=a.template.elementId;return ae("div",{class:y.attachmentElementAddPanel,key:`attachment-replace-panel-${n}-${v(t)}`},ae("input",{accept:a.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:y.attachmentElementFileInput,disabled:i,type:"file",onchange:e=>{const t=e.currentTarget,a=t.files?.[0];a&&this._stageSelectedAttachmentReplacement(a),t.value=""}}),ae("div",{class:y.attachmentElementAddDropzone,"data-disabled":i?"true":"false",ondragover:e=>{e.preventDefault()},ondrop:e=>{if(e.preventDefault(),i)return;const t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},ae("calcite-icon",{class:y.attachmentElementAddDropzoneIcon,icon:"refresh",scale:"l"}),ae("div",{class:y.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),ae("div",{class:y.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),ae("calcite-button",{appearance:"outline-fill",disabled:i,iconStart:"folder-open",scale:"s",onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),ae("div",{class:y.attachmentElementDetailMetadata},ae("div",{class:y.attachmentElementDetailMetadataGroup},ae("span",{class:y.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),ae("span",{class:y.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){const e=this._attachmentDialogInfo;if(!e)return null;const{attachment:t,input:a}=e;return ae("calcite-dialog",{heading:t.name||this.messagesCommon.details,key:"attachment-preview-dialog",modal:!0,open:!0,placement:"cover",width:"l",onCalciteDialogClose:this._closeAttachmentDialog},ae("div",{class:y.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,a)))}_setSelectedAttachment(e){this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){this.viewModel.setSelectedAttachmentAddElementId(e),this.hideAttachmentDialog()}_setAttachmentListElementId(e){this.viewModel.setSelectedAttachmentListElementId(e),this.hideAttachmentDialog()}_getAttachmentLabel(e,a,i,n){return!1!==n&&h(e.name)&&e.name.length>0?e.name:i!==this.messagesCommon.notApplicable?i:t(this.messages.attachments.attachmentNumberedLabel,{index:a+1})}_formatAttachmentSize(e){return null==e||Number.isNaN(e)?this.messagesCommon.notApplicable:r(this.messagesUnits,e)}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;const t=this.messages.attachments.attachmentTypes,a=p(e);return t?.[a]||e}_renderAttachmentPreviewThumbnail(e,t,a){const i=a.getAttachmentPreviewUrl(e,64);return i&&f(e)?ae("img",{alt:t,class:y.attachmentElementListItemThumb,src:i}):ae("calcite-icon",{class:y.attachmentElementListItemIcon,icon:g(e.contentType),scale:"s"})}_renderAttachmentPreviewImageForInput(e,t){const a=t.getAttachmentPreviewUrl(e),i=e.name||this.messagesCommon.details;return a&&f(e)?ae("img",{alt:i,class:y.attachmentElementDetailPreviewImage,src:a,title:i}):[ae("calcite-icon",{class:y.attachmentElementDetailPreviewIcon,icon:g(e.contentType),scale:"l",textLabel:i,title:i}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await z(e)}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){const t=this.selectedAttachmentDetails,a=t?.attachment.globalId;if(t&&a)try{await this.viewModel.stageReplaceAttachment(t.input.template.elementId,a,e)}finally{this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){const t=this.selectedAttachmentDetails,a=t?.attachment.globalId;t&&a&&this.viewModel.stageRenameAttachment(t.input.template.elementId,a,e)}_isSelectedAttachmentDeleteDisabled(){const e=this.selectedAttachmentDetails;if(!e)return!1;if(this.readOnly||this.effectiveDisabled)return!0;const t=e.input.minAttachmentCount;return null!=t&&e.input.attachments.length<=t}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){const{elementId:t}=e.template;return ae("div",{class:y.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;const{elementId:t}=e.template;return ae("div",{class:y.utilityNetworkAssociationsElementInput,"data-testid":t,key:t})}getCommonInputProps(e){const{template:t,valid:a,value:i,minLength:n,maxLength:l,required:s,fieldName:o,editable:r,userHasChangedValue:c,range:{max:d,min:m}}=e,h=!r||this.readOnly,u=!h&&this.effectiveDisabled;let p=t.hint??void 0,g=!1;return i===L&&(p=this.messages.differentValuesPlaceholder,g=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":a?"false":"true",class:this.classes(y.fieldInput,h?y.inputDisabled:null),status:!c&&!this.viewModel.submitHasBeenAttempted||a?"idle":"invalid",maxLength:l&&l>-1?l:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:o,name:o,max:null!=d?d:void 0,min:null!=m?m:void 0,disabled:u,readOnly:h,onblur:this._onComponentBlur,required:s,placeholder:p,value:g?"":i??"",[le]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(le))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,a=e.querySelector("calcite-radio-button"),i=t||a;i&&this._afterComponentCreateOrUpdate(i)}_onComponentFocus(e){const t=e.target,a=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(a.template.elementId),this._focusedFieldInput=a}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),a=this._focusedFieldInput;this._attemptFocusOnNextRender&&a===t&&(this._attemptFocusOnNextRender=!1,ie(e))}_onComponentBlur(){this._focusedFieldInput=null}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText="",this._attachmentFileInputMap.clear()}_parseValue(e,t,a=!1){const i=t.multipleChoiceInput,n=t.multipleChoiceValues;if(i&&n){const l=i.choiceDelimiter,s=e;if(a){return $({input:t}).checked?null:n.length>0?n.join(l):null}const o=B(t.value,l).filter(e=>e!==L),r=new Set(o);s.checked?r.add(s.value):r.delete(s.value);const c=n.filter(e=>r.has(e));return c.length?c.join(l):null}if(_(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const a of t.domain.codedValues)if(a.name===e.selectedItems[0].textContent)return a.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const l=e.value;return null==l||""===l?null:"number"===t.dataType?"-0"===l||"-0."===l||"-0,"===l?l:parseFloat(l):"date"===t.field.type?parseFloat(l):l}_saveInput(e){const t=this._getFieldInputFromHTMLElement(e),{elementId:a}=t.template;if(!t)return;const i=t?.value;if(_(t.template,"switch")&&"single"!==this.viewModel.mode){const e=n(this._batchSwitchInputInitialValues,t,()=>t.value);this._batchSwitchInputInitialValues.set(t,null===e?i:e)}const l=this._parseValue(e,t);l!==i&&this.viewModel.setValue(a,l)}_afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:a}=e.template,i=e.field.type,n=this._dateComponentMap.get(`${a}`);if(!n)return;const l=e.effectiveTimeZone;let s=e.value===L?void 0:e.value,o=null;"date-only"===i?o=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===i?(s=K(s),o=K(t.value)):o="timestamp-offset"===i?null!=t.value?J({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:l}):null:null!=t.value?Q({oldValue:s,dateComponent:n.date,timeZone:l,timeComponent:n.time?.value===L?void 0:n.time}):null,s!==o&&(null!==o&&t.value?this.viewModel.setValue(`${a}`,o):this.viewModel.setValue(`${a}`,null))}};e([c()],re.prototype,"activeFeatureIndex",null),e([c()],re.prototype,"callbacks",null),e([c()],re.prototype,"disabled",null),e([c()],re.prototype,"effectiveTitle",null),e([c()],re.prototype,"effectiveDisabled",null),e([c()],re.prototype,"features",null),e([c()],re.prototype,"footerButtonInfos",null),e([c()],re.prototype,"footerNoticeInfos",null),e([c()],re.prototype,"map",null),e([c()],re.prototype,"maximumFeatureCount",null),e([c()],re.prototype,"maximumFeatureCountWithComplexForms",null),e([c()],re.prototype,"spatialReference",null),e([c()],re.prototype,"layerInfos",null),e([c()],re.prototype,"timeZone",null),e([c()],re.prototype,"headingLevel",void 0),e([c()],re.prototype,"icon",null),e([c(),ee("esri/t9n/common")],re.prototype,"messagesCommon",void 0),e([c(),ee("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],re.prototype,"messages",void 0),e([c(),ee("esri/core/t9n/Units")],re.prototype,"messagesUnits",void 0),e([c()],re.prototype,"page",null),e([c()],re.prototype,"readOnly",null),e([c()],re.prototype,"selectedAttachment",null),e([c()],re.prototype,"selectedAttachmentDetails",null),e([c()],re.prototype,"valid",null),e([c({type:A}),te(["value-change","submit"])],re.prototype,"viewModel",void 0),e([c({type:D,nonNullable:!0})],re.prototype,"visibleElements",void 0),e([c()],re.prototype,"groupDisplay",void 0),e([c()],re.prototype,"_associationsEnabled",null),e([c()],re.prototype,"_attemptFocusOnNextRender",void 0),e([c()],re.prototype,"_formId",null),e([c()],re.prototype,"_focusedFieldInput",void 0),e([c()],re.prototype,"_attachmentDialogInfo",void 0),e([c()],re.prototype,"_attachmentListFilterText",void 0),re=e([d("esri.widgets.BatchAttributeForm")],re);const ce=re;export{ce as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{addMany as t}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import o from"../../core/Error.js";import i from"../../core/Logger.js";import{destroyMaybe as s}from"../../core/maybe.js";import{whenOnce as a}from"../../core/reactiveUtils.js";import{property as n,subclass as l}from"../../core/accessorSupport/decorators.js";import{isSceneLayer as d,isTable as u}from"../../layers/support/layerUtils.js";import c from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import p from"./UpdateFeaturesWorkflowData.js";import h from"./Workflow.js";import{whenEditorLayerView as f,findEditorItemForLayer as m}from"./workflowUtils.js";import{MultipleSourceLayersError as g}from"./support/errors.js";import{SketchController as y}from"./support/SketchController.js";var w;const F=()=>i.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),v=Symbol();let b=w=class extends h{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new r(e),this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new o("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=s(this._sketchController),this._formViewModel.destroy()}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItems.some(e=>e.hasInvalidFormTemplate)}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get selectedFeature(){return this.data.selectedFeature}get sketchUpdateOptions(){const{data:e}=this,t=e.fullFeatures,r=_(e),o=e.getEditorItemForLayer(r),i=!this.selectedFeature||t.length>1;return{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!d(r)&&!!o?.capabilities.supportsTrueCurve},tool:i?"move":void 0}}get sketchViewModel(){return this._sketchController?.viewModel}get supportsMergeFeaturesWorkflow(){const e=this.data,{fullFeatures:t,layers:r}=e;return!(1!==r.length||t.length<2)&&(!this.curveUpdatesDisabled&&!!e.getEditorItemForLayer(r[0])?.supportsMergeFeaturesWorkflow)}getUpdating(){return!!this._sketchController?.updating}get viewGraphics(){return this._sketchController?.sketchGraphics??this.data.fullFeatures}async commit(){const{data:e,_formViewModel:t}=this;for(const r of e.fullFeatures)U(e.getPendingEditsForFeature(r),t.getValues(r));await super.commit()}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:s,viewModel:a}=o,n=new Set;function l(e){const t=m(a.editorItems,e);t&&n.add(t)}s?.length?s.forEach(({layer:e})=>l(e)):i?.length&&(F().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const d=Array.from(n),u=new w({data:new p({...o,editorItems:d}),onCommit:M(e.applyEdits)});return u._set("steps",E()),u}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}async enter(){}exit(e){}async reset(){}async save(){const{formViewModel:e}=this;e.submit(),e.valid&&await super.save()}async start(){await super.start(),await a(()=>!this.updating);const e=this._sketchController;if(e)return e;const{data:t}=this,{view:r}=t.viewModel,o=_(t);return!r||u(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(v)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(_(e)),o=r?.layerInfo?[r.layerInfo]:null,i=new c({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone,layerInfos:o});this._formViewModel=i,this.addHandles(i.on("value-change",t=>{for(const r of t.features)e.getPendingEditsForFeature(r)?.setAttribute(t.fieldName,t.value);this._sketchController?.notifyAttributesChanged(t)}));const s=t=>{e.getPendingEditsForFeature(t.feature)?.setAttachmentEdits(t.attachmentEdits)};this.addHandles(i.on("attachments-change",s))}async _initializeHighlights(e,t,r){const o=await f(r,t);this.addHandles(o.highlight(e),v)}_initializeSketchController(e,t,r){const{data:o}=this,i=new y({defaultUpdateOptions:this.sketchUpdateOptions,sourceLayer:t,view:r,features:e,useLegacyCreateTools:o.viewModel.useLegacyCreateTools,onGeometriesUpdated:e=>{const t=[];for(const{feature:r,geometry:i}of e)o.getPendingEditsForFeature(r)?.updateGeometry(i),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},onVisualVariableAttributesUpdated:()=>{F().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")}});this._sketchController=i}_initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=_(t);if(u(o))return;const i=t.getEditorItemForLayer(o);i?.capabilities.update.geometry&&!this.curveUpdatesDisabled&&this._initializeSketchController(e,o,r)}};e([n()],b.prototype,"curveUpdatesDisabled",null),e([n()],b.prototype,"features",null),e([n()],b.prototype,"featureInfos",null),e([n()],b.prototype,"formViewModel",null),e([n()],b.prototype,"hasInvalidFormTemplate",null),e([n()],b.prototype,"hasPendingEdits",null),e([n()],b.prototype,"parent",null),e([n()],b.prototype,"saveActionLabel",null),e([n()],b.prototype,"selectedFeature",null),e([n()],b.prototype,"sketchUpdateOptions",null),e([n()],b.prototype,"sketchViewModel",null),e([n()],b.prototype,"supportsMergeFeaturesWorkflow",null),e([n()],b.prototype,"type",void 0),e([n()],b.prototype,"viewGraphics",null),e([n()],b.prototype,"_formViewModel",void 0),e([n()],b.prototype,"_sketchController",void 0),b=w=e([l("esri.widgets.Editor.UpdateFeaturesWorkflow")],b);const k=b;function E(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function M(e){return async r=>{const o=_(r),i=[],s=[],a=[],n=[],l=[];for(const e of r.fullFeatures){const o=r.getPendingEditsForFeature(e),d=o?.stagedForDelete;if(!o?.modified&&!d)continue;const u=e.clone();if(!o?.attributesModified||d){const t=e.sourceLayer;if(!t){F().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(u.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&u.setAttribute(r,e.getAttribute(r))}}if(o?.geometryModified&&!d||(u.geometry=null),d?s.push(u):(o?.attributesModified||o?.geometryModified)&&i.push(u),o?.attachmentEdits)for(const e of o.attachmentEdits)t(a,e.add),t(n,e.update),t(l,e.delete)}if(i.length+s.length+a.length+n.length+l.length===0)return void F().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const d={updateFeatures:i.length>0?i:void 0,deleteFeatures:s.length>0?s:void 0,addAttachments:a.length>0?a:void 0,updateAttachments:n.length>0?n:void 0,deleteAttachments:l.length>0?l:void 0},u=o.capabilities?.editing.supportsGlobalId&&(a.length>0||n.length>0||l.length>0)?{globalIdUsed:!0}:void 0;await e(o,d,u)}}function _(e){if(e.layers.length>1)throw new g;return e.layers[0]}function U(e,t){if(!e||!e.feature)return;const{attributes:r}=e.feature;Object.keys(t).some(e=>t[e]!==r[e])&&e.updateAttributes(t)}export{k as default};
2
+ import{__decorate as e}from"tslib";import{addMany as t}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import o from"../../core/Error.js";import i from"../../core/Logger.js";import{destroyMaybe as a}from"../../core/maybe.js";import{whenOnce as s}from"../../core/reactiveUtils.js";import{property as n,subclass as l}from"../../core/accessorSupport/decorators.js";import{isSceneLayer as d,isTable as u}from"../../layers/support/layerUtils.js";import c from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import p from"./UpdateFeaturesWorkflowData.js";import h from"./Workflow.js";import{whenEditorLayerView as f,findEditorItemForLayer as m}from"./workflowUtils.js";import{MultipleSourceLayersError as g}from"./support/errors.js";import{SketchController as y}from"./support/SketchController.js";var w;const F=()=>i.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),v=Symbol();let b=w=class extends h{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new r(e),this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new o("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=a(this._sketchController),this._formViewModel.destroy()}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItems.some(e=>e.hasInvalidFormTemplate)}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get selectedFeature(){return this.data.selectedFeature}get sketchUpdateOptions(){const{data:e}=this,t=e.fullFeatures,r=_(e),o=e.getEditorItemForLayer(r),i=!this.selectedFeature||t.length>1;return{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!d(r)&&!!o?.capabilities.supportsTrueCurve},tool:i?"move":void 0}}get sketchViewModel(){return this._sketchController?.viewModel}get supportsMergeFeaturesWorkflow(){const e=this.data,{fullFeatures:t,layers:r}=e;return!(1!==r.length||t.length<2)&&(!this.curveUpdatesDisabled&&!!e.getEditorItemForLayer(r[0])?.supportsMergeFeaturesWorkflow)}getUpdating(){return!!this._sketchController?.updating}get viewGraphics(){return this._sketchController?.sketchGraphics??this.data.fullFeatures}async commit(){const{data:e,_formViewModel:t}=this;for(const r of e.fullFeatures)U(e.getPendingEditsForFeature(r),t.getValues(r));await super.commit()}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:a,viewModel:s}=o,n=new Set;function l(e){const t=m(s.editorItems,e);t&&n.add(t)}a?.length?a.forEach(({layer:e})=>l(e)):i?.length&&(F().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const d=Array.from(n),u=new w({data:new p({...o,editorItems:d}),onCommit:M(e.applyEdits)});return u._set("steps",E()),u}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}async enter(){}exit(e){}async reset(){}async save(){const{formViewModel:e}=this;await e.submit(),e.valid&&await super.save()}async start(){await super.start(),await s(()=>!this.updating);const e=this._sketchController;if(e)return e;const{data:t}=this,{view:r}=t.viewModel,o=_(t);return!r||u(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(v)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(_(e)),o=r?.layerInfo?[r.layerInfo]:null,i=new c({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone,layerInfos:o});this._formViewModel=i,this.addHandles(i.on("value-change",t=>{for(const r of t.features)e.getPendingEditsForFeature(r)?.setAttribute(t.fieldName,t.value);this._sketchController?.notifyAttributesChanged(t)}));const a=t=>{e.getPendingEditsForFeature(t.feature)?.setAttachmentEdits(t.attachmentEdits)};this.addHandles(i.on("attachments-change",a))}async _initializeHighlights(e,t,r){const o=await f(r,t);this.addHandles(o.highlight(e),v)}_initializeSketchController(e,t,r){const{data:o}=this,i=new y({defaultUpdateOptions:this.sketchUpdateOptions,sourceLayer:t,view:r,features:e,useLegacyCreateTools:o.viewModel.useLegacyCreateTools,onGeometriesUpdated:e=>{const t=[];for(const{feature:r,geometry:i}of e)o.getPendingEditsForFeature(r)?.updateGeometry(i),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},onVisualVariableAttributesUpdated:()=>{F().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")}});this._sketchController=i}_initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=_(t);if(u(o))return;const i=t.getEditorItemForLayer(o);i?.capabilities.update.geometry&&!this.curveUpdatesDisabled&&this._initializeSketchController(e,o,r)}};e([n()],b.prototype,"curveUpdatesDisabled",null),e([n()],b.prototype,"features",null),e([n()],b.prototype,"featureInfos",null),e([n()],b.prototype,"formViewModel",null),e([n()],b.prototype,"hasInvalidFormTemplate",null),e([n()],b.prototype,"hasPendingEdits",null),e([n()],b.prototype,"parent",null),e([n()],b.prototype,"saveActionLabel",null),e([n()],b.prototype,"selectedFeature",null),e([n()],b.prototype,"sketchUpdateOptions",null),e([n()],b.prototype,"sketchViewModel",null),e([n()],b.prototype,"supportsMergeFeaturesWorkflow",null),e([n()],b.prototype,"type",void 0),e([n()],b.prototype,"viewGraphics",null),e([n()],b.prototype,"_formViewModel",void 0),e([n()],b.prototype,"_sketchController",void 0),b=w=e([l("esri.widgets.Editor.UpdateFeaturesWorkflow")],b);const k=b;function E(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function M(e){return async r=>{const o=_(r),i=[],a=[],s=[],n=[],l=[];for(const e of r.fullFeatures){const o=r.getPendingEditsForFeature(e),d=o?.stagedForDelete;if(!o?.modified&&!d)continue;const u=e.clone();if(!o?.attributesModified||d){const t=e.sourceLayer;if(!t){F().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(u.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&u.setAttribute(r,e.getAttribute(r))}}if(o?.geometryModified&&!d||(u.geometry=null),d?a.push(u):(o?.attributesModified||o?.geometryModified)&&i.push(u),o?.attachmentEdits)for(const e of o.attachmentEdits)t(s,e.add),t(n,e.update),t(l,e.delete)}if(i.length+a.length+s.length+n.length+l.length===0)return void F().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const d={updateFeatures:i.length>0?i:void 0,deleteFeatures:a.length>0?a:void 0,addAttachments:s.length>0?s:void 0,updateAttachments:n.length>0?n:void 0,deleteAttachments:l.length>0?l:void 0},u=o.capabilities?.editing.supportsGlobalId&&(s.length>0||n.length>0||l.length>0)?{globalIdUsed:!0}:void 0;await e(o,d,u)}}function _(e){if(e.layers.length>1)throw new g;return e.layers[0]}function U(e,t){if(!e||!e.feature)return;const{attributes:r}=e.feature;Object.keys(t).some(e=>t[e]!==r[e])&&e.updateAttributes(t)}export{k as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import o from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as w,sync as h,on as f,when as g}from"../../core/reactiveUtils.js";import{last as v}from"../../core/SetUtils.js";import{property as k,subclass as m}from"../../core/accessorSupport/decorators.js";import{getGraphicLayer as y}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as W}from"../../layers/support/editableLayers.js";import{isFeatureLayer as A,isSubtypeSublayer as _,isSubtypeGroupLayer as b,isTable as S}from"../../layers/support/layerUtils.js";import{findUtilityNetwork as C,isGraphicForRelatableFeatureSupportedLayer as M}from"../../popup/support/featureUtils.js";import{createFeatureServices as F}from"../../rest/featureService/utils.js";import R from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as U}from"../../views/input/InputManager.js";import{temporaryHighlightName as E}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import j from"./MergeFeaturesWorkflow.js";import V from"./SplitFeatureWorkflow.js";import P from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as L}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as N}from"./UpdateRecordWorkflow.js";import O from"./UpdateWorkflowData.js";import T from"./Workflow.js";import{isFeatureFormViewModel as x,findEditorItemForLayer as D,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as z,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as G,isParentWorkflow as Q,findEditorItemForLayerOrThrow as $,createWorkflowSteps as B,fetchCandidates as J,isUpdateFeaturesWorkflowOptions as K,toFeatureInfos as X,isMergeWorkflowOptions as Y,isSplitWorkflowOptions as Z}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as ee}from"./support/errors.js";var te;let ie=te=class extends T{constructor(e){super(e),this._workflowStack=new p(v),this._sketchStack=new p(v),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!x(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!A(i?.sourceLayer)&&!_(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}getUpdating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||x(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>D(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get noticeMessage(){return this.activeWorkflow?.noticeMessage}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}get curveResizeDisabled(){return this.activeWorkflow?.curveResizeDisabled??!1}get curveUpdatesDisabled(){return this.activeWorkflow?.curveUpdatesDisabled??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(x(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:o,...a}=e,r=new te({data:new O({applyEditsCallback:i,applyEditsFeatureServiceCallback:o,...a}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(e){const{formViewModel:t}=this;if(t&&(t.submit(),!t.submittable||x(t)&&ae(t)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:i}=this;if(await(i?.commit(e)),!z(i))return void await this._popWorkflowAndReconcile();this._popWorkflow();const o=this._workflowStack.peek();if(o&&o===i?.parent&&(await o.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new o("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:a})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:a})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:a})}finally{i.resolve()}}async startAddAssociation(e,t,i){const a=this._makeUpdatingResolver();try{const o=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(o)}catch(r){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{a.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new o("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=G(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new o("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!x(e))throw new o("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:a,viewModel:r}=this.data,{sourceLayer:s}=i,n=_(s)&&s.parent?s.parent:s,l=F([n]),d=l.values().next().value?.featureService;if(!d)throw new o("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=C(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new o("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await a(d,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const o of e)i(t,o)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!x(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:a,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!W(t))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=Q(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:a,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!W(i)||b(i))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:a}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=a.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t={}){const i=S(e.sourceLayer)?N:L,{applyEditsCallback:o,applyEditsFeatureServiceCallback:a,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=Q(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:o,applyEditsFeatureService:a,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await u(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data,r=P.create({applyEdits:i,applyEditsFeatureService:o,featureInfos:e,viewModel:a,...t});return await u(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=Q(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=x(d)?d.activeAssociationInput:null;if(!c)throw new o("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await a.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await u(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data;ee(e);const r=$(this.data.viewModel.editorItems,y(e[0])),s=Q(this.activeWorkflow)?this.activeWorkflow:void 0,n=await j.create({applyEdits:i,applyEditsFeatureService:o,editorItem:r,features:e,parent:s,viewModel:a,...t});return await u(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:a,snappingManager:r,viewModel:s}=this.data,n=Q(this.activeWorkflow)?this.activeWorkflow:void 0,l=$(s.editorItems,e.sourceLayer),d=V.create({applyEdits:i,applyEditsFeatureService:o,editorItem:l,feature:e,parent:n,sketchOptions:a,snappingManager:r,viewModel:s,...t});return await u(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const o of t){const t=e(o).finally(()=>o.destroy());this._updatingHandles.consumePromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:o}=e;if(!M(t))return;const a=i.relationships?.find(e=>e.id===o);if(!a)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===a.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;a.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===o);if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=oe(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=oe(i,a);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new o("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflowAndReconcile(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,a=await(e?.start()),r=i.peek();a?(r?.exit(),i.push(a)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new o("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:o,failureCount:a}=await this._reconcileWorkflowStack();return{activeWorkflow:o,failureCount:a+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!S(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return B(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,o=i.viewModel.view;o.activeTool=null;let r=null;e.addHandles(a(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const c=o.on("immediate-click",async a=>{const s=Promise.withResolvers();e._updatingHandles.consumePromise(s.promise);try{t.location=a.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const c=await a.defer(()=>new Promise((e,t)=>{n(r?.signal,()=>t(l())),e(J(s,o,a,r?.signal))}));if(d(r),i.candidates=c.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(a.stopPropagation(),1===i.candidates.length){const{rootFeatures:o}=i;o.removeAll(),o.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},U.TOOL),p=g(()=>null!=o.activeTool,()=>e.cancel({force:!0}),{once:!0});o.focus(),e.addHandles([c,p],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const o=new R({view:t,highlightName:E});e.addHandles([f(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>o.remove(e)),e.forEach(e=>o.add(e))},h),a(()=>o.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await re(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=c(async()=>{await u(()=>!e.updating),e.previous()});e.addHandles([w(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},h)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){r.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function oe(e,{keyField:t}){return e.getField(t)?.name??t}function ae(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function re(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(K(i)){const{rootFeatureInfos:a}=t,r=a.length>0?a:X(t.rootFeatures.toArray());if(0===r.length)throw new o("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:a}=t,r=a.getItemAt(0);if(!r)throw new o("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");Y(i)?await e.startMergingFeatures(a.toArray(),i.props):Z(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([k()],ie.prototype,"formViewModel",null),e([k()],ie.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([k()],ie.prototype,"activeSketchViewModel",null),e([k()],ie.prototype,"canDeleteAssociation",null),e([k()],ie.prototype,"activeWorkflow",null),e([k()],ie.prototype,"data",void 0),e([k()],ie.prototype,"hasPreviousStep",null),e([k()],ie.prototype,"hasUpdatableCandidates",null),e([k()],ie.prototype,"nestedWorkflowCount",null),e([k()],ie.prototype,"shouldShowAttachments",null),e([k()],ie.prototype,"shouldAllowAttachmentEditing",null),e([k()],ie.prototype,"hasPendingEdits",null),e([k()],ie.prototype,"helpMessage",null),e([k()],ie.prototype,"noticeMessage",null),e([k()],ie.prototype,"reliesOnOwnerAdminPrivileges",null),e([k()],ie.prototype,"hasInvalidFormTemplate",null),e([k()],ie.prototype,"curveResizeDisabled",null),e([k()],ie.prototype,"curveUpdatesDisabled",null),ie=te=e([m("esri.widgets.Editor.UpdateWorkflow")],ie);const se=ie;export{se as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import o from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,watch as w,sync as h,on as f,when as g}from"../../core/reactiveUtils.js";import{last as v}from"../../core/SetUtils.js";import{property as k,subclass as m}from"../../core/accessorSupport/decorators.js";import{getGraphicLayer as y}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as W}from"../../layers/support/editableLayers.js";import{isFeatureLayer as A,isSubtypeSublayer as _,isSubtypeGroupLayer as b,isTable as S}from"../../layers/support/layerUtils.js";import{findUtilityNetwork as C,isGraphicForRelatableFeatureSupportedLayer as M}from"../../popup/support/featureUtils.js";import{createFeatureServices as F}from"../../rest/featureService/utils.js";import R from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as U}from"../../views/input/InputManager.js";import{temporaryHighlightName as E}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import j from"./MergeFeaturesWorkflow.js";import V from"./SplitFeatureWorkflow.js";import P from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as L}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as N}from"./UpdateRecordWorkflow.js";import O from"./UpdateWorkflowData.js";import T from"./Workflow.js";import{isFeatureFormViewModel as x,findEditorItemForLayer as D,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as z,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as G,isParentWorkflow as Q,findEditorItemForLayerOrThrow as $,createWorkflowSteps as B,fetchCandidates as J,isUpdateFeaturesWorkflowOptions as K,toFeatureInfos as X,isMergeWorkflowOptions as Y,isSplitWorkflowOptions as Z}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as ee}from"./support/errors.js";var te;let ie=te=class extends T{constructor(e){super(e),this._workflowStack=new p(v),this._sketchStack=new p(v),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!x(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!A(i?.sourceLayer)&&!_(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}getUpdating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||x(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>D(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get noticeMessage(){return this.activeWorkflow?.noticeMessage}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}get curveResizeDisabled(){return this.activeWorkflow?.curveResizeDisabled??!1}get curveUpdatesDisabled(){return this.activeWorkflow?.curveUpdatesDisabled??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(x(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:o,...a}=e,r=new te({data:new O({applyEditsCallback:i,applyEditsFeatureServiceCallback:o,...a}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(e){const{formViewModel:t}=this;if(t&&(await t.submit(),!t.submittable||x(t)&&ae(t)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:i}=this;if(await(i?.commit(e)),!z(i))return void await this._popWorkflowAndReconcile();this._popWorkflow();const o=this._workflowStack.peek();if(o&&o===i?.parent&&(await o.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new o("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:a})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:a})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:a})}finally{i.resolve()}}async startAddAssociation(e,t,i){const a=this._makeUpdatingResolver();try{const o=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(o)}catch(r){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{a.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new o("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=G(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new o("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!x(e))throw new o("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:a,viewModel:r}=this.data,{sourceLayer:s}=i,n=_(s)&&s.parent?s.parent:s,l=F([n]),d=l.values().next().value?.featureService;if(!d)throw new o("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=C(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new o("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await a(d,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const o of e)i(t,o)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!x(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:a,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!W(t))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=Q(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:a,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!W(i)||b(i))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:a}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=a.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t={}){const i=S(e.sourceLayer)?N:L,{applyEditsCallback:o,applyEditsFeatureServiceCallback:a,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=Q(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:o,applyEditsFeatureService:a,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await u(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data,r=P.create({applyEdits:i,applyEditsFeatureService:o,featureInfos:e,viewModel:a,...t});return await u(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=Q(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=x(d)?d.activeAssociationInput:null;if(!c)throw new o("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await a.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await u(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data;ee(e);const r=$(this.data.viewModel.editorItems,y(e[0])),s=Q(this.activeWorkflow)?this.activeWorkflow:void 0,n=await j.create({applyEdits:i,applyEditsFeatureService:o,editorItem:r,features:e,parent:s,viewModel:a,...t});return await u(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:a,snappingManager:r,viewModel:s}=this.data,n=Q(this.activeWorkflow)?this.activeWorkflow:void 0,l=$(s.editorItems,e.sourceLayer),d=V.create({applyEdits:i,applyEditsFeatureService:o,editorItem:l,feature:e,parent:n,sketchOptions:a,snappingManager:r,viewModel:s,...t});return await u(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const o of t){const t=e(o).finally(()=>o.destroy());this._updatingHandles.consumePromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:o}=e;if(!M(t))return;const a=i.relationships?.find(e=>e.id===o);if(!a)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===a.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;a.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===o);if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=oe(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=oe(i,a);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new o("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflowAndReconcile(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,a=await(e?.start()),r=i.peek();a?(r?.exit(),i.push(a)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new o("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:o,failureCount:a}=await this._reconcileWorkflowStack();return{activeWorkflow:o,failureCount:a+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!S(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return B(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,o=i.viewModel.view;o.activeTool=null;let r=null;e.addHandles(a(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const c=o.on("immediate-click",async a=>{const s=Promise.withResolvers();e._updatingHandles.consumePromise(s.promise);try{t.location=a.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const c=await a.defer(()=>new Promise((e,t)=>{n(r?.signal,()=>t(l())),e(J(s,o,a,r?.signal))}));if(d(r),i.candidates=c.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(a.stopPropagation(),1===i.candidates.length){const{rootFeatures:o}=i;o.removeAll(),o.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},U.TOOL),p=g(()=>null!=o.activeTool,()=>e.cancel({force:!0}),{once:!0});o.focus(),e.addHandles([c,p],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const o=new R({view:t,highlightName:E});e.addHandles([f(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>o.remove(e)),e.forEach(e=>o.add(e))},h),a(()=>o.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await re(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=c(async()=>{await u(()=>!e.updating),e.previous()});e.addHandles([w(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},h)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){r.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function oe(e,{keyField:t}){return e.getField(t)?.name??t}function ae(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function re(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(K(i)){const{rootFeatureInfos:a}=t,r=a.length>0?a:X(t.rootFeatures.toArray());if(0===r.length)throw new o("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:a}=t,r=a.getItemAt(0);if(!r)throw new o("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");Y(i)?await e.startMergingFeatures(a.toArray(),i.props):Z(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([k()],ie.prototype,"formViewModel",null),e([k()],ie.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([k()],ie.prototype,"activeSketchViewModel",null),e([k()],ie.prototype,"canDeleteAssociation",null),e([k()],ie.prototype,"activeWorkflow",null),e([k()],ie.prototype,"data",void 0),e([k()],ie.prototype,"hasPreviousStep",null),e([k()],ie.prototype,"hasUpdatableCandidates",null),e([k()],ie.prototype,"nestedWorkflowCount",null),e([k()],ie.prototype,"shouldShowAttachments",null),e([k()],ie.prototype,"shouldAllowAttachmentEditing",null),e([k()],ie.prototype,"hasPendingEdits",null),e([k()],ie.prototype,"helpMessage",null),e([k()],ie.prototype,"noticeMessage",null),e([k()],ie.prototype,"reliesOnOwnerAdminPrivileges",null),e([k()],ie.prototype,"hasInvalidFormTemplate",null),e([k()],ie.prototype,"curveResizeDisabled",null),e([k()],ie.prototype,"curveUpdatesDisabled",null),ie=te=e([m("esri.widgets.Editor.UpdateWorkflow")],ie);const se=ie;export{se as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{stripHTML as i}from"../../../core/string.js";import{property as s,subclass as o}from"../../../core/accessorSupport/decorators.js";import r from"../UtilityNetworkAssociationInput.js";import{AssociationDetails as a}from"./AssociationDetails.js";import n from"./VisibleElements.js";import{loadCalciteComponents as l}from"../../support/componentsUtils.js";import{globalCss as c}from"../../support/globalCss.js";import{Heading as d}from"../../support/Heading.js";import{tsx as u,tsxFragment as p,messageBundle as m}from"../../support/widget.js";import h from"../../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import y from"../../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as f}from"../../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as g}from"../../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as F}from"../../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";const _="esri-feature-form-utility-network-association-list",v={base:_,header:`${_}__header`,headingContent:`${_}__heading-content`,listContainer:`${_}__list-container`};let L=class extends y{constructor(e,t){super(e,t),this._isLoadingSelectFeature=!1,this._numFilteredItems=0,this.associationInput=null,this.headingLevel=5,this.messagesFeatureForm=null,this.onSelectLayer=()=>{},this.onSelectFeature=async()=>{},this.onAddAssociation=()=>{},this.viewModel=new h,this.visibleElements=new n}initialize(){this.setUpObserver()}loadDependencies(){return l({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get _featureInfosPage(){return this._featureInfos.slice(0,this.endIndex)}get _featureInfos(){const{associationInput:e}=this;return e?.associatedLayer?e.associatedFeatureInfos.get(e.associatedLayer)?.toArray()??[]:[]}get associatedFeatureCount(){return this._featureInfos.length}render(){const{associationInput:e}=this;if(!e)return u("div",{class:this.classes(v.base,c.widget)});const{associatedLayer:t}=e,{state:i}=this.viewModel;return u("div",{class:this.classes(v.base,c.widget)},"loading"===i||"querying"===i?this.renderLoading():t?this._renderFeatureList(e,t):this._renderLayerList(e))}_renderLayerList(e){const{associatedFeatureInfos:t,editable:i}=e;return u("div",{class:v.listContainer},u("calcite-list",{label:this.messagesFeatureForm?.associations.associatedLayers},Array.from(t.keys(),t=>this._renderLayerItem(e,t))),i?u("calcite-fab",{appearance:"outline-fill",icon:"plus",key:`${e.uid}-add-button`,kind:"neutral",text:this.messagesCommon.add,textEnabled:!0,onclick:()=>this.onAddAssociation({feature:e.feature,associationType:e.activeAssociationType,utilityNetwork:e.utilityNetwork})}):null)}_renderFeatureList(e,t){return u(p,null,this._renderHeader(e,t),u("div",{class:v.listContainer},this.renderFeatureCountWarning(),u("calcite-list",{afterCreate:()=>this._numFilteredItems=this.associatedFeatureCount,afterRemoved:()=>this._numFilteredItems=0,filterEnabled:!0,filterLabel:this.messagesFeature.associationFilterPlaceholder,filterPlaceholder:this.messagesFeature.associationFilterPlaceholder,key:`associated-features-list-${t.id}`,label:this.messagesFeatureForm?.associations.associatedFeatures,onCalciteListFilter:e=>this._numFilteredItems=e.currentTarget?.filteredItems.length},this._renderAssociatedFeatureListPage(),this.renderFeatureObserver())))}_renderLayerTitle(e){return e.title?u(d,{key:"title",level:this.headingLevel},u("div",{class:v.headingContent},u("calcite-icon",{icon:"layer"}),e.title)):null}_renderTotal(e){const i=t(this.messagesFeature?.numberRecords,{number:this._numFilteredItems});return u("div",{key:e.id},i)}_renderHeader(e,t){const{messagesFeatureForm:i}=this,{activeAssociationType:s,featureItem:o,feature:r}=e;return u("div",{class:v.header,key:"filter"},this.visibleElements.associationDetails?u(a,{associationType:s?.type,feature:r,heading:o?.label,messages:i.associations}):void 0,this._renderLayerTitle(t),this._renderTotal(t))}_renderAssociatedFeatureListPage(){const{_featureInfosPage:e}=this;return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this,i=e.feature.uid.toString();return g(e.association)?u("calcite-tooltip",{key:`tooltip-${i}`,overlayPositioning:"fixed",referenceElement:t.get(i),topLayerDisabled:this.topLayerDisabled},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const t=this.messagesCommon.untitled,s=e.title||t,o=e.feature.uid.toString();return u("calcite-list-item",{description:i(e.terminalName??""),key:`associated-feature-type-${o}`,label:i(s),onCalciteListItemSelect:()=>this._selectAssociation(e)},g(e.association)?this.renderConnectivityIcon(e.association.associationType,o):null,F(e.association)?u("calcite-chip",{label:f(e.association),scale:"s",slot:"content-end"},f(e.association)):null,u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderTooltips(e){return e.map(e=>this._renderItemTooltip(e))}_renderAssociatedFeatureList(e){return e.map(e=>this._renderAssociatedFeature(e))}_renderLayerItem(e,t){const{associatedFeatureInfos:i}=e,s=i.get(t)?.length??0;return u("calcite-list-item",{expanded:!0,key:`${t.id}-show-all`,label:t.title??this.messagesCommon.untitled,value:t.id,onCalciteListItemSelect:()=>{this._showAllAssociations(t)}},u("calcite-chip",{label:s.toString(),scale:"s",slot:"content-end"},s),u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}async _selectAssociation(e){this._isLoadingSelectFeature||(this._isLoadingSelectFeature=!0,await this.onSelectFeature({feature:e.feature,association:e.association}),this._isLoadingSelectFeature=!1)}_showAllAssociations(e){this.onSelectLayer({layer:e,associationInput:this.associationInput})}};e([s()],L.prototype,"_numFilteredItems",void 0),e([s()],L.prototype,"_featureInfosPage",null),e([s()],L.prototype,"_featureInfos",null),e([s()],L.prototype,"associatedFeatureCount",null),e([s({type:r})],L.prototype,"associationInput",void 0),e([s()],L.prototype,"headingLevel",void 0),e([s(),m("esri/widgets/FeatureForm/t9n/FeatureForm")],L.prototype,"messagesFeatureForm",void 0),e([s({constructOnly:!0})],L.prototype,"onSelectLayer",void 0),e([s({constructOnly:!0})],L.prototype,"onSelectFeature",void 0),e([s({constructOnly:!0})],L.prototype,"onAddAssociation",void 0),e([s({type:h})],L.prototype,"viewModel",void 0),e([s({type:n,nonNullable:!0})],L.prototype,"visibleElements",void 0),L=e([o("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.FeatureFormUtilityNetworkAssociationList")],L);const A=L;export{A as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{stripHTML as i}from"../../../core/string.js";import{property as s,subclass as o}from"../../../core/accessorSupport/decorators.js";import{AssociationDetails as r}from"./AssociationDetails.js";import a from"./VisibleElements.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{globalCss as l}from"../../support/globalCss.js";import{Heading as c}from"../../support/Heading.js";import{tsx as d,tsxFragment as u,messageBundle as p}from"../../support/widget.js";import m from"../../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import h from"../../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as y}from"../../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as f}from"../../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as F}from"../../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";const g="esri-feature-form-utility-network-association-list",_={base:g,header:`${g}__header`,headingContent:`${g}__heading-content`,listContainer:`${g}__list-container`};let v=class extends h{constructor(e,t){super(e,t),this._isLoadingSelectFeature=!1,this._numFilteredItems=0,this.associationInput=null,this.headingLevel=5,this.messagesFeatureForm=null,this.onSelectLayer=()=>{},this.onSelectFeature=async()=>{},this.onAddAssociation=()=>{},this.viewModel=new m,this.visibleElements=new a}initialize(){this.setUpObserver()}loadDependencies(){return n({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get _featureInfosPage(){return this._featureInfos.slice(0,this.endIndex)}get _featureInfos(){const e=this.associationInput?.associatedFeatures;return e?e.toArray():[]}get associatedFeatureCount(){return this._featureInfos.length}render(){const{associationInput:e}=this;if(!e)return d("div",{class:this.classes(_.base,l.widget)});const{associatedLayer:t}=e,{state:i}=this.viewModel;return d("div",{class:this.classes(_.base,l.widget)},"loading"===i||"querying"===i?this.renderLoading():t?this._renderFeatureList(e,t):this._renderLayerList(e))}_renderLayerList(e){const{associatedFeatureInfos:t,associationFeature:i,editable:s}=e;if(i)return d("div",{class:_.listContainer},d("calcite-list",{label:this.messagesFeatureForm?.associations.associatedLayers},Array.from(t.keys(),t=>this._renderLayerItem(e,t))),s?d("calcite-fab",{appearance:"outline-fill",icon:"plus",key:`${e.uid}-add-button`,kind:"neutral",text:this.messagesCommon.add,textEnabled:!0,onclick:()=>this.onAddAssociation({feature:i,associationType:e.activeAssociationType,utilityNetwork:e.utilityNetwork})}):null)}_renderFeatureList(e,t){return d(u,null,this._renderHeader(e,t),d("div",{class:_.listContainer},this.renderFeatureCountWarning(),d("calcite-list",{afterCreate:()=>this._numFilteredItems=this.associatedFeatureCount,afterRemoved:()=>this._numFilteredItems=0,filterEnabled:!0,filterLabel:this.messagesFeature.associationFilterPlaceholder,filterPlaceholder:this.messagesFeature.associationFilterPlaceholder,key:`associated-features-list-${t.id}`,label:this.messagesFeatureForm?.associations.associatedFeatures,onCalciteListFilter:e=>this._numFilteredItems=e.currentTarget?.filteredItems.length},this._renderAssociatedFeatureListPage(),this.renderFeatureObserver())))}_renderLayerTitle(e){return e.title?d(c,{key:"title",level:this.headingLevel},d("div",{class:_.headingContent},d("calcite-icon",{icon:"layer"}),e.title)):null}_renderTotal(e){const i=t(this.messagesFeature?.numberRecords,{number:this._numFilteredItems});return d("div",{key:e.id},i)}_renderHeader(e,t){const{messagesFeatureForm:i}=this,{activeAssociationType:s,associationFeature:o,featureItem:a}=e;if(o)return d("div",{class:_.header,key:"filter"},this.visibleElements.associationDetails?d(r,{associationType:s?.type,feature:o,heading:a?.label,messages:i.associations}):void 0,this._renderLayerTitle(t),this._renderTotal(t))}_renderAssociatedFeatureListPage(){const{_featureInfosPage:e}=this;return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this,i=e.feature.uid.toString();return f(e.association)?d("calcite-tooltip",{key:`tooltip-${i}`,overlayPositioning:"fixed",referenceElement:t.get(i),topLayerDisabled:this.topLayerDisabled},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const t=this.messagesCommon.untitled,s=e.title||t,o=e.feature.uid.toString();return d("calcite-list-item",{description:i(e.terminalName??""),key:`associated-feature-type-${o}`,label:i(s),onCalciteListItemSelect:()=>this._selectAssociation(e)},f(e.association)?this.renderConnectivityIcon(e.association.associationType,o):null,F(e.association)?d("calcite-chip",{label:y(e.association),scale:"s",slot:"content-end"},y(e.association)):null,d("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderTooltips(e){return e.map(e=>this._renderItemTooltip(e))}_renderAssociatedFeatureList(e){return e.map(e=>this._renderAssociatedFeature(e))}_renderLayerItem(e,t){const{associatedFeatureInfos:i}=e,s=i.get(t)?.length??0;return d("calcite-list-item",{expanded:!0,key:`${t.id}-show-all`,label:t.title??this.messagesCommon.untitled,value:t.id,onCalciteListItemSelect:()=>this.onSelectLayer({layer:t})},d("calcite-chip",{label:s.toString(),scale:"s",slot:"content-end"},s),d("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}async _selectAssociation(e){this._isLoadingSelectFeature||(this._isLoadingSelectFeature=!0,await this.onSelectFeature({feature:e.feature,association:e.association}),this._isLoadingSelectFeature=!1)}};e([s()],v.prototype,"_numFilteredItems",void 0),e([s()],v.prototype,"_featureInfosPage",null),e([s()],v.prototype,"_featureInfos",null),e([s()],v.prototype,"associatedFeatureCount",null),e([s()],v.prototype,"associationInput",void 0),e([s()],v.prototype,"headingLevel",void 0),e([s(),p("esri/widgets/FeatureForm/t9n/FeatureForm")],v.prototype,"messagesFeatureForm",void 0),e([s({constructOnly:!0})],v.prototype,"onSelectLayer",void 0),e([s({constructOnly:!0})],v.prototype,"onSelectFeature",void 0),e([s({constructOnly:!0})],v.prototype,"onAddAssociation",void 0),e([s({type:m})],v.prototype,"viewModel",void 0),e([s({type:a,nonNullable:!0})],v.prototype,"visibleElements",void 0),v=e([o("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.FeatureFormUtilityNetworkAssociationList")],v);const L=v;export{L as default};
@@ -29,9 +29,9 @@ export default class RelationshipInput extends EditableInput<RelationshipElement
29
29
  /**
30
30
  * A string value indicating how to display related records within the relationship content. Currently, `list` is the only supported value.
31
31
  *
32
- * | Value | Description |
33
- * | ------ | ----------- |
34
- * | list | Shows a list of related records from the specified relationship. |
32
+ * | Value | Description |
33
+ * | ----- | ----------- |
34
+ * | list | Shows a list of related records from the specified relationship. |
35
35
  *
36
36
  * @default "list"
37
37
  */
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{watch as t,initial as r,on as i}from"../../core/reactiveUtils.js";import{property as l,subclass as s}from"../../core/accessorSupport/decorators.js";import{isSubtypeGroupLayer as a,getEffectiveLayerCapabilities as o}from"../../layers/support/layerUtils.js";import{isRelatableFeatureSupportedLayer as n}from"../../popup/support/featureUtils.js";import p from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import u from"./EditableInput.js";import{getComputedAttributes as d,parseFormTemplateString as h}from"./featureFormUtils.js";const y=3;let g=class extends u{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.addHandles([t(()=>({feature:this.feature,element:this.element,layer:this.layer}),e=>this._createRelationshipVM(e),r),i(()=>this.relatedLayer,"edits",()=>this._relationshipVM?.refresh())])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,relationship:r}=this;if(!r||!this.loaded||!this.relatedLayerAllowsAdds)return!1;if(this.allCategories?.length&&!this.activeCategory)return!1;const{cardinality:i,role:l}=r;return!("one-to-one"===i&&t>0)&&("many-to-many"!==i&&(!("one-to-many"===i&&"destination"===l&&t>0)&&e))}get activeCategory(){return this._relationshipVM?.activeCategory}set activeCategory(e){const t=this._relationshipVM;t&&(t.activeCategory=e)}get allCategories(){const{relatedLayer:e}=this,t=this._relationshipVM?.categories;if(!a(e))return;const r=(e.subtypes??[]).map(({code:e,name:r})=>{const i=t?.find(e=>e.name===r);return{name:r,count:i?.count??0,value:i?.value??e}});return r.length?r:null}get categories(){return this.showAllEnabled?this.allCategories:this.allCategories?.slice(0,this.displayCount)}get displayCount(){return this.element.displayCount??y}get displayType(){return this.element.displayType}get editable(){return!!this.relatedLayerAllowsEdits&&(this.evaluatedEditableExpression??!0)}get featureCount(){return this._relationshipVM?.featureCount??0}get label(){return this.activeCategory?.name?this.activeCategory.name:this.getFormattedLabel(this.element?.label)}get loaded(){return"loading"!==this._relationshipVM?.state}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get originHasValidKey(){return!(!this.relationship||!this.feature.getAttribute(this.relationship.keyField))}get relationship(){return this._relationshipVM?.relationship}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){const{_relationshipVM:e,timeZone:t}=this;if(!e?.relatedFeatures?.length||!e?.relatedLayer)return[];const{itemDescriptionFieldName:r,relatedFeatures:i,relatedLayer:l}=e,s=l&&"formTemplate"in l&&l.formTemplate?l.formTemplate.title:void 0;return i.map(e=>{let i;if(r){const s=e.getAttribute(r),a=l.fieldsIndex.get(r);if(a){const e=d({fields:[a],layer:l,values:[s],timeZone:t})[r];null!=e&&(i=e.toString())}}return{feature:e,description:i,title:s?h({attributes:e.attributes,label:s,layer:l,timeZone:t}):void 0}}).toArray()}get relatedLayer(){return this._relationshipVM?.relatedLayer}get relatedLayerIsTable(){return!!this.relatedLayer?.isTable}get relatedLayerAllowsAdds(){const{relatedLayer:e}=this;if(!e||!this.relatedLayerAllowsEdits)return!1;const t=o(e);return!!t?.operations?.supportsAdd}get relatedLayerAllowsEdits(){const{relatedLayer:e}=this;if(!e)return!1;const t=o(e);return!!t?.operations?.supportsEditing}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get showAllCategoriesVisible(){const e=this.allCategories?.length??0;return!this.showAllEnabled&&e>0&&e>this.displayCount}get visible(){const{relationship:e}=this;if(!e)return!1;const{cardinality:t}=e;return"many-to-many"!==t&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element)}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:i}=e;if(this._relationshipVM?.destroy(),!t||!r||!i)return;const{displayCount:l,map:s,orderByFields:a,relationshipId:o,showAllEnabled:u}=this;n(i)&&(this._relationshipVM=new p({graphic:t,displayCount:l,layer:i,map:s,orderByFields:a,relationshipId:o,showAllEnabled:u}))}};e([l()],g.prototype,"_relationshipVM",void 0),e([l()],g.prototype,"canAddRelatedFeature",null),e([l()],g.prototype,"activeCategory",null),e([l()],g.prototype,"allCategories",null),e([l()],g.prototype,"categories",null),e([l()],g.prototype,"displayCount",null),e([l()],g.prototype,"displayType",null),e([l()],g.prototype,"editable",null),e([l()],g.prototype,"featureCount",null),e([l()],g.prototype,"group",void 0),e([l()],g.prototype,"label",null),e([l()],g.prototype,"loaded",null),e([l()],g.prototype,"map",null),e([l()],g.prototype,"orderByFields",null),e([l()],g.prototype,"originHasValidKey",null),e([l()],g.prototype,"relationship",null),e([l()],g.prototype,"relationshipId",null),e([l()],g.prototype,"relatedFeatureInfos",null),e([l()],g.prototype,"relatedLayer",null),e([l()],g.prototype,"relatedLayerIsTable",null),e([l()],g.prototype,"relatedLayerAllowsAdds",null),e([l()],g.prototype,"relatedLayerAllowsEdits",null),e([l()],g.prototype,"showAllEnabled",null),e([l()],g.prototype,"showAllActionVisible",null),e([l()],g.prototype,"showAllCategoriesVisible",null),e([l({readOnly:!0})],g.prototype,"type",void 0),e([l()],g.prototype,"visible",null),e([l()],g.prototype,"updating",null),g=e([s("esri.widgets.FeatureForm.RelationshipInput")],g);const m=g;export{m as default};
2
+ import{__decorate as e}from"tslib";import{watch as t,initial as r,on as i}from"../../core/reactiveUtils.js";import{property as l,subclass as s}from"../../core/accessorSupport/decorators.js";import{isSubtypeGroupLayer as a,getEffectiveLayerCapabilities as o}from"../../layers/support/layerUtils.js";import{isRelatableFeatureSupportedLayer as n}from"../../popup/support/featureUtils.js";import p from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import u from"./EditableInput.js";import{getComputedAttributes as d,parseFormTemplateString as h}from"./featureFormUtils.js";const y=3;let g=class extends u{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.addHandles([t(()=>({feature:this.feature,element:this.element,layer:this.layer}),e=>this._createRelationshipVM(e),r),i(()=>this.relatedLayer,"edits",()=>this._relationshipVM?.refresh())])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,relationship:r}=this;if(!r||!this.loaded||!this.relatedLayerAllowsAdds)return!1;if(this.allCategories?.length&&!this.activeCategory)return!1;const{cardinality:i,role:l}=r;return!("one-to-one"===i&&t>0)&&("many-to-many"!==i&&(!("one-to-many"===i&&"destination"===l&&t>0)&&e))}get activeCategory(){return this._relationshipVM?.activeCategory}set activeCategory(e){const t=this._relationshipVM;t&&(t.activeCategory=e)}get allCategories(){const{relatedLayer:e}=this,t=this._relationshipVM?.categories;if(!a(e))return;const r=(e.subtypes??[]).map(({code:e,name:r})=>{const i=t?.find(e=>e.name===r);return{name:r,count:i?.count??0,value:i?.value??e}});return r.length?r:null}get categories(){return this.showAllEnabled?this.allCategories:this.allCategories?.slice(0,this.displayCount)}get displayCount(){return this.element.displayCount??y}get displayType(){return this.element.displayType}get editable(){return!!this.relatedLayerAllowsEdits&&(this.evaluatedEditableExpression??!0)}get featureCount(){return this._relationshipVM?.featureCount??0}get label(){return this.activeCategory?.name?this.activeCategory.name:this.getFormattedLabel(this.element?.label)}get loaded(){return"loading"!==this._relationshipVM?.state}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get originHasValidKey(){return!!this.relationship&&null!=this.feature.getAttribute(this.relationship.keyField)}get relationship(){return this._relationshipVM?.relationship}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){const{_relationshipVM:e,timeZone:t}=this;if(!e?.relatedFeatures?.length||!e?.relatedLayer)return[];const{itemDescriptionFieldName:r,relatedFeatures:i,relatedLayer:l}=e,s=l&&"formTemplate"in l&&l.formTemplate?l.formTemplate.title:void 0;return i.map(e=>{let i;if(r){const s=e.getAttribute(r),a=l.fieldsIndex.get(r);if(a){const e=d({fields:[a],layer:l,values:[s],timeZone:t})[r];null!=e&&(i=e.toString())}}return{feature:e,description:i,title:s?h({attributes:e.attributes,label:s,layer:l,timeZone:t}):void 0}}).toArray()}get relatedLayer(){return this._relationshipVM?.relatedLayer}get relatedLayerIsTable(){return!!this.relatedLayer?.isTable}get relatedLayerAllowsAdds(){const{relatedLayer:e}=this;if(!e||!this.relatedLayerAllowsEdits)return!1;const t=o(e);return!!t?.operations?.supportsAdd}get relatedLayerAllowsEdits(){const{relatedLayer:e}=this;if(!e)return!1;const t=o(e);return!!t?.operations?.supportsEditing}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get showAllCategoriesVisible(){const e=this.allCategories?.length??0;return!this.showAllEnabled&&e>0&&e>this.displayCount}get visible(){const{relationship:e}=this;if(!e)return!1;const{cardinality:t}=e;return"many-to-many"!==t&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element)}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:i}=e;if(this._relationshipVM?.destroy(),!t||!r||!i)return;const{displayCount:l,map:s,orderByFields:a,relationshipId:o,showAllEnabled:u}=this;n(i)&&(this._relationshipVM=new p({graphic:t,displayCount:l,layer:i,map:s,orderByFields:a,relationshipId:o,showAllEnabled:u}))}};e([l()],g.prototype,"_relationshipVM",void 0),e([l()],g.prototype,"canAddRelatedFeature",null),e([l()],g.prototype,"activeCategory",null),e([l()],g.prototype,"allCategories",null),e([l()],g.prototype,"categories",null),e([l()],g.prototype,"displayCount",null),e([l()],g.prototype,"displayType",null),e([l()],g.prototype,"editable",null),e([l()],g.prototype,"featureCount",null),e([l()],g.prototype,"group",void 0),e([l()],g.prototype,"label",null),e([l()],g.prototype,"loaded",null),e([l()],g.prototype,"map",null),e([l()],g.prototype,"orderByFields",null),e([l()],g.prototype,"originHasValidKey",null),e([l()],g.prototype,"relationship",null),e([l()],g.prototype,"relationshipId",null),e([l()],g.prototype,"relatedFeatureInfos",null),e([l()],g.prototype,"relatedLayer",null),e([l()],g.prototype,"relatedLayerIsTable",null),e([l()],g.prototype,"relatedLayerAllowsAdds",null),e([l()],g.prototype,"relatedLayerAllowsEdits",null),e([l()],g.prototype,"showAllEnabled",null),e([l()],g.prototype,"showAllActionVisible",null),e([l()],g.prototype,"showAllCategoriesVisible",null),e([l({readOnly:!0})],g.prototype,"type",void 0),e([l()],g.prototype,"visible",null),e([l()],g.prototype,"updating",null),g=e([s("esri.widgets.FeatureForm.RelationshipInput")],g);const m=g;export{m as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{IdentifiableMixin as e}from"../../core/Identifiable.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as i,initial as o,on as a}from"../../core/reactiveUtils.js";import{property as r,subclass as n}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as l}from"../../core/support/UpdatingHandles.js";import{isAssociatedFeatureSupportedLayer as p}from"../../popup/support/featureUtils.js";import u from"./EditableInput.js";import c from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";let d=class extends(e(u)){constructor(t){super(t),this.group=null,this.type="utilityNetworkAssociations",this.featureItem=null,this._updatingHandlesSetUp=new l,this.addHandles([i(()=>({feature:this.feature,element:this.element,layer:this.layer}),t=>this._createAssociationVM(t),o),i(()=>this.feature,()=>this._setFeatureItem()),i(()=>this.associatedLayer,(t,e)=>this._updateLayerEditHandle(t,e),o)])}destroy(){this._associationsVM?.destroy(),this._updatingHandlesSetUp.destroy()}get activeAssociationType(){return this._associationsVM?.activeAssociationType}get associatedFeatures(){const{associatedLayer:t}=this;if(t)return this.associatedFeatureInfos.get(t)}get associatedFeatureInfos(){const{_associationsVM:t}=this;if(!t?.associationFeatures?.size||!t?.utilityNetwork)return new Map;const{associationFeatures:e}=t,s=new Map;return e.forEach((t,e)=>{s.set(e,t)}),s}get associatedLayer(){return this._get("associatedLayer")}set associatedLayer(t){this._associationsVM.showAllEnabled=null!=t,this._set("associatedLayer",t)}get associationsViewModel(){return this._associationsVM}get canAddAssociation(){const{editable:t,utilityNetwork:e}=this;return!(!e||!this.loaded)&&t}get editable(){return this.evaluatedEditableExpression??!0}get featureCount(){return this._associationsVM?.featureCount??0}get viewModel(){return this._associationsVM}get loaded(){return"loading"!==this._associationsVM?.state&&!this._updatingHandlesSetUp.updating}get map(){return this._get("map")}set map(t){t&&this._associationsVM?.set("map",t),this._set("map",t)}get utilityNetwork(){return this._associationsVM?.utilityNetwork}get associationTypes(){return this._associationsVM?.associationTypes??this.element.associationTypes}get visible(){const{utilityNetwork:t}=this;return!!t&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element)}get updating(){return"loading"===this._associationsVM?.state||"querying"===this._associationsVM?.state}async refresh(){await s(this._associationsVM.refresh())}_updateLayerEditHandle(t,e){e&&"layerId"in e&&this.removeHandles(e?.layerId),p(t)&&this.addHandles(a(()=>t,"edits",()=>this.refresh()),t.layerId)}_createAssociationVM(t){const{feature:e,element:s,layer:i}=t;if(this._associationsVM?.destroy(),!e||!s||!i)return;const{map:o,associationTypes:a}=this;p(i)&&(this._associationsVM=new c({graphic:e,layer:i,map:o,associationTypes:a,source:"featureForm",title:this.label,description:this.description}))}_setFeatureItem(){this._updatingHandlesSetUp.consumePromise((async()=>{const{feature:t,layer:e}=this;t&&e&&"getFeatureTitle"in e&&(this.featureItem={feature:t,label:await e.getFeatureTitle(t)})})())}};t([r()],d.prototype,"_associationsVM",void 0),t([r()],d.prototype,"activeAssociationType",null),t([r()],d.prototype,"associatedFeatures",null),t([r()],d.prototype,"associatedFeatureInfos",null),t([r()],d.prototype,"associatedLayer",null),t([r()],d.prototype,"associationsViewModel",null),t([r()],d.prototype,"canAddAssociation",null),t([r()],d.prototype,"editable",null),t([r()],d.prototype,"featureCount",null),t([r()],d.prototype,"viewModel",null),t([r()],d.prototype,"group",void 0),t([r()],d.prototype,"loaded",null),t([r()],d.prototype,"map",null),t([r()],d.prototype,"utilityNetwork",null),t([r()],d.prototype,"associationTypes",null),t([r({readOnly:!0})],d.prototype,"type",void 0),t([r()],d.prototype,"visible",null),t([r()],d.prototype,"updating",null),t([r()],d.prototype,"featureItem",void 0),d=t([n("esri.widgets.FeatureForm.UtilityNetworkAssociationInput")],d);const y=d;export{y as default};
2
+ import{__decorate as t}from"tslib";import{IdentifiableMixin as e}from"../../core/Identifiable.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as i,initial as o,on as a}from"../../core/reactiveUtils.js";import{property as r,subclass as n}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as l}from"../../core/support/UpdatingHandles.js";import{isAssociatedFeatureSupportedLayer as p}from"../../popup/support/featureUtils.js";import u from"./EditableInput.js";import c from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";let d=class extends(e(u)){constructor(t){super(t),this.group=null,this.type="utilityNetworkAssociations",this.featureItem=null,this._updatingHandlesSetUp=new l,this.addHandles([i(()=>({feature:this.feature,element:this.element,layer:this.layer}),t=>this._createAssociationVM(t),o),i(()=>this.feature,()=>this._setFeatureItem()),i(()=>this.associatedLayer,(t,e)=>this._updateLayerEditHandle(t,e),o)])}destroy(){this._associationsVM?.destroy(),this._updatingHandlesSetUp.destroy()}get activeAssociationType(){return this._associationsVM?.activeAssociationType}get associatedFeatures(){const{associatedLayer:t}=this;if(t)return this.associatedFeatureInfos.get(t)}get associatedFeatureInfos(){const{_associationsVM:t}=this;if(!t?.associationFeatures?.size||!t?.utilityNetwork)return new Map;const{associationFeatures:e}=t,s=new Map;return e.forEach((t,e)=>{s.set(e,t)}),s}get associatedLayer(){return this._get("associatedLayer")}set associatedLayer(t){this._associationsVM.showAllEnabled=null!=t,this._set("associatedLayer",t)}get associationFeature(){return this.feature}get associationsViewModel(){return this._associationsVM}get canAddAssociation(){const{editable:t,utilityNetwork:e}=this;return!(!e||!this.loaded)&&t}get editable(){return this.evaluatedEditableExpression??!0}get featureCount(){return this._associationsVM?.featureCount??0}get viewModel(){return this._associationsVM}get loaded(){return"loading"!==this._associationsVM?.state&&!this._updatingHandlesSetUp.updating}get map(){return this._get("map")}set map(t){t&&this._associationsVM?.set("map",t),this._set("map",t)}get utilityNetwork(){return this._associationsVM?.utilityNetwork}get associationTypes(){return this._associationsVM?.associationTypes??this.element.associationTypes}get visible(){const{utilityNetwork:t}=this;return!!t&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element)}get updating(){return"loading"===this._associationsVM?.state||"querying"===this._associationsVM?.state}async refresh(){await s(this._associationsVM.refresh())}_updateLayerEditHandle(t,e){e&&"layerId"in e&&this.removeHandles(e?.layerId),p(t)&&this.addHandles(a(()=>t,"edits",()=>this.refresh()),t.layerId)}_createAssociationVM(t){const{feature:e,element:s,layer:i}=t;if(this._associationsVM?.destroy(),!e||!s||!i)return;const{map:o,associationTypes:a}=this;p(i)&&(this._associationsVM=new c({graphic:e,layer:i,map:o,associationTypes:a,source:"featureForm",title:this.label,description:this.description}))}_setFeatureItem(){this._updatingHandlesSetUp.consumePromise((async()=>{const{feature:t,layer:e}=this;t&&e&&"getFeatureTitle"in e&&(this.featureItem={feature:t,label:await e.getFeatureTitle(t)})})())}};t([r()],d.prototype,"_associationsVM",void 0),t([r()],d.prototype,"activeAssociationType",null),t([r()],d.prototype,"associatedFeatures",null),t([r()],d.prototype,"associatedFeatureInfos",null),t([r()],d.prototype,"associatedLayer",null),t([r()],d.prototype,"associationFeature",null),t([r()],d.prototype,"associationsViewModel",null),t([r()],d.prototype,"canAddAssociation",null),t([r()],d.prototype,"editable",null),t([r()],d.prototype,"featureCount",null),t([r()],d.prototype,"viewModel",null),t([r()],d.prototype,"group",void 0),t([r()],d.prototype,"loaded",null),t([r()],d.prototype,"map",null),t([r()],d.prototype,"utilityNetwork",null),t([r()],d.prototype,"associationTypes",null),t([r({readOnly:!0})],d.prototype,"type",void 0),t([r()],d.prototype,"visible",null),t([r()],d.prototype,"updating",null),t([r()],d.prototype,"featureItem",void 0),d=t([n("esri.widgets.FeatureForm.UtilityNetworkAssociationInput")],d);const y=d;export{y as default};