@arcgis/core 4.33.0-next.20250417 → 4.33.0-next.20250418

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 (62) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{afcb12bf54a5656f641e.js → 02176f84d6d57f1bc1c8.js} +2 -2
  3. package/assets/esri/core/workers/chunks/{afcb12bf54a5656f641e.js.LICENSE.txt → 02176f84d6d57f1bc1c8.js.LICENSE.txt} +1 -1
  4. package/assets/esri/core/workers/chunks/{2db5dd5638c93b0af102.js → 0a7cba60a5286ba621d4.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0c6f2808c57ff820bfdd.js.LICENSE.txt +1 -1
  6. package/assets/esri/core/workers/chunks/244d2196bac5ef279436.js +1 -0
  7. package/assets/esri/core/workers/chunks/32f2e0c88046b39916cc.js +1 -0
  8. package/assets/esri/core/workers/chunks/38f9ede26098eb03ca2d.js.LICENSE.txt +1 -1
  9. package/assets/esri/core/workers/chunks/{c616139a160eab9cd717.js → 4867a515ddbdab97cc61.js} +1 -1
  10. package/assets/esri/core/workers/chunks/5db336767959507c07e5.js.LICENSE.txt +1 -1
  11. package/assets/esri/core/workers/chunks/814d72abbfdd4552e4ec.js.LICENSE.txt +1 -1
  12. package/assets/esri/core/workers/chunks/93f792f5b94f3745b57d.js.LICENSE.txt +1 -1
  13. package/assets/esri/core/workers/chunks/ae13bd77a25ce8b54631.js +1 -0
  14. package/assets/esri/core/workers/chunks/c5d786166a5609b85276.js.LICENSE.txt +1 -1
  15. package/assets/esri/core/workers/chunks/d28e2c9bdf514236b011.js +1 -0
  16. package/assets/esri/core/workers/chunks/dbaa4b8d37aab40d7bd1.js.LICENSE.txt +1 -1
  17. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  18. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  19. package/chunks/BloomComposition.glsl.js +25 -19
  20. package/chunks/ChapmanAtmosphere.glsl.js +1 -1
  21. package/chunks/Fog.glsl.js +3 -3
  22. package/chunks/Haze.glsl.js +1 -1
  23. package/interfaces.d.ts +89 -0
  24. package/layers/VideoLayer.js +1 -1
  25. package/layers/support/domainUtils.js +1 -1
  26. package/layers/support/fieldUtils.js +1 -1
  27. package/layers/support/labelingInfo.js +1 -1
  28. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  29. package/layers/video/VideoController.js +1 -1
  30. package/layers/video/videoUtils.js +1 -1
  31. package/networks/UtilityNetwork.js +1 -1
  32. package/package.json +2 -2
  33. package/rest/featureService/FeatureService.js +1 -1
  34. package/rest/networks/support/NetworkElement.js +1 -1
  35. package/rest/networks/support/TelecomNetworkElement.js +5 -0
  36. package/support/revision.js +1 -1
  37. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  38. package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
  39. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  40. package/views/2d/layers/VideoLayerView2D.js +1 -1
  41. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  42. package/views/3d/environment/ChapmanAtmosphereTechniqueConfiguration.js +1 -1
  43. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +8 -8
  44. package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +1 -1
  45. package/views/3d/webgl-engine/effects/bloom/BloomCompositionTechniqueConfiguration.js +5 -0
  46. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  47. package/views/3d/webgl-engine/effects/haze/HazeTechniqueConfiguration.js +1 -1
  48. package/views/3d/webgl-engine/shaders/ToneMapping.glsl.js +20 -2
  49. package/widgets/Editor.js +1 -1
  50. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  51. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  52. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  53. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  54. package/widgets/OrientedImageryViewer.js +1 -1
  55. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  56. package/widgets/Slider/SliderViewModel.js +1 -1
  57. package/widgets/Slider.js +1 -1
  58. package/widgets/support/Selector2D/SelectionOperation.js +1 -1
  59. package/assets/esri/core/workers/chunks/3b8eee013d7ca156ef2d.js +0 -1
  60. package/assets/esri/core/workers/chunks/3ee505f9ddb671dcfa52.js +0 -1
  61. package/assets/esri/core/workers/chunks/7f36cffc6ed984b7e467.js +0 -1
  62. package/assets/esri/core/workers/chunks/efb0f3ec2344adcb24f3.js +0 -1
@@ -2,6 +2,24 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{glsl as e}from"../core/shaderModules/glsl.js";function o(o){o.code.add(e`vec3 tonemapACES(vec3 x) {
5
+ import{glsl as o}from"../core/shaderModules/glsl.js";var e;function r(r,a){switch(a.toneMapping){case e.SimpleExposure:r.code.add(o`vec3 tonemapSimpleExposure(vec3 x, float exposure) {
6
+ return vec3(1.0) - exp(-x * exposure);
7
+ }`);break;case e.KronosNeutral:r.code.add(o`vec3 tonemapKhronosNeutral(vec3 color, float exposure) {
8
+ const float startCompression = 0.8 - 0.04;
9
+ const float desaturation = 0.15;
10
+ color *= exposure;
11
+ float x = min( color.r, min( color.g, color.b ) );
12
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
13
+ color -= offset;
14
+ float peak = max( color.r, max( color.g, color.b ) );
15
+ if ( peak < startCompression ) {
16
+ return color;
17
+ }
18
+ float d = 1.0 - startCompression;
19
+ float newPeak = 1.0 - d * d / ( peak + d - startCompression );
20
+ color *= newPeak / peak;
21
+ float g = 1.0 - 1.0 / ( desaturation * ( peak - newPeak ) + 1.0 );
22
+ return mix( color, vec3( newPeak ), g );
23
+ }`);break;case e.ACES:r.code.add(o`vec3 tonemapACES(vec3 x) {
6
24
  return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
7
- }`)}export{o as ToneMapping};
25
+ }`)}}!function(o){o[o.ACES=0]="ACES",o[o.KronosNeutral=1]="KronosNeutral",o[o.SimpleExposure=2]="SimpleExposure",o[o.COUNT=3]="COUNT"}(e||(e={}));export{r as ToneMapping,e as ToneMappingFunction};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../core/support/UpdatingHandles.js";import h from"../views/interactive/sketch/SketchValueOptions.js";import p from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import w from"./Spinner.js";import _ from"./Widget.js";import{css as v}from"./Editor/css.js";import f from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as b,CreateFeaturesPanelContent as A}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as F,FeatureList as M}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as T,FooterActions as C}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as W,Notice as E}from"./Editor/components/Notices.js";import{loadPanelContentComponents as P,PanelContent as L,PanelContentSection as S,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as j,loadPanelToolbarComponents as U}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as D,Prompt as V}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as O,UpdateFeaturePanelContent as x}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as B,UploadDetails as N}from"./Editor/components/UploadDetails.js";import{VisibleElements as z,CreateToolVisibilityMap as H}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{globalCss as G}from"./support/globalCss.js";import{incrementHeadingLevel as q,Heading as Z}from"./support/Heading.js";import{renderItem as K}from"./support/ItemList.js";import{connectDelayedLoading as $}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as J}from"./support/decorators/messageBundle.js";import{vmEvent as Q}from"./support/decorators/vmEvent.js";import{tsx as X}from"./support/jsxFactory.js";import{substitute as Y}from"../intl/substitute.js";const ee=Symbol("sketch-setup-handles");let te=class extends _{constructor(e,t){super(e,t),this._featureForm=new u,this._sketchToolbar=null,this._attachments=new p({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?X("calcite-icon",{class:v.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new w,this._loading=!1,this._updatingHandles=new m,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new f,this.visibleElements=new k,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?X("div",{class:v.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>X("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return X("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?X("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?X(j,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>q(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:Y(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),$({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([R({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),b(),F(),T(),W(),P(),U(),D(),O(),B()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(v.base,G.widget,G.panel);if(!t)return X("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return X("div",{class:s,key:"base"},e.flow?X("calcite-flow",{inert:!!this._prompt,key:"flow"},a):a,this._prompt?X(V,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return X("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return X(t,{heading:s.selectTemplate,key:"templates-panel",...e},X(L,{key:"feature-templates"},X(S,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?X(t,{heading:o.createFeatures,key:"upload-details-panel",...e},X(N,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return X(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?X(x,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):X(A,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return X(t,{heading:s.editFeature,key:"update-feature-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return X(t,{heading:n,key:"viewing-associated-layers-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return t?X(s,{heading:r,key:"add-association-select-feature",...e},X(L,{key:"select-feature"},X(S,null,t.render())),X(C,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&(t.viewModel.featureSpatialItems.length&&t.highlightHelper?.removeAll(),o.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):X(s,{heading:r,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this;if(!t)return null;const a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return X(s,{heading:r,key:"add-association",...e},X(L,{key:"add-association-content"},X(S,null,t.render())),X(C,{buttons:[{label:i.add,disabled:n||!a.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?X(E,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return X(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),X(C,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?X(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?X(C,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return X(t,{heading:s.widgetLabel,key:"landing-panel",...e},X(L,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?X(S,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?X(S,{key:"create-actions"},this._renderCreateActions()):null]:X(I,{key:"no-content"},s.noEditableLayers)),a?X("div",{class:v.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return X("div",{class:v.updateActions,key:"update-actions"},X(Z,{level:q(this.headingLevel)},e.editFeatures),X("calcite-list",{class:v.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},K({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return X("div",{key:"create-actions"},X(Z,{level:q(this.headingLevel)},this.messages.createFeatures),X("div",{class:v.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=Y(this.messages.multipleFeaturesTemplate,{total:i.length});return X(t,{heading:a,key:"feature-list",...e},X(M,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(ee);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new z({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new H({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],ee)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],te.prototype,"_featureForm",void 0),e([c()],te.prototype,"_sketchToolbar",void 0),e([c()],te.prototype,"_attachments",void 0),e([c()],te.prototype,"_associationItemList",void 0),e([c()],te.prototype,"_associationSettings",void 0),e([c()],te.prototype,"_featureTemplates",void 0),e([c()],te.prototype,"_filterText",void 0),e([c()],te.prototype,"_prompt",void 0),e([c()],te.prototype,"_spinner",void 0),e([c()],te.prototype,"_deleteButtonCommonInfo",null),e([c()],te.prototype,"_loading",void 0),e([c({readOnly:!0})],te.prototype,"activeWorkflow",null),e([c()],te.prototype,"headingLevel",void 0),e([c()],te.prototype,"hideTemplatesForInactiveLayers",null),e([c()],te.prototype,"icon",null),e([c()],te.prototype,"label",null),e([c()],te.prototype,"labelOptions",null),e([c()],te.prototype,"layerInfos",null),e([c(),J("esri/widgets/Editor/t9n/Editor")],te.prototype,"messages",void 0),e([c(),J("esri/t9n/common")],te.prototype,"messagesCommon",void 0),e([c(),J("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],te.prototype,"messagesTemplates",void 0),e([c(),J("esri/widgets/Feature/t9n/Feature")],te.prototype,"messagesFeature",void 0),e([c()],te.prototype,"snappingOptions",null),e([c()],te.prototype,"tooltipOptions",null),e([c()],te.prototype,"supportingWidgetDefaults",void 0),e([c({type:h,nonNullable:!0})],te.prototype,"valueOptions",null),e([c()],te.prototype,"view",null),e([c(),Q(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],te.prototype,"viewModel",void 0),e([c({type:k,nonNullable:!0})],te.prototype,"visibleElements",void 0),e([c()],te.prototype,"_helpMessage",null),te=e([d("esri.widgets.Editor")],te);const se=te;export{se as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../core/support/UpdatingHandles.js";import h from"../views/interactive/sketch/SketchValueOptions.js";import p from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import w from"./Spinner.js";import _ from"./Widget.js";import{css as v}from"./Editor/css.js";import f from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as b,CreateFeaturesPanelContent as A}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as F,FeatureList as M}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as T,FooterActions as C}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as W,Notice as E}from"./Editor/components/Notices.js";import{loadPanelContentComponents as P,PanelContent as L,PanelContentSection as S,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as j,loadPanelToolbarComponents as U}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as D,Prompt as V}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as O,UpdateFeaturePanelContent as x}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as B,UploadDetails as N}from"./Editor/components/UploadDetails.js";import{VisibleElements as z,CreateToolVisibilityMap as H}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{globalCss as G}from"./support/globalCss.js";import{incrementHeadingLevel as q,Heading as Z}from"./support/Heading.js";import{renderItem as K}from"./support/ItemList.js";import{connectDelayedLoading as $}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as J}from"./support/decorators/messageBundle.js";import{vmEvent as Q}from"./support/decorators/vmEvent.js";import{tsx as X}from"./support/jsxFactory.js";import{substitute as Y}from"../intl/substitute.js";const ee=Symbol("sketch-setup-handles");let te=class extends _{constructor(e,t){super(e,t),this._featureForm=new u,this._sketchToolbar=null,this._attachments=new p({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?X("calcite-icon",{class:v.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new w,this._loading=!1,this._updatingHandles=new m,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new f,this.visibleElements=new k,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?X("div",{class:v.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>X("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return X("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?X("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?X(j,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>q(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:Y(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),$({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([R({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),b(),F(),T(),W(),P(),U(),D(),O(),B()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(v.base,G.widget,G.panel);if(!t)return X("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return X("div",{class:s,key:"base"},e.flow?X("calcite-flow",{inert:!!this._prompt,key:"flow"},a):a,this._prompt?X(V,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return X("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return X(t,{heading:s.selectTemplate,key:"templates-panel",...e},X(L,{key:"feature-templates"},X(S,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?X(t,{heading:o.createFeatures,key:"upload-details-panel",...e},X(N,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return X(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?X(x,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):X(A,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return X(t,{heading:s.editFeature,key:"update-feature-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return X(t,{heading:n,key:"viewing-associated-layers-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return t?X(s,{heading:r,key:"add-association-select-feature",...e},X(L,{key:"select-feature"},X(S,null,t.render())),X(C,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&(a?.reset(),o.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):X(s,{heading:r,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this;if(!t)return null;const a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return X(s,{heading:r,key:"add-association",...e},X(L,{key:"add-association-content"},X(S,null,t.render())),X(C,{buttons:[{label:i.add,disabled:n||!a.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?X(E,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return X(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),X(C,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?X(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?X(C,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return X(t,{heading:s.widgetLabel,key:"landing-panel",...e},X(L,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?X(S,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?X(S,{key:"create-actions"},this._renderCreateActions()):null]:X(I,{key:"no-content"},s.noEditableLayers)),a?X("div",{class:v.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return X("div",{class:v.updateActions,key:"update-actions"},X(Z,{level:q(this.headingLevel)},e.editFeatures),X("calcite-list",{class:v.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},K({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return X("div",{key:"create-actions"},X(Z,{level:q(this.headingLevel)},this.messages.createFeatures),X("div",{class:v.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=Y(this.messages.multipleFeaturesTemplate,{total:i.length});return X(t,{heading:a,key:"feature-list",...e},X(M,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(ee);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new z({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new H({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],ee)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],te.prototype,"_featureForm",void 0),e([c()],te.prototype,"_sketchToolbar",void 0),e([c()],te.prototype,"_attachments",void 0),e([c()],te.prototype,"_associationItemList",void 0),e([c()],te.prototype,"_associationSettings",void 0),e([c()],te.prototype,"_featureTemplates",void 0),e([c()],te.prototype,"_filterText",void 0),e([c()],te.prototype,"_prompt",void 0),e([c()],te.prototype,"_spinner",void 0),e([c()],te.prototype,"_deleteButtonCommonInfo",null),e([c()],te.prototype,"_loading",void 0),e([c({readOnly:!0})],te.prototype,"activeWorkflow",null),e([c()],te.prototype,"headingLevel",void 0),e([c()],te.prototype,"hideTemplatesForInactiveLayers",null),e([c()],te.prototype,"icon",null),e([c()],te.prototype,"label",null),e([c()],te.prototype,"labelOptions",null),e([c()],te.prototype,"layerInfos",null),e([c(),J("esri/widgets/Editor/t9n/Editor")],te.prototype,"messages",void 0),e([c(),J("esri/t9n/common")],te.prototype,"messagesCommon",void 0),e([c(),J("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],te.prototype,"messagesTemplates",void 0),e([c(),J("esri/widgets/Feature/t9n/Feature")],te.prototype,"messagesFeature",void 0),e([c()],te.prototype,"snappingOptions",null),e([c()],te.prototype,"tooltipOptions",null),e([c()],te.prototype,"supportingWidgetDefaults",void 0),e([c({type:h,nonNullable:!0})],te.prototype,"valueOptions",null),e([c()],te.prototype,"view",null),e([c(),Q(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],te.prototype,"viewModel",void 0),e([c({type:k,nonNullable:!0})],te.prototype,"visibleElements",void 0),e([c()],te.prototype,"_helpMessage",null),te=e([d("esri.widgets.Editor")],te);const se=te;export{se as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{watch as t,initial as r,on as i}from"../../../core/reactiveUtils.js";import{stripHTML as s}from"../../../core/string.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import n from"../UtilityNetworkAssociationAddAssociationViewModel.js";import{loadCalciteComponents as d}from"../../support/componentsUtils.js";import c from"../../support/FilterBuilder.js";import{globalCss as p}from"../../support/globalCss.js";import{Heading as u}from"../../support/Heading.js";import h from"../../support/SelectionToolbar.js";import"../../support/widgetUtils.js";import{messageBundle as m}from"../../support/decorators/messageBundle.js";import{tsx as _}from"../../support/jsxFactory.js";import{fetchMessageBundle as f}from"../../../intl/messages.js";import{substitute as g}from"../../../intl/substitute.js";const v="esri-feature-form-utility-network-association-layers",y={base:v,header:`${v}__header`,headingContent:`${v}__heading-content`,featureObserver:`${v}__feature-observer`,filterContainer:`${v}__filter-container`,filterOptionsContainer:`${v}__filter-options-container`,filterOptionsHeader:`${v}__filter-options-header`,listContainer:`${v}__list-container`,spatialSelectContainer:`${v}__spatial-select-container`,spatialSelectToolbar:`${v}__spatial-select-toolbar`,stickySpinnerContainer:`${v}__sticky-loading-container`,loadingContainer:`${v}__loading-container`};let b=class extends a{constructor(e,t){super(e,t),this.headingLevel=5,this.messagesCommon=null,this.messagesEditor=null,this.messagesFeature=null,this.messagesFeatureForm=null,this.messagesFilterBuilder=null,this.viewModel=new n,this.view=null,this._filterBuilder=new c,this._featureFilterText="",this._layerFilterText="",this._observer=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this._observerNode=null,this._selectionToolbar=new h({layerViewPreferenceEnabled:!1}),this._handleSelectionComplete=async e=>{const{highlightHelper:t,viewModel:r}=this;await r.handleSelectionComplete(e),t?.removeAll(),this._featureSpatialGraphics.length>0&&t?.add(this._featureSpatialGraphics)}}initialize(){this._setupSelectionToolbar(),this.addHandles([t((()=>this.viewModel),(()=>this.reset())),t((()=>[this.viewModel.state,this._observerNode]),(()=>this._onObserverChange())),t((()=>this.selectedLayer),(e=>{this._filterBuilder.layer=e,e||(this.filterOptionsVisible=!1,this._featureFilterText="")}))])}loadDependencies(){return d({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._filterBuilder.destroy(),this._selectionToolbar.destroy()}get filterOptionsVisible(){return this.viewModel.filterOptionsVisible}set filterOptionsVisible(e){this.viewModel.filterOptionsVisible=e}get selectedLayer(){return this.viewModel.selectedLayer}set selectedLayer(e){this.viewModel.selectedLayer=e}get selectedFeature(){return this.viewModel.selectedFeature}set selectedFeature(e){this.viewModel.selectedFeature=e}get filterWhereClause(){return this.viewModel.filterWhereClause}set filterWhereClause(e){this.viewModel.filterWhereClause=e,e||this._filterBuilder.reset()}get highlightHelper(){return this.viewModel.highlightHelper}get _featureSpatialGraphics(){return this.viewModel.featureSpatialItems.toArray().map((e=>e.feature))}get _filteredFeatureItems(){const{_featureFilterText:e}=this,{featureItems:t,featureSpatialItems:r}=this.viewModel;return(r.length?r:t).map((e=>({label:e.label,graphic:e.feature,layer:e.feature.sourceLayer}))).filter((t=>t.label?.toLowerCase().includes(e)??!1))}get _filteredFeatureItemsPage(){const{featurePage:e,featuresPerPage:t}=this.viewModel,r=e*t;return this._filteredFeatureItems.toArray().slice(0,r)}render(){return _("div",{class:this.classes(y.base,p.widget)},this._renderContent())}applyFilterOptions(){const{selectedLayer:e}=this;this.filterOptionsVisible=!1,e&&(this.filterWhereClause=this._filterBuilder.whereClause)}reset(){this.filterWhereClause=null,this._featureFilterText="",this._layerFilterText="",this.filterOptionsVisible=!1,this._filterBuilder.reset()}_setupSelectionToolbar(){const{_selectionToolbar:e}=this;e.defaultRectangleToolOptions={...e.defaultRectangleToolOptions,persistSelection:!1},e.defaultLassoToolOptions={...e.defaultLassoToolOptions,persistSelection:!1};const s={createTool:"point",mode:"click",toolName:"",icon:"cursor",toolKey:"point",persistSelection:!1};f("esri/widgets/Editor/t9n/Editor").then((t=>{e.toolConfigs=[{...s,toolName:t.selectFeature}]})),this.addHandles([t((()=>this.view),(e=>{e?this._selectionToolbar.view="2d"===e.type?e:null:this.viewModel.reset()}),r),t((()=>[this.viewModel,this.viewModel.layerItems.length]),(()=>this._selectionToolbar.sources=this.viewModel.layerItems.toArray())),i((()=>this._selectionToolbar),"complete",this._handleSelectionComplete)])}async _onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e}=this.viewModel;this._observerNode&&"ready"===e&&this._observer.observe(this._observerNode)}_increaseFeaturePage(){const{featureCount:e,featurePage:t,featureSpatialItems:r,state:i}=this.viewModel;e||r.length||1===t?"ready"===i&&this.viewModel.featurePage++:this.viewModel.featurePage=1}_renderContent(){const{state:e,filterOptionsVisible:t}=this.viewModel;return"loading"===e?this._renderLoading():t?this._renderFilterOptions():[this._renderSelectionToolbar(),this._renderListContent()]}_renderListContent(){return this.selectedLayer||this.viewModel.featureSpatialItems.length?this._renderFeatures():this._renderLayers()}_renderSelectionToolbar(){const{messagesCommon:e,_selectionToolbar:t}=this,{featureSpatialItems:r,selectedLayer:i}=this.viewModel;if(i||!t.sources?.length)return null;const s=_("div",{class:y.spatialSelectToolbar},t.render()),o=_("calcite-button",{appearance:"transparent",disabled:!r.length,label:e.clear,onclick:()=>this.viewModel.reset()},e.clear);return _("div",{class:y.spatialSelectContainer,key:"spatial-select-toolbar"},s,o)}_renderStickyLoading(){return"querying"===this.viewModel.state?_("div",{class:y.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoading(){return _("div",{class:y.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderLoadingIcon(){return _("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderFilterOptions(){return _("div",{class:y.filterOptionsContainer},_("div",{class:y.filterOptionsHeader},_("span",null,this.messagesFilterBuilder.widgetLabel),_("calcite-button",{appearance:"transparent",onclick:()=>this._filterBuilder.reset()},this.messagesCommon.clear)),this._filterBuilder.render())}_renderLayers(){const e=this.messagesFeatureForm.associations,t=e.availableLayers,r=e.filterLayers;return _("div",null,this._renderHeader({heading:t,placeholder:r,renderFilterOptions:!1,renderTotal:!1}),_("div",{class:y.listContainer},_("calcite-list",{label:e.associatedFeatures},this._renderLayerItems(),this._renderStickyLoading())))}_renderLayerItems(){const{_layerFilterText:e,viewModel:t,messagesCommon:r}=this,{layerItems:i,tableItems:s}=t;return i.concat(s).map((e=>({label:e.title??r.untitled,layer:e}))).filter((t=>t.label?.toLowerCase().includes(e)??!1)).toArray().map((e=>this._renderLayerItem(e)))}_renderLayerItem(e){const{label:t,layer:r}=e;return _("calcite-list-item",{key:`layer-item-${r.id}`,label:s(t),onCalciteListItemSelect:()=>{this.selectedLayer=r,this._filterBuilder.reset()}},_("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderFeatures(){const{selectedLayer:e,viewModel:t}=this,r=t.featureSpatialItems.length>0,i=this.messagesFeatureForm.associations,s=e?.title??this.messagesCommon.untitled,o=i.filterFeatures;return _("div",null,this._renderHeader({heading:s,placeholder:o,renderFilterOptions:!r,renderTotal:!0}),_("div",{class:y.listContainer},_("calcite-list",{label:i.associatedFeatures},this._renderFeatureItems(),this._renderStickyLoading(),this._renderFeatureObserver())))}_renderFeatureItems(){return this._filteredFeatureItemsPage.map((e=>this._renderFeatureItem(e)))}_renderFeatureItem(e){const{label:t,graphic:r}=e;return _("calcite-list-item",{key:`feature-item-${r.uid}`,label:s(t),onCalciteListItemSelect:()=>{this.selectedFeature={feature:r,label:t}}},_("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_onObserverCreate(e){this._observerNode=e}_renderFeatureObserver(){return _("div",{afterCreate:this._onObserverCreate,bind:this,class:y.featureObserver,key:"feature-observer"})}_renderHeader(e){return _("div",{class:y.header,key:"filter"},this._renderHeading(e.heading),this._renderFilter(e.placeholder,e.renderFilterOptions),e.renderTotal?this._renderTotal():null)}_renderHeading(e){return e?_(u,{key:"title",level:this.headingLevel},_("div",{class:y.headingContent},_("calcite-icon",{icon:"layer"}),e)):null}_renderFilter(e,t){const r=!this.selectedLayer&&!this.viewModel.featureSpatialItems.length,i=r?this._layerFilterText:this._featureFilterText;return _("div",{class:y.filterContainer,key:"filter"},_("calcite-input",{icon:"search",placeholder:e,type:"search",value:i,onCalciteInputInput:e=>{r?this._layerFilterText=e.currentTarget.value.trim().toLowerCase():this._featureFilterText=e.currentTarget.value.trim().toLowerCase()}},t?this._renderFilterOptionsAction():null))}_renderFilterOptionsAction(){const e=this.messagesFeatureForm.associations.filterOptions;return _("calcite-action",{appearance:"transparent",icon:"sliders",indicator:!!this._filterBuilder.whereClause,onclick:()=>{this.viewModel.filterOptionsVisible=!this.viewModel.filterOptionsVisible},scale:"s",slot:"action",text:e,title:e})}_renderTotal(){const{messagesFeature:e,viewModel:t}=this,{featureCount:r,featureSpatialItems:i}=t,s=g(e.numberRecords,{number:i.length?i.length:r});return _("div",{key:"total"},s)}};e([o()],b.prototype,"filterOptionsVisible",null),e([o()],b.prototype,"headingLevel",void 0),e([o(),m("esri/t9n/common")],b.prototype,"messagesCommon",void 0),e([o(),m("esri/widgets/Editor/t9n/Editor")],b.prototype,"messagesEditor",void 0),e([o(),m("esri/widgets/Feature/t9n/Feature")],b.prototype,"messagesFeature",void 0),e([o(),m("esri/widgets/FeatureForm/t9n/FeatureForm")],b.prototype,"messagesFeatureForm",void 0),e([o(),m("esri/widgets/support/FilterBuilder/t9n/FilterBuilder")],b.prototype,"messagesFilterBuilder",void 0),e([o()],b.prototype,"selectedLayer",null),e([o({type:n})],b.prototype,"viewModel",void 0),e([o()],b.prototype,"selectedFeature",null),e([o()],b.prototype,"filterWhereClause",null),e([o()],b.prototype,"highlightHelper",null),e([o()],b.prototype,"view",void 0),e([o()],b.prototype,"_filterBuilder",void 0),e([o()],b.prototype,"_featureFilterText",void 0),e([o()],b.prototype,"_layerFilterText",void 0),e([o()],b.prototype,"_observer",void 0),e([o()],b.prototype,"_featureSpatialGraphics",null),e([o()],b.prototype,"_filteredFeatureItems",null),e([o()],b.prototype,"_filteredFeatureItemsPage",null),e([o()],b.prototype,"_observerNode",void 0),b=e([l("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationItemList")],b);const F=b;export{F as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{watch as t,initial as r,on as i}from"../../../core/reactiveUtils.js";import{stripHTML as s}from"../../../core/string.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{defaultHighlightName as a,temporaryHighlightName as n}from"../../../views/support/HighlightDefaults.js";import d from"../../Widget.js";import c from"../UtilityNetworkAssociationAddAssociationViewModel.js";import{loadCalciteComponents as p}from"../../support/componentsUtils.js";import u from"../../support/FilterBuilder.js";import{globalCss as h}from"../../support/globalCss.js";import{Heading as m}from"../../support/Heading.js";import _ from"../../support/SelectionToolbar.js";import"../../support/widgetUtils.js";import{messageBundle as f}from"../../support/decorators/messageBundle.js";import{tsx as g}from"../../support/jsxFactory.js";import{fetchMessageBundle as v}from"../../../intl/messages.js";import{substitute as y}from"../../../intl/substitute.js";const b="esri-feature-form-utility-network-association-layers",F={base:b,header:`${b}__header`,headingContent:`${b}__heading-content`,featureObserver:`${b}__feature-observer`,filterContainer:`${b}__filter-container`,filterOptionsContainer:`${b}__filter-options-container`,filterOptionsHeader:`${b}__filter-options-header`,listContainer:`${b}__list-container`,spatialSelectContainer:`${b}__spatial-select-container`,spatialSelectToolbar:`${b}__spatial-select-toolbar`,stickySpinnerContainer:`${b}__sticky-loading-container`,loadingContainer:`${b}__loading-container`};let w=class extends d{constructor(e,t){super(e,t),this.headingLevel=5,this.messagesCommon=null,this.messagesEditor=null,this.messagesFeature=null,this.messagesFeatureForm=null,this.messagesFilterBuilder=null,this.viewModel=new c,this.view=null,this._filterBuilder=new u,this._featureFilterText="",this._layerFilterText="",this._observer=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this._observerNode=null,this._selectionToolbar=new _({layerViewPreferenceEnabled:!1}),this._handleSelectionComplete=async e=>{const{highlightHelper:t}=this.viewModel;await this.viewModel.handleSelectionComplete(e),t?.removeAll(),this._featureSpatialGraphics.length>0&&t?.add(this._featureSpatialGraphics)}}initialize(){this._setupSelectionToolbar(),this.addHandles([t((()=>this.viewModel),(()=>this.reset())),t((()=>[this.viewModel.state,this._observerNode]),(()=>this._onObserverChange())),t((()=>this.selectedLayer),(e=>{this._filterBuilder.layer=e,e||(this.filterOptionsVisible=!1,this._featureFilterText="")}))])}loadDependencies(){return p({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._filterBuilder.destroy(),this._selectionToolbar.destroy()}get filterOptionsVisible(){return this.viewModel.filterOptionsVisible}set filterOptionsVisible(e){this.viewModel.filterOptionsVisible=e}get selectedLayer(){return this.viewModel.selectedLayer}set selectedLayer(e){this.viewModel.selectedLayer=e}get selectedFeature(){return this.viewModel.selectedFeature}set selectedFeature(e){this.viewModel.selectedFeature=e}get filterWhereClause(){return this.viewModel.filterWhereClause}set filterWhereClause(e){this.viewModel.filterWhereClause=e,e||this._filterBuilder.reset()}get _featureSpatialGraphics(){return this.viewModel.featureSpatialItems.toArray().map((e=>e.feature))}get _filteredFeatureItems(){const{_featureFilterText:e}=this,{featureItems:t,featureSpatialItems:r}=this.viewModel;return(r.length?r:t).map((e=>({label:e.label,graphic:e.feature,layer:e.feature.sourceLayer}))).filter((t=>t.label?.toLowerCase().includes(e)??!1))}get _filteredFeatureItemsPage(){const{featurePage:e,featuresPerPage:t}=this.viewModel,r=e*t;return this._filteredFeatureItems.toArray().slice(0,r)}render(){return g("div",{class:this.classes(F.base,h.widget)},this._renderContent())}applyFilterOptions(){const{selectedLayer:e}=this;this.filterOptionsVisible=!1,e&&(this.filterWhereClause=this._filterBuilder.whereClause)}reset(){this.filterWhereClause=null,this._featureFilterText="",this._layerFilterText="",this.filterOptionsVisible=!1,this._filterBuilder.reset()}_setupSelectionToolbar(){const{_selectionToolbar:e}=this;e.defaultRectangleToolOptions={...e.defaultRectangleToolOptions,persistSelection:!1},e.defaultLassoToolOptions={...e.defaultLassoToolOptions,persistSelection:!1};const s={createTool:"point",mode:"click",toolName:"",icon:"cursor",toolKey:"point",persistSelection:!1};v("esri/widgets/Editor/t9n/Editor").then((t=>{e.toolConfigs=[{...s,toolName:t.selectFeature}]})),this.addHandles([t((()=>this.view),(e=>{this.viewModel.reset(),this._selectionToolbar.view="2d"===e?.type?e:null}),r),t((()=>[this.viewModel,this.viewModel.layerItems.length]),(()=>this._selectionToolbar.sources=this.viewModel.layerItems.toArray())),i((()=>this._selectionToolbar),"complete",this._handleSelectionComplete)])}async _onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e}=this.viewModel;this._observerNode&&"ready"===e&&this._observer.observe(this._observerNode)}_increaseFeaturePage(){const{featureCount:e,featurePage:t,featureSpatialItems:r,state:i}=this.viewModel;e||r.length||1===t?"ready"===i&&this.viewModel.featurePage++:this.viewModel.featurePage=1}_renderContent(){const{state:e,filterOptionsVisible:t}=this.viewModel;return"loading"===e?this._renderLoading():t?this._renderFilterOptions():[this._renderSelectionToolbar(),this._renderListContent()]}_renderListContent(){return this._selectionToolbar.activeToolInfo?.operation.processingFinalSelection?this._renderLoading():this.selectedLayer||this.viewModel.featureSpatialItems.length?this._renderFeatures():this._renderLayers()}_renderSelectionToolbar(){const{messagesCommon:e,_selectionToolbar:t}=this,{featureSpatialItems:r,selectedLayer:i}=this.viewModel;if(i||!t.sources?.length)return null;const s=g("div",{class:F.spatialSelectToolbar},t.render()),o=g("calcite-button",{appearance:"transparent",disabled:!r.length,label:e.clear,onclick:()=>this.viewModel.reset()},e.clear);return g("div",{class:F.spatialSelectContainer,key:"spatial-select-toolbar"},s,o)}_renderStickyLoading(){return"querying"===this.viewModel.state?g("div",{class:F.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoading(){return g("div",{class:F.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderLoadingIcon(){return g("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderFilterOptions(){return g("div",{class:F.filterOptionsContainer},g("div",{class:F.filterOptionsHeader},g("span",null,this.messagesFilterBuilder.widgetLabel),g("calcite-button",{appearance:"transparent",onclick:()=>this._filterBuilder.reset()},this.messagesCommon.clear)),this._filterBuilder.render())}_renderLayers(){const e=this.messagesFeatureForm.associations,t=e.availableLayers,r=e.filterLayers;return g("div",null,this._renderHeader({heading:t,placeholder:r,renderFilterOptions:!1,renderTotal:!1}),g("div",{class:F.listContainer},g("calcite-list",{label:e.associatedFeatures},this._renderLayerItems(),this._renderStickyLoading())))}_renderLayerItems(){const{_layerFilterText:e,viewModel:t,messagesCommon:r}=this,{layerItems:i,tableItems:s}=t;return i.concat(s).map((e=>({label:e.title??r.untitled,layer:e}))).filter((t=>t.label?.toLowerCase().includes(e)??!1)).toArray().map((e=>this._renderLayerItem(e)))}_renderLayerItem(e){const{label:t,layer:r}=e;return g("calcite-list-item",{key:`layer-item-${r.id}`,label:s(t),onCalciteListItemSelect:()=>{this.selectedLayer=r,this._filterBuilder.reset()}},g("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderFeatures(){const{selectedLayer:e,viewModel:t}=this,r=t.featureSpatialItems.length>0,i=this.messagesFeatureForm.associations,s=e?.title??this.messagesCommon.untitled,o=i.filterFeatures;return g("div",null,this._renderHeader({heading:s,placeholder:o,renderFilterOptions:!r,renderTotal:!0}),g("div",{class:F.listContainer},g("calcite-list",{label:i.associatedFeatures},this._renderFeatureItems(),this._renderStickyLoading(),this._renderFeatureObserver())))}_renderFeatureItems(){return this._filteredFeatureItemsPage.map((e=>this._renderFeatureItem(e)))}_renderFeatureItem(e){const{viewModel:t}=this,{highlightHelper:r}=t,{label:i,graphic:o}=e,l=t.featureSpatialItems.length>0?()=>r?.update(o,a):void 0,d=t.featureSpatialItems.length>0?()=>r?.update(o,n):void 0;return g("calcite-list-item",{key:`feature-item-${o.uid}`,label:s(i),onmouseenter:l,onmouseleave:d,onCalciteListItemSelect:()=>{this.selectedFeature={feature:o,label:i}}},g("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_onObserverCreate(e){this._observerNode=e}_renderFeatureObserver(){return g("div",{afterCreate:this._onObserverCreate,bind:this,class:F.featureObserver,key:"feature-observer"})}_renderHeader(e){return g("div",{class:F.header,key:"filter"},this._renderHeading(e.heading),this._renderFilter(e.placeholder,e.renderFilterOptions),e.renderTotal?this._renderTotal():null)}_renderHeading(e){return e?g(m,{key:"title",level:this.headingLevel},g("div",{class:F.headingContent},g("calcite-icon",{icon:"layer"}),e)):null}_renderFilter(e,t){const r=!this.selectedLayer&&!this.viewModel.featureSpatialItems.length,i=r?this._layerFilterText:this._featureFilterText;return g("div",{class:F.filterContainer,key:"filter"},g("calcite-input",{icon:"search",placeholder:e,type:"search",value:i,onCalciteInputInput:e=>{r?this._layerFilterText=e.currentTarget.value.trim().toLowerCase():this._featureFilterText=e.currentTarget.value.trim().toLowerCase()}},t?this._renderFilterOptionsAction():null))}_renderFilterOptionsAction(){const e=this.messagesFeatureForm.associations.filterOptions;return g("calcite-action",{appearance:"transparent",icon:"sliders",indicator:!!this._filterBuilder.whereClause,onclick:()=>{this.viewModel.filterOptionsVisible=!this.viewModel.filterOptionsVisible},scale:"s",slot:"action",text:e,title:e})}_renderTotal(){const{messagesFeature:e,viewModel:t}=this,{featureCount:r,featureSpatialItems:i}=t,s=y(e.numberRecords,{number:i.length?i.length:r});return g("div",{key:"total"},s)}};e([o()],w.prototype,"filterOptionsVisible",null),e([o()],w.prototype,"headingLevel",void 0),e([o(),f("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([o(),f("esri/widgets/Editor/t9n/Editor")],w.prototype,"messagesEditor",void 0),e([o(),f("esri/widgets/Feature/t9n/Feature")],w.prototype,"messagesFeature",void 0),e([o(),f("esri/widgets/FeatureForm/t9n/FeatureForm")],w.prototype,"messagesFeatureForm",void 0),e([o(),f("esri/widgets/support/FilterBuilder/t9n/FilterBuilder")],w.prototype,"messagesFilterBuilder",void 0),e([o()],w.prototype,"selectedLayer",null),e([o({type:c})],w.prototype,"viewModel",void 0),e([o()],w.prototype,"selectedFeature",null),e([o()],w.prototype,"filterWhereClause",null),e([o()],w.prototype,"view",void 0),e([o()],w.prototype,"_filterBuilder",void 0),e([o()],w.prototype,"_featureFilterText",void 0),e([o()],w.prototype,"_layerFilterText",void 0),e([o()],w.prototype,"_observer",void 0),e([o()],w.prototype,"_featureSpatialGraphics",null),e([o()],w.prototype,"_filteredFeatureItems",null),e([o()],w.prototype,"_filteredFeatureItemsPage",null),e([o()],w.prototype,"_observerNode",void 0),w=e([l("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationItemList")],w);const C=w;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as i,equals as a}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as C}from"../../core/accessorSupport/decorators/subclass.js";import{distance as k}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import G from"../../geometry/Multipoint.js";import R from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import z from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ie,getImageToWorldPanoramicProperties as ae,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Se}from"./galleryUtils.js";import{formatPixels as Me,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Ge,pixelAreaMeasurementPanoramic as Re,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as ze,calculateTempImagePoint as He,calculateAngle as De,getModeCorrectedPoint as Te,calculateCorrectedPixel as Ue,calculateHeightFromTemporaryDistance as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,sourcePointSymbol as Ke,diamondSymbol as Qe,diamondSymbol3D as Xe,locationSymbol as Ye,locationSymbol3D as et,activeSourcePointSymbol as tt}from"./symbols.js";import{isNoAttachmentError as it,getContentType as at,isTifOrMrf as rt,filterOILLayerView as st,isSceneView as ot,isGraphic as nt,calculateSegment as lt,calculateDirection as ct}from"./utils.js";import ht from"./components/ImageViewer.js";const ut={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},pt=new Set(["JPG","JPEG"]),mt=/\.(\w+)$/,dt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let gt=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r,view:s}=this;if(s?.closePopup(),a&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ht,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new z({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return f(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:i,popupEnabled:a,layer:r,view:s}=this;if(s?.closePopup(),!(s&&i&&a&&r))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ut.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.WIDGET),ut.click)},this._createImageClickHandle=()=>{this.removeHandles(ut.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;const r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return le(!t,e.spatialReference.equals(t))?e:x(e,t)}));f(i),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,ut.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(ut.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;let r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t});f(i);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),f(i)),this.groundCoordinates=r}))}));this.addHandles(l,ut.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),!i||!t||"none"===a)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?B(m):new R(m);let v=s;if(Ie(s))try{v=await Se(i,h,e)}catch(w){if(y(w))return;return it(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[i.objectIdField]:h,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:a,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:a,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(mt)?.[1]:e.datasetFormat;if(!c)try{c=await at(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=a??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(pt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:a,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=a??0;"number"==typeof n?l=n-l:s&&e&&(l=await X(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if(("mouse"!==i||0===a)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const a=new R({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._crossSymbol=new t({geometry:new R(n,j.WebMercator),symbol:qe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),_),F((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ut.interactionHandles),e){case"default":this.addHandles(F((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),ut.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:a,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&!t.includes("loading")?[a,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,i,a,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,h)}),ut.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._locationPointOnImage=d(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return rt(t)||Ie(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(st(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ve.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:i},_featureChangedTask:a}=this;if(t)return"disabled";if(!this.isFulfilled()||i||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return rt(r)||Ie(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new z({elevationInfo:{mode:"absolute-height"}});case"default":return new z;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,i=!0){const{currentBestFeature:a,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=a?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=Me(m,!1),g="panoramic"===t?await Ce(m,h,c,a,!0,!1):await ke(m,h,c,!0,i);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,a,!0):await Ae(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,i){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const a="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),a?"default"===t?await Ge(e,a,!0):await Re(e,a,!0,i):null}async calculateDistanceMeasurement(e,t,i){const{currentBestFeature:a,activeViewer:r}=this;if(e.length<2||!a||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await Le([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s}=this,o=a?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(f(i),!l)return null;const c="area"===t?await Ge(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);f(i);const{updateElevationProps:h,...u}=l,p=xe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async a=>{const r="area"===t?await Ge(e,a,!0):await Oe([e.at(0),e.at(-1)],a,!0);if(f(i),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(i);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateAccuracyPanoramic(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s,mode:o}=this,n=a?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const h="area"===t?await Re(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);f(i);const{updateElevationProps:u,...p}=c,m=Ee(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async a=>{const r="area"===t?await Re(e,a,!0):await Le([e.at(0),e.at(-1)],a,!0);if(f(i),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(i);const y=g.filter((e=>null!==e));return 0===y.length?null:je(y)}async calculateHeightMeasurementInfo(e,t,i){const{currentBestFeature:a,activeViewer:r}=this,s=r?.imageSize;if(!a||!r||!s?.length||"none"===t)return;const{attributes:o}=a,[n]=Me([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Be(n,l,a,i);if(!e)return;e?.heading>180&&(e.heading-=360);const t=ze(n,e),r=k([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await He(n,l,i);if(!c)return;const h=De(n,c),u=k([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:a}=this;if(!i)throw dt();be(a,e,i),await i.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw dt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw dt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw dt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw dt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw dt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw dt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:i,mode:a}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(i,a);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const i=[],a=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=S(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==fe&&(i.push(c),h&&a.push(h))}})),{features:r,polygons:i,frustums:a}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=ee(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=ae(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t];a?.length&&this._updateCurrentBestFeature(a.at(i))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:i,heightMeasurementPixels:a,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Te(e.vertices.at(-1),r,o);if(a.length<1||!n||!i||!t||"none"===r)return;const l=Ue(a[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=Ne(this.heightMeasurementPixels,i);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:i,activeViewer:a,heightMeasurementPixels:r,mode:s}=this;if(!i||!a||!e.vertices?.length||"none"===s)return;const o=a?.imageSize;if(!r.length&&o){const i=Te(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(i);const a=await this.calculateHeightMeasurementInfo(i,s,t);if(!a?.measurementAngle||!a?.tempDistance)return;this.measurementAngle=a.measurementAngle,this.tempDistance=a.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?B(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;f(e),this.sketch=new i({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],i=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[e],spatialReference:i});else{const a=new L({paths:[e],spatialReference:i}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:a,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,i=this.activeViewer?.imageSize;if(!i)return;const a={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=Y(a,i[0],i[1]),{heading:n,pitch:l}=Y(r,i[0],i[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const i=new L({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:i,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!a||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=T(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${a.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:r}=e,s=await this.getPixels(r,{feature:a,imageSize:l,mode:o}),n=Ke.clone();return n.outline=new pe({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));r.addMany(n),i.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=Fe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const i=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,u=i.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new G({points:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:i,mode:a}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===a)return new R({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=i,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new R(n,j.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:i,mode:a,imageSize:r}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ie(p.elevationSample)&&(i.elevationSample=p.elevationSample),"default"===a){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ae(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new R({...e.toJSON()}),symbol:Qe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:Qe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:Xe}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t}),{success:[],error:[]});a.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(se(s,m,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,i])=>se(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,i])=>se(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),t}}}))),c=l.filter(i);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let i=0;const a=l.map((e=>{const a=t[i++];return e?a:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:a}}))}async searchBestImage(e,t){try{const i=await H(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(a)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const a=i.ui.find("zoom");a&&(a.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const a={include:i},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,a);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:a,invalidCameraHeading:r}=this;if(!e||!t||!i||!a||r)return void(this._sectorData=null);this._sectorData={};for(const c of ve)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:i,featureIndex:r}=e,s=t/l*we[2],o=lt(t,l),n=ct(i);if(!this._sectorData)return;const c=we[3]+s*Math.sin(i*Math.PI/180),h=we[3]+s*Math.cos(i*Math.PI/180);let u;const p=a.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-we[3],t=h-we[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),u=a}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:i,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}_plotLocationPointOnDefaultImage(e){const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._locationPointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:Ye}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:et}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}async _processFeatureResponse(e,t,i){const{features:a}=e;if(!a?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const i of s)e=await A(e,i);const t=[];for(const{geometry:i}of r)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[a,...s]=await K([t,...r.map((e=>e.attributes.geometry.clone()))],i);r[0].elevationSample=n??i.elevationSample,t.elevation=a.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=D({features:r,selectedPoint:t,camera:ot(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,i){const{screenPoint:a,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(a);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:S(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,i)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(a&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:tt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Ke,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-we[3],a=e.y-we[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!a||!t||"image-loaded"!==r?.state||i)return;let s;try{s=await this.worldToImage(a,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:a,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:a}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!a||!i)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await te(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ce(d,{imageHeight:a[1],imageWidth:a[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,a[0],a[1]);m=he(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,s].filter(nt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([M()],gt.prototype,"activeLayer",null),e([M({readOnly:!0})],gt.prototype,"activeViewer",null),e([M()],gt.prototype,"accuracyParametersMissing",null),e([M()],gt.prototype,"additionalFeatures",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalCameraLocations",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalFootprints",void 0),e([M()],gt.prototype,"areaMeasurementResult",void 0),e([M()],gt.prototype,"areaMeasurementAccuracy",void 0),e([M()],gt.prototype,"bestFeatureAngle",void 0),e([M()],gt.prototype,"bestFeatureCurrentFootprint",void 0),e([M({type:t})],gt.prototype,"bestFeatureFootprint",void 0),e([M({type:Number})],gt.prototype,"brightness",null),e([M()],gt.prototype,"collectionId",void 0),e([M({type:Number})],gt.prototype,"contrast",null),e([M()],gt.prototype,"conversionProps",void 0),e([M()],gt.prototype,"coverageFrustums",void 0),e([M()],gt.prototype,"coveragePolygons",void 0),e([M()],gt.prototype,"currentBestFeature",void 0),e([M()],gt.prototype,"currentBestFeatureLocation",void 0),e([M()],gt.prototype,"currentCoverageVisible",void 0),e([M({json:{write:!1}})],gt.prototype,"determineWorkflowForFeature",void 0),e([M()],gt.prototype,"disabled",void 0),e([M()],gt.prototype,"displayMessage",void 0),e([M()],gt.prototype,"displayNewMeasurementButton",void 0),e([M()],gt.prototype,"distanceMeasurementResult",void 0),e([M()],gt.prototype,"distanceAccuracyArray",void 0),e([M()],gt.prototype,"dataCaptureLayer",void 0),e([M({readOnly:!0})],gt.prototype,"featureCount",null),e([M()],gt.prototype,"features",void 0),e([M()],gt.prototype,"groundCoordinates",void 0),e([M()],gt.prototype,"heightMeasurementPixels",void 0),e([M()],gt.prototype,"heightGraphic",void 0),e([M()],gt.prototype,"heightMeasurementResult",void 0),e([M()],gt.prototype,"heightMeasurementAccuracy",void 0),e([M()],gt.prototype,"measurementAngle",void 0),e([M()],gt.prototype,"tempDistance",void 0),e([M({readOnly:!0})],gt.prototype,"imageGalleryEnabled",null),e([M()],gt.prototype,"imageGeometryField",void 0),e([M({readOnly:!0})],gt.prototype,"imageLoaded",null),e([M()],gt.prototype,"imageLocationToolState",void 0),e([M({readOnly:!0})],gt.prototype,"invalidCameraHeading",null),e([M()],gt.prototype,"imagePointsInView",null),e([M()],gt.prototype,"isAdditionalCoverageVisible",void 0),e([M()],gt.prototype,"isAdditionalPointSourcesVisible",void 0),e([M()],gt.prototype,"layer",void 0),e([M()],gt.prototype,"layerView",null),e([M({readOnly:!0})],gt.prototype,"layerFloorFilterClause",null),e([M({type:Number})],gt.prototype,"localPort",void 0),e([M()],gt.prototype,"mapImageConversionToolState",void 0),e([M()],gt.prototype,"measureType",void 0),e([M()],gt.prototype,"measurementGraphic",void 0),e([M({readOnly:!0,value:"none"})],gt.prototype,"mode",null),e([M()],gt.prototype,"navigatorCurrentBestFeature",void 0),e([M()],gt.prototype,"oiObjectIdField",void 0),e([M({type:s.ofType(t)})],gt.prototype,"overlayedCameraLocations",void 0),e([M()],gt.prototype,"overlayedMapFeatures",void 0),e([M()],gt.prototype,"pixelCoordinates",void 0),e([M()],gt.prototype,"pointSources",void 0),e([M({readOnly:!0})],gt.prototype,"popupEnabled",null),e([M()],gt.prototype,"previousFeatureAngle",void 0),e([M()],gt.prototype,"referencePoint",null),e([M({readOnly:!0})],gt.prototype,"sectorData",null),e([M()],gt.prototype,"selectedPoint",void 0),e([M({type:Number})],gt.prototype,"sharpness",null),e([M()],gt.prototype,"shouldShowSelectedImage",void 0),e([M()],gt.prototype,"sketch",void 0),e([M()],gt.prototype,"draw",void 0),e([M()],gt.prototype,"sketchAdapter",void 0),e([M({readOnly:!0})],gt.prototype,"sketchGraphicsLayer",null),e([M({readOnly:!0})],gt.prototype,"state",null),e([M({readOnly:!0})],gt.prototype,"thumbnails",null),e([M()],gt.prototype,"updateFootprint",void 0),e([M()],gt.prototype,"updateFootprintPanorama",void 0),e([M({value:null})],gt.prototype,"view",null),e([M()],gt.prototype,"_adapter",void 0),e([M()],gt.prototype,"_sketchGraphicsLayer",null),e([M()],gt.prototype,"_highlightedFeatureHandle",void 0),e([M()],gt.prototype,"_imageViewer",void 0),e([M()],gt.prototype,"_initialCurrentCoverageUpdate",void 0),e([M()],gt.prototype,"_locationPointOnImage",void 0),e([M()],gt.prototype,"_overlays",void 0),e([M({readOnly:!0})],gt.prototype,"_overlaysView",null),e([M()],gt.prototype,"_panoramicViewer",void 0),e([M()],gt.prototype,"_previousCursor",void 0),e([M()],gt.prototype,"_referencePointOnGround",void 0),e([M()],gt.prototype,"_referencePointOnImage",void 0),e([M()],gt.prototype,"_sectorData",void 0),e([M({readOnly:!0})],gt.prototype,"_updatingHandles",void 0),e([M()],gt.prototype,"footprintExtent",void 0),e([M()],gt.prototype,"_featureChangedTask",void 0),gt=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],gt);const yt=gt;export{yt as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as a,equals as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as M}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as C}from"../../core/accessorSupport/decorators/subclass.js";import{distance as k}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import G from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import B from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ae,getImageToWorldPanoramicProperties as ie,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Me}from"./galleryUtils.js";import{formatPixels as Se,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Re,pixelAreaMeasurementPanoramic as Ge,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateLocationAccuracyFromDeviations as ze,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as He,calculateTempImagePoint as De,calculateAngle as Te,getModeCorrectedPoint as Ue,calculateCorrectedPixel as Ne,calculateHeightFromTemporaryDistance as We}from"./imageMeasurementUtils.js";import{crossSymbol as qe,crossSymbol3D as $e,measurementPolygonSymbol as Je,polylineSymbolPanoramic as Ze,measurementPolylineSymbol as Ke,sourcePointSymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at}from"./symbols.js";import{isNoAttachmentError as it,getContentType as rt,isTifOrMrf as st,filterOILLayerView as ot,isSceneView as nt,isGraphic as lt,calculateSegment as ct,calculateDirection as ht}from"./utils.js";import ut from"./components/ImageViewer.js";const pt={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},mt=new Set(["JPG","JPEG"]),dt=/\.(\w+)$/,gt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let yt=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ut,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new B({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return f(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(pt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.WIDGET),pt.click)},this._createImageClickHandle=()=>{this.removeHandles(pt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=b((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return le(!t,e.spatialReference.equals(t))?e:x(e,t)}));f(a),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,pt.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(pt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=b((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});f(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),f(a)),this.groundCoordinates=r;const n=await this.calculateLocationAccuracy(e,r,t,a);f(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(l,pt.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?z(m):new G(m);let v=s;if(Ie(s))try{v=await Me(a,h,e)}catch(w){if(y(w))return;return it(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(dt)?.[1]:e.datasetFormat;if(!c)try{c=await rt(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",a){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(mt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await X(s,e)-l),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await v(a),!e)return;const i=new G({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:qe}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new G(n,j.WebMercator),symbol:$e}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),_),F((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(pt.interactionHandles),e){case"default":this.addHandles(F((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>i(e,t,h)}),pt.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>i(e,t,h)}),pt.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._locationPointOnImage=d(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return st(t)||Ie(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(ot(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ve.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return st(r)||Ie(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(a)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new B({elevationInfo:{mode:"absolute-height"}});case"default":return new B;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=i?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=Se(m,!1),g="panoramic"===t?await Ce(m,h,c,i,!0,!1):await ke(m,h,c,!0,a);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,i,!0):await Ae(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(a),i?"default"===t?await Re(e,i,!0):await Ge(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(a),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await Le([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(f(a),!l)return null;const c="area"===t?await Re(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);f(a);const{updateElevationProps:h,...u}=l,p=xe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Re(e,i,!0):await Oe([e.at(0),e.at(-1)],i,!0);if(f(a),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(a);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,l=o?.every((e=>0===e))||!o?.length;if(!s||l)return null;const c="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const{updateElevationProps:h,...u}=c,p="default"===a?xe(u,o):Ee(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async r=>{const{updateElevationProps:s,...o}=r;let l="default"===a?await J(e,o,s):await Z(e,o,s);return f(i),n&&!l.spatialReference.equals(n)&&(l=await x(l,n),f(i)),l&&t?[Math.abs(l.x-t.x),Math.abs(l.y-t.y),l.z&&t.z?Math.abs(l.z-t.z):0]:null})),d=await Promise.all(m);if(f(i),!d?.length)return null;const g=d.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,v,w]=ze(g);return{x:y,y:v,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(a),!c)return null;const h="area"===t?await Ge(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);f(a);const{updateElevationProps:u,...p}=c,m=Ee(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ge(e,i,!0):await Le([e.at(0),e.at(-1)],i,!0);if(f(a),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(a);const y=g.filter((e=>null!==e));return 0===y.length?null:je(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=Se([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Be(n,l,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=He(n,e),r=k([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await De(n,l,a);if(!c)return;const h=Te(n,c),u=k([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw gt();be(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw gt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw gt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw gt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw gt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw gt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw gt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const a=[],i=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=M(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==fe&&(a.push(c),h&&i.push(h))}})),{features:r,polygons:a,frustums:i}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ee(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ie(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(a))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Ue(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const l=Ne(i[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=We(this.heightMeasurementPixels,a);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=Ue(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?z(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;f(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(f(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Je(o),this.sketch.polylineSymbol="panoramic"===s?Ze:Ke(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[e],spatialReference:a});else{const i=new L({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ke(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=Y(i,a[0],a[1]),{heading:n,pitch:l}=Y(r,a[0],a[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const a=new L({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Ze}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=T(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${i.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n=Qe.clone();return n.outline=new pe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Fe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async a=>{const r=a.symbol?.clone()??e.renderer?.getSymbol(a)?.clone(),{attributes:s,geometry:l}=a,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,i,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:a,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const a=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:a,visible:e.visible&&i})}case"polygon":{const{rings:a,spatialReference:l}=c,u=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"polyline":{const{paths:a,spatialReference:l}=c,u=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"multipoint":{const{points:a,spatialReference:l}=c,u=a.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}}return null})))).filter(a));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new G({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=a,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new G(n,j.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ae(p.elevationSample)&&(a.elevationSample=p.elevationSample),"default"===i){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ie(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new G({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=c.isSerializable(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(a&&(l[e.objectIdField]=a),i&&e.globalIdField&&(l[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:i,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!i||"none"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:a}=t;if(!a)return;const n=a.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(a):a;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(se(s,m,o),{feature:i,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),t}}}))),c=l.filter(a);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=l.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await H(e,t);a&&await this._processFeatureResponse(a,e.point,{signal:t?.signal})}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return f(a),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:a,features:i,invalidCameraHeading:r}=this;if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};for(const c of ve)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:a,featureIndex:r}=e,s=t/l*we[2],o=ct(t,l),n=ht(a);if(!this._sectorData)return;const c=we[3]+s*Math.sin(a*Math.PI/180),h=we[3]+s*Math.cos(a*Math.PI/180);let u;const p=i.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-we[3],t=h-we[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),u=i}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:a,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}_plotLocationPointOnDefaultImage(e){const a=c.isSerializable(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._locationPointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:tt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}async _processFeatureResponse(e,t,a){const{features:i}=e;if(!i?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const a of s)e=await A(e,a);const t=[];for(const{geometry:a}of r)e.contains(a)||t.push([a.x,a.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const a=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[i,...s]=await K([t,...r.map((e=>e.attributes.geometry.clone()))],a);r[0].elevationSample=n??a.elevationSample,t.elevation=i.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=D({features:r,selectedPoint:t,camera:nt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:M(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,a)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Qe,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-we[3],i=e.y-we[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await te(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ce(d,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,i[0],i[1]);m=he(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...a,...i,s].filter(lt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:qe.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],yt.prototype,"activeLayer",null),e([S({readOnly:!0})],yt.prototype,"activeViewer",null),e([S()],yt.prototype,"accuracyParametersMissing",null),e([S()],yt.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],yt.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],yt.prototype,"additionalFootprints",void 0),e([S()],yt.prototype,"areaMeasurementResult",void 0),e([S()],yt.prototype,"areaMeasurementAccuracy",void 0),e([S()],yt.prototype,"bestFeatureAngle",void 0),e([S()],yt.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],yt.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],yt.prototype,"brightness",null),e([S()],yt.prototype,"collectionId",void 0),e([S({type:Number})],yt.prototype,"contrast",null),e([S()],yt.prototype,"conversionProps",void 0),e([S()],yt.prototype,"coverageFrustums",void 0),e([S()],yt.prototype,"coveragePolygons",void 0),e([S()],yt.prototype,"currentBestFeature",void 0),e([S()],yt.prototype,"currentBestFeatureLocation",void 0),e([S()],yt.prototype,"currentCoverageVisible",void 0),e([S({json:{write:!1}})],yt.prototype,"determineWorkflowForFeature",void 0),e([S()],yt.prototype,"disabled",void 0),e([S()],yt.prototype,"displayMessage",void 0),e([S()],yt.prototype,"displayNewMeasurementButton",void 0),e([S()],yt.prototype,"distanceMeasurementResult",void 0),e([S()],yt.prototype,"distanceAccuracyArray",void 0),e([S()],yt.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],yt.prototype,"featureCount",null),e([S()],yt.prototype,"features",void 0),e([S()],yt.prototype,"groundCoordinates",void 0),e([S()],yt.prototype,"groundCoordinatesAccuracy",void 0),e([S()],yt.prototype,"heightMeasurementPixels",void 0),e([S()],yt.prototype,"heightGraphic",void 0),e([S()],yt.prototype,"heightMeasurementResult",void 0),e([S()],yt.prototype,"heightMeasurementAccuracy",void 0),e([S()],yt.prototype,"measurementAngle",void 0),e([S()],yt.prototype,"tempDistance",void 0),e([S({readOnly:!0})],yt.prototype,"imageGalleryEnabled",null),e([S()],yt.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],yt.prototype,"imageLoaded",null),e([S()],yt.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],yt.prototype,"invalidCameraHeading",null),e([S()],yt.prototype,"imagePointsInView",null),e([S()],yt.prototype,"isAdditionalCoverageVisible",void 0),e([S()],yt.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],yt.prototype,"layer",void 0),e([S()],yt.prototype,"layerView",null),e([S({readOnly:!0})],yt.prototype,"layerFloorFilterClause",null),e([S({type:Number})],yt.prototype,"localPort",void 0),e([S()],yt.prototype,"mapImageConversionToolState",void 0),e([S()],yt.prototype,"measureType",void 0),e([S()],yt.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],yt.prototype,"mode",null),e([S()],yt.prototype,"navigatorCurrentBestFeature",void 0),e([S()],yt.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],yt.prototype,"overlayedCameraLocations",void 0),e([S()],yt.prototype,"overlayedMapFeatures",void 0),e([S()],yt.prototype,"pixelCoordinates",void 0),e([S()],yt.prototype,"pointSources",void 0),e([S({readOnly:!0})],yt.prototype,"popupEnabled",null),e([S()],yt.prototype,"previousFeatureAngle",void 0),e([S()],yt.prototype,"referencePoint",null),e([S({readOnly:!0})],yt.prototype,"sectorData",null),e([S()],yt.prototype,"selectedPoint",void 0),e([S({type:Number})],yt.prototype,"sharpness",null),e([S()],yt.prototype,"shouldShowSelectedImage",void 0),e([S()],yt.prototype,"sketch",void 0),e([S()],yt.prototype,"draw",void 0),e([S()],yt.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],yt.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],yt.prototype,"state",null),e([S({readOnly:!0})],yt.prototype,"thumbnails",null),e([S()],yt.prototype,"updateFootprint",void 0),e([S()],yt.prototype,"updateFootprintPanorama",void 0),e([S({value:null})],yt.prototype,"view",null),e([S()],yt.prototype,"_adapter",void 0),e([S()],yt.prototype,"_sketchGraphicsLayer",null),e([S()],yt.prototype,"_highlightedFeatureHandle",void 0),e([S()],yt.prototype,"_imageViewer",void 0),e([S()],yt.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],yt.prototype,"_locationPointOnImage",void 0),e([S()],yt.prototype,"_overlays",void 0),e([S({readOnly:!0})],yt.prototype,"_overlaysView",null),e([S()],yt.prototype,"_panoramicViewer",void 0),e([S()],yt.prototype,"_previousCursor",void 0),e([S()],yt.prototype,"_referencePointOnGround",void 0),e([S()],yt.prototype,"_referencePointOnImage",void 0),e([S()],yt.prototype,"_sectorData",void 0),e([S({readOnly:!0})],yt.prototype,"_updatingHandles",void 0),e([S()],yt.prototype,"footprintExtent",void 0),e([S()],yt.prototype,"_featureChangedTask",void 0),yt=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],yt);const ft=yt;export{ft as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{substitute as r}from"../../../intl/substitute.js";import s from"../../Widget.js";import{css as n}from"../css.js";import{copyToClipboard as i}from"../imageMeasurementUtils.js";import{loadCalciteComponents as c}from"../../support/componentsUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let p=class extends s{constructor(o){super(o),this.messages=null}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel")})}get _renderLocation(){const{groundCoordinates:o}=this;return o?a("calcite-block",{heading:this.getLocation(),headingLevel:6},a("calcite-action",{icon:"copy-to-clipboard",onclick:()=>this.copyLocation(),slot:"control",text:"Copy"})):null}copyLocation(){const{groundCoordinates:o}=this;if(!o)return;const t=this.getLocation();t&&i(t)}getLocation(){const{groundCoordinates:o}=this;if(null==o?.longitude||null==o?.latitude)return"";const t={groundX:o.longitude.toFixed(3),groundY:o.latitude.toFixed(3)};return r("{groundX}° , {groundY}°",t)}render(){return a("calcite-panel",{class:n.measurementResults,key:"ground-location-container"},this._renderLocation)}};o([t()],p.prototype,"messages",void 0),o([t()],p.prototype,"groundCoordinates",void 0),o([t()],p.prototype,"_renderLocation",null),p=o([e("esri.widgets.OrientedImageryViewer.components.ImageLocationWidget")],p);const l=p;export{l as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{substitute as o}from"../../../intl/substitute.js";import a from"../../Widget.js";import{css as n}from"../css.js";import{copyToClipboard as l}from"../imageMeasurementUtils.js";import{loadCalciteComponents as i}from"../../support/componentsUtils.js";import{tsx as r}from"../../support/jsxFactory.js";let s=class extends a{constructor(e){super(e),this.messages=null,this.accuracy=null,this._selectedSystem="Basemap",this._handleSystemSelection=e=>{this._selectedSystem=e.target.value}}loadDependencies(){return i({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),select:()=>import("@esri/calcite-components/dist/components/calcite-select"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),table:()=>import("@esri/calcite-components/dist/components/calcite-table"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell")})}get _renderLocationBlock(){const{groundCoordinates:e,_selectedSystem:t}=this;return e&&"XY"===t?r("calcite-block",{heading:this.getLocation(),headingLevel:6}):null}get _renderLocationTable(){const{groundCoordinates:e,messages:t,_selectedSystem:c,accuracy:o}=this,a={groundX:e.x.toFixed(3),accuracyX:o?.x?o.x.toFixed(3):"",groundY:e.y.toFixed(3),accuracyY:o?.y?o.y.toFixed(3):"",groundZ:e.z?e.z.toFixed(3):"",accuracyZ:o?.z?o.z.toFixed(3):""};return e&&"Basemap"===c?r("calcite-table",{bordered:!0,caption:t.measurementTable,class:n.measurementsTable,scale:"s"},r("calcite-table-row",{slot:"table-header"},r("calcite-table-header",{alignment:"center",heading:t.type}),r("calcite-table-header",{alignment:"center",heading:t.value}),r("calcite-table-header",{alignment:"center",heading:t.accuracy})),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.x),r("calcite-table-cell",{alignment:"center"},a.groundX),r("calcite-table-cell",{alignment:"center"},a.accuracyX)),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.y),r("calcite-table-cell",{alignment:"center"},a.groundY),r("calcite-table-cell",{alignment:"center"},a.accuracyY)),r("calcite-table-row",null,r("calcite-table-cell",{alignment:"center"},t.z),r("calcite-table-cell",{alignment:"center"},a.groundZ),r("calcite-table-cell",{alignment:"center"},a.accuracyZ))):null}get _renderSystemSelect(){const{messages:e}=this;return r("div",{class:n.measurementsBar},r("calcite-select",{bind:this,label:e.selectUnitSystem,scale:"m",width:"full",onCalciteSelectChange:this._handleSystemSelection},r("calcite-option",{value:"Basemap"},e.basemap),r("calcite-option",{value:"XY"},e.xy)),r("calcite-action",{icon:"copy-to-clipboard",onclick:()=>this.copyLocation(),scale:"s",slot:"control",text:"Copy"}))}copyLocation(){const{groundCoordinates:e}=this;if(!e)return;const t=this.getLocation();t&&l(t)}getLocation(){const{_selectedSystem:e,groundCoordinates:t,accuracy:c}=this;return"Basemap"===e?this.getBasemapLocation(t,c):this.getXYLocation(t)}getXYLocation(e){if(null==e?.longitude||null==e?.latitude)return"";const t={groundX:e.longitude.toFixed(3),groundY:e.latitude.toFixed(3)};return o("{groundX}° , {groundY}°",t)}getBasemapLocation(e,t){if(null==e?.x||null==e?.y)return"";const c={groundX:e.x.toFixed(3),accuracyX:t?.x?t.x.toFixed(3):0,groundY:e.y.toFixed(3),accuracyY:t?.y?t.y.toFixed(3):0,groundZ:e.z?e.z.toFixed(3):0,accuracyZ:t?.z?t.z.toFixed(3):0};return o("{groundX} ± {accuracyX}, {groundY} ± {accuracyY}, {groundZ} ± {accuracyZ}",c)}render(){return r("calcite-panel",{class:n.measurementResults,key:"ground-location-container"},this._renderSystemSelect,this._renderLocationBlock,this._renderLocationTable)}};e([t()],s.prototype,"messages",void 0),e([t()],s.prototype,"groundCoordinates",void 0),e([t()],s.prototype,"accuracy",void 0),e([t()],s.prototype,"_selectedSystem",void 0),e([t()],s.prototype,"_renderLocationBlock",null),e([t()],s.prototype,"_renderLocationTable",null),e([t()],s.prototype,"_renderSystemSelect",null),s=e([c("esri.widgets.OrientedImageryViewer.components.ImageLocationWidget")],s);const d=s;export{d as default};